@wangeditor-next/editor 5.3.2 → 5.3.4

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.js CHANGED
@@ -22620,9 +22620,14 @@
22620
22620
  }
22621
22621
  return (
22622
22622
  // 祖先节点中包括 data-slate-editor 属性,即 textarea
22623
- targetEl.closest("[data-slate-editor]") === editorEl &&
22623
+ (targetEl.closest("[data-slate-editor]") === editorEl &&
22624
22624
  // 通过参数 editable 控制开启是否验证是可编辑元素或零宽字符
22625
- (!editable || targetEl.isContentEditable || !!targetEl.getAttribute('data-slate-zero-width')));
22625
+ // 补全 data-slate-string 可参考本文代码
22626
+ //(data-slate-zero-width、data-slate-string)判断一起出现,唯独此处欠缺,补全
22627
+ (!editable ||
22628
+ targetEl.isContentEditable ||
22629
+ !!targetEl.getAttribute('data-slate-zero-width'))) ||
22630
+ !!targetEl.getAttribute('data-slate-string'));
22626
22631
  },
22627
22632
  /**
22628
22633
  * Find a native DOM range from a Slate `range`.
@@ -24394,7 +24399,7 @@
24394
24399
  div.setAttribute('hidden', 'true');
24395
24400
  document.body.appendChild(div);
24396
24401
  var insertedElemNum = 0; // 记录插入 elem 的数量 ( textNode 不算 )
24397
- domNodes.forEach(function (n) {
24402
+ domNodes.forEach(function (n, index) {
24398
24403
  var nodeType = n.nodeType, nodeName = n.nodeName, _a = n.textContent, textContent = _a === void 0 ? '' : _a;
24399
24404
  // ------ Text node ------
24400
24405
  if (nodeType === NodeType.TEXT_NODE) {
@@ -24448,8 +24453,13 @@
24448
24453
  var display = window.getComputedStyle(el).display;
24449
24454
  if (!DomEditor.isSelectedEmptyParagraph(e)) {
24450
24455
  // 当前不是空行,且 非 inline - 则换行
24451
- if (display.indexOf('inline') < 0)
24456
+ if (display.indexOf('inline') < 0) {
24457
+ var el_1 = domNodes[index - 1];
24458
+ if (el_1.matches('ul:not([data-w-e-type]),ol:not([data-w-e-type])')) {
24459
+ e.insertBreak(); // 列表项,需要插入空行
24460
+ }
24452
24461
  e.insertBreak();
24462
+ }
24453
24463
  }
24454
24464
  e.dangerouslyInsertHtml(el.innerHTML, true); // 继续插入子内容
24455
24465
  });
@@ -26280,9 +26290,6 @@
26280
26290
  });
26281
26291
  slate.Transforms.select(editor, range);
26282
26292
  }
26283
- else {
26284
- slate.Transforms.deselect(editor);
26285
- }
26286
26293
  }
26287
26294
 
26288
26295
  /**
@@ -26538,16 +26545,7 @@
26538
26545
  editorSelectionToDOM(textarea, editor, true);
26539
26546
  });
26540
26547
  }
26541
- if (selection && slate.Range.isCollapsed(selection)) {
26542
- // 记录下 dom text ,以便触发 maxLength 时使用
26543
- var domRange = DomEditor.toDOMRange(editor, selection);
26544
- var startContainer = domRange.startContainer;
26545
- var curText = startContainer.textContent || '';
26546
- EDITOR_TO_TEXT.set(editor, curText);
26547
- // 记录下 dom range startContainer
26548
- EDITOR_TO_START_CONTAINER.set(editor, startContainer);
26549
- }
26550
- if (selection && slate.Range.isExpanded(selection)) {
26548
+ if (selection && (slate.Range.isExpanded(selection) || slate.Range.isCollapsed(selection))) {
26551
26549
  // 记录下 dom text ,以便触发 maxLength 时使用
26552
26550
  var domRange = DomEditor.toDOMRange(editor, selection);
26553
26551
  var startContainer = domRange.startContainer;
@@ -34462,12 +34460,12 @@
34462
34460
  * 未选中时,渲染 image container
34463
34461
  */
34464
34462
  function renderContainer(editor, elemNode, imageVnode, imageInfo) {
34465
- var width = imageInfo.width, height = imageInfo.height;
34463
+ var width = imageInfo.width; imageInfo.height;
34466
34464
  var style = {};
34467
34465
  if (width)
34468
34466
  style.width = width;
34469
- if (height)
34470
- style.height = height;
34467
+ /** 不强制设置高度 */
34468
+ // if (height) style.height = height
34471
34469
  var containerId = genContainerId(editor, elemNode);
34472
34470
  return (snabbdom.jsx("div", { id: containerId, style: style, className: "w-e-image-container" }, imageVnode));
34473
34471
  }
@@ -34477,10 +34475,11 @@
34477
34475
  function renderResizeContainer(editor, elemNode, imageVnode, imageInfo) {
34478
34476
  var $body = $__default["default"]('body');
34479
34477
  var containerId = genContainerId(editor, elemNode);
34480
- var width = imageInfo.width, height = imageInfo.height;
34478
+ var width = imageInfo.width; imageInfo.height;
34481
34479
  var originalX = 0;
34482
34480
  var originalWith = 0;
34483
34481
  var originalHeight = 0;
34482
+ var maxWidth = 0; // 最大宽度
34484
34483
  var revers = false; // 是否反转。如向右拖拽 right-top 需增加宽度(非反转),但向右拖拽 left-top 则需要减少宽度(反转)
34485
34484
  var $container = null;
34486
34485
  function getContainerElem() {
@@ -34492,10 +34491,11 @@
34492
34491
  /**
34493
34492
  * 初始化。监听事件,记录原始数据
34494
34493
  */
34495
- function init(clientX) {
34494
+ function init(clientX, parentNodeWidth) {
34496
34495
  $container = getContainerElem();
34497
34496
  // 记录当前 x 坐标值
34498
34497
  originalX = clientX;
34498
+ maxWidth = parentNodeWidth;
34499
34499
  // 记录 img 原始宽高
34500
34500
  var $img = $container.find('img');
34501
34501
  if ($img.length === 0)
@@ -34518,13 +34518,18 @@
34518
34518
  var gap = revers ? originalX - clientX : clientX - originalX; // 考虑是否反转
34519
34519
  var newWidth = originalWith + gap;
34520
34520
  var newHeight = originalHeight * (newWidth / originalWith); // 根据 width ,按比例计算 height
34521
+ /**
34522
+ * 图片有左右3px margin
34523
+ */
34524
+ if (newWidth > maxWidth - 6)
34525
+ return; // 超过最大宽度,不处理
34521
34526
  // 实时修改 img 宽高 -【注意】这里只修改 DOM ,mouseup 时再统一不修改 node
34522
34527
  if ($container == null)
34523
34528
  return;
34524
34529
  if (newWidth <= 15 || newHeight <= 15)
34525
34530
  return; // 最小就是 15px
34526
34531
  $container.css('width', newWidth + "px");
34527
- $container.css('height', newHeight + "px");
34532
+ // $container.css('height', `${newHeight}px`)
34528
34533
  }, 100);
34529
34534
  function onMouseup(e) {
34530
34535
  // 取消监听 mousemove
@@ -34532,10 +34537,10 @@
34532
34537
  if ($container == null)
34533
34538
  return;
34534
34539
  var newWidth = $container.width().toFixed(2);
34535
- var newHeight = $container.height().toFixed(2);
34540
+ // const newHeight = $container.height().toFixed(2)
34536
34541
  // 修改 node
34537
34542
  var props = {
34538
- style: __assign(__assign({}, elemNode.style), { width: newWidth + "px", height: newHeight + "px" }),
34543
+ style: __assign(__assign({}, elemNode.style), { width: newWidth + "px" }),
34539
34544
  };
34540
34545
  slate.Transforms.setNodes(editor, props, { at: core.DomEditor.findPath(editor, elemNode) });
34541
34546
  // 取消监听 mouseup
@@ -34544,8 +34549,7 @@
34544
34549
  var style = {};
34545
34550
  if (width)
34546
34551
  style.width = width;
34547
- if (height)
34548
- style.height = height;
34552
+ // if (height) style.height = height
34549
34553
  // style.boxShadow = '0 0 0 1px #B4D5FF' // 自定义 selected 样式,因为有拖拽触手
34550
34554
  return (snabbdom.jsx("div", { id: containerId, style: style, className: "w-e-image-container w-e-selected-image-container", on: {
34551
34555
  // 统一绑定拖拽触手的 mousedown 事件
@@ -34559,7 +34563,20 @@
34559
34563
  if ($target.hasClass('left-top') || $target.hasClass('left-bottom')) {
34560
34564
  revers = true; // 反转。向右拖拽,减少宽度
34561
34565
  }
34562
- init(e.clientX); // 初始化
34566
+ // 获取 image 父容器宽度
34567
+ var parentNode = core.DomEditor.getParentNode(editor, elemNode);
34568
+ if (parentNode == null)
34569
+ return;
34570
+ var parentNodeDom = core.DomEditor.toDOMNode(editor, parentNode);
34571
+ var rect = parentNodeDom.getBoundingClientRect();
34572
+ // 获取元素的计算样式
34573
+ var style = window.getComputedStyle(parentNodeDom);
34574
+ // 获取左右 padding 和 border 的宽度
34575
+ var paddingLeft = parseFloat(style.paddingLeft);
34576
+ var paddingRight = parseFloat(style.paddingRight);
34577
+ var borderLeft = parseFloat(style.borderLeftWidth);
34578
+ var borderRight = parseFloat(style.borderRightWidth);
34579
+ init(e.clientX, rect.width - paddingLeft - paddingRight - borderLeft - borderRight); // 初始化
34563
34580
  },
34564
34581
  } },
34565
34582
  imageVnode,
@@ -34572,7 +34589,7 @@
34572
34589
  var _a = elemNode, src = _a.src, _b = _a.alt, alt = _b === void 0 ? '' : _b, _c = _a.href, href = _c === void 0 ? '' : _c, _d = _a.style, style = _d === void 0 ? {} : _d;
34573
34590
  var _e = style.width, width = _e === void 0 ? '' : _e, _f = style.height, height = _f === void 0 ? '' : _f;
34574
34591
  var selected = core.DomEditor.isNodeSelected(editor, elemNode); // 图片是否选中
34575
- var imageStyle = {};
34592
+ var imageStyle = { maxWidth: '100%' };
34576
34593
  if (width)
34577
34594
  imageStyle.width = '100%';
34578
34595
  if (height)
@@ -37977,8 +37994,27 @@
37977
37994
  });
37978
37995
  }
37979
37996
  function withList(editor) {
37980
- var deleteBackward = editor.deleteBackward, handleTab = editor.handleTab, normalizeNode = editor.normalizeNode;
37997
+ var deleteBackward = editor.deleteBackward, handleTab = editor.handleTab, normalizeNode = editor.normalizeNode, insertBreak = editor.insertBreak;
37981
37998
  var newEditor = editor;
37999
+ // 重写 insertBreak - 空 list 点击回车时删除该空 list
38000
+ newEditor.insertBreak = function () {
38001
+ var _a = __read(slate.Editor.nodes(editor, {
38002
+ match: function (n) { return core.DomEditor.checkNodeType(n, 'list-item'); },
38003
+ universal: true,
38004
+ }), 1), nodeEntry = _a[0];
38005
+ if (!nodeEntry)
38006
+ return insertBreak();
38007
+ var listElem = nodeEntry[0];
38008
+ if (listElem.children[0].text === '') {
38009
+ slate.Transforms.setNodes(newEditor, {
38010
+ type: 'paragraph',
38011
+ ordered: undefined,
38012
+ level: undefined,
38013
+ });
38014
+ return;
38015
+ }
38016
+ return insertBreak();
38017
+ };
37982
38018
  // 重写 deleteBackward - 降低 level 或者转换为 p 元素
37983
38019
  newEditor.deleteBackward = function (unit) {
37984
38020
  var selection = newEditor.selection;
@@ -38483,1950 +38519,505 @@
38483
38519
  }));
38484
38520
  });
38485
38521
 
38486
- /**
38487
- * Lodash (Custom Build) <https://lodash.com/>
38488
- * Build: `lodash modularize exports="npm" -o ./`
38489
- * Copyright JS Foundation and other contributors <https://js.foundation/>
38490
- * Released under MIT license <https://lodash.com/license>
38491
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
38492
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
38493
- */
38522
+ var dist$3 = createCommonjsModule$1(function (module, exports) {
38523
+ (function (global, factory) {
38524
+ module.exports = factory(dist$6, require$$2$1, lodash_debounce, require$$2, lodash_throttle, require$$1, require$$4) ;
38525
+ })(commonjsGlobal, (function (core, slate, debounce, snabbdom, throttle, $) {
38526
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
38494
38527
 
38495
- var lodash_isequal = createCommonjsModule$1(function (module, exports) {
38496
- /** Used as the size to enable large array optimizations. */
38497
- var LARGE_ARRAY_SIZE = 200;
38528
+ var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
38529
+ var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle);
38530
+ var $__default = /*#__PURE__*/_interopDefaultLegacy($);
38498
38531
 
38499
- /** Used to stand-in for `undefined` hash values. */
38500
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
38532
+ /**
38533
+ * @description i18n en
38534
+ * @author wangfupeng
38535
+ */
38536
+ var enResources = {
38537
+ tableModule: {
38538
+ deleteCol: 'Delete column',
38539
+ deleteRow: 'Delete row',
38540
+ deleteTable: 'Delete table',
38541
+ widthAuto: 'Width auto',
38542
+ insertCol: 'Insert column',
38543
+ insertRow: 'Insert row',
38544
+ insertTable: 'Insert table',
38545
+ header: 'Header',
38546
+ mergeCell: 'merge cell',
38547
+ splitCell: 'split cell',
38548
+ },
38549
+ };
38501
38550
 
38502
- /** Used to compose bitmasks for value comparisons. */
38503
- var COMPARE_PARTIAL_FLAG = 1,
38504
- COMPARE_UNORDERED_FLAG = 2;
38551
+ /**
38552
+ * @description i18n zh-CN
38553
+ * @author wangfupeng
38554
+ */
38555
+ var zhResources = {
38556
+ tableModule: {
38557
+ deleteCol: '删除列',
38558
+ deleteRow: '删除行',
38559
+ deleteTable: '删除表格',
38560
+ widthAuto: '宽度自适应',
38561
+ insertCol: '插入列',
38562
+ insertRow: '插入行',
38563
+ insertTable: '插入表格',
38564
+ header: '表头',
38565
+ mergeCell: '合并单元格',
38566
+ splitCell: '拆分单元格',
38567
+ },
38568
+ };
38505
38569
 
38506
- /** Used as references for various `Number` constants. */
38507
- var MAX_SAFE_INTEGER = 9007199254740991;
38570
+ /**
38571
+ * @description i18n entry
38572
+ * @author wangfupeng
38573
+ */
38574
+ core.i18nAddResources('en', enResources);
38575
+ core.i18nAddResources('zh-CN', zhResources);
38508
38576
 
38509
- /** `Object#toString` result references. */
38510
- var argsTag = '[object Arguments]',
38511
- arrayTag = '[object Array]',
38512
- asyncTag = '[object AsyncFunction]',
38513
- boolTag = '[object Boolean]',
38514
- dateTag = '[object Date]',
38515
- errorTag = '[object Error]',
38516
- funcTag = '[object Function]',
38517
- genTag = '[object GeneratorFunction]',
38518
- mapTag = '[object Map]',
38519
- numberTag = '[object Number]',
38520
- nullTag = '[object Null]',
38521
- objectTag = '[object Object]',
38522
- promiseTag = '[object Promise]',
38523
- proxyTag = '[object Proxy]',
38524
- regexpTag = '[object RegExp]',
38525
- setTag = '[object Set]',
38526
- stringTag = '[object String]',
38527
- symbolTag = '[object Symbol]',
38528
- undefinedTag = '[object Undefined]',
38529
- weakMapTag = '[object WeakMap]';
38577
+ /*! *****************************************************************************
38578
+ Copyright (c) Microsoft Corporation.
38579
+
38580
+ Permission to use, copy, modify, and/or distribute this software for any
38581
+ purpose with or without fee is hereby granted.
38582
+
38583
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
38584
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
38585
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
38586
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
38587
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
38588
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
38589
+ PERFORMANCE OF THIS SOFTWARE.
38590
+ ***************************************************************************** */
38591
+
38592
+ var __assign = function() {
38593
+ __assign = Object.assign || function __assign(t) {
38594
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
38595
+ s = arguments[i];
38596
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
38597
+ }
38598
+ return t;
38599
+ };
38600
+ return __assign.apply(this, arguments);
38601
+ };
38602
+
38603
+ function __generator(thisArg, body) {
38604
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
38605
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38606
+ function verb(n) { return function (v) { return step([n, v]); }; }
38607
+ function step(op) {
38608
+ if (f) throw new TypeError("Generator is already executing.");
38609
+ while (_) try {
38610
+ 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;
38611
+ if (y = 0, t) op = [op[0] & 2, t.value];
38612
+ switch (op[0]) {
38613
+ case 0: case 1: t = op; break;
38614
+ case 4: _.label++; return { value: op[1], done: false };
38615
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38616
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
38617
+ default:
38618
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38619
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38620
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
38621
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
38622
+ if (t[2]) _.ops.pop();
38623
+ _.trys.pop(); continue;
38624
+ }
38625
+ op = body.call(thisArg, _);
38626
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
38627
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
38628
+ }
38629
+ }
38630
+
38631
+ function __values(o) {
38632
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
38633
+ if (m) return m.call(o);
38634
+ if (o && typeof o.length === "number") return {
38635
+ next: function () {
38636
+ if (o && i >= o.length) o = void 0;
38637
+ return { value: o && o[i++], done: !o };
38638
+ }
38639
+ };
38640
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
38641
+ }
38642
+
38643
+ function __read(o, n) {
38644
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
38645
+ if (!m) return o;
38646
+ var i = m.call(o), r, ar = [], e;
38647
+ try {
38648
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
38649
+ }
38650
+ catch (error) { e = { error: error }; }
38651
+ finally {
38652
+ try {
38653
+ if (r && !r.done && (m = i["return"])) m.call(i);
38654
+ }
38655
+ finally { if (e) throw e.error; }
38656
+ }
38657
+ return ar;
38658
+ }
38659
+
38660
+ function __spreadArray(to, from) {
38661
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
38662
+ to[j] = from[i];
38663
+ return to;
38664
+ }
38530
38665
 
38531
- var arrayBufferTag = '[object ArrayBuffer]',
38532
- dataViewTag = '[object DataView]',
38533
- float32Tag = '[object Float32Array]',
38534
- float64Tag = '[object Float64Array]',
38535
- int8Tag = '[object Int8Array]',
38536
- int16Tag = '[object Int16Array]',
38537
- int32Tag = '[object Int32Array]',
38538
- uint8Tag = '[object Uint8Array]',
38539
- uint8ClampedTag = '[object Uint8ClampedArray]',
38540
- uint16Tag = '[object Uint16Array]',
38541
- uint32Tag = '[object Uint32Array]';
38666
+ /** Weak reference between the `Editor` and the selected elements */
38667
+ var EDITOR_TO_SELECTION = new WeakMap();
38668
+ /** Weak reference between the `Editor` and a set of the selected elements */
38669
+ var EDITOR_TO_SELECTION_SET = new WeakMap();
38670
+
38671
+ var DEFAULT_WITH_TABLE_OPTIONS = {
38672
+ blocks: {
38673
+ td: 'table-cell',
38674
+ th: 'table-cell',
38675
+ content: 'paragraph',
38676
+ tr: 'table-row',
38677
+ table: 'table',
38678
+ tbody: 'table-body',
38679
+ // tfoot: "table-footer",
38680
+ // thead: "table-head",
38681
+ },
38682
+ };
38542
38683
 
38543
- /**
38544
- * Used to match `RegExp`
38545
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
38546
- */
38547
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
38684
+ function isElement(node) {
38685
+ return !slate.Editor.isEditor(node) && slate.Element.isElement(node) && 'type' in node;
38686
+ }
38687
+ /** @returns a `NodeMatch` function which is used to match the elements of a specific `type`. */
38688
+ function isOfType(editor) {
38689
+ var types = [];
38690
+ for (var _i = 1; _i < arguments.length; _i++) {
38691
+ types[_i - 1] = arguments[_i];
38692
+ }
38693
+ 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]; });
38694
+ return function (node) { return isElement(node) && elementTypes.includes(node.type); };
38695
+ }
38548
38696
 
38549
- /** Used to detect host constructors (Safari). */
38550
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
38697
+ /**
38698
+ * Determines whether two paths belong to the same types by checking
38699
+ * if they share a common ancestor node of type table
38700
+ */
38701
+ function hasCommon(editor, _a) {
38702
+ var _b = __read(_a, 2), path = _b[0], another = _b[1];
38703
+ var types = [];
38704
+ for (var _i = 2; _i < arguments.length; _i++) {
38705
+ types[_i - 2] = arguments[_i];
38706
+ }
38707
+ var _c = __read(slate.Node.common(editor, path, another), 2), node = _c[0], commonPath = _c[1];
38708
+ if (isOfType.apply(void 0, __spreadArray([editor], __read(types)))(node, commonPath)) {
38709
+ return true;
38710
+ }
38711
+ // Warning: returns the common ancestor but will return `undefined` if the
38712
+ // `commonPath` is equal to the specified types path
38713
+ return !!slate.Editor.above(editor, {
38714
+ match: isOfType.apply(void 0, __spreadArray([editor], __read(types))),
38715
+ at: commonPath,
38716
+ });
38717
+ }
38551
38718
 
38552
- /** Used to detect unsigned integer values. */
38553
- var reIsUint = /^(?:0|[1-9]\d*)$/;
38719
+ /** Generates a matrix for each table section (`thead`, `tbody`, `tfoot`) */
38720
+ function matrices(editor, options) {
38721
+ var _a, table, _b, tablePath, _c, _d, _e, path, matrix, _f, _g, _h, trPath, e_1_1;
38722
+ var e_1, _j, e_2, _k;
38723
+ if (options === void 0) { options = {}; }
38724
+ return __generator(this, function (_l) {
38725
+ switch (_l.label) {
38726
+ case 0:
38727
+ _a = __read(slate.Editor.nodes(editor, {
38728
+ match: isOfType(editor, 'table'),
38729
+ at: options.at,
38730
+ }), 1), table = _a[0];
38731
+ if (!table) {
38732
+ return [2 /*return*/, []];
38733
+ }
38734
+ _b = __read(table, 2), tablePath = _b[1];
38735
+ _l.label = 1;
38736
+ case 1:
38737
+ _l.trys.push([1, 6, 7, 8]);
38738
+ _c = __values(slate.Editor.nodes(editor, {
38739
+ // match: isOfType(editor, "thead", "tbody", "tfoot"),
38740
+ match: isOfType(editor, 'table'),
38741
+ at: tablePath,
38742
+ })), _d = _c.next();
38743
+ _l.label = 2;
38744
+ case 2:
38745
+ if (!!_d.done) return [3 /*break*/, 5];
38746
+ _e = __read(_d.value, 2), path = _e[1];
38747
+ matrix = [];
38748
+ try {
38749
+ for (_f = (e_2 = void 0, __values(slate.Editor.nodes(editor, {
38750
+ match: isOfType(editor, 'tr'),
38751
+ at: path,
38752
+ }))), _g = _f.next(); !_g.done; _g = _f.next()) {
38753
+ _h = __read(_g.value, 2), trPath = _h[1];
38754
+ matrix.push(__spreadArray([], __read(slate.Editor.nodes(editor, {
38755
+ match: isOfType(editor, 'th', 'td'),
38756
+ at: trPath,
38757
+ }))));
38758
+ }
38759
+ }
38760
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
38761
+ finally {
38762
+ try {
38763
+ if (_g && !_g.done && (_k = _f.return)) _k.call(_f);
38764
+ }
38765
+ finally { if (e_2) throw e_2.error; }
38766
+ }
38767
+ return [4 /*yield*/, matrix];
38768
+ case 3:
38769
+ _l.sent();
38770
+ _l.label = 4;
38771
+ case 4:
38772
+ _d = _c.next();
38773
+ return [3 /*break*/, 2];
38774
+ case 5: return [3 /*break*/, 8];
38775
+ case 6:
38776
+ e_1_1 = _l.sent();
38777
+ e_1 = { error: e_1_1 };
38778
+ return [3 /*break*/, 8];
38779
+ case 7:
38780
+ try {
38781
+ if (_d && !_d.done && (_j = _c.return)) _j.call(_c);
38782
+ }
38783
+ finally { if (e_1) throw e_1.error; }
38784
+ return [7 /*endfinally*/];
38785
+ case 8: return [2 /*return*/];
38786
+ }
38787
+ });
38788
+ }
38789
+ function filledMatrix(editor, options) {
38790
+ var e_3, _a;
38791
+ if (options === void 0) { options = {}; }
38792
+ var filled = [];
38793
+ try {
38794
+ // Expand each section separately to avoid sections collapsing into each other.
38795
+ for (var _b = __values(matrices(editor, { at: options.at })), _c = _b.next(); !_c.done; _c = _b.next()) {
38796
+ var matrix = _c.value;
38797
+ var filledSection = [];
38798
+ for (var x = 0; x < matrix.length; x++) {
38799
+ if (!filledSection[x]) {
38800
+ filledSection[x] = [];
38801
+ }
38802
+ for (var y = 0; y < matrix[x].length; y++) {
38803
+ var _d = __read(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;
38804
+ for (var c = 0, occupied = 0; c < colSpan + occupied; c++) {
38805
+ for (var r = 0; r < rowSpan; r++) {
38806
+ if (!filledSection[x + r]) {
38807
+ filledSection[x + r] = [];
38808
+ }
38809
+ if (filledSection[x + r][y + c]) {
38810
+ continue;
38811
+ }
38812
+ filledSection[x + r][y + c] = [
38813
+ matrix[x + r][y + c],
38814
+ {
38815
+ rtl: c - occupied + 1,
38816
+ ltr: colSpan - c + occupied,
38817
+ ttb: r + 1,
38818
+ btt: rowSpan - r,
38819
+ },
38820
+ ];
38821
+ }
38822
+ }
38823
+ }
38824
+ }
38825
+ filled.push.apply(filled, __spreadArray([], __read(filledSection)));
38826
+ }
38827
+ }
38828
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
38829
+ finally {
38830
+ try {
38831
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
38832
+ }
38833
+ finally { if (e_3) throw e_3.error; }
38834
+ }
38835
+ return filled;
38836
+ }
38554
38837
 
38555
- /** Used to identify `toStringTag` values of typed arrays. */
38556
- var typedArrayTags = {};
38557
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
38558
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
38559
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
38560
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
38561
- typedArrayTags[uint32Tag] = true;
38562
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
38563
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
38564
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
38565
- typedArrayTags[errorTag] = typedArrayTags[funcTag] =
38566
- typedArrayTags[mapTag] = typedArrayTags[numberTag] =
38567
- typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
38568
- typedArrayTags[setTag] = typedArrayTags[stringTag] =
38569
- typedArrayTags[weakMapTag] = false;
38570
-
38571
- /** Detect free variable `global` from Node.js. */
38572
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
38573
-
38574
- /** Detect free variable `self`. */
38575
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
38576
-
38577
- /** Used as a reference to the global object. */
38578
- var root = freeGlobal || freeSelf || Function('return this')();
38579
-
38580
- /** Detect free variable `exports`. */
38581
- var freeExports = exports && !exports.nodeType && exports;
38582
-
38583
- /** Detect free variable `module`. */
38584
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
38585
-
38586
- /** Detect the popular CommonJS extension `module.exports`. */
38587
- var moduleExports = freeModule && freeModule.exports === freeExports;
38588
-
38589
- /** Detect free variable `process` from Node.js. */
38590
- var freeProcess = moduleExports && freeGlobal.process;
38591
-
38592
- /** Used to access faster Node.js helpers. */
38593
- var nodeUtil = (function() {
38594
- try {
38595
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
38596
- } catch (e) {}
38597
- }());
38598
-
38599
- /* Node.js helper references. */
38600
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
38601
-
38602
- /**
38603
- * A specialized version of `_.filter` for arrays without support for
38604
- * iteratee shorthands.
38605
- *
38606
- * @private
38607
- * @param {Array} [array] The array to iterate over.
38608
- * @param {Function} predicate The function invoked per iteration.
38609
- * @returns {Array} Returns the new filtered array.
38610
- */
38611
- function arrayFilter(array, predicate) {
38612
- var index = -1,
38613
- length = array == null ? 0 : array.length,
38614
- resIndex = 0,
38615
- result = [];
38616
-
38617
- while (++index < length) {
38618
- var value = array[index];
38619
- if (predicate(value, index, array)) {
38620
- result[resIndex++] = value;
38621
- }
38622
- }
38623
- return result;
38624
- }
38625
-
38626
- /**
38627
- * Appends the elements of `values` to `array`.
38628
- *
38629
- * @private
38630
- * @param {Array} array The array to modify.
38631
- * @param {Array} values The values to append.
38632
- * @returns {Array} Returns `array`.
38633
- */
38634
- function arrayPush(array, values) {
38635
- var index = -1,
38636
- length = values.length,
38637
- offset = array.length;
38638
-
38639
- while (++index < length) {
38640
- array[offset + index] = values[index];
38641
- }
38642
- return array;
38643
- }
38644
-
38645
- /**
38646
- * A specialized version of `_.some` for arrays without support for iteratee
38647
- * shorthands.
38648
- *
38649
- * @private
38650
- * @param {Array} [array] The array to iterate over.
38651
- * @param {Function} predicate The function invoked per iteration.
38652
- * @returns {boolean} Returns `true` if any element passes the predicate check,
38653
- * else `false`.
38654
- */
38655
- function arraySome(array, predicate) {
38656
- var index = -1,
38657
- length = array == null ? 0 : array.length;
38658
-
38659
- while (++index < length) {
38660
- if (predicate(array[index], index, array)) {
38661
- return true;
38662
- }
38663
- }
38664
- return false;
38665
- }
38666
-
38667
- /**
38668
- * The base implementation of `_.times` without support for iteratee shorthands
38669
- * or max array length checks.
38670
- *
38671
- * @private
38672
- * @param {number} n The number of times to invoke `iteratee`.
38673
- * @param {Function} iteratee The function invoked per iteration.
38674
- * @returns {Array} Returns the array of results.
38675
- */
38676
- function baseTimes(n, iteratee) {
38677
- var index = -1,
38678
- result = Array(n);
38679
-
38680
- while (++index < n) {
38681
- result[index] = iteratee(index);
38682
- }
38683
- return result;
38684
- }
38685
-
38686
- /**
38687
- * The base implementation of `_.unary` without support for storing metadata.
38688
- *
38689
- * @private
38690
- * @param {Function} func The function to cap arguments for.
38691
- * @returns {Function} Returns the new capped function.
38692
- */
38693
- function baseUnary(func) {
38694
- return function(value) {
38695
- return func(value);
38696
- };
38697
- }
38698
-
38699
- /**
38700
- * Checks if a `cache` value for `key` exists.
38701
- *
38702
- * @private
38703
- * @param {Object} cache The cache to query.
38704
- * @param {string} key The key of the entry to check.
38705
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
38706
- */
38707
- function cacheHas(cache, key) {
38708
- return cache.has(key);
38709
- }
38710
-
38711
- /**
38712
- * Gets the value at `key` of `object`.
38713
- *
38714
- * @private
38715
- * @param {Object} [object] The object to query.
38716
- * @param {string} key The key of the property to get.
38717
- * @returns {*} Returns the property value.
38718
- */
38719
- function getValue(object, key) {
38720
- return object == null ? undefined : object[key];
38721
- }
38722
-
38723
- /**
38724
- * Converts `map` to its key-value pairs.
38725
- *
38726
- * @private
38727
- * @param {Object} map The map to convert.
38728
- * @returns {Array} Returns the key-value pairs.
38729
- */
38730
- function mapToArray(map) {
38731
- var index = -1,
38732
- result = Array(map.size);
38733
-
38734
- map.forEach(function(value, key) {
38735
- result[++index] = [key, value];
38736
- });
38737
- return result;
38738
- }
38739
-
38740
- /**
38741
- * Creates a unary function that invokes `func` with its argument transformed.
38742
- *
38743
- * @private
38744
- * @param {Function} func The function to wrap.
38745
- * @param {Function} transform The argument transform.
38746
- * @returns {Function} Returns the new function.
38747
- */
38748
- function overArg(func, transform) {
38749
- return function(arg) {
38750
- return func(transform(arg));
38751
- };
38752
- }
38753
-
38754
- /**
38755
- * Converts `set` to an array of its values.
38756
- *
38757
- * @private
38758
- * @param {Object} set The set to convert.
38759
- * @returns {Array} Returns the values.
38760
- */
38761
- function setToArray(set) {
38762
- var index = -1,
38763
- result = Array(set.size);
38764
-
38765
- set.forEach(function(value) {
38766
- result[++index] = value;
38767
- });
38768
- return result;
38769
- }
38770
-
38771
- /** Used for built-in method references. */
38772
- var arrayProto = Array.prototype,
38773
- funcProto = Function.prototype,
38774
- objectProto = Object.prototype;
38775
-
38776
- /** Used to detect overreaching core-js shims. */
38777
- var coreJsData = root['__core-js_shared__'];
38778
-
38779
- /** Used to resolve the decompiled source of functions. */
38780
- var funcToString = funcProto.toString;
38781
-
38782
- /** Used to check objects for own properties. */
38783
- var hasOwnProperty = objectProto.hasOwnProperty;
38784
-
38785
- /** Used to detect methods masquerading as native. */
38786
- var maskSrcKey = (function() {
38787
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
38788
- return uid ? ('Symbol(src)_1.' + uid) : '';
38789
- }());
38790
-
38791
- /**
38792
- * Used to resolve the
38793
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
38794
- * of values.
38795
- */
38796
- var nativeObjectToString = objectProto.toString;
38797
-
38798
- /** Used to detect if a method is native. */
38799
- var reIsNative = RegExp('^' +
38800
- funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
38801
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
38802
- );
38803
-
38804
- /** Built-in value references. */
38805
- var Buffer = moduleExports ? root.Buffer : undefined,
38806
- Symbol = root.Symbol,
38807
- Uint8Array = root.Uint8Array,
38808
- propertyIsEnumerable = objectProto.propertyIsEnumerable,
38809
- splice = arrayProto.splice,
38810
- symToStringTag = Symbol ? Symbol.toStringTag : undefined;
38811
-
38812
- /* Built-in method references for those with the same name as other `lodash` methods. */
38813
- var nativeGetSymbols = Object.getOwnPropertySymbols,
38814
- nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
38815
- nativeKeys = overArg(Object.keys, Object);
38816
-
38817
- /* Built-in method references that are verified to be native. */
38818
- var DataView = getNative(root, 'DataView'),
38819
- Map = getNative(root, 'Map'),
38820
- Promise = getNative(root, 'Promise'),
38821
- Set = getNative(root, 'Set'),
38822
- WeakMap = getNative(root, 'WeakMap'),
38823
- nativeCreate = getNative(Object, 'create');
38824
-
38825
- /** Used to detect maps, sets, and weakmaps. */
38826
- var dataViewCtorString = toSource(DataView),
38827
- mapCtorString = toSource(Map),
38828
- promiseCtorString = toSource(Promise),
38829
- setCtorString = toSource(Set),
38830
- weakMapCtorString = toSource(WeakMap);
38831
-
38832
- /** Used to convert symbols to primitives and strings. */
38833
- var symbolProto = Symbol ? Symbol.prototype : undefined,
38834
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
38835
-
38836
- /**
38837
- * Creates a hash object.
38838
- *
38839
- * @private
38840
- * @constructor
38841
- * @param {Array} [entries] The key-value pairs to cache.
38842
- */
38843
- function Hash(entries) {
38844
- var index = -1,
38845
- length = entries == null ? 0 : entries.length;
38846
-
38847
- this.clear();
38848
- while (++index < length) {
38849
- var entry = entries[index];
38850
- this.set(entry[0], entry[1]);
38851
- }
38852
- }
38853
-
38854
- /**
38855
- * Removes all key-value entries from the hash.
38856
- *
38857
- * @private
38858
- * @name clear
38859
- * @memberOf Hash
38860
- */
38861
- function hashClear() {
38862
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
38863
- this.size = 0;
38864
- }
38865
-
38866
- /**
38867
- * Removes `key` and its value from the hash.
38868
- *
38869
- * @private
38870
- * @name delete
38871
- * @memberOf Hash
38872
- * @param {Object} hash The hash to modify.
38873
- * @param {string} key The key of the value to remove.
38874
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
38875
- */
38876
- function hashDelete(key) {
38877
- var result = this.has(key) && delete this.__data__[key];
38878
- this.size -= result ? 1 : 0;
38879
- return result;
38880
- }
38881
-
38882
- /**
38883
- * Gets the hash value for `key`.
38884
- *
38885
- * @private
38886
- * @name get
38887
- * @memberOf Hash
38888
- * @param {string} key The key of the value to get.
38889
- * @returns {*} Returns the entry value.
38890
- */
38891
- function hashGet(key) {
38892
- var data = this.__data__;
38893
- if (nativeCreate) {
38894
- var result = data[key];
38895
- return result === HASH_UNDEFINED ? undefined : result;
38896
- }
38897
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
38898
- }
38899
-
38900
- /**
38901
- * Checks if a hash value for `key` exists.
38902
- *
38903
- * @private
38904
- * @name has
38905
- * @memberOf Hash
38906
- * @param {string} key The key of the entry to check.
38907
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
38908
- */
38909
- function hashHas(key) {
38910
- var data = this.__data__;
38911
- return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
38912
- }
38913
-
38914
- /**
38915
- * Sets the hash `key` to `value`.
38916
- *
38917
- * @private
38918
- * @name set
38919
- * @memberOf Hash
38920
- * @param {string} key The key of the value to set.
38921
- * @param {*} value The value to set.
38922
- * @returns {Object} Returns the hash instance.
38923
- */
38924
- function hashSet(key, value) {
38925
- var data = this.__data__;
38926
- this.size += this.has(key) ? 0 : 1;
38927
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
38928
- return this;
38929
- }
38930
-
38931
- // Add methods to `Hash`.
38932
- Hash.prototype.clear = hashClear;
38933
- Hash.prototype['delete'] = hashDelete;
38934
- Hash.prototype.get = hashGet;
38935
- Hash.prototype.has = hashHas;
38936
- Hash.prototype.set = hashSet;
38937
-
38938
- /**
38939
- * Creates an list cache object.
38940
- *
38941
- * @private
38942
- * @constructor
38943
- * @param {Array} [entries] The key-value pairs to cache.
38944
- */
38945
- function ListCache(entries) {
38946
- var index = -1,
38947
- length = entries == null ? 0 : entries.length;
38948
-
38949
- this.clear();
38950
- while (++index < length) {
38951
- var entry = entries[index];
38952
- this.set(entry[0], entry[1]);
38953
- }
38954
- }
38955
-
38956
- /**
38957
- * Removes all key-value entries from the list cache.
38958
- *
38959
- * @private
38960
- * @name clear
38961
- * @memberOf ListCache
38962
- */
38963
- function listCacheClear() {
38964
- this.__data__ = [];
38965
- this.size = 0;
38966
- }
38967
-
38968
- /**
38969
- * Removes `key` and its value from the list cache.
38970
- *
38971
- * @private
38972
- * @name delete
38973
- * @memberOf ListCache
38974
- * @param {string} key The key of the value to remove.
38975
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
38976
- */
38977
- function listCacheDelete(key) {
38978
- var data = this.__data__,
38979
- index = assocIndexOf(data, key);
38980
-
38981
- if (index < 0) {
38982
- return false;
38983
- }
38984
- var lastIndex = data.length - 1;
38985
- if (index == lastIndex) {
38986
- data.pop();
38987
- } else {
38988
- splice.call(data, index, 1);
38989
- }
38990
- --this.size;
38991
- return true;
38992
- }
38993
-
38994
- /**
38995
- * Gets the list cache value for `key`.
38996
- *
38997
- * @private
38998
- * @name get
38999
- * @memberOf ListCache
39000
- * @param {string} key The key of the value to get.
39001
- * @returns {*} Returns the entry value.
39002
- */
39003
- function listCacheGet(key) {
39004
- var data = this.__data__,
39005
- index = assocIndexOf(data, key);
39006
-
39007
- return index < 0 ? undefined : data[index][1];
39008
- }
39009
-
39010
- /**
39011
- * Checks if a list cache value for `key` exists.
39012
- *
39013
- * @private
39014
- * @name has
39015
- * @memberOf ListCache
39016
- * @param {string} key The key of the entry to check.
39017
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
39018
- */
39019
- function listCacheHas(key) {
39020
- return assocIndexOf(this.__data__, key) > -1;
39021
- }
39022
-
39023
- /**
39024
- * Sets the list cache `key` to `value`.
39025
- *
39026
- * @private
39027
- * @name set
39028
- * @memberOf ListCache
39029
- * @param {string} key The key of the value to set.
39030
- * @param {*} value The value to set.
39031
- * @returns {Object} Returns the list cache instance.
39032
- */
39033
- function listCacheSet(key, value) {
39034
- var data = this.__data__,
39035
- index = assocIndexOf(data, key);
39036
-
39037
- if (index < 0) {
39038
- ++this.size;
39039
- data.push([key, value]);
39040
- } else {
39041
- data[index][1] = value;
39042
- }
39043
- return this;
39044
- }
39045
-
39046
- // Add methods to `ListCache`.
39047
- ListCache.prototype.clear = listCacheClear;
39048
- ListCache.prototype['delete'] = listCacheDelete;
39049
- ListCache.prototype.get = listCacheGet;
39050
- ListCache.prototype.has = listCacheHas;
39051
- ListCache.prototype.set = listCacheSet;
39052
-
39053
- /**
39054
- * Creates a map cache object to store key-value pairs.
39055
- *
39056
- * @private
39057
- * @constructor
39058
- * @param {Array} [entries] The key-value pairs to cache.
39059
- */
39060
- function MapCache(entries) {
39061
- var index = -1,
39062
- length = entries == null ? 0 : entries.length;
39063
-
39064
- this.clear();
39065
- while (++index < length) {
39066
- var entry = entries[index];
39067
- this.set(entry[0], entry[1]);
39068
- }
39069
- }
39070
-
39071
- /**
39072
- * Removes all key-value entries from the map.
39073
- *
39074
- * @private
39075
- * @name clear
39076
- * @memberOf MapCache
39077
- */
39078
- function mapCacheClear() {
39079
- this.size = 0;
39080
- this.__data__ = {
39081
- 'hash': new Hash,
39082
- 'map': new (Map || ListCache),
39083
- 'string': new Hash
39084
- };
39085
- }
39086
-
39087
- /**
39088
- * Removes `key` and its value from the map.
39089
- *
39090
- * @private
39091
- * @name delete
39092
- * @memberOf MapCache
39093
- * @param {string} key The key of the value to remove.
39094
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
39095
- */
39096
- function mapCacheDelete(key) {
39097
- var result = getMapData(this, key)['delete'](key);
39098
- this.size -= result ? 1 : 0;
39099
- return result;
39100
- }
39101
-
39102
- /**
39103
- * Gets the map value for `key`.
39104
- *
39105
- * @private
39106
- * @name get
39107
- * @memberOf MapCache
39108
- * @param {string} key The key of the value to get.
39109
- * @returns {*} Returns the entry value.
39110
- */
39111
- function mapCacheGet(key) {
39112
- return getMapData(this, key).get(key);
39113
- }
39114
-
39115
- /**
39116
- * Checks if a map value for `key` exists.
39117
- *
39118
- * @private
39119
- * @name has
39120
- * @memberOf MapCache
39121
- * @param {string} key The key of the entry to check.
39122
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
39123
- */
39124
- function mapCacheHas(key) {
39125
- return getMapData(this, key).has(key);
39126
- }
39127
-
39128
- /**
39129
- * Sets the map `key` to `value`.
39130
- *
39131
- * @private
39132
- * @name set
39133
- * @memberOf MapCache
39134
- * @param {string} key The key of the value to set.
39135
- * @param {*} value The value to set.
39136
- * @returns {Object} Returns the map cache instance.
39137
- */
39138
- function mapCacheSet(key, value) {
39139
- var data = getMapData(this, key),
39140
- size = data.size;
39141
-
39142
- data.set(key, value);
39143
- this.size += data.size == size ? 0 : 1;
39144
- return this;
39145
- }
39146
-
39147
- // Add methods to `MapCache`.
39148
- MapCache.prototype.clear = mapCacheClear;
39149
- MapCache.prototype['delete'] = mapCacheDelete;
39150
- MapCache.prototype.get = mapCacheGet;
39151
- MapCache.prototype.has = mapCacheHas;
39152
- MapCache.prototype.set = mapCacheSet;
39153
-
39154
- /**
39155
- *
39156
- * Creates an array cache object to store unique values.
39157
- *
39158
- * @private
39159
- * @constructor
39160
- * @param {Array} [values] The values to cache.
39161
- */
39162
- function SetCache(values) {
39163
- var index = -1,
39164
- length = values == null ? 0 : values.length;
39165
-
39166
- this.__data__ = new MapCache;
39167
- while (++index < length) {
39168
- this.add(values[index]);
39169
- }
39170
- }
39171
-
39172
- /**
39173
- * Adds `value` to the array cache.
39174
- *
39175
- * @private
39176
- * @name add
39177
- * @memberOf SetCache
39178
- * @alias push
39179
- * @param {*} value The value to cache.
39180
- * @returns {Object} Returns the cache instance.
39181
- */
39182
- function setCacheAdd(value) {
39183
- this.__data__.set(value, HASH_UNDEFINED);
39184
- return this;
39185
- }
39186
-
39187
- /**
39188
- * Checks if `value` is in the array cache.
39189
- *
39190
- * @private
39191
- * @name has
39192
- * @memberOf SetCache
39193
- * @param {*} value The value to search for.
39194
- * @returns {number} Returns `true` if `value` is found, else `false`.
39195
- */
39196
- function setCacheHas(value) {
39197
- return this.__data__.has(value);
39198
- }
39199
-
39200
- // Add methods to `SetCache`.
39201
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
39202
- SetCache.prototype.has = setCacheHas;
39203
-
39204
- /**
39205
- * Creates a stack cache object to store key-value pairs.
39206
- *
39207
- * @private
39208
- * @constructor
39209
- * @param {Array} [entries] The key-value pairs to cache.
39210
- */
39211
- function Stack(entries) {
39212
- var data = this.__data__ = new ListCache(entries);
39213
- this.size = data.size;
39214
- }
39215
-
39216
- /**
39217
- * Removes all key-value entries from the stack.
39218
- *
39219
- * @private
39220
- * @name clear
39221
- * @memberOf Stack
39222
- */
39223
- function stackClear() {
39224
- this.__data__ = new ListCache;
39225
- this.size = 0;
39226
- }
39227
-
39228
- /**
39229
- * Removes `key` and its value from the stack.
39230
- *
39231
- * @private
39232
- * @name delete
39233
- * @memberOf Stack
39234
- * @param {string} key The key of the value to remove.
39235
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
39236
- */
39237
- function stackDelete(key) {
39238
- var data = this.__data__,
39239
- result = data['delete'](key);
39240
-
39241
- this.size = data.size;
39242
- return result;
39243
- }
39244
-
39245
- /**
39246
- * Gets the stack value for `key`.
39247
- *
39248
- * @private
39249
- * @name get
39250
- * @memberOf Stack
39251
- * @param {string} key The key of the value to get.
39252
- * @returns {*} Returns the entry value.
39253
- */
39254
- function stackGet(key) {
39255
- return this.__data__.get(key);
39256
- }
39257
-
39258
- /**
39259
- * Checks if a stack value for `key` exists.
39260
- *
39261
- * @private
39262
- * @name has
39263
- * @memberOf Stack
39264
- * @param {string} key The key of the entry to check.
39265
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
39266
- */
39267
- function stackHas(key) {
39268
- return this.__data__.has(key);
39269
- }
39270
-
39271
- /**
39272
- * Sets the stack `key` to `value`.
39273
- *
39274
- * @private
39275
- * @name set
39276
- * @memberOf Stack
39277
- * @param {string} key The key of the value to set.
39278
- * @param {*} value The value to set.
39279
- * @returns {Object} Returns the stack cache instance.
39280
- */
39281
- function stackSet(key, value) {
39282
- var data = this.__data__;
39283
- if (data instanceof ListCache) {
39284
- var pairs = data.__data__;
39285
- if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
39286
- pairs.push([key, value]);
39287
- this.size = ++data.size;
39288
- return this;
39289
- }
39290
- data = this.__data__ = new MapCache(pairs);
39291
- }
39292
- data.set(key, value);
39293
- this.size = data.size;
39294
- return this;
39295
- }
39296
-
39297
- // Add methods to `Stack`.
39298
- Stack.prototype.clear = stackClear;
39299
- Stack.prototype['delete'] = stackDelete;
39300
- Stack.prototype.get = stackGet;
39301
- Stack.prototype.has = stackHas;
39302
- Stack.prototype.set = stackSet;
39303
-
39304
- /**
39305
- * Creates an array of the enumerable property names of the array-like `value`.
39306
- *
39307
- * @private
39308
- * @param {*} value The value to query.
39309
- * @param {boolean} inherited Specify returning inherited property names.
39310
- * @returns {Array} Returns the array of property names.
39311
- */
39312
- function arrayLikeKeys(value, inherited) {
39313
- var isArr = isArray(value),
39314
- isArg = !isArr && isArguments(value),
39315
- isBuff = !isArr && !isArg && isBuffer(value),
39316
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
39317
- skipIndexes = isArr || isArg || isBuff || isType,
39318
- result = skipIndexes ? baseTimes(value.length, String) : [],
39319
- length = result.length;
39320
-
39321
- for (var key in value) {
39322
- if ((inherited || hasOwnProperty.call(value, key)) &&
39323
- !(skipIndexes && (
39324
- // Safari 9 has enumerable `arguments.length` in strict mode.
39325
- key == 'length' ||
39326
- // Node.js 0.10 has enumerable non-index properties on buffers.
39327
- (isBuff && (key == 'offset' || key == 'parent')) ||
39328
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
39329
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
39330
- // Skip index properties.
39331
- isIndex(key, length)
39332
- ))) {
39333
- result.push(key);
39334
- }
39335
- }
39336
- return result;
39337
- }
39338
-
39339
- /**
39340
- * Gets the index at which the `key` is found in `array` of key-value pairs.
39341
- *
39342
- * @private
39343
- * @param {Array} array The array to inspect.
39344
- * @param {*} key The key to search for.
39345
- * @returns {number} Returns the index of the matched value, else `-1`.
39346
- */
39347
- function assocIndexOf(array, key) {
39348
- var length = array.length;
39349
- while (length--) {
39350
- if (eq(array[length][0], key)) {
39351
- return length;
39352
- }
39353
- }
39354
- return -1;
39355
- }
39356
-
39357
- /**
39358
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
39359
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
39360
- * symbols of `object`.
39361
- *
39362
- * @private
39363
- * @param {Object} object The object to query.
39364
- * @param {Function} keysFunc The function to get the keys of `object`.
39365
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
39366
- * @returns {Array} Returns the array of property names and symbols.
39367
- */
39368
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
39369
- var result = keysFunc(object);
39370
- return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
39371
- }
39372
-
39373
- /**
39374
- * The base implementation of `getTag` without fallbacks for buggy environments.
39375
- *
39376
- * @private
39377
- * @param {*} value The value to query.
39378
- * @returns {string} Returns the `toStringTag`.
39379
- */
39380
- function baseGetTag(value) {
39381
- if (value == null) {
39382
- return value === undefined ? undefinedTag : nullTag;
39383
- }
39384
- return (symToStringTag && symToStringTag in Object(value))
39385
- ? getRawTag(value)
39386
- : objectToString(value);
39387
- }
39388
-
39389
- /**
39390
- * The base implementation of `_.isArguments`.
39391
- *
39392
- * @private
39393
- * @param {*} value The value to check.
39394
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
39395
- */
39396
- function baseIsArguments(value) {
39397
- return isObjectLike(value) && baseGetTag(value) == argsTag;
39398
- }
39399
-
39400
- /**
39401
- * The base implementation of `_.isEqual` which supports partial comparisons
39402
- * and tracks traversed objects.
39403
- *
39404
- * @private
39405
- * @param {*} value The value to compare.
39406
- * @param {*} other The other value to compare.
39407
- * @param {boolean} bitmask The bitmask flags.
39408
- * 1 - Unordered comparison
39409
- * 2 - Partial comparison
39410
- * @param {Function} [customizer] The function to customize comparisons.
39411
- * @param {Object} [stack] Tracks traversed `value` and `other` objects.
39412
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
39413
- */
39414
- function baseIsEqual(value, other, bitmask, customizer, stack) {
39415
- if (value === other) {
39416
- return true;
39417
- }
39418
- if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
39419
- return value !== value && other !== other;
39420
- }
39421
- return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
39422
- }
39423
-
39424
- /**
39425
- * A specialized version of `baseIsEqual` for arrays and objects which performs
39426
- * deep comparisons and tracks traversed objects enabling objects with circular
39427
- * references to be compared.
39428
- *
39429
- * @private
39430
- * @param {Object} object The object to compare.
39431
- * @param {Object} other The other object to compare.
39432
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
39433
- * @param {Function} customizer The function to customize comparisons.
39434
- * @param {Function} equalFunc The function to determine equivalents of values.
39435
- * @param {Object} [stack] Tracks traversed `object` and `other` objects.
39436
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
39437
- */
39438
- function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
39439
- var objIsArr = isArray(object),
39440
- othIsArr = isArray(other),
39441
- objTag = objIsArr ? arrayTag : getTag(object),
39442
- othTag = othIsArr ? arrayTag : getTag(other);
39443
-
39444
- objTag = objTag == argsTag ? objectTag : objTag;
39445
- othTag = othTag == argsTag ? objectTag : othTag;
39446
-
39447
- var objIsObj = objTag == objectTag,
39448
- othIsObj = othTag == objectTag,
39449
- isSameTag = objTag == othTag;
39450
-
39451
- if (isSameTag && isBuffer(object)) {
39452
- if (!isBuffer(other)) {
39453
- return false;
39454
- }
39455
- objIsArr = true;
39456
- objIsObj = false;
39457
- }
39458
- if (isSameTag && !objIsObj) {
39459
- stack || (stack = new Stack);
39460
- return (objIsArr || isTypedArray(object))
39461
- ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
39462
- : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
39463
- }
39464
- if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
39465
- var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
39466
- othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
39467
-
39468
- if (objIsWrapped || othIsWrapped) {
39469
- var objUnwrapped = objIsWrapped ? object.value() : object,
39470
- othUnwrapped = othIsWrapped ? other.value() : other;
39471
-
39472
- stack || (stack = new Stack);
39473
- return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
39474
- }
39475
- }
39476
- if (!isSameTag) {
39477
- return false;
39478
- }
39479
- stack || (stack = new Stack);
39480
- return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
39481
- }
39482
-
39483
- /**
39484
- * The base implementation of `_.isNative` without bad shim checks.
39485
- *
39486
- * @private
39487
- * @param {*} value The value to check.
39488
- * @returns {boolean} Returns `true` if `value` is a native function,
39489
- * else `false`.
39490
- */
39491
- function baseIsNative(value) {
39492
- if (!isObject(value) || isMasked(value)) {
39493
- return false;
39494
- }
39495
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
39496
- return pattern.test(toSource(value));
39497
- }
39498
-
39499
- /**
39500
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
39501
- *
39502
- * @private
39503
- * @param {*} value The value to check.
39504
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
39505
- */
39506
- function baseIsTypedArray(value) {
39507
- return isObjectLike(value) &&
39508
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
39509
- }
39510
-
39511
- /**
39512
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
39513
- *
39514
- * @private
39515
- * @param {Object} object The object to query.
39516
- * @returns {Array} Returns the array of property names.
39517
- */
39518
- function baseKeys(object) {
39519
- if (!isPrototype(object)) {
39520
- return nativeKeys(object);
39521
- }
39522
- var result = [];
39523
- for (var key in Object(object)) {
39524
- if (hasOwnProperty.call(object, key) && key != 'constructor') {
39525
- result.push(key);
39526
- }
39527
- }
39528
- return result;
39529
- }
39530
-
39531
- /**
39532
- * A specialized version of `baseIsEqualDeep` for arrays with support for
39533
- * partial deep comparisons.
39534
- *
39535
- * @private
39536
- * @param {Array} array The array to compare.
39537
- * @param {Array} other The other array to compare.
39538
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
39539
- * @param {Function} customizer The function to customize comparisons.
39540
- * @param {Function} equalFunc The function to determine equivalents of values.
39541
- * @param {Object} stack Tracks traversed `array` and `other` objects.
39542
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
39543
- */
39544
- function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
39545
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
39546
- arrLength = array.length,
39547
- othLength = other.length;
39548
-
39549
- if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
39550
- return false;
39551
- }
39552
- // Assume cyclic values are equal.
39553
- var stacked = stack.get(array);
39554
- if (stacked && stack.get(other)) {
39555
- return stacked == other;
39556
- }
39557
- var index = -1,
39558
- result = true,
39559
- seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
39560
-
39561
- stack.set(array, other);
39562
- stack.set(other, array);
39563
-
39564
- // Ignore non-index properties.
39565
- while (++index < arrLength) {
39566
- var arrValue = array[index],
39567
- othValue = other[index];
39568
-
39569
- if (customizer) {
39570
- var compared = isPartial
39571
- ? customizer(othValue, arrValue, index, other, array, stack)
39572
- : customizer(arrValue, othValue, index, array, other, stack);
39573
- }
39574
- if (compared !== undefined) {
39575
- if (compared) {
39576
- continue;
39577
- }
39578
- result = false;
39579
- break;
39580
- }
39581
- // Recursively compare arrays (susceptible to call stack limits).
39582
- if (seen) {
39583
- if (!arraySome(other, function(othValue, othIndex) {
39584
- if (!cacheHas(seen, othIndex) &&
39585
- (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
39586
- return seen.push(othIndex);
39587
- }
39588
- })) {
39589
- result = false;
39590
- break;
39591
- }
39592
- } else if (!(
39593
- arrValue === othValue ||
39594
- equalFunc(arrValue, othValue, bitmask, customizer, stack)
39595
- )) {
39596
- result = false;
39597
- break;
39598
- }
39599
- }
39600
- stack['delete'](array);
39601
- stack['delete'](other);
39602
- return result;
39603
- }
39604
-
39605
- /**
39606
- * A specialized version of `baseIsEqualDeep` for comparing objects of
39607
- * the same `toStringTag`.
39608
- *
39609
- * **Note:** This function only supports comparing values with tags of
39610
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
39611
- *
39612
- * @private
39613
- * @param {Object} object The object to compare.
39614
- * @param {Object} other The other object to compare.
39615
- * @param {string} tag The `toStringTag` of the objects to compare.
39616
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
39617
- * @param {Function} customizer The function to customize comparisons.
39618
- * @param {Function} equalFunc The function to determine equivalents of values.
39619
- * @param {Object} stack Tracks traversed `object` and `other` objects.
39620
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
39621
- */
39622
- function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
39623
- switch (tag) {
39624
- case dataViewTag:
39625
- if ((object.byteLength != other.byteLength) ||
39626
- (object.byteOffset != other.byteOffset)) {
39627
- return false;
39628
- }
39629
- object = object.buffer;
39630
- other = other.buffer;
39631
-
39632
- case arrayBufferTag:
39633
- if ((object.byteLength != other.byteLength) ||
39634
- !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
39635
- return false;
39636
- }
39637
- return true;
39638
-
39639
- case boolTag:
39640
- case dateTag:
39641
- case numberTag:
39642
- // Coerce booleans to `1` or `0` and dates to milliseconds.
39643
- // Invalid dates are coerced to `NaN`.
39644
- return eq(+object, +other);
39645
-
39646
- case errorTag:
39647
- return object.name == other.name && object.message == other.message;
39648
-
39649
- case regexpTag:
39650
- case stringTag:
39651
- // Coerce regexes to strings and treat strings, primitives and objects,
39652
- // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
39653
- // for more details.
39654
- return object == (other + '');
39655
-
39656
- case mapTag:
39657
- var convert = mapToArray;
39658
-
39659
- case setTag:
39660
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
39661
- convert || (convert = setToArray);
39662
-
39663
- if (object.size != other.size && !isPartial) {
39664
- return false;
39665
- }
39666
- // Assume cyclic values are equal.
39667
- var stacked = stack.get(object);
39668
- if (stacked) {
39669
- return stacked == other;
39670
- }
39671
- bitmask |= COMPARE_UNORDERED_FLAG;
39672
-
39673
- // Recursively compare objects (susceptible to call stack limits).
39674
- stack.set(object, other);
39675
- var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
39676
- stack['delete'](object);
39677
- return result;
39678
-
39679
- case symbolTag:
39680
- if (symbolValueOf) {
39681
- return symbolValueOf.call(object) == symbolValueOf.call(other);
39682
- }
39683
- }
39684
- return false;
39685
- }
39686
-
39687
- /**
39688
- * A specialized version of `baseIsEqualDeep` for objects with support for
39689
- * partial deep comparisons.
39690
- *
39691
- * @private
39692
- * @param {Object} object The object to compare.
39693
- * @param {Object} other The other object to compare.
39694
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
39695
- * @param {Function} customizer The function to customize comparisons.
39696
- * @param {Function} equalFunc The function to determine equivalents of values.
39697
- * @param {Object} stack Tracks traversed `object` and `other` objects.
39698
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
39699
- */
39700
- function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
39701
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
39702
- objProps = getAllKeys(object),
39703
- objLength = objProps.length,
39704
- othProps = getAllKeys(other),
39705
- othLength = othProps.length;
39706
-
39707
- if (objLength != othLength && !isPartial) {
39708
- return false;
39709
- }
39710
- var index = objLength;
39711
- while (index--) {
39712
- var key = objProps[index];
39713
- if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
39714
- return false;
39715
- }
39716
- }
39717
- // Assume cyclic values are equal.
39718
- var stacked = stack.get(object);
39719
- if (stacked && stack.get(other)) {
39720
- return stacked == other;
39721
- }
39722
- var result = true;
39723
- stack.set(object, other);
39724
- stack.set(other, object);
39725
-
39726
- var skipCtor = isPartial;
39727
- while (++index < objLength) {
39728
- key = objProps[index];
39729
- var objValue = object[key],
39730
- othValue = other[key];
39731
-
39732
- if (customizer) {
39733
- var compared = isPartial
39734
- ? customizer(othValue, objValue, key, other, object, stack)
39735
- : customizer(objValue, othValue, key, object, other, stack);
39736
- }
39737
- // Recursively compare objects (susceptible to call stack limits).
39738
- if (!(compared === undefined
39739
- ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
39740
- : compared
39741
- )) {
39742
- result = false;
39743
- break;
39744
- }
39745
- skipCtor || (skipCtor = key == 'constructor');
39746
- }
39747
- if (result && !skipCtor) {
39748
- var objCtor = object.constructor,
39749
- othCtor = other.constructor;
39750
-
39751
- // Non `Object` object instances with different constructors are not equal.
39752
- if (objCtor != othCtor &&
39753
- ('constructor' in object && 'constructor' in other) &&
39754
- !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
39755
- typeof othCtor == 'function' && othCtor instanceof othCtor)) {
39756
- result = false;
39757
- }
39758
- }
39759
- stack['delete'](object);
39760
- stack['delete'](other);
39761
- return result;
39762
- }
39763
-
39764
- /**
39765
- * Creates an array of own enumerable property names and symbols of `object`.
39766
- *
39767
- * @private
39768
- * @param {Object} object The object to query.
39769
- * @returns {Array} Returns the array of property names and symbols.
39770
- */
39771
- function getAllKeys(object) {
39772
- return baseGetAllKeys(object, keys, getSymbols);
39773
- }
39774
-
39775
- /**
39776
- * Gets the data for `map`.
39777
- *
39778
- * @private
39779
- * @param {Object} map The map to query.
39780
- * @param {string} key The reference key.
39781
- * @returns {*} Returns the map data.
39782
- */
39783
- function getMapData(map, key) {
39784
- var data = map.__data__;
39785
- return isKeyable(key)
39786
- ? data[typeof key == 'string' ? 'string' : 'hash']
39787
- : data.map;
39788
- }
39789
-
39790
- /**
39791
- * Gets the native function at `key` of `object`.
39792
- *
39793
- * @private
39794
- * @param {Object} object The object to query.
39795
- * @param {string} key The key of the method to get.
39796
- * @returns {*} Returns the function if it's native, else `undefined`.
39797
- */
39798
- function getNative(object, key) {
39799
- var value = getValue(object, key);
39800
- return baseIsNative(value) ? value : undefined;
39801
- }
39802
-
39803
- /**
39804
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
39805
- *
39806
- * @private
39807
- * @param {*} value The value to query.
39808
- * @returns {string} Returns the raw `toStringTag`.
39809
- */
39810
- function getRawTag(value) {
39811
- var isOwn = hasOwnProperty.call(value, symToStringTag),
39812
- tag = value[symToStringTag];
39813
-
39814
- try {
39815
- value[symToStringTag] = undefined;
39816
- var unmasked = true;
39817
- } catch (e) {}
39818
-
39819
- var result = nativeObjectToString.call(value);
39820
- if (unmasked) {
39821
- if (isOwn) {
39822
- value[symToStringTag] = tag;
39823
- } else {
39824
- delete value[symToStringTag];
39825
- }
39826
- }
39827
- return result;
39828
- }
39829
-
39830
- /**
39831
- * Creates an array of the own enumerable symbols of `object`.
39832
- *
39833
- * @private
39834
- * @param {Object} object The object to query.
39835
- * @returns {Array} Returns the array of symbols.
39836
- */
39837
- var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
39838
- if (object == null) {
39839
- return [];
39840
- }
39841
- object = Object(object);
39842
- return arrayFilter(nativeGetSymbols(object), function(symbol) {
39843
- return propertyIsEnumerable.call(object, symbol);
39844
- });
39845
- };
39846
-
39847
- /**
39848
- * Gets the `toStringTag` of `value`.
39849
- *
39850
- * @private
39851
- * @param {*} value The value to query.
39852
- * @returns {string} Returns the `toStringTag`.
39853
- */
39854
- var getTag = baseGetTag;
39855
-
39856
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
39857
- if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
39858
- (Map && getTag(new Map) != mapTag) ||
39859
- (Promise && getTag(Promise.resolve()) != promiseTag) ||
39860
- (Set && getTag(new Set) != setTag) ||
39861
- (WeakMap && getTag(new WeakMap) != weakMapTag)) {
39862
- getTag = function(value) {
39863
- var result = baseGetTag(value),
39864
- Ctor = result == objectTag ? value.constructor : undefined,
39865
- ctorString = Ctor ? toSource(Ctor) : '';
39866
-
39867
- if (ctorString) {
39868
- switch (ctorString) {
39869
- case dataViewCtorString: return dataViewTag;
39870
- case mapCtorString: return mapTag;
39871
- case promiseCtorString: return promiseTag;
39872
- case setCtorString: return setTag;
39873
- case weakMapCtorString: return weakMapTag;
39874
- }
39875
- }
39876
- return result;
39877
- };
39878
- }
39879
-
39880
- /**
39881
- * Checks if `value` is a valid array-like index.
39882
- *
39883
- * @private
39884
- * @param {*} value The value to check.
39885
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
39886
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
39887
- */
39888
- function isIndex(value, length) {
39889
- length = length == null ? MAX_SAFE_INTEGER : length;
39890
- return !!length &&
39891
- (typeof value == 'number' || reIsUint.test(value)) &&
39892
- (value > -1 && value % 1 == 0 && value < length);
39893
- }
39894
-
39895
- /**
39896
- * Checks if `value` is suitable for use as unique object key.
39897
- *
39898
- * @private
39899
- * @param {*} value The value to check.
39900
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
39901
- */
39902
- function isKeyable(value) {
39903
- var type = typeof value;
39904
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
39905
- ? (value !== '__proto__')
39906
- : (value === null);
39907
- }
39908
-
39909
- /**
39910
- * Checks if `func` has its source masked.
39911
- *
39912
- * @private
39913
- * @param {Function} func The function to check.
39914
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
39915
- */
39916
- function isMasked(func) {
39917
- return !!maskSrcKey && (maskSrcKey in func);
39918
- }
39919
-
39920
- /**
39921
- * Checks if `value` is likely a prototype object.
39922
- *
39923
- * @private
39924
- * @param {*} value The value to check.
39925
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
39926
- */
39927
- function isPrototype(value) {
39928
- var Ctor = value && value.constructor,
39929
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
39930
-
39931
- return value === proto;
39932
- }
39933
-
39934
- /**
39935
- * Converts `value` to a string using `Object.prototype.toString`.
39936
- *
39937
- * @private
39938
- * @param {*} value The value to convert.
39939
- * @returns {string} Returns the converted string.
39940
- */
39941
- function objectToString(value) {
39942
- return nativeObjectToString.call(value);
39943
- }
39944
-
39945
- /**
39946
- * Converts `func` to its source code.
39947
- *
39948
- * @private
39949
- * @param {Function} func The function to convert.
39950
- * @returns {string} Returns the source code.
39951
- */
39952
- function toSource(func) {
39953
- if (func != null) {
39954
- try {
39955
- return funcToString.call(func);
39956
- } catch (e) {}
39957
- try {
39958
- return (func + '');
39959
- } catch (e) {}
39960
- }
39961
- return '';
39962
- }
39963
-
39964
- /**
39965
- * Performs a
39966
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
39967
- * comparison between two values to determine if they are equivalent.
39968
- *
39969
- * @static
39970
- * @memberOf _
39971
- * @since 4.0.0
39972
- * @category Lang
39973
- * @param {*} value The value to compare.
39974
- * @param {*} other The other value to compare.
39975
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
39976
- * @example
39977
- *
39978
- * var object = { 'a': 1 };
39979
- * var other = { 'a': 1 };
39980
- *
39981
- * _.eq(object, object);
39982
- * // => true
39983
- *
39984
- * _.eq(object, other);
39985
- * // => false
39986
- *
39987
- * _.eq('a', 'a');
39988
- * // => true
39989
- *
39990
- * _.eq('a', Object('a'));
39991
- * // => false
39992
- *
39993
- * _.eq(NaN, NaN);
39994
- * // => true
39995
- */
39996
- function eq(value, other) {
39997
- return value === other || (value !== value && other !== other);
39998
- }
39999
-
40000
- /**
40001
- * Checks if `value` is likely an `arguments` object.
40002
- *
40003
- * @static
40004
- * @memberOf _
40005
- * @since 0.1.0
40006
- * @category Lang
40007
- * @param {*} value The value to check.
40008
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
40009
- * else `false`.
40010
- * @example
40011
- *
40012
- * _.isArguments(function() { return arguments; }());
40013
- * // => true
40014
- *
40015
- * _.isArguments([1, 2, 3]);
40016
- * // => false
40017
- */
40018
- var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
40019
- return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
40020
- !propertyIsEnumerable.call(value, 'callee');
40021
- };
40022
-
40023
- /**
40024
- * Checks if `value` is classified as an `Array` object.
40025
- *
40026
- * @static
40027
- * @memberOf _
40028
- * @since 0.1.0
40029
- * @category Lang
40030
- * @param {*} value The value to check.
40031
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
40032
- * @example
40033
- *
40034
- * _.isArray([1, 2, 3]);
40035
- * // => true
40036
- *
40037
- * _.isArray(document.body.children);
40038
- * // => false
40039
- *
40040
- * _.isArray('abc');
40041
- * // => false
40042
- *
40043
- * _.isArray(_.noop);
40044
- * // => false
40045
- */
40046
- var isArray = Array.isArray;
40047
-
40048
- /**
40049
- * Checks if `value` is array-like. A value is considered array-like if it's
40050
- * not a function and has a `value.length` that's an integer greater than or
40051
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
40052
- *
40053
- * @static
40054
- * @memberOf _
40055
- * @since 4.0.0
40056
- * @category Lang
40057
- * @param {*} value The value to check.
40058
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
40059
- * @example
40060
- *
40061
- * _.isArrayLike([1, 2, 3]);
40062
- * // => true
40063
- *
40064
- * _.isArrayLike(document.body.children);
40065
- * // => true
40066
- *
40067
- * _.isArrayLike('abc');
40068
- * // => true
40069
- *
40070
- * _.isArrayLike(_.noop);
40071
- * // => false
40072
- */
40073
- function isArrayLike(value) {
40074
- return value != null && isLength(value.length) && !isFunction(value);
40075
- }
40076
-
40077
- /**
40078
- * Checks if `value` is a buffer.
40079
- *
40080
- * @static
40081
- * @memberOf _
40082
- * @since 4.3.0
40083
- * @category Lang
40084
- * @param {*} value The value to check.
40085
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
40086
- * @example
40087
- *
40088
- * _.isBuffer(new Buffer(2));
40089
- * // => true
40090
- *
40091
- * _.isBuffer(new Uint8Array(2));
40092
- * // => false
40093
- */
40094
- var isBuffer = nativeIsBuffer || stubFalse;
40095
-
40096
- /**
40097
- * Performs a deep comparison between two values to determine if they are
40098
- * equivalent.
40099
- *
40100
- * **Note:** This method supports comparing arrays, array buffers, booleans,
40101
- * date objects, error objects, maps, numbers, `Object` objects, regexes,
40102
- * sets, strings, symbols, and typed arrays. `Object` objects are compared
40103
- * by their own, not inherited, enumerable properties. Functions and DOM
40104
- * nodes are compared by strict equality, i.e. `===`.
40105
- *
40106
- * @static
40107
- * @memberOf _
40108
- * @since 0.1.0
40109
- * @category Lang
40110
- * @param {*} value The value to compare.
40111
- * @param {*} other The other value to compare.
40112
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
40113
- * @example
40114
- *
40115
- * var object = { 'a': 1 };
40116
- * var other = { 'a': 1 };
40117
- *
40118
- * _.isEqual(object, other);
40119
- * // => true
40120
- *
40121
- * object === other;
40122
- * // => false
40123
- */
40124
- function isEqual(value, other) {
40125
- return baseIsEqual(value, other);
40126
- }
40127
-
40128
- /**
40129
- * Checks if `value` is classified as a `Function` object.
40130
- *
40131
- * @static
40132
- * @memberOf _
40133
- * @since 0.1.0
40134
- * @category Lang
40135
- * @param {*} value The value to check.
40136
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
40137
- * @example
40138
- *
40139
- * _.isFunction(_);
40140
- * // => true
40141
- *
40142
- * _.isFunction(/abc/);
40143
- * // => false
40144
- */
40145
- function isFunction(value) {
40146
- if (!isObject(value)) {
40147
- return false;
40148
- }
40149
- // The use of `Object#toString` avoids issues with the `typeof` operator
40150
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
40151
- var tag = baseGetTag(value);
40152
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
40153
- }
40154
-
40155
- /**
40156
- * Checks if `value` is a valid array-like length.
40157
- *
40158
- * **Note:** This method is loosely based on
40159
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
40160
- *
40161
- * @static
40162
- * @memberOf _
40163
- * @since 4.0.0
40164
- * @category Lang
40165
- * @param {*} value The value to check.
40166
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
40167
- * @example
40168
- *
40169
- * _.isLength(3);
40170
- * // => true
40171
- *
40172
- * _.isLength(Number.MIN_VALUE);
40173
- * // => false
40174
- *
40175
- * _.isLength(Infinity);
40176
- * // => false
40177
- *
40178
- * _.isLength('3');
40179
- * // => false
40180
- */
40181
- function isLength(value) {
40182
- return typeof value == 'number' &&
40183
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
40184
- }
40185
-
40186
- /**
40187
- * Checks if `value` is the
40188
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
40189
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
40190
- *
40191
- * @static
40192
- * @memberOf _
40193
- * @since 0.1.0
40194
- * @category Lang
40195
- * @param {*} value The value to check.
40196
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
40197
- * @example
40198
- *
40199
- * _.isObject({});
40200
- * // => true
40201
- *
40202
- * _.isObject([1, 2, 3]);
40203
- * // => true
40204
- *
40205
- * _.isObject(_.noop);
40206
- * // => true
40207
- *
40208
- * _.isObject(null);
40209
- * // => false
40210
- */
40211
- function isObject(value) {
40212
- var type = typeof value;
40213
- return value != null && (type == 'object' || type == 'function');
40214
- }
40215
-
40216
- /**
40217
- * Checks if `value` is object-like. A value is object-like if it's not `null`
40218
- * and has a `typeof` result of "object".
40219
- *
40220
- * @static
40221
- * @memberOf _
40222
- * @since 4.0.0
40223
- * @category Lang
40224
- * @param {*} value The value to check.
40225
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
40226
- * @example
40227
- *
40228
- * _.isObjectLike({});
40229
- * // => true
40230
- *
40231
- * _.isObjectLike([1, 2, 3]);
40232
- * // => true
40233
- *
40234
- * _.isObjectLike(_.noop);
40235
- * // => false
40236
- *
40237
- * _.isObjectLike(null);
40238
- * // => false
40239
- */
40240
- function isObjectLike(value) {
40241
- return value != null && typeof value == 'object';
40242
- }
40243
-
40244
- /**
40245
- * Checks if `value` is classified as a typed array.
40246
- *
40247
- * @static
40248
- * @memberOf _
40249
- * @since 3.0.0
40250
- * @category Lang
40251
- * @param {*} value The value to check.
40252
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
40253
- * @example
40254
- *
40255
- * _.isTypedArray(new Uint8Array);
40256
- * // => true
40257
- *
40258
- * _.isTypedArray([]);
40259
- * // => false
40260
- */
40261
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
40262
-
40263
- /**
40264
- * Creates an array of the own enumerable property names of `object`.
40265
- *
40266
- * **Note:** Non-object values are coerced to objects. See the
40267
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
40268
- * for more details.
40269
- *
40270
- * @static
40271
- * @since 0.1.0
40272
- * @memberOf _
40273
- * @category Object
40274
- * @param {Object} object The object to query.
40275
- * @returns {Array} Returns the array of property names.
40276
- * @example
40277
- *
40278
- * function Foo() {
40279
- * this.a = 1;
40280
- * this.b = 2;
40281
- * }
40282
- *
40283
- * Foo.prototype.c = 3;
40284
- *
40285
- * _.keys(new Foo);
40286
- * // => ['a', 'b'] (iteration order is not guaranteed)
40287
- *
40288
- * _.keys('hi');
40289
- * // => ['0', '1']
40290
- */
40291
- function keys(object) {
40292
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
40293
- }
40294
-
40295
- /**
40296
- * This method returns a new empty array.
40297
- *
40298
- * @static
40299
- * @memberOf _
40300
- * @since 4.13.0
40301
- * @category Util
40302
- * @returns {Array} Returns the new empty array.
40303
- * @example
40304
- *
40305
- * var arrays = _.times(2, _.stubArray);
40306
- *
40307
- * console.log(arrays);
40308
- * // => [[], []]
40309
- *
40310
- * console.log(arrays[0] === arrays[1]);
40311
- * // => false
40312
- */
40313
- function stubArray() {
40314
- return [];
40315
- }
40316
-
40317
- /**
40318
- * This method returns `false`.
40319
- *
40320
- * @static
40321
- * @memberOf _
40322
- * @since 4.13.0
40323
- * @category Util
40324
- * @returns {boolean} Returns `false`.
40325
- * @example
40326
- *
40327
- * _.times(2, _.stubFalse);
40328
- * // => [false, false]
40329
- */
40330
- function stubFalse() {
40331
- return false;
40332
- }
40333
-
40334
- module.exports = isEqual;
40335
- });
40336
-
40337
- var dist$3 = createCommonjsModule$1(function (module, exports) {
40338
- (function (global, factory) {
40339
- module.exports = factory(dist$6, require$$2$1, require$$2, lodash_throttle, require$$1, require$$4, lodash_isequal) ;
40340
- })(commonjsGlobal, (function (core, slate, snabbdom, throttle, $, nanoid, isEqual) {
40341
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
40342
-
40343
- var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle);
40344
- var $__default = /*#__PURE__*/_interopDefaultLegacy($);
40345
- var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
38838
+ var Point = /** @class */ (function () {
38839
+ function Point(x, y) {
38840
+ this.x = x;
38841
+ this.y = y;
38842
+ }
38843
+ Point.valueOf = function (x, y) {
38844
+ return new this(x, y);
38845
+ };
38846
+ Point.equals = function (point, another) {
38847
+ return point.x === another.x && point.y === another.y;
38848
+ };
38849
+ return Point;
38850
+ }());
40346
38851
 
40347
- /**
40348
- * @description i18n en
40349
- * @author wangfupeng
40350
- */
40351
- var enResources = {
40352
- tableModule: {
40353
- deleteCol: 'Delete column',
40354
- deleteRow: 'Delete row',
40355
- deleteTable: 'Delete table',
40356
- widthAuto: 'Width auto',
40357
- insertCol: 'Insert column',
40358
- insertRow: 'Insert row',
40359
- insertTable: 'Insert table',
40360
- header: 'Header',
38852
+ var TableCursor = {
38853
+ /** @returns {boolean} `true` if the selection is inside a table, otherwise `false`. */
38854
+ isInTable: function (editor, options) {
38855
+ if (options === void 0) { options = {}; }
38856
+ var _a = __read(slate.Editor.nodes(editor, {
38857
+ match: isOfType(editor, 'table'),
38858
+ at: options.at,
38859
+ }), 1), table = _a[0];
38860
+ return !!table;
40361
38861
  },
40362
- };
40363
-
40364
- /**
40365
- * @description i18n zh-CN
40366
- * @author wangfupeng
40367
- */
40368
- var zhResources = {
40369
- tableModule: {
40370
- deleteCol: '删除列',
40371
- deleteRow: '删除行',
40372
- deleteTable: '删除表格',
40373
- widthAuto: '宽度自适应',
40374
- insertCol: '插入列',
40375
- insertRow: '插入行',
40376
- insertTable: '插入表格',
40377
- header: '表头',
38862
+ /**
38863
+ * Retrieves a matrix representing the selected cells within a table.
38864
+ * @returns {NodeEntry<T>[][]} A matrix containing the selected cells.
38865
+ */
38866
+ selection: function (editor) {
38867
+ var matrix, x, cells, y, _a, entry, _b, colSpan, ttb;
38868
+ return __generator(this, function (_c) {
38869
+ switch (_c.label) {
38870
+ case 0:
38871
+ matrix = EDITOR_TO_SELECTION.get(editor);
38872
+ x = 0;
38873
+ _c.label = 1;
38874
+ case 1:
38875
+ if (!(matrix && x < matrix.length)) return [3 /*break*/, 4];
38876
+ cells = [];
38877
+ for (y = 0; y < matrix[x].length; y++) {
38878
+ _a = __read(matrix[x][y], 2), entry = _a[0], _b = _a[1], colSpan = _b.ltr, ttb = _b.ttb;
38879
+ ttb === 1 && cells.push(entry);
38880
+ y += colSpan - 1;
38881
+ }
38882
+ return [4 /*yield*/, cells];
38883
+ case 2:
38884
+ _c.sent();
38885
+ _c.label = 3;
38886
+ case 3:
38887
+ x++;
38888
+ return [3 /*break*/, 1];
38889
+ case 4: return [2 /*return*/];
38890
+ }
38891
+ });
38892
+ },
38893
+ /** Clears the selection from the table */
38894
+ unselect: function (editor) {
38895
+ // const matrix = EDITOR_TO_SELECTION.get(editor);
38896
+ var _a;
38897
+ // if (!matrix?.length) {
38898
+ // return;
38899
+ // }
38900
+ // for (let x = 0; x < matrix.length; x++) {
38901
+ // for (let y = 0; y < matrix[x].length; y++) {
38902
+ // const [[, path], { ltr: colSpan, ttb }] = matrix[x][y];
38903
+ // y += colSpan - 1;
38904
+ // if (ttb > 1) {
38905
+ // continue;
38906
+ // }
38907
+ // // no-op since the paths are the same
38908
+ // const noop: Operation = {
38909
+ // type: "move_node",
38910
+ // newPath: path,
38911
+ // path: path,
38912
+ // };
38913
+ // Transforms.transform(editor, noop);
38914
+ // }
38915
+ // }
38916
+ EDITOR_TO_SELECTION_SET.delete(editor);
38917
+ EDITOR_TO_SELECTION.delete(editor);
38918
+ // 清除选区
38919
+ (_a = document.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
38920
+ },
38921
+ /**
38922
+ * Checks whether a given cell is part of the current table selection.
38923
+ * @returns {boolean} - Returns true if the cell is selected, otherwise false.
38924
+ */
38925
+ isSelected: function (editor, element) {
38926
+ var selectedElements = EDITOR_TO_SELECTION_SET.get(editor);
38927
+ if (!selectedElements) {
38928
+ return false;
38929
+ }
38930
+ return selectedElements.has(element);
40378
38931
  },
40379
38932
  };
40380
38933
 
40381
- /**
40382
- * @description i18n entry
40383
- * @author wangfupeng
40384
- */
40385
- core.i18nAddResources('en', enResources);
40386
- core.i18nAddResources('zh-CN', zhResources);
40387
-
40388
- /*! *****************************************************************************
40389
- Copyright (c) Microsoft Corporation.
40390
-
40391
- Permission to use, copy, modify, and/or distribute this software for any
40392
- purpose with or without fee is hereby granted.
40393
-
40394
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
40395
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
40396
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
40397
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
40398
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
40399
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
40400
- PERFORMANCE OF THIS SOFTWARE.
40401
- ***************************************************************************** */
40402
-
40403
- function __values(o) {
40404
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40405
- if (m) return m.call(o);
40406
- if (o && typeof o.length === "number") return {
40407
- next: function () {
40408
- if (o && i >= o.length) o = void 0;
40409
- return { value: o && o[i++], done: !o };
38934
+ function withSelection(editor) {
38935
+ var apply = editor.apply;
38936
+ editor.apply = function (op) {
38937
+ if (!slate.Operation.isSelectionOperation(op) || !op.newProperties) {
38938
+ // TableCursor.unselect(editor);
38939
+ // 仿飞书效果,拖动单元格宽度时,选区不消失
38940
+ return apply(op);
40410
38941
  }
40411
- };
40412
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
40413
- }
40414
-
40415
- function __read(o, n) {
40416
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40417
- if (!m) return o;
40418
- var i = m.call(o), r, ar = [], e;
40419
- try {
40420
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
40421
- }
40422
- catch (error) { e = { error: error }; }
40423
- finally {
40424
- try {
40425
- if (r && !r.done && (m = i["return"])) m.call(i);
38942
+ var selection = __assign(__assign({}, editor.selection), op.newProperties);
38943
+ if (!slate.Range.isRange(selection)) {
38944
+ TableCursor.unselect(editor);
38945
+ return apply(op);
40426
38946
  }
40427
- finally { if (e) throw e.error; }
40428
- }
40429
- return ar;
38947
+ var _a = __read(slate.Editor.nodes(editor, {
38948
+ match: isOfType(editor, 'th', 'td'),
38949
+ at: slate.Range.start(selection),
38950
+ }), 1), fromEntry = _a[0];
38951
+ var _b = __read(slate.Editor.nodes(editor, {
38952
+ match: isOfType(editor, 'th', 'td'),
38953
+ at: slate.Range.end(selection),
38954
+ }), 1), toEntry = _b[0];
38955
+ if (!fromEntry || !toEntry) {
38956
+ TableCursor.unselect(editor);
38957
+ return apply(op);
38958
+ }
38959
+ var _c = __read(fromEntry, 2), fromPath = _c[1];
38960
+ var _d = __read(toEntry, 2), toPath = _d[1];
38961
+ if (slate.Path.equals(fromPath, toPath) || !hasCommon(editor, [fromPath, toPath], 'table')) {
38962
+ TableCursor.unselect(editor);
38963
+ return apply(op);
38964
+ }
38965
+ // TODO: perf: could be improved by passing a Span [fromPath, toPath]
38966
+ var filled = filledMatrix(editor, { at: fromPath });
38967
+ // find initial bounds
38968
+ var from = Point.valueOf(0, 0);
38969
+ var to = Point.valueOf(0, 0);
38970
+ outer: for (var x = 0; x < filled.length; x++) {
38971
+ for (var y = 0; y < filled[x].length; y++) {
38972
+ var _e = __read(filled[x][y], 1), _f = __read(_e[0], 2), path = _f[1];
38973
+ if (slate.Path.equals(fromPath, path)) {
38974
+ from.x = x;
38975
+ from.y = y;
38976
+ }
38977
+ if (slate.Path.equals(toPath, path)) {
38978
+ to.x = x;
38979
+ to.y = y;
38980
+ break outer;
38981
+ }
38982
+ }
38983
+ }
38984
+ var start = Point.valueOf(Math.min(from.x, to.x), Math.min(from.y, to.y));
38985
+ var end = Point.valueOf(Math.max(from.x, to.x), Math.max(from.y, to.y));
38986
+ // expand the selection based on rowspan and colspan
38987
+ for (;;) {
38988
+ var nextStart = Point.valueOf(start.x, start.y);
38989
+ var nextEnd = Point.valueOf(end.x, end.y);
38990
+ for (var x = nextStart.x; x <= nextEnd.x; x++) {
38991
+ for (var y = nextStart.y; y <= nextEnd.y; y++) {
38992
+ var _g = __read(filled[x][y], 2), _h = _g[1], rtl = _h.rtl, ltr = _h.ltr, btt = _h.btt, ttb = _h.ttb;
38993
+ nextStart.x = Math.min(nextStart.x, x - (ttb - 1));
38994
+ nextStart.y = Math.min(nextStart.y, y - (rtl - 1));
38995
+ nextEnd.x = Math.max(nextEnd.x, x + (btt - 1));
38996
+ nextEnd.y = Math.max(nextEnd.y, y + (ltr - 1));
38997
+ }
38998
+ }
38999
+ if (Point.equals(start, nextStart) && Point.equals(end, nextEnd)) {
39000
+ break;
39001
+ }
39002
+ start = nextStart;
39003
+ end = nextEnd;
39004
+ }
39005
+ var selected = [];
39006
+ var selectedSet = new WeakSet();
39007
+ for (var x = start.x; x <= end.x; x++) {
39008
+ var cells = [];
39009
+ for (var y = start.y; y <= end.y; y++) {
39010
+ var _j = __read(filled[x][y], 1), _k = __read(_j[0], 1), element = _k[0];
39011
+ selectedSet.add(element);
39012
+ cells.push(filled[x][y]);
39013
+ }
39014
+ selected.push(cells);
39015
+ }
39016
+ EDITOR_TO_SELECTION.set(editor, selected);
39017
+ EDITOR_TO_SELECTION_SET.set(editor, selectedSet);
39018
+ apply(op);
39019
+ };
39020
+ return editor;
40430
39021
  }
40431
39022
 
40432
39023
  /**
@@ -40618,49 +39209,299 @@
40618
39209
  };
40619
39210
  newEditor.select(newSelection); // 选中 table-cell 内部的全部文字
40620
39211
  };
39212
+ /**
39213
+ * 光标选区行为新增
39214
+ */
39215
+ withSelection(newEditor);
40621
39216
  // 可继续修改其他 newEditor API ...
40622
39217
  // 返回 editor ,重要!
40623
39218
  return newEditor;
40624
39219
  }
40625
39220
 
40626
39221
  /**
40627
- * @description table menu helpers
39222
+ * @description DOM 操作
40628
39223
  * @author wangfupeng
40629
39224
  */
39225
+ if ($.append)
39226
+ $__default["default"].fn.append = $.append;
39227
+ if ($.on)
39228
+ $__default["default"].fn.on = $.on;
39229
+ if ($.focus)
39230
+ $__default["default"].fn.focus = $.focus;
39231
+ if ($.attr)
39232
+ $__default["default"].fn.attr = $.attr;
39233
+ if ($.val)
39234
+ $__default["default"].fn.val = $.val;
39235
+ if ($.html)
39236
+ $__default["default"].fn.html = $.html;
39237
+ if ($.dataset)
39238
+ $__default["default"].fn.dataset = $.dataset;
39239
+ if ($.addClass)
39240
+ $__default["default"].fn.addClass = $.addClass;
39241
+ if ($.removeClass)
39242
+ $__default["default"].fn.removeClass = $.removeClass;
39243
+ if ($.children)
39244
+ $__default["default"].fn.children = $.children;
39245
+ if ($.each)
39246
+ $__default["default"].fn.each = $.each;
39247
+ if ($.find)
39248
+ $__default["default"].fn.find = $.find;
40630
39249
  /**
40631
- * 获取第一行所有 cells
40632
- * @param tableNode table node
39250
+ * 获取 tagName lower-case
39251
+ * @param $elem $elem
40633
39252
  */
40634
- function getFirstRowCells(tableNode) {
40635
- var rows = tableNode.children || []; // 所有行
40636
- if (rows.length === 0)
40637
- return [];
40638
- var firstRow = rows[0] || {}; // 第一行
40639
- var cells = firstRow.children || []; // 第一行所有 cell
40640
- return cells;
39253
+ function getTagName($elem) {
39254
+ if ($elem.length)
39255
+ return $elem[0].tagName.toLowerCase();
39256
+ return '';
40641
39257
  }
40642
39258
  /**
40643
- * 表格是否带有表头?
40644
- * @param tableNode table node
39259
+ * 获取 $elem 某一个 style 值
39260
+ * @param $elem $elem
39261
+ * @param styleKey style key
40645
39262
  */
40646
- function isTableWithHeader(tableNode) {
40647
- var firstRowCells = getFirstRowCells(tableNode);
40648
- return firstRowCells.every(function (cell) { return !!cell.isHeader; });
39263
+ function getStyleValue($elem, styleKey) {
39264
+ var res = '';
39265
+ var styleStr = $elem.attr('style') || ''; // 如 'line-height: 2.5; color: red;'
39266
+ var styleArr = styleStr.split(';'); // 如 ['line-height: 2.5', ' color: red', '']
39267
+ var length = styleArr.length;
39268
+ for (var i = 0; i < length; i++) {
39269
+ var styleItemStr = styleArr[i]; // 如 'line-height: 2.5'
39270
+ if (styleItemStr) {
39271
+ var arr = styleItemStr.split(':'); // ['line-height', ' 2.5']
39272
+ if (arr[0].trim() === styleKey) {
39273
+ res = arr[1].trim();
39274
+ }
39275
+ }
39276
+ }
39277
+ return res;
39278
+ }
39279
+
39280
+ /***
39281
+ * 计算 cell border 距离 table 左侧距离
39282
+ */
39283
+ function getCumulativeWidths(columnWidths) {
39284
+ var e_1, _a;
39285
+ var cumulativeWidths = [];
39286
+ var totalWidth = 0;
39287
+ try {
39288
+ for (var columnWidths_1 = __values(columnWidths), columnWidths_1_1 = columnWidths_1.next(); !columnWidths_1_1.done; columnWidths_1_1 = columnWidths_1.next()) {
39289
+ var width = columnWidths_1_1.value;
39290
+ totalWidth += width;
39291
+ cumulativeWidths.push(totalWidth);
39292
+ }
39293
+ }
39294
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
39295
+ finally {
39296
+ try {
39297
+ if (columnWidths_1_1 && !columnWidths_1_1.done && (_a = columnWidths_1.return)) _a.call(columnWidths_1);
39298
+ }
39299
+ finally { if (e_1) throw e_1.error; }
39300
+ }
39301
+ return cumulativeWidths;
39302
+ }
39303
+ /***
39304
+ * 用于计算拖动 cell 时,cell 宽度变化的比例
39305
+ */
39306
+ function getColumnWidthRatios(columnWidths) {
39307
+ var e_2, _a;
39308
+ var columnWidthsRatio = [];
39309
+ var totalWidth = columnWidths.reduce(function (a, b) { return a + b; }, 0);
39310
+ try {
39311
+ for (var columnWidths_2 = __values(columnWidths), columnWidths_2_1 = columnWidths_2.next(); !columnWidths_2_1.done; columnWidths_2_1 = columnWidths_2.next()) {
39312
+ var width = columnWidths_2_1.value;
39313
+ columnWidthsRatio.push(width / totalWidth);
39314
+ }
39315
+ }
39316
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
39317
+ finally {
39318
+ try {
39319
+ if (columnWidths_2_1 && !columnWidths_2_1.done && (_a = columnWidths_2.return)) _a.call(columnWidths_2);
39320
+ }
39321
+ finally { if (e_2) throw e_2.error; }
39322
+ }
39323
+ return columnWidthsRatio;
40649
39324
  }
40650
39325
  /**
40651
- * 单元格是否在第一行
40652
- * @param editor editor
40653
- * @param cellNode cell node
39326
+ * 监听 table 内部变化,如新增行、列,删除行列等操作,引起的高度变化。
39327
+ * ResizeObserver 需要即时释放,以免引起内存泄露
39328
+ */
39329
+ var resizeObserver = null;
39330
+ function observerTableResize(editor, elm) {
39331
+ if (elm instanceof HTMLElement) {
39332
+ var table = elm.querySelector('table');
39333
+ if (table) {
39334
+ resizeObserver = new ResizeObserver(function (_a) {
39335
+ var _b = __read(_a, 1), contentRect = _b[0].contentRect;
39336
+ // 当非拖动引起的宽度变化,需要调整 columnWidths
39337
+ slate.Transforms.setNodes(editor, {
39338
+ scrollWidth: contentRect.width,
39339
+ height: contentRect.height,
39340
+ }, { mode: 'highest' });
39341
+ });
39342
+ resizeObserver.observe(table);
39343
+ }
39344
+ }
39345
+ }
39346
+ function unObserveTableResize() {
39347
+ if (resizeObserver) {
39348
+ resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
39349
+ resizeObserver = null;
39350
+ }
39351
+ }
39352
+ // 是否为光标选区行为
39353
+ var isSelectionOperation = false;
39354
+ // 拖拽列宽相关信息
39355
+ var isMouseDownForResize = false;
39356
+ var clientXWhenMouseDown = 0;
39357
+ var cellWidthWhenMouseDown = 0;
39358
+ var editorWhenMouseDown = null;
39359
+ var $window = $__default["default"](window);
39360
+ $window.on('mousedown', onMouseDown);
39361
+ function onMouseDown(event) {
39362
+ var elem = event.target;
39363
+ // 判断是否为光标选区行为,对列宽变更行为进行过滤
39364
+ // console.log('onMouseDown', elem)
39365
+ if (elem.closest('[data-block-type="table-cell"]')) {
39366
+ isSelectionOperation = true;
39367
+ }
39368
+ else if (elem.tagName == 'DIV' && elem.closest('.column-resizer-item')) {
39369
+ if (editorWhenMouseDown == null)
39370
+ return;
39371
+ var _a = __read(slate.Editor.nodes(editorWhenMouseDown, {
39372
+ match: isOfType(editorWhenMouseDown, 'table'),
39373
+ }), 1), _b = __read(_a[0], 1), elemNode = _b[0];
39374
+ 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;
39375
+ /**
39376
+ * table width 为 100% 模式时,因无法增加Table宽度,不触发 列宽变更行为
39377
+ * 如需变更,到底哪个列增宽度,哪个列减去宽度??
39378
+ */
39379
+ if (tableWidth == '100%')
39380
+ return;
39381
+ // 记录必要信息
39382
+ isMouseDownForResize = true;
39383
+ var clientX = event.clientX;
39384
+ clientXWhenMouseDown = clientX;
39385
+ cellWidthWhenMouseDown = columnWidths[resizingIndex];
39386
+ document.body.style.cursor = 'col-resize';
39387
+ event.preventDefault();
39388
+ }
39389
+ $window.on('mousemove', onMouseMove);
39390
+ $window.on('mouseup', onMouseUp);
39391
+ }
39392
+ var onMouseMove = throttle__default["default"](function (event) {
39393
+ if (!isMouseDownForResize)
39394
+ return;
39395
+ if (editorWhenMouseDown == null)
39396
+ return;
39397
+ event.preventDefault();
39398
+ var clientX = event.clientX;
39399
+ var newWith = cellWidthWhenMouseDown + (clientX - clientXWhenMouseDown); // 计算新宽度
39400
+ newWith = Math.floor(newWith * 100) / 100; // 保留小数点后两位
39401
+ if (newWith < 30)
39402
+ newWith = 30; // 最小宽度
39403
+ var _a = __read(slate.Editor.nodes(editorWhenMouseDown, {
39404
+ match: isOfType(editorWhenMouseDown, 'table'),
39405
+ }), 1), _b = __read(_a[0], 1), elemNode = _b[0];
39406
+ 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;
39407
+ /**
39408
+ * 判断拖动引起的宽度是否最大化了
39409
+ * 如果最大化了,则需要调整列的宽度
39410
+ *
39411
+ * 0.5 很微妙
39412
+ */
39413
+ var cumulativeTotalWidth = columnWidths.reduce(function (a, b) { return a + b; }, 0);
39414
+ var remainWidth = cumulativeTotalWidth - columnWidths[resizingIndex];
39415
+ if (cumulativeTotalWidth > scrollWidth && remainWidth + newWith > scrollWidth) {
39416
+ newWith = scrollWidth - remainWidth + 0.5;
39417
+ }
39418
+ var adjustColumnWidths = __spreadArray([], __read(columnWidths)).map(function (width) { return Math.floor(width); });
39419
+ adjustColumnWidths[resizingIndex] = newWith;
39420
+ // 这是宽度
39421
+ slate.Transforms.setNodes(editorWhenMouseDown, { columnWidths: adjustColumnWidths }, {
39422
+ mode: 'highest',
39423
+ });
39424
+ }, 100);
39425
+ function onMouseUp(event) {
39426
+ isSelectionOperation = false;
39427
+ isMouseDownForResize = false;
39428
+ editorWhenMouseDown = null;
39429
+ document.body.style.cursor = '';
39430
+ // 解绑事件
39431
+ $window.off('mousemove', onMouseMove);
39432
+ $window.off('mouseup', onMouseUp);
39433
+ }
39434
+ /**
39435
+ * 鼠标移动时,判断在哪个 Cell border 上
39436
+ * Class 先 visible 后 highlight @跟随飞书
39437
+ * 避免光标选区功能收到干扰
40654
39438
  */
40655
- function isCellInFirstRow(editor, cellNode) {
40656
- var rowNode = core.DomEditor.getParentNode(editor, cellNode);
40657
- if (rowNode == null)
40658
- return false;
40659
- var tableNode = core.DomEditor.getParentNode(editor, rowNode);
40660
- if (tableNode == null)
40661
- return false;
40662
- var firstRowCells = getFirstRowCells(tableNode);
40663
- return firstRowCells.some(function (c) { return c === cellNode; });
39439
+ function handleCellBorderVisible(editor, elemNode, e) {
39440
+ if (editor.isDisabled())
39441
+ return;
39442
+ if (isSelectionOperation || isMouseDownForResize)
39443
+ return;
39444
+ 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;
39445
+ /**
39446
+ * table width 为 100% 模式时,因无法增加Table宽度,不触发 列宽变更行为
39447
+ * 如需变更,到底哪个列增宽度,哪个列减去宽度??
39448
+ */
39449
+ if (tableWidth == '100%')
39450
+ return;
39451
+ // Cell Border 宽度为 10px
39452
+ var clientX = e.clientX, target = e.target;
39453
+ // 当单元格合并的时候,鼠标在 cell 中间,则不显示 cell border
39454
+ if (target instanceof HTMLElement) {
39455
+ var rect = target.getBoundingClientRect();
39456
+ if (clientX > rect.x + 5 && clientX < rect.x + rect.width - 5) {
39457
+ if (isHoverCellBorder) {
39458
+ slate.Transforms.setNodes(editor, { isHoverCellBorder: false, resizingIndex: -1 }, { mode: 'highest' });
39459
+ }
39460
+ return;
39461
+ }
39462
+ }
39463
+ if (target instanceof HTMLElement) {
39464
+ var parent_1 = target.closest('.table');
39465
+ if (parent_1) {
39466
+ var clientX_1 = e.clientX;
39467
+ var rect = parent_1.getBoundingClientRect();
39468
+ var cumulativeWidths = getCumulativeWidths(columnWidths);
39469
+ // 鼠标移动时,计算当前鼠标位置,判断在哪个 Cell border 上
39470
+ for (var i = 0; i < cumulativeWidths.length; i++) {
39471
+ if (clientX_1 - rect.x >= cumulativeWidths[i] - 5 &&
39472
+ clientX_1 - rect.x < cumulativeWidths[i] + 5) {
39473
+ // 节流,防止多次引起Transforms.setNodes重绘
39474
+ if (resizingIndex == i)
39475
+ return;
39476
+ slate.Transforms.setNodes(editor, { isHoverCellBorder: true, resizingIndex: i }, { mode: 'highest' });
39477
+ return;
39478
+ }
39479
+ }
39480
+ }
39481
+ }
39482
+ // 鼠标移出时,重置
39483
+ if (isHoverCellBorder == true) {
39484
+ slate.Transforms.setNodes(editor, { isHoverCellBorder: false, resizingIndex: -1 }, {
39485
+ mode: 'highest',
39486
+ });
39487
+ }
39488
+ }
39489
+ /**
39490
+ * 设置 class highlight
39491
+ * 将 render-cell.tsx 拖动功能迁移至 div.column-resize
39492
+ */
39493
+ function handleCellBorderHighlight(editor, e) {
39494
+ if (e.type === 'mouseenter') {
39495
+ slate.Transforms.setNodes(editor, { isResizing: true }, { mode: 'highest' });
39496
+ }
39497
+ else {
39498
+ slate.Transforms.setNodes(editor, { isResizing: false }, { mode: 'highest' });
39499
+ }
39500
+ }
39501
+ function handleCellBorderMouseDown(editor, elemNode) {
39502
+ if (isMouseDownForResize)
39503
+ return; // 此时正在修改列宽
39504
+ editorWhenMouseDown = editor;
40664
39505
  }
40665
39506
 
40666
39507
  /**
@@ -40698,11 +39539,13 @@
40698
39539
  // 是否可编辑
40699
39540
  var editable = getContentEditable(editor, elemNode);
40700
39541
  // 宽度
40701
- var _a = elemNode.width, width = _a === void 0 ? 'auto' : _a;
40702
- // 是否选中
39542
+ 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;
39543
+ // 光标是否选中
40703
39544
  var selected = core.DomEditor.isNodeSelected(editor, elemNode);
40704
- // 第一行的 cells ,以计算列宽
40705
- var firstRowCells = getFirstRowCells(elemNode);
39545
+ // 光标是否有选区
39546
+ var _e = __read(TableCursor.selection(editor), 1), isSelecting = _e[0];
39547
+ // 列宽之间比值
39548
+ var columnWidthRatios = getColumnWidthRatios(columnWidths);
40706
39549
  var vnode = (snabbdom.jsx("div", { className: "table-container", "data-selected": selected, on: {
40707
39550
  mousedown: function (e) {
40708
39551
  // @ts-ignore 阻止光标定位到 table 后面
@@ -40710,6 +39553,10 @@
40710
39553
  e.preventDefault();
40711
39554
  if (editor.isDisabled())
40712
39555
  return;
39556
+ // @ts-ignore 如果用户行为是获取焦点输入文本时,需释放选区
39557
+ if (e.target.closest('[data-block-type="table-cell"]')) {
39558
+ TableCursor.unselect(editor);
39559
+ }
40713
39560
  // 是否需要定位到 table 内部
40714
39561
  var tablePath = core.DomEditor.findPath(editor, elemNode);
40715
39562
  var tableStart = slate.Editor.start(editor, tablePath);
@@ -40724,13 +39571,64 @@
40724
39571
  editor.select(tableStart); // 选中 table 内部
40725
39572
  },
40726
39573
  } },
40727
- snabbdom.jsx("table", { width: width, contentEditable: editable },
40728
- snabbdom.jsx("colgroup", { contentEditable: false }, firstRowCells.map(function (cell) {
40729
- var _a = cell.width, width = _a === void 0 ? 'auto' : _a;
39574
+ snabbdom.jsx("table", { width: tableWidth, contentEditable: editable,
39575
+ /**
39576
+ * 1. 当表格处于选区状态,屏蔽 Chrome 自带的样式
39577
+ * 2. table 宽度为 auto 时,宽度为 列宽之和
39578
+ * 3. 鼠标移动到 单元格 边缘,设置 visible className
39579
+ */
39580
+ className: 'table ' + (isSelecting ? 'table-selection-none' : ''), style: {
39581
+ width: tableWidth == '100%' ? '' : columnWidths.reduce(function (a, b) { return a + b; }, 0) + 'px',
39582
+ }, on: {
39583
+ mousemove: debounce__default["default"](function (e) { return handleCellBorderVisible(editor, elemNode, e); }, 25),
39584
+ } },
39585
+ snabbdom.jsx("colgroup", { contentEditable: false },
39586
+ /**
39587
+ * 剔除 firstRowCells,因单元格合并 表头 th,会计算错误。
39588
+ * 使用 columnWidth 数组长度代表列数
39589
+ * 拖动行为及变量设置均参考 飞书
39590
+ */
39591
+ columnWidths.map(function (width) {
40730
39592
  return snabbdom.jsx("col", { width: width });
40731
39593
  })),
40732
- snabbdom.jsx("tbody", null, children))));
40733
- return vnode;
39594
+ snabbdom.jsx("tbody", null, children)),
39595
+ snabbdom.jsx("div", { className: "column-resizer", contenteditable: "false" }, columnWidths.map(function (width, index) {
39596
+ var minWidth = width;
39597
+ /**
39598
+ * table width 为 100% 模式时
39599
+ * columnWidths 表示的是比例
39600
+ * 1. 需要计算出真实的宽度
39601
+ */
39602
+ if (tableWidth == '100%') {
39603
+ minWidth = columnWidthRatios[index] * scrollWidth;
39604
+ }
39605
+ return (snabbdom.jsx("div", { className: "column-resizer-item", style: { minWidth: minWidth + "px" } },
39606
+ snabbdom.jsx("div", { className: 'resizer-line-hotzone ' +
39607
+ (isHoverCellBorder && index == resizingIndex ? 'visible ' : '') +
39608
+ (isResizing && index == resizingIndex ? 'highlight' : ''), style: { height: height + 'px' }, on: {
39609
+ mouseenter: function (e) { return handleCellBorderHighlight(editor, e); },
39610
+ mouseleave: function (e) { return handleCellBorderHighlight(editor, e); },
39611
+ mousedown: function (e) { return handleCellBorderMouseDown(editor); },
39612
+ } },
39613
+ snabbdom.jsx("div", { className: "resizer-line" }))));
39614
+ }))));
39615
+ /**
39616
+ * 移出直接返回 vnode
39617
+ * 添加 ObserverResize 监听行为
39618
+ * 监听 table 内部变化,更新 table resize-bar 高度
39619
+ */
39620
+ var containerVnode = snabbdom.h('div', {
39621
+ hook: {
39622
+ insert: function (_a) {
39623
+ var elm = _a.elm;
39624
+ return observerTableResize(editor, elm);
39625
+ },
39626
+ destroy: function () {
39627
+ unObserveTableResize();
39628
+ },
39629
+ },
39630
+ }, vnode);
39631
+ return containerVnode;
40734
39632
  }
40735
39633
 
40736
39634
  /**
@@ -40743,154 +39641,60 @@
40743
39641
  }
40744
39642
 
40745
39643
  /**
40746
- * @description DOM 操作
39644
+ * @description table menu helpers
40747
39645
  * @author wangfupeng
40748
39646
  */
40749
- if ($.append)
40750
- $__default["default"].fn.append = $.append;
40751
- if ($.on)
40752
- $__default["default"].fn.on = $.on;
40753
- if ($.focus)
40754
- $__default["default"].fn.focus = $.focus;
40755
- if ($.attr)
40756
- $__default["default"].fn.attr = $.attr;
40757
- if ($.val)
40758
- $__default["default"].fn.val = $.val;
40759
- if ($.html)
40760
- $__default["default"].fn.html = $.html;
40761
- if ($.dataset)
40762
- $__default["default"].fn.dataset = $.dataset;
40763
- if ($.addClass)
40764
- $__default["default"].fn.addClass = $.addClass;
40765
- if ($.removeClass)
40766
- $__default["default"].fn.removeClass = $.removeClass;
40767
- if ($.children)
40768
- $__default["default"].fn.children = $.children;
40769
- if ($.each)
40770
- $__default["default"].fn.each = $.each;
40771
- if ($.find)
40772
- $__default["default"].fn.find = $.find;
40773
39647
  /**
40774
- * 获取 tagName lower-case
40775
- * @param $elem $elem
39648
+ * 获取第一行所有 cells
39649
+ * @param tableNode table node
39650
+ */
39651
+ function getFirstRowCells(tableNode) {
39652
+ var rows = tableNode.children || []; // 所有行
39653
+ if (rows.length === 0)
39654
+ return [];
39655
+ var firstRow = rows[0] || {}; // 第一行
39656
+ var cells = firstRow.children || []; // 第一行所有 cell
39657
+ return cells;
39658
+ }
39659
+ /**
39660
+ * 表格是否带有表头?
39661
+ * @param tableNode table node
40776
39662
  */
40777
- function getTagName($elem) {
40778
- if ($elem.length)
40779
- return $elem[0].tagName.toLowerCase();
40780
- return '';
39663
+ function isTableWithHeader(tableNode) {
39664
+ var firstRowCells = getFirstRowCells(tableNode);
39665
+ return firstRowCells.every(function (cell) { return !!cell.isHeader; });
40781
39666
  }
40782
39667
  /**
40783
- * 获取 $elem 某一个 style 值
40784
- * @param $elem $elem
40785
- * @param styleKey style key
39668
+ * 单元格是否在第一行
39669
+ * @param editor editor
39670
+ * @param cellNode cell node
40786
39671
  */
40787
- function getStyleValue($elem, styleKey) {
40788
- var res = '';
40789
- var styleStr = $elem.attr('style') || ''; // 如 'line-height: 2.5; color: red;'
40790
- var styleArr = styleStr.split(';'); // 如 ['line-height: 2.5', ' color: red', '']
40791
- var length = styleArr.length;
40792
- for (var i = 0; i < length; i++) {
40793
- var styleItemStr = styleArr[i]; // 如 'line-height: 2.5'
40794
- if (styleItemStr) {
40795
- var arr = styleItemStr.split(':'); // ['line-height', ' 2.5']
40796
- if (arr[0].trim() === styleKey) {
40797
- res = arr[1].trim();
40798
- }
40799
- }
40800
- }
40801
- return res;
39672
+ function isCellInFirstRow(editor, cellNode) {
39673
+ var rowNode = core.DomEditor.getParentNode(editor, cellNode);
39674
+ if (rowNode == null)
39675
+ return false;
39676
+ var tableNode = core.DomEditor.getParentNode(editor, rowNode);
39677
+ if (tableNode == null)
39678
+ return false;
39679
+ var firstRowCells = getFirstRowCells(tableNode);
39680
+ return firstRowCells.some(function (c) { return c === cellNode; });
40802
39681
  }
40803
39682
 
40804
39683
  /**
40805
39684
  * @description render cell
40806
39685
  * @author wangfupeng
40807
39686
  */
40808
- // 拖拽列宽相关信息
40809
- var isMouseDownForResize = false;
40810
- var clientXWhenMouseDown = 0;
40811
- var cellWidthWhenMouseDown = 0;
40812
- var cellPathWhenMouseDown = null;
40813
- var editorWhenMouseDown = null;
40814
- var $body = $__default["default"]('body');
40815
- function onMouseDown(event) {
40816
- var elem = event.target;
40817
- if (elem.tagName !== 'TH' && elem.tagName !== 'TD')
40818
- return;
40819
- if (elem.style.cursor !== 'col-resize')
40820
- return;
40821
- elem.style.cursor = 'auto';
40822
- event.preventDefault();
40823
- // 记录必要信息
40824
- isMouseDownForResize = true;
40825
- var clientX = event.clientX;
40826
- clientXWhenMouseDown = clientX;
40827
- var width = elem.getBoundingClientRect().width;
40828
- cellWidthWhenMouseDown = width;
40829
- // 绑定事件
40830
- $body.on('mousemove', onMouseMove);
40831
- $body.on('mouseup', onMouseUp);
40832
- }
40833
- $body.on('mousedown', onMouseDown); // 绑定事件
40834
- function onMouseUp(event) {
40835
- isMouseDownForResize = false;
40836
- editorWhenMouseDown = null;
40837
- cellPathWhenMouseDown = null;
40838
- // 解绑事件
40839
- $body.off('mousemove', onMouseMove);
40840
- $body.off('mouseup', onMouseUp);
40841
- }
40842
- var onMouseMove = throttle__default["default"](function (event) {
40843
- if (!isMouseDownForResize)
40844
- return;
40845
- if (editorWhenMouseDown == null || cellPathWhenMouseDown == null)
40846
- return;
40847
- event.preventDefault();
40848
- var clientX = event.clientX;
40849
- var newWith = cellWidthWhenMouseDown + (clientX - clientXWhenMouseDown); // 计算新宽度
40850
- newWith = Math.floor(newWith * 100) / 100; // 保留小数点后两位
40851
- if (newWith < 30)
40852
- newWith = 30; // 最小宽度
40853
- // 这是宽度
40854
- slate.Transforms.setNodes(editorWhenMouseDown, { width: newWith.toString() }, {
40855
- at: cellPathWhenMouseDown,
40856
- });
40857
- }, 100);
40858
39687
  function renderTableCell(cellNode, children, editor) {
40859
39688
  var isFirstRow = isCellInFirstRow(editor, cellNode);
40860
- 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;
39689
+ 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;
39690
+ var selected = TableCursor.isSelected(editor, cellNode);
40861
39691
  // ------------------ 不是第一行,直接渲染 <td> ------------------
40862
39692
  if (!isFirstRow) {
40863
- return (snabbdom.jsx("td", { colSpan: colSpan, rowSpan: rowSpan }, children));
39693
+ return (snabbdom.jsx("td", { colSpan: colSpan, rowSpan: rowSpan, "data-block-type": "table-cell", className: selected ? 'w-e-selected' : '', style: { display: hidden ? 'none' : '' } }, children));
40864
39694
  }
40865
39695
  // ------------------ 是第一行:1. 判断 th ;2. 拖拽列宽 ------------------
40866
39696
  var Tag = isHeader ? 'th' : 'td';
40867
- var vnode = (snabbdom.jsx(Tag, { colSpan: colSpan, rowSpan: rowSpan, style: { borderRightWidth: '3px' }, on: {
40868
- mousemove: throttle__default["default"](function (event) {
40869
- var elem = this.elm;
40870
- if (elem == null)
40871
- return;
40872
- var _a = elem.getBoundingClientRect(), left = _a.left, width = _a.width, top = _a.top, height = _a.height;
40873
- var clientX = event.clientX, clientY = event.clientY;
40874
- if (isMouseDownForResize)
40875
- return; // 此时正在修改列宽
40876
- // 非 mousedown 状态,计算 cursor 样式
40877
- var matchX = clientX > left + width - 5 && clientX < left + width; // X 轴,是否接近 cell 右侧?
40878
- var matchY = clientY > top && clientY < top + height; // Y 轴,是否在 cell 之内
40879
- // X Y 轴都接近,则修改鼠标样式
40880
- if (matchX && matchY) {
40881
- elem.style.cursor = 'col-resize';
40882
- editorWhenMouseDown = editor;
40883
- cellPathWhenMouseDown = core.DomEditor.findPath(editor, cellNode);
40884
- }
40885
- else {
40886
- if (!isMouseDownForResize) {
40887
- elem.style.cursor = 'auto';
40888
- editorWhenMouseDown = null;
40889
- cellPathWhenMouseDown = null;
40890
- }
40891
- }
40892
- }, 100),
40893
- } }, children));
39697
+ var vnode = (snabbdom.jsx(Tag, { colSpan: colSpan, rowSpan: rowSpan, "data-block-type": "table-cell", className: selected ? 'w-e-selected' : '', style: { display: hidden ? 'none' : '' } }, children));
40894
39698
  return vnode;
40895
39699
  }
40896
39700
 
@@ -40917,15 +39721,16 @@
40917
39721
  */
40918
39722
  function tableToHtml(elemNode, childrenHtml) {
40919
39723
  var _a = elemNode.width, width = _a === void 0 ? 'auto' : _a;
40920
- return "<table style=\"width: " + width + ";\"><tbody>" + childrenHtml + "</tbody></table>";
39724
+ return "<table style=\"width: " + width + ";table-layout: fixed;\"><tbody>" + childrenHtml + "</tbody></table>";
40921
39725
  }
40922
39726
  function tableRowToHtml(elem, childrenHtml) {
40923
39727
  return "<tr>" + childrenHtml + "</tr>";
40924
39728
  }
40925
39729
  function tableCellToHtml(cellNode, childrenHtml) {
40926
- 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;
39730
+ 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;
40927
39731
  var tag = isHeader ? 'th' : 'td';
40928
- return "<" + tag + " colSpan=\"" + colSpan + "\" rowSpan=\"" + rowSpan + "\" width=\"" + width + "\">" + childrenHtml + "</" + tag + ">";
39732
+ var style = hidden ? 'display:none' : '';
39733
+ return "<" + tag + " colSpan=\"" + colSpan + "\" rowSpan=\"" + rowSpan + "\" width=\"" + width + "\" style=\"" + style + "\">" + childrenHtml + "</" + tag + ">";
40929
39734
  }
40930
39735
  var tableToHtmlConf = {
40931
39736
  type: 'table',
@@ -41057,7 +39862,11 @@
41057
39862
  // 表头
41058
39863
  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>';
41059
39864
  // 宽度
41060
- 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>';
39865
+ 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>';
39866
+ // 合并单元格
39867
+ 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>';
39868
+ // 拆分单元格
39869
+ 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>';
41061
39870
 
41062
39871
  /**
41063
39872
  * @description insert table menu
@@ -41066,6 +39875,7 @@
41066
39875
  function genTableNode(rowNum, colNum) {
41067
39876
  // 拼接 rows
41068
39877
  var rows = [];
39878
+ var columnWidths = Array(colNum).fill(60);
41069
39879
  for (var i = 0; i < rowNum; i++) {
41070
39880
  // 拼接 cells
41071
39881
  var cells = [];
@@ -41089,6 +39899,7 @@
41089
39899
  type: 'table',
41090
39900
  width: 'auto',
41091
39901
  children: rows,
39902
+ columnWidths: columnWidths,
41092
39903
  };
41093
39904
  }
41094
39905
  var InsertTable = /** @class */ (function () {
@@ -41298,19 +40109,56 @@
41298
40109
  var cellsLength = (rowNode === null || rowNode === void 0 ? void 0 : rowNode.children.length) || 0;
41299
40110
  if (cellsLength === 0)
41300
40111
  return;
41301
- // 拼接新的 row
41302
- var newRow = { type: 'table-row', children: [] };
41303
- for (var i = 0; i < cellsLength; i++) {
41304
- var cell = {
41305
- type: 'table-cell',
41306
- children: [{ text: '' }],
41307
- };
41308
- newRow.children.push(cell);
40112
+ var matrix = filledMatrix(editor);
40113
+ // 向下插入行为,先找到
40114
+ // 当前选区所在的 tr 索引
40115
+ var trIndex = 0;
40116
+ outer: for (var x = 0; x < matrix.length; x++) {
40117
+ for (var y = 0; y < matrix[x].length; y++) {
40118
+ var _c = __read(matrix[x][y], 1), _d = __read(_c[0], 2), path = _d[1];
40119
+ if (!slate.Path.equals(cellPath, path)) {
40120
+ continue;
40121
+ }
40122
+ trIndex = x;
40123
+ break outer;
40124
+ }
41309
40125
  }
41310
- // 插入 row
41311
- var rowPath = slate.Path.parent(cellPath); // 获取 tr 的 path
41312
- var newRowPath = slate.Path.next(rowPath);
41313
- slate.Transforms.insertNodes(editor, newRow, { at: newRowPath });
40126
+ slate.Editor.withoutNormalizing(editor, function () {
40127
+ // 向下添加 tr 索引
40128
+ var destIndex = trIndex + 1;
40129
+ var isWithinBounds = destIndex >= 0 && destIndex < matrix.length;
40130
+ var exitMerge = [];
40131
+ for (var y = 0; isWithinBounds && y < matrix[trIndex].length; y++) {
40132
+ var _a = __read(matrix[trIndex][y], 2), _b = _a[1], ttb = _b.ttb, btt = _b.btt;
40133
+ // 向上找到 1 元素为止
40134
+ if (ttb > 1 || btt > 1) {
40135
+ if (btt == 1)
40136
+ continue;
40137
+ var _c = __read(matrix[trIndex - (ttb - 1)][y], 1), _d = __read(_c[0], 2), element = _d[0], path = _d[1];
40138
+ var rowSpan = element.rowSpan || 1;
40139
+ exitMerge.push(y);
40140
+ if (!element.hidden) {
40141
+ slate.Transforms.setNodes(editor, {
40142
+ rowSpan: rowSpan + 1,
40143
+ }, { at: path });
40144
+ }
40145
+ }
40146
+ }
40147
+ // 拼接新的 row
40148
+ var newRow = { type: 'table-row', children: [] };
40149
+ for (var i = 0; i < cellsLength; i++) {
40150
+ var cell = {
40151
+ type: 'table-cell',
40152
+ hidden: exitMerge.includes(i),
40153
+ children: [{ text: '' }],
40154
+ };
40155
+ newRow.children.push(cell);
40156
+ }
40157
+ // 插入 row
40158
+ var rowPath = slate.Path.parent(cellPath); // 获取 tr 的 path
40159
+ var newRowPath = slate.Path.next(rowPath);
40160
+ slate.Transforms.insertNodes(editor, newRow, { at: newRowPath });
40161
+ });
41314
40162
  };
41315
40163
  return InsertRow;
41316
40164
  }());
@@ -41362,7 +40210,67 @@
41362
40210
  return;
41363
40211
  }
41364
40212
  // row > 1 行,则删掉这一行
41365
- slate.Transforms.removeNodes(editor, { at: rowPath });
40213
+ var _c = __read(slate.Editor.nodes(editor, {
40214
+ match: function (n) { return core.DomEditor.checkNodeType(n, 'table-cell'); },
40215
+ universal: true,
40216
+ }), 1), cellEntry = _c[0];
40217
+ var _d = __read(cellEntry, 2), cellPath = _d[1];
40218
+ var matrix = filledMatrix(editor);
40219
+ var trIndex = 0;
40220
+ outer: for (var x = 0; x < matrix.length; x++) {
40221
+ for (var y = 0; y < matrix[x].length; y++) {
40222
+ var _e = __read(matrix[x][y], 1), _f = __read(_e[0], 2), path = _f[1];
40223
+ if (!slate.Path.equals(cellPath, path)) {
40224
+ continue;
40225
+ }
40226
+ trIndex = x;
40227
+ break outer;
40228
+ }
40229
+ }
40230
+ slate.Editor.withoutNormalizing(editor, function () {
40231
+ var e_1, _a;
40232
+ for (var y = 0; y < matrix[trIndex].length; y++) {
40233
+ var _b = __read(matrix[trIndex][y], 2), _c = __read(_b[0], 1), hidden = _c[0].hidden, _d = _b[1], ttb = _d.ttb, btt = _d.btt;
40234
+ // 寻找跨行行为
40235
+ if (ttb > 1 || btt > 1) {
40236
+ // 找到显示中 rowSpan 节点
40237
+ var _e = __read(matrix[trIndex - (ttb - 1)][y], 1), _f = __read(_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];
40238
+ // 如果当前选中节点为隐藏节点,则向上寻找处理 rowSpan 逻辑
40239
+ if (hidden) {
40240
+ slate.Transforms.setNodes(editor, {
40241
+ rowSpan: Math.max(rowSpan - 1, 1),
40242
+ colSpan: colSpan,
40243
+ }, { at: path });
40244
+ }
40245
+ else {
40246
+ var _k = __read(matrix[trIndex + 1][y], 1), _l = __read(_k[0], 2), belowPath = _l[1];
40247
+ slate.Transforms.setNodes(editor, {
40248
+ rowSpan: rowSpan - 1,
40249
+ colSpan: colSpan,
40250
+ hidden: false,
40251
+ }, { at: belowPath });
40252
+ try {
40253
+ // 移动单元格 文本、图片等元素
40254
+ for (var _m = (e_1 = void 0, __values(slate.Node.children(editor, path, { reverse: true }))), _o = _m.next(); !_o.done; _o = _m.next()) {
40255
+ var _p = __read(_o.value, 2), childPath = _p[1];
40256
+ slate.Transforms.moveNodes(editor, {
40257
+ to: __spreadArray(__spreadArray([], __read(belowPath)), [0]),
40258
+ at: childPath,
40259
+ });
40260
+ }
40261
+ }
40262
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
40263
+ finally {
40264
+ try {
40265
+ if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
40266
+ }
40267
+ finally { if (e_1) throw e_1.error; }
40268
+ }
40269
+ }
40270
+ }
40271
+ }
40272
+ slate.Transforms.removeNodes(editor, { at: rowPath });
40273
+ });
41366
40274
  };
41367
40275
  return DeleteRow;
41368
40276
  }());
@@ -41412,27 +40320,62 @@
41412
40320
  var tableNode = core.DomEditor.getParentNode(editor, rowNode);
41413
40321
  if (tableNode == null)
41414
40322
  return;
41415
- // 遍历所有 rows ,挨个添加 cell
41416
- var rows = tableNode.children || [];
41417
- rows.forEach(function (row, rowIndex) {
41418
- if (!slate.Element.isElement(row))
41419
- return;
41420
- var cells = row.children || [];
41421
- // 遍历一个 row 的所有 cells
41422
- cells.forEach(function (cell) {
41423
- var path = core.DomEditor.findPath(editor, cell);
41424
- if (path.length === selectedCellPath.length &&
41425
- isEqual__default["default"](path.slice(-1), selectedCellPath.slice(-1)) // 俩数组,最后一位相同
41426
- ) {
41427
- // 如果当前 td 的 path 和选中 td 的 path ,最后一位相同,说明是同一列
41428
- // 则在其后插入一个 cell
41429
- var newCell = { type: 'table-cell', children: [{ text: '' }] };
41430
- if (rowIndex === 0 && isTableWithHeader(tableNode)) {
41431
- newCell.isHeader = true;
40323
+ var matrix = filledMatrix(editor);
40324
+ var tdIndex = 0;
40325
+ out: for (var x = 0; x < matrix.length; x++) {
40326
+ for (var y = 0; y < matrix[x].length; y++) {
40327
+ var _c = __read(matrix[x][y], 1), _d = __read(_c[0], 2), path = _d[1];
40328
+ if (slate.Path.equals(selectedCellPath, path)) {
40329
+ tdIndex = y;
40330
+ break out;
40331
+ }
40332
+ }
40333
+ }
40334
+ slate.Editor.withoutNormalizing(editor, function () {
40335
+ var exitMerge = [];
40336
+ for (var x = 0; x < matrix.length; x++) {
40337
+ var _a = __read(matrix[x][tdIndex], 2), _b = _a[1], ltr = _b.ltr, rtl = _b.rtl;
40338
+ // 向左找到 1 元素为止
40339
+ if (ltr > 1 || rtl > 1) {
40340
+ if (rtl == 1)
40341
+ continue;
40342
+ var _c = __read(matrix[x][tdIndex - (rtl - 1)], 1), _d = __read(_c[0], 2), element = _d[0], path = _d[1];
40343
+ var colSpan = element.colSpan || 1;
40344
+ exitMerge.push(x);
40345
+ if (!element.hidden) {
40346
+ slate.Transforms.setNodes(editor, {
40347
+ colSpan: colSpan + 1,
40348
+ }, { at: path });
41432
40349
  }
41433
- slate.Transforms.insertNodes(editor, newCell, { at: path });
41434
40350
  }
41435
- });
40351
+ }
40352
+ // 遍历所有 rows ,挨个添加 cell
40353
+ for (var x = 0; x < matrix.length; x++) {
40354
+ var newCell = {
40355
+ type: 'table-cell',
40356
+ hidden: exitMerge.includes(x),
40357
+ children: [{ text: '' }],
40358
+ };
40359
+ if (x === 0 && isTableWithHeader(tableNode)) {
40360
+ newCell.isHeader = true;
40361
+ }
40362
+ var _e = __read(matrix[x][tdIndex], 1), _f = __read(_e[0], 2), insertPath = _f[1];
40363
+ slate.Transforms.insertNodes(editor, newCell, { at: insertPath });
40364
+ }
40365
+ // 需要调整 columnWidths
40366
+ var _g = __read(slate.Editor.nodes(editor, {
40367
+ match: function (n) { return core.DomEditor.checkNodeType(n, 'table'); },
40368
+ universal: true,
40369
+ }), 1), tableEntry = _g[0];
40370
+ if (tableEntry) {
40371
+ var _h = __read(tableEntry, 2), elemNode = _h[0], tablePath = _h[1];
40372
+ var _j = elemNode.columnWidths, columnWidths = _j === void 0 ? [] : _j;
40373
+ var adjustColumnWidths = __spreadArray([], __read(columnWidths));
40374
+ adjustColumnWidths.splice(tdIndex, 0, 60);
40375
+ slate.Transforms.setNodes(editor, { columnWidths: adjustColumnWidths }, {
40376
+ at: tablePath,
40377
+ });
40378
+ }
41436
40379
  });
41437
40380
  };
41438
40381
  return InsertCol;
@@ -41488,23 +40431,76 @@
41488
40431
  var tableNode = core.DomEditor.getParentNode(editor, rowNode);
41489
40432
  if (tableNode == null)
41490
40433
  return;
41491
- // 遍历所有 rows ,挨个删除 cell
41492
- var rows = tableNode.children || [];
41493
- rows.forEach(function (row) {
41494
- if (!slate.Element.isElement(row))
41495
- return;
41496
- var cells = row.children || [];
41497
- // 遍历一个 row 的所有 cells
41498
- cells.forEach(function (cell) {
41499
- var path = core.DomEditor.findPath(editor, cell);
41500
- if (path.length === selectedCellPath.length &&
41501
- isEqual__default["default"](path.slice(-1), selectedCellPath.slice(-1)) // 俩数组,最后一位相同
41502
- ) {
41503
- // 如果当前 td 的 path 和选中 td 的 path ,最后一位相同,说明是同一列
41504
- // 删除当前的 cell
41505
- slate.Transforms.removeNodes(editor, { at: path });
40434
+ var matrix = filledMatrix(editor);
40435
+ var tdIndex = 0;
40436
+ out: for (var x = 0; x < matrix.length; x++) {
40437
+ for (var y = 0; y < matrix[x].length; y++) {
40438
+ var _c = __read(matrix[x][y], 1), _d = __read(_c[0], 2), path = _d[1];
40439
+ if (slate.Path.equals(selectedCellPath, path)) {
40440
+ tdIndex = y;
40441
+ break out;
41506
40442
  }
41507
- });
40443
+ }
40444
+ }
40445
+ slate.Editor.withoutNormalizing(editor, function () {
40446
+ var e_1, _a;
40447
+ for (var x = 0; x < matrix.length; x++) {
40448
+ var _b = __read(matrix[x][tdIndex], 2), _c = __read(_b[0], 1), hidden = _c[0].hidden, _d = _b[1], rtl = _d.rtl, ltr = _d.ltr;
40449
+ if (rtl > 1 || ltr > 1) {
40450
+ // 找到显示中 colSpan 节点
40451
+ var _e = __read(matrix[x][tdIndex - (rtl - 1)], 1), _f = __read(_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];
40452
+ if (hidden) {
40453
+ slate.Transforms.setNodes(editor, {
40454
+ rowSpan: rowSpan,
40455
+ colSpan: Math.max(colSpan - 1, 1),
40456
+ }, { at: path });
40457
+ }
40458
+ else {
40459
+ var _k = __read(matrix[x][tdIndex + 1], 1), _l = __read(_k[0], 2), rightPath = _l[1];
40460
+ slate.Transforms.setNodes(editor, {
40461
+ rowSpan: rowSpan,
40462
+ colSpan: colSpan - 1,
40463
+ hidden: false,
40464
+ }, { at: rightPath });
40465
+ try {
40466
+ // 移动单元格 文本、图片等元素
40467
+ for (var _m = (e_1 = void 0, __values(slate.Node.children(editor, path, { reverse: true }))), _o = _m.next(); !_o.done; _o = _m.next()) {
40468
+ var _p = __read(_o.value, 2), childPath = _p[1];
40469
+ slate.Transforms.moveNodes(editor, {
40470
+ to: __spreadArray(__spreadArray([], __read(rightPath)), [0]),
40471
+ at: childPath,
40472
+ });
40473
+ }
40474
+ }
40475
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
40476
+ finally {
40477
+ try {
40478
+ if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
40479
+ }
40480
+ finally { if (e_1) throw e_1.error; }
40481
+ }
40482
+ }
40483
+ }
40484
+ }
40485
+ // 挨个删除 cell
40486
+ for (var x = 0; x < matrix.length; x++) {
40487
+ var _q = __read(matrix[x][tdIndex], 1), _r = __read(_q[0], 2), path = _r[1];
40488
+ slate.Transforms.removeNodes(editor, { at: path });
40489
+ }
40490
+ // 需要调整 columnWidths
40491
+ var _s = __read(slate.Editor.nodes(editor, {
40492
+ match: function (n) { return core.DomEditor.checkNodeType(n, 'table'); },
40493
+ universal: true,
40494
+ }), 1), tableEntry = _s[0];
40495
+ if (tableEntry) {
40496
+ var _t = __read(tableEntry, 2), elemNode = _t[0], tablePath = _t[1];
40497
+ var _u = elemNode.columnWidths, columnWidths = _u === void 0 ? [] : _u;
40498
+ var adjustColumnWidths = __spreadArray([], __read(columnWidths));
40499
+ adjustColumnWidths.splice(tdIndex, 1);
40500
+ slate.Transforms.setNodes(editor, { columnWidths: adjustColumnWidths }, {
40501
+ at: tablePath,
40502
+ });
40503
+ }
41508
40504
  });
41509
40505
  };
41510
40506
  return DeleteCol;
@@ -41607,6 +40603,234 @@
41607
40603
  return TableFullWidth;
41608
40604
  }());
41609
40605
 
40606
+ var MergeCell = /** @class */ (function () {
40607
+ function MergeCell() {
40608
+ this.title = core.t('tableModule.mergeCell');
40609
+ this.iconSvg = MERGE_CELL_SVG;
40610
+ this.tag = 'button';
40611
+ }
40612
+ MergeCell.prototype.getValue = function (editor) {
40613
+ // 无需获取 val
40614
+ return '';
40615
+ };
40616
+ MergeCell.prototype.isActive = function (editor) {
40617
+ // 无需 active
40618
+ return false;
40619
+ };
40620
+ MergeCell.prototype.isDisabled = function (editor) {
40621
+ return !this.canMerge(editor);
40622
+ };
40623
+ MergeCell.prototype.exec = function (editor, value) {
40624
+ if (this.isDisabled(editor))
40625
+ return;
40626
+ this.merge(editor);
40627
+ // 释放选区
40628
+ TableCursor.unselect(editor);
40629
+ };
40630
+ /**
40631
+ * Checks if the current selection can be merged. Merging is not possible when any of the following conditions are met:
40632
+ * - The selection is empty.
40633
+ * - The selection is not within the same "thead", "tbody," or "tfoot" section.
40634
+ * @returns {boolean} `true` if the selection can be merged, otherwise `false`.
40635
+ */
40636
+ MergeCell.prototype.canMerge = function (editor) {
40637
+ var matrix = EDITOR_TO_SELECTION.get(editor);
40638
+ // cannot merge when selection is empty
40639
+ if (!matrix || !matrix.length) {
40640
+ return false;
40641
+ }
40642
+ // prettier-ignore
40643
+ var _a = __read(matrix[matrix.length - 1][matrix[matrix.length - 1].length - 1], 1), _b = __read(_a[0], 2), lastPath = _b[1];
40644
+ var _c = __read(matrix[0][0], 1), _d = __read(_c[0], 2), firstPath = _d[1];
40645
+ // cannot merge when selection is not in common section
40646
+ if (!hasCommon(editor, [firstPath, lastPath], 'table')) {
40647
+ return false;
40648
+ }
40649
+ return true;
40650
+ };
40651
+ /**
40652
+ * Merges the selected cells in the table.
40653
+ * @returns void
40654
+ */
40655
+ MergeCell.prototype.merge = function (editor) {
40656
+ if (!this.canMerge(editor)) {
40657
+ return;
40658
+ }
40659
+ var selection = EDITOR_TO_SELECTION.get(editor);
40660
+ if (!selection || !selection.length) {
40661
+ return;
40662
+ }
40663
+ var _a = __read(selection[0][0], 1), _b = __read(_a[0], 2), basePath = _b[1];
40664
+ var _c = __read(slate.Node.children(editor, basePath, { reverse: true }), 1), _d = __read(_c[0], 2), lastPath = _d[1];
40665
+ filledMatrix(editor, { at: basePath });
40666
+ slate.Editor.withoutNormalizing(editor, function () {
40667
+ var e_1, _a;
40668
+ var rowSpan = 0;
40669
+ var colSpan = 0;
40670
+ for (var x = selection.length - 1; x >= 0; x--, rowSpan++) {
40671
+ colSpan = 0;
40672
+ for (var y = selection[x].length - 1; y >= 0; y--, colSpan++) {
40673
+ var _b = __read(selection[x][y], 2), _c = __read(_b[0], 2), path = _c[1], ttb = _b[1].ttb;
40674
+ // skip first cell and "fake" cells which belong to a cell with a `rowspan`
40675
+ if (slate.Path.equals(basePath, path) || ttb > 1) {
40676
+ continue;
40677
+ }
40678
+ try {
40679
+ // prettier-ignore
40680
+ for (var _d = (e_1 = void 0, __values(slate.Node.children(editor, path, { reverse: true }))), _e = _d.next(); !_e.done; _e = _d.next()) {
40681
+ var _f = __read(_e.value, 2), childPath = _f[1];
40682
+ slate.Transforms.moveNodes(editor, {
40683
+ to: slate.Path.next(lastPath),
40684
+ at: childPath,
40685
+ });
40686
+ }
40687
+ }
40688
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
40689
+ finally {
40690
+ try {
40691
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
40692
+ }
40693
+ finally { if (e_1) throw e_1.error; }
40694
+ }
40695
+ var _g = __read(slate.Editor.nodes(editor, {
40696
+ match: isOfType(editor, 'tr'),
40697
+ at: path,
40698
+ }), 1), _h = __read(_g[0], 2), trPath = _h[1];
40699
+ var _j = __read(slate.Node.children(editor, trPath), 2), sibling = _j[1];
40700
+ if (sibling) {
40701
+ /**
40702
+ * 删除节点调整成隐藏节点
40703
+ * 隐藏节点不会影响 table 布局
40704
+ */
40705
+ slate.Transforms.setNodes(editor, { hidden: true }, { at: path });
40706
+ continue;
40707
+ }
40708
+ }
40709
+ }
40710
+ slate.Transforms.setNodes(editor, { rowSpan: rowSpan, colSpan: colSpan }, { at: basePath });
40711
+ });
40712
+ };
40713
+ return MergeCell;
40714
+ }());
40715
+
40716
+ // import { DEFAULT_WITH_TABLE_OPTIONS } from "../../utils/options";
40717
+ var SplitCell = /** @class */ (function () {
40718
+ function SplitCell() {
40719
+ this.title = core.t('tableModule.splitCell');
40720
+ this.iconSvg = SPLIT_CELL_SVG;
40721
+ this.tag = 'button';
40722
+ }
40723
+ SplitCell.prototype.getValue = function (editor) {
40724
+ // 无需获取 val
40725
+ return '';
40726
+ };
40727
+ SplitCell.prototype.isActive = function (editor) {
40728
+ // 无需 active
40729
+ return false;
40730
+ };
40731
+ SplitCell.prototype.isDisabled = function (editor) {
40732
+ var _a = __read(slate.Editor.nodes(editor, {
40733
+ match: isOfType(editor, 'td'),
40734
+ }), 1), td = _a[0];
40735
+ var _b = __read(td, 1), _c = _b[0], _d = _c.rowSpan, rowSpan = _d === void 0 ? 1 : _d, _e = _c.colSpan, colSpan = _e === void 0 ? 1 : _e;
40736
+ if (rowSpan > 1 || colSpan > 1) {
40737
+ return false;
40738
+ }
40739
+ return true;
40740
+ };
40741
+ SplitCell.prototype.exec = function (editor, value) {
40742
+ if (this.isDisabled(editor))
40743
+ return;
40744
+ this.split(editor);
40745
+ };
40746
+ /**
40747
+ * Splits either the cell at the current selection or a specified location. If a range
40748
+ * selection is present, all cells within the range will be split.
40749
+ * @param {Location} [options.at] - Splits the cell at the specified location. If no
40750
+ * location is specified it will split the cell at the current selection
40751
+ * @param {boolean} [options.all] - If true, splits all cells in the table
40752
+ * @returns void
40753
+ */
40754
+ SplitCell.prototype.split = function (editor, options) {
40755
+ if (options === void 0) { options = {}; }
40756
+ var _a = __read(slate.Editor.nodes(editor, {
40757
+ match: isOfType(editor, 'table', 'th', 'td'),
40758
+ // @ts-ignore
40759
+ at: options.at,
40760
+ }), 2), table = _a[0], td = _a[1];
40761
+ if (!table || !td) {
40762
+ return;
40763
+ }
40764
+ var selection = EDITOR_TO_SELECTION.get(editor) || [];
40765
+ // @ts-ignore
40766
+ var matrix = filledMatrix(editor, { at: options.at });
40767
+ // const { blocks } = DEFAULT_WITH_TABLE_OPTIONS;
40768
+ slate.Editor.withoutNormalizing(editor, function () {
40769
+ for (var x = matrix.length - 1; x >= 0; x--) {
40770
+ for (var y = matrix[x].length - 1; y >= 0; y--) {
40771
+ var _a = __read(matrix[x][y], 2), _b = __read(_a[0], 2), path = _b[1], context = _a[1];
40772
+ var colSpan = context.ltr, rtl = context.rtl, rowSpan = context.btt, ttb = context.ttb;
40773
+ if (rtl > 1) {
40774
+ // get to the start of the colspan
40775
+ y -= rtl - 2;
40776
+ continue;
40777
+ }
40778
+ if (ttb > 1) {
40779
+ continue;
40780
+ }
40781
+ if (rowSpan === 1 && colSpan === 1) {
40782
+ continue;
40783
+ }
40784
+ var found = !!options.all;
40785
+ if (selection.length) {
40786
+ outer: for (var i = 0; !options.all && i < selection.length; i++) {
40787
+ for (var j = 0; j < selection[i].length; j++) {
40788
+ var _c = __read(selection[i][j], 1), _d = __read(_c[0], 2), tdPath = _d[1];
40789
+ if (slate.Path.equals(tdPath, path)) {
40790
+ found = true;
40791
+ break outer;
40792
+ }
40793
+ }
40794
+ }
40795
+ }
40796
+ else {
40797
+ var _e = __read(td, 2), tdPath = _e[1];
40798
+ if (slate.Path.equals(tdPath, path)) {
40799
+ found = true;
40800
+ }
40801
+ }
40802
+ if (!found) {
40803
+ continue;
40804
+ }
40805
+ var _f = __read(slate.Editor.nodes(editor, {
40806
+ match: isOfType(editor, 'table'),
40807
+ at: path,
40808
+ }), 1), _g = __read(_f[0], 1); _g[0];
40809
+ out: for (var r = 1; r < rowSpan; r++) {
40810
+ for (var i = y; i >= 0; i--) {
40811
+ var _h = __read(matrix[x + r][i], 2), _j = __read(_h[0], 2); _j[1]; var ttb_1 = _h[1].ttb;
40812
+ if (ttb_1 == 1) {
40813
+ continue;
40814
+ }
40815
+ for (var c = 0; c < colSpan; c++) {
40816
+ var _k = __read(matrix[x + r][i + c], 1), _l = __read(_k[0], 2), nextPath = _l[1];
40817
+ slate.Transforms.unsetNodes(editor, ['hidden', 'colSpan', 'rowSpan'], { at: nextPath });
40818
+ }
40819
+ continue out;
40820
+ }
40821
+ }
40822
+ for (var c = 1; c < colSpan; c++) {
40823
+ var _m = __read(matrix[x][y + c], 1), _o = __read(_m[0], 2), nextPath = _o[1];
40824
+ slate.Transforms.unsetNodes(editor, ['hidden', 'colSpan', 'rowSpan'], { at: nextPath });
40825
+ }
40826
+ slate.Transforms.setNodes(editor, { rowSpan: 1, colSpan: 1 }, { at: path });
40827
+ }
40828
+ }
40829
+ });
40830
+ };
40831
+ return SplitCell;
40832
+ }());
40833
+
41610
40834
  /**
41611
40835
  * @description table menu
41612
40836
  * @author wangfupeng
@@ -41658,6 +40882,19 @@
41658
40882
  factory: function () {
41659
40883
  return new TableFullWidth();
41660
40884
  },
40885
+ };
40886
+ /** Meger / Split conf */
40887
+ var mergeTableCellConf = {
40888
+ key: 'mergeTableCell',
40889
+ factory: function () {
40890
+ return new MergeCell();
40891
+ },
40892
+ };
40893
+ var splitTableCellConf = {
40894
+ key: 'splitTableCell',
40895
+ factory: function () {
40896
+ return new SplitCell();
40897
+ },
41661
40898
  };
41662
40899
 
41663
40900
  /**
@@ -41678,6 +40915,8 @@
41678
40915
  deleteTableColConf,
41679
40916
  tableHeaderMenuConf,
41680
40917
  tableFullWidthMenuConf,
40918
+ mergeTableCellConf,
40919
+ splitTableCellConf,
41681
40920
  ],
41682
40921
  editorPlugin: withTable,
41683
40922
  };
@@ -48604,6 +47843,9 @@
48604
47843
  'insertTableCol',
48605
47844
  'deleteTableCol',
48606
47845
  'deleteTable',
47846
+ /** 注册单元格合并 拆分 */
47847
+ 'mergeTableCell',
47848
+ 'splitTableCell',
48607
47849
  ],
48608
47850
  },
48609
47851
  divider: {