ckeditor5-phoenix 1.27.0 → 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/hooks/editor/editor.d.ts.map +1 -1
- package/dist/hooks/editor/utils/assign-editor-roots-to-config.d.ts +14 -0
- package/dist/hooks/editor/utils/assign-editor-roots-to-config.d.ts.map +1 -0
- package/dist/hooks/editor/utils/index.d.ts +1 -2
- package/dist/hooks/editor/utils/index.d.ts.map +1 -1
- package/dist/hooks/editor/utils/query-all-editor-editables.d.ts +0 -16
- 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 +324 -369
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/editor/editor.ts +30 -53
- package/src/hooks/editor/utils/{assign-source-elements-to-editor-config.ts → assign-editor-roots-to-config.ts} +16 -22
- package/src/hooks/editor/utils/index.ts +1 -2
- package/src/hooks/editor/utils/query-all-editor-editables.ts +0 -29
- 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/src/hooks/editor/utils/assign-initial-data-to-editor-config.ts +0 -47
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
function
|
|
1
|
+
function j(r, t) {
|
|
2
2
|
if (!r || r.size !== t.size)
|
|
3
3
|
return !1;
|
|
4
|
-
for (const [e,
|
|
5
|
-
if (!t.has(e) || t.get(e) !==
|
|
4
|
+
for (const [e, a] of r)
|
|
5
|
+
if (!t.has(e) || t.get(e) !== a)
|
|
6
6
|
return !1;
|
|
7
7
|
return !0;
|
|
8
8
|
}
|
|
9
|
-
class
|
|
9
|
+
class W {
|
|
10
10
|
/**
|
|
11
11
|
* Map of registered items.
|
|
12
12
|
*/
|
|
@@ -41,13 +41,13 @@ class Y {
|
|
|
41
41
|
* @param onError Optional error callback.
|
|
42
42
|
* @returns A promise that resolves with the result of the function.
|
|
43
43
|
*/
|
|
44
|
-
execute(t, e,
|
|
45
|
-
const
|
|
46
|
-
return i ? (
|
|
44
|
+
execute(t, e, a) {
|
|
45
|
+
const n = this.items.get(t), i = this.initializationErrors.get(t);
|
|
46
|
+
return i ? (a?.(i), Promise.reject(i)) : n ? Promise.resolve(e(n)) : new Promise((s, c) => {
|
|
47
47
|
const o = this.getPendingCallbacks(t);
|
|
48
48
|
o.success.push(async (u) => {
|
|
49
49
|
s(await e(u));
|
|
50
|
-
}),
|
|
50
|
+
}), a ? o.error.push(a) : o.error.push(c);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
@@ -58,19 +58,19 @@ class Y {
|
|
|
58
58
|
* @returns A function that stops observing and immediately runs any pending cleanup.
|
|
59
59
|
*/
|
|
60
60
|
mountEffect(t, e) {
|
|
61
|
-
let
|
|
61
|
+
let a, n, i = !1;
|
|
62
62
|
const s = this.watch((c) => {
|
|
63
63
|
const o = c.get(t);
|
|
64
|
-
if (o !==
|
|
64
|
+
if (o !== n && (a?.(), a = void 0, n = o, !!o))
|
|
65
65
|
try {
|
|
66
66
|
const u = e(o);
|
|
67
|
-
i ? (u?.(), s()) :
|
|
67
|
+
i ? (u?.(), s()) : a = u;
|
|
68
68
|
} catch (u) {
|
|
69
69
|
throw console.error(u), u;
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
return () => {
|
|
73
|
-
i = !0,
|
|
73
|
+
i = !0, n && (s(), a?.(), a = void 0);
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
@@ -84,8 +84,8 @@ class Y {
|
|
|
84
84
|
if (this.items.has(t))
|
|
85
85
|
throw new Error(`Item with ID "${t}" is already registered.`);
|
|
86
86
|
this.resetErrors(t), this.items.set(t, e);
|
|
87
|
-
const
|
|
88
|
-
|
|
87
|
+
const a = this.pendingCallbacks.get(t);
|
|
88
|
+
a && (a.success.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.items.size === 1 && t !== null && this.register(null, e);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -97,8 +97,8 @@ class Y {
|
|
|
97
97
|
error(t, e) {
|
|
98
98
|
this.batch(() => {
|
|
99
99
|
this.items.delete(t), this.initializationErrors.set(t, e);
|
|
100
|
-
const
|
|
101
|
-
|
|
100
|
+
const a = this.pendingCallbacks.get(t);
|
|
101
|
+
a && (a.error.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e);
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
@@ -154,8 +154,8 @@ class Y {
|
|
|
154
154
|
* @returns A promise that resolves with the item instance.
|
|
155
155
|
*/
|
|
156
156
|
waitFor(t) {
|
|
157
|
-
return new Promise((e,
|
|
158
|
-
this.execute(t, e,
|
|
157
|
+
return new Promise((e, a) => {
|
|
158
|
+
this.execute(t, e, a);
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
@@ -215,7 +215,7 @@ class Y {
|
|
|
215
215
|
* Immediately dispatches the current state to all watchers if it changed.
|
|
216
216
|
*/
|
|
217
217
|
flushWatchers() {
|
|
218
|
-
|
|
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,46 +231,42 @@ class Y {
|
|
|
231
231
|
return e || (e = { success: [], error: [] }, this.pendingCallbacks.set(t, e)), e;
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
function
|
|
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 P(r, t) {
|
|
238
238
|
let e = null;
|
|
239
|
-
return (...
|
|
239
|
+
return (...a) => {
|
|
240
240
|
e && clearTimeout(e), e = setTimeout(() => {
|
|
241
|
-
t(...
|
|
241
|
+
t(...a);
|
|
242
242
|
}, r);
|
|
243
243
|
};
|
|
244
244
|
}
|
|
245
|
-
function
|
|
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
|
|
251
|
+
function A(r) {
|
|
252
252
|
if (Array.isArray(r))
|
|
253
|
-
return r.map(
|
|
254
|
-
if (
|
|
253
|
+
return r.map(A);
|
|
254
|
+
if (tt(r)) {
|
|
255
255
|
const t = /* @__PURE__ */ Object.create(null);
|
|
256
|
-
for (const [e,
|
|
257
|
-
t[
|
|
256
|
+
for (const [e, a] of Object.entries(r))
|
|
257
|
+
t[Z(e)] = A(a);
|
|
258
258
|
return t;
|
|
259
259
|
}
|
|
260
260
|
return r;
|
|
261
261
|
}
|
|
262
|
-
function
|
|
263
|
-
const e = Object.entries(r).filter(([n, a]) => t(a, n));
|
|
264
|
-
return Object.fromEntries(e);
|
|
265
|
-
}
|
|
266
|
-
function st() {
|
|
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
|
|
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
|
|
344
|
+
function O(r) {
|
|
349
345
|
return {
|
|
350
346
|
/**
|
|
351
347
|
* The mounted lifecycle callback for the LiveView hook object.
|
|
@@ -353,7 +349,7 @@ function N(r) {
|
|
|
353
349
|
*/
|
|
354
350
|
async mounted() {
|
|
355
351
|
const t = new r();
|
|
356
|
-
this.el.instance = t, t.el = this.el, t.pushEvent = (
|
|
352
|
+
this.el.instance = t, t.el = this.el, t.pushEvent = (a, n, i) => this.pushEvent?.(a, n, i), t.pushEventTo = (a, n, i, s) => this.pushEventTo?.(a, n, i, s), t.handleEvent = (a, n) => this.handleEvent?.(a, n), t.state = "mounting";
|
|
357
353
|
const e = await t.mounted?.();
|
|
358
354
|
return t.state = "mounted", e;
|
|
359
355
|
},
|
|
@@ -390,125 +386,97 @@ function N(r) {
|
|
|
390
386
|
}
|
|
391
387
|
};
|
|
392
388
|
}
|
|
393
|
-
function
|
|
389
|
+
function L(r) {
|
|
394
390
|
return Object.keys(r).length === 0 && r.constructor === Object;
|
|
395
391
|
}
|
|
396
|
-
function
|
|
392
|
+
function rt(r) {
|
|
397
393
|
return r == null;
|
|
398
394
|
}
|
|
399
|
-
function
|
|
400
|
-
const e = Object.entries(r).map(([
|
|
395
|
+
function at(r, t) {
|
|
396
|
+
const e = Object.entries(r).map(([a, n]) => [a, t(n, a)]);
|
|
401
397
|
return Object.fromEntries(e);
|
|
402
398
|
}
|
|
403
|
-
function
|
|
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
|
|
405
|
+
function nt(r) {
|
|
410
406
|
return r == null || r.trim() === "" ? null : JSON.parse(r);
|
|
411
407
|
}
|
|
412
|
-
function
|
|
408
|
+
function it(r, t) {
|
|
413
409
|
if (r === t)
|
|
414
410
|
return !0;
|
|
415
|
-
const e = Object.keys(r),
|
|
416
|
-
if (e.length !==
|
|
411
|
+
const e = Object.keys(r), a = Object.keys(t);
|
|
412
|
+
if (e.length !== a.length)
|
|
417
413
|
return !1;
|
|
418
|
-
for (const
|
|
419
|
-
if (r[
|
|
414
|
+
for (const n of e)
|
|
415
|
+
if (r[n] !== t[n] || !Object.prototype.hasOwnProperty.call(t, n))
|
|
420
416
|
return !1;
|
|
421
417
|
return !0;
|
|
422
418
|
}
|
|
423
|
-
function
|
|
419
|
+
function st() {
|
|
424
420
|
return Math.random().toString(36).substring(2);
|
|
425
421
|
}
|
|
426
|
-
function
|
|
422
|
+
function ot(r, {
|
|
427
423
|
timeOutAfter: t = 500,
|
|
428
424
|
retryAfter: e = 100
|
|
429
425
|
} = {}) {
|
|
430
|
-
return new Promise((
|
|
426
|
+
return new Promise((a, n) => {
|
|
431
427
|
const i = Date.now();
|
|
432
428
|
let s = null;
|
|
433
429
|
const c = setTimeout(() => {
|
|
434
|
-
|
|
430
|
+
n(s ?? new Error("Timeout"));
|
|
435
431
|
}, t), o = async () => {
|
|
436
432
|
try {
|
|
437
433
|
const u = await r();
|
|
438
|
-
clearTimeout(c),
|
|
434
|
+
clearTimeout(c), a(u);
|
|
439
435
|
} catch (u) {
|
|
440
|
-
s = u, Date.now() - i > t ?
|
|
436
|
+
s = u, Date.now() - i > t ? n(u) : setTimeout(o, e);
|
|
441
437
|
}
|
|
442
438
|
};
|
|
443
439
|
o();
|
|
444
440
|
});
|
|
445
441
|
}
|
|
446
|
-
function
|
|
447
|
-
const
|
|
448
|
-
...Object.keys(
|
|
449
|
-
...Object.keys(t.roots ?? {})
|
|
450
|
-
]), a = Array.from(n).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: a
|
|
463
|
-
};
|
|
464
|
-
return delete i.root, i;
|
|
465
|
-
}
|
|
466
|
-
function mt(r) {
|
|
467
|
-
return typeof r == "string" ? { main: r } : { ...r };
|
|
468
|
-
}
|
|
469
|
-
function pt(r, t, e) {
|
|
470
|
-
const n = ft(t);
|
|
471
|
-
if (!r.editorName || r.editorName === "ClassicEditor")
|
|
472
|
-
return {
|
|
473
|
-
...e,
|
|
474
|
-
attachTo: n.main
|
|
475
|
-
};
|
|
476
|
-
const a = /* @__PURE__ */ new Set([
|
|
477
|
-
...Object.keys(n),
|
|
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
|
-
]), i = Array.from(
|
|
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
|
|
486
|
-
...o in
|
|
487
|
-
|
|
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
|
|
497
|
-
return r instanceof HTMLElement ? { main: r } : { ...r };
|
|
498
|
-
}
|
|
499
|
-
function wt(r) {
|
|
467
|
+
function ut(r) {
|
|
500
468
|
const t = [
|
|
501
469
|
r.ui?.element,
|
|
502
470
|
r.ui?.view?.toolbar?.element,
|
|
503
471
|
r.ui?.view?.menuBarView?.element
|
|
504
472
|
].filter(Boolean);
|
|
505
473
|
for (const i of t)
|
|
506
|
-
|
|
474
|
+
n(i);
|
|
507
475
|
const e = r.ui?.view?.body?._bodyCollectionContainer;
|
|
508
|
-
e?.isConnected &&
|
|
509
|
-
const
|
|
510
|
-
if (
|
|
511
|
-
for (const i of
|
|
476
|
+
e?.isConnected && n(e);
|
|
477
|
+
const a = r.editing?.view;
|
|
478
|
+
if (a)
|
|
479
|
+
for (const i of a.domRoots.values())
|
|
512
480
|
i instanceof HTMLElement && (i.removeAttribute("contenteditable"), i.removeAttribute("role"), i.removeAttribute("aria-label"), i.removeAttribute("aria-multiline"), i.removeAttribute("spellcheck"), i.classList.remove(
|
|
513
481
|
"ck",
|
|
514
482
|
"ck-content",
|
|
@@ -517,52 +485,52 @@ function wt(r) {
|
|
|
517
485
|
"ck-editor__editable_inline",
|
|
518
486
|
"ck-blurred",
|
|
519
487
|
"ck-focused"
|
|
520
|
-
),
|
|
521
|
-
function
|
|
488
|
+
), n(i));
|
|
489
|
+
function n(i) {
|
|
522
490
|
i.hasAttribute("data-cke-controlled") ? i.innerHTML = "" : i.remove();
|
|
523
491
|
}
|
|
524
492
|
}
|
|
525
493
|
const R = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
|
|
526
|
-
async function
|
|
527
|
-
const
|
|
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
|
-
id:
|
|
498
|
+
id: a,
|
|
531
499
|
type: "editor",
|
|
532
500
|
config: e
|
|
533
501
|
});
|
|
534
|
-
const
|
|
502
|
+
const n = r.getItem(a), i = {
|
|
535
503
|
state: "available",
|
|
536
|
-
editorContextId:
|
|
504
|
+
editorContextId: a,
|
|
537
505
|
context: r
|
|
538
506
|
};
|
|
539
|
-
|
|
507
|
+
n[R] = i;
|
|
540
508
|
const s = r.destroy.bind(r);
|
|
541
509
|
return r.destroy = async () => (i.state = "unavailable", s()), {
|
|
542
510
|
...i,
|
|
543
|
-
editor:
|
|
511
|
+
editor: n
|
|
544
512
|
};
|
|
545
513
|
}
|
|
546
|
-
function
|
|
514
|
+
function dt(r) {
|
|
547
515
|
return R in r ? r[R] : null;
|
|
548
516
|
}
|
|
549
|
-
function
|
|
517
|
+
function q(r) {
|
|
550
518
|
return "addEditable" in r.ui;
|
|
551
519
|
}
|
|
552
|
-
function
|
|
520
|
+
function N(r) {
|
|
553
521
|
return ["inline", "classic", "balloon", "decoupled"].includes(r);
|
|
554
522
|
}
|
|
555
|
-
async function
|
|
556
|
-
const t = await import("ckeditor5"),
|
|
523
|
+
async function ht(r) {
|
|
524
|
+
const t = await import("ckeditor5"), a = {
|
|
557
525
|
inline: t.InlineEditor,
|
|
558
526
|
balloon: t.BalloonEditor,
|
|
559
527
|
classic: t.ClassicEditor,
|
|
560
528
|
decoupled: t.DecoupledEditor,
|
|
561
529
|
multiroot: t.MultiRootEditor
|
|
562
530
|
}[r];
|
|
563
|
-
if (!
|
|
531
|
+
if (!a)
|
|
564
532
|
throw new Error(`Unsupported editor type: ${r}`);
|
|
565
|
-
return
|
|
533
|
+
return a;
|
|
566
534
|
}
|
|
567
535
|
class $ {
|
|
568
536
|
static the = new $();
|
|
@@ -624,14 +592,14 @@ class $ {
|
|
|
624
592
|
return this.plugins.has(t);
|
|
625
593
|
}
|
|
626
594
|
}
|
|
627
|
-
async function
|
|
595
|
+
async function K(r) {
|
|
628
596
|
const t = await import("ckeditor5");
|
|
629
597
|
let e = null;
|
|
630
|
-
const
|
|
631
|
-
const i = await $.the.get(
|
|
598
|
+
const a = r.map(async (n) => {
|
|
599
|
+
const i = await $.the.get(n);
|
|
632
600
|
if (i)
|
|
633
601
|
return i;
|
|
634
|
-
const { [
|
|
602
|
+
const { [n]: s } = t;
|
|
635
603
|
if (s)
|
|
636
604
|
return s;
|
|
637
605
|
if (!e)
|
|
@@ -640,35 +608,35 @@ async function G(r) {
|
|
|
640
608
|
} catch (o) {
|
|
641
609
|
console.error(`Failed to load premium package: ${o}`);
|
|
642
610
|
}
|
|
643
|
-
const { [
|
|
611
|
+
const { [n]: c } = e || {};
|
|
644
612
|
if (c)
|
|
645
613
|
return c;
|
|
646
|
-
throw new Error(`Plugin "${
|
|
614
|
+
throw new Error(`Plugin "${n}" not found in base or premium packages.`);
|
|
647
615
|
});
|
|
648
616
|
return {
|
|
649
|
-
loadedPlugins: await Promise.all(
|
|
617
|
+
loadedPlugins: await Promise.all(a),
|
|
650
618
|
hasPremium: !!e
|
|
651
619
|
};
|
|
652
620
|
}
|
|
653
|
-
async function
|
|
621
|
+
async function Y(r, t) {
|
|
654
622
|
const e = [r.ui, r.content];
|
|
655
623
|
return await Promise.all(
|
|
656
624
|
[
|
|
657
|
-
|
|
625
|
+
B("ckeditor5", e),
|
|
658
626
|
/* v8 ignore next */
|
|
659
|
-
t &&
|
|
660
|
-
].filter((
|
|
661
|
-
).then((
|
|
627
|
+
t && B("ckeditor5-premium-features", e)
|
|
628
|
+
].filter((n) => !!n)
|
|
629
|
+
).then((n) => n.flat());
|
|
662
630
|
}
|
|
663
|
-
async function
|
|
631
|
+
async function B(r, t) {
|
|
664
632
|
return await Promise.all(
|
|
665
633
|
t.filter((e) => e !== "en").map(async (e) => {
|
|
666
|
-
const
|
|
667
|
-
return
|
|
634
|
+
const a = await mt(r, e);
|
|
635
|
+
return a?.default ?? a;
|
|
668
636
|
}).filter(Boolean)
|
|
669
637
|
);
|
|
670
638
|
}
|
|
671
|
-
async function
|
|
639
|
+
async function mt(r, t) {
|
|
672
640
|
try {
|
|
673
641
|
if (r === "ckeditor5")
|
|
674
642
|
switch (t) {
|
|
@@ -968,20 +936,12 @@ async function kt(r, t) {
|
|
|
968
936
|
return console.error(`Failed to load translation for ${r}/${t}:`, e), null;
|
|
969
937
|
}
|
|
970
938
|
}
|
|
971
|
-
function
|
|
972
|
-
return
|
|
939
|
+
function J(r) {
|
|
940
|
+
return at(r, (t) => ({
|
|
973
941
|
dictionary: t
|
|
974
942
|
}));
|
|
975
943
|
}
|
|
976
|
-
function
|
|
977
|
-
const t = tt(r);
|
|
978
|
-
return j(t, ({ content: e }) => e);
|
|
979
|
-
}
|
|
980
|
-
function W(r) {
|
|
981
|
-
const t = tt(r), e = j(t, ({ initialValue: n }) => n);
|
|
982
|
-
return it(e, (n) => typeof n == "string");
|
|
983
|
-
}
|
|
984
|
-
function tt(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]`,
|
|
@@ -996,114 +956,114 @@ function tt(r) {
|
|
|
996
956
|
initialValue: l
|
|
997
957
|
}
|
|
998
958
|
};
|
|
999
|
-
}, /* @__PURE__ */ Object.create({})),
|
|
1000
|
-
if (!
|
|
959
|
+
}, /* @__PURE__ */ Object.create({})), a = document.querySelector(`[phx-hook="CKEditor5"][id="${r}"]`);
|
|
960
|
+
if (!a)
|
|
1001
961
|
return e;
|
|
1002
|
-
const
|
|
962
|
+
const n = a.getAttribute("data-cke-initial-value") || "", i = a.querySelector(`#${r}_editor `), s = e.main;
|
|
1003
963
|
return s ? {
|
|
1004
964
|
...e,
|
|
1005
965
|
main: {
|
|
1006
966
|
...s,
|
|
1007
|
-
initialValue: s.initialValue ||
|
|
967
|
+
initialValue: s.initialValue || n
|
|
1008
968
|
}
|
|
1009
969
|
} : i ? {
|
|
1010
970
|
...e,
|
|
1011
971
|
main: {
|
|
1012
972
|
content: i,
|
|
1013
|
-
initialValue:
|
|
973
|
+
initialValue: n
|
|
1014
974
|
}
|
|
1015
975
|
} : e;
|
|
1016
976
|
}
|
|
1017
|
-
const
|
|
1018
|
-
function
|
|
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
|
-
const { type: e, config:
|
|
1023
|
-
if (!e || !
|
|
982
|
+
const { type: e, config: a, license: n, watchdog: i, ...s } = JSON.parse(t);
|
|
983
|
+
if (!e || !a || !n)
|
|
1024
984
|
throw new Error('CKEditor5 hook configuration must include "editor", "config", and "license" properties.');
|
|
1025
|
-
if (!
|
|
1026
|
-
throw new Error(`Invalid editor type: ${e}. Must be one of: ${
|
|
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
|
-
license:
|
|
989
|
+
license: n,
|
|
1030
990
|
watchdog: i,
|
|
1031
|
-
config:
|
|
991
|
+
config: A(a),
|
|
1032
992
|
customTranslations: s.customTranslations || s.custom_translations
|
|
1033
993
|
};
|
|
1034
994
|
}
|
|
1035
|
-
function
|
|
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((
|
|
999
|
+
return r.map((a) => T(a));
|
|
1040
1000
|
const t = r;
|
|
1041
1001
|
if (t.$element && typeof t.$element == "string") {
|
|
1042
|
-
const
|
|
1043
|
-
return
|
|
1002
|
+
const a = document.querySelector(t.$element);
|
|
1003
|
+
return a || console.warn(`Element not found for selector: ${t.$element}`), a || null;
|
|
1044
1004
|
}
|
|
1045
1005
|
const e = /* @__PURE__ */ Object.create(null);
|
|
1046
|
-
for (const [
|
|
1047
|
-
e[
|
|
1006
|
+
for (const [a, n] of Object.entries(r))
|
|
1007
|
+
e[a] = T(n);
|
|
1048
1008
|
return e;
|
|
1049
1009
|
}
|
|
1050
|
-
function
|
|
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) =>
|
|
1055
|
-
const
|
|
1056
|
-
if (
|
|
1057
|
-
const i =
|
|
1014
|
+
return e.map((i) => I(r, t, i));
|
|
1015
|
+
const a = e;
|
|
1016
|
+
if (a.$translation && typeof a.$translation == "string") {
|
|
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
|
-
const
|
|
1020
|
+
const n = /* @__PURE__ */ Object.create(null);
|
|
1061
1021
|
for (const [i, s] of Object.entries(e))
|
|
1062
|
-
|
|
1063
|
-
return
|
|
1022
|
+
n[i] = I(r, t, s);
|
|
1023
|
+
return n;
|
|
1064
1024
|
}
|
|
1065
|
-
function
|
|
1066
|
-
for (const
|
|
1067
|
-
const
|
|
1068
|
-
if (
|
|
1069
|
-
return
|
|
1025
|
+
function ft(r, t, e) {
|
|
1026
|
+
for (const a of r) {
|
|
1027
|
+
const n = a[e];
|
|
1028
|
+
if (n?.dictionary && t in n.dictionary)
|
|
1029
|
+
return n.dictionary[t];
|
|
1070
1030
|
}
|
|
1071
1031
|
}
|
|
1072
|
-
function
|
|
1032
|
+
function wt(r, t) {
|
|
1073
1033
|
const { editing: e } = r;
|
|
1074
|
-
e.view.change((
|
|
1075
|
-
|
|
1034
|
+
e.view.change((a) => {
|
|
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
|
|
1080
|
-
const { EditorWatchdog: e } = await import("ckeditor5"),
|
|
1039
|
+
async function gt(r, t) {
|
|
1040
|
+
const { EditorWatchdog: e } = await import("ckeditor5"), a = new e(null, t ?? {
|
|
1081
1041
|
crashNumberLimit: 10,
|
|
1082
1042
|
minimumNonErrorTimePeriod: 5e3
|
|
1083
1043
|
});
|
|
1084
|
-
return
|
|
1085
|
-
const
|
|
1086
|
-
return
|
|
1087
|
-
}),
|
|
1044
|
+
return a.setCreator(async () => {
|
|
1045
|
+
const n = await r();
|
|
1046
|
+
return n[V] = a, n;
|
|
1047
|
+
}), a;
|
|
1088
1048
|
}
|
|
1089
|
-
function
|
|
1049
|
+
function yt(r) {
|
|
1090
1050
|
return V in r ? r[V] : null;
|
|
1091
1051
|
}
|
|
1092
|
-
class y extends
|
|
1052
|
+
class y extends W {
|
|
1093
1053
|
static the = new y();
|
|
1094
1054
|
}
|
|
1095
|
-
function
|
|
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
|
-
const { config: e, ...
|
|
1059
|
+
const { config: e, ...a } = JSON.parse(t);
|
|
1100
1060
|
return {
|
|
1101
|
-
config:
|
|
1102
|
-
customTranslations:
|
|
1103
|
-
watchdogConfig:
|
|
1061
|
+
config: A(e),
|
|
1062
|
+
customTranslations: a.customTranslations || a.custom_translations,
|
|
1063
|
+
watchdogConfig: a.watchdogConfig || a.watchdog_config
|
|
1104
1064
|
};
|
|
1105
1065
|
}
|
|
1106
|
-
class
|
|
1066
|
+
class kt extends x {
|
|
1107
1067
|
/**
|
|
1108
1068
|
* The promise that resolves to the context instance.
|
|
1109
1069
|
*/
|
|
@@ -1112,9 +1072,9 @@ class It extends S {
|
|
|
1112
1072
|
* Attributes for the context instance.
|
|
1113
1073
|
*/
|
|
1114
1074
|
get attrs() {
|
|
1115
|
-
const t = (
|
|
1075
|
+
const t = (a) => this.el.getAttribute(a) || null, e = {
|
|
1116
1076
|
id: this.el.id,
|
|
1117
|
-
config:
|
|
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 It extends S {
|
|
|
1131
1091
|
* Mounts the context component.
|
|
1132
1092
|
*/
|
|
1133
1093
|
async mounted() {
|
|
1134
|
-
const { id: t, language: e } = this.attrs, { customTranslations:
|
|
1135
|
-
...await
|
|
1136
|
-
|
|
1137
|
-
].filter((m) => !
|
|
1138
|
-
let d =
|
|
1139
|
-
d =
|
|
1140
|
-
const { ContextWatchdog: m, Context:
|
|
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
|
|
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
|
-
}),
|
|
1152
|
-
console.error("Context item error:", ...
|
|
1153
|
-
}),
|
|
1111
|
+
}), g.on("itemError", (...E) => {
|
|
1112
|
+
console.error("Context item error:", ...E);
|
|
1113
|
+
}), g;
|
|
1154
1114
|
})();
|
|
1155
|
-
const
|
|
1156
|
-
this.isBeingDestroyed() || y.the.register(t,
|
|
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,39 +1128,39 @@ class It extends S {
|
|
|
1168
1128
|
}
|
|
1169
1129
|
}
|
|
1170
1130
|
}
|
|
1171
|
-
function
|
|
1131
|
+
function Et(r) {
|
|
1172
1132
|
return r.hasAttribute("data-cke-context");
|
|
1173
1133
|
}
|
|
1174
|
-
function
|
|
1134
|
+
function vt(r) {
|
|
1175
1135
|
let t = r;
|
|
1176
1136
|
for (; t; ) {
|
|
1177
|
-
if (
|
|
1137
|
+
if (Et(t))
|
|
1178
1138
|
return t;
|
|
1179
1139
|
t = t.parentElement;
|
|
1180
1140
|
}
|
|
1181
1141
|
return null;
|
|
1182
1142
|
}
|
|
1183
|
-
async function
|
|
1184
|
-
const t =
|
|
1143
|
+
async function Ct(r) {
|
|
1144
|
+
const t = vt(r);
|
|
1185
1145
|
return t ? y.the.waitFor(t.id) : null;
|
|
1186
1146
|
}
|
|
1187
|
-
const
|
|
1188
|
-
function
|
|
1147
|
+
const Pt = O(kt);
|
|
1148
|
+
function At(r, t) {
|
|
1189
1149
|
const e = /* @__PURE__ */ new Set();
|
|
1190
|
-
return (
|
|
1191
|
-
let
|
|
1150
|
+
return (a) => {
|
|
1151
|
+
let n = !1;
|
|
1192
1152
|
return r.model.enqueueChange({ isUndoable: !1 }, (i) => {
|
|
1193
1153
|
const s = r.model.document.getRoot(t);
|
|
1194
1154
|
if (s) {
|
|
1195
1155
|
for (const c of e)
|
|
1196
|
-
|
|
1197
|
-
for (const [c, o] of Object.entries(
|
|
1198
|
-
i.setAttribute(c, o, s), e.add(c),
|
|
1156
|
+
a && c in a || (i.removeAttribute(c, s), e.delete(c), n = !0);
|
|
1157
|
+
for (const [c, o] of Object.entries(a ?? {}))
|
|
1158
|
+
i.setAttribute(c, o, s), e.add(c), n = !0;
|
|
1199
1159
|
}
|
|
1200
|
-
}),
|
|
1160
|
+
}), n;
|
|
1201
1161
|
};
|
|
1202
1162
|
}
|
|
1203
|
-
async function
|
|
1163
|
+
async function Tt() {
|
|
1204
1164
|
const { Plugin: r, FileRepository: t } = await import("ckeditor5");
|
|
1205
1165
|
return class extends r {
|
|
1206
1166
|
/**
|
|
@@ -1216,15 +1176,15 @@ async function Mt() {
|
|
|
1216
1176
|
* Initializes the plugin.
|
|
1217
1177
|
*/
|
|
1218
1178
|
init() {
|
|
1219
|
-
const { editor:
|
|
1220
|
-
if (!s ||
|
|
1179
|
+
const { editor: a } = this, { plugins: n, config: i } = a, s = i.get("phoenixUpload.url");
|
|
1180
|
+
if (!s || n.has("SimpleUploadAdapter") || n.has("Base64UploadAdapter") || n.has("CKFinderUploadAdapter"))
|
|
1221
1181
|
return;
|
|
1222
|
-
const c =
|
|
1223
|
-
c.createUploadAdapter = (o) => new
|
|
1182
|
+
const c = n.get(t);
|
|
1183
|
+
c.createUploadAdapter = (o) => new It(o, s);
|
|
1224
1184
|
}
|
|
1225
1185
|
};
|
|
1226
1186
|
}
|
|
1227
|
-
class
|
|
1187
|
+
class It {
|
|
1228
1188
|
loader;
|
|
1229
1189
|
uploadUrl;
|
|
1230
1190
|
abortController = null;
|
|
@@ -1239,12 +1199,12 @@ class Rt {
|
|
|
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
|
|
1243
|
-
|
|
1202
|
+
const a = {}, n = et();
|
|
1203
|
+
n && (a["X-CSRF-Token"] = n);
|
|
1244
1204
|
try {
|
|
1245
1205
|
const i = await fetch(this.uploadUrl, {
|
|
1246
1206
|
method: "POST",
|
|
1247
|
-
headers:
|
|
1207
|
+
headers: a,
|
|
1248
1208
|
body: e,
|
|
1249
1209
|
signal: this.abortController.signal
|
|
1250
1210
|
});
|
|
@@ -1272,7 +1232,7 @@ class Rt {
|
|
|
1272
1232
|
this.abortController?.abort(), this.abortController = null;
|
|
1273
1233
|
}
|
|
1274
1234
|
}
|
|
1275
|
-
async function
|
|
1235
|
+
async function xt({
|
|
1276
1236
|
editorId: r,
|
|
1277
1237
|
saveDebounceMs: t
|
|
1278
1238
|
}) {
|
|
@@ -1296,15 +1256,15 @@ async function Vt({
|
|
|
1296
1256
|
* Initializes the plugin.
|
|
1297
1257
|
*/
|
|
1298
1258
|
afterInit() {
|
|
1299
|
-
const { editor:
|
|
1300
|
-
this.input = document.getElementById(`${r}_input`), this.input && (
|
|
1259
|
+
const { editor: n } = this;
|
|
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.
|
|
1304
1264
|
*/
|
|
1305
1265
|
sync = () => {
|
|
1306
|
-
const
|
|
1307
|
-
this.input.value =
|
|
1266
|
+
const n = this.editor.getData();
|
|
1267
|
+
this.input.value = n, this.input.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
1308
1268
|
};
|
|
1309
1269
|
/**
|
|
1310
1270
|
* Destroys the plugin.
|
|
@@ -1315,8 +1275,8 @@ async function Vt({
|
|
|
1315
1275
|
};
|
|
1316
1276
|
}
|
|
1317
1277
|
const U = /* @__PURE__ */ Symbol("suppress-phoenix-sync");
|
|
1318
|
-
async function
|
|
1319
|
-
const { Plugin: t } = await import("ckeditor5"), { editorId: e, saveDebounceMs:
|
|
1278
|
+
async function Ot(r) {
|
|
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
|
/**
|
|
1322
1282
|
* The name of the plugin.
|
|
@@ -1329,13 +1289,13 @@ async function Ut(r) {
|
|
|
1329
1289
|
*/
|
|
1330
1290
|
init() {
|
|
1331
1291
|
const { editor: o } = this;
|
|
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:
|
|
1295
|
+
data: S(o)
|
|
1336
1296
|
});
|
|
1337
1297
|
}), s("ckeditor5:set-data", ({ editorId: u, data: l }) => {
|
|
1338
|
-
(
|
|
1298
|
+
(rt(u) || u === e) && o.setData(l);
|
|
1339
1299
|
});
|
|
1340
1300
|
}
|
|
1341
1301
|
/**
|
|
@@ -1347,21 +1307,21 @@ async function Ut(r) {
|
|
|
1347
1307
|
const d = () => {
|
|
1348
1308
|
if (l)
|
|
1349
1309
|
return;
|
|
1350
|
-
const m =
|
|
1351
|
-
(!u || !
|
|
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
|
-
},
|
|
1359
|
-
o.model.document.on("change:data",
|
|
1360
|
-
if (
|
|
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 ?
|
|
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 Ut(r) {
|
|
|
1376
1336
|
`ckeditor5:${o}`,
|
|
1377
1337
|
{
|
|
1378
1338
|
editorId: e,
|
|
1379
|
-
data:
|
|
1339
|
+
data: S(u)
|
|
1380
1340
|
}
|
|
1381
1341
|
);
|
|
1382
1342
|
};
|
|
@@ -1384,23 +1344,23 @@ async function Ut(r) {
|
|
|
1384
1344
|
}
|
|
1385
1345
|
};
|
|
1386
1346
|
}
|
|
1387
|
-
function
|
|
1388
|
-
return r.model.document.getRootNames().reduce((e,
|
|
1347
|
+
function S(r) {
|
|
1348
|
+
return r.model.document.getRootNames().reduce((e, a) => (e[a] = r.getData({ rootName: a }), e), /* @__PURE__ */ Object.create({}));
|
|
1389
1349
|
}
|
|
1390
|
-
function
|
|
1350
|
+
function Dt(r) {
|
|
1391
1351
|
const t = r[U];
|
|
1392
1352
|
return delete r[U], !!t;
|
|
1393
1353
|
}
|
|
1394
|
-
function
|
|
1354
|
+
function Nt(r) {
|
|
1395
1355
|
let t = !1;
|
|
1396
|
-
const e = (
|
|
1397
|
-
t || (
|
|
1356
|
+
const e = (a) => {
|
|
1357
|
+
t || (a[U] = !0);
|
|
1398
1358
|
};
|
|
1399
1359
|
return r.model.document.once("change:data", e, { priority: "highest" }), () => {
|
|
1400
1360
|
t = !0, r.model.document.off("change:data", e);
|
|
1401
1361
|
};
|
|
1402
1362
|
}
|
|
1403
|
-
class
|
|
1363
|
+
class X {
|
|
1404
1364
|
/**
|
|
1405
1365
|
* The DOM element being observed for attribute changes.
|
|
1406
1366
|
*/
|
|
@@ -1455,11 +1415,11 @@ class et {
|
|
|
1455
1415
|
constructor({
|
|
1456
1416
|
el: t,
|
|
1457
1417
|
editor: e,
|
|
1458
|
-
rootName:
|
|
1459
|
-
valueAttrName:
|
|
1418
|
+
rootName: a,
|
|
1419
|
+
valueAttrName: n = "data-cke-value",
|
|
1460
1420
|
rootAttrsAttrName: i = "data-cke-root-attrs"
|
|
1461
1421
|
}) {
|
|
1462
|
-
this.el = t, this.editor = e, this.rootName =
|
|
1422
|
+
this.el = t, this.editor = e, this.rootName = a, this.valueAttrName = n, this.rootAttrsAttrName = i;
|
|
1463
1423
|
const { value: s } = this.attrs;
|
|
1464
1424
|
this.previousValue = s, this.setupSyncHandlers(e, this.rootName);
|
|
1465
1425
|
}
|
|
@@ -1469,7 +1429,7 @@ class et {
|
|
|
1469
1429
|
*/
|
|
1470
1430
|
get attrs() {
|
|
1471
1431
|
return {
|
|
1472
|
-
rootAttributes:
|
|
1432
|
+
rootAttributes: nt(this.el.getAttribute(this.rootAttrsAttrName)),
|
|
1473
1433
|
value: this.el.getAttribute(this.valueAttrName)
|
|
1474
1434
|
};
|
|
1475
1435
|
}
|
|
@@ -1478,36 +1438,36 @@ class et {
|
|
|
1478
1438
|
* However, if the editor is focused, we want to wait until it blurs to avoid disrupting the user while typing.
|
|
1479
1439
|
*/
|
|
1480
1440
|
async updated() {
|
|
1481
|
-
const { editor: t } = this, { value: e, rootAttributes:
|
|
1441
|
+
const { editor: t } = this, { value: e, rootAttributes: a } = this.attrs;
|
|
1482
1442
|
if (!t || t.state === "destroyed" || this.isDestroyed)
|
|
1483
1443
|
return;
|
|
1484
|
-
let
|
|
1444
|
+
let n = () => {
|
|
1485
1445
|
};
|
|
1486
1446
|
t.model.enqueueChange({ isUndoable: !1 }, () => {
|
|
1487
|
-
let i = this.attrsUpdater?.(
|
|
1488
|
-
e !== this.previousValue && (this.previousValue = e, t.ui.focusTracker.isFocused ? this.pendingValue = e : (this.setRootValue(t, this.rootName, e), i = !0)), i && (
|
|
1489
|
-
}),
|
|
1447
|
+
let i = this.attrsUpdater?.(a);
|
|
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));
|
|
1449
|
+
}), n();
|
|
1490
1450
|
}
|
|
1491
1451
|
/**
|
|
1492
1452
|
* Sets up focus-aware sync handlers on the editor.
|
|
1493
1453
|
* Registers cleanup via onBeforeDestroy.
|
|
1494
1454
|
*/
|
|
1495
1455
|
setupSyncHandlers(t, e) {
|
|
1496
|
-
this.attrsUpdater =
|
|
1497
|
-
const
|
|
1456
|
+
this.attrsUpdater = At(t, e), this.attrsUpdater(this.attrs.rootAttributes);
|
|
1457
|
+
const a = () => {
|
|
1498
1458
|
this.pendingValue = null;
|
|
1499
|
-
},
|
|
1459
|
+
}, n = () => {
|
|
1500
1460
|
!t.ui.focusTracker.isFocused && this.pendingValue !== null && (this.setRootValue(t, e, this.pendingValue), this.pendingValue = null);
|
|
1501
1461
|
};
|
|
1502
|
-
t.model.document.on("change:data",
|
|
1503
|
-
t.model.document.off("change:data",
|
|
1462
|
+
t.model.document.on("change:data", a), t.ui.focusTracker.on("change:isFocused", n), this.cleanupCallbacks.push(() => {
|
|
1463
|
+
t.model.document.off("change:data", a), t.ui.focusTracker.off("change:isFocused", n);
|
|
1504
1464
|
});
|
|
1505
1465
|
}
|
|
1506
1466
|
/**
|
|
1507
1467
|
* Sets the value of a specific root in the editor.
|
|
1508
1468
|
*/
|
|
1509
|
-
setRootValue(t, e,
|
|
1510
|
-
t.getData({ rootName: e }) !==
|
|
1469
|
+
setRootValue(t, e, a) {
|
|
1470
|
+
t.getData({ rootName: e }) !== a && t.setData({ [e]: a });
|
|
1511
1471
|
}
|
|
1512
1472
|
/**
|
|
1513
1473
|
* Disconnects the observer and cleans up editor event listeners.
|
|
@@ -1517,10 +1477,10 @@ class et {
|
|
|
1517
1477
|
this.isDestroyed = !0, this.cleanupCallbacks.forEach((t) => t()), this.cleanupCallbacks = [];
|
|
1518
1478
|
}
|
|
1519
1479
|
}
|
|
1520
|
-
class h extends
|
|
1480
|
+
class h extends W {
|
|
1521
1481
|
static the = new h();
|
|
1522
1482
|
}
|
|
1523
|
-
class
|
|
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.
|
|
@@ -1530,30 +1490,30 @@ class _t extends S {
|
|
|
1530
1490
|
* Attributes for the editor instance.
|
|
1531
1491
|
*/
|
|
1532
1492
|
get attrs() {
|
|
1533
|
-
const { el: t } = this, e = t.getAttribute.bind(t),
|
|
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:
|
|
1537
|
-
editableHeight:
|
|
1538
|
-
watchdog:
|
|
1496
|
+
preset: pt(t),
|
|
1497
|
+
editableHeight: H(e("data-cke-editable-height")),
|
|
1498
|
+
watchdog: a("data-cke-watchdog"),
|
|
1539
1499
|
events: {
|
|
1540
|
-
change:
|
|
1541
|
-
blur:
|
|
1542
|
-
focus:
|
|
1543
|
-
ready:
|
|
1500
|
+
change: a("data-cke-change-event"),
|
|
1501
|
+
blur: a("data-cke-blur-event"),
|
|
1502
|
+
focus: a("data-cke-focus-event"),
|
|
1503
|
+
ready: a("data-cke-ready-event")
|
|
1544
1504
|
},
|
|
1545
|
-
saveDebounceMs:
|
|
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"
|
|
1549
1509
|
}
|
|
1550
1510
|
};
|
|
1551
1511
|
return Object.defineProperty(this, "attrs", {
|
|
1552
|
-
value:
|
|
1512
|
+
value: n,
|
|
1553
1513
|
writable: !1,
|
|
1554
1514
|
configurable: !1,
|
|
1555
1515
|
enumerable: !0
|
|
1556
|
-
}),
|
|
1516
|
+
}), n;
|
|
1557
1517
|
}
|
|
1558
1518
|
/**
|
|
1559
1519
|
* Mounts the editor component.
|
|
@@ -1565,10 +1525,10 @@ class _t extends S {
|
|
|
1565
1525
|
const e = await this.createEditor();
|
|
1566
1526
|
if (this.isBeingDestroyed())
|
|
1567
1527
|
return;
|
|
1568
|
-
const
|
|
1528
|
+
const a = h.the.mountEffect(t, (n) => (n.once("destroy", () => {
|
|
1569
1529
|
h.the.unregister(t, !1);
|
|
1570
|
-
}, { priority: "highest" }), this.sentinel = new
|
|
1571
|
-
editor:
|
|
1530
|
+
}, { priority: "highest" }), this.sentinel = new X({
|
|
1531
|
+
editor: n,
|
|
1572
1532
|
el: this.el,
|
|
1573
1533
|
rootName: "main",
|
|
1574
1534
|
valueAttrName: "data-cke-initial-value",
|
|
@@ -1577,9 +1537,9 @@ class _t extends S {
|
|
|
1577
1537
|
this.sentinel?.destroy(), this.sentinel = null;
|
|
1578
1538
|
}));
|
|
1579
1539
|
this.onBeforeDestroy(async () => {
|
|
1580
|
-
h.the.unregister(t),
|
|
1581
|
-
const
|
|
1582
|
-
|
|
1540
|
+
h.the.unregister(t), a();
|
|
1541
|
+
const n = dt(e), i = yt(e);
|
|
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) {
|
|
1585
1545
|
console.error(e), h.the.error(t, e);
|
|
@@ -1605,22 +1565,22 @@ class _t extends S {
|
|
|
1605
1565
|
const {
|
|
1606
1566
|
preset: t,
|
|
1607
1567
|
editorId: e,
|
|
1608
|
-
contextId:
|
|
1609
|
-
editableHeight:
|
|
1568
|
+
contextId: a,
|
|
1569
|
+
editableHeight: n,
|
|
1610
1570
|
events: i,
|
|
1611
1571
|
saveDebounceMs: s,
|
|
1612
1572
|
language: c,
|
|
1613
1573
|
watchdog: o
|
|
1614
|
-
} = this.attrs, { customTranslations: u, type: l, license: d, config: { plugins:
|
|
1615
|
-
const { loadedPlugins: p, hasPremium:
|
|
1616
|
-
|
|
1617
|
-
await
|
|
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
1581
|
), p.push(
|
|
1622
1582
|
...await Promise.all([
|
|
1623
|
-
|
|
1583
|
+
Ot(
|
|
1624
1584
|
{
|
|
1625
1585
|
editorId: e,
|
|
1626
1586
|
saveDebounceMs: s,
|
|
@@ -1629,74 +1589,69 @@ class _t extends S {
|
|
|
1629
1589
|
handleEvent: this.handleEvent.bind(this)
|
|
1630
1590
|
}
|
|
1631
1591
|
),
|
|
1632
|
-
|
|
1592
|
+
Tt()
|
|
1633
1593
|
])
|
|
1634
1594
|
);
|
|
1635
|
-
const
|
|
1636
|
-
...await
|
|
1637
|
-
|
|
1638
|
-
].filter((
|
|
1639
|
-
let
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
rt(f, C) || (f = await zt(e, C), v = W(e));
|
|
1645
|
-
}
|
|
1646
|
-
T(l) && "main" in f && (f = f.main);
|
|
1647
|
-
let w = { ...m };
|
|
1648
|
-
w = x(w), w = D([...k].reverse(), c.ui, w), w = pt(E, f, w), w = ht(v, w);
|
|
1649
|
-
const z = {
|
|
1650
|
-
...w,
|
|
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 = {
|
|
1603
|
+
...m,
|
|
1651
1604
|
licenseKey: d.key,
|
|
1652
1605
|
plugins: p,
|
|
1653
1606
|
language: c,
|
|
1654
|
-
...
|
|
1655
|
-
translations:
|
|
1607
|
+
...b.length && {
|
|
1608
|
+
translations: b
|
|
1656
1609
|
}
|
|
1657
|
-
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1610
|
+
};
|
|
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 && !
|
|
1665
|
-
const p = await
|
|
1666
|
-
return p.on("error", (
|
|
1667
|
-
if (
|
|
1668
|
-
const
|
|
1669
|
-
|
|
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
1626
|
}), p.on("restart", () => {
|
|
1672
|
-
const
|
|
1673
|
-
h.the.register(e,
|
|
1627
|
+
const v = p.editor;
|
|
1628
|
+
h.the.register(e, v);
|
|
1674
1629
|
}), await p.create({}), p.editor;
|
|
1675
1630
|
}
|
|
1676
|
-
return
|
|
1631
|
+
return E();
|
|
1677
1632
|
}
|
|
1678
1633
|
}
|
|
1679
|
-
function
|
|
1634
|
+
function Q(r, t) {
|
|
1680
1635
|
return t.every((e) => r[e]);
|
|
1681
1636
|
}
|
|
1682
|
-
async function
|
|
1683
|
-
return
|
|
1637
|
+
async function Rt(r, t) {
|
|
1638
|
+
return ot(
|
|
1684
1639
|
() => {
|
|
1685
|
-
const e =
|
|
1686
|
-
if (!
|
|
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.
|
|
1690
1645
|
* If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
|
|
1691
|
-
Missing roots: ${t.filter((
|
|
1646
|
+
Missing roots: ${t.filter((a) => !e[a]).join(", ")}.`
|
|
1692
1647
|
);
|
|
1693
1648
|
return e;
|
|
1694
1649
|
},
|
|
1695
1650
|
{ timeOutAfter: 2e3, retryAfter: 100 }
|
|
1696
1651
|
);
|
|
1697
1652
|
}
|
|
1698
|
-
const
|
|
1699
|
-
class
|
|
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
|
*/
|
|
@@ -1722,32 +1677,32 @@ class qt extends S {
|
|
|
1722
1677
|
* Mounts the editable component.
|
|
1723
1678
|
*/
|
|
1724
1679
|
mounted() {
|
|
1725
|
-
const { editableId: t, editorId: e, rootName:
|
|
1680
|
+
const { editableId: t, editorId: e, rootName: a, initialValue: n } = this.attrs, i = h.the.mountEffect(e, (s) => {
|
|
1726
1681
|
const c = this.el.querySelector("[data-cke-editable-content]");
|
|
1727
1682
|
if (this.isBeingDestroyed())
|
|
1728
1683
|
return;
|
|
1729
1684
|
const o = this.el.querySelector(`#${t}_input`);
|
|
1730
|
-
if (
|
|
1685
|
+
if (q(s) && !s.model.document.getRoot(a)) {
|
|
1731
1686
|
const { ui: l, editing: d } = s;
|
|
1732
|
-
s.addRoot(
|
|
1687
|
+
s.addRoot(a, {
|
|
1733
1688
|
isUndoable: !1,
|
|
1734
|
-
initialData:
|
|
1689
|
+
initialData: n
|
|
1735
1690
|
});
|
|
1736
|
-
const
|
|
1737
|
-
l.addEditable(
|
|
1691
|
+
const f = l.view.createEditable(a, c);
|
|
1692
|
+
l.addEditable(f), d.view.forceRender();
|
|
1738
1693
|
}
|
|
1739
|
-
this.sentinel = new
|
|
1694
|
+
this.sentinel = new X({
|
|
1740
1695
|
el: this.el,
|
|
1741
1696
|
editor: s,
|
|
1742
|
-
rootName:
|
|
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 ?
|
|
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
|
-
const l = s.model.document.getRoot(
|
|
1750
|
-
l &&
|
|
1704
|
+
const l = s.model.document.getRoot(a);
|
|
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 qt extends S {
|
|
|
1762
1717
|
this.sentinel?.updated();
|
|
1763
1718
|
}
|
|
1764
1719
|
}
|
|
1765
|
-
const
|
|
1766
|
-
function
|
|
1767
|
-
const
|
|
1720
|
+
const $t = O(Ut);
|
|
1721
|
+
function Mt(r, t, e) {
|
|
1722
|
+
const a = () => {
|
|
1768
1723
|
r.value = t.getData({ rootName: e });
|
|
1769
|
-
},
|
|
1770
|
-
return t.model.document.on("change:data",
|
|
1771
|
-
t.model.document.off("change:data",
|
|
1724
|
+
}, n = P(200, a);
|
|
1725
|
+
return t.model.document.on("change:data", n), a(), () => {
|
|
1726
|
+
t.model.document.off("change:data", n);
|
|
1772
1727
|
};
|
|
1773
1728
|
}
|
|
1774
|
-
class
|
|
1729
|
+
class _t extends x {
|
|
1775
1730
|
/**
|
|
1776
1731
|
* Attributes for the editable instance.
|
|
1777
1732
|
*/
|
|
@@ -1791,10 +1746,10 @@ class Lt extends S {
|
|
|
1791
1746
|
* Mounts the UI part component.
|
|
1792
1747
|
*/
|
|
1793
1748
|
mounted() {
|
|
1794
|
-
const { editorId: t, name: e } = this.attrs,
|
|
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 } =
|
|
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;
|
|
@@ -1804,11 +1759,11 @@ class Lt extends S {
|
|
|
1804
1759
|
};
|
|
1805
1760
|
});
|
|
1806
1761
|
this.onBeforeDestroy(() => {
|
|
1807
|
-
this.el.style.display = "none",
|
|
1762
|
+
this.el.style.display = "none", a();
|
|
1808
1763
|
});
|
|
1809
1764
|
}
|
|
1810
1765
|
}
|
|
1811
|
-
function
|
|
1766
|
+
function zt(r) {
|
|
1812
1767
|
switch (r) {
|
|
1813
1768
|
case "toolbar":
|
|
1814
1769
|
return "toolbar";
|
|
@@ -1818,18 +1773,18 @@ function Wt(r) {
|
|
|
1818
1773
|
return null;
|
|
1819
1774
|
}
|
|
1820
1775
|
}
|
|
1821
|
-
const
|
|
1822
|
-
CKEditor5:
|
|
1823
|
-
CKEditable:
|
|
1824
|
-
CKUIPart:
|
|
1825
|
-
CKContext:
|
|
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
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1786
|
+
Ft as Hooks,
|
|
1787
|
+
dt as unwrapEditorContext,
|
|
1788
|
+
yt as unwrapEditorWatchdog
|
|
1834
1789
|
};
|
|
1835
1790
|
//# sourceMappingURL=index.mjs.map
|