@wangeditor-next/editor 5.3.12-alpha.2 → 5.3.12-experimental.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -3
- package/LICENSE +21 -21
- package/dist/css/style.css +66 -0
- package/dist/index.esm.js +1452 -2228
- package/dist/index.js +1399 -2175
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -22708,9 +22708,14 @@
|
|
|
22708
22708
|
}
|
|
22709
22709
|
return (
|
|
22710
22710
|
// 祖先节点中包括 data-slate-editor 属性,即 textarea
|
|
22711
|
-
targetEl.closest("[data-slate-editor]") === editorEl &&
|
|
22711
|
+
(targetEl.closest("[data-slate-editor]") === editorEl &&
|
|
22712
22712
|
// 通过参数 editable 控制开启是否验证是可编辑元素或零宽字符
|
|
22713
|
-
|
|
22713
|
+
// 补全 data-slate-string 可参考本文代码
|
|
22714
|
+
//(data-slate-zero-width、data-slate-string)判断一起出现,唯独此处欠缺,补全
|
|
22715
|
+
(!editable ||
|
|
22716
|
+
targetEl.isContentEditable ||
|
|
22717
|
+
!!targetEl.getAttribute('data-slate-zero-width'))) ||
|
|
22718
|
+
!!targetEl.getAttribute('data-slate-string'));
|
|
22714
22719
|
},
|
|
22715
22720
|
/**
|
|
22716
22721
|
* Find a native DOM range from a Slate `range`.
|
|
@@ -26308,9 +26313,6 @@
|
|
|
26308
26313
|
});
|
|
26309
26314
|
slate.Transforms.select(editor, range);
|
|
26310
26315
|
}
|
|
26311
|
-
else {
|
|
26312
|
-
slate.Transforms.deselect(editor);
|
|
26313
|
-
}
|
|
26314
26316
|
}
|
|
26315
26317
|
|
|
26316
26318
|
/**
|
|
@@ -38565,1957 +38567,516 @@
|
|
|
38565
38567
|
}));
|
|
38566
38568
|
});
|
|
38567
38569
|
|
|
38568
|
-
|
|
38569
|
-
|
|
38570
|
-
|
|
38571
|
-
|
|
38572
|
-
|
|
38573
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
38574
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
38575
|
-
*/
|
|
38576
|
-
|
|
38577
|
-
var lodash_isequal = createCommonjsModule$1(function (module, exports) {
|
|
38578
|
-
/** Used as the size to enable large array optimizations. */
|
|
38579
|
-
var LARGE_ARRAY_SIZE = 200;
|
|
38580
|
-
|
|
38581
|
-
/** Used to stand-in for `undefined` hash values. */
|
|
38582
|
-
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
38583
|
-
|
|
38584
|
-
/** Used to compose bitmasks for value comparisons. */
|
|
38585
|
-
var COMPARE_PARTIAL_FLAG = 1,
|
|
38586
|
-
COMPARE_UNORDERED_FLAG = 2;
|
|
38587
|
-
|
|
38588
|
-
/** Used as references for various `Number` constants. */
|
|
38589
|
-
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
38590
|
-
|
|
38591
|
-
/** `Object#toString` result references. */
|
|
38592
|
-
var argsTag = '[object Arguments]',
|
|
38593
|
-
arrayTag = '[object Array]',
|
|
38594
|
-
asyncTag = '[object AsyncFunction]',
|
|
38595
|
-
boolTag = '[object Boolean]',
|
|
38596
|
-
dateTag = '[object Date]',
|
|
38597
|
-
errorTag = '[object Error]',
|
|
38598
|
-
funcTag = '[object Function]',
|
|
38599
|
-
genTag = '[object GeneratorFunction]',
|
|
38600
|
-
mapTag = '[object Map]',
|
|
38601
|
-
numberTag = '[object Number]',
|
|
38602
|
-
nullTag = '[object Null]',
|
|
38603
|
-
objectTag = '[object Object]',
|
|
38604
|
-
promiseTag = '[object Promise]',
|
|
38605
|
-
proxyTag = '[object Proxy]',
|
|
38606
|
-
regexpTag = '[object RegExp]',
|
|
38607
|
-
setTag = '[object Set]',
|
|
38608
|
-
stringTag = '[object String]',
|
|
38609
|
-
symbolTag = '[object Symbol]',
|
|
38610
|
-
undefinedTag = '[object Undefined]',
|
|
38611
|
-
weakMapTag = '[object WeakMap]';
|
|
38570
|
+
var dist$3 = createCommonjsModule$1(function (module, exports) {
|
|
38571
|
+
(function (global, factory) {
|
|
38572
|
+
module.exports = factory(dist$6, require$$2$1, lodash_debounce, require$$2, lodash_throttle, require$$1, require$$4) ;
|
|
38573
|
+
})(commonjsGlobal, (function (core, slate, debounce, snabbdom, throttle, $) {
|
|
38574
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
38612
38575
|
|
|
38613
|
-
|
|
38614
|
-
|
|
38615
|
-
|
|
38616
|
-
float64Tag = '[object Float64Array]',
|
|
38617
|
-
int8Tag = '[object Int8Array]',
|
|
38618
|
-
int16Tag = '[object Int16Array]',
|
|
38619
|
-
int32Tag = '[object Int32Array]',
|
|
38620
|
-
uint8Tag = '[object Uint8Array]',
|
|
38621
|
-
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|
38622
|
-
uint16Tag = '[object Uint16Array]',
|
|
38623
|
-
uint32Tag = '[object Uint32Array]';
|
|
38576
|
+
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
38577
|
+
var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle);
|
|
38578
|
+
var $__default = /*#__PURE__*/_interopDefaultLegacy($);
|
|
38624
38579
|
|
|
38625
|
-
|
|
38626
|
-
|
|
38627
|
-
|
|
38628
|
-
|
|
38629
|
-
|
|
38580
|
+
/**
|
|
38581
|
+
* @description i18n en
|
|
38582
|
+
* @author wangfupeng
|
|
38583
|
+
*/
|
|
38584
|
+
var enResources = {
|
|
38585
|
+
tableModule: {
|
|
38586
|
+
deleteCol: 'Delete column',
|
|
38587
|
+
deleteRow: 'Delete row',
|
|
38588
|
+
deleteTable: 'Delete table',
|
|
38589
|
+
widthAuto: 'Width auto',
|
|
38590
|
+
insertCol: 'Insert column',
|
|
38591
|
+
insertRow: 'Insert row',
|
|
38592
|
+
insertTable: 'Insert table',
|
|
38593
|
+
header: 'Header',
|
|
38594
|
+
mergeCell: 'merge cell',
|
|
38595
|
+
splitCell: 'split cell',
|
|
38596
|
+
},
|
|
38597
|
+
};
|
|
38630
38598
|
|
|
38631
|
-
|
|
38632
|
-
|
|
38599
|
+
/**
|
|
38600
|
+
* @description i18n zh-CN
|
|
38601
|
+
* @author wangfupeng
|
|
38602
|
+
*/
|
|
38603
|
+
var zhResources = {
|
|
38604
|
+
tableModule: {
|
|
38605
|
+
deleteCol: '删除列',
|
|
38606
|
+
deleteRow: '删除行',
|
|
38607
|
+
deleteTable: '删除表格',
|
|
38608
|
+
widthAuto: '宽度自适应',
|
|
38609
|
+
insertCol: '插入列',
|
|
38610
|
+
insertRow: '插入行',
|
|
38611
|
+
insertTable: '插入表格',
|
|
38612
|
+
header: '表头',
|
|
38613
|
+
mergeCell: '合并单元格',
|
|
38614
|
+
splitCell: '拆分单元格',
|
|
38615
|
+
},
|
|
38616
|
+
};
|
|
38633
38617
|
|
|
38634
|
-
|
|
38635
|
-
|
|
38618
|
+
/**
|
|
38619
|
+
* @description i18n entry
|
|
38620
|
+
* @author wangfupeng
|
|
38621
|
+
*/
|
|
38622
|
+
core.i18nAddResources('en', enResources);
|
|
38623
|
+
core.i18nAddResources('zh-CN', zhResources);
|
|
38636
38624
|
|
|
38637
|
-
|
|
38638
|
-
|
|
38639
|
-
|
|
38640
|
-
|
|
38641
|
-
|
|
38642
|
-
|
|
38643
|
-
|
|
38644
|
-
|
|
38645
|
-
|
|
38646
|
-
|
|
38647
|
-
|
|
38648
|
-
|
|
38649
|
-
|
|
38650
|
-
|
|
38651
|
-
|
|
38625
|
+
/******************************************************************************
|
|
38626
|
+
Copyright (c) Microsoft Corporation.
|
|
38627
|
+
|
|
38628
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
38629
|
+
purpose with or without fee is hereby granted.
|
|
38630
|
+
|
|
38631
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
38632
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
38633
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
38634
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
38635
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
38636
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
38637
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
38638
|
+
***************************************************************************** */
|
|
38639
|
+
|
|
38640
|
+
var __assign = function() {
|
|
38641
|
+
__assign = Object.assign || function __assign(t) {
|
|
38642
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
38643
|
+
s = arguments[i];
|
|
38644
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
38645
|
+
}
|
|
38646
|
+
return t;
|
|
38647
|
+
};
|
|
38648
|
+
return __assign.apply(this, arguments);
|
|
38649
|
+
};
|
|
38650
|
+
|
|
38651
|
+
function __generator(thisArg, body) {
|
|
38652
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
38653
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
38654
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38655
|
+
function step(op) {
|
|
38656
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
38657
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
38658
|
+
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;
|
|
38659
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
38660
|
+
switch (op[0]) {
|
|
38661
|
+
case 0: case 1: t = op; break;
|
|
38662
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38663
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38664
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38665
|
+
default:
|
|
38666
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38667
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38668
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
38669
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
38670
|
+
if (t[2]) _.ops.pop();
|
|
38671
|
+
_.trys.pop(); continue;
|
|
38672
|
+
}
|
|
38673
|
+
op = body.call(thisArg, _);
|
|
38674
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
38675
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
38676
|
+
}
|
|
38677
|
+
}
|
|
38678
|
+
|
|
38679
|
+
function __values(o) {
|
|
38680
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
38681
|
+
if (m) return m.call(o);
|
|
38682
|
+
if (o && typeof o.length === "number") return {
|
|
38683
|
+
next: function () {
|
|
38684
|
+
if (o && i >= o.length) o = void 0;
|
|
38685
|
+
return { value: o && o[i++], done: !o };
|
|
38686
|
+
}
|
|
38687
|
+
};
|
|
38688
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
38689
|
+
}
|
|
38690
|
+
|
|
38691
|
+
function __read(o, n) {
|
|
38692
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
38693
|
+
if (!m) return o;
|
|
38694
|
+
var i = m.call(o), r, ar = [], e;
|
|
38695
|
+
try {
|
|
38696
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
38697
|
+
}
|
|
38698
|
+
catch (error) { e = { error: error }; }
|
|
38699
|
+
finally {
|
|
38700
|
+
try {
|
|
38701
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
38702
|
+
}
|
|
38703
|
+
finally { if (e) throw e.error; }
|
|
38704
|
+
}
|
|
38705
|
+
return ar;
|
|
38706
|
+
}
|
|
38707
|
+
|
|
38708
|
+
function __spreadArray(to, from, pack) {
|
|
38709
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38710
|
+
if (ar || !(i in from)) {
|
|
38711
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
38712
|
+
ar[i] = from[i];
|
|
38713
|
+
}
|
|
38714
|
+
}
|
|
38715
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
38716
|
+
}
|
|
38717
|
+
|
|
38718
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
38719
|
+
var e = new Error(message);
|
|
38720
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
38721
|
+
};
|
|
38652
38722
|
|
|
38653
|
-
|
|
38654
|
-
|
|
38723
|
+
/** Weak reference between the `Editor` and the selected elements */
|
|
38724
|
+
var EDITOR_TO_SELECTION = new WeakMap();
|
|
38725
|
+
/** Weak reference between the `Editor` and a set of the selected elements */
|
|
38726
|
+
var EDITOR_TO_SELECTION_SET = new WeakMap();
|
|
38727
|
+
|
|
38728
|
+
var DEFAULT_WITH_TABLE_OPTIONS = {
|
|
38729
|
+
blocks: {
|
|
38730
|
+
td: 'table-cell',
|
|
38731
|
+
th: 'table-cell',
|
|
38732
|
+
content: 'paragraph',
|
|
38733
|
+
tr: 'table-row',
|
|
38734
|
+
table: 'table',
|
|
38735
|
+
tbody: 'table-body',
|
|
38736
|
+
// tfoot: "table-footer",
|
|
38737
|
+
// thead: "table-head",
|
|
38738
|
+
},
|
|
38739
|
+
};
|
|
38655
38740
|
|
|
38656
|
-
|
|
38657
|
-
|
|
38741
|
+
function isElement(node) {
|
|
38742
|
+
return !slate.Editor.isEditor(node) && slate.Element.isElement(node) && 'type' in node;
|
|
38743
|
+
}
|
|
38744
|
+
/** @returns a `NodeMatch` function which is used to match the elements of a specific `type`. */
|
|
38745
|
+
function isOfType(editor) {
|
|
38746
|
+
var types = [];
|
|
38747
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
38748
|
+
types[_i - 1] = arguments[_i];
|
|
38749
|
+
}
|
|
38750
|
+
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]; });
|
|
38751
|
+
return function (node) { return isElement(node) && elementTypes.includes(node.type); };
|
|
38752
|
+
}
|
|
38658
38753
|
|
|
38659
|
-
|
|
38660
|
-
|
|
38754
|
+
/**
|
|
38755
|
+
* Determines whether two paths belong to the same types by checking
|
|
38756
|
+
* if they share a common ancestor node of type table
|
|
38757
|
+
*/
|
|
38758
|
+
function hasCommon(editor, _a) {
|
|
38759
|
+
var _b = __read(_a, 2), path = _b[0], another = _b[1];
|
|
38760
|
+
var types = [];
|
|
38761
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
38762
|
+
types[_i - 2] = arguments[_i];
|
|
38763
|
+
}
|
|
38764
|
+
var _c = __read(slate.Node.common(editor, path, another), 2), node = _c[0], commonPath = _c[1];
|
|
38765
|
+
if (isOfType.apply(void 0, __spreadArray([editor], __read(types)))(node, commonPath)) {
|
|
38766
|
+
return true;
|
|
38767
|
+
}
|
|
38768
|
+
// Warning: returns the common ancestor but will return `undefined` if the
|
|
38769
|
+
// `commonPath` is equal to the specified types path
|
|
38770
|
+
return !!slate.Editor.above(editor, {
|
|
38771
|
+
match: isOfType.apply(void 0, __spreadArray([editor], __read(types))),
|
|
38772
|
+
at: commonPath,
|
|
38773
|
+
});
|
|
38774
|
+
}
|
|
38661
38775
|
|
|
38662
|
-
|
|
38663
|
-
|
|
38776
|
+
/** Generates a matrix for each table section (`thead`, `tbody`, `tfoot`) */
|
|
38777
|
+
function matrices(editor, options) {
|
|
38778
|
+
var _a, table, _b, tablePath, _c, _d, _e, path, matrix, _f, _g, _h, trPath, e_1_1;
|
|
38779
|
+
var e_1, _j, e_2, _k;
|
|
38780
|
+
if (options === void 0) { options = {}; }
|
|
38781
|
+
return __generator(this, function (_l) {
|
|
38782
|
+
switch (_l.label) {
|
|
38783
|
+
case 0:
|
|
38784
|
+
_a = __read(slate.Editor.nodes(editor, {
|
|
38785
|
+
match: isOfType(editor, 'table'),
|
|
38786
|
+
at: options.at,
|
|
38787
|
+
}), 1), table = _a[0];
|
|
38788
|
+
if (!table) {
|
|
38789
|
+
return [2 /*return*/, []];
|
|
38790
|
+
}
|
|
38791
|
+
_b = __read(table, 2), tablePath = _b[1];
|
|
38792
|
+
_l.label = 1;
|
|
38793
|
+
case 1:
|
|
38794
|
+
_l.trys.push([1, 6, 7, 8]);
|
|
38795
|
+
_c = __values(slate.Editor.nodes(editor, {
|
|
38796
|
+
// match: isOfType(editor, "thead", "tbody", "tfoot"),
|
|
38797
|
+
match: isOfType(editor, 'table'),
|
|
38798
|
+
at: tablePath,
|
|
38799
|
+
})), _d = _c.next();
|
|
38800
|
+
_l.label = 2;
|
|
38801
|
+
case 2:
|
|
38802
|
+
if (!!_d.done) return [3 /*break*/, 5];
|
|
38803
|
+
_e = __read(_d.value, 2), path = _e[1];
|
|
38804
|
+
matrix = [];
|
|
38805
|
+
try {
|
|
38806
|
+
for (_f = (e_2 = void 0, __values(slate.Editor.nodes(editor, {
|
|
38807
|
+
match: isOfType(editor, 'tr'),
|
|
38808
|
+
at: path,
|
|
38809
|
+
}))), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
38810
|
+
_h = __read(_g.value, 2), trPath = _h[1];
|
|
38811
|
+
matrix.push(__spreadArray([], __read(slate.Editor.nodes(editor, {
|
|
38812
|
+
match: isOfType(editor, 'th', 'td'),
|
|
38813
|
+
at: trPath,
|
|
38814
|
+
}))));
|
|
38815
|
+
}
|
|
38816
|
+
}
|
|
38817
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
38818
|
+
finally {
|
|
38819
|
+
try {
|
|
38820
|
+
if (_g && !_g.done && (_k = _f.return)) _k.call(_f);
|
|
38821
|
+
}
|
|
38822
|
+
finally { if (e_2) throw e_2.error; }
|
|
38823
|
+
}
|
|
38824
|
+
return [4 /*yield*/, matrix];
|
|
38825
|
+
case 3:
|
|
38826
|
+
_l.sent();
|
|
38827
|
+
_l.label = 4;
|
|
38828
|
+
case 4:
|
|
38829
|
+
_d = _c.next();
|
|
38830
|
+
return [3 /*break*/, 2];
|
|
38831
|
+
case 5: return [3 /*break*/, 8];
|
|
38832
|
+
case 6:
|
|
38833
|
+
e_1_1 = _l.sent();
|
|
38834
|
+
e_1 = { error: e_1_1 };
|
|
38835
|
+
return [3 /*break*/, 8];
|
|
38836
|
+
case 7:
|
|
38837
|
+
try {
|
|
38838
|
+
if (_d && !_d.done && (_j = _c.return)) _j.call(_c);
|
|
38839
|
+
}
|
|
38840
|
+
finally { if (e_1) throw e_1.error; }
|
|
38841
|
+
return [7 /*endfinally*/];
|
|
38842
|
+
case 8: return [2 /*return*/];
|
|
38843
|
+
}
|
|
38844
|
+
});
|
|
38845
|
+
}
|
|
38846
|
+
function filledMatrix(editor, options) {
|
|
38847
|
+
var e_3, _a;
|
|
38848
|
+
if (options === void 0) { options = {}; }
|
|
38849
|
+
var filled = [];
|
|
38850
|
+
try {
|
|
38851
|
+
// Expand each section separately to avoid sections collapsing into each other.
|
|
38852
|
+
for (var _b = __values(matrices(editor, { at: options.at })), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
38853
|
+
var matrix = _c.value;
|
|
38854
|
+
var filledSection = [];
|
|
38855
|
+
for (var x = 0; x < matrix.length; x++) {
|
|
38856
|
+
if (!filledSection[x]) {
|
|
38857
|
+
filledSection[x] = [];
|
|
38858
|
+
}
|
|
38859
|
+
for (var y = 0; y < matrix[x].length; y++) {
|
|
38860
|
+
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;
|
|
38861
|
+
for (var c = 0, occupied = 0; c < colSpan + occupied; c++) {
|
|
38862
|
+
for (var r = 0; r < rowSpan; r++) {
|
|
38863
|
+
if (!filledSection[x + r]) {
|
|
38864
|
+
filledSection[x + r] = [];
|
|
38865
|
+
}
|
|
38866
|
+
if (filledSection[x + r][y + c]) {
|
|
38867
|
+
continue;
|
|
38868
|
+
}
|
|
38869
|
+
filledSection[x + r][y + c] = [
|
|
38870
|
+
matrix[x + r][y + c],
|
|
38871
|
+
{
|
|
38872
|
+
rtl: c - occupied + 1,
|
|
38873
|
+
ltr: colSpan - c + occupied,
|
|
38874
|
+
ttb: r + 1,
|
|
38875
|
+
btt: rowSpan - r,
|
|
38876
|
+
},
|
|
38877
|
+
];
|
|
38878
|
+
}
|
|
38879
|
+
}
|
|
38880
|
+
}
|
|
38881
|
+
}
|
|
38882
|
+
filled.push.apply(filled, __spreadArray([], __read(filledSection)));
|
|
38883
|
+
}
|
|
38884
|
+
}
|
|
38885
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
38886
|
+
finally {
|
|
38887
|
+
try {
|
|
38888
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
38889
|
+
}
|
|
38890
|
+
finally { if (e_3) throw e_3.error; }
|
|
38891
|
+
}
|
|
38892
|
+
return filled;
|
|
38893
|
+
}
|
|
38664
38894
|
|
|
38665
|
-
|
|
38666
|
-
|
|
38895
|
+
var Point = /** @class */ (function () {
|
|
38896
|
+
function Point(x, y) {
|
|
38897
|
+
this.x = x;
|
|
38898
|
+
this.y = y;
|
|
38899
|
+
}
|
|
38900
|
+
Point.valueOf = function (x, y) {
|
|
38901
|
+
return new this(x, y);
|
|
38902
|
+
};
|
|
38903
|
+
Point.equals = function (point, another) {
|
|
38904
|
+
return point.x === another.x && point.y === another.y;
|
|
38905
|
+
};
|
|
38906
|
+
return Point;
|
|
38907
|
+
}());
|
|
38667
38908
|
|
|
38668
|
-
|
|
38669
|
-
|
|
38670
|
-
|
|
38671
|
-
|
|
38672
|
-
|
|
38673
|
-
|
|
38674
|
-
|
|
38675
|
-
|
|
38676
|
-
|
|
38677
|
-
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
38678
|
-
} catch (e) {}
|
|
38679
|
-
}());
|
|
38680
|
-
|
|
38681
|
-
/* Node.js helper references. */
|
|
38682
|
-
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
38683
|
-
|
|
38684
|
-
/**
|
|
38685
|
-
* A specialized version of `_.filter` for arrays without support for
|
|
38686
|
-
* iteratee shorthands.
|
|
38687
|
-
*
|
|
38688
|
-
* @private
|
|
38689
|
-
* @param {Array} [array] The array to iterate over.
|
|
38690
|
-
* @param {Function} predicate The function invoked per iteration.
|
|
38691
|
-
* @returns {Array} Returns the new filtered array.
|
|
38692
|
-
*/
|
|
38693
|
-
function arrayFilter(array, predicate) {
|
|
38694
|
-
var index = -1,
|
|
38695
|
-
length = array == null ? 0 : array.length,
|
|
38696
|
-
resIndex = 0,
|
|
38697
|
-
result = [];
|
|
38698
|
-
|
|
38699
|
-
while (++index < length) {
|
|
38700
|
-
var value = array[index];
|
|
38701
|
-
if (predicate(value, index, array)) {
|
|
38702
|
-
result[resIndex++] = value;
|
|
38703
|
-
}
|
|
38704
|
-
}
|
|
38705
|
-
return result;
|
|
38706
|
-
}
|
|
38707
|
-
|
|
38708
|
-
/**
|
|
38709
|
-
* Appends the elements of `values` to `array`.
|
|
38710
|
-
*
|
|
38711
|
-
* @private
|
|
38712
|
-
* @param {Array} array The array to modify.
|
|
38713
|
-
* @param {Array} values The values to append.
|
|
38714
|
-
* @returns {Array} Returns `array`.
|
|
38715
|
-
*/
|
|
38716
|
-
function arrayPush(array, values) {
|
|
38717
|
-
var index = -1,
|
|
38718
|
-
length = values.length,
|
|
38719
|
-
offset = array.length;
|
|
38720
|
-
|
|
38721
|
-
while (++index < length) {
|
|
38722
|
-
array[offset + index] = values[index];
|
|
38723
|
-
}
|
|
38724
|
-
return array;
|
|
38725
|
-
}
|
|
38726
|
-
|
|
38727
|
-
/**
|
|
38728
|
-
* A specialized version of `_.some` for arrays without support for iteratee
|
|
38729
|
-
* shorthands.
|
|
38730
|
-
*
|
|
38731
|
-
* @private
|
|
38732
|
-
* @param {Array} [array] The array to iterate over.
|
|
38733
|
-
* @param {Function} predicate The function invoked per iteration.
|
|
38734
|
-
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|
38735
|
-
* else `false`.
|
|
38736
|
-
*/
|
|
38737
|
-
function arraySome(array, predicate) {
|
|
38738
|
-
var index = -1,
|
|
38739
|
-
length = array == null ? 0 : array.length;
|
|
38740
|
-
|
|
38741
|
-
while (++index < length) {
|
|
38742
|
-
if (predicate(array[index], index, array)) {
|
|
38743
|
-
return true;
|
|
38744
|
-
}
|
|
38745
|
-
}
|
|
38746
|
-
return false;
|
|
38747
|
-
}
|
|
38748
|
-
|
|
38749
|
-
/**
|
|
38750
|
-
* The base implementation of `_.times` without support for iteratee shorthands
|
|
38751
|
-
* or max array length checks.
|
|
38752
|
-
*
|
|
38753
|
-
* @private
|
|
38754
|
-
* @param {number} n The number of times to invoke `iteratee`.
|
|
38755
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
38756
|
-
* @returns {Array} Returns the array of results.
|
|
38757
|
-
*/
|
|
38758
|
-
function baseTimes(n, iteratee) {
|
|
38759
|
-
var index = -1,
|
|
38760
|
-
result = Array(n);
|
|
38761
|
-
|
|
38762
|
-
while (++index < n) {
|
|
38763
|
-
result[index] = iteratee(index);
|
|
38764
|
-
}
|
|
38765
|
-
return result;
|
|
38766
|
-
}
|
|
38767
|
-
|
|
38768
|
-
/**
|
|
38769
|
-
* The base implementation of `_.unary` without support for storing metadata.
|
|
38770
|
-
*
|
|
38771
|
-
* @private
|
|
38772
|
-
* @param {Function} func The function to cap arguments for.
|
|
38773
|
-
* @returns {Function} Returns the new capped function.
|
|
38774
|
-
*/
|
|
38775
|
-
function baseUnary(func) {
|
|
38776
|
-
return function(value) {
|
|
38777
|
-
return func(value);
|
|
38778
|
-
};
|
|
38779
|
-
}
|
|
38780
|
-
|
|
38781
|
-
/**
|
|
38782
|
-
* Checks if a `cache` value for `key` exists.
|
|
38783
|
-
*
|
|
38784
|
-
* @private
|
|
38785
|
-
* @param {Object} cache The cache to query.
|
|
38786
|
-
* @param {string} key The key of the entry to check.
|
|
38787
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
38788
|
-
*/
|
|
38789
|
-
function cacheHas(cache, key) {
|
|
38790
|
-
return cache.has(key);
|
|
38791
|
-
}
|
|
38792
|
-
|
|
38793
|
-
/**
|
|
38794
|
-
* Gets the value at `key` of `object`.
|
|
38795
|
-
*
|
|
38796
|
-
* @private
|
|
38797
|
-
* @param {Object} [object] The object to query.
|
|
38798
|
-
* @param {string} key The key of the property to get.
|
|
38799
|
-
* @returns {*} Returns the property value.
|
|
38800
|
-
*/
|
|
38801
|
-
function getValue(object, key) {
|
|
38802
|
-
return object == null ? undefined : object[key];
|
|
38803
|
-
}
|
|
38804
|
-
|
|
38805
|
-
/**
|
|
38806
|
-
* Converts `map` to its key-value pairs.
|
|
38807
|
-
*
|
|
38808
|
-
* @private
|
|
38809
|
-
* @param {Object} map The map to convert.
|
|
38810
|
-
* @returns {Array} Returns the key-value pairs.
|
|
38811
|
-
*/
|
|
38812
|
-
function mapToArray(map) {
|
|
38813
|
-
var index = -1,
|
|
38814
|
-
result = Array(map.size);
|
|
38815
|
-
|
|
38816
|
-
map.forEach(function(value, key) {
|
|
38817
|
-
result[++index] = [key, value];
|
|
38818
|
-
});
|
|
38819
|
-
return result;
|
|
38820
|
-
}
|
|
38821
|
-
|
|
38822
|
-
/**
|
|
38823
|
-
* Creates a unary function that invokes `func` with its argument transformed.
|
|
38824
|
-
*
|
|
38825
|
-
* @private
|
|
38826
|
-
* @param {Function} func The function to wrap.
|
|
38827
|
-
* @param {Function} transform The argument transform.
|
|
38828
|
-
* @returns {Function} Returns the new function.
|
|
38829
|
-
*/
|
|
38830
|
-
function overArg(func, transform) {
|
|
38831
|
-
return function(arg) {
|
|
38832
|
-
return func(transform(arg));
|
|
38833
|
-
};
|
|
38834
|
-
}
|
|
38835
|
-
|
|
38836
|
-
/**
|
|
38837
|
-
* Converts `set` to an array of its values.
|
|
38838
|
-
*
|
|
38839
|
-
* @private
|
|
38840
|
-
* @param {Object} set The set to convert.
|
|
38841
|
-
* @returns {Array} Returns the values.
|
|
38842
|
-
*/
|
|
38843
|
-
function setToArray(set) {
|
|
38844
|
-
var index = -1,
|
|
38845
|
-
result = Array(set.size);
|
|
38846
|
-
|
|
38847
|
-
set.forEach(function(value) {
|
|
38848
|
-
result[++index] = value;
|
|
38849
|
-
});
|
|
38850
|
-
return result;
|
|
38851
|
-
}
|
|
38852
|
-
|
|
38853
|
-
/** Used for built-in method references. */
|
|
38854
|
-
var arrayProto = Array.prototype,
|
|
38855
|
-
funcProto = Function.prototype,
|
|
38856
|
-
objectProto = Object.prototype;
|
|
38857
|
-
|
|
38858
|
-
/** Used to detect overreaching core-js shims. */
|
|
38859
|
-
var coreJsData = root['__core-js_shared__'];
|
|
38860
|
-
|
|
38861
|
-
/** Used to resolve the decompiled source of functions. */
|
|
38862
|
-
var funcToString = funcProto.toString;
|
|
38863
|
-
|
|
38864
|
-
/** Used to check objects for own properties. */
|
|
38865
|
-
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
38866
|
-
|
|
38867
|
-
/** Used to detect methods masquerading as native. */
|
|
38868
|
-
var maskSrcKey = (function() {
|
|
38869
|
-
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
38870
|
-
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
38871
|
-
}());
|
|
38872
|
-
|
|
38873
|
-
/**
|
|
38874
|
-
* Used to resolve the
|
|
38875
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
38876
|
-
* of values.
|
|
38877
|
-
*/
|
|
38878
|
-
var nativeObjectToString = objectProto.toString;
|
|
38879
|
-
|
|
38880
|
-
/** Used to detect if a method is native. */
|
|
38881
|
-
var reIsNative = RegExp('^' +
|
|
38882
|
-
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
|
38883
|
-
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
38884
|
-
);
|
|
38885
|
-
|
|
38886
|
-
/** Built-in value references. */
|
|
38887
|
-
var Buffer = moduleExports ? root.Buffer : undefined,
|
|
38888
|
-
Symbol = root.Symbol,
|
|
38889
|
-
Uint8Array = root.Uint8Array,
|
|
38890
|
-
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
|
38891
|
-
splice = arrayProto.splice,
|
|
38892
|
-
symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
38893
|
-
|
|
38894
|
-
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
38895
|
-
var nativeGetSymbols = Object.getOwnPropertySymbols,
|
|
38896
|
-
nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
|
|
38897
|
-
nativeKeys = overArg(Object.keys, Object);
|
|
38898
|
-
|
|
38899
|
-
/* Built-in method references that are verified to be native. */
|
|
38900
|
-
var DataView = getNative(root, 'DataView'),
|
|
38901
|
-
Map = getNative(root, 'Map'),
|
|
38902
|
-
Promise = getNative(root, 'Promise'),
|
|
38903
|
-
Set = getNative(root, 'Set'),
|
|
38904
|
-
WeakMap = getNative(root, 'WeakMap'),
|
|
38905
|
-
nativeCreate = getNative(Object, 'create');
|
|
38906
|
-
|
|
38907
|
-
/** Used to detect maps, sets, and weakmaps. */
|
|
38908
|
-
var dataViewCtorString = toSource(DataView),
|
|
38909
|
-
mapCtorString = toSource(Map),
|
|
38910
|
-
promiseCtorString = toSource(Promise),
|
|
38911
|
-
setCtorString = toSource(Set),
|
|
38912
|
-
weakMapCtorString = toSource(WeakMap);
|
|
38913
|
-
|
|
38914
|
-
/** Used to convert symbols to primitives and strings. */
|
|
38915
|
-
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|
38916
|
-
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
|
38917
|
-
|
|
38918
|
-
/**
|
|
38919
|
-
* Creates a hash object.
|
|
38920
|
-
*
|
|
38921
|
-
* @private
|
|
38922
|
-
* @constructor
|
|
38923
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
38924
|
-
*/
|
|
38925
|
-
function Hash(entries) {
|
|
38926
|
-
var index = -1,
|
|
38927
|
-
length = entries == null ? 0 : entries.length;
|
|
38928
|
-
|
|
38929
|
-
this.clear();
|
|
38930
|
-
while (++index < length) {
|
|
38931
|
-
var entry = entries[index];
|
|
38932
|
-
this.set(entry[0], entry[1]);
|
|
38933
|
-
}
|
|
38934
|
-
}
|
|
38935
|
-
|
|
38936
|
-
/**
|
|
38937
|
-
* Removes all key-value entries from the hash.
|
|
38938
|
-
*
|
|
38939
|
-
* @private
|
|
38940
|
-
* @name clear
|
|
38941
|
-
* @memberOf Hash
|
|
38942
|
-
*/
|
|
38943
|
-
function hashClear() {
|
|
38944
|
-
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
38945
|
-
this.size = 0;
|
|
38946
|
-
}
|
|
38947
|
-
|
|
38948
|
-
/**
|
|
38949
|
-
* Removes `key` and its value from the hash.
|
|
38950
|
-
*
|
|
38951
|
-
* @private
|
|
38952
|
-
* @name delete
|
|
38953
|
-
* @memberOf Hash
|
|
38954
|
-
* @param {Object} hash The hash to modify.
|
|
38955
|
-
* @param {string} key The key of the value to remove.
|
|
38956
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
38957
|
-
*/
|
|
38958
|
-
function hashDelete(key) {
|
|
38959
|
-
var result = this.has(key) && delete this.__data__[key];
|
|
38960
|
-
this.size -= result ? 1 : 0;
|
|
38961
|
-
return result;
|
|
38962
|
-
}
|
|
38963
|
-
|
|
38964
|
-
/**
|
|
38965
|
-
* Gets the hash value for `key`.
|
|
38966
|
-
*
|
|
38967
|
-
* @private
|
|
38968
|
-
* @name get
|
|
38969
|
-
* @memberOf Hash
|
|
38970
|
-
* @param {string} key The key of the value to get.
|
|
38971
|
-
* @returns {*} Returns the entry value.
|
|
38972
|
-
*/
|
|
38973
|
-
function hashGet(key) {
|
|
38974
|
-
var data = this.__data__;
|
|
38975
|
-
if (nativeCreate) {
|
|
38976
|
-
var result = data[key];
|
|
38977
|
-
return result === HASH_UNDEFINED ? undefined : result;
|
|
38978
|
-
}
|
|
38979
|
-
return hasOwnProperty.call(data, key) ? data[key] : undefined;
|
|
38980
|
-
}
|
|
38981
|
-
|
|
38982
|
-
/**
|
|
38983
|
-
* Checks if a hash value for `key` exists.
|
|
38984
|
-
*
|
|
38985
|
-
* @private
|
|
38986
|
-
* @name has
|
|
38987
|
-
* @memberOf Hash
|
|
38988
|
-
* @param {string} key The key of the entry to check.
|
|
38989
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
38990
|
-
*/
|
|
38991
|
-
function hashHas(key) {
|
|
38992
|
-
var data = this.__data__;
|
|
38993
|
-
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
|
|
38994
|
-
}
|
|
38995
|
-
|
|
38996
|
-
/**
|
|
38997
|
-
* Sets the hash `key` to `value`.
|
|
38998
|
-
*
|
|
38999
|
-
* @private
|
|
39000
|
-
* @name set
|
|
39001
|
-
* @memberOf Hash
|
|
39002
|
-
* @param {string} key The key of the value to set.
|
|
39003
|
-
* @param {*} value The value to set.
|
|
39004
|
-
* @returns {Object} Returns the hash instance.
|
|
39005
|
-
*/
|
|
39006
|
-
function hashSet(key, value) {
|
|
39007
|
-
var data = this.__data__;
|
|
39008
|
-
this.size += this.has(key) ? 0 : 1;
|
|
39009
|
-
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
|
39010
|
-
return this;
|
|
39011
|
-
}
|
|
39012
|
-
|
|
39013
|
-
// Add methods to `Hash`.
|
|
39014
|
-
Hash.prototype.clear = hashClear;
|
|
39015
|
-
Hash.prototype['delete'] = hashDelete;
|
|
39016
|
-
Hash.prototype.get = hashGet;
|
|
39017
|
-
Hash.prototype.has = hashHas;
|
|
39018
|
-
Hash.prototype.set = hashSet;
|
|
39019
|
-
|
|
39020
|
-
/**
|
|
39021
|
-
* Creates an list cache object.
|
|
39022
|
-
*
|
|
39023
|
-
* @private
|
|
39024
|
-
* @constructor
|
|
39025
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
39026
|
-
*/
|
|
39027
|
-
function ListCache(entries) {
|
|
39028
|
-
var index = -1,
|
|
39029
|
-
length = entries == null ? 0 : entries.length;
|
|
39030
|
-
|
|
39031
|
-
this.clear();
|
|
39032
|
-
while (++index < length) {
|
|
39033
|
-
var entry = entries[index];
|
|
39034
|
-
this.set(entry[0], entry[1]);
|
|
39035
|
-
}
|
|
39036
|
-
}
|
|
39037
|
-
|
|
39038
|
-
/**
|
|
39039
|
-
* Removes all key-value entries from the list cache.
|
|
39040
|
-
*
|
|
39041
|
-
* @private
|
|
39042
|
-
* @name clear
|
|
39043
|
-
* @memberOf ListCache
|
|
39044
|
-
*/
|
|
39045
|
-
function listCacheClear() {
|
|
39046
|
-
this.__data__ = [];
|
|
39047
|
-
this.size = 0;
|
|
39048
|
-
}
|
|
39049
|
-
|
|
39050
|
-
/**
|
|
39051
|
-
* Removes `key` and its value from the list cache.
|
|
39052
|
-
*
|
|
39053
|
-
* @private
|
|
39054
|
-
* @name delete
|
|
39055
|
-
* @memberOf ListCache
|
|
39056
|
-
* @param {string} key The key of the value to remove.
|
|
39057
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
39058
|
-
*/
|
|
39059
|
-
function listCacheDelete(key) {
|
|
39060
|
-
var data = this.__data__,
|
|
39061
|
-
index = assocIndexOf(data, key);
|
|
39062
|
-
|
|
39063
|
-
if (index < 0) {
|
|
39064
|
-
return false;
|
|
39065
|
-
}
|
|
39066
|
-
var lastIndex = data.length - 1;
|
|
39067
|
-
if (index == lastIndex) {
|
|
39068
|
-
data.pop();
|
|
39069
|
-
} else {
|
|
39070
|
-
splice.call(data, index, 1);
|
|
39071
|
-
}
|
|
39072
|
-
--this.size;
|
|
39073
|
-
return true;
|
|
39074
|
-
}
|
|
39075
|
-
|
|
39076
|
-
/**
|
|
39077
|
-
* Gets the list cache value for `key`.
|
|
39078
|
-
*
|
|
39079
|
-
* @private
|
|
39080
|
-
* @name get
|
|
39081
|
-
* @memberOf ListCache
|
|
39082
|
-
* @param {string} key The key of the value to get.
|
|
39083
|
-
* @returns {*} Returns the entry value.
|
|
39084
|
-
*/
|
|
39085
|
-
function listCacheGet(key) {
|
|
39086
|
-
var data = this.__data__,
|
|
39087
|
-
index = assocIndexOf(data, key);
|
|
39088
|
-
|
|
39089
|
-
return index < 0 ? undefined : data[index][1];
|
|
39090
|
-
}
|
|
39091
|
-
|
|
39092
|
-
/**
|
|
39093
|
-
* Checks if a list cache value for `key` exists.
|
|
39094
|
-
*
|
|
39095
|
-
* @private
|
|
39096
|
-
* @name has
|
|
39097
|
-
* @memberOf ListCache
|
|
39098
|
-
* @param {string} key The key of the entry to check.
|
|
39099
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
39100
|
-
*/
|
|
39101
|
-
function listCacheHas(key) {
|
|
39102
|
-
return assocIndexOf(this.__data__, key) > -1;
|
|
39103
|
-
}
|
|
39104
|
-
|
|
39105
|
-
/**
|
|
39106
|
-
* Sets the list cache `key` to `value`.
|
|
39107
|
-
*
|
|
39108
|
-
* @private
|
|
39109
|
-
* @name set
|
|
39110
|
-
* @memberOf ListCache
|
|
39111
|
-
* @param {string} key The key of the value to set.
|
|
39112
|
-
* @param {*} value The value to set.
|
|
39113
|
-
* @returns {Object} Returns the list cache instance.
|
|
39114
|
-
*/
|
|
39115
|
-
function listCacheSet(key, value) {
|
|
39116
|
-
var data = this.__data__,
|
|
39117
|
-
index = assocIndexOf(data, key);
|
|
39118
|
-
|
|
39119
|
-
if (index < 0) {
|
|
39120
|
-
++this.size;
|
|
39121
|
-
data.push([key, value]);
|
|
39122
|
-
} else {
|
|
39123
|
-
data[index][1] = value;
|
|
39124
|
-
}
|
|
39125
|
-
return this;
|
|
39126
|
-
}
|
|
39127
|
-
|
|
39128
|
-
// Add methods to `ListCache`.
|
|
39129
|
-
ListCache.prototype.clear = listCacheClear;
|
|
39130
|
-
ListCache.prototype['delete'] = listCacheDelete;
|
|
39131
|
-
ListCache.prototype.get = listCacheGet;
|
|
39132
|
-
ListCache.prototype.has = listCacheHas;
|
|
39133
|
-
ListCache.prototype.set = listCacheSet;
|
|
39134
|
-
|
|
39135
|
-
/**
|
|
39136
|
-
* Creates a map cache object to store key-value pairs.
|
|
39137
|
-
*
|
|
39138
|
-
* @private
|
|
39139
|
-
* @constructor
|
|
39140
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
39141
|
-
*/
|
|
39142
|
-
function MapCache(entries) {
|
|
39143
|
-
var index = -1,
|
|
39144
|
-
length = entries == null ? 0 : entries.length;
|
|
39145
|
-
|
|
39146
|
-
this.clear();
|
|
39147
|
-
while (++index < length) {
|
|
39148
|
-
var entry = entries[index];
|
|
39149
|
-
this.set(entry[0], entry[1]);
|
|
39150
|
-
}
|
|
39151
|
-
}
|
|
39152
|
-
|
|
39153
|
-
/**
|
|
39154
|
-
* Removes all key-value entries from the map.
|
|
39155
|
-
*
|
|
39156
|
-
* @private
|
|
39157
|
-
* @name clear
|
|
39158
|
-
* @memberOf MapCache
|
|
39159
|
-
*/
|
|
39160
|
-
function mapCacheClear() {
|
|
39161
|
-
this.size = 0;
|
|
39162
|
-
this.__data__ = {
|
|
39163
|
-
'hash': new Hash,
|
|
39164
|
-
'map': new (Map || ListCache),
|
|
39165
|
-
'string': new Hash
|
|
39166
|
-
};
|
|
39167
|
-
}
|
|
39168
|
-
|
|
39169
|
-
/**
|
|
39170
|
-
* Removes `key` and its value from the map.
|
|
39171
|
-
*
|
|
39172
|
-
* @private
|
|
39173
|
-
* @name delete
|
|
39174
|
-
* @memberOf MapCache
|
|
39175
|
-
* @param {string} key The key of the value to remove.
|
|
39176
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
39177
|
-
*/
|
|
39178
|
-
function mapCacheDelete(key) {
|
|
39179
|
-
var result = getMapData(this, key)['delete'](key);
|
|
39180
|
-
this.size -= result ? 1 : 0;
|
|
39181
|
-
return result;
|
|
39182
|
-
}
|
|
39183
|
-
|
|
39184
|
-
/**
|
|
39185
|
-
* Gets the map value for `key`.
|
|
39186
|
-
*
|
|
39187
|
-
* @private
|
|
39188
|
-
* @name get
|
|
39189
|
-
* @memberOf MapCache
|
|
39190
|
-
* @param {string} key The key of the value to get.
|
|
39191
|
-
* @returns {*} Returns the entry value.
|
|
39192
|
-
*/
|
|
39193
|
-
function mapCacheGet(key) {
|
|
39194
|
-
return getMapData(this, key).get(key);
|
|
39195
|
-
}
|
|
39196
|
-
|
|
39197
|
-
/**
|
|
39198
|
-
* Checks if a map value for `key` exists.
|
|
39199
|
-
*
|
|
39200
|
-
* @private
|
|
39201
|
-
* @name has
|
|
39202
|
-
* @memberOf MapCache
|
|
39203
|
-
* @param {string} key The key of the entry to check.
|
|
39204
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
39205
|
-
*/
|
|
39206
|
-
function mapCacheHas(key) {
|
|
39207
|
-
return getMapData(this, key).has(key);
|
|
39208
|
-
}
|
|
39209
|
-
|
|
39210
|
-
/**
|
|
39211
|
-
* Sets the map `key` to `value`.
|
|
39212
|
-
*
|
|
39213
|
-
* @private
|
|
39214
|
-
* @name set
|
|
39215
|
-
* @memberOf MapCache
|
|
39216
|
-
* @param {string} key The key of the value to set.
|
|
39217
|
-
* @param {*} value The value to set.
|
|
39218
|
-
* @returns {Object} Returns the map cache instance.
|
|
39219
|
-
*/
|
|
39220
|
-
function mapCacheSet(key, value) {
|
|
39221
|
-
var data = getMapData(this, key),
|
|
39222
|
-
size = data.size;
|
|
39223
|
-
|
|
39224
|
-
data.set(key, value);
|
|
39225
|
-
this.size += data.size == size ? 0 : 1;
|
|
39226
|
-
return this;
|
|
39227
|
-
}
|
|
39228
|
-
|
|
39229
|
-
// Add methods to `MapCache`.
|
|
39230
|
-
MapCache.prototype.clear = mapCacheClear;
|
|
39231
|
-
MapCache.prototype['delete'] = mapCacheDelete;
|
|
39232
|
-
MapCache.prototype.get = mapCacheGet;
|
|
39233
|
-
MapCache.prototype.has = mapCacheHas;
|
|
39234
|
-
MapCache.prototype.set = mapCacheSet;
|
|
39235
|
-
|
|
39236
|
-
/**
|
|
39237
|
-
*
|
|
39238
|
-
* Creates an array cache object to store unique values.
|
|
39239
|
-
*
|
|
39240
|
-
* @private
|
|
39241
|
-
* @constructor
|
|
39242
|
-
* @param {Array} [values] The values to cache.
|
|
39243
|
-
*/
|
|
39244
|
-
function SetCache(values) {
|
|
39245
|
-
var index = -1,
|
|
39246
|
-
length = values == null ? 0 : values.length;
|
|
39247
|
-
|
|
39248
|
-
this.__data__ = new MapCache;
|
|
39249
|
-
while (++index < length) {
|
|
39250
|
-
this.add(values[index]);
|
|
39251
|
-
}
|
|
39252
|
-
}
|
|
39253
|
-
|
|
39254
|
-
/**
|
|
39255
|
-
* Adds `value` to the array cache.
|
|
39256
|
-
*
|
|
39257
|
-
* @private
|
|
39258
|
-
* @name add
|
|
39259
|
-
* @memberOf SetCache
|
|
39260
|
-
* @alias push
|
|
39261
|
-
* @param {*} value The value to cache.
|
|
39262
|
-
* @returns {Object} Returns the cache instance.
|
|
39263
|
-
*/
|
|
39264
|
-
function setCacheAdd(value) {
|
|
39265
|
-
this.__data__.set(value, HASH_UNDEFINED);
|
|
39266
|
-
return this;
|
|
39267
|
-
}
|
|
39268
|
-
|
|
39269
|
-
/**
|
|
39270
|
-
* Checks if `value` is in the array cache.
|
|
39271
|
-
*
|
|
39272
|
-
* @private
|
|
39273
|
-
* @name has
|
|
39274
|
-
* @memberOf SetCache
|
|
39275
|
-
* @param {*} value The value to search for.
|
|
39276
|
-
* @returns {number} Returns `true` if `value` is found, else `false`.
|
|
39277
|
-
*/
|
|
39278
|
-
function setCacheHas(value) {
|
|
39279
|
-
return this.__data__.has(value);
|
|
39280
|
-
}
|
|
39281
|
-
|
|
39282
|
-
// Add methods to `SetCache`.
|
|
39283
|
-
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|
39284
|
-
SetCache.prototype.has = setCacheHas;
|
|
39285
|
-
|
|
39286
|
-
/**
|
|
39287
|
-
* Creates a stack cache object to store key-value pairs.
|
|
39288
|
-
*
|
|
39289
|
-
* @private
|
|
39290
|
-
* @constructor
|
|
39291
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
39292
|
-
*/
|
|
39293
|
-
function Stack(entries) {
|
|
39294
|
-
var data = this.__data__ = new ListCache(entries);
|
|
39295
|
-
this.size = data.size;
|
|
39296
|
-
}
|
|
39297
|
-
|
|
39298
|
-
/**
|
|
39299
|
-
* Removes all key-value entries from the stack.
|
|
39300
|
-
*
|
|
39301
|
-
* @private
|
|
39302
|
-
* @name clear
|
|
39303
|
-
* @memberOf Stack
|
|
39304
|
-
*/
|
|
39305
|
-
function stackClear() {
|
|
39306
|
-
this.__data__ = new ListCache;
|
|
39307
|
-
this.size = 0;
|
|
39308
|
-
}
|
|
39309
|
-
|
|
39310
|
-
/**
|
|
39311
|
-
* Removes `key` and its value from the stack.
|
|
39312
|
-
*
|
|
39313
|
-
* @private
|
|
39314
|
-
* @name delete
|
|
39315
|
-
* @memberOf Stack
|
|
39316
|
-
* @param {string} key The key of the value to remove.
|
|
39317
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
39318
|
-
*/
|
|
39319
|
-
function stackDelete(key) {
|
|
39320
|
-
var data = this.__data__,
|
|
39321
|
-
result = data['delete'](key);
|
|
39322
|
-
|
|
39323
|
-
this.size = data.size;
|
|
39324
|
-
return result;
|
|
39325
|
-
}
|
|
39326
|
-
|
|
39327
|
-
/**
|
|
39328
|
-
* Gets the stack value for `key`.
|
|
39329
|
-
*
|
|
39330
|
-
* @private
|
|
39331
|
-
* @name get
|
|
39332
|
-
* @memberOf Stack
|
|
39333
|
-
* @param {string} key The key of the value to get.
|
|
39334
|
-
* @returns {*} Returns the entry value.
|
|
39335
|
-
*/
|
|
39336
|
-
function stackGet(key) {
|
|
39337
|
-
return this.__data__.get(key);
|
|
39338
|
-
}
|
|
39339
|
-
|
|
39340
|
-
/**
|
|
39341
|
-
* Checks if a stack value for `key` exists.
|
|
39342
|
-
*
|
|
39343
|
-
* @private
|
|
39344
|
-
* @name has
|
|
39345
|
-
* @memberOf Stack
|
|
39346
|
-
* @param {string} key The key of the entry to check.
|
|
39347
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
39348
|
-
*/
|
|
39349
|
-
function stackHas(key) {
|
|
39350
|
-
return this.__data__.has(key);
|
|
39351
|
-
}
|
|
39352
|
-
|
|
39353
|
-
/**
|
|
39354
|
-
* Sets the stack `key` to `value`.
|
|
39355
|
-
*
|
|
39356
|
-
* @private
|
|
39357
|
-
* @name set
|
|
39358
|
-
* @memberOf Stack
|
|
39359
|
-
* @param {string} key The key of the value to set.
|
|
39360
|
-
* @param {*} value The value to set.
|
|
39361
|
-
* @returns {Object} Returns the stack cache instance.
|
|
39362
|
-
*/
|
|
39363
|
-
function stackSet(key, value) {
|
|
39364
|
-
var data = this.__data__;
|
|
39365
|
-
if (data instanceof ListCache) {
|
|
39366
|
-
var pairs = data.__data__;
|
|
39367
|
-
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
|
39368
|
-
pairs.push([key, value]);
|
|
39369
|
-
this.size = ++data.size;
|
|
39370
|
-
return this;
|
|
39371
|
-
}
|
|
39372
|
-
data = this.__data__ = new MapCache(pairs);
|
|
39373
|
-
}
|
|
39374
|
-
data.set(key, value);
|
|
39375
|
-
this.size = data.size;
|
|
39376
|
-
return this;
|
|
39377
|
-
}
|
|
39378
|
-
|
|
39379
|
-
// Add methods to `Stack`.
|
|
39380
|
-
Stack.prototype.clear = stackClear;
|
|
39381
|
-
Stack.prototype['delete'] = stackDelete;
|
|
39382
|
-
Stack.prototype.get = stackGet;
|
|
39383
|
-
Stack.prototype.has = stackHas;
|
|
39384
|
-
Stack.prototype.set = stackSet;
|
|
39385
|
-
|
|
39386
|
-
/**
|
|
39387
|
-
* Creates an array of the enumerable property names of the array-like `value`.
|
|
39388
|
-
*
|
|
39389
|
-
* @private
|
|
39390
|
-
* @param {*} value The value to query.
|
|
39391
|
-
* @param {boolean} inherited Specify returning inherited property names.
|
|
39392
|
-
* @returns {Array} Returns the array of property names.
|
|
39393
|
-
*/
|
|
39394
|
-
function arrayLikeKeys(value, inherited) {
|
|
39395
|
-
var isArr = isArray(value),
|
|
39396
|
-
isArg = !isArr && isArguments(value),
|
|
39397
|
-
isBuff = !isArr && !isArg && isBuffer(value),
|
|
39398
|
-
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
|
39399
|
-
skipIndexes = isArr || isArg || isBuff || isType,
|
|
39400
|
-
result = skipIndexes ? baseTimes(value.length, String) : [],
|
|
39401
|
-
length = result.length;
|
|
39402
|
-
|
|
39403
|
-
for (var key in value) {
|
|
39404
|
-
if ((inherited || hasOwnProperty.call(value, key)) &&
|
|
39405
|
-
!(skipIndexes && (
|
|
39406
|
-
// Safari 9 has enumerable `arguments.length` in strict mode.
|
|
39407
|
-
key == 'length' ||
|
|
39408
|
-
// Node.js 0.10 has enumerable non-index properties on buffers.
|
|
39409
|
-
(isBuff && (key == 'offset' || key == 'parent')) ||
|
|
39410
|
-
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
39411
|
-
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
|
39412
|
-
// Skip index properties.
|
|
39413
|
-
isIndex(key, length)
|
|
39414
|
-
))) {
|
|
39415
|
-
result.push(key);
|
|
39416
|
-
}
|
|
39417
|
-
}
|
|
39418
|
-
return result;
|
|
39419
|
-
}
|
|
39420
|
-
|
|
39421
|
-
/**
|
|
39422
|
-
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
39423
|
-
*
|
|
39424
|
-
* @private
|
|
39425
|
-
* @param {Array} array The array to inspect.
|
|
39426
|
-
* @param {*} key The key to search for.
|
|
39427
|
-
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
39428
|
-
*/
|
|
39429
|
-
function assocIndexOf(array, key) {
|
|
39430
|
-
var length = array.length;
|
|
39431
|
-
while (length--) {
|
|
39432
|
-
if (eq(array[length][0], key)) {
|
|
39433
|
-
return length;
|
|
39434
|
-
}
|
|
39435
|
-
}
|
|
39436
|
-
return -1;
|
|
39437
|
-
}
|
|
39438
|
-
|
|
39439
|
-
/**
|
|
39440
|
-
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
|
|
39441
|
-
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
|
|
39442
|
-
* symbols of `object`.
|
|
39443
|
-
*
|
|
39444
|
-
* @private
|
|
39445
|
-
* @param {Object} object The object to query.
|
|
39446
|
-
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
39447
|
-
* @param {Function} symbolsFunc The function to get the symbols of `object`.
|
|
39448
|
-
* @returns {Array} Returns the array of property names and symbols.
|
|
39449
|
-
*/
|
|
39450
|
-
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
|
39451
|
-
var result = keysFunc(object);
|
|
39452
|
-
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
|
39453
|
-
}
|
|
39454
|
-
|
|
39455
|
-
/**
|
|
39456
|
-
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
39457
|
-
*
|
|
39458
|
-
* @private
|
|
39459
|
-
* @param {*} value The value to query.
|
|
39460
|
-
* @returns {string} Returns the `toStringTag`.
|
|
39461
|
-
*/
|
|
39462
|
-
function baseGetTag(value) {
|
|
39463
|
-
if (value == null) {
|
|
39464
|
-
return value === undefined ? undefinedTag : nullTag;
|
|
39465
|
-
}
|
|
39466
|
-
return (symToStringTag && symToStringTag in Object(value))
|
|
39467
|
-
? getRawTag(value)
|
|
39468
|
-
: objectToString(value);
|
|
39469
|
-
}
|
|
39470
|
-
|
|
39471
|
-
/**
|
|
39472
|
-
* The base implementation of `_.isArguments`.
|
|
39473
|
-
*
|
|
39474
|
-
* @private
|
|
39475
|
-
* @param {*} value The value to check.
|
|
39476
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
39477
|
-
*/
|
|
39478
|
-
function baseIsArguments(value) {
|
|
39479
|
-
return isObjectLike(value) && baseGetTag(value) == argsTag;
|
|
39480
|
-
}
|
|
39481
|
-
|
|
39482
|
-
/**
|
|
39483
|
-
* The base implementation of `_.isEqual` which supports partial comparisons
|
|
39484
|
-
* and tracks traversed objects.
|
|
39485
|
-
*
|
|
39486
|
-
* @private
|
|
39487
|
-
* @param {*} value The value to compare.
|
|
39488
|
-
* @param {*} other The other value to compare.
|
|
39489
|
-
* @param {boolean} bitmask The bitmask flags.
|
|
39490
|
-
* 1 - Unordered comparison
|
|
39491
|
-
* 2 - Partial comparison
|
|
39492
|
-
* @param {Function} [customizer] The function to customize comparisons.
|
|
39493
|
-
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
|
|
39494
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
39495
|
-
*/
|
|
39496
|
-
function baseIsEqual(value, other, bitmask, customizer, stack) {
|
|
39497
|
-
if (value === other) {
|
|
39498
|
-
return true;
|
|
39499
|
-
}
|
|
39500
|
-
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
|
|
39501
|
-
return value !== value && other !== other;
|
|
39502
|
-
}
|
|
39503
|
-
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
|
39504
|
-
}
|
|
39505
|
-
|
|
39506
|
-
/**
|
|
39507
|
-
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
|
39508
|
-
* deep comparisons and tracks traversed objects enabling objects with circular
|
|
39509
|
-
* references to be compared.
|
|
39510
|
-
*
|
|
39511
|
-
* @private
|
|
39512
|
-
* @param {Object} object The object to compare.
|
|
39513
|
-
* @param {Object} other The other object to compare.
|
|
39514
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
39515
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
39516
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
39517
|
-
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
|
39518
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
39519
|
-
*/
|
|
39520
|
-
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
39521
|
-
var objIsArr = isArray(object),
|
|
39522
|
-
othIsArr = isArray(other),
|
|
39523
|
-
objTag = objIsArr ? arrayTag : getTag(object),
|
|
39524
|
-
othTag = othIsArr ? arrayTag : getTag(other);
|
|
39525
|
-
|
|
39526
|
-
objTag = objTag == argsTag ? objectTag : objTag;
|
|
39527
|
-
othTag = othTag == argsTag ? objectTag : othTag;
|
|
39528
|
-
|
|
39529
|
-
var objIsObj = objTag == objectTag,
|
|
39530
|
-
othIsObj = othTag == objectTag,
|
|
39531
|
-
isSameTag = objTag == othTag;
|
|
39532
|
-
|
|
39533
|
-
if (isSameTag && isBuffer(object)) {
|
|
39534
|
-
if (!isBuffer(other)) {
|
|
39535
|
-
return false;
|
|
39536
|
-
}
|
|
39537
|
-
objIsArr = true;
|
|
39538
|
-
objIsObj = false;
|
|
39539
|
-
}
|
|
39540
|
-
if (isSameTag && !objIsObj) {
|
|
39541
|
-
stack || (stack = new Stack);
|
|
39542
|
-
return (objIsArr || isTypedArray(object))
|
|
39543
|
-
? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
|
|
39544
|
-
: equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
39545
|
-
}
|
|
39546
|
-
if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
|
|
39547
|
-
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
|
39548
|
-
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
|
39549
|
-
|
|
39550
|
-
if (objIsWrapped || othIsWrapped) {
|
|
39551
|
-
var objUnwrapped = objIsWrapped ? object.value() : object,
|
|
39552
|
-
othUnwrapped = othIsWrapped ? other.value() : other;
|
|
39553
|
-
|
|
39554
|
-
stack || (stack = new Stack);
|
|
39555
|
-
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
|
39556
|
-
}
|
|
39557
|
-
}
|
|
39558
|
-
if (!isSameTag) {
|
|
39559
|
-
return false;
|
|
39560
|
-
}
|
|
39561
|
-
stack || (stack = new Stack);
|
|
39562
|
-
return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
|
|
39563
|
-
}
|
|
39564
|
-
|
|
39565
|
-
/**
|
|
39566
|
-
* The base implementation of `_.isNative` without bad shim checks.
|
|
39567
|
-
*
|
|
39568
|
-
* @private
|
|
39569
|
-
* @param {*} value The value to check.
|
|
39570
|
-
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
39571
|
-
* else `false`.
|
|
39572
|
-
*/
|
|
39573
|
-
function baseIsNative(value) {
|
|
39574
|
-
if (!isObject(value) || isMasked(value)) {
|
|
39575
|
-
return false;
|
|
39576
|
-
}
|
|
39577
|
-
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
39578
|
-
return pattern.test(toSource(value));
|
|
39579
|
-
}
|
|
39580
|
-
|
|
39581
|
-
/**
|
|
39582
|
-
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
|
39583
|
-
*
|
|
39584
|
-
* @private
|
|
39585
|
-
* @param {*} value The value to check.
|
|
39586
|
-
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
39587
|
-
*/
|
|
39588
|
-
function baseIsTypedArray(value) {
|
|
39589
|
-
return isObjectLike(value) &&
|
|
39590
|
-
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
39591
|
-
}
|
|
39592
|
-
|
|
39593
|
-
/**
|
|
39594
|
-
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
|
39595
|
-
*
|
|
39596
|
-
* @private
|
|
39597
|
-
* @param {Object} object The object to query.
|
|
39598
|
-
* @returns {Array} Returns the array of property names.
|
|
39599
|
-
*/
|
|
39600
|
-
function baseKeys(object) {
|
|
39601
|
-
if (!isPrototype(object)) {
|
|
39602
|
-
return nativeKeys(object);
|
|
39603
|
-
}
|
|
39604
|
-
var result = [];
|
|
39605
|
-
for (var key in Object(object)) {
|
|
39606
|
-
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
|
39607
|
-
result.push(key);
|
|
39608
|
-
}
|
|
39609
|
-
}
|
|
39610
|
-
return result;
|
|
39611
|
-
}
|
|
39612
|
-
|
|
39613
|
-
/**
|
|
39614
|
-
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|
39615
|
-
* partial deep comparisons.
|
|
39616
|
-
*
|
|
39617
|
-
* @private
|
|
39618
|
-
* @param {Array} array The array to compare.
|
|
39619
|
-
* @param {Array} other The other array to compare.
|
|
39620
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
39621
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
39622
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
39623
|
-
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
|
39624
|
-
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|
39625
|
-
*/
|
|
39626
|
-
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|
39627
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
|
39628
|
-
arrLength = array.length,
|
|
39629
|
-
othLength = other.length;
|
|
39630
|
-
|
|
39631
|
-
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|
39632
|
-
return false;
|
|
39633
|
-
}
|
|
39634
|
-
// Assume cyclic values are equal.
|
|
39635
|
-
var stacked = stack.get(array);
|
|
39636
|
-
if (stacked && stack.get(other)) {
|
|
39637
|
-
return stacked == other;
|
|
39638
|
-
}
|
|
39639
|
-
var index = -1,
|
|
39640
|
-
result = true,
|
|
39641
|
-
seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
|
|
39642
|
-
|
|
39643
|
-
stack.set(array, other);
|
|
39644
|
-
stack.set(other, array);
|
|
39645
|
-
|
|
39646
|
-
// Ignore non-index properties.
|
|
39647
|
-
while (++index < arrLength) {
|
|
39648
|
-
var arrValue = array[index],
|
|
39649
|
-
othValue = other[index];
|
|
39650
|
-
|
|
39651
|
-
if (customizer) {
|
|
39652
|
-
var compared = isPartial
|
|
39653
|
-
? customizer(othValue, arrValue, index, other, array, stack)
|
|
39654
|
-
: customizer(arrValue, othValue, index, array, other, stack);
|
|
39655
|
-
}
|
|
39656
|
-
if (compared !== undefined) {
|
|
39657
|
-
if (compared) {
|
|
39658
|
-
continue;
|
|
39659
|
-
}
|
|
39660
|
-
result = false;
|
|
39661
|
-
break;
|
|
39662
|
-
}
|
|
39663
|
-
// Recursively compare arrays (susceptible to call stack limits).
|
|
39664
|
-
if (seen) {
|
|
39665
|
-
if (!arraySome(other, function(othValue, othIndex) {
|
|
39666
|
-
if (!cacheHas(seen, othIndex) &&
|
|
39667
|
-
(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
|
39668
|
-
return seen.push(othIndex);
|
|
39669
|
-
}
|
|
39670
|
-
})) {
|
|
39671
|
-
result = false;
|
|
39672
|
-
break;
|
|
39673
|
-
}
|
|
39674
|
-
} else if (!(
|
|
39675
|
-
arrValue === othValue ||
|
|
39676
|
-
equalFunc(arrValue, othValue, bitmask, customizer, stack)
|
|
39677
|
-
)) {
|
|
39678
|
-
result = false;
|
|
39679
|
-
break;
|
|
39680
|
-
}
|
|
39681
|
-
}
|
|
39682
|
-
stack['delete'](array);
|
|
39683
|
-
stack['delete'](other);
|
|
39684
|
-
return result;
|
|
39685
|
-
}
|
|
39686
|
-
|
|
39687
|
-
/**
|
|
39688
|
-
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|
39689
|
-
* the same `toStringTag`.
|
|
39690
|
-
*
|
|
39691
|
-
* **Note:** This function only supports comparing values with tags of
|
|
39692
|
-
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
|
39693
|
-
*
|
|
39694
|
-
* @private
|
|
39695
|
-
* @param {Object} object The object to compare.
|
|
39696
|
-
* @param {Object} other The other object to compare.
|
|
39697
|
-
* @param {string} tag The `toStringTag` of the objects to compare.
|
|
39698
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
39699
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
39700
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
39701
|
-
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
39702
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
39703
|
-
*/
|
|
39704
|
-
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
39705
|
-
switch (tag) {
|
|
39706
|
-
case dataViewTag:
|
|
39707
|
-
if ((object.byteLength != other.byteLength) ||
|
|
39708
|
-
(object.byteOffset != other.byteOffset)) {
|
|
39709
|
-
return false;
|
|
39710
|
-
}
|
|
39711
|
-
object = object.buffer;
|
|
39712
|
-
other = other.buffer;
|
|
39713
|
-
|
|
39714
|
-
case arrayBufferTag:
|
|
39715
|
-
if ((object.byteLength != other.byteLength) ||
|
|
39716
|
-
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
|
|
39717
|
-
return false;
|
|
39718
|
-
}
|
|
39719
|
-
return true;
|
|
39720
|
-
|
|
39721
|
-
case boolTag:
|
|
39722
|
-
case dateTag:
|
|
39723
|
-
case numberTag:
|
|
39724
|
-
// Coerce booleans to `1` or `0` and dates to milliseconds.
|
|
39725
|
-
// Invalid dates are coerced to `NaN`.
|
|
39726
|
-
return eq(+object, +other);
|
|
39727
|
-
|
|
39728
|
-
case errorTag:
|
|
39729
|
-
return object.name == other.name && object.message == other.message;
|
|
39730
|
-
|
|
39731
|
-
case regexpTag:
|
|
39732
|
-
case stringTag:
|
|
39733
|
-
// Coerce regexes to strings and treat strings, primitives and objects,
|
|
39734
|
-
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
|
|
39735
|
-
// for more details.
|
|
39736
|
-
return object == (other + '');
|
|
39737
|
-
|
|
39738
|
-
case mapTag:
|
|
39739
|
-
var convert = mapToArray;
|
|
39740
|
-
|
|
39741
|
-
case setTag:
|
|
39742
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
|
|
39743
|
-
convert || (convert = setToArray);
|
|
39744
|
-
|
|
39745
|
-
if (object.size != other.size && !isPartial) {
|
|
39746
|
-
return false;
|
|
39747
|
-
}
|
|
39748
|
-
// Assume cyclic values are equal.
|
|
39749
|
-
var stacked = stack.get(object);
|
|
39750
|
-
if (stacked) {
|
|
39751
|
-
return stacked == other;
|
|
39752
|
-
}
|
|
39753
|
-
bitmask |= COMPARE_UNORDERED_FLAG;
|
|
39754
|
-
|
|
39755
|
-
// Recursively compare objects (susceptible to call stack limits).
|
|
39756
|
-
stack.set(object, other);
|
|
39757
|
-
var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
39758
|
-
stack['delete'](object);
|
|
39759
|
-
return result;
|
|
39760
|
-
|
|
39761
|
-
case symbolTag:
|
|
39762
|
-
if (symbolValueOf) {
|
|
39763
|
-
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
39764
|
-
}
|
|
39765
|
-
}
|
|
39766
|
-
return false;
|
|
39767
|
-
}
|
|
39768
|
-
|
|
39769
|
-
/**
|
|
39770
|
-
* A specialized version of `baseIsEqualDeep` for objects with support for
|
|
39771
|
-
* partial deep comparisons.
|
|
39772
|
-
*
|
|
39773
|
-
* @private
|
|
39774
|
-
* @param {Object} object The object to compare.
|
|
39775
|
-
* @param {Object} other The other object to compare.
|
|
39776
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
39777
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
39778
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
39779
|
-
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
39780
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
39781
|
-
*/
|
|
39782
|
-
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
39783
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
|
39784
|
-
objProps = getAllKeys(object),
|
|
39785
|
-
objLength = objProps.length,
|
|
39786
|
-
othProps = getAllKeys(other),
|
|
39787
|
-
othLength = othProps.length;
|
|
39788
|
-
|
|
39789
|
-
if (objLength != othLength && !isPartial) {
|
|
39790
|
-
return false;
|
|
39791
|
-
}
|
|
39792
|
-
var index = objLength;
|
|
39793
|
-
while (index--) {
|
|
39794
|
-
var key = objProps[index];
|
|
39795
|
-
if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
|
|
39796
|
-
return false;
|
|
39797
|
-
}
|
|
39798
|
-
}
|
|
39799
|
-
// Assume cyclic values are equal.
|
|
39800
|
-
var stacked = stack.get(object);
|
|
39801
|
-
if (stacked && stack.get(other)) {
|
|
39802
|
-
return stacked == other;
|
|
39803
|
-
}
|
|
39804
|
-
var result = true;
|
|
39805
|
-
stack.set(object, other);
|
|
39806
|
-
stack.set(other, object);
|
|
39807
|
-
|
|
39808
|
-
var skipCtor = isPartial;
|
|
39809
|
-
while (++index < objLength) {
|
|
39810
|
-
key = objProps[index];
|
|
39811
|
-
var objValue = object[key],
|
|
39812
|
-
othValue = other[key];
|
|
39813
|
-
|
|
39814
|
-
if (customizer) {
|
|
39815
|
-
var compared = isPartial
|
|
39816
|
-
? customizer(othValue, objValue, key, other, object, stack)
|
|
39817
|
-
: customizer(objValue, othValue, key, object, other, stack);
|
|
39818
|
-
}
|
|
39819
|
-
// Recursively compare objects (susceptible to call stack limits).
|
|
39820
|
-
if (!(compared === undefined
|
|
39821
|
-
? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
|
|
39822
|
-
: compared
|
|
39823
|
-
)) {
|
|
39824
|
-
result = false;
|
|
39825
|
-
break;
|
|
39826
|
-
}
|
|
39827
|
-
skipCtor || (skipCtor = key == 'constructor');
|
|
39828
|
-
}
|
|
39829
|
-
if (result && !skipCtor) {
|
|
39830
|
-
var objCtor = object.constructor,
|
|
39831
|
-
othCtor = other.constructor;
|
|
39832
|
-
|
|
39833
|
-
// Non `Object` object instances with different constructors are not equal.
|
|
39834
|
-
if (objCtor != othCtor &&
|
|
39835
|
-
('constructor' in object && 'constructor' in other) &&
|
|
39836
|
-
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
|
|
39837
|
-
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
|
39838
|
-
result = false;
|
|
39839
|
-
}
|
|
39840
|
-
}
|
|
39841
|
-
stack['delete'](object);
|
|
39842
|
-
stack['delete'](other);
|
|
39843
|
-
return result;
|
|
39844
|
-
}
|
|
39845
|
-
|
|
39846
|
-
/**
|
|
39847
|
-
* Creates an array of own enumerable property names and symbols of `object`.
|
|
39848
|
-
*
|
|
39849
|
-
* @private
|
|
39850
|
-
* @param {Object} object The object to query.
|
|
39851
|
-
* @returns {Array} Returns the array of property names and symbols.
|
|
39852
|
-
*/
|
|
39853
|
-
function getAllKeys(object) {
|
|
39854
|
-
return baseGetAllKeys(object, keys, getSymbols);
|
|
39855
|
-
}
|
|
39856
|
-
|
|
39857
|
-
/**
|
|
39858
|
-
* Gets the data for `map`.
|
|
39859
|
-
*
|
|
39860
|
-
* @private
|
|
39861
|
-
* @param {Object} map The map to query.
|
|
39862
|
-
* @param {string} key The reference key.
|
|
39863
|
-
* @returns {*} Returns the map data.
|
|
39864
|
-
*/
|
|
39865
|
-
function getMapData(map, key) {
|
|
39866
|
-
var data = map.__data__;
|
|
39867
|
-
return isKeyable(key)
|
|
39868
|
-
? data[typeof key == 'string' ? 'string' : 'hash']
|
|
39869
|
-
: data.map;
|
|
39870
|
-
}
|
|
39871
|
-
|
|
39872
|
-
/**
|
|
39873
|
-
* Gets the native function at `key` of `object`.
|
|
39874
|
-
*
|
|
39875
|
-
* @private
|
|
39876
|
-
* @param {Object} object The object to query.
|
|
39877
|
-
* @param {string} key The key of the method to get.
|
|
39878
|
-
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
39879
|
-
*/
|
|
39880
|
-
function getNative(object, key) {
|
|
39881
|
-
var value = getValue(object, key);
|
|
39882
|
-
return baseIsNative(value) ? value : undefined;
|
|
39883
|
-
}
|
|
39884
|
-
|
|
39885
|
-
/**
|
|
39886
|
-
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
39887
|
-
*
|
|
39888
|
-
* @private
|
|
39889
|
-
* @param {*} value The value to query.
|
|
39890
|
-
* @returns {string} Returns the raw `toStringTag`.
|
|
39891
|
-
*/
|
|
39892
|
-
function getRawTag(value) {
|
|
39893
|
-
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
|
39894
|
-
tag = value[symToStringTag];
|
|
39895
|
-
|
|
39896
|
-
try {
|
|
39897
|
-
value[symToStringTag] = undefined;
|
|
39898
|
-
var unmasked = true;
|
|
39899
|
-
} catch (e) {}
|
|
39900
|
-
|
|
39901
|
-
var result = nativeObjectToString.call(value);
|
|
39902
|
-
if (unmasked) {
|
|
39903
|
-
if (isOwn) {
|
|
39904
|
-
value[symToStringTag] = tag;
|
|
39905
|
-
} else {
|
|
39906
|
-
delete value[symToStringTag];
|
|
39907
|
-
}
|
|
39908
|
-
}
|
|
39909
|
-
return result;
|
|
39910
|
-
}
|
|
39911
|
-
|
|
39912
|
-
/**
|
|
39913
|
-
* Creates an array of the own enumerable symbols of `object`.
|
|
39914
|
-
*
|
|
39915
|
-
* @private
|
|
39916
|
-
* @param {Object} object The object to query.
|
|
39917
|
-
* @returns {Array} Returns the array of symbols.
|
|
39918
|
-
*/
|
|
39919
|
-
var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
|
|
39920
|
-
if (object == null) {
|
|
39921
|
-
return [];
|
|
39922
|
-
}
|
|
39923
|
-
object = Object(object);
|
|
39924
|
-
return arrayFilter(nativeGetSymbols(object), function(symbol) {
|
|
39925
|
-
return propertyIsEnumerable.call(object, symbol);
|
|
39926
|
-
});
|
|
39927
|
-
};
|
|
39928
|
-
|
|
39929
|
-
/**
|
|
39930
|
-
* Gets the `toStringTag` of `value`.
|
|
39931
|
-
*
|
|
39932
|
-
* @private
|
|
39933
|
-
* @param {*} value The value to query.
|
|
39934
|
-
* @returns {string} Returns the `toStringTag`.
|
|
39935
|
-
*/
|
|
39936
|
-
var getTag = baseGetTag;
|
|
39937
|
-
|
|
39938
|
-
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
|
39939
|
-
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
|
39940
|
-
(Map && getTag(new Map) != mapTag) ||
|
|
39941
|
-
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
|
39942
|
-
(Set && getTag(new Set) != setTag) ||
|
|
39943
|
-
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
|
39944
|
-
getTag = function(value) {
|
|
39945
|
-
var result = baseGetTag(value),
|
|
39946
|
-
Ctor = result == objectTag ? value.constructor : undefined,
|
|
39947
|
-
ctorString = Ctor ? toSource(Ctor) : '';
|
|
39948
|
-
|
|
39949
|
-
if (ctorString) {
|
|
39950
|
-
switch (ctorString) {
|
|
39951
|
-
case dataViewCtorString: return dataViewTag;
|
|
39952
|
-
case mapCtorString: return mapTag;
|
|
39953
|
-
case promiseCtorString: return promiseTag;
|
|
39954
|
-
case setCtorString: return setTag;
|
|
39955
|
-
case weakMapCtorString: return weakMapTag;
|
|
39956
|
-
}
|
|
39957
|
-
}
|
|
39958
|
-
return result;
|
|
39959
|
-
};
|
|
39960
|
-
}
|
|
39961
|
-
|
|
39962
|
-
/**
|
|
39963
|
-
* Checks if `value` is a valid array-like index.
|
|
39964
|
-
*
|
|
39965
|
-
* @private
|
|
39966
|
-
* @param {*} value The value to check.
|
|
39967
|
-
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
|
39968
|
-
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
|
39969
|
-
*/
|
|
39970
|
-
function isIndex(value, length) {
|
|
39971
|
-
length = length == null ? MAX_SAFE_INTEGER : length;
|
|
39972
|
-
return !!length &&
|
|
39973
|
-
(typeof value == 'number' || reIsUint.test(value)) &&
|
|
39974
|
-
(value > -1 && value % 1 == 0 && value < length);
|
|
39975
|
-
}
|
|
39976
|
-
|
|
39977
|
-
/**
|
|
39978
|
-
* Checks if `value` is suitable for use as unique object key.
|
|
39979
|
-
*
|
|
39980
|
-
* @private
|
|
39981
|
-
* @param {*} value The value to check.
|
|
39982
|
-
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
39983
|
-
*/
|
|
39984
|
-
function isKeyable(value) {
|
|
39985
|
-
var type = typeof value;
|
|
39986
|
-
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|
39987
|
-
? (value !== '__proto__')
|
|
39988
|
-
: (value === null);
|
|
39989
|
-
}
|
|
39990
|
-
|
|
39991
|
-
/**
|
|
39992
|
-
* Checks if `func` has its source masked.
|
|
39993
|
-
*
|
|
39994
|
-
* @private
|
|
39995
|
-
* @param {Function} func The function to check.
|
|
39996
|
-
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
39997
|
-
*/
|
|
39998
|
-
function isMasked(func) {
|
|
39999
|
-
return !!maskSrcKey && (maskSrcKey in func);
|
|
40000
|
-
}
|
|
40001
|
-
|
|
40002
|
-
/**
|
|
40003
|
-
* Checks if `value` is likely a prototype object.
|
|
40004
|
-
*
|
|
40005
|
-
* @private
|
|
40006
|
-
* @param {*} value The value to check.
|
|
40007
|
-
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|
40008
|
-
*/
|
|
40009
|
-
function isPrototype(value) {
|
|
40010
|
-
var Ctor = value && value.constructor,
|
|
40011
|
-
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
|
|
40012
|
-
|
|
40013
|
-
return value === proto;
|
|
40014
|
-
}
|
|
40015
|
-
|
|
40016
|
-
/**
|
|
40017
|
-
* Converts `value` to a string using `Object.prototype.toString`.
|
|
40018
|
-
*
|
|
40019
|
-
* @private
|
|
40020
|
-
* @param {*} value The value to convert.
|
|
40021
|
-
* @returns {string} Returns the converted string.
|
|
40022
|
-
*/
|
|
40023
|
-
function objectToString(value) {
|
|
40024
|
-
return nativeObjectToString.call(value);
|
|
40025
|
-
}
|
|
40026
|
-
|
|
40027
|
-
/**
|
|
40028
|
-
* Converts `func` to its source code.
|
|
40029
|
-
*
|
|
40030
|
-
* @private
|
|
40031
|
-
* @param {Function} func The function to convert.
|
|
40032
|
-
* @returns {string} Returns the source code.
|
|
40033
|
-
*/
|
|
40034
|
-
function toSource(func) {
|
|
40035
|
-
if (func != null) {
|
|
40036
|
-
try {
|
|
40037
|
-
return funcToString.call(func);
|
|
40038
|
-
} catch (e) {}
|
|
40039
|
-
try {
|
|
40040
|
-
return (func + '');
|
|
40041
|
-
} catch (e) {}
|
|
40042
|
-
}
|
|
40043
|
-
return '';
|
|
40044
|
-
}
|
|
40045
|
-
|
|
40046
|
-
/**
|
|
40047
|
-
* Performs a
|
|
40048
|
-
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
40049
|
-
* comparison between two values to determine if they are equivalent.
|
|
40050
|
-
*
|
|
40051
|
-
* @static
|
|
40052
|
-
* @memberOf _
|
|
40053
|
-
* @since 4.0.0
|
|
40054
|
-
* @category Lang
|
|
40055
|
-
* @param {*} value The value to compare.
|
|
40056
|
-
* @param {*} other The other value to compare.
|
|
40057
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
40058
|
-
* @example
|
|
40059
|
-
*
|
|
40060
|
-
* var object = { 'a': 1 };
|
|
40061
|
-
* var other = { 'a': 1 };
|
|
40062
|
-
*
|
|
40063
|
-
* _.eq(object, object);
|
|
40064
|
-
* // => true
|
|
40065
|
-
*
|
|
40066
|
-
* _.eq(object, other);
|
|
40067
|
-
* // => false
|
|
40068
|
-
*
|
|
40069
|
-
* _.eq('a', 'a');
|
|
40070
|
-
* // => true
|
|
40071
|
-
*
|
|
40072
|
-
* _.eq('a', Object('a'));
|
|
40073
|
-
* // => false
|
|
40074
|
-
*
|
|
40075
|
-
* _.eq(NaN, NaN);
|
|
40076
|
-
* // => true
|
|
40077
|
-
*/
|
|
40078
|
-
function eq(value, other) {
|
|
40079
|
-
return value === other || (value !== value && other !== other);
|
|
40080
|
-
}
|
|
40081
|
-
|
|
40082
|
-
/**
|
|
40083
|
-
* Checks if `value` is likely an `arguments` object.
|
|
40084
|
-
*
|
|
40085
|
-
* @static
|
|
40086
|
-
* @memberOf _
|
|
40087
|
-
* @since 0.1.0
|
|
40088
|
-
* @category Lang
|
|
40089
|
-
* @param {*} value The value to check.
|
|
40090
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
40091
|
-
* else `false`.
|
|
40092
|
-
* @example
|
|
40093
|
-
*
|
|
40094
|
-
* _.isArguments(function() { return arguments; }());
|
|
40095
|
-
* // => true
|
|
40096
|
-
*
|
|
40097
|
-
* _.isArguments([1, 2, 3]);
|
|
40098
|
-
* // => false
|
|
40099
|
-
*/
|
|
40100
|
-
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
|
40101
|
-
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
|
40102
|
-
!propertyIsEnumerable.call(value, 'callee');
|
|
40103
|
-
};
|
|
40104
|
-
|
|
40105
|
-
/**
|
|
40106
|
-
* Checks if `value` is classified as an `Array` object.
|
|
40107
|
-
*
|
|
40108
|
-
* @static
|
|
40109
|
-
* @memberOf _
|
|
40110
|
-
* @since 0.1.0
|
|
40111
|
-
* @category Lang
|
|
40112
|
-
* @param {*} value The value to check.
|
|
40113
|
-
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
40114
|
-
* @example
|
|
40115
|
-
*
|
|
40116
|
-
* _.isArray([1, 2, 3]);
|
|
40117
|
-
* // => true
|
|
40118
|
-
*
|
|
40119
|
-
* _.isArray(document.body.children);
|
|
40120
|
-
* // => false
|
|
40121
|
-
*
|
|
40122
|
-
* _.isArray('abc');
|
|
40123
|
-
* // => false
|
|
40124
|
-
*
|
|
40125
|
-
* _.isArray(_.noop);
|
|
40126
|
-
* // => false
|
|
40127
|
-
*/
|
|
40128
|
-
var isArray = Array.isArray;
|
|
40129
|
-
|
|
40130
|
-
/**
|
|
40131
|
-
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
40132
|
-
* not a function and has a `value.length` that's an integer greater than or
|
|
40133
|
-
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
40134
|
-
*
|
|
40135
|
-
* @static
|
|
40136
|
-
* @memberOf _
|
|
40137
|
-
* @since 4.0.0
|
|
40138
|
-
* @category Lang
|
|
40139
|
-
* @param {*} value The value to check.
|
|
40140
|
-
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
40141
|
-
* @example
|
|
40142
|
-
*
|
|
40143
|
-
* _.isArrayLike([1, 2, 3]);
|
|
40144
|
-
* // => true
|
|
40145
|
-
*
|
|
40146
|
-
* _.isArrayLike(document.body.children);
|
|
40147
|
-
* // => true
|
|
40148
|
-
*
|
|
40149
|
-
* _.isArrayLike('abc');
|
|
40150
|
-
* // => true
|
|
40151
|
-
*
|
|
40152
|
-
* _.isArrayLike(_.noop);
|
|
40153
|
-
* // => false
|
|
40154
|
-
*/
|
|
40155
|
-
function isArrayLike(value) {
|
|
40156
|
-
return value != null && isLength(value.length) && !isFunction(value);
|
|
40157
|
-
}
|
|
40158
|
-
|
|
40159
|
-
/**
|
|
40160
|
-
* Checks if `value` is a buffer.
|
|
40161
|
-
*
|
|
40162
|
-
* @static
|
|
40163
|
-
* @memberOf _
|
|
40164
|
-
* @since 4.3.0
|
|
40165
|
-
* @category Lang
|
|
40166
|
-
* @param {*} value The value to check.
|
|
40167
|
-
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
40168
|
-
* @example
|
|
40169
|
-
*
|
|
40170
|
-
* _.isBuffer(new Buffer(2));
|
|
40171
|
-
* // => true
|
|
40172
|
-
*
|
|
40173
|
-
* _.isBuffer(new Uint8Array(2));
|
|
40174
|
-
* // => false
|
|
40175
|
-
*/
|
|
40176
|
-
var isBuffer = nativeIsBuffer || stubFalse;
|
|
40177
|
-
|
|
40178
|
-
/**
|
|
40179
|
-
* Performs a deep comparison between two values to determine if they are
|
|
40180
|
-
* equivalent.
|
|
40181
|
-
*
|
|
40182
|
-
* **Note:** This method supports comparing arrays, array buffers, booleans,
|
|
40183
|
-
* date objects, error objects, maps, numbers, `Object` objects, regexes,
|
|
40184
|
-
* sets, strings, symbols, and typed arrays. `Object` objects are compared
|
|
40185
|
-
* by their own, not inherited, enumerable properties. Functions and DOM
|
|
40186
|
-
* nodes are compared by strict equality, i.e. `===`.
|
|
40187
|
-
*
|
|
40188
|
-
* @static
|
|
40189
|
-
* @memberOf _
|
|
40190
|
-
* @since 0.1.0
|
|
40191
|
-
* @category Lang
|
|
40192
|
-
* @param {*} value The value to compare.
|
|
40193
|
-
* @param {*} other The other value to compare.
|
|
40194
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
40195
|
-
* @example
|
|
40196
|
-
*
|
|
40197
|
-
* var object = { 'a': 1 };
|
|
40198
|
-
* var other = { 'a': 1 };
|
|
40199
|
-
*
|
|
40200
|
-
* _.isEqual(object, other);
|
|
40201
|
-
* // => true
|
|
40202
|
-
*
|
|
40203
|
-
* object === other;
|
|
40204
|
-
* // => false
|
|
40205
|
-
*/
|
|
40206
|
-
function isEqual(value, other) {
|
|
40207
|
-
return baseIsEqual(value, other);
|
|
40208
|
-
}
|
|
40209
|
-
|
|
40210
|
-
/**
|
|
40211
|
-
* Checks if `value` is classified as a `Function` object.
|
|
40212
|
-
*
|
|
40213
|
-
* @static
|
|
40214
|
-
* @memberOf _
|
|
40215
|
-
* @since 0.1.0
|
|
40216
|
-
* @category Lang
|
|
40217
|
-
* @param {*} value The value to check.
|
|
40218
|
-
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
40219
|
-
* @example
|
|
40220
|
-
*
|
|
40221
|
-
* _.isFunction(_);
|
|
40222
|
-
* // => true
|
|
40223
|
-
*
|
|
40224
|
-
* _.isFunction(/abc/);
|
|
40225
|
-
* // => false
|
|
40226
|
-
*/
|
|
40227
|
-
function isFunction(value) {
|
|
40228
|
-
if (!isObject(value)) {
|
|
40229
|
-
return false;
|
|
40230
|
-
}
|
|
40231
|
-
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
40232
|
-
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
40233
|
-
var tag = baseGetTag(value);
|
|
40234
|
-
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
40235
|
-
}
|
|
40236
|
-
|
|
40237
|
-
/**
|
|
40238
|
-
* Checks if `value` is a valid array-like length.
|
|
40239
|
-
*
|
|
40240
|
-
* **Note:** This method is loosely based on
|
|
40241
|
-
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
40242
|
-
*
|
|
40243
|
-
* @static
|
|
40244
|
-
* @memberOf _
|
|
40245
|
-
* @since 4.0.0
|
|
40246
|
-
* @category Lang
|
|
40247
|
-
* @param {*} value The value to check.
|
|
40248
|
-
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
40249
|
-
* @example
|
|
40250
|
-
*
|
|
40251
|
-
* _.isLength(3);
|
|
40252
|
-
* // => true
|
|
40253
|
-
*
|
|
40254
|
-
* _.isLength(Number.MIN_VALUE);
|
|
40255
|
-
* // => false
|
|
40256
|
-
*
|
|
40257
|
-
* _.isLength(Infinity);
|
|
40258
|
-
* // => false
|
|
40259
|
-
*
|
|
40260
|
-
* _.isLength('3');
|
|
40261
|
-
* // => false
|
|
40262
|
-
*/
|
|
40263
|
-
function isLength(value) {
|
|
40264
|
-
return typeof value == 'number' &&
|
|
40265
|
-
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
40266
|
-
}
|
|
40267
|
-
|
|
40268
|
-
/**
|
|
40269
|
-
* Checks if `value` is the
|
|
40270
|
-
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
40271
|
-
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
40272
|
-
*
|
|
40273
|
-
* @static
|
|
40274
|
-
* @memberOf _
|
|
40275
|
-
* @since 0.1.0
|
|
40276
|
-
* @category Lang
|
|
40277
|
-
* @param {*} value The value to check.
|
|
40278
|
-
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
40279
|
-
* @example
|
|
40280
|
-
*
|
|
40281
|
-
* _.isObject({});
|
|
40282
|
-
* // => true
|
|
40283
|
-
*
|
|
40284
|
-
* _.isObject([1, 2, 3]);
|
|
40285
|
-
* // => true
|
|
40286
|
-
*
|
|
40287
|
-
* _.isObject(_.noop);
|
|
40288
|
-
* // => true
|
|
40289
|
-
*
|
|
40290
|
-
* _.isObject(null);
|
|
40291
|
-
* // => false
|
|
40292
|
-
*/
|
|
40293
|
-
function isObject(value) {
|
|
40294
|
-
var type = typeof value;
|
|
40295
|
-
return value != null && (type == 'object' || type == 'function');
|
|
40296
|
-
}
|
|
40297
|
-
|
|
40298
|
-
/**
|
|
40299
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
40300
|
-
* and has a `typeof` result of "object".
|
|
40301
|
-
*
|
|
40302
|
-
* @static
|
|
40303
|
-
* @memberOf _
|
|
40304
|
-
* @since 4.0.0
|
|
40305
|
-
* @category Lang
|
|
40306
|
-
* @param {*} value The value to check.
|
|
40307
|
-
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
40308
|
-
* @example
|
|
40309
|
-
*
|
|
40310
|
-
* _.isObjectLike({});
|
|
40311
|
-
* // => true
|
|
40312
|
-
*
|
|
40313
|
-
* _.isObjectLike([1, 2, 3]);
|
|
40314
|
-
* // => true
|
|
40315
|
-
*
|
|
40316
|
-
* _.isObjectLike(_.noop);
|
|
40317
|
-
* // => false
|
|
40318
|
-
*
|
|
40319
|
-
* _.isObjectLike(null);
|
|
40320
|
-
* // => false
|
|
40321
|
-
*/
|
|
40322
|
-
function isObjectLike(value) {
|
|
40323
|
-
return value != null && typeof value == 'object';
|
|
40324
|
-
}
|
|
40325
|
-
|
|
40326
|
-
/**
|
|
40327
|
-
* Checks if `value` is classified as a typed array.
|
|
40328
|
-
*
|
|
40329
|
-
* @static
|
|
40330
|
-
* @memberOf _
|
|
40331
|
-
* @since 3.0.0
|
|
40332
|
-
* @category Lang
|
|
40333
|
-
* @param {*} value The value to check.
|
|
40334
|
-
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
40335
|
-
* @example
|
|
40336
|
-
*
|
|
40337
|
-
* _.isTypedArray(new Uint8Array);
|
|
40338
|
-
* // => true
|
|
40339
|
-
*
|
|
40340
|
-
* _.isTypedArray([]);
|
|
40341
|
-
* // => false
|
|
40342
|
-
*/
|
|
40343
|
-
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
40344
|
-
|
|
40345
|
-
/**
|
|
40346
|
-
* Creates an array of the own enumerable property names of `object`.
|
|
40347
|
-
*
|
|
40348
|
-
* **Note:** Non-object values are coerced to objects. See the
|
|
40349
|
-
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
|
40350
|
-
* for more details.
|
|
40351
|
-
*
|
|
40352
|
-
* @static
|
|
40353
|
-
* @since 0.1.0
|
|
40354
|
-
* @memberOf _
|
|
40355
|
-
* @category Object
|
|
40356
|
-
* @param {Object} object The object to query.
|
|
40357
|
-
* @returns {Array} Returns the array of property names.
|
|
40358
|
-
* @example
|
|
40359
|
-
*
|
|
40360
|
-
* function Foo() {
|
|
40361
|
-
* this.a = 1;
|
|
40362
|
-
* this.b = 2;
|
|
40363
|
-
* }
|
|
40364
|
-
*
|
|
40365
|
-
* Foo.prototype.c = 3;
|
|
40366
|
-
*
|
|
40367
|
-
* _.keys(new Foo);
|
|
40368
|
-
* // => ['a', 'b'] (iteration order is not guaranteed)
|
|
40369
|
-
*
|
|
40370
|
-
* _.keys('hi');
|
|
40371
|
-
* // => ['0', '1']
|
|
40372
|
-
*/
|
|
40373
|
-
function keys(object) {
|
|
40374
|
-
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|
40375
|
-
}
|
|
40376
|
-
|
|
40377
|
-
/**
|
|
40378
|
-
* This method returns a new empty array.
|
|
40379
|
-
*
|
|
40380
|
-
* @static
|
|
40381
|
-
* @memberOf _
|
|
40382
|
-
* @since 4.13.0
|
|
40383
|
-
* @category Util
|
|
40384
|
-
* @returns {Array} Returns the new empty array.
|
|
40385
|
-
* @example
|
|
40386
|
-
*
|
|
40387
|
-
* var arrays = _.times(2, _.stubArray);
|
|
40388
|
-
*
|
|
40389
|
-
* console.log(arrays);
|
|
40390
|
-
* // => [[], []]
|
|
40391
|
-
*
|
|
40392
|
-
* console.log(arrays[0] === arrays[1]);
|
|
40393
|
-
* // => false
|
|
40394
|
-
*/
|
|
40395
|
-
function stubArray() {
|
|
40396
|
-
return [];
|
|
40397
|
-
}
|
|
40398
|
-
|
|
40399
|
-
/**
|
|
40400
|
-
* This method returns `false`.
|
|
40401
|
-
*
|
|
40402
|
-
* @static
|
|
40403
|
-
* @memberOf _
|
|
40404
|
-
* @since 4.13.0
|
|
40405
|
-
* @category Util
|
|
40406
|
-
* @returns {boolean} Returns `false`.
|
|
40407
|
-
* @example
|
|
40408
|
-
*
|
|
40409
|
-
* _.times(2, _.stubFalse);
|
|
40410
|
-
* // => [false, false]
|
|
40411
|
-
*/
|
|
40412
|
-
function stubFalse() {
|
|
40413
|
-
return false;
|
|
40414
|
-
}
|
|
40415
|
-
|
|
40416
|
-
module.exports = isEqual;
|
|
40417
|
-
});
|
|
40418
|
-
|
|
40419
|
-
var dist$3 = createCommonjsModule$1(function (module, exports) {
|
|
40420
|
-
(function (global, factory) {
|
|
40421
|
-
module.exports = factory(dist$6, require$$2$1, require$$2, lodash_throttle, require$$1, require$$4, lodash_isequal) ;
|
|
40422
|
-
})(commonjsGlobal, (function (core, slate, snabbdom, throttle, $, nanoid, isEqual) {
|
|
40423
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
40424
|
-
|
|
40425
|
-
var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle);
|
|
40426
|
-
var $__default = /*#__PURE__*/_interopDefaultLegacy($);
|
|
40427
|
-
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
40428
|
-
|
|
40429
|
-
/**
|
|
40430
|
-
* @description i18n en
|
|
40431
|
-
* @author wangfupeng
|
|
40432
|
-
*/
|
|
40433
|
-
var enResources = {
|
|
40434
|
-
tableModule: {
|
|
40435
|
-
deleteCol: 'Delete column',
|
|
40436
|
-
deleteRow: 'Delete row',
|
|
40437
|
-
deleteTable: 'Delete table',
|
|
40438
|
-
widthAuto: 'Width auto',
|
|
40439
|
-
insertCol: 'Insert column',
|
|
40440
|
-
insertRow: 'Insert row',
|
|
40441
|
-
insertTable: 'Insert table',
|
|
40442
|
-
header: 'Header',
|
|
40443
|
-
},
|
|
40444
|
-
};
|
|
40445
|
-
|
|
40446
|
-
/**
|
|
40447
|
-
* @description i18n zh-CN
|
|
40448
|
-
* @author wangfupeng
|
|
40449
|
-
*/
|
|
40450
|
-
var zhResources = {
|
|
40451
|
-
tableModule: {
|
|
40452
|
-
deleteCol: '删除列',
|
|
40453
|
-
deleteRow: '删除行',
|
|
40454
|
-
deleteTable: '删除表格',
|
|
40455
|
-
widthAuto: '宽度自适应',
|
|
40456
|
-
insertCol: '插入列',
|
|
40457
|
-
insertRow: '插入行',
|
|
40458
|
-
insertTable: '插入表格',
|
|
40459
|
-
header: '表头',
|
|
38909
|
+
var TableCursor = {
|
|
38910
|
+
/** @returns {boolean} `true` if the selection is inside a table, otherwise `false`. */
|
|
38911
|
+
isInTable: function (editor, options) {
|
|
38912
|
+
if (options === void 0) { options = {}; }
|
|
38913
|
+
var _a = __read(slate.Editor.nodes(editor, {
|
|
38914
|
+
match: isOfType(editor, 'table'),
|
|
38915
|
+
at: options.at,
|
|
38916
|
+
}), 1), table = _a[0];
|
|
38917
|
+
return !!table;
|
|
40460
38918
|
},
|
|
40461
|
-
|
|
40462
|
-
|
|
40463
|
-
|
|
40464
|
-
|
|
40465
|
-
|
|
40466
|
-
|
|
40467
|
-
|
|
40468
|
-
|
|
40469
|
-
|
|
40470
|
-
|
|
40471
|
-
|
|
40472
|
-
|
|
40473
|
-
|
|
40474
|
-
|
|
40475
|
-
|
|
40476
|
-
|
|
40477
|
-
|
|
40478
|
-
|
|
40479
|
-
|
|
40480
|
-
|
|
40481
|
-
|
|
40482
|
-
|
|
40483
|
-
|
|
40484
|
-
|
|
40485
|
-
|
|
40486
|
-
|
|
40487
|
-
|
|
40488
|
-
|
|
40489
|
-
|
|
40490
|
-
|
|
40491
|
-
|
|
40492
|
-
|
|
40493
|
-
|
|
40494
|
-
|
|
40495
|
-
|
|
40496
|
-
|
|
40497
|
-
|
|
40498
|
-
|
|
40499
|
-
|
|
40500
|
-
|
|
40501
|
-
|
|
40502
|
-
|
|
40503
|
-
|
|
40504
|
-
|
|
40505
|
-
|
|
40506
|
-
|
|
40507
|
-
|
|
38919
|
+
/**
|
|
38920
|
+
* Retrieves a matrix representing the selected cells within a table.
|
|
38921
|
+
* @returns {NodeEntry<T>[][]} A matrix containing the selected cells.
|
|
38922
|
+
*/
|
|
38923
|
+
selection: function (editor) {
|
|
38924
|
+
var matrix, x, cells, y, _a, entry, _b, colSpan, ttb;
|
|
38925
|
+
return __generator(this, function (_c) {
|
|
38926
|
+
switch (_c.label) {
|
|
38927
|
+
case 0:
|
|
38928
|
+
matrix = EDITOR_TO_SELECTION.get(editor);
|
|
38929
|
+
x = 0;
|
|
38930
|
+
_c.label = 1;
|
|
38931
|
+
case 1:
|
|
38932
|
+
if (!(matrix && x < matrix.length)) return [3 /*break*/, 4];
|
|
38933
|
+
cells = [];
|
|
38934
|
+
for (y = 0; y < matrix[x].length; y++) {
|
|
38935
|
+
_a = __read(matrix[x][y], 2), entry = _a[0], _b = _a[1], colSpan = _b.ltr, ttb = _b.ttb;
|
|
38936
|
+
ttb === 1 && cells.push(entry);
|
|
38937
|
+
y += colSpan - 1;
|
|
38938
|
+
}
|
|
38939
|
+
return [4 /*yield*/, cells];
|
|
38940
|
+
case 2:
|
|
38941
|
+
_c.sent();
|
|
38942
|
+
_c.label = 3;
|
|
38943
|
+
case 3:
|
|
38944
|
+
x++;
|
|
38945
|
+
return [3 /*break*/, 1];
|
|
38946
|
+
case 4: return [2 /*return*/];
|
|
38947
|
+
}
|
|
38948
|
+
});
|
|
38949
|
+
},
|
|
38950
|
+
/** Clears the selection from the table */
|
|
38951
|
+
unselect: function (editor) {
|
|
38952
|
+
// const matrix = EDITOR_TO_SELECTION.get(editor);
|
|
38953
|
+
var _a;
|
|
38954
|
+
// if (!matrix?.length) {
|
|
38955
|
+
// return;
|
|
38956
|
+
// }
|
|
38957
|
+
// for (let x = 0; x < matrix.length; x++) {
|
|
38958
|
+
// for (let y = 0; y < matrix[x].length; y++) {
|
|
38959
|
+
// const [[, path], { ltr: colSpan, ttb }] = matrix[x][y];
|
|
38960
|
+
// y += colSpan - 1;
|
|
38961
|
+
// if (ttb > 1) {
|
|
38962
|
+
// continue;
|
|
38963
|
+
// }
|
|
38964
|
+
// // no-op since the paths are the same
|
|
38965
|
+
// const noop: Operation = {
|
|
38966
|
+
// type: "move_node",
|
|
38967
|
+
// newPath: path,
|
|
38968
|
+
// path: path,
|
|
38969
|
+
// };
|
|
38970
|
+
// Transforms.transform(editor, noop);
|
|
38971
|
+
// }
|
|
38972
|
+
// }
|
|
38973
|
+
EDITOR_TO_SELECTION_SET.delete(editor);
|
|
38974
|
+
EDITOR_TO_SELECTION.delete(editor);
|
|
38975
|
+
// 清除选区
|
|
38976
|
+
(_a = document.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
38977
|
+
},
|
|
38978
|
+
/**
|
|
38979
|
+
* Checks whether a given cell is part of the current table selection.
|
|
38980
|
+
* @returns {boolean} - Returns true if the cell is selected, otherwise false.
|
|
38981
|
+
*/
|
|
38982
|
+
isSelected: function (editor, element) {
|
|
38983
|
+
var selectedElements = EDITOR_TO_SELECTION_SET.get(editor);
|
|
38984
|
+
if (!selectedElements) {
|
|
38985
|
+
return false;
|
|
40508
38986
|
}
|
|
40509
|
-
|
|
40510
|
-
}
|
|
40511
|
-
return ar;
|
|
40512
|
-
}
|
|
40513
|
-
|
|
40514
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
40515
|
-
var e = new Error(message);
|
|
40516
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
38987
|
+
return selectedElements.has(element);
|
|
38988
|
+
},
|
|
40517
38989
|
};
|
|
40518
38990
|
|
|
38991
|
+
function withSelection(editor) {
|
|
38992
|
+
var apply = editor.apply;
|
|
38993
|
+
editor.apply = function (op) {
|
|
38994
|
+
if (!slate.Operation.isSelectionOperation(op) || !op.newProperties) {
|
|
38995
|
+
// TableCursor.unselect(editor);
|
|
38996
|
+
// 仿飞书效果,拖动单元格宽度时,选区不消失
|
|
38997
|
+
return apply(op);
|
|
38998
|
+
}
|
|
38999
|
+
var selection = __assign(__assign({}, editor.selection), op.newProperties);
|
|
39000
|
+
if (!slate.Range.isRange(selection)) {
|
|
39001
|
+
TableCursor.unselect(editor);
|
|
39002
|
+
return apply(op);
|
|
39003
|
+
}
|
|
39004
|
+
var _a = __read(slate.Editor.nodes(editor, {
|
|
39005
|
+
match: isOfType(editor, 'th', 'td'),
|
|
39006
|
+
at: slate.Range.start(selection),
|
|
39007
|
+
}), 1), fromEntry = _a[0];
|
|
39008
|
+
var _b = __read(slate.Editor.nodes(editor, {
|
|
39009
|
+
match: isOfType(editor, 'th', 'td'),
|
|
39010
|
+
at: slate.Range.end(selection),
|
|
39011
|
+
}), 1), toEntry = _b[0];
|
|
39012
|
+
if (!fromEntry || !toEntry) {
|
|
39013
|
+
// TableCursor.unselect(editor)
|
|
39014
|
+
return apply(op);
|
|
39015
|
+
}
|
|
39016
|
+
var _c = __read(fromEntry, 2), fromPath = _c[1];
|
|
39017
|
+
var _d = __read(toEntry, 2), toPath = _d[1];
|
|
39018
|
+
if (slate.Path.equals(fromPath, toPath) || !hasCommon(editor, [fromPath, toPath], 'table')) {
|
|
39019
|
+
TableCursor.unselect(editor);
|
|
39020
|
+
return apply(op);
|
|
39021
|
+
}
|
|
39022
|
+
// TODO: perf: could be improved by passing a Span [fromPath, toPath]
|
|
39023
|
+
var filled = filledMatrix(editor, { at: fromPath });
|
|
39024
|
+
// find initial bounds
|
|
39025
|
+
var from = Point.valueOf(0, 0);
|
|
39026
|
+
var to = Point.valueOf(0, 0);
|
|
39027
|
+
outer: for (var x = 0; x < filled.length; x++) {
|
|
39028
|
+
for (var y = 0; y < filled[x].length; y++) {
|
|
39029
|
+
var _e = __read(filled[x][y], 1), _f = __read(_e[0], 2), path = _f[1];
|
|
39030
|
+
if (slate.Path.equals(fromPath, path)) {
|
|
39031
|
+
from.x = x;
|
|
39032
|
+
from.y = y;
|
|
39033
|
+
}
|
|
39034
|
+
if (slate.Path.equals(toPath, path)) {
|
|
39035
|
+
to.x = x;
|
|
39036
|
+
to.y = y;
|
|
39037
|
+
break outer;
|
|
39038
|
+
}
|
|
39039
|
+
}
|
|
39040
|
+
}
|
|
39041
|
+
var start = Point.valueOf(Math.min(from.x, to.x), Math.min(from.y, to.y));
|
|
39042
|
+
var end = Point.valueOf(Math.max(from.x, to.x), Math.max(from.y, to.y));
|
|
39043
|
+
// expand the selection based on rowspan and colspan
|
|
39044
|
+
for (;;) {
|
|
39045
|
+
var nextStart = Point.valueOf(start.x, start.y);
|
|
39046
|
+
var nextEnd = Point.valueOf(end.x, end.y);
|
|
39047
|
+
for (var x = nextStart.x; x <= nextEnd.x; x++) {
|
|
39048
|
+
for (var y = nextStart.y; y <= nextEnd.y; y++) {
|
|
39049
|
+
var _g = __read(filled[x][y], 2), _h = _g[1], rtl = _h.rtl, ltr = _h.ltr, btt = _h.btt, ttb = _h.ttb;
|
|
39050
|
+
nextStart.x = Math.min(nextStart.x, x - (ttb - 1));
|
|
39051
|
+
nextStart.y = Math.min(nextStart.y, y - (rtl - 1));
|
|
39052
|
+
nextEnd.x = Math.max(nextEnd.x, x + (btt - 1));
|
|
39053
|
+
nextEnd.y = Math.max(nextEnd.y, y + (ltr - 1));
|
|
39054
|
+
}
|
|
39055
|
+
}
|
|
39056
|
+
if (Point.equals(start, nextStart) && Point.equals(end, nextEnd)) {
|
|
39057
|
+
break;
|
|
39058
|
+
}
|
|
39059
|
+
start = nextStart;
|
|
39060
|
+
end = nextEnd;
|
|
39061
|
+
}
|
|
39062
|
+
var selected = [];
|
|
39063
|
+
var selectedSet = new WeakSet();
|
|
39064
|
+
for (var x = start.x; x <= end.x; x++) {
|
|
39065
|
+
var cells = [];
|
|
39066
|
+
for (var y = start.y; y <= end.y; y++) {
|
|
39067
|
+
var _j = __read(filled[x][y], 1), _k = __read(_j[0], 1), element = _k[0];
|
|
39068
|
+
selectedSet.add(element);
|
|
39069
|
+
cells.push(filled[x][y]);
|
|
39070
|
+
}
|
|
39071
|
+
selected.push(cells);
|
|
39072
|
+
}
|
|
39073
|
+
EDITOR_TO_SELECTION.set(editor, selected);
|
|
39074
|
+
EDITOR_TO_SELECTION_SET.set(editor, selectedSet);
|
|
39075
|
+
apply(op);
|
|
39076
|
+
};
|
|
39077
|
+
return editor;
|
|
39078
|
+
}
|
|
39079
|
+
|
|
40519
39080
|
/**
|
|
40520
39081
|
* @description editor 插件,重写 editor API
|
|
40521
39082
|
* @author wangfupeng
|
|
@@ -40592,9 +39153,9 @@
|
|
|
40592
39153
|
var before = slate.Editor.before(newEditor, selection); // 前一个 location
|
|
40593
39154
|
if (before) {
|
|
40594
39155
|
var isTableOnBeforeLocation = isTableLocation(newEditor, before); // before 是否是 table
|
|
40595
|
-
|
|
40596
|
-
if (isTableOnBeforeLocation &&
|
|
40597
|
-
return;
|
|
39156
|
+
// 如果前面是 table, 当前是空 p,则不执行删除。否则会删除 table 最后一个 cell
|
|
39157
|
+
if (isTableOnBeforeLocation && core.DomEditor.isSelectedEmptyParagraph(newEditor)) {
|
|
39158
|
+
return;
|
|
40598
39159
|
}
|
|
40599
39160
|
}
|
|
40600
39161
|
}
|
|
@@ -40705,49 +39266,299 @@
|
|
|
40705
39266
|
};
|
|
40706
39267
|
newEditor.select(newSelection); // 选中 table-cell 内部的全部文字
|
|
40707
39268
|
};
|
|
39269
|
+
/**
|
|
39270
|
+
* 光标选区行为新增
|
|
39271
|
+
*/
|
|
39272
|
+
withSelection(newEditor);
|
|
40708
39273
|
// 可继续修改其他 newEditor API ...
|
|
40709
39274
|
// 返回 editor ,重要!
|
|
40710
39275
|
return newEditor;
|
|
40711
39276
|
}
|
|
40712
39277
|
|
|
40713
39278
|
/**
|
|
40714
|
-
* @description
|
|
39279
|
+
* @description DOM 操作
|
|
40715
39280
|
* @author wangfupeng
|
|
40716
39281
|
*/
|
|
39282
|
+
if ($.append)
|
|
39283
|
+
$__default["default"].fn.append = $.append;
|
|
39284
|
+
if ($.on)
|
|
39285
|
+
$__default["default"].fn.on = $.on;
|
|
39286
|
+
if ($.focus)
|
|
39287
|
+
$__default["default"].fn.focus = $.focus;
|
|
39288
|
+
if ($.attr)
|
|
39289
|
+
$__default["default"].fn.attr = $.attr;
|
|
39290
|
+
if ($.val)
|
|
39291
|
+
$__default["default"].fn.val = $.val;
|
|
39292
|
+
if ($.html)
|
|
39293
|
+
$__default["default"].fn.html = $.html;
|
|
39294
|
+
if ($.dataset)
|
|
39295
|
+
$__default["default"].fn.dataset = $.dataset;
|
|
39296
|
+
if ($.addClass)
|
|
39297
|
+
$__default["default"].fn.addClass = $.addClass;
|
|
39298
|
+
if ($.removeClass)
|
|
39299
|
+
$__default["default"].fn.removeClass = $.removeClass;
|
|
39300
|
+
if ($.children)
|
|
39301
|
+
$__default["default"].fn.children = $.children;
|
|
39302
|
+
if ($.each)
|
|
39303
|
+
$__default["default"].fn.each = $.each;
|
|
39304
|
+
if ($.find)
|
|
39305
|
+
$__default["default"].fn.find = $.find;
|
|
40717
39306
|
/**
|
|
40718
|
-
*
|
|
40719
|
-
* @param
|
|
39307
|
+
* 获取 tagName lower-case
|
|
39308
|
+
* @param $elem $elem
|
|
40720
39309
|
*/
|
|
40721
|
-
function
|
|
40722
|
-
|
|
40723
|
-
|
|
40724
|
-
|
|
40725
|
-
var firstRow = rows[0] || {}; // 第一行
|
|
40726
|
-
var cells = firstRow.children || []; // 第一行所有 cell
|
|
40727
|
-
return cells;
|
|
39310
|
+
function getTagName($elem) {
|
|
39311
|
+
if ($elem.length)
|
|
39312
|
+
return $elem[0].tagName.toLowerCase();
|
|
39313
|
+
return '';
|
|
40728
39314
|
}
|
|
40729
39315
|
/**
|
|
40730
|
-
*
|
|
40731
|
-
* @param
|
|
39316
|
+
* 获取 $elem 某一个 style 值
|
|
39317
|
+
* @param $elem $elem
|
|
39318
|
+
* @param styleKey style key
|
|
40732
39319
|
*/
|
|
40733
|
-
function
|
|
40734
|
-
var
|
|
40735
|
-
|
|
39320
|
+
function getStyleValue($elem, styleKey) {
|
|
39321
|
+
var res = '';
|
|
39322
|
+
var styleStr = $elem.attr('style') || ''; // 如 'line-height: 2.5; color: red;'
|
|
39323
|
+
var styleArr = styleStr.split(';'); // 如 ['line-height: 2.5', ' color: red', '']
|
|
39324
|
+
var length = styleArr.length;
|
|
39325
|
+
for (var i = 0; i < length; i++) {
|
|
39326
|
+
var styleItemStr = styleArr[i]; // 如 'line-height: 2.5'
|
|
39327
|
+
if (styleItemStr) {
|
|
39328
|
+
var arr = styleItemStr.split(':'); // ['line-height', ' 2.5']
|
|
39329
|
+
if (arr[0].trim() === styleKey) {
|
|
39330
|
+
res = arr[1].trim();
|
|
39331
|
+
}
|
|
39332
|
+
}
|
|
39333
|
+
}
|
|
39334
|
+
return res;
|
|
39335
|
+
}
|
|
39336
|
+
|
|
39337
|
+
/***
|
|
39338
|
+
* 计算 cell border 距离 table 左侧距离
|
|
39339
|
+
*/
|
|
39340
|
+
function getCumulativeWidths(columnWidths) {
|
|
39341
|
+
var e_1, _a;
|
|
39342
|
+
var cumulativeWidths = [];
|
|
39343
|
+
var totalWidth = 0;
|
|
39344
|
+
try {
|
|
39345
|
+
for (var columnWidths_1 = __values(columnWidths), columnWidths_1_1 = columnWidths_1.next(); !columnWidths_1_1.done; columnWidths_1_1 = columnWidths_1.next()) {
|
|
39346
|
+
var width = columnWidths_1_1.value;
|
|
39347
|
+
totalWidth += width;
|
|
39348
|
+
cumulativeWidths.push(totalWidth);
|
|
39349
|
+
}
|
|
39350
|
+
}
|
|
39351
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
39352
|
+
finally {
|
|
39353
|
+
try {
|
|
39354
|
+
if (columnWidths_1_1 && !columnWidths_1_1.done && (_a = columnWidths_1.return)) _a.call(columnWidths_1);
|
|
39355
|
+
}
|
|
39356
|
+
finally { if (e_1) throw e_1.error; }
|
|
39357
|
+
}
|
|
39358
|
+
return cumulativeWidths;
|
|
39359
|
+
}
|
|
39360
|
+
/***
|
|
39361
|
+
* 用于计算拖动 cell 时,cell 宽度变化的比例
|
|
39362
|
+
*/
|
|
39363
|
+
function getColumnWidthRatios(columnWidths) {
|
|
39364
|
+
var e_2, _a;
|
|
39365
|
+
var columnWidthsRatio = [];
|
|
39366
|
+
var totalWidth = columnWidths.reduce(function (a, b) { return a + b; }, 0);
|
|
39367
|
+
try {
|
|
39368
|
+
for (var columnWidths_2 = __values(columnWidths), columnWidths_2_1 = columnWidths_2.next(); !columnWidths_2_1.done; columnWidths_2_1 = columnWidths_2.next()) {
|
|
39369
|
+
var width = columnWidths_2_1.value;
|
|
39370
|
+
columnWidthsRatio.push(width / totalWidth);
|
|
39371
|
+
}
|
|
39372
|
+
}
|
|
39373
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
39374
|
+
finally {
|
|
39375
|
+
try {
|
|
39376
|
+
if (columnWidths_2_1 && !columnWidths_2_1.done && (_a = columnWidths_2.return)) _a.call(columnWidths_2);
|
|
39377
|
+
}
|
|
39378
|
+
finally { if (e_2) throw e_2.error; }
|
|
39379
|
+
}
|
|
39380
|
+
return columnWidthsRatio;
|
|
40736
39381
|
}
|
|
40737
39382
|
/**
|
|
40738
|
-
*
|
|
40739
|
-
*
|
|
40740
|
-
|
|
39383
|
+
* 监听 table 内部变化,如新增行、列,删除行列等操作,引起的高度变化。
|
|
39384
|
+
* ResizeObserver 需要即时释放,以免引起内存泄露
|
|
39385
|
+
*/
|
|
39386
|
+
var resizeObserver = null;
|
|
39387
|
+
function observerTableResize(editor, elm) {
|
|
39388
|
+
if (elm instanceof HTMLElement) {
|
|
39389
|
+
var table = elm.querySelector('table');
|
|
39390
|
+
if (table) {
|
|
39391
|
+
resizeObserver = new ResizeObserver(function (_a) {
|
|
39392
|
+
var _b = __read(_a, 1), contentRect = _b[0].contentRect;
|
|
39393
|
+
// 当非拖动引起的宽度变化,需要调整 columnWidths
|
|
39394
|
+
slate.Transforms.setNodes(editor, {
|
|
39395
|
+
scrollWidth: contentRect.width,
|
|
39396
|
+
height: contentRect.height,
|
|
39397
|
+
}, { mode: 'highest' });
|
|
39398
|
+
});
|
|
39399
|
+
resizeObserver.observe(table);
|
|
39400
|
+
}
|
|
39401
|
+
}
|
|
39402
|
+
}
|
|
39403
|
+
function unObserveTableResize() {
|
|
39404
|
+
if (resizeObserver) {
|
|
39405
|
+
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
|
|
39406
|
+
resizeObserver = null;
|
|
39407
|
+
}
|
|
39408
|
+
}
|
|
39409
|
+
// 是否为光标选区行为
|
|
39410
|
+
var isSelectionOperation = false;
|
|
39411
|
+
// 拖拽列宽相关信息
|
|
39412
|
+
var isMouseDownForResize = false;
|
|
39413
|
+
var clientXWhenMouseDown = 0;
|
|
39414
|
+
var cellWidthWhenMouseDown = 0;
|
|
39415
|
+
var editorWhenMouseDown = null;
|
|
39416
|
+
var $window = $__default["default"](window);
|
|
39417
|
+
$window.on('mousedown', onMouseDown);
|
|
39418
|
+
function onMouseDown(event) {
|
|
39419
|
+
var elem = event.target;
|
|
39420
|
+
// 判断是否为光标选区行为,对列宽变更行为进行过滤
|
|
39421
|
+
// console.log('onMouseDown', elem)
|
|
39422
|
+
if (elem.closest('[data-block-type="table-cell"]')) {
|
|
39423
|
+
isSelectionOperation = true;
|
|
39424
|
+
}
|
|
39425
|
+
else if (elem.tagName == 'DIV' && elem.closest('.column-resizer-item')) {
|
|
39426
|
+
if (editorWhenMouseDown == null)
|
|
39427
|
+
return;
|
|
39428
|
+
var _a = __read(slate.Editor.nodes(editorWhenMouseDown, {
|
|
39429
|
+
match: isOfType(editorWhenMouseDown, 'table'),
|
|
39430
|
+
}), 1), _b = __read(_a[0], 1), elemNode = _b[0];
|
|
39431
|
+
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;
|
|
39432
|
+
/**
|
|
39433
|
+
* table width 为 100% 模式时,因无法增加Table宽度,不触发 列宽变更行为
|
|
39434
|
+
* 如需变更,到底哪个列增宽度,哪个列减去宽度??
|
|
39435
|
+
*/
|
|
39436
|
+
if (tableWidth == '100%')
|
|
39437
|
+
return;
|
|
39438
|
+
// 记录必要信息
|
|
39439
|
+
isMouseDownForResize = true;
|
|
39440
|
+
var clientX = event.clientX;
|
|
39441
|
+
clientXWhenMouseDown = clientX;
|
|
39442
|
+
cellWidthWhenMouseDown = columnWidths[resizingIndex];
|
|
39443
|
+
document.body.style.cursor = 'col-resize';
|
|
39444
|
+
event.preventDefault();
|
|
39445
|
+
}
|
|
39446
|
+
$window.on('mousemove', onMouseMove);
|
|
39447
|
+
$window.on('mouseup', onMouseUp);
|
|
39448
|
+
}
|
|
39449
|
+
var onMouseMove = throttle__default["default"](function (event) {
|
|
39450
|
+
if (!isMouseDownForResize)
|
|
39451
|
+
return;
|
|
39452
|
+
if (editorWhenMouseDown == null)
|
|
39453
|
+
return;
|
|
39454
|
+
event.preventDefault();
|
|
39455
|
+
var clientX = event.clientX;
|
|
39456
|
+
var newWith = cellWidthWhenMouseDown + (clientX - clientXWhenMouseDown); // 计算新宽度
|
|
39457
|
+
newWith = Math.floor(newWith * 100) / 100; // 保留小数点后两位
|
|
39458
|
+
if (newWith < 30)
|
|
39459
|
+
newWith = 30; // 最小宽度
|
|
39460
|
+
var _a = __read(slate.Editor.nodes(editorWhenMouseDown, {
|
|
39461
|
+
match: isOfType(editorWhenMouseDown, 'table'),
|
|
39462
|
+
}), 1), _b = __read(_a[0], 1), elemNode = _b[0];
|
|
39463
|
+
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;
|
|
39464
|
+
/**
|
|
39465
|
+
* 判断拖动引起的宽度是否最大化了
|
|
39466
|
+
* 如果最大化了,则需要调整列的宽度
|
|
39467
|
+
*
|
|
39468
|
+
* 0.5 很微妙
|
|
39469
|
+
*/
|
|
39470
|
+
var cumulativeTotalWidth = columnWidths.reduce(function (a, b) { return a + b; }, 0);
|
|
39471
|
+
var remainWidth = cumulativeTotalWidth - columnWidths[resizingIndex];
|
|
39472
|
+
if (cumulativeTotalWidth > scrollWidth && remainWidth + newWith > scrollWidth) {
|
|
39473
|
+
newWith = scrollWidth - remainWidth + 0.5;
|
|
39474
|
+
}
|
|
39475
|
+
var adjustColumnWidths = __spreadArray([], __read(columnWidths)).map(function (width) { return Math.floor(width); });
|
|
39476
|
+
adjustColumnWidths[resizingIndex] = newWith;
|
|
39477
|
+
// 这是宽度
|
|
39478
|
+
slate.Transforms.setNodes(editorWhenMouseDown, { columnWidths: adjustColumnWidths }, {
|
|
39479
|
+
mode: 'highest',
|
|
39480
|
+
});
|
|
39481
|
+
}, 100);
|
|
39482
|
+
function onMouseUp(event) {
|
|
39483
|
+
isSelectionOperation = false;
|
|
39484
|
+
isMouseDownForResize = false;
|
|
39485
|
+
editorWhenMouseDown = null;
|
|
39486
|
+
document.body.style.cursor = '';
|
|
39487
|
+
// 解绑事件
|
|
39488
|
+
$window.off('mousemove', onMouseMove);
|
|
39489
|
+
$window.off('mouseup', onMouseUp);
|
|
39490
|
+
}
|
|
39491
|
+
/**
|
|
39492
|
+
* 鼠标移动时,判断在哪个 Cell border 上
|
|
39493
|
+
* Class 先 visible 后 highlight @跟随飞书
|
|
39494
|
+
* 避免光标选区功能收到干扰
|
|
40741
39495
|
*/
|
|
40742
|
-
function
|
|
40743
|
-
|
|
40744
|
-
|
|
40745
|
-
|
|
40746
|
-
|
|
40747
|
-
|
|
40748
|
-
|
|
40749
|
-
|
|
40750
|
-
|
|
39496
|
+
function handleCellBorderVisible(editor, elemNode, e) {
|
|
39497
|
+
if (editor.isDisabled())
|
|
39498
|
+
return;
|
|
39499
|
+
if (isSelectionOperation || isMouseDownForResize)
|
|
39500
|
+
return;
|
|
39501
|
+
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;
|
|
39502
|
+
/**
|
|
39503
|
+
* table width 为 100% 模式时,因无法增加Table宽度,不触发 列宽变更行为
|
|
39504
|
+
* 如需变更,到底哪个列增宽度,哪个列减去宽度??
|
|
39505
|
+
*/
|
|
39506
|
+
if (tableWidth == '100%')
|
|
39507
|
+
return;
|
|
39508
|
+
// Cell Border 宽度为 10px
|
|
39509
|
+
var clientX = e.clientX, target = e.target;
|
|
39510
|
+
// 当单元格合并的时候,鼠标在 cell 中间,则不显示 cell border
|
|
39511
|
+
if (target instanceof HTMLElement) {
|
|
39512
|
+
var rect = target.getBoundingClientRect();
|
|
39513
|
+
if (clientX > rect.x + 5 && clientX < rect.x + rect.width - 5) {
|
|
39514
|
+
if (isHoverCellBorder) {
|
|
39515
|
+
slate.Transforms.setNodes(editor, { isHoverCellBorder: false, resizingIndex: -1 }, { mode: 'highest' });
|
|
39516
|
+
}
|
|
39517
|
+
return;
|
|
39518
|
+
}
|
|
39519
|
+
}
|
|
39520
|
+
if (target instanceof HTMLElement) {
|
|
39521
|
+
var parent_1 = target.closest('.table');
|
|
39522
|
+
if (parent_1) {
|
|
39523
|
+
var clientX_1 = e.clientX;
|
|
39524
|
+
var rect = parent_1.getBoundingClientRect();
|
|
39525
|
+
var cumulativeWidths = getCumulativeWidths(columnWidths);
|
|
39526
|
+
// 鼠标移动时,计算当前鼠标位置,判断在哪个 Cell border 上
|
|
39527
|
+
for (var i = 0; i < cumulativeWidths.length; i++) {
|
|
39528
|
+
if (clientX_1 - rect.x >= cumulativeWidths[i] - 5 &&
|
|
39529
|
+
clientX_1 - rect.x < cumulativeWidths[i] + 5) {
|
|
39530
|
+
// 节流,防止多次引起Transforms.setNodes重绘
|
|
39531
|
+
if (resizingIndex == i)
|
|
39532
|
+
return;
|
|
39533
|
+
slate.Transforms.setNodes(editor, { isHoverCellBorder: true, resizingIndex: i }, { mode: 'highest' });
|
|
39534
|
+
return;
|
|
39535
|
+
}
|
|
39536
|
+
}
|
|
39537
|
+
}
|
|
39538
|
+
}
|
|
39539
|
+
// 鼠标移出时,重置
|
|
39540
|
+
if (isHoverCellBorder == true) {
|
|
39541
|
+
slate.Transforms.setNodes(editor, { isHoverCellBorder: false, resizingIndex: -1 }, {
|
|
39542
|
+
mode: 'highest',
|
|
39543
|
+
});
|
|
39544
|
+
}
|
|
39545
|
+
}
|
|
39546
|
+
/**
|
|
39547
|
+
* 设置 class highlight
|
|
39548
|
+
* 将 render-cell.tsx 拖动功能迁移至 div.column-resize
|
|
39549
|
+
*/
|
|
39550
|
+
function handleCellBorderHighlight(editor, e) {
|
|
39551
|
+
if (e.type === 'mouseenter') {
|
|
39552
|
+
slate.Transforms.setNodes(editor, { isResizing: true }, { mode: 'highest' });
|
|
39553
|
+
}
|
|
39554
|
+
else {
|
|
39555
|
+
slate.Transforms.setNodes(editor, { isResizing: false }, { mode: 'highest' });
|
|
39556
|
+
}
|
|
39557
|
+
}
|
|
39558
|
+
function handleCellBorderMouseDown(editor, elemNode) {
|
|
39559
|
+
if (isMouseDownForResize)
|
|
39560
|
+
return; // 此时正在修改列宽
|
|
39561
|
+
editorWhenMouseDown = editor;
|
|
40751
39562
|
}
|
|
40752
39563
|
|
|
40753
39564
|
/**
|
|
@@ -40785,11 +39596,13 @@
|
|
|
40785
39596
|
// 是否可编辑
|
|
40786
39597
|
var editable = getContentEditable(editor, elemNode);
|
|
40787
39598
|
// 宽度
|
|
40788
|
-
var _a = elemNode.width,
|
|
40789
|
-
//
|
|
39599
|
+
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;
|
|
39600
|
+
// 光标是否选中
|
|
40790
39601
|
var selected = core.DomEditor.isNodeSelected(editor, elemNode);
|
|
40791
|
-
//
|
|
40792
|
-
var
|
|
39602
|
+
// 光标是否有选区
|
|
39603
|
+
var _e = __read(TableCursor.selection(editor), 1), isSelecting = _e[0];
|
|
39604
|
+
// 列宽之间比值
|
|
39605
|
+
var columnWidthRatios = getColumnWidthRatios(columnWidths);
|
|
40793
39606
|
var vnode = (snabbdom.jsx("div", { className: "table-container", "data-selected": selected, on: {
|
|
40794
39607
|
mousedown: function (e) {
|
|
40795
39608
|
// @ts-ignore 阻止光标定位到 table 后面
|
|
@@ -40797,6 +39610,10 @@
|
|
|
40797
39610
|
e.preventDefault();
|
|
40798
39611
|
if (editor.isDisabled())
|
|
40799
39612
|
return;
|
|
39613
|
+
// @ts-ignore 如果用户行为是获取焦点输入文本时,需释放选区
|
|
39614
|
+
if (e.target.closest('[data-block-type="table-cell"]')) {
|
|
39615
|
+
TableCursor.unselect(editor);
|
|
39616
|
+
}
|
|
40800
39617
|
// 是否需要定位到 table 内部
|
|
40801
39618
|
var tablePath = core.DomEditor.findPath(editor, elemNode);
|
|
40802
39619
|
var tableStart = slate.Editor.start(editor, tablePath);
|
|
@@ -40811,173 +39628,130 @@
|
|
|
40811
39628
|
editor.select(tableStart); // 选中 table 内部
|
|
40812
39629
|
},
|
|
40813
39630
|
} },
|
|
40814
|
-
snabbdom.jsx("table", { width:
|
|
40815
|
-
|
|
40816
|
-
|
|
39631
|
+
snabbdom.jsx("table", { width: tableWidth, contentEditable: editable,
|
|
39632
|
+
/**
|
|
39633
|
+
* 1. 当表格处于选区状态,屏蔽 Chrome 自带的样式
|
|
39634
|
+
* 2. table 宽度为 auto 时,宽度为 列宽之和
|
|
39635
|
+
* 3. 鼠标移动到 单元格 边缘,设置 visible className
|
|
39636
|
+
*/
|
|
39637
|
+
className: 'table ' + (isSelecting ? 'table-selection-none' : ''), style: {
|
|
39638
|
+
width: tableWidth == '100%' ? '' : columnWidths.reduce(function (a, b) { return a + b; }, 0) + 'px',
|
|
39639
|
+
}, on: {
|
|
39640
|
+
mousemove: debounce__default["default"](function (e) { return handleCellBorderVisible(editor, elemNode, e); }, 25),
|
|
39641
|
+
} },
|
|
39642
|
+
snabbdom.jsx("colgroup", { contentEditable: false },
|
|
39643
|
+
/**
|
|
39644
|
+
* 剔除 firstRowCells,因单元格合并 表头 th,会计算错误。
|
|
39645
|
+
* 使用 columnWidth 数组长度代表列数
|
|
39646
|
+
* 拖动行为及变量设置均参考 飞书
|
|
39647
|
+
*/
|
|
39648
|
+
columnWidths.map(function (width) {
|
|
40817
39649
|
return snabbdom.jsx("col", { width: width });
|
|
40818
39650
|
})),
|
|
40819
|
-
snabbdom.jsx("tbody", null, children))
|
|
40820
|
-
|
|
40821
|
-
|
|
40822
|
-
|
|
40823
|
-
|
|
40824
|
-
|
|
40825
|
-
|
|
40826
|
-
|
|
40827
|
-
|
|
40828
|
-
|
|
40829
|
-
|
|
40830
|
-
|
|
40831
|
-
|
|
40832
|
-
|
|
40833
|
-
|
|
40834
|
-
|
|
40835
|
-
|
|
40836
|
-
|
|
40837
|
-
|
|
40838
|
-
|
|
40839
|
-
|
|
40840
|
-
|
|
40841
|
-
|
|
40842
|
-
|
|
40843
|
-
|
|
40844
|
-
|
|
40845
|
-
|
|
40846
|
-
|
|
40847
|
-
|
|
40848
|
-
|
|
40849
|
-
|
|
40850
|
-
|
|
40851
|
-
|
|
40852
|
-
|
|
40853
|
-
|
|
40854
|
-
|
|
40855
|
-
|
|
40856
|
-
|
|
40857
|
-
|
|
40858
|
-
|
|
40859
|
-
$__default["default"].fn.find = $.find;
|
|
39651
|
+
snabbdom.jsx("tbody", null, children)),
|
|
39652
|
+
snabbdom.jsx("div", { className: "column-resizer", contenteditable: "false" }, columnWidths.map(function (width, index) {
|
|
39653
|
+
var minWidth = width;
|
|
39654
|
+
/**
|
|
39655
|
+
* table width 为 100% 模式时
|
|
39656
|
+
* columnWidths 表示的是比例
|
|
39657
|
+
* 1. 需要计算出真实的宽度
|
|
39658
|
+
*/
|
|
39659
|
+
if (tableWidth == '100%') {
|
|
39660
|
+
minWidth = columnWidthRatios[index] * scrollWidth;
|
|
39661
|
+
}
|
|
39662
|
+
return (snabbdom.jsx("div", { className: "column-resizer-item", style: { minWidth: minWidth + "px" } },
|
|
39663
|
+
snabbdom.jsx("div", { className: 'resizer-line-hotzone ' +
|
|
39664
|
+
(isHoverCellBorder && index == resizingIndex ? 'visible ' : '') +
|
|
39665
|
+
(isResizing && index == resizingIndex ? 'highlight' : ''), style: { height: height + 'px' }, on: {
|
|
39666
|
+
mouseenter: function (e) { return handleCellBorderHighlight(editor, e); },
|
|
39667
|
+
mouseleave: function (e) { return handleCellBorderHighlight(editor, e); },
|
|
39668
|
+
mousedown: function (e) { return handleCellBorderMouseDown(editor); },
|
|
39669
|
+
} },
|
|
39670
|
+
snabbdom.jsx("div", { className: "resizer-line" }))));
|
|
39671
|
+
}))));
|
|
39672
|
+
/**
|
|
39673
|
+
* 移出直接返回 vnode
|
|
39674
|
+
* 添加 ObserverResize 监听行为
|
|
39675
|
+
* 监听 table 内部变化,更新 table resize-bar 高度
|
|
39676
|
+
*/
|
|
39677
|
+
var containerVnode = snabbdom.h('div', {
|
|
39678
|
+
hook: {
|
|
39679
|
+
insert: function (_a) {
|
|
39680
|
+
var elm = _a.elm;
|
|
39681
|
+
return observerTableResize(editor, elm);
|
|
39682
|
+
},
|
|
39683
|
+
destroy: function () {
|
|
39684
|
+
unObserveTableResize();
|
|
39685
|
+
},
|
|
39686
|
+
},
|
|
39687
|
+
}, vnode);
|
|
39688
|
+
return containerVnode;
|
|
39689
|
+
}
|
|
39690
|
+
|
|
40860
39691
|
/**
|
|
40861
|
-
*
|
|
40862
|
-
* @
|
|
39692
|
+
* @description render row
|
|
39693
|
+
* @author wangfupeng
|
|
40863
39694
|
*/
|
|
40864
|
-
function
|
|
40865
|
-
|
|
40866
|
-
|
|
40867
|
-
|
|
39695
|
+
function renderTableRow(elemNode, children, editor) {
|
|
39696
|
+
var vnode = snabbdom.jsx("tr", null, children);
|
|
39697
|
+
return vnode;
|
|
39698
|
+
}
|
|
39699
|
+
|
|
39700
|
+
/**
|
|
39701
|
+
* @description table menu helpers
|
|
39702
|
+
* @author wangfupeng
|
|
39703
|
+
*/
|
|
39704
|
+
/**
|
|
39705
|
+
* 获取第一行所有 cells
|
|
39706
|
+
* @param tableNode table node
|
|
39707
|
+
*/
|
|
39708
|
+
function getFirstRowCells(tableNode) {
|
|
39709
|
+
var rows = tableNode.children || []; // 所有行
|
|
39710
|
+
if (rows.length === 0)
|
|
39711
|
+
return [];
|
|
39712
|
+
var firstRow = rows[0] || {}; // 第一行
|
|
39713
|
+
var cells = firstRow.children || []; // 第一行所有 cell
|
|
39714
|
+
return cells;
|
|
40868
39715
|
}
|
|
40869
39716
|
/**
|
|
40870
|
-
*
|
|
40871
|
-
* @param
|
|
40872
|
-
* @param styleKey style key
|
|
39717
|
+
* 表格是否带有表头?
|
|
39718
|
+
* @param tableNode table node
|
|
40873
39719
|
*/
|
|
40874
|
-
function
|
|
40875
|
-
var
|
|
40876
|
-
|
|
40877
|
-
|
|
40878
|
-
|
|
40879
|
-
|
|
40880
|
-
|
|
40881
|
-
|
|
40882
|
-
|
|
40883
|
-
|
|
40884
|
-
|
|
40885
|
-
|
|
40886
|
-
|
|
40887
|
-
|
|
40888
|
-
|
|
39720
|
+
function isTableWithHeader(tableNode) {
|
|
39721
|
+
var firstRowCells = getFirstRowCells(tableNode);
|
|
39722
|
+
return firstRowCells.every(function (cell) { return !!cell.isHeader; });
|
|
39723
|
+
}
|
|
39724
|
+
/**
|
|
39725
|
+
* 单元格是否在第一行
|
|
39726
|
+
* @param editor editor
|
|
39727
|
+
* @param cellNode cell node
|
|
39728
|
+
*/
|
|
39729
|
+
function isCellInFirstRow(editor, cellNode) {
|
|
39730
|
+
var rowNode = core.DomEditor.getParentNode(editor, cellNode);
|
|
39731
|
+
if (rowNode == null)
|
|
39732
|
+
return false;
|
|
39733
|
+
var tableNode = core.DomEditor.getParentNode(editor, rowNode);
|
|
39734
|
+
if (tableNode == null)
|
|
39735
|
+
return false;
|
|
39736
|
+
var firstRowCells = getFirstRowCells(tableNode);
|
|
39737
|
+
return firstRowCells.some(function (c) { return c === cellNode; });
|
|
40889
39738
|
}
|
|
40890
39739
|
|
|
40891
39740
|
/**
|
|
40892
39741
|
* @description render cell
|
|
40893
39742
|
* @author wangfupeng
|
|
40894
39743
|
*/
|
|
40895
|
-
// 拖拽列宽相关信息
|
|
40896
|
-
var isMouseDownForResize = false;
|
|
40897
|
-
var clientXWhenMouseDown = 0;
|
|
40898
|
-
var cellWidthWhenMouseDown = 0;
|
|
40899
|
-
var cellPathWhenMouseDown = null;
|
|
40900
|
-
var editorWhenMouseDown = null;
|
|
40901
|
-
var $body = $__default["default"]('body');
|
|
40902
|
-
function onMouseDown(event) {
|
|
40903
|
-
var elem = event.target;
|
|
40904
|
-
if (elem.tagName !== 'TH' && elem.tagName !== 'TD')
|
|
40905
|
-
return;
|
|
40906
|
-
if (elem.style.cursor !== 'col-resize')
|
|
40907
|
-
return;
|
|
40908
|
-
elem.style.cursor = 'auto';
|
|
40909
|
-
event.preventDefault();
|
|
40910
|
-
// 记录必要信息
|
|
40911
|
-
isMouseDownForResize = true;
|
|
40912
|
-
var clientX = event.clientX;
|
|
40913
|
-
clientXWhenMouseDown = clientX;
|
|
40914
|
-
var width = elem.getBoundingClientRect().width;
|
|
40915
|
-
cellWidthWhenMouseDown = width;
|
|
40916
|
-
// 绑定事件
|
|
40917
|
-
$body.on('mousemove', onMouseMove);
|
|
40918
|
-
$body.on('mouseup', onMouseUp);
|
|
40919
|
-
}
|
|
40920
|
-
$body.on('mousedown', onMouseDown); // 绑定事件
|
|
40921
|
-
function onMouseUp(event) {
|
|
40922
|
-
isMouseDownForResize = false;
|
|
40923
|
-
editorWhenMouseDown = null;
|
|
40924
|
-
cellPathWhenMouseDown = null;
|
|
40925
|
-
// 解绑事件
|
|
40926
|
-
$body.off('mousemove', onMouseMove);
|
|
40927
|
-
$body.off('mouseup', onMouseUp);
|
|
40928
|
-
}
|
|
40929
|
-
var onMouseMove = throttle__default["default"](function (event) {
|
|
40930
|
-
if (!isMouseDownForResize)
|
|
40931
|
-
return;
|
|
40932
|
-
if (editorWhenMouseDown == null || cellPathWhenMouseDown == null)
|
|
40933
|
-
return;
|
|
40934
|
-
event.preventDefault();
|
|
40935
|
-
var clientX = event.clientX;
|
|
40936
|
-
var newWith = cellWidthWhenMouseDown + (clientX - clientXWhenMouseDown); // 计算新宽度
|
|
40937
|
-
newWith = Math.floor(newWith * 100) / 100; // 保留小数点后两位
|
|
40938
|
-
if (newWith < 30)
|
|
40939
|
-
newWith = 30; // 最小宽度
|
|
40940
|
-
// 这是宽度
|
|
40941
|
-
slate.Transforms.setNodes(editorWhenMouseDown, { width: newWith.toString() }, {
|
|
40942
|
-
at: cellPathWhenMouseDown,
|
|
40943
|
-
});
|
|
40944
|
-
}, 100);
|
|
40945
39744
|
function renderTableCell(cellNode, children, editor) {
|
|
40946
39745
|
var isFirstRow = isCellInFirstRow(editor, cellNode);
|
|
40947
|
-
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;
|
|
39746
|
+
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;
|
|
39747
|
+
var selected = TableCursor.isSelected(editor, cellNode);
|
|
40948
39748
|
// ------------------ 不是第一行,直接渲染 <td> ------------------
|
|
40949
39749
|
if (!isFirstRow) {
|
|
40950
|
-
return (snabbdom.jsx("td", { colSpan: colSpan, rowSpan: rowSpan }, children));
|
|
39750
|
+
return (snabbdom.jsx("td", { colSpan: colSpan, rowSpan: rowSpan, "data-block-type": "table-cell", className: selected ? 'w-e-selected' : '', style: { display: hidden ? 'none' : '' } }, children));
|
|
40951
39751
|
}
|
|
40952
39752
|
// ------------------ 是第一行:1. 判断 th ;2. 拖拽列宽 ------------------
|
|
40953
39753
|
var Tag = isHeader ? 'th' : 'td';
|
|
40954
|
-
var vnode = (snabbdom.jsx(Tag, { colSpan: colSpan, rowSpan: rowSpan, style: {
|
|
40955
|
-
mousemove: throttle__default["default"](function (event) {
|
|
40956
|
-
var elem = this.elm;
|
|
40957
|
-
if (elem == null)
|
|
40958
|
-
return;
|
|
40959
|
-
var _a = elem.getBoundingClientRect(), left = _a.left, width = _a.width, top = _a.top, height = _a.height;
|
|
40960
|
-
var clientX = event.clientX, clientY = event.clientY;
|
|
40961
|
-
if (isMouseDownForResize)
|
|
40962
|
-
return; // 此时正在修改列宽
|
|
40963
|
-
// 非 mousedown 状态,计算 cursor 样式
|
|
40964
|
-
var matchX = clientX > left + width - 5 && clientX < left + width; // X 轴,是否接近 cell 右侧?
|
|
40965
|
-
var matchY = clientY > top && clientY < top + height; // Y 轴,是否在 cell 之内
|
|
40966
|
-
// X Y 轴都接近,则修改鼠标样式
|
|
40967
|
-
if (matchX && matchY) {
|
|
40968
|
-
elem.style.cursor = 'col-resize';
|
|
40969
|
-
editorWhenMouseDown = editor;
|
|
40970
|
-
cellPathWhenMouseDown = core.DomEditor.findPath(editor, cellNode);
|
|
40971
|
-
}
|
|
40972
|
-
else {
|
|
40973
|
-
if (!isMouseDownForResize) {
|
|
40974
|
-
elem.style.cursor = 'auto';
|
|
40975
|
-
editorWhenMouseDown = null;
|
|
40976
|
-
cellPathWhenMouseDown = null;
|
|
40977
|
-
}
|
|
40978
|
-
}
|
|
40979
|
-
}, 100),
|
|
40980
|
-
} }, children));
|
|
39754
|
+
var vnode = (snabbdom.jsx(Tag, { colSpan: colSpan, rowSpan: rowSpan, "data-block-type": "table-cell", className: selected ? 'w-e-selected' : '', style: { display: hidden ? 'none' : '' } }, children));
|
|
40981
39755
|
return vnode;
|
|
40982
39756
|
}
|
|
40983
39757
|
|
|
@@ -41004,15 +39778,16 @@
|
|
|
41004
39778
|
*/
|
|
41005
39779
|
function tableToHtml(elemNode, childrenHtml) {
|
|
41006
39780
|
var _a = elemNode.width, width = _a === void 0 ? 'auto' : _a;
|
|
41007
|
-
return "<table style=\"width: " + width + ";\"><tbody>" + childrenHtml + "</tbody></table>";
|
|
39781
|
+
return "<table style=\"width: " + width + ";table-layout: fixed;\"><tbody>" + childrenHtml + "</tbody></table>";
|
|
41008
39782
|
}
|
|
41009
39783
|
function tableRowToHtml(elem, childrenHtml) {
|
|
41010
39784
|
return "<tr>" + childrenHtml + "</tr>";
|
|
41011
39785
|
}
|
|
41012
39786
|
function tableCellToHtml(cellNode, childrenHtml) {
|
|
41013
|
-
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;
|
|
39787
|
+
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;
|
|
41014
39788
|
var tag = isHeader ? 'th' : 'td';
|
|
41015
|
-
|
|
39789
|
+
var style = hidden ? 'display:none' : '';
|
|
39790
|
+
return "<" + tag + " colSpan=\"" + colSpan + "\" rowSpan=\"" + rowSpan + "\" width=\"" + width + "\" style=\"" + style + "\">" + childrenHtml + "</" + tag + ">";
|
|
41016
39791
|
}
|
|
41017
39792
|
var tableToHtmlConf = {
|
|
41018
39793
|
type: 'table',
|
|
@@ -41101,6 +39876,7 @@
|
|
|
41101
39876
|
parseElemHtml: parseRowHtml,
|
|
41102
39877
|
};
|
|
41103
39878
|
function parseTableHtml(elem, children, editor) {
|
|
39879
|
+
var _a;
|
|
41104
39880
|
var $elem = $__default["default"](elem);
|
|
41105
39881
|
// 计算宽度
|
|
41106
39882
|
var width = 'auto';
|
|
@@ -41108,12 +39884,17 @@
|
|
|
41108
39884
|
width = '100%';
|
|
41109
39885
|
if ($elem.attr('width') === '100%')
|
|
41110
39886
|
width = '100%'; // 兼容 v4 格式
|
|
41111
|
-
|
|
39887
|
+
var tableELement = {
|
|
41112
39888
|
type: 'table',
|
|
41113
39889
|
width: width,
|
|
41114
39890
|
// @ts-ignore
|
|
41115
39891
|
children: children.filter(function (child) { return core.DomEditor.getNodeType(child) === 'table-row'; }),
|
|
41116
39892
|
};
|
|
39893
|
+
var cellLength = (_a = $elem.find('tr')[0]) === null || _a === void 0 ? void 0 : _a.children.length;
|
|
39894
|
+
if (cellLength > 0) {
|
|
39895
|
+
tableELement.columnWidths = Array(cellLength).fill(180);
|
|
39896
|
+
}
|
|
39897
|
+
return tableELement;
|
|
41117
39898
|
}
|
|
41118
39899
|
var parseTableHtmlConf = {
|
|
41119
39900
|
selector: 'table:not([data-w-e-type])',
|
|
@@ -41144,7 +39925,11 @@
|
|
|
41144
39925
|
// 表头
|
|
41145
39926
|
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>';
|
|
41146
39927
|
// 宽度
|
|
41147
|
-
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>';
|
|
39928
|
+
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>';
|
|
39929
|
+
// 合并单元格
|
|
39930
|
+
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>';
|
|
39931
|
+
// 拆分单元格
|
|
39932
|
+
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>';
|
|
41148
39933
|
|
|
41149
39934
|
/**
|
|
41150
39935
|
* @description insert table menu
|
|
@@ -41153,6 +39938,7 @@
|
|
|
41153
39938
|
function genTableNode(rowNum, colNum) {
|
|
41154
39939
|
// 拼接 rows
|
|
41155
39940
|
var rows = [];
|
|
39941
|
+
var columnWidths = Array(colNum).fill(60);
|
|
41156
39942
|
for (var i = 0; i < rowNum; i++) {
|
|
41157
39943
|
// 拼接 cells
|
|
41158
39944
|
var cells = [];
|
|
@@ -41176,6 +39962,7 @@
|
|
|
41176
39962
|
type: 'table',
|
|
41177
39963
|
width: 'auto',
|
|
41178
39964
|
children: rows,
|
|
39965
|
+
columnWidths: columnWidths,
|
|
41179
39966
|
};
|
|
41180
39967
|
}
|
|
41181
39968
|
var InsertTable = /** @class */ (function () {
|
|
@@ -41297,6 +40084,12 @@
|
|
|
41297
40084
|
if (core.DomEditor.isSelectedEmptyParagraph(editor)) {
|
|
41298
40085
|
slate.Transforms.removeNodes(editor, { mode: 'highest' });
|
|
41299
40086
|
}
|
|
40087
|
+
if (editor.children.length === 0) {
|
|
40088
|
+
// table 作为第一个 children 时会导致无法正常删除
|
|
40089
|
+
// 在当前位置插入空行,当前元素下移
|
|
40090
|
+
var newElem = { type: 'paragraph', children: [{ text: '' }] };
|
|
40091
|
+
slate.Transforms.insertNodes(editor, newElem, { mode: 'highest' });
|
|
40092
|
+
}
|
|
41300
40093
|
// 插入表格
|
|
41301
40094
|
var tableNode = genTableNode(rowNum, colNum);
|
|
41302
40095
|
slate.Transforms.insertNodes(editor, tableNode, { mode: 'highest' });
|
|
@@ -41385,19 +40178,56 @@
|
|
|
41385
40178
|
var cellsLength = (rowNode === null || rowNode === void 0 ? void 0 : rowNode.children.length) || 0;
|
|
41386
40179
|
if (cellsLength === 0)
|
|
41387
40180
|
return;
|
|
41388
|
-
|
|
41389
|
-
|
|
41390
|
-
|
|
41391
|
-
|
|
41392
|
-
|
|
41393
|
-
|
|
41394
|
-
|
|
41395
|
-
|
|
40181
|
+
var matrix = filledMatrix(editor);
|
|
40182
|
+
// 向下插入行为,先找到
|
|
40183
|
+
// 当前选区所在的 tr 索引
|
|
40184
|
+
var trIndex = 0;
|
|
40185
|
+
outer: for (var x = 0; x < matrix.length; x++) {
|
|
40186
|
+
for (var y = 0; y < matrix[x].length; y++) {
|
|
40187
|
+
var _c = __read(matrix[x][y], 1), _d = __read(_c[0], 2), path = _d[1];
|
|
40188
|
+
if (!slate.Path.equals(cellPath, path)) {
|
|
40189
|
+
continue;
|
|
40190
|
+
}
|
|
40191
|
+
trIndex = x;
|
|
40192
|
+
break outer;
|
|
40193
|
+
}
|
|
41396
40194
|
}
|
|
41397
|
-
|
|
41398
|
-
|
|
41399
|
-
|
|
41400
|
-
|
|
40195
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
40196
|
+
// 向下添加 tr 索引
|
|
40197
|
+
var destIndex = trIndex + 1;
|
|
40198
|
+
var isWithinBounds = destIndex >= 0 && destIndex < matrix.length;
|
|
40199
|
+
var exitMerge = [];
|
|
40200
|
+
for (var y = 0; isWithinBounds && y < matrix[trIndex].length; y++) {
|
|
40201
|
+
var _a = __read(matrix[trIndex][y], 2), _b = _a[1], ttb = _b.ttb, btt = _b.btt;
|
|
40202
|
+
// 向上找到 1 元素为止
|
|
40203
|
+
if (ttb > 1 || btt > 1) {
|
|
40204
|
+
if (btt == 1)
|
|
40205
|
+
continue;
|
|
40206
|
+
var _c = __read(matrix[trIndex - (ttb - 1)][y], 1), _d = __read(_c[0], 2), element = _d[0], path = _d[1];
|
|
40207
|
+
var rowSpan = element.rowSpan || 1;
|
|
40208
|
+
exitMerge.push(y);
|
|
40209
|
+
if (!element.hidden) {
|
|
40210
|
+
slate.Transforms.setNodes(editor, {
|
|
40211
|
+
rowSpan: rowSpan + 1,
|
|
40212
|
+
}, { at: path });
|
|
40213
|
+
}
|
|
40214
|
+
}
|
|
40215
|
+
}
|
|
40216
|
+
// 拼接新的 row
|
|
40217
|
+
var newRow = { type: 'table-row', children: [] };
|
|
40218
|
+
for (var i = 0; i < cellsLength; i++) {
|
|
40219
|
+
var cell = {
|
|
40220
|
+
type: 'table-cell',
|
|
40221
|
+
hidden: exitMerge.includes(i),
|
|
40222
|
+
children: [{ text: '' }],
|
|
40223
|
+
};
|
|
40224
|
+
newRow.children.push(cell);
|
|
40225
|
+
}
|
|
40226
|
+
// 插入 row
|
|
40227
|
+
var rowPath = slate.Path.parent(cellPath); // 获取 tr 的 path
|
|
40228
|
+
var newRowPath = slate.Path.next(rowPath);
|
|
40229
|
+
slate.Transforms.insertNodes(editor, newRow, { at: newRowPath });
|
|
40230
|
+
});
|
|
41401
40231
|
};
|
|
41402
40232
|
return InsertRow;
|
|
41403
40233
|
}());
|
|
@@ -41449,7 +40279,67 @@
|
|
|
41449
40279
|
return;
|
|
41450
40280
|
}
|
|
41451
40281
|
// row > 1 行,则删掉这一行
|
|
41452
|
-
slate.
|
|
40282
|
+
var _c = __read(slate.Editor.nodes(editor, {
|
|
40283
|
+
match: function (n) { return core.DomEditor.checkNodeType(n, 'table-cell'); },
|
|
40284
|
+
universal: true,
|
|
40285
|
+
}), 1), cellEntry = _c[0];
|
|
40286
|
+
var _d = __read(cellEntry, 2), cellPath = _d[1];
|
|
40287
|
+
var matrix = filledMatrix(editor);
|
|
40288
|
+
var trIndex = 0;
|
|
40289
|
+
outer: for (var x = 0; x < matrix.length; x++) {
|
|
40290
|
+
for (var y = 0; y < matrix[x].length; y++) {
|
|
40291
|
+
var _e = __read(matrix[x][y], 1), _f = __read(_e[0], 2), path = _f[1];
|
|
40292
|
+
if (!slate.Path.equals(cellPath, path)) {
|
|
40293
|
+
continue;
|
|
40294
|
+
}
|
|
40295
|
+
trIndex = x;
|
|
40296
|
+
break outer;
|
|
40297
|
+
}
|
|
40298
|
+
}
|
|
40299
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
40300
|
+
var e_1, _a;
|
|
40301
|
+
for (var y = 0; y < matrix[trIndex].length; y++) {
|
|
40302
|
+
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;
|
|
40303
|
+
// 寻找跨行行为
|
|
40304
|
+
if (ttb > 1 || btt > 1) {
|
|
40305
|
+
// 找到显示中 rowSpan 节点
|
|
40306
|
+
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];
|
|
40307
|
+
// 如果当前选中节点为隐藏节点,则向上寻找处理 rowSpan 逻辑
|
|
40308
|
+
if (hidden) {
|
|
40309
|
+
slate.Transforms.setNodes(editor, {
|
|
40310
|
+
rowSpan: Math.max(rowSpan - 1, 1),
|
|
40311
|
+
colSpan: colSpan,
|
|
40312
|
+
}, { at: path });
|
|
40313
|
+
}
|
|
40314
|
+
else {
|
|
40315
|
+
var _k = __read(matrix[trIndex + 1][y], 1), _l = __read(_k[0], 2), belowPath = _l[1];
|
|
40316
|
+
slate.Transforms.setNodes(editor, {
|
|
40317
|
+
rowSpan: rowSpan - 1,
|
|
40318
|
+
colSpan: colSpan,
|
|
40319
|
+
hidden: false,
|
|
40320
|
+
}, { at: belowPath });
|
|
40321
|
+
try {
|
|
40322
|
+
// 移动单元格 文本、图片等元素
|
|
40323
|
+
for (var _m = (e_1 = void 0, __values(slate.Node.children(editor, path, { reverse: true }))), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
40324
|
+
var _p = __read(_o.value, 2), childPath = _p[1];
|
|
40325
|
+
slate.Transforms.moveNodes(editor, {
|
|
40326
|
+
to: __spreadArray(__spreadArray([], __read(belowPath)), [0]),
|
|
40327
|
+
at: childPath,
|
|
40328
|
+
});
|
|
40329
|
+
}
|
|
40330
|
+
}
|
|
40331
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
40332
|
+
finally {
|
|
40333
|
+
try {
|
|
40334
|
+
if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
|
|
40335
|
+
}
|
|
40336
|
+
finally { if (e_1) throw e_1.error; }
|
|
40337
|
+
}
|
|
40338
|
+
}
|
|
40339
|
+
}
|
|
40340
|
+
}
|
|
40341
|
+
slate.Transforms.removeNodes(editor, { at: rowPath });
|
|
40342
|
+
});
|
|
41453
40343
|
};
|
|
41454
40344
|
return DeleteRow;
|
|
41455
40345
|
}());
|
|
@@ -41499,27 +40389,62 @@
|
|
|
41499
40389
|
var tableNode = core.DomEditor.getParentNode(editor, rowNode);
|
|
41500
40390
|
if (tableNode == null)
|
|
41501
40391
|
return;
|
|
41502
|
-
|
|
41503
|
-
var
|
|
41504
|
-
|
|
41505
|
-
|
|
41506
|
-
|
|
41507
|
-
|
|
41508
|
-
|
|
41509
|
-
|
|
41510
|
-
|
|
41511
|
-
|
|
41512
|
-
|
|
41513
|
-
|
|
41514
|
-
|
|
41515
|
-
|
|
41516
|
-
|
|
41517
|
-
|
|
41518
|
-
|
|
40392
|
+
var matrix = filledMatrix(editor);
|
|
40393
|
+
var tdIndex = 0;
|
|
40394
|
+
out: for (var x = 0; x < matrix.length; x++) {
|
|
40395
|
+
for (var y = 0; y < matrix[x].length; y++) {
|
|
40396
|
+
var _c = __read(matrix[x][y], 1), _d = __read(_c[0], 2), path = _d[1];
|
|
40397
|
+
if (slate.Path.equals(selectedCellPath, path)) {
|
|
40398
|
+
tdIndex = y;
|
|
40399
|
+
break out;
|
|
40400
|
+
}
|
|
40401
|
+
}
|
|
40402
|
+
}
|
|
40403
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
40404
|
+
var exitMerge = [];
|
|
40405
|
+
for (var x = 0; x < matrix.length; x++) {
|
|
40406
|
+
var _a = __read(matrix[x][tdIndex], 2), _b = _a[1], ltr = _b.ltr, rtl = _b.rtl;
|
|
40407
|
+
// 向左找到 1 元素为止
|
|
40408
|
+
if (ltr > 1 || rtl > 1) {
|
|
40409
|
+
if (rtl == 1)
|
|
40410
|
+
continue;
|
|
40411
|
+
var _c = __read(matrix[x][tdIndex - (rtl - 1)], 1), _d = __read(_c[0], 2), element = _d[0], path = _d[1];
|
|
40412
|
+
var colSpan = element.colSpan || 1;
|
|
40413
|
+
exitMerge.push(x);
|
|
40414
|
+
if (!element.hidden) {
|
|
40415
|
+
slate.Transforms.setNodes(editor, {
|
|
40416
|
+
colSpan: colSpan + 1,
|
|
40417
|
+
}, { at: path });
|
|
41519
40418
|
}
|
|
41520
|
-
slate.Transforms.insertNodes(editor, newCell, { at: path });
|
|
41521
40419
|
}
|
|
41522
|
-
}
|
|
40420
|
+
}
|
|
40421
|
+
// 遍历所有 rows ,挨个添加 cell
|
|
40422
|
+
for (var x = 0; x < matrix.length; x++) {
|
|
40423
|
+
var newCell = {
|
|
40424
|
+
type: 'table-cell',
|
|
40425
|
+
hidden: exitMerge.includes(x),
|
|
40426
|
+
children: [{ text: '' }],
|
|
40427
|
+
};
|
|
40428
|
+
if (x === 0 && isTableWithHeader(tableNode)) {
|
|
40429
|
+
newCell.isHeader = true;
|
|
40430
|
+
}
|
|
40431
|
+
var _e = __read(matrix[x][tdIndex], 1), _f = __read(_e[0], 2), insertPath = _f[1];
|
|
40432
|
+
slate.Transforms.insertNodes(editor, newCell, { at: insertPath });
|
|
40433
|
+
}
|
|
40434
|
+
// 需要调整 columnWidths
|
|
40435
|
+
var _g = __read(slate.Editor.nodes(editor, {
|
|
40436
|
+
match: function (n) { return core.DomEditor.checkNodeType(n, 'table'); },
|
|
40437
|
+
universal: true,
|
|
40438
|
+
}), 1), tableEntry = _g[0];
|
|
40439
|
+
if (tableEntry) {
|
|
40440
|
+
var _h = __read(tableEntry, 2), elemNode = _h[0], tablePath = _h[1];
|
|
40441
|
+
var _j = elemNode.columnWidths, columnWidths = _j === void 0 ? [] : _j;
|
|
40442
|
+
var adjustColumnWidths = __spreadArray([], __read(columnWidths));
|
|
40443
|
+
adjustColumnWidths.splice(tdIndex, 0, 60);
|
|
40444
|
+
slate.Transforms.setNodes(editor, { columnWidths: adjustColumnWidths }, {
|
|
40445
|
+
at: tablePath,
|
|
40446
|
+
});
|
|
40447
|
+
}
|
|
41523
40448
|
});
|
|
41524
40449
|
};
|
|
41525
40450
|
return InsertCol;
|
|
@@ -41575,23 +40500,76 @@
|
|
|
41575
40500
|
var tableNode = core.DomEditor.getParentNode(editor, rowNode);
|
|
41576
40501
|
if (tableNode == null)
|
|
41577
40502
|
return;
|
|
41578
|
-
|
|
41579
|
-
var
|
|
41580
|
-
|
|
41581
|
-
|
|
41582
|
-
|
|
41583
|
-
|
|
41584
|
-
|
|
41585
|
-
|
|
41586
|
-
var path = core.DomEditor.findPath(editor, cell);
|
|
41587
|
-
if (path.length === selectedCellPath.length &&
|
|
41588
|
-
isEqual__default["default"](path.slice(-1), selectedCellPath.slice(-1)) // 俩数组,最后一位相同
|
|
41589
|
-
) {
|
|
41590
|
-
// 如果当前 td 的 path 和选中 td 的 path ,最后一位相同,说明是同一列
|
|
41591
|
-
// 删除当前的 cell
|
|
41592
|
-
slate.Transforms.removeNodes(editor, { at: path });
|
|
40503
|
+
var matrix = filledMatrix(editor);
|
|
40504
|
+
var tdIndex = 0;
|
|
40505
|
+
out: for (var x = 0; x < matrix.length; x++) {
|
|
40506
|
+
for (var y = 0; y < matrix[x].length; y++) {
|
|
40507
|
+
var _c = __read(matrix[x][y], 1), _d = __read(_c[0], 2), path = _d[1];
|
|
40508
|
+
if (slate.Path.equals(selectedCellPath, path)) {
|
|
40509
|
+
tdIndex = y;
|
|
40510
|
+
break out;
|
|
41593
40511
|
}
|
|
41594
|
-
}
|
|
40512
|
+
}
|
|
40513
|
+
}
|
|
40514
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
40515
|
+
var e_1, _a;
|
|
40516
|
+
for (var x = 0; x < matrix.length; x++) {
|
|
40517
|
+
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;
|
|
40518
|
+
if (rtl > 1 || ltr > 1) {
|
|
40519
|
+
// 找到显示中 colSpan 节点
|
|
40520
|
+
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];
|
|
40521
|
+
if (hidden) {
|
|
40522
|
+
slate.Transforms.setNodes(editor, {
|
|
40523
|
+
rowSpan: rowSpan,
|
|
40524
|
+
colSpan: Math.max(colSpan - 1, 1),
|
|
40525
|
+
}, { at: path });
|
|
40526
|
+
}
|
|
40527
|
+
else {
|
|
40528
|
+
var _k = __read(matrix[x][tdIndex + 1], 1), _l = __read(_k[0], 2), rightPath = _l[1];
|
|
40529
|
+
slate.Transforms.setNodes(editor, {
|
|
40530
|
+
rowSpan: rowSpan,
|
|
40531
|
+
colSpan: colSpan - 1,
|
|
40532
|
+
hidden: false,
|
|
40533
|
+
}, { at: rightPath });
|
|
40534
|
+
try {
|
|
40535
|
+
// 移动单元格 文本、图片等元素
|
|
40536
|
+
for (var _m = (e_1 = void 0, __values(slate.Node.children(editor, path, { reverse: true }))), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
40537
|
+
var _p = __read(_o.value, 2), childPath = _p[1];
|
|
40538
|
+
slate.Transforms.moveNodes(editor, {
|
|
40539
|
+
to: __spreadArray(__spreadArray([], __read(rightPath)), [0]),
|
|
40540
|
+
at: childPath,
|
|
40541
|
+
});
|
|
40542
|
+
}
|
|
40543
|
+
}
|
|
40544
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
40545
|
+
finally {
|
|
40546
|
+
try {
|
|
40547
|
+
if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
|
|
40548
|
+
}
|
|
40549
|
+
finally { if (e_1) throw e_1.error; }
|
|
40550
|
+
}
|
|
40551
|
+
}
|
|
40552
|
+
}
|
|
40553
|
+
}
|
|
40554
|
+
// 挨个删除 cell
|
|
40555
|
+
for (var x = 0; x < matrix.length; x++) {
|
|
40556
|
+
var _q = __read(matrix[x][tdIndex], 1), _r = __read(_q[0], 2), path = _r[1];
|
|
40557
|
+
slate.Transforms.removeNodes(editor, { at: path });
|
|
40558
|
+
}
|
|
40559
|
+
// 需要调整 columnWidths
|
|
40560
|
+
var _s = __read(slate.Editor.nodes(editor, {
|
|
40561
|
+
match: function (n) { return core.DomEditor.checkNodeType(n, 'table'); },
|
|
40562
|
+
universal: true,
|
|
40563
|
+
}), 1), tableEntry = _s[0];
|
|
40564
|
+
if (tableEntry) {
|
|
40565
|
+
var _t = __read(tableEntry, 2), elemNode = _t[0], tablePath = _t[1];
|
|
40566
|
+
var _u = elemNode.columnWidths, columnWidths = _u === void 0 ? [] : _u;
|
|
40567
|
+
var adjustColumnWidths = __spreadArray([], __read(columnWidths));
|
|
40568
|
+
adjustColumnWidths.splice(tdIndex, 1);
|
|
40569
|
+
slate.Transforms.setNodes(editor, { columnWidths: adjustColumnWidths }, {
|
|
40570
|
+
at: tablePath,
|
|
40571
|
+
});
|
|
40572
|
+
}
|
|
41595
40573
|
});
|
|
41596
40574
|
};
|
|
41597
40575
|
return DeleteCol;
|
|
@@ -41694,6 +40672,234 @@
|
|
|
41694
40672
|
return TableFullWidth;
|
|
41695
40673
|
}());
|
|
41696
40674
|
|
|
40675
|
+
var MergeCell = /** @class */ (function () {
|
|
40676
|
+
function MergeCell() {
|
|
40677
|
+
this.title = core.t('tableModule.mergeCell');
|
|
40678
|
+
this.iconSvg = MERGE_CELL_SVG;
|
|
40679
|
+
this.tag = 'button';
|
|
40680
|
+
}
|
|
40681
|
+
MergeCell.prototype.getValue = function (editor) {
|
|
40682
|
+
// 无需获取 val
|
|
40683
|
+
return '';
|
|
40684
|
+
};
|
|
40685
|
+
MergeCell.prototype.isActive = function (editor) {
|
|
40686
|
+
// 无需 active
|
|
40687
|
+
return false;
|
|
40688
|
+
};
|
|
40689
|
+
MergeCell.prototype.isDisabled = function (editor) {
|
|
40690
|
+
return !this.canMerge(editor);
|
|
40691
|
+
};
|
|
40692
|
+
MergeCell.prototype.exec = function (editor, value) {
|
|
40693
|
+
if (this.isDisabled(editor))
|
|
40694
|
+
return;
|
|
40695
|
+
this.merge(editor);
|
|
40696
|
+
// 释放选区
|
|
40697
|
+
TableCursor.unselect(editor);
|
|
40698
|
+
};
|
|
40699
|
+
/**
|
|
40700
|
+
* Checks if the current selection can be merged. Merging is not possible when any of the following conditions are met:
|
|
40701
|
+
* - The selection is empty.
|
|
40702
|
+
* - The selection is not within the same "thead", "tbody," or "tfoot" section.
|
|
40703
|
+
* @returns {boolean} `true` if the selection can be merged, otherwise `false`.
|
|
40704
|
+
*/
|
|
40705
|
+
MergeCell.prototype.canMerge = function (editor) {
|
|
40706
|
+
var matrix = EDITOR_TO_SELECTION.get(editor);
|
|
40707
|
+
// cannot merge when selection is empty
|
|
40708
|
+
if (!matrix || !matrix.length) {
|
|
40709
|
+
return false;
|
|
40710
|
+
}
|
|
40711
|
+
// prettier-ignore
|
|
40712
|
+
var _a = __read(matrix[matrix.length - 1][matrix[matrix.length - 1].length - 1], 1), _b = __read(_a[0], 2), lastPath = _b[1];
|
|
40713
|
+
var _c = __read(matrix[0][0], 1), _d = __read(_c[0], 2), firstPath = _d[1];
|
|
40714
|
+
// cannot merge when selection is not in common section
|
|
40715
|
+
if (!hasCommon(editor, [firstPath, lastPath], 'table')) {
|
|
40716
|
+
return false;
|
|
40717
|
+
}
|
|
40718
|
+
return true;
|
|
40719
|
+
};
|
|
40720
|
+
/**
|
|
40721
|
+
* Merges the selected cells in the table.
|
|
40722
|
+
* @returns void
|
|
40723
|
+
*/
|
|
40724
|
+
MergeCell.prototype.merge = function (editor) {
|
|
40725
|
+
if (!this.canMerge(editor)) {
|
|
40726
|
+
return;
|
|
40727
|
+
}
|
|
40728
|
+
var selection = EDITOR_TO_SELECTION.get(editor);
|
|
40729
|
+
if (!selection || !selection.length) {
|
|
40730
|
+
return;
|
|
40731
|
+
}
|
|
40732
|
+
var _a = __read(selection[0][0], 1), _b = __read(_a[0], 2), basePath = _b[1];
|
|
40733
|
+
var _c = __read(slate.Node.children(editor, basePath, { reverse: true }), 1), _d = __read(_c[0], 2), lastPath = _d[1];
|
|
40734
|
+
filledMatrix(editor, { at: basePath });
|
|
40735
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
40736
|
+
var e_1, _a;
|
|
40737
|
+
var rowSpan = 0;
|
|
40738
|
+
var colSpan = 0;
|
|
40739
|
+
for (var x = selection.length - 1; x >= 0; x--, rowSpan++) {
|
|
40740
|
+
colSpan = 0;
|
|
40741
|
+
for (var y = selection[x].length - 1; y >= 0; y--, colSpan++) {
|
|
40742
|
+
var _b = __read(selection[x][y], 2), _c = __read(_b[0], 2), path = _c[1], ttb = _b[1].ttb;
|
|
40743
|
+
// skip first cell and "fake" cells which belong to a cell with a `rowspan`
|
|
40744
|
+
if (slate.Path.equals(basePath, path) || ttb > 1) {
|
|
40745
|
+
continue;
|
|
40746
|
+
}
|
|
40747
|
+
try {
|
|
40748
|
+
// prettier-ignore
|
|
40749
|
+
for (var _d = (e_1 = void 0, __values(slate.Node.children(editor, path, { reverse: true }))), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
40750
|
+
var _f = __read(_e.value, 2), childPath = _f[1];
|
|
40751
|
+
slate.Transforms.moveNodes(editor, {
|
|
40752
|
+
to: slate.Path.next(lastPath),
|
|
40753
|
+
at: childPath,
|
|
40754
|
+
});
|
|
40755
|
+
}
|
|
40756
|
+
}
|
|
40757
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
40758
|
+
finally {
|
|
40759
|
+
try {
|
|
40760
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
40761
|
+
}
|
|
40762
|
+
finally { if (e_1) throw e_1.error; }
|
|
40763
|
+
}
|
|
40764
|
+
var _g = __read(slate.Editor.nodes(editor, {
|
|
40765
|
+
match: isOfType(editor, 'tr'),
|
|
40766
|
+
at: path,
|
|
40767
|
+
}), 1), _h = __read(_g[0], 2), trPath = _h[1];
|
|
40768
|
+
var _j = __read(slate.Node.children(editor, trPath), 2), sibling = _j[1];
|
|
40769
|
+
if (sibling) {
|
|
40770
|
+
/**
|
|
40771
|
+
* 删除节点调整成隐藏节点
|
|
40772
|
+
* 隐藏节点不会影响 table 布局
|
|
40773
|
+
*/
|
|
40774
|
+
slate.Transforms.setNodes(editor, { hidden: true }, { at: path });
|
|
40775
|
+
continue;
|
|
40776
|
+
}
|
|
40777
|
+
}
|
|
40778
|
+
}
|
|
40779
|
+
slate.Transforms.setNodes(editor, { rowSpan: rowSpan, colSpan: colSpan }, { at: basePath });
|
|
40780
|
+
});
|
|
40781
|
+
};
|
|
40782
|
+
return MergeCell;
|
|
40783
|
+
}());
|
|
40784
|
+
|
|
40785
|
+
// import { DEFAULT_WITH_TABLE_OPTIONS } from "../../utils/options";
|
|
40786
|
+
var SplitCell = /** @class */ (function () {
|
|
40787
|
+
function SplitCell() {
|
|
40788
|
+
this.title = core.t('tableModule.splitCell');
|
|
40789
|
+
this.iconSvg = SPLIT_CELL_SVG;
|
|
40790
|
+
this.tag = 'button';
|
|
40791
|
+
}
|
|
40792
|
+
SplitCell.prototype.getValue = function (editor) {
|
|
40793
|
+
// 无需获取 val
|
|
40794
|
+
return '';
|
|
40795
|
+
};
|
|
40796
|
+
SplitCell.prototype.isActive = function (editor) {
|
|
40797
|
+
// 无需 active
|
|
40798
|
+
return false;
|
|
40799
|
+
};
|
|
40800
|
+
SplitCell.prototype.isDisabled = function (editor) {
|
|
40801
|
+
var _a = __read(slate.Editor.nodes(editor, {
|
|
40802
|
+
match: isOfType(editor, 'td'),
|
|
40803
|
+
}), 1), td = _a[0];
|
|
40804
|
+
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;
|
|
40805
|
+
if (rowSpan > 1 || colSpan > 1) {
|
|
40806
|
+
return false;
|
|
40807
|
+
}
|
|
40808
|
+
return true;
|
|
40809
|
+
};
|
|
40810
|
+
SplitCell.prototype.exec = function (editor, value) {
|
|
40811
|
+
if (this.isDisabled(editor))
|
|
40812
|
+
return;
|
|
40813
|
+
this.split(editor);
|
|
40814
|
+
};
|
|
40815
|
+
/**
|
|
40816
|
+
* Splits either the cell at the current selection or a specified location. If a range
|
|
40817
|
+
* selection is present, all cells within the range will be split.
|
|
40818
|
+
* @param {Location} [options.at] - Splits the cell at the specified location. If no
|
|
40819
|
+
* location is specified it will split the cell at the current selection
|
|
40820
|
+
* @param {boolean} [options.all] - If true, splits all cells in the table
|
|
40821
|
+
* @returns void
|
|
40822
|
+
*/
|
|
40823
|
+
SplitCell.prototype.split = function (editor, options) {
|
|
40824
|
+
if (options === void 0) { options = {}; }
|
|
40825
|
+
var _a = __read(slate.Editor.nodes(editor, {
|
|
40826
|
+
match: isOfType(editor, 'table', 'th', 'td'),
|
|
40827
|
+
// @ts-ignore
|
|
40828
|
+
at: options.at,
|
|
40829
|
+
}), 2), table = _a[0], td = _a[1];
|
|
40830
|
+
if (!table || !td) {
|
|
40831
|
+
return;
|
|
40832
|
+
}
|
|
40833
|
+
var selection = EDITOR_TO_SELECTION.get(editor) || [];
|
|
40834
|
+
// @ts-ignore
|
|
40835
|
+
var matrix = filledMatrix(editor, { at: options.at });
|
|
40836
|
+
// const { blocks } = DEFAULT_WITH_TABLE_OPTIONS;
|
|
40837
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
40838
|
+
for (var x = matrix.length - 1; x >= 0; x--) {
|
|
40839
|
+
for (var y = matrix[x].length - 1; y >= 0; y--) {
|
|
40840
|
+
var _a = __read(matrix[x][y], 2), _b = __read(_a[0], 2), path = _b[1], context = _a[1];
|
|
40841
|
+
var colSpan = context.ltr, rtl = context.rtl, rowSpan = context.btt, ttb = context.ttb;
|
|
40842
|
+
if (rtl > 1) {
|
|
40843
|
+
// get to the start of the colspan
|
|
40844
|
+
y -= rtl - 2;
|
|
40845
|
+
continue;
|
|
40846
|
+
}
|
|
40847
|
+
if (ttb > 1) {
|
|
40848
|
+
continue;
|
|
40849
|
+
}
|
|
40850
|
+
if (rowSpan === 1 && colSpan === 1) {
|
|
40851
|
+
continue;
|
|
40852
|
+
}
|
|
40853
|
+
var found = !!options.all;
|
|
40854
|
+
if (selection.length) {
|
|
40855
|
+
outer: for (var i = 0; !options.all && i < selection.length; i++) {
|
|
40856
|
+
for (var j = 0; j < selection[i].length; j++) {
|
|
40857
|
+
var _c = __read(selection[i][j], 1), _d = __read(_c[0], 2), tdPath = _d[1];
|
|
40858
|
+
if (slate.Path.equals(tdPath, path)) {
|
|
40859
|
+
found = true;
|
|
40860
|
+
break outer;
|
|
40861
|
+
}
|
|
40862
|
+
}
|
|
40863
|
+
}
|
|
40864
|
+
}
|
|
40865
|
+
else {
|
|
40866
|
+
var _e = __read(td, 2), tdPath = _e[1];
|
|
40867
|
+
if (slate.Path.equals(tdPath, path)) {
|
|
40868
|
+
found = true;
|
|
40869
|
+
}
|
|
40870
|
+
}
|
|
40871
|
+
if (!found) {
|
|
40872
|
+
continue;
|
|
40873
|
+
}
|
|
40874
|
+
var _f = __read(slate.Editor.nodes(editor, {
|
|
40875
|
+
match: isOfType(editor, 'table'),
|
|
40876
|
+
at: path,
|
|
40877
|
+
}), 1), _g = __read(_f[0], 1); _g[0];
|
|
40878
|
+
out: for (var r = 1; r < rowSpan; r++) {
|
|
40879
|
+
for (var i = y; i >= 0; i--) {
|
|
40880
|
+
var _h = __read(matrix[x + r][i], 2), _j = __read(_h[0], 2); _j[1]; var ttb_1 = _h[1].ttb;
|
|
40881
|
+
if (ttb_1 == 1) {
|
|
40882
|
+
continue;
|
|
40883
|
+
}
|
|
40884
|
+
for (var c = 0; c < colSpan; c++) {
|
|
40885
|
+
var _k = __read(matrix[x + r][i + c], 1), _l = __read(_k[0], 2), nextPath = _l[1];
|
|
40886
|
+
slate.Transforms.unsetNodes(editor, ['hidden', 'colSpan', 'rowSpan'], { at: nextPath });
|
|
40887
|
+
}
|
|
40888
|
+
continue out;
|
|
40889
|
+
}
|
|
40890
|
+
}
|
|
40891
|
+
for (var c = 1; c < colSpan; c++) {
|
|
40892
|
+
var _m = __read(matrix[x][y + c], 1), _o = __read(_m[0], 2), nextPath = _o[1];
|
|
40893
|
+
slate.Transforms.unsetNodes(editor, ['hidden', 'colSpan', 'rowSpan'], { at: nextPath });
|
|
40894
|
+
}
|
|
40895
|
+
slate.Transforms.setNodes(editor, { rowSpan: 1, colSpan: 1 }, { at: path });
|
|
40896
|
+
}
|
|
40897
|
+
}
|
|
40898
|
+
});
|
|
40899
|
+
};
|
|
40900
|
+
return SplitCell;
|
|
40901
|
+
}());
|
|
40902
|
+
|
|
41697
40903
|
/**
|
|
41698
40904
|
* @description table menu
|
|
41699
40905
|
* @author wangfupeng
|
|
@@ -41745,6 +40951,19 @@
|
|
|
41745
40951
|
factory: function () {
|
|
41746
40952
|
return new TableFullWidth();
|
|
41747
40953
|
},
|
|
40954
|
+
};
|
|
40955
|
+
/** Meger / Split conf */
|
|
40956
|
+
var mergeTableCellConf = {
|
|
40957
|
+
key: 'mergeTableCell',
|
|
40958
|
+
factory: function () {
|
|
40959
|
+
return new MergeCell();
|
|
40960
|
+
},
|
|
40961
|
+
};
|
|
40962
|
+
var splitTableCellConf = {
|
|
40963
|
+
key: 'splitTableCell',
|
|
40964
|
+
factory: function () {
|
|
40965
|
+
return new SplitCell();
|
|
40966
|
+
},
|
|
41748
40967
|
};
|
|
41749
40968
|
|
|
41750
40969
|
/**
|
|
@@ -41765,6 +40984,8 @@
|
|
|
41765
40984
|
deleteTableColConf,
|
|
41766
40985
|
tableHeaderMenuConf,
|
|
41767
40986
|
tableFullWidthMenuConf,
|
|
40987
|
+
mergeTableCellConf,
|
|
40988
|
+
splitTableCellConf,
|
|
41768
40989
|
],
|
|
41769
40990
|
editorPlugin: withTable,
|
|
41770
40991
|
};
|
|
@@ -48732,6 +47953,9 @@
|
|
|
48732
47953
|
'insertTableCol',
|
|
48733
47954
|
'deleteTableCol',
|
|
48734
47955
|
'deleteTable',
|
|
47956
|
+
/** 注册单元格合并 拆分 */
|
|
47957
|
+
'mergeTableCell',
|
|
47958
|
+
'splitTableCell',
|
|
48735
47959
|
],
|
|
48736
47960
|
},
|
|
48737
47961
|
divider: {
|