@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,24 @@
|
|
|
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.EditorWarnings = EditorWarnings;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const editContext_1 = require("./client/editContext");
|
|
10
|
+
function EditorWarnings({ item }) {
|
|
11
|
+
var context = (0, editContext_1.useEditContext)();
|
|
12
|
+
if (!context || context.previewMode)
|
|
13
|
+
return;
|
|
14
|
+
if (!item) {
|
|
15
|
+
item = context.page?.item;
|
|
16
|
+
}
|
|
17
|
+
if (!item)
|
|
18
|
+
return;
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "z-50 w-full", children: context.configuration.editorWarnings.map((x, i) => react_1.default.createElement(x, {
|
|
20
|
+
item,
|
|
21
|
+
key: "warning" + i,
|
|
22
|
+
editContext: context,
|
|
23
|
+
})) }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.FieldEditorPopup = void 0;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const overlaypanel_1 = require("primereact/overlaypanel");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const FieldList_1 = require("./FieldList");
|
|
9
|
+
exports.FieldEditorPopup = (0, react_1.forwardRef)((_, ref) => {
|
|
10
|
+
const overlayRef = (0, react_1.useRef)(null);
|
|
11
|
+
const [sections, setSections] = (0, react_1.useState)([]);
|
|
12
|
+
const [fields, setFields] = (0, react_1.useState)([]);
|
|
13
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
14
|
+
show: (fields, sections, ev) => {
|
|
15
|
+
setFields(fields);
|
|
16
|
+
setSections(sections);
|
|
17
|
+
overlayRef.current?.toggle(ev, ev.target);
|
|
18
|
+
},
|
|
19
|
+
close: () => {
|
|
20
|
+
overlayRef.current?.hide();
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)(overlaypanel_1.OverlayPanel, { ref: overlayRef, children: (0, jsx_runtime_1.jsxs)("div", { className: "w-96 h-96 flex flex-col gap-2 overflow-auto", onClick: (ev) => ev.stopPropagation(), children: [(0, jsx_runtime_1.jsx)("div", { className: "flex justify-end p-3", children: (0, jsx_runtime_1.jsx)("i", { className: "pi pi-times cursor-pointer", onClick: () => overlayRef?.current?.hide() }) }), fields && ((0, jsx_runtime_1.jsx)(FieldList_1.FieldList, { fields: [{ fields }], sections: sections, validators: [] }))] }) }));
|
|
24
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldHistory = FieldHistory;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const editService_1 = require("../editor/services/editService");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_2 = require("react");
|
|
8
|
+
const editContext_1 = require("./client/editContext");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
const SimpleTable_1 = require("./ui/SimpleTable");
|
|
11
|
+
const SimpleIconButton_1 = require("./ui/SimpleIconButton");
|
|
12
|
+
function FieldHistory({ field, onHover, }) {
|
|
13
|
+
const [fieldHistory, setFieldHistory] = (0, react_2.useState)([]);
|
|
14
|
+
const editContext = (0, editContext_1.useEditContext)();
|
|
15
|
+
if (!editContext) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
19
|
+
(0, editService_1.getFieldHistory)(field.descriptor.item, field.id).then((result) => {
|
|
20
|
+
setFieldHistory(result.data ?? []);
|
|
21
|
+
});
|
|
22
|
+
}, [field]);
|
|
23
|
+
if (fieldHistory.length === 0)
|
|
24
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "p-2 text-gray-500 text-xs", children: "No history" });
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { className: "text-xs p-2 bg-gray-100 text-gray-500", children: "Field History" }), (0, jsx_runtime_1.jsx)("div", { className: "max-h-96 overflow-auto", children: (0, jsx_runtime_1.jsx)(SimpleTable_1.SimpleTable, { items: fieldHistory, onRowHover: onHover, rowClassName: (x) => x.undone
|
|
26
|
+
? "text-gray-300 cursor-pointer hover:bg-gray-50 "
|
|
27
|
+
: "cursor-pointer hover:bg-gray-50", columns: [
|
|
28
|
+
{ header: "Date", body: (x) => (0, utils_1.formatDate)(new Date(x.date)) },
|
|
29
|
+
{ header: "User", body: (x) => x.user },
|
|
30
|
+
{ header: "Version", body: (x) => x.version },
|
|
31
|
+
{
|
|
32
|
+
header: "Revert",
|
|
33
|
+
body: (x) => ((0, jsx_runtime_1.jsx)(SimpleIconButton_1.SimpleIconButton, { icon: "pi pi-undo", onClick: () => editContext.operations.editField({
|
|
34
|
+
field: field.descriptor,
|
|
35
|
+
rawValue: x.rawValue,
|
|
36
|
+
refresh: "immediate",
|
|
37
|
+
}), label: "Revert" })),
|
|
38
|
+
},
|
|
39
|
+
] }) })] }));
|
|
40
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FieldList = FieldList;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const Section_1 = require("./ui/Section");
|
|
10
|
+
const editContext_1 = require("./client/editContext");
|
|
11
|
+
const FieldListFieldWithFallbacks_1 = require("./FieldListFieldWithFallbacks");
|
|
12
|
+
const inputtext_1 = require("primereact/inputtext");
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const checkbox_1 = require("primereact/checkbox");
|
|
15
|
+
const react_uuid_1 = __importDefault(require("react-uuid"));
|
|
16
|
+
const SimpleIconButton_1 = require("./ui/SimpleIconButton");
|
|
17
|
+
function FieldList({ fields, compareToFields, sections, validators, filter, simplified, showStandardFieldsEnabled, readonly, }) {
|
|
18
|
+
const editContext = (0, editContext_1.useEditContext)();
|
|
19
|
+
const [searchFilter, setSearchFilter] = (0, react_1.useState)("");
|
|
20
|
+
const [showStandardFields, setShowStandardFields] = (0, react_1.useState)(false);
|
|
21
|
+
const uniqueId = (0, react_uuid_1.default)();
|
|
22
|
+
if (!editContext)
|
|
23
|
+
return;
|
|
24
|
+
if (!fields)
|
|
25
|
+
return;
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "sticky bg-gray-50 top-0 z-10 flex gap-2 border-y border-gray-200 items-center p-2 tour-field-list", children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-search" }), (0, jsx_runtime_1.jsx)("div", { className: "text-xs", children: "Filter" }), (0, jsx_runtime_1.jsx)(inputtext_1.InputText, { className: "flex-1 text-xs", value: searchFilter, onChange: (x) => setSearchFilter(x.target.value) }), searchFilter && ((0, jsx_runtime_1.jsx)(SimpleIconButton_1.SimpleIconButton, { icon: "pi pi-times", onClick: () => setSearchFilter(""), className: "text-xs", label: "Clear" })), showStandardFieldsEnabled && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { inputId: uniqueId, checked: showStandardFields, onChange: (e) => setShowStandardFields(e.checked) }), " ", (0, jsx_runtime_1.jsx)("label", { htmlFor: uniqueId, className: "text-xs cursor-pointer", children: "Show standard fields" })] }))] }), fields.map((itemFields, index) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [itemFields.headline && ((0, jsx_runtime_1.jsxs)("div", { className: "text-sm mt-2 py-2 border-b flex items-center gap-1", children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-angle-right" }), " ", itemFields.headline] })), (0, jsx_runtime_1.jsx)(FieldListForSingleItem, { fields: itemFields.fields, validators: validators, filter: filter, searchFilter: searchFilter, showStandardFields: showStandardFields, simplified: simplified, sections: sections, compareToFields: compareToFields, readonly: readonly }, index)] }, index)))] }));
|
|
27
|
+
}
|
|
28
|
+
function FieldListForSingleItem({ fields, validators, filter, searchFilter, simplified, sections, showStandardFields, compareToFields, readonly, }) {
|
|
29
|
+
let fieldsArray = Array.isArray(fields)
|
|
30
|
+
? fields
|
|
31
|
+
: Object.values(fields);
|
|
32
|
+
if (filter)
|
|
33
|
+
fieldsArray = fieldsArray.filter(filter);
|
|
34
|
+
if (searchFilter) {
|
|
35
|
+
const searchFilterLower = searchFilter.toLowerCase();
|
|
36
|
+
fieldsArray = fieldsArray.filter((x) => x.name?.toLowerCase().includes(searchFilterLower) ||
|
|
37
|
+
x.displayName?.toLowerCase().includes(searchFilterLower));
|
|
38
|
+
}
|
|
39
|
+
if (!showStandardFields) {
|
|
40
|
+
fieldsArray = fieldsArray.filter((x) => !x.name?.startsWith("__"));
|
|
41
|
+
}
|
|
42
|
+
const sectionsGrouping = fieldsArray.reduce((acc, value) => {
|
|
43
|
+
// Group initialization
|
|
44
|
+
const section = value.section || "Default";
|
|
45
|
+
if (value.descriptor.item.id)
|
|
46
|
+
if (!acc[section]) {
|
|
47
|
+
acc[section] = [];
|
|
48
|
+
}
|
|
49
|
+
// Grouping
|
|
50
|
+
acc[section].push(value);
|
|
51
|
+
return acc;
|
|
52
|
+
}, {});
|
|
53
|
+
const sectionList = Object.values(sectionsGrouping);
|
|
54
|
+
sectionList.sort((a, b) => (a[0]?.sectionSortOrder || 0) - (b[0]?.sectionSortOrder || 0));
|
|
55
|
+
function getSectionFields(fields) {
|
|
56
|
+
fields.sort((a, b) => a?.sortOrder - b?.sortOrder);
|
|
57
|
+
return fields.map((field) => ((0, jsx_runtime_1.jsx)(FieldListFieldWithFallbacks_1.FieldListFieldWithFallbacks, { fieldDescriptor: field.descriptor, simplified: simplified, validators: validators.filter((x) => x.fieldId === field.id), compareToField: compareToFields?.find((x) => x.id === field.id), readonly: readonly }, field.id)));
|
|
58
|
+
}
|
|
59
|
+
return sectionList
|
|
60
|
+
.map((x) => x[0]?.section)
|
|
61
|
+
.filter((x) => !sections || sections.includes(x))
|
|
62
|
+
.map((section) => simplified ? (getSectionFields(sectionsGrouping[section])) : ((0, jsx_runtime_1.jsx)(Section_1.Section, { title: section, children: getSectionFields(sectionsGrouping[section]) }, section)));
|
|
63
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = FieldListField;
|
|
4
|
+
exports.getFieldEditor = getFieldEditor;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const tooltip_1 = require("primereact/tooltip");
|
|
7
|
+
const editContext_1 = require("./client/editContext");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const Icons_1 = require("./ui/Icons");
|
|
10
|
+
const overlaypanel_1 = require("primereact/overlaypanel");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
const editService_1 = require("./services/editService");
|
|
13
|
+
const use_debounce_1 = require("use-debounce");
|
|
14
|
+
const SimpleIconButton_1 = require("./ui/SimpleIconButton");
|
|
15
|
+
const FieldHistory_1 = require("./FieldHistory");
|
|
16
|
+
function FieldListField({ field, validators, simplified, title, isFocusedField, showFallbackButton, compareToField, readonly, }) {
|
|
17
|
+
const editContext = (0, editContext_1.useEditContext)();
|
|
18
|
+
if (!editContext)
|
|
19
|
+
return;
|
|
20
|
+
const modifiedFieldsContext = (0, editContext_1.useModifiedFieldsContext)();
|
|
21
|
+
const fieldItem = field.descriptor.item;
|
|
22
|
+
const [showRawValue, setShowRawValue] = (0, react_1.useState)(false);
|
|
23
|
+
const generatorsOverlay = (0, react_1.useRef)(null);
|
|
24
|
+
const fieldHistoryOverlay = (0, react_1.useRef)(null);
|
|
25
|
+
const [generatorButtons, setButtons] = (0, react_1.useState)();
|
|
26
|
+
const [isModified, setIsModified] = (0, react_1.useState)(false);
|
|
27
|
+
const [isSaved, setIsSaved] = (0, react_1.useState)(false);
|
|
28
|
+
const [historyEntry, setHistoryEntry] = (0, react_1.useState)();
|
|
29
|
+
async function editButtonClicked(x) {
|
|
30
|
+
editContext?.triggerFieldAction(field.descriptor, x);
|
|
31
|
+
}
|
|
32
|
+
(0, react_1.useEffect)(() => {
|
|
33
|
+
updateState();
|
|
34
|
+
setShowRawValue(false);
|
|
35
|
+
}, [
|
|
36
|
+
field.descriptor.item.id,
|
|
37
|
+
field.descriptor.item.language,
|
|
38
|
+
field.descriptor.item.version,
|
|
39
|
+
field.descriptor.fieldId,
|
|
40
|
+
]);
|
|
41
|
+
(0, react_1.useEffect)(updateState, [modifiedFieldsContext?.modifiedFields]);
|
|
42
|
+
function updateState() {
|
|
43
|
+
const modifiedField = modifiedFieldsContext?.modifiedFields.find((x) => x.fieldId === field.id &&
|
|
44
|
+
x.item.id === fieldItem.id &&
|
|
45
|
+
x.item.language === fieldItem.language &&
|
|
46
|
+
x.item.version === fieldItem.version);
|
|
47
|
+
if (modifiedField) {
|
|
48
|
+
setIsModified(true);
|
|
49
|
+
setIsSaved(!modifiedField.isDirty);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
setIsModified(false);
|
|
53
|
+
setIsSaved(false);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const fieldLockedBySession = (0, utils_1.getSessionWithFieldLock)(field.descriptor, editContext);
|
|
57
|
+
const debouncedSetFieldvalue = (0, use_debounce_1.useThrottledCallback)(async (value) => {
|
|
58
|
+
await editContext.operations.editField({
|
|
59
|
+
field: field.descriptor,
|
|
60
|
+
value: value,
|
|
61
|
+
refresh: "none",
|
|
62
|
+
});
|
|
63
|
+
}, editContext.configuration.debounceFieldEditsInterval, {
|
|
64
|
+
trailing: true,
|
|
65
|
+
});
|
|
66
|
+
const isReadOnly = readonly ||
|
|
67
|
+
!field.canWrite ||
|
|
68
|
+
(fieldLockedBySession &&
|
|
69
|
+
fieldLockedBySession.sessionId !== editContext.sessionId) ||
|
|
70
|
+
false;
|
|
71
|
+
let classNames = " flex items-stretch";
|
|
72
|
+
if (isFocusedField)
|
|
73
|
+
classNames += " focused-field ";
|
|
74
|
+
if (isReadOnly)
|
|
75
|
+
classNames += " readonly ";
|
|
76
|
+
if (isModified && !isSaved)
|
|
77
|
+
classNames += " saving ";
|
|
78
|
+
if (isSaved)
|
|
79
|
+
classNames += " saved ";
|
|
80
|
+
let validationBarClassNames = undefined;
|
|
81
|
+
if (validators.find((x) => x.result > 1))
|
|
82
|
+
validationBarClassNames = " pl-2 border-l-4 border-red-500";
|
|
83
|
+
const executingAction = editContext.activeFieldActions.find((x) => x.field.fieldId == field.id &&
|
|
84
|
+
x.field.item?.id == fieldItem.id &&
|
|
85
|
+
x.field.item?.language == fieldItem.language &&
|
|
86
|
+
x.field.item?.version == fieldItem.version);
|
|
87
|
+
if (executingAction?.state == "running")
|
|
88
|
+
classNames += " executing-action ";
|
|
89
|
+
(0, react_1.useEffect)(() => {
|
|
90
|
+
const load = async () => {
|
|
91
|
+
if (!field.descriptor)
|
|
92
|
+
return;
|
|
93
|
+
const buttons = await (0, editService_1.loadFieldButtons)(field.descriptor);
|
|
94
|
+
field.buttons = buttons;
|
|
95
|
+
setButtons(buttons);
|
|
96
|
+
};
|
|
97
|
+
if (isFocusedField) {
|
|
98
|
+
if (field.buttons)
|
|
99
|
+
setButtons(field.buttons);
|
|
100
|
+
else
|
|
101
|
+
load();
|
|
102
|
+
}
|
|
103
|
+
}, [isFocusedField]);
|
|
104
|
+
(0, react_1.useEffect)(() => {
|
|
105
|
+
if (editContext.currentOverlay !== field.id + "_generators")
|
|
106
|
+
generatorsOverlay.current?.hide();
|
|
107
|
+
}, [editContext.currentOverlay]);
|
|
108
|
+
const renderGeneratorButtons = () => {
|
|
109
|
+
if (generatorButtons?.length || 0 > 0)
|
|
110
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(!executingAction || executingAction.state !== "running") && ((0, jsx_runtime_1.jsx)(SimpleIconButton_1.SimpleIconButton, { icon: (0, jsx_runtime_1.jsx)(Icons_1.WizardIcon, { className: "w-4 h-4" }), label: "Generate", onClick: (e) => {
|
|
111
|
+
generatorsOverlay.current?.toggle(e);
|
|
112
|
+
editContext.setCurrentOverlay(field.id + "_generators");
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
e.stopPropagation();
|
|
115
|
+
} })), executingAction && executingAction.state === "running" && ((0, jsx_runtime_1.jsxs)("div", { className: "ml-auto text-xs", children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-spin pi-spinner text-xs flex items-center" }), " ", executingAction?.actionButton.label] })), (0, jsx_runtime_1.jsx)(overlaypanel_1.OverlayPanel, { ref: generatorsOverlay, className: "p-1", children: generatorButtons?.map((x) => ((0, jsx_runtime_1.jsxs)("button", { className: "text-xs p-1 block hover:text-gray-400", onClick: () => {
|
|
116
|
+
editButtonClicked(x);
|
|
117
|
+
generatorsOverlay.current?.hide();
|
|
118
|
+
}, children: [x.icon && (0, jsx_runtime_1.jsx)("i", { className: x.icon + " mr-2 text-xs" }), x.label] }, x.id))) })] }));
|
|
119
|
+
return null;
|
|
120
|
+
};
|
|
121
|
+
const config = editContext.configuration.fieldTypes[field.type];
|
|
122
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: classNames, children: [validationBarClassNames && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: validationBarClassNames, id: "validation_" + field.id }), (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { target: "#validation_" + field.id, children: validators
|
|
123
|
+
.filter((x) => x.result > 1)
|
|
124
|
+
.map((x) => ((0, jsx_runtime_1.jsx)("div", { children: x.message }, x.validator))) })] })), (0, jsx_runtime_1.jsxs)("div", { className: "flex-1", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex gap-x-3 gap-y-1 items-center flex-wrap min-h-7", children: [(0, jsx_runtime_1.jsx)("label", { className: "font-bold block text-xs select-text", children: title || field.displayName || field.name }), fieldLockedBySession &&
|
|
125
|
+
fieldLockedBySession.sessionId !== editContext.sessionId && ((0, jsx_runtime_1.jsxs)("div", { className: "text-xs bg-pink-400 text-white p-1", children: ["locked by ", fieldLockedBySession.user.name] })), isFocusedField &&
|
|
126
|
+
(!fieldLockedBySession ||
|
|
127
|
+
fieldLockedBySession?.sessionId === editContext.sessionId) && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [field.isShared && ((0, jsx_runtime_1.jsx)("span", { className: "text-xs text-gray-400", children: "[Shared]" })), (0, jsx_runtime_1.jsx)("span", { className: "text-xs", children: "\u00B7" }), !field.isFallback && field.rawValue !== null ? ((0, jsx_runtime_1.jsxs)("button", { className: "text-xs p-0 ", onClick: () => {
|
|
128
|
+
editContext?.operations.editField({
|
|
129
|
+
field: field.descriptor,
|
|
130
|
+
rawValue: null,
|
|
131
|
+
});
|
|
132
|
+
}, children: ["Reset", " "] })) : (showFallbackButton), config?.buttons?.map((x) => {
|
|
133
|
+
return ((0, jsx_runtime_1.jsxs)("button", { className: "text-xs p-0", onClick: () => editContext.triggerFieldAction(field.descriptor, x), children: [(0, jsx_runtime_1.jsx)("i", { className: "text-xs pi " + x.icon }), " ", x.label] }, x.id));
|
|
134
|
+
}), !simplified && ((0, jsx_runtime_1.jsxs)("button", { className: "text-xs p-0", onClick: () => {
|
|
135
|
+
setShowRawValue(!showRawValue);
|
|
136
|
+
}, children: [(0, jsx_runtime_1.jsx)("i", { className: "text-xs pi " +
|
|
137
|
+
(showRawValue ? "pi-check-square" : "pi-stop") }), " ", "Raw"] })), (0, jsx_runtime_1.jsxs)("div", { className: "ml-auto flex items-center gap-1", children: [(0, jsx_runtime_1.jsx)(SimpleIconButton_1.SimpleIconButton, { icon: "pi pi-comment", onClick: () => {
|
|
138
|
+
editContext.switchView("reviews");
|
|
139
|
+
editContext.addComment();
|
|
140
|
+
}, label: "Add Comment" }), !readonly && renderGeneratorButtons(), (0, jsx_runtime_1.jsx)(SimpleIconButton_1.SimpleIconButton, { icon: "pi pi-history", onClick: (ev) => {
|
|
141
|
+
fieldHistoryOverlay.current?.toggle(ev);
|
|
142
|
+
ev.preventDefault();
|
|
143
|
+
ev.stopPropagation();
|
|
144
|
+
}, label: "Field History" }), (0, jsx_runtime_1.jsx)(overlaypanel_1.OverlayPanel, { ref: fieldHistoryOverlay, className: "p-1", children: (0, jsx_runtime_1.jsx)(FieldHistory_1.FieldHistory, { field: field, onHover: (x) => setHistoryEntry(x) }) })] })] }))] }), executingAction?.message && ((0, jsx_runtime_1.jsx)("div", { className: "text-xs p-0 mt-1 mb-1", children: executingAction?.message })), !compareToField && ((0, jsx_runtime_1.jsx)("div", { className: "text-xs p-0 mt-1 ", children: getFieldEditor(historyEntry
|
|
145
|
+
? { ...field, value: historyEntry.value, isHistoric: true }
|
|
146
|
+
: field, showRawValue, historyEntry ? true : isReadOnly, editContext.configuration, debouncedSetFieldvalue) })), compareToField && ((0, jsx_runtime_1.jsxs)("div", { className: "text-xs p-0 mt-1 gap-1 flex w-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1", children: getFieldEditor(field, showRawValue, isReadOnly, editContext.configuration, debouncedSetFieldvalue) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1", children: getFieldEditor(compareToField, showRawValue, true, editContext.configuration, debouncedSetFieldvalue) })] }))] })] }, field.id +
|
|
147
|
+
"_" +
|
|
148
|
+
fieldItem.id +
|
|
149
|
+
"_" +
|
|
150
|
+
fieldItem.language +
|
|
151
|
+
"_" +
|
|
152
|
+
fieldItem.version));
|
|
153
|
+
}
|
|
154
|
+
function getFieldEditor(field, showRawValue, isReadOnly, configuration, debouncedSetFieldvalue) {
|
|
155
|
+
let fieldType = showRawValue ? "raw" : field.type;
|
|
156
|
+
var typeConfig = configuration.fieldTypes[fieldType];
|
|
157
|
+
if (!typeConfig)
|
|
158
|
+
typeConfig = configuration.fieldTypes["single-line text"];
|
|
159
|
+
if (!typeConfig)
|
|
160
|
+
return null;
|
|
161
|
+
return ((0, jsx_runtime_1.jsx)(typeConfig.editor, { field: field, readOnly: isReadOnly, updateFieldValue: (value) => {
|
|
162
|
+
debouncedSetFieldvalue(value);
|
|
163
|
+
} }));
|
|
164
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
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.FieldListFieldWithFallbacks = FieldListFieldWithFallbacks;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const FieldListField_1 = __importDefault(require("./FieldListField"));
|
|
10
|
+
const editContext_1 = require("./client/editContext");
|
|
11
|
+
function FieldListFieldWithFallbacks({ fieldDescriptor, validators, simplified, title, compareToField, readonly, }) {
|
|
12
|
+
const [showFallback, setShowFallback] = (0, react_1.useState)(false);
|
|
13
|
+
const [fallbackChain, setFallbackChain] = (0, react_1.useState)();
|
|
14
|
+
const ref = (0, react_1.useRef)(null);
|
|
15
|
+
const [hover, setHover] = (0, react_1.useState)(false);
|
|
16
|
+
const [field, setField] = (0, react_1.useState)();
|
|
17
|
+
const editContext = (0, editContext_1.useEditContext)();
|
|
18
|
+
if (!editContext)
|
|
19
|
+
return;
|
|
20
|
+
const operationsContext = (0, editContext_1.useOperationsContext)();
|
|
21
|
+
(0, react_1.useEffect)(() => {
|
|
22
|
+
const loadField = async () => {
|
|
23
|
+
const field = await editContext.itemsRepository.getField(fieldDescriptor);
|
|
24
|
+
setField(field);
|
|
25
|
+
};
|
|
26
|
+
loadField();
|
|
27
|
+
}, [editContext.itemsRepository.revision, fieldDescriptor]);
|
|
28
|
+
//const liveField = editContext.getLiveField(field);
|
|
29
|
+
// function isEditFieldOp(op?: EditOperation): op is EditFieldOperation {
|
|
30
|
+
// return op?.type === "edit-field";
|
|
31
|
+
// }
|
|
32
|
+
async function loadFallback() {
|
|
33
|
+
if (!field?.fallbackChain || !editContext)
|
|
34
|
+
return;
|
|
35
|
+
await editContext.itemsRepository.getItems(field.fallbackChain?.map((x) => x.item));
|
|
36
|
+
setFallbackChain((await Promise.all(field.fallbackChain.map((x) => editContext.itemsRepository.getField(x)))).filter((x) => x));
|
|
37
|
+
//const chain = await loadFallbackChain(field.descriptor);
|
|
38
|
+
// if(currentEditOp.item.language !== field._editor!.descriptor.item.language) {
|
|
39
|
+
// chain.forEach((x, i) => {
|
|
40
|
+
// if (i > 0) {
|
|
41
|
+
// x._editor!.isFallback = true;
|
|
42
|
+
// }
|
|
43
|
+
// });
|
|
44
|
+
// }
|
|
45
|
+
// // chain.forEach((x, i) => {
|
|
46
|
+
// // if (
|
|
47
|
+
// // init ||
|
|
48
|
+
// // !isEditFieldOp(currentEditOp) ||
|
|
49
|
+
// // currentEditOp.fieldId !== x.id ||
|
|
50
|
+
// // currentEditOp.item.id !== x._editor!.descriptor.item.id ||
|
|
51
|
+
// // currentEditOp.item.language !== x._editor!.descriptor.item.language
|
|
52
|
+
// // ) {
|
|
53
|
+
// // console.log("apply change", i, x);
|
|
54
|
+
// // x._editor! = chain[i]._editor!;
|
|
55
|
+
// // x.value = chain[i].value;
|
|
56
|
+
// // x.jsonValue = chain[i].jsonValue;
|
|
57
|
+
// // }
|
|
58
|
+
// // });
|
|
59
|
+
//setFallbackChain(chain);
|
|
60
|
+
}
|
|
61
|
+
const fieldItem = field?.descriptor.item;
|
|
62
|
+
const isFocusedField = editContext?.focusedField?.fieldId === field?.id &&
|
|
63
|
+
editContext.focusedField?.item?.id === fieldItem?.id &&
|
|
64
|
+
editContext.focusedField?.item?.language === fieldItem?.language;
|
|
65
|
+
(0, react_1.useEffect)(() => {
|
|
66
|
+
const handleEnter = () => {
|
|
67
|
+
setHover(true);
|
|
68
|
+
};
|
|
69
|
+
const handleLeave = () => {
|
|
70
|
+
setHover(false);
|
|
71
|
+
};
|
|
72
|
+
ref.current?.addEventListener("mouseenter", handleEnter);
|
|
73
|
+
ref.current?.addEventListener("mouseleave", handleLeave);
|
|
74
|
+
return () => {
|
|
75
|
+
ref.current?.removeEventListener("mouseenter", handleEnter);
|
|
76
|
+
ref.current?.removeEventListener("mouseleave", handleLeave);
|
|
77
|
+
};
|
|
78
|
+
}, []);
|
|
79
|
+
(0, react_1.useEffect)(() => {
|
|
80
|
+
if (ref.current && isFocusedField) {
|
|
81
|
+
// only scroll if the field is outside the viewport
|
|
82
|
+
const rect = ref.current.getBoundingClientRect();
|
|
83
|
+
if (rect.top < 0 || rect.bottom > window.innerHeight) {
|
|
84
|
+
ref.current.scrollIntoView({
|
|
85
|
+
behavior: "smooth",
|
|
86
|
+
block: "center",
|
|
87
|
+
inline: "center",
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, [editContext.focusedField?.fieldId]);
|
|
92
|
+
(0, react_1.useEffect)(() => {
|
|
93
|
+
if (ref.current && (isFocusedField || hover) && field?.isFallback) {
|
|
94
|
+
loadFallback();
|
|
95
|
+
}
|
|
96
|
+
}, [editContext.focusedField, hover]);
|
|
97
|
+
(0, react_1.useEffect)(() => {
|
|
98
|
+
if (field?.isFallback && isFocusedField) {
|
|
99
|
+
loadFallback();
|
|
100
|
+
}
|
|
101
|
+
}, [
|
|
102
|
+
operationsContext?.editOperationExecuted,
|
|
103
|
+
editContext.refreshCompletedFlag,
|
|
104
|
+
editContext.itemsRepository.revision,
|
|
105
|
+
]);
|
|
106
|
+
const showFallbackButton = field?.isFallback && ((0, jsx_runtime_1.jsxs)("button", { className: "text-xs p-0", onClick: () => setShowFallback(!showFallback), children: [(0, jsx_runtime_1.jsx)("i", { className: "text-xs pi " + (showFallback ? "pi-check-square" : "pi-stop") }), " ", "Fallback"] }));
|
|
107
|
+
if (!field) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
return ((0, jsx_runtime_1.jsxs)("div", { "data-field-id": field.id, ref: ref, className: "[&:not(:first-child)]:mt-4", onClickCapture: () => {
|
|
111
|
+
editContext.setFocusedField(field.descriptor, field.canWrite || false);
|
|
112
|
+
}, children: [(0, jsx_runtime_1.jsx)(FieldListField_1.default, { field: field, validators: validators, simplified: simplified, title: title, isFocusedField: isFocusedField || hover, showFallbackButton: showFallbackButton, compareToField: compareToField, readonly: readonly }), field.isFallback && isFocusedField && showFallback && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: fallbackChain &&
|
|
113
|
+
fallbackChain.map((x, i) => ((0, jsx_runtime_1.jsxs)("div", { className: "ml-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-center mb-4", children: (0, jsx_runtime_1.jsx)("i", { className: "pi pi-arrow-up text-xl font-bold text-blue-300 fallback-arrow-animation relative top-3" }) }), (0, jsx_runtime_1.jsx)(FieldListField_1.default, { field: x, validators: validators, simplified: true, isFocusedField: true, readonly: readonly, title: (0, jsx_runtime_1.jsxs)("div", { className: "text-xs", children: [x.displayName || x.name, " (", x.descriptor.item.language, ")", x.descriptor.item.id != field.descriptor.item.id && ((0, jsx_runtime_1.jsxs)("span", { className: "text-gray-400", children: ["- Item: ", x.descriptor.item.id] }))] }) }, i)] }, i))) }))] }, field.id));
|
|
114
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = FloatingToolbar;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
function FloatingToolbar({ children, onPin, height, width, }) {
|
|
7
|
+
const [position, setPosition] = (0, react_1.useState)({ x: 0, y: 95 });
|
|
8
|
+
const [size, setSize] = (0, react_1.useState)({ width: 400, height: 70 });
|
|
9
|
+
const [dragging, setDragging] = (0, react_1.useState)(false);
|
|
10
|
+
const [resizing, setResizing] = (0, react_1.useState)(false);
|
|
11
|
+
const [offset, setOffset] = (0, react_1.useState)({ x: 0, y: 0 });
|
|
12
|
+
const [hidden, setHidden] = (0, react_1.useState)(false);
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
console.log("WIDTH: ", width, "Height: ", height);
|
|
15
|
+
setSize({ width: width || 400, height: height || 70 });
|
|
16
|
+
}, []);
|
|
17
|
+
const handleMouseDown = (0, react_1.useCallback)((e) => {
|
|
18
|
+
// Start dragging and calculate the offset from the mouse to the sidebar top-left corner
|
|
19
|
+
setDragging(true);
|
|
20
|
+
setOffset({
|
|
21
|
+
x: e.clientX - position.x,
|
|
22
|
+
y: e.clientY - position.y,
|
|
23
|
+
});
|
|
24
|
+
}, [position]);
|
|
25
|
+
const handleMouseMove = (0, react_1.useCallback)((e) => {
|
|
26
|
+
if (dragging) {
|
|
27
|
+
// Update the position state based on mouse movement, adjusted by the initial offset
|
|
28
|
+
setPosition({
|
|
29
|
+
x: e.clientX - offset.x,
|
|
30
|
+
y: e.clientY - offset.y,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, [dragging, offset]);
|
|
34
|
+
const handleMouseUp = (0, react_1.useCallback)(() => {
|
|
35
|
+
// Stop dragging
|
|
36
|
+
setDragging(false);
|
|
37
|
+
}, []);
|
|
38
|
+
const handleResizeMouseDown = (0, react_1.useCallback)((e) => {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
setResizing(true);
|
|
41
|
+
setOffset({
|
|
42
|
+
x: e.clientX,
|
|
43
|
+
y: e.clientY,
|
|
44
|
+
});
|
|
45
|
+
}, []);
|
|
46
|
+
const handleResizeMouseMove = (0, react_1.useCallback)((e) => {
|
|
47
|
+
if (resizing) {
|
|
48
|
+
const newWidth = size.width + (e.clientX - offset.x);
|
|
49
|
+
const newHeight = size.height + (e.clientY - offset.y);
|
|
50
|
+
setSize({
|
|
51
|
+
width: newWidth > 200 ? newWidth : 200, // Minimum width
|
|
52
|
+
height: newHeight > 100 ? newHeight : 100, // Minimum height
|
|
53
|
+
});
|
|
54
|
+
setOffset({
|
|
55
|
+
x: e.clientX,
|
|
56
|
+
y: e.clientY,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}, [resizing, offset, size]);
|
|
60
|
+
const handleResizeMouseUp = (0, react_1.useCallback)(() => {
|
|
61
|
+
setResizing(false);
|
|
62
|
+
}, []);
|
|
63
|
+
(0, react_1.useEffect)(() => {
|
|
64
|
+
if (resizing) {
|
|
65
|
+
document.addEventListener("mousemove", handleResizeMouseMove);
|
|
66
|
+
document.addEventListener("mouseup", handleResizeMouseUp);
|
|
67
|
+
}
|
|
68
|
+
return () => {
|
|
69
|
+
document.removeEventListener("mousemove", handleResizeMouseMove);
|
|
70
|
+
document.removeEventListener("mouseup", handleResizeMouseUp);
|
|
71
|
+
};
|
|
72
|
+
}, [resizing, handleResizeMouseMove, handleResizeMouseUp]);
|
|
73
|
+
// Add event listeners to the document when the sidebar is being dragged
|
|
74
|
+
(0, react_1.useEffect)(() => {
|
|
75
|
+
if (dragging) {
|
|
76
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
77
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
78
|
+
}
|
|
79
|
+
// Cleanup the document event listeners when the component unmounts or dragging stops
|
|
80
|
+
return () => {
|
|
81
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
82
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
83
|
+
};
|
|
84
|
+
}, [dragging, handleMouseMove, handleMouseUp]);
|
|
85
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "border border-gray-200 drop-shadow z-10 flex flex-col", onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, style: {
|
|
86
|
+
left: `${position.x}px`,
|
|
87
|
+
top: `${position.y}px`,
|
|
88
|
+
position: "absolute", // Use 'fixed' or 'absolute' depending on your layout needs
|
|
89
|
+
height: `${hidden ? 30 : size.height}px`,
|
|
90
|
+
width: `${size.width}px`,
|
|
91
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { className: "bg-gray-100 w-full flex justify-between items-between p-2 text-sm", style: { cursor: "move", userSelect: "none" }, onMouseDown: handleMouseDown, children: ["Toolbar", (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2", children: [hidden && ((0, jsx_runtime_1.jsx)("div", { className: "border-2 border-gray-800 w-4 h-4 cusor-pointer", onClick: () => setHidden(false) })), !hidden && ((0, jsx_runtime_1.jsx)("div", { className: "border-b-2 border-gray-800 w-4 h-4 cusor-pointer", onClick: () => setHidden(true) })), onPin && ((0, jsx_runtime_1.jsx)("i", { className: "pi pi-arrow-down-left cursor-pointer", onClick: onPin }))] })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1", children: !hidden && children }), (0, jsx_runtime_1.jsx)("div", { className: "h-4 bg-gray-100" }), (0, jsx_runtime_1.jsx)("div", { className: "cursor-nwse-resize w-4 h-4 absolute -bottom-1 -right-2 text-gray-500", onMouseDown: handleResizeMouseDown, children: (0, jsx_runtime_1.jsx)("i", { className: "pi pi-sort-down -rotate-45 w-4 h-4" }) })] }));
|
|
92
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageEditor = ImageEditor;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const editContext_1 = require("./client/editContext");
|
|
7
|
+
const DialogContext_1 = require("./client/DialogContext");
|
|
8
|
+
function ImageEditor({ field, style, }) {
|
|
9
|
+
const [showMenu, setShowMenu] = (0, react_1.useState)(false);
|
|
10
|
+
const editContext = (0, editContext_1.useEditContext)();
|
|
11
|
+
const dialogContext = (0, DialogContext_1.useDialog)();
|
|
12
|
+
if (!field || !editContext)
|
|
13
|
+
return null;
|
|
14
|
+
const imageSelected = (0, react_1.useCallback)(async (imageId) => {
|
|
15
|
+
editContext.operations.editField({
|
|
16
|
+
field: field.descriptor,
|
|
17
|
+
rawValue: '<image mediaid="{' + imageId + '}" />',
|
|
18
|
+
refresh: "immediate",
|
|
19
|
+
});
|
|
20
|
+
}, [field]);
|
|
21
|
+
async function selectMedia() {
|
|
22
|
+
const selectedImageId = await editContext?.selectMedia({
|
|
23
|
+
selectedIdPath: field.value?.src || "",
|
|
24
|
+
mode: "images",
|
|
25
|
+
});
|
|
26
|
+
if (selectedImageId)
|
|
27
|
+
imageSelected(selectedImageId);
|
|
28
|
+
}
|
|
29
|
+
const getImageSrc = () => {
|
|
30
|
+
if (!field.value) {
|
|
31
|
+
if (!field.rawValue)
|
|
32
|
+
return null;
|
|
33
|
+
const parser = new DOMParser();
|
|
34
|
+
const xmlDoc = parser.parseFromString(field.rawValue, "text/xml");
|
|
35
|
+
const imageElement = xmlDoc.documentElement;
|
|
36
|
+
return imageElement.getAttribute("src");
|
|
37
|
+
}
|
|
38
|
+
return field.value.src;
|
|
39
|
+
};
|
|
40
|
+
const getImageAlt = () => {
|
|
41
|
+
console.log(`GetImageAlt: ${JSON.stringify(field.value)}`);
|
|
42
|
+
if (!field.value)
|
|
43
|
+
return "";
|
|
44
|
+
// Standard image
|
|
45
|
+
return field.value.alt;
|
|
46
|
+
};
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "absolute inset-0 flex items-center justify-center", onMouseEnter: () => setShowMenu(true), onMouseLeave: () => setShowMenu(false), style: style, "data-testid": "select-media", children: [getImageSrc() && ((0, jsx_runtime_1.jsx)("img", { src: getImageSrc(), alt: getImageAlt(), className: "max-h-full max-w-full object-contain" })), showMenu && ((0, jsx_runtime_1.jsxs)("div", { className: "p-3 grid grid-cols-1 gap-1.5 items-stretch justify-center text-sm absolute inset-0 bg-black/50", children: [(0, jsx_runtime_1.jsx)(Btn, { label: getImageSrc() ? "Change Image" : "Select Image", icon: "pi pi-image", onClick: () => selectMedia(), testId: "select-media-button", className: "min-w-[80px]" }), editContext?.configuration?.fieldTypes["image"]?.buttons?.map((button) => ((0, jsx_runtime_1.jsx)(Btn, { label: button.label, icon: button.icon, onClick: () => button?.clientAction?.({
|
|
48
|
+
field,
|
|
49
|
+
editContext,
|
|
50
|
+
dialogContext,
|
|
51
|
+
}) }, button.id)))] }))] }) }));
|
|
52
|
+
}
|
|
53
|
+
function Btn({ label, icon, onClick, testId, className, }) {
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)("button", { className: `btn bg-gray-500 text-white p-1.5 rounded-lg opacity-70 border border-gray-200 hover:opacity-85 gap-1.5 flex items-center ${className}`, onClick: onClick, "data-testid": testId, children: [(0, jsx_runtime_1.jsx)("i", { className: icon }), " ", label] }));
|
|
55
|
+
}
|