@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,245 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { EditorMode, useEditContext } from "../client/editContext";
|
|
3
|
+
import { LanguageSelector } from "../menubar/LanguageSelector";
|
|
4
|
+
import { VersionSelector } from "../menubar/VersionSelector";
|
|
5
|
+
import { FullItem, ItemDescriptor, Version } from "../pageModel";
|
|
6
|
+
import { usePageViewContext } from "../page-viewer/pageViewContext";
|
|
7
|
+
import { useSearchParams } from "next/navigation";
|
|
8
|
+
import { useRouter } from "next/navigation";
|
|
9
|
+
import { SingleEditView } from "./SingleEditView";
|
|
10
|
+
import { getLanguagesAndVersions } from "../services/contentService";
|
|
11
|
+
import { Allotment } from "allotment";
|
|
12
|
+
import { ItemEditor } from "./ItemEditor";
|
|
13
|
+
|
|
14
|
+
export function CompareView() {
|
|
15
|
+
const editContext = useEditContext();
|
|
16
|
+
const searchParams = useSearchParams();
|
|
17
|
+
const router = useRouter();
|
|
18
|
+
if (!editContext) return;
|
|
19
|
+
|
|
20
|
+
const [compareToItem, setCompareToItem] = useState<FullItem | undefined>();
|
|
21
|
+
const [compareToVersions, setCompareToVersions] = useState<Version[]>([]);
|
|
22
|
+
|
|
23
|
+
const compareTo = editContext.compareTo;
|
|
24
|
+
const setCompareTo = editContext.setCompareTo;
|
|
25
|
+
|
|
26
|
+
const comparePageViewContext = usePageViewContext({
|
|
27
|
+
pageItemDescriptor: compareToItem?.descriptor,
|
|
28
|
+
itemsRepository: editContext.itemsRepository,
|
|
29
|
+
configuration: editContext.configuration,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
comparePageViewContext.setDevice(editContext.pageView.device);
|
|
34
|
+
}, [editContext.pageView.device]);
|
|
35
|
+
|
|
36
|
+
const updateCompareToVersions = async () => {
|
|
37
|
+
if (!compareTo || !compareTo.id || !compareTo.language) {
|
|
38
|
+
setCompareToVersions([]);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const result = await getLanguagesAndVersions(compareTo);
|
|
42
|
+
if (result?.data) {
|
|
43
|
+
const versions = result.data.versions.reverse();
|
|
44
|
+
setCompareToVersions(versions);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const updateCompareTo = async () => {
|
|
50
|
+
if (!editContext) return;
|
|
51
|
+
if (editContext.contentEditorItem) {
|
|
52
|
+
let urlLanguage =
|
|
53
|
+
searchParams.get("compareLanguage") ||
|
|
54
|
+
editContext.contentEditorItem.descriptor.language;
|
|
55
|
+
let urlVersion =
|
|
56
|
+
parseInt(searchParams.get("compareVersion") || "0") ||
|
|
57
|
+
editContext.currentItemDescriptor?.version;
|
|
58
|
+
|
|
59
|
+
const language = editContext.itemLanguages.find(
|
|
60
|
+
(x) => x.languageCode === urlLanguage,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (!language || !language.versions) {
|
|
64
|
+
urlLanguage = "";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!editContext.currentItemDescriptor?.id || !language) {
|
|
68
|
+
setCompareTo(undefined);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const result = await getLanguagesAndVersions({
|
|
73
|
+
id: editContext.currentItemDescriptor?.id,
|
|
74
|
+
language: language.languageCode,
|
|
75
|
+
version: 0,
|
|
76
|
+
});
|
|
77
|
+
if (result?.data) {
|
|
78
|
+
const versions = [...result.data.versions].reverse();
|
|
79
|
+
const version = versions.find((x) => x.version === urlVersion);
|
|
80
|
+
|
|
81
|
+
setCompareTo({
|
|
82
|
+
id: editContext.contentEditorItem.descriptor.id,
|
|
83
|
+
language: urlLanguage,
|
|
84
|
+
version: version?.version || 0,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
updateCompareTo();
|
|
90
|
+
}, [searchParams, editContext?.itemLanguages]);
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
const updateCompareToItem = async () => {
|
|
94
|
+
if (!compareTo || !compareTo.id || !compareTo.language) {
|
|
95
|
+
setCompareToItem(undefined);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const item = await editContext?.itemsRepository.getItem(compareTo);
|
|
99
|
+
setCompareToItem(item);
|
|
100
|
+
};
|
|
101
|
+
updateCompareToItem();
|
|
102
|
+
updateCompareToVersions();
|
|
103
|
+
}, [compareTo]);
|
|
104
|
+
|
|
105
|
+
function updateCompareTo(compareToItemDescriptor: ItemDescriptor) {
|
|
106
|
+
if (compareToItemDescriptor) {
|
|
107
|
+
const newParams = new URLSearchParams(searchParams.toString());
|
|
108
|
+
newParams.set("compareLanguage", compareToItemDescriptor.language);
|
|
109
|
+
newParams.set(
|
|
110
|
+
"compareVersion",
|
|
111
|
+
compareToItemDescriptor.version.toString(),
|
|
112
|
+
);
|
|
113
|
+
router.push(`?${newParams.toString()}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const originalSelector = (
|
|
118
|
+
<div className="flex flex-1 flex-shrink-0 items-center justify-center border-b bg-gray-100 p-1 text-sm text-gray-600">
|
|
119
|
+
<LanguageSelector
|
|
120
|
+
selectedLanguage={editContext.contentEditorItem?.descriptor?.language}
|
|
121
|
+
showAllLanguagesSwitch={false}
|
|
122
|
+
darkMode
|
|
123
|
+
onLanguageSelected={(language) => {
|
|
124
|
+
if (!editContext.contentEditorItem) return;
|
|
125
|
+
editContext.loadItem({
|
|
126
|
+
id: editContext.contentEditorItem.descriptor.id,
|
|
127
|
+
language: language.languageCode,
|
|
128
|
+
version: 0,
|
|
129
|
+
});
|
|
130
|
+
}}
|
|
131
|
+
/>
|
|
132
|
+
{compareTo?.language && (
|
|
133
|
+
<VersionSelector
|
|
134
|
+
darkMode
|
|
135
|
+
readOnly={true}
|
|
136
|
+
versions={editContext.itemVersions}
|
|
137
|
+
itemDescriptor={editContext.currentItemDescriptor}
|
|
138
|
+
actualVersion={editContext.contentEditorItem?.version}
|
|
139
|
+
onVersionSelected={(version) => {
|
|
140
|
+
if (!editContext.contentEditorItem) return;
|
|
141
|
+
editContext.loadItem({
|
|
142
|
+
id: editContext.contentEditorItem.descriptor.id,
|
|
143
|
+
language: editContext.contentEditorItem.descriptor.language,
|
|
144
|
+
version,
|
|
145
|
+
});
|
|
146
|
+
}}
|
|
147
|
+
/>
|
|
148
|
+
)}
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const compareToSelector = (
|
|
153
|
+
<div className="flex flex-1 flex-shrink-0 items-center justify-center border-b bg-gray-100 p-1 text-sm text-gray-600">
|
|
154
|
+
<LanguageSelector
|
|
155
|
+
selectedLanguage={compareTo?.language}
|
|
156
|
+
showAllLanguagesSwitch={false}
|
|
157
|
+
darkMode
|
|
158
|
+
onLanguageSelected={(language) => {
|
|
159
|
+
if (!compareTo?.id) return;
|
|
160
|
+
updateCompareTo({
|
|
161
|
+
id: compareTo.id,
|
|
162
|
+
language: language.languageCode,
|
|
163
|
+
version: compareTo.version,
|
|
164
|
+
});
|
|
165
|
+
}}
|
|
166
|
+
/>
|
|
167
|
+
{compareTo?.language && (
|
|
168
|
+
<VersionSelector
|
|
169
|
+
darkMode
|
|
170
|
+
readOnly={true}
|
|
171
|
+
versions={compareToVersions}
|
|
172
|
+
itemDescriptor={compareTo}
|
|
173
|
+
actualVersion={compareToItem?.version}
|
|
174
|
+
onVersionSelected={(version) => {
|
|
175
|
+
if (!compareTo?.id) return;
|
|
176
|
+
updateCompareTo({
|
|
177
|
+
id: compareTo.id,
|
|
178
|
+
language: compareTo.language,
|
|
179
|
+
version,
|
|
180
|
+
});
|
|
181
|
+
}}
|
|
182
|
+
/>
|
|
183
|
+
)}
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
if (
|
|
188
|
+
(compareToItem && !compareToItem.hasLayout) ||
|
|
189
|
+
comparePageViewContext.device === ""
|
|
190
|
+
)
|
|
191
|
+
return (
|
|
192
|
+
<div className="flex h-full w-full flex-col items-stretch">
|
|
193
|
+
<div className="flex w-full">
|
|
194
|
+
{originalSelector}
|
|
195
|
+
{compareToSelector}
|
|
196
|
+
</div>
|
|
197
|
+
<div className="relative flex-1">
|
|
198
|
+
<div className="absolute h-full w-full">
|
|
199
|
+
<ItemEditor
|
|
200
|
+
pageViewContext={editContext.pageView}
|
|
201
|
+
compareToItem={compareToItem}
|
|
202
|
+
/>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<Allotment className="flex h-full w-full">
|
|
210
|
+
<Allotment.Pane>
|
|
211
|
+
<div className="flex h-full w-full flex-col items-stretch">
|
|
212
|
+
{originalSelector}
|
|
213
|
+
<SingleEditView
|
|
214
|
+
key="original"
|
|
215
|
+
name="original"
|
|
216
|
+
compareView={false}
|
|
217
|
+
pageViewContext={editContext.pageView}
|
|
218
|
+
itemDescriptor={editContext.contentEditorItem?.descriptor}
|
|
219
|
+
/>
|
|
220
|
+
</div>
|
|
221
|
+
</Allotment.Pane>
|
|
222
|
+
<Allotment.Pane>
|
|
223
|
+
<div className="flex h-full w-full flex-col items-stretch">
|
|
224
|
+
{compareToSelector}
|
|
225
|
+
{compareTo?.language && (
|
|
226
|
+
<SingleEditView
|
|
227
|
+
key="compareTo"
|
|
228
|
+
name="compareTo"
|
|
229
|
+
compareView={true}
|
|
230
|
+
pageViewContext={comparePageViewContext}
|
|
231
|
+
itemDescriptor={compareTo}
|
|
232
|
+
/>
|
|
233
|
+
)}
|
|
234
|
+
{!compareTo?.language && (
|
|
235
|
+
<div className="flex h-full w-full flex-col items-center justify-center">
|
|
236
|
+
<div className="text-gray-400">
|
|
237
|
+
Select a language and version to compare
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
)}
|
|
241
|
+
</div>
|
|
242
|
+
</Allotment.Pane>
|
|
243
|
+
</Allotment>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEditContext } from "../client/editContext";
|
|
2
|
+
import { CompareView } from "./CompareView";
|
|
3
|
+
import { SingleEditView } from "./SingleEditView";
|
|
4
|
+
|
|
5
|
+
export function EditView() {
|
|
6
|
+
const editContext = useEditContext();
|
|
7
|
+
if (!editContext) return null;
|
|
8
|
+
|
|
9
|
+
if (!editContext.contentEditorItem?.descriptor)
|
|
10
|
+
return (
|
|
11
|
+
<div className="grid h-full w-full items-center justify-center">
|
|
12
|
+
<div className="text-sm text-gray-500">Not item selected</div>
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
if (editContext.compareMode) return <CompareView />;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<SingleEditView
|
|
20
|
+
key="single"
|
|
21
|
+
name="single"
|
|
22
|
+
compareView={false}
|
|
23
|
+
pageViewContext={editContext.pageView}
|
|
24
|
+
itemDescriptor={editContext.contentEditorItem?.descriptor}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Button } from "primereact/button";
|
|
2
|
+
import { EditorWarnings } from "../EditorWarnings";
|
|
3
|
+
import { FieldList } from "../FieldList";
|
|
4
|
+
import { ItemInfo } from "../ItemInfo";
|
|
5
|
+
import { useEditContext } from "../client/editContext";
|
|
6
|
+
import { PageViewContext } from "../page-viewer/pageViewContext";
|
|
7
|
+
import { FullItem } from "../pageModel";
|
|
8
|
+
|
|
9
|
+
export function ItemEditor({
|
|
10
|
+
item,
|
|
11
|
+
compareToItem,
|
|
12
|
+
}: {
|
|
13
|
+
item?: FullItem;
|
|
14
|
+
compareToItem?: FullItem;
|
|
15
|
+
pageViewContext?: PageViewContext;
|
|
16
|
+
}) {
|
|
17
|
+
const editContext = useEditContext();
|
|
18
|
+
|
|
19
|
+
if (!editContext) return;
|
|
20
|
+
if (!item) item = editContext.contentEditorItem;
|
|
21
|
+
if (!item) return;
|
|
22
|
+
|
|
23
|
+
const pageValidators =
|
|
24
|
+
editContext.validationResult?.find(
|
|
25
|
+
(x) =>
|
|
26
|
+
x.item.id === item?.id &&
|
|
27
|
+
x.item.language === item?.language &&
|
|
28
|
+
x.item.version === item?.version,
|
|
29
|
+
)?.results || [];
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className="absolute inset-0 overflow-y-auto">
|
|
33
|
+
<EditorWarnings item={item} />
|
|
34
|
+
<ItemInfo item={item} />
|
|
35
|
+
|
|
36
|
+
{editContext.itemVersions.length > 0 && (
|
|
37
|
+
<FieldList
|
|
38
|
+
fields={[{ fields: Object.values(item.fields) }]}
|
|
39
|
+
validators={pageValidators.filter((x) => x.itemId === item.id)}
|
|
40
|
+
showStandardFieldsEnabled={true}
|
|
41
|
+
compareToFields={compareToItem?.fields}
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
|
|
45
|
+
{editContext.itemVersions.length === 0 && (
|
|
46
|
+
<div className="flex justify-center p-4">
|
|
47
|
+
<Button
|
|
48
|
+
onClick={async () => {
|
|
49
|
+
await editContext.operations.createVersion(item.descriptor);
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
Create First Version ({item.language})
|
|
53
|
+
</Button>
|
|
54
|
+
</div>
|
|
55
|
+
)}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { SimpleTabs, Tab } from "../ui/SimpleTabs";
|
|
3
|
+
import { MediaFolderBrowser } from "../media-selector/MediaFolderBrowser";
|
|
4
|
+
import { ItemEditor } from "./ItemEditor";
|
|
5
|
+
import { FullItem } from "../pageModel";
|
|
6
|
+
import { useEditContext } from "../client/editContext";
|
|
7
|
+
|
|
8
|
+
export function MediaFolderEditView({ item }: { item?: FullItem }) {
|
|
9
|
+
const [activeTabKey, setActiveTabKey] = useState("media-browser");
|
|
10
|
+
const editContext = useEditContext();
|
|
11
|
+
|
|
12
|
+
if (!editContext) return null;
|
|
13
|
+
if (!item) item = editContext.contentEditorItem;
|
|
14
|
+
if (!item) return null;
|
|
15
|
+
|
|
16
|
+
const tabPanels: Tab[] = [];
|
|
17
|
+
|
|
18
|
+
// Media Browser tab for media folders - First tab
|
|
19
|
+
tabPanels.push({
|
|
20
|
+
label: "Media Browser",
|
|
21
|
+
content: (
|
|
22
|
+
<div className="relative flex flex-1 flex-col">
|
|
23
|
+
<div className="absolute inset-0 overflow-y-auto">
|
|
24
|
+
<MediaFolderBrowser
|
|
25
|
+
folderId={item.id}
|
|
26
|
+
language={item.language}
|
|
27
|
+
onMediaSelected={async (mediaId: string) => {
|
|
28
|
+
// Open media selector for the selected media item
|
|
29
|
+
const result = await editContext.selectMedia({
|
|
30
|
+
selectedIdPath: `${item.idPath}/${mediaId}`,
|
|
31
|
+
mode: "images",
|
|
32
|
+
});
|
|
33
|
+
if (result) {
|
|
34
|
+
console.log("Selected media:", result);
|
|
35
|
+
}
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
),
|
|
41
|
+
id: "media-browser",
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Content tab - using the standard ItemEditor
|
|
45
|
+
tabPanels.push({
|
|
46
|
+
label: "Content",
|
|
47
|
+
content: (
|
|
48
|
+
<div className="relative h-full">
|
|
49
|
+
<ItemEditor item={item} />
|
|
50
|
+
</div>
|
|
51
|
+
),
|
|
52
|
+
id: "content",
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className="flex h-full flex-col">
|
|
57
|
+
<SimpleTabs
|
|
58
|
+
key="media-folder-edit-tabs"
|
|
59
|
+
tabs={tabPanels}
|
|
60
|
+
className="border-b border-gray-200 bg-gray-50 px-4 py-2.5 text-sm"
|
|
61
|
+
activeTab={tabPanels.findIndex((x) => x.id === activeTabKey) || 0}
|
|
62
|
+
setActiveTab={(index) => setActiveTabKey(tabPanels[index]?.id!)}
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { useEditContext } from "../client/editContext";
|
|
4
|
+
import { PageViewer } from "../page-viewer/PageViewer";
|
|
5
|
+
import { PageViewContext } from "../page-viewer/pageViewContext";
|
|
6
|
+
import { FullItem, ItemDescriptor } from "../pageModel";
|
|
7
|
+
import { ItemEditor } from "./ItemEditor";
|
|
8
|
+
import { MediaFolderEditView } from "./MediaFolderEditView";
|
|
9
|
+
|
|
10
|
+
export function SingleEditView({
|
|
11
|
+
pageViewContext,
|
|
12
|
+
itemDescriptor,
|
|
13
|
+
compareView,
|
|
14
|
+
name,
|
|
15
|
+
}: {
|
|
16
|
+
pageViewContext: PageViewContext;
|
|
17
|
+
itemDescriptor?: ItemDescriptor;
|
|
18
|
+
compareView: boolean;
|
|
19
|
+
name: string;
|
|
20
|
+
}) {
|
|
21
|
+
const editContext = useEditContext();
|
|
22
|
+
const [item, setItem] = useState<FullItem | undefined>(undefined);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
async function loadItem() {
|
|
26
|
+
if (!itemDescriptor) return;
|
|
27
|
+
const item = await editContext?.itemsRepository.getItem(itemDescriptor);
|
|
28
|
+
setItem(item);
|
|
29
|
+
}
|
|
30
|
+
loadItem();
|
|
31
|
+
}, [itemDescriptor]);
|
|
32
|
+
|
|
33
|
+
if ((item && !item.hasLayout) || pageViewContext.device === "") {
|
|
34
|
+
// Check if this is a media folder
|
|
35
|
+
const isMediaFolder =
|
|
36
|
+
item?.templateId?.toLowerCase() ===
|
|
37
|
+
"fe5dd826-48c6-436d-b87a-7c4210c7413b";
|
|
38
|
+
|
|
39
|
+
if (isMediaFolder) {
|
|
40
|
+
return <MediaFolderEditView item={item} />;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return <ItemEditor item={item} />;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<PageViewer
|
|
48
|
+
pageViewContext={pageViewContext}
|
|
49
|
+
showFormEditor={
|
|
50
|
+
editContext?.viewName == "page-editor" || !editContext?.isMobile
|
|
51
|
+
}
|
|
52
|
+
compareView={compareView}
|
|
53
|
+
name={name}
|
|
54
|
+
followEditsDefault={true}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from "./config/types";
|
|
2
|
+
|
|
3
|
+
export * from "./types";
|
|
4
|
+
|
|
5
|
+
export { Editor } from "./editor/Editor";
|
|
6
|
+
|
|
7
|
+
export { configureForUser } from "./config/config";
|
|
8
|
+
|
|
9
|
+
export type { DialogProps } from "./editor/client/editContext";
|
|
10
|
+
|
|
11
|
+
export type {
|
|
12
|
+
LocalizeItemCommand,
|
|
13
|
+
LocalizeItemCommandContext,
|
|
14
|
+
LocalizeItemCommandData,
|
|
15
|
+
} from "./editor/commands/itemCommands";
|
|
16
|
+
|
|
17
|
+
export { requestTranslation } from "./editor/services/translationService";
|
|
18
|
+
|
|
19
|
+
export { defaultTranslateAll } from "./editor/commands/localizeItem/LocalizeItemUtils";
|
|
20
|
+
|
|
21
|
+
export * from "./fonts";
|
|
22
|
+
|
|
23
|
+
export { Card } from "./components/ui/card";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function Safelist() {
|
|
2
|
+
return (
|
|
3
|
+
<>
|
|
4
|
+
<div className="bg-orange-400"></div>
|
|
5
|
+
<div className="bg-purple-400"></div>
|
|
6
|
+
<div className="bg-sky-400"></div>
|
|
7
|
+
<div className="bg-red-400"></div>
|
|
8
|
+
<div className="bg-teal-400"></div>
|
|
9
|
+
<div className="border-orange-400"></div>
|
|
10
|
+
<div className="border-purple-400"></div>
|
|
11
|
+
<div className="border-sky-400"></div>
|
|
12
|
+
<div className="border-red-400"></div>
|
|
13
|
+
<div className="border-teal-400"></div>
|
|
14
|
+
</>
|
|
15
|
+
);
|
|
16
|
+
}
|
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { useEditContext } from "../editor/client/editContext";
|
|
2
|
+
|
|
3
|
+
import { WizardSteps } from "./WizardSteps";
|
|
4
|
+
import { Thumbnail } from "../editor/media-selector/Thumbnails";
|
|
5
|
+
|
|
6
|
+
export type Wizard = {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
steps: WizardStep[];
|
|
11
|
+
icon: string;
|
|
12
|
+
schema: PageSchema;
|
|
13
|
+
templateId: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type PageSchema = SchemaPlaceholder[];
|
|
17
|
+
|
|
18
|
+
export type SchemaComponent = {
|
|
19
|
+
type: string;
|
|
20
|
+
typeId: string;
|
|
21
|
+
fields: SchemaField[];
|
|
22
|
+
placeholders: SchemaPlaceholder[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type SchemaPlaceholder = {
|
|
26
|
+
name: string;
|
|
27
|
+
components: SchemaComponent[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type SchemaField = {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
type: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type WizardSchemaComponent = {
|
|
37
|
+
type: string;
|
|
38
|
+
fields: WizardSchemaField[];
|
|
39
|
+
availableParentPlaceholders?: string[];
|
|
40
|
+
allowedChildrenComponentTypes: string[];
|
|
41
|
+
allowedOnRoot: boolean;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type WizardSchemaField = {
|
|
45
|
+
name: string;
|
|
46
|
+
type: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type WizardStep = {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
type: string;
|
|
53
|
+
fields: { [key: string]: string };
|
|
54
|
+
children?: WizardStep[];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type WizardData = {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type WizardPageModel = {
|
|
62
|
+
components: WizardPageComponent[];
|
|
63
|
+
name: string;
|
|
64
|
+
metaDescription: string;
|
|
65
|
+
metaKeywords: string;
|
|
66
|
+
message?: string;
|
|
67
|
+
images?: Thumbnail[];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type WizardPageComponent = {
|
|
71
|
+
id: string;
|
|
72
|
+
name: string;
|
|
73
|
+
type: string;
|
|
74
|
+
fields: WizardField[];
|
|
75
|
+
children?: WizardPageComponent[];
|
|
76
|
+
description: string;
|
|
77
|
+
placeholder?: string;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type WizardField = {
|
|
81
|
+
name: string;
|
|
82
|
+
value: string;
|
|
83
|
+
type: string;
|
|
84
|
+
writtenValue?: string;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export function PageWizard() {
|
|
88
|
+
const editContext = useEditContext();
|
|
89
|
+
// const [wizard, setWizard] = useState<Wizard | null>(null);
|
|
90
|
+
// const [parentItem, setParentItem] = useState<ItemDescriptor>();
|
|
91
|
+
|
|
92
|
+
const { wizard, parentItem } = editContext?.pageWizard || {};
|
|
93
|
+
// const searchParams = useSearchParams();
|
|
94
|
+
|
|
95
|
+
// // Load all wizards and check URL param on mount
|
|
96
|
+
// useEffect(() => {
|
|
97
|
+
// if (!editContext?.currentItemDescriptor) return;
|
|
98
|
+
// getWizards(editContext?.currentItemDescriptor).then((availableWizards) => {
|
|
99
|
+
// // Check for wizard ID in URL
|
|
100
|
+
// const params = new URLSearchParams(window.location.search);
|
|
101
|
+
// const wizardName = params.get("wizard");
|
|
102
|
+
|
|
103
|
+
// if (wizardName) {
|
|
104
|
+
// // Find wizard by ID from the loaded wizards
|
|
105
|
+
// const foundWizard = availableWizards.find((w) => w.name === wizardName);
|
|
106
|
+
// if (foundWizard) {
|
|
107
|
+
// setWizard(foundWizard);
|
|
108
|
+
// setParentItem(editContext.currentItemDescriptor);
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
// });
|
|
112
|
+
// }, [searchParams]);
|
|
113
|
+
|
|
114
|
+
// const handleSelect = (selectedWizard: Wizard) => {
|
|
115
|
+
// setWizard(selectedWizard);
|
|
116
|
+
// // Update URL with wizard ID
|
|
117
|
+
// const url = new URL(window.location.href);
|
|
118
|
+
// url.searchParams.set("wizard", selectedWizard.name);
|
|
119
|
+
// window.history.pushState({}, "", url);
|
|
120
|
+
// };
|
|
121
|
+
|
|
122
|
+
// const handleCancel = () => {
|
|
123
|
+
// editContext?.pageWizard.setWizard(undefined);
|
|
124
|
+
// // Remove wizard from URL
|
|
125
|
+
// const url = new URL(window.location.href);
|
|
126
|
+
// url.searchParams.delete("wizard");
|
|
127
|
+
// window.history.pushState({}, "", url);
|
|
128
|
+
// editContext?.switchView("content-editor");
|
|
129
|
+
// };
|
|
130
|
+
|
|
131
|
+
if (!editContext?.currentItemDescriptor) return null;
|
|
132
|
+
|
|
133
|
+
if (!parentItem || !wizard) {
|
|
134
|
+
editContext.switchView("content-editor", { skipConfirmation: true });
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return <WizardSteps wizard={wizard} parentItem={parentItem} />;
|
|
139
|
+
}
|