@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,70 @@
|
|
|
1
|
+
import { ComponentRenderingEditor } from "./ComponentRenderingEditor";
|
|
2
|
+
import { Splitter, SplitterPanel } from "primereact/splitter";
|
|
3
|
+
import { StackedPanels } from "../ui/StackedPanels";
|
|
4
|
+
import { Panel } from "../../config/types";
|
|
5
|
+
|
|
6
|
+
import { PlaceholdersEditor } from "./PlaceholdersEditor";
|
|
7
|
+
import { PuzzleIcon } from "../ui/Icons";
|
|
8
|
+
import { ComponentEditor } from "./ComponentEditor";
|
|
9
|
+
import { useEffect, useState } from "react";
|
|
10
|
+
import { useEditContext } from "../client/editContext";
|
|
11
|
+
import {
|
|
12
|
+
Component,
|
|
13
|
+
getAllComponents,
|
|
14
|
+
} from "../services/componentDesignerService";
|
|
15
|
+
import { PageViewerFrame } from "../page-viewer/PageViewerFrame";
|
|
16
|
+
|
|
17
|
+
export function ComponentDesigner() {
|
|
18
|
+
const [allComponents, setAllComponents] = useState<Component[]>([]);
|
|
19
|
+
const context = useEditContext();
|
|
20
|
+
if (!context?.page) return null;
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
async function loadComponents() {
|
|
24
|
+
if (context?.page) {
|
|
25
|
+
const components = await getAllComponents(context.page.item.id);
|
|
26
|
+
setAllComponents(components);
|
|
27
|
+
} else setAllComponents([]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
loadComponents();
|
|
31
|
+
}, [context.page]);
|
|
32
|
+
|
|
33
|
+
const mainPanels: Panel[] = [
|
|
34
|
+
{
|
|
35
|
+
name: "template",
|
|
36
|
+
title: "Component",
|
|
37
|
+
initialSize: 30,
|
|
38
|
+
icon: <PuzzleIcon />,
|
|
39
|
+
noOverflow: true,
|
|
40
|
+
content: <ComponentEditor allComponents={allComponents} />,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "placeholders",
|
|
44
|
+
title: "Placeholders",
|
|
45
|
+
icon: "pi pi-th-large",
|
|
46
|
+
initialSize: 30,
|
|
47
|
+
noOverflow: true,
|
|
48
|
+
content: <PlaceholdersEditor allComponents={allComponents} />,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "rendering",
|
|
52
|
+
title: "Rendering",
|
|
53
|
+
icon: "pi pi-palette",
|
|
54
|
+
initialSize: 40,
|
|
55
|
+
content: <ComponentRenderingEditor />,
|
|
56
|
+
noOverflow: true,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Splitter className="h-full">
|
|
62
|
+
<SplitterPanel>
|
|
63
|
+
<StackedPanels panels={mainPanels} />
|
|
64
|
+
</SplitterPanel>
|
|
65
|
+
<SplitterPanel>
|
|
66
|
+
<PageViewerFrame compareView={false} />
|
|
67
|
+
</SplitterPanel>
|
|
68
|
+
</Splitter>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AiTerminal } from "../ai/AiTerminal";
|
|
2
|
+
import { createDesignerAiContext } from "./aiContext";
|
|
3
|
+
|
|
4
|
+
export function ComponentDesignerAiTerminal() {
|
|
5
|
+
return (
|
|
6
|
+
<AiTerminal
|
|
7
|
+
createAiContext={createDesignerAiContext}
|
|
8
|
+
defaultProfile="Component Designer"
|
|
9
|
+
/>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Menubar } from "primereact/menubar";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createNewComponent,
|
|
5
|
+
createRendering,
|
|
6
|
+
loadComponentDetails,
|
|
7
|
+
} from "../services/componentDesignerService";
|
|
8
|
+
import { ItemNameDialog } from "../ui/ItemNameDialogNew";
|
|
9
|
+
import { useRef } from "react";
|
|
10
|
+
import { useEditContext } from "../client/editContext";
|
|
11
|
+
import { ItemLanguageVersion } from "../menubar/ItemLanguageVersion";
|
|
12
|
+
|
|
13
|
+
export function ComponentDesignerMenu() {
|
|
14
|
+
const context = useEditContext();
|
|
15
|
+
if (!context) return;
|
|
16
|
+
|
|
17
|
+
// const menuItems = [
|
|
18
|
+
// {
|
|
19
|
+
// id: "newComponent",
|
|
20
|
+
// label: "New Component",
|
|
21
|
+
// icon: "pi pi-fw pi-plus",
|
|
22
|
+
// command: () => createNew(),
|
|
23
|
+
// // disabled: !context.componentRenderingFolder,
|
|
24
|
+
// },
|
|
25
|
+
// {
|
|
26
|
+
// id: "newRendering",
|
|
27
|
+
// label: "New Rendering",
|
|
28
|
+
// icon: "pi pi-fw pi-palette",
|
|
29
|
+
// command: () => createNewRendering(),
|
|
30
|
+
// disabled: !context.componentDesignerComponent,
|
|
31
|
+
// },
|
|
32
|
+
// {
|
|
33
|
+
// id: "delete",
|
|
34
|
+
// label: "Delete rendering",
|
|
35
|
+
// icon: "pi pi-fw pi-trash",
|
|
36
|
+
// disabled: !context.componentDesignerRendering,
|
|
37
|
+
// },
|
|
38
|
+
// ];
|
|
39
|
+
// const itemNameDialogRef = useRef<ItemNameDialogHandle>(null);
|
|
40
|
+
|
|
41
|
+
// const createNew = async () => {
|
|
42
|
+
// itemNameDialogRef.current?.show({
|
|
43
|
+
// title: "Choose Component Name",
|
|
44
|
+
// accept: async (name) => {
|
|
45
|
+
// await createNewComponent(name, context.page!.item);
|
|
46
|
+
// },
|
|
47
|
+
// });
|
|
48
|
+
// };
|
|
49
|
+
|
|
50
|
+
// const createNewRendering = async () => {
|
|
51
|
+
// itemNameDialogRef.current?.show({
|
|
52
|
+
// title: "Choose Rendering Name",
|
|
53
|
+
// accept: async (name) => {
|
|
54
|
+
// if (!context.componentDesignerComponent) return;
|
|
55
|
+
// const details = await createRendering(
|
|
56
|
+
// name,
|
|
57
|
+
// context.page!.item,
|
|
58
|
+
// context.componentDesignerComponent.templateId
|
|
59
|
+
// );
|
|
60
|
+
// if (!("id" in details)) return;
|
|
61
|
+
|
|
62
|
+
// const component = await loadComponentDetails(
|
|
63
|
+
// context.componentDesignerComponent.templateId,
|
|
64
|
+
// context!.page!.item.id
|
|
65
|
+
// );
|
|
66
|
+
// // const rendering = await getItem({
|
|
67
|
+
// // id: details.id,
|
|
68
|
+
// // language: "en",
|
|
69
|
+
// // version: 0,
|
|
70
|
+
// // });
|
|
71
|
+
// context.setComponentDesignerComponent(component);
|
|
72
|
+
// // context.setComponentDesignerRendering(rendering);
|
|
73
|
+
// },
|
|
74
|
+
// });
|
|
75
|
+
// };
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
{/* <Menubar
|
|
80
|
+
model={menuItems}
|
|
81
|
+
end={
|
|
82
|
+
<div className="flex items-center space-x-2">
|
|
83
|
+
<ItemLanguageVersion />
|
|
84
|
+
</div>
|
|
85
|
+
}
|
|
86
|
+
className="rounded-none border-0 border-b bg-gray-50 p-1 text-sm"
|
|
87
|
+
></Menubar>
|
|
88
|
+
<ItemNameDialog ref={itemNameDialogRef} /> */}
|
|
89
|
+
</>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { Toolbar } from "../ui/Toolbar";
|
|
3
|
+
import { ComponentsDropdown } from "./ComponentsDropdown";
|
|
4
|
+
import { TemplateEditor } from "./TemplateEditor";
|
|
5
|
+
import { getSelectedComponents } from "../componentTreeHelper";
|
|
6
|
+
import { useEditContext } from "../client/editContext";
|
|
7
|
+
import {
|
|
8
|
+
Component,
|
|
9
|
+
loadComponentDetails,
|
|
10
|
+
saveComponentDetails,
|
|
11
|
+
} from "../services/componentDesignerService";
|
|
12
|
+
|
|
13
|
+
import { Button } from "primereact/button";
|
|
14
|
+
|
|
15
|
+
export function ComponentEditor({
|
|
16
|
+
allComponents,
|
|
17
|
+
}: {
|
|
18
|
+
allComponents: Component[];
|
|
19
|
+
}) {
|
|
20
|
+
const context = useEditContext()!;
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const loadSelectedComponent = async () => {
|
|
24
|
+
const selectedComponents = getSelectedComponents(context!);
|
|
25
|
+
if (selectedComponents.length !== 1) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const component = selectedComponents[0];
|
|
29
|
+
|
|
30
|
+
if (!component) {
|
|
31
|
+
context.setComponentDesignerComponent(undefined);
|
|
32
|
+
context.setComponentDesignerRendering(undefined);
|
|
33
|
+
} else {
|
|
34
|
+
context.setComponentDesignerComponent(
|
|
35
|
+
await loadComponentDetails(
|
|
36
|
+
component.datasourceItem!.templateId,
|
|
37
|
+
context!.page!.item.id
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
// if (component.rendering) {
|
|
41
|
+
// context.setComponentDesignerRendering(
|
|
42
|
+
// await getItem({
|
|
43
|
+
// id: component.rendering.id,
|
|
44
|
+
// language: "en",
|
|
45
|
+
// version: 0,
|
|
46
|
+
// })
|
|
47
|
+
// );
|
|
48
|
+
// } else context.setComponentDesignerRendering(undefined);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
loadSelectedComponent();
|
|
52
|
+
}, [context.selection]);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const refresh = async () => {
|
|
56
|
+
if (context.componentDesignerComponent) {
|
|
57
|
+
context.setComponentDesignerComponent(
|
|
58
|
+
await loadComponentDetails(
|
|
59
|
+
context.componentDesignerComponent.templateId,
|
|
60
|
+
context!.page!.item.id
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
refresh();
|
|
66
|
+
}, [context.refreshCompletedFlag]);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div className="flex flex-col h-full">
|
|
70
|
+
<Toolbar>
|
|
71
|
+
<ComponentsDropdown allComponents={allComponents} />{" "}
|
|
72
|
+
<Button
|
|
73
|
+
icon="pi pi-fw pi-save"
|
|
74
|
+
text
|
|
75
|
+
size="small"
|
|
76
|
+
disabled={!context.componentDesignerComponent}
|
|
77
|
+
onClick={() => {
|
|
78
|
+
const save = async () => {
|
|
79
|
+
await saveComponentDetails(
|
|
80
|
+
context.componentDesignerComponent!,
|
|
81
|
+
context.page!.item
|
|
82
|
+
);
|
|
83
|
+
context.showToast({
|
|
84
|
+
content: "Component saved",
|
|
85
|
+
severity: "success",
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
save();
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
</Toolbar>
|
|
92
|
+
<div className="flex-1 overflow-auto">
|
|
93
|
+
<TemplateEditor />
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "@uiw/react-textarea-code-editor/dist.css";
|
|
2
|
+
|
|
3
|
+
import CodeEditor from "@uiw/react-textarea-code-editor";
|
|
4
|
+
|
|
5
|
+
export function ComponentRenderingCodeEditor({
|
|
6
|
+
code,
|
|
7
|
+
setCode,
|
|
8
|
+
}: {
|
|
9
|
+
code: string;
|
|
10
|
+
setCode: (code: string) => void;
|
|
11
|
+
}): React.ReactNode {
|
|
12
|
+
return (
|
|
13
|
+
<div className="size-full relative">
|
|
14
|
+
<div className="absolute inset-0 overflow-auto">
|
|
15
|
+
<CodeEditor
|
|
16
|
+
value={code}
|
|
17
|
+
language="js"
|
|
18
|
+
placeholder="Please enter TSX code."
|
|
19
|
+
onChange={(evn: any) => setCode(evn.target.value)}
|
|
20
|
+
padding={15}
|
|
21
|
+
style={{
|
|
22
|
+
fontSize: 12,
|
|
23
|
+
backgroundColor: "#f5f5f5",
|
|
24
|
+
fontFamily:
|
|
25
|
+
"ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace",
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { Toolbar } from "../ui/Toolbar";
|
|
3
|
+
import { ComponentRenderingCodeEditor } from "./ComponentRenderingCodeEditor";
|
|
4
|
+
import { RenderingsDropdown } from "./RenderingsDropdown";
|
|
5
|
+
import { useEditContext } from "../client/editContext";
|
|
6
|
+
import { getSelectedComponents } from "../componentTreeHelper";
|
|
7
|
+
import { Button } from "primereact/button";
|
|
8
|
+
|
|
9
|
+
export function ComponentRenderingEditor() {
|
|
10
|
+
const context = useEditContext()!;
|
|
11
|
+
const [code, setCode] = useState<string>("");
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
async function loadRendering() {
|
|
15
|
+
const selectedComponents = getSelectedComponents(context!);
|
|
16
|
+
|
|
17
|
+
if (selectedComponents.length !== 1) {
|
|
18
|
+
context;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const component = selectedComponents[0];
|
|
23
|
+
const renderingId = component?.rendering?.id;
|
|
24
|
+
|
|
25
|
+
if (renderingId) {
|
|
26
|
+
const renderingItem = await context.itemsRepository.getItem({
|
|
27
|
+
id: renderingId,
|
|
28
|
+
language: "en",
|
|
29
|
+
version: 0,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
context?.setComponentDesignerRendering(renderingItem);
|
|
33
|
+
} else {
|
|
34
|
+
context?.setComponentDesignerRendering(undefined);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
loadRendering();
|
|
39
|
+
}, [context.selection]);
|
|
40
|
+
|
|
41
|
+
const codeField = context.componentDesignerRendering?.fields.find(
|
|
42
|
+
(x) => x.name === "code"
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (codeField) {
|
|
47
|
+
setCode(codeField.value as string);
|
|
48
|
+
} else {
|
|
49
|
+
setCode("");
|
|
50
|
+
}
|
|
51
|
+
}, [context.componentDesignerRendering]);
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const refresh = async () => {
|
|
55
|
+
if (context.componentDesignerRendering) {
|
|
56
|
+
const renderingItem = await context.itemsRepository.getItem({
|
|
57
|
+
id: context.componentDesignerRendering.id,
|
|
58
|
+
language: "en",
|
|
59
|
+
version: 0,
|
|
60
|
+
});
|
|
61
|
+
context?.setComponentDesignerRendering(renderingItem);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
refresh();
|
|
65
|
+
}, [context.refreshCompletedFlag]);
|
|
66
|
+
|
|
67
|
+
if (!context.componentDesignerComponent)
|
|
68
|
+
return (
|
|
69
|
+
<div className="flex items-center justify-center h-full text-xs">
|
|
70
|
+
Select a component
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
else
|
|
74
|
+
return (
|
|
75
|
+
<div className="flex flex-col h-full">
|
|
76
|
+
<Toolbar>
|
|
77
|
+
<RenderingsDropdown />
|
|
78
|
+
<Button
|
|
79
|
+
icon="pi pi-fw pi-save"
|
|
80
|
+
text
|
|
81
|
+
size="small"
|
|
82
|
+
disabled={!codeField}
|
|
83
|
+
onClick={() => {
|
|
84
|
+
if (!codeField) return;
|
|
85
|
+
context.operations.editField({
|
|
86
|
+
field: codeField.descriptor,
|
|
87
|
+
value: code,
|
|
88
|
+
});
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
</Toolbar>
|
|
92
|
+
<div className="flex-1">
|
|
93
|
+
{!codeField && (
|
|
94
|
+
<div className="flex items-center justify-center h-full text-xs">
|
|
95
|
+
Select a rendering
|
|
96
|
+
</div>
|
|
97
|
+
)}
|
|
98
|
+
{codeField && (
|
|
99
|
+
<ComponentRenderingCodeEditor code={code} setCode={setCode} />
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useEditContext } from "../client/editContext";
|
|
2
|
+
import {
|
|
3
|
+
Component,
|
|
4
|
+
loadComponentDetails,
|
|
5
|
+
} from "../services/componentDesignerService";
|
|
6
|
+
|
|
7
|
+
import { Dropdown } from "primereact/dropdown";
|
|
8
|
+
|
|
9
|
+
export function ComponentsDropdown({
|
|
10
|
+
allComponents,
|
|
11
|
+
}: {
|
|
12
|
+
allComponents: Component[];
|
|
13
|
+
}) {
|
|
14
|
+
const context = useEditContext();
|
|
15
|
+
if (!context?.page) return null;
|
|
16
|
+
|
|
17
|
+
async function loadComponent(id: string) {
|
|
18
|
+
const component = await loadComponentDetails(id, context!.page!.item.id);
|
|
19
|
+
context!.setComponentDesignerComponent(component);
|
|
20
|
+
}
|
|
21
|
+
const value = allComponents.find(
|
|
22
|
+
(x) => x.templateId === context.componentDesignerComponent?.templateId
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Dropdown
|
|
27
|
+
value={value}
|
|
28
|
+
filter
|
|
29
|
+
options={allComponents}
|
|
30
|
+
optionLabel="name"
|
|
31
|
+
placeholder="Select a Component"
|
|
32
|
+
onChange={(e) => {
|
|
33
|
+
loadComponent(e.value.templateId);
|
|
34
|
+
context.setComponentDesignerRendering(undefined);
|
|
35
|
+
context.select([]);
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { useEditContext } from "../client/editContext";
|
|
2
|
+
import {
|
|
3
|
+
Component,
|
|
4
|
+
PlaceholderDefinition,
|
|
5
|
+
saveComponentDetails,
|
|
6
|
+
} from "../services/componentDesignerService";
|
|
7
|
+
import { ArrowDownIcon } from "../ui/Icons";
|
|
8
|
+
import { Toolbar } from "../ui/Toolbar";
|
|
9
|
+
import { Button } from "primereact/button";
|
|
10
|
+
import { ItemNameDialog } from "../ui/ItemNameDialogNew";
|
|
11
|
+
|
|
12
|
+
import { InsertOption } from "../../types";
|
|
13
|
+
|
|
14
|
+
export function PlaceholdersEditor({
|
|
15
|
+
allComponents,
|
|
16
|
+
}: {
|
|
17
|
+
allComponents: Component[];
|
|
18
|
+
}) {
|
|
19
|
+
const context = useEditContext()!;
|
|
20
|
+
const component = context.componentDesignerComponent;
|
|
21
|
+
// const itemNameDialogRef = useRef<ItemNameDialogHandle>(null);
|
|
22
|
+
|
|
23
|
+
const handleDragStart = (
|
|
24
|
+
event: React.DragEvent<HTMLDivElement>,
|
|
25
|
+
component: Component | InsertOption,
|
|
26
|
+
) => {
|
|
27
|
+
event.dataTransfer.setData("text/plain", JSON.stringify(component));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const handleDragOver = (event: React.DragEvent<HTMLDivElement>) => {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const handleDrop = (
|
|
35
|
+
event: React.DragEvent<HTMLDivElement>,
|
|
36
|
+
placeholderName: string,
|
|
37
|
+
) => {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
const componentData = JSON.parse(event.dataTransfer.getData("text/plain"));
|
|
40
|
+
const placeholder = component?.placeholders.find(
|
|
41
|
+
(x) => x.name == placeholderName,
|
|
42
|
+
);
|
|
43
|
+
if (!placeholder) return;
|
|
44
|
+
console.log(placeholder, componentData);
|
|
45
|
+
|
|
46
|
+
if (placeholder.components.find((x) => x.typeId === componentData.typeId))
|
|
47
|
+
return;
|
|
48
|
+
placeholder.components.push(componentData);
|
|
49
|
+
context.setComponentDesignerComponent({
|
|
50
|
+
...context.componentDesignerComponent!,
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const removeInsertOption = (
|
|
55
|
+
placeholder: PlaceholderDefinition,
|
|
56
|
+
insertOption: InsertOption,
|
|
57
|
+
) => {
|
|
58
|
+
placeholder.components = placeholder.components.filter(
|
|
59
|
+
(x) => x.typeId !== insertOption.typeId,
|
|
60
|
+
);
|
|
61
|
+
context.setComponentDesignerComponent({
|
|
62
|
+
...context.componentDesignerComponent!,
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// const addNewPlaceholder = async () => {
|
|
67
|
+
// itemNameDialogRef.current?.show({
|
|
68
|
+
// title: "Choose Placeholder Name",
|
|
69
|
+
// accept: async (name: string) => {
|
|
70
|
+
// if (!context.componentDesignerComponent) return;
|
|
71
|
+
// const placeholder = {
|
|
72
|
+
// name: name,
|
|
73
|
+
// components: [],
|
|
74
|
+
// };
|
|
75
|
+
// context.componentDesignerComponent.placeholders.push(placeholder);
|
|
76
|
+
// context.setComponentDesignerComponent({
|
|
77
|
+
// ...context.componentDesignerComponent!,
|
|
78
|
+
// });
|
|
79
|
+
// },
|
|
80
|
+
// });
|
|
81
|
+
// };
|
|
82
|
+
|
|
83
|
+
if (!component)
|
|
84
|
+
return (
|
|
85
|
+
<div className="flex h-full items-center justify-center text-xs">
|
|
86
|
+
Select a component
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
else
|
|
90
|
+
return (
|
|
91
|
+
<div className="flex h-full flex-col">
|
|
92
|
+
<Toolbar>
|
|
93
|
+
{/* <Button
|
|
94
|
+
icon="pi pi-fw pi-plus"
|
|
95
|
+
label="New Placeholder"
|
|
96
|
+
text
|
|
97
|
+
size="small"
|
|
98
|
+
className="text-xs font-normal text-gray-800"
|
|
99
|
+
disabled={!component}
|
|
100
|
+
onClick={() => {
|
|
101
|
+
addNewPlaceholder();
|
|
102
|
+
}}
|
|
103
|
+
/> */}
|
|
104
|
+
<Button
|
|
105
|
+
icon="pi pi-fw pi-save"
|
|
106
|
+
label="Save"
|
|
107
|
+
text
|
|
108
|
+
size="small"
|
|
109
|
+
className="text-xs font-normal text-gray-800"
|
|
110
|
+
disabled={!component}
|
|
111
|
+
onClick={() => {
|
|
112
|
+
saveComponentDetails(component, context.page!.item);
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
</Toolbar>
|
|
116
|
+
<div className="flex flex-1">
|
|
117
|
+
<div className="relative h-full flex-1">
|
|
118
|
+
<div className="absolute inset-1 overflow-y-auto">
|
|
119
|
+
{component.placeholders.map((x) => (
|
|
120
|
+
<div
|
|
121
|
+
key={x.name}
|
|
122
|
+
className="mb-2"
|
|
123
|
+
onDragOver={handleDragOver}
|
|
124
|
+
onDrop={(event) => handleDrop(event, x.name)}
|
|
125
|
+
>
|
|
126
|
+
<div className="flex items-center gap-1 text-xs">
|
|
127
|
+
<ArrowDownIcon /> {x.name}
|
|
128
|
+
</div>
|
|
129
|
+
<div className="mt-1.5 flex flex-wrap gap-4 p-1 text-xs">
|
|
130
|
+
{x.components.map((y) => (
|
|
131
|
+
<div className="relative" key={y.typeId}>
|
|
132
|
+
<div
|
|
133
|
+
className="absolute top-[-12px] right-[-12px] cursor-pointer rounded-full border bg-white p-1"
|
|
134
|
+
onClick={() => removeInsertOption(x, y)}
|
|
135
|
+
>
|
|
136
|
+
<i className="pi pi-times text-xs" />
|
|
137
|
+
</div>
|
|
138
|
+
{renderComponent(y)}
|
|
139
|
+
</div>
|
|
140
|
+
))}
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
))}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
<div className="relative w-24">
|
|
147
|
+
<div className="absolute inset-0 overflow-y-auto border-l text-xs">
|
|
148
|
+
{allComponents.map((x) => (
|
|
149
|
+
<div
|
|
150
|
+
key={x.templateId}
|
|
151
|
+
className="mb-2 cursor-grab"
|
|
152
|
+
draggable
|
|
153
|
+
onDragStart={(event) => handleDragStart(event, x)}
|
|
154
|
+
>
|
|
155
|
+
{renderComponent(x)}
|
|
156
|
+
</div>
|
|
157
|
+
))}
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
{/* <ItemNameDialog ref={itemNameDialogRef} /> */}
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function renderComponent(y: Component | InsertOption) {
|
|
167
|
+
return (
|
|
168
|
+
<div className="flex flex-col items-center border border-gray-200 p-2">
|
|
169
|
+
{y.svg && (
|
|
170
|
+
<div
|
|
171
|
+
className="h-8 w-8"
|
|
172
|
+
dangerouslySetInnerHTML={{ __html: y.svg }}
|
|
173
|
+
></div>
|
|
174
|
+
)}
|
|
175
|
+
{!y.svg && <img src={y.icon} width="32" height="32"></img>}
|
|
176
|
+
{y.name}
|
|
177
|
+
</div>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useEditContext } from "../client/editContext";
|
|
2
|
+
import { Dropdown } from "primereact/dropdown";
|
|
3
|
+
|
|
4
|
+
import { Rendering } from "../../types";
|
|
5
|
+
|
|
6
|
+
export function RenderingsDropdown() {
|
|
7
|
+
const context = useEditContext()!;
|
|
8
|
+
|
|
9
|
+
if (!context.componentDesignerComponent) return null;
|
|
10
|
+
|
|
11
|
+
const compatibleRenderings = [
|
|
12
|
+
...context.componentDesignerComponent.compatibleRenderings,
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
if (!compatibleRenderings) return null;
|
|
16
|
+
|
|
17
|
+
const loadRendering = async (value: Rendering) => {
|
|
18
|
+
const item = await context.itemsRepository.getItem({
|
|
19
|
+
id: value.id,
|
|
20
|
+
language: "en",
|
|
21
|
+
version: 0,
|
|
22
|
+
});
|
|
23
|
+
context.setComponentDesignerRendering(item);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Dropdown
|
|
28
|
+
options={compatibleRenderings}
|
|
29
|
+
optionLabel="name"
|
|
30
|
+
value={compatibleRenderings.find(
|
|
31
|
+
(x) => x.id === (context.componentDesignerRendering?.id || "")
|
|
32
|
+
)}
|
|
33
|
+
onChange={(e) => loadRendering(e.value as Rendering)}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|