@alpaca-editor/core 1.0.0
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/eslint.config.mjs +4 -0
- package/images/bg-shape-black.webp +0 -0
- package/package.json +52 -0
- package/src/client-components/api.ts +6 -0
- package/src/client-components/index.ts +19 -0
- package/src/components/ActionButton.tsx +43 -0
- package/src/components/Error.tsx +57 -0
- package/src/config/config.tsx +737 -0
- package/src/config/types.ts +263 -0
- package/src/editor/ComponentInfo.tsx +77 -0
- package/src/editor/ConfirmationDialog.tsx +103 -0
- package/src/editor/ContentTree.tsx +654 -0
- package/src/editor/ContextMenu.tsx +155 -0
- package/src/editor/Editor.tsx +91 -0
- package/src/editor/EditorWarning.tsx +34 -0
- package/src/editor/EditorWarnings.tsx +33 -0
- package/src/editor/FieldEditorPopup.tsx +65 -0
- package/src/editor/FieldHistory.tsx +74 -0
- package/src/editor/FieldList.tsx +190 -0
- package/src/editor/FieldListField.tsx +387 -0
- package/src/editor/FieldListFieldWithFallbacks.tsx +211 -0
- package/src/editor/FloatingToolbar.tsx +163 -0
- package/src/editor/ImageEditor.tsx +129 -0
- package/src/editor/InsertMenu.tsx +332 -0
- package/src/editor/ItemInfo.tsx +90 -0
- package/src/editor/LinkEditorDialog.tsx +192 -0
- package/src/editor/MainLayout.tsx +94 -0
- package/src/editor/NewEditorClient.tsx +11 -0
- package/src/editor/PictureCropper.tsx +505 -0
- package/src/editor/PictureEditor.tsx +206 -0
- package/src/editor/PictureEditorDialog.tsx +381 -0
- package/src/editor/PublishDialog.ignore +74 -0
- package/src/editor/ScrollingContentTree.tsx +47 -0
- package/src/editor/Terminal.tsx +215 -0
- package/src/editor/Titlebar.tsx +23 -0
- package/src/editor/ai/AiPopup.tsx +59 -0
- package/src/editor/ai/AiResponseMessage.tsx +82 -0
- package/src/editor/ai/AiTerminal.tsx +450 -0
- package/src/editor/ai/AiToolCall.tsx +46 -0
- package/src/editor/ai/EditorAiTerminal.tsx +20 -0
- package/src/editor/ai/editorAiContext.ts +18 -0
- package/src/editor/client/DialogContext.tsx +49 -0
- package/src/editor/client/EditorClient.tsx +1831 -0
- package/src/editor/client/GenericDialog.tsx +50 -0
- package/src/editor/client/editContext.ts +330 -0
- package/src/editor/client/helpers.ts +44 -0
- package/src/editor/client/itemsRepository.ts +391 -0
- package/src/editor/client/operations.ts +610 -0
- package/src/editor/client/pageModelBuilder.ts +182 -0
- package/src/editor/commands/commands.ts +23 -0
- package/src/editor/commands/componentCommands.tsx +408 -0
- package/src/editor/commands/createVersionCommand.ts +33 -0
- package/src/editor/commands/deleteVersionCommand.ts +71 -0
- package/src/editor/commands/itemCommands.tsx +186 -0
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +201 -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 +183 -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 +114 -0
- package/src/editor/control-center/ControlCenterMenu.tsx +71 -0
- package/src/editor/control-center/IndexOverview.tsx +50 -0
- package/src/editor/control-center/IndexSettings.tsx +266 -0
- package/src/editor/control-center/Status.tsx +7 -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 +15 -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 +75 -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 +112 -0
- package/src/editor/field-types/LinkFieldEditor.tsx +85 -0
- package/src/editor/field-types/MultiLineText.tsx +63 -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 +108 -0
- package/src/editor/field-types/SingleLineText.tsx +150 -0
- package/src/editor/field-types/TreeListEditor.tsx +261 -0
- package/src/editor/fieldTypes.ts +140 -0
- package/src/editor/media-selector/AiImageSearch.tsx +186 -0
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +95 -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/menubar/ActionsMenu.tsx +47 -0
- package/src/editor/menubar/ActiveUsers.tsx +17 -0
- package/src/editor/menubar/ApproveAndPublish.tsx +18 -0
- package/src/editor/menubar/BrowseHistory.tsx +37 -0
- package/src/editor/menubar/ItemLanguageVersion.tsx +52 -0
- package/src/editor/menubar/LanguageSelector.tsx +152 -0
- package/src/editor/menubar/Menu.tsx +83 -0
- package/src/editor/menubar/NavButtons.tsx +74 -0
- package/src/editor/menubar/PageSelector.tsx +139 -0
- package/src/editor/menubar/PageViewerControls.tsx +99 -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 +143 -0
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +287 -0
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +35 -0
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +44 -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 +263 -0
- package/src/editor/page-editor-chrome/FrameMenus.tsx +48 -0
- package/src/editor/page-editor-chrome/InlineEditor.tsx +147 -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 +119 -0
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +154 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +171 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +233 -0
- package/src/editor/page-viewer/DeviceToolbar.tsx +70 -0
- package/src/editor/page-viewer/EditorForm.tsx +247 -0
- package/src/editor/page-viewer/MiniMap.tsx +351 -0
- package/src/editor/page-viewer/PageViewer.tsx +127 -0
- package/src/editor/page-viewer/PageViewerFrame.tsx +1030 -0
- package/src/editor/page-viewer/pageViewContext.ts +186 -0
- package/src/editor/pageModel.ts +191 -0
- package/src/editor/picture-shared.tsx +53 -0
- package/src/editor/reviews/Comment.tsx +265 -0
- package/src/editor/reviews/Comments.tsx +50 -0
- package/src/editor/reviews/PreviewInfo.tsx +35 -0
- package/src/editor/reviews/Reviews.tsx +280 -0
- package/src/editor/reviews/reviewCommands.tsx +47 -0
- package/src/editor/reviews/useReviews.tsx +70 -0
- package/src/editor/services/aiService.ts +155 -0
- package/src/editor/services/componentDesignerService.ts +151 -0
- package/src/editor/services/contentService.ts +159 -0
- package/src/editor/services/editService.ts +462 -0
- package/src/editor/services/indexService.ts +24 -0
- package/src/editor/services/reviewsService.ts +45 -0
- package/src/editor/services/serviceHelper.ts +95 -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 +146 -0
- package/src/editor/sidebar/ComponentTree.tsx +512 -0
- package/src/editor/sidebar/ComponentTree2.tsxx +490 -0
- package/src/editor/sidebar/Debug.tsx +105 -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 +95 -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 +150 -0
- package/src/editor/sidebar/Translations.tsx +276 -0
- package/src/editor/sidebar/Validation.tsx +102 -0
- package/src/editor/sidebar/ViewSelector.tsx +49 -0
- package/src/editor/sidebar/Workbox.tsx +209 -0
- package/src/editor/ui/CenteredMessage.tsx +7 -0
- package/src/editor/ui/CopyToClipboardButton.tsx +23 -0
- package/src/editor/ui/DialogButtons.tsx +11 -0
- package/src/editor/ui/Icons.tsx +585 -0
- package/src/editor/ui/ItemNameDialog.tsx +94 -0
- package/src/editor/ui/ItemNameDialogNew.tsx +118 -0
- package/src/editor/ui/ItemSearch.tsx +173 -0
- package/src/editor/ui/PerfectTree.tsx +550 -0
- package/src/editor/ui/Section.tsx +35 -0
- package/src/editor/ui/SimpleIconButton.tsx +43 -0
- package/src/editor/ui/SimpleMenu.tsx +48 -0
- package/src/editor/ui/SimpleTable.tsx +63 -0
- package/src/editor/ui/SimpleTabs.tsx +55 -0
- package/src/editor/ui/SimpleToolbar.tsx +7 -0
- package/src/editor/ui/Spinner.tsx +7 -0
- package/src/editor/ui/Splitter.tsx +247 -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 +435 -0
- package/src/editor/views/CompareView.tsx +256 -0
- package/src/editor/views/EditView.tsx +27 -0
- package/src/editor/views/ItemEditor.tsx +58 -0
- package/src/editor/views/SingleEditView.tsx +44 -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/index.ts +7 -0
- package/src/page-wizard/PageWizard.tsx +163 -0
- package/src/page-wizard/SelectWizard.tsx +109 -0
- package/src/page-wizard/WizardSteps.tsx +207 -0
- package/src/page-wizard/service.ts +35 -0
- package/src/page-wizard/startPageWizardCommand.ts +27 -0
- package/src/page-wizard/steps/BuildPageStep.tsx +266 -0
- package/src/page-wizard/steps/CollectStep.tsx +233 -0
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +443 -0
- package/src/page-wizard/steps/Components.tsx +193 -0
- package/src/page-wizard/steps/CreatePage.tsx +285 -0
- package/src/page-wizard/steps/CreatePageAndLayoutStep.tsx +384 -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 +32 -0
- package/src/page-wizard/steps/ImagesStep.tsx +318 -0
- package/src/page-wizard/steps/LayoutStep.tsx +228 -0
- package/src/page-wizard/steps/SelectStep.tsx +256 -0
- package/src/page-wizard/steps/schema.ts +180 -0
- package/src/page-wizard/steps/usePageCreator.ts +279 -0
- package/src/splash-screen/NewPage.tsx +232 -0
- package/src/splash-screen/SectionHeadline.tsx +21 -0
- package/src/splash-screen/SplashScreen.tsx +156 -0
- package/src/tour/Tour.tsx +558 -0
- package/src/tour/default-tour.tsx +300 -0
- package/src/tour/preview-tour.tsx +127 -0
- package/src/types.ts +302 -0
- package/styles.css +476 -0
- package/tsconfig.build.json +21 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import {
|
|
5
|
+
useEditContext,
|
|
6
|
+
useModifiedFieldsContext,
|
|
7
|
+
} from "../client/editContext";
|
|
8
|
+
import { getDictionary, getSites } from "../services/contentService";
|
|
9
|
+
import { EditableDictionary, Site } from "../../types";
|
|
10
|
+
import { SimpleTable } from "../ui/SimpleTable";
|
|
11
|
+
import { ProgressSpinner } from "primereact/progressspinner";
|
|
12
|
+
import { InputText } from "primereact/inputtext";
|
|
13
|
+
import { Component, Field } from "../pageModel";
|
|
14
|
+
import { Button } from "primereact/button";
|
|
15
|
+
import { classNames } from "primereact/utils";
|
|
16
|
+
import { CenteredMessage } from "../ui/CenteredMessage";
|
|
17
|
+
import { Dropdown } from "primereact/dropdown";
|
|
18
|
+
import { SimpleToolbar } from "../ui/SimpleToolbar";
|
|
19
|
+
|
|
20
|
+
type DictionaryEntry = {
|
|
21
|
+
key: string;
|
|
22
|
+
field: Field | null;
|
|
23
|
+
translation: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function DictionaryEditor({}: {}) {
|
|
27
|
+
const context = useEditContext();
|
|
28
|
+
const [dictionary, setDictionary] = useState<EditableDictionary>({});
|
|
29
|
+
const [renderedDictionaryKeys, setRenderedDictionaryKeys] =
|
|
30
|
+
useState<string[]>();
|
|
31
|
+
const [unknownKeys, setUnknownKeys] = useState<string[]>();
|
|
32
|
+
const [otherKeys, setOtherKeys] = useState<DictionaryEntry[]>();
|
|
33
|
+
const [validKeys, setValidKeys] = useState<DictionaryEntry[]>();
|
|
34
|
+
const [sites, setSites] = useState<Site[]>();
|
|
35
|
+
const [siteName, setSiteName] = useState<string>();
|
|
36
|
+
const [loading, setLoading] = useState(false);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!context?.pageView.site) return;
|
|
40
|
+
setSiteName(context.pageView.site.name);
|
|
41
|
+
}, [context?.pageView.site]);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const loadSites = async () => {
|
|
45
|
+
setLoading(true);
|
|
46
|
+
const sites = await getSites();
|
|
47
|
+
if (sites.data) setSites(sites.data);
|
|
48
|
+
setLoading(false);
|
|
49
|
+
};
|
|
50
|
+
loadSites();
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
53
|
+
const currentItemDescriptor = context?.currentItemDescriptor;
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!siteName || !currentItemDescriptor) return;
|
|
56
|
+
|
|
57
|
+
const loadDictionary = async (site: string, language: string) => {
|
|
58
|
+
const dictionary = await getDictionary(site, language);
|
|
59
|
+
setDictionary(dictionary);
|
|
60
|
+
};
|
|
61
|
+
loadDictionary(siteName, currentItemDescriptor.language);
|
|
62
|
+
}, [siteName, currentItemDescriptor]);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const findAllKeys = (component: Component, keys: string[]) => {
|
|
66
|
+
component.renderedDictionaryKeys.forEach((k) => {
|
|
67
|
+
if (!keys.includes(k)) keys.push(k);
|
|
68
|
+
});
|
|
69
|
+
component.placeholders.forEach((p) => {
|
|
70
|
+
p.components.forEach((c) => findAllKeys(c, keys));
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
if (!context?.page) return;
|
|
74
|
+
const keys: string[] = [];
|
|
75
|
+
findAllKeys(context.page.rootComponent, keys);
|
|
76
|
+
setRenderedDictionaryKeys(keys);
|
|
77
|
+
}, [context?.page]);
|
|
78
|
+
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (!dictionary || !renderedDictionaryKeys) {
|
|
81
|
+
setValidKeys([]);
|
|
82
|
+
setOtherKeys([]);
|
|
83
|
+
setUnknownKeys([]);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const getEntries = (keys: string[]) => {
|
|
88
|
+
const entries = Object.keys(dictionary)
|
|
89
|
+
.filter((k) => keys.includes(k))
|
|
90
|
+
.map((k) => ({
|
|
91
|
+
key: k,
|
|
92
|
+
field: dictionary[k]!,
|
|
93
|
+
translation: dictionary[k]!.value,
|
|
94
|
+
}));
|
|
95
|
+
entries.sort((a, b) => (a.key > b.key ? -1 : 1));
|
|
96
|
+
return entries;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const unknownKeys = renderedDictionaryKeys.filter((k) => !dictionary[k]);
|
|
100
|
+
unknownKeys.sort((a, b) => (a > b ? -1 : 1));
|
|
101
|
+
setUnknownKeys(unknownKeys);
|
|
102
|
+
|
|
103
|
+
setValidKeys(
|
|
104
|
+
getEntries(renderedDictionaryKeys.filter((k) => dictionary[k]))
|
|
105
|
+
);
|
|
106
|
+
setOtherKeys(
|
|
107
|
+
getEntries(
|
|
108
|
+
Object.keys(dictionary).filter(
|
|
109
|
+
(k) => !renderedDictionaryKeys.includes(k)
|
|
110
|
+
)
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
}, [renderedDictionaryKeys, dictionary]);
|
|
114
|
+
|
|
115
|
+
const getContent = () => {
|
|
116
|
+
if (!unknownKeys || !validKeys || !otherKeys) return null;
|
|
117
|
+
|
|
118
|
+
if (!siteName) return <CenteredMessage>No Site</CenteredMessage>;
|
|
119
|
+
|
|
120
|
+
if (loading) return <CenteredMessage>Loading...</CenteredMessage>;
|
|
121
|
+
|
|
122
|
+
if (!dictionary)
|
|
123
|
+
return <CenteredMessage>No dictionary found</CenteredMessage>;
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<>
|
|
127
|
+
<Divider text="Keys rendered on this page" className="mt-1" />
|
|
128
|
+
<DictionaryTable entries={validKeys} context={context} />
|
|
129
|
+
<Divider text="⚠ Unknown keys" className="mt-6" />
|
|
130
|
+
<UnknownKeysTable entries={unknownKeys} />
|
|
131
|
+
<Divider text="Other keys" className="mt-6" />
|
|
132
|
+
<DictionaryTable entries={otherKeys} context={context} />
|
|
133
|
+
</>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<div className="flex flex-col gap-1 h-full">
|
|
139
|
+
<SimpleToolbar>
|
|
140
|
+
Site:{" "}
|
|
141
|
+
<Dropdown
|
|
142
|
+
options={sites?.map((s) => ({ label: s.name, value: s.name })) || []}
|
|
143
|
+
value={siteName}
|
|
144
|
+
onChange={(e) => setSiteName(e.value)}
|
|
145
|
+
/>
|
|
146
|
+
</SimpleToolbar>
|
|
147
|
+
{getContent()}
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function Divider({ text, className }: { text: string; className?: string }) {
|
|
153
|
+
return (
|
|
154
|
+
<div
|
|
155
|
+
className={classNames(
|
|
156
|
+
className,
|
|
157
|
+
"py-1 flex items-center text-sm font-bold before:flex-1 before:border-t before:border-gray-200 before:me-6 after:flex-1 after:border-t after:border-gray-200 after:ms-6"
|
|
158
|
+
)}
|
|
159
|
+
>
|
|
160
|
+
{text}
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function DictionaryTable({
|
|
166
|
+
entries,
|
|
167
|
+
context,
|
|
168
|
+
}: {
|
|
169
|
+
entries: DictionaryEntry[];
|
|
170
|
+
context?: any;
|
|
171
|
+
}) {
|
|
172
|
+
const [editing, setEditing] = useState<string>();
|
|
173
|
+
const [value, setValue] = useState<string>("");
|
|
174
|
+
const [refresh, setRefresh] = useState(false);
|
|
175
|
+
const modifiedFieldsContext = useModifiedFieldsContext();
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
if (refresh) {
|
|
178
|
+
setEditing(undefined);
|
|
179
|
+
setRefresh(false);
|
|
180
|
+
}
|
|
181
|
+
}, [context.refreshCompletedFlag]);
|
|
182
|
+
|
|
183
|
+
const textEditor = (entry: DictionaryEntry) => {
|
|
184
|
+
if (entry.field)
|
|
185
|
+
return (
|
|
186
|
+
<div className="flex flex-wrap gap-2 items-center">
|
|
187
|
+
<InputText
|
|
188
|
+
value={value}
|
|
189
|
+
disabled={refresh}
|
|
190
|
+
onChange={(e) => setValue(e.target.value)}
|
|
191
|
+
autoFocus={true}
|
|
192
|
+
/>
|
|
193
|
+
{!refresh && (
|
|
194
|
+
<Button
|
|
195
|
+
size="small"
|
|
196
|
+
onClick={() => {
|
|
197
|
+
setRefresh(true);
|
|
198
|
+
if (!entry.field) return;
|
|
199
|
+
context?.operations.editField({
|
|
200
|
+
field: entry.field.descriptor,
|
|
201
|
+
value: value,
|
|
202
|
+
refresh: "immediate",
|
|
203
|
+
});
|
|
204
|
+
}}
|
|
205
|
+
>
|
|
206
|
+
Apply
|
|
207
|
+
</Button>
|
|
208
|
+
)}
|
|
209
|
+
{refresh && (
|
|
210
|
+
<ProgressSpinner style={{ width: "20px", height: "20px" }} />
|
|
211
|
+
)}
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
else return null;
|
|
215
|
+
};
|
|
216
|
+
const columns = [
|
|
217
|
+
{ body: (entry: DictionaryEntry) => entry.key, header: "Key" },
|
|
218
|
+
{
|
|
219
|
+
body: (entry: DictionaryEntry) => {
|
|
220
|
+
const modifiedField = modifiedFieldsContext?.modifiedFields.find(
|
|
221
|
+
(x) =>
|
|
222
|
+
x.fieldId === entry.field?.id &&
|
|
223
|
+
x.item.id === entry.field?.descriptor.item.id &&
|
|
224
|
+
x.item.language === entry.field?.descriptor.item.language &&
|
|
225
|
+
x.item.version === entry.field?.descriptor.item.version
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
if (editing === entry.key) return textEditor(entry);
|
|
229
|
+
else
|
|
230
|
+
return (
|
|
231
|
+
<div
|
|
232
|
+
className="min-w-ful cursor-pointer"
|
|
233
|
+
onClick={() => {
|
|
234
|
+
if (!editing) {
|
|
235
|
+
setValue(modifiedField?.value ?? entry.translation);
|
|
236
|
+
setEditing(entry.key);
|
|
237
|
+
}
|
|
238
|
+
}}
|
|
239
|
+
>
|
|
240
|
+
{modifiedField?.value ?? entry.translation}
|
|
241
|
+
</div>
|
|
242
|
+
);
|
|
243
|
+
},
|
|
244
|
+
header: "Translation",
|
|
245
|
+
},
|
|
246
|
+
];
|
|
247
|
+
return (
|
|
248
|
+
<div>
|
|
249
|
+
<SimpleTable items={entries} columns={columns} />
|
|
250
|
+
</div>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function UnknownKeysTable({ entries }: { entries: string[] }) {
|
|
255
|
+
const columns = [{ body: (entry: string) => entry, header: "Key" }];
|
|
256
|
+
return (
|
|
257
|
+
<div>
|
|
258
|
+
<SimpleTable items={entries} columns={columns} />
|
|
259
|
+
</div>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { classNames } from "primereact/utils";
|
|
4
|
+
import { useEditContext } from "../client/editContext";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { WizardIcon } from "../ui/Icons";
|
|
7
|
+
import { EditOperation } from "../../types";
|
|
8
|
+
import { SimpleIconButton } from "../ui/SimpleIconButton";
|
|
9
|
+
import { getRedoCommand, getUndoCommand } from "../commands/undo";
|
|
10
|
+
import { formatDate } from "../utils";
|
|
11
|
+
import { SimpleToolbar } from "../ui/SimpleToolbar";
|
|
12
|
+
|
|
13
|
+
export function EditHistory() {
|
|
14
|
+
const editContext = useEditContext();
|
|
15
|
+
const [showOnlyMyChanges, setShowOnlyMyChanges] = useState(true);
|
|
16
|
+
const [history, setHistory] = useState<EditOperation[]>([]);
|
|
17
|
+
if (!editContext) return;
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
let operations = showOnlyMyChanges
|
|
21
|
+
? editContext.editHistory.filter(
|
|
22
|
+
(x) => x.sessionId === editContext.sessionId,
|
|
23
|
+
)
|
|
24
|
+
: editContext.editHistory;
|
|
25
|
+
|
|
26
|
+
operations = filterUndone(operations);
|
|
27
|
+
|
|
28
|
+
setHistory(operations);
|
|
29
|
+
}, [editContext.editHistory]);
|
|
30
|
+
|
|
31
|
+
const undoCommand = getUndoCommand();
|
|
32
|
+
const redoCommand = getRedoCommand();
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="absolute inset-0 flex flex-col">
|
|
36
|
+
<SimpleToolbar>
|
|
37
|
+
<SimpleIconButton
|
|
38
|
+
selected={showOnlyMyChanges}
|
|
39
|
+
onClick={() => setShowOnlyMyChanges(!showOnlyMyChanges)}
|
|
40
|
+
icon="pi pi-user"
|
|
41
|
+
label="Show only my changes"
|
|
42
|
+
/>
|
|
43
|
+
<SimpleIconButton
|
|
44
|
+
onClick={(ev) => {
|
|
45
|
+
editContext.executeCommand({ command: undoCommand, event: ev });
|
|
46
|
+
}}
|
|
47
|
+
icon={undoCommand.icon}
|
|
48
|
+
label={undoCommand.label}
|
|
49
|
+
disabled={editContext.isCommandDisabled({ command: undoCommand })}
|
|
50
|
+
/>
|
|
51
|
+
<SimpleIconButton
|
|
52
|
+
onClick={(ev) => {
|
|
53
|
+
editContext.executeCommand({ command: redoCommand, event: ev });
|
|
54
|
+
}}
|
|
55
|
+
icon={redoCommand.icon}
|
|
56
|
+
label={redoCommand.label}
|
|
57
|
+
disabled={editContext.isCommandDisabled({ command: redoCommand })}
|
|
58
|
+
/>
|
|
59
|
+
</SimpleToolbar>
|
|
60
|
+
<div className="flex flex-1 flex-col overflow-x-hidden overflow-y-auto text-sm">
|
|
61
|
+
{history.map((o, i) => singleOperation(i, o))}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
function getDate(o: EditOperation) {
|
|
67
|
+
const date = new Date(o.date);
|
|
68
|
+
return formatDate(date);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function singleOperation(i: number, o: EditOperation) {
|
|
72
|
+
let className =
|
|
73
|
+
"border-b border-gray-200 p-2 flex justify-between items-start text-xs hover:bg-gray-100";
|
|
74
|
+
if (o.undone) className = className + " text-gray-300";
|
|
75
|
+
if (o.focus) className = className + " cursor-pointer";
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div
|
|
79
|
+
className={className}
|
|
80
|
+
key={i}
|
|
81
|
+
onClick={() => {
|
|
82
|
+
if (o.focus) {
|
|
83
|
+
const focusComponents = o.focus.split(":");
|
|
84
|
+
if (focusComponents.length > 0) {
|
|
85
|
+
editContext?.select([focusComponents[0]!]);
|
|
86
|
+
}
|
|
87
|
+
if (
|
|
88
|
+
focusComponents.length > 1 &&
|
|
89
|
+
focusComponents[1] &&
|
|
90
|
+
focusComponents[0]
|
|
91
|
+
) {
|
|
92
|
+
editContext?.setFocusedField(
|
|
93
|
+
{
|
|
94
|
+
item: {
|
|
95
|
+
id: focusComponents[0],
|
|
96
|
+
language: editContext.page!.item.language,
|
|
97
|
+
version: editContext.page!.item.version,
|
|
98
|
+
},
|
|
99
|
+
fieldId: focusComponents[1]!,
|
|
100
|
+
},
|
|
101
|
+
false,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<div className="flex gap-1">
|
|
108
|
+
{o.user?.ai && (
|
|
109
|
+
<WizardIcon
|
|
110
|
+
className={classNames(
|
|
111
|
+
"h-4 w-4",
|
|
112
|
+
o.undone ? "text-gray-200" : "text-gray-500",
|
|
113
|
+
)}
|
|
114
|
+
/>
|
|
115
|
+
)}
|
|
116
|
+
<div>{o.description}</div>
|
|
117
|
+
</div>
|
|
118
|
+
<div>
|
|
119
|
+
<div className="text-xs">{getDate(o)}</div>
|
|
120
|
+
{!showOnlyMyChanges && <div className="text-xs">{o.user?.name}</div>}
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function filterUndone(operations: EditOperation[]): EditOperation[] {
|
|
127
|
+
let allUndone = true;
|
|
128
|
+
return operations.filter((o) => {
|
|
129
|
+
if (!o.undone) {
|
|
130
|
+
allUndone = false;
|
|
131
|
+
}
|
|
132
|
+
return allUndone || !o.undone;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { TabView, TabPanel } from "primereact/tabview";
|
|
2
|
+
|
|
3
|
+
import { Splitter, SplitterPanel } from "primereact/splitter";
|
|
4
|
+
import { InputTextarea } from "primereact/inputtextarea";
|
|
5
|
+
import { Button } from "primereact/button";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
|
|
8
|
+
import { useEditContext } from "../client/editContext";
|
|
9
|
+
import { ObjectInspector } from "react-inspector";
|
|
10
|
+
import { SimpleTabs } from "../ui/SimpleTabs";
|
|
11
|
+
|
|
12
|
+
export function GraphQL() {
|
|
13
|
+
const editContext = useEditContext();
|
|
14
|
+
const [query, setQuery] = useState("");
|
|
15
|
+
const [showSpinner, setShowSpinner] = useState(false);
|
|
16
|
+
|
|
17
|
+
let item = editContext?.page?.item;
|
|
18
|
+
|
|
19
|
+
//const graphql = item?.graphql;
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setShowSpinner(false);
|
|
23
|
+
}, [editContext?.refreshCompletedFlag]);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const graphql_query = item?.fields.find(
|
|
27
|
+
(x) => x.name === "graphql_query",
|
|
28
|
+
)?.rawValue;
|
|
29
|
+
|
|
30
|
+
if (graphql_query) setQuery(graphql_query || "");
|
|
31
|
+
}, [item]);
|
|
32
|
+
|
|
33
|
+
// if (item) {
|
|
34
|
+
// const selectedComponents = editContext!.selection
|
|
35
|
+
// .map((x) => getComponentById(x, editContext!.page!))
|
|
36
|
+
// .filter((x) => x) as Component[];
|
|
37
|
+
// if (selectedComponents.length === 1) item = selectedComponents[0];
|
|
38
|
+
// }
|
|
39
|
+
|
|
40
|
+
// type JsonType = { [key: string]: any };
|
|
41
|
+
|
|
42
|
+
// function findFields(json: JsonType): { [key: string]: Array<JsonValueType> } {
|
|
43
|
+
// let result: { [key: string]: Array<JsonValueType> } = {};
|
|
44
|
+
|
|
45
|
+
// for (let key in json) {
|
|
46
|
+
// if (typeof json[key] === "object" && json[key] !== null) {
|
|
47
|
+
// let subResult = findFields(json[key]);
|
|
48
|
+
// for (let subKey in subResult) {
|
|
49
|
+
// if (result[subKey]) {
|
|
50
|
+
// result[subKey] = result[subKey].concat(subResult[subKey]);
|
|
51
|
+
// } else {
|
|
52
|
+
// result[subKey] = subResult[subKey];
|
|
53
|
+
// }
|
|
54
|
+
// }
|
|
55
|
+
// }
|
|
56
|
+
// if (key === "jsonValue" && json[key]) {
|
|
57
|
+
// let groupKey = `${json[key].itemId}_${json[key].language}_${json[key].version}`;
|
|
58
|
+
// if (result[groupKey]) {
|
|
59
|
+
// result[groupKey].push(json[key]);
|
|
60
|
+
// } else {
|
|
61
|
+
// result[groupKey] = [json[key]];
|
|
62
|
+
// }
|
|
63
|
+
// }
|
|
64
|
+
// }
|
|
65
|
+
// return result;
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
//type JsonValueType = { itemId: string; language: string; version: string };
|
|
69
|
+
|
|
70
|
+
//const fieldsjsonValues = findFields(graphql);
|
|
71
|
+
|
|
72
|
+
// function renderItem(fields: Field[]) {
|
|
73
|
+
// const first = fields[0];
|
|
74
|
+
// const item = first.descriptor.item;
|
|
75
|
+
|
|
76
|
+
// if (!item) return null;
|
|
77
|
+
|
|
78
|
+
// return (
|
|
79
|
+
// <div key={first.id + item.id + item.language + item.version}>
|
|
80
|
+
// Item: {item.id} {first.id} {item.language} {item.version}
|
|
81
|
+
// <FieldList
|
|
82
|
+
// fields={fields}
|
|
83
|
+
// validators={
|
|
84
|
+
// editContext?.pageValidationResult?.find(
|
|
85
|
+
// (x) =>
|
|
86
|
+
// x.item.id === item.id &&
|
|
87
|
+
// x.item.language === item.language &&
|
|
88
|
+
// x.item.version === item.version
|
|
89
|
+
// )?.results || []
|
|
90
|
+
// }
|
|
91
|
+
// />
|
|
92
|
+
// </div>
|
|
93
|
+
// );
|
|
94
|
+
// }
|
|
95
|
+
|
|
96
|
+
if (!item) return null;
|
|
97
|
+
const graphql = {};
|
|
98
|
+
|
|
99
|
+
// function refresh() {
|
|
100
|
+
// if (!item) return;
|
|
101
|
+
|
|
102
|
+
// const field: Field = {
|
|
103
|
+
// _editor: {
|
|
104
|
+
// name: "_GraphQL",
|
|
105
|
+
// type: "jsonValue",
|
|
106
|
+
// descriptor: {
|
|
107
|
+
// item: item,
|
|
108
|
+
// fieldId: "3622F861-ECA9-45D7-8DA7-2CDA35235002",
|
|
109
|
+
// },
|
|
110
|
+
// sourceItems: [],
|
|
111
|
+
// },
|
|
112
|
+
// id: "3622F861-ECA9-45D7-8DA7-2CDA35235002",
|
|
113
|
+
// value: query,
|
|
114
|
+
// };
|
|
115
|
+
// const prettyQuery = format(query);
|
|
116
|
+
// setQuery(prettyQuery);
|
|
117
|
+
// setShowSpinner(true);
|
|
118
|
+
// editContext?.editField({
|
|
119
|
+
// field: field._editor!.descriptor,
|
|
120
|
+
// value: prettyQuery,
|
|
121
|
+
// });
|
|
122
|
+
// }
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<Splitter layout="vertical" style={{ height: "100%" }}>
|
|
126
|
+
<SplitterPanel size={50} className="relative">
|
|
127
|
+
<div className="absolute inset-0 flex">
|
|
128
|
+
<InputTextarea
|
|
129
|
+
value={query}
|
|
130
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
131
|
+
className="flex-1 text-xs"
|
|
132
|
+
style={{ height: "100%" }}
|
|
133
|
+
/>
|
|
134
|
+
<Button
|
|
135
|
+
icon={"pi pi-refresh" + (showSpinner ? " pi-spin" : "")}
|
|
136
|
+
// onClick={refresh}
|
|
137
|
+
disabled={showSpinner}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
</SplitterPanel>
|
|
141
|
+
<SplitterPanel className="relative">
|
|
142
|
+
<div className="absolute inset-0">
|
|
143
|
+
<SimpleTabs
|
|
144
|
+
tabs={[
|
|
145
|
+
{
|
|
146
|
+
id: "json",
|
|
147
|
+
label: "JSON",
|
|
148
|
+
content: (
|
|
149
|
+
<div className="relative h-full">
|
|
150
|
+
<div className="flex-1 overflow-y-auto p-2">
|
|
151
|
+
<ObjectInspector data={graphql} expandLevel={3} />
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
),
|
|
155
|
+
},
|
|
156
|
+
]}
|
|
157
|
+
activeTab={0}
|
|
158
|
+
setActiveTab={(index) => {}}
|
|
159
|
+
/>
|
|
160
|
+
</div>
|
|
161
|
+
</SplitterPanel>
|
|
162
|
+
</Splitter>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ComponentPalette } from "./ComponentPalette";
|
|
2
|
+
import { MainContentTree } from "./MainContentTree";
|
|
3
|
+
import { SimpleTabs, Tab } from "../ui/SimpleTabs";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
|
|
6
|
+
export function Insert() {
|
|
7
|
+
const [activeTab, setActiveTab] = useState(0);
|
|
8
|
+
const tabs: Tab[] = [
|
|
9
|
+
{
|
|
10
|
+
label: "New Component",
|
|
11
|
+
content: <ComponentPalette />,
|
|
12
|
+
id: "new",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Existing Component",
|
|
16
|
+
content: (
|
|
17
|
+
<div className="flex-1 relative">
|
|
18
|
+
<div className="absolute inset-0 overflow-auto">
|
|
19
|
+
<MainContentTree mode="insert" />
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
),
|
|
23
|
+
id: "existing",
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
return (
|
|
27
|
+
<SimpleTabs
|
|
28
|
+
key="insert-tabs"
|
|
29
|
+
tabs={tabs}
|
|
30
|
+
className=" flex gap-1 justify-center items-center py-3 text-sm border-b border-gray-200"
|
|
31
|
+
activeTab={activeTab}
|
|
32
|
+
setActiveTab={(index) => setActiveTab(index)}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { InsertOption } from "../../types";
|
|
3
|
+
import ContentTree from "../ContentTree";
|
|
4
|
+
import { useEditContext } from "../client/editContext";
|
|
5
|
+
import { ItemTreeNodeData } from "../services/contentService";
|
|
6
|
+
import { getInsertOptionsForCurrentSelection } from "../utils/insertOptions";
|
|
7
|
+
import ItemSearch from "../ui/ItemSearch";
|
|
8
|
+
|
|
9
|
+
export function MainContentTree({
|
|
10
|
+
mode,
|
|
11
|
+
rootItemId,
|
|
12
|
+
}: {
|
|
13
|
+
mode: "insert" | "normal" | "select-page";
|
|
14
|
+
rootItemId?: string;
|
|
15
|
+
}) {
|
|
16
|
+
const editContext = useEditContext();
|
|
17
|
+
const [insertOptions, setInsertOptions] = useState<InsertOption[]>();
|
|
18
|
+
if (!editContext) return null;
|
|
19
|
+
|
|
20
|
+
const page = editContext.page;
|
|
21
|
+
const selectedItem = editContext.contentEditorItem ?? page?.item;
|
|
22
|
+
const [selectedItemIds, setSelectedItemIds] = useState<string[]>([]);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (selectedItem) setSelectedItemIds([selectedItem.id]);
|
|
26
|
+
}, [selectedItem]);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const loadInsertOptions = async () => {
|
|
30
|
+
if (!page) return;
|
|
31
|
+
const options = await getInsertOptionsForCurrentSelection(editContext);
|
|
32
|
+
setInsertOptions(options);
|
|
33
|
+
};
|
|
34
|
+
loadInsertOptions();
|
|
35
|
+
}, [editContext.selection, page]);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className="flex h-full flex-col">
|
|
39
|
+
<div className="border-b border-gray-200 p-2">
|
|
40
|
+
<ItemSearch
|
|
41
|
+
resultClassName="px-2 py-1"
|
|
42
|
+
itemSelected={(item) =>
|
|
43
|
+
editContext?.loadItem({
|
|
44
|
+
id: item.id,
|
|
45
|
+
language: item.language,
|
|
46
|
+
version: 0,
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
<div className="relative flex-1">
|
|
52
|
+
<div className="absolute inset-1 overflow-auto">
|
|
53
|
+
<ContentTree
|
|
54
|
+
language={editContext.currentItemDescriptor?.language ?? "en"}
|
|
55
|
+
rootItemId={rootItemId ?? "{11111111-1111-1111-1111-111111111111}"}
|
|
56
|
+
expandIdPath={
|
|
57
|
+
selectedItem?.idPath
|
|
58
|
+
? selectedItem?.idPath.split("/").slice(0, -1).join("/")
|
|
59
|
+
: undefined
|
|
60
|
+
}
|
|
61
|
+
className="h-full"
|
|
62
|
+
selectPagesOnly={mode === "select-page"}
|
|
63
|
+
selectionMode={mode == "insert" ? "none" : "multiple"}
|
|
64
|
+
selectedItemIds={selectedItemIds}
|
|
65
|
+
onSelectionChange={(selection) => {
|
|
66
|
+
const selectedItems = selection as ItemTreeNodeData[];
|
|
67
|
+
setSelectedItemIds(selectedItems.map((x) => x.id));
|
|
68
|
+
if (selectedItems.length > 0 && selectedItems[0])
|
|
69
|
+
editContext.loadItem({
|
|
70
|
+
id: selectedItems[0].id,
|
|
71
|
+
language: selectedItems[0].language,
|
|
72
|
+
version: selectedItems[0].version,
|
|
73
|
+
});
|
|
74
|
+
}}
|
|
75
|
+
isDraggable={(x) =>
|
|
76
|
+
mode === "insert" &&
|
|
77
|
+
insertOptions?.find(
|
|
78
|
+
(insertOption: InsertOption) =>
|
|
79
|
+
insertOption.typeId == x.templateId ||
|
|
80
|
+
insertOption.compatibleTemplates?.find(
|
|
81
|
+
(compatibleTemplate) => compatibleTemplate == x.templateId,
|
|
82
|
+
) !== undefined,
|
|
83
|
+
) !== undefined
|
|
84
|
+
}
|
|
85
|
+
renderNode={(node, defaultRenderer) => (
|
|
86
|
+
<div className="group flex w-full gap-4">
|
|
87
|
+
{defaultRenderer(node)}
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|