ckeditor5-phoenix 1.27.1 → 1.28.0

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 (29) hide show
  1. package/dist/hooks/editable.d.ts.map +1 -1
  2. package/dist/hooks/editor/editor.d.ts.map +1 -1
  3. package/dist/hooks/editor/utils/assign-editor-roots-to-config.d.ts +14 -0
  4. package/dist/hooks/editor/utils/assign-editor-roots-to-config.d.ts.map +1 -0
  5. package/dist/hooks/editor/utils/index.d.ts +1 -2
  6. package/dist/hooks/editor/utils/index.d.ts.map +1 -1
  7. package/dist/hooks/editor/utils/query-all-editor-editables.d.ts +1 -16
  8. package/dist/hooks/editor/utils/query-all-editor-editables.d.ts.map +1 -1
  9. package/dist/index.cjs +2 -2
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.mjs +244 -277
  12. package/dist/index.mjs.map +1 -1
  13. package/package.json +3 -3
  14. package/src/hooks/editable.test.ts +29 -0
  15. package/src/hooks/editable.ts +3 -1
  16. package/src/hooks/editor/editor.test.ts +94 -0
  17. package/src/hooks/editor/editor.ts +22 -42
  18. package/src/hooks/editor/plugins/sync-editor-with-phoenix.ts +1 -1
  19. package/src/hooks/editor/utils/assign-editor-roots-to-config.ts +58 -0
  20. package/src/hooks/editor/utils/index.ts +1 -2
  21. package/src/hooks/editor/utils/query-all-editor-editables.ts +12 -35
  22. package/test-utils/editor/create-editable-html-element.ts +5 -0
  23. package/test-utils/editor/create-editor-html-element.ts +5 -0
  24. package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts +0 -10
  25. package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts.map +0 -1
  26. package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts +0 -12
  27. package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts.map +0 -1
  28. package/src/hooks/editor/utils/assign-initial-data-to-editor-config.ts +0 -47
  29. package/src/hooks/editor/utils/assign-source-elements-to-editor-config.ts +0 -60
@@ -1,60 +0,0 @@
1
- import type { EditorConfig } from 'ckeditor5';
2
-
3
- import type { EditorRelaxedConstructor } from '../types/editor-relaxed-constructor.type';
4
-
5
- /**
6
- * Assigns a DOM element to the editor configuration in a way that is compatible with the specific editor type.
7
- *
8
- * @param Editor Constructor of the editor used to determine the location of element config entry.
9
- * @param elementOrMap Element to be assigned to config.
10
- * @param config Config of the editor.
11
- * @returns The updated configuration object.
12
- */
13
- export function assignSourceElementsToEditorConfig<C extends EditorConfig>(
14
- Editor: EditorRelaxedConstructor,
15
- elementOrMap: HTMLElement | Record<string, HTMLElement>,
16
- config: C,
17
- ): C {
18
- const elementsMap = toElementsMap(elementOrMap);
19
-
20
- if (!Editor.editorName || Editor.editorName === 'ClassicEditor') {
21
- return {
22
- ...config,
23
- attachTo: elementsMap['main'],
24
- };
25
- }
26
-
27
- const allRootsKeys = new Set([
28
- ...Object.keys(elementsMap),
29
- ...Object.keys(config.roots ?? {}),
30
- ]);
31
-
32
- const rootsConfig = Array.from(allRootsKeys).reduce((acc, rootKey) => ({
33
- ...acc,
34
- [rootKey]: {
35
- /* v8 ignore next */
36
- ...config.roots?.[rootKey],
37
- ...rootKey === 'main' ? config.root : {},
38
-
39
- /* v8 ignore next 5 */
40
- ...rootKey in elementsMap
41
- ? {
42
- element: elementsMap[rootKey],
43
- }
44
- : {},
45
- },
46
- }), Object.create(config.roots || {}));
47
-
48
- const mappedConfig: C = {
49
- ...config,
50
- roots: rootsConfig,
51
- };
52
-
53
- delete mappedConfig.root;
54
-
55
- return mappedConfig;
56
- }
57
-
58
- function toElementsMap(element: HTMLElement | Record<string, HTMLElement>): Record<string, HTMLElement> {
59
- return element instanceof HTMLElement ? { main: element } : { ...element };
60
- }