fable-editor 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular/core/word-image-paste.d.ts +9 -0
- package/dist/angular/esm2022/core/editor.mjs +47 -13
- package/dist/angular/esm2022/core/word-image-paste.mjs +73 -4
- package/dist/angular/fesm2022/fable-editor.mjs +118 -15
- package/dist/angular/fesm2022/fable-editor.mjs.map +1 -1
- package/dist/core/editor.d.ts.map +1 -1
- package/dist/core/index.cjs +3 -3
- package/dist/core/index.mjs +498 -465
- package/dist/core/word-image-paste.d.ts +9 -0
- package/dist/core/word-image-paste.d.ts.map +1 -1
- package/dist/react/index.cjs +10 -10
- package/dist/react/index.mjs +666 -633
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import me, { forwardRef as Ye, useRef as z, useImperativeHandle as Ge, useEffect as lt } from "react";
|
|
2
2
|
var Mt = { exports: {} }, J = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
@@ -10,18 +10,18 @@ var Mt = { exports: {} }, J = {};
|
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
12
|
var Jt;
|
|
13
|
-
function
|
|
13
|
+
function Ke() {
|
|
14
14
|
if (Jt) return J;
|
|
15
15
|
Jt = 1;
|
|
16
|
-
var u =
|
|
17
|
-
function
|
|
16
|
+
var u = me, t = Symbol.for("react.element"), e = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, s = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, n = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
17
|
+
function r(o, l, a) {
|
|
18
18
|
var d, p = {}, m = null, v = null;
|
|
19
|
-
a !== void 0 && (m = "" + a),
|
|
20
|
-
for (d in
|
|
21
|
-
if (
|
|
22
|
-
return { $$typeof: t, type:
|
|
19
|
+
a !== void 0 && (m = "" + a), l.key !== void 0 && (m = "" + l.key), l.ref !== void 0 && (v = l.ref);
|
|
20
|
+
for (d in l) i.call(l, d) && !n.hasOwnProperty(d) && (p[d] = l[d]);
|
|
21
|
+
if (o && o.defaultProps) for (d in l = o.defaultProps, l) p[d] === void 0 && (p[d] = l[d]);
|
|
22
|
+
return { $$typeof: t, type: o, key: m, ref: v, props: p, _owner: s.current };
|
|
23
23
|
}
|
|
24
|
-
return J.Fragment = e, J.jsx =
|
|
24
|
+
return J.Fragment = e, J.jsx = r, J.jsxs = r, J;
|
|
25
25
|
}
|
|
26
26
|
var tt = {};
|
|
27
27
|
/**
|
|
@@ -34,9 +34,9 @@ var tt = {};
|
|
|
34
34
|
* LICENSE file in the root directory of this source tree.
|
|
35
35
|
*/
|
|
36
36
|
var te;
|
|
37
|
-
function
|
|
37
|
+
function Qe() {
|
|
38
38
|
return te || (te = 1, process.env.NODE_ENV !== "production" && function() {
|
|
39
|
-
var u =
|
|
39
|
+
var u = me, t = Symbol.for("react.element"), e = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), n = Symbol.for("react.profiler"), r = Symbol.for("react.provider"), o = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), a = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), p = Symbol.for("react.memo"), m = Symbol.for("react.lazy"), v = Symbol.for("react.offscreen"), b = Symbol.iterator, f = "@@iterator";
|
|
40
40
|
function y(c) {
|
|
41
41
|
if (c === null || typeof c != "object")
|
|
42
42
|
return null;
|
|
@@ -61,16 +61,16 @@ function Ke() {
|
|
|
61
61
|
H.unshift("Warning: " + g), Function.prototype.apply.call(console[c], console, H);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
var A = !1, $ = !1,
|
|
64
|
+
var A = !1, $ = !1, F = !1, Z = !1, et = !1, kt;
|
|
65
65
|
kt = Symbol.for("react.module.reference");
|
|
66
|
-
function
|
|
67
|
-
return !!(typeof c == "string" || typeof c == "function" || c === i || c === n || et || c === s || c === a || c === d ||
|
|
66
|
+
function xe(c) {
|
|
67
|
+
return !!(typeof c == "string" || typeof c == "function" || c === i || c === n || et || c === s || c === a || c === d || Z || c === v || A || $ || F || typeof c == "object" && c !== null && (c.$$typeof === m || c.$$typeof === p || c.$$typeof === r || c.$$typeof === o || c.$$typeof === l || // This needs to include all possible module reference object
|
|
68
68
|
// types supported by any Flight configuration anywhere since
|
|
69
69
|
// we don't know which Flight build this will end up being used
|
|
70
70
|
// with.
|
|
71
71
|
c.$$typeof === kt || c.getModuleId !== void 0));
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function Ce(c, g, x) {
|
|
74
74
|
var T = c.displayName;
|
|
75
75
|
if (T)
|
|
76
76
|
return T;
|
|
@@ -103,14 +103,14 @@ function Ke() {
|
|
|
103
103
|
}
|
|
104
104
|
if (typeof c == "object")
|
|
105
105
|
switch (c.$$typeof) {
|
|
106
|
-
case
|
|
106
|
+
case o:
|
|
107
107
|
var g = c;
|
|
108
108
|
return At(g) + ".Consumer";
|
|
109
|
-
case
|
|
109
|
+
case r:
|
|
110
110
|
var x = c;
|
|
111
111
|
return At(x._context) + ".Provider";
|
|
112
|
-
case
|
|
113
|
-
return
|
|
112
|
+
case l:
|
|
113
|
+
return Ce(c, c.render, "ForwardRef");
|
|
114
114
|
case p:
|
|
115
115
|
var T = c.displayName || null;
|
|
116
116
|
return T !== null ? T : W(c.type) || "Memo";
|
|
@@ -129,7 +129,7 @@ function Ke() {
|
|
|
129
129
|
function Nt() {
|
|
130
130
|
}
|
|
131
131
|
Nt.__reactDisabledLog = !0;
|
|
132
|
-
function
|
|
132
|
+
function we() {
|
|
133
133
|
{
|
|
134
134
|
if (K === 0) {
|
|
135
135
|
Ht = console.log, It = console.info, qt = console.warn, Rt = console.error, Pt = console.group, Bt = console.groupCollapsed, Dt = console.groupEnd;
|
|
@@ -152,7 +152,7 @@ function Ke() {
|
|
|
152
152
|
K++;
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function Te() {
|
|
156
156
|
{
|
|
157
157
|
if (K--, K === 0) {
|
|
158
158
|
var c = {
|
|
@@ -203,8 +203,8 @@ function Ke() {
|
|
|
203
203
|
}
|
|
204
204
|
var gt = !1, st;
|
|
205
205
|
{
|
|
206
|
-
var
|
|
207
|
-
st = new
|
|
206
|
+
var Ee = typeof WeakMap == "function" ? WeakMap : Map;
|
|
207
|
+
st = new Ee();
|
|
208
208
|
}
|
|
209
209
|
function Ot(c, g) {
|
|
210
210
|
if (!c || gt)
|
|
@@ -219,7 +219,7 @@ function Ke() {
|
|
|
219
219
|
var k = Error.prepareStackTrace;
|
|
220
220
|
Error.prepareStackTrace = void 0;
|
|
221
221
|
var H;
|
|
222
|
-
H = mt.current, mt.current = null,
|
|
222
|
+
H = mt.current, mt.current = null, we();
|
|
223
223
|
try {
|
|
224
224
|
if (g) {
|
|
225
225
|
var M = function() {
|
|
@@ -272,15 +272,15 @@ function Ke() {
|
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
} finally {
|
|
275
|
-
gt = !1, mt.current = H,
|
|
275
|
+
gt = !1, mt.current = H, Te(), Error.prepareStackTrace = k;
|
|
276
276
|
}
|
|
277
277
|
var G = c ? c.displayName || c.name : "", V = G ? it(G) : "";
|
|
278
278
|
return typeof c == "function" && st.set(c, V), V;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function Se(c, g, x) {
|
|
281
281
|
return Ot(c, !1);
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function Me(c) {
|
|
284
284
|
var g = c.prototype;
|
|
285
285
|
return !!(g && g.isReactComponent);
|
|
286
286
|
}
|
|
@@ -288,7 +288,7 @@ function Ke() {
|
|
|
288
288
|
if (c == null)
|
|
289
289
|
return "";
|
|
290
290
|
if (typeof c == "function")
|
|
291
|
-
return Ot(c,
|
|
291
|
+
return Ot(c, Me(c));
|
|
292
292
|
if (typeof c == "string")
|
|
293
293
|
return it(c);
|
|
294
294
|
switch (c) {
|
|
@@ -299,8 +299,8 @@ function Ke() {
|
|
|
299
299
|
}
|
|
300
300
|
if (typeof c == "object")
|
|
301
301
|
switch (c.$$typeof) {
|
|
302
|
-
case
|
|
303
|
-
return
|
|
302
|
+
case l:
|
|
303
|
+
return Se(c.render);
|
|
304
304
|
case p:
|
|
305
305
|
return nt(c.type, g, x);
|
|
306
306
|
case m: {
|
|
@@ -313,15 +313,15 @@ function Ke() {
|
|
|
313
313
|
}
|
|
314
314
|
return "";
|
|
315
315
|
}
|
|
316
|
-
var Q = Object.prototype.hasOwnProperty,
|
|
316
|
+
var Q = Object.prototype.hasOwnProperty, Ft = {}, Zt = C.ReactDebugCurrentFrame;
|
|
317
317
|
function rt(c) {
|
|
318
318
|
if (c) {
|
|
319
319
|
var g = c._owner, x = nt(c.type, c._source, g ? g.type : null);
|
|
320
|
-
|
|
320
|
+
Zt.setExtraStackFrame(x);
|
|
321
321
|
} else
|
|
322
|
-
|
|
322
|
+
Zt.setExtraStackFrame(null);
|
|
323
323
|
}
|
|
324
|
-
function
|
|
324
|
+
function Le(c, g, x, T, k) {
|
|
325
325
|
{
|
|
326
326
|
var H = Function.call.bind(Q);
|
|
327
327
|
for (var M in c)
|
|
@@ -336,21 +336,21 @@ function Ke() {
|
|
|
336
336
|
} catch (R) {
|
|
337
337
|
S = R;
|
|
338
338
|
}
|
|
339
|
-
S && !(S instanceof Error) && (rt(k), E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", T || "React class", x, M, typeof S), rt(null)), S instanceof Error && !(S.message in
|
|
339
|
+
S && !(S instanceof Error) && (rt(k), E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", T || "React class", x, M, typeof S), rt(null)), S instanceof Error && !(S.message in Ft) && (Ft[S.message] = !0, rt(k), E("Failed %s type: %s", x, S.message), rt(null));
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
var
|
|
343
|
+
var ke = Array.isArray;
|
|
344
344
|
function vt(c) {
|
|
345
|
-
return
|
|
345
|
+
return ke(c);
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function Ae(c) {
|
|
348
348
|
{
|
|
349
349
|
var g = typeof Symbol == "function" && Symbol.toStringTag, x = g && c[Symbol.toStringTag] || c.constructor.name || "Object";
|
|
350
350
|
return x;
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function He(c) {
|
|
354
354
|
try {
|
|
355
355
|
return _t(c), !1;
|
|
356
356
|
} catch {
|
|
@@ -361,16 +361,16 @@ function Ke() {
|
|
|
361
361
|
return "" + c;
|
|
362
362
|
}
|
|
363
363
|
function $t(c) {
|
|
364
|
-
if (
|
|
365
|
-
return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",
|
|
364
|
+
if (He(c))
|
|
365
|
+
return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ae(c)), _t(c);
|
|
366
366
|
}
|
|
367
|
-
var jt = C.ReactCurrentOwner,
|
|
367
|
+
var jt = C.ReactCurrentOwner, Ie = {
|
|
368
368
|
key: !0,
|
|
369
369
|
ref: !0,
|
|
370
370
|
__self: !0,
|
|
371
371
|
__source: !0
|
|
372
372
|
}, Wt, Ut;
|
|
373
|
-
function
|
|
373
|
+
function qe(c) {
|
|
374
374
|
if (Q.call(c, "ref")) {
|
|
375
375
|
var g = Object.getOwnPropertyDescriptor(c, "ref").get;
|
|
376
376
|
if (g && g.isReactWarning)
|
|
@@ -378,7 +378,7 @@ function Ke() {
|
|
|
378
378
|
}
|
|
379
379
|
return c.ref !== void 0;
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function Re(c) {
|
|
382
382
|
if (Q.call(c, "key")) {
|
|
383
383
|
var g = Object.getOwnPropertyDescriptor(c, "key").get;
|
|
384
384
|
if (g && g.isReactWarning)
|
|
@@ -386,10 +386,10 @@ function Ke() {
|
|
|
386
386
|
}
|
|
387
387
|
return c.key !== void 0;
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function Pe(c, g) {
|
|
390
390
|
typeof c.ref == "string" && jt.current;
|
|
391
391
|
}
|
|
392
|
-
function
|
|
392
|
+
function Be(c, g) {
|
|
393
393
|
{
|
|
394
394
|
var x = function() {
|
|
395
395
|
Wt || (Wt = !0, E("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", g));
|
|
@@ -400,7 +400,7 @@ function Ke() {
|
|
|
400
400
|
});
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function De(c, g) {
|
|
404
404
|
{
|
|
405
405
|
var x = function() {
|
|
406
406
|
Ut || (Ut = !0, E("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", g));
|
|
@@ -411,7 +411,7 @@ function Ke() {
|
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
var
|
|
414
|
+
var Ne = function(c, g, x, T, k, H, M) {
|
|
415
415
|
var S = {
|
|
416
416
|
// This tag allows us to uniquely identify this as a React Element
|
|
417
417
|
$$typeof: t,
|
|
@@ -440,12 +440,12 @@ function Ke() {
|
|
|
440
440
|
value: k
|
|
441
441
|
}), Object.freeze && (Object.freeze(S.props), Object.freeze(S)), S;
|
|
442
442
|
};
|
|
443
|
-
function
|
|
443
|
+
function Oe(c, g, x, T, k) {
|
|
444
444
|
{
|
|
445
445
|
var H, M = {}, S = null, D = null;
|
|
446
|
-
x !== void 0 && ($t(x), S = "" + x),
|
|
446
|
+
x !== void 0 && ($t(x), S = "" + x), Re(g) && ($t(g.key), S = "" + g.key), qe(g) && (D = g.ref, Pe(g, k));
|
|
447
447
|
for (H in g)
|
|
448
|
-
Q.call(g, H) && !
|
|
448
|
+
Q.call(g, H) && !Ie.hasOwnProperty(H) && (M[H] = g[H]);
|
|
449
449
|
if (c && c.defaultProps) {
|
|
450
450
|
var R = c.defaultProps;
|
|
451
451
|
for (H in R)
|
|
@@ -453,9 +453,9 @@ function Ke() {
|
|
|
453
453
|
}
|
|
454
454
|
if (S || D) {
|
|
455
455
|
var P = typeof c == "function" ? c.displayName || c.name || "Unknown" : c;
|
|
456
|
-
S &&
|
|
456
|
+
S && Be(M, P), D && De(M, P);
|
|
457
457
|
}
|
|
458
|
-
return
|
|
458
|
+
return Ne(c, S, D, k, T, jt.current, M);
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
461
|
var bt = C.ReactCurrentOwner, Vt = C.ReactDebugCurrentFrame;
|
|
@@ -483,7 +483,7 @@ Check the render method of \`` + c + "`.";
|
|
|
483
483
|
return "";
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function Fe(c) {
|
|
487
487
|
return "";
|
|
488
488
|
}
|
|
489
489
|
var Xt = {};
|
|
@@ -531,7 +531,7 @@ Check the top-level render call using <` + x + ">.");
|
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
|
-
function
|
|
534
|
+
function _e(c) {
|
|
535
535
|
{
|
|
536
536
|
var g = c.type;
|
|
537
537
|
if (g == null || typeof g == "string")
|
|
@@ -539,7 +539,7 @@ Check the top-level render call using <` + x + ">.");
|
|
|
539
539
|
var x;
|
|
540
540
|
if (typeof g == "function")
|
|
541
541
|
x = g.propTypes;
|
|
542
|
-
else if (typeof g == "object" && (g.$$typeof ===
|
|
542
|
+
else if (typeof g == "object" && (g.$$typeof === l || // Note: Memo only checks outer props here.
|
|
543
543
|
// Inner props are checked in the reconciler.
|
|
544
544
|
g.$$typeof === p))
|
|
545
545
|
x = g.propTypes;
|
|
@@ -547,7 +547,7 @@ Check the top-level render call using <` + x + ">.");
|
|
|
547
547
|
return;
|
|
548
548
|
if (x) {
|
|
549
549
|
var T = W(g);
|
|
550
|
-
|
|
550
|
+
Le(x, c.props, "prop", T, c);
|
|
551
551
|
} else if (g.PropTypes !== void 0 && !yt) {
|
|
552
552
|
yt = !0;
|
|
553
553
|
var k = W(g);
|
|
@@ -556,7 +556,7 @@ Check the top-level render call using <` + x + ">.");
|
|
|
556
556
|
typeof g.getDefaultProps == "function" && !g.getDefaultProps.isReactClassApproved && E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
|
-
function
|
|
559
|
+
function $e(c) {
|
|
560
560
|
{
|
|
561
561
|
for (var g = Object.keys(c.props), x = 0; x < g.length; x++) {
|
|
562
562
|
var T = g[x];
|
|
@@ -571,16 +571,16 @@ Check the top-level render call using <` + x + ">.");
|
|
|
571
571
|
var Kt = {};
|
|
572
572
|
function Qt(c, g, x, T, k, H) {
|
|
573
573
|
{
|
|
574
|
-
var M =
|
|
574
|
+
var M = xe(c);
|
|
575
575
|
if (!M) {
|
|
576
576
|
var S = "";
|
|
577
577
|
(c === void 0 || typeof c == "object" && c !== null && Object.keys(c).length === 0) && (S += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
578
|
-
var D =
|
|
578
|
+
var D = Fe();
|
|
579
579
|
D ? S += D : S += zt();
|
|
580
580
|
var R;
|
|
581
581
|
c === null ? R = "null" : vt(c) ? R = "array" : c !== void 0 && c.$$typeof === t ? (R = "<" + (W(c.type) || "Unknown") + " />", S = " Did you accidentally export a JSX literal instead of a component?") : R = typeof c, E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", R, S);
|
|
582
582
|
}
|
|
583
|
-
var P =
|
|
583
|
+
var P = Oe(c, g, x, k, H);
|
|
584
584
|
if (P == null)
|
|
585
585
|
return P;
|
|
586
586
|
if (M) {
|
|
@@ -597,35 +597,35 @@ Check the top-level render call using <` + x + ">.");
|
|
|
597
597
|
Gt(_, c);
|
|
598
598
|
}
|
|
599
599
|
if (Q.call(g, "key")) {
|
|
600
|
-
var V = W(c), N = Object.keys(g).filter(function(
|
|
601
|
-
return
|
|
600
|
+
var V = W(c), N = Object.keys(g).filter(function(Xe) {
|
|
601
|
+
return Xe !== "key";
|
|
602
602
|
}), Ct = N.length > 0 ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
603
603
|
if (!Kt[V + Ct]) {
|
|
604
|
-
var
|
|
604
|
+
var ze = N.length > 0 ? "{" + N.join(": ..., ") + ": ...}" : "{}";
|
|
605
605
|
E(`A props object containing a "key" prop is being spread into JSX:
|
|
606
606
|
let props = %s;
|
|
607
607
|
<%s {...props} />
|
|
608
608
|
React keys must be passed directly to JSX without using spread:
|
|
609
609
|
let props = %s;
|
|
610
|
-
<%s key={someKey} {...props} />`, Ct, V,
|
|
610
|
+
<%s key={someKey} {...props} />`, Ct, V, ze, V), Kt[V + Ct] = !0;
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
|
-
return c === i ?
|
|
613
|
+
return c === i ? $e(P) : _e(P), P;
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
|
-
function
|
|
616
|
+
function je(c, g, x) {
|
|
617
617
|
return Qt(c, g, x, !0);
|
|
618
618
|
}
|
|
619
|
-
function
|
|
619
|
+
function We(c, g, x) {
|
|
620
620
|
return Qt(c, g, x, !1);
|
|
621
621
|
}
|
|
622
|
-
var
|
|
623
|
-
tt.Fragment = i, tt.jsx =
|
|
622
|
+
var Ue = We, Ve = je;
|
|
623
|
+
tt.Fragment = i, tt.jsx = Ue, tt.jsxs = Ve;
|
|
624
624
|
}()), tt;
|
|
625
625
|
}
|
|
626
|
-
process.env.NODE_ENV === "production" ? Mt.exports =
|
|
627
|
-
var
|
|
628
|
-
const
|
|
626
|
+
process.env.NODE_ENV === "production" ? Mt.exports = Ke() : Mt.exports = Qe();
|
|
627
|
+
var Je = Mt.exports;
|
|
628
|
+
const ti = {
|
|
629
629
|
en: {
|
|
630
630
|
dir: "ltr",
|
|
631
631
|
file: "File",
|
|
@@ -1012,9 +1012,9 @@ const Je = {
|
|
|
1012
1012
|
}
|
|
1013
1013
|
};
|
|
1014
1014
|
function wt(u) {
|
|
1015
|
-
return
|
|
1015
|
+
return ti[u];
|
|
1016
1016
|
}
|
|
1017
|
-
const
|
|
1017
|
+
const ei = "undo redo | preview print | importword revhistory | fontfamily fontsize | fontsizeincrease fontsizedecrease | bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | link blockquote code changecase lineheight wordspacing letterspacing | removeformat | blocks | ltr rtl | quickimage quickvideo quicktable codesample template charmap emoji | fullscreen sourcecode", ii = "file edit view insert format tools table help", si = [
|
|
1018
1018
|
["Andale Mono", "andale mono,times"],
|
|
1019
1019
|
["Arial", "arial,helvetica,sans-serif"],
|
|
1020
1020
|
["Arial Black", "arial black,avant garde"],
|
|
@@ -1034,7 +1034,7 @@ const ti = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
1034
1034
|
["Verdana", "verdana,geneva"],
|
|
1035
1035
|
["Webdings", "webdings"],
|
|
1036
1036
|
["Wingdings", "wingdings,zapf dingbats"]
|
|
1037
|
-
],
|
|
1037
|
+
], ni = ["8px", "9px", "10px", "11px", "12px", "14px", "16px", "18px", "20px", "24px", "28px", "32px", "36px", "48px", "72px", "96px"], ri = 1, li = 100, ee = ["1", "1.15", "1.4", "1.5", "1.75", "2", "2.5", "3"], ie = ["1px", "2px", "4px", "6px", "8px", "12px"], se = ["0.5px", "1px", "1.5px", "2px", "3px", "4px"], ne = [
|
|
1038
1038
|
["plain", "Plain text"],
|
|
1039
1039
|
["html", "HTML/XML"],
|
|
1040
1040
|
["css", "CSS"],
|
|
@@ -1060,7 +1060,7 @@ const ti = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
1060
1060
|
["h5", "heading5"],
|
|
1061
1061
|
["h6", "heading6"],
|
|
1062
1062
|
["pre", "pre"]
|
|
1063
|
-
],
|
|
1063
|
+
], oi = ["#F76707", "#4263EB", "#CC5DE8"], ai = [
|
|
1064
1064
|
"#FFFFFF",
|
|
1065
1065
|
"#F4F4F4",
|
|
1066
1066
|
"#E8EAED",
|
|
@@ -1086,7 +1086,7 @@ const ti = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
1086
1086
|
"#8E24AA",
|
|
1087
1087
|
"#C2185B",
|
|
1088
1088
|
"#6D4C41"
|
|
1089
|
-
],
|
|
1089
|
+
], ci = [
|
|
1090
1090
|
{
|
|
1091
1091
|
key: "chcat_currency",
|
|
1092
1092
|
chars: [
|
|
@@ -1426,7 +1426,7 @@ const ti = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
1426
1426
|
"ة"
|
|
1427
1427
|
]
|
|
1428
1428
|
}
|
|
1429
|
-
],
|
|
1429
|
+
], hi = [
|
|
1430
1430
|
{
|
|
1431
1431
|
key: "emcat_smileys",
|
|
1432
1432
|
chars: [
|
|
@@ -2380,7 +2380,7 @@ const ti = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
2380
2380
|
codesampleic: L(
|
|
2381
2381
|
'<rect x="3.5" y="4" width="17" height="16" rx="2"/><path d="M3.5 8.5h17"/><path d="M9.5 12 7 14.25l2.5 2.25M14.5 12l2.5 2.25-2.5 2.25"/>'
|
|
2382
2382
|
)
|
|
2383
|
-
},
|
|
2383
|
+
}, di = /* @__PURE__ */ new Set([
|
|
2384
2384
|
"p",
|
|
2385
2385
|
"div",
|
|
2386
2386
|
"span",
|
|
@@ -2422,7 +2422,7 @@ const ti = "undo redo | preview print | importword revhistory | fontfamily fonts
|
|
|
2422
2422
|
"figure",
|
|
2423
2423
|
"figcaption",
|
|
2424
2424
|
"mark"
|
|
2425
|
-
]),
|
|
2425
|
+
]), ui = /* @__PURE__ */ new Set([
|
|
2426
2426
|
"text-align",
|
|
2427
2427
|
"direction",
|
|
2428
2428
|
"unicode-bidi",
|
|
@@ -2494,13 +2494,13 @@ function pt(u) {
|
|
|
2494
2494
|
s < 1 || (t[i.slice(0, s).trim().toLowerCase()] = i.slice(s + 1).trim());
|
|
2495
2495
|
}), t;
|
|
2496
2496
|
}
|
|
2497
|
-
function
|
|
2497
|
+
function pi(u) {
|
|
2498
2498
|
return u.replace(/<!--\[if !supportLists\]-->([\s\S]*?)<!--\[endif\]-->/gi, "$1").replace(/<!--\[if !supportLists\]>([\s\S]*?)<!\[endif\]-->/gi, "$1").replace(/<!\[if !supportLists\]>([\s\S]*?)<!\[endif\]>/gi, "$1").replace(/<!--\[if [\s\S]*?<!\[endif\]-->/gi, "").replace(/<!--[\s\S]*?-->/g, "").replace(/<(script|style|xml|title)[\s\S]*?<\/\1>/gi, "").replace(/<\/?(meta|link)[^>]*>/gi, "").replace(/<\?xml[\s\S]*?\?>/gi, "").replace(/<\/?(o|v|w|m|st1):[^>]*>/gi, "");
|
|
2499
2499
|
}
|
|
2500
|
-
function
|
|
2500
|
+
function mi(u) {
|
|
2501
2501
|
return /^[0-9]+[\.\)،]/.test(u) ? { ordered: !0 } : /^[٠-٩۰-۹]+/.test(u) ? { ordered: !0, style: "arabic-indic" } : /^[ivxlc]{2,}[\.\)]/.test(u) ? { ordered: !0, style: "lower-roman" } : /^[IVXLC]{2,}[\.\)]/.test(u) ? { ordered: !0, style: "upper-roman" } : /^[a-z][\.\)]/.test(u) ? { ordered: !0, style: "lower-alpha" } : /^[A-Z][\.\)]/.test(u) ? { ordered: !0, style: "upper-alpha" } : /^[ء-ي][\.\)،-]/.test(u) ? { ordered: !0, style: "arabic-indic" } : { ordered: !1 };
|
|
2502
2502
|
}
|
|
2503
|
-
function
|
|
2503
|
+
function fi(u) {
|
|
2504
2504
|
const t = (s) => {
|
|
2505
2505
|
const n = (s.getAttribute("style") || "") + " " + (s.className || "");
|
|
2506
2506
|
return /mso-list\s*:(?!\s*ignore)/i.test(n) || /MsoListParagraph/i.test(n);
|
|
@@ -2514,12 +2514,12 @@ function mi(u) {
|
|
|
2514
2514
|
const n = s.previousElementSibling;
|
|
2515
2515
|
i && n && i[i.length - 1] === n ? i.push(s) : (i = [s], e.push(i));
|
|
2516
2516
|
}), e.forEach((s) => {
|
|
2517
|
-
const n = [],
|
|
2518
|
-
s.forEach((
|
|
2517
|
+
const n = [], r = s[0];
|
|
2518
|
+
s.forEach((o) => {
|
|
2519
2519
|
var C, E, I;
|
|
2520
|
-
const a = +(((C = (
|
|
2520
|
+
const a = +(((C = (o.getAttribute("style") || "").match(/level(\d+)/i)) == null ? void 0 : C[1]) || 1), d = Array.from(o.querySelectorAll("span")).find(
|
|
2521
2521
|
(A) => /mso-list\s*:\s*ignore/i.test(A.getAttribute("style") || "")
|
|
2522
|
-
), p = d ? ((E = d.textContent) == null ? void 0 : E.trim()) || "" : (((I =
|
|
2522
|
+
), p = d ? ((E = d.textContent) == null ? void 0 : E.trim()) || "" : (((I = o.textContent) == null ? void 0 : I.trim().match(/^\S{1,4}/)) || [""])[0], { ordered: m, style: v } = mi(p);
|
|
2523
2523
|
for (d && d.remove(); n.length && n[n.length - 1].level > a; ) n.pop();
|
|
2524
2524
|
if (!n.length || n[n.length - 1].level < a) {
|
|
2525
2525
|
const A = u.createElement(m ? "ol" : "ul");
|
|
@@ -2527,22 +2527,22 @@ function mi(u) {
|
|
|
2527
2527
|
const $ = n[n.length - 1].list;
|
|
2528
2528
|
($.lastElementChild || $).appendChild(A);
|
|
2529
2529
|
} else
|
|
2530
|
-
|
|
2530
|
+
r.parentNode.insertBefore(A, r);
|
|
2531
2531
|
n.push({ list: A, level: a });
|
|
2532
2532
|
}
|
|
2533
|
-
const b = u.createElement("li"), f = pt(
|
|
2534
|
-
for (y && b.setAttribute("style", y),
|
|
2535
|
-
n[n.length - 1].list.appendChild(b),
|
|
2533
|
+
const b = u.createElement("li"), f = pt(o), y = ["text-align", "direction", "unicode-bidi", "color", "font-size", "font-family", "background-color"].filter((A) => f[A]).map((A) => A + ":" + f[A]).join(";");
|
|
2534
|
+
for (y && b.setAttribute("style", y), o.getAttribute("dir") && b.setAttribute("dir", o.getAttribute("dir")); o.firstChild; ) b.appendChild(o.firstChild);
|
|
2535
|
+
n[n.length - 1].list.appendChild(b), o.remove();
|
|
2536
2536
|
});
|
|
2537
2537
|
});
|
|
2538
2538
|
}
|
|
2539
|
-
function
|
|
2539
|
+
function gi(u) {
|
|
2540
2540
|
u.querySelectorAll('b[id^="docs-internal-guid"]').forEach((t) => {
|
|
2541
2541
|
for (; t.firstChild; ) t.parentNode.insertBefore(t.firstChild, t);
|
|
2542
2542
|
t.remove();
|
|
2543
2543
|
});
|
|
2544
2544
|
}
|
|
2545
|
-
function
|
|
2545
|
+
function vi(u) {
|
|
2546
2546
|
u.querySelectorAll("table").forEach((t) => {
|
|
2547
2547
|
const e = t;
|
|
2548
2548
|
pt(e)["border-collapse"] || (e.style.borderCollapse = "collapse");
|
|
@@ -2569,12 +2569,12 @@ function dt(u, t) {
|
|
|
2569
2569
|
}
|
|
2570
2570
|
if (e.nodeType !== Node.ELEMENT_NODE) return;
|
|
2571
2571
|
const i = e, s = i.tagName.toLowerCase();
|
|
2572
|
-
if (!
|
|
2572
|
+
if (!di.has(s)) {
|
|
2573
2573
|
if (s === "font") {
|
|
2574
|
-
const
|
|
2575
|
-
i.getAttribute("style") &&
|
|
2574
|
+
const l = t.createElement("span");
|
|
2575
|
+
i.getAttribute("style") && l.setAttribute("style", i.getAttribute("style")), i.getAttribute("color") && (l.style.color = i.getAttribute("color")), i.getAttribute("face") && (l.style.fontFamily = i.getAttribute("face"));
|
|
2576
2576
|
const a = i.getAttribute("size");
|
|
2577
|
-
if (a && !
|
|
2577
|
+
if (a && !l.style.fontSize) {
|
|
2578
2578
|
const d = {
|
|
2579
2579
|
1: "8pt",
|
|
2580
2580
|
2: "10pt",
|
|
@@ -2584,10 +2584,10 @@ function dt(u, t) {
|
|
|
2584
2584
|
6: "24pt",
|
|
2585
2585
|
7: "36pt"
|
|
2586
2586
|
};
|
|
2587
|
-
d[a] && (
|
|
2587
|
+
d[a] && (l.style.fontSize = d[a]);
|
|
2588
2588
|
}
|
|
2589
|
-
for (; i.firstChild; )
|
|
2590
|
-
i.replaceWith(
|
|
2589
|
+
for (; i.firstChild; ) l.appendChild(i.firstChild);
|
|
2590
|
+
i.replaceWith(l), dt(l, t);
|
|
2591
2591
|
return;
|
|
2592
2592
|
}
|
|
2593
2593
|
for (dt(i, t); i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
|
|
@@ -2595,49 +2595,49 @@ function dt(u, t) {
|
|
|
2595
2595
|
return;
|
|
2596
2596
|
}
|
|
2597
2597
|
const n = /* @__PURE__ */ new Set([...le["*"] || [], ...le[s] || []]);
|
|
2598
|
-
if (Array.from(i.attributes).forEach((
|
|
2599
|
-
const a =
|
|
2600
|
-
a !== "style" && !n.has(a) && i.removeAttribute(
|
|
2598
|
+
if (Array.from(i.attributes).forEach((l) => {
|
|
2599
|
+
const a = l.name.toLowerCase();
|
|
2600
|
+
a !== "style" && !n.has(a) && i.removeAttribute(l.name);
|
|
2601
2601
|
}), s === "a") {
|
|
2602
|
-
const
|
|
2603
|
-
/^(https?:|mailto:|tel:|#)/i.test(
|
|
2602
|
+
const l = i.getAttribute("href") || "";
|
|
2603
|
+
/^(https?:|mailto:|tel:|#)/i.test(l) || i.removeAttribute("href");
|
|
2604
2604
|
}
|
|
2605
2605
|
if (s === "img") {
|
|
2606
|
-
const
|
|
2607
|
-
if (!/^(https?:|data:image\/|blob:)/i.test(
|
|
2606
|
+
const l = i.getAttribute("src") || "";
|
|
2607
|
+
if (!/^(https?:|data:image\/|blob:)/i.test(l)) {
|
|
2608
2608
|
const a = t.createElement("span");
|
|
2609
2609
|
a.textContent = "[local image — paste it separately]", a.setAttribute("style", "color:#a33;font-style:italic;font-size:12px"), i.replaceWith(a);
|
|
2610
2610
|
return;
|
|
2611
2611
|
}
|
|
2612
2612
|
}
|
|
2613
|
-
const
|
|
2614
|
-
for (const [
|
|
2615
|
-
|
|
2616
|
-
if (
|
|
2613
|
+
const r = pt(i), o = [];
|
|
2614
|
+
for (const [l, a] of Object.entries(r))
|
|
2615
|
+
ui.has(l) && (/expression|javascript|url\s*\(\s*['"]?\s*file:/i.test(a) || l === "font-weight" && /^(400|normal)$/i.test(a) || l === "font-style" && /^normal$/i.test(a) || l === "text-decoration" && /^none$/i.test(a) || o.push(l + ":" + a));
|
|
2616
|
+
if (o.length ? i.setAttribute("style", o.join(";")) : i.removeAttribute("style"), i.removeAttribute("class"), dt(i, t), s === "span" && !i.attributes.length) {
|
|
2617
2617
|
for (; i.firstChild; ) i.parentNode.insertBefore(i.firstChild, i);
|
|
2618
2618
|
i.remove();
|
|
2619
2619
|
}
|
|
2620
2620
|
});
|
|
2621
2621
|
}
|
|
2622
|
-
function
|
|
2622
|
+
function bi(u) {
|
|
2623
2623
|
const t = [], e = /<style[^>]*>([\s\S]*?)<\/style>/gi;
|
|
2624
2624
|
let i;
|
|
2625
2625
|
for (; i = e.exec(u); ) {
|
|
2626
2626
|
let s = i[1].replace(/<!--|-->/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
2627
2627
|
s = s.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/gi, ""), s = s.replace(/@[\w-]+[^{]*\{[^{}]*\}/g, "");
|
|
2628
2628
|
let n;
|
|
2629
|
-
const
|
|
2630
|
-
for (; n =
|
|
2631
|
-
const
|
|
2632
|
-
const a =
|
|
2633
|
-
return a < 1 ? null : [
|
|
2634
|
-
}).filter((
|
|
2635
|
-
|
|
2629
|
+
const r = /([^{}]+)\{([^}]*)\}/g;
|
|
2630
|
+
for (; n = r.exec(s); ) {
|
|
2631
|
+
const o = n[2].split(";").map((l) => {
|
|
2632
|
+
const a = l.indexOf(":");
|
|
2633
|
+
return a < 1 ? null : [l.slice(0, a).trim().toLowerCase(), l.slice(a + 1).trim()];
|
|
2634
|
+
}).filter((l) => !!l && !!l[1]);
|
|
2635
|
+
o.length && n[1].split(",").map((l) => l.trim()).filter((l) => l && !l.startsWith("@")).forEach((l) => t.push({ sel: l, decls: o }));
|
|
2636
2636
|
}
|
|
2637
2637
|
}
|
|
2638
2638
|
return t;
|
|
2639
2639
|
}
|
|
2640
|
-
function
|
|
2640
|
+
function yi(u, t) {
|
|
2641
2641
|
if (!t.length) return;
|
|
2642
2642
|
const e = /* @__PURE__ */ new Map();
|
|
2643
2643
|
t.forEach(({ sel: i, decls: s }) => {
|
|
@@ -2647,44 +2647,44 @@ function bi(u, t) {
|
|
|
2647
2647
|
} catch {
|
|
2648
2648
|
return;
|
|
2649
2649
|
}
|
|
2650
|
-
n.forEach((
|
|
2651
|
-
let
|
|
2652
|
-
|
|
2653
|
-
|
|
2650
|
+
n.forEach((r) => {
|
|
2651
|
+
let o = e.get(r);
|
|
2652
|
+
o || (o = {}, e.set(r, o)), s.forEach(([l, a]) => {
|
|
2653
|
+
o[l] = a;
|
|
2654
2654
|
});
|
|
2655
2655
|
});
|
|
2656
2656
|
}), e.forEach((i, s) => {
|
|
2657
|
-
const n = pt(s),
|
|
2658
|
-
if (!
|
|
2659
|
-
const a =
|
|
2657
|
+
const n = pt(s), r = s.hasAttribute("dir"), o = s.hasAttribute("align"), l = Object.entries(i).filter(([p]) => !(p in n || (p === "direction" || p === "unicode-bidi") && r || p === "text-align" && (o || r) || (p === "background" || p === "background-color") && s.hasAttribute("bgcolor")));
|
|
2658
|
+
if (!l.length) return;
|
|
2659
|
+
const a = l.map(([p, m]) => p + ":" + m).join(";"), d = s.getAttribute("style");
|
|
2660
2660
|
s.setAttribute("style", d ? a + ";" + d : a);
|
|
2661
2661
|
});
|
|
2662
2662
|
}
|
|
2663
|
-
function
|
|
2663
|
+
function fe(u) {
|
|
2664
2664
|
return u.replace(/[ﭐ-﷿ﹰ-ﻼ]+/g, (t) => t.normalize("NFKC"));
|
|
2665
2665
|
}
|
|
2666
|
-
function
|
|
2666
|
+
function xi(u) {
|
|
2667
2667
|
const t = u.createTreeWalker(u.body, NodeFilter.SHOW_TEXT, null);
|
|
2668
2668
|
let e;
|
|
2669
2669
|
for (; e = t.nextNode(); )
|
|
2670
|
-
/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue =
|
|
2670
|
+
/[ﭐ-﷿ﹰ-ﻼ]/.test(e.nodeValue || "") && (e.nodeValue = fe(e.nodeValue || ""));
|
|
2671
2671
|
}
|
|
2672
|
-
function
|
|
2673
|
-
const e =
|
|
2674
|
-
|
|
2672
|
+
function Ci(u, t = "ltr") {
|
|
2673
|
+
const e = bi(u), i = new DOMParser().parseFromString(pi(u), "text/html");
|
|
2674
|
+
yi(i, e), /class="?Mso|mso-|urn:schemas-microsoft-com/i.test(i.body.innerHTML) && fi(i), gi(i), vi(i), dt(i.body, i), xi(i);
|
|
2675
2675
|
const s = (n) => {
|
|
2676
|
-
var
|
|
2677
|
-
return n && n.tagName === "P" && !((
|
|
2676
|
+
var r;
|
|
2677
|
+
return n && n.tagName === "P" && !((r = n.textContent) != null && r.trim()) && !n.querySelector("img,table");
|
|
2678
2678
|
};
|
|
2679
2679
|
for (; s(i.body.firstElementChild); ) i.body.firstElementChild.remove();
|
|
2680
2680
|
for (; s(i.body.lastElementChild); ) i.body.lastElementChild.remove();
|
|
2681
2681
|
return i.body.innerHTML.trim();
|
|
2682
2682
|
}
|
|
2683
|
-
function
|
|
2684
|
-
const t =
|
|
2683
|
+
function wi(u) {
|
|
2684
|
+
const t = fe(u).replace(/\r/g, ""), e = (i) => i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2685
2685
|
return /\n/.test(t) ? t.split(/\n{2,}/).map((i) => `<p dir="auto">${e(i).replace(/\n/g, "<br>") || "<br>"}</p>`).join("") : e(t);
|
|
2686
2686
|
}
|
|
2687
|
-
const
|
|
2687
|
+
const Ti = 10 * 1024 * 1024, ge = /^(https?:|data:image\/|blob:)/i;
|
|
2688
2688
|
function oe(u, t) {
|
|
2689
2689
|
const e = [], i = "{\\" + t;
|
|
2690
2690
|
let s = 0;
|
|
@@ -2694,22 +2694,22 @@ function oe(u, t) {
|
|
|
2694
2694
|
s += i.length;
|
|
2695
2695
|
continue;
|
|
2696
2696
|
}
|
|
2697
|
-
let
|
|
2698
|
-
for (;
|
|
2699
|
-
const
|
|
2700
|
-
if (
|
|
2701
|
-
|
|
2697
|
+
let r = 0, o = s;
|
|
2698
|
+
for (; o < u.length; o++) {
|
|
2699
|
+
const l = u[o];
|
|
2700
|
+
if (l === "\\") {
|
|
2701
|
+
o++;
|
|
2702
2702
|
continue;
|
|
2703
2703
|
}
|
|
2704
|
-
if (
|
|
2705
|
-
else if (
|
|
2704
|
+
if (l === "{") r++;
|
|
2705
|
+
else if (l === "}" && (r--, !r))
|
|
2706
2706
|
break;
|
|
2707
2707
|
}
|
|
2708
|
-
e.push({ start: s, end:
|
|
2708
|
+
e.push({ start: s, end: o + 1, body: u.slice(s + i.length, o) }), s = o + 1;
|
|
2709
2709
|
}
|
|
2710
2710
|
return e;
|
|
2711
2711
|
}
|
|
2712
|
-
function
|
|
2712
|
+
function Ei(u) {
|
|
2713
2713
|
const t = new Uint8Array(u.length / 2);
|
|
2714
2714
|
for (let e = 0; e < t.length; e++) t[e] = parseInt(u.substr(e * 2, 2), 16);
|
|
2715
2715
|
return t;
|
|
@@ -2726,95 +2726,126 @@ function ae(u, t) {
|
|
|
2726
2726
|
}
|
|
2727
2727
|
return -1;
|
|
2728
2728
|
}
|
|
2729
|
-
const
|
|
2730
|
-
function
|
|
2729
|
+
const Si = [137, 80, 78, 71], Mi = [255, 216, 255];
|
|
2730
|
+
function Li(u) {
|
|
2731
2731
|
let t = null;
|
|
2732
2732
|
if (/\\pngblip/.test(u) ? t = "image/png" : /\\jpegblip/.test(u) ? t = "image/jpeg" : (/\\wmetafile\d*/.test(u) || /\\emfblip/.test(u)) && (t = "metafile"), !t) return null;
|
|
2733
|
-
let e = u.replace(/\{[^{}]*\}/g, "").replace(/\\[a-z]+-?\d*\s?/gi, "").replace(/[^0-9a-fA-F]/g, "");
|
|
2733
|
+
let e = u.replace(/\{[^{}]*\}/g, " ").replace(/\\[a-z]+-?\d*\s?/gi, " ").replace(/[^0-9a-fA-F]/g, "");
|
|
2734
2734
|
if (e.length % 2 && (e = e.slice(0, -1)), !e) return null;
|
|
2735
|
-
const i =
|
|
2735
|
+
const i = Ei(e);
|
|
2736
2736
|
if (t === "metafile") {
|
|
2737
|
-
const s = ae(i,
|
|
2737
|
+
const s = ae(i, Si);
|
|
2738
2738
|
if (s >= 0) return "data:image/png;base64," + Tt(i.slice(s));
|
|
2739
|
-
const n = ae(i,
|
|
2739
|
+
const n = ae(i, Mi);
|
|
2740
2740
|
return n >= 0 ? "data:image/jpeg;base64," + Tt(i.slice(n)) : null;
|
|
2741
2741
|
}
|
|
2742
2742
|
return "data:" + t + ";base64," + Tt(i);
|
|
2743
2743
|
}
|
|
2744
|
-
function
|
|
2744
|
+
function ki(u) {
|
|
2745
2745
|
if (!u || u.indexOf("\\pict") === -1) return [];
|
|
2746
2746
|
let t = u;
|
|
2747
2747
|
oe(u, "nonshppict").reverse().forEach((i) => {
|
|
2748
2748
|
t = t.slice(0, i.start) + t.slice(i.end);
|
|
2749
2749
|
});
|
|
2750
|
-
let e =
|
|
2750
|
+
let e = Ti;
|
|
2751
2751
|
return oe(t, "pict").map((i) => {
|
|
2752
2752
|
if (e <= 0) return null;
|
|
2753
|
-
const s =
|
|
2753
|
+
const s = Li(i.body);
|
|
2754
2754
|
return s && (e -= s.length * 0.75), s;
|
|
2755
2755
|
});
|
|
2756
2756
|
}
|
|
2757
|
-
function
|
|
2757
|
+
function ce(u) {
|
|
2758
|
+
const t = u.match(/^\s*(-?[\d.]+)\s*(pt|px|in|cm|mm)?\s*$/i);
|
|
2759
|
+
if (!t) return null;
|
|
2760
|
+
const e = parseFloat(t[1]);
|
|
2761
|
+
if (!isFinite(e) || e <= 0) return null;
|
|
2762
|
+
const i = (t[2] || "px").toLowerCase(), s = i === "pt" ? e * 4 / 3 : i === "in" ? e * 96 : i === "cm" ? e * 96 / 2.54 : i === "mm" ? e * 96 / 25.4 : e;
|
|
2763
|
+
return Math.round(s);
|
|
2764
|
+
}
|
|
2765
|
+
function Ai(u, t) {
|
|
2766
|
+
const e = u.match(new RegExp("\\s" + t + `\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"));
|
|
2767
|
+
return e ? e[1] ?? e[2] ?? e[3] ?? "" : "";
|
|
2768
|
+
}
|
|
2769
|
+
function Hi(u) {
|
|
2770
|
+
if (!/<v:imagedata\b/i.test(u)) return u;
|
|
2771
|
+
const t = (i, s) => {
|
|
2772
|
+
const n = Ai(i, "src");
|
|
2773
|
+
if (!n) return null;
|
|
2774
|
+
const r = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2775
|
+
if (new RegExp(`<img\\b[^>]*\\bsrc\\s*=\\s*["']?` + r, "i").test(u)) return null;
|
|
2776
|
+
const o = (s.match(/<v:shape\b[^>]*\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)')/i) || []).slice(1).find(Boolean) || "", l = ce((o.match(/(?:^|;)\s*width\s*:\s*([^;]+)/i) || [])[1] || ""), a = ce((o.match(/(?:^|;)\s*height\s*:\s*([^;]+)/i) || [])[1] || "");
|
|
2777
|
+
return '<img src="' + n.replace(/"/g, """) + '"' + (l ? ' width="' + l + '"' : "") + (a ? ' height="' + a + '"' : "") + ">";
|
|
2778
|
+
};
|
|
2779
|
+
let e = u.replace(/<!--\[if [^\]]*\]>([\s\S]*?)<!\[endif\]-->/gi, (i, s) => {
|
|
2780
|
+
const n = s.match(/<v:imagedata\b[^>]*>/i);
|
|
2781
|
+
return n && t(n[0], s) || i;
|
|
2782
|
+
});
|
|
2783
|
+
return e = e.replace(/<v:shape\b[^>]*>[\s\S]*?<\/v:shape\s*>/gi, (i) => {
|
|
2784
|
+
const s = i.match(/<v:imagedata\b[^>]*>/i);
|
|
2785
|
+
return s && t(s[0], i) || i;
|
|
2786
|
+
}), e.replace(/<v:imagedata\b[^>]*>/gi, (i) => t(i, "") || i);
|
|
2787
|
+
}
|
|
2788
|
+
function ve(u, t) {
|
|
2758
2789
|
if (!u || !t.length) return { html: u, injected: [] };
|
|
2759
2790
|
const e = [];
|
|
2760
2791
|
let i = 0;
|
|
2761
|
-
return { html: u.replace(/<img\b[^>]*>/gi, (n) => {
|
|
2762
|
-
const
|
|
2763
|
-
if (
|
|
2764
|
-
const
|
|
2765
|
-
return
|
|
2792
|
+
return { html: Hi(u).replace(/<img\b[^>]*>/gi, (n) => {
|
|
2793
|
+
const r = (n.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
|
|
2794
|
+
if (ge.test(r)) return n;
|
|
2795
|
+
const o = t[i++];
|
|
2796
|
+
return o ? (e.push(o), /\ssrc\s*=\s*["']/i.test(n) ? n.replace(/(\ssrc\s*=\s*)(["'])[^"']*\2/i, '$1"' + o + '"') : n.replace(/(\ssrc\s*=\s*)[^\s>]+/i, '$1"' + o + '"')) : n;
|
|
2766
2797
|
}), injected: e };
|
|
2767
2798
|
}
|
|
2768
|
-
function
|
|
2769
|
-
return !u || !t ? { html: u, injected: [] } :
|
|
2799
|
+
function Ii(u, t) {
|
|
2800
|
+
return !u || !t ? { html: u, injected: [] } : ve(u, ki(t));
|
|
2770
2801
|
}
|
|
2771
|
-
function
|
|
2802
|
+
function qi(u) {
|
|
2772
2803
|
const t = u.match(/<img\b[^>]*>/gi);
|
|
2773
2804
|
return t ? t.filter((e) => {
|
|
2774
2805
|
const i = (e.match(/\ssrc\s*=\s*["']?([^"'\s>]+)/i) || [])[1] || "";
|
|
2775
|
-
return !
|
|
2806
|
+
return !ge.test(i);
|
|
2776
2807
|
}).length : 0;
|
|
2777
2808
|
}
|
|
2778
|
-
function
|
|
2809
|
+
function Ri(u, t) {
|
|
2779
2810
|
const e = u.match(/^data:([^;,]+);base64,(.*)$/);
|
|
2780
2811
|
if (!e) return null;
|
|
2781
2812
|
const i = (e[1].split("/")[1] || "png").replace(/[^a-z0-9]/gi, "") || "png";
|
|
2782
2813
|
try {
|
|
2783
2814
|
const s = atob(e[2]), n = new Uint8Array(s.length);
|
|
2784
|
-
for (let
|
|
2815
|
+
for (let r = 0; r < s.length; r++) n[r] = s.charCodeAt(r);
|
|
2785
2816
|
return new File([n], t + "." + (i === "jpeg" ? "jpg" : i), { type: e[1] });
|
|
2786
2817
|
} catch {
|
|
2787
2818
|
return null;
|
|
2788
2819
|
}
|
|
2789
2820
|
}
|
|
2790
|
-
function
|
|
2821
|
+
function Pi(u) {
|
|
2791
2822
|
const t = new DataView(u), e = /* @__PURE__ */ new Map();
|
|
2792
2823
|
let i = -1;
|
|
2793
|
-
for (let
|
|
2794
|
-
if (t.getUint32(
|
|
2795
|
-
i =
|
|
2824
|
+
for (let o = u.byteLength - 22; o >= Math.max(0, u.byteLength - 22 - 65535); o--)
|
|
2825
|
+
if (t.getUint32(o, !0) === 101010256) {
|
|
2826
|
+
i = o;
|
|
2796
2827
|
break;
|
|
2797
2828
|
}
|
|
2798
2829
|
if (i < 0) throw new Error("EOCD not found");
|
|
2799
2830
|
const s = t.getUint16(i + 10, !0);
|
|
2800
2831
|
let n = t.getUint32(i + 16, !0);
|
|
2801
|
-
const
|
|
2802
|
-
for (let
|
|
2803
|
-
const
|
|
2804
|
-
e.set(b, { name: b, method:
|
|
2832
|
+
const r = new TextDecoder();
|
|
2833
|
+
for (let o = 0; o < s && t.getUint32(n, !0) === 33639248; o++) {
|
|
2834
|
+
const l = t.getUint16(n + 10, !0), a = t.getUint32(n + 20, !0), d = t.getUint16(n + 28, !0), p = t.getUint16(n + 30, !0), m = t.getUint16(n + 32, !0), v = t.getUint32(n + 42, !0), b = r.decode(new Uint8Array(u, n + 46, d));
|
|
2835
|
+
e.set(b, { name: b, method: l, compSize: a, localOffset: v }), n += 46 + d + p + m;
|
|
2805
2836
|
}
|
|
2806
2837
|
return e;
|
|
2807
2838
|
}
|
|
2808
|
-
async function
|
|
2839
|
+
async function he(u, t) {
|
|
2809
2840
|
const e = new DataView(u, t.localOffset);
|
|
2810
2841
|
if (e.getUint32(0, !0) !== 67324752) throw new Error("Bad local header");
|
|
2811
|
-
const i = e.getUint16(26, !0), s = e.getUint16(28, !0), n = t.localOffset + 30 + i + s,
|
|
2812
|
-
if (t.method === 0) return
|
|
2842
|
+
const i = e.getUint16(26, !0), s = e.getUint16(28, !0), n = t.localOffset + 30 + i + s, r = new Uint8Array(u.slice(n, n + t.compSize));
|
|
2843
|
+
if (t.method === 0) return r;
|
|
2813
2844
|
if (t.method !== 8) throw new Error("Unsupported compression method " + t.method);
|
|
2814
|
-
const
|
|
2815
|
-
return new Uint8Array(await new Response(
|
|
2845
|
+
const o = new Blob([r]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
|
|
2846
|
+
return new Uint8Array(await new Response(o).arrayBuffer());
|
|
2816
2847
|
}
|
|
2817
|
-
const
|
|
2848
|
+
const de = (u) => u.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), ut = (u, t) => Array.from(u.children).filter((e) => e.localName === t), B = (u, ...t) => {
|
|
2818
2849
|
let e = u;
|
|
2819
2850
|
for (const i of t) {
|
|
2820
2851
|
if (!e) return null;
|
|
@@ -2831,7 +2862,7 @@ const he = (u) => u.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, "
|
|
|
2831
2862
|
if (!e) return !1;
|
|
2832
2863
|
const i = q(e);
|
|
2833
2864
|
return i !== "false" && i !== "0";
|
|
2834
|
-
},
|
|
2865
|
+
}, ue = {
|
|
2835
2866
|
yellow: "#FFFF00",
|
|
2836
2867
|
green: "#00FF00",
|
|
2837
2868
|
cyan: "#00FFFF",
|
|
@@ -2848,7 +2879,7 @@ const he = (u) => u.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, "
|
|
|
2848
2879
|
lightGray: "#D3D3D3",
|
|
2849
2880
|
black: "#000000",
|
|
2850
2881
|
white: "#FFFFFF"
|
|
2851
|
-
},
|
|
2882
|
+
}, Bi = {
|
|
2852
2883
|
png: "image/png",
|
|
2853
2884
|
jpg: "image/jpeg",
|
|
2854
2885
|
jpeg: "image/jpeg",
|
|
@@ -2856,13 +2887,13 @@ const he = (u) => u.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, "
|
|
|
2856
2887
|
bmp: "image/bmp",
|
|
2857
2888
|
webp: "image/webp"
|
|
2858
2889
|
};
|
|
2859
|
-
function
|
|
2890
|
+
function Di(u) {
|
|
2860
2891
|
let t = "";
|
|
2861
2892
|
for (let e = 0; e < u.length; e += 32768)
|
|
2862
2893
|
t += String.fromCharCode(...u.subarray(e, e + 32768));
|
|
2863
2894
|
return btoa(t);
|
|
2864
2895
|
}
|
|
2865
|
-
class
|
|
2896
|
+
class Ni {
|
|
2866
2897
|
constructor(t, e, i) {
|
|
2867
2898
|
this.rels = t, this.images = e, this.numFmt = i;
|
|
2868
2899
|
}
|
|
@@ -2873,12 +2904,12 @@ class Pi {
|
|
|
2873
2904
|
};
|
|
2874
2905
|
for (const n of Array.from(t.children))
|
|
2875
2906
|
if (n.localName === "p") {
|
|
2876
|
-
const
|
|
2877
|
-
if (
|
|
2878
|
-
const
|
|
2879
|
-
for (; i.length >
|
|
2880
|
-
for (i.length ===
|
|
2881
|
-
e += `<${
|
|
2907
|
+
const r = this.paraList(n);
|
|
2908
|
+
if (r) {
|
|
2909
|
+
const o = r.ilvl + 1;
|
|
2910
|
+
for (; i.length > o; ) e += `</${i.pop()}>`;
|
|
2911
|
+
for (i.length === o && i[o - 1] !== r.type && (e += `</${i.pop()}>`); i.length < o; )
|
|
2912
|
+
e += `<${r.type}>`, i.push(r.type);
|
|
2882
2913
|
e += `<li>${this.runsOf(n) || "<br>"}</li>`;
|
|
2883
2914
|
continue;
|
|
2884
2915
|
}
|
|
@@ -2899,10 +2930,10 @@ class Pi {
|
|
|
2899
2930
|
let s = "p";
|
|
2900
2931
|
const n = /^Heading([1-6])$/i.exec(i);
|
|
2901
2932
|
n ? s = "h" + n[1] : /^Title$/i.test(i) && (s = "h1");
|
|
2902
|
-
const
|
|
2903
|
-
|
|
2904
|
-
const
|
|
2905
|
-
return `<${s}${a}>${
|
|
2933
|
+
const r = [], o = q(B(t, "pPr", "jc"));
|
|
2934
|
+
o === "center" ? r.push("text-align:center") : o === "right" || o === "end" ? r.push("text-align:right") : (o === "both" || o === "distribute") && r.push("text-align:justify"), e && B(e, "bidi") && r.push("direction:rtl");
|
|
2935
|
+
const l = this.runsOf(t), a = r.length ? ` style="${r.join(";")}"` : "";
|
|
2936
|
+
return `<${s}${a}>${l || "<br>"}</${s}>`;
|
|
2906
2937
|
}
|
|
2907
2938
|
runsOf(t) {
|
|
2908
2939
|
let e = "";
|
|
@@ -2912,8 +2943,8 @@ class Pi {
|
|
|
2912
2943
|
let s = this.rels.get(q(i, "id")) || "";
|
|
2913
2944
|
const n = q(i, "anchor");
|
|
2914
2945
|
!s && n && (s = "#" + n);
|
|
2915
|
-
const
|
|
2916
|
-
e += s ? `<a href="${
|
|
2946
|
+
const r = this.runsOf(i);
|
|
2947
|
+
e += s ? `<a href="${de(s)}">${r}</a>` : r;
|
|
2917
2948
|
} else (i.localName === "smartTag" || i.localName === "ins") && (e += this.runsOf(i));
|
|
2918
2949
|
return e;
|
|
2919
2950
|
}
|
|
@@ -2921,79 +2952,79 @@ class Pi {
|
|
|
2921
2952
|
const e = B(t, "rPr");
|
|
2922
2953
|
let i = "";
|
|
2923
2954
|
for (const p of Array.from(t.children))
|
|
2924
|
-
p.localName === "t" ? i +=
|
|
2955
|
+
p.localName === "t" ? i += de(p.textContent || "") : p.localName === "br" || p.localName === "cr" ? i += "<br>" : p.localName === "tab" ? i += " " : (p.localName === "drawing" || p.localName === "pict" || p.localName === "object") && (i += this.convertImage(p));
|
|
2925
2956
|
if (!i) return "";
|
|
2926
2957
|
const s = [], n = q(e ? B(e, "color") : null);
|
|
2927
2958
|
n && n !== "auto" && s.push("color:#" + n);
|
|
2928
|
-
const
|
|
2929
|
-
|
|
2930
|
-
const
|
|
2931
|
-
|
|
2932
|
-
const
|
|
2959
|
+
const r = q(e ? B(e, "highlight") : null);
|
|
2960
|
+
r && ue[r] && s.push("background-color:" + ue[r]);
|
|
2961
|
+
const o = parseFloat(q(e ? B(e, "sz") : null));
|
|
2962
|
+
o && s.push("font-size:" + Math.round(o / 2 * (4 / 3)) + "px");
|
|
2963
|
+
const l = e ? B(e, "rFonts") : null, a = q(l, "ascii") || q(l, "cs");
|
|
2933
2964
|
a && s.push(`font-family:'${a}'`), s.length && (i = `<span style="${s.join(";")}">${i}</span>`), at(e, "b") && (i = `<strong>${i}</strong>`), at(e, "i") && (i = `<em>${i}</em>`), at(e, "u") && q(B(e, "u")) !== "none" && (i = `<u>${i}</u>`), at(e, "strike") && (i = `<s>${i}</s>`);
|
|
2934
2965
|
const d = q(e ? B(e, "vertAlign") : null);
|
|
2935
2966
|
return d === "superscript" ? i = `<sup>${i}</sup>` : d === "subscript" && (i = `<sub>${i}</sub>`), i;
|
|
2936
2967
|
}
|
|
2937
2968
|
convertImage(t) {
|
|
2938
2969
|
let e = "", i = 0;
|
|
2939
|
-
const s = (
|
|
2940
|
-
if (
|
|
2941
|
-
const
|
|
2942
|
-
|
|
2970
|
+
const s = (o) => {
|
|
2971
|
+
if (o.localName === "blip" && (e = e || q(o, "embed") || q(o, "link")), o.localName === "imagedata" && (e = e || q(o, "id")), o.localName === "extent") {
|
|
2972
|
+
const l = parseFloat(o.getAttribute("cx") || "0");
|
|
2973
|
+
l && (i = Math.round(l / 9525));
|
|
2943
2974
|
}
|
|
2944
|
-
for (const
|
|
2975
|
+
for (const l of Array.from(o.children)) s(l);
|
|
2945
2976
|
};
|
|
2946
2977
|
if (s(t), !e) return "";
|
|
2947
2978
|
const n = this.images.get(e);
|
|
2948
2979
|
if (!n) return "";
|
|
2949
|
-
const
|
|
2950
|
-
return `<img src="${n}" alt=""${
|
|
2980
|
+
const r = i ? ` width="${i}"` : "";
|
|
2981
|
+
return `<img src="${n}" alt=""${r}>`;
|
|
2951
2982
|
}
|
|
2952
2983
|
convertTable(t) {
|
|
2953
2984
|
let e = '<table style="border-collapse:collapse;width:100%"><tbody>';
|
|
2954
2985
|
for (const i of ut(t, "tr")) {
|
|
2955
2986
|
e += "<tr>";
|
|
2956
2987
|
for (const s of ut(i, "tc")) {
|
|
2957
|
-
const n = parseInt(q(B(s, "tcPr", "gridSpan")) || "1", 10) || 1,
|
|
2958
|
-
let
|
|
2959
|
-
for (const
|
|
2960
|
-
|
|
2961
|
-
e += `<td style="border:1px solid #b9c2cc"${
|
|
2988
|
+
const n = parseInt(q(B(s, "tcPr", "gridSpan")) || "1", 10) || 1, r = n > 1 ? ` colspan="${n}"` : "";
|
|
2989
|
+
let o = "";
|
|
2990
|
+
for (const l of Array.from(s.children))
|
|
2991
|
+
l.localName === "p" ? o += this.convertPara(l) : l.localName === "tbl" && (o += this.convertTable(l));
|
|
2992
|
+
e += `<td style="border:1px solid #b9c2cc"${r}>${o || "<br>"}</td>`;
|
|
2962
2993
|
}
|
|
2963
2994
|
e += "</tr>";
|
|
2964
2995
|
}
|
|
2965
2996
|
return e + "</tbody></table>";
|
|
2966
2997
|
}
|
|
2967
2998
|
}
|
|
2968
|
-
async function
|
|
2969
|
-
const t = u instanceof ArrayBuffer ? u : await u.arrayBuffer(), e =
|
|
2999
|
+
async function Oi(u) {
|
|
3000
|
+
const t = u instanceof ArrayBuffer ? u : await u.arrayBuffer(), e = Pi(t), i = new TextDecoder(), s = async (b) => {
|
|
2970
3001
|
const f = e.get(b);
|
|
2971
|
-
return f ? new DOMParser().parseFromString(i.decode(await
|
|
2972
|
-
}, n = await s("word/document.xml"),
|
|
2973
|
-
let
|
|
2974
|
-
if (
|
|
2975
|
-
for (const b of Array.from(
|
|
3002
|
+
return f ? new DOMParser().parseFromString(i.decode(await he(t, f)), "application/xml") : null;
|
|
3003
|
+
}, n = await s("word/document.xml"), r = n == null ? void 0 : n.getElementsByTagName("*");
|
|
3004
|
+
let o = null;
|
|
3005
|
+
if (r) {
|
|
3006
|
+
for (const b of Array.from(r))
|
|
2976
3007
|
if (b.localName === "body") {
|
|
2977
|
-
|
|
3008
|
+
o = b;
|
|
2978
3009
|
break;
|
|
2979
3010
|
}
|
|
2980
3011
|
}
|
|
2981
|
-
if (!
|
|
2982
|
-
const
|
|
3012
|
+
if (!o) throw new Error("word/document.xml missing or invalid");
|
|
3013
|
+
const l = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), d = await s("word/_rels/document.xml.rels");
|
|
2983
3014
|
if (d)
|
|
2984
3015
|
for (const b of Array.from(d.getElementsByTagName("*"))) {
|
|
2985
3016
|
if (b.localName !== "Relationship") continue;
|
|
2986
3017
|
const f = b.getAttribute("Id") || "", y = b.getAttribute("Target") || "", C = b.getAttribute("Type") || "";
|
|
2987
|
-
/hyperlink/i.test(C) ?
|
|
3018
|
+
/hyperlink/i.test(C) ? l.set(f, y) : /image/i.test(C) && a.set(f, y);
|
|
2988
3019
|
}
|
|
2989
3020
|
const p = /* @__PURE__ */ new Map();
|
|
2990
3021
|
for (const [b, f] of a) {
|
|
2991
3022
|
const y = f.startsWith("/") ? f.slice(1) : "word/" + f.replace(/^\.\//, ""), C = e.get(y);
|
|
2992
3023
|
if (!C) continue;
|
|
2993
|
-
const E = (y.split(".").pop() || "").toLowerCase(), I =
|
|
3024
|
+
const E = (y.split(".").pop() || "").toLowerCase(), I = Bi[E];
|
|
2994
3025
|
if (I)
|
|
2995
3026
|
try {
|
|
2996
|
-
p.set(b, `data:${I};base64,${
|
|
3027
|
+
p.set(b, `data:${I};base64,${Di(await he(t, C))}`);
|
|
2997
3028
|
} catch {
|
|
2998
3029
|
}
|
|
2999
3030
|
}
|
|
@@ -3011,24 +3042,24 @@ async function Bi(u) {
|
|
|
3011
3042
|
m.set(C, b.get(E) || "ul");
|
|
3012
3043
|
}
|
|
3013
3044
|
}
|
|
3014
|
-
return new
|
|
3045
|
+
return new Ni(l, p, m).convertBody(o);
|
|
3015
3046
|
}
|
|
3016
|
-
const
|
|
3047
|
+
const Fi = ["nw", "ne", "sw", "se"], Et = ["img-left", "img-right", "img-top", "img-center"], St = {
|
|
3017
3048
|
"img-left": "tplimgleft",
|
|
3018
3049
|
"img-right": "tplimgright",
|
|
3019
3050
|
"img-top": "tplimgtop",
|
|
3020
3051
|
"img-center": "tplimgcenter"
|
|
3021
|
-
},
|
|
3052
|
+
}, Zi = {
|
|
3022
3053
|
"img-left": h.tplleft,
|
|
3023
3054
|
"img-right": h.tplright,
|
|
3024
3055
|
"img-top": h.tpltop,
|
|
3025
3056
|
"img-center": h.tplcenter
|
|
3026
|
-
},
|
|
3027
|
-
let O = null, X = null, Lt = 0,
|
|
3057
|
+
}, _i = ".tox,.pop,.tblctx,.imgctx,.selctx,.dlg";
|
|
3058
|
+
let O = null, X = null, Lt = 0, pe = !1;
|
|
3028
3059
|
function ct() {
|
|
3029
3060
|
clearTimeout(Lt), X = null, O && O.classList.remove("show");
|
|
3030
3061
|
}
|
|
3031
|
-
function
|
|
3062
|
+
function $i(u) {
|
|
3032
3063
|
const t = u.dataset.tip;
|
|
3033
3064
|
if (!t) return;
|
|
3034
3065
|
X = u, clearTimeout(Lt);
|
|
@@ -3037,60 +3068,60 @@ function Zi(u) {
|
|
|
3037
3068
|
if (X !== u || !document.contains(u)) return;
|
|
3038
3069
|
O || (O = document.createElement("div"), O.className = "etip", document.body.appendChild(O)), O.textContent = t, O.classList.add("show");
|
|
3039
3070
|
const i = u.getBoundingClientRect(), s = O.offsetWidth, n = O.offsetHeight;
|
|
3040
|
-
let
|
|
3041
|
-
|
|
3042
|
-
let
|
|
3043
|
-
|
|
3071
|
+
let r = i.left + i.width / 2 - s / 2;
|
|
3072
|
+
r = Math.max(6, Math.min(r, innerWidth - s - 6));
|
|
3073
|
+
let o = i.bottom + 7;
|
|
3074
|
+
o + n > innerHeight - 6 && (o = i.top - n - 7), O.style.left = r + "px", O.style.top = o + "px";
|
|
3044
3075
|
}, e);
|
|
3045
3076
|
}
|
|
3046
|
-
function
|
|
3047
|
-
|
|
3077
|
+
function ji() {
|
|
3078
|
+
pe || (pe = !0, document.addEventListener("mouseover", (u) => {
|
|
3048
3079
|
const t = u.target, e = t.closest ? t.closest("[title],[data-tip]") : null;
|
|
3049
|
-
if (!e || !e.closest(
|
|
3080
|
+
if (!e || !e.closest(_i) || e.closest(".earea")) {
|
|
3050
3081
|
e !== X && ct();
|
|
3051
3082
|
return;
|
|
3052
3083
|
}
|
|
3053
3084
|
const i = e.getAttribute("title");
|
|
3054
|
-
i && (e.dataset.tip = i, e.removeAttribute("title"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e !== X &&
|
|
3085
|
+
i && (e.dataset.tip = i, e.removeAttribute("title"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e !== X && $i(e);
|
|
3055
3086
|
}), document.addEventListener("mouseout", (u) => {
|
|
3056
3087
|
X && !X.contains(u.relatedTarget) && ct();
|
|
3057
3088
|
}), document.addEventListener("mousedown", ct, !0), addEventListener("scroll", ct, !0));
|
|
3058
3089
|
}
|
|
3059
|
-
const
|
|
3060
|
-
function
|
|
3090
|
+
const Wi = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u0780-\u07BF\u08A0-\u08FF\uFB1D-\uFB4F\uFB50-\uFDFF\uFE70-\uFEFF]/, Ui = new RegExp("\\p{L}", "u"), Vi = "p,div,li,td,th,blockquote,h1,h2,h3,h4,h5,h6,pre,figcaption";
|
|
3091
|
+
function zi(u) {
|
|
3061
3092
|
for (const t of u) {
|
|
3062
|
-
if (
|
|
3063
|
-
if (
|
|
3093
|
+
if (Wi.test(t)) return "rtl";
|
|
3094
|
+
if (Ui.test(t)) return "ltr";
|
|
3064
3095
|
}
|
|
3065
3096
|
return null;
|
|
3066
3097
|
}
|
|
3067
|
-
const ht = ["top", "right", "bottom", "left"],
|
|
3068
|
-
function
|
|
3098
|
+
const ht = ["top", "right", "bottom", "left"], Xi = /^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/i, Yi = /^(thin|medium|thick|[+-]?(\d+\.?\d*|\.\d+)(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?)$/i, Gi = /^[+-]?0*(\.0*)?(px|pt|em|rem|ex|ch|cm|mm|in|pc|q)?$/i, Ki = /^border-(collapse|spacing|radius|image|block|inline|start|end)/i, Qi = /^border(?:-(top|right|bottom|left))?(?:-(width|style|color))?$/, Ji = /^(inherit|initial|unset|revert|revert-layer)$/i;
|
|
3099
|
+
function be(u) {
|
|
3069
3100
|
const t = [];
|
|
3070
3101
|
let e = 0, i = "";
|
|
3071
3102
|
for (const s of u)
|
|
3072
3103
|
s === "(" ? e++ : s === ")" && e--, e === 0 && /\s/.test(s) ? (i && t.push(i), i = "") : i += s;
|
|
3073
3104
|
return i && t.push(i), t;
|
|
3074
3105
|
}
|
|
3075
|
-
function
|
|
3106
|
+
function ts(u) {
|
|
3076
3107
|
const [t, e = t, i = t, s = e] = u;
|
|
3077
3108
|
return [t, e, i, s];
|
|
3078
3109
|
}
|
|
3079
|
-
function
|
|
3110
|
+
function es(u) {
|
|
3080
3111
|
const t = { width: "medium", style: "none", color: "" };
|
|
3081
|
-
return
|
|
3082
|
-
|
|
3112
|
+
return be(u).forEach((e) => {
|
|
3113
|
+
Xi.test(e) ? t.style = e.toLowerCase() : Yi.test(e) ? t.width = e : t.color = e;
|
|
3083
3114
|
}), t;
|
|
3084
3115
|
}
|
|
3085
|
-
function
|
|
3116
|
+
function is(u) {
|
|
3086
3117
|
return !u || /^currentcolor$/i.test(u) ? "" : /^windowtext$/i.test(u) ? "#000000" : u;
|
|
3087
3118
|
}
|
|
3088
|
-
function
|
|
3119
|
+
function ss(u) {
|
|
3089
3120
|
if (u.width === null && u.style === null && u.color === null) return "";
|
|
3090
3121
|
const t = u.style ?? "solid";
|
|
3091
|
-
return t === "none" || t === "hidden" || u.width &&
|
|
3122
|
+
return t === "none" || t === "hidden" || u.width && Gi.test(u.width) ? "none" : [u.width && u.width !== "medium" ? u.width : "", t, is(u.color || "")].filter(Boolean).join(" ");
|
|
3092
3123
|
}
|
|
3093
|
-
function
|
|
3124
|
+
function ns(u) {
|
|
3094
3125
|
u.querySelectorAll("table,td,th").forEach((t) => {
|
|
3095
3126
|
const e = t.getAttribute("style") || "";
|
|
3096
3127
|
if (!/border/i.test(e)) return;
|
|
@@ -3100,20 +3131,20 @@ function es(u) {
|
|
|
3100
3131
|
bottom: { width: null, style: null, color: null },
|
|
3101
3132
|
left: { width: null, style: null, color: null }
|
|
3102
3133
|
}, s = [];
|
|
3103
|
-
let n = !1,
|
|
3134
|
+
let n = !1, r = !1;
|
|
3104
3135
|
if (e.split(";").forEach((a) => {
|
|
3105
3136
|
const d = a.indexOf(":");
|
|
3106
3137
|
if (d < 1) {
|
|
3107
3138
|
a.trim() && s.push(a.trim());
|
|
3108
3139
|
return;
|
|
3109
3140
|
}
|
|
3110
|
-
const p = a.slice(0, d).trim().toLowerCase(), m = a.slice(d + 1).trim(), v =
|
|
3111
|
-
if (!v ||
|
|
3141
|
+
const p = a.slice(0, d).trim().toLowerCase(), m = a.slice(d + 1).trim(), v = Qi.exec(p);
|
|
3142
|
+
if (!v || Ki.test(p)) {
|
|
3112
3143
|
s.push(p + ":" + m);
|
|
3113
3144
|
return;
|
|
3114
3145
|
}
|
|
3115
|
-
if (
|
|
3116
|
-
|
|
3146
|
+
if (Ji.test(m)) {
|
|
3147
|
+
r = !0;
|
|
3117
3148
|
return;
|
|
3118
3149
|
}
|
|
3119
3150
|
n = !0;
|
|
@@ -3122,23 +3153,23 @@ function es(u) {
|
|
|
3122
3153
|
if (b)
|
|
3123
3154
|
i[b][f] = m;
|
|
3124
3155
|
else {
|
|
3125
|
-
const y =
|
|
3156
|
+
const y = ts(be(m));
|
|
3126
3157
|
ht.forEach((C, E) => {
|
|
3127
3158
|
i[C][f] = y[E];
|
|
3128
3159
|
});
|
|
3129
3160
|
}
|
|
3130
3161
|
else {
|
|
3131
|
-
const y =
|
|
3162
|
+
const y = es(m);
|
|
3132
3163
|
(b ? [b] : ht.slice()).forEach((C) => {
|
|
3133
3164
|
i[C] = { ...y };
|
|
3134
3165
|
});
|
|
3135
3166
|
}
|
|
3136
|
-
}),
|
|
3137
|
-
const
|
|
3138
|
-
|
|
3167
|
+
}), r || !n) return;
|
|
3168
|
+
const o = ht.map((a) => ss(i[a])), l = s.slice();
|
|
3169
|
+
o.every((a) => a && a === o[0]) ? l.push("border:" + o[0]) : ht.forEach((a, d) => o[d] && l.push(`border-${a}:` + o[d])), t.setAttribute("style", l.join(";"));
|
|
3139
3170
|
});
|
|
3140
3171
|
}
|
|
3141
|
-
function
|
|
3172
|
+
function ye(u) {
|
|
3142
3173
|
let t = "";
|
|
3143
3174
|
return u.childNodes.forEach((e) => {
|
|
3144
3175
|
if (e.nodeType === Node.TEXT_NODE)
|
|
@@ -3146,12 +3177,12 @@ function be(u) {
|
|
|
3146
3177
|
else if (e.nodeType === Node.ELEMENT_NODE) {
|
|
3147
3178
|
const i = e, s = (i.getAttribute("dir") || "").toLowerCase();
|
|
3148
3179
|
if (s === "rtl" || s === "ltr") return;
|
|
3149
|
-
t +=
|
|
3180
|
+
t += ye(i);
|
|
3150
3181
|
}
|
|
3151
3182
|
}), t;
|
|
3152
3183
|
}
|
|
3153
3184
|
var j;
|
|
3154
|
-
let
|
|
3185
|
+
let rs = (j = class {
|
|
3155
3186
|
constructor(t) {
|
|
3156
3187
|
this.lang = "en", this.contentClass = "fable-content-" + j.instanceCounter++, this.contentStyleEl = null, this.savedRange = null, this.foreColor = "#000000", this.backColor = "#FACC15", this.openPop = null, this.subStack = [], this.popAnchor = null, this.dlgOvl = null, this.tblActive = null, this.tblCorner = null, this.tblColBars = [], this.tblCtx = null, this.tblCellMark = null, this.tblOpMark = null, this.tblOpMarkKind = null, this.imgActive = null, this.imgHandles = [], this.imgCtx = null, this.imgHideTimer = null, this.phActive = null, this.phCtx = null, this.phUploadTarget = null, this.vidActive = null, this.vidCtx = null, this.vidHideTimer = null, this.vphActive = null, this.vphCtx = null, this.vphUploadTarget = null, this.selCtx = null, this.tbrMore = null, this.tbrExpanded = !1, this.codeActive = null, this.codeCtx = null, this.tplActive = null, this.tplCtx = null, this.revisions = [], this.revTimer = null, this.draftTimer = null, this.draftStorageKey = "", this.listeners = [], this.isDestroyed = !1, this.options = {
|
|
3157
3188
|
target: t.target,
|
|
@@ -3167,7 +3198,7 @@ let is = (j = class {
|
|
|
3167
3198
|
statusbar: t.statusbar ?? !0,
|
|
3168
3199
|
readonly: t.readonly ?? !1,
|
|
3169
3200
|
draftKey: t.draftKey ?? (typeof location < "u" ? location.pathname : "default"),
|
|
3170
|
-
fontFamilyFormats: t.fontFamilyFormats ??
|
|
3201
|
+
fontFamilyFormats: t.fontFamilyFormats ?? si,
|
|
3171
3202
|
imageFileTypes: t.imageFileTypes ?? ["image/jpeg", "image/jpg", "image/png", "image/gif", "image/bmp", "image/webp"],
|
|
3172
3203
|
videoFileTypes: t.videoFileTypes ?? ["video/mp4", "video/webm", "video/ogg"]
|
|
3173
3204
|
}, this.imageUploadHandler = t.imageUploadHandler, this.onImageUploadError = t.onImageUploadError, this.videoUploadHandler = t.videoUploadHandler, this.onVideoUploadError = t.onVideoUploadError, this.contentStyle = t.contentStyle, this.applyTheme(t), this.lang = this.options.language, this.draftStorageKey = "tmclone-draft:" + this.options.draftKey, this.initDOM(), this.bindEvents(), this.initUI(), this.recordRevision(), this.stampExistingImages(), this.options.onReady(this);
|
|
@@ -3193,7 +3224,7 @@ let is = (j = class {
|
|
|
3193
3224
|
</span>
|
|
3194
3225
|
`, this.sbHelp = this.statusbar.querySelector(".mid"), this.sbWords = this.statusbar.querySelector(".words");
|
|
3195
3226
|
const e = this.statusbar.querySelector(".grip");
|
|
3196
|
-
this.bindGrip(e), this.shell.appendChild(this.menubar), this.shell.appendChild(this.toolbar), this.shell.appendChild(this.ed), this.shell.appendChild(this.statusbar), this.contentStyle && (this.contentStyleEl = document.createElement("style"), this.contentStyleEl.textContent = this.scopeContentStyle(this.contentStyle), this.shell.appendChild(this.contentStyleEl)), t.appendChild(this.shell),
|
|
3227
|
+
this.bindGrip(e), this.shell.appendChild(this.menubar), this.shell.appendChild(this.toolbar), this.shell.appendChild(this.ed), this.shell.appendChild(this.statusbar), this.contentStyle && (this.contentStyleEl = document.createElement("style"), this.contentStyleEl.textContent = this.scopeContentStyle(this.contentStyle), this.shell.appendChild(this.contentStyleEl)), t.appendChild(this.shell), ji(), this.options.statusbar || (this.statusbar.style.display = "none"), this.imgInput = document.createElement("input"), this.imgInput.type = "file", this.imgInput.accept = this.options.imageFileTypes.join(","), this.imgInput.style.display = "none", t.appendChild(this.imgInput), this.vidInput = document.createElement("input"), this.vidInput.type = "file", this.vidInput.accept = this.options.videoFileTypes.join(","), this.vidInput.style.display = "none", t.appendChild(this.vidInput), this.docInput = document.createElement("input"), this.docInput.type = "file", this.docInput.accept = ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document", this.docInput.style.display = "none", t.appendChild(this.docInput);
|
|
3197
3228
|
}
|
|
3198
3229
|
/** Theme options land as CSS variables on the document root rather than the editor
|
|
3199
3230
|
* shell, because dialogs, popups and floating context toolbars are appended to
|
|
@@ -3213,12 +3244,12 @@ let is = (j = class {
|
|
|
3213
3244
|
let e = 0, i = 0;
|
|
3214
3245
|
const s = (n) => {
|
|
3215
3246
|
e = n.clientY, i = this.ed.offsetHeight, n.preventDefault();
|
|
3216
|
-
const
|
|
3217
|
-
this.ed.style.height = Math.max(120, i +
|
|
3218
|
-
},
|
|
3219
|
-
window.removeEventListener("mousemove",
|
|
3247
|
+
const r = (l) => {
|
|
3248
|
+
this.ed.style.height = Math.max(120, i + l.clientY - e) + "px";
|
|
3249
|
+
}, o = () => {
|
|
3250
|
+
window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", o);
|
|
3220
3251
|
};
|
|
3221
|
-
window.addEventListener("mousemove",
|
|
3252
|
+
window.addEventListener("mousemove", r), window.addEventListener("mouseup", o);
|
|
3222
3253
|
};
|
|
3223
3254
|
t.addEventListener("mousedown", s), this.listeners.push(() => t.removeEventListener("mousedown", s));
|
|
3224
3255
|
}
|
|
@@ -3236,17 +3267,17 @@ let is = (j = class {
|
|
|
3236
3267
|
}), this.on(this.ed, "keydown", (t) => {
|
|
3237
3268
|
t.altKey && t.key === "0" && (t.preventDefault(), this.helpDlg()), (t.key === "Delete" || t.key === "Backspace") && this.phActive && (t.preventDefault(), this.removeImgPlaceholder()), (t.key === "Delete" || t.key === "Backspace") && this.vphActive && (t.preventDefault(), this.removeVphPlaceholder()), t.key === "`" && !t.ctrlKey && !t.metaKey && !t.altKey && this.tryCodeTyping(t), t.key === "Enter" && !t.shiftKey && !t.ctrlKey && !t.metaKey && !t.altKey && this.tryExitBlockquote(t);
|
|
3238
3269
|
}), this.on(this.ed, "paste", (t) => this.handlePaste(t)), this.on(this.ed, "drop", (t) => {
|
|
3239
|
-
var n,
|
|
3270
|
+
var n, r, o, l;
|
|
3240
3271
|
t.preventDefault();
|
|
3241
3272
|
const e = t.target, i = (n = e.closest) == null ? void 0 : n.call(e, ".img-ph:not(.vid-ph)");
|
|
3242
3273
|
if (i && this.ed.contains(i) && !this.options.readonly) {
|
|
3243
|
-
const a = Array.from(((
|
|
3274
|
+
const a = Array.from(((r = t.dataTransfer) == null ? void 0 : r.files) || []).find((d) => d.type.startsWith("image/"));
|
|
3244
3275
|
a && this.readImageFileInto(a, i);
|
|
3245
3276
|
return;
|
|
3246
3277
|
}
|
|
3247
|
-
const s = (
|
|
3278
|
+
const s = (o = e.closest) == null ? void 0 : o.call(e, ".vid-ph");
|
|
3248
3279
|
if (s && this.ed.contains(s) && !this.options.readonly) {
|
|
3249
|
-
const a = Array.from(((
|
|
3280
|
+
const a = Array.from(((l = t.dataTransfer) == null ? void 0 : l.files) || []).find((d) => d.type.startsWith("video/"));
|
|
3250
3281
|
a && this.readVideoFileInto(a, s);
|
|
3251
3282
|
}
|
|
3252
3283
|
}), this.on(this.ed, "dragover", (t) => t.preventDefault()), this.on(this.ed, "mousedown", (t) => {
|
|
@@ -3257,12 +3288,12 @@ let is = (j = class {
|
|
|
3257
3288
|
s && this.ed.contains(s) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectImgPlaceholder(s)) : this.clearImgPlaceholderSel();
|
|
3258
3289
|
const n = (m = e.closest) == null ? void 0 : m.call(e, ".vid-ph");
|
|
3259
3290
|
n && this.ed.contains(n) && !this.options.readonly ? (t.preventDefault(), this.ed.focus(), this.selectVphPlaceholder(n)) : this.clearVphPlaceholderSel();
|
|
3260
|
-
const
|
|
3261
|
-
|
|
3262
|
-
const
|
|
3263
|
-
|
|
3264
|
-
const
|
|
3265
|
-
|
|
3291
|
+
const r = (v = e.closest) == null ? void 0 : v.call(e, ".tpl");
|
|
3292
|
+
r && this.ed.contains(r) && !this.options.readonly ? this.selectTemplate(r) : this.clearTplSel();
|
|
3293
|
+
const o = (b = e.closest) == null ? void 0 : b.call(e, "pre.code-block");
|
|
3294
|
+
o && this.ed.contains(o) && !this.options.readonly ? (t.preventDefault(), this.selectCodeEl(o)) : this.clearCodeSel();
|
|
3295
|
+
const l = (f = e.closest) == null ? void 0 : f.call(e, "img");
|
|
3296
|
+
l && this.ed.contains(l) && !this.options.readonly ? (t.preventDefault(), this.selectImage(l)) : this.clearImageHandles();
|
|
3266
3297
|
const a = (y = e.closest) == null ? void 0 : y.call(e, "video, .video-embed");
|
|
3267
3298
|
a && this.ed.contains(a) && !this.options.readonly ? (t.preventDefault(), this.selectVideo(a)) : this.clearVidHandles();
|
|
3268
3299
|
}), this.on(this.ed, "mouseover", (t) => {
|
|
@@ -3271,11 +3302,11 @@ let is = (j = class {
|
|
|
3271
3302
|
const e = (s = (i = t.target).closest) == null ? void 0 : s.call(i, "img");
|
|
3272
3303
|
e && this.ed.contains(e) && (this.cancelImgHide(), this.selectImage(e));
|
|
3273
3304
|
}), this.on(this.ed, "mouseout", (t) => {
|
|
3274
|
-
var s, n,
|
|
3305
|
+
var s, n, r, o;
|
|
3275
3306
|
const e = (n = (s = t.target).closest) == null ? void 0 : n.call(s, "img");
|
|
3276
3307
|
if (!e) return;
|
|
3277
3308
|
const i = t.relatedTarget;
|
|
3278
|
-
i && ((
|
|
3309
|
+
i && ((r = this.imgCtx) != null && r.contains(i) || this.imgHandles.some((l) => l.contains(i)) || ((o = i.closest) == null ? void 0 : o.call(i, "img")) === e) || this.scheduleImgHide();
|
|
3279
3310
|
}), this.on(this.ed, "scroll", () => {
|
|
3280
3311
|
this.positionTableHandles(), this.positionImageHandles(), this.positionImgPhCtx(), this.positionTplCtx(), this.positionVphCtx(), this.positionVidCtx(), this.positionCodeCtx();
|
|
3281
3312
|
}), this.onWin(
|
|
@@ -3357,41 +3388,42 @@ let is = (j = class {
|
|
|
3357
3388
|
* content with no strongly-directional character anywhere falls back to the
|
|
3358
3389
|
* editor's current direction. */
|
|
3359
3390
|
getContentForEmail() {
|
|
3360
|
-
const t = (
|
|
3361
|
-
const
|
|
3362
|
-
|
|
3363
|
-
}, e =
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
const
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
const d =
|
|
3378
|
-
|
|
3391
|
+
const t = (l, a) => {
|
|
3392
|
+
const d = (l.getAttribute("style") || "").trim();
|
|
3393
|
+
l.setAttribute("style", d ? d.replace(/;?$/, "; ") + a : a);
|
|
3394
|
+
}, e = (l, a) => {
|
|
3395
|
+
const d = (l.getAttribute("style") || "").split(";").map((p) => p.trim()).filter((p) => p && !/^width\s*:/i.test(p));
|
|
3396
|
+
d.push(`width:${a}px`), l.setAttribute("style", d.join("; "));
|
|
3397
|
+
}, i = document.createElement("div");
|
|
3398
|
+
i.innerHTML = this.ed.innerHTML;
|
|
3399
|
+
let s = null;
|
|
3400
|
+
i.querySelectorAll("[dir]").forEach((l) => {
|
|
3401
|
+
const a = (l.getAttribute("dir") || "").toLowerCase();
|
|
3402
|
+
if (a !== "rtl" && a !== "ltr") return;
|
|
3403
|
+
const d = a;
|
|
3404
|
+
s || (s = d), /text-align\s*:/i.test(l.getAttribute("style") || "") || t(l, `text-align:${d === "rtl" ? "right" : "left"}`);
|
|
3405
|
+
}), i.querySelectorAll(Vi).forEach((l) => {
|
|
3406
|
+
const a = (l.getAttribute("dir") || "").toLowerCase();
|
|
3407
|
+
if (a === "rtl" || a === "ltr") return;
|
|
3408
|
+
const d = zi(ye(l));
|
|
3409
|
+
if (!d) return;
|
|
3410
|
+
s || (s = d), l.setAttribute("dir", d);
|
|
3411
|
+
const p = /text-align\s*:/i.test(l.getAttribute("style") || "");
|
|
3412
|
+
t(l, p ? `direction:${d}` : `direction:${d};text-align:${d === "rtl" ? "right" : "left"}`);
|
|
3379
3413
|
});
|
|
3380
|
-
const
|
|
3381
|
-
|
|
3382
|
-
if (
|
|
3383
|
-
const
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
const o = r.getAttribute("style") || "";
|
|
3389
|
-
/border-collapse\s*:/i.test(o) || t(r, "border-collapse:collapse"), !/border-spacing\s*:/i.test(o) && !r.hasAttribute("cellspacing") && r.setAttribute("cellspacing", "0");
|
|
3414
|
+
const n = this.ed.querySelectorAll("img");
|
|
3415
|
+
i.querySelectorAll("img").forEach((l, a) => {
|
|
3416
|
+
if (l.closest(".tpl-media")) return;
|
|
3417
|
+
const d = n[a], p = Math.round((d == null ? void 0 : d.offsetWidth) || 0);
|
|
3418
|
+
p > 0 && (l.setAttribute("width", String(p)), l.removeAttribute("height"), e(l, p)), /max-width\s*:/i.test(l.getAttribute("style") || "") || t(l, "max-width:100%"), /(^|;)\s*height\s*:/i.test(l.getAttribute("style") || "") || t(l, "height:auto");
|
|
3419
|
+
}), ns(i), i.querySelectorAll("table").forEach((l) => {
|
|
3420
|
+
const a = l.getAttribute("style") || "";
|
|
3421
|
+
/border-collapse\s*:/i.test(a) || t(l, "border-collapse:collapse"), !/border-spacing\s*:/i.test(a) && !l.hasAttribute("cellspacing") && l.setAttribute("cellspacing", "0");
|
|
3390
3422
|
});
|
|
3391
|
-
const
|
|
3392
|
-
return
|
|
3393
|
-
|
|
3394
|
-
}), `<div dir="${
|
|
3423
|
+
const r = s || this.ed.getAttribute("dir") || this.dir();
|
|
3424
|
+
return i.querySelectorAll("table:not([dir])").forEach((l) => {
|
|
3425
|
+
l.setAttribute("dir", r), /direction\s*:/i.test(l.getAttribute("style") || "") || t(l, `direction:${r}`);
|
|
3426
|
+
}), `<div dir="${r}" style="direction:${r};text-align:${r === "rtl" ? "right" : "left"}">${i.innerHTML}</div>`;
|
|
3395
3427
|
}
|
|
3396
3428
|
setContent(t) {
|
|
3397
3429
|
this.ed.innerHTML = t || "<p><br></p>", this.refreshState(), this.clearTableHandles(), this.clearImageHandles(), this.clearImgPlaceholderSel(), this.clearTplSel(), this.clearVphPlaceholderSel(), this.clearVidHandles(), this.clearCodeSel(), this.clearSelToolbar(), this.onChange(), this.stampExistingImages();
|
|
@@ -3406,7 +3438,7 @@ let is = (j = class {
|
|
|
3406
3438
|
this.ed.focus();
|
|
3407
3439
|
}
|
|
3408
3440
|
async importWordFile(t) {
|
|
3409
|
-
const e = await
|
|
3441
|
+
const e = await Oi(t);
|
|
3410
3442
|
this.recordRevision(), this.setContent(e), this.recordRevision();
|
|
3411
3443
|
}
|
|
3412
3444
|
restoreDraft() {
|
|
@@ -3465,8 +3497,8 @@ let is = (j = class {
|
|
|
3465
3497
|
t.preventDefault();
|
|
3466
3498
|
const n = document.createElement("p");
|
|
3467
3499
|
n.appendChild(document.createElement("br")), s.after(n), i.remove(), s.firstElementChild || s.remove();
|
|
3468
|
-
const
|
|
3469
|
-
|
|
3500
|
+
const r = document.createRange();
|
|
3501
|
+
r.setStart(n, 0), r.collapse(!0), e.removeAllRanges(), e.addRange(r), this.saveSel(), this.onChange();
|
|
3470
3502
|
}
|
|
3471
3503
|
selectedBlocks() {
|
|
3472
3504
|
const t = window.getSelection();
|
|
@@ -3516,30 +3548,30 @@ let is = (j = class {
|
|
|
3516
3548
|
s.className = "revprev";
|
|
3517
3549
|
const n = document.createElement("button");
|
|
3518
3550
|
n.type = "button", n.className = "revrestore", n.textContent = this.t("restore");
|
|
3519
|
-
let
|
|
3520
|
-
const
|
|
3551
|
+
let r = this.revisions.length - 1;
|
|
3552
|
+
const o = new Intl.DateTimeFormat(this.lang === "ar" ? "ar-AE" : "en-GB", {
|
|
3521
3553
|
year: "numeric",
|
|
3522
3554
|
month: "short",
|
|
3523
3555
|
day: "numeric",
|
|
3524
3556
|
hour: "2-digit",
|
|
3525
3557
|
minute: "2-digit",
|
|
3526
3558
|
second: "2-digit"
|
|
3527
|
-
}),
|
|
3528
|
-
|
|
3559
|
+
}), l = {}, a = (d) => {
|
|
3560
|
+
r = d, this.revisions.forEach((p, m) => {
|
|
3529
3561
|
var v;
|
|
3530
|
-
return (v =
|
|
3562
|
+
return (v = l[m]) == null ? void 0 : v.classList.toggle("on", m === d);
|
|
3531
3563
|
}), s.innerHTML = this.revisions[d].html, n.disabled = d === this.revisions.length - 1;
|
|
3532
3564
|
};
|
|
3533
3565
|
for (let d = this.revisions.length - 1; d >= 0; d--) {
|
|
3534
3566
|
const p = this.revisions[d], m = document.createElement("button");
|
|
3535
3567
|
m.type = "button";
|
|
3536
3568
|
const v = (new DOMParser().parseFromString(p.html, "text/html").body.textContent || "").trim(), b = v ? v.split(/\s+/).length : 0, f = d === this.revisions.length - 1;
|
|
3537
|
-
m.innerHTML = `<span>${f ? this.t("currentver") :
|
|
3569
|
+
m.innerHTML = `<span>${f ? this.t("currentver") : o.format(new Date(p.time))}</span><span class="wc">${b} ${this.t("words")}</span>`, m.addEventListener("click", () => a(d)), l[d] = m, i.appendChild(m);
|
|
3538
3570
|
}
|
|
3539
3571
|
i.append(n), n.addEventListener("click", () => {
|
|
3540
|
-
const d = this.revisions[
|
|
3572
|
+
const d = this.revisions[r];
|
|
3541
3573
|
d && (this.recordRevision(), this.setContent(d.html), this.recordRevision(), this.closeDlg());
|
|
3542
|
-
}), e.append(i, s), t.appendChild(e), a(
|
|
3574
|
+
}), e.append(i, s), t.appendChild(e), a(r);
|
|
3543
3575
|
});
|
|
3544
3576
|
}
|
|
3545
3577
|
/* ---------------------------------------------------------- popups / menus */
|
|
@@ -3576,10 +3608,10 @@ let is = (j = class {
|
|
|
3576
3608
|
n.className = "pop sub", n.dir = this.dir(), t.subBuild ? t.subBuild(n) : t.sub && this.menuItems(n, t.sub), n.addEventListener("mousedown", (a) => {
|
|
3577
3609
|
a.target.tagName !== "INPUT" && a.preventDefault();
|
|
3578
3610
|
}), document.body.appendChild(n);
|
|
3579
|
-
let
|
|
3580
|
-
|
|
3581
|
-
let
|
|
3582
|
-
|
|
3611
|
+
let o = this.dir() === "rtl" ? i.left - n.offsetWidth + 2 : i.right - 2;
|
|
3612
|
+
o = Math.max(8, Math.min(o + scrollX, scrollX + innerWidth - n.offsetWidth - 8));
|
|
3613
|
+
let l = i.top + scrollY - 6;
|
|
3614
|
+
l = Math.max(8 + scrollY, Math.min(l, scrollY + innerHeight - n.offsetHeight - 8)), n.style.left = o + "px", n.style.top = l + "px", this.subStack.push(n);
|
|
3583
3615
|
}
|
|
3584
3616
|
popup(t, e, i) {
|
|
3585
3617
|
if (this.openPop && this.popAnchor === t) {
|
|
@@ -3591,10 +3623,10 @@ let is = (j = class {
|
|
|
3591
3623
|
s.className = "pop" + (i ? " " + i : ""), s.dir = this.dir(), e(s), document.body.appendChild(s);
|
|
3592
3624
|
const n = t.getBoundingClientRect();
|
|
3593
3625
|
s.style.minWidth = Math.max(160, Math.round(n.width)) + "px";
|
|
3594
|
-
let
|
|
3595
|
-
|
|
3596
|
-
let
|
|
3597
|
-
|
|
3626
|
+
let r = n.bottom + scrollY + 2;
|
|
3627
|
+
r = Math.max(8 + scrollY, Math.min(r, scrollY + innerHeight - s.offsetHeight - 8)), s.style.top = r + "px";
|
|
3628
|
+
let l = this.dir() === "rtl" ? n.right - s.offsetWidth : n.left;
|
|
3629
|
+
l = Math.max(8, Math.min(l + scrollX, scrollX + innerWidth - s.offsetWidth - 8)), s.style.left = l + "px", s.addEventListener("mousedown", (a) => {
|
|
3598
3630
|
a.target.tagName !== "INPUT" && a.preventDefault();
|
|
3599
3631
|
}), this.openPop = s, this.popAnchor = t, t.classList.add("open");
|
|
3600
3632
|
}
|
|
@@ -3608,18 +3640,18 @@ let is = (j = class {
|
|
|
3608
3640
|
n.className = "mi" + (i.on ? " on" : ""), n.innerHTML = `<span class="ic">${i.icon || ""}</span><span class="prev" ${i.previewStyle ? `style="${i.previewStyle}"` : ""}>${i.label}</span>${i.shortcut ? `<span class="sc">${i.shortcut}</span>` : ""}${s ? `<span class="subarrow">${h.chev}</span>` : ""}`, n.addEventListener("click", () => {
|
|
3609
3641
|
i.action && (this.closePop(), i.action());
|
|
3610
3642
|
}), n.addEventListener("mouseenter", () => {
|
|
3611
|
-
var
|
|
3612
|
-
s ? this.openSubFor(i, n) : this.closeSubFrom(this.subLevelOf(t)), (
|
|
3643
|
+
var r;
|
|
3644
|
+
s ? this.openSubFor(i, n) : this.closeSubFrom(this.subLevelOf(t)), (r = i.hover) == null || r.call(i, !0);
|
|
3613
3645
|
}), n.addEventListener("mouseleave", () => {
|
|
3614
|
-
var
|
|
3615
|
-
return (
|
|
3646
|
+
var r;
|
|
3647
|
+
return (r = i.hover) == null ? void 0 : r.call(i, !1);
|
|
3616
3648
|
}), t.appendChild(n);
|
|
3617
3649
|
});
|
|
3618
3650
|
}
|
|
3619
3651
|
/* ---------------------------------------------------------- toolbar builders */
|
|
3620
3652
|
tbtn(t, e, i, s) {
|
|
3621
3653
|
const n = document.createElement("button");
|
|
3622
|
-
return n.className = "tbtn", n.type = "button", n.title = e, n.innerHTML = t, s && (n.dataset.id = s), n.addEventListener("mousedown", (
|
|
3654
|
+
return n.className = "tbtn", n.type = "button", n.title = e, n.innerHTML = t, s && (n.dataset.id = s), n.addEventListener("mousedown", (r) => r.preventDefault()), n.addEventListener("click", i), n;
|
|
3623
3655
|
}
|
|
3624
3656
|
/** Font-size increase / decrease step button. */
|
|
3625
3657
|
stepBtn(t) {
|
|
@@ -3635,10 +3667,10 @@ let is = (j = class {
|
|
|
3635
3667
|
colorChips() {
|
|
3636
3668
|
const t = (s) => {
|
|
3637
3669
|
const n = document.createElement("button");
|
|
3638
|
-
return n.type = "button", n.className = "cchip", n.title = s, n.addEventListener("mousedown", (
|
|
3639
|
-
|
|
3670
|
+
return n.type = "button", n.className = "cchip", n.title = s, n.addEventListener("mousedown", (r) => {
|
|
3671
|
+
r.preventDefault(), this.saveSel();
|
|
3640
3672
|
}), n;
|
|
3641
|
-
}, e =
|
|
3673
|
+
}, e = oi.map((s) => {
|
|
3642
3674
|
const n = t(this.t("forecolor"));
|
|
3643
3675
|
return n.style.background = s, n.addEventListener("click", () => this.applyColor("fore", s)), n;
|
|
3644
3676
|
}), i = t(this.t("forecolor"));
|
|
@@ -3652,17 +3684,17 @@ let is = (j = class {
|
|
|
3652
3684
|
}
|
|
3653
3685
|
tsel(t, e, i, s) {
|
|
3654
3686
|
const n = document.createElement("button");
|
|
3655
|
-
return n.className = "tsel " + t, n.type = "button", n.dataset.id = e, n.innerHTML = `<span class="lbl empty">${i || ""}</span>${h.chev}`, n.addEventListener("mousedown", (
|
|
3656
|
-
|
|
3687
|
+
return n.className = "tsel " + t, n.type = "button", n.dataset.id = e, n.innerHTML = `<span class="lbl empty">${i || ""}</span>${h.chev}`, n.addEventListener("mousedown", (r) => {
|
|
3688
|
+
r.preventDefault(), this.saveSel();
|
|
3657
3689
|
}), n.addEventListener("click", () => s(n)), n;
|
|
3658
3690
|
}
|
|
3659
3691
|
setListStyle(t, e) {
|
|
3660
|
-
var n,
|
|
3692
|
+
var n, r;
|
|
3661
3693
|
this.restoreSel();
|
|
3662
3694
|
const i = window.getSelection();
|
|
3663
3695
|
if (!i) return;
|
|
3664
3696
|
let s = (n = this.closestBlock(i.anchorNode)) == null ? void 0 : n.closest(t);
|
|
3665
|
-
s || (this.exec(t === "ol" ? "insertOrderedList" : "insertUnorderedList"), s = (
|
|
3697
|
+
s || (this.exec(t === "ol" ? "insertOrderedList" : "insertUnorderedList"), s = (r = this.closestBlock(i.anchorNode)) == null ? void 0 : r.closest(t)), s && (s.style.listStyleType = e), this.saveSel(), this.onChange();
|
|
3666
3698
|
}
|
|
3667
3699
|
listMenu(t, e) {
|
|
3668
3700
|
var a;
|
|
@@ -3674,7 +3706,7 @@ let is = (j = class {
|
|
|
3674
3706
|
] : [
|
|
3675
3707
|
["circle", h.ul_circle],
|
|
3676
3708
|
["square", h.ul_square]
|
|
3677
|
-
], n = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1),
|
|
3709
|
+
], n = this.tArr(e === "ol" ? "liststyles_ol" : "liststyles_ul").slice(1), r = window.getSelection(), o = r ? (a = this.closestBlock(r.anchorNode)) == null ? void 0 : a.closest(e) : null, l = o ? o.style.listStyleType : "";
|
|
3678
3710
|
this.popup(t, (d) => {
|
|
3679
3711
|
this.menuItems(d, [
|
|
3680
3712
|
{
|
|
@@ -3687,7 +3719,7 @@ let is = (j = class {
|
|
|
3687
3719
|
const p = document.createElement("div");
|
|
3688
3720
|
p.className = "mi-grid", s.forEach(([m, v], b) => {
|
|
3689
3721
|
const f = document.createElement("button");
|
|
3690
|
-
f.className = "mi" + (
|
|
3722
|
+
f.className = "mi" + (l === m ? " on" : ""), f.innerHTML = `<span class="ic">${v}</span><span class="prev">${n[b]}</span>`, f.addEventListener("click", () => {
|
|
3691
3723
|
this.closePop(), this.setListStyle(e, m);
|
|
3692
3724
|
}), p.appendChild(f);
|
|
3693
3725
|
}), d.appendChild(p);
|
|
@@ -3698,7 +3730,7 @@ let is = (j = class {
|
|
|
3698
3730
|
* table cell-background menu all show the identical popup. */
|
|
3699
3731
|
buildPaletteInto(t, e, i) {
|
|
3700
3732
|
const s = document.createElement("div");
|
|
3701
|
-
s.className = "cpal",
|
|
3733
|
+
s.className = "cpal", ai.forEach((p) => {
|
|
3702
3734
|
const m = document.createElement("button");
|
|
3703
3735
|
m.type = "button", m.style.background = p, m.title = p, m.addEventListener("click", () => {
|
|
3704
3736
|
this.closePop(), i(p);
|
|
@@ -3706,18 +3738,18 @@ let is = (j = class {
|
|
|
3706
3738
|
}), t.appendChild(s), t.insertAdjacentHTML("beforeend", '<div class="sep"></div>');
|
|
3707
3739
|
const n = document.createElement("div");
|
|
3708
3740
|
n.className = "cfoot";
|
|
3709
|
-
const
|
|
3710
|
-
|
|
3711
|
-
const
|
|
3712
|
-
|
|
3741
|
+
const r = /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", o = document.createElement("div");
|
|
3742
|
+
o.className = "cswatch cur", o.title = this.t("currentcolor"), o.style.background = r, o.innerHTML = h.check;
|
|
3743
|
+
const l = document.createElement("button");
|
|
3744
|
+
l.type = "button", l.className = "cswatch nocolor", l.title = this.t("removecolor"), l.addEventListener("click", () => {
|
|
3713
3745
|
this.closePop(), i(null);
|
|
3714
3746
|
});
|
|
3715
3747
|
const a = document.createElement("label");
|
|
3716
3748
|
a.className = "cswatch cwheel", a.title = this.t("customcolor"), a.innerHTML = h.palette;
|
|
3717
3749
|
const d = document.createElement("input");
|
|
3718
|
-
d.type = "color", d.value =
|
|
3750
|
+
d.type = "color", d.value = r, d.addEventListener("change", () => {
|
|
3719
3751
|
this.closePop(), i(d.value);
|
|
3720
|
-
}), a.appendChild(d), n.append(
|
|
3752
|
+
}), a.appendChild(d), n.append(o, l, a), t.appendChild(n);
|
|
3721
3753
|
}
|
|
3722
3754
|
colorMenu(t, e) {
|
|
3723
3755
|
this.popup(
|
|
@@ -3747,7 +3779,7 @@ let is = (j = class {
|
|
|
3747
3779
|
this.popup(t, (e) => this.menuItems(e, this.fontItems()));
|
|
3748
3780
|
}
|
|
3749
3781
|
sizeItems() {
|
|
3750
|
-
return
|
|
3782
|
+
return ni.map((t) => ({
|
|
3751
3783
|
label: t,
|
|
3752
3784
|
on: this.currentSize() === t,
|
|
3753
3785
|
action: () => this.applyFontSize(t)
|
|
@@ -3763,19 +3795,19 @@ let is = (j = class {
|
|
|
3763
3795
|
const t = window.getSelection();
|
|
3764
3796
|
if (!t) return;
|
|
3765
3797
|
if (!t.rangeCount) {
|
|
3766
|
-
const
|
|
3767
|
-
|
|
3798
|
+
const r = document.createRange();
|
|
3799
|
+
r.selectNodeContents(this.ed), r.collapse(!0), t.addRange(r);
|
|
3768
3800
|
}
|
|
3769
3801
|
if (!t.isCollapsed) return;
|
|
3770
3802
|
const e = t.getRangeAt(0), i = e.startContainer;
|
|
3771
3803
|
if (i.nodeType === 3) {
|
|
3772
|
-
const
|
|
3773
|
-
let
|
|
3774
|
-
for (;
|
|
3775
|
-
for (;
|
|
3776
|
-
if (
|
|
3804
|
+
const r = i.data;
|
|
3805
|
+
let o = e.startOffset, l = e.startOffset;
|
|
3806
|
+
for (; o > 0 && /\S/.test(r[o - 1]); ) o--;
|
|
3807
|
+
for (; l < r.length && /\S/.test(r[l]); ) l++;
|
|
3808
|
+
if (l > o) {
|
|
3777
3809
|
const a = document.createRange();
|
|
3778
|
-
a.setStart(i,
|
|
3810
|
+
a.setStart(i, o), a.setEnd(i, l), t.removeAllRanges(), t.addRange(a), this.savedRange = a.cloneRange();
|
|
3779
3811
|
return;
|
|
3780
3812
|
}
|
|
3781
3813
|
}
|
|
@@ -3800,7 +3832,7 @@ let is = (j = class {
|
|
|
3800
3832
|
this.saveSel(), this.refreshState(), this.onChange();
|
|
3801
3833
|
}
|
|
3802
3834
|
stepFontSize(t) {
|
|
3803
|
-
const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(
|
|
3835
|
+
const e = parseInt(this.currentSize(), 10) || 14, i = Math.min(li, Math.max(ri, e + t));
|
|
3804
3836
|
i !== e && this.applyFontSize(i + "px");
|
|
3805
3837
|
}
|
|
3806
3838
|
/* ------------------------------------------------ case / spacing / link */
|
|
@@ -3809,14 +3841,14 @@ let is = (j = class {
|
|
|
3809
3841
|
const e = window.getSelection();
|
|
3810
3842
|
if (!e || !e.rangeCount || e.isCollapsed) return;
|
|
3811
3843
|
const i = e.getRangeAt(0), s = document.createTreeWalker(this.ed, NodeFilter.SHOW_TEXT), n = [];
|
|
3812
|
-
let
|
|
3813
|
-
for (;
|
|
3814
|
-
n.forEach((
|
|
3815
|
-
const
|
|
3816
|
-
if (a <=
|
|
3817
|
-
const d =
|
|
3844
|
+
let r;
|
|
3845
|
+
for (; r = s.nextNode(); ) i.intersectsNode(r) && n.push(r);
|
|
3846
|
+
n.forEach((o) => {
|
|
3847
|
+
const l = o === i.startContainer ? i.startOffset : 0, a = o === i.endContainer ? i.endOffset : o.data.length;
|
|
3848
|
+
if (a <= l) return;
|
|
3849
|
+
const d = o.data.slice(l, a);
|
|
3818
3850
|
let p = d;
|
|
3819
|
-
t === "lower" ? p = d.toLowerCase() : t === "upper" ? p = d.toUpperCase() : p = d.replace(/(^|\s)(\S)/g, (m, v, b) => v + b.toUpperCase()),
|
|
3851
|
+
t === "lower" ? p = d.toLowerCase() : t === "upper" ? p = d.toUpperCase() : p = d.replace(/(^|\s)(\S)/g, (m, v, b) => v + b.toUpperCase()), o.replaceData(l, a - l, p);
|
|
3820
3852
|
}), this.saveSel(), this.refreshState(), this.onChange();
|
|
3821
3853
|
}
|
|
3822
3854
|
caseItems() {
|
|
@@ -3904,8 +3936,8 @@ let is = (j = class {
|
|
|
3904
3936
|
(s) => {
|
|
3905
3937
|
const n = document.createElement("div");
|
|
3906
3938
|
n.style.cssText = "display:flex;align-items:center;gap:10px;margin:10px 0;min-width:360px";
|
|
3907
|
-
const
|
|
3908
|
-
|
|
3939
|
+
const r = document.createElement("span");
|
|
3940
|
+
r.style.cssText = "width:60px;color:#556;flex:none", r.textContent = this.t("linkurl"), e = document.createElement("input"), e.type = "url", e.placeholder = "https://", e.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", e.value = (t == null ? void 0 : t.getAttribute("href")) || "", n.append(r, e), s.appendChild(n), setTimeout(() => e.focus(), 0);
|
|
3909
3941
|
},
|
|
3910
3942
|
i
|
|
3911
3943
|
);
|
|
@@ -3948,15 +3980,15 @@ let is = (j = class {
|
|
|
3948
3980
|
s.className = "tgrid";
|
|
3949
3981
|
const n = document.createElement("div");
|
|
3950
3982
|
n.className = "tgridlbl", n.textContent = "1 × 1";
|
|
3951
|
-
const
|
|
3952
|
-
for (let
|
|
3953
|
-
for (let
|
|
3983
|
+
const r = [];
|
|
3984
|
+
for (let o = 0; o < 8; o++)
|
|
3985
|
+
for (let l = 0; l < 10; l++) {
|
|
3954
3986
|
const a = document.createElement("span");
|
|
3955
|
-
a.dataset.r = String(
|
|
3956
|
-
|
|
3987
|
+
a.dataset.r = String(o), a.dataset.c = String(l), a.addEventListener("mouseenter", () => {
|
|
3988
|
+
r.forEach((d) => d.classList.toggle("hot", +d.dataset.r <= o && +d.dataset.c <= l)), n.textContent = l + 1 + " × " + (o + 1);
|
|
3957
3989
|
}), a.addEventListener("click", () => {
|
|
3958
|
-
this.closePop(), this.insertTable(
|
|
3959
|
-
}),
|
|
3990
|
+
this.closePop(), this.insertTable(o + 1, l + 1), e == null || e();
|
|
3991
|
+
}), r.push(a), s.appendChild(a);
|
|
3960
3992
|
}
|
|
3961
3993
|
i.append(s, n), t.appendChild(i);
|
|
3962
3994
|
}
|
|
@@ -4041,17 +4073,17 @@ let is = (j = class {
|
|
|
4041
4073
|
}
|
|
4042
4074
|
buildToolbar() {
|
|
4043
4075
|
this.toolbar.innerHTML = "";
|
|
4044
|
-
const t = this.options.toolbar === !0 ?
|
|
4076
|
+
const t = this.options.toolbar === !0 ? ei : this.options.toolbar, e = this.buildToolbarRegistry();
|
|
4045
4077
|
this.parseToolbarString(t).forEach((i) => {
|
|
4046
4078
|
const s = [];
|
|
4047
4079
|
i.forEach((n) => {
|
|
4048
|
-
const
|
|
4049
|
-
if (!
|
|
4080
|
+
const r = e[n];
|
|
4081
|
+
if (!r) {
|
|
4050
4082
|
console.warn(`FableEditor: unknown toolbar item "${n}"`);
|
|
4051
4083
|
return;
|
|
4052
4084
|
}
|
|
4053
|
-
const
|
|
4054
|
-
Array.isArray(
|
|
4085
|
+
const o = r();
|
|
4086
|
+
Array.isArray(o) ? s.push(...o) : s.push(o);
|
|
4055
4087
|
}), s.length && this.toolbar.appendChild(this.group(...s));
|
|
4056
4088
|
}), this.tbrMore = this.tbtn(h.more, this.t("more"), () => {
|
|
4057
4089
|
this.tbrExpanded = !this.tbrExpanded, this.updateToolbarOverflow();
|
|
@@ -4223,7 +4255,7 @@ let is = (j = class {
|
|
|
4223
4255
|
{ label: this.t("deltable"), icon: h.trash, action: () => this.tableOp("deltable") }
|
|
4224
4256
|
],
|
|
4225
4257
|
help: [this.mItem("helpttl", h.helpic, () => this.helpDlg(), "Alt+0")]
|
|
4226
|
-
}, e = this.options.menubar === !0 ?
|
|
4258
|
+
}, e = this.options.menubar === !0 ? ii : this.options.menubar, i = /* @__PURE__ */ new Set();
|
|
4227
4259
|
e.split(/\s+/).filter(Boolean).forEach((s) => {
|
|
4228
4260
|
if (i.has(s)) return;
|
|
4229
4261
|
if (i.add(s), !t[s]) {
|
|
@@ -4231,36 +4263,36 @@ let is = (j = class {
|
|
|
4231
4263
|
return;
|
|
4232
4264
|
}
|
|
4233
4265
|
const n = document.createElement("button");
|
|
4234
|
-
n.type = "button", n.textContent = this.t(s), n.dataset.menuKey = s, n.addEventListener("mousedown", (
|
|
4235
|
-
|
|
4236
|
-
}), n.addEventListener("click", () => this.popup(n, (
|
|
4266
|
+
n.type = "button", n.textContent = this.t(s), n.dataset.menuKey = s, n.addEventListener("mousedown", (r) => {
|
|
4267
|
+
r.preventDefault(), this.saveSel();
|
|
4268
|
+
}), n.addEventListener("click", () => this.popup(n, (r) => this.menuItems(r, t[s]))), this.menubar.appendChild(n);
|
|
4237
4269
|
});
|
|
4238
4270
|
}
|
|
4239
4271
|
/* ---------------------------------------------------------- table ops */
|
|
4240
4272
|
tableOp(t) {
|
|
4241
|
-
var
|
|
4273
|
+
var l, a, d;
|
|
4242
4274
|
this.restoreSel();
|
|
4243
4275
|
const e = window.getSelection();
|
|
4244
4276
|
if (!e) return;
|
|
4245
|
-
const i = ((
|
|
4277
|
+
const i = ((l = this.closestBlock(e.anchorNode)) == null ? void 0 : l.closest("td,th")) || (e.anchorNode && e.anchorNode.nodeType === 1 ? (d = (a = e.anchorNode).closest) == null ? void 0 : d.call(a, "td,th") : null);
|
|
4246
4278
|
if (!i) return;
|
|
4247
|
-
const s = i.parentElement, n = i.closest("table"),
|
|
4279
|
+
const s = i.parentElement, n = i.closest("table"), r = Array.from(s.children).indexOf(i), o = () => {
|
|
4248
4280
|
const p = s.cloneNode(!1);
|
|
4249
4281
|
return Array.from(s.children).forEach((m) => {
|
|
4250
4282
|
const v = document.createElement("td"), b = m.getAttribute("style");
|
|
4251
4283
|
b && v.setAttribute("style", b), v.style.removeProperty("background-color"), v.innerHTML = "<br>", p.appendChild(v);
|
|
4252
4284
|
}), p;
|
|
4253
4285
|
};
|
|
4254
|
-
if (t === "rowabove" && s.before(
|
|
4286
|
+
if (t === "rowabove" && s.before(o()), t === "rowbelow" && s.after(o()), t === "delrow") {
|
|
4255
4287
|
const p = s.parentElement;
|
|
4256
4288
|
s.remove(), p.querySelector("tr") || n.remove();
|
|
4257
4289
|
}
|
|
4258
4290
|
(t === "colbefore" || t === "colafter") && n.querySelectorAll("tr").forEach((p) => {
|
|
4259
|
-
const m = p.children[Math.min(
|
|
4291
|
+
const m = p.children[Math.min(r, p.children.length - 1)], v = document.createElement("td"), b = m.getAttribute("style");
|
|
4260
4292
|
b && v.setAttribute("style", b), v.style.removeProperty("width"), v.style.removeProperty("background-color"), v.innerHTML = "<br>", t === "colbefore" ? m.before(v) : m.after(v);
|
|
4261
4293
|
}), t === "delcol" && (n.querySelectorAll("tr").forEach((p) => {
|
|
4262
4294
|
var m;
|
|
4263
|
-
return (m = p.children[
|
|
4295
|
+
return (m = p.children[r]) == null ? void 0 : m.remove();
|
|
4264
4296
|
}), n.querySelector("td,th") || n.remove()), t === "deltable" && n.remove(), this.onChange(), this.positionTableHandles();
|
|
4265
4297
|
}
|
|
4266
4298
|
/** Reorders the current row/column: 'rowup'/'rowdown' swap the caret's row with
|
|
@@ -4272,24 +4304,24 @@ let is = (j = class {
|
|
|
4272
4304
|
if (!e) return;
|
|
4273
4305
|
const i = e.parentElement, s = e.closest("table"), n = Array.from(i.children).indexOf(e);
|
|
4274
4306
|
if (t === "rowup") {
|
|
4275
|
-
const
|
|
4276
|
-
|
|
4307
|
+
const l = i.previousElementSibling;
|
|
4308
|
+
l && l.before(i);
|
|
4277
4309
|
}
|
|
4278
4310
|
if (t === "rowdown") {
|
|
4279
|
-
const
|
|
4280
|
-
|
|
4311
|
+
const l = i.nextElementSibling;
|
|
4312
|
+
l && l.after(i);
|
|
4281
4313
|
}
|
|
4282
|
-
t === "colleft" && n > 0 && s.querySelectorAll("tr").forEach((
|
|
4283
|
-
const a =
|
|
4314
|
+
t === "colleft" && n > 0 && s.querySelectorAll("tr").forEach((l) => {
|
|
4315
|
+
const a = l.children[n], d = l.children[n - 1];
|
|
4284
4316
|
a && d && d.before(a);
|
|
4285
|
-
}), t === "colright" && s.querySelectorAll("tr").forEach((
|
|
4286
|
-
const a =
|
|
4317
|
+
}), t === "colright" && s.querySelectorAll("tr").forEach((l) => {
|
|
4318
|
+
const a = l.children[n], d = l.children[n + 1];
|
|
4287
4319
|
a && d && d.after(a);
|
|
4288
4320
|
});
|
|
4289
|
-
const
|
|
4290
|
-
|
|
4291
|
-
const
|
|
4292
|
-
|
|
4321
|
+
const r = document.createRange();
|
|
4322
|
+
r.selectNodeContents(e), r.collapse(!0);
|
|
4323
|
+
const o = window.getSelection();
|
|
4324
|
+
o && (o.removeAllRanges(), o.addRange(r)), this.saveSel(), this.onChange(), this.positionTableHandles(), this.positionCellMarker();
|
|
4293
4325
|
}
|
|
4294
4326
|
/** Align the whole table via auto margins — same semantics as the align
|
|
4295
4327
|
* field in the table-properties dialog. */
|
|
@@ -4326,26 +4358,26 @@ let is = (j = class {
|
|
|
4326
4358
|
tablePropsDlg() {
|
|
4327
4359
|
const t = this.tblActive;
|
|
4328
4360
|
if (!t) return;
|
|
4329
|
-
let e, i, s, n,
|
|
4330
|
-
const
|
|
4361
|
+
let e, i, s, n, r;
|
|
4362
|
+
const o = "display:flex;align-items:center;gap:10px;margin:10px 0", l = "width:120px;color:#556;flex:none", a = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit", d = t.querySelector("td,th"), p = t.style.width || "", m = d && d.style.padding ? parseFloat(d.style.padding) : "", v = t.style.borderSpacing ? parseFloat(t.style.borderSpacing) : "", b = t.style.borderWidth ? parseFloat(t.style.borderWidth) : "", f = t.style.marginLeft, y = t.style.marginRight, C = f === "auto" && y === "auto" ? "center" : f === "auto" ? "right" : y === "auto" && f === "0" ? "left" : "";
|
|
4331
4363
|
this.dialog(
|
|
4332
4364
|
this.t("tablepropsttl"),
|
|
4333
4365
|
(E) => {
|
|
4334
4366
|
const I = (A, $) => {
|
|
4335
|
-
const
|
|
4336
|
-
|
|
4337
|
-
const
|
|
4338
|
-
|
|
4367
|
+
const F = document.createElement("div");
|
|
4368
|
+
F.style.cssText = o;
|
|
4369
|
+
const Z = document.createElement("span");
|
|
4370
|
+
Z.style.cssText = l, Z.textContent = this.t(A), F.append(Z, $), E.appendChild(F);
|
|
4339
4371
|
};
|
|
4340
|
-
e = document.createElement("input"), e.type = "text", e.style.cssText = a, e.placeholder = "e.g. 600px or 100%", e.value = p, I("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = a, i.value = String(m), I("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = a, s.value = String(v), I("tblcellspacing", s), n = document.createElement("input"), n.type = "number", n.min = "0", n.style.cssText = a, n.value = String(b), I("tblborder", n),
|
|
4372
|
+
e = document.createElement("input"), e.type = "text", e.style.cssText = a, e.placeholder = "e.g. 600px or 100%", e.value = p, I("tblwidth", e), i = document.createElement("input"), i.type = "number", i.min = "0", i.style.cssText = a, i.value = String(m), I("tblcellpadding", i), s = document.createElement("input"), s.type = "number", s.min = "0", s.style.cssText = a, s.value = String(v), I("tblcellspacing", s), n = document.createElement("input"), n.type = "number", n.min = "0", n.style.cssText = a, n.value = String(b), I("tblborder", n), r = document.createElement("select"), r.style.cssText = a, [
|
|
4341
4373
|
["", "alignnone"],
|
|
4342
4374
|
["left", "alignleft"],
|
|
4343
4375
|
["center", "aligncenter"],
|
|
4344
4376
|
["right", "alignright"]
|
|
4345
4377
|
].forEach(([A, $]) => {
|
|
4346
|
-
const
|
|
4347
|
-
|
|
4348
|
-
}), I("tblalign",
|
|
4378
|
+
const F = document.createElement("option");
|
|
4379
|
+
F.value = A, F.textContent = this.t($), A === C && (F.selected = !0), r.appendChild(F);
|
|
4380
|
+
}), I("tblalign", r);
|
|
4349
4381
|
},
|
|
4350
4382
|
[
|
|
4351
4383
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -4358,7 +4390,7 @@ let is = (j = class {
|
|
|
4358
4390
|
cellpadding: i.value.trim(),
|
|
4359
4391
|
cellspacing: s.value.trim(),
|
|
4360
4392
|
border: n.value.trim(),
|
|
4361
|
-
align:
|
|
4393
|
+
align: r.value
|
|
4362
4394
|
}), this.closeDlg(), this.onChange(), this.positionTableHandles();
|
|
4363
4395
|
}
|
|
4364
4396
|
}
|
|
@@ -4397,8 +4429,8 @@ let is = (j = class {
|
|
|
4397
4429
|
formSelect(t, e) {
|
|
4398
4430
|
const i = document.createElement("select");
|
|
4399
4431
|
return i.style.cssText = "flex:1;border:1px solid #cfd6df;border-radius:6px;padding:7px 9px;font:14px inherit;background:#fff", t.forEach(([s, n]) => {
|
|
4400
|
-
const
|
|
4401
|
-
|
|
4432
|
+
const r = document.createElement("option");
|
|
4433
|
+
r.value = s, r.textContent = n, s === e && (r.selected = !0), i.appendChild(r);
|
|
4402
4434
|
}), i;
|
|
4403
4435
|
}
|
|
4404
4436
|
formBg(t) {
|
|
@@ -4408,8 +4440,8 @@ let is = (j = class {
|
|
|
4408
4440
|
s.type = "color", s.value = i || "#ffffff", s.style.cssText = "width:36px;height:29px;border:1px solid #cfd6df;border-radius:4px;padding:1px;background:none;cursor:pointer";
|
|
4409
4441
|
const n = document.createElement("label");
|
|
4410
4442
|
n.style.cssText = "display:flex;align-items:center;gap:6px;cursor:pointer;color:#556";
|
|
4411
|
-
const
|
|
4412
|
-
return
|
|
4443
|
+
const r = document.createElement("input");
|
|
4444
|
+
return r.type = "checkbox", r.checked = !!i, n.append(r, document.createTextNode(this.t("fill"))), s.addEventListener("input", () => r.checked = !0), e.append(s, n), { wrap: e, color: s, fill: r };
|
|
4413
4445
|
}
|
|
4414
4446
|
setOrClear(t, e, i) {
|
|
4415
4447
|
i ? t.style.setProperty(e, /^(width|height)$/.test(e) && /^\d+$/.test(i) ? i + "px" : i) : t.style.removeProperty(e);
|
|
@@ -4420,11 +4452,11 @@ let is = (j = class {
|
|
|
4420
4452
|
alert(this.t("nocell"));
|
|
4421
4453
|
return;
|
|
4422
4454
|
}
|
|
4423
|
-
let e, i, s, n,
|
|
4455
|
+
let e, i, s, n, r;
|
|
4424
4456
|
this.dialog(
|
|
4425
4457
|
this.t("cellprops").replace("…", ""),
|
|
4426
|
-
(
|
|
4427
|
-
e = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(
|
|
4458
|
+
(o) => {
|
|
4459
|
+
e = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(o, this.t("tblwidth"), e), i = this.formInput(t.style.height, "e.g. 40px"), this.formRow(o, this.t("tblheight"), i), s = this.formSelect(
|
|
4428
4460
|
[
|
|
4429
4461
|
["", this.t("alignnone")],
|
|
4430
4462
|
["left", this.t("alignleft")],
|
|
@@ -4432,7 +4464,7 @@ let is = (j = class {
|
|
|
4432
4464
|
["right", this.t("alignright")]
|
|
4433
4465
|
],
|
|
4434
4466
|
t.style.textAlign || ""
|
|
4435
|
-
), this.formRow(
|
|
4467
|
+
), this.formRow(o, this.t("tblalign"), s), n = this.formSelect(
|
|
4436
4468
|
[
|
|
4437
4469
|
["", this.t("alignnone")],
|
|
4438
4470
|
["top", this.t("valigntop")],
|
|
@@ -4440,7 +4472,7 @@ let is = (j = class {
|
|
|
4440
4472
|
["bottom", this.t("valignbottom")]
|
|
4441
4473
|
],
|
|
4442
4474
|
t.style.verticalAlign || ""
|
|
4443
|
-
), this.formRow(
|
|
4475
|
+
), this.formRow(o, this.t("valign"), n), r = this.formBg(t.style.backgroundColor || ""), this.formRow(o, this.t("backcolor"), r.wrap);
|
|
4444
4476
|
},
|
|
4445
4477
|
[
|
|
4446
4478
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -4448,7 +4480,7 @@ let is = (j = class {
|
|
|
4448
4480
|
label: this.t("save"),
|
|
4449
4481
|
primary: !0,
|
|
4450
4482
|
action: () => {
|
|
4451
|
-
this.setOrClear(t, "width", e.value.trim()), this.setOrClear(t, "height", i.value.trim()), this.setOrClear(t, "text-align", s.value), this.setOrClear(t, "vertical-align", n.value), this.setOrClear(t, "background-color",
|
|
4483
|
+
this.setOrClear(t, "width", e.value.trim()), this.setOrClear(t, "height", i.value.trim()), this.setOrClear(t, "text-align", s.value), this.setOrClear(t, "vertical-align", n.value), this.setOrClear(t, "background-color", r.fill.checked ? r.color.value : ""), this.closeDlg(), this.onChange(), this.positionTableHandles();
|
|
4452
4484
|
}
|
|
4453
4485
|
}
|
|
4454
4486
|
]
|
|
@@ -4485,12 +4517,12 @@ let is = (j = class {
|
|
|
4485
4517
|
alert(this.t("nocell"));
|
|
4486
4518
|
return;
|
|
4487
4519
|
}
|
|
4488
|
-
const e = t.parentElement, i = t.closest("table"), s = Array.from(e.children).indexOf(t), n = Array.from(i.rows).map((
|
|
4489
|
-
let
|
|
4520
|
+
const e = t.parentElement, i = t.closest("table"), s = Array.from(e.children).indexOf(t), n = Array.from(i.rows).map((l) => l.cells[s]).filter(Boolean);
|
|
4521
|
+
let r, o;
|
|
4490
4522
|
this.dialog(
|
|
4491
4523
|
this.t("colprops").replace("…", ""),
|
|
4492
|
-
(
|
|
4493
|
-
|
|
4524
|
+
(l) => {
|
|
4525
|
+
r = this.formInput(t.style.width, "e.g. 120px / 25%"), this.formRow(l, this.t("tblwidth"), r), o = this.formBg(t.style.backgroundColor || ""), this.formRow(l, this.t("backcolor"), o.wrap);
|
|
4494
4526
|
},
|
|
4495
4527
|
[
|
|
4496
4528
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -4498,8 +4530,8 @@ let is = (j = class {
|
|
|
4498
4530
|
label: this.t("save"),
|
|
4499
4531
|
primary: !0,
|
|
4500
4532
|
action: () => {
|
|
4501
|
-
n.forEach((
|
|
4502
|
-
this.setOrClear(
|
|
4533
|
+
n.forEach((l) => {
|
|
4534
|
+
this.setOrClear(l, "width", r.value.trim()), this.setOrClear(l, "background-color", o.fill.checked ? o.color.value : "");
|
|
4503
4535
|
}), this.closeDlg(), this.onChange(), this.positionTableHandles();
|
|
4504
4536
|
}
|
|
4505
4537
|
}
|
|
@@ -4515,8 +4547,8 @@ let is = (j = class {
|
|
|
4515
4547
|
const s = document.createElement("div");
|
|
4516
4548
|
s.className = "dlg", s.dir = this.dir(), s.innerHTML = `<header><span>${t}</span><button type="button">×</button></header>
|
|
4517
4549
|
<div class="body"></div><footer></footer>`, s.querySelector("header button").onclick = () => this.closeDlg(), e(s.querySelector(".body")), (i || [{ label: this.t("close"), primary: !0, action: () => this.closeDlg() }]).forEach((n) => {
|
|
4518
|
-
const
|
|
4519
|
-
|
|
4550
|
+
const r = document.createElement("button");
|
|
4551
|
+
r.type = "button", r.textContent = n.label, n.primary && (r.className = "pri"), r.onclick = n.action, s.querySelector("footer").appendChild(r);
|
|
4520
4552
|
}), this.dlgOvl.appendChild(s), this.dlgOvl.addEventListener("mousedown", (n) => {
|
|
4521
4553
|
n.target === this.dlgOvl && this.closeDlg();
|
|
4522
4554
|
}), document.body.appendChild(this.dlgOvl);
|
|
@@ -4571,7 +4603,7 @@ let is = (j = class {
|
|
|
4571
4603
|
const e = document.createElement("div");
|
|
4572
4604
|
e.className = "pv-box";
|
|
4573
4605
|
const i = this.contentWidth();
|
|
4574
|
-
e.style.cssText = `width:${i > 0 ? Math.round(i) : 640}px;max-width:100%;max-height:52vh;overflow:auto;border:1px solid #e3e3e3;border-radius:6px;padding:14px;font-family:Helvetica,Arial,sans-serif;font-size:14px`, e.innerHTML = this.ed.innerHTML, t.appendChild(e);
|
|
4606
|
+
e.style.cssText = `width:${i > 0 ? Math.round(i) : 640}px;max-width:100%;max-height:52vh;overflow:auto;box-sizing:content-box;border:1px solid #e3e3e3;border-radius:6px;padding:14px;font-family:Helvetica,Arial,sans-serif;font-size:14px`, e.innerHTML = this.ed.innerHTML, t.appendChild(e);
|
|
4575
4607
|
});
|
|
4576
4608
|
}
|
|
4577
4609
|
/** Two-pane picker shared by the special-character map and the emoji map:
|
|
@@ -4580,31 +4612,31 @@ let is = (j = class {
|
|
|
4580
4612
|
this.saveSel(), this.dialog(t, (s) => {
|
|
4581
4613
|
const n = document.createElement("div");
|
|
4582
4614
|
n.className = "chmap";
|
|
4583
|
-
const l = document.createElement("div");
|
|
4584
|
-
l.className = "chtabs";
|
|
4585
4615
|
const r = document.createElement("div");
|
|
4586
|
-
r.className = "
|
|
4616
|
+
r.className = "chtabs";
|
|
4587
4617
|
const o = document.createElement("div");
|
|
4588
|
-
o.className = "
|
|
4618
|
+
o.className = "chpanel";
|
|
4619
|
+
const l = document.createElement("div");
|
|
4620
|
+
l.className = "chgrid" + (i ? " emgrid" : ""), o.appendChild(l);
|
|
4589
4621
|
const a = (d) => {
|
|
4590
|
-
|
|
4622
|
+
r.querySelectorAll("button").forEach((p, m) => p.classList.toggle("on", m === d)), l.innerHTML = "", e[d].chars.forEach((p) => {
|
|
4591
4623
|
const m = document.createElement("button");
|
|
4592
4624
|
m.type = "button", m.textContent = p, m.onclick = () => {
|
|
4593
4625
|
this.closeDlg(), this.exec("insertText", p);
|
|
4594
|
-
},
|
|
4595
|
-
}),
|
|
4626
|
+
}, l.appendChild(m);
|
|
4627
|
+
}), o.scrollTop = 0;
|
|
4596
4628
|
};
|
|
4597
4629
|
e.forEach((d, p) => {
|
|
4598
4630
|
const m = document.createElement("button");
|
|
4599
|
-
m.type = "button", m.textContent = this.t(d.key), m.addEventListener("click", () => a(p)),
|
|
4600
|
-
}), n.append(
|
|
4631
|
+
m.type = "button", m.textContent = this.t(d.key), m.addEventListener("click", () => a(p)), r.appendChild(m);
|
|
4632
|
+
}), n.append(r, o), s.appendChild(n), a(0);
|
|
4601
4633
|
});
|
|
4602
4634
|
}
|
|
4603
4635
|
charMap() {
|
|
4604
|
-
this.glyphPickerDlg(this.t("charmap").replace("…", ""),
|
|
4636
|
+
this.glyphPickerDlg(this.t("charmap").replace("…", ""), ci, !1);
|
|
4605
4637
|
}
|
|
4606
4638
|
emojiMap() {
|
|
4607
|
-
this.glyphPickerDlg(this.t("emoji").replace("…", ""),
|
|
4639
|
+
this.glyphPickerDlg(this.t("emoji").replace("…", ""), hi, !0);
|
|
4608
4640
|
}
|
|
4609
4641
|
printDoc() {
|
|
4610
4642
|
const t = window.open("", "_blank");
|
|
@@ -4666,17 +4698,17 @@ let is = (j = class {
|
|
|
4666
4698
|
const i = document.createElement("button");
|
|
4667
4699
|
i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertimg");
|
|
4668
4700
|
const s = () => {
|
|
4669
|
-
const n = e.value.trim(),
|
|
4670
|
-
if (!
|
|
4701
|
+
const n = e.value.trim(), r = this.phActive;
|
|
4702
|
+
if (!r) return;
|
|
4671
4703
|
if (!/^(https?:|data:image\/|blob:)/i.test(n)) {
|
|
4672
4704
|
e.classList.add("err"), e.focus();
|
|
4673
4705
|
return;
|
|
4674
4706
|
}
|
|
4675
4707
|
i.disabled = !0, e.disabled = !0;
|
|
4676
|
-
const
|
|
4677
|
-
|
|
4708
|
+
const o = new Image();
|
|
4709
|
+
o.onload = () => this.replacePlaceholderWithImage(r, n, ""), o.onerror = () => {
|
|
4678
4710
|
i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
|
|
4679
|
-
},
|
|
4711
|
+
}, o.src = n;
|
|
4680
4712
|
};
|
|
4681
4713
|
i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (n) => {
|
|
4682
4714
|
n.key === "Enter" ? (n.preventDefault(), s()) : n.key === "Escape" && (n.stopPropagation(), this.renderPhCtxButtons());
|
|
@@ -4702,8 +4734,8 @@ let is = (j = class {
|
|
|
4702
4734
|
s && (s.textContent = this.t("uploading")), this.imageUploadHandler(t).then((n) => {
|
|
4703
4735
|
this.ed.contains(e) && this.replacePlaceholderWithImage(e, n, i);
|
|
4704
4736
|
}).catch((n) => {
|
|
4705
|
-
var
|
|
4706
|
-
this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (
|
|
4737
|
+
var r;
|
|
4738
|
+
this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (r = this.onImageUploadError) == null || r.call(this, n, t));
|
|
4707
4739
|
});
|
|
4708
4740
|
}
|
|
4709
4741
|
replacePlaceholderWithImage(t, e, i) {
|
|
@@ -4741,8 +4773,8 @@ let is = (j = class {
|
|
|
4741
4773
|
if (!this.ed.contains(t) || t.closest(".tpl-media") || t.getAttribute("width") || t.getAttribute("height") || t.style.width || t.style.height) return i(!1);
|
|
4742
4774
|
const n = t.naturalWidth;
|
|
4743
4775
|
if (!n) return i(!1);
|
|
4744
|
-
const
|
|
4745
|
-
t.setAttribute("width", String(
|
|
4776
|
+
const r = this.contentWidth(), o = Math.round(r > 0 ? Math.min(n, r) : n);
|
|
4777
|
+
t.setAttribute("width", String(o)), t.style.width = o + "px", t.style.height = "auto", i(!0);
|
|
4746
4778
|
};
|
|
4747
4779
|
t.complete && t.naturalWidth ? s() : (t.addEventListener("load", s, { once: !0 }), t.addEventListener("error", () => i(!1), { once: !0 }));
|
|
4748
4780
|
}
|
|
@@ -4817,22 +4849,22 @@ let is = (j = class {
|
|
|
4817
4849
|
const i = document.createElement("button");
|
|
4818
4850
|
i.type = "button", i.className = "txtbtn", i.textContent = this.t("insertvideo");
|
|
4819
4851
|
const s = () => {
|
|
4820
|
-
const n = e.value.trim(),
|
|
4821
|
-
if (!
|
|
4852
|
+
const n = e.value.trim(), r = this.vphActive;
|
|
4853
|
+
if (!r) return;
|
|
4822
4854
|
if (!/^(https?:|data:video\/|blob:)/i.test(n)) {
|
|
4823
4855
|
e.classList.add("err"), e.focus();
|
|
4824
4856
|
return;
|
|
4825
4857
|
}
|
|
4826
|
-
const
|
|
4827
|
-
if (
|
|
4828
|
-
this.replacePlaceholderWithEmbed(
|
|
4858
|
+
const o = this.videoEmbedUrl(n);
|
|
4859
|
+
if (o) {
|
|
4860
|
+
this.replacePlaceholderWithEmbed(r, o);
|
|
4829
4861
|
return;
|
|
4830
4862
|
}
|
|
4831
4863
|
i.disabled = !0, e.disabled = !0;
|
|
4832
|
-
const
|
|
4833
|
-
|
|
4864
|
+
const l = document.createElement("video");
|
|
4865
|
+
l.preload = "metadata", l.onloadedmetadata = () => this.replacePlaceholderWithVideo(r, n, ""), l.onerror = () => {
|
|
4834
4866
|
i.disabled = !1, e.disabled = !1, e.classList.add("err"), e.focus();
|
|
4835
|
-
},
|
|
4867
|
+
}, l.src = n;
|
|
4836
4868
|
};
|
|
4837
4869
|
i.addEventListener("click", s), e.addEventListener("input", () => e.classList.remove("err")), e.addEventListener("keydown", (n) => {
|
|
4838
4870
|
n.key === "Enter" ? (n.preventDefault(), s()) : n.key === "Escape" && (n.stopPropagation(), this.renderVphCtxButtons());
|
|
@@ -4858,8 +4890,8 @@ let is = (j = class {
|
|
|
4858
4890
|
s && (s.textContent = this.t("uploading")), this.videoUploadHandler(t).then((n) => {
|
|
4859
4891
|
this.ed.contains(e) && this.replacePlaceholderWithVideo(e, n, i);
|
|
4860
4892
|
}).catch((n) => {
|
|
4861
|
-
var
|
|
4862
|
-
this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (
|
|
4893
|
+
var r;
|
|
4894
|
+
this.ed.contains(e) && (e.classList.remove("uploading"), e.classList.add("upload-error"), s && (s.textContent = this.t("uploadfailed")), (r = this.onVideoUploadError) == null || r.call(this, n, t));
|
|
4863
4895
|
});
|
|
4864
4896
|
}
|
|
4865
4897
|
replacePlaceholderWithVideo(t, e, i) {
|
|
@@ -4903,16 +4935,16 @@ let is = (j = class {
|
|
|
4903
4935
|
(d = this.vidCtx) == null || d.replaceWith(a), this.vidCtx = a, this.positionVidCtx();
|
|
4904
4936
|
}, s = (a) => {
|
|
4905
4937
|
this.setVideoAlign(t, a), i();
|
|
4906
|
-
}, n = t.style.float === "left",
|
|
4938
|
+
}, n = t.style.float === "left", r = t.style.float === "right", o = !n && !r && t.style.marginLeft === "auto" && t.style.marginRight === "auto", l = (a, d, p, m) => {
|
|
4907
4939
|
const v = this.ctxBtn(a, d, m);
|
|
4908
4940
|
return v.classList.toggle("on", p), v;
|
|
4909
4941
|
};
|
|
4910
4942
|
return e.append(
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4943
|
+
l(h.alignleft, this.t("alignleft"), n, () => s("left")),
|
|
4944
|
+
l(h.aligncenter, this.t("aligncenter"), o, () => s("center")),
|
|
4945
|
+
l(h.alignright, this.t("alignright"), r, () => s("right")),
|
|
4914
4946
|
this.ctxSep(),
|
|
4915
|
-
|
|
4947
|
+
l(h.trash, this.t("deletevideo"), !1, () => {
|
|
4916
4948
|
t.remove(), this.clearVidHandles(), this.onChange();
|
|
4917
4949
|
})
|
|
4918
4950
|
), e.addEventListener("mousedown", (a) => a.preventDefault()), e.addEventListener("mouseenter", () => this.cancelVidHide()), e.addEventListener("mouseleave", () => {
|
|
@@ -4952,13 +4984,13 @@ let is = (j = class {
|
|
|
4952
4984
|
* (videoUploadHandler when configured, else inline base64). */
|
|
4953
4985
|
videoDlg() {
|
|
4954
4986
|
this.saveSel();
|
|
4955
|
-
let t, e, i, s, n,
|
|
4956
|
-
const
|
|
4987
|
+
let t, e, i, s, n, r;
|
|
4988
|
+
const o = (a, d) => {
|
|
4957
4989
|
const p = document.createElement("div");
|
|
4958
4990
|
p.className = "dfield";
|
|
4959
4991
|
const m = document.createElement("label");
|
|
4960
4992
|
return m.textContent = this.t(a), p.append(m, d), p;
|
|
4961
|
-
},
|
|
4993
|
+
}, l = () => {
|
|
4962
4994
|
const a = document.createElement("input");
|
|
4963
4995
|
return a.type = "url", a;
|
|
4964
4996
|
};
|
|
@@ -4978,7 +5010,7 @@ let is = (j = class {
|
|
|
4978
5010
|
d.querySelectorAll("button").forEach((y, C) => y.classList.toggle("on", C === f)), p.forEach((y, C) => y.style.display = C === f ? "" : "none");
|
|
4979
5011
|
};
|
|
4980
5012
|
m("vidgeneral", (f) => {
|
|
4981
|
-
t =
|
|
5013
|
+
t = l(), t.placeholder = this.t("videourlph");
|
|
4982
5014
|
const y = document.createElement("div");
|
|
4983
5015
|
y.className = "drow";
|
|
4984
5016
|
const C = document.createElement("button");
|
|
@@ -4987,30 +5019,30 @@ let is = (j = class {
|
|
|
4987
5019
|
E.type = "file", E.accept = this.options.videoFileTypes.join(","), E.style.display = "none", C.addEventListener("click", () => {
|
|
4988
5020
|
E.value = "", E.click();
|
|
4989
5021
|
}), E.addEventListener("change", () => {
|
|
4990
|
-
var
|
|
4991
|
-
const A = (
|
|
5022
|
+
var F;
|
|
5023
|
+
const A = (F = E.files) == null ? void 0 : F[0];
|
|
4992
5024
|
if (!A) return;
|
|
4993
5025
|
C.disabled = !0, C.textContent = this.t("uploading");
|
|
4994
|
-
const $ = (
|
|
4995
|
-
t.value =
|
|
5026
|
+
const $ = (Z) => {
|
|
5027
|
+
t.value = Z, C.disabled = !1, C.textContent = this.t("uploadvideo");
|
|
4996
5028
|
};
|
|
4997
5029
|
if (this.videoUploadHandler)
|
|
4998
|
-
this.videoUploadHandler(A).then($).catch((
|
|
5030
|
+
this.videoUploadHandler(A).then($).catch((Z) => {
|
|
4999
5031
|
var et;
|
|
5000
|
-
C.disabled = !1, C.textContent = this.t("uploadfailed"), (et = this.onVideoUploadError) == null || et.call(this,
|
|
5032
|
+
C.disabled = !1, C.textContent = this.t("uploadfailed"), (et = this.onVideoUploadError) == null || et.call(this, Z, A);
|
|
5001
5033
|
});
|
|
5002
5034
|
else {
|
|
5003
|
-
const
|
|
5004
|
-
|
|
5035
|
+
const Z = new FileReader();
|
|
5036
|
+
Z.onload = () => $(Z.result), Z.readAsDataURL(A);
|
|
5005
5037
|
}
|
|
5006
|
-
}), y.append(t, C, E), t.style.flex = "1", f.appendChild(
|
|
5038
|
+
}), y.append(t, C, E), t.style.flex = "1", f.appendChild(o("vidsource", y));
|
|
5007
5039
|
const I = document.createElement("div");
|
|
5008
|
-
I.className = "drow", e = document.createElement("input"), e.type = "number", e.value = "560", i = document.createElement("input"), i.type = "number", i.value = "314", I.append(
|
|
5040
|
+
I.className = "drow", e = document.createElement("input"), e.type = "number", e.value = "560", i = document.createElement("input"), i.type = "number", i.value = "314", I.append(o("tblwidth", e), o("tblheight", i)), f.appendChild(I);
|
|
5009
5041
|
}), m("vidembed", (f) => {
|
|
5010
5042
|
const y = document.createElement("p");
|
|
5011
5043
|
y.textContent = this.t("vidembedhint"), y.style.cssText = "margin:0 0 8px;color:#556;font-size:13.5px", s = document.createElement("textarea"), s.style.cssText = "width:100%;box-sizing:border-box;height:160px", f.append(y, s);
|
|
5012
5044
|
}), m("vidadvanced", (f) => {
|
|
5013
|
-
n =
|
|
5045
|
+
n = l(), r = l(), f.append(o("vidaltsource", n), o("vidposter", r));
|
|
5014
5046
|
});
|
|
5015
5047
|
const b = document.createElement("div");
|
|
5016
5048
|
b.className = "dtabbody", p.forEach((f) => b.appendChild(f)), a.append(d, b), v(0), setTimeout(() => t.focus(), 0);
|
|
@@ -5031,7 +5063,7 @@ let is = (j = class {
|
|
|
5031
5063
|
if (v)
|
|
5032
5064
|
document.execCommand("insertHTML", !1, this.videoEmbedHTML(v, p, m));
|
|
5033
5065
|
else {
|
|
5034
|
-
const b = n.value.trim(), f =
|
|
5066
|
+
const b = n.value.trim(), f = r.value.trim();
|
|
5035
5067
|
document.execCommand(
|
|
5036
5068
|
"insertHTML",
|
|
5037
5069
|
!1,
|
|
@@ -5093,42 +5125,42 @@ let is = (j = class {
|
|
|
5093
5125
|
if (i.nodeType !== Node.TEXT_NODE || !this.ed.contains(i) || (d = i.parentElement) != null && d.closest("code, pre")) return;
|
|
5094
5126
|
const n = (i.textContent || "").slice(0, e.anchorOffset).match(/(?:^|[^`])`([^`]+)$/);
|
|
5095
5127
|
if (!n) return;
|
|
5096
|
-
const
|
|
5097
|
-
if (/^\s|\s$/.test(
|
|
5128
|
+
const r = n[1];
|
|
5129
|
+
if (/^\s|\s$/.test(r)) return;
|
|
5098
5130
|
t.preventDefault();
|
|
5099
|
-
const
|
|
5100
|
-
|
|
5101
|
-
const
|
|
5102
|
-
|
|
5131
|
+
const o = document.createRange();
|
|
5132
|
+
o.setStart(i, e.anchorOffset - r.length - 1), o.setEnd(i, e.anchorOffset), o.deleteContents();
|
|
5133
|
+
const l = document.createElement("code");
|
|
5134
|
+
l.textContent = r, o.insertNode(l);
|
|
5103
5135
|
const a = document.createRange();
|
|
5104
|
-
a.setStartAfter(
|
|
5136
|
+
a.setStartAfter(l), a.collapse(!0), e.removeAllRanges(), e.addRange(a), this.saveSel(), this.onChange();
|
|
5105
5137
|
}
|
|
5106
5138
|
/** Custom dropdown for dialog fields (a native <select> popup can't be styled):
|
|
5107
5139
|
* a field-styled button showing the current choice that opens a floating,
|
|
5108
5140
|
* scrollable option list. Read the current choice via `.value()`. */
|
|
5109
5141
|
dlgSelect(t, e) {
|
|
5110
|
-
var
|
|
5142
|
+
var l;
|
|
5111
5143
|
let i = e;
|
|
5112
5144
|
const s = document.createElement("div");
|
|
5113
5145
|
s.className = "dsel";
|
|
5114
5146
|
const n = document.createElement("button");
|
|
5115
5147
|
n.type = "button", n.className = "dsel-btn";
|
|
5116
|
-
const
|
|
5117
|
-
|
|
5118
|
-
const
|
|
5119
|
-
return
|
|
5148
|
+
const r = document.createElement("span");
|
|
5149
|
+
r.className = "lbl", r.textContent = ((l = t.find(([a]) => a === e)) == null ? void 0 : l[1]) || "", n.append(r), n.insertAdjacentHTML("beforeend", h.chev);
|
|
5150
|
+
const o = document.createElement("div");
|
|
5151
|
+
return o.className = "dsel-list", t.forEach(([a, d]) => {
|
|
5120
5152
|
const p = document.createElement("button");
|
|
5121
5153
|
p.type = "button", p.textContent = d, p.classList.toggle("on", a === i), p.addEventListener("click", () => {
|
|
5122
|
-
i = a,
|
|
5123
|
-
}),
|
|
5154
|
+
i = a, r.textContent = d, o.querySelectorAll("button").forEach((m) => m.classList.toggle("on", m === p)), s.classList.remove("open"), n.focus();
|
|
5155
|
+
}), o.appendChild(p);
|
|
5124
5156
|
}), n.addEventListener("click", () => {
|
|
5125
5157
|
var a;
|
|
5126
|
-
s.classList.toggle("open"), s.classList.contains("open") && ((a =
|
|
5158
|
+
s.classList.toggle("open"), s.classList.contains("open") && ((a = o.querySelector(".on")) == null || a.scrollIntoView({ block: "nearest" }));
|
|
5127
5159
|
}), s.addEventListener("focusout", (a) => {
|
|
5128
5160
|
s.contains(a.relatedTarget) || s.classList.remove("open");
|
|
5129
5161
|
}), s.addEventListener("keydown", (a) => {
|
|
5130
5162
|
a.key === "Escape" && s.classList.contains("open") && (a.stopPropagation(), s.classList.remove("open"), n.focus());
|
|
5131
|
-
}), s.append(n,
|
|
5163
|
+
}), s.append(n, o), { el: s, value: () => i };
|
|
5132
5164
|
}
|
|
5133
5165
|
/** Insert/edit-code-sample dialog: language dropdown + monospace textarea to
|
|
5134
5166
|
* paste or type code into. Inserts a non-editable <pre class="code-block">
|
|
@@ -5139,11 +5171,11 @@ let is = (j = class {
|
|
|
5139
5171
|
this.dialog(
|
|
5140
5172
|
this.t("codedlgttl"),
|
|
5141
5173
|
(s) => {
|
|
5142
|
-
var
|
|
5174
|
+
var o;
|
|
5143
5175
|
const n = document.createElement("div");
|
|
5144
5176
|
n.className = "dfield";
|
|
5145
|
-
const
|
|
5146
|
-
|
|
5177
|
+
const r = document.createElement("label");
|
|
5178
|
+
r.textContent = this.t("codelang"), e = this.dlgSelect(ne, (t == null ? void 0 : t.dataset.lang) || "plain"), n.append(r, e.el), i = document.createElement("textarea"), i.className = "code-input", i.spellcheck = !1, i.value = ((o = t == null ? void 0 : t.querySelector("code")) == null ? void 0 : o.textContent) || "", i.placeholder = "const answer = 42;", s.append(n, i), setTimeout(() => i.focus(), 0);
|
|
5147
5179
|
},
|
|
5148
5180
|
[
|
|
5149
5181
|
{ label: this.t("cancel"), action: () => this.closeDlg() },
|
|
@@ -5151,19 +5183,19 @@ let is = (j = class {
|
|
|
5151
5183
|
label: this.t("save"),
|
|
5152
5184
|
primary: !0,
|
|
5153
5185
|
action: () => {
|
|
5154
|
-
var
|
|
5155
|
-
const s = i.value.replace(/\s+$/, ""), n = e.value(),
|
|
5186
|
+
var o;
|
|
5187
|
+
const s = i.value.replace(/\s+$/, ""), n = e.value(), r = ((o = ne.find(([l]) => l === n)) == null ? void 0 : o[1]) || n;
|
|
5156
5188
|
if (this.closeDlg(), !!s.trim()) {
|
|
5157
5189
|
if (t) {
|
|
5158
|
-
t.dataset.lang = n, t.setAttribute("data-lang-label",
|
|
5159
|
-
const
|
|
5160
|
-
|
|
5190
|
+
t.dataset.lang = n, t.setAttribute("data-lang-label", r);
|
|
5191
|
+
const l = t.querySelector("code") || t;
|
|
5192
|
+
l.textContent = s, this.clearCodeSel(), this.onChange();
|
|
5161
5193
|
return;
|
|
5162
5194
|
}
|
|
5163
5195
|
this.restoreSel(), document.execCommand(
|
|
5164
5196
|
"insertHTML",
|
|
5165
5197
|
!1,
|
|
5166
|
-
`<pre class="code-block" contenteditable="false" data-lang="${n}" data-lang-label="${this.escapeAttr(
|
|
5198
|
+
`<pre class="code-block" contenteditable="false" data-lang="${n}" data-lang-label="${this.escapeAttr(r)}"><code>${this.escHtml(s)}</code></pre><p><br></p>`
|
|
5167
5199
|
), this.onChange();
|
|
5168
5200
|
}
|
|
5169
5201
|
}
|
|
@@ -5220,8 +5252,8 @@ let is = (j = class {
|
|
|
5220
5252
|
/** Miniature div-based mockup of a layout, mirroring what the block looks
|
|
5221
5253
|
like in the editor: grey box = image slot, bars = heading/paragraph. */
|
|
5222
5254
|
tplPreviewHTML(t) {
|
|
5223
|
-
const e = '<span class="pv-img"></span>', i = '<span class="pv-h"></span>', s = (
|
|
5224
|
-
return t === "img-left" ? `<span class="pv">${
|
|
5255
|
+
const e = '<span class="pv-img"></span>', i = '<span class="pv-h"></span>', s = (l) => `<span class="pv-l" style="width:${l}%"></span>`, n = (l) => `<span class="pv-col">${l}</span>`, r = (l) => `<span class="pv-row">${l}</span>`, o = n(i + s(100) + s(88));
|
|
5256
|
+
return t === "img-left" ? `<span class="pv">${r(e + o)}${s(100)}${s(72)}</span>` : t === "img-right" ? `<span class="pv">${r(o + e)}${s(100)}${s(72)}</span>` : t === "img-top" ? `<span class="pv pv-c">${e}${i}${s(100)}${s(72)}</span>` : `<span class="pv pv-c">${i}${s(100)}${s(72)}${e}</span>`;
|
|
5225
5257
|
}
|
|
5226
5258
|
buildTemplatePickInto(t, e) {
|
|
5227
5259
|
const i = document.createElement("div");
|
|
@@ -5247,7 +5279,7 @@ let is = (j = class {
|
|
|
5247
5279
|
renderTplCtxButtons() {
|
|
5248
5280
|
const t = this.tplCtx, e = this.tplActive;
|
|
5249
5281
|
!t || !e || (t.innerHTML = "", Et.forEach((i) => {
|
|
5250
|
-
const s = this.ctxBtn(
|
|
5282
|
+
const s = this.ctxBtn(Zi[i], this.t(St[i]), () => this.setTplLayout(i));
|
|
5251
5283
|
s.classList.toggle("on", e.classList.contains("tpl-" + i)), t.appendChild(s);
|
|
5252
5284
|
}), t.append(this.ctxSep(), this.ctxBtn(h.trash, this.t("deltemplate"), () => this.removeTemplate())), this.positionTplCtx());
|
|
5253
5285
|
}
|
|
@@ -5286,7 +5318,7 @@ let is = (j = class {
|
|
|
5286
5318
|
/* ---------------------------------------------------------- table resize */
|
|
5287
5319
|
clearTableHandles() {
|
|
5288
5320
|
var t, e, i, s, n;
|
|
5289
|
-
(t = this.tblCorner) == null || t.remove(), this.tblCorner = null, this.tblColBars.forEach((
|
|
5321
|
+
(t = this.tblCorner) == null || t.remove(), this.tblCorner = null, this.tblColBars.forEach((r) => r.remove()), this.tblColBars = [], (e = this.tblCtx) == null || e.remove(), this.tblCtx = null, (i = this.tblCellMark) == null || i.remove(), this.tblCellMark = null, (s = this.tblOpMark) == null || s.remove(), this.tblOpMark = null, this.tblOpMarkKind = null, (n = this.tblActive) == null || n.classList.remove("tbl-selected"), this.tblActive = null;
|
|
5290
5322
|
}
|
|
5291
5323
|
/** Blue outline around the cell that holds the caret, so it is clear
|
|
5292
5324
|
which cell / row / column the table operations will target. */
|
|
@@ -5313,8 +5345,8 @@ let is = (j = class {
|
|
|
5313
5345
|
return;
|
|
5314
5346
|
}
|
|
5315
5347
|
this.tblOpMark || (this.tblOpMark = document.createElement("div"), this.tblOpMark.className = "tbl-opmark", document.body.appendChild(this.tblOpMark));
|
|
5316
|
-
const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), n = e.parentElement.getBoundingClientRect(),
|
|
5317
|
-
this.tblOpMark.style.left =
|
|
5348
|
+
const i = this.tblActive.getBoundingClientRect(), s = e.getBoundingClientRect(), n = e.parentElement.getBoundingClientRect(), r = t === "row" ? n.left : s.left, o = t === "row" ? n.top : i.top, l = t === "row" ? n.width : s.width, a = t === "row" ? n.height : i.height;
|
|
5349
|
+
this.tblOpMark.style.left = r + scrollX + "px", this.tblOpMark.style.top = o + scrollY + "px", this.tblOpMark.style.width = l + "px", this.tblOpMark.style.height = a + "px";
|
|
5318
5350
|
}
|
|
5319
5351
|
/** Lowest allowed top for floating context toolbars — keeps them from
|
|
5320
5352
|
covering the editor menubar/toolbar when the target sits on the first line. */
|
|
@@ -5323,7 +5355,7 @@ let is = (j = class {
|
|
|
5323
5355
|
}
|
|
5324
5356
|
ctxBtn(t, e, i, s) {
|
|
5325
5357
|
const n = document.createElement("button");
|
|
5326
|
-
return n.type = "button", n.title = e, n.innerHTML = t, s && (n.dataset.id = s), n.addEventListener("mousedown", (
|
|
5358
|
+
return n.type = "button", n.title = e, n.innerHTML = t, s && (n.dataset.id = s), n.addEventListener("mousedown", (r) => r.preventDefault()), n.addEventListener("click", i), n;
|
|
5327
5359
|
}
|
|
5328
5360
|
ctxSep() {
|
|
5329
5361
|
const t = document.createElement("div");
|
|
@@ -5360,20 +5392,20 @@ let is = (j = class {
|
|
|
5360
5392
|
this.clearTableHandles();
|
|
5361
5393
|
return;
|
|
5362
5394
|
}
|
|
5363
|
-
const t = this.ed.getAttribute("dir") === "rtl", e = this.tblActive.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, n = e.right + scrollX,
|
|
5364
|
-
if (this.tblCorner && (this.tblCorner.style.top =
|
|
5365
|
-
const
|
|
5366
|
-
let d = s + (n - s) / 2 -
|
|
5367
|
-
d = Math.max(8 + scrollX, Math.min(d, scrollX + innerWidth -
|
|
5395
|
+
const t = this.ed.getAttribute("dir") === "rtl", e = this.tblActive.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, n = e.right + scrollX, r = e.bottom + scrollY;
|
|
5396
|
+
if (this.tblCorner && (this.tblCorner.style.top = r - 5 + "px", this.tblCorner.style.left = (t ? s - 5 : n - 5) + "px", this.tblCorner.style.cursor = t ? "nesw-resize" : "nwse-resize"), this.tblCtx) {
|
|
5397
|
+
const l = this.tblCtx.offsetWidth, a = this.tblCtx.offsetHeight;
|
|
5398
|
+
let d = s + (n - s) / 2 - l / 2;
|
|
5399
|
+
d = Math.max(8 + scrollX, Math.min(d, scrollX + innerWidth - l - 8));
|
|
5368
5400
|
let p = i - a - 8;
|
|
5369
|
-
p < this.ctxMinTop() && (p =
|
|
5401
|
+
p < this.ctxMinTop() && (p = r + 8), this.tblCtx.style.left = d + "px", this.tblCtx.style.top = p + "px";
|
|
5370
5402
|
}
|
|
5371
|
-
this.tblColBars.forEach((
|
|
5372
|
-
const
|
|
5373
|
-
if (
|
|
5374
|
-
for (let
|
|
5375
|
-
const a =
|
|
5376
|
-
p.className = "tbl-colbar", p.style.top = i + "px", p.style.left = d + "px", p.style.height =
|
|
5403
|
+
this.tblColBars.forEach((l) => l.remove()), this.tblColBars = [];
|
|
5404
|
+
const o = this.tblActive.rows[0];
|
|
5405
|
+
if (o)
|
|
5406
|
+
for (let l = 0; l < o.cells.length - 1; l++) {
|
|
5407
|
+
const a = o.cells[l].getBoundingClientRect(), d = (t ? a.left : a.right) + scrollX, p = document.createElement("div");
|
|
5408
|
+
p.className = "tbl-colbar", p.style.top = i + "px", p.style.left = d + "px", p.style.height = r - i + "px", document.body.appendChild(p), p.addEventListener("mousedown", (m) => this.startColBarDrag(m, l)), this.tblColBars.push(p);
|
|
5377
5409
|
}
|
|
5378
5410
|
this.positionCellMarker(), this.positionOpMark();
|
|
5379
5411
|
}
|
|
@@ -5391,27 +5423,27 @@ let is = (j = class {
|
|
|
5391
5423
|
const e = this.tblActive;
|
|
5392
5424
|
if (!e) return;
|
|
5393
5425
|
const i = this.ed.getAttribute("dir") === "rtl", s = t.clientX, n = e.getBoundingClientRect().width;
|
|
5394
|
-
e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((
|
|
5395
|
-
const
|
|
5426
|
+
e.style.tableLayout = e.style.tableLayout || "fixed", this.withNoTextSelect((r) => {
|
|
5427
|
+
const o = (a) => {
|
|
5396
5428
|
const d = i ? -(a.clientX - s) : a.clientX - s;
|
|
5397
5429
|
e.style.width = Math.max(60, Math.round(n + d)) + "px", this.positionTableHandles();
|
|
5398
|
-
},
|
|
5399
|
-
window.removeEventListener("mousemove",
|
|
5430
|
+
}, l = () => {
|
|
5431
|
+
window.removeEventListener("mousemove", o), window.removeEventListener("mouseup", l), r(), this.onChange();
|
|
5400
5432
|
};
|
|
5401
|
-
window.addEventListener("mousemove",
|
|
5433
|
+
window.addEventListener("mousemove", o), window.addEventListener("mouseup", l);
|
|
5402
5434
|
});
|
|
5403
5435
|
}
|
|
5404
5436
|
startColBarDrag(t, e) {
|
|
5405
5437
|
t.preventDefault(), t.stopPropagation();
|
|
5406
5438
|
const i = this.tblActive;
|
|
5407
5439
|
if (!i) return;
|
|
5408
|
-
const s = this.ed.getAttribute("dir") === "rtl", n = Array.from(i.rows),
|
|
5409
|
-
if (!
|
|
5410
|
-
const
|
|
5440
|
+
const s = this.ed.getAttribute("dir") === "rtl", n = Array.from(i.rows), r = n.map((p) => p.cells[e]).filter(Boolean), o = n.map((p) => p.cells[e + 1]).filter(Boolean);
|
|
5441
|
+
if (!r.length || !o.length) return;
|
|
5442
|
+
const l = t.clientX, a = r[0].getBoundingClientRect().width, d = o[0].getBoundingClientRect().width;
|
|
5411
5443
|
i.style.tableLayout = "fixed", this.withNoTextSelect((p) => {
|
|
5412
5444
|
const m = (b) => {
|
|
5413
|
-
const f = (s ? -1 : 1) * (b.clientX -
|
|
5414
|
-
|
|
5445
|
+
const f = (s ? -1 : 1) * (b.clientX - l);
|
|
5446
|
+
r.forEach((y) => y.style.width = Math.max(24, Math.round(a + f)) + "px"), o.forEach((y) => y.style.width = Math.max(24, Math.round(d - f)) + "px"), this.positionTableHandles();
|
|
5415
5447
|
}, v = () => {
|
|
5416
5448
|
window.removeEventListener("mousemove", m), window.removeEventListener("mouseup", v), p(), this.onChange();
|
|
5417
5449
|
};
|
|
@@ -5430,7 +5462,7 @@ let is = (j = class {
|
|
|
5430
5462
|
this.cancelImgHide(), this.imgHandles.forEach((i) => i.remove()), this.imgHandles = [], (t = this.imgCtx) == null || t.remove(), this.imgCtx = null, (e = this.imgActive) == null || e.classList.remove("img-selected"), this.imgActive = null;
|
|
5431
5463
|
}
|
|
5432
5464
|
selectImage(t) {
|
|
5433
|
-
this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles =
|
|
5465
|
+
this.imgActive !== t && (this.clearImageHandles(), this.imgActive = t, t.classList.add("img-selected"), this.imgHandles = Fi.map((e) => {
|
|
5434
5466
|
const i = document.createElement("div");
|
|
5435
5467
|
return i.className = "img-handle img-handle-" + e, i.dataset.corner = e, i.addEventListener("mousedown", (s) => this.startImageResizeDrag(s, e)), i.addEventListener("mouseenter", () => this.cancelImgHide()), i.addEventListener("mouseleave", () => this.scheduleImgHide()), document.body.appendChild(i), i;
|
|
5436
5468
|
}), this.imgCtx = this.buildImageCtxToolbar(t), this.positionImageHandles());
|
|
@@ -5444,30 +5476,30 @@ let is = (j = class {
|
|
|
5444
5476
|
(d = this.imgCtx) == null || d.replaceWith(a), this.imgCtx = a, this.positionImageHandles();
|
|
5445
5477
|
}, s = (a) => {
|
|
5446
5478
|
this.setImageAlign(t, a), i();
|
|
5447
|
-
}, n = t.style.float === "left",
|
|
5479
|
+
}, n = t.style.float === "left", r = t.style.float === "right", o = !n && !r && t.style.marginLeft === "auto" && t.style.marginRight === "auto", l = (a, d, p, m) => {
|
|
5448
5480
|
const v = this.ctxBtn(a, d, m);
|
|
5449
5481
|
return v.classList.toggle("on", p), v;
|
|
5450
5482
|
};
|
|
5451
5483
|
return e.append(
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5484
|
+
l(h.alignleft, this.t("alignleft"), n, () => s("left")),
|
|
5485
|
+
l(h.aligncenter, this.t("aligncenter"), o, () => s("center")),
|
|
5486
|
+
l(h.alignright, this.t("alignright"), r, () => s("right")),
|
|
5455
5487
|
this.ctxSep(),
|
|
5456
|
-
|
|
5488
|
+
l(h.rotateleft, this.t("rotateleft"), !1, () => {
|
|
5457
5489
|
this.rotateImage(t, -90), i();
|
|
5458
5490
|
}),
|
|
5459
|
-
|
|
5491
|
+
l(h.rotateright, this.t("rotateright"), !1, () => {
|
|
5460
5492
|
this.rotateImage(t, 90), i();
|
|
5461
5493
|
}),
|
|
5462
5494
|
this.ctxSep(),
|
|
5463
|
-
|
|
5495
|
+
l(h.fliphorizontal, this.t("fliphorizontal"), t.dataset.flipx === "1", () => {
|
|
5464
5496
|
this.flipImage(t, "x"), i();
|
|
5465
5497
|
}),
|
|
5466
|
-
|
|
5498
|
+
l(h.flipvertical, this.t("flipvertical"), t.dataset.flipy === "1", () => {
|
|
5467
5499
|
this.flipImage(t, "y"), i();
|
|
5468
5500
|
}),
|
|
5469
5501
|
this.ctxSep(),
|
|
5470
|
-
|
|
5502
|
+
l(h.trash, this.t("deleteimg"), !1, () => {
|
|
5471
5503
|
const a = t.closest(".tpl-media");
|
|
5472
5504
|
a && this.ed.contains(a) ? t.outerHTML = this.imgPhHTML() : t.remove(), this.clearImageHandles(), this.onChange();
|
|
5473
5505
|
})
|
|
@@ -5493,20 +5525,20 @@ let is = (j = class {
|
|
|
5493
5525
|
this.clearImageHandles();
|
|
5494
5526
|
return;
|
|
5495
5527
|
}
|
|
5496
|
-
const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, n = t.bottom + scrollY,
|
|
5528
|
+
const t = this.imgActive.getBoundingClientRect(), e = t.top + scrollY, i = t.left + scrollX, s = t.right + scrollX, n = t.bottom + scrollY, r = {
|
|
5497
5529
|
nw: [i, e],
|
|
5498
5530
|
ne: [s, e],
|
|
5499
5531
|
sw: [i, n],
|
|
5500
5532
|
se: [s, n]
|
|
5501
5533
|
};
|
|
5502
|
-
if (this.imgHandles.forEach((
|
|
5503
|
-
const [
|
|
5504
|
-
|
|
5534
|
+
if (this.imgHandles.forEach((o) => {
|
|
5535
|
+
const [l, a] = r[o.dataset.corner];
|
|
5536
|
+
o.style.left = l - 5 + "px", o.style.top = a - 5 + "px";
|
|
5505
5537
|
}), this.imgCtx) {
|
|
5506
|
-
const
|
|
5507
|
-
let a = i + (s - i) / 2 -
|
|
5508
|
-
a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth -
|
|
5509
|
-
let d = e -
|
|
5538
|
+
const o = this.imgCtx.offsetWidth, l = this.imgCtx.offsetHeight;
|
|
5539
|
+
let a = i + (s - i) / 2 - o / 2;
|
|
5540
|
+
a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - o - 8));
|
|
5541
|
+
let d = e - l - 8;
|
|
5510
5542
|
d < this.ctxMinTop() && (d = n + 8), this.imgCtx.style.left = a + "px", this.imgCtx.style.top = d + "px";
|
|
5511
5543
|
}
|
|
5512
5544
|
}
|
|
@@ -5515,16 +5547,17 @@ let is = (j = class {
|
|
|
5515
5547
|
const i = this.imgActive;
|
|
5516
5548
|
if (!i) return;
|
|
5517
5549
|
this.cancelImgHide();
|
|
5518
|
-
const s = t.clientX, n = i.getBoundingClientRect().width,
|
|
5519
|
-
this.withNoTextSelect((
|
|
5520
|
-
const
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5550
|
+
const s = t.clientX, n = i.offsetWidth || i.getBoundingClientRect().width, r = e === "nw" || e === "sw" ? -1 : 1, o = Math.round(this.contentWidth());
|
|
5551
|
+
this.withNoTextSelect((l) => {
|
|
5552
|
+
const a = (p) => {
|
|
5553
|
+
let m = Math.max(24, Math.round(n + r * (p.clientX - s)));
|
|
5554
|
+
o > 0 && (m = Math.min(m, o)), i.style.width = m + "px", i.style.height = "auto", this.positionImageHandles();
|
|
5555
|
+
}, d = () => {
|
|
5556
|
+
window.removeEventListener("mousemove", a), window.removeEventListener("mouseup", d), l();
|
|
5557
|
+
const p = Math.round(i.offsetWidth) || parseInt(i.style.width, 10);
|
|
5558
|
+
p > 0 && !i.closest(".tpl-media") && (i.style.width = p + "px", i.setAttribute("width", String(p)), i.removeAttribute("height")), this.onChange();
|
|
5526
5559
|
};
|
|
5527
|
-
window.addEventListener("mousemove",
|
|
5560
|
+
window.addEventListener("mousemove", a), window.addEventListener("mouseup", d);
|
|
5528
5561
|
});
|
|
5529
5562
|
}
|
|
5530
5563
|
/* ---------------------------------------------------------- selection bubble toolbar */
|
|
@@ -5563,7 +5596,7 @@ let is = (j = class {
|
|
|
5563
5596
|
this.selCtx || (this.selCtx = this.buildSelToolbar()), this.positionSelToolbar(e);
|
|
5564
5597
|
}
|
|
5565
5598
|
buildSelToolbar() {
|
|
5566
|
-
var
|
|
5599
|
+
var o;
|
|
5567
5600
|
const t = document.createElement("div");
|
|
5568
5601
|
t.className = "selctx", t.dir = this.dir();
|
|
5569
5602
|
const e = this.ctxBtn(
|
|
@@ -5571,8 +5604,8 @@ let is = (j = class {
|
|
|
5571
5604
|
this.t("forecolor"),
|
|
5572
5605
|
() => this.colorMenu(e, "fore")
|
|
5573
5606
|
), i = this.ctxBtn(h.backcolor, this.t("backcolor"), () => this.colorMenu(i, "back"));
|
|
5574
|
-
(
|
|
5575
|
-
const s = this.ctxBtn(h.caseic, this.t("changecase"), () => this.caseMenu(s)), n = this.ctxBtn(h.lineheight, this.t("lineheight"), () => this.lineHeightMenu(n)),
|
|
5607
|
+
(o = i.querySelector("svg")) == null || o.insertAdjacentHTML("afterend", '<span class="colorbar" data-cb="back"></span>');
|
|
5608
|
+
const s = this.ctxBtn(h.caseic, this.t("changecase"), () => this.caseMenu(s)), n = this.ctxBtn(h.lineheight, this.t("lineheight"), () => this.lineHeightMenu(n)), r = this.ctxBtn(h.wordspacing, this.t("wordspacing"), () => this.wordSpacingMenu(r));
|
|
5576
5609
|
return t.append(
|
|
5577
5610
|
this.ctxBtn(h.bold, this.t("bold"), () => this.exec("bold"), "bold"),
|
|
5578
5611
|
this.ctxBtn(h.italic, this.t("italic"), () => this.exec("italic"), "italic"),
|
|
@@ -5587,16 +5620,16 @@ let is = (j = class {
|
|
|
5587
5620
|
this.ctxBtn(h.link, this.t("linkttl"), () => this.linkDlg()),
|
|
5588
5621
|
s,
|
|
5589
5622
|
n,
|
|
5590
|
-
|
|
5591
|
-
), t.addEventListener("mousedown", (
|
|
5623
|
+
r
|
|
5624
|
+
), t.addEventListener("mousedown", (l) => l.preventDefault()), document.body.appendChild(t), this.syncColorSwatches(t), t;
|
|
5592
5625
|
}
|
|
5593
5626
|
positionSelToolbar(t) {
|
|
5594
5627
|
if (!this.selCtx) return;
|
|
5595
|
-
const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, n = e.right + scrollX,
|
|
5596
|
-
let a = s + (n - s) / 2 -
|
|
5597
|
-
a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth -
|
|
5598
|
-
let d = i -
|
|
5599
|
-
d < this.ctxMinTop() && (d =
|
|
5628
|
+
const e = t.getBoundingClientRect(), i = e.top + scrollY, s = e.left + scrollX, n = e.right + scrollX, r = e.bottom + scrollY, o = this.selCtx.offsetWidth, l = this.selCtx.offsetHeight;
|
|
5629
|
+
let a = s + (n - s) / 2 - o / 2;
|
|
5630
|
+
a = Math.max(8 + scrollX, Math.min(a, scrollX + innerWidth - o - 8));
|
|
5631
|
+
let d = i - l - 8;
|
|
5632
|
+
d < this.ctxMinTop() && (d = r + 8), this.selCtx.style.left = a + "px", this.selCtx.style.top = d + "px";
|
|
5600
5633
|
}
|
|
5601
5634
|
repositionSelToolbar() {
|
|
5602
5635
|
if (!this.selCtx) return;
|
|
@@ -5629,7 +5662,7 @@ let is = (j = class {
|
|
|
5629
5662
|
return t > 0 ? t + "px" : "";
|
|
5630
5663
|
}
|
|
5631
5664
|
refreshState() {
|
|
5632
|
-
var
|
|
5665
|
+
var l, a, d;
|
|
5633
5666
|
const t = window.getSelection(), e = t ? this.ed.contains(t.anchorNode) : !1, i = this.currentBlock();
|
|
5634
5667
|
[this.toolbar, this.selCtx].filter(Boolean).forEach((p) => {
|
|
5635
5668
|
[
|
|
@@ -5653,13 +5686,13 @@ let is = (j = class {
|
|
|
5653
5686
|
const m = p.querySelector("[data-id=code]");
|
|
5654
5687
|
m && m.classList.toggle("on", e && !!this.closestInlineCode());
|
|
5655
5688
|
});
|
|
5656
|
-
const n = t ? this.closestBlock(t.anchorNode) : null,
|
|
5657
|
-
(a = this.toolbar.querySelector("[data-id=ltr]")) == null || a.classList.toggle("on", e &&
|
|
5658
|
-
const
|
|
5689
|
+
const n = t ? this.closestBlock(t.anchorNode) : null, r = ((l = n == null ? void 0 : n.closest("[dir]")) == null ? void 0 : l.getAttribute("dir")) || this.ed.getAttribute("dir") || this.dir();
|
|
5690
|
+
(a = this.toolbar.querySelector("[data-id=ltr]")) == null || a.classList.toggle("on", e && r === "ltr"), (d = this.toolbar.querySelector("[data-id=rtl]")) == null || d.classList.toggle("on", e && r === "rtl");
|
|
5691
|
+
const o = (p, m, v) => {
|
|
5659
5692
|
const b = this.toolbar.querySelector(`[data-id=${p}] .lbl`);
|
|
5660
5693
|
b && (b.textContent = m || v || "", b.classList.toggle("empty", !m));
|
|
5661
5694
|
};
|
|
5662
|
-
|
|
5695
|
+
o("fontsel", this.currentFont()), o("sizesel", this.currentSize().replace("px", "")), e && o("blocksel", re.some((p) => p[0] === i) ? this.blockLabel(i) : this.t("para")), this.sbWords.textContent = this.countWords() + " " + this.t("words");
|
|
5663
5696
|
}
|
|
5664
5697
|
countWords() {
|
|
5665
5698
|
const t = (this.ed.textContent || "").trim();
|
|
@@ -5679,13 +5712,13 @@ let is = (j = class {
|
|
|
5679
5712
|
return;
|
|
5680
5713
|
}
|
|
5681
5714
|
if (!i) {
|
|
5682
|
-
const n = e.getData("text/plain"),
|
|
5683
|
-
if (
|
|
5684
|
-
document.execCommand("insertHTML", !1, this.videoEmbedHTML(
|
|
5715
|
+
const n = e.getData("text/plain"), r = /^\S+$/.test(n.trim()) ? this.videoEmbedUrl(n.trim()) : null;
|
|
5716
|
+
if (r) {
|
|
5717
|
+
document.execCommand("insertHTML", !1, this.videoEmbedHTML(r)), this.onChange();
|
|
5685
5718
|
return;
|
|
5686
5719
|
}
|
|
5687
5720
|
}
|
|
5688
|
-
i ? this.pasteRichHTML(i, e, s) : (document.execCommand("insertHTML", !1,
|
|
5721
|
+
i ? this.pasteRichHTML(i, e, s) : (document.execCommand("insertHTML", !1, wi(e.getData("text/plain"))), this.onChange());
|
|
5689
5722
|
}
|
|
5690
5723
|
/** Rich-HTML paste. Before the (untouched) paste engine runs, pictures Word left
|
|
5691
5724
|
* behind as unreadable file:// refs are pulled out of the clipboard's RTF flavor
|
|
@@ -5697,19 +5730,19 @@ let is = (j = class {
|
|
|
5697
5730
|
let s = [];
|
|
5698
5731
|
const n = e.getData("text/rtf");
|
|
5699
5732
|
if (n) {
|
|
5700
|
-
const
|
|
5701
|
-
t =
|
|
5733
|
+
const r = Ii(t, n);
|
|
5734
|
+
t = r.html, s = r.injected;
|
|
5702
5735
|
}
|
|
5703
|
-
if (i &&
|
|
5704
|
-
const
|
|
5705
|
-
if (
|
|
5706
|
-
const
|
|
5736
|
+
if (i && qi(t) === 1) {
|
|
5737
|
+
const r = i.getAsFile();
|
|
5738
|
+
if (r) {
|
|
5739
|
+
const o = t;
|
|
5707
5740
|
this.saveSel();
|
|
5708
|
-
const
|
|
5709
|
-
|
|
5710
|
-
const a =
|
|
5741
|
+
const l = new FileReader();
|
|
5742
|
+
l.onload = () => {
|
|
5743
|
+
const a = ve(o, [l.result]);
|
|
5711
5744
|
this.finishRichPaste(a.html, s.concat(a.injected), !0);
|
|
5712
|
-
},
|
|
5745
|
+
}, l.onerror = () => this.finishRichPaste(o, s, !0), l.readAsDataURL(r);
|
|
5713
5746
|
return;
|
|
5714
5747
|
}
|
|
5715
5748
|
}
|
|
@@ -5723,36 +5756,36 @@ let is = (j = class {
|
|
|
5723
5756
|
this.insertPastedHTML(t, i);
|
|
5724
5757
|
return;
|
|
5725
5758
|
}
|
|
5726
|
-
const s = this.imageUploadHandler, n = e.filter((
|
|
5759
|
+
const s = this.imageUploadHandler, n = e.filter((r, o) => e.indexOf(r) === o);
|
|
5727
5760
|
i || this.saveSel(), Promise.all(
|
|
5728
|
-
n.map((
|
|
5729
|
-
const
|
|
5730
|
-
return
|
|
5761
|
+
n.map((r, o) => {
|
|
5762
|
+
const l = Ri(r, "pasted-image-" + (o + 1));
|
|
5763
|
+
return l ? s(l).catch((a) => {
|
|
5731
5764
|
var d;
|
|
5732
|
-
return (d = this.onImageUploadError) == null || d.call(this, a,
|
|
5733
|
-
}) : Promise.resolve(
|
|
5765
|
+
return (d = this.onImageUploadError) == null || d.call(this, a, l), r;
|
|
5766
|
+
}) : Promise.resolve(r);
|
|
5734
5767
|
})
|
|
5735
|
-
).then((
|
|
5736
|
-
let
|
|
5737
|
-
n.forEach((
|
|
5738
|
-
|
|
5739
|
-
}), this.insertPastedHTML(
|
|
5768
|
+
).then((r) => {
|
|
5769
|
+
let o = t;
|
|
5770
|
+
n.forEach((l, a) => {
|
|
5771
|
+
r[a] !== l && (o = o.split(l).join(r[a]));
|
|
5772
|
+
}), this.insertPastedHTML(o, !0);
|
|
5740
5773
|
});
|
|
5741
5774
|
}
|
|
5742
5775
|
/** `deferred` means the insert is happening after an async hop, so the caret the
|
|
5743
5776
|
* paste started from has to be put back first. */
|
|
5744
5777
|
insertPastedHTML(t, e = !1) {
|
|
5745
|
-
e && this.restoreSel(), document.execCommand("insertHTML", !1,
|
|
5778
|
+
e && this.restoreSel(), document.execCommand("insertHTML", !1, Ci(t, this.dir())), e && this.saveSel(), this.onChange();
|
|
5746
5779
|
}
|
|
5747
5780
|
/* ---------------------------------------------------------- init */
|
|
5748
5781
|
initUI() {
|
|
5749
5782
|
this.closePop(), this.closeDlg(), this.clearTableHandles(), this.clearImgPlaceholderSel(), this.clearVphPlaceholderSel(), this.clearVidHandles(), this.clearCodeSel(), this.shell.dir = this.dir(), this.ed.dir = this.dir(), this.options.menubar ? this.buildMenubar() : this.menubar.style.display = "none", this.options.toolbar ? this.buildToolbar() : this.toolbar.style.display = "none", this.sbHelp.textContent = this.t("statushelp"), this.refreshState();
|
|
5750
5783
|
}
|
|
5751
5784
|
}, j.instanceCounter = 0, j.TBR_COLLAPSE_MAX = 992, j);
|
|
5752
|
-
const
|
|
5753
|
-
({ value: u, defaultValue: t, onChange: e, onReady: i, className: s, style: n, ...
|
|
5754
|
-
const
|
|
5755
|
-
return v.current = e, b.current = i,
|
|
5785
|
+
const ls = Ye(
|
|
5786
|
+
({ value: u, defaultValue: t, onChange: e, onReady: i, className: s, style: n, ...r }, o) => {
|
|
5787
|
+
const l = z(null), a = z(null), d = z(!1), p = z(u ?? t), m = z(null), v = z(e), b = z(i);
|
|
5788
|
+
return v.current = e, b.current = i, Ge(o, () => ({
|
|
5756
5789
|
getContent: () => {
|
|
5757
5790
|
var f;
|
|
5758
5791
|
return ((f = a.current) == null ? void 0 : f.getContent()) ?? "";
|
|
@@ -5794,9 +5827,9 @@ const ss = Xe(
|
|
|
5794
5827
|
return ((f = a.current) == null ? void 0 : f.getRevisions()) ?? [];
|
|
5795
5828
|
}
|
|
5796
5829
|
})), lt(() => {
|
|
5797
|
-
if (!
|
|
5798
|
-
const f = new
|
|
5799
|
-
target:
|
|
5830
|
+
if (!l.current) return;
|
|
5831
|
+
const f = new rs({
|
|
5832
|
+
target: l.current,
|
|
5800
5833
|
initialContent: p.current,
|
|
5801
5834
|
onChange: (y) => {
|
|
5802
5835
|
var C;
|
|
@@ -5806,7 +5839,7 @@ const ss = Xe(
|
|
|
5806
5839
|
var C;
|
|
5807
5840
|
return (C = b.current) == null ? void 0 : C.call(b, y);
|
|
5808
5841
|
},
|
|
5809
|
-
...
|
|
5842
|
+
...r
|
|
5810
5843
|
});
|
|
5811
5844
|
return a.current = f, () => {
|
|
5812
5845
|
f.destroy(), a.current = null;
|
|
@@ -5818,14 +5851,14 @@ const ss = Xe(
|
|
|
5818
5851
|
d.current = !1;
|
|
5819
5852
|
return;
|
|
5820
5853
|
}
|
|
5821
|
-
if ((f =
|
|
5854
|
+
if ((f = l.current) != null && f.contains(document.activeElement)) {
|
|
5822
5855
|
m.current = u;
|
|
5823
5856
|
return;
|
|
5824
5857
|
}
|
|
5825
5858
|
p.current = u, (y = a.current) == null || y.setContent(u);
|
|
5826
5859
|
}
|
|
5827
5860
|
}, [u]), lt(() => {
|
|
5828
|
-
const f =
|
|
5861
|
+
const f = l.current;
|
|
5829
5862
|
if (!f) return;
|
|
5830
5863
|
const y = (C) => {
|
|
5831
5864
|
var A;
|
|
@@ -5838,11 +5871,11 @@ const ss = Xe(
|
|
|
5838
5871
|
return f.addEventListener("focusout", y), () => f.removeEventListener("focusout", y);
|
|
5839
5872
|
}, []), lt(() => {
|
|
5840
5873
|
var f;
|
|
5841
|
-
|
|
5842
|
-
}, [
|
|
5874
|
+
r.language && ((f = a.current) == null || f.setLanguage(r.language));
|
|
5875
|
+
}, [r.language]), /* @__PURE__ */ Je.jsx("div", { ref: l, className: s, style: n });
|
|
5843
5876
|
}
|
|
5844
5877
|
);
|
|
5845
|
-
|
|
5878
|
+
ls.displayName = "FableEditor";
|
|
5846
5879
|
export {
|
|
5847
|
-
|
|
5880
|
+
ls as FableEditor
|
|
5848
5881
|
};
|