@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
package/dist/editor.css
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "server-only";
|
|
3
|
+
import { EditorClientHost } from "./editor/EditorClientHost";
|
|
4
|
+
import { PreviewClientHost } from "./editor/PreviewClientHost";
|
|
5
|
+
import { createClientContext } from "./renderContext";
|
|
6
|
+
export function Editor({ children, context, clientBuilder, }) {
|
|
7
|
+
const data = context.page;
|
|
8
|
+
if (!data._editor && !data.previewing)
|
|
9
|
+
return _jsx(_Fragment, { children: children });
|
|
10
|
+
if (data.previewing)
|
|
11
|
+
return _jsx(PreviewClientHost, { children: children });
|
|
12
|
+
return (_jsx(EditorClientHost, { context: createClientContext(context), clientBuilder: clientBuilder, children: children }));
|
|
13
|
+
}
|
|
@@ -11,7 +11,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { useEditContext
|
|
14
|
+
import { useEditContext } from "../editor/editContext";
|
|
15
|
+
import { usePreviewContext } from "../editor/previewContext";
|
|
15
16
|
import LinkEditor from "./LinkEditor";
|
|
16
17
|
import LinkPreview from "../components/LinkPreview";
|
|
17
18
|
export function ClientLink(_a) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { EditFilterChildrenContextProvider, useEditContext, } from "../editor";
|
|
3
|
+
import { EditFilterChildrenContextProvider, useEditContext, } from "../editor/editContext";
|
|
4
4
|
export function MultiComponentEditor({ component, children, thumbZoom = 0.2, thumbHeight = "150px", thumbWidth = "150px", numComponentsVisibleWhenNotEditing = 1, listClassName = "", listClassNameEditing = "a-flex a-gap-2 a-flex-wrap a-items-center", }) {
|
|
5
5
|
var editContext = useEditContext();
|
|
6
6
|
if (!editContext)
|
|
@@ -25,7 +25,7 @@ import "server-only";
|
|
|
25
25
|
// }
|
|
26
26
|
// };
|
|
27
27
|
export const Image = (_a) => {
|
|
28
|
-
var { field } = _a, otherProps = __rest(_a, ["field"]);
|
|
28
|
+
var { field, context } = _a, otherProps = __rest(_a, ["field", "context"]);
|
|
29
29
|
if (!field)
|
|
30
30
|
return;
|
|
31
31
|
const attrs = Object.assign(Object.assign({}, field.value), otherProps);
|
|
@@ -11,21 +11,19 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import "server-only";
|
|
14
|
-
import { useAlpacaContext } from "../alpacaContext";
|
|
15
14
|
import LinkEditor from "../client-components/LinkEditor";
|
|
16
15
|
import LinkPreview from "./LinkPreview";
|
|
17
16
|
export function Link(_a) {
|
|
18
|
-
var { field, children } = _a, props = __rest(_a, ["field", "children"]);
|
|
17
|
+
var { field, children, context } = _a, props = __rest(_a, ["field", "children", "context"]);
|
|
19
18
|
if (field === null || field === void 0 ? void 0 : field.jsonValue) {
|
|
20
19
|
field = field.jsonValue;
|
|
21
20
|
}
|
|
22
|
-
const
|
|
23
|
-
const editing = pageContext === null || pageContext === void 0 ? void 0 : pageContext.pageEditing;
|
|
21
|
+
const editing = context.isEditing;
|
|
24
22
|
if (editing)
|
|
25
23
|
return (_jsx(LinkEditor, Object.assign({ field: field }, props, { children: children })));
|
|
26
24
|
if (!(field === null || field === void 0 ? void 0 : field.value))
|
|
27
25
|
return;
|
|
28
|
-
if (
|
|
26
|
+
if (context.isPreview) {
|
|
29
27
|
return (_jsx(LinkPreview, Object.assign({ field: field }, props, { children: children })));
|
|
30
28
|
}
|
|
31
29
|
return (_jsx("a", Object.assign({ href: field.value.url }, props, { children: children })));
|
|
@@ -12,12 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import "server-only";
|
|
14
14
|
import { hashImageUrl } from "../mediaProtection";
|
|
15
|
-
import { getAlpacaContext } from "../alpacaContext";
|
|
16
15
|
import { getRenderedPictureVariant, } from "./picture-shared";
|
|
17
16
|
import { PictureEditorWrapper } from "./PictureEditorWrapper";
|
|
18
17
|
export const Picture = (_a) => {
|
|
19
|
-
var _b, _c, _d
|
|
20
|
-
var { field, params, renderJsonLinkedData, renderEditButton } = _a, otherProps = __rest(_a, ["field", "params", "renderJsonLinkedData", "renderEditButton"]);
|
|
18
|
+
var _b, _c, _d;
|
|
19
|
+
var { field, params, renderJsonLinkedData, renderEditButton, context } = _a, otherProps = __rest(_a, ["field", "params", "renderJsonLinkedData", "renderEditButton", "context"]);
|
|
21
20
|
if (!field)
|
|
22
21
|
return null;
|
|
23
22
|
if (field.jsonValue) {
|
|
@@ -75,7 +74,7 @@ export const Picture = (_a) => {
|
|
|
75
74
|
// }}
|
|
76
75
|
// />
|
|
77
76
|
// ) : null}
|
|
78
|
-
if (
|
|
77
|
+
if (context.isEditing)
|
|
79
78
|
return (_jsx(PictureEditorWrapper, { field: field, renderEditButton: renderEditButton, params: params, picture: picture }));
|
|
80
79
|
else
|
|
81
80
|
return picture;
|
|
@@ -15,7 +15,7 @@ import React, { useEffect, useState } from "react";
|
|
|
15
15
|
import { PictureEditorDialog } from "../editor/PictureEditorDialog";
|
|
16
16
|
import { getFieldContextMenu } from "../editor/ContextMenu";
|
|
17
17
|
import { isFieldActionExecuting } from "../editor/utils";
|
|
18
|
-
import { useEditContext, useEditFrameContext } from "../editor";
|
|
18
|
+
import { useEditContext, useEditFrameContext } from "../editor/editContext";
|
|
19
19
|
export const PictureEditor = (_a) => {
|
|
20
20
|
var _b, _c, _d, _e;
|
|
21
21
|
var { field, params, renderEditButton, picture } = _a, otherProps = __rest(_a, ["field", "params", "renderEditButton", "picture"]);
|
|
@@ -1,110 +1,134 @@
|
|
|
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 { createElement as _createElement } from "react";
|
|
2
11
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
12
|
import "server-only";
|
|
4
|
-
import { useAlpacaContext } from "../alpacaContext";
|
|
5
13
|
import { PlaceholderDropZoneHost } from "../editor/PlaceholderDropZoneHost";
|
|
6
14
|
import { EditFrameWrapper } from "../editor/EditFrameWrapper";
|
|
7
15
|
import Slot from "./Slot";
|
|
8
16
|
import { ErrorBoundary } from "react-error-boundary";
|
|
9
17
|
import { ErrorFallback } from "./Error";
|
|
10
18
|
import React from "react";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
import { getRenderingById } from "../renderings";
|
|
20
|
+
export function Placeholder({ name, description, content, tag, className, mapComponent, getComponentProps, context, }) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const data = content;
|
|
23
|
+
if (!data || !("placeholders" in data))
|
|
24
|
+
return;
|
|
25
|
+
const placeholderData = data.placeholders.find((x) => x.name == name);
|
|
26
|
+
if (!placeholderData)
|
|
27
|
+
return;
|
|
28
|
+
const componentPromises = placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.components.filter((c) => c.visible).map((component, index) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
if (component.componentType == "Slot")
|
|
30
|
+
return {
|
|
31
|
+
Component: Slot,
|
|
32
|
+
data: component,
|
|
33
|
+
parent: data,
|
|
34
|
+
};
|
|
35
|
+
const componentType = mapComponent
|
|
36
|
+
? mapComponent({ data: component, index })
|
|
37
|
+
: component.componentType;
|
|
38
|
+
if (!context.renderings) {
|
|
39
|
+
console.log("No components registered");
|
|
40
|
+
return {
|
|
41
|
+
data: { name: componentType, id: "0" },
|
|
42
|
+
Component: ComponentNotFound,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const reactComponent = context.renderings[componentType];
|
|
46
|
+
if (component.renderingId) {
|
|
47
|
+
const rendering = yield getRenderingById(component.renderingId);
|
|
48
|
+
if (rendering) {
|
|
49
|
+
return {
|
|
50
|
+
parent: data,
|
|
51
|
+
data: component,
|
|
52
|
+
Component: rendering,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (!reactComponent) {
|
|
57
|
+
console.log("Could not find module for component type: " + componentType);
|
|
58
|
+
return {
|
|
59
|
+
data: { name: componentType, id: "0" },
|
|
60
|
+
Component: ComponentNotFound,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
21
63
|
return {
|
|
22
|
-
Component: Slot,
|
|
23
|
-
data: component,
|
|
24
64
|
parent: data,
|
|
65
|
+
data: component,
|
|
66
|
+
Component: reactComponent,
|
|
25
67
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
68
|
+
}));
|
|
69
|
+
const components = yield Promise.all(componentPromises);
|
|
70
|
+
function wrap(children) {
|
|
71
|
+
if (!tag)
|
|
72
|
+
return children;
|
|
73
|
+
if (context.isEditing || components.length > 0) {
|
|
74
|
+
return React.createElement(tag, { className }, children);
|
|
75
|
+
}
|
|
35
76
|
}
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
77
|
+
// const mappedComponents = mapComponent
|
|
78
|
+
// ? components.map(({ Component, data, parent }, index) => ({
|
|
79
|
+
// Component: mapComponent({
|
|
80
|
+
// Component,
|
|
81
|
+
// data: data as ComponentData,
|
|
82
|
+
// index,
|
|
83
|
+
// }),
|
|
84
|
+
// data,
|
|
85
|
+
// parent,
|
|
86
|
+
// }))
|
|
87
|
+
// : components;
|
|
88
|
+
const componentsWithProps = components.map(({ Component, data, parent }, index) => {
|
|
89
|
+
const defaultProps = {
|
|
90
|
+
component: data,
|
|
91
|
+
context,
|
|
92
|
+
index,
|
|
93
|
+
count: components.length,
|
|
42
94
|
};
|
|
95
|
+
var props = getComponentProps
|
|
96
|
+
? getComponentProps(defaultProps)
|
|
97
|
+
: defaultProps;
|
|
98
|
+
return { Component, props, data, parent };
|
|
99
|
+
});
|
|
100
|
+
if (context.isEditing) {
|
|
101
|
+
let phIndex = 0;
|
|
102
|
+
return wrap(_jsxs(_Fragment, { children: [componentsWithProps.map(({ Component, props, data, parent }) => {
|
|
103
|
+
try {
|
|
104
|
+
return (_jsxs(_Fragment, { children: [(!data._editor.hostingPageItem ||
|
|
105
|
+
data.componentType == "Slot") && (_jsx(PlaceholderDropZoneHost, { parentName: parent === null || parent === void 0 ? void 0 : parent.name, description: description, placeholder: placeholderData, index: phIndex++ }, data.id + "_zone" + phIndex)), _jsx(EditFrameWrapper, { componentId: data.id, index: phIndex, children: _jsx(Component, Object.assign({}, props)) }, data.id)] }));
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
return (_jsxs("div", { children: ["Error rendering component ", data.name, ": ", e.message] }));
|
|
109
|
+
}
|
|
110
|
+
}), (!data._editor.hostingPageItem ||
|
|
111
|
+
data.componentType == "Slot") && (_jsx(PlaceholderDropZoneHost, { parentName: data === null || data === void 0 ? void 0 : data.name, description: description, placeholder: placeholderData, index: phIndex++ }, data.id + "_zone" + phIndex))] }));
|
|
43
112
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
113
|
+
else {
|
|
114
|
+
return wrap(_jsx(_Fragment, { children: components.map(({ Component, data }, index) => {
|
|
115
|
+
var props = getComponentProps
|
|
116
|
+
? getComponentProps({
|
|
117
|
+
component: data,
|
|
118
|
+
context,
|
|
119
|
+
index,
|
|
120
|
+
count: components.length,
|
|
121
|
+
})
|
|
122
|
+
: {
|
|
123
|
+
component: data,
|
|
124
|
+
context,
|
|
125
|
+
index,
|
|
126
|
+
count: components.length,
|
|
127
|
+
};
|
|
128
|
+
return (_jsx(_Fragment, { children: _jsx(ErrorBoundary, { FallbackComponent: ErrorFallback, children: _createElement(Component, Object.assign({}, props, { key: data.id })) }, data.id) }));
|
|
129
|
+
}) }));
|
|
55
130
|
}
|
|
56
|
-
}
|
|
57
|
-
// const mappedComponents = mapComponent
|
|
58
|
-
// ? components.map(({ Component, data, parent }, index) => ({
|
|
59
|
-
// Component: mapComponent({
|
|
60
|
-
// Component,
|
|
61
|
-
// data: data as ComponentData,
|
|
62
|
-
// index,
|
|
63
|
-
// }),
|
|
64
|
-
// data,
|
|
65
|
-
// parent,
|
|
66
|
-
// }))
|
|
67
|
-
// : components;
|
|
68
|
-
const componentsWithProps = components.map(({ Component, data, parent }, index) => {
|
|
69
|
-
const defaultProps = {
|
|
70
|
-
component: data,
|
|
71
|
-
index,
|
|
72
|
-
count: components.length,
|
|
73
|
-
};
|
|
74
|
-
var props = getComponentProps
|
|
75
|
-
? getComponentProps(defaultProps)
|
|
76
|
-
: defaultProps;
|
|
77
|
-
return { Component, props, data, parent };
|
|
78
131
|
});
|
|
79
|
-
if (context.pageContext.pageEditing) {
|
|
80
|
-
let phIndex = 0;
|
|
81
|
-
return wrap(_jsxs(_Fragment, { children: [componentsWithProps.map(({ Component, props, data, parent }) => {
|
|
82
|
-
try {
|
|
83
|
-
return (_jsxs(_Fragment, { children: [(!data._editor.hostingPageItem ||
|
|
84
|
-
data.componentType == "Slot") && (_jsx(PlaceholderDropZoneHost, { parentName: parent === null || parent === void 0 ? void 0 : parent.name, description: description, placeholder: placeholderData, index: phIndex++ }, data.id + "_zone" + phIndex)), _jsx(EditFrameWrapper, { componentId: data.id, index: phIndex, children: _jsx(Component, Object.assign({}, props)) }, data.id)] }));
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
return (_jsxs("div", { children: ["Error rendering component ", data.name, ": ", e.message] }));
|
|
88
|
-
}
|
|
89
|
-
}), (!data._editor.hostingPageItem ||
|
|
90
|
-
data.componentType == "Slot") && (_jsx(PlaceholderDropZoneHost, { parentName: data === null || data === void 0 ? void 0 : data.name, description: description, placeholder: placeholderData, index: phIndex++ }, data.id + "_zone" + phIndex))] }));
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
return wrap(_jsx(_Fragment, { children: components.map(({ Component, data }, index) => {
|
|
94
|
-
var props = getComponentProps
|
|
95
|
-
? getComponentProps({
|
|
96
|
-
component: data,
|
|
97
|
-
index,
|
|
98
|
-
count: components.length,
|
|
99
|
-
})
|
|
100
|
-
: {
|
|
101
|
-
component: data,
|
|
102
|
-
index,
|
|
103
|
-
count: components.length,
|
|
104
|
-
};
|
|
105
|
-
return (_jsx(_Fragment, { children: _jsx(ErrorBoundary, { FallbackComponent: ErrorFallback, children: _createElement(Component, Object.assign({}, props, { key: data.id })) }, data.id) }));
|
|
106
|
-
}) }));
|
|
107
|
-
}
|
|
108
132
|
}
|
|
109
133
|
function ComponentNotFound({ component }) {
|
|
110
134
|
return (_jsxs("div", { style: {
|
|
@@ -12,10 +12,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import "server-only";
|
|
14
14
|
import React from "react";
|
|
15
|
-
import { useAlpacaContext } from "../alpacaContext";
|
|
16
15
|
import { RichTextEditorWrapper } from "./RichTextEditorWrapper";
|
|
17
16
|
export function RichText(_a) {
|
|
18
|
-
var { field, tag, editable } = _a, props = __rest(_a, ["field", "tag", "editable"]);
|
|
17
|
+
var { field, tag, editable, context } = _a, props = __rest(_a, ["field", "tag", "editable", "context"]);
|
|
19
18
|
if (!field)
|
|
20
19
|
return;
|
|
21
20
|
if (field.jsonValue) {
|
|
@@ -24,7 +23,7 @@ export function RichText(_a) {
|
|
|
24
23
|
const internalProps = Object.assign(Object.assign({}, props), { dangerouslySetInnerHTML: {
|
|
25
24
|
__html: field.value,
|
|
26
25
|
} });
|
|
27
|
-
if (
|
|
26
|
+
if (context.isEditing)
|
|
28
27
|
return (_jsx(RichTextEditorWrapper, Object.assign({ field: field, tag: tag }, props)));
|
|
29
28
|
return React.createElement(tag || "div", Object.assign(props, internalProps));
|
|
30
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import "server-only";
|
|
3
3
|
import { Placeholder } from "./Placeholder";
|
|
4
|
-
export default function Section({ component }) {
|
|
5
|
-
return (_jsx(_Fragment, { children: _jsx(Placeholder, { name: "ph-slot-content", content: component }) }));
|
|
4
|
+
export default function Section({ component, context, }) {
|
|
5
|
+
return (_jsx(_Fragment, { children: _jsx(Placeholder, { name: "ph-slot-content", content: component, context: context }) }));
|
|
6
6
|
}
|
|
@@ -12,16 +12,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import "server-only";
|
|
14
14
|
import React from "react";
|
|
15
|
-
import { useAlpacaContext } from "../alpacaContext";
|
|
16
15
|
import { TextEditorWrapper } from "./TextEditorWrapper";
|
|
17
16
|
export function Text(_a) {
|
|
18
|
-
var { field, tag, editable } = _a, props = __rest(_a, ["field", "tag", "editable"]);
|
|
17
|
+
var { field, tag, editable, context } = _a, props = __rest(_a, ["field", "tag", "editable", "context"]);
|
|
19
18
|
if (!field)
|
|
20
19
|
return;
|
|
21
20
|
if (field.jsonValue) {
|
|
22
21
|
field = field.jsonValue;
|
|
23
22
|
}
|
|
24
|
-
if (
|
|
23
|
+
if (context.isEditing) {
|
|
25
24
|
return (_jsx("div", { children: _jsx(TextEditorWrapper, Object.assign({ field: field, tag: tag }, props)) }));
|
|
26
25
|
}
|
|
27
26
|
else
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import "server-only";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const TranslateEditor = dynamic(() => import("./TranslateEditor").then((dnd) => dnd.TranslateEditor), { ssr: false });
|
|
6
|
-
export function Translate({ text }) {
|
|
7
|
-
const context = useAlpacaContext();
|
|
3
|
+
import { TranslateEditorWrapper } from "./TranslateEditorWrapper";
|
|
4
|
+
export function Translate({ text, context, }) {
|
|
8
5
|
const dictionary = context.dictionary;
|
|
9
|
-
if (context.
|
|
10
|
-
return _jsx(
|
|
6
|
+
if (context.isEditing)
|
|
7
|
+
return _jsx(TranslateEditorWrapper, { text: text });
|
|
11
8
|
return dictionary[text] || text;
|
|
12
9
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import dynamic from "next/dynamic";
|
|
4
|
+
const TranslateEditor = dynamic(() => import("./TranslateEditor").then((dnd) => dnd.TranslateEditor), { ssr: false });
|
|
5
|
+
export function TranslateEditorWrapper({ text }) {
|
|
6
|
+
return _jsx(TranslateEditor, { text: text });
|
|
7
|
+
}
|
|
@@ -10,15 +10,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
12
|
import { ProgressSpinner } from "primereact/progressspinner";
|
|
13
|
-
import { useEditContext } from "
|
|
13
|
+
import { useEditContext } from "./editContext";
|
|
14
14
|
import { Tree, } from "primereact/tree";
|
|
15
15
|
import { useEffect, useRef, useState } from "react";
|
|
16
16
|
import { getChildren } from "./services/contentService";
|
|
17
17
|
import { ContextMenu } from "primereact/contextmenu";
|
|
18
18
|
import { createItem, loadInsertOptions } from "./services/editService";
|
|
19
|
-
import ItemNameDialog from "./ItemNameDialog";
|
|
19
|
+
import ItemNameDialog from "./ui/ItemNameDialog";
|
|
20
20
|
import { getDeleteItemCommand } from "./itemCommands";
|
|
21
|
-
export default function ContentTree({ isDraggable, dragStart, dragEnd, expandIdPath, selectionMode, selectedItemIds, rootItemId, onSelectionChange, filter, templateIds, className, includeEmbeddedItems, onDoubleClick, secondarySelectedItemId, }) {
|
|
21
|
+
export default function ContentTree({ isDraggable, dragStart, dragEnd, expandIdPath, selectionMode, selectedItemIds, rootItemId, onSelectionChange, filter, templateIds, className, includeEmbeddedItems, onDoubleClick, secondarySelectedItemId, selectPagesOnly, }) {
|
|
22
22
|
const [treeNodes, setTreeNodes] = useState([]);
|
|
23
23
|
const [selectedKeys, setSelectedKeys] = useState();
|
|
24
24
|
const [expandedKeys, setExpandedKeys] = useState();
|
|
@@ -59,6 +59,7 @@ export default function ContentTree({ isDraggable, dragStart, dragEnd, expandIdP
|
|
|
59
59
|
label: x.name,
|
|
60
60
|
iconUrl: x.icon,
|
|
61
61
|
isDraggable: isDraggable && isDraggable(x),
|
|
62
|
+
selectable: !selectPagesOnly || x.hasLayout,
|
|
62
63
|
data: x,
|
|
63
64
|
leaf: !x.hasChildren,
|
|
64
65
|
parent: node,
|
|
@@ -116,9 +117,14 @@ export default function ContentTree({ isDraggable, dragStart, dragEnd, expandIdP
|
|
|
116
117
|
if (node.url) {
|
|
117
118
|
label = (_jsx("a", { onDragStart: (e) => e.preventDefault(), href: node.url, className: "a-text-primary hover:a-underline a-font-semibold", children: node.label }));
|
|
118
119
|
}
|
|
120
|
+
const getNodeCursor = (node) => {
|
|
121
|
+
if (node.isDraggable)
|
|
122
|
+
return "a-cursor-grab";
|
|
123
|
+
return "";
|
|
124
|
+
};
|
|
119
125
|
return (_jsxs("span", { onDragStart: (event) => {
|
|
120
126
|
handleDragStart(event, node.data);
|
|
121
|
-
}, onDragEnd: handleDragEnd, draggable: node.isDraggable, className: `a-flex a-items-center a-gap-2 ${node
|
|
127
|
+
}, onDragEnd: handleDragEnd, draggable: node.isDraggable, className: `a-flex a-items-center a-gap-2 ${getNodeCursor(node)} ${options.className} ${node.data.id == secondarySelectedItemId ? "a-selected-secondary" : ""}`, children: [_jsx("img", { src: node.iconUrl, style: { height: "16px" }, width: "16", height: "16", onDragStart: (e) => e.preventDefault() }), label, node.loading && (_jsx(ProgressSpinner, { style: { width: "20px", height: "20px" } }))] }));
|
|
122
128
|
};
|
|
123
129
|
function handleDragStart(event, item) {
|
|
124
130
|
if (dragStart)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { DataTable } from "primereact/datatable";
|
|
4
4
|
import { Column } from "primereact/column";
|
|
5
|
-
import { useEditContext } from "
|
|
5
|
+
import { useEditContext } from "./editContext";
|
|
6
6
|
import { SingleLineText } from "./fieldTypes/SingleLineText";
|
|
7
7
|
export function DictionaryEditor({}) {
|
|
8
8
|
const context = useEditContext();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
import { EditFrameContextProvider, useEditContext, useEditFilterChildrenContext, } from "
|
|
4
|
+
import { EditFrameContextProvider, useEditContext, useEditFilterChildrenContext, } from "./editContext";
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { showComponentContextMenu } from "./ContextMenu";
|
|
7
7
|
import { ErrorBoundary } from "react-error-boundary";
|