@mnykj/wangeditoroptimize-table-module 1.0.0
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/README.md +3 -0
- package/dist/css/style.css +1 -0
- package/dist/index.esm.js +3389 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/table-module/src/constants/svg.d.ts +17 -0
- package/dist/table-module/src/index.d.ts +8 -0
- package/dist/table-module/src/locale/en.d.ts +17 -0
- package/dist/table-module/src/locale/index.d.ts +5 -0
- package/dist/table-module/src/locale/zh-CN.d.ts +17 -0
- package/dist/table-module/src/module/custom-types.d.ts +22 -0
- package/dist/table-module/src/module/elem-to-html.d.ts +21 -0
- package/dist/table-module/src/module/helpers.d.ts +22 -0
- package/dist/table-module/src/module/index.d.ts +7 -0
- package/dist/table-module/src/module/menu/DeleteCol.d.ts +15 -0
- package/dist/table-module/src/module/menu/DeleteRow.d.ts +15 -0
- package/dist/table-module/src/module/menu/DeleteTable.d.ts +15 -0
- package/dist/table-module/src/module/menu/FullWidth.d.ts +15 -0
- package/dist/table-module/src/module/menu/InsertCol.d.ts +15 -0
- package/dist/table-module/src/module/menu/InsertRow.d.ts +15 -0
- package/dist/table-module/src/module/menu/InsertTable.d.ts +24 -0
- package/dist/table-module/src/module/menu/TableHeader.d.ts +15 -0
- package/dist/table-module/src/module/menu/index.d.ts +44 -0
- package/dist/table-module/src/module/parse-elem-html.d.ts +24 -0
- package/dist/table-module/src/module/plugin.d.ts +7 -0
- package/dist/table-module/src/module/pre-parse-html.d.ts +15 -0
- package/dist/table-module/src/module/render-elem/index.d.ts +19 -0
- package/dist/table-module/src/module/render-elem/render-cell.d.ts +9 -0
- package/dist/table-module/src/module/render-elem/render-row.d.ts +9 -0
- package/dist/table-module/src/module/render-elem/render-table.d.ts +9 -0
- package/dist/table-module/src/utils/dom.d.ts +26 -0
- package/dist/table-module/src/utils/util.d.ts +10 -0
- package/package.json +52 -0
|
@@ -0,0 +1,3389 @@
|
|
|
1
|
+
import { i18nAddResources, DomEditor, t, canRemoveEmptyLineAboveBlock, resolveElemPath, insertEmptyLineAboveAtPath, removeEmptyLineAboveTopLevelBlock } from '@mnykj/wangeditoroptimize-core';
|
|
2
|
+
import { Editor, Transforms, Path, Node, Point, Range, Element, Text } from 'slate';
|
|
3
|
+
import { jsx, h } from 'snabbdom';
|
|
4
|
+
import isEqual from 'lodash.isequal';
|
|
5
|
+
import throttle from 'lodash.throttle';
|
|
6
|
+
import $, { append, on, focus, attr, val, html as html$1, dataset, addClass, removeClass, children, each, find } from 'dom7';
|
|
7
|
+
import 'nanoid';
|
|
8
|
+
|
|
9
|
+
var enResources = {
|
|
10
|
+
tableModule: {
|
|
11
|
+
deleteCol: 'Delete column',
|
|
12
|
+
deleteRow: 'Delete row',
|
|
13
|
+
deleteTable: 'Delete table',
|
|
14
|
+
widthAuto: 'Width auto',
|
|
15
|
+
insertCol: 'Insert column',
|
|
16
|
+
insertRow: 'Insert row',
|
|
17
|
+
insertTable: 'Insert table',
|
|
18
|
+
header: 'Header'
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var zhResources = {
|
|
23
|
+
tableModule: {
|
|
24
|
+
deleteCol: '删除列',
|
|
25
|
+
deleteRow: '删除行',
|
|
26
|
+
deleteTable: '删除表格',
|
|
27
|
+
widthAuto: '宽度自适应',
|
|
28
|
+
insertCol: '插入列',
|
|
29
|
+
insertRow: '插入行',
|
|
30
|
+
insertTable: '插入表格',
|
|
31
|
+
header: '表头'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
i18nAddResources('en', enResources);
|
|
36
|
+
i18nAddResources('zh-CN', zhResources);
|
|
37
|
+
|
|
38
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
39
|
+
|
|
40
|
+
function createCommonjsModule(fn) {
|
|
41
|
+
var module = { exports: {} };
|
|
42
|
+
return fn(module, module.exports), module.exports;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var check = function (it) {
|
|
46
|
+
return it && it.Math == Math && it;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
50
|
+
var global$1 =
|
|
51
|
+
// eslint-disable-next-line es/no-global-this -- safe
|
|
52
|
+
check(typeof globalThis == 'object' && globalThis) ||
|
|
53
|
+
check(typeof window == 'object' && window) ||
|
|
54
|
+
// eslint-disable-next-line no-restricted-globals -- safe
|
|
55
|
+
check(typeof self == 'object' && self) ||
|
|
56
|
+
check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
|
|
57
|
+
// eslint-disable-next-line no-new-func -- fallback
|
|
58
|
+
(function () { return this; })() || Function('return this')();
|
|
59
|
+
|
|
60
|
+
var fails = function (exec) {
|
|
61
|
+
try {
|
|
62
|
+
return !!exec();
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Detect IE8's incomplete defineProperty implementation
|
|
69
|
+
var descriptors = !fails(function () {
|
|
70
|
+
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
71
|
+
return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
var call$2 = Function.prototype.call;
|
|
75
|
+
|
|
76
|
+
var functionCall = call$2.bind ? call$2.bind(call$2) : function () {
|
|
77
|
+
return call$2.apply(call$2, arguments);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
var $propertyIsEnumerable = {}.propertyIsEnumerable;
|
|
81
|
+
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
82
|
+
var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
|
|
83
|
+
|
|
84
|
+
// Nashorn ~ JDK8 bug
|
|
85
|
+
var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
|
|
86
|
+
|
|
87
|
+
// `Object.prototype.propertyIsEnumerable` method implementation
|
|
88
|
+
// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
|
|
89
|
+
var f$4 = NASHORN_BUG ? function propertyIsEnumerable(V) {
|
|
90
|
+
var descriptor = getOwnPropertyDescriptor$1(this, V);
|
|
91
|
+
return !!descriptor && descriptor.enumerable;
|
|
92
|
+
} : $propertyIsEnumerable;
|
|
93
|
+
|
|
94
|
+
var objectPropertyIsEnumerable = {
|
|
95
|
+
f: f$4
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
var createPropertyDescriptor = function (bitmap, value) {
|
|
99
|
+
return {
|
|
100
|
+
enumerable: !(bitmap & 1),
|
|
101
|
+
configurable: !(bitmap & 2),
|
|
102
|
+
writable: !(bitmap & 4),
|
|
103
|
+
value: value
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
var FunctionPrototype$2 = Function.prototype;
|
|
108
|
+
var bind$2 = FunctionPrototype$2.bind;
|
|
109
|
+
var call$1 = FunctionPrototype$2.call;
|
|
110
|
+
var callBind = bind$2 && bind$2.bind(call$1);
|
|
111
|
+
|
|
112
|
+
var functionUncurryThis = bind$2 ? function (fn) {
|
|
113
|
+
return fn && callBind(call$1, fn);
|
|
114
|
+
} : function (fn) {
|
|
115
|
+
return fn && function () {
|
|
116
|
+
return call$1.apply(fn, arguments);
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var toString$2 = functionUncurryThis({}.toString);
|
|
121
|
+
var stringSlice$5 = functionUncurryThis(''.slice);
|
|
122
|
+
|
|
123
|
+
var classofRaw = function (it) {
|
|
124
|
+
return stringSlice$5(toString$2(it), 8, -1);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var Object$4 = global$1.Object;
|
|
128
|
+
var split = functionUncurryThis(''.split);
|
|
129
|
+
|
|
130
|
+
// fallback for non-array-like ES3 and non-enumerable old V8 strings
|
|
131
|
+
var indexedObject = fails(function () {
|
|
132
|
+
// throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
|
|
133
|
+
// eslint-disable-next-line no-prototype-builtins -- safe
|
|
134
|
+
return !Object$4('z').propertyIsEnumerable(0);
|
|
135
|
+
}) ? function (it) {
|
|
136
|
+
return classofRaw(it) == 'String' ? split(it, '') : Object$4(it);
|
|
137
|
+
} : Object$4;
|
|
138
|
+
|
|
139
|
+
var TypeError$9 = global$1.TypeError;
|
|
140
|
+
|
|
141
|
+
// `RequireObjectCoercible` abstract operation
|
|
142
|
+
// https://tc39.es/ecma262/#sec-requireobjectcoercible
|
|
143
|
+
var requireObjectCoercible = function (it) {
|
|
144
|
+
if (it == undefined) throw TypeError$9("Can't call method on " + it);
|
|
145
|
+
return it;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// toObject with fallback for non-array-like ES3 strings
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
var toIndexedObject = function (it) {
|
|
153
|
+
return indexedObject(requireObjectCoercible(it));
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// `IsCallable` abstract operation
|
|
157
|
+
// https://tc39.es/ecma262/#sec-iscallable
|
|
158
|
+
var isCallable = function (argument) {
|
|
159
|
+
return typeof argument == 'function';
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
var isObject = function (it) {
|
|
163
|
+
return typeof it == 'object' ? it !== null : isCallable(it);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
var aFunction = function (argument) {
|
|
167
|
+
return isCallable(argument) ? argument : undefined;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
var getBuiltIn = function (namespace, method) {
|
|
171
|
+
return arguments.length < 2 ? aFunction(global$1[namespace]) : global$1[namespace] && global$1[namespace][method];
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf);
|
|
175
|
+
|
|
176
|
+
var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';
|
|
177
|
+
|
|
178
|
+
var process = global$1.process;
|
|
179
|
+
var Deno = global$1.Deno;
|
|
180
|
+
var versions = process && process.versions || Deno && Deno.version;
|
|
181
|
+
var v8 = versions && versions.v8;
|
|
182
|
+
var match, version;
|
|
183
|
+
|
|
184
|
+
if (v8) {
|
|
185
|
+
match = v8.split('.');
|
|
186
|
+
// in old Chrome, versions of V8 isn't V8 = Chrome / 10
|
|
187
|
+
// but their correct versions are not interesting for us
|
|
188
|
+
version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
|
|
192
|
+
// so check `userAgent` even if `.v8` exists, but 0
|
|
193
|
+
if (!version && engineUserAgent) {
|
|
194
|
+
match = engineUserAgent.match(/Edge\/(\d+)/);
|
|
195
|
+
if (!match || match[1] >= 74) {
|
|
196
|
+
match = engineUserAgent.match(/Chrome\/(\d+)/);
|
|
197
|
+
if (match) version = +match[1];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
var engineV8Version = version;
|
|
202
|
+
|
|
203
|
+
/* eslint-disable es/no-symbol -- required for testing */
|
|
204
|
+
|
|
205
|
+
// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
|
|
206
|
+
var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
|
|
207
|
+
var symbol = Symbol();
|
|
208
|
+
// Chrome 38 Symbol has incorrect toString conversion
|
|
209
|
+
// `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
|
|
210
|
+
return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
|
|
211
|
+
// Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
|
|
212
|
+
!Symbol.sham && engineV8Version && engineV8Version < 41;
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
/* eslint-disable es/no-symbol -- required for testing */
|
|
216
|
+
|
|
217
|
+
var useSymbolAsUid = nativeSymbol
|
|
218
|
+
&& !Symbol.sham
|
|
219
|
+
&& typeof Symbol.iterator == 'symbol';
|
|
220
|
+
|
|
221
|
+
var Object$3 = global$1.Object;
|
|
222
|
+
|
|
223
|
+
var isSymbol = useSymbolAsUid ? function (it) {
|
|
224
|
+
return typeof it == 'symbol';
|
|
225
|
+
} : function (it) {
|
|
226
|
+
var $Symbol = getBuiltIn('Symbol');
|
|
227
|
+
return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, Object$3(it));
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
var String$3 = global$1.String;
|
|
231
|
+
|
|
232
|
+
var tryToString = function (argument) {
|
|
233
|
+
try {
|
|
234
|
+
return String$3(argument);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
return 'Object';
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
var TypeError$8 = global$1.TypeError;
|
|
241
|
+
|
|
242
|
+
// `Assert: IsCallable(argument) is true`
|
|
243
|
+
var aCallable = function (argument) {
|
|
244
|
+
if (isCallable(argument)) return argument;
|
|
245
|
+
throw TypeError$8(tryToString(argument) + ' is not a function');
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// `GetMethod` abstract operation
|
|
249
|
+
// https://tc39.es/ecma262/#sec-getmethod
|
|
250
|
+
var getMethod = function (V, P) {
|
|
251
|
+
var func = V[P];
|
|
252
|
+
return func == null ? undefined : aCallable(func);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
var TypeError$7 = global$1.TypeError;
|
|
256
|
+
|
|
257
|
+
// `OrdinaryToPrimitive` abstract operation
|
|
258
|
+
// https://tc39.es/ecma262/#sec-ordinarytoprimitive
|
|
259
|
+
var ordinaryToPrimitive = function (input, pref) {
|
|
260
|
+
var fn, val;
|
|
261
|
+
if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val;
|
|
262
|
+
if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val;
|
|
263
|
+
if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val;
|
|
264
|
+
throw TypeError$7("Can't convert object to primitive value");
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
268
|
+
var defineProperty = Object.defineProperty;
|
|
269
|
+
|
|
270
|
+
var setGlobal = function (key, value) {
|
|
271
|
+
try {
|
|
272
|
+
defineProperty(global$1, key, { value: value, configurable: true, writable: true });
|
|
273
|
+
} catch (error) {
|
|
274
|
+
global$1[key] = value;
|
|
275
|
+
} return value;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
var SHARED = '__core-js_shared__';
|
|
279
|
+
var store$1 = global$1[SHARED] || setGlobal(SHARED, {});
|
|
280
|
+
|
|
281
|
+
var sharedStore = store$1;
|
|
282
|
+
|
|
283
|
+
var shared = createCommonjsModule(function (module) {
|
|
284
|
+
(module.exports = function (key, value) {
|
|
285
|
+
return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
|
|
286
|
+
})('versions', []).push({
|
|
287
|
+
version: '3.19.3',
|
|
288
|
+
mode: 'global',
|
|
289
|
+
copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
var Object$2 = global$1.Object;
|
|
294
|
+
|
|
295
|
+
// `ToObject` abstract operation
|
|
296
|
+
// https://tc39.es/ecma262/#sec-toobject
|
|
297
|
+
var toObject = function (argument) {
|
|
298
|
+
return Object$2(requireObjectCoercible(argument));
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
var hasOwnProperty = functionUncurryThis({}.hasOwnProperty);
|
|
302
|
+
|
|
303
|
+
// `HasOwnProperty` abstract operation
|
|
304
|
+
// https://tc39.es/ecma262/#sec-hasownproperty
|
|
305
|
+
var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
|
|
306
|
+
return hasOwnProperty(toObject(it), key);
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
var id = 0;
|
|
310
|
+
var postfix = Math.random();
|
|
311
|
+
var toString$1 = functionUncurryThis(1.0.toString);
|
|
312
|
+
|
|
313
|
+
var uid = function (key) {
|
|
314
|
+
return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36);
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
var WellKnownSymbolsStore = shared('wks');
|
|
318
|
+
var Symbol$1 = global$1.Symbol;
|
|
319
|
+
var symbolFor = Symbol$1 && Symbol$1['for'];
|
|
320
|
+
var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
|
|
321
|
+
|
|
322
|
+
var wellKnownSymbol = function (name) {
|
|
323
|
+
if (!hasOwnProperty_1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) {
|
|
324
|
+
var description = 'Symbol.' + name;
|
|
325
|
+
if (nativeSymbol && hasOwnProperty_1(Symbol$1, name)) {
|
|
326
|
+
WellKnownSymbolsStore[name] = Symbol$1[name];
|
|
327
|
+
} else if (useSymbolAsUid && symbolFor) {
|
|
328
|
+
WellKnownSymbolsStore[name] = symbolFor(description);
|
|
329
|
+
} else {
|
|
330
|
+
WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
|
|
331
|
+
}
|
|
332
|
+
} return WellKnownSymbolsStore[name];
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
var TypeError$6 = global$1.TypeError;
|
|
336
|
+
var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
|
|
337
|
+
|
|
338
|
+
// `ToPrimitive` abstract operation
|
|
339
|
+
// https://tc39.es/ecma262/#sec-toprimitive
|
|
340
|
+
var toPrimitive = function (input, pref) {
|
|
341
|
+
if (!isObject(input) || isSymbol(input)) return input;
|
|
342
|
+
var exoticToPrim = getMethod(input, TO_PRIMITIVE);
|
|
343
|
+
var result;
|
|
344
|
+
if (exoticToPrim) {
|
|
345
|
+
if (pref === undefined) pref = 'default';
|
|
346
|
+
result = functionCall(exoticToPrim, input, pref);
|
|
347
|
+
if (!isObject(result) || isSymbol(result)) return result;
|
|
348
|
+
throw TypeError$6("Can't convert object to primitive value");
|
|
349
|
+
}
|
|
350
|
+
if (pref === undefined) pref = 'number';
|
|
351
|
+
return ordinaryToPrimitive(input, pref);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
// `ToPropertyKey` abstract operation
|
|
355
|
+
// https://tc39.es/ecma262/#sec-topropertykey
|
|
356
|
+
var toPropertyKey = function (argument) {
|
|
357
|
+
var key = toPrimitive(argument, 'string');
|
|
358
|
+
return isSymbol(key) ? key : key + '';
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
var document$1 = global$1.document;
|
|
362
|
+
// typeof document.createElement is 'object' in old IE
|
|
363
|
+
var EXISTS$1 = isObject(document$1) && isObject(document$1.createElement);
|
|
364
|
+
|
|
365
|
+
var documentCreateElement = function (it) {
|
|
366
|
+
return EXISTS$1 ? document$1.createElement(it) : {};
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
// Thank's IE8 for his funny defineProperty
|
|
370
|
+
var ie8DomDefine = !descriptors && !fails(function () {
|
|
371
|
+
// eslint-disable-next-line es/no-object-defineproperty -- requied for testing
|
|
372
|
+
return Object.defineProperty(documentCreateElement('div'), 'a', {
|
|
373
|
+
get: function () { return 7; }
|
|
374
|
+
}).a != 7;
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
378
|
+
var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
379
|
+
|
|
380
|
+
// `Object.getOwnPropertyDescriptor` method
|
|
381
|
+
// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
|
|
382
|
+
var f$3 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
|
|
383
|
+
O = toIndexedObject(O);
|
|
384
|
+
P = toPropertyKey(P);
|
|
385
|
+
if (ie8DomDefine) try {
|
|
386
|
+
return $getOwnPropertyDescriptor(O, P);
|
|
387
|
+
} catch (error) { /* empty */ }
|
|
388
|
+
if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]);
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
var objectGetOwnPropertyDescriptor = {
|
|
392
|
+
f: f$3
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
var String$2 = global$1.String;
|
|
396
|
+
var TypeError$5 = global$1.TypeError;
|
|
397
|
+
|
|
398
|
+
// `Assert: Type(argument) is Object`
|
|
399
|
+
var anObject = function (argument) {
|
|
400
|
+
if (isObject(argument)) return argument;
|
|
401
|
+
throw TypeError$5(String$2(argument) + ' is not an object');
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
var TypeError$4 = global$1.TypeError;
|
|
405
|
+
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
406
|
+
var $defineProperty = Object.defineProperty;
|
|
407
|
+
|
|
408
|
+
// `Object.defineProperty` method
|
|
409
|
+
// https://tc39.es/ecma262/#sec-object.defineproperty
|
|
410
|
+
var f$2 = descriptors ? $defineProperty : function defineProperty(O, P, Attributes) {
|
|
411
|
+
anObject(O);
|
|
412
|
+
P = toPropertyKey(P);
|
|
413
|
+
anObject(Attributes);
|
|
414
|
+
if (ie8DomDefine) try {
|
|
415
|
+
return $defineProperty(O, P, Attributes);
|
|
416
|
+
} catch (error) { /* empty */ }
|
|
417
|
+
if ('get' in Attributes || 'set' in Attributes) throw TypeError$4('Accessors not supported');
|
|
418
|
+
if ('value' in Attributes) O[P] = Attributes.value;
|
|
419
|
+
return O;
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
var objectDefineProperty = {
|
|
423
|
+
f: f$2
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
var createNonEnumerableProperty = descriptors ? function (object, key, value) {
|
|
427
|
+
return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
|
|
428
|
+
} : function (object, key, value) {
|
|
429
|
+
object[key] = value;
|
|
430
|
+
return object;
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
var functionToString = functionUncurryThis(Function.toString);
|
|
434
|
+
|
|
435
|
+
// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
|
|
436
|
+
if (!isCallable(sharedStore.inspectSource)) {
|
|
437
|
+
sharedStore.inspectSource = function (it) {
|
|
438
|
+
return functionToString(it);
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
var inspectSource = sharedStore.inspectSource;
|
|
443
|
+
|
|
444
|
+
var WeakMap$1 = global$1.WeakMap;
|
|
445
|
+
|
|
446
|
+
var nativeWeakMap = isCallable(WeakMap$1) && /native code/.test(inspectSource(WeakMap$1));
|
|
447
|
+
|
|
448
|
+
var keys = shared('keys');
|
|
449
|
+
|
|
450
|
+
var sharedKey = function (key) {
|
|
451
|
+
return keys[key] || (keys[key] = uid(key));
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
var hiddenKeys$1 = {};
|
|
455
|
+
|
|
456
|
+
var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
|
|
457
|
+
var TypeError$3 = global$1.TypeError;
|
|
458
|
+
var WeakMap = global$1.WeakMap;
|
|
459
|
+
var set, get, has;
|
|
460
|
+
|
|
461
|
+
var enforce = function (it) {
|
|
462
|
+
return has(it) ? get(it) : set(it, {});
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
var getterFor = function (TYPE) {
|
|
466
|
+
return function (it) {
|
|
467
|
+
var state;
|
|
468
|
+
if (!isObject(it) || (state = get(it)).type !== TYPE) {
|
|
469
|
+
throw TypeError$3('Incompatible receiver, ' + TYPE + ' required');
|
|
470
|
+
} return state;
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
if (nativeWeakMap || sharedStore.state) {
|
|
475
|
+
var store = sharedStore.state || (sharedStore.state = new WeakMap());
|
|
476
|
+
var wmget = functionUncurryThis(store.get);
|
|
477
|
+
var wmhas = functionUncurryThis(store.has);
|
|
478
|
+
var wmset = functionUncurryThis(store.set);
|
|
479
|
+
set = function (it, metadata) {
|
|
480
|
+
if (wmhas(store, it)) throw new TypeError$3(OBJECT_ALREADY_INITIALIZED);
|
|
481
|
+
metadata.facade = it;
|
|
482
|
+
wmset(store, it, metadata);
|
|
483
|
+
return metadata;
|
|
484
|
+
};
|
|
485
|
+
get = function (it) {
|
|
486
|
+
return wmget(store, it) || {};
|
|
487
|
+
};
|
|
488
|
+
has = function (it) {
|
|
489
|
+
return wmhas(store, it);
|
|
490
|
+
};
|
|
491
|
+
} else {
|
|
492
|
+
var STATE = sharedKey('state');
|
|
493
|
+
hiddenKeys$1[STATE] = true;
|
|
494
|
+
set = function (it, metadata) {
|
|
495
|
+
if (hasOwnProperty_1(it, STATE)) throw new TypeError$3(OBJECT_ALREADY_INITIALIZED);
|
|
496
|
+
metadata.facade = it;
|
|
497
|
+
createNonEnumerableProperty(it, STATE, metadata);
|
|
498
|
+
return metadata;
|
|
499
|
+
};
|
|
500
|
+
get = function (it) {
|
|
501
|
+
return hasOwnProperty_1(it, STATE) ? it[STATE] : {};
|
|
502
|
+
};
|
|
503
|
+
has = function (it) {
|
|
504
|
+
return hasOwnProperty_1(it, STATE);
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
var internalState = {
|
|
509
|
+
set: set,
|
|
510
|
+
get: get,
|
|
511
|
+
has: has,
|
|
512
|
+
enforce: enforce,
|
|
513
|
+
getterFor: getterFor
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
var FunctionPrototype$1 = Function.prototype;
|
|
517
|
+
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
518
|
+
var getDescriptor = descriptors && Object.getOwnPropertyDescriptor;
|
|
519
|
+
|
|
520
|
+
var EXISTS = hasOwnProperty_1(FunctionPrototype$1, 'name');
|
|
521
|
+
// additional protection from minified / mangled / dropped function names
|
|
522
|
+
var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
|
|
523
|
+
var CONFIGURABLE = EXISTS && (!descriptors || (descriptors && getDescriptor(FunctionPrototype$1, 'name').configurable));
|
|
524
|
+
|
|
525
|
+
var functionName = {
|
|
526
|
+
EXISTS: EXISTS,
|
|
527
|
+
PROPER: PROPER,
|
|
528
|
+
CONFIGURABLE: CONFIGURABLE
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
var redefine = createCommonjsModule(function (module) {
|
|
532
|
+
var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
|
|
533
|
+
|
|
534
|
+
var getInternalState = internalState.get;
|
|
535
|
+
var enforceInternalState = internalState.enforce;
|
|
536
|
+
var TEMPLATE = String(String).split('String');
|
|
537
|
+
|
|
538
|
+
(module.exports = function (O, key, value, options) {
|
|
539
|
+
var unsafe = options ? !!options.unsafe : false;
|
|
540
|
+
var simple = options ? !!options.enumerable : false;
|
|
541
|
+
var noTargetGet = options ? !!options.noTargetGet : false;
|
|
542
|
+
var name = options && options.name !== undefined ? options.name : key;
|
|
543
|
+
var state;
|
|
544
|
+
if (isCallable(value)) {
|
|
545
|
+
if (String(name).slice(0, 7) === 'Symbol(') {
|
|
546
|
+
name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
|
|
547
|
+
}
|
|
548
|
+
if (!hasOwnProperty_1(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
|
|
549
|
+
createNonEnumerableProperty(value, 'name', name);
|
|
550
|
+
}
|
|
551
|
+
state = enforceInternalState(value);
|
|
552
|
+
if (!state.source) {
|
|
553
|
+
state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (O === global$1) {
|
|
557
|
+
if (simple) O[key] = value;
|
|
558
|
+
else setGlobal(key, value);
|
|
559
|
+
return;
|
|
560
|
+
} else if (!unsafe) {
|
|
561
|
+
delete O[key];
|
|
562
|
+
} else if (!noTargetGet && O[key]) {
|
|
563
|
+
simple = true;
|
|
564
|
+
}
|
|
565
|
+
if (simple) O[key] = value;
|
|
566
|
+
else createNonEnumerableProperty(O, key, value);
|
|
567
|
+
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
|
|
568
|
+
})(Function.prototype, 'toString', function toString() {
|
|
569
|
+
return isCallable(this) && getInternalState(this).source || inspectSource(this);
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
var ceil = Math.ceil;
|
|
574
|
+
var floor$1 = Math.floor;
|
|
575
|
+
|
|
576
|
+
// `ToIntegerOrInfinity` abstract operation
|
|
577
|
+
// https://tc39.es/ecma262/#sec-tointegerorinfinity
|
|
578
|
+
var toIntegerOrInfinity = function (argument) {
|
|
579
|
+
var number = +argument;
|
|
580
|
+
// eslint-disable-next-line no-self-compare -- safe
|
|
581
|
+
return number !== number || number === 0 ? 0 : (number > 0 ? floor$1 : ceil)(number);
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
var max$3 = Math.max;
|
|
585
|
+
var min$3 = Math.min;
|
|
586
|
+
|
|
587
|
+
// Helper for a popular repeating case of the spec:
|
|
588
|
+
// Let integer be ? ToInteger(index).
|
|
589
|
+
// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
|
|
590
|
+
var toAbsoluteIndex = function (index, length) {
|
|
591
|
+
var integer = toIntegerOrInfinity(index);
|
|
592
|
+
return integer < 0 ? max$3(integer + length, 0) : min$3(integer, length);
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
var min$2 = Math.min;
|
|
596
|
+
|
|
597
|
+
// `ToLength` abstract operation
|
|
598
|
+
// https://tc39.es/ecma262/#sec-tolength
|
|
599
|
+
var toLength = function (argument) {
|
|
600
|
+
return argument > 0 ? min$2(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
// `LengthOfArrayLike` abstract operation
|
|
604
|
+
// https://tc39.es/ecma262/#sec-lengthofarraylike
|
|
605
|
+
var lengthOfArrayLike = function (obj) {
|
|
606
|
+
return toLength(obj.length);
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
// `Array.prototype.{ indexOf, includes }` methods implementation
|
|
610
|
+
var createMethod$3 = function (IS_INCLUDES) {
|
|
611
|
+
return function ($this, el, fromIndex) {
|
|
612
|
+
var O = toIndexedObject($this);
|
|
613
|
+
var length = lengthOfArrayLike(O);
|
|
614
|
+
var index = toAbsoluteIndex(fromIndex, length);
|
|
615
|
+
var value;
|
|
616
|
+
// Array#includes uses SameValueZero equality algorithm
|
|
617
|
+
// eslint-disable-next-line no-self-compare -- NaN check
|
|
618
|
+
if (IS_INCLUDES && el != el) while (length > index) {
|
|
619
|
+
value = O[index++];
|
|
620
|
+
// eslint-disable-next-line no-self-compare -- NaN check
|
|
621
|
+
if (value != value) return true;
|
|
622
|
+
// Array#indexOf ignores holes, Array#includes - not
|
|
623
|
+
} else for (;length > index; index++) {
|
|
624
|
+
if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
|
|
625
|
+
} return !IS_INCLUDES && -1;
|
|
626
|
+
};
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
var arrayIncludes = {
|
|
630
|
+
// `Array.prototype.includes` method
|
|
631
|
+
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
632
|
+
includes: createMethod$3(true),
|
|
633
|
+
// `Array.prototype.indexOf` method
|
|
634
|
+
// https://tc39.es/ecma262/#sec-array.prototype.indexof
|
|
635
|
+
indexOf: createMethod$3(false)
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
var indexOf$1 = arrayIncludes.indexOf;
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
var push$3 = functionUncurryThis([].push);
|
|
642
|
+
|
|
643
|
+
var objectKeysInternal = function (object, names) {
|
|
644
|
+
var O = toIndexedObject(object);
|
|
645
|
+
var i = 0;
|
|
646
|
+
var result = [];
|
|
647
|
+
var key;
|
|
648
|
+
for (key in O) !hasOwnProperty_1(hiddenKeys$1, key) && hasOwnProperty_1(O, key) && push$3(result, key);
|
|
649
|
+
// Don't enum bug & hidden keys
|
|
650
|
+
while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) {
|
|
651
|
+
~indexOf$1(result, key) || push$3(result, key);
|
|
652
|
+
}
|
|
653
|
+
return result;
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
// IE8- don't enum bug keys
|
|
657
|
+
var enumBugKeys = [
|
|
658
|
+
'constructor',
|
|
659
|
+
'hasOwnProperty',
|
|
660
|
+
'isPrototypeOf',
|
|
661
|
+
'propertyIsEnumerable',
|
|
662
|
+
'toLocaleString',
|
|
663
|
+
'toString',
|
|
664
|
+
'valueOf'
|
|
665
|
+
];
|
|
666
|
+
|
|
667
|
+
var hiddenKeys = enumBugKeys.concat('length', 'prototype');
|
|
668
|
+
|
|
669
|
+
// `Object.getOwnPropertyNames` method
|
|
670
|
+
// https://tc39.es/ecma262/#sec-object.getownpropertynames
|
|
671
|
+
// eslint-disable-next-line es/no-object-getownpropertynames -- safe
|
|
672
|
+
var f$1 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
|
|
673
|
+
return objectKeysInternal(O, hiddenKeys);
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
var objectGetOwnPropertyNames = {
|
|
677
|
+
f: f$1
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
|
|
681
|
+
var f = Object.getOwnPropertySymbols;
|
|
682
|
+
|
|
683
|
+
var objectGetOwnPropertySymbols = {
|
|
684
|
+
f: f
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
var concat$1 = functionUncurryThis([].concat);
|
|
688
|
+
|
|
689
|
+
// all object keys, includes non-enumerable and symbols
|
|
690
|
+
var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
|
|
691
|
+
var keys = objectGetOwnPropertyNames.f(anObject(it));
|
|
692
|
+
var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
|
|
693
|
+
return getOwnPropertySymbols ? concat$1(keys, getOwnPropertySymbols(it)) : keys;
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
var copyConstructorProperties = function (target, source) {
|
|
697
|
+
var keys = ownKeys(source);
|
|
698
|
+
var defineProperty = objectDefineProperty.f;
|
|
699
|
+
var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
|
|
700
|
+
for (var i = 0; i < keys.length; i++) {
|
|
701
|
+
var key = keys[i];
|
|
702
|
+
if (!hasOwnProperty_1(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
var replacement = /#|\.prototype\./;
|
|
707
|
+
|
|
708
|
+
var isForced = function (feature, detection) {
|
|
709
|
+
var value = data[normalize(feature)];
|
|
710
|
+
return value == POLYFILL ? true
|
|
711
|
+
: value == NATIVE ? false
|
|
712
|
+
: isCallable(detection) ? fails(detection)
|
|
713
|
+
: !!detection;
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
var normalize = isForced.normalize = function (string) {
|
|
717
|
+
return String(string).replace(replacement, '.').toLowerCase();
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
var data = isForced.data = {};
|
|
721
|
+
var NATIVE = isForced.NATIVE = 'N';
|
|
722
|
+
var POLYFILL = isForced.POLYFILL = 'P';
|
|
723
|
+
|
|
724
|
+
var isForced_1 = isForced;
|
|
725
|
+
|
|
726
|
+
var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
/*
|
|
734
|
+
options.target - name of the target object
|
|
735
|
+
options.global - target is the global object
|
|
736
|
+
options.stat - export as static methods of target
|
|
737
|
+
options.proto - export as prototype methods of target
|
|
738
|
+
options.real - real prototype method for the `pure` version
|
|
739
|
+
options.forced - export even if the native feature is available
|
|
740
|
+
options.bind - bind methods to the target, required for the `pure` version
|
|
741
|
+
options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
|
|
742
|
+
options.unsafe - use the simple assignment of property instead of delete + defineProperty
|
|
743
|
+
options.sham - add a flag to not completely full polyfills
|
|
744
|
+
options.enumerable - export as enumerable property
|
|
745
|
+
options.noTargetGet - prevent calling a getter on target
|
|
746
|
+
options.name - the .name of the function if it does not match the key
|
|
747
|
+
*/
|
|
748
|
+
var _export = function (options, source) {
|
|
749
|
+
var TARGET = options.target;
|
|
750
|
+
var GLOBAL = options.global;
|
|
751
|
+
var STATIC = options.stat;
|
|
752
|
+
var FORCED, target, key, targetProperty, sourceProperty, descriptor;
|
|
753
|
+
if (GLOBAL) {
|
|
754
|
+
target = global$1;
|
|
755
|
+
} else if (STATIC) {
|
|
756
|
+
target = global$1[TARGET] || setGlobal(TARGET, {});
|
|
757
|
+
} else {
|
|
758
|
+
target = (global$1[TARGET] || {}).prototype;
|
|
759
|
+
}
|
|
760
|
+
if (target) for (key in source) {
|
|
761
|
+
sourceProperty = source[key];
|
|
762
|
+
if (options.noTargetGet) {
|
|
763
|
+
descriptor = getOwnPropertyDescriptor(target, key);
|
|
764
|
+
targetProperty = descriptor && descriptor.value;
|
|
765
|
+
} else targetProperty = target[key];
|
|
766
|
+
FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
|
|
767
|
+
// contained in target
|
|
768
|
+
if (!FORCED && targetProperty !== undefined) {
|
|
769
|
+
if (typeof sourceProperty == typeof targetProperty) continue;
|
|
770
|
+
copyConstructorProperties(sourceProperty, targetProperty);
|
|
771
|
+
}
|
|
772
|
+
// add a flag to not completely full polyfills
|
|
773
|
+
if (options.sham || (targetProperty && targetProperty.sham)) {
|
|
774
|
+
createNonEnumerableProperty(sourceProperty, 'sham', true);
|
|
775
|
+
}
|
|
776
|
+
// extend global
|
|
777
|
+
redefine(target, key, sourceProperty, options);
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
|
|
782
|
+
var test = {};
|
|
783
|
+
|
|
784
|
+
test[TO_STRING_TAG$1] = 'z';
|
|
785
|
+
|
|
786
|
+
var toStringTagSupport = String(test) === '[object z]';
|
|
787
|
+
|
|
788
|
+
var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
|
789
|
+
var Object$1 = global$1.Object;
|
|
790
|
+
|
|
791
|
+
// ES3 wrong here
|
|
792
|
+
var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
|
|
793
|
+
|
|
794
|
+
// fallback for IE11 Script Access Denied error
|
|
795
|
+
var tryGet = function (it, key) {
|
|
796
|
+
try {
|
|
797
|
+
return it[key];
|
|
798
|
+
} catch (error) { /* empty */ }
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
// getting tag from ES6+ `Object.prototype.toString`
|
|
802
|
+
var classof = toStringTagSupport ? classofRaw : function (it) {
|
|
803
|
+
var O, tag, result;
|
|
804
|
+
return it === undefined ? 'Undefined' : it === null ? 'Null'
|
|
805
|
+
// @@toStringTag case
|
|
806
|
+
: typeof (tag = tryGet(O = Object$1(it), TO_STRING_TAG)) == 'string' ? tag
|
|
807
|
+
// builtinTag case
|
|
808
|
+
: CORRECT_ARGUMENTS ? classofRaw(O)
|
|
809
|
+
// ES3 arguments fallback
|
|
810
|
+
: (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
var String$1 = global$1.String;
|
|
814
|
+
|
|
815
|
+
var toString = function (argument) {
|
|
816
|
+
if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
|
|
817
|
+
return String$1(argument);
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
var quot = /"/g;
|
|
821
|
+
var replace$3 = functionUncurryThis(''.replace);
|
|
822
|
+
|
|
823
|
+
// `CreateHTML` abstract operation
|
|
824
|
+
// https://tc39.es/ecma262/#sec-createhtml
|
|
825
|
+
var createHtml = function (string, tag, attribute, value) {
|
|
826
|
+
var S = toString(requireObjectCoercible(string));
|
|
827
|
+
var p1 = '<' + tag;
|
|
828
|
+
if (attribute !== '') p1 += ' ' + attribute + '="' + replace$3(toString(value), quot, '"') + '"';
|
|
829
|
+
return p1 + '>' + S + '</' + tag + '>';
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
// check the existence of a method, lowercase
|
|
833
|
+
// of a tag and escaping quotes in arguments
|
|
834
|
+
var stringHtmlForced = function (METHOD_NAME) {
|
|
835
|
+
return fails(function () {
|
|
836
|
+
var test = ''[METHOD_NAME]('"');
|
|
837
|
+
return test !== test.toLowerCase() || test.split('"').length > 3;
|
|
838
|
+
});
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
// `String.prototype.anchor` method
|
|
842
|
+
// https://tc39.es/ecma262/#sec-string.prototype.anchor
|
|
843
|
+
_export({ target: 'String', proto: true, forced: stringHtmlForced('anchor') }, {
|
|
844
|
+
anchor: function anchor(name) {
|
|
845
|
+
return createHtml(this, 'a', 'name', name);
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
// `RegExp.prototype.flags` getter implementation
|
|
850
|
+
// https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
|
|
851
|
+
var regexpFlags = function () {
|
|
852
|
+
var that = anObject(this);
|
|
853
|
+
var result = '';
|
|
854
|
+
if (that.global) result += 'g';
|
|
855
|
+
if (that.ignoreCase) result += 'i';
|
|
856
|
+
if (that.multiline) result += 'm';
|
|
857
|
+
if (that.dotAll) result += 's';
|
|
858
|
+
if (that.unicode) result += 'u';
|
|
859
|
+
if (that.sticky) result += 'y';
|
|
860
|
+
return result;
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
// babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
|
|
864
|
+
var $RegExp$2 = global$1.RegExp;
|
|
865
|
+
|
|
866
|
+
var UNSUPPORTED_Y$2 = fails(function () {
|
|
867
|
+
var re = $RegExp$2('a', 'y');
|
|
868
|
+
re.lastIndex = 2;
|
|
869
|
+
return re.exec('abcd') != null;
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
// UC Browser bug
|
|
873
|
+
// https://github.com/zloirock/core-js/issues/1008
|
|
874
|
+
var MISSED_STICKY = UNSUPPORTED_Y$2 || fails(function () {
|
|
875
|
+
return !$RegExp$2('a', 'y').sticky;
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
var BROKEN_CARET = UNSUPPORTED_Y$2 || fails(function () {
|
|
879
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=773687
|
|
880
|
+
var re = $RegExp$2('^r', 'gy');
|
|
881
|
+
re.lastIndex = 2;
|
|
882
|
+
return re.exec('str') != null;
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
var regexpStickyHelpers = {
|
|
886
|
+
BROKEN_CARET: BROKEN_CARET,
|
|
887
|
+
MISSED_STICKY: MISSED_STICKY,
|
|
888
|
+
UNSUPPORTED_Y: UNSUPPORTED_Y$2
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
// `Object.keys` method
|
|
892
|
+
// https://tc39.es/ecma262/#sec-object.keys
|
|
893
|
+
// eslint-disable-next-line es/no-object-keys -- safe
|
|
894
|
+
var objectKeys = Object.keys || function keys(O) {
|
|
895
|
+
return objectKeysInternal(O, enumBugKeys);
|
|
896
|
+
};
|
|
897
|
+
|
|
898
|
+
// `Object.defineProperties` method
|
|
899
|
+
// https://tc39.es/ecma262/#sec-object.defineproperties
|
|
900
|
+
// eslint-disable-next-line es/no-object-defineproperties -- safe
|
|
901
|
+
var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
|
|
902
|
+
anObject(O);
|
|
903
|
+
var props = toIndexedObject(Properties);
|
|
904
|
+
var keys = objectKeys(Properties);
|
|
905
|
+
var length = keys.length;
|
|
906
|
+
var index = 0;
|
|
907
|
+
var key;
|
|
908
|
+
while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]);
|
|
909
|
+
return O;
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
var html = getBuiltIn('document', 'documentElement');
|
|
913
|
+
|
|
914
|
+
/* global ActiveXObject -- old IE, WSH */
|
|
915
|
+
|
|
916
|
+
var GT = '>';
|
|
917
|
+
var LT = '<';
|
|
918
|
+
var PROTOTYPE = 'prototype';
|
|
919
|
+
var SCRIPT = 'script';
|
|
920
|
+
var IE_PROTO = sharedKey('IE_PROTO');
|
|
921
|
+
|
|
922
|
+
var EmptyConstructor = function () { /* empty */ };
|
|
923
|
+
|
|
924
|
+
var scriptTag = function (content) {
|
|
925
|
+
return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
// Create object with fake `null` prototype: use ActiveX Object with cleared prototype
|
|
929
|
+
var NullProtoObjectViaActiveX = function (activeXDocument) {
|
|
930
|
+
activeXDocument.write(scriptTag(''));
|
|
931
|
+
activeXDocument.close();
|
|
932
|
+
var temp = activeXDocument.parentWindow.Object;
|
|
933
|
+
activeXDocument = null; // avoid memory leak
|
|
934
|
+
return temp;
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
// Create object with fake `null` prototype: use iframe Object with cleared prototype
|
|
938
|
+
var NullProtoObjectViaIFrame = function () {
|
|
939
|
+
// Thrash, waste and sodomy: IE GC bug
|
|
940
|
+
var iframe = documentCreateElement('iframe');
|
|
941
|
+
var JS = 'java' + SCRIPT + ':';
|
|
942
|
+
var iframeDocument;
|
|
943
|
+
iframe.style.display = 'none';
|
|
944
|
+
html.appendChild(iframe);
|
|
945
|
+
// https://github.com/zloirock/core-js/issues/475
|
|
946
|
+
iframe.src = String(JS);
|
|
947
|
+
iframeDocument = iframe.contentWindow.document;
|
|
948
|
+
iframeDocument.open();
|
|
949
|
+
iframeDocument.write(scriptTag('document.F=Object'));
|
|
950
|
+
iframeDocument.close();
|
|
951
|
+
return iframeDocument.F;
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
// Check for document.domain and active x support
|
|
955
|
+
// No need to use active x approach when document.domain is not set
|
|
956
|
+
// see https://github.com/es-shims/es5-shim/issues/150
|
|
957
|
+
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
|
|
958
|
+
// avoid IE GC bug
|
|
959
|
+
var activeXDocument;
|
|
960
|
+
var NullProtoObject = function () {
|
|
961
|
+
try {
|
|
962
|
+
activeXDocument = new ActiveXObject('htmlfile');
|
|
963
|
+
} catch (error) { /* ignore */ }
|
|
964
|
+
NullProtoObject = typeof document != 'undefined'
|
|
965
|
+
? document.domain && activeXDocument
|
|
966
|
+
? NullProtoObjectViaActiveX(activeXDocument) // old IE
|
|
967
|
+
: NullProtoObjectViaIFrame()
|
|
968
|
+
: NullProtoObjectViaActiveX(activeXDocument); // WSH
|
|
969
|
+
var length = enumBugKeys.length;
|
|
970
|
+
while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
|
|
971
|
+
return NullProtoObject();
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
hiddenKeys$1[IE_PROTO] = true;
|
|
975
|
+
|
|
976
|
+
// `Object.create` method
|
|
977
|
+
// https://tc39.es/ecma262/#sec-object.create
|
|
978
|
+
var objectCreate = Object.create || function create(O, Properties) {
|
|
979
|
+
var result;
|
|
980
|
+
if (O !== null) {
|
|
981
|
+
EmptyConstructor[PROTOTYPE] = anObject(O);
|
|
982
|
+
result = new EmptyConstructor();
|
|
983
|
+
EmptyConstructor[PROTOTYPE] = null;
|
|
984
|
+
// add "__proto__" for Object.getPrototypeOf polyfill
|
|
985
|
+
result[IE_PROTO] = O;
|
|
986
|
+
} else result = NullProtoObject();
|
|
987
|
+
return Properties === undefined ? result : objectDefineProperties(result, Properties);
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
// babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
|
|
991
|
+
var $RegExp$1 = global$1.RegExp;
|
|
992
|
+
|
|
993
|
+
var regexpUnsupportedDotAll = fails(function () {
|
|
994
|
+
var re = $RegExp$1('.', 's');
|
|
995
|
+
return !(re.dotAll && re.exec('\n') && re.flags === 's');
|
|
996
|
+
});
|
|
997
|
+
|
|
998
|
+
// babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
|
|
999
|
+
var $RegExp = global$1.RegExp;
|
|
1000
|
+
|
|
1001
|
+
var regexpUnsupportedNcg = fails(function () {
|
|
1002
|
+
var re = $RegExp('(?<a>b)', 'g');
|
|
1003
|
+
return re.exec('b').groups.a !== 'b' ||
|
|
1004
|
+
'b'.replace(re, '$<a>c') !== 'bc';
|
|
1005
|
+
});
|
|
1006
|
+
|
|
1007
|
+
/* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
|
|
1008
|
+
/* eslint-disable regexp/no-useless-quantifier -- testing */
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
var getInternalState = internalState.get;
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
var nativeReplace = shared('native-string-replace', String.prototype.replace);
|
|
1021
|
+
var nativeExec = RegExp.prototype.exec;
|
|
1022
|
+
var patchedExec = nativeExec;
|
|
1023
|
+
var charAt$3 = functionUncurryThis(''.charAt);
|
|
1024
|
+
var indexOf = functionUncurryThis(''.indexOf);
|
|
1025
|
+
var replace$2 = functionUncurryThis(''.replace);
|
|
1026
|
+
var stringSlice$4 = functionUncurryThis(''.slice);
|
|
1027
|
+
|
|
1028
|
+
var UPDATES_LAST_INDEX_WRONG = (function () {
|
|
1029
|
+
var re1 = /a/;
|
|
1030
|
+
var re2 = /b*/g;
|
|
1031
|
+
functionCall(nativeExec, re1, 'a');
|
|
1032
|
+
functionCall(nativeExec, re2, 'a');
|
|
1033
|
+
return re1.lastIndex !== 0 || re2.lastIndex !== 0;
|
|
1034
|
+
})();
|
|
1035
|
+
|
|
1036
|
+
var UNSUPPORTED_Y$1 = regexpStickyHelpers.BROKEN_CARET;
|
|
1037
|
+
|
|
1038
|
+
// nonparticipating capturing group, copied from es5-shim's String#split patch.
|
|
1039
|
+
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
|
|
1040
|
+
|
|
1041
|
+
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || regexpUnsupportedDotAll || regexpUnsupportedNcg;
|
|
1042
|
+
|
|
1043
|
+
if (PATCH) {
|
|
1044
|
+
patchedExec = function exec(string) {
|
|
1045
|
+
var re = this;
|
|
1046
|
+
var state = getInternalState(re);
|
|
1047
|
+
var str = toString(string);
|
|
1048
|
+
var raw = state.raw;
|
|
1049
|
+
var result, reCopy, lastIndex, match, i, object, group;
|
|
1050
|
+
|
|
1051
|
+
if (raw) {
|
|
1052
|
+
raw.lastIndex = re.lastIndex;
|
|
1053
|
+
result = functionCall(patchedExec, raw, str);
|
|
1054
|
+
re.lastIndex = raw.lastIndex;
|
|
1055
|
+
return result;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
var groups = state.groups;
|
|
1059
|
+
var sticky = UNSUPPORTED_Y$1 && re.sticky;
|
|
1060
|
+
var flags = functionCall(regexpFlags, re);
|
|
1061
|
+
var source = re.source;
|
|
1062
|
+
var charsAdded = 0;
|
|
1063
|
+
var strCopy = str;
|
|
1064
|
+
|
|
1065
|
+
if (sticky) {
|
|
1066
|
+
flags = replace$2(flags, 'y', '');
|
|
1067
|
+
if (indexOf(flags, 'g') === -1) {
|
|
1068
|
+
flags += 'g';
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
strCopy = stringSlice$4(str, re.lastIndex);
|
|
1072
|
+
// Support anchored sticky behavior.
|
|
1073
|
+
if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$3(str, re.lastIndex - 1) !== '\n')) {
|
|
1074
|
+
source = '(?: ' + source + ')';
|
|
1075
|
+
strCopy = ' ' + strCopy;
|
|
1076
|
+
charsAdded++;
|
|
1077
|
+
}
|
|
1078
|
+
// ^(? + rx + ) is needed, in combination with some str slicing, to
|
|
1079
|
+
// simulate the 'y' flag.
|
|
1080
|
+
reCopy = new RegExp('^(?:' + source + ')', flags);
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
if (NPCG_INCLUDED) {
|
|
1084
|
+
reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
|
|
1085
|
+
}
|
|
1086
|
+
if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
|
|
1087
|
+
|
|
1088
|
+
match = functionCall(nativeExec, sticky ? reCopy : re, strCopy);
|
|
1089
|
+
|
|
1090
|
+
if (sticky) {
|
|
1091
|
+
if (match) {
|
|
1092
|
+
match.input = stringSlice$4(match.input, charsAdded);
|
|
1093
|
+
match[0] = stringSlice$4(match[0], charsAdded);
|
|
1094
|
+
match.index = re.lastIndex;
|
|
1095
|
+
re.lastIndex += match[0].length;
|
|
1096
|
+
} else re.lastIndex = 0;
|
|
1097
|
+
} else if (UPDATES_LAST_INDEX_WRONG && match) {
|
|
1098
|
+
re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
|
|
1099
|
+
}
|
|
1100
|
+
if (NPCG_INCLUDED && match && match.length > 1) {
|
|
1101
|
+
// Fix browsers whose `exec` methods don't consistently return `undefined`
|
|
1102
|
+
// for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
|
|
1103
|
+
functionCall(nativeReplace, match[0], reCopy, function () {
|
|
1104
|
+
for (i = 1; i < arguments.length - 2; i++) {
|
|
1105
|
+
if (arguments[i] === undefined) match[i] = undefined;
|
|
1106
|
+
}
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
if (match && groups) {
|
|
1111
|
+
match.groups = object = objectCreate(null);
|
|
1112
|
+
for (i = 0; i < groups.length; i++) {
|
|
1113
|
+
group = groups[i];
|
|
1114
|
+
object[group[0]] = match[group[1]];
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
return match;
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
var regexpExec = patchedExec;
|
|
1123
|
+
|
|
1124
|
+
// `RegExp.prototype.exec` method
|
|
1125
|
+
// https://tc39.es/ecma262/#sec-regexp.prototype.exec
|
|
1126
|
+
_export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, {
|
|
1127
|
+
exec: regexpExec
|
|
1128
|
+
});
|
|
1129
|
+
|
|
1130
|
+
// `IsArray` abstract operation
|
|
1131
|
+
// https://tc39.es/ecma262/#sec-isarray
|
|
1132
|
+
// eslint-disable-next-line es/no-array-isarray -- safe
|
|
1133
|
+
var isArray = Array.isArray || function isArray(argument) {
|
|
1134
|
+
return classofRaw(argument) == 'Array';
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
var noop = function () { /* empty */ };
|
|
1138
|
+
var empty = [];
|
|
1139
|
+
var construct = getBuiltIn('Reflect', 'construct');
|
|
1140
|
+
var constructorRegExp = /^\s*(?:class|function)\b/;
|
|
1141
|
+
var exec$1 = functionUncurryThis(constructorRegExp.exec);
|
|
1142
|
+
var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
|
|
1143
|
+
|
|
1144
|
+
var isConstructorModern = function (argument) {
|
|
1145
|
+
if (!isCallable(argument)) return false;
|
|
1146
|
+
try {
|
|
1147
|
+
construct(noop, empty, argument);
|
|
1148
|
+
return true;
|
|
1149
|
+
} catch (error) {
|
|
1150
|
+
return false;
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
|
|
1154
|
+
var isConstructorLegacy = function (argument) {
|
|
1155
|
+
if (!isCallable(argument)) return false;
|
|
1156
|
+
switch (classof(argument)) {
|
|
1157
|
+
case 'AsyncFunction':
|
|
1158
|
+
case 'GeneratorFunction':
|
|
1159
|
+
case 'AsyncGeneratorFunction': return false;
|
|
1160
|
+
// we can't check .prototype since constructors produced by .bind haven't it
|
|
1161
|
+
} return INCORRECT_TO_STRING || !!exec$1(constructorRegExp, inspectSource(argument));
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1164
|
+
// `IsConstructor` abstract operation
|
|
1165
|
+
// https://tc39.es/ecma262/#sec-isconstructor
|
|
1166
|
+
var isConstructor = !construct || fails(function () {
|
|
1167
|
+
var called;
|
|
1168
|
+
return isConstructorModern(isConstructorModern.call)
|
|
1169
|
+
|| !isConstructorModern(Object)
|
|
1170
|
+
|| !isConstructorModern(function () { called = true; })
|
|
1171
|
+
|| called;
|
|
1172
|
+
}) ? isConstructorLegacy : isConstructorModern;
|
|
1173
|
+
|
|
1174
|
+
var createProperty = function (object, key, value) {
|
|
1175
|
+
var propertyKey = toPropertyKey(key);
|
|
1176
|
+
if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
|
|
1177
|
+
else object[propertyKey] = value;
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
var SPECIES$4 = wellKnownSymbol('species');
|
|
1181
|
+
|
|
1182
|
+
var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
|
|
1183
|
+
// We can't use this feature detection in V8 since it causes
|
|
1184
|
+
// deoptimization and serious performance degradation
|
|
1185
|
+
// https://github.com/zloirock/core-js/issues/677
|
|
1186
|
+
return engineV8Version >= 51 || !fails(function () {
|
|
1187
|
+
var array = [];
|
|
1188
|
+
var constructor = array.constructor = {};
|
|
1189
|
+
constructor[SPECIES$4] = function () {
|
|
1190
|
+
return { foo: 1 };
|
|
1191
|
+
};
|
|
1192
|
+
return array[METHOD_NAME](Boolean).foo !== 1;
|
|
1193
|
+
});
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
var arraySlice = functionUncurryThis([].slice);
|
|
1197
|
+
|
|
1198
|
+
var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport('slice');
|
|
1199
|
+
|
|
1200
|
+
var SPECIES$3 = wellKnownSymbol('species');
|
|
1201
|
+
var Array$3 = global$1.Array;
|
|
1202
|
+
var max$2 = Math.max;
|
|
1203
|
+
|
|
1204
|
+
// `Array.prototype.slice` method
|
|
1205
|
+
// https://tc39.es/ecma262/#sec-array.prototype.slice
|
|
1206
|
+
// fallback for not array-like ES3 strings and DOM objects
|
|
1207
|
+
_export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$2 }, {
|
|
1208
|
+
slice: function slice(start, end) {
|
|
1209
|
+
var O = toIndexedObject(this);
|
|
1210
|
+
var length = lengthOfArrayLike(O);
|
|
1211
|
+
var k = toAbsoluteIndex(start, length);
|
|
1212
|
+
var fin = toAbsoluteIndex(end === undefined ? length : end, length);
|
|
1213
|
+
// inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
|
|
1214
|
+
var Constructor, result, n;
|
|
1215
|
+
if (isArray(O)) {
|
|
1216
|
+
Constructor = O.constructor;
|
|
1217
|
+
// cross-realm fallback
|
|
1218
|
+
if (isConstructor(Constructor) && (Constructor === Array$3 || isArray(Constructor.prototype))) {
|
|
1219
|
+
Constructor = undefined;
|
|
1220
|
+
} else if (isObject(Constructor)) {
|
|
1221
|
+
Constructor = Constructor[SPECIES$3];
|
|
1222
|
+
if (Constructor === null) Constructor = undefined;
|
|
1223
|
+
}
|
|
1224
|
+
if (Constructor === Array$3 || Constructor === undefined) {
|
|
1225
|
+
return arraySlice(O, k, fin);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
result = new (Constructor === undefined ? Array$3 : Constructor)(max$2(fin - k, 0));
|
|
1229
|
+
for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
|
|
1230
|
+
result.length = n;
|
|
1231
|
+
return result;
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
|
|
1235
|
+
/******************************************************************************
|
|
1236
|
+
Copyright (c) Microsoft Corporation.
|
|
1237
|
+
|
|
1238
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1239
|
+
purpose with or without fee is hereby granted.
|
|
1240
|
+
|
|
1241
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1242
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1243
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1244
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1245
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1246
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1247
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1248
|
+
***************************************************************************** */
|
|
1249
|
+
|
|
1250
|
+
var __assign = function() {
|
|
1251
|
+
__assign = Object.assign || function __assign(t) {
|
|
1252
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1253
|
+
s = arguments[i];
|
|
1254
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1255
|
+
}
|
|
1256
|
+
return t;
|
|
1257
|
+
};
|
|
1258
|
+
return __assign.apply(this, arguments);
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
function __values(o) {
|
|
1262
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
1263
|
+
if (m) return m.call(o);
|
|
1264
|
+
if (o && typeof o.length === "number") return {
|
|
1265
|
+
next: function () {
|
|
1266
|
+
if (o && i >= o.length) o = void 0;
|
|
1267
|
+
return { value: o && o[i++], done: !o };
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
function __read(o, n) {
|
|
1274
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1275
|
+
if (!m) return o;
|
|
1276
|
+
var i = m.call(o), r, ar = [], e;
|
|
1277
|
+
try {
|
|
1278
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1279
|
+
}
|
|
1280
|
+
catch (error) { e = { error: error }; }
|
|
1281
|
+
finally {
|
|
1282
|
+
try {
|
|
1283
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1284
|
+
}
|
|
1285
|
+
finally { if (e) throw e.error; }
|
|
1286
|
+
}
|
|
1287
|
+
return ar;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
function __spreadArray(to, from, pack) {
|
|
1291
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1292
|
+
if (ar || !(i in from)) {
|
|
1293
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1294
|
+
ar[i] = from[i];
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1301
|
+
var e = new Error(message);
|
|
1302
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1303
|
+
};
|
|
1304
|
+
|
|
1305
|
+
function deleteHandler(newEditor) {
|
|
1306
|
+
var selection = newEditor.selection;
|
|
1307
|
+
if (selection == null) return false;
|
|
1308
|
+
var _a = __read(Editor.nodes(newEditor, {
|
|
1309
|
+
match: function match(n) {
|
|
1310
|
+
return DomEditor.checkNodeType(n, 'table-cell');
|
|
1311
|
+
}
|
|
1312
|
+
}), 1),
|
|
1313
|
+
cellNodeEntry = _a[0];
|
|
1314
|
+
if (cellNodeEntry) {
|
|
1315
|
+
var _b = __read(cellNodeEntry, 2),
|
|
1316
|
+
cellPath = _b[1];
|
|
1317
|
+
var start = Editor.start(newEditor, cellPath);
|
|
1318
|
+
if (Point.equals(selection.anchor, start)) {
|
|
1319
|
+
return true;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
return false;
|
|
1323
|
+
}
|
|
1324
|
+
function isTableLocation(editor, location) {
|
|
1325
|
+
var e_1, _a;
|
|
1326
|
+
var tables = Editor.nodes(editor, {
|
|
1327
|
+
at: location,
|
|
1328
|
+
match: function match(n) {
|
|
1329
|
+
var type = DomEditor.getNodeType(n);
|
|
1330
|
+
return type === 'table';
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
var hasTable = false;
|
|
1334
|
+
try {
|
|
1335
|
+
for (var tables_1 = __values(tables), tables_1_1 = tables_1.next(); !tables_1_1.done; tables_1_1 = tables_1.next()) {
|
|
1336
|
+
var table = tables_1_1.value;
|
|
1337
|
+
hasTable = true;
|
|
1338
|
+
}
|
|
1339
|
+
} catch (e_1_1) {
|
|
1340
|
+
e_1 = {
|
|
1341
|
+
error: e_1_1
|
|
1342
|
+
};
|
|
1343
|
+
} finally {
|
|
1344
|
+
try {
|
|
1345
|
+
if (tables_1_1 && !tables_1_1.done && (_a = tables_1.return)) _a.call(tables_1);
|
|
1346
|
+
} finally {
|
|
1347
|
+
if (e_1) throw e_1.error;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
return hasTable;
|
|
1351
|
+
}
|
|
1352
|
+
function withTable(editor) {
|
|
1353
|
+
var insertBreak = editor.insertBreak,
|
|
1354
|
+
deleteBackward = editor.deleteBackward,
|
|
1355
|
+
deleteForward = editor.deleteForward,
|
|
1356
|
+
normalizeNode = editor.normalizeNode,
|
|
1357
|
+
insertData = editor.insertData,
|
|
1358
|
+
handleTab = editor.handleTab,
|
|
1359
|
+
selectAll = editor.selectAll;
|
|
1360
|
+
var newEditor = editor;
|
|
1361
|
+
newEditor.insertBreak = function () {
|
|
1362
|
+
var selectedNode = DomEditor.getSelectedNodeByType(newEditor, 'table');
|
|
1363
|
+
if (selectedNode != null) {
|
|
1364
|
+
newEditor.insertText('\n');
|
|
1365
|
+
return;
|
|
1366
|
+
}
|
|
1367
|
+
insertBreak();
|
|
1368
|
+
};
|
|
1369
|
+
newEditor.deleteBackward = function (unit) {
|
|
1370
|
+
var res = deleteHandler(newEditor);
|
|
1371
|
+
if (res) return;
|
|
1372
|
+
var selection = newEditor.selection;
|
|
1373
|
+
if (selection) {
|
|
1374
|
+
var before = Editor.before(newEditor, selection);
|
|
1375
|
+
if (before) {
|
|
1376
|
+
var isTableOnBeforeLocation = isTableLocation(newEditor, before);
|
|
1377
|
+
var isTableOnCurSelection = isTableLocation(newEditor, selection);
|
|
1378
|
+
if (isTableOnBeforeLocation && !isTableOnCurSelection) {
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
deleteBackward(unit);
|
|
1384
|
+
};
|
|
1385
|
+
newEditor.handleTab = function () {
|
|
1386
|
+
var _a;
|
|
1387
|
+
var selectedNode = DomEditor.getSelectedNodeByType(newEditor, 'table');
|
|
1388
|
+
if (selectedNode) {
|
|
1389
|
+
var above = Editor.above(editor);
|
|
1390
|
+
if (DomEditor.checkNodeType(above[0], 'table-cell')) {
|
|
1391
|
+
Transforms.select(editor, above[1]);
|
|
1392
|
+
}
|
|
1393
|
+
var next = Editor.next(editor);
|
|
1394
|
+
if (next) {
|
|
1395
|
+
if (next[0] && next[0].text) {
|
|
1396
|
+
next = (_a = Editor.above(editor, {
|
|
1397
|
+
at: next[1]
|
|
1398
|
+
})) !== null && _a !== void 0 ? _a : next;
|
|
1399
|
+
}
|
|
1400
|
+
Transforms.select(editor, next[1]);
|
|
1401
|
+
} else {
|
|
1402
|
+
var topLevelNodes = newEditor.children || [];
|
|
1403
|
+
var topLevelNodesLength = topLevelNodes.length;
|
|
1404
|
+
if (DomEditor.checkNodeType(topLevelNodes[topLevelNodesLength - 1], 'table')) {
|
|
1405
|
+
var p = DomEditor.genEmptyParagraph();
|
|
1406
|
+
Transforms.insertNodes(newEditor, p, {
|
|
1407
|
+
at: [topLevelNodesLength]
|
|
1408
|
+
});
|
|
1409
|
+
newEditor.handleTab();
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
handleTab();
|
|
1415
|
+
};
|
|
1416
|
+
newEditor.deleteForward = function (unit) {
|
|
1417
|
+
var res = deleteHandler(newEditor);
|
|
1418
|
+
if (res) return;
|
|
1419
|
+
deleteForward(unit);
|
|
1420
|
+
};
|
|
1421
|
+
newEditor.normalizeNode = function (_a) {
|
|
1422
|
+
var _b = __read(_a, 2),
|
|
1423
|
+
node = _b[0],
|
|
1424
|
+
path = _b[1];
|
|
1425
|
+
var type = DomEditor.getNodeType(node);
|
|
1426
|
+
if (type !== 'table') {
|
|
1427
|
+
return normalizeNode([node, path]);
|
|
1428
|
+
}
|
|
1429
|
+
var isLast = DomEditor.isLastNode(newEditor, node);
|
|
1430
|
+
if (isLast) {
|
|
1431
|
+
var p = DomEditor.genEmptyParagraph();
|
|
1432
|
+
Transforms.insertNodes(newEditor, p, {
|
|
1433
|
+
at: [path[0] + 1]
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
newEditor.insertData = function (data) {
|
|
1438
|
+
var tableNode = DomEditor.getSelectedNodeByType(newEditor, 'table');
|
|
1439
|
+
if (tableNode == null) {
|
|
1440
|
+
insertData(data);
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
var text = data.getData('text/plain');
|
|
1444
|
+
if (text === '\n' || /<img[^>]+>/.test(data.getData('text/html'))) {
|
|
1445
|
+
insertData(data);
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
Editor.insertText(newEditor, text);
|
|
1449
|
+
};
|
|
1450
|
+
newEditor.selectAll = function () {
|
|
1451
|
+
var selection = newEditor.selection;
|
|
1452
|
+
if (selection == null) {
|
|
1453
|
+
selectAll();
|
|
1454
|
+
return;
|
|
1455
|
+
}
|
|
1456
|
+
var cell = DomEditor.getSelectedNodeByType(newEditor, 'table-cell');
|
|
1457
|
+
if (cell == null) {
|
|
1458
|
+
selectAll();
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
var anchor = selection.anchor,
|
|
1462
|
+
focus = selection.focus;
|
|
1463
|
+
if (!Path.equals(anchor.path.slice(0, 3), focus.path.slice(0, 3))) {
|
|
1464
|
+
selectAll();
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
var text = Node.string(cell);
|
|
1468
|
+
var textLength = text.length;
|
|
1469
|
+
if (textLength === 0) {
|
|
1470
|
+
selectAll();
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
var path = DomEditor.findPath(newEditor, cell);
|
|
1474
|
+
var start = Editor.start(newEditor, path);
|
|
1475
|
+
var end = Editor.end(newEditor, path);
|
|
1476
|
+
var newSelection = {
|
|
1477
|
+
anchor: start,
|
|
1478
|
+
focus: end
|
|
1479
|
+
};
|
|
1480
|
+
newEditor.select(newSelection);
|
|
1481
|
+
};
|
|
1482
|
+
return newEditor;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
var arrayMethodIsStrict = function (METHOD_NAME, argument) {
|
|
1486
|
+
var method = [][METHOD_NAME];
|
|
1487
|
+
return !!method && fails(function () {
|
|
1488
|
+
// eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
|
|
1489
|
+
method.call(null, argument || function () { throw 1; }, 1);
|
|
1490
|
+
});
|
|
1491
|
+
};
|
|
1492
|
+
|
|
1493
|
+
var un$Join = functionUncurryThis([].join);
|
|
1494
|
+
|
|
1495
|
+
var ES3_STRINGS = indexedObject != Object;
|
|
1496
|
+
var STRICT_METHOD$1 = arrayMethodIsStrict('join', ',');
|
|
1497
|
+
|
|
1498
|
+
// `Array.prototype.join` method
|
|
1499
|
+
// https://tc39.es/ecma262/#sec-array.prototype.join
|
|
1500
|
+
_export({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD$1 }, {
|
|
1501
|
+
join: function join(separator) {
|
|
1502
|
+
return un$Join(toIndexedObject(this), separator === undefined ? ',' : separator);
|
|
1503
|
+
}
|
|
1504
|
+
});
|
|
1505
|
+
|
|
1506
|
+
var bind$1 = functionUncurryThis(functionUncurryThis.bind);
|
|
1507
|
+
|
|
1508
|
+
// optional / simple context binding
|
|
1509
|
+
var functionBindContext = function (fn, that) {
|
|
1510
|
+
aCallable(fn);
|
|
1511
|
+
return that === undefined ? fn : bind$1 ? bind$1(fn, that) : function (/* ...args */) {
|
|
1512
|
+
return fn.apply(that, arguments);
|
|
1513
|
+
};
|
|
1514
|
+
};
|
|
1515
|
+
|
|
1516
|
+
var SPECIES$2 = wellKnownSymbol('species');
|
|
1517
|
+
var Array$2 = global$1.Array;
|
|
1518
|
+
|
|
1519
|
+
// a part of `ArraySpeciesCreate` abstract operation
|
|
1520
|
+
// https://tc39.es/ecma262/#sec-arrayspeciescreate
|
|
1521
|
+
var arraySpeciesConstructor = function (originalArray) {
|
|
1522
|
+
var C;
|
|
1523
|
+
if (isArray(originalArray)) {
|
|
1524
|
+
C = originalArray.constructor;
|
|
1525
|
+
// cross-realm fallback
|
|
1526
|
+
if (isConstructor(C) && (C === Array$2 || isArray(C.prototype))) C = undefined;
|
|
1527
|
+
else if (isObject(C)) {
|
|
1528
|
+
C = C[SPECIES$2];
|
|
1529
|
+
if (C === null) C = undefined;
|
|
1530
|
+
}
|
|
1531
|
+
} return C === undefined ? Array$2 : C;
|
|
1532
|
+
};
|
|
1533
|
+
|
|
1534
|
+
// `ArraySpeciesCreate` abstract operation
|
|
1535
|
+
// https://tc39.es/ecma262/#sec-arrayspeciescreate
|
|
1536
|
+
var arraySpeciesCreate = function (originalArray, length) {
|
|
1537
|
+
return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
|
|
1538
|
+
};
|
|
1539
|
+
|
|
1540
|
+
var push$2 = functionUncurryThis([].push);
|
|
1541
|
+
|
|
1542
|
+
// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
|
|
1543
|
+
var createMethod$2 = function (TYPE) {
|
|
1544
|
+
var IS_MAP = TYPE == 1;
|
|
1545
|
+
var IS_FILTER = TYPE == 2;
|
|
1546
|
+
var IS_SOME = TYPE == 3;
|
|
1547
|
+
var IS_EVERY = TYPE == 4;
|
|
1548
|
+
var IS_FIND_INDEX = TYPE == 6;
|
|
1549
|
+
var IS_FILTER_REJECT = TYPE == 7;
|
|
1550
|
+
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
|
|
1551
|
+
return function ($this, callbackfn, that, specificCreate) {
|
|
1552
|
+
var O = toObject($this);
|
|
1553
|
+
var self = indexedObject(O);
|
|
1554
|
+
var boundFunction = functionBindContext(callbackfn, that);
|
|
1555
|
+
var length = lengthOfArrayLike(self);
|
|
1556
|
+
var index = 0;
|
|
1557
|
+
var create = specificCreate || arraySpeciesCreate;
|
|
1558
|
+
var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
|
|
1559
|
+
var value, result;
|
|
1560
|
+
for (;length > index; index++) if (NO_HOLES || index in self) {
|
|
1561
|
+
value = self[index];
|
|
1562
|
+
result = boundFunction(value, index, O);
|
|
1563
|
+
if (TYPE) {
|
|
1564
|
+
if (IS_MAP) target[index] = result; // map
|
|
1565
|
+
else if (result) switch (TYPE) {
|
|
1566
|
+
case 3: return true; // some
|
|
1567
|
+
case 5: return value; // find
|
|
1568
|
+
case 6: return index; // findIndex
|
|
1569
|
+
case 2: push$2(target, value); // filter
|
|
1570
|
+
} else switch (TYPE) {
|
|
1571
|
+
case 4: return false; // every
|
|
1572
|
+
case 7: push$2(target, value); // filterReject
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
|
|
1577
|
+
};
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
var arrayIteration = {
|
|
1581
|
+
// `Array.prototype.forEach` method
|
|
1582
|
+
// https://tc39.es/ecma262/#sec-array.prototype.foreach
|
|
1583
|
+
forEach: createMethod$2(0),
|
|
1584
|
+
// `Array.prototype.map` method
|
|
1585
|
+
// https://tc39.es/ecma262/#sec-array.prototype.map
|
|
1586
|
+
map: createMethod$2(1),
|
|
1587
|
+
// `Array.prototype.filter` method
|
|
1588
|
+
// https://tc39.es/ecma262/#sec-array.prototype.filter
|
|
1589
|
+
filter: createMethod$2(2),
|
|
1590
|
+
// `Array.prototype.some` method
|
|
1591
|
+
// https://tc39.es/ecma262/#sec-array.prototype.some
|
|
1592
|
+
some: createMethod$2(3),
|
|
1593
|
+
// `Array.prototype.every` method
|
|
1594
|
+
// https://tc39.es/ecma262/#sec-array.prototype.every
|
|
1595
|
+
every: createMethod$2(4),
|
|
1596
|
+
// `Array.prototype.find` method
|
|
1597
|
+
// https://tc39.es/ecma262/#sec-array.prototype.find
|
|
1598
|
+
find: createMethod$2(5),
|
|
1599
|
+
// `Array.prototype.findIndex` method
|
|
1600
|
+
// https://tc39.es/ecma262/#sec-array.prototype.findIndex
|
|
1601
|
+
findIndex: createMethod$2(6),
|
|
1602
|
+
// `Array.prototype.filterReject` method
|
|
1603
|
+
// https://github.com/tc39/proposal-array-filtering
|
|
1604
|
+
filterReject: createMethod$2(7)
|
|
1605
|
+
};
|
|
1606
|
+
|
|
1607
|
+
var $filter = arrayIteration.filter;
|
|
1608
|
+
|
|
1609
|
+
|
|
1610
|
+
var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('filter');
|
|
1611
|
+
|
|
1612
|
+
// `Array.prototype.filter` method
|
|
1613
|
+
// https://tc39.es/ecma262/#sec-array.prototype.filter
|
|
1614
|
+
// with adding support of @@species
|
|
1615
|
+
_export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 }, {
|
|
1616
|
+
filter: function filter(callbackfn /* , thisArg */) {
|
|
1617
|
+
return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
|
|
1621
|
+
// `Object.prototype.toString` method implementation
|
|
1622
|
+
// https://tc39.es/ecma262/#sec-object.prototype.tostring
|
|
1623
|
+
var objectToString = toStringTagSupport ? {}.toString : function toString() {
|
|
1624
|
+
return '[object ' + classof(this) + ']';
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1627
|
+
// `Object.prototype.toString` method
|
|
1628
|
+
// https://tc39.es/ecma262/#sec-object.prototype.tostring
|
|
1629
|
+
if (!toStringTagSupport) {
|
|
1630
|
+
redefine(Object.prototype, 'toString', objectToString, { unsafe: true });
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
var $map = arrayIteration.map;
|
|
1634
|
+
|
|
1635
|
+
|
|
1636
|
+
var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');
|
|
1637
|
+
|
|
1638
|
+
// `Array.prototype.map` method
|
|
1639
|
+
// https://tc39.es/ecma262/#sec-array.prototype.map
|
|
1640
|
+
// with adding support of @@species
|
|
1641
|
+
_export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
|
|
1642
|
+
map: function map(callbackfn /* , thisArg */) {
|
|
1643
|
+
return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
1644
|
+
}
|
|
1645
|
+
});
|
|
1646
|
+
|
|
1647
|
+
function getFirstRowCells(tableNode) {
|
|
1648
|
+
var rows = tableNode.children || [];
|
|
1649
|
+
if (rows.length === 0) return [];
|
|
1650
|
+
var firstRow = rows[0] || {};
|
|
1651
|
+
var cells = firstRow.children || [];
|
|
1652
|
+
return cells;
|
|
1653
|
+
}
|
|
1654
|
+
function isTableWithHeader(tableNode) {
|
|
1655
|
+
var firstRowCells = getFirstRowCells(tableNode);
|
|
1656
|
+
return firstRowCells.every(function (cell) {
|
|
1657
|
+
return !!cell.isHeader;
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
function isCellInFirstRow(editor, cellNode) {
|
|
1661
|
+
var rowNode = DomEditor.getParentNode(editor, cellNode);
|
|
1662
|
+
if (rowNode == null) return false;
|
|
1663
|
+
var tableNode = DomEditor.getParentNode(editor, rowNode);
|
|
1664
|
+
if (tableNode == null) return false;
|
|
1665
|
+
var firstRowCells = getFirstRowCells(tableNode);
|
|
1666
|
+
return firstRowCells.some(function (c) {
|
|
1667
|
+
return c === cellNode;
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
var TABLE_SVG = '<svg viewBox="0 0 1024 1024"><path d="M0 64v896h1024V64H0z m384 576v-192h256v192h-256z m256 64v192h-256v-192h256z m0-512v192h-256V192h256zM320 192v192H64V192h256z m-256 256h256v192H64v-192z m640 0h256v192h-256v-192z m0-64V192h256v192h-256zM64 704h256v192H64v-192z m640 192v-192h256v192h-256z"></path></svg>';
|
|
1672
|
+
var TRASH_SVG = '<svg viewBox="0 0 1024 1024"><path d="M826.8032 356.5312c-19.328 0-36.3776 15.6928-36.3776 35.0464v524.2624c0 19.328-16 34.56-35.328 34.56H264.9344c-19.328 0-35.5072-15.3088-35.5072-34.56V390.0416c0-19.328-14.1568-35.0464-33.5104-35.0464s-33.5104 15.6928-33.5104 35.0464V915.712c0 57.9328 44.6208 108.288 102.528 108.288H755.2c57.9328 0 108.0832-50.4576 108.0832-108.288V391.4752c-0.1024-19.2512-17.1264-34.944-36.48-34.944z" p-id="9577"></path><path d="M437.1712 775.7568V390.6048c0-19.328-14.1568-35.0464-33.5104-35.0464s-33.5104 15.616-33.5104 35.0464v385.152c0 19.328 14.1568 35.0464 33.5104 35.0464s33.5104-15.7184 33.5104-35.0464zM649.7024 775.7568V390.6048c0-19.328-17.0496-35.0464-36.3776-35.0464s-36.3776 15.616-36.3776 35.0464v385.152c0 19.328 17.0496 35.0464 36.3776 35.0464s36.3776-15.7184 36.3776-35.0464zM965.0432 217.0368h-174.6176V145.5104c0-57.9328-47.2064-101.76-104.6528-101.76h-350.976c-57.8304 0-105.3952 43.8528-105.3952 101.76v71.5264H54.784c-19.4304 0-35.0464 14.1568-35.0464 33.5104 0 19.328 15.616 33.5104 35.0464 33.5104h910.3616c19.328 0 35.0464-14.1568 35.0464-33.5104 0-19.3536-15.6928-33.5104-35.1488-33.5104z m-247.3728 0H297.3952V145.5104c0-19.328 18.2016-34.7648 37.4272-34.7648h350.976c19.1488 0 31.872 15.1296 31.872 34.7648v71.5264z"></path></svg>';
|
|
1673
|
+
var ADD_ROW_SVG = '<svg viewBox="0 0 1048 1024"><path d="M707.7888 521.0112h-147.456v-147.456H488.2432v147.456h-147.456v68.8128h147.456v147.456h72.0896v-147.456h147.456zM0 917.504V0h1048.576v917.504H0zM327.68 65.536H65.536v196.608H327.68V65.536z m327.68 0H393.216v196.608h262.144V65.536z m327.68 0h-262.144v196.608h262.144V65.536z m0 258.8672H65.536v462.0288H983.04V324.4032z"></path></svg>';
|
|
1674
|
+
var DEL_ROW_SVG = '<svg viewBox="0 0 1048 1024"><path d="M907.6736 586.5472L747.1104 425.984l163.84-163.84-78.6432-78.6432-163.84 163.84L507.904 186.7776 429.2608 262.144l163.84 163.84-167.1168 167.1168 78.6432 78.6432 167.1168-167.1168 160.5632 160.5632 75.3664-78.6432zM0 917.504V0h1048.576v917.504H0z m983.04-327.68h-22.9376l-65.536-65.536H983.04V327.68h-91.7504l65.536-65.536h26.2144V65.536H65.536v196.608h317.8496l65.536 65.536H65.536v196.608h380.1088l-65.536 65.536H65.536v196.608H983.04v-196.608z"></path></svg>';
|
|
1675
|
+
var ADD_COL_SVG = '<svg viewBox="0 0 1048 1024"><path d="M327.68 193.3312v186.7776H140.9024v91.7504H327.68v186.7776h88.4736V471.8592h190.0544V380.1088H416.1536V193.3312zM0 917.504V0h1048.576v917.504H0zM655.36 65.536H65.536v720.896H655.36V65.536z m327.68 0h-262.144v196.608h262.144V65.536z m0 262.144h-262.144v196.608h262.144V327.68z m0 262.144h-262.144v196.608h262.144v-196.608z"></path></svg>';
|
|
1676
|
+
var DEL_COL_SVG = '<svg viewBox="0 0 1048 1024"><path d="M327.68 510.976L393.216 445.44v-13.1072L327.68 366.7968V510.976z m327.68-78.4384l65.536-65.536V507.904L655.36 442.368v-9.8304z m393.216 484.9664V0H0v917.504h1048.576z m-65.536-131.072h-262.144v-52.4288l-13.1072 13.1072-52.4288-52.4288v91.7504H393.216v-91.7504l-52.4288 52.4288-13.1072-13.1072v52.4288H65.536V65.536H327.68v121.2416l36.0448-36.0448 29.4912 29.4912V62.2592h262.144V180.224l49.152-49.152 16.384 16.384V62.2592h262.144V786.432z m-294.912-108.1344l-160.5632-160.5632-167.1168 167.1168-78.6432-78.6432 167.1168-167.1168L288.3584 278.528l78.6432-78.6432 160.5632 160.5632 163.84-163.84 78.6432 78.6432-163.84 163.84 160.5632 160.5632-78.6432 78.6432z"></path></svg>';
|
|
1677
|
+
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>';
|
|
1678
|
+
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>';
|
|
1679
|
+
|
|
1680
|
+
var InsertRow =
|
|
1681
|
+
function () {
|
|
1682
|
+
function InsertRow() {
|
|
1683
|
+
this.title = t('tableModule.insertRow');
|
|
1684
|
+
this.iconSvg = ADD_ROW_SVG;
|
|
1685
|
+
this.tag = 'button';
|
|
1686
|
+
}
|
|
1687
|
+
InsertRow.prototype.getValue = function (editor) {
|
|
1688
|
+
return '';
|
|
1689
|
+
};
|
|
1690
|
+
InsertRow.prototype.isActive = function (editor) {
|
|
1691
|
+
return false;
|
|
1692
|
+
};
|
|
1693
|
+
InsertRow.prototype.isDisabled = function (editor) {
|
|
1694
|
+
var selection = editor.selection;
|
|
1695
|
+
if (selection == null) return true;
|
|
1696
|
+
if (!Range.isCollapsed(selection)) return true;
|
|
1697
|
+
var tableNode = DomEditor.getSelectedNodeByType(editor, 'table');
|
|
1698
|
+
if (tableNode == null) {
|
|
1699
|
+
return true;
|
|
1700
|
+
}
|
|
1701
|
+
return false;
|
|
1702
|
+
};
|
|
1703
|
+
InsertRow.prototype.exec = function (editor, value) {
|
|
1704
|
+
if (this.isDisabled(editor)) return;
|
|
1705
|
+
var _a = __read(Editor.nodes(editor, {
|
|
1706
|
+
match: function match(n) {
|
|
1707
|
+
return DomEditor.checkNodeType(n, 'table-cell');
|
|
1708
|
+
},
|
|
1709
|
+
universal: true
|
|
1710
|
+
}), 1),
|
|
1711
|
+
cellEntry = _a[0];
|
|
1712
|
+
var _b = __read(cellEntry, 2),
|
|
1713
|
+
cellNode = _b[0],
|
|
1714
|
+
cellPath = _b[1];
|
|
1715
|
+
var rowNode = DomEditor.getParentNode(editor, cellNode);
|
|
1716
|
+
var cellsLength = (rowNode === null || rowNode === void 0 ? void 0 : rowNode.children.length) || 0;
|
|
1717
|
+
if (cellsLength === 0) return;
|
|
1718
|
+
var newRow = {
|
|
1719
|
+
type: 'table-row',
|
|
1720
|
+
children: []
|
|
1721
|
+
};
|
|
1722
|
+
for (var i = 0; i < cellsLength; i++) {
|
|
1723
|
+
var cell = {
|
|
1724
|
+
type: 'table-cell',
|
|
1725
|
+
children: [{
|
|
1726
|
+
text: ''
|
|
1727
|
+
}]
|
|
1728
|
+
};
|
|
1729
|
+
newRow.children.push(cell);
|
|
1730
|
+
}
|
|
1731
|
+
var rowPath = Path.parent(cellPath);
|
|
1732
|
+
var newRowPath = Path.next(rowPath);
|
|
1733
|
+
Transforms.insertNodes(editor, newRow, {
|
|
1734
|
+
at: newRowPath
|
|
1735
|
+
});
|
|
1736
|
+
};
|
|
1737
|
+
return InsertRow;
|
|
1738
|
+
}();
|
|
1739
|
+
|
|
1740
|
+
var DeleteRow =
|
|
1741
|
+
function () {
|
|
1742
|
+
function DeleteRow() {
|
|
1743
|
+
this.title = t('tableModule.deleteRow');
|
|
1744
|
+
this.iconSvg = DEL_ROW_SVG;
|
|
1745
|
+
this.tag = 'button';
|
|
1746
|
+
}
|
|
1747
|
+
DeleteRow.prototype.getValue = function (editor) {
|
|
1748
|
+
return '';
|
|
1749
|
+
};
|
|
1750
|
+
DeleteRow.prototype.isActive = function (editor) {
|
|
1751
|
+
return false;
|
|
1752
|
+
};
|
|
1753
|
+
DeleteRow.prototype.isDisabled = function (editor) {
|
|
1754
|
+
var selection = editor.selection;
|
|
1755
|
+
if (selection == null) return true;
|
|
1756
|
+
if (!Range.isCollapsed(selection)) return true;
|
|
1757
|
+
var rowNode = DomEditor.getSelectedNodeByType(editor, 'table-row');
|
|
1758
|
+
if (rowNode == null) {
|
|
1759
|
+
return true;
|
|
1760
|
+
}
|
|
1761
|
+
return false;
|
|
1762
|
+
};
|
|
1763
|
+
DeleteRow.prototype.exec = function (editor, value) {
|
|
1764
|
+
if (this.isDisabled(editor)) return;
|
|
1765
|
+
var _a = __read(Editor.nodes(editor, {
|
|
1766
|
+
match: function match(n) {
|
|
1767
|
+
return DomEditor.checkNodeType(n, 'table-row');
|
|
1768
|
+
},
|
|
1769
|
+
universal: true
|
|
1770
|
+
}), 1),
|
|
1771
|
+
rowEntry = _a[0];
|
|
1772
|
+
var _b = __read(rowEntry, 2),
|
|
1773
|
+
rowNode = _b[0],
|
|
1774
|
+
rowPath = _b[1];
|
|
1775
|
+
var tableNode = DomEditor.getParentNode(editor, rowNode);
|
|
1776
|
+
var rowsLength = (tableNode === null || tableNode === void 0 ? void 0 : tableNode.children.length) || 0;
|
|
1777
|
+
if (rowsLength <= 1) {
|
|
1778
|
+
Transforms.removeNodes(editor, {
|
|
1779
|
+
mode: 'highest'
|
|
1780
|
+
});
|
|
1781
|
+
return;
|
|
1782
|
+
}
|
|
1783
|
+
Transforms.removeNodes(editor, {
|
|
1784
|
+
at: rowPath
|
|
1785
|
+
});
|
|
1786
|
+
};
|
|
1787
|
+
return DeleteRow;
|
|
1788
|
+
}();
|
|
1789
|
+
|
|
1790
|
+
// iterable DOM collections
|
|
1791
|
+
// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
|
|
1792
|
+
var domIterables = {
|
|
1793
|
+
CSSRuleList: 0,
|
|
1794
|
+
CSSStyleDeclaration: 0,
|
|
1795
|
+
CSSValueList: 0,
|
|
1796
|
+
ClientRectList: 0,
|
|
1797
|
+
DOMRectList: 0,
|
|
1798
|
+
DOMStringList: 0,
|
|
1799
|
+
DOMTokenList: 1,
|
|
1800
|
+
DataTransferItemList: 0,
|
|
1801
|
+
FileList: 0,
|
|
1802
|
+
HTMLAllCollection: 0,
|
|
1803
|
+
HTMLCollection: 0,
|
|
1804
|
+
HTMLFormElement: 0,
|
|
1805
|
+
HTMLSelectElement: 0,
|
|
1806
|
+
MediaList: 0,
|
|
1807
|
+
MimeTypeArray: 0,
|
|
1808
|
+
NamedNodeMap: 0,
|
|
1809
|
+
NodeList: 1,
|
|
1810
|
+
PaintRequestList: 0,
|
|
1811
|
+
Plugin: 0,
|
|
1812
|
+
PluginArray: 0,
|
|
1813
|
+
SVGLengthList: 0,
|
|
1814
|
+
SVGNumberList: 0,
|
|
1815
|
+
SVGPathSegList: 0,
|
|
1816
|
+
SVGPointList: 0,
|
|
1817
|
+
SVGStringList: 0,
|
|
1818
|
+
SVGTransformList: 0,
|
|
1819
|
+
SourceBufferList: 0,
|
|
1820
|
+
StyleSheetList: 0,
|
|
1821
|
+
TextTrackCueList: 0,
|
|
1822
|
+
TextTrackList: 0,
|
|
1823
|
+
TouchList: 0
|
|
1824
|
+
};
|
|
1825
|
+
|
|
1826
|
+
// in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList`
|
|
1827
|
+
|
|
1828
|
+
|
|
1829
|
+
var classList = documentCreateElement('span').classList;
|
|
1830
|
+
var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype;
|
|
1831
|
+
|
|
1832
|
+
var domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype;
|
|
1833
|
+
|
|
1834
|
+
var $forEach = arrayIteration.forEach;
|
|
1835
|
+
|
|
1836
|
+
|
|
1837
|
+
var STRICT_METHOD = arrayMethodIsStrict('forEach');
|
|
1838
|
+
|
|
1839
|
+
// `Array.prototype.forEach` method implementation
|
|
1840
|
+
// https://tc39.es/ecma262/#sec-array.prototype.foreach
|
|
1841
|
+
var arrayForEach = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {
|
|
1842
|
+
return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
1843
|
+
// eslint-disable-next-line es/no-array-prototype-foreach -- safe
|
|
1844
|
+
} : [].forEach;
|
|
1845
|
+
|
|
1846
|
+
var handlePrototype = function (CollectionPrototype) {
|
|
1847
|
+
// some Chrome versions have non-configurable methods on DOMTokenList
|
|
1848
|
+
if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try {
|
|
1849
|
+
createNonEnumerableProperty(CollectionPrototype, 'forEach', arrayForEach);
|
|
1850
|
+
} catch (error) {
|
|
1851
|
+
CollectionPrototype.forEach = arrayForEach;
|
|
1852
|
+
}
|
|
1853
|
+
};
|
|
1854
|
+
|
|
1855
|
+
for (var COLLECTION_NAME in domIterables) {
|
|
1856
|
+
if (domIterables[COLLECTION_NAME]) {
|
|
1857
|
+
handlePrototype(global$1[COLLECTION_NAME] && global$1[COLLECTION_NAME].prototype);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
handlePrototype(domTokenListPrototype);
|
|
1862
|
+
|
|
1863
|
+
var InsertCol =
|
|
1864
|
+
function () {
|
|
1865
|
+
function InsertCol() {
|
|
1866
|
+
this.title = t('tableModule.insertCol');
|
|
1867
|
+
this.iconSvg = ADD_COL_SVG;
|
|
1868
|
+
this.tag = 'button';
|
|
1869
|
+
}
|
|
1870
|
+
InsertCol.prototype.getValue = function (editor) {
|
|
1871
|
+
return '';
|
|
1872
|
+
};
|
|
1873
|
+
InsertCol.prototype.isActive = function (editor) {
|
|
1874
|
+
return false;
|
|
1875
|
+
};
|
|
1876
|
+
InsertCol.prototype.isDisabled = function (editor) {
|
|
1877
|
+
var selection = editor.selection;
|
|
1878
|
+
if (selection == null) return true;
|
|
1879
|
+
if (!Range.isCollapsed(selection)) return true;
|
|
1880
|
+
var tableNode = DomEditor.getSelectedNodeByType(editor, 'table');
|
|
1881
|
+
if (tableNode == null) {
|
|
1882
|
+
return true;
|
|
1883
|
+
}
|
|
1884
|
+
return false;
|
|
1885
|
+
};
|
|
1886
|
+
InsertCol.prototype.exec = function (editor, value) {
|
|
1887
|
+
if (this.isDisabled(editor)) return;
|
|
1888
|
+
var _a = __read(Editor.nodes(editor, {
|
|
1889
|
+
match: function match(n) {
|
|
1890
|
+
return DomEditor.checkNodeType(n, 'table-cell');
|
|
1891
|
+
},
|
|
1892
|
+
universal: true
|
|
1893
|
+
}), 1),
|
|
1894
|
+
cellEntry = _a[0];
|
|
1895
|
+
var _b = __read(cellEntry, 2),
|
|
1896
|
+
selectedCellNode = _b[0],
|
|
1897
|
+
selectedCellPath = _b[1];
|
|
1898
|
+
var rowNode = DomEditor.getParentNode(editor, selectedCellNode);
|
|
1899
|
+
if (rowNode == null) return;
|
|
1900
|
+
var tableNode = DomEditor.getParentNode(editor, rowNode);
|
|
1901
|
+
if (tableNode == null) return;
|
|
1902
|
+
var rows = tableNode.children || [];
|
|
1903
|
+
rows.forEach(function (row, rowIndex) {
|
|
1904
|
+
if (!Element.isElement(row)) return;
|
|
1905
|
+
var cells = row.children || [];
|
|
1906
|
+
cells.forEach(function (cell) {
|
|
1907
|
+
var path = DomEditor.findPath(editor, cell);
|
|
1908
|
+
if (path.length === selectedCellPath.length && isEqual(path.slice(-1), selectedCellPath.slice(-1))
|
|
1909
|
+
) {
|
|
1910
|
+
var newCell = {
|
|
1911
|
+
type: 'table-cell',
|
|
1912
|
+
children: [{
|
|
1913
|
+
text: ''
|
|
1914
|
+
}]
|
|
1915
|
+
};
|
|
1916
|
+
if (rowIndex === 0 && isTableWithHeader(tableNode)) {
|
|
1917
|
+
newCell.isHeader = true;
|
|
1918
|
+
}
|
|
1919
|
+
Transforms.insertNodes(editor, newCell, {
|
|
1920
|
+
at: path
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
});
|
|
1924
|
+
});
|
|
1925
|
+
};
|
|
1926
|
+
return InsertCol;
|
|
1927
|
+
}();
|
|
1928
|
+
|
|
1929
|
+
var DeleteCol =
|
|
1930
|
+
function () {
|
|
1931
|
+
function DeleteCol() {
|
|
1932
|
+
this.title = t('tableModule.deleteCol');
|
|
1933
|
+
this.iconSvg = DEL_COL_SVG;
|
|
1934
|
+
this.tag = 'button';
|
|
1935
|
+
}
|
|
1936
|
+
DeleteCol.prototype.getValue = function (editor) {
|
|
1937
|
+
return '';
|
|
1938
|
+
};
|
|
1939
|
+
DeleteCol.prototype.isActive = function (editor) {
|
|
1940
|
+
return false;
|
|
1941
|
+
};
|
|
1942
|
+
DeleteCol.prototype.isDisabled = function (editor) {
|
|
1943
|
+
var selection = editor.selection;
|
|
1944
|
+
if (selection == null) return true;
|
|
1945
|
+
if (!Range.isCollapsed(selection)) return true;
|
|
1946
|
+
var cellNode = DomEditor.getSelectedNodeByType(editor, 'table-cell');
|
|
1947
|
+
if (cellNode == null) {
|
|
1948
|
+
return true;
|
|
1949
|
+
}
|
|
1950
|
+
return false;
|
|
1951
|
+
};
|
|
1952
|
+
DeleteCol.prototype.exec = function (editor, value) {
|
|
1953
|
+
if (this.isDisabled(editor)) return;
|
|
1954
|
+
var _a = __read(Editor.nodes(editor, {
|
|
1955
|
+
match: function match(n) {
|
|
1956
|
+
return DomEditor.checkNodeType(n, 'table-cell');
|
|
1957
|
+
},
|
|
1958
|
+
universal: true
|
|
1959
|
+
}), 1),
|
|
1960
|
+
cellEntry = _a[0];
|
|
1961
|
+
var _b = __read(cellEntry, 2),
|
|
1962
|
+
selectedCellNode = _b[0],
|
|
1963
|
+
selectedCellPath = _b[1];
|
|
1964
|
+
var rowNode = DomEditor.getParentNode(editor, selectedCellNode);
|
|
1965
|
+
var colLength = (rowNode === null || rowNode === void 0 ? void 0 : rowNode.children.length) || 0;
|
|
1966
|
+
if (!rowNode || colLength <= 1) {
|
|
1967
|
+
Transforms.removeNodes(editor, {
|
|
1968
|
+
mode: 'highest'
|
|
1969
|
+
});
|
|
1970
|
+
return;
|
|
1971
|
+
}
|
|
1972
|
+
var tableNode = DomEditor.getParentNode(editor, rowNode);
|
|
1973
|
+
if (tableNode == null) return;
|
|
1974
|
+
var rows = tableNode.children || [];
|
|
1975
|
+
rows.forEach(function (row) {
|
|
1976
|
+
if (!Element.isElement(row)) return;
|
|
1977
|
+
var cells = row.children || [];
|
|
1978
|
+
cells.forEach(function (cell) {
|
|
1979
|
+
var path = DomEditor.findPath(editor, cell);
|
|
1980
|
+
if (path.length === selectedCellPath.length && isEqual(path.slice(-1), selectedCellPath.slice(-1))
|
|
1981
|
+
) {
|
|
1982
|
+
Transforms.removeNodes(editor, {
|
|
1983
|
+
at: path
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
});
|
|
1988
|
+
};
|
|
1989
|
+
return DeleteCol;
|
|
1990
|
+
}();
|
|
1991
|
+
|
|
1992
|
+
var DeleteTable =
|
|
1993
|
+
function () {
|
|
1994
|
+
function DeleteTable() {
|
|
1995
|
+
this.title = t('tableModule.deleteTable');
|
|
1996
|
+
this.iconSvg = TRASH_SVG;
|
|
1997
|
+
this.tag = 'button';
|
|
1998
|
+
}
|
|
1999
|
+
DeleteTable.prototype.getValue = function (editor) {
|
|
2000
|
+
return '';
|
|
2001
|
+
};
|
|
2002
|
+
DeleteTable.prototype.isActive = function (editor) {
|
|
2003
|
+
return false;
|
|
2004
|
+
};
|
|
2005
|
+
DeleteTable.prototype.isDisabled = function (editor) {
|
|
2006
|
+
if (editor.selection == null) return true;
|
|
2007
|
+
var tableNode = DomEditor.getSelectedNodeByType(editor, 'table');
|
|
2008
|
+
if (tableNode == null) {
|
|
2009
|
+
return true;
|
|
2010
|
+
}
|
|
2011
|
+
return false;
|
|
2012
|
+
};
|
|
2013
|
+
DeleteTable.prototype.exec = function (editor, value) {
|
|
2014
|
+
if (this.isDisabled(editor)) return;
|
|
2015
|
+
Transforms.removeNodes(editor, {
|
|
2016
|
+
mode: 'highest'
|
|
2017
|
+
});
|
|
2018
|
+
};
|
|
2019
|
+
return DeleteTable;
|
|
2020
|
+
}();
|
|
2021
|
+
|
|
2022
|
+
var TableHeader =
|
|
2023
|
+
function () {
|
|
2024
|
+
function TableHeader() {
|
|
2025
|
+
this.title = t('tableModule.header');
|
|
2026
|
+
this.iconSvg = TABLE_HEADER_SVG;
|
|
2027
|
+
this.tag = 'button';
|
|
2028
|
+
}
|
|
2029
|
+
TableHeader.prototype.getValue = function (editor) {
|
|
2030
|
+
var tableNode = DomEditor.getSelectedNodeByType(editor, 'table');
|
|
2031
|
+
if (tableNode == null) return false;
|
|
2032
|
+
return isTableWithHeader(tableNode);
|
|
2033
|
+
};
|
|
2034
|
+
TableHeader.prototype.isActive = function (editor) {
|
|
2035
|
+
return !!this.getValue(editor);
|
|
2036
|
+
};
|
|
2037
|
+
TableHeader.prototype.isDisabled = function (editor) {
|
|
2038
|
+
var selection = editor.selection;
|
|
2039
|
+
if (selection == null) return true;
|
|
2040
|
+
if (!Range.isCollapsed(selection)) return true;
|
|
2041
|
+
var tableNode = DomEditor.getSelectedNodeByType(editor, 'table');
|
|
2042
|
+
if (tableNode == null) {
|
|
2043
|
+
return true;
|
|
2044
|
+
}
|
|
2045
|
+
return false;
|
|
2046
|
+
};
|
|
2047
|
+
TableHeader.prototype.exec = function (editor, value) {
|
|
2048
|
+
if (this.isDisabled(editor)) return;
|
|
2049
|
+
var newValue = value ? false : true;
|
|
2050
|
+
var tableNode = DomEditor.getSelectedNodeByType(editor, 'table');
|
|
2051
|
+
if (tableNode == null) return;
|
|
2052
|
+
var firstRowCells = getFirstRowCells(tableNode);
|
|
2053
|
+
firstRowCells.forEach(function (cell) {
|
|
2054
|
+
return Transforms.setNodes(editor, {
|
|
2055
|
+
isHeader: newValue
|
|
2056
|
+
}, {
|
|
2057
|
+
at: DomEditor.findPath(editor, cell)
|
|
2058
|
+
});
|
|
2059
|
+
});
|
|
2060
|
+
};
|
|
2061
|
+
return TableHeader;
|
|
2062
|
+
}();
|
|
2063
|
+
|
|
2064
|
+
var TableFullWidth =
|
|
2065
|
+
function () {
|
|
2066
|
+
function TableFullWidth() {
|
|
2067
|
+
this.title = t('tableModule.widthAuto');
|
|
2068
|
+
this.iconSvg = FULL_WIDTH_SVG;
|
|
2069
|
+
this.tag = 'button';
|
|
2070
|
+
}
|
|
2071
|
+
TableFullWidth.prototype.getValue = function (editor) {
|
|
2072
|
+
var tableNode = DomEditor.getSelectedNodeByType(editor, 'table');
|
|
2073
|
+
if (tableNode == null) return false;
|
|
2074
|
+
return tableNode.width === '100%';
|
|
2075
|
+
};
|
|
2076
|
+
TableFullWidth.prototype.isActive = function (editor) {
|
|
2077
|
+
return !!this.getValue(editor);
|
|
2078
|
+
};
|
|
2079
|
+
TableFullWidth.prototype.isDisabled = function (editor) {
|
|
2080
|
+
var selection = editor.selection;
|
|
2081
|
+
if (selection == null) return true;
|
|
2082
|
+
if (!Range.isCollapsed(selection)) return true;
|
|
2083
|
+
var tableNode = DomEditor.getSelectedNodeByType(editor, 'table');
|
|
2084
|
+
if (tableNode == null) {
|
|
2085
|
+
return true;
|
|
2086
|
+
}
|
|
2087
|
+
return false;
|
|
2088
|
+
};
|
|
2089
|
+
TableFullWidth.prototype.exec = function (editor, value) {
|
|
2090
|
+
if (this.isDisabled(editor)) return;
|
|
2091
|
+
var props = {
|
|
2092
|
+
width: value ? 'auto' : '100%'
|
|
2093
|
+
};
|
|
2094
|
+
Transforms.setNodes(editor, props, {
|
|
2095
|
+
mode: 'highest'
|
|
2096
|
+
});
|
|
2097
|
+
};
|
|
2098
|
+
return TableFullWidth;
|
|
2099
|
+
}();
|
|
2100
|
+
|
|
2101
|
+
var ICON_ENTER = '<svg viewBox="0 0 1255 1024"><path d="M1095.111111 731.477333h-625.777778V1024L0 658.318222 469.333333 292.408889v292.636444h625.777778V0h156.444445v731.477333z"></path></svg>';
|
|
2102
|
+
var ICON_CANCEL_ENTER = '<svg viewBox="0 0 1024 1024"><path d="M436 680H124v-56h312l-124-124 42-42 220 220-220 220-42-42 124-124z"></path><path d="M198 128l64-64 628 628-64 64z"></path></svg>';
|
|
2103
|
+
function makeBtn(action, title, iconSvg, opts) {
|
|
2104
|
+
if (opts === void 0) {
|
|
2105
|
+
opts = {};
|
|
2106
|
+
}
|
|
2107
|
+
var _a = opts.disabled,
|
|
2108
|
+
disabled = _a === void 0 ? false : _a,
|
|
2109
|
+
_b = opts.active,
|
|
2110
|
+
active = _b === void 0 ? false : _b;
|
|
2111
|
+
var cls = ['mdg-table-btn', disabled ? 'is-disabled' : '', active ? 'is-active' : ''].filter(Boolean).join(' ');
|
|
2112
|
+
return h('button', {
|
|
2113
|
+
attrs: __assign({
|
|
2114
|
+
type: 'button',
|
|
2115
|
+
class: cls,
|
|
2116
|
+
title: title,
|
|
2117
|
+
'data-table-action': action
|
|
2118
|
+
}, disabled ? {
|
|
2119
|
+
disabled: 'disabled'
|
|
2120
|
+
} : {}),
|
|
2121
|
+
props: {
|
|
2122
|
+
contentEditable: false,
|
|
2123
|
+
disabled: disabled
|
|
2124
|
+
},
|
|
2125
|
+
hook: {
|
|
2126
|
+
insert: function insert(vnode) {
|
|
2127
|
+
var el = vnode.elm;
|
|
2128
|
+
if (el) el.innerHTML = iconSvg;
|
|
2129
|
+
},
|
|
2130
|
+
postpatch: function postpatch(_o, vnode) {
|
|
2131
|
+
var el = vnode.elm;
|
|
2132
|
+
if (el && el.innerHTML !== iconSvg) el.innerHTML = iconSvg;
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
});
|
|
2136
|
+
}
|
|
2137
|
+
function getContentEditable(editor, tableElem) {
|
|
2138
|
+
if (editor.isDisabled()) return false;
|
|
2139
|
+
var selection = editor.selection;
|
|
2140
|
+
if (selection == null) return true;
|
|
2141
|
+
if (Range.isCollapsed(selection)) return true;
|
|
2142
|
+
var anchor = selection.anchor,
|
|
2143
|
+
focus = selection.focus;
|
|
2144
|
+
var tablePath = DomEditor.findPath(editor, tableElem);
|
|
2145
|
+
var tableStart = Editor.start(editor, tablePath);
|
|
2146
|
+
var tableEnd = Editor.end(editor, tablePath);
|
|
2147
|
+
var isAnchorInTable = Point.compare(anchor, tableEnd) <= 0 && Point.compare(anchor, tableStart) >= 0;
|
|
2148
|
+
var isFocusInTable = Point.compare(focus, tableEnd) <= 0 && Point.compare(focus, tableStart) >= 0;
|
|
2149
|
+
if (isAnchorInTable && isFocusInTable) {
|
|
2150
|
+
if (Path.equals(anchor.path.slice(0, 3), focus.path.slice(0, 3))) {
|
|
2151
|
+
return true;
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
return false;
|
|
2155
|
+
}
|
|
2156
|
+
function isTableHeaderOn(tableElem) {
|
|
2157
|
+
var _a, _b;
|
|
2158
|
+
var row = (_b = (_a = tableElem) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b[0];
|
|
2159
|
+
var cells = Array.isArray(row === null || row === void 0 ? void 0 : row.children) ? row.children : [];
|
|
2160
|
+
return cells.length > 0 && cells.every(function (c) {
|
|
2161
|
+
return !!(c === null || c === void 0 ? void 0 : c.isHeader);
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
function isTableFullWidthOn(tableElem) {
|
|
2165
|
+
var _a;
|
|
2166
|
+
return String(((_a = tableElem) === null || _a === void 0 ? void 0 : _a.width) || '') === '100%';
|
|
2167
|
+
}
|
|
2168
|
+
function ensureSelectionInTable(editor, tableElem) {
|
|
2169
|
+
try {
|
|
2170
|
+
var path = resolveElemPath(editor, tableElem);
|
|
2171
|
+
if (!(path === null || path === void 0 ? void 0 : path.length)) return false;
|
|
2172
|
+
var selected = DomEditor.getSelectedNodeByType(editor, 'table');
|
|
2173
|
+
if (selected) {
|
|
2174
|
+
try {
|
|
2175
|
+
var selPath = DomEditor.findPath(editor, selected);
|
|
2176
|
+
if ((selPath === null || selPath === void 0 ? void 0 : selPath[0]) === path[0]) return true;
|
|
2177
|
+
} catch (_) {
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
var cellStart = Editor.start(editor, __spreadArray(__spreadArray([], __read(path)), [0, 0]));
|
|
2181
|
+
editor.select(cellStart);
|
|
2182
|
+
return true;
|
|
2183
|
+
} catch (_) {
|
|
2184
|
+
return false;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
function runMenu(editor, MenuClass) {
|
|
2188
|
+
var menu = new MenuClass();
|
|
2189
|
+
if (typeof menu.isDisabled === 'function' && menu.isDisabled(editor)) return;
|
|
2190
|
+
menu.exec(editor, '');
|
|
2191
|
+
}
|
|
2192
|
+
function handleTableToolbarAction(editor, tableElem, action) {
|
|
2193
|
+
if (!editor || editor.isDestroyed || editor.isDisabled()) return;
|
|
2194
|
+
var path = resolveElemPath(editor, tableElem);
|
|
2195
|
+
if (!(path === null || path === void 0 ? void 0 : path.length)) return;
|
|
2196
|
+
if (action === 'enter') {
|
|
2197
|
+
insertEmptyLineAboveAtPath(editor, path);
|
|
2198
|
+
return;
|
|
2199
|
+
}
|
|
2200
|
+
if (action === 'cancel-enter') {
|
|
2201
|
+
removeEmptyLineAboveTopLevelBlock(editor, path);
|
|
2202
|
+
return;
|
|
2203
|
+
}
|
|
2204
|
+
if (!ensureSelectionInTable(editor, tableElem)) return;
|
|
2205
|
+
try {
|
|
2206
|
+
switch (action) {
|
|
2207
|
+
case 'header':
|
|
2208
|
+
runMenu(editor, TableHeader);
|
|
2209
|
+
break;
|
|
2210
|
+
case 'full-width':
|
|
2211
|
+
runMenu(editor, TableFullWidth);
|
|
2212
|
+
break;
|
|
2213
|
+
case 'insert-row':
|
|
2214
|
+
runMenu(editor, InsertRow);
|
|
2215
|
+
break;
|
|
2216
|
+
case 'delete-row':
|
|
2217
|
+
runMenu(editor, DeleteRow);
|
|
2218
|
+
break;
|
|
2219
|
+
case 'insert-col':
|
|
2220
|
+
runMenu(editor, InsertCol);
|
|
2221
|
+
break;
|
|
2222
|
+
case 'delete-col':
|
|
2223
|
+
runMenu(editor, DeleteCol);
|
|
2224
|
+
break;
|
|
2225
|
+
case 'remove':
|
|
2226
|
+
runMenu(editor, DeleteTable);
|
|
2227
|
+
break;
|
|
2228
|
+
default:
|
|
2229
|
+
break;
|
|
2230
|
+
}
|
|
2231
|
+
} catch (err) {
|
|
2232
|
+
console.warn('[wangeditor] table toolbar action failed', action, err);
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
function renderTable(elemNode, children, editor) {
|
|
2236
|
+
var editable = getContentEditable(editor, elemNode);
|
|
2237
|
+
var _a = elemNode.width,
|
|
2238
|
+
width = _a === void 0 ? 'auto' : _a;
|
|
2239
|
+
var selected = DomEditor.isNodeSelected(editor, elemNode);
|
|
2240
|
+
var firstRowCells = getFirstRowCells(elemNode);
|
|
2241
|
+
var kids = children == null ? [] : Array.isArray(children) ? children : [children];
|
|
2242
|
+
var tableOn = {
|
|
2243
|
+
mousedown: function mousedown(e) {
|
|
2244
|
+
var _a, _b, _c;
|
|
2245
|
+
var target = e.target;
|
|
2246
|
+
if ((_a = target === null || target === void 0 ? void 0 : target.closest) === null || _a === void 0 ? void 0 : _a.call(target, '[data-mdg-table-toolbar]')) return;
|
|
2247
|
+
if ((target === null || target === void 0 ? void 0 : target.tagName) === 'DIV') e.preventDefault();
|
|
2248
|
+
if (editor.isDisabled()) return;
|
|
2249
|
+
try {
|
|
2250
|
+
var tablePath = DomEditor.findPath(editor, elemNode);
|
|
2251
|
+
var tableStart = Editor.start(editor, tablePath);
|
|
2252
|
+
var selection = editor.selection;
|
|
2253
|
+
if (selection == null || ((_c = (_b = selection.anchor) === null || _b === void 0 ? void 0 : _b.path) === null || _c === void 0 ? void 0 : _c[0]) !== tablePath[0]) {
|
|
2254
|
+
editor.select(tableStart);
|
|
2255
|
+
}
|
|
2256
|
+
} catch (_) {
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
};
|
|
2260
|
+
var tableInner = jsx("table", {
|
|
2261
|
+
width: width,
|
|
2262
|
+
contentEditable: editable
|
|
2263
|
+
}, jsx("colgroup", null, firstRowCells.map(function (cell) {
|
|
2264
|
+
var _a = cell.width,
|
|
2265
|
+
colWidth = _a === void 0 ? 'auto' : _a;
|
|
2266
|
+
return jsx("col", {
|
|
2267
|
+
width: colWidth
|
|
2268
|
+
});
|
|
2269
|
+
})), jsx("tbody", null, kids));
|
|
2270
|
+
if (editor.isDisabled()) {
|
|
2271
|
+
return h('div', {
|
|
2272
|
+
attrs: {
|
|
2273
|
+
class: 'mdg-table-wrap'
|
|
2274
|
+
}
|
|
2275
|
+
}, [h('div', {
|
|
2276
|
+
attrs: {
|
|
2277
|
+
class: 'table-container',
|
|
2278
|
+
'data-selected': selected ? 'true' : 'false'
|
|
2279
|
+
},
|
|
2280
|
+
on: tableOn
|
|
2281
|
+
}, [tableInner])]);
|
|
2282
|
+
}
|
|
2283
|
+
var canCancelEnter = false;
|
|
2284
|
+
try {
|
|
2285
|
+
var path = DomEditor.findPath(editor, elemNode);
|
|
2286
|
+
canCancelEnter = canRemoveEmptyLineAboveBlock(editor, path);
|
|
2287
|
+
} catch (_) {
|
|
2288
|
+
canCancelEnter = false;
|
|
2289
|
+
}
|
|
2290
|
+
var headerOn = isTableHeaderOn(elemNode);
|
|
2291
|
+
var fullWidthOn = isTableFullWidthOn(elemNode);
|
|
2292
|
+
var toolbar = h('div', {
|
|
2293
|
+
attrs: {
|
|
2294
|
+
class: 'mdg-table-toolbar',
|
|
2295
|
+
contenteditable: 'false',
|
|
2296
|
+
'data-mdg-table-toolbar': '1'
|
|
2297
|
+
},
|
|
2298
|
+
props: {
|
|
2299
|
+
contentEditable: false
|
|
2300
|
+
},
|
|
2301
|
+
on: {
|
|
2302
|
+
mousedown: function mousedown(e) {
|
|
2303
|
+
e.preventDefault();
|
|
2304
|
+
e.stopPropagation();
|
|
2305
|
+
},
|
|
2306
|
+
click: function click(e) {
|
|
2307
|
+
var _a, _b, _c;
|
|
2308
|
+
e.preventDefault();
|
|
2309
|
+
e.stopPropagation();
|
|
2310
|
+
var t = e.target;
|
|
2311
|
+
var btn = (_a = t === null || t === void 0 ? void 0 : t.closest) === null || _a === void 0 ? void 0 : _a.call(t, 'button[data-table-action]');
|
|
2312
|
+
var action = (_b = btn === null || btn === void 0 ? void 0 : btn.getAttribute) === null || _b === void 0 ? void 0 : _b.call(btn, 'data-table-action');
|
|
2313
|
+
if (!action || ((_c = btn === null || btn === void 0 ? void 0 : btn.classList) === null || _c === void 0 ? void 0 : _c.contains('is-disabled'))) return;
|
|
2314
|
+
handleTableToolbarAction(editor, elemNode, action);
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
}, [makeBtn('enter', '回车(上方空行)', ICON_ENTER), makeBtn('cancel-enter', '取消回车', ICON_CANCEL_ENTER, {
|
|
2318
|
+
disabled: !canCancelEnter
|
|
2319
|
+
}), makeBtn('header', '表头', TABLE_HEADER_SVG, {
|
|
2320
|
+
active: headerOn
|
|
2321
|
+
}), makeBtn('full-width', '宽度自适应', FULL_WIDTH_SVG, {
|
|
2322
|
+
active: fullWidthOn
|
|
2323
|
+
}), makeBtn('insert-row', '插入行', ADD_ROW_SVG), makeBtn('delete-row', '删除行', DEL_ROW_SVG), makeBtn('insert-col', '插入列', ADD_COL_SVG), makeBtn('delete-col', '删除列', DEL_COL_SVG), makeBtn('remove', '删除表格', TRASH_SVG)]);
|
|
2324
|
+
return h('div', {
|
|
2325
|
+
attrs: {
|
|
2326
|
+
class: 'mdg-table-wrap'
|
|
2327
|
+
}
|
|
2328
|
+
}, [h('div', {
|
|
2329
|
+
attrs: {
|
|
2330
|
+
class: 'table-container mdg-table-with-toolbar',
|
|
2331
|
+
'data-selected': selected ? 'true' : 'false'
|
|
2332
|
+
},
|
|
2333
|
+
on: tableOn
|
|
2334
|
+
}, [toolbar, tableInner])]);
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
function renderTableRow(elemNode, children, editor) {
|
|
2338
|
+
var vnode = jsx("tr", null, children);
|
|
2339
|
+
return vnode;
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
|
|
2343
|
+
|
|
2344
|
+
|
|
2345
|
+
|
|
2346
|
+
|
|
2347
|
+
|
|
2348
|
+
|
|
2349
|
+
|
|
2350
|
+
var TO_STRING = 'toString';
|
|
2351
|
+
var RegExpPrototype$1 = RegExp.prototype;
|
|
2352
|
+
var n$ToString = RegExpPrototype$1[TO_STRING];
|
|
2353
|
+
var getFlags = functionUncurryThis(regexpFlags);
|
|
2354
|
+
|
|
2355
|
+
var NOT_GENERIC = fails(function () { return n$ToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
|
|
2356
|
+
// FF44- RegExp#toString has a wrong name
|
|
2357
|
+
var INCORRECT_NAME = PROPER_FUNCTION_NAME$1 && n$ToString.name != TO_STRING;
|
|
2358
|
+
|
|
2359
|
+
// `RegExp.prototype.toString` method
|
|
2360
|
+
// https://tc39.es/ecma262/#sec-regexp.prototype.tostring
|
|
2361
|
+
if (NOT_GENERIC || INCORRECT_NAME) {
|
|
2362
|
+
redefine(RegExp.prototype, TO_STRING, function toString$1() {
|
|
2363
|
+
var R = anObject(this);
|
|
2364
|
+
var p = toString(R.source);
|
|
2365
|
+
var rf = R.flags;
|
|
2366
|
+
var f = toString(rf === undefined && objectIsPrototypeOf(RegExpPrototype$1, R) && !('flags' in RegExpPrototype$1) ? getFlags(R) : rf);
|
|
2367
|
+
return '/' + p + '/' + f;
|
|
2368
|
+
}, { unsafe: true });
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
var UNSCOPABLES = wellKnownSymbol('unscopables');
|
|
2372
|
+
var ArrayPrototype = Array.prototype;
|
|
2373
|
+
|
|
2374
|
+
// Array.prototype[@@unscopables]
|
|
2375
|
+
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
2376
|
+
if (ArrayPrototype[UNSCOPABLES] == undefined) {
|
|
2377
|
+
objectDefineProperty.f(ArrayPrototype, UNSCOPABLES, {
|
|
2378
|
+
configurable: true,
|
|
2379
|
+
value: objectCreate(null)
|
|
2380
|
+
});
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
// add a key to Array.prototype[@@unscopables]
|
|
2384
|
+
var addToUnscopables = function (key) {
|
|
2385
|
+
ArrayPrototype[UNSCOPABLES][key] = true;
|
|
2386
|
+
};
|
|
2387
|
+
|
|
2388
|
+
var $find = arrayIteration.find;
|
|
2389
|
+
|
|
2390
|
+
|
|
2391
|
+
var FIND = 'find';
|
|
2392
|
+
var SKIPS_HOLES = true;
|
|
2393
|
+
|
|
2394
|
+
// Shouldn't skip holes
|
|
2395
|
+
if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
|
|
2396
|
+
|
|
2397
|
+
// `Array.prototype.find` method
|
|
2398
|
+
// https://tc39.es/ecma262/#sec-array.prototype.find
|
|
2399
|
+
_export({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
|
|
2400
|
+
find: function find(callbackfn /* , that = undefined */) {
|
|
2401
|
+
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
2402
|
+
}
|
|
2403
|
+
});
|
|
2404
|
+
|
|
2405
|
+
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
2406
|
+
addToUnscopables(FIND);
|
|
2407
|
+
|
|
2408
|
+
var FunctionPrototype = Function.prototype;
|
|
2409
|
+
var apply = FunctionPrototype.apply;
|
|
2410
|
+
var bind = FunctionPrototype.bind;
|
|
2411
|
+
var call = FunctionPrototype.call;
|
|
2412
|
+
|
|
2413
|
+
// eslint-disable-next-line es/no-reflect -- safe
|
|
2414
|
+
var functionApply = typeof Reflect == 'object' && Reflect.apply || (bind ? call.bind(apply) : function () {
|
|
2415
|
+
return call.apply(apply, arguments);
|
|
2416
|
+
});
|
|
2417
|
+
|
|
2418
|
+
// TODO: Remove from `core-js@4` since it's moved to entry points
|
|
2419
|
+
|
|
2420
|
+
|
|
2421
|
+
|
|
2422
|
+
|
|
2423
|
+
|
|
2424
|
+
|
|
2425
|
+
|
|
2426
|
+
|
|
2427
|
+
var SPECIES$1 = wellKnownSymbol('species');
|
|
2428
|
+
var RegExpPrototype = RegExp.prototype;
|
|
2429
|
+
|
|
2430
|
+
var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) {
|
|
2431
|
+
var SYMBOL = wellKnownSymbol(KEY);
|
|
2432
|
+
|
|
2433
|
+
var DELEGATES_TO_SYMBOL = !fails(function () {
|
|
2434
|
+
// String methods call symbol-named RegEp methods
|
|
2435
|
+
var O = {};
|
|
2436
|
+
O[SYMBOL] = function () { return 7; };
|
|
2437
|
+
return ''[KEY](O) != 7;
|
|
2438
|
+
});
|
|
2439
|
+
|
|
2440
|
+
var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
|
|
2441
|
+
// Symbol-named RegExp methods call .exec
|
|
2442
|
+
var execCalled = false;
|
|
2443
|
+
var re = /a/;
|
|
2444
|
+
|
|
2445
|
+
if (KEY === 'split') {
|
|
2446
|
+
// We can't use real regex here since it causes deoptimization
|
|
2447
|
+
// and serious performance degradation in V8
|
|
2448
|
+
// https://github.com/zloirock/core-js/issues/306
|
|
2449
|
+
re = {};
|
|
2450
|
+
// RegExp[@@split] doesn't call the regex's exec method, but first creates
|
|
2451
|
+
// a new one. We need to return the patched regex when creating the new one.
|
|
2452
|
+
re.constructor = {};
|
|
2453
|
+
re.constructor[SPECIES$1] = function () { return re; };
|
|
2454
|
+
re.flags = '';
|
|
2455
|
+
re[SYMBOL] = /./[SYMBOL];
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
re.exec = function () { execCalled = true; return null; };
|
|
2459
|
+
|
|
2460
|
+
re[SYMBOL]('');
|
|
2461
|
+
return !execCalled;
|
|
2462
|
+
});
|
|
2463
|
+
|
|
2464
|
+
if (
|
|
2465
|
+
!DELEGATES_TO_SYMBOL ||
|
|
2466
|
+
!DELEGATES_TO_EXEC ||
|
|
2467
|
+
FORCED
|
|
2468
|
+
) {
|
|
2469
|
+
var uncurriedNativeRegExpMethod = functionUncurryThis(/./[SYMBOL]);
|
|
2470
|
+
var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
|
|
2471
|
+
var uncurriedNativeMethod = functionUncurryThis(nativeMethod);
|
|
2472
|
+
var $exec = regexp.exec;
|
|
2473
|
+
if ($exec === regexpExec || $exec === RegExpPrototype.exec) {
|
|
2474
|
+
if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
|
|
2475
|
+
// The native String method already delegates to @@method (this
|
|
2476
|
+
// polyfilled function), leasing to infinite recursion.
|
|
2477
|
+
// We avoid it by directly calling the native @@method method.
|
|
2478
|
+
return { done: true, value: uncurriedNativeRegExpMethod(regexp, str, arg2) };
|
|
2479
|
+
}
|
|
2480
|
+
return { done: true, value: uncurriedNativeMethod(str, regexp, arg2) };
|
|
2481
|
+
}
|
|
2482
|
+
return { done: false };
|
|
2483
|
+
});
|
|
2484
|
+
|
|
2485
|
+
redefine(String.prototype, KEY, methods[0]);
|
|
2486
|
+
redefine(RegExpPrototype, SYMBOL, methods[1]);
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
|
|
2490
|
+
};
|
|
2491
|
+
|
|
2492
|
+
var MATCH = wellKnownSymbol('match');
|
|
2493
|
+
|
|
2494
|
+
// `IsRegExp` abstract operation
|
|
2495
|
+
// https://tc39.es/ecma262/#sec-isregexp
|
|
2496
|
+
var isRegexp = function (it) {
|
|
2497
|
+
var isRegExp;
|
|
2498
|
+
return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp');
|
|
2499
|
+
};
|
|
2500
|
+
|
|
2501
|
+
var TypeError$2 = global$1.TypeError;
|
|
2502
|
+
|
|
2503
|
+
// `Assert: IsConstructor(argument) is true`
|
|
2504
|
+
var aConstructor = function (argument) {
|
|
2505
|
+
if (isConstructor(argument)) return argument;
|
|
2506
|
+
throw TypeError$2(tryToString(argument) + ' is not a constructor');
|
|
2507
|
+
};
|
|
2508
|
+
|
|
2509
|
+
var SPECIES = wellKnownSymbol('species');
|
|
2510
|
+
|
|
2511
|
+
// `SpeciesConstructor` abstract operation
|
|
2512
|
+
// https://tc39.es/ecma262/#sec-speciesconstructor
|
|
2513
|
+
var speciesConstructor = function (O, defaultConstructor) {
|
|
2514
|
+
var C = anObject(O).constructor;
|
|
2515
|
+
var S;
|
|
2516
|
+
return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aConstructor(S);
|
|
2517
|
+
};
|
|
2518
|
+
|
|
2519
|
+
var charAt$2 = functionUncurryThis(''.charAt);
|
|
2520
|
+
var charCodeAt = functionUncurryThis(''.charCodeAt);
|
|
2521
|
+
var stringSlice$3 = functionUncurryThis(''.slice);
|
|
2522
|
+
|
|
2523
|
+
var createMethod$1 = function (CONVERT_TO_STRING) {
|
|
2524
|
+
return function ($this, pos) {
|
|
2525
|
+
var S = toString(requireObjectCoercible($this));
|
|
2526
|
+
var position = toIntegerOrInfinity(pos);
|
|
2527
|
+
var size = S.length;
|
|
2528
|
+
var first, second;
|
|
2529
|
+
if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
|
|
2530
|
+
first = charCodeAt(S, position);
|
|
2531
|
+
return first < 0xD800 || first > 0xDBFF || position + 1 === size
|
|
2532
|
+
|| (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
|
|
2533
|
+
? CONVERT_TO_STRING
|
|
2534
|
+
? charAt$2(S, position)
|
|
2535
|
+
: first
|
|
2536
|
+
: CONVERT_TO_STRING
|
|
2537
|
+
? stringSlice$3(S, position, position + 2)
|
|
2538
|
+
: (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
|
|
2539
|
+
};
|
|
2540
|
+
};
|
|
2541
|
+
|
|
2542
|
+
var stringMultibyte = {
|
|
2543
|
+
// `String.prototype.codePointAt` method
|
|
2544
|
+
// https://tc39.es/ecma262/#sec-string.prototype.codepointat
|
|
2545
|
+
codeAt: createMethod$1(false),
|
|
2546
|
+
// `String.prototype.at` method
|
|
2547
|
+
// https://github.com/mathiasbynens/String.prototype.at
|
|
2548
|
+
charAt: createMethod$1(true)
|
|
2549
|
+
};
|
|
2550
|
+
|
|
2551
|
+
var charAt$1 = stringMultibyte.charAt;
|
|
2552
|
+
|
|
2553
|
+
// `AdvanceStringIndex` abstract operation
|
|
2554
|
+
// https://tc39.es/ecma262/#sec-advancestringindex
|
|
2555
|
+
var advanceStringIndex = function (S, index, unicode) {
|
|
2556
|
+
return index + (unicode ? charAt$1(S, index).length : 1);
|
|
2557
|
+
};
|
|
2558
|
+
|
|
2559
|
+
var Array$1 = global$1.Array;
|
|
2560
|
+
var max$1 = Math.max;
|
|
2561
|
+
|
|
2562
|
+
var arraySliceSimple = function (O, start, end) {
|
|
2563
|
+
var length = lengthOfArrayLike(O);
|
|
2564
|
+
var k = toAbsoluteIndex(start, length);
|
|
2565
|
+
var fin = toAbsoluteIndex(end === undefined ? length : end, length);
|
|
2566
|
+
var result = Array$1(max$1(fin - k, 0));
|
|
2567
|
+
for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
|
|
2568
|
+
result.length = n;
|
|
2569
|
+
return result;
|
|
2570
|
+
};
|
|
2571
|
+
|
|
2572
|
+
var TypeError$1 = global$1.TypeError;
|
|
2573
|
+
|
|
2574
|
+
// `RegExpExec` abstract operation
|
|
2575
|
+
// https://tc39.es/ecma262/#sec-regexpexec
|
|
2576
|
+
var regexpExecAbstract = function (R, S) {
|
|
2577
|
+
var exec = R.exec;
|
|
2578
|
+
if (isCallable(exec)) {
|
|
2579
|
+
var result = functionCall(exec, R, S);
|
|
2580
|
+
if (result !== null) anObject(result);
|
|
2581
|
+
return result;
|
|
2582
|
+
}
|
|
2583
|
+
if (classofRaw(R) === 'RegExp') return functionCall(regexpExec, R, S);
|
|
2584
|
+
throw TypeError$1('RegExp#exec called on incompatible receiver');
|
|
2585
|
+
};
|
|
2586
|
+
|
|
2587
|
+
var UNSUPPORTED_Y = regexpStickyHelpers.UNSUPPORTED_Y;
|
|
2588
|
+
var MAX_UINT32 = 0xFFFFFFFF;
|
|
2589
|
+
var min$1 = Math.min;
|
|
2590
|
+
var $push = [].push;
|
|
2591
|
+
var exec = functionUncurryThis(/./.exec);
|
|
2592
|
+
var push$1 = functionUncurryThis($push);
|
|
2593
|
+
var stringSlice$2 = functionUncurryThis(''.slice);
|
|
2594
|
+
|
|
2595
|
+
// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
|
|
2596
|
+
// Weex JS has frozen built-in prototypes, so use try / catch wrapper
|
|
2597
|
+
var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
|
|
2598
|
+
// eslint-disable-next-line regexp/no-empty-group -- required for testing
|
|
2599
|
+
var re = /(?:)/;
|
|
2600
|
+
var originalExec = re.exec;
|
|
2601
|
+
re.exec = function () { return originalExec.apply(this, arguments); };
|
|
2602
|
+
var result = 'ab'.split(re);
|
|
2603
|
+
return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
|
|
2604
|
+
});
|
|
2605
|
+
|
|
2606
|
+
// @@split logic
|
|
2607
|
+
fixRegexpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) {
|
|
2608
|
+
var internalSplit;
|
|
2609
|
+
if (
|
|
2610
|
+
'abbc'.split(/(b)*/)[1] == 'c' ||
|
|
2611
|
+
// eslint-disable-next-line regexp/no-empty-group -- required for testing
|
|
2612
|
+
'test'.split(/(?:)/, -1).length != 4 ||
|
|
2613
|
+
'ab'.split(/(?:ab)*/).length != 2 ||
|
|
2614
|
+
'.'.split(/(.?)(.?)/).length != 4 ||
|
|
2615
|
+
// eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing
|
|
2616
|
+
'.'.split(/()()/).length > 1 ||
|
|
2617
|
+
''.split(/.?/).length
|
|
2618
|
+
) {
|
|
2619
|
+
// based on es5-shim implementation, need to rework it
|
|
2620
|
+
internalSplit = function (separator, limit) {
|
|
2621
|
+
var string = toString(requireObjectCoercible(this));
|
|
2622
|
+
var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
|
|
2623
|
+
if (lim === 0) return [];
|
|
2624
|
+
if (separator === undefined) return [string];
|
|
2625
|
+
// If `separator` is not a regex, use native split
|
|
2626
|
+
if (!isRegexp(separator)) {
|
|
2627
|
+
return functionCall(nativeSplit, string, separator, lim);
|
|
2628
|
+
}
|
|
2629
|
+
var output = [];
|
|
2630
|
+
var flags = (separator.ignoreCase ? 'i' : '') +
|
|
2631
|
+
(separator.multiline ? 'm' : '') +
|
|
2632
|
+
(separator.unicode ? 'u' : '') +
|
|
2633
|
+
(separator.sticky ? 'y' : '');
|
|
2634
|
+
var lastLastIndex = 0;
|
|
2635
|
+
// Make `global` and avoid `lastIndex` issues by working with a copy
|
|
2636
|
+
var separatorCopy = new RegExp(separator.source, flags + 'g');
|
|
2637
|
+
var match, lastIndex, lastLength;
|
|
2638
|
+
while (match = functionCall(regexpExec, separatorCopy, string)) {
|
|
2639
|
+
lastIndex = separatorCopy.lastIndex;
|
|
2640
|
+
if (lastIndex > lastLastIndex) {
|
|
2641
|
+
push$1(output, stringSlice$2(string, lastLastIndex, match.index));
|
|
2642
|
+
if (match.length > 1 && match.index < string.length) functionApply($push, output, arraySliceSimple(match, 1));
|
|
2643
|
+
lastLength = match[0].length;
|
|
2644
|
+
lastLastIndex = lastIndex;
|
|
2645
|
+
if (output.length >= lim) break;
|
|
2646
|
+
}
|
|
2647
|
+
if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
|
|
2648
|
+
}
|
|
2649
|
+
if (lastLastIndex === string.length) {
|
|
2650
|
+
if (lastLength || !exec(separatorCopy, '')) push$1(output, '');
|
|
2651
|
+
} else push$1(output, stringSlice$2(string, lastLastIndex));
|
|
2652
|
+
return output.length > lim ? arraySliceSimple(output, 0, lim) : output;
|
|
2653
|
+
};
|
|
2654
|
+
// Chakra, V8
|
|
2655
|
+
} else if ('0'.split(undefined, 0).length) {
|
|
2656
|
+
internalSplit = function (separator, limit) {
|
|
2657
|
+
return separator === undefined && limit === 0 ? [] : functionCall(nativeSplit, this, separator, limit);
|
|
2658
|
+
};
|
|
2659
|
+
} else internalSplit = nativeSplit;
|
|
2660
|
+
|
|
2661
|
+
return [
|
|
2662
|
+
// `String.prototype.split` method
|
|
2663
|
+
// https://tc39.es/ecma262/#sec-string.prototype.split
|
|
2664
|
+
function split(separator, limit) {
|
|
2665
|
+
var O = requireObjectCoercible(this);
|
|
2666
|
+
var splitter = separator == undefined ? undefined : getMethod(separator, SPLIT);
|
|
2667
|
+
return splitter
|
|
2668
|
+
? functionCall(splitter, separator, O, limit)
|
|
2669
|
+
: functionCall(internalSplit, toString(O), separator, limit);
|
|
2670
|
+
},
|
|
2671
|
+
// `RegExp.prototype[@@split]` method
|
|
2672
|
+
// https://tc39.es/ecma262/#sec-regexp.prototype-@@split
|
|
2673
|
+
//
|
|
2674
|
+
// NOTE: This cannot be properly polyfilled in engines that don't support
|
|
2675
|
+
// the 'y' flag.
|
|
2676
|
+
function (string, limit) {
|
|
2677
|
+
var rx = anObject(this);
|
|
2678
|
+
var S = toString(string);
|
|
2679
|
+
var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);
|
|
2680
|
+
|
|
2681
|
+
if (res.done) return res.value;
|
|
2682
|
+
|
|
2683
|
+
var C = speciesConstructor(rx, RegExp);
|
|
2684
|
+
|
|
2685
|
+
var unicodeMatching = rx.unicode;
|
|
2686
|
+
var flags = (rx.ignoreCase ? 'i' : '') +
|
|
2687
|
+
(rx.multiline ? 'm' : '') +
|
|
2688
|
+
(rx.unicode ? 'u' : '') +
|
|
2689
|
+
(UNSUPPORTED_Y ? 'g' : 'y');
|
|
2690
|
+
|
|
2691
|
+
// ^(? + rx + ) is needed, in combination with some S slicing, to
|
|
2692
|
+
// simulate the 'y' flag.
|
|
2693
|
+
var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags);
|
|
2694
|
+
var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
|
|
2695
|
+
if (lim === 0) return [];
|
|
2696
|
+
if (S.length === 0) return regexpExecAbstract(splitter, S) === null ? [S] : [];
|
|
2697
|
+
var p = 0;
|
|
2698
|
+
var q = 0;
|
|
2699
|
+
var A = [];
|
|
2700
|
+
while (q < S.length) {
|
|
2701
|
+
splitter.lastIndex = UNSUPPORTED_Y ? 0 : q;
|
|
2702
|
+
var z = regexpExecAbstract(splitter, UNSUPPORTED_Y ? stringSlice$2(S, q) : S);
|
|
2703
|
+
var e;
|
|
2704
|
+
if (
|
|
2705
|
+
z === null ||
|
|
2706
|
+
(e = min$1(toLength(splitter.lastIndex + (UNSUPPORTED_Y ? q : 0)), S.length)) === p
|
|
2707
|
+
) {
|
|
2708
|
+
q = advanceStringIndex(S, q, unicodeMatching);
|
|
2709
|
+
} else {
|
|
2710
|
+
push$1(A, stringSlice$2(S, p, q));
|
|
2711
|
+
if (A.length === lim) return A;
|
|
2712
|
+
for (var i = 1; i <= z.length - 1; i++) {
|
|
2713
|
+
push$1(A, z[i]);
|
|
2714
|
+
if (A.length === lim) return A;
|
|
2715
|
+
}
|
|
2716
|
+
q = p = e;
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
push$1(A, stringSlice$2(S, p));
|
|
2720
|
+
return A;
|
|
2721
|
+
}
|
|
2722
|
+
];
|
|
2723
|
+
}, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
|
|
2724
|
+
|
|
2725
|
+
// a string of all valid unicode whitespaces
|
|
2726
|
+
var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
|
|
2727
|
+
'\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
|
|
2728
|
+
|
|
2729
|
+
var replace$1 = functionUncurryThis(''.replace);
|
|
2730
|
+
var whitespace = '[' + whitespaces + ']';
|
|
2731
|
+
var ltrim = RegExp('^' + whitespace + whitespace + '*');
|
|
2732
|
+
var rtrim = RegExp(whitespace + whitespace + '*$');
|
|
2733
|
+
|
|
2734
|
+
// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
|
|
2735
|
+
var createMethod = function (TYPE) {
|
|
2736
|
+
return function ($this) {
|
|
2737
|
+
var string = toString(requireObjectCoercible($this));
|
|
2738
|
+
if (TYPE & 1) string = replace$1(string, ltrim, '');
|
|
2739
|
+
if (TYPE & 2) string = replace$1(string, rtrim, '');
|
|
2740
|
+
return string;
|
|
2741
|
+
};
|
|
2742
|
+
};
|
|
2743
|
+
|
|
2744
|
+
var stringTrim = {
|
|
2745
|
+
// `String.prototype.{ trimLeft, trimStart }` methods
|
|
2746
|
+
// https://tc39.es/ecma262/#sec-string.prototype.trimstart
|
|
2747
|
+
start: createMethod(1),
|
|
2748
|
+
// `String.prototype.{ trimRight, trimEnd }` methods
|
|
2749
|
+
// https://tc39.es/ecma262/#sec-string.prototype.trimend
|
|
2750
|
+
end: createMethod(2),
|
|
2751
|
+
// `String.prototype.trim` method
|
|
2752
|
+
// https://tc39.es/ecma262/#sec-string.prototype.trim
|
|
2753
|
+
trim: createMethod(3)
|
|
2754
|
+
};
|
|
2755
|
+
|
|
2756
|
+
var PROPER_FUNCTION_NAME = functionName.PROPER;
|
|
2757
|
+
|
|
2758
|
+
|
|
2759
|
+
|
|
2760
|
+
var non = '\u200B\u0085\u180E';
|
|
2761
|
+
|
|
2762
|
+
// check that a method works with the correct list
|
|
2763
|
+
// of whitespaces and has a correct name
|
|
2764
|
+
var stringTrimForced = function (METHOD_NAME) {
|
|
2765
|
+
return fails(function () {
|
|
2766
|
+
return !!whitespaces[METHOD_NAME]()
|
|
2767
|
+
|| non[METHOD_NAME]() !== non
|
|
2768
|
+
|| (PROPER_FUNCTION_NAME && whitespaces[METHOD_NAME].name !== METHOD_NAME);
|
|
2769
|
+
});
|
|
2770
|
+
};
|
|
2771
|
+
|
|
2772
|
+
var $trim = stringTrim.trim;
|
|
2773
|
+
|
|
2774
|
+
|
|
2775
|
+
// `String.prototype.trim` method
|
|
2776
|
+
// https://tc39.es/ecma262/#sec-string.prototype.trim
|
|
2777
|
+
_export({ target: 'String', proto: true, forced: stringTrimForced('trim') }, {
|
|
2778
|
+
trim: function trim() {
|
|
2779
|
+
return $trim(this);
|
|
2780
|
+
}
|
|
2781
|
+
});
|
|
2782
|
+
|
|
2783
|
+
// `globalThis` object
|
|
2784
|
+
// https://tc39.es/ecma262/#sec-globalthis
|
|
2785
|
+
_export({ global: true }, {
|
|
2786
|
+
globalThis: global$1
|
|
2787
|
+
});
|
|
2788
|
+
|
|
2789
|
+
if (append) $.fn.append = append;
|
|
2790
|
+
if (on) $.fn.on = on;
|
|
2791
|
+
if (focus) $.fn.focus = focus;
|
|
2792
|
+
if (attr) $.fn.attr = attr;
|
|
2793
|
+
if (val) $.fn.val = val;
|
|
2794
|
+
if (html$1) $.fn.html = html$1;
|
|
2795
|
+
if (dataset) $.fn.dataset = dataset;
|
|
2796
|
+
if (addClass) $.fn.addClass = addClass;
|
|
2797
|
+
if (removeClass) $.fn.removeClass = removeClass;
|
|
2798
|
+
if (children) $.fn.children = children;
|
|
2799
|
+
if (each) $.fn.each = each;
|
|
2800
|
+
if (find) $.fn.find = find;
|
|
2801
|
+
function getTagName($elem) {
|
|
2802
|
+
if ($elem.length) return $elem[0].tagName.toLowerCase();
|
|
2803
|
+
return '';
|
|
2804
|
+
}
|
|
2805
|
+
function getStyleValue($elem, styleKey) {
|
|
2806
|
+
var res = '';
|
|
2807
|
+
var styleStr = $elem.attr('style') || '';
|
|
2808
|
+
var styleArr = styleStr.split(';');
|
|
2809
|
+
var length = styleArr.length;
|
|
2810
|
+
for (var i = 0; i < length; i++) {
|
|
2811
|
+
var styleItemStr = styleArr[i];
|
|
2812
|
+
if (styleItemStr) {
|
|
2813
|
+
var arr = styleItemStr.split(':');
|
|
2814
|
+
if (arr[0].trim() === styleKey) {
|
|
2815
|
+
res = arr[1].trim();
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
return res;
|
|
2820
|
+
}
|
|
2821
|
+
|
|
2822
|
+
var isMouseDownForResize = false;
|
|
2823
|
+
var clientXWhenMouseDown = 0;
|
|
2824
|
+
var cellWidthWhenMouseDown = 0;
|
|
2825
|
+
var cellPathWhenMouseDown = null;
|
|
2826
|
+
var editorWhenMouseDown = null;
|
|
2827
|
+
var $body = $('body');
|
|
2828
|
+
function onMouseDown(event) {
|
|
2829
|
+
var elem = event.target;
|
|
2830
|
+
if (elem.tagName !== 'TH' && elem.tagName !== 'TD') return;
|
|
2831
|
+
if (elem.style.cursor !== 'col-resize') return;
|
|
2832
|
+
elem.style.cursor = 'auto';
|
|
2833
|
+
event.preventDefault();
|
|
2834
|
+
isMouseDownForResize = true;
|
|
2835
|
+
var clientX = event.clientX;
|
|
2836
|
+
clientXWhenMouseDown = clientX;
|
|
2837
|
+
var width = elem.getBoundingClientRect().width;
|
|
2838
|
+
cellWidthWhenMouseDown = width;
|
|
2839
|
+
$body.on('mousemove', onMouseMove);
|
|
2840
|
+
$body.on('mouseup', onMouseUp);
|
|
2841
|
+
}
|
|
2842
|
+
$body.on('mousedown', onMouseDown);
|
|
2843
|
+
function onMouseUp(event) {
|
|
2844
|
+
isMouseDownForResize = false;
|
|
2845
|
+
editorWhenMouseDown = null;
|
|
2846
|
+
cellPathWhenMouseDown = null;
|
|
2847
|
+
$body.off('mousemove', onMouseMove);
|
|
2848
|
+
$body.off('mouseup', onMouseUp);
|
|
2849
|
+
}
|
|
2850
|
+
var onMouseMove = throttle(function (event) {
|
|
2851
|
+
if (!isMouseDownForResize) return;
|
|
2852
|
+
if (editorWhenMouseDown == null || cellPathWhenMouseDown == null) return;
|
|
2853
|
+
event.preventDefault();
|
|
2854
|
+
var clientX = event.clientX;
|
|
2855
|
+
var newWith = cellWidthWhenMouseDown + (clientX - clientXWhenMouseDown);
|
|
2856
|
+
newWith = Math.floor(newWith * 100) / 100;
|
|
2857
|
+
if (newWith < 30) newWith = 30;
|
|
2858
|
+
Transforms.setNodes(editorWhenMouseDown, {
|
|
2859
|
+
width: newWith.toString()
|
|
2860
|
+
}, {
|
|
2861
|
+
at: cellPathWhenMouseDown
|
|
2862
|
+
});
|
|
2863
|
+
}, 100);
|
|
2864
|
+
function renderTableCell(cellNode, children, editor) {
|
|
2865
|
+
var isFirstRow = isCellInFirstRow(editor, cellNode);
|
|
2866
|
+
var _a = cellNode,
|
|
2867
|
+
_b = _a.colSpan,
|
|
2868
|
+
colSpan = _b === void 0 ? 1 : _b,
|
|
2869
|
+
_c = _a.rowSpan,
|
|
2870
|
+
rowSpan = _c === void 0 ? 1 : _c,
|
|
2871
|
+
_d = _a.isHeader,
|
|
2872
|
+
isHeader = _d === void 0 ? false : _d;
|
|
2873
|
+
if (!isFirstRow) {
|
|
2874
|
+
return jsx("td", {
|
|
2875
|
+
colSpan: colSpan,
|
|
2876
|
+
rowSpan: rowSpan
|
|
2877
|
+
}, children);
|
|
2878
|
+
}
|
|
2879
|
+
var Tag = isHeader ? 'th' : 'td';
|
|
2880
|
+
var vnode = jsx(Tag, {
|
|
2881
|
+
colSpan: colSpan,
|
|
2882
|
+
rowSpan: rowSpan,
|
|
2883
|
+
style: {
|
|
2884
|
+
borderRightWidth: '3px'
|
|
2885
|
+
},
|
|
2886
|
+
on: {
|
|
2887
|
+
mousemove: throttle(function (event) {
|
|
2888
|
+
var elem = this.elm;
|
|
2889
|
+
if (elem == null) return;
|
|
2890
|
+
var _a = elem.getBoundingClientRect(),
|
|
2891
|
+
left = _a.left,
|
|
2892
|
+
width = _a.width,
|
|
2893
|
+
top = _a.top,
|
|
2894
|
+
height = _a.height;
|
|
2895
|
+
var clientX = event.clientX,
|
|
2896
|
+
clientY = event.clientY;
|
|
2897
|
+
if (isMouseDownForResize) return;
|
|
2898
|
+
var matchX = clientX > left + width - 5 && clientX < left + width;
|
|
2899
|
+
var matchY = clientY > top && clientY < top + height;
|
|
2900
|
+
if (matchX && matchY) {
|
|
2901
|
+
elem.style.cursor = 'col-resize';
|
|
2902
|
+
editorWhenMouseDown = editor;
|
|
2903
|
+
cellPathWhenMouseDown = DomEditor.findPath(editor, cellNode);
|
|
2904
|
+
} else {
|
|
2905
|
+
if (!isMouseDownForResize) {
|
|
2906
|
+
elem.style.cursor = 'auto';
|
|
2907
|
+
editorWhenMouseDown = null;
|
|
2908
|
+
cellPathWhenMouseDown = null;
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
}, 100)
|
|
2912
|
+
}
|
|
2913
|
+
}, children);
|
|
2914
|
+
return vnode;
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2917
|
+
var renderTableConf = {
|
|
2918
|
+
type: 'table',
|
|
2919
|
+
renderElem: renderTable
|
|
2920
|
+
};
|
|
2921
|
+
var renderTableRowConf = {
|
|
2922
|
+
type: 'table-row',
|
|
2923
|
+
renderElem: renderTableRow
|
|
2924
|
+
};
|
|
2925
|
+
var renderTableCellConf = {
|
|
2926
|
+
type: 'table-cell',
|
|
2927
|
+
renderElem: renderTableCell
|
|
2928
|
+
};
|
|
2929
|
+
|
|
2930
|
+
function tableToHtml(elemNode, childrenHtml) {
|
|
2931
|
+
var _a = elemNode.width,
|
|
2932
|
+
width = _a === void 0 ? 'auto' : _a;
|
|
2933
|
+
return "<table style=\"width: " + width + ";\"><tbody>" + childrenHtml + "</tbody></table>";
|
|
2934
|
+
}
|
|
2935
|
+
function tableRowToHtml(elem, childrenHtml) {
|
|
2936
|
+
return "<tr>" + childrenHtml + "</tr>";
|
|
2937
|
+
}
|
|
2938
|
+
function tableCellToHtml(cellNode, childrenHtml) {
|
|
2939
|
+
var _a = cellNode,
|
|
2940
|
+
_b = _a.colSpan,
|
|
2941
|
+
colSpan = _b === void 0 ? 1 : _b,
|
|
2942
|
+
_c = _a.rowSpan,
|
|
2943
|
+
rowSpan = _c === void 0 ? 1 : _c,
|
|
2944
|
+
_d = _a.isHeader,
|
|
2945
|
+
isHeader = _d === void 0 ? false : _d,
|
|
2946
|
+
_e = _a.width,
|
|
2947
|
+
width = _e === void 0 ? 'auto' : _e;
|
|
2948
|
+
var tag = isHeader ? 'th' : 'td';
|
|
2949
|
+
return "<" + tag + " colSpan=\"" + colSpan + "\" rowSpan=\"" + rowSpan + "\" width=\"" + width + "\">" + childrenHtml + "</" + tag + ">";
|
|
2950
|
+
}
|
|
2951
|
+
var tableToHtmlConf = {
|
|
2952
|
+
type: 'table',
|
|
2953
|
+
elemToHtml: tableToHtml
|
|
2954
|
+
};
|
|
2955
|
+
var tableRowToHtmlConf = {
|
|
2956
|
+
type: 'table-row',
|
|
2957
|
+
elemToHtml: tableRowToHtml
|
|
2958
|
+
};
|
|
2959
|
+
var tableCellToHtmlConf = {
|
|
2960
|
+
type: 'table-cell',
|
|
2961
|
+
elemToHtml: tableCellToHtml
|
|
2962
|
+
};
|
|
2963
|
+
|
|
2964
|
+
function preParse(tableElem) {
|
|
2965
|
+
var $table = $(tableElem);
|
|
2966
|
+
var tagName = getTagName($table);
|
|
2967
|
+
if (tagName !== 'table') return tableElem;
|
|
2968
|
+
var $tbody = $table.find('tbody');
|
|
2969
|
+
if ($tbody.length === 0) return tableElem;
|
|
2970
|
+
var $tr = $table.find('tr');
|
|
2971
|
+
$table.append($tr);
|
|
2972
|
+
$tbody.remove();
|
|
2973
|
+
return $table[0];
|
|
2974
|
+
}
|
|
2975
|
+
var preParseTableHtmlConf = {
|
|
2976
|
+
selector: 'table',
|
|
2977
|
+
preParseHtml: preParse
|
|
2978
|
+
};
|
|
2979
|
+
|
|
2980
|
+
var floor = Math.floor;
|
|
2981
|
+
var charAt = functionUncurryThis(''.charAt);
|
|
2982
|
+
var replace = functionUncurryThis(''.replace);
|
|
2983
|
+
var stringSlice$1 = functionUncurryThis(''.slice);
|
|
2984
|
+
var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g;
|
|
2985
|
+
var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g;
|
|
2986
|
+
|
|
2987
|
+
// `GetSubstitution` abstract operation
|
|
2988
|
+
// https://tc39.es/ecma262/#sec-getsubstitution
|
|
2989
|
+
var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) {
|
|
2990
|
+
var tailPos = position + matched.length;
|
|
2991
|
+
var m = captures.length;
|
|
2992
|
+
var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
|
|
2993
|
+
if (namedCaptures !== undefined) {
|
|
2994
|
+
namedCaptures = toObject(namedCaptures);
|
|
2995
|
+
symbols = SUBSTITUTION_SYMBOLS;
|
|
2996
|
+
}
|
|
2997
|
+
return replace(replacement, symbols, function (match, ch) {
|
|
2998
|
+
var capture;
|
|
2999
|
+
switch (charAt(ch, 0)) {
|
|
3000
|
+
case '$': return '$';
|
|
3001
|
+
case '&': return matched;
|
|
3002
|
+
case '`': return stringSlice$1(str, 0, position);
|
|
3003
|
+
case "'": return stringSlice$1(str, tailPos);
|
|
3004
|
+
case '<':
|
|
3005
|
+
capture = namedCaptures[stringSlice$1(ch, 1, -1)];
|
|
3006
|
+
break;
|
|
3007
|
+
default: // \d\d?
|
|
3008
|
+
var n = +ch;
|
|
3009
|
+
if (n === 0) return match;
|
|
3010
|
+
if (n > m) {
|
|
3011
|
+
var f = floor(n / 10);
|
|
3012
|
+
if (f === 0) return match;
|
|
3013
|
+
if (f <= m) return captures[f - 1] === undefined ? charAt(ch, 1) : captures[f - 1] + charAt(ch, 1);
|
|
3014
|
+
return match;
|
|
3015
|
+
}
|
|
3016
|
+
capture = captures[n - 1];
|
|
3017
|
+
}
|
|
3018
|
+
return capture === undefined ? '' : capture;
|
|
3019
|
+
});
|
|
3020
|
+
};
|
|
3021
|
+
|
|
3022
|
+
var REPLACE = wellKnownSymbol('replace');
|
|
3023
|
+
var max = Math.max;
|
|
3024
|
+
var min = Math.min;
|
|
3025
|
+
var concat = functionUncurryThis([].concat);
|
|
3026
|
+
var push = functionUncurryThis([].push);
|
|
3027
|
+
var stringIndexOf = functionUncurryThis(''.indexOf);
|
|
3028
|
+
var stringSlice = functionUncurryThis(''.slice);
|
|
3029
|
+
|
|
3030
|
+
var maybeToString = function (it) {
|
|
3031
|
+
return it === undefined ? it : String(it);
|
|
3032
|
+
};
|
|
3033
|
+
|
|
3034
|
+
// IE <= 11 replaces $0 with the whole match, as if it was $&
|
|
3035
|
+
// https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
|
|
3036
|
+
var REPLACE_KEEPS_$0 = (function () {
|
|
3037
|
+
// eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing
|
|
3038
|
+
return 'a'.replace(/./, '$0') === '$0';
|
|
3039
|
+
})();
|
|
3040
|
+
|
|
3041
|
+
// Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
|
|
3042
|
+
var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {
|
|
3043
|
+
if (/./[REPLACE]) {
|
|
3044
|
+
return /./[REPLACE]('a', '$0') === '';
|
|
3045
|
+
}
|
|
3046
|
+
return false;
|
|
3047
|
+
})();
|
|
3048
|
+
|
|
3049
|
+
var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
|
|
3050
|
+
var re = /./;
|
|
3051
|
+
re.exec = function () {
|
|
3052
|
+
var result = [];
|
|
3053
|
+
result.groups = { a: '7' };
|
|
3054
|
+
return result;
|
|
3055
|
+
};
|
|
3056
|
+
// eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive
|
|
3057
|
+
return ''.replace(re, '$<a>') !== '7';
|
|
3058
|
+
});
|
|
3059
|
+
|
|
3060
|
+
// @@replace logic
|
|
3061
|
+
fixRegexpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNative) {
|
|
3062
|
+
var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
|
|
3063
|
+
|
|
3064
|
+
return [
|
|
3065
|
+
// `String.prototype.replace` method
|
|
3066
|
+
// https://tc39.es/ecma262/#sec-string.prototype.replace
|
|
3067
|
+
function replace(searchValue, replaceValue) {
|
|
3068
|
+
var O = requireObjectCoercible(this);
|
|
3069
|
+
var replacer = searchValue == undefined ? undefined : getMethod(searchValue, REPLACE);
|
|
3070
|
+
return replacer
|
|
3071
|
+
? functionCall(replacer, searchValue, O, replaceValue)
|
|
3072
|
+
: functionCall(nativeReplace, toString(O), searchValue, replaceValue);
|
|
3073
|
+
},
|
|
3074
|
+
// `RegExp.prototype[@@replace]` method
|
|
3075
|
+
// https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
|
|
3076
|
+
function (string, replaceValue) {
|
|
3077
|
+
var rx = anObject(this);
|
|
3078
|
+
var S = toString(string);
|
|
3079
|
+
|
|
3080
|
+
if (
|
|
3081
|
+
typeof replaceValue == 'string' &&
|
|
3082
|
+
stringIndexOf(replaceValue, UNSAFE_SUBSTITUTE) === -1 &&
|
|
3083
|
+
stringIndexOf(replaceValue, '$<') === -1
|
|
3084
|
+
) {
|
|
3085
|
+
var res = maybeCallNative(nativeReplace, rx, S, replaceValue);
|
|
3086
|
+
if (res.done) return res.value;
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
var functionalReplace = isCallable(replaceValue);
|
|
3090
|
+
if (!functionalReplace) replaceValue = toString(replaceValue);
|
|
3091
|
+
|
|
3092
|
+
var global = rx.global;
|
|
3093
|
+
if (global) {
|
|
3094
|
+
var fullUnicode = rx.unicode;
|
|
3095
|
+
rx.lastIndex = 0;
|
|
3096
|
+
}
|
|
3097
|
+
var results = [];
|
|
3098
|
+
while (true) {
|
|
3099
|
+
var result = regexpExecAbstract(rx, S);
|
|
3100
|
+
if (result === null) break;
|
|
3101
|
+
|
|
3102
|
+
push(results, result);
|
|
3103
|
+
if (!global) break;
|
|
3104
|
+
|
|
3105
|
+
var matchStr = toString(result[0]);
|
|
3106
|
+
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
var accumulatedResult = '';
|
|
3110
|
+
var nextSourcePosition = 0;
|
|
3111
|
+
for (var i = 0; i < results.length; i++) {
|
|
3112
|
+
result = results[i];
|
|
3113
|
+
|
|
3114
|
+
var matched = toString(result[0]);
|
|
3115
|
+
var position = max(min(toIntegerOrInfinity(result.index), S.length), 0);
|
|
3116
|
+
var captures = [];
|
|
3117
|
+
// NOTE: This is equivalent to
|
|
3118
|
+
// captures = result.slice(1).map(maybeToString)
|
|
3119
|
+
// but for some reason `nativeSlice.call(result, 1, result.length)` (called in
|
|
3120
|
+
// the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
|
|
3121
|
+
// causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
|
|
3122
|
+
for (var j = 1; j < result.length; j++) push(captures, maybeToString(result[j]));
|
|
3123
|
+
var namedCaptures = result.groups;
|
|
3124
|
+
if (functionalReplace) {
|
|
3125
|
+
var replacerArgs = concat([matched], captures, position, S);
|
|
3126
|
+
if (namedCaptures !== undefined) push(replacerArgs, namedCaptures);
|
|
3127
|
+
var replacement = toString(functionApply(replaceValue, undefined, replacerArgs));
|
|
3128
|
+
} else {
|
|
3129
|
+
replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
|
|
3130
|
+
}
|
|
3131
|
+
if (position >= nextSourcePosition) {
|
|
3132
|
+
accumulatedResult += stringSlice(S, nextSourcePosition, position) + replacement;
|
|
3133
|
+
nextSourcePosition = position + matched.length;
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
return accumulatedResult + stringSlice(S, nextSourcePosition);
|
|
3137
|
+
}
|
|
3138
|
+
];
|
|
3139
|
+
}, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE);
|
|
3140
|
+
|
|
3141
|
+
function parseCellHtml(elem, children, editor) {
|
|
3142
|
+
var $elem = $(elem);
|
|
3143
|
+
children = children.filter(function (child) {
|
|
3144
|
+
if (Text.isText(child)) return true;
|
|
3145
|
+
if (editor.isInline(child)) return true;
|
|
3146
|
+
return false;
|
|
3147
|
+
});
|
|
3148
|
+
if (children.length === 0) {
|
|
3149
|
+
children = [{
|
|
3150
|
+
text: $elem.text().replace(/\s+/gm, ' ')
|
|
3151
|
+
}];
|
|
3152
|
+
}
|
|
3153
|
+
var colSpan = parseInt($elem.attr('colSpan') || '1');
|
|
3154
|
+
var rowSpan = parseInt($elem.attr('rowSpan') || '1');
|
|
3155
|
+
var width = $elem.attr('width') || 'auto';
|
|
3156
|
+
return {
|
|
3157
|
+
type: 'table-cell',
|
|
3158
|
+
isHeader: getTagName($elem) === 'th',
|
|
3159
|
+
colSpan: colSpan,
|
|
3160
|
+
rowSpan: rowSpan,
|
|
3161
|
+
width: width,
|
|
3162
|
+
children: children
|
|
3163
|
+
};
|
|
3164
|
+
}
|
|
3165
|
+
var parseCellHtmlConf = {
|
|
3166
|
+
selector: 'td:not([data-w-e-type]),th:not([data-w-e-type])',
|
|
3167
|
+
parseElemHtml: parseCellHtml
|
|
3168
|
+
};
|
|
3169
|
+
function parseRowHtml(elem, children, editor) {
|
|
3170
|
+
return {
|
|
3171
|
+
type: 'table-row',
|
|
3172
|
+
children: children.filter(function (child) {
|
|
3173
|
+
return DomEditor.getNodeType(child) === 'table-cell';
|
|
3174
|
+
})
|
|
3175
|
+
};
|
|
3176
|
+
}
|
|
3177
|
+
var parseRowHtmlConf = {
|
|
3178
|
+
selector: 'tr:not([data-w-e-type])',
|
|
3179
|
+
parseElemHtml: parseRowHtml
|
|
3180
|
+
};
|
|
3181
|
+
function parseTableHtml(elem, children, editor) {
|
|
3182
|
+
var $elem = $(elem);
|
|
3183
|
+
var width = 'auto';
|
|
3184
|
+
if (getStyleValue($elem, 'width') === '100%') width = '100%';
|
|
3185
|
+
if ($elem.attr('width') === '100%') width = '100%';
|
|
3186
|
+
return {
|
|
3187
|
+
type: 'table',
|
|
3188
|
+
width: width,
|
|
3189
|
+
children: children.filter(function (child) {
|
|
3190
|
+
return DomEditor.getNodeType(child) === 'table-row';
|
|
3191
|
+
})
|
|
3192
|
+
};
|
|
3193
|
+
}
|
|
3194
|
+
var parseTableHtmlConf = {
|
|
3195
|
+
selector: 'table:not([data-w-e-type])',
|
|
3196
|
+
parseElemHtml: parseTableHtml
|
|
3197
|
+
};
|
|
3198
|
+
|
|
3199
|
+
function genTableNode(rowNum, colNum) {
|
|
3200
|
+
var rows = [];
|
|
3201
|
+
for (var i = 0; i < rowNum; i++) {
|
|
3202
|
+
var cells = [];
|
|
3203
|
+
for (var j = 0; j < colNum; j++) {
|
|
3204
|
+
var cellNode = {
|
|
3205
|
+
type: 'table-cell',
|
|
3206
|
+
children: [{
|
|
3207
|
+
text: ''
|
|
3208
|
+
}]
|
|
3209
|
+
};
|
|
3210
|
+
if (i === 0) {
|
|
3211
|
+
cellNode.isHeader = true;
|
|
3212
|
+
}
|
|
3213
|
+
cells.push(cellNode);
|
|
3214
|
+
}
|
|
3215
|
+
rows.push({
|
|
3216
|
+
type: 'table-row',
|
|
3217
|
+
children: cells
|
|
3218
|
+
});
|
|
3219
|
+
}
|
|
3220
|
+
return {
|
|
3221
|
+
type: 'table',
|
|
3222
|
+
width: 'auto',
|
|
3223
|
+
children: rows
|
|
3224
|
+
};
|
|
3225
|
+
}
|
|
3226
|
+
var InsertTable =
|
|
3227
|
+
function () {
|
|
3228
|
+
function InsertTable() {
|
|
3229
|
+
this.title = t('tableModule.insertTable');
|
|
3230
|
+
this.iconSvg = TABLE_SVG;
|
|
3231
|
+
this.tag = 'button';
|
|
3232
|
+
this.showDropPanel = true;
|
|
3233
|
+
this.$content = null;
|
|
3234
|
+
}
|
|
3235
|
+
InsertTable.prototype.getValue = function (editor) {
|
|
3236
|
+
return '';
|
|
3237
|
+
};
|
|
3238
|
+
InsertTable.prototype.isActive = function (editor) {
|
|
3239
|
+
return false;
|
|
3240
|
+
};
|
|
3241
|
+
InsertTable.prototype.exec = function (editor, value) {
|
|
3242
|
+
};
|
|
3243
|
+
InsertTable.prototype.isDisabled = function (editor) {
|
|
3244
|
+
var selection = editor.selection;
|
|
3245
|
+
if (selection == null) return true;
|
|
3246
|
+
if (!Range.isCollapsed(selection)) return true;
|
|
3247
|
+
var selectedElems = DomEditor.getSelectedElems(editor);
|
|
3248
|
+
var hasVoidOrPreOrTable = selectedElems.some(function (elem) {
|
|
3249
|
+
var type = DomEditor.getNodeType(elem);
|
|
3250
|
+
if (type === 'pre') return true;
|
|
3251
|
+
if (type === 'table') return true;
|
|
3252
|
+
if (type === 'list-item') return true;
|
|
3253
|
+
if (editor.isVoid(elem)) return true;
|
|
3254
|
+
return false;
|
|
3255
|
+
});
|
|
3256
|
+
if (hasVoidOrPreOrTable) return true;
|
|
3257
|
+
return false;
|
|
3258
|
+
};
|
|
3259
|
+
InsertTable.prototype.getPanelContentElem = function (editor) {
|
|
3260
|
+
var _this = this;
|
|
3261
|
+
if (this.$content) return this.$content[0];
|
|
3262
|
+
var $content = $('<div class="w-e-panel-content-table"></div>');
|
|
3263
|
+
var $info = $('<span>0 × 0</span>');
|
|
3264
|
+
var $table = $('<table></table>');
|
|
3265
|
+
for (var i = 0; i < 10; i++) {
|
|
3266
|
+
var $tr = $('<tr></tr>');
|
|
3267
|
+
for (var j = 0; j < 10; j++) {
|
|
3268
|
+
var $td = $('<td></td>');
|
|
3269
|
+
$td.attr('data-x', j.toString());
|
|
3270
|
+
$td.attr('data-y', i.toString());
|
|
3271
|
+
$tr.append($td);
|
|
3272
|
+
$td.on('mouseenter', function (e) {
|
|
3273
|
+
var target = e.target;
|
|
3274
|
+
if (target == null) return;
|
|
3275
|
+
var $focusTd = $(target);
|
|
3276
|
+
var _a = $focusTd.dataset(),
|
|
3277
|
+
focusX = _a.x,
|
|
3278
|
+
focusY = _a.y;
|
|
3279
|
+
$info[0].innerHTML = focusX + 1 + " × " + (focusY + 1);
|
|
3280
|
+
$table.children().each(function (tr) {
|
|
3281
|
+
$(tr).children().each(function (td) {
|
|
3282
|
+
var $td = $(td);
|
|
3283
|
+
var _a = $td.dataset(),
|
|
3284
|
+
x = _a.x,
|
|
3285
|
+
y = _a.y;
|
|
3286
|
+
if (x <= focusX && y <= focusY) {
|
|
3287
|
+
$td.addClass('active');
|
|
3288
|
+
} else {
|
|
3289
|
+
$td.removeClass('active');
|
|
3290
|
+
}
|
|
3291
|
+
});
|
|
3292
|
+
});
|
|
3293
|
+
});
|
|
3294
|
+
$td.on('click', function (e) {
|
|
3295
|
+
e.preventDefault();
|
|
3296
|
+
var target = e.target;
|
|
3297
|
+
if (target == null) return;
|
|
3298
|
+
var $td = $(target);
|
|
3299
|
+
var _a = $td.dataset(),
|
|
3300
|
+
x = _a.x,
|
|
3301
|
+
y = _a.y;
|
|
3302
|
+
_this.insertTable(editor, y + 1, x + 1);
|
|
3303
|
+
});
|
|
3304
|
+
}
|
|
3305
|
+
$table.append($tr);
|
|
3306
|
+
}
|
|
3307
|
+
$content.append($table);
|
|
3308
|
+
$content.append($info);
|
|
3309
|
+
this.$content = $content;
|
|
3310
|
+
return $content[0];
|
|
3311
|
+
};
|
|
3312
|
+
InsertTable.prototype.insertTable = function (editor, rowNumStr, colNumStr) {
|
|
3313
|
+
var rowNum = parseInt(rowNumStr, 10);
|
|
3314
|
+
var colNum = parseInt(colNumStr, 10);
|
|
3315
|
+
if (!rowNum || !colNum) return;
|
|
3316
|
+
if (rowNum <= 0 || colNum <= 0) return;
|
|
3317
|
+
if (DomEditor.isSelectedEmptyParagraph(editor)) {
|
|
3318
|
+
Transforms.removeNodes(editor, {
|
|
3319
|
+
mode: 'highest'
|
|
3320
|
+
});
|
|
3321
|
+
}
|
|
3322
|
+
var tableNode = genTableNode(rowNum, colNum);
|
|
3323
|
+
Transforms.insertNodes(editor, tableNode, {
|
|
3324
|
+
mode: 'highest'
|
|
3325
|
+
});
|
|
3326
|
+
};
|
|
3327
|
+
return InsertTable;
|
|
3328
|
+
}();
|
|
3329
|
+
|
|
3330
|
+
var insertTableMenuConf = {
|
|
3331
|
+
key: 'insertTable',
|
|
3332
|
+
factory: function factory() {
|
|
3333
|
+
return new InsertTable();
|
|
3334
|
+
}
|
|
3335
|
+
};
|
|
3336
|
+
var deleteTableMenuConf = {
|
|
3337
|
+
key: 'deleteTable',
|
|
3338
|
+
factory: function factory() {
|
|
3339
|
+
return new DeleteTable();
|
|
3340
|
+
}
|
|
3341
|
+
};
|
|
3342
|
+
var insertTableRowConf = {
|
|
3343
|
+
key: 'insertTableRow',
|
|
3344
|
+
factory: function factory() {
|
|
3345
|
+
return new InsertRow();
|
|
3346
|
+
}
|
|
3347
|
+
};
|
|
3348
|
+
var deleteTableRowConf = {
|
|
3349
|
+
key: 'deleteTableRow',
|
|
3350
|
+
factory: function factory() {
|
|
3351
|
+
return new DeleteRow();
|
|
3352
|
+
}
|
|
3353
|
+
};
|
|
3354
|
+
var insertTableColConf = {
|
|
3355
|
+
key: 'insertTableCol',
|
|
3356
|
+
factory: function factory() {
|
|
3357
|
+
return new InsertCol();
|
|
3358
|
+
}
|
|
3359
|
+
};
|
|
3360
|
+
var deleteTableColConf = {
|
|
3361
|
+
key: 'deleteTableCol',
|
|
3362
|
+
factory: function factory() {
|
|
3363
|
+
return new DeleteCol();
|
|
3364
|
+
}
|
|
3365
|
+
};
|
|
3366
|
+
var tableHeaderMenuConf = {
|
|
3367
|
+
key: 'tableHeader',
|
|
3368
|
+
factory: function factory() {
|
|
3369
|
+
return new TableHeader();
|
|
3370
|
+
}
|
|
3371
|
+
};
|
|
3372
|
+
var tableFullWidthMenuConf = {
|
|
3373
|
+
key: 'tableFullWidth',
|
|
3374
|
+
factory: function factory() {
|
|
3375
|
+
return new TableFullWidth();
|
|
3376
|
+
}
|
|
3377
|
+
};
|
|
3378
|
+
|
|
3379
|
+
var table = {
|
|
3380
|
+
renderElems: [renderTableConf, renderTableRowConf, renderTableCellConf],
|
|
3381
|
+
elemsToHtml: [tableToHtmlConf, tableRowToHtmlConf, tableCellToHtmlConf],
|
|
3382
|
+
preParseHtml: [preParseTableHtmlConf],
|
|
3383
|
+
parseElemsHtml: [parseCellHtmlConf, parseRowHtmlConf, parseTableHtmlConf],
|
|
3384
|
+
menus: [insertTableMenuConf, deleteTableMenuConf, insertTableRowConf, deleteTableRowConf, insertTableColConf, deleteTableColConf, tableHeaderMenuConf, tableFullWidthMenuConf],
|
|
3385
|
+
editorPlugin: withTable
|
|
3386
|
+
};
|
|
3387
|
+
|
|
3388
|
+
export { table as default };
|
|
3389
|
+
//# sourceMappingURL=index.esm.js.map
|