@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,212 +0,0 @@
|
|
|
1
|
-
import { EditContextType } from "./client/editContext";
|
|
2
|
-
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
3
|
-
|
|
4
|
-
import { FieldDescriptor } from "../types";
|
|
5
|
-
import { Component, FieldButton } from "./pageModel";
|
|
6
|
-
import {
|
|
7
|
-
ContextMenu,
|
|
8
|
-
ContextMenuContent,
|
|
9
|
-
ContextMenuItem,
|
|
10
|
-
ContextMenuSeparator,
|
|
11
|
-
ContextMenuTrigger,
|
|
12
|
-
} from "../components/ui/context-menu";
|
|
13
|
-
import { MenuItem } from "../config/types";
|
|
14
|
-
|
|
15
|
-
// export function getFieldContextMenu(
|
|
16
|
-
// field: Field,
|
|
17
|
-
// editContext: EditContextType,
|
|
18
|
-
// customButtons: EditButton[] = []
|
|
19
|
-
// ) {
|
|
20
|
-
// return (e: any) => {
|
|
21
|
-
// e.preventDefault();
|
|
22
|
-
// e.stopPropagation();
|
|
23
|
-
// const menuItems: MenuItem[] = getComponentMenuItems(
|
|
24
|
-
// editContext,
|
|
25
|
-
// getComponentById(field._editor!.descriptor.item.id, editContext.page!)!
|
|
26
|
-
// );
|
|
27
|
-
|
|
28
|
-
// if (customButtons.length) {
|
|
29
|
-
// if (menuItems.length)
|
|
30
|
-
// menuItems.push({
|
|
31
|
-
// separator: true,
|
|
32
|
-
// });
|
|
33
|
-
|
|
34
|
-
// customButtons.forEach((button) => {
|
|
35
|
-
// menuItems.push({
|
|
36
|
-
// label: button.label,
|
|
37
|
-
// command: (ev) => button.onClick(ev.originalEvent as any),
|
|
38
|
-
// icon: button.icon,
|
|
39
|
-
// });
|
|
40
|
-
// });
|
|
41
|
-
// }
|
|
42
|
-
|
|
43
|
-
// if (field._editor?.buttons?.length) {
|
|
44
|
-
// if (menuItems.length)
|
|
45
|
-
// menuItems.push({
|
|
46
|
-
// separator: true,
|
|
47
|
-
// });
|
|
48
|
-
|
|
49
|
-
// field._editor?.buttons.forEach((button: FieldButton) => {
|
|
50
|
-
// menuItems.push({
|
|
51
|
-
// label: button.label,
|
|
52
|
-
// command: () => {
|
|
53
|
-
// editContext!.triggerFieldAction(field._editor!.descriptor, button);
|
|
54
|
-
// },
|
|
55
|
-
// icon: button.icon ? "pi " + button.icon : undefined,
|
|
56
|
-
// });
|
|
57
|
-
// });
|
|
58
|
-
// }
|
|
59
|
-
|
|
60
|
-
// if (!e.ctrlKey && !e.shiftKey && !e.altKey && menuItems.length) {
|
|
61
|
-
// editContext.select([field._editor!.descriptor.item.id]);
|
|
62
|
-
// editContext!.setFocusedField(field._editor!.descriptor, false);
|
|
63
|
-
// editContext!.showContextMenu(e, menuItems);
|
|
64
|
-
// }
|
|
65
|
-
// };
|
|
66
|
-
// }
|
|
67
|
-
|
|
68
|
-
export async function showComponentContextMenu(
|
|
69
|
-
components: Component[],
|
|
70
|
-
editContext: EditContextType,
|
|
71
|
-
field?: FieldDescriptor,
|
|
72
|
-
fieldButtons?: FieldButton[],
|
|
73
|
-
) {
|
|
74
|
-
const componentCommandMenuItems = await getComponentMenuItems(
|
|
75
|
-
editContext,
|
|
76
|
-
components,
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const menuItems = componentCommandMenuItems;
|
|
80
|
-
|
|
81
|
-
if (!editContext.readonly && field && fieldButtons?.length) {
|
|
82
|
-
if (menuItems.length)
|
|
83
|
-
menuItems.push({
|
|
84
|
-
id: "separator",
|
|
85
|
-
separator: true,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
fieldButtons.forEach((button) => {
|
|
89
|
-
menuItems.push({
|
|
90
|
-
id: button.id,
|
|
91
|
-
label: button.label,
|
|
92
|
-
command: async () => {
|
|
93
|
-
editContext!.triggerFieldAction(field, button);
|
|
94
|
-
},
|
|
95
|
-
icon: button.icon ? <img src={button.icon} width={16} /> : undefined,
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return (e: any) => {
|
|
101
|
-
if (!e.shiftKey && !e.altKey) {
|
|
102
|
-
if (menuItems.length) {
|
|
103
|
-
// editContext.select([component.id]);
|
|
104
|
-
editContext!.showContextMenu(e, menuItems);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface EditContextMenuRef {
|
|
114
|
-
show: (event: any, menuItems: MenuItem[]) => void;
|
|
115
|
-
close: (event: any) => void;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
interface EditContextMenuProps {}
|
|
119
|
-
|
|
120
|
-
export const EditContextMenu = forwardRef<
|
|
121
|
-
EditContextMenuRef,
|
|
122
|
-
EditContextMenuProps
|
|
123
|
-
>((props, ref) => {
|
|
124
|
-
const canvasRef = useRef<HTMLSpanElement>(null);
|
|
125
|
-
|
|
126
|
-
const [menuItems, setMenuItems] = useState<MenuItem[]>([]);
|
|
127
|
-
if (!props) return;
|
|
128
|
-
useImperativeHandle(ref, () => ({
|
|
129
|
-
show: (e: any, items: MenuItem[]) => {
|
|
130
|
-
if (!e.ctrlKey && !e.shiftKey && !e.altKey) {
|
|
131
|
-
setMenuItems(items);
|
|
132
|
-
e.preventDefault();
|
|
133
|
-
triggerRightClick(canvasRef.current!, {
|
|
134
|
-
position: { x: e.clientX, y: e.clientY },
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
close: (event: any) => {
|
|
139
|
-
// cm.current?.hide(event);
|
|
140
|
-
},
|
|
141
|
-
}));
|
|
142
|
-
|
|
143
|
-
const triggerRightClick = (
|
|
144
|
-
element: HTMLSpanElement,
|
|
145
|
-
{ position }: { position: any },
|
|
146
|
-
) => {
|
|
147
|
-
const event = new MouseEvent("contextmenu", {
|
|
148
|
-
bubbles: true,
|
|
149
|
-
cancelable: true,
|
|
150
|
-
clientX: position.x,
|
|
151
|
-
clientY: position.y,
|
|
152
|
-
});
|
|
153
|
-
element.dispatchEvent(event);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<ContextMenu>
|
|
158
|
-
<ContextMenuTrigger>
|
|
159
|
-
<span id="contextmenu_canvas" ref={canvasRef}>
|
|
160
|
-
CM trigger
|
|
161
|
-
</span>
|
|
162
|
-
</ContextMenuTrigger>
|
|
163
|
-
<ContextMenuContent>
|
|
164
|
-
{menuItems.map((item, index) =>
|
|
165
|
-
item.separator ? (
|
|
166
|
-
<ContextMenuSeparator />
|
|
167
|
-
) : (
|
|
168
|
-
<ContextMenuItem
|
|
169
|
-
key={index}
|
|
170
|
-
onClick={(e) => {
|
|
171
|
-
if (item.command) {
|
|
172
|
-
item.command(e);
|
|
173
|
-
}
|
|
174
|
-
// Close the context menu when an item is clicked
|
|
175
|
-
canvasRef.current?.dispatchEvent(
|
|
176
|
-
new KeyboardEvent("keydown", { key: "Escape" }),
|
|
177
|
-
);
|
|
178
|
-
}}
|
|
179
|
-
disabled={item.disabled}
|
|
180
|
-
className="cursor-pointer"
|
|
181
|
-
>
|
|
182
|
-
{item.icon}
|
|
183
|
-
{item.label}
|
|
184
|
-
</ContextMenuItem>
|
|
185
|
-
),
|
|
186
|
-
)}
|
|
187
|
-
</ContextMenuContent>
|
|
188
|
-
</ContextMenu>
|
|
189
|
-
);
|
|
190
|
-
// return <ContextMenu model={menuItems} ref={cm} />;
|
|
191
|
-
});
|
|
192
|
-
async function getComponentMenuItems(
|
|
193
|
-
editContext: EditContextType,
|
|
194
|
-
components: Component[],
|
|
195
|
-
): Promise<MenuItem[]> {
|
|
196
|
-
const componentCommands = await editContext.getComponentCommands(components);
|
|
197
|
-
|
|
198
|
-
const componentCommandMenuItems = componentCommands.map((x) => {
|
|
199
|
-
return {
|
|
200
|
-
id: x.id,
|
|
201
|
-
label: x.label,
|
|
202
|
-
icon: x.icon,
|
|
203
|
-
command: (ev: React.SyntheticEvent) =>
|
|
204
|
-
editContext.executeCommand({
|
|
205
|
-
command: x,
|
|
206
|
-
event: ev,
|
|
207
|
-
}),
|
|
208
|
-
disabled: editContext.isCommandDisabled({ command: x }),
|
|
209
|
-
};
|
|
210
|
-
});
|
|
211
|
-
return componentCommandMenuItems;
|
|
212
|
-
}
|
package/src/editor/Editor.tsx
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { EditorClient } from "./client/EditorClient";
|
|
4
|
-
|
|
5
|
-
import { ItemDescriptor } from "./pageModel";
|
|
6
|
-
import { EditorConfiguration } from "../config/types";
|
|
7
|
-
import { useEffect, useState } from "react";
|
|
8
|
-
import { SystemStatus, UserInfo } from "../types";
|
|
9
|
-
|
|
10
|
-
import { getUserInfo } from "./services/editService";
|
|
11
|
-
import { getSystemStatus } from "./services/systemService";
|
|
12
|
-
import uuid from "react-uuid";
|
|
13
|
-
import { getConfiguration } from "../config/config";
|
|
14
|
-
|
|
15
|
-
export function Editor({
|
|
16
|
-
configure,
|
|
17
|
-
className,
|
|
18
|
-
page,
|
|
19
|
-
}: {
|
|
20
|
-
configure: (props: {
|
|
21
|
-
configuration: EditorConfiguration;
|
|
22
|
-
user: UserInfo;
|
|
23
|
-
}) => EditorConfiguration;
|
|
24
|
-
className?: string;
|
|
25
|
-
page?: ItemDescriptor;
|
|
26
|
-
}) {
|
|
27
|
-
const [config, setConfig] = useState<EditorConfiguration>();
|
|
28
|
-
const [userInfo, setUserInfo] = useState<UserInfo>();
|
|
29
|
-
const [systemStatus, setSystemStatus] = useState<SystemStatus>();
|
|
30
|
-
|
|
31
|
-
const sessionId =
|
|
32
|
-
typeof window !== "undefined"
|
|
33
|
-
? sessionStorage.getItem("sessionId") || uuid()
|
|
34
|
-
: uuid();
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
// Get user info and system status
|
|
38
|
-
getUserInfo().then((userInfo) => {
|
|
39
|
-
if (!userInfo) {
|
|
40
|
-
window.location.href = "/sitecore/login";
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
setUserInfo(userInfo);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
getSystemStatus().then((status) => {
|
|
47
|
-
if (status.data) {
|
|
48
|
-
setSystemStatus(status.data);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}, []);
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (!userInfo || !systemStatus) return;
|
|
55
|
-
|
|
56
|
-
const config = configure({
|
|
57
|
-
configuration: getConfiguration(),
|
|
58
|
-
user: userInfo,
|
|
59
|
-
});
|
|
60
|
-
setConfig(config);
|
|
61
|
-
}, [userInfo, systemStatus]);
|
|
62
|
-
|
|
63
|
-
if (!userInfo || !systemStatus) return null;
|
|
64
|
-
|
|
65
|
-
if (systemStatus.messages.some((m) => m.severity === "error")) {
|
|
66
|
-
return (
|
|
67
|
-
<div className="fixed inset-0 flex flex-col items-center justify-center gap-2 text-sm">
|
|
68
|
-
<h1 className="text-2xl">Please fix the following issues:</h1>
|
|
69
|
-
<div className="text-sm text-red-500">
|
|
70
|
-
{systemStatus.messages.map((m) => (
|
|
71
|
-
<div key={m.message}>{m.message}</div>
|
|
72
|
-
))}
|
|
73
|
-
</div>
|
|
74
|
-
<p>Check the logs for more details.</p>
|
|
75
|
-
</div>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (!config) return null;
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<EditorClient
|
|
83
|
-
configuration={config}
|
|
84
|
-
className={className}
|
|
85
|
-
item={page}
|
|
86
|
-
sessionId={sessionId}
|
|
87
|
-
userInfo={userInfo}
|
|
88
|
-
></EditorClient>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { classNames } from "primereact/utils";
|
|
2
|
-
|
|
3
|
-
export function EditorWarning({
|
|
4
|
-
title,
|
|
5
|
-
severity = "warning",
|
|
6
|
-
children,
|
|
7
|
-
}: {
|
|
8
|
-
title: string;
|
|
9
|
-
severity?: "info" | "error" | "warning";
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
}) {
|
|
12
|
-
const background =
|
|
13
|
-
severity === "info"
|
|
14
|
-
? "bg-blue-100"
|
|
15
|
-
: severity === "error"
|
|
16
|
-
? "bg-red-100"
|
|
17
|
-
: "bg-yellow-100";
|
|
18
|
-
return (
|
|
19
|
-
<div
|
|
20
|
-
className={classNames(
|
|
21
|
-
background,
|
|
22
|
-
"text-sm text-gray-500 border-b border-yellow-300 flex gap-2 items-stretch"
|
|
23
|
-
)}
|
|
24
|
-
>
|
|
25
|
-
<div className="bg-yellow-200 px-4 flex items-center text-gray-900">
|
|
26
|
-
<span className="pi pi-exclamation-triangle text-2xl" />
|
|
27
|
-
</div>
|
|
28
|
-
<div className="p-2">
|
|
29
|
-
<div className="font-bold">{title}</div>
|
|
30
|
-
<div className="text-xs">{children}</div>
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { EditContextType, useEditContext } from "./client/editContext";
|
|
4
|
-
|
|
5
|
-
import { FullItem } from "./pageModel";
|
|
6
|
-
|
|
7
|
-
export type EditorWarningProps = {
|
|
8
|
-
item: FullItem;
|
|
9
|
-
editContext: EditContextType;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export function EditorWarnings({ item }: { item?: FullItem }) {
|
|
13
|
-
var context = useEditContext();
|
|
14
|
-
if (!context || context.mode === "preview") return;
|
|
15
|
-
|
|
16
|
-
if (!item) {
|
|
17
|
-
item = context.page?.item;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!item) return;
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div className="z-50 w-full">
|
|
24
|
-
{context.configuration.editorWarnings.map((x, i) =>
|
|
25
|
-
React.createElement(x, {
|
|
26
|
-
item,
|
|
27
|
-
key: "warning" + i,
|
|
28
|
-
editContext: context!,
|
|
29
|
-
}),
|
|
30
|
-
)}
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { OverlayPanel } from "primereact/overlaypanel";
|
|
4
|
-
import {
|
|
5
|
-
SyntheticEvent,
|
|
6
|
-
forwardRef,
|
|
7
|
-
useImperativeHandle,
|
|
8
|
-
useRef,
|
|
9
|
-
useState,
|
|
10
|
-
} from "react";
|
|
11
|
-
|
|
12
|
-
import { FieldList } from "./FieldList";
|
|
13
|
-
import { Field } from "./pageModel";
|
|
14
|
-
|
|
15
|
-
export interface FieldEditorPopupRef {
|
|
16
|
-
show: (fields: Field[], sections: string[], event: SyntheticEvent) => void;
|
|
17
|
-
close: () => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface FieldEditorPopupProps {}
|
|
21
|
-
|
|
22
|
-
export const FieldEditorPopup = forwardRef<
|
|
23
|
-
FieldEditorPopupRef,
|
|
24
|
-
FieldEditorPopupProps
|
|
25
|
-
>((_, ref) => {
|
|
26
|
-
const overlayRef = useRef<OverlayPanel>(null);
|
|
27
|
-
|
|
28
|
-
const [sections, setSections] = useState<string[]>([]);
|
|
29
|
-
const [fields, setFields] = useState<Field[]>([]);
|
|
30
|
-
|
|
31
|
-
useImperativeHandle(ref, () => ({
|
|
32
|
-
show: (fields: Field[], sections: string[], ev: SyntheticEvent) => {
|
|
33
|
-
setFields(fields);
|
|
34
|
-
setSections(sections);
|
|
35
|
-
overlayRef.current?.toggle(ev, ev.target);
|
|
36
|
-
},
|
|
37
|
-
close: () => {
|
|
38
|
-
overlayRef.current?.hide();
|
|
39
|
-
},
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<OverlayPanel ref={overlayRef}>
|
|
44
|
-
<div
|
|
45
|
-
className="w-96 h-96 flex flex-col gap-2 overflow-auto"
|
|
46
|
-
onClick={(ev) => ev.stopPropagation()}
|
|
47
|
-
>
|
|
48
|
-
<div className="flex justify-end p-3">
|
|
49
|
-
<i
|
|
50
|
-
className="pi pi-times cursor-pointer"
|
|
51
|
-
onClick={() => overlayRef?.current?.hide()}
|
|
52
|
-
/>
|
|
53
|
-
</div>
|
|
54
|
-
|
|
55
|
-
{fields && (
|
|
56
|
-
<FieldList
|
|
57
|
-
fields={[{ fields }]}
|
|
58
|
-
sections={sections}
|
|
59
|
-
validators={[]}
|
|
60
|
-
/>
|
|
61
|
-
)}
|
|
62
|
-
</div>
|
|
63
|
-
</OverlayPanel>
|
|
64
|
-
);
|
|
65
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Field } from "../editor/pageModel";
|
|
2
|
-
import { FieldHistoryItem } from "../types";
|
|
3
|
-
import { getFieldHistory } from "../editor/services/editService";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
import { useState } from "react";
|
|
6
|
-
|
|
7
|
-
import { useEditContext } from "./client/editContext";
|
|
8
|
-
import { formatDate } from "./utils";
|
|
9
|
-
import { SimpleTable } from "./ui/SimpleTable";
|
|
10
|
-
import { SimpleIconButton } from "./ui/SimpleIconButton";
|
|
11
|
-
|
|
12
|
-
export function FieldHistory({
|
|
13
|
-
field,
|
|
14
|
-
onHover,
|
|
15
|
-
}: {
|
|
16
|
-
field: Field;
|
|
17
|
-
onHover: (historyEntry: FieldHistoryItem | undefined) => void;
|
|
18
|
-
}) {
|
|
19
|
-
const [fieldHistory, setFieldHistory] = useState<FieldHistoryItem[]>([]);
|
|
20
|
-
const editContext = useEditContext();
|
|
21
|
-
|
|
22
|
-
if (!editContext) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
getFieldHistory(field.descriptor.item, field.id).then((result) => {
|
|
28
|
-
setFieldHistory(result.data ?? []);
|
|
29
|
-
});
|
|
30
|
-
}, [field]);
|
|
31
|
-
|
|
32
|
-
if (fieldHistory.length === 0)
|
|
33
|
-
return <div className="p-2 text-gray-500 text-xs">No history</div>;
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div>
|
|
37
|
-
<div className="text-xs p-2 bg-gray-100 text-gray-500">
|
|
38
|
-
Field History
|
|
39
|
-
</div>
|
|
40
|
-
<div className="max-h-96 overflow-auto">
|
|
41
|
-
<SimpleTable
|
|
42
|
-
items={fieldHistory}
|
|
43
|
-
onRowHover={onHover}
|
|
44
|
-
rowClassName={(x) =>
|
|
45
|
-
x.undone
|
|
46
|
-
? "text-gray-300 cursor-pointer hover:bg-gray-50 "
|
|
47
|
-
: "cursor-pointer hover:bg-gray-50"
|
|
48
|
-
}
|
|
49
|
-
columns={[
|
|
50
|
-
{ header: "Date", body: (x) => formatDate(new Date(x.date)) },
|
|
51
|
-
{ header: "User", body: (x) => x.user },
|
|
52
|
-
{ header: "Version", body: (x) => x.version },
|
|
53
|
-
{
|
|
54
|
-
header: "Revert",
|
|
55
|
-
body: (x) => (
|
|
56
|
-
<SimpleIconButton
|
|
57
|
-
icon="pi pi-undo"
|
|
58
|
-
onClick={() =>
|
|
59
|
-
editContext.operations.editField({
|
|
60
|
-
field: field.descriptor,
|
|
61
|
-
rawValue: x.rawValue,
|
|
62
|
-
refresh: "immediate",
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
label="Revert"
|
|
66
|
-
/>
|
|
67
|
-
),
|
|
68
|
-
},
|
|
69
|
-
]}
|
|
70
|
-
/>
|
|
71
|
-
</div>
|
|
72
|
-
</div>
|
|
73
|
-
);
|
|
74
|
-
}
|
package/src/editor/FieldList.tsx
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { Section } from "./ui/Section";
|
|
4
|
-
import { useEditContext } from "./client/editContext";
|
|
5
|
-
import { FieldListFieldWithFallbacks } from "./FieldListFieldWithFallbacks";
|
|
6
|
-
import { SingleValidatorResult } from "../types";
|
|
7
|
-
import { Field } from "./pageModel";
|
|
8
|
-
import { InputText } from "primereact/inputtext";
|
|
9
|
-
import { Fragment, useState } from "react";
|
|
10
|
-
import { Checkbox } from "primereact/checkbox";
|
|
11
|
-
import uuid from "react-uuid";
|
|
12
|
-
import { SimpleIconButton } from "./ui/SimpleIconButton";
|
|
13
|
-
|
|
14
|
-
export type ItemFields = {
|
|
15
|
-
headline?: string;
|
|
16
|
-
fields: Field[];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export function FieldList({
|
|
20
|
-
fields,
|
|
21
|
-
compareToFields,
|
|
22
|
-
sections,
|
|
23
|
-
validators,
|
|
24
|
-
filter,
|
|
25
|
-
simplified,
|
|
26
|
-
showStandardFieldsEnabled,
|
|
27
|
-
readonly,
|
|
28
|
-
}: {
|
|
29
|
-
fields: ItemFields[];
|
|
30
|
-
compareToFields?: Field[];
|
|
31
|
-
sections?: string[];
|
|
32
|
-
validators: SingleValidatorResult[];
|
|
33
|
-
filter?: (field: Field) => boolean;
|
|
34
|
-
simplified?: boolean;
|
|
35
|
-
showStandardFieldsEnabled?: boolean;
|
|
36
|
-
readonly?: boolean;
|
|
37
|
-
}) {
|
|
38
|
-
const editContext = useEditContext();
|
|
39
|
-
|
|
40
|
-
const [searchFilter, setSearchFilter] = useState<string>("");
|
|
41
|
-
const [showStandardFields, setShowStandardFields] = useState<boolean>(false);
|
|
42
|
-
const uniqueId = uuid();
|
|
43
|
-
|
|
44
|
-
if (!editContext) return;
|
|
45
|
-
if (!fields) return;
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div>
|
|
49
|
-
<div className="tour-field-list sticky top-0 z-10 ml-[1px] flex items-center gap-2 border-y border-gray-200 bg-gray-50 p-2">
|
|
50
|
-
<i className="pi pi-search" />
|
|
51
|
-
<div className="text-xs">Filter</div>
|
|
52
|
-
<InputText
|
|
53
|
-
className="flex-1 text-xs"
|
|
54
|
-
value={searchFilter}
|
|
55
|
-
onChange={(x) => setSearchFilter(x.target.value)}
|
|
56
|
-
/>
|
|
57
|
-
{searchFilter && (
|
|
58
|
-
<SimpleIconButton
|
|
59
|
-
icon="pi pi-times"
|
|
60
|
-
onClick={() => setSearchFilter("")}
|
|
61
|
-
className="text-xs"
|
|
62
|
-
label="Clear"
|
|
63
|
-
/>
|
|
64
|
-
)}
|
|
65
|
-
{showStandardFieldsEnabled && (
|
|
66
|
-
<>
|
|
67
|
-
<Checkbox
|
|
68
|
-
inputId={uniqueId}
|
|
69
|
-
checked={showStandardFields}
|
|
70
|
-
onChange={(e: any) => setShowStandardFields(e.checked)}
|
|
71
|
-
/>{" "}
|
|
72
|
-
<label htmlFor={uniqueId} className="cursor-pointer text-xs">
|
|
73
|
-
Show standard fields
|
|
74
|
-
</label>
|
|
75
|
-
</>
|
|
76
|
-
)}
|
|
77
|
-
</div>
|
|
78
|
-
|
|
79
|
-
{fields.map((itemFields, index) => (
|
|
80
|
-
<Fragment key={index}>
|
|
81
|
-
{itemFields.headline && (
|
|
82
|
-
<div className="mt-2 flex items-center gap-1 border-b py-2 text-sm">
|
|
83
|
-
<i className="pi pi-angle-right" /> {itemFields.headline}
|
|
84
|
-
</div>
|
|
85
|
-
)}
|
|
86
|
-
<FieldListForSingleItem
|
|
87
|
-
key={index}
|
|
88
|
-
fields={itemFields.fields}
|
|
89
|
-
validators={validators}
|
|
90
|
-
filter={filter}
|
|
91
|
-
searchFilter={searchFilter}
|
|
92
|
-
showStandardFields={showStandardFields}
|
|
93
|
-
simplified={simplified}
|
|
94
|
-
sections={sections}
|
|
95
|
-
compareToFields={compareToFields}
|
|
96
|
-
readonly={readonly}
|
|
97
|
-
/>
|
|
98
|
-
</Fragment>
|
|
99
|
-
))}
|
|
100
|
-
</div>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function FieldListForSingleItem({
|
|
105
|
-
fields,
|
|
106
|
-
validators,
|
|
107
|
-
filter,
|
|
108
|
-
searchFilter,
|
|
109
|
-
simplified,
|
|
110
|
-
sections,
|
|
111
|
-
showStandardFields,
|
|
112
|
-
compareToFields,
|
|
113
|
-
readonly,
|
|
114
|
-
}: {
|
|
115
|
-
fields: Field[];
|
|
116
|
-
validators: SingleValidatorResult[];
|
|
117
|
-
filter?: (field: Field) => boolean;
|
|
118
|
-
searchFilter?: string;
|
|
119
|
-
simplified?: boolean;
|
|
120
|
-
sections?: string[];
|
|
121
|
-
showStandardFields?: boolean;
|
|
122
|
-
compareToFields?: Field[];
|
|
123
|
-
readonly?: boolean;
|
|
124
|
-
}) {
|
|
125
|
-
let fieldsArray = Array.isArray(fields)
|
|
126
|
-
? (fields as Field[])
|
|
127
|
-
: (Object.values(fields) as Field[]);
|
|
128
|
-
|
|
129
|
-
if (filter) fieldsArray = fieldsArray.filter(filter);
|
|
130
|
-
|
|
131
|
-
if (searchFilter) {
|
|
132
|
-
const searchFilterLower = searchFilter.toLowerCase();
|
|
133
|
-
fieldsArray = fieldsArray.filter(
|
|
134
|
-
(x) =>
|
|
135
|
-
x.name?.toLowerCase().includes(searchFilterLower) ||
|
|
136
|
-
x.displayName?.toLowerCase().includes(searchFilterLower),
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (!showStandardFields) {
|
|
141
|
-
fieldsArray = fieldsArray.filter((x) => !x.name?.startsWith("__"));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const sectionsGrouping = fieldsArray.reduce((acc, value) => {
|
|
145
|
-
// Group initialization
|
|
146
|
-
const section = value.section || "";
|
|
147
|
-
|
|
148
|
-
if (value.descriptor.item.id)
|
|
149
|
-
if (!acc[section]) {
|
|
150
|
-
acc[section] = [];
|
|
151
|
-
}
|
|
152
|
-
// Grouping
|
|
153
|
-
acc[section].push(value);
|
|
154
|
-
|
|
155
|
-
return acc;
|
|
156
|
-
}, {} as any);
|
|
157
|
-
|
|
158
|
-
const sectionList: Field[][] = Object.values(sectionsGrouping);
|
|
159
|
-
sectionList.sort(
|
|
160
|
-
(a: Field[], b: Field[]) =>
|
|
161
|
-
(a[0]?.sectionSortOrder || 0) - (b[0]?.sectionSortOrder || 0),
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
function getSectionFields(fields: Field[]) {
|
|
165
|
-
fields.sort((a: any, b: any) => a?.sortOrder - b?.sortOrder);
|
|
166
|
-
|
|
167
|
-
return fields.map((field) => (
|
|
168
|
-
<FieldListFieldWithFallbacks
|
|
169
|
-
key={field.id}
|
|
170
|
-
fieldDescriptor={field.descriptor}
|
|
171
|
-
simplified={simplified}
|
|
172
|
-
validators={validators.filter((x) => x.fieldId === field.id)}
|
|
173
|
-
compareToField={compareToFields?.find((x) => x.id === field.id)}
|
|
174
|
-
readonly={readonly}
|
|
175
|
-
/>
|
|
176
|
-
));
|
|
177
|
-
}
|
|
178
|
-
return sectionList
|
|
179
|
-
.map((x) => x[0]?.section)
|
|
180
|
-
.filter((x) => !sections || sections.includes(x!))
|
|
181
|
-
.map((section) =>
|
|
182
|
-
simplified ? (
|
|
183
|
-
getSectionFields(sectionsGrouping[section!])
|
|
184
|
-
) : (
|
|
185
|
-
<Section key={section} title={section!}>
|
|
186
|
-
{getSectionFields(sectionsGrouping[section!])}
|
|
187
|
-
</Section>
|
|
188
|
-
),
|
|
189
|
-
);
|
|
190
|
-
}
|