Merge pull request #1129 from ONLYOFFICE/feature/bug-fixes

Feature/bug fixes
This commit is contained in:
maxkadushkin 2021-08-27 11:52:39 +03:00 committed by GitHub
commit bed8b542ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 32 deletions

View file

@ -12,28 +12,6 @@ const PageDocumentFormats = props => {
const pageSizesIndex = storeSettings.pageSizesIndex; const pageSizesIndex = storeSettings.pageSizesIndex;
const pageSizes = storeSettings.getPageSizesList(); const pageSizes = storeSettings.getPageSizesList();
const textMetric = Common.Utils.Metric.getCurrentMetricName(); const textMetric = Common.Utils.Metric.getCurrentMetricName();
const margins = props.getMargins();
const maxMarginsW = margins.maxMarginsW;
const maxMarginsH = margins.maxMarginsH;
// console.log(margins.left, margins.right, margins.top, margins.bottom);
// console.log(maxMarginsW, maxMarginsH);
const onFormatChange = (value) => {
let errorMsg;
if (margins.left + margins.right > maxMarginsW) {
errorMsg = _t.textMarginsW;
} else if (margins.top + margins.bottom > maxMarginsH) {
errorMsg = _t.textMarginsH;
}
if(errorMsg) {
f7.dialog.alert(errorMsg, _t.notcriticalErrorTitle);
} else {
props.onFormatChange(value);
}
}
return ( return (
<Page> <Page>
@ -45,7 +23,7 @@ const PageDocumentFormats = props => {
subtitle={parseFloat(Common.Utils.Metric.fnRecalcFromMM(item.value[0]).toFixed(2)) + ' ' + textMetric + ' x ' + parseFloat(Common.Utils.Metric.fnRecalcFromMM(item.value[1]).toFixed(2)) + ' ' + textMetric} subtitle={parseFloat(Common.Utils.Metric.fnRecalcFromMM(item.value[0]).toFixed(2)) + ' ' + textMetric + ' x ' + parseFloat(Common.Utils.Metric.fnRecalcFromMM(item.value[1]).toFixed(2)) + ' ' + textMetric}
name="format-size-checkbox" name="format-size-checkbox"
checked={pageSizesIndex === index} checked={pageSizesIndex === index}
onClick={e => onFormatChange(item.value)} onClick={e => props.onFormatChange(item.value)}
></ListItem>)} ></ListItem>)}
</List> </List>
</Page> </Page>
@ -58,6 +36,8 @@ const PageDocumentMargins = props => {
const _t = t('Settings', {returnObjects: true}); const _t = t('Settings', {returnObjects: true});
const metricText = Common.Utils.Metric.getMetricName(Common.Utils.Metric.getCurrentMetric()); const metricText = Common.Utils.Metric.getMetricName(Common.Utils.Metric.getCurrentMetric());
const margins = props.getMargins(); const margins = props.getMargins();
const maxMarginsW = margins.maxMarginsW;
const maxMarginsH = margins.maxMarginsH;
const [stateTop, setTop] = useState(margins.top); const [stateTop, setTop] = useState(margins.top);
const [stateBottom, setBottom] = useState(margins.bottom); const [stateBottom, setBottom] = useState(margins.bottom);
const [stateLeft, setLeft] = useState(margins.left); const [stateLeft, setLeft] = useState(margins.left);
@ -65,7 +45,7 @@ const PageDocumentMargins = props => {
const onChangeMargins = (align, isDecrement) => { const onChangeMargins = (align, isDecrement) => {
const step = Common.Utils.Metric.fnRecalcToMM(Common.Utils.Metric.getCurrentMetric() === Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1); const step = Common.Utils.Metric.fnRecalcToMM(Common.Utils.Metric.getCurrentMetric() === Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
let marginValue; let marginValue, errorMsg;
switch (align) { switch (align) {
case 'left': marginValue = stateLeft; break; case 'left': marginValue = stateLeft; break;
@ -77,7 +57,21 @@ const PageDocumentMargins = props => {
if (isDecrement) { if (isDecrement) {
marginValue = Math.max(0, marginValue - step); marginValue = Math.max(0, marginValue - step);
} else { } else {
marginValue = Math.min((align == 'left' || align == 'right') ? margins.maxMarginsW : margins.maxMarginsH, marginValue + step); if(align == 'left' || align == 'right') {
marginValue = Math.min(maxMarginsW, marginValue + step);
if(stateLeft + stateRight + step > maxMarginsW)
errorMsg = _t.textMarginsW;
} else {
marginValue = Math.min(maxMarginsH, marginValue + step);
if(stateTop + stateBottom + step > maxMarginsH)
errorMsg = _t.textMarginsH;
}
if(errorMsg) {
f7.dialog.alert(errorMsg, _t.notcriticalErrorTitle);
return;
}
} }
switch (align) { switch (align) {

View file

@ -138,7 +138,7 @@ class EditTextController extends Component {
} else { } else {
typeof size === 'undefined' || size == '' ? api.FontSizeIn() : size = Math.min(300, ++size); typeof size === 'undefined' || size == '' ? api.FontSizeIn() : size = Math.min(300, ++size);
} }
if (typeof size !== 'undefined' || size == '') { if (typeof size !== 'undefined' && size !== '') {
api.put_TextPrFontSize(size); api.put_TextPrFontSize(size);
} }
}; };

View file

@ -328,7 +328,6 @@ const EditLayoutContent = ({ editors }) => {
const EditTabs = props => { const EditTabs = props => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t('View.Edit', {returnObjects: true}); const _t = t('View.Edit', {returnObjects: true});
const store = props.storeFocusObjects; const store = props.storeFocusObjects;
const settings = !store.focusOn ? [] : (store.focusOn === 'obj' ? store.objects : store.selections); const settings = !store.focusOn ? [] : (store.focusOn === 'obj' ? store.objects : store.selections);
let editors = []; let editors = [];
@ -374,7 +373,7 @@ const EditTabs = props => {
component: <EditChartController /> component: <EditChartController />
}) })
} }
if (settings.indexOf('hyperlink') > -1) { if (settings.indexOf('hyperlink') > -1 || (props.hyperinfo && props.isAddShapeHyperlink)) {
editors.push({ editors.push({
caption: _t.textHyperlink, caption: _t.textHyperlink,
id: 'edit-link', id: 'edit-link',
@ -404,10 +403,10 @@ const EditView = props => {
return ( return (
show_popover ? show_popover ?
<Popover id="edit-popover" className="popover__titled" onPopoverClosed={() => props.onClosed()}> <Popover id="edit-popover" className="popover__titled" onPopoverClosed={() => props.onClosed()}>
<EditTabsContainer inPopover={true} onOptionClick={onOptionClick} style={{height: '410px'}} /> <EditTabsContainer isAddShapeHyperlink={props.isAddShapeHyperlink} hyperinfo={props.hyperinfo} inPopover={true} onOptionClick={onOptionClick} style={{height: '410px'}} />
</Popover> : </Popover> :
<Sheet id="edit-sheet" push onSheetClosed={() => props.onClosed()}> <Sheet id="edit-sheet" push onSheetClosed={() => props.onClosed()}>
<EditTabsContainer onOptionClick={onOptionClick} /> <EditTabsContainer isAddShapeHyperlink={props.isAddShapeHyperlink} hyperinfo={props.hyperinfo} onOptionClick={onOptionClick} />
</Sheet> </Sheet>
) )
}; };
@ -428,8 +427,13 @@ const EditOptions = props => {
props.onclosed(); props.onclosed();
}; };
const api = Common.EditorApi.get();
const cellinfo = api.asc_getCellInfo();
const hyperinfo = cellinfo.asc_getHyperlink();
const isAddShapeHyperlink = api.asc_canAddShapeHyperlink();
return ( return (
<EditView usePopover={!Device.phone} onClosed={onviewclosed} /> <EditView usePopover={!Device.phone} onClosed={onviewclosed} isAddShapeHyperlink={isAddShapeHyperlink} hyperinfo={hyperinfo} />
) )
}; };