From 4bd023abd37fb59c130b0c830cf7195a2f27e75a Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Mon, 22 Aug 2022 13:51:51 +0800 Subject: [PATCH] fix: build issue --- tldraw/apps/tldraw-logseq/src/lib/shapes/HTMLShape.tsx | 5 +++-- tldraw/apps/tldraw-logseq/src/styles.css | 4 ++++ .../core/src/lib/shapes/TLImageShape/TLImageShape.ts | 2 +- .../TLSelectTool/states/HoveringSelectionHandleState.ts | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/HTMLShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/HTMLShape.tsx index 9084b20c39..8a30421af4 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/HTMLShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/HTMLShape.tsx @@ -61,10 +61,11 @@ export class HTMLShape extends TLBoxShape { onResetBounds = (info?: TLResetBoundsInfo) => { if (this.htmlAnchorRef.current) { + const rect = this.htmlAnchorRef.current.getBoundingClientRect() this.update({ size: [ - this.props.size[0], - Math.max(Math.min(this.htmlAnchorRef.current.offsetHeight || 400, 800), 10), + Math.max(Math.min(rect.width || 400, 800), 10), + Math.max(Math.min(rect.height || 400, 800), 10), ], }) } diff --git a/tldraw/apps/tldraw-logseq/src/styles.css b/tldraw/apps/tldraw-logseq/src/styles.css index 409e2faf19..e505c38490 100644 --- a/tldraw/apps/tldraw-logseq/src/styles.css +++ b/tldraw/apps/tldraw-logseq/src/styles.css @@ -642,6 +642,10 @@ button.tl-select-input-trigger { transform-origin: top left; } +.tl-html-anchor { + width: fit-content; +} + .tl-html-anchor > iframe { @apply h-full w-full !important; margin: 0; diff --git a/tldraw/packages/core/src/lib/shapes/TLImageShape/TLImageShape.ts b/tldraw/packages/core/src/lib/shapes/TLImageShape/TLImageShape.ts index d65bf22048..a80d11d502 100644 --- a/tldraw/packages/core/src/lib/shapes/TLImageShape/TLImageShape.ts +++ b/tldraw/packages/core/src/lib/shapes/TLImageShape/TLImageShape.ts @@ -38,7 +38,7 @@ export class TLImageShape< assetId: '', } - autoResize = (info: TLResetBoundsInfo) => { + onResetBounds: (info?: TLResetBoundsInfo | undefined) => this = (info: any) => { const { clipping, size, point } = this.props if (clipping) { const [t, r, b, l] = Array.isArray(clipping) diff --git a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/HoveringSelectionHandleState.ts b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/HoveringSelectionHandleState.ts index faccfd6294..eae3bf9333 100644 --- a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/HoveringSelectionHandleState.ts +++ b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/HoveringSelectionHandleState.ts @@ -77,7 +77,7 @@ export class HoveringSelectionHandleState< break } case TLTargetType.Selection: { - selectedShape.autoResize?.({}) + selectedShape.onResetBounds?.({}) if (this.app.selectedShapesArray.length === 1) { this.tool.transition('editingShape', { type: TLTargetType.Shape, @@ -91,7 +91,7 @@ export class HoveringSelectionHandleState< const asset = selectedShape.props.assetId ? this.app.assets[selectedShape.props.assetId] : undefined - selectedShape.autoResize({ asset }) + selectedShape.onResetBounds({ asset }) this.tool.transition('idle') } }