From c40e9437492f6973e631f42d8859d50182f777df Mon Sep 17 00:00:00 2001
From: long <515897141@qq.com>
Date: 星期一, 24 一月 2022 10:01:36 +0800
Subject: [PATCH] 删除富文本组件多余代码

---
 src/components/WangEnduit/index.vue |   72 +++++++++++++++++++++++++++++------
 1 files changed, 59 insertions(+), 13 deletions(-)

diff --git a/src/components/WangEnduit/index.vue b/src/components/WangEnduit/index.vue
index b5ed31b..53f61fb 100644
--- a/src/components/WangEnduit/index.vue
+++ b/src/components/WangEnduit/index.vue
@@ -40,16 +40,16 @@
   mounted() {
     self = this
     this.editor = new E(this.$refs.editorElem)
-    this.editor.customConfig.focus = false
-    this.editor.customConfig.onchange = (html) => {
+    this.editor.config.focus = false
+    this.editor.config.onchange = (html) => {
       this.editorContent = html
       this.catchdata(this.editorContent) // 鎶婅繖涓猦tml閫氳繃catchData鐨勬柟娉曚紶鍏ョ埗缁勪欢
     }
     // 鍘绘帀鎻掑叆缃戠粶鍥剧墖
-    this.editor.customConfig.showLinkImg = false
+    this.editor.config.showLinkImg = false
     // 绮樿创鏉ョ殑鍐呭杩囨护鍥剧墖
-    this.editor.customConfig.pasteIgnoreImg = true
-    this.editor.customConfig.menus = [ // 鑿滃崟閰嶇疆
+    this.editor.config.pasteIgnoreImg = true
+    this.editor.config.menus = [ // 鑿滃崟閰嶇疆
       'head', // 鏍囬
       'bold', // 绮椾綋
       'fontSize', // 瀛楀彿
@@ -65,29 +65,32 @@
       'quote', // 寮曠敤
       // 'emoticon',  // 琛ㄦ儏
       'image', // 鎻掑叆鍥剧墖
+      'video', // 鎻掑叆瑙嗛
       // 'table',  // 琛ㄦ牸
-      // 'code',  // 鎻掑叆浠g爜
+      'code', // 鎻掑叆浠g爜
+      'video',
       'undo', // 鎾ら攢
       'redo' // 閲嶅
     ]
     // 涓嬮潰鏄渶閲嶈鐨勭殑鏂规硶
-    // this.editor.customConfig.withCredentials = true
+    // this.editor.config.withCredentials = true
     // 灏嗗浘鐗囧ぇ灏忛檺鍒朵负 5M
-    this.editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024
+    this.editor.config.uploadImgMaxSize = 5 * 1024 * 1024
     // 闄愬埗涓�娆℃渶澶氫笂浼� 1 寮犲浘鐗�
-    this.editor.customConfig.uploadImgMaxLength = 1
+    this.editor.config.uploadImgMaxLength = 1
     // 涓嶅拷鐣ョ矘璐村唴瀹逛腑鐨勫浘鐗�
-    this.editor.customConfig.pasteIgnoreImg = false
-    this.editor.customConfig.customUploadImg = function(files, insert) {
+    this.editor.config.pasteIgnoreImg = false
+    this.editor.config.customUploadImg = function(files, insert) {
       // files 鏄� input 涓�変腑鐨勬枃浠跺垪琛�
       // insert 鏄幏鍙栧浘鐗� url 鍚庯紝鎻掑叆鍒扮紪杈戝櫒鐨勬柟娉�
       // 鍥犱负file鏄釜FormData鏍煎紡鐨勫璞℃墍浠ュ彲浠ョ洿鎺ラ�氳繃鎺ュ彛寮�濮嬩笂浼狅紝涓嶉渶瑕佸仛澶氫綑鎿嶄綔
       // 铏界劧鏂囨。璇存槸FormData鏍煎紡锛屼絾鏄垜瀹為檯浣跨敤闇�瑕佷互涓嬫搷浣�
       const formData = new FormData()
       formData.append('file', files[0])
+      console.log(formData, 'formDataformDataformDataformDataformData')
       self.postFN(
         {
-          url: 'admin/image/upload',
+          url: 'admin/image/upload?folderCode=IMG',
           header: { 'Content-Type': 'multipart/form-data' },
           params: formData,
           mockData: {
@@ -103,11 +106,54 @@
         }
       )
     }
+
+    // 閰嶇疆瀵屾枃鏈棰戜笂浼�
+    this.editor.config.customUploadVideo = function(files, insert) {
+    // files 鏄� input 涓�変腑鐨勬枃浠跺垪琛�
+    // insert 鏄幏鍙栬棰� url 鍚庯紝鎻掑叆鍒扮紪杈戝櫒鐨勬柟娉�
+      const formDataVideo = new FormData()
+      formDataVideo.append('file', files[0])
+      console.log(formDataVideo, 'formDataVideoformDataVideoformDataVideoformDataVideo')
+      self.postFN(
+        {
+          url: 'admin/image/upload?folderCode=VIDEO',
+          header: { 'Content-Type': 'multipart/form-data' },
+          params: formDataVideo,
+          mockData: {
+            code: 100,
+            msg: '',
+            data: {
+              imgUrl: 'xxxx'
+            }
+          }
+        },
+        inf => {
+          // 涓婁紶瑙嗛锛岃繑鍥炵粨鏋滐紝灏嗚棰戝湴鍧�鎻掑叆鍒扮紪杈戝櫒涓�
+          insert(inf.imgUrl)
+          console.log(inf.imgUrl, '99999999999999999999999999')
+        }
+      )
+    }
+
     // 鑷畾涔夐敊璇彁绀�
-    this.editor.customConfig.customAlert = function(info) {
+    this.editor.config.customAlert = function(info) {
       // info 鏄渶瑕佹彁绀虹殑鍐呭
       self.$messagewarn(info)
     }
+    // 杩囨护word澶嶅埗
+    this.editor.config.pasteTextHandle = function(content) {
+      var html = content
+      html = html.replace(/<\/?SPANYES[^>]*>/gi, '')//  绉婚櫎span
+      html = html.replace(/<\!\-\-(.|[\r\n])*?\-\->/gi, '')//  绉婚櫎娉ㄩ噴
+      html = html.replace(/<(\w[^>]*) {2}lang=([^|>]*)([^>]*)/gi, '<$1$3')// 绉婚櫎lang灞炴��
+      html = html.replace(/<\\?\?xml[^>]*>/gi, '')//  绉婚櫎xml鍜岀浉鍏虫弿杩�
+      html = html.replace(/<\/?\w+:[^>]*>/gi, '')// 绉婚櫎xml鍛藉悕绌洪棿鐨勬爣绛�
+      html = html.replace(/&nbsp;/gi, '')//  绉婚櫎绌烘牸
+      html = html.replace(/^\s+|\s+$/g, '')
+      html = html.replace(/<o:p> <\/o:p>/g, '')// 绉婚櫎鏍囩
+      html = html.replace(/<br\/>/g, '')// 绉婚櫎br鏍囩
+      return html
+    }
     this.editor.create() // 鍒涘缓瀵屾枃鏈疄渚�
     // if (!this.content) {
     //     // this.editor.txt.html('璇风紪杈戝唴瀹�1')

--
Gitblit v1.8.0