From f7a7ead12b5113a04127e58d9999ff8b2f71a1de Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Tue, 22 Apr 2025 17:33:56 +0200 Subject: [PATCH] Fixed selection handling clicking editor padding --- .../06-custom-schema/04-pdf-file-block/styles.css | 8 +------- .../render/createResizableFileBlockWrapper.ts | 5 ++++- packages/core/src/editor/Block.css | 2 +- .../helpers/render/ResizableFileBlockWrapper.tsx | 12 +++++++----- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/examples/06-custom-schema/04-pdf-file-block/styles.css b/examples/06-custom-schema/04-pdf-file-block/styles.css index 00cf5b63ee..dd9bed7b7a 100644 --- a/examples/06-custom-schema/04-pdf-file-block/styles.css +++ b/examples/06-custom-schema/04-pdf-file-block/styles.css @@ -1,10 +1,4 @@ -[data-content-type="pdf"] .bn-file-block-content-wrapper, -[data-content-type="pdf"] .bn-file-and-caption-wrapper { - height: 800px; - width: 100%; -} - [data-content-type="pdf"] embed { - height: 100%; + height: 800px; width: 100%; } \ No newline at end of file diff --git a/packages/core/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts b/packages/core/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts index a207961cd3..f8e6488627 100644 --- a/packages/core/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +++ b/packages/core/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts @@ -87,7 +87,10 @@ export const createResizableFileBlockWrapper = ( // Ensures the element is not wider than the editor and not narrower than a // predetermined minimum width. - width = Math.max(newWidth, minWidth); + width = Math.min( + Math.max(newWidth, minWidth), + editor.domElement?.firstElementChild?.clientWidth || Number.MAX_VALUE + ); wrapper.style.width = `${width}px`; }; // Stops mouse movements from resizing the element and updates the block's diff --git a/packages/core/src/editor/Block.css b/packages/core/src/editor/Block.css index 2bff2395b4..b86e8e1af3 100644 --- a/packages/core/src/editor/Block.css +++ b/packages/core/src/editor/Block.css @@ -14,7 +14,6 @@ BASIC STYLES } .bn-block-content { - display: flex; padding: 3px 0; transition: font-size 0.2s; width: 100%; @@ -163,6 +162,7 @@ NESTED BLOCKS .bn-block-content::before { margin-right: 0; content: ""; + display: inline; } /* Ordered */ diff --git a/packages/react/src/blocks/FileBlockContent/helpers/render/ResizableFileBlockWrapper.tsx b/packages/react/src/blocks/FileBlockContent/helpers/render/ResizableFileBlockWrapper.tsx index f8a9a2b635..63d12e6a90 100644 --- a/packages/react/src/blocks/FileBlockContent/helpers/render/ResizableFileBlockWrapper.tsx +++ b/packages/react/src/blocks/FileBlockContent/helpers/render/ResizableFileBlockWrapper.tsx @@ -66,11 +66,13 @@ export const ResizableFileBlockWrapper = ( // Ensures the child is not wider than the editor and not narrower than a // predetermined minimum width. - if (newWidth < minWidth) { - setWidth(minWidth); - } else { - setWidth(newWidth); - } + setWidth( + Math.min( + Math.max(newWidth, minWidth), + props.editor.domElement?.firstElementChild?.clientWidth || + Number.MAX_VALUE + ) + ); }; // Stops mouse movements from resizing the child and updates the block's // `width` prop to the new value.