浏览代码

fix: build issue

Peng Xiao 3 年之前
父节点
当前提交
4bd023abd3

+ 3 - 2
tldraw/apps/tldraw-logseq/src/lib/shapes/HTMLShape.tsx

@@ -61,10 +61,11 @@ export class HTMLShape extends TLBoxShape<HTMLShapeProps> {
 
   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),
         ],
       })
     }

+ 4 - 0
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;

+ 1 - 1
tldraw/packages/core/src/lib/shapes/TLImageShape/TLImageShape.ts

@@ -38,7 +38,7 @@ export class TLImageShape<
     assetId: '',
   }
 
-  autoResize = (info: TLResetBoundsInfo<TLImageAsset>) => {
+  onResetBounds: (info?: TLResetBoundsInfo | undefined) => this = (info: any) => {
     const { clipping, size, point } = this.props
     if (clipping) {
       const [t, r, b, l] = Array.isArray(clipping)

+ 2 - 2
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')
     }
   }