vue-editify 0.2.21 → 0.2.23

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
2
  <div style="height: 100%">
3
- <Editify :dark="dark" ref="editifyRef" border v-model="val" :menu="menuConfig" placeholder="Please Enter Text..." :toolbar="toolbarConfig" locale="zh_CN" allow-paste-html show-word-length></Editify>
3
+ <Editify :dark="dark" ref="editifyRef" border v-model="val" :menu="menuConfig" placeholder="Please Enter Text..." :toolbar="toolbarConfig" locale="zh_CN" show-word-length></Editify>
4
4
  </div>
5
5
  </template>
6
6
  <script setup lang="ts">
@@ -66,7 +66,7 @@ const toolbarConfig = ref({
66
66
  use: true,
67
67
  text: {}
68
68
  })
69
- const val = ref<string>(`<p>333</p>`)
69
+ const val = ref<string>(`<p><br/></p>`)
70
70
  </script>
71
71
  <style lang="less">
72
72
  html,
@@ -1,32 +1,29 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Document</title>
7
+ <script src="../node_modules/vue/dist/vue.global.prod.js"></script>
8
+ <script src="../lib/editify.umd.js"></script>
9
+ </head>
3
10
 
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Document</title>
8
- <link rel="stylesheet" href="../lib/style.css">
9
- <script src="../node_modules/vue/dist/vue.global.prod.js"></script>
10
- <script src="../lib/editify.umd.js"></script>
11
- </head>
12
-
13
- <body>
14
- <div id="app">
15
- <editify v-model="value" placeholder="请输入"></editify>
16
- </div>
17
- </body>
18
- <script>
19
- const { createApp } = Vue
20
- const app = createApp({
21
- data() {
22
- return {
23
- value: '<p><br></p>'
24
- }
25
- }
26
- })
27
- console.log(editify.version)
28
- app.use(editify)
29
- app.mount('#app')
30
- </script>
31
-
32
- </html>
11
+ <body>
12
+ <div id="app">
13
+ <editify v-model="value" placeholder="请输入"></editify>
14
+ </div>
15
+ </body>
16
+ <script>
17
+ const { createApp } = Vue
18
+ const app = createApp({
19
+ data() {
20
+ return {
21
+ value: '<p><br></p>'
22
+ }
23
+ }
24
+ })
25
+ console.log(editify.version)
26
+ app.use(editify)
27
+ app.mount('#app')
28
+ </script>
29
+ </html>
@@ -632,7 +632,6 @@ declare const _default: import('vue').DefineComponent<{
632
632
  observe: (target: Node, options?: MutationObserverInit) => void;
633
633
  takeRecords: () => MutationRecord[];
634
634
  } | null;
635
- __illegalDoms: Node[];
636
635
  initRange: () => void;
637
636
  delete: () => void;
638
637
  insertText: (data: string) => void;
package/lib/editify.es.js CHANGED
@@ -1623,7 +1623,7 @@ const _AlexElement = class _AlexElement2 {
1623
1623
  this.parsedom = parsedom;
1624
1624
  this.marks = marks;
1625
1625
  this.styles = styles2;
1626
- this.textContent = textContent;
1626
+ this.textContent = textContent ? textContent.replace(/\r\n/g, "\n") : textContent;
1627
1627
  }
1628
1628
  /**
1629
1629
  * 是否根级块元素
@@ -2849,14 +2849,6 @@ const doPaste = async function(html, text2, files) {
2849
2849
  }
2850
2850
  }
2851
2851
  };
2852
- const removeIllegalDoms = function() {
2853
- var _a;
2854
- while (this.__illegalDoms.length > 0) {
2855
- const node = this.__illegalDoms[0];
2856
- (_a = node.parentNode) == null ? void 0 : _a.removeChild(node);
2857
- this.__illegalDoms.splice(0, 1);
2858
- }
2859
- };
2860
2852
  const setEditorDomObserve = function() {
2861
2853
  if (!window.MutationObserver) {
2862
2854
  console.warn("The current browser does not support MutationObserver");
@@ -2866,9 +2858,11 @@ const setEditorDomObserve = function() {
2866
2858
  this.__domObserver = null;
2867
2859
  }
2868
2860
  this.__domObserver = new MutationObserver((mutationList) => {
2861
+ var _a;
2869
2862
  let length = mutationList.length;
2870
2863
  for (let i = 0; i < length; i++) {
2871
2864
  if (mutationList[i].type == "childList") {
2865
+ const illegalDoms = [];
2872
2866
  const addNodesLength = mutationList[i].addedNodes.length;
2873
2867
  for (let j = 0; j < addNodesLength; j++) {
2874
2868
  const node = mutationList[i].addedNodes[j];
@@ -2877,12 +2871,17 @@ const setEditorDomObserve = function() {
2877
2871
  const key = parentNode ? data$1.get(parentNode, "data-alex-editor-key") : null;
2878
2872
  const element2 = key ? this.getElementByKey(key) : null;
2879
2873
  if (element2 && !element2.isText()) {
2880
- this.__illegalDoms.push(node);
2874
+ illegalDoms.push(node);
2881
2875
  }
2882
2876
  } else if (element$1.isElement(node) && !data$1.get(node, "data-alex-editor-key")) {
2883
- this.__illegalDoms.push(node);
2877
+ illegalDoms.push(node);
2884
2878
  }
2885
2879
  }
2880
+ while (illegalDoms.length > 0) {
2881
+ const node = illegalDoms[0];
2882
+ (_a = node.parentNode) == null ? void 0 : _a.removeChild(node);
2883
+ illegalDoms.splice(0, 1);
2884
+ }
2886
2885
  }
2887
2886
  }
2888
2887
  });
@@ -3569,7 +3568,6 @@ class AlexEditor {
3569
3568
  __publicField(this, "__innerSelectionChange", false);
3570
3569
  __publicField(this, "__chineseInputTimer", null);
3571
3570
  __publicField(this, "__domObserver", null);
3572
- __publicField(this, "__illegalDoms", []);
3573
3571
  this.$el = initEditorNode(node);
3574
3572
  const options = initEditorOptions(opts);
3575
3573
  this.disabled = options.disabled;
@@ -3906,7 +3904,7 @@ class AlexEditor {
3906
3904
  }
3907
3905
  if (this.range.anchor.element.isText()) {
3908
3906
  let val = this.range.anchor.element.textContent;
3909
- this.range.anchor.element.textContent = val.substring(0, this.range.anchor.offset) + data2 + val.substring(this.range.anchor.offset);
3907
+ this.range.anchor.element.textContent = val.substring(0, this.range.anchor.offset) + data2.replace(/\r\n/g, "\n") + val.substring(this.range.anchor.offset);
3910
3908
  this.range.anchor.offset = this.range.anchor.offset + data2.length;
3911
3909
  this.range.focus.offset = this.range.anchor.offset;
3912
3910
  } else {
@@ -4195,7 +4193,6 @@ class AlexEditor {
4195
4193
  this.$el.innerHTML = "";
4196
4194
  this.$el.appendChild(fragment);
4197
4195
  } else {
4198
- removeIllegalDoms.apply(this);
4199
4196
  patch(this.stack, this.__oldStack, false).forEach((item) => {
4200
4197
  if (item.newElement) {
4201
4198
  const el = item.newElement.parent ? item.newElement.parent : item.newElement;
@@ -5008,7 +5005,7 @@ class AlexEditor {
5008
5005
  event$1.off(this.$el, "beforeinput.alex_editor compositionstart.alex_editor compositionupdate.alex_editor compositionend.alex_editor keydown.alex_editor cut.alex_editor paste.alex_editor copy.alex_editor dragstart.alex_editor drop.alex_editor focus.alex_editor blur.alex_editor");
5009
5006
  }
5010
5007
  }
5011
- const version$2 = "1.4.34";
5008
+ const version$2 = "1.4.36";
5012
5009
  console.log(`%c alex-editor %c v${version$2} `, "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;");
5013
5010
  const number = {
5014
5011
  /**
@@ -44683,7 +44680,7 @@ const Editify = withInstall(editify);
44683
44680
  const install = (app) => {
44684
44681
  app.component(Editify.name, Editify);
44685
44682
  };
44686
- const version = "0.2.21";
44683
+ const version = "0.2.23";
44687
44684
  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;");
44688
44685
  export {
44689
44686
  AlexElement,