@alpaca-editor/core 1.0.3939 → 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/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
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { deleteVersion } from "../services/editService";
|
|
2
|
-
import { getItemDescriptor } from "../utils";
|
|
3
|
-
import { Command, CommandContext } from "./commands";
|
|
4
|
-
|
|
5
|
-
export function getDeleteVersionCommand({}: {
|
|
6
|
-
language?: string;
|
|
7
|
-
}): Command<CommandContext<any>> {
|
|
8
|
-
return {
|
|
9
|
-
id: "deleteVersion",
|
|
10
|
-
execute: (context) => execute(context),
|
|
11
|
-
label: "Delete Version",
|
|
12
|
-
icon: "pi pi-fw pi-times",
|
|
13
|
-
disabled: (context: CommandContext<any>) =>
|
|
14
|
-
!context.editContext.item?.canLock ||
|
|
15
|
-
context.editContext.item.version === 0 ||
|
|
16
|
-
context.editContext.itemVersions.length === 0,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async function execute(context: CommandContext<any>): Promise<void> {
|
|
21
|
-
if (!context.editContext.item) return;
|
|
22
|
-
const descriptor = getItemDescriptor(context.editContext.item);
|
|
23
|
-
|
|
24
|
-
let message =
|
|
25
|
-
"Are you sure you want to delete version " +
|
|
26
|
-
context.editContext.item.version +
|
|
27
|
-
"?";
|
|
28
|
-
|
|
29
|
-
const sessions = context.editContext.activeSessions.filter(
|
|
30
|
-
(x) =>
|
|
31
|
-
((x.item?.id === descriptor.id &&
|
|
32
|
-
x.item?.language === descriptor.language &&
|
|
33
|
-
x.item?.version === descriptor.version) ||
|
|
34
|
-
(x.page?.id === descriptor.id &&
|
|
35
|
-
x.page?.language === descriptor.language &&
|
|
36
|
-
x.page?.version === descriptor.version)) &&
|
|
37
|
-
x.sessionId !== context.editContext.sessionId
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
if (sessions.length > 0) {
|
|
41
|
-
context.editContext.showMessageDialog({
|
|
42
|
-
header: "Delete Version",
|
|
43
|
-
message:
|
|
44
|
-
"This version is currently locked by " +
|
|
45
|
-
sessions.map((x) => x.user.name).join(", ") +
|
|
46
|
-
". You cannot delete it.",
|
|
47
|
-
});
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
context.editContext.itemVersions[
|
|
53
|
-
context.editContext.itemVersions.length - 1
|
|
54
|
-
]?.version === context.editContext.item.version
|
|
55
|
-
) {
|
|
56
|
-
message += " This is the latest version!";
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
context.editContext.confirm?.({
|
|
60
|
-
header: "Delete Version",
|
|
61
|
-
message,
|
|
62
|
-
showCancel: true,
|
|
63
|
-
accept: async () => {
|
|
64
|
-
await deleteVersion(descriptor, context.editContext.sessionId);
|
|
65
|
-
context.editContext.loadItem({
|
|
66
|
-
...descriptor,
|
|
67
|
-
version: 0,
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
import { Command, CommandContext, CommandData } from "./commands";
|
|
2
|
-
import { FullItem, ItemDescriptor } from "../pageModel";
|
|
3
|
-
|
|
4
|
-
import { ItemNameDialog, ItemNameDialogProps } from "../ui/ItemNameDialogNew";
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
CopyMoveTargetSelectorDialog,
|
|
8
|
-
CopyMoveTargetSelectorDialogProps,
|
|
9
|
-
} from "../ui/CopyMoveTargetSelectorDialog";
|
|
10
|
-
import { defaultTranslateAll } from "./localizeItem/LocalizeItemUtils";
|
|
11
|
-
import { TranslationStatus } from "../../config/types";
|
|
12
|
-
|
|
13
|
-
export type ItemCommandData = CommandData & {
|
|
14
|
-
items: FullItem[];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type ItemCommandContext = CommandContext<ItemCommandData>;
|
|
18
|
-
|
|
19
|
-
export type ItemCommand = Command<ItemCommandData>;
|
|
20
|
-
|
|
21
|
-
export const deleteItemCommand: ItemCommand = {
|
|
22
|
-
id: "deleteItem",
|
|
23
|
-
label: "Delete",
|
|
24
|
-
icon: "pi pi-times",
|
|
25
|
-
disabled: (context: ItemCommandContext) =>
|
|
26
|
-
!context.data?.items || !context.data?.items[0]?.canDelete || false,
|
|
27
|
-
execute: async (context: ItemCommandContext) => {
|
|
28
|
-
const items = context.data?.items;
|
|
29
|
-
|
|
30
|
-
if (!items || items.length === 0) return;
|
|
31
|
-
const confirmed = await new Promise<boolean>((resolve) => {
|
|
32
|
-
context.editContext.confirm({
|
|
33
|
-
message: (
|
|
34
|
-
<div>
|
|
35
|
-
Are you sure you want to delete{" "}
|
|
36
|
-
<em>{items.map((x) => x.name).join(", ")}</em>? This cannot be
|
|
37
|
-
undone.
|
|
38
|
-
</div>
|
|
39
|
-
),
|
|
40
|
-
header: "Confirmation",
|
|
41
|
-
icon: "pi pi-exclamation-triangle",
|
|
42
|
-
accept: () => resolve(true),
|
|
43
|
-
reject: () => resolve(false),
|
|
44
|
-
showCancel: true,
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
if (confirmed) {
|
|
49
|
-
if (
|
|
50
|
-
items.some(
|
|
51
|
-
(x) => context.editContext.contentEditorItem?.descriptor.id === x.id,
|
|
52
|
-
)
|
|
53
|
-
) {
|
|
54
|
-
const firstItem = items[0];
|
|
55
|
-
if (firstItem) {
|
|
56
|
-
context.editContext.loadItem({
|
|
57
|
-
id: firstItem.parentId,
|
|
58
|
-
language: context.editContext.contentEditorItem!.language,
|
|
59
|
-
version: 0,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
await context.editContext.operations.deleteItems(
|
|
65
|
-
items.map((x) => x.descriptor),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
export const renameItemCommand: ItemCommand = {
|
|
74
|
-
id: "renameItem",
|
|
75
|
-
label: "Rename",
|
|
76
|
-
icon: "pi pi-pencil",
|
|
77
|
-
keyBinding: "F2",
|
|
78
|
-
disabled: (context: ItemCommandContext) =>
|
|
79
|
-
!context.data?.items ||
|
|
80
|
-
context.data.items.length !== 1 ||
|
|
81
|
-
!context.data.items[0]?.canRename ||
|
|
82
|
-
false,
|
|
83
|
-
execute: async (context: ItemCommandContext) => {
|
|
84
|
-
const item = context.data?.items[0];
|
|
85
|
-
|
|
86
|
-
if (!item) return;
|
|
87
|
-
const newName = await context.openDialog<string, ItemNameDialogProps>(
|
|
88
|
-
ItemNameDialog,
|
|
89
|
-
{
|
|
90
|
-
name: item.name,
|
|
91
|
-
title: "Rename Item",
|
|
92
|
-
message: "Enter a new name for the item:",
|
|
93
|
-
parentItem: { ...item.descriptor, id: item.parentId },
|
|
94
|
-
itemId: item.id,
|
|
95
|
-
},
|
|
96
|
-
);
|
|
97
|
-
if (newName) {
|
|
98
|
-
await context.editContext.operations.renameItem(item.descriptor, newName);
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
type InsertItemCommandData = ItemCommandData & {
|
|
104
|
-
templateId: string;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export type InsertItemCommandContext = CommandContext<InsertItemCommandData>;
|
|
108
|
-
|
|
109
|
-
export type InsertItemCommand = Command<InsertItemCommandData>;
|
|
110
|
-
|
|
111
|
-
export const insertItemCommand: ItemCommand = {
|
|
112
|
-
id: "insertItem",
|
|
113
|
-
label: "Insert Item",
|
|
114
|
-
icon: "pi pi-plus",
|
|
115
|
-
disabled: (context: ItemCommandContext) =>
|
|
116
|
-
!context.data?.items ||
|
|
117
|
-
context.data.items.length !== 1 ||
|
|
118
|
-
!context.data.items[0]?.canCreate ||
|
|
119
|
-
false,
|
|
120
|
-
execute: async (context: InsertItemCommandContext) => {
|
|
121
|
-
const parentItem = context.data?.items[0];
|
|
122
|
-
const templateId = context.data?.templateId;
|
|
123
|
-
|
|
124
|
-
if (!parentItem || !templateId) return;
|
|
125
|
-
|
|
126
|
-
const templateItem = await context.editContext.itemsRepository.getItem({
|
|
127
|
-
id: templateId,
|
|
128
|
-
language: "en",
|
|
129
|
-
version: 0,
|
|
130
|
-
});
|
|
131
|
-
const templateName = templateItem?.name;
|
|
132
|
-
|
|
133
|
-
const name = await context.openDialog<string, ItemNameDialogProps>(
|
|
134
|
-
ItemNameDialog,
|
|
135
|
-
{
|
|
136
|
-
title: "Create Item",
|
|
137
|
-
message: "Enter a name for the new item:",
|
|
138
|
-
name: templateName,
|
|
139
|
-
parentItem: parentItem.descriptor,
|
|
140
|
-
},
|
|
141
|
-
);
|
|
142
|
-
if (name) {
|
|
143
|
-
const result = await context.editContext.operations.createItem(
|
|
144
|
-
parentItem.descriptor,
|
|
145
|
-
templateId,
|
|
146
|
-
name,
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
if (result) {
|
|
150
|
-
context.editContext.loadItem(result);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return result;
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
type MoveCopyItemsCommandData = ItemCommandData & {
|
|
159
|
-
targetItem: ItemDescriptor;
|
|
160
|
-
index: number;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export type MoveCopyItemsCommandContext =
|
|
164
|
-
CommandContext<MoveCopyItemsCommandData>;
|
|
165
|
-
|
|
166
|
-
export type MoveCopyItemsCommand = Command<MoveCopyItemsCommandData>;
|
|
167
|
-
|
|
168
|
-
export const moveItemsCommand: MoveCopyItemsCommand = {
|
|
169
|
-
id: "moveItems",
|
|
170
|
-
label: "Move Item(s)",
|
|
171
|
-
icon: "pi pi-arrow-right",
|
|
172
|
-
disabled: (context: MoveCopyItemsCommandContext) =>
|
|
173
|
-
!context.data?.items ||
|
|
174
|
-
context.data.items.some((x) => !x.canDelete) ||
|
|
175
|
-
false,
|
|
176
|
-
execute: async (context: MoveCopyItemsCommandContext) => {
|
|
177
|
-
const items = context.data?.items;
|
|
178
|
-
let targetItem = context.data?.targetItem;
|
|
179
|
-
let index = context.data?.index;
|
|
180
|
-
|
|
181
|
-
if (!items) return;
|
|
182
|
-
|
|
183
|
-
if (!targetItem) {
|
|
184
|
-
const result = await context.openDialog<
|
|
185
|
-
ItemDescriptor,
|
|
186
|
-
CopyMoveTargetSelectorDialogProps
|
|
187
|
-
>(CopyMoveTargetSelectorDialog, {
|
|
188
|
-
items: items ?? [],
|
|
189
|
-
editContext: context.editContext,
|
|
190
|
-
header: "Select Target Item",
|
|
191
|
-
label:
|
|
192
|
-
items?.length && items.length > 1
|
|
193
|
-
? `Move ${items?.length} items`
|
|
194
|
-
: `Move item`,
|
|
195
|
-
});
|
|
196
|
-
if (result) {
|
|
197
|
-
targetItem = result;
|
|
198
|
-
index = -1;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (!targetItem) return;
|
|
203
|
-
|
|
204
|
-
context.editContext.operations.moveItems(items, targetItem, index ?? 0);
|
|
205
|
-
},
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export const copyItemsCommand: MoveCopyItemsCommand = {
|
|
209
|
-
id: "copyItems",
|
|
210
|
-
label: "Copy Item(s)",
|
|
211
|
-
icon: "pi pi-copy",
|
|
212
|
-
disabled: (context: MoveCopyItemsCommandContext) =>
|
|
213
|
-
!context.data?.items || false,
|
|
214
|
-
execute: async (context: MoveCopyItemsCommandContext) => {
|
|
215
|
-
console.log("copyItemsCommand", context.data);
|
|
216
|
-
const items = context.data?.items;
|
|
217
|
-
let targetItem = context.data?.targetItem;
|
|
218
|
-
let index = context.data?.index;
|
|
219
|
-
|
|
220
|
-
if (!targetItem) {
|
|
221
|
-
const result = await context.openDialog<
|
|
222
|
-
ItemDescriptor,
|
|
223
|
-
CopyMoveTargetSelectorDialogProps
|
|
224
|
-
>(CopyMoveTargetSelectorDialog, {
|
|
225
|
-
items: items ?? [],
|
|
226
|
-
editContext: context.editContext,
|
|
227
|
-
header: "Select Target Item",
|
|
228
|
-
label:
|
|
229
|
-
items?.length && items.length > 1
|
|
230
|
-
? `Copy ${items?.length} items`
|
|
231
|
-
: `Copy item`,
|
|
232
|
-
});
|
|
233
|
-
if (result) {
|
|
234
|
-
targetItem = result;
|
|
235
|
-
index = -1;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (!items || !targetItem) return;
|
|
240
|
-
|
|
241
|
-
const result = await context.editContext.operations.copyItems(
|
|
242
|
-
items,
|
|
243
|
-
targetItem,
|
|
244
|
-
index ?? 0,
|
|
245
|
-
);
|
|
246
|
-
if (result && result.length > 0 && result[0]) {
|
|
247
|
-
context.editContext.loadItem(result[0]);
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
export const duplicateItemCommand: MoveCopyItemsCommand = {
|
|
253
|
-
id: "duplicateItem",
|
|
254
|
-
label: "Duplicate Item",
|
|
255
|
-
icon: "pi pi-clone",
|
|
256
|
-
disabled: (context: MoveCopyItemsCommandContext) =>
|
|
257
|
-
!context.data?.items || context.data.items.length !== 1 || false,
|
|
258
|
-
execute: async (context: MoveCopyItemsCommandContext) => {
|
|
259
|
-
const item = context.data?.items[0];
|
|
260
|
-
console.log("item", item);
|
|
261
|
-
if (!item) return;
|
|
262
|
-
const targetItem = {
|
|
263
|
-
id: item.parentId,
|
|
264
|
-
language: item.language,
|
|
265
|
-
version: 0,
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
const newName = await context.openDialog<string, ItemNameDialogProps>(
|
|
269
|
-
ItemNameDialog,
|
|
270
|
-
{
|
|
271
|
-
name: item.name,
|
|
272
|
-
title: "Duplicate Item",
|
|
273
|
-
message: "Enter a name for the new item:",
|
|
274
|
-
parentItem: { ...item.descriptor, id: item.parentId },
|
|
275
|
-
itemId: item.id,
|
|
276
|
-
},
|
|
277
|
-
);
|
|
278
|
-
if (newName) {
|
|
279
|
-
const result = await context.editContext.operations.duplicateItem(
|
|
280
|
-
item.descriptor,
|
|
281
|
-
targetItem,
|
|
282
|
-
newName,
|
|
283
|
-
);
|
|
284
|
-
if (result) {
|
|
285
|
-
context.editContext.loadItem(result);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return result;
|
|
289
|
-
}
|
|
290
|
-
},
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
export type LocalizeItemCommandData = ItemCommandData & {
|
|
294
|
-
targetLanguages: string[];
|
|
295
|
-
translationProvider: string;
|
|
296
|
-
translationStatus: TranslationStatus[];
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
export type TargetLanguage = {
|
|
300
|
-
language: string;
|
|
301
|
-
version: number;
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
export type LocalizeItemCommandContext =
|
|
305
|
-
CommandContext<LocalizeItemCommandData>;
|
|
306
|
-
|
|
307
|
-
export type LocalizeItemCommand = Command<LocalizeItemCommandData>;
|
|
308
|
-
|
|
309
|
-
export const localizeItemCommand: LocalizeItemCommand = {
|
|
310
|
-
id: "localizeItem",
|
|
311
|
-
label: "Localize",
|
|
312
|
-
icon: "pi pi-globe",
|
|
313
|
-
disabled: (context: LocalizeItemCommandContext) =>
|
|
314
|
-
!context.data?.items || context.data.items.length === 0 || false,
|
|
315
|
-
execute: async (context: LocalizeItemCommandContext) => {
|
|
316
|
-
const items = context.data?.items;
|
|
317
|
-
if (
|
|
318
|
-
!items ||
|
|
319
|
-
!items?.length ||
|
|
320
|
-
!context.data?.targetLanguages ||
|
|
321
|
-
!context.data?.translationProvider ||
|
|
322
|
-
!context.data?.translationStatus ||
|
|
323
|
-
!context.data?.translationStatus.length
|
|
324
|
-
) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
await defaultTranslateAll(
|
|
328
|
-
context.data?.targetLanguages,
|
|
329
|
-
context.data?.translationStatus,
|
|
330
|
-
context.editContext.sessionId,
|
|
331
|
-
items[0]!,
|
|
332
|
-
context.data?.translationProvider,
|
|
333
|
-
);
|
|
334
|
-
},
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
export const publishItemCommand: ItemCommand = {
|
|
338
|
-
id: "publishItem",
|
|
339
|
-
label: "Publish",
|
|
340
|
-
icon: "pi pi-cloud-upload",
|
|
341
|
-
disabled: (context: ItemCommandContext) =>
|
|
342
|
-
!context.data?.items ||
|
|
343
|
-
context.data.items.length !== 1 ||
|
|
344
|
-
!context.data.items[0]?.canLock ||
|
|
345
|
-
false,
|
|
346
|
-
execute: async (context: ItemCommandContext) => {
|
|
347
|
-
const item = context.data?.items[0];
|
|
348
|
-
if (!item) return;
|
|
349
|
-
await context.editContext.switchView("publish");
|
|
350
|
-
},
|
|
351
|
-
};
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { Button } from "primereact/button";
|
|
2
|
-
import { Dialog } from "primereact/dialog";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import DialogButtons from "../../ui/DialogButtons";
|
|
5
|
-
import { DialogProps } from "../../client/editContext";
|
|
6
|
-
import { getLanguagesAndVersions } from "../../services/contentService";
|
|
7
|
-
import { FullItem, ItemDescriptor } from "../../pageModel";
|
|
8
|
-
import { LanguageVersions } from "../../../types";
|
|
9
|
-
import { Checkbox } from "primereact/checkbox";
|
|
10
|
-
|
|
11
|
-
import { EditContextType } from "../../client/editContext";
|
|
12
|
-
import { Spinner } from "../../ui/Spinner";
|
|
13
|
-
|
|
14
|
-
export type LocalizeItemDialogProps = {
|
|
15
|
-
items: FullItem[];
|
|
16
|
-
editContext: EditContextType;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type LanguageData = {
|
|
20
|
-
name: string;
|
|
21
|
-
items: ItemDescriptor[];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export function LocalizeItemDialog(
|
|
25
|
-
props: LocalizeItemDialogProps & DialogProps<string>,
|
|
26
|
-
) {
|
|
27
|
-
const [languageSelection, setLanguageSelection] = useState<
|
|
28
|
-
Record<string, boolean>
|
|
29
|
-
>({});
|
|
30
|
-
const [languageData, setLanguageData] = useState<Map<string, LanguageData>>();
|
|
31
|
-
|
|
32
|
-
const [isExecuting, setIsExecuting] = useState(false);
|
|
33
|
-
const [currentTask, setCurrentTask] = useState<string>();
|
|
34
|
-
const [completedTasks, setCompletedTasks] = useState<string[]>([]);
|
|
35
|
-
const [finished, setFinished] = useState(false);
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
const itemDescriptors = props.items.map((x) => x.descriptor);
|
|
39
|
-
|
|
40
|
-
const loadLanguages = async () => {
|
|
41
|
-
const itemLanguages = await Promise.all(
|
|
42
|
-
itemDescriptors.map(async (item: ItemDescriptor) => {
|
|
43
|
-
const result = await getLanguagesAndVersions(item);
|
|
44
|
-
return result.data?.languages || [];
|
|
45
|
-
}),
|
|
46
|
-
);
|
|
47
|
-
const languageMap = new Map<string, LanguageData>();
|
|
48
|
-
itemLanguages.forEach((languages, index) => {
|
|
49
|
-
languages.forEach((language: LanguageVersions) => {
|
|
50
|
-
const languageData: LanguageData = languageMap.get(language.name) || {
|
|
51
|
-
name: language.name,
|
|
52
|
-
items: [],
|
|
53
|
-
};
|
|
54
|
-
if (language.versions > 0 && itemDescriptors[index])
|
|
55
|
-
languageData.items.push(itemDescriptors[index]);
|
|
56
|
-
languageMap.set(language.languageCode, languageData);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
setLanguageData(languageMap);
|
|
60
|
-
};
|
|
61
|
-
loadLanguages();
|
|
62
|
-
}, [props]);
|
|
63
|
-
|
|
64
|
-
async function startLocalization() {
|
|
65
|
-
setIsExecuting(true);
|
|
66
|
-
const completedTasks: string[] = [];
|
|
67
|
-
for (const item of props.items) {
|
|
68
|
-
for (const language of Object.keys(languageSelection)) {
|
|
69
|
-
if (!languageSelection[language]) continue;
|
|
70
|
-
if (
|
|
71
|
-
languageData
|
|
72
|
-
?.get(language)
|
|
73
|
-
?.items.find((x) => x.id === item.descriptor.id)
|
|
74
|
-
)
|
|
75
|
-
continue;
|
|
76
|
-
setCurrentTask(`${item.name} - ${language}`);
|
|
77
|
-
await props.editContext.operations.createVersion({
|
|
78
|
-
id: item.descriptor.id,
|
|
79
|
-
language: language,
|
|
80
|
-
version: 0,
|
|
81
|
-
});
|
|
82
|
-
completedTasks.push(`${item.name} - ${language}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
setFinished(true);
|
|
86
|
-
setCompletedTasks(completedTasks);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const allLanguages = Array.from(languageData?.keys() || []).map((x) => ({
|
|
90
|
-
code: x,
|
|
91
|
-
name: languageData?.get(x)?.name || "",
|
|
92
|
-
}));
|
|
93
|
-
|
|
94
|
-
allLanguages.sort((a, b) => a.name.localeCompare(b.name));
|
|
95
|
-
|
|
96
|
-
const dialogContent = getContent();
|
|
97
|
-
|
|
98
|
-
function getContent() {
|
|
99
|
-
if (finished)
|
|
100
|
-
return (
|
|
101
|
-
<div className="justify flex h-full flex-col gap-1">
|
|
102
|
-
{completedTasks.length > 0 && (
|
|
103
|
-
<>
|
|
104
|
-
<div className="px-3 pt-3 text-lg font-bold">
|
|
105
|
-
Finished. Versions created:
|
|
106
|
-
</div>
|
|
107
|
-
<div className="relative flex-1">
|
|
108
|
-
<div className="absolute inset-3 flex flex-col gap-3 overflow-y-auto">
|
|
109
|
-
{completedTasks.map((x, index) => (
|
|
110
|
-
<div key={index}>{x}</div>
|
|
111
|
-
))}
|
|
112
|
-
</div>
|
|
113
|
-
</div>
|
|
114
|
-
</>
|
|
115
|
-
)}
|
|
116
|
-
{completedTasks.length === 0 && (
|
|
117
|
-
<div className="flex h-full items-center justify-center">
|
|
118
|
-
All items are already localized.
|
|
119
|
-
</div>
|
|
120
|
-
)}
|
|
121
|
-
<DialogButtons>
|
|
122
|
-
<Button onClick={() => props.onClose?.(null)} label="Close" />
|
|
123
|
-
</DialogButtons>
|
|
124
|
-
</div>
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
if (isExecuting)
|
|
128
|
-
return (
|
|
129
|
-
<div className="flex h-full items-center justify-center gap-3">
|
|
130
|
-
<Spinner /> Creating version {currentTask}
|
|
131
|
-
</div>
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<div className="justify flex h-full flex-col gap-1 text-sm">
|
|
136
|
-
<div className="flex h-full flex-col gap-2 p-3">
|
|
137
|
-
<div className="my-2">
|
|
138
|
-
Select languages to localize{" "}
|
|
139
|
-
{props.items.map((x) => x.name).join(", ")}:
|
|
140
|
-
</div>
|
|
141
|
-
<div className="my-1 flex items-center gap-2">
|
|
142
|
-
<Checkbox
|
|
143
|
-
checked={allLanguages.every(
|
|
144
|
-
(language) => languageSelection[language.code],
|
|
145
|
-
)}
|
|
146
|
-
onChange={(e) => {
|
|
147
|
-
setLanguageSelection(
|
|
148
|
-
Object.fromEntries(
|
|
149
|
-
Array.from(languageData?.keys() || []).map((language) => [
|
|
150
|
-
language,
|
|
151
|
-
e.checked || false,
|
|
152
|
-
]),
|
|
153
|
-
),
|
|
154
|
-
);
|
|
155
|
-
}}
|
|
156
|
-
/>{" "}
|
|
157
|
-
All
|
|
158
|
-
</div>
|
|
159
|
-
<div className="relative flex-1">
|
|
160
|
-
<div className="absolute top-0 left-0 h-full w-full overflow-y-auto">
|
|
161
|
-
{allLanguages.map((language) => (
|
|
162
|
-
<div
|
|
163
|
-
key={language.code}
|
|
164
|
-
className="my-2 flex items-center gap-2"
|
|
165
|
-
>
|
|
166
|
-
<Checkbox
|
|
167
|
-
checked={languageSelection[language.code] || false}
|
|
168
|
-
onChange={(e) => {
|
|
169
|
-
setLanguageSelection((prev) => ({
|
|
170
|
-
...prev,
|
|
171
|
-
[language.code]: e.checked || false,
|
|
172
|
-
}));
|
|
173
|
-
}}
|
|
174
|
-
/>
|
|
175
|
-
<div>{language.name}</div>
|
|
176
|
-
</div>
|
|
177
|
-
))}
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
</div>
|
|
181
|
-
<DialogButtons>
|
|
182
|
-
<Button onClick={startLocalization} label="Start" />
|
|
183
|
-
<Button onClick={() => props.onClose?.(null)} label="Cancel" />
|
|
184
|
-
</DialogButtons>
|
|
185
|
-
</div>
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return (
|
|
190
|
-
<Dialog
|
|
191
|
-
visible={true}
|
|
192
|
-
onHide={() => {
|
|
193
|
-
props.onClose?.(null);
|
|
194
|
-
}}
|
|
195
|
-
style={{ width: "75vw", height: "75vh" }}
|
|
196
|
-
header="Localize"
|
|
197
|
-
>
|
|
198
|
-
{dialogContent}
|
|
199
|
-
</Dialog>
|
|
200
|
-
);
|
|
201
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { requestTranslation } from "../../services/translationService";
|
|
2
|
-
import { TranslationStatus } from "../../../config/types";
|
|
3
|
-
import { FullItem } from "../../pageModel";
|
|
4
|
-
|
|
5
|
-
export const defaultTranslateAll = async (languageCodes: string[], translationStatus: TranslationStatus[], sessionId: string, item: FullItem, translationProvider: string) => {
|
|
6
|
-
const translationPromises = [];
|
|
7
|
-
|
|
8
|
-
for (const languageCode of languageCodes) {
|
|
9
|
-
const status = translationStatus?.find(
|
|
10
|
-
(x) => x.targetLanguage === languageCode
|
|
11
|
-
);
|
|
12
|
-
if (!status) continue;
|
|
13
|
-
if (status.sourceLanguage === languageCode) continue;
|
|
14
|
-
|
|
15
|
-
translationPromises.push(
|
|
16
|
-
requestTranslation({
|
|
17
|
-
itemId: item.descriptor.id,
|
|
18
|
-
targetLanguage: languageCode,
|
|
19
|
-
sourceLanguage: status.sourceLanguage,
|
|
20
|
-
sessionId: sessionId,
|
|
21
|
-
provider: translationProvider,
|
|
22
|
-
metadata: ""
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
await Promise.all(translationPromises);
|
|
27
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { CommandContext } from "./commands";
|
|
2
|
-
|
|
3
|
-
export function getUndoCommand() {
|
|
4
|
-
return {
|
|
5
|
-
id: "undo",
|
|
6
|
-
label: "Undo",
|
|
7
|
-
icon: "pi pi-undo",
|
|
8
|
-
execute: async (context: CommandContext<any>) => {
|
|
9
|
-
context.editContext.operations.undo();
|
|
10
|
-
},
|
|
11
|
-
disabled: (context: CommandContext<any>) => {
|
|
12
|
-
return (
|
|
13
|
-
context.editContext.editHistory.length === 0 ||
|
|
14
|
-
!context.editContext.editHistory.find(
|
|
15
|
-
(x) => x.sessionId === context.editContext.sessionId && x.canUndo
|
|
16
|
-
)
|
|
17
|
-
);
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function getRedoCommand() {
|
|
23
|
-
return {
|
|
24
|
-
id: "redo",
|
|
25
|
-
label: "Redo",
|
|
26
|
-
icon: "pi pi-refresh",
|
|
27
|
-
execute: async (context: CommandContext<any>) => {
|
|
28
|
-
context.editContext.operations.redo();
|
|
29
|
-
},
|
|
30
|
-
disabled: (context: CommandContext<any>) => {
|
|
31
|
-
return (
|
|
32
|
-
context.editContext.editHistory.length === 0 ||
|
|
33
|
-
!context.editContext.editHistory.find(
|
|
34
|
-
(x) => x.sessionId === context.editContext.sessionId && x.canRedo
|
|
35
|
-
)
|
|
36
|
-
);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|