@alpaca-editor/core 1.0.3880 → 1.0.3881
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/config/config.js +30 -13
- package/dist/config/config.js.map +1 -1
- package/dist/config/types.d.ts +1 -3
- package/dist/editor/ContentTree.js +1 -3
- package/dist/editor/ContentTree.js.map +1 -1
- package/dist/editor/Editor.js +1 -2
- package/dist/editor/Editor.js.map +1 -1
- package/dist/editor/FieldListField.js +19 -16
- package/dist/editor/FieldListField.js.map +1 -1
- package/dist/editor/ImageEditor.js +2 -3
- package/dist/editor/ImageEditor.js.map +1 -1
- package/dist/editor/LinkEditorDialog.d.ts +1 -1
- package/dist/editor/LinkEditorDialog.js +4 -0
- package/dist/editor/LinkEditorDialog.js.map +1 -1
- package/dist/editor/ScrollingContentTree.d.ts +2 -1
- package/dist/editor/ScrollingContentTree.js +19 -2
- package/dist/editor/ScrollingContentTree.js.map +1 -1
- package/dist/editor/ai/AiTerminal.js +0 -1
- package/dist/editor/ai/AiTerminal.js.map +1 -1
- package/dist/editor/ai/AiToolCall.js +1 -1
- package/dist/editor/ai/AiToolCall.js.map +1 -1
- package/dist/editor/client/AboutDialog.d.ts +1 -1
- package/dist/editor/client/EditorClient.js +15 -8
- package/dist/editor/client/EditorClient.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +5 -2
- package/dist/editor/client/editContext.js.map +1 -1
- package/dist/editor/client/operations.d.ts +1 -1
- package/dist/editor/client/operations.js +2 -1
- package/dist/editor/client/operations.js.map +1 -1
- package/dist/editor/commands/commands.d.ts +1 -1
- package/dist/editor/commands/itemCommands.js +45 -9
- package/dist/editor/commands/itemCommands.js.map +1 -1
- package/dist/editor/commands/localizeItem/LocalizeItemDialog.d.ts +1 -1
- package/dist/editor/commands/localizeItem/LocalizeItemDialog.js +5 -5
- package/dist/editor/commands/localizeItem/LocalizeItemDialog.js.map +1 -1
- package/dist/editor/component-designer/ComponentDesignerMenu.js +58 -58
- package/dist/editor/component-designer/ComponentDesignerMenu.js.map +1 -1
- package/dist/editor/component-designer/PlaceholdersEditor.js +22 -27
- package/dist/editor/component-designer/PlaceholdersEditor.js.map +1 -1
- package/dist/editor/componentTreeHelper.js +3 -0
- package/dist/editor/componentTreeHelper.js.map +1 -1
- package/dist/editor/context-menu/CopyMoveMenu.d.ts +1 -1
- package/dist/editor/context-menu/CopyMoveMenu.js +2 -0
- package/dist/editor/context-menu/CopyMoveMenu.js.map +1 -1
- package/dist/editor/context-menu/InsertMenu.d.ts +1 -1
- package/dist/editor/context-menu/InsertMenu.js +2 -0
- package/dist/editor/context-menu/InsertMenu.js.map +1 -1
- package/dist/editor/menubar/PageSelector.d.ts +1 -1
- package/dist/editor/menubar/PageSelector.js +2 -0
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-viewer/EditorForm.js +2 -1
- package/dist/editor/page-viewer/EditorForm.js.map +1 -1
- package/dist/editor/sidebar/ComponentTree.js +5 -3
- package/dist/editor/sidebar/ComponentTree.js.map +1 -1
- package/dist/editor/ui/CopyMoveTargetSelectorDialog.d.ts +10 -0
- package/dist/editor/ui/CopyMoveTargetSelectorDialog.js +32 -0
- package/dist/editor/ui/CopyMoveTargetSelectorDialog.js.map +1 -0
- package/dist/editor/ui/ItemNameDialogNew.d.ts +1 -1
- package/dist/editor/ui/ItemNameDialogNew.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +2 -7
- package/package.json +3 -5
- package/src/config/config.tsx +31 -29
- package/src/config/types.ts +2 -3
- package/src/editor/ContentTree.tsx +1 -4
- package/src/editor/Editor.tsx +7 -9
- package/src/editor/FieldListField.tsx +17 -14
- package/src/editor/ImageEditor.tsx +3 -3
- package/src/editor/LinkEditorDialog.tsx +5 -1
- package/src/editor/ScrollingContentTree.tsx +23 -3
- package/src/editor/ai/AiTerminal.tsx +1 -6
- package/src/editor/ai/AiToolCall.tsx +0 -1
- package/src/editor/client/AboutDialog.tsx +1 -1
- package/src/editor/client/EditorClient.tsx +20 -8
- package/src/editor/client/editContext.ts +9 -2
- package/src/editor/client/operations.ts +2 -1
- package/src/editor/commands/commands.ts +2 -3
- package/src/editor/commands/itemCommands.tsx +64 -9
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +17 -17
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +60 -60
- package/src/editor/component-designer/PlaceholdersEditor.tsx +39 -43
- package/src/editor/componentTreeHelper.tsx +7 -0
- package/src/editor/context-menu/CopyMoveMenu.tsx +1 -0
- package/src/editor/context-menu/InsertMenu.tsx +2 -0
- package/src/editor/menubar/PageSelector.tsx +2 -0
- package/src/editor/page-viewer/EditorForm.tsx +4 -1
- package/src/editor/pageModel.ts +1 -1
- package/src/editor/sidebar/ComponentTree.tsx +4 -3
- package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +72 -0
- package/src/editor/ui/ItemNameDialogNew.tsx +7 -7
- package/src/index.ts +1 -1
- package/src/revision.ts +2 -2
- package/styles.css +2 -2
- package/dist/editor/client/DialogContext.d.ts +0 -12
- package/dist/editor/client/DialogContext.js +0 -25
- package/dist/editor/client/DialogContext.js.map +0 -1
- package/dist/editor/ui/ItemNameDialog.d.ts +0 -11
- package/dist/editor/ui/ItemNameDialog.js +0 -40
- package/dist/editor/ui/ItemNameDialog.js.map +0 -1
- package/src/editor/client/DialogContext.tsx +0 -49
- package/src/editor/ui/ItemNameDialog.tsx +0 -94
|
@@ -2,20 +2,24 @@ import { useEffect, useState } from "react";
|
|
|
2
2
|
import { ItemTreeNodeData } from "./services/contentService";
|
|
3
3
|
|
|
4
4
|
import ContentTree from "./ContentTree";
|
|
5
|
-
import { FullItem } from "./pageModel";
|
|
5
|
+
import { FullItem, ItemDescriptor } from "./pageModel";
|
|
6
6
|
import { contentItemId } from "../config/config";
|
|
7
|
-
import { useEditContext } from "./client/editContext";
|
|
7
|
+
import { useEditContext, EditContextType } from "./client/editContext";
|
|
8
8
|
|
|
9
9
|
export function ScrollingContentTree({
|
|
10
10
|
selectedItemId,
|
|
11
11
|
onSelectionChange,
|
|
12
12
|
rootItemId,
|
|
13
|
+
|
|
14
|
+
expandedItemId,
|
|
13
15
|
}: {
|
|
14
16
|
selectedItemId?: string;
|
|
15
17
|
onSelectionChange?: (itemIds: ItemTreeNodeData[]) => void;
|
|
16
18
|
rootItemId?: string;
|
|
19
|
+
expandedItemId?: string;
|
|
17
20
|
}) {
|
|
18
21
|
const [selectedItem, setSelectdItem] = useState<FullItem | null>(null);
|
|
22
|
+
const [expandedItem, setExpandedItem] = useState<FullItem | null>();
|
|
19
23
|
const editContext = useEditContext();
|
|
20
24
|
|
|
21
25
|
useEffect(() => {
|
|
@@ -31,12 +35,28 @@ export function ScrollingContentTree({
|
|
|
31
35
|
loadItem();
|
|
32
36
|
}, [selectedItemId]);
|
|
33
37
|
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const loadItem = async () => {
|
|
40
|
+
if (!expandedItemId && !selectedItemId) {
|
|
41
|
+
setExpandedItem(null);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const item = await editContext!.itemsRepository.getItem({
|
|
45
|
+
id: expandedItemId ?? selectedItemId ?? "",
|
|
46
|
+
language: editContext!.currentItemDescriptor?.language ?? "en",
|
|
47
|
+
version: 0,
|
|
48
|
+
});
|
|
49
|
+
if (item) setExpandedItem(item);
|
|
50
|
+
};
|
|
51
|
+
loadItem();
|
|
52
|
+
}, [expandedItemId, selectedItemId]);
|
|
53
|
+
|
|
34
54
|
return (
|
|
35
55
|
<div className="absolute inset-0 overflow-auto">
|
|
36
56
|
<ContentTree
|
|
37
57
|
language={editContext!.currentItemDescriptor?.language ?? "en"}
|
|
38
58
|
rootItemId={rootItemId ?? contentItemId}
|
|
39
|
-
expandIdPath={
|
|
59
|
+
expandIdPath={expandedItem?.idPath}
|
|
40
60
|
selectedItemIds={selectedItemId ? [selectedItemId] : []}
|
|
41
61
|
selectionMode="single"
|
|
42
62
|
className="h-full p-1"
|
|
@@ -162,12 +162,7 @@ export function AiTerminal({
|
|
|
162
162
|
// Update the messages state
|
|
163
163
|
setMessages([...currentMessages]);
|
|
164
164
|
setResponseMessages([...currentMessages]);
|
|
165
|
-
|
|
166
|
-
"response",
|
|
167
|
-
messagesRef.current,
|
|
168
|
-
response.messages,
|
|
169
|
-
currentMessages,
|
|
170
|
-
);
|
|
165
|
+
|
|
171
166
|
terminalCallback(
|
|
172
167
|
<AiResponseMessage
|
|
173
168
|
messages={currentMessages}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dialog } from "primereact/dialog";
|
|
2
|
-
import { DialogProps } from "./
|
|
2
|
+
import { DialogProps } from "./editContext";
|
|
3
3
|
import { useImperativeHandle, useState, forwardRef, useEffect } from "react";
|
|
4
4
|
import { buildDate, version } from "../../revision";
|
|
5
5
|
|
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
EditorMode,
|
|
25
25
|
} from "./editContext";
|
|
26
26
|
|
|
27
|
+
import type { OpenDialog } from "./editContext";
|
|
28
|
+
|
|
27
29
|
import { EditorConfiguration, MenuItem } from "../../config/types";
|
|
28
30
|
import { useRouter, useSearchParams, usePathname } from "next/navigation";
|
|
29
31
|
import { findComponent, getComponentById } from "../componentTreeHelper";
|
|
@@ -103,7 +105,7 @@ import { useItemsRepository } from "./itemsRepository";
|
|
|
103
105
|
|
|
104
106
|
import { Spinner } from "../ui/Spinner";
|
|
105
107
|
import { cleanId } from "../utils/id-helper";
|
|
106
|
-
|
|
108
|
+
|
|
107
109
|
import { useDebouncedCallback } from "use-debounce";
|
|
108
110
|
|
|
109
111
|
import { Tour } from "../../tour/Tour";
|
|
@@ -306,8 +308,6 @@ export function EditorClient({
|
|
|
306
308
|
}
|
|
307
309
|
}, [selection]);
|
|
308
310
|
|
|
309
|
-
const dialogContext = useDialog();
|
|
310
|
-
|
|
311
311
|
const itemsRepository = useItemsRepository(
|
|
312
312
|
setModifiedFields,
|
|
313
313
|
setLastEditedFields,
|
|
@@ -1024,7 +1024,7 @@ export function EditorClient({
|
|
|
1024
1024
|
pathname,
|
|
1025
1025
|
router,
|
|
1026
1026
|
searchParams,
|
|
1027
|
-
openDialog:
|
|
1027
|
+
openDialog: openDialog,
|
|
1028
1028
|
event,
|
|
1029
1029
|
data,
|
|
1030
1030
|
};
|
|
@@ -1032,7 +1032,7 @@ export function EditorClient({
|
|
|
1032
1032
|
|
|
1033
1033
|
return result;
|
|
1034
1034
|
},
|
|
1035
|
-
[editContextRef, pathname, router, searchParams
|
|
1035
|
+
[editContextRef, pathname, router, searchParams],
|
|
1036
1036
|
);
|
|
1037
1037
|
|
|
1038
1038
|
const handleKeyDownDebounced = useDebouncedCallback(
|
|
@@ -1389,7 +1389,18 @@ export function EditorClient({
|
|
|
1389
1389
|
switchView();
|
|
1390
1390
|
};
|
|
1391
1391
|
|
|
1392
|
-
const
|
|
1392
|
+
const [dialog, setDialog] = useState<ReactNode>(null);
|
|
1393
|
+
|
|
1394
|
+
const openDialog: OpenDialog = (Component, props) => {
|
|
1395
|
+
return new Promise((resolve) => {
|
|
1396
|
+
const handleClose = (result: any) => {
|
|
1397
|
+
setDialog(null);
|
|
1398
|
+
resolve(result);
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
setDialog(<Component {...(props as any)} onClose={handleClose} />);
|
|
1402
|
+
});
|
|
1403
|
+
};
|
|
1393
1404
|
|
|
1394
1405
|
const operationsContext = getOperationsContext(state, ui);
|
|
1395
1406
|
|
|
@@ -1607,7 +1618,7 @@ export function EditorClient({
|
|
|
1607
1618
|
await (actionButton as ClientFieldButton).clientAction!({
|
|
1608
1619
|
field,
|
|
1609
1620
|
editContext,
|
|
1610
|
-
dialogContext,
|
|
1621
|
+
//dialogContext,
|
|
1611
1622
|
});
|
|
1612
1623
|
}
|
|
1613
1624
|
|
|
@@ -1673,7 +1684,7 @@ export function EditorClient({
|
|
|
1673
1684
|
router,
|
|
1674
1685
|
searchParams,
|
|
1675
1686
|
data,
|
|
1676
|
-
openDialog
|
|
1687
|
+
openDialog,
|
|
1677
1688
|
};
|
|
1678
1689
|
|
|
1679
1690
|
return command.disabled(props);
|
|
@@ -1965,6 +1976,7 @@ export function EditorClient({
|
|
|
1965
1976
|
<Spinner />
|
|
1966
1977
|
</div>
|
|
1967
1978
|
)}
|
|
1979
|
+
{dialog}
|
|
1968
1980
|
</EditContextProvider>
|
|
1969
1981
|
</ModifiedFieldsContextProvider>
|
|
1970
1982
|
</OperationsContextProvider>
|
|
@@ -46,7 +46,6 @@ import { ItemsRepository } from "./itemsRepository";
|
|
|
46
46
|
import { MediaSelectorMode } from "../media-selector/MediaSelector";
|
|
47
47
|
import { ComponentCommand } from "../commands/componentCommands";
|
|
48
48
|
import { AiTerminalOptions } from "../ai/AiTerminal";
|
|
49
|
-
import { OpenDialog } from "./DialogContext";
|
|
50
49
|
import { Wizard } from "../../page-wizard/PageWizard";
|
|
51
50
|
export type DragObject = {
|
|
52
51
|
type: "template" | "component" | "link-component" | "items";
|
|
@@ -65,6 +64,14 @@ export type SelectionRange = {
|
|
|
65
64
|
text: string;
|
|
66
65
|
};
|
|
67
66
|
|
|
67
|
+
export type DialogProps<T> = {
|
|
68
|
+
onClose: (result: T | null) => void;
|
|
69
|
+
};
|
|
70
|
+
export type OpenDialog = <T, P>(
|
|
71
|
+
Component: React.ComponentType<P & DialogProps<T>>,
|
|
72
|
+
props: P,
|
|
73
|
+
) => Promise<T | null>;
|
|
74
|
+
|
|
68
75
|
export type EditorMode = "edit" | "preview" | "suggestions";
|
|
69
76
|
|
|
70
77
|
export type EditContextType = {
|
|
@@ -78,7 +85,7 @@ export type EditContextType = {
|
|
|
78
85
|
items: ItemDescriptor[],
|
|
79
86
|
target: ItemDescriptor,
|
|
80
87
|
index: number,
|
|
81
|
-
) => Promise<
|
|
88
|
+
) => Promise<ItemDescriptor[]>;
|
|
82
89
|
duplicateItem: (
|
|
83
90
|
item: ItemDescriptor,
|
|
84
91
|
target: ItemDescriptor,
|
|
@@ -612,7 +612,8 @@ export function getOperationsContext(
|
|
|
612
612
|
|
|
613
613
|
const copyItems = useCallback(
|
|
614
614
|
async (items: ItemDescriptor[], target: ItemDescriptor, index: number) => {
|
|
615
|
-
await executeCopyItems(items, target, index);
|
|
615
|
+
const result = await executeCopyItems(items, target, index);
|
|
616
|
+
return result.data as ItemDescriptor[];
|
|
616
617
|
},
|
|
617
618
|
[state.itemsRepository],
|
|
618
619
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OpenDialog } from "../client/
|
|
1
|
+
import { OpenDialog } from "../client/editContext";
|
|
2
2
|
import { EditContextType } from "../client/editContext";
|
|
3
3
|
|
|
4
4
|
export type CommandContext<T> = {
|
|
@@ -6,7 +6,7 @@ export type CommandContext<T> = {
|
|
|
6
6
|
openDialog: OpenDialog;
|
|
7
7
|
event?: React.SyntheticEvent;
|
|
8
8
|
searchParams?: URLSearchParams;
|
|
9
|
-
pathname?: string;
|
|
9
|
+
pathname?: string;
|
|
10
10
|
data?: T;
|
|
11
11
|
};
|
|
12
12
|
|
|
@@ -17,7 +17,6 @@ export type Command<T extends CommandData> = {
|
|
|
17
17
|
execute(context: CommandContext<T>): Promise<any>;
|
|
18
18
|
disabled: (context: CommandContext<T>) => boolean;
|
|
19
19
|
keyBinding?: string;
|
|
20
|
-
|
|
21
20
|
};
|
|
22
21
|
|
|
23
22
|
export type CommandData = {};
|
|
@@ -3,6 +3,11 @@ import { FullItem, ItemDescriptor } from "../pageModel";
|
|
|
3
3
|
|
|
4
4
|
import { ItemNameDialog, ItemNameDialogProps } from "../ui/ItemNameDialogNew";
|
|
5
5
|
|
|
6
|
+
import {
|
|
7
|
+
CopyMoveTargetSelectorDialog,
|
|
8
|
+
CopyMoveTargetSelectorDialogProps,
|
|
9
|
+
} from "../ui/CopyMoveTargetSelectorDialog";
|
|
10
|
+
|
|
6
11
|
export type ItemCommandData = CommandData & {
|
|
7
12
|
items: FullItem[];
|
|
8
13
|
};
|
|
@@ -163,12 +168,33 @@ export const moveItemsCommand: MoveCopyItemsCommand = {
|
|
|
163
168
|
!context.data?.items || context.data.items.length !== 1 || false,
|
|
164
169
|
execute: async (context: MoveCopyItemsCommandContext) => {
|
|
165
170
|
const items = context.data?.items;
|
|
166
|
-
|
|
167
|
-
|
|
171
|
+
let targetItem = context.data?.targetItem;
|
|
172
|
+
let index = context.data?.index;
|
|
173
|
+
|
|
174
|
+
if (!items) return;
|
|
175
|
+
|
|
176
|
+
if (!targetItem) {
|
|
177
|
+
const result = await context.openDialog<
|
|
178
|
+
ItemDescriptor,
|
|
179
|
+
CopyMoveTargetSelectorDialogProps
|
|
180
|
+
>(CopyMoveTargetSelectorDialog, {
|
|
181
|
+
items: items ?? [],
|
|
182
|
+
editContext: context.editContext,
|
|
183
|
+
header: "Select Target Item",
|
|
184
|
+
label:
|
|
185
|
+
items?.length && items.length > 1
|
|
186
|
+
? `Move ${items?.length} items`
|
|
187
|
+
: `Move item`,
|
|
188
|
+
});
|
|
189
|
+
if (result) {
|
|
190
|
+
targetItem = result;
|
|
191
|
+
index = -1;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
168
194
|
|
|
169
|
-
if (!
|
|
195
|
+
if (!targetItem) return;
|
|
170
196
|
|
|
171
|
-
context.editContext.operations.moveItems(items, targetItem, index);
|
|
197
|
+
context.editContext.operations.moveItems(items, targetItem, index ?? 0);
|
|
172
198
|
},
|
|
173
199
|
};
|
|
174
200
|
|
|
@@ -177,15 +203,44 @@ export const copyItemsCommand: MoveCopyItemsCommand = {
|
|
|
177
203
|
label: "Copy Items",
|
|
178
204
|
icon: "pi pi-copy",
|
|
179
205
|
disabled: (context: MoveCopyItemsCommandContext) =>
|
|
180
|
-
!context.data?.items ||
|
|
206
|
+
!context.data?.items || false,
|
|
181
207
|
execute: async (context: MoveCopyItemsCommandContext) => {
|
|
208
|
+
console.log("copyItemsCommand", context.data);
|
|
182
209
|
const items = context.data?.items;
|
|
183
|
-
|
|
184
|
-
|
|
210
|
+
let targetItem = context.data?.targetItem;
|
|
211
|
+
let index = context.data?.index;
|
|
212
|
+
|
|
213
|
+
console.log("targetItem", targetItem);
|
|
214
|
+
|
|
215
|
+
if (!targetItem) {
|
|
216
|
+
const result = await context.openDialog<
|
|
217
|
+
ItemDescriptor,
|
|
218
|
+
CopyMoveTargetSelectorDialogProps
|
|
219
|
+
>(CopyMoveTargetSelectorDialog, {
|
|
220
|
+
items: items ?? [],
|
|
221
|
+
editContext: context.editContext,
|
|
222
|
+
header: "Select Target Item",
|
|
223
|
+
label:
|
|
224
|
+
items?.length && items.length > 1
|
|
225
|
+
? `Copy ${items?.length} items`
|
|
226
|
+
: `Copy item`,
|
|
227
|
+
});
|
|
228
|
+
if (result) {
|
|
229
|
+
targetItem = result;
|
|
230
|
+
index = -1;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
185
233
|
|
|
186
|
-
if (!items || !targetItem
|
|
234
|
+
if (!items || !targetItem) return;
|
|
187
235
|
|
|
188
|
-
context.editContext.operations.copyItems(
|
|
236
|
+
const result = await context.editContext.operations.copyItems(
|
|
237
|
+
items,
|
|
238
|
+
targetItem,
|
|
239
|
+
index ?? 0,
|
|
240
|
+
);
|
|
241
|
+
if (result && result.length > 0 && result[0]) {
|
|
242
|
+
context.editContext.loadItem(result[0]);
|
|
243
|
+
}
|
|
189
244
|
},
|
|
190
245
|
};
|
|
191
246
|
|
|
@@ -2,7 +2,7 @@ import { Button } from "primereact/button";
|
|
|
2
2
|
import { Dialog } from "primereact/dialog";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import DialogButtons from "../../ui/DialogButtons";
|
|
5
|
-
import { DialogProps } from "../../client/
|
|
5
|
+
import { DialogProps } from "../../client/editContext";
|
|
6
6
|
import { getLanguagesAndVersions } from "../../services/contentService";
|
|
7
7
|
import { FullItem, ItemDescriptor } from "../../pageModel";
|
|
8
8
|
import { LanguageVersions } from "../../../types";
|
|
@@ -22,7 +22,7 @@ type LanguageData = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export function LocalizeItemDialog(
|
|
25
|
-
props: LocalizeItemDialogProps & DialogProps<string
|
|
25
|
+
props: LocalizeItemDialogProps & DialogProps<string>,
|
|
26
26
|
) {
|
|
27
27
|
const [languageSelection, setLanguageSelection] = useState<
|
|
28
28
|
Record<string, boolean>
|
|
@@ -42,7 +42,7 @@ export function LocalizeItemDialog(
|
|
|
42
42
|
itemDescriptors.map(async (item: ItemDescriptor) => {
|
|
43
43
|
const result = await getLanguagesAndVersions(item);
|
|
44
44
|
return result.data?.languages || [];
|
|
45
|
-
})
|
|
45
|
+
}),
|
|
46
46
|
);
|
|
47
47
|
const languageMap = new Map<string, LanguageData>();
|
|
48
48
|
itemLanguages.forEach((languages, index) => {
|
|
@@ -51,7 +51,7 @@ export function LocalizeItemDialog(
|
|
|
51
51
|
name: language.name,
|
|
52
52
|
items: [],
|
|
53
53
|
};
|
|
54
|
-
if (language.versions > 0)
|
|
54
|
+
if (language.versions > 0 && itemDescriptors[index])
|
|
55
55
|
languageData.items.push(itemDescriptors[index]);
|
|
56
56
|
languageMap.set(language.languageCode, languageData);
|
|
57
57
|
});
|
|
@@ -98,13 +98,13 @@ export function LocalizeItemDialog(
|
|
|
98
98
|
function getContent() {
|
|
99
99
|
if (finished)
|
|
100
100
|
return (
|
|
101
|
-
<div className="flex
|
|
101
|
+
<div className="justify flex h-full flex-col gap-1">
|
|
102
102
|
{completedTasks.length > 0 && (
|
|
103
103
|
<>
|
|
104
|
-
<div className="text-lg font-bold
|
|
104
|
+
<div className="px-3 pt-3 text-lg font-bold">
|
|
105
105
|
Finished. Versions created:
|
|
106
106
|
</div>
|
|
107
|
-
<div className="flex-1
|
|
107
|
+
<div className="relative flex-1">
|
|
108
108
|
<div className="absolute inset-3 flex flex-col gap-3 overflow-y-auto">
|
|
109
109
|
{completedTasks.map((x, index) => (
|
|
110
110
|
<div key={index}>{x}</div>
|
|
@@ -114,7 +114,7 @@ export function LocalizeItemDialog(
|
|
|
114
114
|
</>
|
|
115
115
|
)}
|
|
116
116
|
{completedTasks.length === 0 && (
|
|
117
|
-
<div className="flex items-center justify-center
|
|
117
|
+
<div className="flex h-full items-center justify-center">
|
|
118
118
|
All items are already localized.
|
|
119
119
|
</div>
|
|
120
120
|
)}
|
|
@@ -126,22 +126,22 @@ export function LocalizeItemDialog(
|
|
|
126
126
|
|
|
127
127
|
if (isExecuting)
|
|
128
128
|
return (
|
|
129
|
-
<div className="flex items-center justify-center gap-3
|
|
129
|
+
<div className="flex h-full items-center justify-center gap-3">
|
|
130
130
|
<Spinner /> Creating version {currentTask}
|
|
131
131
|
</div>
|
|
132
132
|
);
|
|
133
133
|
|
|
134
134
|
return (
|
|
135
|
-
<div className="flex
|
|
136
|
-
<div className="
|
|
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
137
|
<div className="my-2">
|
|
138
138
|
Select languages to localize{" "}
|
|
139
139
|
{props.items.map((x) => x.name).join(", ")}:
|
|
140
140
|
</div>
|
|
141
|
-
<div className="flex items-center gap-2
|
|
141
|
+
<div className="my-1 flex items-center gap-2">
|
|
142
142
|
<Checkbox
|
|
143
143
|
checked={allLanguages.every(
|
|
144
|
-
(language) => languageSelection[language.code]
|
|
144
|
+
(language) => languageSelection[language.code],
|
|
145
145
|
)}
|
|
146
146
|
onChange={(e) => {
|
|
147
147
|
setLanguageSelection(
|
|
@@ -149,19 +149,19 @@ export function LocalizeItemDialog(
|
|
|
149
149
|
Array.from(languageData?.keys() || []).map((language) => [
|
|
150
150
|
language,
|
|
151
151
|
e.checked || false,
|
|
152
|
-
])
|
|
153
|
-
)
|
|
152
|
+
]),
|
|
153
|
+
),
|
|
154
154
|
);
|
|
155
155
|
}}
|
|
156
156
|
/>{" "}
|
|
157
157
|
All
|
|
158
158
|
</div>
|
|
159
159
|
<div className="relative flex-1">
|
|
160
|
-
<div className="absolute top-0 left-0
|
|
160
|
+
<div className="absolute top-0 left-0 h-full w-full overflow-y-auto">
|
|
161
161
|
{allLanguages.map((language) => (
|
|
162
162
|
<div
|
|
163
163
|
key={language.code}
|
|
164
|
-
className="flex items-center gap-2
|
|
164
|
+
className="my-2 flex items-center gap-2"
|
|
165
165
|
>
|
|
166
166
|
<Checkbox
|
|
167
167
|
checked={languageSelection[language.code] || false}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
createRendering,
|
|
6
6
|
loadComponentDetails,
|
|
7
7
|
} from "../services/componentDesignerService";
|
|
8
|
-
import {
|
|
8
|
+
import { ItemNameDialog } from "../ui/ItemNameDialogNew";
|
|
9
9
|
import { useRef } from "react";
|
|
10
10
|
import { useEditContext } from "../client/editContext";
|
|
11
11
|
import { ItemLanguageVersion } from "../menubar/ItemLanguageVersion";
|
|
@@ -14,78 +14,78 @@ export function ComponentDesignerMenu() {
|
|
|
14
14
|
const context = useEditContext();
|
|
15
15
|
if (!context) return;
|
|
16
16
|
|
|
17
|
-
const menuItems = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
];
|
|
39
|
-
const itemNameDialogRef = useRef<ItemNameDialogHandle>(null);
|
|
17
|
+
// const menuItems = [
|
|
18
|
+
// {
|
|
19
|
+
// id: "newComponent",
|
|
20
|
+
// label: "New Component",
|
|
21
|
+
// icon: "pi pi-fw pi-plus",
|
|
22
|
+
// command: () => createNew(),
|
|
23
|
+
// // disabled: !context.componentRenderingFolder,
|
|
24
|
+
// },
|
|
25
|
+
// {
|
|
26
|
+
// id: "newRendering",
|
|
27
|
+
// label: "New Rendering",
|
|
28
|
+
// icon: "pi pi-fw pi-palette",
|
|
29
|
+
// command: () => createNewRendering(),
|
|
30
|
+
// disabled: !context.componentDesignerComponent,
|
|
31
|
+
// },
|
|
32
|
+
// {
|
|
33
|
+
// id: "delete",
|
|
34
|
+
// label: "Delete rendering",
|
|
35
|
+
// icon: "pi pi-fw pi-trash",
|
|
36
|
+
// disabled: !context.componentDesignerRendering,
|
|
37
|
+
// },
|
|
38
|
+
// ];
|
|
39
|
+
// const itemNameDialogRef = useRef<ItemNameDialogHandle>(null);
|
|
40
40
|
|
|
41
|
-
const createNew = async () => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
41
|
+
// const createNew = async () => {
|
|
42
|
+
// itemNameDialogRef.current?.show({
|
|
43
|
+
// title: "Choose Component Name",
|
|
44
|
+
// accept: async (name) => {
|
|
45
|
+
// await createNewComponent(name, context.page!.item);
|
|
46
|
+
// },
|
|
47
|
+
// });
|
|
48
|
+
// };
|
|
49
49
|
|
|
50
|
-
const createNewRendering = async () => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
// const createNewRendering = async () => {
|
|
51
|
+
// itemNameDialogRef.current?.show({
|
|
52
|
+
// title: "Choose Rendering Name",
|
|
53
|
+
// accept: async (name) => {
|
|
54
|
+
// if (!context.componentDesignerComponent) return;
|
|
55
|
+
// const details = await createRendering(
|
|
56
|
+
// name,
|
|
57
|
+
// context.page!.item,
|
|
58
|
+
// context.componentDesignerComponent.templateId
|
|
59
|
+
// );
|
|
60
|
+
// if (!("id" in details)) return;
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
62
|
+
// const component = await loadComponentDetails(
|
|
63
|
+
// context.componentDesignerComponent.templateId,
|
|
64
|
+
// context!.page!.item.id
|
|
65
|
+
// );
|
|
66
|
+
// // const rendering = await getItem({
|
|
67
|
+
// // id: details.id,
|
|
68
|
+
// // language: "en",
|
|
69
|
+
// // version: 0,
|
|
70
|
+
// // });
|
|
71
|
+
// context.setComponentDesignerComponent(component);
|
|
72
|
+
// // context.setComponentDesignerRendering(rendering);
|
|
73
|
+
// },
|
|
74
|
+
// });
|
|
75
|
+
// };
|
|
76
76
|
|
|
77
77
|
return (
|
|
78
78
|
<>
|
|
79
|
-
<Menubar
|
|
79
|
+
{/* <Menubar
|
|
80
80
|
model={menuItems}
|
|
81
81
|
end={
|
|
82
82
|
<div className="flex items-center space-x-2">
|
|
83
83
|
<ItemLanguageVersion />
|
|
84
84
|
</div>
|
|
85
85
|
}
|
|
86
|
-
className="
|
|
86
|
+
className="rounded-none border-0 border-b bg-gray-50 p-1 text-sm"
|
|
87
87
|
></Menubar>
|
|
88
|
-
<ItemNameDialog ref={itemNameDialogRef} />
|
|
88
|
+
<ItemNameDialog ref={itemNameDialogRef} /> */}
|
|
89
89
|
</>
|
|
90
90
|
);
|
|
91
91
|
}
|