@alpaca-editor/core 1.0.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 (239) hide show
  1. package/.prettierrc +3 -0
  2. package/eslint.config.mjs +4 -0
  3. package/images/bg-shape-black.webp +0 -0
  4. package/package.json +52 -0
  5. package/src/client-components/api.ts +6 -0
  6. package/src/client-components/index.ts +19 -0
  7. package/src/components/ActionButton.tsx +43 -0
  8. package/src/components/Error.tsx +57 -0
  9. package/src/config/config.tsx +737 -0
  10. package/src/config/types.ts +263 -0
  11. package/src/editor/ComponentInfo.tsx +77 -0
  12. package/src/editor/ConfirmationDialog.tsx +103 -0
  13. package/src/editor/ContentTree.tsx +654 -0
  14. package/src/editor/ContextMenu.tsx +155 -0
  15. package/src/editor/Editor.tsx +91 -0
  16. package/src/editor/EditorWarning.tsx +34 -0
  17. package/src/editor/EditorWarnings.tsx +33 -0
  18. package/src/editor/FieldEditorPopup.tsx +65 -0
  19. package/src/editor/FieldHistory.tsx +74 -0
  20. package/src/editor/FieldList.tsx +190 -0
  21. package/src/editor/FieldListField.tsx +387 -0
  22. package/src/editor/FieldListFieldWithFallbacks.tsx +211 -0
  23. package/src/editor/FloatingToolbar.tsx +163 -0
  24. package/src/editor/ImageEditor.tsx +129 -0
  25. package/src/editor/InsertMenu.tsx +332 -0
  26. package/src/editor/ItemInfo.tsx +90 -0
  27. package/src/editor/LinkEditorDialog.tsx +192 -0
  28. package/src/editor/MainLayout.tsx +94 -0
  29. package/src/editor/NewEditorClient.tsx +11 -0
  30. package/src/editor/PictureCropper.tsx +505 -0
  31. package/src/editor/PictureEditor.tsx +206 -0
  32. package/src/editor/PictureEditorDialog.tsx +381 -0
  33. package/src/editor/PublishDialog.ignore +74 -0
  34. package/src/editor/ScrollingContentTree.tsx +47 -0
  35. package/src/editor/Terminal.tsx +215 -0
  36. package/src/editor/Titlebar.tsx +23 -0
  37. package/src/editor/ai/AiPopup.tsx +59 -0
  38. package/src/editor/ai/AiResponseMessage.tsx +82 -0
  39. package/src/editor/ai/AiTerminal.tsx +450 -0
  40. package/src/editor/ai/AiToolCall.tsx +46 -0
  41. package/src/editor/ai/EditorAiTerminal.tsx +20 -0
  42. package/src/editor/ai/editorAiContext.ts +18 -0
  43. package/src/editor/client/DialogContext.tsx +49 -0
  44. package/src/editor/client/EditorClient.tsx +1831 -0
  45. package/src/editor/client/GenericDialog.tsx +50 -0
  46. package/src/editor/client/editContext.ts +330 -0
  47. package/src/editor/client/helpers.ts +44 -0
  48. package/src/editor/client/itemsRepository.ts +391 -0
  49. package/src/editor/client/operations.ts +610 -0
  50. package/src/editor/client/pageModelBuilder.ts +182 -0
  51. package/src/editor/commands/commands.ts +23 -0
  52. package/src/editor/commands/componentCommands.tsx +408 -0
  53. package/src/editor/commands/createVersionCommand.ts +33 -0
  54. package/src/editor/commands/deleteVersionCommand.ts +71 -0
  55. package/src/editor/commands/itemCommands.tsx +186 -0
  56. package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +201 -0
  57. package/src/editor/commands/undo.ts +39 -0
  58. package/src/editor/component-designer/ComponentDesigner.tsx +70 -0
  59. package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +11 -0
  60. package/src/editor/component-designer/ComponentDesignerMenu.tsx +91 -0
  61. package/src/editor/component-designer/ComponentEditor.tsx +97 -0
  62. package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +31 -0
  63. package/src/editor/component-designer/ComponentRenderingEditor.tsx +104 -0
  64. package/src/editor/component-designer/ComponentsDropdown.tsx +39 -0
  65. package/src/editor/component-designer/PlaceholdersEditor.tsx +183 -0
  66. package/src/editor/component-designer/RenderingsDropdown.tsx +36 -0
  67. package/src/editor/component-designer/TemplateEditor.tsx +236 -0
  68. package/src/editor/component-designer/aiContext.ts +23 -0
  69. package/src/editor/componentTreeHelper.tsx +114 -0
  70. package/src/editor/control-center/ControlCenterMenu.tsx +71 -0
  71. package/src/editor/control-center/IndexOverview.tsx +50 -0
  72. package/src/editor/control-center/IndexSettings.tsx +266 -0
  73. package/src/editor/control-center/Status.tsx +7 -0
  74. package/src/editor/editor-warnings/ItemLocked.tsx +63 -0
  75. package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +22 -0
  76. package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +23 -0
  77. package/src/editor/editor-warnings/NoWriteAccess.tsx +15 -0
  78. package/src/editor/editor-warnings/ValidationErrors.tsx +54 -0
  79. package/src/editor/field-types/AttachmentEditor.tsx +9 -0
  80. package/src/editor/field-types/CheckboxEditor.tsx +47 -0
  81. package/src/editor/field-types/DropLinkEditor.tsx +75 -0
  82. package/src/editor/field-types/DropListEditor.tsx +84 -0
  83. package/src/editor/field-types/ImageFieldEditor.tsx +65 -0
  84. package/src/editor/field-types/InternalLinkFieldEditor.tsx +112 -0
  85. package/src/editor/field-types/LinkFieldEditor.tsx +85 -0
  86. package/src/editor/field-types/MultiLineText.tsx +63 -0
  87. package/src/editor/field-types/PictureFieldEditor.tsx +121 -0
  88. package/src/editor/field-types/RawEditor.tsx +53 -0
  89. package/src/editor/field-types/ReactQuill.tsx +580 -0
  90. package/src/editor/field-types/RichTextEditor.tsx +22 -0
  91. package/src/editor/field-types/RichTextEditorComponent.tsx +108 -0
  92. package/src/editor/field-types/SingleLineText.tsx +150 -0
  93. package/src/editor/field-types/TreeListEditor.tsx +261 -0
  94. package/src/editor/fieldTypes.ts +140 -0
  95. package/src/editor/media-selector/AiImageSearch.tsx +186 -0
  96. package/src/editor/media-selector/AiImageSearchPrompt.tsx +95 -0
  97. package/src/editor/media-selector/MediaSelector.tsx +42 -0
  98. package/src/editor/media-selector/Preview.tsx +14 -0
  99. package/src/editor/media-selector/Thumbnails.tsx +48 -0
  100. package/src/editor/media-selector/TreeSelector.tsx +292 -0
  101. package/src/editor/media-selector/UploadZone.tsx +137 -0
  102. package/src/editor/menubar/ActionsMenu.tsx +47 -0
  103. package/src/editor/menubar/ActiveUsers.tsx +17 -0
  104. package/src/editor/menubar/ApproveAndPublish.tsx +18 -0
  105. package/src/editor/menubar/BrowseHistory.tsx +37 -0
  106. package/src/editor/menubar/ItemLanguageVersion.tsx +52 -0
  107. package/src/editor/menubar/LanguageSelector.tsx +152 -0
  108. package/src/editor/menubar/Menu.tsx +83 -0
  109. package/src/editor/menubar/NavButtons.tsx +74 -0
  110. package/src/editor/menubar/PageSelector.tsx +139 -0
  111. package/src/editor/menubar/PageViewerControls.tsx +99 -0
  112. package/src/editor/menubar/Separator.tsx +12 -0
  113. package/src/editor/menubar/SiteInfo.tsx +53 -0
  114. package/src/editor/menubar/User.tsx +27 -0
  115. package/src/editor/menubar/VersionSelector.tsx +143 -0
  116. package/src/editor/page-editor-chrome/CommentHighlighting.tsx +287 -0
  117. package/src/editor/page-editor-chrome/CommentHighlightings.tsx +35 -0
  118. package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +44 -0
  119. package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +23 -0
  120. package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +64 -0
  121. package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +35 -0
  122. package/src/editor/page-editor-chrome/FrameMenu.tsx +263 -0
  123. package/src/editor/page-editor-chrome/FrameMenus.tsx +48 -0
  124. package/src/editor/page-editor-chrome/InlineEditor.tsx +147 -0
  125. package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +61 -0
  126. package/src/editor/page-editor-chrome/NoLayout.tsx +36 -0
  127. package/src/editor/page-editor-chrome/PageEditorChrome.tsx +119 -0
  128. package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +154 -0
  129. package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +171 -0
  130. package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +233 -0
  131. package/src/editor/page-viewer/DeviceToolbar.tsx +70 -0
  132. package/src/editor/page-viewer/EditorForm.tsx +247 -0
  133. package/src/editor/page-viewer/MiniMap.tsx +351 -0
  134. package/src/editor/page-viewer/PageViewer.tsx +127 -0
  135. package/src/editor/page-viewer/PageViewerFrame.tsx +1030 -0
  136. package/src/editor/page-viewer/pageViewContext.ts +186 -0
  137. package/src/editor/pageModel.ts +191 -0
  138. package/src/editor/picture-shared.tsx +53 -0
  139. package/src/editor/reviews/Comment.tsx +265 -0
  140. package/src/editor/reviews/Comments.tsx +50 -0
  141. package/src/editor/reviews/PreviewInfo.tsx +35 -0
  142. package/src/editor/reviews/Reviews.tsx +280 -0
  143. package/src/editor/reviews/reviewCommands.tsx +47 -0
  144. package/src/editor/reviews/useReviews.tsx +70 -0
  145. package/src/editor/services/aiService.ts +155 -0
  146. package/src/editor/services/componentDesignerService.ts +151 -0
  147. package/src/editor/services/contentService.ts +159 -0
  148. package/src/editor/services/editService.ts +462 -0
  149. package/src/editor/services/indexService.ts +24 -0
  150. package/src/editor/services/reviewsService.ts +45 -0
  151. package/src/editor/services/serviceHelper.ts +95 -0
  152. package/src/editor/services/systemService.ts +5 -0
  153. package/src/editor/services/translationService.ts +21 -0
  154. package/src/editor/services-server/api.ts +150 -0
  155. package/src/editor/services-server/graphQL.ts +106 -0
  156. package/src/editor/sidebar/ComponentPalette.tsx +146 -0
  157. package/src/editor/sidebar/ComponentTree.tsx +512 -0
  158. package/src/editor/sidebar/ComponentTree2.tsxx +490 -0
  159. package/src/editor/sidebar/Debug.tsx +105 -0
  160. package/src/editor/sidebar/DictionaryEditor.tsx +261 -0
  161. package/src/editor/sidebar/EditHistory.tsx +134 -0
  162. package/src/editor/sidebar/GraphQL.tsx +164 -0
  163. package/src/editor/sidebar/Insert.tsx +35 -0
  164. package/src/editor/sidebar/MainContentTree.tsx +95 -0
  165. package/src/editor/sidebar/Performance.tsx +53 -0
  166. package/src/editor/sidebar/Sessions.tsx +35 -0
  167. package/src/editor/sidebar/Sidebar.tsx +20 -0
  168. package/src/editor/sidebar/SidebarView.tsx +150 -0
  169. package/src/editor/sidebar/Translations.tsx +276 -0
  170. package/src/editor/sidebar/Validation.tsx +102 -0
  171. package/src/editor/sidebar/ViewSelector.tsx +49 -0
  172. package/src/editor/sidebar/Workbox.tsx +209 -0
  173. package/src/editor/ui/CenteredMessage.tsx +7 -0
  174. package/src/editor/ui/CopyToClipboardButton.tsx +23 -0
  175. package/src/editor/ui/DialogButtons.tsx +11 -0
  176. package/src/editor/ui/Icons.tsx +585 -0
  177. package/src/editor/ui/ItemNameDialog.tsx +94 -0
  178. package/src/editor/ui/ItemNameDialogNew.tsx +118 -0
  179. package/src/editor/ui/ItemSearch.tsx +173 -0
  180. package/src/editor/ui/PerfectTree.tsx +550 -0
  181. package/src/editor/ui/Section.tsx +35 -0
  182. package/src/editor/ui/SimpleIconButton.tsx +43 -0
  183. package/src/editor/ui/SimpleMenu.tsx +48 -0
  184. package/src/editor/ui/SimpleTable.tsx +63 -0
  185. package/src/editor/ui/SimpleTabs.tsx +55 -0
  186. package/src/editor/ui/SimpleToolbar.tsx +7 -0
  187. package/src/editor/ui/Spinner.tsx +7 -0
  188. package/src/editor/ui/Splitter.tsx +247 -0
  189. package/src/editor/ui/StackedPanels.tsx +134 -0
  190. package/src/editor/ui/Toolbar.tsx +7 -0
  191. package/src/editor/utils/id-helper.ts +3 -0
  192. package/src/editor/utils/insertOptions.ts +69 -0
  193. package/src/editor/utils/itemutils.ts +29 -0
  194. package/src/editor/utils/useMemoDebug.ts +28 -0
  195. package/src/editor/utils.ts +435 -0
  196. package/src/editor/views/CompareView.tsx +256 -0
  197. package/src/editor/views/EditView.tsx +27 -0
  198. package/src/editor/views/ItemEditor.tsx +58 -0
  199. package/src/editor/views/SingleEditView.tsx +44 -0
  200. package/src/fonts/Geist-Black.woff2 +0 -0
  201. package/src/fonts/Geist-Bold.woff2 +0 -0
  202. package/src/fonts/Geist-ExtraBold.woff2 +0 -0
  203. package/src/fonts/Geist-ExtraLight.woff2 +0 -0
  204. package/src/fonts/Geist-Light.woff2 +0 -0
  205. package/src/fonts/Geist-Medium.woff2 +0 -0
  206. package/src/fonts/Geist-Regular.woff2 +0 -0
  207. package/src/fonts/Geist-SemiBold.woff2 +0 -0
  208. package/src/fonts/Geist-Thin.woff2 +0 -0
  209. package/src/fonts/Geist[wght].woff2 +0 -0
  210. package/src/index.ts +7 -0
  211. package/src/page-wizard/PageWizard.tsx +163 -0
  212. package/src/page-wizard/SelectWizard.tsx +109 -0
  213. package/src/page-wizard/WizardSteps.tsx +207 -0
  214. package/src/page-wizard/service.ts +35 -0
  215. package/src/page-wizard/startPageWizardCommand.ts +27 -0
  216. package/src/page-wizard/steps/BuildPageStep.tsx +266 -0
  217. package/src/page-wizard/steps/CollectStep.tsx +233 -0
  218. package/src/page-wizard/steps/ComponentTypesSelector.tsx +443 -0
  219. package/src/page-wizard/steps/Components.tsx +193 -0
  220. package/src/page-wizard/steps/CreatePage.tsx +285 -0
  221. package/src/page-wizard/steps/CreatePageAndLayoutStep.tsx +384 -0
  222. package/src/page-wizard/steps/EditButton.tsx +34 -0
  223. package/src/page-wizard/steps/FieldEditor.tsx +102 -0
  224. package/src/page-wizard/steps/Generate.tsx +32 -0
  225. package/src/page-wizard/steps/ImagesStep.tsx +318 -0
  226. package/src/page-wizard/steps/LayoutStep.tsx +228 -0
  227. package/src/page-wizard/steps/SelectStep.tsx +256 -0
  228. package/src/page-wizard/steps/schema.ts +180 -0
  229. package/src/page-wizard/steps/usePageCreator.ts +279 -0
  230. package/src/splash-screen/NewPage.tsx +232 -0
  231. package/src/splash-screen/SectionHeadline.tsx +21 -0
  232. package/src/splash-screen/SplashScreen.tsx +156 -0
  233. package/src/tour/Tour.tsx +558 -0
  234. package/src/tour/default-tour.tsx +300 -0
  235. package/src/tour/preview-tour.tsx +127 -0
  236. package/src/types.ts +302 -0
  237. package/styles.css +476 -0
  238. package/tsconfig.build.json +21 -0
  239. package/tsconfig.json +11 -0
@@ -0,0 +1,737 @@
1
+ import {
2
+ ClientFieldButton,
3
+ EditorConfiguration,
4
+ MenuItem,
5
+ RichTextEditorProfile,
6
+ } from "./types";
7
+ import { RichTextEditor } from "../editor/field-types/RichTextEditor";
8
+ import { LinkFieldEditor } from "../editor/field-types/LinkFieldEditor";
9
+ import { PictureFieldEditor } from "../editor/field-types/PictureFieldEditor";
10
+ import { InternalLinkFieldEditor } from "../editor/field-types/InternalLinkFieldEditor";
11
+ import TreeListEditor from "../editor/field-types/TreeListEditor";
12
+ import { SingleLineText } from "../editor/field-types/SingleLineText";
13
+ import { MultiLineText } from "../editor/field-types/MultiLineText";
14
+ import { DropLinkEditor } from "../editor/field-types/DropLinkEditor";
15
+ import { DropListEditor } from "../editor/field-types/DropListEditor";
16
+ import { RawEditor } from "../editor/field-types/RawEditor";
17
+ import { CheckboxEditor } from "../editor/field-types/CheckboxEditor";
18
+
19
+ import { ItemLocked } from "../editor/editor-warnings/ItemLocked";
20
+ import { NoWriteAccess } from "../editor/editor-warnings/NoWriteAccess";
21
+ import { ValidationErrors } from "../editor/editor-warnings/ValidationErrors";
22
+ import { ComponentTree } from "../editor/sidebar/ComponentTree";
23
+ import { Performance } from "../editor/sidebar/Performance";
24
+
25
+ import { EditHistory } from "../editor/sidebar/EditHistory";
26
+ import { Sessions } from "../editor/sidebar/Sessions";
27
+ import { Workbox } from "../editor/sidebar/Workbox";
28
+ import { DictionaryEditor } from "../editor/sidebar/DictionaryEditor";
29
+ import {
30
+ BugIcon,
31
+ EditIcon,
32
+ GraphQLIcon,
33
+ JsonIcon,
34
+ NavigatorIcon,
35
+ PageWizardIcon,
36
+ WizardIcon,
37
+ } from "../editor/ui/Icons";
38
+ import { Debug } from "../editor/sidebar/Debug";
39
+ import { GraphQL } from "../editor/sidebar/GraphQL";
40
+
41
+ import { EditorAiTerminal } from "../editor/ai/EditorAiTerminal";
42
+
43
+ import { EditContextType } from "../editor/client/editContext";
44
+
45
+ import { Titlebar } from "../editor/Titlebar";
46
+ import { NoWriteLanguageAccess } from "../editor/editor-warnings/NoLanguageWriteAccess";
47
+ import { NoWorkflowWriteAccess } from "../editor/editor-warnings/NoWorkflowWriteAccess";
48
+ import { SplashScreen } from "../splash-screen/SplashScreen";
49
+ import { PageViewerControls } from "../editor/menubar/PageViewerControls";
50
+ import { ItemLanguageVersion } from "../editor/menubar/ItemLanguageVersion";
51
+ import { ActiveUsers } from "../editor/menubar/ActiveUsers";
52
+ import { Validation } from "../editor/sidebar/Validation";
53
+ import { Separator } from "../editor/menubar/Separator";
54
+ import { Field, FieldButton, FullItem } from "../editor/pageModel";
55
+ import { LinkValue } from "../editor/fieldTypes";
56
+ import {
57
+ deleteItemCommand,
58
+ insertItemCommand,
59
+ ItemCommand,
60
+ publishItemCommand,
61
+ renameItemCommand,
62
+ } from "../editor/commands/itemCommands";
63
+ import { loadInsertOptions } from "../editor/services/editService";
64
+ import { getDefaultTourSteps } from "../tour/default-tour";
65
+ import { Translation } from "../editor/sidebar/Translations";
66
+ import { EditView } from "../editor/views/EditView";
67
+ import { InsertMenuTemplate } from "../editor/InsertMenu";
68
+ import { ControlCenterMenu } from "../editor/control-center/ControlCenterMenu";
69
+ import { Status } from "../editor/control-center/Status";
70
+ import { IndexOverview } from "../editor/control-center/IndexOverview";
71
+ import { MainContentTree } from "../editor/sidebar/MainContentTree";
72
+ import { AttachmentEditor } from "../editor/field-types/AttachmentEditor";
73
+ import { Comments } from "../editor/reviews/Comments";
74
+ import { Reviews } from "../editor/reviews/Reviews";
75
+
76
+ import { rejectReviewCommand } from "../editor/reviews/reviewCommands";
77
+ import { approveReviewCommand } from "../editor/reviews/reviewCommands";
78
+ import { ActionsMenu } from "../editor/menubar/ActionsMenu";
79
+ import { User } from "../types";
80
+ import { PreviewInfo } from "../editor/reviews/PreviewInfo";
81
+ import { getPreviewTourSteps } from "../tour/preview-tour";
82
+ import { PageWizard } from "../page-wizard/PageWizard";
83
+ import { CollectStep } from "../page-wizard/steps/CollectStep";
84
+ import { LayoutStep } from "../page-wizard/steps/LayoutStep";
85
+ import { BuildPageStep } from "../page-wizard/steps/BuildPageStep";
86
+ import { SelectStep } from "../page-wizard/steps/SelectStep";
87
+ import { ImagesStep } from "../page-wizard/steps/ImagesStep";
88
+ import { CreatePageAndLayoutStep } from "../page-wizard/steps/CreatePageAndLayoutStep";
89
+ import { getWizards } from "../page-wizard/service";
90
+
91
+ import { startPageWizardCommand } from "../page-wizard/startPageWizardCommand";
92
+ import { ImageFieldEditor } from "../editor/field-types/ImageFieldEditor";
93
+ import { FieldAction } from "./types";
94
+
95
+ const defaultRichTextEditorProfile: RichTextEditorProfile = {
96
+ toolbar: {
97
+ groups: [
98
+ {
99
+ items: ["bold", "italic", "underline", "strikethrough"],
100
+ },
101
+ ],
102
+ },
103
+ };
104
+
105
+ export const contentItemId = "0DE95AE4-41AB-4D01-9EB0-67441B7C2450";
106
+ export const templatesRootItemId = "3c1715fe-6a13-4fcf-845f-de308ba9741d";
107
+
108
+ const openTargetActionButton: ClientFieldButton = {
109
+ label: "Open target item",
110
+ icon: "pi pi-external-link",
111
+ clientAction: ({ field, editContext }) => {
112
+ const fieldValue = field.value as LinkValue;
113
+
114
+ if (fieldValue?.targetItemId) {
115
+ editContext.loadItem({
116
+ id: fieldValue.targetItemId,
117
+ language: field.descriptor.item.language,
118
+ version: 0,
119
+ });
120
+ }
121
+ },
122
+ isGenerator: false,
123
+ id: "open-target-in-content-editor",
124
+ description: "Opens the target item in the content/page editor",
125
+ };
126
+
127
+ const pageEditorRightSidebar = {
128
+ title: "COMPONENT NAVIGATOR & HISTORY",
129
+ panels: [
130
+ {
131
+ name: "component-tree",
132
+ icon: <NavigatorIcon />,
133
+ title: "Component Navigator",
134
+ content: <ComponentTree />,
135
+ initialSize: 20,
136
+ },
137
+ {
138
+ name: "history",
139
+ icon: "pi pi-clock",
140
+ title: "History",
141
+ content: <EditHistory />,
142
+ initialSize: 15,
143
+ },
144
+ ],
145
+ };
146
+
147
+ const editView = <EditView />;
148
+ const editPrimaryControls = <PageViewerControls />;
149
+ const itemPageEditorSecondaryControls = (
150
+ <div className="flex items-center gap-2">
151
+ <ItemLanguageVersion />
152
+ <Separator size="large" />
153
+ <ActiveUsers />
154
+ <ActionsMenu />
155
+ </div>
156
+ );
157
+
158
+ const pageEditorViewBase = {
159
+ primaryControls: editPrimaryControls,
160
+ secondaryControls: itemPageEditorSecondaryControls,
161
+ rightSidebar: pageEditorRightSidebar,
162
+ defaultCenterPanelView: editView,
163
+ };
164
+
165
+ export const getConfiguration = (): EditorConfiguration => {
166
+ return {
167
+ extensions: {},
168
+ tours: {
169
+ default: {
170
+ getSteps: (params) =>
171
+ getDefaultTourSteps(params, {
172
+ firstComponentTemplateId: "39593ec8-0d85-46f2-9573-c368ef7e4ae3",
173
+ firstComponentTemplateName: "Section",
174
+ firstComponentTextFieldName: "Title",
175
+ firstComponentTextFieldId: "f352f51f-062c-4874-a561-6283f8679583",
176
+ firstComponentRichTextFieldName: "Introduction",
177
+ firstComponentRichTextFieldId:
178
+ "b44b547b-33f5-4379-8ac3-c57ccea2d407",
179
+ }),
180
+ },
181
+ preview: {
182
+ getSteps: (params) => getPreviewTourSteps(params),
183
+ },
184
+ },
185
+ activeTour: "default",
186
+ commands: {
187
+ renameItem: renameItemCommand,
188
+ deleteItem: deleteItemCommand,
189
+ insertItem: insertItemCommand,
190
+ publishItem: publishItemCommand,
191
+ allItemCommands: [
192
+ renameItemCommand,
193
+ deleteItemCommand,
194
+ publishItemCommand,
195
+ ],
196
+ reviewcommands: [approveReviewCommand, rejectReviewCommand],
197
+ },
198
+ events: {},
199
+ services: {
200
+ renderService: { path: "/alpaca/editor/render" },
201
+ editorService: {
202
+ //baseUrl: "",
203
+ },
204
+ aiService: {
205
+ promptUrl: "/alpaca/editor/ai/prompt",
206
+ },
207
+ },
208
+ fieldTypes: {
209
+ raw: {
210
+ editor: RawEditor,
211
+ },
212
+ "single-line text": {
213
+ editor: SingleLineText,
214
+ },
215
+ "multi-line text": {
216
+ editor: MultiLineText,
217
+ },
218
+ "rich text": {
219
+ editor: RichTextEditor,
220
+ custom: {
221
+ profiles: { default: defaultRichTextEditorProfile },
222
+ },
223
+ },
224
+ "general link": {
225
+ editor: LinkFieldEditor,
226
+ },
227
+ picture: {
228
+ editor: PictureFieldEditor,
229
+ },
230
+ image: {
231
+ editor: ImageFieldEditor,
232
+ buttons: [],
233
+ },
234
+ droplink: {
235
+ editor: DropLinkEditor,
236
+ buttons: [openTargetActionButton],
237
+ },
238
+ "enhanced dropLink": {
239
+ editor: DropLinkEditor,
240
+ buttons: [openTargetActionButton],
241
+ },
242
+ "enhanced internal link": {
243
+ editor: InternalLinkFieldEditor,
244
+ buttons: [openTargetActionButton],
245
+ },
246
+ droplist: {
247
+ editor: DropListEditor,
248
+ },
249
+ treelistex: {
250
+ editor: TreeListEditor,
251
+ },
252
+ treelist: {
253
+ editor: TreeListEditor,
254
+ },
255
+ "enhanced treelist": {
256
+ editor: TreeListEditor,
257
+ },
258
+ "tree list": {
259
+ editor: TreeListEditor,
260
+ },
261
+ multilist: {
262
+ editor: TreeListEditor,
263
+ },
264
+ checkbox: {
265
+ editor: CheckboxEditor,
266
+ },
267
+ droptree: {
268
+ editor: InternalLinkFieldEditor,
269
+ },
270
+ attachment: {
271
+ editor: AttachmentEditor,
272
+ },
273
+ },
274
+ editorWarnings: [
275
+ NoWriteAccess,
276
+ NoWriteLanguageAccess,
277
+ NoWorkflowWriteAccess,
278
+ ItemLocked,
279
+ ValidationErrors,
280
+ ],
281
+ outline: {
282
+ width: 100,
283
+ },
284
+ debounceFieldEditsInterval: 250,
285
+ devices: [
286
+ { name: "iPhone 14 Pro Max", width: 430, height: 932 },
287
+ { name: "iPhone SE", width: 375, height: 667 },
288
+ { name: "Pixel 7", width: 412, height: 915 },
289
+ { name: "iPad Mini", width: 768, height: 1024 },
290
+ { name: "iPad Pro", width: 1024, height: 1366 },
291
+ { name: "Responsive", width: undefined, height: undefined },
292
+ ],
293
+
294
+ pageWizard: {
295
+ getWizards: getWizards,
296
+ startWizardCommand: startPageWizardCommand,
297
+
298
+ stepComponents: {
299
+ CollectStep,
300
+ LayoutStep,
301
+ BuildPageStep,
302
+ SelectStep,
303
+ ImagesStep,
304
+ CreatePageAndLayoutStep,
305
+ },
306
+ },
307
+
308
+ controlCenter: {
309
+ groups: [
310
+ {
311
+ title: "Indexing",
312
+ icon: <i className="pi pi-search" />,
313
+ panels: [
314
+ {
315
+ id: "indexes",
316
+ title: "All Indexes",
317
+ icon: <i className="pi pi-search" />,
318
+ content: <IndexOverview />,
319
+ },
320
+ ],
321
+ },
322
+ ],
323
+ },
324
+ editor: {
325
+ defaultPanelSizes: [400, 300],
326
+ dialogs: {
327
+ newPage: {
328
+ expandTreeNode: "bafb88a1-506a-4671-b47b-1947730d25f6",
329
+ },
330
+ },
331
+ views: [
332
+ {
333
+ name: "splash-screen",
334
+ title: "Splash Screen",
335
+ icon: "pi pi-home",
336
+ hidden: true,
337
+ defaultCenterPanelView: <SplashScreen />,
338
+ hideViewSelector: true,
339
+ },
340
+ {
341
+ name: "page-editor",
342
+ title: "Edit",
343
+ icon: <EditIcon />,
344
+
345
+ ...pageEditorViewBase,
346
+ },
347
+ {
348
+ name: "ai",
349
+ title: "AI",
350
+ icon: <WizardIcon />,
351
+ leftSidebar: {
352
+ panels: [
353
+ {
354
+ name: "ai-terminal",
355
+ icon: "pi pi-comments",
356
+ title: "AI",
357
+ content: <EditorAiTerminal />,
358
+ initialSize: 70,
359
+ noOverflow: true,
360
+ },
361
+ ],
362
+ },
363
+ ...pageEditorViewBase,
364
+ },
365
+ {
366
+ name: "translate",
367
+ icon: "pi pi-language",
368
+ title: "Translate",
369
+ leftSidebar: {
370
+ panels: [
371
+ {
372
+ name: "translation",
373
+ icon: "pi pi-language",
374
+ title: "Translations",
375
+ content: <Translation />,
376
+ initialSize: 20,
377
+ },
378
+ ],
379
+ },
380
+ ...pageEditorViewBase,
381
+ },
382
+ {
383
+ name: "reviews",
384
+ title: "Reviews",
385
+ icon: "pi pi-comments",
386
+ leftSidebar: {
387
+ panels: [
388
+ {
389
+ name: "comments",
390
+ icon: "pi pi-comments",
391
+ title: "Comments",
392
+ content: <Comments />,
393
+ initialSize: 65,
394
+ noOverflow: true,
395
+ },
396
+ {
397
+ name: "reviews",
398
+ icon: "pi pi-users",
399
+ title: "Reviews",
400
+ content: <Reviews />,
401
+ initialSize: 35,
402
+ noOverflow: true,
403
+ },
404
+ ],
405
+ },
406
+ ...pageEditorViewBase,
407
+ },
408
+ {
409
+ name: "publish",
410
+ title: "Publish",
411
+ icon: "pi pi-globe",
412
+
413
+ leftSidebar: {
414
+ panels: [
415
+ {
416
+ name: "Workbox",
417
+ title: "Workbox",
418
+ icon: "pi-inbox",
419
+ content: <Workbox />,
420
+ initialSize: 50,
421
+ },
422
+ {
423
+ name: "Validation",
424
+ title: "Validation",
425
+ icon: "pi-check",
426
+ content: <Validation />,
427
+ initialSize: 50,
428
+ },
429
+ ],
430
+ },
431
+
432
+ ...pageEditorViewBase,
433
+ },
434
+ {
435
+ name: "content-editor",
436
+ title: "Content Editor",
437
+ icon: "pi pi-sitemap",
438
+ defaultCenterPanelView: editView,
439
+ leftSidebar: {
440
+ panels: [
441
+ {
442
+ name: "tree",
443
+ icon: "pi pi-sitemap",
444
+ title: "Content",
445
+ content: <MainContentTree mode="normal" />,
446
+ initialSize: 80,
447
+ },
448
+ ],
449
+ },
450
+ rightSidebar: pageEditorRightSidebar,
451
+ primaryControls: editPrimaryControls,
452
+ secondaryControls: itemPageEditorSecondaryControls,
453
+ },
454
+
455
+ {
456
+ name: "dictionary",
457
+ title: "Dictionary",
458
+ icon: "pi pi-book",
459
+ leftSidebar: {
460
+ panels: [
461
+ {
462
+ name: "dictionary",
463
+ icon: "pi pi-book",
464
+ title: "Dictionary",
465
+ content: <DictionaryEditor />,
466
+ initialSize: 100,
467
+ },
468
+ ],
469
+ },
470
+ ...pageEditorViewBase,
471
+ },
472
+
473
+ {
474
+ name: "sessions",
475
+ title: "Sessions",
476
+ icon: "pi pi-users",
477
+ leftSidebar: {
478
+ panels: [
479
+ {
480
+ name: "sessions",
481
+ icon: "pi pi-users",
482
+ title: "Sessions",
483
+ content: <Sessions />,
484
+ initialSize: 100,
485
+ },
486
+ ],
487
+ },
488
+ ...pageEditorViewBase,
489
+ },
490
+ {
491
+ name: "debug",
492
+ title: "Debug",
493
+ icon: <BugIcon />,
494
+
495
+ leftSidebar: {
496
+ panels: [
497
+ {
498
+ name: "component-tree",
499
+ icon: "pi pi-list",
500
+ title: "Outline",
501
+ content: <ComponentTree />,
502
+ initialSize: 20,
503
+ },
504
+ {
505
+ name: "debug",
506
+ icon: <JsonIcon />,
507
+ title: "JSON",
508
+ content: <Debug />,
509
+ initialSize: 30,
510
+ },
511
+ {
512
+ name: "graphql",
513
+ icon: <GraphQLIcon />,
514
+ title: "GraphQL",
515
+ content: <GraphQL />,
516
+ initialSize: 30,
517
+ },
518
+ {
519
+ name: "performance",
520
+ icon: "pi pi-stopwatch",
521
+ title: "Performance",
522
+ content: <Performance />,
523
+ initialSize: 20,
524
+ },
525
+ ],
526
+ },
527
+ ...pageEditorViewBase,
528
+ },
529
+ // {
530
+ // name: "component-designer",
531
+ // title: "Component Designer",
532
+ // icon: "pi pi-palette",
533
+ // defaultCenterPanelView: <ComponentDesigner />,
534
+ // menuBar: <ComponentDesignerMenu />,
535
+ // leftSidebar: {
536
+ // panels: [
537
+ // {
538
+ // name: "component-tree",
539
+ // icon: "pi pi-list",
540
+ // title: "Outline",
541
+ // content: <ComponentTree />,
542
+ // initialSize: 30,
543
+ // },
544
+ // {
545
+ // name: "ai-terminal",
546
+ // icon: "pi pi-comments",
547
+ // title: "AI",
548
+ // content: <ComponentDesignerAiTerminal />,
549
+ // initialSize: 40,
550
+ // },
551
+ // {
552
+ // name: "history",
553
+ // icon: "pi pi-clock",
554
+ // title: "History",
555
+ // content: <EditHistory />,
556
+ // initialSize: 30,
557
+ // },
558
+ // ],
559
+ // },
560
+ // },
561
+ {
562
+ name: "page-wizard",
563
+ title: "Page Wizard",
564
+ icon: <PageWizardIcon />,
565
+ defaultCenterPanelView: <PageWizard />,
566
+ hidden: true,
567
+ },
568
+ {
569
+ name: "control-center",
570
+ title: "Control Center",
571
+ icon: "pi pi-cog",
572
+ defaultCenterPanelView: <Status />,
573
+ menuBar: <></>,
574
+ leftSidebar: {
575
+ panels: [
576
+ {
577
+ name: "settings",
578
+ icon: "pi pi-cog",
579
+ title: "Control Center",
580
+ content: <ControlCenterMenu />,
581
+ initialSize: 30,
582
+ },
583
+ ],
584
+ },
585
+ },
586
+ ],
587
+
588
+ titlebar: <Titlebar />,
589
+ actionsMenu: {
590
+ itemsFactory: (editContext: EditContextType) => {
591
+ const commands = [
592
+ ...editContext.configuration.commands.reviewcommands,
593
+ "splitter",
594
+ ...editContext.configuration.commands.allItemCommands,
595
+ ];
596
+
597
+ if (!editContext.contentEditorItem) return [];
598
+
599
+ const items = [editContext.contentEditorItem];
600
+
601
+ const menuItems: MenuItem[] = [
602
+ ...commands.map((command) => {
603
+ if (typeof command === "string") {
604
+ return {
605
+ id: "separator",
606
+ separator: true,
607
+ label: "",
608
+ icon: "pi pi-splitter",
609
+ };
610
+ }
611
+ return {
612
+ id: command.id,
613
+ label: command.label,
614
+ icon: command.icon,
615
+ disabled: editContext.isCommandDisabled({
616
+ command: command,
617
+ data: { items },
618
+ }),
619
+ command: async (event: any) => {
620
+ await editContext.executeCommand({
621
+ command: command,
622
+ event: event,
623
+ data: { items },
624
+ });
625
+ },
626
+ };
627
+ }),
628
+ ];
629
+ return menuItems;
630
+ },
631
+ },
632
+
633
+ contentTree: {
634
+ contextMenu: {
635
+ factory: async (props: {
636
+ items: FullItem[];
637
+ editContext: EditContextType;
638
+ commandCallback?: (command: ItemCommand, result: any) => void;
639
+ }): Promise<MenuItem[] | undefined> => {
640
+ const editContext = props.editContext;
641
+
642
+ if (!props.items) return;
643
+
644
+ const menuItems: MenuItem[] =
645
+ props.editContext.configuration.commands.allItemCommands?.map(
646
+ (x: ItemCommand) => {
647
+ const commandData = {
648
+ items: props.items,
649
+ };
650
+
651
+ return {
652
+ id: x.id,
653
+ label: x.label,
654
+ icon: x.icon,
655
+ command: async (triggerEvent: any) => {
656
+ const result = await editContext?.executeCommand({
657
+ command: x,
658
+ data: commandData,
659
+ event: triggerEvent,
660
+ });
661
+
662
+ if (props.commandCallback)
663
+ props.commandCallback(x, result);
664
+ },
665
+ disabled: editContext?.isCommandDisabled({
666
+ command: x,
667
+ data: commandData,
668
+ }),
669
+ };
670
+ },
671
+ );
672
+
673
+ if (props.items.length > 1) return menuItems;
674
+
675
+ const item = props.items[0];
676
+ if (!item) return menuItems;
677
+ const insertOptions = await loadInsertOptions(item.descriptor);
678
+
679
+ const insertMenuItem = {
680
+ label: "Insert",
681
+ id: "insert",
682
+ disabled: insertOptions.length == 0,
683
+ icon: "pi pi-plus",
684
+ template: (
685
+ <InsertMenuTemplate
686
+ insertOptions={insertOptions}
687
+ item={item}
688
+ commandCallback={props.commandCallback}
689
+ />
690
+ ),
691
+ };
692
+
693
+ return [insertMenuItem, ...menuItems];
694
+ },
695
+ },
696
+ },
697
+ },
698
+ };
699
+ };
700
+
701
+ export function configureForUser(
702
+ configuration: EditorConfiguration,
703
+ user: User,
704
+ ): EditorConfiguration {
705
+ if (user.isLimitedPreviewUser) {
706
+ return {
707
+ ...configuration,
708
+ activeTour: "preview",
709
+
710
+ editor: {
711
+ ...configuration.editor,
712
+ views: configuration.editor.views
713
+ .filter((x) => x.name === "reviews")
714
+ .map((x) => {
715
+ return {
716
+ ...x,
717
+ leftSidebar: {
718
+ ...x.leftSidebar,
719
+ panels: [
720
+ ...(x.leftSidebar?.panels ?? []).filter(
721
+ (x) => x.name !== "reviews",
722
+ ),
723
+ ],
724
+ },
725
+ secondaryControls: (
726
+ <div className="flex items-center gap-3">
727
+ <PreviewInfo />
728
+ <ActionsMenu />
729
+ </div>
730
+ ),
731
+ };
732
+ }),
733
+ },
734
+ };
735
+ }
736
+ return configuration;
737
+ }