@alpaca-editor/core 1.0.3938 → 1.0.3941
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/ContentTree.js +12 -8
- package/dist/editor/ContentTree.js.map +1 -1
- package/dist/editor/ContextMenu.d.ts +1 -1
- package/dist/editor/ContextMenu.js +17 -3
- package/dist/editor/ContextMenu.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.d.ts +18 -0
- package/dist/editor/FieldActionsOverlay.js +139 -0
- package/dist/editor/FieldActionsOverlay.js.map +1 -0
- package/dist/editor/FieldHistory.d.ts +2 -1
- package/dist/editor/FieldHistory.js +11 -8
- package/dist/editor/FieldHistory.js.map +1 -1
- package/dist/editor/FieldListField.js +14 -17
- package/dist/editor/FieldListField.js.map +1 -1
- package/dist/editor/PictureCropper.js +65 -23
- package/dist/editor/PictureCropper.js.map +1 -1
- package/dist/editor/PictureEditor.js +43 -3
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/Titlebar.js +19 -10
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/AiTerminal.js +27 -41
- package/dist/editor/ai/AiTerminal.js.map +1 -1
- package/dist/editor/ai/GhostWriter.js +21 -2
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/client/EditorClient.js +48 -18
- package/dist/editor/client/EditorClient.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +1 -1
- package/dist/editor/client/editContext.js.map +1 -1
- package/dist/editor/client/itemsRepository.js +126 -90
- package/dist/editor/client/itemsRepository.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 +3 -4
- package/dist/editor/menubar/BrowseHistory.js.map +1 -1
- package/dist/editor/menubar/PageSelector.js +62 -10
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicator.js +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicator.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/page-viewer/PageViewerFrame.js +98 -2
- package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
- package/dist/editor/pageModel.d.ts +14 -0
- package/dist/editor/reviews/Comment.js +3 -2
- 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/services/editService.d.ts +1 -1
- package/dist/editor/services/editService.js +2 -1
- package/dist/editor/services/editService.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/Icons.js +1 -1
- package/dist/editor/ui/Icons.js.map +1 -1
- package/dist/editor/ui/ItemList.d.ts +16 -0
- package/dist/editor/ui/ItemList.js +19 -0
- package/dist/editor/ui/ItemList.js.map +1 -0
- package/dist/editor/ui/ItemSearch.js +2 -12
- package/dist/editor/ui/ItemSearch.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 +64 -13
- 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 -727
- package/src/editor/ContextMenu.tsx +0 -212
- package/src/editor/Editor.tsx +0 -90
- package/src/editor/EditorWarning.tsx +0 -34
- package/src/editor/EditorWarnings.tsx +0 -33
- package/src/editor/FieldEditorPopup.tsx +0 -65
- package/src/editor/FieldHistory.tsx +0 -74
- 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 -212
- 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 -93
- package/src/editor/ai/AiPopup.tsx +0 -59
- package/src/editor/ai/AiResponseMessage.tsx +0 -106
- package/src/editor/ai/AiTerminal.tsx +0 -514
- 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 -2197
- package/src/editor/client/GenericDialog.tsx +0 -50
- package/src/editor/client/editContext.ts +0 -412
- package/src/editor/client/helpers.ts +0 -44
- package/src/editor/client/itemsRepository.ts +0 -538
- 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 -37
- 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 -141
- 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 -879
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
- package/src/editor/page-viewer/pageViewContext.ts +0 -186
- package/src/editor/pageModel.ts +0 -208
- package/src/editor/picture-shared.tsx +0 -53
- package/src/editor/reviews/Comment.tsx +0 -308
- 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 -486
- 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 -708
- package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
- package/src/editor/ui/ItemSearch.tsx +0 -190
- 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,261 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
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, showOnlyMyChanges]);
|
|
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
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
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="relative flex-1">
|
|
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 items-center justify-center gap-4 border-b border-gray-200 py-3 text-sm"
|
|
31
|
-
activeTab={activeTab}
|
|
32
|
-
setActiveTab={(index) => setActiveTab(index)}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { useCallback, 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
|
-
const isDraggable = useCallback(
|
|
25
|
-
(x: ItemTreeNodeData) => {
|
|
26
|
-
return (
|
|
27
|
-
mode === "insert" &&
|
|
28
|
-
insertOptions?.find(
|
|
29
|
-
(insertOption: InsertOption) =>
|
|
30
|
-
insertOption.typeId == x.templateId ||
|
|
31
|
-
insertOption.compatibleTypeIds?.find(
|
|
32
|
-
(compatibleTemplate) => compatibleTemplate == x.templateId,
|
|
33
|
-
) !== undefined,
|
|
34
|
-
) !== undefined
|
|
35
|
-
);
|
|
36
|
-
},
|
|
37
|
-
[mode, insertOptions],
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (selectedItem) setSelectedItemIds([selectedItem.id]);
|
|
42
|
-
}, [selectedItem]);
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
const loadInsertOptions = async () => {
|
|
46
|
-
if (!page) return;
|
|
47
|
-
const options = await getInsertOptionsForCurrentSelection(editContext);
|
|
48
|
-
setInsertOptions(options);
|
|
49
|
-
};
|
|
50
|
-
loadInsertOptions();
|
|
51
|
-
}, [editContext.selection, page]);
|
|
52
|
-
return (
|
|
53
|
-
<div className="flex h-full flex-col">
|
|
54
|
-
<div className="border-b border-gray-200 p-2">
|
|
55
|
-
<ItemSearch
|
|
56
|
-
resultClassName="px-2 py-1"
|
|
57
|
-
itemSelected={(item) =>
|
|
58
|
-
editContext?.loadItem({
|
|
59
|
-
id: item.id,
|
|
60
|
-
language: item.language,
|
|
61
|
-
version: 0,
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
/>
|
|
65
|
-
</div>
|
|
66
|
-
<div className="relative flex-1">
|
|
67
|
-
<div className="absolute inset-1 overflow-auto">
|
|
68
|
-
<ContentTree
|
|
69
|
-
language={editContext.currentItemDescriptor?.language ?? "en"}
|
|
70
|
-
rootItemId={rootItemId ?? "{11111111-1111-1111-1111-111111111111}"}
|
|
71
|
-
expandIdPath={
|
|
72
|
-
selectedItem?.idPath
|
|
73
|
-
? selectedItem?.idPath.split("/").slice(0, -1).join("/")
|
|
74
|
-
: undefined
|
|
75
|
-
}
|
|
76
|
-
className="h-full"
|
|
77
|
-
selectPagesOnly={mode === "select-page"}
|
|
78
|
-
selectionMode={mode == "insert" ? "none" : "multiple"}
|
|
79
|
-
selectedItemIds={selectedItemIds}
|
|
80
|
-
onSelectionChange={(selection) => {
|
|
81
|
-
if (mode === "insert") return;
|
|
82
|
-
const selectedItems = selection as ItemTreeNodeData[];
|
|
83
|
-
setSelectedItemIds(selectedItems.map((x) => x.id));
|
|
84
|
-
if (selectedItems.length > 0 && selectedItems[0])
|
|
85
|
-
editContext.loadItem({
|
|
86
|
-
id: selectedItems[0].id,
|
|
87
|
-
language: selectedItems[0].language,
|
|
88
|
-
version: selectedItems[0].version,
|
|
89
|
-
});
|
|
90
|
-
}}
|
|
91
|
-
isDraggable={isDraggable}
|
|
92
|
-
renderNode={(node, defaultRenderer) => (
|
|
93
|
-
<div className="group flex w-full gap-4">
|
|
94
|
-
{defaultRenderer(node)}
|
|
95
|
-
</div>
|
|
96
|
-
)}
|
|
97
|
-
/>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
101
|
-
);
|
|
102
|
-
}
|