ckeditor5-blazor 1.10.3 → 1.11.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/elements/context/context.d.ts.map +1 -1
- package/dist/elements/editor/editor.d.ts.map +1 -1
- package/dist/elements/editor/types/editor-relaxed-constructor.type.d.ts +6 -0
- package/dist/elements/editor/types/editor-relaxed-constructor.type.d.ts.map +1 -0
- package/dist/elements/editor/types/index.d.ts +2 -0
- package/dist/elements/editor/types/index.d.ts.map +1 -0
- package/dist/elements/editor/utils/assign-initial-data-to-editor-config.d.ts +10 -0
- package/dist/elements/editor/utils/assign-initial-data-to-editor-config.d.ts.map +1 -0
- package/dist/elements/editor/utils/assign-source-elements-to-editor-config.d.ts +12 -0
- package/dist/elements/editor/utils/assign-source-elements-to-editor-config.d.ts.map +1 -0
- package/dist/elements/editor/utils/create-editor-in-context.d.ts +1 -3
- package/dist/elements/editor/utils/create-editor-in-context.d.ts.map +1 -1
- package/dist/elements/editor/utils/index.d.ts +3 -0
- package/dist/elements/editor/utils/index.d.ts.map +1 -1
- package/dist/elements/editor/utils/normalize-editor-language.d.ts +9 -0
- package/dist/elements/editor/utils/normalize-editor-language.d.ts.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +410 -353
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/elements/context/context.test.ts +107 -66
- package/src/elements/context/context.ts +9 -3
- package/src/elements/editable.ts +2 -2
- package/src/elements/editor/editor.ts +33 -29
- package/src/elements/editor/types/editor-relaxed-constructor.type.ts +6 -0
- package/src/elements/editor/types/index.ts +1 -0
- package/src/elements/editor/utils/assign-initial-data-to-editor-config.ts +47 -0
- package/src/elements/editor/utils/assign-source-elements-to-editor-config.ts +59 -0
- package/src/elements/editor/utils/create-editor-in-context.ts +2 -5
- package/src/elements/editor/utils/index.ts +3 -0
- package/src/elements/editor/utils/normalize-editor-language.test.ts +50 -0
- package/src/elements/editor/utils/normalize-editor-language.ts +25 -0
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
class
|
|
1
|
+
class v extends Error {
|
|
2
2
|
constructor(t) {
|
|
3
3
|
super(t), this.name = "CKEditor5BlazorError";
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function B(r, t) {
|
|
7
7
|
if (!r || r.size !== t.size)
|
|
8
8
|
return !1;
|
|
9
9
|
for (const [e, a] of r)
|
|
@@ -47,12 +47,12 @@ class Y {
|
|
|
47
47
|
* @returns A promise that resolves with the result of the function.
|
|
48
48
|
*/
|
|
49
49
|
execute(t, e, a) {
|
|
50
|
-
const
|
|
51
|
-
return
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
o(await e(
|
|
55
|
-
}), a ?
|
|
50
|
+
const n = this.items.get(t), i = this.initializationErrors.get(t);
|
|
51
|
+
return i ? (a?.(i), Promise.reject(i)) : n ? Promise.resolve(e(n)) : new Promise((o, s) => {
|
|
52
|
+
const c = this.getPendingCallbacks(t);
|
|
53
|
+
c.success.push(async (u) => {
|
|
54
|
+
o(await e(u));
|
|
55
|
+
}), a ? c.error.push(a) : c.error.push(s);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
@@ -63,19 +63,19 @@ class Y {
|
|
|
63
63
|
* @returns A function that stops observing and immediately runs any pending cleanup.
|
|
64
64
|
*/
|
|
65
65
|
mountEffect(t, e) {
|
|
66
|
-
let a,
|
|
67
|
-
const o = this.watch((
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
66
|
+
let a, n, i = !1;
|
|
67
|
+
const o = this.watch((s) => {
|
|
68
|
+
const c = s.get(t);
|
|
69
|
+
if (c !== n && (a?.(), a = void 0, n = c, !!c))
|
|
70
70
|
try {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
} catch (
|
|
74
|
-
throw console.error(
|
|
71
|
+
const u = e(c);
|
|
72
|
+
i ? (u?.(), o()) : a = u;
|
|
73
|
+
} catch (u) {
|
|
74
|
+
throw console.error(u), u;
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
return () => {
|
|
78
|
-
|
|
78
|
+
i = !0, n && (o(), a?.(), a = void 0);
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
@@ -90,7 +90,7 @@ class Y {
|
|
|
90
90
|
throw new Error(`Item with ID "${t}" is already registered.`);
|
|
91
91
|
this.resetErrors(t), this.items.set(t, e);
|
|
92
92
|
const a = this.pendingCallbacks.get(t);
|
|
93
|
-
a && (a.success.forEach((
|
|
93
|
+
a && (a.success.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.items.size === 1 && t !== null && this.register(null, e);
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
@@ -103,7 +103,7 @@ class Y {
|
|
|
103
103
|
this.batch(() => {
|
|
104
104
|
this.items.delete(t), this.initializationErrors.set(t, e);
|
|
105
105
|
const a = this.pendingCallbacks.get(t);
|
|
106
|
-
a && (a.error.forEach((
|
|
106
|
+
a && (a.error.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e);
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
@@ -220,7 +220,7 @@ class Y {
|
|
|
220
220
|
* Immediately dispatches the current state to all watchers if it changed.
|
|
221
221
|
*/
|
|
222
222
|
flushWatchers() {
|
|
223
|
-
|
|
223
|
+
B(this.lastNotifiedItems, this.items) && B(this.lastNotifiedErrors, this.initializationErrors) || (this.lastNotifiedItems = new Map(this.items), this.lastNotifiedErrors = new Map(this.initializationErrors), this.watchers.forEach((t) => t(
|
|
224
224
|
new Map(this.items),
|
|
225
225
|
new Map(this.initializationErrors)
|
|
226
226
|
)));
|
|
@@ -245,14 +245,14 @@ function $(r, t) {
|
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
function st(r, t) {
|
|
248
|
-
const e = Object.entries(r).filter(([a,
|
|
248
|
+
const e = Object.entries(r).filter(([a, n]) => t(n, a));
|
|
249
249
|
return Object.fromEntries(e);
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function S(r) {
|
|
252
252
|
return Object.keys(r).length === 0 && r.constructor === Object;
|
|
253
253
|
}
|
|
254
254
|
function W(r, t) {
|
|
255
|
-
const e = Object.entries(r).map(([a,
|
|
255
|
+
const e = Object.entries(r).map(([a, n]) => [a, t(n, a)]);
|
|
256
256
|
return Object.fromEntries(e);
|
|
257
257
|
}
|
|
258
258
|
function ct(r, t) {
|
|
@@ -261,8 +261,8 @@ function ct(r, t) {
|
|
|
261
261
|
const e = Object.keys(r), a = Object.keys(t);
|
|
262
262
|
if (e.length !== a.length)
|
|
263
263
|
return !1;
|
|
264
|
-
for (const
|
|
265
|
-
if (r[
|
|
264
|
+
for (const n of e)
|
|
265
|
+
if (r[n] !== t[n] || !Object.prototype.hasOwnProperty.call(t, n))
|
|
266
266
|
return !1;
|
|
267
267
|
return !0;
|
|
268
268
|
}
|
|
@@ -273,23 +273,23 @@ function lt(r, {
|
|
|
273
273
|
timeOutAfter: t = 500,
|
|
274
274
|
retryAfter: e = 100
|
|
275
275
|
} = {}) {
|
|
276
|
-
return new Promise((a,
|
|
277
|
-
const
|
|
276
|
+
return new Promise((a, n) => {
|
|
277
|
+
const i = Date.now();
|
|
278
278
|
let o = null;
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
}, t),
|
|
279
|
+
const s = setTimeout(() => {
|
|
280
|
+
n(o ?? new Error("Timeout"));
|
|
281
|
+
}, t), c = async () => {
|
|
282
282
|
try {
|
|
283
|
-
const
|
|
284
|
-
clearTimeout(
|
|
285
|
-
} catch (
|
|
286
|
-
o =
|
|
283
|
+
const u = await r();
|
|
284
|
+
clearTimeout(s), a(u);
|
|
285
|
+
} catch (u) {
|
|
286
|
+
o = u, Date.now() - i > t ? n(u) : setTimeout(c, e);
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
|
-
|
|
289
|
+
c();
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function R() {
|
|
293
293
|
return new Promise((r) => {
|
|
294
294
|
switch (document.readyState) {
|
|
295
295
|
case "loading":
|
|
@@ -311,9 +311,9 @@ function L(r) {
|
|
|
311
311
|
let t;
|
|
312
312
|
return {
|
|
313
313
|
promise: new Promise((a) => {
|
|
314
|
-
t = new MutationObserver((
|
|
315
|
-
for (const
|
|
316
|
-
if (
|
|
314
|
+
t = new MutationObserver((n) => {
|
|
315
|
+
for (const i of n)
|
|
316
|
+
if (i.type === "attributes" && i.attributeName === "data-cke-interactive" && r.hasAttribute("data-cke-interactive")) {
|
|
317
317
|
t.disconnect(), a();
|
|
318
318
|
break;
|
|
319
319
|
}
|
|
@@ -325,20 +325,73 @@ function L(r) {
|
|
|
325
325
|
function x(r) {
|
|
326
326
|
r.setAttribute("data-cke-interactive", "true");
|
|
327
327
|
}
|
|
328
|
-
function dt(r) {
|
|
328
|
+
function dt(r, t) {
|
|
329
|
+
const e = mt(r), a = /* @__PURE__ */ new Set([
|
|
330
|
+
...Object.keys(e),
|
|
331
|
+
...Object.keys(t.roots ?? {})
|
|
332
|
+
]), n = Array.from(a).reduce((o, s) => ({
|
|
333
|
+
...o,
|
|
334
|
+
[s]: {
|
|
335
|
+
...t.roots?.[s],
|
|
336
|
+
...s === "main" ? t.root : {},
|
|
337
|
+
/* v8 ignore next 5 */
|
|
338
|
+
...s in e ? {
|
|
339
|
+
initialData: e[s]
|
|
340
|
+
} : {}
|
|
341
|
+
}
|
|
342
|
+
}), Object.create(t.roots || {})), i = {
|
|
343
|
+
...t,
|
|
344
|
+
roots: n
|
|
345
|
+
};
|
|
346
|
+
return delete i.root, i;
|
|
347
|
+
}
|
|
348
|
+
function mt(r) {
|
|
349
|
+
return typeof r == "string" ? { main: r } : { ...r };
|
|
350
|
+
}
|
|
351
|
+
function ht(r, t, e) {
|
|
352
|
+
const a = ft(t);
|
|
353
|
+
if (!r.editorName || r.editorName === "ClassicEditor")
|
|
354
|
+
return {
|
|
355
|
+
...e,
|
|
356
|
+
attachTo: a.main
|
|
357
|
+
};
|
|
358
|
+
const n = /* @__PURE__ */ new Set([
|
|
359
|
+
...Object.keys(a),
|
|
360
|
+
...Object.keys(e.roots ?? {})
|
|
361
|
+
]), i = Array.from(n).reduce((s, c) => ({
|
|
362
|
+
...s,
|
|
363
|
+
[c]: {
|
|
364
|
+
/* v8 ignore next */
|
|
365
|
+
...e.roots?.[c],
|
|
366
|
+
...c === "main" ? e.root : {},
|
|
367
|
+
/* v8 ignore next 5 */
|
|
368
|
+
...c in a ? {
|
|
369
|
+
element: a[c]
|
|
370
|
+
} : {}
|
|
371
|
+
}
|
|
372
|
+
}), Object.create(e.roots || {})), o = {
|
|
373
|
+
...e,
|
|
374
|
+
roots: i
|
|
375
|
+
};
|
|
376
|
+
return delete o.root, o;
|
|
377
|
+
}
|
|
378
|
+
function ft(r) {
|
|
379
|
+
return r instanceof HTMLElement ? { main: r } : { ...r };
|
|
380
|
+
}
|
|
381
|
+
function pt(r) {
|
|
329
382
|
const t = [
|
|
330
383
|
r.ui?.element,
|
|
331
384
|
r.ui?.view?.toolbar?.element,
|
|
332
385
|
r.ui?.view?.menuBarView?.element
|
|
333
386
|
].filter(Boolean);
|
|
334
|
-
for (const
|
|
335
|
-
i
|
|
387
|
+
for (const i of t)
|
|
388
|
+
n(i);
|
|
336
389
|
const e = r.ui?.view?.body?._bodyCollectionContainer;
|
|
337
|
-
e?.isConnected &&
|
|
390
|
+
e?.isConnected && n(e);
|
|
338
391
|
const a = r.editing?.view;
|
|
339
392
|
if (a)
|
|
340
|
-
for (const
|
|
341
|
-
|
|
393
|
+
for (const i of a.domRoots.values())
|
|
394
|
+
i instanceof HTMLElement && (i.removeAttribute("contenteditable"), i.removeAttribute("role"), i.removeAttribute("aria-label"), i.removeAttribute("aria-multiline"), i.removeAttribute("spellcheck"), i.classList.remove(
|
|
342
395
|
"ck",
|
|
343
396
|
"ck-content",
|
|
344
397
|
"ck-editor__editable",
|
|
@@ -346,43 +399,42 @@ function dt(r) {
|
|
|
346
399
|
"ck-editor__editable_inline",
|
|
347
400
|
"ck-blurred",
|
|
348
401
|
"ck-focused"
|
|
349
|
-
), i
|
|
350
|
-
function i
|
|
351
|
-
|
|
402
|
+
), n(i));
|
|
403
|
+
function n(i) {
|
|
404
|
+
i.hasAttribute("data-cke-controlled") ? i.innerHTML = "" : i.remove();
|
|
352
405
|
}
|
|
353
406
|
}
|
|
354
407
|
const V = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
|
|
355
|
-
async function
|
|
356
|
-
const
|
|
357
|
-
await
|
|
358
|
-
creator:
|
|
359
|
-
id:
|
|
360
|
-
sourceElementOrData: r,
|
|
408
|
+
async function wt({ context: r, creator: t, config: e }) {
|
|
409
|
+
const a = ut();
|
|
410
|
+
await r.add({
|
|
411
|
+
creator: t.create.bind(t),
|
|
412
|
+
id: a,
|
|
361
413
|
type: "editor",
|
|
362
|
-
config:
|
|
414
|
+
config: e
|
|
363
415
|
});
|
|
364
|
-
const n =
|
|
416
|
+
const n = r.getItem(a), i = {
|
|
365
417
|
state: "available",
|
|
366
|
-
editorContextId:
|
|
367
|
-
context:
|
|
418
|
+
editorContextId: a,
|
|
419
|
+
context: r
|
|
368
420
|
};
|
|
369
|
-
n[V] =
|
|
370
|
-
const
|
|
371
|
-
return
|
|
372
|
-
...
|
|
421
|
+
n[V] = i;
|
|
422
|
+
const o = r.destroy.bind(r);
|
|
423
|
+
return r.destroy = async () => (i.state = "unavailable", o()), {
|
|
424
|
+
...i,
|
|
373
425
|
editor: n
|
|
374
426
|
};
|
|
375
427
|
}
|
|
376
|
-
function
|
|
428
|
+
function gt(r) {
|
|
377
429
|
return V in r ? r[V] : null;
|
|
378
430
|
}
|
|
379
431
|
function X(r) {
|
|
380
432
|
return Array.from(r.model.document.getRoots()).reduce((t, e) => (e.rootName === "$graveyard" || (t[e.rootName] = r.getData({ rootName: e.rootName })), t), /* @__PURE__ */ Object.create({}));
|
|
381
433
|
}
|
|
382
|
-
function
|
|
434
|
+
function T(r) {
|
|
383
435
|
return ["inline", "classic", "balloon", "decoupled"].includes(r);
|
|
384
436
|
}
|
|
385
|
-
async function
|
|
437
|
+
async function H(r) {
|
|
386
438
|
const t = await import("ckeditor5"), a = {
|
|
387
439
|
inline: t.InlineEditor,
|
|
388
440
|
balloon: t.BalloonEditor,
|
|
@@ -391,11 +443,11 @@ async function J(r) {
|
|
|
391
443
|
multiroot: t.MultiRootEditor
|
|
392
444
|
}[r];
|
|
393
445
|
if (!a)
|
|
394
|
-
throw new
|
|
446
|
+
throw new v(`Unsupported editor type: ${r}`);
|
|
395
447
|
return a;
|
|
396
448
|
}
|
|
397
|
-
class
|
|
398
|
-
static the = new
|
|
449
|
+
class j {
|
|
450
|
+
static the = new j();
|
|
399
451
|
/**
|
|
400
452
|
* Map of registered custom plugins.
|
|
401
453
|
*/
|
|
@@ -414,7 +466,7 @@ class _ {
|
|
|
414
466
|
*/
|
|
415
467
|
register(t, e) {
|
|
416
468
|
if (this.plugins.has(t))
|
|
417
|
-
throw new
|
|
469
|
+
throw new v(`Plugin with name "${t}" is already registered.`);
|
|
418
470
|
return this.plugins.set(t, e), this.unregister.bind(this, t);
|
|
419
471
|
}
|
|
420
472
|
/**
|
|
@@ -425,7 +477,7 @@ class _ {
|
|
|
425
477
|
*/
|
|
426
478
|
unregister(t) {
|
|
427
479
|
if (!this.plugins.has(t))
|
|
428
|
-
throw new
|
|
480
|
+
throw new v(`Plugin with name "${t}" is not registered.`);
|
|
429
481
|
this.plugins.delete(t);
|
|
430
482
|
}
|
|
431
483
|
/**
|
|
@@ -454,63 +506,63 @@ class _ {
|
|
|
454
506
|
return this.plugins.has(t);
|
|
455
507
|
}
|
|
456
508
|
}
|
|
457
|
-
async function
|
|
509
|
+
async function K(r) {
|
|
458
510
|
const t = await import("ckeditor5");
|
|
459
511
|
let e = null;
|
|
460
|
-
const a = r.map(async (
|
|
461
|
-
if (
|
|
462
|
-
const { name:
|
|
512
|
+
const a = r.map(async (n) => {
|
|
513
|
+
if (bt(n)) {
|
|
514
|
+
const { name: c, path: u } = n.$import, d = await import(
|
|
463
515
|
/* @vite-ignore */
|
|
464
|
-
|
|
465
|
-
),
|
|
466
|
-
if (!
|
|
467
|
-
throw new
|
|
468
|
-
return
|
|
516
|
+
u
|
|
517
|
+
), f = (Object.prototype.hasOwnProperty.call(d, c) ? d[c] : void 0) ?? (Object.prototype.hasOwnProperty.call(d, "default") ? d.default : void 0);
|
|
518
|
+
if (!f)
|
|
519
|
+
throw new v(`Plugin "${c}" not found in module "${u}".`);
|
|
520
|
+
return f;
|
|
469
521
|
}
|
|
470
|
-
const
|
|
471
|
-
if (
|
|
472
|
-
return
|
|
473
|
-
const { [
|
|
522
|
+
const i = await j.the.get(n);
|
|
523
|
+
if (i)
|
|
524
|
+
return i;
|
|
525
|
+
const { [n]: o } = t;
|
|
474
526
|
if (o)
|
|
475
527
|
return o;
|
|
476
528
|
if (!e)
|
|
477
529
|
try {
|
|
478
530
|
e = await import("ckeditor5-premium-features");
|
|
479
|
-
} catch (
|
|
480
|
-
throw console.error(`Failed to load premium package: ${
|
|
531
|
+
} catch (c) {
|
|
532
|
+
throw console.error(`Failed to load premium package: ${c}`), new v(`Plugin "${n}" not found in base package and failed to load premium package.`);
|
|
481
533
|
}
|
|
482
|
-
const { [
|
|
483
|
-
if (
|
|
484
|
-
return
|
|
485
|
-
throw new
|
|
534
|
+
const { [n]: s } = e || {};
|
|
535
|
+
if (s)
|
|
536
|
+
return s;
|
|
537
|
+
throw new v(`Plugin "${n}" not found in base or premium packages.`);
|
|
486
538
|
});
|
|
487
539
|
return {
|
|
488
540
|
loadedPlugins: await Promise.all(a),
|
|
489
541
|
hasPremium: !!e
|
|
490
542
|
};
|
|
491
543
|
}
|
|
492
|
-
function
|
|
544
|
+
function bt(r) {
|
|
493
545
|
return typeof r == "object" && r !== null && "$import" in r;
|
|
494
546
|
}
|
|
495
|
-
async function
|
|
547
|
+
async function Q(r, t) {
|
|
496
548
|
const e = [r.ui, r.content];
|
|
497
549
|
return await Promise.all(
|
|
498
550
|
[
|
|
499
|
-
|
|
551
|
+
J("ckeditor5", e),
|
|
500
552
|
/* v8 ignore next -- @preserve */
|
|
501
|
-
t &&
|
|
502
|
-
].filter((
|
|
503
|
-
).then((
|
|
553
|
+
t && J("ckeditor5-premium-features", e)
|
|
554
|
+
].filter((n) => !!n)
|
|
555
|
+
).then((n) => n.flat());
|
|
504
556
|
}
|
|
505
|
-
async function
|
|
557
|
+
async function J(r, t) {
|
|
506
558
|
return await Promise.all(
|
|
507
559
|
t.filter((e) => e !== "en").map(async (e) => {
|
|
508
|
-
const a = await
|
|
560
|
+
const a = await yt(r, e);
|
|
509
561
|
return a?.default ?? a;
|
|
510
562
|
}).filter(Boolean)
|
|
511
563
|
);
|
|
512
564
|
}
|
|
513
|
-
async function
|
|
565
|
+
async function yt(r, t) {
|
|
514
566
|
try {
|
|
515
567
|
if (r === "ckeditor5")
|
|
516
568
|
switch (t) {
|
|
@@ -810,12 +862,21 @@ async function pt(r, t) {
|
|
|
810
862
|
return console.error(`Failed to load translation for ${r}/${t}:`, e), null;
|
|
811
863
|
}
|
|
812
864
|
}
|
|
813
|
-
function
|
|
865
|
+
function Z(r) {
|
|
814
866
|
return W(r, (t) => ({
|
|
815
867
|
dictionary: t
|
|
816
868
|
}));
|
|
817
869
|
}
|
|
818
|
-
function
|
|
870
|
+
function tt(r) {
|
|
871
|
+
return r ? typeof r == "string" ? {
|
|
872
|
+
ui: r,
|
|
873
|
+
content: r
|
|
874
|
+
} : r : {
|
|
875
|
+
ui: "en",
|
|
876
|
+
content: "en"
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
function _() {
|
|
819
880
|
return Array.from(document.querySelectorAll("cke5-editor")).map((r) => r.getAttribute("data-cke-editor-id")).filter((r) => r !== null);
|
|
820
881
|
}
|
|
821
882
|
function et(r) {
|
|
@@ -827,91 +888,91 @@ function G(r) {
|
|
|
827
888
|
return st(e, (a) => typeof a == "string");
|
|
828
889
|
}
|
|
829
890
|
function rt(r) {
|
|
830
|
-
const t = Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${r}"]`)).reduce((o,
|
|
831
|
-
const
|
|
832
|
-
return o[
|
|
833
|
-
element:
|
|
834
|
-
content:
|
|
891
|
+
const t = Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${r}"]`)).reduce((o, s) => {
|
|
892
|
+
const c = s.getAttribute("data-cke-root-name"), u = s.getAttribute("data-cke-content");
|
|
893
|
+
return o[c] = {
|
|
894
|
+
element: s.querySelector("[data-cke-editable-content]"),
|
|
895
|
+
content: u
|
|
835
896
|
}, o;
|
|
836
897
|
}, /* @__PURE__ */ Object.create({})), e = document.querySelector(`cke5-editor[data-cke-editor-id="${r}"]`);
|
|
837
898
|
if (!e)
|
|
838
899
|
return t;
|
|
839
|
-
const a = t.main,
|
|
840
|
-
return a &&
|
|
900
|
+
const a = t.main, n = JSON.parse(e.getAttribute("data-cke-content")), i = document.querySelector(`#${r}_editor `);
|
|
901
|
+
return a && n?.main ? {
|
|
841
902
|
...t,
|
|
842
903
|
main: {
|
|
843
904
|
...a,
|
|
844
|
-
content: a.content ||
|
|
905
|
+
content: a.content || n.main
|
|
845
906
|
}
|
|
846
|
-
} :
|
|
907
|
+
} : i ? {
|
|
847
908
|
...t,
|
|
848
909
|
main: {
|
|
849
|
-
element:
|
|
850
|
-
content:
|
|
910
|
+
element: i,
|
|
911
|
+
content: n?.main || null
|
|
851
912
|
}
|
|
852
913
|
} : t;
|
|
853
914
|
}
|
|
854
|
-
function
|
|
915
|
+
function M(r) {
|
|
855
916
|
if (!r || typeof r != "object")
|
|
856
917
|
return r;
|
|
857
918
|
if (Array.isArray(r))
|
|
858
|
-
return r.map((a) =>
|
|
919
|
+
return r.map((a) => M(a));
|
|
859
920
|
const t = r;
|
|
860
921
|
if (t.$element && typeof t.$element == "string") {
|
|
861
922
|
const a = document.querySelector(t.$element);
|
|
862
923
|
return a || console.warn(`Element not found for selector: ${t.$element}`), a || null;
|
|
863
924
|
}
|
|
864
925
|
const e = /* @__PURE__ */ Object.create(null);
|
|
865
|
-
for (const [a,
|
|
866
|
-
e[a] =
|
|
926
|
+
for (const [a, n] of Object.entries(r))
|
|
927
|
+
e[a] = M(n);
|
|
867
928
|
return e;
|
|
868
929
|
}
|
|
869
930
|
function D(r, t, e) {
|
|
870
931
|
if (!e || typeof e != "object")
|
|
871
932
|
return e;
|
|
872
933
|
if (Array.isArray(e))
|
|
873
|
-
return e.map((
|
|
934
|
+
return e.map((i) => D(r, t, i));
|
|
874
935
|
const a = e;
|
|
875
936
|
if (a.$translation && typeof a.$translation == "string") {
|
|
876
|
-
const
|
|
877
|
-
return o === void 0 && console.warn(`Translation not found for key: ${
|
|
937
|
+
const i = a.$translation, o = Et(r, i, t);
|
|
938
|
+
return o === void 0 && console.warn(`Translation not found for key: ${i}`), o !== void 0 ? o : null;
|
|
878
939
|
}
|
|
879
|
-
const
|
|
880
|
-
for (const [
|
|
881
|
-
i
|
|
882
|
-
return
|
|
940
|
+
const n = /* @__PURE__ */ Object.create(null);
|
|
941
|
+
for (const [i, o] of Object.entries(e))
|
|
942
|
+
n[i] = D(r, t, o);
|
|
943
|
+
return n;
|
|
883
944
|
}
|
|
884
|
-
function
|
|
945
|
+
function Et(r, t, e) {
|
|
885
946
|
for (const a of r) {
|
|
886
|
-
const
|
|
887
|
-
if (
|
|
888
|
-
return
|
|
947
|
+
const n = a[e];
|
|
948
|
+
if (n?.dictionary && t in n.dictionary)
|
|
949
|
+
return n.dictionary[t];
|
|
889
950
|
}
|
|
890
951
|
}
|
|
891
|
-
function
|
|
952
|
+
function kt(r, t) {
|
|
892
953
|
const { editing: e } = r;
|
|
893
954
|
e.view.change((a) => {
|
|
894
955
|
a.setStyle("height", `${t}px`, e.view.document.getRoot());
|
|
895
956
|
});
|
|
896
957
|
}
|
|
897
958
|
const z = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
|
|
898
|
-
async function
|
|
959
|
+
async function vt(r, t) {
|
|
899
960
|
const { EditorWatchdog: e } = await import("ckeditor5"), a = new e(null, t ?? {
|
|
900
961
|
crashNumberLimit: 10,
|
|
901
962
|
minimumNonErrorTimePeriod: 5e3
|
|
902
963
|
});
|
|
903
964
|
return a.setCreator(async () => {
|
|
904
|
-
const
|
|
905
|
-
return
|
|
965
|
+
const n = await r();
|
|
966
|
+
return n[z] = a, n;
|
|
906
967
|
}), a;
|
|
907
968
|
}
|
|
908
|
-
function
|
|
969
|
+
function At(r) {
|
|
909
970
|
return z in r ? r[z] : null;
|
|
910
971
|
}
|
|
911
|
-
class
|
|
912
|
-
static the = new
|
|
972
|
+
class O extends Y {
|
|
973
|
+
static the = new O();
|
|
913
974
|
}
|
|
914
|
-
class
|
|
975
|
+
class Ct extends HTMLElement {
|
|
915
976
|
/**
|
|
916
977
|
* The promise that resolves to the context instance.
|
|
917
978
|
*/
|
|
@@ -924,35 +985,35 @@ class Et extends HTMLElement {
|
|
|
924
985
|
* Mounts the context component.
|
|
925
986
|
*/
|
|
926
987
|
async connectedCallback() {
|
|
927
|
-
await
|
|
988
|
+
await R(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeContext();
|
|
928
989
|
}
|
|
929
990
|
/**
|
|
930
991
|
* Initializes the context component.
|
|
931
992
|
*/
|
|
932
993
|
async initializeContext() {
|
|
933
|
-
const t = this.getAttribute("data-cke-context
|
|
934
|
-
...await
|
|
935
|
-
|
|
936
|
-
].filter((
|
|
994
|
+
const t = JSON.parse(this.getAttribute("data-cke-context")), { customTranslations: e, watchdogConfig: a, config: { plugins: n, ...i } } = t, o = this.getAttribute("data-cke-context-id"), s = this.getAttribute("data-cke-language") ? JSON.parse(this.getAttribute("data-cke-language")) : tt(i.language), { loadedPlugins: c, hasPremium: u } = await K(n ?? []), d = [
|
|
995
|
+
...await Q(s, u),
|
|
996
|
+
Z(e || {})
|
|
997
|
+
].filter((b) => !S(b));
|
|
937
998
|
this.contextPromise = (async () => {
|
|
938
|
-
const { ContextWatchdog:
|
|
999
|
+
const { ContextWatchdog: b, Context: y } = await import("ckeditor5"), w = new b(y, {
|
|
939
1000
|
crashNumberLimit: 10,
|
|
940
|
-
...
|
|
1001
|
+
...a
|
|
941
1002
|
});
|
|
942
|
-
let h =
|
|
943
|
-
return h = D([...
|
|
1003
|
+
let h = M(i);
|
|
1004
|
+
return h = D([...d].reverse(), s.ui, h), await w.create({
|
|
944
1005
|
...h,
|
|
945
|
-
language:
|
|
946
|
-
plugins:
|
|
947
|
-
...
|
|
948
|
-
translations:
|
|
1006
|
+
language: s,
|
|
1007
|
+
plugins: c,
|
|
1008
|
+
...d.length && {
|
|
1009
|
+
translations: d
|
|
949
1010
|
}
|
|
950
|
-
}),
|
|
951
|
-
console.error("Context item error:", ...
|
|
952
|
-
}),
|
|
1011
|
+
}), w.on("itemError", (...A) => {
|
|
1012
|
+
console.error("Context item error:", ...A);
|
|
1013
|
+
}), w;
|
|
953
1014
|
})();
|
|
954
|
-
const
|
|
955
|
-
this.isConnected &&
|
|
1015
|
+
const f = await this.contextPromise;
|
|
1016
|
+
this.isConnected && O.the.register(o, f);
|
|
956
1017
|
}
|
|
957
1018
|
/**
|
|
958
1019
|
* Destroys the context component. Unmounts root from the editor.
|
|
@@ -964,14 +1025,14 @@ class Et extends HTMLElement {
|
|
|
964
1025
|
try {
|
|
965
1026
|
await (await this.contextPromise)?.destroy();
|
|
966
1027
|
} finally {
|
|
967
|
-
this.contextPromise = null, t &&
|
|
1028
|
+
this.contextPromise = null, t && O.the.hasItem(t) && O.the.unregister(t);
|
|
968
1029
|
}
|
|
969
1030
|
}
|
|
970
1031
|
}
|
|
971
1032
|
class m extends Y {
|
|
972
1033
|
static the = new m();
|
|
973
1034
|
}
|
|
974
|
-
class
|
|
1035
|
+
class Ot extends HTMLElement {
|
|
975
1036
|
/**
|
|
976
1037
|
* Stops observing the editor registry and immediately runs any pending cleanup.
|
|
977
1038
|
*/
|
|
@@ -984,59 +1045,59 @@ class kt extends HTMLElement {
|
|
|
984
1045
|
* Mounts the editable component.
|
|
985
1046
|
*/
|
|
986
1047
|
async connectedCallback() {
|
|
987
|
-
await
|
|
1048
|
+
await R(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeEditable();
|
|
988
1049
|
}
|
|
989
1050
|
/**
|
|
990
1051
|
* Initializes the editable instance.
|
|
991
1052
|
*/
|
|
992
1053
|
async initializeEditable() {
|
|
993
|
-
this.hasAttribute("data-cke-editor-id") || this.setAttribute("data-cke-editor-id",
|
|
994
|
-
const t = this.getAttribute("data-cke-editor-id"), e = this.getAttribute("data-cke-root-name"), a = JSON.parse(this.getAttribute("data-cke-root-attributes") || "{}"),
|
|
1054
|
+
this.hasAttribute("data-cke-editor-id") || this.setAttribute("data-cke-editor-id", _()[0]);
|
|
1055
|
+
const t = this.getAttribute("data-cke-editor-id"), e = this.getAttribute("data-cke-root-name"), a = JSON.parse(this.getAttribute("data-cke-root-attributes") || "{}"), n = this.getAttribute("data-cke-content"), i = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10);
|
|
995
1056
|
if (!t || !e)
|
|
996
|
-
throw new
|
|
1057
|
+
throw new v("Editor ID or Root Name is missing.");
|
|
997
1058
|
this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (o) => {
|
|
998
1059
|
if (!this.isConnected)
|
|
999
1060
|
return;
|
|
1000
|
-
const { ui:
|
|
1001
|
-
if (
|
|
1002
|
-
if (
|
|
1061
|
+
const { ui: s, editing: c, model: u } = o, l = this.querySelector("input"), d = u.document.getRoot(e);
|
|
1062
|
+
if (d?.isAttached()) {
|
|
1063
|
+
if (n !== null) {
|
|
1003
1064
|
const h = o.getData({ rootName: e });
|
|
1004
|
-
h && h !==
|
|
1005
|
-
[e]:
|
|
1065
|
+
h && h !== n && o.setData({
|
|
1066
|
+
[e]: n
|
|
1006
1067
|
});
|
|
1007
1068
|
}
|
|
1008
|
-
|
|
1009
|
-
h.setAttributes(a,
|
|
1069
|
+
S(a) || o.model.change((h) => {
|
|
1070
|
+
h.setAttributes(a, d);
|
|
1010
1071
|
});
|
|
1011
1072
|
return;
|
|
1012
1073
|
}
|
|
1013
1074
|
o.addRoot(e, {
|
|
1014
1075
|
isUndoable: !1,
|
|
1015
|
-
|
|
1016
|
-
...
|
|
1017
|
-
|
|
1076
|
+
modelAttributes: { ...a },
|
|
1077
|
+
...n !== null && {
|
|
1078
|
+
initialData: n
|
|
1018
1079
|
}
|
|
1019
1080
|
});
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1081
|
+
const f = this.querySelector("[data-cke-editable-content]"), b = s.view.createEditable(e, f);
|
|
1082
|
+
s.addEditable(b), c.view.forceRender();
|
|
1022
1083
|
const y = () => {
|
|
1023
|
-
if (!
|
|
1084
|
+
if (!u.document.getRoot(e)?.isAttached())
|
|
1024
1085
|
return;
|
|
1025
1086
|
const h = o.getData({ rootName: e });
|
|
1026
|
-
|
|
1087
|
+
l && (l.value = h, l.dispatchEvent(new Event("input"))), this.dispatchEvent(new CustomEvent("change", {
|
|
1027
1088
|
detail: {
|
|
1028
1089
|
value: h
|
|
1029
1090
|
}
|
|
1030
1091
|
}));
|
|
1031
|
-
},
|
|
1032
|
-
return o.model.document.on("change:data",
|
|
1033
|
-
if (o.model.document.off("change:data",
|
|
1092
|
+
}, w = $(i, y);
|
|
1093
|
+
return o.model.document.on("change:data", w), y(), () => {
|
|
1094
|
+
if (o.model.document.off("change:data", w), o.state !== "destroyed" && e) {
|
|
1034
1095
|
const h = o.model.document.getRoot(e);
|
|
1035
1096
|
if (h && "detachEditable" in o) {
|
|
1036
1097
|
try {
|
|
1037
1098
|
o.ui.view.editables[e] && o.detachEditable(h);
|
|
1038
|
-
} catch (
|
|
1039
|
-
console.error("Unable unmount editable from root:",
|
|
1099
|
+
} catch (A) {
|
|
1100
|
+
console.error("Unable unmount editable from root:", A);
|
|
1040
1101
|
}
|
|
1041
1102
|
h.isAttached() && o.detachRoot(e, !1);
|
|
1042
1103
|
}
|
|
@@ -1051,7 +1112,7 @@ class kt extends HTMLElement {
|
|
|
1051
1112
|
this.interactiveWait?.disconnect(), this.style.display = "none", this.unmountEffect?.(), this.unmountEffect = null;
|
|
1052
1113
|
}
|
|
1053
1114
|
}
|
|
1054
|
-
async function
|
|
1115
|
+
async function It({
|
|
1055
1116
|
saveDebounceMs: r,
|
|
1056
1117
|
editorId: t,
|
|
1057
1118
|
targetElement: e
|
|
@@ -1068,34 +1129,34 @@ async function vt({
|
|
|
1068
1129
|
* Initializes the plugin.
|
|
1069
1130
|
*/
|
|
1070
1131
|
afterInit() {
|
|
1071
|
-
const { editor:
|
|
1072
|
-
|
|
1132
|
+
const { editor: i } = this, o = $(r, this.dispatch);
|
|
1133
|
+
i.model.document.on("change:data", o), i.once("ready", this.dispatch);
|
|
1073
1134
|
}
|
|
1074
1135
|
/**
|
|
1075
1136
|
* Dispatches a custom event with all roots data.
|
|
1076
1137
|
*/
|
|
1077
1138
|
dispatch = () => {
|
|
1078
|
-
const { editor:
|
|
1139
|
+
const { editor: i } = this;
|
|
1079
1140
|
e.dispatchEvent(
|
|
1080
|
-
new
|
|
1141
|
+
new k({
|
|
1081
1142
|
editorId: t,
|
|
1082
|
-
editor:
|
|
1083
|
-
roots: X(
|
|
1143
|
+
editor: i,
|
|
1144
|
+
roots: X(i)
|
|
1084
1145
|
})
|
|
1085
1146
|
);
|
|
1086
1147
|
};
|
|
1087
1148
|
};
|
|
1088
1149
|
}
|
|
1089
|
-
class
|
|
1150
|
+
class k extends CustomEvent {
|
|
1090
1151
|
static EVENT_NAME = "ckeditor5:change:data";
|
|
1091
1152
|
constructor(t) {
|
|
1092
|
-
super(
|
|
1153
|
+
super(k.EVENT_NAME, {
|
|
1093
1154
|
detail: t,
|
|
1094
1155
|
bubbles: !0
|
|
1095
1156
|
});
|
|
1096
1157
|
}
|
|
1097
1158
|
}
|
|
1098
|
-
async function
|
|
1159
|
+
async function Tt(r) {
|
|
1099
1160
|
const { Plugin: t } = await import("ckeditor5");
|
|
1100
1161
|
return class extends t {
|
|
1101
1162
|
/**
|
|
@@ -1116,8 +1177,8 @@ async function At(r) {
|
|
|
1116
1177
|
* Initializes the plugin.
|
|
1117
1178
|
*/
|
|
1118
1179
|
afterInit() {
|
|
1119
|
-
const { editor: a } = this,
|
|
1120
|
-
this.input = document.getElementById(`${
|
|
1180
|
+
const { editor: a } = this, i = a.sourceElement.id.replace(/_editor$/, "");
|
|
1181
|
+
this.input = document.getElementById(`${i}_input`), this.input && (a.model.document.on("change:data", $(r, () => this.sync())), a.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
|
|
1121
1182
|
}
|
|
1122
1183
|
/**
|
|
1123
1184
|
* Synchronizes the editor's content with the input field.
|
|
@@ -1136,7 +1197,7 @@ async function At(r) {
|
|
|
1136
1197
|
}
|
|
1137
1198
|
};
|
|
1138
1199
|
}
|
|
1139
|
-
class
|
|
1200
|
+
class Nt extends HTMLElement {
|
|
1140
1201
|
/**
|
|
1141
1202
|
* Stops observing the editor registry and immediately runs any pending cleanup.
|
|
1142
1203
|
*/
|
|
@@ -1149,7 +1210,7 @@ class Ct extends HTMLElement {
|
|
|
1149
1210
|
* Mounts the editor component.
|
|
1150
1211
|
*/
|
|
1151
1212
|
async connectedCallback() {
|
|
1152
|
-
await
|
|
1213
|
+
await R(), this.interactiveWait = L(this), H("classic"), await this.interactiveWait.promise, await this.initializeEditor();
|
|
1153
1214
|
}
|
|
1154
1215
|
/**
|
|
1155
1216
|
* Initializes the editor instance.
|
|
@@ -1159,15 +1220,15 @@ class Ct extends HTMLElement {
|
|
|
1159
1220
|
m.the.resetErrors(t);
|
|
1160
1221
|
try {
|
|
1161
1222
|
this.style.display = "block";
|
|
1162
|
-
const e = await this.createEditor(), a =
|
|
1223
|
+
const e = await this.createEditor(), a = gt(e), n = At(e);
|
|
1163
1224
|
if (this.isConnected) {
|
|
1164
|
-
const
|
|
1225
|
+
const i = m.the.mountEffect(t, (o) => {
|
|
1165
1226
|
o.once("destroy", () => {
|
|
1166
1227
|
m.the.unregister(t, !1);
|
|
1167
1228
|
}, { priority: "highest" });
|
|
1168
1229
|
});
|
|
1169
1230
|
this.unmountEffect = async () => {
|
|
1170
|
-
m.the.unregister(t),
|
|
1231
|
+
m.the.unregister(t), i(), a ? a.state !== "unavailable" && await a.context.remove(a.editorContextId) : n ? await n.destroy() : await e.destroy();
|
|
1171
1232
|
}, m.the.register(t, e);
|
|
1172
1233
|
}
|
|
1173
1234
|
} catch (e) {
|
|
@@ -1185,84 +1246,80 @@ class Ct extends HTMLElement {
|
|
|
1185
1246
|
* Creates the CKEditor instance.
|
|
1186
1247
|
*/
|
|
1187
1248
|
async createEditor() {
|
|
1188
|
-
const t =
|
|
1189
|
-
customTranslations:
|
|
1190
|
-
editorType:
|
|
1191
|
-
licenseKey:
|
|
1192
|
-
watchdogConfig:
|
|
1193
|
-
config: { plugins:
|
|
1194
|
-
} =
|
|
1195
|
-
const { loadedPlugins:
|
|
1196
|
-
|
|
1197
|
-
await
|
|
1198
|
-
saveDebounceMs:
|
|
1199
|
-
editorId:
|
|
1249
|
+
const t = JSON.parse(this.getAttribute("data-cke-preset")), {
|
|
1250
|
+
customTranslations: e,
|
|
1251
|
+
editorType: a,
|
|
1252
|
+
licenseKey: n,
|
|
1253
|
+
watchdogConfig: i,
|
|
1254
|
+
config: { plugins: o, ...s }
|
|
1255
|
+
} = t, c = this.getAttribute("data-cke-editor-id"), u = this.getAttribute("data-cke-context-id"), l = JSON.parse(this.getAttribute("data-cke-root-attributes") || "{}"), d = this.getAttribute("data-cke-editable-height") ? Number.parseInt(this.getAttribute("data-cke-editable-height"), 10) : null, f = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10), b = this.hasAttribute("data-cke-watchdog"), y = JSON.parse(this.getAttribute("data-cke-content")), w = this.getAttribute("data-cke-language") ? JSON.parse(this.getAttribute("data-cke-language")) : tt(t.config.language), h = await H(a), A = await (u ? O.the.waitFor(u) : null), q = async () => {
|
|
1256
|
+
const { loadedPlugins: E, hasPremium: N } = await K(o);
|
|
1257
|
+
E.push(
|
|
1258
|
+
await It({
|
|
1259
|
+
saveDebounceMs: f,
|
|
1260
|
+
editorId: c,
|
|
1200
1261
|
targetElement: this
|
|
1201
1262
|
})
|
|
1202
|
-
),
|
|
1203
|
-
await
|
|
1263
|
+
), T(a) && E.push(
|
|
1264
|
+
await Tt(f)
|
|
1204
1265
|
);
|
|
1205
|
-
const
|
|
1206
|
-
...await
|
|
1207
|
-
|
|
1208
|
-
].filter((
|
|
1266
|
+
const C = [
|
|
1267
|
+
...await Q(w, N),
|
|
1268
|
+
Z(e || {})
|
|
1269
|
+
].filter((p) => !S(p));
|
|
1209
1270
|
let I = {
|
|
1210
|
-
...
|
|
1211
|
-
...G(
|
|
1271
|
+
...y,
|
|
1272
|
+
...G(c)
|
|
1212
1273
|
};
|
|
1213
|
-
|
|
1214
|
-
const
|
|
1215
|
-
let
|
|
1216
|
-
if (!
|
|
1217
|
-
const
|
|
1218
|
-
at(
|
|
1219
|
-
...
|
|
1220
|
-
...G(
|
|
1274
|
+
T(a) && (I = I.main || "");
|
|
1275
|
+
const P = await (async () => {
|
|
1276
|
+
let p = et(c);
|
|
1277
|
+
if (!p.main) {
|
|
1278
|
+
const U = T(a) ? ["main"] : Object.keys(I);
|
|
1279
|
+
at(p, U) || (p = await Pt(c, U), I = {
|
|
1280
|
+
...y,
|
|
1281
|
+
...G(c)
|
|
1221
1282
|
});
|
|
1222
1283
|
}
|
|
1223
|
-
|
|
1224
|
-
let
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
language: c,
|
|
1232
|
-
...A.length && {
|
|
1233
|
-
translations: A
|
|
1284
|
+
T(a) && "main" in p && (p = p.main);
|
|
1285
|
+
let g = {
|
|
1286
|
+
...s,
|
|
1287
|
+
licenseKey: n,
|
|
1288
|
+
plugins: E,
|
|
1289
|
+
language: w,
|
|
1290
|
+
...C.length && {
|
|
1291
|
+
translations: C
|
|
1234
1292
|
}
|
|
1235
1293
|
};
|
|
1236
|
-
return
|
|
1237
|
-
context:
|
|
1238
|
-
element: f,
|
|
1294
|
+
return g = M(g), g = D([...C].reverse(), w.ui, g), g = ht(h, p, g), g = dt(I, g), A ? (await wt({
|
|
1295
|
+
context: A,
|
|
1239
1296
|
creator: h,
|
|
1240
|
-
config:
|
|
1241
|
-
})).editor;
|
|
1297
|
+
config: g
|
|
1298
|
+
})).editor : h.create(g);
|
|
1242
1299
|
})();
|
|
1243
|
-
return
|
|
1244
|
-
|
|
1245
|
-
}),
|
|
1300
|
+
return S(l) || P.model.change((p) => {
|
|
1301
|
+
p.setAttributes(l, P.model.document.getRoot());
|
|
1302
|
+
}), T(a) && d && kt(P, d), P;
|
|
1246
1303
|
};
|
|
1247
|
-
if (
|
|
1248
|
-
const
|
|
1249
|
-
return
|
|
1250
|
-
if (
|
|
1251
|
-
const
|
|
1252
|
-
|
|
1304
|
+
if (b && !A) {
|
|
1305
|
+
const E = await vt(q, i);
|
|
1306
|
+
return E.on("error", (N, { causesRestart: F }) => {
|
|
1307
|
+
if (F) {
|
|
1308
|
+
const C = m.the.getItem(c);
|
|
1309
|
+
C && (pt(C), m.the.unregister(c));
|
|
1253
1310
|
}
|
|
1254
|
-
}),
|
|
1255
|
-
const
|
|
1256
|
-
m.the.register(
|
|
1257
|
-
}), await
|
|
1311
|
+
}), E.on("restart", () => {
|
|
1312
|
+
const N = E.editor;
|
|
1313
|
+
m.the.register(c, N);
|
|
1314
|
+
}), await E.create({}), E.editor;
|
|
1258
1315
|
}
|
|
1259
|
-
return
|
|
1316
|
+
return q();
|
|
1260
1317
|
}
|
|
1261
1318
|
}
|
|
1262
1319
|
function at(r, t) {
|
|
1263
1320
|
return t.every((e) => r[e]);
|
|
1264
1321
|
}
|
|
1265
|
-
async function
|
|
1322
|
+
async function Pt(r, t) {
|
|
1266
1323
|
return lt(
|
|
1267
1324
|
() => {
|
|
1268
1325
|
const e = et(r);
|
|
@@ -1278,7 +1335,7 @@ Missing roots: ${t.filter((a) => !e[a]).join(", ")}.`
|
|
|
1278
1335
|
{ timeOutAfter: 2e3, retryAfter: 100 }
|
|
1279
1336
|
);
|
|
1280
1337
|
}
|
|
1281
|
-
class
|
|
1338
|
+
class St extends HTMLElement {
|
|
1282
1339
|
/**
|
|
1283
1340
|
* Stops observing the editor registry and immediately runs any pending cleanup.
|
|
1284
1341
|
*/
|
|
@@ -1287,14 +1344,14 @@ class Ot extends HTMLElement {
|
|
|
1287
1344
|
* Mounts the UI part component.
|
|
1288
1345
|
*/
|
|
1289
1346
|
async connectedCallback() {
|
|
1290
|
-
await
|
|
1291
|
-
const t = this.getAttribute("data-cke-editor-id") ||
|
|
1347
|
+
await R();
|
|
1348
|
+
const t = this.getAttribute("data-cke-editor-id") || _()[0], e = this.getAttribute("data-cke-name");
|
|
1292
1349
|
!t || !e || (this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (a) => {
|
|
1293
1350
|
if (!this.isConnected)
|
|
1294
1351
|
return;
|
|
1295
|
-
const { ui:
|
|
1352
|
+
const { ui: n } = a, i = Mt(e), o = n.view[i];
|
|
1296
1353
|
if (!o)
|
|
1297
|
-
throw new
|
|
1354
|
+
throw new v(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
|
|
1298
1355
|
return this.appendChild(o.element), () => {
|
|
1299
1356
|
this.innerHTML = "";
|
|
1300
1357
|
};
|
|
@@ -1307,7 +1364,7 @@ class Ot extends HTMLElement {
|
|
|
1307
1364
|
this.style.display = "none", this.unmountEffect?.(), this.unmountEffect = null;
|
|
1308
1365
|
}
|
|
1309
1366
|
}
|
|
1310
|
-
function
|
|
1367
|
+
function Mt(r) {
|
|
1311
1368
|
switch (r) {
|
|
1312
1369
|
case "toolbar":
|
|
1313
1370
|
return "toolbar";
|
|
@@ -1318,23 +1375,23 @@ function Tt(r) {
|
|
|
1318
1375
|
return null;
|
|
1319
1376
|
}
|
|
1320
1377
|
}
|
|
1321
|
-
const
|
|
1322
|
-
"cke5-editor":
|
|
1323
|
-
"cke5-context":
|
|
1324
|
-
"cke5-ui-part":
|
|
1325
|
-
"cke5-editable":
|
|
1378
|
+
const Dt = {
|
|
1379
|
+
"cke5-editor": Nt,
|
|
1380
|
+
"cke5-context": Ct,
|
|
1381
|
+
"cke5-ui-part": St,
|
|
1382
|
+
"cke5-editable": Ot
|
|
1326
1383
|
};
|
|
1327
|
-
function
|
|
1328
|
-
for (const [r, t] of Object.entries(
|
|
1384
|
+
function Rt() {
|
|
1385
|
+
for (const [r, t] of Object.entries(Dt))
|
|
1329
1386
|
window.customElements.get(r) || window.customElements.define(r, t);
|
|
1330
1387
|
}
|
|
1331
|
-
function
|
|
1388
|
+
function Lt(r) {
|
|
1332
1389
|
return x(r), {
|
|
1333
1390
|
unmount() {
|
|
1334
1391
|
}
|
|
1335
1392
|
};
|
|
1336
1393
|
}
|
|
1337
|
-
function
|
|
1394
|
+
function nt(r, t) {
|
|
1338
1395
|
const e = {
|
|
1339
1396
|
/** Value received from Blazor while the editor was focused, pending application on blur. */
|
|
1340
1397
|
pendingValue: null,
|
|
@@ -1342,19 +1399,19 @@ function it(r, t) {
|
|
|
1342
1399
|
lastSyncedValue: null
|
|
1343
1400
|
}, a = () => {
|
|
1344
1401
|
e.pendingValue = null;
|
|
1345
|
-
},
|
|
1346
|
-
if (
|
|
1402
|
+
}, n = (i, o, s) => {
|
|
1403
|
+
if (s || e.pendingValue === null)
|
|
1347
1404
|
return;
|
|
1348
|
-
const
|
|
1349
|
-
t.isEqual(
|
|
1405
|
+
const c = t.getCurrentValue();
|
|
1406
|
+
t.isEqual(c, e.pendingValue) || t.applyValue(e.pendingValue), e.pendingValue = null;
|
|
1350
1407
|
};
|
|
1351
|
-
return r.model.document.on("change:data", a), r.ui.focusTracker.on("change:isFocused",
|
|
1408
|
+
return r.model.document.on("change:data", a), r.ui.focusTracker.on("change:isFocused", n), {
|
|
1352
1409
|
/**
|
|
1353
1410
|
* Removes all editor listeners registered by this sync instance.
|
|
1354
1411
|
* Call this when the Blazor component is disposed.
|
|
1355
1412
|
*/
|
|
1356
1413
|
unmount() {
|
|
1357
|
-
r.model.document.off("change:data", a), r.ui.focusTracker.off("change:isFocused",
|
|
1414
|
+
r.model.document.off("change:data", a), r.ui.focusTracker.off("change:isFocused", n);
|
|
1358
1415
|
},
|
|
1359
1416
|
/**
|
|
1360
1417
|
* Checks whether the given value differs from the last synced value and, if so,
|
|
@@ -1363,24 +1420,24 @@ function it(r, t) {
|
|
|
1363
1420
|
* Call this from the `CKEditor5ChangeDataEvent` handler to conditionally invoke
|
|
1364
1421
|
* the .NET interop method.
|
|
1365
1422
|
*/
|
|
1366
|
-
shouldNotify(
|
|
1367
|
-
return e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue,
|
|
1423
|
+
shouldNotify(i) {
|
|
1424
|
+
return e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, i) ? !1 : (e.lastSyncedValue = i, !0);
|
|
1368
1425
|
},
|
|
1369
1426
|
/**
|
|
1370
1427
|
* Pushes a new value from Blazor into the editor.
|
|
1371
1428
|
* If the editor is currently focused, the update is deferred until blur.
|
|
1372
1429
|
* If the value matches the last synced state, the update is skipped entirely.
|
|
1373
1430
|
*/
|
|
1374
|
-
setValue(
|
|
1431
|
+
setValue(i) {
|
|
1375
1432
|
if (r.ui.focusTracker.isFocused) {
|
|
1376
|
-
e.pendingValue =
|
|
1433
|
+
e.pendingValue = i;
|
|
1377
1434
|
return;
|
|
1378
1435
|
}
|
|
1379
|
-
e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue,
|
|
1436
|
+
e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, i) || (e.lastSyncedValue = i, t.applyValue(i));
|
|
1380
1437
|
}
|
|
1381
1438
|
};
|
|
1382
1439
|
}
|
|
1383
|
-
function
|
|
1440
|
+
function it() {
|
|
1384
1441
|
return {
|
|
1385
1442
|
unmount() {
|
|
1386
1443
|
},
|
|
@@ -1394,92 +1451,92 @@ function nt() {
|
|
|
1394
1451
|
function ot(r, t) {
|
|
1395
1452
|
const e = /* @__PURE__ */ new Set();
|
|
1396
1453
|
return (a) => {
|
|
1397
|
-
r.model.enqueueChange({ isUndoable: !1 }, (
|
|
1398
|
-
const
|
|
1399
|
-
if (
|
|
1454
|
+
r.model.enqueueChange({ isUndoable: !1 }, (n) => {
|
|
1455
|
+
const i = r.model.document.getRoot(t);
|
|
1456
|
+
if (i) {
|
|
1400
1457
|
for (const o of e)
|
|
1401
|
-
a && o in a || (
|
|
1402
|
-
for (const [o,
|
|
1403
|
-
|
|
1458
|
+
a && o in a || (n.removeAttribute(o, i), e.delete(o));
|
|
1459
|
+
for (const [o, s] of Object.entries(a ?? {}))
|
|
1460
|
+
n.setAttribute(o, s, i), e.add(o);
|
|
1404
1461
|
}
|
|
1405
1462
|
});
|
|
1406
1463
|
};
|
|
1407
1464
|
}
|
|
1408
|
-
function
|
|
1409
|
-
const e = r.getAttribute("data-cke-editor-id") ??
|
|
1410
|
-
let
|
|
1411
|
-
const
|
|
1412
|
-
if (!(
|
|
1465
|
+
function jt(r, t) {
|
|
1466
|
+
const e = r.getAttribute("data-cke-editor-id") ?? _()[0], a = r.getAttribute("data-cke-root-name") ?? "main";
|
|
1467
|
+
let n = !1, i = null, o = null, s = it(), c = null;
|
|
1468
|
+
const u = (l) => {
|
|
1469
|
+
if (!(l instanceof k) || l.detail.editorId !== e)
|
|
1413
1470
|
return;
|
|
1414
|
-
const
|
|
1415
|
-
|
|
1471
|
+
const d = l.detail.roots[a];
|
|
1472
|
+
d !== void 0 && s.shouldNotify(d) && t.invokeMethodAsync("OnChangeEditableData", o, d);
|
|
1416
1473
|
};
|
|
1417
|
-
return
|
|
1418
|
-
getCurrentValue: () =>
|
|
1419
|
-
applyValue: (
|
|
1420
|
-
isEqual: (
|
|
1421
|
-
}),
|
|
1422
|
-
|
|
1423
|
-
})), document.body.addEventListener(
|
|
1474
|
+
return i = m.the.mountEffect(e, (l) => (o = globalThis.DotNet.createJSObjectReference(l), s = nt(l, {
|
|
1475
|
+
getCurrentValue: () => l.getData({ rootName: a }) ?? "",
|
|
1476
|
+
applyValue: (d) => l.setData({ [a]: d }),
|
|
1477
|
+
isEqual: (d, f) => d === f
|
|
1478
|
+
}), c = ot(l, a), () => {
|
|
1479
|
+
s.unmount(), o && (globalThis.DotNet?.disposeJSObjectReference(o), o = null), c = null;
|
|
1480
|
+
})), document.body.addEventListener(k.EVENT_NAME, u), x(r), {
|
|
1424
1481
|
/**
|
|
1425
1482
|
* Cleans up all event listeners when the Blazor component is disposed.
|
|
1426
1483
|
*/
|
|
1427
1484
|
unmount() {
|
|
1428
|
-
|
|
1485
|
+
n || (document.body.removeEventListener(k.EVENT_NAME, u), i?.(), i = null, n = !0);
|
|
1429
1486
|
},
|
|
1430
1487
|
/**
|
|
1431
1488
|
* Updates this editable root's data from Blazor.
|
|
1432
1489
|
* If the editor is focused, the update is deferred until blur to avoid interrupting the user.
|
|
1433
1490
|
*/
|
|
1434
|
-
setValue: async (
|
|
1435
|
-
|
|
1491
|
+
setValue: async (l) => {
|
|
1492
|
+
n || (await m.the.waitFor(e), s.setValue(l));
|
|
1436
1493
|
},
|
|
1437
1494
|
/**
|
|
1438
1495
|
* Updates the root attributes on the editor. This is useful when the Blazor component
|
|
1439
1496
|
* re-renders with new root attributes.
|
|
1440
1497
|
*/
|
|
1441
|
-
setRootAttributes: async (
|
|
1442
|
-
|
|
1498
|
+
setRootAttributes: async (l) => {
|
|
1499
|
+
n || (await m.the.waitFor(e), c?.(l));
|
|
1443
1500
|
}
|
|
1444
1501
|
};
|
|
1445
1502
|
}
|
|
1446
|
-
function
|
|
1503
|
+
function _t(r, t) {
|
|
1447
1504
|
const e = r.getAttribute("data-cke-editor-id");
|
|
1448
|
-
let a = !1,
|
|
1449
|
-
const
|
|
1450
|
-
!(
|
|
1505
|
+
let a = !1, n = null, i = it(), o = null, s = null;
|
|
1506
|
+
const c = (u) => {
|
|
1507
|
+
!(u instanceof k) || u.detail.editorId !== e || i.shouldNotify(u.detail.roots) && t.invokeMethodAsync("OnChangeEditorData", s, u.detail.roots);
|
|
1451
1508
|
};
|
|
1452
|
-
return
|
|
1453
|
-
|
|
1454
|
-
getCurrentValue: () => X(
|
|
1455
|
-
applyValue: (
|
|
1509
|
+
return n = m.the.mountEffect(e, (u) => {
|
|
1510
|
+
s = globalThis.DotNet.createJSObjectReference(u), i = nt(u, {
|
|
1511
|
+
getCurrentValue: () => X(u),
|
|
1512
|
+
applyValue: (d) => u.setData(d),
|
|
1456
1513
|
isEqual: ct
|
|
1457
|
-
}), o = ot(
|
|
1458
|
-
const
|
|
1459
|
-
const y =
|
|
1460
|
-
t.invokeMethodAsync(y,
|
|
1514
|
+
}), o = ot(u, "main");
|
|
1515
|
+
const l = (d, f, b) => {
|
|
1516
|
+
const y = b ? "OnEditorFocus" : "OnEditorBlur";
|
|
1517
|
+
t.invokeMethodAsync(y, s);
|
|
1461
1518
|
};
|
|
1462
|
-
return
|
|
1463
|
-
|
|
1519
|
+
return u.ui.focusTracker.on("change:isFocused", l), t.invokeMethodAsync("OnEditorReady", s), () => {
|
|
1520
|
+
u.ui.focusTracker.off("change:isFocused", l), i.unmount(), s && (globalThis.DotNet?.disposeJSObjectReference(s), s = null), o = null;
|
|
1464
1521
|
};
|
|
1465
|
-
}), document.body.addEventListener(
|
|
1522
|
+
}), document.body.addEventListener(k.EVENT_NAME, c), Rt(), x(r), {
|
|
1466
1523
|
/**
|
|
1467
1524
|
* Updates the editor data from Blazor. If the editor is focused, the update is deferred until blur to avoid interrupting the user.
|
|
1468
1525
|
*/
|
|
1469
|
-
setValue: async (
|
|
1470
|
-
a || (await m.the.waitFor(e),
|
|
1526
|
+
setValue: async (u) => {
|
|
1527
|
+
a || (await m.the.waitFor(e), i.setValue(u));
|
|
1471
1528
|
},
|
|
1472
1529
|
/**
|
|
1473
1530
|
* Updates the root attributes on the editor instance.
|
|
1474
1531
|
*/
|
|
1475
|
-
setRootAttributes: async (
|
|
1476
|
-
a || (await m.the.waitFor(e), o?.(
|
|
1532
|
+
setRootAttributes: async (u) => {
|
|
1533
|
+
a || (await m.the.waitFor(e), o?.(u));
|
|
1477
1534
|
},
|
|
1478
1535
|
/**
|
|
1479
1536
|
* Cleans up all event listeners when the Blazor component is disposed.
|
|
1480
1537
|
*/
|
|
1481
1538
|
unmount() {
|
|
1482
|
-
a || (document.body.removeEventListener(
|
|
1539
|
+
a || (document.body.removeEventListener(k.EVENT_NAME, c), n?.(), n = null, a = !0);
|
|
1483
1540
|
},
|
|
1484
1541
|
/**
|
|
1485
1542
|
* Installs the custom image upload adapter that delegates uploads to Blazor.
|
|
@@ -1487,68 +1544,68 @@ function $t(r, t) {
|
|
|
1487
1544
|
* to avoid unnecessary overhead for consumers that don't use this feature.
|
|
1488
1545
|
*/
|
|
1489
1546
|
attachImageUploadAdapter: async () => {
|
|
1490
|
-
a || m.the.mountEffect(e, (
|
|
1491
|
-
|
|
1547
|
+
a || m.the.mountEffect(e, (u) => {
|
|
1548
|
+
xt(u, t);
|
|
1492
1549
|
});
|
|
1493
1550
|
}
|
|
1494
1551
|
};
|
|
1495
1552
|
}
|
|
1496
|
-
function
|
|
1553
|
+
function xt(r, t) {
|
|
1497
1554
|
if (!r.plugins.has("FileRepository"))
|
|
1498
1555
|
return;
|
|
1499
1556
|
const e = r.plugins.get("FileRepository");
|
|
1500
1557
|
e.createUploadAdapter = (a) => {
|
|
1501
|
-
let
|
|
1558
|
+
let n = !1;
|
|
1502
1559
|
return {
|
|
1503
1560
|
async upload() {
|
|
1504
|
-
const
|
|
1505
|
-
if (
|
|
1561
|
+
const i = await a.file;
|
|
1562
|
+
if (n)
|
|
1506
1563
|
throw new Error("Upload aborted.");
|
|
1507
|
-
const o = await
|
|
1508
|
-
fileName:
|
|
1509
|
-
mimeType:
|
|
1564
|
+
const o = await Vt(i), s = await t.invokeMethodAsync("OnEditorImageUpload", {
|
|
1565
|
+
fileName: i.name,
|
|
1566
|
+
mimeType: i.type,
|
|
1510
1567
|
payload: o
|
|
1511
1568
|
});
|
|
1512
|
-
if (!
|
|
1569
|
+
if (!s)
|
|
1513
1570
|
throw new Error(
|
|
1514
1571
|
"OnImageUpload handler returned null. Make sure the OnImageUpload parameter is set on the <CKE5Editor> component."
|
|
1515
1572
|
);
|
|
1516
|
-
return { default:
|
|
1573
|
+
return { default: s };
|
|
1517
1574
|
},
|
|
1518
1575
|
abort() {
|
|
1519
|
-
|
|
1576
|
+
n = !0;
|
|
1520
1577
|
}
|
|
1521
1578
|
};
|
|
1522
1579
|
};
|
|
1523
1580
|
}
|
|
1524
|
-
function
|
|
1581
|
+
function Vt(r) {
|
|
1525
1582
|
return new Promise((t, e) => {
|
|
1526
1583
|
const a = new FileReader();
|
|
1527
1584
|
a.onload = () => {
|
|
1528
|
-
const
|
|
1529
|
-
t(
|
|
1585
|
+
const n = a.result, i = n.split(",")[1] ?? n;
|
|
1586
|
+
t(i);
|
|
1530
1587
|
}, a.onerror = () => e(a.error), a.readAsDataURL(r);
|
|
1531
1588
|
});
|
|
1532
1589
|
}
|
|
1533
|
-
function
|
|
1590
|
+
function qt(r) {
|
|
1534
1591
|
return x(r), {
|
|
1535
1592
|
unmount() {
|
|
1536
1593
|
}
|
|
1537
1594
|
};
|
|
1538
1595
|
}
|
|
1539
1596
|
export {
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1597
|
+
v as CKEditor5BlazorError,
|
|
1598
|
+
k as CKEditor5ChangeDataEvent,
|
|
1599
|
+
O as ContextsRegistry,
|
|
1600
|
+
j as CustomEditorPluginsRegistry,
|
|
1601
|
+
Ot as EditableComponentElement,
|
|
1602
|
+
Nt as EditorComponentElement,
|
|
1546
1603
|
m as EditorsRegistry,
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1604
|
+
St as UIPartComponentElement,
|
|
1605
|
+
Lt as createContextBlazorInterop,
|
|
1606
|
+
jt as createEditableBlazorInterop,
|
|
1607
|
+
_t as createEditorBlazorInterop,
|
|
1608
|
+
qt as createUIPartBlazorInterop,
|
|
1609
|
+
Rt as ensureEditorElementsRegistered
|
|
1553
1610
|
};
|
|
1554
1611
|
//# sourceMappingURL=index.mjs.map
|