@alpaca-editor/core 1.0.4017 → 1.0.4026

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 (173) hide show
  1. package/dist/components/SimpleLanguageSelector.d.ts +2 -1
  2. package/dist/components/SimpleLanguageSelector.js +9 -2
  3. package/dist/components/SimpleLanguageSelector.js.map +1 -1
  4. package/dist/components/ui/input.js +1 -1
  5. package/dist/components/ui/input.js.map +1 -1
  6. package/dist/components/ui/tooltip.d.ts +3 -1
  7. package/dist/components/ui/tooltip.js +2 -2
  8. package/dist/components/ui/tooltip.js.map +1 -1
  9. package/dist/config/config.js +4 -0
  10. package/dist/config/config.js.map +1 -1
  11. package/dist/config/types.d.ts +2 -0
  12. package/dist/editor/ContentTree.js +1 -1
  13. package/dist/editor/ContentTree.js.map +1 -1
  14. package/dist/editor/ContextMenu.js +26 -0
  15. package/dist/editor/ContextMenu.js.map +1 -1
  16. package/dist/editor/FieldHistory.js +1 -1
  17. package/dist/editor/FieldHistory.js.map +1 -1
  18. package/dist/editor/FieldListField.js +2 -2
  19. package/dist/editor/FieldListField.js.map +1 -1
  20. package/dist/editor/Terminal.js +3 -1
  21. package/dist/editor/Terminal.js.map +1 -1
  22. package/dist/editor/ai/Agents.js +19 -10
  23. package/dist/editor/ai/Agents.js.map +1 -1
  24. package/dist/editor/ai/AiResponseMessage.js +63 -5
  25. package/dist/editor/ai/AiResponseMessage.js.map +1 -1
  26. package/dist/editor/ai/AiTerminal.js +7 -7
  27. package/dist/editor/ai/AiTerminal.js.map +1 -1
  28. package/dist/editor/ai/AiToolCall.js +3 -3
  29. package/dist/editor/ai/AiToolCall.js.map +1 -1
  30. package/dist/editor/client/EditorClient.js +5 -1
  31. package/dist/editor/client/EditorClient.js.map +1 -1
  32. package/dist/editor/client/editContext.d.ts +2 -0
  33. package/dist/editor/client/editContext.js.map +1 -1
  34. package/dist/editor/client/operations.d.ts +1 -0
  35. package/dist/editor/client/operations.js +7 -0
  36. package/dist/editor/client/operations.js.map +1 -1
  37. package/dist/editor/commands/componentCommands.js +1 -1
  38. package/dist/editor/commands/componentCommands.js.map +1 -1
  39. package/dist/editor/field-types/ImageFieldEditor.js +1 -1
  40. package/dist/editor/field-types/ImageFieldEditor.js.map +1 -1
  41. package/dist/editor/field-types/MultiLineText.js +1 -1
  42. package/dist/editor/field-types/MultiLineText.js.map +1 -1
  43. package/dist/editor/field-types/PictureFieldEditor.js +1 -1
  44. package/dist/editor/field-types/PictureFieldEditor.js.map +1 -1
  45. package/dist/editor/field-types/RawEditor.js +1 -1
  46. package/dist/editor/field-types/RawEditor.js.map +1 -1
  47. package/dist/editor/field-types/RichTextEditorComponent.js +16 -17
  48. package/dist/editor/field-types/RichTextEditorComponent.js.map +1 -1
  49. package/dist/editor/field-types/SingleLineText.js +1 -1
  50. package/dist/editor/field-types/SingleLineText.js.map +1 -1
  51. package/dist/editor/field-types/richtext/components/SimpleDropdown.d.ts +18 -0
  52. package/dist/editor/field-types/richtext/components/SimpleDropdown.js +71 -0
  53. package/dist/editor/field-types/richtext/components/SimpleDropdown.js.map +1 -0
  54. package/dist/editor/field-types/richtext/components/SimpleRichTextEditor.d.ts +5 -0
  55. package/dist/editor/field-types/richtext/components/SimpleRichTextEditor.js +359 -0
  56. package/dist/editor/field-types/richtext/components/SimpleRichTextEditor.js.map +1 -0
  57. package/dist/editor/field-types/richtext/components/SimpleToolbar.d.ts +16 -0
  58. package/dist/editor/field-types/richtext/components/SimpleToolbar.js +181 -0
  59. package/dist/editor/field-types/richtext/components/SimpleToolbar.js.map +1 -0
  60. package/dist/editor/field-types/richtext/components/SimpleToolbarButton.d.ts +9 -0
  61. package/dist/editor/field-types/richtext/components/SimpleToolbarButton.js +14 -0
  62. package/dist/editor/field-types/richtext/components/SimpleToolbarButton.js.map +1 -0
  63. package/dist/editor/field-types/richtext/contextMenuFactory.d.ts +4 -0
  64. package/dist/editor/field-types/richtext/contextMenuFactory.js +193 -0
  65. package/dist/editor/field-types/richtext/contextMenuFactory.js.map +1 -0
  66. package/dist/editor/field-types/richtext/index.d.ts +6 -5
  67. package/dist/editor/field-types/richtext/index.js +6 -5
  68. package/dist/editor/field-types/richtext/index.js.map +1 -1
  69. package/dist/editor/field-types/richtext/types.d.ts +16 -16
  70. package/dist/editor/field-types/richtext/types.js +84 -84
  71. package/dist/editor/field-types/richtext/types.js.map +1 -1
  72. package/dist/editor/page-editor-chrome/CommentHighlighting.js +1 -1
  73. package/dist/editor/page-editor-chrome/CommentHighlighting.js.map +1 -1
  74. package/dist/editor/page-editor-chrome/FrameMenu.js +5 -5
  75. package/dist/editor/page-editor-chrome/FrameMenu.js.map +1 -1
  76. package/dist/editor/page-editor-chrome/PlaceholderDropZone.js +1 -1
  77. package/dist/editor/page-viewer/PageViewerFrame.js +3 -2
  78. package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
  79. package/dist/editor/services/agentService.d.ts +14 -4
  80. package/dist/editor/services/agentService.js.map +1 -1
  81. package/dist/editor/services/aiService.js +1 -0
  82. package/dist/editor/services/aiService.js.map +1 -1
  83. package/dist/page-wizard/PageWizard.d.ts +2 -0
  84. package/dist/page-wizard/PageWizard.js +6 -13
  85. package/dist/page-wizard/PageWizard.js.map +1 -1
  86. package/dist/page-wizard/WizardSteps.js +3 -1
  87. package/dist/page-wizard/WizardSteps.js.map +1 -1
  88. package/dist/page-wizard/service.d.ts +1 -0
  89. package/dist/page-wizard/service.js +7 -0
  90. package/dist/page-wizard/service.js.map +1 -1
  91. package/dist/page-wizard/steps/ContentStep.js +210 -33
  92. package/dist/page-wizard/steps/ContentStep.js.map +1 -1
  93. package/dist/page-wizard/steps/FindItemsStep.js +11 -3
  94. package/dist/page-wizard/steps/FindItemsStep.js.map +1 -1
  95. package/dist/page-wizard/steps/LayoutStep.js +1 -1
  96. package/dist/page-wizard/steps/LayoutStep.js.map +1 -1
  97. package/dist/page-wizard/steps/MetaDataStep.js +1 -1
  98. package/dist/page-wizard/steps/MetaDataStep.js.map +1 -1
  99. package/dist/page-wizard/steps/SchottSelectImagesStep.d.ts +2 -0
  100. package/dist/page-wizard/steps/SchottSelectImagesStep.js +55 -0
  101. package/dist/page-wizard/steps/SchottSelectImagesStep.js.map +1 -0
  102. package/dist/page-wizard/steps/StructureStep.js +20 -5
  103. package/dist/page-wizard/steps/StructureStep.js.map +1 -1
  104. package/dist/page-wizard/steps/TranslateStep.d.ts +2 -0
  105. package/dist/page-wizard/steps/TranslateStep.js +413 -0
  106. package/dist/page-wizard/steps/TranslateStep.js.map +1 -0
  107. package/dist/page-wizard/utils/dataAccessor.d.ts +7 -0
  108. package/dist/page-wizard/utils/dataAccessor.js +76 -0
  109. package/dist/page-wizard/utils/dataAccessor.js.map +1 -1
  110. package/dist/revision.d.ts +2 -2
  111. package/dist/revision.js +2 -2
  112. package/dist/splash-screen/NewPage.js +5 -4
  113. package/dist/splash-screen/NewPage.js.map +1 -1
  114. package/dist/splash-screen/OpenPage.js +2 -1
  115. package/dist/splash-screen/OpenPage.js.map +1 -1
  116. package/dist/splash-screen/RecentPages.js +3 -1
  117. package/dist/splash-screen/RecentPages.js.map +1 -1
  118. package/dist/styles.css +57 -0
  119. package/package.json +5 -4
  120. package/src/components/SimpleLanguageSelector.tsx +11 -1
  121. package/src/components/ui/input.tsx +1 -1
  122. package/src/components/ui/tooltip.tsx +3 -2
  123. package/src/config/config.tsx +4 -0
  124. package/src/config/types.ts +6 -0
  125. package/src/editor/ContentTree.tsx +1 -1
  126. package/src/editor/ContextMenu.tsx +39 -0
  127. package/src/editor/FieldHistory.tsx +1 -1
  128. package/src/editor/FieldListField.tsx +2 -6
  129. package/src/editor/Terminal.tsx +5 -1
  130. package/src/editor/ai/Agents.tsx +27 -16
  131. package/src/editor/ai/AiResponseMessage.tsx +138 -23
  132. package/src/editor/ai/AiTerminal.tsx +43 -29
  133. package/src/editor/ai/AiToolCall.tsx +14 -4
  134. package/src/editor/client/EditorClient.tsx +9 -1
  135. package/src/editor/client/editContext.ts +2 -0
  136. package/src/editor/client/operations.ts +9 -0
  137. package/src/editor/commands/componentCommands.tsx +1 -1
  138. package/src/editor/field-types/ImageFieldEditor.tsx +1 -0
  139. package/src/editor/field-types/MultiLineText.tsx +1 -0
  140. package/src/editor/field-types/PictureFieldEditor.tsx +1 -0
  141. package/src/editor/field-types/RawEditor.tsx +1 -0
  142. package/src/editor/field-types/RichTextEditorComponent.tsx +27 -25
  143. package/src/editor/field-types/SingleLineText.tsx +1 -0
  144. package/src/editor/field-types/richtext/components/SimpleDropdown.tsx +165 -0
  145. package/src/editor/field-types/richtext/components/SimpleRichTextEditor.css +261 -0
  146. package/src/editor/field-types/richtext/components/SimpleRichTextEditor.tsx +505 -0
  147. package/src/editor/field-types/richtext/components/SimpleToolbar.tsx +362 -0
  148. package/src/editor/field-types/richtext/components/SimpleToolbarButton.tsx +36 -0
  149. package/src/editor/field-types/richtext/contextMenuFactory.tsx +264 -0
  150. package/src/editor/field-types/richtext/index.ts +6 -5
  151. package/src/editor/field-types/richtext/types.ts +168 -148
  152. package/src/editor/page-editor-chrome/CommentHighlighting.tsx +1 -1
  153. package/src/editor/page-editor-chrome/FrameMenu.tsx +16 -11
  154. package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +1 -1
  155. package/src/editor/page-viewer/PageViewerFrame.tsx +4 -3
  156. package/src/editor/services/agentService.ts +16 -5
  157. package/src/editor/services/aiService.ts +2 -0
  158. package/src/page-wizard/PageWizard.tsx +10 -13
  159. package/src/page-wizard/WizardSteps.tsx +3 -1
  160. package/src/page-wizard/service.ts +11 -0
  161. package/src/page-wizard/steps/ContentStep.tsx +376 -43
  162. package/src/page-wizard/steps/FindItemsStep.tsx +23 -3
  163. package/src/page-wizard/steps/LayoutStep.tsx +1 -1
  164. package/src/page-wizard/steps/MetaDataStep.tsx +1 -1
  165. package/src/page-wizard/steps/SchottSelectImagesStep.tsx +141 -0
  166. package/src/page-wizard/steps/StructureStep.tsx +40 -5
  167. package/src/page-wizard/steps/TranslateStep.tsx +772 -0
  168. package/src/page-wizard/utils/dataAccessor.ts +85 -0
  169. package/src/revision.ts +2 -2
  170. package/src/splash-screen/NewPage.tsx +18 -3
  171. package/src/splash-screen/OpenPage.tsx +14 -1
  172. package/src/splash-screen/RecentPages.tsx +4 -2
  173. package/tsconfig.build.json +1 -0
@@ -0,0 +1,181 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback } from "react";
3
+ import { SLATE_MARKS, SLATE_BLOCKS, SLATE_ALIGNMENTS, } from "../types";
4
+ import { SimpleToolbarButton } from "./SimpleToolbarButton";
5
+ import { SimpleDropdown } from "./SimpleDropdown";
6
+ export const SimpleToolbar = ({ profile, isMarkActive, isBlockActive, isAlignActive, isListActive, toggleMark, toggleBlock, toggleAlign, toggleList, stripFormatting, }) => {
7
+ // Create toolbar option from configuration
8
+ const createToolbarOption = useCallback((option) => {
9
+ switch (option.type) {
10
+ case "mark":
11
+ const markConfig = SLATE_MARKS[option.id];
12
+ if (markConfig) {
13
+ return {
14
+ id: option.id,
15
+ type: option.type,
16
+ label: markConfig.label,
17
+ icon: markConfig.icon,
18
+ isActive: isMarkActive(option.id),
19
+ onSelect: () => toggleMark(option.id),
20
+ };
21
+ }
22
+ return null;
23
+ case "block":
24
+ const blockConfig = SLATE_BLOCKS[option.id];
25
+ if (blockConfig) {
26
+ return {
27
+ id: option.id,
28
+ type: option.type,
29
+ label: blockConfig.label,
30
+ icon: blockConfig.icon,
31
+ isActive: isBlockActive(option.id),
32
+ onSelect: () => toggleBlock(option.id),
33
+ };
34
+ }
35
+ return null;
36
+ case "alignment":
37
+ const alignConfig = SLATE_ALIGNMENTS[option.id];
38
+ if (alignConfig) {
39
+ return {
40
+ id: option.id,
41
+ type: option.type,
42
+ label: alignConfig.label,
43
+ icon: alignConfig.icon,
44
+ isActive: isAlignActive(alignConfig.value),
45
+ onSelect: () => toggleAlign(alignConfig.value),
46
+ };
47
+ }
48
+ return null;
49
+ case "list":
50
+ const listType = option.id === "unordered-list" ? "unordered" : "ordered";
51
+ return {
52
+ id: option.id,
53
+ type: option.type,
54
+ label: option.id === "unordered-list"
55
+ ? "Bulleted List"
56
+ : "Numbered List",
57
+ icon: option.id === "unordered-list" ? "•" : "1.",
58
+ isActive: isListActive(listType),
59
+ onSelect: () => toggleList(listType),
60
+ };
61
+ case "divider":
62
+ return {
63
+ id: "divider",
64
+ type: "divider",
65
+ label: "Divider",
66
+ icon: null,
67
+ isActive: false,
68
+ onSelect: () => { },
69
+ };
70
+ case "strip":
71
+ return {
72
+ id: "strip-formatting",
73
+ type: "strip",
74
+ label: "Strip Formatting",
75
+ icon: "✗",
76
+ isActive: false,
77
+ onSelect: () => stripFormatting(),
78
+ };
79
+ default:
80
+ return null;
81
+ }
82
+ }, [
83
+ isMarkActive,
84
+ isBlockActive,
85
+ isAlignActive,
86
+ isListActive,
87
+ toggleMark,
88
+ toggleBlock,
89
+ toggleAlign,
90
+ toggleList,
91
+ ]);
92
+ // Split options by dividers
93
+ const splitOptionsByDividers = (options) => {
94
+ const groups = [];
95
+ let currentGroup = [];
96
+ options.forEach((option) => {
97
+ if (option.type === "divider") {
98
+ if (currentGroup.length > 0) {
99
+ groups.push(currentGroup);
100
+ currentGroup = [];
101
+ }
102
+ }
103
+ else {
104
+ currentGroup.push(option);
105
+ }
106
+ });
107
+ if (currentGroup.length > 0) {
108
+ groups.push(currentGroup);
109
+ }
110
+ return groups;
111
+ };
112
+ // Render a toolbar group
113
+ const renderToolbarGroup = (group, rowIndex) => {
114
+ if (!group.options || group.options.length === 0)
115
+ return null;
116
+ // Create toolbar options from configuration
117
+ const validOptions = group.options
118
+ .map(createToolbarOption)
119
+ .filter((option) => option !== null);
120
+ if (validOptions.length === 0)
121
+ return null;
122
+ const groupKey = `${group.id}-${rowIndex}`;
123
+ // Render as buttons
124
+ if (group.display === "buttons" || !group.display) {
125
+ const subGroups = splitOptionsByDividers(validOptions);
126
+ return (_jsx("div", { className: "toolbar-group", children: subGroups.map((subGroup, subGroupIndex) => (_jsx("div", { className: "toolbar-button-group", children: subGroup.map((option) => (_jsx(SimpleToolbarButton, { icon: option.icon, active: option.isActive, title: option.label, onMouseDown: (event) => {
127
+ event.preventDefault();
128
+ option.onSelect();
129
+ } }, `${option.type}-${option.id}`))) }, `subgroup-${subGroupIndex}`))) }, groupKey));
130
+ }
131
+ // Render as dropdown
132
+ if (group.display === "dropdown") {
133
+ const blockOptions = validOptions.filter((option) => option.type === "block");
134
+ // If there's only one block option, render it as a disabled-style button
135
+ if (blockOptions.length === 1) {
136
+ const singleOption = blockOptions[0];
137
+ if (!singleOption)
138
+ return null;
139
+ return (_jsx("div", { className: "toolbar-group", children: _jsx("div", { className: "toolbar-dropdown-container", children: _jsx("button", { className: "toolbar-dropdown-button", disabled: true, children: group.label ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "toolbar-dropdown-content", children: [group.label, ": ", singleOption.label] }), _jsx("span", { className: "toolbar-dropdown-arrow", children: "\u25BC" })] })) : group.showIconsOnly ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "toolbar-dropdown-icon", children: singleOption.icon }), _jsx("span", { className: "toolbar-dropdown-arrow", children: "\u25BC" })] })) : (_jsxs(_Fragment, { children: [_jsxs("span", { className: "toolbar-dropdown-icon", children: [singleOption.icon && (_jsx("span", { className: "toolbar-dropdown-icon", children: singleOption.icon })), _jsx("span", { className: "toolbar-dropdown-content", children: singleOption.label })] }), _jsx("span", { className: "toolbar-dropdown-arrow", children: "\u25BC" })] })) }) }) }, groupKey));
140
+ }
141
+ // Multiple options - render normally with dropdown
142
+ const isActive = validOptions.some((option) => option.isActive);
143
+ return (_jsx("div", { className: "toolbar-group", children: _jsx("div", { className: "toolbar-dropdown-container", children: _jsx(SimpleDropdown, { options: validOptions, label: group.label, showIconsOnly: group.showIconsOnly, isActive: isActive, title: group.label
144
+ ? `${group.label} formatting options`
145
+ : "Formatting options" }) }) }, groupKey));
146
+ }
147
+ return null;
148
+ };
149
+ if (!profile.toolbar?.groups || profile.toolbar.groups.length === 0) {
150
+ return null;
151
+ }
152
+ // Group toolbar items by row
153
+ const groupsByRow = profile.toolbar.groups.reduce((acc, group, index) => {
154
+ const row = group.row !== undefined ? group.row : index;
155
+ if (!acc[row])
156
+ acc[row] = [];
157
+ acc[row].push(group);
158
+ return acc;
159
+ }, {});
160
+ // Create strip formatting option that's always available
161
+ const stripFormattingOption = {
162
+ id: "strip-formatting",
163
+ type: "strip",
164
+ label: "Strip Formatting",
165
+ icon: "✗",
166
+ isActive: false,
167
+ onSelect: () => stripFormatting(),
168
+ };
169
+ // Render each row
170
+ return (_jsxs("div", { className: "toolbar", children: [Object.entries(groupsByRow)
171
+ .sort(([a], [b]) => parseInt(a) - parseInt(b))
172
+ .map(([rowIndex, rowGroups]) => (_jsxs("div", { className: "toolbar-row", children: [rowGroups.map((group) => renderToolbarGroup(group, parseInt(rowIndex))), parseInt(rowIndex) === 0 && (_jsx("div", { className: "toolbar-group", children: _jsx("div", { className: "toolbar-button-group", children: _jsx(SimpleToolbarButton, { icon: stripFormattingOption.icon, active: stripFormattingOption.isActive, title: stripFormattingOption.label, onMouseDown: (event) => {
173
+ event.preventDefault();
174
+ stripFormattingOption.onSelect();
175
+ } }, "strip-formatting") }) }))] }, `row-${rowIndex}`))), Object.keys(groupsByRow).length === 0 && (_jsx("div", { className: "toolbar-row", children: _jsx("div", { className: "toolbar-group", children: _jsx("div", { className: "toolbar-button-group", children: _jsx(SimpleToolbarButton, { icon: stripFormattingOption.icon, active: stripFormattingOption.isActive, title: stripFormattingOption.label, onMouseDown: (event) => {
176
+ event.preventDefault();
177
+ stripFormattingOption.onSelect();
178
+ } }, "strip-formatting") }) }) }))] }));
179
+ };
180
+ export default SimpleToolbar;
181
+ //# sourceMappingURL=SimpleToolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleToolbar.js","sourceRoot":"","sources":["../../../../../src/editor/field-types/richtext/components/SimpleToolbar.tsx"],"names":[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,cAAK,SAAS,EAAC,aAAa,YAC1B,cAAK,SAAS,EAAC,eAAe,YAC5B,cAAK,SAAS,EAAC,sBAAsB,YACnC,KAAC,mBAAmB,IAElB,IAAI,EAAE,qBAAqB,CAAC,IAAI,EAChC,MAAM,EAAE,qBAAqB,CAAC,QAAQ,EACtC,KAAK,EAAE,qBAAqB,CAAC,KAAK,EAClC,WAAW,EAAE,CAAC,KAA0C,EAAE,EAAE;gCAC1D,KAAK,CAAC,cAAc,EAAE,CAAC;gCACvB,qBAAqB,CAAC,QAAQ,EAAE,CAAC;4BACnC,CAAC,IAPG,kBAAkB,CAQtB,GACE,GACF,GACF,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ interface SimpleToolbarButtonProps {
3
+ icon: React.ReactNode;
4
+ active: boolean;
5
+ title?: string;
6
+ onMouseDown?: (event: React.MouseEvent<HTMLButtonElement>) => void;
7
+ }
8
+ export declare const SimpleToolbarButton: React.FC<SimpleToolbarButtonProps>;
9
+ export default SimpleToolbarButton;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const SimpleToolbarButton = ({ icon, active, title, onMouseDown, }) => {
3
+ return (_jsx("button", { className: `toolbar-button ${active ? "active" : ""}`, onMouseDown: onMouseDown, title: title, style: {
4
+ padding: "5px 10px",
5
+ margin: "0 2px",
6
+ background: active ? "#ffffff" : "transparent",
7
+ border: "none",
8
+ borderRadius: "3px",
9
+ cursor: "pointer",
10
+ boxShadow: active ? "0 1px 2px rgba(0,0,0,0.1)" : "none",
11
+ }, children: icon }));
12
+ };
13
+ export default SimpleToolbarButton;
14
+ //# sourceMappingURL=SimpleToolbarButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleToolbarButton.js","sourceRoot":"","sources":["../../../../../src/editor/field-types/richtext/components/SimpleToolbarButton.tsx"],"names":[],"mappings":";AASA,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CAAC,EACtE,IAAI,EACJ,MAAM,EACN,KAAK,EACL,WAAW,GACZ,EAAE,EAAE;IACH,OAAO,CACL,iBACE,SAAS,EAAE,kBAAkB,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EACrD,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE;YACL,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa;YAC9C,MAAM,EAAE,MAAM;YACd,YAAY,EAAE,KAAK;YACnB,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,MAAM;SACzD,YAEA,IAAI,GACE,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { MenuItem } from "../../../config/types";
2
+ import { Field } from "../../pageModel";
3
+ import { EditContextType } from "../../client/editContext";
4
+ export declare function createRichTextContextMenu(field: Field, editContext: EditContextType): Promise<MenuItem[]>;
@@ -0,0 +1,193 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { getRichTextProfile } from "../../services/contentService";
3
+ import { getCachedParsedProfile } from "./utils/profileServiceCache";
4
+ import { SLATE_MARKS, } from "./types";
5
+ // Helper function to execute formatting commands on the contentEditable element in iframe
6
+ function executeFormatCommand(command, iframeDocument, value) {
7
+ try {
8
+ // Focus the contentEditable element first
9
+ const activeElement = iframeDocument.activeElement;
10
+ if (activeElement &&
11
+ activeElement.contentEditable === "true") {
12
+ activeElement.focus();
13
+ }
14
+ // Execute the command on the iframe document
15
+ console.log("Executing command:", command, value);
16
+ return iframeDocument.execCommand(command, false, value);
17
+ }
18
+ catch (error) {
19
+ console.error(`Failed to execute command: ${command}`, error);
20
+ return false;
21
+ }
22
+ }
23
+ // Helper function to get the current contentEditable element for this field in iframe
24
+ function getFieldEditableElement(fieldId, iframeDocument) {
25
+ // Look for the contentEditable element with the matching field ID in iframe
26
+ const element = iframeDocument.querySelector(`[data-fieldid="${fieldId}"][contenteditable="true"]`);
27
+ return element;
28
+ }
29
+ // Trigger a save by calling the editContext operations directly
30
+ // Wait for DOM to update before reading content to avoid race conditions
31
+ async function triggerSave(element, field, editContext) {
32
+ try {
33
+ // Wait for DOM updates to complete before reading content
34
+ await new Promise((resolve) => {
35
+ // Use a shorter delay - just enough for execCommand to complete
36
+ setTimeout(resolve, 50);
37
+ });
38
+ const isRichText = element.getAttribute("data-is-richtext") === "true";
39
+ const value = isRichText ? element.innerHTML : element.innerText;
40
+ await editContext.operations.editField({
41
+ field: field.descriptor,
42
+ value: value,
43
+ refresh: "none",
44
+ });
45
+ }
46
+ catch (error) {
47
+ console.error("Failed to save field value:", error);
48
+ }
49
+ }
50
+ export async function createRichTextContextMenu(field, editContext) {
51
+ const richTextField = field;
52
+ const profilePath = richTextField.customProperties?.profile;
53
+ if (!profilePath) {
54
+ return [];
55
+ }
56
+ // Get the iframe document
57
+ const iframeDocument = editContext.pageView?.editorIframeRef?.current?.contentWindow?.document;
58
+ if (!iframeDocument) {
59
+ console.error("Could not find iframe document for rich text editing");
60
+ return [];
61
+ }
62
+ try {
63
+ // Get the rich text profile using the cached parsed profile
64
+ const profile = await getCachedParsedProfile(profilePath, getRichTextProfile);
65
+ if (!profile?.toolbar?.groups) {
66
+ return [];
67
+ }
68
+ // Create format submenu items based on the profile
69
+ const formatMenuItems = [];
70
+ // Process each toolbar group to extract formatting options
71
+ for (const group of profile.toolbar.groups) {
72
+ if (group.options && group.options.length > 0) {
73
+ // Collect valid items for this group first
74
+ const groupItems = [];
75
+ // Process each option in the group
76
+ for (const option of group.options) {
77
+ let menuItem = null;
78
+ switch (option.type) {
79
+ case "mark":
80
+ const markConfig = SLATE_MARKS[option.id];
81
+ if (markConfig) {
82
+ let command = "";
83
+ // Only support specific formatting commands
84
+ switch (option.id) {
85
+ case "bold":
86
+ command = "bold";
87
+ break;
88
+ case "italic":
89
+ command = "italic";
90
+ break;
91
+ case "underline":
92
+ command = "underline";
93
+ break;
94
+ case "strikethrough":
95
+ command = "strikeThrough";
96
+ break;
97
+ case "subscript":
98
+ command = "subscript";
99
+ break;
100
+ case "superscript":
101
+ command = "superscript";
102
+ break;
103
+ default:
104
+ // Skip unsupported commands
105
+ continue;
106
+ }
107
+ menuItem = {
108
+ id: `format-mark-${option.id}`,
109
+ label: markConfig.label,
110
+ icon: (_jsx("span", { style: { fontFamily: "monospace", fontWeight: "bold" }, children: markConfig.icon })),
111
+ command: async () => {
112
+ try {
113
+ const element = getFieldEditableElement(field.id, iframeDocument);
114
+ if (element) {
115
+ element.focus();
116
+ const success = executeFormatCommand(command, iframeDocument);
117
+ if (success) {
118
+ await triggerSave(element, field, editContext);
119
+ }
120
+ }
121
+ }
122
+ catch (error) {
123
+ console.error(`Failed to apply mark formatting: ${option.id}`, error);
124
+ }
125
+ },
126
+ };
127
+ }
128
+ break;
129
+ // Block, alignment, and list formatting not supported
130
+ case "block":
131
+ case "alignment":
132
+ case "list":
133
+ // Skip unsupported formatting types
134
+ continue;
135
+ }
136
+ if (menuItem) {
137
+ groupItems.push(menuItem);
138
+ }
139
+ }
140
+ // Only add group items if we have any valid items for this group
141
+ if (groupItems.length > 0) {
142
+ // Add separator if we already have items from previous groups
143
+ if (formatMenuItems.length > 0) {
144
+ formatMenuItems.push({
145
+ id: `${group.id}-separator`,
146
+ separator: true,
147
+ });
148
+ }
149
+ // Add all valid items from this group
150
+ formatMenuItems.push(...groupItems);
151
+ }
152
+ }
153
+ }
154
+ // Build the context menu items
155
+ const menuItems = [];
156
+ // Add the Format submenu if we have any items
157
+ if (formatMenuItems.length > 0) {
158
+ menuItems.push({
159
+ id: "format-submenu",
160
+ label: "Format",
161
+ icon: (_jsx("span", { style: { fontFamily: "monospace", fontWeight: "bold" }, children: "F" })),
162
+ items: formatMenuItems,
163
+ });
164
+ }
165
+ // Add Strip Formatting command
166
+ menuItems.push({
167
+ id: "strip-formatting",
168
+ label: "Strip Formatting",
169
+ icon: (_jsx("span", { style: { fontFamily: "monospace", fontWeight: "bold" }, children: "\u2717" })),
170
+ command: async () => {
171
+ try {
172
+ const element = getFieldEditableElement(field.id, iframeDocument);
173
+ if (element) {
174
+ element.focus();
175
+ const success = executeFormatCommand("removeFormat", iframeDocument);
176
+ if (success) {
177
+ await triggerSave(element, field, editContext);
178
+ }
179
+ }
180
+ }
181
+ catch (error) {
182
+ console.error("Failed to strip formatting:", error);
183
+ }
184
+ },
185
+ });
186
+ return menuItems;
187
+ }
188
+ catch (error) {
189
+ console.error("Error creating RichText context menu:", error);
190
+ return [];
191
+ }
192
+ }
193
+ //# sourceMappingURL=contextMenuFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextMenuFactory.js","sourceRoot":"","sources":["../../../../src/editor/field-types/richtext/contextMenuFactory.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAEL,WAAW,GAIZ,MAAM,SAAS,CAAC;AAEjB,0FAA0F;AAC1F,SAAS,oBAAoB,CAC3B,OAAe,EACf,cAAwB,EACxB,KAAc;IAEd,IAAI,CAAC;QACH,0CAA0C;QAC1C,MAAM,aAAa,GAAG,cAAc,CAAC,aAAa,CAAC;QACnD,IACE,aAAa;YACZ,aAA6B,CAAC,eAAe,KAAK,MAAM,EACzD,CAAC;YACA,aAA6B,CAAC,KAAK,EAAE,CAAC;QACzC,CAAC;QAED,6CAA6C;QAC7C,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAClD,OAAO,cAAc,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,C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;oBACH,MAAM,OAAO,GAAG,uBAAuB,CAAC,KAAK,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;oBAClE,IAAI,OAAO,EAAE,CAAC;wBACZ,OAAO,CAAC,KAAK,EAAE,CAAC;wBAChB,MAAM,OAAO,GAAG,oBAAoB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;wBACrE,IAAI,OAAO,EAAE,CAAC;4BACZ,MAAM,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;wBACjD,CAAC;oBACH,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;gBACtD,CAAC;YACH,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC;IACnB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;QAC9D,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -1,5 +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';
1
+ export * from "./components/ReactSlate";
2
+ export * from "./components/SimpleRichTextEditor";
3
+ export * from "./types";
4
+ export * from "./utils/profileServiceCache";
5
+ export * from "./hooks/useProfileCache";
6
+ export * from "./hooks/useRichTextProfile";
@@ -1,6 +1,7 @@
1
- export * from './components/ReactSlate';
2
- export * from './types';
3
- export * from './utils/profileServiceCache';
4
- export * from './hooks/useProfileCache';
5
- export * from './hooks/useRichTextProfile';
1
+ export * from "./components/ReactSlate";
2
+ export * from "./components/SimpleRichTextEditor";
3
+ export * from "./types";
4
+ export * from "./utils/profileServiceCache";
5
+ export * from "./hooks/useProfileCache";
6
+ export * from "./hooks/useRichTextProfile";
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/editor/field-types/richtext/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,SAAS,CAAC;AACxB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC"}
@@ -1,10 +1,10 @@
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' {
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
8
  interface CustomTypes {
9
9
  Editor: BaseEditor & ReactEditor & HistoryEditor & {
10
10
  isMarkActive(format: string): boolean;
@@ -17,8 +17,8 @@ declare module 'slate' {
17
17
  insertLink(options?: {
18
18
  onOpenLinkDialog?: (callback: (link: any) => void) => void;
19
19
  }): void;
20
- isListActive(listType?: 'unordered' | 'ordered'): boolean;
21
- toggleList(listType: 'unordered' | 'ordered'): void;
20
+ isListActive(listType?: "unordered" | "ordered"): boolean;
21
+ toggleList(listType: "unordered" | "ordered"): void;
22
22
  indentList(): void;
23
23
  outdentList(): void;
24
24
  };
@@ -37,29 +37,29 @@ export type CustomText = {
37
37
  extrabold?: boolean;
38
38
  isRawHtml?: boolean;
39
39
  };
40
- export type Alignment = 'left' | 'center' | 'right' | 'justify';
40
+ export type Alignment = "left" | "center" | "right" | "justify";
41
41
  export type CustomElement = {
42
42
  type: string;
43
43
  align?: Alignment;
44
- listType?: 'unordered' | 'ordered';
44
+ listType?: "unordered" | "ordered";
45
45
  indent?: number;
46
46
  children: (CustomText | CustomElement)[];
47
47
  [key: string]: any;
48
48
  };
49
49
  export type PreservedElement = CustomElement & {
50
- type: 'preserved-element';
50
+ type: "preserved-element";
51
51
  originalTag: string;
52
52
  originalHtml: string;
53
53
  attributes: Record<string, any>;
54
54
  };
55
55
  export type PreservedInlineElement = CustomElement & {
56
- type: 'preserved-inline';
56
+ type: "preserved-inline";
57
57
  originalTag: string;
58
58
  originalHtml: string;
59
59
  attributes: Record<string, any>;
60
60
  };
61
61
  export type LinkElement = CustomElement & {
62
- type: 'link';
62
+ type: "link";
63
63
  link: Link;
64
64
  };
65
65
  export interface ReactSlateProps {
@@ -95,13 +95,13 @@ export interface ToolbarButtonProps {
95
95
  export interface ToolbarGroupConfig {
96
96
  id: string;
97
97
  label?: string;
98
- display?: 'buttons' | 'dropdown';
98
+ display?: "buttons" | "dropdown";
99
99
  showIconsOnly?: boolean;
100
100
  options: ToolbarOptionConfig[];
101
101
  row?: number;
102
102
  }
103
103
  export interface ToolbarOptionConfig {
104
- type: 'mark' | 'block' | 'alignment' | 'link' | 'list' | 'divider' | string;
104
+ type: "mark" | "block" | "alignment" | "link" | "list" | "divider" | string;
105
105
  id: string;
106
106
  }
107
107
  export type RichTextEditorProfile = {