From c1aa4c8ddeb94f8d83bf15d9e137da0d91f3a2ce Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 22 Jan 2023 10:13:15 -0500 Subject: [PATCH] fix: Alignment of caption on fullwidth images --- shared/editor/nodes/Image.tsx | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/shared/editor/nodes/Image.tsx b/shared/editor/nodes/Image.tsx index 2752b5e12..655ca7f14 100644 --- a/shared/editor/nodes/Image.tsx +++ b/shared/editor/nodes/Image.tsx @@ -594,7 +594,7 @@ const ImageComponent = ( onClick: (event: React.MouseEvent) => void; onDownload: (event: React.MouseEvent) => void; onChangeSize: (props: { width: number; height?: number }) => void; - children: React.ReactNode; + children: React.ReactElement; view: EditorView; } ) => { @@ -721,27 +721,23 @@ const ImageComponent = ( }; }, [dragging, handlePointerMove, handlePointerUp]); - const style = isFullWidth + const widthStyle = isFullWidth ? { width: contentWidth } : { width: size.width || "auto" }; + const containerStyle = isFullWidth + ? ({ + "--offset": `${-(contentWidth - documentWidth) / 2}px`, + } as React.CSSProperties) + : undefined; + return ( -
+
{!dragging && size.width > 60 && size.height > 60 && (
); };