Browse Source

点击其他位置收回富文本编辑器工具栏抽屉

dusenyao 1 year ago
parent
commit
c1628331fd
1 changed files with 10 additions and 0 deletions
  1. 10 0
      src/components/common/RichText.vue

+ 10 - 0
src/components/common/RichText.vue

@@ -164,11 +164,13 @@ export default {
     };
     };
   },
   },
   created() {
   created() {
+    window.addEventListener('click', this.hideToolbarDrawer);
     if (this.isFill) {
     if (this.isFill) {
       window.addEventListener('click', this.hideContentmenu);
       window.addEventListener('click', this.hideContentmenu);
     }
     }
   },
   },
   beforeDestroy() {
   beforeDestroy() {
+    window.removeEventListener('click', this.hideToolbarDrawer);
     if (this.isFill) {
     if (this.isFill) {
       window.removeEventListener('click', this.hideContentmenu);
       window.removeEventListener('click', this.hideContentmenu);
     }
     }
@@ -367,6 +369,14 @@ export default {
       this.deleteContent();
       this.deleteContent();
       this.hideContentmenu();
       this.hideContentmenu();
     },
     },
+    // 隐藏工具栏抽屉
+    hideToolbarDrawer() {
+      let editor = tinymce.get(this.id);
+      if (editor.queryCommandState('ToggleToolbarDrawer')) {
+        editor.execCommand('ToggleToolbarDrawer');
+      }
+    },
+    // 隐藏填空右键菜单
     hideContentmenu() {
     hideContentmenu() {
       this.isShow = false;
       this.isShow = false;
     },
     },