ckeditor5-phoenix 1.27.2 → 1.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/editable.d.ts.map +1 -1
- package/dist/hooks/editor/utils/assign-editor-roots-to-config.d.ts.map +1 -1
- package/dist/hooks/editor/utils/query-all-editor-editables.d.ts +1 -0
- package/dist/hooks/editor/utils/query-all-editor-editables.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +134 -122
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/hooks/editable.test.ts +29 -0
- package/src/hooks/editable.ts +3 -1
- package/src/hooks/editor/editor.test.ts +78 -0
- package/src/hooks/editor/plugins/sync-editor-with-phoenix.ts +1 -1
- package/src/hooks/editor/utils/assign-editor-roots-to-config.ts +7 -3
- package/src/hooks/editor/utils/query-all-editor-editables.ts +12 -6
- package/test-utils/editor/create-editable-html-element.ts +5 -0
- package/test-utils/editor/create-editor-html-element.ts +5 -0
package/dist/index.mjs
CHANGED
|
@@ -234,7 +234,7 @@ class W {
|
|
|
234
234
|
function Z(r) {
|
|
235
235
|
return r.replace(/[-_\s]+(.)?/g, (t, e) => e ? e.toUpperCase() : "").replace(/^./, (t) => t.toLowerCase());
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function A(r, t) {
|
|
238
238
|
let e = null;
|
|
239
239
|
return (...a) => {
|
|
240
240
|
e && clearTimeout(e), e = setTimeout(() => {
|
|
@@ -248,13 +248,13 @@ function tt(r) {
|
|
|
248
248
|
const t = Object.getPrototypeOf(r);
|
|
249
249
|
return t === Object.prototype || t === null;
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function P(r) {
|
|
252
252
|
if (Array.isArray(r))
|
|
253
|
-
return r.map(
|
|
253
|
+
return r.map(P);
|
|
254
254
|
if (tt(r)) {
|
|
255
255
|
const t = /* @__PURE__ */ Object.create(null);
|
|
256
256
|
for (const [e, a] of Object.entries(r))
|
|
257
|
-
t[Z(e)] =
|
|
257
|
+
t[Z(e)] = P(a);
|
|
258
258
|
return t;
|
|
259
259
|
}
|
|
260
260
|
return r;
|
|
@@ -341,7 +341,7 @@ class x {
|
|
|
341
341
|
this._beforeDestroyCallbacks = [];
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
function
|
|
344
|
+
function D(r) {
|
|
345
345
|
return {
|
|
346
346
|
/**
|
|
347
347
|
* The mounted lifecycle callback for the LiveView hook object.
|
|
@@ -416,10 +416,10 @@ function it(r, t) {
|
|
|
416
416
|
return !1;
|
|
417
417
|
return !0;
|
|
418
418
|
}
|
|
419
|
-
function
|
|
419
|
+
function ot() {
|
|
420
420
|
return Math.random().toString(36).substring(2);
|
|
421
421
|
}
|
|
422
|
-
function
|
|
422
|
+
function st(r, {
|
|
423
423
|
timeOutAfter: t = 500,
|
|
424
424
|
retryAfter: e = 100
|
|
425
425
|
} = {}) {
|
|
@@ -449,13 +449,17 @@ function ct(r, t, e) {
|
|
|
449
449
|
/* v8 ignore next 1 */
|
|
450
450
|
...e.roots?.[o],
|
|
451
451
|
...o === "main" ? e.root : {},
|
|
452
|
-
/* v8 ignore
|
|
452
|
+
/* v8 ignore start */
|
|
453
453
|
...o in t ? {
|
|
454
454
|
initialData: t[o].initialValue,
|
|
455
|
-
|
|
455
|
+
modelElement: t[o].modelElement || "$root",
|
|
456
|
+
...!a && {
|
|
457
|
+
element: t[o].content
|
|
458
|
+
}
|
|
456
459
|
} : {}
|
|
460
|
+
/* v8 ignore end */
|
|
457
461
|
}
|
|
458
|
-
}),
|
|
462
|
+
}), { ...e.roots || {} }), s = {
|
|
459
463
|
...e,
|
|
460
464
|
roots: i,
|
|
461
465
|
...a && {
|
|
@@ -492,7 +496,7 @@ function ut(r) {
|
|
|
492
496
|
}
|
|
493
497
|
const R = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
|
|
494
498
|
async function lt({ context: r, creator: t, config: e }) {
|
|
495
|
-
const a =
|
|
499
|
+
const a = ot();
|
|
496
500
|
await r.add({
|
|
497
501
|
creator: t.create.bind(t),
|
|
498
502
|
id: a,
|
|
@@ -520,7 +524,7 @@ function q(r) {
|
|
|
520
524
|
function N(r) {
|
|
521
525
|
return ["inline", "classic", "balloon", "decoupled"].includes(r);
|
|
522
526
|
}
|
|
523
|
-
async function
|
|
527
|
+
async function mt(r) {
|
|
524
528
|
const t = await import("ckeditor5"), a = {
|
|
525
529
|
inline: t.InlineEditor,
|
|
526
530
|
balloon: t.BalloonEditor,
|
|
@@ -532,8 +536,8 @@ async function ht(r) {
|
|
|
532
536
|
throw new Error(`Unsupported editor type: ${r}`);
|
|
533
537
|
return a;
|
|
534
538
|
}
|
|
535
|
-
class
|
|
536
|
-
static the = new
|
|
539
|
+
class U {
|
|
540
|
+
static the = new U();
|
|
537
541
|
/**
|
|
538
542
|
* Map of registered custom plugins.
|
|
539
543
|
*/
|
|
@@ -596,7 +600,7 @@ async function K(r) {
|
|
|
596
600
|
const t = await import("ckeditor5");
|
|
597
601
|
let e = null;
|
|
598
602
|
const a = r.map(async (n) => {
|
|
599
|
-
const i = await
|
|
603
|
+
const i = await U.the.get(n);
|
|
600
604
|
if (i)
|
|
601
605
|
return i;
|
|
602
606
|
const { [n]: s } = t;
|
|
@@ -631,12 +635,12 @@ async function Y(r, t) {
|
|
|
631
635
|
async function B(r, t) {
|
|
632
636
|
return await Promise.all(
|
|
633
637
|
t.filter((e) => e !== "en").map(async (e) => {
|
|
634
|
-
const a = await
|
|
638
|
+
const a = await ht(r, e);
|
|
635
639
|
return a?.default ?? a;
|
|
636
640
|
}).filter(Boolean)
|
|
637
641
|
);
|
|
638
642
|
}
|
|
639
|
-
async function
|
|
643
|
+
async function ht(r, t) {
|
|
640
644
|
try {
|
|
641
645
|
if (r === "ckeditor5")
|
|
642
646
|
switch (t) {
|
|
@@ -948,29 +952,35 @@ function G(r) {
|
|
|
948
952
|
"[data-cke-editable-root-name]:not([data-cke-editor-id])"
|
|
949
953
|
].join(", ")
|
|
950
954
|
), e = Array.from(t).reduce((c, o) => {
|
|
951
|
-
const u = o.getAttribute("data-cke-editable-root-name"), l = o.getAttribute("data-cke-editable-initial-value") || "",
|
|
952
|
-
return !u || !
|
|
955
|
+
const u = o.getAttribute("data-cke-editable-root-name"), d = o.getAttribute("data-cke-editable-root-model-element-name") || null, l = o.getAttribute("data-cke-editable-initial-value") || "", p = o.querySelector("[data-cke-editable-content]");
|
|
956
|
+
return !u || !p ? c : {
|
|
953
957
|
...c,
|
|
954
958
|
[u]: {
|
|
955
|
-
content:
|
|
956
|
-
initialValue: l
|
|
959
|
+
content: p,
|
|
960
|
+
initialValue: l,
|
|
961
|
+
modelElement: d
|
|
957
962
|
}
|
|
958
963
|
};
|
|
959
|
-
}, /* @__PURE__ */ Object.create(
|
|
964
|
+
}, /* @__PURE__ */ Object.create(null)), a = document.querySelector(`[phx-hook="CKEditor5"][id="${r}"]`);
|
|
960
965
|
if (!a)
|
|
961
966
|
return e;
|
|
962
|
-
const n = a.getAttribute("data-cke-
|
|
967
|
+
const n = a.getAttribute("data-cke-root-model-element-name"), i = a.getAttribute("data-cke-initial-value") || "";
|
|
968
|
+
if (e.main)
|
|
969
|
+
return {
|
|
970
|
+
...e,
|
|
971
|
+
main: {
|
|
972
|
+
...e.main,
|
|
973
|
+
modelElement: e.main.modelElement || n,
|
|
974
|
+
initialValue: e.main.initialValue || i
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
const s = a.querySelector(`#${r}_editor `);
|
|
963
978
|
return s ? {
|
|
964
979
|
...e,
|
|
965
980
|
main: {
|
|
966
|
-
|
|
967
|
-
initialValue:
|
|
968
|
-
|
|
969
|
-
} : i ? {
|
|
970
|
-
...e,
|
|
971
|
-
main: {
|
|
972
|
-
content: i,
|
|
973
|
-
initialValue: n
|
|
981
|
+
content: s,
|
|
982
|
+
initialValue: i,
|
|
983
|
+
modelElement: a.getAttribute("data-cke-root-model-element-name") || "$root"
|
|
974
984
|
}
|
|
975
985
|
} : e;
|
|
976
986
|
}
|
|
@@ -988,7 +998,7 @@ function pt(r) {
|
|
|
988
998
|
type: e,
|
|
989
999
|
license: n,
|
|
990
1000
|
watchdog: i,
|
|
991
|
-
config:
|
|
1001
|
+
config: P(a),
|
|
992
1002
|
customTranslations: s.customTranslations || s.custom_translations
|
|
993
1003
|
};
|
|
994
1004
|
}
|
|
@@ -1046,19 +1056,19 @@ async function gt(r, t) {
|
|
|
1046
1056
|
return n[V] = a, n;
|
|
1047
1057
|
}), a;
|
|
1048
1058
|
}
|
|
1049
|
-
function
|
|
1059
|
+
function bt(r) {
|
|
1050
1060
|
return V in r ? r[V] : null;
|
|
1051
1061
|
}
|
|
1052
|
-
class
|
|
1053
|
-
static the = new
|
|
1062
|
+
class b extends W {
|
|
1063
|
+
static the = new b();
|
|
1054
1064
|
}
|
|
1055
|
-
function
|
|
1065
|
+
function yt(r) {
|
|
1056
1066
|
const t = r.getAttribute("data-cke-context");
|
|
1057
1067
|
if (!t)
|
|
1058
1068
|
throw new Error('CKEditor5 hook requires a "data-cke-context" attribute on the element.');
|
|
1059
1069
|
const { config: e, ...a } = JSON.parse(t);
|
|
1060
1070
|
return {
|
|
1061
|
-
config:
|
|
1071
|
+
config: P(e),
|
|
1062
1072
|
customTranslations: a.customTranslations || a.custom_translations,
|
|
1063
1073
|
watchdogConfig: a.watchdogConfig || a.watchdog_config
|
|
1064
1074
|
};
|
|
@@ -1074,7 +1084,7 @@ class kt extends x {
|
|
|
1074
1084
|
get attrs() {
|
|
1075
1085
|
const t = (a) => this.el.getAttribute(a) || null, e = {
|
|
1076
1086
|
id: this.el.id,
|
|
1077
|
-
config:
|
|
1087
|
+
config: yt(this.el),
|
|
1078
1088
|
language: {
|
|
1079
1089
|
ui: t("data-cke-language") || "en",
|
|
1080
1090
|
content: t("data-cke-content-language") || "en"
|
|
@@ -1091,29 +1101,29 @@ class kt extends x {
|
|
|
1091
1101
|
* Mounts the context component.
|
|
1092
1102
|
*/
|
|
1093
1103
|
async mounted() {
|
|
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 ?? []),
|
|
1104
|
+
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 ?? []), d = [
|
|
1095
1105
|
...await Y(e, o),
|
|
1096
1106
|
J(a?.dictionary || {})
|
|
1097
1107
|
].filter((m) => !L(m));
|
|
1098
|
-
let
|
|
1099
|
-
|
|
1108
|
+
let l = T(s);
|
|
1109
|
+
l = I([...d].reverse(), e.ui, l), this.contextPromise = (async () => {
|
|
1100
1110
|
const { ContextWatchdog: m, Context: k } = await import("ckeditor5"), g = new m(k, {
|
|
1101
1111
|
crashNumberLimit: 10,
|
|
1102
1112
|
...n
|
|
1103
1113
|
});
|
|
1104
1114
|
return await g.create({
|
|
1105
|
-
...
|
|
1115
|
+
...l,
|
|
1106
1116
|
language: e,
|
|
1107
1117
|
plugins: c,
|
|
1108
|
-
...
|
|
1109
|
-
translations:
|
|
1118
|
+
...d.length && {
|
|
1119
|
+
translations: d
|
|
1110
1120
|
}
|
|
1111
1121
|
}), g.on("itemError", (...E) => {
|
|
1112
1122
|
console.error("Context item error:", ...E);
|
|
1113
1123
|
}), g;
|
|
1114
1124
|
})();
|
|
1115
|
-
const
|
|
1116
|
-
this.isBeingDestroyed() ||
|
|
1125
|
+
const p = await this.contextPromise;
|
|
1126
|
+
this.isBeingDestroyed() || b.the.register(t, p);
|
|
1117
1127
|
}
|
|
1118
1128
|
/**
|
|
1119
1129
|
* Destroys the context component. Unmounts root from the editor.
|
|
@@ -1124,7 +1134,7 @@ class kt extends x {
|
|
|
1124
1134
|
try {
|
|
1125
1135
|
await (await this.contextPromise)?.destroy();
|
|
1126
1136
|
} finally {
|
|
1127
|
-
this.contextPromise = null,
|
|
1137
|
+
this.contextPromise = null, b.the.hasItem(t) && b.the.unregister(t);
|
|
1128
1138
|
}
|
|
1129
1139
|
}
|
|
1130
1140
|
}
|
|
@@ -1142,10 +1152,10 @@ function vt(r) {
|
|
|
1142
1152
|
}
|
|
1143
1153
|
async function Ct(r) {
|
|
1144
1154
|
const t = vt(r);
|
|
1145
|
-
return t ?
|
|
1155
|
+
return t ? b.the.waitFor(t.id) : null;
|
|
1146
1156
|
}
|
|
1147
|
-
const
|
|
1148
|
-
function
|
|
1157
|
+
const At = D(kt);
|
|
1158
|
+
function Pt(r, t) {
|
|
1149
1159
|
const e = /* @__PURE__ */ new Set();
|
|
1150
1160
|
return (a) => {
|
|
1151
1161
|
let n = !1;
|
|
@@ -1257,7 +1267,7 @@ async function xt({
|
|
|
1257
1267
|
*/
|
|
1258
1268
|
afterInit() {
|
|
1259
1269
|
const { editor: n } = this;
|
|
1260
|
-
this.input = document.getElementById(`${r}_input`), this.input && (n.model.document.on("change:data",
|
|
1270
|
+
this.input = document.getElementById(`${r}_input`), this.input && (n.model.document.on("change:data", A(t, () => this.sync())), n.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
|
|
1261
1271
|
}
|
|
1262
1272
|
/**
|
|
1263
1273
|
* Synchronizes the editor's content with the input field.
|
|
@@ -1274,8 +1284,8 @@ async function xt({
|
|
|
1274
1284
|
}
|
|
1275
1285
|
};
|
|
1276
1286
|
}
|
|
1277
|
-
const
|
|
1278
|
-
async function
|
|
1287
|
+
const $ = /* @__PURE__ */ Symbol("suppress-phoenix-sync");
|
|
1288
|
+
async function Dt(r) {
|
|
1279
1289
|
const { Plugin: t } = await import("ckeditor5"), { editorId: e, saveDebounceMs: a, events: n, pushEvent: i, handleEvent: s } = r;
|
|
1280
1290
|
return class extends t {
|
|
1281
1291
|
/**
|
|
@@ -1294,8 +1304,8 @@ async function Ot(r) {
|
|
|
1294
1304
|
editorId: e,
|
|
1295
1305
|
data: S(o)
|
|
1296
1306
|
});
|
|
1297
|
-
}), s("ckeditor5:set-data", ({ editorId: u, data:
|
|
1298
|
-
(rt(u) || u === e) && o.setData(
|
|
1307
|
+
}), s("ckeditor5:set-data", ({ editorId: u, data: d }) => {
|
|
1308
|
+
(rt(u) || u === e) && o.setData(d);
|
|
1299
1309
|
});
|
|
1300
1310
|
}
|
|
1301
1311
|
/**
|
|
@@ -1303,9 +1313,9 @@ async function Ot(r) {
|
|
|
1303
1313
|
*/
|
|
1304
1314
|
setupTypingContentPush() {
|
|
1305
1315
|
const { editor: o } = this;
|
|
1306
|
-
let u = null,
|
|
1307
|
-
const
|
|
1308
|
-
if (
|
|
1316
|
+
let u = null, d = !1;
|
|
1317
|
+
const l = () => {
|
|
1318
|
+
if (d)
|
|
1309
1319
|
return;
|
|
1310
1320
|
const m = S(o);
|
|
1311
1321
|
(!u || !it(u, m)) && (i(
|
|
@@ -1315,24 +1325,24 @@ async function Ot(r) {
|
|
|
1315
1325
|
data: m
|
|
1316
1326
|
}
|
|
1317
1327
|
), u = m);
|
|
1318
|
-
},
|
|
1319
|
-
o.model.document.on("change:data",
|
|
1320
|
-
if (
|
|
1328
|
+
}, p = A(a, l);
|
|
1329
|
+
o.model.document.on("change:data", A(10, (m) => {
|
|
1330
|
+
if (Ot(m)) {
|
|
1321
1331
|
u = null;
|
|
1322
1332
|
return;
|
|
1323
1333
|
}
|
|
1324
|
-
o.ui.focusTracker.isFocused ?
|
|
1325
|
-
})), o.once("ready",
|
|
1326
|
-
|
|
1334
|
+
o.ui.focusTracker.isFocused ? p() : l();
|
|
1335
|
+
})), o.once("ready", l), o.once("destroy", () => {
|
|
1336
|
+
d = !0;
|
|
1327
1337
|
});
|
|
1328
1338
|
}
|
|
1329
1339
|
/**
|
|
1330
1340
|
* Setups the event push for the editor.
|
|
1331
1341
|
*/
|
|
1332
1342
|
setupEventPush(o) {
|
|
1333
|
-
const { editor: u } = this,
|
|
1334
|
-
const { isFocused:
|
|
1335
|
-
(
|
|
1343
|
+
const { editor: u } = this, d = () => {
|
|
1344
|
+
const { isFocused: l } = u.ui.focusTracker;
|
|
1345
|
+
(l ? "focus" : "blur") === o && i(
|
|
1336
1346
|
`ckeditor5:${o}`,
|
|
1337
1347
|
{
|
|
1338
1348
|
editorId: e,
|
|
@@ -1340,21 +1350,21 @@ async function Ot(r) {
|
|
|
1340
1350
|
}
|
|
1341
1351
|
);
|
|
1342
1352
|
};
|
|
1343
|
-
u.ui.focusTracker.on("change:isFocused",
|
|
1353
|
+
u.ui.focusTracker.on("change:isFocused", d);
|
|
1344
1354
|
}
|
|
1345
1355
|
};
|
|
1346
1356
|
}
|
|
1347
1357
|
function S(r) {
|
|
1348
|
-
return r.model.document.getRootNames().reduce((e, a) => (e[a] = r.getData({ rootName: a }), e), /* @__PURE__ */ Object.create(
|
|
1358
|
+
return r.model.document.getRootNames().reduce((e, a) => (e[a] = r.getData({ rootName: a }), e), /* @__PURE__ */ Object.create(null));
|
|
1349
1359
|
}
|
|
1350
|
-
function
|
|
1351
|
-
const t = r[
|
|
1352
|
-
return delete r[
|
|
1360
|
+
function Ot(r) {
|
|
1361
|
+
const t = r[$];
|
|
1362
|
+
return delete r[$], !!t;
|
|
1353
1363
|
}
|
|
1354
1364
|
function Nt(r) {
|
|
1355
1365
|
let t = !1;
|
|
1356
1366
|
const e = (a) => {
|
|
1357
|
-
t || (a[
|
|
1367
|
+
t || (a[$] = !0);
|
|
1358
1368
|
};
|
|
1359
1369
|
return r.model.document.once("change:data", e, { priority: "highest" }), () => {
|
|
1360
1370
|
t = !0, r.model.document.off("change:data", e);
|
|
@@ -1453,7 +1463,7 @@ class X {
|
|
|
1453
1463
|
* Registers cleanup via onBeforeDestroy.
|
|
1454
1464
|
*/
|
|
1455
1465
|
setupSyncHandlers(t, e) {
|
|
1456
|
-
this.attrsUpdater =
|
|
1466
|
+
this.attrsUpdater = Pt(t, e), this.attrsUpdater(this.attrs.rootAttributes);
|
|
1457
1467
|
const a = () => {
|
|
1458
1468
|
this.pendingValue = null;
|
|
1459
1469
|
}, n = () => {
|
|
@@ -1538,7 +1548,7 @@ class St extends x {
|
|
|
1538
1548
|
}));
|
|
1539
1549
|
this.onBeforeDestroy(async () => {
|
|
1540
1550
|
h.the.unregister(t), a();
|
|
1541
|
-
const n = dt(e), i =
|
|
1551
|
+
const n = dt(e), i = bt(e);
|
|
1542
1552
|
n ? n.state !== "unavailable" && await n.context.remove(n.editorContextId) : i ? await i.destroy() : await e.destroy();
|
|
1543
1553
|
}), h.the.register(t, e);
|
|
1544
1554
|
} catch (e) {
|
|
@@ -1571,16 +1581,16 @@ class St extends x {
|
|
|
1571
1581
|
saveDebounceMs: s,
|
|
1572
1582
|
language: c,
|
|
1573
1583
|
watchdog: o
|
|
1574
|
-
} = this.attrs, { customTranslations: u, type:
|
|
1575
|
-
const { loadedPlugins:
|
|
1576
|
-
N(
|
|
1584
|
+
} = this.attrs, { customTranslations: u, type: d, license: l, config: { plugins: p, ...m } } = t, k = await mt(d), g = await (a ? b.the.waitFor(a) : Ct(this.el)), E = async () => {
|
|
1585
|
+
const { loadedPlugins: f, hasPremium: v } = await K(p);
|
|
1586
|
+
N(d) && f.push(
|
|
1577
1587
|
await xt({
|
|
1578
1588
|
editorId: e,
|
|
1579
1589
|
saveDebounceMs: s
|
|
1580
1590
|
})
|
|
1581
|
-
),
|
|
1591
|
+
), f.push(
|
|
1582
1592
|
...await Promise.all([
|
|
1583
|
-
|
|
1593
|
+
Dt(
|
|
1584
1594
|
{
|
|
1585
1595
|
editorId: e,
|
|
1586
1596
|
saveDebounceMs: s,
|
|
@@ -1592,41 +1602,41 @@ class St extends x {
|
|
|
1592
1602
|
Tt()
|
|
1593
1603
|
])
|
|
1594
1604
|
);
|
|
1595
|
-
const
|
|
1605
|
+
const y = [
|
|
1596
1606
|
...await Y(c, v),
|
|
1597
1607
|
J(u?.dictionary || {})
|
|
1598
1608
|
].filter((z) => !L(z));
|
|
1599
1609
|
let C = G(e);
|
|
1600
|
-
const
|
|
1601
|
-
N(
|
|
1610
|
+
const O = Object.keys(C);
|
|
1611
|
+
N(d) && O.push("main"), Q(C, O) || (C = await Rt(e, O));
|
|
1602
1612
|
let w = {
|
|
1603
1613
|
...m,
|
|
1604
|
-
licenseKey:
|
|
1605
|
-
plugins:
|
|
1614
|
+
licenseKey: l.key,
|
|
1615
|
+
plugins: f,
|
|
1606
1616
|
language: c,
|
|
1607
|
-
...
|
|
1608
|
-
translations:
|
|
1617
|
+
...y.length && {
|
|
1618
|
+
translations: y
|
|
1609
1619
|
}
|
|
1610
1620
|
};
|
|
1611
|
-
w = T(w), w = I([...
|
|
1621
|
+
w = T(w), w = I([...y].reverse(), c.ui, w), w = ct(k, C, w);
|
|
1612
1622
|
const _ = await (async () => g ? (await lt({
|
|
1613
1623
|
context: g,
|
|
1614
1624
|
creator: k,
|
|
1615
1625
|
config: w
|
|
1616
1626
|
})).editor : k.create(w))();
|
|
1617
|
-
return N(
|
|
1627
|
+
return N(d) && n && wt(_, n), _;
|
|
1618
1628
|
};
|
|
1619
1629
|
if (o && !g) {
|
|
1620
|
-
const
|
|
1621
|
-
return
|
|
1630
|
+
const f = await gt(E, t.watchdog);
|
|
1631
|
+
return f.on("error", (v, { causesRestart: M }) => {
|
|
1622
1632
|
if (M) {
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1633
|
+
const y = h.the.getItem(e);
|
|
1634
|
+
y && (ut(y), h.the.unregister(e));
|
|
1625
1635
|
}
|
|
1626
|
-
}),
|
|
1627
|
-
const v =
|
|
1636
|
+
}), f.on("restart", () => {
|
|
1637
|
+
const v = f.editor;
|
|
1628
1638
|
h.the.register(e, v);
|
|
1629
|
-
}), await
|
|
1639
|
+
}), await f.create({}), f.editor;
|
|
1630
1640
|
}
|
|
1631
1641
|
return E();
|
|
1632
1642
|
}
|
|
@@ -1635,7 +1645,7 @@ function Q(r, t) {
|
|
|
1635
1645
|
return t.every((e) => r[e]);
|
|
1636
1646
|
}
|
|
1637
1647
|
async function Rt(r, t) {
|
|
1638
|
-
return
|
|
1648
|
+
return st(
|
|
1639
1649
|
() => {
|
|
1640
1650
|
const e = G(r);
|
|
1641
1651
|
if (!Q(e, t))
|
|
@@ -1650,8 +1660,8 @@ Missing roots: ${t.filter((a) => !e[a]).join(", ")}.`
|
|
|
1650
1660
|
{ timeOutAfter: 2e3, retryAfter: 100 }
|
|
1651
1661
|
);
|
|
1652
1662
|
}
|
|
1653
|
-
const Vt =
|
|
1654
|
-
class
|
|
1663
|
+
const Vt = D(St);
|
|
1664
|
+
class $t extends x {
|
|
1655
1665
|
/**
|
|
1656
1666
|
* The sentinel instance responsible for tracking and updating root values and attributes.
|
|
1657
1667
|
*/
|
|
@@ -1664,6 +1674,7 @@ class Ut extends x {
|
|
|
1664
1674
|
editableId: this.el.getAttribute("id"),
|
|
1665
1675
|
editorId: this.el.getAttribute("data-cke-editor-id") || null,
|
|
1666
1676
|
rootName: this.el.getAttribute("data-cke-editable-root-name"),
|
|
1677
|
+
modelElement: this.el.getAttribute("data-cke-editable-root-model-element-name") || null,
|
|
1667
1678
|
initialValue: this.el.getAttribute("data-cke-editable-initial-value") || ""
|
|
1668
1679
|
};
|
|
1669
1680
|
return Object.defineProperty(this, "attrs", {
|
|
@@ -1677,37 +1688,38 @@ class Ut extends x {
|
|
|
1677
1688
|
* Mounts the editable component.
|
|
1678
1689
|
*/
|
|
1679
1690
|
mounted() {
|
|
1680
|
-
const { editableId: t, editorId: e, rootName: a, initialValue: n } = this.attrs,
|
|
1681
|
-
const
|
|
1691
|
+
const { editableId: t, editorId: e, rootName: a, initialValue: n, modelElement: i } = this.attrs, s = h.the.mountEffect(e, (c) => {
|
|
1692
|
+
const o = this.el.querySelector("[data-cke-editable-content]");
|
|
1682
1693
|
if (this.isBeingDestroyed())
|
|
1683
1694
|
return;
|
|
1684
|
-
const
|
|
1685
|
-
if (q(
|
|
1686
|
-
const { ui: l, editing:
|
|
1687
|
-
|
|
1695
|
+
const u = this.el.querySelector(`#${t}_input`);
|
|
1696
|
+
if (q(c) && !c.model.document.getRoot(a)) {
|
|
1697
|
+
const { ui: l, editing: p } = c;
|
|
1698
|
+
c.addRoot(a, {
|
|
1688
1699
|
isUndoable: !1,
|
|
1689
|
-
initialData: n
|
|
1700
|
+
initialData: n,
|
|
1701
|
+
modelElement: i || "$root"
|
|
1690
1702
|
});
|
|
1691
|
-
const
|
|
1692
|
-
l.addEditable(
|
|
1703
|
+
const m = l.view.createEditable(a, o);
|
|
1704
|
+
l.addEditable(m), p.view.forceRender();
|
|
1693
1705
|
}
|
|
1694
1706
|
this.sentinel = new X({
|
|
1695
1707
|
el: this.el,
|
|
1696
|
-
editor:
|
|
1708
|
+
editor: c,
|
|
1697
1709
|
rootName: a,
|
|
1698
1710
|
valueAttrName: "data-cke-editable-initial-value",
|
|
1699
1711
|
rootAttrsAttrName: "data-cke-editable-root-attrs"
|
|
1700
1712
|
});
|
|
1701
|
-
const
|
|
1713
|
+
const d = u ? Mt(u, c, a) : null;
|
|
1702
1714
|
return () => {
|
|
1703
|
-
if (
|
|
1704
|
-
const l =
|
|
1705
|
-
l && q(
|
|
1715
|
+
if (d?.(), this.sentinel?.destroy(), this.sentinel = null, c.state !== "destroyed") {
|
|
1716
|
+
const l = c.model.document.getRoot(a);
|
|
1717
|
+
l && q(c) && (c.ui.view.editables[a] && c.detachEditable(l), l.isAttached() && c.detachRoot(a, !1));
|
|
1706
1718
|
}
|
|
1707
1719
|
};
|
|
1708
1720
|
});
|
|
1709
1721
|
this.onBeforeDestroy(() => {
|
|
1710
|
-
this.el.style.display = "none",
|
|
1722
|
+
this.el.style.display = "none", s();
|
|
1711
1723
|
});
|
|
1712
1724
|
}
|
|
1713
1725
|
/**
|
|
@@ -1717,11 +1729,11 @@ class Ut extends x {
|
|
|
1717
1729
|
this.sentinel?.updated();
|
|
1718
1730
|
}
|
|
1719
1731
|
}
|
|
1720
|
-
const
|
|
1732
|
+
const Ut = D($t);
|
|
1721
1733
|
function Mt(r, t, e) {
|
|
1722
1734
|
const a = () => {
|
|
1723
1735
|
r.value = t.getData({ rootName: e });
|
|
1724
|
-
}, n =
|
|
1736
|
+
}, n = A(200, a);
|
|
1725
1737
|
return t.model.document.on("change:data", n), a(), () => {
|
|
1726
1738
|
t.model.document.off("change:data", n);
|
|
1727
1739
|
};
|
|
@@ -1773,18 +1785,18 @@ function zt(r) {
|
|
|
1773
1785
|
return null;
|
|
1774
1786
|
}
|
|
1775
1787
|
}
|
|
1776
|
-
const jt =
|
|
1788
|
+
const jt = D(_t), Ft = {
|
|
1777
1789
|
CKEditor5: Vt,
|
|
1778
|
-
CKEditable:
|
|
1790
|
+
CKEditable: Ut,
|
|
1779
1791
|
CKUIPart: jt,
|
|
1780
|
-
CKContext:
|
|
1792
|
+
CKContext: At
|
|
1781
1793
|
};
|
|
1782
1794
|
export {
|
|
1783
|
-
|
|
1784
|
-
|
|
1795
|
+
b as ContextsRegistry,
|
|
1796
|
+
U as CustomEditorPluginsRegistry,
|
|
1785
1797
|
h as EditorsRegistry,
|
|
1786
1798
|
Ft as Hooks,
|
|
1787
1799
|
dt as unwrapEditorContext,
|
|
1788
|
-
|
|
1800
|
+
bt as unwrapEditorWatchdog
|
|
1789
1801
|
};
|
|
1790
1802
|
//# sourceMappingURL=index.mjs.map
|