@wangeditor-next/editor 5.3.2 → 5.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/css/style.css +66 -0
- package/dist/index.esm.js +1484 -2242
- package/dist/index.js +1415 -2173
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -860,7 +860,7 @@ var endsWithOddNumberOfRIs = str => {
|
|
|
860
860
|
* Shared the function with isElementType utility
|
|
861
861
|
*/
|
|
862
862
|
|
|
863
|
-
var isElement$
|
|
863
|
+
var isElement$2 = value => {
|
|
864
864
|
return isPlainObject$1(value) && Node$1.isNodeList(value.children) && !Editor.isEditor(value);
|
|
865
865
|
};
|
|
866
866
|
|
|
@@ -875,7 +875,7 @@ var Element$1 = {
|
|
|
875
875
|
/**
|
|
876
876
|
* Check if a value implements the `Element` interface.
|
|
877
877
|
*/
|
|
878
|
-
isElement: isElement$
|
|
878
|
+
isElement: isElement$2,
|
|
879
879
|
|
|
880
880
|
/**
|
|
881
881
|
* Check if a value is an array of `Element` objects.
|
|
@@ -897,7 +897,7 @@ var Element$1 = {
|
|
|
897
897
|
*/
|
|
898
898
|
isElementType: function isElementType(value, elementVal) {
|
|
899
899
|
var elementKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'type';
|
|
900
|
-
return isElement$
|
|
900
|
+
return isElement$2(value) && value[elementKey] === elementVal;
|
|
901
901
|
},
|
|
902
902
|
|
|
903
903
|
/**
|
|
@@ -1197,7 +1197,7 @@ var Editor = {
|
|
|
1197
1197
|
*/
|
|
1198
1198
|
isEnd(editor, point, at) {
|
|
1199
1199
|
var end = Editor.end(editor, at);
|
|
1200
|
-
return Point.equals(point, end);
|
|
1200
|
+
return Point$1.equals(point, end);
|
|
1201
1201
|
},
|
|
1202
1202
|
|
|
1203
1203
|
/**
|
|
@@ -1243,7 +1243,7 @@ var Editor = {
|
|
|
1243
1243
|
}
|
|
1244
1244
|
|
|
1245
1245
|
var start = Editor.start(editor, at);
|
|
1246
|
-
return Point.equals(point, start);
|
|
1246
|
+
return Point$1.equals(point, start);
|
|
1247
1247
|
},
|
|
1248
1248
|
|
|
1249
1249
|
/**
|
|
@@ -1663,7 +1663,7 @@ var Editor = {
|
|
|
1663
1663
|
}
|
|
1664
1664
|
}
|
|
1665
1665
|
|
|
1666
|
-
if (Point.isPoint(at)) {
|
|
1666
|
+
if (Point$1.isPoint(at)) {
|
|
1667
1667
|
at = at.path;
|
|
1668
1668
|
}
|
|
1669
1669
|
|
|
@@ -2255,7 +2255,7 @@ var Location = {
|
|
|
2255
2255
|
* Check if a value implements the `Location` interface.
|
|
2256
2256
|
*/
|
|
2257
2257
|
isLocation(value) {
|
|
2258
|
-
return Path.isPath(value) || Point.isPoint(value) || Range.isRange(value);
|
|
2258
|
+
return Path.isPath(value) || Point$1.isPoint(value) || Range.isRange(value);
|
|
2259
2259
|
}
|
|
2260
2260
|
|
|
2261
2261
|
};
|
|
@@ -3329,7 +3329,7 @@ var PathRef = {
|
|
|
3329
3329
|
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
3330
3330
|
|
|
3331
3331
|
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3332
|
-
var Point = {
|
|
3332
|
+
var Point$1 = {
|
|
3333
3333
|
/**
|
|
3334
3334
|
* Compare a point to another, returning an integer indicating whether the
|
|
3335
3335
|
* point was before, at, or after the other.
|
|
@@ -3350,14 +3350,14 @@ var Point = {
|
|
|
3350
3350
|
* Check if a point is after another.
|
|
3351
3351
|
*/
|
|
3352
3352
|
isAfter(point, another) {
|
|
3353
|
-
return Point.compare(point, another) === 1;
|
|
3353
|
+
return Point$1.compare(point, another) === 1;
|
|
3354
3354
|
},
|
|
3355
3355
|
|
|
3356
3356
|
/**
|
|
3357
3357
|
* Check if a point is before another.
|
|
3358
3358
|
*/
|
|
3359
3359
|
isBefore(point, another) {
|
|
3360
|
-
return Point.compare(point, another) === -1;
|
|
3360
|
+
return Point$1.compare(point, another) === -1;
|
|
3361
3361
|
},
|
|
3362
3362
|
|
|
3363
3363
|
/**
|
|
@@ -3476,7 +3476,7 @@ var PointRef = {
|
|
|
3476
3476
|
return;
|
|
3477
3477
|
}
|
|
3478
3478
|
|
|
3479
|
-
var point = Point.transform(current, op, {
|
|
3479
|
+
var point = Point$1.transform(current, op, {
|
|
3480
3480
|
affinity
|
|
3481
3481
|
});
|
|
3482
3482
|
ref.current = point;
|
|
@@ -3522,7 +3522,7 @@ var Range = {
|
|
|
3522
3522
|
* Check if a range is exactly equal to another.
|
|
3523
3523
|
*/
|
|
3524
3524
|
equals(range, another) {
|
|
3525
|
-
return Point.equals(range.anchor, another.anchor) && Point.equals(range.focus, another.focus);
|
|
3525
|
+
return Point$1.equals(range.anchor, another.anchor) && Point$1.equals(range.focus, another.focus);
|
|
3526
3526
|
},
|
|
3527
3527
|
|
|
3528
3528
|
/**
|
|
@@ -3536,16 +3536,16 @@ var Range = {
|
|
|
3536
3536
|
|
|
3537
3537
|
var [rs, re] = Range.edges(range);
|
|
3538
3538
|
var [ts, te] = Range.edges(target);
|
|
3539
|
-
return Point.isBefore(rs, ts) && Point.isAfter(re, te);
|
|
3539
|
+
return Point$1.isBefore(rs, ts) && Point$1.isAfter(re, te);
|
|
3540
3540
|
}
|
|
3541
3541
|
|
|
3542
3542
|
var [start, end] = Range.edges(range);
|
|
3543
3543
|
var isAfterStart = false;
|
|
3544
3544
|
var isBeforeEnd = false;
|
|
3545
3545
|
|
|
3546
|
-
if (Point.isPoint(target)) {
|
|
3547
|
-
isAfterStart = Point.compare(target, start) >= 0;
|
|
3548
|
-
isBeforeEnd = Point.compare(target, end) <= 0;
|
|
3546
|
+
if (Point$1.isPoint(target)) {
|
|
3547
|
+
isAfterStart = Point$1.compare(target, start) >= 0;
|
|
3548
|
+
isBeforeEnd = Point$1.compare(target, end) <= 0;
|
|
3549
3549
|
} else {
|
|
3550
3550
|
isAfterStart = Path.compare(target, start.path) >= 0;
|
|
3551
3551
|
isBeforeEnd = Path.compare(target, end.path) <= 0;
|
|
@@ -3562,10 +3562,10 @@ var Range = {
|
|
|
3562
3562
|
|
|
3563
3563
|
var [s1, e1] = Range.edges(range);
|
|
3564
3564
|
var [s2, e2] = Range.edges(another);
|
|
3565
|
-
var start = Point.isBefore(s1, s2) ? s2 : s1;
|
|
3566
|
-
var end = Point.isBefore(e1, e2) ? e1 : e2;
|
|
3565
|
+
var start = Point$1.isBefore(s1, s2) ? s2 : s1;
|
|
3566
|
+
var end = Point$1.isBefore(e1, e2) ? e1 : e2;
|
|
3567
3567
|
|
|
3568
|
-
if (Point.isBefore(end, start)) {
|
|
3568
|
+
if (Point$1.isBefore(end, start)) {
|
|
3569
3569
|
return null;
|
|
3570
3570
|
} else {
|
|
3571
3571
|
return _objectSpread$5({
|
|
@@ -3584,7 +3584,7 @@ var Range = {
|
|
|
3584
3584
|
anchor,
|
|
3585
3585
|
focus
|
|
3586
3586
|
} = range;
|
|
3587
|
-
return Point.isAfter(anchor, focus);
|
|
3587
|
+
return Point$1.isAfter(anchor, focus);
|
|
3588
3588
|
},
|
|
3589
3589
|
|
|
3590
3590
|
/**
|
|
@@ -3596,7 +3596,7 @@ var Range = {
|
|
|
3596
3596
|
anchor,
|
|
3597
3597
|
focus
|
|
3598
3598
|
} = range;
|
|
3599
|
-
return Point.equals(anchor, focus);
|
|
3599
|
+
return Point$1.equals(anchor, focus);
|
|
3600
3600
|
},
|
|
3601
3601
|
|
|
3602
3602
|
/**
|
|
@@ -3621,7 +3621,7 @@ var Range = {
|
|
|
3621
3621
|
* Check if a value implements the [[Range]] interface.
|
|
3622
3622
|
*/
|
|
3623
3623
|
isRange(value) {
|
|
3624
|
-
return isPlainObject$1(value) && Point.isPoint(value.anchor) && Point.isPoint(value.focus);
|
|
3624
|
+
return isPlainObject$1(value) && Point$1.isPoint(value.anchor) && Point$1.isPoint(value.focus);
|
|
3625
3625
|
},
|
|
3626
3626
|
|
|
3627
3627
|
/**
|
|
@@ -3682,10 +3682,10 @@ var Range = {
|
|
|
3682
3682
|
affinityFocus = affinity;
|
|
3683
3683
|
}
|
|
3684
3684
|
|
|
3685
|
-
var anchor = Point.transform(r.anchor, op, {
|
|
3685
|
+
var anchor = Point$1.transform(r.anchor, op, {
|
|
3686
3686
|
affinity: affinityAnchor
|
|
3687
3687
|
});
|
|
3688
|
-
var focus = Point.transform(r.focus, op, {
|
|
3688
|
+
var focus = Point$1.transform(r.focus, op, {
|
|
3689
3689
|
affinity: affinityFocus
|
|
3690
3690
|
});
|
|
3691
3691
|
|
|
@@ -3943,7 +3943,7 @@ var applyToDraft = (editor, selection, op) => {
|
|
|
3943
3943
|
|
|
3944
3944
|
if (selection) {
|
|
3945
3945
|
for (var [point, key] of Range.points(selection)) {
|
|
3946
|
-
selection[key] = Point.transform(point, op);
|
|
3946
|
+
selection[key] = Point$1.transform(point, op);
|
|
3947
3947
|
}
|
|
3948
3948
|
}
|
|
3949
3949
|
|
|
@@ -3969,7 +3969,7 @@ var applyToDraft = (editor, selection, op) => {
|
|
|
3969
3969
|
|
|
3970
3970
|
if (selection) {
|
|
3971
3971
|
for (var [_point, _key] of Range.points(selection)) {
|
|
3972
|
-
selection[_key] = Point.transform(_point, op);
|
|
3972
|
+
selection[_key] = Point$1.transform(_point, op);
|
|
3973
3973
|
}
|
|
3974
3974
|
}
|
|
3975
3975
|
|
|
@@ -4003,7 +4003,7 @@ var applyToDraft = (editor, selection, op) => {
|
|
|
4003
4003
|
|
|
4004
4004
|
if (selection) {
|
|
4005
4005
|
for (var [_point2, _key2] of Range.points(selection)) {
|
|
4006
|
-
selection[_key2] = Point.transform(_point2, op);
|
|
4006
|
+
selection[_key2] = Point$1.transform(_point2, op);
|
|
4007
4007
|
}
|
|
4008
4008
|
}
|
|
4009
4009
|
|
|
@@ -4041,7 +4041,7 @@ var applyToDraft = (editor, selection, op) => {
|
|
|
4041
4041
|
|
|
4042
4042
|
if (selection) {
|
|
4043
4043
|
for (var [_point3, _key3] of Range.points(selection)) {
|
|
4044
|
-
selection[_key3] = Point.transform(_point3, op);
|
|
4044
|
+
selection[_key3] = Point$1.transform(_point3, op);
|
|
4045
4045
|
}
|
|
4046
4046
|
}
|
|
4047
4047
|
|
|
@@ -4063,7 +4063,7 @@ var applyToDraft = (editor, selection, op) => {
|
|
|
4063
4063
|
|
|
4064
4064
|
if (selection) {
|
|
4065
4065
|
for (var [_point4, _key4] of Range.points(selection)) {
|
|
4066
|
-
var result = Point.transform(_point4, op);
|
|
4066
|
+
var result = Point$1.transform(_point4, op);
|
|
4067
4067
|
|
|
4068
4068
|
if (selection != null && result != null) {
|
|
4069
4069
|
selection[_key4] = result;
|
|
@@ -4126,7 +4126,7 @@ var applyToDraft = (editor, selection, op) => {
|
|
|
4126
4126
|
|
|
4127
4127
|
if (selection) {
|
|
4128
4128
|
for (var [_point5, _key5] of Range.points(selection)) {
|
|
4129
|
-
selection[_key5] = Point.transform(_point5, op);
|
|
4129
|
+
selection[_key5] = Point$1.transform(_point5, op);
|
|
4130
4130
|
}
|
|
4131
4131
|
}
|
|
4132
4132
|
|
|
@@ -4249,7 +4249,7 @@ var applyToDraft = (editor, selection, op) => {
|
|
|
4249
4249
|
|
|
4250
4250
|
if (selection) {
|
|
4251
4251
|
for (var [_point6, _key9] of Range.points(selection)) {
|
|
4252
|
-
selection[_key9] = Point.transform(_point6, op);
|
|
4252
|
+
selection[_key9] = Point$1.transform(_point6, op);
|
|
4253
4253
|
}
|
|
4254
4254
|
}
|
|
4255
4255
|
|
|
@@ -4352,7 +4352,7 @@ var NodeTransforms = {
|
|
|
4352
4352
|
}
|
|
4353
4353
|
}
|
|
4354
4354
|
|
|
4355
|
-
if (Point.isPoint(at)) {
|
|
4355
|
+
if (Point$1.isPoint(at)) {
|
|
4356
4356
|
if (match == null) {
|
|
4357
4357
|
if (Text.isText(node)) {
|
|
4358
4358
|
match = n => Text.isText(n);
|
|
@@ -5447,7 +5447,7 @@ var SelectionTransforms = {
|
|
|
5447
5447
|
}
|
|
5448
5448
|
|
|
5449
5449
|
for (var k in props) {
|
|
5450
|
-
if (k === 'anchor' && props.anchor != null && !Point.equals(props.anchor, selection.anchor) || k === 'focus' && props.focus != null && !Point.equals(props.focus, selection.focus) || k !== 'anchor' && k !== 'focus' && props[k] !== selection[k]) {
|
|
5450
|
+
if (k === 'anchor' && props.anchor != null && !Point$1.equals(props.anchor, selection.anchor) || k === 'focus' && props.focus != null && !Point$1.equals(props.focus, selection.focus) || k !== 'anchor' && k !== 'focus' && props[k] !== selection[k]) {
|
|
5451
5451
|
oldProps[k] = selection[k];
|
|
5452
5452
|
newProps[k] = props[k];
|
|
5453
5453
|
}
|
|
@@ -5490,7 +5490,7 @@ var TextTransforms = {
|
|
|
5490
5490
|
at = at.anchor;
|
|
5491
5491
|
}
|
|
5492
5492
|
|
|
5493
|
-
if (Point.isPoint(at)) {
|
|
5493
|
+
if (Point$1.isPoint(at)) {
|
|
5494
5494
|
var furthestVoid = Editor.void(editor, {
|
|
5495
5495
|
at,
|
|
5496
5496
|
mode: 'highest'
|
|
@@ -5529,7 +5529,7 @@ var TextTransforms = {
|
|
|
5529
5529
|
var [, _end] = Range.edges(at);
|
|
5530
5530
|
var endOfDoc = Editor.end(editor, []);
|
|
5531
5531
|
|
|
5532
|
-
if (!Point.equals(_end, endOfDoc)) {
|
|
5532
|
+
if (!Point$1.equals(_end, endOfDoc)) {
|
|
5533
5533
|
at = Editor.unhangRange(editor, at, {
|
|
5534
5534
|
voids
|
|
5535
5535
|
});
|
|
@@ -8930,7 +8930,7 @@ function setTextContent(node, text) {
|
|
|
8930
8930
|
function getTextContent(node) {
|
|
8931
8931
|
return node.textContent;
|
|
8932
8932
|
}
|
|
8933
|
-
function isElement(node) {
|
|
8933
|
+
function isElement$1(node) {
|
|
8934
8934
|
return node.nodeType === 1;
|
|
8935
8935
|
}
|
|
8936
8936
|
function isText(node) {
|
|
@@ -8952,7 +8952,7 @@ const htmlDomApi = {
|
|
|
8952
8952
|
tagName,
|
|
8953
8953
|
setTextContent,
|
|
8954
8954
|
getTextContent,
|
|
8955
|
-
isElement,
|
|
8955
|
+
isElement: isElement$1,
|
|
8956
8956
|
isText,
|
|
8957
8957
|
isComment,
|
|
8958
8958
|
};
|
|
@@ -17782,15 +17782,15 @@ function __extends$2(d, b) {
|
|
|
17782
17782
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
17783
17783
|
}
|
|
17784
17784
|
|
|
17785
|
-
var __assign$
|
|
17786
|
-
__assign$
|
|
17785
|
+
var __assign$5 = function() {
|
|
17786
|
+
__assign$5 = Object.assign || function __assign(t) {
|
|
17787
17787
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
17788
17788
|
s = arguments[i];
|
|
17789
17789
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
17790
17790
|
}
|
|
17791
17791
|
return t;
|
|
17792
17792
|
};
|
|
17793
|
-
return __assign$
|
|
17793
|
+
return __assign$5.apply(this, arguments);
|
|
17794
17794
|
};
|
|
17795
17795
|
|
|
17796
17796
|
function __values$6(o) {
|
|
@@ -17822,7 +17822,7 @@ function __read$6(o, n) {
|
|
|
17822
17822
|
return ar;
|
|
17823
17823
|
}
|
|
17824
17824
|
|
|
17825
|
-
function __spreadArray(to, from) {
|
|
17825
|
+
function __spreadArray$1(to, from) {
|
|
17826
17826
|
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
17827
17827
|
to[j] = from[i];
|
|
17828
17828
|
return to;
|
|
@@ -17885,7 +17885,7 @@ var EDITOR_TO_WINDOW = new WeakMap();
|
|
|
17885
17885
|
*/
|
|
17886
17886
|
var IS_FOCUSED = new WeakMap();
|
|
17887
17887
|
// 保存 editor -> selection ,用于还原 editor 选区
|
|
17888
|
-
var EDITOR_TO_SELECTION = new WeakMap();
|
|
17888
|
+
var EDITOR_TO_SELECTION$1 = new WeakMap();
|
|
17889
17889
|
// editor -> eventEmitter 自定义事件
|
|
17890
17890
|
var EDITOR_TO_EMITTER = new WeakMap();
|
|
17891
17891
|
// editor 是否可执行粘贴
|
|
@@ -18427,9 +18427,14 @@ var DomEditor = {
|
|
|
18427
18427
|
}
|
|
18428
18428
|
return (
|
|
18429
18429
|
// 祖先节点中包括 data-slate-editor 属性,即 textarea
|
|
18430
|
-
targetEl.closest("[data-slate-editor]") === editorEl &&
|
|
18430
|
+
(targetEl.closest("[data-slate-editor]") === editorEl &&
|
|
18431
18431
|
// 通过参数 editable 控制开启是否验证是可编辑元素或零宽字符
|
|
18432
|
-
|
|
18432
|
+
// 补全 data-slate-string 可参考本文代码
|
|
18433
|
+
//(data-slate-zero-width、data-slate-string)判断一起出现,唯独此处欠缺,补全
|
|
18434
|
+
(!editable ||
|
|
18435
|
+
targetEl.isContentEditable ||
|
|
18436
|
+
!!targetEl.getAttribute('data-slate-zero-width'))) ||
|
|
18437
|
+
!!targetEl.getAttribute('data-slate-string'));
|
|
18433
18438
|
},
|
|
18434
18439
|
/**
|
|
18435
18440
|
* Find a native DOM range from a Slate `range`.
|
|
@@ -18671,7 +18676,7 @@ var DomEditor = {
|
|
|
18671
18676
|
range.setStart(textNode, 0);
|
|
18672
18677
|
range.setEnd(nearestNode, nearestOffset);
|
|
18673
18678
|
var contents = range.cloneContents();
|
|
18674
|
-
var removals = __spreadArray(__spreadArray([], __read$6(lodash_toarray(contents.querySelectorAll('[data-slate-zero-width]')))), __read$6(lodash_toarray(contents.querySelectorAll('[contenteditable=false]'))));
|
|
18679
|
+
var removals = __spreadArray$1(__spreadArray$1([], __read$6(lodash_toarray(contents.querySelectorAll('[data-slate-zero-width]')))), __read$6(lodash_toarray(contents.querySelectorAll('[contenteditable=false]'))));
|
|
18675
18680
|
removals.forEach(function (el) {
|
|
18676
18681
|
el.parentNode.removeChild(el);
|
|
18677
18682
|
});
|
|
@@ -19019,7 +19024,7 @@ var withDOM = function (editor) {
|
|
|
19019
19024
|
Transforms.select(e, end);
|
|
19020
19025
|
}
|
|
19021
19026
|
else {
|
|
19022
|
-
var selection = EDITOR_TO_SELECTION.get(e);
|
|
19027
|
+
var selection = EDITOR_TO_SELECTION$1.get(e);
|
|
19023
19028
|
if (selection) {
|
|
19024
19029
|
Transforms.select(e, selection); // 选区定位到之前的位置
|
|
19025
19030
|
}
|
|
@@ -19223,7 +19228,7 @@ var MENU_ITEM_FACTORIES = {};
|
|
|
19223
19228
|
function registerMenu(registerMenuConf, customConfig) {
|
|
19224
19229
|
var key = registerMenuConf.key, factory = registerMenuConf.factory, config = registerMenuConf.config;
|
|
19225
19230
|
// 合并 config
|
|
19226
|
-
var newConfig = __assign$
|
|
19231
|
+
var newConfig = __assign$5(__assign$5({}, config), (customConfig || {}));
|
|
19227
19232
|
// 注册 menu
|
|
19228
19233
|
if (MENU_ITEM_FACTORIES[key] != null) {
|
|
19229
19234
|
throw new Error("Duplicated key '" + key + "' in menu items");
|
|
@@ -20043,7 +20048,7 @@ var withContent = function (editor) {
|
|
|
20043
20048
|
// 记录当前选区
|
|
20044
20049
|
var selection = e.selection;
|
|
20045
20050
|
if (selection != null) {
|
|
20046
|
-
EDITOR_TO_SELECTION.set(e, selection);
|
|
20051
|
+
EDITOR_TO_SELECTION$1.set(e, selection);
|
|
20047
20052
|
}
|
|
20048
20053
|
// 触发配置的 change 事件
|
|
20049
20054
|
e.emit('change');
|
|
@@ -20092,7 +20097,7 @@ var withContent = function (editor) {
|
|
|
20092
20097
|
var key = DomEditor.findKey(e, node);
|
|
20093
20098
|
var id = genElemId$1(key.id);
|
|
20094
20099
|
// node + id
|
|
20095
|
-
elems.push(__assign$
|
|
20100
|
+
elems.push(__assign$5(__assign$5({}, node), { id: id }));
|
|
20096
20101
|
}
|
|
20097
20102
|
}
|
|
20098
20103
|
}
|
|
@@ -20201,7 +20206,7 @@ var withContent = function (editor) {
|
|
|
20201
20206
|
div.setAttribute('hidden', 'true');
|
|
20202
20207
|
document.body.appendChild(div);
|
|
20203
20208
|
var insertedElemNum = 0; // 记录插入 elem 的数量 ( textNode 不算 )
|
|
20204
|
-
domNodes.forEach(function (n) {
|
|
20209
|
+
domNodes.forEach(function (n, index) {
|
|
20205
20210
|
var nodeType = n.nodeType, nodeName = n.nodeName, _a = n.textContent, textContent = _a === void 0 ? '' : _a;
|
|
20206
20211
|
// ------ Text node ------
|
|
20207
20212
|
if (nodeType === NodeType.TEXT_NODE) {
|
|
@@ -20255,8 +20260,13 @@ var withContent = function (editor) {
|
|
|
20255
20260
|
var display = window.getComputedStyle(el).display;
|
|
20256
20261
|
if (!DomEditor.isSelectedEmptyParagraph(e)) {
|
|
20257
20262
|
// 当前不是空行,且 非 inline - 则换行
|
|
20258
|
-
if (display.indexOf('inline') < 0)
|
|
20263
|
+
if (display.indexOf('inline') < 0) {
|
|
20264
|
+
var el_1 = domNodes[index - 1];
|
|
20265
|
+
if (el_1.matches('ul:not([data-w-e-type]),ol:not([data-w-e-type])')) {
|
|
20266
|
+
e.insertBreak(); // 列表项,需要插入空行
|
|
20267
|
+
}
|
|
20259
20268
|
e.insertBreak();
|
|
20269
|
+
}
|
|
20260
20270
|
}
|
|
20261
20271
|
e.dangerouslyInsertHtml(el.innerHTML, true); // 继续插入子内容
|
|
20262
20272
|
});
|
|
@@ -20834,7 +20844,7 @@ var withEmitter = function (editor) {
|
|
|
20834
20844
|
args[_i - 1] = arguments[_i];
|
|
20835
20845
|
}
|
|
20836
20846
|
var emitter = getEmitter(e);
|
|
20837
|
-
emitter.emit.apply(emitter, __spreadArray([type], __read$6(args)));
|
|
20847
|
+
emitter.emit.apply(emitter, __spreadArray$1([type], __read$6(args)));
|
|
20838
20848
|
// editor 销毁时,off 掉 destroyed listeners
|
|
20839
20849
|
if (type === 'destroyed') {
|
|
20840
20850
|
var listeners = getDestroyListeners(e);
|
|
@@ -21089,7 +21099,7 @@ function correctPosition(editor, $positionElem) {
|
|
|
21089
21099
|
* @description slate 插件 - selection 相关
|
|
21090
21100
|
* @author wangfupeng
|
|
21091
21101
|
*/
|
|
21092
|
-
var withSelection = function (editor) {
|
|
21102
|
+
var withSelection$1 = function (editor) {
|
|
21093
21103
|
var e = editor;
|
|
21094
21104
|
// 选中
|
|
21095
21105
|
e.select = function (at) {
|
|
@@ -21128,7 +21138,7 @@ var withSelection = function (editor) {
|
|
|
21128
21138
|
* 还原选区
|
|
21129
21139
|
*/
|
|
21130
21140
|
e.restoreSelection = function () {
|
|
21131
|
-
var selection = EDITOR_TO_SELECTION.get(e);
|
|
21141
|
+
var selection = EDITOR_TO_SELECTION$1.get(e);
|
|
21132
21142
|
if (selection == null)
|
|
21133
21143
|
return;
|
|
21134
21144
|
e.focus();
|
|
@@ -21155,7 +21165,7 @@ var withSelection = function (editor) {
|
|
|
21155
21165
|
return false;
|
|
21156
21166
|
var _a = __read$6(Range.edges(selection), 2), start1 = _a[0], end1 = _a[1]; // 获取当前选取的开始、结束 point
|
|
21157
21167
|
var _b = __read$6(Editor.edges(e, []), 2), start2 = _b[0], end2 = _b[1]; // 获取编辑器全部的开始、结束 point
|
|
21158
|
-
if (Point.equals(start1, start2) && Point.equals(end1, end2)) {
|
|
21168
|
+
if (Point$1.equals(start1, start2) && Point$1.equals(end1, end2)) {
|
|
21159
21169
|
return true;
|
|
21160
21170
|
}
|
|
21161
21171
|
return false;
|
|
@@ -22065,9 +22075,6 @@ function DOMSelectionToEditor(textarea, editor) {
|
|
|
22065
22075
|
});
|
|
22066
22076
|
Transforms.select(editor, range);
|
|
22067
22077
|
}
|
|
22068
|
-
else {
|
|
22069
|
-
Transforms.deselect(editor);
|
|
22070
|
-
}
|
|
22071
22078
|
}
|
|
22072
22079
|
|
|
22073
22080
|
/**
|
|
@@ -22323,16 +22330,7 @@ function handleCompositionStart(e, textarea, editor) {
|
|
|
22323
22330
|
editorSelectionToDOM(textarea, editor, true);
|
|
22324
22331
|
});
|
|
22325
22332
|
}
|
|
22326
|
-
if (selection && Range.isCollapsed(selection)) {
|
|
22327
|
-
// 记录下 dom text ,以便触发 maxLength 时使用
|
|
22328
|
-
var domRange = DomEditor.toDOMRange(editor, selection);
|
|
22329
|
-
var startContainer = domRange.startContainer;
|
|
22330
|
-
var curText = startContainer.textContent || '';
|
|
22331
|
-
EDITOR_TO_TEXT.set(editor, curText);
|
|
22332
|
-
// 记录下 dom range startContainer
|
|
22333
|
-
EDITOR_TO_START_CONTAINER.set(editor, startContainer);
|
|
22334
|
-
}
|
|
22335
|
-
if (selection && Range.isExpanded(selection)) {
|
|
22333
|
+
if (selection && (Range.isExpanded(selection) || Range.isCollapsed(selection))) {
|
|
22336
22334
|
// 记录下 dom text ,以便触发 maxLength 时使用
|
|
22337
22335
|
var domRange = DomEditor.toDOMRange(editor, selection);
|
|
22338
22336
|
var startContainer = domRange.startContainer;
|
|
@@ -22571,7 +22569,7 @@ function triggerMenuHotKey(editor, event) {
|
|
|
22571
22569
|
var hoverbar = EDITOR_TO_HOVER_BAR.get(editor);
|
|
22572
22570
|
var hoverbarMenus = hoverbar && hoverbar.getMenus();
|
|
22573
22571
|
// 合并所有 menus
|
|
22574
|
-
var allMenus = __assign$
|
|
22572
|
+
var allMenus = __assign$5(__assign$5({}, toolbarMenus), hoverbarMenus);
|
|
22575
22573
|
for (var key in allMenus) {
|
|
22576
22574
|
var menu = allMenus[key];
|
|
22577
22575
|
var hotkey = menu.hotkey;
|
|
@@ -24367,10 +24365,10 @@ function genEditorConfig(userConfig) {
|
|
|
24367
24365
|
var _a = userConfig.MENU_CONF, userMenuConf = _a === void 0 ? {} : _a;
|
|
24368
24366
|
lodash_foreach(defaultMenuConf, function (menuConf, menuKey) {
|
|
24369
24367
|
// 生成新的 menu config
|
|
24370
|
-
newMenuConf[menuKey] = __assign$
|
|
24368
|
+
newMenuConf[menuKey] = __assign$5(__assign$5({}, menuConf), (userMenuConf[menuKey] || {}));
|
|
24371
24369
|
});
|
|
24372
24370
|
delete userConfig.MENU_CONF; // 处理完,则删掉 menuConf ,以防下面 merge 时造成干扰
|
|
24373
|
-
return __assign$
|
|
24371
|
+
return __assign$5({
|
|
24374
24372
|
// 默认配置
|
|
24375
24373
|
scroll: true, readOnly: false, autoFocus: true, decorate: function () { return []; }, maxLength: 0, MENU_CONF: newMenuConf, hoverbarKeys: {
|
|
24376
24374
|
// 'link': { menuKeys: ['editLink', 'unLink', 'viewLink'] },
|
|
@@ -24382,7 +24380,7 @@ function genEditorConfig(userConfig) {
|
|
|
24382
24380
|
* 生成 toolbar 默认配置
|
|
24383
24381
|
*/
|
|
24384
24382
|
function genToolbarConfig(userConfig) {
|
|
24385
|
-
return __assign$
|
|
24383
|
+
return __assign$5({
|
|
24386
24384
|
// 默认配置
|
|
24387
24385
|
toolbarKeys: [], excludeKeys: [], insertKeys: { index: 0, keys: [] }, modalAppendToBody: false }, (userConfig || {}));
|
|
24388
24386
|
}
|
|
@@ -24425,7 +24423,7 @@ function bindNodeRelation(node, index, parent, editor) {
|
|
|
24425
24423
|
function createEditor$1 (option) {
|
|
24426
24424
|
var _a = option.selector, selector = _a === void 0 ? '' : _a, _b = option.config, config = _b === void 0 ? {} : _b, content = option.content, html = option.html, _c = option.plugins, plugins = _c === void 0 ? [] : _c;
|
|
24427
24425
|
// 创建实例 - 使用插件
|
|
24428
|
-
var editor = withHistory(withMaxLength(withEmitter(withSelection(withContent(withConfig(withDOM(withEventData(createEditor$2()))))))));
|
|
24426
|
+
var editor = withHistory(withMaxLength(withEmitter(withSelection$1(withContent(withConfig(withDOM(withEventData(createEditor$2()))))))));
|
|
24429
24427
|
if (selector) {
|
|
24430
24428
|
// 检查是否对同一个 DOM 重复创建
|
|
24431
24429
|
if (isRepeatedCreateTextarea(editor, selector)) {
|
|
@@ -27782,15 +27780,15 @@ function __extends$1(d, b) {
|
|
|
27782
27780
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
27783
27781
|
}
|
|
27784
27782
|
|
|
27785
|
-
var __assign$
|
|
27786
|
-
__assign$
|
|
27783
|
+
var __assign$4 = function() {
|
|
27784
|
+
__assign$4 = Object.assign || function __assign(t) {
|
|
27787
27785
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
27788
27786
|
s = arguments[i];
|
|
27789
27787
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
27790
27788
|
}
|
|
27791
27789
|
return t;
|
|
27792
27790
|
};
|
|
27793
|
-
return __assign$
|
|
27791
|
+
return __assign$4.apply(this, arguments);
|
|
27794
27792
|
};
|
|
27795
27793
|
|
|
27796
27794
|
function __awaiter$2(thisArg, _arguments, P, generator) {
|
|
@@ -27803,7 +27801,7 @@ function __awaiter$2(thisArg, _arguments, P, generator) {
|
|
|
27803
27801
|
});
|
|
27804
27802
|
}
|
|
27805
27803
|
|
|
27806
|
-
function __generator$
|
|
27804
|
+
function __generator$3(thisArg, body) {
|
|
27807
27805
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27808
27806
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27809
27807
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -29439,7 +29437,7 @@ function replaceSymbols$1(str) {
|
|
|
29439
29437
|
function check$1(menuKey, editor, text, url) {
|
|
29440
29438
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
29441
29439
|
var checkLink, res;
|
|
29442
|
-
return __generator$
|
|
29440
|
+
return __generator$3(this, function (_a) {
|
|
29443
29441
|
switch (_a.label) {
|
|
29444
29442
|
case 0:
|
|
29445
29443
|
checkLink = editor.getMenuConfig(menuKey).checkLink;
|
|
@@ -29472,7 +29470,7 @@ function check$1(menuKey, editor, text, url) {
|
|
|
29472
29470
|
function parse(menuKey, editor, url) {
|
|
29473
29471
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
29474
29472
|
var parseLinkUrl, newUrl;
|
|
29475
|
-
return __generator$
|
|
29473
|
+
return __generator$3(this, function (_a) {
|
|
29476
29474
|
switch (_a.label) {
|
|
29477
29475
|
case 0:
|
|
29478
29476
|
parseLinkUrl = editor.getMenuConfig(menuKey).parseLinkUrl;
|
|
@@ -29523,7 +29521,7 @@ function genLinkNode(url, text) {
|
|
|
29523
29521
|
function insertLink(editor, text, url) {
|
|
29524
29522
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
29525
29523
|
var checkRes, parsedUrl, selection, isCollapsed, leftLength, linkNode, selectedText, leftLength, linkNode, linkNode;
|
|
29526
|
-
return __generator$
|
|
29524
|
+
return __generator$3(this, function (_a) {
|
|
29527
29525
|
switch (_a.label) {
|
|
29528
29526
|
case 0:
|
|
29529
29527
|
if (!url)
|
|
@@ -29604,7 +29602,7 @@ function insertLink(editor, text, url) {
|
|
|
29604
29602
|
function updateLink(editor, text, url) {
|
|
29605
29603
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
29606
29604
|
var checkRes, parsedUrl, props;
|
|
29607
|
-
return __generator$
|
|
29605
|
+
return __generator$3(this, function (_a) {
|
|
29608
29606
|
switch (_a.label) {
|
|
29609
29607
|
case 0:
|
|
29610
29608
|
if (!url)
|
|
@@ -30131,12 +30129,12 @@ function genContainerId(editor, elemNode) {
|
|
|
30131
30129
|
* 未选中时,渲染 image container
|
|
30132
30130
|
*/
|
|
30133
30131
|
function renderContainer(editor, elemNode, imageVnode, imageInfo) {
|
|
30134
|
-
var width = imageInfo.width
|
|
30132
|
+
var width = imageInfo.width; imageInfo.height;
|
|
30135
30133
|
var style = {};
|
|
30136
30134
|
if (width)
|
|
30137
30135
|
style.width = width;
|
|
30138
|
-
|
|
30139
|
-
|
|
30136
|
+
/** 不强制设置高度 */
|
|
30137
|
+
// if (height) style.height = height
|
|
30140
30138
|
var containerId = genContainerId(editor, elemNode);
|
|
30141
30139
|
return (jsx("div", { id: containerId, style: style, className: "w-e-image-container" }, imageVnode));
|
|
30142
30140
|
}
|
|
@@ -30146,10 +30144,11 @@ function renderContainer(editor, elemNode, imageVnode, imageInfo) {
|
|
|
30146
30144
|
function renderResizeContainer(editor, elemNode, imageVnode, imageInfo) {
|
|
30147
30145
|
var $body = $('body');
|
|
30148
30146
|
var containerId = genContainerId(editor, elemNode);
|
|
30149
|
-
var width = imageInfo.width
|
|
30147
|
+
var width = imageInfo.width; imageInfo.height;
|
|
30150
30148
|
var originalX = 0;
|
|
30151
30149
|
var originalWith = 0;
|
|
30152
30150
|
var originalHeight = 0;
|
|
30151
|
+
var maxWidth = 0; // 最大宽度
|
|
30153
30152
|
var revers = false; // 是否反转。如向右拖拽 right-top 需增加宽度(非反转),但向右拖拽 left-top 则需要减少宽度(反转)
|
|
30154
30153
|
var $container = null;
|
|
30155
30154
|
function getContainerElem() {
|
|
@@ -30161,10 +30160,11 @@ function renderResizeContainer(editor, elemNode, imageVnode, imageInfo) {
|
|
|
30161
30160
|
/**
|
|
30162
30161
|
* 初始化。监听事件,记录原始数据
|
|
30163
30162
|
*/
|
|
30164
|
-
function init(clientX) {
|
|
30163
|
+
function init(clientX, parentNodeWidth) {
|
|
30165
30164
|
$container = getContainerElem();
|
|
30166
30165
|
// 记录当前 x 坐标值
|
|
30167
30166
|
originalX = clientX;
|
|
30167
|
+
maxWidth = parentNodeWidth;
|
|
30168
30168
|
// 记录 img 原始宽高
|
|
30169
30169
|
var $img = $container.find('img');
|
|
30170
30170
|
if ($img.length === 0)
|
|
@@ -30187,13 +30187,18 @@ function renderResizeContainer(editor, elemNode, imageVnode, imageInfo) {
|
|
|
30187
30187
|
var gap = revers ? originalX - clientX : clientX - originalX; // 考虑是否反转
|
|
30188
30188
|
var newWidth = originalWith + gap;
|
|
30189
30189
|
var newHeight = originalHeight * (newWidth / originalWith); // 根据 width ,按比例计算 height
|
|
30190
|
+
/**
|
|
30191
|
+
* 图片有左右3px margin
|
|
30192
|
+
*/
|
|
30193
|
+
if (newWidth > maxWidth - 6)
|
|
30194
|
+
return; // 超过最大宽度,不处理
|
|
30190
30195
|
// 实时修改 img 宽高 -【注意】这里只修改 DOM ,mouseup 时再统一不修改 node
|
|
30191
30196
|
if ($container == null)
|
|
30192
30197
|
return;
|
|
30193
30198
|
if (newWidth <= 15 || newHeight <= 15)
|
|
30194
30199
|
return; // 最小就是 15px
|
|
30195
30200
|
$container.css('width', newWidth + "px");
|
|
30196
|
-
$container.css('height', newHeight
|
|
30201
|
+
// $container.css('height', `${newHeight}px`)
|
|
30197
30202
|
}, 100);
|
|
30198
30203
|
function onMouseup(e) {
|
|
30199
30204
|
// 取消监听 mousemove
|
|
@@ -30201,10 +30206,10 @@ function renderResizeContainer(editor, elemNode, imageVnode, imageInfo) {
|
|
|
30201
30206
|
if ($container == null)
|
|
30202
30207
|
return;
|
|
30203
30208
|
var newWidth = $container.width().toFixed(2);
|
|
30204
|
-
|
|
30209
|
+
// const newHeight = $container.height().toFixed(2)
|
|
30205
30210
|
// 修改 node
|
|
30206
30211
|
var props = {
|
|
30207
|
-
style: __assign$
|
|
30212
|
+
style: __assign$4(__assign$4({}, elemNode.style), { width: newWidth + "px" }),
|
|
30208
30213
|
};
|
|
30209
30214
|
Transforms.setNodes(editor, props, { at: DomEditor.findPath(editor, elemNode) });
|
|
30210
30215
|
// 取消监听 mouseup
|
|
@@ -30213,8 +30218,7 @@ function renderResizeContainer(editor, elemNode, imageVnode, imageInfo) {
|
|
|
30213
30218
|
var style = {};
|
|
30214
30219
|
if (width)
|
|
30215
30220
|
style.width = width;
|
|
30216
|
-
if (height)
|
|
30217
|
-
style.height = height;
|
|
30221
|
+
// if (height) style.height = height
|
|
30218
30222
|
// style.boxShadow = '0 0 0 1px #B4D5FF' // 自定义 selected 样式,因为有拖拽触手
|
|
30219
30223
|
return (jsx("div", { id: containerId, style: style, className: "w-e-image-container w-e-selected-image-container", on: {
|
|
30220
30224
|
// 统一绑定拖拽触手的 mousedown 事件
|
|
@@ -30228,7 +30232,20 @@ function renderResizeContainer(editor, elemNode, imageVnode, imageInfo) {
|
|
|
30228
30232
|
if ($target.hasClass('left-top') || $target.hasClass('left-bottom')) {
|
|
30229
30233
|
revers = true; // 反转。向右拖拽,减少宽度
|
|
30230
30234
|
}
|
|
30231
|
-
|
|
30235
|
+
// 获取 image 父容器宽度
|
|
30236
|
+
var parentNode = DomEditor.getParentNode(editor, elemNode);
|
|
30237
|
+
if (parentNode == null)
|
|
30238
|
+
return;
|
|
30239
|
+
var parentNodeDom = DomEditor.toDOMNode(editor, parentNode);
|
|
30240
|
+
var rect = parentNodeDom.getBoundingClientRect();
|
|
30241
|
+
// 获取元素的计算样式
|
|
30242
|
+
var style = window.getComputedStyle(parentNodeDom);
|
|
30243
|
+
// 获取左右 padding 和 border 的宽度
|
|
30244
|
+
var paddingLeft = parseFloat(style.paddingLeft);
|
|
30245
|
+
var paddingRight = parseFloat(style.paddingRight);
|
|
30246
|
+
var borderLeft = parseFloat(style.borderLeftWidth);
|
|
30247
|
+
var borderRight = parseFloat(style.borderRightWidth);
|
|
30248
|
+
init(e.clientX, rect.width - paddingLeft - paddingRight - borderLeft - borderRight); // 初始化
|
|
30232
30249
|
},
|
|
30233
30250
|
} },
|
|
30234
30251
|
imageVnode,
|
|
@@ -30241,7 +30258,7 @@ function renderImage(elemNode, children, editor) {
|
|
|
30241
30258
|
var _a = elemNode, src = _a.src, _b = _a.alt, alt = _b === void 0 ? '' : _b, _c = _a.href, href = _c === void 0 ? '' : _c, _d = _a.style, style = _d === void 0 ? {} : _d;
|
|
30242
30259
|
var _e = style.width, width = _e === void 0 ? '' : _e, _f = style.height, height = _f === void 0 ? '' : _f;
|
|
30243
30260
|
var selected = DomEditor.isNodeSelected(editor, elemNode); // 图片是否选中
|
|
30244
|
-
var imageStyle = {};
|
|
30261
|
+
var imageStyle = { maxWidth: '100%' };
|
|
30245
30262
|
if (width)
|
|
30246
30263
|
imageStyle.width = '100%';
|
|
30247
30264
|
if (height)
|
|
@@ -30316,7 +30333,7 @@ function check(menuKey, editor, src, alt, href) {
|
|
|
30316
30333
|
if (href === void 0) { href = ''; }
|
|
30317
30334
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
30318
30335
|
var checkImage, res;
|
|
30319
|
-
return __generator$
|
|
30336
|
+
return __generator$3(this, function (_a) {
|
|
30320
30337
|
switch (_a.label) {
|
|
30321
30338
|
case 0:
|
|
30322
30339
|
checkImage = editor.getMenuConfig(menuKey).checkImage;
|
|
@@ -30342,7 +30359,7 @@ function check(menuKey, editor, src, alt, href) {
|
|
|
30342
30359
|
function parseSrc(menuKey, editor, src) {
|
|
30343
30360
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
30344
30361
|
var parseImageSrc, newSrc;
|
|
30345
|
-
return __generator$
|
|
30362
|
+
return __generator$3(this, function (_a) {
|
|
30346
30363
|
switch (_a.label) {
|
|
30347
30364
|
case 0:
|
|
30348
30365
|
parseImageSrc = editor.getMenuConfig(menuKey).parseImageSrc;
|
|
@@ -30361,7 +30378,7 @@ function insertImageNode(editor, src, alt, href) {
|
|
|
30361
30378
|
if (href === void 0) { href = ''; }
|
|
30362
30379
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
30363
30380
|
var res, parsedSrc, image, onInsertedImage;
|
|
30364
|
-
return __generator$
|
|
30381
|
+
return __generator$3(this, function (_a) {
|
|
30365
30382
|
switch (_a.label) {
|
|
30366
30383
|
case 0: return [4 /*yield*/, check('insertImage', editor, src, alt, href)];
|
|
30367
30384
|
case 1:
|
|
@@ -30406,7 +30423,7 @@ function updateImageNode(editor, src, alt, href, style) {
|
|
|
30406
30423
|
if (style === void 0) { style = {}; }
|
|
30407
30424
|
return __awaiter$2(this, void 0, void 0, function () {
|
|
30408
30425
|
var res, parsedSrc, selectedImageNode, _a, curStyle, nodeProps, imageNode, onUpdatedImage;
|
|
30409
|
-
return __generator$
|
|
30426
|
+
return __generator$3(this, function (_b) {
|
|
30410
30427
|
switch (_b.label) {
|
|
30411
30428
|
case 0: return [4 /*yield*/, check('editImage', editor, src, alt, href)];
|
|
30412
30429
|
case 1:
|
|
@@ -30424,7 +30441,7 @@ function updateImageNode(editor, src, alt, href, style) {
|
|
|
30424
30441
|
src: parsedSrc,
|
|
30425
30442
|
alt: alt,
|
|
30426
30443
|
href: href,
|
|
30427
|
-
style: __assign$
|
|
30444
|
+
style: __assign$4(__assign$4({}, curStyle), style),
|
|
30428
30445
|
};
|
|
30429
30446
|
Transforms.setNodes(editor, nodeProps, {
|
|
30430
30447
|
match: function (n) { return DomEditor.checkNodeType(n, 'image'); },
|
|
@@ -30814,7 +30831,7 @@ var ImageWidthBaseClass = /** @class */ (function () {
|
|
|
30814
30831
|
hoverbar.hideAndClean();
|
|
30815
30832
|
var _a = imageNode.style, style = _a === void 0 ? {} : _a;
|
|
30816
30833
|
var props = {
|
|
30817
|
-
style: __assign$
|
|
30834
|
+
style: __assign$4(__assign$4({}, style), { width: this.value, height: '' }),
|
|
30818
30835
|
};
|
|
30819
30836
|
Transforms.setNodes(editor, props, {
|
|
30820
30837
|
match: function (n) { return DomEditor.checkNodeType(n, 'image'); },
|
|
@@ -30951,7 +30968,7 @@ var EditorImageSizeMenu = /** @class */ (function () {
|
|
|
30951
30968
|
}
|
|
30952
30969
|
var _a = imageNode.style, style = _a === void 0 ? {} : _a;
|
|
30953
30970
|
editor.restoreSelection();
|
|
30954
|
-
var props = __assign$
|
|
30971
|
+
var props = __assign$4(__assign$4({}, style), { style: {
|
|
30955
30972
|
width: width,
|
|
30956
30973
|
height: height,
|
|
30957
30974
|
} });
|
|
@@ -31462,7 +31479,7 @@ function withBlockquote(editor) {
|
|
|
31462
31479
|
var quoteElem = nodeEntry[0];
|
|
31463
31480
|
var quotePath = DomEditor.findPath(editor, quoteElem);
|
|
31464
31481
|
var quoteEndLocation = Editor.end(editor, quotePath);
|
|
31465
|
-
if (Point.equals(quoteEndLocation, selection.focus)) {
|
|
31482
|
+
if (Point$1.equals(quoteEndLocation, selection.focus)) {
|
|
31466
31483
|
// 光标位于 blockquote 最后
|
|
31467
31484
|
var str = Node$1.string(quoteElem);
|
|
31468
31485
|
if (str && str.slice(-1) === '\n') {
|
|
@@ -33626,8 +33643,27 @@ function getTopSelectedElemsBySelection(editor) {
|
|
|
33626
33643
|
});
|
|
33627
33644
|
}
|
|
33628
33645
|
function withList(editor) {
|
|
33629
|
-
var deleteBackward = editor.deleteBackward, handleTab = editor.handleTab, normalizeNode = editor.normalizeNode;
|
|
33646
|
+
var deleteBackward = editor.deleteBackward, handleTab = editor.handleTab, normalizeNode = editor.normalizeNode, insertBreak = editor.insertBreak;
|
|
33630
33647
|
var newEditor = editor;
|
|
33648
|
+
// 重写 insertBreak - 空 list 点击回车时删除该空 list
|
|
33649
|
+
newEditor.insertBreak = function () {
|
|
33650
|
+
var _a = __read$4(Editor.nodes(editor, {
|
|
33651
|
+
match: function (n) { return DomEditor.checkNodeType(n, 'list-item'); },
|
|
33652
|
+
universal: true,
|
|
33653
|
+
}), 1), nodeEntry = _a[0];
|
|
33654
|
+
if (!nodeEntry)
|
|
33655
|
+
return insertBreak();
|
|
33656
|
+
var listElem = nodeEntry[0];
|
|
33657
|
+
if (listElem.children[0].text === '') {
|
|
33658
|
+
Transforms.setNodes(newEditor, {
|
|
33659
|
+
type: 'paragraph',
|
|
33660
|
+
ordered: undefined,
|
|
33661
|
+
level: undefined,
|
|
33662
|
+
});
|
|
33663
|
+
return;
|
|
33664
|
+
}
|
|
33665
|
+
return insertBreak();
|
|
33666
|
+
};
|
|
33631
33667
|
// 重写 deleteBackward - 降低 level 或者转换为 p 元素
|
|
33632
33668
|
newEditor.deleteBackward = function (unit) {
|
|
33633
33669
|
var selection = newEditor.selection;
|
|
@@ -34122,1941 +34158,496 @@ var list = {
|
|
|
34122
34158
|
parseElemsHtml: [parseListHtmlConf, parseItemHtmlConf],
|
|
34123
34159
|
};
|
|
34124
34160
|
|
|
34125
|
-
/**
|
|
34126
|
-
*
|
|
34127
|
-
*
|
|
34128
|
-
|
|
34129
|
-
|
|
34130
|
-
|
|
34131
|
-
|
|
34132
|
-
|
|
34133
|
-
|
|
34134
|
-
|
|
34135
|
-
|
|
34136
|
-
|
|
34137
|
-
|
|
34138
|
-
|
|
34139
|
-
|
|
34140
|
-
|
|
34141
|
-
|
|
34142
|
-
|
|
34143
|
-
COMPARE_UNORDERED_FLAG = 2;
|
|
34144
|
-
|
|
34145
|
-
/** Used as references for various `Number` constants. */
|
|
34146
|
-
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
34147
|
-
|
|
34148
|
-
/** `Object#toString` result references. */
|
|
34149
|
-
var argsTag = '[object Arguments]',
|
|
34150
|
-
arrayTag = '[object Array]',
|
|
34151
|
-
asyncTag = '[object AsyncFunction]',
|
|
34152
|
-
boolTag = '[object Boolean]',
|
|
34153
|
-
dateTag = '[object Date]',
|
|
34154
|
-
errorTag = '[object Error]',
|
|
34155
|
-
funcTag = '[object Function]',
|
|
34156
|
-
genTag = '[object GeneratorFunction]',
|
|
34157
|
-
mapTag = '[object Map]',
|
|
34158
|
-
numberTag = '[object Number]',
|
|
34159
|
-
nullTag = '[object Null]',
|
|
34160
|
-
objectTag = '[object Object]',
|
|
34161
|
-
promiseTag = '[object Promise]',
|
|
34162
|
-
proxyTag = '[object Proxy]',
|
|
34163
|
-
regexpTag = '[object RegExp]',
|
|
34164
|
-
setTag = '[object Set]',
|
|
34165
|
-
stringTag = '[object String]',
|
|
34166
|
-
symbolTag = '[object Symbol]',
|
|
34167
|
-
undefinedTag = '[object Undefined]',
|
|
34168
|
-
weakMapTag = '[object WeakMap]';
|
|
34169
|
-
|
|
34170
|
-
var arrayBufferTag = '[object ArrayBuffer]',
|
|
34171
|
-
dataViewTag = '[object DataView]',
|
|
34172
|
-
float32Tag = '[object Float32Array]',
|
|
34173
|
-
float64Tag = '[object Float64Array]',
|
|
34174
|
-
int8Tag = '[object Int8Array]',
|
|
34175
|
-
int16Tag = '[object Int16Array]',
|
|
34176
|
-
int32Tag = '[object Int32Array]',
|
|
34177
|
-
uint8Tag = '[object Uint8Array]',
|
|
34178
|
-
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|
34179
|
-
uint16Tag = '[object Uint16Array]',
|
|
34180
|
-
uint32Tag = '[object Uint32Array]';
|
|
34181
|
-
|
|
34182
|
-
/**
|
|
34183
|
-
* Used to match `RegExp`
|
|
34184
|
-
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
34185
|
-
*/
|
|
34186
|
-
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
34187
|
-
|
|
34188
|
-
/** Used to detect host constructors (Safari). */
|
|
34189
|
-
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
34190
|
-
|
|
34191
|
-
/** Used to detect unsigned integer values. */
|
|
34192
|
-
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
34193
|
-
|
|
34194
|
-
/** Used to identify `toStringTag` values of typed arrays. */
|
|
34195
|
-
var typedArrayTags = {};
|
|
34196
|
-
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
|
34197
|
-
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
|
34198
|
-
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
|
34199
|
-
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
|
34200
|
-
typedArrayTags[uint32Tag] = true;
|
|
34201
|
-
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
|
34202
|
-
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
|
34203
|
-
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
|
34204
|
-
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
|
|
34205
|
-
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
|
|
34206
|
-
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
|
|
34207
|
-
typedArrayTags[setTag] = typedArrayTags[stringTag] =
|
|
34208
|
-
typedArrayTags[weakMapTag] = false;
|
|
34209
|
-
|
|
34210
|
-
/** Detect free variable `global` from Node.js. */
|
|
34211
|
-
var freeGlobal = typeof commonjsGlobal$1 == 'object' && commonjsGlobal$1 && commonjsGlobal$1.Object === Object && commonjsGlobal$1;
|
|
34212
|
-
|
|
34213
|
-
/** Detect free variable `self`. */
|
|
34214
|
-
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
34215
|
-
|
|
34216
|
-
/** Used as a reference to the global object. */
|
|
34217
|
-
var root = freeGlobal || freeSelf || Function('return this')();
|
|
34218
|
-
|
|
34219
|
-
/** Detect free variable `exports`. */
|
|
34220
|
-
var freeExports = exports && !exports.nodeType && exports;
|
|
34221
|
-
|
|
34222
|
-
/** Detect free variable `module`. */
|
|
34223
|
-
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
34224
|
-
|
|
34225
|
-
/** Detect the popular CommonJS extension `module.exports`. */
|
|
34226
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
34227
|
-
|
|
34228
|
-
/** Detect free variable `process` from Node.js. */
|
|
34229
|
-
var freeProcess = moduleExports && freeGlobal.process;
|
|
34230
|
-
|
|
34231
|
-
/** Used to access faster Node.js helpers. */
|
|
34232
|
-
var nodeUtil = (function() {
|
|
34233
|
-
try {
|
|
34234
|
-
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
34235
|
-
} catch (e) {}
|
|
34236
|
-
}());
|
|
34237
|
-
|
|
34238
|
-
/* Node.js helper references. */
|
|
34239
|
-
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
34240
|
-
|
|
34241
|
-
/**
|
|
34242
|
-
* A specialized version of `_.filter` for arrays without support for
|
|
34243
|
-
* iteratee shorthands.
|
|
34244
|
-
*
|
|
34245
|
-
* @private
|
|
34246
|
-
* @param {Array} [array] The array to iterate over.
|
|
34247
|
-
* @param {Function} predicate The function invoked per iteration.
|
|
34248
|
-
* @returns {Array} Returns the new filtered array.
|
|
34249
|
-
*/
|
|
34250
|
-
function arrayFilter(array, predicate) {
|
|
34251
|
-
var index = -1,
|
|
34252
|
-
length = array == null ? 0 : array.length,
|
|
34253
|
-
resIndex = 0,
|
|
34254
|
-
result = [];
|
|
34255
|
-
|
|
34256
|
-
while (++index < length) {
|
|
34257
|
-
var value = array[index];
|
|
34258
|
-
if (predicate(value, index, array)) {
|
|
34259
|
-
result[resIndex++] = value;
|
|
34260
|
-
}
|
|
34261
|
-
}
|
|
34262
|
-
return result;
|
|
34263
|
-
}
|
|
34264
|
-
|
|
34265
|
-
/**
|
|
34266
|
-
* Appends the elements of `values` to `array`.
|
|
34267
|
-
*
|
|
34268
|
-
* @private
|
|
34269
|
-
* @param {Array} array The array to modify.
|
|
34270
|
-
* @param {Array} values The values to append.
|
|
34271
|
-
* @returns {Array} Returns `array`.
|
|
34272
|
-
*/
|
|
34273
|
-
function arrayPush(array, values) {
|
|
34274
|
-
var index = -1,
|
|
34275
|
-
length = values.length,
|
|
34276
|
-
offset = array.length;
|
|
34277
|
-
|
|
34278
|
-
while (++index < length) {
|
|
34279
|
-
array[offset + index] = values[index];
|
|
34280
|
-
}
|
|
34281
|
-
return array;
|
|
34282
|
-
}
|
|
34283
|
-
|
|
34284
|
-
/**
|
|
34285
|
-
* A specialized version of `_.some` for arrays without support for iteratee
|
|
34286
|
-
* shorthands.
|
|
34287
|
-
*
|
|
34288
|
-
* @private
|
|
34289
|
-
* @param {Array} [array] The array to iterate over.
|
|
34290
|
-
* @param {Function} predicate The function invoked per iteration.
|
|
34291
|
-
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|
34292
|
-
* else `false`.
|
|
34293
|
-
*/
|
|
34294
|
-
function arraySome(array, predicate) {
|
|
34295
|
-
var index = -1,
|
|
34296
|
-
length = array == null ? 0 : array.length;
|
|
34297
|
-
|
|
34298
|
-
while (++index < length) {
|
|
34299
|
-
if (predicate(array[index], index, array)) {
|
|
34300
|
-
return true;
|
|
34301
|
-
}
|
|
34302
|
-
}
|
|
34303
|
-
return false;
|
|
34304
|
-
}
|
|
34305
|
-
|
|
34306
|
-
/**
|
|
34307
|
-
* The base implementation of `_.times` without support for iteratee shorthands
|
|
34308
|
-
* or max array length checks.
|
|
34309
|
-
*
|
|
34310
|
-
* @private
|
|
34311
|
-
* @param {number} n The number of times to invoke `iteratee`.
|
|
34312
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
34313
|
-
* @returns {Array} Returns the array of results.
|
|
34314
|
-
*/
|
|
34315
|
-
function baseTimes(n, iteratee) {
|
|
34316
|
-
var index = -1,
|
|
34317
|
-
result = Array(n);
|
|
34318
|
-
|
|
34319
|
-
while (++index < n) {
|
|
34320
|
-
result[index] = iteratee(index);
|
|
34321
|
-
}
|
|
34322
|
-
return result;
|
|
34323
|
-
}
|
|
34161
|
+
/**
|
|
34162
|
+
* @description i18n en
|
|
34163
|
+
* @author wangfupeng
|
|
34164
|
+
*/
|
|
34165
|
+
var enResources$3 = {
|
|
34166
|
+
tableModule: {
|
|
34167
|
+
deleteCol: 'Delete column',
|
|
34168
|
+
deleteRow: 'Delete row',
|
|
34169
|
+
deleteTable: 'Delete table',
|
|
34170
|
+
widthAuto: 'Width auto',
|
|
34171
|
+
insertCol: 'Insert column',
|
|
34172
|
+
insertRow: 'Insert row',
|
|
34173
|
+
insertTable: 'Insert table',
|
|
34174
|
+
header: 'Header',
|
|
34175
|
+
mergeCell: 'merge cell',
|
|
34176
|
+
splitCell: 'split cell',
|
|
34177
|
+
},
|
|
34178
|
+
};
|
|
34324
34179
|
|
|
34325
|
-
/**
|
|
34326
|
-
*
|
|
34327
|
-
*
|
|
34328
|
-
|
|
34329
|
-
|
|
34330
|
-
|
|
34331
|
-
|
|
34332
|
-
|
|
34333
|
-
|
|
34334
|
-
|
|
34335
|
-
|
|
34336
|
-
|
|
34180
|
+
/**
|
|
34181
|
+
* @description i18n zh-CN
|
|
34182
|
+
* @author wangfupeng
|
|
34183
|
+
*/
|
|
34184
|
+
var zhResources$3 = {
|
|
34185
|
+
tableModule: {
|
|
34186
|
+
deleteCol: '删除列',
|
|
34187
|
+
deleteRow: '删除行',
|
|
34188
|
+
deleteTable: '删除表格',
|
|
34189
|
+
widthAuto: '宽度自适应',
|
|
34190
|
+
insertCol: '插入列',
|
|
34191
|
+
insertRow: '插入行',
|
|
34192
|
+
insertTable: '插入表格',
|
|
34193
|
+
header: '表头',
|
|
34194
|
+
mergeCell: '合并单元格',
|
|
34195
|
+
splitCell: '拆分单元格',
|
|
34196
|
+
},
|
|
34197
|
+
};
|
|
34337
34198
|
|
|
34338
|
-
/**
|
|
34339
|
-
*
|
|
34340
|
-
*
|
|
34341
|
-
|
|
34342
|
-
|
|
34343
|
-
|
|
34344
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
34345
|
-
*/
|
|
34346
|
-
function cacheHas(cache, key) {
|
|
34347
|
-
return cache.has(key);
|
|
34348
|
-
}
|
|
34199
|
+
/**
|
|
34200
|
+
* @description i18n entry
|
|
34201
|
+
* @author wangfupeng
|
|
34202
|
+
*/
|
|
34203
|
+
i18nAddResources('en', enResources$3);
|
|
34204
|
+
i18nAddResources('zh-CN', zhResources$3);
|
|
34349
34205
|
|
|
34350
|
-
|
|
34351
|
-
|
|
34352
|
-
|
|
34353
|
-
|
|
34354
|
-
|
|
34355
|
-
|
|
34356
|
-
|
|
34357
|
-
|
|
34358
|
-
|
|
34359
|
-
|
|
34206
|
+
/*! *****************************************************************************
|
|
34207
|
+
Copyright (c) Microsoft Corporation.
|
|
34208
|
+
|
|
34209
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
34210
|
+
purpose with or without fee is hereby granted.
|
|
34211
|
+
|
|
34212
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
34213
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
34214
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
34215
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
34216
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
34217
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
34218
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
34219
|
+
***************************************************************************** */
|
|
34220
|
+
|
|
34221
|
+
var __assign$3 = function() {
|
|
34222
|
+
__assign$3 = Object.assign || function __assign(t) {
|
|
34223
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
34224
|
+
s = arguments[i];
|
|
34225
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
34226
|
+
}
|
|
34227
|
+
return t;
|
|
34228
|
+
};
|
|
34229
|
+
return __assign$3.apply(this, arguments);
|
|
34230
|
+
};
|
|
34231
|
+
|
|
34232
|
+
function __generator$2(thisArg, body) {
|
|
34233
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
34234
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
34235
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34236
|
+
function step(op) {
|
|
34237
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
34238
|
+
while (_) try {
|
|
34239
|
+
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;
|
|
34240
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34241
|
+
switch (op[0]) {
|
|
34242
|
+
case 0: case 1: t = op; break;
|
|
34243
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34244
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34245
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
34246
|
+
default:
|
|
34247
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
34248
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
34249
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
34250
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
34251
|
+
if (t[2]) _.ops.pop();
|
|
34252
|
+
_.trys.pop(); continue;
|
|
34253
|
+
}
|
|
34254
|
+
op = body.call(thisArg, _);
|
|
34255
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34256
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
34257
|
+
}
|
|
34258
|
+
}
|
|
34259
|
+
|
|
34260
|
+
function __values$3(o) {
|
|
34261
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
34262
|
+
if (m) return m.call(o);
|
|
34263
|
+
if (o && typeof o.length === "number") return {
|
|
34264
|
+
next: function () {
|
|
34265
|
+
if (o && i >= o.length) o = void 0;
|
|
34266
|
+
return { value: o && o[i++], done: !o };
|
|
34267
|
+
}
|
|
34268
|
+
};
|
|
34269
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
34270
|
+
}
|
|
34271
|
+
|
|
34272
|
+
function __read$3(o, n) {
|
|
34273
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
34274
|
+
if (!m) return o;
|
|
34275
|
+
var i = m.call(o), r, ar = [], e;
|
|
34276
|
+
try {
|
|
34277
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
34278
|
+
}
|
|
34279
|
+
catch (error) { e = { error: error }; }
|
|
34280
|
+
finally {
|
|
34281
|
+
try {
|
|
34282
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
34283
|
+
}
|
|
34284
|
+
finally { if (e) throw e.error; }
|
|
34285
|
+
}
|
|
34286
|
+
return ar;
|
|
34287
|
+
}
|
|
34288
|
+
|
|
34289
|
+
function __spreadArray(to, from) {
|
|
34290
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
34291
|
+
to[j] = from[i];
|
|
34292
|
+
return to;
|
|
34360
34293
|
}
|
|
34361
34294
|
|
|
34362
|
-
/**
|
|
34363
|
-
|
|
34364
|
-
|
|
34365
|
-
|
|
34366
|
-
|
|
34367
|
-
|
|
34368
|
-
|
|
34369
|
-
|
|
34370
|
-
|
|
34371
|
-
|
|
34295
|
+
/** Weak reference between the `Editor` and the selected elements */
|
|
34296
|
+
var EDITOR_TO_SELECTION = new WeakMap();
|
|
34297
|
+
/** Weak reference between the `Editor` and a set of the selected elements */
|
|
34298
|
+
var EDITOR_TO_SELECTION_SET = new WeakMap();
|
|
34299
|
+
|
|
34300
|
+
var DEFAULT_WITH_TABLE_OPTIONS = {
|
|
34301
|
+
blocks: {
|
|
34302
|
+
td: 'table-cell',
|
|
34303
|
+
th: 'table-cell',
|
|
34304
|
+
content: 'paragraph',
|
|
34305
|
+
tr: 'table-row',
|
|
34306
|
+
table: 'table',
|
|
34307
|
+
tbody: 'table-body',
|
|
34308
|
+
// tfoot: "table-footer",
|
|
34309
|
+
// thead: "table-head",
|
|
34310
|
+
},
|
|
34311
|
+
};
|
|
34372
34312
|
|
|
34373
|
-
|
|
34374
|
-
|
|
34375
|
-
|
|
34376
|
-
|
|
34313
|
+
function isElement(node) {
|
|
34314
|
+
return !Editor.isEditor(node) && Element$1.isElement(node) && 'type' in node;
|
|
34315
|
+
}
|
|
34316
|
+
/** @returns a `NodeMatch` function which is used to match the elements of a specific `type`. */
|
|
34317
|
+
function isOfType(editor) {
|
|
34318
|
+
var types = [];
|
|
34319
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
34320
|
+
types[_i - 1] = arguments[_i];
|
|
34321
|
+
}
|
|
34322
|
+
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]; });
|
|
34323
|
+
return function (node) { return isElement(node) && elementTypes.includes(node.type); };
|
|
34377
34324
|
}
|
|
34378
34325
|
|
|
34379
|
-
/**
|
|
34380
|
-
*
|
|
34381
|
-
*
|
|
34382
|
-
|
|
34383
|
-
|
|
34384
|
-
|
|
34385
|
-
|
|
34386
|
-
|
|
34387
|
-
|
|
34388
|
-
|
|
34389
|
-
|
|
34390
|
-
|
|
34326
|
+
/**
|
|
34327
|
+
* Determines whether two paths belong to the same types by checking
|
|
34328
|
+
* if they share a common ancestor node of type table
|
|
34329
|
+
*/
|
|
34330
|
+
function hasCommon(editor, _a) {
|
|
34331
|
+
var _b = __read$3(_a, 2), path = _b[0], another = _b[1];
|
|
34332
|
+
var types = [];
|
|
34333
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
34334
|
+
types[_i - 2] = arguments[_i];
|
|
34335
|
+
}
|
|
34336
|
+
var _c = __read$3(Node$1.common(editor, path, another), 2), node = _c[0], commonPath = _c[1];
|
|
34337
|
+
if (isOfType.apply(void 0, __spreadArray([editor], __read$3(types)))(node, commonPath)) {
|
|
34338
|
+
return true;
|
|
34339
|
+
}
|
|
34340
|
+
// Warning: returns the common ancestor but will return `undefined` if the
|
|
34341
|
+
// `commonPath` is equal to the specified types path
|
|
34342
|
+
return !!Editor.above(editor, {
|
|
34343
|
+
match: isOfType.apply(void 0, __spreadArray([editor], __read$3(types))),
|
|
34344
|
+
at: commonPath,
|
|
34345
|
+
});
|
|
34391
34346
|
}
|
|
34392
34347
|
|
|
34393
|
-
/**
|
|
34394
|
-
|
|
34395
|
-
|
|
34396
|
-
|
|
34397
|
-
|
|
34398
|
-
|
|
34399
|
-
|
|
34400
|
-
|
|
34401
|
-
|
|
34402
|
-
|
|
34403
|
-
|
|
34404
|
-
|
|
34405
|
-
|
|
34406
|
-
|
|
34407
|
-
|
|
34348
|
+
/** Generates a matrix for each table section (`thead`, `tbody`, `tfoot`) */
|
|
34349
|
+
function matrices(editor, options) {
|
|
34350
|
+
var _a, table, _b, tablePath, _c, _d, _e, path, matrix, _f, _g, _h, trPath, e_1_1;
|
|
34351
|
+
var e_1, _j, e_2, _k;
|
|
34352
|
+
if (options === void 0) { options = {}; }
|
|
34353
|
+
return __generator$2(this, function (_l) {
|
|
34354
|
+
switch (_l.label) {
|
|
34355
|
+
case 0:
|
|
34356
|
+
_a = __read$3(Editor.nodes(editor, {
|
|
34357
|
+
match: isOfType(editor, 'table'),
|
|
34358
|
+
at: options.at,
|
|
34359
|
+
}), 1), table = _a[0];
|
|
34360
|
+
if (!table) {
|
|
34361
|
+
return [2 /*return*/, []];
|
|
34362
|
+
}
|
|
34363
|
+
_b = __read$3(table, 2), tablePath = _b[1];
|
|
34364
|
+
_l.label = 1;
|
|
34365
|
+
case 1:
|
|
34366
|
+
_l.trys.push([1, 6, 7, 8]);
|
|
34367
|
+
_c = __values$3(Editor.nodes(editor, {
|
|
34368
|
+
// match: isOfType(editor, "thead", "tbody", "tfoot"),
|
|
34369
|
+
match: isOfType(editor, 'table'),
|
|
34370
|
+
at: tablePath,
|
|
34371
|
+
})), _d = _c.next();
|
|
34372
|
+
_l.label = 2;
|
|
34373
|
+
case 2:
|
|
34374
|
+
if (!!_d.done) return [3 /*break*/, 5];
|
|
34375
|
+
_e = __read$3(_d.value, 2), path = _e[1];
|
|
34376
|
+
matrix = [];
|
|
34377
|
+
try {
|
|
34378
|
+
for (_f = (e_2 = void 0, __values$3(Editor.nodes(editor, {
|
|
34379
|
+
match: isOfType(editor, 'tr'),
|
|
34380
|
+
at: path,
|
|
34381
|
+
}))), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
34382
|
+
_h = __read$3(_g.value, 2), trPath = _h[1];
|
|
34383
|
+
matrix.push(__spreadArray([], __read$3(Editor.nodes(editor, {
|
|
34384
|
+
match: isOfType(editor, 'th', 'td'),
|
|
34385
|
+
at: trPath,
|
|
34386
|
+
}))));
|
|
34387
|
+
}
|
|
34388
|
+
}
|
|
34389
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
34390
|
+
finally {
|
|
34391
|
+
try {
|
|
34392
|
+
if (_g && !_g.done && (_k = _f.return)) _k.call(_f);
|
|
34393
|
+
}
|
|
34394
|
+
finally { if (e_2) throw e_2.error; }
|
|
34395
|
+
}
|
|
34396
|
+
return [4 /*yield*/, matrix];
|
|
34397
|
+
case 3:
|
|
34398
|
+
_l.sent();
|
|
34399
|
+
_l.label = 4;
|
|
34400
|
+
case 4:
|
|
34401
|
+
_d = _c.next();
|
|
34402
|
+
return [3 /*break*/, 2];
|
|
34403
|
+
case 5: return [3 /*break*/, 8];
|
|
34404
|
+
case 6:
|
|
34405
|
+
e_1_1 = _l.sent();
|
|
34406
|
+
e_1 = { error: e_1_1 };
|
|
34407
|
+
return [3 /*break*/, 8];
|
|
34408
|
+
case 7:
|
|
34409
|
+
try {
|
|
34410
|
+
if (_d && !_d.done && (_j = _c.return)) _j.call(_c);
|
|
34411
|
+
}
|
|
34412
|
+
finally { if (e_1) throw e_1.error; }
|
|
34413
|
+
return [7 /*endfinally*/];
|
|
34414
|
+
case 8: return [2 /*return*/];
|
|
34415
|
+
}
|
|
34416
|
+
});
|
|
34417
|
+
}
|
|
34418
|
+
function filledMatrix(editor, options) {
|
|
34419
|
+
var e_3, _a;
|
|
34420
|
+
if (options === void 0) { options = {}; }
|
|
34421
|
+
var filled = [];
|
|
34422
|
+
try {
|
|
34423
|
+
// Expand each section separately to avoid sections collapsing into each other.
|
|
34424
|
+
for (var _b = __values$3(matrices(editor, { at: options.at })), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
34425
|
+
var matrix = _c.value;
|
|
34426
|
+
var filledSection = [];
|
|
34427
|
+
for (var x = 0; x < matrix.length; x++) {
|
|
34428
|
+
if (!filledSection[x]) {
|
|
34429
|
+
filledSection[x] = [];
|
|
34430
|
+
}
|
|
34431
|
+
for (var y = 0; y < matrix[x].length; y++) {
|
|
34432
|
+
var _d = __read$3(matrix[x][y], 1), _e = _d[0], _f = _e.rowSpan, rowSpan = _f === void 0 ? 1 : _f, _g = _e.colSpan, colSpan = _g === void 0 ? 1 : _g;
|
|
34433
|
+
for (var c = 0, occupied = 0; c < colSpan + occupied; c++) {
|
|
34434
|
+
for (var r = 0; r < rowSpan; r++) {
|
|
34435
|
+
if (!filledSection[x + r]) {
|
|
34436
|
+
filledSection[x + r] = [];
|
|
34437
|
+
}
|
|
34438
|
+
if (filledSection[x + r][y + c]) {
|
|
34439
|
+
continue;
|
|
34440
|
+
}
|
|
34441
|
+
filledSection[x + r][y + c] = [
|
|
34442
|
+
matrix[x + r][y + c],
|
|
34443
|
+
{
|
|
34444
|
+
rtl: c - occupied + 1,
|
|
34445
|
+
ltr: colSpan - c + occupied,
|
|
34446
|
+
ttb: r + 1,
|
|
34447
|
+
btt: rowSpan - r,
|
|
34448
|
+
},
|
|
34449
|
+
];
|
|
34450
|
+
}
|
|
34451
|
+
}
|
|
34452
|
+
}
|
|
34453
|
+
}
|
|
34454
|
+
filled.push.apply(filled, __spreadArray([], __read$3(filledSection)));
|
|
34455
|
+
}
|
|
34456
|
+
}
|
|
34457
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
34458
|
+
finally {
|
|
34459
|
+
try {
|
|
34460
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
34461
|
+
}
|
|
34462
|
+
finally { if (e_3) throw e_3.error; }
|
|
34463
|
+
}
|
|
34464
|
+
return filled;
|
|
34408
34465
|
}
|
|
34409
34466
|
|
|
34410
|
-
/**
|
|
34411
|
-
|
|
34412
|
-
|
|
34413
|
-
|
|
34414
|
-
|
|
34415
|
-
|
|
34416
|
-
|
|
34417
|
-
|
|
34418
|
-
|
|
34419
|
-
|
|
34420
|
-
|
|
34421
|
-
|
|
34422
|
-
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
34423
|
-
|
|
34424
|
-
/** Used to detect methods masquerading as native. */
|
|
34425
|
-
var maskSrcKey = (function() {
|
|
34426
|
-
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
34427
|
-
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
34467
|
+
var Point = /** @class */ (function () {
|
|
34468
|
+
function Point(x, y) {
|
|
34469
|
+
this.x = x;
|
|
34470
|
+
this.y = y;
|
|
34471
|
+
}
|
|
34472
|
+
Point.valueOf = function (x, y) {
|
|
34473
|
+
return new this(x, y);
|
|
34474
|
+
};
|
|
34475
|
+
Point.equals = function (point, another) {
|
|
34476
|
+
return point.x === another.x && point.y === another.y;
|
|
34477
|
+
};
|
|
34478
|
+
return Point;
|
|
34428
34479
|
}());
|
|
34429
34480
|
|
|
34430
|
-
|
|
34431
|
-
|
|
34432
|
-
|
|
34433
|
-
|
|
34434
|
-
|
|
34435
|
-
|
|
34436
|
-
|
|
34437
|
-
|
|
34438
|
-
|
|
34439
|
-
|
|
34440
|
-
|
|
34441
|
-
|
|
34442
|
-
|
|
34443
|
-
|
|
34444
|
-
|
|
34445
|
-
|
|
34446
|
-
|
|
34447
|
-
|
|
34448
|
-
|
|
34449
|
-
|
|
34481
|
+
var TableCursor = {
|
|
34482
|
+
/** @returns {boolean} `true` if the selection is inside a table, otherwise `false`. */
|
|
34483
|
+
isInTable: function (editor, options) {
|
|
34484
|
+
if (options === void 0) { options = {}; }
|
|
34485
|
+
var _a = __read$3(Editor.nodes(editor, {
|
|
34486
|
+
match: isOfType(editor, 'table'),
|
|
34487
|
+
at: options.at,
|
|
34488
|
+
}), 1), table = _a[0];
|
|
34489
|
+
return !!table;
|
|
34490
|
+
},
|
|
34491
|
+
/**
|
|
34492
|
+
* Retrieves a matrix representing the selected cells within a table.
|
|
34493
|
+
* @returns {NodeEntry<T>[][]} A matrix containing the selected cells.
|
|
34494
|
+
*/
|
|
34495
|
+
selection: function (editor) {
|
|
34496
|
+
var matrix, x, cells, y, _a, entry, _b, colSpan, ttb;
|
|
34497
|
+
return __generator$2(this, function (_c) {
|
|
34498
|
+
switch (_c.label) {
|
|
34499
|
+
case 0:
|
|
34500
|
+
matrix = EDITOR_TO_SELECTION.get(editor);
|
|
34501
|
+
x = 0;
|
|
34502
|
+
_c.label = 1;
|
|
34503
|
+
case 1:
|
|
34504
|
+
if (!(matrix && x < matrix.length)) return [3 /*break*/, 4];
|
|
34505
|
+
cells = [];
|
|
34506
|
+
for (y = 0; y < matrix[x].length; y++) {
|
|
34507
|
+
_a = __read$3(matrix[x][y], 2), entry = _a[0], _b = _a[1], colSpan = _b.ltr, ttb = _b.ttb;
|
|
34508
|
+
ttb === 1 && cells.push(entry);
|
|
34509
|
+
y += colSpan - 1;
|
|
34510
|
+
}
|
|
34511
|
+
return [4 /*yield*/, cells];
|
|
34512
|
+
case 2:
|
|
34513
|
+
_c.sent();
|
|
34514
|
+
_c.label = 3;
|
|
34515
|
+
case 3:
|
|
34516
|
+
x++;
|
|
34517
|
+
return [3 /*break*/, 1];
|
|
34518
|
+
case 4: return [2 /*return*/];
|
|
34519
|
+
}
|
|
34520
|
+
});
|
|
34521
|
+
},
|
|
34522
|
+
/** Clears the selection from the table */
|
|
34523
|
+
unselect: function (editor) {
|
|
34524
|
+
// const matrix = EDITOR_TO_SELECTION.get(editor);
|
|
34525
|
+
var _a;
|
|
34526
|
+
// if (!matrix?.length) {
|
|
34527
|
+
// return;
|
|
34528
|
+
// }
|
|
34529
|
+
// for (let x = 0; x < matrix.length; x++) {
|
|
34530
|
+
// for (let y = 0; y < matrix[x].length; y++) {
|
|
34531
|
+
// const [[, path], { ltr: colSpan, ttb }] = matrix[x][y];
|
|
34532
|
+
// y += colSpan - 1;
|
|
34533
|
+
// if (ttb > 1) {
|
|
34534
|
+
// continue;
|
|
34535
|
+
// }
|
|
34536
|
+
// // no-op since the paths are the same
|
|
34537
|
+
// const noop: Operation = {
|
|
34538
|
+
// type: "move_node",
|
|
34539
|
+
// newPath: path,
|
|
34540
|
+
// path: path,
|
|
34541
|
+
// };
|
|
34542
|
+
// Transforms.transform(editor, noop);
|
|
34543
|
+
// }
|
|
34544
|
+
// }
|
|
34545
|
+
EDITOR_TO_SELECTION_SET.delete(editor);
|
|
34546
|
+
EDITOR_TO_SELECTION.delete(editor);
|
|
34547
|
+
// 清除选区
|
|
34548
|
+
(_a = document.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
34549
|
+
},
|
|
34550
|
+
/**
|
|
34551
|
+
* Checks whether a given cell is part of the current table selection.
|
|
34552
|
+
* @returns {boolean} - Returns true if the cell is selected, otherwise false.
|
|
34553
|
+
*/
|
|
34554
|
+
isSelected: function (editor, element) {
|
|
34555
|
+
var selectedElements = EDITOR_TO_SELECTION_SET.get(editor);
|
|
34556
|
+
if (!selectedElements) {
|
|
34557
|
+
return false;
|
|
34558
|
+
}
|
|
34559
|
+
return selectedElements.has(element);
|
|
34560
|
+
},
|
|
34561
|
+
};
|
|
34450
34562
|
|
|
34451
|
-
|
|
34452
|
-
var
|
|
34453
|
-
|
|
34454
|
-
|
|
34455
|
-
|
|
34456
|
-
|
|
34457
|
-
|
|
34458
|
-
|
|
34459
|
-
|
|
34460
|
-
|
|
34461
|
-
|
|
34462
|
-
|
|
34463
|
-
|
|
34464
|
-
|
|
34465
|
-
|
|
34466
|
-
|
|
34467
|
-
|
|
34468
|
-
|
|
34469
|
-
|
|
34470
|
-
|
|
34471
|
-
|
|
34472
|
-
|
|
34473
|
-
|
|
34474
|
-
|
|
34475
|
-
|
|
34476
|
-
|
|
34477
|
-
|
|
34478
|
-
|
|
34479
|
-
|
|
34480
|
-
|
|
34481
|
-
|
|
34482
|
-
|
|
34483
|
-
|
|
34484
|
-
|
|
34485
|
-
|
|
34486
|
-
|
|
34487
|
-
|
|
34488
|
-
|
|
34489
|
-
|
|
34490
|
-
|
|
34491
|
-
|
|
34492
|
-
|
|
34493
|
-
|
|
34494
|
-
|
|
34495
|
-
|
|
34496
|
-
|
|
34497
|
-
|
|
34498
|
-
|
|
34499
|
-
|
|
34500
|
-
|
|
34501
|
-
|
|
34502
|
-
|
|
34503
|
-
|
|
34504
|
-
|
|
34505
|
-
|
|
34506
|
-
|
|
34507
|
-
|
|
34508
|
-
|
|
34509
|
-
|
|
34510
|
-
|
|
34511
|
-
|
|
34512
|
-
|
|
34513
|
-
|
|
34514
|
-
|
|
34515
|
-
|
|
34516
|
-
|
|
34517
|
-
|
|
34518
|
-
|
|
34519
|
-
|
|
34520
|
-
|
|
34521
|
-
|
|
34522
|
-
|
|
34523
|
-
|
|
34524
|
-
|
|
34525
|
-
|
|
34526
|
-
|
|
34527
|
-
|
|
34528
|
-
|
|
34529
|
-
|
|
34530
|
-
|
|
34531
|
-
|
|
34532
|
-
|
|
34533
|
-
|
|
34534
|
-
|
|
34535
|
-
|
|
34536
|
-
|
|
34537
|
-
|
|
34538
|
-
|
|
34539
|
-
/**
|
|
34540
|
-
* Checks if a hash value for `key` exists.
|
|
34541
|
-
*
|
|
34542
|
-
* @private
|
|
34543
|
-
* @name has
|
|
34544
|
-
* @memberOf Hash
|
|
34545
|
-
* @param {string} key The key of the entry to check.
|
|
34546
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
34547
|
-
*/
|
|
34548
|
-
function hashHas(key) {
|
|
34549
|
-
var data = this.__data__;
|
|
34550
|
-
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
|
|
34551
|
-
}
|
|
34552
|
-
|
|
34553
|
-
/**
|
|
34554
|
-
* Sets the hash `key` to `value`.
|
|
34555
|
-
*
|
|
34556
|
-
* @private
|
|
34557
|
-
* @name set
|
|
34558
|
-
* @memberOf Hash
|
|
34559
|
-
* @param {string} key The key of the value to set.
|
|
34560
|
-
* @param {*} value The value to set.
|
|
34561
|
-
* @returns {Object} Returns the hash instance.
|
|
34562
|
-
*/
|
|
34563
|
-
function hashSet(key, value) {
|
|
34564
|
-
var data = this.__data__;
|
|
34565
|
-
this.size += this.has(key) ? 0 : 1;
|
|
34566
|
-
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
|
34567
|
-
return this;
|
|
34568
|
-
}
|
|
34569
|
-
|
|
34570
|
-
// Add methods to `Hash`.
|
|
34571
|
-
Hash.prototype.clear = hashClear;
|
|
34572
|
-
Hash.prototype['delete'] = hashDelete;
|
|
34573
|
-
Hash.prototype.get = hashGet;
|
|
34574
|
-
Hash.prototype.has = hashHas;
|
|
34575
|
-
Hash.prototype.set = hashSet;
|
|
34576
|
-
|
|
34577
|
-
/**
|
|
34578
|
-
* Creates an list cache object.
|
|
34579
|
-
*
|
|
34580
|
-
* @private
|
|
34581
|
-
* @constructor
|
|
34582
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
34583
|
-
*/
|
|
34584
|
-
function ListCache(entries) {
|
|
34585
|
-
var index = -1,
|
|
34586
|
-
length = entries == null ? 0 : entries.length;
|
|
34587
|
-
|
|
34588
|
-
this.clear();
|
|
34589
|
-
while (++index < length) {
|
|
34590
|
-
var entry = entries[index];
|
|
34591
|
-
this.set(entry[0], entry[1]);
|
|
34592
|
-
}
|
|
34593
|
-
}
|
|
34594
|
-
|
|
34595
|
-
/**
|
|
34596
|
-
* Removes all key-value entries from the list cache.
|
|
34597
|
-
*
|
|
34598
|
-
* @private
|
|
34599
|
-
* @name clear
|
|
34600
|
-
* @memberOf ListCache
|
|
34601
|
-
*/
|
|
34602
|
-
function listCacheClear() {
|
|
34603
|
-
this.__data__ = [];
|
|
34604
|
-
this.size = 0;
|
|
34605
|
-
}
|
|
34606
|
-
|
|
34607
|
-
/**
|
|
34608
|
-
* Removes `key` and its value from the list cache.
|
|
34609
|
-
*
|
|
34610
|
-
* @private
|
|
34611
|
-
* @name delete
|
|
34612
|
-
* @memberOf ListCache
|
|
34613
|
-
* @param {string} key The key of the value to remove.
|
|
34614
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
34615
|
-
*/
|
|
34616
|
-
function listCacheDelete(key) {
|
|
34617
|
-
var data = this.__data__,
|
|
34618
|
-
index = assocIndexOf(data, key);
|
|
34619
|
-
|
|
34620
|
-
if (index < 0) {
|
|
34621
|
-
return false;
|
|
34622
|
-
}
|
|
34623
|
-
var lastIndex = data.length - 1;
|
|
34624
|
-
if (index == lastIndex) {
|
|
34625
|
-
data.pop();
|
|
34626
|
-
} else {
|
|
34627
|
-
splice.call(data, index, 1);
|
|
34628
|
-
}
|
|
34629
|
-
--this.size;
|
|
34630
|
-
return true;
|
|
34631
|
-
}
|
|
34632
|
-
|
|
34633
|
-
/**
|
|
34634
|
-
* Gets the list cache value for `key`.
|
|
34635
|
-
*
|
|
34636
|
-
* @private
|
|
34637
|
-
* @name get
|
|
34638
|
-
* @memberOf ListCache
|
|
34639
|
-
* @param {string} key The key of the value to get.
|
|
34640
|
-
* @returns {*} Returns the entry value.
|
|
34641
|
-
*/
|
|
34642
|
-
function listCacheGet(key) {
|
|
34643
|
-
var data = this.__data__,
|
|
34644
|
-
index = assocIndexOf(data, key);
|
|
34645
|
-
|
|
34646
|
-
return index < 0 ? undefined : data[index][1];
|
|
34647
|
-
}
|
|
34648
|
-
|
|
34649
|
-
/**
|
|
34650
|
-
* Checks if a list cache value for `key` exists.
|
|
34651
|
-
*
|
|
34652
|
-
* @private
|
|
34653
|
-
* @name has
|
|
34654
|
-
* @memberOf ListCache
|
|
34655
|
-
* @param {string} key The key of the entry to check.
|
|
34656
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
34657
|
-
*/
|
|
34658
|
-
function listCacheHas(key) {
|
|
34659
|
-
return assocIndexOf(this.__data__, key) > -1;
|
|
34660
|
-
}
|
|
34661
|
-
|
|
34662
|
-
/**
|
|
34663
|
-
* Sets the list cache `key` to `value`.
|
|
34664
|
-
*
|
|
34665
|
-
* @private
|
|
34666
|
-
* @name set
|
|
34667
|
-
* @memberOf ListCache
|
|
34668
|
-
* @param {string} key The key of the value to set.
|
|
34669
|
-
* @param {*} value The value to set.
|
|
34670
|
-
* @returns {Object} Returns the list cache instance.
|
|
34671
|
-
*/
|
|
34672
|
-
function listCacheSet(key, value) {
|
|
34673
|
-
var data = this.__data__,
|
|
34674
|
-
index = assocIndexOf(data, key);
|
|
34675
|
-
|
|
34676
|
-
if (index < 0) {
|
|
34677
|
-
++this.size;
|
|
34678
|
-
data.push([key, value]);
|
|
34679
|
-
} else {
|
|
34680
|
-
data[index][1] = value;
|
|
34681
|
-
}
|
|
34682
|
-
return this;
|
|
34683
|
-
}
|
|
34684
|
-
|
|
34685
|
-
// Add methods to `ListCache`.
|
|
34686
|
-
ListCache.prototype.clear = listCacheClear;
|
|
34687
|
-
ListCache.prototype['delete'] = listCacheDelete;
|
|
34688
|
-
ListCache.prototype.get = listCacheGet;
|
|
34689
|
-
ListCache.prototype.has = listCacheHas;
|
|
34690
|
-
ListCache.prototype.set = listCacheSet;
|
|
34691
|
-
|
|
34692
|
-
/**
|
|
34693
|
-
* Creates a map cache object to store key-value pairs.
|
|
34694
|
-
*
|
|
34695
|
-
* @private
|
|
34696
|
-
* @constructor
|
|
34697
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
34698
|
-
*/
|
|
34699
|
-
function MapCache(entries) {
|
|
34700
|
-
var index = -1,
|
|
34701
|
-
length = entries == null ? 0 : entries.length;
|
|
34702
|
-
|
|
34703
|
-
this.clear();
|
|
34704
|
-
while (++index < length) {
|
|
34705
|
-
var entry = entries[index];
|
|
34706
|
-
this.set(entry[0], entry[1]);
|
|
34707
|
-
}
|
|
34708
|
-
}
|
|
34709
|
-
|
|
34710
|
-
/**
|
|
34711
|
-
* Removes all key-value entries from the map.
|
|
34712
|
-
*
|
|
34713
|
-
* @private
|
|
34714
|
-
* @name clear
|
|
34715
|
-
* @memberOf MapCache
|
|
34716
|
-
*/
|
|
34717
|
-
function mapCacheClear() {
|
|
34718
|
-
this.size = 0;
|
|
34719
|
-
this.__data__ = {
|
|
34720
|
-
'hash': new Hash,
|
|
34721
|
-
'map': new (Map || ListCache),
|
|
34722
|
-
'string': new Hash
|
|
34723
|
-
};
|
|
34724
|
-
}
|
|
34725
|
-
|
|
34726
|
-
/**
|
|
34727
|
-
* Removes `key` and its value from the map.
|
|
34728
|
-
*
|
|
34729
|
-
* @private
|
|
34730
|
-
* @name delete
|
|
34731
|
-
* @memberOf MapCache
|
|
34732
|
-
* @param {string} key The key of the value to remove.
|
|
34733
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
34734
|
-
*/
|
|
34735
|
-
function mapCacheDelete(key) {
|
|
34736
|
-
var result = getMapData(this, key)['delete'](key);
|
|
34737
|
-
this.size -= result ? 1 : 0;
|
|
34738
|
-
return result;
|
|
34739
|
-
}
|
|
34740
|
-
|
|
34741
|
-
/**
|
|
34742
|
-
* Gets the map value for `key`.
|
|
34743
|
-
*
|
|
34744
|
-
* @private
|
|
34745
|
-
* @name get
|
|
34746
|
-
* @memberOf MapCache
|
|
34747
|
-
* @param {string} key The key of the value to get.
|
|
34748
|
-
* @returns {*} Returns the entry value.
|
|
34749
|
-
*/
|
|
34750
|
-
function mapCacheGet(key) {
|
|
34751
|
-
return getMapData(this, key).get(key);
|
|
34752
|
-
}
|
|
34753
|
-
|
|
34754
|
-
/**
|
|
34755
|
-
* Checks if a map value for `key` exists.
|
|
34756
|
-
*
|
|
34757
|
-
* @private
|
|
34758
|
-
* @name has
|
|
34759
|
-
* @memberOf MapCache
|
|
34760
|
-
* @param {string} key The key of the entry to check.
|
|
34761
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
34762
|
-
*/
|
|
34763
|
-
function mapCacheHas(key) {
|
|
34764
|
-
return getMapData(this, key).has(key);
|
|
34765
|
-
}
|
|
34766
|
-
|
|
34767
|
-
/**
|
|
34768
|
-
* Sets the map `key` to `value`.
|
|
34769
|
-
*
|
|
34770
|
-
* @private
|
|
34771
|
-
* @name set
|
|
34772
|
-
* @memberOf MapCache
|
|
34773
|
-
* @param {string} key The key of the value to set.
|
|
34774
|
-
* @param {*} value The value to set.
|
|
34775
|
-
* @returns {Object} Returns the map cache instance.
|
|
34776
|
-
*/
|
|
34777
|
-
function mapCacheSet(key, value) {
|
|
34778
|
-
var data = getMapData(this, key),
|
|
34779
|
-
size = data.size;
|
|
34780
|
-
|
|
34781
|
-
data.set(key, value);
|
|
34782
|
-
this.size += data.size == size ? 0 : 1;
|
|
34783
|
-
return this;
|
|
34784
|
-
}
|
|
34785
|
-
|
|
34786
|
-
// Add methods to `MapCache`.
|
|
34787
|
-
MapCache.prototype.clear = mapCacheClear;
|
|
34788
|
-
MapCache.prototype['delete'] = mapCacheDelete;
|
|
34789
|
-
MapCache.prototype.get = mapCacheGet;
|
|
34790
|
-
MapCache.prototype.has = mapCacheHas;
|
|
34791
|
-
MapCache.prototype.set = mapCacheSet;
|
|
34792
|
-
|
|
34793
|
-
/**
|
|
34794
|
-
*
|
|
34795
|
-
* Creates an array cache object to store unique values.
|
|
34796
|
-
*
|
|
34797
|
-
* @private
|
|
34798
|
-
* @constructor
|
|
34799
|
-
* @param {Array} [values] The values to cache.
|
|
34800
|
-
*/
|
|
34801
|
-
function SetCache(values) {
|
|
34802
|
-
var index = -1,
|
|
34803
|
-
length = values == null ? 0 : values.length;
|
|
34804
|
-
|
|
34805
|
-
this.__data__ = new MapCache;
|
|
34806
|
-
while (++index < length) {
|
|
34807
|
-
this.add(values[index]);
|
|
34808
|
-
}
|
|
34809
|
-
}
|
|
34810
|
-
|
|
34811
|
-
/**
|
|
34812
|
-
* Adds `value` to the array cache.
|
|
34813
|
-
*
|
|
34814
|
-
* @private
|
|
34815
|
-
* @name add
|
|
34816
|
-
* @memberOf SetCache
|
|
34817
|
-
* @alias push
|
|
34818
|
-
* @param {*} value The value to cache.
|
|
34819
|
-
* @returns {Object} Returns the cache instance.
|
|
34820
|
-
*/
|
|
34821
|
-
function setCacheAdd(value) {
|
|
34822
|
-
this.__data__.set(value, HASH_UNDEFINED);
|
|
34823
|
-
return this;
|
|
34824
|
-
}
|
|
34825
|
-
|
|
34826
|
-
/**
|
|
34827
|
-
* Checks if `value` is in the array cache.
|
|
34828
|
-
*
|
|
34829
|
-
* @private
|
|
34830
|
-
* @name has
|
|
34831
|
-
* @memberOf SetCache
|
|
34832
|
-
* @param {*} value The value to search for.
|
|
34833
|
-
* @returns {number} Returns `true` if `value` is found, else `false`.
|
|
34834
|
-
*/
|
|
34835
|
-
function setCacheHas(value) {
|
|
34836
|
-
return this.__data__.has(value);
|
|
34837
|
-
}
|
|
34838
|
-
|
|
34839
|
-
// Add methods to `SetCache`.
|
|
34840
|
-
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|
34841
|
-
SetCache.prototype.has = setCacheHas;
|
|
34842
|
-
|
|
34843
|
-
/**
|
|
34844
|
-
* Creates a stack cache object to store key-value pairs.
|
|
34845
|
-
*
|
|
34846
|
-
* @private
|
|
34847
|
-
* @constructor
|
|
34848
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
34849
|
-
*/
|
|
34850
|
-
function Stack(entries) {
|
|
34851
|
-
var data = this.__data__ = new ListCache(entries);
|
|
34852
|
-
this.size = data.size;
|
|
34853
|
-
}
|
|
34854
|
-
|
|
34855
|
-
/**
|
|
34856
|
-
* Removes all key-value entries from the stack.
|
|
34857
|
-
*
|
|
34858
|
-
* @private
|
|
34859
|
-
* @name clear
|
|
34860
|
-
* @memberOf Stack
|
|
34861
|
-
*/
|
|
34862
|
-
function stackClear() {
|
|
34863
|
-
this.__data__ = new ListCache;
|
|
34864
|
-
this.size = 0;
|
|
34865
|
-
}
|
|
34866
|
-
|
|
34867
|
-
/**
|
|
34868
|
-
* Removes `key` and its value from the stack.
|
|
34869
|
-
*
|
|
34870
|
-
* @private
|
|
34871
|
-
* @name delete
|
|
34872
|
-
* @memberOf Stack
|
|
34873
|
-
* @param {string} key The key of the value to remove.
|
|
34874
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
34875
|
-
*/
|
|
34876
|
-
function stackDelete(key) {
|
|
34877
|
-
var data = this.__data__,
|
|
34878
|
-
result = data['delete'](key);
|
|
34879
|
-
|
|
34880
|
-
this.size = data.size;
|
|
34881
|
-
return result;
|
|
34882
|
-
}
|
|
34883
|
-
|
|
34884
|
-
/**
|
|
34885
|
-
* Gets the stack value for `key`.
|
|
34886
|
-
*
|
|
34887
|
-
* @private
|
|
34888
|
-
* @name get
|
|
34889
|
-
* @memberOf Stack
|
|
34890
|
-
* @param {string} key The key of the value to get.
|
|
34891
|
-
* @returns {*} Returns the entry value.
|
|
34892
|
-
*/
|
|
34893
|
-
function stackGet(key) {
|
|
34894
|
-
return this.__data__.get(key);
|
|
34895
|
-
}
|
|
34896
|
-
|
|
34897
|
-
/**
|
|
34898
|
-
* Checks if a stack value for `key` exists.
|
|
34899
|
-
*
|
|
34900
|
-
* @private
|
|
34901
|
-
* @name has
|
|
34902
|
-
* @memberOf Stack
|
|
34903
|
-
* @param {string} key The key of the entry to check.
|
|
34904
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
34905
|
-
*/
|
|
34906
|
-
function stackHas(key) {
|
|
34907
|
-
return this.__data__.has(key);
|
|
34908
|
-
}
|
|
34909
|
-
|
|
34910
|
-
/**
|
|
34911
|
-
* Sets the stack `key` to `value`.
|
|
34912
|
-
*
|
|
34913
|
-
* @private
|
|
34914
|
-
* @name set
|
|
34915
|
-
* @memberOf Stack
|
|
34916
|
-
* @param {string} key The key of the value to set.
|
|
34917
|
-
* @param {*} value The value to set.
|
|
34918
|
-
* @returns {Object} Returns the stack cache instance.
|
|
34919
|
-
*/
|
|
34920
|
-
function stackSet(key, value) {
|
|
34921
|
-
var data = this.__data__;
|
|
34922
|
-
if (data instanceof ListCache) {
|
|
34923
|
-
var pairs = data.__data__;
|
|
34924
|
-
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
|
34925
|
-
pairs.push([key, value]);
|
|
34926
|
-
this.size = ++data.size;
|
|
34927
|
-
return this;
|
|
34928
|
-
}
|
|
34929
|
-
data = this.__data__ = new MapCache(pairs);
|
|
34930
|
-
}
|
|
34931
|
-
data.set(key, value);
|
|
34932
|
-
this.size = data.size;
|
|
34933
|
-
return this;
|
|
34934
|
-
}
|
|
34935
|
-
|
|
34936
|
-
// Add methods to `Stack`.
|
|
34937
|
-
Stack.prototype.clear = stackClear;
|
|
34938
|
-
Stack.prototype['delete'] = stackDelete;
|
|
34939
|
-
Stack.prototype.get = stackGet;
|
|
34940
|
-
Stack.prototype.has = stackHas;
|
|
34941
|
-
Stack.prototype.set = stackSet;
|
|
34942
|
-
|
|
34943
|
-
/**
|
|
34944
|
-
* Creates an array of the enumerable property names of the array-like `value`.
|
|
34945
|
-
*
|
|
34946
|
-
* @private
|
|
34947
|
-
* @param {*} value The value to query.
|
|
34948
|
-
* @param {boolean} inherited Specify returning inherited property names.
|
|
34949
|
-
* @returns {Array} Returns the array of property names.
|
|
34950
|
-
*/
|
|
34951
|
-
function arrayLikeKeys(value, inherited) {
|
|
34952
|
-
var isArr = isArray(value),
|
|
34953
|
-
isArg = !isArr && isArguments(value),
|
|
34954
|
-
isBuff = !isArr && !isArg && isBuffer(value),
|
|
34955
|
-
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
|
34956
|
-
skipIndexes = isArr || isArg || isBuff || isType,
|
|
34957
|
-
result = skipIndexes ? baseTimes(value.length, String) : [],
|
|
34958
|
-
length = result.length;
|
|
34959
|
-
|
|
34960
|
-
for (var key in value) {
|
|
34961
|
-
if ((inherited || hasOwnProperty.call(value, key)) &&
|
|
34962
|
-
!(skipIndexes && (
|
|
34963
|
-
// Safari 9 has enumerable `arguments.length` in strict mode.
|
|
34964
|
-
key == 'length' ||
|
|
34965
|
-
// Node.js 0.10 has enumerable non-index properties on buffers.
|
|
34966
|
-
(isBuff && (key == 'offset' || key == 'parent')) ||
|
|
34967
|
-
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
34968
|
-
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
|
34969
|
-
// Skip index properties.
|
|
34970
|
-
isIndex(key, length)
|
|
34971
|
-
))) {
|
|
34972
|
-
result.push(key);
|
|
34973
|
-
}
|
|
34974
|
-
}
|
|
34975
|
-
return result;
|
|
34976
|
-
}
|
|
34977
|
-
|
|
34978
|
-
/**
|
|
34979
|
-
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
34980
|
-
*
|
|
34981
|
-
* @private
|
|
34982
|
-
* @param {Array} array The array to inspect.
|
|
34983
|
-
* @param {*} key The key to search for.
|
|
34984
|
-
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
34985
|
-
*/
|
|
34986
|
-
function assocIndexOf(array, key) {
|
|
34987
|
-
var length = array.length;
|
|
34988
|
-
while (length--) {
|
|
34989
|
-
if (eq(array[length][0], key)) {
|
|
34990
|
-
return length;
|
|
34991
|
-
}
|
|
34992
|
-
}
|
|
34993
|
-
return -1;
|
|
34994
|
-
}
|
|
34995
|
-
|
|
34996
|
-
/**
|
|
34997
|
-
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
|
|
34998
|
-
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
|
|
34999
|
-
* symbols of `object`.
|
|
35000
|
-
*
|
|
35001
|
-
* @private
|
|
35002
|
-
* @param {Object} object The object to query.
|
|
35003
|
-
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
35004
|
-
* @param {Function} symbolsFunc The function to get the symbols of `object`.
|
|
35005
|
-
* @returns {Array} Returns the array of property names and symbols.
|
|
35006
|
-
*/
|
|
35007
|
-
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
|
35008
|
-
var result = keysFunc(object);
|
|
35009
|
-
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
|
35010
|
-
}
|
|
35011
|
-
|
|
35012
|
-
/**
|
|
35013
|
-
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
35014
|
-
*
|
|
35015
|
-
* @private
|
|
35016
|
-
* @param {*} value The value to query.
|
|
35017
|
-
* @returns {string} Returns the `toStringTag`.
|
|
35018
|
-
*/
|
|
35019
|
-
function baseGetTag(value) {
|
|
35020
|
-
if (value == null) {
|
|
35021
|
-
return value === undefined ? undefinedTag : nullTag;
|
|
35022
|
-
}
|
|
35023
|
-
return (symToStringTag && symToStringTag in Object(value))
|
|
35024
|
-
? getRawTag(value)
|
|
35025
|
-
: objectToString(value);
|
|
35026
|
-
}
|
|
35027
|
-
|
|
35028
|
-
/**
|
|
35029
|
-
* The base implementation of `_.isArguments`.
|
|
35030
|
-
*
|
|
35031
|
-
* @private
|
|
35032
|
-
* @param {*} value The value to check.
|
|
35033
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
35034
|
-
*/
|
|
35035
|
-
function baseIsArguments(value) {
|
|
35036
|
-
return isObjectLike(value) && baseGetTag(value) == argsTag;
|
|
35037
|
-
}
|
|
35038
|
-
|
|
35039
|
-
/**
|
|
35040
|
-
* The base implementation of `_.isEqual` which supports partial comparisons
|
|
35041
|
-
* and tracks traversed objects.
|
|
35042
|
-
*
|
|
35043
|
-
* @private
|
|
35044
|
-
* @param {*} value The value to compare.
|
|
35045
|
-
* @param {*} other The other value to compare.
|
|
35046
|
-
* @param {boolean} bitmask The bitmask flags.
|
|
35047
|
-
* 1 - Unordered comparison
|
|
35048
|
-
* 2 - Partial comparison
|
|
35049
|
-
* @param {Function} [customizer] The function to customize comparisons.
|
|
35050
|
-
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
|
|
35051
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
35052
|
-
*/
|
|
35053
|
-
function baseIsEqual(value, other, bitmask, customizer, stack) {
|
|
35054
|
-
if (value === other) {
|
|
35055
|
-
return true;
|
|
35056
|
-
}
|
|
35057
|
-
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
|
|
35058
|
-
return value !== value && other !== other;
|
|
35059
|
-
}
|
|
35060
|
-
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
|
35061
|
-
}
|
|
35062
|
-
|
|
35063
|
-
/**
|
|
35064
|
-
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
|
35065
|
-
* deep comparisons and tracks traversed objects enabling objects with circular
|
|
35066
|
-
* references to be compared.
|
|
35067
|
-
*
|
|
35068
|
-
* @private
|
|
35069
|
-
* @param {Object} object The object to compare.
|
|
35070
|
-
* @param {Object} other The other object to compare.
|
|
35071
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
35072
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
35073
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
35074
|
-
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
|
35075
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
35076
|
-
*/
|
|
35077
|
-
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
35078
|
-
var objIsArr = isArray(object),
|
|
35079
|
-
othIsArr = isArray(other),
|
|
35080
|
-
objTag = objIsArr ? arrayTag : getTag(object),
|
|
35081
|
-
othTag = othIsArr ? arrayTag : getTag(other);
|
|
35082
|
-
|
|
35083
|
-
objTag = objTag == argsTag ? objectTag : objTag;
|
|
35084
|
-
othTag = othTag == argsTag ? objectTag : othTag;
|
|
35085
|
-
|
|
35086
|
-
var objIsObj = objTag == objectTag,
|
|
35087
|
-
othIsObj = othTag == objectTag,
|
|
35088
|
-
isSameTag = objTag == othTag;
|
|
35089
|
-
|
|
35090
|
-
if (isSameTag && isBuffer(object)) {
|
|
35091
|
-
if (!isBuffer(other)) {
|
|
35092
|
-
return false;
|
|
35093
|
-
}
|
|
35094
|
-
objIsArr = true;
|
|
35095
|
-
objIsObj = false;
|
|
35096
|
-
}
|
|
35097
|
-
if (isSameTag && !objIsObj) {
|
|
35098
|
-
stack || (stack = new Stack);
|
|
35099
|
-
return (objIsArr || isTypedArray(object))
|
|
35100
|
-
? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
|
|
35101
|
-
: equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
35102
|
-
}
|
|
35103
|
-
if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
|
|
35104
|
-
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
|
35105
|
-
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
|
35106
|
-
|
|
35107
|
-
if (objIsWrapped || othIsWrapped) {
|
|
35108
|
-
var objUnwrapped = objIsWrapped ? object.value() : object,
|
|
35109
|
-
othUnwrapped = othIsWrapped ? other.value() : other;
|
|
35110
|
-
|
|
35111
|
-
stack || (stack = new Stack);
|
|
35112
|
-
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
|
35113
|
-
}
|
|
35114
|
-
}
|
|
35115
|
-
if (!isSameTag) {
|
|
35116
|
-
return false;
|
|
35117
|
-
}
|
|
35118
|
-
stack || (stack = new Stack);
|
|
35119
|
-
return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
|
|
35120
|
-
}
|
|
35121
|
-
|
|
35122
|
-
/**
|
|
35123
|
-
* The base implementation of `_.isNative` without bad shim checks.
|
|
35124
|
-
*
|
|
35125
|
-
* @private
|
|
35126
|
-
* @param {*} value The value to check.
|
|
35127
|
-
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
35128
|
-
* else `false`.
|
|
35129
|
-
*/
|
|
35130
|
-
function baseIsNative(value) {
|
|
35131
|
-
if (!isObject(value) || isMasked(value)) {
|
|
35132
|
-
return false;
|
|
35133
|
-
}
|
|
35134
|
-
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
35135
|
-
return pattern.test(toSource(value));
|
|
35136
|
-
}
|
|
35137
|
-
|
|
35138
|
-
/**
|
|
35139
|
-
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
|
35140
|
-
*
|
|
35141
|
-
* @private
|
|
35142
|
-
* @param {*} value The value to check.
|
|
35143
|
-
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
35144
|
-
*/
|
|
35145
|
-
function baseIsTypedArray(value) {
|
|
35146
|
-
return isObjectLike(value) &&
|
|
35147
|
-
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
35148
|
-
}
|
|
35149
|
-
|
|
35150
|
-
/**
|
|
35151
|
-
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
|
35152
|
-
*
|
|
35153
|
-
* @private
|
|
35154
|
-
* @param {Object} object The object to query.
|
|
35155
|
-
* @returns {Array} Returns the array of property names.
|
|
35156
|
-
*/
|
|
35157
|
-
function baseKeys(object) {
|
|
35158
|
-
if (!isPrototype(object)) {
|
|
35159
|
-
return nativeKeys(object);
|
|
35160
|
-
}
|
|
35161
|
-
var result = [];
|
|
35162
|
-
for (var key in Object(object)) {
|
|
35163
|
-
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
|
35164
|
-
result.push(key);
|
|
35165
|
-
}
|
|
35166
|
-
}
|
|
35167
|
-
return result;
|
|
35168
|
-
}
|
|
35169
|
-
|
|
35170
|
-
/**
|
|
35171
|
-
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|
35172
|
-
* partial deep comparisons.
|
|
35173
|
-
*
|
|
35174
|
-
* @private
|
|
35175
|
-
* @param {Array} array The array to compare.
|
|
35176
|
-
* @param {Array} other The other array to compare.
|
|
35177
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
35178
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
35179
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
35180
|
-
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
|
35181
|
-
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|
35182
|
-
*/
|
|
35183
|
-
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|
35184
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
|
35185
|
-
arrLength = array.length,
|
|
35186
|
-
othLength = other.length;
|
|
35187
|
-
|
|
35188
|
-
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|
35189
|
-
return false;
|
|
35190
|
-
}
|
|
35191
|
-
// Assume cyclic values are equal.
|
|
35192
|
-
var stacked = stack.get(array);
|
|
35193
|
-
if (stacked && stack.get(other)) {
|
|
35194
|
-
return stacked == other;
|
|
35195
|
-
}
|
|
35196
|
-
var index = -1,
|
|
35197
|
-
result = true,
|
|
35198
|
-
seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
|
|
35199
|
-
|
|
35200
|
-
stack.set(array, other);
|
|
35201
|
-
stack.set(other, array);
|
|
35202
|
-
|
|
35203
|
-
// Ignore non-index properties.
|
|
35204
|
-
while (++index < arrLength) {
|
|
35205
|
-
var arrValue = array[index],
|
|
35206
|
-
othValue = other[index];
|
|
35207
|
-
|
|
35208
|
-
if (customizer) {
|
|
35209
|
-
var compared = isPartial
|
|
35210
|
-
? customizer(othValue, arrValue, index, other, array, stack)
|
|
35211
|
-
: customizer(arrValue, othValue, index, array, other, stack);
|
|
35212
|
-
}
|
|
35213
|
-
if (compared !== undefined) {
|
|
35214
|
-
if (compared) {
|
|
35215
|
-
continue;
|
|
35216
|
-
}
|
|
35217
|
-
result = false;
|
|
35218
|
-
break;
|
|
35219
|
-
}
|
|
35220
|
-
// Recursively compare arrays (susceptible to call stack limits).
|
|
35221
|
-
if (seen) {
|
|
35222
|
-
if (!arraySome(other, function(othValue, othIndex) {
|
|
35223
|
-
if (!cacheHas(seen, othIndex) &&
|
|
35224
|
-
(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
|
35225
|
-
return seen.push(othIndex);
|
|
35226
|
-
}
|
|
35227
|
-
})) {
|
|
35228
|
-
result = false;
|
|
35229
|
-
break;
|
|
35230
|
-
}
|
|
35231
|
-
} else if (!(
|
|
35232
|
-
arrValue === othValue ||
|
|
35233
|
-
equalFunc(arrValue, othValue, bitmask, customizer, stack)
|
|
35234
|
-
)) {
|
|
35235
|
-
result = false;
|
|
35236
|
-
break;
|
|
35237
|
-
}
|
|
35238
|
-
}
|
|
35239
|
-
stack['delete'](array);
|
|
35240
|
-
stack['delete'](other);
|
|
35241
|
-
return result;
|
|
35242
|
-
}
|
|
35243
|
-
|
|
35244
|
-
/**
|
|
35245
|
-
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|
35246
|
-
* the same `toStringTag`.
|
|
35247
|
-
*
|
|
35248
|
-
* **Note:** This function only supports comparing values with tags of
|
|
35249
|
-
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
|
35250
|
-
*
|
|
35251
|
-
* @private
|
|
35252
|
-
* @param {Object} object The object to compare.
|
|
35253
|
-
* @param {Object} other The other object to compare.
|
|
35254
|
-
* @param {string} tag The `toStringTag` of the objects to compare.
|
|
35255
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
35256
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
35257
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
35258
|
-
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
35259
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
35260
|
-
*/
|
|
35261
|
-
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
35262
|
-
switch (tag) {
|
|
35263
|
-
case dataViewTag:
|
|
35264
|
-
if ((object.byteLength != other.byteLength) ||
|
|
35265
|
-
(object.byteOffset != other.byteOffset)) {
|
|
35266
|
-
return false;
|
|
35267
|
-
}
|
|
35268
|
-
object = object.buffer;
|
|
35269
|
-
other = other.buffer;
|
|
35270
|
-
|
|
35271
|
-
case arrayBufferTag:
|
|
35272
|
-
if ((object.byteLength != other.byteLength) ||
|
|
35273
|
-
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
|
|
35274
|
-
return false;
|
|
35275
|
-
}
|
|
35276
|
-
return true;
|
|
35277
|
-
|
|
35278
|
-
case boolTag:
|
|
35279
|
-
case dateTag:
|
|
35280
|
-
case numberTag:
|
|
35281
|
-
// Coerce booleans to `1` or `0` and dates to milliseconds.
|
|
35282
|
-
// Invalid dates are coerced to `NaN`.
|
|
35283
|
-
return eq(+object, +other);
|
|
35284
|
-
|
|
35285
|
-
case errorTag:
|
|
35286
|
-
return object.name == other.name && object.message == other.message;
|
|
35287
|
-
|
|
35288
|
-
case regexpTag:
|
|
35289
|
-
case stringTag:
|
|
35290
|
-
// Coerce regexes to strings and treat strings, primitives and objects,
|
|
35291
|
-
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
|
|
35292
|
-
// for more details.
|
|
35293
|
-
return object == (other + '');
|
|
35294
|
-
|
|
35295
|
-
case mapTag:
|
|
35296
|
-
var convert = mapToArray;
|
|
35297
|
-
|
|
35298
|
-
case setTag:
|
|
35299
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
|
|
35300
|
-
convert || (convert = setToArray);
|
|
35301
|
-
|
|
35302
|
-
if (object.size != other.size && !isPartial) {
|
|
35303
|
-
return false;
|
|
35304
|
-
}
|
|
35305
|
-
// Assume cyclic values are equal.
|
|
35306
|
-
var stacked = stack.get(object);
|
|
35307
|
-
if (stacked) {
|
|
35308
|
-
return stacked == other;
|
|
35309
|
-
}
|
|
35310
|
-
bitmask |= COMPARE_UNORDERED_FLAG;
|
|
35311
|
-
|
|
35312
|
-
// Recursively compare objects (susceptible to call stack limits).
|
|
35313
|
-
stack.set(object, other);
|
|
35314
|
-
var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
35315
|
-
stack['delete'](object);
|
|
35316
|
-
return result;
|
|
35317
|
-
|
|
35318
|
-
case symbolTag:
|
|
35319
|
-
if (symbolValueOf) {
|
|
35320
|
-
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
35321
|
-
}
|
|
35322
|
-
}
|
|
35323
|
-
return false;
|
|
35324
|
-
}
|
|
35325
|
-
|
|
35326
|
-
/**
|
|
35327
|
-
* A specialized version of `baseIsEqualDeep` for objects with support for
|
|
35328
|
-
* partial deep comparisons.
|
|
35329
|
-
*
|
|
35330
|
-
* @private
|
|
35331
|
-
* @param {Object} object The object to compare.
|
|
35332
|
-
* @param {Object} other The other object to compare.
|
|
35333
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
35334
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
35335
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
35336
|
-
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
35337
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
35338
|
-
*/
|
|
35339
|
-
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
35340
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
|
35341
|
-
objProps = getAllKeys(object),
|
|
35342
|
-
objLength = objProps.length,
|
|
35343
|
-
othProps = getAllKeys(other),
|
|
35344
|
-
othLength = othProps.length;
|
|
35345
|
-
|
|
35346
|
-
if (objLength != othLength && !isPartial) {
|
|
35347
|
-
return false;
|
|
35348
|
-
}
|
|
35349
|
-
var index = objLength;
|
|
35350
|
-
while (index--) {
|
|
35351
|
-
var key = objProps[index];
|
|
35352
|
-
if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
|
|
35353
|
-
return false;
|
|
35354
|
-
}
|
|
35355
|
-
}
|
|
35356
|
-
// Assume cyclic values are equal.
|
|
35357
|
-
var stacked = stack.get(object);
|
|
35358
|
-
if (stacked && stack.get(other)) {
|
|
35359
|
-
return stacked == other;
|
|
35360
|
-
}
|
|
35361
|
-
var result = true;
|
|
35362
|
-
stack.set(object, other);
|
|
35363
|
-
stack.set(other, object);
|
|
35364
|
-
|
|
35365
|
-
var skipCtor = isPartial;
|
|
35366
|
-
while (++index < objLength) {
|
|
35367
|
-
key = objProps[index];
|
|
35368
|
-
var objValue = object[key],
|
|
35369
|
-
othValue = other[key];
|
|
35370
|
-
|
|
35371
|
-
if (customizer) {
|
|
35372
|
-
var compared = isPartial
|
|
35373
|
-
? customizer(othValue, objValue, key, other, object, stack)
|
|
35374
|
-
: customizer(objValue, othValue, key, object, other, stack);
|
|
35375
|
-
}
|
|
35376
|
-
// Recursively compare objects (susceptible to call stack limits).
|
|
35377
|
-
if (!(compared === undefined
|
|
35378
|
-
? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
|
|
35379
|
-
: compared
|
|
35380
|
-
)) {
|
|
35381
|
-
result = false;
|
|
35382
|
-
break;
|
|
35383
|
-
}
|
|
35384
|
-
skipCtor || (skipCtor = key == 'constructor');
|
|
35385
|
-
}
|
|
35386
|
-
if (result && !skipCtor) {
|
|
35387
|
-
var objCtor = object.constructor,
|
|
35388
|
-
othCtor = other.constructor;
|
|
35389
|
-
|
|
35390
|
-
// Non `Object` object instances with different constructors are not equal.
|
|
35391
|
-
if (objCtor != othCtor &&
|
|
35392
|
-
('constructor' in object && 'constructor' in other) &&
|
|
35393
|
-
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
|
|
35394
|
-
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
|
35395
|
-
result = false;
|
|
35396
|
-
}
|
|
35397
|
-
}
|
|
35398
|
-
stack['delete'](object);
|
|
35399
|
-
stack['delete'](other);
|
|
35400
|
-
return result;
|
|
35401
|
-
}
|
|
35402
|
-
|
|
35403
|
-
/**
|
|
35404
|
-
* Creates an array of own enumerable property names and symbols of `object`.
|
|
35405
|
-
*
|
|
35406
|
-
* @private
|
|
35407
|
-
* @param {Object} object The object to query.
|
|
35408
|
-
* @returns {Array} Returns the array of property names and symbols.
|
|
35409
|
-
*/
|
|
35410
|
-
function getAllKeys(object) {
|
|
35411
|
-
return baseGetAllKeys(object, keys, getSymbols);
|
|
35412
|
-
}
|
|
35413
|
-
|
|
35414
|
-
/**
|
|
35415
|
-
* Gets the data for `map`.
|
|
35416
|
-
*
|
|
35417
|
-
* @private
|
|
35418
|
-
* @param {Object} map The map to query.
|
|
35419
|
-
* @param {string} key The reference key.
|
|
35420
|
-
* @returns {*} Returns the map data.
|
|
35421
|
-
*/
|
|
35422
|
-
function getMapData(map, key) {
|
|
35423
|
-
var data = map.__data__;
|
|
35424
|
-
return isKeyable(key)
|
|
35425
|
-
? data[typeof key == 'string' ? 'string' : 'hash']
|
|
35426
|
-
: data.map;
|
|
35427
|
-
}
|
|
35428
|
-
|
|
35429
|
-
/**
|
|
35430
|
-
* Gets the native function at `key` of `object`.
|
|
35431
|
-
*
|
|
35432
|
-
* @private
|
|
35433
|
-
* @param {Object} object The object to query.
|
|
35434
|
-
* @param {string} key The key of the method to get.
|
|
35435
|
-
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
35436
|
-
*/
|
|
35437
|
-
function getNative(object, key) {
|
|
35438
|
-
var value = getValue(object, key);
|
|
35439
|
-
return baseIsNative(value) ? value : undefined;
|
|
35440
|
-
}
|
|
35441
|
-
|
|
35442
|
-
/**
|
|
35443
|
-
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
35444
|
-
*
|
|
35445
|
-
* @private
|
|
35446
|
-
* @param {*} value The value to query.
|
|
35447
|
-
* @returns {string} Returns the raw `toStringTag`.
|
|
35448
|
-
*/
|
|
35449
|
-
function getRawTag(value) {
|
|
35450
|
-
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
|
35451
|
-
tag = value[symToStringTag];
|
|
35452
|
-
|
|
35453
|
-
try {
|
|
35454
|
-
value[symToStringTag] = undefined;
|
|
35455
|
-
var unmasked = true;
|
|
35456
|
-
} catch (e) {}
|
|
35457
|
-
|
|
35458
|
-
var result = nativeObjectToString.call(value);
|
|
35459
|
-
if (unmasked) {
|
|
35460
|
-
if (isOwn) {
|
|
35461
|
-
value[symToStringTag] = tag;
|
|
35462
|
-
} else {
|
|
35463
|
-
delete value[symToStringTag];
|
|
35464
|
-
}
|
|
35465
|
-
}
|
|
35466
|
-
return result;
|
|
35467
|
-
}
|
|
35468
|
-
|
|
35469
|
-
/**
|
|
35470
|
-
* Creates an array of the own enumerable symbols of `object`.
|
|
35471
|
-
*
|
|
35472
|
-
* @private
|
|
35473
|
-
* @param {Object} object The object to query.
|
|
35474
|
-
* @returns {Array} Returns the array of symbols.
|
|
35475
|
-
*/
|
|
35476
|
-
var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
|
|
35477
|
-
if (object == null) {
|
|
35478
|
-
return [];
|
|
35479
|
-
}
|
|
35480
|
-
object = Object(object);
|
|
35481
|
-
return arrayFilter(nativeGetSymbols(object), function(symbol) {
|
|
35482
|
-
return propertyIsEnumerable.call(object, symbol);
|
|
35483
|
-
});
|
|
35484
|
-
};
|
|
35485
|
-
|
|
35486
|
-
/**
|
|
35487
|
-
* Gets the `toStringTag` of `value`.
|
|
35488
|
-
*
|
|
35489
|
-
* @private
|
|
35490
|
-
* @param {*} value The value to query.
|
|
35491
|
-
* @returns {string} Returns the `toStringTag`.
|
|
35492
|
-
*/
|
|
35493
|
-
var getTag = baseGetTag;
|
|
35494
|
-
|
|
35495
|
-
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
|
35496
|
-
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
|
35497
|
-
(Map && getTag(new Map) != mapTag) ||
|
|
35498
|
-
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
|
35499
|
-
(Set && getTag(new Set) != setTag) ||
|
|
35500
|
-
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
|
35501
|
-
getTag = function(value) {
|
|
35502
|
-
var result = baseGetTag(value),
|
|
35503
|
-
Ctor = result == objectTag ? value.constructor : undefined,
|
|
35504
|
-
ctorString = Ctor ? toSource(Ctor) : '';
|
|
35505
|
-
|
|
35506
|
-
if (ctorString) {
|
|
35507
|
-
switch (ctorString) {
|
|
35508
|
-
case dataViewCtorString: return dataViewTag;
|
|
35509
|
-
case mapCtorString: return mapTag;
|
|
35510
|
-
case promiseCtorString: return promiseTag;
|
|
35511
|
-
case setCtorString: return setTag;
|
|
35512
|
-
case weakMapCtorString: return weakMapTag;
|
|
35513
|
-
}
|
|
35514
|
-
}
|
|
35515
|
-
return result;
|
|
35516
|
-
};
|
|
35517
|
-
}
|
|
35518
|
-
|
|
35519
|
-
/**
|
|
35520
|
-
* Checks if `value` is a valid array-like index.
|
|
35521
|
-
*
|
|
35522
|
-
* @private
|
|
35523
|
-
* @param {*} value The value to check.
|
|
35524
|
-
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
|
35525
|
-
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
|
35526
|
-
*/
|
|
35527
|
-
function isIndex(value, length) {
|
|
35528
|
-
length = length == null ? MAX_SAFE_INTEGER : length;
|
|
35529
|
-
return !!length &&
|
|
35530
|
-
(typeof value == 'number' || reIsUint.test(value)) &&
|
|
35531
|
-
(value > -1 && value % 1 == 0 && value < length);
|
|
35532
|
-
}
|
|
35533
|
-
|
|
35534
|
-
/**
|
|
35535
|
-
* Checks if `value` is suitable for use as unique object key.
|
|
35536
|
-
*
|
|
35537
|
-
* @private
|
|
35538
|
-
* @param {*} value The value to check.
|
|
35539
|
-
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
35540
|
-
*/
|
|
35541
|
-
function isKeyable(value) {
|
|
35542
|
-
var type = typeof value;
|
|
35543
|
-
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|
35544
|
-
? (value !== '__proto__')
|
|
35545
|
-
: (value === null);
|
|
35546
|
-
}
|
|
35547
|
-
|
|
35548
|
-
/**
|
|
35549
|
-
* Checks if `func` has its source masked.
|
|
35550
|
-
*
|
|
35551
|
-
* @private
|
|
35552
|
-
* @param {Function} func The function to check.
|
|
35553
|
-
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
35554
|
-
*/
|
|
35555
|
-
function isMasked(func) {
|
|
35556
|
-
return !!maskSrcKey && (maskSrcKey in func);
|
|
35557
|
-
}
|
|
35558
|
-
|
|
35559
|
-
/**
|
|
35560
|
-
* Checks if `value` is likely a prototype object.
|
|
35561
|
-
*
|
|
35562
|
-
* @private
|
|
35563
|
-
* @param {*} value The value to check.
|
|
35564
|
-
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|
35565
|
-
*/
|
|
35566
|
-
function isPrototype(value) {
|
|
35567
|
-
var Ctor = value && value.constructor,
|
|
35568
|
-
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
|
|
35569
|
-
|
|
35570
|
-
return value === proto;
|
|
35571
|
-
}
|
|
35572
|
-
|
|
35573
|
-
/**
|
|
35574
|
-
* Converts `value` to a string using `Object.prototype.toString`.
|
|
35575
|
-
*
|
|
35576
|
-
* @private
|
|
35577
|
-
* @param {*} value The value to convert.
|
|
35578
|
-
* @returns {string} Returns the converted string.
|
|
35579
|
-
*/
|
|
35580
|
-
function objectToString(value) {
|
|
35581
|
-
return nativeObjectToString.call(value);
|
|
35582
|
-
}
|
|
35583
|
-
|
|
35584
|
-
/**
|
|
35585
|
-
* Converts `func` to its source code.
|
|
35586
|
-
*
|
|
35587
|
-
* @private
|
|
35588
|
-
* @param {Function} func The function to convert.
|
|
35589
|
-
* @returns {string} Returns the source code.
|
|
35590
|
-
*/
|
|
35591
|
-
function toSource(func) {
|
|
35592
|
-
if (func != null) {
|
|
35593
|
-
try {
|
|
35594
|
-
return funcToString.call(func);
|
|
35595
|
-
} catch (e) {}
|
|
35596
|
-
try {
|
|
35597
|
-
return (func + '');
|
|
35598
|
-
} catch (e) {}
|
|
35599
|
-
}
|
|
35600
|
-
return '';
|
|
35601
|
-
}
|
|
35602
|
-
|
|
35603
|
-
/**
|
|
35604
|
-
* Performs a
|
|
35605
|
-
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
35606
|
-
* comparison between two values to determine if they are equivalent.
|
|
35607
|
-
*
|
|
35608
|
-
* @static
|
|
35609
|
-
* @memberOf _
|
|
35610
|
-
* @since 4.0.0
|
|
35611
|
-
* @category Lang
|
|
35612
|
-
* @param {*} value The value to compare.
|
|
35613
|
-
* @param {*} other The other value to compare.
|
|
35614
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
35615
|
-
* @example
|
|
35616
|
-
*
|
|
35617
|
-
* var object = { 'a': 1 };
|
|
35618
|
-
* var other = { 'a': 1 };
|
|
35619
|
-
*
|
|
35620
|
-
* _.eq(object, object);
|
|
35621
|
-
* // => true
|
|
35622
|
-
*
|
|
35623
|
-
* _.eq(object, other);
|
|
35624
|
-
* // => false
|
|
35625
|
-
*
|
|
35626
|
-
* _.eq('a', 'a');
|
|
35627
|
-
* // => true
|
|
35628
|
-
*
|
|
35629
|
-
* _.eq('a', Object('a'));
|
|
35630
|
-
* // => false
|
|
35631
|
-
*
|
|
35632
|
-
* _.eq(NaN, NaN);
|
|
35633
|
-
* // => true
|
|
35634
|
-
*/
|
|
35635
|
-
function eq(value, other) {
|
|
35636
|
-
return value === other || (value !== value && other !== other);
|
|
35637
|
-
}
|
|
35638
|
-
|
|
35639
|
-
/**
|
|
35640
|
-
* Checks if `value` is likely an `arguments` object.
|
|
35641
|
-
*
|
|
35642
|
-
* @static
|
|
35643
|
-
* @memberOf _
|
|
35644
|
-
* @since 0.1.0
|
|
35645
|
-
* @category Lang
|
|
35646
|
-
* @param {*} value The value to check.
|
|
35647
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
35648
|
-
* else `false`.
|
|
35649
|
-
* @example
|
|
35650
|
-
*
|
|
35651
|
-
* _.isArguments(function() { return arguments; }());
|
|
35652
|
-
* // => true
|
|
35653
|
-
*
|
|
35654
|
-
* _.isArguments([1, 2, 3]);
|
|
35655
|
-
* // => false
|
|
35656
|
-
*/
|
|
35657
|
-
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
|
35658
|
-
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
|
35659
|
-
!propertyIsEnumerable.call(value, 'callee');
|
|
35660
|
-
};
|
|
35661
|
-
|
|
35662
|
-
/**
|
|
35663
|
-
* Checks if `value` is classified as an `Array` object.
|
|
35664
|
-
*
|
|
35665
|
-
* @static
|
|
35666
|
-
* @memberOf _
|
|
35667
|
-
* @since 0.1.0
|
|
35668
|
-
* @category Lang
|
|
35669
|
-
* @param {*} value The value to check.
|
|
35670
|
-
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
35671
|
-
* @example
|
|
35672
|
-
*
|
|
35673
|
-
* _.isArray([1, 2, 3]);
|
|
35674
|
-
* // => true
|
|
35675
|
-
*
|
|
35676
|
-
* _.isArray(document.body.children);
|
|
35677
|
-
* // => false
|
|
35678
|
-
*
|
|
35679
|
-
* _.isArray('abc');
|
|
35680
|
-
* // => false
|
|
35681
|
-
*
|
|
35682
|
-
* _.isArray(_.noop);
|
|
35683
|
-
* // => false
|
|
35684
|
-
*/
|
|
35685
|
-
var isArray = Array.isArray;
|
|
35686
|
-
|
|
35687
|
-
/**
|
|
35688
|
-
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
35689
|
-
* not a function and has a `value.length` that's an integer greater than or
|
|
35690
|
-
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
35691
|
-
*
|
|
35692
|
-
* @static
|
|
35693
|
-
* @memberOf _
|
|
35694
|
-
* @since 4.0.0
|
|
35695
|
-
* @category Lang
|
|
35696
|
-
* @param {*} value The value to check.
|
|
35697
|
-
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
35698
|
-
* @example
|
|
35699
|
-
*
|
|
35700
|
-
* _.isArrayLike([1, 2, 3]);
|
|
35701
|
-
* // => true
|
|
35702
|
-
*
|
|
35703
|
-
* _.isArrayLike(document.body.children);
|
|
35704
|
-
* // => true
|
|
35705
|
-
*
|
|
35706
|
-
* _.isArrayLike('abc');
|
|
35707
|
-
* // => true
|
|
35708
|
-
*
|
|
35709
|
-
* _.isArrayLike(_.noop);
|
|
35710
|
-
* // => false
|
|
35711
|
-
*/
|
|
35712
|
-
function isArrayLike(value) {
|
|
35713
|
-
return value != null && isLength(value.length) && !isFunction(value);
|
|
35714
|
-
}
|
|
35715
|
-
|
|
35716
|
-
/**
|
|
35717
|
-
* Checks if `value` is a buffer.
|
|
35718
|
-
*
|
|
35719
|
-
* @static
|
|
35720
|
-
* @memberOf _
|
|
35721
|
-
* @since 4.3.0
|
|
35722
|
-
* @category Lang
|
|
35723
|
-
* @param {*} value The value to check.
|
|
35724
|
-
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
35725
|
-
* @example
|
|
35726
|
-
*
|
|
35727
|
-
* _.isBuffer(new Buffer(2));
|
|
35728
|
-
* // => true
|
|
35729
|
-
*
|
|
35730
|
-
* _.isBuffer(new Uint8Array(2));
|
|
35731
|
-
* // => false
|
|
35732
|
-
*/
|
|
35733
|
-
var isBuffer = nativeIsBuffer || stubFalse;
|
|
35734
|
-
|
|
35735
|
-
/**
|
|
35736
|
-
* Performs a deep comparison between two values to determine if they are
|
|
35737
|
-
* equivalent.
|
|
35738
|
-
*
|
|
35739
|
-
* **Note:** This method supports comparing arrays, array buffers, booleans,
|
|
35740
|
-
* date objects, error objects, maps, numbers, `Object` objects, regexes,
|
|
35741
|
-
* sets, strings, symbols, and typed arrays. `Object` objects are compared
|
|
35742
|
-
* by their own, not inherited, enumerable properties. Functions and DOM
|
|
35743
|
-
* nodes are compared by strict equality, i.e. `===`.
|
|
35744
|
-
*
|
|
35745
|
-
* @static
|
|
35746
|
-
* @memberOf _
|
|
35747
|
-
* @since 0.1.0
|
|
35748
|
-
* @category Lang
|
|
35749
|
-
* @param {*} value The value to compare.
|
|
35750
|
-
* @param {*} other The other value to compare.
|
|
35751
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
35752
|
-
* @example
|
|
35753
|
-
*
|
|
35754
|
-
* var object = { 'a': 1 };
|
|
35755
|
-
* var other = { 'a': 1 };
|
|
35756
|
-
*
|
|
35757
|
-
* _.isEqual(object, other);
|
|
35758
|
-
* // => true
|
|
35759
|
-
*
|
|
35760
|
-
* object === other;
|
|
35761
|
-
* // => false
|
|
35762
|
-
*/
|
|
35763
|
-
function isEqual(value, other) {
|
|
35764
|
-
return baseIsEqual(value, other);
|
|
35765
|
-
}
|
|
35766
|
-
|
|
35767
|
-
/**
|
|
35768
|
-
* Checks if `value` is classified as a `Function` object.
|
|
35769
|
-
*
|
|
35770
|
-
* @static
|
|
35771
|
-
* @memberOf _
|
|
35772
|
-
* @since 0.1.0
|
|
35773
|
-
* @category Lang
|
|
35774
|
-
* @param {*} value The value to check.
|
|
35775
|
-
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
35776
|
-
* @example
|
|
35777
|
-
*
|
|
35778
|
-
* _.isFunction(_);
|
|
35779
|
-
* // => true
|
|
35780
|
-
*
|
|
35781
|
-
* _.isFunction(/abc/);
|
|
35782
|
-
* // => false
|
|
35783
|
-
*/
|
|
35784
|
-
function isFunction(value) {
|
|
35785
|
-
if (!isObject(value)) {
|
|
35786
|
-
return false;
|
|
35787
|
-
}
|
|
35788
|
-
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
35789
|
-
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
35790
|
-
var tag = baseGetTag(value);
|
|
35791
|
-
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
35792
|
-
}
|
|
35793
|
-
|
|
35794
|
-
/**
|
|
35795
|
-
* Checks if `value` is a valid array-like length.
|
|
35796
|
-
*
|
|
35797
|
-
* **Note:** This method is loosely based on
|
|
35798
|
-
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
35799
|
-
*
|
|
35800
|
-
* @static
|
|
35801
|
-
* @memberOf _
|
|
35802
|
-
* @since 4.0.0
|
|
35803
|
-
* @category Lang
|
|
35804
|
-
* @param {*} value The value to check.
|
|
35805
|
-
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
35806
|
-
* @example
|
|
35807
|
-
*
|
|
35808
|
-
* _.isLength(3);
|
|
35809
|
-
* // => true
|
|
35810
|
-
*
|
|
35811
|
-
* _.isLength(Number.MIN_VALUE);
|
|
35812
|
-
* // => false
|
|
35813
|
-
*
|
|
35814
|
-
* _.isLength(Infinity);
|
|
35815
|
-
* // => false
|
|
35816
|
-
*
|
|
35817
|
-
* _.isLength('3');
|
|
35818
|
-
* // => false
|
|
35819
|
-
*/
|
|
35820
|
-
function isLength(value) {
|
|
35821
|
-
return typeof value == 'number' &&
|
|
35822
|
-
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
35823
|
-
}
|
|
35824
|
-
|
|
35825
|
-
/**
|
|
35826
|
-
* Checks if `value` is the
|
|
35827
|
-
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
35828
|
-
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
35829
|
-
*
|
|
35830
|
-
* @static
|
|
35831
|
-
* @memberOf _
|
|
35832
|
-
* @since 0.1.0
|
|
35833
|
-
* @category Lang
|
|
35834
|
-
* @param {*} value The value to check.
|
|
35835
|
-
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
35836
|
-
* @example
|
|
35837
|
-
*
|
|
35838
|
-
* _.isObject({});
|
|
35839
|
-
* // => true
|
|
35840
|
-
*
|
|
35841
|
-
* _.isObject([1, 2, 3]);
|
|
35842
|
-
* // => true
|
|
35843
|
-
*
|
|
35844
|
-
* _.isObject(_.noop);
|
|
35845
|
-
* // => true
|
|
35846
|
-
*
|
|
35847
|
-
* _.isObject(null);
|
|
35848
|
-
* // => false
|
|
35849
|
-
*/
|
|
35850
|
-
function isObject(value) {
|
|
35851
|
-
var type = typeof value;
|
|
35852
|
-
return value != null && (type == 'object' || type == 'function');
|
|
35853
|
-
}
|
|
35854
|
-
|
|
35855
|
-
/**
|
|
35856
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
35857
|
-
* and has a `typeof` result of "object".
|
|
35858
|
-
*
|
|
35859
|
-
* @static
|
|
35860
|
-
* @memberOf _
|
|
35861
|
-
* @since 4.0.0
|
|
35862
|
-
* @category Lang
|
|
35863
|
-
* @param {*} value The value to check.
|
|
35864
|
-
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
35865
|
-
* @example
|
|
35866
|
-
*
|
|
35867
|
-
* _.isObjectLike({});
|
|
35868
|
-
* // => true
|
|
35869
|
-
*
|
|
35870
|
-
* _.isObjectLike([1, 2, 3]);
|
|
35871
|
-
* // => true
|
|
35872
|
-
*
|
|
35873
|
-
* _.isObjectLike(_.noop);
|
|
35874
|
-
* // => false
|
|
35875
|
-
*
|
|
35876
|
-
* _.isObjectLike(null);
|
|
35877
|
-
* // => false
|
|
35878
|
-
*/
|
|
35879
|
-
function isObjectLike(value) {
|
|
35880
|
-
return value != null && typeof value == 'object';
|
|
35881
|
-
}
|
|
35882
|
-
|
|
35883
|
-
/**
|
|
35884
|
-
* Checks if `value` is classified as a typed array.
|
|
35885
|
-
*
|
|
35886
|
-
* @static
|
|
35887
|
-
* @memberOf _
|
|
35888
|
-
* @since 3.0.0
|
|
35889
|
-
* @category Lang
|
|
35890
|
-
* @param {*} value The value to check.
|
|
35891
|
-
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
35892
|
-
* @example
|
|
35893
|
-
*
|
|
35894
|
-
* _.isTypedArray(new Uint8Array);
|
|
35895
|
-
* // => true
|
|
35896
|
-
*
|
|
35897
|
-
* _.isTypedArray([]);
|
|
35898
|
-
* // => false
|
|
35899
|
-
*/
|
|
35900
|
-
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
35901
|
-
|
|
35902
|
-
/**
|
|
35903
|
-
* Creates an array of the own enumerable property names of `object`.
|
|
35904
|
-
*
|
|
35905
|
-
* **Note:** Non-object values are coerced to objects. See the
|
|
35906
|
-
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
|
35907
|
-
* for more details.
|
|
35908
|
-
*
|
|
35909
|
-
* @static
|
|
35910
|
-
* @since 0.1.0
|
|
35911
|
-
* @memberOf _
|
|
35912
|
-
* @category Object
|
|
35913
|
-
* @param {Object} object The object to query.
|
|
35914
|
-
* @returns {Array} Returns the array of property names.
|
|
35915
|
-
* @example
|
|
35916
|
-
*
|
|
35917
|
-
* function Foo() {
|
|
35918
|
-
* this.a = 1;
|
|
35919
|
-
* this.b = 2;
|
|
35920
|
-
* }
|
|
35921
|
-
*
|
|
35922
|
-
* Foo.prototype.c = 3;
|
|
35923
|
-
*
|
|
35924
|
-
* _.keys(new Foo);
|
|
35925
|
-
* // => ['a', 'b'] (iteration order is not guaranteed)
|
|
35926
|
-
*
|
|
35927
|
-
* _.keys('hi');
|
|
35928
|
-
* // => ['0', '1']
|
|
35929
|
-
*/
|
|
35930
|
-
function keys(object) {
|
|
35931
|
-
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|
35932
|
-
}
|
|
35933
|
-
|
|
35934
|
-
/**
|
|
35935
|
-
* This method returns a new empty array.
|
|
35936
|
-
*
|
|
35937
|
-
* @static
|
|
35938
|
-
* @memberOf _
|
|
35939
|
-
* @since 4.13.0
|
|
35940
|
-
* @category Util
|
|
35941
|
-
* @returns {Array} Returns the new empty array.
|
|
35942
|
-
* @example
|
|
35943
|
-
*
|
|
35944
|
-
* var arrays = _.times(2, _.stubArray);
|
|
35945
|
-
*
|
|
35946
|
-
* console.log(arrays);
|
|
35947
|
-
* // => [[], []]
|
|
35948
|
-
*
|
|
35949
|
-
* console.log(arrays[0] === arrays[1]);
|
|
35950
|
-
* // => false
|
|
35951
|
-
*/
|
|
35952
|
-
function stubArray() {
|
|
35953
|
-
return [];
|
|
35954
|
-
}
|
|
35955
|
-
|
|
35956
|
-
/**
|
|
35957
|
-
* This method returns `false`.
|
|
35958
|
-
*
|
|
35959
|
-
* @static
|
|
35960
|
-
* @memberOf _
|
|
35961
|
-
* @since 4.13.0
|
|
35962
|
-
* @category Util
|
|
35963
|
-
* @returns {boolean} Returns `false`.
|
|
35964
|
-
* @example
|
|
35965
|
-
*
|
|
35966
|
-
* _.times(2, _.stubFalse);
|
|
35967
|
-
* // => [false, false]
|
|
35968
|
-
*/
|
|
35969
|
-
function stubFalse() {
|
|
35970
|
-
return false;
|
|
35971
|
-
}
|
|
35972
|
-
|
|
35973
|
-
module.exports = isEqual;
|
|
35974
|
-
});
|
|
35975
|
-
|
|
35976
|
-
/**
|
|
35977
|
-
* @description i18n en
|
|
35978
|
-
* @author wangfupeng
|
|
35979
|
-
*/
|
|
35980
|
-
var enResources$3 = {
|
|
35981
|
-
tableModule: {
|
|
35982
|
-
deleteCol: 'Delete column',
|
|
35983
|
-
deleteRow: 'Delete row',
|
|
35984
|
-
deleteTable: 'Delete table',
|
|
35985
|
-
widthAuto: 'Width auto',
|
|
35986
|
-
insertCol: 'Insert column',
|
|
35987
|
-
insertRow: 'Insert row',
|
|
35988
|
-
insertTable: 'Insert table',
|
|
35989
|
-
header: 'Header',
|
|
35990
|
-
},
|
|
35991
|
-
};
|
|
35992
|
-
|
|
35993
|
-
/**
|
|
35994
|
-
* @description i18n zh-CN
|
|
35995
|
-
* @author wangfupeng
|
|
35996
|
-
*/
|
|
35997
|
-
var zhResources$3 = {
|
|
35998
|
-
tableModule: {
|
|
35999
|
-
deleteCol: '删除列',
|
|
36000
|
-
deleteRow: '删除行',
|
|
36001
|
-
deleteTable: '删除表格',
|
|
36002
|
-
widthAuto: '宽度自适应',
|
|
36003
|
-
insertCol: '插入列',
|
|
36004
|
-
insertRow: '插入行',
|
|
36005
|
-
insertTable: '插入表格',
|
|
36006
|
-
header: '表头',
|
|
36007
|
-
},
|
|
36008
|
-
};
|
|
36009
|
-
|
|
36010
|
-
/**
|
|
36011
|
-
* @description i18n entry
|
|
36012
|
-
* @author wangfupeng
|
|
36013
|
-
*/
|
|
36014
|
-
i18nAddResources('en', enResources$3);
|
|
36015
|
-
i18nAddResources('zh-CN', zhResources$3);
|
|
36016
|
-
|
|
36017
|
-
/*! *****************************************************************************
|
|
36018
|
-
Copyright (c) Microsoft Corporation.
|
|
36019
|
-
|
|
36020
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
36021
|
-
purpose with or without fee is hereby granted.
|
|
36022
|
-
|
|
36023
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
36024
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
36025
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
36026
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
36027
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
36028
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
36029
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
36030
|
-
***************************************************************************** */
|
|
36031
|
-
|
|
36032
|
-
function __values$3(o) {
|
|
36033
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
36034
|
-
if (m) return m.call(o);
|
|
36035
|
-
if (o && typeof o.length === "number") return {
|
|
36036
|
-
next: function () {
|
|
36037
|
-
if (o && i >= o.length) o = void 0;
|
|
36038
|
-
return { value: o && o[i++], done: !o };
|
|
36039
|
-
}
|
|
36040
|
-
};
|
|
36041
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
36042
|
-
}
|
|
36043
|
-
|
|
36044
|
-
function __read$3(o, n) {
|
|
36045
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
36046
|
-
if (!m) return o;
|
|
36047
|
-
var i = m.call(o), r, ar = [], e;
|
|
36048
|
-
try {
|
|
36049
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
36050
|
-
}
|
|
36051
|
-
catch (error) { e = { error: error }; }
|
|
36052
|
-
finally {
|
|
36053
|
-
try {
|
|
36054
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
36055
|
-
}
|
|
36056
|
-
finally { if (e) throw e.error; }
|
|
36057
|
-
}
|
|
36058
|
-
return ar;
|
|
36059
|
-
}
|
|
34563
|
+
function withSelection(editor) {
|
|
34564
|
+
var apply = editor.apply;
|
|
34565
|
+
editor.apply = function (op) {
|
|
34566
|
+
if (!Operation.isSelectionOperation(op) || !op.newProperties) {
|
|
34567
|
+
// TableCursor.unselect(editor);
|
|
34568
|
+
// 仿飞书效果,拖动单元格宽度时,选区不消失
|
|
34569
|
+
return apply(op);
|
|
34570
|
+
}
|
|
34571
|
+
var selection = __assign$3(__assign$3({}, editor.selection), op.newProperties);
|
|
34572
|
+
if (!Range.isRange(selection)) {
|
|
34573
|
+
TableCursor.unselect(editor);
|
|
34574
|
+
return apply(op);
|
|
34575
|
+
}
|
|
34576
|
+
var _a = __read$3(Editor.nodes(editor, {
|
|
34577
|
+
match: isOfType(editor, 'th', 'td'),
|
|
34578
|
+
at: Range.start(selection),
|
|
34579
|
+
}), 1), fromEntry = _a[0];
|
|
34580
|
+
var _b = __read$3(Editor.nodes(editor, {
|
|
34581
|
+
match: isOfType(editor, 'th', 'td'),
|
|
34582
|
+
at: Range.end(selection),
|
|
34583
|
+
}), 1), toEntry = _b[0];
|
|
34584
|
+
if (!fromEntry || !toEntry) {
|
|
34585
|
+
TableCursor.unselect(editor);
|
|
34586
|
+
return apply(op);
|
|
34587
|
+
}
|
|
34588
|
+
var _c = __read$3(fromEntry, 2), fromPath = _c[1];
|
|
34589
|
+
var _d = __read$3(toEntry, 2), toPath = _d[1];
|
|
34590
|
+
if (Path.equals(fromPath, toPath) || !hasCommon(editor, [fromPath, toPath], 'table')) {
|
|
34591
|
+
TableCursor.unselect(editor);
|
|
34592
|
+
return apply(op);
|
|
34593
|
+
}
|
|
34594
|
+
// TODO: perf: could be improved by passing a Span [fromPath, toPath]
|
|
34595
|
+
var filled = filledMatrix(editor, { at: fromPath });
|
|
34596
|
+
// find initial bounds
|
|
34597
|
+
var from = Point.valueOf(0, 0);
|
|
34598
|
+
var to = Point.valueOf(0, 0);
|
|
34599
|
+
outer: for (var x = 0; x < filled.length; x++) {
|
|
34600
|
+
for (var y = 0; y < filled[x].length; y++) {
|
|
34601
|
+
var _e = __read$3(filled[x][y], 1), _f = __read$3(_e[0], 2), path = _f[1];
|
|
34602
|
+
if (Path.equals(fromPath, path)) {
|
|
34603
|
+
from.x = x;
|
|
34604
|
+
from.y = y;
|
|
34605
|
+
}
|
|
34606
|
+
if (Path.equals(toPath, path)) {
|
|
34607
|
+
to.x = x;
|
|
34608
|
+
to.y = y;
|
|
34609
|
+
break outer;
|
|
34610
|
+
}
|
|
34611
|
+
}
|
|
34612
|
+
}
|
|
34613
|
+
var start = Point.valueOf(Math.min(from.x, to.x), Math.min(from.y, to.y));
|
|
34614
|
+
var end = Point.valueOf(Math.max(from.x, to.x), Math.max(from.y, to.y));
|
|
34615
|
+
// expand the selection based on rowspan and colspan
|
|
34616
|
+
for (;;) {
|
|
34617
|
+
var nextStart = Point.valueOf(start.x, start.y);
|
|
34618
|
+
var nextEnd = Point.valueOf(end.x, end.y);
|
|
34619
|
+
for (var x = nextStart.x; x <= nextEnd.x; x++) {
|
|
34620
|
+
for (var y = nextStart.y; y <= nextEnd.y; y++) {
|
|
34621
|
+
var _g = __read$3(filled[x][y], 2), _h = _g[1], rtl = _h.rtl, ltr = _h.ltr, btt = _h.btt, ttb = _h.ttb;
|
|
34622
|
+
nextStart.x = Math.min(nextStart.x, x - (ttb - 1));
|
|
34623
|
+
nextStart.y = Math.min(nextStart.y, y - (rtl - 1));
|
|
34624
|
+
nextEnd.x = Math.max(nextEnd.x, x + (btt - 1));
|
|
34625
|
+
nextEnd.y = Math.max(nextEnd.y, y + (ltr - 1));
|
|
34626
|
+
}
|
|
34627
|
+
}
|
|
34628
|
+
if (Point.equals(start, nextStart) && Point.equals(end, nextEnd)) {
|
|
34629
|
+
break;
|
|
34630
|
+
}
|
|
34631
|
+
start = nextStart;
|
|
34632
|
+
end = nextEnd;
|
|
34633
|
+
}
|
|
34634
|
+
var selected = [];
|
|
34635
|
+
var selectedSet = new WeakSet();
|
|
34636
|
+
for (var x = start.x; x <= end.x; x++) {
|
|
34637
|
+
var cells = [];
|
|
34638
|
+
for (var y = start.y; y <= end.y; y++) {
|
|
34639
|
+
var _j = __read$3(filled[x][y], 1), _k = __read$3(_j[0], 1), element = _k[0];
|
|
34640
|
+
selectedSet.add(element);
|
|
34641
|
+
cells.push(filled[x][y]);
|
|
34642
|
+
}
|
|
34643
|
+
selected.push(cells);
|
|
34644
|
+
}
|
|
34645
|
+
EDITOR_TO_SELECTION.set(editor, selected);
|
|
34646
|
+
EDITOR_TO_SELECTION_SET.set(editor, selectedSet);
|
|
34647
|
+
apply(op);
|
|
34648
|
+
};
|
|
34649
|
+
return editor;
|
|
34650
|
+
}
|
|
36060
34651
|
|
|
36061
34652
|
/**
|
|
36062
34653
|
* @description editor 插件,重写 editor API
|
|
@@ -36073,7 +34664,7 @@ function deleteHandler(newEditor) {
|
|
|
36073
34664
|
if (cellNodeEntry) {
|
|
36074
34665
|
var _b = __read$3(cellNodeEntry, 2), cellPath = _b[1];
|
|
36075
34666
|
var start = Editor.start(newEditor, cellPath);
|
|
36076
|
-
if (Point.equals(selection.anchor, start)) {
|
|
34667
|
+
if (Point$1.equals(selection.anchor, start)) {
|
|
36077
34668
|
return true; // 阻止删除 cell
|
|
36078
34669
|
}
|
|
36079
34670
|
}
|
|
@@ -36247,49 +34838,299 @@ function withTable(editor) {
|
|
|
36247
34838
|
};
|
|
36248
34839
|
newEditor.select(newSelection); // 选中 table-cell 内部的全部文字
|
|
36249
34840
|
};
|
|
34841
|
+
/**
|
|
34842
|
+
* 光标选区行为新增
|
|
34843
|
+
*/
|
|
34844
|
+
withSelection(newEditor);
|
|
36250
34845
|
// 可继续修改其他 newEditor API ...
|
|
36251
34846
|
// 返回 editor ,重要!
|
|
36252
34847
|
return newEditor;
|
|
36253
34848
|
}
|
|
36254
34849
|
|
|
36255
34850
|
/**
|
|
36256
|
-
* @description
|
|
34851
|
+
* @description DOM 操作
|
|
36257
34852
|
* @author wangfupeng
|
|
36258
34853
|
*/
|
|
34854
|
+
if (append)
|
|
34855
|
+
$.fn.append = append;
|
|
34856
|
+
if (on)
|
|
34857
|
+
$.fn.on = on;
|
|
34858
|
+
if (focus)
|
|
34859
|
+
$.fn.focus = focus;
|
|
34860
|
+
if (attr)
|
|
34861
|
+
$.fn.attr = attr;
|
|
34862
|
+
if (val)
|
|
34863
|
+
$.fn.val = val;
|
|
34864
|
+
if (html)
|
|
34865
|
+
$.fn.html = html;
|
|
34866
|
+
if (dataset)
|
|
34867
|
+
$.fn.dataset = dataset;
|
|
34868
|
+
if (addClass)
|
|
34869
|
+
$.fn.addClass = addClass;
|
|
34870
|
+
if (removeClass)
|
|
34871
|
+
$.fn.removeClass = removeClass;
|
|
34872
|
+
if (children)
|
|
34873
|
+
$.fn.children = children;
|
|
34874
|
+
if (each)
|
|
34875
|
+
$.fn.each = each;
|
|
34876
|
+
if (find)
|
|
34877
|
+
$.fn.find = find;
|
|
36259
34878
|
/**
|
|
36260
|
-
*
|
|
36261
|
-
* @param
|
|
34879
|
+
* 获取 tagName lower-case
|
|
34880
|
+
* @param $elem $elem
|
|
36262
34881
|
*/
|
|
36263
|
-
function
|
|
36264
|
-
|
|
36265
|
-
|
|
36266
|
-
|
|
36267
|
-
var firstRow = rows[0] || {}; // 第一行
|
|
36268
|
-
var cells = firstRow.children || []; // 第一行所有 cell
|
|
36269
|
-
return cells;
|
|
34882
|
+
function getTagName$1($elem) {
|
|
34883
|
+
if ($elem.length)
|
|
34884
|
+
return $elem[0].tagName.toLowerCase();
|
|
34885
|
+
return '';
|
|
36270
34886
|
}
|
|
36271
34887
|
/**
|
|
36272
|
-
*
|
|
36273
|
-
* @param
|
|
34888
|
+
* 获取 $elem 某一个 style 值
|
|
34889
|
+
* @param $elem $elem
|
|
34890
|
+
* @param styleKey style key
|
|
36274
34891
|
*/
|
|
36275
|
-
function
|
|
36276
|
-
var
|
|
36277
|
-
|
|
34892
|
+
function getStyleValue($elem, styleKey) {
|
|
34893
|
+
var res = '';
|
|
34894
|
+
var styleStr = $elem.attr('style') || ''; // 如 'line-height: 2.5; color: red;'
|
|
34895
|
+
var styleArr = styleStr.split(';'); // 如 ['line-height: 2.5', ' color: red', '']
|
|
34896
|
+
var length = styleArr.length;
|
|
34897
|
+
for (var i = 0; i < length; i++) {
|
|
34898
|
+
var styleItemStr = styleArr[i]; // 如 'line-height: 2.5'
|
|
34899
|
+
if (styleItemStr) {
|
|
34900
|
+
var arr = styleItemStr.split(':'); // ['line-height', ' 2.5']
|
|
34901
|
+
if (arr[0].trim() === styleKey) {
|
|
34902
|
+
res = arr[1].trim();
|
|
34903
|
+
}
|
|
34904
|
+
}
|
|
34905
|
+
}
|
|
34906
|
+
return res;
|
|
34907
|
+
}
|
|
34908
|
+
|
|
34909
|
+
/***
|
|
34910
|
+
* 计算 cell border 距离 table 左侧距离
|
|
34911
|
+
*/
|
|
34912
|
+
function getCumulativeWidths(columnWidths) {
|
|
34913
|
+
var e_1, _a;
|
|
34914
|
+
var cumulativeWidths = [];
|
|
34915
|
+
var totalWidth = 0;
|
|
34916
|
+
try {
|
|
34917
|
+
for (var columnWidths_1 = __values$3(columnWidths), columnWidths_1_1 = columnWidths_1.next(); !columnWidths_1_1.done; columnWidths_1_1 = columnWidths_1.next()) {
|
|
34918
|
+
var width = columnWidths_1_1.value;
|
|
34919
|
+
totalWidth += width;
|
|
34920
|
+
cumulativeWidths.push(totalWidth);
|
|
34921
|
+
}
|
|
34922
|
+
}
|
|
34923
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
34924
|
+
finally {
|
|
34925
|
+
try {
|
|
34926
|
+
if (columnWidths_1_1 && !columnWidths_1_1.done && (_a = columnWidths_1.return)) _a.call(columnWidths_1);
|
|
34927
|
+
}
|
|
34928
|
+
finally { if (e_1) throw e_1.error; }
|
|
34929
|
+
}
|
|
34930
|
+
return cumulativeWidths;
|
|
34931
|
+
}
|
|
34932
|
+
/***
|
|
34933
|
+
* 用于计算拖动 cell 时,cell 宽度变化的比例
|
|
34934
|
+
*/
|
|
34935
|
+
function getColumnWidthRatios(columnWidths) {
|
|
34936
|
+
var e_2, _a;
|
|
34937
|
+
var columnWidthsRatio = [];
|
|
34938
|
+
var totalWidth = columnWidths.reduce(function (a, b) { return a + b; }, 0);
|
|
34939
|
+
try {
|
|
34940
|
+
for (var columnWidths_2 = __values$3(columnWidths), columnWidths_2_1 = columnWidths_2.next(); !columnWidths_2_1.done; columnWidths_2_1 = columnWidths_2.next()) {
|
|
34941
|
+
var width = columnWidths_2_1.value;
|
|
34942
|
+
columnWidthsRatio.push(width / totalWidth);
|
|
34943
|
+
}
|
|
34944
|
+
}
|
|
34945
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
34946
|
+
finally {
|
|
34947
|
+
try {
|
|
34948
|
+
if (columnWidths_2_1 && !columnWidths_2_1.done && (_a = columnWidths_2.return)) _a.call(columnWidths_2);
|
|
34949
|
+
}
|
|
34950
|
+
finally { if (e_2) throw e_2.error; }
|
|
34951
|
+
}
|
|
34952
|
+
return columnWidthsRatio;
|
|
36278
34953
|
}
|
|
36279
34954
|
/**
|
|
36280
|
-
*
|
|
36281
|
-
*
|
|
36282
|
-
|
|
34955
|
+
* 监听 table 内部变化,如新增行、列,删除行列等操作,引起的高度变化。
|
|
34956
|
+
* ResizeObserver 需要即时释放,以免引起内存泄露
|
|
34957
|
+
*/
|
|
34958
|
+
var resizeObserver = null;
|
|
34959
|
+
function observerTableResize(editor, elm) {
|
|
34960
|
+
if (elm instanceof HTMLElement) {
|
|
34961
|
+
var table = elm.querySelector('table');
|
|
34962
|
+
if (table) {
|
|
34963
|
+
resizeObserver = new ResizeObserver(function (_a) {
|
|
34964
|
+
var _b = __read$3(_a, 1), contentRect = _b[0].contentRect;
|
|
34965
|
+
// 当非拖动引起的宽度变化,需要调整 columnWidths
|
|
34966
|
+
Transforms.setNodes(editor, {
|
|
34967
|
+
scrollWidth: contentRect.width,
|
|
34968
|
+
height: contentRect.height,
|
|
34969
|
+
}, { mode: 'highest' });
|
|
34970
|
+
});
|
|
34971
|
+
resizeObserver.observe(table);
|
|
34972
|
+
}
|
|
34973
|
+
}
|
|
34974
|
+
}
|
|
34975
|
+
function unObserveTableResize() {
|
|
34976
|
+
if (resizeObserver) {
|
|
34977
|
+
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
|
|
34978
|
+
resizeObserver = null;
|
|
34979
|
+
}
|
|
34980
|
+
}
|
|
34981
|
+
// 是否为光标选区行为
|
|
34982
|
+
var isSelectionOperation = false;
|
|
34983
|
+
// 拖拽列宽相关信息
|
|
34984
|
+
var isMouseDownForResize = false;
|
|
34985
|
+
var clientXWhenMouseDown = 0;
|
|
34986
|
+
var cellWidthWhenMouseDown = 0;
|
|
34987
|
+
var editorWhenMouseDown = null;
|
|
34988
|
+
var $window = $(window);
|
|
34989
|
+
$window.on('mousedown', onMouseDown);
|
|
34990
|
+
function onMouseDown(event) {
|
|
34991
|
+
var elem = event.target;
|
|
34992
|
+
// 判断是否为光标选区行为,对列宽变更行为进行过滤
|
|
34993
|
+
// console.log('onMouseDown', elem)
|
|
34994
|
+
if (elem.closest('[data-block-type="table-cell"]')) {
|
|
34995
|
+
isSelectionOperation = true;
|
|
34996
|
+
}
|
|
34997
|
+
else if (elem.tagName == 'DIV' && elem.closest('.column-resizer-item')) {
|
|
34998
|
+
if (editorWhenMouseDown == null)
|
|
34999
|
+
return;
|
|
35000
|
+
var _a = __read$3(Editor.nodes(editorWhenMouseDown, {
|
|
35001
|
+
match: isOfType(editorWhenMouseDown, 'table'),
|
|
35002
|
+
}), 1), _b = __read$3(_a[0], 1), elemNode = _b[0];
|
|
35003
|
+
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;
|
|
35004
|
+
/**
|
|
35005
|
+
* table width 为 100% 模式时,因无法增加Table宽度,不触发 列宽变更行为
|
|
35006
|
+
* 如需变更,到底哪个列增宽度,哪个列减去宽度??
|
|
35007
|
+
*/
|
|
35008
|
+
if (tableWidth == '100%')
|
|
35009
|
+
return;
|
|
35010
|
+
// 记录必要信息
|
|
35011
|
+
isMouseDownForResize = true;
|
|
35012
|
+
var clientX = event.clientX;
|
|
35013
|
+
clientXWhenMouseDown = clientX;
|
|
35014
|
+
cellWidthWhenMouseDown = columnWidths[resizingIndex];
|
|
35015
|
+
document.body.style.cursor = 'col-resize';
|
|
35016
|
+
event.preventDefault();
|
|
35017
|
+
}
|
|
35018
|
+
$window.on('mousemove', onMouseMove);
|
|
35019
|
+
$window.on('mouseup', onMouseUp);
|
|
35020
|
+
}
|
|
35021
|
+
var onMouseMove = lodash_throttle(function (event) {
|
|
35022
|
+
if (!isMouseDownForResize)
|
|
35023
|
+
return;
|
|
35024
|
+
if (editorWhenMouseDown == null)
|
|
35025
|
+
return;
|
|
35026
|
+
event.preventDefault();
|
|
35027
|
+
var clientX = event.clientX;
|
|
35028
|
+
var newWith = cellWidthWhenMouseDown + (clientX - clientXWhenMouseDown); // 计算新宽度
|
|
35029
|
+
newWith = Math.floor(newWith * 100) / 100; // 保留小数点后两位
|
|
35030
|
+
if (newWith < 30)
|
|
35031
|
+
newWith = 30; // 最小宽度
|
|
35032
|
+
var _a = __read$3(Editor.nodes(editorWhenMouseDown, {
|
|
35033
|
+
match: isOfType(editorWhenMouseDown, 'table'),
|
|
35034
|
+
}), 1), _b = __read$3(_a[0], 1), elemNode = _b[0];
|
|
35035
|
+
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;
|
|
35036
|
+
/**
|
|
35037
|
+
* 判断拖动引起的宽度是否最大化了
|
|
35038
|
+
* 如果最大化了,则需要调整列的宽度
|
|
35039
|
+
*
|
|
35040
|
+
* 0.5 很微妙
|
|
35041
|
+
*/
|
|
35042
|
+
var cumulativeTotalWidth = columnWidths.reduce(function (a, b) { return a + b; }, 0);
|
|
35043
|
+
var remainWidth = cumulativeTotalWidth - columnWidths[resizingIndex];
|
|
35044
|
+
if (cumulativeTotalWidth > scrollWidth && remainWidth + newWith > scrollWidth) {
|
|
35045
|
+
newWith = scrollWidth - remainWidth + 0.5;
|
|
35046
|
+
}
|
|
35047
|
+
var adjustColumnWidths = __spreadArray([], __read$3(columnWidths)).map(function (width) { return Math.floor(width); });
|
|
35048
|
+
adjustColumnWidths[resizingIndex] = newWith;
|
|
35049
|
+
// 这是宽度
|
|
35050
|
+
Transforms.setNodes(editorWhenMouseDown, { columnWidths: adjustColumnWidths }, {
|
|
35051
|
+
mode: 'highest',
|
|
35052
|
+
});
|
|
35053
|
+
}, 100);
|
|
35054
|
+
function onMouseUp(event) {
|
|
35055
|
+
isSelectionOperation = false;
|
|
35056
|
+
isMouseDownForResize = false;
|
|
35057
|
+
editorWhenMouseDown = null;
|
|
35058
|
+
document.body.style.cursor = '';
|
|
35059
|
+
// 解绑事件
|
|
35060
|
+
$window.off('mousemove', onMouseMove);
|
|
35061
|
+
$window.off('mouseup', onMouseUp);
|
|
35062
|
+
}
|
|
35063
|
+
/**
|
|
35064
|
+
* 鼠标移动时,判断在哪个 Cell border 上
|
|
35065
|
+
* Class 先 visible 后 highlight @跟随飞书
|
|
35066
|
+
* 避免光标选区功能收到干扰
|
|
36283
35067
|
*/
|
|
36284
|
-
function
|
|
36285
|
-
|
|
36286
|
-
|
|
36287
|
-
|
|
36288
|
-
|
|
36289
|
-
|
|
36290
|
-
|
|
36291
|
-
|
|
36292
|
-
|
|
35068
|
+
function handleCellBorderVisible(editor, elemNode, e) {
|
|
35069
|
+
if (editor.isDisabled())
|
|
35070
|
+
return;
|
|
35071
|
+
if (isSelectionOperation || isMouseDownForResize)
|
|
35072
|
+
return;
|
|
35073
|
+
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;
|
|
35074
|
+
/**
|
|
35075
|
+
* table width 为 100% 模式时,因无法增加Table宽度,不触发 列宽变更行为
|
|
35076
|
+
* 如需变更,到底哪个列增宽度,哪个列减去宽度??
|
|
35077
|
+
*/
|
|
35078
|
+
if (tableWidth == '100%')
|
|
35079
|
+
return;
|
|
35080
|
+
// Cell Border 宽度为 10px
|
|
35081
|
+
var clientX = e.clientX, target = e.target;
|
|
35082
|
+
// 当单元格合并的时候,鼠标在 cell 中间,则不显示 cell border
|
|
35083
|
+
if (target instanceof HTMLElement) {
|
|
35084
|
+
var rect = target.getBoundingClientRect();
|
|
35085
|
+
if (clientX > rect.x + 5 && clientX < rect.x + rect.width - 5) {
|
|
35086
|
+
if (isHoverCellBorder) {
|
|
35087
|
+
Transforms.setNodes(editor, { isHoverCellBorder: false, resizingIndex: -1 }, { mode: 'highest' });
|
|
35088
|
+
}
|
|
35089
|
+
return;
|
|
35090
|
+
}
|
|
35091
|
+
}
|
|
35092
|
+
if (target instanceof HTMLElement) {
|
|
35093
|
+
var parent_1 = target.closest('.table');
|
|
35094
|
+
if (parent_1) {
|
|
35095
|
+
var clientX_1 = e.clientX;
|
|
35096
|
+
var rect = parent_1.getBoundingClientRect();
|
|
35097
|
+
var cumulativeWidths = getCumulativeWidths(columnWidths);
|
|
35098
|
+
// 鼠标移动时,计算当前鼠标位置,判断在哪个 Cell border 上
|
|
35099
|
+
for (var i = 0; i < cumulativeWidths.length; i++) {
|
|
35100
|
+
if (clientX_1 - rect.x >= cumulativeWidths[i] - 5 &&
|
|
35101
|
+
clientX_1 - rect.x < cumulativeWidths[i] + 5) {
|
|
35102
|
+
// 节流,防止多次引起Transforms.setNodes重绘
|
|
35103
|
+
if (resizingIndex == i)
|
|
35104
|
+
return;
|
|
35105
|
+
Transforms.setNodes(editor, { isHoverCellBorder: true, resizingIndex: i }, { mode: 'highest' });
|
|
35106
|
+
return;
|
|
35107
|
+
}
|
|
35108
|
+
}
|
|
35109
|
+
}
|
|
35110
|
+
}
|
|
35111
|
+
// 鼠标移出时,重置
|
|
35112
|
+
if (isHoverCellBorder == true) {
|
|
35113
|
+
Transforms.setNodes(editor, { isHoverCellBorder: false, resizingIndex: -1 }, {
|
|
35114
|
+
mode: 'highest',
|
|
35115
|
+
});
|
|
35116
|
+
}
|
|
35117
|
+
}
|
|
35118
|
+
/**
|
|
35119
|
+
* 设置 class highlight
|
|
35120
|
+
* 将 render-cell.tsx 拖动功能迁移至 div.column-resize
|
|
35121
|
+
*/
|
|
35122
|
+
function handleCellBorderHighlight(editor, e) {
|
|
35123
|
+
if (e.type === 'mouseenter') {
|
|
35124
|
+
Transforms.setNodes(editor, { isResizing: true }, { mode: 'highest' });
|
|
35125
|
+
}
|
|
35126
|
+
else {
|
|
35127
|
+
Transforms.setNodes(editor, { isResizing: false }, { mode: 'highest' });
|
|
35128
|
+
}
|
|
35129
|
+
}
|
|
35130
|
+
function handleCellBorderMouseDown(editor, elemNode) {
|
|
35131
|
+
if (isMouseDownForResize)
|
|
35132
|
+
return; // 此时正在修改列宽
|
|
35133
|
+
editorWhenMouseDown = editor;
|
|
36293
35134
|
}
|
|
36294
35135
|
|
|
36295
35136
|
/**
|
|
@@ -36313,8 +35154,8 @@ function getContentEditable(editor, tableElem) {
|
|
|
36313
35154
|
var tablePath = DomEditor.findPath(editor, tableElem);
|
|
36314
35155
|
var tableStart = Editor.start(editor, tablePath);
|
|
36315
35156
|
var tableEnd = Editor.end(editor, tablePath);
|
|
36316
|
-
var isAnchorInTable = Point.compare(anchor, tableEnd) <= 0 && Point.compare(anchor, tableStart) >= 0;
|
|
36317
|
-
var isFocusInTable = Point.compare(focus, tableEnd) <= 0 && Point.compare(focus, tableStart) >= 0;
|
|
35157
|
+
var isAnchorInTable = Point$1.compare(anchor, tableEnd) <= 0 && Point$1.compare(anchor, tableStart) >= 0;
|
|
35158
|
+
var isFocusInTable = Point$1.compare(focus, tableEnd) <= 0 && Point$1.compare(focus, tableStart) >= 0;
|
|
36318
35159
|
// 选区在 table 内部,且选中了同一个单元格。表格可以编辑
|
|
36319
35160
|
if (isAnchorInTable && isFocusInTable) {
|
|
36320
35161
|
if (Path.equals(anchor.path.slice(0, 3), focus.path.slice(0, 3))) {
|
|
@@ -36327,11 +35168,13 @@ function renderTable(elemNode, children, editor) {
|
|
|
36327
35168
|
// 是否可编辑
|
|
36328
35169
|
var editable = getContentEditable(editor, elemNode);
|
|
36329
35170
|
// 宽度
|
|
36330
|
-
var _a = elemNode.width,
|
|
36331
|
-
//
|
|
35171
|
+
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;
|
|
35172
|
+
// 光标是否选中
|
|
36332
35173
|
var selected = DomEditor.isNodeSelected(editor, elemNode);
|
|
36333
|
-
//
|
|
36334
|
-
var
|
|
35174
|
+
// 光标是否有选区
|
|
35175
|
+
var _e = __read$3(TableCursor.selection(editor), 1), isSelecting = _e[0];
|
|
35176
|
+
// 列宽之间比值
|
|
35177
|
+
var columnWidthRatios = getColumnWidthRatios(columnWidths);
|
|
36335
35178
|
var vnode = (jsx("div", { className: "table-container", "data-selected": selected, on: {
|
|
36336
35179
|
mousedown: function (e) {
|
|
36337
35180
|
// @ts-ignore 阻止光标定位到 table 后面
|
|
@@ -36339,6 +35182,10 @@ function renderTable(elemNode, children, editor) {
|
|
|
36339
35182
|
e.preventDefault();
|
|
36340
35183
|
if (editor.isDisabled())
|
|
36341
35184
|
return;
|
|
35185
|
+
// @ts-ignore 如果用户行为是获取焦点输入文本时,需释放选区
|
|
35186
|
+
if (e.target.closest('[data-block-type="table-cell"]')) {
|
|
35187
|
+
TableCursor.unselect(editor);
|
|
35188
|
+
}
|
|
36342
35189
|
// 是否需要定位到 table 内部
|
|
36343
35190
|
var tablePath = DomEditor.findPath(editor, elemNode);
|
|
36344
35191
|
var tableStart = Editor.start(editor, tablePath);
|
|
@@ -36353,13 +35200,64 @@ function renderTable(elemNode, children, editor) {
|
|
|
36353
35200
|
editor.select(tableStart); // 选中 table 内部
|
|
36354
35201
|
},
|
|
36355
35202
|
} },
|
|
36356
|
-
jsx("table", { width:
|
|
36357
|
-
|
|
36358
|
-
|
|
35203
|
+
jsx("table", { width: tableWidth, contentEditable: editable,
|
|
35204
|
+
/**
|
|
35205
|
+
* 1. 当表格处于选区状态,屏蔽 Chrome 自带的样式
|
|
35206
|
+
* 2. table 宽度为 auto 时,宽度为 列宽之和
|
|
35207
|
+
* 3. 鼠标移动到 单元格 边缘,设置 visible className
|
|
35208
|
+
*/
|
|
35209
|
+
className: 'table ' + (isSelecting ? 'table-selection-none' : ''), style: {
|
|
35210
|
+
width: tableWidth == '100%' ? '' : columnWidths.reduce(function (a, b) { return a + b; }, 0) + 'px',
|
|
35211
|
+
}, on: {
|
|
35212
|
+
mousemove: lodash_debounce(function (e) { return handleCellBorderVisible(editor, elemNode, e); }, 25),
|
|
35213
|
+
} },
|
|
35214
|
+
jsx("colgroup", { contentEditable: false },
|
|
35215
|
+
/**
|
|
35216
|
+
* 剔除 firstRowCells,因单元格合并 表头 th,会计算错误。
|
|
35217
|
+
* 使用 columnWidth 数组长度代表列数
|
|
35218
|
+
* 拖动行为及变量设置均参考 飞书
|
|
35219
|
+
*/
|
|
35220
|
+
columnWidths.map(function (width) {
|
|
36359
35221
|
return jsx("col", { width: width });
|
|
36360
35222
|
})),
|
|
36361
|
-
jsx("tbody", null, children))
|
|
36362
|
-
|
|
35223
|
+
jsx("tbody", null, children)),
|
|
35224
|
+
jsx("div", { className: "column-resizer", contenteditable: "false" }, columnWidths.map(function (width, index) {
|
|
35225
|
+
var minWidth = width;
|
|
35226
|
+
/**
|
|
35227
|
+
* table width 为 100% 模式时
|
|
35228
|
+
* columnWidths 表示的是比例
|
|
35229
|
+
* 1. 需要计算出真实的宽度
|
|
35230
|
+
*/
|
|
35231
|
+
if (tableWidth == '100%') {
|
|
35232
|
+
minWidth = columnWidthRatios[index] * scrollWidth;
|
|
35233
|
+
}
|
|
35234
|
+
return (jsx("div", { className: "column-resizer-item", style: { minWidth: minWidth + "px" } },
|
|
35235
|
+
jsx("div", { className: 'resizer-line-hotzone ' +
|
|
35236
|
+
(isHoverCellBorder && index == resizingIndex ? 'visible ' : '') +
|
|
35237
|
+
(isResizing && index == resizingIndex ? 'highlight' : ''), style: { height: height + 'px' }, on: {
|
|
35238
|
+
mouseenter: function (e) { return handleCellBorderHighlight(editor, e); },
|
|
35239
|
+
mouseleave: function (e) { return handleCellBorderHighlight(editor, e); },
|
|
35240
|
+
mousedown: function (e) { return handleCellBorderMouseDown(editor); },
|
|
35241
|
+
} },
|
|
35242
|
+
jsx("div", { className: "resizer-line" }))));
|
|
35243
|
+
}))));
|
|
35244
|
+
/**
|
|
35245
|
+
* 移出直接返回 vnode
|
|
35246
|
+
* 添加 ObserverResize 监听行为
|
|
35247
|
+
* 监听 table 内部变化,更新 table resize-bar 高度
|
|
35248
|
+
*/
|
|
35249
|
+
var containerVnode = h('div', {
|
|
35250
|
+
hook: {
|
|
35251
|
+
insert: function (_a) {
|
|
35252
|
+
var elm = _a.elm;
|
|
35253
|
+
return observerTableResize(editor, elm);
|
|
35254
|
+
},
|
|
35255
|
+
destroy: function () {
|
|
35256
|
+
unObserveTableResize();
|
|
35257
|
+
},
|
|
35258
|
+
},
|
|
35259
|
+
}, vnode);
|
|
35260
|
+
return containerVnode;
|
|
36363
35261
|
}
|
|
36364
35262
|
|
|
36365
35263
|
/**
|
|
@@ -36372,154 +35270,60 @@ function renderTableRow(elemNode, children, editor) {
|
|
|
36372
35270
|
}
|
|
36373
35271
|
|
|
36374
35272
|
/**
|
|
36375
|
-
* @description
|
|
35273
|
+
* @description table menu helpers
|
|
36376
35274
|
* @author wangfupeng
|
|
36377
35275
|
*/
|
|
36378
|
-
if (append)
|
|
36379
|
-
$.fn.append = append;
|
|
36380
|
-
if (on)
|
|
36381
|
-
$.fn.on = on;
|
|
36382
|
-
if (focus)
|
|
36383
|
-
$.fn.focus = focus;
|
|
36384
|
-
if (attr)
|
|
36385
|
-
$.fn.attr = attr;
|
|
36386
|
-
if (val)
|
|
36387
|
-
$.fn.val = val;
|
|
36388
|
-
if (html)
|
|
36389
|
-
$.fn.html = html;
|
|
36390
|
-
if (dataset)
|
|
36391
|
-
$.fn.dataset = dataset;
|
|
36392
|
-
if (addClass)
|
|
36393
|
-
$.fn.addClass = addClass;
|
|
36394
|
-
if (removeClass)
|
|
36395
|
-
$.fn.removeClass = removeClass;
|
|
36396
|
-
if (children)
|
|
36397
|
-
$.fn.children = children;
|
|
36398
|
-
if (each)
|
|
36399
|
-
$.fn.each = each;
|
|
36400
|
-
if (find)
|
|
36401
|
-
$.fn.find = find;
|
|
36402
35276
|
/**
|
|
36403
|
-
*
|
|
36404
|
-
* @param
|
|
35277
|
+
* 获取第一行所有 cells
|
|
35278
|
+
* @param tableNode table node
|
|
36405
35279
|
*/
|
|
36406
|
-
function
|
|
36407
|
-
|
|
36408
|
-
|
|
36409
|
-
|
|
35280
|
+
function getFirstRowCells(tableNode) {
|
|
35281
|
+
var rows = tableNode.children || []; // 所有行
|
|
35282
|
+
if (rows.length === 0)
|
|
35283
|
+
return [];
|
|
35284
|
+
var firstRow = rows[0] || {}; // 第一行
|
|
35285
|
+
var cells = firstRow.children || []; // 第一行所有 cell
|
|
35286
|
+
return cells;
|
|
36410
35287
|
}
|
|
36411
35288
|
/**
|
|
36412
|
-
*
|
|
36413
|
-
* @param
|
|
36414
|
-
* @param styleKey style key
|
|
35289
|
+
* 表格是否带有表头?
|
|
35290
|
+
* @param tableNode table node
|
|
36415
35291
|
*/
|
|
36416
|
-
function
|
|
36417
|
-
var
|
|
36418
|
-
|
|
36419
|
-
|
|
36420
|
-
|
|
36421
|
-
|
|
36422
|
-
|
|
36423
|
-
|
|
36424
|
-
|
|
36425
|
-
|
|
36426
|
-
|
|
36427
|
-
|
|
36428
|
-
|
|
36429
|
-
|
|
36430
|
-
|
|
35292
|
+
function isTableWithHeader(tableNode) {
|
|
35293
|
+
var firstRowCells = getFirstRowCells(tableNode);
|
|
35294
|
+
return firstRowCells.every(function (cell) { return !!cell.isHeader; });
|
|
35295
|
+
}
|
|
35296
|
+
/**
|
|
35297
|
+
* 单元格是否在第一行
|
|
35298
|
+
* @param editor editor
|
|
35299
|
+
* @param cellNode cell node
|
|
35300
|
+
*/
|
|
35301
|
+
function isCellInFirstRow(editor, cellNode) {
|
|
35302
|
+
var rowNode = DomEditor.getParentNode(editor, cellNode);
|
|
35303
|
+
if (rowNode == null)
|
|
35304
|
+
return false;
|
|
35305
|
+
var tableNode = DomEditor.getParentNode(editor, rowNode);
|
|
35306
|
+
if (tableNode == null)
|
|
35307
|
+
return false;
|
|
35308
|
+
var firstRowCells = getFirstRowCells(tableNode);
|
|
35309
|
+
return firstRowCells.some(function (c) { return c === cellNode; });
|
|
36431
35310
|
}
|
|
36432
35311
|
|
|
36433
35312
|
/**
|
|
36434
35313
|
* @description render cell
|
|
36435
35314
|
* @author wangfupeng
|
|
36436
35315
|
*/
|
|
36437
|
-
// 拖拽列宽相关信息
|
|
36438
|
-
var isMouseDownForResize = false;
|
|
36439
|
-
var clientXWhenMouseDown = 0;
|
|
36440
|
-
var cellWidthWhenMouseDown = 0;
|
|
36441
|
-
var cellPathWhenMouseDown = null;
|
|
36442
|
-
var editorWhenMouseDown = null;
|
|
36443
|
-
var $body = $('body');
|
|
36444
|
-
function onMouseDown(event) {
|
|
36445
|
-
var elem = event.target;
|
|
36446
|
-
if (elem.tagName !== 'TH' && elem.tagName !== 'TD')
|
|
36447
|
-
return;
|
|
36448
|
-
if (elem.style.cursor !== 'col-resize')
|
|
36449
|
-
return;
|
|
36450
|
-
elem.style.cursor = 'auto';
|
|
36451
|
-
event.preventDefault();
|
|
36452
|
-
// 记录必要信息
|
|
36453
|
-
isMouseDownForResize = true;
|
|
36454
|
-
var clientX = event.clientX;
|
|
36455
|
-
clientXWhenMouseDown = clientX;
|
|
36456
|
-
var width = elem.getBoundingClientRect().width;
|
|
36457
|
-
cellWidthWhenMouseDown = width;
|
|
36458
|
-
// 绑定事件
|
|
36459
|
-
$body.on('mousemove', onMouseMove);
|
|
36460
|
-
$body.on('mouseup', onMouseUp);
|
|
36461
|
-
}
|
|
36462
|
-
$body.on('mousedown', onMouseDown); // 绑定事件
|
|
36463
|
-
function onMouseUp(event) {
|
|
36464
|
-
isMouseDownForResize = false;
|
|
36465
|
-
editorWhenMouseDown = null;
|
|
36466
|
-
cellPathWhenMouseDown = null;
|
|
36467
|
-
// 解绑事件
|
|
36468
|
-
$body.off('mousemove', onMouseMove);
|
|
36469
|
-
$body.off('mouseup', onMouseUp);
|
|
36470
|
-
}
|
|
36471
|
-
var onMouseMove = lodash_throttle(function (event) {
|
|
36472
|
-
if (!isMouseDownForResize)
|
|
36473
|
-
return;
|
|
36474
|
-
if (editorWhenMouseDown == null || cellPathWhenMouseDown == null)
|
|
36475
|
-
return;
|
|
36476
|
-
event.preventDefault();
|
|
36477
|
-
var clientX = event.clientX;
|
|
36478
|
-
var newWith = cellWidthWhenMouseDown + (clientX - clientXWhenMouseDown); // 计算新宽度
|
|
36479
|
-
newWith = Math.floor(newWith * 100) / 100; // 保留小数点后两位
|
|
36480
|
-
if (newWith < 30)
|
|
36481
|
-
newWith = 30; // 最小宽度
|
|
36482
|
-
// 这是宽度
|
|
36483
|
-
Transforms.setNodes(editorWhenMouseDown, { width: newWith.toString() }, {
|
|
36484
|
-
at: cellPathWhenMouseDown,
|
|
36485
|
-
});
|
|
36486
|
-
}, 100);
|
|
36487
35316
|
function renderTableCell(cellNode, children, editor) {
|
|
36488
35317
|
var isFirstRow = isCellInFirstRow(editor, cellNode);
|
|
36489
|
-
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;
|
|
35318
|
+
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;
|
|
35319
|
+
var selected = TableCursor.isSelected(editor, cellNode);
|
|
36490
35320
|
// ------------------ 不是第一行,直接渲染 <td> ------------------
|
|
36491
35321
|
if (!isFirstRow) {
|
|
36492
|
-
return (jsx("td", { colSpan: colSpan, rowSpan: rowSpan }, children));
|
|
35322
|
+
return (jsx("td", { colSpan: colSpan, rowSpan: rowSpan, "data-block-type": "table-cell", className: selected ? 'w-e-selected' : '', style: { display: hidden ? 'none' : '' } }, children));
|
|
36493
35323
|
}
|
|
36494
35324
|
// ------------------ 是第一行:1. 判断 th ;2. 拖拽列宽 ------------------
|
|
36495
35325
|
var Tag = isHeader ? 'th' : 'td';
|
|
36496
|
-
var vnode = (jsx(Tag, { colSpan: colSpan, rowSpan: rowSpan, style: {
|
|
36497
|
-
mousemove: lodash_throttle(function (event) {
|
|
36498
|
-
var elem = this.elm;
|
|
36499
|
-
if (elem == null)
|
|
36500
|
-
return;
|
|
36501
|
-
var _a = elem.getBoundingClientRect(), left = _a.left, width = _a.width, top = _a.top, height = _a.height;
|
|
36502
|
-
var clientX = event.clientX, clientY = event.clientY;
|
|
36503
|
-
if (isMouseDownForResize)
|
|
36504
|
-
return; // 此时正在修改列宽
|
|
36505
|
-
// 非 mousedown 状态,计算 cursor 样式
|
|
36506
|
-
var matchX = clientX > left + width - 5 && clientX < left + width; // X 轴,是否接近 cell 右侧?
|
|
36507
|
-
var matchY = clientY > top && clientY < top + height; // Y 轴,是否在 cell 之内
|
|
36508
|
-
// X Y 轴都接近,则修改鼠标样式
|
|
36509
|
-
if (matchX && matchY) {
|
|
36510
|
-
elem.style.cursor = 'col-resize';
|
|
36511
|
-
editorWhenMouseDown = editor;
|
|
36512
|
-
cellPathWhenMouseDown = DomEditor.findPath(editor, cellNode);
|
|
36513
|
-
}
|
|
36514
|
-
else {
|
|
36515
|
-
if (!isMouseDownForResize) {
|
|
36516
|
-
elem.style.cursor = 'auto';
|
|
36517
|
-
editorWhenMouseDown = null;
|
|
36518
|
-
cellPathWhenMouseDown = null;
|
|
36519
|
-
}
|
|
36520
|
-
}
|
|
36521
|
-
}, 100),
|
|
36522
|
-
} }, children));
|
|
35326
|
+
var vnode = (jsx(Tag, { colSpan: colSpan, rowSpan: rowSpan, "data-block-type": "table-cell", className: selected ? 'w-e-selected' : '', style: { display: hidden ? 'none' : '' } }, children));
|
|
36523
35327
|
return vnode;
|
|
36524
35328
|
}
|
|
36525
35329
|
|
|
@@ -36546,15 +35350,16 @@ var renderTableCellConf = {
|
|
|
36546
35350
|
*/
|
|
36547
35351
|
function tableToHtml(elemNode, childrenHtml) {
|
|
36548
35352
|
var _a = elemNode.width, width = _a === void 0 ? 'auto' : _a;
|
|
36549
|
-
return "<table style=\"width: " + width + ";\"><tbody>" + childrenHtml + "</tbody></table>";
|
|
35353
|
+
return "<table style=\"width: " + width + ";table-layout: fixed;\"><tbody>" + childrenHtml + "</tbody></table>";
|
|
36550
35354
|
}
|
|
36551
35355
|
function tableRowToHtml(elem, childrenHtml) {
|
|
36552
35356
|
return "<tr>" + childrenHtml + "</tr>";
|
|
36553
35357
|
}
|
|
36554
35358
|
function tableCellToHtml(cellNode, childrenHtml) {
|
|
36555
|
-
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;
|
|
35359
|
+
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;
|
|
36556
35360
|
var tag = isHeader ? 'th' : 'td';
|
|
36557
|
-
|
|
35361
|
+
var style = hidden ? 'display:none' : '';
|
|
35362
|
+
return "<" + tag + " colSpan=\"" + colSpan + "\" rowSpan=\"" + rowSpan + "\" width=\"" + width + "\" style=\"" + style + "\">" + childrenHtml + "</" + tag + ">";
|
|
36558
35363
|
}
|
|
36559
35364
|
var tableToHtmlConf = {
|
|
36560
35365
|
type: 'table',
|
|
@@ -36686,7 +35491,11 @@ var DEL_COL_SVG = '<svg viewBox="0 0 1048 1024"><path d="M327.68 510.976L393.216
|
|
|
36686
35491
|
// 表头
|
|
36687
35492
|
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>';
|
|
36688
35493
|
// 宽度
|
|
36689
|
-
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>';
|
|
35494
|
+
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>';
|
|
35495
|
+
// 合并单元格
|
|
35496
|
+
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>';
|
|
35497
|
+
// 拆分单元格
|
|
35498
|
+
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>';
|
|
36690
35499
|
|
|
36691
35500
|
/**
|
|
36692
35501
|
* @description insert table menu
|
|
@@ -36695,6 +35504,7 @@ var FULL_WIDTH_SVG = '<svg viewBox="0 0 1228 1024"><path d="M862.514337 563.2004
|
|
|
36695
35504
|
function genTableNode(rowNum, colNum) {
|
|
36696
35505
|
// 拼接 rows
|
|
36697
35506
|
var rows = [];
|
|
35507
|
+
var columnWidths = Array(colNum).fill(60);
|
|
36698
35508
|
for (var i = 0; i < rowNum; i++) {
|
|
36699
35509
|
// 拼接 cells
|
|
36700
35510
|
var cells = [];
|
|
@@ -36718,6 +35528,7 @@ function genTableNode(rowNum, colNum) {
|
|
|
36718
35528
|
type: 'table',
|
|
36719
35529
|
width: 'auto',
|
|
36720
35530
|
children: rows,
|
|
35531
|
+
columnWidths: columnWidths,
|
|
36721
35532
|
};
|
|
36722
35533
|
}
|
|
36723
35534
|
var InsertTable = /** @class */ (function () {
|
|
@@ -36927,19 +35738,56 @@ var InsertRow = /** @class */ (function () {
|
|
|
36927
35738
|
var cellsLength = (rowNode === null || rowNode === void 0 ? void 0 : rowNode.children.length) || 0;
|
|
36928
35739
|
if (cellsLength === 0)
|
|
36929
35740
|
return;
|
|
36930
|
-
|
|
36931
|
-
|
|
36932
|
-
|
|
36933
|
-
|
|
36934
|
-
|
|
36935
|
-
|
|
36936
|
-
|
|
36937
|
-
|
|
35741
|
+
var matrix = filledMatrix(editor);
|
|
35742
|
+
// 向下插入行为,先找到
|
|
35743
|
+
// 当前选区所在的 tr 索引
|
|
35744
|
+
var trIndex = 0;
|
|
35745
|
+
outer: for (var x = 0; x < matrix.length; x++) {
|
|
35746
|
+
for (var y = 0; y < matrix[x].length; y++) {
|
|
35747
|
+
var _c = __read$3(matrix[x][y], 1), _d = __read$3(_c[0], 2), path = _d[1];
|
|
35748
|
+
if (!Path.equals(cellPath, path)) {
|
|
35749
|
+
continue;
|
|
35750
|
+
}
|
|
35751
|
+
trIndex = x;
|
|
35752
|
+
break outer;
|
|
35753
|
+
}
|
|
36938
35754
|
}
|
|
36939
|
-
|
|
36940
|
-
|
|
36941
|
-
|
|
36942
|
-
|
|
35755
|
+
Editor.withoutNormalizing(editor, function () {
|
|
35756
|
+
// 向下添加 tr 索引
|
|
35757
|
+
var destIndex = trIndex + 1;
|
|
35758
|
+
var isWithinBounds = destIndex >= 0 && destIndex < matrix.length;
|
|
35759
|
+
var exitMerge = [];
|
|
35760
|
+
for (var y = 0; isWithinBounds && y < matrix[trIndex].length; y++) {
|
|
35761
|
+
var _a = __read$3(matrix[trIndex][y], 2), _b = _a[1], ttb = _b.ttb, btt = _b.btt;
|
|
35762
|
+
// 向上找到 1 元素为止
|
|
35763
|
+
if (ttb > 1 || btt > 1) {
|
|
35764
|
+
if (btt == 1)
|
|
35765
|
+
continue;
|
|
35766
|
+
var _c = __read$3(matrix[trIndex - (ttb - 1)][y], 1), _d = __read$3(_c[0], 2), element = _d[0], path = _d[1];
|
|
35767
|
+
var rowSpan = element.rowSpan || 1;
|
|
35768
|
+
exitMerge.push(y);
|
|
35769
|
+
if (!element.hidden) {
|
|
35770
|
+
Transforms.setNodes(editor, {
|
|
35771
|
+
rowSpan: rowSpan + 1,
|
|
35772
|
+
}, { at: path });
|
|
35773
|
+
}
|
|
35774
|
+
}
|
|
35775
|
+
}
|
|
35776
|
+
// 拼接新的 row
|
|
35777
|
+
var newRow = { type: 'table-row', children: [] };
|
|
35778
|
+
for (var i = 0; i < cellsLength; i++) {
|
|
35779
|
+
var cell = {
|
|
35780
|
+
type: 'table-cell',
|
|
35781
|
+
hidden: exitMerge.includes(i),
|
|
35782
|
+
children: [{ text: '' }],
|
|
35783
|
+
};
|
|
35784
|
+
newRow.children.push(cell);
|
|
35785
|
+
}
|
|
35786
|
+
// 插入 row
|
|
35787
|
+
var rowPath = Path.parent(cellPath); // 获取 tr 的 path
|
|
35788
|
+
var newRowPath = Path.next(rowPath);
|
|
35789
|
+
Transforms.insertNodes(editor, newRow, { at: newRowPath });
|
|
35790
|
+
});
|
|
36943
35791
|
};
|
|
36944
35792
|
return InsertRow;
|
|
36945
35793
|
}());
|
|
@@ -36991,7 +35839,67 @@ var DeleteRow = /** @class */ (function () {
|
|
|
36991
35839
|
return;
|
|
36992
35840
|
}
|
|
36993
35841
|
// row > 1 行,则删掉这一行
|
|
36994
|
-
|
|
35842
|
+
var _c = __read$3(Editor.nodes(editor, {
|
|
35843
|
+
match: function (n) { return DomEditor.checkNodeType(n, 'table-cell'); },
|
|
35844
|
+
universal: true,
|
|
35845
|
+
}), 1), cellEntry = _c[0];
|
|
35846
|
+
var _d = __read$3(cellEntry, 2), cellPath = _d[1];
|
|
35847
|
+
var matrix = filledMatrix(editor);
|
|
35848
|
+
var trIndex = 0;
|
|
35849
|
+
outer: for (var x = 0; x < matrix.length; x++) {
|
|
35850
|
+
for (var y = 0; y < matrix[x].length; y++) {
|
|
35851
|
+
var _e = __read$3(matrix[x][y], 1), _f = __read$3(_e[0], 2), path = _f[1];
|
|
35852
|
+
if (!Path.equals(cellPath, path)) {
|
|
35853
|
+
continue;
|
|
35854
|
+
}
|
|
35855
|
+
trIndex = x;
|
|
35856
|
+
break outer;
|
|
35857
|
+
}
|
|
35858
|
+
}
|
|
35859
|
+
Editor.withoutNormalizing(editor, function () {
|
|
35860
|
+
var e_1, _a;
|
|
35861
|
+
for (var y = 0; y < matrix[trIndex].length; y++) {
|
|
35862
|
+
var _b = __read$3(matrix[trIndex][y], 2), _c = __read$3(_b[0], 1), hidden = _c[0].hidden, _d = _b[1], ttb = _d.ttb, btt = _d.btt;
|
|
35863
|
+
// 寻找跨行行为
|
|
35864
|
+
if (ttb > 1 || btt > 1) {
|
|
35865
|
+
// 找到显示中 rowSpan 节点
|
|
35866
|
+
var _e = __read$3(matrix[trIndex - (ttb - 1)][y], 1), _f = __read$3(_e[0], 2), _g = _f[0], _h = _g.rowSpan, rowSpan = _h === void 0 ? 1 : _h, _j = _g.colSpan, colSpan = _j === void 0 ? 1 : _j, path = _f[1];
|
|
35867
|
+
// 如果当前选中节点为隐藏节点,则向上寻找处理 rowSpan 逻辑
|
|
35868
|
+
if (hidden) {
|
|
35869
|
+
Transforms.setNodes(editor, {
|
|
35870
|
+
rowSpan: Math.max(rowSpan - 1, 1),
|
|
35871
|
+
colSpan: colSpan,
|
|
35872
|
+
}, { at: path });
|
|
35873
|
+
}
|
|
35874
|
+
else {
|
|
35875
|
+
var _k = __read$3(matrix[trIndex + 1][y], 1), _l = __read$3(_k[0], 2), belowPath = _l[1];
|
|
35876
|
+
Transforms.setNodes(editor, {
|
|
35877
|
+
rowSpan: rowSpan - 1,
|
|
35878
|
+
colSpan: colSpan,
|
|
35879
|
+
hidden: false,
|
|
35880
|
+
}, { at: belowPath });
|
|
35881
|
+
try {
|
|
35882
|
+
// 移动单元格 文本、图片等元素
|
|
35883
|
+
for (var _m = (e_1 = void 0, __values$3(Node$1.children(editor, path, { reverse: true }))), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
35884
|
+
var _p = __read$3(_o.value, 2), childPath = _p[1];
|
|
35885
|
+
Transforms.moveNodes(editor, {
|
|
35886
|
+
to: __spreadArray(__spreadArray([], __read$3(belowPath)), [0]),
|
|
35887
|
+
at: childPath,
|
|
35888
|
+
});
|
|
35889
|
+
}
|
|
35890
|
+
}
|
|
35891
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
35892
|
+
finally {
|
|
35893
|
+
try {
|
|
35894
|
+
if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
|
|
35895
|
+
}
|
|
35896
|
+
finally { if (e_1) throw e_1.error; }
|
|
35897
|
+
}
|
|
35898
|
+
}
|
|
35899
|
+
}
|
|
35900
|
+
}
|
|
35901
|
+
Transforms.removeNodes(editor, { at: rowPath });
|
|
35902
|
+
});
|
|
36995
35903
|
};
|
|
36996
35904
|
return DeleteRow;
|
|
36997
35905
|
}());
|
|
@@ -37041,27 +35949,62 @@ var InsertCol = /** @class */ (function () {
|
|
|
37041
35949
|
var tableNode = DomEditor.getParentNode(editor, rowNode);
|
|
37042
35950
|
if (tableNode == null)
|
|
37043
35951
|
return;
|
|
37044
|
-
|
|
37045
|
-
var
|
|
37046
|
-
|
|
37047
|
-
|
|
37048
|
-
|
|
37049
|
-
|
|
37050
|
-
|
|
37051
|
-
|
|
37052
|
-
|
|
37053
|
-
|
|
37054
|
-
|
|
37055
|
-
|
|
37056
|
-
|
|
37057
|
-
|
|
37058
|
-
|
|
37059
|
-
|
|
37060
|
-
|
|
35952
|
+
var matrix = filledMatrix(editor);
|
|
35953
|
+
var tdIndex = 0;
|
|
35954
|
+
out: for (var x = 0; x < matrix.length; x++) {
|
|
35955
|
+
for (var y = 0; y < matrix[x].length; y++) {
|
|
35956
|
+
var _c = __read$3(matrix[x][y], 1), _d = __read$3(_c[0], 2), path = _d[1];
|
|
35957
|
+
if (Path.equals(selectedCellPath, path)) {
|
|
35958
|
+
tdIndex = y;
|
|
35959
|
+
break out;
|
|
35960
|
+
}
|
|
35961
|
+
}
|
|
35962
|
+
}
|
|
35963
|
+
Editor.withoutNormalizing(editor, function () {
|
|
35964
|
+
var exitMerge = [];
|
|
35965
|
+
for (var x = 0; x < matrix.length; x++) {
|
|
35966
|
+
var _a = __read$3(matrix[x][tdIndex], 2), _b = _a[1], ltr = _b.ltr, rtl = _b.rtl;
|
|
35967
|
+
// 向左找到 1 元素为止
|
|
35968
|
+
if (ltr > 1 || rtl > 1) {
|
|
35969
|
+
if (rtl == 1)
|
|
35970
|
+
continue;
|
|
35971
|
+
var _c = __read$3(matrix[x][tdIndex - (rtl - 1)], 1), _d = __read$3(_c[0], 2), element = _d[0], path = _d[1];
|
|
35972
|
+
var colSpan = element.colSpan || 1;
|
|
35973
|
+
exitMerge.push(x);
|
|
35974
|
+
if (!element.hidden) {
|
|
35975
|
+
Transforms.setNodes(editor, {
|
|
35976
|
+
colSpan: colSpan + 1,
|
|
35977
|
+
}, { at: path });
|
|
37061
35978
|
}
|
|
37062
|
-
Transforms.insertNodes(editor, newCell, { at: path });
|
|
37063
35979
|
}
|
|
37064
|
-
}
|
|
35980
|
+
}
|
|
35981
|
+
// 遍历所有 rows ,挨个添加 cell
|
|
35982
|
+
for (var x = 0; x < matrix.length; x++) {
|
|
35983
|
+
var newCell = {
|
|
35984
|
+
type: 'table-cell',
|
|
35985
|
+
hidden: exitMerge.includes(x),
|
|
35986
|
+
children: [{ text: '' }],
|
|
35987
|
+
};
|
|
35988
|
+
if (x === 0 && isTableWithHeader(tableNode)) {
|
|
35989
|
+
newCell.isHeader = true;
|
|
35990
|
+
}
|
|
35991
|
+
var _e = __read$3(matrix[x][tdIndex], 1), _f = __read$3(_e[0], 2), insertPath = _f[1];
|
|
35992
|
+
Transforms.insertNodes(editor, newCell, { at: insertPath });
|
|
35993
|
+
}
|
|
35994
|
+
// 需要调整 columnWidths
|
|
35995
|
+
var _g = __read$3(Editor.nodes(editor, {
|
|
35996
|
+
match: function (n) { return DomEditor.checkNodeType(n, 'table'); },
|
|
35997
|
+
universal: true,
|
|
35998
|
+
}), 1), tableEntry = _g[0];
|
|
35999
|
+
if (tableEntry) {
|
|
36000
|
+
var _h = __read$3(tableEntry, 2), elemNode = _h[0], tablePath = _h[1];
|
|
36001
|
+
var _j = elemNode.columnWidths, columnWidths = _j === void 0 ? [] : _j;
|
|
36002
|
+
var adjustColumnWidths = __spreadArray([], __read$3(columnWidths));
|
|
36003
|
+
adjustColumnWidths.splice(tdIndex, 0, 60);
|
|
36004
|
+
Transforms.setNodes(editor, { columnWidths: adjustColumnWidths }, {
|
|
36005
|
+
at: tablePath,
|
|
36006
|
+
});
|
|
36007
|
+
}
|
|
37065
36008
|
});
|
|
37066
36009
|
};
|
|
37067
36010
|
return InsertCol;
|
|
@@ -37117,23 +36060,76 @@ var DeleteCol = /** @class */ (function () {
|
|
|
37117
36060
|
var tableNode = DomEditor.getParentNode(editor, rowNode);
|
|
37118
36061
|
if (tableNode == null)
|
|
37119
36062
|
return;
|
|
37120
|
-
|
|
37121
|
-
var
|
|
37122
|
-
|
|
37123
|
-
|
|
37124
|
-
|
|
37125
|
-
|
|
37126
|
-
|
|
37127
|
-
|
|
37128
|
-
var path = DomEditor.findPath(editor, cell);
|
|
37129
|
-
if (path.length === selectedCellPath.length &&
|
|
37130
|
-
lodash_isequal(path.slice(-1), selectedCellPath.slice(-1)) // 俩数组,最后一位相同
|
|
37131
|
-
) {
|
|
37132
|
-
// 如果当前 td 的 path 和选中 td 的 path ,最后一位相同,说明是同一列
|
|
37133
|
-
// 删除当前的 cell
|
|
37134
|
-
Transforms.removeNodes(editor, { at: path });
|
|
36063
|
+
var matrix = filledMatrix(editor);
|
|
36064
|
+
var tdIndex = 0;
|
|
36065
|
+
out: for (var x = 0; x < matrix.length; x++) {
|
|
36066
|
+
for (var y = 0; y < matrix[x].length; y++) {
|
|
36067
|
+
var _c = __read$3(matrix[x][y], 1), _d = __read$3(_c[0], 2), path = _d[1];
|
|
36068
|
+
if (Path.equals(selectedCellPath, path)) {
|
|
36069
|
+
tdIndex = y;
|
|
36070
|
+
break out;
|
|
37135
36071
|
}
|
|
37136
|
-
}
|
|
36072
|
+
}
|
|
36073
|
+
}
|
|
36074
|
+
Editor.withoutNormalizing(editor, function () {
|
|
36075
|
+
var e_1, _a;
|
|
36076
|
+
for (var x = 0; x < matrix.length; x++) {
|
|
36077
|
+
var _b = __read$3(matrix[x][tdIndex], 2), _c = __read$3(_b[0], 1), hidden = _c[0].hidden, _d = _b[1], rtl = _d.rtl, ltr = _d.ltr;
|
|
36078
|
+
if (rtl > 1 || ltr > 1) {
|
|
36079
|
+
// 找到显示中 colSpan 节点
|
|
36080
|
+
var _e = __read$3(matrix[x][tdIndex - (rtl - 1)], 1), _f = __read$3(_e[0], 2), _g = _f[0], _h = _g.rowSpan, rowSpan = _h === void 0 ? 1 : _h, _j = _g.colSpan, colSpan = _j === void 0 ? 1 : _j, path = _f[1];
|
|
36081
|
+
if (hidden) {
|
|
36082
|
+
Transforms.setNodes(editor, {
|
|
36083
|
+
rowSpan: rowSpan,
|
|
36084
|
+
colSpan: Math.max(colSpan - 1, 1),
|
|
36085
|
+
}, { at: path });
|
|
36086
|
+
}
|
|
36087
|
+
else {
|
|
36088
|
+
var _k = __read$3(matrix[x][tdIndex + 1], 1), _l = __read$3(_k[0], 2), rightPath = _l[1];
|
|
36089
|
+
Transforms.setNodes(editor, {
|
|
36090
|
+
rowSpan: rowSpan,
|
|
36091
|
+
colSpan: colSpan - 1,
|
|
36092
|
+
hidden: false,
|
|
36093
|
+
}, { at: rightPath });
|
|
36094
|
+
try {
|
|
36095
|
+
// 移动单元格 文本、图片等元素
|
|
36096
|
+
for (var _m = (e_1 = void 0, __values$3(Node$1.children(editor, path, { reverse: true }))), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
36097
|
+
var _p = __read$3(_o.value, 2), childPath = _p[1];
|
|
36098
|
+
Transforms.moveNodes(editor, {
|
|
36099
|
+
to: __spreadArray(__spreadArray([], __read$3(rightPath)), [0]),
|
|
36100
|
+
at: childPath,
|
|
36101
|
+
});
|
|
36102
|
+
}
|
|
36103
|
+
}
|
|
36104
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36105
|
+
finally {
|
|
36106
|
+
try {
|
|
36107
|
+
if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
|
|
36108
|
+
}
|
|
36109
|
+
finally { if (e_1) throw e_1.error; }
|
|
36110
|
+
}
|
|
36111
|
+
}
|
|
36112
|
+
}
|
|
36113
|
+
}
|
|
36114
|
+
// 挨个删除 cell
|
|
36115
|
+
for (var x = 0; x < matrix.length; x++) {
|
|
36116
|
+
var _q = __read$3(matrix[x][tdIndex], 1), _r = __read$3(_q[0], 2), path = _r[1];
|
|
36117
|
+
Transforms.removeNodes(editor, { at: path });
|
|
36118
|
+
}
|
|
36119
|
+
// 需要调整 columnWidths
|
|
36120
|
+
var _s = __read$3(Editor.nodes(editor, {
|
|
36121
|
+
match: function (n) { return DomEditor.checkNodeType(n, 'table'); },
|
|
36122
|
+
universal: true,
|
|
36123
|
+
}), 1), tableEntry = _s[0];
|
|
36124
|
+
if (tableEntry) {
|
|
36125
|
+
var _t = __read$3(tableEntry, 2), elemNode = _t[0], tablePath = _t[1];
|
|
36126
|
+
var _u = elemNode.columnWidths, columnWidths = _u === void 0 ? [] : _u;
|
|
36127
|
+
var adjustColumnWidths = __spreadArray([], __read$3(columnWidths));
|
|
36128
|
+
adjustColumnWidths.splice(tdIndex, 1);
|
|
36129
|
+
Transforms.setNodes(editor, { columnWidths: adjustColumnWidths }, {
|
|
36130
|
+
at: tablePath,
|
|
36131
|
+
});
|
|
36132
|
+
}
|
|
37137
36133
|
});
|
|
37138
36134
|
};
|
|
37139
36135
|
return DeleteCol;
|
|
@@ -37236,6 +36232,234 @@ var TableFullWidth = /** @class */ (function () {
|
|
|
37236
36232
|
return TableFullWidth;
|
|
37237
36233
|
}());
|
|
37238
36234
|
|
|
36235
|
+
var MergeCell = /** @class */ (function () {
|
|
36236
|
+
function MergeCell() {
|
|
36237
|
+
this.title = t('tableModule.mergeCell');
|
|
36238
|
+
this.iconSvg = MERGE_CELL_SVG;
|
|
36239
|
+
this.tag = 'button';
|
|
36240
|
+
}
|
|
36241
|
+
MergeCell.prototype.getValue = function (editor) {
|
|
36242
|
+
// 无需获取 val
|
|
36243
|
+
return '';
|
|
36244
|
+
};
|
|
36245
|
+
MergeCell.prototype.isActive = function (editor) {
|
|
36246
|
+
// 无需 active
|
|
36247
|
+
return false;
|
|
36248
|
+
};
|
|
36249
|
+
MergeCell.prototype.isDisabled = function (editor) {
|
|
36250
|
+
return !this.canMerge(editor);
|
|
36251
|
+
};
|
|
36252
|
+
MergeCell.prototype.exec = function (editor, value) {
|
|
36253
|
+
if (this.isDisabled(editor))
|
|
36254
|
+
return;
|
|
36255
|
+
this.merge(editor);
|
|
36256
|
+
// 释放选区
|
|
36257
|
+
TableCursor.unselect(editor);
|
|
36258
|
+
};
|
|
36259
|
+
/**
|
|
36260
|
+
* Checks if the current selection can be merged. Merging is not possible when any of the following conditions are met:
|
|
36261
|
+
* - The selection is empty.
|
|
36262
|
+
* - The selection is not within the same "thead", "tbody," or "tfoot" section.
|
|
36263
|
+
* @returns {boolean} `true` if the selection can be merged, otherwise `false`.
|
|
36264
|
+
*/
|
|
36265
|
+
MergeCell.prototype.canMerge = function (editor) {
|
|
36266
|
+
var matrix = EDITOR_TO_SELECTION.get(editor);
|
|
36267
|
+
// cannot merge when selection is empty
|
|
36268
|
+
if (!matrix || !matrix.length) {
|
|
36269
|
+
return false;
|
|
36270
|
+
}
|
|
36271
|
+
// prettier-ignore
|
|
36272
|
+
var _a = __read$3(matrix[matrix.length - 1][matrix[matrix.length - 1].length - 1], 1), _b = __read$3(_a[0], 2), lastPath = _b[1];
|
|
36273
|
+
var _c = __read$3(matrix[0][0], 1), _d = __read$3(_c[0], 2), firstPath = _d[1];
|
|
36274
|
+
// cannot merge when selection is not in common section
|
|
36275
|
+
if (!hasCommon(editor, [firstPath, lastPath], 'table')) {
|
|
36276
|
+
return false;
|
|
36277
|
+
}
|
|
36278
|
+
return true;
|
|
36279
|
+
};
|
|
36280
|
+
/**
|
|
36281
|
+
* Merges the selected cells in the table.
|
|
36282
|
+
* @returns void
|
|
36283
|
+
*/
|
|
36284
|
+
MergeCell.prototype.merge = function (editor) {
|
|
36285
|
+
if (!this.canMerge(editor)) {
|
|
36286
|
+
return;
|
|
36287
|
+
}
|
|
36288
|
+
var selection = EDITOR_TO_SELECTION.get(editor);
|
|
36289
|
+
if (!selection || !selection.length) {
|
|
36290
|
+
return;
|
|
36291
|
+
}
|
|
36292
|
+
var _a = __read$3(selection[0][0], 1), _b = __read$3(_a[0], 2), basePath = _b[1];
|
|
36293
|
+
var _c = __read$3(Node$1.children(editor, basePath, { reverse: true }), 1), _d = __read$3(_c[0], 2), lastPath = _d[1];
|
|
36294
|
+
filledMatrix(editor, { at: basePath });
|
|
36295
|
+
Editor.withoutNormalizing(editor, function () {
|
|
36296
|
+
var e_1, _a;
|
|
36297
|
+
var rowSpan = 0;
|
|
36298
|
+
var colSpan = 0;
|
|
36299
|
+
for (var x = selection.length - 1; x >= 0; x--, rowSpan++) {
|
|
36300
|
+
colSpan = 0;
|
|
36301
|
+
for (var y = selection[x].length - 1; y >= 0; y--, colSpan++) {
|
|
36302
|
+
var _b = __read$3(selection[x][y], 2), _c = __read$3(_b[0], 2), path = _c[1], ttb = _b[1].ttb;
|
|
36303
|
+
// skip first cell and "fake" cells which belong to a cell with a `rowspan`
|
|
36304
|
+
if (Path.equals(basePath, path) || ttb > 1) {
|
|
36305
|
+
continue;
|
|
36306
|
+
}
|
|
36307
|
+
try {
|
|
36308
|
+
// prettier-ignore
|
|
36309
|
+
for (var _d = (e_1 = void 0, __values$3(Node$1.children(editor, path, { reverse: true }))), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
36310
|
+
var _f = __read$3(_e.value, 2), childPath = _f[1];
|
|
36311
|
+
Transforms.moveNodes(editor, {
|
|
36312
|
+
to: Path.next(lastPath),
|
|
36313
|
+
at: childPath,
|
|
36314
|
+
});
|
|
36315
|
+
}
|
|
36316
|
+
}
|
|
36317
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36318
|
+
finally {
|
|
36319
|
+
try {
|
|
36320
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
36321
|
+
}
|
|
36322
|
+
finally { if (e_1) throw e_1.error; }
|
|
36323
|
+
}
|
|
36324
|
+
var _g = __read$3(Editor.nodes(editor, {
|
|
36325
|
+
match: isOfType(editor, 'tr'),
|
|
36326
|
+
at: path,
|
|
36327
|
+
}), 1), _h = __read$3(_g[0], 2), trPath = _h[1];
|
|
36328
|
+
var _j = __read$3(Node$1.children(editor, trPath), 2), sibling = _j[1];
|
|
36329
|
+
if (sibling) {
|
|
36330
|
+
/**
|
|
36331
|
+
* 删除节点调整成隐藏节点
|
|
36332
|
+
* 隐藏节点不会影响 table 布局
|
|
36333
|
+
*/
|
|
36334
|
+
Transforms.setNodes(editor, { hidden: true }, { at: path });
|
|
36335
|
+
continue;
|
|
36336
|
+
}
|
|
36337
|
+
}
|
|
36338
|
+
}
|
|
36339
|
+
Transforms.setNodes(editor, { rowSpan: rowSpan, colSpan: colSpan }, { at: basePath });
|
|
36340
|
+
});
|
|
36341
|
+
};
|
|
36342
|
+
return MergeCell;
|
|
36343
|
+
}());
|
|
36344
|
+
|
|
36345
|
+
// import { DEFAULT_WITH_TABLE_OPTIONS } from "../../utils/options";
|
|
36346
|
+
var SplitCell = /** @class */ (function () {
|
|
36347
|
+
function SplitCell() {
|
|
36348
|
+
this.title = t('tableModule.splitCell');
|
|
36349
|
+
this.iconSvg = SPLIT_CELL_SVG;
|
|
36350
|
+
this.tag = 'button';
|
|
36351
|
+
}
|
|
36352
|
+
SplitCell.prototype.getValue = function (editor) {
|
|
36353
|
+
// 无需获取 val
|
|
36354
|
+
return '';
|
|
36355
|
+
};
|
|
36356
|
+
SplitCell.prototype.isActive = function (editor) {
|
|
36357
|
+
// 无需 active
|
|
36358
|
+
return false;
|
|
36359
|
+
};
|
|
36360
|
+
SplitCell.prototype.isDisabled = function (editor) {
|
|
36361
|
+
var _a = __read$3(Editor.nodes(editor, {
|
|
36362
|
+
match: isOfType(editor, 'td'),
|
|
36363
|
+
}), 1), td = _a[0];
|
|
36364
|
+
var _b = __read$3(td, 1), _c = _b[0], _d = _c.rowSpan, rowSpan = _d === void 0 ? 1 : _d, _e = _c.colSpan, colSpan = _e === void 0 ? 1 : _e;
|
|
36365
|
+
if (rowSpan > 1 || colSpan > 1) {
|
|
36366
|
+
return false;
|
|
36367
|
+
}
|
|
36368
|
+
return true;
|
|
36369
|
+
};
|
|
36370
|
+
SplitCell.prototype.exec = function (editor, value) {
|
|
36371
|
+
if (this.isDisabled(editor))
|
|
36372
|
+
return;
|
|
36373
|
+
this.split(editor);
|
|
36374
|
+
};
|
|
36375
|
+
/**
|
|
36376
|
+
* Splits either the cell at the current selection or a specified location. If a range
|
|
36377
|
+
* selection is present, all cells within the range will be split.
|
|
36378
|
+
* @param {Location} [options.at] - Splits the cell at the specified location. If no
|
|
36379
|
+
* location is specified it will split the cell at the current selection
|
|
36380
|
+
* @param {boolean} [options.all] - If true, splits all cells in the table
|
|
36381
|
+
* @returns void
|
|
36382
|
+
*/
|
|
36383
|
+
SplitCell.prototype.split = function (editor, options) {
|
|
36384
|
+
if (options === void 0) { options = {}; }
|
|
36385
|
+
var _a = __read$3(Editor.nodes(editor, {
|
|
36386
|
+
match: isOfType(editor, 'table', 'th', 'td'),
|
|
36387
|
+
// @ts-ignore
|
|
36388
|
+
at: options.at,
|
|
36389
|
+
}), 2), table = _a[0], td = _a[1];
|
|
36390
|
+
if (!table || !td) {
|
|
36391
|
+
return;
|
|
36392
|
+
}
|
|
36393
|
+
var selection = EDITOR_TO_SELECTION.get(editor) || [];
|
|
36394
|
+
// @ts-ignore
|
|
36395
|
+
var matrix = filledMatrix(editor, { at: options.at });
|
|
36396
|
+
// const { blocks } = DEFAULT_WITH_TABLE_OPTIONS;
|
|
36397
|
+
Editor.withoutNormalizing(editor, function () {
|
|
36398
|
+
for (var x = matrix.length - 1; x >= 0; x--) {
|
|
36399
|
+
for (var y = matrix[x].length - 1; y >= 0; y--) {
|
|
36400
|
+
var _a = __read$3(matrix[x][y], 2), _b = __read$3(_a[0], 2), path = _b[1], context = _a[1];
|
|
36401
|
+
var colSpan = context.ltr, rtl = context.rtl, rowSpan = context.btt, ttb = context.ttb;
|
|
36402
|
+
if (rtl > 1) {
|
|
36403
|
+
// get to the start of the colspan
|
|
36404
|
+
y -= rtl - 2;
|
|
36405
|
+
continue;
|
|
36406
|
+
}
|
|
36407
|
+
if (ttb > 1) {
|
|
36408
|
+
continue;
|
|
36409
|
+
}
|
|
36410
|
+
if (rowSpan === 1 && colSpan === 1) {
|
|
36411
|
+
continue;
|
|
36412
|
+
}
|
|
36413
|
+
var found = !!options.all;
|
|
36414
|
+
if (selection.length) {
|
|
36415
|
+
outer: for (var i = 0; !options.all && i < selection.length; i++) {
|
|
36416
|
+
for (var j = 0; j < selection[i].length; j++) {
|
|
36417
|
+
var _c = __read$3(selection[i][j], 1), _d = __read$3(_c[0], 2), tdPath = _d[1];
|
|
36418
|
+
if (Path.equals(tdPath, path)) {
|
|
36419
|
+
found = true;
|
|
36420
|
+
break outer;
|
|
36421
|
+
}
|
|
36422
|
+
}
|
|
36423
|
+
}
|
|
36424
|
+
}
|
|
36425
|
+
else {
|
|
36426
|
+
var _e = __read$3(td, 2), tdPath = _e[1];
|
|
36427
|
+
if (Path.equals(tdPath, path)) {
|
|
36428
|
+
found = true;
|
|
36429
|
+
}
|
|
36430
|
+
}
|
|
36431
|
+
if (!found) {
|
|
36432
|
+
continue;
|
|
36433
|
+
}
|
|
36434
|
+
var _f = __read$3(Editor.nodes(editor, {
|
|
36435
|
+
match: isOfType(editor, 'table'),
|
|
36436
|
+
at: path,
|
|
36437
|
+
}), 1), _g = __read$3(_f[0], 1); _g[0];
|
|
36438
|
+
out: for (var r = 1; r < rowSpan; r++) {
|
|
36439
|
+
for (var i = y; i >= 0; i--) {
|
|
36440
|
+
var _h = __read$3(matrix[x + r][i], 2), _j = __read$3(_h[0], 2); _j[1]; var ttb_1 = _h[1].ttb;
|
|
36441
|
+
if (ttb_1 == 1) {
|
|
36442
|
+
continue;
|
|
36443
|
+
}
|
|
36444
|
+
for (var c = 0; c < colSpan; c++) {
|
|
36445
|
+
var _k = __read$3(matrix[x + r][i + c], 1), _l = __read$3(_k[0], 2), nextPath = _l[1];
|
|
36446
|
+
Transforms.unsetNodes(editor, ['hidden', 'colSpan', 'rowSpan'], { at: nextPath });
|
|
36447
|
+
}
|
|
36448
|
+
continue out;
|
|
36449
|
+
}
|
|
36450
|
+
}
|
|
36451
|
+
for (var c = 1; c < colSpan; c++) {
|
|
36452
|
+
var _m = __read$3(matrix[x][y + c], 1), _o = __read$3(_m[0], 2), nextPath = _o[1];
|
|
36453
|
+
Transforms.unsetNodes(editor, ['hidden', 'colSpan', 'rowSpan'], { at: nextPath });
|
|
36454
|
+
}
|
|
36455
|
+
Transforms.setNodes(editor, { rowSpan: 1, colSpan: 1 }, { at: path });
|
|
36456
|
+
}
|
|
36457
|
+
}
|
|
36458
|
+
});
|
|
36459
|
+
};
|
|
36460
|
+
return SplitCell;
|
|
36461
|
+
}());
|
|
36462
|
+
|
|
37239
36463
|
/**
|
|
37240
36464
|
* @description table menu
|
|
37241
36465
|
* @author wangfupeng
|
|
@@ -37287,6 +36511,19 @@ var tableFullWidthMenuConf = {
|
|
|
37287
36511
|
factory: function () {
|
|
37288
36512
|
return new TableFullWidth();
|
|
37289
36513
|
},
|
|
36514
|
+
};
|
|
36515
|
+
/** Meger / Split conf */
|
|
36516
|
+
var mergeTableCellConf = {
|
|
36517
|
+
key: 'mergeTableCell',
|
|
36518
|
+
factory: function () {
|
|
36519
|
+
return new MergeCell();
|
|
36520
|
+
},
|
|
36521
|
+
};
|
|
36522
|
+
var splitTableCellConf = {
|
|
36523
|
+
key: 'splitTableCell',
|
|
36524
|
+
factory: function () {
|
|
36525
|
+
return new SplitCell();
|
|
36526
|
+
},
|
|
37290
36527
|
};
|
|
37291
36528
|
|
|
37292
36529
|
/**
|
|
@@ -37307,6 +36544,8 @@ var table = {
|
|
|
37307
36544
|
deleteTableColConf,
|
|
37308
36545
|
tableHeaderMenuConf,
|
|
37309
36546
|
tableFullWidthMenuConf,
|
|
36547
|
+
mergeTableCellConf,
|
|
36548
|
+
splitTableCellConf,
|
|
37310
36549
|
],
|
|
37311
36550
|
editorPlugin: withTable,
|
|
37312
36551
|
};
|
|
@@ -44171,6 +43410,9 @@ var COMMON_HOVERBAR_KEYS = {
|
|
|
44171
43410
|
'insertTableCol',
|
|
44172
43411
|
'deleteTableCol',
|
|
44173
43412
|
'deleteTable',
|
|
43413
|
+
/** 注册单元格合并 拆分 */
|
|
43414
|
+
'mergeTableCell',
|
|
43415
|
+
'splitTableCell',
|
|
44174
43416
|
],
|
|
44175
43417
|
},
|
|
44176
43418
|
divider: {
|
|
@@ -44283,4 +43525,4 @@ function createToolbar(option) {
|
|
|
44283
43525
|
*/
|
|
44284
43526
|
var index = {};
|
|
44285
43527
|
|
|
44286
|
-
export { Boot, DomEditor, Editor as SlateEditor, Element$1 as SlateElement, Location as SlateLocation, Node$1 as SlateNode, Path as SlatePath, Point as SlatePoint, Range as SlateRange, Text as SlateText, Transforms as SlateTransforms, Toolbar, createEditor, createToolbar, createUploader, index as default, genModalButtonElems, genModalInputElems, genModalTextareaElems, i18nAddResources, i18nChangeLanguage, i18nGetResources, t };
|
|
43528
|
+
export { Boot, DomEditor, Editor as SlateEditor, Element$1 as SlateElement, Location as SlateLocation, Node$1 as SlateNode, Path as SlatePath, Point$1 as SlatePoint, Range as SlateRange, Text as SlateText, Transforms as SlateTransforms, Toolbar, createEditor, createToolbar, createUploader, index as default, genModalButtonElems, genModalInputElems, genModalTextareaElems, i18nAddResources, i18nChangeLanguage, i18nGetResources, t };
|