feat(editor): add max height to edgeless embed doc (#12030)

Close [BS-3250](https://linear.app/affine-design/issue/BS-3250/embed-doc在白板的高度需要适应内容)
This commit is contained in:
L-Sun
2025-04-30 03:11:38 +00:00
parent 315ea00390
commit d6f79a0c71

View File

@@ -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,