@alpaca-headless/alpaca-headless-nextjs 1.0.26 → 1.0.128
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/cjs/client-components/ClientLink.js +36 -0
- package/dist/cjs/client-components/MultiComponentEditor.js +26 -0
- package/dist/cjs/client-components/index.js +19 -0
- package/dist/cjs/components/Link.js +1 -1
- package/dist/cjs/components/LinkEditor.js +47 -1
- package/dist/cjs/components/Picture.js +14 -12
- package/dist/cjs/components/PictureEditor.js +22 -18
- package/dist/cjs/components/Placeholder.js +51 -9
- package/dist/cjs/components/RichText.js +1 -1
- package/dist/cjs/components/RichTextEditor.js +17 -2
- package/dist/cjs/components/TextEditor.js +15 -3
- package/dist/cjs/components/Translate.js +1 -1
- package/dist/cjs/{editor → components}/TranslateEditor.js +5 -2
- package/dist/cjs/editor/AiPopup.js +33 -0
- package/dist/cjs/editor/AiTerminal.js +42 -18
- package/dist/cjs/editor/ComponentInfo.js +4 -3
- package/dist/cjs/editor/ComponentPalette.js +12 -68
- package/dist/cjs/editor/ComponentTree.js +76 -59
- package/dist/cjs/editor/ConfirmationDialog.js +31 -0
- package/dist/cjs/editor/ContentTree.js +144 -49
- package/dist/cjs/editor/Debug.js +12 -2
- package/dist/cjs/editor/DialogButtons.js +7 -0
- package/dist/cjs/editor/DictionaryEditor.js +14 -8
- package/dist/cjs/editor/EditFrame.js +88 -20
- package/dist/cjs/editor/EditHistory.js +17 -4
- package/dist/cjs/editor/Editor.js +1 -1
- package/dist/cjs/editor/EditorClient.js +506 -237
- package/dist/cjs/editor/EditorClientHost.js +2 -2
- package/dist/cjs/editor/FieldList.js +30 -43
- package/dist/cjs/editor/FieldListField.js +75 -0
- package/dist/cjs/editor/FloatingToolbar.js +92 -0
- package/dist/cjs/editor/GraphQL.js +4 -6
- package/dist/cjs/editor/ItemEditor.js +9 -0
- package/dist/cjs/editor/ItemInfo.js +17 -0
- package/dist/cjs/editor/ItemNameDialog.js +37 -0
- package/dist/cjs/editor/LanguageSelector.js +1 -1
- package/dist/cjs/editor/LinkEditorDialog.js +67 -0
- package/dist/cjs/editor/MainLayout.js +24 -0
- package/dist/cjs/editor/MediaSelector.js +44 -13
- package/dist/cjs/editor/PictureEditorDialog.js +93 -0
- package/dist/cjs/editor/PlaceholderDropZone.js +48 -9
- package/dist/cjs/editor/SidebarTabs.js +47 -0
- package/dist/cjs/editor/Terminal.js +21 -11
- package/dist/cjs/editor/Utils.js +43 -0
- package/dist/cjs/editor/VersionSelector.js +1 -1
- package/dist/cjs/editor/Workbox.js +41 -0
- package/dist/cjs/editor/componentCommands.js +141 -0
- package/dist/cjs/editor/contentService.js +45 -3
- package/dist/cjs/editor/editContext.js +9 -4
- package/dist/cjs/editor/editService.js +187 -3
- package/dist/cjs/editor/fieldTypes/CheckboxEditor.js +21 -0
- package/dist/cjs/editor/fieldTypes/InternalLinkFieldEditor.js +46 -0
- package/dist/cjs/editor/fieldTypes/LinkFieldEditor.js +55 -0
- package/dist/cjs/editor/fieldTypes/MultiLineText.js +25 -0
- package/dist/cjs/editor/fieldTypes/PictureFieldEditor.js +19 -0
- package/dist/cjs/editor/fieldTypes/RichTextEditor.js +9 -4
- package/dist/cjs/editor/fieldTypes/SingleLineText.js +12 -4
- package/dist/cjs/editor/fieldTypes/TreeListEditor.js +59 -0
- package/dist/cjs/editor/ui/Section.js +8 -0
- package/dist/cjs/loadRouteData.js +24 -14
- package/dist/cjs/middleware/authorization.js +52 -0
- package/dist/cjs/middleware/index.js +17 -0
- package/dist/editor.css +552 -74
- package/dist/primereact/resources/themes/arya-blue/theme.css +103 -91
- package/dist/primereact/resources/themes/arya-green/theme.css +103 -91
- package/dist/primereact/resources/themes/arya-orange/theme.css +103 -91
- package/dist/primereact/resources/themes/arya-purple/theme.css +103 -91
- package/dist/primereact/resources/themes/bootstrap4-dark-blue/theme.css +103 -91
- package/dist/primereact/resources/themes/bootstrap4-dark-purple/theme.css +103 -91
- package/dist/primereact/resources/themes/bootstrap4-light-blue/theme.css +102 -90
- package/dist/primereact/resources/themes/bootstrap4-light-purple/theme.css +102 -90
- package/dist/primereact/resources/themes/fluent-light/theme.css +103 -91
- package/dist/primereact/resources/themes/lara-dark-amber/fonts/Inter-italic.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-dark-amber/fonts/Inter-roman.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-dark-amber/theme.css +6049 -0
- package/dist/primereact/resources/themes/lara-dark-blue/theme.css +1006 -955
- package/dist/primereact/resources/themes/lara-dark-cyan/fonts/Inter-italic.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-dark-cyan/fonts/Inter-roman.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-dark-cyan/theme.css +6049 -0
- package/dist/primereact/resources/themes/lara-dark-green/fonts/Inter-italic.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-dark-green/fonts/Inter-roman.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-dark-green/theme.css +6049 -0
- package/dist/primereact/resources/themes/lara-dark-indigo/theme.css +1006 -955
- package/dist/primereact/resources/themes/lara-dark-pink/fonts/Inter-italic.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-dark-pink/fonts/Inter-roman.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-dark-pink/theme.css +6049 -0
- package/dist/primereact/resources/themes/lara-dark-purple/theme.css +1006 -955
- package/dist/primereact/resources/themes/lara-dark-teal/theme.css +1006 -955
- package/dist/primereact/resources/themes/lara-light-amber/fonts/Inter-italic.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-light-amber/fonts/Inter-roman.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-light-amber/theme.css +6041 -0
- package/dist/primereact/resources/themes/lara-light-blue/theme.css +842 -799
- package/dist/primereact/resources/themes/lara-light-cyan/fonts/Inter-italic.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-light-cyan/fonts/Inter-roman.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-light-cyan/theme.css +6041 -0
- package/dist/primereact/resources/themes/lara-light-green/fonts/Inter-italic.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-light-green/fonts/Inter-roman.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-light-green/theme.css +6041 -0
- package/dist/primereact/resources/themes/lara-light-indigo/theme.css +842 -799
- package/dist/primereact/resources/themes/lara-light-pink/fonts/Inter-italic.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-light-pink/fonts/Inter-roman.var.woff2 +0 -0
- package/dist/primereact/resources/themes/lara-light-pink/theme.css +6041 -0
- package/dist/primereact/resources/themes/lara-light-purple/theme.css +842 -799
- package/dist/primereact/resources/themes/lara-light-teal/theme.css +1115 -1072
- package/dist/primereact/resources/themes/luna-amber/theme.css +103 -91
- package/dist/primereact/resources/themes/luna-blue/theme.css +103 -91
- package/dist/primereact/resources/themes/luna-green/theme.css +103 -91
- package/dist/primereact/resources/themes/luna-pink/theme.css +103 -91
- package/dist/primereact/resources/themes/md-dark-deeppurple/theme.css +147 -135
- package/dist/primereact/resources/themes/md-dark-indigo/theme.css +147 -135
- package/dist/primereact/resources/themes/md-light-deeppurple/theme.css +147 -135
- package/dist/primereact/resources/themes/md-light-indigo/theme.css +147 -135
- package/dist/primereact/resources/themes/mdc-dark-deeppurple/theme.css +147 -135
- package/dist/primereact/resources/themes/mdc-dark-indigo/theme.css +147 -135
- package/dist/primereact/resources/themes/mdc-light-deeppurple/theme.css +147 -135
- package/dist/primereact/resources/themes/mdc-light-indigo/theme.css +147 -135
- package/dist/primereact/resources/themes/mira/theme.css +108 -91
- package/dist/primereact/resources/themes/nano/theme.css +107 -91
- package/dist/primereact/resources/themes/nova/theme.css +103 -91
- package/dist/primereact/resources/themes/nova-accent/theme.css +103 -91
- package/dist/primereact/resources/themes/nova-alt/theme.css +103 -91
- package/dist/primereact/resources/themes/rhea/theme.css +103 -91
- package/dist/primereact/resources/themes/saga-blue/theme.css +103 -91
- package/dist/primereact/resources/themes/saga-green/theme.css +103 -91
- package/dist/primereact/resources/themes/saga-orange/theme.css +103 -91
- package/dist/primereact/resources/themes/saga-purple/theme.css +103 -91
- package/dist/primereact/resources/themes/soho-dark/theme.css +108 -91
- package/dist/primereact/resources/themes/soho-light/theme.css +108 -91
- package/dist/primereact/resources/themes/vela-blue/theme.css +103 -91
- package/dist/primereact/resources/themes/vela-green/theme.css +103 -91
- package/dist/primereact/resources/themes/vela-orange/theme.css +103 -91
- package/dist/primereact/resources/themes/vela-purple/theme.css +103 -91
- package/dist/primereact/resources/themes/viva-dark/theme.css +103 -91
- package/dist/primereact/resources/themes/viva-light/theme.css +103 -91
- package/package.json +29 -16
- package/tailwind.config.js +9 -2
- package/types/client-components/ClientLink.d.ts +6 -0
- package/types/client-components/MultiComponentEditor.d.ts +10 -0
- package/types/client-components/index.d.ts +2 -0
- package/types/components/Picture.d.ts +1 -0
- package/types/components/Placeholder.d.ts +16 -2
- package/types/components/RichTextEditor.d.ts +55 -55
- package/types/components/TextEditor.d.ts +54 -54
- package/types/editor/AiPopup.d.ts +10 -0
- package/types/editor/AiTerminal.d.ts +4 -3
- package/types/editor/ComponentPalette.d.ts +3 -4
- package/types/editor/ComponentTree.d.ts +1 -1
- package/types/editor/ConfirmationDialog.d.ts +19 -0
- package/types/editor/ContentTree.d.ts +7 -3
- package/types/editor/Debug.d.ts +1 -1
- package/types/editor/DialogButtons.d.ts +4 -0
- package/types/editor/DictionaryEditor.d.ts +3 -2
- package/types/editor/EditFrame.d.ts +4 -3
- package/types/editor/EditorClient.d.ts +4 -4
- package/types/editor/EditorClientHost.d.ts +4 -3
- package/types/editor/FieldListField.d.ts +4 -0
- package/types/editor/FloatingToolbar.d.ts +7 -0
- package/types/editor/ItemEditor.d.ts +4 -0
- package/types/editor/ItemInfo.d.ts +4 -0
- package/types/editor/ItemNameDialog.d.ts +10 -0
- package/types/editor/LinkEditorDialog.d.ts +15 -0
- package/types/editor/MainLayout.d.ts +6 -0
- package/types/editor/MediaSelector.d.ts +2 -1
- package/types/editor/PictureEditorDialog.d.ts +6 -0
- package/types/editor/SidebarTabs.d.ts +8 -0
- package/types/editor/Terminal.d.ts +3 -1
- package/types/editor/Utils.d.ts +3 -0
- package/types/editor/Workbox.d.ts +6 -0
- package/types/editor/componentCommands.d.ts +4 -0
- package/types/editor/contentService.d.ts +7 -1
- package/types/editor/editContext.d.ts +90 -19
- package/types/editor/editService.d.ts +9 -1
- package/types/editor/fieldTypes/CheckboxEditor.d.ts +4 -0
- package/types/editor/fieldTypes/InternalLinkFieldEditor.d.ts +4 -0
- package/types/editor/fieldTypes/LinkFieldEditor.d.ts +4 -0
- package/types/editor/fieldTypes/MultiLineText.d.ts +4 -0
- package/types/editor/fieldTypes/PictureFieldEditor.d.ts +4 -0
- package/types/editor/fieldTypes/TreeListEditor.d.ts +4 -0
- package/types/editor/ui/Section.d.ts +5 -0
- package/types/fieldTypes.d.ts +32 -17
- package/types/layoutData.d.ts +34 -9
- package/types/loadRouteData.d.ts +34 -5
- package/types/mediaProtection.d.ts +1 -0
- package/types/middleware/authorization.d.ts +2 -0
- package/types/middleware/index.d.ts +1 -0
- package/dist/cjs/editor/PageInfo.js +0 -12
- package/dist/esm/alpacaContext.js +0 -8
- package/dist/esm/components/Error.js +0 -10
- package/dist/esm/components/Image.js +0 -32
- package/dist/esm/components/Link.js +0 -29
- package/dist/esm/components/LinkEditor.js +0 -19
- package/dist/esm/components/Picture.js +0 -118
- package/dist/esm/components/PictureEditor.js +0 -41
- package/dist/esm/components/Placeholder.js +0 -69
- package/dist/esm/components/RichText.js +0 -40
- package/dist/esm/components/RichTextEditor.js +0 -52
- package/dist/esm/components/Slot.js +0 -5
- package/dist/esm/components/Text.js +0 -39
- package/dist/esm/components/TextEditor.js +0 -38
- package/dist/esm/components/Translate.js +0 -10
- package/dist/esm/components/index.js +0 -7
- package/dist/esm/editor/AiTerminal.js +0 -157
- package/dist/esm/editor/ComponentInfo.js +0 -10
- package/dist/esm/editor/ComponentPalette.js +0 -72
- package/dist/esm/editor/ComponentTree.js +0 -196
- package/dist/esm/editor/ContentTree.js +0 -117
- package/dist/esm/editor/Debug.js +0 -9
- package/dist/esm/editor/DictionaryEditor.js +0 -31
- package/dist/esm/editor/EditFrame.js +0 -57
- package/dist/esm/editor/EditHistory.js +0 -26
- package/dist/esm/editor/Editor.js +0 -23
- package/dist/esm/editor/EditorClient.js +0 -477
- package/dist/esm/editor/EditorClientHost.js +0 -7
- package/dist/esm/editor/FieldList.js +0 -60
- package/dist/esm/editor/GraphQL.js +0 -82
- package/dist/esm/editor/LanguageSelector.js +0 -17
- package/dist/esm/editor/MediaSelector.js +0 -54
- package/dist/esm/editor/PageInfo.js +0 -8
- package/dist/esm/editor/PlaceholderDropZone.js +0 -50
- package/dist/esm/editor/PlaceholderDropZoneHost.js +0 -7
- package/dist/esm/editor/Terminal.js +0 -47
- package/dist/esm/editor/TranslateEditor.js +0 -21
- package/dist/esm/editor/VersionSelector.js +0 -17
- package/dist/esm/editor/componentTreeHelper.js +0 -14
- package/dist/esm/editor/contentService.js +0 -31
- package/dist/esm/editor/editContext.js +0 -5
- package/dist/esm/editor/editService.js +0 -139
- package/dist/esm/editor/fieldTypes/RichTextEditor.js +0 -15
- package/dist/esm/editor/fieldTypes/SingleLineText.js +0 -13
- package/dist/esm/editor/index.js +0 -2
- package/dist/esm/fieldTypes.js +0 -1
- package/dist/esm/graphQLTypes.js +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/layoutData.js +0 -1
- package/dist/esm/loadRouteData.js +0 -123
- package/dist/esm/mediaProtection.js +0 -49
- package/types/editor/PageInfo.d.ts +0 -4
- /package/types/{editor → components}/TranslateEditor.d.ts +0 -0
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { useAlpacaContext } from "..";
|
|
14
|
-
import LinkEditor from "./LinkEditor";
|
|
15
|
-
export function Link(_a) {
|
|
16
|
-
var _b;
|
|
17
|
-
var { field, children } = _a, props = __rest(_a, ["field", "children"]);
|
|
18
|
-
if (!field)
|
|
19
|
-
return;
|
|
20
|
-
if (field.jsonValue) {
|
|
21
|
-
field = field.jsonValue;
|
|
22
|
-
}
|
|
23
|
-
if (!field.value)
|
|
24
|
-
return;
|
|
25
|
-
const editing = (_b = useAlpacaContext().pageContext) === null || _b === void 0 ? void 0 : _b.pageEditing;
|
|
26
|
-
if (editing)
|
|
27
|
-
return (_jsx(LinkEditor, Object.assign({ field: field, children: children }, props)));
|
|
28
|
-
return (_jsx("a", Object.assign({ href: field.value.url }, props, { children: children })));
|
|
29
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
export default function LinkEditor(_a) {
|
|
15
|
-
var { field, children } = _a, props = __rest(_a, ["field", "children"]);
|
|
16
|
-
if (!field)
|
|
17
|
-
return;
|
|
18
|
-
return (_jsx("a", Object.assign({ href: field.value.url }, props, { onClick: (e) => e.preventDefault(), children: children })));
|
|
19
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
-
import { hashImageUrl } from "../mediaProtection";
|
|
14
|
-
import { useAlpacaContext } from "..";
|
|
15
|
-
import { PictureEditor } from "./PictureEditor";
|
|
16
|
-
// const addClassName = (otherAttrs: { [key: string]: unknown }): void => {
|
|
17
|
-
// if (otherAttrs.class) {
|
|
18
|
-
// // if any classes are defined properly already
|
|
19
|
-
// if (otherAttrs.className) {
|
|
20
|
-
// let className: string = otherAttrs.className as string;
|
|
21
|
-
// className += ` ${otherAttrs.class}`;
|
|
22
|
-
// otherAttrs.className = className;
|
|
23
|
-
// } else {
|
|
24
|
-
// otherAttrs.className = otherAttrs.class;
|
|
25
|
-
// }
|
|
26
|
-
// delete otherAttrs.class;
|
|
27
|
-
// }
|
|
28
|
-
// };
|
|
29
|
-
export const Picture = (_a) => {
|
|
30
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
31
|
-
var { field, imageParams, sources, defaultVariant, renderJsonLinkedData } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant", "renderJsonLinkedData"]);
|
|
32
|
-
if (!field)
|
|
33
|
-
return null;
|
|
34
|
-
if (field.jsonValue) {
|
|
35
|
-
field = field.jsonValue;
|
|
36
|
-
}
|
|
37
|
-
if ((_b = useAlpacaContext().pageContext) === null || _b === void 0 ? void 0 : _b.pageEditing)
|
|
38
|
-
return _jsx(PictureEditor, Object.assign({ field: field }, otherProps));
|
|
39
|
-
const variants = (_c = field.value) === null || _c === void 0 ? void 0 : _c.variants;
|
|
40
|
-
const img = (_e = (_d = field.value) === null || _d === void 0 ? void 0 : _d.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _e !== void 0 ? _e : (_f = field.value) === null || _f === void 0 ? void 0 : _f.variants[0];
|
|
41
|
-
const attrs = Object.assign({ src: img === null || img === void 0 ? void 0 : img.src }, otherProps);
|
|
42
|
-
const video = img === null || img === void 0 ? void 0 : img.videoUrl;
|
|
43
|
-
const videoAttr = Object.assign({ src: video }, otherProps);
|
|
44
|
-
if (!(sources === null || sources === void 0 ? void 0 : sources.length)) {
|
|
45
|
-
return _jsx("img", Object.assign({}, attrs, { alt: (_g = field.value) === null || _g === void 0 ? void 0 : _g.alt }));
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return (_jsxs(_Fragment, { children: [_jsxs("picture", { children: [sources === null || sources === void 0 ? void 0 : sources.map((source) => {
|
|
49
|
-
const variant = variants === null || variants === void 0 ? void 0 : variants.find((v) => v.name.toLowerCase() == source.variant.toLowerCase());
|
|
50
|
-
if (!(variant === null || variant === void 0 ? void 0 : variant.src))
|
|
51
|
-
return;
|
|
52
|
-
let srcSet = hashImageUrl(variant.src);
|
|
53
|
-
const getScaledImage = (variant, width) => {
|
|
54
|
-
if (width > variant.width)
|
|
55
|
-
return { src: variant.src, width: 0 };
|
|
56
|
-
else
|
|
57
|
-
return {
|
|
58
|
-
src: variant.src +
|
|
59
|
-
`${variant.src.includes("?") ? "&" : "?"}mw=` +
|
|
60
|
-
width,
|
|
61
|
-
width: width,
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
if (source.widths && source.widths.length) {
|
|
65
|
-
let scaledImages = source.widths.map((x) => getScaledImage(variant, x));
|
|
66
|
-
srcSet = "";
|
|
67
|
-
for (let w = 0; w < scaledImages.length; w++) {
|
|
68
|
-
if (srcSet.length)
|
|
69
|
-
srcSet = srcSet + ", ";
|
|
70
|
-
srcSet +=
|
|
71
|
-
hashImageUrl(scaledImages[w].src) +
|
|
72
|
-
" " +
|
|
73
|
-
source.widths[w] +
|
|
74
|
-
"w";
|
|
75
|
-
if (scaledImages[w].width === 0)
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
if (source.width) {
|
|
81
|
-
srcSet = hashImageUrl(getScaledImage(variant, source.width).src);
|
|
82
|
-
if (source.scales) {
|
|
83
|
-
let scaledImages = source.scales.map((x) => { var _a; return getScaledImage(variant, ((_a = source.width) !== null && _a !== void 0 ? _a : 0) * x); });
|
|
84
|
-
srcSet = "";
|
|
85
|
-
for (let w = 0; w < scaledImages.length; w++) {
|
|
86
|
-
if (srcSet.length)
|
|
87
|
-
srcSet = srcSet + ", ";
|
|
88
|
-
srcSet +=
|
|
89
|
-
hashImageUrl(scaledImages[w].src) +
|
|
90
|
-
" " +
|
|
91
|
-
source.scales[w] +
|
|
92
|
-
"x";
|
|
93
|
-
if (scaledImages[w].width === 0)
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return (_jsx("source", { srcSet: srcSet, media: source.media }, source.variant + source.media));
|
|
100
|
-
}), _jsx("img", Object.assign({}, attrs, { alt: (_h = field.value) === null || _h === void 0 ? void 0 : _h.alt }))] }), renderJsonLinkedData && !video ? (_jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
|
|
101
|
-
__html: JSON.stringify({
|
|
102
|
-
"@context": "http://schema.org",
|
|
103
|
-
"@type": "ImageObject",
|
|
104
|
-
image: img === null || img === void 0 ? void 0 : img.src,
|
|
105
|
-
description: (_j = field.value) === null || _j === void 0 ? void 0 : _j.alt,
|
|
106
|
-
name: (_k = field.value) === null || _k === void 0 ? void 0 : _k.name,
|
|
107
|
-
}),
|
|
108
|
-
} })) : null, video && _jsx("video", Object.assign({}, videoAttr)), renderJsonLinkedData && video ? (_jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
|
|
109
|
-
__html: JSON.stringify({
|
|
110
|
-
"@context": "http://schema.org",
|
|
111
|
-
"@type": "VideoObject",
|
|
112
|
-
contentUrl: img === null || img === void 0 ? void 0 : img.src,
|
|
113
|
-
description: (_l = field.value) === null || _l === void 0 ? void 0 : _l.alt,
|
|
114
|
-
name: (_m = field.value) === null || _m === void 0 ? void 0 : _m.name,
|
|
115
|
-
}),
|
|
116
|
-
} })) : null] }));
|
|
117
|
-
}
|
|
118
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
-
import { useState } from "react";
|
|
15
|
-
import { Picture } from "./Picture";
|
|
16
|
-
import { useEditContext } from "..";
|
|
17
|
-
import { MediaSelector } from "../editor/MediaSelector";
|
|
18
|
-
import { Dialog } from "primereact/dialog";
|
|
19
|
-
export const PictureEditor = (_a) => {
|
|
20
|
-
var _b, _c;
|
|
21
|
-
var { field, imageParams, sources, defaultVariant, renderJsonLinkedData } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant", "renderJsonLinkedData"]);
|
|
22
|
-
const editContext = useEditContext();
|
|
23
|
-
const [mediaSelectorVisible, setMediaSelectorVisible] = useState(false);
|
|
24
|
-
const [editorVisible, setEditorVisible] = useState(false);
|
|
25
|
-
const [selectedVariant, setSelectedVariant] = useState();
|
|
26
|
-
if (!editContext)
|
|
27
|
-
return;
|
|
28
|
-
function imageSelected(imageId) {
|
|
29
|
-
const value = (field === null || field === void 0 ? void 0 : field.value) || {};
|
|
30
|
-
if (!selectedVariant)
|
|
31
|
-
return;
|
|
32
|
-
selectedVariant.mediaId = imageId;
|
|
33
|
-
console.log(imageId);
|
|
34
|
-
console.log(JSON.stringify(value));
|
|
35
|
-
if (field)
|
|
36
|
-
editContext === null || editContext === void 0 ? void 0 : editContext.editField(field, JSON.stringify(value), false);
|
|
37
|
-
}
|
|
38
|
-
console.log(JSON.stringify(field));
|
|
39
|
-
return (_jsxs(_Fragment, { children: [_jsx(MediaSelector, { visible: mediaSelectorVisible, onHide: () => setMediaSelectorVisible(false), onMediaSelected: imageSelected }), _jsx(Dialog, { header: "Edit picture", visible: editorVisible, style: { width: "50vw" }, onHide: () => setEditorVisible(false), children: _jsx("div", { className: "a-flex a-gap-1", children: (_c = (_b = field === null || field === void 0 ? void 0 : field.value) === null || _b === void 0 ? void 0 : _b.variants) === null || _c === void 0 ? void 0 : _c.map((variant) => (_jsxs("div", { onClick: () => setSelectedVariant(variant), children: [_jsxs("div", { className: "a-h-24 a-w-24 a-border a-relative" +
|
|
40
|
-
(selectedVariant == variant ? " a-shadow-xl " : ""), children: [variant.src && _jsx("img", { src: variant.src }), _jsx("div", { className: "a-absolute a-top-0 a-right-0 ", children: _jsx("i", { className: "pi pi-pencil a-m-1 a-cursor-pointer", onClick: () => setMediaSelectorVisible(true) }) })] }, variant.name), _jsx("div", { children: variant.name }), _jsx("div", { children: variant.aspectRatioText })] }))) }) }), _jsxs("span", Object.assign({}, otherProps, { onClick: () => setEditorVisible(true), children: ["PICTURE", _jsx(Picture, { field: field, imageParams: imageParams, sources: sources })] }))] }));
|
|
41
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
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, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { EditFrame } from "../editor/EditFrame";
|
|
12
|
-
import { useAlpacaContext, } from "..";
|
|
13
|
-
import { PlaceholderDropZoneHost } from "../editor/PlaceholderDropZoneHost";
|
|
14
|
-
import Slot from "./Slot";
|
|
15
|
-
import { ErrorBoundary } from "react-error-boundary";
|
|
16
|
-
import { ErrorFallbackWithDetails, ErrorFallback } from "./Error";
|
|
17
|
-
export function Placeholder({ name, content, }) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const data = yield content;
|
|
20
|
-
if (!data || !("placeholders" in data))
|
|
21
|
-
return;
|
|
22
|
-
const placeholderData = data.placeholders.find((x) => x.name == name);
|
|
23
|
-
if (!placeholderData)
|
|
24
|
-
return;
|
|
25
|
-
const context = useAlpacaContext();
|
|
26
|
-
const loader = context.componentModuleLoader;
|
|
27
|
-
const promises = placeholderData === null || placeholderData === void 0 ? void 0 : placeholderData.components.map((component) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
if (component.componentType == "Slot")
|
|
29
|
-
return { Component: Slot, data: component, parent: data };
|
|
30
|
-
let module = null;
|
|
31
|
-
try {
|
|
32
|
-
module = yield loader(component.componentType);
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
console.log(e);
|
|
36
|
-
}
|
|
37
|
-
if (!module) {
|
|
38
|
-
console.log("Could not find module " + component.componentType);
|
|
39
|
-
return {
|
|
40
|
-
data: { name: component.componentType, id: "0" },
|
|
41
|
-
Component: ComponentNotFound,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return { parent: data, data: component, Component: module.default };
|
|
45
|
-
}));
|
|
46
|
-
const components = yield Promise.all(promises);
|
|
47
|
-
if (context.pageContext.pageEditing) {
|
|
48
|
-
return (_jsxs(_Fragment, { children: [components.map(({ Component, data, parent }, index) => {
|
|
49
|
-
try {
|
|
50
|
-
return (_jsxs(_Fragment, { children: [_jsx(PlaceholderDropZoneHost, { parentName: parent === null || parent === void 0 ? void 0 : parent.name, placeholder: placeholderData, index: index + 1 }), _jsx(EditFrame, { componentId: data.id, children: _jsx(ErrorBoundary, { FallbackComponent: ErrorFallbackWithDetails, children: _jsx(Component, { component: data }) }) }, data.id)] }));
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
return (_jsxs("div", { children: ["Error rendering component ", data.name, ": ", e.message] }));
|
|
54
|
-
}
|
|
55
|
-
}), _jsx(PlaceholderDropZoneHost, { parentName: data === null || data === void 0 ? void 0 : data.name, placeholder: placeholderData, index: components.length + 1 })] }));
|
|
56
|
-
}
|
|
57
|
-
else
|
|
58
|
-
return (_jsx(_Fragment, { children: components.map(({ Component, data }) => (_jsx(_Fragment, { children: _jsx(ErrorBoundary, { FallbackComponent: ErrorFallback, children: _jsx(Component, { component: data }) }) }))) }));
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
function ComponentNotFound({ component }) {
|
|
62
|
-
return (_jsxs("div", { style: {
|
|
63
|
-
backgroundColor: "orange",
|
|
64
|
-
color: "red",
|
|
65
|
-
fontSize: 18,
|
|
66
|
-
padding: 10,
|
|
67
|
-
border: "3px solid red",
|
|
68
|
-
}, children: ["Component not found: ", component.name, " "] }));
|
|
69
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
-
import React from "react";
|
|
23
|
-
import { RichTextEditor } from "./RichTextEditor";
|
|
24
|
-
import { useAlpacaContext } from "..";
|
|
25
|
-
export function RichText(_a) {
|
|
26
|
-
var { field, tag, editable } = _a, props = __rest(_a, ["field", "tag", "editable"]);
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
if (!field)
|
|
29
|
-
return;
|
|
30
|
-
if (field.jsonValue) {
|
|
31
|
-
field = field.jsonValue;
|
|
32
|
-
}
|
|
33
|
-
const internalProps = Object.assign(Object.assign({}, props), { dangerouslySetInnerHTML: {
|
|
34
|
-
__html: field.value,
|
|
35
|
-
}, editable: editable, contentEditable: true, "data-test": "test", placeholder: "[" + field.name + "]" });
|
|
36
|
-
if (useAlpacaContext().pageContext.pageEditing)
|
|
37
|
-
return _jsx(RichTextEditor, Object.assign({ field: field, tag: tag }, props));
|
|
38
|
-
return React.createElement(tag || "div", Object.assign(props, internalProps));
|
|
39
|
-
});
|
|
40
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
|
14
|
-
import { useEditContext } from "../editor/editContext";
|
|
15
|
-
export function RichTextEditor(_a) {
|
|
16
|
-
var { field, tag } = _a, props = __rest(_a, ["field", "tag"]);
|
|
17
|
-
const editContext = useEditContext();
|
|
18
|
-
const [value, setValue] = useState("");
|
|
19
|
-
const [editedValue, setEditedValue] = useState();
|
|
20
|
-
if (!editContext)
|
|
21
|
-
return;
|
|
22
|
-
const { updateContentEditingFields } = editContext;
|
|
23
|
-
const liveField = editContext.getLiveField(field);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (editedValue != liveField.value &&
|
|
26
|
-
"<p>" + editedValue + "</p>" != liveField.value) {
|
|
27
|
-
// console.log(
|
|
28
|
-
// "editedValue:" + editedValue + " liveField.value " + liveField.value
|
|
29
|
-
// );
|
|
30
|
-
setValue(liveField.value);
|
|
31
|
-
}
|
|
32
|
-
}, [liveField.value]);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
setValue(liveField.value); // Otherwise react would not update the field after the refresh
|
|
35
|
-
}, [updateContentEditingFields]);
|
|
36
|
-
const setFieldValue = (val) => {
|
|
37
|
-
if (val != editedValue) {
|
|
38
|
-
setEditedValue(val);
|
|
39
|
-
if (editContext)
|
|
40
|
-
editContext.editField(field, val, true);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const eventHandler = useCallback((e) => {
|
|
44
|
-
setFieldValue(e.currentTarget.innerHTML);
|
|
45
|
-
}, [editContext.editField]);
|
|
46
|
-
return useMemo(() => {
|
|
47
|
-
const properies = Object.assign(Object.assign({}, props), { contentEditable: true, suppressContentEditableWarning: true, onInput: eventHandler, placeholder: "[" + field.name + "]", dangerouslySetInnerHTML: {
|
|
48
|
-
__html: value,
|
|
49
|
-
} });
|
|
50
|
-
return React.createElement(tag || "div", properies);
|
|
51
|
-
}, [value]);
|
|
52
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Placeholder } from "..";
|
|
3
|
-
export default function Section({ component }) {
|
|
4
|
-
return (_jsx(_Fragment, { children: _jsx(Placeholder, { name: "ph-slot-content", content: component }) }));
|
|
5
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
-
import React from "react";
|
|
23
|
-
import { TextEditor } from "./TextEditor";
|
|
24
|
-
import { useAlpacaContext } from "..";
|
|
25
|
-
export function Text(_a) {
|
|
26
|
-
var { field, tag, editable } = _a, props = __rest(_a, ["field", "tag", "editable"]);
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
if (!field)
|
|
29
|
-
return;
|
|
30
|
-
if (field.jsonValue) {
|
|
31
|
-
field = field.jsonValue;
|
|
32
|
-
}
|
|
33
|
-
if (useAlpacaContext().pageContext.pageEditing) {
|
|
34
|
-
return (_jsx("div", { children: _jsx(TextEditor, Object.assign({ field: field, tag: tag }, props)) }));
|
|
35
|
-
}
|
|
36
|
-
else
|
|
37
|
-
return React.createElement(tag || "div", props, field.value);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
import React, { useEffect, useState } from "react";
|
|
14
|
-
import { useEditContext } from "../editor/editContext";
|
|
15
|
-
export function TextEditor(_a) {
|
|
16
|
-
var { field, tag } = _a, props = __rest(_a, ["field", "tag"]);
|
|
17
|
-
const editContext = useEditContext();
|
|
18
|
-
const [value, setValue] = useState("");
|
|
19
|
-
const [editedValue, setEditedValue] = useState();
|
|
20
|
-
if (!editContext)
|
|
21
|
-
return;
|
|
22
|
-
const { updateContentEditingFields } = editContext;
|
|
23
|
-
const liveField = editContext.getLiveField(field);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (editedValue != liveField.value)
|
|
26
|
-
setValue(liveField.value);
|
|
27
|
-
}, [liveField.value]);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
setValue(liveField.value); // Otherwise react would not update the field after the refresh
|
|
30
|
-
}, [updateContentEditingFields]);
|
|
31
|
-
const properies = Object.assign(Object.assign({}, props), { contentEditable: true, suppressContentEditableWarning: true, onInput: (e) => setFieldValue(e.currentTarget.textContent), placeholder: "[" + field.name + "]" });
|
|
32
|
-
const setFieldValue = (val) => {
|
|
33
|
-
setEditedValue(val);
|
|
34
|
-
if (editContext)
|
|
35
|
-
editContext.editField(field, val, true);
|
|
36
|
-
};
|
|
37
|
-
return React.createElement(tag || "div", properies, value);
|
|
38
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useAlpacaContext } from "..";
|
|
3
|
-
import { TranslateEditor } from "../editor/TranslateEditor";
|
|
4
|
-
export function Translate({ text }) {
|
|
5
|
-
const context = useAlpacaContext();
|
|
6
|
-
const dictionary = context.dictionary;
|
|
7
|
-
if (context.pageContext.pageEditing)
|
|
8
|
-
return _jsx(TranslateEditor, { text: text });
|
|
9
|
-
return dictionary[text] || text;
|
|
10
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { useEffect, useRef, useState } from "react";
|
|
13
|
-
import { TerminalService } from "primereact/terminalservice";
|
|
14
|
-
import { useRouter, useSearchParams } from "next/navigation";
|
|
15
|
-
import { Terminal } from "./Terminal";
|
|
16
|
-
export function AiTerminal({ requestRefresh, selection, }) {
|
|
17
|
-
const searchParams = useSearchParams();
|
|
18
|
-
const [messages, setMessages] = useState([]);
|
|
19
|
-
const [tokens, setTokens] = useState({ in: 0, out: 0 });
|
|
20
|
-
const selectionRef = useRef(selection);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
selectionRef.current = selection;
|
|
23
|
-
}, [selection]);
|
|
24
|
-
const messagesRef = useRef(messages);
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
messagesRef.current = messages;
|
|
27
|
-
}, [messages]);
|
|
28
|
-
const router = useRouter();
|
|
29
|
-
function commandHandler(text, callback) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const newMessages = [
|
|
32
|
-
...messagesRef.current,
|
|
33
|
-
{ content: text, role: "user", name: "user" },
|
|
34
|
-
];
|
|
35
|
-
let lastRefresh = new Date().getTime();
|
|
36
|
-
const response = yield prompt(newMessages, selectionRef.current, searchParams.get("session"), searchParams.get("itemid"), searchParams.get("language"), searchParams.get("version"), (response) => {
|
|
37
|
-
console.log(response);
|
|
38
|
-
setTokens({
|
|
39
|
-
in: response.numInputTokens,
|
|
40
|
-
out: response.numOutputTokens,
|
|
41
|
-
});
|
|
42
|
-
handleResponse(response, callback, false);
|
|
43
|
-
if (response.editOperations.length) {
|
|
44
|
-
if (new Date().getTime() - lastRefresh > 500) {
|
|
45
|
-
requestRefresh("delayed");
|
|
46
|
-
router.refresh();
|
|
47
|
-
lastRefresh = new Date().getTime();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
if (response) {
|
|
52
|
-
handleResponse(response, callback, true);
|
|
53
|
-
setTokens({ in: response.numInputTokens, out: response.numOutputTokens });
|
|
54
|
-
router.refresh();
|
|
55
|
-
}
|
|
56
|
-
// if (response) {
|
|
57
|
-
// messages.push({content: text, 'role': 'assistant', 'name': 'assistant'});
|
|
58
|
-
// if(response.editOperations) {
|
|
59
|
-
// const newEditOperations = [...editOperationsRef.current, {
|
|
60
|
-
// type:'composite',
|
|
61
|
-
// name: 'ghostwriter',
|
|
62
|
-
// date: new Date(),
|
|
63
|
-
// operations: response.editOperations
|
|
64
|
-
// }];
|
|
65
|
-
// setEditOperations(newEditOperations);
|
|
66
|
-
// }
|
|
67
|
-
if (response === null || response === void 0 ? void 0 : response.responseText)
|
|
68
|
-
newMessages.push({
|
|
69
|
-
content: response.responseText,
|
|
70
|
-
role: "assistant",
|
|
71
|
-
name: "assistant",
|
|
72
|
-
});
|
|
73
|
-
// TerminalService.emit('response', response.responseText);
|
|
74
|
-
// }
|
|
75
|
-
// // else
|
|
76
|
-
// // TerminalService.emit('clear');
|
|
77
|
-
setMessages(newMessages);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
TerminalService.on("command", commandHandler);
|
|
82
|
-
return () => {
|
|
83
|
-
TerminalService.off("command", commandHandler);
|
|
84
|
-
};
|
|
85
|
-
}, []);
|
|
86
|
-
return (_jsxs("div", { className: "a-h-full a-flex a-flex-col a-relative", children: [_jsx("div", { className: "a-flex-1 a-relative", children: _jsx("div", { className: "a-inset-0 a-absolute", children: _jsx(Terminal, { onReset: () => setMessages([]), commandHandler: (v, callback) => {
|
|
87
|
-
commandHandler(v, callback);
|
|
88
|
-
} }) }) }), _jsxs("div", { className: "a-text-xs", children: ["Tokens in: ", tokens.in, " out: ", tokens.out] })] }));
|
|
89
|
-
}
|
|
90
|
-
function prompt(messages, selection, session, itemid, language, version, callback) {
|
|
91
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const response = yield fetch("/alpaca/headless/ai/prompt", {
|
|
93
|
-
method: "POST",
|
|
94
|
-
body: JSON.stringify({
|
|
95
|
-
messages,
|
|
96
|
-
itemid,
|
|
97
|
-
language,
|
|
98
|
-
version,
|
|
99
|
-
selection,
|
|
100
|
-
sessionId: session,
|
|
101
|
-
}),
|
|
102
|
-
credentials: "omit",
|
|
103
|
-
headers: {
|
|
104
|
-
"Content-Type": "application/json",
|
|
105
|
-
//Cookie: 'test'// new Cookies().getAll(),
|
|
106
|
-
},
|
|
107
|
-
next: {
|
|
108
|
-
revalidate: 0,
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
if (!(response === null || response === void 0 ? void 0 : response.body))
|
|
112
|
-
return null;
|
|
113
|
-
const reader = response.body.getReader();
|
|
114
|
-
const decoder = new TextDecoder();
|
|
115
|
-
let buffer = "";
|
|
116
|
-
let result = null;
|
|
117
|
-
while (true) {
|
|
118
|
-
const { done, value } = yield reader.read();
|
|
119
|
-
if (done) {
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
buffer += decoder.decode(value, { stream: true }); // 'stream: true' ensures that any incomplete multi-byte characters aren't malformed.
|
|
123
|
-
// Split the buffer by newline and keep the last partial line for the next iteration.
|
|
124
|
-
const lines = buffer.split("\n");
|
|
125
|
-
if (lines.length > 0) {
|
|
126
|
-
buffer = lines.pop() || ""; // Incomplete line (if any) is kept for the next iteration.
|
|
127
|
-
for (let line of lines) {
|
|
128
|
-
if (line.trim() === "")
|
|
129
|
-
continue; // Skip empty lines if any.
|
|
130
|
-
try {
|
|
131
|
-
const jsonData = JSON.parse(line);
|
|
132
|
-
callback(jsonData);
|
|
133
|
-
result = jsonData;
|
|
134
|
-
}
|
|
135
|
-
catch (e) {
|
|
136
|
-
console.error("Error parsing line:" + line, e);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
// If there's any remaining content in the buffer after processing all chunks, try to process it.
|
|
142
|
-
if (buffer.trim() !== "") {
|
|
143
|
-
try {
|
|
144
|
-
const jsonData = JSON.parse(buffer);
|
|
145
|
-
result = jsonData;
|
|
146
|
-
}
|
|
147
|
-
catch (e) {
|
|
148
|
-
console.error("Error parsing the final buffer content:", e);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return result;
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
function handleResponse(response, terminalCallback, isFinished) {
|
|
155
|
-
console.log(response.responseText);
|
|
156
|
-
terminalCallback(response.responseText, isFinished);
|
|
157
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
export function ComponentInfo({ component, }) {
|
|
4
|
-
var _a;
|
|
5
|
-
if (!(component === null || component === void 0 ? void 0 : component.fields))
|
|
6
|
-
return;
|
|
7
|
-
const hostingPageItem = component.hostingPageItem ? (_jsx("div", { children: _jsxs("div", { className: "a-text-xs", children: ["Source: ", component.hostingPageItem.path, "( ID:", " ", component.hostingPageItem.id, ")"] }) })) : null;
|
|
8
|
-
const linkedComponent = component.linkedComponentItem ? (_jsx("div", { children: _jsxs("div", { className: "a-text-xs", children: ["Source: ", component.linkedComponentItem.path] }) })) : null;
|
|
9
|
-
return (_jsxs("div", { className: "a-p-1", children: [_jsx("h2", { className: "a-text-xl a-font-bold a-my-2", children: component.name }), _jsxs("div", { className: "a-text-xs", children: ["ID: ", component.id] }), _jsxs("div", { className: "a-text-xs", children: ["Languages: ", (_a = component.translations) === null || _a === void 0 ? void 0 : _a.join(", ")] }), hostingPageItem, linkedComponent] }));
|
|
10
|
-
}
|