ckeditor5-livewire 1.12.1 → 1.12.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/hooks/editor/editor.d.ts.map +1 -1
- package/dist/hooks/editor/utils/assign-editor-roots-to-config.d.ts +17 -0
- package/dist/hooks/editor/utils/assign-editor-roots-to-config.d.ts.map +1 -0
- package/dist/hooks/editor/utils/index.d.ts +2 -3
- package/dist/hooks/editor/utils/index.d.ts.map +1 -1
- package/dist/hooks/editor/utils/query-all-editor-editables.d.ts +23 -0
- package/dist/hooks/editor/utils/query-all-editor-editables.d.ts.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +159 -204
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/editor/editor.ts +40 -64
- package/src/hooks/editor/utils/assign-editor-roots-to-config.ts +60 -0
- package/src/hooks/editor/utils/index.ts +2 -3
- package/src/hooks/editor/utils/query-all-editor-editables.ts +77 -0
- package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts +0 -10
- package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts.map +0 -1
- package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts +0 -12
- package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts.map +0 -1
- package/dist/hooks/editor/utils/query-editor-editables.d.ts +0 -32
- package/dist/hooks/editor/utils/query-editor-editables.d.ts.map +0 -1
- package/src/hooks/editor/utils/assign-initial-data-to-editor-config.ts +0 -48
- package/src/hooks/editor/utils/assign-source-elements-to-editor-config.ts +0 -61
- package/src/hooks/editor/utils/query-editor-editables.ts +0 -93
package/dist/index.mjs
CHANGED
|
@@ -162,25 +162,19 @@ function i(e, t) {
|
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
//#endregion
|
|
165
|
-
//#region src/shared/filter-object-values.ts
|
|
166
|
-
function a(e, t) {
|
|
167
|
-
let n = Object.entries(e).filter(([e, n]) => t(n, e));
|
|
168
|
-
return Object.fromEntries(n);
|
|
169
|
-
}
|
|
170
|
-
//#endregion
|
|
171
165
|
//#region src/shared/is-empty-object.ts
|
|
172
|
-
function
|
|
166
|
+
function a(e) {
|
|
173
167
|
return Object.keys(e).length === 0 && e.constructor === Object;
|
|
174
168
|
}
|
|
175
169
|
//#endregion
|
|
176
170
|
//#region src/shared/map-object-values.ts
|
|
177
|
-
function
|
|
171
|
+
function o(e, t) {
|
|
178
172
|
let n = Object.entries(e).map(([e, n]) => [e, t(n, e)]);
|
|
179
173
|
return Object.fromEntries(n);
|
|
180
174
|
}
|
|
181
175
|
//#endregion
|
|
182
176
|
//#region src/shared/shallow-equal.ts
|
|
183
|
-
function
|
|
177
|
+
function s(e, t) {
|
|
184
178
|
if (e === t) return !0;
|
|
185
179
|
let n = Object.keys(e), r = Object.keys(t);
|
|
186
180
|
if (n.length !== r.length) return !1;
|
|
@@ -189,12 +183,12 @@ function c(e, t) {
|
|
|
189
183
|
}
|
|
190
184
|
//#endregion
|
|
191
185
|
//#region src/shared/uid.ts
|
|
192
|
-
function
|
|
186
|
+
function c() {
|
|
193
187
|
return Math.random().toString(36).substring(2);
|
|
194
188
|
}
|
|
195
189
|
//#endregion
|
|
196
190
|
//#region src/shared/wait-for.ts
|
|
197
|
-
function
|
|
191
|
+
function l(e, { timeOutAfter: t = 500, retryAfter: n = 100 } = {}) {
|
|
198
192
|
return new Promise((r, i) => {
|
|
199
193
|
let a = Date.now(), o = null, s = setTimeout(() => {
|
|
200
194
|
i(o ?? /* @__PURE__ */ Error("Timeout"));
|
|
@@ -210,51 +204,28 @@ function u(e, { timeOutAfter: t = 500, retryAfter: n = 100 } = {}) {
|
|
|
210
204
|
});
|
|
211
205
|
}
|
|
212
206
|
//#endregion
|
|
213
|
-
//#region src/hooks/editor/utils/assign-
|
|
214
|
-
function
|
|
215
|
-
let
|
|
216
|
-
...e,
|
|
217
|
-
[r]: {
|
|
218
|
-
...t.roots?.[r],
|
|
219
|
-
...r === "main" ? t.root : {},
|
|
220
|
-
...r in n ? { initialData: n[r] } : {}
|
|
221
|
-
}
|
|
222
|
-
}), Object.create(t.roots || {})), a = {
|
|
223
|
-
...t,
|
|
224
|
-
roots: i
|
|
225
|
-
};
|
|
226
|
-
return delete a.root, a;
|
|
227
|
-
}
|
|
228
|
-
function f(e) {
|
|
229
|
-
return typeof e == "string" ? { main: e } : { ...e };
|
|
230
|
-
}
|
|
231
|
-
//#endregion
|
|
232
|
-
//#region src/hooks/editor/utils/assign-source-elements-to-editor-config.ts
|
|
233
|
-
function p(e, t, n) {
|
|
234
|
-
let r = m(t);
|
|
235
|
-
if (!e.editorName || e.editorName === "ClassicEditor") return {
|
|
236
|
-
...n,
|
|
237
|
-
attachTo: r.main
|
|
238
|
-
};
|
|
239
|
-
let i = new Set([...Object.keys(r), ...Object.keys(n.roots ?? {})]), a = Array.from(i).reduce((e, t) => ({
|
|
207
|
+
//#region src/hooks/editor/utils/assign-editor-roots-to-config.ts
|
|
208
|
+
function u(e, t, n) {
|
|
209
|
+
let r = !e.editorName || e.editorName === "ClassicEditor", i = new Set([...Object.keys(t), ...Object.keys(n.roots ?? {})]), a = Array.from(i).reduce((e, i) => ({
|
|
240
210
|
...e,
|
|
241
|
-
[
|
|
242
|
-
...n.roots?.[
|
|
243
|
-
...
|
|
244
|
-
...
|
|
211
|
+
[i]: {
|
|
212
|
+
...n.roots?.[i],
|
|
213
|
+
...i === "main" ? n.root : {},
|
|
214
|
+
...i in t ? {
|
|
215
|
+
...t[i].content !== null && { initialData: t[i].content },
|
|
216
|
+
...!r && t[i].element !== null && { element: t[i].element }
|
|
217
|
+
} : {}
|
|
245
218
|
}
|
|
246
219
|
}), Object.create(n.roots || {})), o = {
|
|
247
220
|
...n,
|
|
248
|
-
roots: a
|
|
221
|
+
roots: a,
|
|
222
|
+
...r && t.main?.element && { attachTo: t.main.element }
|
|
249
223
|
};
|
|
250
224
|
return delete o.root, o;
|
|
251
225
|
}
|
|
252
|
-
function m(e) {
|
|
253
|
-
return e instanceof HTMLElement ? { main: e } : { ...e };
|
|
254
|
-
}
|
|
255
226
|
//#endregion
|
|
256
227
|
//#region src/hooks/editor/utils/cleanup-orphan-editor-elements.ts
|
|
257
|
-
function
|
|
228
|
+
function d(e) {
|
|
258
229
|
let t = [
|
|
259
230
|
e.ui?.element,
|
|
260
231
|
e.ui?.view?.toolbar?.element,
|
|
@@ -271,9 +242,9 @@ function h(e) {
|
|
|
271
242
|
}
|
|
272
243
|
//#endregion
|
|
273
244
|
//#region src/hooks/editor/utils/create-editor-in-context.ts
|
|
274
|
-
var
|
|
275
|
-
async function
|
|
276
|
-
let r =
|
|
245
|
+
var f = Symbol.for("context-editor-watchdog");
|
|
246
|
+
async function p({ context: e, creator: t, config: n }) {
|
|
247
|
+
let r = c();
|
|
277
248
|
await e.add({
|
|
278
249
|
creator: t.create.bind(t),
|
|
279
250
|
id: r,
|
|
@@ -285,29 +256,29 @@ async function _({ context: e, creator: t, config: n }) {
|
|
|
285
256
|
editorContextId: r,
|
|
286
257
|
context: e
|
|
287
258
|
};
|
|
288
|
-
i[
|
|
259
|
+
i[f] = a;
|
|
289
260
|
let o = e.destroy.bind(e);
|
|
290
261
|
return e.destroy = async () => (a.state = "unavailable", o()), {
|
|
291
262
|
...a,
|
|
292
263
|
editor: i
|
|
293
264
|
};
|
|
294
265
|
}
|
|
295
|
-
function
|
|
296
|
-
return
|
|
266
|
+
function m(e) {
|
|
267
|
+
return f in e ? e[f] : null;
|
|
297
268
|
}
|
|
298
269
|
//#endregion
|
|
299
270
|
//#region src/hooks/editor/utils/get-editor-roots-values.ts
|
|
300
|
-
function
|
|
271
|
+
function h(e) {
|
|
301
272
|
return e.model.document.getRootNames().reduce((t, n) => (t[n] = e.getData({ rootName: n }), t), Object.create({}));
|
|
302
273
|
}
|
|
303
274
|
//#endregion
|
|
304
275
|
//#region src/hooks/editor/utils/is-multiroot-editor-instance.ts
|
|
305
|
-
function
|
|
276
|
+
function g(e) {
|
|
306
277
|
return "addEditable" in e.ui;
|
|
307
278
|
}
|
|
308
279
|
//#endregion
|
|
309
280
|
//#region src/hooks/editor/utils/is-single-root-editor.ts
|
|
310
|
-
function
|
|
281
|
+
function _(e) {
|
|
311
282
|
return [
|
|
312
283
|
"inline",
|
|
313
284
|
"classic",
|
|
@@ -317,7 +288,7 @@ function x(e) {
|
|
|
317
288
|
}
|
|
318
289
|
//#endregion
|
|
319
290
|
//#region src/hooks/editor/utils/load-editor-constructor.ts
|
|
320
|
-
async function
|
|
291
|
+
async function v(e) {
|
|
321
292
|
let t = await import("ckeditor5"), n = {
|
|
322
293
|
inline: t.InlineEditor,
|
|
323
294
|
balloon: t.BalloonEditor,
|
|
@@ -330,7 +301,7 @@ async function S(e) {
|
|
|
330
301
|
}
|
|
331
302
|
//#endregion
|
|
332
303
|
//#region src/hooks/editor/custom-editor-plugins.ts
|
|
333
|
-
var
|
|
304
|
+
var y = class e {
|
|
334
305
|
static the = new e();
|
|
335
306
|
plugins = /* @__PURE__ */ new Map();
|
|
336
307
|
constructor() {}
|
|
@@ -354,9 +325,9 @@ var C = class e {
|
|
|
354
325
|
};
|
|
355
326
|
//#endregion
|
|
356
327
|
//#region src/hooks/editor/utils/load-editor-plugins.ts
|
|
357
|
-
async function
|
|
328
|
+
async function b(e) {
|
|
358
329
|
let t = await import("ckeditor5"), n = null, r = e.map(async (e) => {
|
|
359
|
-
let r = await
|
|
330
|
+
let r = await y.the.get(e);
|
|
360
331
|
if (r) return r;
|
|
361
332
|
let { [e]: i } = t;
|
|
362
333
|
if (i) return i;
|
|
@@ -378,19 +349,19 @@ async function w(e) {
|
|
|
378
349
|
}
|
|
379
350
|
//#endregion
|
|
380
351
|
//#region src/hooks/editor/utils/load-editor-translations.ts
|
|
381
|
-
async function
|
|
382
|
-
let n = [e.ui, e.content], r = [
|
|
383
|
-
return t && r.push(
|
|
352
|
+
async function x(e, t) {
|
|
353
|
+
let n = [e.ui, e.content], r = [S("ckeditor5", n)];
|
|
354
|
+
return t && r.push(S("ckeditor5-premium-features", n)), await Promise.all(r).then((e) => e.flat());
|
|
384
355
|
}
|
|
385
|
-
async function
|
|
356
|
+
async function S(e, t) {
|
|
386
357
|
/* v8 ignore next */
|
|
387
358
|
return await Promise.all(t.filter((e) => e !== "en").map(async (t) => {
|
|
388
|
-
let n = await
|
|
359
|
+
let n = await C(e, t);
|
|
389
360
|
/* v8 ignore next -- @preserve */
|
|
390
361
|
return n?.default ?? n;
|
|
391
362
|
}).filter(Boolean));
|
|
392
363
|
}
|
|
393
|
-
async function
|
|
364
|
+
async function C(e, t) {
|
|
394
365
|
try {
|
|
395
366
|
/* v8 ignore next if -- @preserve */
|
|
396
367
|
if (e === "ckeditor5") switch (t) {
|
|
@@ -550,68 +521,65 @@ catch (n) {
|
|
|
550
521
|
}
|
|
551
522
|
//#endregion
|
|
552
523
|
//#region src/hooks/editor/utils/normalize-custom-translations.ts
|
|
553
|
-
function
|
|
554
|
-
return
|
|
524
|
+
function w(e) {
|
|
525
|
+
return o(e, (e) => ({ dictionary: e }));
|
|
555
526
|
}
|
|
556
527
|
//#endregion
|
|
557
|
-
//#region src/hooks/editor/utils/query-editor-editables.ts
|
|
558
|
-
function
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
let t = window.Livewire.all().filter(({ name: t, canonical: n }) => t === "ckeditor5-editable" && n.editorId === e).reduce((e, { canonical: t, el: n }) => ({
|
|
563
|
-
...e,
|
|
564
|
-
[t.rootName]: {
|
|
528
|
+
//#region src/hooks/editor/utils/query-all-editor-editables.ts
|
|
529
|
+
function T(e) {
|
|
530
|
+
let t = window.Livewire.all().filter(({ name: t, canonical: n }) => t === "ckeditor5-editable" && n.editorId === e).reduce((e, { canonical: t, el: n }) => {
|
|
531
|
+
let r = t.rootName;
|
|
532
|
+
return e[r] = {
|
|
565
533
|
element: n.querySelector("[data-cke-editable-content]"),
|
|
566
534
|
content: t.content
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
return
|
|
535
|
+
}, e;
|
|
536
|
+
}, Object.create({})), n = window.Livewire.all().find(({ name: t, canonical: n }) => t === "ckeditor5" && n.editorId === e);
|
|
537
|
+
/* v8 ignore next -- @preserve */
|
|
538
|
+
if (!n) return t;
|
|
539
|
+
// v8 ignore next -- @preserve
|
|
540
|
+
let r = n.canonical.content ?? {}, i = document.querySelector(`#${e}_editor`);
|
|
541
|
+
i && !t.main && (t.main = {
|
|
542
|
+
element: i,
|
|
543
|
+
content: r.main ?? ""
|
|
544
|
+
});
|
|
545
|
+
for (let [e, n] of Object.entries(r)) t[e] ? t[e] = {
|
|
546
|
+
...t[e],
|
|
547
|
+
content: t[e].content ?? n
|
|
548
|
+
} : t[e] = {
|
|
549
|
+
element: null,
|
|
550
|
+
content: n
|
|
551
|
+
};
|
|
552
|
+
return t;
|
|
585
553
|
}
|
|
586
554
|
//#endregion
|
|
587
555
|
//#region src/hooks/editor/utils/resolve-editor-config-elements-references.ts
|
|
588
|
-
function
|
|
556
|
+
function E(e) {
|
|
589
557
|
if (!e || typeof e != "object") return e;
|
|
590
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
558
|
+
if (Array.isArray(e)) return e.map((e) => E(e));
|
|
591
559
|
let t = e;
|
|
592
560
|
if (t.$element && typeof t.$element == "string") {
|
|
593
561
|
let e = document.querySelector(t.$element);
|
|
594
562
|
return e || console.warn(`Element not found for selector: ${t.$element}`), e || null;
|
|
595
563
|
}
|
|
596
564
|
let n = Object.create(null);
|
|
597
|
-
for (let [t, r] of Object.entries(e)) n[t] =
|
|
565
|
+
for (let [t, r] of Object.entries(e)) n[t] = E(r);
|
|
598
566
|
return n;
|
|
599
567
|
}
|
|
600
568
|
//#endregion
|
|
601
569
|
//#region src/hooks/editor/utils/resolve-editor-config-translations.ts
|
|
602
|
-
function
|
|
570
|
+
function D(e, t, n) {
|
|
603
571
|
if (!n || typeof n != "object") return n;
|
|
604
|
-
if (Array.isArray(n)) return n.map((n) =>
|
|
572
|
+
if (Array.isArray(n)) return n.map((n) => D(e, t, n));
|
|
605
573
|
let r = n;
|
|
606
574
|
if (r.$translation && typeof r.$translation == "string") {
|
|
607
|
-
let n = r.$translation, i =
|
|
575
|
+
let n = r.$translation, i = O(e, n, t);
|
|
608
576
|
return i === void 0 && console.warn(`Translation not found for key: ${n}`), i === void 0 ? null : i;
|
|
609
577
|
}
|
|
610
578
|
let i = Object.create(null);
|
|
611
|
-
for (let [r, a] of Object.entries(n)) i[r] =
|
|
579
|
+
for (let [r, a] of Object.entries(n)) i[r] = D(e, t, a);
|
|
612
580
|
return i;
|
|
613
581
|
}
|
|
614
|
-
function
|
|
582
|
+
function O(e, t, n) {
|
|
615
583
|
for (let r of e) {
|
|
616
584
|
let e = r[n];
|
|
617
585
|
if (e?.dictionary && t in e.dictionary) return e.dictionary[t];
|
|
@@ -619,7 +587,7 @@ function P(e, t, n) {
|
|
|
619
587
|
}
|
|
620
588
|
//#endregion
|
|
621
589
|
//#region src/hooks/editor/utils/set-editor-editable-height.ts
|
|
622
|
-
function
|
|
590
|
+
function k(e, t) {
|
|
623
591
|
let { editing: n } = e;
|
|
624
592
|
n.view.change((e) => {
|
|
625
593
|
e.setStyle("height", `${t}px`, n.view.document.getRoot());
|
|
@@ -627,34 +595,34 @@ function F(e, t) {
|
|
|
627
595
|
}
|
|
628
596
|
//#endregion
|
|
629
597
|
//#region src/hooks/editor/utils/wrap-with-watchdog.ts
|
|
630
|
-
var
|
|
631
|
-
async function
|
|
598
|
+
var A = Symbol.for("livewire-editor-watchdog");
|
|
599
|
+
async function j(e, t) {
|
|
632
600
|
let { EditorWatchdog: n } = await import("ckeditor5"), r = new n(null, t ?? {
|
|
633
601
|
crashNumberLimit: 10,
|
|
634
602
|
minimumNonErrorTimePeriod: 5e3
|
|
635
603
|
});
|
|
636
604
|
return r.setCreator(async () => {
|
|
637
605
|
let t = await e();
|
|
638
|
-
return t[
|
|
606
|
+
return t[A] = r, t;
|
|
639
607
|
}), r;
|
|
640
608
|
}
|
|
641
|
-
function
|
|
642
|
-
return
|
|
609
|
+
function M(e) {
|
|
610
|
+
return A in e ? e[A] : null;
|
|
643
611
|
}
|
|
644
612
|
//#endregion
|
|
645
613
|
//#region src/hooks/context/contexts-registry.ts
|
|
646
|
-
var
|
|
614
|
+
var N = class e extends r {
|
|
647
615
|
static the = new e();
|
|
648
|
-
},
|
|
616
|
+
}, P = class extends e {
|
|
649
617
|
contextPromise = null;
|
|
650
618
|
async mounted() {
|
|
651
|
-
let { contextId: e, language: t, context: n } = this.canonical, { customTranslations: r, watchdogConfig: i, config: { plugins:
|
|
619
|
+
let { contextId: e, language: t, context: n } = this.canonical, { customTranslations: r, watchdogConfig: i, config: { plugins: o, ...s } } = n, { loadedPlugins: c, hasPremium: l } = await b(o ?? []), u = [...await x(t, l), w(r || {})].filter((e) => !a(e));
|
|
652
620
|
this.contextPromise = (async () => {
|
|
653
621
|
let { ContextWatchdog: e, Context: n } = await import("ckeditor5"), r = new e(n, {
|
|
654
622
|
crashNumberLimit: 10,
|
|
655
623
|
...i
|
|
656
|
-
}), a =
|
|
657
|
-
return a =
|
|
624
|
+
}), a = E(s);
|
|
625
|
+
return a = D([...u].reverse(), t.ui, a), await r.create({
|
|
658
626
|
...a,
|
|
659
627
|
language: t,
|
|
660
628
|
plugins: c,
|
|
@@ -665,7 +633,7 @@ var z = class e extends r {
|
|
|
665
633
|
})();
|
|
666
634
|
let d = await this.contextPromise;
|
|
667
635
|
/* v8 ignore next if -- @preserve */
|
|
668
|
-
this.isBeingDestroyed() ||
|
|
636
|
+
this.isBeingDestroyed() || N.the.register(e, d);
|
|
669
637
|
}
|
|
670
638
|
async destroyed() {
|
|
671
639
|
let { contextId: e } = this.canonical;
|
|
@@ -673,15 +641,15 @@ var z = class e extends r {
|
|
|
673
641
|
try {
|
|
674
642
|
await (await this.contextPromise)?.destroy();
|
|
675
643
|
} finally {
|
|
676
|
-
this.contextPromise = null,
|
|
644
|
+
this.contextPromise = null, N.the.hasItem(e) && N.the.unregister(e);
|
|
677
645
|
}
|
|
678
646
|
}
|
|
679
|
-
},
|
|
647
|
+
}, F = class e extends r {
|
|
680
648
|
static the = new e();
|
|
681
649
|
};
|
|
682
650
|
//#endregion
|
|
683
651
|
//#region src/hooks/utils/is-wire-model-connected.ts
|
|
684
|
-
function
|
|
652
|
+
function I(e) {
|
|
685
653
|
let t = e;
|
|
686
654
|
for (; t;) {
|
|
687
655
|
for (let e of t.attributes) if (e.name.startsWith("wire:model")) return !0;
|
|
@@ -691,7 +659,7 @@ function H(e) {
|
|
|
691
659
|
}
|
|
692
660
|
//#endregion
|
|
693
661
|
//#region src/hooks/utils/root-attributes-updater.ts
|
|
694
|
-
function
|
|
662
|
+
function L(e, t) {
|
|
695
663
|
let n = /* @__PURE__ */ new Set();
|
|
696
664
|
return (r) => {
|
|
697
665
|
e.model.enqueueChange({ isUndoable: !1 }, (i) => {
|
|
@@ -705,11 +673,11 @@ function U(e, t) {
|
|
|
705
673
|
}
|
|
706
674
|
//#endregion
|
|
707
675
|
//#region src/hooks/editable.ts
|
|
708
|
-
var
|
|
676
|
+
var R = class extends e {
|
|
709
677
|
rootAttributesUpdater = null;
|
|
710
678
|
pendingContent = null;
|
|
711
679
|
mounted() {
|
|
712
|
-
let { editorId: e, rootName: t, content: n } = this.canonical, r =
|
|
680
|
+
let { editorId: e, rootName: t, content: n } = this.canonical, r = F.the.mountEffect(e, (e) => {
|
|
713
681
|
/* v8 ignore next if -- @preserve */
|
|
714
682
|
if (this.isBeingDestroyed()) return;
|
|
715
683
|
let r = e.model.document.getRoot(t);
|
|
@@ -718,7 +686,7 @@ var W = class extends e {
|
|
|
718
686
|
r && r !== n && e.setData({ [t]: n });
|
|
719
687
|
}
|
|
720
688
|
/* v8 ignore next else -- @preserve */
|
|
721
|
-
if (!r &&
|
|
689
|
+
if (!r && g(e)) {
|
|
722
690
|
let { ui: r, editing: i } = e;
|
|
723
691
|
e.addRoot(t, {
|
|
724
692
|
isUndoable: !1,
|
|
@@ -733,7 +701,7 @@ var W = class extends e {
|
|
|
733
701
|
if (i(), a(), this.rootAttributesUpdater?.(null), e.state !== "destroyed") {
|
|
734
702
|
let n = e.model.document.getRoot(t);
|
|
735
703
|
/* v8 ignore next if -- @preserve */
|
|
736
|
-
if (n &&
|
|
704
|
+
if (n && g(e)) {
|
|
737
705
|
try {
|
|
738
706
|
/* v8 ignore else -- @preserve */
|
|
739
707
|
e.ui.view.editables[t] && e.detachEditable(n);
|
|
@@ -749,7 +717,7 @@ var W = class extends e {
|
|
|
749
717
|
this.onBeforeDestroy(r);
|
|
750
718
|
}
|
|
751
719
|
async afterCommitSynced() {
|
|
752
|
-
let { editorId: e } = this.canonical, t = await
|
|
720
|
+
let { editorId: e } = this.canonical, t = await F.the.waitFor(e);
|
|
753
721
|
this.applyCanonicalContentToEditor(t), this.applyRootAttributes(t);
|
|
754
722
|
}
|
|
755
723
|
destroyed() {
|
|
@@ -778,7 +746,7 @@ var W = class extends e {
|
|
|
778
746
|
};
|
|
779
747
|
}
|
|
780
748
|
applyCanonicalContentToEditor(e) {
|
|
781
|
-
if (!
|
|
749
|
+
if (!I(this.element)) return;
|
|
782
750
|
let { content: t, rootName: n } = this.canonical, { ui: r } = e;
|
|
783
751
|
if (e.getData({ rootName: n }) !== (t ?? "")) {
|
|
784
752
|
if (r.focusTracker.isFocused) {
|
|
@@ -790,12 +758,12 @@ var W = class extends e {
|
|
|
790
758
|
}
|
|
791
759
|
applyRootAttributes(e) {
|
|
792
760
|
let { rootName: t, rootAttributes: n } = this.canonical;
|
|
793
|
-
this.rootAttributesUpdater ??=
|
|
761
|
+
this.rootAttributesUpdater ??= L(e, t), this.rootAttributesUpdater(n);
|
|
794
762
|
}
|
|
795
763
|
};
|
|
796
764
|
//#endregion
|
|
797
765
|
//#region src/hooks/editor/plugins/livewire-sync.ts
|
|
798
|
-
async function
|
|
766
|
+
async function z({ saveDebounceMs: e, component: t }) {
|
|
799
767
|
let { Plugin: n } = await import("ckeditor5");
|
|
800
768
|
return class extends n {
|
|
801
769
|
static get pluginName() {
|
|
@@ -807,15 +775,15 @@ async function G({ saveDebounceMs: e, component: t }) {
|
|
|
807
775
|
setupAfterCommitHandler() {
|
|
808
776
|
let { editor: e } = this, { model: n, ui: { focusTracker: r } } = e, i = null;
|
|
809
777
|
e.on("afterCommitSynced", () => {
|
|
810
|
-
if (!
|
|
778
|
+
if (!I(t.element)) return;
|
|
811
779
|
let { content: n } = t.canonical, a = this.getEditorRootsValues();
|
|
812
780
|
if (r.isFocused) {
|
|
813
781
|
/* v8 ignore next else -- @preserve */
|
|
814
|
-
|
|
782
|
+
s(n, a) || (i = n);
|
|
815
783
|
return;
|
|
816
784
|
}
|
|
817
785
|
/* v8 ignore next else -- @preserve */
|
|
818
|
-
|
|
786
|
+
s(n, a) || e.setData(n);
|
|
819
787
|
}), n.document.on("change:data", () => {
|
|
820
788
|
i = null;
|
|
821
789
|
}), r.on("change:isFocused", () => {
|
|
@@ -830,17 +798,17 @@ async function G({ saveDebounceMs: e, component: t }) {
|
|
|
830
798
|
}
|
|
831
799
|
setupSetEditorContentHandler() {
|
|
832
800
|
let { editor: e } = this, n = Livewire.on("set-editor-content", ({ editorId: n, content: r }) => {
|
|
833
|
-
n === t.canonical.editorId && (
|
|
801
|
+
n === t.canonical.editorId && (s(this.getEditorRootsValues(), r) || e.setData(r));
|
|
834
802
|
});
|
|
835
803
|
/* v8 ignore next if -- @preserve */
|
|
836
804
|
typeof n == "function" && e.once("destroy", n);
|
|
837
805
|
}
|
|
838
806
|
setupTypingContentPush() {
|
|
839
|
-
let { editor: n } = this, { model: r, ui: a } = n, { $wire: o } = t,
|
|
807
|
+
let { editor: n } = this, { model: r, ui: a } = n, { $wire: o } = t, c = !1, l = () => {
|
|
840
808
|
/* v8 ignore next if -- @preserve */
|
|
841
|
-
if (
|
|
809
|
+
if (c) return;
|
|
842
810
|
let e = this.getEditorRootsValues();
|
|
843
|
-
|
|
811
|
+
s(e, t.canonical.content ?? {}) || (o.set("content", e), o.dispatch("editor-content-changed", {
|
|
844
812
|
editorId: t.canonical.editorId,
|
|
845
813
|
content: e
|
|
846
814
|
}));
|
|
@@ -848,24 +816,24 @@ async function G({ saveDebounceMs: e, component: t }) {
|
|
|
848
816
|
r.document.on("change:data", i(10, () => {
|
|
849
817
|
a.focusTracker.isFocused ? u() : l();
|
|
850
818
|
})), n.once("ready", l), n.once("destroy", () => {
|
|
851
|
-
|
|
819
|
+
c = !0;
|
|
852
820
|
});
|
|
853
821
|
}
|
|
854
822
|
setupFocusableEventPush() {
|
|
855
823
|
let { ui: e } = this.editor, { $wire: n } = t;
|
|
856
824
|
e.focusTracker.on("change:isFocused", () => {
|
|
857
825
|
let r = this.getEditorRootsValues();
|
|
858
|
-
n.set("focused", e.focusTracker.isFocused),
|
|
826
|
+
n.set("focused", e.focusTracker.isFocused), s(r, t.canonical.content ?? {}) || n.set("content", r);
|
|
859
827
|
});
|
|
860
828
|
}
|
|
861
829
|
getEditorRootsValues() {
|
|
862
|
-
return
|
|
830
|
+
return h(this.editor);
|
|
863
831
|
}
|
|
864
832
|
};
|
|
865
833
|
}
|
|
866
834
|
//#endregion
|
|
867
835
|
//#region src/hooks/editor/plugins/sync-editor-with-input.ts
|
|
868
|
-
async function
|
|
836
|
+
async function B(e) {
|
|
869
837
|
let { Plugin: t } = await import("ckeditor5");
|
|
870
838
|
return class extends t {
|
|
871
839
|
input = null;
|
|
@@ -891,101 +859,88 @@ async function K(e) {
|
|
|
891
859
|
}
|
|
892
860
|
//#endregion
|
|
893
861
|
//#region src/hooks/editor/editor.ts
|
|
894
|
-
var
|
|
862
|
+
var V = class extends e {
|
|
895
863
|
rootAttributesUpdater = null;
|
|
896
864
|
async mounted() {
|
|
897
865
|
let { editorId: e } = this.canonical;
|
|
898
|
-
|
|
866
|
+
F.the.resetErrors(e);
|
|
899
867
|
try {
|
|
900
|
-
let t = await this.createEditor(), n =
|
|
868
|
+
let t = await this.createEditor(), n = m(t), r = M(t);
|
|
901
869
|
/* v8 ignore next 3 */
|
|
902
870
|
if (this.isBeingDestroyed()) return;
|
|
903
|
-
let i =
|
|
871
|
+
let i = F.the.mountEffect(e, (t) => {
|
|
904
872
|
t.once("destroy", () => {
|
|
905
|
-
|
|
873
|
+
F.the.unregister(e, !1);
|
|
906
874
|
}, { priority: "highest" });
|
|
907
875
|
});
|
|
908
876
|
this.onBeforeDestroy(async () => {
|
|
909
|
-
|
|
910
|
-
}),
|
|
877
|
+
F.the.unregister(e), i(), n ? n.state !== "unavailable" && await n.context.remove(n.editorContextId) : r ? await r.destroy() : await t.destroy();
|
|
878
|
+
}), F.the.register(e, t);
|
|
911
879
|
} catch (t) {
|
|
912
|
-
console.error(`Error initializing CKEditor5 instance with ID "${e}":`, t),
|
|
880
|
+
console.error(`Error initializing CKEditor5 instance with ID "${e}":`, t), F.the.error(e, t);
|
|
913
881
|
}
|
|
914
882
|
}
|
|
915
883
|
async destroyed() {
|
|
916
884
|
this.element.style.display = "none";
|
|
917
885
|
}
|
|
918
886
|
async afterCommitSynced() {
|
|
919
|
-
let e = await
|
|
887
|
+
let e = await F.the.waitFor(this.canonical.editorId);
|
|
920
888
|
/* v8 ignore if -- @preserve */
|
|
921
889
|
e && (e.fire("afterCommitSynced"), this.applyRootAttributes(e));
|
|
922
890
|
}
|
|
923
891
|
applyRootAttributes(e) {
|
|
924
892
|
let { rootAttributes: t } = this.canonical;
|
|
925
|
-
this.rootAttributesUpdater ??=
|
|
893
|
+
this.rootAttributesUpdater ??= L(e, "main"), this.rootAttributesUpdater(t);
|
|
926
894
|
}
|
|
927
895
|
async createEditor() {
|
|
928
|
-
let { preset: e, editorId: t, contextId: n, editableHeight: r, saveDebounceMs: i, language:
|
|
929
|
-
let { loadedPlugins: e, hasPremium: n } = await
|
|
930
|
-
e.push(await
|
|
896
|
+
let { preset: e, editorId: t, contextId: n, editableHeight: r, saveDebounceMs: i, language: o, watchdog: s } = this.canonical, { customTranslations: c, editorType: l, licenseKey: f, watchdogConfig: m, config: { plugins: h, ...g } } = e, y = await v(l), S = await (n ? N.the.waitFor(n) : null), C = async () => {
|
|
897
|
+
let { loadedPlugins: e, hasPremium: n } = await b(h);
|
|
898
|
+
e.push(await z({
|
|
931
899
|
saveDebounceMs: i,
|
|
932
900
|
component: this
|
|
933
|
-
})),
|
|
934
|
-
let s = [...await
|
|
935
|
-
|
|
936
|
-
|
|
901
|
+
})), _(l) && e.push(await B(i));
|
|
902
|
+
let s = [...await x(o, n), w(c || {})].filter((e) => !a(e)), d = T(t), m = Object.keys(d);
|
|
903
|
+
_(l) && m.push("main"), H(d, m) || (d = await U(t, m));
|
|
904
|
+
let v = {
|
|
905
|
+
...g,
|
|
906
|
+
licenseKey: f,
|
|
907
|
+
plugins: e,
|
|
908
|
+
language: o,
|
|
909
|
+
...s.length && { translations: s }
|
|
937
910
|
};
|
|
938
|
-
|
|
939
|
-
let
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
...j(t)
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
x(u) && "main" in n && (n = n.main);
|
|
949
|
-
let r = {
|
|
950
|
-
...v,
|
|
951
|
-
licenseKey: f,
|
|
952
|
-
plugins: e,
|
|
953
|
-
language: a,
|
|
954
|
-
...s.length && { translations: s }
|
|
955
|
-
};
|
|
956
|
-
return r = M(r), r = N([...s].reverse(), a.ui, r), r = p(y, n, r), r = d(m, r), b ? (await _({
|
|
957
|
-
context: b,
|
|
958
|
-
creator: y,
|
|
959
|
-
config: r
|
|
960
|
-
})).editor : y.create(r);
|
|
961
|
-
})();
|
|
962
|
-
return x(u) && r && F(h, r), this.applyRootAttributes(h), h;
|
|
911
|
+
v = E(v), v = D([...s].reverse(), o.ui, v), v = u(y, d, v);
|
|
912
|
+
let C = await (async () => S ? (await p({
|
|
913
|
+
context: S,
|
|
914
|
+
creator: y,
|
|
915
|
+
config: v
|
|
916
|
+
})).editor : y.create(v))();
|
|
917
|
+
return _(l) && r && k(C, r), this.applyRootAttributes(C), C;
|
|
963
918
|
};
|
|
964
|
-
if (s && !
|
|
965
|
-
let e = await
|
|
919
|
+
if (s && !S) {
|
|
920
|
+
let e = await j(C, m);
|
|
966
921
|
return e.on("error", (e, { causesRestart: n }) => {
|
|
967
922
|
if (n) {
|
|
968
|
-
let e =
|
|
923
|
+
let e = F.the.getItem(t);
|
|
969
924
|
/* v8 ignore next 3 */
|
|
970
|
-
e && (
|
|
925
|
+
e && (d(e), F.the.unregister(t));
|
|
971
926
|
}
|
|
972
927
|
}), e.on("restart", () => {
|
|
973
|
-
|
|
928
|
+
F.the.register(t, e.editor);
|
|
974
929
|
}), await e.create({}), e.editor;
|
|
975
930
|
}
|
|
976
931
|
return C();
|
|
977
932
|
}
|
|
978
933
|
};
|
|
979
|
-
function
|
|
980
|
-
return t.every((t) => e[t]);
|
|
934
|
+
function H(e, t) {
|
|
935
|
+
return t.every((t) => e[t]?.element);
|
|
981
936
|
}
|
|
982
|
-
async function
|
|
983
|
-
return
|
|
984
|
-
let n =
|
|
985
|
-
if (!
|
|
937
|
+
async function U(e, t) {
|
|
938
|
+
return l(() => {
|
|
939
|
+
let n = T(e);
|
|
940
|
+
if (!H(n, t)) throw Error(`It looks like not all required root elements are present yet.
|
|
986
941
|
* If you want to wait for them, ensure they are registered before editor initialization.
|
|
987
942
|
* If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
|
|
988
|
-
Missing roots: ${t.filter((e) => !n[e]).join(", ")}.`);
|
|
943
|
+
Missing roots: ${t.filter((e) => !n[e]?.element).join(", ")}.`);
|
|
989
944
|
return n;
|
|
990
945
|
}, {
|
|
991
946
|
timeOutAfter: 2e3,
|
|
@@ -994,12 +949,12 @@ Missing roots: ${t.filter((e) => !n[e]).join(", ")}.`);
|
|
|
994
949
|
}
|
|
995
950
|
//#endregion
|
|
996
951
|
//#region src/hooks/ui-part.ts
|
|
997
|
-
var
|
|
952
|
+
var W = class extends e {
|
|
998
953
|
mounted() {
|
|
999
|
-
let { editorId: e, name: t } = this.canonical, n =
|
|
954
|
+
let { editorId: e, name: t } = this.canonical, n = F.the.mountEffect(e, (e) => {
|
|
1000
955
|
/* v8 ignore next if -- @preserve */
|
|
1001
956
|
if (this.isBeingDestroyed()) return;
|
|
1002
|
-
let { ui: n } = e, r =
|
|
957
|
+
let { ui: n } = e, r = G(t), i = n.view[r];
|
|
1003
958
|
if (!i) {
|
|
1004
959
|
console.error(`Unknown UI part name: "${t}". Supported names are "toolbar" and "menubar".`);
|
|
1005
960
|
return;
|
|
@@ -1014,7 +969,7 @@ var X = class extends e {
|
|
|
1014
969
|
this.element.style.display = "none";
|
|
1015
970
|
}
|
|
1016
971
|
};
|
|
1017
|
-
function
|
|
972
|
+
function G(e) {
|
|
1018
973
|
switch (e) {
|
|
1019
974
|
case "toolbar": return "toolbar";
|
|
1020
975
|
case "menubar": return "menuBarView";
|
|
@@ -1023,19 +978,19 @@ function Z(e) {
|
|
|
1023
978
|
}
|
|
1024
979
|
//#endregion
|
|
1025
980
|
//#region src/hooks/index.ts
|
|
1026
|
-
var
|
|
1027
|
-
ckeditor5:
|
|
1028
|
-
"ckeditor5-context":
|
|
1029
|
-
"ckeditor5-ui-part":
|
|
1030
|
-
"ckeditor5-editable":
|
|
981
|
+
var K = {
|
|
982
|
+
ckeditor5: V,
|
|
983
|
+
"ckeditor5-context": P,
|
|
984
|
+
"ckeditor5-ui-part": W,
|
|
985
|
+
"ckeditor5-editable": R
|
|
1031
986
|
};
|
|
1032
|
-
function
|
|
1033
|
-
for (let [e, n] of Object.entries(
|
|
987
|
+
function q() {
|
|
988
|
+
for (let [e, n] of Object.entries(K)) t(e, n);
|
|
1034
989
|
}
|
|
1035
990
|
//#endregion
|
|
1036
991
|
//#region src/index.ts
|
|
1037
|
-
|
|
992
|
+
q();
|
|
1038
993
|
//#endregion
|
|
1039
|
-
export { e as ClassHook,
|
|
994
|
+
export { e as ClassHook, N as ContextsRegistry, y as CustomEditorPluginsRegistry, R as EditableComponentHook, V as EditorComponentHook, F as EditorsRegistry, W as UIPartComponentHook, t as registerLivewireComponentHook };
|
|
1040
995
|
|
|
1041
996
|
//# sourceMappingURL=index.mjs.map
|