diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx index 8fa7b392f5f..9e09076b290 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx @@ -1,7 +1,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { + BoundsUtils, delay, getComputedColor, + TLBounds, TLBoxShape, TLBoxShapeProps, TLResetBoundsInfo, @@ -392,9 +394,18 @@ export class LogseqPortalShape extends TLBoxShape { React.useEffect(() => { if (isCreating) { - app.viewport.zoomToBounds({ ...this.bounds, minY: this.bounds.maxY + 25 }) + const screenSize = [app.viewport.bounds.width, app.viewport.bounds.height] + const boundScreenCenter = app.viewport.getScreenPoint([this.bounds.minX, this.bounds.minY]) + + if ( + boundScreenCenter[0] > screenSize[0] - 400 || + boundScreenCenter[1] > screenSize[1] - 240 || + app.viewport.camera.zoom > 1.5 || app.viewport.camera.zoom < 0.5 + ) { + app.viewport.zoomToBounds({ ...this.bounds, minY: this.bounds.maxY + 25 }) + } } - }, [app.viewport.currentView.height]) + }, [app.viewport.bounds.height.toFixed(2)]) const onPageNameChanged = React.useCallback((id: string) => { this.initialHeightCalculated = false @@ -434,6 +445,7 @@ export class LogseqPortalShape extends TLBoxShape { }} {...events} > +
{isBinding && }