张延森 5 jaren geleden
bovenliggende
commit
54d89b7850
1 gewijzigde bestanden met toevoegingen van 15 en 0 verwijderingen
  1. 15
    0
      src/components/Wangedit/Wangedit.jsx

+ 15
- 0
src/components/Wangedit/Wangedit.jsx Bestand weergeven

60
       'undo',  // 撤销
60
       'undo',  // 撤销
61
       'redo'  // 重复
61
       'redo'  // 重复
62
     ]
62
     ]
63
+    
64
+    // 过滤 word 字符
65
+    this.editor.customConfig.pasteFilterStyle = false
66
+    this.editor.customConfig.pasteTextHandle = function(content) {
67
+      const regs = [
68
+        /<!--\[if [\s\S]*?endif\]-->/ig,
69
+        /<[a-zA-Z0-9]+\:[^>]+>[^>]*<\/[a-zA-Z0-9]+\:[^>]+>/ig,
70
+        /<[a-zA-Z0-9]+\:[^>]+\/>/ig,
71
+        /<style>[\s\S]*?<\/style>/ig,
72
+      ]
73
+
74
+      return regs.reduce((acc, reg) => {
75
+        return acc.replace(reg, '')
76
+      }, content)
77
+    }
63
 
78
 
64
     this.editor.create()
79
     this.editor.create()
65
     this.editor.customConfig.uploadImgShowBase64 = true
80
     this.editor.customConfig.uploadImgShowBase64 = true