|
@@ -123,7 +123,12 @@ export default {
|
|
},
|
|
},
|
|
execCommand(command, event) {
|
|
execCommand(command, event) {
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
- document.execCommand(command);
|
|
|
|
|
|
+ if (!this.checkEditorFocus()) {
|
|
|
|
+ window.getSelection().removeAllRanges();
|
|
|
|
+ this.$el.nextSibling.focus();
|
|
|
|
+ } else {
|
|
|
|
+ document.execCommand(command);
|
|
|
|
+ }
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
* @param {Event} event
|
|
* @param {Event} event
|
|
@@ -147,27 +152,30 @@ export default {
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
answerPointHandle.bind(this.$parent)(event);
|
|
answerPointHandle.bind(this.$parent)(event);
|
|
},
|
|
},
|
|
|
|
+ checkEditorFocus() {
|
|
|
|
+ const selection = window.getSelection();
|
|
|
|
+ return selection.focusNode && this.checkDomInEditor(selection.focusNode);
|
|
|
|
+ },
|
|
/**
|
|
/**
|
|
* @param {Event} event
|
|
* @param {Event} event
|
|
*/
|
|
*/
|
|
addFormula(event) {
|
|
addFormula(event) {
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
- const selection = window.getSelection();
|
|
|
|
- if (selection.focusNode && this.checkDomInEditor(selection.focusNode)) {
|
|
|
|
- this.curEditFocusRange = selection.getRangeAt(0);
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (!this.checkEditorFocus()) {
|
|
|
|
+ window.getSelection().removeAllRanges();
|
|
this.$el.nextSibling.focus();
|
|
this.$el.nextSibling.focus();
|
|
- const selection = window.getSelection();
|
|
|
|
- this.curEditFocusRange = selection.getRangeAt(0);
|
|
|
|
}
|
|
}
|
|
|
|
+ this.curEditFocusRange = window.getSelection().getRangeAt(0);
|
|
this.$refs.FormulaDialog.open();
|
|
this.$refs.FormulaDialog.open();
|
|
},
|
|
},
|
|
checkDomInEditor(dom) {
|
|
checkDomInEditor(dom) {
|
|
|
|
+ const editorUid = this.$parent["_uid"];
|
|
|
|
+ const siblingBodyCls = `v-editor-body-${editorUid}`;
|
|
let parentNode = dom;
|
|
let parentNode = dom;
|
|
while (
|
|
while (
|
|
!(
|
|
!(
|
|
(parentNode.className &&
|
|
(parentNode.className &&
|
|
- parentNode.className.includes("v-editor-body")) ||
|
|
|
|
|
|
+ parentNode.className.includes(siblingBodyCls)) ||
|
|
parentNode.nodeName === "BODY"
|
|
parentNode.nodeName === "BODY"
|
|
)
|
|
)
|
|
) {
|
|
) {
|
|
@@ -175,7 +183,7 @@ export default {
|
|
}
|
|
}
|
|
|
|
|
|
return (
|
|
return (
|
|
- parentNode.className && parentNode.className.includes("v-editor-body")
|
|
|
|
|
|
+ parentNode.className && parentNode.className.includes(siblingBodyCls)
|
|
);
|
|
);
|
|
},
|
|
},
|
|
formulaConfirm(result) {
|
|
formulaConfirm(result) {
|