Procházet zdrojové kódy

优化:编辑器点击富文本框,提示语不消失

zq před 1 měsícem
rodič
revize
a1a46caa08
1 změnil soubory, kde provedl 23 přidání a 0 odebrání
  1. 23 0
      src/components/RichText.vue

+ 23 - 0
src/components/RichText.vue

@@ -553,6 +553,29 @@ export default {
           //     this.$emit('selectContentSetMemo', null, annotationId);
           //   }
           // });
+
+          editor.on('focus', () => {
+            const body = editor.getBody();
+            if (body && body.hasAttribute('data-mce-placeholder')) {
+              body.removeAttribute('data-mce-placeholder');
+            }
+          });
+          editor.on('blur', () => {
+            const body = editor.getBody();
+            const content = editor.getContent({ format: 'text' }).trim();
+            if (body && !content && this.placeholder) {
+              body.setAttribute('data-mce-placeholder', this.placeholder);
+            }
+          });
+          editor.on('input', () => {
+            const body = editor.getBody();
+            const content = editor.getContent({ format: 'text' }).trim();
+            if (body && content && body.hasAttribute('data-mce-placeholder')) {
+              body.removeAttribute('data-mce-placeholder');
+            } else if (body && !content && !body.hasAttribute('data-mce-placeholder') && this.placeholder) {
+              body.setAttribute('data-mce-placeholder', this.placeholder);
+            }
+          });
         },
         font_formats:
           '楷体=楷体,微软雅黑;' +