@wangeditor-next/plugin-formula 0.0.13-beta.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -1,1230 +1,2 @@
1
- import katex from 'katex';
2
- import { i18nAddResources, t, DomEditor, SlateRange, genModalTextareaElems, genModalButtonElems, SlateTransforms } from '@wangeditor-next/editor';
3
- import { h } from 'snabbdom';
4
-
5
- /******************************************************************************
6
- Copyright (c) Microsoft Corporation.
7
-
8
- Permission to use, copy, modify, and/or distribute this software for any
9
- purpose with or without fee is hereby granted.
10
-
11
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
- PERFORMANCE OF THIS SOFTWARE.
18
- ***************************************************************************** */
19
- /* global Reflect, Promise, SuppressedError, Symbol */
20
-
21
- var extendStatics = function(d, b) {
22
- extendStatics = Object.setPrototypeOf ||
23
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
25
- return extendStatics(d, b);
26
- };
27
-
28
- function __extends(d, b) {
29
- if (typeof b !== "function" && b !== null)
30
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
31
- extendStatics(d, b);
32
- function __() { this.constructor = d; }
33
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
- }
35
-
36
- function __read(o, n) {
37
- var m = typeof Symbol === "function" && o[Symbol.iterator];
38
- if (!m) return o;
39
- var i = m.call(o), r, ar = [], e;
40
- try {
41
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
42
- }
43
- catch (error) { e = { error: error }; }
44
- finally {
45
- try {
46
- if (r && !r.done && (m = i["return"])) m.call(i);
47
- }
48
- finally { if (e) throw e.error; }
49
- }
50
- return ar;
51
- }
52
-
53
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
54
- var e = new Error(message);
55
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
56
- };
57
-
58
- // @ts-nocheck
59
- // 参考 https://github.com/webcomponents/custom-elements/blob/master/src/native-shim.js
60
- /**
61
- * @license
62
- * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
63
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
64
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
65
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
66
- * Code distributed by Google as part of the polymer project is also
67
- * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
68
- */
69
- /**
70
- * This shim allows elements written in, or compiled to, ES5 to work on native
71
- * implementations of Custom Elements v1. It sets new.target to the value of
72
- * this.constructor so that the native HTMLElement constructor can access the
73
- * current under-construction element's definition.
74
- */
75
- (function () {
76
- if (
77
- // No Reflect, no classes, no need for shim because native custom elements
78
- // require ES2015 classes or Reflect.
79
- window.Reflect === undefined
80
- || window.customElements === undefined
81
- // The webcomponentsjs custom elements polyfill doesn't require
82
- // ES2015-compatible construction (`super()` or `Reflect.construct`).
83
- || window.customElements.polyfillWrapFlushCallback) {
84
- return;
85
- }
86
- var BuiltInHTMLElement = HTMLElement;
87
- /**
88
- * With jscompiler's RECOMMENDED_FLAGS the function name will be optimized away.
89
- * However, if we declare the function as a property on an object literal, and
90
- * use quotes for the property name, then closure will leave that much intact,
91
- * which is enough for the JS VM to correctly set Function.prototype.name.
92
- */
93
- var wrapperForTheName = {
94
- // eslint-disable-next-line func-names
95
- HTMLElement: /** @this {!Object} */ function HTMLElement() {
96
- return Reflect.construct(BuiltInHTMLElement, [], /** @type {!Function} */ this.constructor);
97
- },
98
- };
99
- window.HTMLElement = wrapperForTheName.HTMLElement;
100
- HTMLElement.prototype = BuiltInHTMLElement.prototype;
101
- HTMLElement.prototype.constructor = HTMLElement;
102
- Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);
103
- }());
104
-
105
- /**
106
- * @description 注册自定义 elem
107
- * @author wangfupeng
108
- */
109
- var WangEditorFormulaCard = /** @class */ (function (_super) {
110
- __extends(WangEditorFormulaCard, _super);
111
- function WangEditorFormulaCard() {
112
- var _this = _super.call(this) || this;
113
- var shadow = _this.attachShadow({ mode: 'open' });
114
- var document = shadow.ownerDocument;
115
- var style = document.createElement('style');
116
- shadow.appendChild(style);
117
- var span = document.createElement('span');
118
- span.style.display = 'inline-block';
119
- shadow.appendChild(span);
120
- _this.span = span;
121
- return _this;
122
- }
123
- Object.defineProperty(WangEditorFormulaCard, "observedAttributes", {
124
- // 监听的 attr
125
- get: function () {
126
- return ['data-value'];
127
- },
128
- enumerable: false,
129
- configurable: true
130
- });
131
- // connectedCallback() {
132
- // // 当 custom element首次被插入文档DOM时,被调用
133
- // console.log('connected')
134
- // }
135
- // disconnectedCallback() {
136
- // // 当 custom element从文档DOM中删除时,被调用
137
- // console.log('disconnected')
138
- // }
139
- // adoptedCallback() {
140
- // // 当 custom element被移动到新的文档时,被调用
141
- // console.log('adopted')
142
- // }
143
- WangEditorFormulaCard.prototype.attributeChangedCallback = function (name, oldValue, newValue) {
144
- if (name === 'data-value') {
145
- if (oldValue === newValue) {
146
- return;
147
- }
148
- this.render(newValue || '');
149
- }
150
- };
151
- WangEditorFormulaCard.prototype.render = function (value) {
152
- katex.render(value, this.span, {
153
- throwOnError: false,
154
- });
155
- };
156
- return WangEditorFormulaCard;
157
- }(HTMLElement));
158
- if (!window.customElements.get('w-e-formula-card')) {
159
- window.customElements.define('w-e-formula-card', WangEditorFormulaCard);
160
- }
161
-
162
- /**
163
- * @description 多语言
164
- * @author wangfupeng
165
- */
166
- i18nAddResources('en', {
167
- formula: {
168
- formula: 'Formula',
169
- placeholder: 'Use LateX syntax',
170
- insert: 'Insert formula',
171
- edit: 'Edit formula',
172
- ok: 'OK',
173
- },
174
- });
175
- i18nAddResources('zh-CN', {
176
- formula: {
177
- formula: '公式',
178
- placeholder: '使用 LateX 语法',
179
- insert: '插入公式',
180
- edit: '编辑公式',
181
- ok: '确定',
182
- },
183
- });
184
-
185
- /**
186
- * @description elem to html
187
- * @author wangfupeng
188
- */
189
- // 生成 html 的函数
190
- function formulaToHtml(elem, _childrenHtml) {
191
- var _a = elem.value, value = _a === void 0 ? '' : _a;
192
- return "<span data-w-e-type=\"formula\" data-w-e-is-void data-w-e-is-inline data-value=\"".concat(value, "\"></span>");
193
- }
194
- // 配置
195
- var conf$1 = {
196
- type: 'formula', // 节点 type ,重要!!!
197
- elemToHtml: formulaToHtml,
198
- };
199
-
200
- /**
201
- * @description icon svg
202
- * @author wangfupeng
203
- */
204
- /**
205
- * 【注意】svg 字符串的长度 ,否则会导致代码体积过大
206
- * 尽量选择 https://www.iconfont.cn/collections/detail?spm=a313x.7781069.0.da5a778a4&cid=20293
207
- * 找不到再从 iconfont.com 搜索
208
- */
209
- // 公式
210
- var SIGMA_SVG = '<svg viewBox="0 0 1024 1024"><path d="M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z"></path></svg>';
211
- // 编辑
212
- var PENCIL_SVG = '<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>';
213
-
214
- /**
215
- * SSR Window 3.0.0
216
- * Better handling for window object in SSR environment
217
- * https://github.com/nolimits4web/ssr-window
218
- *
219
- * Copyright 2020, Vladimir Kharlampidi
220
- *
221
- * Licensed under MIT
222
- *
223
- * Released on: November 9, 2020
224
- */
225
- /* eslint-disable no-param-reassign */
226
- function isObject(obj) {
227
- return (obj !== null &&
228
- typeof obj === 'object' &&
229
- 'constructor' in obj &&
230
- obj.constructor === Object);
231
- }
232
- function extend(target, src) {
233
- if (target === void 0) { target = {}; }
234
- if (src === void 0) { src = {}; }
235
- Object.keys(src).forEach(function (key) {
236
- if (typeof target[key] === 'undefined')
237
- target[key] = src[key];
238
- else if (isObject(src[key]) &&
239
- isObject(target[key]) &&
240
- Object.keys(src[key]).length > 0) {
241
- extend(target[key], src[key]);
242
- }
243
- });
244
- }
245
-
246
- var ssrDocument = {
247
- body: {},
248
- addEventListener: function () { },
249
- removeEventListener: function () { },
250
- activeElement: {
251
- blur: function () { },
252
- nodeName: '',
253
- },
254
- querySelector: function () {
255
- return null;
256
- },
257
- querySelectorAll: function () {
258
- return [];
259
- },
260
- getElementById: function () {
261
- return null;
262
- },
263
- createEvent: function () {
264
- return {
265
- initEvent: function () { },
266
- };
267
- },
268
- createElement: function () {
269
- return {
270
- children: [],
271
- childNodes: [],
272
- style: {},
273
- setAttribute: function () { },
274
- getElementsByTagName: function () {
275
- return [];
276
- },
277
- };
278
- },
279
- createElementNS: function () {
280
- return {};
281
- },
282
- importNode: function () {
283
- return null;
284
- },
285
- location: {
286
- hash: '',
287
- host: '',
288
- hostname: '',
289
- href: '',
290
- origin: '',
291
- pathname: '',
292
- protocol: '',
293
- search: '',
294
- },
295
- };
296
- function getDocument() {
297
- var doc = typeof document !== 'undefined' ? document : {};
298
- extend(doc, ssrDocument);
299
- return doc;
300
- }
301
-
302
- var ssrWindow = {
303
- document: ssrDocument,
304
- navigator: {
305
- userAgent: '',
306
- },
307
- location: {
308
- hash: '',
309
- host: '',
310
- hostname: '',
311
- href: '',
312
- origin: '',
313
- pathname: '',
314
- protocol: '',
315
- search: '',
316
- },
317
- history: {
318
- replaceState: function () { },
319
- pushState: function () { },
320
- go: function () { },
321
- back: function () { },
322
- },
323
- CustomEvent: function CustomEvent() {
324
- return this;
325
- },
326
- addEventListener: function () { },
327
- removeEventListener: function () { },
328
- getComputedStyle: function () {
329
- return {
330
- getPropertyValue: function () {
331
- return '';
332
- },
333
- };
334
- },
335
- Image: function () { },
336
- Date: function () { },
337
- screen: {},
338
- setTimeout: function () { },
339
- clearTimeout: function () { },
340
- matchMedia: function () {
341
- return {};
342
- },
343
- requestAnimationFrame: function (callback) {
344
- if (typeof setTimeout === 'undefined') {
345
- callback();
346
- return null;
347
- }
348
- return setTimeout(callback, 0);
349
- },
350
- cancelAnimationFrame: function (id) {
351
- if (typeof setTimeout === 'undefined') {
352
- return;
353
- }
354
- clearTimeout(id);
355
- },
356
- };
357
- function getWindow() {
358
- var win = typeof window !== 'undefined' ? window : {};
359
- extend(win, ssrWindow);
360
- return win;
361
- }
362
-
363
- /**
364
- * Dom7 3.0.0
365
- * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
366
- * https://framework7.io/docs/dom7.html
367
- *
368
- * Copyright 2020, Vladimir Kharlampidi
369
- *
370
- * Licensed under MIT
371
- *
372
- * Released on: November 9, 2020
373
- */
374
-
375
- function _inheritsLoose(subClass, superClass) {
376
- subClass.prototype = Object.create(superClass.prototype);
377
- subClass.prototype.constructor = subClass;
378
- subClass.__proto__ = superClass;
379
- }
380
-
381
- function _getPrototypeOf(o) {
382
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
383
- return o.__proto__ || Object.getPrototypeOf(o);
384
- };
385
- return _getPrototypeOf(o);
386
- }
387
-
388
- function _setPrototypeOf(o, p) {
389
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
390
- o.__proto__ = p;
391
- return o;
392
- };
393
-
394
- return _setPrototypeOf(o, p);
395
- }
396
-
397
- function _isNativeReflectConstruct() {
398
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
399
- if (Reflect.construct.sham) return false;
400
- if (typeof Proxy === "function") return true;
401
-
402
- try {
403
- Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
404
- return true;
405
- } catch (e) {
406
- return false;
407
- }
408
- }
409
-
410
- function _construct(Parent, args, Class) {
411
- if (_isNativeReflectConstruct()) {
412
- _construct = Reflect.construct;
413
- } else {
414
- _construct = function _construct(Parent, args, Class) {
415
- var a = [null];
416
- a.push.apply(a, args);
417
- var Constructor = Function.bind.apply(Parent, a);
418
- var instance = new Constructor();
419
- if (Class) _setPrototypeOf(instance, Class.prototype);
420
- return instance;
421
- };
422
- }
423
-
424
- return _construct.apply(null, arguments);
425
- }
426
-
427
- function _isNativeFunction(fn) {
428
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
429
- }
430
-
431
- function _wrapNativeSuper(Class) {
432
- var _cache = typeof Map === "function" ? new Map() : undefined;
433
-
434
- _wrapNativeSuper = function _wrapNativeSuper(Class) {
435
- if (Class === null || !_isNativeFunction(Class)) return Class;
436
-
437
- if (typeof Class !== "function") {
438
- throw new TypeError("Super expression must either be null or a function");
439
- }
440
-
441
- if (typeof _cache !== "undefined") {
442
- if (_cache.has(Class)) return _cache.get(Class);
443
-
444
- _cache.set(Class, Wrapper);
445
- }
446
-
447
- function Wrapper() {
448
- return _construct(Class, arguments, _getPrototypeOf(this).constructor);
449
- }
450
-
451
- Wrapper.prototype = Object.create(Class.prototype, {
452
- constructor: {
453
- value: Wrapper,
454
- enumerable: false,
455
- writable: true,
456
- configurable: true
457
- }
458
- });
459
- return _setPrototypeOf(Wrapper, Class);
460
- };
461
-
462
- return _wrapNativeSuper(Class);
463
- }
464
-
465
- function _assertThisInitialized(self) {
466
- if (self === void 0) {
467
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
468
- }
469
-
470
- return self;
471
- }
472
-
473
- /* eslint-disable no-proto */
474
- function makeReactive(obj) {
475
- var proto = obj.__proto__;
476
- Object.defineProperty(obj, '__proto__', {
477
- get: function get() {
478
- return proto;
479
- },
480
- set: function set(value) {
481
- proto.__proto__ = value;
482
- }
483
- });
484
- }
485
-
486
- var Dom7 = /*#__PURE__*/function (_Array) {
487
- _inheritsLoose(Dom7, _Array);
488
-
489
- function Dom7(items) {
490
- var _this;
491
-
492
- _this = _Array.call.apply(_Array, [this].concat(items)) || this;
493
- makeReactive(_assertThisInitialized(_this));
494
- return _this;
495
- }
496
-
497
- return Dom7;
498
- }( /*#__PURE__*/_wrapNativeSuper(Array));
499
- function arrayUnique(arr) {
500
- var uniqueArray = [];
501
-
502
- for (var i = 0; i < arr.length; i += 1) {
503
- if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);
504
- }
505
-
506
- return uniqueArray;
507
- }
508
-
509
- function qsa(selector, context) {
510
- if (typeof selector !== 'string') {
511
- return [selector];
512
- }
513
-
514
- var a = [];
515
- var res = context.querySelectorAll(selector);
516
-
517
- for (var i = 0; i < res.length; i += 1) {
518
- a.push(res[i]);
519
- }
520
-
521
- return a;
522
- }
523
-
524
- function $(selector, context) {
525
- var window = getWindow();
526
- var document = getDocument();
527
- var arr = [];
528
-
529
- if (!context && selector instanceof Dom7) {
530
- return selector;
531
- }
532
-
533
- if (!selector) {
534
- return new Dom7(arr);
535
- }
536
-
537
- if (typeof selector === 'string') {
538
- var html = selector.trim();
539
-
540
- if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
541
- var toCreate = 'div';
542
- if (html.indexOf('<li') === 0) toCreate = 'ul';
543
- if (html.indexOf('<tr') === 0) toCreate = 'tbody';
544
- if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';
545
- if (html.indexOf('<tbody') === 0) toCreate = 'table';
546
- if (html.indexOf('<option') === 0) toCreate = 'select';
547
- var tempParent = document.createElement(toCreate);
548
- tempParent.innerHTML = html;
549
-
550
- for (var i = 0; i < tempParent.childNodes.length; i += 1) {
551
- arr.push(tempParent.childNodes[i]);
552
- }
553
- } else {
554
- arr = qsa(selector.trim(), context || document);
555
- } // arr = qsa(selector, document);
556
-
557
- } else if (selector.nodeType || selector === window || selector === document) {
558
- arr.push(selector);
559
- } else if (Array.isArray(selector)) {
560
- if (selector instanceof Dom7) return selector;
561
- arr = selector;
562
- }
563
-
564
- return new Dom7(arrayUnique(arr));
565
- }
566
-
567
- $.fn = Dom7.prototype;
568
-
569
- function val(value) {
570
- if (typeof value === 'undefined') {
571
- // get value
572
- var el = this[0];
573
- if (!el) return undefined;
574
-
575
- if (el.multiple && el.nodeName.toLowerCase() === 'select') {
576
- var values = [];
577
-
578
- for (var i = 0; i < el.selectedOptions.length; i += 1) {
579
- values.push(el.selectedOptions[i].value);
580
- }
581
-
582
- return values;
583
- }
584
-
585
- return el.value;
586
- } // set value
587
-
588
-
589
- for (var _i = 0; _i < this.length; _i += 1) {
590
- var _el = this[_i];
591
-
592
- if (Array.isArray(value) && _el.multiple && _el.nodeName.toLowerCase() === 'select') {
593
- for (var j = 0; j < _el.options.length; j += 1) {
594
- _el.options[j].selected = value.indexOf(_el.options[j].value) >= 0;
595
- }
596
- } else {
597
- _el.value = value;
598
- }
599
- }
600
-
601
- return this;
602
- }
603
-
604
- function on() {
605
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
606
- args[_key5] = arguments[_key5];
607
- }
608
-
609
- var eventType = args[0],
610
- targetSelector = args[1],
611
- listener = args[2],
612
- capture = args[3];
613
-
614
- if (typeof args[1] === 'function') {
615
- eventType = args[0];
616
- listener = args[1];
617
- capture = args[2];
618
- targetSelector = undefined;
619
- }
620
-
621
- if (!capture) capture = false;
622
-
623
- function handleLiveEvent(e) {
624
- var target = e.target;
625
- if (!target) return;
626
- var eventData = e.target.dom7EventData || [];
627
-
628
- if (eventData.indexOf(e) < 0) {
629
- eventData.unshift(e);
630
- }
631
-
632
- if ($(target).is(targetSelector)) listener.apply(target, eventData);else {
633
- var _parents = $(target).parents(); // eslint-disable-line
634
-
635
-
636
- for (var k = 0; k < _parents.length; k += 1) {
637
- if ($(_parents[k]).is(targetSelector)) listener.apply(_parents[k], eventData);
638
- }
639
- }
640
- }
641
-
642
- function handleEvent(e) {
643
- var eventData = e && e.target ? e.target.dom7EventData || [] : [];
644
-
645
- if (eventData.indexOf(e) < 0) {
646
- eventData.unshift(e);
647
- }
648
-
649
- listener.apply(this, eventData);
650
- }
651
-
652
- var events = eventType.split(' ');
653
- var j;
654
-
655
- for (var i = 0; i < this.length; i += 1) {
656
- var el = this[i];
657
-
658
- if (!targetSelector) {
659
- for (j = 0; j < events.length; j += 1) {
660
- var event = events[j];
661
- if (!el.dom7Listeners) el.dom7Listeners = {};
662
- if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];
663
- el.dom7Listeners[event].push({
664
- listener: listener,
665
- proxyListener: handleEvent
666
- });
667
- el.addEventListener(event, handleEvent, capture);
668
- }
669
- } else {
670
- // Live events
671
- for (j = 0; j < events.length; j += 1) {
672
- var _event = events[j];
673
- if (!el.dom7LiveListeners) el.dom7LiveListeners = {};
674
- if (!el.dom7LiveListeners[_event]) el.dom7LiveListeners[_event] = [];
675
-
676
- el.dom7LiveListeners[_event].push({
677
- listener: listener,
678
- proxyListener: handleLiveEvent
679
- });
680
-
681
- el.addEventListener(_event, handleLiveEvent, capture);
682
- }
683
- }
684
- }
685
-
686
- return this;
687
- }
688
-
689
- function html(html) {
690
- if (typeof html === 'undefined') {
691
- return this[0] ? this[0].innerHTML : null;
692
- }
693
-
694
- for (var i = 0; i < this.length; i += 1) {
695
- this[i].innerHTML = html;
696
- }
697
-
698
- return this;
699
- }
700
-
701
- function is(selector) {
702
- var window = getWindow();
703
- var document = getDocument();
704
- var el = this[0];
705
- var compareWith;
706
- var i;
707
- if (!el || typeof selector === 'undefined') return false;
708
-
709
- if (typeof selector === 'string') {
710
- if (el.matches) return el.matches(selector);
711
- if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);
712
- if (el.msMatchesSelector) return el.msMatchesSelector(selector);
713
- compareWith = $(selector);
714
-
715
- for (i = 0; i < compareWith.length; i += 1) {
716
- if (compareWith[i] === el) return true;
717
- }
718
-
719
- return false;
720
- }
721
-
722
- if (selector === document) {
723
- return el === document;
724
- }
725
-
726
- if (selector === window) {
727
- return el === window;
728
- }
729
-
730
- if (selector.nodeType || selector instanceof Dom7) {
731
- compareWith = selector.nodeType ? [selector] : selector;
732
-
733
- for (i = 0; i < compareWith.length; i += 1) {
734
- if (compareWith[i] === el) return true;
735
- }
736
-
737
- return false;
738
- }
739
-
740
- return false;
741
- }
742
-
743
- function append() {
744
- var newChild;
745
- var document = getDocument();
746
-
747
- for (var k = 0; k < arguments.length; k += 1) {
748
- newChild = k < 0 || arguments.length <= k ? undefined : arguments[k];
749
-
750
- for (var i = 0; i < this.length; i += 1) {
751
- if (typeof newChild === 'string') {
752
- var tempDiv = document.createElement('div');
753
- tempDiv.innerHTML = newChild;
754
-
755
- while (tempDiv.firstChild) {
756
- this[i].appendChild(tempDiv.firstChild);
757
- }
758
- } else if (newChild instanceof Dom7) {
759
- for (var j = 0; j < newChild.length; j += 1) {
760
- this[i].appendChild(newChild[j]);
761
- }
762
- } else {
763
- this[i].appendChild(newChild);
764
- }
765
- }
766
- }
767
-
768
- return this;
769
- }
770
-
771
- function parents(selector) {
772
- var parents = []; // eslint-disable-line
773
-
774
- for (var i = 0; i < this.length; i += 1) {
775
- var _parent = this[i].parentNode; // eslint-disable-line
776
-
777
- while (_parent) {
778
- if (selector) {
779
- if ($(_parent).is(selector)) parents.push(_parent);
780
- } else {
781
- parents.push(_parent);
782
- }
783
-
784
- _parent = _parent.parentNode;
785
- }
786
- }
787
-
788
- return $(parents);
789
- }
790
-
791
- function find(selector) {
792
- var foundElements = [];
793
-
794
- for (var i = 0; i < this.length; i += 1) {
795
- var found = this[i].querySelectorAll(selector);
796
-
797
- for (var j = 0; j < found.length; j += 1) {
798
- foundElements.push(found[j]);
799
- }
800
- }
801
-
802
- return $(foundElements);
803
- }
804
-
805
- var noTrigger = 'resize scroll'.split(' ');
806
-
807
- function shortcut(name) {
808
- function eventHandler() {
809
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
810
- args[_key] = arguments[_key];
811
- }
812
-
813
- if (typeof args[0] === 'undefined') {
814
- for (var i = 0; i < this.length; i += 1) {
815
- if (noTrigger.indexOf(name) < 0) {
816
- if (name in this[i]) this[i][name]();else {
817
- $(this[i]).trigger(name);
818
- }
819
- }
820
- }
821
-
822
- return this;
823
- }
824
-
825
- return this.on.apply(this, [name].concat(args));
826
- }
827
-
828
- return eventHandler;
829
- }
830
- var focus = shortcut('focus');
831
-
832
- /**
833
- * @description DOM 操作
834
- * @author wangfupeng
835
- */
836
- if (append) {
837
- $.fn.append = append;
838
- }
839
- if (html) {
840
- $.fn.html = html;
841
- }
842
- if (val) {
843
- $.fn.val = val;
844
- }
845
- if (on) {
846
- $.fn.on = on;
847
- }
848
- if (focus) {
849
- $.fn.focus = focus;
850
- }
851
- if (is) {
852
- $.fn.is = is;
853
- }
854
- if (parents) {
855
- $.fn.parents = parents;
856
- }
857
- if (find) {
858
- $.fn.find = find;
859
- }
860
-
861
- let nanoid = (size = 21) =>
862
- crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
863
- byte &= 63;
864
- if (byte < 36) {
865
- id += byte.toString(36);
866
- } else if (byte < 62) {
867
- id += (byte - 26).toString(36).toUpperCase();
868
- } else if (byte > 62) {
869
- id += '-';
870
- } else {
871
- id += '_';
872
- }
873
- return id
874
- }, '');
875
-
876
- /**
877
- * @description 工具函数
878
- * @author wangfupeng
879
- */
880
- /**
881
- * 获取随机数字符串
882
- * @param prefix 前缀
883
- * @returns 随机数字符串
884
- */
885
- function genRandomStr(prefix) {
886
- return "".concat(prefix, "-").concat(nanoid());
887
- }
888
- // export function replaceSymbols(str: string) {
889
- // return str.replace(/</g, '&lt;').replace(/>/g, '&gt;')
890
- // }
891
-
892
- /**
893
- * @description edit formula menu
894
- * @author wangfupeng
895
- */
896
- /**
897
- * 生成唯一的 DOM ID
898
- */
899
- function genDomID$1() {
900
- return genRandomStr('w-e-insert-formula');
901
- }
902
- var EditFormulaMenu = /** @class */ (function () {
903
- function EditFormulaMenu() {
904
- this.title = t('formula.edit');
905
- this.iconSvg = PENCIL_SVG;
906
- this.tag = 'button';
907
- this.showModal = true; // 点击 button 时显示 modal
908
- this.modalWidth = 300;
909
- this.$content = null;
910
- this.textareaId = genDomID$1();
911
- this.buttonId = genDomID$1();
912
- }
913
- EditFormulaMenu.prototype.getSelectedElem = function (editor) {
914
- var node = DomEditor.getSelectedNodeByType(editor, 'formula');
915
- if (node == null) {
916
- return null;
917
- }
918
- return node;
919
- };
920
- /**
921
- * 获取公式 value
922
- * @param editor editor
923
- */
924
- EditFormulaMenu.prototype.getValue = function (editor) {
925
- var formulaElem = this.getSelectedElem(editor);
926
- if (formulaElem) {
927
- return formulaElem.value || '';
928
- }
929
- return '';
930
- };
931
- EditFormulaMenu.prototype.isActive = function (_editor) {
932
- // 无需 active
933
- return false;
934
- };
935
- EditFormulaMenu.prototype.exec = function (_editor, _value) {
936
- // 点击菜单时,弹出 modal 之前,不需要执行其他代码
937
- // 此处空着即可
938
- };
939
- EditFormulaMenu.prototype.isDisabled = function (editor) {
940
- var selection = editor.selection;
941
- if (selection == null) {
942
- return true;
943
- }
944
- if (SlateRange.isExpanded(selection)) {
945
- return true;
946
- } // 选区非折叠,禁用
947
- // 未匹配到 formula node 则禁用
948
- var formulaElem = this.getSelectedElem(editor);
949
- if (formulaElem == null) {
950
- return true;
951
- }
952
- return false;
953
- };
954
- // modal 定位
955
- EditFormulaMenu.prototype.getModalPositionNode = function (editor) {
956
- return this.getSelectedElem(editor);
957
- };
958
- EditFormulaMenu.prototype.getModalContentElem = function (editor) {
959
- var _this = this;
960
- var _a = this, textareaId = _a.textareaId, buttonId = _a.buttonId;
961
- var _b = __read(genModalTextareaElems(t('formula.formula'), textareaId, t('formula.placeholder')), 2), textareaContainerElem = _b[0], textareaElem = _b[1];
962
- var $textarea = $(textareaElem);
963
- var _c = __read(genModalButtonElems(buttonId, t('formula.ok')), 1), buttonContainerElem = _c[0];
964
- if (this.$content == null) {
965
- // 第一次渲染
966
- var $content_1 = $('<div></div>');
967
- // 绑定事件(第一次渲染时绑定,不要重复绑定)
968
- $content_1.on('click', "#".concat(buttonId), function (e) {
969
- e.preventDefault();
970
- var value = $content_1.find("#".concat(textareaId)).val().trim();
971
- _this.updateFormula(editor, value);
972
- editor.hidePanelOrModal(); // 隐藏 modal
973
- });
974
- // 记录属性,重要
975
- this.$content = $content_1;
976
- }
977
- var $content = this.$content;
978
- $content.html(''); // 先清空内容
979
- // append textarea and button
980
- $content.append(textareaContainerElem);
981
- $content.append(buttonContainerElem);
982
- // 设置 input val
983
- var value = this.getValue(editor);
984
- $textarea.val(value);
985
- // focus 一个 input(异步,此时 DOM 尚未渲染)
986
- setTimeout(function () {
987
- $textarea.focus();
988
- });
989
- return $content[0];
990
- };
991
- EditFormulaMenu.prototype.updateFormula = function (editor, value) {
992
- if (!value) {
993
- return;
994
- }
995
- // 还原选区
996
- editor.restoreSelection();
997
- if (this.isDisabled(editor)) {
998
- return;
999
- }
1000
- var selectedElem = this.getSelectedElem(editor);
1001
- if (selectedElem == null) {
1002
- return;
1003
- }
1004
- var path = DomEditor.findPath(editor, selectedElem);
1005
- var props = { value: value };
1006
- SlateTransforms.setNodes(editor, props, { at: path });
1007
- };
1008
- return EditFormulaMenu;
1009
- }());
1010
-
1011
- /**
1012
- * @description insert formula menu
1013
- * @author wangfupeng
1014
- */
1015
- /**
1016
- * 生成唯一的 DOM ID
1017
- */
1018
- function genDomID() {
1019
- return genRandomStr('w-e-insert-formula');
1020
- }
1021
- var InsertFormulaMenu = /** @class */ (function () {
1022
- function InsertFormulaMenu() {
1023
- this.title = t('formula.insert');
1024
- this.iconSvg = SIGMA_SVG;
1025
- this.tag = 'button';
1026
- this.showModal = true; // 点击 button 时显示 modal
1027
- this.modalWidth = 300;
1028
- this.$content = null;
1029
- this.textareaId = genDomID();
1030
- this.buttonId = genDomID();
1031
- }
1032
- InsertFormulaMenu.prototype.getValue = function (_editor) {
1033
- // 插入菜单,不需要 value
1034
- return '';
1035
- };
1036
- InsertFormulaMenu.prototype.isActive = function (_editor) {
1037
- // 任何时候,都不用激活 menu
1038
- return false;
1039
- };
1040
- InsertFormulaMenu.prototype.exec = function (_editor, _value) {
1041
- // 点击菜单时,弹出 modal 之前,不需要执行其他代码
1042
- // 此处空着即可
1043
- };
1044
- InsertFormulaMenu.prototype.isDisabled = function (editor) {
1045
- var selection = editor.selection;
1046
- if (selection == null) {
1047
- return true;
1048
- }
1049
- if (SlateRange.isExpanded(selection)) {
1050
- return true;
1051
- } // 选区非折叠,禁用
1052
- var selectedElems = DomEditor.getSelectedElems(editor);
1053
- var hasVoidElem = selectedElems.some(function (elem) { return editor.isVoid(elem); });
1054
- if (hasVoidElem) {
1055
- return true;
1056
- } // 选中了 void 元素,禁用
1057
- var hasPreElem = selectedElems.some(function (elem) { return DomEditor.getNodeType(elem) === 'pre'; });
1058
- if (hasPreElem) {
1059
- return true;
1060
- } // 选中了 pre 原则,禁用
1061
- return false;
1062
- };
1063
- InsertFormulaMenu.prototype.getModalPositionNode = function (_editor) {
1064
- return null; // modal 依据选区定位
1065
- };
1066
- InsertFormulaMenu.prototype.getModalContentElem = function (editor) {
1067
- var _this = this;
1068
- var _a = this, textareaId = _a.textareaId, buttonId = _a.buttonId;
1069
- var _b = __read(genModalTextareaElems(t('formula.formula'), textareaId, t('formula.placeholder')), 2), textareaContainerElem = _b[0], textareaElem = _b[1];
1070
- var $textarea = $(textareaElem);
1071
- var _c = __read(genModalButtonElems(buttonId, t('formula.ok')), 1), buttonContainerElem = _c[0];
1072
- if (this.$content == null) {
1073
- // 第一次渲染
1074
- var $content_1 = $('<div></div>');
1075
- // 绑定事件(第一次渲染时绑定,不要重复绑定)
1076
- $content_1.on('click', "#".concat(buttonId), function (e) {
1077
- e.preventDefault();
1078
- var value = $content_1.find("#".concat(textareaId)).val().trim();
1079
- _this.insertFormula(editor, value);
1080
- editor.hidePanelOrModal(); // 隐藏 modal
1081
- });
1082
- // 记录属性,重要
1083
- this.$content = $content_1;
1084
- }
1085
- var $content = this.$content;
1086
- $content.html(''); // 先清空内容
1087
- // append textarea and button
1088
- $content.append(textareaContainerElem);
1089
- $content.append(buttonContainerElem);
1090
- // 设置 input val
1091
- $textarea.val('');
1092
- // focus 一个 input(异步,此时 DOM 尚未渲染)
1093
- setTimeout(function () {
1094
- $textarea.focus();
1095
- });
1096
- return $content[0];
1097
- };
1098
- InsertFormulaMenu.prototype.insertFormula = function (editor, value) {
1099
- if (!value) {
1100
- return;
1101
- }
1102
- // 还原选区
1103
- editor.restoreSelection();
1104
- if (this.isDisabled(editor)) {
1105
- return;
1106
- }
1107
- var formulaElem = {
1108
- type: 'formula',
1109
- value: value,
1110
- children: [{ text: '' }], // void node 需要有一个空 text
1111
- };
1112
- editor.insertNode(formulaElem);
1113
- };
1114
- return InsertFormulaMenu;
1115
- }());
1116
-
1117
- /**
1118
- * @description formula menu entry
1119
- * @author wangfupeng
1120
- */
1121
- var insertFormulaMenuConf = {
1122
- key: 'insertFormula', // menu key ,唯一。注册之后,可配置到工具栏
1123
- factory: function () {
1124
- return new InsertFormulaMenu();
1125
- },
1126
- };
1127
- var editFormulaMenuConf = {
1128
- key: 'editFormula', // menu key ,唯一。注册之后,可配置到工具栏
1129
- factory: function () {
1130
- return new EditFormulaMenu();
1131
- },
1132
- };
1133
-
1134
- /**
1135
- * @description parse elem html
1136
- * @author wangfupeng
1137
- */
1138
- function parseHtml(elem, _children, _editor) {
1139
- var value = elem.getAttribute('data-value') || '';
1140
- return {
1141
- type: 'formula',
1142
- value: value,
1143
- children: [{ text: '' }], // void node 必须有一个空白 text
1144
- };
1145
- }
1146
- var parseHtmlConf = {
1147
- selector: 'span[data-w-e-type="formula"]',
1148
- parseElemHtml: parseHtml,
1149
- };
1150
-
1151
- /**
1152
- * @description formula plugin
1153
- * @author wangfupeng
1154
- */
1155
- function withFormula(editor) {
1156
- var isInline = editor.isInline, isVoid = editor.isVoid;
1157
- var newEditor = editor;
1158
- // 重写 isInline
1159
- newEditor.isInline = function (elem) {
1160
- var type = DomEditor.getNodeType(elem);
1161
- if (type === 'formula') {
1162
- return true;
1163
- }
1164
- return isInline(elem);
1165
- };
1166
- // 重写 isVoid
1167
- newEditor.isVoid = function (elem) {
1168
- var type = DomEditor.getNodeType(elem);
1169
- if (type === 'formula') {
1170
- return true;
1171
- }
1172
- return isVoid(elem);
1173
- };
1174
- return newEditor;
1175
- }
1176
-
1177
- /**
1178
- * @description render elem
1179
- * @author wangfupeng
1180
- */
1181
- function renderFormula(elem, children, editor) {
1182
- // 当前节点是否选中
1183
- var selected = DomEditor.isNodeSelected(editor, elem);
1184
- // 构建 formula vnode
1185
- var _a = elem.value, value = _a === void 0 ? '' : _a;
1186
- var formulaVnode = h('w-e-formula-card', {
1187
- dataset: { value: value },
1188
- }, null);
1189
- // 构建容器 vnode
1190
- var containerVnode = h('div', {
1191
- props: {
1192
- contentEditable: false, // 不可编辑
1193
- },
1194
- style: {
1195
- display: 'inline-block', // inline
1196
- marginLeft: '3px',
1197
- marginRight: '3px',
1198
- border: selected // 选中/不选中,样式不一样
1199
- ? '2px solid var(--w-e-textarea-selected-border-color)' // wangEditor 提供了 css var https://www.wangeditor.com/v5/theme.html
1200
- : '2px solid transparent',
1201
- borderRadius: '3px',
1202
- padding: '3px 3px',
1203
- },
1204
- }, [formulaVnode]);
1205
- return containerVnode;
1206
- }
1207
- var conf = {
1208
- type: 'formula', // 节点 type ,重要!!!
1209
- renderElem: renderFormula,
1210
- };
1211
-
1212
- /**
1213
- * @description formula module entry
1214
- * @author wangfupeng
1215
- */
1216
- var module = {
1217
- editorPlugin: withFormula,
1218
- renderElems: [conf],
1219
- elemsToHtml: [conf$1],
1220
- parseElemsHtml: [parseHtmlConf],
1221
- menus: [insertFormulaMenuConf, editFormulaMenuConf],
1222
- };
1223
-
1224
- /**
1225
- * @description src entry
1226
- * @author wangfupeng
1227
- */
1228
- // 全局注册自定义组件,用于渲染公式
1229
-
1230
- export { module as default };
1
+ import t from"katex";import{i18nAddResources as n,t as r,DomEditor as e,SlateRange as o,genModalTextareaElems as i,genModalButtonElems as u,SlateTransforms as c}from"@wangeditor-next/editor";import{h as f}from"snabbdom";var a=function(t,n){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},a(t,n)};function l(t,n){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var e,o,i=r.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(e=i.next()).done;)u.push(e.value)}catch(t){o={error:t}}finally{try{e&&!e.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}"function"==typeof SuppressedError&&SuppressedError;var s,p,v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},d={};function h(){if(p)return s;p=1;var t=function(t){return t&&t.Math===Math&&t};return s=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof v&&v)||t("object"==typeof s&&s)||function(){return this}()||Function("return this")()}var y,m,g,b,w,O,x,E,S,j,T,L,P,I,_,A,M,R,C,N,k,F,D,H,z,$,B,V,U,W,q,G,K,X,Y,J,Q,Z={exports:{}};function tt(){if(b)return g;b=1;var t=h(),n=Object.defineProperty;return g=function(r,e){try{n(t,r,{value:e,configurable:!0,writable:!0})}catch(n){t[r]=e}return e}}function nt(){if(w)return Z.exports;w=1;var t=m?y:(m=1,y=!1),n=h(),r=tt(),e="__core-js_shared__",o=Z.exports=n[e]||r(e,{});return(o.versions||(o.versions=[])).push({version:"3.38.1",mode:t?"pure":"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"}),Z.exports}function rt(){if(x)return O;x=1;var t=nt();return O=function(n,r){return t[n]||(t[n]=r||{})}}function et(){return S?E:(S=1,E=function(t){try{return!!t()}catch(t){return!0}})}function ot(){if(T)return j;T=1;var t=et();return j=!t((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))}function it(){if(P)return L;P=1;var t=ot(),n=Function.prototype,r=n.call,e=t&&n.bind.bind(r,r);return L=t?e:function(t){return function(){return r.apply(t,arguments)}},L}function ut(){return _?I:(_=1,I=function(t){return null==t})}function ct(){if(M)return A;M=1;var t=ut(),n=TypeError;return A=function(r){if(t(r))throw new n("Can't call method on "+r);return r}}function ft(){if(C)return R;C=1;var t=ct(),n=Object;return R=function(r){return n(t(r))}}function at(){if(k)return N;k=1;var t=it(),n=ft(),r=t({}.hasOwnProperty);return N=Object.hasOwn||function(t,e){return r(n(t),e)}}function lt(){if(D)return F;D=1;var t=it(),n=0,r=Math.random(),e=t(1..toString);return F=function(t){return"Symbol("+(void 0===t?"":t)+")_"+e(++n+r,36)}}function st(){if(B)return $;B=1;var t,n,r=h(),e=function(){if(z)return H;z=1;var t=h().navigator,n=t&&t.userAgent;return H=n?String(n):""}(),o=r.process,i=r.Deno,u=o&&o.versions||i&&i.version,c=u&&u.v8;return c&&(n=(t=c.split("."))[0]>0&&t[0]<4?1:+(t[0]+t[1])),!n&&e&&(!(t=e.match(/Edge\/(\d+)/))||t[1]>=74)&&(t=e.match(/Chrome\/(\d+)/))&&(n=+t[1]),$=n}function pt(){if(U)return V;U=1;var t=st(),n=et(),r=h().String;return V=!!Object.getOwnPropertySymbols&&!n((function(){var n=Symbol("symbol detection");return!r(n)||!(Object(n)instanceof Symbol)||!Symbol.sham&&t&&t<41}))}function vt(){if(q)return W;q=1;var t=pt();return W=t&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function dt(){if(K)return G;K=1;var t=h(),n=rt(),r=at(),e=lt(),o=pt(),i=vt(),u=t.Symbol,c=n("wks"),f=i?u.for||u:u&&u.withoutSetter||e;return G=function(t){return r(c,t)||(c[t]=o&&r(u,t)?u[t]:f("Symbol."+t)),c[t]}}function ht(){if(Y)return X;Y=1;var t={};return t[dt()("toStringTag")]="z",X="[object z]"===String(t)}function yt(){if(Q)return J;Q=1;var t="object"==typeof document&&document.all;return J=void 0===t&&void 0!==t?function(n){return"function"==typeof n||n===t}:function(t){return"function"==typeof t}}var mt,gt,bt,wt,Ot,xt,Et,St,jt,Tt,Lt,Pt,It,_t,At,Mt,Rt,Ct,Nt,kt,Ft,Dt,Ht,zt,$t,Bt,Vt,Ut,Wt,qt,Gt,Kt,Xt,Yt={};function Jt(){if(gt)return mt;gt=1;var t=et();return mt=!t((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))}function Qt(){if(wt)return bt;wt=1;var t=yt();return bt=function(n){return"object"==typeof n?null!==n:t(n)}}function Zt(){if(xt)return Ot;xt=1;var t=h(),n=Qt(),r=t.document,e=n(r)&&n(r.createElement);return Ot=function(t){return e?r.createElement(t):{}}}function tn(){if(St)return Et;St=1;var t=Jt(),n=et(),r=Zt();return Et=!t&&!n((function(){return 7!==Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))}function nn(){if(Tt)return jt;Tt=1;var t=Jt(),n=et();return jt=t&&n((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))}function rn(){if(Pt)return Lt;Pt=1;var t=Qt(),n=String,r=TypeError;return Lt=function(e){if(t(e))return e;throw new r(n(e)+" is not an object")}}function en(){if(_t)return It;_t=1;var t=ot(),n=Function.prototype.call;return It=t?n.bind(n):function(){return n.apply(n,arguments)},It}function on(){if(Mt)return At;Mt=1;var t=h(),n=yt();return At=function(r,e){return arguments.length<2?(o=t[r],n(o)?o:void 0):t[r]&&t[r][e];var o},At}function un(){if(kt)return Nt;kt=1;var t=on(),n=yt(),r=function(){if(Ct)return Rt;Ct=1;var t=it();return Rt=t({}.isPrototypeOf)}(),e=vt(),o=Object;return Nt=e?function(t){return"symbol"==typeof t}:function(e){var i=t("Symbol");return n(i)&&r(i.prototype,o(e))}}function cn(){if(Dt)return Ft;Dt=1;var t=String;return Ft=function(n){try{return t(n)}catch(t){return"Object"}}}function fn(){if(zt)return Ht;zt=1;var t=yt(),n=cn(),r=TypeError;return Ht=function(e){if(t(e))return e;throw new r(n(e)+" is not a function")}}function an(){if(Bt)return $t;Bt=1;var t=fn(),n=ut();return $t=function(r,e){var o=r[e];return n(o)?void 0:t(o)}}function ln(){if(Ut)return Vt;Ut=1;var t=en(),n=yt(),r=Qt(),e=TypeError;return Vt=function(o,i){var u,c;if("string"===i&&n(u=o.toString)&&!r(c=t(u,o)))return c;if(n(u=o.valueOf)&&!r(c=t(u,o)))return c;if("string"!==i&&n(u=o.toString)&&!r(c=t(u,o)))return c;throw new e("Can't convert object to primitive value")},Vt}function sn(){if(qt)return Wt;qt=1;var t=en(),n=Qt(),r=un(),e=an(),o=ln(),i=dt(),u=TypeError,c=i("toPrimitive");return Wt=function(i,f){if(!n(i)||r(i))return i;var a,l=e(i,c);if(l){if(void 0===f&&(f="default"),a=t(l,i,f),!n(a)||r(a))return a;throw new u("Can't convert object to primitive value")}return void 0===f&&(f="number"),o(i,f)}}function pn(){if(Kt)return Gt;Kt=1;var t=sn(),n=un();return Gt=function(r){var e=t(r,"string");return n(e)?e:e+""}}function vn(){if(Xt)return Yt;Xt=1;var t=Jt(),n=tn(),r=nn(),e=rn(),o=pn(),i=TypeError,u=Object.defineProperty,c=Object.getOwnPropertyDescriptor,f="enumerable",a="configurable",l="writable";return Yt.f=t?r?function(t,n,r){if(e(t),n=o(n),e(r),"function"==typeof t&&"prototype"===n&&"value"in r&&l in r&&!r[l]){var i=c(t,n);i&&i[l]&&(t[n]=r.value,r={configurable:a in r?r[a]:i[a],enumerable:f in r?r[f]:i[f],writable:!1})}return u(t,n,r)}:u:function(t,r,c){if(e(t),r=o(r),e(c),n)try{return u(t,r,c)}catch(t){}if("get"in c||"set"in c)throw new i("Accessors not supported");return"value"in c&&(t[r]=c.value),t},Yt}var dn,hn,yn,mn,gn,bn,wn,On,xn,En,Sn,jn,Tn,Ln,Pn,In,_n,An,Mn,Rn,Cn,Nn,kn,Fn,Dn,Hn,zn={exports:{}};function $n(){if(hn)return dn;hn=1;var t=Jt(),n=at(),r=Function.prototype,e=t&&Object.getOwnPropertyDescriptor,o=n(r,"name"),i=o&&"something"===function(){}.name,u=o&&(!t||t&&e(r,"name").configurable);return dn={EXISTS:o,PROPER:i,CONFIGURABLE:u}}function Bn(){if(mn)return yn;mn=1;var t=it(),n=yt(),r=nt(),e=t(Function.toString);return n(r.inspectSource)||(r.inspectSource=function(t){return e(t)}),yn=r.inspectSource}function Vn(){return On?wn:(On=1,wn=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}})}function Un(){if(En)return xn;En=1;var t=Jt(),n=vn(),r=Vn();return xn=t?function(t,e,o){return n.f(t,e,r(1,o))}:function(t,n,r){return t[n]=r,t}}function Wn(){if(jn)return Sn;jn=1;var t=rt(),n=lt(),r=t("keys");return Sn=function(t){return r[t]||(r[t]=n(t))}}function qn(){return Ln?Tn:(Ln=1,Tn={})}function Gn(){if(In)return Pn;In=1;var t,n,r,e=function(){if(bn)return gn;bn=1;var t=h(),n=yt(),r=t.WeakMap;return gn=n(r)&&/native code/.test(String(r))}(),o=h(),i=Qt(),u=Un(),c=at(),f=nt(),a=Wn(),l=qn(),s="Object already initialized",p=o.TypeError,v=o.WeakMap;if(e||f.state){var d=f.state||(f.state=new v);d.get=d.get,d.has=d.has,d.set=d.set,t=function(t,n){if(d.has(t))throw new p(s);return n.facade=t,d.set(t,n),n},n=function(t){return d.get(t)||{}},r=function(t){return d.has(t)}}else{var y=a("state");l[y]=!0,t=function(t,n){if(c(t,y))throw new p(s);return n.facade=t,u(t,y,n),n},n=function(t){return c(t,y)?t[y]:{}},r=function(t){return c(t,y)}}return Pn={set:t,get:n,has:r,enforce:function(e){return r(e)?n(e):t(e,{})},getterFor:function(t){return function(r){var e;if(!i(r)||(e=n(r)).type!==t)throw new p("Incompatible receiver, "+t+" required");return e}}}}function Kn(){if(_n)return zn.exports;_n=1;var t=it(),n=et(),r=yt(),e=at(),o=Jt(),i=$n().CONFIGURABLE,u=Bn(),c=Gn(),f=c.enforce,a=c.get,l=String,s=Object.defineProperty,p=t("".slice),v=t("".replace),d=t([].join),h=o&&!n((function(){return 8!==s((function(){}),"length",{value:8}).length})),y=String(String).split("String"),m=zn.exports=function(t,n,r){"Symbol("===p(l(n),0,7)&&(n="["+v(l(n),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(n="get "+n),r&&r.setter&&(n="set "+n),(!e(t,"name")||i&&t.name!==n)&&(o?s(t,"name",{value:n,configurable:!0}):t.name=n),h&&r&&e(r,"arity")&&t.length!==r.arity&&s(t,"length",{value:r.arity});try{r&&e(r,"constructor")&&r.constructor?o&&s(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var u=f(t);return e(u,"source")||(u.source=d(y,"string"==typeof n?n:"")),t};return Function.prototype.toString=m((function(){return r(this)&&a(this).source||u(this)}),"toString"),zn.exports}function Xn(){if(Mn)return An;Mn=1;var t=yt(),n=vn(),r=Kn(),e=tt();return An=function(o,i,u,c){c||(c={});var f=c.enumerable,a=void 0!==c.name?c.name:i;if(t(u)&&r(u,a,c),c.global)f?o[i]=u:e(i,u);else{try{c.unsafe?o[i]&&(f=!0):delete o[i]}catch(t){}f?o[i]=u:n.f(o,i,{value:u,enumerable:!1,configurable:!c.nonConfigurable,writable:!c.nonWritable})}return o}}function Yn(){if(Cn)return Rn;Cn=1;var t=it(),n=t({}.toString),r=t("".slice);return Rn=function(t){return r(n(t),8,-1)}}function Jn(){if(kn)return Nn;kn=1;var t=ht(),n=yt(),r=Yn(),e=dt()("toStringTag"),o=Object,i="Arguments"===r(function(){return arguments}());return Nn=t?r:function(t){var u,c,f;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(c=function(t,n){try{return t[n]}catch(t){}}(u=o(t),e))?c:i?r(u):"Object"===(f=r(u))&&n(u.callee)?"Arguments":f}}!function(){if(Hn)return d;Hn=1;var t=ht(),n=Xn(),r=function(){if(Dn)return Fn;Dn=1;var t=ht(),n=Jn();return Fn=t?{}.toString:function(){return"[object "+n(this)+"]"}}();t||n(Object.prototype,"toString",r,{unsafe:!0})}();var Qn,Zn,tr,nr,rr,er,or={},ir={},ur={};function cr(){if(tr)return Zn;tr=1;var t=it(),n=et(),r=Yn(),e=Object,o=t("".split);return Zn=n((function(){return!e("z").propertyIsEnumerable(0)}))?function(t){return"String"===r(t)?o(t,""):e(t)}:e}function fr(){if(rr)return nr;rr=1;var t=cr(),n=ct();return nr=function(r){return t(n(r))}}function ar(){if(er)return ir;er=1;var t=Jt(),n=en(),r=function(){if(Qn)return ur;Qn=1;var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,r=n&&!t.call({1:2},1);return ur.f=r?function(t){var r=n(this,t);return!!r&&r.enumerable}:t,ur}(),e=Vn(),o=fr(),i=pn(),u=at(),c=tn(),f=Object.getOwnPropertyDescriptor;return ir.f=t?f:function(t,a){if(t=o(t),a=i(a),c)try{return f(t,a)}catch(t){}if(u(t,a))return e(!n(r.f,t,a),t[a])},ir}var lr,sr,pr,vr,dr,hr,yr,mr,gr,br,wr,Or,xr,Er,Sr,jr,Tr,Lr={};function Pr(){if(vr)return pr;vr=1;var t=function(){if(sr)return lr;sr=1;var t=Math.ceil,n=Math.floor;return lr=Math.trunc||function(r){var e=+r;return(e>0?n:t)(e)}}();return pr=function(n){var r=+n;return r!=r||0===r?0:t(r)}}function Ir(){if(hr)return dr;hr=1;var t=Pr(),n=Math.max,r=Math.min;return dr=function(e,o){var i=t(e);return i<0?n(i+o,0):r(i,o)}}function _r(){if(mr)return yr;mr=1;var t=Pr(),n=Math.min;return yr=function(r){var e=t(r);return e>0?n(e,9007199254740991):0}}function Ar(){if(br)return gr;br=1;var t=_r();return gr=function(n){return t(n.length)}}function Mr(){if(Er)return xr;Er=1;var t=it(),n=at(),r=fr(),e=function(){if(Or)return wr;Or=1;var t=fr(),n=Ir(),r=Ar(),e=function(e){return function(o,i,u){var c=t(o),f=r(c);if(0===f)return!e&&-1;var a,l=n(u,f);if(e&&i!=i){for(;f>l;)if((a=c[l++])!=a)return!0}else for(;f>l;l++)if((e||l in c)&&c[l]===i)return e||l||0;return!e&&-1}};return wr={includes:e(!0),indexOf:e(!1)}}().indexOf,o=qn(),i=t([].push);return xr=function(t,u){var c,f=r(t),a=0,l=[];for(c in f)!n(o,c)&&n(f,c)&&i(l,c);for(;u.length>a;)n(f,c=u[a++])&&(~e(l,c)||i(l,c));return l}}function Rr(){return jr?Sr:(jr=1,Sr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}var Cr,Nr,kr,Fr,Dr,Hr,zr,$r,Br,Vr,Ur,Wr,qr,Gr,Kr,Xr,Yr,Jr,Qr,Zr={};function te(){if(kr)return Nr;kr=1;var t=on(),n=it(),r=function(){if(Tr)return Lr;Tr=1;var t=Mr(),n=Rr().concat("length","prototype");return Lr.f=Object.getOwnPropertyNames||function(r){return t(r,n)},Lr}(),e=(Cr||(Cr=1,Zr.f=Object.getOwnPropertySymbols),Zr),o=rn(),i=n([].concat);return Nr=t("Reflect","ownKeys")||function(t){var n=r.f(o(t)),u=e.f;return u?i(n,u(t)):n}}function ne(){if(Dr)return Fr;Dr=1;var t=at(),n=te(),r=ar(),e=vn();return Fr=function(o,i,u){for(var c=n(i),f=e.f,a=r.f,l=0;l<c.length;l++){var s=c[l];t(o,s)||u&&t(u,s)||f(o,s,a(i,s))}}}function re(){if(Br)return $r;Br=1;var t=h(),n=ar().f,r=Un(),e=Xn(),o=tt(),i=ne(),u=function(){if(zr)return Hr;zr=1;var t=et(),n=yt(),r=/#|\.prototype\./,e=function(r,e){var f=i[o(r)];return f===c||f!==u&&(n(e)?t(e):!!e)},o=e.normalize=function(t){return String(t).replace(r,".").toLowerCase()},i=e.data={},u=e.NATIVE="N",c=e.POLYFILL="P";return Hr=e}();return $r=function(c,f){var a,l,s,p,v,d=c.target,h=c.global,y=c.stat;if(a=h?t:y?t[d]||o(d,{}):t[d]&&t[d].prototype)for(l in f){if(p=f[l],s=c.dontCallGetSet?(v=n(a,l))&&v.value:a[l],!u(h?l:d+(y?".":"#")+l,c.forced)&&void 0!==s){if(typeof p==typeof s)continue;i(p,s)}(c.sham||s&&s.sham)&&r(p,"sham",!0),e(a,l,p,c)}}}function ee(){if(qr)return Wr;qr=1;var t=it();return Wr=t([].slice)}function oe(){if(Kr)return Gr;Kr=1;var t=it(),n=fn(),r=Qt(),e=at(),o=ee(),i=ot(),u=Function,c=t([].concat),f=t([].join),a={};return Gr=i?u.bind:function(t){var i=n(this),l=i.prototype,s=o(arguments,1),p=function(){var n=c(s,o(arguments));return this instanceof p?function(t,n,r){if(!e(a,n)){for(var o=[],i=0;i<n;i++)o[i]="a["+i+"]";a[n]=u("C,a","return new C("+f(o,",")+")")}return a[n](t,r)}(i,n.length,n):i.apply(t,n)};return r(l)&&(p.prototype=l),p},Gr}function ie(){if(Yr)return Xr;Yr=1;var t=it(),n=et(),r=yt(),e=Jn(),o=on(),i=Bn(),u=function(){},c=o("Reflect","construct"),f=/^\s*(?:class|function)\b/,a=t(f.exec),l=!f.test(u),s=function(t){if(!r(t))return!1;try{return c(u,[],t),!0}catch(t){return!1}},p=function(t){if(!r(t))return!1;switch(e(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return l||!!a(f,i(t))}catch(t){return!0}};return p.sham=!0,Xr=!c||n((function(){var t;return s(s.call)||!s(Object)||!s((function(){t=!0}))||t}))?p:s}function ue(){if(Qr)return Jr;Qr=1;var t=ie(),n=cn(),r=TypeError;return Jr=function(e){if(t(e))return e;throw new r(n(e)+" is not a constructor")}}var ce,fe,ae,le,se,pe,ve,de,he={};function ye(){if(fe)return ce;fe=1;var t=Mr(),n=Rr();return ce=Object.keys||function(r){return t(r,n)}}function me(){if(ve)return pe;ve=1;var t,n=rn(),r=function(){if(ae)return he;ae=1;var t=Jt(),n=nn(),r=vn(),e=rn(),o=fr(),i=ye();return he.f=t&&!n?Object.defineProperties:function(t,n){e(t);for(var u,c=o(n),f=i(n),a=f.length,l=0;a>l;)r.f(t,u=f[l++],c[u]);return t},he}(),e=Rr(),o=qn(),i=function(){if(se)return le;se=1;var t=on();return le=t("document","documentElement")}(),u=Zt(),c=Wn(),f="prototype",a="script",l=c("IE_PROTO"),s=function(){},p=function(t){return"<"+a+">"+t+"</"+a+">"},v=function(t){t.write(p("")),t.close();var n=t.parentWindow.Object;return t=null,n},d=function(){try{t=new ActiveXObject("htmlfile")}catch(t){}var n,r,o;d="undefined"!=typeof document?document.domain&&t?v(t):(r=u("iframe"),o="java"+a+":",r.style.display="none",i.appendChild(r),r.src=String(o),(n=r.contentWindow.document).open(),n.write(p("document.F=Object")),n.close(),n.F):v(t);for(var c=e.length;c--;)delete d[f][e[c]];return d()};return o[l]=!0,pe=Object.create||function(t,e){var o;return null!==t?(s[f]=n(t),o=new s,s[f]=null,o[l]=t):o=d(),void 0===e?o:r.f(o,e)}}!function(){if(de)return or;de=1;var t=re(),n=on(),r=function(){if(Ur)return Vr;Ur=1;var t=ot(),n=Function.prototype,r=n.apply,e=n.call;return Vr="object"==typeof Reflect&&Reflect.apply||(t?e.bind(r):function(){return e.apply(r,arguments)}),Vr}(),e=oe(),o=ue(),i=rn(),u=Qt(),c=me(),f=et(),a=n("Reflect","construct"),l=Object.prototype,s=[].push,p=f((function(){function t(){}return!(a((function(){}),[],t)instanceof t)})),v=!f((function(){a((function(){}))})),d=p||v;t({target:"Reflect",stat:!0,forced:d,sham:d},{construct:function(t,n){o(t),i(n);var f=arguments.length<3?t:o(arguments[2]);if(v&&!p)return a(t,n,f);if(t===f){switch(n.length){case 0:return new t;case 1:return new t(n[0]);case 2:return new t(n[0],n[1]);case 3:return new t(n[0],n[1],n[2]);case 4:return new t(n[0],n[1],n[2],n[3])}var d=[null];return r(s,d,n),new(r(e,t,d))}var h=f.prototype,y=c(u(h)?h:l),m=r(t,y,n);return u(m)?m:y}})}(),function(){if(void 0!==window.Reflect&&void 0!==window.customElements&&!window.customElements.polyfillWrapFlushCallback){var t=HTMLElement,n=function(){return Reflect.construct(t,[],this.constructor)};window.HTMLElement=n,HTMLElement.prototype=t.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,t)}}();var ge=function(n){function r(){var t=n.call(this)||this,r=t.attachShadow({mode:"open"}),e=r.ownerDocument.createElement("span");return e.style.display="inline-block",r.appendChild(e),t.span=e,t}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}a(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(r,n),Object.defineProperty(r,"observedAttributes",{get:function(){return["data-value"]},enumerable:!1,configurable:!0}),r.prototype.attributeChangedCallback=function(t,n,r){if("data-value"===t){if(n===r)return;this.render(r||"")}},r.prototype.render=function(n){t.render(n,this.span,{throwOnError:!1,output:"mathml"})},r}(HTMLElement);window.customElements.get("w-e-formula-card")||window.customElements.define("w-e-formula-card",ge),n("en",{formula:{formula:"Formula",placeholder:"Use LateX syntax",insert:"Insert formula",edit:"Edit formula",ok:"OK"}}),n("zh-CN",{formula:{formula:"公式",placeholder:"使用 LateX 语法",insert:"插入公式",edit:"编辑公式",ok:"确定"}});var be,we,Oe,xe,Ee,Se,je,Te,Le,Pe,Ie,_e,Ae,Me,Re,Ce={type:"formula",elemToHtml:function(t,n){var r=t.value;return'<span data-w-e-type="formula" data-w-e-is-void data-w-e-is-inline data-value="'.concat(void 0===r?"":r,'"></span>')}},Ne={};function ke(){if(xe)return Oe;xe=1;var t=function(){if(we)return be;we=1;var t=Yn(),n=it();return be=function(r){if("Function"===t(r))return n(r)}}(),n=fn(),r=ot(),e=t(t.bind);return Oe=function(t,o){return n(t),void 0===o?t:r?e(t,o):function(){return t.apply(o,arguments)}},Oe}function Fe(){if(Se)return Ee;Se=1;var t=Yn();return Ee=Array.isArray||function(n){return"Array"===t(n)}}function De(){if(Te)return je;Te=1;var t=Fe(),n=ie(),r=Qt(),e=dt()("species"),o=Array;return je=function(i){var u;return t(i)&&(u=i.constructor,(n(u)&&(u===o||t(u.prototype))||r(u)&&null===(u=u[e]))&&(u=void 0)),void 0===u?o:u}}function He(){if(Pe)return Le;Pe=1;var t=De();return Le=function(n,r){return new(t(n))(0===r?0:r)}}function ze(){if(Me)return Ae;Me=1;var t=dt(),n=me(),r=vn().f,e=t("unscopables"),o=Array.prototype;return void 0===o[e]&&r(o,e,{configurable:!0,value:n(null)}),Ae=function(t){o[e][t]=!0}}!function(){if(Re)return Ne;Re=1;var t=re(),n=function(){if(_e)return Ie;_e=1;var t=ke(),n=it(),r=cr(),e=ft(),o=Ar(),i=He(),u=n([].push),c=function(n){var c=1===n,f=2===n,a=3===n,l=4===n,s=6===n,p=7===n,v=5===n||s;return function(d,h,y,m){for(var g,b,w=e(d),O=r(w),x=o(O),E=t(h,y),S=0,j=m||i,T=c?j(d,x):f||p?j(d,0):void 0;x>S;S++)if((v||S in O)&&(b=E(g=O[S],S,w),n))if(c)T[S]=b;else if(b)switch(n){case 3:return!0;case 5:return g;case 6:return S;case 2:u(T,g)}else switch(n){case 4:return!1;case 7:u(T,g)}return s?-1:a||l?l:T}};return Ie={forEach:c(0),map:c(1),filter:c(2),some:c(3),every:c(4),find:c(5),findIndex:c(6),filterReject:c(7)}}().find,r=ze(),e="find",o=!0;e in[]&&Array(1)[e]((function(){o=!1})),t({target:"Array",proto:!0,forced:o},{find:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}}),r(e)}();var $e,Be,Ve,Ue,We,qe,Ge,Ke,Xe,Ye,Je,Qe,Ze,to={};function no(){if(Be)return $e;Be=1;var t=Jn(),n=String;return $e=function(r){if("Symbol"===t(r))throw new TypeError("Cannot convert a Symbol value to a string");return n(r)}}function ro(){if(Ue)return Ve;Ue=1;var t=rn();return Ve=function(){var n=t(this),r="";return n.hasIndices&&(r+="d"),n.global&&(r+="g"),n.ignoreCase&&(r+="i"),n.multiline&&(r+="m"),n.dotAll&&(r+="s"),n.unicode&&(r+="u"),n.unicodeSets&&(r+="v"),n.sticky&&(r+="y"),r}}function eo(){if(Qe)return Je;Qe=1;var t,n,r=en(),e=it(),o=no(),i=ro(),u=function(){if(qe)return We;qe=1;var t=et(),n=h().RegExp,r=t((function(){var t=n("a","y");return t.lastIndex=2,null!==t.exec("abcd")})),e=r||t((function(){return!n("a","y").sticky})),o=r||t((function(){var t=n("^r","gy");return t.lastIndex=2,null!==t.exec("str")}));return We={BROKEN_CARET:o,MISSED_STICKY:e,UNSUPPORTED_Y:r}}(),c=rt(),f=me(),a=Gn().get,l=function(){if(Ke)return Ge;Ke=1;var t=et(),n=h().RegExp;return Ge=t((function(){var t=n(".","s");return!(t.dotAll&&t.test("\n")&&"s"===t.flags)}))}(),s=function(){if(Ye)return Xe;Ye=1;var t=et(),n=h().RegExp;return Xe=t((function(){var t=n("(?<a>b)","g");return"b"!==t.exec("b").groups.a||"bc"!=="b".replace(t,"$<a>c")}))}(),p=c("native-string-replace",String.prototype.replace),v=RegExp.prototype.exec,d=v,y=e("".charAt),m=e("".indexOf),g=e("".replace),b=e("".slice),w=(n=/b*/g,r(v,t=/a/,"a"),r(v,n,"a"),0!==t.lastIndex||0!==n.lastIndex),O=u.BROKEN_CARET,x=void 0!==/()??/.exec("")[1];return(w||x||O||l||s)&&(d=function(t){var n,e,u,c,l,s,h,E=this,S=a(E),j=o(t),T=S.raw;if(T)return T.lastIndex=E.lastIndex,n=r(d,T,j),E.lastIndex=T.lastIndex,n;var L=S.groups,P=O&&E.sticky,I=r(i,E),_=E.source,A=0,M=j;if(P&&(I=g(I,"y",""),-1===m(I,"g")&&(I+="g"),M=b(j,E.lastIndex),E.lastIndex>0&&(!E.multiline||E.multiline&&"\n"!==y(j,E.lastIndex-1))&&(_="(?: "+_+")",M=" "+M,A++),e=new RegExp("^(?:"+_+")",I)),x&&(e=new RegExp("^"+_+"$(?!\\s)",I)),w&&(u=E.lastIndex),c=r(v,P?e:E,M),P?c?(c.input=b(c.input,A),c[0]=b(c[0],A),c.index=E.lastIndex,E.lastIndex+=c[0].length):E.lastIndex=0:w&&c&&(E.lastIndex=E.global?c.index+c[0].length:u),x&&c&&c.length>1&&r(p,c[0],e,(function(){for(l=1;l<arguments.length-2;l++)void 0===arguments[l]&&(c[l]=void 0)})),c&&L)for(c.groups=s=f(null),l=0;l<L.length;l++)s[(h=L[l])[0]]=c[h[1]];return c}),Je=d}!function(){if(Ze)return to;Ze=1;var t=re(),n=eo();t({target:"RegExp",proto:!0,forced:/./.exec!==n},{exec:n})}();var oo,io,uo,co,fo,ao,lo,so={};function po(){return io?oo:(io=1,oo="\t\n\v\f\r                 \u2028\u2029\ufeff")}!function(){if(lo)return so;lo=1;var t=re(),n=function(){if(co)return uo;co=1;var t=it(),n=ct(),r=no(),e=po(),o=t("".replace),i=RegExp("^["+e+"]+"),u=RegExp("(^|[^"+e+"])["+e+"]+$"),c=function(t){return function(e){var c=r(n(e));return 1&t&&(c=o(c,i,"")),2&t&&(c=o(c,u,"$1")),c}};return uo={start:c(1),end:c(2),trim:c(3)}}().trim,r=function(){if(ao)return fo;ao=1;var t=$n().PROPER,n=et(),r=po();return fo=function(e){return n((function(){return!!r[e]()||"​…᠎"!=="​…᠎"[e]()||t&&r[e].name!==e}))}}();t({target:"String",proto:!0,forced:r("trim")},{trim:function(){return n(this)}})}();var vo,ho,yo={};function mo(t){return null!==t&&"object"==typeof t&&"constructor"in t&&t.constructor===Object}function go(t,n){void 0===t&&(t={}),void 0===n&&(n={}),Object.keys(n).forEach((function(r){void 0===t[r]?t[r]=n[r]:mo(n[r])&&mo(t[r])&&Object.keys(n[r]).length>0&&go(t[r],n[r])}))}ho||(ho=1,function(){if(vo)return yo;vo=1;var t=re(),n=h();t({global:!0,forced:n.globalThis!==n},{globalThis:n})}());var bo={body:{},addEventListener:function(){},removeEventListener:function(){},activeElement:{blur:function(){},nodeName:""},querySelector:function(){return null},querySelectorAll:function(){return[]},getElementById:function(){return null},createEvent:function(){return{initEvent:function(){}}},createElement:function(){return{children:[],childNodes:[],style:{},setAttribute:function(){},getElementsByTagName:function(){return[]}}},createElementNS:function(){return{}},importNode:function(){return null},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function wo(){var t="undefined"!=typeof document?document:{};return go(t,bo),t}var Oo={document:bo,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState:function(){},pushState:function(){},go:function(){},back:function(){}},CustomEvent:function(){return this},addEventListener:function(){},removeEventListener:function(){},getComputedStyle:function(){return{getPropertyValue:function(){return""}}},Image:function(){},Date:function(){},screen:{},setTimeout:function(){},clearTimeout:function(){},matchMedia:function(){return{}},requestAnimationFrame:function(t){return"undefined"==typeof setTimeout?(t(),null):setTimeout(t,0)},cancelAnimationFrame:function(t){"undefined"!=typeof setTimeout&&clearTimeout(t)}};function xo(){var t="undefined"!=typeof window?window:{};return go(t,Oo),t}function Eo(t){return Eo=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Eo(t)}function So(t,n){return So=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t},So(t,n)}function jo(t,n,r){return jo=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct:function(t,n,r){var e=[null];e.push.apply(e,n);var o=new(Function.bind.apply(t,e));return r&&So(o,r.prototype),o},jo.apply(null,arguments)}function To(t){var n="function"==typeof Map?new Map:void 0;return To=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return jo(t,arguments,Eo(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),So(e,t)},To(t)}var Lo=function(t){var n,r;function e(n){var r,e,o;return r=t.call.apply(t,[this].concat(n))||this,e=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(r),o=e.__proto__,Object.defineProperty(e,"__proto__",{get:function(){return o},set:function(t){o.__proto__=t}}),r}return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,e}(To(Array));function Po(t,n){var r=xo(),e=wo(),o=[];if(!n&&t instanceof Lo)return t;if(!t)return new Lo(o);if("string"==typeof t){var i=t.trim();if(i.indexOf("<")>=0&&i.indexOf(">")>=0){var u="div";0===i.indexOf("<li")&&(u="ul"),0===i.indexOf("<tr")&&(u="tbody"),0!==i.indexOf("<td")&&0!==i.indexOf("<th")||(u="tr"),0===i.indexOf("<tbody")&&(u="table"),0===i.indexOf("<option")&&(u="select");var c=e.createElement(u);c.innerHTML=i;for(var f=0;f<c.childNodes.length;f+=1)o.push(c.childNodes[f])}else o=function(t,n){if("string"!=typeof t)return[t];for(var r=[],e=n.querySelectorAll(t),o=0;o<e.length;o+=1)r.push(e[o]);return r}(t.trim(),n||e)}else if(t.nodeType||t===r||t===e)o.push(t);else if(Array.isArray(t)){if(t instanceof Lo)return t;o=t}return new Lo(function(t){for(var n=[],r=0;r<t.length;r+=1)-1===n.indexOf(t[r])&&n.push(t[r]);return n}(o))}function Io(t){if(void 0===t){var n=this[0];if(!n)return;if(n.multiple&&"select"===n.nodeName.toLowerCase()){for(var r=[],e=0;e<n.selectedOptions.length;e+=1)r.push(n.selectedOptions[e].value);return r}return n.value}for(var o=0;o<this.length;o+=1){var i=this[o];if(Array.isArray(t)&&i.multiple&&"select"===i.nodeName.toLowerCase())for(var u=0;u<i.options.length;u+=1)i.options[u].selected=t.indexOf(i.options[u].value)>=0;else i.value=t}return this}function _o(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var e=n[0],o=n[1],i=n[2],u=n[3];function c(t){var n=t.target;if(n){var r=t.target.dom7EventData||[];if(r.indexOf(t)<0&&r.unshift(t),Po(n).is(o))i.apply(n,r);else for(var e=Po(n).parents(),u=0;u<e.length;u+=1)Po(e[u]).is(o)&&i.apply(e[u],r)}}function f(t){var n=t&&t.target&&t.target.dom7EventData||[];n.indexOf(t)<0&&n.unshift(t),i.apply(this,n)}"function"==typeof n[1]&&(e=n[0],i=n[1],u=n[2],o=void 0),u||(u=!1);for(var a,l=e.split(" "),s=0;s<this.length;s+=1){var p=this[s];if(o)for(a=0;a<l.length;a+=1){var v=l[a];p.dom7LiveListeners||(p.dom7LiveListeners={}),p.dom7LiveListeners[v]||(p.dom7LiveListeners[v]=[]),p.dom7LiveListeners[v].push({listener:i,proxyListener:c}),p.addEventListener(v,c,u)}else for(a=0;a<l.length;a+=1){var d=l[a];p.dom7Listeners||(p.dom7Listeners={}),p.dom7Listeners[d]||(p.dom7Listeners[d]=[]),p.dom7Listeners[d].push({listener:i,proxyListener:f}),p.addEventListener(d,f,u)}}return this}function Ao(t){if(void 0===t)return this[0]?this[0].innerHTML:null;for(var n=0;n<this.length;n+=1)this[n].innerHTML=t;return this}function Mo(t){var n,r,e=xo(),o=wo(),i=this[0];if(!i||void 0===t)return!1;if("string"==typeof t){if(i.matches)return i.matches(t);if(i.webkitMatchesSelector)return i.webkitMatchesSelector(t);if(i.msMatchesSelector)return i.msMatchesSelector(t);for(n=Po(t),r=0;r<n.length;r+=1)if(n[r]===i)return!0;return!1}if(t===o)return i===o;if(t===e)return i===e;if(t.nodeType||t instanceof Lo){for(n=t.nodeType?[t]:t,r=0;r<n.length;r+=1)if(n[r]===i)return!0;return!1}return!1}function Ro(){for(var t,n=wo(),r=0;r<arguments.length;r+=1){t=r<0||arguments.length<=r?void 0:arguments[r];for(var e=0;e<this.length;e+=1)if("string"==typeof t){var o=n.createElement("div");for(o.innerHTML=t;o.firstChild;)this[e].appendChild(o.firstChild)}else if(t instanceof Lo)for(var i=0;i<t.length;i+=1)this[e].appendChild(t[i]);else this[e].appendChild(t)}return this}function Co(t){for(var n=[],r=0;r<this.length;r+=1)for(var e=this[r].parentNode;e;)t?Po(e).is(t)&&n.push(e):n.push(e),e=e.parentNode;return Po(n)}function No(t){for(var n=[],r=0;r<this.length;r+=1)for(var e=this[r].querySelectorAll(t),o=0;o<e.length;o+=1)n.push(e[o]);return Po(n)}Po.fn=Lo.prototype;var ko="resize scroll".split(" ");var Fo,Do=(Fo="focus",function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];if(void 0===n[0]){for(var e=0;e<this.length;e+=1)ko.indexOf(Fo)<0&&(Fo in this[e]?this[e][Fo]():Po(this[e]).trigger(Fo));return this}return this.on.apply(this,[Fo].concat(n))});Ro&&(Po.fn.append=Ro),Ao&&(Po.fn.html=Ao),Io&&(Po.fn.val=Io),_o&&(Po.fn.on=_o),Do&&(Po.fn.focus=Do),Mo&&(Po.fn.is=Mo),Co&&(Po.fn.parents=Co),No&&(Po.fn.find=No);var Ho,zo,$o,Bo,Vo,Uo,Wo,qo={};function Go(){if(zo)return Ho;zo=1;var t=TypeError;return Ho=function(n){if(n>9007199254740991)throw t("Maximum allowed index exceeded");return n}}function Ko(){if(Bo)return $o;Bo=1;var t=Jt(),n=vn(),r=Vn();return $o=function(e,o,i){t?n.f(e,o,r(0,i)):e[o]=i}}function Xo(){if(Uo)return Vo;Uo=1;var t=et(),n=dt(),r=st(),e=n("species");return Vo=function(n){return r>=51||!t((function(){var t=[];return(t.constructor={})[e]=function(){return{foo:1}},1!==t[n](Boolean).foo}))}}!function(){if(Wo)return qo;Wo=1;var t=re(),n=et(),r=Fe(),e=Qt(),o=ft(),i=Ar(),u=Go(),c=Ko(),f=He(),a=Xo(),l=dt(),s=st(),p=l("isConcatSpreadable"),v=s>=51||!n((function(){var t=[];return t[p]=!1,t.concat()[0]!==t})),d=function(t){if(!e(t))return!1;var n=t[p];return void 0!==n?!!n:r(t)};t({target:"Array",proto:!0,arity:1,forced:!v||!a("concat")},{concat:function(t){var n,r,e,a,l,s=o(this),p=f(s,0),v=0;for(n=-1,e=arguments.length;n<e;n++)if(d(l=-1===n?s:arguments[n]))for(a=i(l),u(v+a),r=0;r<a;r++,v++)r in l&&c(p,v,l[r]);else u(v+1),c(p,v++,l);return p.length=v,p}})}();let Yo=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,n)=>t+=(n&=63)<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n>62?"-":"_"),"");function Jo(t){return"".concat(t,"-").concat(Yo())}function Qo(){return Jo("w-e-insert-formula")}var Zo=function(){function t(){this.title=r("formula.edit"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=Qo(),this.buttonId=Qo()}return t.prototype.getSelectedElem=function(t){var n=e.getSelectedNodeByType(t,"formula");return null==n?null:n},t.prototype.getValue=function(t){var n=this.getSelectedElem(t);return n&&n.value||""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,n){},t.prototype.isDisabled=function(t){var n=t.selection;return null==n||(!!o.isExpanded(n)||null==this.getSelectedElem(t))},t.prototype.getModalPositionNode=function(t){return this.getSelectedElem(t)},t.prototype.getModalContentElem=function(t){var n=this,e=this.textareaId,o=this.buttonId,c=l(i(r("formula.formula"),e,r("formula.placeholder")),2),f=c[0],a=Po(c[1]),s=l(u(o,r("formula.ok")),1)[0];if(null==this.$content){var p=Po("<div></div>");p.on("click","#".concat(o),(function(r){r.preventDefault();var o=p.find("#".concat(e)).val().trim();n.updateFormula(t,o),t.hidePanelOrModal()})),this.$content=p}var v=this.$content;v.html(""),v.append(f),v.append(s);var d=this.getValue(t);return a.val(d),setTimeout((function(){a.focus()})),v[0]},t.prototype.updateFormula=function(t,n){if(n&&(t.restoreSelection(),!this.isDisabled(t))){var r=this.getSelectedElem(t);if(null!=r){var o=e.findPath(t,r),i={value:n};c.setNodes(t,i,{at:o})}}},t}();function ti(){return Jo("w-e-insert-formula")}var ni=function(){function t(){this.title=r("formula.insert"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=ti(),this.buttonId=ti()}return t.prototype.getValue=function(t){return""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,n){},t.prototype.isDisabled=function(t){var n=t.selection;if(null==n)return!0;if(o.isExpanded(n))return!0;var r=e.getSelectedElems(t);return!!r.some((function(n){return t.isVoid(n)}))||!!r.some((function(t){return"pre"===e.getNodeType(t)}))},t.prototype.getModalPositionNode=function(t){return null},t.prototype.getModalContentElem=function(t){var n=this,e=this.textareaId,o=this.buttonId,c=l(i(r("formula.formula"),e,r("formula.placeholder")),2),f=c[0],a=Po(c[1]),s=l(u(o,r("formula.ok")),1)[0];if(null==this.$content){var p=Po("<div></div>");p.on("click","#".concat(o),(function(r){r.preventDefault();var o=p.find("#".concat(e)).val().trim();n.insertFormula(t,o),t.hidePanelOrModal()})),this.$content=p}var v=this.$content;return v.html(""),v.append(f),v.append(s),a.val(""),setTimeout((function(){a.focus()})),v[0]},t.prototype.insertFormula=function(t,n){if(n&&(t.restoreSelection(),!this.isDisabled(t))){var r={type:"formula",value:n,children:[{text:""}]};t.insertNode(r)}},t}();var ri={editorPlugin:function(t){var n=t.isInline,r=t.isVoid,o=t;return o.isInline=function(t){return"formula"===e.getNodeType(t)||n(t)},o.isVoid=function(t){return"formula"===e.getNodeType(t)||r(t)},o},renderElems:[{type:"formula",renderElem:function(t,n,r){var o=e.isNodeSelected(r,t),i=t.value,u=f("w-e-formula-card",{dataset:{value:void 0===i?"":i}},null);return f("div",{className:"w-e-textarea-formula-container",props:{contentEditable:!1},style:{display:"inline-block",marginLeft:"3px",marginRight:"3px",border:o?"2px solid var(--w-e-textarea-selected-border-color)":"2px solid transparent",borderRadius:"3px",padding:"3px 3px"}},[u])}}],elemsToHtml:[Ce],parseElemsHtml:[{selector:'span[data-w-e-type="formula"]',parseElemHtml:function(t,n,r){return{type:"formula",value:t.getAttribute("data-value")||"",children:[{text:""}]}}}],menus:[{key:"insertFormula",factory:function(){return new ni}},{key:"editFormula",factory:function(){return new Zo}}]};export{ri as default};
2
+ //# sourceMappingURL=index.mjs.map