@alpaca-editor/core 1.0.3762-mono
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.
- package/.prettierrc +3 -0
- package/dist/client-components/api.js +6 -0
- package/dist/client-components/index.js +36 -0
- package/dist/components/ActionButton.js +9 -0
- package/dist/components/Error.js +28 -0
- package/dist/config/config.js +654 -0
- package/dist/config/types.js +2 -0
- package/dist/editor/ComponentInfo.js +31 -0
- package/dist/editor/ConfirmationDialog.js +32 -0
- package/dist/editor/ContentTree.js +406 -0
- package/dist/editor/ContextMenu.js +117 -0
- package/dist/editor/Editor.js +55 -0
- package/dist/editor/EditorWarning.js +13 -0
- package/dist/editor/EditorWarnings.js +24 -0
- package/dist/editor/FieldEditorPopup.js +24 -0
- package/dist/editor/FieldHistory.js +40 -0
- package/dist/editor/FieldList.js +63 -0
- package/dist/editor/FieldListField.js +164 -0
- package/dist/editor/FieldListFieldWithFallbacks.js +114 -0
- package/dist/editor/FloatingToolbar.js +92 -0
- package/dist/editor/ImageEditor.js +55 -0
- package/dist/editor/InsertMenu.js +164 -0
- package/dist/editor/ItemInfo.js +30 -0
- package/dist/editor/LinkEditorDialog.js +89 -0
- package/dist/editor/MainLayout.js +46 -0
- package/dist/editor/NewEditorClient.js +9 -0
- package/dist/editor/PictureCropper.js +332 -0
- package/dist/editor/PictureEditor.js +104 -0
- package/dist/editor/PictureEditorDialog.js +194 -0
- package/dist/editor/ScrollingContentTree.js +30 -0
- package/dist/editor/Terminal.js +109 -0
- package/dist/editor/Titlebar.js +11 -0
- package/dist/editor/ai/AiPopup.js +25 -0
- package/dist/editor/ai/AiResponseMessage.js +24 -0
- package/dist/editor/ai/AiTerminal.js +241 -0
- package/dist/editor/ai/AiToolCall.js +18 -0
- package/dist/editor/ai/EditorAiTerminal.js +9 -0
- package/dist/editor/ai/editorAiContext.js +14 -0
- package/dist/editor/client/DialogContext.js +29 -0
- package/dist/editor/client/EditorClient.js +1336 -0
- package/dist/editor/client/GenericDialog.js +27 -0
- package/dist/editor/client/editContext.js +59 -0
- package/dist/editor/client/helpers.js +31 -0
- package/dist/editor/client/itemsRepository.js +255 -0
- package/dist/editor/client/operations.js +398 -0
- package/dist/editor/client/pageModelBuilder.js +129 -0
- package/dist/editor/commands/commands.js +2 -0
- package/dist/editor/commands/componentCommands.js +277 -0
- package/dist/editor/commands/createVersionCommand.js +26 -0
- package/dist/editor/commands/deleteVersionCommand.js +55 -0
- package/dist/editor/commands/itemCommands.js +134 -0
- package/dist/editor/commands/localizeItem/LocalizeItemDialog.js +94 -0
- package/dist/editor/commands/undo.js +32 -0
- package/dist/editor/component-designer/ComponentDesigner.js +58 -0
- package/dist/editor/component-designer/ComponentDesignerAiTerminal.js +9 -0
- package/dist/editor/component-designer/ComponentDesignerMenu.js +67 -0
- package/dist/editor/component-designer/ComponentEditor.js +59 -0
- package/dist/editor/component-designer/ComponentRenderingCodeEditor.js +16 -0
- package/dist/editor/component-designer/ComponentRenderingEditor.js +71 -0
- package/dist/editor/component-designer/ComponentsDropdown.js +22 -0
- package/dist/editor/component-designer/PlaceholdersEditor.js +70 -0
- package/dist/editor/component-designer/RenderingsDropdown.js +25 -0
- package/dist/editor/component-designer/TemplateEditor.js +144 -0
- package/dist/editor/component-designer/aiContext.js +18 -0
- package/dist/editor/componentTreeHelper.js +97 -0
- package/dist/editor/control-center/ControlCenterMenu.js +59 -0
- package/dist/editor/control-center/IndexOverview.js +27 -0
- package/dist/editor/control-center/IndexSettings.js +106 -0
- package/dist/editor/control-center/Status.js +7 -0
- package/dist/editor/editor-warnings/ItemLocked.js +40 -0
- package/dist/editor/editor-warnings/NoLanguageWriteAccess.js +16 -0
- package/dist/editor/editor-warnings/NoWorkflowWriteAccess.js +16 -0
- package/dist/editor/editor-warnings/NoWriteAccess.js +14 -0
- package/dist/editor/editor-warnings/ValidationErrors.js +27 -0
- package/dist/editor/field-types/AttachmentEditor.js +7 -0
- package/dist/editor/field-types/CheckboxEditor.js +32 -0
- package/dist/editor/field-types/DropLinkEditor.js +51 -0
- package/dist/editor/field-types/DropListEditor.js +58 -0
- package/dist/editor/field-types/ImageFieldEditor.js +36 -0
- package/dist/editor/field-types/InternalLinkFieldEditor.js +64 -0
- package/dist/editor/field-types/LinkFieldEditor.js +58 -0
- package/dist/editor/field-types/MultiLineText.js +35 -0
- package/dist/editor/field-types/PictureFieldEditor.js +59 -0
- package/dist/editor/field-types/RawEditor.js +33 -0
- package/dist/editor/field-types/ReactQuill.js +366 -0
- package/dist/editor/field-types/RichTextEditor.js +46 -0
- package/dist/editor/field-types/RichTextEditorComponent.js +72 -0
- package/dist/editor/field-types/SingleLineText.js +92 -0
- package/dist/editor/field-types/TreeListEditor.js +137 -0
- package/dist/editor/fieldTypes.js +2 -0
- package/dist/editor/media-selector/AiImageSearch.js +110 -0
- package/dist/editor/media-selector/AiImageSearchPrompt.js +58 -0
- package/dist/editor/media-selector/MediaSelector.js +11 -0
- package/dist/editor/media-selector/Preview.js +9 -0
- package/dist/editor/media-selector/Thumbnails.js +11 -0
- package/dist/editor/media-selector/TreeSelector.js +171 -0
- package/dist/editor/media-selector/UploadZone.js +80 -0
- package/dist/editor/menubar/ActionsMenu.js +33 -0
- package/dist/editor/menubar/ActiveUsers.js +13 -0
- package/dist/editor/menubar/ApproveAndPublish.js +13 -0
- package/dist/editor/menubar/BrowseHistory.js +14 -0
- package/dist/editor/menubar/ItemLanguageVersion.js +36 -0
- package/dist/editor/menubar/LanguageSelector.js +33 -0
- package/dist/editor/menubar/Menu.js +65 -0
- package/dist/editor/menubar/NavButtons.js +43 -0
- package/dist/editor/menubar/PageSelector.js +50 -0
- package/dist/editor/menubar/PageViewerControls.js +37 -0
- package/dist/editor/menubar/Separator.js +8 -0
- package/dist/editor/menubar/SiteInfo.js +26 -0
- package/dist/editor/menubar/User.js +18 -0
- package/dist/editor/menubar/VersionSelector.js +49 -0
- package/dist/editor/page-editor-chrome/CommentHighlighting.js +214 -0
- package/dist/editor/page-editor-chrome/CommentHighlightings.js +17 -0
- package/dist/editor/page-editor-chrome/FieldActionIndicator.js +27 -0
- package/dist/editor/page-editor-chrome/FieldActionIndicators.js +15 -0
- package/dist/editor/page-editor-chrome/FieldEditedIndicator.js +27 -0
- package/dist/editor/page-editor-chrome/FieldEditedIndicators.js +15 -0
- package/dist/editor/page-editor-chrome/FrameMenu.js +178 -0
- package/dist/editor/page-editor-chrome/FrameMenus.js +24 -0
- package/dist/editor/page-editor-chrome/InlineEditor.js +101 -0
- package/dist/editor/page-editor-chrome/LockedFieldIndicator.js +35 -0
- package/dist/editor/page-editor-chrome/NoLayout.js +21 -0
- package/dist/editor/page-editor-chrome/PageEditorChrome.js +65 -0
- package/dist/editor/page-editor-chrome/PictureEditorOverlay.js +109 -0
- package/dist/editor/page-editor-chrome/PlaceholderDropZone.js +82 -0
- package/dist/editor/page-editor-chrome/PlaceholderDropZones.js +147 -0
- package/dist/editor/page-viewer/DeviceToolbar.js +21 -0
- package/dist/editor/page-viewer/EditorForm.js +130 -0
- package/dist/editor/page-viewer/MiniMap.js +257 -0
- package/dist/editor/page-viewer/PageViewer.js +64 -0
- package/dist/editor/page-viewer/PageViewerFrame.js +696 -0
- package/dist/editor/page-viewer/pageViewContext.js +117 -0
- package/dist/editor/pageModel.js +2 -0
- package/dist/editor/picture-shared.js +28 -0
- package/dist/editor/reviews/Comment.js +112 -0
- package/dist/editor/reviews/Comments.js +24 -0
- package/dist/editor/reviews/PreviewInfo.js +13 -0
- package/dist/editor/reviews/Reviews.js +165 -0
- package/dist/editor/reviews/reviewCommands.js +44 -0
- package/dist/editor/reviews/useReviews.js +48 -0
- package/dist/editor/services/aiService.js +99 -0
- package/dist/editor/services/componentDesignerService.js +79 -0
- package/dist/editor/services/contentService.js +104 -0
- package/dist/editor/services/editService.js +322 -0
- package/dist/editor/services/indexService.js +25 -0
- package/dist/editor/services/reviewsService.js +43 -0
- package/dist/editor/services/serviceHelper.js +67 -0
- package/dist/editor/services/systemService.js +7 -0
- package/dist/editor/services/translationService.js +15 -0
- package/dist/editor/services-server/api.js +119 -0
- package/dist/editor/services-server/graphQL.js +56 -0
- package/dist/editor/sidebar/ComponentPalette.js +55 -0
- package/dist/editor/sidebar/ComponentTree.js +362 -0
- package/dist/editor/sidebar/Debug.js +60 -0
- package/dist/editor/sidebar/DictionaryEditor.js +160 -0
- package/dist/editor/sidebar/EditHistory.js +74 -0
- package/dist/editor/sidebar/GraphQL.js +115 -0
- package/dist/editor/sidebar/Insert.js +24 -0
- package/dist/editor/sidebar/MainContentTree.js +52 -0
- package/dist/editor/sidebar/Performance.js +34 -0
- package/dist/editor/sidebar/Sessions.js +31 -0
- package/dist/editor/sidebar/Sidebar.js +15 -0
- package/dist/editor/sidebar/SidebarView.js +76 -0
- package/dist/editor/sidebar/Translations.js +160 -0
- package/dist/editor/sidebar/Validation.js +52 -0
- package/dist/editor/sidebar/ViewSelector.js +15 -0
- package/dist/editor/sidebar/Workbox.js +80 -0
- package/dist/editor/ui/CenteredMessage.js +7 -0
- package/dist/editor/ui/CopyToClipboardButton.js +17 -0
- package/dist/editor/ui/DialogButtons.js +7 -0
- package/dist/editor/ui/Icons.js +75 -0
- package/dist/editor/ui/ItemNameDialog.js +45 -0
- package/dist/editor/ui/ItemNameDialogNew.js +61 -0
- package/dist/editor/ui/ItemSearch.js +93 -0
- package/dist/editor/ui/PerfectTree.js +223 -0
- package/dist/editor/ui/Section.js +12 -0
- package/dist/editor/ui/SimpleIconButton.js +11 -0
- package/dist/editor/ui/SimpleMenu.js +9 -0
- package/dist/editor/ui/SimpleTable.js +11 -0
- package/dist/editor/ui/SimpleTabs.js +21 -0
- package/dist/editor/ui/SimpleToolbar.js +7 -0
- package/dist/editor/ui/Spinner.js +7 -0
- package/dist/editor/ui/Splitter.js +187 -0
- package/dist/editor/ui/StackedPanels.js +69 -0
- package/dist/editor/ui/Toolbar.js +7 -0
- package/dist/editor/utils/id-helper.js +7 -0
- package/dist/editor/utils/insertOptions.js +45 -0
- package/dist/editor/utils/itemutils.js +25 -0
- package/dist/editor/utils/useMemoDebug.js +20 -0
- package/dist/editor/utils.js +328 -0
- package/dist/editor/views/CompareView.js +147 -0
- package/dist/editor/views/EditView.js +17 -0
- package/dist/editor/views/ItemEditor.js +24 -0
- package/dist/editor/views/SingleEditView.js +25 -0
- package/dist/index.js +22 -0
- package/dist/page-wizard/PageWizard.js +62 -0
- package/dist/page-wizard/SelectWizard.js +43 -0
- package/dist/page-wizard/WizardSteps.js +71 -0
- package/dist/page-wizard/service.js +26 -0
- package/dist/page-wizard/startPageWizardCommand.js +23 -0
- package/dist/page-wizard/steps/BuildPageStep.js +138 -0
- package/dist/page-wizard/steps/CollectStep.js +124 -0
- package/dist/page-wizard/steps/ComponentTypesSelector.js +211 -0
- package/dist/page-wizard/steps/Components.js +94 -0
- package/dist/page-wizard/steps/CreatePage.js +142 -0
- package/dist/page-wizard/steps/CreatePageAndLayoutStep.js +230 -0
- package/dist/page-wizard/steps/EditButton.js +7 -0
- package/dist/page-wizard/steps/FieldEditor.js +30 -0
- package/dist/page-wizard/steps/Generate.js +11 -0
- package/dist/page-wizard/steps/ImagesStep.js +159 -0
- package/dist/page-wizard/steps/LayoutStep.js +120 -0
- package/dist/page-wizard/steps/SelectStep.js +150 -0
- package/dist/page-wizard/steps/schema.js +140 -0
- package/dist/page-wizard/steps/usePageCreator.js +194 -0
- package/dist/splash-screen/NewPage.js +131 -0
- package/dist/splash-screen/SectionHeadline.js +9 -0
- package/dist/splash-screen/SplashScreen.js +81 -0
- package/dist/tour/Tour.js +321 -0
- package/dist/tour/default-tour.js +231 -0
- package/dist/tour/preview-tour.js +93 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types.js +2 -0
- package/eslint.config.mjs +4 -0
- package/images/bg-shape-black.webp +0 -0
- package/package.json +52 -0
- package/src/client-components/api.ts +6 -0
- package/src/client-components/index.ts +19 -0
- package/src/components/ActionButton.tsx +43 -0
- package/src/components/Error.tsx +57 -0
- package/src/config/config.tsx +737 -0
- package/src/config/types.ts +263 -0
- package/src/editor/ComponentInfo.tsx +77 -0
- package/src/editor/ConfirmationDialog.tsx +103 -0
- package/src/editor/ContentTree.tsx +654 -0
- package/src/editor/ContextMenu.tsx +155 -0
- package/src/editor/Editor.tsx +91 -0
- package/src/editor/EditorWarning.tsx +34 -0
- package/src/editor/EditorWarnings.tsx +33 -0
- package/src/editor/FieldEditorPopup.tsx +65 -0
- package/src/editor/FieldHistory.tsx +74 -0
- package/src/editor/FieldList.tsx +190 -0
- package/src/editor/FieldListField.tsx +387 -0
- package/src/editor/FieldListFieldWithFallbacks.tsx +211 -0
- package/src/editor/FloatingToolbar.tsx +163 -0
- package/src/editor/ImageEditor.tsx +129 -0
- package/src/editor/InsertMenu.tsx +332 -0
- package/src/editor/ItemInfo.tsx +90 -0
- package/src/editor/LinkEditorDialog.tsx +192 -0
- package/src/editor/MainLayout.tsx +94 -0
- package/src/editor/NewEditorClient.tsx +11 -0
- package/src/editor/PictureCropper.tsx +505 -0
- package/src/editor/PictureEditor.tsx +206 -0
- package/src/editor/PictureEditorDialog.tsx +381 -0
- package/src/editor/PublishDialog.ignore +74 -0
- package/src/editor/ScrollingContentTree.tsx +47 -0
- package/src/editor/Terminal.tsx +215 -0
- package/src/editor/Titlebar.tsx +23 -0
- package/src/editor/ai/AiPopup.tsx +59 -0
- package/src/editor/ai/AiResponseMessage.tsx +82 -0
- package/src/editor/ai/AiTerminal.tsx +450 -0
- package/src/editor/ai/AiToolCall.tsx +46 -0
- package/src/editor/ai/EditorAiTerminal.tsx +20 -0
- package/src/editor/ai/editorAiContext.ts +18 -0
- package/src/editor/client/DialogContext.tsx +49 -0
- package/src/editor/client/EditorClient.tsx +1831 -0
- package/src/editor/client/GenericDialog.tsx +50 -0
- package/src/editor/client/editContext.ts +330 -0
- package/src/editor/client/helpers.ts +44 -0
- package/src/editor/client/itemsRepository.ts +391 -0
- package/src/editor/client/operations.ts +610 -0
- package/src/editor/client/pageModelBuilder.ts +182 -0
- package/src/editor/commands/commands.ts +23 -0
- package/src/editor/commands/componentCommands.tsx +408 -0
- package/src/editor/commands/createVersionCommand.ts +33 -0
- package/src/editor/commands/deleteVersionCommand.ts +71 -0
- package/src/editor/commands/itemCommands.tsx +186 -0
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +201 -0
- package/src/editor/commands/undo.ts +39 -0
- package/src/editor/component-designer/ComponentDesigner.tsx +70 -0
- package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +11 -0
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +91 -0
- package/src/editor/component-designer/ComponentEditor.tsx +97 -0
- package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +31 -0
- package/src/editor/component-designer/ComponentRenderingEditor.tsx +104 -0
- package/src/editor/component-designer/ComponentsDropdown.tsx +39 -0
- package/src/editor/component-designer/PlaceholdersEditor.tsx +183 -0
- package/src/editor/component-designer/RenderingsDropdown.tsx +36 -0
- package/src/editor/component-designer/TemplateEditor.tsx +236 -0
- package/src/editor/component-designer/aiContext.ts +23 -0
- package/src/editor/componentTreeHelper.tsx +114 -0
- package/src/editor/control-center/ControlCenterMenu.tsx +71 -0
- package/src/editor/control-center/IndexOverview.tsx +50 -0
- package/src/editor/control-center/IndexSettings.tsx +266 -0
- package/src/editor/control-center/Status.tsx +7 -0
- package/src/editor/editor-warnings/ItemLocked.tsx +63 -0
- package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +22 -0
- package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +23 -0
- package/src/editor/editor-warnings/NoWriteAccess.tsx +15 -0
- package/src/editor/editor-warnings/ValidationErrors.tsx +54 -0
- package/src/editor/field-types/AttachmentEditor.tsx +9 -0
- package/src/editor/field-types/CheckboxEditor.tsx +47 -0
- package/src/editor/field-types/DropLinkEditor.tsx +75 -0
- package/src/editor/field-types/DropListEditor.tsx +84 -0
- package/src/editor/field-types/ImageFieldEditor.tsx +65 -0
- package/src/editor/field-types/InternalLinkFieldEditor.tsx +112 -0
- package/src/editor/field-types/LinkFieldEditor.tsx +85 -0
- package/src/editor/field-types/MultiLineText.tsx +63 -0
- package/src/editor/field-types/PictureFieldEditor.tsx +121 -0
- package/src/editor/field-types/RawEditor.tsx +53 -0
- package/src/editor/field-types/ReactQuill.tsx +580 -0
- package/src/editor/field-types/RichTextEditor.tsx +22 -0
- package/src/editor/field-types/RichTextEditorComponent.tsx +108 -0
- package/src/editor/field-types/SingleLineText.tsx +150 -0
- package/src/editor/field-types/TreeListEditor.tsx +261 -0
- package/src/editor/fieldTypes.ts +140 -0
- package/src/editor/media-selector/AiImageSearch.tsx +186 -0
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +95 -0
- package/src/editor/media-selector/MediaSelector.tsx +42 -0
- package/src/editor/media-selector/Preview.tsx +14 -0
- package/src/editor/media-selector/Thumbnails.tsx +48 -0
- package/src/editor/media-selector/TreeSelector.tsx +292 -0
- package/src/editor/media-selector/UploadZone.tsx +137 -0
- package/src/editor/menubar/ActionsMenu.tsx +47 -0
- package/src/editor/menubar/ActiveUsers.tsx +17 -0
- package/src/editor/menubar/ApproveAndPublish.tsx +18 -0
- package/src/editor/menubar/BrowseHistory.tsx +37 -0
- package/src/editor/menubar/ItemLanguageVersion.tsx +52 -0
- package/src/editor/menubar/LanguageSelector.tsx +152 -0
- package/src/editor/menubar/Menu.tsx +83 -0
- package/src/editor/menubar/NavButtons.tsx +74 -0
- package/src/editor/menubar/PageSelector.tsx +139 -0
- package/src/editor/menubar/PageViewerControls.tsx +99 -0
- package/src/editor/menubar/Separator.tsx +12 -0
- package/src/editor/menubar/SiteInfo.tsx +53 -0
- package/src/editor/menubar/User.tsx +27 -0
- package/src/editor/menubar/VersionSelector.tsx +143 -0
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +287 -0
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +35 -0
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +44 -0
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +23 -0
- package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +64 -0
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +35 -0
- package/src/editor/page-editor-chrome/FrameMenu.tsx +263 -0
- package/src/editor/page-editor-chrome/FrameMenus.tsx +48 -0
- package/src/editor/page-editor-chrome/InlineEditor.tsx +147 -0
- package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +61 -0
- package/src/editor/page-editor-chrome/NoLayout.tsx +36 -0
- package/src/editor/page-editor-chrome/PageEditorChrome.tsx +119 -0
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +154 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +171 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +233 -0
- package/src/editor/page-viewer/DeviceToolbar.tsx +70 -0
- package/src/editor/page-viewer/EditorForm.tsx +247 -0
- package/src/editor/page-viewer/MiniMap.tsx +351 -0
- package/src/editor/page-viewer/PageViewer.tsx +127 -0
- package/src/editor/page-viewer/PageViewerFrame.tsx +1030 -0
- package/src/editor/page-viewer/pageViewContext.ts +186 -0
- package/src/editor/pageModel.ts +191 -0
- package/src/editor/picture-shared.tsx +53 -0
- package/src/editor/reviews/Comment.tsx +265 -0
- package/src/editor/reviews/Comments.tsx +50 -0
- package/src/editor/reviews/PreviewInfo.tsx +35 -0
- package/src/editor/reviews/Reviews.tsx +280 -0
- package/src/editor/reviews/reviewCommands.tsx +47 -0
- package/src/editor/reviews/useReviews.tsx +70 -0
- package/src/editor/services/aiService.ts +155 -0
- package/src/editor/services/componentDesignerService.ts +151 -0
- package/src/editor/services/contentService.ts +159 -0
- package/src/editor/services/editService.ts +462 -0
- package/src/editor/services/indexService.ts +24 -0
- package/src/editor/services/reviewsService.ts +45 -0
- package/src/editor/services/serviceHelper.ts +95 -0
- package/src/editor/services/systemService.ts +5 -0
- package/src/editor/services/translationService.ts +21 -0
- package/src/editor/services-server/api.ts +150 -0
- package/src/editor/services-server/graphQL.ts +106 -0
- package/src/editor/sidebar/ComponentPalette.tsx +146 -0
- package/src/editor/sidebar/ComponentTree.tsx +512 -0
- package/src/editor/sidebar/ComponentTree2.tsxx +490 -0
- package/src/editor/sidebar/Debug.tsx +105 -0
- package/src/editor/sidebar/DictionaryEditor.tsx +261 -0
- package/src/editor/sidebar/EditHistory.tsx +134 -0
- package/src/editor/sidebar/GraphQL.tsx +164 -0
- package/src/editor/sidebar/Insert.tsx +35 -0
- package/src/editor/sidebar/MainContentTree.tsx +95 -0
- package/src/editor/sidebar/Performance.tsx +53 -0
- package/src/editor/sidebar/Sessions.tsx +35 -0
- package/src/editor/sidebar/Sidebar.tsx +20 -0
- package/src/editor/sidebar/SidebarView.tsx +150 -0
- package/src/editor/sidebar/Translations.tsx +276 -0
- package/src/editor/sidebar/Validation.tsx +102 -0
- package/src/editor/sidebar/ViewSelector.tsx +49 -0
- package/src/editor/sidebar/Workbox.tsx +209 -0
- package/src/editor/ui/CenteredMessage.tsx +7 -0
- package/src/editor/ui/CopyToClipboardButton.tsx +23 -0
- package/src/editor/ui/DialogButtons.tsx +11 -0
- package/src/editor/ui/Icons.tsx +585 -0
- package/src/editor/ui/ItemNameDialog.tsx +94 -0
- package/src/editor/ui/ItemNameDialogNew.tsx +118 -0
- package/src/editor/ui/ItemSearch.tsx +173 -0
- package/src/editor/ui/PerfectTree.tsx +550 -0
- package/src/editor/ui/Section.tsx +35 -0
- package/src/editor/ui/SimpleIconButton.tsx +43 -0
- package/src/editor/ui/SimpleMenu.tsx +48 -0
- package/src/editor/ui/SimpleTable.tsx +63 -0
- package/src/editor/ui/SimpleTabs.tsx +55 -0
- package/src/editor/ui/SimpleToolbar.tsx +7 -0
- package/src/editor/ui/Spinner.tsx +7 -0
- package/src/editor/ui/Splitter.tsx +247 -0
- package/src/editor/ui/StackedPanels.tsx +134 -0
- package/src/editor/ui/Toolbar.tsx +7 -0
- package/src/editor/utils/id-helper.ts +3 -0
- package/src/editor/utils/insertOptions.ts +69 -0
- package/src/editor/utils/itemutils.ts +29 -0
- package/src/editor/utils/useMemoDebug.ts +28 -0
- package/src/editor/utils.ts +435 -0
- package/src/editor/views/CompareView.tsx +256 -0
- package/src/editor/views/EditView.tsx +27 -0
- package/src/editor/views/ItemEditor.tsx +58 -0
- package/src/editor/views/SingleEditView.tsx +44 -0
- package/src/fonts/Geist-Black.woff2 +0 -0
- package/src/fonts/Geist-Bold.woff2 +0 -0
- package/src/fonts/Geist-ExtraBold.woff2 +0 -0
- package/src/fonts/Geist-ExtraLight.woff2 +0 -0
- package/src/fonts/Geist-Light.woff2 +0 -0
- package/src/fonts/Geist-Medium.woff2 +0 -0
- package/src/fonts/Geist-Regular.woff2 +0 -0
- package/src/fonts/Geist-SemiBold.woff2 +0 -0
- package/src/fonts/Geist-Thin.woff2 +0 -0
- package/src/fonts/Geist[wght].woff2 +0 -0
- package/src/index.ts +7 -0
- package/src/page-wizard/PageWizard.tsx +163 -0
- package/src/page-wizard/SelectWizard.tsx +109 -0
- package/src/page-wizard/WizardSteps.tsx +207 -0
- package/src/page-wizard/service.ts +35 -0
- package/src/page-wizard/startPageWizardCommand.ts +27 -0
- package/src/page-wizard/steps/BuildPageStep.tsx +266 -0
- package/src/page-wizard/steps/CollectStep.tsx +233 -0
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +443 -0
- package/src/page-wizard/steps/Components.tsx +193 -0
- package/src/page-wizard/steps/CreatePage.tsx +285 -0
- package/src/page-wizard/steps/CreatePageAndLayoutStep.tsx +384 -0
- package/src/page-wizard/steps/EditButton.tsx +34 -0
- package/src/page-wizard/steps/FieldEditor.tsx +102 -0
- package/src/page-wizard/steps/Generate.tsx +32 -0
- package/src/page-wizard/steps/ImagesStep.tsx +318 -0
- package/src/page-wizard/steps/LayoutStep.tsx +228 -0
- package/src/page-wizard/steps/SelectStep.tsx +256 -0
- package/src/page-wizard/steps/schema.ts +180 -0
- package/src/page-wizard/steps/usePageCreator.ts +279 -0
- package/src/splash-screen/NewPage.tsx +232 -0
- package/src/splash-screen/SectionHeadline.tsx +21 -0
- package/src/splash-screen/SplashScreen.tsx +156 -0
- package/src/tour/Tour.tsx +558 -0
- package/src/tour/default-tour.tsx +300 -0
- package/src/tour/preview-tour.tsx +127 -0
- package/src/types.ts +302 -0
- package/styles.css +476 -0
- package/tsconfig.build.json +21 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.post = post;
|
|
4
|
+
exports.get = get;
|
|
5
|
+
async function post(url, body, session) {
|
|
6
|
+
if (session)
|
|
7
|
+
url += "?sessionId=" + session;
|
|
8
|
+
const response = await fetch(url, {
|
|
9
|
+
method: "POST",
|
|
10
|
+
body: JSON.stringify(body),
|
|
11
|
+
credentials: "include",
|
|
12
|
+
headers: {
|
|
13
|
+
"Content-Type": "application/json",
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return handleResponse(response);
|
|
17
|
+
}
|
|
18
|
+
async function get(url, session) {
|
|
19
|
+
if (session)
|
|
20
|
+
url += "?sessionId=" + session;
|
|
21
|
+
const response = await fetch(url, {
|
|
22
|
+
method: "GET",
|
|
23
|
+
credentials: "include",
|
|
24
|
+
headers: {
|
|
25
|
+
"Content-Type": "application/json",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
return handleResponse(response);
|
|
29
|
+
}
|
|
30
|
+
async function handleResponse(response) {
|
|
31
|
+
if (response.status === 400) {
|
|
32
|
+
const data = await response.json();
|
|
33
|
+
return {
|
|
34
|
+
type: "error",
|
|
35
|
+
summary: data.summary,
|
|
36
|
+
details: data.details,
|
|
37
|
+
response,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (response.status === 500 || response.redirected) {
|
|
41
|
+
return {
|
|
42
|
+
type: "error",
|
|
43
|
+
summary: "Error",
|
|
44
|
+
details: await response.text(),
|
|
45
|
+
response,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (response.status === 401) {
|
|
49
|
+
return {
|
|
50
|
+
type: "unauthorized",
|
|
51
|
+
summary: "Unauthorized",
|
|
52
|
+
details: "Not logged in anymore?",
|
|
53
|
+
response,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (response.status !== 200) {
|
|
57
|
+
return { type: "error", response, details: await response.text() };
|
|
58
|
+
}
|
|
59
|
+
if (!response.headers.get("content-type")?.includes("application/json")) {
|
|
60
|
+
return {
|
|
61
|
+
type: "success",
|
|
62
|
+
response,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const data = (await response.json());
|
|
66
|
+
return { type: "success", response, data };
|
|
67
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSystemStatus = getSystemStatus;
|
|
4
|
+
const serviceHelper_1 = require("./serviceHelper");
|
|
5
|
+
function getSystemStatus() {
|
|
6
|
+
return (0, serviceHelper_1.get)("/alpaca/editor/status");
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestTranslation = requestTranslation;
|
|
4
|
+
exports.getTranslationStatus = getTranslationStatus;
|
|
5
|
+
exports.getTranslationProviders = getTranslationProviders;
|
|
6
|
+
const serviceHelper_1 = require("./serviceHelper");
|
|
7
|
+
async function requestTranslation({ itemId, targetLanguage, sourceLanguage, sessionId, provider }) {
|
|
8
|
+
return await (0, serviceHelper_1.post)("/alpaca/editor/translation/requestTranslation", { itemId, targetLanguage, sourceLanguage, sessionId, provider });
|
|
9
|
+
}
|
|
10
|
+
async function getTranslationStatus(itemId) {
|
|
11
|
+
return await (0, serviceHelper_1.get)(`/alpaca/editor/translation/getTranslations?itemId=${itemId}`);
|
|
12
|
+
}
|
|
13
|
+
async function getTranslationProviders() {
|
|
14
|
+
return await (0, serviceHelper_1.get)(`/alpaca/editor/translation/providers`);
|
|
15
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.apiGet = apiGet;
|
|
7
|
+
exports.apiPostObject = apiPostObject;
|
|
8
|
+
exports.getApiKey = getApiKey;
|
|
9
|
+
exports.getApiHeaders = getApiHeaders;
|
|
10
|
+
require("server-only");
|
|
11
|
+
const headers_1 = require("next/headers");
|
|
12
|
+
const axios_1 = __importDefault(require("axios"));
|
|
13
|
+
async function apiGet(route, config) {
|
|
14
|
+
const url = process.env.LAYOUT_SERVICE_URL + route;
|
|
15
|
+
const requestHeaders = getRequestHeaders(config);
|
|
16
|
+
try {
|
|
17
|
+
const response = await axios_1.default.get(url, {
|
|
18
|
+
headers: requestHeaders,
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
data: response.data,
|
|
22
|
+
status: response.status,
|
|
23
|
+
headers: convertAxiosHeaders(response.headers),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error.response) {
|
|
28
|
+
return {
|
|
29
|
+
status: error.response.status,
|
|
30
|
+
error: error.response.statusText,
|
|
31
|
+
headers: convertAxiosHeaders(error.response.headers),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return {
|
|
36
|
+
status: 500,
|
|
37
|
+
error: error.message,
|
|
38
|
+
headers: convertAxiosHeaders(error.response.headers),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function getRequestHeaders(config) {
|
|
44
|
+
const requestHeaders = {};
|
|
45
|
+
// Convert Headers (node-fetch) to AxiosRequestHeaders (plain object)
|
|
46
|
+
if (config?.headers) {
|
|
47
|
+
config.headers.forEach((value, key) => {
|
|
48
|
+
requestHeaders[key] = value;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// Set default headers
|
|
52
|
+
requestHeaders["Content-Type"] = "application/json";
|
|
53
|
+
requestHeaders["x-api-key"] = config?.apiKey ?? getApiKey();
|
|
54
|
+
return requestHeaders;
|
|
55
|
+
}
|
|
56
|
+
async function apiPostObject(route, object, config) {
|
|
57
|
+
const url = process.env.LAYOUT_SERVICE_URL + route;
|
|
58
|
+
const requestHeaders = getRequestHeaders(config);
|
|
59
|
+
const body = JSON.stringify(object);
|
|
60
|
+
try {
|
|
61
|
+
const response = await axios_1.default.post(url, body, {
|
|
62
|
+
headers: requestHeaders,
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
data: response.data,
|
|
66
|
+
status: response.status,
|
|
67
|
+
headers: convertAxiosHeaders(response.headers),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error.errors) {
|
|
72
|
+
let message = "";
|
|
73
|
+
error.errors.forEach((error) => {
|
|
74
|
+
message += error.message + " ";
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
status: 500,
|
|
78
|
+
error: message,
|
|
79
|
+
headers: new Headers(),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (error.response) {
|
|
83
|
+
return {
|
|
84
|
+
status: error.response.status,
|
|
85
|
+
error: error.response.statusText,
|
|
86
|
+
headers: convertAxiosHeaders(error.response.headers),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return {
|
|
91
|
+
status: 500,
|
|
92
|
+
error: error.message,
|
|
93
|
+
headers: new Headers(),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function getApiKey() {
|
|
99
|
+
const apiKey = process.env.ALPACA_HEADLESS_API_KEY || process.env.API_KEY;
|
|
100
|
+
if (!apiKey)
|
|
101
|
+
console.log("ERROR: Could not find API key environment variable: ALPACA_HEADLESS_API_KEY");
|
|
102
|
+
return apiKey;
|
|
103
|
+
}
|
|
104
|
+
function convertAxiosHeaders(headers) {
|
|
105
|
+
const convertedHeaders = new Headers();
|
|
106
|
+
for (const key in headers) {
|
|
107
|
+
if (headers.hasOwnProperty(key)) {
|
|
108
|
+
convertedHeaders.set(key.toLowerCase(), headers[key]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return convertedHeaders;
|
|
112
|
+
}
|
|
113
|
+
async function getApiHeaders() {
|
|
114
|
+
const requestHeaders = await (0, headers_1.headers)();
|
|
115
|
+
const apiHeaders = new Headers();
|
|
116
|
+
apiHeaders.set("Cookie", requestHeaders.get("Cookie") || "");
|
|
117
|
+
apiHeaders.set("Authorization", requestHeaders.get("Authorization") || "");
|
|
118
|
+
return apiHeaders;
|
|
119
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeGraphQLQuery = executeGraphQLQuery;
|
|
4
|
+
exports.getGraphQLSchema = getGraphQLSchema;
|
|
5
|
+
const api_1 = require("../services-server/api");
|
|
6
|
+
async function executeGraphQLQuery({ query, host, path, language, mode, itemId, version,
|
|
7
|
+
// tags,
|
|
8
|
+
// revalidate,
|
|
9
|
+
siteName, schema, sessionId, apiConfig, }) {
|
|
10
|
+
let url = "/alpaca/headless/graphql";
|
|
11
|
+
if (sessionId)
|
|
12
|
+
url += "?sessionId=" + sessionId;
|
|
13
|
+
//console.log(`GraphQL query:`, query);
|
|
14
|
+
const request = {
|
|
15
|
+
Query: query,
|
|
16
|
+
Host: host,
|
|
17
|
+
Path: path,
|
|
18
|
+
ItemId: itemId,
|
|
19
|
+
Language: language,
|
|
20
|
+
Version: version,
|
|
21
|
+
Mode: mode,
|
|
22
|
+
SiteName: siteName,
|
|
23
|
+
Schema: schema,
|
|
24
|
+
};
|
|
25
|
+
//TODO: cache:
|
|
26
|
+
const response = await (0, api_1.apiPostObject)(url, request, apiConfig);
|
|
27
|
+
if (response.status !== 200) {
|
|
28
|
+
return { status: response.status, errors: getErrors(response) };
|
|
29
|
+
}
|
|
30
|
+
if (response.data?.errors) {
|
|
31
|
+
return {
|
|
32
|
+
status: 400,
|
|
33
|
+
errors: response.data?.errors,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
data: response.data?.data,
|
|
38
|
+
status: response.status,
|
|
39
|
+
errors: getErrors(response),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function getErrors(response) {
|
|
43
|
+
if (response.data?.errors)
|
|
44
|
+
return response.data?.errors;
|
|
45
|
+
if (response.error)
|
|
46
|
+
return [{ message: response.error }];
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
async function getGraphQLSchema({ id, apiConfig, }) {
|
|
50
|
+
let url = "/alpaca/headless/graphql/schema?id=" + id;
|
|
51
|
+
const response = await (0, api_1.apiGet)(url, apiConfig);
|
|
52
|
+
if (response.status !== 200) {
|
|
53
|
+
return { status: response.status, error: response.error };
|
|
54
|
+
}
|
|
55
|
+
return response.data;
|
|
56
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComponentPalette = ComponentPalette;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const insertOptions_1 = require("../utils/insertOptions");
|
|
6
|
+
const Icons_1 = require("../ui/Icons");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const utils_2 = require("primereact/utils");
|
|
9
|
+
const editContext_1 = require("../client/editContext");
|
|
10
|
+
const inputtext_1 = require("primereact/inputtext");
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
function ComponentPalette({}) {
|
|
13
|
+
const editContext = (0, editContext_1.useEditContext)();
|
|
14
|
+
const [filter, setFilter] = (0, react_1.useState)("");
|
|
15
|
+
const filterRef = (0, react_1.useRef)(null);
|
|
16
|
+
const insertOptions = (0, insertOptions_1.getInsertOptionsForCurrentSelection)(editContext);
|
|
17
|
+
const insertOptionsByGroup = insertOptions.reduce((acc, value) => {
|
|
18
|
+
const group = value.group || "Other";
|
|
19
|
+
if (!acc[group]) {
|
|
20
|
+
acc[group] = [];
|
|
21
|
+
}
|
|
22
|
+
acc[group].push(value);
|
|
23
|
+
return acc;
|
|
24
|
+
}, {});
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "h-full relative tour-component-palette", children: (0, jsx_runtime_1.jsxs)("div", { className: "overflow-y-auto absolute inset-0", children: [(0, jsx_runtime_1.jsx)("div", { className: "p-4", children: (0, jsx_runtime_1.jsx)(inputtext_1.InputText, { ref: filterRef, className: "w-full text-sm", placeholder: "Filter components", onChange: (e) => setFilter(e.target.value) }) }), Object.keys(insertOptionsByGroup)
|
|
26
|
+
.sort()
|
|
27
|
+
.map((group, index) => {
|
|
28
|
+
const options = insertOptionsByGroup[group].filter((x) => !x.isHidden).filter((x) => x.name.toLowerCase().indexOf(filter.toLowerCase()) > -1);
|
|
29
|
+
if (options.length === 0)
|
|
30
|
+
return;
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_2.classNames)("m-4", index > 0 ? " border-t border-gray-200" : ""), children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-xs font-bold mt-2 mb-3 flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(Icons_1.ArrowDownIcon, {}), " ", group] }), (0, jsx_runtime_1.jsx)("div", { className: "grid gap-4 grid-cols-[repeat(auto-fill,_minmax(70px,_1fr))]", children: options.map((option) => {
|
|
32
|
+
function handleDragStart(event) {
|
|
33
|
+
editContext?.dragStart({
|
|
34
|
+
type: "template",
|
|
35
|
+
typeId: option.typeId,
|
|
36
|
+
name: option.name,
|
|
37
|
+
});
|
|
38
|
+
event.stopPropagation();
|
|
39
|
+
}
|
|
40
|
+
function handleDragEnd() {
|
|
41
|
+
editContext.dragEnd();
|
|
42
|
+
editContext.setSelectedForInsertion("");
|
|
43
|
+
}
|
|
44
|
+
const isDraggable = !option.isInvalid;
|
|
45
|
+
return ((0, jsx_runtime_1.jsxs)("div", { id: "insert-component-" + option.typeId, onClick: () => {
|
|
46
|
+
editContext.setSelectedForInsertion(option.typeId);
|
|
47
|
+
}, draggable: isDraggable, onDragStart: handleDragStart, onDragEnd: handleDragEnd, className: (0, utils_2.classNames)("p-2 border border-gray-200 flex items-center flex-col gap-2 text-center text-xs relative rounded break-all ", isDraggable ? "cursor-grab" : "", editContext.selectedForInsertion === option.typeId
|
|
48
|
+
? "border-sky-500"
|
|
49
|
+
: ""), "data-testid": "insert-component-option", children: [option.svg && ((0, jsx_runtime_1.jsx)("div", { className: "w-8 h-8", dangerouslySetInnerHTML: { __html: option.svg } })), !option.svg && ((0, jsx_runtime_1.jsx)("img", { src: (0, utils_1.getAbsoluteIconUrl)(option.icon), width: "32", height: "32" })), (0, jsx_runtime_1.jsx)("div", { className: "text-xs", children: option.name
|
|
50
|
+
.split(new RegExp(`(${filter})`, "i"))
|
|
51
|
+
.map((part, i) => part.toLowerCase() === filter.toLowerCase() &&
|
|
52
|
+
part ? ((0, jsx_runtime_1.jsx)("u", { className: "font-bold", children: part }, i)) : (part && (0, jsx_runtime_1.jsx)("span", { children: part }, i))) }), option.isInvalid && ((0, jsx_runtime_1.jsx)("i", { className: "pi pi-exclamation-triangle text-red-500 absolute top-0 right-0", title: option.message }))] }, option.typeId));
|
|
53
|
+
}) })] }, group));
|
|
54
|
+
})] }) }));
|
|
55
|
+
}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ComponentTree = ComponentTree;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const editContext_1 = require("../client/editContext");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const confirmdialog_1 = require("primereact/confirmdialog");
|
|
9
|
+
const componentCommands_1 = require("../commands/componentCommands");
|
|
10
|
+
const PerfectTree_1 = require("../ui/PerfectTree");
|
|
11
|
+
const componentTreeHelper_1 = require("../componentTreeHelper");
|
|
12
|
+
function ComponentTree({}) {
|
|
13
|
+
const [expandedKeys, setExpandedKeys] = (0, react_1.useState)([]);
|
|
14
|
+
const [selectedKeys, setSelectedKeys] = (0, react_1.useState)([]);
|
|
15
|
+
const [rootNodes, setRootNodes] = (0, react_1.useState)([]);
|
|
16
|
+
const [nodeDictionary, setNodeDictionary] = (0, react_1.useState)({});
|
|
17
|
+
let editContextRef = (0, editContext_1.useEditContextRef)();
|
|
18
|
+
const editContext = (0, editContext_1.useEditContext)();
|
|
19
|
+
const treeRef = (0, react_1.useRef)(null);
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
if (treeRef.current) {
|
|
22
|
+
const selectedNodeKey = Object.keys(selectedKeys || {})[0];
|
|
23
|
+
const selectedNodeElement = treeRef.current.querySelector(`[data-id="${selectedNodeKey}"]`);
|
|
24
|
+
if (selectedNodeElement) {
|
|
25
|
+
selectedNodeElement.scrollIntoView({
|
|
26
|
+
behavior: "smooth",
|
|
27
|
+
block: "nearest",
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, [selectedKeys]);
|
|
32
|
+
(0, react_1.useEffect)(() => {
|
|
33
|
+
if (editContext?.selection) {
|
|
34
|
+
setSelectedKeys(editContext.selection);
|
|
35
|
+
}
|
|
36
|
+
}, [editContext?.selection]);
|
|
37
|
+
const selection = editContext?.selection || [];
|
|
38
|
+
const page = editContext?.page;
|
|
39
|
+
(0, react_1.useEffect)(() => {
|
|
40
|
+
const newExpandedKeys = [...expandedKeys];
|
|
41
|
+
for (const id of selection) {
|
|
42
|
+
if (nodeDictionary[id]?.parent) {
|
|
43
|
+
expandParents(nodeDictionary[id].parent, newExpandedKeys);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (newExpandedKeys.length !== expandedKeys.length ||
|
|
47
|
+
!newExpandedKeys.every((key, i) => key === expandedKeys[i])) {
|
|
48
|
+
setExpandedKeys(newExpandedKeys);
|
|
49
|
+
}
|
|
50
|
+
}, [selection, nodeDictionary]);
|
|
51
|
+
function mapPlaceholderNode(p, parent) {
|
|
52
|
+
const node = {
|
|
53
|
+
key: p.key,
|
|
54
|
+
componentId: p.key,
|
|
55
|
+
label: p.name,
|
|
56
|
+
icon: "pi pi-folder",
|
|
57
|
+
data: p,
|
|
58
|
+
parent: parent,
|
|
59
|
+
type: "placeholder",
|
|
60
|
+
};
|
|
61
|
+
node.children = p.components.map((c) => mapComponentNode(c, node));
|
|
62
|
+
return node;
|
|
63
|
+
}
|
|
64
|
+
function mapPlaceholders(c, parent) {
|
|
65
|
+
if (!c?.placeholders)
|
|
66
|
+
return [];
|
|
67
|
+
if (c.placeholders.length > 1)
|
|
68
|
+
return c.placeholders.map((x) => mapPlaceholderNode(x, parent));
|
|
69
|
+
else if (c.placeholders.length > 0) {
|
|
70
|
+
return c.placeholders[0].components.map((c) => mapComponentNode(c, parent));
|
|
71
|
+
}
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
function mapComponentNode(c, parent) {
|
|
75
|
+
const node = {
|
|
76
|
+
key: c.id,
|
|
77
|
+
componentId: c.id,
|
|
78
|
+
label: c.name,
|
|
79
|
+
icon: "pi pi-stop",
|
|
80
|
+
data: c,
|
|
81
|
+
parent: parent,
|
|
82
|
+
tags: [],
|
|
83
|
+
className: c.isRemovedFromMasterLanguage ? "text-gray-400" : "",
|
|
84
|
+
type: "component",
|
|
85
|
+
};
|
|
86
|
+
if (c.isInheritedFromMasterLanguage) {
|
|
87
|
+
node.tags.push({
|
|
88
|
+
id: "inherited",
|
|
89
|
+
severity: "info",
|
|
90
|
+
value: "Inherited " + (c.isRemovedFromMasterLanguage ? " / removed" : ""),
|
|
91
|
+
tooltip: c.isRemovedFromMasterLanguage
|
|
92
|
+
? "Component was removed from master language"
|
|
93
|
+
: "Component is inherited from master language",
|
|
94
|
+
icon: "pi pi-caret-right",
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (c.layoutId) {
|
|
98
|
+
node.tags.push({
|
|
99
|
+
id: "layout",
|
|
100
|
+
severity: "warning",
|
|
101
|
+
value: "Layout",
|
|
102
|
+
icon: "",
|
|
103
|
+
color: "rgb(192 132 252)",
|
|
104
|
+
tooltip: "Component is inherited from layout. Click to edit layout.",
|
|
105
|
+
onClick: async () => {
|
|
106
|
+
if (!editContext || !c.layoutId)
|
|
107
|
+
return;
|
|
108
|
+
const hostItem = await editContext.itemsRepository.getItem({
|
|
109
|
+
id: c.layoutId,
|
|
110
|
+
language: page.item.language,
|
|
111
|
+
version: 0,
|
|
112
|
+
});
|
|
113
|
+
if (!hostItem)
|
|
114
|
+
return;
|
|
115
|
+
(0, confirmdialog_1.confirmDialog)({
|
|
116
|
+
header: "Edit layout",
|
|
117
|
+
message: "Edit layout " + hostItem.path + "?",
|
|
118
|
+
accept: () => editContext.loadItem({
|
|
119
|
+
id: c.layoutId,
|
|
120
|
+
language: page.item.language,
|
|
121
|
+
version: 0,
|
|
122
|
+
}),
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (c.datasourceItem && c.datasourceItem?.id !== c.id) {
|
|
128
|
+
node.tags.push({
|
|
129
|
+
id: "linked",
|
|
130
|
+
severity: "warning",
|
|
131
|
+
value: "Shared",
|
|
132
|
+
icon: "",
|
|
133
|
+
tooltip: "Component is linked to " + c.datasourceItem?.id,
|
|
134
|
+
color: "rgb(251, 146, 60)",
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
node.children = mapPlaceholders(c, node);
|
|
138
|
+
if (c.items.length > 0 && c.items[0].id !== c.datasourceItem?.id) {
|
|
139
|
+
const itemsNode = {
|
|
140
|
+
key: "items" + c.id,
|
|
141
|
+
label: "items",
|
|
142
|
+
icon: "pi pi-circle",
|
|
143
|
+
parent: node,
|
|
144
|
+
type: "items",
|
|
145
|
+
};
|
|
146
|
+
itemsNode.children = c.items.map((x) => {
|
|
147
|
+
const itemNode = {
|
|
148
|
+
key: x.id,
|
|
149
|
+
label: x.name,
|
|
150
|
+
icon: "pi pi-file",
|
|
151
|
+
parent: itemsNode,
|
|
152
|
+
type: "item",
|
|
153
|
+
};
|
|
154
|
+
return itemNode;
|
|
155
|
+
});
|
|
156
|
+
node.children.push(itemsNode);
|
|
157
|
+
}
|
|
158
|
+
return node;
|
|
159
|
+
}
|
|
160
|
+
(0, react_1.useEffect)(() => {
|
|
161
|
+
if (!page)
|
|
162
|
+
return;
|
|
163
|
+
const treeNodes = mapPlaceholders(page.rootComponent, {
|
|
164
|
+
key: "root",
|
|
165
|
+
label: "Root",
|
|
166
|
+
icon: "pi pi-home",
|
|
167
|
+
children: [],
|
|
168
|
+
type: "placeholder",
|
|
169
|
+
});
|
|
170
|
+
const dict = {};
|
|
171
|
+
createMap(treeNodes, dict);
|
|
172
|
+
const otherNode = {
|
|
173
|
+
key: "other",
|
|
174
|
+
label: "Other",
|
|
175
|
+
icon: "pi pi-file",
|
|
176
|
+
children: [],
|
|
177
|
+
type: "other",
|
|
178
|
+
};
|
|
179
|
+
if (otherNode.children?.length)
|
|
180
|
+
treeNodes.push(otherNode);
|
|
181
|
+
const pageNode = {
|
|
182
|
+
key: "page",
|
|
183
|
+
label: "Page",
|
|
184
|
+
icon: "pi pi-home",
|
|
185
|
+
parent: undefined,
|
|
186
|
+
componentId: page.item.id,
|
|
187
|
+
type: "page",
|
|
188
|
+
};
|
|
189
|
+
setRootNodes([pageNode, ...treeNodes]);
|
|
190
|
+
setNodeDictionary(dict);
|
|
191
|
+
}, [page]);
|
|
192
|
+
const handleTreeSelection = (key, event) => {
|
|
193
|
+
let newKeys = [key];
|
|
194
|
+
if (event.ctrlKey) {
|
|
195
|
+
if (selectedKeys.includes(key)) {
|
|
196
|
+
newKeys = selectedKeys.filter((x) => x !== key);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
newKeys = [...selectedKeys, key];
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const selectedComponentIds = newKeys
|
|
203
|
+
.filter((key) => nodeDictionary[key])
|
|
204
|
+
.map((key) => nodeDictionary[key].componentId);
|
|
205
|
+
editContextRef.current?.select(selectedComponentIds);
|
|
206
|
+
if (selectedComponentIds.length === 1) {
|
|
207
|
+
editContextRef.current?.setScrollIntoView(selectedComponentIds[0]);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
// Handle tree context menu
|
|
211
|
+
const handleTreeContextMenu = (item, event) => {
|
|
212
|
+
const componentId = nodeDictionary[item.id]?.componentId;
|
|
213
|
+
let selectedComponentIds = editContext?.selection || [];
|
|
214
|
+
if (componentId) {
|
|
215
|
+
if (selectedComponentIds.indexOf(componentId) < 0) {
|
|
216
|
+
editContextRef.current?.select([componentId]);
|
|
217
|
+
selectedComponentIds = [componentId];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function isDefinedEntity(entity) {
|
|
221
|
+
return entity !== undefined;
|
|
222
|
+
}
|
|
223
|
+
let selectedEntities = selectedComponentIds
|
|
224
|
+
.filter((key) => nodeDictionary[key])
|
|
225
|
+
.map((key) => nodeDictionary[key].data)
|
|
226
|
+
.filter(isDefinedEntity);
|
|
227
|
+
if (selectedEntities.length === 0 && item.data) {
|
|
228
|
+
selectedEntities = [item.data];
|
|
229
|
+
}
|
|
230
|
+
let commands = (0, componentCommands_1.getComponentCommands)(selectedEntities, editContextRef.current);
|
|
231
|
+
const menu = commands.map((x) => ({
|
|
232
|
+
label: x.label,
|
|
233
|
+
icon: x.icon,
|
|
234
|
+
disabled: editContextRef.current?.isCommandDisabled({
|
|
235
|
+
command: x,
|
|
236
|
+
}),
|
|
237
|
+
command: (ev) => {
|
|
238
|
+
editContextRef.current?.executeCommand({
|
|
239
|
+
command: x,
|
|
240
|
+
data: { components: selectedEntities },
|
|
241
|
+
event: ev.originalEvent,
|
|
242
|
+
});
|
|
243
|
+
},
|
|
244
|
+
}));
|
|
245
|
+
editContextRef.current?.showContextMenu(event, menu);
|
|
246
|
+
};
|
|
247
|
+
// Convert expanded keys for PerfectTree
|
|
248
|
+
const expandedItems = expandedKeys;
|
|
249
|
+
// Convert selected keys for PerfectTree
|
|
250
|
+
const selectedItems = selectedKeys;
|
|
251
|
+
// Handle expanding nodes
|
|
252
|
+
const handleToggle = (key) => {
|
|
253
|
+
if (expandedKeys.includes(key)) {
|
|
254
|
+
handleCollapseItem(key);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
const newExpandedKeys = [...expandedKeys];
|
|
258
|
+
newExpandedKeys.push(key);
|
|
259
|
+
setExpandedKeys(newExpandedKeys);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
// Handle collapsing nodes
|
|
263
|
+
const handleCollapseItem = (key) => {
|
|
264
|
+
// First, get the node we're collapsing
|
|
265
|
+
const nodeToCollapse = nodeDictionary[key];
|
|
266
|
+
// Create a new array for expanded keys
|
|
267
|
+
const newExpandedKeys = [...expandedKeys].filter((x) => x !== key);
|
|
268
|
+
setExpandedKeys(newExpandedKeys);
|
|
269
|
+
};
|
|
270
|
+
const getPlaceholder = (node) => {
|
|
271
|
+
if (!node)
|
|
272
|
+
return null;
|
|
273
|
+
if (node.type === "placeholder")
|
|
274
|
+
return node.data;
|
|
275
|
+
if (node.type === "component" && node.data.placeholders) {
|
|
276
|
+
if (node.data.placeholders.length === 1)
|
|
277
|
+
return node.data.placeholders[0];
|
|
278
|
+
}
|
|
279
|
+
return null;
|
|
280
|
+
};
|
|
281
|
+
// Handle drag over node
|
|
282
|
+
const handleDragOverZone = (dragOverNode, index, event) => {
|
|
283
|
+
if (!editContext?.dragObject)
|
|
284
|
+
return false;
|
|
285
|
+
const placeholder = getPlaceholder(dragOverNode);
|
|
286
|
+
if (!placeholder)
|
|
287
|
+
return false;
|
|
288
|
+
var isValid = (0, componentTreeHelper_1.isValidPlaceholder)(placeholder, editContext.dragObject);
|
|
289
|
+
return isValid;
|
|
290
|
+
};
|
|
291
|
+
// Handle drop on node
|
|
292
|
+
const handleDropZone = (droppedOnNode, index, event) => {
|
|
293
|
+
const placeholder = getPlaceholder(droppedOnNode);
|
|
294
|
+
if (!placeholder)
|
|
295
|
+
return;
|
|
296
|
+
editContext.droppedInPlaceholder(placeholder.key, index);
|
|
297
|
+
};
|
|
298
|
+
if (!page)
|
|
299
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "flex h-full items-center justify-center text-sm text-gray-500" }));
|
|
300
|
+
// Use the PerfectTree component
|
|
301
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "p-2", ref: treeRef, children: (0, jsx_runtime_1.jsx)(PerfectTree_1.PerfectTree, { nodes: rootNodes, isDragging: !!editContext?.dragObject, selectedKeys: selectedItems, expandedKeys: expandedItems, onToggleExpand: handleToggle, onSelect: handleTreeSelection, enableDragAndDrop: true, onDragOverZone: (parent, index, event) => handleDragOverZone(parent, index, event), onStartDrag: (data) => {
|
|
302
|
+
const component = data.node.data;
|
|
303
|
+
// Initialize drag data to make sure dataTransfer is set
|
|
304
|
+
data.event.dataTransfer.setData("text/plain", data.node.key);
|
|
305
|
+
// Only create drag object for components with datasourceItem
|
|
306
|
+
if (!component?.datasourceItem)
|
|
307
|
+
return;
|
|
308
|
+
editContext.dragStart({
|
|
309
|
+
type: "component",
|
|
310
|
+
typeId: component.typeId,
|
|
311
|
+
templateId: component.datasourceItem?.templateId,
|
|
312
|
+
name: component.name,
|
|
313
|
+
component: {
|
|
314
|
+
id: component.id,
|
|
315
|
+
language: editContext.page.item.language,
|
|
316
|
+
version: editContext.page.item.version,
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
}, onDragEnd: (event) => {
|
|
320
|
+
editContext.dragEnd();
|
|
321
|
+
}, onDrop: (parent, index, event) => handleDropZone(parent, index, event), renderNode: (node) => renderNode(node) }) }));
|
|
322
|
+
}
|
|
323
|
+
function renderNode(node) {
|
|
324
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", { className: "font-geist-sans flex items-center gap-2 p-0.5 text-[12px] text-gray-600", children: [(0, jsx_runtime_1.jsx)("i", { className: node.icon }), (0, jsx_runtime_1.jsx)("span", { className: node.className, children: node.label }), node.tags?.map((x) => ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("span", { id: `id-${node.key}-${x.id}`, className: "ml-2 rounded px-1 py-0.5 text-xs", style: {
|
|
325
|
+
backgroundColor: x.color,
|
|
326
|
+
marginLeft: "8px",
|
|
327
|
+
fontSize: "10px",
|
|
328
|
+
padding: "1px 4px 2px 2px",
|
|
329
|
+
}, title: x.tooltip, onClick: x.onClick
|
|
330
|
+
? (e) => {
|
|
331
|
+
e.stopPropagation();
|
|
332
|
+
x.onClick();
|
|
333
|
+
}
|
|
334
|
+
: undefined, children: [x.icon && (0, jsx_runtime_1.jsx)("i", { className: x.icon }), x.value] }) }, `tag-${node.key}-${x.id}`)))] }) }));
|
|
335
|
+
}
|
|
336
|
+
function createMap(treeNodes, nodeDictionary) {
|
|
337
|
+
treeNodes.forEach((n) => {
|
|
338
|
+
if (n.key)
|
|
339
|
+
nodeDictionary[n.key] = n;
|
|
340
|
+
if (n.children)
|
|
341
|
+
createMap(n.children, nodeDictionary);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
function expandParents(node, expandedKeysList) {
|
|
345
|
+
if (!node)
|
|
346
|
+
return;
|
|
347
|
+
if (node.key && !expandedKeysList.includes(node.key)) {
|
|
348
|
+
expandedKeysList.push(node.key);
|
|
349
|
+
}
|
|
350
|
+
if (node.parent) {
|
|
351
|
+
expandParents(node.parent, expandedKeysList);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function hasSameProps(obj1, obj2) {
|
|
355
|
+
var obj1Props = Object.keys(obj1), obj2Props = Object.keys(obj2);
|
|
356
|
+
if (obj1Props.length == obj2Props.length) {
|
|
357
|
+
return obj1Props.every(function (prop) {
|
|
358
|
+
return obj2Props.indexOf(prop) >= 0;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
return false;
|
|
362
|
+
}
|