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

Feature/bug fixes
This commit is contained in:
maxkadushkin 2021-07-12 16:48:33 +03:00 committed by GitHub
commit cd9ff4a918
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 241 additions and 83 deletions

View file

@ -614,15 +614,17 @@ const pickLink = (message) => {
arrayComment = arrayComment.sort(function(item1,item2){ return item1.start - item2.start; }); arrayComment = arrayComment.sort(function(item1,item2){ return item1.start - item2.start; });
let str_res = (arrayComment.length>0) ? <label>{Common.Utils.String.htmlEncode(message.substring(0, arrayComment[0].start))}{arrayComment[0].str}</label> : <label>{Common.Utils.String.htmlEncode(message)}</label>; let str_res = (arrayComment.length>0) ? <label>{Common.Utils.String.htmlEncode(message.substring(0, arrayComment[0].start))}{arrayComment[0].str}</label> : <label>{message}</label>;
for (var i=1; i<arrayComment.length; i++) { for (var i=1; i<arrayComment.length; i++) {
str_res = <label>{str_res}{Common.Utils.String.htmlEncode(message.substring(arrayComment[i-1].end, arrayComment[i].start))}{arrayComment[i].str}</label>; str_res = <label>{str_res}{Common.Utils.String.htmlEncode(message.substring(arrayComment[i-1].end, arrayComment[i].start))}{arrayComment[i].str}</label>;
} }
if (arrayComment.length>0) { if (arrayComment.length>0) {
str_res = <label>{str_res}{Common.Utils.String.htmlEncode(message.substring(arrayComment[i-1].end, message.length))}</label>; str_res = <label>{str_res}{Common.Utils.String.htmlEncode(message.substring(arrayComment[i-1].end, message.length))}</label>;
} }
return str_res;
return str_res;
} }
// View comments // View comments

View file

@ -6,6 +6,9 @@
"X Axis": "X Axis XAS", "X Axis": "X Axis XAS",
"Y Axis": "Y Axis", "Y Axis": "Y Axis",
"Your text here": "Your text here", "Your text here": "Your text here",
"Error! Bookmark not defined": "Error! Bookmark not defined.",
"above": "above",
"below": "below",
"Footer": "Footer", "Footer": "Footer",
"Header": "Header", "Header": "Header",
"Normal": "Normal", "Normal": "Normal",
@ -24,7 +27,40 @@
"Quote": "Quote", "Quote": "Quote",
"Intense Quote": "Intense Quote", "Intense Quote": "Intense Quote",
"List Paragraph": "List Paragraph", "List Paragraph": "List Paragraph",
"footnote text": "Footnote Text" "footnote text": "Footnote Text",
"Caption": "Caption",
"endnote text": "Endnote Text",
" -Section ": " -Section ",
"First Page ": "First Page ",
"Even Page ": "Even Page ",
"Odd Page ": "Odd Page ",
"Same as Previous": "Same as Previous",
"Current Document": "Current Document",
"No table of contents entries found.": "There are no headings in the document. Apply a heading style to the text so that it appears in the table of contents.",
"Table of Contents": "Table of Contents",
"Syntax Error": "Syntax Error",
"Missing Operator": "Missing Operator",
"Missing Argument": "Missing Argument",
"Number Too Large To Format": "Number Too Large To Format",
"Zero Divide": "Zero Divide",
"Is Not In Table": "Is Not In Table",
"Index Too Large": "Index Too Large",
"The Formula Not In Table": "The Formula Not In Table",
"Table Index Cannot be Zero": "Table Index Cannot be Zero",
"Undefined Bookmark": "Undefined Bookmark",
"Unexpected End of Formula": "Unexpected End of Formula",
"Hyperlink": "Hyperlink",
"Error! Main Document Only.": "Error! Main Document Only.",
"Error! Not a valid bookmark self-reference.": "Error! Not a valid bookmark self-reference.",
"Error! No text of specified style in document.": "Error! No text of specified style in document.",
"Choose an item": "Choose an item",
"Enter a date": "Enter a date",
"Type equation here": "Type equation here",
"Click to load image": "Click to load image",
"None": "None",
"No table of figures entries found.": "No table of figures entries found.",
"table of figures": "Table of figures",
"TOC Heading": "TOC Heading"
}, },
"textGuest": "Guest", "textGuest": "Guest",
"textAnonymous": "Anonymous", "textAnonymous": "Anonymous",

View file

@ -26,7 +26,8 @@ import PluginsController from '../../../../common/mobile/lib/controller/Plugins.
"storeTableSettings", "storeTableSettings",
"storeDocumentInfo", "storeDocumentInfo",
"storeChartSettings", "storeChartSettings",
"storeApplicationSettings" "storeApplicationSettings",
"storeLinkSettings"
) )
class MainController extends Component { class MainController extends Component {
constructor(props) { constructor(props) {
@ -572,6 +573,12 @@ class MainController extends Component {
storeTextSettings.resetBackgroundColor(color); storeTextSettings.resetBackgroundColor(color);
}); });
// link settings
const storeLinkSettings = this.props.storeLinkSettings;
this.api.asc_registerCallback('asc_onCanAddHyperlink', (value) => {
storeLinkSettings.canAddHyperlink(value);
});
//paragraph settings //paragraph settings
EditorUIController.initEditorStyles && EditorUIController.initEditorStyles(this.props.storeParagraphSettings); EditorUIController.initEditorStyles && EditorUIController.initEditorStyles(this.props.storeParagraphSettings);

View file

@ -242,7 +242,8 @@ class AddOtherController extends Component {
render () { render () {
return ( return (
<AddOther closeModal={this.closeModal} <AddOther
closeModal={this.closeModal}
onInsertPageNumber={this.onInsertPageNumber} onInsertPageNumber={this.onInsertPageNumber}
onPageBreak={this.onPageBreak} onPageBreak={this.onPageBreak}
onColumnBreak={this.onColumnBreak} onColumnBreak={this.onColumnBreak}
@ -252,6 +253,14 @@ class AddOtherController extends Component {
onFootnoteStartAt={this.onFootnoteStartAt} onFootnoteStartAt={this.onFootnoteStartAt}
onInsertFootnote={this.onInsertFootnote} onInsertFootnote={this.onInsertFootnote}
initFootnoteStartAt={this.initFootnoteStartAt} initFootnoteStartAt={this.initFootnoteStartAt}
inFootnote={this.props.inFootnote}
inControl={this.props.inControl}
paragraphLocked={this.props.paragraphLocked}
controlPlain={this.props.controlPlain}
richDelLock={this.props.richDelLock}
richEditLock={this.props.richEditLock}
plainDelLock={this.props.plainDelLock}
plainEditLock={this.props.plainEditLock}
/> />
) )
} }

View file

@ -0,0 +1,16 @@
import {action, observable, makeObservable} from 'mobx';
export class storeLinkSettings {
constructor() {
makeObservable(this, {
canAddLink: observable,
canAddHyperlink: action
});
}
canAddLink;
canAddHyperlink (value) {
this.canAddLink = value;
}
}

View file

@ -9,6 +9,7 @@ import {storeImageSettings} from "./imageSettings";
import {storeTableSettings} from "./tableSettings"; import {storeTableSettings} from "./tableSettings";
import {storeChartSettings} from "./chartSettings"; import {storeChartSettings} from "./chartSettings";
import {storeDocumentInfo} from "./documentInfo"; import {storeDocumentInfo} from "./documentInfo";
import {storeLinkSettings} from './linkSettings';
import {storeApplicationSettings} from './applicationSettings'; import {storeApplicationSettings} from './applicationSettings';
import {storeAppOptions} from "./appOptions"; import {storeAppOptions} from "./appOptions";
import {storePalette} from "./palette"; import {storePalette} from "./palette";
@ -21,6 +22,7 @@ export const stores = {
storeDocumentSettings: new storeDocumentSettings(), storeDocumentSettings: new storeDocumentSettings(),
users: new storeUsers(), users: new storeUsers(),
storeTextSettings: new storeTextSettings(), storeTextSettings: new storeTextSettings(),
storeLinkSettings: new storeLinkSettings(),
storeParagraphSettings: new storeParagraphSettings(), storeParagraphSettings: new storeParagraphSettings(),
storeShapeSettings: new storeShapeSettings(), storeShapeSettings: new storeShapeSettings(),
storeChartSettings: new storeChartSettings(), storeChartSettings: new storeChartSettings(),

View file

@ -79,9 +79,49 @@ const AddLayoutContent = ({ tabs }) => {
const AddTabs = inject("storeFocusObjects")(observer(({storeFocusObjects, showPanels, style, inPopover}) => { const AddTabs = inject("storeFocusObjects")(observer(({storeFocusObjects, showPanels, style, inPopover}) => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t('Add', {returnObjects: true}); const _t = t('Add', {returnObjects: true});
const api = Common.EditorApi.get();
const tabs = []; const tabs = [];
const options = storeFocusObjects.settings; const options = storeFocusObjects.settings;
const paragraphObj = storeFocusObjects.paragraphObject;
let needDisable = false,
canAddTable = true,
canAddImage = true,
paragraphLocked = false,
inFootnote = false,
inControl = false,
controlProps = false,
lockType = false,
controlPlain = false,
contentLocked = false,
richDelLock = false,
richEditLock = false,
plainDelLock = false,
plainEditLock = false;
if(paragraphObj) {
canAddTable = paragraphObj.get_CanAddTable();
canAddImage = paragraphObj.get_CanAddImage();
paragraphLocked = paragraphObj.get_Locked();
inFootnote = api.asc_IsCursorInFootnote() || api.asc_IsCursorInEndnote();
inControl = api.asc_IsContentControl();
controlProps = inControl ? api.asc_GetContentControlProperties() : null;
lockType = (inControl && controlProps) ? controlProps.get_Lock() : Asc.c_oAscSdtLockType.Unlocked;
controlPlain = (inControl && controlProps) ? (controlProps.get_ContentControlType() == Asc.c_oAscSdtLevelType.Inline) : false;
contentLocked = lockType == Asc.c_oAscSdtLockType.SdtContentLocked || lockType == Asc.c_oAscSdtLockType.ContentLocked;
richDelLock = paragraphObj ? !paragraphObj.can_DeleteBlockContentControl() : false;
richEditLock = paragraphObj ? !paragraphObj.can_EditBlockContentControl() : false;
plainDelLock = paragraphObj ? !paragraphObj.can_DeleteInlineContentControl() : false;
plainEditLock = paragraphObj ? !paragraphObj.can_EditInlineContentControl() : false;
}
if (!showPanels && options.indexOf('text') > -1) { if (!showPanels && options.indexOf('text') > -1) {
needDisable = !canAddTable || controlPlain || richEditLock || plainEditLock || richDelLock || plainDelLock;
if(!needDisable) {
tabs.push({ tabs.push({
caption: _t.textTable, caption: _t.textTable,
id: 'add-table', id: 'add-table',
@ -89,7 +129,11 @@ const AddTabs = inject("storeFocusObjects")(observer(({storeFocusObjects, showPa
component: <AddTableController/> component: <AddTableController/>
}); });
} }
}
if(!showPanels) { if(!showPanels) {
needDisable = paragraphLocked || controlPlain || contentLocked || inFootnote;
if(!needDisable) {
tabs.push({ tabs.push({
caption: _t.textShape, caption: _t.textShape,
id: 'add-shape', id: 'add-shape',
@ -97,7 +141,11 @@ const AddTabs = inject("storeFocusObjects")(observer(({storeFocusObjects, showPa
component: <AddShapeController/> component: <AddShapeController/>
}); });
} }
}
if(!showPanels) { if(!showPanels) {
needDisable = paragraphLocked || paragraphObj && !canAddImage || controlPlain || richDelLock || plainDelLock || contentLocked;
if(!needDisable) {
tabs.push({ tabs.push({
caption: _t.textImage, caption: _t.textImage,
id: 'add-image', id: 'add-image',
@ -105,12 +153,23 @@ const AddTabs = inject("storeFocusObjects")(observer(({storeFocusObjects, showPa
component: <AddImageController/> component: <AddImageController/>
}); });
} }
}
if(!showPanels) { if(!showPanels) {
tabs.push({ tabs.push({
caption: _t.textOther, caption: _t.textOther,
id: 'add-other', id: 'add-other',
icon: 'icon-add-other', icon: 'icon-add-other',
component: <AddOtherController/> component:
<AddOtherController
inFootnote={inFootnote}
inControl={inControl}
paragraphLocked={paragraphLocked}
controlPlain={controlPlain}
richDelLock={richDelLock}
richEditLock={richEditLock}
plainDelLock={plainDelLock}
plainEditLock={plainEditLock}
/>
}); });
} }
if (showPanels && showPanels === 'link') { if (showPanels && showPanels === 'link') {

View file

@ -153,40 +153,63 @@ const PageFootnote = props => {
const AddOther = props => { const AddOther = props => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t('Add', {returnObjects: true}); const _t = t('Add', {returnObjects: true});
const storeFocusObjects = props.storeFocusObjects; const storeFocusObjects = props.storeFocusObjects;
const storeLinkSettings = props.storeLinkSettings;
const canAddLink = storeLinkSettings.canAddLink;
let isShape = storeFocusObjects.settings.indexOf('shape') > -1, let isShape = storeFocusObjects.settings.indexOf('shape') > -1,
isText = storeFocusObjects.settings.indexOf('text') > -1, isText = storeFocusObjects.settings.indexOf('text') > -1,
isChart = storeFocusObjects.settings.indexOf('chart') > -1; isChart = storeFocusObjects.settings.indexOf('chart') > -1;
let disabledAddLink = false,
disabledAddBreak = false,
disabledAddFootnote = false,
disabledAddPageNumber = false,
inFootnote = props.inFootnote,
inControl = props.inControl,
paragraphLocked = props.paragraphLocked,
controlPlain = props.controlPlain,
richDelLock = props.richDelLock,
richEditLock = props.richEditLock,
plainDelLock = props.plainDelLock,
plainEditLock = props.plainEditLock;
disabledAddBreak = paragraphLocked || inFootnote || inControl || richEditLock || plainEditLock || richDelLock || plainDelLock;
disabledAddFootnote = paragraphLocked || controlPlain || richEditLock || plainEditLock;
disabledAddLink = paragraphLocked || !canAddLink;
disabledAddPageNumber = controlPlain;
return ( return (
<List> <List>
{isText &&<ListItem title={_t.textComment} onClick={() => { {isText && <ListItem title={_t.textComment} onClick={() => {
props.closeModal(); props.closeModal();
Common.Notifications.trigger('addcomment'); Common.Notifications.trigger('addcomment');
}}> }}>
<Icon slot="media" icon="icon-insert-comment"></Icon> <Icon slot="media" icon="icon-insert-comment"></Icon>
</ListItem>} </ListItem>}
{isText && <ListItem title={_t.textLink} link={'/add-link/'} routeProps={{ {(isText && !disabledAddLink) && <ListItem title={_t.textLink} link={'/add-link/'} routeProps={{
onInsertLink: props.onInsertLink, onInsertLink: props.onInsertLink,
getDisplayLinkText: props.getDisplayLinkText getDisplayLinkText: props.getDisplayLinkText
}}> }}>
<Icon slot="media" icon="icon-link"></Icon> <Icon slot="media" icon="icon-link"></Icon>
</ListItem>} </ListItem>}
{!disabledAddPageNumber &&
<ListItem title={_t.textPageNumber} link={'/add-page-number/'} routeProps={{ <ListItem title={_t.textPageNumber} link={'/add-page-number/'} routeProps={{
onInsertPageNumber: props.onInsertPageNumber onInsertPageNumber: props.onInsertPageNumber
}}> }}>
<Icon slot="media" icon="icon-pagenumber"></Icon> <Icon slot="media" icon="icon-pagenumber"></Icon>
</ListItem> </ListItem>
{(isShape || isChart) ? null : }
[ <ListItem key='break' title={_t.textBreak} link={'/add-break/'} routeProps={{ {(isShape || isChart) || (isText && disabledAddBreak) ? null :
<ListItem key='break' title={_t.textBreak} link={'/add-break/'} routeProps={{
onPageBreak: props.onPageBreak, onPageBreak: props.onPageBreak,
onColumnBreak: props.onColumnBreak, onColumnBreak: props.onColumnBreak,
onInsertSectionBreak: props.onInsertSectionBreak onInsertSectionBreak: props.onInsertSectionBreak
}}> }}>
<Icon slot="media" icon="icon-sectionbreak"></Icon> <Icon slot="media" icon="icon-sectionbreak"></Icon>
</ListItem>, </ListItem>
}
{(isShape || isChart) || (isText && disabledAddFootnote) ? null :
<ListItem key='footnote' title={_t.textFootnote} link={'/add-footnote/'} routeProps={{ <ListItem key='footnote' title={_t.textFootnote} link={'/add-footnote/'} routeProps={{
getFootnoteProps: props.getFootnoteProps, getFootnoteProps: props.getFootnoteProps,
getFootnoteStartAt: props.getFootnoteStartAt, getFootnoteStartAt: props.getFootnoteStartAt,
@ -195,13 +218,13 @@ const AddOther = props => {
initFootnoteStartAt: props.initFootnoteStartAt initFootnoteStartAt: props.initFootnoteStartAt
}}> }}>
<Icon slot="media" icon="icon-footnote"></Icon> <Icon slot="media" icon="icon-footnote"></Icon>
</ListItem> ] </ListItem>
} }
</List> </List>
) )
}; };
const AddOtherContainer = inject("storeComments","storeFocusObjects")(observer(AddOther)); const AddOtherContainer = inject("storeComments","storeFocusObjects", "storeLinkSettings")(observer(AddOther));
export {AddOtherContainer as AddOther, export {AddOtherContainer as AddOther,
PageNumber as PageAddNumber, PageNumber as PageAddNumber,

View file

@ -20,7 +20,11 @@
"Slide number": "Slide number", "Slide number": "Slide number",
"Slide subtitle": "Slide subtitle", "Slide subtitle": "Slide subtitle",
"Table": "Table", "Table": "Table",
"Slide title": "Slide title" "Slide title": "Slide title",
"Loading": "Loading",
"Click to add notes": "Click to add notes",
"Click to add first slide": "Click to add first slide",
"None": "None"
}, },
"textGuest": "Guest", "textGuest": "Guest",
"textAnonymous": "Anonymous", "textAnonymous": "Anonymous",