Explorar o código

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

Michael Wang %!s(int64=4) %!d(string=hai) anos
pai
achega
9f4543b707
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      src/components/VEditor/VEditor.vue

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

@@ -36,6 +36,14 @@ export default {
   },
   mounted() {
     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: {
     emitJSON() {