Browse Source

富文本编辑器粘贴时转换为text

Michael Wang 4 years ago
parent
commit
9f4543b707
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/components/VEditor/VEditor.vue

+ 8 - 0
src/components/VEditor/VEditor.vue

@@ -36,6 +36,14 @@ export default {
   },
   },
   mounted() {
   mounted() {
     renderRichText(JSON.parse(this.value), this.$refs.editor);
     renderRichText(JSON.parse(this.value), this.$refs.editor);
+
+    this.$refs.editor.addEventListener("paste", (event) => {
+      event.preventDefault();
+      let pasteText = (event.clipboardData || window.clipboardData).getData(
+        "text"
+      );
+      document.execCommand("insertText", false, pasteText);
+    });
   },
   },
   methods: {
   methods: {
     emitJSON() {
     emitJSON() {