From d6f79a0c715d2ff4f6f1e5b1a040c27dda80cb50 Mon Sep 17 00:00:00 2001 From: L-Sun Date: Wed, 30 Apr 2025 03:11:38 +0000 Subject: [PATCH] feat(editor): add max height to edgeless embed doc (#12030) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close [BS-3250](https://linear.app/affine-design/issue/BS-3250/embed-doc在白板的高度需要适应内容) --- .../components/rects/edgeless-selected-rect.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/blocksuite/affine/blocks/root/src/edgeless/components/rects/edgeless-selected-rect.ts b/blocksuite/affine/blocks/root/src/edgeless/components/rects/edgeless-selected-rect.ts index 993218fbf..e9256a0be 100644 --- a/blocksuite/affine/blocks/root/src/edgeless/components/rects/edgeless-selected-rect.ts +++ b/blocksuite/affine/blocks/root/src/edgeless/components/rects/edgeless-selected-rect.ts @@ -1125,6 +1125,18 @@ export class EdgelessSelectedRectWidget extends WidgetComponent< bound: Bound, direction: HandleDirection ) { + const block = this.std.view.getBlock(element.id); + if (!block) return; + const headerHeight = + block + .querySelector('.affine-embed-synced-doc-edgeless-header-wrapper') + ?.getBoundingClientRect().height ?? 0; + const contentHeight = + block.querySelector('affine-preview-root')?.getBoundingClientRect() + .height ?? 0; + + const maxHeight = (headerHeight + contentHeight) / this.zoom; + const curBound = Bound.deserialize(element.xywh); let scale = element.props.scale ?? 1; @@ -1141,11 +1153,11 @@ export class EdgelessSelectedRectWidget extends WidgetComponent< bound.w = width * scale; height = bound.h / scale; - height = clamp(height, SYNCED_MIN_HEIGHT, Infinity); + height = clamp(height, SYNCED_MIN_HEIGHT, maxHeight); bound.h = height * scale; this._isWidthLimit = width === SYNCED_MIN_WIDTH; - this._isHeightLimit = height === SYNCED_MIN_HEIGHT; + this._isHeightLimit = height === SYNCED_MIN_HEIGHT || height === maxHeight; this.gfx.updateElement(element.id, { scale,