vue-editify 0.1.31 → 0.1.33

Sign up to get free protection for your applications and to get access to all the features.
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
- redPlugin()
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">
@@ -190,7 +190,7 @@ export type PluginResultType = {
190
190
  pasteKeepStyles?: ObjectType;
191
191
  pasteKeepMarks?: ObjectType;
192
192
  };
193
- export type PluginType = (editifyInstance: ComponentInternalInstance, color: string | null, editTrans: (key: string) => any) => PluginResultType;
193
+ export type PluginType = (editifyInstance: ComponentInternalInstance, editTrans: (key: string) => any) => PluginResultType;
194
194
  /**
195
195
  * 粘贴html时保留的数据
196
196
  */
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;
@@ -23012,9 +23012,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
23012
23012
  images.push(url);
23013
23013
  }
23014
23014
  }
23015
- images.forEach((url) => {
23016
- emits("insert", url);
23017
- });
23015
+ emits("insert", images);
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-17d0a9c4"]]);
23076
+ const InsertImage = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-1d6646fd"]]);
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;
@@ -23209,9 +23207,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
23209
23207
  videos.push(url);
23210
23208
  }
23211
23209
  }
23212
- videos.forEach((url) => {
23213
- emits("insert", url);
23214
- });
23210
+ emits("insert", videos);
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-a54e06d0"]]);
23271
+ const InsertVideo = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-46f99390"]]);
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
- insertImage(editor.value, val);
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
- insertVideo(editor.value, val);
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: (url) => {
24542
- handleOperate("image", url);
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: (url) => {
24583
- handleOperate("video", url);
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-fbf50ae5"]]);
24783
+ const Menu = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-98c51b8e"]]);
24772
24784
  const EditifyProps = {
24773
24785
  //国际化语言类型
24774
24786
  locale: {
@@ -25184,7 +25196,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
25184
25196
  const pluginResultList = computed(() => {
25185
25197
  const pluginResultList2 = [];
25186
25198
  props.plugins.forEach((plugin) => {
25187
- let pluginResult = plugin(instance, props.color, $editTrans);
25199
+ let pluginResult = plugin(instance, $editTrans);
25188
25200
  pluginResultList2.push(pluginResult);
25189
25201
  });
25190
25202
  return pluginResultList2;
@@ -25858,7 +25870,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
25858
25870
  };
25859
25871
  }
25860
25872
  });
25861
- const Editify = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-306d3e9a"]]);
25873
+ const Editify = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4a3bc815"]]);
25862
25874
  const InsertAttachmentProps = {
25863
25875
  //主题色
25864
25876
  color: {
@@ -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();
@@ -26003,9 +26015,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
26003
26015
  attachments.push(url);
26004
26016
  }
26005
26017
  }
26006
- attachments.forEach((url) => {
26007
- emits("insert", attachmentName.value, url);
26008
- });
26018
+ emits("insert", attachmentName.value, attachments);
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-f995f4bd"]]);
26115
+ const InsertAttachment = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-71f31c71"]]);
26106
26116
  const isAttachment = (element2) => {
26107
26117
  if (element2.isEmpty()) {
26108
26118
  return false;
@@ -26124,7 +26134,7 @@ const attachment = (options) => {
26124
26134
  if (!common.isObject(options)) {
26125
26135
  options = {};
26126
26136
  }
26127
- const plugin = (editifyInstance, color2, editTrans) => {
26137
+ const plugin = (editifyInstance, editTrans) => {
26128
26138
  let isDisabled = false;
26129
26139
  if (editifyInstance.exposed.editor.value) {
26130
26140
  isDisabled = hasPreInRange(editifyInstance.exposed.editor.value, editifyInstance.exposed.dataRangeCaches.value) || hasLinkInRange(editifyInstance.exposed.editor.value, editifyInstance.exposed.dataRangeCaches.value) || hasQuoteInRange(editifyInstance.exposed.editor.value, editifyInstance.exposed.dataRangeCaches.value);
@@ -26149,7 +26159,7 @@ const attachment = (options) => {
26149
26159
  disabled: isDisabled,
26150
26160
  default: () => h(Icon, { value: "attachment" }),
26151
26161
  layer: (_name, btnInstance) => h(InsertAttachment, {
26152
- color: color2,
26162
+ color: editifyInstance.props.color,
26153
26163
  accept: options.accept,
26154
26164
  allowedFileType: options.allowedFileType || [],
26155
26165
  multiple: !!options.multiple,
@@ -26160,22 +26170,27 @@ const attachment = (options) => {
26160
26170
  onChange: () => {
26161
26171
  btnInstance.$refs.layerRef.setPosition();
26162
26172
  },
26163
- onInsert: (name, url) => {
26164
- if (url) {
26165
- const marks = {
26166
- "data-attachment": url,
26167
- "data-attachment-name": name || editTrans("attachmentDefaultName"),
26168
- contenteditable: "false"
26169
- };
26170
- const attachmentElement = new AlexElement("closed", "span", marks, null, null);
26173
+ onInsert: (name, urls) => {
26174
+ const filterUrls = urls.filter((url) => {
26175
+ return !!url;
26176
+ });
26177
+ if (filterUrls.length) {
26171
26178
  const editor = editifyInstance.exposed.editor.value;
26172
- editor.insertElement(attachmentElement);
26173
- const beforeText = AlexElement.getSpaceElement();
26174
- const afterText = AlexElement.getSpaceElement();
26175
- editor.addElementAfter(afterText, attachmentElement);
26176
- editor.addElementBefore(beforeText, attachmentElement);
26177
- editor.range.anchor.moveToStart(afterText);
26178
- editor.range.focus.moveToStart(afterText);
26179
+ filterUrls.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.31";
26260
+ const version = "0.1.33";
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,