@lambo-design/wang-editor 1.0.0-beta.1 → 1.0.0-beta.11
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/index.js +1 -0
- package/package.json +11 -4
- package/src/index.vue +63 -33
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambo-design/wang-editor",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "lambo",
|
|
@@ -13,8 +13,15 @@
|
|
|
13
13
|
"wangeditor": "^3.1.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@lambo-design/core": "^4.7.1-beta.
|
|
17
|
-
"@lambo-design/shared": "^1.0.0-beta.
|
|
16
|
+
"@lambo-design/core": "^4.7.1-beta.167",
|
|
17
|
+
"@lambo-design/shared": "^1.0.0-beta.285"
|
|
18
18
|
},
|
|
19
|
-
"scripts": {
|
|
19
|
+
"scripts": {
|
|
20
|
+
"release": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
|
|
21
|
+
"release-major": "standard-version --release-as major",
|
|
22
|
+
"release-minor": "standard-version --release-as minor",
|
|
23
|
+
"release-patch": "standard-version --release-as patch",
|
|
24
|
+
"release-beta": "standard-version --prerelease beta",
|
|
25
|
+
"re-publish": "pnpm publish --access public --no-git-checks"
|
|
26
|
+
}
|
|
20
27
|
}
|
package/src/index.vue
CHANGED
|
@@ -39,6 +39,13 @@ export default {
|
|
|
39
39
|
type: Boolean,
|
|
40
40
|
default: true
|
|
41
41
|
},
|
|
42
|
+
/**
|
|
43
|
+
* @description 是否使用 base64 保存图片
|
|
44
|
+
*/
|
|
45
|
+
uploadImgShowBase64: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: false
|
|
48
|
+
},
|
|
42
49
|
/**
|
|
43
50
|
* 上传图片上下文
|
|
44
51
|
*/
|
|
@@ -58,10 +65,30 @@ export default {
|
|
|
58
65
|
*/
|
|
59
66
|
ossFileGetImgUrl: {
|
|
60
67
|
type: String,
|
|
61
|
-
default: "/oss/file/
|
|
68
|
+
default: "/oss/file/get/"
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* @description 是否保留粘贴内容的样式
|
|
72
|
+
*/
|
|
73
|
+
preservePasteStyle: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false
|
|
62
76
|
},
|
|
63
77
|
|
|
64
78
|
},
|
|
79
|
+
watch: {
|
|
80
|
+
value: {
|
|
81
|
+
handler: function (newVal, oldVal) {
|
|
82
|
+
if (oldVal === '') {
|
|
83
|
+
if (this.valueType === 'html') {
|
|
84
|
+
this.editor.txt.html(newVal)
|
|
85
|
+
} else {
|
|
86
|
+
this.editor.txt.text(newVal)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
},
|
|
65
92
|
computed: {
|
|
66
93
|
editorId() {
|
|
67
94
|
return `editor${this._uid}`
|
|
@@ -83,19 +110,19 @@ export default {
|
|
|
83
110
|
this.$emit('on-change', html, text)
|
|
84
111
|
}
|
|
85
112
|
|
|
86
|
-
//
|
|
87
|
-
self.editor.customConfig.pasteFilterStyle =
|
|
113
|
+
// 根据 preservePasteStyle 属性决定是否保留粘贴样式
|
|
114
|
+
self.editor.customConfig.pasteFilterStyle = this.preservePasteStyle
|
|
88
115
|
// 设置触发事件间隔
|
|
89
116
|
self.editor.customConfig.onchangeTimeout = this.changeInterval
|
|
90
117
|
|
|
91
|
-
self.editor.customConfig.zIndex =
|
|
118
|
+
self.editor.customConfig.zIndex = 999
|
|
92
119
|
|
|
93
120
|
// 配置debug模式
|
|
94
121
|
self.editor.customConfig.debug = true
|
|
95
122
|
// 隐藏“网络图片”tab
|
|
96
123
|
self.editor.customConfig.showLinkImg = false
|
|
97
124
|
// 使用 base64 保存图片
|
|
98
|
-
|
|
125
|
+
self.editor.customConfig.uploadImgShowBase64 = self.uploadImgShowBase64
|
|
99
126
|
// 上传图片到服务器
|
|
100
127
|
// this.editor.customConfig.uploadImgServer = config.ossServerContext + "/file/wangeditor/put"
|
|
101
128
|
//
|
|
@@ -105,26 +132,27 @@ export default {
|
|
|
105
132
|
// =""
|
|
106
133
|
}
|
|
107
134
|
let ossServer = this.ossServerContext;
|
|
108
|
-
self.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
// files 是 input 中选中的文件列表
|
|
114
|
-
// insert 是获取图片 url 后,插入到编辑器的方法
|
|
115
|
-
axios.post(ossServer + self.ossFilePutUrl, formData).then(response => {
|
|
116
|
-
if (response.data.code == "1") {
|
|
117
|
-
var result = response.data.data;
|
|
118
|
-
// 上传代码返回结果之后,将图片插入到编辑器中
|
|
119
|
-
let imgUrl = []
|
|
120
|
-
result.forEach(item => {
|
|
121
|
-
insert(ossServer + self.ossFileGetImgUrl + item.fileId)
|
|
122
|
-
// imgUrl.push()
|
|
123
|
-
})
|
|
124
|
-
|
|
135
|
+
if(!self.uploadImgShowBase64){
|
|
136
|
+
self.editor.customConfig.customUploadImg = function (files, insert) {
|
|
137
|
+
let formData = new FormData();
|
|
138
|
+
for (let file of files) {
|
|
139
|
+
formData.append('file', file);
|
|
125
140
|
}
|
|
126
|
-
|
|
141
|
+
// files 是 input 中选中的文件列表
|
|
142
|
+
// insert 是获取图片 url 后,插入到编辑器的方法
|
|
143
|
+
axios.post(ossServer + self.ossFilePutUrl, formData).then(response => {
|
|
144
|
+
if (response.data.code == "1") {
|
|
145
|
+
var result = response.data.data;
|
|
146
|
+
// 上传代码返回结果之后,将图片插入到编辑器中
|
|
147
|
+
let imgUrl = []
|
|
148
|
+
result.forEach(item => {
|
|
149
|
+
insert(ossServer + self.ossFileGetImgUrl + item.fileId)
|
|
150
|
+
// imgUrl.push()
|
|
151
|
+
})
|
|
127
152
|
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
}
|
|
128
156
|
|
|
129
157
|
}
|
|
130
158
|
// 自定义菜单配置
|
|
@@ -163,16 +191,18 @@ export default {
|
|
|
163
191
|
'#f9963b',
|
|
164
192
|
'#ffffff'
|
|
165
193
|
]
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
194
|
+
if (!this.preservePasteStyle) {
|
|
195
|
+
self.editor.customConfig.pasteTextHandle = function (content) {
|
|
196
|
+
// content 即粘贴过来的内容(html 或 纯文本),可进行自定义处理然后返回
|
|
197
|
+
if (content == '' && !content) return ''
|
|
198
|
+
var str = content
|
|
199
|
+
str = str.replace(/<xml>[\s\S]*?<\/xml>/ig, '')
|
|
200
|
+
str = str.replace(/<style>[\s\S]*?<\/style>/ig, '')
|
|
201
|
+
str = str.replace(/<\/?[^>]*>/g, '')
|
|
202
|
+
str = str.replace(/[ | ]*\n/g, '\n')
|
|
203
|
+
// str = str.replace(/ /ig, '')
|
|
204
|
+
return str
|
|
205
|
+
}
|
|
176
206
|
}
|
|
177
207
|
|
|
178
208
|
// create这个方法一定要在所有配置项之后调用
|