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.
Files changed (36) 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-editor-roots-to-config.d.ts +17 -0
  8. package/dist/elements/editor/utils/assign-editor-roots-to-config.d.ts.map +1 -0
  9. package/dist/elements/editor/utils/create-editor-in-context.d.ts +1 -3
  10. package/dist/elements/editor/utils/create-editor-in-context.d.ts.map +1 -1
  11. package/dist/elements/editor/utils/index.d.ts +3 -1
  12. package/dist/elements/editor/utils/index.d.ts.map +1 -1
  13. package/dist/elements/editor/utils/normalize-editor-language.d.ts +9 -0
  14. package/dist/elements/editor/utils/normalize-editor-language.d.ts.map +1 -0
  15. package/dist/elements/editor/utils/query-all-editor-editables.d.ts +23 -0
  16. package/dist/elements/editor/utils/query-all-editor-editables.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 +396 -387
  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 +55 -76
  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-editor-roots-to-config.ts +60 -0
  29. package/src/elements/editor/utils/create-editor-in-context.ts +2 -5
  30. package/src/elements/editor/utils/index.ts +3 -1
  31. package/src/elements/editor/utils/normalize-editor-language.test.ts +50 -0
  32. package/src/elements/editor/utils/normalize-editor-language.ts +25 -0
  33. package/src/elements/editor/utils/query-all-editor-editables.ts +74 -0
  34. package/dist/elements/editor/utils/query-editor-editables.d.ts +0 -25
  35. package/dist/elements/editor/utils/query-editor-editables.d.ts.map +0 -1
  36. 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 H(r, t) {
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 Y {
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 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, 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, 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((u) => {
68
+ const s = u.get(t);
69
+ if (s !== n && (a?.(), a = void 0, n = s, !!s))
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 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
- 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
+ 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 $(r, t) {
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 W(r, t) {
255
- const e = Object.entries(r).map(([a, i]) => [a, t(i, 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 ct(r, t) {
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 i of e)
265
- if (r[i] !== t[i] || !Object.prototype.hasOwnProperty.call(t, i))
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 ut() {
265
+ function nt() {
270
266
  return Math.random().toString(36).substring(2);
271
267
  }
272
- function lt(r, {
268
+ function ot(r, {
273
269
  timeOutAfter: t = 500,
274
270
  retryAfter: e = 100
275
271
  } = {}) {
276
- return new Promise((a, i) => {
277
- const n = Date.now();
272
+ return new Promise((a, n) => {
273
+ const i = Date.now();
278
274
  let o = null;
279
- const c = setTimeout(() => {
280
- i(o ?? new Error("Timeout"));
281
- }, t), u = async () => {
275
+ const u = setTimeout(() => {
276
+ n(o ?? new Error("Timeout"));
277
+ }, t), s = async () => {
282
278
  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);
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
- u();
285
+ s();
290
286
  });
291
287
  }
292
- function M() {
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((i) => {
315
- for (const n of i)
316
- if (n.type === "attributes" && n.attributeName === "data-cke-interactive" && r.hasAttribute("data-cke-interactive")) {
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 x(r) {
321
+ function D(r) {
326
322
  r.setAttribute("data-cke-interactive", "true");
327
323
  }
328
- function dt(r) {
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 n of t)
335
- i(n);
359
+ for (const i of t)
360
+ n(i);
336
361
  const e = r.ui?.view?.body?._bodyCollectionContainer;
337
- e?.isConnected && i(e);
362
+ e?.isConnected && n(e);
338
363
  const a = r.editing?.view;
339
364
  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(
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(n));
350
- function i(n) {
351
- n.hasAttribute("data-cke-controlled") ? n.innerHTML = "" : n.remove();
374
+ ), n(i));
375
+ function n(i) {
376
+ i.hasAttribute("data-cke-controlled") ? i.innerHTML = "" : i.remove();
352
377
  }
353
378
  }
354
- 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,
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: a
386
+ config: e
363
387
  });
364
- const n = t.getItem(i), o = {
388
+ const n = r.getItem(a), i = {
365
389
  state: "available",
366
- editorContextId: i,
367
- context: t
390
+ editorContextId: a,
391
+ context: r
368
392
  };
369
- n[V] = o;
370
- const c = t.destroy.bind(t);
371
- return t.destroy = async () => (o.state = "unavailable", c()), {
372
- ...o,
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 ht(r) {
377
- return V in r ? r[V] : null;
400
+ function lt(r) {
401
+ return z in r ? r[z] : null;
378
402
  }
379
- function X(r) {
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 O(r) {
406
+ function V(r) {
383
407
  return ["inline", "classic", "balloon", "decoupled"].includes(r);
384
408
  }
385
- async function J(r) {
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 Q(r) {
481
+ async function G(r) {
458
482
  const t = await import("ckeditor5");
459
483
  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(
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
- 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;
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 n = await _.the.get(i);
471
- if (n)
472
- return n;
473
- const { [i]: o } = t;
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 (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.`);
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 { [i]: c } = e || {};
483
- if (c)
484
- return c;
485
- throw new k(`Plugin "${i}" not found in base or premium packages.`);
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 ft(r) {
516
+ function dt(r) {
493
517
  return typeof r == "object" && r !== null && "$import" in r;
494
518
  }
495
- async function Z(r, t) {
519
+ async function Y(r, t) {
496
520
  const e = [r.ui, r.content];
497
521
  return await Promise.all(
498
522
  [
499
- K("ckeditor5", e),
523
+ B("ckeditor5", e),
500
524
  /* v8 ignore next -- @preserve */
501
- t && K("ckeditor5-premium-features", e)
502
- ].filter((i) => !!i)
503
- ).then((i) => i.flat());
525
+ t && B("ckeditor5-premium-features", e)
526
+ ].filter((n) => !!n)
527
+ ).then((n) => n.flat());
504
528
  }
505
- async function K(r, t) {
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 pt(r, e);
532
+ const a = await mt(r, e);
509
533
  return a?.default ?? a;
510
534
  }).filter(Boolean)
511
535
  );
512
536
  }
513
- async function pt(r, t) {
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 tt(r) {
814
- return W(r, (t) => ({
837
+ function X(r) {
838
+ return at(r, (t) => ({
815
839
  dictionary: t
816
840
  }));
817
841
  }
818
- function q() {
819
- return Array.from(document.querySelectorAll("cke5-editor")).map((r) => r.getAttribute("data-cke-editor-id")).filter((r) => r !== null);
820
- }
821
- function et(r) {
822
- const t = rt(r);
823
- return W(t, ({ element: e }) => e);
824
- }
825
- function G(r) {
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 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
835
- }, o;
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 = t.main, i = JSON.parse(e.getAttribute("data-cke-content")), n = document.querySelector(`#${r}_editor `);
840
- return a && i?.main ? {
841
- ...t,
842
- main: {
843
- ...a,
844
- content: a.content || i.main
845
- }
846
- } : n ? {
847
- ...t,
848
- main: {
849
- element: n,
850
- content: i?.main || null
851
- }
852
- } : t;
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, i] of Object.entries(r))
866
- e[a] = S(i);
890
+ for (const [a, n] of Object.entries(r))
891
+ e[a] = S(n);
867
892
  return e;
868
893
  }
869
- function D(r, t, e) {
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((n) => D(r, t, n));
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 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;
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 i = /* @__PURE__ */ Object.create(null);
880
- for (const [n, o] of Object.entries(e))
881
- i[n] = D(r, t, o);
882
- return i;
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 wt(r, t, e) {
909
+ function ht(r, t, e) {
885
910
  for (const a of r) {
886
- const i = a[e];
887
- if (i?.dictionary && t in i.dictionary)
888
- return i.dictionary[t];
911
+ const n = a[e];
912
+ if (n?.dictionary && t in n.dictionary)
913
+ return n.dictionary[t];
889
914
  }
890
915
  }
891
- function gt(r, t) {
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 z = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
898
- async function bt(r, t) {
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 i = await r();
905
- return i[z] = a, i;
929
+ const n = await r();
930
+ return n[$] = a, n;
906
931
  }), a;
907
932
  }
908
- function yt(r) {
909
- return z in r ? r[z] : null;
933
+ function wt(r) {
934
+ return $ in r ? r[$] : null;
910
935
  }
911
- class C extends Y {
936
+ class C extends H {
912
937
  static the = new C();
913
938
  }
914
- class Et extends HTMLElement {
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 M(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeContext();
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-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));
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: w, Context: y } = await import("ckeditor5"), E = new w(y, {
963
+ const { ContextWatchdog: g, Context: p } = await import("ckeditor5"), w = new g(p, {
939
964
  crashNumberLimit: 10,
940
- ...n
965
+ ...a
941
966
  });
942
- let h = S(c);
943
- return h = D([...l].reverse(), e.ui, h), await E.create({
967
+ let h = S(i);
968
+ return h = R([...d].reverse(), u.ui, h), await w.create({
944
969
  ...h,
945
- language: e,
946
- plugins: u,
947
- ...l.length && {
948
- translations: l
970
+ language: u,
971
+ plugins: s,
972
+ ...d.length && {
973
+ translations: d
949
974
  }
950
- }), E.on("itemError", (...v) => {
975
+ }), w.on("itemError", (...v) => {
951
976
  console.error("Context item error:", ...v);
952
- }), E;
977
+ }), w;
953
978
  })();
954
- const p = await this.contextPromise;
955
- this.isConnected && C.the.register(t, p);
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 Y {
996
+ class m extends H {
972
997
  static the = new m();
973
998
  }
974
- class kt extends HTMLElement {
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 M(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeEditable();
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", 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);
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: c, editing: u, model: s } = o, d = this.querySelector("input"), l = s.document.getRoot(e);
1001
- if (l?.isAttached()) {
1002
- if (i !== null) {
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 !== i && o.setData({
1005
- [e]: i
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, l);
1034
+ h.setAttributes(a, d);
1010
1035
  });
1011
1036
  return;
1012
1037
  }
1013
1038
  o.addRoot(e, {
1014
1039
  isUndoable: !1,
1015
- attributes: { ...a },
1016
- ...i !== null && {
1017
- data: i
1040
+ modelAttributes: { ...a },
1041
+ ...n !== null && {
1042
+ initialData: n
1018
1043
  }
1019
1044
  });
1020
- const p = this.querySelector("[data-cke-editable-content]"), w = c.view.createEditable(e, p);
1021
- c.addEditable(w), u.view.forceRender();
1022
- const y = () => {
1023
- if (!s.document.getRoot(e)?.isAttached())
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
- d && (d.value = h, d.dispatchEvent(new Event("input"))), this.dispatchEvent(new CustomEvent("change", {
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
- }, 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) {
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 vt({
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: n } = this, o = $(r, this.dispatch);
1072
- n.model.document.on("change:data", o), n.once("ready", this.dispatch);
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: n } = this;
1103
+ const { editor: i } = this;
1079
1104
  e.dispatchEvent(
1080
- new b({
1105
+ new y({
1081
1106
  editorId: t,
1082
- editor: n,
1083
- roots: X(n)
1107
+ editor: i,
1108
+ roots: J(i)
1084
1109
  })
1085
1110
  );
1086
1111
  };
1087
1112
  };
1088
1113
  }
1089
- class b extends CustomEvent {
1114
+ class y extends CustomEvent {
1090
1115
  static EVENT_NAME = "ckeditor5:change:data";
1091
1116
  constructor(t) {
1092
- super(b.EVENT_NAME, {
1117
+ super(y.EVENT_NAME, {
1093
1118
  detail: t,
1094
1119
  bubbles: !0
1095
1120
  });
1096
1121
  }
1097
1122
  }
1098
- async function At(r) {
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, 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));
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 Ct extends HTMLElement {
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 M(), this.interactiveWait = L(this), J("classic"), await this.interactiveWait.promise, await this.initializeEditor();
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 = ht(e), i = yt(e);
1187
+ const e = await this.createEditor(), a = lt(e), n = wt(e);
1163
1188
  if (this.isConnected) {
1164
- const n = m.the.mountEffect(t, (o) => {
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), n(), a ? a.state !== "unavailable" && await a.context.remove(a.editorContextId) : i ? await i.destroy() : await e.destroy();
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 = 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,
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
- ), O(l) && g.push(
1203
- await At(o)
1227
+ ), V(a) && b.push(
1228
+ await Et(f)
1204
1229
  );
1205
1230
  const A = [
1206
- ...await Z(c, T),
1207
- tt(d || {})
1208
- ].filter((f) => !P(f));
1209
- let I = {
1210
- ...s,
1211
- ...G(t)
1212
- };
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)
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
- 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
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 (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));
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
- }), g.on("restart", () => {
1255
- const T = g.editor;
1256
- m.the.register(t, T);
1257
- }), await g.create({}), g.editor;
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 F();
1268
+ return v();
1260
1269
  }
1261
1270
  }
1262
- function at(r, t) {
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 It(r, t) {
1266
- return lt(
1274
+ async function vt(r, t) {
1275
+ return ot(
1267
1276
  () => {
1268
- const e = et(r);
1269
- if (!at(e, t))
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 Ot extends HTMLElement {
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 M();
1291
- const t = this.getAttribute("data-cke-editor-id") || q()[0], e = this.getAttribute("data-cke-name");
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: i } = a, n = Tt(e), o = i.view[n];
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 Tt(r) {
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 Nt = {
1322
- "cke5-editor": Ct,
1323
- "cke5-context": Et,
1324
- "cke5-ui-part": Ot,
1325
- "cke5-editable": kt
1330
+ const It = {
1331
+ "cke5-editor": kt,
1332
+ "cke5-context": gt,
1333
+ "cke5-ui-part": At,
1334
+ "cke5-editable": bt
1326
1335
  };
1327
- function Pt() {
1328
- for (const [r, t] of Object.entries(Nt))
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 Vt(r) {
1332
- return x(r), {
1340
+ function Rt(r) {
1341
+ return D(r), {
1333
1342
  unmount() {
1334
1343
  }
1335
1344
  };
1336
1345
  }
1337
- function it(r, t) {
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
- }, i = (n, o, c) => {
1346
- if (c || e.pendingValue === null)
1354
+ }, n = (i, o, u) => {
1355
+ if (u || e.pendingValue === null)
1347
1356
  return;
1348
- const u = t.getCurrentValue();
1349
- t.isEqual(u, e.pendingValue) || t.applyValue(e.pendingValue), e.pendingValue = null;
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", i), {
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", i);
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(n) {
1367
- return e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, n) ? !1 : (e.lastSyncedValue = n, !0);
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(n) {
1383
+ setValue(i) {
1375
1384
  if (r.ui.focusTracker.isFocused) {
1376
- e.pendingValue = n;
1385
+ e.pendingValue = i;
1377
1386
  return;
1378
1387
  }
1379
- e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, n) || (e.lastSyncedValue = n, t.applyValue(n));
1388
+ e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, i) || (e.lastSyncedValue = i, t.applyValue(i));
1380
1389
  }
1381
1390
  };
1382
1391
  }
1383
- function nt() {
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 ot(r, t) {
1403
+ function rt(r, t) {
1395
1404
  const e = /* @__PURE__ */ new Set();
1396
1405
  return (a) => {
1397
- r.model.enqueueChange({ isUndoable: !1 }, (i) => {
1398
- const n = r.model.document.getRoot(t);
1399
- if (n) {
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 || (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);
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 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)
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 l = d.detail.roots[a];
1415
- l !== void 0 && c.shouldNotify(l) && t.invokeMethodAsync("OnChangeEditableData", o, l);
1423
+ const d = l.detail.roots[a];
1424
+ d !== void 0 && u.shouldNotify(d) && t.invokeMethodAsync("OnChangeEditableData", o, d);
1416
1425
  };
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), {
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
- i || (document.body.removeEventListener(b.EVENT_NAME, s), n?.(), n = null, i = !0);
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 (d) => {
1435
- i || (await m.the.waitFor(e), c.setValue(d));
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 (d) => {
1442
- i || (await m.the.waitFor(e), u?.(d));
1450
+ setRootAttributes: async (l) => {
1451
+ n || (await m.the.waitFor(e), s?.(l));
1443
1452
  }
1444
1453
  };
1445
1454
  }
1446
- function $t(r, t) {
1455
+ function Dt(r, t) {
1447
1456
  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);
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 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),
1456
- isEqual: ct
1457
- }), o = ot(s, "main");
1458
- const d = (l, p, w) => {
1459
- const y = w ? "OnEditorFocus" : "OnEditorBlur";
1460
- t.invokeMethodAsync(y, c);
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 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;
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(b.EVENT_NAME, u), Pt(), x(r), {
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 (s) => {
1470
- a || (await m.the.waitFor(e), n.setValue(s));
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 (s) => {
1476
- a || (await m.the.waitFor(e), o?.(s));
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(b.EVENT_NAME, u), i?.(), i = null, a = !0);
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, (s) => {
1491
- St(s, t);
1499
+ a || m.the.mountEffect(e, (c) => {
1500
+ Ot(c, t);
1492
1501
  });
1493
1502
  }
1494
1503
  };
1495
1504
  }
1496
- function St(r, t) {
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 i = !1;
1510
+ let n = !1;
1502
1511
  return {
1503
1512
  async upload() {
1504
- const n = await a.file;
1505
- if (i)
1513
+ const i = await a.file;
1514
+ if (n)
1506
1515
  throw new Error("Upload aborted.");
1507
- const o = await Dt(n), c = await t.invokeMethodAsync("OnEditorImageUpload", {
1508
- fileName: n.name,
1509
- mimeType: n.type,
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 (!c)
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: c };
1525
+ return { default: u };
1517
1526
  },
1518
1527
  abort() {
1519
- i = !0;
1528
+ n = !0;
1520
1529
  }
1521
1530
  };
1522
1531
  };
1523
1532
  }
1524
- function Dt(r) {
1533
+ function Nt(r) {
1525
1534
  return new Promise((t, e) => {
1526
1535
  const a = new FileReader();
1527
1536
  a.onload = () => {
1528
- const i = a.result, n = i.split(",")[1] ?? i;
1529
- t(n);
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 Wt(r) {
1534
- return x(r), {
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
- b as CKEditor5ChangeDataEvent,
1550
+ y as CKEditor5ChangeDataEvent,
1542
1551
  C as ContextsRegistry,
1543
1552
  _ as CustomEditorPluginsRegistry,
1544
- kt as EditableComponentElement,
1545
- Ct as EditorComponentElement,
1553
+ bt as EditableComponentElement,
1554
+ kt as EditorComponentElement,
1546
1555
  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
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