vue-editify 0.1.32 → 0.1.34
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/examples/App.vue +10 -22
- package/lib/editify.es.js +62 -47
- package/lib/editify.umd.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/components/insertImage/insertImage.vue +5 -7
- package/src/components/insertVideo/insertVideo.vue +5 -7
- package/src/components/menu/menu.vue +29 -7
- package/src/index.ts +1 -1
- package/src/plugins/attachment/index.ts +28 -21
- package/src/plugins/attachment/insertAttachment/insertAttachment.vue +5 -7
package/examples/App.vue
CHANGED
@@ -14,35 +14,23 @@ const menuConfig = ref<MenuConfigType>({
|
|
14
14
|
sourceView: {
|
15
15
|
show: true
|
16
16
|
},
|
17
|
+
video: {
|
18
|
+
multiple: true
|
19
|
+
},
|
17
20
|
fullScreen: {
|
18
21
|
show: true
|
19
22
|
}
|
20
23
|
})
|
21
24
|
|
22
|
-
//自定义插件
|
23
|
-
const redPlugin = () => {
|
24
|
-
const plugin: PluginType = () => {
|
25
|
-
return {
|
26
|
-
name: 'red',
|
27
|
-
renderRule: (el: AlexElement) => {
|
28
|
-
if (el.hasStyles()) {
|
29
|
-
el.styles!['color'] = 'red'
|
30
|
-
} else {
|
31
|
-
el.styles = {
|
32
|
-
color: 'red'
|
33
|
-
}
|
34
|
-
}
|
35
|
-
return el
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
return plugin
|
40
|
-
}
|
41
25
|
const plugins = ref<PluginType[]>([
|
42
26
|
attachment({
|
43
|
-
multiple: true
|
44
|
-
|
45
|
-
|
27
|
+
multiple: true,
|
28
|
+
customUpload: (files: File[]) => {
|
29
|
+
return files.map(item => {
|
30
|
+
return 'xxx'
|
31
|
+
})
|
32
|
+
}
|
33
|
+
})
|
46
34
|
])
|
47
35
|
</script>
|
48
36
|
<style lang="less">
|
package/lib/editify.es.js
CHANGED
@@ -22967,7 +22967,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
22967
22967
|
e.currentTarget.style.borderColor = "";
|
22968
22968
|
};
|
22969
22969
|
const insertRemoteImage = () => {
|
22970
|
-
emits("insert", remoteUrl.value);
|
22970
|
+
emits("insert", [remoteUrl.value]);
|
22971
22971
|
};
|
22972
22972
|
const selectFile = async (e) => {
|
22973
22973
|
const inputEle = e.currentTarget;
|
@@ -23003,18 +23003,16 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
23003
23003
|
filterFiles.push(file2);
|
23004
23004
|
}
|
23005
23005
|
if (filterFiles.length) {
|
23006
|
-
let
|
23006
|
+
let urls = [];
|
23007
23007
|
if (typeof props.customUpload == "function") {
|
23008
|
-
|
23008
|
+
urls = await props.customUpload(filterFiles) || [];
|
23009
23009
|
} else {
|
23010
23010
|
for (let i = 0; i < filterFiles.length; i++) {
|
23011
23011
|
const url = await file.dataFileToBase64(filterFiles[i]);
|
23012
|
-
|
23012
|
+
urls.push(url);
|
23013
23013
|
}
|
23014
23014
|
}
|
23015
|
-
|
23016
|
-
emits("insert", url);
|
23017
|
-
});
|
23015
|
+
emits("insert", urls);
|
23018
23016
|
}
|
23019
23017
|
inputEle.value = "";
|
23020
23018
|
};
|
@@ -23075,7 +23073,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
23075
23073
|
};
|
23076
23074
|
}
|
23077
23075
|
});
|
23078
|
-
const InsertImage = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-
|
23076
|
+
const InsertImage = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-b63a5bff"]]);
|
23079
23077
|
const InsertVideoProps = {
|
23080
23078
|
//主题色
|
23081
23079
|
color: {
|
@@ -23164,7 +23162,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
23164
23162
|
e.currentTarget.style.borderColor = "";
|
23165
23163
|
};
|
23166
23164
|
const insertRemoteVideo = () => {
|
23167
|
-
emits("insert", remoteUrl.value);
|
23165
|
+
emits("insert", [remoteUrl.value]);
|
23168
23166
|
};
|
23169
23167
|
const selectFile = async (e) => {
|
23170
23168
|
const inputEle = e.currentTarget;
|
@@ -23200,18 +23198,16 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
23200
23198
|
filterFiles.push(file2);
|
23201
23199
|
}
|
23202
23200
|
if (filterFiles.length) {
|
23203
|
-
let
|
23201
|
+
let urls = [];
|
23204
23202
|
if (typeof props.customUpload == "function") {
|
23205
|
-
|
23203
|
+
urls = await props.customUpload(filterFiles) || [];
|
23206
23204
|
} else {
|
23207
23205
|
for (let i = 0; i < filterFiles.length; i++) {
|
23208
23206
|
const url = await file.dataFileToBase64(filterFiles[i]);
|
23209
|
-
|
23207
|
+
urls.push(url);
|
23210
23208
|
}
|
23211
23209
|
}
|
23212
|
-
|
23213
|
-
emits("insert", url);
|
23214
|
-
});
|
23210
|
+
emits("insert", urls);
|
23215
23211
|
}
|
23216
23212
|
inputEle.value = "";
|
23217
23213
|
};
|
@@ -23272,7 +23268,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
23272
23268
|
};
|
23273
23269
|
}
|
23274
23270
|
});
|
23275
|
-
const InsertVideo = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
23271
|
+
const InsertVideo = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-4383bae9"]]);
|
23276
23272
|
const InsertTableProps = {
|
23277
23273
|
//主题色
|
23278
23274
|
color: {
|
@@ -23907,7 +23903,15 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
23907
23903
|
if (!val) {
|
23908
23904
|
return;
|
23909
23905
|
}
|
23910
|
-
|
23906
|
+
const urls = val.filter((url) => {
|
23907
|
+
return !!url;
|
23908
|
+
});
|
23909
|
+
if (urls.length == 0) {
|
23910
|
+
return;
|
23911
|
+
}
|
23912
|
+
urls.forEach((url) => {
|
23913
|
+
insertImage(editor.value, url);
|
23914
|
+
});
|
23911
23915
|
editor.value.formatElementStack();
|
23912
23916
|
editor.value.domRender();
|
23913
23917
|
editor.value.rangeRender();
|
@@ -23915,7 +23919,15 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
23915
23919
|
if (!val) {
|
23916
23920
|
return;
|
23917
23921
|
}
|
23918
|
-
|
23922
|
+
const urls = val.filter((url) => {
|
23923
|
+
return !!url;
|
23924
|
+
});
|
23925
|
+
if (urls.length == 0) {
|
23926
|
+
return;
|
23927
|
+
}
|
23928
|
+
urls.forEach((url) => {
|
23929
|
+
insertVideo(editor.value, url);
|
23930
|
+
});
|
23919
23931
|
editor.value.formatElementStack();
|
23920
23932
|
editor.value.domRender();
|
23921
23933
|
editor.value.rangeRender();
|
@@ -24538,8 +24550,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
24538
24550
|
const layer = btn.$refs.layerRef;
|
24539
24551
|
layer.setPosition();
|
24540
24552
|
},
|
24541
|
-
onInsert: (
|
24542
|
-
handleOperate("image",
|
24553
|
+
onInsert: (urls) => {
|
24554
|
+
handleOperate("image", urls);
|
24543
24555
|
const btn = itemInstance.proxy.$refs.btnRef;
|
24544
24556
|
btn.show = false;
|
24545
24557
|
}
|
@@ -24579,8 +24591,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
24579
24591
|
const layer = btn.$refs.layerRef;
|
24580
24592
|
layer.setPosition();
|
24581
24593
|
},
|
24582
|
-
onInsert: (
|
24583
|
-
handleOperate("video",
|
24594
|
+
onInsert: (urls) => {
|
24595
|
+
handleOperate("video", urls);
|
24584
24596
|
const btn = itemInstance.proxy.$refs.btnRef;
|
24585
24597
|
btn.show = false;
|
24586
24598
|
}
|
@@ -24768,7 +24780,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
24768
24780
|
};
|
24769
24781
|
}
|
24770
24782
|
});
|
24771
|
-
const Menu = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
24783
|
+
const Menu = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-98c51b8e"]]);
|
24772
24784
|
const EditifyProps = {
|
24773
24785
|
//国际化语言类型
|
24774
24786
|
locale: {
|
@@ -25956,7 +25968,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
25956
25968
|
e.currentTarget.style.borderColor = "";
|
25957
25969
|
};
|
25958
25970
|
const insertRemoteAttachment = () => {
|
25959
|
-
emits("insert", attachmentName.value, attachmentUrl.value);
|
25971
|
+
emits("insert", attachmentName.value, [attachmentUrl.value]);
|
25960
25972
|
};
|
25961
25973
|
const triggerFileInput = () => {
|
25962
25974
|
fileInputRef.value.click();
|
@@ -25994,18 +26006,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
25994
26006
|
filterFiles.push(file2);
|
25995
26007
|
}
|
25996
26008
|
if (filterFiles.length) {
|
25997
|
-
let
|
26009
|
+
let urls = [];
|
25998
26010
|
if (typeof props.customUpload == "function") {
|
25999
|
-
|
26011
|
+
urls = await props.customUpload(filterFiles) || [];
|
26000
26012
|
} else {
|
26001
26013
|
for (let i = 0; i < filterFiles.length; i++) {
|
26002
26014
|
const url = await file.dataFileToBase64(filterFiles[i]);
|
26003
|
-
|
26015
|
+
urls.push(url);
|
26004
26016
|
}
|
26005
26017
|
}
|
26006
|
-
|
26007
|
-
emits("insert", attachmentName.value, url);
|
26008
|
-
});
|
26018
|
+
emits("insert", attachmentName.value, urls);
|
26009
26019
|
}
|
26010
26020
|
fileInputRef.value.value = "";
|
26011
26021
|
};
|
@@ -26102,7 +26112,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
26102
26112
|
};
|
26103
26113
|
}
|
26104
26114
|
});
|
26105
|
-
const InsertAttachment = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
26115
|
+
const InsertAttachment = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-52b1e545"]]);
|
26106
26116
|
const isAttachment = (element2) => {
|
26107
26117
|
if (element2.isEmpty()) {
|
26108
26118
|
return false;
|
@@ -26160,22 +26170,27 @@ const attachment = (options) => {
|
|
26160
26170
|
onChange: () => {
|
26161
26171
|
btnInstance.$refs.layerRef.setPosition();
|
26162
26172
|
},
|
26163
|
-
onInsert: (name,
|
26164
|
-
|
26165
|
-
|
26166
|
-
|
26167
|
-
|
26168
|
-
contenteditable: "false"
|
26169
|
-
};
|
26170
|
-
const attachmentElement = new AlexElement("closed", "span", marks, null, null);
|
26173
|
+
onInsert: (name, urls) => {
|
26174
|
+
urls = urls.filter((url) => {
|
26175
|
+
return !!url;
|
26176
|
+
});
|
26177
|
+
if (urls.length) {
|
26171
26178
|
const editor = editifyInstance.exposed.editor.value;
|
26172
|
-
|
26173
|
-
|
26174
|
-
|
26175
|
-
|
26176
|
-
|
26177
|
-
|
26178
|
-
|
26179
|
+
urls.forEach((url) => {
|
26180
|
+
const marks = {
|
26181
|
+
"data-attachment": url,
|
26182
|
+
"data-attachment-name": name || editTrans("attachmentDefaultName"),
|
26183
|
+
contenteditable: "false"
|
26184
|
+
};
|
26185
|
+
const attachmentElement = new AlexElement("closed", "span", marks, null, null);
|
26186
|
+
editor.insertElement(attachmentElement);
|
26187
|
+
const beforeText = AlexElement.getSpaceElement();
|
26188
|
+
const afterText = AlexElement.getSpaceElement();
|
26189
|
+
editor.addElementAfter(afterText, attachmentElement);
|
26190
|
+
editor.addElementBefore(beforeText, attachmentElement);
|
26191
|
+
editor.range.anchor.moveToStart(afterText);
|
26192
|
+
editor.range.focus.moveToStart(afterText);
|
26193
|
+
});
|
26179
26194
|
editor.formatElementStack();
|
26180
26195
|
editor.domRender();
|
26181
26196
|
editor.rangeRender();
|
@@ -26242,7 +26257,7 @@ const attachment = (options) => {
|
|
26242
26257
|
const install = (app) => {
|
26243
26258
|
app.component(Editify.name, Editify);
|
26244
26259
|
};
|
26245
|
-
const version = "0.1.
|
26260
|
+
const version = "0.1.34";
|
26246
26261
|
console.log(`%c vue-editify %c v${version} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;", "padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;");
|
26247
26262
|
export {
|
26248
26263
|
AlexElement,
|