From a763e94f27286153414c637b39d2c70f21b07d97 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Sun, 4 Dec 2022 16:22:08 +0800 Subject: [PATCH] fix:content block boundary error --- src/editor/core/draw/Draw.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index 17f68f2..3e0022d 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -711,9 +711,13 @@ export class Draw { metrics.boundingBoxDescent = 0 metrics.boundingBoxAscent = metrics.height } else if (element.type === ElementType.BLOCK) { - metrics.width = element.width - ? element.width * scale - : this.getInnerWidth() + const innerWidth = this.getInnerWidth() + if (!element.width) { + metrics.width = innerWidth + } else { + const elementWidth = element.width * scale + metrics.width = elementWidth > innerWidth ? innerWidth : elementWidth + } metrics.height = element.height! * scale metrics.boundingBoxDescent = metrics.height metrics.boundingBoxAscent = 0 @@ -750,6 +754,7 @@ export class Draw { if ( preElement?.type === ElementType.TABLE || preElement?.type === ElementType.BLOCK + || element.type === ElementType.BLOCK || preElement?.imgDisplay === ImageDisplay.INLINE || element.imgDisplay === ImageDisplay.INLINE || curRow.width + metrics.width > innerWidth