@alpaca-editor/core 1.0.3942 → 1.0.3943
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/build.css +3 -0
- package/components.json +21 -0
- package/dist/editor/ContentTree.d.ts +2 -1
- package/dist/editor/ContentTree.js +23 -21
- package/dist/editor/ContentTree.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.js +0 -2
- package/dist/editor/FieldActionsOverlay.js.map +1 -1
- package/dist/editor/ScrollingContentTree.js +1 -1
- package/dist/editor/ScrollingContentTree.js.map +1 -1
- package/dist/editor/Titlebar.js +1 -1
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/GhostWriter.js +24 -3
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/client/EditorClient.js +7 -7
- package/dist/editor/client/EditorClient.js.map +1 -1
- package/dist/editor/field-types/InternalLinkFieldEditor.js +60 -10
- package/dist/editor/field-types/InternalLinkFieldEditor.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.js +48 -1
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -1
- package/dist/editor/menubar/PageSelector.js +116 -65
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-viewer/EditorForm.js +5 -2
- package/dist/editor/page-viewer/EditorForm.js.map +1 -1
- package/dist/editor/ui/ItemSearch.js +14 -8
- package/dist/editor/ui/ItemSearch.js.map +1 -1
- package/dist/editor/ui/PerfectTree.d.ts +4 -2
- package/dist/editor/ui/PerfectTree.js +78 -4
- package/dist/editor/ui/PerfectTree.js.map +1 -1
- package/dist/editor/ui/Splitter.js +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +8 -2
- package/eslint.config.mjs +4 -0
- package/images/bg-shape-black.webp +0 -0
- package/images/wizard-bg.png +0 -0
- package/images/wizard-tour.png +0 -0
- package/images/wizard.png +0 -0
- package/package.json +2 -8
- package/src/client-components/api.ts +6 -0
- package/src/client-components/index.ts +19 -0
- package/src/components/ActionButton.tsx +50 -0
- package/src/components/Error.tsx +57 -0
- package/src/components/ui/CardConnector.tsx +56 -0
- package/src/components/ui/button.tsx +62 -0
- package/src/components/ui/card.tsx +372 -0
- package/src/components/ui/context-menu.tsx +250 -0
- package/src/config/config.tsx +917 -0
- package/src/config/types.ts +286 -0
- package/src/editor/ComponentInfo.tsx +90 -0
- package/src/editor/ConfirmationDialog.tsx +103 -0
- package/src/editor/ContentTree.tsx +733 -0
- package/src/editor/ContextMenu.tsx +230 -0
- package/src/editor/Editor.tsx +90 -0
- package/src/editor/EditorWarning.tsx +34 -0
- package/src/editor/EditorWarnings.tsx +33 -0
- package/src/editor/FieldActionsOverlay.tsx +296 -0
- package/src/editor/FieldEditorPopup.tsx +65 -0
- package/src/editor/FieldHistory.tsx +75 -0
- package/src/editor/FieldList.tsx +190 -0
- package/src/editor/FieldListField.tsx +391 -0
- package/src/editor/FieldListFieldWithFallbacks.tsx +217 -0
- package/src/editor/FloatingToolbar.tsx +163 -0
- package/src/editor/ImageEditor.tsx +128 -0
- package/src/editor/ItemInfo.tsx +90 -0
- package/src/editor/LinkEditorDialog.tsx +196 -0
- package/src/editor/MainLayout.tsx +95 -0
- package/src/editor/MobileLayout.tsx +68 -0
- package/src/editor/NewEditorClient.tsx +11 -0
- package/src/editor/PictureCropper.tsx +568 -0
- package/src/editor/PictureEditor.tsx +301 -0
- package/src/editor/PictureEditorDialog.tsx +381 -0
- package/src/editor/PublishDialog.ignore +74 -0
- package/src/editor/ScrollingContentTree.tsx +68 -0
- package/src/editor/Terminal.tsx +227 -0
- package/src/editor/Titlebar.tsx +104 -0
- package/src/editor/ai/AiPopup.tsx +59 -0
- package/src/editor/ai/AiResponseMessage.tsx +106 -0
- package/src/editor/ai/AiTerminal.tsx +503 -0
- package/src/editor/ai/AiToolCall.tsx +61 -0
- package/src/editor/ai/EditorAiTerminal.tsx +20 -0
- package/src/editor/ai/GhostWriter.tsx +480 -0
- package/src/editor/ai/aiPageModel.ts +108 -0
- package/src/editor/ai/editorAiContext.ts +18 -0
- package/src/editor/client/AboutDialog.tsx +44 -0
- package/src/editor/client/EditorClient.tsx +2241 -0
- package/src/editor/client/GenericDialog.tsx +50 -0
- package/src/editor/client/editContext.ts +416 -0
- package/src/editor/client/helpers.ts +44 -0
- package/src/editor/client/itemsRepository.ts +574 -0
- package/src/editor/client/operations.ts +768 -0
- package/src/editor/client/pageModelBuilder.ts +219 -0
- package/src/editor/commands/commands.ts +22 -0
- package/src/editor/commands/componentCommands.tsx +431 -0
- package/src/editor/commands/createVersionCommand.ts +33 -0
- package/src/editor/commands/deleteVersionCommand.ts +71 -0
- package/src/editor/commands/itemCommands.tsx +351 -0
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +201 -0
- package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +27 -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 +179 -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 +116 -0
- package/src/editor/context-menu/CopyMoveMenu.tsx +103 -0
- package/src/editor/context-menu/InsertMenu.tsx +347 -0
- package/src/editor/control-center/About.tsx +342 -0
- package/src/editor/control-center/ControlCenterMenu.tsx +76 -0
- package/src/editor/control-center/IndexOverview.tsx +50 -0
- package/src/editor/control-center/IndexSettings.tsx +266 -0
- package/src/editor/control-center/Info.tsx +104 -0
- package/src/editor/control-center/QuotaInfo.tsx +301 -0
- package/src/editor/control-center/Status.tsx +113 -0
- package/src/editor/control-center/WebSocketMessages.tsx +155 -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 +16 -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 +80 -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 +188 -0
- package/src/editor/field-types/LinkFieldEditor.tsx +85 -0
- package/src/editor/field-types/MultiLineText.tsx +82 -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 +127 -0
- package/src/editor/field-types/SingleLineText.tsx +174 -0
- package/src/editor/field-types/TreeListEditor.tsx +261 -0
- package/src/editor/fieldTypes.ts +140 -0
- package/src/editor/media-selector/AiImageSearch.tsx +185 -0
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +94 -0
- package/src/editor/media-selector/MediaFolderBrowser.tsx +321 -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/media-selector/index.ts +8 -0
- package/src/editor/menubar/ActionsMenu.tsx +94 -0
- package/src/editor/menubar/ActiveUsers.tsx +17 -0
- package/src/editor/menubar/ApproveAndPublish.tsx +18 -0
- package/src/editor/menubar/BrowseHistory.tsx +28 -0
- package/src/editor/menubar/ItemLanguageVersion.tsx +76 -0
- package/src/editor/menubar/LanguageSelector.tsx +226 -0
- package/src/editor/menubar/Menu.tsx +83 -0
- package/src/editor/menubar/NavButtons.tsx +74 -0
- package/src/editor/menubar/PageSelector.tsx +278 -0
- package/src/editor/menubar/PageViewerControls.tsx +120 -0
- package/src/editor/menubar/PreviewSecondaryControls.tsx +18 -0
- package/src/editor/menubar/SecondaryControls.tsx +45 -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 +142 -0
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +307 -0
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +35 -0
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +59 -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 +338 -0
- package/src/editor/page-editor-chrome/FrameMenus.tsx +48 -0
- package/src/editor/page-editor-chrome/InlineEditor.tsx +765 -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 +122 -0
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +161 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +169 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +315 -0
- package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +300 -0
- package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +40 -0
- package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +828 -0
- package/src/editor/page-viewer/DeviceToolbar.tsx +70 -0
- package/src/editor/page-viewer/EditorForm.tsx +262 -0
- package/src/editor/page-viewer/MiniMap.tsx +362 -0
- package/src/editor/page-viewer/PageViewer.tsx +169 -0
- package/src/editor/page-viewer/PageViewerFrame.tsx +1022 -0
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +412 -0
- package/src/editor/page-viewer/pageViewContext.ts +186 -0
- package/src/editor/pageModel.ts +220 -0
- package/src/editor/picture-shared.tsx +53 -0
- package/src/editor/reviews/Comment.tsx +308 -0
- package/src/editor/reviews/Comments.tsx +125 -0
- package/src/editor/reviews/DiffView.tsx +109 -0
- package/src/editor/reviews/PreviewInfo.tsx +35 -0
- package/src/editor/reviews/Reviews.tsx +280 -0
- package/src/editor/reviews/SuggestedEdit.tsx +316 -0
- package/src/editor/reviews/reviewCommands.tsx +47 -0
- package/src/editor/reviews/useReviews.tsx +70 -0
- package/src/editor/services/aiService.ts +173 -0
- package/src/editor/services/componentDesignerService.ts +151 -0
- package/src/editor/services/contentService.ts +180 -0
- package/src/editor/services/editService.ts +488 -0
- package/src/editor/services/indexService.ts +24 -0
- package/src/editor/services/reviewsService.ts +53 -0
- package/src/editor/services/serviceHelper.ts +95 -0
- package/src/editor/services/suggestedEditsService.ts +39 -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 +161 -0
- package/src/editor/sidebar/ComponentTree.tsx +549 -0
- package/src/editor/sidebar/Debug.tsx +111 -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 +102 -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 +152 -0
- package/src/editor/sidebar/Translations.tsx +295 -0
- package/src/editor/sidebar/Validation.tsx +102 -0
- package/src/editor/sidebar/ViewSelector.tsx +60 -0
- package/src/editor/sidebar/Workbox.tsx +209 -0
- package/src/editor/ui/CenteredMessage.tsx +7 -0
- package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +81 -0
- package/src/editor/ui/CopyToClipboardButton.tsx +24 -0
- package/src/editor/ui/DialogButtons.tsx +11 -0
- package/src/editor/ui/Icons.tsx +709 -0
- package/src/editor/ui/ItemList.tsx +76 -0
- package/src/editor/ui/ItemNameDialogNew.tsx +118 -0
- package/src/editor/ui/ItemSearch.tsx +159 -0
- package/src/editor/ui/PerfectTree.tsx +676 -0
- package/src/editor/ui/Section.tsx +35 -0
- package/src/editor/ui/SimpleIconButton.tsx +54 -0
- package/src/editor/ui/SimpleMenu.tsx +40 -0
- package/src/editor/ui/SimpleTable.tsx +60 -0
- package/src/editor/ui/SimpleTabs.tsx +60 -0
- package/src/editor/ui/SimpleToolbar.tsx +7 -0
- package/src/editor/ui/Spinner.tsx +9 -0
- package/src/editor/ui/Splitter.tsx +420 -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 +486 -0
- package/src/editor/views/CompareView.tsx +245 -0
- package/src/editor/views/EditView.tsx +27 -0
- package/src/editor/views/ItemEditor.tsx +58 -0
- package/src/editor/views/MediaFolderEditView.tsx +66 -0
- package/src/editor/views/SingleEditView.tsx +57 -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/fonts/index.ts +10 -0
- package/src/index.ts +23 -0
- package/src/lib/safelist.tsx +16 -0
- package/src/lib/utils.ts +6 -0
- package/src/page-wizard/PageWizard.tsx +139 -0
- package/src/page-wizard/WizardBox.tsx +4 -0
- package/src/page-wizard/WizardBoxConnector.tsx +56 -0
- package/src/page-wizard/WizardSteps.tsx +458 -0
- package/src/page-wizard/service.ts +35 -0
- package/src/page-wizard/startPageWizardCommand.ts +26 -0
- package/src/page-wizard/steps/BuildPageStep.tsx +259 -0
- package/src/page-wizard/steps/CollectStep.tsx +296 -0
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +454 -0
- package/src/page-wizard/steps/Components.tsx +193 -0
- package/src/page-wizard/steps/ContentStep.tsx +890 -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 +60 -0
- package/src/page-wizard/steps/ImagesStep.tsx +382 -0
- package/src/page-wizard/steps/LayoutStep.tsx +227 -0
- package/src/page-wizard/steps/MetaDataStep.tsx +173 -0
- package/src/page-wizard/steps/SelectStep.tsx +281 -0
- package/src/page-wizard/steps/schema.ts +180 -0
- package/src/page-wizard/steps/usePageCreator.ts +325 -0
- package/src/page-wizard/usePageWizard.ts +79 -0
- package/src/revision.ts +2 -0
- package/src/splash-screen/NewPage.tsx +294 -0
- package/src/splash-screen/OpenPage.tsx +113 -0
- package/src/splash-screen/RecentPages.tsx +123 -0
- package/src/splash-screen/SectionHeadline.tsx +21 -0
- package/src/splash-screen/SplashScreen.tsx +195 -0
- package/src/tour/Tour.tsx +566 -0
- package/src/tour/default-tour.tsx +301 -0
- package/src/tour/preview-tour.tsx +128 -0
- package/src/types.ts +335 -0
- package/styles.css +765 -0
- package/tsconfig.build.json +31 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { cn } from "../lib/utils";
|
|
2
|
+
|
|
3
|
+
export function WizardBoxConnector({
|
|
4
|
+
className,
|
|
5
|
+
direction,
|
|
6
|
+
}: {
|
|
7
|
+
className?: string;
|
|
8
|
+
direction?: "horizontal" | "vertical";
|
|
9
|
+
}) {
|
|
10
|
+
return (
|
|
11
|
+
<>
|
|
12
|
+
<div
|
|
13
|
+
className={cn(
|
|
14
|
+
"mt-[-3px] mb-[-3px] flex items-center justify-center",
|
|
15
|
+
className,
|
|
16
|
+
(!direction || direction === "horizontal") && "md:hidden",
|
|
17
|
+
)}
|
|
18
|
+
>
|
|
19
|
+
<svg
|
|
20
|
+
width="40"
|
|
21
|
+
height="31"
|
|
22
|
+
viewBox="0 0 40 31"
|
|
23
|
+
fill="none"
|
|
24
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
+
>
|
|
26
|
+
<path
|
|
27
|
+
d="M40 3.04199C33.8405 3.55018 29 8.70936 29 15C29 21.2906 33.8405 26.4498 40 26.958L40 31L-1.35505e-06 31L-1.18021e-06 27C6.62741 27 12 21.6274 12 15C12 8.37258 6.62741 3 -1.31134e-07 3L0 -1.74846e-06L40 0L40 3.04199Z"
|
|
28
|
+
fill="white"
|
|
29
|
+
/>
|
|
30
|
+
</svg>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div
|
|
34
|
+
className={cn(
|
|
35
|
+
"mt-6 mr-[-3px] ml-[-3px] hidden",
|
|
36
|
+
className,
|
|
37
|
+
(!direction || direction === "horizontal") && "md:block",
|
|
38
|
+
)}
|
|
39
|
+
>
|
|
40
|
+
<svg
|
|
41
|
+
className={className}
|
|
42
|
+
width="31"
|
|
43
|
+
height="40"
|
|
44
|
+
viewBox="0 0 31 40"
|
|
45
|
+
fill="none"
|
|
46
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
47
|
+
>
|
|
48
|
+
<path
|
|
49
|
+
d="M3.04199 0C3.55018 6.15949 8.70936 11 15 11C21.2906 11 26.4498 6.1595 26.958 0H31V40H27C27 33.3726 21.6274 28 15 28C8.37258 28 3 33.3726 3 40H0V0H3.04199Z"
|
|
50
|
+
fill="white"
|
|
51
|
+
/>
|
|
52
|
+
</svg>
|
|
53
|
+
</div>
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Wizard, WizardData, WizardPageModel, WizardStep } from "./PageWizard";
|
|
3
|
+
|
|
4
|
+
import { ItemDescriptor } from "../editor/pageModel";
|
|
5
|
+
import { Logo } from "../editor/ui/Icons";
|
|
6
|
+
|
|
7
|
+
import { flushSync } from "react-dom";
|
|
8
|
+
import { useEditContext } from "../editor/client/editContext";
|
|
9
|
+
import { classNames } from "primereact/utils";
|
|
10
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
11
|
+
|
|
12
|
+
import { Button } from "../components/ui/button";
|
|
13
|
+
import { cn } from "../lib/utils";
|
|
14
|
+
import { useRef, useEffect } from "react";
|
|
15
|
+
|
|
16
|
+
interface WizardStepsProps {
|
|
17
|
+
wizard: Wizard;
|
|
18
|
+
parentItem: ItemDescriptor;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface NavigationStepsProps {
|
|
22
|
+
wizard: Wizard;
|
|
23
|
+
currentStepIndex: number;
|
|
24
|
+
onStepClick: (index: number) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface PreviousButtonProps {
|
|
28
|
+
currentStepIndex: number;
|
|
29
|
+
wizard: Wizard;
|
|
30
|
+
onPrevious: () => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface NextButtonProps {
|
|
34
|
+
currentStepIndex: number;
|
|
35
|
+
wizard: Wizard;
|
|
36
|
+
stepCompleted: number;
|
|
37
|
+
onNext: () => void;
|
|
38
|
+
onFinish: () => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface WizardHeaderProps {
|
|
42
|
+
wizard: Wizard;
|
|
43
|
+
currentStepIndex: number;
|
|
44
|
+
onStepClick: (index: number) => void;
|
|
45
|
+
onPrevious: () => void;
|
|
46
|
+
onNext: () => void;
|
|
47
|
+
onFinish: () => void;
|
|
48
|
+
stepCompleted: number;
|
|
49
|
+
isMobile: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface WizardContentProps {
|
|
53
|
+
currentStep: WizardStep;
|
|
54
|
+
children: React.ReactNode;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface MobileNavigationButtonsProps {
|
|
58
|
+
currentStepIndex: number;
|
|
59
|
+
wizard: Wizard;
|
|
60
|
+
stepCompleted: number;
|
|
61
|
+
onPrevious: () => void;
|
|
62
|
+
onNext: () => void;
|
|
63
|
+
onFinish: () => void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function PreviousButton({
|
|
67
|
+
currentStepIndex,
|
|
68
|
+
wizard,
|
|
69
|
+
onPrevious,
|
|
70
|
+
}: PreviousButtonProps) {
|
|
71
|
+
if (currentStepIndex === 0) return null;
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Button onClick={onPrevious} variant="outline">
|
|
75
|
+
<ChevronLeft /> {wizard.steps[currentStepIndex - 1]?.name}
|
|
76
|
+
</Button>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function NextButton({
|
|
81
|
+
currentStepIndex,
|
|
82
|
+
wizard,
|
|
83
|
+
stepCompleted,
|
|
84
|
+
onNext,
|
|
85
|
+
onFinish,
|
|
86
|
+
}: NextButtonProps) {
|
|
87
|
+
const isLastStep = currentStepIndex === wizard.steps.length - 1;
|
|
88
|
+
const isDisabled = stepCompleted < currentStepIndex;
|
|
89
|
+
|
|
90
|
+
if (isLastStep) {
|
|
91
|
+
return (
|
|
92
|
+
<Button disabled={isDisabled} onClick={onFinish}>
|
|
93
|
+
Finish <ChevronRight />
|
|
94
|
+
</Button>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Button disabled={isDisabled} onClick={onNext}>
|
|
100
|
+
{wizard.steps[currentStepIndex + 1]?.name}
|
|
101
|
+
<ChevronRight />
|
|
102
|
+
</Button>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function NavigationSteps({
|
|
107
|
+
wizard,
|
|
108
|
+
currentStepIndex,
|
|
109
|
+
onStepClick,
|
|
110
|
+
}: NavigationStepsProps) {
|
|
111
|
+
const stepRefs = useRef<(HTMLDivElement | null)[]>([]);
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
const activeStepElement = stepRefs.current[currentStepIndex];
|
|
115
|
+
if (activeStepElement) {
|
|
116
|
+
activeStepElement.scrollIntoView({
|
|
117
|
+
behavior: "smooth",
|
|
118
|
+
block: "nearest",
|
|
119
|
+
inline: "center",
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, [currentStepIndex]);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div className="min-w-0 flex-1">
|
|
126
|
+
<div className="p-2.5 text-xs">
|
|
127
|
+
<div className="flex items-center gap-3 md:justify-center">
|
|
128
|
+
{wizard.steps.map((step, index) => (
|
|
129
|
+
<>
|
|
130
|
+
<div
|
|
131
|
+
key={step.id}
|
|
132
|
+
ref={(el) => {
|
|
133
|
+
stepRefs.current[index] = el;
|
|
134
|
+
}}
|
|
135
|
+
className={classNames(
|
|
136
|
+
"flex shrink-0 flex-col items-center gap-1 px-1",
|
|
137
|
+
currentStepIndex > index && "cursor-pointer",
|
|
138
|
+
)}
|
|
139
|
+
onClick={() =>
|
|
140
|
+
index < currentStepIndex ? onStepClick(index) : undefined
|
|
141
|
+
}
|
|
142
|
+
>
|
|
143
|
+
<span
|
|
144
|
+
className={cn(
|
|
145
|
+
"relative flex h-6 w-6 shrink-0 items-center justify-center rounded-full border-1 p-2 text-xs font-medium",
|
|
146
|
+
currentStepIndex === index &&
|
|
147
|
+
"border-theme-secondary text-theme-secondary bg-theme-secondary-light",
|
|
148
|
+
currentStepIndex < index && "border-gray-400 text-gray-400",
|
|
149
|
+
currentStepIndex > index &&
|
|
150
|
+
"bg-theme-secondary text-gray-200",
|
|
151
|
+
)}
|
|
152
|
+
>
|
|
153
|
+
{currentStepIndex > index ? "✓" : index + 1}
|
|
154
|
+
</span>
|
|
155
|
+
<div
|
|
156
|
+
className={classNames(
|
|
157
|
+
"max-w-[80px] text-center text-[10px] whitespace-nowrap opacity-100 md:max-w-none md:text-xs",
|
|
158
|
+
currentStepIndex === index
|
|
159
|
+
? "text-theme-secondary font-semibold"
|
|
160
|
+
: currentStepIndex >= index
|
|
161
|
+
? "text-theme-secondary"
|
|
162
|
+
: "text-gray-400",
|
|
163
|
+
)}
|
|
164
|
+
>
|
|
165
|
+
{step.name}
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
{index < wizard.steps.length - 1 && (
|
|
170
|
+
<div
|
|
171
|
+
className={cn(
|
|
172
|
+
index < currentStepIndex
|
|
173
|
+
? "border-theme-secondary"
|
|
174
|
+
: "border-gray-400",
|
|
175
|
+
"mt-[-20px] h-0 w-4 shrink-0 border-t-2 bg-gray-300 md:w-8",
|
|
176
|
+
)}
|
|
177
|
+
/>
|
|
178
|
+
)}
|
|
179
|
+
</>
|
|
180
|
+
))}
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function WizardHeader({
|
|
188
|
+
wizard,
|
|
189
|
+
currentStepIndex,
|
|
190
|
+
onStepClick,
|
|
191
|
+
onPrevious,
|
|
192
|
+
onNext,
|
|
193
|
+
onFinish,
|
|
194
|
+
stepCompleted,
|
|
195
|
+
isMobile,
|
|
196
|
+
}: WizardHeaderProps) {
|
|
197
|
+
return (
|
|
198
|
+
<div className="scrollbar-hide flex w-[100vw] items-center gap-3 overflow-x-auto scroll-smooth border-b border-gray-300 bg-white md:w-auto md:px-4">
|
|
199
|
+
{!isMobile && (
|
|
200
|
+
<div className="shrink-0">
|
|
201
|
+
<PreviousButton
|
|
202
|
+
currentStepIndex={currentStepIndex}
|
|
203
|
+
wizard={wizard}
|
|
204
|
+
onPrevious={onPrevious}
|
|
205
|
+
/>
|
|
206
|
+
</div>
|
|
207
|
+
)}
|
|
208
|
+
|
|
209
|
+
<NavigationSteps
|
|
210
|
+
wizard={wizard}
|
|
211
|
+
currentStepIndex={currentStepIndex}
|
|
212
|
+
onStepClick={onStepClick}
|
|
213
|
+
/>
|
|
214
|
+
|
|
215
|
+
{!isMobile && (
|
|
216
|
+
<div className="shrink-0">
|
|
217
|
+
<NextButton
|
|
218
|
+
currentStepIndex={currentStepIndex}
|
|
219
|
+
wizard={wizard}
|
|
220
|
+
stepCompleted={stepCompleted}
|
|
221
|
+
onNext={onNext}
|
|
222
|
+
onFinish={onFinish}
|
|
223
|
+
/>
|
|
224
|
+
</div>
|
|
225
|
+
)}
|
|
226
|
+
</div>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function WizardContent({ currentStep, children }: WizardContentProps) {
|
|
231
|
+
return (
|
|
232
|
+
<div className="relative h-full flex-1 bg-neutral-100">
|
|
233
|
+
<div className="h-full p-4 md:p-8">
|
|
234
|
+
<div className="relative z-10 h-full">
|
|
235
|
+
<div className="flex h-full flex-col gap-6 md:gap-10">
|
|
236
|
+
<div className="flex gap-4">
|
|
237
|
+
<Logo className="h-8 w-8" />
|
|
238
|
+
<div className="flex-1 text-neutral-800">
|
|
239
|
+
<div className="text-lg font-semibold md:text-xl">
|
|
240
|
+
{currentStep?.fields?.title ?? currentStep?.name}
|
|
241
|
+
</div>
|
|
242
|
+
{currentStep?.fields?.description && (
|
|
243
|
+
<div className="mt-1 text-xs font-light md:text-sm">
|
|
244
|
+
{currentStep.fields.description}
|
|
245
|
+
</div>
|
|
246
|
+
)}
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
<div className="relative flex-1">
|
|
250
|
+
<div className="absolute inset-0 overflow-auto">{children}</div>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
<div className="bg-wizard absolute inset-0" />
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function MobileNavigationButtons({
|
|
261
|
+
currentStepIndex,
|
|
262
|
+
wizard,
|
|
263
|
+
stepCompleted,
|
|
264
|
+
onPrevious,
|
|
265
|
+
onNext,
|
|
266
|
+
onFinish,
|
|
267
|
+
}: MobileNavigationButtonsProps) {
|
|
268
|
+
const isLastStep = currentStepIndex === wizard.steps.length - 1;
|
|
269
|
+
const isNextDisabled = stepCompleted < currentStepIndex;
|
|
270
|
+
const showPrevious = currentStepIndex > 0;
|
|
271
|
+
|
|
272
|
+
return (
|
|
273
|
+
<div className="srcollbar-hide w-[100vw] overflow-x-auto border-t border-gray-300 bg-white px-4 py-3">
|
|
274
|
+
<div className="flex gap-3">
|
|
275
|
+
{showPrevious && (
|
|
276
|
+
<Button onClick={onPrevious} variant="outline" className="flex-1">
|
|
277
|
+
<ChevronLeft className="h-4 w-4" />
|
|
278
|
+
{wizard.steps[currentStepIndex - 1]?.name}
|
|
279
|
+
</Button>
|
|
280
|
+
)}
|
|
281
|
+
|
|
282
|
+
{isLastStep ? (
|
|
283
|
+
<Button
|
|
284
|
+
disabled={isNextDisabled}
|
|
285
|
+
onClick={onFinish}
|
|
286
|
+
className={cn("flex-1", !showPrevious && "w-full")}
|
|
287
|
+
>
|
|
288
|
+
Finish
|
|
289
|
+
<ChevronRight className="h-4 w-4" />
|
|
290
|
+
</Button>
|
|
291
|
+
) : (
|
|
292
|
+
<Button
|
|
293
|
+
disabled={isNextDisabled}
|
|
294
|
+
onClick={onNext}
|
|
295
|
+
className={cn("flex-1", !showPrevious && "w-full")}
|
|
296
|
+
>
|
|
297
|
+
{wizard.steps[currentStepIndex + 1]?.name}
|
|
298
|
+
<ChevronRight className="h-4 w-4" />
|
|
299
|
+
</Button>
|
|
300
|
+
)}
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export function WizardSteps({ wizard, parentItem }: WizardStepsProps) {
|
|
307
|
+
useEffect(() => {
|
|
308
|
+
const handleBeforeUnload = (e: BeforeUnloadEvent) => {
|
|
309
|
+
e.preventDefault();
|
|
310
|
+
e.returnValue = "";
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
314
|
+
|
|
315
|
+
return () => {
|
|
316
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
317
|
+
};
|
|
318
|
+
}, []);
|
|
319
|
+
|
|
320
|
+
const editContext = useEditContext();
|
|
321
|
+
const pageWizard = editContext?.pageWizard;
|
|
322
|
+
|
|
323
|
+
// Use state from pageWizard context instead of local state
|
|
324
|
+
const currentStepIndex = pageWizard?.currentStepIndex ?? 0;
|
|
325
|
+
const setCurrentStepIndex = pageWizard?.setCurrentStepIndex ?? (() => {});
|
|
326
|
+
const data = pageWizard?.data ?? {};
|
|
327
|
+
const setData = pageWizard?.setData ?? (() => {});
|
|
328
|
+
const pageModel = pageWizard?.pageModel ?? {
|
|
329
|
+
components: [],
|
|
330
|
+
name: "",
|
|
331
|
+
metaDescription: "",
|
|
332
|
+
metaKeywords: "",
|
|
333
|
+
};
|
|
334
|
+
const setPageModel = pageWizard?.setPageModel ?? (() => {});
|
|
335
|
+
const internalState = pageWizard?.internalState ?? {};
|
|
336
|
+
const setInternalState = pageWizard?.setInternalState ?? (() => {});
|
|
337
|
+
const stepCompleted = pageWizard?.stepCompleted ?? -1;
|
|
338
|
+
const setStepCompleted = pageWizard?.setStepCompleted ?? (() => {});
|
|
339
|
+
|
|
340
|
+
const beforeNextCallbackRef = pageWizard?.beforeNextCallbackRef ?? {
|
|
341
|
+
current: null,
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const isMobile = editContext?.isMobile ?? false;
|
|
345
|
+
|
|
346
|
+
const setBeforeNextCallback = (callback: (() => Promise<boolean>) | null) => {
|
|
347
|
+
if (beforeNextCallbackRef) {
|
|
348
|
+
beforeNextCallbackRef.current = callback;
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const getCurrentStep = () => {
|
|
353
|
+
const step = wizard.steps[currentStepIndex];
|
|
354
|
+
if (!step) return null;
|
|
355
|
+
const type = step.type;
|
|
356
|
+
const stepId = step.id;
|
|
357
|
+
|
|
358
|
+
if (!type) throw new Error("Step type is required");
|
|
359
|
+
|
|
360
|
+
// Extract component name by removing "Page Wizard" prefix and spaces
|
|
361
|
+
const componentName = type.replace("Page Wizard ", "").replace(/\s+/g, "");
|
|
362
|
+
|
|
363
|
+
const config = editContext?.configuration;
|
|
364
|
+
if (!config) return null;
|
|
365
|
+
|
|
366
|
+
// Get the appropriate component based on the extracted name
|
|
367
|
+
const StepComponent = config.pageWizard.stepComponents[componentName];
|
|
368
|
+
|
|
369
|
+
if (StepComponent) {
|
|
370
|
+
return (
|
|
371
|
+
<StepComponent
|
|
372
|
+
step={step}
|
|
373
|
+
data={data}
|
|
374
|
+
setData={setData}
|
|
375
|
+
setPageModel={setPageModel}
|
|
376
|
+
pageModel={pageModel}
|
|
377
|
+
key={stepId}
|
|
378
|
+
wizard={wizard}
|
|
379
|
+
setStepCompleted={(completed) => {
|
|
380
|
+
if (completed) {
|
|
381
|
+
setStepCompleted((prev) => Math.max(prev, currentStepIndex));
|
|
382
|
+
} else {
|
|
383
|
+
setStepCompleted(currentStepIndex - 1);
|
|
384
|
+
}
|
|
385
|
+
}}
|
|
386
|
+
setBeforeNextCallback={setBeforeNextCallback}
|
|
387
|
+
internalState={internalState}
|
|
388
|
+
setInternalState={setInternalState}
|
|
389
|
+
parentItem={parentItem}
|
|
390
|
+
/>
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return null;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
const switchStep = (index: number) => {
|
|
398
|
+
document.startViewTransition(() => {
|
|
399
|
+
flushSync(() => {
|
|
400
|
+
setCurrentStepIndex(index);
|
|
401
|
+
beforeNextCallbackRef.current = null; // Clear callback when switching steps
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
const handlePrevious = () => {
|
|
407
|
+
switchStep(currentStepIndex - 1);
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
const handleNext = async () => {
|
|
411
|
+
// If there's a beforeNext callback, execute it first
|
|
412
|
+
if (beforeNextCallbackRef.current) {
|
|
413
|
+
console.log("Calling beforeNext callback");
|
|
414
|
+
const canProceed = await beforeNextCallbackRef.current();
|
|
415
|
+
if (!canProceed) {
|
|
416
|
+
return; // Don't proceed if callback returns false
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
switchStep(currentStepIndex + 1);
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const handleFinish = () => {
|
|
423
|
+
editContext?.switchView("page-editor", { skipConfirmation: true });
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
const currentStep = wizard.steps[currentStepIndex];
|
|
427
|
+
|
|
428
|
+
if (!currentStep) return null;
|
|
429
|
+
|
|
430
|
+
return (
|
|
431
|
+
<div className="flex h-full flex-col">
|
|
432
|
+
<WizardHeader
|
|
433
|
+
wizard={wizard}
|
|
434
|
+
currentStepIndex={currentStepIndex}
|
|
435
|
+
onStepClick={switchStep}
|
|
436
|
+
onPrevious={handlePrevious}
|
|
437
|
+
onNext={handleNext}
|
|
438
|
+
onFinish={handleFinish}
|
|
439
|
+
stepCompleted={stepCompleted}
|
|
440
|
+
isMobile={isMobile}
|
|
441
|
+
/>
|
|
442
|
+
|
|
443
|
+
<WizardContent currentStep={currentStep}>
|
|
444
|
+
{getCurrentStep()}
|
|
445
|
+
</WizardContent>
|
|
446
|
+
{isMobile && (
|
|
447
|
+
<MobileNavigationButtons
|
|
448
|
+
currentStepIndex={currentStepIndex}
|
|
449
|
+
wizard={wizard}
|
|
450
|
+
stepCompleted={stepCompleted}
|
|
451
|
+
onPrevious={handlePrevious}
|
|
452
|
+
onNext={handleNext}
|
|
453
|
+
onFinish={handleFinish}
|
|
454
|
+
/>
|
|
455
|
+
)}
|
|
456
|
+
</div>
|
|
457
|
+
);
|
|
458
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EditContextType } from "../editor/client/editContext";
|
|
2
|
+
import { ItemDescriptor } from "../editor/pageModel";
|
|
3
|
+
import { post } from "../editor/services/serviceHelper";
|
|
4
|
+
|
|
5
|
+
import { Wizard } from "./PageWizard";
|
|
6
|
+
|
|
7
|
+
export async function getWizards(
|
|
8
|
+
parentItem: ItemDescriptor,
|
|
9
|
+
): Promise<Wizard[]> {
|
|
10
|
+
const result = await post("/alpaca/editor/page-wizard/wizards", parentItem);
|
|
11
|
+
return result.data as Wizard[] | [];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createWizardAiContext({
|
|
15
|
+
editContext,
|
|
16
|
+
}: {
|
|
17
|
+
editContext: EditContextType;
|
|
18
|
+
}) {
|
|
19
|
+
const aiPromptUrl = "/alpaca/editor/page-wizard/prompt";
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
// configuration.services.editorService.baseUrl +
|
|
23
|
+
endpoint: aiPromptUrl,
|
|
24
|
+
promptData: {
|
|
25
|
+
itemid: editContext.currentItemDescriptor?.id,
|
|
26
|
+
language: editContext.currentItemDescriptor?.language,
|
|
27
|
+
version: editContext.currentItemDescriptor?.version,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function wipeComponents(pageItem: ItemDescriptor) {
|
|
33
|
+
const result = await post("/alpaca/editor/page-wizard/wipePage", pageItem);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CommandContext } from "../editor/commands/commands";
|
|
2
|
+
import { ItemDescriptor } from "../editor/pageModel";
|
|
3
|
+
import { Wizard } from "./PageWizard";
|
|
4
|
+
|
|
5
|
+
export const startPageWizardCommand = {
|
|
6
|
+
id: "startWizard",
|
|
7
|
+
label: "Start Wizard",
|
|
8
|
+
icon: "pi pi-magic",
|
|
9
|
+
execute: async (
|
|
10
|
+
context: CommandContext<{ wizard: Wizard; item: ItemDescriptor }>,
|
|
11
|
+
) => {
|
|
12
|
+
if (!context.data?.item) return;
|
|
13
|
+
|
|
14
|
+
await context.editContext.loadItem(context.data.item);
|
|
15
|
+
|
|
16
|
+
// Add wizard name to URL
|
|
17
|
+
if (context.data?.wizard) {
|
|
18
|
+
context.editContext.pageWizard.setWizard(context.data.wizard);
|
|
19
|
+
context.editContext.pageWizard.setParentItem(context.data.item);
|
|
20
|
+
context.editContext.switchView("page-wizard");
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
disabled: () => {
|
|
24
|
+
return false;
|
|
25
|
+
},
|
|
26
|
+
};
|