@wangeditor-next/editor 5.3.12-alpha.2 → 5.3.12-experimental.9

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/dist/index.esm.js CHANGED
@@ -860,7 +860,7 @@ var endsWithOddNumberOfRIs = str => {
860
860
  * Shared the function with isElementType utility
861
861
  */
862
862
 
863
- var isElement$1 = value => {
863
+ var isElement$2 = value => {
864
864
  return isPlainObject$1(value) && Node$1.isNodeList(value.children) && !Editor.isEditor(value);
865
865
  };
866
866
 
@@ -875,7 +875,7 @@ var Element$1 = {
875
875
  /**
876
876
  * Check if a value implements the `Element` interface.
877
877
  */
878
- isElement: isElement$1,
878
+ isElement: isElement$2,
879
879
 
880
880
  /**
881
881
  * Check if a value is an array of `Element` objects.
@@ -897,7 +897,7 @@ var Element$1 = {
897
897
  */
898
898
  isElementType: function isElementType(value, elementVal) {
899
899
  var elementKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'type';
900
- return isElement$1(value) && value[elementKey] === elementVal;
900
+ return isElement$2(value) && value[elementKey] === elementVal;
901
901
  },
902
902
 
903
903
  /**
@@ -1197,7 +1197,7 @@ var Editor = {
1197
1197
  */
1198
1198
  isEnd(editor, point, at) {
1199
1199
  var end = Editor.end(editor, at);
1200
- return Point.equals(point, end);
1200
+ return Point$1.equals(point, end);
1201
1201
  },
1202
1202
 
1203
1203
  /**
@@ -1243,7 +1243,7 @@ var Editor = {
1243
1243
  }
1244
1244
 
1245
1245
  var start = Editor.start(editor, at);
1246
- return Point.equals(point, start);
1246
+ return Point$1.equals(point, start);
1247
1247
  },
1248
1248
 
1249
1249
  /**
@@ -1663,7 +1663,7 @@ var Editor = {
1663
1663
  }
1664
1664
  }
1665
1665
 
1666
- if (Point.isPoint(at)) {
1666
+ if (Point$1.isPoint(at)) {
1667
1667
  at = at.path;
1668
1668
  }
1669
1669
 
@@ -2255,7 +2255,7 @@ var Location = {
2255
2255
  * Check if a value implements the `Location` interface.
2256
2256
  */
2257
2257
  isLocation(value) {
2258
- return Path.isPath(value) || Point.isPoint(value) || Range.isRange(value);
2258
+ return Path.isPath(value) || Point$1.isPoint(value) || Range.isRange(value);
2259
2259
  }
2260
2260
 
2261
2261
  };
@@ -3329,7 +3329,7 @@ var PathRef = {
3329
3329
  function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3330
3330
 
3331
3331
  function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
3332
- var Point = {
3332
+ var Point$1 = {
3333
3333
  /**
3334
3334
  * Compare a point to another, returning an integer indicating whether the
3335
3335
  * point was before, at, or after the other.
@@ -3350,14 +3350,14 @@ var Point = {
3350
3350
  * Check if a point is after another.
3351
3351
  */
3352
3352
  isAfter(point, another) {
3353
- return Point.compare(point, another) === 1;
3353
+ return Point$1.compare(point, another) === 1;
3354
3354
  },
3355
3355
 
3356
3356
  /**
3357
3357
  * Check if a point is before another.
3358
3358
  */
3359
3359
  isBefore(point, another) {
3360
- return Point.compare(point, another) === -1;
3360
+ return Point$1.compare(point, another) === -1;
3361
3361
  },
3362
3362
 
3363
3363
  /**
@@ -3476,7 +3476,7 @@ var PointRef = {
3476
3476
  return;
3477
3477
  }
3478
3478
 
3479
- var point = Point.transform(current, op, {
3479
+ var point = Point$1.transform(current, op, {
3480
3480
  affinity
3481
3481
  });
3482
3482
  ref.current = point;
@@ -3522,7 +3522,7 @@ var Range = {
3522
3522
  * Check if a range is exactly equal to another.
3523
3523
  */
3524
3524
  equals(range, another) {
3525
- return Point.equals(range.anchor, another.anchor) && Point.equals(range.focus, another.focus);
3525
+ return Point$1.equals(range.anchor, another.anchor) && Point$1.equals(range.focus, another.focus);
3526
3526
  },
3527
3527
 
3528
3528
  /**
@@ -3536,16 +3536,16 @@ var Range = {
3536
3536
 
3537
3537
  var [rs, re] = Range.edges(range);
3538
3538
  var [ts, te] = Range.edges(target);
3539
- return Point.isBefore(rs, ts) && Point.isAfter(re, te);
3539
+ return Point$1.isBefore(rs, ts) && Point$1.isAfter(re, te);
3540
3540
  }
3541
3541
 
3542
3542
  var [start, end] = Range.edges(range);
3543
3543
  var isAfterStart = false;
3544
3544
  var isBeforeEnd = false;
3545
3545
 
3546
- if (Point.isPoint(target)) {
3547
- isAfterStart = Point.compare(target, start) >= 0;
3548
- isBeforeEnd = Point.compare(target, end) <= 0;
3546
+ if (Point$1.isPoint(target)) {
3547
+ isAfterStart = Point$1.compare(target, start) >= 0;
3548
+ isBeforeEnd = Point$1.compare(target, end) <= 0;
3549
3549
  } else {
3550
3550
  isAfterStart = Path.compare(target, start.path) >= 0;
3551
3551
  isBeforeEnd = Path.compare(target, end.path) <= 0;
@@ -3562,10 +3562,10 @@ var Range = {
3562
3562
 
3563
3563
  var [s1, e1] = Range.edges(range);
3564
3564
  var [s2, e2] = Range.edges(another);
3565
- var start = Point.isBefore(s1, s2) ? s2 : s1;
3566
- var end = Point.isBefore(e1, e2) ? e1 : e2;
3565
+ var start = Point$1.isBefore(s1, s2) ? s2 : s1;
3566
+ var end = Point$1.isBefore(e1, e2) ? e1 : e2;
3567
3567
 
3568
- if (Point.isBefore(end, start)) {
3568
+ if (Point$1.isBefore(end, start)) {
3569
3569
  return null;
3570
3570
  } else {
3571
3571
  return _objectSpread$5({
@@ -3584,7 +3584,7 @@ var Range = {
3584
3584
  anchor,
3585
3585
  focus
3586
3586
  } = range;
3587
- return Point.isAfter(anchor, focus);
3587
+ return Point$1.isAfter(anchor, focus);
3588
3588
  },
3589
3589
 
3590
3590
  /**
@@ -3596,7 +3596,7 @@ var Range = {
3596
3596
  anchor,
3597
3597
  focus
3598
3598
  } = range;
3599
- return Point.equals(anchor, focus);
3599
+ return Point$1.equals(anchor, focus);
3600
3600
  },
3601
3601
 
3602
3602
  /**
@@ -3621,7 +3621,7 @@ var Range = {
3621
3621
  * Check if a value implements the [[Range]] interface.
3622
3622
  */
3623
3623
  isRange(value) {
3624
- return isPlainObject$1(value) && Point.isPoint(value.anchor) && Point.isPoint(value.focus);
3624
+ return isPlainObject$1(value) && Point$1.isPoint(value.anchor) && Point$1.isPoint(value.focus);
3625
3625
  },
3626
3626
 
3627
3627
  /**
@@ -3682,10 +3682,10 @@ var Range = {
3682
3682
  affinityFocus = affinity;
3683
3683
  }
3684
3684
 
3685
- var anchor = Point.transform(r.anchor, op, {
3685
+ var anchor = Point$1.transform(r.anchor, op, {
3686
3686
  affinity: affinityAnchor
3687
3687
  });
3688
- var focus = Point.transform(r.focus, op, {
3688
+ var focus = Point$1.transform(r.focus, op, {
3689
3689
  affinity: affinityFocus
3690
3690
  });
3691
3691
 
@@ -3943,7 +3943,7 @@ var applyToDraft = (editor, selection, op) => {
3943
3943
 
3944
3944
  if (selection) {
3945
3945
  for (var [point, key] of Range.points(selection)) {
3946
- selection[key] = Point.transform(point, op);
3946
+ selection[key] = Point$1.transform(point, op);
3947
3947
  }
3948
3948
  }
3949
3949
 
@@ -3969,7 +3969,7 @@ var applyToDraft = (editor, selection, op) => {
3969
3969
 
3970
3970
  if (selection) {
3971
3971
  for (var [_point, _key] of Range.points(selection)) {
3972
- selection[_key] = Point.transform(_point, op);
3972
+ selection[_key] = Point$1.transform(_point, op);
3973
3973
  }
3974
3974
  }
3975
3975
 
@@ -4003,7 +4003,7 @@ var applyToDraft = (editor, selection, op) => {
4003
4003
 
4004
4004
  if (selection) {
4005
4005
  for (var [_point2, _key2] of Range.points(selection)) {
4006
- selection[_key2] = Point.transform(_point2, op);
4006
+ selection[_key2] = Point$1.transform(_point2, op);
4007
4007
  }
4008
4008
  }
4009
4009
 
@@ -4041,7 +4041,7 @@ var applyToDraft = (editor, selection, op) => {
4041
4041
 
4042
4042
  if (selection) {
4043
4043
  for (var [_point3, _key3] of Range.points(selection)) {
4044
- selection[_key3] = Point.transform(_point3, op);
4044
+ selection[_key3] = Point$1.transform(_point3, op);
4045
4045
  }
4046
4046
  }
4047
4047
 
@@ -4063,7 +4063,7 @@ var applyToDraft = (editor, selection, op) => {
4063
4063
 
4064
4064
  if (selection) {
4065
4065
  for (var [_point4, _key4] of Range.points(selection)) {
4066
- var result = Point.transform(_point4, op);
4066
+ var result = Point$1.transform(_point4, op);
4067
4067
 
4068
4068
  if (selection != null && result != null) {
4069
4069
  selection[_key4] = result;
@@ -4126,7 +4126,7 @@ var applyToDraft = (editor, selection, op) => {
4126
4126
 
4127
4127
  if (selection) {
4128
4128
  for (var [_point5, _key5] of Range.points(selection)) {
4129
- selection[_key5] = Point.transform(_point5, op);
4129
+ selection[_key5] = Point$1.transform(_point5, op);
4130
4130
  }
4131
4131
  }
4132
4132
 
@@ -4249,7 +4249,7 @@ var applyToDraft = (editor, selection, op) => {
4249
4249
 
4250
4250
  if (selection) {
4251
4251
  for (var [_point6, _key9] of Range.points(selection)) {
4252
- selection[_key9] = Point.transform(_point6, op);
4252
+ selection[_key9] = Point$1.transform(_point6, op);
4253
4253
  }
4254
4254
  }
4255
4255
 
@@ -4352,7 +4352,7 @@ var NodeTransforms = {
4352
4352
  }
4353
4353
  }
4354
4354
 
4355
- if (Point.isPoint(at)) {
4355
+ if (Point$1.isPoint(at)) {
4356
4356
  if (match == null) {
4357
4357
  if (Text.isText(node)) {
4358
4358
  match = n => Text.isText(n);
@@ -5447,7 +5447,7 @@ var SelectionTransforms = {
5447
5447
  }
5448
5448
 
5449
5449
  for (var k in props) {
5450
- if (k === 'anchor' && props.anchor != null && !Point.equals(props.anchor, selection.anchor) || k === 'focus' && props.focus != null && !Point.equals(props.focus, selection.focus) || k !== 'anchor' && k !== 'focus' && props[k] !== selection[k]) {
5450
+ if (k === 'anchor' && props.anchor != null && !Point$1.equals(props.anchor, selection.anchor) || k === 'focus' && props.focus != null && !Point$1.equals(props.focus, selection.focus) || k !== 'anchor' && k !== 'focus' && props[k] !== selection[k]) {
5451
5451
  oldProps[k] = selection[k];
5452
5452
  newProps[k] = props[k];
5453
5453
  }
@@ -5490,7 +5490,7 @@ var TextTransforms = {
5490
5490
  at = at.anchor;
5491
5491
  }
5492
5492
 
5493
- if (Point.isPoint(at)) {
5493
+ if (Point$1.isPoint(at)) {
5494
5494
  var furthestVoid = Editor.void(editor, {
5495
5495
  at,
5496
5496
  mode: 'highest'
@@ -5529,7 +5529,7 @@ var TextTransforms = {
5529
5529
  var [, _end] = Range.edges(at);
5530
5530
  var endOfDoc = Editor.end(editor, []);
5531
5531
 
5532
- if (!Point.equals(_end, endOfDoc)) {
5532
+ if (!Point$1.equals(_end, endOfDoc)) {
5533
5533
  at = Editor.unhangRange(editor, at, {
5534
5534
  voids
5535
5535
  });
@@ -8930,7 +8930,7 @@ function setTextContent(node, text) {
8930
8930
  function getTextContent(node) {
8931
8931
  return node.textContent;
8932
8932
  }
8933
- function isElement(node) {
8933
+ function isElement$1(node) {
8934
8934
  return node.nodeType === 1;
8935
8935
  }
8936
8936
  function isText(node) {
@@ -8952,7 +8952,7 @@ const htmlDomApi = {
8952
8952
  tagName,
8953
8953
  setTextContent,
8954
8954
  getTextContent,
8955
- isElement,
8955
+ isElement: isElement$1,
8956
8956
  isText,
8957
8957
  isComment,
8958
8958
  };
@@ -17782,15 +17782,15 @@ function __extends$2(d, b) {
17782
17782
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17783
17783
  }
17784
17784
 
17785
- var __assign$4 = function() {
17786
- __assign$4 = Object.assign || function __assign(t) {
17785
+ var __assign$5 = function() {
17786
+ __assign$5 = Object.assign || function __assign(t) {
17787
17787
  for (var s, i = 1, n = arguments.length; i < n; i++) {
17788
17788
  s = arguments[i];
17789
17789
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
17790
17790
  }
17791
17791
  return t;
17792
17792
  };
17793
- return __assign$4.apply(this, arguments);
17793
+ return __assign$5.apply(this, arguments);
17794
17794
  };
17795
17795
 
17796
17796
  function __values$6(o) {
@@ -17822,7 +17822,7 @@ function __read$6(o, n) {
17822
17822
  return ar;
17823
17823
  }
17824
17824
 
17825
- function __spreadArray(to, from, pack) {
17825
+ function __spreadArray$1(to, from, pack) {
17826
17826
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
17827
17827
  if (ar || !(i in from)) {
17828
17828
  if (!ar) ar = Array.prototype.slice.call(from, 0, i);
@@ -17894,7 +17894,7 @@ var EDITOR_TO_WINDOW = new WeakMap();
17894
17894
  */
17895
17895
  var IS_FOCUSED = new WeakMap();
17896
17896
  // 保存 editor -> selection ,用于还原 editor 选区
17897
- var EDITOR_TO_SELECTION = new WeakMap();
17897
+ var EDITOR_TO_SELECTION$1 = new WeakMap();
17898
17898
  // editor -> eventEmitter 自定义事件
17899
17899
  var EDITOR_TO_EMITTER = new WeakMap();
17900
17900
  // editor 是否可执行粘贴
@@ -18515,9 +18515,14 @@ var DomEditor = {
18515
18515
  }
18516
18516
  return (
18517
18517
  // 祖先节点中包括 data-slate-editor 属性,即 textarea
18518
- targetEl.closest("[data-slate-editor]") === editorEl &&
18518
+ (targetEl.closest("[data-slate-editor]") === editorEl &&
18519
18519
  // 通过参数 editable 控制开启是否验证是可编辑元素或零宽字符
18520
- (!editable || targetEl.isContentEditable || !!targetEl.getAttribute('data-slate-zero-width')));
18520
+ // 补全 data-slate-string 可参考本文代码
18521
+ //(data-slate-zero-width、data-slate-string)判断一起出现,唯独此处欠缺,补全
18522
+ (!editable ||
18523
+ targetEl.isContentEditable ||
18524
+ !!targetEl.getAttribute('data-slate-zero-width'))) ||
18525
+ !!targetEl.getAttribute('data-slate-string'));
18521
18526
  },
18522
18527
  /**
18523
18528
  * Find a native DOM range from a Slate `range`.
@@ -18759,7 +18764,7 @@ var DomEditor = {
18759
18764
  range.setStart(textNode, 0);
18760
18765
  range.setEnd(nearestNode, nearestOffset);
18761
18766
  var contents = range.cloneContents();
18762
- var removals = __spreadArray(__spreadArray([], __read$6(lodash_toarray(contents.querySelectorAll('[data-slate-zero-width]')))), __read$6(lodash_toarray(contents.querySelectorAll('[contenteditable=false]'))));
18767
+ var removals = __spreadArray$1(__spreadArray$1([], __read$6(lodash_toarray(contents.querySelectorAll('[data-slate-zero-width]')))), __read$6(lodash_toarray(contents.querySelectorAll('[contenteditable=false]'))));
18763
18768
  removals.forEach(function (el) {
18764
18769
  el.parentNode.removeChild(el);
18765
18770
  });
@@ -19107,7 +19112,7 @@ var withDOM = function (editor) {
19107
19112
  Transforms.select(e, end);
19108
19113
  }
19109
19114
  else {
19110
- var selection = EDITOR_TO_SELECTION.get(e);
19115
+ var selection = EDITOR_TO_SELECTION$1.get(e);
19111
19116
  if (selection) {
19112
19117
  Transforms.select(e, selection); // 选区定位到之前的位置
19113
19118
  }
@@ -19311,7 +19316,7 @@ var MENU_ITEM_FACTORIES = {};
19311
19316
  function registerMenu(registerMenuConf, customConfig) {
19312
19317
  var key = registerMenuConf.key, factory = registerMenuConf.factory, config = registerMenuConf.config;
19313
19318
  // 合并 config
19314
- var newConfig = __assign$4(__assign$4({}, config), (customConfig || {}));
19319
+ var newConfig = __assign$5(__assign$5({}, config), (customConfig || {}));
19315
19320
  // 注册 menu
19316
19321
  if (MENU_ITEM_FACTORIES[key] != null) {
19317
19322
  throw new Error("Duplicated key '" + key + "' in menu items");
@@ -20062,7 +20067,7 @@ var withContent = function (editor) {
20062
20067
  // 记录当前选区
20063
20068
  var selection = e.selection;
20064
20069
  if (selection != null) {
20065
- EDITOR_TO_SELECTION.set(e, selection);
20070
+ EDITOR_TO_SELECTION$1.set(e, selection);
20066
20071
  }
20067
20072
  // 触发配置的 change 事件
20068
20073
  e.emit('change');
@@ -20111,7 +20116,7 @@ var withContent = function (editor) {
20111
20116
  var key = DomEditor.findKey(e, node);
20112
20117
  var id = genElemId$1(key.id);
20113
20118
  // node + id
20114
- elems.push(__assign$4(__assign$4({}, node), { id: id }));
20119
+ elems.push(__assign$5(__assign$5({}, node), { id: id }));
20115
20120
  }
20116
20121
  }
20117
20122
  }
@@ -20862,7 +20867,7 @@ var withEmitter = function (editor) {
20862
20867
  args[_i - 1] = arguments[_i];
20863
20868
  }
20864
20869
  var emitter = getEmitter(e);
20865
- emitter.emit.apply(emitter, __spreadArray([type], __read$6(args)));
20870
+ emitter.emit.apply(emitter, __spreadArray$1([type], __read$6(args)));
20866
20871
  // editor 销毁时,off 掉 destroyed listeners
20867
20872
  if (type === 'destroyed') {
20868
20873
  var listeners = getDestroyListeners(e);
@@ -21117,7 +21122,7 @@ function correctPosition(editor, $positionElem) {
21117
21122
  * @description slate 插件 - selection 相关
21118
21123
  * @author wangfupeng
21119
21124
  */
21120
- var withSelection = function (editor) {
21125
+ var withSelection$1 = function (editor) {
21121
21126
  var e = editor;
21122
21127
  // 选中
21123
21128
  e.select = function (at) {
@@ -21156,7 +21161,7 @@ var withSelection = function (editor) {
21156
21161
  * 还原选区
21157
21162
  */
21158
21163
  e.restoreSelection = function () {
21159
- var selection = EDITOR_TO_SELECTION.get(e);
21164
+ var selection = EDITOR_TO_SELECTION$1.get(e);
21160
21165
  if (selection == null)
21161
21166
  return;
21162
21167
  e.focus();
@@ -21183,7 +21188,7 @@ var withSelection = function (editor) {
21183
21188
  return false;
21184
21189
  var _a = __read$6(Range.edges(selection), 2), start1 = _a[0], end1 = _a[1]; // 获取当前选取的开始、结束 point
21185
21190
  var _b = __read$6(Editor.edges(e, []), 2), start2 = _b[0], end2 = _b[1]; // 获取编辑器全部的开始、结束 point
21186
- if (Point.equals(start1, start2) && Point.equals(end1, end2)) {
21191
+ if (Point$1.equals(start1, start2) && Point$1.equals(end1, end2)) {
21187
21192
  return true;
21188
21193
  }
21189
21194
  return false;
@@ -22093,9 +22098,6 @@ function DOMSelectionToEditor(textarea, editor) {
22093
22098
  });
22094
22099
  Transforms.select(editor, range);
22095
22100
  }
22096
- else {
22097
- Transforms.deselect(editor);
22098
- }
22099
22101
  }
22100
22102
 
22101
22103
  /**
@@ -22590,7 +22592,7 @@ function triggerMenuHotKey(editor, event) {
22590
22592
  var hoverbar = EDITOR_TO_HOVER_BAR.get(editor);
22591
22593
  var hoverbarMenus = hoverbar && hoverbar.getMenus();
22592
22594
  // 合并所有 menus
22593
- var allMenus = __assign$4(__assign$4({}, toolbarMenus), hoverbarMenus);
22595
+ var allMenus = __assign$5(__assign$5({}, toolbarMenus), hoverbarMenus);
22594
22596
  for (var key in allMenus) {
22595
22597
  var menu = allMenus[key];
22596
22598
  var hotkey = menu.hotkey;
@@ -24391,10 +24393,10 @@ function genEditorConfig(userConfig) {
24391
24393
  var _a = userConfig.MENU_CONF, userMenuConf = _a === void 0 ? {} : _a;
24392
24394
  lodash_foreach(defaultMenuConf, function (menuConf, menuKey) {
24393
24395
  // 生成新的 menu config
24394
- newMenuConf[menuKey] = __assign$4(__assign$4({}, menuConf), (userMenuConf[menuKey] || {}));
24396
+ newMenuConf[menuKey] = __assign$5(__assign$5({}, menuConf), (userMenuConf[menuKey] || {}));
24395
24397
  });
24396
24398
  delete userConfig.MENU_CONF; // 处理完,则删掉 menuConf ,以防下面 merge 时造成干扰
24397
- return __assign$4({
24399
+ return __assign$5({
24398
24400
  // 默认配置
24399
24401
  scroll: true, readOnly: false, autoFocus: true, decorate: function () { return []; }, maxLength: 0, MENU_CONF: newMenuConf, hoverbarKeys: {
24400
24402
  // 'link': { menuKeys: ['editLink', 'unLink', 'viewLink'] },
@@ -24406,7 +24408,7 @@ function genEditorConfig(userConfig) {
24406
24408
  * 生成 toolbar 默认配置
24407
24409
  */
24408
24410
  function genToolbarConfig(userConfig) {
24409
- return __assign$4({
24411
+ return __assign$5({
24410
24412
  // 默认配置
24411
24413
  toolbarKeys: [], excludeKeys: [], insertKeys: { index: 0, keys: [] }, modalAppendToBody: false }, (userConfig || {}));
24412
24414
  }
@@ -24449,7 +24451,7 @@ function bindNodeRelation(node, index, parent, editor) {
24449
24451
  function createEditor$1 (option) {
24450
24452
  var _a = option.selector, selector = _a === void 0 ? '' : _a, _b = option.config, config = _b === void 0 ? {} : _b, content = option.content, html = option.html, _c = option.plugins, plugins = _c === void 0 ? [] : _c;
24451
24453
  // 创建实例 - 使用插件
24452
- var editor = withHistory(withMaxLength(withEmitter(withSelection(withContent(withConfig(withDOM(withEventData(createEditor$2()))))))));
24454
+ var editor = withHistory(withMaxLength(withEmitter(withSelection$1(withContent(withConfig(withDOM(withEventData(createEditor$2()))))))));
24453
24455
  if (selector) {
24454
24456
  // 检查是否对同一个 DOM 重复创建
24455
24457
  if (isRepeatedCreateTextarea(editor, selector)) {
@@ -27806,15 +27808,15 @@ function __extends$1(d, b) {
27806
27808
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27807
27809
  }
27808
27810
 
27809
- var __assign$3 = function() {
27810
- __assign$3 = Object.assign || function __assign(t) {
27811
+ var __assign$4 = function() {
27812
+ __assign$4 = Object.assign || function __assign(t) {
27811
27813
  for (var s, i = 1, n = arguments.length; i < n; i++) {
27812
27814
  s = arguments[i];
27813
27815
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
27814
27816
  }
27815
27817
  return t;
27816
27818
  };
27817
- return __assign$3.apply(this, arguments);
27819
+ return __assign$4.apply(this, arguments);
27818
27820
  };
27819
27821
 
27820
27822
  function __awaiter$2(thisArg, _arguments, P, generator) {
@@ -27827,7 +27829,7 @@ function __awaiter$2(thisArg, _arguments, P, generator) {
27827
27829
  });
27828
27830
  }
27829
27831
 
27830
- function __generator$2(thisArg, body) {
27832
+ function __generator$3(thisArg, body) {
27831
27833
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27832
27834
  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27833
27835
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -29468,7 +29470,7 @@ function replaceSymbols$1(str) {
29468
29470
  function check$1(menuKey, editor, text, url) {
29469
29471
  return __awaiter$2(this, void 0, void 0, function () {
29470
29472
  var checkLink, res;
29471
- return __generator$2(this, function (_a) {
29473
+ return __generator$3(this, function (_a) {
29472
29474
  switch (_a.label) {
29473
29475
  case 0:
29474
29476
  checkLink = editor.getMenuConfig(menuKey).checkLink;
@@ -29501,7 +29503,7 @@ function check$1(menuKey, editor, text, url) {
29501
29503
  function parse(menuKey, editor, url) {
29502
29504
  return __awaiter$2(this, void 0, void 0, function () {
29503
29505
  var parseLinkUrl, newUrl;
29504
- return __generator$2(this, function (_a) {
29506
+ return __generator$3(this, function (_a) {
29505
29507
  switch (_a.label) {
29506
29508
  case 0:
29507
29509
  parseLinkUrl = editor.getMenuConfig(menuKey).parseLinkUrl;
@@ -29552,7 +29554,7 @@ function genLinkNode(url, text) {
29552
29554
  function insertLink(editor, text, url) {
29553
29555
  return __awaiter$2(this, void 0, void 0, function () {
29554
29556
  var checkRes, parsedUrl, selection, isCollapsed, leftLength, linkNode, selectedText, leftLength, linkNode, linkNode;
29555
- return __generator$2(this, function (_a) {
29557
+ return __generator$3(this, function (_a) {
29556
29558
  switch (_a.label) {
29557
29559
  case 0:
29558
29560
  if (!url)
@@ -29633,7 +29635,7 @@ function insertLink(editor, text, url) {
29633
29635
  function updateLink(editor, text, url) {
29634
29636
  return __awaiter$2(this, void 0, void 0, function () {
29635
29637
  var checkRes, parsedUrl, props;
29636
- return __generator$2(this, function (_a) {
29638
+ return __generator$3(this, function (_a) {
29637
29639
  switch (_a.label) {
29638
29640
  case 0:
29639
29641
  if (!url)
@@ -30245,7 +30247,7 @@ function renderResizeContainer(editor, elemNode, imageVnode, imageInfo) {
30245
30247
  // const newHeight = $container.height().toFixed(2)
30246
30248
  // 修改 node
30247
30249
  var props = {
30248
- style: __assign$3(__assign$3({}, elemNode.style), { width: newWidth + "px" }),
30250
+ style: __assign$4(__assign$4({}, elemNode.style), { width: newWidth + "px" }),
30249
30251
  };
30250
30252
  Transforms.setNodes(editor, props, { at: DomEditor.findPath(editor, elemNode) });
30251
30253
  // 取消监听 mouseup
@@ -30369,7 +30371,7 @@ function check(menuKey, editor, src, alt, href) {
30369
30371
  if (href === void 0) { href = ''; }
30370
30372
  return __awaiter$2(this, void 0, void 0, function () {
30371
30373
  var checkImage, res;
30372
- return __generator$2(this, function (_a) {
30374
+ return __generator$3(this, function (_a) {
30373
30375
  switch (_a.label) {
30374
30376
  case 0:
30375
30377
  checkImage = editor.getMenuConfig(menuKey).checkImage;
@@ -30395,7 +30397,7 @@ function check(menuKey, editor, src, alt, href) {
30395
30397
  function parseSrc(menuKey, editor, src) {
30396
30398
  return __awaiter$2(this, void 0, void 0, function () {
30397
30399
  var parseImageSrc, newSrc;
30398
- return __generator$2(this, function (_a) {
30400
+ return __generator$3(this, function (_a) {
30399
30401
  switch (_a.label) {
30400
30402
  case 0:
30401
30403
  parseImageSrc = editor.getMenuConfig(menuKey).parseImageSrc;
@@ -30414,7 +30416,7 @@ function insertImageNode(editor, src, alt, href) {
30414
30416
  if (href === void 0) { href = ''; }
30415
30417
  return __awaiter$2(this, void 0, void 0, function () {
30416
30418
  var res, parsedSrc, image, onInsertedImage;
30417
- return __generator$2(this, function (_a) {
30419
+ return __generator$3(this, function (_a) {
30418
30420
  switch (_a.label) {
30419
30421
  case 0: return [4 /*yield*/, check('insertImage', editor, src, alt, href)];
30420
30422
  case 1:
@@ -30459,7 +30461,7 @@ function updateImageNode(editor, src, alt, href, style) {
30459
30461
  if (style === void 0) { style = {}; }
30460
30462
  return __awaiter$2(this, void 0, void 0, function () {
30461
30463
  var res, parsedSrc, selectedImageNode, _a, curStyle, nodeProps, imageNode, onUpdatedImage;
30462
- return __generator$2(this, function (_b) {
30464
+ return __generator$3(this, function (_b) {
30463
30465
  switch (_b.label) {
30464
30466
  case 0: return [4 /*yield*/, check('editImage', editor, src, alt, href)];
30465
30467
  case 1:
@@ -30477,7 +30479,7 @@ function updateImageNode(editor, src, alt, href, style) {
30477
30479
  src: parsedSrc,
30478
30480
  alt: alt,
30479
30481
  href: href,
30480
- style: __assign$3(__assign$3({}, curStyle), style),
30482
+ style: __assign$4(__assign$4({}, curStyle), style),
30481
30483
  };
30482
30484
  Transforms.setNodes(editor, nodeProps, {
30483
30485
  match: function (n) { return DomEditor.checkNodeType(n, 'image'); },
@@ -30867,7 +30869,7 @@ var ImageWidthBaseClass = /** @class */ (function () {
30867
30869
  hoverbar.hideAndClean();
30868
30870
  var _a = imageNode.style, style = _a === void 0 ? {} : _a;
30869
30871
  var props = {
30870
- style: __assign$3(__assign$3({}, style), { width: this.value, height: '' }),
30872
+ style: __assign$4(__assign$4({}, style), { width: this.value, height: '' }),
30871
30873
  };
30872
30874
  Transforms.setNodes(editor, props, {
30873
30875
  match: function (n) { return DomEditor.checkNodeType(n, 'image'); },
@@ -31004,7 +31006,7 @@ var EditorImageSizeMenu = /** @class */ (function () {
31004
31006
  }
31005
31007
  var _a = imageNode.style, style = _a === void 0 ? {} : _a;
31006
31008
  editor.restoreSelection();
31007
- var props = __assign$3(__assign$3({}, style), { style: {
31009
+ var props = __assign$4(__assign$4({}, style), { style: {
31008
31010
  width: width,
31009
31011
  height: height,
31010
31012
  } });
@@ -31521,7 +31523,7 @@ function withBlockquote(editor) {
31521
31523
  }
31522
31524
  var quotePath = DomEditor.findPath(editor, quoteElem);
31523
31525
  var quoteEndLocation = Editor.end(editor, quotePath);
31524
- if (Point.equals(quoteEndLocation, selection.focus)) {
31526
+ if (Point$1.equals(quoteEndLocation, selection.focus)) {
31525
31527
  // 光标位于 blockquote 最后
31526
31528
  var str = Node$1.string(quoteElem);
31527
31529
  if (str && str.slice(-1) === '\n') {
@@ -34204,1946 +34206,505 @@ var list = {
34204
34206
  parseElemsHtml: [parseListHtmlConf, parseItemHtmlConf],
34205
34207
  };
34206
34208
 
34207
- /**
34208
- * Lodash (Custom Build) <https://lodash.com/>
34209
- * Build: `lodash modularize exports="npm" -o ./`
34210
- * Copyright JS Foundation and other contributors <https://js.foundation/>
34211
- * Released under MIT license <https://lodash.com/license>
34212
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
34213
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
34214
- */
34215
-
34216
- var lodash_isequal = createCommonjsModule$2(function (module, exports) {
34217
- /** Used as the size to enable large array optimizations. */
34218
- var LARGE_ARRAY_SIZE = 200;
34219
-
34220
- /** Used to stand-in for `undefined` hash values. */
34221
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
34222
-
34223
- /** Used to compose bitmasks for value comparisons. */
34224
- var COMPARE_PARTIAL_FLAG = 1,
34225
- COMPARE_UNORDERED_FLAG = 2;
34226
-
34227
- /** Used as references for various `Number` constants. */
34228
- var MAX_SAFE_INTEGER = 9007199254740991;
34229
-
34230
- /** `Object#toString` result references. */
34231
- var argsTag = '[object Arguments]',
34232
- arrayTag = '[object Array]',
34233
- asyncTag = '[object AsyncFunction]',
34234
- boolTag = '[object Boolean]',
34235
- dateTag = '[object Date]',
34236
- errorTag = '[object Error]',
34237
- funcTag = '[object Function]',
34238
- genTag = '[object GeneratorFunction]',
34239
- mapTag = '[object Map]',
34240
- numberTag = '[object Number]',
34241
- nullTag = '[object Null]',
34242
- objectTag = '[object Object]',
34243
- promiseTag = '[object Promise]',
34244
- proxyTag = '[object Proxy]',
34245
- regexpTag = '[object RegExp]',
34246
- setTag = '[object Set]',
34247
- stringTag = '[object String]',
34248
- symbolTag = '[object Symbol]',
34249
- undefinedTag = '[object Undefined]',
34250
- weakMapTag = '[object WeakMap]';
34251
-
34252
- var arrayBufferTag = '[object ArrayBuffer]',
34253
- dataViewTag = '[object DataView]',
34254
- float32Tag = '[object Float32Array]',
34255
- float64Tag = '[object Float64Array]',
34256
- int8Tag = '[object Int8Array]',
34257
- int16Tag = '[object Int16Array]',
34258
- int32Tag = '[object Int32Array]',
34259
- uint8Tag = '[object Uint8Array]',
34260
- uint8ClampedTag = '[object Uint8ClampedArray]',
34261
- uint16Tag = '[object Uint16Array]',
34262
- uint32Tag = '[object Uint32Array]';
34263
-
34264
- /**
34265
- * Used to match `RegExp`
34266
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
34267
- */
34268
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
34269
-
34270
- /** Used to detect host constructors (Safari). */
34271
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
34272
-
34273
- /** Used to detect unsigned integer values. */
34274
- var reIsUint = /^(?:0|[1-9]\d*)$/;
34275
-
34276
- /** Used to identify `toStringTag` values of typed arrays. */
34277
- var typedArrayTags = {};
34278
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
34279
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
34280
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
34281
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
34282
- typedArrayTags[uint32Tag] = true;
34283
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
34284
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
34285
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
34286
- typedArrayTags[errorTag] = typedArrayTags[funcTag] =
34287
- typedArrayTags[mapTag] = typedArrayTags[numberTag] =
34288
- typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
34289
- typedArrayTags[setTag] = typedArrayTags[stringTag] =
34290
- typedArrayTags[weakMapTag] = false;
34291
-
34292
- /** Detect free variable `global` from Node.js. */
34293
- var freeGlobal = typeof commonjsGlobal$1 == 'object' && commonjsGlobal$1 && commonjsGlobal$1.Object === Object && commonjsGlobal$1;
34294
-
34295
- /** Detect free variable `self`. */
34296
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
34297
-
34298
- /** Used as a reference to the global object. */
34299
- var root = freeGlobal || freeSelf || Function('return this')();
34300
-
34301
- /** Detect free variable `exports`. */
34302
- var freeExports = exports && !exports.nodeType && exports;
34303
-
34304
- /** Detect free variable `module`. */
34305
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
34306
-
34307
- /** Detect the popular CommonJS extension `module.exports`. */
34308
- var moduleExports = freeModule && freeModule.exports === freeExports;
34309
-
34310
- /** Detect free variable `process` from Node.js. */
34311
- var freeProcess = moduleExports && freeGlobal.process;
34312
-
34313
- /** Used to access faster Node.js helpers. */
34314
- var nodeUtil = (function() {
34315
- try {
34316
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
34317
- } catch (e) {}
34318
- }());
34319
-
34320
- /* Node.js helper references. */
34321
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
34322
-
34323
- /**
34324
- * A specialized version of `_.filter` for arrays without support for
34325
- * iteratee shorthands.
34326
- *
34327
- * @private
34328
- * @param {Array} [array] The array to iterate over.
34329
- * @param {Function} predicate The function invoked per iteration.
34330
- * @returns {Array} Returns the new filtered array.
34331
- */
34332
- function arrayFilter(array, predicate) {
34333
- var index = -1,
34334
- length = array == null ? 0 : array.length,
34335
- resIndex = 0,
34336
- result = [];
34337
-
34338
- while (++index < length) {
34339
- var value = array[index];
34340
- if (predicate(value, index, array)) {
34341
- result[resIndex++] = value;
34342
- }
34343
- }
34344
- return result;
34345
- }
34346
-
34347
- /**
34348
- * Appends the elements of `values` to `array`.
34349
- *
34350
- * @private
34351
- * @param {Array} array The array to modify.
34352
- * @param {Array} values The values to append.
34353
- * @returns {Array} Returns `array`.
34354
- */
34355
- function arrayPush(array, values) {
34356
- var index = -1,
34357
- length = values.length,
34358
- offset = array.length;
34359
-
34360
- while (++index < length) {
34361
- array[offset + index] = values[index];
34362
- }
34363
- return array;
34364
- }
34365
-
34366
- /**
34367
- * A specialized version of `_.some` for arrays without support for iteratee
34368
- * shorthands.
34369
- *
34370
- * @private
34371
- * @param {Array} [array] The array to iterate over.
34372
- * @param {Function} predicate The function invoked per iteration.
34373
- * @returns {boolean} Returns `true` if any element passes the predicate check,
34374
- * else `false`.
34375
- */
34376
- function arraySome(array, predicate) {
34377
- var index = -1,
34378
- length = array == null ? 0 : array.length;
34379
-
34380
- while (++index < length) {
34381
- if (predicate(array[index], index, array)) {
34382
- return true;
34383
- }
34384
- }
34385
- return false;
34386
- }
34387
-
34388
- /**
34389
- * The base implementation of `_.times` without support for iteratee shorthands
34390
- * or max array length checks.
34391
- *
34392
- * @private
34393
- * @param {number} n The number of times to invoke `iteratee`.
34394
- * @param {Function} iteratee The function invoked per iteration.
34395
- * @returns {Array} Returns the array of results.
34396
- */
34397
- function baseTimes(n, iteratee) {
34398
- var index = -1,
34399
- result = Array(n);
34400
-
34401
- while (++index < n) {
34402
- result[index] = iteratee(index);
34403
- }
34404
- return result;
34405
- }
34209
+ /**
34210
+ * @description i18n en
34211
+ * @author wangfupeng
34212
+ */
34213
+ var enResources$3 = {
34214
+ tableModule: {
34215
+ deleteCol: 'Delete column',
34216
+ deleteRow: 'Delete row',
34217
+ deleteTable: 'Delete table',
34218
+ widthAuto: 'Width auto',
34219
+ insertCol: 'Insert column',
34220
+ insertRow: 'Insert row',
34221
+ insertTable: 'Insert table',
34222
+ header: 'Header',
34223
+ mergeCell: 'merge cell',
34224
+ splitCell: 'split cell',
34225
+ },
34226
+ };
34406
34227
 
34407
- /**
34408
- * The base implementation of `_.unary` without support for storing metadata.
34409
- *
34410
- * @private
34411
- * @param {Function} func The function to cap arguments for.
34412
- * @returns {Function} Returns the new capped function.
34413
- */
34414
- function baseUnary(func) {
34415
- return function(value) {
34416
- return func(value);
34417
- };
34418
- }
34228
+ /**
34229
+ * @description i18n zh-CN
34230
+ * @author wangfupeng
34231
+ */
34232
+ var zhResources$3 = {
34233
+ tableModule: {
34234
+ deleteCol: '删除列',
34235
+ deleteRow: '删除行',
34236
+ deleteTable: '删除表格',
34237
+ widthAuto: '宽度自适应',
34238
+ insertCol: '插入列',
34239
+ insertRow: '插入行',
34240
+ insertTable: '插入表格',
34241
+ header: '表头',
34242
+ mergeCell: '合并单元格',
34243
+ splitCell: '拆分单元格',
34244
+ },
34245
+ };
34419
34246
 
34420
- /**
34421
- * Checks if a `cache` value for `key` exists.
34422
- *
34423
- * @private
34424
- * @param {Object} cache The cache to query.
34425
- * @param {string} key The key of the entry to check.
34426
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
34427
- */
34428
- function cacheHas(cache, key) {
34429
- return cache.has(key);
34430
- }
34247
+ /**
34248
+ * @description i18n entry
34249
+ * @author wangfupeng
34250
+ */
34251
+ i18nAddResources('en', enResources$3);
34252
+ i18nAddResources('zh-CN', zhResources$3);
34431
34253
 
34432
- /**
34433
- * Gets the value at `key` of `object`.
34434
- *
34435
- * @private
34436
- * @param {Object} [object] The object to query.
34437
- * @param {string} key The key of the property to get.
34438
- * @returns {*} Returns the property value.
34439
- */
34440
- function getValue(object, key) {
34441
- return object == null ? undefined : object[key];
34442
- }
34254
+ /******************************************************************************
34255
+ Copyright (c) Microsoft Corporation.
34256
+
34257
+ Permission to use, copy, modify, and/or distribute this software for any
34258
+ purpose with or without fee is hereby granted.
34259
+
34260
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
34261
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
34262
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
34263
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
34264
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
34265
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
34266
+ PERFORMANCE OF THIS SOFTWARE.
34267
+ ***************************************************************************** */
34268
+
34269
+ var __assign$3 = function() {
34270
+ __assign$3 = Object.assign || function __assign(t) {
34271
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
34272
+ s = arguments[i];
34273
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
34274
+ }
34275
+ return t;
34276
+ };
34277
+ return __assign$3.apply(this, arguments);
34278
+ };
34279
+
34280
+ function __generator$2(thisArg, body) {
34281
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
34282
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
34283
+ function verb(n) { return function (v) { return step([n, v]); }; }
34284
+ function step(op) {
34285
+ if (f) throw new TypeError("Generator is already executing.");
34286
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
34287
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34288
+ if (y = 0, t) op = [op[0] & 2, t.value];
34289
+ switch (op[0]) {
34290
+ case 0: case 1: t = op; break;
34291
+ case 4: _.label++; return { value: op[1], done: false };
34292
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34293
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
34294
+ default:
34295
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
34296
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
34297
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
34298
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
34299
+ if (t[2]) _.ops.pop();
34300
+ _.trys.pop(); continue;
34301
+ }
34302
+ op = body.call(thisArg, _);
34303
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34304
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
34305
+ }
34306
+ }
34307
+
34308
+ function __values$3(o) {
34309
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
34310
+ if (m) return m.call(o);
34311
+ if (o && typeof o.length === "number") return {
34312
+ next: function () {
34313
+ if (o && i >= o.length) o = void 0;
34314
+ return { value: o && o[i++], done: !o };
34315
+ }
34316
+ };
34317
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
34318
+ }
34319
+
34320
+ function __read$3(o, n) {
34321
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
34322
+ if (!m) return o;
34323
+ var i = m.call(o), r, ar = [], e;
34324
+ try {
34325
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
34326
+ }
34327
+ catch (error) { e = { error: error }; }
34328
+ finally {
34329
+ try {
34330
+ if (r && !r.done && (m = i["return"])) m.call(i);
34331
+ }
34332
+ finally { if (e) throw e.error; }
34333
+ }
34334
+ return ar;
34335
+ }
34336
+
34337
+ function __spreadArray(to, from, pack) {
34338
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
34339
+ if (ar || !(i in from)) {
34340
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
34341
+ ar[i] = from[i];
34342
+ }
34343
+ }
34344
+ return to.concat(ar || Array.prototype.slice.call(from));
34345
+ }
34346
+
34347
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
34348
+ var e = new Error(message);
34349
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
34350
+ };
34443
34351
 
34444
- /**
34445
- * Converts `map` to its key-value pairs.
34446
- *
34447
- * @private
34448
- * @param {Object} map The map to convert.
34449
- * @returns {Array} Returns the key-value pairs.
34450
- */
34451
- function mapToArray(map) {
34452
- var index = -1,
34453
- result = Array(map.size);
34352
+ /** Weak reference between the `Editor` and the selected elements */
34353
+ var EDITOR_TO_SELECTION = new WeakMap();
34354
+ /** Weak reference between the `Editor` and a set of the selected elements */
34355
+ var EDITOR_TO_SELECTION_SET = new WeakMap();
34356
+
34357
+ var DEFAULT_WITH_TABLE_OPTIONS = {
34358
+ blocks: {
34359
+ td: 'table-cell',
34360
+ th: 'table-cell',
34361
+ content: 'paragraph',
34362
+ tr: 'table-row',
34363
+ table: 'table',
34364
+ tbody: 'table-body',
34365
+ // tfoot: "table-footer",
34366
+ // thead: "table-head",
34367
+ },
34368
+ };
34454
34369
 
34455
- map.forEach(function(value, key) {
34456
- result[++index] = [key, value];
34457
- });
34458
- return result;
34370
+ function isElement(node) {
34371
+ return !Editor.isEditor(node) && Element$1.isElement(node) && 'type' in node;
34372
+ }
34373
+ /** @returns a `NodeMatch` function which is used to match the elements of a specific `type`. */
34374
+ function isOfType(editor) {
34375
+ var types = [];
34376
+ for (var _i = 1; _i < arguments.length; _i++) {
34377
+ types[_i - 1] = arguments[_i];
34378
+ }
34379
+ var options = DEFAULT_WITH_TABLE_OPTIONS, elementTypes = types.map(function (type) { var _a; return (_a = options === null || options === void 0 ? void 0 : options.blocks) === null || _a === void 0 ? void 0 : _a[type]; });
34380
+ return function (node) { return isElement(node) && elementTypes.includes(node.type); };
34459
34381
  }
34460
34382
 
34461
- /**
34462
- * Creates a unary function that invokes `func` with its argument transformed.
34463
- *
34464
- * @private
34465
- * @param {Function} func The function to wrap.
34466
- * @param {Function} transform The argument transform.
34467
- * @returns {Function} Returns the new function.
34468
- */
34469
- function overArg(func, transform) {
34470
- return function(arg) {
34471
- return func(transform(arg));
34472
- };
34383
+ /**
34384
+ * Determines whether two paths belong to the same types by checking
34385
+ * if they share a common ancestor node of type table
34386
+ */
34387
+ function hasCommon(editor, _a) {
34388
+ var _b = __read$3(_a, 2), path = _b[0], another = _b[1];
34389
+ var types = [];
34390
+ for (var _i = 2; _i < arguments.length; _i++) {
34391
+ types[_i - 2] = arguments[_i];
34392
+ }
34393
+ var _c = __read$3(Node$1.common(editor, path, another), 2), node = _c[0], commonPath = _c[1];
34394
+ if (isOfType.apply(void 0, __spreadArray([editor], __read$3(types)))(node, commonPath)) {
34395
+ return true;
34396
+ }
34397
+ // Warning: returns the common ancestor but will return `undefined` if the
34398
+ // `commonPath` is equal to the specified types path
34399
+ return !!Editor.above(editor, {
34400
+ match: isOfType.apply(void 0, __spreadArray([editor], __read$3(types))),
34401
+ at: commonPath,
34402
+ });
34473
34403
  }
34474
34404
 
34475
- /**
34476
- * Converts `set` to an array of its values.
34477
- *
34478
- * @private
34479
- * @param {Object} set The set to convert.
34480
- * @returns {Array} Returns the values.
34481
- */
34482
- function setToArray(set) {
34483
- var index = -1,
34484
- result = Array(set.size);
34485
-
34486
- set.forEach(function(value) {
34487
- result[++index] = value;
34488
- });
34489
- return result;
34405
+ /** Generates a matrix for each table section (`thead`, `tbody`, `tfoot`) */
34406
+ function matrices(editor, options) {
34407
+ var _a, table, _b, tablePath, _c, _d, _e, path, matrix, _f, _g, _h, trPath, e_1_1;
34408
+ var e_1, _j, e_2, _k;
34409
+ if (options === void 0) { options = {}; }
34410
+ return __generator$2(this, function (_l) {
34411
+ switch (_l.label) {
34412
+ case 0:
34413
+ _a = __read$3(Editor.nodes(editor, {
34414
+ match: isOfType(editor, 'table'),
34415
+ at: options.at,
34416
+ }), 1), table = _a[0];
34417
+ if (!table) {
34418
+ return [2 /*return*/, []];
34419
+ }
34420
+ _b = __read$3(table, 2), tablePath = _b[1];
34421
+ _l.label = 1;
34422
+ case 1:
34423
+ _l.trys.push([1, 6, 7, 8]);
34424
+ _c = __values$3(Editor.nodes(editor, {
34425
+ // match: isOfType(editor, "thead", "tbody", "tfoot"),
34426
+ match: isOfType(editor, 'table'),
34427
+ at: tablePath,
34428
+ })), _d = _c.next();
34429
+ _l.label = 2;
34430
+ case 2:
34431
+ if (!!_d.done) return [3 /*break*/, 5];
34432
+ _e = __read$3(_d.value, 2), path = _e[1];
34433
+ matrix = [];
34434
+ try {
34435
+ for (_f = (e_2 = void 0, __values$3(Editor.nodes(editor, {
34436
+ match: isOfType(editor, 'tr'),
34437
+ at: path,
34438
+ }))), _g = _f.next(); !_g.done; _g = _f.next()) {
34439
+ _h = __read$3(_g.value, 2), trPath = _h[1];
34440
+ matrix.push(__spreadArray([], __read$3(Editor.nodes(editor, {
34441
+ match: isOfType(editor, 'th', 'td'),
34442
+ at: trPath,
34443
+ }))));
34444
+ }
34445
+ }
34446
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
34447
+ finally {
34448
+ try {
34449
+ if (_g && !_g.done && (_k = _f.return)) _k.call(_f);
34450
+ }
34451
+ finally { if (e_2) throw e_2.error; }
34452
+ }
34453
+ return [4 /*yield*/, matrix];
34454
+ case 3:
34455
+ _l.sent();
34456
+ _l.label = 4;
34457
+ case 4:
34458
+ _d = _c.next();
34459
+ return [3 /*break*/, 2];
34460
+ case 5: return [3 /*break*/, 8];
34461
+ case 6:
34462
+ e_1_1 = _l.sent();
34463
+ e_1 = { error: e_1_1 };
34464
+ return [3 /*break*/, 8];
34465
+ case 7:
34466
+ try {
34467
+ if (_d && !_d.done && (_j = _c.return)) _j.call(_c);
34468
+ }
34469
+ finally { if (e_1) throw e_1.error; }
34470
+ return [7 /*endfinally*/];
34471
+ case 8: return [2 /*return*/];
34472
+ }
34473
+ });
34474
+ }
34475
+ function filledMatrix(editor, options) {
34476
+ var e_3, _a;
34477
+ if (options === void 0) { options = {}; }
34478
+ var filled = [];
34479
+ try {
34480
+ // Expand each section separately to avoid sections collapsing into each other.
34481
+ for (var _b = __values$3(matrices(editor, { at: options.at })), _c = _b.next(); !_c.done; _c = _b.next()) {
34482
+ var matrix = _c.value;
34483
+ var filledSection = [];
34484
+ for (var x = 0; x < matrix.length; x++) {
34485
+ if (!filledSection[x]) {
34486
+ filledSection[x] = [];
34487
+ }
34488
+ for (var y = 0; y < matrix[x].length; y++) {
34489
+ var _d = __read$3(matrix[x][y], 1), _e = _d[0], _f = _e.rowSpan, rowSpan = _f === void 0 ? 1 : _f, _g = _e.colSpan, colSpan = _g === void 0 ? 1 : _g;
34490
+ for (var c = 0, occupied = 0; c < colSpan + occupied; c++) {
34491
+ for (var r = 0; r < rowSpan; r++) {
34492
+ if (!filledSection[x + r]) {
34493
+ filledSection[x + r] = [];
34494
+ }
34495
+ if (filledSection[x + r][y + c]) {
34496
+ continue;
34497
+ }
34498
+ filledSection[x + r][y + c] = [
34499
+ matrix[x + r][y + c],
34500
+ {
34501
+ rtl: c - occupied + 1,
34502
+ ltr: colSpan - c + occupied,
34503
+ ttb: r + 1,
34504
+ btt: rowSpan - r,
34505
+ },
34506
+ ];
34507
+ }
34508
+ }
34509
+ }
34510
+ }
34511
+ filled.push.apply(filled, __spreadArray([], __read$3(filledSection)));
34512
+ }
34513
+ }
34514
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
34515
+ finally {
34516
+ try {
34517
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
34518
+ }
34519
+ finally { if (e_3) throw e_3.error; }
34520
+ }
34521
+ return filled;
34490
34522
  }
34491
34523
 
34492
- /** Used for built-in method references. */
34493
- var arrayProto = Array.prototype,
34494
- funcProto = Function.prototype,
34495
- objectProto = Object.prototype;
34496
-
34497
- /** Used to detect overreaching core-js shims. */
34498
- var coreJsData = root['__core-js_shared__'];
34499
-
34500
- /** Used to resolve the decompiled source of functions. */
34501
- var funcToString = funcProto.toString;
34502
-
34503
- /** Used to check objects for own properties. */
34504
- var hasOwnProperty = objectProto.hasOwnProperty;
34505
-
34506
- /** Used to detect methods masquerading as native. */
34507
- var maskSrcKey = (function() {
34508
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
34509
- return uid ? ('Symbol(src)_1.' + uid) : '';
34524
+ var Point = /** @class */ (function () {
34525
+ function Point(x, y) {
34526
+ this.x = x;
34527
+ this.y = y;
34528
+ }
34529
+ Point.valueOf = function (x, y) {
34530
+ return new this(x, y);
34531
+ };
34532
+ Point.equals = function (point, another) {
34533
+ return point.x === another.x && point.y === another.y;
34534
+ };
34535
+ return Point;
34510
34536
  }());
34511
34537
 
34512
- /**
34513
- * Used to resolve the
34514
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
34515
- * of values.
34516
- */
34517
- var nativeObjectToString = objectProto.toString;
34518
-
34519
- /** Used to detect if a method is native. */
34520
- var reIsNative = RegExp('^' +
34521
- funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
34522
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
34523
- );
34524
-
34525
- /** Built-in value references. */
34526
- var Buffer = moduleExports ? root.Buffer : undefined,
34527
- Symbol = root.Symbol,
34528
- Uint8Array = root.Uint8Array,
34529
- propertyIsEnumerable = objectProto.propertyIsEnumerable,
34530
- splice = arrayProto.splice,
34531
- symToStringTag = Symbol ? Symbol.toStringTag : undefined;
34532
-
34533
- /* Built-in method references for those with the same name as other `lodash` methods. */
34534
- var nativeGetSymbols = Object.getOwnPropertySymbols,
34535
- nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
34536
- nativeKeys = overArg(Object.keys, Object);
34537
-
34538
- /* Built-in method references that are verified to be native. */
34539
- var DataView = getNative(root, 'DataView'),
34540
- Map = getNative(root, 'Map'),
34541
- Promise = getNative(root, 'Promise'),
34542
- Set = getNative(root, 'Set'),
34543
- WeakMap = getNative(root, 'WeakMap'),
34544
- nativeCreate = getNative(Object, 'create');
34545
-
34546
- /** Used to detect maps, sets, and weakmaps. */
34547
- var dataViewCtorString = toSource(DataView),
34548
- mapCtorString = toSource(Map),
34549
- promiseCtorString = toSource(Promise),
34550
- setCtorString = toSource(Set),
34551
- weakMapCtorString = toSource(WeakMap);
34538
+ var TableCursor = {
34539
+ /** @returns {boolean} `true` if the selection is inside a table, otherwise `false`. */
34540
+ isInTable: function (editor, options) {
34541
+ if (options === void 0) { options = {}; }
34542
+ var _a = __read$3(Editor.nodes(editor, {
34543
+ match: isOfType(editor, 'table'),
34544
+ at: options.at,
34545
+ }), 1), table = _a[0];
34546
+ return !!table;
34547
+ },
34548
+ /**
34549
+ * Retrieves a matrix representing the selected cells within a table.
34550
+ * @returns {NodeEntry<T>[][]} A matrix containing the selected cells.
34551
+ */
34552
+ selection: function (editor) {
34553
+ var matrix, x, cells, y, _a, entry, _b, colSpan, ttb;
34554
+ return __generator$2(this, function (_c) {
34555
+ switch (_c.label) {
34556
+ case 0:
34557
+ matrix = EDITOR_TO_SELECTION.get(editor);
34558
+ x = 0;
34559
+ _c.label = 1;
34560
+ case 1:
34561
+ if (!(matrix && x < matrix.length)) return [3 /*break*/, 4];
34562
+ cells = [];
34563
+ for (y = 0; y < matrix[x].length; y++) {
34564
+ _a = __read$3(matrix[x][y], 2), entry = _a[0], _b = _a[1], colSpan = _b.ltr, ttb = _b.ttb;
34565
+ ttb === 1 && cells.push(entry);
34566
+ y += colSpan - 1;
34567
+ }
34568
+ return [4 /*yield*/, cells];
34569
+ case 2:
34570
+ _c.sent();
34571
+ _c.label = 3;
34572
+ case 3:
34573
+ x++;
34574
+ return [3 /*break*/, 1];
34575
+ case 4: return [2 /*return*/];
34576
+ }
34577
+ });
34578
+ },
34579
+ /** Clears the selection from the table */
34580
+ unselect: function (editor) {
34581
+ // const matrix = EDITOR_TO_SELECTION.get(editor);
34582
+ var _a;
34583
+ // if (!matrix?.length) {
34584
+ // return;
34585
+ // }
34586
+ // for (let x = 0; x < matrix.length; x++) {
34587
+ // for (let y = 0; y < matrix[x].length; y++) {
34588
+ // const [[, path], { ltr: colSpan, ttb }] = matrix[x][y];
34589
+ // y += colSpan - 1;
34590
+ // if (ttb > 1) {
34591
+ // continue;
34592
+ // }
34593
+ // // no-op since the paths are the same
34594
+ // const noop: Operation = {
34595
+ // type: "move_node",
34596
+ // newPath: path,
34597
+ // path: path,
34598
+ // };
34599
+ // Transforms.transform(editor, noop);
34600
+ // }
34601
+ // }
34602
+ EDITOR_TO_SELECTION_SET.delete(editor);
34603
+ EDITOR_TO_SELECTION.delete(editor);
34604
+ // 清除选区
34605
+ (_a = document.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
34606
+ },
34607
+ /**
34608
+ * Checks whether a given cell is part of the current table selection.
34609
+ * @returns {boolean} - Returns true if the cell is selected, otherwise false.
34610
+ */
34611
+ isSelected: function (editor, element) {
34612
+ var selectedElements = EDITOR_TO_SELECTION_SET.get(editor);
34613
+ if (!selectedElements) {
34614
+ return false;
34615
+ }
34616
+ return selectedElements.has(element);
34617
+ },
34618
+ };
34552
34619
 
34553
- /** Used to convert symbols to primitives and strings. */
34554
- var symbolProto = Symbol ? Symbol.prototype : undefined,
34555
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
34556
-
34557
- /**
34558
- * Creates a hash object.
34559
- *
34560
- * @private
34561
- * @constructor
34562
- * @param {Array} [entries] The key-value pairs to cache.
34563
- */
34564
- function Hash(entries) {
34565
- var index = -1,
34566
- length = entries == null ? 0 : entries.length;
34567
-
34568
- this.clear();
34569
- while (++index < length) {
34570
- var entry = entries[index];
34571
- this.set(entry[0], entry[1]);
34572
- }
34573
- }
34574
-
34575
- /**
34576
- * Removes all key-value entries from the hash.
34577
- *
34578
- * @private
34579
- * @name clear
34580
- * @memberOf Hash
34581
- */
34582
- function hashClear() {
34583
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
34584
- this.size = 0;
34585
- }
34586
-
34587
- /**
34588
- * Removes `key` and its value from the hash.
34589
- *
34590
- * @private
34591
- * @name delete
34592
- * @memberOf Hash
34593
- * @param {Object} hash The hash to modify.
34594
- * @param {string} key The key of the value to remove.
34595
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
34596
- */
34597
- function hashDelete(key) {
34598
- var result = this.has(key) && delete this.__data__[key];
34599
- this.size -= result ? 1 : 0;
34600
- return result;
34601
- }
34602
-
34603
- /**
34604
- * Gets the hash value for `key`.
34605
- *
34606
- * @private
34607
- * @name get
34608
- * @memberOf Hash
34609
- * @param {string} key The key of the value to get.
34610
- * @returns {*} Returns the entry value.
34611
- */
34612
- function hashGet(key) {
34613
- var data = this.__data__;
34614
- if (nativeCreate) {
34615
- var result = data[key];
34616
- return result === HASH_UNDEFINED ? undefined : result;
34617
- }
34618
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
34619
- }
34620
-
34621
- /**
34622
- * Checks if a hash value for `key` exists.
34623
- *
34624
- * @private
34625
- * @name has
34626
- * @memberOf Hash
34627
- * @param {string} key The key of the entry to check.
34628
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
34629
- */
34630
- function hashHas(key) {
34631
- var data = this.__data__;
34632
- return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
34633
- }
34634
-
34635
- /**
34636
- * Sets the hash `key` to `value`.
34637
- *
34638
- * @private
34639
- * @name set
34640
- * @memberOf Hash
34641
- * @param {string} key The key of the value to set.
34642
- * @param {*} value The value to set.
34643
- * @returns {Object} Returns the hash instance.
34644
- */
34645
- function hashSet(key, value) {
34646
- var data = this.__data__;
34647
- this.size += this.has(key) ? 0 : 1;
34648
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
34649
- return this;
34650
- }
34651
-
34652
- // Add methods to `Hash`.
34653
- Hash.prototype.clear = hashClear;
34654
- Hash.prototype['delete'] = hashDelete;
34655
- Hash.prototype.get = hashGet;
34656
- Hash.prototype.has = hashHas;
34657
- Hash.prototype.set = hashSet;
34658
-
34659
- /**
34660
- * Creates an list cache object.
34661
- *
34662
- * @private
34663
- * @constructor
34664
- * @param {Array} [entries] The key-value pairs to cache.
34665
- */
34666
- function ListCache(entries) {
34667
- var index = -1,
34668
- length = entries == null ? 0 : entries.length;
34669
-
34670
- this.clear();
34671
- while (++index < length) {
34672
- var entry = entries[index];
34673
- this.set(entry[0], entry[1]);
34674
- }
34675
- }
34676
-
34677
- /**
34678
- * Removes all key-value entries from the list cache.
34679
- *
34680
- * @private
34681
- * @name clear
34682
- * @memberOf ListCache
34683
- */
34684
- function listCacheClear() {
34685
- this.__data__ = [];
34686
- this.size = 0;
34687
- }
34688
-
34689
- /**
34690
- * Removes `key` and its value from the list cache.
34691
- *
34692
- * @private
34693
- * @name delete
34694
- * @memberOf ListCache
34695
- * @param {string} key The key of the value to remove.
34696
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
34697
- */
34698
- function listCacheDelete(key) {
34699
- var data = this.__data__,
34700
- index = assocIndexOf(data, key);
34701
-
34702
- if (index < 0) {
34703
- return false;
34704
- }
34705
- var lastIndex = data.length - 1;
34706
- if (index == lastIndex) {
34707
- data.pop();
34708
- } else {
34709
- splice.call(data, index, 1);
34710
- }
34711
- --this.size;
34712
- return true;
34713
- }
34714
-
34715
- /**
34716
- * Gets the list cache value for `key`.
34717
- *
34718
- * @private
34719
- * @name get
34720
- * @memberOf ListCache
34721
- * @param {string} key The key of the value to get.
34722
- * @returns {*} Returns the entry value.
34723
- */
34724
- function listCacheGet(key) {
34725
- var data = this.__data__,
34726
- index = assocIndexOf(data, key);
34727
-
34728
- return index < 0 ? undefined : data[index][1];
34729
- }
34730
-
34731
- /**
34732
- * Checks if a list cache value for `key` exists.
34733
- *
34734
- * @private
34735
- * @name has
34736
- * @memberOf ListCache
34737
- * @param {string} key The key of the entry to check.
34738
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
34739
- */
34740
- function listCacheHas(key) {
34741
- return assocIndexOf(this.__data__, key) > -1;
34742
- }
34743
-
34744
- /**
34745
- * Sets the list cache `key` to `value`.
34746
- *
34747
- * @private
34748
- * @name set
34749
- * @memberOf ListCache
34750
- * @param {string} key The key of the value to set.
34751
- * @param {*} value The value to set.
34752
- * @returns {Object} Returns the list cache instance.
34753
- */
34754
- function listCacheSet(key, value) {
34755
- var data = this.__data__,
34756
- index = assocIndexOf(data, key);
34757
-
34758
- if (index < 0) {
34759
- ++this.size;
34760
- data.push([key, value]);
34761
- } else {
34762
- data[index][1] = value;
34763
- }
34764
- return this;
34765
- }
34766
-
34767
- // Add methods to `ListCache`.
34768
- ListCache.prototype.clear = listCacheClear;
34769
- ListCache.prototype['delete'] = listCacheDelete;
34770
- ListCache.prototype.get = listCacheGet;
34771
- ListCache.prototype.has = listCacheHas;
34772
- ListCache.prototype.set = listCacheSet;
34773
-
34774
- /**
34775
- * Creates a map cache object to store key-value pairs.
34776
- *
34777
- * @private
34778
- * @constructor
34779
- * @param {Array} [entries] The key-value pairs to cache.
34780
- */
34781
- function MapCache(entries) {
34782
- var index = -1,
34783
- length = entries == null ? 0 : entries.length;
34784
-
34785
- this.clear();
34786
- while (++index < length) {
34787
- var entry = entries[index];
34788
- this.set(entry[0], entry[1]);
34789
- }
34790
- }
34791
-
34792
- /**
34793
- * Removes all key-value entries from the map.
34794
- *
34795
- * @private
34796
- * @name clear
34797
- * @memberOf MapCache
34798
- */
34799
- function mapCacheClear() {
34800
- this.size = 0;
34801
- this.__data__ = {
34802
- 'hash': new Hash,
34803
- 'map': new (Map || ListCache),
34804
- 'string': new Hash
34805
- };
34806
- }
34807
-
34808
- /**
34809
- * Removes `key` and its value from the map.
34810
- *
34811
- * @private
34812
- * @name delete
34813
- * @memberOf MapCache
34814
- * @param {string} key The key of the value to remove.
34815
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
34816
- */
34817
- function mapCacheDelete(key) {
34818
- var result = getMapData(this, key)['delete'](key);
34819
- this.size -= result ? 1 : 0;
34820
- return result;
34821
- }
34822
-
34823
- /**
34824
- * Gets the map value for `key`.
34825
- *
34826
- * @private
34827
- * @name get
34828
- * @memberOf MapCache
34829
- * @param {string} key The key of the value to get.
34830
- * @returns {*} Returns the entry value.
34831
- */
34832
- function mapCacheGet(key) {
34833
- return getMapData(this, key).get(key);
34834
- }
34835
-
34836
- /**
34837
- * Checks if a map value for `key` exists.
34838
- *
34839
- * @private
34840
- * @name has
34841
- * @memberOf MapCache
34842
- * @param {string} key The key of the entry to check.
34843
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
34844
- */
34845
- function mapCacheHas(key) {
34846
- return getMapData(this, key).has(key);
34847
- }
34848
-
34849
- /**
34850
- * Sets the map `key` to `value`.
34851
- *
34852
- * @private
34853
- * @name set
34854
- * @memberOf MapCache
34855
- * @param {string} key The key of the value to set.
34856
- * @param {*} value The value to set.
34857
- * @returns {Object} Returns the map cache instance.
34858
- */
34859
- function mapCacheSet(key, value) {
34860
- var data = getMapData(this, key),
34861
- size = data.size;
34862
-
34863
- data.set(key, value);
34864
- this.size += data.size == size ? 0 : 1;
34865
- return this;
34866
- }
34867
-
34868
- // Add methods to `MapCache`.
34869
- MapCache.prototype.clear = mapCacheClear;
34870
- MapCache.prototype['delete'] = mapCacheDelete;
34871
- MapCache.prototype.get = mapCacheGet;
34872
- MapCache.prototype.has = mapCacheHas;
34873
- MapCache.prototype.set = mapCacheSet;
34874
-
34875
- /**
34876
- *
34877
- * Creates an array cache object to store unique values.
34878
- *
34879
- * @private
34880
- * @constructor
34881
- * @param {Array} [values] The values to cache.
34882
- */
34883
- function SetCache(values) {
34884
- var index = -1,
34885
- length = values == null ? 0 : values.length;
34886
-
34887
- this.__data__ = new MapCache;
34888
- while (++index < length) {
34889
- this.add(values[index]);
34890
- }
34891
- }
34892
-
34893
- /**
34894
- * Adds `value` to the array cache.
34895
- *
34896
- * @private
34897
- * @name add
34898
- * @memberOf SetCache
34899
- * @alias push
34900
- * @param {*} value The value to cache.
34901
- * @returns {Object} Returns the cache instance.
34902
- */
34903
- function setCacheAdd(value) {
34904
- this.__data__.set(value, HASH_UNDEFINED);
34905
- return this;
34906
- }
34907
-
34908
- /**
34909
- * Checks if `value` is in the array cache.
34910
- *
34911
- * @private
34912
- * @name has
34913
- * @memberOf SetCache
34914
- * @param {*} value The value to search for.
34915
- * @returns {number} Returns `true` if `value` is found, else `false`.
34916
- */
34917
- function setCacheHas(value) {
34918
- return this.__data__.has(value);
34919
- }
34920
-
34921
- // Add methods to `SetCache`.
34922
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
34923
- SetCache.prototype.has = setCacheHas;
34924
-
34925
- /**
34926
- * Creates a stack cache object to store key-value pairs.
34927
- *
34928
- * @private
34929
- * @constructor
34930
- * @param {Array} [entries] The key-value pairs to cache.
34931
- */
34932
- function Stack(entries) {
34933
- var data = this.__data__ = new ListCache(entries);
34934
- this.size = data.size;
34935
- }
34936
-
34937
- /**
34938
- * Removes all key-value entries from the stack.
34939
- *
34940
- * @private
34941
- * @name clear
34942
- * @memberOf Stack
34943
- */
34944
- function stackClear() {
34945
- this.__data__ = new ListCache;
34946
- this.size = 0;
34947
- }
34948
-
34949
- /**
34950
- * Removes `key` and its value from the stack.
34951
- *
34952
- * @private
34953
- * @name delete
34954
- * @memberOf Stack
34955
- * @param {string} key The key of the value to remove.
34956
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
34957
- */
34958
- function stackDelete(key) {
34959
- var data = this.__data__,
34960
- result = data['delete'](key);
34961
-
34962
- this.size = data.size;
34963
- return result;
34964
- }
34965
-
34966
- /**
34967
- * Gets the stack value for `key`.
34968
- *
34969
- * @private
34970
- * @name get
34971
- * @memberOf Stack
34972
- * @param {string} key The key of the value to get.
34973
- * @returns {*} Returns the entry value.
34974
- */
34975
- function stackGet(key) {
34976
- return this.__data__.get(key);
34977
- }
34978
-
34979
- /**
34980
- * Checks if a stack value for `key` exists.
34981
- *
34982
- * @private
34983
- * @name has
34984
- * @memberOf Stack
34985
- * @param {string} key The key of the entry to check.
34986
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
34987
- */
34988
- function stackHas(key) {
34989
- return this.__data__.has(key);
34990
- }
34991
-
34992
- /**
34993
- * Sets the stack `key` to `value`.
34994
- *
34995
- * @private
34996
- * @name set
34997
- * @memberOf Stack
34998
- * @param {string} key The key of the value to set.
34999
- * @param {*} value The value to set.
35000
- * @returns {Object} Returns the stack cache instance.
35001
- */
35002
- function stackSet(key, value) {
35003
- var data = this.__data__;
35004
- if (data instanceof ListCache) {
35005
- var pairs = data.__data__;
35006
- if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
35007
- pairs.push([key, value]);
35008
- this.size = ++data.size;
35009
- return this;
35010
- }
35011
- data = this.__data__ = new MapCache(pairs);
35012
- }
35013
- data.set(key, value);
35014
- this.size = data.size;
35015
- return this;
35016
- }
35017
-
35018
- // Add methods to `Stack`.
35019
- Stack.prototype.clear = stackClear;
35020
- Stack.prototype['delete'] = stackDelete;
35021
- Stack.prototype.get = stackGet;
35022
- Stack.prototype.has = stackHas;
35023
- Stack.prototype.set = stackSet;
35024
-
35025
- /**
35026
- * Creates an array of the enumerable property names of the array-like `value`.
35027
- *
35028
- * @private
35029
- * @param {*} value The value to query.
35030
- * @param {boolean} inherited Specify returning inherited property names.
35031
- * @returns {Array} Returns the array of property names.
35032
- */
35033
- function arrayLikeKeys(value, inherited) {
35034
- var isArr = isArray(value),
35035
- isArg = !isArr && isArguments(value),
35036
- isBuff = !isArr && !isArg && isBuffer(value),
35037
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
35038
- skipIndexes = isArr || isArg || isBuff || isType,
35039
- result = skipIndexes ? baseTimes(value.length, String) : [],
35040
- length = result.length;
35041
-
35042
- for (var key in value) {
35043
- if ((inherited || hasOwnProperty.call(value, key)) &&
35044
- !(skipIndexes && (
35045
- // Safari 9 has enumerable `arguments.length` in strict mode.
35046
- key == 'length' ||
35047
- // Node.js 0.10 has enumerable non-index properties on buffers.
35048
- (isBuff && (key == 'offset' || key == 'parent')) ||
35049
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
35050
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
35051
- // Skip index properties.
35052
- isIndex(key, length)
35053
- ))) {
35054
- result.push(key);
35055
- }
35056
- }
35057
- return result;
35058
- }
35059
-
35060
- /**
35061
- * Gets the index at which the `key` is found in `array` of key-value pairs.
35062
- *
35063
- * @private
35064
- * @param {Array} array The array to inspect.
35065
- * @param {*} key The key to search for.
35066
- * @returns {number} Returns the index of the matched value, else `-1`.
35067
- */
35068
- function assocIndexOf(array, key) {
35069
- var length = array.length;
35070
- while (length--) {
35071
- if (eq(array[length][0], key)) {
35072
- return length;
35073
- }
35074
- }
35075
- return -1;
35076
- }
35077
-
35078
- /**
35079
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
35080
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
35081
- * symbols of `object`.
35082
- *
35083
- * @private
35084
- * @param {Object} object The object to query.
35085
- * @param {Function} keysFunc The function to get the keys of `object`.
35086
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
35087
- * @returns {Array} Returns the array of property names and symbols.
35088
- */
35089
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
35090
- var result = keysFunc(object);
35091
- return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
35092
- }
35093
-
35094
- /**
35095
- * The base implementation of `getTag` without fallbacks for buggy environments.
35096
- *
35097
- * @private
35098
- * @param {*} value The value to query.
35099
- * @returns {string} Returns the `toStringTag`.
35100
- */
35101
- function baseGetTag(value) {
35102
- if (value == null) {
35103
- return value === undefined ? undefinedTag : nullTag;
35104
- }
35105
- return (symToStringTag && symToStringTag in Object(value))
35106
- ? getRawTag(value)
35107
- : objectToString(value);
35108
- }
35109
-
35110
- /**
35111
- * The base implementation of `_.isArguments`.
35112
- *
35113
- * @private
35114
- * @param {*} value The value to check.
35115
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
35116
- */
35117
- function baseIsArguments(value) {
35118
- return isObjectLike(value) && baseGetTag(value) == argsTag;
35119
- }
35120
-
35121
- /**
35122
- * The base implementation of `_.isEqual` which supports partial comparisons
35123
- * and tracks traversed objects.
35124
- *
35125
- * @private
35126
- * @param {*} value The value to compare.
35127
- * @param {*} other The other value to compare.
35128
- * @param {boolean} bitmask The bitmask flags.
35129
- * 1 - Unordered comparison
35130
- * 2 - Partial comparison
35131
- * @param {Function} [customizer] The function to customize comparisons.
35132
- * @param {Object} [stack] Tracks traversed `value` and `other` objects.
35133
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
35134
- */
35135
- function baseIsEqual(value, other, bitmask, customizer, stack) {
35136
- if (value === other) {
35137
- return true;
35138
- }
35139
- if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
35140
- return value !== value && other !== other;
35141
- }
35142
- return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
35143
- }
35144
-
35145
- /**
35146
- * A specialized version of `baseIsEqual` for arrays and objects which performs
35147
- * deep comparisons and tracks traversed objects enabling objects with circular
35148
- * references to be compared.
35149
- *
35150
- * @private
35151
- * @param {Object} object The object to compare.
35152
- * @param {Object} other The other object to compare.
35153
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
35154
- * @param {Function} customizer The function to customize comparisons.
35155
- * @param {Function} equalFunc The function to determine equivalents of values.
35156
- * @param {Object} [stack] Tracks traversed `object` and `other` objects.
35157
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
35158
- */
35159
- function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
35160
- var objIsArr = isArray(object),
35161
- othIsArr = isArray(other),
35162
- objTag = objIsArr ? arrayTag : getTag(object),
35163
- othTag = othIsArr ? arrayTag : getTag(other);
35164
-
35165
- objTag = objTag == argsTag ? objectTag : objTag;
35166
- othTag = othTag == argsTag ? objectTag : othTag;
35167
-
35168
- var objIsObj = objTag == objectTag,
35169
- othIsObj = othTag == objectTag,
35170
- isSameTag = objTag == othTag;
35171
-
35172
- if (isSameTag && isBuffer(object)) {
35173
- if (!isBuffer(other)) {
35174
- return false;
35175
- }
35176
- objIsArr = true;
35177
- objIsObj = false;
35178
- }
35179
- if (isSameTag && !objIsObj) {
35180
- stack || (stack = new Stack);
35181
- return (objIsArr || isTypedArray(object))
35182
- ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
35183
- : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
35184
- }
35185
- if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
35186
- var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
35187
- othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
35188
-
35189
- if (objIsWrapped || othIsWrapped) {
35190
- var objUnwrapped = objIsWrapped ? object.value() : object,
35191
- othUnwrapped = othIsWrapped ? other.value() : other;
35192
-
35193
- stack || (stack = new Stack);
35194
- return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
35195
- }
35196
- }
35197
- if (!isSameTag) {
35198
- return false;
35199
- }
35200
- stack || (stack = new Stack);
35201
- return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
35202
- }
35203
-
35204
- /**
35205
- * The base implementation of `_.isNative` without bad shim checks.
35206
- *
35207
- * @private
35208
- * @param {*} value The value to check.
35209
- * @returns {boolean} Returns `true` if `value` is a native function,
35210
- * else `false`.
35211
- */
35212
- function baseIsNative(value) {
35213
- if (!isObject(value) || isMasked(value)) {
35214
- return false;
35215
- }
35216
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
35217
- return pattern.test(toSource(value));
35218
- }
35219
-
35220
- /**
35221
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
35222
- *
35223
- * @private
35224
- * @param {*} value The value to check.
35225
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
35226
- */
35227
- function baseIsTypedArray(value) {
35228
- return isObjectLike(value) &&
35229
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
35230
- }
35231
-
35232
- /**
35233
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
35234
- *
35235
- * @private
35236
- * @param {Object} object The object to query.
35237
- * @returns {Array} Returns the array of property names.
35238
- */
35239
- function baseKeys(object) {
35240
- if (!isPrototype(object)) {
35241
- return nativeKeys(object);
35242
- }
35243
- var result = [];
35244
- for (var key in Object(object)) {
35245
- if (hasOwnProperty.call(object, key) && key != 'constructor') {
35246
- result.push(key);
35247
- }
35248
- }
35249
- return result;
35250
- }
35251
-
35252
- /**
35253
- * A specialized version of `baseIsEqualDeep` for arrays with support for
35254
- * partial deep comparisons.
35255
- *
35256
- * @private
35257
- * @param {Array} array The array to compare.
35258
- * @param {Array} other The other array to compare.
35259
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
35260
- * @param {Function} customizer The function to customize comparisons.
35261
- * @param {Function} equalFunc The function to determine equivalents of values.
35262
- * @param {Object} stack Tracks traversed `array` and `other` objects.
35263
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
35264
- */
35265
- function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
35266
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
35267
- arrLength = array.length,
35268
- othLength = other.length;
35269
-
35270
- if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
35271
- return false;
35272
- }
35273
- // Assume cyclic values are equal.
35274
- var stacked = stack.get(array);
35275
- if (stacked && stack.get(other)) {
35276
- return stacked == other;
35277
- }
35278
- var index = -1,
35279
- result = true,
35280
- seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
35281
-
35282
- stack.set(array, other);
35283
- stack.set(other, array);
35284
-
35285
- // Ignore non-index properties.
35286
- while (++index < arrLength) {
35287
- var arrValue = array[index],
35288
- othValue = other[index];
35289
-
35290
- if (customizer) {
35291
- var compared = isPartial
35292
- ? customizer(othValue, arrValue, index, other, array, stack)
35293
- : customizer(arrValue, othValue, index, array, other, stack);
35294
- }
35295
- if (compared !== undefined) {
35296
- if (compared) {
35297
- continue;
35298
- }
35299
- result = false;
35300
- break;
35301
- }
35302
- // Recursively compare arrays (susceptible to call stack limits).
35303
- if (seen) {
35304
- if (!arraySome(other, function(othValue, othIndex) {
35305
- if (!cacheHas(seen, othIndex) &&
35306
- (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
35307
- return seen.push(othIndex);
35308
- }
35309
- })) {
35310
- result = false;
35311
- break;
35312
- }
35313
- } else if (!(
35314
- arrValue === othValue ||
35315
- equalFunc(arrValue, othValue, bitmask, customizer, stack)
35316
- )) {
35317
- result = false;
35318
- break;
35319
- }
35320
- }
35321
- stack['delete'](array);
35322
- stack['delete'](other);
35323
- return result;
35324
- }
35325
-
35326
- /**
35327
- * A specialized version of `baseIsEqualDeep` for comparing objects of
35328
- * the same `toStringTag`.
35329
- *
35330
- * **Note:** This function only supports comparing values with tags of
35331
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
35332
- *
35333
- * @private
35334
- * @param {Object} object The object to compare.
35335
- * @param {Object} other The other object to compare.
35336
- * @param {string} tag The `toStringTag` of the objects to compare.
35337
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
35338
- * @param {Function} customizer The function to customize comparisons.
35339
- * @param {Function} equalFunc The function to determine equivalents of values.
35340
- * @param {Object} stack Tracks traversed `object` and `other` objects.
35341
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
35342
- */
35343
- function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
35344
- switch (tag) {
35345
- case dataViewTag:
35346
- if ((object.byteLength != other.byteLength) ||
35347
- (object.byteOffset != other.byteOffset)) {
35348
- return false;
35349
- }
35350
- object = object.buffer;
35351
- other = other.buffer;
35352
-
35353
- case arrayBufferTag:
35354
- if ((object.byteLength != other.byteLength) ||
35355
- !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
35356
- return false;
35357
- }
35358
- return true;
35359
-
35360
- case boolTag:
35361
- case dateTag:
35362
- case numberTag:
35363
- // Coerce booleans to `1` or `0` and dates to milliseconds.
35364
- // Invalid dates are coerced to `NaN`.
35365
- return eq(+object, +other);
35366
-
35367
- case errorTag:
35368
- return object.name == other.name && object.message == other.message;
35369
-
35370
- case regexpTag:
35371
- case stringTag:
35372
- // Coerce regexes to strings and treat strings, primitives and objects,
35373
- // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
35374
- // for more details.
35375
- return object == (other + '');
35376
-
35377
- case mapTag:
35378
- var convert = mapToArray;
35379
-
35380
- case setTag:
35381
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
35382
- convert || (convert = setToArray);
35383
-
35384
- if (object.size != other.size && !isPartial) {
35385
- return false;
35386
- }
35387
- // Assume cyclic values are equal.
35388
- var stacked = stack.get(object);
35389
- if (stacked) {
35390
- return stacked == other;
35391
- }
35392
- bitmask |= COMPARE_UNORDERED_FLAG;
35393
-
35394
- // Recursively compare objects (susceptible to call stack limits).
35395
- stack.set(object, other);
35396
- var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
35397
- stack['delete'](object);
35398
- return result;
35399
-
35400
- case symbolTag:
35401
- if (symbolValueOf) {
35402
- return symbolValueOf.call(object) == symbolValueOf.call(other);
35403
- }
35404
- }
35405
- return false;
35406
- }
35407
-
35408
- /**
35409
- * A specialized version of `baseIsEqualDeep` for objects with support for
35410
- * partial deep comparisons.
35411
- *
35412
- * @private
35413
- * @param {Object} object The object to compare.
35414
- * @param {Object} other The other object to compare.
35415
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
35416
- * @param {Function} customizer The function to customize comparisons.
35417
- * @param {Function} equalFunc The function to determine equivalents of values.
35418
- * @param {Object} stack Tracks traversed `object` and `other` objects.
35419
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
35420
- */
35421
- function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
35422
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
35423
- objProps = getAllKeys(object),
35424
- objLength = objProps.length,
35425
- othProps = getAllKeys(other),
35426
- othLength = othProps.length;
35427
-
35428
- if (objLength != othLength && !isPartial) {
35429
- return false;
35430
- }
35431
- var index = objLength;
35432
- while (index--) {
35433
- var key = objProps[index];
35434
- if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
35435
- return false;
35436
- }
35437
- }
35438
- // Assume cyclic values are equal.
35439
- var stacked = stack.get(object);
35440
- if (stacked && stack.get(other)) {
35441
- return stacked == other;
35442
- }
35443
- var result = true;
35444
- stack.set(object, other);
35445
- stack.set(other, object);
35446
-
35447
- var skipCtor = isPartial;
35448
- while (++index < objLength) {
35449
- key = objProps[index];
35450
- var objValue = object[key],
35451
- othValue = other[key];
35452
-
35453
- if (customizer) {
35454
- var compared = isPartial
35455
- ? customizer(othValue, objValue, key, other, object, stack)
35456
- : customizer(objValue, othValue, key, object, other, stack);
35457
- }
35458
- // Recursively compare objects (susceptible to call stack limits).
35459
- if (!(compared === undefined
35460
- ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
35461
- : compared
35462
- )) {
35463
- result = false;
35464
- break;
35465
- }
35466
- skipCtor || (skipCtor = key == 'constructor');
35467
- }
35468
- if (result && !skipCtor) {
35469
- var objCtor = object.constructor,
35470
- othCtor = other.constructor;
35471
-
35472
- // Non `Object` object instances with different constructors are not equal.
35473
- if (objCtor != othCtor &&
35474
- ('constructor' in object && 'constructor' in other) &&
35475
- !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
35476
- typeof othCtor == 'function' && othCtor instanceof othCtor)) {
35477
- result = false;
35478
- }
35479
- }
35480
- stack['delete'](object);
35481
- stack['delete'](other);
35482
- return result;
35483
- }
35484
-
35485
- /**
35486
- * Creates an array of own enumerable property names and symbols of `object`.
35487
- *
35488
- * @private
35489
- * @param {Object} object The object to query.
35490
- * @returns {Array} Returns the array of property names and symbols.
35491
- */
35492
- function getAllKeys(object) {
35493
- return baseGetAllKeys(object, keys, getSymbols);
35494
- }
35495
-
35496
- /**
35497
- * Gets the data for `map`.
35498
- *
35499
- * @private
35500
- * @param {Object} map The map to query.
35501
- * @param {string} key The reference key.
35502
- * @returns {*} Returns the map data.
35503
- */
35504
- function getMapData(map, key) {
35505
- var data = map.__data__;
35506
- return isKeyable(key)
35507
- ? data[typeof key == 'string' ? 'string' : 'hash']
35508
- : data.map;
35509
- }
35510
-
35511
- /**
35512
- * Gets the native function at `key` of `object`.
35513
- *
35514
- * @private
35515
- * @param {Object} object The object to query.
35516
- * @param {string} key The key of the method to get.
35517
- * @returns {*} Returns the function if it's native, else `undefined`.
35518
- */
35519
- function getNative(object, key) {
35520
- var value = getValue(object, key);
35521
- return baseIsNative(value) ? value : undefined;
35522
- }
35523
-
35524
- /**
35525
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
35526
- *
35527
- * @private
35528
- * @param {*} value The value to query.
35529
- * @returns {string} Returns the raw `toStringTag`.
35530
- */
35531
- function getRawTag(value) {
35532
- var isOwn = hasOwnProperty.call(value, symToStringTag),
35533
- tag = value[symToStringTag];
35534
-
35535
- try {
35536
- value[symToStringTag] = undefined;
35537
- var unmasked = true;
35538
- } catch (e) {}
35539
-
35540
- var result = nativeObjectToString.call(value);
35541
- if (unmasked) {
35542
- if (isOwn) {
35543
- value[symToStringTag] = tag;
35544
- } else {
35545
- delete value[symToStringTag];
35546
- }
35547
- }
35548
- return result;
35549
- }
35550
-
35551
- /**
35552
- * Creates an array of the own enumerable symbols of `object`.
35553
- *
35554
- * @private
35555
- * @param {Object} object The object to query.
35556
- * @returns {Array} Returns the array of symbols.
35557
- */
35558
- var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
35559
- if (object == null) {
35560
- return [];
35561
- }
35562
- object = Object(object);
35563
- return arrayFilter(nativeGetSymbols(object), function(symbol) {
35564
- return propertyIsEnumerable.call(object, symbol);
35565
- });
35566
- };
35567
-
35568
- /**
35569
- * Gets the `toStringTag` of `value`.
35570
- *
35571
- * @private
35572
- * @param {*} value The value to query.
35573
- * @returns {string} Returns the `toStringTag`.
35574
- */
35575
- var getTag = baseGetTag;
35576
-
35577
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
35578
- if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
35579
- (Map && getTag(new Map) != mapTag) ||
35580
- (Promise && getTag(Promise.resolve()) != promiseTag) ||
35581
- (Set && getTag(new Set) != setTag) ||
35582
- (WeakMap && getTag(new WeakMap) != weakMapTag)) {
35583
- getTag = function(value) {
35584
- var result = baseGetTag(value),
35585
- Ctor = result == objectTag ? value.constructor : undefined,
35586
- ctorString = Ctor ? toSource(Ctor) : '';
35587
-
35588
- if (ctorString) {
35589
- switch (ctorString) {
35590
- case dataViewCtorString: return dataViewTag;
35591
- case mapCtorString: return mapTag;
35592
- case promiseCtorString: return promiseTag;
35593
- case setCtorString: return setTag;
35594
- case weakMapCtorString: return weakMapTag;
35595
- }
35596
- }
35597
- return result;
35598
- };
35599
- }
35600
-
35601
- /**
35602
- * Checks if `value` is a valid array-like index.
35603
- *
35604
- * @private
35605
- * @param {*} value The value to check.
35606
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
35607
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
35608
- */
35609
- function isIndex(value, length) {
35610
- length = length == null ? MAX_SAFE_INTEGER : length;
35611
- return !!length &&
35612
- (typeof value == 'number' || reIsUint.test(value)) &&
35613
- (value > -1 && value % 1 == 0 && value < length);
35614
- }
35615
-
35616
- /**
35617
- * Checks if `value` is suitable for use as unique object key.
35618
- *
35619
- * @private
35620
- * @param {*} value The value to check.
35621
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
35622
- */
35623
- function isKeyable(value) {
35624
- var type = typeof value;
35625
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
35626
- ? (value !== '__proto__')
35627
- : (value === null);
35628
- }
35629
-
35630
- /**
35631
- * Checks if `func` has its source masked.
35632
- *
35633
- * @private
35634
- * @param {Function} func The function to check.
35635
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
35636
- */
35637
- function isMasked(func) {
35638
- return !!maskSrcKey && (maskSrcKey in func);
35639
- }
35640
-
35641
- /**
35642
- * Checks if `value` is likely a prototype object.
35643
- *
35644
- * @private
35645
- * @param {*} value The value to check.
35646
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
35647
- */
35648
- function isPrototype(value) {
35649
- var Ctor = value && value.constructor,
35650
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
35651
-
35652
- return value === proto;
35653
- }
35654
-
35655
- /**
35656
- * Converts `value` to a string using `Object.prototype.toString`.
35657
- *
35658
- * @private
35659
- * @param {*} value The value to convert.
35660
- * @returns {string} Returns the converted string.
35661
- */
35662
- function objectToString(value) {
35663
- return nativeObjectToString.call(value);
35664
- }
35665
-
35666
- /**
35667
- * Converts `func` to its source code.
35668
- *
35669
- * @private
35670
- * @param {Function} func The function to convert.
35671
- * @returns {string} Returns the source code.
35672
- */
35673
- function toSource(func) {
35674
- if (func != null) {
35675
- try {
35676
- return funcToString.call(func);
35677
- } catch (e) {}
35678
- try {
35679
- return (func + '');
35680
- } catch (e) {}
35681
- }
35682
- return '';
35683
- }
35684
-
35685
- /**
35686
- * Performs a
35687
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
35688
- * comparison between two values to determine if they are equivalent.
35689
- *
35690
- * @static
35691
- * @memberOf _
35692
- * @since 4.0.0
35693
- * @category Lang
35694
- * @param {*} value The value to compare.
35695
- * @param {*} other The other value to compare.
35696
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
35697
- * @example
35698
- *
35699
- * var object = { 'a': 1 };
35700
- * var other = { 'a': 1 };
35701
- *
35702
- * _.eq(object, object);
35703
- * // => true
35704
- *
35705
- * _.eq(object, other);
35706
- * // => false
35707
- *
35708
- * _.eq('a', 'a');
35709
- * // => true
35710
- *
35711
- * _.eq('a', Object('a'));
35712
- * // => false
35713
- *
35714
- * _.eq(NaN, NaN);
35715
- * // => true
35716
- */
35717
- function eq(value, other) {
35718
- return value === other || (value !== value && other !== other);
35719
- }
35720
-
35721
- /**
35722
- * Checks if `value` is likely an `arguments` object.
35723
- *
35724
- * @static
35725
- * @memberOf _
35726
- * @since 0.1.0
35727
- * @category Lang
35728
- * @param {*} value The value to check.
35729
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
35730
- * else `false`.
35731
- * @example
35732
- *
35733
- * _.isArguments(function() { return arguments; }());
35734
- * // => true
35735
- *
35736
- * _.isArguments([1, 2, 3]);
35737
- * // => false
35738
- */
35739
- var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
35740
- return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
35741
- !propertyIsEnumerable.call(value, 'callee');
35742
- };
35743
-
35744
- /**
35745
- * Checks if `value` is classified as an `Array` object.
35746
- *
35747
- * @static
35748
- * @memberOf _
35749
- * @since 0.1.0
35750
- * @category Lang
35751
- * @param {*} value The value to check.
35752
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
35753
- * @example
35754
- *
35755
- * _.isArray([1, 2, 3]);
35756
- * // => true
35757
- *
35758
- * _.isArray(document.body.children);
35759
- * // => false
35760
- *
35761
- * _.isArray('abc');
35762
- * // => false
35763
- *
35764
- * _.isArray(_.noop);
35765
- * // => false
35766
- */
35767
- var isArray = Array.isArray;
35768
-
35769
- /**
35770
- * Checks if `value` is array-like. A value is considered array-like if it's
35771
- * not a function and has a `value.length` that's an integer greater than or
35772
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
35773
- *
35774
- * @static
35775
- * @memberOf _
35776
- * @since 4.0.0
35777
- * @category Lang
35778
- * @param {*} value The value to check.
35779
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
35780
- * @example
35781
- *
35782
- * _.isArrayLike([1, 2, 3]);
35783
- * // => true
35784
- *
35785
- * _.isArrayLike(document.body.children);
35786
- * // => true
35787
- *
35788
- * _.isArrayLike('abc');
35789
- * // => true
35790
- *
35791
- * _.isArrayLike(_.noop);
35792
- * // => false
35793
- */
35794
- function isArrayLike(value) {
35795
- return value != null && isLength(value.length) && !isFunction(value);
35796
- }
35797
-
35798
- /**
35799
- * Checks if `value` is a buffer.
35800
- *
35801
- * @static
35802
- * @memberOf _
35803
- * @since 4.3.0
35804
- * @category Lang
35805
- * @param {*} value The value to check.
35806
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
35807
- * @example
35808
- *
35809
- * _.isBuffer(new Buffer(2));
35810
- * // => true
35811
- *
35812
- * _.isBuffer(new Uint8Array(2));
35813
- * // => false
35814
- */
35815
- var isBuffer = nativeIsBuffer || stubFalse;
35816
-
35817
- /**
35818
- * Performs a deep comparison between two values to determine if they are
35819
- * equivalent.
35820
- *
35821
- * **Note:** This method supports comparing arrays, array buffers, booleans,
35822
- * date objects, error objects, maps, numbers, `Object` objects, regexes,
35823
- * sets, strings, symbols, and typed arrays. `Object` objects are compared
35824
- * by their own, not inherited, enumerable properties. Functions and DOM
35825
- * nodes are compared by strict equality, i.e. `===`.
35826
- *
35827
- * @static
35828
- * @memberOf _
35829
- * @since 0.1.0
35830
- * @category Lang
35831
- * @param {*} value The value to compare.
35832
- * @param {*} other The other value to compare.
35833
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
35834
- * @example
35835
- *
35836
- * var object = { 'a': 1 };
35837
- * var other = { 'a': 1 };
35838
- *
35839
- * _.isEqual(object, other);
35840
- * // => true
35841
- *
35842
- * object === other;
35843
- * // => false
35844
- */
35845
- function isEqual(value, other) {
35846
- return baseIsEqual(value, other);
35847
- }
35848
-
35849
- /**
35850
- * Checks if `value` is classified as a `Function` object.
35851
- *
35852
- * @static
35853
- * @memberOf _
35854
- * @since 0.1.0
35855
- * @category Lang
35856
- * @param {*} value The value to check.
35857
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
35858
- * @example
35859
- *
35860
- * _.isFunction(_);
35861
- * // => true
35862
- *
35863
- * _.isFunction(/abc/);
35864
- * // => false
35865
- */
35866
- function isFunction(value) {
35867
- if (!isObject(value)) {
35868
- return false;
35869
- }
35870
- // The use of `Object#toString` avoids issues with the `typeof` operator
35871
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
35872
- var tag = baseGetTag(value);
35873
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
35874
- }
35875
-
35876
- /**
35877
- * Checks if `value` is a valid array-like length.
35878
- *
35879
- * **Note:** This method is loosely based on
35880
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
35881
- *
35882
- * @static
35883
- * @memberOf _
35884
- * @since 4.0.0
35885
- * @category Lang
35886
- * @param {*} value The value to check.
35887
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
35888
- * @example
35889
- *
35890
- * _.isLength(3);
35891
- * // => true
35892
- *
35893
- * _.isLength(Number.MIN_VALUE);
35894
- * // => false
35895
- *
35896
- * _.isLength(Infinity);
35897
- * // => false
35898
- *
35899
- * _.isLength('3');
35900
- * // => false
35901
- */
35902
- function isLength(value) {
35903
- return typeof value == 'number' &&
35904
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
35905
- }
35906
-
35907
- /**
35908
- * Checks if `value` is the
35909
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
35910
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
35911
- *
35912
- * @static
35913
- * @memberOf _
35914
- * @since 0.1.0
35915
- * @category Lang
35916
- * @param {*} value The value to check.
35917
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
35918
- * @example
35919
- *
35920
- * _.isObject({});
35921
- * // => true
35922
- *
35923
- * _.isObject([1, 2, 3]);
35924
- * // => true
35925
- *
35926
- * _.isObject(_.noop);
35927
- * // => true
35928
- *
35929
- * _.isObject(null);
35930
- * // => false
35931
- */
35932
- function isObject(value) {
35933
- var type = typeof value;
35934
- return value != null && (type == 'object' || type == 'function');
35935
- }
35936
-
35937
- /**
35938
- * Checks if `value` is object-like. A value is object-like if it's not `null`
35939
- * and has a `typeof` result of "object".
35940
- *
35941
- * @static
35942
- * @memberOf _
35943
- * @since 4.0.0
35944
- * @category Lang
35945
- * @param {*} value The value to check.
35946
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
35947
- * @example
35948
- *
35949
- * _.isObjectLike({});
35950
- * // => true
35951
- *
35952
- * _.isObjectLike([1, 2, 3]);
35953
- * // => true
35954
- *
35955
- * _.isObjectLike(_.noop);
35956
- * // => false
35957
- *
35958
- * _.isObjectLike(null);
35959
- * // => false
35960
- */
35961
- function isObjectLike(value) {
35962
- return value != null && typeof value == 'object';
35963
- }
35964
-
35965
- /**
35966
- * Checks if `value` is classified as a typed array.
35967
- *
35968
- * @static
35969
- * @memberOf _
35970
- * @since 3.0.0
35971
- * @category Lang
35972
- * @param {*} value The value to check.
35973
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
35974
- * @example
35975
- *
35976
- * _.isTypedArray(new Uint8Array);
35977
- * // => true
35978
- *
35979
- * _.isTypedArray([]);
35980
- * // => false
35981
- */
35982
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
35983
-
35984
- /**
35985
- * Creates an array of the own enumerable property names of `object`.
35986
- *
35987
- * **Note:** Non-object values are coerced to objects. See the
35988
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
35989
- * for more details.
35990
- *
35991
- * @static
35992
- * @since 0.1.0
35993
- * @memberOf _
35994
- * @category Object
35995
- * @param {Object} object The object to query.
35996
- * @returns {Array} Returns the array of property names.
35997
- * @example
35998
- *
35999
- * function Foo() {
36000
- * this.a = 1;
36001
- * this.b = 2;
36002
- * }
36003
- *
36004
- * Foo.prototype.c = 3;
36005
- *
36006
- * _.keys(new Foo);
36007
- * // => ['a', 'b'] (iteration order is not guaranteed)
36008
- *
36009
- * _.keys('hi');
36010
- * // => ['0', '1']
36011
- */
36012
- function keys(object) {
36013
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
36014
- }
36015
-
36016
- /**
36017
- * This method returns a new empty array.
36018
- *
36019
- * @static
36020
- * @memberOf _
36021
- * @since 4.13.0
36022
- * @category Util
36023
- * @returns {Array} Returns the new empty array.
36024
- * @example
36025
- *
36026
- * var arrays = _.times(2, _.stubArray);
36027
- *
36028
- * console.log(arrays);
36029
- * // => [[], []]
36030
- *
36031
- * console.log(arrays[0] === arrays[1]);
36032
- * // => false
36033
- */
36034
- function stubArray() {
36035
- return [];
36036
- }
36037
-
36038
- /**
36039
- * This method returns `false`.
36040
- *
36041
- * @static
36042
- * @memberOf _
36043
- * @since 4.13.0
36044
- * @category Util
36045
- * @returns {boolean} Returns `false`.
36046
- * @example
36047
- *
36048
- * _.times(2, _.stubFalse);
36049
- * // => [false, false]
36050
- */
36051
- function stubFalse() {
36052
- return false;
36053
- }
36054
-
36055
- module.exports = isEqual;
36056
- });
36057
-
36058
- /**
36059
- * @description i18n en
36060
- * @author wangfupeng
36061
- */
36062
- var enResources$3 = {
36063
- tableModule: {
36064
- deleteCol: 'Delete column',
36065
- deleteRow: 'Delete row',
36066
- deleteTable: 'Delete table',
36067
- widthAuto: 'Width auto',
36068
- insertCol: 'Insert column',
36069
- insertRow: 'Insert row',
36070
- insertTable: 'Insert table',
36071
- header: 'Header',
36072
- },
36073
- };
36074
-
36075
- /**
36076
- * @description i18n zh-CN
36077
- * @author wangfupeng
36078
- */
36079
- var zhResources$3 = {
36080
- tableModule: {
36081
- deleteCol: '删除列',
36082
- deleteRow: '删除行',
36083
- deleteTable: '删除表格',
36084
- widthAuto: '宽度自适应',
36085
- insertCol: '插入列',
36086
- insertRow: '插入行',
36087
- insertTable: '插入表格',
36088
- header: '表头',
36089
- },
36090
- };
36091
-
36092
- /**
36093
- * @description i18n entry
36094
- * @author wangfupeng
36095
- */
36096
- i18nAddResources('en', enResources$3);
36097
- i18nAddResources('zh-CN', zhResources$3);
36098
-
36099
- /******************************************************************************
36100
- Copyright (c) Microsoft Corporation.
36101
-
36102
- Permission to use, copy, modify, and/or distribute this software for any
36103
- purpose with or without fee is hereby granted.
36104
-
36105
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
36106
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36107
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
36108
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
36109
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
36110
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
36111
- PERFORMANCE OF THIS SOFTWARE.
36112
- ***************************************************************************** */
36113
-
36114
- function __values$3(o) {
36115
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
36116
- if (m) return m.call(o);
36117
- if (o && typeof o.length === "number") return {
36118
- next: function () {
36119
- if (o && i >= o.length) o = void 0;
36120
- return { value: o && o[i++], done: !o };
36121
- }
36122
- };
36123
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
36124
- }
36125
-
36126
- function __read$3(o, n) {
36127
- var m = typeof Symbol === "function" && o[Symbol.iterator];
36128
- if (!m) return o;
36129
- var i = m.call(o), r, ar = [], e;
36130
- try {
36131
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
36132
- }
36133
- catch (error) { e = { error: error }; }
36134
- finally {
36135
- try {
36136
- if (r && !r.done && (m = i["return"])) m.call(i);
36137
- }
36138
- finally { if (e) throw e.error; }
36139
- }
36140
- return ar;
36141
- }
36142
-
36143
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
36144
- var e = new Error(message);
36145
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
36146
- };
34620
+ function withSelection(editor) {
34621
+ var apply = editor.apply;
34622
+ editor.apply = function (op) {
34623
+ if (!Operation.isSelectionOperation(op) || !op.newProperties) {
34624
+ // TableCursor.unselect(editor);
34625
+ // 仿飞书效果,拖动单元格宽度时,选区不消失
34626
+ return apply(op);
34627
+ }
34628
+ var selection = __assign$3(__assign$3({}, editor.selection), op.newProperties);
34629
+ if (!Range.isRange(selection)) {
34630
+ TableCursor.unselect(editor);
34631
+ return apply(op);
34632
+ }
34633
+ var _a = __read$3(Editor.nodes(editor, {
34634
+ match: isOfType(editor, 'th', 'td'),
34635
+ at: Range.start(selection),
34636
+ }), 1), fromEntry = _a[0];
34637
+ var _b = __read$3(Editor.nodes(editor, {
34638
+ match: isOfType(editor, 'th', 'td'),
34639
+ at: Range.end(selection),
34640
+ }), 1), toEntry = _b[0];
34641
+ if (!fromEntry || !toEntry) {
34642
+ // TableCursor.unselect(editor)
34643
+ return apply(op);
34644
+ }
34645
+ var _c = __read$3(fromEntry, 2), fromPath = _c[1];
34646
+ var _d = __read$3(toEntry, 2), toPath = _d[1];
34647
+ if (Path.equals(fromPath, toPath) || !hasCommon(editor, [fromPath, toPath], 'table')) {
34648
+ TableCursor.unselect(editor);
34649
+ return apply(op);
34650
+ }
34651
+ // TODO: perf: could be improved by passing a Span [fromPath, toPath]
34652
+ var filled = filledMatrix(editor, { at: fromPath });
34653
+ // find initial bounds
34654
+ var from = Point.valueOf(0, 0);
34655
+ var to = Point.valueOf(0, 0);
34656
+ outer: for (var x = 0; x < filled.length; x++) {
34657
+ for (var y = 0; y < filled[x].length; y++) {
34658
+ var _e = __read$3(filled[x][y], 1), _f = __read$3(_e[0], 2), path = _f[1];
34659
+ if (Path.equals(fromPath, path)) {
34660
+ from.x = x;
34661
+ from.y = y;
34662
+ }
34663
+ if (Path.equals(toPath, path)) {
34664
+ to.x = x;
34665
+ to.y = y;
34666
+ break outer;
34667
+ }
34668
+ }
34669
+ }
34670
+ var start = Point.valueOf(Math.min(from.x, to.x), Math.min(from.y, to.y));
34671
+ var end = Point.valueOf(Math.max(from.x, to.x), Math.max(from.y, to.y));
34672
+ // expand the selection based on rowspan and colspan
34673
+ for (;;) {
34674
+ var nextStart = Point.valueOf(start.x, start.y);
34675
+ var nextEnd = Point.valueOf(end.x, end.y);
34676
+ for (var x = nextStart.x; x <= nextEnd.x; x++) {
34677
+ for (var y = nextStart.y; y <= nextEnd.y; y++) {
34678
+ var _g = __read$3(filled[x][y], 2), _h = _g[1], rtl = _h.rtl, ltr = _h.ltr, btt = _h.btt, ttb = _h.ttb;
34679
+ nextStart.x = Math.min(nextStart.x, x - (ttb - 1));
34680
+ nextStart.y = Math.min(nextStart.y, y - (rtl - 1));
34681
+ nextEnd.x = Math.max(nextEnd.x, x + (btt - 1));
34682
+ nextEnd.y = Math.max(nextEnd.y, y + (ltr - 1));
34683
+ }
34684
+ }
34685
+ if (Point.equals(start, nextStart) && Point.equals(end, nextEnd)) {
34686
+ break;
34687
+ }
34688
+ start = nextStart;
34689
+ end = nextEnd;
34690
+ }
34691
+ var selected = [];
34692
+ var selectedSet = new WeakSet();
34693
+ for (var x = start.x; x <= end.x; x++) {
34694
+ var cells = [];
34695
+ for (var y = start.y; y <= end.y; y++) {
34696
+ var _j = __read$3(filled[x][y], 1), _k = __read$3(_j[0], 1), element = _k[0];
34697
+ selectedSet.add(element);
34698
+ cells.push(filled[x][y]);
34699
+ }
34700
+ selected.push(cells);
34701
+ }
34702
+ EDITOR_TO_SELECTION.set(editor, selected);
34703
+ EDITOR_TO_SELECTION_SET.set(editor, selectedSet);
34704
+ apply(op);
34705
+ };
34706
+ return editor;
34707
+ }
36147
34708
 
36148
34709
  /**
36149
34710
  * @description editor 插件,重写 editor API
@@ -36160,7 +34721,7 @@ function deleteHandler(newEditor) {
36160
34721
  if (cellNodeEntry) {
36161
34722
  var _b = __read$3(cellNodeEntry, 2), cellPath = _b[1];
36162
34723
  var start = Editor.start(newEditor, cellPath);
36163
- if (Point.equals(selection.anchor, start)) {
34724
+ if (Point$1.equals(selection.anchor, start)) {
36164
34725
  return true; // 阻止删除 cell
36165
34726
  }
36166
34727
  }
@@ -36221,9 +34782,9 @@ function withTable(editor) {
36221
34782
  var before = Editor.before(newEditor, selection); // 前一个 location
36222
34783
  if (before) {
36223
34784
  var isTableOnBeforeLocation = isTableLocation(newEditor, before); // before 是否是 table
36224
- var isTableOnCurSelection = isTableLocation(newEditor, selection); // 当前是否是 table
36225
- if (isTableOnBeforeLocation && !isTableOnCurSelection) {
36226
- return; // 如果当前不是 table ,前面是 table ,则不执行删除。否则会删除 table 最后一个 cell
34785
+ // 如果前面是 table, 当前是空 p,则不执行删除。否则会删除 table 最后一个 cell
34786
+ if (isTableOnBeforeLocation && DomEditor.isSelectedEmptyParagraph(newEditor)) {
34787
+ return;
36227
34788
  }
36228
34789
  }
36229
34790
  }
@@ -36334,49 +34895,299 @@ function withTable(editor) {
36334
34895
  };
36335
34896
  newEditor.select(newSelection); // 选中 table-cell 内部的全部文字
36336
34897
  };
34898
+ /**
34899
+ * 光标选区行为新增
34900
+ */
34901
+ withSelection(newEditor);
36337
34902
  // 可继续修改其他 newEditor API ...
36338
34903
  // 返回 editor ,重要!
36339
34904
  return newEditor;
36340
34905
  }
36341
34906
 
36342
34907
  /**
36343
- * @description table menu helpers
34908
+ * @description DOM 操作
36344
34909
  * @author wangfupeng
36345
34910
  */
34911
+ if (append)
34912
+ $.fn.append = append;
34913
+ if (on)
34914
+ $.fn.on = on;
34915
+ if (focus)
34916
+ $.fn.focus = focus;
34917
+ if (attr)
34918
+ $.fn.attr = attr;
34919
+ if (val)
34920
+ $.fn.val = val;
34921
+ if (html)
34922
+ $.fn.html = html;
34923
+ if (dataset)
34924
+ $.fn.dataset = dataset;
34925
+ if (addClass)
34926
+ $.fn.addClass = addClass;
34927
+ if (removeClass)
34928
+ $.fn.removeClass = removeClass;
34929
+ if (children)
34930
+ $.fn.children = children;
34931
+ if (each)
34932
+ $.fn.each = each;
34933
+ if (find)
34934
+ $.fn.find = find;
36346
34935
  /**
36347
- * 获取第一行所有 cells
36348
- * @param tableNode table node
34936
+ * 获取 tagName lower-case
34937
+ * @param $elem $elem
36349
34938
  */
36350
- function getFirstRowCells(tableNode) {
36351
- var rows = tableNode.children || []; // 所有行
36352
- if (rows.length === 0)
36353
- return [];
36354
- var firstRow = rows[0] || {}; // 第一行
36355
- var cells = firstRow.children || []; // 第一行所有 cell
36356
- return cells;
34939
+ function getTagName$1($elem) {
34940
+ if ($elem.length)
34941
+ return $elem[0].tagName.toLowerCase();
34942
+ return '';
36357
34943
  }
36358
34944
  /**
36359
- * 表格是否带有表头?
36360
- * @param tableNode table node
34945
+ * 获取 $elem 某一个 style 值
34946
+ * @param $elem $elem
34947
+ * @param styleKey style key
36361
34948
  */
36362
- function isTableWithHeader(tableNode) {
36363
- var firstRowCells = getFirstRowCells(tableNode);
36364
- return firstRowCells.every(function (cell) { return !!cell.isHeader; });
34949
+ function getStyleValue($elem, styleKey) {
34950
+ var res = '';
34951
+ var styleStr = $elem.attr('style') || ''; // 如 'line-height: 2.5; color: red;'
34952
+ var styleArr = styleStr.split(';'); // 如 ['line-height: 2.5', ' color: red', '']
34953
+ var length = styleArr.length;
34954
+ for (var i = 0; i < length; i++) {
34955
+ var styleItemStr = styleArr[i]; // 如 'line-height: 2.5'
34956
+ if (styleItemStr) {
34957
+ var arr = styleItemStr.split(':'); // ['line-height', ' 2.5']
34958
+ if (arr[0].trim() === styleKey) {
34959
+ res = arr[1].trim();
34960
+ }
34961
+ }
34962
+ }
34963
+ return res;
34964
+ }
34965
+
34966
+ /***
34967
+ * 计算 cell border 距离 table 左侧距离
34968
+ */
34969
+ function getCumulativeWidths(columnWidths) {
34970
+ var e_1, _a;
34971
+ var cumulativeWidths = [];
34972
+ var totalWidth = 0;
34973
+ try {
34974
+ for (var columnWidths_1 = __values$3(columnWidths), columnWidths_1_1 = columnWidths_1.next(); !columnWidths_1_1.done; columnWidths_1_1 = columnWidths_1.next()) {
34975
+ var width = columnWidths_1_1.value;
34976
+ totalWidth += width;
34977
+ cumulativeWidths.push(totalWidth);
34978
+ }
34979
+ }
34980
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
34981
+ finally {
34982
+ try {
34983
+ if (columnWidths_1_1 && !columnWidths_1_1.done && (_a = columnWidths_1.return)) _a.call(columnWidths_1);
34984
+ }
34985
+ finally { if (e_1) throw e_1.error; }
34986
+ }
34987
+ return cumulativeWidths;
34988
+ }
34989
+ /***
34990
+ * 用于计算拖动 cell 时,cell 宽度变化的比例
34991
+ */
34992
+ function getColumnWidthRatios(columnWidths) {
34993
+ var e_2, _a;
34994
+ var columnWidthsRatio = [];
34995
+ var totalWidth = columnWidths.reduce(function (a, b) { return a + b; }, 0);
34996
+ try {
34997
+ for (var columnWidths_2 = __values$3(columnWidths), columnWidths_2_1 = columnWidths_2.next(); !columnWidths_2_1.done; columnWidths_2_1 = columnWidths_2.next()) {
34998
+ var width = columnWidths_2_1.value;
34999
+ columnWidthsRatio.push(width / totalWidth);
35000
+ }
35001
+ }
35002
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
35003
+ finally {
35004
+ try {
35005
+ if (columnWidths_2_1 && !columnWidths_2_1.done && (_a = columnWidths_2.return)) _a.call(columnWidths_2);
35006
+ }
35007
+ finally { if (e_2) throw e_2.error; }
35008
+ }
35009
+ return columnWidthsRatio;
36365
35010
  }
36366
35011
  /**
36367
- * 单元格是否在第一行
36368
- * @param editor editor
36369
- * @param cellNode cell node
35012
+ * 监听 table 内部变化,如新增行、列,删除行列等操作,引起的高度变化。
35013
+ * ResizeObserver 需要即时释放,以免引起内存泄露
35014
+ */
35015
+ var resizeObserver = null;
35016
+ function observerTableResize(editor, elm) {
35017
+ if (elm instanceof HTMLElement) {
35018
+ var table = elm.querySelector('table');
35019
+ if (table) {
35020
+ resizeObserver = new ResizeObserver(function (_a) {
35021
+ var _b = __read$3(_a, 1), contentRect = _b[0].contentRect;
35022
+ // 当非拖动引起的宽度变化,需要调整 columnWidths
35023
+ Transforms.setNodes(editor, {
35024
+ scrollWidth: contentRect.width,
35025
+ height: contentRect.height,
35026
+ }, { mode: 'highest' });
35027
+ });
35028
+ resizeObserver.observe(table);
35029
+ }
35030
+ }
35031
+ }
35032
+ function unObserveTableResize() {
35033
+ if (resizeObserver) {
35034
+ resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
35035
+ resizeObserver = null;
35036
+ }
35037
+ }
35038
+ // 是否为光标选区行为
35039
+ var isSelectionOperation = false;
35040
+ // 拖拽列宽相关信息
35041
+ var isMouseDownForResize = false;
35042
+ var clientXWhenMouseDown = 0;
35043
+ var cellWidthWhenMouseDown = 0;
35044
+ var editorWhenMouseDown = null;
35045
+ var $window = $(window);
35046
+ $window.on('mousedown', onMouseDown);
35047
+ function onMouseDown(event) {
35048
+ var elem = event.target;
35049
+ // 判断是否为光标选区行为,对列宽变更行为进行过滤
35050
+ // console.log('onMouseDown', elem)
35051
+ if (elem.closest('[data-block-type="table-cell"]')) {
35052
+ isSelectionOperation = true;
35053
+ }
35054
+ else if (elem.tagName == 'DIV' && elem.closest('.column-resizer-item')) {
35055
+ if (editorWhenMouseDown == null)
35056
+ return;
35057
+ var _a = __read$3(Editor.nodes(editorWhenMouseDown, {
35058
+ match: isOfType(editorWhenMouseDown, 'table'),
35059
+ }), 1), _b = __read$3(_a[0], 1), elemNode = _b[0];
35060
+ var _c = elemNode, _d = _c.width, tableWidth = _d === void 0 ? 'auto' : _d, _e = _c.columnWidths, columnWidths = _e === void 0 ? [] : _e, _f = _c.resizingIndex, resizingIndex = _f === void 0 ? -1 : _f;
35061
+ /**
35062
+ * table width 为 100% 模式时,因无法增加Table宽度,不触发 列宽变更行为
35063
+ * 如需变更,到底哪个列增宽度,哪个列减去宽度??
35064
+ */
35065
+ if (tableWidth == '100%')
35066
+ return;
35067
+ // 记录必要信息
35068
+ isMouseDownForResize = true;
35069
+ var clientX = event.clientX;
35070
+ clientXWhenMouseDown = clientX;
35071
+ cellWidthWhenMouseDown = columnWidths[resizingIndex];
35072
+ document.body.style.cursor = 'col-resize';
35073
+ event.preventDefault();
35074
+ }
35075
+ $window.on('mousemove', onMouseMove);
35076
+ $window.on('mouseup', onMouseUp);
35077
+ }
35078
+ var onMouseMove = lodash_throttle(function (event) {
35079
+ if (!isMouseDownForResize)
35080
+ return;
35081
+ if (editorWhenMouseDown == null)
35082
+ return;
35083
+ event.preventDefault();
35084
+ var clientX = event.clientX;
35085
+ var newWith = cellWidthWhenMouseDown + (clientX - clientXWhenMouseDown); // 计算新宽度
35086
+ newWith = Math.floor(newWith * 100) / 100; // 保留小数点后两位
35087
+ if (newWith < 30)
35088
+ newWith = 30; // 最小宽度
35089
+ var _a = __read$3(Editor.nodes(editorWhenMouseDown, {
35090
+ match: isOfType(editorWhenMouseDown, 'table'),
35091
+ }), 1), _b = __read$3(_a[0], 1), elemNode = _b[0];
35092
+ var _c = elemNode, _d = _c.columnWidths, columnWidths = _d === void 0 ? [] : _d, _e = _c.resizingIndex, resizingIndex = _e === void 0 ? -1 : _e, _f = _c.scrollWidth, scrollWidth = _f === void 0 ? 0 : _f;
35093
+ /**
35094
+ * 判断拖动引起的宽度是否最大化了
35095
+ * 如果最大化了,则需要调整列的宽度
35096
+ *
35097
+ * 0.5 很微妙
35098
+ */
35099
+ var cumulativeTotalWidth = columnWidths.reduce(function (a, b) { return a + b; }, 0);
35100
+ var remainWidth = cumulativeTotalWidth - columnWidths[resizingIndex];
35101
+ if (cumulativeTotalWidth > scrollWidth && remainWidth + newWith > scrollWidth) {
35102
+ newWith = scrollWidth - remainWidth + 0.5;
35103
+ }
35104
+ var adjustColumnWidths = __spreadArray([], __read$3(columnWidths)).map(function (width) { return Math.floor(width); });
35105
+ adjustColumnWidths[resizingIndex] = newWith;
35106
+ // 这是宽度
35107
+ Transforms.setNodes(editorWhenMouseDown, { columnWidths: adjustColumnWidths }, {
35108
+ mode: 'highest',
35109
+ });
35110
+ }, 100);
35111
+ function onMouseUp(event) {
35112
+ isSelectionOperation = false;
35113
+ isMouseDownForResize = false;
35114
+ editorWhenMouseDown = null;
35115
+ document.body.style.cursor = '';
35116
+ // 解绑事件
35117
+ $window.off('mousemove', onMouseMove);
35118
+ $window.off('mouseup', onMouseUp);
35119
+ }
35120
+ /**
35121
+ * 鼠标移动时,判断在哪个 Cell border 上
35122
+ * Class 先 visible 后 highlight @跟随飞书
35123
+ * 避免光标选区功能收到干扰
36370
35124
  */
36371
- function isCellInFirstRow(editor, cellNode) {
36372
- var rowNode = DomEditor.getParentNode(editor, cellNode);
36373
- if (rowNode == null)
36374
- return false;
36375
- var tableNode = DomEditor.getParentNode(editor, rowNode);
36376
- if (tableNode == null)
36377
- return false;
36378
- var firstRowCells = getFirstRowCells(tableNode);
36379
- return firstRowCells.some(function (c) { return c === cellNode; });
35125
+ function handleCellBorderVisible(editor, elemNode, e) {
35126
+ if (editor.isDisabled())
35127
+ return;
35128
+ if (isSelectionOperation || isMouseDownForResize)
35129
+ return;
35130
+ var _a = elemNode, _b = _a.width, tableWidth = _b === void 0 ? 'auto' : _b, _c = _a.columnWidths, columnWidths = _c === void 0 ? [] : _c, isHoverCellBorder = _a.isHoverCellBorder, resizingIndex = _a.resizingIndex;
35131
+ /**
35132
+ * table width 为 100% 模式时,因无法增加Table宽度,不触发 列宽变更行为
35133
+ * 如需变更,到底哪个列增宽度,哪个列减去宽度??
35134
+ */
35135
+ if (tableWidth == '100%')
35136
+ return;
35137
+ // Cell Border 宽度为 10px
35138
+ var clientX = e.clientX, target = e.target;
35139
+ // 当单元格合并的时候,鼠标在 cell 中间,则不显示 cell border
35140
+ if (target instanceof HTMLElement) {
35141
+ var rect = target.getBoundingClientRect();
35142
+ if (clientX > rect.x + 5 && clientX < rect.x + rect.width - 5) {
35143
+ if (isHoverCellBorder) {
35144
+ Transforms.setNodes(editor, { isHoverCellBorder: false, resizingIndex: -1 }, { mode: 'highest' });
35145
+ }
35146
+ return;
35147
+ }
35148
+ }
35149
+ if (target instanceof HTMLElement) {
35150
+ var parent_1 = target.closest('.table');
35151
+ if (parent_1) {
35152
+ var clientX_1 = e.clientX;
35153
+ var rect = parent_1.getBoundingClientRect();
35154
+ var cumulativeWidths = getCumulativeWidths(columnWidths);
35155
+ // 鼠标移动时,计算当前鼠标位置,判断在哪个 Cell border 上
35156
+ for (var i = 0; i < cumulativeWidths.length; i++) {
35157
+ if (clientX_1 - rect.x >= cumulativeWidths[i] - 5 &&
35158
+ clientX_1 - rect.x < cumulativeWidths[i] + 5) {
35159
+ // 节流,防止多次引起Transforms.setNodes重绘
35160
+ if (resizingIndex == i)
35161
+ return;
35162
+ Transforms.setNodes(editor, { isHoverCellBorder: true, resizingIndex: i }, { mode: 'highest' });
35163
+ return;
35164
+ }
35165
+ }
35166
+ }
35167
+ }
35168
+ // 鼠标移出时,重置
35169
+ if (isHoverCellBorder == true) {
35170
+ Transforms.setNodes(editor, { isHoverCellBorder: false, resizingIndex: -1 }, {
35171
+ mode: 'highest',
35172
+ });
35173
+ }
35174
+ }
35175
+ /**
35176
+ * 设置 class highlight
35177
+ * 将 render-cell.tsx 拖动功能迁移至 div.column-resize
35178
+ */
35179
+ function handleCellBorderHighlight(editor, e) {
35180
+ if (e.type === 'mouseenter') {
35181
+ Transforms.setNodes(editor, { isResizing: true }, { mode: 'highest' });
35182
+ }
35183
+ else {
35184
+ Transforms.setNodes(editor, { isResizing: false }, { mode: 'highest' });
35185
+ }
35186
+ }
35187
+ function handleCellBorderMouseDown(editor, elemNode) {
35188
+ if (isMouseDownForResize)
35189
+ return; // 此时正在修改列宽
35190
+ editorWhenMouseDown = editor;
36380
35191
  }
36381
35192
 
36382
35193
  /**
@@ -36400,8 +35211,8 @@ function getContentEditable(editor, tableElem) {
36400
35211
  var tablePath = DomEditor.findPath(editor, tableElem);
36401
35212
  var tableStart = Editor.start(editor, tablePath);
36402
35213
  var tableEnd = Editor.end(editor, tablePath);
36403
- var isAnchorInTable = Point.compare(anchor, tableEnd) <= 0 && Point.compare(anchor, tableStart) >= 0;
36404
- var isFocusInTable = Point.compare(focus, tableEnd) <= 0 && Point.compare(focus, tableStart) >= 0;
35214
+ var isAnchorInTable = Point$1.compare(anchor, tableEnd) <= 0 && Point$1.compare(anchor, tableStart) >= 0;
35215
+ var isFocusInTable = Point$1.compare(focus, tableEnd) <= 0 && Point$1.compare(focus, tableStart) >= 0;
36405
35216
  // 选区在 table 内部,且选中了同一个单元格。表格可以编辑
36406
35217
  if (isAnchorInTable && isFocusInTable) {
36407
35218
  if (Path.equals(anchor.path.slice(0, 3), focus.path.slice(0, 3))) {
@@ -36414,11 +35225,13 @@ function renderTable(elemNode, children, editor) {
36414
35225
  // 是否可编辑
36415
35226
  var editable = getContentEditable(editor, elemNode);
36416
35227
  // 宽度
36417
- var _a = elemNode.width, width = _a === void 0 ? 'auto' : _a;
36418
- // 是否选中
35228
+ var _a = elemNode, _b = _a.width, tableWidth = _b === void 0 ? 'auto' : _b, height = _a.height, _c = _a.columnWidths, columnWidths = _c === void 0 ? [] : _c, _d = _a.scrollWidth, scrollWidth = _d === void 0 ? 0 : _d, isHoverCellBorder = _a.isHoverCellBorder, resizingIndex = _a.resizingIndex, isResizing = _a.isResizing;
35229
+ // 光标是否选中
36419
35230
  var selected = DomEditor.isNodeSelected(editor, elemNode);
36420
- // 第一行的 cells ,以计算列宽
36421
- var firstRowCells = getFirstRowCells(elemNode);
35231
+ // 光标是否有选区
35232
+ var _e = __read$3(TableCursor.selection(editor), 1), isSelecting = _e[0];
35233
+ // 列宽之间比值
35234
+ var columnWidthRatios = getColumnWidthRatios(columnWidths);
36422
35235
  var vnode = (jsx("div", { className: "table-container", "data-selected": selected, on: {
36423
35236
  mousedown: function (e) {
36424
35237
  // @ts-ignore 阻止光标定位到 table 后面
@@ -36426,6 +35239,10 @@ function renderTable(elemNode, children, editor) {
36426
35239
  e.preventDefault();
36427
35240
  if (editor.isDisabled())
36428
35241
  return;
35242
+ // @ts-ignore 如果用户行为是获取焦点输入文本时,需释放选区
35243
+ if (e.target.closest('[data-block-type="table-cell"]')) {
35244
+ TableCursor.unselect(editor);
35245
+ }
36429
35246
  // 是否需要定位到 table 内部
36430
35247
  var tablePath = DomEditor.findPath(editor, elemNode);
36431
35248
  var tableStart = Editor.start(editor, tablePath);
@@ -36440,13 +35257,64 @@ function renderTable(elemNode, children, editor) {
36440
35257
  editor.select(tableStart); // 选中 table 内部
36441
35258
  },
36442
35259
  } },
36443
- jsx("table", { width: width, contentEditable: editable },
36444
- jsx("colgroup", { contentEditable: false }, firstRowCells.map(function (cell) {
36445
- var _a = cell.width, width = _a === void 0 ? 'auto' : _a;
35260
+ jsx("table", { width: tableWidth, contentEditable: editable,
35261
+ /**
35262
+ * 1. 当表格处于选区状态,屏蔽 Chrome 自带的样式
35263
+ * 2. table 宽度为 auto 时,宽度为 列宽之和
35264
+ * 3. 鼠标移动到 单元格 边缘,设置 visible className
35265
+ */
35266
+ className: 'table ' + (isSelecting ? 'table-selection-none' : ''), style: {
35267
+ width: tableWidth == '100%' ? '' : columnWidths.reduce(function (a, b) { return a + b; }, 0) + 'px',
35268
+ }, on: {
35269
+ mousemove: lodash_debounce(function (e) { return handleCellBorderVisible(editor, elemNode, e); }, 25),
35270
+ } },
35271
+ jsx("colgroup", { contentEditable: false },
35272
+ /**
35273
+ * 剔除 firstRowCells,因单元格合并 表头 th,会计算错误。
35274
+ * 使用 columnWidth 数组长度代表列数
35275
+ * 拖动行为及变量设置均参考 飞书
35276
+ */
35277
+ columnWidths.map(function (width) {
36446
35278
  return jsx("col", { width: width });
36447
35279
  })),
36448
- jsx("tbody", null, children))));
36449
- return vnode;
35280
+ jsx("tbody", null, children)),
35281
+ jsx("div", { className: "column-resizer", contenteditable: "false" }, columnWidths.map(function (width, index) {
35282
+ var minWidth = width;
35283
+ /**
35284
+ * table width 为 100% 模式时
35285
+ * columnWidths 表示的是比例
35286
+ * 1. 需要计算出真实的宽度
35287
+ */
35288
+ if (tableWidth == '100%') {
35289
+ minWidth = columnWidthRatios[index] * scrollWidth;
35290
+ }
35291
+ return (jsx("div", { className: "column-resizer-item", style: { minWidth: minWidth + "px" } },
35292
+ jsx("div", { className: 'resizer-line-hotzone ' +
35293
+ (isHoverCellBorder && index == resizingIndex ? 'visible ' : '') +
35294
+ (isResizing && index == resizingIndex ? 'highlight' : ''), style: { height: height + 'px' }, on: {
35295
+ mouseenter: function (e) { return handleCellBorderHighlight(editor, e); },
35296
+ mouseleave: function (e) { return handleCellBorderHighlight(editor, e); },
35297
+ mousedown: function (e) { return handleCellBorderMouseDown(editor); },
35298
+ } },
35299
+ jsx("div", { className: "resizer-line" }))));
35300
+ }))));
35301
+ /**
35302
+ * 移出直接返回 vnode
35303
+ * 添加 ObserverResize 监听行为
35304
+ * 监听 table 内部变化,更新 table resize-bar 高度
35305
+ */
35306
+ var containerVnode = h('div', {
35307
+ hook: {
35308
+ insert: function (_a) {
35309
+ var elm = _a.elm;
35310
+ return observerTableResize(editor, elm);
35311
+ },
35312
+ destroy: function () {
35313
+ unObserveTableResize();
35314
+ },
35315
+ },
35316
+ }, vnode);
35317
+ return containerVnode;
36450
35318
  }
36451
35319
 
36452
35320
  /**
@@ -36459,154 +35327,60 @@ function renderTableRow(elemNode, children, editor) {
36459
35327
  }
36460
35328
 
36461
35329
  /**
36462
- * @description DOM 操作
35330
+ * @description table menu helpers
36463
35331
  * @author wangfupeng
36464
35332
  */
36465
- if (append)
36466
- $.fn.append = append;
36467
- if (on)
36468
- $.fn.on = on;
36469
- if (focus)
36470
- $.fn.focus = focus;
36471
- if (attr)
36472
- $.fn.attr = attr;
36473
- if (val)
36474
- $.fn.val = val;
36475
- if (html)
36476
- $.fn.html = html;
36477
- if (dataset)
36478
- $.fn.dataset = dataset;
36479
- if (addClass)
36480
- $.fn.addClass = addClass;
36481
- if (removeClass)
36482
- $.fn.removeClass = removeClass;
36483
- if (children)
36484
- $.fn.children = children;
36485
- if (each)
36486
- $.fn.each = each;
36487
- if (find)
36488
- $.fn.find = find;
36489
35333
  /**
36490
- * 获取 tagName lower-case
36491
- * @param $elem $elem
35334
+ * 获取第一行所有 cells
35335
+ * @param tableNode table node
36492
35336
  */
36493
- function getTagName$1($elem) {
36494
- if ($elem.length)
36495
- return $elem[0].tagName.toLowerCase();
36496
- return '';
35337
+ function getFirstRowCells(tableNode) {
35338
+ var rows = tableNode.children || []; // 所有行
35339
+ if (rows.length === 0)
35340
+ return [];
35341
+ var firstRow = rows[0] || {}; // 第一行
35342
+ var cells = firstRow.children || []; // 第一行所有 cell
35343
+ return cells;
36497
35344
  }
36498
35345
  /**
36499
- * 获取 $elem 某一个 style 值
36500
- * @param $elem $elem
36501
- * @param styleKey style key
35346
+ * 表格是否带有表头?
35347
+ * @param tableNode table node
36502
35348
  */
36503
- function getStyleValue($elem, styleKey) {
36504
- var res = '';
36505
- var styleStr = $elem.attr('style') || ''; // 如 'line-height: 2.5; color: red;'
36506
- var styleArr = styleStr.split(';'); // 如 ['line-height: 2.5', ' color: red', '']
36507
- var length = styleArr.length;
36508
- for (var i = 0; i < length; i++) {
36509
- var styleItemStr = styleArr[i]; // 如 'line-height: 2.5'
36510
- if (styleItemStr) {
36511
- var arr = styleItemStr.split(':'); // ['line-height', ' 2.5']
36512
- if (arr[0].trim() === styleKey) {
36513
- res = arr[1].trim();
36514
- }
36515
- }
36516
- }
36517
- return res;
35349
+ function isTableWithHeader(tableNode) {
35350
+ var firstRowCells = getFirstRowCells(tableNode);
35351
+ return firstRowCells.every(function (cell) { return !!cell.isHeader; });
35352
+ }
35353
+ /**
35354
+ * 单元格是否在第一行
35355
+ * @param editor editor
35356
+ * @param cellNode cell node
35357
+ */
35358
+ function isCellInFirstRow(editor, cellNode) {
35359
+ var rowNode = DomEditor.getParentNode(editor, cellNode);
35360
+ if (rowNode == null)
35361
+ return false;
35362
+ var tableNode = DomEditor.getParentNode(editor, rowNode);
35363
+ if (tableNode == null)
35364
+ return false;
35365
+ var firstRowCells = getFirstRowCells(tableNode);
35366
+ return firstRowCells.some(function (c) { return c === cellNode; });
36518
35367
  }
36519
35368
 
36520
35369
  /**
36521
35370
  * @description render cell
36522
35371
  * @author wangfupeng
36523
35372
  */
36524
- // 拖拽列宽相关信息
36525
- var isMouseDownForResize = false;
36526
- var clientXWhenMouseDown = 0;
36527
- var cellWidthWhenMouseDown = 0;
36528
- var cellPathWhenMouseDown = null;
36529
- var editorWhenMouseDown = null;
36530
- var $body = $('body');
36531
- function onMouseDown(event) {
36532
- var elem = event.target;
36533
- if (elem.tagName !== 'TH' && elem.tagName !== 'TD')
36534
- return;
36535
- if (elem.style.cursor !== 'col-resize')
36536
- return;
36537
- elem.style.cursor = 'auto';
36538
- event.preventDefault();
36539
- // 记录必要信息
36540
- isMouseDownForResize = true;
36541
- var clientX = event.clientX;
36542
- clientXWhenMouseDown = clientX;
36543
- var width = elem.getBoundingClientRect().width;
36544
- cellWidthWhenMouseDown = width;
36545
- // 绑定事件
36546
- $body.on('mousemove', onMouseMove);
36547
- $body.on('mouseup', onMouseUp);
36548
- }
36549
- $body.on('mousedown', onMouseDown); // 绑定事件
36550
- function onMouseUp(event) {
36551
- isMouseDownForResize = false;
36552
- editorWhenMouseDown = null;
36553
- cellPathWhenMouseDown = null;
36554
- // 解绑事件
36555
- $body.off('mousemove', onMouseMove);
36556
- $body.off('mouseup', onMouseUp);
36557
- }
36558
- var onMouseMove = lodash_throttle(function (event) {
36559
- if (!isMouseDownForResize)
36560
- return;
36561
- if (editorWhenMouseDown == null || cellPathWhenMouseDown == null)
36562
- return;
36563
- event.preventDefault();
36564
- var clientX = event.clientX;
36565
- var newWith = cellWidthWhenMouseDown + (clientX - clientXWhenMouseDown); // 计算新宽度
36566
- newWith = Math.floor(newWith * 100) / 100; // 保留小数点后两位
36567
- if (newWith < 30)
36568
- newWith = 30; // 最小宽度
36569
- // 这是宽度
36570
- Transforms.setNodes(editorWhenMouseDown, { width: newWith.toString() }, {
36571
- at: cellPathWhenMouseDown,
36572
- });
36573
- }, 100);
36574
35373
  function renderTableCell(cellNode, children, editor) {
36575
35374
  var isFirstRow = isCellInFirstRow(editor, cellNode);
36576
- var _a = cellNode, _b = _a.colSpan, colSpan = _b === void 0 ? 1 : _b, _c = _a.rowSpan, rowSpan = _c === void 0 ? 1 : _c, _d = _a.isHeader, isHeader = _d === void 0 ? false : _d;
35375
+ var _a = cellNode, _b = _a.colSpan, colSpan = _b === void 0 ? 1 : _b, _c = _a.rowSpan, rowSpan = _c === void 0 ? 1 : _c, _d = _a.isHeader, isHeader = _d === void 0 ? false : _d, _e = _a.hidden, hidden = _e === void 0 ? false : _e;
35376
+ var selected = TableCursor.isSelected(editor, cellNode);
36577
35377
  // ------------------ 不是第一行,直接渲染 <td> ------------------
36578
35378
  if (!isFirstRow) {
36579
- return (jsx("td", { colSpan: colSpan, rowSpan: rowSpan }, children));
35379
+ return (jsx("td", { colSpan: colSpan, rowSpan: rowSpan, "data-block-type": "table-cell", className: selected ? 'w-e-selected' : '', style: { display: hidden ? 'none' : '' } }, children));
36580
35380
  }
36581
35381
  // ------------------ 是第一行:1. 判断 th ;2. 拖拽列宽 ------------------
36582
35382
  var Tag = isHeader ? 'th' : 'td';
36583
- var vnode = (jsx(Tag, { colSpan: colSpan, rowSpan: rowSpan, style: { borderRightWidth: '3px' }, on: {
36584
- mousemove: lodash_throttle(function (event) {
36585
- var elem = this.elm;
36586
- if (elem == null)
36587
- return;
36588
- var _a = elem.getBoundingClientRect(), left = _a.left, width = _a.width, top = _a.top, height = _a.height;
36589
- var clientX = event.clientX, clientY = event.clientY;
36590
- if (isMouseDownForResize)
36591
- return; // 此时正在修改列宽
36592
- // 非 mousedown 状态,计算 cursor 样式
36593
- var matchX = clientX > left + width - 5 && clientX < left + width; // X 轴,是否接近 cell 右侧?
36594
- var matchY = clientY > top && clientY < top + height; // Y 轴,是否在 cell 之内
36595
- // X Y 轴都接近,则修改鼠标样式
36596
- if (matchX && matchY) {
36597
- elem.style.cursor = 'col-resize';
36598
- editorWhenMouseDown = editor;
36599
- cellPathWhenMouseDown = DomEditor.findPath(editor, cellNode);
36600
- }
36601
- else {
36602
- if (!isMouseDownForResize) {
36603
- elem.style.cursor = 'auto';
36604
- editorWhenMouseDown = null;
36605
- cellPathWhenMouseDown = null;
36606
- }
36607
- }
36608
- }, 100),
36609
- } }, children));
35383
+ var vnode = (jsx(Tag, { colSpan: colSpan, rowSpan: rowSpan, "data-block-type": "table-cell", className: selected ? 'w-e-selected' : '', style: { display: hidden ? 'none' : '' } }, children));
36610
35384
  return vnode;
36611
35385
  }
36612
35386
 
@@ -36633,15 +35407,16 @@ var renderTableCellConf = {
36633
35407
  */
36634
35408
  function tableToHtml(elemNode, childrenHtml) {
36635
35409
  var _a = elemNode.width, width = _a === void 0 ? 'auto' : _a;
36636
- return "<table style=\"width: " + width + ";\"><tbody>" + childrenHtml + "</tbody></table>";
35410
+ return "<table style=\"width: " + width + ";table-layout: fixed;\"><tbody>" + childrenHtml + "</tbody></table>";
36637
35411
  }
36638
35412
  function tableRowToHtml(elem, childrenHtml) {
36639
35413
  return "<tr>" + childrenHtml + "</tr>";
36640
35414
  }
36641
35415
  function tableCellToHtml(cellNode, childrenHtml) {
36642
- var _a = cellNode, _b = _a.colSpan, colSpan = _b === void 0 ? 1 : _b, _c = _a.rowSpan, rowSpan = _c === void 0 ? 1 : _c, _d = _a.isHeader, isHeader = _d === void 0 ? false : _d, _e = _a.width, width = _e === void 0 ? 'auto' : _e;
35416
+ var _a = cellNode, _b = _a.colSpan, colSpan = _b === void 0 ? 1 : _b, _c = _a.rowSpan, rowSpan = _c === void 0 ? 1 : _c, _d = _a.isHeader, isHeader = _d === void 0 ? false : _d, _e = _a.width, width = _e === void 0 ? 'auto' : _e, _f = _a.hidden, hidden = _f === void 0 ? false : _f;
36643
35417
  var tag = isHeader ? 'th' : 'td';
36644
- return "<" + tag + " colSpan=\"" + colSpan + "\" rowSpan=\"" + rowSpan + "\" width=\"" + width + "\">" + childrenHtml + "</" + tag + ">";
35418
+ var style = hidden ? 'display:none' : '';
35419
+ return "<" + tag + " colSpan=\"" + colSpan + "\" rowSpan=\"" + rowSpan + "\" width=\"" + width + "\" style=\"" + style + "\">" + childrenHtml + "</" + tag + ">";
36645
35420
  }
36646
35421
  var tableToHtmlConf = {
36647
35422
  type: 'table',
@@ -36730,6 +35505,7 @@ var parseRowHtmlConf = {
36730
35505
  parseElemHtml: parseRowHtml,
36731
35506
  };
36732
35507
  function parseTableHtml(elem, children, editor) {
35508
+ var _a;
36733
35509
  var $elem = $(elem);
36734
35510
  // 计算宽度
36735
35511
  var width = 'auto';
@@ -36737,12 +35513,17 @@ function parseTableHtml(elem, children, editor) {
36737
35513
  width = '100%';
36738
35514
  if ($elem.attr('width') === '100%')
36739
35515
  width = '100%'; // 兼容 v4 格式
36740
- return {
35516
+ var tableELement = {
36741
35517
  type: 'table',
36742
35518
  width: width,
36743
35519
  // @ts-ignore
36744
35520
  children: children.filter(function (child) { return DomEditor.getNodeType(child) === 'table-row'; }),
36745
35521
  };
35522
+ var cellLength = (_a = $elem.find('tr')[0]) === null || _a === void 0 ? void 0 : _a.children.length;
35523
+ if (cellLength > 0) {
35524
+ tableELement.columnWidths = Array(cellLength).fill(180);
35525
+ }
35526
+ return tableELement;
36746
35527
  }
36747
35528
  var parseTableHtmlConf = {
36748
35529
  selector: 'table:not([data-w-e-type])',
@@ -36773,7 +35554,11 @@ var DEL_COL_SVG = '<svg viewBox="0 0 1048 1024"><path d="M327.68 510.976L393.216
36773
35554
  // 表头
36774
35555
  var TABLE_HEADER_SVG = '<svg viewBox="0 0 1024 1024"><path d="M704 128l-64 0L384 128 320 128 0 128l0 256 0 64 0 192 0 64 0 256 320 0 64 0 256 0 64 0 320 0 0-256 0-64L1024 448 1024 384 1024 128 704 128zM640 640 384 640 384 448l256 0L640 640zM64 448l256 0 0 192L64 640 64 448zM320 896 64 896l0-192 256 0L320 896zM640 896 384 896l0-192 256 0L640 896zM960 896l-256 0 0-192 256 0L960 896zM960 640l-256 0L704 448l256 0L960 640z"></path></svg>';
36775
35556
  // 宽度
36776
- var FULL_WIDTH_SVG = '<svg viewBox="0 0 1228 1024"><path d="M862.514337 563.200461H404.581995v121.753478a13.311987 13.311987 0 0 1-6.655993 11.468789 10.23999 10.23999 0 0 1-12.083188-1.433599l-204.799795-179.199821a13.721586 13.721586 0 0 1 0-20.479979l204.799795-179.302221a10.23999 10.23999 0 0 1 12.185588-1.535998 13.209587 13.209587 0 0 1 6.553593 11.673588v115.097485h457.932342V319.693504a11.571188 11.571188 0 0 1 18.841582-10.239989l204.799795 179.19982a13.721586 13.721586 0 0 1 0 20.47998l-204.799795 179.199821a10.23999 10.23999 0 0 1-12.185588 1.535998 13.311987 13.311987 0 0 1-6.655994-11.571188V563.200461zM136.499064 14.951409v993.893406a15.257585 15.257585 0 0 1-15.155185 15.052785H15.155185A15.155185 15.155185 0 0 1 0 1008.844815V14.951409a15.257585 15.257585 0 0 1 15.155185-15.052785h106.086294a15.155185 15.155185 0 0 1 15.257585 15.155185zM1228.798771 14.951409v993.893406a15.257585 15.257585 0 0 1-15.155185 15.052785h-106.188693a15.155185 15.155185 0 0 1-15.155185-15.052785V14.951409a15.257585 15.257585 0 0 1 15.155185-15.052785h106.086293A15.155185 15.155185 0 0 1 1228.798771 15.053809z"></path></svg>';
35557
+ var FULL_WIDTH_SVG = '<svg viewBox="0 0 1228 1024"><path d="M862.514337 563.200461H404.581995v121.753478a13.311987 13.311987 0 0 1-6.655993 11.468789 10.23999 10.23999 0 0 1-12.083188-1.433599l-204.799795-179.199821a13.721586 13.721586 0 0 1 0-20.479979l204.799795-179.302221a10.23999 10.23999 0 0 1 12.185588-1.535998 13.209587 13.209587 0 0 1 6.553593 11.673588v115.097485h457.932342V319.693504a11.571188 11.571188 0 0 1 18.841582-10.239989l204.799795 179.19982a13.721586 13.721586 0 0 1 0 20.47998l-204.799795 179.199821a10.23999 10.23999 0 0 1-12.185588 1.535998 13.311987 13.311987 0 0 1-6.655994-11.571188V563.200461zM136.499064 14.951409v993.893406a15.257585 15.257585 0 0 1-15.155185 15.052785H15.155185A15.155185 15.155185 0 0 1 0 1008.844815V14.951409a15.257585 15.257585 0 0 1 15.155185-15.052785h106.086294a15.155185 15.155185 0 0 1 15.257585 15.155185zM1228.798771 14.951409v993.893406a15.257585 15.257585 0 0 1-15.155185 15.052785h-106.188693a15.155185 15.155185 0 0 1-15.155185-15.052785V14.951409a15.257585 15.257585 0 0 1 15.155185-15.052785h106.086293A15.155185 15.155185 0 0 1 1228.798771 15.053809z"></path></svg>';
35558
+ // 合并单元格
35559
+ var MERGE_CELL_SVG = '<svg viewBox="0 0 1024 1024"><path d="M482.2 508.4 331.3 389c-3-2.4-7.3-.2-7.3 3.6V478H184V184h204v128c0 2.2 1.8 4 4 4h60c2.2 0 4-1.8 4-4V144c0-15.5-12.5-28-28-28H144c-15.5 0-28 12.5-28 28v736c0 15.5 12.5 28 28 28h284c15.5 0 28-12.5 28-28V712c0-2.2-1.8-4-4-4h-60c-2.2 0-4 1.8-4 4v128H184V546h140v85.4c0 3.8 4.4 6 7.3 3.6l150.9-119.4c2.4-1.8 2.4-5.4 0-7.2zM880 116H596c-15.5 0-28 12.5-28 28v168c0 2.2 1.8 4 4 4h60c2.2 0 4-1.8 4-4V184h204v294H700v-85.4c0-3.8-4.3-6-7.3-3.6l-151 119.4c-2.3 1.8-2.3 5.3 0 7.1l151 119.5c2.9 2.3 7.3.2 7.3-3.6V546h140v294H636V712c0-2.2-1.8-4-4-4h-60c-2.2 0-4 1.8-4 4v168c0 15.5 12.5 28 28 28h284c15.5 0 28-12.5 28-28V144c0-15.5-12.5-28-28-28z"/></svg>';
35560
+ // 拆分单元格
35561
+ var SPLIT_CELL_SVG = '<svg viewBox="0 0 1024 1024"><path d="M362.667 494.933v53.334l25.6-25.6zm0-241.066L460.8 352V78.933H57.6v98.134h305.067zm0 535.466v57.6H57.6v98.134h403.2V691.2zM661.333 494.933v53.334l-25.6-25.6zm0-241.066L563.2 352V78.933h403.2v98.134H661.333zm0 535.466v57.6H966.4v98.134H563.2V691.2z"/><path d="M753.067 341.333 693.333 281.6 512 460.8 330.667 281.6l-59.734 59.733 181.334 181.334L270.933 704l59.734 59.733L512 582.4l181.333 181.333L753.067 704 571.733 522.667z"/></svg>';
36777
35562
 
36778
35563
  /**
36779
35564
  * @description insert table menu
@@ -36782,6 +35567,7 @@ var FULL_WIDTH_SVG = '<svg viewBox="0 0 1228 1024"><path d="M862.514337 563.2004
36782
35567
  function genTableNode(rowNum, colNum) {
36783
35568
  // 拼接 rows
36784
35569
  var rows = [];
35570
+ var columnWidths = Array(colNum).fill(60);
36785
35571
  for (var i = 0; i < rowNum; i++) {
36786
35572
  // 拼接 cells
36787
35573
  var cells = [];
@@ -36805,6 +35591,7 @@ function genTableNode(rowNum, colNum) {
36805
35591
  type: 'table',
36806
35592
  width: 'auto',
36807
35593
  children: rows,
35594
+ columnWidths: columnWidths,
36808
35595
  };
36809
35596
  }
36810
35597
  var InsertTable = /** @class */ (function () {
@@ -36926,6 +35713,12 @@ var InsertTable = /** @class */ (function () {
36926
35713
  if (DomEditor.isSelectedEmptyParagraph(editor)) {
36927
35714
  Transforms.removeNodes(editor, { mode: 'highest' });
36928
35715
  }
35716
+ if (editor.children.length === 0) {
35717
+ // table 作为第一个 children 时会导致无法正常删除
35718
+ // 在当前位置插入空行,当前元素下移
35719
+ var newElem = { type: 'paragraph', children: [{ text: '' }] };
35720
+ Transforms.insertNodes(editor, newElem, { mode: 'highest' });
35721
+ }
36929
35722
  // 插入表格
36930
35723
  var tableNode = genTableNode(rowNum, colNum);
36931
35724
  Transforms.insertNodes(editor, tableNode, { mode: 'highest' });
@@ -37014,19 +35807,56 @@ var InsertRow = /** @class */ (function () {
37014
35807
  var cellsLength = (rowNode === null || rowNode === void 0 ? void 0 : rowNode.children.length) || 0;
37015
35808
  if (cellsLength === 0)
37016
35809
  return;
37017
- // 拼接新的 row
37018
- var newRow = { type: 'table-row', children: [] };
37019
- for (var i = 0; i < cellsLength; i++) {
37020
- var cell = {
37021
- type: 'table-cell',
37022
- children: [{ text: '' }],
37023
- };
37024
- newRow.children.push(cell);
35810
+ var matrix = filledMatrix(editor);
35811
+ // 向下插入行为,先找到
35812
+ // 当前选区所在的 tr 索引
35813
+ var trIndex = 0;
35814
+ outer: for (var x = 0; x < matrix.length; x++) {
35815
+ for (var y = 0; y < matrix[x].length; y++) {
35816
+ var _c = __read$3(matrix[x][y], 1), _d = __read$3(_c[0], 2), path = _d[1];
35817
+ if (!Path.equals(cellPath, path)) {
35818
+ continue;
35819
+ }
35820
+ trIndex = x;
35821
+ break outer;
35822
+ }
37025
35823
  }
37026
- // 插入 row
37027
- var rowPath = Path.parent(cellPath); // 获取 tr 的 path
37028
- var newRowPath = Path.next(rowPath);
37029
- Transforms.insertNodes(editor, newRow, { at: newRowPath });
35824
+ Editor.withoutNormalizing(editor, function () {
35825
+ // 向下添加 tr 索引
35826
+ var destIndex = trIndex + 1;
35827
+ var isWithinBounds = destIndex >= 0 && destIndex < matrix.length;
35828
+ var exitMerge = [];
35829
+ for (var y = 0; isWithinBounds && y < matrix[trIndex].length; y++) {
35830
+ var _a = __read$3(matrix[trIndex][y], 2), _b = _a[1], ttb = _b.ttb, btt = _b.btt;
35831
+ // 向上找到 1 元素为止
35832
+ if (ttb > 1 || btt > 1) {
35833
+ if (btt == 1)
35834
+ continue;
35835
+ var _c = __read$3(matrix[trIndex - (ttb - 1)][y], 1), _d = __read$3(_c[0], 2), element = _d[0], path = _d[1];
35836
+ var rowSpan = element.rowSpan || 1;
35837
+ exitMerge.push(y);
35838
+ if (!element.hidden) {
35839
+ Transforms.setNodes(editor, {
35840
+ rowSpan: rowSpan + 1,
35841
+ }, { at: path });
35842
+ }
35843
+ }
35844
+ }
35845
+ // 拼接新的 row
35846
+ var newRow = { type: 'table-row', children: [] };
35847
+ for (var i = 0; i < cellsLength; i++) {
35848
+ var cell = {
35849
+ type: 'table-cell',
35850
+ hidden: exitMerge.includes(i),
35851
+ children: [{ text: '' }],
35852
+ };
35853
+ newRow.children.push(cell);
35854
+ }
35855
+ // 插入 row
35856
+ var rowPath = Path.parent(cellPath); // 获取 tr 的 path
35857
+ var newRowPath = Path.next(rowPath);
35858
+ Transforms.insertNodes(editor, newRow, { at: newRowPath });
35859
+ });
37030
35860
  };
37031
35861
  return InsertRow;
37032
35862
  }());
@@ -37078,7 +35908,67 @@ var DeleteRow = /** @class */ (function () {
37078
35908
  return;
37079
35909
  }
37080
35910
  // row > 1 行,则删掉这一行
37081
- Transforms.removeNodes(editor, { at: rowPath });
35911
+ var _c = __read$3(Editor.nodes(editor, {
35912
+ match: function (n) { return DomEditor.checkNodeType(n, 'table-cell'); },
35913
+ universal: true,
35914
+ }), 1), cellEntry = _c[0];
35915
+ var _d = __read$3(cellEntry, 2), cellPath = _d[1];
35916
+ var matrix = filledMatrix(editor);
35917
+ var trIndex = 0;
35918
+ outer: for (var x = 0; x < matrix.length; x++) {
35919
+ for (var y = 0; y < matrix[x].length; y++) {
35920
+ var _e = __read$3(matrix[x][y], 1), _f = __read$3(_e[0], 2), path = _f[1];
35921
+ if (!Path.equals(cellPath, path)) {
35922
+ continue;
35923
+ }
35924
+ trIndex = x;
35925
+ break outer;
35926
+ }
35927
+ }
35928
+ Editor.withoutNormalizing(editor, function () {
35929
+ var e_1, _a;
35930
+ for (var y = 0; y < matrix[trIndex].length; y++) {
35931
+ var _b = __read$3(matrix[trIndex][y], 2), _c = __read$3(_b[0], 1), hidden = _c[0].hidden, _d = _b[1], ttb = _d.ttb, btt = _d.btt;
35932
+ // 寻找跨行行为
35933
+ if (ttb > 1 || btt > 1) {
35934
+ // 找到显示中 rowSpan 节点
35935
+ var _e = __read$3(matrix[trIndex - (ttb - 1)][y], 1), _f = __read$3(_e[0], 2), _g = _f[0], _h = _g.rowSpan, rowSpan = _h === void 0 ? 1 : _h, _j = _g.colSpan, colSpan = _j === void 0 ? 1 : _j, path = _f[1];
35936
+ // 如果当前选中节点为隐藏节点,则向上寻找处理 rowSpan 逻辑
35937
+ if (hidden) {
35938
+ Transforms.setNodes(editor, {
35939
+ rowSpan: Math.max(rowSpan - 1, 1),
35940
+ colSpan: colSpan,
35941
+ }, { at: path });
35942
+ }
35943
+ else {
35944
+ var _k = __read$3(matrix[trIndex + 1][y], 1), _l = __read$3(_k[0], 2), belowPath = _l[1];
35945
+ Transforms.setNodes(editor, {
35946
+ rowSpan: rowSpan - 1,
35947
+ colSpan: colSpan,
35948
+ hidden: false,
35949
+ }, { at: belowPath });
35950
+ try {
35951
+ // 移动单元格 文本、图片等元素
35952
+ for (var _m = (e_1 = void 0, __values$3(Node$1.children(editor, path, { reverse: true }))), _o = _m.next(); !_o.done; _o = _m.next()) {
35953
+ var _p = __read$3(_o.value, 2), childPath = _p[1];
35954
+ Transforms.moveNodes(editor, {
35955
+ to: __spreadArray(__spreadArray([], __read$3(belowPath)), [0]),
35956
+ at: childPath,
35957
+ });
35958
+ }
35959
+ }
35960
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
35961
+ finally {
35962
+ try {
35963
+ if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
35964
+ }
35965
+ finally { if (e_1) throw e_1.error; }
35966
+ }
35967
+ }
35968
+ }
35969
+ }
35970
+ Transforms.removeNodes(editor, { at: rowPath });
35971
+ });
37082
35972
  };
37083
35973
  return DeleteRow;
37084
35974
  }());
@@ -37128,27 +36018,62 @@ var InsertCol = /** @class */ (function () {
37128
36018
  var tableNode = DomEditor.getParentNode(editor, rowNode);
37129
36019
  if (tableNode == null)
37130
36020
  return;
37131
- // 遍历所有 rows ,挨个添加 cell
37132
- var rows = tableNode.children || [];
37133
- rows.forEach(function (row, rowIndex) {
37134
- if (!Element$1.isElement(row))
37135
- return;
37136
- var cells = row.children || [];
37137
- // 遍历一个 row 的所有 cells
37138
- cells.forEach(function (cell) {
37139
- var path = DomEditor.findPath(editor, cell);
37140
- if (path.length === selectedCellPath.length &&
37141
- lodash_isequal(path.slice(-1), selectedCellPath.slice(-1)) // 俩数组,最后一位相同
37142
- ) {
37143
- // 如果当前 td 的 path 和选中 td 的 path ,最后一位相同,说明是同一列
37144
- // 则在其后插入一个 cell
37145
- var newCell = { type: 'table-cell', children: [{ text: '' }] };
37146
- if (rowIndex === 0 && isTableWithHeader(tableNode)) {
37147
- newCell.isHeader = true;
36021
+ var matrix = filledMatrix(editor);
36022
+ var tdIndex = 0;
36023
+ out: for (var x = 0; x < matrix.length; x++) {
36024
+ for (var y = 0; y < matrix[x].length; y++) {
36025
+ var _c = __read$3(matrix[x][y], 1), _d = __read$3(_c[0], 2), path = _d[1];
36026
+ if (Path.equals(selectedCellPath, path)) {
36027
+ tdIndex = y;
36028
+ break out;
36029
+ }
36030
+ }
36031
+ }
36032
+ Editor.withoutNormalizing(editor, function () {
36033
+ var exitMerge = [];
36034
+ for (var x = 0; x < matrix.length; x++) {
36035
+ var _a = __read$3(matrix[x][tdIndex], 2), _b = _a[1], ltr = _b.ltr, rtl = _b.rtl;
36036
+ // 向左找到 1 元素为止
36037
+ if (ltr > 1 || rtl > 1) {
36038
+ if (rtl == 1)
36039
+ continue;
36040
+ var _c = __read$3(matrix[x][tdIndex - (rtl - 1)], 1), _d = __read$3(_c[0], 2), element = _d[0], path = _d[1];
36041
+ var colSpan = element.colSpan || 1;
36042
+ exitMerge.push(x);
36043
+ if (!element.hidden) {
36044
+ Transforms.setNodes(editor, {
36045
+ colSpan: colSpan + 1,
36046
+ }, { at: path });
37148
36047
  }
37149
- Transforms.insertNodes(editor, newCell, { at: path });
37150
36048
  }
37151
- });
36049
+ }
36050
+ // 遍历所有 rows ,挨个添加 cell
36051
+ for (var x = 0; x < matrix.length; x++) {
36052
+ var newCell = {
36053
+ type: 'table-cell',
36054
+ hidden: exitMerge.includes(x),
36055
+ children: [{ text: '' }],
36056
+ };
36057
+ if (x === 0 && isTableWithHeader(tableNode)) {
36058
+ newCell.isHeader = true;
36059
+ }
36060
+ var _e = __read$3(matrix[x][tdIndex], 1), _f = __read$3(_e[0], 2), insertPath = _f[1];
36061
+ Transforms.insertNodes(editor, newCell, { at: insertPath });
36062
+ }
36063
+ // 需要调整 columnWidths
36064
+ var _g = __read$3(Editor.nodes(editor, {
36065
+ match: function (n) { return DomEditor.checkNodeType(n, 'table'); },
36066
+ universal: true,
36067
+ }), 1), tableEntry = _g[0];
36068
+ if (tableEntry) {
36069
+ var _h = __read$3(tableEntry, 2), elemNode = _h[0], tablePath = _h[1];
36070
+ var _j = elemNode.columnWidths, columnWidths = _j === void 0 ? [] : _j;
36071
+ var adjustColumnWidths = __spreadArray([], __read$3(columnWidths));
36072
+ adjustColumnWidths.splice(tdIndex, 0, 60);
36073
+ Transforms.setNodes(editor, { columnWidths: adjustColumnWidths }, {
36074
+ at: tablePath,
36075
+ });
36076
+ }
37152
36077
  });
37153
36078
  };
37154
36079
  return InsertCol;
@@ -37204,23 +36129,76 @@ var DeleteCol = /** @class */ (function () {
37204
36129
  var tableNode = DomEditor.getParentNode(editor, rowNode);
37205
36130
  if (tableNode == null)
37206
36131
  return;
37207
- // 遍历所有 rows ,挨个删除 cell
37208
- var rows = tableNode.children || [];
37209
- rows.forEach(function (row) {
37210
- if (!Element$1.isElement(row))
37211
- return;
37212
- var cells = row.children || [];
37213
- // 遍历一个 row 的所有 cells
37214
- cells.forEach(function (cell) {
37215
- var path = DomEditor.findPath(editor, cell);
37216
- if (path.length === selectedCellPath.length &&
37217
- lodash_isequal(path.slice(-1), selectedCellPath.slice(-1)) // 俩数组,最后一位相同
37218
- ) {
37219
- // 如果当前 td 的 path 和选中 td 的 path ,最后一位相同,说明是同一列
37220
- // 删除当前的 cell
37221
- Transforms.removeNodes(editor, { at: path });
36132
+ var matrix = filledMatrix(editor);
36133
+ var tdIndex = 0;
36134
+ out: for (var x = 0; x < matrix.length; x++) {
36135
+ for (var y = 0; y < matrix[x].length; y++) {
36136
+ var _c = __read$3(matrix[x][y], 1), _d = __read$3(_c[0], 2), path = _d[1];
36137
+ if (Path.equals(selectedCellPath, path)) {
36138
+ tdIndex = y;
36139
+ break out;
37222
36140
  }
37223
- });
36141
+ }
36142
+ }
36143
+ Editor.withoutNormalizing(editor, function () {
36144
+ var e_1, _a;
36145
+ for (var x = 0; x < matrix.length; x++) {
36146
+ var _b = __read$3(matrix[x][tdIndex], 2), _c = __read$3(_b[0], 1), hidden = _c[0].hidden, _d = _b[1], rtl = _d.rtl, ltr = _d.ltr;
36147
+ if (rtl > 1 || ltr > 1) {
36148
+ // 找到显示中 colSpan 节点
36149
+ var _e = __read$3(matrix[x][tdIndex - (rtl - 1)], 1), _f = __read$3(_e[0], 2), _g = _f[0], _h = _g.rowSpan, rowSpan = _h === void 0 ? 1 : _h, _j = _g.colSpan, colSpan = _j === void 0 ? 1 : _j, path = _f[1];
36150
+ if (hidden) {
36151
+ Transforms.setNodes(editor, {
36152
+ rowSpan: rowSpan,
36153
+ colSpan: Math.max(colSpan - 1, 1),
36154
+ }, { at: path });
36155
+ }
36156
+ else {
36157
+ var _k = __read$3(matrix[x][tdIndex + 1], 1), _l = __read$3(_k[0], 2), rightPath = _l[1];
36158
+ Transforms.setNodes(editor, {
36159
+ rowSpan: rowSpan,
36160
+ colSpan: colSpan - 1,
36161
+ hidden: false,
36162
+ }, { at: rightPath });
36163
+ try {
36164
+ // 移动单元格 文本、图片等元素
36165
+ for (var _m = (e_1 = void 0, __values$3(Node$1.children(editor, path, { reverse: true }))), _o = _m.next(); !_o.done; _o = _m.next()) {
36166
+ var _p = __read$3(_o.value, 2), childPath = _p[1];
36167
+ Transforms.moveNodes(editor, {
36168
+ to: __spreadArray(__spreadArray([], __read$3(rightPath)), [0]),
36169
+ at: childPath,
36170
+ });
36171
+ }
36172
+ }
36173
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
36174
+ finally {
36175
+ try {
36176
+ if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
36177
+ }
36178
+ finally { if (e_1) throw e_1.error; }
36179
+ }
36180
+ }
36181
+ }
36182
+ }
36183
+ // 挨个删除 cell
36184
+ for (var x = 0; x < matrix.length; x++) {
36185
+ var _q = __read$3(matrix[x][tdIndex], 1), _r = __read$3(_q[0], 2), path = _r[1];
36186
+ Transforms.removeNodes(editor, { at: path });
36187
+ }
36188
+ // 需要调整 columnWidths
36189
+ var _s = __read$3(Editor.nodes(editor, {
36190
+ match: function (n) { return DomEditor.checkNodeType(n, 'table'); },
36191
+ universal: true,
36192
+ }), 1), tableEntry = _s[0];
36193
+ if (tableEntry) {
36194
+ var _t = __read$3(tableEntry, 2), elemNode = _t[0], tablePath = _t[1];
36195
+ var _u = elemNode.columnWidths, columnWidths = _u === void 0 ? [] : _u;
36196
+ var adjustColumnWidths = __spreadArray([], __read$3(columnWidths));
36197
+ adjustColumnWidths.splice(tdIndex, 1);
36198
+ Transforms.setNodes(editor, { columnWidths: adjustColumnWidths }, {
36199
+ at: tablePath,
36200
+ });
36201
+ }
37224
36202
  });
37225
36203
  };
37226
36204
  return DeleteCol;
@@ -37323,6 +36301,234 @@ var TableFullWidth = /** @class */ (function () {
37323
36301
  return TableFullWidth;
37324
36302
  }());
37325
36303
 
36304
+ var MergeCell = /** @class */ (function () {
36305
+ function MergeCell() {
36306
+ this.title = t('tableModule.mergeCell');
36307
+ this.iconSvg = MERGE_CELL_SVG;
36308
+ this.tag = 'button';
36309
+ }
36310
+ MergeCell.prototype.getValue = function (editor) {
36311
+ // 无需获取 val
36312
+ return '';
36313
+ };
36314
+ MergeCell.prototype.isActive = function (editor) {
36315
+ // 无需 active
36316
+ return false;
36317
+ };
36318
+ MergeCell.prototype.isDisabled = function (editor) {
36319
+ return !this.canMerge(editor);
36320
+ };
36321
+ MergeCell.prototype.exec = function (editor, value) {
36322
+ if (this.isDisabled(editor))
36323
+ return;
36324
+ this.merge(editor);
36325
+ // 释放选区
36326
+ TableCursor.unselect(editor);
36327
+ };
36328
+ /**
36329
+ * Checks if the current selection can be merged. Merging is not possible when any of the following conditions are met:
36330
+ * - The selection is empty.
36331
+ * - The selection is not within the same "thead", "tbody," or "tfoot" section.
36332
+ * @returns {boolean} `true` if the selection can be merged, otherwise `false`.
36333
+ */
36334
+ MergeCell.prototype.canMerge = function (editor) {
36335
+ var matrix = EDITOR_TO_SELECTION.get(editor);
36336
+ // cannot merge when selection is empty
36337
+ if (!matrix || !matrix.length) {
36338
+ return false;
36339
+ }
36340
+ // prettier-ignore
36341
+ var _a = __read$3(matrix[matrix.length - 1][matrix[matrix.length - 1].length - 1], 1), _b = __read$3(_a[0], 2), lastPath = _b[1];
36342
+ var _c = __read$3(matrix[0][0], 1), _d = __read$3(_c[0], 2), firstPath = _d[1];
36343
+ // cannot merge when selection is not in common section
36344
+ if (!hasCommon(editor, [firstPath, lastPath], 'table')) {
36345
+ return false;
36346
+ }
36347
+ return true;
36348
+ };
36349
+ /**
36350
+ * Merges the selected cells in the table.
36351
+ * @returns void
36352
+ */
36353
+ MergeCell.prototype.merge = function (editor) {
36354
+ if (!this.canMerge(editor)) {
36355
+ return;
36356
+ }
36357
+ var selection = EDITOR_TO_SELECTION.get(editor);
36358
+ if (!selection || !selection.length) {
36359
+ return;
36360
+ }
36361
+ var _a = __read$3(selection[0][0], 1), _b = __read$3(_a[0], 2), basePath = _b[1];
36362
+ var _c = __read$3(Node$1.children(editor, basePath, { reverse: true }), 1), _d = __read$3(_c[0], 2), lastPath = _d[1];
36363
+ filledMatrix(editor, { at: basePath });
36364
+ Editor.withoutNormalizing(editor, function () {
36365
+ var e_1, _a;
36366
+ var rowSpan = 0;
36367
+ var colSpan = 0;
36368
+ for (var x = selection.length - 1; x >= 0; x--, rowSpan++) {
36369
+ colSpan = 0;
36370
+ for (var y = selection[x].length - 1; y >= 0; y--, colSpan++) {
36371
+ var _b = __read$3(selection[x][y], 2), _c = __read$3(_b[0], 2), path = _c[1], ttb = _b[1].ttb;
36372
+ // skip first cell and "fake" cells which belong to a cell with a `rowspan`
36373
+ if (Path.equals(basePath, path) || ttb > 1) {
36374
+ continue;
36375
+ }
36376
+ try {
36377
+ // prettier-ignore
36378
+ for (var _d = (e_1 = void 0, __values$3(Node$1.children(editor, path, { reverse: true }))), _e = _d.next(); !_e.done; _e = _d.next()) {
36379
+ var _f = __read$3(_e.value, 2), childPath = _f[1];
36380
+ Transforms.moveNodes(editor, {
36381
+ to: Path.next(lastPath),
36382
+ at: childPath,
36383
+ });
36384
+ }
36385
+ }
36386
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
36387
+ finally {
36388
+ try {
36389
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
36390
+ }
36391
+ finally { if (e_1) throw e_1.error; }
36392
+ }
36393
+ var _g = __read$3(Editor.nodes(editor, {
36394
+ match: isOfType(editor, 'tr'),
36395
+ at: path,
36396
+ }), 1), _h = __read$3(_g[0], 2), trPath = _h[1];
36397
+ var _j = __read$3(Node$1.children(editor, trPath), 2), sibling = _j[1];
36398
+ if (sibling) {
36399
+ /**
36400
+ * 删除节点调整成隐藏节点
36401
+ * 隐藏节点不会影响 table 布局
36402
+ */
36403
+ Transforms.setNodes(editor, { hidden: true }, { at: path });
36404
+ continue;
36405
+ }
36406
+ }
36407
+ }
36408
+ Transforms.setNodes(editor, { rowSpan: rowSpan, colSpan: colSpan }, { at: basePath });
36409
+ });
36410
+ };
36411
+ return MergeCell;
36412
+ }());
36413
+
36414
+ // import { DEFAULT_WITH_TABLE_OPTIONS } from "../../utils/options";
36415
+ var SplitCell = /** @class */ (function () {
36416
+ function SplitCell() {
36417
+ this.title = t('tableModule.splitCell');
36418
+ this.iconSvg = SPLIT_CELL_SVG;
36419
+ this.tag = 'button';
36420
+ }
36421
+ SplitCell.prototype.getValue = function (editor) {
36422
+ // 无需获取 val
36423
+ return '';
36424
+ };
36425
+ SplitCell.prototype.isActive = function (editor) {
36426
+ // 无需 active
36427
+ return false;
36428
+ };
36429
+ SplitCell.prototype.isDisabled = function (editor) {
36430
+ var _a = __read$3(Editor.nodes(editor, {
36431
+ match: isOfType(editor, 'td'),
36432
+ }), 1), td = _a[0];
36433
+ var _b = __read$3(td, 1), _c = _b[0], _d = _c.rowSpan, rowSpan = _d === void 0 ? 1 : _d, _e = _c.colSpan, colSpan = _e === void 0 ? 1 : _e;
36434
+ if (rowSpan > 1 || colSpan > 1) {
36435
+ return false;
36436
+ }
36437
+ return true;
36438
+ };
36439
+ SplitCell.prototype.exec = function (editor, value) {
36440
+ if (this.isDisabled(editor))
36441
+ return;
36442
+ this.split(editor);
36443
+ };
36444
+ /**
36445
+ * Splits either the cell at the current selection or a specified location. If a range
36446
+ * selection is present, all cells within the range will be split.
36447
+ * @param {Location} [options.at] - Splits the cell at the specified location. If no
36448
+ * location is specified it will split the cell at the current selection
36449
+ * @param {boolean} [options.all] - If true, splits all cells in the table
36450
+ * @returns void
36451
+ */
36452
+ SplitCell.prototype.split = function (editor, options) {
36453
+ if (options === void 0) { options = {}; }
36454
+ var _a = __read$3(Editor.nodes(editor, {
36455
+ match: isOfType(editor, 'table', 'th', 'td'),
36456
+ // @ts-ignore
36457
+ at: options.at,
36458
+ }), 2), table = _a[0], td = _a[1];
36459
+ if (!table || !td) {
36460
+ return;
36461
+ }
36462
+ var selection = EDITOR_TO_SELECTION.get(editor) || [];
36463
+ // @ts-ignore
36464
+ var matrix = filledMatrix(editor, { at: options.at });
36465
+ // const { blocks } = DEFAULT_WITH_TABLE_OPTIONS;
36466
+ Editor.withoutNormalizing(editor, function () {
36467
+ for (var x = matrix.length - 1; x >= 0; x--) {
36468
+ for (var y = matrix[x].length - 1; y >= 0; y--) {
36469
+ var _a = __read$3(matrix[x][y], 2), _b = __read$3(_a[0], 2), path = _b[1], context = _a[1];
36470
+ var colSpan = context.ltr, rtl = context.rtl, rowSpan = context.btt, ttb = context.ttb;
36471
+ if (rtl > 1) {
36472
+ // get to the start of the colspan
36473
+ y -= rtl - 2;
36474
+ continue;
36475
+ }
36476
+ if (ttb > 1) {
36477
+ continue;
36478
+ }
36479
+ if (rowSpan === 1 && colSpan === 1) {
36480
+ continue;
36481
+ }
36482
+ var found = !!options.all;
36483
+ if (selection.length) {
36484
+ outer: for (var i = 0; !options.all && i < selection.length; i++) {
36485
+ for (var j = 0; j < selection[i].length; j++) {
36486
+ var _c = __read$3(selection[i][j], 1), _d = __read$3(_c[0], 2), tdPath = _d[1];
36487
+ if (Path.equals(tdPath, path)) {
36488
+ found = true;
36489
+ break outer;
36490
+ }
36491
+ }
36492
+ }
36493
+ }
36494
+ else {
36495
+ var _e = __read$3(td, 2), tdPath = _e[1];
36496
+ if (Path.equals(tdPath, path)) {
36497
+ found = true;
36498
+ }
36499
+ }
36500
+ if (!found) {
36501
+ continue;
36502
+ }
36503
+ var _f = __read$3(Editor.nodes(editor, {
36504
+ match: isOfType(editor, 'table'),
36505
+ at: path,
36506
+ }), 1), _g = __read$3(_f[0], 1); _g[0];
36507
+ out: for (var r = 1; r < rowSpan; r++) {
36508
+ for (var i = y; i >= 0; i--) {
36509
+ var _h = __read$3(matrix[x + r][i], 2), _j = __read$3(_h[0], 2); _j[1]; var ttb_1 = _h[1].ttb;
36510
+ if (ttb_1 == 1) {
36511
+ continue;
36512
+ }
36513
+ for (var c = 0; c < colSpan; c++) {
36514
+ var _k = __read$3(matrix[x + r][i + c], 1), _l = __read$3(_k[0], 2), nextPath = _l[1];
36515
+ Transforms.unsetNodes(editor, ['hidden', 'colSpan', 'rowSpan'], { at: nextPath });
36516
+ }
36517
+ continue out;
36518
+ }
36519
+ }
36520
+ for (var c = 1; c < colSpan; c++) {
36521
+ var _m = __read$3(matrix[x][y + c], 1), _o = __read$3(_m[0], 2), nextPath = _o[1];
36522
+ Transforms.unsetNodes(editor, ['hidden', 'colSpan', 'rowSpan'], { at: nextPath });
36523
+ }
36524
+ Transforms.setNodes(editor, { rowSpan: 1, colSpan: 1 }, { at: path });
36525
+ }
36526
+ }
36527
+ });
36528
+ };
36529
+ return SplitCell;
36530
+ }());
36531
+
37326
36532
  /**
37327
36533
  * @description table menu
37328
36534
  * @author wangfupeng
@@ -37374,6 +36580,19 @@ var tableFullWidthMenuConf = {
37374
36580
  factory: function () {
37375
36581
  return new TableFullWidth();
37376
36582
  },
36583
+ };
36584
+ /** Meger / Split conf */
36585
+ var mergeTableCellConf = {
36586
+ key: 'mergeTableCell',
36587
+ factory: function () {
36588
+ return new MergeCell();
36589
+ },
36590
+ };
36591
+ var splitTableCellConf = {
36592
+ key: 'splitTableCell',
36593
+ factory: function () {
36594
+ return new SplitCell();
36595
+ },
37377
36596
  };
37378
36597
 
37379
36598
  /**
@@ -37394,6 +36613,8 @@ var table = {
37394
36613
  deleteTableColConf,
37395
36614
  tableHeaderMenuConf,
37396
36615
  tableFullWidthMenuConf,
36616
+ mergeTableCellConf,
36617
+ splitTableCellConf,
37397
36618
  ],
37398
36619
  editorPlugin: withTable,
37399
36620
  };
@@ -44299,6 +43520,9 @@ var COMMON_HOVERBAR_KEYS = {
44299
43520
  'insertTableCol',
44300
43521
  'deleteTableCol',
44301
43522
  'deleteTable',
43523
+ /** 注册单元格合并 拆分 */
43524
+ 'mergeTableCell',
43525
+ 'splitTableCell',
44302
43526
  ],
44303
43527
  },
44304
43528
  divider: {
@@ -44411,4 +43635,4 @@ function createToolbar(option) {
44411
43635
  */
44412
43636
  var index = {};
44413
43637
 
44414
- export { Boot, DomEditor, Editor as SlateEditor, Element$1 as SlateElement, Location as SlateLocation, Node$1 as SlateNode, Path as SlatePath, Point as SlatePoint, Range as SlateRange, Text as SlateText, Transforms as SlateTransforms, Toolbar, createEditor, createToolbar, createUploader, index as default, genModalButtonElems, genModalInputElems, genModalTextareaElems, i18nAddResources, i18nChangeLanguage, i18nGetResources, t };
43638
+ export { Boot, DomEditor, Editor as SlateEditor, Element$1 as SlateElement, Location as SlateLocation, Node$1 as SlateNode, Path as SlatePath, Point$1 as SlatePoint, Range as SlateRange, Text as SlateText, Transforms as SlateTransforms, Toolbar, createEditor, createToolbar, createUploader, index as default, genModalButtonElems, genModalInputElems, genModalTextareaElems, i18nAddResources, i18nChangeLanguage, i18nGetResources, t };