@wangeditor-next/list-module 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.esm.js +2 -815
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2 -822
- package/dist/index.js.map +1 -0
- package/package.json +2 -3
- package/CHANGELOG.md +0 -82
- package/LICENSE +0 -21
package/dist/index.esm.js
CHANGED
|
@@ -1,815 +1,2 @@
|
|
|
1
|
-
import { i18nAddResources, DomEditor, t } from '@wangeditor-next/core';
|
|
2
|
-
|
|
3
|
-
import { jsx } from 'snabbdom';
|
|
4
|
-
import $, { append, attr, parent } from 'dom7';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @description i18n en
|
|
8
|
-
* @author wangfupeng
|
|
9
|
-
*/
|
|
10
|
-
var enResources = {
|
|
11
|
-
listModule: {
|
|
12
|
-
unOrderedList: 'Unordered list',
|
|
13
|
-
orderedList: 'Ordered list',
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @description i18n zh-CN
|
|
19
|
-
* @author wangfupeng
|
|
20
|
-
*/
|
|
21
|
-
var zhResources = {
|
|
22
|
-
listModule: {
|
|
23
|
-
unOrderedList: '无序列表',
|
|
24
|
-
orderedList: '有序列表',
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @description i18n entry
|
|
30
|
-
* @author wangfupeng
|
|
31
|
-
*/
|
|
32
|
-
i18nAddResources('en', enResources);
|
|
33
|
-
i18nAddResources('zh-CN', zhResources);
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @description maps
|
|
37
|
-
* @author wangfupeng
|
|
38
|
-
*/
|
|
39
|
-
var ELEM_TO_EDITOR = new WeakMap();
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @description render list elem
|
|
43
|
-
* @author wangfupeng
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
* 无序列表:根据 level 获取的前置符号
|
|
47
|
-
* @param level 层级
|
|
48
|
-
*/
|
|
49
|
-
function genPreSymbol(level) {
|
|
50
|
-
if (level === void 0) { level = 0; }
|
|
51
|
-
var s = '';
|
|
52
|
-
switch (level) {
|
|
53
|
-
case 0:
|
|
54
|
-
s = '•'; // 第一层级
|
|
55
|
-
break;
|
|
56
|
-
case 1:
|
|
57
|
-
s = '◦'; // 第一层级
|
|
58
|
-
break;
|
|
59
|
-
case 2:
|
|
60
|
-
s = '▪'; // 第三层级
|
|
61
|
-
break;
|
|
62
|
-
default:
|
|
63
|
-
s = '▪'; // 其他层级
|
|
64
|
-
}
|
|
65
|
-
return s;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* 有序列表:获取前缀 number
|
|
69
|
-
* @param editor editor
|
|
70
|
-
* @param elem listItem elem
|
|
71
|
-
*/
|
|
72
|
-
function getOrderedItemNumber(editor, elem) {
|
|
73
|
-
var _a = elem, type = _a.type, _b = _a.level, level = _b === void 0 ? 0 : _b, _c = _a.ordered, ordered = _c === void 0 ? false : _c;
|
|
74
|
-
if (!ordered) {
|
|
75
|
-
return -1; // 不是有序列表
|
|
76
|
-
}
|
|
77
|
-
var num = 1; // 默认值 1
|
|
78
|
-
var curElem = elem;
|
|
79
|
-
var curPath = DomEditor.findPath(editor, curElem);
|
|
80
|
-
// 第一个元素,直接返回 1
|
|
81
|
-
if (curPath[0] === 0)
|
|
82
|
-
return 1;
|
|
83
|
-
while (curPath[0] > 0) {
|
|
84
|
-
var prevPath = Path.previous(curPath);
|
|
85
|
-
var prevEntry = Editor.node(editor, prevPath);
|
|
86
|
-
if (prevEntry == null)
|
|
87
|
-
break;
|
|
88
|
-
var prevElem = prevEntry[0]; // 上一个节点
|
|
89
|
-
var _d = prevElem.level, prevLevel = _d === void 0 ? 0 : _d, prevType = prevElem.type, prevOrdered = prevElem.ordered;
|
|
90
|
-
// type 不一致,退出循环,不再累加 num
|
|
91
|
-
if (prevType !== type)
|
|
92
|
-
break;
|
|
93
|
-
// prevLevel 更小,退出循环,不再累加 num
|
|
94
|
-
if (prevLevel < level)
|
|
95
|
-
break;
|
|
96
|
-
if (prevLevel === level) {
|
|
97
|
-
// level 一样,如果 ordered 不一样,则退出循环,不再累加 num
|
|
98
|
-
if (prevOrdered !== ordered)
|
|
99
|
-
break;
|
|
100
|
-
// level 一样,order 一样,则累加 num
|
|
101
|
-
else
|
|
102
|
-
num++;
|
|
103
|
-
}
|
|
104
|
-
// prevLevel 更大,不累加 num ,继续向前
|
|
105
|
-
curElem = prevElem;
|
|
106
|
-
curPath = prevPath;
|
|
107
|
-
}
|
|
108
|
-
return num;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* 获取第一个 text-node 的颜色
|
|
112
|
-
* @param elem elem
|
|
113
|
-
*/
|
|
114
|
-
function getListItemColor(elem) {
|
|
115
|
-
var children = elem.children || [];
|
|
116
|
-
var length = children.length;
|
|
117
|
-
if (length === 0)
|
|
118
|
-
return '';
|
|
119
|
-
var firstTextNode;
|
|
120
|
-
for (var i = 0; i < length; i++) {
|
|
121
|
-
if (firstTextNode)
|
|
122
|
-
break; // 已找到第一个 text-node ,则退出
|
|
123
|
-
var child = children[i];
|
|
124
|
-
if (Text.isText(child))
|
|
125
|
-
firstTextNode = child;
|
|
126
|
-
}
|
|
127
|
-
if (firstTextNode == null)
|
|
128
|
-
return '';
|
|
129
|
-
return firstTextNode['color'] || '';
|
|
130
|
-
}
|
|
131
|
-
function renderListElem(elemNode, children, editor) {
|
|
132
|
-
ELEM_TO_EDITOR.set(elemNode, editor); // 记录 elem 和 editor 关系,elem-to-html 时要用
|
|
133
|
-
var _a = elemNode, _b = _a.level, level = _b === void 0 ? 0 : _b, _c = _a.ordered, ordered = _c === void 0 ? false : _c;
|
|
134
|
-
// 根据 level 增加 margin-left
|
|
135
|
-
var listStyle = { margin: "5px 0 5px " + level * 20 + "px" };
|
|
136
|
-
// list-item 前缀
|
|
137
|
-
var prefix = '';
|
|
138
|
-
if (ordered) {
|
|
139
|
-
// 有序列表:获取前缀 number
|
|
140
|
-
var orderedNumber = getOrderedItemNumber(editor, elemNode);
|
|
141
|
-
prefix = orderedNumber + ".";
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
// 无序列表:根据层级,使用不同的前缀符号
|
|
145
|
-
prefix = genPreSymbol(level);
|
|
146
|
-
}
|
|
147
|
-
// 获取前缀颜色
|
|
148
|
-
var prefixColor = getListItemColor(elemNode);
|
|
149
|
-
var vnode = (jsx("div", { style: listStyle },
|
|
150
|
-
jsx("span", { contentEditable: false, style: { marginRight: '0.5em', color: prefixColor }, "data-w-e-reserve": true }, prefix),
|
|
151
|
-
jsx("span", null, children)));
|
|
152
|
-
return vnode;
|
|
153
|
-
}
|
|
154
|
-
var renderListItemConf = {
|
|
155
|
-
type: 'list-item',
|
|
156
|
-
renderElem: renderListElem,
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/******************************************************************************
|
|
160
|
-
Copyright (c) Microsoft Corporation.
|
|
161
|
-
|
|
162
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
163
|
-
purpose with or without fee is hereby granted.
|
|
164
|
-
|
|
165
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
166
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
167
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
168
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
169
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
170
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
171
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
172
|
-
***************************************************************************** */
|
|
173
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
174
|
-
|
|
175
|
-
var extendStatics = function(d, b) {
|
|
176
|
-
extendStatics = Object.setPrototypeOf ||
|
|
177
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
178
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
179
|
-
return extendStatics(d, b);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
function __extends(d, b) {
|
|
183
|
-
if (typeof b !== "function" && b !== null)
|
|
184
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
185
|
-
extendStatics(d, b);
|
|
186
|
-
function __() { this.constructor = d; }
|
|
187
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function __rest(s, e) {
|
|
191
|
-
var t = {};
|
|
192
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
193
|
-
t[p] = s[p];
|
|
194
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
195
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
196
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
197
|
-
t[p[i]] = s[p[i]];
|
|
198
|
-
}
|
|
199
|
-
return t;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function __values(o) {
|
|
203
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
204
|
-
if (m) return m.call(o);
|
|
205
|
-
if (o && typeof o.length === "number") return {
|
|
206
|
-
next: function () {
|
|
207
|
-
if (o && i >= o.length) o = void 0;
|
|
208
|
-
return { value: o && o[i++], done: !o };
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function __read(o, n) {
|
|
215
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
216
|
-
if (!m) return o;
|
|
217
|
-
var i = m.call(o), r, ar = [], e;
|
|
218
|
-
try {
|
|
219
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
220
|
-
}
|
|
221
|
-
catch (error) { e = { error: error }; }
|
|
222
|
-
finally {
|
|
223
|
-
try {
|
|
224
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
225
|
-
}
|
|
226
|
-
finally { if (e) throw e.error; }
|
|
227
|
-
}
|
|
228
|
-
return ar;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
232
|
-
var e = new Error(message);
|
|
233
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* @description table menu helpers
|
|
238
|
-
* @author wangfupeng
|
|
239
|
-
*/
|
|
240
|
-
/**
|
|
241
|
-
* 获取上一个同一 level 的 list item
|
|
242
|
-
* @param editor 编辑器实例
|
|
243
|
-
* @param elem elem
|
|
244
|
-
*/
|
|
245
|
-
function getBrotherListNodeByLevel(editor, elem, level) {
|
|
246
|
-
var type = elem.type, otherProps = __rest(elem
|
|
247
|
-
// level 可能是 退格前的值,所以这里需要判断
|
|
248
|
-
, ["type"]);
|
|
249
|
-
// level 可能是 退格前的值,所以这里需要判断
|
|
250
|
-
var elemLevel = level !== undefined ? level : otherProps.level || 0;
|
|
251
|
-
var path = DomEditor.findPath(editor, elem);
|
|
252
|
-
var brotherPath = path;
|
|
253
|
-
// eslint-disable-next-line no-constant-condition
|
|
254
|
-
while (true) {
|
|
255
|
-
if (brotherPath.length === 0 || path[path.length - 1] === 0) {
|
|
256
|
-
return null; // 已经是最后一个节点或没有找到有效的前一个 list 节点
|
|
257
|
-
}
|
|
258
|
-
brotherPath = Path.previous(brotherPath);
|
|
259
|
-
var brotherEntry = Editor.node(editor, brotherPath);
|
|
260
|
-
if (!brotherEntry) {
|
|
261
|
-
return null; // 没有找到有效的前一个 list 节点
|
|
262
|
-
}
|
|
263
|
-
var _a = __read(brotherEntry, 1), brotherElem = _a[0];
|
|
264
|
-
var _b = brotherElem.level, brotherLevel = _b === void 0 ? 0 : _b;
|
|
265
|
-
var brotherType = DomEditor.getNodeType(brotherElem);
|
|
266
|
-
// 验证兄弟节点是否是期望的类型和层级
|
|
267
|
-
if (brotherType !== type) {
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
if (brotherLevel === elemLevel) {
|
|
271
|
-
return brotherElem;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
function hasSameOrderWithBrother(editor, elem, level) {
|
|
276
|
-
var brotherElem = getBrotherListNodeByLevel(editor, elem, level);
|
|
277
|
-
return brotherElem ? brotherElem.ordered === elem.ordered : false;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* @description editor 插件,重写 editor API
|
|
282
|
-
* @author wangfupeng
|
|
283
|
-
*/
|
|
284
|
-
/**
|
|
285
|
-
* 获取选中的 top elems
|
|
286
|
-
* @param editor editor
|
|
287
|
-
*/
|
|
288
|
-
function getTopSelectedElemsBySelection(editor) {
|
|
289
|
-
return Editor.nodes(editor, {
|
|
290
|
-
at: editor.selection || undefined,
|
|
291
|
-
match: function (n) { return DomEditor.findPath(editor, n).length === 1; }, // 只匹配顶级元素
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
function withList(editor) {
|
|
295
|
-
var deleteBackward = editor.deleteBackward, handleTab = editor.handleTab, normalizeNode = editor.normalizeNode, insertBreak = editor.insertBreak;
|
|
296
|
-
var newEditor = editor;
|
|
297
|
-
// 重写 insertBreak - 空 list 点击回车时删除该空 list
|
|
298
|
-
newEditor.insertBreak = function () {
|
|
299
|
-
var _a = __read(Editor.nodes(editor, {
|
|
300
|
-
match: function (n) { return DomEditor.checkNodeType(n, 'list-item'); },
|
|
301
|
-
universal: true,
|
|
302
|
-
}), 1), nodeEntry = _a[0];
|
|
303
|
-
if (!nodeEntry)
|
|
304
|
-
return insertBreak();
|
|
305
|
-
var listElem = nodeEntry[0];
|
|
306
|
-
if (listElem.children[0].text === '') {
|
|
307
|
-
Transforms.setNodes(newEditor, {
|
|
308
|
-
type: 'paragraph',
|
|
309
|
-
ordered: undefined,
|
|
310
|
-
level: undefined,
|
|
311
|
-
});
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
return insertBreak();
|
|
315
|
-
};
|
|
316
|
-
// 重写 deleteBackward - 降低 level 或者转换为 p 元素
|
|
317
|
-
newEditor.deleteBackward = function (unit) {
|
|
318
|
-
var selection = newEditor.selection;
|
|
319
|
-
if (selection == null) {
|
|
320
|
-
deleteBackward(unit);
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
if (Range.isExpanded(selection)) {
|
|
324
|
-
deleteBackward(unit);
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
var listItemElem = DomEditor.getSelectedNodeByType(newEditor, 'list-item');
|
|
328
|
-
if (listItemElem == null) {
|
|
329
|
-
// 未匹配到 list-item
|
|
330
|
-
deleteBackward(unit);
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
if (selection.focus.offset === 0) {
|
|
334
|
-
// 选中了当前 list-item 文本的开头,此时按删除键,应该降低 level 或转换为 p 元素
|
|
335
|
-
var _a = listItemElem, _b = _a.level, level = _b === void 0 ? 0 : _b, _c = _a.ordered, ordered = _c === void 0 ? false : _c;
|
|
336
|
-
if (level > 0) {
|
|
337
|
-
// 如果有兄弟节点,则判断 ordered 是否一致,不一致需要切换 ordered
|
|
338
|
-
var brotherElem = getBrotherListNodeByLevel(editor, listItemElem, level - 1);
|
|
339
|
-
if (brotherElem && brotherElem.ordered !== ordered) {
|
|
340
|
-
Transforms.setNodes(newEditor, { level: level - 1, ordered: !ordered });
|
|
341
|
-
}
|
|
342
|
-
else
|
|
343
|
-
Transforms.setNodes(newEditor, { level: level - 1 });
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
346
|
-
// 转换为 p 元素
|
|
347
|
-
Transforms.setNodes(newEditor, {
|
|
348
|
-
type: 'paragraph',
|
|
349
|
-
ordered: undefined,
|
|
350
|
-
level: undefined,
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
// 其他情况
|
|
356
|
-
deleteBackward(unit);
|
|
357
|
-
};
|
|
358
|
-
// 重写 tab - 当选中 list-item 文本开头时,增加 level
|
|
359
|
-
newEditor.handleTab = function () {
|
|
360
|
-
var e_1, _a, e_2, _b;
|
|
361
|
-
var selection = newEditor.selection;
|
|
362
|
-
if (selection == null) {
|
|
363
|
-
handleTab();
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
// 选区是合并的,判断单个 list-item 即可
|
|
367
|
-
if (Range.isCollapsed(selection)) {
|
|
368
|
-
var listItemElem = DomEditor.getSelectedNodeByType(newEditor, 'list-item');
|
|
369
|
-
if (listItemElem == null) {
|
|
370
|
-
// 未匹配到 list-item
|
|
371
|
-
handleTab();
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
if (selection.focus.offset === 0) {
|
|
375
|
-
// 选中了当前 list-item 文本的开头,此时按 tab 应该增加 level
|
|
376
|
-
var _c = listItemElem.level, level = _c === void 0 ? 0 : _c;
|
|
377
|
-
Transforms.setNodes(newEditor, { level: level + 1 });
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
// 选区是展开的,要判断多个 list-item
|
|
382
|
-
if (Range.isExpanded(selection)) {
|
|
383
|
-
var listItemNum = 0; // 选中的 list-item 有几个
|
|
384
|
-
var hasOtherElem = false; // 是否有其他元素
|
|
385
|
-
try {
|
|
386
|
-
for (var _d = __values(getTopSelectedElemsBySelection(newEditor)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
387
|
-
var entry = _e.value;
|
|
388
|
-
var _f = __read(entry, 1), elem = _f[0];
|
|
389
|
-
var type = DomEditor.getNodeType(elem);
|
|
390
|
-
if (type === 'list-item')
|
|
391
|
-
listItemNum++;
|
|
392
|
-
else
|
|
393
|
-
hasOtherElem = true;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
397
|
-
finally {
|
|
398
|
-
try {
|
|
399
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
400
|
-
}
|
|
401
|
-
finally { if (e_1) throw e_1.error; }
|
|
402
|
-
}
|
|
403
|
-
if (hasOtherElem || listItemNum <= 1) {
|
|
404
|
-
// 选中了其他元素,或者只选中一个 list-item ,则执行默认行为
|
|
405
|
-
handleTab();
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
try {
|
|
409
|
-
// 未选中其他元素,且选中多个 list-item ,则增加 level
|
|
410
|
-
for (var _g = __values(getTopSelectedElemsBySelection(newEditor)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
411
|
-
var entry = _h.value;
|
|
412
|
-
var _j = __read(entry, 2), elem = _j[0], path = _j[1];
|
|
413
|
-
var _k = elem.level, level = _k === void 0 ? 0 : _k;
|
|
414
|
-
Transforms.setNodes(newEditor, { level: level + 1 }, { at: path });
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
418
|
-
finally {
|
|
419
|
-
try {
|
|
420
|
-
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
421
|
-
}
|
|
422
|
-
finally { if (e_2) throw e_2.error; }
|
|
423
|
-
}
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
// 其他情况
|
|
427
|
-
handleTab();
|
|
428
|
-
};
|
|
429
|
-
// 兼容之前的 JSON 格式 `numbered-list` 和 `bulleted-list` (之前的 list 没有嵌套功能)
|
|
430
|
-
newEditor.normalizeNode = function (_a) {
|
|
431
|
-
var _b = __read(_a, 2), node = _b[0], path = _b[1];
|
|
432
|
-
var type = DomEditor.getNodeType(node);
|
|
433
|
-
if (type === 'bulleted-list' || type === 'numbered-list') {
|
|
434
|
-
Transforms.unwrapNodes(newEditor, { at: path });
|
|
435
|
-
}
|
|
436
|
-
// 执行默认行为
|
|
437
|
-
return normalizeNode([node, path]);
|
|
438
|
-
};
|
|
439
|
-
return newEditor;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* @description base menu
|
|
444
|
-
* @author wangfupeng
|
|
445
|
-
*/
|
|
446
|
-
var BaseMenu = /** @class */ (function () {
|
|
447
|
-
function BaseMenu() {
|
|
448
|
-
this.type = 'list-item';
|
|
449
|
-
this.tag = 'button';
|
|
450
|
-
}
|
|
451
|
-
BaseMenu.prototype.getListNode = function (editor) {
|
|
452
|
-
var type = this.type;
|
|
453
|
-
return DomEditor.getSelectedNodeByType(editor, type);
|
|
454
|
-
};
|
|
455
|
-
BaseMenu.prototype.getValue = function (editor) {
|
|
456
|
-
return '';
|
|
457
|
-
};
|
|
458
|
-
BaseMenu.prototype.isActive = function (editor) {
|
|
459
|
-
var node = this.getListNode(editor);
|
|
460
|
-
if (node == null)
|
|
461
|
-
return false;
|
|
462
|
-
var _a = node.ordered, ordered = _a === void 0 ? false : _a;
|
|
463
|
-
return ordered === this.ordered;
|
|
464
|
-
};
|
|
465
|
-
BaseMenu.prototype.isDisabled = function (editor) {
|
|
466
|
-
if (editor.selection == null)
|
|
467
|
-
return true;
|
|
468
|
-
var selectedElems = DomEditor.getSelectedElems(editor);
|
|
469
|
-
var notMatch = selectedElems.some(function (elem) {
|
|
470
|
-
if (Editor.isVoid(editor, elem) && Editor.isBlock(editor, elem))
|
|
471
|
-
return true;
|
|
472
|
-
var type = elem.type;
|
|
473
|
-
if (['pre', 'code', 'table'].includes(type))
|
|
474
|
-
return true;
|
|
475
|
-
});
|
|
476
|
-
if (notMatch)
|
|
477
|
-
return true;
|
|
478
|
-
return false;
|
|
479
|
-
};
|
|
480
|
-
BaseMenu.prototype.exec = function (editor, value) {
|
|
481
|
-
var active = this.isActive(editor);
|
|
482
|
-
if (active) {
|
|
483
|
-
// 如果当前 active ,则转换为 p 标签
|
|
484
|
-
Transforms.setNodes(editor, {
|
|
485
|
-
type: 'paragraph',
|
|
486
|
-
ordered: undefined,
|
|
487
|
-
level: undefined,
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
else {
|
|
491
|
-
// 否则,转换为 list-item
|
|
492
|
-
Transforms.setNodes(editor, {
|
|
493
|
-
type: 'list-item',
|
|
494
|
-
ordered: this.ordered,
|
|
495
|
-
indent: undefined,
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
};
|
|
499
|
-
return BaseMenu;
|
|
500
|
-
}());
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* @description icon svg
|
|
504
|
-
* @author wangfupeng
|
|
505
|
-
*/
|
|
506
|
-
/**
|
|
507
|
-
* 【注意】svg 字符串的长度 ,否则会导致代码体积过大
|
|
508
|
-
* 尽量选择 https://www.iconfont.cn/collections/detail?spm=a313x.7781069.0.da5a778a4&cid=20293
|
|
509
|
-
* 找不到再从 iconfont.com 搜索
|
|
510
|
-
*/
|
|
511
|
-
// 无序列表
|
|
512
|
-
var BULLETED_LIST_SVG = '<svg viewBox="0 0 1024 1024"><path d="M384 64h640v128H384V64z m0 384h640v128H384v-128z m0 384h640v128H384v-128zM0 128a128 128 0 1 1 256 0 128 128 0 0 1-256 0z m0 384a128 128 0 1 1 256 0 128 128 0 0 1-256 0z m0 384a128 128 0 1 1 256 0 128 128 0 0 1-256 0z"></path></svg>';
|
|
513
|
-
// 有序列表
|
|
514
|
-
var NUMBERED_LIST_SVG = '<svg viewBox="0 0 1024 1024"><path d="M384 832h640v128H384z m0-384h640v128H384z m0-384h640v128H384zM192 0v256H128V64H64V0zM128 526.016v50.016h128v64H64v-146.016l128-60V384H64v-64h192v146.016zM256 704v320H64v-64h128v-64H64v-64h128v-64H64v-64z"></path></svg>';
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* @description bulleted list menu
|
|
518
|
-
* @author wangfupeng
|
|
519
|
-
*/
|
|
520
|
-
var BulletedListMenu = /** @class */ (function (_super) {
|
|
521
|
-
__extends(BulletedListMenu, _super);
|
|
522
|
-
function BulletedListMenu() {
|
|
523
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
524
|
-
_this.ordered = false;
|
|
525
|
-
_this.title = t('listModule.unOrderedList');
|
|
526
|
-
_this.iconSvg = BULLETED_LIST_SVG;
|
|
527
|
-
return _this;
|
|
528
|
-
}
|
|
529
|
-
return BulletedListMenu;
|
|
530
|
-
}(BaseMenu));
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* @description numbered list menu
|
|
534
|
-
* @author wangfupeng
|
|
535
|
-
*/
|
|
536
|
-
var NumberedListMenu = /** @class */ (function (_super) {
|
|
537
|
-
__extends(NumberedListMenu, _super);
|
|
538
|
-
function NumberedListMenu() {
|
|
539
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
540
|
-
_this.ordered = true;
|
|
541
|
-
_this.title = t('listModule.orderedList');
|
|
542
|
-
_this.iconSvg = NUMBERED_LIST_SVG;
|
|
543
|
-
return _this;
|
|
544
|
-
}
|
|
545
|
-
return NumberedListMenu;
|
|
546
|
-
}(BaseMenu));
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* @description menu entry
|
|
550
|
-
* @author wangfupeng
|
|
551
|
-
*/
|
|
552
|
-
var bulletedListMenuConf = {
|
|
553
|
-
key: 'bulletedList',
|
|
554
|
-
factory: function () {
|
|
555
|
-
return new BulletedListMenu();
|
|
556
|
-
},
|
|
557
|
-
};
|
|
558
|
-
var numberedListMenuConf = {
|
|
559
|
-
key: 'numberedList',
|
|
560
|
-
factory: function () {
|
|
561
|
-
return new NumberedListMenu();
|
|
562
|
-
},
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* @description to html
|
|
567
|
-
* @author wangfupeng
|
|
568
|
-
*/
|
|
569
|
-
/**
|
|
570
|
-
* 当前 list-item 前面需要拼接几个 <ol> 或 <ul>
|
|
571
|
-
* @param elem elem
|
|
572
|
-
*/
|
|
573
|
-
function getStartContainerTagNumber(elem) {
|
|
574
|
-
var editor = ELEM_TO_EDITOR.get(elem);
|
|
575
|
-
if (editor == null)
|
|
576
|
-
return 0;
|
|
577
|
-
var _a = elem, type = _a.type, _b = _a.ordered, ordered = _b === void 0 ? false : _b, _c = _a.level, level = _c === void 0 ? 0 : _c;
|
|
578
|
-
var path = DomEditor.findPath(editor, elem);
|
|
579
|
-
if (path[0] === 0) {
|
|
580
|
-
// list-item 是第一个元素,再往前没有了。需要拼接 <ol> 或 <ul>
|
|
581
|
-
return level + 1;
|
|
582
|
-
}
|
|
583
|
-
// 获取上一个 elem
|
|
584
|
-
var prevPath = Path.previous(path);
|
|
585
|
-
var prevEntry = Editor.node(editor, prevPath);
|
|
586
|
-
if (!prevEntry)
|
|
587
|
-
return 0;
|
|
588
|
-
var _d = __read(prevEntry, 1), prevElem = _d[0];
|
|
589
|
-
var prevType = DomEditor.getNodeType(prevElem);
|
|
590
|
-
if (prevType !== type) {
|
|
591
|
-
// 上一个 elem 不是 list-item ,需要拼接 <ol> 或 <ul>
|
|
592
|
-
return level + 1;
|
|
593
|
-
}
|
|
594
|
-
// 上一个 elem 是 list-item
|
|
595
|
-
var _e = prevElem, _f = _e.ordered, prevOrdered = _f === void 0 ? false : _f, _g = _e.level, prevLevel = _g === void 0 ? 0 : _g;
|
|
596
|
-
if (prevLevel < level) {
|
|
597
|
-
// 上一个 level 小于当前 level ,需要拼接 <ol> 或 <ul>
|
|
598
|
-
return level - prevLevel;
|
|
599
|
-
}
|
|
600
|
-
if (prevLevel > level) {
|
|
601
|
-
// 此处需要看上一个同级兄弟节点 ordered 是否一致,如果一致则不需要拼接,否则需要拼接
|
|
602
|
-
return hasSameOrderWithBrother(editor, elem) ? 0 : 1;
|
|
603
|
-
}
|
|
604
|
-
if (prevLevel === level) {
|
|
605
|
-
// 上一个 level 等于当前 level
|
|
606
|
-
if (prevOrdered === ordered) {
|
|
607
|
-
// ordered 一致,则不需要拼接 <ol> 或 <ul>
|
|
608
|
-
return 0;
|
|
609
|
-
}
|
|
610
|
-
else {
|
|
611
|
-
/// ordered 不一致,则需要拼接 <ol> 或 <ul>
|
|
612
|
-
return 1;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
// 其他情况
|
|
616
|
-
return 0;
|
|
617
|
-
}
|
|
618
|
-
/**
|
|
619
|
-
* 当前 list-item 后面面需要拼接几个 </ol> 或 </ul>
|
|
620
|
-
* @param elem elem
|
|
621
|
-
*/
|
|
622
|
-
function getEndContainerTagNumber(elem) {
|
|
623
|
-
var editor = ELEM_TO_EDITOR.get(elem);
|
|
624
|
-
if (editor == null)
|
|
625
|
-
return 0;
|
|
626
|
-
var _a = elem, type = _a.type, _b = _a.ordered, ordered = _b === void 0 ? false : _b, _c = _a.level, level = _c === void 0 ? 0 : _c;
|
|
627
|
-
var path = DomEditor.findPath(editor, elem);
|
|
628
|
-
if (path[0] === editor.children.length - 1) {
|
|
629
|
-
// list-item 是最后一个元素,再往后没有了。需要拼接 </ol> 或 </ul>
|
|
630
|
-
return level + 1;
|
|
631
|
-
}
|
|
632
|
-
// 获取下一个 elem
|
|
633
|
-
var nextPath = Path.next(path);
|
|
634
|
-
var nextEntry = Editor.node(editor, nextPath);
|
|
635
|
-
if (!nextEntry)
|
|
636
|
-
return 0;
|
|
637
|
-
var _d = __read(nextEntry, 1), nextElem = _d[0];
|
|
638
|
-
var nextType = DomEditor.getNodeType(nextElem);
|
|
639
|
-
if (nextType !== type) {
|
|
640
|
-
// 下一个 elem 不是 list-item ,需要拼接 <ol> 或 <ul>
|
|
641
|
-
return level + 1;
|
|
642
|
-
}
|
|
643
|
-
// 下一个 elem 是 list-item
|
|
644
|
-
var _e = nextElem, _f = _e.ordered, nextOrdered = _f === void 0 ? false : _f, _g = _e.level, nextLevel = _g === void 0 ? 0 : _g;
|
|
645
|
-
if (nextLevel < level) {
|
|
646
|
-
// 下一个 level 小于当前 level,此处需要看上一个同级兄弟节点 ordered 是否一致,如果一致则不需要拼接,否则需要拼接
|
|
647
|
-
if (hasSameOrderWithBrother(editor, nextElem)) {
|
|
648
|
-
// ordered 一致,则不需要额外拼接 </ol> 或 </ul>
|
|
649
|
-
return level - nextLevel;
|
|
650
|
-
}
|
|
651
|
-
else {
|
|
652
|
-
// ordered 不一致,则需要额外拼接 </ol> 或 </ul>
|
|
653
|
-
return level - nextLevel + 1;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
if (nextLevel > level) {
|
|
657
|
-
// 下一个 level 大于当前 level ,不需要拼接 </ol> 或 </ul>
|
|
658
|
-
return 0;
|
|
659
|
-
}
|
|
660
|
-
if (nextLevel === level) {
|
|
661
|
-
// 下一个 level 等于当前 level
|
|
662
|
-
if (nextOrdered === ordered) {
|
|
663
|
-
// ordered 一致,则不需要拼接 </ol> 或 </ul>
|
|
664
|
-
return 0;
|
|
665
|
-
}
|
|
666
|
-
else {
|
|
667
|
-
/// ordered 不一致,则需要拼接 </ol> 或 </ul>
|
|
668
|
-
return 1;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
// 其他情况
|
|
672
|
-
return 0;
|
|
673
|
-
}
|
|
674
|
-
// ol ul 栈
|
|
675
|
-
var CONTAINER_TAG_STACK = [];
|
|
676
|
-
function elemToHtml(elem, childrenHtml) {
|
|
677
|
-
var startContainerStr = '';
|
|
678
|
-
var endContainerStr = '';
|
|
679
|
-
var _a = elem.ordered, ordered = _a === void 0 ? false : _a;
|
|
680
|
-
var containerTag = ordered ? 'ol' : 'ul';
|
|
681
|
-
// 前面需要拼接几个 <ol> 或 <ul>
|
|
682
|
-
var startContainerTagNumber = getStartContainerTagNumber(elem);
|
|
683
|
-
if (startContainerTagNumber > 0) {
|
|
684
|
-
for (var i = 0; i < startContainerTagNumber; i++) {
|
|
685
|
-
startContainerStr += "<" + containerTag + ">"; // 记录 start container tag ,如 `<ul>`
|
|
686
|
-
CONTAINER_TAG_STACK.push(containerTag); // tag 压栈
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
// 后面需要拼接几个 </ol> 或 </ul>
|
|
690
|
-
var endContainerTagNumber = getEndContainerTagNumber(elem);
|
|
691
|
-
if (endContainerTagNumber > 0) {
|
|
692
|
-
for (var i = 0; i < endContainerTagNumber; i++) {
|
|
693
|
-
var tag = CONTAINER_TAG_STACK.pop(); // tag 从栈中获取
|
|
694
|
-
endContainerStr += "</" + tag + ">"; // 记录 end container tag ,如 `</ul>`
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
return {
|
|
698
|
-
html: "<li>" + childrenHtml + "</li>",
|
|
699
|
-
prefix: startContainerStr,
|
|
700
|
-
suffix: endContainerStr,
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
var listItemToHtmlConf = {
|
|
704
|
-
type: 'list-item',
|
|
705
|
-
elemToHtml: elemToHtml,
|
|
706
|
-
};
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
* @description DOM 操作
|
|
710
|
-
* @author wangfupeng
|
|
711
|
-
*/
|
|
712
|
-
if (append)
|
|
713
|
-
$.fn.append = append;
|
|
714
|
-
// if (on) $.fn.on = on
|
|
715
|
-
// if (focus) $.fn.focus = focus
|
|
716
|
-
if (attr)
|
|
717
|
-
$.fn.attr = attr;
|
|
718
|
-
// if (val) $.fn.val = val
|
|
719
|
-
// if (html) $.fn.html = html
|
|
720
|
-
if (parent)
|
|
721
|
-
$.fn.parent = parent;
|
|
722
|
-
/**
|
|
723
|
-
* 获取 tagName lower-case
|
|
724
|
-
* @param $elem $elem
|
|
725
|
-
*/
|
|
726
|
-
function getTagName($elem) {
|
|
727
|
-
if ($elem.length)
|
|
728
|
-
return $elem[0].tagName.toLowerCase();
|
|
729
|
-
return '';
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/**
|
|
733
|
-
* @description parse elem html
|
|
734
|
-
* @author wangfupeng
|
|
735
|
-
*/
|
|
736
|
-
/**
|
|
737
|
-
* 获取 ordered
|
|
738
|
-
* @param $elem list $elem
|
|
739
|
-
*/
|
|
740
|
-
function getOrdered($elem) {
|
|
741
|
-
var $list = $elem.parent();
|
|
742
|
-
var listTagName = getTagName($list);
|
|
743
|
-
if (listTagName === 'ol')
|
|
744
|
-
return true;
|
|
745
|
-
return false;
|
|
746
|
-
}
|
|
747
|
-
/**
|
|
748
|
-
* 获取 level
|
|
749
|
-
* @param $elem list $elem
|
|
750
|
-
*/
|
|
751
|
-
function getLevel($elem) {
|
|
752
|
-
var level = 0;
|
|
753
|
-
var $cur = $elem.parent();
|
|
754
|
-
var tagName = getTagName($cur);
|
|
755
|
-
while (tagName === 'ul' || tagName === 'ol') {
|
|
756
|
-
$cur = $cur.parent();
|
|
757
|
-
tagName = getTagName($cur);
|
|
758
|
-
level++;
|
|
759
|
-
}
|
|
760
|
-
return level - 1;
|
|
761
|
-
}
|
|
762
|
-
function parseItemHtml(elem, children, editor) {
|
|
763
|
-
var $elem = $(elem);
|
|
764
|
-
children = children.filter(function (child) {
|
|
765
|
-
if (Text.isText(child))
|
|
766
|
-
return true;
|
|
767
|
-
if (editor.isInline(child))
|
|
768
|
-
return true;
|
|
769
|
-
return false;
|
|
770
|
-
});
|
|
771
|
-
// 无 children ,则用纯文本
|
|
772
|
-
if (children.length === 0) {
|
|
773
|
-
children = [{ text: $elem.text().replace(/\s+/gm, ' ') }];
|
|
774
|
-
}
|
|
775
|
-
var ordered = getOrdered($elem);
|
|
776
|
-
var level = getLevel($elem);
|
|
777
|
-
return {
|
|
778
|
-
type: 'list-item',
|
|
779
|
-
ordered: ordered,
|
|
780
|
-
level: level,
|
|
781
|
-
// @ts-ignore
|
|
782
|
-
children: children,
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
var parseItemHtmlConf = {
|
|
786
|
-
selector: 'li:not([data-w-e-type])',
|
|
787
|
-
parseElemHtml: parseItemHtml,
|
|
788
|
-
};
|
|
789
|
-
function parseListHtml(elem, children, editor) {
|
|
790
|
-
// @ts-ignore flatten 因为可能有 ul/ol 嵌套,重要!!!
|
|
791
|
-
return children.flat(Infinity);
|
|
792
|
-
}
|
|
793
|
-
var parseListHtmlConf = {
|
|
794
|
-
selector: 'ul:not([data-w-e-type]),ol:not([data-w-e-type])',
|
|
795
|
-
parseElemHtml: parseListHtml,
|
|
796
|
-
};
|
|
797
|
-
|
|
798
|
-
/**
|
|
799
|
-
* @description list module entry
|
|
800
|
-
* @author wangfupeng
|
|
801
|
-
*/
|
|
802
|
-
var list = {
|
|
803
|
-
renderElems: [renderListItemConf],
|
|
804
|
-
editorPlugin: withList,
|
|
805
|
-
menus: [bulletedListMenuConf, numberedListMenuConf],
|
|
806
|
-
elemsToHtml: [listItemToHtmlConf],
|
|
807
|
-
parseElemsHtml: [parseListHtmlConf, parseItemHtmlConf],
|
|
808
|
-
};
|
|
809
|
-
|
|
810
|
-
/**
|
|
811
|
-
* @description list module
|
|
812
|
-
* @author wangfupeng
|
|
813
|
-
*/
|
|
814
|
-
|
|
815
|
-
export { list as default };
|
|
1
|
+
import{i18nAddResources as t,DomEditor as e,t as r}from"@wangeditor-next/core";import{Path as n,Editor as o,Text as i,Transforms as u,Range as a}from"slate";import{jsx as c}from"snabbdom";import f,{append as l,attr as s,parent as d}from"dom7";t("en",{listModule:{unOrderedList:"Unordered list",orderedList:"Ordered list"}}),t("zh-CN",{listModule:{unOrderedList:"无序列表",orderedList:"有序列表"}});var v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function p(t){var e={exports:{}};return t(e,e.exports),e.exports}var y,h,g=function(t){return t&&t.Math==Math&&t},b=g("object"==typeof globalThis&&globalThis)||g("object"==typeof window&&window)||g("object"==typeof self&&self)||g("object"==typeof v&&v)||function(){return this}()||Function("return this")(),m=Function.prototype,w=m.bind,O=m.call,x=w&&w.bind(O),S=w?function(t){return t&&x(O,t)}:function(t){return t&&function(){return O.apply(t,arguments)}},E=function(t){try{return!!t()}catch(t){return!0}},j=S({}.toString),T=S("".slice),A=function(t){return T(j(t),8,-1)},I=b.Object,P=S("".split),k=E((function(){return!I("z").propertyIsEnumerable(0)}))?function(t){return"String"==A(t)?P(t,""):I(t)}:I,L=b.TypeError,R=function(t){if(null==t)throw L("Can't call method on "+t);return t},N=function(t){return k(R(t))},_=Object.defineProperty,M=function(t,e){try{_(b,t,{value:e,configurable:!0,writable:!0})}catch(r){b[t]=e}return e},z=b["__core-js_shared__"]||M("__core-js_shared__",{}),C=p((function(t){(t.exports=function(t,e){return z[t]||(z[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.19.3",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),F=b.Object,B=function(t){return F(R(t))},D=S({}.hasOwnProperty),H=Object.hasOwn||function(t,e){return D(B(t),e)},G=0,$=Math.random(),V=S(1..toString),W=function(t){return"Symbol("+(void 0===t?"":t)+")_"+V(++G+$,36)},U=function(t){return"function"==typeof t},K=function(t){return U(t)?t:void 0},Y=function(t,e){return arguments.length<2?K(b[t]):b[t]&&b[t][e]},X=Y("navigator","userAgent")||"",q=b.process,J=b.Deno,Q=q&&q.versions||J&&J.version,Z=Q&&Q.v8;Z&&(h=(y=Z.split("."))[0]>0&&y[0]<4?1:+(y[0]+y[1])),!h&&X&&(!(y=X.match(/Edge\/(\d+)/))||y[1]>=74)&&(y=X.match(/Chrome\/(\d+)/))&&(h=+y[1]);var tt,et=h,rt=!!Object.getOwnPropertySymbols&&!E((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&et&&et<41})),nt=rt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ot=C("wks"),it=b.Symbol,ut=it&&it.for,at=nt?it:it&&it.withoutSetter||W,ct=function(t){if(!H(ot,t)||!rt&&"string"!=typeof ot[t]){var e="Symbol."+t;rt&&H(it,t)?ot[t]=it[t]:ot[t]=nt&&ut?ut(e):at(e)}return ot[t]},ft=function(t){return"object"==typeof t?null!==t:U(t)},lt=b.String,st=b.TypeError,dt=function(t){if(ft(t))return t;throw st(lt(t)+" is not an object")},vt=!E((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),pt=b.document,yt=ft(pt)&&ft(pt.createElement),ht=function(t){return yt?pt.createElement(t):{}},gt=!vt&&!E((function(){return 7!=Object.defineProperty(ht("div"),"a",{get:function(){return 7}}).a})),bt=Function.prototype.call,mt=bt.bind?bt.bind(bt):function(){return bt.apply(bt,arguments)},wt=S({}.isPrototypeOf),Ot=b.Object,xt=nt?function(t){return"symbol"==typeof t}:function(t){var e=Y("Symbol");return U(e)&&wt(e.prototype,Ot(t))},St=b.String,Et=function(t){try{return St(t)}catch(t){return"Object"}},jt=b.TypeError,Tt=function(t){if(U(t))return t;throw jt(Et(t)+" is not a function")},At=function(t,e){var r=t[e];return null==r?void 0:Tt(r)},It=b.TypeError,Pt=b.TypeError,kt=ct("toPrimitive"),Lt=function(t,e){if(!ft(t)||xt(t))return t;var r,n=At(t,kt);if(n){if(void 0===e&&(e="default"),r=mt(n,t,e),!ft(r)||xt(r))return r;throw Pt("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(t,e){var r,n;if("string"===e&&U(r=t.toString)&&!ft(n=mt(r,t)))return n;if(U(r=t.valueOf)&&!ft(n=mt(r,t)))return n;if("string"!==e&&U(r=t.toString)&&!ft(n=mt(r,t)))return n;throw It("Can't convert object to primitive value")}(t,e)},Rt=function(t){var e=Lt(t,"string");return xt(e)?e:e+""},Nt=b.TypeError,_t=Object.defineProperty,Mt={f:vt?_t:function(t,e,r){if(dt(t),e=Rt(e),dt(r),gt)try{return _t(t,e,r)}catch(t){}if("get"in r||"set"in r)throw Nt("Accessors not supported");return"value"in r&&(t[e]=r.value),t}},zt=Math.ceil,Ct=Math.floor,Ft=function(t){var e=+t;return e!=e||0===e?0:(e>0?Ct:zt)(e)},Bt=Math.max,Dt=Math.min,Ht=function(t,e){var r=Ft(t);return r<0?Bt(r+e,0):Dt(r,e)},Gt=Math.min,$t=function(t){return t>0?Gt(Ft(t),9007199254740991):0},Vt=function(t){return $t(t.length)},Wt=function(t){return function(e,r,n){var o,i=N(e),u=Vt(i),a=Ht(n,u);if(t&&r!=r){for(;u>a;)if((o=i[a++])!=o)return!0}else for(;u>a;a++)if((t||a in i)&&i[a]===r)return t||a||0;return!t&&-1}},Ut={includes:Wt(!0),indexOf:Wt(!1)},Kt={},Yt=Ut.indexOf,Xt=S([].push),qt=function(t,e){var r,n=N(t),o=0,i=[];for(r in n)!H(Kt,r)&&H(n,r)&&Xt(i,r);for(;e.length>o;)H(n,r=e[o++])&&(~Yt(i,r)||Xt(i,r));return i},Jt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Qt=Object.keys||function(t){return qt(t,Jt)},Zt=vt?Object.defineProperties:function(t,e){dt(t);for(var r,n=N(e),o=Qt(e),i=o.length,u=0;i>u;)Mt.f(t,r=o[u++],n[r]);return t},te=Y("document","documentElement"),ee=C("keys"),re=function(t){return ee[t]||(ee[t]=W(t))},ne=re("IE_PROTO"),oe=function(){},ie=function(t){return"<script>"+t+"<\/script>"},ue=function(t){t.write(ie("")),t.close();var e=t.parentWindow.Object;return t=null,e},ae=function(){try{tt=new ActiveXObject("htmlfile")}catch(t){}var t,e;ae="undefined"!=typeof document?document.domain&&tt?ue(tt):((e=ht("iframe")).style.display="none",te.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(ie("document.F=Object")),t.close(),t.F):ue(tt);for(var r=Jt.length;r--;)delete ae.prototype[Jt[r]];return ae()};Kt[ne]=!0;var ce=Object.create||function(t,e){var r;return null!==t?(oe.prototype=dt(t),r=new oe,oe.prototype=null,r[ne]=t):r=ae(),void 0===e?r:Zt(r,e)},fe=ct("unscopables"),le=Array.prototype;null==le[fe]&&Mt.f(le,fe,{configurable:!0,value:ce(null)});var se=function(t){le[fe][t]=!0},de={},ve=S(Function.toString);U(z.inspectSource)||(z.inspectSource=function(t){return ve(t)});var pe,ye,he,ge=z.inspectSource,be=b.WeakMap,me=U(be)&&/native code/.test(ge(be)),we=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Oe=vt?function(t,e,r){return Mt.f(t,e,we(1,r))}:function(t,e,r){return t[e]=r,t},xe=b.TypeError,Se=b.WeakMap;if(me||z.state){var Ee=z.state||(z.state=new Se),je=S(Ee.get),Te=S(Ee.has),Ae=S(Ee.set);pe=function(t,e){if(Te(Ee,t))throw new xe("Object already initialized");return e.facade=t,Ae(Ee,t,e),e},ye=function(t){return je(Ee,t)||{}},he=function(t){return Te(Ee,t)}}else{var Ie=re("state");Kt[Ie]=!0,pe=function(t,e){if(H(t,Ie))throw new xe("Object already initialized");return e.facade=t,Oe(t,Ie,e),e},ye=function(t){return H(t,Ie)?t[Ie]:{}},he=function(t){return H(t,Ie)}}var Pe,ke,Le,Re={set:pe,get:ye,has:he,enforce:function(t){return he(t)?ye(t):pe(t,{})},getterFor:function(t){return function(e){var r;if(!ft(e)||(r=ye(e)).type!==t)throw xe("Incompatible receiver, "+t+" required");return r}}},Ne={}.propertyIsEnumerable,_e=Object.getOwnPropertyDescriptor,Me={f:_e&&!Ne.call({1:2},1)?function(t){var e=_e(this,t);return!!e&&e.enumerable}:Ne},ze=Object.getOwnPropertyDescriptor,Ce={f:vt?ze:function(t,e){if(t=N(t),e=Rt(e),gt)try{return ze(t,e)}catch(t){}if(H(t,e))return we(!mt(Me.f,t,e),t[e])}},Fe=Function.prototype,Be=vt&&Object.getOwnPropertyDescriptor,De=H(Fe,"name"),He={EXISTS:De,PROPER:De&&"something"===function(){}.name,CONFIGURABLE:De&&(!vt||vt&&Be(Fe,"name").configurable)},Ge=p((function(t){var e=He.CONFIGURABLE,r=Re.get,n=Re.enforce,o=String(String).split("String");(t.exports=function(t,r,i,u){var a,c=!!u&&!!u.unsafe,f=!!u&&!!u.enumerable,l=!!u&&!!u.noTargetGet,s=u&&void 0!==u.name?u.name:r;U(i)&&("Symbol("===String(s).slice(0,7)&&(s="["+String(s).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!H(i,"name")||e&&i.name!==s)&&Oe(i,"name",s),(a=n(i)).source||(a.source=o.join("string"==typeof s?s:""))),t!==b?(c?!l&&t[r]&&(f=!0):delete t[r],f?t[r]=i:Oe(t,r,i)):f?t[r]=i:M(r,i)})(Function.prototype,"toString",(function(){return U(this)&&r(this).source||ge(this)}))})),$e=Jt.concat("length","prototype"),Ve={f:Object.getOwnPropertyNames||function(t){return qt(t,$e)}},We={f:Object.getOwnPropertySymbols},Ue=S([].concat),Ke=Y("Reflect","ownKeys")||function(t){var e=Ve.f(dt(t)),r=We.f;return r?Ue(e,r(t)):e},Ye=function(t,e){for(var r=Ke(e),n=Mt.f,o=Ce.f,i=0;i<r.length;i++){var u=r[i];H(t,u)||n(t,u,o(e,u))}},Xe=/#|\.prototype\./,qe=function(t,e){var r=Qe[Je(t)];return r==tr||r!=Ze&&(U(e)?E(e):!!e)},Je=qe.normalize=function(t){return String(t).replace(Xe,".").toLowerCase()},Qe=qe.data={},Ze=qe.NATIVE="N",tr=qe.POLYFILL="P",er=qe,rr=Ce.f,nr=function(t,e){var r,n,o,i,u,a=t.target,c=t.global,f=t.stat;if(r=c?b:f?b[a]||M(a,{}):(b[a]||{}).prototype)for(n in e){if(i=e[n],o=t.noTargetGet?(u=rr(r,n))&&u.value:r[n],!er(c?n:a+(f?".":"#")+n,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;Ye(i,o)}(t.sham||o&&o.sham)&&Oe(i,"sham",!0),Ge(r,n,i,t)}},or=!E((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),ir=re("IE_PROTO"),ur=b.Object,ar=ur.prototype,cr=or?ur.getPrototypeOf:function(t){var e=B(t);if(H(e,ir))return e[ir];var r=e.constructor;return U(r)&&e instanceof r?r.prototype:e instanceof ur?ar:null},fr=ct("iterator"),lr=!1;[].keys&&("next"in(Le=[].keys())?(ke=cr(cr(Le)))!==Object.prototype&&(Pe=ke):lr=!0);var sr=null==Pe||E((function(){var t={};return Pe[fr].call(t)!==t}));sr&&(Pe={}),U(Pe[fr])||Ge(Pe,fr,(function(){return this}));var dr={IteratorPrototype:Pe,BUGGY_SAFARI_ITERATORS:lr},vr=Mt.f,pr=ct("toStringTag"),yr=function(t,e,r){t&&!H(t=r?t:t.prototype,pr)&&vr(t,pr,{configurable:!0,value:e})},hr=dr.IteratorPrototype,gr=function(){return this},br=b.String,mr=b.TypeError,wr=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,r={};try{(t=S(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),e=r instanceof Array}catch(t){}return function(r,n){return dt(r),function(t){if("object"==typeof t||U(t))return t;throw mr("Can't set "+br(t)+" as a prototype")}(n),e?t(r,n):r.__proto__=n,r}}():void 0),Or=He.PROPER,xr=He.CONFIGURABLE,Sr=dr.IteratorPrototype,Er=dr.BUGGY_SAFARI_ITERATORS,jr=ct("iterator"),Tr=function(){return this},Ar=function(t,e,r,n,o,i,u){!function(t,e,r,n){var o=e+" Iterator";t.prototype=ce(hr,{next:we(+!n,r)}),yr(t,o,!1),de[o]=gr}(r,e,n);var a,c,f,l=function(t){if(t===o&&y)return y;if(!Er&&t in v)return v[t];switch(t){case"keys":case"values":case"entries":return function(){return new r(this,t)}}return function(){return new r(this)}},s=e+" Iterator",d=!1,v=t.prototype,p=v[jr]||v["@@iterator"]||o&&v[o],y=!Er&&p||l(o),h="Array"==e&&v.entries||p;if(h&&(a=cr(h.call(new t)))!==Object.prototype&&a.next&&(cr(a)!==Sr&&(wr?wr(a,Sr):U(a[jr])||Ge(a,jr,Tr)),yr(a,s,!0)),Or&&"values"==o&&p&&"values"!==p.name&&(xr?Oe(v,"name","values"):(d=!0,y=function(){return mt(p,this)})),o)if(c={values:l("values"),keys:i?y:l("keys"),entries:l("entries")},u)for(f in c)(Er||d||!(f in v))&&Ge(v,f,c[f]);else nr({target:e,proto:!0,forced:Er||d},c);return v[jr]!==y&&Ge(v,jr,y,{name:o}),de[e]=y,c},Ir=Re.set,Pr=Re.getterFor("Array Iterator"),kr=Ar(Array,"Array",(function(t,e){Ir(this,{type:"Array Iterator",target:N(t),index:0,kind:e})}),(function(){var t=Pr(this),e=t.target,r=t.kind,n=t.index++;return!e||n>=e.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==r?{value:n,done:!1}:"values"==r?{value:e[n],done:!1}:{value:[n,e[n]],done:!1}}),"values");de.Arguments=de.Array,se("keys"),se("values"),se("entries");var Lr={};Lr[ct("toStringTag")]="z";var Rr="[object z]"===String(Lr),Nr=ct("toStringTag"),_r=b.Object,Mr="Arguments"==A(function(){return arguments}()),zr=Rr?A:function(t){var e,r,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=_r(t),Nr))?r:Mr?A(e):"Object"==(n=A(e))&&U(e.callee)?"Arguments":n},Cr=Rr?{}.toString:function(){return"[object "+zr(this)+"]"};Rr||Ge(Object.prototype,"toString",Cr,{unsafe:!0});var Fr=b.String,Br=function(t){if("Symbol"===zr(t))throw TypeError("Cannot convert a Symbol value to a string");return Fr(t)},Dr=S("".charAt),Hr=S("".charCodeAt),Gr=S("".slice),$r=function(t){return function(e,r){var n,o,i=Br(R(e)),u=Ft(r),a=i.length;return u<0||u>=a?t?"":void 0:(n=Hr(i,u))<55296||n>56319||u+1===a||(o=Hr(i,u+1))<56320||o>57343?t?Dr(i,u):n:t?Gr(i,u,u+2):o-56320+(n-55296<<10)+65536}},Vr={codeAt:$r(!1),charAt:$r(!0)},Wr=Vr.charAt,Ur=Re.set,Kr=Re.getterFor("String Iterator");Ar(String,"String",(function(t){Ur(this,{type:"String Iterator",string:Br(t),index:0})}),(function(){var t,e=Kr(this),r=e.string,n=e.index;return n>=r.length?{value:void 0,done:!0}:(t=Wr(r,n),e.index+=t.length,{value:t,done:!1})}));var Yr=function(t,e,r){for(var n in e)Ge(t,n,e[n],r);return t},Xr=b.Array,qr=Math.max,Jr=Ve.f,Qr="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Zr=function(t){try{return Jr(t)}catch(t){return function(t,e,r){for(var n,o,i,u,a=Vt(t),c=Ht(e,a),f=Ht(void 0===r?a:r,a),l=Xr(qr(f-c,0)),s=0;c<f;c++,s++)n=l,o=s,i=t[c],u=void 0,(u=Rt(o))in n?Mt.f(n,u,we(0,i)):n[u]=i;return l.length=s,l}(Qr)}},tn={f:function(t){return Qr&&"Window"==A(t)?Zr(t):Jr(N(t))}},en=E((function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})),rn=Object.isExtensible,nn=E((function(){rn(1)}))||en?function(t){return!!ft(t)&&((!en||"ArrayBuffer"!=A(t))&&(!rn||rn(t)))}:rn,on=!E((function(){return Object.isExtensible(Object.preventExtensions({}))})),un=p((function(t){var e=Mt.f,r=!1,n=W("meta"),o=0,i=function(t){e(t,n,{value:{objectID:"O"+o++,weakData:{}}})},u=t.exports={enable:function(){u.enable=function(){},r=!0;var t=Ve.f,e=S([].splice),o={};o[n]=1,t(o).length&&(Ve.f=function(r){for(var o=t(r),i=0,u=o.length;i<u;i++)if(o[i]===n){e(o,i,1);break}return o},nr({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:tn.f}))},fastKey:function(t,e){if(!ft(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!H(t,n)){if(!nn(t))return"F";if(!e)return"E";i(t)}return t[n].objectID},getWeakData:function(t,e){if(!H(t,n)){if(!nn(t))return!0;if(!e)return!1;i(t)}return t[n].weakData},onFreeze:function(t){return on&&r&&nn(t)&&!H(t,n)&&i(t),t}};Kt[n]=!0})),an=S(S.bind),cn=function(t,e){return Tt(t),void 0===e?t:an?an(t,e):function(){return t.apply(e,arguments)}},fn=ct("iterator"),ln=Array.prototype,sn=ct("iterator"),dn=function(t){if(null!=t)return At(t,sn)||At(t,"@@iterator")||de[zr(t)]},vn=b.TypeError,pn=function(t,e,r){var n,o;dt(t);try{if(!(n=At(t,"return"))){if("throw"===e)throw r;return r}n=mt(n,t)}catch(t){o=!0,n=t}if("throw"===e)throw r;if(o)throw n;return dt(n),r},yn=b.TypeError,hn=function(t,e){this.stopped=t,this.result=e},gn=hn.prototype,bn=function(t,e,r){var n,o,i,u,a,c,f,l,s=r&&r.that,d=!(!r||!r.AS_ENTRIES),v=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),y=cn(e,s),h=function(t){return n&&pn(n,"normal",t),new hn(!0,t)},g=function(t){return d?(dt(t),p?y(t[0],t[1],h):y(t[0],t[1])):p?y(t,h):y(t)};if(v)n=t;else{if(!(o=dn(t)))throw yn(Et(t)+" is not iterable");if(void 0!==(l=o)&&(de.Array===l||ln[fn]===l)){for(i=0,u=Vt(t);u>i;i++)if((a=g(t[i]))&&wt(gn,a))return a;return new hn(!1)}n=function(t,e){var r=arguments.length<2?dn(t):e;if(Tt(r))return dt(mt(r,t));throw vn(Et(t)+" is not iterable")}(t,o)}for(c=n.next;!(f=mt(c,n)).done;){try{a=g(f.value)}catch(t){pn(n,"throw",t)}if("object"==typeof a&&a&&wt(gn,a))return a}return new hn(!1)},mn=b.TypeError,wn=function(t,e){if(wt(e,t))return t;throw mn("Incorrect invocation")},On=ct("iterator"),xn=!1;try{var Sn=0,En={next:function(){return{done:!!Sn++}},return:function(){xn=!0}};En[On]=function(){return this},Array.from(En,(function(){throw 2}))}catch(t){}var jn=Array.isArray||function(t){return"Array"==A(t)},Tn=function(){},An=[],In=Y("Reflect","construct"),Pn=/^\s*(?:class|function)\b/,kn=S(Pn.exec),Ln=!Pn.exec(Tn),Rn=function(t){if(!U(t))return!1;try{return In(Tn,An,t),!0}catch(t){return!1}},Nn=!In||E((function(){var t;return Rn(Rn.call)||!Rn(Object)||!Rn((function(){t=!0}))||t}))?function(t){if(!U(t))return!1;switch(zr(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}return Ln||!!kn(Pn,ge(t))}:Rn,_n=ct("species"),Mn=b.Array,zn=function(t,e){return new(function(t){var e;return jn(t)&&(e=t.constructor,(Nn(e)&&(e===Mn||jn(e.prototype))||ft(e)&&null===(e=e[_n]))&&(e=void 0)),void 0===e?Mn:e}(t))(0===e?0:e)},Cn=S([].push),Fn=function(t){var e=1==t,r=2==t,n=3==t,o=4==t,i=6==t,u=7==t,a=5==t||i;return function(c,f,l,s){for(var d,v,p=B(c),y=k(p),h=cn(f,l),g=Vt(y),b=0,m=s||zn,w=e?m(c,g):r||u?m(c,0):void 0;g>b;b++)if((a||b in y)&&(v=h(d=y[b],b,p),t))if(e)w[b]=v;else if(v)switch(t){case 3:return!0;case 5:return d;case 6:return b;case 2:Cn(w,d)}else switch(t){case 4:return!1;case 7:Cn(w,d)}return i?-1:n||o?o:w}},Bn={forEach:Fn(0),map:Fn(1),filter:Fn(2),some:Fn(3),every:Fn(4),find:Fn(5),findIndex:Fn(6),filterReject:Fn(7)},Dn=un.getWeakData,Hn=Re.set,Gn=Re.getterFor,$n=Bn.find,Vn=Bn.findIndex,Wn=S([].splice),Un=0,Kn=function(t){return t.frozen||(t.frozen=new Yn)},Yn=function(){this.entries=[]},Xn=function(t,e){return $n(t.entries,(function(t){return t[0]===e}))};Yn.prototype={get:function(t){var e=Xn(this,t);if(e)return e[1]},has:function(t){return!!Xn(this,t)},set:function(t,e){var r=Xn(this,t);r?r[1]=e:this.entries.push([t,e])},delete:function(t){var e=Vn(this.entries,(function(e){return e[0]===t}));return~e&&Wn(this.entries,e,1),!!~e}};var qn,Jn={getConstructor:function(t,e,r,n){var o=t((function(t,o){wn(t,i),Hn(t,{type:e,id:Un++,frozen:void 0}),null!=o&&bn(o,t[n],{that:t,AS_ENTRIES:r})})),i=o.prototype,u=Gn(e),a=function(t,e,r){var n=u(t),o=Dn(dt(e),!0);return!0===o?Kn(n).set(e,r):o[n.id]=r,t};return Yr(i,{delete:function(t){var e=u(this);if(!ft(t))return!1;var r=Dn(t);return!0===r?Kn(e).delete(t):r&&H(r,e.id)&&delete r[e.id]},has:function(t){var e=u(this);if(!ft(t))return!1;var r=Dn(t);return!0===r?Kn(e).has(t):r&&H(r,e.id)}}),Yr(i,r?{get:function(t){var e=u(this);if(ft(t)){var r=Dn(t);return!0===r?Kn(e).get(t):r?r[e.id]:void 0}},set:function(t,e){return a(this,t,e)}}:{add:function(t){return a(this,t,!0)}}),o}},Qn=Re.enforce,Zn=!b.ActiveXObject&&"ActiveXObject"in b,to=function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},eo=function(t,e,r){var n=-1!==t.indexOf("Map"),o=-1!==t.indexOf("Weak"),i=n?"set":"add",u=b[t],a=u&&u.prototype,c=u,f={},l=function(t){var e=S(a[t]);Ge(a,t,"add"==t?function(t){return e(this,0===t?0:t),this}:"delete"==t?function(t){return!(o&&!ft(t))&&e(this,0===t?0:t)}:"get"==t?function(t){return o&&!ft(t)?void 0:e(this,0===t?0:t)}:"has"==t?function(t){return!(o&&!ft(t))&&e(this,0===t?0:t)}:function(t,r){return e(this,0===t?0:t,r),this})};if(er(t,!U(u)||!(o||a.forEach&&!E((function(){(new u).entries().next()})))))c=r.getConstructor(e,t,n,i),un.enable();else if(er(t,!0)){var s=new c,d=s[i](o?{}:-0,1)!=s,v=E((function(){s.has(1)})),p=function(t,e){if(!e&&!xn)return!1;var r=!1;try{var n={};n[On]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r}((function(t){new u(t)})),y=!o&&E((function(){for(var t=new u,e=5;e--;)t[i](e,e);return!t.has(-0)}));p||((c=e((function(t,e){wn(t,a);var r=function(t,e,r){var n,o;return wr&&U(n=e.constructor)&&n!==r&&ft(o=n.prototype)&&o!==r.prototype&&wr(t,o),t}(new u,t,c);return null!=e&&bn(e,r[i],{that:r,AS_ENTRIES:n}),r}))).prototype=a,a.constructor=c),(v||y)&&(l("delete"),l("has"),n&&l("get")),(y||d)&&l(i),o&&a.clear&&delete a.clear}return f[t]=c,nr({global:!0,forced:c!=u},f),yr(c,t),o||r.setStrong(c,t,n),c}("WeakMap",to,Jn);if(me&&Zn){qn=Jn.getConstructor(to,"WeakMap",!0),un.enable();var ro=eo.prototype,no=S(ro.delete),oo=S(ro.has),io=S(ro.get),uo=S(ro.set);Yr(ro,{delete:function(t){if(ft(t)&&!nn(t)){var e=Qn(this);return e.frozen||(e.frozen=new qn),no(this,t)||e.frozen.delete(t)}return no(this,t)},has:function(t){if(ft(t)&&!nn(t)){var e=Qn(this);return e.frozen||(e.frozen=new qn),oo(this,t)||e.frozen.has(t)}return oo(this,t)},get:function(t){if(ft(t)&&!nn(t)){var e=Qn(this);return e.frozen||(e.frozen=new qn),oo(this,t)?io(this,t):e.frozen.get(t)}return io(this,t)},set:function(t,e){if(ft(t)&&!nn(t)){var r=Qn(this);r.frozen||(r.frozen=new qn),oo(this,t)?uo(this,t,e):r.frozen.set(t,e)}else uo(this,t,e);return this}})}var ao={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},co=ht("span").classList,fo=co&&co.constructor&&co.constructor.prototype,lo=fo===Object.prototype?void 0:fo,so=ct("iterator"),vo=ct("toStringTag"),po=kr.values,yo=function(t,e){if(t){if(t[so]!==po)try{Oe(t,so,po)}catch(e){t[so]=po}if(t[vo]||Oe(t,vo,e),ao[e])for(var r in kr)if(t[r]!==kr[r])try{Oe(t,r,kr[r])}catch(e){t[r]=kr[r]}}};for(var ho in ao)yo(b[ho]&&b[ho].prototype,ho);yo(lo,"DOMTokenList");var go=new WeakMap;var bo={type:"list-item",renderElem:function(t,r,u){go.set(t,u);var a=t,f=a.level,l=void 0===f?0:f,s=a.ordered,d={margin:"5px 0 5px "+20*l+"px"},v="";if(void 0!==s&&s){var p=function(t,r){var i=r,u=i.type,a=i.level,c=void 0===a?0:a,f=i.ordered,l=void 0!==f&&f,s=1,d=r,v=e.findPath(t,d);if(0===v[0])return 1;for(;v[0]>0;){var p=n.previous(v),y=o.node(t,p);if(null==y)break;var h=y[0],g=h.level,b=void 0===g?0:g,m=h.type,w=h.ordered;if(m!==u)break;if(b<c)break;if(b===c){if(w!==l)break;s++}d=h,v=p}return s}(u,t);v=p+"."}else v=function(t){void 0===t&&(t=0);var e="";switch(t){case 0:e="•";break;case 1:e="◦";break;default:e="▪"}return e}(l);var y=function(t){var e,r=t.children||[],n=r.length;if(0===n)return"";for(var o=0;o<n&&!e;o++){var u=r[o];i.isText(u)&&(e=u)}return null==e?"":e.color||""}(t);return c("div",{style:d},c("span",{contentEditable:!1,style:{marginRight:"0.5em",color:y},"data-w-e-reserve":!0},v),c("span",null,r))}},mo=function(t,e){return mo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},mo(t,e)};function wo(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}mo(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function Oo(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function xo(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function So(t,r,i){for(var u=r.type,a=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(r,["type"]),c=void 0!==i?i:a.level||0,f=e.findPath(t,r),l=f;;){if(0===l.length||0===f[f.length-1])return null;l=n.previous(l);var s=o.node(t,l);if(!s)return null;var d=xo(s,1)[0],v=d.level,p=void 0===v?0:v;if(e.getNodeType(d)!==u)return null;if(p===c)return d}}function Eo(t,e,r){var n=So(t,e,r);return!!n&&n.ordered===e.ordered}function jo(t){return o.nodes(t,{at:t.selection||void 0,match:function(r){return 1===e.findPath(t,r).length}})}"function"==typeof SuppressedError&&SuppressedError;var To=Ut.includes;nr({target:"Array",proto:!0},{includes:function(t){return To(this,t,arguments.length>1?arguments[1]:void 0)}}),se("includes");var Ao,Io,Po=function(){var t=dt(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e},ko=b.RegExp,Lo=E((function(){var t=ko("a","y");return t.lastIndex=2,null!=t.exec("abcd")})),Ro=Lo||E((function(){return!ko("a","y").sticky})),No={BROKEN_CARET:Lo||E((function(){var t=ko("^r","gy");return t.lastIndex=2,null!=t.exec("str")})),MISSED_STICKY:Ro,UNSUPPORTED_Y:Lo},_o=b.RegExp,Mo=E((function(){var t=_o(".","s");return!(t.dotAll&&t.exec("\n")&&"s"===t.flags)})),zo=b.RegExp,Co=E((function(){var t=zo("(?<a>b)","g");return"b"!==t.exec("b").groups.a||"bc"!=="b".replace(t,"$<a>c")})),Fo=Re.get,Bo=C("native-string-replace",String.prototype.replace),Do=RegExp.prototype.exec,Ho=Do,Go=S("".charAt),$o=S("".indexOf),Vo=S("".replace),Wo=S("".slice),Uo=(Io=/b*/g,mt(Do,Ao=/a/,"a"),mt(Do,Io,"a"),0!==Ao.lastIndex||0!==Io.lastIndex),Ko=No.BROKEN_CARET,Yo=void 0!==/()??/.exec("")[1];(Uo||Yo||Ko||Mo||Co)&&(Ho=function(t){var e,r,n,o,i,u,a,c=this,f=Fo(c),l=Br(t),s=f.raw;if(s)return s.lastIndex=c.lastIndex,e=mt(Ho,s,l),c.lastIndex=s.lastIndex,e;var d=f.groups,v=Ko&&c.sticky,p=mt(Po,c),y=c.source,h=0,g=l;if(v&&(p=Vo(p,"y",""),-1===$o(p,"g")&&(p+="g"),g=Wo(l,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==Go(l,c.lastIndex-1))&&(y="(?: "+y+")",g=" "+g,h++),r=new RegExp("^(?:"+y+")",p)),Yo&&(r=new RegExp("^"+y+"$(?!\\s)",p)),Uo&&(n=c.lastIndex),o=mt(Do,v?r:c,g),v?o?(o.input=Wo(o.input,h),o[0]=Wo(o[0],h),o.index=c.lastIndex,c.lastIndex+=o[0].length):c.lastIndex=0:Uo&&o&&(c.lastIndex=c.global?o.index+o[0].length:n),Yo&&o&&o.length>1&&mt(Bo,o[0],r,(function(){for(i=1;i<arguments.length-2;i++)void 0===arguments[i]&&(o[i]=void 0)})),o&&d)for(o.groups=u=ce(null),i=0;i<d.length;i++)u[(a=d[i])[0]]=o[a[1]];return o});var Xo=Ho;nr({target:"RegExp",proto:!0,forced:/./.exec!==Xo},{exec:Xo});var qo=function(){function t(){this.type="list-item",this.tag="button"}return t.prototype.getListNode=function(t){var r=this.type;return e.getSelectedNodeByType(t,r)},t.prototype.getValue=function(t){return""},t.prototype.isActive=function(t){var e=this.getListNode(t);if(null==e)return!1;var r=e.ordered;return(void 0!==r&&r)===this.ordered},t.prototype.isDisabled=function(t){return null==t.selection||!!e.getSelectedElems(t).some((function(e){if(o.isVoid(t,e)&&o.isBlock(t,e))return!0;var r=e.type;return!!["pre","code","table"].includes(r)||void 0}))},t.prototype.exec=function(t,e){this.isActive(t)?u.setNodes(t,{type:"paragraph",ordered:void 0,level:void 0}):u.setNodes(t,{type:"list-item",ordered:this.ordered,indent:void 0})},t}(),Jo='<svg viewBox="0 0 1024 1024"><path d="M384 64h640v128H384V64z m0 384h640v128H384v-128z m0 384h640v128H384v-128zM0 128a128 128 0 1 1 256 0 128 128 0 0 1-256 0z m0 384a128 128 0 1 1 256 0 128 128 0 0 1-256 0z m0 384a128 128 0 1 1 256 0 128 128 0 0 1-256 0z"></path></svg>',Qo='<svg viewBox="0 0 1024 1024"><path d="M384 832h640v128H384z m0-384h640v128H384z m0-384h640v128H384zM192 0v256H128V64H64V0zM128 526.016v50.016h128v64H64v-146.016l128-60V384H64v-64h192v146.016zM256 704v320H64v-64h128v-64H64v-64h128v-64H64v-64z"></path></svg>',Zo=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ordered=!1,e.title=r("listModule.unOrderedList"),e.iconSvg=Jo,e}return wo(e,t),e}(qo),ti=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ordered=!0,e.title=r("listModule.orderedList"),e.iconSvg=Qo,e}return wo(e,t),e}(qo),ei={key:"bulletedList",factory:function(){return new Zo}},ri={key:"numberedList",factory:function(){return new ti}};var ni=[];var oi,ii={type:"list-item",elemToHtml:function(t,r){var i="",u="",a=t.ordered,c=void 0!==a&&a?"ol":"ul",f=function(t){var r=go.get(t);if(null==r)return 0;var i=t,u=i.type,a=i.ordered,c=void 0!==a&&a,f=i.level,l=void 0===f?0:f,s=e.findPath(r,t);if(0===s[0])return l+1;var d=n.previous(s),v=o.node(r,d);if(!v)return 0;var p=xo(v,1)[0];if(e.getNodeType(p)!==u)return l+1;var y=p,h=y.ordered,g=void 0!==h&&h,b=y.level,m=void 0===b?0:b;return m<l?l-m:m>l?Eo(r,t)?0:1:m===l?g===c?0:1:0}(t);if(f>0)for(var l=0;l<f;l++)i+="<"+c+">",ni.push(c);var s=function(t){var r=go.get(t);if(null==r)return 0;var i=t,u=i.type,a=i.ordered,c=void 0!==a&&a,f=i.level,l=void 0===f?0:f,s=e.findPath(r,t);if(s[0]===r.children.length-1)return l+1;var d=n.next(s),v=o.node(r,d);if(!v)return 0;var p=xo(v,1)[0];if(e.getNodeType(p)!==u)return l+1;var y=p,h=y.ordered,g=void 0!==h&&h,b=y.level,m=void 0===b?0:b;return m<l?Eo(r,p)?l-m:l-m+1:m>l?0:m===l?g===c?0:1:0}(t);if(s>0)for(l=0;l<s;l++){u+="</"+ni.pop()+">"}return{html:"<li>"+r+"</li>",prefix:i,suffix:u}}},ui=ct("species"),ai=Bn.filter,ci=(oi="filter",et>=51||!E((function(){var t=[];return(t.constructor={})[ui]=function(){return{foo:1}},1!==t[oi](Boolean).foo})));nr({target:"Array",proto:!0,forced:!ci},{filter:function(t){return ai(this,t,arguments.length>1?arguments[1]:void 0)}});var fi=Function.prototype,li=fi.apply,si=fi.bind,di=fi.call,vi="object"==typeof Reflect&&Reflect.apply||(si?di.bind(li):function(){return di.apply(li,arguments)}),pi=ct("species"),yi=RegExp.prototype,hi=Vr.charAt,gi=function(t,e,r){return e+(r?hi(t,e).length:1)},bi=Math.floor,mi=S("".charAt),wi=S("".replace),Oi=S("".slice),xi=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Si=/\$([$&'`]|\d{1,2})/g,Ei=function(t,e,r,n,o,i){var u=r+t.length,a=n.length,c=Si;return void 0!==o&&(o=B(o),c=xi),wi(i,c,(function(i,c){var f;switch(mi(c,0)){case"$":return"$";case"&":return t;case"`":return Oi(e,0,r);case"'":return Oi(e,u);case"<":f=o[Oi(c,1,-1)];break;default:var l=+c;if(0===l)return i;if(l>a){var s=bi(l/10);return 0===s?i:s<=a?void 0===n[s-1]?mi(c,1):n[s-1]+mi(c,1):i}f=n[l-1]}return void 0===f?"":f}))},ji=b.TypeError,Ti=function(t,e){var r=t.exec;if(U(r)){var n=mt(r,t,e);return null!==n&&dt(n),n}if("RegExp"===A(t))return mt(Xo,t,e);throw ji("RegExp#exec called on incompatible receiver")},Ai=ct("replace"),Ii=Math.max,Pi=Math.min,ki=S([].concat),Li=S([].push),Ri=S("".indexOf),Ni=S("".slice),_i="$0"==="a".replace(/./,"$0"),Mi=!!/./[Ai]&&""===/./[Ai]("a","$0");!function(t,e,r,n){var o=ct(t),i=!E((function(){var e={};return e[o]=function(){return 7},7!=""[t](e)})),u=i&&!E((function(){var e=!1,r=/a/;return"split"===t&&((r={}).constructor={},r.constructor[pi]=function(){return r},r.flags="",r[o]=/./[o]),r.exec=function(){return e=!0,null},r[o](""),!e}));if(!i||!u||r){var a=S(/./[o]),c=e(o,""[t],(function(t,e,r,n,o){var u=S(t),c=e.exec;return c===Xo||c===yi.exec?i&&!o?{done:!0,value:a(e,r,n)}:{done:!0,value:u(r,e,n)}:{done:!1}}));Ge(String.prototype,t,c[0]),Ge(yi,o,c[1])}n&&Oe(yi[o],"sham",!0)}("replace",(function(t,e,r){var n=Mi?"$":"$0";return[function(t,r){var n=R(this),o=null==t?void 0:At(t,Ai);return o?mt(o,t,n,r):mt(e,Br(n),t,r)},function(t,o){var i=dt(this),u=Br(t);if("string"==typeof o&&-1===Ri(o,n)&&-1===Ri(o,"$<")){var a=r(e,i,u,o);if(a.done)return a.value}var c=U(o);c||(o=Br(o));var f=i.global;if(f){var l=i.unicode;i.lastIndex=0}for(var s=[];;){var d=Ti(i,u);if(null===d)break;if(Li(s,d),!f)break;""===Br(d[0])&&(i.lastIndex=gi(u,$t(i.lastIndex),l))}for(var v,p="",y=0,h=0;h<s.length;h++){for(var g=Br((d=s[h])[0]),b=Ii(Pi(Ft(d.index),u.length),0),m=[],w=1;w<d.length;w++)Li(m,void 0===(v=d[w])?v:String(v));var O=d.groups;if(c){var x=ki([g],m,b,u);void 0!==O&&Li(x,O);var S=Br(vi(o,void 0,x))}else S=Ei(g,u,b,m,O,o);b>=y&&(p+=Ni(u,y,b)+S,y=b+g.length)}return p+Ni(u,y)}]}),!!E((function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")}))||!_i||Mi);var zi=b.TypeError,Ci=function(t,e,r,n,o,i,u,a){for(var c,f,l=o,s=0,d=!!u&&cn(u,a);s<n;){if(s in r){if(c=d?d(r[s],s,e):r[s],i>0&&jn(c))f=Vt(c),l=Ci(t,e,c,f,l,i-1)-1;else{if(l>=9007199254740991)throw zi("Exceed the acceptable array length");t[l]=c}l++}s++}return l},Fi=Ci;function Bi(t){return t.length?t[0].tagName.toLowerCase():""}nr({target:"Array",proto:!0},{flat:function(){var t=arguments.length?arguments[0]:void 0,e=B(this),r=Vt(e),n=zn(e,0);return n.length=Fi(n,e,e,r,0,void 0===t?1:Ft(t)),n}}),se("flat"),nr({global:!0},{globalThis:b}),l&&(f.fn.append=l),s&&(f.fn.attr=s),d&&(f.fn.parent=d);var Di={renderElems:[bo],editorPlugin:function(t){var r=t.deleteBackward,n=t.handleTab,i=t.normalizeNode,c=t.insertBreak,f=t;return f.insertBreak=function(){var r=xo(o.nodes(t,{match:function(t){return e.checkNodeType(t,"list-item")},universal:!0}),1)[0];return r?""!==r[0].children[0].text?c():void u.setNodes(f,{type:"paragraph",ordered:void 0,level:void 0}):c()},f.deleteBackward=function(n){var o=f.selection;if(null!=o)if(a.isExpanded(o))r(n);else{var i=e.getSelectedNodeByType(f,"list-item");if(null!=i)if(0!==o.focus.offset)r(n);else{var c=i,l=c.level,s=void 0===l?0:l,d=c.ordered,v=void 0!==d&&d;if(s>0){var p=So(t,i,s-1);p&&p.ordered!==v?u.setNodes(f,{level:s-1,ordered:!v}):u.setNodes(f,{level:s-1})}else u.setNodes(f,{type:"paragraph",ordered:void 0,level:void 0})}else r(n)}else r(n)},f.handleTab=function(){var t,r,o,i,c=f.selection;if(null!=c){if(a.isCollapsed(c)){var l=e.getSelectedNodeByType(f,"list-item");if(null==l)return void n();if(0===c.focus.offset){var s=l.level,d=void 0===s?0:s;return void u.setNodes(f,{level:d+1})}}if(a.isExpanded(c)){var v=0,p=!1;try{for(var y=Oo(jo(f)),h=y.next();!h.done;h=y.next()){var g=xo(h.value,1)[0];"list-item"===e.getNodeType(g)?v++:p=!0}}catch(e){t={error:e}}finally{try{h&&!h.done&&(r=y.return)&&r.call(y)}finally{if(t)throw t.error}}if(p||v<=1)return void n();try{for(var b=Oo(jo(f)),m=b.next();!m.done;m=b.next()){var w=xo(m.value,2),O=(g=w[0],w[1]),x=g.level;d=void 0===x?0:x;u.setNodes(f,{level:d+1},{at:O})}}catch(t){o={error:t}}finally{try{m&&!m.done&&(i=b.return)&&i.call(b)}finally{if(o)throw o.error}}}else n()}else n()},f.normalizeNode=function(t){var r=xo(t,2),n=r[0],o=r[1],a=e.getNodeType(n);return"bulleted-list"!==a&&"numbered-list"!==a||u.unwrapNodes(f,{at:o}),i([n,o])},f},menus:[ei,ri],elemsToHtml:[ii],parseElemsHtml:[{selector:"ul:not([data-w-e-type]),ol:not([data-w-e-type])",parseElemHtml:function(t,e,r){return e.flat(1/0)}},{selector:"li:not([data-w-e-type])",parseElemHtml:function(t,e,r){var n=f(t);0===(e=e.filter((function(t){return!!i.isText(t)||!!r.isInline(t)}))).length&&(e=[{text:n.text().replace(/\s+/gm," ")}]);var o=function(t){return"ol"===Bi(t.parent())}(n),u=function(t){for(var e=0,r=t.parent(),n=Bi(r);"ul"===n||"ol"===n;)n=Bi(r=r.parent()),e++;return e-1}(n);return{type:"list-item",ordered:o,level:u,children:e}}}]};export{Di as default};
|
|
2
|
+
//# sourceMappingURL=index.esm.js.map
|