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