vue-editify 0.0.47 → 0.0.48

Sign up to get free protection for your applications and to get access to all the features.
package/lib/editify.es.js CHANGED
@@ -1722,7 +1722,7 @@ const speech$1 = {
1722
1722
  }
1723
1723
  };
1724
1724
  const obj$1 = { number: number$1, data: data$1, element: element$1, event: event$1, common: common$1, color: color$1, file: file$1, string: string$1, platform: platform$1, speech: speech$1 };
1725
- const getAttributes = (node) => {
1725
+ const getAttributes = function(node) {
1726
1726
  let o = {};
1727
1727
  const length = node.attributes.length;
1728
1728
  for (let i = 0; i < length; i++) {
@@ -1733,7 +1733,7 @@ const getAttributes = (node) => {
1733
1733
  }
1734
1734
  return o;
1735
1735
  };
1736
- const getStyles = (node) => {
1736
+ const getStyles = function(node) {
1737
1737
  let o = {};
1738
1738
  if (node.getAttribute("style")) {
1739
1739
  const styles = node.getAttribute("style");
@@ -1759,34 +1759,34 @@ const getStyles = (node) => {
1759
1759
  }
1760
1760
  return o;
1761
1761
  };
1762
- const createUniqueKey = () => {
1762
+ const createUniqueKey = function() {
1763
1763
  let key = obj$1.data.get(window, "data-alex-editor-key") || 0;
1764
1764
  key++;
1765
1765
  obj$1.data.set(window, "data-alex-editor-key", key);
1766
1766
  return key;
1767
1767
  };
1768
- const createGuid = () => {
1768
+ const createGuid = function() {
1769
1769
  let key = obj$1.data.get(window, "data-alex-editor-guid") || 0;
1770
1770
  key++;
1771
1771
  obj$1.data.set(window, "data-alex-editor-guid", key);
1772
1772
  return key;
1773
1773
  };
1774
- const isSpaceText = (val) => {
1774
+ const isSpaceText = function(val) {
1775
1775
  return /^[\uFEFF]+$/g.test(val);
1776
1776
  };
1777
- const cloneData = (data2) => {
1777
+ const cloneData = function(data2) {
1778
1778
  if (obj$1.common.isObject(data2) || Array.isArray(data2)) {
1779
1779
  return JSON.parse(JSON.stringify(data2));
1780
1780
  }
1781
1781
  return data2;
1782
1782
  };
1783
- const isContains = (parentNode, childNode) => {
1783
+ const isContains = function(parentNode, childNode) {
1784
1784
  if (childNode.nodeType == 3) {
1785
1785
  return obj$1.element.isContains(parentNode, childNode.parentNode);
1786
1786
  }
1787
1787
  return obj$1.element.isContains(parentNode, childNode);
1788
1788
  };
1789
- const blobToBase64 = (blob) => {
1789
+ const blobToBase64 = function(blob) {
1790
1790
  return new Promise((resolve) => {
1791
1791
  const fileReader = new FileReader();
1792
1792
  fileReader.onload = (e) => {
@@ -1795,7 +1795,7 @@ const blobToBase64 = (blob) => {
1795
1795
  fileReader.readAsDataURL(blob);
1796
1796
  });
1797
1797
  };
1798
- const canUseClipboard = () => {
1798
+ const canUseClipboard = function() {
1799
1799
  if (!window.ClipboardItem) {
1800
1800
  console.warn("window.ClipboardItem must be obtained in a secure environment, such as localhost, 127.0.0.1, or https, so the editor's copy, paste, and cut functions cannot be used");
1801
1801
  return false;
@@ -1806,7 +1806,7 @@ const canUseClipboard = () => {
1806
1806
  }
1807
1807
  return true;
1808
1808
  };
1809
- const initEditorNode = (node) => {
1809
+ const initEditorNode = function(node) {
1810
1810
  if (typeof node == "string" && node) {
1811
1811
  node = document.body.querySelector(node);
1812
1812
  }
@@ -1819,7 +1819,7 @@ const initEditorNode = (node) => {
1819
1819
  obj$1.data.set(node, "data-alex-editor-init", true);
1820
1820
  return node;
1821
1821
  };
1822
- const initEditorOptions = (options) => {
1822
+ const initEditorOptions = function(options) {
1823
1823
  let opts = {
1824
1824
  //是否禁用
1825
1825
  disabled: false,
@@ -1891,7 +1891,7 @@ const initEditorOptions = (options) => {
1891
1891
  }
1892
1892
  return opts;
1893
1893
  };
1894
- const queryHasValue = (obj$1$1, name, value) => {
1894
+ const queryHasValue = function(obj$1$1, name, value) {
1895
1895
  if (value == null || value == void 0) {
1896
1896
  return obj$1$1.hasOwnProperty(name);
1897
1897
  }
@@ -1921,6 +1921,60 @@ const queryHasValue = (obj$1$1, name, value) => {
1921
1921
  }
1922
1922
  return ownValue == value;
1923
1923
  };
1924
+ const getNewFlatData = function(arr) {
1925
+ const length = arr.length;
1926
+ let newArr = [];
1927
+ for (let i = length - 1; i >= 0; i--) {
1928
+ if (arr[i].element.hasChildren()) {
1929
+ let allIn = arr[i].element.children.every((child) => {
1930
+ return newArr.some((item) => {
1931
+ return item.element.isEqual(child) && !item.offset;
1932
+ });
1933
+ });
1934
+ if (allIn) {
1935
+ newArr.unshift(arr[i]);
1936
+ }
1937
+ } else {
1938
+ newArr.unshift(arr[i]);
1939
+ }
1940
+ }
1941
+ for (let i = 0; i < newArr.length; i++) {
1942
+ const element2 = newArr[i].element;
1943
+ if (!element2.offset && element2.parent) {
1944
+ const selfIn = newArr.some((item) => {
1945
+ return item.element.isEqual(element2.parent);
1946
+ });
1947
+ const allIn = element2.parent.children.every((child) => {
1948
+ return newArr.some((item) => {
1949
+ return item.element.isEqual(child) && !item.offset;
1950
+ });
1951
+ });
1952
+ if (allIn && !selfIn) {
1953
+ newArr.splice(i, 0, {
1954
+ element: element2.parent,
1955
+ offset: false
1956
+ });
1957
+ i++;
1958
+ }
1959
+ }
1960
+ }
1961
+ return newArr;
1962
+ };
1963
+ const getNoFlatData = function(arr) {
1964
+ let noFlat = [];
1965
+ const length = arr.length;
1966
+ for (let i = 0; i < length; i++) {
1967
+ if (arr[i].element.isBlock()) {
1968
+ noFlat.push(arr[i]);
1969
+ } else {
1970
+ const isIn = arr.some((item) => item.element.isEqual(arr[i].element.parent));
1971
+ if (!isIn) {
1972
+ noFlat.push(arr[i]);
1973
+ }
1974
+ }
1975
+ }
1976
+ return noFlat;
1977
+ };
1924
1978
  const _AlexElement = class _AlexElement2 {
1925
1979
  constructor(type, parsedom, marks, styles, textContent) {
1926
1980
  this.key = createUniqueKey();
@@ -3277,15 +3331,15 @@ class AlexEditor {
3277
3331
  this.__isInputChinese = false;
3278
3332
  this.__innerSelectionChange = false;
3279
3333
  this.__chineseInputTimer = null;
3280
- this.__rangeElementsCache = {
3281
- //includes和flat都是true
3282
- all: [],
3283
- //includes为true
3334
+ this.__getElementsByRangeData = {
3335
+ //起点和终点范围内的元素,但是不包含起点和终点所在的元素
3336
+ default: [],
3337
+ //起点和终点范围内的元素,但是包含起点和终点所在的元素
3284
3338
  includes: [],
3285
- //flat为true
3339
+ //起点和终点范围内的元素扁平化处理结果,不包含起点和终点所在的元素
3286
3340
  flat: [],
3287
- //includes和flat都是false
3288
- none: []
3341
+ //起点和终点范围内的元素扁平化处理结果,包含起点和终点所在的元素
3342
+ flatIncludes: []
3289
3343
  };
3290
3344
  this.disabled ? this.setDisabled() : this.setEnabled();
3291
3345
  obj$1.event.on(document, `selectionchange.alex_editor_${this.__guid}`, handleSelectionChange.bind(this));
@@ -3436,7 +3490,7 @@ class AlexEditor {
3436
3490
  const result = await this.copy(true);
3437
3491
  if (result) {
3438
3492
  if (!this.disabled) {
3439
- this.delete();
3493
+ this.delete(true);
3440
3494
  }
3441
3495
  this.emit("cut", result.text, result.html);
3442
3496
  }
@@ -3456,7 +3510,7 @@ class AlexEditor {
3456
3510
  if (!this.allowCopy) {
3457
3511
  return;
3458
3512
  }
3459
- let result = this.getElementsByRange(true, false);
3513
+ let result = this.getElementsByRange().includes;
3460
3514
  if (result.length == 0) {
3461
3515
  return;
3462
3516
  }
@@ -3484,7 +3538,7 @@ class AlexEditor {
3484
3538
  /**
3485
3539
  * 根据光标进行删除操作
3486
3540
  */
3487
- delete() {
3541
+ delete(useCache = false) {
3488
3542
  if (this.disabled) {
3489
3543
  return;
3490
3544
  }
@@ -3632,7 +3686,7 @@ class AlexEditor {
3632
3686
  }
3633
3687
  }
3634
3688
  } else {
3635
- const result = this.getElementsByRange(true, false).filter((item) => {
3689
+ const result = this.getElementsByRange(useCache).includes.filter((item) => {
3636
3690
  return !AlexElement.VOID_NODES.includes(item.element.parsedom);
3637
3691
  });
3638
3692
  const anchorInblock = this.range.anchor.element.getInblock();
@@ -3750,7 +3804,7 @@ class AlexEditor {
3750
3804
  /**
3751
3805
  * 根据光标位置向编辑器内插入文本
3752
3806
  */
3753
- insertText(data2) {
3807
+ insertText(data2, useCache = false) {
3754
3808
  if (this.disabled) {
3755
3809
  return;
3756
3810
  }
@@ -3784,14 +3838,14 @@ class AlexEditor {
3784
3838
  this.range.focus.moveToEnd(textEl);
3785
3839
  }
3786
3840
  } else {
3787
- this.delete();
3841
+ this.delete(useCache);
3788
3842
  this.insertText(data2);
3789
3843
  }
3790
3844
  }
3791
3845
  /**
3792
3846
  * 在光标处换行
3793
3847
  */
3794
- insertParagraph() {
3848
+ insertParagraph(useCache = false) {
3795
3849
  if (this.disabled) {
3796
3850
  return;
3797
3851
  }
@@ -3887,7 +3941,7 @@ class AlexEditor {
3887
3941
  }
3888
3942
  }
3889
3943
  } else {
3890
- this.delete();
3944
+ this.delete(useCache);
3891
3945
  this.insertParagraph();
3892
3946
  }
3893
3947
  }
@@ -3895,7 +3949,7 @@ class AlexEditor {
3895
3949
  * 根据光标插入元素
3896
3950
  * cover表示所在根级块或者内部块元素只有换行符时是否覆盖此元素
3897
3951
  */
3898
- insertElement(ele, cover = true) {
3952
+ insertElement(ele, cover = true, useCache = false) {
3899
3953
  if (this.disabled) {
3900
3954
  return;
3901
3955
  }
@@ -4029,7 +4083,7 @@ class AlexEditor {
4029
4083
  this.range.anchor.moveToEnd(ele);
4030
4084
  this.range.focus.moveToEnd(ele);
4031
4085
  } else {
4032
- this.delete();
4086
+ this.delete(useCache);
4033
4087
  this.insertElement(ele, cover);
4034
4088
  }
4035
4089
  }
@@ -4437,137 +4491,86 @@ class AlexEditor {
4437
4491
  /**
4438
4492
  * 获取选区之间的元素
4439
4493
  */
4440
- getElementsByRange(includes = false, flat = false, useCache = false) {
4494
+ getElementsByRange(useCache = false) {
4495
+ if (useCache) {
4496
+ return this.__getElementsByRangeData;
4497
+ }
4498
+ const result = {
4499
+ //起点和终点范围内的元素,但是不包含起点和终点所在的元素
4500
+ default: [],
4501
+ //起点和终点范围内的元素,但是包含起点和终点所在的元素
4502
+ includes: [],
4503
+ //起点和终点范围内的元素扁平化处理结果,不包含起点和终点所在的元素
4504
+ flat: [],
4505
+ //起点和终点范围内的元素扁平化处理结果,包含起点和终点所在的元素
4506
+ flatIncludes: []
4507
+ };
4441
4508
  if (!this.range) {
4442
- return [];
4509
+ this.__getElementsByRangeData = result;
4510
+ return result;
4443
4511
  }
4444
4512
  if (this.range.anchor.isEqual(this.range.focus)) {
4445
- return [];
4446
- }
4447
- if (useCache) {
4448
- if (includes && flat) {
4449
- return this.__rangeElementsCache.all || [];
4450
- }
4451
- if (includes) {
4452
- return this.__rangeElementsCache.includes || [];
4453
- }
4454
- if (flat) {
4455
- return this.__rangeElementsCache.flat || [];
4456
- }
4457
- return this.__rangeElementsCache.none || [];
4513
+ this.__getElementsByRangeData = result;
4514
+ return result;
4458
4515
  }
4459
- const setRangeElementsCache = (result2 = []) => {
4460
- if (includes && flat) {
4461
- this.__rangeElementsCache.all = result2;
4462
- } else if (includes) {
4463
- this.__rangeElementsCache.includes = result2;
4464
- } else if (flat) {
4465
- this.__rangeElementsCache.flat = result2;
4466
- } else {
4467
- this.__rangeElementsCache.none = result2;
4468
- }
4469
- return result2;
4470
- };
4471
4516
  if (this.range.anchor.element.isEqual(this.range.focus.element)) {
4472
- if (includes) {
4473
- const isCover = this.range.anchor.offset == 0 && this.range.focus.offset == (this.range.anchor.element.isText() ? this.range.anchor.element.textContent.length : 1);
4474
- return setRangeElementsCache([
4475
- {
4476
- element: this.range.anchor.element,
4477
- offset: isCover ? false : [this.range.anchor.offset, this.range.focus.offset]
4478
- }
4479
- ]);
4480
- }
4481
- return setRangeElementsCache();
4482
- }
4483
- let result = [];
4484
- if (includes) {
4485
- if (this.range.anchor.offset == 0) {
4486
- result.push({
4517
+ const isCover = this.range.anchor.offset == 0 && this.range.focus.offset == (this.range.anchor.element.isText() ? this.range.anchor.element.textContent.length : 1);
4518
+ result.includes = [
4519
+ {
4487
4520
  element: this.range.anchor.element,
4488
- offset: false
4489
- });
4490
- } else if (this.range.anchor.offset < (this.range.anchor.element.isText() ? this.range.anchor.element.textContent.length : 1)) {
4491
- result.push({
4521
+ offset: isCover ? false : [this.range.anchor.offset, this.range.focus.offset]
4522
+ }
4523
+ ];
4524
+ result.flatIncludes = [
4525
+ {
4492
4526
  element: this.range.anchor.element,
4493
- offset: [this.range.anchor.offset, this.range.anchor.element.isText() ? this.range.anchor.element.textContent.length : 1]
4494
- });
4495
- }
4527
+ offset: isCover ? false : [this.range.anchor.offset, this.range.focus.offset]
4528
+ }
4529
+ ];
4530
+ this.__getElementsByRangeData = result;
4531
+ return result;
4532
+ }
4533
+ if (this.range.anchor.offset == 0) {
4534
+ result.flatIncludes.push({
4535
+ element: this.range.anchor.element,
4536
+ offset: false
4537
+ });
4538
+ } else if (this.range.anchor.offset < (this.range.anchor.element.isText() ? this.range.anchor.element.textContent.length : 1)) {
4539
+ result.flatIncludes.push({
4540
+ element: this.range.anchor.element,
4541
+ offset: [this.range.anchor.offset, this.range.anchor.element.isText() ? this.range.anchor.element.textContent.length : 1]
4542
+ });
4496
4543
  }
4497
4544
  const elements = AlexElement.flatElements(this.stack);
4498
4545
  const anchorIndex = elements.findIndex((el) => el.isEqual(this.range.anchor.element));
4499
4546
  const focusIndex = elements.findIndex((el) => el.isEqual(this.range.focus.element));
4500
4547
  for (let i = anchorIndex + 1; i < focusIndex; i++) {
4501
- result.push({
4548
+ result.flatIncludes.push({
4549
+ element: elements[i],
4550
+ offset: false
4551
+ });
4552
+ result.flat.push({
4502
4553
  element: elements[i],
4503
4554
  offset: false
4504
4555
  });
4505
4556
  }
4506
- if (includes) {
4507
- if (this.range.focus.offset == (this.range.focus.element.isText() ? this.range.focus.element.textContent.length : 1)) {
4508
- result.push({
4509
- element: this.range.focus.element,
4510
- offset: false
4511
- });
4512
- } else if (this.range.focus.offset > 0) {
4513
- result.push({
4514
- element: this.range.focus.element,
4515
- offset: [0, this.range.focus.offset]
4516
- });
4517
- }
4518
- }
4519
- const resLength = result.length;
4520
- let newResult = [];
4521
- for (let i = resLength - 1; i >= 0; i--) {
4522
- if (result[i].element.hasChildren()) {
4523
- let allIn = result[i].element.children.every((child) => {
4524
- return newResult.some((item) => {
4525
- return item.element.isEqual(child) && !item.offset;
4526
- });
4527
- });
4528
- if (allIn) {
4529
- newResult.unshift(result[i]);
4530
- }
4531
- } else {
4532
- newResult.unshift(result[i]);
4533
- }
4534
- }
4535
- for (let i = 0; i < newResult.length; i++) {
4536
- const element2 = newResult[i].element;
4537
- if (!element2.offset && element2.parent) {
4538
- const selfIn = newResult.some((item) => {
4539
- return item.element.isEqual(element2.parent);
4540
- });
4541
- const allIn = element2.parent.children.every((child) => {
4542
- return newResult.some((item) => {
4543
- return item.element.isEqual(child) && !item.offset;
4544
- });
4545
- });
4546
- if (allIn && !selfIn) {
4547
- newResult.splice(i, 0, {
4548
- element: element2.parent,
4549
- offset: false
4550
- });
4551
- i++;
4552
- }
4553
- }
4554
- }
4555
- if (flat) {
4556
- return setRangeElementsCache(newResult);
4557
- }
4558
- let notFlatResult = [];
4559
- const length = newResult.length;
4560
- for (let i = 0; i < length; i++) {
4561
- if (newResult[i].element.isBlock()) {
4562
- notFlatResult.push(newResult[i]);
4563
- } else {
4564
- const isIn = newResult.some((item) => item.element.isEqual(newResult[i].element.parent));
4565
- if (!isIn) {
4566
- notFlatResult.push(newResult[i]);
4567
- }
4568
- }
4557
+ if (this.range.focus.offset == (this.range.focus.element.isText() ? this.range.focus.element.textContent.length : 1)) {
4558
+ result.flatIncludes.push({
4559
+ element: this.range.focus.element,
4560
+ offset: false
4561
+ });
4562
+ } else if (this.range.focus.offset > 0) {
4563
+ result.flatIncludes.push({
4564
+ element: this.range.focus.element,
4565
+ offset: [0, this.range.focus.offset]
4566
+ });
4569
4567
  }
4570
- return setRangeElementsCache(notFlatResult);
4568
+ result.flat = getNewFlatData.apply(this, [result.flat]);
4569
+ result.flatIncludes = getNewFlatData.apply(this, [result.flatIncludes]);
4570
+ result.default = getNoFlatData.apply(this, [result.flat]);
4571
+ result.includes = getNoFlatData.apply(this, [result.flatIncludes]);
4572
+ this.__getElementsByRangeData = result;
4573
+ return result;
4571
4574
  }
4572
4575
  /**
4573
4576
  * 分割选区选中的元素,会更新光标位置
@@ -4576,7 +4579,8 @@ class AlexEditor {
4576
4579
  if (!this.range) {
4577
4580
  return [];
4578
4581
  }
4579
- const result = this.getElementsByRange(includes, flat, useCache);
4582
+ const key = includes && flat ? "flatIncludes" : includes ? "includes" : flat ? "flat" : "default";
4583
+ const result = this.getElementsByRange(useCache)[key];
4580
4584
  let elements = [];
4581
4585
  result.forEach((item, index) => {
4582
4586
  if (item.offset) {
@@ -4871,7 +4875,7 @@ class AlexEditor {
4871
4875
  }
4872
4876
  return false;
4873
4877
  }
4874
- let result = this.getElementsByRange(true, true, useCache).filter((item) => {
4878
+ let result = this.getElementsByRange(useCache).flatIncludes.filter((item) => {
4875
4879
  return item.element.isText();
4876
4880
  });
4877
4881
  if (result.length == 0) {
@@ -4993,7 +4997,7 @@ class AlexEditor {
4993
4997
  }
4994
4998
  return false;
4995
4999
  }
4996
- let result = this.getElementsByRange(true, true, useCache).filter((item) => {
5000
+ let result = this.getElementsByRange(useCache).flatIncludes.filter((item) => {
4997
5001
  return item.element.isText();
4998
5002
  });
4999
5003
  if (result.length == 0) {
@@ -17886,7 +17890,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
17886
17890
  ]);
17887
17891
  }
17888
17892
  const Colors = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7], ["__scopeId", "data-v-dc6d3d68"]]);
17889
- const Toolbar_vue_vue_type_style_index_0_scoped_38c4144f_lang = "";
17893
+ const Toolbar_vue_vue_type_style_index_0_scoped_36dbd332_lang = "";
17890
17894
  const _sfc_main$6 = {
17891
17895
  name: "Toolbar",
17892
17896
  emits: ["update:modelValue"],
@@ -18161,80 +18165,80 @@ const _sfc_main$6 = {
18161
18165
  methods: {
18162
18166
  //清除格式
18163
18167
  clearFormat() {
18164
- this.$parent.formatText();
18168
+ this.$parent.formatText(true, true);
18165
18169
  },
18166
18170
  //设置背景色
18167
18171
  setBackColor(value) {
18168
- this.$parent.setTextStyle("background-color", value);
18172
+ this.$parent.setTextStyle("background-color", value, true, true);
18169
18173
  this.$refs.backColor.hideLayer();
18170
18174
  },
18171
18175
  //设置前景色
18172
18176
  setForeColor(value) {
18173
- this.$parent.setTextStyle("color", value);
18177
+ this.$parent.setTextStyle("color", value, true, true);
18174
18178
  this.$refs.foreColor.hideLayer();
18175
18179
  },
18176
18180
  //设置行高
18177
18181
  setLineHeight(name, value) {
18178
- this.$parent.setLineHeight(value);
18182
+ this.$parent.setLineHeight(value, true, true);
18179
18183
  },
18180
18184
  //设置字体
18181
18185
  setFontFamily(name, value) {
18182
- this.$parent.setTextStyle("font-family", value);
18186
+ this.$parent.setTextStyle("font-family", value, true, true);
18183
18187
  },
18184
18188
  //设置字号
18185
18189
  setFontSize(name, value) {
18186
- this.$parent.setTextStyle("font-size", value);
18190
+ this.$parent.setTextStyle("font-size", value, true, true);
18187
18191
  },
18188
18192
  //设置上标
18189
18193
  setSuperscript() {
18190
- this.$parent.setTextStyle("vertical-align", "super");
18194
+ this.$parent.setTextStyle("vertical-align", "super", true, true);
18191
18195
  },
18192
18196
  //设置下标
18193
18197
  setSubscript() {
18194
- this.$parent.setTextStyle("vertical-align", "sub");
18198
+ this.$parent.setTextStyle("vertical-align", "sub", true, true);
18195
18199
  },
18196
18200
  //设置行内代码样式
18197
18201
  setCodeStyle() {
18198
- this.$parent.setTextMark("data-editify-code", true);
18202
+ this.$parent.setTextMark("data-editify-code", true, true, true);
18199
18203
  },
18200
18204
  //设置下划线
18201
18205
  setUnderline() {
18202
- this.$parent.setTextStyle("text-decoration", "underline");
18206
+ this.$parent.setTextStyle("text-decoration", "underline", true, true);
18203
18207
  },
18204
18208
  //设置删除线
18205
18209
  setStrikethrough() {
18206
- this.$parent.setTextStyle("text-decoration", "line-through");
18210
+ this.$parent.setTextStyle("text-decoration", "line-through", true, true);
18207
18211
  },
18208
18212
  //设置列表
18209
18213
  setList(name) {
18210
- this.$parent.setList(name == "orderList");
18214
+ this.$parent.setList(name == "orderList", true, true);
18211
18215
  },
18212
18216
  //设置任务列表
18213
18217
  setTask() {
18214
- this.$parent.setTask();
18218
+ this.$parent.setTask(true, true);
18215
18219
  },
18216
18220
  //斜体
18217
18221
  setItalic() {
18218
- this.$parent.setTextStyle("font-style", "italic");
18222
+ this.$parent.setTextStyle("font-style", "italic", true, true);
18219
18223
  },
18220
18224
  //加粗
18221
18225
  setBold() {
18222
- this.$parent.setTextStyle("font-weight", "bold");
18226
+ this.$parent.setTextStyle("font-weight", "bold", true, true);
18223
18227
  },
18224
18228
  //设置标题
18225
18229
  setHeading(name, value) {
18226
- this.$parent.setHeading(value);
18230
+ this.$parent.setHeading(value, true, true);
18227
18231
  },
18228
18232
  //设置对齐方式
18229
18233
  setAlign(name, value) {
18230
- this.$parent.setAlign(value);
18234
+ this.$parent.setAlign(value, true, true);
18231
18235
  },
18232
18236
  //设置视频
18233
18237
  setVideo(prop) {
18234
18238
  if (this.$parent.disabled) {
18235
18239
  return;
18236
18240
  }
18237
- const video = this.$parent.getCurrentParsedomElement("video");
18241
+ const video = this.$parent.getCurrentParsedomElement("video", true);
18238
18242
  if (video) {
18239
18243
  if (this.videoConfig[prop]) {
18240
18244
  delete video.marks[prop];
@@ -18251,7 +18255,7 @@ const _sfc_main$6 = {
18251
18255
  if (this.$parent.disabled) {
18252
18256
  return;
18253
18257
  }
18254
- const element2 = this.$parent.getCurrentParsedomElement("img") || this.$parent.getCurrentParsedomElement("video", true);
18258
+ const element2 = this.$parent.getCurrentParsedomElement("img", true) || this.$parent.getCurrentParsedomElement("video", true);
18255
18259
  if (element2) {
18256
18260
  const styles = {
18257
18261
  width: value
@@ -18277,7 +18281,7 @@ const _sfc_main$6 = {
18277
18281
  if (!this.linkConfig.url) {
18278
18282
  return;
18279
18283
  }
18280
- const link = this.$parent.getCurrentParsedomElement("a");
18284
+ const link = this.$parent.getCurrentParsedomElement("a", true);
18281
18285
  if (link) {
18282
18286
  link.marks.href = this.linkConfig.url;
18283
18287
  if (this.linkConfig.newOpen) {
@@ -18310,7 +18314,7 @@ const _sfc_main$6 = {
18310
18314
  if (this.$parent.disabled) {
18311
18315
  return;
18312
18316
  }
18313
- const pre = this.$parent.getCurrentParsedomElement("pre");
18317
+ const pre = this.$parent.getCurrentParsedomElement("pre", true);
18314
18318
  if (pre) {
18315
18319
  Object.assign(pre.marks, {
18316
18320
  "data-editify-hljs": value
@@ -18329,7 +18333,7 @@ const _sfc_main$6 = {
18329
18333
  this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element;
18330
18334
  this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
18331
18335
  }
18332
- const pre = this.$parent.getCurrentParsedomElement("pre");
18336
+ const pre = this.$parent.getCurrentParsedomElement("pre", true);
18333
18337
  if (pre) {
18334
18338
  const paragraph = new AlexElement("block", AlexElement.BLOCK_NODE, null, null, null);
18335
18339
  const breakEl = new AlexElement("closed", "br", null, null, null);
@@ -18355,7 +18359,7 @@ const _sfc_main$6 = {
18355
18359
  this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element;
18356
18360
  this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
18357
18361
  }
18358
- const table = this.$parent.getCurrentParsedomElement("table");
18362
+ const table = this.$parent.getCurrentParsedomElement("table", true);
18359
18363
  const column = this.$parent.getCurrentParsedomElement("td", true);
18360
18364
  const tbody = this.$parent.getCurrentParsedomElement("tbody", true);
18361
18365
  if (column && table && tbody) {
@@ -18396,7 +18400,7 @@ const _sfc_main$6 = {
18396
18400
  this.$parent.editor.rangeRender();
18397
18401
  }
18398
18402
  },
18399
- //表格插入前后插入行
18403
+ //表格前后插入行
18400
18404
  insertTableRow(type = "up") {
18401
18405
  if (this.$parent.disabled) {
18402
18406
  return;
@@ -18405,7 +18409,7 @@ const _sfc_main$6 = {
18405
18409
  this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element;
18406
18410
  this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
18407
18411
  }
18408
- const table = this.$parent.getCurrentParsedomElement("table");
18412
+ const table = this.$parent.getCurrentParsedomElement("table", true);
18409
18413
  const row = this.$parent.getCurrentParsedomElement("tr", true);
18410
18414
  if (table && row) {
18411
18415
  const newRow = row.clone();
@@ -18434,7 +18438,7 @@ const _sfc_main$6 = {
18434
18438
  if (this.$parent.disabled) {
18435
18439
  return;
18436
18440
  }
18437
- const table = this.$parent.getCurrentParsedomElement("table");
18441
+ const table = this.$parent.getCurrentParsedomElement("table", true);
18438
18442
  if (table) {
18439
18443
  const paragraph = new AlexElement("block", AlexElement.BLOCK_NODE, null, null, null);
18440
18444
  const breakEl = new AlexElement("closed", "br", null, null, null);
@@ -18460,12 +18464,12 @@ const _sfc_main$6 = {
18460
18464
  this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element;
18461
18465
  this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
18462
18466
  }
18463
- const table = this.$parent.getCurrentParsedomElement("table");
18467
+ const table = this.$parent.getCurrentParsedomElement("table", true);
18464
18468
  const row = this.$parent.getCurrentParsedomElement("tr", true);
18465
18469
  if (table && row) {
18466
18470
  const parent = row.parent;
18467
18471
  if (parent.children.length == 1) {
18468
- this.$parent.deleteByParsedom("table");
18472
+ this.$parent.deleteByParsedom("table", true, true);
18469
18473
  return;
18470
18474
  }
18471
18475
  const previousRow = this.$parent.editor.getPreviousElement(row);
@@ -18495,14 +18499,14 @@ const _sfc_main$6 = {
18495
18499
  this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element;
18496
18500
  this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
18497
18501
  }
18498
- const column = this.$parent.getCurrentParsedomElement("td");
18502
+ const column = this.$parent.getCurrentParsedomElement("td", true);
18499
18503
  const tbody = this.$parent.getCurrentParsedomElement("tbody", true);
18500
18504
  const table = this.$parent.getCurrentParsedomElement("table", true);
18501
18505
  if (column && table && tbody) {
18502
18506
  const rows = tbody.children;
18503
18507
  const parent = column.parent;
18504
18508
  if (parent.children.length == 1) {
18505
- this.$parent.deleteByParsedom("table", true);
18509
+ this.$parent.deleteByParsedom("table", true, true);
18506
18510
  return;
18507
18511
  }
18508
18512
  const previousColumn = this.$parent.editor.getPreviousElement(column);
@@ -18531,7 +18535,7 @@ const _sfc_main$6 = {
18531
18535
  },
18532
18536
  //浮层显示时
18533
18537
  layerShow() {
18534
- const result = this.$parent.editor.getElementsByRange(true, false, true);
18538
+ const result = this.$parent.editor.getElementsByRange(true).includes;
18535
18539
  if (this.type == "codeBlock") {
18536
18540
  const pre = this.$parent.getCurrentParsedomElement("pre", true);
18537
18541
  if (pre) {
@@ -19381,7 +19385,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
19381
19385
  _: 1
19382
19386
  }, 8, ["modelValue", "node", "onShow", "useRange"]);
19383
19387
  }
19384
- const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-38c4144f"]]);
19388
+ const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-36dbd332"]]);
19385
19389
  const InsertLink_vue_vue_type_style_index_0_scoped_e6c3c2ee_lang = "";
19386
19390
  const _sfc_main$5 = {
19387
19391
  name: "InsertLink",
@@ -20029,7 +20033,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
20029
20033
  ]);
20030
20034
  }
20031
20035
  const InsertTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-227ede65"]]);
20032
- const Menu_vue_vue_type_style_index_0_scoped_afb2092e_lang = "";
20036
+ const Menu_vue_vue_type_style_index_0_scoped_da918768_lang = "";
20033
20037
  const _sfc_main$1 = {
20034
20038
  name: "Menu",
20035
20039
  props: {
@@ -20779,7 +20783,7 @@ const _sfc_main$1 = {
20779
20783
  hideScroll: true,
20780
20784
  onLayerShow: () => {
20781
20785
  let text2 = "";
20782
- const result = this.$parent.$parent.editor.getElementsByRange(true, true);
20786
+ const result = this.$parent.$parent.editor.getElementsByRange().flatIncludes;
20783
20787
  result.forEach((item) => {
20784
20788
  if (item.element.isText()) {
20785
20789
  if (item.offset) {
@@ -21103,11 +21107,11 @@ const _sfc_main$1 = {
21103
21107
  }
21104
21108
  },
21105
21109
  //处理光标更新
21106
- handleRangeUpdate() {
21110
+ handleRangeUpdate(useCache = false) {
21107
21111
  if (this.disabled) {
21108
21112
  return;
21109
21113
  }
21110
- const result = this.$parent.editor.getElementsByRange(true, false, true);
21114
+ const result = this.$parent.editor.getElementsByRange(useCache).includes;
21111
21115
  const hasPreStyle = this.$parent.hasPreStyle(true);
21112
21116
  const hasTable = this.$parent.hasTable(true);
21113
21117
  const hasQuote = this.$parent.hasQuote(true);
@@ -21247,8 +21251,8 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
21247
21251
  }), 256))
21248
21252
  ], 14, _hoisted_1$1);
21249
21253
  }
21250
- const Menu = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-afb2092e"]]);
21251
- const Editify_vue_vue_type_style_index_0_scoped_b523f8ea_lang = "";
21254
+ const Menu = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-da918768"]]);
21255
+ const Editify_vue_vue_type_style_index_0_scoped_3f1c784c_lang = "";
21252
21256
  const _sfc_main = {
21253
21257
  name: "editify",
21254
21258
  props: { ...editorProps },
@@ -21447,13 +21451,13 @@ const _sfc_main = {
21447
21451
  removeScroll(this.$refs.content);
21448
21452
  },
21449
21453
  //工具条显示判断
21450
- handleToolbar() {
21454
+ handleToolbar(useCache = false) {
21451
21455
  if (this.disabled || this.isSourceView) {
21452
21456
  return;
21453
21457
  }
21454
21458
  this.hideToolbar();
21455
21459
  this.$nextTick(() => {
21456
- const table = this.getCurrentParsedomElement("table", true);
21460
+ const table = this.getCurrentParsedomElement("table", useCache);
21457
21461
  const pre = this.getCurrentParsedomElement("pre", true);
21458
21462
  const link = this.getCurrentParsedomElement("a", true);
21459
21463
  const image = this.getCurrentParsedomElement("img", true);
@@ -21499,7 +21503,7 @@ const _sfc_main = {
21499
21503
  this.toolbarOptions.show = true;
21500
21504
  }
21501
21505
  } else {
21502
- const result = this.editor.getElementsByRange(true, true, true).filter((item) => {
21506
+ const result = this.editor.getElementsByRange(true).flatIncludes.filter((item) => {
21503
21507
  return item.element.isText();
21504
21508
  });
21505
21509
  if (result.length && !this.hasTable(true) && !this.hasPreStyle(true) && !this.hasLink(true) && !this.hasImage(true) && !this.hasVideo(true)) {
@@ -21753,7 +21757,7 @@ const _sfc_main = {
21753
21757
  this.$emit("insertparagraph", this.value);
21754
21758
  },
21755
21759
  //编辑器焦点更新
21756
- handleRangeUpdate(range) {
21760
+ handleRangeUpdate() {
21757
21761
  if (this.disabled) {
21758
21762
  return;
21759
21763
  }
@@ -21762,17 +21766,16 @@ const _sfc_main = {
21762
21766
  }
21763
21767
  this.updateTimer = setTimeout(() => {
21764
21768
  if (this.toolbarConfig.use || this.menuConfig.use) {
21765
- this.editor.getElementsByRange(true, false);
21766
- this.editor.getElementsByRange(true, true);
21767
- }
21768
- if (this.toolbarConfig.use) {
21769
- this.handleToolbar();
21770
- }
21771
- if (this.menuConfig.use) {
21772
- this.$refs.menu.handleRangeUpdate();
21769
+ this.editor.getElementsByRange();
21770
+ if (this.toolbarConfig.use) {
21771
+ this.handleToolbar(true);
21772
+ }
21773
+ if (this.menuConfig.use) {
21774
+ this.$refs.menu.handleRangeUpdate(true);
21775
+ }
21773
21776
  }
21774
21777
  }, 200);
21775
- this.$emit("rangeupdate", this.value, range);
21778
+ this.$emit("rangeupdate", this.value);
21776
21779
  },
21777
21780
  //编辑器复制
21778
21781
  handleCopy(text2, html) {
@@ -21787,7 +21790,7 @@ const _sfc_main = {
21787
21790
  this.$emit("paste-text", data2);
21788
21791
  },
21789
21792
  //编辑器粘贴html
21790
- handlePasteHtml(elements, data2) {
21793
+ handlePasteHtml(elements) {
21791
21794
  const keepStyles = Object.assign(pasteKeepData.styles, this.pasteKeepStyles || {});
21792
21795
  const keepMarks = Object.assign(pasteKeepData.marks, this.pasteKeepMarks || {});
21793
21796
  AlexElement.flatElements(elements).forEach((el) => {
@@ -21897,7 +21900,7 @@ const _sfc_main = {
21897
21900
  if (this.editor.range.anchor.element.isEqual(this.editor.range.focus.element)) {
21898
21901
  return this.getParsedomElementByElement(this.editor.range.anchor.element, parsedom);
21899
21902
  }
21900
- const arr = this.editor.getElementsByRange(true, false, useCache).map((item) => {
21903
+ const arr = this.editor.getElementsByRange(useCache).includes.map((item) => {
21901
21904
  return this.getParsedomElementByElement(item.element, parsedom);
21902
21905
  });
21903
21906
  let hasNull = arr.some((el) => {
@@ -21978,7 +21981,7 @@ const _sfc_main = {
21978
21981
  blockToParagraph(block);
21979
21982
  block.parsedom = parsedom;
21980
21983
  } else {
21981
- const result = this.editor.getElementsByRange(true, false, useCache);
21984
+ const result = this.editor.getElementsByRange(useCache).includes;
21982
21985
  result.forEach((el) => {
21983
21986
  if (el.element.isBlock()) {
21984
21987
  blockToParagraph(el.element);
@@ -22014,7 +22017,7 @@ const _sfc_main = {
22014
22017
  }
22015
22018
  } else {
22016
22019
  let blocks = [];
22017
- const result = this.editor.getElementsByRange(true, false, useCache);
22020
+ const result = this.editor.getElementsByRange(useCache).includes;
22018
22021
  result.forEach((item) => {
22019
22022
  const block = item.element.getBlock();
22020
22023
  const exist = blocks.some((el) => block.isEqual(el));
@@ -22055,7 +22058,7 @@ const _sfc_main = {
22055
22058
  }
22056
22059
  } else {
22057
22060
  let blocks = [];
22058
- const result = this.editor.getElementsByRange(true, false, useCache);
22061
+ const result = this.editor.getElementsByRange(useCache).includes;
22059
22062
  result.forEach((item) => {
22060
22063
  const block = item.element.getBlock();
22061
22064
  const exist = blocks.some((el) => block.isEqual(el));
@@ -22088,11 +22091,11 @@ const _sfc_main = {
22088
22091
  }
22089
22092
  const active = this.queryTextStyle(name, value, useCache);
22090
22093
  if (active) {
22091
- this.editor.removeTextStyle([name], useCache);
22094
+ this.editor.removeTextStyle([name], true);
22092
22095
  } else {
22093
22096
  let styles = {};
22094
22097
  styles[name] = value;
22095
- this.editor.setTextStyle(styles, useCache);
22098
+ this.editor.setTextStyle(styles, true);
22096
22099
  }
22097
22100
  if (isRender) {
22098
22101
  this.editor.formatElementStack();
@@ -22114,11 +22117,11 @@ const _sfc_main = {
22114
22117
  }
22115
22118
  const active = this.queryTextMark(name, value, useCache);
22116
22119
  if (active) {
22117
- this.editor.removeTextMark([name], useCache);
22120
+ this.editor.removeTextMark([name], true);
22118
22121
  } else {
22119
22122
  let marks = {};
22120
22123
  marks[name] = value;
22121
- this.editor.setTextMark(marks, useCache);
22124
+ this.editor.setTextMark(marks, true);
22122
22125
  }
22123
22126
  if (isRender) {
22124
22127
  this.editor.formatElementStack();
@@ -22139,7 +22142,7 @@ const _sfc_main = {
22139
22142
  return;
22140
22143
  }
22141
22144
  this.editor.removeTextStyle(null, useCache);
22142
- this.editor.removeTextMark(null, useCache);
22145
+ this.editor.removeTextMark(null);
22143
22146
  if (isRender) {
22144
22147
  this.editor.formatElementStack();
22145
22148
  this.editor.domRender();
@@ -22175,7 +22178,7 @@ const _sfc_main = {
22175
22178
  }
22176
22179
  }
22177
22180
  } else {
22178
- const result = this.editor.getElementsByRange(true, false, useCache);
22181
+ const result = this.editor.getElementsByRange(useCache).includes;
22179
22182
  result.forEach((el) => {
22180
22183
  if (el.element.isBlock() || el.element.isInblock()) {
22181
22184
  if (el.element.hasStyles()) {
@@ -22261,7 +22264,7 @@ const _sfc_main = {
22261
22264
  }
22262
22265
  } else {
22263
22266
  let blocks = [];
22264
- const result = this.editor.getElementsByRange(true, false, useCache);
22267
+ const result = this.editor.getElementsByRange(useCache).includes;
22265
22268
  result.forEach((item) => {
22266
22269
  const block = item.element.getBlock();
22267
22270
  const exist = blocks.some((el) => block.isEqual(el));
@@ -22312,7 +22315,7 @@ const _sfc_main = {
22312
22315
  }
22313
22316
  }
22314
22317
  } else {
22315
- const result = this.editor.getElementsByRange(true, false, useCache);
22318
+ const result = this.editor.getElementsByRange(useCache).includes;
22316
22319
  result.forEach((el) => {
22317
22320
  if (el.element.isBlock() || el.element.isInblock()) {
22318
22321
  if (el.element.hasStyles()) {
@@ -22387,7 +22390,7 @@ const _sfc_main = {
22387
22390
  fn(block);
22388
22391
  }
22389
22392
  } else {
22390
- const result = this.editor.getElementsByRange(true, false, useCache);
22393
+ const result = this.editor.getElementsByRange(useCache).includes;
22391
22394
  result.forEach((item) => {
22392
22395
  const block = item.element.getBlock();
22393
22396
  const inblock = item.element.getInblock();
@@ -22432,7 +22435,7 @@ const _sfc_main = {
22432
22435
  fn(block);
22433
22436
  }
22434
22437
  } else {
22435
- const result = this.editor.getElementsByRange(true, false, useCache);
22438
+ const result = this.editor.getElementsByRange(useCache).includes;
22436
22439
  result.forEach((item) => {
22437
22440
  const block = item.element.getBlock();
22438
22441
  const inblock = item.element.getInblock();
@@ -22450,7 +22453,7 @@ const _sfc_main = {
22450
22453
  }
22451
22454
  },
22452
22455
  //api:插入图片
22453
- insertImage(url2, isRender = true) {
22456
+ insertImage(url2, isRender = true, useCache = false) {
22454
22457
  if (this.disabled) {
22455
22458
  return;
22456
22459
  }
@@ -22469,7 +22472,7 @@ const _sfc_main = {
22469
22472
  null,
22470
22473
  null
22471
22474
  );
22472
- this.editor.insertElement(image);
22475
+ this.editor.insertElement(image, true, useCache);
22473
22476
  if (isRender) {
22474
22477
  this.editor.formatElementStack();
22475
22478
  this.editor.domRender();
@@ -22477,7 +22480,7 @@ const _sfc_main = {
22477
22480
  }
22478
22481
  },
22479
22482
  //api:插入视频
22480
- insertVideo(url2, isRender = true) {
22483
+ insertVideo(url2, isRender = true, useCache = false) {
22481
22484
  if (this.disabled) {
22482
22485
  return;
22483
22486
  }
@@ -22496,7 +22499,7 @@ const _sfc_main = {
22496
22499
  null,
22497
22500
  null
22498
22501
  );
22499
- this.editor.insertElement(video);
22502
+ this.editor.insertElement(video, true, useCache);
22500
22503
  const leftSpace = AlexElement.getSpaceElement();
22501
22504
  const rightSpace = AlexElement.getSpaceElement();
22502
22505
  this.editor.addElementAfter(rightSpace, video);
@@ -22517,7 +22520,7 @@ const _sfc_main = {
22517
22520
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22518
22521
  return this.editor.range.anchor.element.isPreStyle();
22519
22522
  }
22520
- const result = this.editor.getElementsByRange(true, false, useCache);
22523
+ const result = this.editor.getElementsByRange(useCache).includes;
22521
22524
  return result.some((item) => {
22522
22525
  return item.element.isPreStyle();
22523
22526
  });
@@ -22531,7 +22534,7 @@ const _sfc_main = {
22531
22534
  const block = this.editor.range.anchor.element.getBlock();
22532
22535
  return block.parsedom == "blockquote";
22533
22536
  }
22534
- const result = this.editor.getElementsByRange(true, false, useCache);
22537
+ const result = this.editor.getElementsByRange(useCache).includes;
22535
22538
  return result.some((item) => {
22536
22539
  if (item.element.isBlock()) {
22537
22540
  return item.element.parsedom == "blockquote";
@@ -22550,7 +22553,7 @@ const _sfc_main = {
22550
22553
  const block = this.editor.range.anchor.element.getBlock();
22551
22554
  return blockIsList(block, ordered);
22552
22555
  }
22553
- const result = this.editor.getElementsByRange(true, false, useCache);
22556
+ const result = this.editor.getElementsByRange(useCache).includes;
22554
22557
  return result.some((item) => {
22555
22558
  if (item.element.isBlock()) {
22556
22559
  return blockIsList(item.element, ordered);
@@ -22568,7 +22571,7 @@ const _sfc_main = {
22568
22571
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22569
22572
  return !!this.getParsedomElementByElement(this.editor.range.anchor.element, "a");
22570
22573
  }
22571
- const result = this.editor.getElementsByRange(true, true, useCache).filter((item) => {
22574
+ const result = this.editor.getElementsByRange(useCache).flatIncludes.filter((item) => {
22572
22575
  return item.element.isText();
22573
22576
  });
22574
22577
  return result.some((item) => {
@@ -22584,7 +22587,7 @@ const _sfc_main = {
22584
22587
  const block = this.editor.range.anchor.element.getBlock();
22585
22588
  return block.parsedom == "table";
22586
22589
  }
22587
- const result = this.editor.getElementsByRange(true, false, useCache);
22590
+ const result = this.editor.getElementsByRange(useCache).includes;
22588
22591
  return result.some((item) => {
22589
22592
  if (item.element.isBlock()) {
22590
22593
  return item.element.parsedom == "table";
@@ -22603,7 +22606,7 @@ const _sfc_main = {
22603
22606
  const block = this.editor.range.anchor.element.getBlock();
22604
22607
  return blockIsTask(block);
22605
22608
  }
22606
- const result = this.editor.getElementsByRange(true, false, useCache);
22609
+ const result = this.editor.getElementsByRange(useCache).includes;
22607
22610
  return result.some((item) => {
22608
22611
  if (item.element.isBlock()) {
22609
22612
  return blockIsTask(item.element);
@@ -22621,7 +22624,7 @@ const _sfc_main = {
22621
22624
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22622
22625
  return this.editor.range.anchor.element.isClosed() && this.editor.range.anchor.element.parsedom == "img";
22623
22626
  }
22624
- const result = this.editor.getElementsByRange(true, true, useCache);
22627
+ const result = this.editor.getElementsByRange(useCache).flatIncludes;
22625
22628
  return result.some((item) => {
22626
22629
  return item.element.isClosed() && item.element.parsedom == "img";
22627
22630
  });
@@ -22634,7 +22637,7 @@ const _sfc_main = {
22634
22637
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22635
22638
  return this.editor.range.anchor.element.isClosed() && this.editor.range.anchor.element.parsedom == "video";
22636
22639
  }
22637
- const result = this.editor.getElementsByRange(true, true, useCache);
22640
+ const result = this.editor.getElementsByRange(useCache).flatIncludes;
22638
22641
  return result.some((item) => {
22639
22642
  return item.element.isClosed() && item.element.parsedom == "video";
22640
22643
  });
@@ -22648,7 +22651,7 @@ const _sfc_main = {
22648
22651
  const block = this.editor.range.anchor.element.getBlock();
22649
22652
  return block.parsedom == "blockquote";
22650
22653
  }
22651
- const result = this.editor.getElementsByRange(true, false, useCache);
22654
+ const result = this.editor.getElementsByRange(useCache).includes;
22652
22655
  return result.every((item) => {
22653
22656
  if (item.element.isBlock()) {
22654
22657
  return item.element.parsedom == "blockquote";
@@ -22667,7 +22670,7 @@ const _sfc_main = {
22667
22670
  const block = this.editor.range.anchor.element.getBlock();
22668
22671
  return blockIsList(block, ordered);
22669
22672
  }
22670
- const result = this.editor.getElementsByRange(true, false, useCache);
22673
+ const result = this.editor.getElementsByRange(useCache).includes;
22671
22674
  return result.every((item) => {
22672
22675
  if (item.element.isBlock()) {
22673
22676
  return blockIsList(item.element, ordered);
@@ -22686,7 +22689,7 @@ const _sfc_main = {
22686
22689
  const block = this.editor.range.anchor.element.getBlock();
22687
22690
  return blockIsTask(block);
22688
22691
  }
22689
- const result = this.editor.getElementsByRange(true, false, useCache);
22692
+ const result = this.editor.getElementsByRange(useCache).includes;
22690
22693
  return result.every((item) => {
22691
22694
  if (item.element.isBlock()) {
22692
22695
  return blockIsTask(item.element);
@@ -22697,7 +22700,7 @@ const _sfc_main = {
22697
22700
  });
22698
22701
  },
22699
22702
  //api:创建一个空的表格
22700
- insertTable(rowLength, colLength, isRender = true) {
22703
+ insertTable(rowLength, colLength, isRender = true, useCache = false) {
22701
22704
  if (this.disabled) {
22702
22705
  return;
22703
22706
  }
@@ -22717,7 +22720,7 @@ const _sfc_main = {
22717
22720
  }
22718
22721
  this.editor.addElementTo(row, tbody);
22719
22722
  }
22720
- this.editor.insertElement(table);
22723
+ this.editor.insertElement(table, true, useCache);
22721
22724
  const paragraph = new AlexElement("block", AlexElement.BLOCK_NODE, null, null, null);
22722
22725
  const breakEl = new AlexElement("closed", "br", null, null, null);
22723
22726
  this.editor.addElementTo(breakEl, paragraph);
@@ -22764,10 +22767,10 @@ const _sfc_main = {
22764
22767
  this.editor.addElementTo(breakEl, paragraph);
22765
22768
  this.editor.addElementAfter(paragraph, block);
22766
22769
  } else {
22767
- let result = this.editor.getElementsByRange(true, false, useCache);
22770
+ let result = this.editor.getElementsByRange(true).includes;
22768
22771
  this.editor.range.anchor.moveToStart(result[0].element.getBlock());
22769
22772
  this.editor.range.focus.moveToEnd(result[result.length - 1].element.getBlock());
22770
- const res = this.editor.getElementsByRange(true, true, useCache).filter((el) => el.element.isText());
22773
+ const res = this.editor.getElementsByRange(true).flatIncludes.filter((el) => el.element.isText());
22771
22774
  const obj2 = {};
22772
22775
  res.forEach((el) => {
22773
22776
  if (obj2[el.element.getBlock().key]) {
@@ -22809,14 +22812,14 @@ const _sfc_main = {
22809
22812
  }
22810
22813
  },
22811
22814
  //api:插入文本
22812
- insertText(text2, isRender = true) {
22815
+ insertText(text2, isRender = true, useCache = false) {
22813
22816
  if (this.disabled) {
22814
22817
  return;
22815
22818
  }
22816
22819
  if (!this.editor.range) {
22817
22820
  return;
22818
22821
  }
22819
- this.editor.insertText(text2);
22822
+ this.editor.insertText(text2, useCache);
22820
22823
  if (isRender) {
22821
22824
  this.editor.formatElementStack();
22822
22825
  this.editor.domRender();
@@ -22824,7 +22827,7 @@ const _sfc_main = {
22824
22827
  }
22825
22828
  },
22826
22829
  //api:插入html
22827
- insertHtml(html, isRender = true) {
22830
+ insertHtml(html, isRender = true, useCache = false) {
22828
22831
  if (this.disabled) {
22829
22832
  return;
22830
22833
  }
@@ -22833,7 +22836,7 @@ const _sfc_main = {
22833
22836
  }
22834
22837
  const elements = this.editor.parseHtml(html);
22835
22838
  for (let i = 0; i < elements.length; i++) {
22836
- this.editor.insertElement(elements[i], false);
22839
+ this.editor.insertElement(elements[i], false, i == 0 ? useCache : false);
22837
22840
  }
22838
22841
  if (isRender) {
22839
22842
  this.editor.formatElementStack();
@@ -22904,7 +22907,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
22904
22907
  ])) : createCommentVNode("", true)
22905
22908
  ]);
22906
22909
  }
22907
- const Editify = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-b523f8ea"]]);
22910
+ const Editify = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-3f1c784c"]]);
22908
22911
  const iconfont = "";
22909
22912
  const en_US = {
22910
22913
  textWrapUp: "Up feed",
@@ -23085,7 +23088,7 @@ const i18n = (locale) => {
23085
23088
  return translations[locale][key];
23086
23089
  };
23087
23090
  };
23088
- const version = "0.0.47";
23091
+ const version = "0.0.48";
23089
23092
  const install = (app, props) => {
23090
23093
  const locale = (props ? props.locale : "zh_CN") || "zh_CN";
23091
23094
  app.provide("$editTrans", i18n(locale));