@lambo-design/wang-editor 1.0.0-beta.10 → 1.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design/wang-editor",
3
- "version": "1.0.0-beta.10",
3
+ "version": "1.0.0-beta.12",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -9,12 +9,9 @@
9
9
  "access": "public",
10
10
  "registry": "https://registry.npmjs.org/"
11
11
  },
12
- "dependencies": {
13
- "wangeditor": "^3.1.1"
14
- },
15
12
  "devDependencies": {
16
- "@lambo-design/core": "^4.7.1-beta.167",
17
- "@lambo-design/shared": "^1.0.0-beta.274"
13
+ "@lambo-design/core": "^4.7.1-beta.169",
14
+ "@lambo-design/shared": "^1.0.0-beta.298"
18
15
  },
19
16
  "scripts": {
20
17
  "release": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
package/src/index.vue CHANGED
@@ -67,6 +67,13 @@ export default {
67
67
  type: String,
68
68
  default: "/oss/file/get/"
69
69
  },
70
+ /**
71
+ * @description 是否保留粘贴内容的样式
72
+ */
73
+ preservePasteStyle: {
74
+ type: Boolean,
75
+ default: false
76
+ },
70
77
 
71
78
  },
72
79
  watch: {
@@ -94,7 +101,7 @@ export default {
94
101
  },
95
102
  mounted() {
96
103
  let self = this;
97
- const Editor = require('wangeditor')
104
+ const Editor = require('./js/wang-editor.js')
98
105
  self.editor = new Editor(`#${this.editorId}`)
99
106
  self.editor.customConfig.onchange = (html) => {
100
107
  let text = self.editor.txt.text()
@@ -103,8 +110,8 @@ export default {
103
110
  this.$emit('on-change', html, text)
104
111
  }
105
112
 
106
- // 删除粘贴内容的样式
107
- self.editor.customConfig.pasteFilterStyle = false
113
+ // 根据 preservePasteStyle 属性决定是否保留粘贴样式
114
+ self.editor.customConfig.pasteFilterStyle = this.preservePasteStyle
108
115
  // 设置触发事件间隔
109
116
  self.editor.customConfig.onchangeTimeout = this.changeInterval
110
117
 
@@ -152,6 +159,7 @@ export default {
152
159
  self.editor.customConfig.menus = [
153
160
  'head', // 标题
154
161
  'bold', // 粗体
162
+ 'hr', //分割线
155
163
  'fontSize', // 字号
156
164
  'fontName', // 字体
157
165
  'italic', // 斜体
@@ -182,18 +190,21 @@ export default {
182
190
  '#7b5ba1',
183
191
  '#46acc8',
184
192
  '#f9963b',
185
- '#ffffff'
193
+ '#ffffff',
194
+ '#FF0000'
186
195
  ]
187
- self.editor.customConfig.pasteTextHandle = function (content) {
188
- // content 即粘贴过来的内容(html 或 纯文本),可进行自定义处理然后返回
189
- if (content == '' && !content) return ''
190
- var str = content
191
- str = str.replace(/<xml>[\s\S]*?<\/xml>/ig, '')
192
- str = str.replace(/<style>[\s\S]*?<\/style>/ig, '')
193
- str = str.replace(/<\/?[^>]*>/g, '')
194
- str = str.replace(/[ | ]*\n/g, '\n')
195
- // str = str.replace(/&nbsp;/ig, '')
196
- return str
196
+ if (!this.preservePasteStyle) {
197
+ self.editor.customConfig.pasteTextHandle = function (content) {
198
+ // content 即粘贴过来的内容(html 或 纯文本),可进行自定义处理然后返回
199
+ if (content == '' && !content) return ''
200
+ var str = content
201
+ str = str.replace(/<xml>[\s\S]*?<\/xml>/ig, '')
202
+ str = str.replace(/<style>[\s\S]*?<\/style>/ig, '')
203
+ str = str.replace(/<\/?[^>]*>/g, '')
204
+ str = str.replace(/[ | ]*\n/g, '\n')
205
+ // str = str.replace(/&nbsp;/ig, '')
206
+ return str
207
+ }
197
208
  }
198
209
 
199
210
  // create这个方法一定要在所有配置项之后调用