@alpaca-editor/core 1.0.3942 → 1.0.3944
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,163 @@
|
|
|
1
|
+
import { ReactNode, useCallback, useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export default function FloatingToolbar({
|
|
4
|
+
children,
|
|
5
|
+
onPin,
|
|
6
|
+
height,
|
|
7
|
+
width,
|
|
8
|
+
}: {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
onPin?: () => void;
|
|
11
|
+
height?: number;
|
|
12
|
+
width?: number;
|
|
13
|
+
}) {
|
|
14
|
+
const [position, setPosition] = useState({ x: 0, y: 95 });
|
|
15
|
+
const [size, setSize] = useState({ width: 400, height: 70 });
|
|
16
|
+
const [dragging, setDragging] = useState(false);
|
|
17
|
+
const [resizing, setResizing] = useState(false);
|
|
18
|
+
const [offset, setOffset] = useState({ x: 0, y: 0 });
|
|
19
|
+
const [hidden, setHidden] = useState(false);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
console.log("WIDTH: ", width, "Height: ", height);
|
|
23
|
+
setSize({ width: width || 400, height: height || 70 });
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
const handleMouseDown = useCallback(
|
|
27
|
+
(e: any) => {
|
|
28
|
+
// Start dragging and calculate the offset from the mouse to the sidebar top-left corner
|
|
29
|
+
setDragging(true);
|
|
30
|
+
setOffset({
|
|
31
|
+
x: e.clientX - position.x,
|
|
32
|
+
y: e.clientY - position.y,
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
[position]
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const handleMouseMove = useCallback(
|
|
39
|
+
(e: any) => {
|
|
40
|
+
if (dragging) {
|
|
41
|
+
// Update the position state based on mouse movement, adjusted by the initial offset
|
|
42
|
+
setPosition({
|
|
43
|
+
x: e.clientX - offset.x,
|
|
44
|
+
y: e.clientY - offset.y,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
[dragging, offset]
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const handleMouseUp = useCallback(() => {
|
|
52
|
+
// Stop dragging
|
|
53
|
+
setDragging(false);
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
const handleResizeMouseDown = useCallback((e: any) => {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
setResizing(true);
|
|
59
|
+
setOffset({
|
|
60
|
+
x: e.clientX,
|
|
61
|
+
y: e.clientY,
|
|
62
|
+
});
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
const handleResizeMouseMove = useCallback(
|
|
66
|
+
(e: any) => {
|
|
67
|
+
if (resizing) {
|
|
68
|
+
const newWidth = size.width + (e.clientX - offset.x);
|
|
69
|
+
const newHeight = size.height + (e.clientY - offset.y);
|
|
70
|
+
setSize({
|
|
71
|
+
width: newWidth > 200 ? newWidth : 200, // Minimum width
|
|
72
|
+
height: newHeight > 100 ? newHeight : 100, // Minimum height
|
|
73
|
+
});
|
|
74
|
+
setOffset({
|
|
75
|
+
x: e.clientX,
|
|
76
|
+
y: e.clientY,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[resizing, offset, size]
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const handleResizeMouseUp = useCallback(() => {
|
|
84
|
+
setResizing(false);
|
|
85
|
+
}, []);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (resizing) {
|
|
89
|
+
document.addEventListener("mousemove", handleResizeMouseMove);
|
|
90
|
+
document.addEventListener("mouseup", handleResizeMouseUp);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return () => {
|
|
94
|
+
document.removeEventListener("mousemove", handleResizeMouseMove);
|
|
95
|
+
document.removeEventListener("mouseup", handleResizeMouseUp);
|
|
96
|
+
};
|
|
97
|
+
}, [resizing, handleResizeMouseMove, handleResizeMouseUp]);
|
|
98
|
+
|
|
99
|
+
// Add event listeners to the document when the sidebar is being dragged
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (dragging) {
|
|
102
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
103
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Cleanup the document event listeners when the component unmounts or dragging stops
|
|
107
|
+
return () => {
|
|
108
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
109
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
110
|
+
};
|
|
111
|
+
}, [dragging, handleMouseMove, handleMouseUp]);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div
|
|
115
|
+
className="border border-gray-200 drop-shadow z-10 flex flex-col"
|
|
116
|
+
onMouseMove={handleMouseMove}
|
|
117
|
+
onMouseUp={handleMouseUp}
|
|
118
|
+
style={{
|
|
119
|
+
left: `${position.x}px`,
|
|
120
|
+
top: `${position.y}px`,
|
|
121
|
+
position: "absolute", // Use 'fixed' or 'absolute' depending on your layout needs
|
|
122
|
+
height: `${hidden ? 30 : size.height}px`,
|
|
123
|
+
width: `${size.width}px`,
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
<div
|
|
127
|
+
className="bg-gray-100 w-full flex justify-between items-between p-2 text-sm"
|
|
128
|
+
style={{ cursor: "move", userSelect: "none" }}
|
|
129
|
+
onMouseDown={handleMouseDown}
|
|
130
|
+
>
|
|
131
|
+
Toolbar
|
|
132
|
+
<div className="flex gap-2">
|
|
133
|
+
{hidden && (
|
|
134
|
+
<div
|
|
135
|
+
className="border-2 border-gray-800 w-4 h-4 cusor-pointer"
|
|
136
|
+
onClick={() => setHidden(false)}
|
|
137
|
+
></div>
|
|
138
|
+
)}
|
|
139
|
+
{!hidden && (
|
|
140
|
+
<div
|
|
141
|
+
className="border-b-2 border-gray-800 w-4 h-4 cusor-pointer"
|
|
142
|
+
onClick={() => setHidden(true)}
|
|
143
|
+
></div>
|
|
144
|
+
)}
|
|
145
|
+
{onPin && (
|
|
146
|
+
<i
|
|
147
|
+
className="pi pi-arrow-down-left cursor-pointer"
|
|
148
|
+
onClick={onPin}
|
|
149
|
+
></i>
|
|
150
|
+
)}
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
<div className="flex-1">{!hidden && children}</div>
|
|
154
|
+
<div className="h-4 bg-gray-100"></div>
|
|
155
|
+
<div
|
|
156
|
+
className="cursor-nwse-resize w-4 h-4 absolute -bottom-1 -right-2 text-gray-500"
|
|
157
|
+
onMouseDown={handleResizeMouseDown}
|
|
158
|
+
>
|
|
159
|
+
<i className="pi pi-sort-down -rotate-45 w-4 h-4" />
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { MouseEventHandler, useCallback, useState } from "react";
|
|
2
|
+
import { useEditContext } from "./client/editContext";
|
|
3
|
+
import { ImageField } from "./fieldTypes";
|
|
4
|
+
//import { useDialog } from "./client/DialogContext";
|
|
5
|
+
import { ClientFieldButton } from "../config/types";
|
|
6
|
+
|
|
7
|
+
export function ImageEditor({
|
|
8
|
+
field,
|
|
9
|
+
style,
|
|
10
|
+
}: {
|
|
11
|
+
field: ImageField;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
}) {
|
|
14
|
+
const [showMenu, setShowMenu] = useState(true);
|
|
15
|
+
const editContext = useEditContext();
|
|
16
|
+
//const dialogContext = useDialog();
|
|
17
|
+
|
|
18
|
+
if (!field || !editContext) return null;
|
|
19
|
+
|
|
20
|
+
const imageSelected = useCallback(
|
|
21
|
+
async (imageId: string) => {
|
|
22
|
+
editContext.operations.editField({
|
|
23
|
+
field: field.descriptor,
|
|
24
|
+
rawValue: '<image mediaid="{' + imageId + '}" />',
|
|
25
|
+
refresh: "immediate",
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
[field],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
async function selectMedia() {
|
|
32
|
+
const selectedImageId = await editContext?.selectMedia({
|
|
33
|
+
selectedIdPath: field.value?.src || "",
|
|
34
|
+
mode: "images",
|
|
35
|
+
});
|
|
36
|
+
if (selectedImageId) imageSelected(selectedImageId);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const getImageSrc = () => {
|
|
40
|
+
if (!field.value) {
|
|
41
|
+
if (!field.rawValue) return null;
|
|
42
|
+
|
|
43
|
+
const parser = new DOMParser();
|
|
44
|
+
const xmlDoc = parser.parseFromString(field.rawValue, "text/xml");
|
|
45
|
+
const imageElement = xmlDoc.documentElement;
|
|
46
|
+
return imageElement.getAttribute("src");
|
|
47
|
+
}
|
|
48
|
+
return field.value.src;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const getImageAlt = () => {
|
|
52
|
+
if (!field.value) return "";
|
|
53
|
+
|
|
54
|
+
// Standard image
|
|
55
|
+
return field.value.alt;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
<div
|
|
61
|
+
className="absolute inset-0 flex items-center justify-center"
|
|
62
|
+
onMouseEnter={() => setShowMenu(true)}
|
|
63
|
+
onMouseLeave={() => setShowMenu(false)}
|
|
64
|
+
style={style}
|
|
65
|
+
data-testid="select-media"
|
|
66
|
+
>
|
|
67
|
+
{getImageSrc() && (
|
|
68
|
+
<img
|
|
69
|
+
src={getImageSrc()!}
|
|
70
|
+
alt={getImageAlt()}
|
|
71
|
+
className="max-h-full max-w-full object-contain"
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
{showMenu && (
|
|
75
|
+
<div className="absolute inset-0 grid grid-cols-1 items-center justify-center gap-1.5 bg-black/50 p-3 text-sm">
|
|
76
|
+
<Btn
|
|
77
|
+
label={getImageSrc() ? "Change Image" : "Select Image"}
|
|
78
|
+
icon="pi pi-image"
|
|
79
|
+
onClick={() => selectMedia()}
|
|
80
|
+
testId="select-media-button"
|
|
81
|
+
className="min-w-[80px]"
|
|
82
|
+
/>
|
|
83
|
+
{editContext?.configuration?.fieldTypes["image"]?.buttons?.map(
|
|
84
|
+
(button: ClientFieldButton) => (
|
|
85
|
+
<Btn
|
|
86
|
+
key={button.id}
|
|
87
|
+
label={button.label}
|
|
88
|
+
icon={button.icon}
|
|
89
|
+
onClick={() =>
|
|
90
|
+
button?.clientAction?.({
|
|
91
|
+
field,
|
|
92
|
+
editContext,
|
|
93
|
+
//dialogContext,
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
),
|
|
98
|
+
)}
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
</>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function Btn({
|
|
107
|
+
label,
|
|
108
|
+
icon,
|
|
109
|
+
onClick,
|
|
110
|
+
testId,
|
|
111
|
+
className,
|
|
112
|
+
}: {
|
|
113
|
+
label: string;
|
|
114
|
+
icon?: string;
|
|
115
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
116
|
+
testId?: string;
|
|
117
|
+
className?: string;
|
|
118
|
+
}) {
|
|
119
|
+
return (
|
|
120
|
+
<button
|
|
121
|
+
className={`btn flex items-center gap-1.5 rounded-lg border border-gray-200 bg-gray-500 p-1.5 text-white opacity-70 hover:opacity-85 ${className}`}
|
|
122
|
+
onClick={onClick}
|
|
123
|
+
data-testid={testId}
|
|
124
|
+
>
|
|
125
|
+
<i className={icon} /> {label}
|
|
126
|
+
</button>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEditContext } from "./client/editContext";
|
|
4
|
+
import { FullItem } from "./pageModel";
|
|
5
|
+
import { CopyToClipboardButton } from "./ui/CopyToClipboardButton";
|
|
6
|
+
import { Section } from "./ui/Section";
|
|
7
|
+
|
|
8
|
+
export function ItemInfo({ item }: { item: FullItem | null }) {
|
|
9
|
+
if (!item?.fields) return;
|
|
10
|
+
const editContext = useEditContext();
|
|
11
|
+
|
|
12
|
+
function formatRow(label: string, value: string) {
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<div className="font-bold">{label}</div>
|
|
16
|
+
<div>{value}</div>
|
|
17
|
+
</>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
<div className="my-2 flex items-center px-3 py-2">
|
|
24
|
+
<img
|
|
25
|
+
src={item.largeIcon}
|
|
26
|
+
alt="Icon"
|
|
27
|
+
className="mr-2"
|
|
28
|
+
style={{ height: "32px", width: "32px" }}
|
|
29
|
+
/>
|
|
30
|
+
<h2 className="text-l font-bold">
|
|
31
|
+
{item.name}
|
|
32
|
+
<button
|
|
33
|
+
className="ml-2"
|
|
34
|
+
onClick={() => {
|
|
35
|
+
editContext?.executeCommand({
|
|
36
|
+
command: editContext.configuration.commands.renameItem,
|
|
37
|
+
data: { items: [item] },
|
|
38
|
+
});
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<i className="pi pi-pencil" />
|
|
42
|
+
</button>
|
|
43
|
+
</h2>
|
|
44
|
+
</div>
|
|
45
|
+
<Section title="Info">
|
|
46
|
+
<div className="grid grid-cols-[min-content_1fr] gap-3 text-xs">
|
|
47
|
+
<div className="font-bold">ID:</div>
|
|
48
|
+
<div className="flex items-center gap-1">
|
|
49
|
+
{item.id} <CopyToClipboardButton text={item.id} />
|
|
50
|
+
</div>
|
|
51
|
+
<div className="font-bold">Path:</div>
|
|
52
|
+
<div className="flex items-center gap-1">
|
|
53
|
+
{item.path} <CopyToClipboardButton text={item.path} />
|
|
54
|
+
</div>
|
|
55
|
+
<div className="font-bold">Language:</div>
|
|
56
|
+
<div>{item.language}</div>
|
|
57
|
+
<div className="font-bold">Version:</div>
|
|
58
|
+
<div>{item.versions > 0 ? item.version : "No versions"}</div>
|
|
59
|
+
<div className="font-bold">Template:</div>
|
|
60
|
+
<div className="flex items-center gap-1">
|
|
61
|
+
<span
|
|
62
|
+
className="cursor-pointer hover:underline"
|
|
63
|
+
onClick={() => {
|
|
64
|
+
editContext?.loadItem({
|
|
65
|
+
id: item.templateId,
|
|
66
|
+
language: "en",
|
|
67
|
+
version: 0,
|
|
68
|
+
});
|
|
69
|
+
editContext?.switchView("content-editor");
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
{" "}
|
|
73
|
+
{item.templateName} ({item.templateId}{" "}
|
|
74
|
+
</span>
|
|
75
|
+
<CopyToClipboardButton text={item.templateId} />)
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
{item.masterLanguages &&
|
|
79
|
+
formatRow("Master languages", item.masterLanguages.join(", "))}
|
|
80
|
+
{item.translations && (
|
|
81
|
+
<>
|
|
82
|
+
<div className="font-bold">Languages</div>
|
|
83
|
+
<div>{item.translations?.join(", ")}</div>
|
|
84
|
+
</>
|
|
85
|
+
)}
|
|
86
|
+
</div>
|
|
87
|
+
</Section>
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Dialog } from "primereact/dialog";
|
|
2
|
+
|
|
3
|
+
import { InputText } from "primereact/inputtext";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { Dropdown } from "primereact/dropdown";
|
|
6
|
+
import { Divider } from "primereact/divider";
|
|
7
|
+
import { Button } from "primereact/button";
|
|
8
|
+
|
|
9
|
+
import { Splitter, SplitterPanel } from "primereact/splitter";
|
|
10
|
+
import ItemSearch, { ResultItem } from "./ui/ItemSearch";
|
|
11
|
+
import { SimpleTabs } from "./ui/SimpleTabs";
|
|
12
|
+
import { ScrollingContentTree } from "./ScrollingContentTree";
|
|
13
|
+
import { useEditContext } from "./client/editContext";
|
|
14
|
+
|
|
15
|
+
export type Link = {
|
|
16
|
+
url?: string;
|
|
17
|
+
itemId?: string;
|
|
18
|
+
queryString?: string;
|
|
19
|
+
target?: string;
|
|
20
|
+
customTarget?: string;
|
|
21
|
+
type: string;
|
|
22
|
+
targetItemLongId?: string;
|
|
23
|
+
targetItemName?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function LinkEditorDialog({
|
|
27
|
+
linkValue,
|
|
28
|
+
onCancel,
|
|
29
|
+
onOk,
|
|
30
|
+
}: {
|
|
31
|
+
linkValue: Link;
|
|
32
|
+
onOk: (link: Link) => void;
|
|
33
|
+
onCancel: () => void;
|
|
34
|
+
}) {
|
|
35
|
+
const [url, setUrl] = useState<string>();
|
|
36
|
+
const [targetWindow, setTargetWindow] = useState<string>();
|
|
37
|
+
const [customTarget, setCustomTarget] = useState<string>();
|
|
38
|
+
const [queryString, setQueryString] = useState<string>();
|
|
39
|
+
const [activeTabIndex, setActiveTabIndex] = useState<number>(0);
|
|
40
|
+
const [selectedItemId, setSelectedItemId] = useState<string>("");
|
|
41
|
+
const [hoveredItemId, setHoveredItemId] = useState<string>();
|
|
42
|
+
const editContext = useEditContext();
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
setUrl(linkValue.url);
|
|
46
|
+
setTargetWindow(linkValue.target);
|
|
47
|
+
|
|
48
|
+
if (linkValue.type == "external") setActiveTabIndex(1);
|
|
49
|
+
else setActiveTabIndex(0);
|
|
50
|
+
|
|
51
|
+
if (linkValue.target && linkValue.target != "_blank") {
|
|
52
|
+
setTargetWindow("custom");
|
|
53
|
+
setCustomTarget(linkValue.target);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (linkValue.itemId) setSelectedItemId(linkValue.itemId);
|
|
57
|
+
if (linkValue.queryString) setQueryString(linkValue.queryString);
|
|
58
|
+
}, [linkValue]);
|
|
59
|
+
|
|
60
|
+
const targetWindows = [
|
|
61
|
+
{ name: "Active browser", code: "" },
|
|
62
|
+
{ name: "New browser", code: "_blank" },
|
|
63
|
+
{ name: "Custom", code: "custom" },
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
function getTargetWindow() {
|
|
67
|
+
if (targetWindow == "custom") return customTarget;
|
|
68
|
+
return targetWindow;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!editContext) return null;
|
|
72
|
+
|
|
73
|
+
const tabs = [
|
|
74
|
+
{
|
|
75
|
+
id: "internal",
|
|
76
|
+
label: "Internal",
|
|
77
|
+
content: (
|
|
78
|
+
<Splitter className="mt-4 flex-1">
|
|
79
|
+
<SplitterPanel className="relative h-full">
|
|
80
|
+
<div className="absolute inset-0 overflow-auto">
|
|
81
|
+
<ScrollingContentTree
|
|
82
|
+
selectedItemId={hoveredItemId || selectedItemId}
|
|
83
|
+
onSelectionChange={(selection) => {
|
|
84
|
+
setSelectedItemId(selection[0]?.id || "");
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
</SplitterPanel>
|
|
89
|
+
<SplitterPanel>
|
|
90
|
+
<div className="relative ml-2 h-full w-full">
|
|
91
|
+
<div className="absolute inset-0 overflow-auto">
|
|
92
|
+
<ItemSearch
|
|
93
|
+
itemSelected={(item) => {
|
|
94
|
+
setSelectedItemId(item.id);
|
|
95
|
+
}}
|
|
96
|
+
setHoveredItem={(item) =>
|
|
97
|
+
((item?: ResultItem) => {
|
|
98
|
+
if (!item) return;
|
|
99
|
+
setHoveredItemId(item.id);
|
|
100
|
+
})(item as ResultItem)
|
|
101
|
+
}
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</SplitterPanel>
|
|
106
|
+
</Splitter>
|
|
107
|
+
),
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: "external",
|
|
111
|
+
label: "External",
|
|
112
|
+
content: (
|
|
113
|
+
<div className="flex-1">
|
|
114
|
+
{" "}
|
|
115
|
+
<label className="mt-4 block text-sm">Url:</label>
|
|
116
|
+
<InputText
|
|
117
|
+
value={url || ""}
|
|
118
|
+
onChange={(e) => {
|
|
119
|
+
setUrl(e.target.value);
|
|
120
|
+
}}
|
|
121
|
+
className="w-full text-sm"
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
),
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<Dialog
|
|
130
|
+
style={{ width: "60%", height: "70%" }}
|
|
131
|
+
onHide={onCancel}
|
|
132
|
+
header={"Select link target"}
|
|
133
|
+
visible={true}
|
|
134
|
+
onShow={() => {
|
|
135
|
+
// Trigger a resize event to recalculate TabView layout
|
|
136
|
+
window.dispatchEvent(new Event("resize"));
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<div className="flex h-full flex-col p-4">
|
|
140
|
+
{linkValue && (
|
|
141
|
+
<SimpleTabs
|
|
142
|
+
tabs={tabs}
|
|
143
|
+
activeTab={activeTabIndex}
|
|
144
|
+
setActiveTab={setActiveTabIndex}
|
|
145
|
+
/>
|
|
146
|
+
)}
|
|
147
|
+
<Divider />
|
|
148
|
+
<label className="text-xs">QueryString</label>
|
|
149
|
+
<InputText
|
|
150
|
+
value={queryString}
|
|
151
|
+
onChange={(e) => setQueryString(e.target.value)}
|
|
152
|
+
className="text-sm"
|
|
153
|
+
/>
|
|
154
|
+
<label className="mt-4 text-xs">Window</label>
|
|
155
|
+
<Dropdown
|
|
156
|
+
options={targetWindows}
|
|
157
|
+
optionLabel="name"
|
|
158
|
+
optionValue="code"
|
|
159
|
+
value={targetWindow}
|
|
160
|
+
onChange={(e) => setTargetWindow(e.value)}
|
|
161
|
+
className="text-sm"
|
|
162
|
+
></Dropdown>
|
|
163
|
+
{targetWindow === "custom" && (
|
|
164
|
+
<div className="m-2">
|
|
165
|
+
<label className="block text-xs">Custom:</label>
|
|
166
|
+
<InputText
|
|
167
|
+
value={customTarget || ""}
|
|
168
|
+
onChange={(e) => {
|
|
169
|
+
setCustomTarget(e.target.value);
|
|
170
|
+
}}
|
|
171
|
+
className="text-sm"
|
|
172
|
+
/>
|
|
173
|
+
</div>
|
|
174
|
+
)}
|
|
175
|
+
<Divider />
|
|
176
|
+
<div className="flex justify-end gap-3">
|
|
177
|
+
<Button
|
|
178
|
+
onClick={() => {
|
|
179
|
+
onOk({
|
|
180
|
+
url,
|
|
181
|
+
target: getTargetWindow(),
|
|
182
|
+
customTarget: customTarget,
|
|
183
|
+
itemId: selectedItemId,
|
|
184
|
+
queryString: queryString,
|
|
185
|
+
type: activeTabIndex === 1 ? "external" : "internal",
|
|
186
|
+
});
|
|
187
|
+
}}
|
|
188
|
+
>
|
|
189
|
+
Select
|
|
190
|
+
</Button>
|
|
191
|
+
<Button onClick={onCancel}>Cancel</Button>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
</Dialog>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { EditorView } from "../config/types";
|
|
3
|
+
import { classNames } from "primereact/utils";
|
|
4
|
+
import { useEditContext } from "./client/editContext";
|
|
5
|
+
import { SidebarView } from "./sidebar/SidebarView";
|
|
6
|
+
import { Splitter, SplitterPanel } from "./ui/Splitter";
|
|
7
|
+
import { ViewSelector } from "./sidebar/ViewSelector";
|
|
8
|
+
import { Layers } from "lucide-react";
|
|
9
|
+
import { MobileLayout } from "./MobileLayout";
|
|
10
|
+
|
|
11
|
+
export type MainLayoutProps = {
|
|
12
|
+
rightSidebar?: ReactNode;
|
|
13
|
+
rightSidebarTitle?: string;
|
|
14
|
+
view: EditorView;
|
|
15
|
+
centerPanelView: ReactNode;
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default function MainLayout(props: MainLayoutProps) {
|
|
20
|
+
const panels: SplitterPanel[] = [];
|
|
21
|
+
const editContext = useEditContext();
|
|
22
|
+
|
|
23
|
+
if (!editContext) return null;
|
|
24
|
+
|
|
25
|
+
if (editContext.isMobile) {
|
|
26
|
+
return <MobileLayout {...props} />;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Keep all left sidebars mounted to preserve their state when switching views
|
|
30
|
+
const viewsWithLeftSidebar = editContext.configuration.editor.views.filter(
|
|
31
|
+
(v) => v.leftSidebar,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
if (viewsWithLeftSidebar.length > 0) {
|
|
35
|
+
panels.push({
|
|
36
|
+
name: "leftSidebar",
|
|
37
|
+
defaultSize: props.view.leftSidebar ? 350 : 0,
|
|
38
|
+
hidden: !props.view.leftSidebar,
|
|
39
|
+
content: (
|
|
40
|
+
<div className="relative h-full w-full" style={{ wordBreak: "normal" }}>
|
|
41
|
+
{viewsWithLeftSidebar.map((v) => (
|
|
42
|
+
<SidebarView
|
|
43
|
+
key={v.name}
|
|
44
|
+
sidebar={v.leftSidebar!}
|
|
45
|
+
editContext={editContext}
|
|
46
|
+
active={props.view.name === v.name && !!v.leftSidebar}
|
|
47
|
+
/>
|
|
48
|
+
))}
|
|
49
|
+
</div>
|
|
50
|
+
),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
panels.push({
|
|
54
|
+
name: "center",
|
|
55
|
+
defaultSize: "auto",
|
|
56
|
+
content: props.centerPanelView,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (props.rightSidebar) {
|
|
60
|
+
panels.push({
|
|
61
|
+
name: "rightSidebar",
|
|
62
|
+
defaultSize: 250,
|
|
63
|
+
content: props.rightSidebar,
|
|
64
|
+
collapsible: true,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let className = props.className;
|
|
69
|
+
|
|
70
|
+
if (!editContext?.configuration.editor.embedded) {
|
|
71
|
+
className = classNames("fixed inset-0", props.className);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div className={classNames("flex flex-col select-none", className)}>
|
|
76
|
+
{editContext?.configuration.editor.titlebar}
|
|
77
|
+
<div className="flex flex-1">
|
|
78
|
+
{!props.view.hideViewSelector && <ViewSelector />}
|
|
79
|
+
<div className="flex-1">
|
|
80
|
+
<Splitter
|
|
81
|
+
localStorageKey="editor.panelSizes"
|
|
82
|
+
expandLabel={
|
|
83
|
+
<div className="flex items-center justify-center">
|
|
84
|
+
<Layers size={14} />
|
|
85
|
+
<div className="mt-3">{props.rightSidebarTitle} </div>
|
|
86
|
+
</div>
|
|
87
|
+
}
|
|
88
|
+
panels={panels}
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
{/* sidebars already rendered above; no hidden cache needed */}
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|