Skip to content

Commit 2299e0a

Browse files
ENG-965 Fix tldraw image paste positioning bug (#491)
* Center image placement based on shift key Co-authored-by: mclicks <mclicks@gmail.com> * rm shift modifier --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent ffc313a commit 2299e0a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

apps/roam/src/components/canvas/Tldraw.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -801,11 +801,13 @@ const InsideEditorAndUiContext = ({
801801
},
802802
});
803803
editor.createAssets([asset]);
804+
805+
const position = editor.getViewportPageBounds().center;
806+
804807
editor.createShape({
805808
type: "image",
806-
// Center the image in the editor
807-
x: (window.innerWidth - size.w) / 2,
808-
y: (window.innerHeight - size.h) / 2,
809+
x: position.x - size.w / 2,
810+
y: position.y - size.h / 2,
809811
props: { assetId, w: size.w, h: size.h },
810812
});
811813

0 commit comments

Comments
 (0)