vue-editify 0.0.16 → 0.0.18

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/lib/editify.es.js CHANGED
@@ -186,10 +186,10 @@ const string$1 = {
186
186
  },
187
187
  /**
188
188
  * 去除字符串空格
189
- * @param {Object} str
189
+ * @param {Object} str 原始字符串
190
190
  * @param {Object} global 为true时去除所有空格,否则只去除两边空格
191
191
  */
192
- trim(str, global) {
192
+ trim(str, global = false) {
193
193
  if (typeof str != "string") {
194
194
  throw new TypeError("The first argument must be a string");
195
195
  }
@@ -209,9 +209,9 @@ const element$1 = {
209
209
  return data2 && data2 instanceof Window;
210
210
  },
211
211
  /**
212
- * 获取元素距离指定祖先元素左侧/顶部/底部/右侧的距离
212
+ * 获取元素距离某个定位祖先元素左侧/顶部/底部/右侧的距离
213
213
  * @param {Object} el 元素
214
- * @param {Object} root 父元素或者祖先元素,未指定则为document.body
214
+ * @param {Object} root 定位父元素或者祖先元素,未指定则为document.body
215
215
  */
216
216
  getElementPoint(el, root) {
217
217
  if (!this.isElement(el)) {
@@ -241,9 +241,9 @@ const element$1 = {
241
241
  };
242
242
  },
243
243
  /**
244
- * 判断某个节点是否包含指定节点,包含相等关系和父子关系
245
- * @param {Object} parentNode 父节点或祖先节点
246
- * @param {Object} childNode 子节点
244
+ * 判断某个元素是否包含指定元素,包含相等关系和父子关系
245
+ * @param {Object} parentNode 父元素或祖先元素
246
+ * @param {Object} childNode 子元素
247
247
  */
248
248
  isContains(parentNode, childNode) {
249
249
  if (!this.isElement(parentNode)) {
@@ -263,9 +263,9 @@ const element$1 = {
263
263
  }
264
264
  },
265
265
  /**
266
- * 判断某个节点是否是指定节点的父节点
267
- * @param {Object} parentNode 父节点
268
- * @param {Object} childNode 子节点
266
+ * 判断某个元素是否是指定元素的父元素
267
+ * @param {Object} parentNode 父元素
268
+ * @param {Object} childNode 子元素
269
269
  */
270
270
  isParentNode(parentNode, childNode) {
271
271
  if (!this.isElement(parentNode)) {
@@ -280,8 +280,8 @@ const element$1 = {
280
280
  return childNode.parentNode === parentNode;
281
281
  },
282
282
  /**
283
- * 查找某个节点下指定选择器的子元素
284
- * @param {Object} el 元素节点
283
+ * 查找某个元素下指定选择器的子元素
284
+ * @param {Object} el 元素
285
285
  * @param {Object} selector 支持多选择器,等同于querySelectorAll的参数
286
286
  */
287
287
  children(el, selector) {
@@ -297,8 +297,8 @@ const element$1 = {
297
297
  });
298
298
  },
299
299
  /**
300
- * 查找某个节点下指定选择器的兄弟节点
301
- * @param {Object} el 元素节点
300
+ * 查找某个元素下指定选择器的兄弟元素
301
+ * @param {Object} el 元素
302
302
  * @param {Object} selector 取值等同于queryselectorAll的参数,支持多选择器
303
303
  */
304
304
  siblings(el, selector) {
@@ -372,7 +372,7 @@ const element$1 = {
372
372
  },
373
373
  /**
374
374
  * 移除class
375
- * @param {Object} el 元素节点
375
+ * @param {Object} el 元素
376
376
  * @param {Object} className 支持多类,以空格划分
377
377
  */
378
378
  removeClass(el, className) {
@@ -390,7 +390,7 @@ const element$1 = {
390
390
  },
391
391
  /**
392
392
  * 添加class
393
- * @param {Object} el 元素节点
393
+ * @param {Object} el 元素
394
394
  * @param {Object} className 支持多类,以空格划分
395
395
  */
396
396
  addClass(el, className) {
@@ -408,7 +408,7 @@ const element$1 = {
408
408
  },
409
409
  /**
410
410
  * 判断指定元素是否含有指定类名
411
- * @param {Object} el 元素节点
411
+ * @param {Object} el 元素
412
412
  * @param {Object} className 支持多类,以空格划分
413
413
  */
414
414
  hasClass(el, className) {
@@ -736,7 +736,7 @@ const element$1 = {
736
736
  };
737
737
  },
738
738
  /**
739
- * 判断是否是元素节点
739
+ * 判断是否是元素
740
740
  * @param {Object} el
741
741
  */
742
742
  isElement(el) {
@@ -755,7 +755,7 @@ const element$1 = {
755
755
  if (parentEle.children.length == 1) {
756
756
  return parentEle.children[0];
757
757
  } else {
758
- return parentEle.children;
758
+ return Array.from(parentEle.children);
759
759
  }
760
760
  }
761
761
  };
@@ -810,7 +810,7 @@ const data$1 = {
810
810
  }
811
811
  },
812
812
  /**
813
- * 获取元素指定数据
813
+ * 设置元素指定数据
814
814
  * @param {Object} el
815
815
  * @param {Object} key
816
816
  * @param {Object} value
@@ -831,68 +831,74 @@ const common$1 = {
831
831
  /**
832
832
  * 常用判断
833
833
  * @param {Object} text 要判断的字符串
834
- * @param {Object} params 判断的类型字符串
834
+ * @param {Object} param 判断的类型字符串
835
835
  */
836
- matchingText(text2, params) {
836
+ matchingText(text2, param) {
837
837
  if (!text2 || typeof text2 != "string") {
838
838
  throw new TypeError("The first argument must be a string");
839
839
  }
840
- if (!params || typeof params != "string") {
840
+ if (!param || typeof param != "string") {
841
841
  throw new TypeError("The second argument must be a string");
842
842
  }
843
843
  let reg = null;
844
- if (params == "Chinese") {
844
+ if (param == "Chinese") {
845
845
  reg = /^[\u4e00-\u9fa5]+$/;
846
846
  }
847
- if (params == "chinese") {
847
+ if (param == "chinese") {
848
848
  reg = /[\u4e00-\u9fa5]/;
849
849
  }
850
- if (params == "email") {
850
+ if (param == "email") {
851
851
  reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
852
852
  }
853
- if (params == "username") {
853
+ if (param == "username") {
854
854
  reg = /^[a-zA-Z0-9_]{4,16}$/;
855
855
  }
856
- if (params == "int+") {
856
+ if (param == "int+") {
857
857
  reg = /^\d+$/;
858
858
  }
859
- if (params == "int-") {
859
+ if (param == "int-") {
860
860
  reg = /^-\d+$/;
861
861
  }
862
- if (params == "int") {
862
+ if (param == "int") {
863
863
  reg = /^-?\d+$/;
864
864
  }
865
- if (params == "pos") {
865
+ if (param == "pos") {
866
866
  reg = /^\d*\.?\d+$/;
867
867
  }
868
- if (params == "neg") {
868
+ if (param == "neg") {
869
869
  reg = /^-\d*\.?\d+$/;
870
870
  }
871
- if (params == "number") {
871
+ if (param == "number") {
872
872
  reg = /^-?\d*\.?\d+$/;
873
873
  }
874
- if (params == "phone") {
874
+ if (param == "phone") {
875
875
  reg = /^1[0-9]\d{9}$/;
876
876
  }
877
- if (params == "idCard") {
877
+ if (param == "idCard") {
878
878
  reg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
879
879
  }
880
- if (params == "url") {
881
- reg = /^((https?|ftp|file):\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
880
+ if (param == "url") {
881
+ reg = /^((https?|ftp|file):\/\/)?([\da-z\.-]+)\.([\da-z\.]{2,6})([\/\w \.-]*)*\/?$/;
882
882
  }
883
- if (params == "IPv4") {
883
+ if (param == "IPv4") {
884
884
  reg = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
885
885
  }
886
- if (params == "hex") {
886
+ if (param == "hex") {
887
887
  reg = /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/;
888
888
  }
889
- if (params == "QQ") {
889
+ if (param == "rgb") {
890
+ reg = /^rgb\((25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d),\s?(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d),\s?(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\)$/;
891
+ }
892
+ if (param == "rgba") {
893
+ reg = /^rgba\((25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d),\s?(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d),\s?(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d),\s?(0?\.\d|1(\.0)?|0)\)$/;
894
+ }
895
+ if (param == "QQ") {
890
896
  reg = /^[1-9][0-9]{4,10}$/;
891
897
  }
892
- if (params == "weixin") {
898
+ if (param == "weixin") {
893
899
  reg = /^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/;
894
900
  }
895
- if (params == "plate") {
901
+ if (param == "plate") {
896
902
  reg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/;
897
903
  }
898
904
  if (!reg) {
@@ -930,12 +936,10 @@ const common$1 = {
930
936
  if (this.isObject(obj2)) {
931
937
  if (Object.keys(obj2).length == 0) {
932
938
  return true;
933
- } else {
934
- return false;
935
939
  }
936
- } else {
937
940
  return false;
938
941
  }
942
+ return false;
939
943
  },
940
944
  /**
941
945
  * 判断两个参数是否相等
@@ -947,32 +951,25 @@ const common$1 = {
947
951
  return false;
948
952
  }
949
953
  if (this.isObject(a) && this.isObject(b)) {
950
- a = Object.assign({}, a);
951
- b = Object.assign({}, b);
952
954
  let aProps = Object.getOwnPropertyNames(a);
953
955
  let bProps = Object.getOwnPropertyNames(b);
954
956
  if (aProps.length != bProps.length) {
955
957
  return false;
956
958
  }
957
959
  let length = aProps.length;
960
+ let isEqual = true;
958
961
  for (let i = 0; i < length; i++) {
959
962
  let propName = aProps[i];
960
963
  let propA = a[propName];
961
964
  let propB = b[propName];
962
- if (this.isObject(propA)) {
963
- if (this.equal(propA, propB)) {
964
- return true;
965
- } else {
966
- return false;
967
- }
968
- } else if (propA !== propB) {
969
- return false;
965
+ if (!this.equal(propA, propB)) {
966
+ isEqual = false;
967
+ break;
970
968
  }
971
969
  }
972
- return true;
973
- } else {
974
- return a === b;
970
+ return isEqual;
975
971
  }
972
+ return a === b;
976
973
  },
977
974
  /**
978
975
  * 是否对象
@@ -993,9 +990,28 @@ const common$1 = {
993
990
  throw new TypeError("No text to copy is defined");
994
991
  }
995
992
  if (!navigator.clipboard) {
996
- throw new Error("navigator.clipboard 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");
993
+ throw new Error("navigator.clipboard must be obtained in a secure environment, such as localhost, 127.0.0.1, or https, so the method won't work");
997
994
  }
998
995
  return navigator.clipboard.writeText(text2);
996
+ },
997
+ /**
998
+ * 深度克隆
999
+ * @param {Object} data
1000
+ */
1001
+ clone(data2) {
1002
+ if (this.isObject(data2)) {
1003
+ if (Array.isArray(data2)) {
1004
+ return data2.map((item) => {
1005
+ return this.clone(item);
1006
+ });
1007
+ }
1008
+ let newData = {};
1009
+ for (let key in data2) {
1010
+ newData[key] = this.clone(data2[key]);
1011
+ }
1012
+ return newData;
1013
+ }
1014
+ return data2;
999
1015
  }
1000
1016
  };
1001
1017
  const parseEventName$1 = (eventName) => {
@@ -1503,9 +1519,11 @@ const platform$1 = {
1503
1519
  Windows_Version: function() {
1504
1520
  if (userAgent.includes("Windows NT 6.1") || userAgent.includes("Windows 7")) {
1505
1521
  return "Win7";
1506
- } else if (userAgent.includes("Windows NT 6.3") || userAgent.includes("Windows NT 6.2") || userAgent.includes("Windows NT 8")) {
1522
+ }
1523
+ if (userAgent.includes("Windows NT 6.3") || userAgent.includes("Windows NT 6.2") || userAgent.includes("Windows NT 8")) {
1507
1524
  return "Win8";
1508
- } else if (userAgent.includes("Windows NT 10") || userAgent.includes("Windows NT 6.4")) {
1525
+ }
1526
+ if (userAgent.includes("Windows NT 10") || userAgent.includes("Windows NT 6.4")) {
1509
1527
  return "Win10";
1510
1528
  }
1511
1529
  return "";
@@ -1868,6 +1886,27 @@ const initEditorOptions = (options) => {
1868
1886
  }
1869
1887
  return opts;
1870
1888
  };
1889
+ const queryHasValue = (obj$1$1, name, value) => {
1890
+ if (value == null || value == void 0) {
1891
+ return obj$1$1.hasOwnProperty(name);
1892
+ }
1893
+ if (typeof value == "string") {
1894
+ value = value.toLocaleLowerCase();
1895
+ }
1896
+ let ownValue = obj$1$1[name];
1897
+ if (typeof ownValue == "string") {
1898
+ ownValue = ownValue.toLocaleLowerCase();
1899
+ }
1900
+ if (typeof value == "string" && value && obj$1.common.matchingText(value, "hex")) {
1901
+ const arr = obj$1.color.hex2rgb(value);
1902
+ value = `rgb(${arr[0]},${arr[1]},${arr[2]})`;
1903
+ }
1904
+ if (typeof ownValue == "string" && ownValue && obj$1.common.matchingText(ownValue, "hex")) {
1905
+ const arr = obj$1.color.hex2rgb(ownValue);
1906
+ ownValue = `rgb(${arr[0]},${arr[1]},${arr[2]})`;
1907
+ }
1908
+ return ownValue == value;
1909
+ };
1871
1910
  const _AlexElement = class _AlexElement2 {
1872
1911
  constructor(type, parsedom, marks, styles, textContent) {
1873
1912
  this.key = createUniqueKey();
@@ -2267,6 +2306,12 @@ __publicField(_AlexElement, "BLOCK_NODE", "p");
2267
2306
  __publicField(_AlexElement, "TEXT_NODE", "span");
2268
2307
  __publicField(_AlexElement, "VOID_NODES", ["colgroup", "col"]);
2269
2308
  let AlexElement = _AlexElement;
2309
+ class AlexRange {
2310
+ constructor(anchor, focus) {
2311
+ this.anchor = anchor;
2312
+ this.focus = focus;
2313
+ }
2314
+ }
2270
2315
  class AlexPoint {
2271
2316
  constructor(element2, offset) {
2272
2317
  this.element = element2;
@@ -2358,12 +2403,6 @@ class AlexPoint {
2358
2403
  }
2359
2404
  }
2360
2405
  }
2361
- class AlexRange {
2362
- constructor(anchor, focus) {
2363
- this.anchor = anchor;
2364
- this.focus = focus;
2365
- }
2366
- }
2367
2406
  class AlexHistory {
2368
2407
  constructor() {
2369
2408
  this.records = [];
@@ -2379,15 +2418,7 @@ class AlexHistory {
2379
2418
  const newStack = stack.map((ele) => {
2380
2419
  return ele.__fullClone();
2381
2420
  });
2382
- const anchorElement = AlexElement.flatElements(newStack).find((ele) => {
2383
- return ele.key == range.anchor.element.key;
2384
- });
2385
- const focusElement = AlexElement.flatElements(newStack).find((ele) => {
2386
- return ele.key == range.focus.element.key;
2387
- });
2388
- const anchor = new AlexPoint(anchorElement, range.anchor.offset);
2389
- const focus = new AlexPoint(focusElement, range.focus.offset);
2390
- const newRange = new AlexRange(anchor, focus);
2421
+ const newRange = this.__cloneRange(newStack, range);
2391
2422
  this.records.push({
2392
2423
  stack: newStack,
2393
2424
  range: newRange
@@ -2414,21 +2445,38 @@ class AlexHistory {
2414
2445
  const newStack = stack.map((ele) => {
2415
2446
  return ele.__fullClone();
2416
2447
  });
2417
- const anchorElement = AlexElement.flatElements(newStack).find((ele) => {
2418
- return ele.key == range.anchor.element.key;
2419
- });
2420
- const focusElement = AlexElement.flatElements(newStack).find((ele) => {
2421
- return ele.key == range.focus.element.key;
2422
- });
2423
- const anchor = new AlexPoint(anchorElement, range.anchor.offset);
2424
- const focus = new AlexPoint(focusElement, range.focus.offset);
2425
- const newRange = new AlexRange(anchor, focus);
2448
+ const newRange = this.__cloneRange(newStack, range);
2426
2449
  return {
2427
2450
  current,
2428
2451
  stack: newStack,
2429
2452
  range: newRange
2430
2453
  };
2431
2454
  }
2455
+ /**
2456
+ * 更新当前历史记录的range
2457
+ */
2458
+ updateCurrentRange(range) {
2459
+ const records = this.records[this.current];
2460
+ const newRange = this.__cloneRange(records.stack, range);
2461
+ this.records[this.current].range = newRange;
2462
+ }
2463
+ /**
2464
+ * 克隆range
2465
+ */
2466
+ __cloneRange(newStack, range) {
2467
+ if (range) {
2468
+ const anchorElement = AlexElement.flatElements(newStack).find((ele) => {
2469
+ return ele.key == range.anchor.element.key;
2470
+ });
2471
+ const focusElement = AlexElement.flatElements(newStack).find((ele) => {
2472
+ return ele.key == range.focus.element.key;
2473
+ });
2474
+ const anchor = new AlexPoint(anchorElement, range.anchor.offset);
2475
+ const focus = new AlexPoint(focusElement, range.focus.offset);
2476
+ return new AlexRange(anchor, focus);
2477
+ }
2478
+ return null;
2479
+ }
2432
2480
  }
2433
2481
  const blockParse = [
2434
2482
  {
@@ -2670,10 +2718,10 @@ const breakFormat = function(element2) {
2670
2718
  });
2671
2719
  if (allIsBreak && children.length) {
2672
2720
  const breakEl = children[0];
2673
- if (element2.isContains(this.range.anchor.element)) {
2721
+ if (this.range && element2.isContains(this.range.anchor.element)) {
2674
2722
  this.range.anchor.moveToStart(breakEl);
2675
2723
  }
2676
- if (element2.isContains(this.range.focus.element)) {
2724
+ if (this.range && element2.isContains(this.range.focus.element)) {
2677
2725
  this.range.focus.moveToStart(breakEl);
2678
2726
  }
2679
2727
  element2.children = [breakEl];
@@ -2702,7 +2750,7 @@ const mergeWithBrotherElement = function(element2) {
2702
2750
  const merge = (pel, nel) => {
2703
2751
  if (pel.isEmpty() || nel.isEmpty()) {
2704
2752
  if (nel.isEmpty()) {
2705
- if (nel.isContains(this.range.anchor.element)) {
2753
+ if (this.range && nel.isContains(this.range.anchor.element)) {
2706
2754
  if (pel.isEmpty()) {
2707
2755
  this.range.anchor.element = pel;
2708
2756
  this.range.anchor.offset = 0;
@@ -2710,7 +2758,7 @@ const mergeWithBrotherElement = function(element2) {
2710
2758
  this.range.anchor.moveToEnd(pel);
2711
2759
  }
2712
2760
  }
2713
- if (nel.isContains(this.range.focus.element)) {
2761
+ if (this.range && nel.isContains(this.range.focus.element)) {
2714
2762
  if (pel.isEmpty()) {
2715
2763
  this.range.focus.element = pel;
2716
2764
  this.range.focus.offset = 0;
@@ -2723,7 +2771,7 @@ const mergeWithBrotherElement = function(element2) {
2723
2771
  });
2724
2772
  nel.parent.children.splice(index, 1);
2725
2773
  } else if (pel.isEmpty()) {
2726
- if (pel.isContains(this.range.anchor.element)) {
2774
+ if (this.range && pel.isContains(this.range.anchor.element)) {
2727
2775
  if (nel.isEmpty()) {
2728
2776
  this.range.anchor.element = nel;
2729
2777
  this.range.anchor.offset = 0;
@@ -2731,7 +2779,7 @@ const mergeWithBrotherElement = function(element2) {
2731
2779
  this.range.anchor.moveToStart(nel);
2732
2780
  }
2733
2781
  }
2734
- if (pel.isContains(this.range.focus.element)) {
2782
+ if (this.range && pel.isContains(this.range.focus.element)) {
2735
2783
  if (nel.isEmpty()) {
2736
2784
  this.range.focus.element = nel;
2737
2785
  this.range.focus.offset = 0;
@@ -2745,11 +2793,11 @@ const mergeWithBrotherElement = function(element2) {
2745
2793
  pel.parent.children.splice(index, 1);
2746
2794
  }
2747
2795
  } else if (pel.isText()) {
2748
- if (nel.isEqual(this.range.anchor.element)) {
2796
+ if (this.range && nel.isEqual(this.range.anchor.element)) {
2749
2797
  this.range.anchor.element = pel;
2750
2798
  this.range.anchor.offset = pel.textContent.length + this.range.anchor.offset;
2751
2799
  }
2752
- if (nel.isEqual(this.range.focus.element)) {
2800
+ if (this.range && nel.isEqual(this.range.focus.element)) {
2753
2801
  this.range.focus.element = pel;
2754
2802
  this.range.focus.offset = pel.textContent.length + this.range.focus.offset;
2755
2803
  }
@@ -2814,10 +2862,10 @@ const mergeWithParentElement = function(element2) {
2814
2862
  }
2815
2863
  parent.textContent = child.textContent;
2816
2864
  parent.children = null;
2817
- if (child.isContains(this.range.anchor.element)) {
2865
+ if (this.range && child.isContains(this.range.anchor.element)) {
2818
2866
  this.range.anchor.element = parent;
2819
2867
  }
2820
- if (child.isContains(this.range.focus.element)) {
2868
+ if (this.range && child.isContains(this.range.focus.element)) {
2821
2869
  this.range.focus.element = parent;
2822
2870
  }
2823
2871
  } else {
@@ -2869,14 +2917,6 @@ const checkStack = function() {
2869
2917
  const breakEle = new AlexElement("closed", "br", null, null, null);
2870
2918
  this.addElementTo(breakEle, ele);
2871
2919
  this.stack = [ele];
2872
- const anchor = new AlexPoint(breakEle, 0);
2873
- const focus = new AlexPoint(breakEle, 0);
2874
- this.range = new AlexRange(anchor, focus);
2875
- } else {
2876
- const firstElement = elements[0];
2877
- const anchor = new AlexPoint(firstElement, 0);
2878
- const focus = new AlexPoint(firstElement, 0);
2879
- this.range = new AlexRange(anchor, focus);
2880
2920
  }
2881
2921
  };
2882
2922
  const setRecentlyPoint = function(point) {
@@ -2935,7 +2975,7 @@ const setRangeInVisible = function() {
2935
2975
  }
2936
2976
  const childRect = target.getBoundingClientRect();
2937
2977
  const parentRect = root2.getBoundingClientRect();
2938
- if (childRect.top < parentRect.top && parentRect.top >= childRect.bottom) {
2978
+ if (childRect.top < parentRect.top) {
2939
2979
  await obj$1.element.setScrollTop({
2940
2980
  el: root2,
2941
2981
  number: 0
@@ -2946,7 +2986,7 @@ const setRangeInVisible = function() {
2946
2986
  el: root2,
2947
2987
  number: tempChildRect.top - tempParentRect.top - tempChildRect.height * 2
2948
2988
  });
2949
- } else if (childRect.bottom > parentRect.bottom && parentRect.bottom <= childRect.top) {
2989
+ } else if (childRect.bottom > parentRect.bottom) {
2950
2990
  await obj$1.element.setScrollTop({
2951
2991
  el: root2,
2952
2992
  number: 0
@@ -3034,8 +3074,12 @@ const handleSelectionChange = function() {
3034
3074
  const focusEle = this.getElementByKey(focusKey);
3035
3075
  const anchor = new AlexPoint(anchorEle, anchorOffset);
3036
3076
  const focus = new AlexPoint(focusEle, focusOffset);
3037
- this.range.anchor = anchor;
3038
- this.range.focus = focus;
3077
+ if (this.range) {
3078
+ this.range.anchor = anchor;
3079
+ this.range.focus = focus;
3080
+ } else {
3081
+ this.range = new AlexRange(anchor, focus);
3082
+ }
3039
3083
  this.emit("rangeUpdate", this.range);
3040
3084
  }
3041
3085
  }
@@ -3197,6 +3241,18 @@ class AlexEditor {
3197
3241
  obj$1.event.on(this.$el, "focus.alex_editor", handleFocus.bind(this));
3198
3242
  obj$1.event.on(this.$el, "blur.alex_editor", handleBlur.bind(this));
3199
3243
  }
3244
+ /**
3245
+ * 初始化range
3246
+ */
3247
+ initRange() {
3248
+ const elements = AlexElement.flatElements(this.stack).filter((el) => {
3249
+ return !el.isEmpty() && !AlexElement.VOID_NODES.includes(el.parsedom);
3250
+ });
3251
+ const firstElement = elements[0];
3252
+ const anchor = new AlexPoint(firstElement, 0);
3253
+ const focus = new AlexPoint(firstElement, 0);
3254
+ this.range = new AlexRange(anchor, focus);
3255
+ }
3200
3256
  /**
3201
3257
  * 根据光标进行粘贴操作
3202
3258
  */
@@ -3204,6 +3260,9 @@ class AlexEditor {
3204
3260
  if (this.disabled) {
3205
3261
  return;
3206
3262
  }
3263
+ if (!this.range) {
3264
+ return;
3265
+ }
3207
3266
  if (!this.useClipboard) {
3208
3267
  return;
3209
3268
  }
@@ -3310,6 +3369,9 @@ class AlexEditor {
3310
3369
  if (!this.useClipboard) {
3311
3370
  return;
3312
3371
  }
3372
+ if (!this.range) {
3373
+ return;
3374
+ }
3313
3375
  if (!this.allowCut) {
3314
3376
  return;
3315
3377
  }
@@ -3330,6 +3392,9 @@ class AlexEditor {
3330
3392
  if (!this.useClipboard) {
3331
3393
  return;
3332
3394
  }
3395
+ if (!this.range) {
3396
+ return;
3397
+ }
3333
3398
  if (!this.allowCopy) {
3334
3399
  return;
3335
3400
  }
@@ -3365,6 +3430,9 @@ class AlexEditor {
3365
3430
  if (this.disabled) {
3366
3431
  return;
3367
3432
  }
3433
+ if (!this.range) {
3434
+ return;
3435
+ }
3368
3436
  if (this.range.anchor.isEqual(this.range.focus)) {
3369
3437
  const previousElement = this.getPreviousElementOfPoint(this.range.anchor);
3370
3438
  const block = this.range.anchor.element.getBlock();
@@ -3631,6 +3699,9 @@ class AlexEditor {
3631
3699
  if (!data2 || typeof data2 != "string") {
3632
3700
  throw new Error("The argument must be a string");
3633
3701
  }
3702
+ if (!this.range) {
3703
+ return;
3704
+ }
3634
3705
  if (this.range.anchor.isEqual(this.range.focus)) {
3635
3706
  if (!this.range.anchor.element.isPreStyle()) {
3636
3707
  data2 = data2.replace(/\s/g, () => {
@@ -3666,6 +3737,9 @@ class AlexEditor {
3666
3737
  if (this.disabled) {
3667
3738
  return;
3668
3739
  }
3740
+ if (!this.range) {
3741
+ return;
3742
+ }
3669
3743
  if (this.range.anchor.isEqual(this.range.focus)) {
3670
3744
  const previousElement = this.getPreviousElementOfPoint(this.range.anchor);
3671
3745
  const nextElement = this.getNextElementOfPoint(this.range.anchor);
@@ -3766,6 +3840,9 @@ class AlexEditor {
3766
3840
  if (this.disabled) {
3767
3841
  return;
3768
3842
  }
3843
+ if (!this.range) {
3844
+ return;
3845
+ }
3769
3846
  if (!AlexElement.isElement(ele)) {
3770
3847
  throw new Error("The argument must be an AlexElement instance");
3771
3848
  }
@@ -3912,10 +3989,10 @@ class AlexEditor {
3912
3989
  while (index < element2.children.length) {
3913
3990
  const ele = element2.children[index];
3914
3991
  if (ele.isEmpty()) {
3915
- if (ele.isContains(this.range.anchor.element)) {
3992
+ if (this.range && ele.isContains(this.range.anchor.element)) {
3916
3993
  setRecentlyPoint.apply(this, [this.range.anchor]);
3917
3994
  }
3918
- if (ele.isContains(this.range.focus.element)) {
3995
+ if (this.range && ele.isContains(this.range.focus.element)) {
3919
3996
  setRecentlyPoint.apply(this, [this.range.focus]);
3920
3997
  }
3921
3998
  element2.children.splice(index, 1);
@@ -3944,10 +4021,10 @@ class AlexEditor {
3944
4021
  while (index < this.stack.length) {
3945
4022
  const ele = this.stack[index];
3946
4023
  if (ele.isEmpty()) {
3947
- if (ele.isContains(this.range.anchor.element)) {
4024
+ if (this.range && ele.isContains(this.range.anchor.element)) {
3948
4025
  setRecentlyPoint.apply(this, [this.range.anchor]);
3949
4026
  }
3950
- if (ele.isContains(this.range.focus.element)) {
4027
+ if (this.range && ele.isContains(this.range.focus.element)) {
3951
4028
  setRecentlyPoint.apply(this, [this.range.focus]);
3952
4029
  }
3953
4030
  this.stack.splice(index, 1);
@@ -3958,10 +4035,10 @@ class AlexEditor {
3958
4035
  }
3959
4036
  this.formatElement(ele);
3960
4037
  if (ele.isEmpty()) {
3961
- if (ele.isContains(this.range.anchor.element)) {
4038
+ if (this.range && ele.isContains(this.range.anchor.element)) {
3962
4039
  setRecentlyPoint.apply(this, [this.range.anchor]);
3963
4040
  }
3964
- if (ele.isContains(this.range.focus.element)) {
4041
+ if (this.range && ele.isContains(this.range.focus.element)) {
3965
4042
  setRecentlyPoint.apply(this, [this.range.focus]);
3966
4043
  }
3967
4044
  this.stack.splice(index, 1);
@@ -4006,6 +4083,11 @@ class AlexEditor {
4006
4083
  if (this.disabled) {
4007
4084
  return;
4008
4085
  }
4086
+ if (!this.range) {
4087
+ const selection2 = window.getSelection();
4088
+ selection2.removeAllRanges();
4089
+ return;
4090
+ }
4009
4091
  const handler = (point) => {
4010
4092
  let node = null;
4011
4093
  let offset = null;
@@ -4293,6 +4375,9 @@ class AlexEditor {
4293
4375
  * 获取选区之间的元素
4294
4376
  */
4295
4377
  getElementsByRange(includes = false, flat = false) {
4378
+ if (!this.range) {
4379
+ return;
4380
+ }
4296
4381
  if (this.range.anchor.isEqual(this.range.focus)) {
4297
4382
  return [];
4298
4383
  }
@@ -4401,6 +4486,9 @@ class AlexEditor {
4401
4486
  * 分割选区选中的元素,会更新光标位置
4402
4487
  */
4403
4488
  splitElementsByRange(includes = false, flat = false) {
4489
+ if (!this.range) {
4490
+ return;
4491
+ }
4404
4492
  const result = this.getElementsByRange(includes, flat);
4405
4493
  let elements = [];
4406
4494
  result.forEach((item, index) => {
@@ -4522,6 +4610,11 @@ class AlexEditor {
4522
4610
  if (this.disabled) {
4523
4611
  return;
4524
4612
  }
4613
+ let rangeIsNull = false;
4614
+ if (!this.range) {
4615
+ this.initRange();
4616
+ rangeIsNull = true;
4617
+ }
4525
4618
  if (AlexElement.isElement(element2)) {
4526
4619
  this.range.anchor.moveToStart(element2);
4527
4620
  this.range.focus.moveToStart(element2);
@@ -4535,6 +4628,9 @@ class AlexEditor {
4535
4628
  this.range.anchor.moveToStart(flatElements[0]);
4536
4629
  this.range.focus.moveToStart(flatElements[0]);
4537
4630
  }
4631
+ if (rangeIsNull) {
4632
+ this.history.updateCurrentRange(this.range);
4633
+ }
4538
4634
  }
4539
4635
  /**
4540
4636
  * 将虚拟光标设置到指定元素最后
@@ -4543,6 +4639,11 @@ class AlexEditor {
4543
4639
  if (this.disabled) {
4544
4640
  return;
4545
4641
  }
4642
+ let rangeIsNull = false;
4643
+ if (!this.range) {
4644
+ this.initRange();
4645
+ rangeIsNull = true;
4646
+ }
4546
4647
  if (AlexElement.isElement(element2)) {
4547
4648
  this.range.anchor.moveToEnd(element2);
4548
4649
  this.range.focus.moveToEnd(element2);
@@ -4557,6 +4658,9 @@ class AlexEditor {
4557
4658
  this.range.anchor.moveToEnd(flatElements[length - 1]);
4558
4659
  this.range.focus.moveToEnd(flatElements[length - 1]);
4559
4660
  }
4661
+ if (rangeIsNull) {
4662
+ this.history.updateCurrentRange(this.range);
4663
+ }
4560
4664
  }
4561
4665
  /**
4562
4666
  * 禁用编辑器
@@ -4579,6 +4683,9 @@ class AlexEditor {
4579
4683
  if (this.disabled) {
4580
4684
  return;
4581
4685
  }
4686
+ if (!this.range) {
4687
+ return;
4688
+ }
4582
4689
  if (!obj$1.common.isObject(styles)) {
4583
4690
  throw new Error("The argument must be an object");
4584
4691
  }
@@ -4624,6 +4731,9 @@ class AlexEditor {
4624
4731
  if (this.disabled) {
4625
4732
  return;
4626
4733
  }
4734
+ if (!this.range) {
4735
+ return;
4736
+ }
4627
4737
  const removeFn = (el) => {
4628
4738
  if (Array.isArray(styleNames)) {
4629
4739
  if (el.hasStyles()) {
@@ -4665,12 +4775,12 @@ class AlexEditor {
4665
4775
  if (!name) {
4666
4776
  throw new Error("The first argument cannot be null");
4667
4777
  }
4778
+ if (!this.range) {
4779
+ return false;
4780
+ }
4668
4781
  if (this.range.anchor.isEqual(this.range.focus)) {
4669
4782
  if (this.range.anchor.element.isText() && this.range.anchor.element.hasStyles()) {
4670
- if (value == null || value == void 0) {
4671
- return this.range.anchor.element.styles.hasOwnProperty(name);
4672
- }
4673
- return this.range.anchor.element.styles[name] == value;
4783
+ return queryHasValue(this.range.anchor.element.styles, name, value);
4674
4784
  }
4675
4785
  return false;
4676
4786
  }
@@ -4690,10 +4800,7 @@ class AlexEditor {
4690
4800
  }
4691
4801
  let flag = result.every((item) => {
4692
4802
  if (item.element.hasStyles()) {
4693
- if (value == null || value == void 0) {
4694
- return item.element.styles.hasOwnProperty(name);
4695
- }
4696
- return item.element.styles[name] == value;
4803
+ return queryHasValue(item.element.styles, name, value);
4697
4804
  }
4698
4805
  return false;
4699
4806
  });
@@ -4706,6 +4813,9 @@ class AlexEditor {
4706
4813
  if (this.disabled) {
4707
4814
  return;
4708
4815
  }
4816
+ if (!this.range) {
4817
+ return;
4818
+ }
4709
4819
  if (!obj$1.common.isObject(marks)) {
4710
4820
  throw new Error("The argument must be an object");
4711
4821
  }
@@ -4751,6 +4861,9 @@ class AlexEditor {
4751
4861
  if (this.disabled) {
4752
4862
  return;
4753
4863
  }
4864
+ if (!this.range) {
4865
+ return;
4866
+ }
4754
4867
  const removeFn = (el) => {
4755
4868
  if (Array.isArray(markNames)) {
4756
4869
  if (el.hasMarks()) {
@@ -4792,12 +4905,12 @@ class AlexEditor {
4792
4905
  if (!name) {
4793
4906
  throw new Error("The first argument cannot be null");
4794
4907
  }
4908
+ if (!this.range) {
4909
+ return false;
4910
+ }
4795
4911
  if (this.range.anchor.isEqual(this.range.focus)) {
4796
4912
  if (this.range.anchor.element.isText() && this.range.anchor.element.hasMarks()) {
4797
- if (value == null || value == void 0) {
4798
- return this.range.anchor.element.marks.hasOwnProperty(name);
4799
- }
4800
- return this.range.anchor.element.marks[name] == value;
4913
+ return queryHasValue(this.range.anchor.element.marks, name, value);
4801
4914
  }
4802
4915
  return false;
4803
4916
  }
@@ -4817,10 +4930,7 @@ class AlexEditor {
4817
4930
  }
4818
4931
  let flag = result.every((item) => {
4819
4932
  if (item.element.hasMarks()) {
4820
- if (value == null || value == void 0) {
4821
- return item.element.marks.hasOwnProperty(name);
4822
- }
4823
- return item.element.marks[name] == value;
4933
+ return queryHasValue(item.element.marks, name, value);
4824
4934
  }
4825
4935
  return false;
4826
4936
  });
@@ -5037,10 +5147,10 @@ const string = {
5037
5147
  },
5038
5148
  /**
5039
5149
  * 去除字符串空格
5040
- * @param {Object} str
5150
+ * @param {Object} str 原始字符串
5041
5151
  * @param {Object} global 为true时去除所有空格,否则只去除两边空格
5042
5152
  */
5043
- trim(str, global) {
5153
+ trim(str, global = false) {
5044
5154
  if (typeof str != "string") {
5045
5155
  throw new TypeError("The first argument must be a string");
5046
5156
  }
@@ -5060,9 +5170,9 @@ const element = {
5060
5170
  return data2 && data2 instanceof Window;
5061
5171
  },
5062
5172
  /**
5063
- * 获取元素距离指定祖先元素左侧/顶部/底部/右侧的距离
5173
+ * 获取元素距离某个定位祖先元素左侧/顶部/底部/右侧的距离
5064
5174
  * @param {Object} el 元素
5065
- * @param {Object} root 父元素或者祖先元素,未指定则为document.body
5175
+ * @param {Object} root 定位父元素或者祖先元素,未指定则为document.body
5066
5176
  */
5067
5177
  getElementPoint(el, root) {
5068
5178
  if (!this.isElement(el)) {
@@ -5092,9 +5202,9 @@ const element = {
5092
5202
  };
5093
5203
  },
5094
5204
  /**
5095
- * 判断某个节点是否包含指定节点,包含相等关系和父子关系
5096
- * @param {Object} parentNode 父节点或祖先节点
5097
- * @param {Object} childNode 子节点
5205
+ * 判断某个元素是否包含指定元素,包含相等关系和父子关系
5206
+ * @param {Object} parentNode 父元素或祖先元素
5207
+ * @param {Object} childNode 子元素
5098
5208
  */
5099
5209
  isContains(parentNode, childNode) {
5100
5210
  if (!this.isElement(parentNode)) {
@@ -5114,9 +5224,9 @@ const element = {
5114
5224
  }
5115
5225
  },
5116
5226
  /**
5117
- * 判断某个节点是否是指定节点的父节点
5118
- * @param {Object} parentNode 父节点
5119
- * @param {Object} childNode 子节点
5227
+ * 判断某个元素是否是指定元素的父元素
5228
+ * @param {Object} parentNode 父元素
5229
+ * @param {Object} childNode 子元素
5120
5230
  */
5121
5231
  isParentNode(parentNode, childNode) {
5122
5232
  if (!this.isElement(parentNode)) {
@@ -5131,8 +5241,8 @@ const element = {
5131
5241
  return childNode.parentNode === parentNode;
5132
5242
  },
5133
5243
  /**
5134
- * 查找某个节点下指定选择器的子元素
5135
- * @param {Object} el 元素节点
5244
+ * 查找某个元素下指定选择器的子元素
5245
+ * @param {Object} el 元素
5136
5246
  * @param {Object} selector 支持多选择器,等同于querySelectorAll的参数
5137
5247
  */
5138
5248
  children(el, selector) {
@@ -5148,8 +5258,8 @@ const element = {
5148
5258
  });
5149
5259
  },
5150
5260
  /**
5151
- * 查找某个节点下指定选择器的兄弟节点
5152
- * @param {Object} el 元素节点
5261
+ * 查找某个元素下指定选择器的兄弟元素
5262
+ * @param {Object} el 元素
5153
5263
  * @param {Object} selector 取值等同于queryselectorAll的参数,支持多选择器
5154
5264
  */
5155
5265
  siblings(el, selector) {
@@ -5223,7 +5333,7 @@ const element = {
5223
5333
  },
5224
5334
  /**
5225
5335
  * 移除class
5226
- * @param {Object} el 元素节点
5336
+ * @param {Object} el 元素
5227
5337
  * @param {Object} className 支持多类,以空格划分
5228
5338
  */
5229
5339
  removeClass(el, className) {
@@ -5241,7 +5351,7 @@ const element = {
5241
5351
  },
5242
5352
  /**
5243
5353
  * 添加class
5244
- * @param {Object} el 元素节点
5354
+ * @param {Object} el 元素
5245
5355
  * @param {Object} className 支持多类,以空格划分
5246
5356
  */
5247
5357
  addClass(el, className) {
@@ -5259,7 +5369,7 @@ const element = {
5259
5369
  },
5260
5370
  /**
5261
5371
  * 判断指定元素是否含有指定类名
5262
- * @param {Object} el 元素节点
5372
+ * @param {Object} el 元素
5263
5373
  * @param {Object} className 支持多类,以空格划分
5264
5374
  */
5265
5375
  hasClass(el, className) {
@@ -5587,7 +5697,7 @@ const element = {
5587
5697
  };
5588
5698
  },
5589
5699
  /**
5590
- * 判断是否是元素节点
5700
+ * 判断是否是元素
5591
5701
  * @param {Object} el
5592
5702
  */
5593
5703
  isElement(el) {
@@ -5606,7 +5716,7 @@ const element = {
5606
5716
  if (parentEle.children.length == 1) {
5607
5717
  return parentEle.children[0];
5608
5718
  } else {
5609
- return parentEle.children;
5719
+ return Array.from(parentEle.children);
5610
5720
  }
5611
5721
  }
5612
5722
  };
@@ -5661,7 +5771,7 @@ const data = {
5661
5771
  }
5662
5772
  },
5663
5773
  /**
5664
- * 获取元素指定数据
5774
+ * 设置元素指定数据
5665
5775
  * @param {Object} el
5666
5776
  * @param {Object} key
5667
5777
  * @param {Object} value
@@ -5682,68 +5792,74 @@ const common = {
5682
5792
  /**
5683
5793
  * 常用判断
5684
5794
  * @param {Object} text 要判断的字符串
5685
- * @param {Object} params 判断的类型字符串
5795
+ * @param {Object} param 判断的类型字符串
5686
5796
  */
5687
- matchingText(text2, params) {
5797
+ matchingText(text2, param) {
5688
5798
  if (!text2 || typeof text2 != "string") {
5689
5799
  throw new TypeError("The first argument must be a string");
5690
5800
  }
5691
- if (!params || typeof params != "string") {
5801
+ if (!param || typeof param != "string") {
5692
5802
  throw new TypeError("The second argument must be a string");
5693
5803
  }
5694
5804
  let reg = null;
5695
- if (params == "Chinese") {
5805
+ if (param == "Chinese") {
5696
5806
  reg = /^[\u4e00-\u9fa5]+$/;
5697
5807
  }
5698
- if (params == "chinese") {
5808
+ if (param == "chinese") {
5699
5809
  reg = /[\u4e00-\u9fa5]/;
5700
5810
  }
5701
- if (params == "email") {
5811
+ if (param == "email") {
5702
5812
  reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
5703
5813
  }
5704
- if (params == "username") {
5814
+ if (param == "username") {
5705
5815
  reg = /^[a-zA-Z0-9_]{4,16}$/;
5706
5816
  }
5707
- if (params == "int+") {
5817
+ if (param == "int+") {
5708
5818
  reg = /^\d+$/;
5709
5819
  }
5710
- if (params == "int-") {
5820
+ if (param == "int-") {
5711
5821
  reg = /^-\d+$/;
5712
5822
  }
5713
- if (params == "int") {
5823
+ if (param == "int") {
5714
5824
  reg = /^-?\d+$/;
5715
5825
  }
5716
- if (params == "pos") {
5826
+ if (param == "pos") {
5717
5827
  reg = /^\d*\.?\d+$/;
5718
5828
  }
5719
- if (params == "neg") {
5829
+ if (param == "neg") {
5720
5830
  reg = /^-\d*\.?\d+$/;
5721
5831
  }
5722
- if (params == "number") {
5832
+ if (param == "number") {
5723
5833
  reg = /^-?\d*\.?\d+$/;
5724
5834
  }
5725
- if (params == "phone") {
5835
+ if (param == "phone") {
5726
5836
  reg = /^1[0-9]\d{9}$/;
5727
5837
  }
5728
- if (params == "idCard") {
5838
+ if (param == "idCard") {
5729
5839
  reg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
5730
5840
  }
5731
- if (params == "url") {
5732
- reg = /^((https?|ftp|file):\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
5841
+ if (param == "url") {
5842
+ reg = /^((https?|ftp|file):\/\/)?([\da-z\.-]+)\.([\da-z\.]{2,6})([\/\w \.-]*)*\/?$/;
5733
5843
  }
5734
- if (params == "IPv4") {
5844
+ if (param == "IPv4") {
5735
5845
  reg = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
5736
5846
  }
5737
- if (params == "hex") {
5847
+ if (param == "hex") {
5738
5848
  reg = /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/;
5739
5849
  }
5740
- if (params == "QQ") {
5850
+ if (param == "rgb") {
5851
+ reg = /^rgb\((25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d),\s?(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d),\s?(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\)$/;
5852
+ }
5853
+ if (param == "rgba") {
5854
+ reg = /^rgba\((25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d),\s?(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d),\s?(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d),\s?(0?\.\d|1(\.0)?|0)\)$/;
5855
+ }
5856
+ if (param == "QQ") {
5741
5857
  reg = /^[1-9][0-9]{4,10}$/;
5742
5858
  }
5743
- if (params == "weixin") {
5859
+ if (param == "weixin") {
5744
5860
  reg = /^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/;
5745
5861
  }
5746
- if (params == "plate") {
5862
+ if (param == "plate") {
5747
5863
  reg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/;
5748
5864
  }
5749
5865
  if (!reg) {
@@ -5781,12 +5897,10 @@ const common = {
5781
5897
  if (this.isObject(obj2)) {
5782
5898
  if (Object.keys(obj2).length == 0) {
5783
5899
  return true;
5784
- } else {
5785
- return false;
5786
5900
  }
5787
- } else {
5788
5901
  return false;
5789
5902
  }
5903
+ return false;
5790
5904
  },
5791
5905
  /**
5792
5906
  * 判断两个参数是否相等
@@ -5798,32 +5912,25 @@ const common = {
5798
5912
  return false;
5799
5913
  }
5800
5914
  if (this.isObject(a) && this.isObject(b)) {
5801
- a = Object.assign({}, a);
5802
- b = Object.assign({}, b);
5803
5915
  let aProps = Object.getOwnPropertyNames(a);
5804
5916
  let bProps = Object.getOwnPropertyNames(b);
5805
5917
  if (aProps.length != bProps.length) {
5806
5918
  return false;
5807
5919
  }
5808
5920
  let length = aProps.length;
5921
+ let isEqual = true;
5809
5922
  for (let i = 0; i < length; i++) {
5810
5923
  let propName = aProps[i];
5811
5924
  let propA = a[propName];
5812
5925
  let propB = b[propName];
5813
- if (this.isObject(propA)) {
5814
- if (this.equal(propA, propB)) {
5815
- return true;
5816
- } else {
5817
- return false;
5818
- }
5819
- } else if (propA !== propB) {
5820
- return false;
5926
+ if (!this.equal(propA, propB)) {
5927
+ isEqual = false;
5928
+ break;
5821
5929
  }
5822
5930
  }
5823
- return true;
5824
- } else {
5825
- return a === b;
5931
+ return isEqual;
5826
5932
  }
5933
+ return a === b;
5827
5934
  },
5828
5935
  /**
5829
5936
  * 是否对象
@@ -5844,9 +5951,28 @@ const common = {
5844
5951
  throw new TypeError("No text to copy is defined");
5845
5952
  }
5846
5953
  if (!navigator.clipboard) {
5847
- throw new Error("navigator.clipboard 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");
5954
+ throw new Error("navigator.clipboard must be obtained in a secure environment, such as localhost, 127.0.0.1, or https, so the method won't work");
5848
5955
  }
5849
5956
  return navigator.clipboard.writeText(text2);
5957
+ },
5958
+ /**
5959
+ * 深度克隆
5960
+ * @param {Object} data
5961
+ */
5962
+ clone(data2) {
5963
+ if (this.isObject(data2)) {
5964
+ if (Array.isArray(data2)) {
5965
+ return data2.map((item) => {
5966
+ return this.clone(item);
5967
+ });
5968
+ }
5969
+ let newData = {};
5970
+ for (let key in data2) {
5971
+ newData[key] = this.clone(data2[key]);
5972
+ }
5973
+ return newData;
5974
+ }
5975
+ return data2;
5850
5976
  }
5851
5977
  };
5852
5978
  const parseEventName = (eventName) => {
@@ -6354,9 +6480,11 @@ const platform = {
6354
6480
  Windows_Version: function() {
6355
6481
  if (userAgent.includes("Windows NT 6.1") || userAgent.includes("Windows 7")) {
6356
6482
  return "Win7";
6357
- } else if (userAgent.includes("Windows NT 6.3") || userAgent.includes("Windows NT 6.2") || userAgent.includes("Windows NT 8")) {
6483
+ }
6484
+ if (userAgent.includes("Windows NT 6.3") || userAgent.includes("Windows NT 6.2") || userAgent.includes("Windows NT 8")) {
6358
6485
  return "Win8";
6359
- } else if (userAgent.includes("Windows NT 10") || userAgent.includes("Windows NT 6.4")) {
6486
+ }
6487
+ if (userAgent.includes("Windows NT 10") || userAgent.includes("Windows NT 6.4")) {
6360
6488
  return "Win10";
6361
6489
  }
6362
6490
  return "";
@@ -15363,6 +15491,9 @@ const tableHandle = function(element2) {
15363
15491
  }
15364
15492
  };
15365
15493
  const updateRangeInPre = function(element2, originalTextElements, newElements) {
15494
+ if (!this.range) {
15495
+ return;
15496
+ }
15366
15497
  if (this.range.anchor.element.getBlock().isEqual(element2)) {
15367
15498
  const elIndex = originalTextElements.findIndex((el) => this.range.anchor.element.isEqual(el));
15368
15499
  const offset = originalTextElements.filter((el, i2) => i2 < elIndex).reduce((total, item, i2) => total + item.textContent.length, 0) + this.range.anchor.offset;
@@ -20951,7 +21082,7 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
20951
21082
  ], 14, _hoisted_1$1);
20952
21083
  }
20953
21084
  const Menu = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-4c7850ff"]]);
20954
- const Editify_vue_vue_type_style_index_0_scoped_ee4c1326_lang = "";
21085
+ const Editify_vue_vue_type_style_index_0_scoped_bcab43d0_lang = "";
20955
21086
  const _sfc_main = {
20956
21087
  name: "editify",
20957
21088
  props: { ...editorProps },
@@ -21044,10 +21175,10 @@ const _sfc_main = {
21044
21175
  return;
21045
21176
  }
21046
21177
  this.editor.stack = this.editor.parseHtml(newVal);
21178
+ this.editor.range = null;
21047
21179
  this.editor.formatElementStack();
21048
- this.editor.range.anchor.moveToStart(this.editor.stack[0]);
21049
- this.editor.range.focus.moveToStart(this.editor.stack[0]);
21050
21180
  this.editor.domRender();
21181
+ this.editor.rangeRender();
21051
21182
  },
21052
21183
  //代码视图切换
21053
21184
  isSourceView(newValue) {
@@ -21334,6 +21465,9 @@ const _sfc_main = {
21334
21465
  } else {
21335
21466
  element2.marks["data-editify-task"] = "checked";
21336
21467
  }
21468
+ if (!this.editor.range) {
21469
+ this.editor.initRange();
21470
+ }
21337
21471
  this.editor.range.anchor.moveToEnd(element2);
21338
21472
  this.editor.range.focus.moveToEnd(element2);
21339
21473
  this.editor.formatElementStack();
@@ -21414,6 +21548,9 @@ const _sfc_main = {
21414
21548
  const key = node.getAttribute("data-editify-element");
21415
21549
  if (key) {
21416
21550
  const element2 = this.editor.getElementByKey(key);
21551
+ if (!this.editor.range) {
21552
+ this.editor.initRange();
21553
+ }
21417
21554
  this.editor.range.anchor.moveToStart(element2);
21418
21555
  this.editor.range.focus.moveToEnd(element2);
21419
21556
  this.editor.rangeRender();
@@ -21563,6 +21700,9 @@ const _sfc_main = {
21563
21700
  if (this.disabled) {
21564
21701
  return null;
21565
21702
  }
21703
+ if (!this.editor.range) {
21704
+ return null;
21705
+ }
21566
21706
  if (this.editor.range.anchor.element.isEqual(this.editor.range.focus.element)) {
21567
21707
  return this.getParsedomElementByElement(this.editor.range.anchor.element, parsedom);
21568
21708
  }
@@ -21595,6 +21735,9 @@ const _sfc_main = {
21595
21735
  if (this.disabled) {
21596
21736
  return;
21597
21737
  }
21738
+ if (!this.editor.range) {
21739
+ return;
21740
+ }
21598
21741
  const element2 = this.getCurrentParsedomElement(parsedom);
21599
21742
  if (element2) {
21600
21743
  element2.toEmpty();
@@ -21608,6 +21751,9 @@ const _sfc_main = {
21608
21751
  if (this.disabled) {
21609
21752
  return;
21610
21753
  }
21754
+ if (!this.editor.range) {
21755
+ return;
21756
+ }
21611
21757
  const link = this.getCurrentParsedomElement("a");
21612
21758
  if (link) {
21613
21759
  link.parsedom = AlexElement.TEXT_NODE;
@@ -21623,6 +21769,9 @@ const _sfc_main = {
21623
21769
  if (this.disabled) {
21624
21770
  return;
21625
21771
  }
21772
+ if (!this.editor.range) {
21773
+ return;
21774
+ }
21626
21775
  const values = getButtonOptionsConfig(this.$editTrans, this.$editLocale).heading.map((item) => {
21627
21776
  return item.value;
21628
21777
  });
@@ -21655,6 +21804,9 @@ const _sfc_main = {
21655
21804
  if (this.disabled) {
21656
21805
  return;
21657
21806
  }
21807
+ if (!this.editor.range) {
21808
+ return;
21809
+ }
21658
21810
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
21659
21811
  const block = this.editor.range.anchor.element.getBlock();
21660
21812
  const isList = blockIsList(block, ordered);
@@ -21691,6 +21843,9 @@ const _sfc_main = {
21691
21843
  if (this.disabled) {
21692
21844
  return;
21693
21845
  }
21846
+ if (!this.editor.range) {
21847
+ return;
21848
+ }
21694
21849
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
21695
21850
  const block = this.editor.range.anchor.element.getBlock();
21696
21851
  const isTask = blockIsTask(block);
@@ -21727,6 +21882,9 @@ const _sfc_main = {
21727
21882
  if (this.disabled) {
21728
21883
  return;
21729
21884
  }
21885
+ if (!this.editor.range) {
21886
+ return;
21887
+ }
21730
21888
  const active = this.queryTextStyle(name, value);
21731
21889
  if (active) {
21732
21890
  this.editor.removeTextStyle([name]);
@@ -21748,6 +21906,9 @@ const _sfc_main = {
21748
21906
  if (this.disabled) {
21749
21907
  return;
21750
21908
  }
21909
+ if (!this.editor.range) {
21910
+ return;
21911
+ }
21751
21912
  const active = this.queryTextMark(name, value);
21752
21913
  if (active) {
21753
21914
  this.editor.removeTextMark([name]);
@@ -21769,6 +21930,9 @@ const _sfc_main = {
21769
21930
  if (this.disabled) {
21770
21931
  return;
21771
21932
  }
21933
+ if (!this.editor.range) {
21934
+ return;
21935
+ }
21772
21936
  this.editor.removeTextStyle();
21773
21937
  this.editor.removeTextMark();
21774
21938
  this.editor.formatElementStack();
@@ -21780,6 +21944,9 @@ const _sfc_main = {
21780
21944
  if (this.disabled) {
21781
21945
  return;
21782
21946
  }
21947
+ if (!this.editor.range) {
21948
+ return;
21949
+ }
21783
21950
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
21784
21951
  const block = this.editor.range.anchor.element.getBlock();
21785
21952
  const inblock = this.editor.range.anchor.element.getInblock();
@@ -21873,6 +22040,9 @@ const _sfc_main = {
21873
22040
  if (this.disabled) {
21874
22041
  return;
21875
22042
  }
22043
+ if (!this.editor.range) {
22044
+ return;
22045
+ }
21876
22046
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
21877
22047
  const block = this.editor.range.anchor.element.getBlock();
21878
22048
  const oldParsedom = block.parsedom;
@@ -21907,6 +22077,9 @@ const _sfc_main = {
21907
22077
  if (this.disabled) {
21908
22078
  return;
21909
22079
  }
22080
+ if (!this.editor.range) {
22081
+ return;
22082
+ }
21910
22083
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
21911
22084
  const block = this.editor.range.anchor.element.getBlock();
21912
22085
  const inblock = this.editor.range.anchor.element.getInblock();
@@ -21970,6 +22143,9 @@ const _sfc_main = {
21970
22143
  if (this.disabled) {
21971
22144
  return;
21972
22145
  }
22146
+ if (!this.editor.range) {
22147
+ return;
22148
+ }
21973
22149
  const fn = (element2) => {
21974
22150
  if (element2.hasStyles()) {
21975
22151
  if (element2.styles.hasOwnProperty("text-indent")) {
@@ -22018,6 +22194,9 @@ const _sfc_main = {
22018
22194
  if (this.disabled) {
22019
22195
  return;
22020
22196
  }
22197
+ if (!this.editor.range) {
22198
+ return;
22199
+ }
22021
22200
  const fn = (element2) => {
22022
22201
  if (element2.hasStyles() && element2.styles.hasOwnProperty("text-indent")) {
22023
22202
  let val = element2.styles["text-indent"];
@@ -22038,7 +22217,7 @@ const _sfc_main = {
22038
22217
  fn(block);
22039
22218
  }
22040
22219
  } else {
22041
- const result = this.getElementsByRange(true, false);
22220
+ const result = this.editor.getElementsByRange(true, false);
22042
22221
  result.forEach((item) => {
22043
22222
  const block = item.element.getBlock();
22044
22223
  const inblock = item.element.getInblock();
@@ -22058,6 +22237,9 @@ const _sfc_main = {
22058
22237
  if (this.disabled) {
22059
22238
  return;
22060
22239
  }
22240
+ if (!this.editor.range) {
22241
+ return;
22242
+ }
22061
22243
  if (!url2 || typeof url2 != "string") {
22062
22244
  throw new Error("An image address must be given");
22063
22245
  }
@@ -22080,6 +22262,9 @@ const _sfc_main = {
22080
22262
  if (this.disabled) {
22081
22263
  return;
22082
22264
  }
22265
+ if (!this.editor.range) {
22266
+ return;
22267
+ }
22083
22268
  if (!url2 || typeof url2 != "string") {
22084
22269
  throw new Error("A video address must be given");
22085
22270
  }
@@ -22105,171 +22290,199 @@ const _sfc_main = {
22105
22290
  },
22106
22291
  //api:选区是否含有代码块样式
22107
22292
  hasPreStyle() {
22293
+ if (!this.editor.range) {
22294
+ return false;
22295
+ }
22108
22296
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22109
22297
  return this.editor.range.anchor.element.isPreStyle();
22110
- } else {
22111
- const result = this.editor.getElementsByRange(true, false);
22112
- return result.some((item) => {
22113
- return item.element.isPreStyle();
22114
- });
22115
22298
  }
22299
+ const result = this.editor.getElementsByRange(true, false);
22300
+ return result.some((item) => {
22301
+ return item.element.isPreStyle();
22302
+ });
22116
22303
  },
22117
22304
  //api:选区是否含有引用
22118
22305
  hasQuote() {
22306
+ if (!this.editor.range) {
22307
+ return false;
22308
+ }
22119
22309
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22120
22310
  const block = this.editor.range.anchor.element.getBlock();
22121
22311
  return block.parsedom == "blockquote";
22122
- } else {
22123
- const result = this.editor.getElementsByRange(true, false);
22124
- return result.some((item) => {
22125
- if (item.element.isBlock()) {
22126
- return item.element.parsedom == "blockquote";
22127
- } else {
22128
- const block = item.element.getBlock();
22129
- return block.parsedom == "blockquote";
22130
- }
22131
- });
22132
22312
  }
22313
+ const result = this.editor.getElementsByRange(true, false);
22314
+ return result.some((item) => {
22315
+ if (item.element.isBlock()) {
22316
+ return item.element.parsedom == "blockquote";
22317
+ } else {
22318
+ const block = item.element.getBlock();
22319
+ return block.parsedom == "blockquote";
22320
+ }
22321
+ });
22133
22322
  },
22134
22323
  //api:选区是否含有列表
22135
22324
  hasList(ordered = false) {
22325
+ if (!this.editor.range) {
22326
+ return false;
22327
+ }
22136
22328
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22137
22329
  const block = this.editor.range.anchor.element.getBlock();
22138
22330
  return blockIsList(block, ordered);
22139
- } else {
22140
- const result = this.editor.getElementsByRange(true, false);
22141
- return result.some((item) => {
22142
- if (item.element.isBlock()) {
22143
- return blockIsList(item.element, ordered);
22144
- } else {
22145
- const block = item.element.getBlock();
22146
- return blockIsList(block, ordered);
22147
- }
22148
- });
22149
22331
  }
22332
+ const result = this.editor.getElementsByRange(true, false);
22333
+ return result.some((item) => {
22334
+ if (item.element.isBlock()) {
22335
+ return blockIsList(item.element, ordered);
22336
+ } else {
22337
+ const block = item.element.getBlock();
22338
+ return blockIsList(block, ordered);
22339
+ }
22340
+ });
22150
22341
  },
22151
22342
  //api:选区是否含有链接
22152
22343
  hasLink() {
22344
+ if (!this.editor.range) {
22345
+ return false;
22346
+ }
22153
22347
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22154
22348
  return !!this.getParsedomElementByElement(this.editor.range.anchor.element, "a");
22155
- } else {
22156
- const result = this.editor.getElementsByRange(true, true).filter((item) => {
22157
- return item.element.isText();
22158
- });
22159
- return result.some((item) => {
22160
- return !!this.getParsedomElementByElement(item.element, "a");
22161
- });
22162
22349
  }
22350
+ const result = this.editor.getElementsByRange(true, true).filter((item) => {
22351
+ return item.element.isText();
22352
+ });
22353
+ return result.some((item) => {
22354
+ return !!this.getParsedomElementByElement(item.element, "a");
22355
+ });
22163
22356
  },
22164
22357
  //api:选区是否含有表格
22165
22358
  hasTable() {
22359
+ if (!this.editor.range) {
22360
+ return false;
22361
+ }
22166
22362
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22167
22363
  const block = this.editor.range.anchor.element.getBlock();
22168
22364
  return block.parsedom == "table";
22169
- } else {
22170
- const result = this.editor.getElementsByRange(true, false);
22171
- return result.some((item) => {
22172
- if (item.element.isBlock()) {
22173
- return item.element.parsedom == "table";
22174
- } else {
22175
- const block = item.element.getBlock();
22176
- return block.parsedom == "table";
22177
- }
22178
- });
22179
22365
  }
22366
+ const result = this.editor.getElementsByRange(true, false);
22367
+ return result.some((item) => {
22368
+ if (item.element.isBlock()) {
22369
+ return item.element.parsedom == "table";
22370
+ } else {
22371
+ const block = item.element.getBlock();
22372
+ return block.parsedom == "table";
22373
+ }
22374
+ });
22180
22375
  },
22181
22376
  //api:选区是否含有任务列表
22182
22377
  hasTask() {
22378
+ if (!this.editor.range) {
22379
+ return false;
22380
+ }
22183
22381
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22184
22382
  const block = this.editor.range.anchor.element.getBlock();
22185
22383
  return blockIsTask(block);
22186
- } else {
22187
- const result = this.editor.getElementsByRange(true, false);
22188
- return result.some((item) => {
22189
- if (item.element.isBlock()) {
22190
- return blockIsTask(item.element);
22191
- } else {
22192
- const block = item.element.getBlock();
22193
- return blockIsTask(block);
22194
- }
22195
- });
22196
22384
  }
22385
+ const result = this.editor.getElementsByRange(true, false);
22386
+ return result.some((item) => {
22387
+ if (item.element.isBlock()) {
22388
+ return blockIsTask(item.element);
22389
+ } else {
22390
+ const block = item.element.getBlock();
22391
+ return blockIsTask(block);
22392
+ }
22393
+ });
22197
22394
  },
22198
22395
  //选区是否含有图片
22199
22396
  hasImage() {
22397
+ if (!this.editor.range) {
22398
+ return false;
22399
+ }
22200
22400
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22201
22401
  return this.editor.range.anchor.element.isClosed() && this.editor.range.anchor.element.parsedom == "img";
22202
- } else {
22203
- const result = this.editor.getElementsByRange(true, true);
22204
- return result.some((item) => {
22205
- return item.element.isClosed() && item.element.parsedom == "img";
22206
- });
22207
22402
  }
22403
+ const result = this.editor.getElementsByRange(true, true);
22404
+ return result.some((item) => {
22405
+ return item.element.isClosed() && item.element.parsedom == "img";
22406
+ });
22208
22407
  },
22209
22408
  //选区是否含有视频
22210
22409
  hasVideo() {
22410
+ if (!this.editor.range) {
22411
+ return false;
22412
+ }
22211
22413
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22212
22414
  return this.editor.range.anchor.element.isClosed() && this.editor.range.anchor.element.parsedom == "video";
22213
- } else {
22214
- const result = this.editor.getElementsByRange(true, true);
22215
- return result.some((item) => {
22216
- return item.element.isClosed() && item.element.parsedom == "video";
22217
- });
22218
22415
  }
22416
+ const result = this.editor.getElementsByRange(true, true);
22417
+ return result.some((item) => {
22418
+ return item.element.isClosed() && item.element.parsedom == "video";
22419
+ });
22219
22420
  },
22220
22421
  //api:选区是否全部在引用内
22221
22422
  inQuote() {
22423
+ if (!this.editor.range) {
22424
+ return false;
22425
+ }
22222
22426
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22223
22427
  const block = this.editor.range.anchor.element.getBlock();
22224
22428
  return block.parsedom == "blockquote";
22225
- } else {
22226
- const result = this.editor.getElementsByRange(true, false);
22227
- return result.every((item) => {
22228
- if (item.element.isBlock()) {
22229
- return item.element.parsedom == "blockquote";
22230
- } else {
22231
- const block = item.element.getBlock();
22232
- return block.parsedom == "blockquote";
22233
- }
22234
- });
22235
22429
  }
22430
+ const result = this.editor.getElementsByRange(true, false);
22431
+ return result.every((item) => {
22432
+ if (item.element.isBlock()) {
22433
+ return item.element.parsedom == "blockquote";
22434
+ } else {
22435
+ const block = item.element.getBlock();
22436
+ return block.parsedom == "blockquote";
22437
+ }
22438
+ });
22236
22439
  },
22237
22440
  //api:选区是否全部在列表内
22238
22441
  inList(ordered = false) {
22442
+ if (!this.editor.range) {
22443
+ return false;
22444
+ }
22239
22445
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22240
22446
  const block = this.editor.range.anchor.element.getBlock();
22241
22447
  return blockIsList(block, ordered);
22242
- } else {
22243
- const result = this.editor.getElementsByRange(true, false);
22244
- return result.every((item) => {
22245
- if (item.element.isBlock()) {
22246
- return blockIsList(item.element, ordered);
22247
- } else {
22248
- const block = item.element.getBlock();
22249
- return blockIsList(block, ordered);
22250
- }
22251
- });
22252
22448
  }
22449
+ const result = this.editor.getElementsByRange(true, false);
22450
+ return result.every((item) => {
22451
+ if (item.element.isBlock()) {
22452
+ return blockIsList(item.element, ordered);
22453
+ } else {
22454
+ const block = item.element.getBlock();
22455
+ return blockIsList(block, ordered);
22456
+ }
22457
+ });
22253
22458
  },
22254
22459
  //api:选区是否全部在任务列表里
22255
22460
  inTask() {
22461
+ if (!this.editor.range) {
22462
+ return false;
22463
+ }
22256
22464
  if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
22257
22465
  const block = this.editor.range.anchor.element.getBlock();
22258
22466
  return blockIsTask(block);
22259
- } else {
22260
- const result = this.editor.getElementsByRange(true, false);
22261
- return result.every((item) => {
22262
- if (item.element.isBlock()) {
22263
- return blockIsTask(item.element);
22264
- } else {
22265
- const block = item.element.getBlock();
22266
- return blockIsTask(block);
22267
- }
22268
- });
22269
22467
  }
22468
+ const result = this.editor.getElementsByRange(true, false);
22469
+ return result.every((item) => {
22470
+ if (item.element.isBlock()) {
22471
+ return blockIsTask(item.element);
22472
+ } else {
22473
+ const block = item.element.getBlock();
22474
+ return blockIsTask(block);
22475
+ }
22476
+ });
22270
22477
  },
22271
22478
  //api:创建一个空的表格
22272
22479
  insertTable(rowLength, colLength) {
22480
+ if (this.disabled) {
22481
+ return;
22482
+ }
22483
+ if (!this.editor.range) {
22484
+ return;
22485
+ }
22273
22486
  const table = new AlexElement("block", "table", null, null, null);
22274
22487
  const tbody = new AlexElement("inblock", "tbody", null, null, null);
22275
22488
  this.editor.addElementTo(tbody, table);
@@ -22299,6 +22512,9 @@ const _sfc_main = {
22299
22512
  if (this.disabled) {
22300
22513
  return;
22301
22514
  }
22515
+ if (!this.editor.range) {
22516
+ return;
22517
+ }
22302
22518
  const pre = this.getCurrentParsedomElement("pre");
22303
22519
  if (pre) {
22304
22520
  let content = "";
@@ -22372,6 +22588,9 @@ const _sfc_main = {
22372
22588
  if (this.disabled) {
22373
22589
  return;
22374
22590
  }
22591
+ if (!this.editor.range) {
22592
+ return;
22593
+ }
22375
22594
  this.editor.insertText(text2);
22376
22595
  this.editor.formatElementStack();
22377
22596
  this.editor.domRender();
@@ -22382,6 +22601,9 @@ const _sfc_main = {
22382
22601
  if (this.disabled) {
22383
22602
  return;
22384
22603
  }
22604
+ if (!this.editor.range) {
22605
+ return;
22606
+ }
22385
22607
  const elements = this.editor.parseHtml(html);
22386
22608
  for (let i = 0; i < elements.length; i++) {
22387
22609
  this.editor.insertElement(elements[i], false);
@@ -22453,7 +22675,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
22453
22675
  ])) : createCommentVNode("", true)
22454
22676
  ]);
22455
22677
  }
22456
- const Editify = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-ee4c1326"]]);
22678
+ const Editify = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-bcab43d0"]]);
22457
22679
  const iconfont = "";
22458
22680
  const en_US = {
22459
22681
  textWrapUp: "Up feed",
@@ -22632,7 +22854,7 @@ const i18n = (locale) => {
22632
22854
  return translations[locale][key];
22633
22855
  };
22634
22856
  };
22635
- const version = "0.0.16";
22857
+ const version = "0.0.18";
22636
22858
  const install = (app, props) => {
22637
22859
  const locale = (props ? props.locale : "zh_CN") || "zh_CN";
22638
22860
  app.provide("$editTrans", i18n(locale));