Jelajahi Sumber

富文本注释修正

zq 4 hari lalu
induk
melakukan
0eaa7bf46f
1 mengubah file dengan 11 tambahan dan 17 penghapusan
  1. 11 17
      src/components/RichText.vue

+ 11 - 17
src/components/RichText.vue

@@ -1,16 +1,7 @@
 <template>
   <div ref="richArea" class="rich-wrapper">
-    <Editor
-      v-bind="$attrs"
-      :id="id"
-      ref="richText"
-      model-events="change keyup undo redo setContent"
-      :value="value"
-      :class="['rich-text', isBorder ? 'is-border' : '']"
-      :init="init"
-      v-on="$listeners"
-      @onBlur="handleRichTextBlur"
-    />
+    <Editor v-bind="$attrs" :id="id" ref="richText" model-events="change keyup undo redo setContent" :value="value"
+      :class="['rich-text', isBorder ? 'is-border' : '']" :init="init" v-on="$listeners" @onBlur="handleRichTextBlur" />
     <div v-show="isShow" :style="contentmenu" class="contentmenu">
       <div v-if="isViewNote" @click="openExplanatoryNoteDialog">
         <SvgIcon icon-class="mark" size="14" />
@@ -662,6 +653,9 @@ export default {
     getRichContent() {
       return tinymce.get(this.id).getContent();
     },
+    getRichSelectionContent() {
+      return tinymce.get(this.id).selection.getContent();
+    },
     displayToolbar(isTitle, isInit) {
       if (!this.editorIsInited) {
         this.editorBeforeInitConfig['isTitle'] = isTitle;
@@ -1005,7 +999,7 @@ export default {
       let start = editor.selection.getStart();
       if (isNodeType(start, 'span')) {
         let textContent = start.textContent;
-        let content = this.getRichContent();
+        let content = this.getRichSelectionContent();
         let str = textContent.split(content);
         start.remove();
         editor.selection.setContent(str.join(content));
@@ -1017,7 +1011,7 @@ export default {
     setContent() {
       let editor = tinymce.get(this.id);
       let start = editor.selection.getStart();
-      let content = this.getRichContent();
+      let content = this.getRichSelectionContent();
       if (isNodeType(start, 'span')) {
         let textContent = start.textContent;
         let str = textContent.split(content);
@@ -1184,7 +1178,7 @@ export default {
       let noteId = '';
       let editor = tinymce.get(this.id);
       let start = editor.selection.getStart();
-      let content = this.getRichContent();
+      let content = this.getRichSelectionContent();
       if (isNodeType(start, 'span')) {
         noteId = start.getAttribute('data-annotation-id');
       } else {
@@ -1204,7 +1198,7 @@ export default {
       let start = editor.selection.getStart();
       if (isNodeType(start, 'span')) {
         let textContent = start.textContent;
-        let content = this.getRichContent();
+        let content = this.getRichSelectionContent();
         let str = textContent.split(content);
         start.remove();
         editor.selection.setContent(str.join(content));
@@ -1326,7 +1320,7 @@ export default {
 
 <style lang="scss" scoped>
 .rich-text {
-  :deep + .tox {
+  :deep+.tox {
     .tox-sidebar-wrap {
       border: 1px solid $fill-color;
       border-radius: 4px;
@@ -1351,7 +1345,7 @@ export default {
   }
 
   &.is-border {
-    :deep + .tox.tox-tinymce {
+    :deep+.tox.tox-tinymce {
       border: $border;
       border-radius: 4px;
     }