vue-editify 0.1.18 → 0.1.20

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <div style="padding: 80px 10px 10px 10px; height: 100%; box-sizing: border-box">
3
- <Editify ref="editify" border v-model="val" :menu="menuConfig" style="height: 100%" placeholder="Please Enter Text..." locale="zh_CN" allowPasteHtml :customHtmlPaste="customHtmlPaste"></Editify>
2
+ <div style="padding: 10px; height: 100%; box-sizing: border-box">
3
+ <Editify ref="editify" border v-model="val" :menu="menuConfig" style="height: 100%" placeholder="Please Enter Text..." locale="zh_CN" :customTextPaste="customTextPaste"></Editify>
4
4
  </div>
5
5
  </template>
6
6
  <script setup lang="ts">
@@ -11,7 +11,7 @@ const val = ref<string>('<p><br></p>')
11
11
  const editify = ref<InstanceType<typeof Editify> | null>(null)
12
12
  const menuConfig = ref<MenuConfigType>({
13
13
  use: true,
14
- mode: 'fixed',
14
+ mode: 'inner',
15
15
  image: {
16
16
  accept: ['jpg'],
17
17
  handleError: (error, file) => {
@@ -22,17 +22,18 @@ const menuConfig = ref<MenuConfigType>({
22
22
  show: true
23
23
  }
24
24
  })
25
- const customHtmlPaste = function (elements) {
26
- for (let i = 0; i < elements.length; i++) {
27
- if (elements[i].hasMarks()) {
28
- elements[i].marks['data-paste'] = 'true'
29
- } else {
30
- elements[i].marks = {
31
- 'data-paste': 'true'
32
- }
33
- }
34
- editify.value!.editor!.insertElement(elements[i], false)
35
- }
25
+ const customTextPaste = function (data: string) {
26
+ const text = new AlexElement(
27
+ 'text',
28
+ null,
29
+ null,
30
+ {
31
+ color: 'red',
32
+ 'font-weight': 'bold'
33
+ },
34
+ data
35
+ )
36
+ editify.value!.editor!.insertElement(text)
36
37
  }
37
38
  </script>
38
39
  <style lang="less">
package/lib/editify.es.js CHANGED
@@ -3539,7 +3539,7 @@ class AlexEditor {
3539
3539
  this.insertElement(text);
3540
3540
  this.range.anchor.moveToEnd(text);
3541
3541
  this.range.focus.moveToEnd(text);
3542
- this.emit("insertParagraph", null, inblock);
3542
+ this.emit("insertParagraph", inblock, inblock);
3543
3543
  } else if (inblock.behavior == "block") {
3544
3544
  if (this.range.anchor.offset == 0 && !(previousElement && inblock.isContains(previousElement))) {
3545
3545
  const paragraph = inblock.clone(false);
@@ -3579,7 +3579,7 @@ class AlexEditor {
3579
3579
  this.insertElement(text);
3580
3580
  this.range.anchor.moveToEnd(text);
3581
3581
  this.range.focus.moveToEnd(text);
3582
- this.emit("insertParagraph", null, block);
3582
+ this.emit("insertParagraph", block, block);
3583
3583
  } else {
3584
3584
  if (this.range.anchor.offset == 0 && !(previousElement && block.isContains(previousElement))) {
3585
3585
  const paragraph = block.clone(false);
@@ -18815,9 +18815,15 @@ const elementIsInTask = (element2) => {
18815
18815
  return false;
18816
18816
  };
18817
18817
  const isList = function(element2, ordered = false) {
18818
+ if (element2.isEmpty()) {
18819
+ return false;
18820
+ }
18818
18821
  return element2.parsedom == "div" && element2.hasMarks() && element2.marks["data-editify-list"] == (ordered ? "ol" : "ul");
18819
18822
  };
18820
18823
  const isTask = function(element2) {
18824
+ if (element2.isEmpty()) {
18825
+ return false;
18826
+ }
18821
18827
  return element2.parsedom == "div" && element2.hasMarks() && element2.marks.hasOwnProperty("data-editify-task");
18822
18828
  };
18823
18829
  const hasPreInRange = (editor, dataRangeCaches) => {
@@ -25352,7 +25358,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
25352
25358
  const element$12 = editor.value.getElementByKey(key);
25353
25359
  if (isTask(element$12)) {
25354
25360
  const rect = element.getElementBounding(elm);
25355
- if (e.pageX >= Math.abs(rect.left) && e.pageX <= Math.abs(rect.left + 16) && e.pageY >= Math.abs(rect.top + 2) && e.pageY <= Math.abs(rect.top + 18)) {
25361
+ if (e.pageX >= Math.abs(rect.left) && e.pageX <= Math.abs(rect.left + 16) && e.pageY >= Math.abs(rect.top + elm.offsetHeight / 2 - 8) && e.pageY <= Math.abs(rect.top + elm.offsetHeight / 2 + 8)) {
25356
25362
  if (element$12.marks["data-editify-task"] == "checked") {
25357
25363
  element$12.marks["data-editify-task"] = "uncheck";
25358
25364
  } else {
@@ -25506,12 +25512,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
25506
25512
  }, 0);
25507
25513
  };
25508
25514
  const handleInsertParagraph = (element2, previousElement) => {
25509
- if (previousElement.isOnlyHasBreak() && element2.isOnlyHasBreak()) {
25510
- if (previousElement.parsedom != AlexElement.BLOCK_NODE) {
25511
- elementToParagraph(previousElement);
25512
- editor.value.range.anchor.moveToStart(previousElement);
25513
- editor.value.range.focus.moveToStart(previousElement);
25514
- element2.toEmpty();
25515
+ if (!element2.isEqual(previousElement)) {
25516
+ if (previousElement.isOnlyHasBreak() && element2.isOnlyHasBreak()) {
25517
+ if (previousElement.parsedom != AlexElement.BLOCK_NODE) {
25518
+ elementToParagraph(previousElement);
25519
+ editor.value.range.anchor.moveToStart(previousElement);
25520
+ editor.value.range.focus.moveToStart(previousElement);
25521
+ element2.toEmpty();
25522
+ }
25523
+ }
25524
+ if (isTask(element2)) {
25525
+ element2.marks["data-editify-task"] = "uncheck";
25515
25526
  }
25516
25527
  }
25517
25528
  emits("insertparagraph", value.value);
@@ -25738,8 +25749,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
25738
25749
  };
25739
25750
  }
25740
25751
  });
25741
- const Editify = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c0db2307"]]);
25742
- const version = "0.1.18";
25752
+ const Editify = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c794ee6c"]]);
25753
+ const version = "0.1.20";
25743
25754
  const install = (app) => {
25744
25755
  app.component(Editify.name, Editify);
25745
25756
  };