@alpaca-editor/core 1.0.3939 → 1.0.3942
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ActionButton.d.ts +1 -0
- package/dist/components/ActionButton.js +2 -2
- package/dist/components/ActionButton.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.d.ts +1 -0
- package/dist/editor/FieldActionsOverlay.js +2 -11
- package/dist/editor/FieldActionsOverlay.js.map +1 -1
- package/dist/editor/PictureCropper.js +65 -23
- package/dist/editor/PictureCropper.js.map +1 -1
- package/dist/editor/PictureEditor.js +16 -2
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/Titlebar.js +1 -1
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/GhostWriter.js +21 -2
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/commands/componentCommands.js +7 -3
- package/dist/editor/commands/componentCommands.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.d.ts +5 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js +77 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -0
- package/dist/editor/media-selector/MediaSelector.js +1 -1
- package/dist/editor/media-selector/MediaSelector.js.map +1 -1
- package/dist/editor/media-selector/Thumbnails.js +2 -2
- package/dist/editor/media-selector/index.d.ts +8 -0
- package/dist/editor/media-selector/index.js +9 -0
- package/dist/editor/media-selector/index.js.map +1 -0
- package/dist/editor/menubar/BrowseHistory.js +1 -1
- package/dist/editor/menubar/PageSelector.js +39 -15
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js +37 -11
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
- package/dist/editor/reviews/Comment.js +1 -1
- package/dist/editor/reviews/Comment.js.map +1 -1
- package/dist/editor/services/aiService.js +0 -1
- package/dist/editor/services/aiService.js.map +1 -1
- package/dist/editor/sidebar/ComponentTree.js +3 -4
- package/dist/editor/sidebar/ComponentTree.js.map +1 -1
- package/dist/editor/ui/SimpleTabs.d.ts +1 -0
- package/dist/editor/ui/SimpleTabs.js +3 -3
- package/dist/editor/ui/SimpleTabs.js.map +1 -1
- package/dist/editor/ui/Splitter.js +61 -6
- package/dist/editor/ui/Splitter.js.map +1 -1
- package/dist/editor/views/MediaFolderEditView.d.ts +4 -0
- package/dist/editor/views/MediaFolderEditView.js +40 -0
- package/dist/editor/views/MediaFolderEditView.js.map +1 -0
- package/dist/editor/views/SingleEditView.js +9 -1
- package/dist/editor/views/SingleEditView.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +61 -5
- package/package.json +8 -2
- package/.prettierrc +0 -3
- package/build.css +0 -3
- package/components.json +0 -21
- package/eslint.config.mjs +0 -4
- package/images/bg-shape-black.webp +0 -0
- package/images/wizard-bg.png +0 -0
- package/images/wizard-tour.png +0 -0
- package/images/wizard.png +0 -0
- package/src/client-components/api.ts +0 -6
- package/src/client-components/index.ts +0 -19
- package/src/components/ActionButton.tsx +0 -41
- package/src/components/Error.tsx +0 -57
- package/src/components/ui/CardConnector.tsx +0 -56
- package/src/components/ui/button.tsx +0 -62
- package/src/components/ui/card.tsx +0 -372
- package/src/components/ui/context-menu.tsx +0 -250
- package/src/config/config.tsx +0 -917
- package/src/config/types.ts +0 -286
- package/src/editor/ComponentInfo.tsx +0 -90
- package/src/editor/ConfirmationDialog.tsx +0 -103
- package/src/editor/ContentTree.tsx +0 -730
- package/src/editor/ContextMenu.tsx +0 -230
- package/src/editor/Editor.tsx +0 -90
- package/src/editor/EditorWarning.tsx +0 -34
- package/src/editor/EditorWarnings.tsx +0 -33
- package/src/editor/FieldActionsOverlay.tsx +0 -307
- package/src/editor/FieldEditorPopup.tsx +0 -65
- package/src/editor/FieldHistory.tsx +0 -75
- package/src/editor/FieldList.tsx +0 -190
- package/src/editor/FieldListField.tsx +0 -391
- package/src/editor/FieldListFieldWithFallbacks.tsx +0 -217
- package/src/editor/FloatingToolbar.tsx +0 -163
- package/src/editor/ImageEditor.tsx +0 -128
- package/src/editor/ItemInfo.tsx +0 -90
- package/src/editor/LinkEditorDialog.tsx +0 -196
- package/src/editor/MainLayout.tsx +0 -95
- package/src/editor/MobileLayout.tsx +0 -68
- package/src/editor/NewEditorClient.tsx +0 -11
- package/src/editor/PictureCropper.tsx +0 -503
- package/src/editor/PictureEditor.tsx +0 -277
- package/src/editor/PictureEditorDialog.tsx +0 -381
- package/src/editor/PublishDialog.ignore +0 -74
- package/src/editor/ScrollingContentTree.tsx +0 -67
- package/src/editor/Terminal.tsx +0 -227
- package/src/editor/Titlebar.tsx +0 -104
- package/src/editor/ai/AiPopup.tsx +0 -59
- package/src/editor/ai/AiResponseMessage.tsx +0 -106
- package/src/editor/ai/AiTerminal.tsx +0 -503
- package/src/editor/ai/AiToolCall.tsx +0 -61
- package/src/editor/ai/EditorAiTerminal.tsx +0 -20
- package/src/editor/ai/GhostWriter.tsx +0 -432
- package/src/editor/ai/aiPageModel.ts +0 -108
- package/src/editor/ai/editorAiContext.ts +0 -18
- package/src/editor/client/AboutDialog.tsx +0 -44
- package/src/editor/client/EditorClient.tsx +0 -2241
- package/src/editor/client/GenericDialog.tsx +0 -50
- package/src/editor/client/editContext.ts +0 -416
- package/src/editor/client/helpers.ts +0 -44
- package/src/editor/client/itemsRepository.ts +0 -574
- package/src/editor/client/operations.ts +0 -768
- package/src/editor/client/pageModelBuilder.ts +0 -219
- package/src/editor/commands/commands.ts +0 -22
- package/src/editor/commands/componentCommands.tsx +0 -424
- package/src/editor/commands/createVersionCommand.ts +0 -33
- package/src/editor/commands/deleteVersionCommand.ts +0 -71
- package/src/editor/commands/itemCommands.tsx +0 -351
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +0 -201
- package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +0 -27
- package/src/editor/commands/undo.ts +0 -39
- package/src/editor/component-designer/ComponentDesigner.tsx +0 -70
- package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +0 -11
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +0 -91
- package/src/editor/component-designer/ComponentEditor.tsx +0 -97
- package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +0 -31
- package/src/editor/component-designer/ComponentRenderingEditor.tsx +0 -104
- package/src/editor/component-designer/ComponentsDropdown.tsx +0 -39
- package/src/editor/component-designer/PlaceholdersEditor.tsx +0 -179
- package/src/editor/component-designer/RenderingsDropdown.tsx +0 -36
- package/src/editor/component-designer/TemplateEditor.tsx +0 -236
- package/src/editor/component-designer/aiContext.ts +0 -23
- package/src/editor/componentTreeHelper.tsx +0 -116
- package/src/editor/context-menu/CopyMoveMenu.tsx +0 -103
- package/src/editor/context-menu/InsertMenu.tsx +0 -347
- package/src/editor/control-center/About.tsx +0 -342
- package/src/editor/control-center/ControlCenterMenu.tsx +0 -76
- package/src/editor/control-center/IndexOverview.tsx +0 -50
- package/src/editor/control-center/IndexSettings.tsx +0 -266
- package/src/editor/control-center/Info.tsx +0 -104
- package/src/editor/control-center/QuotaInfo.tsx +0 -301
- package/src/editor/control-center/Status.tsx +0 -113
- package/src/editor/control-center/WebSocketMessages.tsx +0 -155
- package/src/editor/editor-warnings/ItemLocked.tsx +0 -63
- package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +0 -22
- package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +0 -23
- package/src/editor/editor-warnings/NoWriteAccess.tsx +0 -16
- package/src/editor/editor-warnings/ValidationErrors.tsx +0 -54
- package/src/editor/field-types/AttachmentEditor.tsx +0 -9
- package/src/editor/field-types/CheckboxEditor.tsx +0 -47
- package/src/editor/field-types/DropLinkEditor.tsx +0 -80
- package/src/editor/field-types/DropListEditor.tsx +0 -84
- package/src/editor/field-types/ImageFieldEditor.tsx +0 -65
- package/src/editor/field-types/InternalLinkFieldEditor.tsx +0 -117
- package/src/editor/field-types/LinkFieldEditor.tsx +0 -85
- package/src/editor/field-types/MultiLineText.tsx +0 -82
- package/src/editor/field-types/PictureFieldEditor.tsx +0 -121
- package/src/editor/field-types/RawEditor.tsx +0 -53
- package/src/editor/field-types/ReactQuill.tsx +0 -580
- package/src/editor/field-types/RichTextEditor.tsx +0 -22
- package/src/editor/field-types/RichTextEditorComponent.tsx +0 -127
- package/src/editor/field-types/SingleLineText.tsx +0 -174
- package/src/editor/field-types/TreeListEditor.tsx +0 -261
- package/src/editor/fieldTypes.ts +0 -140
- package/src/editor/media-selector/AiImageSearch.tsx +0 -185
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +0 -94
- package/src/editor/media-selector/MediaSelector.tsx +0 -42
- package/src/editor/media-selector/Preview.tsx +0 -14
- package/src/editor/media-selector/Thumbnails.tsx +0 -48
- package/src/editor/media-selector/TreeSelector.tsx +0 -292
- package/src/editor/media-selector/UploadZone.tsx +0 -137
- package/src/editor/menubar/ActionsMenu.tsx +0 -94
- package/src/editor/menubar/ActiveUsers.tsx +0 -17
- package/src/editor/menubar/ApproveAndPublish.tsx +0 -18
- package/src/editor/menubar/BrowseHistory.tsx +0 -28
- package/src/editor/menubar/ItemLanguageVersion.tsx +0 -76
- package/src/editor/menubar/LanguageSelector.tsx +0 -226
- package/src/editor/menubar/Menu.tsx +0 -83
- package/src/editor/menubar/NavButtons.tsx +0 -74
- package/src/editor/menubar/PageSelector.tsx +0 -166
- package/src/editor/menubar/PageViewerControls.tsx +0 -120
- package/src/editor/menubar/PreviewSecondaryControls.tsx +0 -18
- package/src/editor/menubar/SecondaryControls.tsx +0 -45
- package/src/editor/menubar/Separator.tsx +0 -12
- package/src/editor/menubar/SiteInfo.tsx +0 -53
- package/src/editor/menubar/User.tsx +0 -27
- package/src/editor/menubar/VersionSelector.tsx +0 -142
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +0 -307
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +0 -35
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +0 -59
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +0 -23
- package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +0 -64
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +0 -35
- package/src/editor/page-editor-chrome/FrameMenu.tsx +0 -338
- package/src/editor/page-editor-chrome/FrameMenus.tsx +0 -48
- package/src/editor/page-editor-chrome/InlineEditor.tsx +0 -765
- package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +0 -61
- package/src/editor/page-editor-chrome/NoLayout.tsx +0 -36
- package/src/editor/page-editor-chrome/PageEditorChrome.tsx +0 -122
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +0 -161
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +0 -169
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +0 -315
- package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +0 -300
- package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +0 -40
- package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +0 -791
- package/src/editor/page-viewer/DeviceToolbar.tsx +0 -70
- package/src/editor/page-viewer/EditorForm.tsx +0 -258
- package/src/editor/page-viewer/MiniMap.tsx +0 -362
- package/src/editor/page-viewer/PageViewer.tsx +0 -169
- package/src/editor/page-viewer/PageViewerFrame.tsx +0 -1022
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
- package/src/editor/page-viewer/pageViewContext.ts +0 -186
- package/src/editor/pageModel.ts +0 -220
- package/src/editor/picture-shared.tsx +0 -53
- package/src/editor/reviews/Comment.tsx +0 -307
- package/src/editor/reviews/Comments.tsx +0 -125
- package/src/editor/reviews/DiffView.tsx +0 -109
- package/src/editor/reviews/PreviewInfo.tsx +0 -35
- package/src/editor/reviews/Reviews.tsx +0 -280
- package/src/editor/reviews/SuggestedEdit.tsx +0 -316
- package/src/editor/reviews/reviewCommands.tsx +0 -47
- package/src/editor/reviews/useReviews.tsx +0 -70
- package/src/editor/services/aiService.ts +0 -174
- package/src/editor/services/componentDesignerService.ts +0 -151
- package/src/editor/services/contentService.ts +0 -180
- package/src/editor/services/editService.ts +0 -488
- package/src/editor/services/indexService.ts +0 -24
- package/src/editor/services/reviewsService.ts +0 -53
- package/src/editor/services/serviceHelper.ts +0 -95
- package/src/editor/services/suggestedEditsService.ts +0 -39
- package/src/editor/services/systemService.ts +0 -5
- package/src/editor/services/translationService.ts +0 -21
- package/src/editor/services-server/api.ts +0 -150
- package/src/editor/services-server/graphQL.ts +0 -106
- package/src/editor/sidebar/ComponentPalette.tsx +0 -161
- package/src/editor/sidebar/ComponentTree.tsx +0 -548
- package/src/editor/sidebar/ComponentTree2.tsxx +0 -490
- package/src/editor/sidebar/Debug.tsx +0 -111
- package/src/editor/sidebar/DictionaryEditor.tsx +0 -261
- package/src/editor/sidebar/EditHistory.tsx +0 -134
- package/src/editor/sidebar/GraphQL.tsx +0 -164
- package/src/editor/sidebar/Insert.tsx +0 -35
- package/src/editor/sidebar/MainContentTree.tsx +0 -102
- package/src/editor/sidebar/Performance.tsx +0 -53
- package/src/editor/sidebar/Sessions.tsx +0 -35
- package/src/editor/sidebar/Sidebar.tsx +0 -20
- package/src/editor/sidebar/SidebarView.tsx +0 -152
- package/src/editor/sidebar/Translations.tsx +0 -295
- package/src/editor/sidebar/Validation.tsx +0 -102
- package/src/editor/sidebar/ViewSelector.tsx +0 -60
- package/src/editor/sidebar/Workbox.tsx +0 -209
- package/src/editor/ui/CenteredMessage.tsx +0 -7
- package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +0 -81
- package/src/editor/ui/CopyToClipboardButton.tsx +0 -24
- package/src/editor/ui/DialogButtons.tsx +0 -11
- package/src/editor/ui/Icons.tsx +0 -709
- package/src/editor/ui/ItemList.tsx +0 -76
- package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
- package/src/editor/ui/ItemSearch.tsx +0 -153
- package/src/editor/ui/PerfectTree.tsx +0 -571
- package/src/editor/ui/Section.tsx +0 -35
- package/src/editor/ui/SimpleIconButton.tsx +0 -54
- package/src/editor/ui/SimpleMenu.tsx +0 -40
- package/src/editor/ui/SimpleTable.tsx +0 -60
- package/src/editor/ui/SimpleTabs.tsx +0 -55
- package/src/editor/ui/SimpleToolbar.tsx +0 -7
- package/src/editor/ui/Spinner.tsx +0 -9
- package/src/editor/ui/Splitter.tsx +0 -314
- package/src/editor/ui/StackedPanels.tsx +0 -134
- package/src/editor/ui/Toolbar.tsx +0 -7
- package/src/editor/utils/id-helper.ts +0 -3
- package/src/editor/utils/insertOptions.ts +0 -69
- package/src/editor/utils/itemutils.ts +0 -29
- package/src/editor/utils/useMemoDebug.ts +0 -28
- package/src/editor/utils.ts +0 -486
- package/src/editor/views/CompareView.tsx +0 -245
- package/src/editor/views/EditView.tsx +0 -27
- package/src/editor/views/ItemEditor.tsx +0 -58
- package/src/editor/views/SingleEditView.tsx +0 -46
- package/src/fonts/Geist-Black.woff2 +0 -0
- package/src/fonts/Geist-Bold.woff2 +0 -0
- package/src/fonts/Geist-ExtraBold.woff2 +0 -0
- package/src/fonts/Geist-ExtraLight.woff2 +0 -0
- package/src/fonts/Geist-Light.woff2 +0 -0
- package/src/fonts/Geist-Medium.woff2 +0 -0
- package/src/fonts/Geist-Regular.woff2 +0 -0
- package/src/fonts/Geist-SemiBold.woff2 +0 -0
- package/src/fonts/Geist-Thin.woff2 +0 -0
- package/src/fonts/Geist[wght].woff2 +0 -0
- package/src/fonts/index.ts +0 -10
- package/src/index.ts +0 -23
- package/src/lib/safelist.tsx +0 -16
- package/src/lib/utils.ts +0 -6
- package/src/page-wizard/PageWizard.tsx +0 -139
- package/src/page-wizard/WizardBox.tsx +0 -4
- package/src/page-wizard/WizardBoxConnector.tsx +0 -56
- package/src/page-wizard/WizardSteps.tsx +0 -458
- package/src/page-wizard/service.ts +0 -35
- package/src/page-wizard/startPageWizardCommand.ts +0 -26
- package/src/page-wizard/steps/BuildPageStep.tsx +0 -259
- package/src/page-wizard/steps/CollectStep.tsx +0 -296
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +0 -454
- package/src/page-wizard/steps/Components.tsx +0 -193
- package/src/page-wizard/steps/ContentStep.tsx +0 -890
- package/src/page-wizard/steps/EditButton.tsx +0 -34
- package/src/page-wizard/steps/FieldEditor.tsx +0 -102
- package/src/page-wizard/steps/Generate.tsx +0 -60
- package/src/page-wizard/steps/ImagesStep.tsx +0 -382
- package/src/page-wizard/steps/LayoutStep.tsx +0 -227
- package/src/page-wizard/steps/MetaDataStep.tsx +0 -173
- package/src/page-wizard/steps/SelectStep.tsx +0 -281
- package/src/page-wizard/steps/schema.ts +0 -180
- package/src/page-wizard/steps/usePageCreator.ts +0 -325
- package/src/page-wizard/usePageWizard.ts +0 -79
- package/src/revision.ts +0 -2
- package/src/splash-screen/NewPage.tsx +0 -294
- package/src/splash-screen/OpenPage.tsx +0 -113
- package/src/splash-screen/RecentPages.tsx +0 -123
- package/src/splash-screen/SectionHeadline.tsx +0 -21
- package/src/splash-screen/SplashScreen.tsx +0 -195
- package/src/tour/Tour.tsx +0 -566
- package/src/tour/default-tour.tsx +0 -301
- package/src/tour/preview-tour.tsx +0 -128
- package/src/types.ts +0 -335
- package/styles.css +0 -765
- package/tsconfig.build.json +0 -31
- package/tsconfig.json +0 -14
package/src/editor/pageModel.ts
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { InsertOption } from "../types";
|
|
2
|
-
|
|
3
|
-
export type PageSkeleton = {
|
|
4
|
-
editRevision: string;
|
|
5
|
-
item: ItemDescriptor;
|
|
6
|
-
rootComponent: ComponentSkeleton;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type PlaceholderSkeleton = {
|
|
10
|
-
name: string;
|
|
11
|
-
key: string;
|
|
12
|
-
description: string;
|
|
13
|
-
components: ComponentSkeleton[];
|
|
14
|
-
parentComponent: ComponentSkeleton;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type ComponentSkeleton = {
|
|
18
|
-
id: string;
|
|
19
|
-
name: string;
|
|
20
|
-
type: string;
|
|
21
|
-
typeId: string;
|
|
22
|
-
items: RenderedItemSkeleton[];
|
|
23
|
-
placeholders: PlaceholderSkeleton[];
|
|
24
|
-
datasourceItem?: RenderedItemSkeleton;
|
|
25
|
-
isRemovedFromMasterLanguage?: boolean;
|
|
26
|
-
isInheritedFromMasterLanguage?: boolean;
|
|
27
|
-
visible?: boolean;
|
|
28
|
-
parentPlaceholder?: PlaceholderSkeleton;
|
|
29
|
-
renderedDictionaryKeys: string[];
|
|
30
|
-
layoutId?: string;
|
|
31
|
-
editorFields: EditorFields;
|
|
32
|
-
firstDOMElement?: Element;
|
|
33
|
-
lastDOMElement?: Element;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export type RenderedItemSkeleton = ItemDescriptor & {
|
|
37
|
-
renderedFieldIds: string[];
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export type ItemDescriptor = {
|
|
41
|
-
id: string;
|
|
42
|
-
language: string;
|
|
43
|
-
version: number;
|
|
44
|
-
name?: string;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type Field = {
|
|
48
|
-
id: string;
|
|
49
|
-
value: unknown;
|
|
50
|
-
rawValue?: string | null;
|
|
51
|
-
name?: string;
|
|
52
|
-
type: string;
|
|
53
|
-
descriptor: FieldDescriptor;
|
|
54
|
-
displayName?: string;
|
|
55
|
-
sortOrder?: number;
|
|
56
|
-
sectionSortOrder?: number;
|
|
57
|
-
customProperties?: any;
|
|
58
|
-
canWrite?: boolean;
|
|
59
|
-
hasLock?: boolean;
|
|
60
|
-
canLock?: boolean;
|
|
61
|
-
lockedBy?: LockSession;
|
|
62
|
-
section?: string;
|
|
63
|
-
isFallback?: boolean;
|
|
64
|
-
isStandardValue?: boolean;
|
|
65
|
-
isShared?: boolean;
|
|
66
|
-
sourceItems: ItemRef[];
|
|
67
|
-
buttons?: FieldButton[];
|
|
68
|
-
fallbackChain?: FieldDescriptor[];
|
|
69
|
-
isHistoric?: boolean; // true if the value is from the fields history
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export type ItemRef = {
|
|
73
|
-
id: string;
|
|
74
|
-
name?: string;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export type FieldButtonParameter = {
|
|
78
|
-
id: string;
|
|
79
|
-
label: string;
|
|
80
|
-
placeholder?: string;
|
|
81
|
-
type?: "text" | "textarea" | "number" | "select";
|
|
82
|
-
required?: boolean;
|
|
83
|
-
defaultValue?: string;
|
|
84
|
-
options?: { value: string; label: string }[]; // for select type
|
|
85
|
-
rows?: number; // for textarea type
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export type FieldButton = {
|
|
89
|
-
id: string;
|
|
90
|
-
label: string;
|
|
91
|
-
description: string;
|
|
92
|
-
action?: string;
|
|
93
|
-
icon?: string;
|
|
94
|
-
isGenerator: boolean;
|
|
95
|
-
parameters?: FieldButtonParameter[];
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export type LockSession = {
|
|
99
|
-
sessionId: string;
|
|
100
|
-
name: string;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export type FieldDescriptor = {
|
|
104
|
-
item: ItemDescriptor;
|
|
105
|
-
fieldId: string;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export type Language = {
|
|
109
|
-
name: string;
|
|
110
|
-
versions: number;
|
|
111
|
-
icon: string;
|
|
112
|
-
languageCode: string;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export type Version = {
|
|
116
|
-
version: number;
|
|
117
|
-
updated: Date;
|
|
118
|
-
updatedBy: string;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export type Timings = {
|
|
122
|
-
[key: string]: number;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export type ItemStub = ItemDescriptor & {
|
|
126
|
-
name: string;
|
|
127
|
-
templateId: string;
|
|
128
|
-
templateName: string;
|
|
129
|
-
icon: string;
|
|
130
|
-
path: string;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export type FullItem = ItemDescriptor & {
|
|
134
|
-
descriptor: ItemDescriptor;
|
|
135
|
-
name: string;
|
|
136
|
-
templateId: string;
|
|
137
|
-
templateName: string;
|
|
138
|
-
icon: string;
|
|
139
|
-
largeIcon: string;
|
|
140
|
-
thumbnail: string;
|
|
141
|
-
path: string;
|
|
142
|
-
masterLanguages?: string[];
|
|
143
|
-
translations?: string[];
|
|
144
|
-
fields: Field[];
|
|
145
|
-
canWriteItem: boolean;
|
|
146
|
-
canWriteLanguage: boolean;
|
|
147
|
-
canWriteWorkflow: boolean;
|
|
148
|
-
canRename: boolean;
|
|
149
|
-
canDelete: boolean;
|
|
150
|
-
canCreate: boolean;
|
|
151
|
-
workflowState: string;
|
|
152
|
-
hasLock: boolean;
|
|
153
|
-
hasLayout: boolean;
|
|
154
|
-
idPath: string;
|
|
155
|
-
canLock: boolean;
|
|
156
|
-
lockedBy: string;
|
|
157
|
-
isInheritedFromMasterLanguage: boolean;
|
|
158
|
-
mainItemId?: string;
|
|
159
|
-
hasChildren: boolean;
|
|
160
|
-
parentId: string;
|
|
161
|
-
versions: number;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
export type Page = {
|
|
165
|
-
editRevision: string;
|
|
166
|
-
item: FullItem;
|
|
167
|
-
rootComponent: Component;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
export type RenderedItem = RenderedItemSkeleton & ItemStub;
|
|
171
|
-
|
|
172
|
-
type EditorFields = {
|
|
173
|
-
[group: string]: {
|
|
174
|
-
addFields: string[];
|
|
175
|
-
removeFields: string[];
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export type Component = {
|
|
180
|
-
id: string;
|
|
181
|
-
name: string;
|
|
182
|
-
type: string;
|
|
183
|
-
typeId: string;
|
|
184
|
-
items: RenderedItem[];
|
|
185
|
-
placeholders: Placeholder[];
|
|
186
|
-
datasourceItem?: RenderedItem;
|
|
187
|
-
isRemovedFromMasterLanguage?: boolean;
|
|
188
|
-
isInheritedFromMasterLanguage?: boolean;
|
|
189
|
-
visible?: boolean;
|
|
190
|
-
parentPlaceholder?: Placeholder;
|
|
191
|
-
renderedDictionaryKeys: string[];
|
|
192
|
-
isShared: boolean;
|
|
193
|
-
rendering?: RenderingReference;
|
|
194
|
-
layoutId?: string;
|
|
195
|
-
editorFields: EditorFields;
|
|
196
|
-
firstDOMElement?: Element;
|
|
197
|
-
lastDOMElement?: Element;
|
|
198
|
-
canBeMoved: boolean;
|
|
199
|
-
icon?: string;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
export type Placeholder = {
|
|
203
|
-
key: string;
|
|
204
|
-
name: string;
|
|
205
|
-
description: string;
|
|
206
|
-
components: Component[];
|
|
207
|
-
parentComponent: Component;
|
|
208
|
-
canSynchronize: boolean;
|
|
209
|
-
insertOptions: InsertOption[];
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
export interface RenderingReference {
|
|
213
|
-
id: string;
|
|
214
|
-
revision: string;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export type ItemIdAndName = {
|
|
218
|
-
name: string;
|
|
219
|
-
id: string;
|
|
220
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { PictureVariant } from "./fieldTypes";
|
|
2
|
-
|
|
3
|
-
export type PictureParams = {
|
|
4
|
-
variant?: string;
|
|
5
|
-
aspectRatio?: number;
|
|
6
|
-
scales?: number[];
|
|
7
|
-
maxWidth?: number;
|
|
8
|
-
custom?: { [paramName: string]: string | number | boolean | undefined };
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type MediaPictureParams = {
|
|
12
|
-
default: PictureParams;
|
|
13
|
-
[mediaQuery: string]: PictureParams;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export function getRenderedPictureVariant(
|
|
17
|
-
params: PictureParams,
|
|
18
|
-
variants: PictureVariant[]
|
|
19
|
-
) {
|
|
20
|
-
const variantName = params.variant ?? "auto";
|
|
21
|
-
|
|
22
|
-
const variant =
|
|
23
|
-
variantName.toLocaleLowerCase() === "auto" && params.aspectRatio
|
|
24
|
-
? getBestMatchingVariant(variants, params.aspectRatio)
|
|
25
|
-
: variants.find(
|
|
26
|
-
(v) => v.name.toLowerCase() == variantName.toLowerCase()
|
|
27
|
-
) ?? variants[0];
|
|
28
|
-
return variant;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function getBestMatchingVariant(
|
|
32
|
-
variants: PictureVariant[],
|
|
33
|
-
aspectRatio: number | undefined
|
|
34
|
-
) {
|
|
35
|
-
if (!aspectRatio)
|
|
36
|
-
return (
|
|
37
|
-
variants.find((v) => v.name.toLowerCase() == "default") ?? variants[0]
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
let minDistance = 1000000;
|
|
41
|
-
let bestMatch = undefined;
|
|
42
|
-
for (let i = 0; i < variants.length; i++) {
|
|
43
|
-
const variant = variants[i];
|
|
44
|
-
if (!variant.src) continue;
|
|
45
|
-
const distance = Math.abs(aspectRatio - variant.aspectRatio);
|
|
46
|
-
if (distance < minDistance) {
|
|
47
|
-
minDistance = distance;
|
|
48
|
-
bestMatch = variant;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return bestMatch ?? variants[0];
|
|
53
|
-
}
|
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import { Comment as CommentType } from "../../types";
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
3
|
-
import { useEditContext } from "../client/editContext";
|
|
4
|
-
import {
|
|
5
|
-
createOrUpdateComment,
|
|
6
|
-
deleteComment,
|
|
7
|
-
resolveComment,
|
|
8
|
-
unresolveComment,
|
|
9
|
-
} from "../services/reviewsService";
|
|
10
|
-
import { Button } from "../../components/ui/button";
|
|
11
|
-
import { formatDate } from "../utils";
|
|
12
|
-
import { SimpleIconButton } from "../ui/SimpleIconButton";
|
|
13
|
-
import { OverlayPanel } from "primereact/overlaypanel";
|
|
14
|
-
import { ProgressSpinner } from "primereact/progressspinner";
|
|
15
|
-
import { useDebouncedCallback } from "use-debounce";
|
|
16
|
-
import { ActionButton } from "../../components/ActionButton";
|
|
17
|
-
|
|
18
|
-
export function Comment({ comment }: { comment: CommentType }) {
|
|
19
|
-
const editContext = useEditContext();
|
|
20
|
-
const [commentText, setCommentText] = useState(comment.text);
|
|
21
|
-
const [isEditing, setIsEditing] = useState(false);
|
|
22
|
-
const [isSaving, setIsSaving] = useState(false);
|
|
23
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (comment.isNew) setIsEditing(true);
|
|
27
|
-
}, [comment]);
|
|
28
|
-
|
|
29
|
-
const isSelected = comment.id === editContext?.selectedComment?.id;
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (isSelected) {
|
|
33
|
-
if (ref.current) {
|
|
34
|
-
ref.current.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}, [isSelected]);
|
|
38
|
-
|
|
39
|
-
const renderContextInfo = () => {
|
|
40
|
-
const showItemName =
|
|
41
|
-
comment.itemId && comment.mainItemId !== comment.itemId;
|
|
42
|
-
|
|
43
|
-
const showFieldName = comment.fieldId;
|
|
44
|
-
|
|
45
|
-
if (!showItemName && !showFieldName) return null;
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div className="mt-3 flex items-center border-t pt-3 text-xs">
|
|
49
|
-
{showItemName && (
|
|
50
|
-
<div className="text-2xs text-gray-500">{comment.itemName}</div>
|
|
51
|
-
)}
|
|
52
|
-
|
|
53
|
-
{showFieldName && showItemName && (
|
|
54
|
-
<div className="text-2xs mx-2 text-gray-500">></div>
|
|
55
|
-
)}
|
|
56
|
-
|
|
57
|
-
{showFieldName && (
|
|
58
|
-
<div className="text-2xs text-gray-500">{comment.fieldName}</div>
|
|
59
|
-
)}
|
|
60
|
-
</div>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const canDelete =
|
|
65
|
-
!comment.isNew && comment.author === editContext?.user?.name;
|
|
66
|
-
|
|
67
|
-
const canEdit =
|
|
68
|
-
!comment.isNew &&
|
|
69
|
-
!comment.isResolved &&
|
|
70
|
-
comment.author === editContext?.user?.name;
|
|
71
|
-
|
|
72
|
-
const canResolve = !comment.isNew && !editContext?.readonly;
|
|
73
|
-
|
|
74
|
-
const getHiddenSystemPrompt = (comment: CommentType) => {
|
|
75
|
-
let prompt =
|
|
76
|
-
"Please make suggestions how to resolve a review comment. Ask the user whether you should apply the suggested changes.";
|
|
77
|
-
if (comment.itemId) {
|
|
78
|
-
prompt += "\n\nItemId: " + comment.itemId;
|
|
79
|
-
}
|
|
80
|
-
if (comment.itemName) {
|
|
81
|
-
prompt += "\n\nItem name: " + comment.itemName;
|
|
82
|
-
}
|
|
83
|
-
if (comment.itemId) {
|
|
84
|
-
prompt += "\n\nItemId: " + comment.itemId;
|
|
85
|
-
}
|
|
86
|
-
if (comment.fieldName) {
|
|
87
|
-
prompt += "\n\nField name: " + comment.fieldName;
|
|
88
|
-
}
|
|
89
|
-
return prompt;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const renderHeader = () => {
|
|
93
|
-
const overlayPanelRef = useRef<OverlayPanel>(null);
|
|
94
|
-
const deleteOverlayPanelRef = useRef<OverlayPanel>(null);
|
|
95
|
-
return (
|
|
96
|
-
<>
|
|
97
|
-
<div className="mb-3 flex items-start justify-between">
|
|
98
|
-
<div>
|
|
99
|
-
<div
|
|
100
|
-
className="text-xs font-bold text-gray-900"
|
|
101
|
-
title={comment.author}
|
|
102
|
-
>
|
|
103
|
-
{comment.authorDisplayName}
|
|
104
|
-
</div>
|
|
105
|
-
<div className="text-xs text-gray-500">
|
|
106
|
-
{comment.created ? formatDate(new Date(comment.created)) : ""}
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
<div className="text-xs text-gray-500">
|
|
110
|
-
{!isEditing && canEdit && (
|
|
111
|
-
<SimpleIconButton
|
|
112
|
-
icon="pi pi-pencil"
|
|
113
|
-
label="Edit"
|
|
114
|
-
onClick={() => setIsEditing(true)}
|
|
115
|
-
/>
|
|
116
|
-
)}
|
|
117
|
-
{canDelete && (
|
|
118
|
-
<SimpleIconButton
|
|
119
|
-
icon="pi pi-trash"
|
|
120
|
-
label="Delete"
|
|
121
|
-
onClick={(e) => {
|
|
122
|
-
deleteOverlayPanelRef.current?.toggle(e);
|
|
123
|
-
}}
|
|
124
|
-
/>
|
|
125
|
-
)}
|
|
126
|
-
<OverlayPanel ref={deleteOverlayPanelRef}>
|
|
127
|
-
<Button
|
|
128
|
-
className="m-2"
|
|
129
|
-
variant="outline"
|
|
130
|
-
onClick={async () => {
|
|
131
|
-
await deleteComment(comment);
|
|
132
|
-
}}
|
|
133
|
-
>
|
|
134
|
-
Delete
|
|
135
|
-
</Button>
|
|
136
|
-
</OverlayPanel>
|
|
137
|
-
{canResolve && !comment.isResolved && (
|
|
138
|
-
<SimpleIconButton
|
|
139
|
-
icon="pi pi-check"
|
|
140
|
-
label="Resolve"
|
|
141
|
-
onClick={async () => {
|
|
142
|
-
await resolveComment(comment);
|
|
143
|
-
}}
|
|
144
|
-
/>
|
|
145
|
-
)}
|
|
146
|
-
{comment.isResolved && (
|
|
147
|
-
<>
|
|
148
|
-
<i
|
|
149
|
-
className="pi pi-check cursor-pointer px-1 text-xs text-green-500"
|
|
150
|
-
style={{ fontWeight: "bold" }}
|
|
151
|
-
title={
|
|
152
|
-
"Resolved by " +
|
|
153
|
-
comment.resolvedBy +
|
|
154
|
-
" (" +
|
|
155
|
-
formatDate(new Date(comment.resolvedDate!)) +
|
|
156
|
-
")"
|
|
157
|
-
}
|
|
158
|
-
onClick={(e) => {
|
|
159
|
-
if (canResolve) {
|
|
160
|
-
overlayPanelRef.current?.toggle(e);
|
|
161
|
-
}
|
|
162
|
-
}}
|
|
163
|
-
></i>
|
|
164
|
-
<OverlayPanel ref={overlayPanelRef}>
|
|
165
|
-
<Button
|
|
166
|
-
className="m-2"
|
|
167
|
-
variant="outline"
|
|
168
|
-
onClick={async () => {
|
|
169
|
-
await unresolveComment(comment);
|
|
170
|
-
}}
|
|
171
|
-
>
|
|
172
|
-
Unresolve
|
|
173
|
-
</Button>
|
|
174
|
-
</OverlayPanel>
|
|
175
|
-
</>
|
|
176
|
-
)}
|
|
177
|
-
{canResolve && !comment.isResolved && (
|
|
178
|
-
<SimpleIconButton
|
|
179
|
-
icon="pi pi-sparkles"
|
|
180
|
-
label="AI"
|
|
181
|
-
onClick={async (event) => {
|
|
182
|
-
editContext?.showAiPopup(event as any, {
|
|
183
|
-
initialPrompt:
|
|
184
|
-
'Please help me resolve this comment: "' +
|
|
185
|
-
comment.text +
|
|
186
|
-
'"',
|
|
187
|
-
hiddenSystemPrompt: getHiddenSystemPrompt(comment),
|
|
188
|
-
});
|
|
189
|
-
}}
|
|
190
|
-
/>
|
|
191
|
-
)}
|
|
192
|
-
</div>
|
|
193
|
-
</div>
|
|
194
|
-
</>
|
|
195
|
-
);
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const setCommentsDebounced = useDebouncedCallback(() => {
|
|
199
|
-
if (!editContext?.setComments) return;
|
|
200
|
-
editContext.setComments([...editContext.comments]);
|
|
201
|
-
}, 300);
|
|
202
|
-
|
|
203
|
-
return !isEditing ? (
|
|
204
|
-
<div
|
|
205
|
-
ref={ref}
|
|
206
|
-
key={comment.id}
|
|
207
|
-
data-testid="comment"
|
|
208
|
-
className={`mb-3 cursor-pointer rounded-lg border-2 bg-white p-3 shadow-sm hover:bg-gray-50 ${
|
|
209
|
-
isSelected ? "border-blue-500" : "border-transparent"
|
|
210
|
-
}`}
|
|
211
|
-
onClick={() => {
|
|
212
|
-
editContext?.setSelectedComment(comment);
|
|
213
|
-
editContext?.setScrollIntoView(comment.itemId);
|
|
214
|
-
editContext?.select([comment.itemId]);
|
|
215
|
-
if (comment.fieldId) {
|
|
216
|
-
editContext?.setFocusedField(
|
|
217
|
-
{
|
|
218
|
-
fieldId: comment.fieldId,
|
|
219
|
-
item: {
|
|
220
|
-
id: comment.itemId,
|
|
221
|
-
language: comment.language,
|
|
222
|
-
version: comment.version,
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
false,
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
}}
|
|
229
|
-
>
|
|
230
|
-
{renderHeader()}
|
|
231
|
-
<div className="text-sm whitespace-pre-wrap text-gray-700">
|
|
232
|
-
{comment.text}
|
|
233
|
-
</div>
|
|
234
|
-
{renderContextInfo()}
|
|
235
|
-
</div>
|
|
236
|
-
) : (
|
|
237
|
-
<div key="new-comment" className="mb-3 rounded-lg bg-white p-3 shadow-sm">
|
|
238
|
-
{renderHeader()}
|
|
239
|
-
<textarea
|
|
240
|
-
className="mt-2 min-h-[100px] w-full rounded border border-gray-200 p-2 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none"
|
|
241
|
-
placeholder="Add a comment..."
|
|
242
|
-
value={commentText}
|
|
243
|
-
onChange={async (e) => {
|
|
244
|
-
if (!editContext) return;
|
|
245
|
-
setCommentText(e.target.value);
|
|
246
|
-
|
|
247
|
-
setCommentsDebounced();
|
|
248
|
-
}}
|
|
249
|
-
autoFocus
|
|
250
|
-
/>
|
|
251
|
-
{isSaving && (
|
|
252
|
-
<div className="mt-1 flex justify-end gap-2">
|
|
253
|
-
<div className="flex items-center gap-2 text-xs text-gray-500">
|
|
254
|
-
<ProgressSpinner className="h-4 w-4" />
|
|
255
|
-
Saving...
|
|
256
|
-
</div>
|
|
257
|
-
</div>
|
|
258
|
-
)}
|
|
259
|
-
{!isSaving && (
|
|
260
|
-
<div className="mt-1 flex justify-end gap-2">
|
|
261
|
-
<ActionButton
|
|
262
|
-
onClick={() => {
|
|
263
|
-
if (comment.isNew) {
|
|
264
|
-
if (editContext?.setComments) {
|
|
265
|
-
editContext.setComments([
|
|
266
|
-
...editContext.comments.filter((c) => c.id !== comment.id),
|
|
267
|
-
]);
|
|
268
|
-
}
|
|
269
|
-
} else {
|
|
270
|
-
setIsEditing(false);
|
|
271
|
-
}
|
|
272
|
-
}}
|
|
273
|
-
>
|
|
274
|
-
Cancel
|
|
275
|
-
</ActionButton>
|
|
276
|
-
|
|
277
|
-
<ActionButton
|
|
278
|
-
className="tour-submit-comment-button"
|
|
279
|
-
onClick={async () => {
|
|
280
|
-
comment.text = commentText;
|
|
281
|
-
setIsSaving(true);
|
|
282
|
-
const item = await editContext?.itemsRepository?.getItem({
|
|
283
|
-
id: comment.itemId,
|
|
284
|
-
language: comment.language,
|
|
285
|
-
version: comment.version,
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
if (item) {
|
|
289
|
-
comment.fieldValue = item.fields.find(
|
|
290
|
-
(f) => f.id === comment.fieldId,
|
|
291
|
-
)?.rawValue;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
await createOrUpdateComment(comment);
|
|
295
|
-
|
|
296
|
-
setIsSaving(false);
|
|
297
|
-
setIsEditing(false);
|
|
298
|
-
}}
|
|
299
|
-
>
|
|
300
|
-
{comment.isNew ? "Comment" : "Save"}
|
|
301
|
-
</ActionButton>
|
|
302
|
-
</div>
|
|
303
|
-
)}
|
|
304
|
-
{renderContextInfo()}
|
|
305
|
-
</div>
|
|
306
|
-
);
|
|
307
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { useEditContext } from "../client/editContext";
|
|
3
|
-
import { Comment as CommentComponent } from "./Comment";
|
|
4
|
-
import { SuggestedEditComponent } from "./SuggestedEdit";
|
|
5
|
-
import { Comment as CommentType, SuggestedEdit } from "../../types";
|
|
6
|
-
import { SimpleToolbar } from "../ui/SimpleToolbar";
|
|
7
|
-
import { SimpleIconButton } from "../ui/SimpleIconButton";
|
|
8
|
-
import {
|
|
9
|
-
FileDiff,
|
|
10
|
-
SquarePen,
|
|
11
|
-
CheckCircle,
|
|
12
|
-
CheckCircle2,
|
|
13
|
-
MessageSquareMore,
|
|
14
|
-
} from "lucide-react";
|
|
15
|
-
|
|
16
|
-
// Define a union type for feedback items:
|
|
17
|
-
export type FeedbackItem = CommentType | SuggestedEdit;
|
|
18
|
-
|
|
19
|
-
export function Comments() {
|
|
20
|
-
const editContext = useEditContext();
|
|
21
|
-
const [feedbackItems, setFeedbackItems] = useState<FeedbackItem[]>([]);
|
|
22
|
-
const [hideAppliedSuggestions, setHideAppliedSuggestions] =
|
|
23
|
-
useState<boolean>(true);
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
// Retrieve your list of comments (and ensure there's an array of suggested edits,
|
|
27
|
-
// for instance from your editContext)
|
|
28
|
-
const comments: CommentType[] = editContext?.comments || [];
|
|
29
|
-
const suggestedEdits: SuggestedEdit[] = editContext?.suggestedEdits || [];
|
|
30
|
-
|
|
31
|
-
// Filter out applied suggestions if hideAppliedSuggestions is true
|
|
32
|
-
const filteredSuggestedEdits = hideAppliedSuggestions
|
|
33
|
-
? suggestedEdits.filter((edit) => edit.status !== "Applied")
|
|
34
|
-
: suggestedEdits;
|
|
35
|
-
|
|
36
|
-
const combined: FeedbackItem[] = [...comments, ...filteredSuggestedEdits];
|
|
37
|
-
|
|
38
|
-
// Sort by creation date. Adjust the comparison as needed if the date properties differ.
|
|
39
|
-
combined.sort(
|
|
40
|
-
(a, b) =>
|
|
41
|
-
new Date(b.created || "").getTime() -
|
|
42
|
-
new Date(a.created || "").getTime(),
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
setFeedbackItems(combined);
|
|
46
|
-
}, [editContext, hideAppliedSuggestions]);
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div className="flex h-full flex-col">
|
|
50
|
-
<SimpleToolbar>
|
|
51
|
-
<SimpleIconButton
|
|
52
|
-
id="add-comment"
|
|
53
|
-
icon="pi pi-plus"
|
|
54
|
-
label="Add Comment"
|
|
55
|
-
onClick={() => {
|
|
56
|
-
editContext?.addComment();
|
|
57
|
-
}}
|
|
58
|
-
/>
|
|
59
|
-
<SimpleIconButton
|
|
60
|
-
selected={editContext?.showComments}
|
|
61
|
-
icon={<MessageSquareMore size={16} className="p-0.5" />}
|
|
62
|
-
label="Show Comments"
|
|
63
|
-
onClick={() => {
|
|
64
|
-
editContext?.setShowComments((x) => !x);
|
|
65
|
-
}}
|
|
66
|
-
/>
|
|
67
|
-
<SimpleIconButton
|
|
68
|
-
selected={editContext?.showSuggestedEdits}
|
|
69
|
-
icon={<SquarePen size={16} className="p-0.5" />}
|
|
70
|
-
label="Show Suggestions"
|
|
71
|
-
onClick={() => {
|
|
72
|
-
editContext?.setShowSuggestedEdits((x) => !x);
|
|
73
|
-
}}
|
|
74
|
-
/>
|
|
75
|
-
{editContext?.showSuggestedEdits && (
|
|
76
|
-
<SimpleIconButton
|
|
77
|
-
selected={editContext?.showSuggestedEditsDiff}
|
|
78
|
-
icon={<FileDiff size={16} className="p-0.5" />}
|
|
79
|
-
label="Show Suggestions Diff"
|
|
80
|
-
onClick={() => {
|
|
81
|
-
editContext?.setShowSuggestedEditsDiff((x) => !x);
|
|
82
|
-
}}
|
|
83
|
-
/>
|
|
84
|
-
)}
|
|
85
|
-
<SimpleIconButton
|
|
86
|
-
selected={hideAppliedSuggestions}
|
|
87
|
-
icon={
|
|
88
|
-
hideAppliedSuggestions ? (
|
|
89
|
-
<CheckCircle2 size={16} className="p-0.5" />
|
|
90
|
-
) : (
|
|
91
|
-
<CheckCircle size={16} className="p-0.5" />
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
label={
|
|
95
|
-
hideAppliedSuggestions
|
|
96
|
-
? "Show Applied Suggestions"
|
|
97
|
-
: "Hide Applied Suggestions"
|
|
98
|
-
}
|
|
99
|
-
onClick={() => {
|
|
100
|
-
setHideAppliedSuggestions((x) => !x);
|
|
101
|
-
}}
|
|
102
|
-
/>
|
|
103
|
-
</SimpleToolbar>
|
|
104
|
-
|
|
105
|
-
<div className="flex-1 overflow-auto">
|
|
106
|
-
<div className="h-fill-available border-l border-gray-200 bg-gray-50 p-4">
|
|
107
|
-
{feedbackItems.map((item) => {
|
|
108
|
-
// Use a discriminator check. Here we assume suggested edits have the properties oldValue and newValue.
|
|
109
|
-
if ("oldValue" in item && "newValue" in item) {
|
|
110
|
-
return (
|
|
111
|
-
<SuggestedEditComponent
|
|
112
|
-
key={item.id}
|
|
113
|
-
edit={item as SuggestedEdit}
|
|
114
|
-
/>
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
return (
|
|
118
|
-
<CommentComponent key={item.id} comment={item as CommentType} />
|
|
119
|
-
);
|
|
120
|
-
})}
|
|
121
|
-
</div>
|
|
122
|
-
</div>
|
|
123
|
-
</div>
|
|
124
|
-
);
|
|
125
|
-
}
|