浏览代码

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

dusenyao 1 年之前
父节点
当前提交
c1628331fd
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      src/components/common/RichText.vue

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

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