@alpaca-headless/alpaca-headless-nextjs 1.0.246 → 1.0.253
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/editor.css +0 -4
- package/dist/esm/Editor.js +13 -0
- package/dist/esm/client-components/ClientLink.js +2 -1
- package/dist/esm/client-components/MultiComponentEditor.js +1 -1
- package/dist/esm/components/Image.js +1 -1
- package/dist/esm/components/Link.js +3 -5
- package/dist/esm/components/Picture.js +3 -4
- package/dist/esm/components/PictureEditor.js +1 -1
- package/dist/esm/components/PictureEditorWrapper.js +1 -0
- package/dist/esm/components/Placeholder.js +114 -90
- package/dist/esm/components/RichText.js +2 -3
- package/dist/esm/components/Slot.js +2 -2
- package/dist/esm/components/Text.js +2 -3
- package/dist/esm/components/Translate.js +4 -7
- package/dist/esm/components/TranslateEditorWrapper.js +7 -0
- package/dist/esm/editor/ContentTree.js +10 -4
- package/dist/esm/editor/DictionaryEditor.js +1 -1
- package/dist/esm/editor/EditFrame.js +1 -1
- package/dist/esm/editor/EditorClient.js +27 -15
- package/dist/esm/editor/EditorClientHost.js +2 -2
- package/dist/esm/editor/FieldList.js +2 -2
- package/dist/esm/editor/FieldListField.js +13 -64
- package/dist/esm/editor/FieldListFieldWithFallbacks.js +79 -0
- package/dist/esm/editor/PictureEditorDialog.js +1 -1
- package/dist/esm/editor/PlaceholderDropZone.js +1 -1
- package/dist/esm/editor/PreviewClient.js +1 -0
- package/dist/esm/editor/ai/AiPopup.js +2 -2
- package/dist/esm/editor/ai/AiTerminal.js +17 -5
- package/dist/esm/editor/ai/EditorAiTerminal.js +5 -0
- package/dist/esm/editor/component-designer/ComponentDesigner.js +7 -0
- package/dist/esm/editor/component-designer/ComponentDesignerAiTerminal.js +5 -0
- package/dist/esm/editor/component-designer/ComponentDesignerMenu.js +39 -0
- package/dist/esm/editor/component-designer/ComponentPreview.js +20 -0
- package/dist/esm/editor/component-designer/ComponentRenderingEditor.js +38 -0
- package/dist/esm/editor/component-designer/ComponentSelectionTree.js +56 -0
- package/dist/esm/editor/component-designer/componentDesignerContext.js +22 -0
- package/dist/esm/editor/config/config.js +81 -15
- package/dist/esm/editor/config/types.js +1 -0
- package/dist/esm/editor/fieldTypes/CheckboxEditor.js +1 -1
- package/dist/esm/editor/fieldTypes/DropLinkEditor.js +1 -1
- package/dist/esm/editor/fieldTypes/MultiLineText.js +1 -1
- package/dist/esm/editor/fieldTypes/RawEditor.js +1 -1
- package/dist/esm/editor/fieldTypes/RichTextEditorComponent.js +1 -1
- package/dist/esm/editor/fieldTypes/SingleLineText.js +2 -4
- package/dist/esm/editor/fieldTypes/TreeListEditor.js +1 -1
- package/dist/esm/editor/menubar/Menu.js +1 -1
- package/dist/esm/editor/services/aiService.js +20 -0
- package/dist/esm/editor/services/componentDesignerService.js +23 -0
- package/dist/esm/editor/services/contentService.js +2 -4
- package/dist/esm/editor/services/editService.js +1 -35
- package/dist/esm/editor/services/serviceHelper.js +45 -0
- package/dist/esm/editor/sidebar/ComponentPalette.js +1 -1
- package/dist/esm/editor/sidebar/MainContentTree.js +3 -3
- package/dist/esm/editor/sidebar/Sidebar.js +1 -1
- package/dist/esm/editor/sidebar/SidebarView.js +17 -13
- package/dist/esm/editor/sidebar/Workbox.js +1 -1
- package/dist/esm/editor/{ItemNameDialog.js → ui/ItemNameDialog.js} +3 -2
- package/dist/esm/index.js +3 -2
- package/dist/esm/loadRouteData.js +1 -22
- package/dist/esm/middleware/handleRequest.js +1 -1
- package/dist/esm/public.js +10 -0
- package/dist/esm/renderContext.js +49 -0
- package/dist/esm/renderings.js +87 -0
- package/dist/esm/translate.js +7 -0
- package/package.json +2 -1
- package/types/Editor.d.ts +9 -0
- package/types/components/Image.d.ts +2 -0
- package/types/components/Link.d.ts +3 -2
- package/types/components/LockedFieldIndicator.d.ts +1 -1
- package/types/components/Picture.d.ts +2 -1
- package/types/components/Placeholder.d.ts +5 -8
- package/types/components/RichText.d.ts +3 -1
- package/types/components/Slot.d.ts +3 -1
- package/types/components/Text.d.ts +3 -1
- package/types/components/Translate.d.ts +3 -1
- package/types/components/TranslateEditorWrapper.d.ts +3 -0
- package/types/editor/ContentTree.d.ts +2 -1
- package/types/editor/ContextMenu.d.ts +1 -1
- package/types/editor/EditorClient.d.ts +5 -6
- package/types/editor/EditorClientHost.d.ts +5 -8
- package/types/editor/FieldListField.d.ts +3 -1
- package/types/editor/FieldListFieldWithFallbacks.d.ts +8 -0
- package/types/editor/PreviewClient.d.ts +1 -0
- package/types/editor/ai/EditorAiTerminal.d.ts +4 -0
- package/types/editor/component-designer/ComponentDesigner.d.ts +1 -0
- package/types/editor/component-designer/ComponentDesignerAiTerminal.d.ts +1 -0
- package/types/editor/component-designer/ComponentDesignerMenu.d.ts +1 -0
- package/types/editor/component-designer/ComponentPreview.d.ts +1 -0
- package/types/editor/component-designer/ComponentRenderingEditor.d.ts +2 -0
- package/types/editor/component-designer/ComponentSelectionTree.d.ts +1 -0
- package/types/editor/component-designer/componentDesignerContext.d.ts +14 -0
- package/types/editor/config/config.d.ts +1 -1
- package/types/editor/{Editor.d.ts → config/types.d.ts} +7 -10
- package/types/editor/editContext.d.ts +5 -3
- package/types/editor/services/aiService.d.ts +8 -0
- package/types/editor/services/componentDesignerService.d.ts +2 -0
- package/types/editor/services/contentService.d.ts +1 -1
- package/types/editor/services/editService.d.ts +2 -6
- package/types/editor/services/serviceHelper.d.ts +7 -0
- package/types/editor/sidebar/MainContentTree.d.ts +2 -2
- package/types/editor/sidebar/Sidebar.d.ts +1 -1
- package/types/editor/sidebar/SidebarView.d.ts +1 -1
- package/types/editor/{ItemNameDialog.d.ts → ui/ItemNameDialog.d.ts} +1 -0
- package/types/index.d.ts +4 -2
- package/types/loadRouteData.d.ts +1 -0
- package/types/public.d.ts +12 -0
- package/types/renderContext.d.ts +41 -0
- package/types/renderings.d.ts +7 -0
- package/types/servertypes.d.ts +2 -0
- package/types/translate.d.ts +2 -0
- package/dist/esm/alpacaContext.js +0 -16
- package/dist/esm/editor/Editor.js +0 -15
- package/dist/esm/editor/index.js +0 -4
- package/types/alpacaContext.d.ts +0 -31
- package/types/editor/index.d.ts +0 -4
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import ContentTree from "../ContentTree";
|
|
12
|
+
import { getItem } from "../services/contentService";
|
|
13
|
+
import { useComponentDesignerContext } from "./componentDesignerContext";
|
|
14
|
+
export function ComponentSelectionTree() {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
const context = useComponentDesignerContext();
|
|
17
|
+
if (!context)
|
|
18
|
+
return;
|
|
19
|
+
const loadItem = (item) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const itemData = yield getItem({
|
|
21
|
+
id: item.id,
|
|
22
|
+
language: item.language,
|
|
23
|
+
version: item.version,
|
|
24
|
+
});
|
|
25
|
+
if (!itemData)
|
|
26
|
+
return;
|
|
27
|
+
if (itemData.templateId === "d7dd274d-69ee-4686-9171-21c89a088fd8") {
|
|
28
|
+
context.setComponentRenderingItem(itemData);
|
|
29
|
+
context.setComponentRenderingFolder(undefined);
|
|
30
|
+
context.setSampleItem(undefined);
|
|
31
|
+
}
|
|
32
|
+
if (itemData.templateId === "dcfdeb8f-c2a6-4046-a7fc-23296b2d4569") {
|
|
33
|
+
context.setComponentRenderingFolder(itemData);
|
|
34
|
+
context.setComponentRenderingItem(undefined);
|
|
35
|
+
context.setSampleItem(undefined);
|
|
36
|
+
}
|
|
37
|
+
if (itemData.templateId === "e85ffcff-38b8-4a0b-844e-17f6faf745fe") {
|
|
38
|
+
context.setSampleItem(itemData);
|
|
39
|
+
const parent = yield getItem({
|
|
40
|
+
id: itemData._editor.parentId,
|
|
41
|
+
language: item.language,
|
|
42
|
+
version: 0,
|
|
43
|
+
});
|
|
44
|
+
context.setComponentRenderingItem(parent);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return (_jsx(ContentTree, { rootItemId: "{11111111-1111-1111-1111-111111111111}", expandIdPath: "{11111111-1111-1111-1111-111111111111}/{0de95ae4-41ab-4d01-9eb0-67441b7c2450}/{c8c7b950-e876-448e-991f-5eaf756a1db2}/{5f2dcc67-d9c1-451f-ad14-85244c9cca41}", className: "a-p-1", selectionMode: "single", selectedItemIds: [
|
|
48
|
+
((_a = context.sampleItem) === null || _a === void 0 ? void 0 : _a.id) ||
|
|
49
|
+
((_b = context.componentRenderingItem) === null || _b === void 0 ? void 0 : _b.id) ||
|
|
50
|
+
((_c = context.componentRenderingFolder) === null || _c === void 0 ? void 0 : _c.id) ||
|
|
51
|
+
"11111111-1111-1111-1111-111111111111",
|
|
52
|
+
], onSelectionChange: (selection) => {
|
|
53
|
+
const selectedItem = selection;
|
|
54
|
+
loadItem(selectedItem);
|
|
55
|
+
} }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { useEditContext } from "../editContext";
|
|
3
|
+
export function getComponentDesignerContext() {
|
|
4
|
+
const [componentRenderingItem, setComponentRenderingItem] = useState();
|
|
5
|
+
const [componentRenderingFolder, setComponentRenderingFolder] = useState();
|
|
6
|
+
const [sampleItem, setSampleItem] = useState();
|
|
7
|
+
const [code, setCode] = useState();
|
|
8
|
+
return {
|
|
9
|
+
componentRenderingItem,
|
|
10
|
+
setComponentRenderingItem,
|
|
11
|
+
componentRenderingFolder,
|
|
12
|
+
setComponentRenderingFolder,
|
|
13
|
+
sampleItem,
|
|
14
|
+
setSampleItem,
|
|
15
|
+
code,
|
|
16
|
+
setCode,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function useComponentDesignerContext() {
|
|
20
|
+
var _a;
|
|
21
|
+
return (_a = useEditContext()) === null || _a === void 0 ? void 0 : _a.componentDesignerContext;
|
|
22
|
+
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
11
|
import { RichTextEditor } from "../fieldTypes/RichTextEditor";
|
|
3
12
|
import { LinkFieldEditor } from "../fieldTypes/LinkFieldEditor";
|
|
@@ -23,11 +32,15 @@ import { GraphQL } from "../sidebar/GraphQL";
|
|
|
23
32
|
import { PageViewer } from "../PageViewer";
|
|
24
33
|
import { ItemEditor } from "../views/ItemEditor";
|
|
25
34
|
import { EditorForm } from "../sidebar/EditorForm";
|
|
26
|
-
import {
|
|
35
|
+
import { EditorAiTerminal } from "../ai/EditorAiTerminal";
|
|
27
36
|
import { Insert } from "../sidebar/Insert";
|
|
28
37
|
import { getCreateAndSwitchToNewVersionCommand } from "../commands/createVersionCommand";
|
|
29
38
|
import { getSelectedComponentCommands } from "../commands/componentCommands";
|
|
30
39
|
import { getRedoCommand, getUndoCommand } from "../commands/undo";
|
|
40
|
+
import { ComponentSelectionTree } from "../component-designer/ComponentSelectionTree";
|
|
41
|
+
import { ComponentDesigner } from "../component-designer/ComponentDesigner";
|
|
42
|
+
import { ComponentDesignerMenu } from "../component-designer/ComponentDesignerMenu";
|
|
43
|
+
import { ComponentDesignerAiTerminal } from "../component-designer/ComponentDesignerAiTerminal";
|
|
31
44
|
const defaultRichTextEditorProfile = {
|
|
32
45
|
toolbar: {
|
|
33
46
|
groups: [
|
|
@@ -131,25 +144,18 @@ export const configuration = {
|
|
|
131
144
|
],
|
|
132
145
|
},
|
|
133
146
|
{
|
|
134
|
-
name: "
|
|
147
|
+
name: "navigate",
|
|
135
148
|
title: "Navigate",
|
|
136
149
|
icon: "pi pi-sitemap",
|
|
137
|
-
centerPanelView: "
|
|
150
|
+
centerPanelView: "page",
|
|
138
151
|
leftSidebar: [
|
|
139
152
|
{
|
|
140
|
-
name: "
|
|
141
|
-
icon: "pi pi-
|
|
142
|
-
title: "
|
|
143
|
-
content: _jsx(MainContentTree, {}),
|
|
153
|
+
name: "tree",
|
|
154
|
+
icon: "pi pi-list",
|
|
155
|
+
title: "Select Page",
|
|
156
|
+
content: _jsx(MainContentTree, { mode: "select-page" }),
|
|
144
157
|
initialSize: 100,
|
|
145
158
|
},
|
|
146
|
-
{
|
|
147
|
-
name: "history",
|
|
148
|
-
icon: "pi pi-clock",
|
|
149
|
-
title: "History",
|
|
150
|
-
content: _jsx(EditHistory, {}),
|
|
151
|
-
initialSize: 0,
|
|
152
|
-
},
|
|
153
159
|
],
|
|
154
160
|
},
|
|
155
161
|
{
|
|
@@ -175,7 +181,7 @@ export const configuration = {
|
|
|
175
181
|
name: "ai-terminal",
|
|
176
182
|
icon: "pi pi-comments",
|
|
177
183
|
title: "AI",
|
|
178
|
-
content: _jsx(
|
|
184
|
+
content: _jsx(EditorAiTerminal, {}),
|
|
179
185
|
initialSize: 20,
|
|
180
186
|
},
|
|
181
187
|
{
|
|
@@ -187,6 +193,28 @@ export const configuration = {
|
|
|
187
193
|
},
|
|
188
194
|
],
|
|
189
195
|
},
|
|
196
|
+
{
|
|
197
|
+
name: "content-editor",
|
|
198
|
+
title: "Content Editor",
|
|
199
|
+
icon: "pi pi-list",
|
|
200
|
+
centerPanelView: "form",
|
|
201
|
+
leftSidebar: [
|
|
202
|
+
{
|
|
203
|
+
name: "tree",
|
|
204
|
+
icon: "pi pi-sitemap",
|
|
205
|
+
title: "Content",
|
|
206
|
+
content: _jsx(MainContentTree, { mode: "normal" }),
|
|
207
|
+
initialSize: 100,
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: "history",
|
|
211
|
+
icon: "pi pi-clock",
|
|
212
|
+
title: "History",
|
|
213
|
+
content: _jsx(EditHistory, {}),
|
|
214
|
+
initialSize: 0,
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
},
|
|
190
218
|
{
|
|
191
219
|
name: "dictionary",
|
|
192
220
|
title: "Dictionary",
|
|
@@ -237,10 +265,34 @@ export const configuration = {
|
|
|
237
265
|
},
|
|
238
266
|
],
|
|
239
267
|
},
|
|
268
|
+
{
|
|
269
|
+
name: "component-designer",
|
|
270
|
+
title: "Component Designer",
|
|
271
|
+
icon: "pi pi-palette",
|
|
272
|
+
centerPanelView: "component-designer",
|
|
273
|
+
menuBar: _jsx(ComponentDesignerMenu, {}),
|
|
274
|
+
leftSidebar: [
|
|
275
|
+
{
|
|
276
|
+
name: "component-designer",
|
|
277
|
+
icon: "pi pi-palette",
|
|
278
|
+
title: "Component List",
|
|
279
|
+
initialSize: 60,
|
|
280
|
+
content: _jsx(ComponentSelectionTree, {}),
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: "ai-terminal",
|
|
284
|
+
icon: "pi pi-comments",
|
|
285
|
+
title: "AI",
|
|
286
|
+
content: _jsx(ComponentDesignerAiTerminal, {}),
|
|
287
|
+
initialSize: 40,
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
},
|
|
240
291
|
],
|
|
241
292
|
centerPanelViews: [
|
|
242
293
|
{ name: "page", content: _jsx(PageViewer, {}) },
|
|
243
294
|
{ name: "form", content: _jsx(ItemEditor, {}) },
|
|
295
|
+
{ name: "component-designer", content: _jsx(ComponentDesigner, {}) },
|
|
244
296
|
],
|
|
245
297
|
mainNavigation: [
|
|
246
298
|
getUndoCommand(),
|
|
@@ -255,6 +307,20 @@ export const configuration = {
|
|
|
255
307
|
icon: "pi pi-fw",
|
|
256
308
|
items: (editContext) => getSelectedComponentCommands(editContext),
|
|
257
309
|
},
|
|
310
|
+
{
|
|
311
|
+
name: "preview",
|
|
312
|
+
disabled: () => false,
|
|
313
|
+
label: "Preview",
|
|
314
|
+
icon: "pi pi-fw pi-external-link",
|
|
315
|
+
execute: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
316
|
+
const currentUrl = new URL(window.location.href);
|
|
317
|
+
const searchParams = currentUrl.searchParams;
|
|
318
|
+
if (searchParams.get("mode") === "edit") {
|
|
319
|
+
searchParams.set("mode", "preview");
|
|
320
|
+
}
|
|
321
|
+
window.open(currentUrl.href);
|
|
322
|
+
}),
|
|
323
|
+
},
|
|
258
324
|
],
|
|
259
325
|
},
|
|
260
326
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useEditContext } from "
|
|
3
|
+
import { useEditContext } from "../editContext";
|
|
4
4
|
import { Checkbox } from "primereact/checkbox";
|
|
5
5
|
export function CheckboxEditor({ field, readOnly, }) {
|
|
6
6
|
var _a;
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
import { Dropdown } from "primereact/dropdown";
|
|
13
|
-
import { useEditContext } from "
|
|
13
|
+
import { useEditContext } from "../editContext";
|
|
14
14
|
import { useEffect, useState } from "react";
|
|
15
15
|
import { loadDropLinkOptions } from "../services/editService";
|
|
16
16
|
import { Skeleton } from "primereact/skeleton";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { InputTextarea } from "primereact/inputtextarea";
|
|
4
|
-
import { useEditContext } from "
|
|
4
|
+
import { useEditContext } from "../editContext";
|
|
5
5
|
export function MultiLineText({ field, readOnly, }) {
|
|
6
6
|
var _a;
|
|
7
7
|
const editContext = useEditContext();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { InputTextarea } from "primereact/inputtextarea";
|
|
4
|
-
import { useEditContext } from "
|
|
4
|
+
import { useEditContext } from "../editContext";
|
|
5
5
|
export function RawEditor({ field, readOnly, }) {
|
|
6
6
|
var _a, _b;
|
|
7
7
|
const editContext = useEditContext();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { Editor } from "primereact/editor";
|
|
4
|
-
import { useEditContext } from "
|
|
4
|
+
import { useEditContext } from "../editContext";
|
|
5
5
|
import Quill from "quill";
|
|
6
6
|
let Inline = Quill.import("blots/inline");
|
|
7
7
|
class BoldBlot extends Inline {
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { InputText } from "primereact/inputtext";
|
|
4
|
-
import { useEditContext } from "
|
|
4
|
+
import { useEditContext } from "../editContext";
|
|
5
5
|
export function SingleLineText({ field, readOnly, }) {
|
|
6
6
|
var _a;
|
|
7
7
|
const editContext = useEditContext();
|
|
8
8
|
if (!editContext)
|
|
9
9
|
return;
|
|
10
10
|
const liveField = editContext.getLiveField(field);
|
|
11
|
-
if (!editContext)
|
|
12
|
-
return;
|
|
13
11
|
const value = (liveField === null || liveField === void 0 ? void 0 : liveField.value) || field.value;
|
|
14
12
|
const fieldItem = (_a = field._editor) === null || _a === void 0 ? void 0 : _a.descriptor.item;
|
|
15
13
|
if (!fieldItem)
|
|
16
14
|
return;
|
|
17
|
-
return (_jsx(InputText, { value: value, disabled: readOnly, className: "a-p-2 a-focus-shadow a-text-sm", style: { width: "100%" }, onChange: (e) => {
|
|
15
|
+
return (_jsx(InputText, { value: value || "", disabled: readOnly, className: "a-p-2 a-focus-shadow a-text-sm", style: { width: "100%" }, onChange: (e) => {
|
|
18
16
|
editContext.editField({
|
|
19
17
|
field,
|
|
20
18
|
value: e.target.value,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Splitter, SplitterPanel } from "primereact/splitter";
|
|
3
|
-
import { useEditContext } from "
|
|
3
|
+
import { useEditContext } from "../editContext";
|
|
4
4
|
import ContentTree from "../ContentTree";
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
import { ListBox } from "primereact/listbox";
|
|
@@ -101,5 +101,5 @@ export function Menu() {
|
|
|
101
101
|
// //{ separator: true },
|
|
102
102
|
// ];
|
|
103
103
|
const endContent = (_jsxs("div", { className: "a-flex a-gap-3 a-items-center", children: [_jsx(PageViewerControls, {}), _jsx(ItemLanguageVersion, {})] }));
|
|
104
|
-
return (_jsx(Menubar, { model: menuItems, end: endContent, className: "a-p-1 a-text-sm a-rounded-none a-border-0 a-border-b" }));
|
|
104
|
+
return (_jsx(Menubar, { model: menuItems, end: endContent, className: "a-p-1 a-text-sm a-rounded-none a-border-0 a-border-b a-bg-gray-50" }));
|
|
105
105
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { post } from "./serviceHelper";
|
|
11
|
+
export function loadAiConfig(item) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
let url = "/alpaca/headless/ai/config";
|
|
14
|
+
const response = yield post(url, item);
|
|
15
|
+
if (!response.response.ok) {
|
|
16
|
+
throw new Error("Error loading AI config");
|
|
17
|
+
}
|
|
18
|
+
return yield response.response.json();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { post } from "./serviceHelper";
|
|
11
|
+
export function createNewComponent(parent, name) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
let url = "/alpaca/headless/component/create";
|
|
14
|
+
const response = yield post(url, {
|
|
15
|
+
settingsItemId: parent.id,
|
|
16
|
+
name,
|
|
17
|
+
});
|
|
18
|
+
if (!response.response.ok) {
|
|
19
|
+
return new Error("Error creating new item");
|
|
20
|
+
}
|
|
21
|
+
return yield response.response.json();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -31,16 +31,14 @@ export function getChildren(itemId, sessionId, templateIds = [], includeEmbedded
|
|
|
31
31
|
return yield response.json();
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
export function getItem(item
|
|
34
|
+
export function getItem(item) {
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
36
|
let url = "/alpaca/headless/editor/item?itemId=" +
|
|
37
37
|
item.id +
|
|
38
38
|
"&language=" +
|
|
39
39
|
item.language +
|
|
40
40
|
"&version=" +
|
|
41
|
-
item.version
|
|
42
|
-
"&sessionId=" +
|
|
43
|
-
sessionId;
|
|
41
|
+
item.version;
|
|
44
42
|
const response = yield fetch(url, {
|
|
45
43
|
method: "GET",
|
|
46
44
|
credentials: "include",
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import Cookies from "universal-cookie";
|
|
11
|
+
import { post } from "./serviceHelper";
|
|
11
12
|
export function connectSocket(sessionId) {
|
|
12
13
|
let loc = window.location, new_uri;
|
|
13
14
|
if (loc.protocol === "https:") {
|
|
@@ -141,41 +142,6 @@ export function validateItems(items, sessionId) {
|
|
|
141
142
|
return yield response;
|
|
142
143
|
});
|
|
143
144
|
}
|
|
144
|
-
function post(url, body, session) {
|
|
145
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
if (session)
|
|
147
|
-
url += "?sessionId=" + session;
|
|
148
|
-
const response = yield fetch(url, {
|
|
149
|
-
method: "POST",
|
|
150
|
-
body: JSON.stringify(body),
|
|
151
|
-
credentials: "include",
|
|
152
|
-
headers: {
|
|
153
|
-
"Content-Type": "application/json",
|
|
154
|
-
Cookie: new Cookies().getAll(),
|
|
155
|
-
},
|
|
156
|
-
next: {
|
|
157
|
-
revalidate: 0,
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
if (response.status === 500 || response.redirected) {
|
|
161
|
-
return {
|
|
162
|
-
type: "error",
|
|
163
|
-
summary: "Error",
|
|
164
|
-
details: "An error occured while locking the item.",
|
|
165
|
-
response,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
if (response.status === 401) {
|
|
169
|
-
return {
|
|
170
|
-
type: "error",
|
|
171
|
-
summary: "Unauthorized",
|
|
172
|
-
details: "Not logged in anymore?",
|
|
173
|
-
response,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
return { type: "success", response };
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
145
|
export function executeWorkflowCommand(item, commandId, comment) {
|
|
180
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
147
|
const response = yield fetch("/alpaca/headless/editor/executeWorkflowCommand", {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import Cookies from "universal-cookie";
|
|
11
|
+
export function post(url, body, session) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
if (session)
|
|
14
|
+
url += "?sessionId=" + session;
|
|
15
|
+
const response = yield fetch(url, {
|
|
16
|
+
method: "POST",
|
|
17
|
+
body: JSON.stringify(body),
|
|
18
|
+
credentials: "include",
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
Cookie: new Cookies().getAll(),
|
|
22
|
+
},
|
|
23
|
+
next: {
|
|
24
|
+
revalidate: 0,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
if (response.status === 500 || response.redirected) {
|
|
28
|
+
return {
|
|
29
|
+
type: "error",
|
|
30
|
+
summary: "Error",
|
|
31
|
+
details: "An error occured while locking the item.",
|
|
32
|
+
response,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (response.status === 401) {
|
|
36
|
+
return {
|
|
37
|
+
type: "error",
|
|
38
|
+
summary: "Unauthorized",
|
|
39
|
+
details: "Not logged in anymore?",
|
|
40
|
+
response,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return { type: "success", response };
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEditContext } from "
|
|
2
|
+
import { useEditContext } from "../editContext";
|
|
3
3
|
import { getInsertOptionsForCurrentSelection } from "../utils/insertOptions";
|
|
4
4
|
import { ArrowDownIcon } from "../ui/Icons";
|
|
5
5
|
export function ComponentPalette({}) {
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import ContentTree from "../ContentTree";
|
|
3
3
|
import { useEditContext } from "../editContext";
|
|
4
4
|
import { getInsertOptionsForCurrentSelection } from "../utils/insertOptions";
|
|
5
|
-
export function MainContentTree({ mode }) {
|
|
5
|
+
export function MainContentTree({ mode, }) {
|
|
6
6
|
var _a;
|
|
7
7
|
const editContext = useEditContext();
|
|
8
8
|
if (!editContext)
|
|
@@ -11,7 +11,7 @@ export function MainContentTree({ mode }) {
|
|
|
11
11
|
if (!(page === null || page === void 0 ? void 0 : page._editor))
|
|
12
12
|
return null;
|
|
13
13
|
const currentInsertOptions = getInsertOptionsForCurrentSelection(editContext);
|
|
14
|
-
return (_jsx(ContentTree, { rootItemId: "{11111111-1111-1111-1111-111111111111}", expandIdPath: page._editor.idPath, className: "a-p-1", selectionMode: mode == "insert" ? "none" : "single", selectedItemIds: editContext.secondaryItem ? [editContext.secondaryItem.id] : [page.id], secondarySelectedItemId: (_a = editContext.secondaryItem) === null || _a === void 0 ? void 0 : _a.id, onSelectionChange: (selection) => {
|
|
14
|
+
return (_jsx(ContentTree, { rootItemId: "{11111111-1111-1111-1111-111111111111}", expandIdPath: page._editor.idPath, className: "a-p-1", selectPagesOnly: mode === "select-page", selectionMode: mode == "insert" ? "none" : "single", selectedItemIds: editContext.secondaryItem ? [editContext.secondaryItem.id] : [page.id], secondarySelectedItemId: (_a = editContext.secondaryItem) === null || _a === void 0 ? void 0 : _a.id, onSelectionChange: (selection) => {
|
|
15
15
|
const selectedItem = selection;
|
|
16
16
|
editContext.loadItem({
|
|
17
17
|
id: selectedItem.id,
|
|
@@ -19,7 +19,7 @@ export function MainContentTree({ mode }) {
|
|
|
19
19
|
version: selectedItem.version,
|
|
20
20
|
hasLayout: selectedItem.hasLayout,
|
|
21
21
|
});
|
|
22
|
-
}, isDraggable: (x) => mode
|
|
22
|
+
}, isDraggable: (x) => mode === "insert" &&
|
|
23
23
|
(currentInsertOptions === null || currentInsertOptions === void 0 ? void 0 : currentInsertOptions.find((insertOption) => {
|
|
24
24
|
var _a;
|
|
25
25
|
return insertOption.id == x.templateId ||
|
|
@@ -7,7 +7,7 @@ export function Sidebar({ views }) {
|
|
|
7
7
|
if (!editContext)
|
|
8
8
|
return null;
|
|
9
9
|
const view = editContext.view;
|
|
10
|
-
return (_jsxs("div", { className: "a-flex a-items-stretch a-h-full", children: [_jsx("div", { className: "a-bg-slate-700 a-flex a-flex-col
|
|
10
|
+
return (_jsxs("div", { className: "a-flex a-items-stretch a-h-full", children: [_jsx("div", { className: "a-bg-slate-700 a-flex a-flex-col", children: views.map((x, i) => (_jsx("div", { title: x.title, className: classNames(view.name == x.name
|
|
11
11
|
? "a-text-white"
|
|
12
12
|
: "a-text-gray-400 hover:a-text-white", "a-cursor-pointer a-p-3"), onClick: () => editContext.setView(x), children: typeof x.icon === "string" ? (_jsx("i", { className: classNames(x.icon, "a-text-xl") })) : (x.icon) }, i))) }), views.map((x, i) => (_jsx(SidebarView, { view: x, editContext: editContext, active: view.name === x.name }, i)))] }));
|
|
13
13
|
}
|
|
@@ -6,13 +6,14 @@ import { classNames } from "primereact/utils";
|
|
|
6
6
|
export function SidebarView({ view, editContext, active, }) {
|
|
7
7
|
const splitter = useRef(null);
|
|
8
8
|
const [sizes, setSizes] = useState([]);
|
|
9
|
-
const [preferredSizes, setPreferredSizes] = useState(
|
|
9
|
+
const [preferredSizes, setPreferredSizes] = useState(undefined);
|
|
10
10
|
const [panelsExpanded, setPanelsExpanded] = useState([]);
|
|
11
|
+
const [sizeToSet, setSizeToSet] = useState();
|
|
11
12
|
const panelHeaderSize = 30;
|
|
12
13
|
const toggle = (panelIndex) => {
|
|
13
14
|
const newSize = panelsExpanded[panelIndex]
|
|
14
15
|
? panelHeaderSize
|
|
15
|
-
: preferredSizes[panelIndex];
|
|
16
|
+
: (preferredSizes || sizes)[panelIndex];
|
|
16
17
|
resizePanel(panelIndex, newSize);
|
|
17
18
|
setPanelsExpanded((x) => {
|
|
18
19
|
const newState = [...x];
|
|
@@ -20,12 +21,6 @@ export function SidebarView({ view, editContext, active, }) {
|
|
|
20
21
|
return newState;
|
|
21
22
|
});
|
|
22
23
|
};
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
var _a;
|
|
25
|
-
if (sizes.length == 0)
|
|
26
|
-
return;
|
|
27
|
-
(_a = splitter.current) === null || _a === void 0 ? void 0 : _a.resize(sizes);
|
|
28
|
-
}, [sizes]);
|
|
29
24
|
const resolvedPanels = view.leftSidebar.map((x) => {
|
|
30
25
|
if (typeof x === "function") {
|
|
31
26
|
return x(editContext);
|
|
@@ -47,23 +42,32 @@ export function SidebarView({ view, editContext, active, }) {
|
|
|
47
42
|
const newSizes = percentages.map((x) => x * remaining);
|
|
48
43
|
newSizes[panelIndex] = newSize;
|
|
49
44
|
setSizes(newSizes);
|
|
45
|
+
setSizeToSet(newSizes);
|
|
50
46
|
};
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
var _a;
|
|
49
|
+
if (sizeToSet)
|
|
50
|
+
(_a = splitter.current) === null || _a === void 0 ? void 0 : _a.resize(sizeToSet);
|
|
51
|
+
}, [sizeToSet]);
|
|
51
52
|
const getHeader = (panel, index) => {
|
|
52
53
|
if (panel.header)
|
|
53
54
|
return panel.header({ panel, index });
|
|
54
55
|
return (_jsxs("div", { className: classNames("a-p-1.5 a-bg-gray-50 a-uppercase a-text-gray-500 a-text-xs a-flex a-justify a-items-center a-cursor-pointer", panelsExpanded[index] ? "a-border-b" : ""), onClick: () => toggle(index), children: [panel.icon &&
|
|
55
56
|
(typeof panel.icon === "string" ? (_jsx("i", { className: classNames(panel.icon, "pi a-mr-1.5") })) : (_jsx("div", { className: "a-w-4 a-h-4 a-mr-1.5", children: panel.icon }))), _jsx("div", { className: "a-mr-auto", children: panel.title }), _jsx("i", { className: classNames(panelsExpanded[index] ? "pi-chevron-up" : "pi-chevron-down", "pi a-text-sm") })] }));
|
|
56
57
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return;
|
|
58
|
+
const initalSizes = resolvedPanels.map((x) => x.initialSize);
|
|
59
|
+
return (_jsx(Allotment, { vertical: true, snap: true, className: !active ? "a-hidden a-h-full" : "a-h-full", ref: splitter, defaultSizes: initalSizes, onChange: (s) => {
|
|
60
60
|
if (sizes.join(",") != s.join(","))
|
|
61
61
|
setSizes(s);
|
|
62
|
-
const newPreferred = [...preferredSizes];
|
|
62
|
+
const newPreferred = [...(preferredSizes || s)];
|
|
63
63
|
s.forEach((x, i) => {
|
|
64
64
|
if (x > panelHeaderSize)
|
|
65
65
|
newPreferred[i] = x;
|
|
66
66
|
});
|
|
67
67
|
setPreferredSizes(newPreferred);
|
|
68
|
-
}, children: resolvedPanels.map((panel, index) => (_jsx(Allotment.Pane, {
|
|
68
|
+
}, children: resolvedPanels.map((panel, index) => (_jsx(Allotment.Pane, {
|
|
69
|
+
// preferredSize={(preferredSizes || initalSizes)[index] + "%"}
|
|
70
|
+
maxSize: panelsExpanded.length <= index || panelsExpanded[index]
|
|
71
|
+
? 10000
|
|
72
|
+
: panelHeaderSize, children: _jsxs("div", { className: "a-flex a-flex-col a-h-full", children: [getHeader(panel, index), panelsExpanded[index] && (_jsx("div", { className: "a-overflow-hidden a-relative a-flex-1", children: _jsx("div", { className: "a-inset-0 a-absolute a-overflow-y-auto", children: panel.content }) }))] }) }, index))) }));
|
|
69
73
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Column } from "primereact/column";
|
|
3
3
|
import { DataTable } from "primereact/datatable";
|
|
4
|
-
import { useEditContext } from "
|
|
4
|
+
import { useEditContext } from "../editContext";
|
|
5
5
|
import { Tooltip } from "primereact/tooltip";
|
|
6
6
|
import { Button } from "primereact/button";
|
|
7
7
|
import { useRef, useState } from "react";
|
|
@@ -2,9 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Dialog } from "primereact/dialog";
|
|
3
3
|
import { InputText } from "primereact/inputtext";
|
|
4
4
|
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
|
5
|
-
import DialogButtons from "
|
|
5
|
+
import DialogButtons from "../DialogButtons";
|
|
6
6
|
import { Button } from "primereact/button";
|
|
7
7
|
const ItemNameDialog = forwardRef((_props, ref) => {
|
|
8
|
+
var _a;
|
|
8
9
|
const [visible, setVisible] = useState(false);
|
|
9
10
|
const [props, setProps] = useState();
|
|
10
11
|
const [name, setName] = useState("");
|
|
@@ -24,7 +25,7 @@ const ItemNameDialog = forwardRef((_props, ref) => {
|
|
|
24
25
|
};
|
|
25
26
|
return (_jsxs(Dialog, { visible: visible, onHide: () => {
|
|
26
27
|
setVisible(false);
|
|
27
|
-
}, header: "Choose item name", children: [_jsx("div", { className: "a-pt-3", children: _jsx(InputText, { autoFocus: true, value: name, onChange: (e) => setName(e.target.value), onKeyDown: (ev) => {
|
|
28
|
+
}, header: (_a = props === null || props === void 0 ? void 0 : props.title) !== null && _a !== void 0 ? _a : "Choose item name", children: [_jsx("div", { className: "a-pt-3", children: _jsx(InputText, { autoFocus: true, value: name, onChange: (e) => setName(e.target.value), onKeyDown: (ev) => {
|
|
28
29
|
if (ev.key === "Enter" && isValidName)
|
|
29
30
|
handleOk();
|
|
30
31
|
} }) }), _jsxs(DialogButtons, { children: [_jsx(Button, { onClick: handleOk, label: "Ok", disabled: !isValidName }), _jsx(Button, { onClick: () => setVisible(false), label: "Cancel" })] })] }));
|