ckeditor5-blazor 1.10.2 → 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.
Files changed (33) hide show
  1. package/dist/elements/context/context.d.ts.map +1 -1
  2. package/dist/elements/editor/editor.d.ts.map +1 -1
  3. package/dist/elements/editor/types/editor-relaxed-constructor.type.d.ts +6 -0
  4. package/dist/elements/editor/types/editor-relaxed-constructor.type.d.ts.map +1 -0
  5. package/dist/elements/editor/types/index.d.ts +2 -0
  6. package/dist/elements/editor/types/index.d.ts.map +1 -0
  7. package/dist/elements/editor/utils/assign-initial-data-to-editor-config.d.ts +10 -0
  8. package/dist/elements/editor/utils/assign-initial-data-to-editor-config.d.ts.map +1 -0
  9. package/dist/elements/editor/utils/assign-source-elements-to-editor-config.d.ts +12 -0
  10. package/dist/elements/editor/utils/assign-source-elements-to-editor-config.d.ts.map +1 -0
  11. package/dist/elements/editor/utils/create-editor-in-context.d.ts +1 -3
  12. package/dist/elements/editor/utils/create-editor-in-context.d.ts.map +1 -1
  13. package/dist/elements/editor/utils/index.d.ts +3 -0
  14. package/dist/elements/editor/utils/index.d.ts.map +1 -1
  15. package/dist/elements/editor/utils/normalize-editor-language.d.ts +9 -0
  16. package/dist/elements/editor/utils/normalize-editor-language.d.ts.map +1 -0
  17. package/dist/index.cjs +2 -2
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.mjs +410 -353
  20. package/dist/index.mjs.map +1 -1
  21. package/package.json +3 -3
  22. package/src/elements/context/context.test.ts +107 -66
  23. package/src/elements/context/context.ts +9 -3
  24. package/src/elements/editable.ts +2 -2
  25. package/src/elements/editor/editor.ts +33 -29
  26. package/src/elements/editor/types/editor-relaxed-constructor.type.ts +6 -0
  27. package/src/elements/editor/types/index.ts +1 -0
  28. package/src/elements/editor/utils/assign-initial-data-to-editor-config.ts +47 -0
  29. package/src/elements/editor/utils/assign-source-elements-to-editor-config.ts +59 -0
  30. package/src/elements/editor/utils/create-editor-in-context.ts +2 -5
  31. package/src/elements/editor/utils/index.ts +3 -0
  32. package/src/elements/editor/utils/normalize-editor-language.test.ts +50 -0
  33. package/src/elements/editor/utils/normalize-editor-language.ts +25 -0
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- class k extends Error {
1
+ class v extends Error {
2
2
  constructor(t) {
3
3
  super(t), this.name = "CKEditor5BlazorError";
4
4
  }
5
5
  }
6
- function H(r, t) {
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 i = this.items.get(t), n = this.initializationErrors.get(t);
51
- return n ? (a?.(n), Promise.reject(n)) : i ? Promise.resolve(e(i)) : new Promise((o, c) => {
52
- const u = this.getPendingCallbacks(t);
53
- u.success.push(async (s) => {
54
- o(await e(s));
55
- }), a ? u.error.push(a) : u.error.push(c);
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, i, n = !1;
67
- const o = this.watch((c) => {
68
- const u = c.get(t);
69
- if (u !== i && (a?.(), a = void 0, i = u, !!u))
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 s = e(u);
72
- n ? (s?.(), o()) : a = s;
73
- } catch (s) {
74
- throw console.error(s), s;
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
- n = !0, i && (o(), a?.(), a = void 0);
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((i) => i(e)), this.pendingCallbacks.delete(t)), this.items.size === 1 && t !== null && this.register(null, e);
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((i) => i(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e);
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
- H(this.lastNotifiedItems, this.items) && H(this.lastNotifiedErrors, this.initializationErrors) || (this.lastNotifiedItems = new Map(this.items), this.lastNotifiedErrors = new Map(this.initializationErrors), this.watchers.forEach((t) => t(
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, i]) => t(i, a));
248
+ const e = Object.entries(r).filter(([a, n]) => t(n, a));
249
249
  return Object.fromEntries(e);
250
250
  }
251
- function P(r) {
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, i]) => [a, t(i, 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 i of e)
265
- if (r[i] !== t[i] || !Object.prototype.hasOwnProperty.call(t, i))
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, i) => {
277
- const n = Date.now();
276
+ return new Promise((a, n) => {
277
+ const i = Date.now();
278
278
  let o = null;
279
- const c = setTimeout(() => {
280
- i(o ?? new Error("Timeout"));
281
- }, t), u = async () => {
279
+ const s = setTimeout(() => {
280
+ n(o ?? new Error("Timeout"));
281
+ }, t), c = async () => {
282
282
  try {
283
- const s = await r();
284
- clearTimeout(c), a(s);
285
- } catch (s) {
286
- o = s, Date.now() - n > t ? i(s) : setTimeout(u, e);
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
- u();
289
+ c();
290
290
  });
291
291
  }
292
- function M() {
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((i) => {
315
- for (const n of i)
316
- if (n.type === "attributes" && n.attributeName === "data-cke-interactive" && r.hasAttribute("data-cke-interactive")) {
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 n of t)
335
- i(n);
387
+ for (const i of t)
388
+ n(i);
336
389
  const e = r.ui?.view?.body?._bodyCollectionContainer;
337
- e?.isConnected && i(e);
390
+ e?.isConnected && n(e);
338
391
  const a = r.editing?.view;
339
392
  if (a)
340
- for (const n of a.domRoots.values())
341
- n instanceof HTMLElement && (n.removeAttribute("contenteditable"), n.removeAttribute("role"), n.removeAttribute("aria-label"), n.removeAttribute("aria-multiline"), n.removeAttribute("spellcheck"), n.classList.remove(
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(n));
350
- function i(n) {
351
- n.hasAttribute("data-cke-controlled") ? n.innerHTML = "" : n.remove();
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 mt({ element: r, context: t, creator: e, config: a }) {
356
- const i = ut();
357
- await t.add({
358
- creator: (u, s) => e.create(u, s),
359
- id: i,
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: a
414
+ config: e
363
415
  });
364
- const n = t.getItem(i), o = {
416
+ const n = r.getItem(a), i = {
365
417
  state: "available",
366
- editorContextId: i,
367
- context: t
418
+ editorContextId: a,
419
+ context: r
368
420
  };
369
- n[V] = o;
370
- const c = t.destroy.bind(t);
371
- return t.destroy = async () => (o.state = "unavailable", c()), {
372
- ...o,
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 ht(r) {
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 O(r) {
434
+ function T(r) {
383
435
  return ["inline", "classic", "balloon", "decoupled"].includes(r);
384
436
  }
385
- async function J(r) {
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 k(`Unsupported editor type: ${r}`);
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 k(`Plugin with name "${t}" is already registered.`);
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 k(`Plugin with name "${t}" is not registered.`);
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 Q(r) {
509
+ async function K(r) {
458
510
  const t = await import("ckeditor5");
459
511
  let e = null;
460
- const a = r.map(async (i) => {
461
- if (ft(i)) {
462
- const { name: u, path: s } = i.$import, l = await import(
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
- s
465
- ), p = (Object.prototype.hasOwnProperty.call(l, u) ? l[u] : void 0) ?? (Object.prototype.hasOwnProperty.call(l, "default") ? l.default : void 0);
466
- if (!p)
467
- throw new k(`Plugin "${u}" not found in module "${s}".`);
468
- return p;
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 n = await _.the.get(i);
471
- if (n)
472
- return n;
473
- const { [i]: o } = t;
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 (u) {
480
- throw console.error(`Failed to load premium package: ${u}`), new k(`Plugin "${i}" not found in base package and 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 { [i]: c } = e || {};
483
- if (c)
484
- return c;
485
- throw new k(`Plugin "${i}" not found in base or premium packages.`);
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 ft(r) {
544
+ function bt(r) {
493
545
  return typeof r == "object" && r !== null && "$import" in r;
494
546
  }
495
- async function Z(r, t) {
547
+ async function Q(r, t) {
496
548
  const e = [r.ui, r.content];
497
549
  return await Promise.all(
498
550
  [
499
- K("ckeditor5", e),
551
+ J("ckeditor5", e),
500
552
  /* v8 ignore next -- @preserve */
501
- t && K("ckeditor5-premium-features", e)
502
- ].filter((i) => !!i)
503
- ).then((i) => i.flat());
553
+ t && J("ckeditor5-premium-features", e)
554
+ ].filter((n) => !!n)
555
+ ).then((n) => n.flat());
504
556
  }
505
- async function K(r, t) {
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 pt(r, e);
560
+ const a = await yt(r, e);
509
561
  return a?.default ?? a;
510
562
  }).filter(Boolean)
511
563
  );
512
564
  }
513
- async function pt(r, t) {
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 tt(r) {
865
+ function Z(r) {
814
866
  return W(r, (t) => ({
815
867
  dictionary: t
816
868
  }));
817
869
  }
818
- function q() {
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, c) => {
831
- const u = c.getAttribute("data-cke-root-name"), s = c.getAttribute("data-cke-content");
832
- return o[u] = {
833
- element: c.querySelector("[data-cke-editable-content]"),
834
- content: s
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, i = JSON.parse(e.getAttribute("data-cke-content")), n = document.querySelector(`#${r}_editor `);
840
- return a && i?.main ? {
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 || i.main
905
+ content: a.content || n.main
845
906
  }
846
- } : n ? {
907
+ } : i ? {
847
908
  ...t,
848
909
  main: {
849
- element: n,
850
- content: i?.main || null
910
+ element: i,
911
+ content: n?.main || null
851
912
  }
852
913
  } : t;
853
914
  }
854
- function S(r) {
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) => S(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, i] of Object.entries(r))
866
- e[a] = S(i);
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((n) => D(r, t, n));
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 n = a.$translation, o = wt(r, n, t);
877
- return o === void 0 && console.warn(`Translation not found for key: ${n}`), o !== void 0 ? o : null;
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 i = /* @__PURE__ */ Object.create(null);
880
- for (const [n, o] of Object.entries(e))
881
- i[n] = D(r, t, o);
882
- return i;
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 wt(r, t, e) {
945
+ function Et(r, t, e) {
885
946
  for (const a of r) {
886
- const i = a[e];
887
- if (i?.dictionary && t in i.dictionary)
888
- return i.dictionary[t];
947
+ const n = a[e];
948
+ if (n?.dictionary && t in n.dictionary)
949
+ return n.dictionary[t];
889
950
  }
890
951
  }
891
- function gt(r, t) {
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 bt(r, t) {
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 i = await r();
905
- return i[z] = a, i;
965
+ const n = await r();
966
+ return n[z] = a, n;
906
967
  }), a;
907
968
  }
908
- function yt(r) {
969
+ function At(r) {
909
970
  return z in r ? r[z] : null;
910
971
  }
911
- class C extends Y {
912
- static the = new C();
972
+ class O extends Y {
973
+ static the = new O();
913
974
  }
914
- class Et extends HTMLElement {
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 M(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeContext();
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-id"), e = JSON.parse(this.getAttribute("data-cke-language")), a = JSON.parse(this.getAttribute("data-cke-context")), { customTranslations: i, watchdogConfig: n, config: { plugins: o, ...c } } = a, { loadedPlugins: u, hasPremium: s } = await Q(o ?? []), l = [
934
- ...await Z(e, s),
935
- tt(i || {})
936
- ].filter((w) => !P(w));
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: w, Context: y } = await import("ckeditor5"), E = new w(y, {
999
+ const { ContextWatchdog: b, Context: y } = await import("ckeditor5"), w = new b(y, {
939
1000
  crashNumberLimit: 10,
940
- ...n
1001
+ ...a
941
1002
  });
942
- let h = S(c);
943
- return h = D([...l].reverse(), e.ui, h), await E.create({
1003
+ let h = M(i);
1004
+ return h = D([...d].reverse(), s.ui, h), await w.create({
944
1005
  ...h,
945
- language: e,
946
- plugins: u,
947
- ...l.length && {
948
- translations: l
1006
+ language: s,
1007
+ plugins: c,
1008
+ ...d.length && {
1009
+ translations: d
949
1010
  }
950
- }), E.on("itemError", (...v) => {
951
- console.error("Context item error:", ...v);
952
- }), E;
1011
+ }), w.on("itemError", (...A) => {
1012
+ console.error("Context item error:", ...A);
1013
+ }), w;
953
1014
  })();
954
- const p = await this.contextPromise;
955
- this.isConnected && C.the.register(t, p);
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 && C.the.hasItem(t) && C.the.unregister(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 kt extends HTMLElement {
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 M(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeEditable();
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", q()[0]);
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") || "{}"), i = this.getAttribute("data-cke-content"), n = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10);
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 k("Editor ID or Root Name is missing.");
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: c, editing: u, model: s } = o, d = this.querySelector("input"), l = s.document.getRoot(e);
1001
- if (l?.isAttached()) {
1002
- if (i !== null) {
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 !== i && o.setData({
1005
- [e]: i
1065
+ h && h !== n && o.setData({
1066
+ [e]: n
1006
1067
  });
1007
1068
  }
1008
- P(a) || o.model.change((h) => {
1009
- h.setAttributes(a, l);
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
- attributes: { ...a },
1016
- ...i !== null && {
1017
- data: i
1076
+ modelAttributes: { ...a },
1077
+ ...n !== null && {
1078
+ initialData: n
1018
1079
  }
1019
1080
  });
1020
- const p = this.querySelector("[data-cke-editable-content]"), w = c.view.createEditable(e, p);
1021
- c.addEditable(w), u.view.forceRender();
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 (!s.document.getRoot(e)?.isAttached())
1084
+ if (!u.document.getRoot(e)?.isAttached())
1024
1085
  return;
1025
1086
  const h = o.getData({ rootName: e });
1026
- d && (d.value = h, d.dispatchEvent(new Event("input"))), this.dispatchEvent(new CustomEvent("change", {
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
- }, E = $(n, y);
1032
- return o.model.document.on("change:data", E), y(), () => {
1033
- if (o.model.document.off("change:data", E), o.state !== "destroyed" && e) {
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 (v) {
1039
- console.error("Unable unmount editable from root:", v);
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 vt({
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: n } = this, o = $(r, this.dispatch);
1072
- n.model.document.on("change:data", o), n.once("ready", this.dispatch);
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: n } = this;
1139
+ const { editor: i } = this;
1079
1140
  e.dispatchEvent(
1080
- new b({
1141
+ new k({
1081
1142
  editorId: t,
1082
- editor: n,
1083
- roots: X(n)
1143
+ editor: i,
1144
+ roots: X(i)
1084
1145
  })
1085
1146
  );
1086
1147
  };
1087
1148
  };
1088
1149
  }
1089
- class b extends CustomEvent {
1150
+ class k extends CustomEvent {
1090
1151
  static EVENT_NAME = "ckeditor5:change:data";
1091
1152
  constructor(t) {
1092
- super(b.EVENT_NAME, {
1153
+ super(k.EVENT_NAME, {
1093
1154
  detail: t,
1094
1155
  bubbles: !0
1095
1156
  });
1096
1157
  }
1097
1158
  }
1098
- async function At(r) {
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, n = a.sourceElement.id.replace(/_editor$/, "");
1120
- this.input = document.getElementById(`${n}_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));
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 Ct extends HTMLElement {
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 M(), this.interactiveWait = L(this), J("classic"), await this.interactiveWait.promise, await this.initializeEditor();
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 = ht(e), i = yt(e);
1223
+ const e = await this.createEditor(), a = gt(e), n = At(e);
1163
1224
  if (this.isConnected) {
1164
- const n = m.the.mountEffect(t, (o) => {
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), n(), a ? a.state !== "unavailable" && await a.context.remove(a.editorContextId) : i ? await i.destroy() : await e.destroy();
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 = this.getAttribute("data-cke-editor-id"), e = JSON.parse(this.getAttribute("data-cke-preset")), a = this.getAttribute("data-cke-context-id"), i = JSON.parse(this.getAttribute("data-cke-root-attributes") || "{}"), n = this.getAttribute("data-cke-editable-height") ? Number.parseInt(this.getAttribute("data-cke-editable-height"), 10) : null, o = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10), c = JSON.parse(this.getAttribute("data-cke-language")), u = this.hasAttribute("data-cke-watchdog"), s = JSON.parse(this.getAttribute("data-cke-content")), {
1189
- customTranslations: d,
1190
- editorType: l,
1191
- licenseKey: p,
1192
- watchdogConfig: w,
1193
- config: { plugins: y, ...E }
1194
- } = e, h = await J(l), v = await (a ? C.the.waitFor(a) : null), F = async () => {
1195
- const { loadedPlugins: g, hasPremium: T } = await Q(y);
1196
- g.push(
1197
- await vt({
1198
- saveDebounceMs: o,
1199
- editorId: t,
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
- ), O(l) && g.push(
1203
- await At(o)
1263
+ ), T(a) && E.push(
1264
+ await Tt(f)
1204
1265
  );
1205
- const A = [
1206
- ...await Z(c, T),
1207
- tt(d || {})
1208
- ].filter((f) => !P(f));
1266
+ const C = [
1267
+ ...await Q(w, N),
1268
+ Z(e || {})
1269
+ ].filter((p) => !S(p));
1209
1270
  let I = {
1210
- ...s,
1211
- ...G(t)
1271
+ ...y,
1272
+ ...G(c)
1212
1273
  };
1213
- O(l) && (I = I.main || "");
1214
- const N = await (async () => {
1215
- let f = et(t);
1216
- if (!f.main) {
1217
- const B = O(l) ? ["main"] : Object.keys(I);
1218
- at(f, B) || (f = await It(t, B), I = {
1219
- ...s,
1220
- ...G(t)
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
- O(l) && "main" in f && (f = f.main);
1224
- let R = S(E);
1225
- R = D([...A].reverse(), c.ui, R);
1226
- const j = {
1227
- ...R,
1228
- initialData: I,
1229
- licenseKey: p,
1230
- plugins: g,
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 !v || !(f instanceof HTMLElement) ? h.create(f, j) : (await mt({
1237
- context: v,
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: j
1241
- })).editor;
1297
+ config: g
1298
+ })).editor : h.create(g);
1242
1299
  })();
1243
- return P(i) || N.model.change((f) => {
1244
- f.setAttributes(i, N.model.document.getRoot());
1245
- }), O(l) && n && gt(N, n), N;
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 (u && !v) {
1248
- const g = await bt(F, w);
1249
- return g.on("error", (T, { causesRestart: U }) => {
1250
- if (U) {
1251
- const A = m.the.getItem(t);
1252
- A && (dt(A), m.the.unregister(t));
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
- }), g.on("restart", () => {
1255
- const T = g.editor;
1256
- m.the.register(t, T);
1257
- }), await g.create({}), g.editor;
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 F();
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 It(r, t) {
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 Ot extends HTMLElement {
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 M();
1291
- const t = this.getAttribute("data-cke-editor-id") || q()[0], e = this.getAttribute("data-cke-name");
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: i } = a, n = Tt(e), o = i.view[n];
1352
+ const { ui: n } = a, i = Mt(e), o = n.view[i];
1296
1353
  if (!o)
1297
- throw new k(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
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 Tt(r) {
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 Nt = {
1322
- "cke5-editor": Ct,
1323
- "cke5-context": Et,
1324
- "cke5-ui-part": Ot,
1325
- "cke5-editable": kt
1378
+ const Dt = {
1379
+ "cke5-editor": Nt,
1380
+ "cke5-context": Ct,
1381
+ "cke5-ui-part": St,
1382
+ "cke5-editable": Ot
1326
1383
  };
1327
- function Pt() {
1328
- for (const [r, t] of Object.entries(Nt))
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 Vt(r) {
1388
+ function Lt(r) {
1332
1389
  return x(r), {
1333
1390
  unmount() {
1334
1391
  }
1335
1392
  };
1336
1393
  }
1337
- function it(r, t) {
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
- }, i = (n, o, c) => {
1346
- if (c || e.pendingValue === null)
1402
+ }, n = (i, o, s) => {
1403
+ if (s || e.pendingValue === null)
1347
1404
  return;
1348
- const u = t.getCurrentValue();
1349
- t.isEqual(u, e.pendingValue) || t.applyValue(e.pendingValue), e.pendingValue = null;
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", i), {
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", i);
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(n) {
1367
- return e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, n) ? !1 : (e.lastSyncedValue = n, !0);
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(n) {
1431
+ setValue(i) {
1375
1432
  if (r.ui.focusTracker.isFocused) {
1376
- e.pendingValue = n;
1433
+ e.pendingValue = i;
1377
1434
  return;
1378
1435
  }
1379
- e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, n) || (e.lastSyncedValue = n, t.applyValue(n));
1436
+ e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, i) || (e.lastSyncedValue = i, t.applyValue(i));
1380
1437
  }
1381
1438
  };
1382
1439
  }
1383
- function nt() {
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 }, (i) => {
1398
- const n = r.model.document.getRoot(t);
1399
- if (n) {
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 || (i.removeAttribute(o, n), e.delete(o));
1402
- for (const [o, c] of Object.entries(a ?? {}))
1403
- i.setAttribute(o, c, n), e.add(o);
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 zt(r, t) {
1409
- const e = r.getAttribute("data-cke-editor-id") ?? q()[0], a = r.getAttribute("data-cke-root-name") ?? "main";
1410
- let i = !1, n = null, o = null, c = nt(), u = null;
1411
- const s = (d) => {
1412
- if (!(d instanceof b) || d.detail.editorId !== e)
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 l = d.detail.roots[a];
1415
- l !== void 0 && c.shouldNotify(l) && t.invokeMethodAsync("OnChangeEditableData", o, l);
1471
+ const d = l.detail.roots[a];
1472
+ d !== void 0 && s.shouldNotify(d) && t.invokeMethodAsync("OnChangeEditableData", o, d);
1416
1473
  };
1417
- return n = m.the.mountEffect(e, (d) => (o = globalThis.DotNet.createJSObjectReference(d), c = it(d, {
1418
- getCurrentValue: () => d.getData({ rootName: a }) ?? "",
1419
- applyValue: (l) => d.setData({ [a]: l }),
1420
- isEqual: (l, p) => l === p
1421
- }), u = ot(d, a), () => {
1422
- c.unmount(), o && (globalThis.DotNet?.disposeJSObjectReference(o), o = null), u = null;
1423
- })), document.body.addEventListener(b.EVENT_NAME, s), x(r), {
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
- i || (document.body.removeEventListener(b.EVENT_NAME, s), n?.(), n = null, i = !0);
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 (d) => {
1435
- i || (await m.the.waitFor(e), c.setValue(d));
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 (d) => {
1442
- i || (await m.the.waitFor(e), u?.(d));
1498
+ setRootAttributes: async (l) => {
1499
+ n || (await m.the.waitFor(e), c?.(l));
1443
1500
  }
1444
1501
  };
1445
1502
  }
1446
- function $t(r, t) {
1503
+ function _t(r, t) {
1447
1504
  const e = r.getAttribute("data-cke-editor-id");
1448
- let a = !1, i = null, n = nt(), o = null, c = null;
1449
- const u = (s) => {
1450
- !(s instanceof b) || s.detail.editorId !== e || n.shouldNotify(s.detail.roots) && t.invokeMethodAsync("OnChangeEditorData", c, s.detail.roots);
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 i = m.the.mountEffect(e, (s) => {
1453
- c = globalThis.DotNet.createJSObjectReference(s), n = it(s, {
1454
- getCurrentValue: () => X(s),
1455
- applyValue: (l) => s.setData(l),
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(s, "main");
1458
- const d = (l, p, w) => {
1459
- const y = w ? "OnEditorFocus" : "OnEditorBlur";
1460
- t.invokeMethodAsync(y, c);
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 s.ui.focusTracker.on("change:isFocused", d), t.invokeMethodAsync("OnEditorReady", c), () => {
1463
- s.ui.focusTracker.off("change:isFocused", d), n.unmount(), c && (globalThis.DotNet?.disposeJSObjectReference(c), c = null), o = null;
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(b.EVENT_NAME, u), Pt(), x(r), {
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 (s) => {
1470
- a || (await m.the.waitFor(e), n.setValue(s));
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 (s) => {
1476
- a || (await m.the.waitFor(e), o?.(s));
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(b.EVENT_NAME, u), i?.(), i = null, a = !0);
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, (s) => {
1491
- St(s, t);
1547
+ a || m.the.mountEffect(e, (u) => {
1548
+ xt(u, t);
1492
1549
  });
1493
1550
  }
1494
1551
  };
1495
1552
  }
1496
- function St(r, t) {
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 i = !1;
1558
+ let n = !1;
1502
1559
  return {
1503
1560
  async upload() {
1504
- const n = await a.file;
1505
- if (i)
1561
+ const i = await a.file;
1562
+ if (n)
1506
1563
  throw new Error("Upload aborted.");
1507
- const o = await Dt(n), c = await t.invokeMethodAsync("OnEditorImageUpload", {
1508
- fileName: n.name,
1509
- mimeType: n.type,
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 (!c)
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: c };
1573
+ return { default: s };
1517
1574
  },
1518
1575
  abort() {
1519
- i = !0;
1576
+ n = !0;
1520
1577
  }
1521
1578
  };
1522
1579
  };
1523
1580
  }
1524
- function Dt(r) {
1581
+ function Vt(r) {
1525
1582
  return new Promise((t, e) => {
1526
1583
  const a = new FileReader();
1527
1584
  a.onload = () => {
1528
- const i = a.result, n = i.split(",")[1] ?? i;
1529
- t(n);
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 Wt(r) {
1590
+ function qt(r) {
1534
1591
  return x(r), {
1535
1592
  unmount() {
1536
1593
  }
1537
1594
  };
1538
1595
  }
1539
1596
  export {
1540
- k as CKEditor5BlazorError,
1541
- b as CKEditor5ChangeDataEvent,
1542
- C as ContextsRegistry,
1543
- _ as CustomEditorPluginsRegistry,
1544
- kt as EditableComponentElement,
1545
- Ct as EditorComponentElement,
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
- Ot as UIPartComponentElement,
1548
- Vt as createContextBlazorInterop,
1549
- zt as createEditableBlazorInterop,
1550
- $t as createEditorBlazorInterop,
1551
- Wt as createUIPartBlazorInterop,
1552
- Pt as ensureEditorElementsRegistered
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