@alpaca-editor/core 1.0.0
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/.prettierrc +3 -0
- package/eslint.config.mjs +4 -0
- package/images/bg-shape-black.webp +0 -0
- package/package.json +52 -0
- package/src/client-components/api.ts +6 -0
- package/src/client-components/index.ts +19 -0
- package/src/components/ActionButton.tsx +43 -0
- package/src/components/Error.tsx +57 -0
- package/src/config/config.tsx +737 -0
- package/src/config/types.ts +263 -0
- package/src/editor/ComponentInfo.tsx +77 -0
- package/src/editor/ConfirmationDialog.tsx +103 -0
- package/src/editor/ContentTree.tsx +654 -0
- package/src/editor/ContextMenu.tsx +155 -0
- package/src/editor/Editor.tsx +91 -0
- package/src/editor/EditorWarning.tsx +34 -0
- package/src/editor/EditorWarnings.tsx +33 -0
- package/src/editor/FieldEditorPopup.tsx +65 -0
- package/src/editor/FieldHistory.tsx +74 -0
- package/src/editor/FieldList.tsx +190 -0
- package/src/editor/FieldListField.tsx +387 -0
- package/src/editor/FieldListFieldWithFallbacks.tsx +211 -0
- package/src/editor/FloatingToolbar.tsx +163 -0
- package/src/editor/ImageEditor.tsx +129 -0
- package/src/editor/InsertMenu.tsx +332 -0
- package/src/editor/ItemInfo.tsx +90 -0
- package/src/editor/LinkEditorDialog.tsx +192 -0
- package/src/editor/MainLayout.tsx +94 -0
- package/src/editor/NewEditorClient.tsx +11 -0
- package/src/editor/PictureCropper.tsx +505 -0
- package/src/editor/PictureEditor.tsx +206 -0
- package/src/editor/PictureEditorDialog.tsx +381 -0
- package/src/editor/PublishDialog.ignore +74 -0
- package/src/editor/ScrollingContentTree.tsx +47 -0
- package/src/editor/Terminal.tsx +215 -0
- package/src/editor/Titlebar.tsx +23 -0
- package/src/editor/ai/AiPopup.tsx +59 -0
- package/src/editor/ai/AiResponseMessage.tsx +82 -0
- package/src/editor/ai/AiTerminal.tsx +450 -0
- package/src/editor/ai/AiToolCall.tsx +46 -0
- package/src/editor/ai/EditorAiTerminal.tsx +20 -0
- package/src/editor/ai/editorAiContext.ts +18 -0
- package/src/editor/client/DialogContext.tsx +49 -0
- package/src/editor/client/EditorClient.tsx +1831 -0
- package/src/editor/client/GenericDialog.tsx +50 -0
- package/src/editor/client/editContext.ts +330 -0
- package/src/editor/client/helpers.ts +44 -0
- package/src/editor/client/itemsRepository.ts +391 -0
- package/src/editor/client/operations.ts +610 -0
- package/src/editor/client/pageModelBuilder.ts +182 -0
- package/src/editor/commands/commands.ts +23 -0
- package/src/editor/commands/componentCommands.tsx +408 -0
- package/src/editor/commands/createVersionCommand.ts +33 -0
- package/src/editor/commands/deleteVersionCommand.ts +71 -0
- package/src/editor/commands/itemCommands.tsx +186 -0
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +201 -0
- package/src/editor/commands/undo.ts +39 -0
- package/src/editor/component-designer/ComponentDesigner.tsx +70 -0
- package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +11 -0
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +91 -0
- package/src/editor/component-designer/ComponentEditor.tsx +97 -0
- package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +31 -0
- package/src/editor/component-designer/ComponentRenderingEditor.tsx +104 -0
- package/src/editor/component-designer/ComponentsDropdown.tsx +39 -0
- package/src/editor/component-designer/PlaceholdersEditor.tsx +183 -0
- package/src/editor/component-designer/RenderingsDropdown.tsx +36 -0
- package/src/editor/component-designer/TemplateEditor.tsx +236 -0
- package/src/editor/component-designer/aiContext.ts +23 -0
- package/src/editor/componentTreeHelper.tsx +114 -0
- package/src/editor/control-center/ControlCenterMenu.tsx +71 -0
- package/src/editor/control-center/IndexOverview.tsx +50 -0
- package/src/editor/control-center/IndexSettings.tsx +266 -0
- package/src/editor/control-center/Status.tsx +7 -0
- package/src/editor/editor-warnings/ItemLocked.tsx +63 -0
- package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +22 -0
- package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +23 -0
- package/src/editor/editor-warnings/NoWriteAccess.tsx +15 -0
- package/src/editor/editor-warnings/ValidationErrors.tsx +54 -0
- package/src/editor/field-types/AttachmentEditor.tsx +9 -0
- package/src/editor/field-types/CheckboxEditor.tsx +47 -0
- package/src/editor/field-types/DropLinkEditor.tsx +75 -0
- package/src/editor/field-types/DropListEditor.tsx +84 -0
- package/src/editor/field-types/ImageFieldEditor.tsx +65 -0
- package/src/editor/field-types/InternalLinkFieldEditor.tsx +112 -0
- package/src/editor/field-types/LinkFieldEditor.tsx +85 -0
- package/src/editor/field-types/MultiLineText.tsx +63 -0
- package/src/editor/field-types/PictureFieldEditor.tsx +121 -0
- package/src/editor/field-types/RawEditor.tsx +53 -0
- package/src/editor/field-types/ReactQuill.tsx +580 -0
- package/src/editor/field-types/RichTextEditor.tsx +22 -0
- package/src/editor/field-types/RichTextEditorComponent.tsx +108 -0
- package/src/editor/field-types/SingleLineText.tsx +150 -0
- package/src/editor/field-types/TreeListEditor.tsx +261 -0
- package/src/editor/fieldTypes.ts +140 -0
- package/src/editor/media-selector/AiImageSearch.tsx +186 -0
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +95 -0
- package/src/editor/media-selector/MediaSelector.tsx +42 -0
- package/src/editor/media-selector/Preview.tsx +14 -0
- package/src/editor/media-selector/Thumbnails.tsx +48 -0
- package/src/editor/media-selector/TreeSelector.tsx +292 -0
- package/src/editor/media-selector/UploadZone.tsx +137 -0
- package/src/editor/menubar/ActionsMenu.tsx +47 -0
- package/src/editor/menubar/ActiveUsers.tsx +17 -0
- package/src/editor/menubar/ApproveAndPublish.tsx +18 -0
- package/src/editor/menubar/BrowseHistory.tsx +37 -0
- package/src/editor/menubar/ItemLanguageVersion.tsx +52 -0
- package/src/editor/menubar/LanguageSelector.tsx +152 -0
- package/src/editor/menubar/Menu.tsx +83 -0
- package/src/editor/menubar/NavButtons.tsx +74 -0
- package/src/editor/menubar/PageSelector.tsx +139 -0
- package/src/editor/menubar/PageViewerControls.tsx +99 -0
- package/src/editor/menubar/Separator.tsx +12 -0
- package/src/editor/menubar/SiteInfo.tsx +53 -0
- package/src/editor/menubar/User.tsx +27 -0
- package/src/editor/menubar/VersionSelector.tsx +143 -0
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +287 -0
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +35 -0
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +44 -0
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +23 -0
- package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +64 -0
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +35 -0
- package/src/editor/page-editor-chrome/FrameMenu.tsx +263 -0
- package/src/editor/page-editor-chrome/FrameMenus.tsx +48 -0
- package/src/editor/page-editor-chrome/InlineEditor.tsx +147 -0
- package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +61 -0
- package/src/editor/page-editor-chrome/NoLayout.tsx +36 -0
- package/src/editor/page-editor-chrome/PageEditorChrome.tsx +119 -0
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +154 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +171 -0
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +233 -0
- package/src/editor/page-viewer/DeviceToolbar.tsx +70 -0
- package/src/editor/page-viewer/EditorForm.tsx +247 -0
- package/src/editor/page-viewer/MiniMap.tsx +351 -0
- package/src/editor/page-viewer/PageViewer.tsx +127 -0
- package/src/editor/page-viewer/PageViewerFrame.tsx +1030 -0
- package/src/editor/page-viewer/pageViewContext.ts +186 -0
- package/src/editor/pageModel.ts +191 -0
- package/src/editor/picture-shared.tsx +53 -0
- package/src/editor/reviews/Comment.tsx +265 -0
- package/src/editor/reviews/Comments.tsx +50 -0
- package/src/editor/reviews/PreviewInfo.tsx +35 -0
- package/src/editor/reviews/Reviews.tsx +280 -0
- package/src/editor/reviews/reviewCommands.tsx +47 -0
- package/src/editor/reviews/useReviews.tsx +70 -0
- package/src/editor/services/aiService.ts +155 -0
- package/src/editor/services/componentDesignerService.ts +151 -0
- package/src/editor/services/contentService.ts +159 -0
- package/src/editor/services/editService.ts +462 -0
- package/src/editor/services/indexService.ts +24 -0
- package/src/editor/services/reviewsService.ts +45 -0
- package/src/editor/services/serviceHelper.ts +95 -0
- package/src/editor/services/systemService.ts +5 -0
- package/src/editor/services/translationService.ts +21 -0
- package/src/editor/services-server/api.ts +150 -0
- package/src/editor/services-server/graphQL.ts +106 -0
- package/src/editor/sidebar/ComponentPalette.tsx +146 -0
- package/src/editor/sidebar/ComponentTree.tsx +512 -0
- package/src/editor/sidebar/ComponentTree2.tsxx +490 -0
- package/src/editor/sidebar/Debug.tsx +105 -0
- package/src/editor/sidebar/DictionaryEditor.tsx +261 -0
- package/src/editor/sidebar/EditHistory.tsx +134 -0
- package/src/editor/sidebar/GraphQL.tsx +164 -0
- package/src/editor/sidebar/Insert.tsx +35 -0
- package/src/editor/sidebar/MainContentTree.tsx +95 -0
- package/src/editor/sidebar/Performance.tsx +53 -0
- package/src/editor/sidebar/Sessions.tsx +35 -0
- package/src/editor/sidebar/Sidebar.tsx +20 -0
- package/src/editor/sidebar/SidebarView.tsx +150 -0
- package/src/editor/sidebar/Translations.tsx +276 -0
- package/src/editor/sidebar/Validation.tsx +102 -0
- package/src/editor/sidebar/ViewSelector.tsx +49 -0
- package/src/editor/sidebar/Workbox.tsx +209 -0
- package/src/editor/ui/CenteredMessage.tsx +7 -0
- package/src/editor/ui/CopyToClipboardButton.tsx +23 -0
- package/src/editor/ui/DialogButtons.tsx +11 -0
- package/src/editor/ui/Icons.tsx +585 -0
- package/src/editor/ui/ItemNameDialog.tsx +94 -0
- package/src/editor/ui/ItemNameDialogNew.tsx +118 -0
- package/src/editor/ui/ItemSearch.tsx +173 -0
- package/src/editor/ui/PerfectTree.tsx +550 -0
- package/src/editor/ui/Section.tsx +35 -0
- package/src/editor/ui/SimpleIconButton.tsx +43 -0
- package/src/editor/ui/SimpleMenu.tsx +48 -0
- package/src/editor/ui/SimpleTable.tsx +63 -0
- package/src/editor/ui/SimpleTabs.tsx +55 -0
- package/src/editor/ui/SimpleToolbar.tsx +7 -0
- package/src/editor/ui/Spinner.tsx +7 -0
- package/src/editor/ui/Splitter.tsx +247 -0
- package/src/editor/ui/StackedPanels.tsx +134 -0
- package/src/editor/ui/Toolbar.tsx +7 -0
- package/src/editor/utils/id-helper.ts +3 -0
- package/src/editor/utils/insertOptions.ts +69 -0
- package/src/editor/utils/itemutils.ts +29 -0
- package/src/editor/utils/useMemoDebug.ts +28 -0
- package/src/editor/utils.ts +435 -0
- package/src/editor/views/CompareView.tsx +256 -0
- package/src/editor/views/EditView.tsx +27 -0
- package/src/editor/views/ItemEditor.tsx +58 -0
- package/src/editor/views/SingleEditView.tsx +44 -0
- package/src/fonts/Geist-Black.woff2 +0 -0
- package/src/fonts/Geist-Bold.woff2 +0 -0
- package/src/fonts/Geist-ExtraBold.woff2 +0 -0
- package/src/fonts/Geist-ExtraLight.woff2 +0 -0
- package/src/fonts/Geist-Light.woff2 +0 -0
- package/src/fonts/Geist-Medium.woff2 +0 -0
- package/src/fonts/Geist-Regular.woff2 +0 -0
- package/src/fonts/Geist-SemiBold.woff2 +0 -0
- package/src/fonts/Geist-Thin.woff2 +0 -0
- package/src/fonts/Geist[wght].woff2 +0 -0
- package/src/index.ts +7 -0
- package/src/page-wizard/PageWizard.tsx +163 -0
- package/src/page-wizard/SelectWizard.tsx +109 -0
- package/src/page-wizard/WizardSteps.tsx +207 -0
- package/src/page-wizard/service.ts +35 -0
- package/src/page-wizard/startPageWizardCommand.ts +27 -0
- package/src/page-wizard/steps/BuildPageStep.tsx +266 -0
- package/src/page-wizard/steps/CollectStep.tsx +233 -0
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +443 -0
- package/src/page-wizard/steps/Components.tsx +193 -0
- package/src/page-wizard/steps/CreatePage.tsx +285 -0
- package/src/page-wizard/steps/CreatePageAndLayoutStep.tsx +384 -0
- package/src/page-wizard/steps/EditButton.tsx +34 -0
- package/src/page-wizard/steps/FieldEditor.tsx +102 -0
- package/src/page-wizard/steps/Generate.tsx +32 -0
- package/src/page-wizard/steps/ImagesStep.tsx +318 -0
- package/src/page-wizard/steps/LayoutStep.tsx +228 -0
- package/src/page-wizard/steps/SelectStep.tsx +256 -0
- package/src/page-wizard/steps/schema.ts +180 -0
- package/src/page-wizard/steps/usePageCreator.ts +279 -0
- package/src/splash-screen/NewPage.tsx +232 -0
- package/src/splash-screen/SectionHeadline.tsx +21 -0
- package/src/splash-screen/SplashScreen.tsx +156 -0
- package/src/tour/Tour.tsx +558 -0
- package/src/tour/default-tour.tsx +300 -0
- package/src/tour/preview-tour.tsx +127 -0
- package/src/types.ts +302 -0
- package/styles.css +476 -0
- package/tsconfig.build.json +21 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { Dialog } from "primereact/dialog";
|
|
2
|
+
|
|
3
|
+
import { useEditContext } from "./client/editContext";
|
|
4
|
+
|
|
5
|
+
import { useCallback, useEffect, useState } from "react";
|
|
6
|
+
import { Button } from "primereact/button";
|
|
7
|
+
import DialogButtons from "./ui/DialogButtons";
|
|
8
|
+
|
|
9
|
+
import { getPictureValue } from "./services/editService";
|
|
10
|
+
import {
|
|
11
|
+
PictureField,
|
|
12
|
+
PictureRawValue,
|
|
13
|
+
PictureRawVariant,
|
|
14
|
+
PictureValue,
|
|
15
|
+
} from "./fieldTypes";
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
MediaPictureParams,
|
|
19
|
+
PictureParams,
|
|
20
|
+
getRenderedPictureVariant,
|
|
21
|
+
} from "./picture-shared";
|
|
22
|
+
import { Field } from "./pageModel";
|
|
23
|
+
|
|
24
|
+
export function PictureEditorDialog({
|
|
25
|
+
field,
|
|
26
|
+
onCancel,
|
|
27
|
+
onOk,
|
|
28
|
+
params,
|
|
29
|
+
}: {
|
|
30
|
+
field: PictureField;
|
|
31
|
+
onOk: (link: PictureValue) => void;
|
|
32
|
+
onCancel: () => void;
|
|
33
|
+
params?: PictureParams | MediaPictureParams;
|
|
34
|
+
}) {
|
|
35
|
+
const [selectedVariantName, setSelectedVariantName] = useState<string>();
|
|
36
|
+
const [pictureValue, setPictureValue] = useState<PictureValue>();
|
|
37
|
+
const [rawValue, setRawValue] = useState<PictureRawValue>();
|
|
38
|
+
const emptyRect = () => ({
|
|
39
|
+
width: 0,
|
|
40
|
+
height: 0,
|
|
41
|
+
top: 0,
|
|
42
|
+
left: 0,
|
|
43
|
+
});
|
|
44
|
+
const [rect, setRect] = useState(emptyRect());
|
|
45
|
+
|
|
46
|
+
const editContext = useEditContext();
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
setSelectedVariantName(field?.value?.variants[0].name);
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const deepCopy = JSON.parse(JSON.stringify(field.value));
|
|
53
|
+
setPictureValue(deepCopy);
|
|
54
|
+
const raw = field?.rawValue
|
|
55
|
+
? (JSON.parse(field?.rawValue) as PictureRawValue)
|
|
56
|
+
: ({ Variants: [] } as PictureRawValue);
|
|
57
|
+
setRawValue(raw);
|
|
58
|
+
if (!field?.value?.variants[0].src)
|
|
59
|
+
selectMedia(field?.value?.variants[0].name, raw);
|
|
60
|
+
}, [field]);
|
|
61
|
+
|
|
62
|
+
async function selectMedia(variantName?: string, raw?: PictureRawValue) {
|
|
63
|
+
const chosenImage = await editContext?.selectMedia({
|
|
64
|
+
selectedIdPath: selectedVariant?.idPath || "",
|
|
65
|
+
mode: "images",
|
|
66
|
+
});
|
|
67
|
+
if (chosenImage)
|
|
68
|
+
imageSelected(
|
|
69
|
+
chosenImage,
|
|
70
|
+
variantName ?? selectedVariantName,
|
|
71
|
+
raw ?? rawValue
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const selectedVariant =
|
|
76
|
+
pictureValue && pictureValue.variants
|
|
77
|
+
? pictureValue.variants?.find((x) => x.name == selectedVariantName)
|
|
78
|
+
: null;
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (
|
|
82
|
+
selectedVariant?.region &&
|
|
83
|
+
(!selectedVariant.aspectRatioLock ||
|
|
84
|
+
Math.abs(
|
|
85
|
+
selectedVariant.aspectRatioLock -
|
|
86
|
+
selectedVariant.region.width / selectedVariant.region.height
|
|
87
|
+
) < 0.1)
|
|
88
|
+
)
|
|
89
|
+
setRect({
|
|
90
|
+
width: selectedVariant.region.width,
|
|
91
|
+
height: selectedVariant.region.height,
|
|
92
|
+
top: selectedVariant.region.y,
|
|
93
|
+
left: selectedVariant.region.x,
|
|
94
|
+
});
|
|
95
|
+
else {
|
|
96
|
+
setRect(emptyRect());
|
|
97
|
+
}
|
|
98
|
+
}, [selectedVariantName]);
|
|
99
|
+
|
|
100
|
+
const getPictureFieldValue = async (
|
|
101
|
+
field: Field,
|
|
102
|
+
rawValue: PictureRawValue
|
|
103
|
+
): Promise<PictureValue | null> => {
|
|
104
|
+
if (!editContext?.pageView.site) return null;
|
|
105
|
+
|
|
106
|
+
return getPictureValue(
|
|
107
|
+
field,
|
|
108
|
+
rawValue,
|
|
109
|
+
editContext.pageView.site?.name,
|
|
110
|
+
editContext.sessionId
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const imageSelected = useCallback(
|
|
115
|
+
async (
|
|
116
|
+
imageId: string,
|
|
117
|
+
variantName?: string,
|
|
118
|
+
rawValue?: PictureRawValue
|
|
119
|
+
) => {
|
|
120
|
+
if (!variantName || !rawValue) return;
|
|
121
|
+
|
|
122
|
+
const selected = rawValue.Variants?.find((x) => x.Name == variantName);
|
|
123
|
+
if (!selected) {
|
|
124
|
+
if (!rawValue.Variants) rawValue.Variants = [];
|
|
125
|
+
rawValue.Variants.push({
|
|
126
|
+
Name: variantName,
|
|
127
|
+
MediaId: imageId,
|
|
128
|
+
});
|
|
129
|
+
} else {
|
|
130
|
+
selected.MediaId = imageId;
|
|
131
|
+
}
|
|
132
|
+
setRawValue(rawValue);
|
|
133
|
+
const newValue = await getPictureFieldValue(field, rawValue);
|
|
134
|
+
if (newValue) {
|
|
135
|
+
setPictureValue(newValue);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
[]
|
|
139
|
+
);
|
|
140
|
+
const updateRawValue = async (rawValue: PictureRawValue) => {
|
|
141
|
+
setRawValue(rawValue);
|
|
142
|
+
const newValue = await getPictureFieldValue(field, rawValue);
|
|
143
|
+
if (newValue) {
|
|
144
|
+
setPictureValue(newValue);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const setVariantCrop = async () => {
|
|
149
|
+
if (!rawValue) return;
|
|
150
|
+
if (!selectedVariantName) return;
|
|
151
|
+
|
|
152
|
+
if (selectedVariant) {
|
|
153
|
+
let selected = rawValue.Variants?.find(
|
|
154
|
+
(x: PictureRawVariant) => x.Name == selectedVariantName
|
|
155
|
+
);
|
|
156
|
+
if (!selected) {
|
|
157
|
+
selected = {
|
|
158
|
+
Name: selectedVariantName,
|
|
159
|
+
MediaId: selectedVariant.mediaId!,
|
|
160
|
+
};
|
|
161
|
+
rawValue.Variants?.push(selected);
|
|
162
|
+
}
|
|
163
|
+
if (selected) {
|
|
164
|
+
selected.Region = {
|
|
165
|
+
X: rect.left,
|
|
166
|
+
Y: rect.top,
|
|
167
|
+
Width: rect.width,
|
|
168
|
+
Height: rect.height,
|
|
169
|
+
};
|
|
170
|
+
await updateRawValue(rawValue);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const usage = getUsage(pictureValue, params);
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<>
|
|
179
|
+
<Dialog
|
|
180
|
+
header={"Edit " + field.name}
|
|
181
|
+
visible={true}
|
|
182
|
+
style={{ width: "70vw", height: "70vh" }}
|
|
183
|
+
onHide={onCancel}
|
|
184
|
+
>
|
|
185
|
+
<div className="flex gap-1 flex-col justify h-full">
|
|
186
|
+
<div className="flex-1 flex gap-2">
|
|
187
|
+
<div className=" h-full border-r pt-3 w-48 relative">
|
|
188
|
+
<div className="absolute inset-0 overflow-y-auto flex flex-col gap-6">
|
|
189
|
+
{pictureValue &&
|
|
190
|
+
pictureValue.variants?.map((variant) => (
|
|
191
|
+
<div
|
|
192
|
+
key={variant.name}
|
|
193
|
+
onClick={() => setSelectedVariantName(variant.name)}
|
|
194
|
+
className="text-xs flex flex-col items-center justify-center gap-1 cursor-pointer"
|
|
195
|
+
>
|
|
196
|
+
<div
|
|
197
|
+
className={
|
|
198
|
+
"flex justify-center items-center h-40 w-40 border relative" +
|
|
199
|
+
(selectedVariantName == variant.name
|
|
200
|
+
? " shadow-xl "
|
|
201
|
+
: "")
|
|
202
|
+
}
|
|
203
|
+
>
|
|
204
|
+
{variant.src && <img src={variant.thumbSrc} />}
|
|
205
|
+
</div>
|
|
206
|
+
<div className="w-40">
|
|
207
|
+
<div>{variant.name}</div>
|
|
208
|
+
<div>{variant.aspectRatioLockText}</div>
|
|
209
|
+
<div>
|
|
210
|
+
<div className="break-all">
|
|
211
|
+
Name: {variant.mediaItemName}
|
|
212
|
+
</div>
|
|
213
|
+
<div>
|
|
214
|
+
Orig. size: {variant.width} x {variant.height}
|
|
215
|
+
</div>
|
|
216
|
+
{(variant.width < 1 || variant.height < 1) && (
|
|
217
|
+
<span>
|
|
218
|
+
{" "}
|
|
219
|
+
<i className="pi pi-exclamation-triangle text-red-600 "></i>
|
|
220
|
+
</span>
|
|
221
|
+
)}
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
))}
|
|
226
|
+
</div>
|
|
227
|
+
{usage && <div className="text-xs">{usage}</div>}
|
|
228
|
+
</div>
|
|
229
|
+
<div className="flex-1 relative p-3">
|
|
230
|
+
<div className="absolute inset-0 top-3 overflow-auto select-none flex align-center justify-center">
|
|
231
|
+
{selectedVariant && (
|
|
232
|
+
<div
|
|
233
|
+
className="relative"
|
|
234
|
+
onDoubleClick={() => selectMedia()}
|
|
235
|
+
onMouseDown={(ev) => {
|
|
236
|
+
ev.preventDefault();
|
|
237
|
+
ev.stopPropagation();
|
|
238
|
+
const bounds = ev.currentTarget.getBoundingClientRect();
|
|
239
|
+
|
|
240
|
+
setRect({
|
|
241
|
+
left: (ev.clientX - bounds.left) / bounds.width,
|
|
242
|
+
top: (ev.clientY - bounds.top) / bounds.height,
|
|
243
|
+
width: 0,
|
|
244
|
+
height: 0,
|
|
245
|
+
});
|
|
246
|
+
}}
|
|
247
|
+
onMouseMoveCapture={(ev) => {
|
|
248
|
+
if (ev.buttons === 1) {
|
|
249
|
+
const bounds = ev.currentTarget.getBoundingClientRect();
|
|
250
|
+
|
|
251
|
+
const width =
|
|
252
|
+
(ev.clientX - bounds.left) / bounds.width - rect.left;
|
|
253
|
+
|
|
254
|
+
const newRect = {
|
|
255
|
+
...rect,
|
|
256
|
+
width,
|
|
257
|
+
height: selectedVariant.aspectRatioLock
|
|
258
|
+
? width / selectedVariant.aspectRatioLock
|
|
259
|
+
: (ev.clientY - bounds.top) / bounds.height -
|
|
260
|
+
rect.top,
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
setRect(newRect);
|
|
264
|
+
ev.preventDefault();
|
|
265
|
+
ev.stopPropagation();
|
|
266
|
+
}
|
|
267
|
+
}}
|
|
268
|
+
onMouseUp={() => setVariantCrop()}
|
|
269
|
+
>
|
|
270
|
+
<img
|
|
271
|
+
src={selectedVariant.originalSrc ?? selectedVariant.src}
|
|
272
|
+
className="object-contain h-full w-full"
|
|
273
|
+
/>
|
|
274
|
+
<div
|
|
275
|
+
className="absolute bg-opacity-70 bg-gray-300"
|
|
276
|
+
style={{
|
|
277
|
+
left: rect.left * 100 + "%",
|
|
278
|
+
top: rect.top * 100 + "%",
|
|
279
|
+
width: rect.width * 100 + "%",
|
|
280
|
+
height: rect.height * 100 + "%",
|
|
281
|
+
}}
|
|
282
|
+
/>
|
|
283
|
+
</div>
|
|
284
|
+
)}
|
|
285
|
+
{selectedVariant && (
|
|
286
|
+
<div
|
|
287
|
+
className="absolute top-0 right-0 cursor-pointer text-sm flex flex-col gap-1 items-center p-2 bg-gray-100 bg-opacity-70"
|
|
288
|
+
onClick={() => selectMedia()}
|
|
289
|
+
>
|
|
290
|
+
<i className="pi pi-pencil text-xl"></i>
|
|
291
|
+
Choose
|
|
292
|
+
</div>
|
|
293
|
+
)}
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
</div>
|
|
297
|
+
<DialogButtons>
|
|
298
|
+
<Button
|
|
299
|
+
size="small"
|
|
300
|
+
onClick={() => {
|
|
301
|
+
if (pictureValue) {
|
|
302
|
+
if (field) {
|
|
303
|
+
editContext?.operations.editField({
|
|
304
|
+
field: field.descriptor,
|
|
305
|
+
rawValue: JSON.stringify(rawValue),
|
|
306
|
+
refresh: "immediate",
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
onOk(pictureValue);
|
|
310
|
+
}
|
|
311
|
+
}}
|
|
312
|
+
>
|
|
313
|
+
Ok
|
|
314
|
+
</Button>
|
|
315
|
+
<Button
|
|
316
|
+
onClick={() => {
|
|
317
|
+
onCancel();
|
|
318
|
+
}}
|
|
319
|
+
size="small"
|
|
320
|
+
>
|
|
321
|
+
Cancel
|
|
322
|
+
</Button>
|
|
323
|
+
</DialogButtons>
|
|
324
|
+
</div>
|
|
325
|
+
</Dialog>
|
|
326
|
+
</>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
function getUsage(
|
|
330
|
+
pictureValue: PictureValue | undefined,
|
|
331
|
+
params: PictureParams | MediaPictureParams | undefined
|
|
332
|
+
) {
|
|
333
|
+
if (!params) return;
|
|
334
|
+
if (!pictureValue) return;
|
|
335
|
+
if (pictureValue.variants.length <= 1) return;
|
|
336
|
+
const mediaParams =
|
|
337
|
+
typeof params === "object" && "default" in params ? params : undefined;
|
|
338
|
+
|
|
339
|
+
if (mediaParams) {
|
|
340
|
+
const sources = Object.keys(mediaParams ?? {});
|
|
341
|
+
const variants = sources
|
|
342
|
+
.map((source) => ({
|
|
343
|
+
source,
|
|
344
|
+
variant: getRenderedPictureVariant(
|
|
345
|
+
mediaParams[source],
|
|
346
|
+
pictureValue.variants
|
|
347
|
+
),
|
|
348
|
+
}))
|
|
349
|
+
.filter((x) => x.variant);
|
|
350
|
+
|
|
351
|
+
return (
|
|
352
|
+
<>
|
|
353
|
+
This field rendering is using these variants:
|
|
354
|
+
<table>
|
|
355
|
+
{variants.map((v) => (
|
|
356
|
+
<tr>
|
|
357
|
+
<td>{v.source}</td>
|
|
358
|
+
<td>
|
|
359
|
+
<b>{v.variant.name}</b>
|
|
360
|
+
</td>
|
|
361
|
+
</tr>
|
|
362
|
+
))}
|
|
363
|
+
</table>
|
|
364
|
+
</>
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
return (
|
|
368
|
+
<>
|
|
369
|
+
This field rendering is using the variant{" "}
|
|
370
|
+
<b>
|
|
371
|
+
{
|
|
372
|
+
getRenderedPictureVariant(
|
|
373
|
+
params as PictureParams,
|
|
374
|
+
pictureValue.variants
|
|
375
|
+
)?.name
|
|
376
|
+
}
|
|
377
|
+
.
|
|
378
|
+
</b>
|
|
379
|
+
</>
|
|
380
|
+
);
|
|
381
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Dialog } from "primereact/dialog";
|
|
2
|
+
|
|
3
|
+
import { Workbox as WorkboxWidget } from "./sidebar/Workbox";
|
|
4
|
+
|
|
5
|
+
import DialogButtons from "./DialogButtons";
|
|
6
|
+
import { Button } from "primereact/button";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function PublishDialog({
|
|
10
|
+
// lockItems,
|
|
11
|
+
// unlockItems,
|
|
12
|
+
|
|
13
|
+
visible,
|
|
14
|
+
onHide,
|
|
15
|
+
page,
|
|
16
|
+
}: {
|
|
17
|
+
// lockItems: (item: ItemDescriptor[]) => void;
|
|
18
|
+
// unlockItems: (item: ItemDescriptor[]) => void;
|
|
19
|
+
executeWorkflowCommand: (item: ItemDescriptor, commandId: string) => void;
|
|
20
|
+
visible: boolean;
|
|
21
|
+
onHide: () => void;
|
|
22
|
+
page: Page;
|
|
23
|
+
}) {
|
|
24
|
+
const allUnlocked =
|
|
25
|
+
page._editor!.workbox.items.filter((x) => x.hasLock).length > 0;
|
|
26
|
+
const allInFinalState =
|
|
27
|
+
page._editor!.workbox.items.filter((x) => !x.isFinalState).length > 0;
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<Dialog
|
|
31
|
+
header={"Publish page " + page.name}
|
|
32
|
+
style={{ width: "70vw", height: "70vh" }}
|
|
33
|
+
onHide={onHide}
|
|
34
|
+
visible={visible}
|
|
35
|
+
>
|
|
36
|
+
<div className="a-w-full a-h-full a-flex a-flex-col">
|
|
37
|
+
<WorkboxWidget />
|
|
38
|
+
|
|
39
|
+
<DialogButtons>
|
|
40
|
+
{/* {allUnlocked && (
|
|
41
|
+
<Button
|
|
42
|
+
onClick={() => {
|
|
43
|
+
unlockItems(
|
|
44
|
+
page.workbox.items
|
|
45
|
+
.filter((x) => x.hasLock)
|
|
46
|
+
.map((x) => x.item)
|
|
47
|
+
);
|
|
48
|
+
}}
|
|
49
|
+
size="small"
|
|
50
|
+
>
|
|
51
|
+
Unlock all
|
|
52
|
+
</Button>
|
|
53
|
+
)} */}
|
|
54
|
+
{allInFinalState && (
|
|
55
|
+
<Button size="small" onClick={() => {}}>
|
|
56
|
+
Publish
|
|
57
|
+
</Button>
|
|
58
|
+
)}
|
|
59
|
+
{!(allInFinalState || !allUnlocked) && (
|
|
60
|
+
<Button
|
|
61
|
+
onClick={() => {
|
|
62
|
+
onHide();
|
|
63
|
+
}}
|
|
64
|
+
size="small"
|
|
65
|
+
>
|
|
66
|
+
Cancel
|
|
67
|
+
</Button>
|
|
68
|
+
)}
|
|
69
|
+
</DialogButtons>
|
|
70
|
+
</div>
|
|
71
|
+
</Dialog>
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { ItemTreeNodeData } from "./services/contentService";
|
|
3
|
+
|
|
4
|
+
import ContentTree from "./ContentTree";
|
|
5
|
+
import { FullItem } from "./pageModel";
|
|
6
|
+
import { contentItemId } from "../config/config";
|
|
7
|
+
import { useEditContext } from "./client/editContext";
|
|
8
|
+
|
|
9
|
+
export function ScrollingContentTree({
|
|
10
|
+
selectedItemId,
|
|
11
|
+
onSelectionChange,
|
|
12
|
+
rootItemId,
|
|
13
|
+
}: {
|
|
14
|
+
selectedItemId?: string;
|
|
15
|
+
onSelectionChange?: (itemIds: ItemTreeNodeData[]) => void;
|
|
16
|
+
rootItemId?: string;
|
|
17
|
+
}) {
|
|
18
|
+
const [selectedItem, setSelectdItem] = useState<FullItem | null>(null);
|
|
19
|
+
const editContext = useEditContext();
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const loadItem = async () => {
|
|
23
|
+
if (!selectedItemId) return;
|
|
24
|
+
const item = await editContext!.itemsRepository.getItem({
|
|
25
|
+
id: selectedItemId,
|
|
26
|
+
language: editContext!.currentItemDescriptor?.language ?? "en",
|
|
27
|
+
version: 0,
|
|
28
|
+
});
|
|
29
|
+
if (item) setSelectdItem(item);
|
|
30
|
+
};
|
|
31
|
+
loadItem();
|
|
32
|
+
}, [selectedItemId]);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="absolute inset-0 overflow-auto">
|
|
36
|
+
<ContentTree
|
|
37
|
+
language={editContext!.currentItemDescriptor?.language ?? "en"}
|
|
38
|
+
rootItemId={rootItemId ?? contentItemId}
|
|
39
|
+
expandIdPath={selectedItem?.idPath}
|
|
40
|
+
selectedItemIds={selectedItemId ? [selectedItemId] : []}
|
|
41
|
+
selectionMode="single"
|
|
42
|
+
className="h-full p-1"
|
|
43
|
+
onSelectionChange={onSelectionChange}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|