ckeditor5-blazor 1.11.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
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 j(r, t) {
6
+ function U(r, t) {
7
7
  if (!r || r.size !== t.size)
8
8
  return !1;
9
- for (const [e, a] of r)
10
- if (!t.has(e) || t.get(e) !== a)
9
+ for (const [e, n] of r)
10
+ if (!t.has(e) || t.get(e) !== n)
11
11
  return !1;
12
12
  return !0;
13
13
  }
@@ -46,13 +46,13 @@ class H {
46
46
  * @param onError Optional error callback.
47
47
  * @returns A promise that resolves with the result of the function.
48
48
  */
49
- execute(t, e, a) {
50
- const n = this.items.get(t), i = this.initializationErrors.get(t);
51
- return i ? (a?.(i), Promise.reject(i)) : n ? Promise.resolve(e(n)) : new Promise((o, u) => {
52
- const s = this.getPendingCallbacks(t);
53
- s.success.push(async (c) => {
54
- o(await e(c));
55
- }), a ? s.error.push(a) : s.error.push(u);
49
+ execute(t, e, n) {
50
+ const i = this.items.get(t), a = this.initializationErrors.get(t);
51
+ return a ? (n?.(a), Promise.reject(a)) : i ? Promise.resolve(e(i)) : new Promise((o, s) => {
52
+ const c = this.getPendingCallbacks(t);
53
+ c.success.push(async (u) => {
54
+ o(await e(u));
55
+ }), n ? c.error.push(n) : c.error.push(s);
56
56
  });
57
57
  }
58
58
  /**
@@ -63,19 +63,19 @@ class H {
63
63
  * @returns A function that stops observing and immediately runs any pending cleanup.
64
64
  */
65
65
  mountEffect(t, e) {
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))
66
+ let n, i, a = !1;
67
+ const o = this.watch((s) => {
68
+ const c = s.get(t);
69
+ if (c !== i && (n?.(), n = void 0, i = c, !!c))
70
70
  try {
71
- const c = e(s);
72
- i ? (c?.(), o()) : a = c;
73
- } catch (c) {
74
- throw console.error(c), c;
71
+ const u = e(c);
72
+ a ? (u?.(), o()) : n = u;
73
+ } catch (u) {
74
+ throw console.error(u), u;
75
75
  }
76
76
  });
77
77
  return () => {
78
- i = !0, n && (o(), a?.(), a = void 0);
78
+ a = !0, i && (o(), n?.(), n = void 0);
79
79
  };
80
80
  }
81
81
  /**
@@ -89,8 +89,8 @@ class H {
89
89
  if (this.items.has(t))
90
90
  throw new Error(`Item with ID "${t}" is already registered.`);
91
91
  this.resetErrors(t), this.items.set(t, e);
92
- const a = this.pendingCallbacks.get(t);
93
- a && (a.success.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.items.size === 1 && t !== null && this.register(null, e);
92
+ const n = this.pendingCallbacks.get(t);
93
+ n && (n.success.forEach((i) => i(e)), this.pendingCallbacks.delete(t)), this.items.size === 1 && t !== null && this.register(null, e);
94
94
  });
95
95
  }
96
96
  /**
@@ -102,8 +102,8 @@ class H {
102
102
  error(t, e) {
103
103
  this.batch(() => {
104
104
  this.items.delete(t), this.initializationErrors.set(t, e);
105
- const a = this.pendingCallbacks.get(t);
106
- a && (a.error.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e);
105
+ const n = this.pendingCallbacks.get(t);
106
+ n && (n.error.forEach((i) => i(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e);
107
107
  });
108
108
  }
109
109
  /**
@@ -159,8 +159,8 @@ class H {
159
159
  * @returns A promise that resolves with the item instance.
160
160
  */
161
161
  waitFor(t) {
162
- return new Promise((e, a) => {
163
- this.execute(t, e, a);
162
+ return new Promise((e, n) => {
163
+ this.execute(t, e, n);
164
164
  });
165
165
  }
166
166
  /**
@@ -220,7 +220,7 @@ class H {
220
220
  * Immediately dispatches the current state to all watchers if it changed.
221
221
  */
222
222
  flushWatchers() {
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(
223
+ U(this.lastNotifiedItems, this.items) && U(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
  )));
@@ -238,54 +238,54 @@ class H {
238
238
  }
239
239
  function W(r, t) {
240
240
  let e = null;
241
- return (...a) => {
241
+ return (...n) => {
242
242
  e && clearTimeout(e), e = setTimeout(() => {
243
- t(...a);
243
+ t(...n);
244
244
  }, r);
245
245
  };
246
246
  }
247
247
  function P(r) {
248
248
  return Object.keys(r).length === 0 && r.constructor === Object;
249
249
  }
250
- function at(r, t) {
251
- const e = Object.entries(r).map(([a, n]) => [a, t(n, a)]);
250
+ function nt(r, t) {
251
+ const e = Object.entries(r).map(([n, i]) => [n, t(i, n)]);
252
252
  return Object.fromEntries(e);
253
253
  }
254
- function it(r, t) {
254
+ function at(r, t) {
255
255
  if (r === t)
256
256
  return !0;
257
- const e = Object.keys(r), a = Object.keys(t);
258
- if (e.length !== a.length)
257
+ const e = Object.keys(r), n = Object.keys(t);
258
+ if (e.length !== n.length)
259
259
  return !1;
260
- for (const n of e)
261
- if (r[n] !== t[n] || !Object.prototype.hasOwnProperty.call(t, n))
260
+ for (const i of e)
261
+ if (r[i] !== t[i] || !Object.prototype.hasOwnProperty.call(t, i))
262
262
  return !1;
263
263
  return !0;
264
264
  }
265
- function nt() {
265
+ function it() {
266
266
  return Math.random().toString(36).substring(2);
267
267
  }
268
268
  function ot(r, {
269
269
  timeOutAfter: t = 500,
270
270
  retryAfter: e = 100
271
271
  } = {}) {
272
- return new Promise((a, n) => {
273
- const i = Date.now();
272
+ return new Promise((n, i) => {
273
+ const a = Date.now();
274
274
  let o = null;
275
- const u = setTimeout(() => {
276
- n(o ?? new Error("Timeout"));
277
- }, t), s = async () => {
275
+ const s = setTimeout(() => {
276
+ i(o ?? new Error("Timeout"));
277
+ }, t), c = async () => {
278
278
  try {
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);
279
+ const u = await r();
280
+ clearTimeout(s), n(u);
281
+ } catch (u) {
282
+ o = u, Date.now() - a > t ? i(u) : setTimeout(c, e);
283
283
  }
284
284
  };
285
- s();
285
+ c();
286
286
  });
287
287
  }
288
- function x() {
288
+ function R() {
289
289
  return new Promise((r) => {
290
290
  switch (document.readyState) {
291
291
  case "loading":
@@ -306,11 +306,11 @@ function L(r) {
306
306
  } };
307
307
  let t;
308
308
  return {
309
- promise: new Promise((a) => {
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")) {
313
- t.disconnect(), a();
309
+ promise: new Promise((n) => {
310
+ t = new MutationObserver((i) => {
311
+ for (const a of i)
312
+ if (a.type === "attributes" && a.attributeName === "data-cke-interactive" && r.hasAttribute("data-cke-interactive")) {
313
+ t.disconnect(), n();
314
314
  break;
315
315
  }
316
316
  }), t.observe(r, { attributes: !0 });
@@ -318,33 +318,34 @@ function L(r) {
318
318
  disconnect: () => t?.disconnect()
319
319
  };
320
320
  }
321
- function D(r) {
321
+ function x(r) {
322
322
  r.setAttribute("data-cke-interactive", "true");
323
323
  }
324
324
  function st(r, t, e) {
325
- const a = !r.editorName || r.editorName === "ClassicEditor", n = /* @__PURE__ */ new Set([
325
+ const n = !r.editorName || r.editorName === "ClassicEditor", i = /* @__PURE__ */ new Set([
326
326
  ...Object.keys(t),
327
327
  ...Object.keys(e.roots ?? {})
328
- ]), i = Array.from(n).reduce((u, s) => ({
329
- ...u,
330
- [s]: {
328
+ ]), a = Array.from(i).reduce((s, c) => ({
329
+ ...s,
330
+ [c]: {
331
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
332
+ ...e.roots?.[c],
333
+ ...c === "main" ? e.root : {},
334
+ /* v8 ignore next 12 */
335
+ ...c in t ? {
336
+ ...t[c].content !== null && {
337
+ initialData: t[c].content
338
338
  },
339
- ...!a && t[s].element !== null && {
340
- element: t[s].element
339
+ modelElement: t[c].modelElement || "$root",
340
+ ...!n && t[c].element !== null && {
341
+ element: t[c].element
341
342
  }
342
343
  } : {}
343
344
  }
344
- }), Object.create(e.roots || {})), o = {
345
+ }), { ...e.roots || {} }), o = {
345
346
  ...e,
346
- roots: i,
347
- ...a && t.main?.element && {
347
+ roots: a,
348
+ ...n && t.main?.element && {
348
349
  attachTo: t.main.element
349
350
  }
350
351
  };
@@ -356,14 +357,14 @@ function ct(r) {
356
357
  r.ui?.view?.toolbar?.element,
357
358
  r.ui?.view?.menuBarView?.element
358
359
  ].filter(Boolean);
359
- for (const i of t)
360
- n(i);
360
+ for (const a of t)
361
+ i(a);
361
362
  const e = r.ui?.view?.body?._bodyCollectionContainer;
362
- e?.isConnected && n(e);
363
- const a = r.editing?.view;
364
- if (a)
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(
363
+ e?.isConnected && i(e);
364
+ const n = r.editing?.view;
365
+ if (n)
366
+ for (const a of n.domRoots.values())
367
+ a instanceof HTMLElement && (a.removeAttribute("contenteditable"), a.removeAttribute("role"), a.removeAttribute("aria-label"), a.removeAttribute("aria-multiline"), a.removeAttribute("spellcheck"), a.classList.remove(
367
368
  "ck",
368
369
  "ck-content",
369
370
  "ck-editor__editable",
@@ -371,52 +372,52 @@ function ct(r) {
371
372
  "ck-editor__editable_inline",
372
373
  "ck-blurred",
373
374
  "ck-focused"
374
- ), n(i));
375
- function n(i) {
376
- i.hasAttribute("data-cke-controlled") ? i.innerHTML = "" : i.remove();
375
+ ), i(a));
376
+ function i(a) {
377
+ a.hasAttribute("data-cke-controlled") ? a.innerHTML = "" : a.remove();
377
378
  }
378
379
  }
379
380
  const z = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
380
381
  async function ut({ context: r, creator: t, config: e }) {
381
- const a = nt();
382
+ const n = it();
382
383
  await r.add({
383
384
  creator: t.create.bind(t),
384
- id: a,
385
+ id: n,
385
386
  type: "editor",
386
387
  config: e
387
388
  });
388
- const n = r.getItem(a), i = {
389
+ const i = r.getItem(n), a = {
389
390
  state: "available",
390
- editorContextId: a,
391
+ editorContextId: n,
391
392
  context: r
392
393
  };
393
- n[z] = i;
394
+ i[z] = a;
394
395
  const o = r.destroy.bind(r);
395
- return r.destroy = async () => (i.state = "unavailable", o()), {
396
- ...i,
397
- editor: n
396
+ return r.destroy = async () => (a.state = "unavailable", o()), {
397
+ ...a,
398
+ editor: i
398
399
  };
399
400
  }
400
401
  function lt(r) {
401
402
  return z in r ? r[z] : null;
402
403
  }
403
404
  function J(r) {
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({}));
405
+ 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(null));
405
406
  }
406
407
  function V(r) {
407
408
  return ["inline", "classic", "balloon", "decoupled"].includes(r);
408
409
  }
409
- async function U(r) {
410
- const t = await import("ckeditor5"), a = {
410
+ async function j(r) {
411
+ const t = await import("ckeditor5"), n = {
411
412
  inline: t.InlineEditor,
412
413
  balloon: t.BalloonEditor,
413
414
  classic: t.ClassicEditor,
414
415
  decoupled: t.DecoupledEditor,
415
416
  multiroot: t.MultiRootEditor
416
417
  }[r];
417
- if (!a)
418
- throw new k(`Unsupported editor type: ${r}`);
419
- return a;
418
+ if (!n)
419
+ throw new v(`Unsupported editor type: ${r}`);
420
+ return n;
420
421
  }
421
422
  class _ {
422
423
  static the = new _();
@@ -438,7 +439,7 @@ class _ {
438
439
  */
439
440
  register(t, e) {
440
441
  if (this.plugins.has(t))
441
- throw new k(`Plugin with name "${t}" is already registered.`);
442
+ throw new v(`Plugin with name "${t}" is already registered.`);
442
443
  return this.plugins.set(t, e), this.unregister.bind(this, t);
443
444
  }
444
445
  /**
@@ -449,7 +450,7 @@ class _ {
449
450
  */
450
451
  unregister(t) {
451
452
  if (!this.plugins.has(t))
452
- throw new k(`Plugin with name "${t}" is not registered.`);
453
+ throw new v(`Plugin with name "${t}" is not registered.`);
453
454
  this.plugins.delete(t);
454
455
  }
455
456
  /**
@@ -481,35 +482,35 @@ class _ {
481
482
  async function G(r) {
482
483
  const t = await import("ckeditor5");
483
484
  let e = null;
484
- const a = r.map(async (n) => {
485
- if (dt(n)) {
486
- const { name: s, path: c } = n.$import, d = await import(
485
+ const n = r.map(async (i) => {
486
+ if (dt(i)) {
487
+ const { name: c, path: u } = i.$import, l = await import(
487
488
  /* @vite-ignore */
488
- c
489
- ), f = (Object.prototype.hasOwnProperty.call(d, s) ? d[s] : void 0) ?? (Object.prototype.hasOwnProperty.call(d, "default") ? d.default : void 0);
489
+ u
490
+ ), f = (Object.prototype.hasOwnProperty.call(l, c) ? l[c] : void 0) ?? (Object.prototype.hasOwnProperty.call(l, "default") ? l.default : void 0);
490
491
  if (!f)
491
- throw new k(`Plugin "${s}" not found in module "${c}".`);
492
+ throw new v(`Plugin "${c}" not found in module "${u}".`);
492
493
  return f;
493
494
  }
494
- const i = await _.the.get(n);
495
- if (i)
496
- return i;
497
- const { [n]: o } = t;
495
+ const a = await _.the.get(i);
496
+ if (a)
497
+ return a;
498
+ const { [i]: o } = t;
498
499
  if (o)
499
500
  return o;
500
501
  if (!e)
501
502
  try {
502
503
  e = await import("ckeditor5-premium-features");
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.`);
504
+ } catch (c) {
505
+ throw console.error(`Failed to load premium package: ${c}`), new v(`Plugin "${i}" not found in base package and failed to load premium package.`);
505
506
  }
506
- const { [n]: u } = e || {};
507
- if (u)
508
- return u;
509
- throw new k(`Plugin "${n}" not found in base or premium packages.`);
507
+ const { [i]: s } = e || {};
508
+ if (s)
509
+ return s;
510
+ throw new v(`Plugin "${i}" not found in base or premium packages.`);
510
511
  });
511
512
  return {
512
- loadedPlugins: await Promise.all(a),
513
+ loadedPlugins: await Promise.all(n),
513
514
  hasPremium: !!e
514
515
  };
515
516
  }
@@ -523,14 +524,14 @@ async function Y(r, t) {
523
524
  B("ckeditor5", e),
524
525
  /* v8 ignore next -- @preserve */
525
526
  t && B("ckeditor5-premium-features", e)
526
- ].filter((n) => !!n)
527
- ).then((n) => n.flat());
527
+ ].filter((i) => !!i)
528
+ ).then((i) => i.flat());
528
529
  }
529
530
  async function B(r, t) {
530
531
  return await Promise.all(
531
532
  t.filter((e) => e !== "en").map(async (e) => {
532
- const a = await mt(r, e);
533
- return a?.default ?? a;
533
+ const n = await mt(r, e);
534
+ return n?.default ?? n;
534
535
  }).filter(Boolean)
535
536
  );
536
537
  }
@@ -835,11 +836,11 @@ async function mt(r, t) {
835
836
  }
836
837
  }
837
838
  function X(r) {
838
- return at(r, (t) => ({
839
+ return nt(r, (t) => ({
839
840
  dictionary: t
840
841
  }));
841
842
  }
842
- function K(r) {
843
+ function Q(r) {
843
844
  return r ? typeof r == "string" ? {
844
845
  ui: r,
845
846
  content: r
@@ -848,87 +849,91 @@ function K(r) {
848
849
  content: "en"
849
850
  };
850
851
  }
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;
858
- }, /* @__PURE__ */ Object.create({})), e = document.querySelector(`cke5-editor[data-cke-editor-id="${r}"]`);
852
+ function Z(r) {
853
+ const t = Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${r}"]`)).reduce((o, s) => {
854
+ const c = s.getAttribute("data-cke-root-name"), u = s.getAttribute("data-cke-root-model-element-name") || null;
855
+ return o[c] = {
856
+ element: s.querySelector("[data-cke-editable-content]"),
857
+ content: s.getAttribute("data-cke-content"),
858
+ modelElement: u
859
+ }, o;
860
+ }, /* @__PURE__ */ Object.create(null)), e = document.querySelector(`cke5-editor[data-cke-editor-id="${r}"]`);
859
861
  if (!e)
860
862
  return 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 || ""
863
+ const n = JSON.parse(e.getAttribute("data-cke-content")) ?? {}, i = document.querySelector(`#${r}_editor`), a = e.getAttribute("data-cke-root-model-element-name");
864
+ i && !t.main && (t.main = {
865
+ element: i,
866
+ content: n.main || "",
867
+ modelElement: a
865
868
  });
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] = {
869
+ for (const [o, s] of Object.entries(n))
870
+ t[o] ? t[o] = {
871
+ ...t[o],
872
+ content: t[o].content ?? s,
873
+ modelElement: t[o].modelElement ?? a
874
+ } : t[o] = {
871
875
  element: null,
872
- content: o
876
+ content: s,
877
+ modelElement: a
873
878
  };
874
879
  return t;
875
880
  }
876
881
  function F() {
877
882
  return Array.from(document.querySelectorAll("cke5-editor")).map((r) => r.getAttribute("data-cke-editor-id")).filter((r) => r !== null);
878
883
  }
879
- function S(r) {
884
+ function M(r) {
880
885
  if (!r || typeof r != "object")
881
886
  return r;
882
887
  if (Array.isArray(r))
883
- return r.map((a) => S(a));
888
+ return r.map((n) => M(n));
884
889
  const t = r;
885
890
  if (t.$element && typeof t.$element == "string") {
886
- const a = document.querySelector(t.$element);
887
- return a || console.warn(`Element not found for selector: ${t.$element}`), a || null;
891
+ const n = document.querySelector(t.$element);
892
+ return n || console.warn(`Element not found for selector: ${t.$element}`), n || null;
888
893
  }
889
894
  const e = /* @__PURE__ */ Object.create(null);
890
- for (const [a, n] of Object.entries(r))
891
- e[a] = S(n);
895
+ for (const [n, i] of Object.entries(r))
896
+ e[n] = M(i);
892
897
  return e;
893
898
  }
894
- function R(r, t, e) {
899
+ function S(r, t, e) {
895
900
  if (!e || typeof e != "object")
896
901
  return e;
897
902
  if (Array.isArray(e))
898
- return e.map((i) => R(r, t, i));
899
- const a = e;
900
- if (a.$translation && typeof a.$translation == "string") {
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;
903
+ return e.map((a) => S(r, t, a));
904
+ const n = e;
905
+ if (n.$translation && typeof n.$translation == "string") {
906
+ const a = n.$translation, o = ht(r, a, t);
907
+ return o === void 0 && console.warn(`Translation not found for key: ${a}`), o !== void 0 ? o : null;
903
908
  }
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;
909
+ const i = /* @__PURE__ */ Object.create(null);
910
+ for (const [a, o] of Object.entries(e))
911
+ i[a] = S(r, t, o);
912
+ return i;
908
913
  }
909
914
  function ht(r, t, e) {
910
- for (const a of r) {
911
- const n = a[e];
912
- if (n?.dictionary && t in n.dictionary)
913
- return n.dictionary[t];
915
+ for (const n of r) {
916
+ const i = n[e];
917
+ if (i?.dictionary && t in i.dictionary)
918
+ return i.dictionary[t];
914
919
  }
915
920
  }
916
921
  function ft(r, t) {
917
922
  const { editing: e } = r;
918
- e.view.change((a) => {
919
- a.setStyle("height", `${t}px`, e.view.document.getRoot());
923
+ e.view.change((n) => {
924
+ n.setStyle("height", `${t}px`, e.view.document.getRoot());
920
925
  });
921
926
  }
922
927
  const $ = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
923
928
  async function pt(r, t) {
924
- const { EditorWatchdog: e } = await import("ckeditor5"), a = new e(null, t ?? {
929
+ const { EditorWatchdog: e } = await import("ckeditor5"), n = new e(null, t ?? {
925
930
  crashNumberLimit: 10,
926
931
  minimumNonErrorTimePeriod: 5e3
927
932
  });
928
- return a.setCreator(async () => {
929
- const n = await r();
930
- return n[$] = a, n;
931
- }), a;
933
+ return n.setCreator(async () => {
934
+ const i = await r();
935
+ return i[$] = n, i;
936
+ }), n;
932
937
  }
933
938
  function wt(r) {
934
939
  return $ in r ? r[$] : null;
@@ -949,31 +954,31 @@ class gt extends HTMLElement {
949
954
  * Mounts the context component.
950
955
  */
951
956
  async connectedCallback() {
952
- await x(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeContext();
957
+ await R(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeContext();
953
958
  }
954
959
  /**
955
960
  * Initializes the context component.
956
961
  */
957
962
  async initializeContext() {
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),
963
+ const t = JSON.parse(this.getAttribute("data-cke-context")), { customTranslations: e, watchdogConfig: n, config: { plugins: i, ...a } } = t, o = this.getAttribute("data-cke-context-id"), s = this.getAttribute("data-cke-language") ? JSON.parse(this.getAttribute("data-cke-language")) : Q(a.language), { loadedPlugins: c, hasPremium: u } = await G(i ?? []), l = [
964
+ ...await Y(s, u),
960
965
  X(e || {})
961
- ].filter((g) => !P(g));
966
+ ].filter((b) => !P(b));
962
967
  this.contextPromise = (async () => {
963
- const { ContextWatchdog: g, Context: p } = await import("ckeditor5"), w = new g(p, {
968
+ const { ContextWatchdog: b, Context: E } = await import("ckeditor5"), w = new b(E, {
964
969
  crashNumberLimit: 10,
965
- ...a
970
+ ...n
966
971
  });
967
- let h = S(i);
968
- return h = R([...d].reverse(), u.ui, h), await w.create({
969
- ...h,
970
- language: u,
971
- plugins: s,
972
- ...d.length && {
973
- translations: d
972
+ let g = M(a);
973
+ return g = S([...l].reverse(), s.ui, g), await w.create({
974
+ ...g,
975
+ language: s,
976
+ plugins: c,
977
+ ...l.length && {
978
+ translations: l
974
979
  }
975
- }), w.on("itemError", (...v) => {
976
- console.error("Context item error:", ...v);
980
+ }), w.on("itemError", (...h) => {
981
+ console.error("Context item error:", ...h);
977
982
  }), w;
978
983
  })();
979
984
  const f = await this.contextPromise;
@@ -1009,61 +1014,62 @@ class bt extends HTMLElement {
1009
1014
  * Mounts the editable component.
1010
1015
  */
1011
1016
  async connectedCallback() {
1012
- await x(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeEditable();
1017
+ await R(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeEditable();
1013
1018
  }
1014
1019
  /**
1015
1020
  * Initializes the editable instance.
1016
1021
  */
1017
1022
  async initializeEditable() {
1018
1023
  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);
1024
+ const t = this.getAttribute("data-cke-editor-id"), e = this.getAttribute("data-cke-root-name"), n = JSON.parse(this.getAttribute("data-cke-root-attributes") || "{}"), i = this.getAttribute("data-cke-root-model-element-name") || "$root", a = this.getAttribute("data-cke-content"), o = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10);
1020
1025
  if (!t || !e)
1021
- throw new k("Editor ID or Root Name is missing.");
1022
- this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (o) => {
1026
+ throw new v("Editor ID or Root Name is missing.");
1027
+ this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (s) => {
1023
1028
  if (!this.isConnected)
1024
1029
  return;
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) {
1028
- const h = o.getData({ rootName: e });
1029
- h && h !== n && o.setData({
1030
- [e]: n
1030
+ const { ui: c, editing: u, model: d } = s, l = this.querySelector("input"), f = d.document.getRoot(e);
1031
+ if (f?.isAttached()) {
1032
+ if (a !== null) {
1033
+ const h = s.getData({ rootName: e });
1034
+ h && h !== a && s.setData({
1035
+ [e]: a
1031
1036
  });
1032
1037
  }
1033
- P(a) || o.model.change((h) => {
1034
- h.setAttributes(a, d);
1038
+ P(n) || s.model.change((h) => {
1039
+ h.setAttributes(n, f);
1035
1040
  });
1036
1041
  return;
1037
1042
  }
1038
- o.addRoot(e, {
1043
+ s.addRoot(e, {
1039
1044
  isUndoable: !1,
1040
- modelAttributes: { ...a },
1041
- ...n !== null && {
1042
- initialData: n
1045
+ modelAttributes: { ...n },
1046
+ modelElement: i,
1047
+ ...a !== null && {
1048
+ initialData: a
1043
1049
  }
1044
1050
  });
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())
1051
+ const b = this.querySelector("[data-cke-editable-content]"), E = c.view.createEditable(e, b);
1052
+ c.addEditable(E), u.view.forceRender();
1053
+ const w = () => {
1054
+ if (!d.document.getRoot(e)?.isAttached())
1049
1055
  return;
1050
- const h = o.getData({ rootName: e });
1056
+ const h = s.getData({ rootName: e });
1051
1057
  l && (l.value = h, l.dispatchEvent(new Event("input"))), this.dispatchEvent(new CustomEvent("change", {
1052
1058
  detail: {
1053
1059
  value: h
1054
1060
  }
1055
1061
  }));
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) {
1059
- const h = o.model.document.getRoot(e);
1060
- if (h && "detachEditable" in o) {
1062
+ }, g = W(o, w);
1063
+ return s.model.document.on("change:data", g), w(), () => {
1064
+ if (s.model.document.off("change:data", g), s.state !== "destroyed" && e) {
1065
+ const h = s.model.document.getRoot(e);
1066
+ if (h && "detachEditable" in s) {
1061
1067
  try {
1062
- o.ui.view.editables[e] && o.detachEditable(h);
1063
- } catch (v) {
1064
- console.error("Unable unmount editable from root:", v);
1068
+ s.ui.view.editables[e] && s.detachEditable(h);
1069
+ } catch (p) {
1070
+ console.error("Unable unmount editable from root:", p);
1065
1071
  }
1066
- h.isAttached() && o.detachRoot(e, !1);
1072
+ h.isAttached() && s.detachRoot(e, !1);
1067
1073
  }
1068
1074
  }
1069
1075
  };
@@ -1076,13 +1082,13 @@ class bt extends HTMLElement {
1076
1082
  this.interactiveWait?.disconnect(), this.style.display = "none", this.unmountEffect?.(), this.unmountEffect = null;
1077
1083
  }
1078
1084
  }
1079
- async function yt({
1085
+ async function Et({
1080
1086
  saveDebounceMs: r,
1081
1087
  editorId: t,
1082
1088
  targetElement: e
1083
1089
  }) {
1084
- const { Plugin: a } = await import("ckeditor5");
1085
- return class extends a {
1090
+ const { Plugin: n } = await import("ckeditor5");
1091
+ return class extends n {
1086
1092
  /**
1087
1093
  * The name of the plugin.
1088
1094
  */
@@ -1093,19 +1099,19 @@ async function yt({
1093
1099
  * Initializes the plugin.
1094
1100
  */
1095
1101
  afterInit() {
1096
- const { editor: i } = this, o = W(r, this.dispatch);
1097
- i.model.document.on("change:data", o), i.once("ready", this.dispatch);
1102
+ const { editor: a } = this, o = W(r, this.dispatch);
1103
+ a.model.document.on("change:data", o), a.once("ready", this.dispatch);
1098
1104
  }
1099
1105
  /**
1100
1106
  * Dispatches a custom event with all roots data.
1101
1107
  */
1102
1108
  dispatch = () => {
1103
- const { editor: i } = this;
1109
+ const { editor: a } = this;
1104
1110
  e.dispatchEvent(
1105
1111
  new y({
1106
1112
  editorId: t,
1107
- editor: i,
1108
- roots: J(i)
1113
+ editor: a,
1114
+ roots: J(a)
1109
1115
  })
1110
1116
  );
1111
1117
  };
@@ -1120,7 +1126,7 @@ class y extends CustomEvent {
1120
1126
  });
1121
1127
  }
1122
1128
  }
1123
- async function Et(r) {
1129
+ async function yt(r) {
1124
1130
  const { Plugin: t } = await import("ckeditor5");
1125
1131
  return class extends t {
1126
1132
  /**
@@ -1141,16 +1147,16 @@ async function Et(r) {
1141
1147
  * Initializes the plugin.
1142
1148
  */
1143
1149
  afterInit() {
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));
1150
+ const { editor: n } = this, a = n.sourceElement.id.replace(/_editor$/, "");
1151
+ this.input = document.getElementById(`${a}_input`), this.input && (n.model.document.on("change:data", W(r, () => this.sync())), n.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
1146
1152
  }
1147
1153
  /**
1148
1154
  * Synchronizes the editor's content with the input field.
1149
1155
  */
1150
1156
  sync = () => {
1151
1157
  if (this.input) {
1152
- const a = this.editor.getData();
1153
- this.input.value = a, this.input.dispatchEvent(new Event("input", { bubbles: !0 }));
1158
+ const n = this.editor.getData();
1159
+ this.input.value = n, this.input.dispatchEvent(new Event("input", { bubbles: !0 }));
1154
1160
  }
1155
1161
  };
1156
1162
  /**
@@ -1174,7 +1180,7 @@ class kt extends HTMLElement {
1174
1180
  * Mounts the editor component.
1175
1181
  */
1176
1182
  async connectedCallback() {
1177
- await x(), this.interactiveWait = L(this), U("classic"), await this.interactiveWait.promise, await this.initializeEditor();
1183
+ await R(), this.interactiveWait = L(this), j("classic"), await this.interactiveWait.promise, await this.initializeEditor();
1178
1184
  }
1179
1185
  /**
1180
1186
  * Initializes the editor instance.
@@ -1184,15 +1190,15 @@ class kt extends HTMLElement {
1184
1190
  m.the.resetErrors(t);
1185
1191
  try {
1186
1192
  this.style.display = "block";
1187
- const e = await this.createEditor(), a = lt(e), n = wt(e);
1193
+ const e = await this.createEditor(), n = lt(e), i = wt(e);
1188
1194
  if (this.isConnected) {
1189
- const i = m.the.mountEffect(t, (o) => {
1195
+ const a = m.the.mountEffect(t, (o) => {
1190
1196
  o.once("destroy", () => {
1191
1197
  m.the.unregister(t, !1);
1192
1198
  }, { priority: "highest" });
1193
1199
  });
1194
1200
  this.unmountEffect = async () => {
1195
- m.the.unregister(t), i(), a ? a.state !== "unavailable" && await a.context.remove(a.editorContextId) : n ? await n.destroy() : await e.destroy();
1201
+ m.the.unregister(t), a(), n ? n.state !== "unavailable" && await n.context.remove(n.editorContextId) : i ? await i.destroy() : await e.destroy();
1196
1202
  }, m.the.register(t, e);
1197
1203
  }
1198
1204
  } catch (e) {
@@ -1212,75 +1218,75 @@ class kt extends HTMLElement {
1212
1218
  async createEditor() {
1213
1219
  const t = JSON.parse(this.getAttribute("data-cke-preset")), {
1214
1220
  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({
1221
+ editorType: n,
1222
+ licenseKey: i,
1223
+ watchdogConfig: a,
1224
+ config: { plugins: o, ...s }
1225
+ } = t, c = this.getAttribute("data-cke-editor-id"), u = this.getAttribute("data-cke-context-id"), d = JSON.parse(this.getAttribute("data-cke-root-attributes") || "{}"), l = 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"), E = this.getAttribute("data-cke-language") ? JSON.parse(this.getAttribute("data-cke-language")) : Q(t.config.language), w = await j(n), g = await (u ? C.the.waitFor(u) : null), h = async () => {
1226
+ const { loadedPlugins: p, hasPremium: I } = await G(o);
1227
+ p.push(
1228
+ await Et({
1223
1229
  saveDebounceMs: f,
1224
- editorId: s,
1230
+ editorId: c,
1225
1231
  targetElement: this
1226
1232
  })
1227
- ), V(a) && b.push(
1228
- await Et(f)
1233
+ ), V(n) && p.push(
1234
+ await yt(f)
1229
1235
  );
1230
1236
  const A = [
1231
- ...await Y(p, I),
1237
+ ...await Y(E, I),
1232
1238
  X(e || {})
1233
1239
  ].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,
1240
+ let T = Z(c);
1241
+ const D = Object.keys(T);
1242
+ V(n) && D.push("main"), K(T, D) || (T = await vt(c, D));
1243
+ let k = {
1244
+ ...s,
1245
+ licenseKey: i,
1246
+ plugins: p,
1247
+ language: E,
1242
1248
  ...A.length && {
1243
1249
  translations: A
1244
1250
  }
1245
1251
  };
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,
1252
+ k = M(k), k = S([...A].reverse(), E.ui, k), k = st(w, T, k);
1253
+ const O = await (async () => g ? (await ut({
1254
+ context: g,
1249
1255
  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;
1256
+ config: k
1257
+ })).editor : w.create(k))();
1258
+ return P(d) || O.model.change((N) => {
1259
+ N.setAttributes(d, O.model.document.getRoot());
1260
+ }), V(n) && l && ft(O, l), O;
1255
1261
  };
1256
- if (g && !h) {
1257
- const b = await pt(v, i);
1258
- return b.on("error", (I, { causesRestart: q }) => {
1262
+ if (b && !g) {
1263
+ const p = await pt(h, a);
1264
+ return p.on("error", (I, { causesRestart: q }) => {
1259
1265
  if (q) {
1260
- const A = m.the.getItem(s);
1261
- A && (ct(A), m.the.unregister(s));
1266
+ const A = m.the.getItem(c);
1267
+ A && (ct(A), m.the.unregister(c));
1262
1268
  }
1263
- }), b.on("restart", () => {
1264
- const I = b.editor;
1265
- m.the.register(s, I);
1266
- }), await b.create({}), b.editor;
1269
+ }), p.on("restart", () => {
1270
+ const I = p.editor;
1271
+ m.the.register(c, I);
1272
+ }), await p.create({}), p.editor;
1267
1273
  }
1268
- return v();
1274
+ return h();
1269
1275
  }
1270
1276
  }
1271
- function Z(r, t) {
1277
+ function K(r, t) {
1272
1278
  return t.every((e) => r[e]?.element);
1273
1279
  }
1274
1280
  async function vt(r, t) {
1275
1281
  return ot(
1276
1282
  () => {
1277
- const e = Q(r);
1278
- if (!Z(e, t))
1283
+ const e = Z(r);
1284
+ if (!K(e, t))
1279
1285
  throw new Error(
1280
1286
  `It looks like not all required root elements are present yet.
1281
1287
  * If you want to wait for them, ensure they are registered before editor initialization.
1282
1288
  * If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
1283
- Missing roots: ${t.filter((a) => !e[a]?.element).join(", ")}.`
1289
+ Missing roots: ${t.filter((n) => !e[n]?.element).join(", ")}.`
1284
1290
  );
1285
1291
  return e;
1286
1292
  },
@@ -1296,14 +1302,14 @@ class At extends HTMLElement {
1296
1302
  * Mounts the UI part component.
1297
1303
  */
1298
1304
  async connectedCallback() {
1299
- await x();
1305
+ await R();
1300
1306
  const t = this.getAttribute("data-cke-editor-id") || F()[0], e = this.getAttribute("data-cke-name");
1301
- !t || !e || (this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (a) => {
1307
+ !t || !e || (this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (n) => {
1302
1308
  if (!this.isConnected)
1303
1309
  return;
1304
- const { ui: n } = a, i = Ct(e), o = n.view[i];
1310
+ const { ui: i } = n, a = Ct(e), o = i.view[a];
1305
1311
  if (!o)
1306
- throw new k(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
1312
+ throw new v(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
1307
1313
  return this.appendChild(o.element), () => {
1308
1314
  this.innerHTML = "";
1309
1315
  };
@@ -1337,8 +1343,8 @@ function Tt() {
1337
1343
  for (const [r, t] of Object.entries(It))
1338
1344
  window.customElements.get(r) || window.customElements.define(r, t);
1339
1345
  }
1340
- function Rt(r) {
1341
- return D(r), {
1346
+ function St(r) {
1347
+ return x(r), {
1342
1348
  unmount() {
1343
1349
  }
1344
1350
  };
@@ -1349,21 +1355,21 @@ function tt(r, t) {
1349
1355
  pendingValue: null,
1350
1356
  /** The last value sent to or received from Blazor to prevent circular updates. */
1351
1357
  lastSyncedValue: null
1352
- }, a = () => {
1358
+ }, n = () => {
1353
1359
  e.pendingValue = null;
1354
- }, n = (i, o, u) => {
1355
- if (u || e.pendingValue === null)
1360
+ }, i = (a, o, s) => {
1361
+ if (s || e.pendingValue === null)
1356
1362
  return;
1357
- const s = t.getCurrentValue();
1358
- t.isEqual(s, e.pendingValue) || t.applyValue(e.pendingValue), e.pendingValue = null;
1363
+ const c = t.getCurrentValue();
1364
+ t.isEqual(c, e.pendingValue) || t.applyValue(e.pendingValue), e.pendingValue = null;
1359
1365
  };
1360
- return r.model.document.on("change:data", a), r.ui.focusTracker.on("change:isFocused", n), {
1366
+ return r.model.document.on("change:data", n), r.ui.focusTracker.on("change:isFocused", i), {
1361
1367
  /**
1362
1368
  * Removes all editor listeners registered by this sync instance.
1363
1369
  * Call this when the Blazor component is disposed.
1364
1370
  */
1365
1371
  unmount() {
1366
- r.model.document.off("change:data", a), r.ui.focusTracker.off("change:isFocused", n);
1372
+ r.model.document.off("change:data", n), r.ui.focusTracker.off("change:isFocused", i);
1367
1373
  },
1368
1374
  /**
1369
1375
  * Checks whether the given value differs from the last synced value and, if so,
@@ -1372,20 +1378,20 @@ function tt(r, t) {
1372
1378
  * Call this from the `CKEditor5ChangeDataEvent` handler to conditionally invoke
1373
1379
  * the .NET interop method.
1374
1380
  */
1375
- shouldNotify(i) {
1376
- return e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, i) ? !1 : (e.lastSyncedValue = i, !0);
1381
+ shouldNotify(a) {
1382
+ return e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, a) ? !1 : (e.lastSyncedValue = a, !0);
1377
1383
  },
1378
1384
  /**
1379
1385
  * Pushes a new value from Blazor into the editor.
1380
1386
  * If the editor is currently focused, the update is deferred until blur.
1381
1387
  * If the value matches the last synced state, the update is skipped entirely.
1382
1388
  */
1383
- setValue(i) {
1389
+ setValue(a) {
1384
1390
  if (r.ui.focusTracker.isFocused) {
1385
- e.pendingValue = i;
1391
+ e.pendingValue = a;
1386
1392
  return;
1387
1393
  }
1388
- e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, i) || (e.lastSyncedValue = i, t.applyValue(i));
1394
+ e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, a) || (e.lastSyncedValue = a, t.applyValue(a));
1389
1395
  }
1390
1396
  };
1391
1397
  }
@@ -1402,93 +1408,93 @@ function et() {
1402
1408
  }
1403
1409
  function rt(r, t) {
1404
1410
  const e = /* @__PURE__ */ new Set();
1405
- return (a) => {
1406
- r.model.enqueueChange({ isUndoable: !1 }, (n) => {
1407
- const i = r.model.document.getRoot(t);
1408
- if (i) {
1411
+ return (n) => {
1412
+ r.model.enqueueChange({ isUndoable: !1 }, (i) => {
1413
+ const a = r.model.document.getRoot(t);
1414
+ if (a) {
1409
1415
  for (const o of e)
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);
1416
+ n && o in n || (i.removeAttribute(o, a), e.delete(o));
1417
+ for (const [o, s] of Object.entries(n ?? {}))
1418
+ i.setAttribute(o, s, a), e.add(o);
1413
1419
  }
1414
1420
  });
1415
1421
  };
1416
1422
  }
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)
1423
+ function Rt(r, t) {
1424
+ const e = r.getAttribute("data-cke-editor-id") ?? F()[0], n = r.getAttribute("data-cke-root-name") ?? "main";
1425
+ let i = !1, a = null, o = null, s = et(), c = null;
1426
+ const u = (d) => {
1427
+ if (!(d instanceof y) || d.detail.editorId !== e)
1422
1428
  return;
1423
- const d = l.detail.roots[a];
1424
- d !== void 0 && u.shouldNotify(d) && t.invokeMethodAsync("OnChangeEditableData", o, d);
1429
+ const l = d.detail.roots[n];
1430
+ l !== void 0 && s.shouldNotify(l) && t.invokeMethodAsync("OnChangeEditableData", o, l);
1425
1431
  };
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), {
1432
+ return a = m.the.mountEffect(e, (d) => (o = globalThis.DotNet.createJSObjectReference(d), s = tt(d, {
1433
+ getCurrentValue: () => d.getData({ rootName: n }) ?? "",
1434
+ applyValue: (l) => d.setData({ [n]: l }),
1435
+ isEqual: (l, f) => l === f
1436
+ }), c = rt(d, n), () => {
1437
+ s.unmount(), o && (globalThis.DotNet?.disposeJSObjectReference(o), o = null), c = null;
1438
+ })), document.body.addEventListener(y.EVENT_NAME, u), x(r), {
1433
1439
  /**
1434
1440
  * Cleans up all event listeners when the Blazor component is disposed.
1435
1441
  */
1436
1442
  unmount() {
1437
- n || (document.body.removeEventListener(y.EVENT_NAME, c), i?.(), i = null, n = !0);
1443
+ i || (document.body.removeEventListener(y.EVENT_NAME, u), a?.(), a = null, i = !0);
1438
1444
  },
1439
1445
  /**
1440
1446
  * Updates this editable root's data from Blazor.
1441
1447
  * If the editor is focused, the update is deferred until blur to avoid interrupting the user.
1442
1448
  */
1443
- setValue: async (l) => {
1444
- n || (await m.the.waitFor(e), u.setValue(l));
1449
+ setValue: async (d) => {
1450
+ i || (await m.the.waitFor(e), s.setValue(d));
1445
1451
  },
1446
1452
  /**
1447
1453
  * Updates the root attributes on the editor. This is useful when the Blazor component
1448
1454
  * re-renders with new root attributes.
1449
1455
  */
1450
- setRootAttributes: async (l) => {
1451
- n || (await m.the.waitFor(e), s?.(l));
1456
+ setRootAttributes: async (d) => {
1457
+ i || (await m.the.waitFor(e), c?.(d));
1452
1458
  }
1453
1459
  };
1454
1460
  }
1455
- function Dt(r, t) {
1461
+ function xt(r, t) {
1456
1462
  const e = r.getAttribute("data-cke-editor-id");
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);
1463
+ let n = !1, i = null, a = et(), o = null, s = null;
1464
+ const c = (u) => {
1465
+ !(u instanceof y) || u.detail.editorId !== e || a.shouldNotify(u.detail.roots) && t.invokeMethodAsync("OnChangeEditorData", s, u.detail.roots);
1460
1466
  };
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);
1467
+ return i = m.the.mountEffect(e, (u) => {
1468
+ s = globalThis.DotNet.createJSObjectReference(u), a = tt(u, {
1469
+ getCurrentValue: () => J(u),
1470
+ applyValue: (l) => u.setData(l),
1471
+ isEqual: at
1472
+ }), o = rt(u, "main");
1473
+ const d = (l, f, b) => {
1474
+ const E = b ? "OnEditorFocus" : "OnEditorBlur";
1475
+ t.invokeMethodAsync(E, s);
1470
1476
  };
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;
1477
+ return u.ui.focusTracker.on("change:isFocused", d), t.invokeMethodAsync("OnEditorReady", s), () => {
1478
+ u.ui.focusTracker.off("change:isFocused", d), a.unmount(), s && (globalThis.DotNet?.disposeJSObjectReference(s), s = null), o = null;
1473
1479
  };
1474
- }), document.body.addEventListener(y.EVENT_NAME, s), Tt(), D(r), {
1480
+ }), document.body.addEventListener(y.EVENT_NAME, c), Tt(), x(r), {
1475
1481
  /**
1476
1482
  * Updates the editor data from Blazor. If the editor is focused, the update is deferred until blur to avoid interrupting the user.
1477
1483
  */
1478
- setValue: async (c) => {
1479
- a || (await m.the.waitFor(e), i.setValue(c));
1484
+ setValue: async (u) => {
1485
+ n || (await m.the.waitFor(e), a.setValue(u));
1480
1486
  },
1481
1487
  /**
1482
1488
  * Updates the root attributes on the editor instance.
1483
1489
  */
1484
- setRootAttributes: async (c) => {
1485
- a || (await m.the.waitFor(e), o?.(c));
1490
+ setRootAttributes: async (u) => {
1491
+ n || (await m.the.waitFor(e), o?.(u));
1486
1492
  },
1487
1493
  /**
1488
1494
  * Cleans up all event listeners when the Blazor component is disposed.
1489
1495
  */
1490
1496
  unmount() {
1491
- a || (document.body.removeEventListener(y.EVENT_NAME, s), n?.(), n = null, a = !0);
1497
+ n || (document.body.removeEventListener(y.EVENT_NAME, c), i?.(), i = null, n = !0);
1492
1498
  },
1493
1499
  /**
1494
1500
  * Installs the custom image upload adapter that delegates uploads to Blazor.
@@ -1496,8 +1502,8 @@ function Dt(r, t) {
1496
1502
  * to avoid unnecessary overhead for consumers that don't use this feature.
1497
1503
  */
1498
1504
  attachImageUploadAdapter: async () => {
1499
- a || m.the.mountEffect(e, (c) => {
1500
- Ot(c, t);
1505
+ n || m.the.mountEffect(e, (u) => {
1506
+ Ot(u, t);
1501
1507
  });
1502
1508
  }
1503
1509
  };
@@ -1506,47 +1512,47 @@ function Ot(r, t) {
1506
1512
  if (!r.plugins.has("FileRepository"))
1507
1513
  return;
1508
1514
  const e = r.plugins.get("FileRepository");
1509
- e.createUploadAdapter = (a) => {
1510
- let n = !1;
1515
+ e.createUploadAdapter = (n) => {
1516
+ let i = !1;
1511
1517
  return {
1512
1518
  async upload() {
1513
- const i = await a.file;
1514
- if (n)
1519
+ const a = await n.file;
1520
+ if (i)
1515
1521
  throw new Error("Upload aborted.");
1516
- const o = await Nt(i), u = await t.invokeMethodAsync("OnEditorImageUpload", {
1517
- fileName: i.name,
1518
- mimeType: i.type,
1522
+ const o = await Nt(a), s = await t.invokeMethodAsync("OnEditorImageUpload", {
1523
+ fileName: a.name,
1524
+ mimeType: a.type,
1519
1525
  payload: o
1520
1526
  });
1521
- if (!u)
1527
+ if (!s)
1522
1528
  throw new Error(
1523
1529
  "OnImageUpload handler returned null. Make sure the OnImageUpload parameter is set on the <CKE5Editor> component."
1524
1530
  );
1525
- return { default: u };
1531
+ return { default: s };
1526
1532
  },
1527
1533
  abort() {
1528
- n = !0;
1534
+ i = !0;
1529
1535
  }
1530
1536
  };
1531
1537
  };
1532
1538
  }
1533
1539
  function Nt(r) {
1534
1540
  return new Promise((t, e) => {
1535
- const a = new FileReader();
1536
- a.onload = () => {
1537
- const n = a.result, i = n.split(",")[1] ?? n;
1538
- t(i);
1539
- }, a.onerror = () => e(a.error), a.readAsDataURL(r);
1541
+ const n = new FileReader();
1542
+ n.onload = () => {
1543
+ const i = n.result, a = i.split(",")[1] ?? i;
1544
+ t(a);
1545
+ }, n.onerror = () => e(n.error), n.readAsDataURL(r);
1540
1546
  });
1541
1547
  }
1542
- function Mt(r) {
1543
- return D(r), {
1548
+ function Dt(r) {
1549
+ return x(r), {
1544
1550
  unmount() {
1545
1551
  }
1546
1552
  };
1547
1553
  }
1548
1554
  export {
1549
- k as CKEditor5BlazorError,
1555
+ v as CKEditor5BlazorError,
1550
1556
  y as CKEditor5ChangeDataEvent,
1551
1557
  C as ContextsRegistry,
1552
1558
  _ as CustomEditorPluginsRegistry,
@@ -1554,10 +1560,10 @@ export {
1554
1560
  kt as EditorComponentElement,
1555
1561
  m as EditorsRegistry,
1556
1562
  At as UIPartComponentElement,
1557
- Rt as createContextBlazorInterop,
1558
- xt as createEditableBlazorInterop,
1559
- Dt as createEditorBlazorInterop,
1560
- Mt as createUIPartBlazorInterop,
1563
+ St as createContextBlazorInterop,
1564
+ Rt as createEditableBlazorInterop,
1565
+ xt as createEditorBlazorInterop,
1566
+ Dt as createUIPartBlazorInterop,
1561
1567
  Tt as ensureEditorElementsRegistered
1562
1568
  };
1563
1569
  //# sourceMappingURL=index.mjs.map