ckeditor5-phoenix 1.27.1 → 1.27.2

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,4 +1,4 @@
1
- function H(r, t) {
1
+ function j(r, t) {
2
2
  if (!r || r.size !== t.size)
3
3
  return !1;
4
4
  for (const [e, a] of r)
@@ -6,7 +6,7 @@ function H(r, t) {
6
6
  return !1;
7
7
  return !0;
8
8
  }
9
- class K {
9
+ class W {
10
10
  /**
11
11
  * Map of registered items.
12
12
  */
@@ -215,7 +215,7 @@ class K {
215
215
  * Immediately dispatches the current state to all watchers if it changed.
216
216
  */
217
217
  flushWatchers() {
218
- 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(
218
+ 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(
219
219
  new Map(this.items),
220
220
  new Map(this.initializationErrors)
221
221
  )));
@@ -231,10 +231,10 @@ class K {
231
231
  return e || (e = { success: [], error: [] }, this.pendingCallbacks.set(t, e)), e;
232
232
  }
233
233
  }
234
- function rt(r) {
234
+ function Z(r) {
235
235
  return r.replace(/[-_\s]+(.)?/g, (t, e) => e ? e.toUpperCase() : "").replace(/^./, (t) => t.toLowerCase());
236
236
  }
237
- function I(r, t) {
237
+ function P(r, t) {
238
238
  let e = null;
239
239
  return (...a) => {
240
240
  e && clearTimeout(e), e = setTimeout(() => {
@@ -242,35 +242,31 @@ function I(r, t) {
242
242
  }, r);
243
243
  };
244
244
  }
245
- function at(r) {
245
+ function tt(r) {
246
246
  if (Object.prototype.toString.call(r) !== "[object Object]")
247
247
  return !1;
248
248
  const t = Object.getPrototypeOf(r);
249
249
  return t === Object.prototype || t === null;
250
250
  }
251
- function O(r) {
251
+ function A(r) {
252
252
  if (Array.isArray(r))
253
- return r.map(O);
254
- if (at(r)) {
253
+ return r.map(A);
254
+ if (tt(r)) {
255
255
  const t = /* @__PURE__ */ Object.create(null);
256
256
  for (const [e, a] of Object.entries(r))
257
- t[rt(e)] = O(a);
257
+ t[Z(e)] = A(a);
258
258
  return t;
259
259
  }
260
260
  return r;
261
261
  }
262
- function nt(r, t) {
263
- const e = Object.entries(r).filter(([a, n]) => t(n, a));
264
- return Object.fromEntries(e);
265
- }
266
- function it() {
262
+ function et() {
267
263
  const r = document.querySelector('meta[name="csrf-token"]');
268
264
  if (r)
269
265
  return r.getAttribute("content");
270
266
  const t = document.cookie.match(/(?:^|; )_csrf_token=([^;]*)/);
271
267
  return t ? decodeURIComponent(t[1]) : null;
272
268
  }
273
- class S {
269
+ class x {
274
270
  /**
275
271
  * The current state of the hook.
276
272
  */
@@ -345,7 +341,7 @@ class S {
345
341
  this._beforeDestroyCallbacks = [];
346
342
  }
347
343
  }
348
- function N(r) {
344
+ function O(r) {
349
345
  return {
350
346
  /**
351
347
  * The mounted lifecycle callback for the LiveView hook object.
@@ -390,26 +386,26 @@ function N(r) {
390
386
  }
391
387
  };
392
388
  }
393
- function Y(r) {
389
+ function L(r) {
394
390
  return Object.keys(r).length === 0 && r.constructor === Object;
395
391
  }
396
- function st(r) {
392
+ function rt(r) {
397
393
  return r == null;
398
394
  }
399
- function j(r, t) {
395
+ function at(r, t) {
400
396
  const e = Object.entries(r).map(([a, n]) => [a, t(n, a)]);
401
397
  return Object.fromEntries(e);
402
398
  }
403
- function q(r) {
399
+ function H(r) {
404
400
  if (r === null)
405
401
  return null;
406
402
  const t = Number.parseInt(r, 10);
407
403
  return Number.isNaN(t) ? null : t;
408
404
  }
409
- function ot(r) {
405
+ function nt(r) {
410
406
  return r == null || r.trim() === "" ? null : JSON.parse(r);
411
407
  }
412
- function ct(r, t) {
408
+ function it(r, t) {
413
409
  if (r === t)
414
410
  return !0;
415
411
  const e = Object.keys(r), a = Object.keys(t);
@@ -420,10 +416,10 @@ function ct(r, t) {
420
416
  return !1;
421
417
  return !0;
422
418
  }
423
- function ut() {
419
+ function st() {
424
420
  return Math.random().toString(36).substring(2);
425
421
  }
426
- function lt(r, {
422
+ function ot(r, {
427
423
  timeOutAfter: t = 500,
428
424
  retryAfter: e = 100
429
425
  } = {}) {
@@ -443,60 +439,32 @@ function lt(r, {
443
439
  o();
444
440
  });
445
441
  }
446
- function dt(r, t) {
447
- const e = ht(r), a = /* @__PURE__ */ new Set([
448
- ...Object.keys(e),
449
- ...Object.keys(t.roots ?? {})
450
- ]), n = Array.from(a).reduce((s, c) => ({
451
- ...s,
452
- [c]: {
453
- ...t.roots?.[c],
454
- ...c === "main" ? t.root : {},
455
- /* v8 ignore next 5 */
456
- ...c in e ? {
457
- initialData: e[c]
458
- } : {}
459
- }
460
- }), Object.create(t.roots || {})), i = {
461
- ...t,
462
- roots: n
463
- };
464
- return delete i.root, i;
465
- }
466
- function ht(r) {
467
- return typeof r == "string" ? { main: r } : { ...r };
468
- }
469
- function mt(r, t, e) {
470
- const a = pt(t);
471
- if (!r.editorName || r.editorName === "ClassicEditor")
472
- return {
473
- ...e,
474
- attachTo: a.main
475
- };
476
- const n = /* @__PURE__ */ new Set([
477
- ...Object.keys(a),
442
+ function ct(r, t, e) {
443
+ const a = !r.editorName || r.editorName === "ClassicEditor", n = /* @__PURE__ */ new Set([
444
+ ...Object.keys(t),
478
445
  ...Object.keys(e.roots ?? {})
479
446
  ]), i = Array.from(n).reduce((c, o) => ({
480
447
  ...c,
481
448
  [o]: {
482
- /* v8 ignore next */
449
+ /* v8 ignore next 1 */
483
450
  ...e.roots?.[o],
484
451
  ...o === "main" ? e.root : {},
485
- /* v8 ignore next 5 */
486
- ...o in a ? {
487
- element: a[o]
452
+ /* v8 ignore next 6 */
453
+ ...o in t ? {
454
+ initialData: t[o].initialValue,
455
+ ...!a && { element: t[o].content }
488
456
  } : {}
489
457
  }
490
458
  }), Object.create(e.roots || {})), s = {
491
459
  ...e,
492
- roots: i
460
+ roots: i,
461
+ ...a && {
462
+ attachTo: t.main?.content
463
+ }
493
464
  };
494
465
  return delete s.root, s;
495
466
  }
496
- function pt(r) {
497
- return r instanceof HTMLElement ? { main: r } : { ...r };
498
- }
499
- function ft(r) {
467
+ function ut(r) {
500
468
  const t = [
501
469
  r.ui?.element,
502
470
  r.ui?.view?.toolbar?.element,
@@ -523,8 +491,8 @@ function ft(r) {
523
491
  }
524
492
  }
525
493
  const R = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
526
- async function wt({ context: r, creator: t, config: e }) {
527
- const a = ut();
494
+ async function lt({ context: r, creator: t, config: e }) {
495
+ const a = st();
528
496
  await r.add({
529
497
  creator: t.create.bind(t),
530
498
  id: a,
@@ -543,16 +511,16 @@ async function wt({ context: r, creator: t, config: e }) {
543
511
  editor: n
544
512
  };
545
513
  }
546
- function gt(r) {
514
+ function dt(r) {
547
515
  return R in r ? r[R] : null;
548
516
  }
549
- function B(r) {
517
+ function q(r) {
550
518
  return "addEditable" in r.ui;
551
519
  }
552
- function T(r) {
520
+ function N(r) {
553
521
  return ["inline", "classic", "balloon", "decoupled"].includes(r);
554
522
  }
555
- async function bt(r) {
523
+ async function ht(r) {
556
524
  const t = await import("ckeditor5"), a = {
557
525
  inline: t.InlineEditor,
558
526
  balloon: t.BalloonEditor,
@@ -624,7 +592,7 @@ class $ {
624
592
  return this.plugins.has(t);
625
593
  }
626
594
  }
627
- async function J(r) {
595
+ async function K(r) {
628
596
  const t = await import("ckeditor5");
629
597
  let e = null;
630
598
  const a = r.map(async (n) => {
@@ -650,25 +618,25 @@ async function J(r) {
650
618
  hasPremium: !!e
651
619
  };
652
620
  }
653
- async function G(r, t) {
621
+ async function Y(r, t) {
654
622
  const e = [r.ui, r.content];
655
623
  return await Promise.all(
656
624
  [
657
- F("ckeditor5", e),
625
+ B("ckeditor5", e),
658
626
  /* v8 ignore next */
659
- t && F("ckeditor5-premium-features", e)
627
+ t && B("ckeditor5-premium-features", e)
660
628
  ].filter((n) => !!n)
661
629
  ).then((n) => n.flat());
662
630
  }
663
- async function F(r, t) {
631
+ async function B(r, t) {
664
632
  return await Promise.all(
665
633
  t.filter((e) => e !== "en").map(async (e) => {
666
- const a = await yt(r, e);
634
+ const a = await mt(r, e);
667
635
  return a?.default ?? a;
668
636
  }).filter(Boolean)
669
637
  );
670
638
  }
671
- async function yt(r, t) {
639
+ async function mt(r, t) {
672
640
  try {
673
641
  if (r === "ckeditor5")
674
642
  switch (t) {
@@ -968,20 +936,12 @@ async function yt(r, t) {
968
936
  return console.error(`Failed to load translation for ${r}/${t}:`, e), null;
969
937
  }
970
938
  }
971
- function X(r) {
972
- return j(r, (t) => ({
939
+ function J(r) {
940
+ return at(r, (t) => ({
973
941
  dictionary: t
974
942
  }));
975
943
  }
976
- function Q(r) {
977
- const t = Z(r);
978
- return j(t, ({ content: e }) => e);
979
- }
980
- function L(r) {
981
- const t = Z(r), e = j(t, ({ initialValue: a }) => a);
982
- return nt(e, (a) => typeof a == "string");
983
- }
984
- function Z(r) {
944
+ function G(r) {
985
945
  const t = document.querySelectorAll(
986
946
  [
987
947
  `[data-cke-editor-id="${r}"][data-cke-editable-root-name]`,
@@ -1014,29 +974,29 @@ function Z(r) {
1014
974
  }
1015
975
  } : e;
1016
976
  }
1017
- const W = ["inline", "classic", "balloon", "decoupled", "multiroot"];
1018
- function kt(r) {
977
+ const F = ["inline", "classic", "balloon", "decoupled", "multiroot"];
978
+ function pt(r) {
1019
979
  const t = r.getAttribute("data-cke-preset");
1020
980
  if (!t)
1021
981
  throw new Error('CKEditor5 hook requires a "cke-preset" attribute on the element.');
1022
982
  const { type: e, config: a, license: n, watchdog: i, ...s } = JSON.parse(t);
1023
983
  if (!e || !a || !n)
1024
984
  throw new Error('CKEditor5 hook configuration must include "editor", "config", and "license" properties.');
1025
- if (!W.includes(e))
1026
- throw new Error(`Invalid editor type: ${e}. Must be one of: ${W.join(", ")}.`);
985
+ if (!F.includes(e))
986
+ throw new Error(`Invalid editor type: ${e}. Must be one of: ${F.join(", ")}.`);
1027
987
  return {
1028
988
  type: e,
1029
989
  license: n,
1030
990
  watchdog: i,
1031
- config: O(a),
991
+ config: A(a),
1032
992
  customTranslations: s.customTranslations || s.custom_translations
1033
993
  };
1034
994
  }
1035
- function x(r) {
995
+ function T(r) {
1036
996
  if (!r || typeof r != "object")
1037
997
  return r;
1038
998
  if (Array.isArray(r))
1039
- return r.map((a) => x(a));
999
+ return r.map((a) => T(a));
1040
1000
  const t = r;
1041
1001
  if (t.$element && typeof t.$element == "string") {
1042
1002
  const a = document.querySelector(t.$element);
@@ -1044,39 +1004,39 @@ function x(r) {
1044
1004
  }
1045
1005
  const e = /* @__PURE__ */ Object.create(null);
1046
1006
  for (const [a, n] of Object.entries(r))
1047
- e[a] = x(n);
1007
+ e[a] = T(n);
1048
1008
  return e;
1049
1009
  }
1050
- function D(r, t, e) {
1010
+ function I(r, t, e) {
1051
1011
  if (!e || typeof e != "object")
1052
1012
  return e;
1053
1013
  if (Array.isArray(e))
1054
- return e.map((i) => D(r, t, i));
1014
+ return e.map((i) => I(r, t, i));
1055
1015
  const a = e;
1056
1016
  if (a.$translation && typeof a.$translation == "string") {
1057
- const i = a.$translation, s = Et(r, i, t);
1017
+ const i = a.$translation, s = ft(r, i, t);
1058
1018
  return s === void 0 && console.warn(`Translation not found for key: ${i}`), s !== void 0 ? s : null;
1059
1019
  }
1060
1020
  const n = /* @__PURE__ */ Object.create(null);
1061
1021
  for (const [i, s] of Object.entries(e))
1062
- n[i] = D(r, t, s);
1022
+ n[i] = I(r, t, s);
1063
1023
  return n;
1064
1024
  }
1065
- function Et(r, t, e) {
1025
+ function ft(r, t, e) {
1066
1026
  for (const a of r) {
1067
1027
  const n = a[e];
1068
1028
  if (n?.dictionary && t in n.dictionary)
1069
1029
  return n.dictionary[t];
1070
1030
  }
1071
1031
  }
1072
- function vt(r, t) {
1032
+ function wt(r, t) {
1073
1033
  const { editing: e } = r;
1074
1034
  e.view.change((a) => {
1075
1035
  a.setStyle("height", `${t}px`, e.view.document.getRoot());
1076
1036
  });
1077
1037
  }
1078
1038
  const V = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
1079
- async function Ct(r, t) {
1039
+ async function gt(r, t) {
1080
1040
  const { EditorWatchdog: e } = await import("ckeditor5"), a = new e(null, t ?? {
1081
1041
  crashNumberLimit: 10,
1082
1042
  minimumNonErrorTimePeriod: 5e3
@@ -1086,24 +1046,24 @@ async function Ct(r, t) {
1086
1046
  return n[V] = a, n;
1087
1047
  }), a;
1088
1048
  }
1089
- function Pt(r) {
1049
+ function yt(r) {
1090
1050
  return V in r ? r[V] : null;
1091
1051
  }
1092
- class y extends K {
1052
+ class y extends W {
1093
1053
  static the = new y();
1094
1054
  }
1095
- function At(r) {
1055
+ function bt(r) {
1096
1056
  const t = r.getAttribute("data-cke-context");
1097
1057
  if (!t)
1098
1058
  throw new Error('CKEditor5 hook requires a "data-cke-context" attribute on the element.');
1099
1059
  const { config: e, ...a } = JSON.parse(t);
1100
1060
  return {
1101
- config: O(e),
1061
+ config: A(e),
1102
1062
  customTranslations: a.customTranslations || a.custom_translations,
1103
1063
  watchdogConfig: a.watchdogConfig || a.watchdog_config
1104
1064
  };
1105
1065
  }
1106
- class Tt extends S {
1066
+ class kt extends x {
1107
1067
  /**
1108
1068
  * The promise that resolves to the context instance.
1109
1069
  */
@@ -1114,7 +1074,7 @@ class Tt extends S {
1114
1074
  get attrs() {
1115
1075
  const t = (a) => this.el.getAttribute(a) || null, e = {
1116
1076
  id: this.el.id,
1117
- config: At(this.el),
1077
+ config: bt(this.el),
1118
1078
  language: {
1119
1079
  ui: t("data-cke-language") || "en",
1120
1080
  content: t("data-cke-content-language") || "en"
@@ -1131,29 +1091,29 @@ class Tt extends S {
1131
1091
  * Mounts the context component.
1132
1092
  */
1133
1093
  async mounted() {
1134
- const { id: t, language: e } = this.attrs, { customTranslations: a, watchdogConfig: n, config: { plugins: i, ...s } } = this.attrs.config, { loadedPlugins: c, hasPremium: o } = await J(i ?? []), l = [
1135
- ...await G(e, o),
1136
- X(a?.dictionary || {})
1137
- ].filter((m) => !Y(m));
1138
- let d = x(s);
1139
- d = D([...l].reverse(), e.ui, d), this.contextPromise = (async () => {
1140
- const { ContextWatchdog: m, Context: E } = await import("ckeditor5"), b = new m(E, {
1094
+ const { id: t, language: e } = this.attrs, { customTranslations: a, watchdogConfig: n, config: { plugins: i, ...s } } = this.attrs.config, { loadedPlugins: c, hasPremium: o } = await K(i ?? []), l = [
1095
+ ...await Y(e, o),
1096
+ J(a?.dictionary || {})
1097
+ ].filter((m) => !L(m));
1098
+ let d = T(s);
1099
+ d = I([...l].reverse(), e.ui, d), this.contextPromise = (async () => {
1100
+ const { ContextWatchdog: m, Context: k } = await import("ckeditor5"), g = new m(k, {
1141
1101
  crashNumberLimit: 10,
1142
1102
  ...n
1143
1103
  });
1144
- return await b.create({
1104
+ return await g.create({
1145
1105
  ...d,
1146
1106
  language: e,
1147
1107
  plugins: c,
1148
1108
  ...l.length && {
1149
1109
  translations: l
1150
1110
  }
1151
- }), b.on("itemError", (...P) => {
1152
- console.error("Context item error:", ...P);
1153
- }), b;
1111
+ }), g.on("itemError", (...E) => {
1112
+ console.error("Context item error:", ...E);
1113
+ }), g;
1154
1114
  })();
1155
- const w = await this.contextPromise;
1156
- this.isBeingDestroyed() || y.the.register(t, w);
1115
+ const f = await this.contextPromise;
1116
+ this.isBeingDestroyed() || y.the.register(t, f);
1157
1117
  }
1158
1118
  /**
1159
1119
  * Destroys the context component. Unmounts root from the editor.
@@ -1168,24 +1128,24 @@ class Tt extends S {
1168
1128
  }
1169
1129
  }
1170
1130
  }
1171
- function It(r) {
1131
+ function Et(r) {
1172
1132
  return r.hasAttribute("data-cke-context");
1173
1133
  }
1174
- function Ot(r) {
1134
+ function vt(r) {
1175
1135
  let t = r;
1176
1136
  for (; t; ) {
1177
- if (It(t))
1137
+ if (Et(t))
1178
1138
  return t;
1179
1139
  t = t.parentElement;
1180
1140
  }
1181
1141
  return null;
1182
1142
  }
1183
- async function xt(r) {
1184
- const t = Ot(r);
1143
+ async function Ct(r) {
1144
+ const t = vt(r);
1185
1145
  return t ? y.the.waitFor(t.id) : null;
1186
1146
  }
1187
- const Dt = N(Tt);
1188
- function St(r, t) {
1147
+ const Pt = O(kt);
1148
+ function At(r, t) {
1189
1149
  const e = /* @__PURE__ */ new Set();
1190
1150
  return (a) => {
1191
1151
  let n = !1;
@@ -1200,7 +1160,7 @@ function St(r, t) {
1200
1160
  }), n;
1201
1161
  };
1202
1162
  }
1203
- async function Nt() {
1163
+ async function Tt() {
1204
1164
  const { Plugin: r, FileRepository: t } = await import("ckeditor5");
1205
1165
  return class extends r {
1206
1166
  /**
@@ -1220,11 +1180,11 @@ async function Nt() {
1220
1180
  if (!s || n.has("SimpleUploadAdapter") || n.has("Base64UploadAdapter") || n.has("CKFinderUploadAdapter"))
1221
1181
  return;
1222
1182
  const c = n.get(t);
1223
- c.createUploadAdapter = (o) => new Mt(o, s);
1183
+ c.createUploadAdapter = (o) => new It(o, s);
1224
1184
  }
1225
1185
  };
1226
1186
  }
1227
- class Mt {
1187
+ class It {
1228
1188
  loader;
1229
1189
  uploadUrl;
1230
1190
  abortController = null;
@@ -1239,7 +1199,7 @@ class Mt {
1239
1199
  this.abortController = new AbortController();
1240
1200
  const e = new FormData();
1241
1201
  e.append("file", t), t.size && (this.loader.uploadTotal = t.size, this.loader.uploaded = 0);
1242
- const a = {}, n = it();
1202
+ const a = {}, n = et();
1243
1203
  n && (a["X-CSRF-Token"] = n);
1244
1204
  try {
1245
1205
  const i = await fetch(this.uploadUrl, {
@@ -1272,7 +1232,7 @@ class Mt {
1272
1232
  this.abortController?.abort(), this.abortController = null;
1273
1233
  }
1274
1234
  }
1275
- async function Rt({
1235
+ async function xt({
1276
1236
  editorId: r,
1277
1237
  saveDebounceMs: t
1278
1238
  }) {
@@ -1297,7 +1257,7 @@ async function Rt({
1297
1257
  */
1298
1258
  afterInit() {
1299
1259
  const { editor: n } = this;
1300
- this.input = document.getElementById(`${r}_input`), this.input && (n.model.document.on("change:data", I(t, () => this.sync())), n.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
1260
+ this.input = document.getElementById(`${r}_input`), this.input && (n.model.document.on("change:data", P(t, () => this.sync())), n.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
1301
1261
  }
1302
1262
  /**
1303
1263
  * Synchronizes the editor's content with the input field.
@@ -1315,7 +1275,7 @@ async function Rt({
1315
1275
  };
1316
1276
  }
1317
1277
  const U = /* @__PURE__ */ Symbol("suppress-phoenix-sync");
1318
- async function Vt(r) {
1278
+ async function Ot(r) {
1319
1279
  const { Plugin: t } = await import("ckeditor5"), { editorId: e, saveDebounceMs: a, events: n, pushEvent: i, handleEvent: s } = r;
1320
1280
  return class extends t {
1321
1281
  /**
@@ -1332,10 +1292,10 @@ async function Vt(r) {
1332
1292
  n.change && this.setupTypingContentPush(), n.blur && this.setupEventPush("blur"), n.focus && this.setupEventPush("focus"), n.ready && this.editor.once("ready", () => {
1333
1293
  i("ckeditor5:ready", {
1334
1294
  editorId: e,
1335
- data: M(o)
1295
+ data: S(o)
1336
1296
  });
1337
1297
  }), s("ckeditor5:set-data", ({ editorId: u, data: l }) => {
1338
- (st(u) || u === e) && o.setData(l);
1298
+ (rt(u) || u === e) && o.setData(l);
1339
1299
  });
1340
1300
  }
1341
1301
  /**
@@ -1347,21 +1307,21 @@ async function Vt(r) {
1347
1307
  const d = () => {
1348
1308
  if (l)
1349
1309
  return;
1350
- const m = M(o);
1351
- (!u || !ct(u, m)) && (i(
1310
+ const m = S(o);
1311
+ (!u || !it(u, m)) && (i(
1352
1312
  "ckeditor5:change",
1353
1313
  {
1354
1314
  editorId: e,
1355
1315
  data: m
1356
1316
  }
1357
1317
  ), u = m);
1358
- }, w = I(a, d);
1359
- o.model.document.on("change:data", I(10, (m) => {
1360
- if (Ut(m)) {
1318
+ }, f = P(a, d);
1319
+ o.model.document.on("change:data", P(10, (m) => {
1320
+ if (Dt(m)) {
1361
1321
  u = null;
1362
1322
  return;
1363
1323
  }
1364
- o.ui.focusTracker.isFocused ? w() : d();
1324
+ o.ui.focusTracker.isFocused ? f() : d();
1365
1325
  })), o.once("ready", d), o.once("destroy", () => {
1366
1326
  l = !0;
1367
1327
  });
@@ -1376,7 +1336,7 @@ async function Vt(r) {
1376
1336
  `ckeditor5:${o}`,
1377
1337
  {
1378
1338
  editorId: e,
1379
- data: M(u)
1339
+ data: S(u)
1380
1340
  }
1381
1341
  );
1382
1342
  };
@@ -1384,14 +1344,14 @@ async function Vt(r) {
1384
1344
  }
1385
1345
  };
1386
1346
  }
1387
- function M(r) {
1347
+ function S(r) {
1388
1348
  return r.model.document.getRootNames().reduce((e, a) => (e[a] = r.getData({ rootName: a }), e), /* @__PURE__ */ Object.create({}));
1389
1349
  }
1390
- function Ut(r) {
1350
+ function Dt(r) {
1391
1351
  const t = r[U];
1392
1352
  return delete r[U], !!t;
1393
1353
  }
1394
- function jt(r) {
1354
+ function Nt(r) {
1395
1355
  let t = !1;
1396
1356
  const e = (a) => {
1397
1357
  t || (a[U] = !0);
@@ -1400,7 +1360,7 @@ function jt(r) {
1400
1360
  t = !0, r.model.document.off("change:data", e);
1401
1361
  };
1402
1362
  }
1403
- class tt {
1363
+ class X {
1404
1364
  /**
1405
1365
  * The DOM element being observed for attribute changes.
1406
1366
  */
@@ -1469,7 +1429,7 @@ class tt {
1469
1429
  */
1470
1430
  get attrs() {
1471
1431
  return {
1472
- rootAttributes: ot(this.el.getAttribute(this.rootAttrsAttrName)),
1432
+ rootAttributes: nt(this.el.getAttribute(this.rootAttrsAttrName)),
1473
1433
  value: this.el.getAttribute(this.valueAttrName)
1474
1434
  };
1475
1435
  }
@@ -1485,7 +1445,7 @@ class tt {
1485
1445
  };
1486
1446
  t.model.enqueueChange({ isUndoable: !1 }, () => {
1487
1447
  let i = this.attrsUpdater?.(a);
1488
- e !== this.previousValue && (this.previousValue = e, t.ui.focusTracker.isFocused ? this.pendingValue = e : (this.setRootValue(t, this.rootName, e), i = !0)), i && (n = jt(t));
1448
+ e !== this.previousValue && (this.previousValue = e, t.ui.focusTracker.isFocused ? this.pendingValue = e : (this.setRootValue(t, this.rootName, e), i = !0)), i && (n = Nt(t));
1489
1449
  }), n();
1490
1450
  }
1491
1451
  /**
@@ -1493,7 +1453,7 @@ class tt {
1493
1453
  * Registers cleanup via onBeforeDestroy.
1494
1454
  */
1495
1455
  setupSyncHandlers(t, e) {
1496
- this.attrsUpdater = St(t, e), this.attrsUpdater(this.attrs.rootAttributes);
1456
+ this.attrsUpdater = At(t, e), this.attrsUpdater(this.attrs.rootAttributes);
1497
1457
  const a = () => {
1498
1458
  this.pendingValue = null;
1499
1459
  }, n = () => {
@@ -1517,10 +1477,10 @@ class tt {
1517
1477
  this.isDestroyed = !0, this.cleanupCallbacks.forEach((t) => t()), this.cleanupCallbacks = [];
1518
1478
  }
1519
1479
  }
1520
- class h extends K {
1480
+ class h extends W {
1521
1481
  static the = new h();
1522
1482
  }
1523
- class $t extends S {
1483
+ class St extends x {
1524
1484
  /**
1525
1485
  * The sentinel instance responsible for tracking and updating root values and attributes
1526
1486
  * for single-root editors.
@@ -1533,8 +1493,8 @@ class $t extends S {
1533
1493
  const { el: t } = this, e = t.getAttribute.bind(t), a = t.hasAttribute.bind(t), n = {
1534
1494
  editorId: e("id"),
1535
1495
  contextId: e("data-cke-context-id"),
1536
- preset: kt(t),
1537
- editableHeight: q(e("data-cke-editable-height")),
1496
+ preset: pt(t),
1497
+ editableHeight: H(e("data-cke-editable-height")),
1538
1498
  watchdog: a("data-cke-watchdog"),
1539
1499
  events: {
1540
1500
  change: a("data-cke-change-event"),
@@ -1542,7 +1502,7 @@ class $t extends S {
1542
1502
  focus: a("data-cke-focus-event"),
1543
1503
  ready: a("data-cke-ready-event")
1544
1504
  },
1545
- saveDebounceMs: q(e("data-cke-save-debounce-ms")) ?? 400,
1505
+ saveDebounceMs: H(e("data-cke-save-debounce-ms")) ?? 400,
1546
1506
  language: {
1547
1507
  ui: e("data-cke-language") || "en",
1548
1508
  content: e("data-cke-content-language") || "en"
@@ -1567,7 +1527,7 @@ class $t extends S {
1567
1527
  return;
1568
1528
  const a = h.the.mountEffect(t, (n) => (n.once("destroy", () => {
1569
1529
  h.the.unregister(t, !1);
1570
- }, { priority: "highest" }), this.sentinel = new tt({
1530
+ }, { priority: "highest" }), this.sentinel = new X({
1571
1531
  editor: n,
1572
1532
  el: this.el,
1573
1533
  rootName: "main",
@@ -1578,7 +1538,7 @@ class $t extends S {
1578
1538
  }));
1579
1539
  this.onBeforeDestroy(async () => {
1580
1540
  h.the.unregister(t), a();
1581
- const n = gt(e), i = Pt(e);
1541
+ const n = dt(e), i = yt(e);
1582
1542
  n ? n.state !== "unavailable" && await n.context.remove(n.editorContextId) : i ? await i.destroy() : await e.destroy();
1583
1543
  }), h.the.register(t, e);
1584
1544
  } catch (e) {
@@ -1611,16 +1571,16 @@ class $t extends S {
1611
1571
  saveDebounceMs: s,
1612
1572
  language: c,
1613
1573
  watchdog: o
1614
- } = this.attrs, { customTranslations: u, type: l, license: d, config: { plugins: w, ...m } } = t, E = await bt(l), b = await (a ? y.the.waitFor(a) : xt(this.el)), P = async () => {
1615
- const { loadedPlugins: f, hasPremium: A } = await J(w);
1616
- T(l) && f.push(
1617
- await Rt({
1574
+ } = this.attrs, { customTranslations: u, type: l, license: d, config: { plugins: f, ...m } } = t, k = await ht(l), g = await (a ? y.the.waitFor(a) : Ct(this.el)), E = async () => {
1575
+ const { loadedPlugins: p, hasPremium: v } = await K(f);
1576
+ N(l) && p.push(
1577
+ await xt({
1618
1578
  editorId: e,
1619
1579
  saveDebounceMs: s
1620
1580
  })
1621
- ), f.push(
1581
+ ), p.push(
1622
1582
  ...await Promise.all([
1623
- Vt(
1583
+ Ot(
1624
1584
  {
1625
1585
  editorId: e,
1626
1586
  saveDebounceMs: s,
@@ -1629,61 +1589,56 @@ class $t extends S {
1629
1589
  handleEvent: this.handleEvent.bind(this)
1630
1590
  }
1631
1591
  ),
1632
- Nt()
1592
+ Tt()
1633
1593
  ])
1634
1594
  );
1635
- const k = [
1636
- ...await G(c, A),
1637
- X(u?.dictionary || {})
1638
- ].filter((C) => !Y(C));
1639
- let v = L(e);
1640
- T(l) && (v = v.main || "");
1641
- let g = Q(e);
1642
- if (!(g instanceof HTMLElement) && !("main" in g)) {
1643
- const C = l === "decoupled" ? ["main"] : Object.keys(v);
1644
- et(g, C) || (g = await _t(e, C), v = L(e));
1645
- }
1646
- T(l) && "main" in g && (g = g.main);
1647
- let p = {
1595
+ const b = [
1596
+ ...await Y(c, v),
1597
+ J(u?.dictionary || {})
1598
+ ].filter((z) => !L(z));
1599
+ let C = G(e);
1600
+ const D = Object.keys(C);
1601
+ N(l) && D.push("main"), Q(C, D) || (C = await Rt(e, D));
1602
+ let w = {
1648
1603
  ...m,
1649
1604
  licenseKey: d.key,
1650
- plugins: f,
1605
+ plugins: p,
1651
1606
  language: c,
1652
- ...k.length && {
1653
- translations: k
1607
+ ...b.length && {
1608
+ translations: b
1654
1609
  }
1655
1610
  };
1656
- p = x(p), p = D([...k].reverse(), c.ui, p), p = mt(E, g, p), p = dt(v, p);
1657
- const z = await (async () => b ? (await wt({
1658
- context: b,
1659
- creator: E,
1660
- config: p
1661
- })).editor : E.create(p))();
1662
- return T(l) && n && vt(z, n), z;
1611
+ w = T(w), w = I([...b].reverse(), c.ui, w), w = ct(k, C, w);
1612
+ const _ = await (async () => g ? (await lt({
1613
+ context: g,
1614
+ creator: k,
1615
+ config: w
1616
+ })).editor : k.create(w))();
1617
+ return N(l) && n && wt(_, n), _;
1663
1618
  };
1664
- if (o && !b) {
1665
- const f = await Ct(P, t.watchdog);
1666
- return f.on("error", (A, { causesRestart: _ }) => {
1667
- if (_) {
1668
- const k = h.the.getItem(e);
1669
- k && (ft(k), h.the.unregister(e));
1619
+ if (o && !g) {
1620
+ const p = await gt(E, t.watchdog);
1621
+ return p.on("error", (v, { causesRestart: M }) => {
1622
+ if (M) {
1623
+ const b = h.the.getItem(e);
1624
+ b && (ut(b), h.the.unregister(e));
1670
1625
  }
1671
- }), f.on("restart", () => {
1672
- const A = f.editor;
1673
- h.the.register(e, A);
1674
- }), await f.create({}), f.editor;
1626
+ }), p.on("restart", () => {
1627
+ const v = p.editor;
1628
+ h.the.register(e, v);
1629
+ }), await p.create({}), p.editor;
1675
1630
  }
1676
- return P();
1631
+ return E();
1677
1632
  }
1678
1633
  }
1679
- function et(r, t) {
1634
+ function Q(r, t) {
1680
1635
  return t.every((e) => r[e]);
1681
1636
  }
1682
- async function _t(r, t) {
1683
- return lt(
1637
+ async function Rt(r, t) {
1638
+ return ot(
1684
1639
  () => {
1685
- const e = Q(r);
1686
- if (!et(e, t))
1640
+ const e = G(r);
1641
+ if (!Q(e, t))
1687
1642
  throw new Error(
1688
1643
  `It looks like not all required root elements are present yet.
1689
1644
  * If you want to wait for them, ensure they are registered before editor initialization.
@@ -1695,8 +1650,8 @@ Missing roots: ${t.filter((a) => !e[a]).join(", ")}.`
1695
1650
  { timeOutAfter: 2e3, retryAfter: 100 }
1696
1651
  );
1697
1652
  }
1698
- const zt = N($t);
1699
- class Ht extends S {
1653
+ const Vt = O(St);
1654
+ class Ut extends x {
1700
1655
  /**
1701
1656
  * The sentinel instance responsible for tracking and updating root values and attributes.
1702
1657
  */
@@ -1727,27 +1682,27 @@ class Ht extends S {
1727
1682
  if (this.isBeingDestroyed())
1728
1683
  return;
1729
1684
  const o = this.el.querySelector(`#${t}_input`);
1730
- if (B(s) && !s.model.document.getRoot(a)) {
1685
+ if (q(s) && !s.model.document.getRoot(a)) {
1731
1686
  const { ui: l, editing: d } = s;
1732
1687
  s.addRoot(a, {
1733
1688
  isUndoable: !1,
1734
1689
  initialData: n
1735
1690
  });
1736
- const w = l.view.createEditable(a, c);
1737
- l.addEditable(w), d.view.forceRender();
1691
+ const f = l.view.createEditable(a, c);
1692
+ l.addEditable(f), d.view.forceRender();
1738
1693
  }
1739
- this.sentinel = new tt({
1694
+ this.sentinel = new X({
1740
1695
  el: this.el,
1741
1696
  editor: s,
1742
1697
  rootName: a,
1743
1698
  valueAttrName: "data-cke-editable-initial-value",
1744
1699
  rootAttrsAttrName: "data-cke-editable-root-attrs"
1745
1700
  });
1746
- const u = o ? Bt(o, s, a) : null;
1701
+ const u = o ? Mt(o, s, a) : null;
1747
1702
  return () => {
1748
1703
  if (u?.(), this.sentinel?.destroy(), this.sentinel = null, s.state !== "destroyed") {
1749
1704
  const l = s.model.document.getRoot(a);
1750
- l && B(s) && (s.ui.view.editables[a] && s.detachEditable(l), l.isAttached() && s.detachRoot(a, !1));
1705
+ l && q(s) && (s.ui.view.editables[a] && s.detachEditable(l), l.isAttached() && s.detachRoot(a, !1));
1751
1706
  }
1752
1707
  };
1753
1708
  });
@@ -1762,16 +1717,16 @@ class Ht extends S {
1762
1717
  this.sentinel?.updated();
1763
1718
  }
1764
1719
  }
1765
- const qt = N(Ht);
1766
- function Bt(r, t, e) {
1720
+ const $t = O(Ut);
1721
+ function Mt(r, t, e) {
1767
1722
  const a = () => {
1768
1723
  r.value = t.getData({ rootName: e });
1769
- }, n = I(200, a);
1724
+ }, n = P(200, a);
1770
1725
  return t.model.document.on("change:data", n), a(), () => {
1771
1726
  t.model.document.off("change:data", n);
1772
1727
  };
1773
1728
  }
1774
- class Ft extends S {
1729
+ class _t extends x {
1775
1730
  /**
1776
1731
  * Attributes for the editable instance.
1777
1732
  */
@@ -1794,7 +1749,7 @@ class Ft extends S {
1794
1749
  const { editorId: t, name: e } = this.attrs, a = h.the.mountEffect(t, (n) => {
1795
1750
  if (this.isBeingDestroyed())
1796
1751
  return;
1797
- const { ui: i } = n, s = Lt(e), c = i.view[s];
1752
+ const { ui: i } = n, s = zt(e), c = i.view[s];
1798
1753
  if (!c) {
1799
1754
  console.error(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
1800
1755
  return;
@@ -1808,7 +1763,7 @@ class Ft extends S {
1808
1763
  });
1809
1764
  }
1810
1765
  }
1811
- function Lt(r) {
1766
+ function zt(r) {
1812
1767
  switch (r) {
1813
1768
  case "toolbar":
1814
1769
  return "toolbar";
@@ -1818,18 +1773,18 @@ function Lt(r) {
1818
1773
  return null;
1819
1774
  }
1820
1775
  }
1821
- const Wt = N(Ft), Gt = {
1822
- CKEditor5: zt,
1823
- CKEditable: qt,
1824
- CKUIPart: Wt,
1825
- CKContext: Dt
1776
+ const jt = O(_t), Ft = {
1777
+ CKEditor5: Vt,
1778
+ CKEditable: $t,
1779
+ CKUIPart: jt,
1780
+ CKContext: Pt
1826
1781
  };
1827
1782
  export {
1828
1783
  y as ContextsRegistry,
1829
1784
  $ as CustomEditorPluginsRegistry,
1830
1785
  h as EditorsRegistry,
1831
- Gt as Hooks,
1832
- gt as unwrapEditorContext,
1833
- Pt as unwrapEditorWatchdog
1786
+ Ft as Hooks,
1787
+ dt as unwrapEditorContext,
1788
+ yt as unwrapEditorWatchdog
1834
1789
  };
1835
1790
  //# sourceMappingURL=index.mjs.map