ckeditor5-livewire 0.0.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.
Files changed (167) hide show
  1. package/dist/hooks/context/context.d.ts +39 -0
  2. package/dist/hooks/context/context.d.ts.map +1 -0
  3. package/dist/hooks/context/contexts-registry.d.ts +9 -0
  4. package/dist/hooks/context/contexts-registry.d.ts.map +1 -0
  5. package/dist/hooks/context/index.d.ts +4 -0
  6. package/dist/hooks/context/index.d.ts.map +1 -0
  7. package/dist/hooks/context/typings.d.ts +34 -0
  8. package/dist/hooks/context/typings.d.ts.map +1 -0
  9. package/dist/hooks/editable.d.ts +40 -0
  10. package/dist/hooks/editable.d.ts.map +1 -0
  11. package/dist/hooks/editor/custom-editor-plugins.d.ts +54 -0
  12. package/dist/hooks/editor/custom-editor-plugins.d.ts.map +1 -0
  13. package/dist/hooks/editor/editor.d.ts +69 -0
  14. package/dist/hooks/editor/editor.d.ts.map +1 -0
  15. package/dist/hooks/editor/editors-registry.d.ts +9 -0
  16. package/dist/hooks/editor/editors-registry.d.ts.map +1 -0
  17. package/dist/hooks/editor/index.d.ts +3 -0
  18. package/dist/hooks/editor/index.d.ts.map +1 -0
  19. package/dist/hooks/editor/plugins/index.d.ts +3 -0
  20. package/dist/hooks/editor/plugins/index.d.ts.map +1 -0
  21. package/dist/hooks/editor/plugins/livewire-sync.d.ts +19 -0
  22. package/dist/hooks/editor/plugins/livewire-sync.d.ts.map +1 -0
  23. package/dist/hooks/editor/plugins/sync-editor-with-input.d.ts +6 -0
  24. package/dist/hooks/editor/plugins/sync-editor-with-input.d.ts.map +1 -0
  25. package/dist/hooks/editor/typings.d.ts +99 -0
  26. package/dist/hooks/editor/typings.d.ts.map +1 -0
  27. package/dist/hooks/editor/utils/create-editor-in-context.d.ts +44 -0
  28. package/dist/hooks/editor/utils/create-editor-in-context.d.ts.map +1 -0
  29. package/dist/hooks/editor/utils/get-editor-roots-values.d.ts +9 -0
  30. package/dist/hooks/editor/utils/get-editor-roots-values.d.ts.map +1 -0
  31. package/dist/hooks/editor/utils/index.d.ts +12 -0
  32. package/dist/hooks/editor/utils/index.d.ts.map +1 -0
  33. package/dist/hooks/editor/utils/is-single-editing-like-editor.d.ts +9 -0
  34. package/dist/hooks/editor/utils/is-single-editing-like-editor.d.ts.map +1 -0
  35. package/dist/hooks/editor/utils/load-editor-constructor.d.ts +9 -0
  36. package/dist/hooks/editor/utils/load-editor-constructor.d.ts.map +1 -0
  37. package/dist/hooks/editor/utils/load-editor-plugins.d.ts +20 -0
  38. package/dist/hooks/editor/utils/load-editor-plugins.d.ts.map +1 -0
  39. package/dist/hooks/editor/utils/load-editor-translations.d.ts +14 -0
  40. package/dist/hooks/editor/utils/load-editor-translations.d.ts.map +1 -0
  41. package/dist/hooks/editor/utils/normalize-custom-translations.d.ts +11 -0
  42. package/dist/hooks/editor/utils/normalize-custom-translations.d.ts.map +1 -0
  43. package/dist/hooks/editor/utils/query-editor-editables.d.ts +34 -0
  44. package/dist/hooks/editor/utils/query-editor-editables.d.ts.map +1 -0
  45. package/dist/hooks/editor/utils/resolve-editor-config-elements-references.d.ts +9 -0
  46. package/dist/hooks/editor/utils/resolve-editor-config-elements-references.d.ts.map +1 -0
  47. package/dist/hooks/editor/utils/set-editor-editable-height.d.ts +9 -0
  48. package/dist/hooks/editor/utils/set-editor-editable-height.d.ts.map +1 -0
  49. package/dist/hooks/editor/utils/wrap-with-watchdog.d.ts +24 -0
  50. package/dist/hooks/editor/utils/wrap-with-watchdog.d.ts.map +1 -0
  51. package/dist/hooks/hook.d.ts +58 -0
  52. package/dist/hooks/hook.d.ts.map +1 -0
  53. package/dist/hooks/index.d.ts +5 -0
  54. package/dist/hooks/index.d.ts.map +1 -0
  55. package/dist/hooks/ui-part.d.ts +32 -0
  56. package/dist/hooks/ui-part.d.ts.map +1 -0
  57. package/dist/index.cjs +5 -0
  58. package/dist/index.cjs.map +1 -0
  59. package/dist/index.d.ts +1 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.mjs +1146 -0
  62. package/dist/index.mjs.map +1 -0
  63. package/dist/shared/async-registry.d.ts +131 -0
  64. package/dist/shared/async-registry.d.ts.map +1 -0
  65. package/dist/shared/camel-case.d.ts +8 -0
  66. package/dist/shared/camel-case.d.ts.map +1 -0
  67. package/dist/shared/debounce.d.ts +2 -0
  68. package/dist/shared/debounce.d.ts.map +1 -0
  69. package/dist/shared/deep-camel-case-keys.d.ts +8 -0
  70. package/dist/shared/deep-camel-case-keys.d.ts.map +1 -0
  71. package/dist/shared/filter-object-values.d.ts +9 -0
  72. package/dist/shared/filter-object-values.d.ts.map +1 -0
  73. package/dist/shared/index.d.ts +13 -0
  74. package/dist/shared/index.d.ts.map +1 -0
  75. package/dist/shared/is-empty-object.d.ts +2 -0
  76. package/dist/shared/is-empty-object.d.ts.map +1 -0
  77. package/dist/shared/is-plain-object.d.ts +8 -0
  78. package/dist/shared/is-plain-object.d.ts.map +1 -0
  79. package/dist/shared/map-object-values.d.ts +11 -0
  80. package/dist/shared/map-object-values.d.ts.map +1 -0
  81. package/dist/shared/once.d.ts +2 -0
  82. package/dist/shared/once.d.ts.map +1 -0
  83. package/dist/shared/timeout.d.ts +8 -0
  84. package/dist/shared/timeout.d.ts.map +1 -0
  85. package/dist/shared/uid.d.ts +7 -0
  86. package/dist/shared/uid.d.ts.map +1 -0
  87. package/dist/shared/wait-for.d.ts +20 -0
  88. package/dist/shared/wait-for.d.ts.map +1 -0
  89. package/dist/types/can-be-promise.type.d.ts +2 -0
  90. package/dist/types/can-be-promise.type.d.ts.map +1 -0
  91. package/dist/types/index.d.ts +3 -0
  92. package/dist/types/index.d.ts.map +1 -0
  93. package/dist/types/required-by.type.d.ts +2 -0
  94. package/dist/types/required-by.type.d.ts.map +1 -0
  95. package/package.json +40 -0
  96. package/src/hooks/context/context.test.ts +394 -0
  97. package/src/hooks/context/context.ts +116 -0
  98. package/src/hooks/context/contexts-registry.test.ts +10 -0
  99. package/src/hooks/context/contexts-registry.ts +10 -0
  100. package/src/hooks/context/index.ts +3 -0
  101. package/src/hooks/context/typings.ts +39 -0
  102. package/src/hooks/editable.test.ts +276 -0
  103. package/src/hooks/editable.ts +122 -0
  104. package/src/hooks/editor/custom-editor-plugins.test.ts +103 -0
  105. package/src/hooks/editor/custom-editor-plugins.ts +84 -0
  106. package/src/hooks/editor/editor.test.ts +782 -0
  107. package/src/hooks/editor/editor.ts +357 -0
  108. package/src/hooks/editor/editors-registry.test.ts +10 -0
  109. package/src/hooks/editor/editors-registry.ts +10 -0
  110. package/src/hooks/editor/index.ts +2 -0
  111. package/src/hooks/editor/plugins/index.ts +2 -0
  112. package/src/hooks/editor/plugins/livewire-sync.ts +85 -0
  113. package/src/hooks/editor/plugins/sync-editor-with-input.ts +76 -0
  114. package/src/hooks/editor/typings.ts +114 -0
  115. package/src/hooks/editor/utils/create-editor-in-context.ts +90 -0
  116. package/src/hooks/editor/utils/get-editor-roots-values.ts +16 -0
  117. package/src/hooks/editor/utils/index.ts +11 -0
  118. package/src/hooks/editor/utils/is-single-editing-like-editor.test.ts +40 -0
  119. package/src/hooks/editor/utils/is-single-editing-like-editor.ts +11 -0
  120. package/src/hooks/editor/utils/load-editor-constructor.test.ts +62 -0
  121. package/src/hooks/editor/utils/load-editor-constructor.ts +27 -0
  122. package/src/hooks/editor/utils/load-editor-plugins.test.ts +100 -0
  123. package/src/hooks/editor/utils/load-editor-plugins.ts +71 -0
  124. package/src/hooks/editor/utils/load-editor-translations.ts +233 -0
  125. package/src/hooks/editor/utils/normalize-custom-translations.test.ts +152 -0
  126. package/src/hooks/editor/utils/normalize-custom-translations.ts +18 -0
  127. package/src/hooks/editor/utils/query-editor-editables.ts +102 -0
  128. package/src/hooks/editor/utils/resolve-editor-config-elements-references.test.ts +93 -0
  129. package/src/hooks/editor/utils/resolve-editor-config-elements-references.ts +36 -0
  130. package/src/hooks/editor/utils/set-editor-editable-height.test.ts +131 -0
  131. package/src/hooks/editor/utils/set-editor-editable-height.ts +15 -0
  132. package/src/hooks/editor/utils/wrap-with-watchdog.test.ts +45 -0
  133. package/src/hooks/editor/utils/wrap-with-watchdog.ts +51 -0
  134. package/src/hooks/hook.ts +87 -0
  135. package/src/hooks/index.ts +21 -0
  136. package/src/hooks/ui-part.test.ts +161 -0
  137. package/src/hooks/ui-part.ts +80 -0
  138. package/src/index.ts +5 -0
  139. package/src/livewire.d.ts +42 -0
  140. package/src/shared/async-registry.test.ts +658 -0
  141. package/src/shared/async-registry.ts +308 -0
  142. package/src/shared/camel-case.test.ts +35 -0
  143. package/src/shared/camel-case.ts +11 -0
  144. package/src/shared/debounce.test.ts +72 -0
  145. package/src/shared/debounce.ts +16 -0
  146. package/src/shared/deep-camel-case-keys.test.ts +34 -0
  147. package/src/shared/deep-camel-case-keys.ts +26 -0
  148. package/src/shared/filter-object-values.test.ts +25 -0
  149. package/src/shared/filter-object-values.ts +17 -0
  150. package/src/shared/index.ts +12 -0
  151. package/src/shared/is-empty-object.test.ts +78 -0
  152. package/src/shared/is-empty-object.ts +3 -0
  153. package/src/shared/is-plain-object.test.ts +38 -0
  154. package/src/shared/is-plain-object.ts +15 -0
  155. package/src/shared/map-object-values.test.ts +29 -0
  156. package/src/shared/map-object-values.ts +19 -0
  157. package/src/shared/once.test.ts +116 -0
  158. package/src/shared/once.ts +12 -0
  159. package/src/shared/timeout.test.ts +65 -0
  160. package/src/shared/timeout.ts +13 -0
  161. package/src/shared/uid.test.ts +25 -0
  162. package/src/shared/uid.ts +8 -0
  163. package/src/shared/wait-for.test.ts +24 -0
  164. package/src/shared/wait-for.ts +56 -0
  165. package/src/types/can-be-promise.type.ts +1 -0
  166. package/src/types/index.ts +2 -0
  167. package/src/types/required-by.type.ts +1 -0
@@ -0,0 +1,34 @@
1
+ import { EditorId, EditorType } from '../typings';
2
+ /**
3
+ * Queries all editable elements within a specific editor instance.
4
+ *
5
+ * @param editorId The ID of the editor to query.
6
+ * @returns An object mapping editable names to their corresponding elements and initial values.
7
+ */
8
+ export declare function queryAllEditorEditables(editorId: EditorId): Record<string, EditableItem>;
9
+ /**
10
+ * Gets the initial root elements for the editor based on its type.
11
+ *
12
+ * @param editorId The editor's ID.
13
+ * @param type The type of the editor.
14
+ * @returns The root element(s) for the editor.
15
+ */
16
+ export declare function queryEditablesElements(editorId: EditorId, type: EditorType): HTMLElement | Record<string, HTMLElement>;
17
+ /**
18
+ * Gets the initial data for the roots of the editor. If the editor is a single editing-like editor,
19
+ * it retrieves the initial value from the element's attribute. Otherwise, it returns an object mapping
20
+ * editable names to their initial values.
21
+ *
22
+ * @param editorId The editor's ID.
23
+ * @param type The type of the editor.
24
+ * @returns The initial values for the editor's roots.
25
+ */
26
+ export declare function queryEditablesSnapshotContent(editorId: EditorId, type: EditorType): Record<string, string>;
27
+ /**
28
+ * Type representing an editable item within an editor.
29
+ */
30
+ export type EditableItem = {
31
+ element: HTMLElement;
32
+ content: string | null;
33
+ };
34
+ //# sourceMappingURL=query-editor-editables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-editor-editables.d.ts","sourceRoot":"","sources":["../../../../src/hooks/editor/utils/query-editor-editables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKvD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAaxF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,6CAgB1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,0BAkBjF;AAiBD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Resolves element references in configuration object.
3
+ * Looks for objects with { $element: "selector" } format and replaces them with actual DOM elements.
4
+ *
5
+ * @param obj - Configuration object to process
6
+ * @returns Processed configuration object with resolved element references
7
+ */
8
+ export declare function resolveEditorConfigElementReferences<T>(obj: T): T;
9
+ //# sourceMappingURL=resolve-editor-config-elements-references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-editor-config-elements-references.d.ts","sourceRoot":"","sources":["../../../../src/hooks/editor/utils/resolve-editor-config-elements-references.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CA4BjE"}
@@ -0,0 +1,9 @@
1
+ import { Editor } from 'ckeditor5';
2
+ /**
3
+ * Sets the height of the editable area in the CKEditor instance.
4
+ *
5
+ * @param instance - The CKEditor instance to modify.
6
+ * @param height - The height in pixels to set for the editable area.
7
+ */
8
+ export declare function setEditorEditableHeight(instance: Editor, height: number): void;
9
+ //# sourceMappingURL=set-editor-editable-height.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-editor-editable-height.d.ts","sourceRoot":"","sources":["../../../../src/hooks/editor/utils/set-editor-editable-height.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAM9E"}
@@ -0,0 +1,24 @@
1
+ import { Editor, EditorWatchdog } from 'ckeditor5';
2
+ /**
3
+ * Wraps an Editor creator with a watchdog for automatic recovery.
4
+ *
5
+ * @param Editor - The Editor creator to wrap.
6
+ * @returns The Editor creator wrapped with a watchdog.
7
+ */
8
+ export declare function wrapWithWatchdog(Editor: EditorCreator): Promise<{
9
+ watchdog: EditorWatchdog<Editor>;
10
+ Constructor: {
11
+ create: (...args: Parameters<(typeof Editor)["create"]>) => Promise<Editor>;
12
+ };
13
+ }>;
14
+ /**
15
+ * Unwraps the EditorWatchdog from the editor instance.
16
+ */
17
+ 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
+ //# sourceMappingURL=wrap-with-watchdog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-with-watchdog.d.ts","sourceRoot":"","sources":["../../../../src/hooks/editor/utils/wrap-with-watchdog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIxD;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,aAAa;;;0BAe9B,UAAU,CAAC,CAAA,OAAO,MAAM,EAAC,QAAQ,CAAC,CAAC;;GAOhE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAM1E;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { LivewireComponent, Wire } from '../livewire';
2
+ import { CanBePromise } from '../types';
3
+ /**
4
+ * An abstract class representing a class-based hook for Livewire components.
5
+ */
6
+ export declare abstract class ClassHook<T extends object = Record<string, unknown>> {
7
+ /**
8
+ * The Livewire component instance associated with this hook.
9
+ */
10
+ protected livewireComponent: LivewireComponent;
11
+ /**
12
+ * The current state of the hook.
13
+ */
14
+ state: ClassHookState;
15
+ constructor(
16
+ /**
17
+ * The Livewire component instance associated with this hook.
18
+ */
19
+ livewireComponent: LivewireComponent);
20
+ /**
21
+ * The ephemeral snapshot of the Livewire component.
22
+ */
23
+ get ephemeral(): T;
24
+ /**
25
+ * The root HTML element of the Livewire component.
26
+ */
27
+ get element(): HTMLElement;
28
+ /**
29
+ * The wire interface for the Livewire component.
30
+ */
31
+ get $wire(): Wire;
32
+ /**
33
+ * Checks if the hook is in the process of being destroyed.
34
+ */
35
+ isBeingDestroyed(): boolean;
36
+ /**
37
+ * Called when the hook has been mounted to the DOM.
38
+ */
39
+ abstract mounted(): CanBePromise<void>;
40
+ /**
41
+ * Called when the element has been removed from the DOM.
42
+ */
43
+ abstract destroyed(): CanBePromise<void>;
44
+ }
45
+ /**
46
+ * A type that represents the state of a class-based hook.
47
+ */
48
+ export type ClassHookState = 'mounting' | 'mounted' | 'destroying' | 'destroyed';
49
+ /**
50
+ * Registers a Livewire hook that watches initialization of components and manages their lifecycle.
51
+ *
52
+ * @param name - The name of the component to watch for.
53
+ * @param Hook - A class that extends `ClassHook` to handle component lifecycle events.
54
+ */
55
+ export declare function registerLivewireComponentHook(name: string, Hook: {
56
+ new (component: LivewireComponent): ClassHook<any>;
57
+ }): void;
58
+ //# sourceMappingURL=hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../src/hooks/hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,8BAAsB,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOtE;;OAEG;IACH,SAAS,CAAC,iBAAiB,EAAE,iBAAiB;IAThD;;OAEG;IACH,KAAK,EAAE,cAAc,CAAc;;IAGjC;;OAEG;IACO,iBAAiB,EAAE,iBAAiB;IAGhD;;OAEG;IACH,IAAI,SAAS,IAAI,CAAC,CAEjB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,IAAI,CAEhB;IAED;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;OAEG;IACH,QAAQ,CAAC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,SAAS,IAAI,YAAY,CAAC,IAAI,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,GAAG,WAAW,CAAC;AAEjF;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,KAAI,SAAS,EAAE,iBAAiB,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;CAAE,QAiBvH"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Registers all available Livewire component hooks.
3
+ */
4
+ export declare function registerLivewireComponentHooks(): void;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,wBAAgB,8BAA8B,SAI7C"}
@@ -0,0 +1,32 @@
1
+ import { ClassHook } from './hook';
2
+ /**
3
+ * UI Part hook for Livewire. It allows you to create UI parts for multi-root editors.
4
+ */
5
+ export declare class UIPartComponentHook extends ClassHook<Snapshot> {
6
+ /**
7
+ * The promise that resolves when the UI part is mounted.
8
+ */
9
+ private mountedPromise;
10
+ /**
11
+ * Mounts the UI part component.
12
+ */
13
+ mounted(): Promise<void>;
14
+ /**
15
+ * Destroys the UI part component. Unmounts UI parts from the editor.
16
+ */
17
+ destroyed(): Promise<void>;
18
+ }
19
+ /**
20
+ * A snapshot of the Livewire component's state relevant to the CKEditor5 UI part hook.
21
+ */
22
+ export type Snapshot = {
23
+ /**
24
+ * The ID of the editor instance this UI part belongs to.
25
+ */
26
+ editorId: string;
27
+ /**
28
+ * The name of the UI part (e.g., "toolbar", "menubar").
29
+ */
30
+ name: string;
31
+ };
32
+ //# sourceMappingURL=ui-part.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-part.d.ts","sourceRoot":"","sources":["../../src/hooks/ui-part.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,SAAS,CAAC,QAAQ,CAAC;IAC1D;;OAEG;IACH,OAAO,CAAC,cAAc,CAA8B;IAEpD;;OAEG;IACY,OAAO;IAmBtB;;OAEG;IACY,SAAS;CAWzB;AAkBD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var K=Object.create;var j=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var Z=(i,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of X(t))!Q.call(i,n)&&n!==r&&j(i,n,{get:()=>t[n],enumerable:!(a=Y(t,n))||a.enumerable});return i};var e=(i,t,r)=>(r=i!=null?K(J(i)):{},Z(t||!i||!i.__esModule?j(r,"default",{value:i,enumerable:!0}):r,i));class v{constructor(t){this.livewireComponent=t}state="mounting";get ephemeral(){return this.livewireComponent.ephemeral}get element(){return this.livewireComponent.el}get $wire(){return this.livewireComponent.$wire}isBeingDestroyed(){return["destroyed","destroying"].includes(this.state)}}function tt(i,t){window.Livewire.hook("component.init",async({component:r,cleanup:a})=>{if(r.name!==i)return;const n=new t(r);a(async()=>{n.state="destroying",await n.destroyed(),n.state="destroyed"}),await n.mounted(),n.state="mounted"})}class q{items=new Map;initializationErrors=new Map;pendingCallbacks=new Map;watchers=new Set;execute(t,r,a){const n=this.items.get(t),o=this.initializationErrors.get(t);return o?(a?.(o),Promise.reject(o)):n?Promise.resolve(r(n)):new Promise((s,c)=>{const u=this.getPendingCallbacks(t);u.success.push(async l=>{s(await r(l))}),a?u.error.push(a):u.error.push(c)})}register(t,r){if(this.items.has(t))throw new Error(`Item with ID "${t}" is already registered.`);this.resetErrors(t),this.items.set(t,r);const a=this.pendingCallbacks.get(t);a&&(a.success.forEach(n=>n(r)),this.pendingCallbacks.delete(t)),this.registerAsDefault(t,r),this.notifyWatchers()}error(t,r){this.items.delete(t),this.initializationErrors.set(t,r);const a=this.pendingCallbacks.get(t);a&&(a.error.forEach(n=>n(r)),this.pendingCallbacks.delete(t)),this.initializationErrors.size===1&&!this.items.size&&this.error(null,r),this.notifyWatchers()}resetErrors(t){const{initializationErrors:r}=this;r.has(null)&&r.get(null)===r.get(t)&&r.delete(null),r.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){return new Promise((r,a)=>{this.execute(t,r,a)})}async destroyAll(){const t=Array.from(new Set(this.items.values())).map(r=>r.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)}notifyWatchers(){this.watchers.forEach(t=>t(new Map(this.items),new Map(this.initializationErrors)))}getPendingCallbacks(t){let r=this.pendingCallbacks.get(t);return r||(r={success:[],error:[]},this.pendingCallbacks.set(t,r)),r}registerAsDefault(t,r){this.items.size===1&&t!==null&&this.register(null,r)}}function $(i,t){let r=null;return(...a)=>{r&&clearTimeout(r),r=setTimeout(()=>{t(...a)},i)}}function et(i,t){const r=Object.entries(i).filter(([a,n])=>t(n,a));return Object.fromEntries(r)}function B(i){return Object.keys(i).length===0&&i.constructor===Object}function z(i,t){const r=Object.entries(i).map(([a,n])=>[a,t(n,a)]);return Object.fromEntries(r)}function rt(){return Math.random().toString(36).substring(2)}function it(i,{timeOutAfter:t=500,retryAfter:r=100}={}){return new Promise((a,n)=>{const o=Date.now();let s=null;const c=setTimeout(()=>{n(s??new Error("Timeout"))},t),u=async()=>{try{const l=await i();clearTimeout(c),a(l)}catch(l){s=l,Date.now()-o>t?n(l):setTimeout(u,r)}};u()})}const I=Symbol.for("context-editor-watchdog");async function at({element:i,context:t,creator:r,config:a}){const n=rt();await t.add({creator:(u,l)=>r.create(u,l),id:n,sourceElementOrData:i,type:"editor",config:a});const o=t.getItem(n),s={state:"available",editorContextId:n,context:t};o[I]=s;const c=t.destroy.bind(t);return t.destroy=async()=>(s.state="unavailable",c()),{...s,editor:o}}function nt(i){return I in i?i[I]:null}function st(i){return i.model.document.getRootNames().reduce((r,a)=>(r[a]=i.getData({rootName:a}),r),Object.create({}))}function k(i){return["inline","classic","balloon","decoupled"].includes(i)}async function ot(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 Error(`Unsupported editor type: ${i}`);return a}class M{static the=new M;plugins=new Map;constructor(){}register(t,r){if(this.plugins.has(t))throw new Error(`Plugin with name "${t}" is already registered.`);return this.plugins.set(t,r),this.unregister.bind(this,t)}unregister(t){if(!this.plugins.has(t))throw new Error(`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 F(i){const t=await import("ckeditor5");let r=null;const a=i.map(async n=>{const o=await M.the.get(n);if(o)return o;const{[n]:s}=t;if(s)return s;if(!r)try{r=await import("ckeditor5-premium-features")}catch(u){console.error(`Failed to load premium package: ${u}`)}const{[n]:c}=r||{};if(c)return c;throw new Error(`Plugin "${n}" not found in base or premium packages.`)});return{loadedPlugins:await Promise.all(a),hasPremium:!!r}}async function N(i,t){const r=[i.ui,i.content];return await Promise.all([H("ckeditor5",r),t&&H("ckeditor5-premium-features",r)].filter(n=>!!n)).then(n=>n.flat())}async function H(i,t){return await Promise.all(t.filter(r=>r!=="en").map(async r=>{const a=await ct(i,r);return a?.default??a}).filter(Boolean))}async function ct(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(r){return console.error(`Failed to load translation for ${i}/${t}:`,r),null}}function V(i){return z(i,t=>({dictionary:t}))}function S(i){return window.Livewire.all().filter(({name:t,ephemeral:r})=>t==="ckeditor5-editable"&&r.editorId===i).reduce((t,{ephemeral:r,el:a})=>({...t,[r.rootName]:{element:a.querySelector("[data-cke-editable-content]"),content:r.content}}),Object.create({}))}function T(i,t){if(t==="decoupled"){const{element:a}=U(i);return a}if(k(t))return document.getElementById(`${i}_editor`);const r=S(i);return z(r,({element:a})=>a)}function W(i,t){if(t==="decoupled"){const{content:n}=U(i);if(typeof n=="string")return{main:n}}const r=S(i),a=z(r,({content:n})=>n);return et(a,n=>typeof n=="string")}function U(i){const t=S(i).main;if(!t)throw new Error(`No "main" editable found for editor with ID "${i}".`);return t}function O(i){if(!i||typeof i!="object")return i;if(Array.isArray(i))return i.map(a=>O(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 r=Object.create(null);for(const[a,n]of Object.entries(i))r[a]=O(n);return r}function ut(i,t){const{editing:r}=i;r.view.change(a=>{a.setStyle("height",`${t}px`,r.view.document.getRoot())})}const D=Symbol.for("elixir-editor-watchdog");async function lt(i){const{EditorWatchdog:t}=await import("ckeditor5"),r=new t(i);return r.setCreator(async(...a)=>{const n=await i.create(...a);return n[D]=r,n}),{watchdog:r,Constructor:{create:async(...a)=>(await r.create(...a),r.editor)}}}function mt(i){return D in i?i[D]:null}class g extends q{static the=new g}class dt extends v{contextPromise=null;async mounted(){const{contextId:t,language:r,context:a}=this.ephemeral,{customTranslations:n,watchdogConfig:o,config:{plugins:s,...c}}=a,{loadedPlugins:u,hasPremium:l}=await F(s??[]),m=[...await N(r,l),V(n||{})].filter(p=>!B(p));this.contextPromise=(async()=>{const{ContextWatchdog:p,Context:C}=await import("ckeditor5"),h=new p(C,{crashNumberLimit:10,...o});return await h.create({...c,language:r,plugins:u,...m.length&&{translations:m}}),h.on("itemError",(...y)=>{console.error("Context item error:",...y)}),h})();const f=await this.contextPromise;this.isBeingDestroyed()||g.the.register(t,f)}async destroyed(){const{contextId:t}=this.ephemeral;this.element.style.display="none";try{await(await this.contextPromise)?.destroy()}finally{this.contextPromise=null,g.the.hasItem(t)&&g.the.unregister(t)}}}class w extends q{static the=new w}class pt extends v{editorPromise=null;mounted(){const{editorId:t,rootName:r,content:a,saveDebounceMs:n}=this.ephemeral,o=this.element.querySelector("input");this.editorPromise=w.the.execute(t,s=>{const{ui:c,editing:u,model:l}=s;if(l.document.getRoot(r)){if(a!==null){const p=s.getData({rootName:r});p&&p!==a&&s.setData({[r]:a})}return s}s.addRoot(r,{isUndoable:!1,...a!==null&&{data:a}});const P=this.element.querySelector("[data-cke-editable-content]"),m=c.view.createEditable(r,P);c.addEditable(m),u.view.forceRender();const f=()=>{const p=s.getData({rootName:r});o&&(o.value=p),this.$wire.set("content",p)};return s.model.document.on("change:data",$(n,f)),f(),s})}async destroyed(){const{rootName:t}=this.ephemeral;this.element.style.display="none";const r=await this.editorPromise;if(this.editorPromise=null,r&&r.state!=="destroyed"){const a=r.model.document.getRoot(t);a&&"detachEditable"in r&&(r.detachEditable(a),r.detachRoot(t,!1))}}}async function wt({emit:i,saveDebounceMs:t,$wire:r}){const{Plugin:a}=await import("ckeditor5");return class extends a{static get pluginName(){return"LivewireSync"}init(){i.change&&this.setupTypingContentPush(),i.focus&&this.setupFocusableEventPush()}setupTypingContentPush(){const{model:o}=this.editor,s=()=>{r.set("content",this.getEditorRootsValues())};o.document.on("change:data",$(t,s)),s()}setupFocusableEventPush(){const{ui:o}=this.editor,s=()=>{r.set("focused",o.focusTracker.isFocused),r.set("content",this.getEditorRootsValues())};o.focusTracker.on("change:isFocused",s)}getEditorRootsValues(){return st(this.editor)}}}async function ht(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=()=>{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 ft extends v{editorPromise=null;async mounted(){const{editorId:t}=this.ephemeral;w.the.resetErrors(t);try{this.editorPromise=this.createEditor();const r=await this.editorPromise;this.isBeingDestroyed()||(w.the.register(t,r),r.once("destroy",()=>{w.the.hasItem(t)&&w.the.unregister(t)}))}catch(r){this.editorPromise=null,w.the.error(t,r)}}async destroyed(){this.element.style.display="none";try{const t=await this.editorPromise;if(!t)return;const r=nt(t),a=mt(t);r?r.state!=="unavailable"&&await r.context.remove(r.editorContextId):a?await a.destroy():await t.destroy()}finally{this.editorPromise=null}}async createEditor(){const{preset:t,editorId:r,contextId:a,editableHeight:n,emit:o,saveDebounceMs:s,language:c,watchdog:u,content:l}=this.ephemeral,{customTranslations:P,editorType:m,licenseKey:f,config:{plugins:p,...C}}=t;let h=await ot(m);const y=await(a?g.the.waitFor(a):null);if(u&&!y){const d=await lt(h);({Constructor:h}=d),d.watchdog.on("restart",()=>{const b=d.watchdog.editor;this.editorPromise=Promise.resolve(b),w.the.register(r,b)})}const{loadedPlugins:x,hasPremium:G}=await F(p);x.push(await wt({emit:o,saveDebounceMs:s,$wire:this.$wire})),k(m)&&x.push(await ht(s));const R=[...await N(c,G),V(P||{})].filter(d=>!B(d));let E={...l,...W(r,m)};k(m)&&(E=E.main||"");const L=await(async()=>{let d=T(r,m);if(yt(d,m)){const A=Object.keys(E);_(d,A)||(d=await gt(r,m,A),E={...l,...W(r,m)})}const b={...O(C),initialData:E,licenseKey:f,plugins:x,language:c,...R.length&&{translations:R}};return!y||!(d instanceof HTMLElement)?h.create(d,b):(await at({context:y,element:d,creator:h,config:b})).editor})();return k(m)&&n&&ut(L,n),L}}function _(i,t){return t.every(r=>i[r])}async function gt(i,t,r){return await it(()=>{const a=T(i,t);if(!_(a,r))throw new Error(`It looks like not all required root elements are present yet.
2
+ * If you want to wait for them, ensure they are registered before editor initialization.
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: ${r.filter(n=>!a[n]).join(", ")}.`);return!0},{timeOutAfter:2e3,retryAfter:100}),T(i,t)}function yt(i,t){return!k(t)&&typeof i=="object"&&!(i instanceof HTMLElement)}class Et extends v{mountedPromise=null;async mounted(){const{editorId:t,name:r}=this.ephemeral;this.mountedPromise=w.the.execute(t,a=>{const{ui:n}=a,o=bt(r),s=n.view[o];if(!s){console.error(`Unknown UI part name: "${r}". Supported names are "toolbar" and "menubar".`);return}this.element.appendChild(s.element)})}async destroyed(){this.element.style.display="none",await this.mountedPromise,this.mountedPromise=null,this.element.innerHTML=""}}function bt(i){switch(i){case"toolbar":return"toolbar";case"menubar":return"menuBarView";default:return null}}const kt={ckeditor5:ft,"ckeditor5-context":dt,"ckeditor5-ui-part":Et,"ckeditor5-editable":pt};function Pt(){for(const[i,t]of Object.entries(kt))tt(i,t)}Pt();
5
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/hooks/hook.ts","../src/shared/async-registry.ts","../src/shared/debounce.ts","../src/shared/filter-object-values.ts","../src/shared/is-empty-object.ts","../src/shared/map-object-values.ts","../src/shared/uid.ts","../src/shared/wait-for.ts","../src/hooks/editor/utils/create-editor-in-context.ts","../src/hooks/editor/utils/get-editor-roots-values.ts","../src/hooks/editor/utils/is-single-editing-like-editor.ts","../src/hooks/editor/utils/load-editor-constructor.ts","../src/hooks/editor/custom-editor-plugins.ts","../src/hooks/editor/utils/load-editor-plugins.ts","../src/hooks/editor/utils/load-editor-translations.ts","../src/hooks/editor/utils/normalize-custom-translations.ts","../src/hooks/editor/utils/query-editor-editables.ts","../src/hooks/editor/utils/resolve-editor-config-elements-references.ts","../src/hooks/editor/utils/set-editor-editable-height.ts","../src/hooks/editor/utils/wrap-with-watchdog.ts","../src/hooks/context/contexts-registry.ts","../src/hooks/context/context.ts","../src/hooks/editor/editors-registry.ts","../src/hooks/editable.ts","../src/hooks/editor/plugins/livewire-sync.ts","../src/hooks/editor/plugins/sync-editor-with-input.ts","../src/hooks/editor/editor.ts","../src/hooks/ui-part.ts","../src/hooks/index.ts","../src/index.ts"],"sourcesContent":["import type { LivewireComponent, Wire } from '../livewire';\nimport type { CanBePromise } from '../types';\n\n/**\n * An abstract class representing a class-based hook for Livewire components.\n */\nexport abstract class ClassHook<T extends object = Record<string, unknown>> {\n /**\n * The current state of the hook.\n */\n state: ClassHookState = 'mounting';\n\n constructor(\n /**\n * The Livewire component instance associated with this hook.\n */\n protected livewireComponent: LivewireComponent,\n ) {}\n\n /**\n * The ephemeral snapshot of the Livewire component.\n */\n get ephemeral(): T {\n return this.livewireComponent.ephemeral as T;\n }\n\n /**\n * The root HTML element of the Livewire component.\n */\n get element(): HTMLElement {\n return this.livewireComponent.el;\n }\n\n /**\n * The wire interface for the Livewire component.\n */\n get $wire(): Wire {\n return this.livewireComponent.$wire;\n }\n\n /**\n * Checks if the hook is in the process of being destroyed.\n */\n isBeingDestroyed(): boolean {\n return ['destroyed', 'destroying'].includes(this.state);\n }\n\n /**\n * Called when the hook has been mounted to the DOM.\n */\n abstract mounted(): CanBePromise<void>;\n\n /**\n * Called when the element has been removed from the DOM.\n */\n abstract destroyed(): CanBePromise<void>;\n}\n\n/**\n * A type that represents the state of a class-based hook.\n */\nexport type ClassHookState = 'mounting' | 'mounted' | 'destroying' | 'destroyed';\n\n/**\n * Registers a Livewire hook that watches initialization of components and manages their lifecycle.\n *\n * @param name - The name of the component to watch for.\n * @param Hook - A class that extends `ClassHook` to handle component lifecycle events.\n */\nexport function registerLivewireComponentHook(name: string, Hook: { new(component: LivewireComponent): ClassHook<any>; }) {\n window.Livewire.hook('component.init', async ({ component, cleanup }) => {\n if (component.name !== name) {\n return;\n }\n\n const instance = new Hook(component);\n\n cleanup(async () => {\n instance.state = 'destroying';\n await instance.destroyed();\n instance.state = 'destroyed';\n });\n\n await instance.mounted();\n instance.state = 'mounted';\n });\n}\n","/**\n * Generic async registry for objects with an async destroy method.\n * Provides a way to register, unregister, and execute callbacks on objects by ID.\n */\nexport class AsyncRegistry<T extends Destructible> {\n /**\n * Map of registered items.\n */\n private readonly items = new Map<RegistryId | null, T>();\n\n /**\n * Map of initialization errors for items that failed to register.\n */\n private readonly initializationErrors = new Map<RegistryId | null, any>();\n\n /**\n * Map of pending callbacks waiting for items to be registered or fail.\n */\n private readonly pendingCallbacks = new Map<RegistryId | null, PendingCallbacks<T>>();\n\n /**\n * Set of watchers that observe changes to the registry.\n */\n private readonly watchers = new Set<RegistryWatcher<T>>();\n\n /**\n * Executes a function on an item.\n * If the item is not yet registered, it will wait for it to be registered.\n *\n * @param id The ID of the item.\n * @param onSuccess The function to execute.\n * @param onError Optional error callback.\n * @returns A promise that resolves with the result of the function.\n */\n execute<R, E extends T = T>(\n id: RegistryId | null,\n onSuccess: (item: E) => R,\n onError?: (error: any) => void,\n ): Promise<Awaited<R>> {\n const item = this.items.get(id);\n const error = this.initializationErrors.get(id);\n\n // If error exists and callback provided, invoke it immediately.\n if (error) {\n onError?.(error);\n return Promise.reject(error);\n }\n\n // If item exists, invoke callback immediately (synchronously via Promise.resolve).\n if (item) {\n return Promise.resolve(onSuccess(item as E));\n }\n\n // Item not ready yet - queue the callbacks.\n return new Promise((resolve, reject) => {\n const pending = this.getPendingCallbacks(id);\n\n pending.success.push(async (item: T) => {\n resolve(await onSuccess(item as E));\n });\n\n if (onError) {\n pending.error.push(onError);\n }\n else {\n pending.error.push(reject);\n }\n });\n }\n\n /**\n * Registers an item.\n *\n * @param id The ID of the item.\n * @param item The item instance.\n */\n register(id: RegistryId | null, item: T): void {\n if (this.items.has(id)) {\n throw new Error(`Item with ID \"${id}\" is already registered.`);\n }\n\n this.resetErrors(id);\n this.items.set(id, item);\n\n // Execute all pending callbacks for this item (synchronously).\n const pending = this.pendingCallbacks.get(id);\n\n if (pending) {\n pending.success.forEach(callback => callback(item));\n this.pendingCallbacks.delete(id);\n }\n\n // Register the first item as the default item (null ID).\n this.registerAsDefault(id, item);\n this.notifyWatchers();\n }\n\n /**\n * Registers an error for an item.\n *\n * @param id The ID of the item.\n * @param error The error to register.\n */\n error(id: RegistryId | null, error: any): void {\n this.items.delete(id);\n this.initializationErrors.set(id, error);\n\n // Execute all pending error callbacks for this item.\n const pending = this.pendingCallbacks.get(id);\n\n if (pending) {\n pending.error.forEach(callback => callback(error));\n this.pendingCallbacks.delete(id);\n }\n\n // Set as default error if this is the first error and no items exist.\n if (this.initializationErrors.size === 1 && !this.items.size) {\n this.error(null, error);\n }\n\n // Notify watchers about the error state.\n this.notifyWatchers();\n }\n\n /**\n * Resets errors for an item.\n *\n * @param id The ID of the item.\n */\n resetErrors(id: RegistryId | null): void {\n const { initializationErrors } = this;\n\n // Clear default error if it's the same as the specific error.\n if (initializationErrors.has(null) && initializationErrors.get(null) === initializationErrors.get(id)) {\n initializationErrors.delete(null);\n }\n\n initializationErrors.delete(id);\n }\n\n /**\n * Un-registers an item.\n *\n * @param id The ID of the item.\n */\n unregister(id: RegistryId | null): void {\n if (!this.items.has(id)) {\n throw new Error(`Item with ID \"${id}\" is not registered.`);\n }\n\n // If unregistering the default item, clear it.\n if (id && this.items.get(null) === this.items.get(id)) {\n this.unregister(null);\n }\n\n this.items.delete(id);\n this.pendingCallbacks.delete(id);\n\n this.notifyWatchers();\n }\n\n /**\n * Gets all registered items.\n *\n * @returns An array of all registered items.\n */\n getItems(): T[] {\n return Array.from(this.items.values());\n }\n\n /**\n * Checks if an item with the given ID is registered.\n *\n * @param id The ID of the item.\n * @returns `true` if the item is registered, `false` otherwise.\n */\n hasItem(id: RegistryId | null): boolean {\n return this.items.has(id);\n }\n\n /**\n * Gets a promise that resolves with the item instance for the given ID.\n * If the item is not registered yet, it will wait for it to be registered.\n *\n * @param id The ID of the item.\n * @returns A promise that resolves with the item instance.\n */\n waitFor<E extends T = T>(id: RegistryId | null): Promise<E> {\n return new Promise<E>((resolve, reject) => {\n void this.execute(id, resolve as (value: E) => void, reject);\n });\n }\n\n /**\n * Destroys all registered items and clears the registry.\n * This will call the `destroy` method on each item.\n */\n async destroyAll() {\n const promises = (\n Array\n .from(new Set(this.items.values()))\n .map(item => item.destroy())\n );\n\n this.items.clear();\n this.pendingCallbacks.clear();\n\n await Promise.all(promises);\n\n this.notifyWatchers();\n }\n\n /**\n * Registers a watcher that will be called whenever the registry changes.\n *\n * @param watcher The watcher function to register.\n * @returns A function to unregister the watcher.\n */\n watch(watcher: RegistryWatcher<T>): () => void {\n this.watchers.add(watcher);\n\n // Call the watcher immediately with the current state.\n watcher(\n new Map(this.items),\n new Map(this.initializationErrors),\n );\n\n return this.unwatch.bind(this, watcher);\n }\n\n /**\n * Un-registers a watcher.\n *\n * @param watcher The watcher function to unregister.\n */\n unwatch(watcher: RegistryWatcher<T>): void {\n this.watchers.delete(watcher);\n }\n\n /**\n * Notifies all watchers about changes to the registry.\n */\n private notifyWatchers(): void {\n this.watchers.forEach(\n watcher => watcher(\n new Map(this.items),\n new Map(this.initializationErrors),\n ),\n );\n }\n\n /**\n * Gets or creates pending callbacks for a specific ID.\n *\n * @param id The ID of the item.\n * @returns The pending callbacks structure.\n */\n private getPendingCallbacks(id: RegistryId | null): PendingCallbacks<T> {\n let pending = this.pendingCallbacks.get(id);\n\n if (!pending) {\n pending = { success: [], error: [] };\n this.pendingCallbacks.set(id, pending);\n }\n\n return pending;\n }\n\n /**\n * Registers an item as the default (null ID) item if it's the first one.\n *\n * @param id The ID of the item being registered.\n * @param item The item instance.\n */\n private registerAsDefault(id: RegistryId | null, item: T): void {\n if (this.items.size === 1 && id !== null) {\n this.register(null, item);\n }\n }\n}\n\n/**\n * Interface for objects that can be destroyed.\n */\nexport type Destructible = {\n destroy: () => Promise<any>;\n};\n\n/**\n * Identifier of the registry item.\n */\ntype RegistryId = string;\n\n/**\n * Structure holding pending success and error callbacks for an item.\n */\ntype PendingCallbacks<T> = {\n success: Array<(item: T) => void>;\n error: Array<(error: Error) => void>;\n};\n\n/**\n * Callback type for watching registry changes.\n */\ntype RegistryWatcher<T> = (\n items: Map<RegistryId | null, T>,\n errors: Map<RegistryId | null, Error>,\n) => void;\n","export function debounce<T extends (...args: any[]) => any>(\n delay: number,\n callback: T,\n): (...args: Parameters<T>) => void {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n return (...args: Parameters<T>): void => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n callback(...args);\n }, delay);\n };\n}\n","/**\n * Filters the values of an object based on a provided filter function.\n *\n * @param obj The object to filter.\n * @param filter The filter function that determines whether a value should be included.\n * @returns A new object containing only the key-value pairs that passed the filter.\n */\nexport function filterObjectValues<T>(\n obj: Record<string, T>,\n filter: (value: T, key: string) => boolean,\n): Record<string, T> {\n const filteredEntries = Object\n .entries(obj)\n .filter(([key, value]) => filter(value, key));\n\n return Object.fromEntries(filteredEntries);\n}\n","export function isEmptyObject(obj: Record<string, unknown>): boolean {\n return Object.keys(obj).length === 0 && obj.constructor === Object;\n}\n","/**\n * Maps the values of an object using a provided mapper function.\n *\n * @param obj The object whose values will be mapped.\n * @param mapper A function that takes a value and its key, and returns a new value.\n * @template T The type of the original values in the object.\n * @template U The type of the new values in the object.\n * @returns A new object with the same keys as the original, but with values transformed by\n */\nexport function mapObjectValues<T, U>(\n obj: Record<string, T>,\n mapper: (value: T, key: string) => U,\n): Record<string, U> {\n const mappedEntries = Object\n .entries(obj)\n .map(([key, value]) => [key, mapper(value, key)] as const);\n\n return Object.fromEntries(mappedEntries);\n}\n","/**\n * Generates a unique identifier string\n *\n * @returns Random string that can be used as unique identifier\n */\nexport function uid() {\n return Math.random().toString(36).substring(2);\n}\n","import type { CanBePromise } from '../types';\n\n/**\n * Waits for the provided callback to succeed. The callback is executed multiple times until it succeeds or the timeout is reached.\n * It's executed immediately and then with a delay defined by the `retry` option.\n *\n * @param callback The callback to execute.\n * @param config Configuration for the function.\n * @param config.timeOutAfter The maximum time to wait for the callback to succeed, in milliseconds. Default is 500ms.\n * @param config.retryAfter The time to wait between retries, in milliseconds. Default is 100ms.\n * @returns A promise that resolves when the callback succeeds.\n */\nexport function waitFor<R>(\n callback: () => CanBePromise<R>,\n {\n timeOutAfter = 500,\n retryAfter = 100,\n }: WaitForConfig = {},\n): Promise<R> {\n return new Promise<R>((resolve, reject) => {\n const startTime = Date.now();\n let lastError: Error | null = null;\n\n const timeoutTimerId = setTimeout(() => {\n reject(lastError ?? new Error('Timeout'));\n }, timeOutAfter);\n\n const tick = async () => {\n try {\n const result = await callback();\n clearTimeout(timeoutTimerId);\n resolve(result);\n }\n catch (err: any) {\n lastError = err;\n\n if (Date.now() - startTime > timeOutAfter) {\n reject(err);\n }\n else {\n setTimeout(tick, retryAfter);\n }\n }\n };\n\n void tick();\n });\n}\n\n/**\n * Configuration for the `waitFor` function.\n */\nexport type WaitForConfig = {\n timeOutAfter?: number;\n retryAfter?: number;\n};\n","import type { Context, ContextWatchdog, Editor, EditorConfig } from 'ckeditor5';\n\nimport type { EditorCreator } from './wrap-with-watchdog';\n\nimport { uid } from '../../../shared';\n\n/**\n * Symbol used to store the context watchdog on the editor instance.\n * Internal use only.\n */\nconst CONTEXT_EDITOR_WATCHDOG_SYMBOL = Symbol.for('context-editor-watchdog');\n\n/**\n * Creates a CKEditor 5 editor instance within a given context watchdog.\n *\n * @param params Parameters for editor creation.\n * @param params.element The DOM element or data for the editor.\n * @param params.context The context watchdog instance.\n * @param params.creator The editor creator utility.\n * @param params.config The editor configuration object.\n * @returns The created editor instance.\n */\nexport async function createEditorInContext({ element, context, creator, config }: Attrs) {\n const editorContextId = uid();\n\n await context.add({\n creator: (_element, _config) => creator.create(_element, _config),\n id: editorContextId,\n sourceElementOrData: element,\n type: 'editor',\n config,\n });\n\n const editor = context.getItem(editorContextId) as Editor;\n const contextDescriptor: EditorContextDescriptor = {\n state: 'available',\n editorContextId,\n context,\n };\n\n (editor as any)[CONTEXT_EDITOR_WATCHDOG_SYMBOL] = contextDescriptor;\n\n // Destroying of context is async. There can be situation when the destroy of the context\n // and the destroy of the editor is called in parallel. It often happens during unmounting of\n // phoenix hooks. Let's make sure that descriptor informs other components, that context is being\n // destroyed.\n const originalDestroy = context.destroy.bind(context);\n context.destroy = async () => {\n contextDescriptor.state = 'unavailable';\n return originalDestroy();\n };\n\n return {\n ...contextDescriptor,\n editor,\n };\n}\n\n/**\n * Retrieves the context watchdog from an editor instance, if available.\n *\n * @param editor The editor instance.\n * @returns The context watchdog or null if not found.\n */\nexport function unwrapEditorContext(editor: Editor): EditorContextDescriptor | null {\n if (CONTEXT_EDITOR_WATCHDOG_SYMBOL in editor) {\n return (editor as any)[CONTEXT_EDITOR_WATCHDOG_SYMBOL];\n }\n\n return null;\n}\n\n/**\n * Parameters for creating an editor in a context.\n */\ntype Attrs = {\n context: ContextWatchdog<Context>;\n creator: EditorCreator;\n element: HTMLElement;\n config: EditorConfig;\n};\n\n/**\n * Descriptor for an editor context.\n */\ntype EditorContextDescriptor = {\n state: 'available' | 'unavailable';\n editorContextId: string;\n context: ContextWatchdog<Context>;\n};\n","import type { Editor } from 'ckeditor5';\n\n/**\n * Gets the values of the editor's roots.\n *\n * @param editor The CKEditor instance.\n * @returns An object mapping root names to their content.\n */\nexport function getEditorRootsValues(editor: Editor) {\n const roots = editor.model.document.getRootNames();\n\n return roots.reduce<Record<string, string>>((acc, rootName) => {\n acc[rootName] = editor.getData({ rootName });\n return acc;\n }, Object.create({}));\n}\n","import type { EditorType } from '../typings';\n\n/**\n * Checks if the given editor type is one of the single editing-like editors.\n *\n * @param editorType - The type of the editor to check.\n * @returns `true` if the editor type is 'inline', 'classic', or 'balloon', otherwise `false`.\n */\nexport function isSingleEditingLikeEditor(editorType: EditorType): boolean {\n return ['inline', 'classic', 'balloon', 'decoupled'].includes(editorType);\n}\n","import type { EditorType } from '../typings';\n\n/**\n * Returns the constructor for the specified CKEditor5 editor type.\n *\n * @param type - The type of the editor to load.\n * @returns A promise that resolves to the editor constructor.\n */\nexport async function loadEditorConstructor(type: EditorType) {\n const PKG = await import('ckeditor5');\n\n const editorMap = {\n inline: PKG.InlineEditor,\n balloon: PKG.BalloonEditor,\n classic: PKG.ClassicEditor,\n decoupled: PKG.DecoupledEditor,\n multiroot: PKG.MultiRootEditor,\n } as const;\n\n const EditorConstructor = editorMap[type];\n\n if (!EditorConstructor) {\n throw new Error(`Unsupported editor type: ${type}`);\n }\n\n return EditorConstructor;\n}\n","import type { PluginConstructor } from 'ckeditor5';\n\nimport type { CanBePromise } from '../../types';\n\ntype PluginReader = () => CanBePromise<PluginConstructor>;\n\n/**\n * Registry for custom CKEditor plugins.\n * Allows registration and retrieval of custom plugins that can be used alongside built-in plugins.\n */\nexport class CustomEditorPluginsRegistry {\n static readonly the = new CustomEditorPluginsRegistry();\n\n /**\n * Map of registered custom plugins.\n */\n private readonly plugins = new Map<string, PluginReader>();\n\n /**\n * Private constructor to enforce singleton pattern.\n */\n private constructor() {}\n\n /**\n * Registers a custom plugin for the CKEditor.\n *\n * @param name The name of the plugin.\n * @param reader The plugin reader function that returns the plugin constructor.\n * @returns A function to unregister the plugin.\n */\n register(name: string, reader: PluginReader): () => void {\n if (this.plugins.has(name)) {\n throw new Error(`Plugin with name \"${name}\" is already registered.`);\n }\n\n this.plugins.set(name, reader);\n\n return this.unregister.bind(this, name);\n }\n\n /**\n * Removes a custom plugin by its name.\n *\n * @param name The name of the plugin to unregister.\n * @throws Will throw an error if the plugin is not registered.\n */\n unregister(name: string): void {\n if (!this.plugins.has(name)) {\n throw new Error(`Plugin with name \"${name}\" is not registered.`);\n }\n\n this.plugins.delete(name);\n }\n\n /**\n * Removes all custom editor plugins.\n * This is useful for cleanup in tests or when reloading plugins.\n */\n unregisterAll(): void {\n this.plugins.clear();\n }\n\n /**\n * Retrieves a custom plugin by its name.\n *\n * @param name The name of the plugin.\n * @returns The plugin constructor or undefined if not found.\n */\n async get(name: string): Promise<PluginConstructor | undefined> {\n const reader = this.plugins.get(name);\n\n return reader?.();\n }\n\n /**\n * Checks if a plugin with the given name is registered.\n *\n * @param name The name of the plugin.\n * @returns `true` if the plugin is registered, `false` otherwise.\n */\n has(name: string): boolean {\n return this.plugins.has(name);\n }\n}\n","import type { PluginConstructor } from 'ckeditor5';\n\nimport type { EditorPlugin } from '../typings';\n\nimport { CustomEditorPluginsRegistry } from '../custom-editor-plugins';\n\n/**\n * Loads CKEditor plugins from base and premium packages.\n * First tries to load from the base 'ckeditor5' package, then falls back to 'ckeditor5-premium-features'.\n *\n * @param plugins - Array of plugin names to load\n * @returns Promise that resolves to an array of loaded Plugin instances\n * @throws Error if a plugin is not found in either package\n */\nexport async function loadEditorPlugins(plugins: EditorPlugin[]): Promise<LoadedPlugins> {\n const basePackage = await import('ckeditor5');\n let premiumPackage: Record<string, any> | null = null;\n\n const loaders = plugins.map(async (plugin) => {\n // Let's first try to load the plugin from the base package.\n // Coverage is disabled due to Vitest issues with mocking dynamic imports.\n\n // If the plugin is not found in the base package, try custom plugins.\n const customPlugin = await CustomEditorPluginsRegistry.the.get(plugin);\n\n if (customPlugin) {\n return customPlugin;\n }\n\n // If not found, try to load from the base package.\n const { [plugin]: basePkgImport } = basePackage as Record<string, unknown>;\n\n if (basePkgImport) {\n return basePkgImport as PluginConstructor;\n }\n\n // Plugin not found in base package, try premium package.\n if (!premiumPackage) {\n try {\n premiumPackage = await import('ckeditor5-premium-features');\n /* v8 ignore next 6 */\n }\n catch (error) {\n console.error(`Failed to load premium package: ${error}`);\n }\n }\n\n /* v8 ignore next */\n const { [plugin]: premiumPkgImport } = premiumPackage || {};\n\n if (premiumPkgImport) {\n return premiumPkgImport as PluginConstructor;\n }\n\n // Plugin not found in either package, throw an error.\n throw new Error(`Plugin \"${plugin}\" not found in base or premium packages.`);\n });\n\n return {\n loadedPlugins: await Promise.all(loaders),\n hasPremium: !!premiumPackage,\n };\n}\n\n/**\n * Type representing the loaded plugins and whether premium features are available.\n */\ntype LoadedPlugins = {\n loadedPlugins: PluginConstructor<any>[];\n hasPremium: boolean;\n};\n","/**\n * Loads all required translations for the editor based on the language configuration.\n *\n * @param language - The language configuration object containing UI and content language codes.\n * @param language.ui - The UI language code.\n * @param language.content - The content language code.\n * @param hasPremium - Whether premium features are enabled and premium translations should be loaded.\n * @returns A promise that resolves to an array of loaded translation objects.\n */\nexport async function loadAllEditorTranslations(\n language: { ui: string; content: string; },\n hasPremium: boolean,\n) {\n const translations = [language.ui, language.content];\n const loadedTranslations = await Promise.all(\n [\n loadEditorPkgTranslations('ckeditor5', translations),\n /* v8 ignore next */\n hasPremium && loadEditorPkgTranslations('ckeditor5-premium-features', translations),\n ].filter(pkg => !!pkg),\n )\n .then(translations => translations.flat());\n\n return loadedTranslations;\n}\n\n/**\n * Loads the editor translations for the given languages.\n *\n * Make sure this function is properly compiled and bundled in self hosted environments!\n *\n * @param pkg - The package to load translations from ('ckeditor5' or 'ckeditor5-premium-features').\n * @param translations - The list of language codes to load translations for.\n * @returns A promise that resolves to an array of loaded translation packs.\n */\nasync function loadEditorPkgTranslations(\n pkg: EditorPkgName,\n translations: string[],\n) {\n /* v8 ignore next */\n return await Promise.all(\n translations\n .filter(lang => lang !== 'en') // 'en' is the default language, no need to load it.\n .map(async (lang) => {\n const pack = await loadEditorTranslation(pkg, lang);\n\n /* v8 ignore next */\n return pack?.default ?? pack;\n })\n .filter(Boolean),\n );\n}\n\n/**\n * Type representing the package name for CKEditor 5.\n */\ntype EditorPkgName = 'ckeditor5' | 'ckeditor5-premium-features';\n\n/**\n * Load translation for CKEditor 5\n * @param pkg - Package type: 'ckeditor5' or 'premium'\n * @param lang - Language code (e.g., 'pl', 'en', 'de')\n * @returns Translation object or null if failed\n */\nasync function loadEditorTranslation(pkg: EditorPkgName, lang: string): Promise<any> {\n try {\n /* v8 ignore next 2 */\n if (pkg === 'ckeditor5') {\n /* v8 ignore next 79 */\n switch (lang) {\n case 'af': return await import('ckeditor5/translations/af.js');\n case 'ar': return await import('ckeditor5/translations/ar.js');\n case 'ast': return await import('ckeditor5/translations/ast.js');\n case 'az': return await import('ckeditor5/translations/az.js');\n case 'bg': return await import('ckeditor5/translations/bg.js');\n case 'bn': return await import('ckeditor5/translations/bn.js');\n case 'bs': return await import('ckeditor5/translations/bs.js');\n case 'ca': return await import('ckeditor5/translations/ca.js');\n case 'cs': return await import('ckeditor5/translations/cs.js');\n case 'da': return await import('ckeditor5/translations/da.js');\n case 'de': return await import('ckeditor5/translations/de.js');\n case 'de-ch': return await import('ckeditor5/translations/de-ch.js');\n case 'el': return await import('ckeditor5/translations/el.js');\n case 'en': return await import('ckeditor5/translations/en.js');\n case 'en-au': return await import('ckeditor5/translations/en-au.js');\n case 'en-gb': return await import('ckeditor5/translations/en-gb.js');\n case 'eo': return await import('ckeditor5/translations/eo.js');\n case 'es': return await import('ckeditor5/translations/es.js');\n case 'es-co': return await import('ckeditor5/translations/es-co.js');\n case 'et': return await import('ckeditor5/translations/et.js');\n case 'eu': return await import('ckeditor5/translations/eu.js');\n case 'fa': return await import('ckeditor5/translations/fa.js');\n case 'fi': return await import('ckeditor5/translations/fi.js');\n case 'fr': return await import('ckeditor5/translations/fr.js');\n case 'gl': return await import('ckeditor5/translations/gl.js');\n case 'gu': return await import('ckeditor5/translations/gu.js');\n case 'he': return await import('ckeditor5/translations/he.js');\n case 'hi': return await import('ckeditor5/translations/hi.js');\n case 'hr': return await import('ckeditor5/translations/hr.js');\n case 'hu': return await import('ckeditor5/translations/hu.js');\n case 'hy': return await import('ckeditor5/translations/hy.js');\n case 'id': return await import('ckeditor5/translations/id.js');\n case 'it': return await import('ckeditor5/translations/it.js');\n case 'ja': return await import('ckeditor5/translations/ja.js');\n case 'jv': return await import('ckeditor5/translations/jv.js');\n case 'kk': return await import('ckeditor5/translations/kk.js');\n case 'km': return await import('ckeditor5/translations/km.js');\n case 'kn': return await import('ckeditor5/translations/kn.js');\n case 'ko': return await import('ckeditor5/translations/ko.js');\n case 'ku': return await import('ckeditor5/translations/ku.js');\n case 'lt': return await import('ckeditor5/translations/lt.js');\n case 'lv': return await import('ckeditor5/translations/lv.js');\n case 'ms': return await import('ckeditor5/translations/ms.js');\n case 'nb': return await import('ckeditor5/translations/nb.js');\n case 'ne': return await import('ckeditor5/translations/ne.js');\n case 'nl': return await import('ckeditor5/translations/nl.js');\n case 'no': return await import('ckeditor5/translations/no.js');\n case 'oc': return await import('ckeditor5/translations/oc.js');\n case 'pl': return await import('ckeditor5/translations/pl.js');\n case 'pt': return await import('ckeditor5/translations/pt.js');\n case 'pt-br': return await import('ckeditor5/translations/pt-br.js');\n case 'ro': return await import('ckeditor5/translations/ro.js');\n case 'ru': return await import('ckeditor5/translations/ru.js');\n case 'si': return await import('ckeditor5/translations/si.js');\n case 'sk': return await import('ckeditor5/translations/sk.js');\n case 'sl': return await import('ckeditor5/translations/sl.js');\n case 'sq': return await import('ckeditor5/translations/sq.js');\n case 'sr': return await import('ckeditor5/translations/sr.js');\n case 'sr-latn': return await import('ckeditor5/translations/sr-latn.js');\n case 'sv': return await import('ckeditor5/translations/sv.js');\n case 'th': return await import('ckeditor5/translations/th.js');\n case 'tk': return await import('ckeditor5/translations/tk.js');\n case 'tr': return await import('ckeditor5/translations/tr.js');\n case 'tt': return await import('ckeditor5/translations/tt.js');\n case 'ug': return await import('ckeditor5/translations/ug.js');\n case 'uk': return await import('ckeditor5/translations/uk.js');\n case 'ur': return await import('ckeditor5/translations/ur.js');\n case 'uz': return await import('ckeditor5/translations/uz.js');\n case 'vi': return await import('ckeditor5/translations/vi.js');\n case 'zh': return await import('ckeditor5/translations/zh.js');\n case 'zh-cn': return await import('ckeditor5/translations/zh-cn.js');\n default:\n console.warn(`Language ${lang} not found in ckeditor5 translations`);\n return null;\n }\n }\n /* v8 ignore next 79 */\n else {\n // Premium features translations\n switch (lang) {\n case 'af': return await import('ckeditor5-premium-features/translations/af.js');\n case 'ar': return await import('ckeditor5-premium-features/translations/ar.js');\n case 'ast': return await import('ckeditor5-premium-features/translations/ast.js');\n case 'az': return await import('ckeditor5-premium-features/translations/az.js');\n case 'bg': return await import('ckeditor5-premium-features/translations/bg.js');\n case 'bn': return await import('ckeditor5-premium-features/translations/bn.js');\n case 'bs': return await import('ckeditor5-premium-features/translations/bs.js');\n case 'ca': return await import('ckeditor5-premium-features/translations/ca.js');\n case 'cs': return await import('ckeditor5-premium-features/translations/cs.js');\n case 'da': return await import('ckeditor5-premium-features/translations/da.js');\n case 'de': return await import('ckeditor5-premium-features/translations/de.js');\n case 'de-ch': return await import('ckeditor5-premium-features/translations/de-ch.js');\n case 'el': return await import('ckeditor5-premium-features/translations/el.js');\n case 'en': return await import('ckeditor5-premium-features/translations/en.js');\n case 'en-au': return await import('ckeditor5-premium-features/translations/en-au.js');\n case 'en-gb': return await import('ckeditor5-premium-features/translations/en-gb.js');\n case 'eo': return await import('ckeditor5-premium-features/translations/eo.js');\n case 'es': return await import('ckeditor5-premium-features/translations/es.js');\n case 'es-co': return await import('ckeditor5-premium-features/translations/es-co.js');\n case 'et': return await import('ckeditor5-premium-features/translations/et.js');\n case 'eu': return await import('ckeditor5-premium-features/translations/eu.js');\n case 'fa': return await import('ckeditor5-premium-features/translations/fa.js');\n case 'fi': return await import('ckeditor5-premium-features/translations/fi.js');\n case 'fr': return await import('ckeditor5-premium-features/translations/fr.js');\n case 'gl': return await import('ckeditor5-premium-features/translations/gl.js');\n case 'gu': return await import('ckeditor5-premium-features/translations/gu.js');\n case 'he': return await import('ckeditor5-premium-features/translations/he.js');\n case 'hi': return await import('ckeditor5-premium-features/translations/hi.js');\n case 'hr': return await import('ckeditor5-premium-features/translations/hr.js');\n case 'hu': return await import('ckeditor5-premium-features/translations/hu.js');\n case 'hy': return await import('ckeditor5-premium-features/translations/hy.js');\n case 'id': return await import('ckeditor5-premium-features/translations/id.js');\n case 'it': return await import('ckeditor5-premium-features/translations/it.js');\n case 'ja': return await import('ckeditor5-premium-features/translations/ja.js');\n case 'jv': return await import('ckeditor5-premium-features/translations/jv.js');\n case 'kk': return await import('ckeditor5-premium-features/translations/kk.js');\n case 'km': return await import('ckeditor5-premium-features/translations/km.js');\n case 'kn': return await import('ckeditor5-premium-features/translations/kn.js');\n case 'ko': return await import('ckeditor5-premium-features/translations/ko.js');\n case 'ku': return await import('ckeditor5-premium-features/translations/ku.js');\n case 'lt': return await import('ckeditor5-premium-features/translations/lt.js');\n case 'lv': return await import('ckeditor5-premium-features/translations/lv.js');\n case 'ms': return await import('ckeditor5-premium-features/translations/ms.js');\n case 'nb': return await import('ckeditor5-premium-features/translations/nb.js');\n case 'ne': return await import('ckeditor5-premium-features/translations/ne.js');\n case 'nl': return await import('ckeditor5-premium-features/translations/nl.js');\n case 'no': return await import('ckeditor5-premium-features/translations/no.js');\n case 'oc': return await import('ckeditor5-premium-features/translations/oc.js');\n case 'pl': return await import('ckeditor5-premium-features/translations/pl.js');\n case 'pt': return await import('ckeditor5-premium-features/translations/pt.js');\n case 'pt-br': return await import('ckeditor5-premium-features/translations/pt-br.js');\n case 'ro': return await import('ckeditor5-premium-features/translations/ro.js');\n case 'ru': return await import('ckeditor5-premium-features/translations/ru.js');\n case 'si': return await import('ckeditor5-premium-features/translations/si.js');\n case 'sk': return await import('ckeditor5-premium-features/translations/sk.js');\n case 'sl': return await import('ckeditor5-premium-features/translations/sl.js');\n case 'sq': return await import('ckeditor5-premium-features/translations/sq.js');\n case 'sr': return await import('ckeditor5-premium-features/translations/sr.js');\n case 'sr-latn': return await import('ckeditor5-premium-features/translations/sr-latn.js');\n case 'sv': return await import('ckeditor5-premium-features/translations/sv.js');\n case 'th': return await import('ckeditor5-premium-features/translations/th.js');\n case 'tk': return await import('ckeditor5-premium-features/translations/tk.js');\n case 'tr': return await import('ckeditor5-premium-features/translations/tr.js');\n case 'tt': return await import('ckeditor5-premium-features/translations/tt.js');\n case 'ug': return await import('ckeditor5-premium-features/translations/ug.js');\n case 'uk': return await import('ckeditor5-premium-features/translations/uk.js');\n case 'ur': return await import('ckeditor5-premium-features/translations/ur.js');\n case 'uz': return await import('ckeditor5-premium-features/translations/uz.js');\n case 'vi': return await import('ckeditor5-premium-features/translations/vi.js');\n case 'zh': return await import('ckeditor5-premium-features/translations/zh.js');\n case 'zh-cn': return await import('ckeditor5-premium-features/translations/zh-cn.js');\n default:\n console.warn(`Language ${lang} not found in premium translations`);\n return await import('ckeditor5-premium-features/translations/en.js'); // fallback to English\n }\n }\n /* v8 ignore next 7 */\n }\n catch (error) {\n console.error(`Failed to load translation for ${pkg}/${lang}:`, error);\n return null;\n }\n}\n","import type { Translations } from 'ckeditor5';\n\nimport type { EditorCustomTranslationsDictionary } from '../typings';\n\nimport { mapObjectValues } from '../../../shared';\n\n/**\n * This function takes a custom translations object and maps it to the format expected by CKEditor5.\n * Each translation dictionary is wrapped in an object with a `dictionary` key.\n *\n * @param translations - The custom translations to normalize.\n * @returns A normalized translations object suitable for CKEditor5.\n */\nexport function normalizeCustomTranslations(translations: EditorCustomTranslationsDictionary): Translations {\n return mapObjectValues(translations, dictionary => ({\n dictionary,\n }));\n}\n","import type { EditorId, EditorType } from '../typings';\n\nimport { filterObjectValues, mapObjectValues } from '../../../shared';\nimport { isSingleEditingLikeEditor } from './is-single-editing-like-editor';\n\n/**\n * Queries all editable elements within a specific editor instance.\n *\n * @param editorId The ID of the editor to query.\n * @returns An object mapping editable names to their corresponding elements and initial values.\n */\nexport function queryAllEditorEditables(editorId: EditorId): Record<string, EditableItem> {\n return (\n window.Livewire\n .all()\n .filter(({ name, ephemeral }) => name === 'ckeditor5-editable' && ephemeral['editorId'] === editorId)\n .reduce<Record<string, EditableItem>>((acc, { ephemeral, el }) => ({\n ...acc,\n [ephemeral['rootName'] as string]: {\n element: el.querySelector('[data-cke-editable-content]')!,\n content: ephemeral['content'],\n },\n }), Object.create({}))\n );\n}\n\n/**\n * Gets the initial root elements for the editor based on its type.\n *\n * @param editorId The editor's ID.\n * @param type The type of the editor.\n * @returns The root element(s) for the editor.\n */\nexport function queryEditablesElements(editorId: EditorId, type: EditorType) {\n // While the `decoupled` editor is a single editing-like editor, it has a different structure\n // and requires special handling to get the main editable.\n if (type === 'decoupled') {\n const { element } = queryDecoupledMainEditableOrThrow(editorId);\n\n return element;\n }\n\n if (isSingleEditingLikeEditor(type)) {\n return document.getElementById(`${editorId}_editor`)!;\n }\n\n const editables = queryAllEditorEditables(editorId);\n\n return mapObjectValues(editables, ({ element }) => element);\n}\n\n/**\n * Gets the initial data for the roots of the editor. If the editor is a single editing-like editor,\n * it retrieves the initial value from the element's attribute. Otherwise, it returns an object mapping\n * editable names to their initial values.\n *\n * @param editorId The editor's ID.\n * @param type The type of the editor.\n * @returns The initial values for the editor's roots.\n */\nexport function queryEditablesSnapshotContent(editorId: EditorId, type: EditorType) {\n // While the `decoupled` editor is a single editing-like editor, it has a different structure\n // and requires special handling to get the main editable.\n if (type === 'decoupled') {\n const { content } = queryDecoupledMainEditableOrThrow(editorId);\n\n // If initial value is not set, then pick it from the editor element.\n if (typeof content === 'string') {\n return {\n main: content,\n };\n }\n }\n\n const editables = queryAllEditorEditables(editorId);\n const values = mapObjectValues(editables, ({ content }) => content);\n\n return filterObjectValues(values, value => typeof value === 'string') as Record<string, string>;\n}\n\n/**\n * Queries the main editable for a decoupled editor and throws an error if not found.\n *\n * @param editorId The ID of the editor to query.\n */\nfunction queryDecoupledMainEditableOrThrow(editorId: EditorId) {\n const mainEditable = queryAllEditorEditables(editorId)['main'];\n\n if (!mainEditable) {\n throw new Error(`No \"main\" editable found for editor with ID \"${editorId}\".`);\n }\n\n return mainEditable;\n}\n\n/**\n * Type representing an editable item within an editor.\n */\nexport type EditableItem = {\n element: HTMLElement;\n content: string | null;\n};\n","/**\n * Resolves element references in configuration object.\n * Looks for objects with { $element: \"selector\" } format and replaces them with actual DOM elements.\n *\n * @param obj - Configuration object to process\n * @returns Processed configuration object with resolved element references\n */\nexport function resolveEditorConfigElementReferences<T>(obj: T): T {\n if (!obj || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => resolveEditorConfigElementReferences(item)) as T;\n }\n\n const anyObj = obj as any;\n\n if (anyObj.$element && typeof anyObj.$element === 'string') {\n const element = document.querySelector(anyObj.$element);\n\n if (!element) {\n console.warn(`Element not found for selector: ${anyObj.$element}`);\n }\n\n return (element || null) as T;\n }\n\n const result = Object.create(null);\n\n for (const [key, value] of Object.entries(obj)) {\n result[key] = resolveEditorConfigElementReferences(value);\n }\n\n return result as T;\n}\n","import type { Editor } from 'ckeditor5';\n\n/**\n * Sets the height of the editable area in the CKEditor instance.\n *\n * @param instance - The CKEditor instance to modify.\n * @param height - The height in pixels to set for the editable area.\n */\nexport function setEditorEditableHeight(instance: Editor, height: number): void {\n const { editing } = instance;\n\n editing.view.change((writer) => {\n writer.setStyle('height', `${height}px`, editing.view.document.getRoot()!);\n });\n}\n","import type { Editor, EditorWatchdog } from 'ckeditor5';\n\nconst EDITOR_WATCHDOG_SYMBOL = Symbol.for('elixir-editor-watchdog');\n\n/**\n * Wraps an Editor creator with a watchdog for automatic recovery.\n *\n * @param Editor - The Editor creator to wrap.\n * @returns The Editor creator wrapped with a watchdog.\n */\nexport async function wrapWithWatchdog(Editor: EditorCreator) {\n const { EditorWatchdog } = await import('ckeditor5');\n const watchdog = new EditorWatchdog(Editor);\n\n watchdog.setCreator(async (...args: Parameters<typeof Editor['create']>) => {\n const editor = await Editor.create(...args);\n\n (editor as any)[EDITOR_WATCHDOG_SYMBOL] = watchdog;\n\n return editor;\n });\n\n return {\n watchdog,\n Constructor: {\n create: async (...args: Parameters<typeof Editor['create']>) => {\n await watchdog.create(...args);\n\n return watchdog.editor!;\n },\n },\n };\n}\n\n/**\n * Unwraps the EditorWatchdog from the editor instance.\n */\nexport function unwrapEditorWatchdog(editor: Editor): EditorWatchdog | null {\n if (EDITOR_WATCHDOG_SYMBOL in editor) {\n return (editor as any)[EDITOR_WATCHDOG_SYMBOL] as EditorWatchdog;\n }\n\n return null;\n}\n\n/**\n * Type representing an Editor creator with a create method.\n */\nexport type EditorCreator = {\n create: (...args: any) => Promise<Editor>;\n};\n","import type { Context, ContextWatchdog } from 'ckeditor5';\n\nimport { AsyncRegistry } from '../../shared';\n\n/**\n * It provides a way to register contexts and execute callbacks on them when they are available.\n */\nexport class ContextsRegistry extends AsyncRegistry<ContextWatchdog<Context>> {\n static readonly the = new ContextsRegistry();\n}\n","import type { Context, ContextWatchdog } from 'ckeditor5';\n\nimport type { EditorLanguage } from '../editor';\nimport type { ContextConfig } from './typings';\n\nimport { ClassHook } from '../../hooks/hook';\nimport { isEmptyObject } from '../../shared';\nimport {\n loadAllEditorTranslations,\n loadEditorPlugins,\n normalizeCustomTranslations,\n} from '../editor/utils';\nimport { ContextsRegistry } from './contexts-registry';\n\n/**\n * The Livewire hook that mounts CKEditor context instances.\n */\nexport class ContextComponentHook extends ClassHook<Snapshot> {\n /**\n * The promise that resolves to the context instance.\n */\n private contextPromise: Promise<ContextWatchdog<Context>> | null = null;\n\n /**\n * Mounts the context component.\n */\n override async mounted() {\n const { contextId, language, context: contextConfig } = this.ephemeral;\n const { customTranslations, watchdogConfig, config: { plugins, ...config } } = contextConfig;\n\n const { loadedPlugins, hasPremium } = await loadEditorPlugins(plugins ?? []);\n\n // Mix custom translations with loaded translations.\n const loadedTranslations = await loadAllEditorTranslations(language, hasPremium);\n const mixedTranslations = [\n ...loadedTranslations,\n normalizeCustomTranslations(customTranslations || {}),\n ]\n .filter(translations => !isEmptyObject(translations));\n\n // Initialize context with watchdog.\n this.contextPromise = (async () => {\n const { ContextWatchdog, Context } = await import('ckeditor5');\n\n const instance = new ContextWatchdog(Context, {\n crashNumberLimit: 10,\n ...watchdogConfig,\n });\n\n await instance.create({\n ...config,\n language,\n plugins: loadedPlugins,\n ...mixedTranslations.length && {\n translations: mixedTranslations,\n },\n });\n\n instance.on('itemError', (...args) => {\n console.error('Context item error:', ...args);\n });\n\n return instance;\n })();\n\n const context = await this.contextPromise;\n\n if (!this.isBeingDestroyed()) {\n ContextsRegistry.the.register(contextId, context);\n }\n }\n\n /**\n * Destroys the context component. Unmounts root from the editor.\n */\n override async destroyed() {\n const { contextId } = this.ephemeral;\n\n // Let's hide the element during destruction to prevent flickering.\n this.element.style.display = 'none';\n\n // Let's wait for the mounted promise to resolve before proceeding with destruction.\n try {\n const context = await this.contextPromise;\n\n await context?.destroy();\n }\n finally {\n this.contextPromise = null;\n\n if (ContextsRegistry.the.hasItem(contextId)) {\n ContextsRegistry.the.unregister(contextId);\n }\n }\n }\n}\n\n/**\n * The snapshot type stored in the Livewire Context hook.\n */\ntype Snapshot = {\n /**\n * The unique identifier for the context instance.\n */\n contextId: string;\n\n /**\n * The context configuration for the context instance.\n */\n context: ContextConfig;\n\n /**\n * The language of the context UI and content.\n */\n language: EditorLanguage;\n};\n","import type { Editor } from 'ckeditor5';\n\nimport { AsyncRegistry } from '../../shared/async-registry';\n\n/**\n * It provides a way to register editors and execute callbacks on them when they are available.\n */\nexport class EditorsRegistry extends AsyncRegistry<Editor> {\n static readonly the = new EditorsRegistry();\n}\n","import type { MultiRootEditor } from 'ckeditor5';\n\nimport { debounce } from '../shared';\nimport { EditorsRegistry } from './editor/editors-registry';\nimport { ClassHook } from './hook';\n\n/**\n * Editable hook for Livewire. It allows you to create editables for multi-root editors.\n */\nexport class EditableComponentHook extends ClassHook<Snapshot> {\n /**\n * The promise that resolves when the editable is mounted.\n */\n private editorPromise: Promise<MultiRootEditor> | null = null;\n\n /**\n * Mounts the editable component.\n */\n override mounted() {\n const { editorId, rootName, content, saveDebounceMs } = this.ephemeral;\n const input = this.element.querySelector<HTMLInputElement>('input');\n\n // If the editor is not registered yet, we will wait for it to be registered.\n this.editorPromise = EditorsRegistry.the.execute(editorId, (editor: MultiRootEditor) => {\n const { ui, editing, model } = editor;\n\n if (model.document.getRoot(rootName)) {\n // If the newly added root already exists, but the newly added editable has content,\n // we need to update the root data with the editable content.\n if (content !== null) {\n const data = editor.getData({ rootName });\n\n if (data && data !== content) {\n editor.setData({\n [rootName]: content,\n });\n }\n }\n\n return editor;\n }\n\n editor.addRoot(rootName, {\n isUndoable: false,\n ...content !== null && {\n data: content,\n },\n });\n\n const contentElement = this.element.querySelector('[data-cke-editable-content]') as HTMLElement | null;\n const editable = ui.view.createEditable(rootName, contentElement!);\n\n ui.addEditable(editable);\n editing.view.forceRender();\n\n // Sync data with socket and input element.\n const sync = () => {\n const html = editor.getData({ rootName });\n\n if (input) {\n input.value = html;\n }\n\n this.$wire.set('content', html);\n };\n\n editor.model.document.on('change:data', debounce(saveDebounceMs, sync));\n sync();\n\n return editor;\n });\n }\n\n /**\n * Destroys the editable component. Unmounts root from the editor.\n */\n override async destroyed() {\n const { rootName } = this.ephemeral;\n\n // Let's hide the element during destruction to prevent flickering.\n this.element.style.display = 'none';\n\n // Let's wait for the mounted promise to resolve before proceeding with destruction.\n const editor = await this.editorPromise;\n this.editorPromise = null;\n\n // Unmount root from the editor if editor is still registered.\n if (editor && editor.state !== 'destroyed') {\n const root = editor.model.document.getRoot(rootName);\n\n if (root && 'detachEditable' in editor) {\n editor.detachEditable(root);\n editor.detachRoot(rootName, false);\n }\n }\n }\n}\n\n/**\n * A snapshot of the Livewire component's state relevant to the CKEditor5 editable hook.\n */\nexport type Snapshot = {\n /**\n * The ID of the editor instance this editable belongs to.\n */\n editorId: string;\n\n /**\n * The name of the root element in the editor.\n */\n rootName: string;\n\n /**\n * The initial content value for the editable.\n */\n content: string | null;\n\n /**\n * The debounce time in milliseconds for saving changes.\n */\n saveDebounceMs: number;\n};\n","import type { PluginConstructor } from 'ckeditor5';\n\nimport type { Wire } from '../../../livewire';\n\nimport { debounce } from '../../../shared';\nimport { getEditorRootsValues } from '../utils';\n\n/**\n * Creates a LivewireSync plugin class.\n */\nexport async function createLivewireSyncPlugin(\n {\n emit,\n saveDebounceMs,\n $wire,\n }: Attrs,\n): Promise<PluginConstructor> {\n const { Plugin } = await import('ckeditor5');\n\n return class LivewireSync extends Plugin {\n /**\n * The name of the plugin.\n */\n static get pluginName() {\n return 'LivewireSync' as const;\n }\n\n /**\n * Initializes the plugin.\n */\n public init(): void {\n if (emit.change) {\n this.setupTypingContentPush();\n }\n\n if (emit.focus) {\n this.setupFocusableEventPush();\n }\n }\n\n /**\n * Setups the content push event for the editor.\n */\n private setupTypingContentPush() {\n const { model } = this.editor;\n\n const syncContentChange = () => {\n $wire.set('content', this.getEditorRootsValues());\n };\n\n model.document.on('change:data', debounce(saveDebounceMs, syncContentChange));\n syncContentChange();\n }\n\n /**\n * Setups the event push for the editor.\n */\n private setupFocusableEventPush() {\n const { ui } = this.editor;\n\n const pushEvent = () => {\n $wire.set('focused', ui.focusTracker.isFocused);\n $wire.set('content', this.getEditorRootsValues());\n };\n\n ui.focusTracker.on('change:isFocused', pushEvent);\n }\n\n /**\n * Gets the current values of all editor roots.\n */\n private getEditorRootsValues(): Record<string, string> {\n return getEditorRootsValues(this.editor);\n }\n };\n}\n\n/**\n * The attributes required to create the LivewireSync plugin.\n */\ntype Attrs = {\n emit: { change?: boolean; focus?: boolean; };\n saveDebounceMs: number;\n $wire: Wire;\n};\n","import type { ClassicEditor, PluginConstructor } from 'ckeditor5';\n\nimport { debounce } from '../../../shared';\n\n/**\n * Creates a SyncEditorWithInput plugin class.\n */\nexport async function createSyncEditorWithInputPlugin(saveDebounceMs: number): Promise<PluginConstructor> {\n const { Plugin } = await import('ckeditor5');\n\n return class SyncEditorWithInput extends Plugin {\n /**\n * The input element to synchronize with.\n */\n private input: HTMLInputElement | null = null;\n\n /**\n * The form element reference for cleanup.\n */\n private form: HTMLFormElement | null = null;\n\n /**\n * The name of the plugin.\n */\n static get pluginName() {\n return 'SyncEditorWithInput' as const;\n }\n\n /**\n * Initializes the plugin.\n */\n public afterInit(): void {\n const { editor } = this;\n const editorElement = (editor as ClassicEditor).sourceElement as HTMLElement;\n\n // Try to find the associated input field.\n const editorId = editorElement.id.replace(/_editor$/, '');\n\n this.input = document.getElementById(`${editorId}_input`) as HTMLInputElement | null;\n\n if (!this.input) {\n return;\n }\n\n // Setup handlers.\n editor.model.document.on('change:data', debounce(saveDebounceMs, () => this.sync()));\n editor.once('ready', this.sync);\n\n // Setup form integration.\n this.form = this.input.closest('form');\n this.form?.addEventListener('submit', this.sync);\n }\n\n /**\n * Synchronizes the editor's content with the input field.\n */\n private sync = (): void => {\n const newValue = this.editor.getData();\n\n this.input!.value = newValue;\n this.input!.dispatchEvent(new Event('input', { bubbles: true }));\n };\n\n /**\n * Destroys the plugin.\n */\n public override destroy(): void {\n if (this.form) {\n this.form.removeEventListener('submit', this.sync);\n }\n\n this.input = null;\n this.form = null;\n }\n };\n}\n","import type { Editor } from 'ckeditor5';\n\nimport type { EditorId, EditorLanguage, EditorPreset, EditorType } from './typings';\nimport type { EditorCreator } from './utils';\n\nimport { ContextsRegistry } from '../../hooks/context';\nimport { isEmptyObject, waitFor } from '../../shared';\nimport { ClassHook } from '../hook';\nimport { EditorsRegistry } from './editors-registry';\nimport {\n createLivewireSyncPlugin,\n createSyncEditorWithInputPlugin,\n} from './plugins';\nimport {\n createEditorInContext,\n isSingleEditingLikeEditor,\n loadAllEditorTranslations,\n loadEditorConstructor,\n loadEditorPlugins,\n normalizeCustomTranslations,\n queryEditablesElements,\n queryEditablesSnapshotContent,\n resolveEditorConfigElementReferences,\n setEditorEditableHeight,\n unwrapEditorContext,\n unwrapEditorWatchdog,\n wrapWithWatchdog,\n} from './utils';\n\n/**\n * The Livewire hook that manages the lifecycle of CKEditor5 instances.\n */\nexport class EditorComponentHook extends ClassHook<Snapshot> {\n /**\n * The promise that resolves to the editor instance.\n */\n private editorPromise: Promise<Editor> | null = null;\n\n /**\n * @inheritdoc\n */\n override async mounted(): Promise<void> {\n const { editorId } = this.ephemeral;\n\n EditorsRegistry.the.resetErrors(editorId);\n\n try {\n this.editorPromise = this.createEditor();\n\n const editor = await this.editorPromise;\n\n // Do not even try to broadcast about the registration of the editor\n // if hook was immediately destroyed.\n if (!this.isBeingDestroyed()) {\n EditorsRegistry.the.register(editorId, editor);\n\n editor.once('destroy', () => {\n if (EditorsRegistry.the.hasItem(editorId)) {\n EditorsRegistry.the.unregister(editorId);\n }\n });\n }\n }\n catch (error: any) {\n this.editorPromise = null;\n EditorsRegistry.the.error(editorId, error);\n }\n }\n\n /**\n * Destroys the editor instance when the component is destroyed.\n * This is important to prevent memory leaks and ensure that the editor is properly cleaned up.\n */\n override async destroyed() {\n // Let's hide the element during destruction to prevent flickering.\n this.element.style.display = 'none';\n\n // Let's wait for the mounted promise to resolve before proceeding with destruction.\n try {\n const editor = await this.editorPromise;\n\n if (!editor) {\n return;\n }\n\n const editorContext = unwrapEditorContext(editor);\n const watchdog = unwrapEditorWatchdog(editor);\n\n if (editorContext) {\n // If context is present, make sure it's not in unmounting phase, as it'll kill the editors.\n // If it's being destroyed, don't do anything, as the context will take care of it.\n if (editorContext.state !== 'unavailable') {\n await editorContext.context.remove(editorContext.editorContextId);\n }\n }\n else if (watchdog) {\n await watchdog.destroy();\n }\n else {\n await editor.destroy();\n }\n }\n finally {\n this.editorPromise = null;\n }\n }\n\n /**\n * Creates the CKEditor instance.\n */\n private async createEditor() {\n const {\n preset,\n editorId,\n contextId,\n editableHeight,\n emit,\n saveDebounceMs,\n language,\n watchdog,\n content,\n } = this.ephemeral;\n\n const {\n customTranslations,\n editorType,\n licenseKey,\n config: { plugins, ...config },\n } = preset;\n\n // Wrap editor creator with watchdog if needed.\n let Constructor: EditorCreator = await loadEditorConstructor(editorType);\n const context = await (\n contextId\n ? ContextsRegistry.the.waitFor(contextId)\n : null\n );\n\n // Do not use editor specific watchdog if context is attached, as the context is by default protected.\n if (watchdog && !context) {\n const wrapped = await wrapWithWatchdog(Constructor);\n\n ({ Constructor } = wrapped);\n wrapped.watchdog.on('restart', () => {\n const newInstance = wrapped.watchdog.editor!;\n\n this.editorPromise = Promise.resolve(newInstance);\n\n EditorsRegistry.the.register(editorId, newInstance);\n });\n }\n\n const { loadedPlugins, hasPremium } = await loadEditorPlugins(plugins);\n\n // Add integration specific plugins.\n loadedPlugins.push(\n await createLivewireSyncPlugin(\n {\n emit,\n saveDebounceMs,\n $wire: this.$wire,\n },\n ),\n );\n\n if (isSingleEditingLikeEditor(editorType)) {\n loadedPlugins.push(\n await createSyncEditorWithInputPlugin(saveDebounceMs),\n );\n }\n\n // Mix custom translations with loaded translations.\n const loadedTranslations = await loadAllEditorTranslations(language, hasPremium);\n const mixedTranslations = [\n ...loadedTranslations,\n normalizeCustomTranslations(customTranslations || {}),\n ]\n .filter(translations => !isEmptyObject(translations));\n\n // Let's query all elements, and create basic configuration.\n let initialData: string | Record<string, string> = {\n ...content,\n ...queryEditablesSnapshotContent(editorId, editorType),\n };\n\n if (isSingleEditingLikeEditor(editorType)) {\n initialData = initialData['main'] || '';\n }\n\n // Depending of the editor type, and parent lookup for nearest context or initialize it without it.\n const editor = await (async () => {\n let sourceElementOrData = queryEditablesElements(editorId, editorType);\n\n // Handle special case when user specified `initialData` of several root elements, but editable components\n // are not yet present in the DOM. In other words - editor is initialized before attaching root elements.\n if (shouldWaitForRoots(sourceElementOrData, editorType)) {\n const requiredRoots = Object.keys(initialData as Record<string, string>);\n\n if (!checkIfAllRootsArePresent(sourceElementOrData, requiredRoots)) {\n sourceElementOrData = await waitForAllRootsToBePresent(editorId, editorType, requiredRoots);\n initialData = {\n ...content,\n ...queryEditablesSnapshotContent(editorId, editorType),\n };\n }\n }\n\n // Construct parsed config.\n const parsedConfig = {\n ...resolveEditorConfigElementReferences(config),\n initialData,\n licenseKey,\n plugins: loadedPlugins,\n language,\n ...mixedTranslations.length && {\n translations: mixedTranslations,\n },\n };\n\n if (!context || !(sourceElementOrData instanceof HTMLElement)) {\n return Constructor.create(sourceElementOrData as any, parsedConfig);\n }\n\n const result = await createEditorInContext({\n context,\n element: sourceElementOrData,\n creator: Constructor,\n config: parsedConfig,\n });\n\n return result.editor;\n })();\n\n if (isSingleEditingLikeEditor(editorType) && editableHeight) {\n setEditorEditableHeight(editor, editableHeight);\n }\n\n return editor;\n };\n}\n\n/**\n * Checks if all required root elements are present in the elements object.\n *\n * @param elements The elements object mapping root IDs to HTMLElements.\n * @param requiredRoots The list of required root IDs.\n * @returns True if all required roots are present, false otherwise.\n */\nfunction checkIfAllRootsArePresent(elements: Record<string, HTMLElement>, requiredRoots: string[]): boolean {\n return requiredRoots.every(rootId => elements[rootId]);\n}\n\n/**\n * Waits for all required root elements to be present in the DOM.\n *\n * @param editorId The editor's ID.\n * @param editorType The type of the editor.\n * @param requiredRoots The list of required root IDs.\n * @returns A promise that resolves to the record of root elements.\n */\nasync function waitForAllRootsToBePresent(\n editorId: EditorId,\n editorType: EditorType,\n requiredRoots: string[],\n): Promise<Record<string, HTMLElement>> {\n await waitFor(\n () => {\n const elements = queryEditablesElements(editorId, editorType) as unknown as Record<string, HTMLElement>;\n\n if (!checkIfAllRootsArePresent(elements, requiredRoots)) {\n throw new Error(\n 'It looks like not all required root elements are present yet.\\n'\n + '* If you want to wait for them, ensure they are registered before editor initialization.\\n'\n + '* If you want lazy initialize roots, consider removing root values from the `initialData` config '\n + 'and assign initial data in editable components.\\n'\n + `Missing roots: ${requiredRoots.filter(rootId => !elements[rootId]).join(', ')}.`,\n );\n }\n\n return true;\n },\n { timeOutAfter: 2000, retryAfter: 100 },\n );\n\n return queryEditablesElements(editorId, editorType) as unknown as Record<string, HTMLElement>;\n}\n\n/**\n * Type guard to check if we should wait for multiple root elements.\n *\n * @param elements The elements retrieved for the editor.\n * @param editorType The type of the editor.\n * @returns True if we should wait for multiple root elements, false otherwise.\n */\nfunction shouldWaitForRoots(\n elements: HTMLElement | Record<string, HTMLElement>,\n editorType: EditorType,\n): elements is Record<string, HTMLElement> {\n return (\n !isSingleEditingLikeEditor(editorType)\n && typeof elements === 'object'\n && !(elements instanceof HTMLElement)\n );\n}\n\n/**\n * A snapshot of the Livewire component's state relevant to the CKEditor5 hook.\n */\nexport type Snapshot = {\n /**\n * The unique identifier for the CKEditor5 instance.\n */\n editorId: string;\n\n /**\n * Whether to use a watchdog for the CKEditor5 instance.\n */\n watchdog: boolean;\n\n /**\n * The identifier of the CKEditor context.\n */\n contextId: string | null;\n\n /**\n * The debounce time in milliseconds for saving content changes.\n */\n saveDebounceMs: number;\n\n /**\n * The preset configuration for the CKEditor5 instance.\n */\n preset: EditorPreset;\n\n /**\n * The content of the editor, mapped by ID of root elements.\n */\n content: Record<string, string>;\n\n /**\n * The height of the editable area, if specified.\n */\n editableHeight: number | null;\n\n /**\n * The language of the editor UI and content.\n */\n language: EditorLanguage;\n\n /**\n * The global events of the editor to forward to Livewire.\n */\n emit: {\n change: boolean;\n focus: boolean;\n };\n};\n","import { EditorsRegistry } from './editor/editors-registry';\nimport { ClassHook } from './hook';\n\n/**\n * UI Part hook for Livewire. It allows you to create UI parts for multi-root editors.\n */\nexport class UIPartComponentHook extends ClassHook<Snapshot> {\n /**\n * The promise that resolves when the UI part is mounted.\n */\n private mountedPromise: Promise<void> | null = null;\n\n /**\n * Mounts the UI part component.\n */\n override async mounted() {\n const { editorId, name } = this.ephemeral;\n\n // If the editor is not registered yet, we will wait for it to be registered.\n this.mountedPromise = EditorsRegistry.the.execute(editorId, (editor) => {\n const { ui } = editor;\n\n const uiViewName = mapUIPartView(name);\n const uiPart = (ui.view as any)[uiViewName!];\n\n if (!uiPart) {\n console.error(`Unknown UI part name: \"${name}\". Supported names are \"toolbar\" and \"menubar\".`);\n return;\n }\n\n this.element.appendChild(uiPart.element);\n });\n }\n\n /**\n * Destroys the UI part component. Unmounts UI parts from the editor.\n */\n override async destroyed() {\n // Let's hide the element during destruction to prevent flickering.\n this.element.style.display = 'none';\n\n // Let's wait for the mounted promise to resolve before proceeding with destruction.\n await this.mountedPromise;\n this.mountedPromise = null;\n\n // Unmount all UI parts from the editor.\n this.element.innerHTML = '';\n }\n}\n\n/**\n * Maps the UI part name to the corresponding view in the editor.\n */\nfunction mapUIPartView(name: string): string | null {\n switch (name) {\n case 'toolbar':\n return 'toolbar';\n\n case 'menubar':\n return 'menuBarView';\n\n default:\n return null;\n }\n}\n\n/**\n * A snapshot of the Livewire component's state relevant to the CKEditor5 UI part hook.\n */\nexport type Snapshot = {\n /**\n * The ID of the editor instance this UI part belongs to.\n */\n editorId: string;\n\n /**\n * The name of the UI part (e.g., \"toolbar\", \"menubar\").\n */\n name: string;\n};\n","import { ContextComponentHook } from './context';\nimport { EditableComponentHook } from './editable';\nimport { EditorComponentHook } from './editor';\nimport { registerLivewireComponentHook } from './hook';\nimport { UIPartComponentHook } from './ui-part';\n\nconst COMPONENT_HOOKS = {\n 'ckeditor5': EditorComponentHook,\n 'ckeditor5-context': ContextComponentHook,\n 'ckeditor5-ui-part': UIPartComponentHook,\n 'ckeditor5-editable': EditableComponentHook,\n};\n\n/**\n * Registers all available Livewire component hooks.\n */\nexport function registerLivewireComponentHooks() {\n for (const [name, Hook] of Object.entries(COMPONENT_HOOKS)) {\n registerLivewireComponentHook(name, Hook);\n }\n}\n","import './livewire.d';\n\nimport { registerLivewireComponentHooks } from './hooks';\n\nregisterLivewireComponentHooks();\n"],"names":["ClassHook","livewireComponent","registerLivewireComponentHook","name","Hook","component","cleanup","instance","AsyncRegistry","id","onSuccess","onError","item","error","resolve","reject","pending","callback","initializationErrors","promises","watcher","debounce","delay","timeoutId","args","filterObjectValues","obj","filter","filteredEntries","key","value","isEmptyObject","mapObjectValues","mapper","mappedEntries","uid","waitFor","timeOutAfter","retryAfter","startTime","lastError","timeoutTimerId","tick","result","err","CONTEXT_EDITOR_WATCHDOG_SYMBOL","createEditorInContext","element","context","creator","config","editorContextId","_element","_config","editor","contextDescriptor","originalDestroy","unwrapEditorContext","getEditorRootsValues","acc","rootName","isSingleEditingLikeEditor","editorType","loadEditorConstructor","type","PKG","EditorConstructor","CustomEditorPluginsRegistry","reader","loadEditorPlugins","plugins","basePackage","premiumPackage","loaders","plugin","customPlugin","basePkgImport","premiumPkgImport","loadAllEditorTranslations","language","hasPremium","translations","loadEditorPkgTranslations","pkg","lang","pack","loadEditorTranslation","normalizeCustomTranslations","dictionary","queryAllEditorEditables","editorId","ephemeral","el","queryEditablesElements","queryDecoupledMainEditableOrThrow","editables","queryEditablesSnapshotContent","content","values","mainEditable","resolveEditorConfigElementReferences","anyObj","setEditorEditableHeight","height","editing","writer","EDITOR_WATCHDOG_SYMBOL","wrapWithWatchdog","Editor","EditorWatchdog","watchdog","unwrapEditorWatchdog","ContextsRegistry","ContextComponentHook","contextId","contextConfig","customTranslations","watchdogConfig","loadedPlugins","mixedTranslations","ContextWatchdog","Context","EditorsRegistry","EditableComponentHook","saveDebounceMs","input","ui","model","data","contentElement","editable","sync","html","root","createLivewireSyncPlugin","emit","$wire","Plugin","syncContentChange","pushEvent","createSyncEditorWithInputPlugin","newValue","EditorComponentHook","editorContext","preset","editableHeight","licenseKey","Constructor","wrapped","newInstance","initialData","sourceElementOrData","shouldWaitForRoots","requiredRoots","checkIfAllRootsArePresent","waitForAllRootsToBePresent","parsedConfig","elements","rootId","UIPartComponentHook","uiViewName","mapUIPartView","uiPart","COMPONENT_HOOKS","registerLivewireComponentHooks"],"mappings":"wdAMO,MAAeA,CAAsD,CAM1E,YAIYC,EACV,CADU,KAAA,kBAAAA,CACT,CAPH,MAAwB,WAYxB,IAAI,WAAe,CACjB,OAAO,KAAK,kBAAkB,SAChC,CAKA,IAAI,SAAuB,CACzB,OAAO,KAAK,kBAAkB,EAChC,CAKA,IAAI,OAAc,CAChB,OAAO,KAAK,kBAAkB,KAChC,CAKA,kBAA4B,CAC1B,MAAO,CAAC,YAAa,YAAY,EAAE,SAAS,KAAK,KAAK,CACxD,CAWF,CAaO,SAASC,GAA8BC,EAAcC,EAA8D,CACxH,OAAO,SAAS,KAAK,iBAAkB,MAAO,CAAE,UAAAC,EAAW,QAAAC,KAAc,CACvE,GAAID,EAAU,OAASF,EACrB,OAGF,MAAMI,EAAW,IAAIH,EAAKC,CAAS,EAEn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A4B/J,CAAoB,CAInD,eAAuC,KAK/C,MAAe,SAAU,CACvB,KAAM,CAAE,SAAA0F,EAAU,KAAAvF,CAAA,EAAS,KAAK,UAGhC,KAAK,eAAiBuH,EAAgB,IAAI,QAAQhC,EAAWpC,GAAW,CACtE,KAAM,CAAE,GAAAwE,GAAOxE,EAET0G,EAAaC,GAAc9J,CAAI,EAC/B+J,EAAUpC,EAAG,KAAakC,CAAW,EAE3C,GAAI,CAACE,EAAQ,CACX,QAAQ,MAAM,0BAA0B/J,CAAI,iDAAiD,EAC7F,MACF,CAEA,KAAK,QAAQ,YAAY+J,EAAO,OAAO,CACzC,CAAC,CACH,CAKA,MAAe,WAAY,CAEzB,KAAK,QAAQ,MAAM,QAAU,OAG7B,MAAM,KAAK,eACX,KAAK,eAAiB,KAGtB,KAAK,QAAQ,UAAY,EAC3B,CACF,CAKA,SAASD,GAAc9J,EAA6B,CAClD,OAAQA,EAAA,CACN,IAAK,UACH,MAAO,UAET,IAAK,UACH,MAAO,cAET,QACE,OAAO,IAAA,CAEb,CC1DA,MAAMgK,GAAkB,CACtB,UAAarB,GACb,oBAAqB7B,GACrB,oBAAqB8C,GACrB,qBAAsBpC,EACxB,EAKO,SAASyC,IAAiC,CAC/C,SAAW,CAACjK,EAAMC,CAAI,IAAK,OAAO,QAAQ+J,EAAe,EACvDjK,GAA8BC,EAAMC,CAAI,CAE5C,CChBAgK,GAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC"}