Skip to content

Commit 4c62d00

Browse files
committed
fix: also apply width attribute to video block
Apply the same fix as the image block to video: - React VideoPreview now sets width on the <video> element so read-only rendering includes it. - React VideoToExternalHTML now serializes previewWidth (it was previously dropped entirely on export). - Core video render path guards `video.width = previewWidth` against undefined (assigning undefined to a numeric DOM property coerces to 0). Audio and File blocks don't have a previewWidth prop, so no change is needed there. Refs #2726
1 parent b2aa79c commit 4c62d00

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

packages/core/src/blocks/Video/block.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ export const createVideoBlockSpec = createBlockSpec(
9292
video.controls = true;
9393
video.contentEditable = "false";
9494
video.draggable = false;
95-
video.width = block.props.previewWidth;
95+
if (block.props.previewWidth) {
96+
video.width = block.props.previewWidth;
97+
}
9698
videoWrapper.appendChild(video);
9799

98100
return createResizableFileBlockWrapper(

packages/react/src/blocks/Video/block.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const VideoPreview = (
2727
: resolved.downloadUrl
2828
}
2929
controls={true}
30+
width={props.block.props.previewWidth}
3031
contentEditable={false}
3132
draggable={false}
3233
/>
@@ -44,7 +45,7 @@ export const VideoToExternalHTML = (
4445
}
4546

4647
const video = props.block.props.showPreview ? (
47-
<video src={props.block.props.url} />
48+
<video src={props.block.props.url} width={props.block.props.previewWidth} />
4849
) : (
4950
<a href={props.block.props.url}>
5051
{props.block.props.name || props.block.props.url}

0 commit comments

Comments
 (0)