import React from 'react'; import { useEditor } from '@craftjs/core'; import { BG_COLORS, RADIUS_PRESETS, } from '../../../constants/presets'; import { StylePanelProps, SectionLabel, ColorSwatchGrid, PresetButtonGrid, CollapsibleSection, ColorPickerField, ArrayPropEditor, SizeControl, AspectRatioControl, labelStyle, inputStyle, smallInputStyle, sectionGap, useNodeProp, } from './shared'; import { AssetPicker } from '../../../ui/AssetPicker'; import { BoxModelSection, BorderEffectsSection, AnimVisSection } from './mediaBoxModel'; const GALLERY_COLUMN_PRESETS = [ { label: '2', value: '2' }, { label: '3', value: '3' }, { label: '4', value: '4' }, { label: '5', value: '5' }, ]; /* ---------- MEDIA (Video / Gallery / Map / Slider) ---------- */ export const MediaStylePanel: React.FC = ({ selectedId, nodeProps }) => { const { actions } = useEditor(); const { setProp, setPropStyle } = useNodeProp(selectedId); const style = nodeProps.style || {}; // Same crop-fills-by-default + no stale-height-conflict treatment as // ImageStylePanel (see there for the full rationale): applying a ratio // defaults objectFit to 'cover' when unset, and clears height so Width + // ratio + cover is the single source of truth for the box. const applyAspectRatio = (v: string) => { setPropStyle('aspectRatio', v); if (v) { if (!style.objectFit) setPropStyle('objectFit', 'cover'); setPropStyle('height', ''); } }; return ( <> {/* Video source -- upload/browse/paste-URL (paste-URL still handles YouTube/Vimeo; upload/browse handle files via detectVideoType's serve_asset resolution). */} {nodeProps.videoUrl !== undefined && (
Video Source setProp('videoUrl', url)} variant="full" placeholder="Or paste a YouTube/Vimeo/.mp4 URL..." />
)} {/* Video size -- width + aspect ratio for the video frame. */} {nodeProps.videoUrl !== undefined && ( <> setPropStyle('width', v)} /> {/* NOTE: unlike ImageStylePanel, there is no separate Height control here to gate on aspect-ratio -- VideoBlock's