@alpaca-editor/core 1.0.3992 β†’ 1.0.3995

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 (190) hide show
  1. package/dist/components/ui/copy-button.d.ts +10 -0
  2. package/dist/components/ui/copy-button.js +33 -0
  3. package/dist/components/ui/copy-button.js.map +1 -0
  4. package/dist/components/ui/sonner.d.ts +3 -0
  5. package/dist/components/ui/sonner.js +14 -0
  6. package/dist/components/ui/sonner.js.map +1 -0
  7. package/dist/config/config.js +4 -16
  8. package/dist/config/config.js.map +1 -1
  9. package/dist/config/types.d.ts +6 -3
  10. package/dist/editor/ComponentInfo.js +2 -2
  11. package/dist/editor/ComponentInfo.js.map +1 -1
  12. package/dist/editor/ContentTree.d.ts +2 -1
  13. package/dist/editor/ContentTree.js +4 -8
  14. package/dist/editor/ContentTree.js.map +1 -1
  15. package/dist/editor/FieldListField.js +3 -10
  16. package/dist/editor/FieldListField.js.map +1 -1
  17. package/dist/editor/ItemInfo.js +3 -3
  18. package/dist/editor/ItemInfo.js.map +1 -1
  19. package/dist/editor/ai/Agents.d.ts +6 -0
  20. package/dist/editor/ai/Agents.js +48 -0
  21. package/dist/editor/ai/Agents.js.map +1 -0
  22. package/dist/editor/ai/AiTerminal.js +4 -2
  23. package/dist/editor/ai/AiTerminal.js.map +1 -1
  24. package/dist/editor/client/EditorClient.js +48 -91
  25. package/dist/editor/client/EditorClient.js.map +1 -1
  26. package/dist/editor/client/editContext.d.ts +3 -2
  27. package/dist/editor/client/editContext.js.map +1 -1
  28. package/dist/editor/commands/itemCommands.js +5 -24
  29. package/dist/editor/commands/itemCommands.js.map +1 -1
  30. package/dist/editor/component-designer/ComponentEditor.js +3 -5
  31. package/dist/editor/component-designer/ComponentEditor.js.map +1 -1
  32. package/dist/editor/field-types/InternalLinkFieldEditor.js +20 -25
  33. package/dist/editor/field-types/InternalLinkFieldEditor.js.map +1 -1
  34. package/dist/editor/field-types/RichTextEditor.d.ts +4 -3
  35. package/dist/editor/field-types/RichTextEditor.js +16 -3
  36. package/dist/editor/field-types/RichTextEditor.js.map +1 -1
  37. package/dist/editor/field-types/RichTextEditorComponent.d.ts +6 -5
  38. package/dist/editor/field-types/RichTextEditorComponent.js +59 -60
  39. package/dist/editor/field-types/RichTextEditorComponent.js.map +1 -1
  40. package/dist/editor/field-types/TreeListEditor.js +7 -5
  41. package/dist/editor/field-types/TreeListEditor.js.map +1 -1
  42. package/dist/editor/field-types/richtext/components/EditorDropdown.d.ts +11 -0
  43. package/dist/editor/field-types/richtext/components/EditorDropdown.js +83 -0
  44. package/dist/editor/field-types/richtext/components/EditorDropdown.js.map +1 -0
  45. package/dist/editor/field-types/richtext/components/ReactSlate.d.ts +5 -0
  46. package/dist/editor/field-types/richtext/components/ReactSlate.js +562 -0
  47. package/dist/editor/field-types/richtext/components/ReactSlate.js.map +1 -0
  48. package/dist/editor/field-types/richtext/components/ToolbarButton.d.ts +3 -0
  49. package/dist/editor/field-types/richtext/components/ToolbarButton.js +13 -0
  50. package/dist/editor/field-types/richtext/components/ToolbarButton.js.map +1 -0
  51. package/dist/editor/field-types/richtext/config/pluginFactory.d.ts +17 -0
  52. package/dist/editor/field-types/richtext/config/pluginFactory.js +14 -0
  53. package/dist/editor/field-types/richtext/config/pluginFactory.js.map +1 -0
  54. package/dist/editor/field-types/richtext/hooks/useProfileCache.d.ts +68 -0
  55. package/dist/editor/field-types/richtext/hooks/useProfileCache.js +208 -0
  56. package/dist/editor/field-types/richtext/hooks/useProfileCache.js.map +1 -0
  57. package/dist/editor/field-types/richtext/hooks/useRichTextProfile.d.ts +25 -0
  58. package/dist/editor/field-types/richtext/hooks/useRichTextProfile.js +64 -0
  59. package/dist/editor/field-types/richtext/hooks/useRichTextProfile.js.map +1 -0
  60. package/dist/editor/field-types/richtext/index.d.ts +5 -0
  61. package/dist/editor/field-types/richtext/index.js +6 -0
  62. package/dist/editor/field-types/richtext/index.js.map +1 -0
  63. package/dist/editor/field-types/richtext/types.d.ts +139 -0
  64. package/dist/editor/field-types/richtext/types.js +107 -0
  65. package/dist/editor/field-types/richtext/types.js.map +1 -0
  66. package/dist/editor/field-types/richtext/utils/conversion.d.ts +5 -0
  67. package/dist/editor/field-types/richtext/utils/conversion.js +539 -0
  68. package/dist/editor/field-types/richtext/utils/conversion.js.map +1 -0
  69. package/dist/editor/field-types/richtext/utils/plugins.d.ts +97 -0
  70. package/dist/editor/field-types/richtext/utils/plugins.js +272 -0
  71. package/dist/editor/field-types/richtext/utils/plugins.js.map +1 -0
  72. package/dist/editor/field-types/richtext/utils/profileMapper.d.ts +38 -0
  73. package/dist/editor/field-types/richtext/utils/profileMapper.js +366 -0
  74. package/dist/editor/field-types/richtext/utils/profileMapper.js.map +1 -0
  75. package/dist/editor/field-types/richtext/utils/profileServiceCache.d.ts +37 -0
  76. package/dist/editor/field-types/richtext/utils/profileServiceCache.js +117 -0
  77. package/dist/editor/field-types/richtext/utils/profileServiceCache.js.map +1 -0
  78. package/dist/editor/media-selector/AiImageSearch.js +2 -5
  79. package/dist/editor/media-selector/AiImageSearch.js.map +1 -1
  80. package/dist/editor/media-selector/MediaFolderBrowser.js +2 -5
  81. package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -1
  82. package/dist/editor/media-selector/TreeSelector.js +2 -5
  83. package/dist/editor/media-selector/TreeSelector.js.map +1 -1
  84. package/dist/editor/menubar/FavoritesControls.d.ts +8 -0
  85. package/dist/editor/menubar/FavoritesControls.js +124 -0
  86. package/dist/editor/menubar/FavoritesControls.js.map +1 -0
  87. package/dist/editor/menubar/ItemLanguageVersion.js +2 -1
  88. package/dist/editor/menubar/ItemLanguageVersion.js.map +1 -1
  89. package/dist/editor/menubar/PageSelector.js +3 -6
  90. package/dist/editor/menubar/PageSelector.js.map +1 -1
  91. package/dist/editor/reviews/reviewCommands.js +3 -8
  92. package/dist/editor/reviews/reviewCommands.js.map +1 -1
  93. package/dist/editor/services/contentService.d.ts +8 -0
  94. package/dist/editor/services/contentService.js +3 -0
  95. package/dist/editor/services/contentService.js.map +1 -1
  96. package/dist/editor/services/favouritesService.d.ts +33 -0
  97. package/dist/editor/services/favouritesService.js +22 -0
  98. package/dist/editor/services/favouritesService.js.map +1 -0
  99. package/dist/editor/sidebar/ComponentTree.js +7 -1
  100. package/dist/editor/sidebar/ComponentTree.js.map +1 -1
  101. package/dist/editor/sidebar/Debug.js +2 -2
  102. package/dist/editor/sidebar/Debug.js.map +1 -1
  103. package/dist/editor/sidebar/SEOInfo.js +4 -15
  104. package/dist/editor/sidebar/SEOInfo.js.map +1 -1
  105. package/dist/editor/ui/ItemSearch.js +2 -5
  106. package/dist/editor/ui/ItemSearch.js.map +1 -1
  107. package/dist/editor/ui/PerfectTree.d.ts +4 -2
  108. package/dist/editor/ui/PerfectTree.js +16 -7
  109. package/dist/editor/ui/PerfectTree.js.map +1 -1
  110. package/dist/editor/ui/Section.js +1 -1
  111. package/dist/editor/utils/itemutils.js +3 -1
  112. package/dist/editor/utils/itemutils.js.map +1 -1
  113. package/dist/editor/utils/keyboardNavigation.d.ts +32 -0
  114. package/dist/editor/utils/keyboardNavigation.js +156 -0
  115. package/dist/editor/utils/keyboardNavigation.js.map +1 -0
  116. package/dist/editor/views/ItemEditor.js +10 -3
  117. package/dist/editor/views/ItemEditor.js.map +1 -1
  118. package/dist/page-wizard/PageWizard.d.ts +2 -2
  119. package/dist/page-wizard/steps/ContentStep.js +7 -7
  120. package/dist/page-wizard/steps/ContentStep.js.map +1 -1
  121. package/dist/page-wizard/steps/schema.js +4 -2
  122. package/dist/page-wizard/steps/schema.js.map +1 -1
  123. package/dist/page-wizard/steps/usePageCreator.js +1 -1
  124. package/dist/page-wizard/steps/usePageCreator.js.map +1 -1
  125. package/dist/revision.d.ts +2 -2
  126. package/dist/revision.js +2 -2
  127. package/dist/splash-screen/NewPage.js +7 -10
  128. package/dist/splash-screen/NewPage.js.map +1 -1
  129. package/dist/styles.css +34 -5
  130. package/package.json +6 -1
  131. package/src/components/ui/copy-button.tsx +75 -0
  132. package/src/components/ui/sonner.tsx +25 -0
  133. package/src/config/config.tsx +5 -19
  134. package/src/config/types.ts +6 -3
  135. package/src/editor/ComponentInfo.tsx +5 -4
  136. package/src/editor/ContentTree.tsx +5 -6
  137. package/src/editor/FieldListField.tsx +4 -25
  138. package/src/editor/ItemInfo.tsx +5 -5
  139. package/src/editor/ai/Agents.tsx +125 -0
  140. package/src/editor/ai/AiTerminal.tsx +4 -0
  141. package/src/editor/client/EditorClient.tsx +58 -119
  142. package/src/editor/client/editContext.ts +3 -2
  143. package/src/editor/commands/itemCommands.tsx +10 -25
  144. package/src/editor/component-designer/ComponentEditor.tsx +8 -10
  145. package/src/editor/field-types/InternalLinkFieldEditor.tsx +73 -69
  146. package/src/editor/field-types/RichTextEditor.tsx +40 -3
  147. package/src/editor/field-types/RichTextEditorComponent.tsx +74 -77
  148. package/src/editor/field-types/TreeListEditor.tsx +7 -7
  149. package/src/editor/field-types/richtext/components/EditorDropdown.css +81 -0
  150. package/src/editor/field-types/richtext/components/EditorDropdown.tsx +165 -0
  151. package/src/editor/field-types/richtext/components/ReactSlate.css +161 -0
  152. package/src/editor/field-types/richtext/components/ReactSlate.tsx +801 -0
  153. package/src/editor/field-types/richtext/components/ToolbarButton.tsx +23 -0
  154. package/src/editor/field-types/richtext/config/pluginFactory.tsx +22 -0
  155. package/src/editor/field-types/richtext/hooks/useProfileCache.ts +270 -0
  156. package/src/editor/field-types/richtext/hooks/useRichTextProfile.ts +94 -0
  157. package/src/editor/field-types/richtext/index.ts +5 -0
  158. package/src/editor/field-types/richtext/types.ts +269 -0
  159. package/src/editor/field-types/richtext/utils/conversion.ts +589 -0
  160. package/src/editor/field-types/richtext/utils/plugins.ts +346 -0
  161. package/src/editor/field-types/richtext/utils/profileMapper.ts +424 -0
  162. package/src/editor/field-types/richtext/utils/profileServiceCache.ts +154 -0
  163. package/src/editor/media-selector/AiImageSearch.tsx +2 -5
  164. package/src/editor/media-selector/MediaFolderBrowser.tsx +2 -5
  165. package/src/editor/media-selector/TreeSelector.tsx +2 -5
  166. package/src/editor/menubar/FavoritesControls.tsx +250 -0
  167. package/src/editor/menubar/ItemLanguageVersion.tsx +3 -1
  168. package/src/editor/menubar/PageSelector.tsx +76 -75
  169. package/src/editor/reviews/reviewCommands.tsx +3 -8
  170. package/src/editor/services/contentService.ts +12 -0
  171. package/src/editor/services/favouritesService.ts +60 -0
  172. package/src/editor/sidebar/ComponentTree.tsx +12 -1
  173. package/src/editor/sidebar/Debug.tsx +4 -3
  174. package/src/editor/sidebar/SEOInfo.tsx +6 -16
  175. package/src/editor/ui/ItemSearch.tsx +2 -5
  176. package/src/editor/ui/PerfectTree.tsx +19 -6
  177. package/src/editor/ui/Section.tsx +1 -1
  178. package/src/editor/utils/{itemutils.ts β†’ itemutils.tsx} +12 -12
  179. package/src/editor/utils/keyboardNavigation.ts +234 -0
  180. package/src/editor/views/ItemEditor.tsx +22 -1
  181. package/src/page-wizard/PageWizard.tsx +2 -2
  182. package/src/page-wizard/steps/ContentStep.tsx +7 -9
  183. package/src/page-wizard/steps/schema.ts +10 -7
  184. package/src/page-wizard/steps/usePageCreator.ts +1 -0
  185. package/src/revision.ts +2 -2
  186. package/src/splash-screen/NewPage.tsx +28 -24
  187. package/dist/editor/ui/CopyToClipboardButton.d.ts +0 -3
  188. package/dist/editor/ui/CopyToClipboardButton.js +0 -16
  189. package/dist/editor/ui/CopyToClipboardButton.js.map +0 -1
  190. package/src/editor/ui/CopyToClipboardButton.tsx +0 -24
@@ -0,0 +1,14 @@
1
+ import { withMark, withBlock, withAlignment, withLink, withList, withNormalization } from '../utils/plugins';
2
+ // Create plugins from configuration
3
+ export const createPluginsFromConfig = (editor) => {
4
+ let enhancedEditor = editor;
5
+ enhancedEditor = withMark(enhancedEditor);
6
+ enhancedEditor = withBlock(enhancedEditor);
7
+ enhancedEditor = withAlignment(enhancedEditor);
8
+ enhancedEditor = withList(enhancedEditor);
9
+ enhancedEditor = withLink(enhancedEditor);
10
+ // Add normalization plugin last to ensure it can normalize all other plugin behaviors
11
+ enhancedEditor = withNormalization(enhancedEditor);
12
+ return enhancedEditor;
13
+ };
14
+ //# sourceMappingURL=pluginFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginFactory.js","sourceRoot":"","sources":["../../../../../src/editor/field-types/richtext/config/pluginFactory.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE7G,oCAAoC;AACpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAAE,EAAE;IACxD,IAAI,cAAc,GAAG,MAAM,CAAC;IAE5B,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC1C,cAAc,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,cAAc,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;IAC/C,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC1C,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAE1C,sFAAsF;IACtF,cAAc,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAEnD,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { RichTextEditorProfile, SimplifiedProfile } from '../types';
2
+ export interface ProfileCacheStats {
3
+ simplifiedCacheSize: number;
4
+ rawCacheSize: number;
5
+ simplifiedHits: number;
6
+ simplifiedMisses: number;
7
+ rawHits: number;
8
+ rawMisses: number;
9
+ }
10
+ /**
11
+ * Get a simplified profile from cache or convert and cache it
12
+ */
13
+ export declare function getCachedSimplifiedProfile(profile: RichTextEditorProfile | null): SimplifiedProfile;
14
+ /**
15
+ * Get a parsed profile from cache or parse and cache it (backward compatibility)
16
+ */
17
+ export declare function getCachedProfile(profileJson: string): RichTextEditorProfile;
18
+ /**
19
+ * Clear all profile caches
20
+ */
21
+ export declare function clearProfileCache(): void;
22
+ /**
23
+ * Remove a specific profile from cache
24
+ */
25
+ export declare function evictProfileFromCache(profileKey: string): boolean;
26
+ /**
27
+ * Check if a profile is cached without accessing it
28
+ */
29
+ export declare function isProfileCached(profileKey: string): boolean;
30
+ /**
31
+ * Get all cached profile keys (useful for debugging)
32
+ */
33
+ export declare function getCachedProfileKeys(): string[];
34
+ /**
35
+ * Get cache statistics
36
+ */
37
+ export declare function getProfileCacheStats(): Readonly<ProfileCacheStats>;
38
+ export interface ProfileCacheHook {
39
+ /** Get a cached simplified profile (optimized for the new system) */
40
+ getCachedSimplifiedProfile: (profile: RichTextEditorProfile | null) => SimplifiedProfile;
41
+ /** Get a cached profile (same as getCachedProfile but wrapped in useCallback) */
42
+ getCachedProfile: (profileJson: string) => RichTextEditorProfile;
43
+ /** Clear all caches */
44
+ clearCache: () => void;
45
+ /** Remove a specific profile from cache */
46
+ evictProfile: (profileKey: string) => boolean;
47
+ /** Check if a profile is cached */
48
+ isProfileCached: (profileKey: string) => boolean;
49
+ /** Get all cached profile keys */
50
+ getCachedKeys: () => string[];
51
+ /** Get cache statistics */
52
+ getStats: () => Readonly<ProfileCacheStats>;
53
+ }
54
+ /**
55
+ * React hook for managing profile cache
56
+ * This provides memoized cache functions for React components
57
+ */
58
+ export declare function useProfileCache(): ProfileCacheHook;
59
+ /**
60
+ * Simple hook that just returns a cached simplified profile
61
+ * Use this when you only need to get a simplified profile and don't need cache management
62
+ */
63
+ export declare function useCachedSimplifiedProfile(profile: RichTextEditorProfile | null): SimplifiedProfile;
64
+ /**
65
+ * Simple hook that just returns a cached profile
66
+ * Use this when you only need to get a profile and don't need cache management
67
+ */
68
+ export declare function useCachedProfile(profileJson: string): RichTextEditorProfile;
@@ -0,0 +1,208 @@
1
+ import { useCallback, useMemo } from 'react';
2
+ // Cache for simplified profiles converted from complex profiles
3
+ const simplifiedProfileCache = new Map();
4
+ // Cache for raw profile JSON strings (for backward compatibility)
5
+ const rawProfileCache = new Map();
6
+ let cacheStats = {
7
+ simplifiedCacheSize: 0,
8
+ rawCacheSize: 0,
9
+ simplifiedHits: 0,
10
+ simplifiedMisses: 0,
11
+ rawHits: 0,
12
+ rawMisses: 0
13
+ };
14
+ /**
15
+ * Convert complex profile to simplified profile
16
+ */
17
+ const convertToSimplifiedProfile = (profile) => {
18
+ if (!profile) {
19
+ return {
20
+ marks: ['bold', 'italic'],
21
+ blocks: ['paragraph'],
22
+ alignment: [],
23
+ lists: false,
24
+ links: false
25
+ };
26
+ }
27
+ const simplifiedProfile = {
28
+ marks: [],
29
+ blocks: [],
30
+ alignment: [],
31
+ lists: false,
32
+ links: false
33
+ };
34
+ // Extract capabilities from the profile groups
35
+ profile.toolbar.groups.forEach(group => {
36
+ group.options.forEach(option => {
37
+ switch (option.type) {
38
+ case 'mark':
39
+ if (!simplifiedProfile.marks.includes(option.id)) {
40
+ simplifiedProfile.marks.push(option.id);
41
+ }
42
+ break;
43
+ case 'block':
44
+ if (!simplifiedProfile.blocks.includes(option.id)) {
45
+ simplifiedProfile.blocks.push(option.id);
46
+ }
47
+ break;
48
+ case 'alignment':
49
+ if (!simplifiedProfile.alignment.includes(option.id)) {
50
+ simplifiedProfile.alignment.push(option.id);
51
+ }
52
+ break;
53
+ case 'list':
54
+ simplifiedProfile.lists = true;
55
+ break;
56
+ case 'link':
57
+ simplifiedProfile.links = true;
58
+ break;
59
+ }
60
+ });
61
+ });
62
+ // Ensure we have at least one block type
63
+ if (simplifiedProfile.blocks.length === 0) {
64
+ simplifiedProfile.blocks.push('paragraph');
65
+ }
66
+ return simplifiedProfile;
67
+ };
68
+ /**
69
+ * Get a simplified profile from cache or convert and cache it
70
+ */
71
+ export function getCachedSimplifiedProfile(profile) {
72
+ const cacheKey = profile ? JSON.stringify(profile) : 'null';
73
+ if (simplifiedProfileCache.has(cacheKey)) {
74
+ cacheStats.simplifiedHits++;
75
+ return simplifiedProfileCache.get(cacheKey);
76
+ }
77
+ cacheStats.simplifiedMisses++;
78
+ const simplifiedProfile = convertToSimplifiedProfile(profile);
79
+ simplifiedProfileCache.set(cacheKey, simplifiedProfile);
80
+ cacheStats.simplifiedCacheSize = simplifiedProfileCache.size;
81
+ return simplifiedProfile;
82
+ }
83
+ /**
84
+ * Get a parsed profile from cache or parse and cache it (backward compatibility)
85
+ */
86
+ export function getCachedProfile(profileJson) {
87
+ if (rawProfileCache.has(profileJson)) {
88
+ cacheStats.rawHits++;
89
+ return rawProfileCache.get(profileJson);
90
+ }
91
+ cacheStats.rawMisses++;
92
+ const parsedProfile = JSON.parse(profileJson);
93
+ rawProfileCache.set(profileJson, parsedProfile);
94
+ cacheStats.rawCacheSize = rawProfileCache.size;
95
+ return parsedProfile;
96
+ }
97
+ /**
98
+ * Clear all profile caches
99
+ */
100
+ export function clearProfileCache() {
101
+ simplifiedProfileCache.clear();
102
+ rawProfileCache.clear();
103
+ cacheStats = {
104
+ simplifiedCacheSize: 0,
105
+ rawCacheSize: 0,
106
+ simplifiedHits: 0,
107
+ simplifiedMisses: 0,
108
+ rawHits: 0,
109
+ rawMisses: 0
110
+ };
111
+ }
112
+ /**
113
+ * Remove a specific profile from cache
114
+ */
115
+ export function evictProfileFromCache(profileKey) {
116
+ const simplifiedEvicted = simplifiedProfileCache.delete(profileKey);
117
+ const rawEvicted = rawProfileCache.delete(profileKey);
118
+ if (simplifiedEvicted) {
119
+ cacheStats.simplifiedCacheSize = simplifiedProfileCache.size;
120
+ }
121
+ if (rawEvicted) {
122
+ cacheStats.rawCacheSize = rawProfileCache.size;
123
+ }
124
+ return simplifiedEvicted || rawEvicted;
125
+ }
126
+ /**
127
+ * Check if a profile is cached without accessing it
128
+ */
129
+ export function isProfileCached(profileKey) {
130
+ return simplifiedProfileCache.has(profileKey) || rawProfileCache.has(profileKey);
131
+ }
132
+ /**
133
+ * Get all cached profile keys (useful for debugging)
134
+ */
135
+ export function getCachedProfileKeys() {
136
+ const simplifiedKeys = Array.from(simplifiedProfileCache.keys());
137
+ const rawKeys = Array.from(rawProfileCache.keys());
138
+ return [...new Set([...simplifiedKeys, ...rawKeys])];
139
+ }
140
+ /**
141
+ * Get cache statistics
142
+ */
143
+ export function getProfileCacheStats() {
144
+ return { ...cacheStats };
145
+ }
146
+ /**
147
+ * React hook for managing profile cache
148
+ * This provides memoized cache functions for React components
149
+ */
150
+ export function useProfileCache() {
151
+ const getCachedSimplifiedProfileMemo = useCallback((profile) => {
152
+ return getCachedSimplifiedProfile(profile);
153
+ }, []);
154
+ const getCachedProfileMemo = useCallback((profileJson) => {
155
+ return getCachedProfile(profileJson);
156
+ }, []);
157
+ const clearCacheMemo = useCallback(() => {
158
+ clearProfileCache();
159
+ }, []);
160
+ const evictProfileMemo = useCallback((profileKey) => {
161
+ return evictProfileFromCache(profileKey);
162
+ }, []);
163
+ const isProfileCachedMemo = useCallback((profileKey) => {
164
+ return isProfileCached(profileKey);
165
+ }, []);
166
+ const getCachedKeysMemo = useCallback(() => {
167
+ return getCachedProfileKeys();
168
+ }, []);
169
+ const getStatsMemo = useCallback(() => {
170
+ return getProfileCacheStats();
171
+ }, []);
172
+ return useMemo(() => ({
173
+ getCachedSimplifiedProfile: getCachedSimplifiedProfileMemo,
174
+ getCachedProfile: getCachedProfileMemo,
175
+ clearCache: clearCacheMemo,
176
+ evictProfile: evictProfileMemo,
177
+ isProfileCached: isProfileCachedMemo,
178
+ getCachedKeys: getCachedKeysMemo,
179
+ getStats: getStatsMemo
180
+ }), [
181
+ getCachedSimplifiedProfileMemo,
182
+ getCachedProfileMemo,
183
+ clearCacheMemo,
184
+ evictProfileMemo,
185
+ isProfileCachedMemo,
186
+ getCachedKeysMemo,
187
+ getStatsMemo
188
+ ]);
189
+ }
190
+ /**
191
+ * Simple hook that just returns a cached simplified profile
192
+ * Use this when you only need to get a simplified profile and don't need cache management
193
+ */
194
+ export function useCachedSimplifiedProfile(profile) {
195
+ return useMemo(() => {
196
+ return getCachedSimplifiedProfile(profile);
197
+ }, [profile]);
198
+ }
199
+ /**
200
+ * Simple hook that just returns a cached profile
201
+ * Use this when you only need to get a profile and don't need cache management
202
+ */
203
+ export function useCachedProfile(profileJson) {
204
+ return useMemo(() => {
205
+ return getCachedProfile(profileJson);
206
+ }, [profileJson]);
207
+ }
208
+ //# sourceMappingURL=useProfileCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useProfileCache.js","sourceRoot":"","sources":["../../../../../src/editor/field-types/richtext/hooks/useProfileCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAG7C,gEAAgE;AAChE,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAA6B,CAAC;AAEpE,kEAAkE;AAClE,MAAM,eAAe,GAAG,IAAI,GAAG,EAAiC,CAAC;AAYjE,IAAI,UAAU,GAAsB;IAClC,mBAAmB,EAAE,CAAC;IACtB,YAAY,EAAE,CAAC;IACf,cAAc,EAAE,CAAC;IACjB,gBAAgB,EAAE,CAAC;IACnB,OAAO,EAAE,CAAC;IACV,SAAS,EAAE,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,0BAA0B,GAAG,CAAC,OAAqC,EAAqB,EAAE;IAC9F,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;YACzB,MAAM,EAAE,CAAC,WAAW,CAAC;YACrB,SAAS,EAAE,EAAE;YACb,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;IAED,MAAM,iBAAiB,GAAsB;QAC3C,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,EAAE;QACb,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,KAAK;KACb,CAAC;IAEF,+CAA+C;IAC/C,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACrC,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B,CAAC,OAAqC;IAC9E,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAClD,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,OAAO,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;AACpB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { RichTextEditorProfile } from '../types';
2
+ interface ProfileState {
3
+ profile: RichTextEditorProfile | null;
4
+ loading: boolean;
5
+ error: Error | null;
6
+ }
7
+ interface UseRichTextProfileOptions {
8
+ /** Custom error handler */
9
+ onError?: (error: Error) => void;
10
+ }
11
+ /**
12
+ * Hook to load and cache rich text profiles
13
+ * Uses simplified service-level caching for parsed profiles
14
+ */
15
+ export declare function useRichTextProfile(profilePath: string | undefined, serviceCall: (path: string) => Promise<any>, options?: UseRichTextProfileOptions): ProfileState;
16
+ /**
17
+ * Hook that returns the fully parsed profile object
18
+ * This is now the main hook to use for rich text profiles
19
+ */
20
+ export declare function useRichTextProfileParsed(profilePath: string | undefined, serviceCall: (path: string) => Promise<any>): {
21
+ profile: RichTextEditorProfile | null;
22
+ loading: boolean;
23
+ error: Error | null;
24
+ };
25
+ export {};
@@ -0,0 +1,64 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { getCachedParsedProfile } from '../utils/profileServiceCache';
3
+ /**
4
+ * Hook to load and cache rich text profiles
5
+ * Uses simplified service-level caching for parsed profiles
6
+ */
7
+ export function useRichTextProfile(profilePath, serviceCall, options = {}) {
8
+ const { onError } = options;
9
+ const [state, setState] = useState({
10
+ profile: null,
11
+ loading: false,
12
+ error: null
13
+ });
14
+ useEffect(() => {
15
+ if (!profilePath) {
16
+ setState({
17
+ profile: null,
18
+ loading: false,
19
+ error: null
20
+ });
21
+ return;
22
+ }
23
+ const loadProfile = async () => {
24
+ setState(prev => ({ ...prev, loading: true, error: null }));
25
+ try {
26
+ const parsedProfile = await getCachedParsedProfile(profilePath, serviceCall);
27
+ setState({
28
+ profile: parsedProfile,
29
+ loading: false,
30
+ error: null
31
+ });
32
+ }
33
+ catch (error) {
34
+ const errorObj = error instanceof Error ? error : new Error('Failed to load profile');
35
+ setState({
36
+ profile: null,
37
+ loading: false,
38
+ error: errorObj
39
+ });
40
+ if (onError) {
41
+ onError(errorObj);
42
+ }
43
+ else {
44
+ console.error("RTE loadProfile - error:", errorObj);
45
+ }
46
+ }
47
+ };
48
+ loadProfile();
49
+ }, [profilePath, serviceCall, onError]);
50
+ return state;
51
+ }
52
+ /**
53
+ * Hook that returns the fully parsed profile object
54
+ * This is now the main hook to use for rich text profiles
55
+ */
56
+ export function useRichTextProfileParsed(profilePath, serviceCall) {
57
+ const { profile, loading, error } = useRichTextProfile(profilePath, serviceCall);
58
+ return {
59
+ profile,
60
+ loading,
61
+ error
62
+ };
63
+ }
64
+ //# sourceMappingURL=useRichTextProfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRichTextProfile.js","sourceRoot":"","sources":["../../../../../src/editor/field-types/richtext/hooks/useRichTextProfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAatE;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,WAA+B,EAC/B,WAA2C,EAC3C,UAAqC,EAAE;IAEvC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE5B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe;QAC/C,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;IAEH,SAAS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A+B,EAC/B,WAA2C;IAM3C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAEjF,OAAO;QACL,OAAO;QACP,OAAO;QACP,KAAK;KACN,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './components/ReactSlate';
2
+ export * from './types';
3
+ export * from './utils/profileServiceCache';
4
+ export * from './hooks/useProfileCache';
5
+ export * from './hooks/useRichTextProfile';
@@ -0,0 +1,6 @@
1
+ export * from './components/ReactSlate';
2
+ export * from './types';
3
+ export * from './utils/profileServiceCache';
4
+ export * from './hooks/useProfileCache';
5
+ export * from './hooks/useRichTextProfile';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/editor/field-types/richtext/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC;AACxB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,139 @@
1
+ import { BaseEditor, Editor } from 'slate';
2
+ import { ReactEditor } from 'slate-react';
3
+ import React from 'react';
4
+ import { Link } from '../../LinkEditorDialog';
5
+ import { HistoryEditor } from 'slate-history';
6
+ import { Field } from '../../pageModel';
7
+ declare module 'slate' {
8
+ interface CustomTypes {
9
+ Editor: BaseEditor & ReactEditor & HistoryEditor & {
10
+ isMarkActive(format: string): boolean;
11
+ toggleMark(format: string): void;
12
+ isBlockActive(format: string): boolean;
13
+ toggleBlock(format: string): void;
14
+ isAlignActive(align: string): boolean;
15
+ toggleAlign(align: string): void;
16
+ isLinkActive(): boolean;
17
+ insertLink(options?: {
18
+ onOpenLinkDialog?: (callback: (link: any) => void) => void;
19
+ }): void;
20
+ isListActive(listType?: 'unordered' | 'ordered'): boolean;
21
+ toggleList(listType: 'unordered' | 'ordered'): void;
22
+ indentList(): void;
23
+ outdentList(): void;
24
+ };
25
+ Element: CustomElement;
26
+ Text: CustomText;
27
+ }
28
+ }
29
+ export type CustomText = {
30
+ text: string;
31
+ bold?: boolean;
32
+ italic?: boolean;
33
+ underline?: boolean;
34
+ strikethrough?: boolean;
35
+ subscript?: boolean;
36
+ superscript?: boolean;
37
+ extrabold?: boolean;
38
+ isRawHtml?: boolean;
39
+ };
40
+ export type Alignment = 'left' | 'center' | 'right' | 'justify';
41
+ export type CustomElement = {
42
+ type: string;
43
+ align?: Alignment;
44
+ listType?: 'unordered' | 'ordered';
45
+ indent?: number;
46
+ children: (CustomText | CustomElement)[];
47
+ [key: string]: any;
48
+ };
49
+ export type PreservedElement = CustomElement & {
50
+ type: 'preserved-element';
51
+ originalTag: string;
52
+ originalHtml: string;
53
+ attributes: Record<string, any>;
54
+ };
55
+ export type PreservedInlineElement = CustomElement & {
56
+ type: 'preserved-inline';
57
+ originalTag: string;
58
+ originalHtml: string;
59
+ attributes: Record<string, any>;
60
+ };
61
+ export type LinkElement = CustomElement & {
62
+ type: 'link';
63
+ link: Link;
64
+ };
65
+ export interface ReactSlateProps {
66
+ value?: string;
67
+ onChange?: (value: string) => void;
68
+ onFocus?: () => void;
69
+ onBlur?: () => void;
70
+ readOnly?: boolean;
71
+ placeholder?: string;
72
+ className?: string;
73
+ profile?: RichTextEditorProfile;
74
+ }
75
+ export interface CustomOption {
76
+ id: string;
77
+ label?: string;
78
+ icon?: React.ReactNode;
79
+ isActive?: (editor: Editor) => boolean;
80
+ toggle?: (editor: Editor, event: React.MouseEvent) => void;
81
+ }
82
+ export type DropdownOption<T> = {
83
+ value: T;
84
+ label?: string;
85
+ icon?: React.ReactNode;
86
+ style?: React.CSSProperties;
87
+ isActive: (editor: Editor) => boolean;
88
+ onSelect: (editor: Editor, event: React.MouseEvent) => void;
89
+ };
90
+ export interface ToolbarButtonProps {
91
+ icon: React.ReactNode;
92
+ active: boolean;
93
+ onMouseDown?: (event: React.MouseEvent<HTMLButtonElement>) => void;
94
+ }
95
+ export interface ToolbarGroupConfig {
96
+ id: string;
97
+ label?: string;
98
+ display?: 'buttons' | 'dropdown';
99
+ showIconsOnly?: boolean;
100
+ options: ToolbarOptionConfig[];
101
+ row?: number;
102
+ }
103
+ export interface ToolbarOptionConfig {
104
+ type: 'mark' | 'block' | 'alignment' | 'link' | 'list' | 'divider' | string;
105
+ id: string;
106
+ }
107
+ export type RichTextEditorProfile = {
108
+ toolbar: {
109
+ groups: ToolbarGroupConfig[];
110
+ };
111
+ };
112
+ export interface SimplifiedProfile {
113
+ marks: string[];
114
+ blocks: string[];
115
+ alignment: string[];
116
+ lists: boolean;
117
+ links: boolean;
118
+ }
119
+ export declare const SLATE_MARKS: Record<string, {
120
+ hotkey?: string;
121
+ htmlTag: string;
122
+ label: string;
123
+ icon: string;
124
+ renderHtml: (text: string) => string;
125
+ }>;
126
+ export declare const SLATE_BLOCKS: Record<string, {
127
+ htmlTag: string;
128
+ label: string;
129
+ icon: string;
130
+ renderHtml: (text: string, alignStyle: string) => string;
131
+ }>;
132
+ export declare const SLATE_ALIGNMENTS: Record<string, {
133
+ label: string;
134
+ icon: string;
135
+ value: Alignment;
136
+ }>;
137
+ export type RichTextField = Field & {
138
+ source: string;
139
+ };
@@ -0,0 +1,107 @@
1
+ // Built-in Slate mark configurations
2
+ export const SLATE_MARKS = {
3
+ 'bold': {
4
+ hotkey: 'mod+b',
5
+ htmlTag: 'strong',
6
+ label: 'Bold',
7
+ icon: '𝐁',
8
+ renderHtml: (text) => `<strong>${text}</strong>`
9
+ },
10
+ 'italic': {
11
+ hotkey: 'mod+i',
12
+ htmlTag: 'em',
13
+ label: 'Italic',
14
+ icon: '𝐼',
15
+ renderHtml: (text) => `<em>${text}</em>`
16
+ },
17
+ 'underline': {
18
+ hotkey: 'mod+u',
19
+ htmlTag: 'u',
20
+ label: 'Underline',
21
+ icon: '𝐔',
22
+ renderHtml: (text) => `<u>${text}</u>`
23
+ },
24
+ 'strikethrough': {
25
+ htmlTag: 's',
26
+ label: 'Strikethrough',
27
+ icon: '𝐒',
28
+ renderHtml: (text) => `<s>${text}</s>`
29
+ },
30
+ 'subscript': {
31
+ htmlTag: 'sub',
32
+ label: 'Subscript',
33
+ icon: 'Xβ‚‚',
34
+ renderHtml: (text) => `<sub>${text}</sub>`
35
+ },
36
+ 'superscript': {
37
+ htmlTag: 'sup',
38
+ label: 'Superscript',
39
+ icon: 'XΒ²',
40
+ renderHtml: (text) => `<sup>${text}</sup>`
41
+ },
42
+ 'extrabold': {
43
+ htmlTag: 'span',
44
+ label: 'Extra Bold',
45
+ icon: '𝐄𝐁',
46
+ renderHtml: (text) => `<span class="extrabold">${text}</span>`
47
+ }
48
+ };
49
+ // Built-in Slate block configurations
50
+ export const SLATE_BLOCKS = {
51
+ 'paragraph': {
52
+ htmlTag: 'p',
53
+ label: 'Paragraph',
54
+ icon: 'ΒΆ',
55
+ renderHtml: (text, alignStyle) => `<p${alignStyle}>${text}</p>`
56
+ },
57
+ 'no-tag': {
58
+ htmlTag: 'no-tag',
59
+ label: 'Plain Text',
60
+ icon: 'T',
61
+ renderHtml: (text, alignStyle) => text
62
+ },
63
+ 'heading-1': {
64
+ htmlTag: 'h1',
65
+ label: 'Heading 1',
66
+ icon: 'H1',
67
+ renderHtml: (text, alignStyle) => `<h1${alignStyle}>${text}</h1>`
68
+ },
69
+ 'heading-2': {
70
+ htmlTag: 'h2',
71
+ label: 'Heading 2',
72
+ icon: 'H2',
73
+ renderHtml: (text, alignStyle) => `<h2${alignStyle}>${text}</h2>`
74
+ },
75
+ 'heading-3': {
76
+ htmlTag: 'h3',
77
+ label: 'Heading 3',
78
+ icon: 'H3',
79
+ renderHtml: (text, alignStyle) => `<h3${alignStyle}>${text}</h3>`
80
+ },
81
+ 'heading-4': {
82
+ htmlTag: 'h4',
83
+ label: 'Heading 4',
84
+ icon: 'H4',
85
+ renderHtml: (text, alignStyle) => `<h4${alignStyle}>${text}</h4>`
86
+ },
87
+ 'heading-5': {
88
+ htmlTag: 'h5',
89
+ label: 'Heading 5',
90
+ icon: 'H5',
91
+ renderHtml: (text, alignStyle) => `<h5${alignStyle}>${text}</h5>`
92
+ },
93
+ 'heading-6': {
94
+ htmlTag: 'h6',
95
+ label: 'Heading 6',
96
+ icon: 'H6',
97
+ renderHtml: (text, alignStyle) => `<h6${alignStyle}>${text}</h6>`
98
+ }
99
+ };
100
+ // Built-in alignment configurations
101
+ export const SLATE_ALIGNMENTS = {
102
+ 'left': { label: 'Align Left', icon: '←', value: 'left' },
103
+ 'center': { label: 'Align Center', icon: '↔', value: 'center' },
104
+ 'right': { label: 'Align Right', icon: 'β†’', value: 'right' },
105
+ 'justify': { label: 'Justify', icon: '≑', value: 'justify' }
106
+ };
107
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/editor/field-types/richtext/types.ts"],"names":[],"mappings":"AA8IA,qCAAqC;AACrC,MAAM,CAAC,MAAM,WAAW,GAMnB;IACH,MAAM,EAAE;QACN,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,QAAQ;QACjB,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,IAAI;QACV,UAAU,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,WAAW,IAAI,WAAW;KACzD;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,IAAI;QACV,UAAU,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,IAAI,OAAO;KACjD;IACD,WAAW,EAAE;QACX,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,IAAI;QACV,UAAU,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,IAAI,MAAM;KAC/C;IACD,eAAe,EAAE;QACf,OAAO,EAAE,GAAG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