-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Images now paste under the cursor #3861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli | |
| let canvasFocused = true; | ||
| let inPointerLock = false; | ||
| const shakeSamples: { x: number; y: number; time: number }[] = []; | ||
| let lastMousePosition: [number, number] = [0, 0]; | ||
| let lastShakeTime = 0; | ||
|
|
||
| // Event listeners | ||
|
|
@@ -159,6 +160,8 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli | |
| function onPointerMove(e: PointerEvent) { | ||
| potentiallyRestoreCanvasFocus(e); | ||
|
|
||
| lastMousePosition = [e.clientX, e.clientY]; | ||
|
|
||
| if (!e.buttons) viewportPointerInteractionOngoing = false; | ||
|
|
||
| // Don't redirect pointer movement to the backend if there's no ongoing interaction and it's over a floating menu, or the graph overlay, on top of the canvas | ||
|
|
@@ -320,7 +323,7 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli | |
|
|
||
| Array.from(dataTransfer.items).forEach(async (item) => { | ||
| if (item.type === "text/plain") item.getAsString((text) => editor.handle.pasteText(text)); | ||
| await pasteFile(item, editor); | ||
| await pasteFile(item, editor, lastMousePosition); | ||
| }); | ||
|
Comment on lines
324
to
327
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using Additionally, the logic can be made more robust by checking Note that the for (const item of dataTransfer.items) {
if (item.kind === "file") {
await pasteFile(item, editor, lastMousePosition);
} else if (item.kind === "string" && item.type === "text/plain") {
const text = await new Promise<string>((resolve) => item.getAsString(resolve));
editor.handle.pasteText(text);
}
} |
||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.