ckeditor5-blazor 1.9.1 → 1.10.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/elements/editable.d.ts +3 -11
- package/dist/elements/editable.d.ts.map +1 -1
- package/dist/elements/editor/editor.d.ts.map +1 -1
- package/dist/elements/editor/typings.d.ts +2 -1
- package/dist/elements/editor/typings.d.ts.map +1 -1
- package/dist/elements/editor/utils/cleanup-orphan-editor-elements.d.ts +8 -0
- package/dist/elements/editor/utils/cleanup-orphan-editor-elements.d.ts.map +1 -0
- package/dist/elements/editor/utils/create-editor-in-context.d.ts +6 -1
- package/dist/elements/editor/utils/create-editor-in-context.d.ts.map +1 -1
- package/dist/elements/editor/utils/index.d.ts +1 -0
- package/dist/elements/editor/utils/index.d.ts.map +1 -1
- package/dist/elements/editor/utils/wrap-with-watchdog.d.ts +7 -16
- package/dist/elements/editor/utils/wrap-with-watchdog.d.ts.map +1 -1
- package/dist/elements/ui-part.d.ts +3 -3
- package/dist/elements/ui-part.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +460 -396
- package/dist/index.mjs.map +1 -1
- package/dist/interop/create-editable-blazor-interop.d.ts.map +1 -1
- package/dist/interop/create-editor-blazor-interop.d.ts.map +1 -1
- package/dist/shared/are-maps-equal.d.ts +11 -0
- package/dist/shared/are-maps-equal.d.ts.map +1 -0
- package/dist/shared/async-registry.d.ts +44 -16
- package/dist/shared/async-registry.d.ts.map +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/elements/editable.ts +38 -58
- package/src/elements/editor/editor.ts +122 -101
- package/src/elements/editor/typings.ts +3 -1
- package/src/elements/editor/utils/cleanup-orphan-editor-elements.test.ts +285 -0
- package/src/elements/editor/utils/cleanup-orphan-editor-elements.ts +60 -0
- package/src/elements/editor/utils/create-editor-in-context.ts +8 -2
- package/src/elements/editor/utils/index.ts +1 -0
- package/src/elements/editor/utils/wrap-with-watchdog.test.ts +34 -14
- package/src/elements/editor/utils/wrap-with-watchdog.ts +15 -25
- package/src/elements/ui-part.test.ts +1 -1
- package/src/elements/ui-part.ts +12 -11
- package/src/interop/create-editable-blazor-interop.ts +19 -16
- package/src/interop/create-editor-blazor-interop.ts +18 -21
- package/src/shared/are-maps-equal.test.ts +56 -0
- package/src/shared/are-maps-equal.ts +22 -0
- package/src/shared/async-registry.test.ts +190 -88
- package/src/shared/async-registry.ts +179 -107
- package/src/shared/index.ts +1 -0
|
@@ -3,21 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare class EditableComponentElement extends HTMLElement {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Stops observing the editor registry and immediately runs any pending cleanup.
|
|
7
7
|
*/
|
|
8
|
-
private
|
|
8
|
+
private unmountEffect;
|
|
9
9
|
/**
|
|
10
10
|
* Wait result for the interactive attribute.
|
|
11
11
|
*/
|
|
12
12
|
private interactiveWait?;
|
|
13
|
-
/**
|
|
14
|
-
* Callbacks to be invoked before the editable is destroyed.
|
|
15
|
-
*/
|
|
16
|
-
private beforeDestroyCallbacks;
|
|
17
|
-
/**
|
|
18
|
-
* Registers a callback to be called before the editable is destroyed.
|
|
19
|
-
*/
|
|
20
|
-
onBeforeDestroy(callback: () => void): void;
|
|
21
13
|
/**
|
|
22
14
|
* Mounts the editable component.
|
|
23
15
|
*/
|
|
@@ -29,6 +21,6 @@ export declare class EditableComponentElement extends HTMLElement {
|
|
|
29
21
|
/**
|
|
30
22
|
* Destroys the editable component. Unmounts root from the editor.
|
|
31
23
|
*/
|
|
32
|
-
disconnectedCallback():
|
|
24
|
+
disconnectedCallback(): void;
|
|
33
25
|
}
|
|
34
26
|
//# sourceMappingURL=editable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editable.d.ts","sourceRoot":"","sources":["../../../src/elements/editable.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,WAAW;IACvD;;OAEG;IACH,OAAO,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"editable.d.ts","sourceRoot":"","sources":["../../../src/elements/editable.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,WAAW;IACvD;;OAEG;IACH,OAAO,CAAC,aAAa,CAA6B;IAElD;;OAEG;IACH,OAAO,CAAC,eAAe,CAAC,CAA2B;IAEnD;;OAEG;IACG,iBAAiB;IAQvB;;OAEG;YACW,kBAAkB;IA0HhC;;OAEG;IACH,oBAAoB;CAWrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../../src/elements/editor/editor.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACrD;;OAEG;IACH,OAAO,CAAC,aAAa,CAAgC;IAErD;;OAEG;IACH,OAAO,CAAC,eAAe,CAAC,CAA2B;IAEnD;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBxC;;OAEG;YACW,gBAAgB;IAiC9B;;;OAGG;IACG,oBAAoB;IAsC1B;;OAEG;YACW,YAAY;
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../../src/elements/editor/editor.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACrD;;OAEG;IACH,OAAO,CAAC,aAAa,CAAgC;IAErD;;OAEG;IACH,OAAO,CAAC,eAAe,CAAC,CAA2B;IAEnD;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBxC;;OAEG;YACW,gBAAgB;IAiC9B;;;OAGG;IACG,oBAAoB;IAsC1B;;OAEG;YACW,YAAY;CAuK3B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WatchdogConfig } from 'ckeditor5';
|
|
1
2
|
/**
|
|
2
3
|
* Represents a unique identifier for a CKEditor5 editor instance.
|
|
3
4
|
* This is typically the ID of the HTML element that the editor is attached to.
|
|
@@ -86,7 +87,7 @@ export type EditorPreset = {
|
|
|
86
87
|
/**
|
|
87
88
|
* Optional watchdog configuration for error recovery.
|
|
88
89
|
*/
|
|
89
|
-
watchdogConfig?:
|
|
90
|
+
watchdogConfig?: WatchdogConfig | null;
|
|
90
91
|
/**
|
|
91
92
|
* Optional custom translations for the editor.
|
|
92
93
|
* This allows for localization of the editor interface.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typings.d.ts","sourceRoot":"","sources":["../../../../src/elements/editor/typings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;AAEtF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,kBAAkB,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,OAAO,EAAE,YAAY,EAAE,CAAC;IAExB;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB,GAAG,IAAI,CAAC;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAEhC;;;OAGG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;;OAGG;IACH,MAAM,EAAE,YAAY,CAAC;IAErB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,cAAc,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"typings.d.ts","sourceRoot":"","sources":["../../../../src/elements/editor/typings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;AAEtF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,kBAAkB,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,OAAO,EAAE,YAAY,EAAE,CAAC;IAExB;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB,GAAG,IAAI,CAAC;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAEhC;;;OAGG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;;OAGG;IACH,MAAM,EAAE,YAAY,CAAC;IAErB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAEvC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,kCAAkC,GAAG,IAAI,CAAC;CAChE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,CAAC,QAAQ,EAAE,MAAM,GAAG;QAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;KAC/C,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Editor } from 'ckeditor5';
|
|
2
|
+
/**
|
|
3
|
+
* Removes all DOM elements injected by a specific CKEditor instance.
|
|
4
|
+
* Call this before assigning a new instance (e.g. in the 'restart' watchdog handler),
|
|
5
|
+
* because the watchdog does not clean up the previous editor's DOM on its own.
|
|
6
|
+
*/
|
|
7
|
+
export declare function cleanupOrphanEditorElements(editor: Editor): void;
|
|
8
|
+
//# sourceMappingURL=cleanup-orphan-editor-elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup-orphan-editor-elements.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/cleanup-orphan-editor-elements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAoDhE"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { EditorCreator } from './wrap-with-watchdog';
|
|
2
1
|
import { Context, ContextWatchdog, Editor, EditorConfig } from 'ckeditor5';
|
|
3
2
|
/**
|
|
4
3
|
* Creates a CKEditor 5 editor instance within a given context watchdog.
|
|
@@ -40,5 +39,11 @@ type EditorContextDescriptor = {
|
|
|
40
39
|
editorContextId: string;
|
|
41
40
|
context: ContextWatchdog<Context>;
|
|
42
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Type representing an Editor creator with a create method.
|
|
44
|
+
*/
|
|
45
|
+
type EditorCreator = {
|
|
46
|
+
create: (...args: any) => Promise<Editor>;
|
|
47
|
+
};
|
|
43
48
|
export {};
|
|
44
49
|
//# sourceMappingURL=create-editor-in-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-editor-in-context.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/create-editor-in-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"create-editor-in-context.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/create-editor-in-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAUhF;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK;;WAgE/E,WAAW,GAAG,aAAa;qBACjB,MAAM;aACd,eAAe,CAAC,OAAO,CAAC;GAhClC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI,CAMlF;AAED;;GAEG;AACH,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,WAAW,GAAG,aAAa,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import { Editor, EditorWatchdog } from 'ckeditor5';
|
|
1
|
+
import { Editor, EditorWatchdog, WatchdogConfig } from 'ckeditor5';
|
|
2
2
|
/**
|
|
3
|
-
* Wraps an
|
|
3
|
+
* Wraps an editor factory with a watchdog for automatic recovery.
|
|
4
|
+
* The factory is invoked on each (re)start, so configuration is rebuilt every time.
|
|
4
5
|
*
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
6
|
+
* @param factory Async function that creates and returns an Editor instance.
|
|
7
|
+
* @param watchdogConfig Configuration of the watchdog.
|
|
8
|
+
* @returns The watchdog instance.
|
|
7
9
|
*/
|
|
8
|
-
export declare function wrapWithWatchdog(
|
|
9
|
-
watchdog: EditorWatchdog<Editor>;
|
|
10
|
-
Constructor: {
|
|
11
|
-
create: (...args: Parameters<(typeof Editor)["create"]>) => Promise<Editor>;
|
|
12
|
-
};
|
|
13
|
-
}>;
|
|
10
|
+
export declare function wrapWithWatchdog(factory: () => Promise<Editor>, watchdogConfig?: WatchdogConfig | null): Promise<EditorWatchdog<Editor>>;
|
|
14
11
|
/**
|
|
15
12
|
* Unwraps the EditorWatchdog from the editor instance.
|
|
16
13
|
*/
|
|
17
14
|
export declare function unwrapEditorWatchdog(editor: Editor): EditorWatchdog | null;
|
|
18
|
-
/**
|
|
19
|
-
* Type representing an Editor creator with a create method.
|
|
20
|
-
*/
|
|
21
|
-
export type EditorCreator = {
|
|
22
|
-
create: (...args: any) => Promise<Editor>;
|
|
23
|
-
};
|
|
24
15
|
//# sourceMappingURL=wrap-with-watchdog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-with-watchdog.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/wrap-with-watchdog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"wrap-with-watchdog.d.ts","sourceRoot":"","sources":["../../../../../src/elements/editor/utils/wrap-with-watchdog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIxE;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,mCAiB5G;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAM1E"}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare class UIPartComponentElement extends HTMLElement {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Stops observing the editor registry and immediately runs any pending cleanup.
|
|
7
7
|
*/
|
|
8
|
-
private
|
|
8
|
+
private unmountEffect;
|
|
9
9
|
/**
|
|
10
10
|
* Mounts the UI part component.
|
|
11
11
|
*/
|
|
@@ -13,6 +13,6 @@ export declare class UIPartComponentElement extends HTMLElement {
|
|
|
13
13
|
/**
|
|
14
14
|
* Destroys the UI part component. Unmounts UI parts from the editor.
|
|
15
15
|
*/
|
|
16
|
-
disconnectedCallback():
|
|
16
|
+
disconnectedCallback(): void;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=ui-part.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-part.d.ts","sourceRoot":"","sources":["../../../src/elements/ui-part.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACrD;;OAEG;IACH,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"ui-part.d.ts","sourceRoot":"","sources":["../../../src/elements/ui-part.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACrD;;OAEG;IACH,OAAO,CAAC,aAAa,CAA6B;IAElD;;OAEG;IACG,iBAAiB;IAoCvB;;OAEG;IACH,oBAAoB;CAQrB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var ut=Object.create;var B=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var mt=Object.getPrototypeOf,ht=Object.prototype.hasOwnProperty;var pt=(i,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of dt(t))!ht.call(i,n)&&n!==e&&B(i,n,{get:()=>t[n],enumerable:!(a=lt(t,n))||a.enumerable});return i};var r=(i,t,e)=>(e=i!=null?ut(mt(i)):{},pt(t||!i||!i.__esModule?B(e,"default",{value:i,enumerable:!0}):e,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class b extends Error{constructor(t){super(t),this.name="CKEditor5BlazorError"}}class H{items=new Map;initializationErrors=new Map;pendingCallbacks=new Map;watchers=new Set;execute(t,e,a){const n=this.items.get(t),o=this.initializationErrors.get(t);return o?(a?.(o),Promise.reject(o)):n?Promise.resolve(e(n)):new Promise((s,c)=>{const l=this.getPendingCallbacks(t);l.success.push(async m=>{s(await e(m))}),a?l.error.push(a):l.error.push(c)})}register(t,e){if(this.items.has(t))throw new Error(`Item with ID "${t}" is already registered.`);this.resetErrors(t),this.items.set(t,e);const a=this.pendingCallbacks.get(t);a&&(a.success.forEach(n=>n(e)),this.pendingCallbacks.delete(t)),this.registerAsDefault(t,e),this.notifyWatchers()}error(t,e){this.items.delete(t),this.initializationErrors.set(t,e);const a=this.pendingCallbacks.get(t);a&&(a.error.forEach(n=>n(e)),this.pendingCallbacks.delete(t)),this.initializationErrors.size===1&&!this.items.size&&this.error(null,e),this.notifyWatchers()}resetErrors(t){const{initializationErrors:e}=this;e.has(null)&&e.get(null)===e.get(t)&&e.delete(null),e.delete(t)}unregister(t){if(!this.items.has(t))throw new Error(`Item with ID "${t}" is not registered.`);t&&this.items.get(null)===this.items.get(t)&&this.unregister(null),this.items.delete(t),this.pendingCallbacks.delete(t),this.notifyWatchers()}getItems(){return Array.from(this.items.values())}hasItem(t){return this.items.has(t)}waitFor(t,e){return new Promise((a,n)=>{let o=!1,s=null;this.execute(t,c=>{o||(s!==null&&clearTimeout(s),a(c))},c=>{o||(s!==null&&clearTimeout(s),n(c))}),e&&(s=setTimeout(()=>{o=!0,n(new Error(`Timeout waiting for item with ID "${t}" to be registered.`))},e))})}async destroyAll(){const t=Array.from(new Set(this.items.values())).map(e=>e.destroy());this.items.clear(),this.pendingCallbacks.clear(),await Promise.all(t),this.notifyWatchers()}watch(t){return this.watchers.add(t),t(new Map(this.items),new Map(this.initializationErrors)),this.unwatch.bind(this,t)}unwatch(t){this.watchers.delete(t)}reset(){this.items.clear(),this.initializationErrors.clear(),this.pendingCallbacks.clear(),this.notifyWatchers()}notifyWatchers(){this.watchers.forEach(t=>t(new Map(this.items),new Map(this.initializationErrors)))}getPendingCallbacks(t){let e=this.pendingCallbacks.get(t);return e||(e={success:[],error:[]},this.pendingCallbacks.set(t,e)),e}registerAsDefault(t,e){this.items.size===1&&t!==null&&this.register(null,e)}}function $(i,t){let e=null;return(...a)=>{e&&clearTimeout(e),e=setTimeout(()=>{t(...a)},i)}}function wt(i,t){const e=Object.entries(i).filter(([a,n])=>t(n,a));return Object.fromEntries(e)}function O(i){return Object.keys(i).length===0&&i.constructor===Object}function W(i,t){const e=Object.entries(i).map(([a,n])=>[a,t(n,a)]);return Object.fromEntries(e)}function ft(i,t){if(i===t)return!0;const e=Object.keys(i),a=Object.keys(t);if(e.length!==a.length)return!1;for(const n of e)if(i[n]!==t[n]||!Object.prototype.hasOwnProperty.call(t,n))return!1;return!0}function gt(){return Math.random().toString(36).substring(2)}function yt(i,{timeOutAfter:t=500,retryAfter:e=100}={}){return new Promise((a,n)=>{const o=Date.now();let s=null;const c=setTimeout(()=>{n(s??new Error("Timeout"))},t),l=async()=>{try{const m=await i();clearTimeout(c),a(m)}catch(m){s=m,Date.now()-o>t?n(m):setTimeout(l,e)}};l()})}function x(){return new Promise(i=>{switch(document.readyState){case"loading":document.addEventListener("DOMContentLoaded",()=>i(),{once:!0});break;case"interactive":case"complete":setTimeout(i,0);break;default:console.warn("Unexpected document.readyState:",document.readyState),setTimeout(i,0)}})}function F(i){if(i.hasAttribute("data-cke-interactive"))return{promise:Promise.resolve(),disconnect:()=>{}};let t;return{promise:new Promise(a=>{t=new MutationObserver(n=>{for(const o of n)if(o.type==="attributes"&&o.attributeName==="data-cke-interactive"&&i.hasAttribute("data-cke-interactive")){t.disconnect(),a();break}}),t.observe(i,{attributes:!0})}),disconnect:()=>t?.disconnect()}}function z(i){i.setAttribute("data-cke-interactive","true")}const V=Symbol.for("context-editor-watchdog");async function bt({element:i,context:t,creator:e,config:a}){const n=gt();await t.add({creator:(l,m)=>e.create(l,m),id:n,sourceElementOrData:i,type:"editor",config:a});const o=t.getItem(n),s={state:"available",editorContextId:n,context:t};o[V]=s;const c=t.destroy.bind(t);return t.destroy=async()=>(s.state="unavailable",c()),{...s,editor:o}}function Et(i){return V in i?i[V]:null}function K(i){return Array.from(i.model.document.getRoots()).reduce((t,e)=>(e.rootName==="$graveyard"||(t[e.rootName]=i.getData({rootName:e.rootName})),t),Object.create({}))}function I(i){return["inline","classic","balloon","decoupled"].includes(i)}async function j(i){const t=await import("ckeditor5"),a={inline:t.InlineEditor,balloon:t.BalloonEditor,classic:t.ClassicEditor,decoupled:t.DecoupledEditor,multiroot:t.MultiRootEditor}[i];if(!a)throw new b(`Unsupported editor type: ${i}`);return a}class N{static the=new N;plugins=new Map;constructor(){}register(t,e){if(this.plugins.has(t))throw new b(`Plugin with name "${t}" is already registered.`);return this.plugins.set(t,e),this.unregister.bind(this,t)}unregister(t){if(!this.plugins.has(t))throw new b(`Plugin with name "${t}" is not registered.`);this.plugins.delete(t)}unregisterAll(){this.plugins.clear()}async get(t){return this.plugins.get(t)?.()}has(t){return this.plugins.has(t)}}async function G(i){const t=await import("ckeditor5");let e=null;const a=i.map(async n=>{if(kt(n)){const{name:l,path:m}=n.$import,d=await import(m),f=(Object.prototype.hasOwnProperty.call(d,l)?d[l]:void 0)??(Object.prototype.hasOwnProperty.call(d,"default")?d.default:void 0);if(!f)throw new b(`Plugin "${l}" not found in module "${m}".`);return f}const o=await N.the.get(n);if(o)return o;const{[n]:s}=t;if(s)return s;if(!e)try{e=await import("ckeditor5-premium-features")}catch(l){throw console.error(`Failed to load premium package: ${l}`),new b(`Plugin "${n}" not found in base package and failed to load premium package.`)}const{[n]:c}=e||{};if(c)return c;throw new b(`Plugin "${n}" not found in base or premium packages.`)});return{loadedPlugins:await Promise.all(a),hasPremium:!!e}}function kt(i){return typeof i=="object"&&i!==null&&"$import"in i}async function Y(i,t){const e=[i.ui,i.content];return await Promise.all([_("ckeditor5",e),t&&_("ckeditor5-premium-features",e)].filter(n=>!!n)).then(n=>n.flat())}async function _(i,t){return await Promise.all(t.filter(e=>e!=="en").map(async e=>{const a=await vt(i,e);return a?.default??a}).filter(Boolean))}async function vt(i,t){try{if(i==="ckeditor5")switch(t){case"af":return await import("ckeditor5/translations/af.js");case"ar":return await import("ckeditor5/translations/ar.js");case"ast":return await import("ckeditor5/translations/ast.js");case"az":return await import("ckeditor5/translations/az.js");case"bg":return await import("ckeditor5/translations/bg.js");case"bn":return await import("ckeditor5/translations/bn.js");case"bs":return await import("ckeditor5/translations/bs.js");case"ca":return await import("ckeditor5/translations/ca.js");case"cs":return await import("ckeditor5/translations/cs.js");case"da":return await import("ckeditor5/translations/da.js");case"de":return await import("ckeditor5/translations/de.js");case"de-ch":return await import("ckeditor5/translations/de-ch.js");case"el":return await import("ckeditor5/translations/el.js");case"en":return await import("ckeditor5/translations/en.js");case"en-au":return await import("ckeditor5/translations/en-au.js");case"en-gb":return await import("ckeditor5/translations/en-gb.js");case"eo":return await import("ckeditor5/translations/eo.js");case"es":return await import("ckeditor5/translations/es.js");case"es-co":return await import("ckeditor5/translations/es-co.js");case"et":return await import("ckeditor5/translations/et.js");case"eu":return await import("ckeditor5/translations/eu.js");case"fa":return await import("ckeditor5/translations/fa.js");case"fi":return await import("ckeditor5/translations/fi.js");case"fr":return await import("ckeditor5/translations/fr.js");case"gl":return await import("ckeditor5/translations/gl.js");case"gu":return await import("ckeditor5/translations/gu.js");case"he":return await import("ckeditor5/translations/he.js");case"hi":return await import("ckeditor5/translations/hi.js");case"hr":return await import("ckeditor5/translations/hr.js");case"hu":return await import("ckeditor5/translations/hu.js");case"hy":return await import("ckeditor5/translations/hy.js");case"id":return await import("ckeditor5/translations/id.js");case"it":return await import("ckeditor5/translations/it.js");case"ja":return await import("ckeditor5/translations/ja.js");case"jv":return await import("ckeditor5/translations/jv.js");case"kk":return await import("ckeditor5/translations/kk.js");case"km":return await import("ckeditor5/translations/km.js");case"kn":return await import("ckeditor5/translations/kn.js");case"ko":return await import("ckeditor5/translations/ko.js");case"ku":return await import("ckeditor5/translations/ku.js");case"lt":return await import("ckeditor5/translations/lt.js");case"lv":return await import("ckeditor5/translations/lv.js");case"ms":return await import("ckeditor5/translations/ms.js");case"nb":return await import("ckeditor5/translations/nb.js");case"ne":return await import("ckeditor5/translations/ne.js");case"nl":return await import("ckeditor5/translations/nl.js");case"no":return await import("ckeditor5/translations/no.js");case"oc":return await import("ckeditor5/translations/oc.js");case"pl":return await import("ckeditor5/translations/pl.js");case"pt":return await import("ckeditor5/translations/pt.js");case"pt-br":return await import("ckeditor5/translations/pt-br.js");case"ro":return await import("ckeditor5/translations/ro.js");case"ru":return await import("ckeditor5/translations/ru.js");case"si":return await import("ckeditor5/translations/si.js");case"sk":return await import("ckeditor5/translations/sk.js");case"sl":return await import("ckeditor5/translations/sl.js");case"sq":return await import("ckeditor5/translations/sq.js");case"sr":return await import("ckeditor5/translations/sr.js");case"sr-latn":return await import("ckeditor5/translations/sr-latn.js");case"sv":return await import("ckeditor5/translations/sv.js");case"th":return await import("ckeditor5/translations/th.js");case"tk":return await import("ckeditor5/translations/tk.js");case"tr":return await import("ckeditor5/translations/tr.js");case"tt":return await import("ckeditor5/translations/tt.js");case"ug":return await import("ckeditor5/translations/ug.js");case"uk":return await import("ckeditor5/translations/uk.js");case"ur":return await import("ckeditor5/translations/ur.js");case"uz":return await import("ckeditor5/translations/uz.js");case"vi":return await import("ckeditor5/translations/vi.js");case"zh":return await import("ckeditor5/translations/zh.js");case"zh-cn":return await import("ckeditor5/translations/zh-cn.js");default:return console.warn(`Language ${t} not found in ckeditor5 translations`),null}else switch(t){case"af":return await import("ckeditor5-premium-features/translations/af.js");case"ar":return await import("ckeditor5-premium-features/translations/ar.js");case"ast":return await import("ckeditor5-premium-features/translations/ast.js");case"az":return await import("ckeditor5-premium-features/translations/az.js");case"bg":return await import("ckeditor5-premium-features/translations/bg.js");case"bn":return await import("ckeditor5-premium-features/translations/bn.js");case"bs":return await import("ckeditor5-premium-features/translations/bs.js");case"ca":return await import("ckeditor5-premium-features/translations/ca.js");case"cs":return await import("ckeditor5-premium-features/translations/cs.js");case"da":return await import("ckeditor5-premium-features/translations/da.js");case"de":return await import("ckeditor5-premium-features/translations/de.js");case"de-ch":return await import("ckeditor5-premium-features/translations/de-ch.js");case"el":return await import("ckeditor5-premium-features/translations/el.js");case"en":return await import("ckeditor5-premium-features/translations/en.js");case"en-au":return await import("ckeditor5-premium-features/translations/en-au.js");case"en-gb":return await import("ckeditor5-premium-features/translations/en-gb.js");case"eo":return await import("ckeditor5-premium-features/translations/eo.js");case"es":return await import("ckeditor5-premium-features/translations/es.js");case"es-co":return await import("ckeditor5-premium-features/translations/es-co.js");case"et":return await import("ckeditor5-premium-features/translations/et.js");case"eu":return await import("ckeditor5-premium-features/translations/eu.js");case"fa":return await import("ckeditor5-premium-features/translations/fa.js");case"fi":return await import("ckeditor5-premium-features/translations/fi.js");case"fr":return await import("ckeditor5-premium-features/translations/fr.js");case"gl":return await import("ckeditor5-premium-features/translations/gl.js");case"gu":return await import("ckeditor5-premium-features/translations/gu.js");case"he":return await import("ckeditor5-premium-features/translations/he.js");case"hi":return await import("ckeditor5-premium-features/translations/hi.js");case"hr":return await import("ckeditor5-premium-features/translations/hr.js");case"hu":return await import("ckeditor5-premium-features/translations/hu.js");case"hy":return await import("ckeditor5-premium-features/translations/hy.js");case"id":return await import("ckeditor5-premium-features/translations/id.js");case"it":return await import("ckeditor5-premium-features/translations/it.js");case"ja":return await import("ckeditor5-premium-features/translations/ja.js");case"jv":return await import("ckeditor5-premium-features/translations/jv.js");case"kk":return await import("ckeditor5-premium-features/translations/kk.js");case"km":return await import("ckeditor5-premium-features/translations/km.js");case"kn":return await import("ckeditor5-premium-features/translations/kn.js");case"ko":return await import("ckeditor5-premium-features/translations/ko.js");case"ku":return await import("ckeditor5-premium-features/translations/ku.js");case"lt":return await import("ckeditor5-premium-features/translations/lt.js");case"lv":return await import("ckeditor5-premium-features/translations/lv.js");case"ms":return await import("ckeditor5-premium-features/translations/ms.js");case"nb":return await import("ckeditor5-premium-features/translations/nb.js");case"ne":return await import("ckeditor5-premium-features/translations/ne.js");case"nl":return await import("ckeditor5-premium-features/translations/nl.js");case"no":return await import("ckeditor5-premium-features/translations/no.js");case"oc":return await import("ckeditor5-premium-features/translations/oc.js");case"pl":return await import("ckeditor5-premium-features/translations/pl.js");case"pt":return await import("ckeditor5-premium-features/translations/pt.js");case"pt-br":return await import("ckeditor5-premium-features/translations/pt-br.js");case"ro":return await import("ckeditor5-premium-features/translations/ro.js");case"ru":return await import("ckeditor5-premium-features/translations/ru.js");case"si":return await import("ckeditor5-premium-features/translations/si.js");case"sk":return await import("ckeditor5-premium-features/translations/sk.js");case"sl":return await import("ckeditor5-premium-features/translations/sl.js");case"sq":return await import("ckeditor5-premium-features/translations/sq.js");case"sr":return await import("ckeditor5-premium-features/translations/sr.js");case"sr-latn":return await import("ckeditor5-premium-features/translations/sr-latn.js");case"sv":return await import("ckeditor5-premium-features/translations/sv.js");case"th":return await import("ckeditor5-premium-features/translations/th.js");case"tk":return await import("ckeditor5-premium-features/translations/tk.js");case"tr":return await import("ckeditor5-premium-features/translations/tr.js");case"tt":return await import("ckeditor5-premium-features/translations/tt.js");case"ug":return await import("ckeditor5-premium-features/translations/ug.js");case"uk":return await import("ckeditor5-premium-features/translations/uk.js");case"ur":return await import("ckeditor5-premium-features/translations/ur.js");case"uz":return await import("ckeditor5-premium-features/translations/uz.js");case"vi":return await import("ckeditor5-premium-features/translations/vi.js");case"zh":return await import("ckeditor5-premium-features/translations/zh.js");case"zh-cn":return await import("ckeditor5-premium-features/translations/zh-cn.js");default:return console.warn(`Language ${t} not found in premium translations`),await import("ckeditor5-premium-features/translations/en.js")}}catch(e){return console.error(`Failed to load translation for ${i}/${t}:`,e),null}}function X(i){return W(i,t=>({dictionary:t}))}function q(){return Array.from(document.querySelectorAll("cke5-editor")).map(i=>i.getAttribute("data-cke-editor-id")).filter(i=>i!==null)}function Q(i){const t=Z(i);return W(t,({element:e})=>e)}function J(i){const t=Z(i),e=W(t,({content:a})=>a);return wt(e,a=>typeof a=="string")}function Z(i){const t=Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${i}"]`)).reduce((s,c)=>{const l=c.getAttribute("data-cke-root-name"),m=c.getAttribute("data-cke-content");return s[l]={element:c.querySelector("[data-cke-editable-content]"),content:m},s},Object.create({})),e=document.querySelector(`cke5-editor[data-cke-editor-id="${i}"]`);if(!e)return t;const a=t.main,n=JSON.parse(e.getAttribute("data-cke-content")),o=document.querySelector(`#${i}_editor `);return a&&n?.main?{...t,main:{...a,content:a.content||n.main}}:o?{...t,main:{element:o,content:n?.main||null}}:t}function S(i){if(!i||typeof i!="object")return i;if(Array.isArray(i))return i.map(a=>S(a));const t=i;if(t.$element&&typeof t.$element=="string"){const a=document.querySelector(t.$element);return a||console.warn(`Element not found for selector: ${t.$element}`),a||null}const e=Object.create(null);for(const[a,n]of Object.entries(i))e[a]=S(n);return e}function D(i,t,e){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(o=>D(i,t,o));const a=e;if(a.$translation&&typeof a.$translation=="string"){const o=a.$translation,s=Ct(i,o,t);return s===void 0&&console.warn(`Translation not found for key: ${o}`),s!==void 0?s:null}const n=Object.create(null);for(const[o,s]of Object.entries(e))n[o]=D(i,t,s);return n}function Ct(i,t,e){for(const a of i){const n=a[e];if(n?.dictionary&&t in n.dictionary)return n.dictionary[t]}}function At(i,t){const{editing:e}=i;e.view.change(a=>{a.setStyle("height",`${t}px`,e.view.document.getRoot())})}const M=Symbol.for("elixir-editor-watchdog");async function Pt(i){const{EditorWatchdog:t}=await import("ckeditor5"),e=new t(i);return e.setCreator(async(...a)=>{const n=await i.create(...a);return n[M]=e,n}),{watchdog:e,Constructor:{create:async(...a)=>(await e.create(...a),e.editor)}}}function It(i){return M in i?i[M]:null}class v extends H{static the=new v}class Tt extends HTMLElement{contextPromise=null;interactiveWait;async connectedCallback(){await x(),this.interactiveWait=F(this),await this.interactiveWait.promise,await this.initializeContext()}async initializeContext(){const t=this.getAttribute("data-cke-context-id"),e=JSON.parse(this.getAttribute("data-cke-language")),a=JSON.parse(this.getAttribute("data-cke-context")),{customTranslations:n,watchdogConfig:o,config:{plugins:s,...c}}=a,{loadedPlugins:l,hasPremium:m}=await G(s??[]),d=[...await Y(e,m),X(n||{})].filter(E=>!O(E));this.contextPromise=(async()=>{const{ContextWatchdog:E,Context:k}=await import("ckeditor5"),g=new E(k,{crashNumberLimit:10,...o});let w=S(c);return w=D([...d].reverse(),e.ui,w),await g.create({...w,language:e,plugins:l,...d.length&&{translations:d}}),g.on("itemError",(...A)=>{console.error("Context item error:",...A)}),g})();const f=await this.contextPromise;this.isConnected&&v.the.register(t,f)}async disconnectedCallback(){this.interactiveWait?.disconnect();const t=this.getAttribute("data-cke-context-id");this.style.display="none";try{await(await this.contextPromise)?.destroy()}finally{this.contextPromise=null,t&&v.the.hasItem(t)&&v.the.unregister(t)}}}class h extends H{static the=new h}class tt extends HTMLElement{editorPromise=null;interactiveWait;beforeDestroyCallbacks=[];onBeforeDestroy(t){this.beforeDestroyCallbacks.push(t)}async connectedCallback(){await x(),this.interactiveWait=F(this),await this.interactiveWait.promise,await this.initializeEditable()}async initializeEditable(){this.hasAttribute("data-cke-editor-id")||this.setAttribute("data-cke-editor-id",q()[0]);const t=this.getAttribute("data-cke-editor-id"),e=this.getAttribute("data-cke-root-name"),a=JSON.parse(this.getAttribute("data-cke-root-attributes")||"{}"),n=this.getAttribute("data-cke-content"),o=Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"),10);if(!t||!e)throw new b("Editor ID or Root Name is missing.");this.style.display="block",this.editorPromise=h.the.execute(t,async s=>{if(!this.isConnected)return null;const{ui:c,editing:l,model:m}=s,u=this.querySelector("input"),d=m.document.getRoot(e);if(d?.isAttached()){if(n!==null){const w=s.getData({rootName:e});w&&w!==n&&s.setData({[e]:n})}return O(a)||s.model.change(w=>{w.setAttributes(a,d)}),s}s.addRoot(e,{isUndoable:!1,attributes:{...a},...n!==null&&{data:n}});const f=this.querySelector("[data-cke-editable-content]"),E=c.view.createEditable(e,f);c.addEditable(E),l.view.forceRender();const k=()=>{if(!m.document.getRoot(e)?.isAttached())return;const w=s.getData({rootName:e});u&&(u.value=w,u.dispatchEvent(new Event("input"))),this.dispatchEvent(new CustomEvent("change",{detail:{value:w}}))},g=$(o,k);return s.model.document.on("change:data",g),this.onBeforeDestroy(()=>s.model.document.off("change:data",g)),k(),s})}async disconnectedCallback(){this.interactiveWait?.disconnect();const t=this.getAttribute("data-cke-root-name");this.style.display="none";const e=await this.editorPromise;this.editorPromise=null;for(const a of this.beforeDestroyCallbacks)a();if(this.beforeDestroyCallbacks=[],e&&e.state!=="destroyed"&&t){const a=e.model.document.getRoot(t);if(a&&"detachEditable"in e){try{e.ui.view.editables[t]&&e.detachEditable(a)}catch(n){console.error("Unable unmount editable from root:",n)}a.isAttached()&&e.detachRoot(t,!1)}}}}async function Ot({saveDebounceMs:i,editorId:t,targetElement:e}){const{Plugin:a}=await import("ckeditor5");return class extends a{static get pluginName(){return"DispatchEditorRootsChangeEvent"}afterInit(){const{editor:o}=this,s=$(i,this.dispatch);o.model.document.on("change:data",s),o.once("ready",this.dispatch)}dispatch=()=>{const{editor:o}=this;e.dispatchEvent(new y({editorId:t,editor:o,roots:K(o)}))}}}class y extends CustomEvent{static EVENT_NAME="ckeditor5:change:data";constructor(t){super(y.EVENT_NAME,{detail:t,bubbles:!0})}}async function St(i){const{Plugin:t}=await import("ckeditor5");return class extends t{input=null;form=null;static get pluginName(){return"SyncEditorWithInput"}afterInit(){const{editor:a}=this,o=a.sourceElement.id.replace(/_editor$/,"");this.input=document.getElementById(`${o}_input`),this.input&&(a.model.document.on("change:data",$(i,()=>this.sync())),a.once("ready",this.sync),this.form=this.input.closest("form"),this.form?.addEventListener("submit",this.sync))}sync=()=>{if(this.input){const a=this.editor.getData();this.input.value=a,this.input.dispatchEvent(new Event("input",{bubbles:!0}))}};destroy(){this.form&&this.form.removeEventListener("submit",this.sync),this.input=null,this.form=null}}}class et extends HTMLElement{editorPromise=null;interactiveWait;async connectedCallback(){await x(),this.interactiveWait=F(this),j("classic"),await this.interactiveWait.promise,await this.initializeEditor()}async initializeEditor(){const t=this.getAttribute("data-cke-editor-id");h.the.resetErrors(t);try{this.style.display="block",this.editorPromise=this.createEditor();const e=await this.editorPromise;this.isConnected&&(h.the.register(t,e),e.once("destroy",()=>{h.the.hasItem(t)&&h.the.unregister(t)}))}catch(e){console.error(`Error initializing CKEditor5 instance with ID "${t}":`,e),this.editorPromise=null,h.the.error(t,e)}}async disconnectedCallback(){this.interactiveWait?.disconnect(),this.style.display="none";try{const t=await this.editorPromise;if(!t)return;const e=Et(t),a=It(t);e?e.state!=="unavailable"&&await e.context.remove(e.editorContextId):a?await a.destroy():await t.destroy()}finally{this.editorPromise=null}}async createEditor(){const t=this.getAttribute("data-cke-editor-id"),e=JSON.parse(this.getAttribute("data-cke-preset")),a=this.getAttribute("data-cke-context-id"),n=JSON.parse(this.getAttribute("data-cke-root-attributes")||"{}"),o=this.getAttribute("data-cke-editable-height")?Number.parseInt(this.getAttribute("data-cke-editable-height"),10):null,s=Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"),10),c=JSON.parse(this.getAttribute("data-cke-language")),l=this.hasAttribute("data-cke-watchdog"),m=JSON.parse(this.getAttribute("data-cke-content")),{customTranslations:u,editorType:d,licenseKey:f,config:{plugins:E,...k}}=e;let g=await j(d);const w=await(a?v.the.waitFor(a):null);if(l&&!w){const p=await Pt(g);({Constructor:g}=p),p.watchdog.on("restart",()=>{const C=p.watchdog.editor;this.editorPromise=Promise.resolve(C),h.the.register(t,C)})}const{loadedPlugins:A,hasPremium:ct}=await G(E);A.push(await Ot({saveDebounceMs:s,editorId:t,targetElement:this})),I(d)&&A.push(await St(s));const R=[...await Y(c,ct),X(u||{})].filter(p=>!O(p));let P={...m,...J(t)};I(d)&&(P=P.main||"");const T=await(async()=>{let p=Q(t);if(!p.main){const U=I(d)?["main"]:Object.keys(P);rt(p,U)||(p=await Dt(t,U),P={...m,...J(t)})}I(d)&&"main"in p&&(p=p.main);let C=S(k);C=D([...R].reverse(),c.ui,C);const L={...C,initialData:P,licenseKey:f,plugins:A,language:c,...R.length&&{translations:R}};return!w||!(p instanceof HTMLElement)?g.create(p,L):(await bt({context:w,element:p,creator:g,config:L})).editor})();return O(n)||T.model.change(p=>{p.setAttributes(n,T.model.document.getRoot())}),I(d)&&o&&At(T,o),T}}function rt(i,t){return t.every(e=>i[e])}async function Dt(i,t){return yt(()=>{const e=Q(i);if(!rt(e,t))throw new Error(`It looks like not all required root elements are present yet.
|
|
1
|
+
"use strict";var ht=Object.create;var J=Object.defineProperty;var pt=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var wt=Object.getPrototypeOf,gt=Object.prototype.hasOwnProperty;var bt=(r,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ft(t))!gt.call(r,n)&&n!==e&&J(r,n,{get:()=>t[n],enumerable:!(a=pt(t,n))||a.enumerable});return r};var i=(r,t,e)=>(e=r!=null?ht(wt(r)):{},bt(t||!r||!r.__esModule?J(e,"default",{value:r,enumerable:!0}):e,r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class E extends Error{constructor(t){super(t),this.name="CKEditor5BlazorError"}}function K(r,t){if(!r||r.size!==t.size)return!1;for(const[e,a]of r)if(!t.has(e)||t.get(e)!==a)return!1;return!0}class Q{items=new Map;initializationErrors=new Map;pendingCallbacks=new Map;watchers=new Set;batchDepth=0;lastNotifiedItems=null;lastNotifiedErrors=null;execute(t,e,a){const n=this.items.get(t),o=this.initializationErrors.get(t);return o?(a?.(o),Promise.reject(o)):n?Promise.resolve(e(n)):new Promise((s,u)=>{const l=this.getPendingCallbacks(t);l.success.push(async c=>{s(await e(c))}),a?l.error.push(a):l.error.push(u)})}mountEffect(t,e){let a,n,o=!1;const s=this.watch(u=>{const l=u.get(t);if(l!==n&&(a?.(),a=void 0,n=l,!!l))try{const c=e(l);o?(c?.(),s()):a=c}catch(c){throw console.error(c),c}});return()=>{o=!0,n&&(s(),a?.(),a=void 0)}}register(t,e){this.batch(()=>{if(this.items.has(t))throw new Error(`Item with ID "${t}" is already registered.`);this.resetErrors(t),this.items.set(t,e);const a=this.pendingCallbacks.get(t);a&&(a.success.forEach(n=>n(e)),this.pendingCallbacks.delete(t)),this.items.size===1&&t!==null&&this.register(null,e)})}error(t,e){this.batch(()=>{this.items.delete(t),this.initializationErrors.set(t,e);const a=this.pendingCallbacks.get(t);a&&(a.error.forEach(n=>n(e)),this.pendingCallbacks.delete(t)),this.initializationErrors.size===1&&!this.items.size&&this.error(null,e)})}resetErrors(t){const{initializationErrors:e}=this;e.has(null)&&e.get(null)===e.get(t)&&e.delete(null),e.delete(t)}unregister(t,e=!0){this.batch(()=>{t&&this.items.get(null)===this.items.get(t)&&this.unregister(null,!1),this.items.delete(t),e&&this.pendingCallbacks.delete(t),this.resetErrors(t)})}getItems(){return Array.from(this.items.values())}getItem(t){return this.items.get(t)}hasItem(t){return this.items.has(t)}waitFor(t){return new Promise((e,a)=>{this.execute(t,e,a)})}async destroyAll(){const t=Array.from(new Set(this.items.values())).map(e=>e.destroy());this.items.clear(),this.pendingCallbacks.clear(),await Promise.all(t),this.flushWatchers()}async reset(){await this.destroyAll(),this.watchers.clear()}batch(t){this.batchDepth++;try{return t()}finally{this.batchDepth--,this.batchDepth===0&&this.flushWatchers()}}watch(t){return this.watchers.add(t),t(new Map(this.items),new Map(this.initializationErrors)),this.unwatch.bind(this,t)}unwatch(t){this.watchers.delete(t)}flushWatchers(){K(this.lastNotifiedItems,this.items)&&K(this.lastNotifiedErrors,this.initializationErrors)||(this.lastNotifiedItems=new Map(this.items),this.lastNotifiedErrors=new Map(this.initializationErrors),this.watchers.forEach(t=>t(new Map(this.items),new Map(this.initializationErrors))))}getPendingCallbacks(t){let e=this.pendingCallbacks.get(t);return e||(e={success:[],error:[]},this.pendingCallbacks.set(t,e)),e}}function L(r,t){let e=null;return(...a)=>{e&&clearTimeout(e),e=setTimeout(()=>{t(...a)},r)}}function yt(r,t){const e=Object.entries(r).filter(([a,n])=>t(n,a));return Object.fromEntries(e)}function S(r){return Object.keys(r).length===0&&r.constructor===Object}function _(r,t){const e=Object.entries(r).map(([a,n])=>[a,t(n,a)]);return Object.fromEntries(e)}function Et(r,t){if(r===t)return!0;const e=Object.keys(r),a=Object.keys(t);if(e.length!==a.length)return!1;for(const n of e)if(r[n]!==t[n]||!Object.prototype.hasOwnProperty.call(t,n))return!1;return!0}function kt(){return Math.random().toString(36).substring(2)}function vt(r,{timeOutAfter:t=500,retryAfter:e=100}={}){return new Promise((a,n)=>{const o=Date.now();let s=null;const u=setTimeout(()=>{n(s??new Error("Timeout"))},t),l=async()=>{try{const c=await r();clearTimeout(u),a(c)}catch(c){s=c,Date.now()-o>t?n(c):setTimeout(l,e)}};l()})}function x(){return new Promise(r=>{switch(document.readyState){case"loading":document.addEventListener("DOMContentLoaded",()=>r(),{once:!0});break;case"interactive":case"complete":setTimeout(r,0);break;default:console.warn("Unexpected document.readyState:",document.readyState),setTimeout(r,0)}})}function q(r){if(r.hasAttribute("data-cke-interactive"))return{promise:Promise.resolve(),disconnect:()=>{}};let t;return{promise:new Promise(a=>{t=new MutationObserver(n=>{for(const o of n)if(o.type==="attributes"&&o.attributeName==="data-cke-interactive"&&r.hasAttribute("data-cke-interactive")){t.disconnect(),a();break}}),t.observe(r,{attributes:!0})}),disconnect:()=>t?.disconnect()}}function D(r){r.setAttribute("data-cke-interactive","true")}function Ct(r){const t=[r.ui?.element,r.ui?.view?.toolbar?.element,r.ui?.view?.menuBarView?.element].filter(Boolean);for(const o of t)n(o);const e=r.ui?.view?.body?._bodyCollectionContainer;e?.isConnected&&n(e);const a=r.editing?.view;if(a)for(const o of a.domRoots.values())o instanceof HTMLElement&&(o.removeAttribute("contenteditable"),o.removeAttribute("role"),o.removeAttribute("aria-label"),o.removeAttribute("aria-multiline"),o.removeAttribute("spellcheck"),o.classList.remove("ck","ck-content","ck-editor__editable","ck-rounded-corners","ck-editor__editable_inline","ck-blurred","ck-focused"),n(o));function n(o){o.hasAttribute("data-cke-controlled")?o.innerHTML="":o.remove()}}const $=Symbol.for("context-editor-watchdog");async function At({element:r,context:t,creator:e,config:a}){const n=kt();await t.add({creator:(l,c)=>e.create(l,c),id:n,sourceElementOrData:r,type:"editor",config:a});const o=t.getItem(n),s={state:"available",editorContextId:n,context:t};o[$]=s;const u=t.destroy.bind(t);return t.destroy=async()=>(s.state="unavailable",u()),{...s,editor:o}}function It(r){return $ in r?r[$]:null}function Z(r){return Array.from(r.model.document.getRoots()).reduce((t,e)=>(e.rootName==="$graveyard"||(t[e.rootName]=r.getData({rootName:e.rootName})),t),Object.create({}))}function P(r){return["inline","classic","balloon","decoupled"].includes(r)}async function G(r){const t=await import("ckeditor5"),a={inline:t.InlineEditor,balloon:t.BalloonEditor,classic:t.ClassicEditor,decoupled:t.DecoupledEditor,multiroot:t.MultiRootEditor}[r];if(!a)throw new E(`Unsupported editor type: ${r}`);return a}class V{static the=new V;plugins=new Map;constructor(){}register(t,e){if(this.plugins.has(t))throw new E(`Plugin with name "${t}" is already registered.`);return this.plugins.set(t,e),this.unregister.bind(this,t)}unregister(t){if(!this.plugins.has(t))throw new E(`Plugin with name "${t}" is not registered.`);this.plugins.delete(t)}unregisterAll(){this.plugins.clear()}async get(t){return this.plugins.get(t)?.()}has(t){return this.plugins.has(t)}}async function tt(r){const t=await import("ckeditor5");let e=null;const a=r.map(async n=>{if(Ot(n)){const{name:l,path:c}=n.$import,d=await import(c),w=(Object.prototype.hasOwnProperty.call(d,l)?d[l]:void 0)??(Object.prototype.hasOwnProperty.call(d,"default")?d.default:void 0);if(!w)throw new E(`Plugin "${l}" not found in module "${c}".`);return w}const o=await V.the.get(n);if(o)return o;const{[n]:s}=t;if(s)return s;if(!e)try{e=await import("ckeditor5-premium-features")}catch(l){throw console.error(`Failed to load premium package: ${l}`),new E(`Plugin "${n}" not found in base package and failed to load premium package.`)}const{[n]:u}=e||{};if(u)return u;throw new E(`Plugin "${n}" not found in base or premium packages.`)});return{loadedPlugins:await Promise.all(a),hasPremium:!!e}}function Ot(r){return typeof r=="object"&&r!==null&&"$import"in r}async function et(r,t){const e=[r.ui,r.content];return await Promise.all([Y("ckeditor5",e),t&&Y("ckeditor5-premium-features",e)].filter(n=>!!n)).then(n=>n.flat())}async function Y(r,t){return await Promise.all(t.filter(e=>e!=="en").map(async e=>{const a=await Pt(r,e);return a?.default??a}).filter(Boolean))}async function Pt(r,t){try{if(r==="ckeditor5")switch(t){case"af":return await import("ckeditor5/translations/af.js");case"ar":return await import("ckeditor5/translations/ar.js");case"ast":return await import("ckeditor5/translations/ast.js");case"az":return await import("ckeditor5/translations/az.js");case"bg":return await import("ckeditor5/translations/bg.js");case"bn":return await import("ckeditor5/translations/bn.js");case"bs":return await import("ckeditor5/translations/bs.js");case"ca":return await import("ckeditor5/translations/ca.js");case"cs":return await import("ckeditor5/translations/cs.js");case"da":return await import("ckeditor5/translations/da.js");case"de":return await import("ckeditor5/translations/de.js");case"de-ch":return await import("ckeditor5/translations/de-ch.js");case"el":return await import("ckeditor5/translations/el.js");case"en":return await import("ckeditor5/translations/en.js");case"en-au":return await import("ckeditor5/translations/en-au.js");case"en-gb":return await import("ckeditor5/translations/en-gb.js");case"eo":return await import("ckeditor5/translations/eo.js");case"es":return await import("ckeditor5/translations/es.js");case"es-co":return await import("ckeditor5/translations/es-co.js");case"et":return await import("ckeditor5/translations/et.js");case"eu":return await import("ckeditor5/translations/eu.js");case"fa":return await import("ckeditor5/translations/fa.js");case"fi":return await import("ckeditor5/translations/fi.js");case"fr":return await import("ckeditor5/translations/fr.js");case"gl":return await import("ckeditor5/translations/gl.js");case"gu":return await import("ckeditor5/translations/gu.js");case"he":return await import("ckeditor5/translations/he.js");case"hi":return await import("ckeditor5/translations/hi.js");case"hr":return await import("ckeditor5/translations/hr.js");case"hu":return await import("ckeditor5/translations/hu.js");case"hy":return await import("ckeditor5/translations/hy.js");case"id":return await import("ckeditor5/translations/id.js");case"it":return await import("ckeditor5/translations/it.js");case"ja":return await import("ckeditor5/translations/ja.js");case"jv":return await import("ckeditor5/translations/jv.js");case"kk":return await import("ckeditor5/translations/kk.js");case"km":return await import("ckeditor5/translations/km.js");case"kn":return await import("ckeditor5/translations/kn.js");case"ko":return await import("ckeditor5/translations/ko.js");case"ku":return await import("ckeditor5/translations/ku.js");case"lt":return await import("ckeditor5/translations/lt.js");case"lv":return await import("ckeditor5/translations/lv.js");case"ms":return await import("ckeditor5/translations/ms.js");case"nb":return await import("ckeditor5/translations/nb.js");case"ne":return await import("ckeditor5/translations/ne.js");case"nl":return await import("ckeditor5/translations/nl.js");case"no":return await import("ckeditor5/translations/no.js");case"oc":return await import("ckeditor5/translations/oc.js");case"pl":return await import("ckeditor5/translations/pl.js");case"pt":return await import("ckeditor5/translations/pt.js");case"pt-br":return await import("ckeditor5/translations/pt-br.js");case"ro":return await import("ckeditor5/translations/ro.js");case"ru":return await import("ckeditor5/translations/ru.js");case"si":return await import("ckeditor5/translations/si.js");case"sk":return await import("ckeditor5/translations/sk.js");case"sl":return await import("ckeditor5/translations/sl.js");case"sq":return await import("ckeditor5/translations/sq.js");case"sr":return await import("ckeditor5/translations/sr.js");case"sr-latn":return await import("ckeditor5/translations/sr-latn.js");case"sv":return await import("ckeditor5/translations/sv.js");case"th":return await import("ckeditor5/translations/th.js");case"tk":return await import("ckeditor5/translations/tk.js");case"tr":return await import("ckeditor5/translations/tr.js");case"tt":return await import("ckeditor5/translations/tt.js");case"ug":return await import("ckeditor5/translations/ug.js");case"uk":return await import("ckeditor5/translations/uk.js");case"ur":return await import("ckeditor5/translations/ur.js");case"uz":return await import("ckeditor5/translations/uz.js");case"vi":return await import("ckeditor5/translations/vi.js");case"zh":return await import("ckeditor5/translations/zh.js");case"zh-cn":return await import("ckeditor5/translations/zh-cn.js");default:return console.warn(`Language ${t} not found in ckeditor5 translations`),null}else switch(t){case"af":return await import("ckeditor5-premium-features/translations/af.js");case"ar":return await import("ckeditor5-premium-features/translations/ar.js");case"ast":return await import("ckeditor5-premium-features/translations/ast.js");case"az":return await import("ckeditor5-premium-features/translations/az.js");case"bg":return await import("ckeditor5-premium-features/translations/bg.js");case"bn":return await import("ckeditor5-premium-features/translations/bn.js");case"bs":return await import("ckeditor5-premium-features/translations/bs.js");case"ca":return await import("ckeditor5-premium-features/translations/ca.js");case"cs":return await import("ckeditor5-premium-features/translations/cs.js");case"da":return await import("ckeditor5-premium-features/translations/da.js");case"de":return await import("ckeditor5-premium-features/translations/de.js");case"de-ch":return await import("ckeditor5-premium-features/translations/de-ch.js");case"el":return await import("ckeditor5-premium-features/translations/el.js");case"en":return await import("ckeditor5-premium-features/translations/en.js");case"en-au":return await import("ckeditor5-premium-features/translations/en-au.js");case"en-gb":return await import("ckeditor5-premium-features/translations/en-gb.js");case"eo":return await import("ckeditor5-premium-features/translations/eo.js");case"es":return await import("ckeditor5-premium-features/translations/es.js");case"es-co":return await import("ckeditor5-premium-features/translations/es-co.js");case"et":return await import("ckeditor5-premium-features/translations/et.js");case"eu":return await import("ckeditor5-premium-features/translations/eu.js");case"fa":return await import("ckeditor5-premium-features/translations/fa.js");case"fi":return await import("ckeditor5-premium-features/translations/fi.js");case"fr":return await import("ckeditor5-premium-features/translations/fr.js");case"gl":return await import("ckeditor5-premium-features/translations/gl.js");case"gu":return await import("ckeditor5-premium-features/translations/gu.js");case"he":return await import("ckeditor5-premium-features/translations/he.js");case"hi":return await import("ckeditor5-premium-features/translations/hi.js");case"hr":return await import("ckeditor5-premium-features/translations/hr.js");case"hu":return await import("ckeditor5-premium-features/translations/hu.js");case"hy":return await import("ckeditor5-premium-features/translations/hy.js");case"id":return await import("ckeditor5-premium-features/translations/id.js");case"it":return await import("ckeditor5-premium-features/translations/it.js");case"ja":return await import("ckeditor5-premium-features/translations/ja.js");case"jv":return await import("ckeditor5-premium-features/translations/jv.js");case"kk":return await import("ckeditor5-premium-features/translations/kk.js");case"km":return await import("ckeditor5-premium-features/translations/km.js");case"kn":return await import("ckeditor5-premium-features/translations/kn.js");case"ko":return await import("ckeditor5-premium-features/translations/ko.js");case"ku":return await import("ckeditor5-premium-features/translations/ku.js");case"lt":return await import("ckeditor5-premium-features/translations/lt.js");case"lv":return await import("ckeditor5-premium-features/translations/lv.js");case"ms":return await import("ckeditor5-premium-features/translations/ms.js");case"nb":return await import("ckeditor5-premium-features/translations/nb.js");case"ne":return await import("ckeditor5-premium-features/translations/ne.js");case"nl":return await import("ckeditor5-premium-features/translations/nl.js");case"no":return await import("ckeditor5-premium-features/translations/no.js");case"oc":return await import("ckeditor5-premium-features/translations/oc.js");case"pl":return await import("ckeditor5-premium-features/translations/pl.js");case"pt":return await import("ckeditor5-premium-features/translations/pt.js");case"pt-br":return await import("ckeditor5-premium-features/translations/pt-br.js");case"ro":return await import("ckeditor5-premium-features/translations/ro.js");case"ru":return await import("ckeditor5-premium-features/translations/ru.js");case"si":return await import("ckeditor5-premium-features/translations/si.js");case"sk":return await import("ckeditor5-premium-features/translations/sk.js");case"sl":return await import("ckeditor5-premium-features/translations/sl.js");case"sq":return await import("ckeditor5-premium-features/translations/sq.js");case"sr":return await import("ckeditor5-premium-features/translations/sr.js");case"sr-latn":return await import("ckeditor5-premium-features/translations/sr-latn.js");case"sv":return await import("ckeditor5-premium-features/translations/sv.js");case"th":return await import("ckeditor5-premium-features/translations/th.js");case"tk":return await import("ckeditor5-premium-features/translations/tk.js");case"tr":return await import("ckeditor5-premium-features/translations/tr.js");case"tt":return await import("ckeditor5-premium-features/translations/tt.js");case"ug":return await import("ckeditor5-premium-features/translations/ug.js");case"uk":return await import("ckeditor5-premium-features/translations/uk.js");case"ur":return await import("ckeditor5-premium-features/translations/ur.js");case"uz":return await import("ckeditor5-premium-features/translations/uz.js");case"vi":return await import("ckeditor5-premium-features/translations/vi.js");case"zh":return await import("ckeditor5-premium-features/translations/zh.js");case"zh-cn":return await import("ckeditor5-premium-features/translations/zh-cn.js");default:return console.warn(`Language ${t} not found in premium translations`),await import("ckeditor5-premium-features/translations/en.js")}}catch(e){return console.error(`Failed to load translation for ${r}/${t}:`,e),null}}function rt(r){return _(r,t=>({dictionary:t}))}function F(){return Array.from(document.querySelectorAll("cke5-editor")).map(r=>r.getAttribute("data-cke-editor-id")).filter(r=>r!==null)}function it(r){const t=at(r);return _(t,({element:e})=>e)}function X(r){const t=at(r),e=_(t,({content:a})=>a);return yt(e,a=>typeof a=="string")}function at(r){const t=Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${r}"]`)).reduce((s,u)=>{const l=u.getAttribute("data-cke-root-name"),c=u.getAttribute("data-cke-content");return s[l]={element:u.querySelector("[data-cke-editable-content]"),content:c},s},Object.create({})),e=document.querySelector(`cke5-editor[data-cke-editor-id="${r}"]`);if(!e)return t;const a=t.main,n=JSON.parse(e.getAttribute("data-cke-content")),o=document.querySelector(`#${r}_editor `);return a&&n?.main?{...t,main:{...a,content:a.content||n.main}}:o?{...t,main:{element:o,content:n?.main||null}}:t}function R(r){if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(a=>R(a));const t=r;if(t.$element&&typeof t.$element=="string"){const a=document.querySelector(t.$element);return a||console.warn(`Element not found for selector: ${t.$element}`),a||null}const e=Object.create(null);for(const[a,n]of Object.entries(r))e[a]=R(n);return e}function M(r,t,e){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(o=>M(r,t,o));const a=e;if(a.$translation&&typeof a.$translation=="string"){const o=a.$translation,s=Tt(r,o,t);return s===void 0&&console.warn(`Translation not found for key: ${o}`),s!==void 0?s:null}const n=Object.create(null);for(const[o,s]of Object.entries(e))n[o]=M(r,t,s);return n}function Tt(r,t,e){for(const a of r){const n=a[e];if(n?.dictionary&&t in n.dictionary)return n.dictionary[t]}}function Nt(r,t){const{editing:e}=r;e.view.change(a=>{a.setStyle("height",`${t}px`,e.view.document.getRoot())})}const W=Symbol.for("elixir-editor-watchdog");async function St(r,t){const{EditorWatchdog:e}=await import("ckeditor5"),a=new e(null,t??{crashNumberLimit:10,minimumNonErrorTimePeriod:5e3});return a.setCreator(async()=>{const n=await r();return n[W]=a,n}),a}function Rt(r){return W in r?r[W]:null}class A extends Q{static the=new A}class Mt extends HTMLElement{contextPromise=null;interactiveWait;async connectedCallback(){await x(),this.interactiveWait=q(this),await this.interactiveWait.promise,await this.initializeContext()}async initializeContext(){const t=this.getAttribute("data-cke-context-id"),e=JSON.parse(this.getAttribute("data-cke-language")),a=JSON.parse(this.getAttribute("data-cke-context")),{customTranslations:n,watchdogConfig:o,config:{plugins:s,...u}}=a,{loadedPlugins:l,hasPremium:c}=await tt(s??[]),d=[...await et(e,c),rt(n||{})].filter(b=>!S(b));this.contextPromise=(async()=>{const{ContextWatchdog:b,Context:k}=await import("ckeditor5"),v=new b(k,{crashNumberLimit:10,...o});let p=R(u);return p=M([...d].reverse(),e.ui,p),await v.create({...p,language:e,plugins:l,...d.length&&{translations:d}}),v.on("itemError",(...C)=>{console.error("Context item error:",...C)}),v})();const w=await this.contextPromise;this.isConnected&&A.the.register(t,w)}async disconnectedCallback(){this.interactiveWait?.disconnect();const t=this.getAttribute("data-cke-context-id");this.style.display="none";try{await(await this.contextPromise)?.destroy()}finally{this.contextPromise=null,t&&A.the.hasItem(t)&&A.the.unregister(t)}}}class h extends Q{static the=new h}class nt extends HTMLElement{unmountEffect=null;interactiveWait;async connectedCallback(){await x(),this.interactiveWait=q(this),await this.interactiveWait.promise,await this.initializeEditable()}async initializeEditable(){this.hasAttribute("data-cke-editor-id")||this.setAttribute("data-cke-editor-id",F()[0]);const t=this.getAttribute("data-cke-editor-id"),e=this.getAttribute("data-cke-root-name"),a=JSON.parse(this.getAttribute("data-cke-root-attributes")||"{}"),n=this.getAttribute("data-cke-content"),o=Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"),10);if(!t||!e)throw new E("Editor ID or Root Name is missing.");this.style.display="block",this.unmountEffect=h.the.mountEffect(t,s=>{if(!this.isConnected)return;const{ui:u,editing:l,model:c}=s,m=this.querySelector("input"),d=c.document.getRoot(e);if(d?.isAttached()){if(n!==null){const p=s.getData({rootName:e});p&&p!==n&&s.setData({[e]:n})}S(a)||s.model.change(p=>{p.setAttributes(a,d)});return}s.addRoot(e,{isUndoable:!1,attributes:{...a},...n!==null&&{data:n}});const w=this.querySelector("[data-cke-editable-content]"),b=u.view.createEditable(e,w);u.addEditable(b),l.view.forceRender();const k=()=>{if(!c.document.getRoot(e)?.isAttached())return;const p=s.getData({rootName:e});m&&(m.value=p,m.dispatchEvent(new Event("input"))),this.dispatchEvent(new CustomEvent("change",{detail:{value:p}}))},v=L(o,k);return s.model.document.on("change:data",v),k(),()=>{if(s.model.document.off("change:data",v),s.state!=="destroyed"&&e){const p=s.model.document.getRoot(e);if(p&&"detachEditable"in s){try{s.ui.view.editables[e]&&s.detachEditable(p)}catch(C){console.error("Unable unmount editable from root:",C)}p.isAttached()&&s.detachRoot(e,!1)}}}})}disconnectedCallback(){this.interactiveWait?.disconnect(),this.style.display="none",this.unmountEffect?.(),this.unmountEffect=null}}async function xt({saveDebounceMs:r,editorId:t,targetElement:e}){const{Plugin:a}=await import("ckeditor5");return class extends a{static get pluginName(){return"DispatchEditorRootsChangeEvent"}afterInit(){const{editor:o}=this,s=L(r,this.dispatch);o.model.document.on("change:data",s),o.once("ready",this.dispatch)}dispatch=()=>{const{editor:o}=this;e.dispatchEvent(new g({editorId:t,editor:o,roots:Z(o)}))}}}class g extends CustomEvent{static EVENT_NAME="ckeditor5:change:data";constructor(t){super(g.EVENT_NAME,{detail:t,bubbles:!0})}}async function Dt(r){const{Plugin:t}=await import("ckeditor5");return class extends t{input=null;form=null;static get pluginName(){return"SyncEditorWithInput"}afterInit(){const{editor:a}=this,o=a.sourceElement.id.replace(/_editor$/,"");this.input=document.getElementById(`${o}_input`),this.input&&(a.model.document.on("change:data",L(r,()=>this.sync())),a.once("ready",this.sync),this.form=this.input.closest("form"),this.form?.addEventListener("submit",this.sync))}sync=()=>{if(this.input){const a=this.editor.getData();this.input.value=a,this.input.dispatchEvent(new Event("input",{bubbles:!0}))}};destroy(){this.form&&this.form.removeEventListener("submit",this.sync),this.input=null,this.form=null}}}class ot extends HTMLElement{editorPromise=null;interactiveWait;async connectedCallback(){await x(),this.interactiveWait=q(this),G("classic"),await this.interactiveWait.promise,await this.initializeEditor()}async initializeEditor(){const t=this.getAttribute("data-cke-editor-id");h.the.resetErrors(t);try{this.style.display="block",this.editorPromise=this.createEditor();const e=await this.editorPromise;this.isConnected&&(h.the.register(t,e),e.once("destroy",()=>{h.the.hasItem(t)&&h.the.unregister(t)}))}catch(e){console.error(`Error initializing CKEditor5 instance with ID "${t}":`,e),this.editorPromise=null,h.the.error(t,e)}}async disconnectedCallback(){this.interactiveWait?.disconnect(),this.style.display="none";try{const t=await this.editorPromise;if(!t)return;const e=It(t),a=Rt(t);e?e.state!=="unavailable"&&await e.context.remove(e.editorContextId):a?await a.destroy():await t.destroy()}finally{this.editorPromise=null}}async createEditor(){const t=this.getAttribute("data-cke-editor-id"),e=JSON.parse(this.getAttribute("data-cke-preset")),a=this.getAttribute("data-cke-context-id"),n=JSON.parse(this.getAttribute("data-cke-root-attributes")||"{}"),o=this.getAttribute("data-cke-editable-height")?Number.parseInt(this.getAttribute("data-cke-editable-height"),10):null,s=Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"),10),u=JSON.parse(this.getAttribute("data-cke-language")),l=this.hasAttribute("data-cke-watchdog"),c=JSON.parse(this.getAttribute("data-cke-content")),{customTranslations:m,editorType:d,licenseKey:w,watchdogConfig:b,config:{plugins:k,...v}}=e,p=await G(d),C=await(a?A.the.waitFor(a):null),U=async()=>{const{loadedPlugins:y,hasPremium:T}=await tt(k);y.push(await xt({saveDebounceMs:s,editorId:t,targetElement:this})),P(d)&&y.push(await Dt(s));const I=[...await et(u,T),rt(m||{})].filter(f=>!S(f));let O={...c,...X(t)};P(d)&&(O=O.main||"");const N=await(async()=>{let f=it(t);if(!f.main){const H=P(d)?["main"]:Object.keys(O);st(f,H)||(f=await Vt(t,H),O={...c,...X(t)})}P(d)&&"main"in f&&(f=f.main);let z=R(v);z=M([...I].reverse(),u.ui,z);const B={...z,initialData:O,licenseKey:w,plugins:y,language:u,...I.length&&{translations:I}};return!C||!(f instanceof HTMLElement)?p.create(f,B):(await At({context:C,element:f,creator:p,config:B})).editor})();return S(n)||N.model.change(f=>{f.setAttributes(n,N.model.document.getRoot())}),P(d)&&o&&Nt(N,o),N};if(l&&!C){const y=await St(U,b);return y.on("error",(T,{causesRestart:j})=>{if(j){const I=h.the.getItem(t);I&&(Ct(I),h.the.unregister(t))}}),y.on("restart",()=>{const T=y.editor;h.the.register(t,T)}),await y.create({}),y.editor}return U()}}function st(r,t){return t.every(e=>r[e])}async function Vt(r,t){return vt(()=>{const e=it(r);if(!st(e,t))throw new Error(`It looks like not all required root elements are present yet.
|
|
2
2
|
* If you want to wait for them, ensure they are registered before editor initialization.
|
|
3
3
|
* If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
|
|
4
|
-
Missing roots: ${t.filter(a=>!e[a]).join(", ")}.`);return e},{timeOutAfter:2e3,retryAfter:100})}class
|
|
4
|
+
Missing roots: ${t.filter(a=>!e[a]).join(", ")}.`);return e},{timeOutAfter:2e3,retryAfter:100})}class ct extends HTMLElement{unmountEffect=null;async connectedCallback(){await x();const t=this.getAttribute("data-cke-editor-id")||F()[0],e=this.getAttribute("data-cke-name");!t||!e||(this.style.display="block",this.unmountEffect=h.the.mountEffect(t,a=>{if(!this.isConnected)return;const{ui:n}=a,o=zt(e),s=n.view[o];if(!s)throw new E(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);return this.appendChild(s.element),()=>{this.innerHTML=""}}))}disconnectedCallback(){this.style.display="none",this.unmountEffect?.(),this.unmountEffect=null}}function zt(r){switch(r){case"toolbar":return"toolbar";case"menubar":return"menuBarView";default:return null}}const $t={"cke5-editor":ot,"cke5-context":Mt,"cke5-ui-part":ct,"cke5-editable":nt};function ut(){for(const[r,t]of Object.entries($t))window.customElements.get(r)||window.customElements.define(r,t)}function Wt(r){return D(r),{unmount(){}}}function lt(r,t){const e={pendingValue:null,lastSyncedValue:null},a=()=>{e.pendingValue=null},n=(o,s,u)=>{if(u||e.pendingValue===null)return;const l=t.getCurrentValue();t.isEqual(l,e.pendingValue)||t.applyValue(e.pendingValue),e.pendingValue=null};return r.model.document.on("change:data",a),r.ui.focusTracker.on("change:isFocused",n),{unmount(){r.model.document.off("change:data",a),r.ui.focusTracker.off("change:isFocused",n)},shouldNotify(o){return e.lastSyncedValue!==null&&t.isEqual(e.lastSyncedValue,o)?!1:(e.lastSyncedValue=o,!0)},setValue(o){if(r.ui.focusTracker.isFocused){e.pendingValue=o;return}e.lastSyncedValue!==null&&t.isEqual(e.lastSyncedValue,o)||(e.lastSyncedValue=o,t.applyValue(o))}}}function dt(){return{unmount(){},shouldNotify(r){return!1},setValue(r){}}}function mt(r,t){const e=new Set;return a=>{r.model.enqueueChange({isUndoable:!1},n=>{const o=r.model.document.getRoot(t);if(o){for(const s of e)a&&s in a||(n.removeAttribute(s,o),e.delete(s));for(const[s,u]of Object.entries(a??{}))n.setAttribute(s,u,o),e.add(s)}})}}function Lt(r,t){const e=r.getAttribute("data-cke-editor-id")??F()[0],a=r.getAttribute("data-cke-root-name")??"main";let n=!1,o=null,s=null,u=dt(),l=null;const c=m=>{if(!(m instanceof g)||m.detail.editorId!==e)return;const d=m.detail.roots[a];d!==void 0&&u.shouldNotify(d)&&t.invokeMethodAsync("OnChangeEditableData",s,d)};return o=h.the.mountEffect(e,m=>(s=globalThis.DotNet.createJSObjectReference(m),u=lt(m,{getCurrentValue:()=>m.getData({rootName:a})??"",applyValue:d=>m.setData({[a]:d}),isEqual:(d,w)=>d===w}),l=mt(m,a),()=>{u.unmount(),s&&(globalThis.DotNet?.disposeJSObjectReference(s),s=null),l=null})),document.body.addEventListener(g.EVENT_NAME,c),D(r),{unmount(){n||(document.body.removeEventListener(g.EVENT_NAME,c),o?.(),o=null,n=!0)},setValue:async m=>{n||(await h.the.waitFor(e),u.setValue(m))},setRootAttributes:async m=>{n||(await h.the.waitFor(e),l?.(m))}}}function _t(r,t){const e=r.getAttribute("data-cke-editor-id");let a=!1,n=null,o=dt(),s=null,u=null;const l=c=>{!(c instanceof g)||c.detail.editorId!==e||o.shouldNotify(c.detail.roots)&&t.invokeMethodAsync("OnChangeEditorData",u,c.detail.roots)};return n=h.the.mountEffect(e,c=>{u=globalThis.DotNet.createJSObjectReference(c),o=lt(c,{getCurrentValue:()=>Z(c),applyValue:d=>c.setData(d),isEqual:Et}),s=mt(c,"main");const m=(d,w,b)=>{const k=b?"OnEditorFocus":"OnEditorBlur";t.invokeMethodAsync(k,u)};return c.ui.focusTracker.on("change:isFocused",m),t.invokeMethodAsync("OnEditorReady",u),()=>{c.ui.focusTracker.off("change:isFocused",m),o.unmount(),u&&(globalThis.DotNet?.disposeJSObjectReference(u),u=null),s=null}}),document.body.addEventListener(g.EVENT_NAME,l),ut(),D(r),{setValue:async c=>{a||(await h.the.waitFor(e),o.setValue(c))},setRootAttributes:async c=>{a||(await h.the.waitFor(e),s?.(c))},unmount(){a||(document.body.removeEventListener(g.EVENT_NAME,l),n?.(),n=null,a=!0)},attachImageUploadAdapter:async()=>{a||h.the.mountEffect(e,c=>{qt(c,t)})}}}function qt(r,t){if(!r.plugins.has("FileRepository"))return;const e=r.plugins.get("FileRepository");e.createUploadAdapter=a=>{let n=!1;return{async upload(){const o=await a.file;if(n)throw new Error("Upload aborted.");const s=await Ft(o),u=await t.invokeMethodAsync("OnEditorImageUpload",{fileName:o.name,mimeType:o.type,payload:s});if(!u)throw new Error("OnImageUpload handler returned null. Make sure the OnImageUpload parameter is set on the <CKE5Editor> component.");return{default:u}},abort(){n=!0}}}}function Ft(r){return new Promise((t,e)=>{const a=new FileReader;a.onload=()=>{const n=a.result,o=n.split(",")[1]??n;t(o)},a.onerror=()=>e(a.error),a.readAsDataURL(r)})}function Ut(r){return D(r),{unmount(){}}}exports.CKEditor5BlazorError=E;exports.CKEditor5ChangeDataEvent=g;exports.ContextsRegistry=A;exports.CustomEditorPluginsRegistry=V;exports.EditableComponentElement=nt;exports.EditorComponentElement=ot;exports.EditorsRegistry=h;exports.UIPartComponentElement=ct;exports.createContextBlazorInterop=Wt;exports.createEditableBlazorInterop=Lt;exports.createEditorBlazorInterop=_t;exports.createUIPartBlazorInterop=Ut;exports.ensureEditorElementsRegistered=ut;
|
|
5
5
|
//# sourceMappingURL=index.cjs.map
|