@wangeditor-next/editor 5.3.12-alpha.0 → 5.3.12-alpha.2

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$2 = value => {
863
+ var isElement$1 = 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$2,
878
+ isElement: isElement$1,
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$2(value) && value[elementKey] === elementVal;
900
+ return isElement$1(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$1.equals(point, end);
1200
+ return Point.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$1.equals(point, start);
1246
+ return Point.equals(point, start);
1247
1247
  },
1248
1248
 
1249
1249
  /**
@@ -1663,7 +1663,7 @@ var Editor = {
1663
1663
  }
1664
1664
  }
1665
1665
 
1666
- if (Point$1.isPoint(at)) {
1666
+ if (Point.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$1.isPoint(value) || Range.isRange(value);
2258
+ return Path.isPath(value) || Point.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$1 = {
3332
+ var Point = {
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$1 = {
3350
3350
  * Check if a point is after another.
3351
3351
  */
3352
3352
  isAfter(point, another) {
3353
- return Point$1.compare(point, another) === 1;
3353
+ return Point.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$1.compare(point, another) === -1;
3360
+ return Point.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$1.transform(current, op, {
3479
+ var point = Point.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$1.equals(range.anchor, another.anchor) && Point$1.equals(range.focus, another.focus);
3525
+ return Point.equals(range.anchor, another.anchor) && Point.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$1.isBefore(rs, ts) && Point$1.isAfter(re, te);
3539
+ return Point.isBefore(rs, ts) && Point.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$1.isPoint(target)) {
3547
- isAfterStart = Point$1.compare(target, start) >= 0;
3548
- isBeforeEnd = Point$1.compare(target, end) <= 0;
3546
+ if (Point.isPoint(target)) {
3547
+ isAfterStart = Point.compare(target, start) >= 0;
3548
+ isBeforeEnd = Point.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$1.isBefore(s1, s2) ? s2 : s1;
3566
- var end = Point$1.isBefore(e1, e2) ? e1 : e2;
3565
+ var start = Point.isBefore(s1, s2) ? s2 : s1;
3566
+ var end = Point.isBefore(e1, e2) ? e1 : e2;
3567
3567
 
3568
- if (Point$1.isBefore(end, start)) {
3568
+ if (Point.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$1.isAfter(anchor, focus);
3587
+ return Point.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$1.equals(anchor, focus);
3599
+ return Point.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$1.isPoint(value.anchor) && Point$1.isPoint(value.focus);
3624
+ return isPlainObject$1(value) && Point.isPoint(value.anchor) && Point.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$1.transform(r.anchor, op, {
3685
+ var anchor = Point.transform(r.anchor, op, {
3686
3686
  affinity: affinityAnchor
3687
3687
  });
3688
- var focus = Point$1.transform(r.focus, op, {
3688
+ var focus = Point.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$1.transform(point, op);
3946
+ selection[key] = Point.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$1.transform(_point, op);
3972
+ selection[_key] = Point.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$1.transform(_point2, op);
4006
+ selection[_key2] = Point.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$1.transform(_point3, op);
4044
+ selection[_key3] = Point.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$1.transform(_point4, op);
4066
+ var result = Point.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$1.transform(_point5, op);
4129
+ selection[_key5] = Point.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$1.transform(_point6, op);
4252
+ selection[_key9] = Point.transform(_point6, op);
4253
4253
  }
4254
4254
  }
4255
4255
 
@@ -4352,7 +4352,7 @@ var NodeTransforms = {
4352
4352
  }
4353
4353
  }
4354
4354
 
4355
- if (Point$1.isPoint(at)) {
4355
+ if (Point.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$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]) {
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]) {
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$1.isPoint(at)) {
5493
+ if (Point.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$1.equals(_end, endOfDoc)) {
5532
+ if (!Point.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$1(node) {
8933
+ function isElement(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: isElement$1,
8955
+ isElement,
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$5 = function() {
17786
- __assign$5 = Object.assign || function __assign(t) {
17785
+ var __assign$4 = function() {
17786
+ __assign$4 = 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$5.apply(this, arguments);
17793
+ return __assign$4.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$1(to, from, pack) {
17825
+ function __spreadArray(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$1 = new WeakMap();
17897
+ var EDITOR_TO_SELECTION = new WeakMap();
17898
17898
  // editor -> eventEmitter 自定义事件
17899
17899
  var EDITOR_TO_EMITTER = new WeakMap();
17900
17900
  // editor 是否可执行粘贴
@@ -18759,7 +18759,7 @@ var DomEditor = {
18759
18759
  range.setStart(textNode, 0);
18760
18760
  range.setEnd(nearestNode, nearestOffset);
18761
18761
  var contents = range.cloneContents();
18762
- var removals = __spreadArray$1(__spreadArray$1([], __read$6(lodash_toarray(contents.querySelectorAll('[data-slate-zero-width]')))), __read$6(lodash_toarray(contents.querySelectorAll('[contenteditable=false]'))));
18762
+ var removals = __spreadArray(__spreadArray([], __read$6(lodash_toarray(contents.querySelectorAll('[data-slate-zero-width]')))), __read$6(lodash_toarray(contents.querySelectorAll('[contenteditable=false]'))));
18763
18763
  removals.forEach(function (el) {
18764
18764
  el.parentNode.removeChild(el);
18765
18765
  });
@@ -19107,7 +19107,7 @@ var withDOM = function (editor) {
19107
19107
  Transforms.select(e, end);
19108
19108
  }
19109
19109
  else {
19110
- var selection = EDITOR_TO_SELECTION$1.get(e);
19110
+ var selection = EDITOR_TO_SELECTION.get(e);
19111
19111
  if (selection) {
19112
19112
  Transforms.select(e, selection); // 选区定位到之前的位置
19113
19113
  }
@@ -19311,7 +19311,7 @@ var MENU_ITEM_FACTORIES = {};
19311
19311
  function registerMenu(registerMenuConf, customConfig) {
19312
19312
  var key = registerMenuConf.key, factory = registerMenuConf.factory, config = registerMenuConf.config;
19313
19313
  // 合并 config
19314
- var newConfig = __assign$5(__assign$5({}, config), (customConfig || {}));
19314
+ var newConfig = __assign$4(__assign$4({}, config), (customConfig || {}));
19315
19315
  // 注册 menu
19316
19316
  if (MENU_ITEM_FACTORIES[key] != null) {
19317
19317
  throw new Error("Duplicated key '" + key + "' in menu items");
@@ -20062,7 +20062,7 @@ var withContent = function (editor) {
20062
20062
  // 记录当前选区
20063
20063
  var selection = e.selection;
20064
20064
  if (selection != null) {
20065
- EDITOR_TO_SELECTION$1.set(e, selection);
20065
+ EDITOR_TO_SELECTION.set(e, selection);
20066
20066
  }
20067
20067
  // 触发配置的 change 事件
20068
20068
  e.emit('change');
@@ -20111,7 +20111,7 @@ var withContent = function (editor) {
20111
20111
  var key = DomEditor.findKey(e, node);
20112
20112
  var id = genElemId$1(key.id);
20113
20113
  // node + id
20114
- elems.push(__assign$5(__assign$5({}, node), { id: id }));
20114
+ elems.push(__assign$4(__assign$4({}, node), { id: id }));
20115
20115
  }
20116
20116
  }
20117
20117
  }
@@ -20862,7 +20862,7 @@ var withEmitter = function (editor) {
20862
20862
  args[_i - 1] = arguments[_i];
20863
20863
  }
20864
20864
  var emitter = getEmitter(e);
20865
- emitter.emit.apply(emitter, __spreadArray$1([type], __read$6(args)));
20865
+ emitter.emit.apply(emitter, __spreadArray([type], __read$6(args)));
20866
20866
  // editor 销毁时,off 掉 destroyed listeners
20867
20867
  if (type === 'destroyed') {
20868
20868
  var listeners = getDestroyListeners(e);
@@ -21117,7 +21117,7 @@ function correctPosition(editor, $positionElem) {
21117
21117
  * @description slate 插件 - selection 相关
21118
21118
  * @author wangfupeng
21119
21119
  */
21120
- var withSelection$1 = function (editor) {
21120
+ var withSelection = function (editor) {
21121
21121
  var e = editor;
21122
21122
  // 选中
21123
21123
  e.select = function (at) {
@@ -21156,7 +21156,7 @@ var withSelection$1 = function (editor) {
21156
21156
  * 还原选区
21157
21157
  */
21158
21158
  e.restoreSelection = function () {
21159
- var selection = EDITOR_TO_SELECTION$1.get(e);
21159
+ var selection = EDITOR_TO_SELECTION.get(e);
21160
21160
  if (selection == null)
21161
21161
  return;
21162
21162
  e.focus();
@@ -21183,7 +21183,7 @@ var withSelection$1 = function (editor) {
21183
21183
  return false;
21184
21184
  var _a = __read$6(Range.edges(selection), 2), start1 = _a[0], end1 = _a[1]; // 获取当前选取的开始、结束 point
21185
21185
  var _b = __read$6(Editor.edges(e, []), 2), start2 = _b[0], end2 = _b[1]; // 获取编辑器全部的开始、结束 point
21186
- if (Point$1.equals(start1, start2) && Point$1.equals(end1, end2)) {
21186
+ if (Point.equals(start1, start2) && Point.equals(end1, end2)) {
21187
21187
  return true;
21188
21188
  }
21189
21189
  return false;
@@ -22590,7 +22590,7 @@ function triggerMenuHotKey(editor, event) {
22590
22590
  var hoverbar = EDITOR_TO_HOVER_BAR.get(editor);
22591
22591
  var hoverbarMenus = hoverbar && hoverbar.getMenus();
22592
22592
  // 合并所有 menus
22593
- var allMenus = __assign$5(__assign$5({}, toolbarMenus), hoverbarMenus);
22593
+ var allMenus = __assign$4(__assign$4({}, toolbarMenus), hoverbarMenus);
22594
22594
  for (var key in allMenus) {
22595
22595
  var menu = allMenus[key];
22596
22596
  var hotkey = menu.hotkey;
@@ -24391,10 +24391,10 @@ function genEditorConfig(userConfig) {
24391
24391
  var _a = userConfig.MENU_CONF, userMenuConf = _a === void 0 ? {} : _a;
24392
24392
  lodash_foreach(defaultMenuConf, function (menuConf, menuKey) {
24393
24393
  // 生成新的 menu config
24394
- newMenuConf[menuKey] = __assign$5(__assign$5({}, menuConf), (userMenuConf[menuKey] || {}));
24394
+ newMenuConf[menuKey] = __assign$4(__assign$4({}, menuConf), (userMenuConf[menuKey] || {}));
24395
24395
  });
24396
24396
  delete userConfig.MENU_CONF; // 处理完,则删掉 menuConf ,以防下面 merge 时造成干扰
24397
- return __assign$5({
24397
+ return __assign$4({
24398
24398
  // 默认配置
24399
24399
  scroll: true, readOnly: false, autoFocus: true, decorate: function () { return []; }, maxLength: 0, MENU_CONF: newMenuConf, hoverbarKeys: {
24400
24400
  // 'link': { menuKeys: ['editLink', 'unLink', 'viewLink'] },
@@ -24406,7 +24406,7 @@ function genEditorConfig(userConfig) {
24406
24406
  * 生成 toolbar 默认配置
24407
24407
  */
24408
24408
  function genToolbarConfig(userConfig) {
24409
- return __assign$5({
24409
+ return __assign$4({
24410
24410
  // 默认配置
24411
24411
  toolbarKeys: [], excludeKeys: [], insertKeys: { index: 0, keys: [] }, modalAppendToBody: false }, (userConfig || {}));
24412
24412
  }
@@ -24449,7 +24449,7 @@ function bindNodeRelation(node, index, parent, editor) {
24449
24449
  function createEditor$1 (option) {
24450
24450
  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
24451
  // 创建实例 - 使用插件
24452
- var editor = withHistory(withMaxLength(withEmitter(withSelection$1(withContent(withConfig(withDOM(withEventData(createEditor$2()))))))));
24452
+ var editor = withHistory(withMaxLength(withEmitter(withSelection(withContent(withConfig(withDOM(withEventData(createEditor$2()))))))));
24453
24453
  if (selector) {
24454
24454
  // 检查是否对同一个 DOM 重复创建
24455
24455
  if (isRepeatedCreateTextarea(editor, selector)) {
@@ -27806,15 +27806,15 @@ function __extends$1(d, b) {
27806
27806
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27807
27807
  }
27808
27808
 
27809
- var __assign$4 = function() {
27810
- __assign$4 = Object.assign || function __assign(t) {
27809
+ var __assign$3 = function() {
27810
+ __assign$3 = Object.assign || function __assign(t) {
27811
27811
  for (var s, i = 1, n = arguments.length; i < n; i++) {
27812
27812
  s = arguments[i];
27813
27813
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
27814
27814
  }
27815
27815
  return t;
27816
27816
  };
27817
- return __assign$4.apply(this, arguments);
27817
+ return __assign$3.apply(this, arguments);
27818
27818
  };
27819
27819
 
27820
27820
  function __awaiter$2(thisArg, _arguments, P, generator) {
@@ -27827,7 +27827,7 @@ function __awaiter$2(thisArg, _arguments, P, generator) {
27827
27827
  });
27828
27828
  }
27829
27829
 
27830
- function __generator$3(thisArg, body) {
27830
+ function __generator$2(thisArg, body) {
27831
27831
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27832
27832
  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27833
27833
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -29468,7 +29468,7 @@ function replaceSymbols$1(str) {
29468
29468
  function check$1(menuKey, editor, text, url) {
29469
29469
  return __awaiter$2(this, void 0, void 0, function () {
29470
29470
  var checkLink, res;
29471
- return __generator$3(this, function (_a) {
29471
+ return __generator$2(this, function (_a) {
29472
29472
  switch (_a.label) {
29473
29473
  case 0:
29474
29474
  checkLink = editor.getMenuConfig(menuKey).checkLink;
@@ -29501,7 +29501,7 @@ function check$1(menuKey, editor, text, url) {
29501
29501
  function parse(menuKey, editor, url) {
29502
29502
  return __awaiter$2(this, void 0, void 0, function () {
29503
29503
  var parseLinkUrl, newUrl;
29504
- return __generator$3(this, function (_a) {
29504
+ return __generator$2(this, function (_a) {
29505
29505
  switch (_a.label) {
29506
29506
  case 0:
29507
29507
  parseLinkUrl = editor.getMenuConfig(menuKey).parseLinkUrl;
@@ -29552,7 +29552,7 @@ function genLinkNode(url, text) {
29552
29552
  function insertLink(editor, text, url) {
29553
29553
  return __awaiter$2(this, void 0, void 0, function () {
29554
29554
  var checkRes, parsedUrl, selection, isCollapsed, leftLength, linkNode, selectedText, leftLength, linkNode, linkNode;
29555
- return __generator$3(this, function (_a) {
29555
+ return __generator$2(this, function (_a) {
29556
29556
  switch (_a.label) {
29557
29557
  case 0:
29558
29558
  if (!url)
@@ -29633,7 +29633,7 @@ function insertLink(editor, text, url) {
29633
29633
  function updateLink(editor, text, url) {
29634
29634
  return __awaiter$2(this, void 0, void 0, function () {
29635
29635
  var checkRes, parsedUrl, props;
29636
- return __generator$3(this, function (_a) {
29636
+ return __generator$2(this, function (_a) {
29637
29637
  switch (_a.label) {
29638
29638
  case 0:
29639
29639
  if (!url)
@@ -30245,7 +30245,7 @@ function renderResizeContainer(editor, elemNode, imageVnode, imageInfo) {
30245
30245
  // const newHeight = $container.height().toFixed(2)
30246
30246
  // 修改 node
30247
30247
  var props = {
30248
- style: __assign$4(__assign$4({}, elemNode.style), { width: newWidth + "px" }),
30248
+ style: __assign$3(__assign$3({}, elemNode.style), { width: newWidth + "px" }),
30249
30249
  };
30250
30250
  Transforms.setNodes(editor, props, { at: DomEditor.findPath(editor, elemNode) });
30251
30251
  // 取消监听 mouseup
@@ -30369,7 +30369,7 @@ function check(menuKey, editor, src, alt, href) {
30369
30369
  if (href === void 0) { href = ''; }
30370
30370
  return __awaiter$2(this, void 0, void 0, function () {
30371
30371
  var checkImage, res;
30372
- return __generator$3(this, function (_a) {
30372
+ return __generator$2(this, function (_a) {
30373
30373
  switch (_a.label) {
30374
30374
  case 0:
30375
30375
  checkImage = editor.getMenuConfig(menuKey).checkImage;
@@ -30395,7 +30395,7 @@ function check(menuKey, editor, src, alt, href) {
30395
30395
  function parseSrc(menuKey, editor, src) {
30396
30396
  return __awaiter$2(this, void 0, void 0, function () {
30397
30397
  var parseImageSrc, newSrc;
30398
- return __generator$3(this, function (_a) {
30398
+ return __generator$2(this, function (_a) {
30399
30399
  switch (_a.label) {
30400
30400
  case 0:
30401
30401
  parseImageSrc = editor.getMenuConfig(menuKey).parseImageSrc;
@@ -30414,7 +30414,7 @@ function insertImageNode(editor, src, alt, href) {
30414
30414
  if (href === void 0) { href = ''; }
30415
30415
  return __awaiter$2(this, void 0, void 0, function () {
30416
30416
  var res, parsedSrc, image, onInsertedImage;
30417
- return __generator$3(this, function (_a) {
30417
+ return __generator$2(this, function (_a) {
30418
30418
  switch (_a.label) {
30419
30419
  case 0: return [4 /*yield*/, check('insertImage', editor, src, alt, href)];
30420
30420
  case 1:
@@ -30459,7 +30459,7 @@ function updateImageNode(editor, src, alt, href, style) {
30459
30459
  if (style === void 0) { style = {}; }
30460
30460
  return __awaiter$2(this, void 0, void 0, function () {
30461
30461
  var res, parsedSrc, selectedImageNode, _a, curStyle, nodeProps, imageNode, onUpdatedImage;
30462
- return __generator$3(this, function (_b) {
30462
+ return __generator$2(this, function (_b) {
30463
30463
  switch (_b.label) {
30464
30464
  case 0: return [4 /*yield*/, check('editImage', editor, src, alt, href)];
30465
30465
  case 1:
@@ -30477,7 +30477,7 @@ function updateImageNode(editor, src, alt, href, style) {
30477
30477
  src: parsedSrc,
30478
30478
  alt: alt,
30479
30479
  href: href,
30480
- style: __assign$4(__assign$4({}, curStyle), style),
30480
+ style: __assign$3(__assign$3({}, curStyle), style),
30481
30481
  };
30482
30482
  Transforms.setNodes(editor, nodeProps, {
30483
30483
  match: function (n) { return DomEditor.checkNodeType(n, 'image'); },
@@ -30867,7 +30867,7 @@ var ImageWidthBaseClass = /** @class */ (function () {
30867
30867
  hoverbar.hideAndClean();
30868
30868
  var _a = imageNode.style, style = _a === void 0 ? {} : _a;
30869
30869
  var props = {
30870
- style: __assign$4(__assign$4({}, style), { width: this.value, height: '' }),
30870
+ style: __assign$3(__assign$3({}, style), { width: this.value, height: '' }),
30871
30871
  };
30872
30872
  Transforms.setNodes(editor, props, {
30873
30873
  match: function (n) { return DomEditor.checkNodeType(n, 'image'); },
@@ -31004,7 +31004,7 @@ var EditorImageSizeMenu = /** @class */ (function () {
31004
31004
  }
31005
31005
  var _a = imageNode.style, style = _a === void 0 ? {} : _a;
31006
31006
  editor.restoreSelection();
31007
- var props = __assign$4(__assign$4({}, style), { style: {
31007
+ var props = __assign$3(__assign$3({}, style), { style: {
31008
31008
  width: width,
31009
31009
  height: height,
31010
31010
  } });
@@ -31521,7 +31521,7 @@ function withBlockquote(editor) {
31521
31521
  }
31522
31522
  var quotePath = DomEditor.findPath(editor, quoteElem);
31523
31523
  var quoteEndLocation = Editor.end(editor, quotePath);
31524
- if (Point$1.equals(quoteEndLocation, selection.focus)) {
31524
+ if (Point.equals(quoteEndLocation, selection.focus)) {
31525
31525
  // 光标位于 blockquote 最后
31526
31526
  var str = Node$1.string(quoteElem);
31527
31527
  if (str && str.slice(-1) === '\n') {
@@ -34204,643 +34204,2084 @@ var list = {
34204
34204
  parseElemsHtml: [parseListHtmlConf, parseItemHtmlConf],
34205
34205
  };
34206
34206
 
34207
- /**
34208
- * @description i18n en
34209
- * @author wangfupeng
34210
- */
34211
- var enResources$3 = {
34212
- tableModule: {
34213
- deleteCol: 'Delete column',
34214
- deleteRow: 'Delete row',
34215
- deleteTable: 'Delete table',
34216
- widthAuto: 'Width auto',
34217
- insertCol: 'Insert column',
34218
- insertRow: 'Insert row',
34219
- insertTable: 'Insert table',
34220
- header: 'Header',
34221
- mergeCell: 'merge cell',
34222
- splitCell: 'split cell',
34223
- },
34224
- };
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
+ */
34225
34215
 
34226
- /**
34227
- * @description i18n zh-CN
34228
- * @author wangfupeng
34229
- */
34230
- var zhResources$3 = {
34231
- tableModule: {
34232
- deleteCol: '删除列',
34233
- deleteRow: '删除行',
34234
- deleteTable: '删除表格',
34235
- widthAuto: '宽度自适应',
34236
- insertCol: '插入列',
34237
- insertRow: '插入行',
34238
- insertTable: '插入表格',
34239
- header: '表头',
34240
- mergeCell: '合并单元格',
34241
- splitCell: '拆分单元格',
34242
- },
34243
- };
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;
34244
34219
 
34245
- /**
34246
- * @description i18n entry
34247
- * @author wangfupeng
34248
- */
34249
- i18nAddResources('en', enResources$3);
34250
- i18nAddResources('zh-CN', zhResources$3);
34220
+ /** Used to stand-in for `undefined` hash values. */
34221
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
34251
34222
 
34252
- /******************************************************************************
34253
- Copyright (c) Microsoft Corporation.
34254
-
34255
- Permission to use, copy, modify, and/or distribute this software for any
34256
- purpose with or without fee is hereby granted.
34257
-
34258
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
34259
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
34260
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
34261
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
34262
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
34263
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
34264
- PERFORMANCE OF THIS SOFTWARE.
34265
- ***************************************************************************** */
34266
-
34267
- var __assign$3 = function() {
34268
- __assign$3 = Object.assign || function __assign(t) {
34269
- for (var s, i = 1, n = arguments.length; i < n; i++) {
34270
- s = arguments[i];
34271
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
34272
- }
34273
- return t;
34274
- };
34275
- return __assign$3.apply(this, arguments);
34276
- };
34277
-
34278
- function __generator$2(thisArg, body) {
34279
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
34280
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
34281
- function verb(n) { return function (v) { return step([n, v]); }; }
34282
- function step(op) {
34283
- if (f) throw new TypeError("Generator is already executing.");
34284
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
34285
- 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;
34286
- if (y = 0, t) op = [op[0] & 2, t.value];
34287
- switch (op[0]) {
34288
- case 0: case 1: t = op; break;
34289
- case 4: _.label++; return { value: op[1], done: false };
34290
- case 5: _.label++; y = op[1]; op = [0]; continue;
34291
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
34292
- default:
34293
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
34294
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
34295
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
34296
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
34297
- if (t[2]) _.ops.pop();
34298
- _.trys.pop(); continue;
34299
- }
34300
- op = body.call(thisArg, _);
34301
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34302
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
34303
- }
34304
- }
34305
-
34306
- function __values$3(o) {
34307
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
34308
- if (m) return m.call(o);
34309
- if (o && typeof o.length === "number") return {
34310
- next: function () {
34311
- if (o && i >= o.length) o = void 0;
34312
- return { value: o && o[i++], done: !o };
34313
- }
34314
- };
34315
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
34316
- }
34317
-
34318
- function __read$3(o, n) {
34319
- var m = typeof Symbol === "function" && o[Symbol.iterator];
34320
- if (!m) return o;
34321
- var i = m.call(o), r, ar = [], e;
34322
- try {
34323
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
34324
- }
34325
- catch (error) { e = { error: error }; }
34326
- finally {
34327
- try {
34328
- if (r && !r.done && (m = i["return"])) m.call(i);
34329
- }
34330
- finally { if (e) throw e.error; }
34331
- }
34332
- return ar;
34333
- }
34334
-
34335
- function __spreadArray(to, from, pack) {
34336
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
34337
- if (ar || !(i in from)) {
34338
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
34339
- ar[i] = from[i];
34340
- }
34341
- }
34342
- return to.concat(ar || Array.prototype.slice.call(from));
34343
- }
34344
-
34345
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
34346
- var e = new Error(message);
34347
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
34348
- };
34223
+ /** Used to compose bitmasks for value comparisons. */
34224
+ var COMPARE_PARTIAL_FLAG = 1,
34225
+ COMPARE_UNORDERED_FLAG = 2;
34349
34226
 
34350
- /** Weak reference between the `Editor` and the selected elements */
34351
- var EDITOR_TO_SELECTION = new WeakMap();
34352
- /** Weak reference between the `Editor` and a set of the selected elements */
34353
- var EDITOR_TO_SELECTION_SET = new WeakMap();
34354
-
34355
- var DEFAULT_WITH_TABLE_OPTIONS = {
34356
- blocks: {
34357
- td: 'table-cell',
34358
- th: 'table-cell',
34359
- content: 'paragraph',
34360
- tr: 'table-row',
34361
- table: 'table',
34362
- tbody: 'table-body',
34363
- // tfoot: "table-footer",
34364
- // thead: "table-head",
34365
- },
34366
- };
34227
+ /** Used as references for various `Number` constants. */
34228
+ var MAX_SAFE_INTEGER = 9007199254740991;
34367
34229
 
34368
- function isElement(node) {
34369
- return !Editor.isEditor(node) && Element$1.isElement(node) && 'type' in node;
34370
- }
34371
- /** @returns a `NodeMatch` function which is used to match the elements of a specific `type`. */
34372
- function isOfType(editor) {
34373
- var types = [];
34374
- for (var _i = 1; _i < arguments.length; _i++) {
34375
- types[_i - 1] = arguments[_i];
34376
- }
34377
- 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]; });
34378
- return function (node) { return isElement(node) && elementTypes.includes(node.type); };
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;
34379
34345
  }
34380
34346
 
34381
- /**
34382
- * Determines whether two paths belong to the same types by checking
34383
- * if they share a common ancestor node of type table
34384
- */
34385
- function hasCommon(editor, _a) {
34386
- var _b = __read$3(_a, 2), path = _b[0], another = _b[1];
34387
- var types = [];
34388
- for (var _i = 2; _i < arguments.length; _i++) {
34389
- types[_i - 2] = arguments[_i];
34390
- }
34391
- var _c = __read$3(Node$1.common(editor, path, another), 2), node = _c[0], commonPath = _c[1];
34392
- if (isOfType.apply(void 0, __spreadArray([editor], __read$3(types)))(node, commonPath)) {
34393
- return true;
34394
- }
34395
- // Warning: returns the common ancestor but will return `undefined` if the
34396
- // `commonPath` is equal to the specified types path
34397
- return !!Editor.above(editor, {
34398
- match: isOfType.apply(void 0, __spreadArray([editor], __read$3(types))),
34399
- at: commonPath,
34400
- });
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;
34401
34364
  }
34402
34365
 
34403
- /** Generates a matrix for each table section (`thead`, `tbody`, `tfoot`) */
34404
- function matrices(editor, options) {
34405
- var _a, table, _b, tablePath, _c, _d, _e, path, matrix, _f, _g, _h, trPath, e_1_1;
34406
- var e_1, _j, e_2, _k;
34407
- if (options === void 0) { options = {}; }
34408
- return __generator$2(this, function (_l) {
34409
- switch (_l.label) {
34410
- case 0:
34411
- _a = __read$3(Editor.nodes(editor, {
34412
- match: isOfType(editor, 'table'),
34413
- at: options.at,
34414
- }), 1), table = _a[0];
34415
- if (!table) {
34416
- return [2 /*return*/, []];
34417
- }
34418
- _b = __read$3(table, 2), tablePath = _b[1];
34419
- _l.label = 1;
34420
- case 1:
34421
- _l.trys.push([1, 6, 7, 8]);
34422
- _c = __values$3(Editor.nodes(editor, {
34423
- // match: isOfType(editor, "thead", "tbody", "tfoot"),
34424
- match: isOfType(editor, 'table'),
34425
- at: tablePath,
34426
- })), _d = _c.next();
34427
- _l.label = 2;
34428
- case 2:
34429
- if (!!_d.done) return [3 /*break*/, 5];
34430
- _e = __read$3(_d.value, 2), path = _e[1];
34431
- matrix = [];
34432
- try {
34433
- for (_f = (e_2 = void 0, __values$3(Editor.nodes(editor, {
34434
- match: isOfType(editor, 'tr'),
34435
- at: path,
34436
- }))), _g = _f.next(); !_g.done; _g = _f.next()) {
34437
- _h = __read$3(_g.value, 2), trPath = _h[1];
34438
- matrix.push(__spreadArray([], __read$3(Editor.nodes(editor, {
34439
- match: isOfType(editor, 'th', 'td'),
34440
- at: trPath,
34441
- }))));
34442
- }
34443
- }
34444
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
34445
- finally {
34446
- try {
34447
- if (_g && !_g.done && (_k = _f.return)) _k.call(_f);
34448
- }
34449
- finally { if (e_2) throw e_2.error; }
34450
- }
34451
- return [4 /*yield*/, matrix];
34452
- case 3:
34453
- _l.sent();
34454
- _l.label = 4;
34455
- case 4:
34456
- _d = _c.next();
34457
- return [3 /*break*/, 2];
34458
- case 5: return [3 /*break*/, 8];
34459
- case 6:
34460
- e_1_1 = _l.sent();
34461
- e_1 = { error: e_1_1 };
34462
- return [3 /*break*/, 8];
34463
- case 7:
34464
- try {
34465
- if (_d && !_d.done && (_j = _c.return)) _j.call(_c);
34466
- }
34467
- finally { if (e_1) throw e_1.error; }
34468
- return [7 /*endfinally*/];
34469
- case 8: return [2 /*return*/];
34470
- }
34471
- });
34472
- }
34473
- function filledMatrix(editor, options) {
34474
- var e_3, _a;
34475
- if (options === void 0) { options = {}; }
34476
- var filled = [];
34477
- try {
34478
- // Expand each section separately to avoid sections collapsing into each other.
34479
- for (var _b = __values$3(matrices(editor, { at: options.at })), _c = _b.next(); !_c.done; _c = _b.next()) {
34480
- var matrix = _c.value;
34481
- var filledSection = [];
34482
- for (var x = 0; x < matrix.length; x++) {
34483
- if (!filledSection[x]) {
34484
- filledSection[x] = [];
34485
- }
34486
- for (var y = 0; y < matrix[x].length; y++) {
34487
- 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;
34488
- for (var c = 0, occupied = 0; c < colSpan + occupied; c++) {
34489
- for (var r = 0; r < rowSpan; r++) {
34490
- if (!filledSection[x + r]) {
34491
- filledSection[x + r] = [];
34492
- }
34493
- if (filledSection[x + r][y + c]) {
34494
- continue;
34495
- }
34496
- filledSection[x + r][y + c] = [
34497
- matrix[x + r][y + c],
34498
- {
34499
- rtl: c - occupied + 1,
34500
- ltr: colSpan - c + occupied,
34501
- ttb: r + 1,
34502
- btt: rowSpan - r,
34503
- },
34504
- ];
34505
- }
34506
- }
34507
- }
34508
- }
34509
- filled.push.apply(filled, __spreadArray([], __read$3(filledSection)));
34510
- }
34511
- }
34512
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
34513
- finally {
34514
- try {
34515
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
34516
- }
34517
- finally { if (e_3) throw e_3.error; }
34518
- }
34519
- return filled;
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;
34520
34386
  }
34521
34387
 
34522
- var Point = /** @class */ (function () {
34523
- function Point(x, y) {
34524
- this.x = x;
34525
- this.y = y;
34526
- }
34527
- Point.valueOf = function (x, y) {
34528
- return new this(x, y);
34529
- };
34530
- Point.equals = function (point, another) {
34531
- return point.x === another.x && point.y === another.y;
34532
- };
34533
- return Point;
34534
- }());
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);
34535
34400
 
34536
- var TableCursor = {
34537
- /** @returns {boolean} `true` if the selection is inside a table, otherwise `false`. */
34538
- isInTable: function (editor, options) {
34539
- if (options === void 0) { options = {}; }
34540
- var _a = __read$3(Editor.nodes(editor, {
34541
- match: isOfType(editor, 'table'),
34542
- at: options.at,
34543
- }), 1), table = _a[0];
34544
- return !!table;
34545
- },
34546
- /**
34547
- * Retrieves a matrix representing the selected cells within a table.
34548
- * @returns {NodeEntry<T>[][]} A matrix containing the selected cells.
34549
- */
34550
- selection: function (editor) {
34551
- var matrix, x, cells, y, _a, entry, _b, colSpan, ttb;
34552
- return __generator$2(this, function (_c) {
34553
- switch (_c.label) {
34554
- case 0:
34555
- matrix = EDITOR_TO_SELECTION.get(editor);
34556
- x = 0;
34557
- _c.label = 1;
34558
- case 1:
34559
- if (!(matrix && x < matrix.length)) return [3 /*break*/, 4];
34560
- cells = [];
34561
- for (y = 0; y < matrix[x].length; y++) {
34562
- _a = __read$3(matrix[x][y], 2), entry = _a[0], _b = _a[1], colSpan = _b.ltr, ttb = _b.ttb;
34563
- ttb === 1 && cells.push(entry);
34564
- y += colSpan - 1;
34565
- }
34566
- return [4 /*yield*/, cells];
34567
- case 2:
34568
- _c.sent();
34569
- _c.label = 3;
34570
- case 3:
34571
- x++;
34572
- return [3 /*break*/, 1];
34573
- case 4: return [2 /*return*/];
34574
- }
34575
- });
34576
- },
34577
- /** Clears the selection from the table */
34578
- unselect: function (editor) {
34579
- // const matrix = EDITOR_TO_SELECTION.get(editor);
34580
- var _a;
34581
- // if (!matrix?.length) {
34582
- // return;
34583
- // }
34584
- // for (let x = 0; x < matrix.length; x++) {
34585
- // for (let y = 0; y < matrix[x].length; y++) {
34586
- // const [[, path], { ltr: colSpan, ttb }] = matrix[x][y];
34587
- // y += colSpan - 1;
34588
- // if (ttb > 1) {
34589
- // continue;
34590
- // }
34591
- // // no-op since the paths are the same
34592
- // const noop: Operation = {
34593
- // type: "move_node",
34594
- // newPath: path,
34595
- // path: path,
34596
- // };
34597
- // Transforms.transform(editor, noop);
34598
- // }
34599
- // }
34600
- EDITOR_TO_SELECTION_SET.delete(editor);
34601
- EDITOR_TO_SELECTION.delete(editor);
34602
- // 清除选区
34603
- (_a = document.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
34604
- },
34605
- /**
34606
- * Checks whether a given cell is part of the current table selection.
34607
- * @returns {boolean} - Returns true if the cell is selected, otherwise false.
34608
- */
34609
- isSelected: function (editor, element) {
34610
- var selectedElements = EDITOR_TO_SELECTION_SET.get(editor);
34611
- if (!selectedElements) {
34612
- return false;
34613
- }
34614
- return selectedElements.has(element);
34615
- },
34616
- };
34401
+ while (++index < n) {
34402
+ result[index] = iteratee(index);
34403
+ }
34404
+ return result;
34405
+ }
34617
34406
 
34618
- function withSelection(editor) {
34619
- var apply = editor.apply;
34620
- editor.apply = function (op) {
34621
- if (!Operation.isSelectionOperation(op) || !op.newProperties) {
34622
- // TableCursor.unselect(editor);
34623
- // 仿飞书效果,拖动单元格宽度时,选区不消失
34624
- return apply(op);
34625
- }
34626
- var selection = __assign$3(__assign$3({}, editor.selection), op.newProperties);
34627
- if (!Range.isRange(selection)) {
34628
- TableCursor.unselect(editor);
34629
- return apply(op);
34630
- }
34631
- var _a = __read$3(Editor.nodes(editor, {
34632
- match: isOfType(editor, 'th', 'td'),
34633
- at: Range.start(selection),
34634
- }), 1), fromEntry = _a[0];
34635
- var _b = __read$3(Editor.nodes(editor, {
34636
- match: isOfType(editor, 'th', 'td'),
34637
- at: Range.end(selection),
34638
- }), 1), toEntry = _b[0];
34639
- if (!fromEntry || !toEntry) {
34640
- TableCursor.unselect(editor);
34641
- return apply(op);
34642
- }
34643
- var _c = __read$3(fromEntry, 2), fromPath = _c[1];
34644
- var _d = __read$3(toEntry, 2), toPath = _d[1];
34645
- if (Path.equals(fromPath, toPath) || !hasCommon(editor, [fromPath, toPath], 'table')) {
34646
- TableCursor.unselect(editor);
34647
- return apply(op);
34648
- }
34649
- // TODO: perf: could be improved by passing a Span [fromPath, toPath]
34650
- var filled = filledMatrix(editor, { at: fromPath });
34651
- // find initial bounds
34652
- var from = Point.valueOf(0, 0);
34653
- var to = Point.valueOf(0, 0);
34654
- outer: for (var x = 0; x < filled.length; x++) {
34655
- for (var y = 0; y < filled[x].length; y++) {
34656
- var _e = __read$3(filled[x][y], 1), _f = __read$3(_e[0], 2), path = _f[1];
34657
- if (Path.equals(fromPath, path)) {
34658
- from.x = x;
34659
- from.y = y;
34660
- }
34661
- if (Path.equals(toPath, path)) {
34662
- to.x = x;
34663
- to.y = y;
34664
- break outer;
34665
- }
34666
- }
34667
- }
34668
- var start = Point.valueOf(Math.min(from.x, to.x), Math.min(from.y, to.y));
34669
- var end = Point.valueOf(Math.max(from.x, to.x), Math.max(from.y, to.y));
34670
- // expand the selection based on rowspan and colspan
34671
- for (;;) {
34672
- var nextStart = Point.valueOf(start.x, start.y);
34673
- var nextEnd = Point.valueOf(end.x, end.y);
34674
- for (var x = nextStart.x; x <= nextEnd.x; x++) {
34675
- for (var y = nextStart.y; y <= nextEnd.y; y++) {
34676
- var _g = __read$3(filled[x][y], 2), _h = _g[1], rtl = _h.rtl, ltr = _h.ltr, btt = _h.btt, ttb = _h.ttb;
34677
- nextStart.x = Math.min(nextStart.x, x - (ttb - 1));
34678
- nextStart.y = Math.min(nextStart.y, y - (rtl - 1));
34679
- nextEnd.x = Math.max(nextEnd.x, x + (btt - 1));
34680
- nextEnd.y = Math.max(nextEnd.y, y + (ltr - 1));
34681
- }
34682
- }
34683
- if (Point.equals(start, nextStart) && Point.equals(end, nextEnd)) {
34684
- break;
34685
- }
34686
- start = nextStart;
34687
- end = nextEnd;
34688
- }
34689
- var selected = [];
34690
- var selectedSet = new WeakSet();
34691
- for (var x = start.x; x <= end.x; x++) {
34692
- var cells = [];
34693
- for (var y = start.y; y <= end.y; y++) {
34694
- var _j = __read$3(filled[x][y], 1), _k = __read$3(_j[0], 1), element = _k[0];
34695
- selectedSet.add(element);
34696
- cells.push(filled[x][y]);
34697
- }
34698
- selected.push(cells);
34699
- }
34700
- EDITOR_TO_SELECTION.set(editor, selected);
34701
- EDITOR_TO_SELECTION_SET.set(editor, selectedSet);
34702
- apply(op);
34703
- };
34704
- return editor;
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
+ };
34705
34418
  }
34706
34419
 
34707
- /**
34708
- * @description editor 插件,重写 editor API
34709
- * @author wangfupeng
34710
- */
34711
- // table cell 内部的删除处理
34712
- function deleteHandler(newEditor) {
34713
- var selection = newEditor.selection;
34714
- if (selection == null)
34715
- return false;
34716
- var _a = __read$3(Editor.nodes(newEditor, {
34717
- match: function (n) { return DomEditor.checkNodeType(n, 'table-cell'); },
34718
- }), 1), cellNodeEntry = _a[0];
34719
- if (cellNodeEntry) {
34720
- var _b = __read$3(cellNodeEntry, 2), cellPath = _b[1];
34721
- var start = Editor.start(newEditor, cellPath);
34722
- if (Point$1.equals(selection.anchor, start)) {
34723
- return true; // 阻止删除 cell
34724
- }
34725
- }
34726
- return false;
34727
- }
34728
- /**
34729
- * 判断该 location 有没有命中 table
34730
- * @param editor editor
34731
- * @param location location
34732
- */
34733
- function isTableLocation(editor, location) {
34734
- var e_1, _a;
34735
- var tables = Editor.nodes(editor, {
34736
- at: location,
34737
- match: function (n) {
34738
- var type = DomEditor.getNodeType(n);
34739
- return type === 'table';
34740
- },
34741
- });
34742
- var hasTable = false;
34743
- try {
34744
- for (var tables_1 = __values$3(tables), tables_1_1 = tables_1.next(); !tables_1_1.done; tables_1_1 = tables_1.next()) {
34745
- var table = tables_1_1.value;
34746
- hasTable = true; // 找到了 table
34747
- }
34748
- }
34749
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
34750
- finally {
34751
- try {
34752
- if (tables_1_1 && !tables_1_1.done && (_a = tables_1.return)) _a.call(tables_1);
34753
- }
34754
- finally { if (e_1) throw e_1.error; }
34755
- }
34756
- return hasTable;
34757
- }
34758
- function withTable(editor) {
34759
- var insertBreak = editor.insertBreak, deleteBackward = editor.deleteBackward, deleteForward = editor.deleteForward, normalizeNode = editor.normalizeNode, insertData = editor.insertData, handleTab = editor.handleTab, selectAll = editor.selectAll;
34760
- var newEditor = editor;
34761
- // 重写 insertBreak - cell 内换行,只换行文本,不拆分 node
34762
- newEditor.insertBreak = function () {
34763
- var selectedNode = DomEditor.getSelectedNodeByType(newEditor, 'table');
34764
- if (selectedNode != null) {
34765
- // 选中了 table ,则在 cell 内换行
34766
- newEditor.insertText('\n');
34767
- return;
34768
- }
34769
- // 未选中 table ,默认的换行
34770
- insertBreak();
34771
- };
34772
- // 重写 delete - cell 内删除,只删除文字,不删除 node
34773
- newEditor.deleteBackward = function (unit) {
34774
- var res = deleteHandler(newEditor);
34775
- if (res)
34776
- return; // 命中 table cell ,自己处理删除
34777
- // 防止从 table 后面的 p 删除时,删除最后一个 cell - issues/4221
34778
- var selection = newEditor.selection;
34779
- if (selection) {
34780
- var before = Editor.before(newEditor, selection); // 前一个 location
34781
- if (before) {
34782
- var isTableOnBeforeLocation = isTableLocation(newEditor, before); // before 是否是 table
34783
- // 如果前面是 table, 当前是空 p,则不执行删除。否则会删除 table 最后一个 cell
34784
- if (isTableOnBeforeLocation && DomEditor.isSelectedEmptyParagraph(newEditor)) {
34785
- return;
34786
- }
34787
- }
34788
- }
34789
- // 执行默认的删除
34790
- deleteBackward(unit);
34791
- };
34792
- // 重写 handleTab 在table内按tab时跳到下一个单元格
34793
- newEditor.handleTab = function () {
34794
- var _a;
34795
- var selectedNode = DomEditor.getSelectedNodeByType(newEditor, 'table');
34796
- if (selectedNode) {
34797
- var above = Editor.above(editor);
34798
- // 常规情况下选中文字外层 table-cell 进行跳转
34799
- if (DomEditor.checkNodeType(above[0], 'table-cell')) {
34800
- Transforms.select(editor, above[1]);
34801
- }
34802
- var next = Editor.next(editor);
34803
- if (next) {
34804
- if (next[0] && next[0].text) {
34805
- // 多个单元格同时选中按 tab 导致错位修复
34806
- next = (_a = Editor.above(editor, { at: next[1] })) !== null && _a !== void 0 ? _a : next;
34807
- }
34808
- Transforms.select(editor, next[1]);
34809
- }
34810
- else {
34811
- var topLevelNodes = newEditor.children || [];
34812
- var topLevelNodesLength = topLevelNodes.length;
34813
- // 在最后一个单元格按tab时table末尾如果没有p则插入p后光标切到p上
34814
- if (DomEditor.checkNodeType(topLevelNodes[topLevelNodesLength - 1], 'table')) {
34815
- var p = DomEditor.genEmptyParagraph();
34816
- Transforms.insertNodes(newEditor, p, { at: [topLevelNodesLength] });
34817
- // 在表格末尾插入p后再次执行使光标切到p上
34818
- newEditor.handleTab();
34819
- }
34820
- }
34821
- return;
34822
- }
34823
- handleTab();
34824
- };
34825
- newEditor.deleteForward = function (unit) {
34826
- var res = deleteHandler(newEditor);
34827
- if (res)
34828
- return; // 命中 table cell ,自己处理删除
34829
- // 执行默认的删除
34830
- deleteForward(unit);
34831
- };
34832
- // 重新 normalize
34833
- newEditor.normalizeNode = function (_a) {
34834
- var _b = __read$3(_a, 2), node = _b[0], path = _b[1];
34835
- var type = DomEditor.getNodeType(node);
34836
- if (type !== 'table') {
34837
- // 未命中 table ,执行默认的 normalizeNode
34838
- return normalizeNode([node, path]);
34839
- }
34840
- // -------------- table editor 最后一个节点,需要后面插入 p --------------
34841
- var isLast = DomEditor.isLastNode(newEditor, node);
34842
- if (isLast) {
34843
- var p = DomEditor.genEmptyParagraph();
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
+ }
34431
+
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
+ }
34443
+
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);
34454
+
34455
+ map.forEach(function(value, key) {
34456
+ result[++index] = [key, value];
34457
+ });
34458
+ return result;
34459
+ }
34460
+
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
+ };
34473
+ }
34474
+
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;
34490
+ }
34491
+
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) : '';
34510
+ }());
34511
+
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);
34552
+
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
+ };
36147
+
36148
+ /**
36149
+ * @description editor 插件,重写 editor API
36150
+ * @author wangfupeng
36151
+ */
36152
+ // table cell 内部的删除处理
36153
+ function deleteHandler(newEditor) {
36154
+ var selection = newEditor.selection;
36155
+ if (selection == null)
36156
+ return false;
36157
+ var _a = __read$3(Editor.nodes(newEditor, {
36158
+ match: function (n) { return DomEditor.checkNodeType(n, 'table-cell'); },
36159
+ }), 1), cellNodeEntry = _a[0];
36160
+ if (cellNodeEntry) {
36161
+ var _b = __read$3(cellNodeEntry, 2), cellPath = _b[1];
36162
+ var start = Editor.start(newEditor, cellPath);
36163
+ if (Point.equals(selection.anchor, start)) {
36164
+ return true; // 阻止删除 cell
36165
+ }
36166
+ }
36167
+ return false;
36168
+ }
36169
+ /**
36170
+ * 判断该 location 有没有命中 table
36171
+ * @param editor editor
36172
+ * @param location location
36173
+ */
36174
+ function isTableLocation(editor, location) {
36175
+ var e_1, _a;
36176
+ var tables = Editor.nodes(editor, {
36177
+ at: location,
36178
+ match: function (n) {
36179
+ var type = DomEditor.getNodeType(n);
36180
+ return type === 'table';
36181
+ },
36182
+ });
36183
+ var hasTable = false;
36184
+ try {
36185
+ for (var tables_1 = __values$3(tables), tables_1_1 = tables_1.next(); !tables_1_1.done; tables_1_1 = tables_1.next()) {
36186
+ var table = tables_1_1.value;
36187
+ hasTable = true; // 找到了 table
36188
+ }
36189
+ }
36190
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
36191
+ finally {
36192
+ try {
36193
+ if (tables_1_1 && !tables_1_1.done && (_a = tables_1.return)) _a.call(tables_1);
36194
+ }
36195
+ finally { if (e_1) throw e_1.error; }
36196
+ }
36197
+ return hasTable;
36198
+ }
36199
+ function withTable(editor) {
36200
+ var insertBreak = editor.insertBreak, deleteBackward = editor.deleteBackward, deleteForward = editor.deleteForward, normalizeNode = editor.normalizeNode, insertData = editor.insertData, handleTab = editor.handleTab, selectAll = editor.selectAll;
36201
+ var newEditor = editor;
36202
+ // 重写 insertBreak - cell 内换行,只换行文本,不拆分 node
36203
+ newEditor.insertBreak = function () {
36204
+ var selectedNode = DomEditor.getSelectedNodeByType(newEditor, 'table');
36205
+ if (selectedNode != null) {
36206
+ // 选中了 table ,则在 cell 内换行
36207
+ newEditor.insertText('\n');
36208
+ return;
36209
+ }
36210
+ // 未选中 table ,默认的换行
36211
+ insertBreak();
36212
+ };
36213
+ // 重写 delete - cell 内删除,只删除文字,不删除 node
36214
+ newEditor.deleteBackward = function (unit) {
36215
+ var res = deleteHandler(newEditor);
36216
+ if (res)
36217
+ return; // 命中 table cell ,自己处理删除
36218
+ // 防止从 table 后面的 p 删除时,删除最后一个 cell - issues/4221
36219
+ var selection = newEditor.selection;
36220
+ if (selection) {
36221
+ var before = Editor.before(newEditor, selection); // 前一个 location
36222
+ if (before) {
36223
+ var isTableOnBeforeLocation = isTableLocation(newEditor, before); // before 是否是 table
36224
+ var isTableOnCurSelection = isTableLocation(newEditor, selection); // 当前是否是 table
36225
+ if (isTableOnBeforeLocation && !isTableOnCurSelection) {
36226
+ return; // 如果当前不是 table ,前面是 table ,则不执行删除。否则会删除 table 最后一个 cell
36227
+ }
36228
+ }
36229
+ }
36230
+ // 执行默认的删除
36231
+ deleteBackward(unit);
36232
+ };
36233
+ // 重写 handleTab 在table内按tab时跳到下一个单元格
36234
+ newEditor.handleTab = function () {
36235
+ var _a;
36236
+ var selectedNode = DomEditor.getSelectedNodeByType(newEditor, 'table');
36237
+ if (selectedNode) {
36238
+ var above = Editor.above(editor);
36239
+ // 常规情况下选中文字外层 table-cell 进行跳转
36240
+ if (DomEditor.checkNodeType(above[0], 'table-cell')) {
36241
+ Transforms.select(editor, above[1]);
36242
+ }
36243
+ var next = Editor.next(editor);
36244
+ if (next) {
36245
+ if (next[0] && next[0].text) {
36246
+ // 多个单元格同时选中按 tab 导致错位修复
36247
+ next = (_a = Editor.above(editor, { at: next[1] })) !== null && _a !== void 0 ? _a : next;
36248
+ }
36249
+ Transforms.select(editor, next[1]);
36250
+ }
36251
+ else {
36252
+ var topLevelNodes = newEditor.children || [];
36253
+ var topLevelNodesLength = topLevelNodes.length;
36254
+ // 在最后一个单元格按tab时table末尾如果没有p则插入p后光标切到p上
36255
+ if (DomEditor.checkNodeType(topLevelNodes[topLevelNodesLength - 1], 'table')) {
36256
+ var p = DomEditor.genEmptyParagraph();
36257
+ Transforms.insertNodes(newEditor, p, { at: [topLevelNodesLength] });
36258
+ // 在表格末尾插入p后再次执行使光标切到p上
36259
+ newEditor.handleTab();
36260
+ }
36261
+ }
36262
+ return;
36263
+ }
36264
+ handleTab();
36265
+ };
36266
+ newEditor.deleteForward = function (unit) {
36267
+ var res = deleteHandler(newEditor);
36268
+ if (res)
36269
+ return; // 命中 table cell ,自己处理删除
36270
+ // 执行默认的删除
36271
+ deleteForward(unit);
36272
+ };
36273
+ // 重新 normalize
36274
+ newEditor.normalizeNode = function (_a) {
36275
+ var _b = __read$3(_a, 2), node = _b[0], path = _b[1];
36276
+ var type = DomEditor.getNodeType(node);
36277
+ if (type !== 'table') {
36278
+ // 未命中 table ,执行默认的 normalizeNode
36279
+ return normalizeNode([node, path]);
36280
+ }
36281
+ // -------------- table 是 editor 最后一个节点,需要后面插入 p --------------
36282
+ var isLast = DomEditor.isLastNode(newEditor, node);
36283
+ if (isLast) {
36284
+ var p = DomEditor.genEmptyParagraph();
34844
36285
  Transforms.insertNodes(newEditor, p, { at: [path[0] + 1] });
34845
36286
  }
34846
36287
  };
@@ -34893,299 +36334,49 @@ function withTable(editor) {
34893
36334
  };
34894
36335
  newEditor.select(newSelection); // 选中 table-cell 内部的全部文字
34895
36336
  };
34896
- /**
34897
- * 光标选区行为新增
34898
- */
34899
- withSelection(newEditor);
34900
36337
  // 可继续修改其他 newEditor API ...
34901
36338
  // 返回 editor ,重要!
34902
36339
  return newEditor;
34903
36340
  }
34904
36341
 
34905
36342
  /**
34906
- * @description DOM 操作
36343
+ * @description table menu helpers
34907
36344
  * @author wangfupeng
34908
36345
  */
34909
- if (append)
34910
- $.fn.append = append;
34911
- if (on)
34912
- $.fn.on = on;
34913
- if (focus)
34914
- $.fn.focus = focus;
34915
- if (attr)
34916
- $.fn.attr = attr;
34917
- if (val)
34918
- $.fn.val = val;
34919
- if (html)
34920
- $.fn.html = html;
34921
- if (dataset)
34922
- $.fn.dataset = dataset;
34923
- if (addClass)
34924
- $.fn.addClass = addClass;
34925
- if (removeClass)
34926
- $.fn.removeClass = removeClass;
34927
- if (children)
34928
- $.fn.children = children;
34929
- if (each)
34930
- $.fn.each = each;
34931
- if (find)
34932
- $.fn.find = find;
34933
- /**
34934
- * 获取 tagName lower-case
34935
- * @param $elem $elem
34936
- */
34937
- function getTagName$1($elem) {
34938
- if ($elem.length)
34939
- return $elem[0].tagName.toLowerCase();
34940
- return '';
34941
- }
34942
36346
  /**
34943
- * 获取 $elem 某一个 style 值
34944
- * @param $elem $elem
34945
- * @param styleKey style key
34946
- */
34947
- function getStyleValue($elem, styleKey) {
34948
- var res = '';
34949
- var styleStr = $elem.attr('style') || ''; // 如 'line-height: 2.5; color: red;'
34950
- var styleArr = styleStr.split(';'); // 如 ['line-height: 2.5', ' color: red', '']
34951
- var length = styleArr.length;
34952
- for (var i = 0; i < length; i++) {
34953
- var styleItemStr = styleArr[i]; // 如 'line-height: 2.5'
34954
- if (styleItemStr) {
34955
- var arr = styleItemStr.split(':'); // ['line-height', ' 2.5']
34956
- if (arr[0].trim() === styleKey) {
34957
- res = arr[1].trim();
34958
- }
34959
- }
34960
- }
34961
- return res;
34962
- }
34963
-
34964
- /***
34965
- * 计算 cell border 距离 table 左侧距离
34966
- */
34967
- function getCumulativeWidths(columnWidths) {
34968
- var e_1, _a;
34969
- var cumulativeWidths = [];
34970
- var totalWidth = 0;
34971
- try {
34972
- for (var columnWidths_1 = __values$3(columnWidths), columnWidths_1_1 = columnWidths_1.next(); !columnWidths_1_1.done; columnWidths_1_1 = columnWidths_1.next()) {
34973
- var width = columnWidths_1_1.value;
34974
- totalWidth += width;
34975
- cumulativeWidths.push(totalWidth);
34976
- }
34977
- }
34978
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
34979
- finally {
34980
- try {
34981
- if (columnWidths_1_1 && !columnWidths_1_1.done && (_a = columnWidths_1.return)) _a.call(columnWidths_1);
34982
- }
34983
- finally { if (e_1) throw e_1.error; }
34984
- }
34985
- return cumulativeWidths;
34986
- }
34987
- /***
34988
- * 用于计算拖动 cell 时,cell 宽度变化的比例
36347
+ * 获取第一行所有 cells
36348
+ * @param tableNode table node
34989
36349
  */
34990
- function getColumnWidthRatios(columnWidths) {
34991
- var e_2, _a;
34992
- var columnWidthsRatio = [];
34993
- var totalWidth = columnWidths.reduce(function (a, b) { return a + b; }, 0);
34994
- try {
34995
- for (var columnWidths_2 = __values$3(columnWidths), columnWidths_2_1 = columnWidths_2.next(); !columnWidths_2_1.done; columnWidths_2_1 = columnWidths_2.next()) {
34996
- var width = columnWidths_2_1.value;
34997
- columnWidthsRatio.push(width / totalWidth);
34998
- }
34999
- }
35000
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
35001
- finally {
35002
- try {
35003
- if (columnWidths_2_1 && !columnWidths_2_1.done && (_a = columnWidths_2.return)) _a.call(columnWidths_2);
35004
- }
35005
- finally { if (e_2) throw e_2.error; }
35006
- }
35007
- return columnWidthsRatio;
35008
- }
35009
- /**
35010
- * 监听 table 内部变化,如新增行、列,删除行列等操作,引起的高度变化。
35011
- * ResizeObserver 需要即时释放,以免引起内存泄露
35012
- */
35013
- var resizeObserver = null;
35014
- function observerTableResize(editor, elm) {
35015
- if (elm instanceof HTMLElement) {
35016
- var table = elm.querySelector('table');
35017
- if (table) {
35018
- resizeObserver = new ResizeObserver(function (_a) {
35019
- var _b = __read$3(_a, 1), contentRect = _b[0].contentRect;
35020
- // 当非拖动引起的宽度变化,需要调整 columnWidths
35021
- Transforms.setNodes(editor, {
35022
- scrollWidth: contentRect.width,
35023
- height: contentRect.height,
35024
- }, { mode: 'highest' });
35025
- });
35026
- resizeObserver.observe(table);
35027
- }
35028
- }
35029
- }
35030
- function unObserveTableResize() {
35031
- if (resizeObserver) {
35032
- resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
35033
- resizeObserver = null;
35034
- }
35035
- }
35036
- // 是否为光标选区行为
35037
- var isSelectionOperation = false;
35038
- // 拖拽列宽相关信息
35039
- var isMouseDownForResize = false;
35040
- var clientXWhenMouseDown = 0;
35041
- var cellWidthWhenMouseDown = 0;
35042
- var editorWhenMouseDown = null;
35043
- var $window = $(window);
35044
- $window.on('mousedown', onMouseDown);
35045
- function onMouseDown(event) {
35046
- var elem = event.target;
35047
- // 判断是否为光标选区行为,对列宽变更行为进行过滤
35048
- // console.log('onMouseDown', elem)
35049
- if (elem.closest('[data-block-type="table-cell"]')) {
35050
- isSelectionOperation = true;
35051
- }
35052
- else if (elem.tagName == 'DIV' && elem.closest('.column-resizer-item')) {
35053
- if (editorWhenMouseDown == null)
35054
- return;
35055
- var _a = __read$3(Editor.nodes(editorWhenMouseDown, {
35056
- match: isOfType(editorWhenMouseDown, 'table'),
35057
- }), 1), _b = __read$3(_a[0], 1), elemNode = _b[0];
35058
- 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;
35059
- /**
35060
- * table width 为 100% 模式时,因无法增加Table宽度,不触发 列宽变更行为
35061
- * 如需变更,到底哪个列增宽度,哪个列减去宽度??
35062
- */
35063
- if (tableWidth == '100%')
35064
- return;
35065
- // 记录必要信息
35066
- isMouseDownForResize = true;
35067
- var clientX = event.clientX;
35068
- clientXWhenMouseDown = clientX;
35069
- cellWidthWhenMouseDown = columnWidths[resizingIndex];
35070
- document.body.style.cursor = 'col-resize';
35071
- event.preventDefault();
35072
- }
35073
- $window.on('mousemove', onMouseMove);
35074
- $window.on('mouseup', onMouseUp);
35075
- }
35076
- var onMouseMove = lodash_throttle(function (event) {
35077
- if (!isMouseDownForResize)
35078
- return;
35079
- if (editorWhenMouseDown == null)
35080
- return;
35081
- event.preventDefault();
35082
- var clientX = event.clientX;
35083
- var newWith = cellWidthWhenMouseDown + (clientX - clientXWhenMouseDown); // 计算新宽度
35084
- newWith = Math.floor(newWith * 100) / 100; // 保留小数点后两位
35085
- if (newWith < 30)
35086
- newWith = 30; // 最小宽度
35087
- var _a = __read$3(Editor.nodes(editorWhenMouseDown, {
35088
- match: isOfType(editorWhenMouseDown, 'table'),
35089
- }), 1), _b = __read$3(_a[0], 1), elemNode = _b[0];
35090
- 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;
35091
- /**
35092
- * 判断拖动引起的宽度是否最大化了
35093
- * 如果最大化了,则需要调整列的宽度
35094
- *
35095
- * 0.5 很微妙
35096
- */
35097
- var cumulativeTotalWidth = columnWidths.reduce(function (a, b) { return a + b; }, 0);
35098
- var remainWidth = cumulativeTotalWidth - columnWidths[resizingIndex];
35099
- if (cumulativeTotalWidth > scrollWidth && remainWidth + newWith > scrollWidth) {
35100
- newWith = scrollWidth - remainWidth + 0.5;
35101
- }
35102
- var adjustColumnWidths = __spreadArray([], __read$3(columnWidths)).map(function (width) { return Math.floor(width); });
35103
- adjustColumnWidths[resizingIndex] = newWith;
35104
- // 这是宽度
35105
- Transforms.setNodes(editorWhenMouseDown, { columnWidths: adjustColumnWidths }, {
35106
- mode: 'highest',
35107
- });
35108
- }, 100);
35109
- function onMouseUp(event) {
35110
- isSelectionOperation = false;
35111
- isMouseDownForResize = false;
35112
- editorWhenMouseDown = null;
35113
- document.body.style.cursor = '';
35114
- // 解绑事件
35115
- $window.off('mousemove', onMouseMove);
35116
- $window.off('mouseup', onMouseUp);
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;
35117
36357
  }
35118
36358
  /**
35119
- * 鼠标移动时,判断在哪个 Cell border 上
35120
- * Class visible 后 highlight @跟随飞书
35121
- * 避免光标选区功能收到干扰
36359
+ * 表格是否带有表头?
36360
+ * @param tableNode table node
35122
36361
  */
35123
- function handleCellBorderVisible(editor, elemNode, e) {
35124
- if (editor.isDisabled())
35125
- return;
35126
- if (isSelectionOperation || isMouseDownForResize)
35127
- return;
35128
- 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;
35129
- /**
35130
- * table width 为 100% 模式时,因无法增加Table宽度,不触发 列宽变更行为
35131
- * 如需变更,到底哪个列增宽度,哪个列减去宽度??
35132
- */
35133
- if (tableWidth == '100%')
35134
- return;
35135
- // Cell Border 宽度为 10px
35136
- var clientX = e.clientX, target = e.target;
35137
- // 当单元格合并的时候,鼠标在 cell 中间,则不显示 cell border
35138
- if (target instanceof HTMLElement) {
35139
- var rect = target.getBoundingClientRect();
35140
- if (clientX > rect.x + 5 && clientX < rect.x + rect.width - 5) {
35141
- if (isHoverCellBorder) {
35142
- Transforms.setNodes(editor, { isHoverCellBorder: false, resizingIndex: -1 }, { mode: 'highest' });
35143
- }
35144
- return;
35145
- }
35146
- }
35147
- if (target instanceof HTMLElement) {
35148
- var parent_1 = target.closest('.table');
35149
- if (parent_1) {
35150
- var clientX_1 = e.clientX;
35151
- var rect = parent_1.getBoundingClientRect();
35152
- var cumulativeWidths = getCumulativeWidths(columnWidths);
35153
- // 鼠标移动时,计算当前鼠标位置,判断在哪个 Cell border 上
35154
- for (var i = 0; i < cumulativeWidths.length; i++) {
35155
- if (clientX_1 - rect.x >= cumulativeWidths[i] - 5 &&
35156
- clientX_1 - rect.x < cumulativeWidths[i] + 5) {
35157
- // 节流,防止多次引起Transforms.setNodes重绘
35158
- if (resizingIndex == i)
35159
- return;
35160
- Transforms.setNodes(editor, { isHoverCellBorder: true, resizingIndex: i }, { mode: 'highest' });
35161
- return;
35162
- }
35163
- }
35164
- }
35165
- }
35166
- // 鼠标移出时,重置
35167
- if (isHoverCellBorder == true) {
35168
- Transforms.setNodes(editor, { isHoverCellBorder: false, resizingIndex: -1 }, {
35169
- mode: 'highest',
35170
- });
35171
- }
36362
+ function isTableWithHeader(tableNode) {
36363
+ var firstRowCells = getFirstRowCells(tableNode);
36364
+ return firstRowCells.every(function (cell) { return !!cell.isHeader; });
35172
36365
  }
35173
36366
  /**
35174
- * 设置 class highlight
35175
- * render-cell.tsx 拖动功能迁移至 div.column-resize
36367
+ * 单元格是否在第一行
36368
+ * @param editor editor
36369
+ * @param cellNode cell node
35176
36370
  */
35177
- function handleCellBorderHighlight(editor, e) {
35178
- if (e.type === 'mouseenter') {
35179
- Transforms.setNodes(editor, { isResizing: true }, { mode: 'highest' });
35180
- }
35181
- else {
35182
- Transforms.setNodes(editor, { isResizing: false }, { mode: 'highest' });
35183
- }
35184
- }
35185
- function handleCellBorderMouseDown(editor, elemNode) {
35186
- if (isMouseDownForResize)
35187
- return; // 此时正在修改列宽
35188
- editorWhenMouseDown = editor;
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; });
35189
36380
  }
35190
36381
 
35191
36382
  /**
@@ -35209,8 +36400,8 @@ function getContentEditable(editor, tableElem) {
35209
36400
  var tablePath = DomEditor.findPath(editor, tableElem);
35210
36401
  var tableStart = Editor.start(editor, tablePath);
35211
36402
  var tableEnd = Editor.end(editor, tablePath);
35212
- var isAnchorInTable = Point$1.compare(anchor, tableEnd) <= 0 && Point$1.compare(anchor, tableStart) >= 0;
35213
- var isFocusInTable = Point$1.compare(focus, tableEnd) <= 0 && Point$1.compare(focus, tableStart) >= 0;
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
36405
  // 选区在 table 内部,且选中了同一个单元格。表格可以编辑
35215
36406
  if (isAnchorInTable && isFocusInTable) {
35216
36407
  if (Path.equals(anchor.path.slice(0, 3), focus.path.slice(0, 3))) {
@@ -35223,13 +36414,11 @@ function renderTable(elemNode, children, editor) {
35223
36414
  // 是否可编辑
35224
36415
  var editable = getContentEditable(editor, elemNode);
35225
36416
  // 宽度
35226
- 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;
35227
- // 光标是否选中
36417
+ var _a = elemNode.width, width = _a === void 0 ? 'auto' : _a;
36418
+ // 是否选中
35228
36419
  var selected = DomEditor.isNodeSelected(editor, elemNode);
35229
- // 光标是否有选区
35230
- var _e = __read$3(TableCursor.selection(editor), 1), isSelecting = _e[0];
35231
- // 列宽之间比值
35232
- var columnWidthRatios = getColumnWidthRatios(columnWidths);
36420
+ // 第一行的 cells ,以计算列宽
36421
+ var firstRowCells = getFirstRowCells(elemNode);
35233
36422
  var vnode = (jsx("div", { className: "table-container", "data-selected": selected, on: {
35234
36423
  mousedown: function (e) {
35235
36424
  // @ts-ignore 阻止光标定位到 table 后面
@@ -35237,10 +36426,6 @@ function renderTable(elemNode, children, editor) {
35237
36426
  e.preventDefault();
35238
36427
  if (editor.isDisabled())
35239
36428
  return;
35240
- // @ts-ignore 如果用户行为是获取焦点输入文本时,需释放选区
35241
- if (e.target.closest('[data-block-type="table-cell"]')) {
35242
- TableCursor.unselect(editor);
35243
- }
35244
36429
  // 是否需要定位到 table 内部
35245
36430
  var tablePath = DomEditor.findPath(editor, elemNode);
35246
36431
  var tableStart = Editor.start(editor, tablePath);
@@ -35255,64 +36440,13 @@ function renderTable(elemNode, children, editor) {
35255
36440
  editor.select(tableStart); // 选中 table 内部
35256
36441
  },
35257
36442
  } },
35258
- jsx("table", { width: tableWidth, contentEditable: editable,
35259
- /**
35260
- * 1. 当表格处于选区状态,屏蔽 Chrome 自带的样式
35261
- * 2. table 宽度为 auto 时,宽度为 列宽之和
35262
- * 3. 鼠标移动到 单元格 边缘,设置 visible className
35263
- */
35264
- className: 'table ' + (isSelecting ? 'table-selection-none' : ''), style: {
35265
- width: tableWidth == '100%' ? '' : columnWidths.reduce(function (a, b) { return a + b; }, 0) + 'px',
35266
- }, on: {
35267
- mousemove: lodash_debounce(function (e) { return handleCellBorderVisible(editor, elemNode, e); }, 25),
35268
- } },
35269
- jsx("colgroup", { contentEditable: false },
35270
- /**
35271
- * 剔除 firstRowCells,因单元格合并 表头 th,会计算错误。
35272
- * 使用 columnWidth 数组长度代表列数
35273
- * 拖动行为及变量设置均参考 飞书
35274
- */
35275
- columnWidths.map(function (width) {
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;
35276
36446
  return jsx("col", { width: width });
35277
36447
  })),
35278
- jsx("tbody", null, children)),
35279
- jsx("div", { className: "column-resizer", contenteditable: "false" }, columnWidths.map(function (width, index) {
35280
- var minWidth = width;
35281
- /**
35282
- * table width 为 100% 模式时
35283
- * columnWidths 表示的是比例
35284
- * 1. 需要计算出真实的宽度
35285
- */
35286
- if (tableWidth == '100%') {
35287
- minWidth = columnWidthRatios[index] * scrollWidth;
35288
- }
35289
- return (jsx("div", { className: "column-resizer-item", style: { minWidth: minWidth + "px" } },
35290
- jsx("div", { className: 'resizer-line-hotzone ' +
35291
- (isHoverCellBorder && index == resizingIndex ? 'visible ' : '') +
35292
- (isResizing && index == resizingIndex ? 'highlight' : ''), style: { height: height + 'px' }, on: {
35293
- mouseenter: function (e) { return handleCellBorderHighlight(editor, e); },
35294
- mouseleave: function (e) { return handleCellBorderHighlight(editor, e); },
35295
- mousedown: function (e) { return handleCellBorderMouseDown(editor); },
35296
- } },
35297
- jsx("div", { className: "resizer-line" }))));
35298
- }))));
35299
- /**
35300
- * 移出直接返回 vnode
35301
- * 添加 ObserverResize 监听行为
35302
- * 监听 table 内部变化,更新 table resize-bar 高度
35303
- */
35304
- var containerVnode = h('div', {
35305
- hook: {
35306
- insert: function (_a) {
35307
- var elm = _a.elm;
35308
- return observerTableResize(editor, elm);
35309
- },
35310
- destroy: function () {
35311
- unObserveTableResize();
35312
- },
35313
- },
35314
- }, vnode);
35315
- return containerVnode;
36448
+ jsx("tbody", null, children))));
36449
+ return vnode;
35316
36450
  }
35317
36451
 
35318
36452
  /**
@@ -35325,60 +36459,154 @@ function renderTableRow(elemNode, children, editor) {
35325
36459
  }
35326
36460
 
35327
36461
  /**
35328
- * @description table menu helpers
36462
+ * @description DOM 操作
35329
36463
  * @author wangfupeng
35330
36464
  */
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;
35331
36489
  /**
35332
- * 获取第一行所有 cells
35333
- * @param tableNode table node
35334
- */
35335
- function getFirstRowCells(tableNode) {
35336
- var rows = tableNode.children || []; // 所有行
35337
- if (rows.length === 0)
35338
- return [];
35339
- var firstRow = rows[0] || {}; // 第一行
35340
- var cells = firstRow.children || []; // 第一行所有 cell
35341
- return cells;
35342
- }
35343
- /**
35344
- * 表格是否带有表头?
35345
- * @param tableNode table node
36490
+ * 获取 tagName lower-case
36491
+ * @param $elem $elem
35346
36492
  */
35347
- function isTableWithHeader(tableNode) {
35348
- var firstRowCells = getFirstRowCells(tableNode);
35349
- return firstRowCells.every(function (cell) { return !!cell.isHeader; });
36493
+ function getTagName$1($elem) {
36494
+ if ($elem.length)
36495
+ return $elem[0].tagName.toLowerCase();
36496
+ return '';
35350
36497
  }
35351
36498
  /**
35352
- * 单元格是否在第一行
35353
- * @param editor editor
35354
- * @param cellNode cell node
36499
+ * 获取 $elem 某一个 style 值
36500
+ * @param $elem $elem
36501
+ * @param styleKey style key
35355
36502
  */
35356
- function isCellInFirstRow(editor, cellNode) {
35357
- var rowNode = DomEditor.getParentNode(editor, cellNode);
35358
- if (rowNode == null)
35359
- return false;
35360
- var tableNode = DomEditor.getParentNode(editor, rowNode);
35361
- if (tableNode == null)
35362
- return false;
35363
- var firstRowCells = getFirstRowCells(tableNode);
35364
- return firstRowCells.some(function (c) { return c === cellNode; });
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;
35365
36518
  }
35366
36519
 
35367
36520
  /**
35368
36521
  * @description render cell
35369
36522
  * @author wangfupeng
35370
36523
  */
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);
35371
36574
  function renderTableCell(cellNode, children, editor) {
35372
36575
  var isFirstRow = isCellInFirstRow(editor, cellNode);
35373
- 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;
35374
- var selected = TableCursor.isSelected(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
36577
  // ------------------ 不是第一行,直接渲染 <td> ------------------
35376
36578
  if (!isFirstRow) {
35377
- return (jsx("td", { colSpan: colSpan, rowSpan: rowSpan, "data-block-type": "table-cell", className: selected ? 'w-e-selected' : '', style: { display: hidden ? 'none' : '' } }, children));
36579
+ return (jsx("td", { colSpan: colSpan, rowSpan: rowSpan }, children));
35378
36580
  }
35379
36581
  // ------------------ 是第一行:1. 判断 th ;2. 拖拽列宽 ------------------
35380
36582
  var Tag = isHeader ? 'th' : 'td';
35381
- var vnode = (jsx(Tag, { colSpan: colSpan, rowSpan: rowSpan, "data-block-type": "table-cell", className: selected ? 'w-e-selected' : '', style: { display: hidden ? 'none' : '' } }, children));
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));
35382
36610
  return vnode;
35383
36611
  }
35384
36612
 
@@ -35405,16 +36633,15 @@ var renderTableCellConf = {
35405
36633
  */
35406
36634
  function tableToHtml(elemNode, childrenHtml) {
35407
36635
  var _a = elemNode.width, width = _a === void 0 ? 'auto' : _a;
35408
- return "<table style=\"width: " + width + ";table-layout: fixed;\"><tbody>" + childrenHtml + "</tbody></table>";
36636
+ return "<table style=\"width: " + width + ";\"><tbody>" + childrenHtml + "</tbody></table>";
35409
36637
  }
35410
36638
  function tableRowToHtml(elem, childrenHtml) {
35411
36639
  return "<tr>" + childrenHtml + "</tr>";
35412
36640
  }
35413
36641
  function tableCellToHtml(cellNode, childrenHtml) {
35414
- 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;
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;
35415
36643
  var tag = isHeader ? 'th' : 'td';
35416
- var style = hidden ? 'display:none' : '';
35417
- return "<" + tag + " colSpan=\"" + colSpan + "\" rowSpan=\"" + rowSpan + "\" width=\"" + width + "\" style=\"" + style + "\">" + childrenHtml + "</" + tag + ">";
36644
+ return "<" + tag + " colSpan=\"" + colSpan + "\" rowSpan=\"" + rowSpan + "\" width=\"" + width + "\">" + childrenHtml + "</" + tag + ">";
35418
36645
  }
35419
36646
  var tableToHtmlConf = {
35420
36647
  type: 'table',
@@ -35503,7 +36730,6 @@ var parseRowHtmlConf = {
35503
36730
  parseElemHtml: parseRowHtml,
35504
36731
  };
35505
36732
  function parseTableHtml(elem, children, editor) {
35506
- var _a;
35507
36733
  var $elem = $(elem);
35508
36734
  // 计算宽度
35509
36735
  var width = 'auto';
@@ -35511,17 +36737,12 @@ function parseTableHtml(elem, children, editor) {
35511
36737
  width = '100%';
35512
36738
  if ($elem.attr('width') === '100%')
35513
36739
  width = '100%'; // 兼容 v4 格式
35514
- var tableELement = {
36740
+ return {
35515
36741
  type: 'table',
35516
36742
  width: width,
35517
36743
  // @ts-ignore
35518
36744
  children: children.filter(function (child) { return DomEditor.getNodeType(child) === 'table-row'; }),
35519
36745
  };
35520
- var cellLength = (_a = $elem.find('tr')[0]) === null || _a === void 0 ? void 0 : _a.children.length;
35521
- if (cellLength > 0) {
35522
- tableELement.columnWidths = Array(cellLength).fill(180);
35523
- }
35524
- return tableELement;
35525
36746
  }
35526
36747
  var parseTableHtmlConf = {
35527
36748
  selector: 'table:not([data-w-e-type])',
@@ -35552,11 +36773,7 @@ var DEL_COL_SVG = '<svg viewBox="0 0 1048 1024"><path d="M327.68 510.976L393.216
35552
36773
  // 表头
35553
36774
  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>';
35554
36775
  // 宽度
35555
- 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>';
35556
- // 合并单元格
35557
- 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>';
35558
- // 拆分单元格
35559
- 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>';
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>';
35560
36777
 
35561
36778
  /**
35562
36779
  * @description insert table menu
@@ -35565,7 +36782,6 @@ var SPLIT_CELL_SVG = '<svg viewBox="0 0 1024 1024"><path d="M362.667 494.933v53.
35565
36782
  function genTableNode(rowNum, colNum) {
35566
36783
  // 拼接 rows
35567
36784
  var rows = [];
35568
- var columnWidths = Array(colNum).fill(60);
35569
36785
  for (var i = 0; i < rowNum; i++) {
35570
36786
  // 拼接 cells
35571
36787
  var cells = [];
@@ -35589,7 +36805,6 @@ function genTableNode(rowNum, colNum) {
35589
36805
  type: 'table',
35590
36806
  width: 'auto',
35591
36807
  children: rows,
35592
- columnWidths: columnWidths,
35593
36808
  };
35594
36809
  }
35595
36810
  var InsertTable = /** @class */ (function () {
@@ -35711,12 +36926,6 @@ var InsertTable = /** @class */ (function () {
35711
36926
  if (DomEditor.isSelectedEmptyParagraph(editor)) {
35712
36927
  Transforms.removeNodes(editor, { mode: 'highest' });
35713
36928
  }
35714
- if (editor.children.length === 0) {
35715
- // table 作为第一个 children 时会导致无法正常删除
35716
- // 在当前位置插入空行,当前元素下移
35717
- var newElem = { type: 'paragraph', children: [{ text: '' }] };
35718
- Transforms.insertNodes(editor, newElem, { mode: 'highest' });
35719
- }
35720
36929
  // 插入表格
35721
36930
  var tableNode = genTableNode(rowNum, colNum);
35722
36931
  Transforms.insertNodes(editor, tableNode, { mode: 'highest' });
@@ -35805,56 +37014,19 @@ var InsertRow = /** @class */ (function () {
35805
37014
  var cellsLength = (rowNode === null || rowNode === void 0 ? void 0 : rowNode.children.length) || 0;
35806
37015
  if (cellsLength === 0)
35807
37016
  return;
35808
- var matrix = filledMatrix(editor);
35809
- // 向下插入行为,先找到
35810
- // 当前选区所在的 tr 索引
35811
- var trIndex = 0;
35812
- outer: for (var x = 0; x < matrix.length; x++) {
35813
- for (var y = 0; y < matrix[x].length; y++) {
35814
- var _c = __read$3(matrix[x][y], 1), _d = __read$3(_c[0], 2), path = _d[1];
35815
- if (!Path.equals(cellPath, path)) {
35816
- continue;
35817
- }
35818
- trIndex = x;
35819
- break outer;
35820
- }
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);
35821
37025
  }
35822
- Editor.withoutNormalizing(editor, function () {
35823
- // 向下添加 tr 索引
35824
- var destIndex = trIndex + 1;
35825
- var isWithinBounds = destIndex >= 0 && destIndex < matrix.length;
35826
- var exitMerge = [];
35827
- for (var y = 0; isWithinBounds && y < matrix[trIndex].length; y++) {
35828
- var _a = __read$3(matrix[trIndex][y], 2), _b = _a[1], ttb = _b.ttb, btt = _b.btt;
35829
- // 向上找到 1 元素为止
35830
- if (ttb > 1 || btt > 1) {
35831
- if (btt == 1)
35832
- continue;
35833
- var _c = __read$3(matrix[trIndex - (ttb - 1)][y], 1), _d = __read$3(_c[0], 2), element = _d[0], path = _d[1];
35834
- var rowSpan = element.rowSpan || 1;
35835
- exitMerge.push(y);
35836
- if (!element.hidden) {
35837
- Transforms.setNodes(editor, {
35838
- rowSpan: rowSpan + 1,
35839
- }, { at: path });
35840
- }
35841
- }
35842
- }
35843
- // 拼接新的 row
35844
- var newRow = { type: 'table-row', children: [] };
35845
- for (var i = 0; i < cellsLength; i++) {
35846
- var cell = {
35847
- type: 'table-cell',
35848
- hidden: exitMerge.includes(i),
35849
- children: [{ text: '' }],
35850
- };
35851
- newRow.children.push(cell);
35852
- }
35853
- // 插入 row
35854
- var rowPath = Path.parent(cellPath); // 获取 tr 的 path
35855
- var newRowPath = Path.next(rowPath);
35856
- Transforms.insertNodes(editor, newRow, { at: newRowPath });
35857
- });
37026
+ // 插入 row
37027
+ var rowPath = Path.parent(cellPath); // 获取 tr 的 path
37028
+ var newRowPath = Path.next(rowPath);
37029
+ Transforms.insertNodes(editor, newRow, { at: newRowPath });
35858
37030
  };
35859
37031
  return InsertRow;
35860
37032
  }());
@@ -35906,67 +37078,7 @@ var DeleteRow = /** @class */ (function () {
35906
37078
  return;
35907
37079
  }
35908
37080
  // row > 1 行,则删掉这一行
35909
- var _c = __read$3(Editor.nodes(editor, {
35910
- match: function (n) { return DomEditor.checkNodeType(n, 'table-cell'); },
35911
- universal: true,
35912
- }), 1), cellEntry = _c[0];
35913
- var _d = __read$3(cellEntry, 2), cellPath = _d[1];
35914
- var matrix = filledMatrix(editor);
35915
- var trIndex = 0;
35916
- outer: for (var x = 0; x < matrix.length; x++) {
35917
- for (var y = 0; y < matrix[x].length; y++) {
35918
- var _e = __read$3(matrix[x][y], 1), _f = __read$3(_e[0], 2), path = _f[1];
35919
- if (!Path.equals(cellPath, path)) {
35920
- continue;
35921
- }
35922
- trIndex = x;
35923
- break outer;
35924
- }
35925
- }
35926
- Editor.withoutNormalizing(editor, function () {
35927
- var e_1, _a;
35928
- for (var y = 0; y < matrix[trIndex].length; y++) {
35929
- 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;
35930
- // 寻找跨行行为
35931
- if (ttb > 1 || btt > 1) {
35932
- // 找到显示中 rowSpan 节点
35933
- 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];
35934
- // 如果当前选中节点为隐藏节点,则向上寻找处理 rowSpan 逻辑
35935
- if (hidden) {
35936
- Transforms.setNodes(editor, {
35937
- rowSpan: Math.max(rowSpan - 1, 1),
35938
- colSpan: colSpan,
35939
- }, { at: path });
35940
- }
35941
- else {
35942
- var _k = __read$3(matrix[trIndex + 1][y], 1), _l = __read$3(_k[0], 2), belowPath = _l[1];
35943
- Transforms.setNodes(editor, {
35944
- rowSpan: rowSpan - 1,
35945
- colSpan: colSpan,
35946
- hidden: false,
35947
- }, { at: belowPath });
35948
- try {
35949
- // 移动单元格 文本、图片等元素
35950
- for (var _m = (e_1 = void 0, __values$3(Node$1.children(editor, path, { reverse: true }))), _o = _m.next(); !_o.done; _o = _m.next()) {
35951
- var _p = __read$3(_o.value, 2), childPath = _p[1];
35952
- Transforms.moveNodes(editor, {
35953
- to: __spreadArray(__spreadArray([], __read$3(belowPath)), [0]),
35954
- at: childPath,
35955
- });
35956
- }
35957
- }
35958
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
35959
- finally {
35960
- try {
35961
- if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
35962
- }
35963
- finally { if (e_1) throw e_1.error; }
35964
- }
35965
- }
35966
- }
35967
- }
35968
- Transforms.removeNodes(editor, { at: rowPath });
35969
- });
37081
+ Transforms.removeNodes(editor, { at: rowPath });
35970
37082
  };
35971
37083
  return DeleteRow;
35972
37084
  }());
@@ -36016,62 +37128,27 @@ var InsertCol = /** @class */ (function () {
36016
37128
  var tableNode = DomEditor.getParentNode(editor, rowNode);
36017
37129
  if (tableNode == null)
36018
37130
  return;
36019
- var matrix = filledMatrix(editor);
36020
- var tdIndex = 0;
36021
- out: for (var x = 0; x < matrix.length; x++) {
36022
- for (var y = 0; y < matrix[x].length; y++) {
36023
- var _c = __read$3(matrix[x][y], 1), _d = __read$3(_c[0], 2), path = _d[1];
36024
- if (Path.equals(selectedCellPath, path)) {
36025
- tdIndex = y;
36026
- break out;
36027
- }
36028
- }
36029
- }
36030
- Editor.withoutNormalizing(editor, function () {
36031
- var exitMerge = [];
36032
- for (var x = 0; x < matrix.length; x++) {
36033
- var _a = __read$3(matrix[x][tdIndex], 2), _b = _a[1], ltr = _b.ltr, rtl = _b.rtl;
36034
- // 向左找到 1 元素为止
36035
- if (ltr > 1 || rtl > 1) {
36036
- if (rtl == 1)
36037
- continue;
36038
- var _c = __read$3(matrix[x][tdIndex - (rtl - 1)], 1), _d = __read$3(_c[0], 2), element = _d[0], path = _d[1];
36039
- var colSpan = element.colSpan || 1;
36040
- exitMerge.push(x);
36041
- if (!element.hidden) {
36042
- Transforms.setNodes(editor, {
36043
- colSpan: colSpan + 1,
36044
- }, { at: path });
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;
36045
37148
  }
37149
+ Transforms.insertNodes(editor, newCell, { at: path });
36046
37150
  }
36047
- }
36048
- // 遍历所有 rows ,挨个添加 cell
36049
- for (var x = 0; x < matrix.length; x++) {
36050
- var newCell = {
36051
- type: 'table-cell',
36052
- hidden: exitMerge.includes(x),
36053
- children: [{ text: '' }],
36054
- };
36055
- if (x === 0 && isTableWithHeader(tableNode)) {
36056
- newCell.isHeader = true;
36057
- }
36058
- var _e = __read$3(matrix[x][tdIndex], 1), _f = __read$3(_e[0], 2), insertPath = _f[1];
36059
- Transforms.insertNodes(editor, newCell, { at: insertPath });
36060
- }
36061
- // 需要调整 columnWidths
36062
- var _g = __read$3(Editor.nodes(editor, {
36063
- match: function (n) { return DomEditor.checkNodeType(n, 'table'); },
36064
- universal: true,
36065
- }), 1), tableEntry = _g[0];
36066
- if (tableEntry) {
36067
- var _h = __read$3(tableEntry, 2), elemNode = _h[0], tablePath = _h[1];
36068
- var _j = elemNode.columnWidths, columnWidths = _j === void 0 ? [] : _j;
36069
- var adjustColumnWidths = __spreadArray([], __read$3(columnWidths));
36070
- adjustColumnWidths.splice(tdIndex, 0, 60);
36071
- Transforms.setNodes(editor, { columnWidths: adjustColumnWidths }, {
36072
- at: tablePath,
36073
- });
36074
- }
37151
+ });
36075
37152
  });
36076
37153
  };
36077
37154
  return InsertCol;
@@ -36127,76 +37204,23 @@ var DeleteCol = /** @class */ (function () {
36127
37204
  var tableNode = DomEditor.getParentNode(editor, rowNode);
36128
37205
  if (tableNode == null)
36129
37206
  return;
36130
- var matrix = filledMatrix(editor);
36131
- var tdIndex = 0;
36132
- out: for (var x = 0; x < matrix.length; x++) {
36133
- for (var y = 0; y < matrix[x].length; y++) {
36134
- var _c = __read$3(matrix[x][y], 1), _d = __read$3(_c[0], 2), path = _d[1];
36135
- if (Path.equals(selectedCellPath, path)) {
36136
- tdIndex = y;
36137
- break out;
36138
- }
36139
- }
36140
- }
36141
- Editor.withoutNormalizing(editor, function () {
36142
- var e_1, _a;
36143
- for (var x = 0; x < matrix.length; x++) {
36144
- 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;
36145
- if (rtl > 1 || ltr > 1) {
36146
- // 找到显示中 colSpan 节点
36147
- 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];
36148
- if (hidden) {
36149
- Transforms.setNodes(editor, {
36150
- rowSpan: rowSpan,
36151
- colSpan: Math.max(colSpan - 1, 1),
36152
- }, { at: path });
36153
- }
36154
- else {
36155
- var _k = __read$3(matrix[x][tdIndex + 1], 1), _l = __read$3(_k[0], 2), rightPath = _l[1];
36156
- Transforms.setNodes(editor, {
36157
- rowSpan: rowSpan,
36158
- colSpan: colSpan - 1,
36159
- hidden: false,
36160
- }, { at: rightPath });
36161
- try {
36162
- // 移动单元格 文本、图片等元素
36163
- for (var _m = (e_1 = void 0, __values$3(Node$1.children(editor, path, { reverse: true }))), _o = _m.next(); !_o.done; _o = _m.next()) {
36164
- var _p = __read$3(_o.value, 2), childPath = _p[1];
36165
- Transforms.moveNodes(editor, {
36166
- to: __spreadArray(__spreadArray([], __read$3(rightPath)), [0]),
36167
- at: childPath,
36168
- });
36169
- }
36170
- }
36171
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
36172
- finally {
36173
- try {
36174
- if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
36175
- }
36176
- finally { if (e_1) throw e_1.error; }
36177
- }
36178
- }
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 });
36179
37222
  }
36180
- }
36181
- // 挨个删除 cell
36182
- for (var x = 0; x < matrix.length; x++) {
36183
- var _q = __read$3(matrix[x][tdIndex], 1), _r = __read$3(_q[0], 2), path = _r[1];
36184
- Transforms.removeNodes(editor, { at: path });
36185
- }
36186
- // 需要调整 columnWidths
36187
- var _s = __read$3(Editor.nodes(editor, {
36188
- match: function (n) { return DomEditor.checkNodeType(n, 'table'); },
36189
- universal: true,
36190
- }), 1), tableEntry = _s[0];
36191
- if (tableEntry) {
36192
- var _t = __read$3(tableEntry, 2), elemNode = _t[0], tablePath = _t[1];
36193
- var _u = elemNode.columnWidths, columnWidths = _u === void 0 ? [] : _u;
36194
- var adjustColumnWidths = __spreadArray([], __read$3(columnWidths));
36195
- adjustColumnWidths.splice(tdIndex, 1);
36196
- Transforms.setNodes(editor, { columnWidths: adjustColumnWidths }, {
36197
- at: tablePath,
36198
- });
36199
- }
37223
+ });
36200
37224
  });
36201
37225
  };
36202
37226
  return DeleteCol;
@@ -36299,234 +37323,6 @@ var TableFullWidth = /** @class */ (function () {
36299
37323
  return TableFullWidth;
36300
37324
  }());
36301
37325
 
36302
- var MergeCell = /** @class */ (function () {
36303
- function MergeCell() {
36304
- this.title = t('tableModule.mergeCell');
36305
- this.iconSvg = MERGE_CELL_SVG;
36306
- this.tag = 'button';
36307
- }
36308
- MergeCell.prototype.getValue = function (editor) {
36309
- // 无需获取 val
36310
- return '';
36311
- };
36312
- MergeCell.prototype.isActive = function (editor) {
36313
- // 无需 active
36314
- return false;
36315
- };
36316
- MergeCell.prototype.isDisabled = function (editor) {
36317
- return !this.canMerge(editor);
36318
- };
36319
- MergeCell.prototype.exec = function (editor, value) {
36320
- if (this.isDisabled(editor))
36321
- return;
36322
- this.merge(editor);
36323
- // 释放选区
36324
- TableCursor.unselect(editor);
36325
- };
36326
- /**
36327
- * Checks if the current selection can be merged. Merging is not possible when any of the following conditions are met:
36328
- * - The selection is empty.
36329
- * - The selection is not within the same "thead", "tbody," or "tfoot" section.
36330
- * @returns {boolean} `true` if the selection can be merged, otherwise `false`.
36331
- */
36332
- MergeCell.prototype.canMerge = function (editor) {
36333
- var matrix = EDITOR_TO_SELECTION.get(editor);
36334
- // cannot merge when selection is empty
36335
- if (!matrix || !matrix.length) {
36336
- return false;
36337
- }
36338
- // prettier-ignore
36339
- var _a = __read$3(matrix[matrix.length - 1][matrix[matrix.length - 1].length - 1], 1), _b = __read$3(_a[0], 2), lastPath = _b[1];
36340
- var _c = __read$3(matrix[0][0], 1), _d = __read$3(_c[0], 2), firstPath = _d[1];
36341
- // cannot merge when selection is not in common section
36342
- if (!hasCommon(editor, [firstPath, lastPath], 'table')) {
36343
- return false;
36344
- }
36345
- return true;
36346
- };
36347
- /**
36348
- * Merges the selected cells in the table.
36349
- * @returns void
36350
- */
36351
- MergeCell.prototype.merge = function (editor) {
36352
- if (!this.canMerge(editor)) {
36353
- return;
36354
- }
36355
- var selection = EDITOR_TO_SELECTION.get(editor);
36356
- if (!selection || !selection.length) {
36357
- return;
36358
- }
36359
- var _a = __read$3(selection[0][0], 1), _b = __read$3(_a[0], 2), basePath = _b[1];
36360
- var _c = __read$3(Node$1.children(editor, basePath, { reverse: true }), 1), _d = __read$3(_c[0], 2), lastPath = _d[1];
36361
- filledMatrix(editor, { at: basePath });
36362
- Editor.withoutNormalizing(editor, function () {
36363
- var e_1, _a;
36364
- var rowSpan = 0;
36365
- var colSpan = 0;
36366
- for (var x = selection.length - 1; x >= 0; x--, rowSpan++) {
36367
- colSpan = 0;
36368
- for (var y = selection[x].length - 1; y >= 0; y--, colSpan++) {
36369
- var _b = __read$3(selection[x][y], 2), _c = __read$3(_b[0], 2), path = _c[1], ttb = _b[1].ttb;
36370
- // skip first cell and "fake" cells which belong to a cell with a `rowspan`
36371
- if (Path.equals(basePath, path) || ttb > 1) {
36372
- continue;
36373
- }
36374
- try {
36375
- // prettier-ignore
36376
- for (var _d = (e_1 = void 0, __values$3(Node$1.children(editor, path, { reverse: true }))), _e = _d.next(); !_e.done; _e = _d.next()) {
36377
- var _f = __read$3(_e.value, 2), childPath = _f[1];
36378
- Transforms.moveNodes(editor, {
36379
- to: Path.next(lastPath),
36380
- at: childPath,
36381
- });
36382
- }
36383
- }
36384
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
36385
- finally {
36386
- try {
36387
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
36388
- }
36389
- finally { if (e_1) throw e_1.error; }
36390
- }
36391
- var _g = __read$3(Editor.nodes(editor, {
36392
- match: isOfType(editor, 'tr'),
36393
- at: path,
36394
- }), 1), _h = __read$3(_g[0], 2), trPath = _h[1];
36395
- var _j = __read$3(Node$1.children(editor, trPath), 2), sibling = _j[1];
36396
- if (sibling) {
36397
- /**
36398
- * 删除节点调整成隐藏节点
36399
- * 隐藏节点不会影响 table 布局
36400
- */
36401
- Transforms.setNodes(editor, { hidden: true }, { at: path });
36402
- continue;
36403
- }
36404
- }
36405
- }
36406
- Transforms.setNodes(editor, { rowSpan: rowSpan, colSpan: colSpan }, { at: basePath });
36407
- });
36408
- };
36409
- return MergeCell;
36410
- }());
36411
-
36412
- // import { DEFAULT_WITH_TABLE_OPTIONS } from "../../utils/options";
36413
- var SplitCell = /** @class */ (function () {
36414
- function SplitCell() {
36415
- this.title = t('tableModule.splitCell');
36416
- this.iconSvg = SPLIT_CELL_SVG;
36417
- this.tag = 'button';
36418
- }
36419
- SplitCell.prototype.getValue = function (editor) {
36420
- // 无需获取 val
36421
- return '';
36422
- };
36423
- SplitCell.prototype.isActive = function (editor) {
36424
- // 无需 active
36425
- return false;
36426
- };
36427
- SplitCell.prototype.isDisabled = function (editor) {
36428
- var _a = __read$3(Editor.nodes(editor, {
36429
- match: isOfType(editor, 'td'),
36430
- }), 1), td = _a[0];
36431
- 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;
36432
- if (rowSpan > 1 || colSpan > 1) {
36433
- return false;
36434
- }
36435
- return true;
36436
- };
36437
- SplitCell.prototype.exec = function (editor, value) {
36438
- if (this.isDisabled(editor))
36439
- return;
36440
- this.split(editor);
36441
- };
36442
- /**
36443
- * Splits either the cell at the current selection or a specified location. If a range
36444
- * selection is present, all cells within the range will be split.
36445
- * @param {Location} [options.at] - Splits the cell at the specified location. If no
36446
- * location is specified it will split the cell at the current selection
36447
- * @param {boolean} [options.all] - If true, splits all cells in the table
36448
- * @returns void
36449
- */
36450
- SplitCell.prototype.split = function (editor, options) {
36451
- if (options === void 0) { options = {}; }
36452
- var _a = __read$3(Editor.nodes(editor, {
36453
- match: isOfType(editor, 'table', 'th', 'td'),
36454
- // @ts-ignore
36455
- at: options.at,
36456
- }), 2), table = _a[0], td = _a[1];
36457
- if (!table || !td) {
36458
- return;
36459
- }
36460
- var selection = EDITOR_TO_SELECTION.get(editor) || [];
36461
- // @ts-ignore
36462
- var matrix = filledMatrix(editor, { at: options.at });
36463
- // const { blocks } = DEFAULT_WITH_TABLE_OPTIONS;
36464
- Editor.withoutNormalizing(editor, function () {
36465
- for (var x = matrix.length - 1; x >= 0; x--) {
36466
- for (var y = matrix[x].length - 1; y >= 0; y--) {
36467
- var _a = __read$3(matrix[x][y], 2), _b = __read$3(_a[0], 2), path = _b[1], context = _a[1];
36468
- var colSpan = context.ltr, rtl = context.rtl, rowSpan = context.btt, ttb = context.ttb;
36469
- if (rtl > 1) {
36470
- // get to the start of the colspan
36471
- y -= rtl - 2;
36472
- continue;
36473
- }
36474
- if (ttb > 1) {
36475
- continue;
36476
- }
36477
- if (rowSpan === 1 && colSpan === 1) {
36478
- continue;
36479
- }
36480
- var found = !!options.all;
36481
- if (selection.length) {
36482
- outer: for (var i = 0; !options.all && i < selection.length; i++) {
36483
- for (var j = 0; j < selection[i].length; j++) {
36484
- var _c = __read$3(selection[i][j], 1), _d = __read$3(_c[0], 2), tdPath = _d[1];
36485
- if (Path.equals(tdPath, path)) {
36486
- found = true;
36487
- break outer;
36488
- }
36489
- }
36490
- }
36491
- }
36492
- else {
36493
- var _e = __read$3(td, 2), tdPath = _e[1];
36494
- if (Path.equals(tdPath, path)) {
36495
- found = true;
36496
- }
36497
- }
36498
- if (!found) {
36499
- continue;
36500
- }
36501
- var _f = __read$3(Editor.nodes(editor, {
36502
- match: isOfType(editor, 'table'),
36503
- at: path,
36504
- }), 1), _g = __read$3(_f[0], 1); _g[0];
36505
- out: for (var r = 1; r < rowSpan; r++) {
36506
- for (var i = y; i >= 0; i--) {
36507
- var _h = __read$3(matrix[x + r][i], 2), _j = __read$3(_h[0], 2); _j[1]; var ttb_1 = _h[1].ttb;
36508
- if (ttb_1 == 1) {
36509
- continue;
36510
- }
36511
- for (var c = 0; c < colSpan; c++) {
36512
- var _k = __read$3(matrix[x + r][i + c], 1), _l = __read$3(_k[0], 2), nextPath = _l[1];
36513
- Transforms.unsetNodes(editor, ['hidden', 'colSpan', 'rowSpan'], { at: nextPath });
36514
- }
36515
- continue out;
36516
- }
36517
- }
36518
- for (var c = 1; c < colSpan; c++) {
36519
- var _m = __read$3(matrix[x][y + c], 1), _o = __read$3(_m[0], 2), nextPath = _o[1];
36520
- Transforms.unsetNodes(editor, ['hidden', 'colSpan', 'rowSpan'], { at: nextPath });
36521
- }
36522
- Transforms.setNodes(editor, { rowSpan: 1, colSpan: 1 }, { at: path });
36523
- }
36524
- }
36525
- });
36526
- };
36527
- return SplitCell;
36528
- }());
36529
-
36530
37326
  /**
36531
37327
  * @description table menu
36532
37328
  * @author wangfupeng
@@ -36578,19 +37374,6 @@ var tableFullWidthMenuConf = {
36578
37374
  factory: function () {
36579
37375
  return new TableFullWidth();
36580
37376
  },
36581
- };
36582
- /** Meger / Split conf */
36583
- var mergeTableCellConf = {
36584
- key: 'mergeTableCell',
36585
- factory: function () {
36586
- return new MergeCell();
36587
- },
36588
- };
36589
- var splitTableCellConf = {
36590
- key: 'splitTableCell',
36591
- factory: function () {
36592
- return new SplitCell();
36593
- },
36594
37377
  };
36595
37378
 
36596
37379
  /**
@@ -36611,8 +37394,6 @@ var table = {
36611
37394
  deleteTableColConf,
36612
37395
  tableHeaderMenuConf,
36613
37396
  tableFullWidthMenuConf,
36614
- mergeTableCellConf,
36615
- splitTableCellConf,
36616
37397
  ],
36617
37398
  editorPlugin: withTable,
36618
37399
  };
@@ -43518,9 +44299,6 @@ var COMMON_HOVERBAR_KEYS = {
43518
44299
  'insertTableCol',
43519
44300
  'deleteTableCol',
43520
44301
  'deleteTable',
43521
- /** 注册单元格合并 拆分 */
43522
- 'mergeTableCell',
43523
- 'splitTableCell',
43524
44302
  ],
43525
44303
  },
43526
44304
  divider: {
@@ -43633,4 +44411,4 @@ function createToolbar(option) {
43633
44411
  */
43634
44412
  var index = {};
43635
44413
 
43636
- 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 };
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 };