@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,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Terminal = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const button_1 = require("primereact/button");
|
|
7
|
+
const inputtextarea_1 = require("primereact/inputtextarea");
|
|
8
|
+
const utils_1 = require("primereact/utils");
|
|
9
|
+
exports.Terminal = (0, react_1.forwardRef)((props, ref) => {
|
|
10
|
+
const { commandHandler, prompt, setPrompt, onReset, toolbar, statusbar, infobar, disabled, className, } = props;
|
|
11
|
+
const [response, setResponse] = (0, react_1.useState)();
|
|
12
|
+
const [messages, setMessages] = (0, react_1.useState)([]);
|
|
13
|
+
const bottomRef = (0, react_1.useRef)(null);
|
|
14
|
+
const messageRef = (0, react_1.useRef)(messages);
|
|
15
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
16
|
+
const [promptHistory, setPromptHistory] = (0, react_1.useState)(() => {
|
|
17
|
+
if (typeof window !== "undefined") {
|
|
18
|
+
return JSON.parse(localStorage.getItem("editor.ai.promptHistory") || "[]");
|
|
19
|
+
}
|
|
20
|
+
return [];
|
|
21
|
+
});
|
|
22
|
+
const [currentHistoryIndex, setCurrentHistoryIndex] = (0, react_1.useState)(-1);
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
localStorage.setItem("editor.ai.promptHistory", JSON.stringify(promptHistory));
|
|
25
|
+
}, [promptHistory]);
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
27
|
+
if (inputRef.current) {
|
|
28
|
+
inputRef.current.focus();
|
|
29
|
+
}
|
|
30
|
+
}, []);
|
|
31
|
+
(0, react_1.useEffect)(() => {
|
|
32
|
+
messageRef.current = messages;
|
|
33
|
+
}, [messages]);
|
|
34
|
+
const callback = (text, finished) => {
|
|
35
|
+
if (!finished)
|
|
36
|
+
setResponse(text);
|
|
37
|
+
else {
|
|
38
|
+
setResponse(undefined);
|
|
39
|
+
setMessages([...messageRef.current, { type: "response", text }]);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const handleKeyPress = (e) => {
|
|
43
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
submit();
|
|
46
|
+
}
|
|
47
|
+
if (e.key === "ArrowUp") {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
if (promptHistory.length > 0) {
|
|
50
|
+
const newIndex = currentHistoryIndex < promptHistory.length - 1
|
|
51
|
+
? currentHistoryIndex + 1
|
|
52
|
+
: currentHistoryIndex;
|
|
53
|
+
setCurrentHistoryIndex(newIndex);
|
|
54
|
+
const historicalPrompt = promptHistory[newIndex];
|
|
55
|
+
if (inputRef.current && historicalPrompt) {
|
|
56
|
+
setPrompt(historicalPrompt);
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
inputRef.current.selectionStart = historicalPrompt.length;
|
|
59
|
+
inputRef.current.selectionEnd = historicalPrompt.length;
|
|
60
|
+
}, 0);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (e.key === "ArrowDown" && currentHistoryIndex >= 0) {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
const newIndex = currentHistoryIndex - 1;
|
|
67
|
+
setCurrentHistoryIndex(newIndex);
|
|
68
|
+
const historicalPrompt = newIndex >= 0 ? promptHistory[newIndex] : "";
|
|
69
|
+
if (inputRef.current && historicalPrompt) {
|
|
70
|
+
setPrompt(historicalPrompt);
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
inputRef.current.selectionStart = historicalPrompt.length;
|
|
73
|
+
inputRef.current.selectionEnd = historicalPrompt.length;
|
|
74
|
+
}, 0);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
(0, react_1.useEffect)(() => {
|
|
79
|
+
// Scroll to bottom every time messages or response changes.
|
|
80
|
+
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
81
|
+
}, [messages, response]);
|
|
82
|
+
const responseBoxClasses = "text-xs self-stretch text-gray-700 p-2 rounded shadow border border-gray-200";
|
|
83
|
+
const getClasses = (m) => {
|
|
84
|
+
if (m.type === "response")
|
|
85
|
+
return responseBoxClasses;
|
|
86
|
+
return "text-xs text-gray-700 bg-indigo-100 p-2 rounded prompt";
|
|
87
|
+
};
|
|
88
|
+
// Expose the submit function via the ref.
|
|
89
|
+
const submit = () => {
|
|
90
|
+
if (prompt.trim()) {
|
|
91
|
+
setPromptHistory((prev) => [
|
|
92
|
+
prompt,
|
|
93
|
+
...prev.filter((p) => p !== prompt).slice(0, 9),
|
|
94
|
+
]);
|
|
95
|
+
setCurrentHistoryIndex(-1);
|
|
96
|
+
}
|
|
97
|
+
setMessages([...messages, { type: "command", text: prompt }]);
|
|
98
|
+
setPrompt("");
|
|
99
|
+
setResponse("...");
|
|
100
|
+
commandHandler(prompt, callback);
|
|
101
|
+
};
|
|
102
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
103
|
+
submit,
|
|
104
|
+
}));
|
|
105
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.classNames)("flex flex-col h-full", className), children: [(0, jsx_runtime_1.jsxs)("div", { className: "p-1 border-b border-gray-200 flex justify-between gap-2 text-xs items-center", children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
106
|
+
setMessages([]);
|
|
107
|
+
onReset();
|
|
108
|
+
}, children: (0, jsx_runtime_1.jsx)("i", { className: "pi pi-trash text-sm m-1" }) }), toolbar] }), (0, jsx_runtime_1.jsx)("div", { className: "overflow-y-auto h-full overflow-x-hidden p-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-3 items-end select-text", children: [messages.map((m, i) => ((0, jsx_runtime_1.jsx)("div", { className: getClasses(m), children: m.text }, i))), response != null && ((0, jsx_runtime_1.jsx)("div", { className: responseBoxClasses, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex text-xs", children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-xs mr-4", children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-spin pi-spinner" }), " "] }), response] }) })), (0, jsx_runtime_1.jsx)("div", { ref: bottomRef })] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col p-1 pb-0", children: [infobar, (0, jsx_runtime_1.jsx)(inputtextarea_1.InputTextarea, { ref: inputRef, value: prompt, className: "border-gray-300 border rounded flex-1 text-xs resize-none self-stretch", onKeyDown: handleKeyPress, onChange: (e) => setPrompt(e.target.value), rows: 4, cols: 30, disabled: disabled }), (0, jsx_runtime_1.jsxs)("div", { className: "flex justify-between items-center py-1", children: [statusbar, (0, jsx_runtime_1.jsx)(button_1.Button, { icon: "pi pi-send", text: true, size: "small", className: "tour-send-button", onClick: submit, disabled: prompt.trim().length === 0 })] })] })] }));
|
|
109
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Titlebar = Titlebar;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const editContext_1 = require("./client/editContext");
|
|
6
|
+
function Titlebar() {
|
|
7
|
+
const editContext = (0, editContext_1.useEditContext)();
|
|
8
|
+
if (!editContext?.view)
|
|
9
|
+
return null;
|
|
10
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "bg-gradient-to-r from-gray-900 from-10% vigray-500 to-indigo-950 h-12 flex justify-between items-center z-1 min-h-12", children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-white flex gap-2 items-center relative pl-2 font-bold", children: [(0, jsx_runtime_1.jsx)("a", { href: "/sitecore/shell/sitecore/client/Applications/Launchpad", className: "glow-text", children: (0, jsx_runtime_1.jsx)("i", { className: "pi pi-sparkles text-pink-400" }) }), " ", (0, jsx_runtime_1.jsx)("span", { className: "ml-2 font-mono", children: "editor" })] }), (0, jsx_runtime_1.jsx)("div", { children: editContext?.view.primaryControls }), (0, jsx_runtime_1.jsx)("div", { children: editContext?.view.secondaryControls })] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AiPopup = void 0;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const overlaypanel_1 = require("primereact/overlaypanel");
|
|
7
|
+
const button_1 = require("primereact/button");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const EditorAiTerminal_1 = require("./EditorAiTerminal");
|
|
10
|
+
exports.AiPopup = (0, react_1.forwardRef)((_, ref) => {
|
|
11
|
+
const overlayRef = (0, react_1.useRef)(null);
|
|
12
|
+
const [terminalOptions, setTerminalOptions] = (0, react_1.useState)();
|
|
13
|
+
//const [components, setComponents] = useState<ComponentData[]>([]); // [componentId, componentId, ...]
|
|
14
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
15
|
+
show: (ev, terminalOptions) => {
|
|
16
|
+
setTerminalOptions(terminalOptions);
|
|
17
|
+
//setComponents(components || []);
|
|
18
|
+
overlayRef.current?.toggle(ev);
|
|
19
|
+
},
|
|
20
|
+
close: () => {
|
|
21
|
+
overlayRef.current?.hide();
|
|
22
|
+
},
|
|
23
|
+
}));
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(overlaypanel_1.OverlayPanel, { ref: overlayRef, children: (0, jsx_runtime_1.jsx)("div", { className: "w-96 h-96 flex flex-col gap-2", onClick: (ev) => ev.stopPropagation(), children: (0, jsx_runtime_1.jsx)(EditorAiTerminal_1.EditorAiTerminal, { options: terminalOptions, closeButton: (0, jsx_runtime_1.jsx)(button_1.Button, { icon: "pi pi-times", onClick: () => overlayRef.current?.hide(), size: "small", text: true }) }) }) }));
|
|
25
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiResponseMessage = AiResponseMessage;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const AiToolCall_1 = require("./AiToolCall");
|
|
7
|
+
const editContext_1 = require("../client/editContext");
|
|
8
|
+
function AiResponseMessage({ responseText, toolcalls, editOperations, finished, }) {
|
|
9
|
+
const editContext = (0, editContext_1.useEditContext)();
|
|
10
|
+
if (!editContext)
|
|
11
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
12
|
+
const [showFunctions, setShowFunctions] = (0, react_1.useState)(false);
|
|
13
|
+
const [changesRejected, setChangesRejected] = (0, react_1.useState)(undefined);
|
|
14
|
+
const reversedEditOperations = [...editOperations].reverse();
|
|
15
|
+
const canReject = editContext.editHistory.length >= editOperations.length &&
|
|
16
|
+
reversedEditOperations.find((x, index) => editContext.editHistory[index]?.id !== x.id ||
|
|
17
|
+
!editContext.editHistory[index]?.canUndo) === undefined;
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { dangerouslySetInnerHTML: {
|
|
19
|
+
__html: responseText.replaceAll("\\n", "<br>"),
|
|
20
|
+
} }), toolcalls.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "text-xs text-gray-400 cursor-pointer flex items-center gap-1 mt-1", onClick: () => setShowFunctions(!showFunctions), children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-wrench text-xs" }), " Tool calls"] })), showFunctions && ((0, jsx_runtime_1.jsx)("div", { className: "text-xs text-gray-400", children: toolcalls.map((x, index) => ((0, jsx_runtime_1.jsx)(AiToolCall_1.AiToolCall, { toolCall: x }, index))) })), finished && editOperations.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 my-2 items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-xs tour-ai-response-message-changes", children: [editOperations.length, " changes"] }), canReject && !changesRejected && ((0, jsx_runtime_1.jsxs)("div", { className: "text-xs text-red-500 cursor-pointer flex items-center gap-1", onClick: async () => {
|
|
21
|
+
await editContext?.operations.undo(editOperations.length);
|
|
22
|
+
setChangesRejected(true);
|
|
23
|
+
}, children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-times" }), " Reject"] })), changesRejected && ((0, jsx_runtime_1.jsx)("div", { className: "text-xs text-red-500", children: "rejected" }))] }))] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
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.AiTerminal = AiTerminal;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const terminalservice_1 = require("primereact/terminalservice");
|
|
11
|
+
const Terminal_1 = require("../Terminal");
|
|
12
|
+
const editContext_1 = require("../client/editContext");
|
|
13
|
+
const dropdown_1 = require("primereact/dropdown");
|
|
14
|
+
const universal_cookie_1 = __importDefault(require("universal-cookie"));
|
|
15
|
+
const Icons_1 = require("../ui/Icons");
|
|
16
|
+
const AiResponseMessage_1 = require("./AiResponseMessage");
|
|
17
|
+
const aiService_1 = require("../services/aiService");
|
|
18
|
+
const SimpleIconButton_1 = require("../ui/SimpleIconButton");
|
|
19
|
+
function AiTerminal({ closeButton, createAiContext, defaultProfile, options, }) {
|
|
20
|
+
const editContext = (0, editContext_1.useEditContext)();
|
|
21
|
+
const [showPredefined, setShowPredefined] = (0, react_1.useState)(false);
|
|
22
|
+
if (!editContext)
|
|
23
|
+
return null;
|
|
24
|
+
const [messages, setMessages] = (0, react_1.useState)([]);
|
|
25
|
+
const [response, setResponse] = (0, react_1.useState)();
|
|
26
|
+
const [model, setModel] = (0, react_1.useState)();
|
|
27
|
+
const [prompt, setPrompt] = (0, react_1.useState)("");
|
|
28
|
+
const [profiles, setProfiles] = (0, react_1.useState)([]);
|
|
29
|
+
const [activeProfile, setActiveProfile] = (0, react_1.useState)();
|
|
30
|
+
const [initialPromptExecuted, setInitialPromptExecuted] = (0, react_1.useState)(false);
|
|
31
|
+
const selection = editContext.selection;
|
|
32
|
+
const terminalRef = (0, react_1.useRef)(null);
|
|
33
|
+
(0, react_1.useEffect)(() => {
|
|
34
|
+
if (options?.initialPrompt && !initialPromptExecuted && model) {
|
|
35
|
+
// Set the initial prompt text into the terminal's state.
|
|
36
|
+
console.log("setting prompt", options.initialPrompt);
|
|
37
|
+
setPrompt(options.initialPrompt);
|
|
38
|
+
setInitialPromptExecuted(true);
|
|
39
|
+
// Wait for the Terminal to update, then programmatically submit.
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
terminalRef.current?.submit();
|
|
42
|
+
}, 100);
|
|
43
|
+
}
|
|
44
|
+
}, [options?.initialPrompt, initialPromptExecuted, model]);
|
|
45
|
+
(0, react_1.useEffect)(() => {
|
|
46
|
+
async function fetchProfiles() {
|
|
47
|
+
if (!editContext?.currentItemDescriptor)
|
|
48
|
+
return;
|
|
49
|
+
const profiles = await (0, aiService_1.loadAiProfiles)(editContext.currentItemDescriptor);
|
|
50
|
+
setProfiles(profiles);
|
|
51
|
+
if (!activeProfile)
|
|
52
|
+
setActiveProfile(profiles.find((x) => x.name == defaultProfile) || profiles[0]);
|
|
53
|
+
}
|
|
54
|
+
fetchProfiles();
|
|
55
|
+
}, [editContext?.currentItemDescriptor]);
|
|
56
|
+
(0, react_1.useEffect)(() => {
|
|
57
|
+
if (activeProfile?.defaultModel)
|
|
58
|
+
setModel(activeProfile.defaultModel);
|
|
59
|
+
}, [activeProfile]);
|
|
60
|
+
const messagesRef = (0, react_1.useRef)(messages);
|
|
61
|
+
(0, react_1.useEffect)(() => {
|
|
62
|
+
messagesRef.current = messages;
|
|
63
|
+
}, [messages]);
|
|
64
|
+
async function commandHandler(text, callback) {
|
|
65
|
+
const newMessages = [
|
|
66
|
+
...messagesRef.current,
|
|
67
|
+
{ content: text, role: "user", name: "user" },
|
|
68
|
+
];
|
|
69
|
+
const context = createAiContext({ editContext });
|
|
70
|
+
let lastOpIndex = 0;
|
|
71
|
+
const selectedText = editContext?.selectedRange?.text || null;
|
|
72
|
+
if (!activeProfile || !model)
|
|
73
|
+
return;
|
|
74
|
+
const messages = [
|
|
75
|
+
...(options?.hiddenSystemPrompt
|
|
76
|
+
? [
|
|
77
|
+
{
|
|
78
|
+
role: "system",
|
|
79
|
+
name: "system",
|
|
80
|
+
content: options.hiddenSystemPrompt,
|
|
81
|
+
},
|
|
82
|
+
]
|
|
83
|
+
: []),
|
|
84
|
+
...newMessages,
|
|
85
|
+
];
|
|
86
|
+
console.log(messages);
|
|
87
|
+
const response = await executePrompt(activeProfile.id, messages, selection, editContext.sessionId, model, selectedText, context, (response) => {
|
|
88
|
+
setResponse(response);
|
|
89
|
+
handleResponse(response, callback, false);
|
|
90
|
+
if (response.editOperations.length) {
|
|
91
|
+
if (!editContext)
|
|
92
|
+
return;
|
|
93
|
+
const newOps = response.editOperations.slice(lastOpIndex);
|
|
94
|
+
if (newOps.length === 0)
|
|
95
|
+
return;
|
|
96
|
+
const isEditTextFieldOp = (op) => {
|
|
97
|
+
if (op.type !== "edit-field")
|
|
98
|
+
return false;
|
|
99
|
+
const editFieldOp = op;
|
|
100
|
+
return (editFieldOp.fieldType &&
|
|
101
|
+
editFieldOp.fieldType.indexOf("text") !== -1);
|
|
102
|
+
};
|
|
103
|
+
const isEditTextField = isEditTextFieldOp(newOps[newOps.length - 1]);
|
|
104
|
+
if (isEditTextField)
|
|
105
|
+
lastOpIndex = response.editOperations.length - 1;
|
|
106
|
+
else
|
|
107
|
+
lastOpIndex = response.editOperations.length;
|
|
108
|
+
newOps.forEach((op) => {
|
|
109
|
+
if (isEditTextFieldOp(op)) {
|
|
110
|
+
const editFieldOp = op;
|
|
111
|
+
if (editFieldOp.item) {
|
|
112
|
+
editContext.itemsRepository.updateFieldValue(editFieldOp, editFieldOp.user ?? { name: "unknown", ai: false }, false, editFieldOp.value);
|
|
113
|
+
editContext.select([editFieldOp.item.id]);
|
|
114
|
+
editContext.setScrollIntoView(editFieldOp.item.id);
|
|
115
|
+
editContext?.setFocusedField(editFieldOp, false);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
const addOp = op;
|
|
120
|
+
if (op.type === "add-component" && addOp.componentId) {
|
|
121
|
+
const newComponentId = addOp.componentId;
|
|
122
|
+
editContext.select([newComponentId]);
|
|
123
|
+
editContext.setScrollIntoView(newComponentId);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
if (response) {
|
|
130
|
+
handleResponse(response, callback, true);
|
|
131
|
+
if (context.callback)
|
|
132
|
+
context.callback(response);
|
|
133
|
+
editContext?.requestRefresh("immediate");
|
|
134
|
+
}
|
|
135
|
+
if (response?.responseText)
|
|
136
|
+
newMessages.push({
|
|
137
|
+
content: response.responseText,
|
|
138
|
+
role: "assistant",
|
|
139
|
+
name: "assistant",
|
|
140
|
+
});
|
|
141
|
+
setResponse(response ? response : undefined);
|
|
142
|
+
setMessages(newMessages);
|
|
143
|
+
}
|
|
144
|
+
(0, react_1.useEffect)(() => {
|
|
145
|
+
terminalservice_1.TerminalService.on("command", commandHandler);
|
|
146
|
+
return () => {
|
|
147
|
+
terminalservice_1.TerminalService.off("command", commandHandler);
|
|
148
|
+
};
|
|
149
|
+
}, []);
|
|
150
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "h-full flex flex-col relative flex-1 pl-1.5", "data-testid": "ai-terminal", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex-1 relative", children: [(0, jsx_runtime_1.jsx)("div", { className: "inset-0 absolute tour-ai-terminal", children: (0, jsx_runtime_1.jsx)(Terminal_1.Terminal, { disabled: !model, ref: terminalRef, onReset: () => {
|
|
151
|
+
setMessages([]);
|
|
152
|
+
setResponse(undefined);
|
|
153
|
+
}, infobar: response?.numInputTokens && ((0, jsx_runtime_1.jsxs)("div", { className: "text-gray-400 text-right", style: { fontSize: "10px" }, children: ["Tokens in: ", response?.numInputTokens?.toLocaleString(), " out:", " ", response?.numOutputTokens?.toLocaleString(), " ", response?.numCachedTokens
|
|
154
|
+
? `cached: ${response?.numCachedTokens?.toLocaleString()} `
|
|
155
|
+
: "", response?.state] })), prompt: prompt, setPrompt: setPrompt, statusbar: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between gap-1 flex-1", children: [(0, jsx_runtime_1.jsxs)("a", { className: "text-xs text-blue-300 cursor-pointer flex items-center gap-1 ml-1", onClick: () => {
|
|
156
|
+
setShowPredefined(!showPredefined);
|
|
157
|
+
}, children: [(0, jsx_runtime_1.jsx)(Icons_1.WizardIcon, { className: "w-5 h-5" }), "Predefined prompts"] }), editContext.selection?.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "text-xs text-red-400 flex items-center mr-2", children: [editContext.selection.length, " items selected", (0, jsx_runtime_1.jsx)(SimpleIconButton_1.SimpleIconButton, { icon: "pi pi-times", label: "Clear selection", onClick: () => {
|
|
158
|
+
editContext.select([]);
|
|
159
|
+
} })] })), showPredefined && ((0, jsx_runtime_1.jsx)("div", { className: "absolute right-0 left-0 bottom-8 text-sm overflow-y-auto bg-white p-3 pb-1 flex flex-col gap-1 ", children: activeProfile &&
|
|
160
|
+
activeProfile.prompts.map((p, index) => ((0, jsx_runtime_1.jsx)("div", { className: "p-1.5 mb-1 border border-gray-200 rounded-lg cursor-pointer text-gray-700 text-xs", onClick: () => {
|
|
161
|
+
setPrompt(p.prompt);
|
|
162
|
+
setShowPredefined(false);
|
|
163
|
+
}, children: p.title }, index))) }))] }), toolbar: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-stretch gap-1", children: [(0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, { className: "text-sm", value: activeProfile, onChange: (e) => setActiveProfile(e.value), optionLabel: "name", options: profiles }), activeProfile && ((0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, { className: "text-sm", value: model, onChange: (e) => setModel(e.value), options: activeProfile.models })), closeButton] }), commandHandler: (v, callback) => {
|
|
164
|
+
commandHandler(v, callback);
|
|
165
|
+
} }) }), activeProfile?.errorMessage && ((0, jsx_runtime_1.jsx)("div", { className: "text-red-500 text-sm p-2 inset-0 absolute grid items-center justify-center", children: activeProfile?.errorMessage })), !model && ((0, jsx_runtime_1.jsx)("div", { className: "inset-0 absolute grid items-center justify-center text-gray-400 text-sm", children: !activeProfile ? "No profile selected" : "No model selected" }))] }) }));
|
|
166
|
+
}
|
|
167
|
+
async function executePrompt(profileId, messages, selection, session, model, selectedText, context, callback) {
|
|
168
|
+
const response = await fetch(context.endpoint, {
|
|
169
|
+
method: "POST",
|
|
170
|
+
body: JSON.stringify({
|
|
171
|
+
...context.promptData,
|
|
172
|
+
profileId,
|
|
173
|
+
messages,
|
|
174
|
+
selection,
|
|
175
|
+
selectedText,
|
|
176
|
+
model,
|
|
177
|
+
sessionId: session,
|
|
178
|
+
}),
|
|
179
|
+
credentials: "include",
|
|
180
|
+
headers: {
|
|
181
|
+
"Content-Type": "application/json",
|
|
182
|
+
Cookie: new universal_cookie_1.default().getAll(),
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
if (!response?.body)
|
|
186
|
+
return null;
|
|
187
|
+
const reader = response.body.getReader();
|
|
188
|
+
const decoder = new TextDecoder();
|
|
189
|
+
let buffer = "";
|
|
190
|
+
let result = null;
|
|
191
|
+
while (true) {
|
|
192
|
+
const { done, value } = await reader.read();
|
|
193
|
+
if (done) {
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
buffer += decoder.decode(value, { stream: true }); // 'stream: true' ensures that any incomplete multi-byte characters aren't malformed.
|
|
197
|
+
// Split the buffer by newline and keep the last partial line for the next iteration.
|
|
198
|
+
const lines = buffer.split("\n");
|
|
199
|
+
if (lines.length > 0) {
|
|
200
|
+
buffer = lines.pop() || ""; // Incomplete line (if any) is kept for the next iteration.
|
|
201
|
+
for (let line of lines) {
|
|
202
|
+
if (line.trim() === "")
|
|
203
|
+
continue; // Skip empty lines if any.
|
|
204
|
+
try {
|
|
205
|
+
const jsonData = JSON.parse(line);
|
|
206
|
+
callback(jsonData);
|
|
207
|
+
result = jsonData;
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
console.error("Error parsing line:" + line, e);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// If there's any remaining content in the buffer after processing all chunks, try to process it.
|
|
216
|
+
if (buffer.trim() !== "") {
|
|
217
|
+
try {
|
|
218
|
+
const jsonData = JSON.parse(buffer);
|
|
219
|
+
result = jsonData;
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
console.error("Error parsing the final buffer content:", e);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
function handleResponse(response, terminalCallback, isFinished) {
|
|
228
|
+
const toolcalls = response?.toolCalls?.map((tool_call) => {
|
|
229
|
+
return {
|
|
230
|
+
func: tool_call.function?.name,
|
|
231
|
+
arguments: tool_call.function?.arguments,
|
|
232
|
+
result: tool_call.result,
|
|
233
|
+
error: tool_call.error,
|
|
234
|
+
};
|
|
235
|
+
}) || [];
|
|
236
|
+
const responseText = response.responseText
|
|
237
|
+
?.trim()
|
|
238
|
+
.replace(/\n/g, "<br/>")
|
|
239
|
+
?.replace(/\*\*(.*?)\*\*/g, "<b>$1</b>");
|
|
240
|
+
terminalCallback((0, jsx_runtime_1.jsx)(AiResponseMessage_1.AiResponseMessage, { responseText: responseText, toolcalls: toolcalls, editOperations: response.editOperations, finished: isFinished }), isFinished);
|
|
241
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiToolCall = AiToolCall;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_json_view_lite_1 = require("react-json-view-lite");
|
|
7
|
+
function AiToolCall({ toolCall }) {
|
|
8
|
+
const [expanded, setExpaded] = (0, react_1.useState)(false);
|
|
9
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "mt-2", children: [(0, jsx_runtime_1.jsxs)("div", { onClick: () => setExpaded(!expanded), className: "flex items-center cursor-pointer", children: [(0, jsx_runtime_1.jsx)("i", { className: "pi pi-angle-right" }), " ", toolCall.func] }), expanded && ((0, jsx_runtime_1.jsxs)("div", { className: "ml-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "italic", children: "Args:" }), (0, jsx_runtime_1.jsx)("div", { children: renderJsonOrText(toolCall.arguments) }), (0, jsx_runtime_1.jsx)("div", { className: "italic mt-1", children: "Result:" }), (0, jsx_runtime_1.jsxs)("div", { className: "mb-4", children: [toolCall.error && ((0, jsx_runtime_1.jsx)("div", { className: "text-red", children: toolCall.error })), renderJsonOrText(toolCall.result)] })] }))] }));
|
|
10
|
+
}
|
|
11
|
+
function renderJsonOrText(json) {
|
|
12
|
+
try {
|
|
13
|
+
return (0, jsx_runtime_1.jsx)(react_json_view_lite_1.JsonView, { data: JSON.parse(json), style: react_json_view_lite_1.defaultStyles });
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
return (0, jsx_runtime_1.jsx)("div", { children: json });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EditorAiTerminal = EditorAiTerminal;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const AiTerminal_1 = require("./AiTerminal");
|
|
6
|
+
const editorAiContext_1 = require("./editorAiContext");
|
|
7
|
+
function EditorAiTerminal({ closeButton, options, }) {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(AiTerminal_1.AiTerminal, { options: options, closeButton: closeButton, createAiContext: editorAiContext_1.createEditorAiContext, defaultProfile: "Editor" }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEditorAiContext = createEditorAiContext;
|
|
4
|
+
function createEditorAiContext({ editContext, }) {
|
|
5
|
+
const aiPromptUrl = editContext.configuration.services.aiService.promptUrl;
|
|
6
|
+
return {
|
|
7
|
+
endpoint: aiPromptUrl,
|
|
8
|
+
promptData: {
|
|
9
|
+
itemid: editContext.currentItemDescriptor?.id,
|
|
10
|
+
language: editContext.currentItemDescriptor?.language,
|
|
11
|
+
version: editContext.currentItemDescriptor?.version,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDialog = exports.DialogProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
// DialogContext.tsx
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const DialogContext = (0, react_1.createContext)(undefined);
|
|
8
|
+
const DialogProvider = ({ children, }) => {
|
|
9
|
+
const [dialog, setDialog] = (0, react_1.useState)(null);
|
|
10
|
+
const openDialog = (Component, props) => {
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
const handleClose = (result) => {
|
|
13
|
+
setDialog(null);
|
|
14
|
+
resolve(result);
|
|
15
|
+
};
|
|
16
|
+
setDialog((0, jsx_runtime_1.jsx)(Component, { ...props, onClose: handleClose }));
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
return ((0, jsx_runtime_1.jsxs)(DialogContext.Provider, { value: { openDialog }, children: [children, dialog] }));
|
|
20
|
+
};
|
|
21
|
+
exports.DialogProvider = DialogProvider;
|
|
22
|
+
const useDialog = () => {
|
|
23
|
+
const context = (0, react_1.useContext)(DialogContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error("useDialog must be used within a DialogProvider");
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
28
|
+
};
|
|
29
|
+
exports.useDialog = useDialog;
|