@alpaca-editor/core 1.0.3939 → 1.0.3942
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/dist/components/ActionButton.d.ts +1 -0
- package/dist/components/ActionButton.js +2 -2
- package/dist/components/ActionButton.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.d.ts +1 -0
- package/dist/editor/FieldActionsOverlay.js +2 -11
- package/dist/editor/FieldActionsOverlay.js.map +1 -1
- package/dist/editor/PictureCropper.js +65 -23
- package/dist/editor/PictureCropper.js.map +1 -1
- package/dist/editor/PictureEditor.js +16 -2
- package/dist/editor/PictureEditor.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 +21 -2
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/commands/componentCommands.js +7 -3
- package/dist/editor/commands/componentCommands.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.d.ts +5 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js +77 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -0
- package/dist/editor/media-selector/MediaSelector.js +1 -1
- package/dist/editor/media-selector/MediaSelector.js.map +1 -1
- package/dist/editor/media-selector/Thumbnails.js +2 -2
- package/dist/editor/media-selector/index.d.ts +8 -0
- package/dist/editor/media-selector/index.js +9 -0
- package/dist/editor/media-selector/index.js.map +1 -0
- package/dist/editor/menubar/BrowseHistory.js +1 -1
- package/dist/editor/menubar/PageSelector.js +39 -15
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js +37 -11
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
- package/dist/editor/reviews/Comment.js +1 -1
- package/dist/editor/reviews/Comment.js.map +1 -1
- package/dist/editor/services/aiService.js +0 -1
- package/dist/editor/services/aiService.js.map +1 -1
- package/dist/editor/sidebar/ComponentTree.js +3 -4
- package/dist/editor/sidebar/ComponentTree.js.map +1 -1
- package/dist/editor/ui/SimpleTabs.d.ts +1 -0
- package/dist/editor/ui/SimpleTabs.js +3 -3
- package/dist/editor/ui/SimpleTabs.js.map +1 -1
- package/dist/editor/ui/Splitter.js +61 -6
- package/dist/editor/ui/Splitter.js.map +1 -1
- package/dist/editor/views/MediaFolderEditView.d.ts +4 -0
- package/dist/editor/views/MediaFolderEditView.js +40 -0
- package/dist/editor/views/MediaFolderEditView.js.map +1 -0
- package/dist/editor/views/SingleEditView.js +9 -1
- package/dist/editor/views/SingleEditView.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +61 -5
- package/package.json +8 -2
- package/.prettierrc +0 -3
- package/build.css +0 -3
- package/components.json +0 -21
- package/eslint.config.mjs +0 -4
- 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/src/client-components/api.ts +0 -6
- package/src/client-components/index.ts +0 -19
- package/src/components/ActionButton.tsx +0 -41
- package/src/components/Error.tsx +0 -57
- package/src/components/ui/CardConnector.tsx +0 -56
- package/src/components/ui/button.tsx +0 -62
- package/src/components/ui/card.tsx +0 -372
- package/src/components/ui/context-menu.tsx +0 -250
- package/src/config/config.tsx +0 -917
- package/src/config/types.ts +0 -286
- package/src/editor/ComponentInfo.tsx +0 -90
- package/src/editor/ConfirmationDialog.tsx +0 -103
- package/src/editor/ContentTree.tsx +0 -730
- package/src/editor/ContextMenu.tsx +0 -230
- package/src/editor/Editor.tsx +0 -90
- package/src/editor/EditorWarning.tsx +0 -34
- package/src/editor/EditorWarnings.tsx +0 -33
- package/src/editor/FieldActionsOverlay.tsx +0 -307
- package/src/editor/FieldEditorPopup.tsx +0 -65
- package/src/editor/FieldHistory.tsx +0 -75
- package/src/editor/FieldList.tsx +0 -190
- package/src/editor/FieldListField.tsx +0 -391
- package/src/editor/FieldListFieldWithFallbacks.tsx +0 -217
- package/src/editor/FloatingToolbar.tsx +0 -163
- package/src/editor/ImageEditor.tsx +0 -128
- package/src/editor/ItemInfo.tsx +0 -90
- package/src/editor/LinkEditorDialog.tsx +0 -196
- package/src/editor/MainLayout.tsx +0 -95
- package/src/editor/MobileLayout.tsx +0 -68
- package/src/editor/NewEditorClient.tsx +0 -11
- package/src/editor/PictureCropper.tsx +0 -503
- package/src/editor/PictureEditor.tsx +0 -277
- package/src/editor/PictureEditorDialog.tsx +0 -381
- package/src/editor/PublishDialog.ignore +0 -74
- package/src/editor/ScrollingContentTree.tsx +0 -67
- package/src/editor/Terminal.tsx +0 -227
- package/src/editor/Titlebar.tsx +0 -104
- package/src/editor/ai/AiPopup.tsx +0 -59
- package/src/editor/ai/AiResponseMessage.tsx +0 -106
- package/src/editor/ai/AiTerminal.tsx +0 -503
- package/src/editor/ai/AiToolCall.tsx +0 -61
- package/src/editor/ai/EditorAiTerminal.tsx +0 -20
- package/src/editor/ai/GhostWriter.tsx +0 -432
- package/src/editor/ai/aiPageModel.ts +0 -108
- package/src/editor/ai/editorAiContext.ts +0 -18
- package/src/editor/client/AboutDialog.tsx +0 -44
- package/src/editor/client/EditorClient.tsx +0 -2241
- package/src/editor/client/GenericDialog.tsx +0 -50
- package/src/editor/client/editContext.ts +0 -416
- package/src/editor/client/helpers.ts +0 -44
- package/src/editor/client/itemsRepository.ts +0 -574
- package/src/editor/client/operations.ts +0 -768
- package/src/editor/client/pageModelBuilder.ts +0 -219
- package/src/editor/commands/commands.ts +0 -22
- package/src/editor/commands/componentCommands.tsx +0 -424
- package/src/editor/commands/createVersionCommand.ts +0 -33
- package/src/editor/commands/deleteVersionCommand.ts +0 -71
- package/src/editor/commands/itemCommands.tsx +0 -351
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +0 -201
- package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +0 -27
- package/src/editor/commands/undo.ts +0 -39
- package/src/editor/component-designer/ComponentDesigner.tsx +0 -70
- package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +0 -11
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +0 -91
- package/src/editor/component-designer/ComponentEditor.tsx +0 -97
- package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +0 -31
- package/src/editor/component-designer/ComponentRenderingEditor.tsx +0 -104
- package/src/editor/component-designer/ComponentsDropdown.tsx +0 -39
- package/src/editor/component-designer/PlaceholdersEditor.tsx +0 -179
- package/src/editor/component-designer/RenderingsDropdown.tsx +0 -36
- package/src/editor/component-designer/TemplateEditor.tsx +0 -236
- package/src/editor/component-designer/aiContext.ts +0 -23
- package/src/editor/componentTreeHelper.tsx +0 -116
- package/src/editor/context-menu/CopyMoveMenu.tsx +0 -103
- package/src/editor/context-menu/InsertMenu.tsx +0 -347
- package/src/editor/control-center/About.tsx +0 -342
- package/src/editor/control-center/ControlCenterMenu.tsx +0 -76
- package/src/editor/control-center/IndexOverview.tsx +0 -50
- package/src/editor/control-center/IndexSettings.tsx +0 -266
- package/src/editor/control-center/Info.tsx +0 -104
- package/src/editor/control-center/QuotaInfo.tsx +0 -301
- package/src/editor/control-center/Status.tsx +0 -113
- package/src/editor/control-center/WebSocketMessages.tsx +0 -155
- package/src/editor/editor-warnings/ItemLocked.tsx +0 -63
- package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +0 -22
- package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +0 -23
- package/src/editor/editor-warnings/NoWriteAccess.tsx +0 -16
- package/src/editor/editor-warnings/ValidationErrors.tsx +0 -54
- package/src/editor/field-types/AttachmentEditor.tsx +0 -9
- package/src/editor/field-types/CheckboxEditor.tsx +0 -47
- package/src/editor/field-types/DropLinkEditor.tsx +0 -80
- package/src/editor/field-types/DropListEditor.tsx +0 -84
- package/src/editor/field-types/ImageFieldEditor.tsx +0 -65
- package/src/editor/field-types/InternalLinkFieldEditor.tsx +0 -117
- package/src/editor/field-types/LinkFieldEditor.tsx +0 -85
- package/src/editor/field-types/MultiLineText.tsx +0 -82
- package/src/editor/field-types/PictureFieldEditor.tsx +0 -121
- package/src/editor/field-types/RawEditor.tsx +0 -53
- package/src/editor/field-types/ReactQuill.tsx +0 -580
- package/src/editor/field-types/RichTextEditor.tsx +0 -22
- package/src/editor/field-types/RichTextEditorComponent.tsx +0 -127
- package/src/editor/field-types/SingleLineText.tsx +0 -174
- package/src/editor/field-types/TreeListEditor.tsx +0 -261
- package/src/editor/fieldTypes.ts +0 -140
- package/src/editor/media-selector/AiImageSearch.tsx +0 -185
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +0 -94
- package/src/editor/media-selector/MediaSelector.tsx +0 -42
- package/src/editor/media-selector/Preview.tsx +0 -14
- package/src/editor/media-selector/Thumbnails.tsx +0 -48
- package/src/editor/media-selector/TreeSelector.tsx +0 -292
- package/src/editor/media-selector/UploadZone.tsx +0 -137
- package/src/editor/menubar/ActionsMenu.tsx +0 -94
- package/src/editor/menubar/ActiveUsers.tsx +0 -17
- package/src/editor/menubar/ApproveAndPublish.tsx +0 -18
- package/src/editor/menubar/BrowseHistory.tsx +0 -28
- package/src/editor/menubar/ItemLanguageVersion.tsx +0 -76
- package/src/editor/menubar/LanguageSelector.tsx +0 -226
- package/src/editor/menubar/Menu.tsx +0 -83
- package/src/editor/menubar/NavButtons.tsx +0 -74
- package/src/editor/menubar/PageSelector.tsx +0 -166
- package/src/editor/menubar/PageViewerControls.tsx +0 -120
- package/src/editor/menubar/PreviewSecondaryControls.tsx +0 -18
- package/src/editor/menubar/SecondaryControls.tsx +0 -45
- package/src/editor/menubar/Separator.tsx +0 -12
- package/src/editor/menubar/SiteInfo.tsx +0 -53
- package/src/editor/menubar/User.tsx +0 -27
- package/src/editor/menubar/VersionSelector.tsx +0 -142
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +0 -307
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +0 -35
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +0 -59
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +0 -23
- package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +0 -64
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +0 -35
- package/src/editor/page-editor-chrome/FrameMenu.tsx +0 -338
- package/src/editor/page-editor-chrome/FrameMenus.tsx +0 -48
- package/src/editor/page-editor-chrome/InlineEditor.tsx +0 -765
- package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +0 -61
- package/src/editor/page-editor-chrome/NoLayout.tsx +0 -36
- package/src/editor/page-editor-chrome/PageEditorChrome.tsx +0 -122
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +0 -161
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +0 -169
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +0 -315
- package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +0 -300
- package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +0 -40
- package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +0 -791
- package/src/editor/page-viewer/DeviceToolbar.tsx +0 -70
- package/src/editor/page-viewer/EditorForm.tsx +0 -258
- package/src/editor/page-viewer/MiniMap.tsx +0 -362
- package/src/editor/page-viewer/PageViewer.tsx +0 -169
- package/src/editor/page-viewer/PageViewerFrame.tsx +0 -1022
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
- package/src/editor/page-viewer/pageViewContext.ts +0 -186
- package/src/editor/pageModel.ts +0 -220
- package/src/editor/picture-shared.tsx +0 -53
- package/src/editor/reviews/Comment.tsx +0 -307
- package/src/editor/reviews/Comments.tsx +0 -125
- package/src/editor/reviews/DiffView.tsx +0 -109
- package/src/editor/reviews/PreviewInfo.tsx +0 -35
- package/src/editor/reviews/Reviews.tsx +0 -280
- package/src/editor/reviews/SuggestedEdit.tsx +0 -316
- package/src/editor/reviews/reviewCommands.tsx +0 -47
- package/src/editor/reviews/useReviews.tsx +0 -70
- package/src/editor/services/aiService.ts +0 -174
- package/src/editor/services/componentDesignerService.ts +0 -151
- package/src/editor/services/contentService.ts +0 -180
- package/src/editor/services/editService.ts +0 -488
- package/src/editor/services/indexService.ts +0 -24
- package/src/editor/services/reviewsService.ts +0 -53
- package/src/editor/services/serviceHelper.ts +0 -95
- package/src/editor/services/suggestedEditsService.ts +0 -39
- package/src/editor/services/systemService.ts +0 -5
- package/src/editor/services/translationService.ts +0 -21
- package/src/editor/services-server/api.ts +0 -150
- package/src/editor/services-server/graphQL.ts +0 -106
- package/src/editor/sidebar/ComponentPalette.tsx +0 -161
- package/src/editor/sidebar/ComponentTree.tsx +0 -548
- package/src/editor/sidebar/ComponentTree2.tsxx +0 -490
- package/src/editor/sidebar/Debug.tsx +0 -111
- package/src/editor/sidebar/DictionaryEditor.tsx +0 -261
- package/src/editor/sidebar/EditHistory.tsx +0 -134
- package/src/editor/sidebar/GraphQL.tsx +0 -164
- package/src/editor/sidebar/Insert.tsx +0 -35
- package/src/editor/sidebar/MainContentTree.tsx +0 -102
- package/src/editor/sidebar/Performance.tsx +0 -53
- package/src/editor/sidebar/Sessions.tsx +0 -35
- package/src/editor/sidebar/Sidebar.tsx +0 -20
- package/src/editor/sidebar/SidebarView.tsx +0 -152
- package/src/editor/sidebar/Translations.tsx +0 -295
- package/src/editor/sidebar/Validation.tsx +0 -102
- package/src/editor/sidebar/ViewSelector.tsx +0 -60
- package/src/editor/sidebar/Workbox.tsx +0 -209
- package/src/editor/ui/CenteredMessage.tsx +0 -7
- package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +0 -81
- package/src/editor/ui/CopyToClipboardButton.tsx +0 -24
- package/src/editor/ui/DialogButtons.tsx +0 -11
- package/src/editor/ui/Icons.tsx +0 -709
- package/src/editor/ui/ItemList.tsx +0 -76
- package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
- package/src/editor/ui/ItemSearch.tsx +0 -153
- package/src/editor/ui/PerfectTree.tsx +0 -571
- package/src/editor/ui/Section.tsx +0 -35
- package/src/editor/ui/SimpleIconButton.tsx +0 -54
- package/src/editor/ui/SimpleMenu.tsx +0 -40
- package/src/editor/ui/SimpleTable.tsx +0 -60
- package/src/editor/ui/SimpleTabs.tsx +0 -55
- package/src/editor/ui/SimpleToolbar.tsx +0 -7
- package/src/editor/ui/Spinner.tsx +0 -9
- package/src/editor/ui/Splitter.tsx +0 -314
- package/src/editor/ui/StackedPanels.tsx +0 -134
- package/src/editor/ui/Toolbar.tsx +0 -7
- package/src/editor/utils/id-helper.ts +0 -3
- package/src/editor/utils/insertOptions.ts +0 -69
- package/src/editor/utils/itemutils.ts +0 -29
- package/src/editor/utils/useMemoDebug.ts +0 -28
- package/src/editor/utils.ts +0 -486
- package/src/editor/views/CompareView.tsx +0 -245
- package/src/editor/views/EditView.tsx +0 -27
- package/src/editor/views/ItemEditor.tsx +0 -58
- package/src/editor/views/SingleEditView.tsx +0 -46
- 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 +0 -10
- package/src/index.ts +0 -23
- package/src/lib/safelist.tsx +0 -16
- package/src/lib/utils.ts +0 -6
- package/src/page-wizard/PageWizard.tsx +0 -139
- package/src/page-wizard/WizardBox.tsx +0 -4
- package/src/page-wizard/WizardBoxConnector.tsx +0 -56
- package/src/page-wizard/WizardSteps.tsx +0 -458
- package/src/page-wizard/service.ts +0 -35
- package/src/page-wizard/startPageWizardCommand.ts +0 -26
- package/src/page-wizard/steps/BuildPageStep.tsx +0 -259
- package/src/page-wizard/steps/CollectStep.tsx +0 -296
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +0 -454
- package/src/page-wizard/steps/Components.tsx +0 -193
- package/src/page-wizard/steps/ContentStep.tsx +0 -890
- package/src/page-wizard/steps/EditButton.tsx +0 -34
- package/src/page-wizard/steps/FieldEditor.tsx +0 -102
- package/src/page-wizard/steps/Generate.tsx +0 -60
- package/src/page-wizard/steps/ImagesStep.tsx +0 -382
- package/src/page-wizard/steps/LayoutStep.tsx +0 -227
- package/src/page-wizard/steps/MetaDataStep.tsx +0 -173
- package/src/page-wizard/steps/SelectStep.tsx +0 -281
- package/src/page-wizard/steps/schema.ts +0 -180
- package/src/page-wizard/steps/usePageCreator.ts +0 -325
- package/src/page-wizard/usePageWizard.ts +0 -79
- package/src/revision.ts +0 -2
- package/src/splash-screen/NewPage.tsx +0 -294
- package/src/splash-screen/OpenPage.tsx +0 -113
- package/src/splash-screen/RecentPages.tsx +0 -123
- package/src/splash-screen/SectionHeadline.tsx +0 -21
- package/src/splash-screen/SplashScreen.tsx +0 -195
- package/src/tour/Tour.tsx +0 -566
- package/src/tour/default-tour.tsx +0 -301
- package/src/tour/preview-tour.tsx +0 -128
- package/src/types.ts +0 -335
- package/styles.css +0 -765
- package/tsconfig.build.json +0 -31
- package/tsconfig.json +0 -14
|
@@ -1,163 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
}
|
package/src/editor/ItemInfo.tsx
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,196 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
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
|
-
}
|