@alpaca-editor/core 1.0.3939 → 1.0.3941
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/components/ActionButton.d.ts +1 -0
- package/dist/components/ActionButton.js +2 -2
- package/dist/components/ActionButton.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.d.ts +1 -0
- package/dist/editor/FieldActionsOverlay.js +2 -11
- package/dist/editor/FieldActionsOverlay.js.map +1 -1
- package/dist/editor/PictureCropper.js +65 -23
- package/dist/editor/PictureCropper.js.map +1 -1
- package/dist/editor/PictureEditor.js +16 -2
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/Titlebar.js +1 -1
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/GhostWriter.js +21 -2
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/commands/componentCommands.js +7 -3
- package/dist/editor/commands/componentCommands.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.d.ts +5 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js +77 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -0
- package/dist/editor/media-selector/MediaSelector.js +1 -1
- package/dist/editor/media-selector/MediaSelector.js.map +1 -1
- package/dist/editor/media-selector/Thumbnails.js +2 -2
- package/dist/editor/media-selector/index.d.ts +8 -0
- package/dist/editor/media-selector/index.js +9 -0
- package/dist/editor/media-selector/index.js.map +1 -0
- package/dist/editor/menubar/BrowseHistory.js +1 -1
- package/dist/editor/menubar/PageSelector.js +39 -15
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js +37 -11
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
- package/dist/editor/reviews/Comment.js +1 -1
- package/dist/editor/reviews/Comment.js.map +1 -1
- package/dist/editor/services/aiService.js +0 -1
- package/dist/editor/services/aiService.js.map +1 -1
- package/dist/editor/sidebar/ComponentTree.js +3 -4
- package/dist/editor/sidebar/ComponentTree.js.map +1 -1
- package/dist/editor/ui/SimpleTabs.d.ts +1 -0
- package/dist/editor/ui/SimpleTabs.js +3 -3
- package/dist/editor/ui/SimpleTabs.js.map +1 -1
- package/dist/editor/ui/Splitter.js +61 -6
- package/dist/editor/ui/Splitter.js.map +1 -1
- package/dist/editor/views/MediaFolderEditView.d.ts +4 -0
- package/dist/editor/views/MediaFolderEditView.js +40 -0
- package/dist/editor/views/MediaFolderEditView.js.map +1 -0
- package/dist/editor/views/SingleEditView.js +9 -1
- package/dist/editor/views/SingleEditView.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +61 -5
- package/package.json +8 -2
- package/.prettierrc +0 -3
- package/build.css +0 -3
- package/components.json +0 -21
- package/eslint.config.mjs +0 -4
- package/images/bg-shape-black.webp +0 -0
- package/images/wizard-bg.png +0 -0
- package/images/wizard-tour.png +0 -0
- package/images/wizard.png +0 -0
- package/src/client-components/api.ts +0 -6
- package/src/client-components/index.ts +0 -19
- package/src/components/ActionButton.tsx +0 -41
- package/src/components/Error.tsx +0 -57
- package/src/components/ui/CardConnector.tsx +0 -56
- package/src/components/ui/button.tsx +0 -62
- package/src/components/ui/card.tsx +0 -372
- package/src/components/ui/context-menu.tsx +0 -250
- package/src/config/config.tsx +0 -917
- package/src/config/types.ts +0 -286
- package/src/editor/ComponentInfo.tsx +0 -90
- package/src/editor/ConfirmationDialog.tsx +0 -103
- package/src/editor/ContentTree.tsx +0 -730
- package/src/editor/ContextMenu.tsx +0 -230
- package/src/editor/Editor.tsx +0 -90
- package/src/editor/EditorWarning.tsx +0 -34
- package/src/editor/EditorWarnings.tsx +0 -33
- package/src/editor/FieldActionsOverlay.tsx +0 -307
- package/src/editor/FieldEditorPopup.tsx +0 -65
- package/src/editor/FieldHistory.tsx +0 -75
- package/src/editor/FieldList.tsx +0 -190
- package/src/editor/FieldListField.tsx +0 -391
- package/src/editor/FieldListFieldWithFallbacks.tsx +0 -217
- package/src/editor/FloatingToolbar.tsx +0 -163
- package/src/editor/ImageEditor.tsx +0 -128
- package/src/editor/ItemInfo.tsx +0 -90
- package/src/editor/LinkEditorDialog.tsx +0 -196
- package/src/editor/MainLayout.tsx +0 -95
- package/src/editor/MobileLayout.tsx +0 -68
- package/src/editor/NewEditorClient.tsx +0 -11
- package/src/editor/PictureCropper.tsx +0 -503
- package/src/editor/PictureEditor.tsx +0 -277
- package/src/editor/PictureEditorDialog.tsx +0 -381
- package/src/editor/PublishDialog.ignore +0 -74
- package/src/editor/ScrollingContentTree.tsx +0 -67
- package/src/editor/Terminal.tsx +0 -227
- package/src/editor/Titlebar.tsx +0 -104
- package/src/editor/ai/AiPopup.tsx +0 -59
- package/src/editor/ai/AiResponseMessage.tsx +0 -106
- package/src/editor/ai/AiTerminal.tsx +0 -503
- package/src/editor/ai/AiToolCall.tsx +0 -61
- package/src/editor/ai/EditorAiTerminal.tsx +0 -20
- package/src/editor/ai/GhostWriter.tsx +0 -432
- package/src/editor/ai/aiPageModel.ts +0 -108
- package/src/editor/ai/editorAiContext.ts +0 -18
- package/src/editor/client/AboutDialog.tsx +0 -44
- package/src/editor/client/EditorClient.tsx +0 -2241
- package/src/editor/client/GenericDialog.tsx +0 -50
- package/src/editor/client/editContext.ts +0 -416
- package/src/editor/client/helpers.ts +0 -44
- package/src/editor/client/itemsRepository.ts +0 -574
- package/src/editor/client/operations.ts +0 -768
- package/src/editor/client/pageModelBuilder.ts +0 -219
- package/src/editor/commands/commands.ts +0 -22
- package/src/editor/commands/componentCommands.tsx +0 -424
- package/src/editor/commands/createVersionCommand.ts +0 -33
- package/src/editor/commands/deleteVersionCommand.ts +0 -71
- package/src/editor/commands/itemCommands.tsx +0 -351
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +0 -201
- package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +0 -27
- package/src/editor/commands/undo.ts +0 -39
- package/src/editor/component-designer/ComponentDesigner.tsx +0 -70
- package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +0 -11
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +0 -91
- package/src/editor/component-designer/ComponentEditor.tsx +0 -97
- package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +0 -31
- package/src/editor/component-designer/ComponentRenderingEditor.tsx +0 -104
- package/src/editor/component-designer/ComponentsDropdown.tsx +0 -39
- package/src/editor/component-designer/PlaceholdersEditor.tsx +0 -179
- package/src/editor/component-designer/RenderingsDropdown.tsx +0 -36
- package/src/editor/component-designer/TemplateEditor.tsx +0 -236
- package/src/editor/component-designer/aiContext.ts +0 -23
- package/src/editor/componentTreeHelper.tsx +0 -116
- package/src/editor/context-menu/CopyMoveMenu.tsx +0 -103
- package/src/editor/context-menu/InsertMenu.tsx +0 -347
- package/src/editor/control-center/About.tsx +0 -342
- package/src/editor/control-center/ControlCenterMenu.tsx +0 -76
- package/src/editor/control-center/IndexOverview.tsx +0 -50
- package/src/editor/control-center/IndexSettings.tsx +0 -266
- package/src/editor/control-center/Info.tsx +0 -104
- package/src/editor/control-center/QuotaInfo.tsx +0 -301
- package/src/editor/control-center/Status.tsx +0 -113
- package/src/editor/control-center/WebSocketMessages.tsx +0 -155
- package/src/editor/editor-warnings/ItemLocked.tsx +0 -63
- package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +0 -22
- package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +0 -23
- package/src/editor/editor-warnings/NoWriteAccess.tsx +0 -16
- package/src/editor/editor-warnings/ValidationErrors.tsx +0 -54
- package/src/editor/field-types/AttachmentEditor.tsx +0 -9
- package/src/editor/field-types/CheckboxEditor.tsx +0 -47
- package/src/editor/field-types/DropLinkEditor.tsx +0 -80
- package/src/editor/field-types/DropListEditor.tsx +0 -84
- package/src/editor/field-types/ImageFieldEditor.tsx +0 -65
- package/src/editor/field-types/InternalLinkFieldEditor.tsx +0 -117
- package/src/editor/field-types/LinkFieldEditor.tsx +0 -85
- package/src/editor/field-types/MultiLineText.tsx +0 -82
- package/src/editor/field-types/PictureFieldEditor.tsx +0 -121
- package/src/editor/field-types/RawEditor.tsx +0 -53
- package/src/editor/field-types/ReactQuill.tsx +0 -580
- package/src/editor/field-types/RichTextEditor.tsx +0 -22
- package/src/editor/field-types/RichTextEditorComponent.tsx +0 -127
- package/src/editor/field-types/SingleLineText.tsx +0 -174
- package/src/editor/field-types/TreeListEditor.tsx +0 -261
- package/src/editor/fieldTypes.ts +0 -140
- package/src/editor/media-selector/AiImageSearch.tsx +0 -185
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +0 -94
- package/src/editor/media-selector/MediaSelector.tsx +0 -42
- package/src/editor/media-selector/Preview.tsx +0 -14
- package/src/editor/media-selector/Thumbnails.tsx +0 -48
- package/src/editor/media-selector/TreeSelector.tsx +0 -292
- package/src/editor/media-selector/UploadZone.tsx +0 -137
- package/src/editor/menubar/ActionsMenu.tsx +0 -94
- package/src/editor/menubar/ActiveUsers.tsx +0 -17
- package/src/editor/menubar/ApproveAndPublish.tsx +0 -18
- package/src/editor/menubar/BrowseHistory.tsx +0 -28
- package/src/editor/menubar/ItemLanguageVersion.tsx +0 -76
- package/src/editor/menubar/LanguageSelector.tsx +0 -226
- package/src/editor/menubar/Menu.tsx +0 -83
- package/src/editor/menubar/NavButtons.tsx +0 -74
- package/src/editor/menubar/PageSelector.tsx +0 -166
- package/src/editor/menubar/PageViewerControls.tsx +0 -120
- package/src/editor/menubar/PreviewSecondaryControls.tsx +0 -18
- package/src/editor/menubar/SecondaryControls.tsx +0 -45
- package/src/editor/menubar/Separator.tsx +0 -12
- package/src/editor/menubar/SiteInfo.tsx +0 -53
- package/src/editor/menubar/User.tsx +0 -27
- package/src/editor/menubar/VersionSelector.tsx +0 -142
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +0 -307
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +0 -35
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +0 -59
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +0 -23
- package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +0 -64
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +0 -35
- package/src/editor/page-editor-chrome/FrameMenu.tsx +0 -338
- package/src/editor/page-editor-chrome/FrameMenus.tsx +0 -48
- package/src/editor/page-editor-chrome/InlineEditor.tsx +0 -765
- package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +0 -61
- package/src/editor/page-editor-chrome/NoLayout.tsx +0 -36
- package/src/editor/page-editor-chrome/PageEditorChrome.tsx +0 -122
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +0 -161
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +0 -169
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +0 -315
- package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +0 -300
- package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +0 -40
- package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +0 -791
- package/src/editor/page-viewer/DeviceToolbar.tsx +0 -70
- package/src/editor/page-viewer/EditorForm.tsx +0 -258
- package/src/editor/page-viewer/MiniMap.tsx +0 -362
- package/src/editor/page-viewer/PageViewer.tsx +0 -169
- package/src/editor/page-viewer/PageViewerFrame.tsx +0 -1022
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
- package/src/editor/page-viewer/pageViewContext.ts +0 -186
- package/src/editor/pageModel.ts +0 -220
- package/src/editor/picture-shared.tsx +0 -53
- package/src/editor/reviews/Comment.tsx +0 -307
- package/src/editor/reviews/Comments.tsx +0 -125
- package/src/editor/reviews/DiffView.tsx +0 -109
- package/src/editor/reviews/PreviewInfo.tsx +0 -35
- package/src/editor/reviews/Reviews.tsx +0 -280
- package/src/editor/reviews/SuggestedEdit.tsx +0 -316
- package/src/editor/reviews/reviewCommands.tsx +0 -47
- package/src/editor/reviews/useReviews.tsx +0 -70
- package/src/editor/services/aiService.ts +0 -174
- package/src/editor/services/componentDesignerService.ts +0 -151
- package/src/editor/services/contentService.ts +0 -180
- package/src/editor/services/editService.ts +0 -488
- package/src/editor/services/indexService.ts +0 -24
- package/src/editor/services/reviewsService.ts +0 -53
- package/src/editor/services/serviceHelper.ts +0 -95
- package/src/editor/services/suggestedEditsService.ts +0 -39
- package/src/editor/services/systemService.ts +0 -5
- package/src/editor/services/translationService.ts +0 -21
- package/src/editor/services-server/api.ts +0 -150
- package/src/editor/services-server/graphQL.ts +0 -106
- package/src/editor/sidebar/ComponentPalette.tsx +0 -161
- package/src/editor/sidebar/ComponentTree.tsx +0 -548
- package/src/editor/sidebar/ComponentTree2.tsxx +0 -490
- package/src/editor/sidebar/Debug.tsx +0 -111
- package/src/editor/sidebar/DictionaryEditor.tsx +0 -261
- package/src/editor/sidebar/EditHistory.tsx +0 -134
- package/src/editor/sidebar/GraphQL.tsx +0 -164
- package/src/editor/sidebar/Insert.tsx +0 -35
- package/src/editor/sidebar/MainContentTree.tsx +0 -102
- package/src/editor/sidebar/Performance.tsx +0 -53
- package/src/editor/sidebar/Sessions.tsx +0 -35
- package/src/editor/sidebar/Sidebar.tsx +0 -20
- package/src/editor/sidebar/SidebarView.tsx +0 -152
- package/src/editor/sidebar/Translations.tsx +0 -295
- package/src/editor/sidebar/Validation.tsx +0 -102
- package/src/editor/sidebar/ViewSelector.tsx +0 -60
- package/src/editor/sidebar/Workbox.tsx +0 -209
- package/src/editor/ui/CenteredMessage.tsx +0 -7
- package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +0 -81
- package/src/editor/ui/CopyToClipboardButton.tsx +0 -24
- package/src/editor/ui/DialogButtons.tsx +0 -11
- package/src/editor/ui/Icons.tsx +0 -709
- package/src/editor/ui/ItemList.tsx +0 -76
- package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
- package/src/editor/ui/ItemSearch.tsx +0 -153
- package/src/editor/ui/PerfectTree.tsx +0 -571
- package/src/editor/ui/Section.tsx +0 -35
- package/src/editor/ui/SimpleIconButton.tsx +0 -54
- package/src/editor/ui/SimpleMenu.tsx +0 -40
- package/src/editor/ui/SimpleTable.tsx +0 -60
- package/src/editor/ui/SimpleTabs.tsx +0 -55
- package/src/editor/ui/SimpleToolbar.tsx +0 -7
- package/src/editor/ui/Spinner.tsx +0 -9
- package/src/editor/ui/Splitter.tsx +0 -314
- package/src/editor/ui/StackedPanels.tsx +0 -134
- package/src/editor/ui/Toolbar.tsx +0 -7
- package/src/editor/utils/id-helper.ts +0 -3
- package/src/editor/utils/insertOptions.ts +0 -69
- package/src/editor/utils/itemutils.ts +0 -29
- package/src/editor/utils/useMemoDebug.ts +0 -28
- package/src/editor/utils.ts +0 -486
- package/src/editor/views/CompareView.tsx +0 -245
- package/src/editor/views/EditView.tsx +0 -27
- package/src/editor/views/ItemEditor.tsx +0 -58
- package/src/editor/views/SingleEditView.tsx +0 -46
- 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/fonts/index.ts +0 -10
- package/src/index.ts +0 -23
- package/src/lib/safelist.tsx +0 -16
- package/src/lib/utils.ts +0 -6
- package/src/page-wizard/PageWizard.tsx +0 -139
- package/src/page-wizard/WizardBox.tsx +0 -4
- package/src/page-wizard/WizardBoxConnector.tsx +0 -56
- package/src/page-wizard/WizardSteps.tsx +0 -458
- package/src/page-wizard/service.ts +0 -35
- package/src/page-wizard/startPageWizardCommand.ts +0 -26
- package/src/page-wizard/steps/BuildPageStep.tsx +0 -259
- package/src/page-wizard/steps/CollectStep.tsx +0 -296
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +0 -454
- package/src/page-wizard/steps/Components.tsx +0 -193
- package/src/page-wizard/steps/ContentStep.tsx +0 -890
- package/src/page-wizard/steps/EditButton.tsx +0 -34
- package/src/page-wizard/steps/FieldEditor.tsx +0 -102
- package/src/page-wizard/steps/Generate.tsx +0 -60
- package/src/page-wizard/steps/ImagesStep.tsx +0 -382
- package/src/page-wizard/steps/LayoutStep.tsx +0 -227
- package/src/page-wizard/steps/MetaDataStep.tsx +0 -173
- package/src/page-wizard/steps/SelectStep.tsx +0 -281
- package/src/page-wizard/steps/schema.ts +0 -180
- package/src/page-wizard/steps/usePageCreator.ts +0 -325
- package/src/page-wizard/usePageWizard.ts +0 -79
- package/src/revision.ts +0 -2
- package/src/splash-screen/NewPage.tsx +0 -294
- package/src/splash-screen/OpenPage.tsx +0 -113
- package/src/splash-screen/RecentPages.tsx +0 -123
- package/src/splash-screen/SectionHeadline.tsx +0 -21
- package/src/splash-screen/SplashScreen.tsx +0 -195
- package/src/tour/Tour.tsx +0 -566
- package/src/tour/default-tour.tsx +0 -301
- package/src/tour/preview-tour.tsx +0 -128
- package/src/types.ts +0 -335
- package/styles.css +0 -765
- package/tsconfig.build.json +0 -31
- package/tsconfig.json +0 -14
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MouseEventHandler,
|
|
3
|
-
useCallback,
|
|
4
|
-
useEffect,
|
|
5
|
-
useRef,
|
|
6
|
-
useState,
|
|
7
|
-
} from "react";
|
|
8
|
-
import { useEditContext } from "./client/editContext";
|
|
9
|
-
import { PictureCropper } from "./PictureCropper";
|
|
10
|
-
import { PictureField, PictureRawValue } from "./fieldTypes";
|
|
11
|
-
import { MediaSelectorMode } from "./media-selector/MediaSelector";
|
|
12
|
-
import { loadFieldButtons } from "./services/editService";
|
|
13
|
-
import { FieldButton } from "./pageModel";
|
|
14
|
-
import {
|
|
15
|
-
FieldActionsOverlay,
|
|
16
|
-
FieldActionsOverlayRef,
|
|
17
|
-
} from "./FieldActionsOverlay";
|
|
18
|
-
|
|
19
|
-
export function PictureEditor({
|
|
20
|
-
field,
|
|
21
|
-
variantName,
|
|
22
|
-
style,
|
|
23
|
-
forwardScrollevents,
|
|
24
|
-
isPageEditor,
|
|
25
|
-
}: {
|
|
26
|
-
field: PictureField;
|
|
27
|
-
variantName: string;
|
|
28
|
-
style?: React.CSSProperties;
|
|
29
|
-
forwardScrollevents?: boolean;
|
|
30
|
-
isPageEditor?: boolean;
|
|
31
|
-
}) {
|
|
32
|
-
const [showMenu, setShowMenu] = useState(false);
|
|
33
|
-
const [showCropper, setShowCropper] = useState(false);
|
|
34
|
-
const [fieldButtons, setFieldButtons] = useState<FieldButton[]>([]);
|
|
35
|
-
const fieldActionsOverlay = useRef<FieldActionsOverlayRef>(null);
|
|
36
|
-
const editContext = useEditContext();
|
|
37
|
-
|
|
38
|
-
// Load field buttons when component mounts
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
const loadButtons = async () => {
|
|
41
|
-
if (field.descriptor) {
|
|
42
|
-
try {
|
|
43
|
-
const buttons = await loadFieldButtons(field.descriptor);
|
|
44
|
-
setFieldButtons(buttons);
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.warn("Failed to load field buttons:", error);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
loadButtons();
|
|
51
|
-
}, [field.descriptor]);
|
|
52
|
-
|
|
53
|
-
// Field action handlers
|
|
54
|
-
const handleActionClick = useCallback(
|
|
55
|
-
async (action: FieldButton): Promise<void> => {
|
|
56
|
-
editContext?.triggerFieldAction(field.descriptor, action);
|
|
57
|
-
},
|
|
58
|
-
[editContext, field.descriptor],
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const handleParameterizedActionExecute = useCallback(
|
|
62
|
-
async (
|
|
63
|
-
action: FieldButton,
|
|
64
|
-
parameters: Record<string, string>,
|
|
65
|
-
): Promise<void> => {
|
|
66
|
-
editContext?.triggerFieldAction(field.descriptor, action, parameters);
|
|
67
|
-
},
|
|
68
|
-
[editContext, field.descriptor],
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const variant = field.value?.variants?.find((v) => v.name === variantName);
|
|
72
|
-
const raw = (() => {
|
|
73
|
-
try {
|
|
74
|
-
return field?.rawValue && field?.rawValue[0] === "{"
|
|
75
|
-
? (JSON.parse(field?.rawValue) as PictureRawValue)
|
|
76
|
-
: ({ Variants: [] } as PictureRawValue);
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.warn("Failed to parse picture field raw value:", error);
|
|
79
|
-
return { Variants: [] } as PictureRawValue;
|
|
80
|
-
}
|
|
81
|
-
})();
|
|
82
|
-
|
|
83
|
-
const rawVariant = raw.Variants?.find((x) => x.Name == variantName);
|
|
84
|
-
|
|
85
|
-
const reset = useCallback(() => {
|
|
86
|
-
raw.Variants = raw.Variants.filter((x) => x.Name !== variantName);
|
|
87
|
-
editContext!.operations.editField({
|
|
88
|
-
field: field.descriptor,
|
|
89
|
-
rawValue: JSON.stringify(raw),
|
|
90
|
-
refresh: "immediate",
|
|
91
|
-
});
|
|
92
|
-
}, [field, variant]);
|
|
93
|
-
|
|
94
|
-
const imageSelected = useCallback(
|
|
95
|
-
async (imageId: string) => {
|
|
96
|
-
const selected = raw.Variants?.find((x) => x.Name == variantName);
|
|
97
|
-
if (!selected) {
|
|
98
|
-
if (!raw.Variants) raw.Variants = [];
|
|
99
|
-
raw.Variants.push({
|
|
100
|
-
Name: variantName,
|
|
101
|
-
MediaId: imageId,
|
|
102
|
-
});
|
|
103
|
-
} else {
|
|
104
|
-
selected.MediaId = imageId;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
editContext!.operations.editField({
|
|
108
|
-
field: field.descriptor,
|
|
109
|
-
rawValue: JSON.stringify(raw),
|
|
110
|
-
refresh: "immediate",
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
[field, variant],
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const videoSelected = useCallback(
|
|
117
|
-
async (videoId: string) => {
|
|
118
|
-
const selected = raw.Variants?.find((x) => x.Name == variantName);
|
|
119
|
-
if (!selected) {
|
|
120
|
-
if (!raw.Variants) raw.Variants = [];
|
|
121
|
-
raw.Variants.push({
|
|
122
|
-
Name: variantName,
|
|
123
|
-
VideoId: videoId,
|
|
124
|
-
});
|
|
125
|
-
} else {
|
|
126
|
-
selected.VideoId = videoId;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
editContext!.operations.editField({
|
|
130
|
-
field: field.descriptor,
|
|
131
|
-
rawValue: JSON.stringify(raw),
|
|
132
|
-
refresh: "immediate",
|
|
133
|
-
});
|
|
134
|
-
},
|
|
135
|
-
[field, variant],
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
async function selectMedia(mode: MediaSelectorMode) {
|
|
139
|
-
const selectedImageId = await editContext?.selectMedia({
|
|
140
|
-
selectedIdPath: variant?.idPath || "",
|
|
141
|
-
mode: mode,
|
|
142
|
-
});
|
|
143
|
-
if (selectedImageId) imageSelected(selectedImageId);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async function selectVideo() {
|
|
147
|
-
const selectedVideoId = await editContext?.selectMedia({
|
|
148
|
-
selectedIdPath: variant?.idPath || "",
|
|
149
|
-
mode: "video",
|
|
150
|
-
});
|
|
151
|
-
if (selectedVideoId) videoSelected(selectedVideoId);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const notEmpty = variant?.mediaId;
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<div
|
|
158
|
-
className="absolute inset-0 flex items-center justify-center"
|
|
159
|
-
onMouseEnter={() => setShowMenu(true)}
|
|
160
|
-
onMouseLeave={() => setShowMenu(false)}
|
|
161
|
-
onClick={() => {
|
|
162
|
-
if (!isPageEditor) return;
|
|
163
|
-
const itemId = field.descriptor.item?.id;
|
|
164
|
-
if (itemId) editContext?.select([itemId]);
|
|
165
|
-
}}
|
|
166
|
-
onWheel={(e) => {
|
|
167
|
-
if (forwardScrollevents)
|
|
168
|
-
editContext?.pageView.editorIframeRef!.current?.contentWindow?.document.documentElement?.scrollBy(
|
|
169
|
-
{
|
|
170
|
-
behavior: "instant",
|
|
171
|
-
left: 0,
|
|
172
|
-
top: e.deltaY,
|
|
173
|
-
},
|
|
174
|
-
);
|
|
175
|
-
editContext?.pageView.editorIframeRef!.current?.contentWindow?.document.body?.scrollBy(
|
|
176
|
-
{
|
|
177
|
-
behavior: "instant",
|
|
178
|
-
left: 0,
|
|
179
|
-
top: e.deltaY,
|
|
180
|
-
},
|
|
181
|
-
);
|
|
182
|
-
}}
|
|
183
|
-
style={style}
|
|
184
|
-
data-testid="select-media"
|
|
185
|
-
>
|
|
186
|
-
{showMenu && (
|
|
187
|
-
<div className="grid min-w-48 grid-cols-2 items-stretch justify-center gap-1.5 p-3 text-sm">
|
|
188
|
-
<Btn
|
|
189
|
-
label="Select"
|
|
190
|
-
icon="pi pi-image"
|
|
191
|
-
onClick={() => selectMedia("images")}
|
|
192
|
-
testId="select-media-button"
|
|
193
|
-
className="min-w-[80px]"
|
|
194
|
-
/>
|
|
195
|
-
{field.value?.allowVideos && (
|
|
196
|
-
<Btn
|
|
197
|
-
label="Video"
|
|
198
|
-
icon="pi pi-video"
|
|
199
|
-
onClick={() => selectVideo()}
|
|
200
|
-
testId="video-media-button"
|
|
201
|
-
className="min-w-[80px]"
|
|
202
|
-
/>
|
|
203
|
-
)}
|
|
204
|
-
{notEmpty && (
|
|
205
|
-
<Btn
|
|
206
|
-
label="Crop"
|
|
207
|
-
icon="pi pi-expand"
|
|
208
|
-
onClick={() => {
|
|
209
|
-
setShowCropper(true);
|
|
210
|
-
}}
|
|
211
|
-
testId="crop-media-button"
|
|
212
|
-
className="min-w-[80px]"
|
|
213
|
-
/>
|
|
214
|
-
)}
|
|
215
|
-
{rawVariant && (
|
|
216
|
-
<Btn
|
|
217
|
-
label="Reset"
|
|
218
|
-
icon="pi pi-times"
|
|
219
|
-
onClick={() => reset()}
|
|
220
|
-
testId="reset-media-button"
|
|
221
|
-
className="min-w-[80px]"
|
|
222
|
-
/>
|
|
223
|
-
)}
|
|
224
|
-
{fieldButtons.length > 0 && (
|
|
225
|
-
<Btn
|
|
226
|
-
label="Actions"
|
|
227
|
-
icon="pi pi-bolt"
|
|
228
|
-
onClick={(e) => fieldActionsOverlay.current?.show(e)}
|
|
229
|
-
testId="field-actions-button"
|
|
230
|
-
className="min-w-[80px]"
|
|
231
|
-
/>
|
|
232
|
-
)}
|
|
233
|
-
</div>
|
|
234
|
-
)}
|
|
235
|
-
{showCropper && (
|
|
236
|
-
<PictureCropper
|
|
237
|
-
field={field}
|
|
238
|
-
onClose={() => setShowCropper(false)}
|
|
239
|
-
variantName={variantName}
|
|
240
|
-
/>
|
|
241
|
-
)}
|
|
242
|
-
<FieldActionsOverlay
|
|
243
|
-
ref={fieldActionsOverlay}
|
|
244
|
-
generatorButtons={fieldButtons}
|
|
245
|
-
onActionClick={handleActionClick}
|
|
246
|
-
onParameterizedActionExecute={handleParameterizedActionExecute}
|
|
247
|
-
currentOverlay={editContext?.currentOverlay}
|
|
248
|
-
fieldId={field.id}
|
|
249
|
-
setCurrentOverlay={editContext?.setCurrentOverlay || (() => {})}
|
|
250
|
-
/>
|
|
251
|
-
</div>
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function Btn({
|
|
256
|
-
label,
|
|
257
|
-
icon,
|
|
258
|
-
onClick,
|
|
259
|
-
testId,
|
|
260
|
-
className,
|
|
261
|
-
}: {
|
|
262
|
-
label: string;
|
|
263
|
-
icon: string;
|
|
264
|
-
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
265
|
-
testId?: string;
|
|
266
|
-
className?: string;
|
|
267
|
-
}) {
|
|
268
|
-
return (
|
|
269
|
-
<button
|
|
270
|
-
className={`btn flex cursor-pointer items-center gap-1.5 rounded-lg border bg-gray-500 p-1.5 text-white opacity-70 hover:opacity-85 ${className}`}
|
|
271
|
-
onClick={onClick}
|
|
272
|
-
data-testid={testId}
|
|
273
|
-
>
|
|
274
|
-
<i className={icon} /> {label}
|
|
275
|
-
</button>
|
|
276
|
-
);
|
|
277
|
-
}
|
|
@@ -1,381 +0,0 @@
|
|
|
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
|
-
}
|