Let the native clipboard through where the canvas has nothing to copy

A bound chord used to be `preventDefault`ed before its handler ran, so the
canvas took every ⌘C and ⌘V whether or not the node clipboard would act —
which is what blocked copying selected text out of the chrome floating over
the canvas. A binding may now return `false` to decline the key; ⌘C does so
when there is a text selection or no node selected, ⌘V when nothing of ours
is stored.
This commit is contained in:
2026-09-06 18:16:17 +02:00
parent 7d8fe6456a
commit 23a80db6bb
3 changed files with 115 additions and 4 deletions
+15 -2
View File
@@ -1061,8 +1061,21 @@ function FlowEditorInner({
{
"mod+z": () => step(true),
"mod+shift+z": () => step(false),
"mod+c": () => void copyNodes(),
"mod+v": pasteNodes,
// Both decline the key unless the node clipboard has something to do
// with it, so the native copy and paste still work on the canvas. A
// text selection wins outright: that is what the user asked to copy.
"mod+c": () => {
const selection = document.getSelection()
if (selection && !selection.isCollapsed) return false
if (!canvasNodes.some((node) => node.selected) && !selectedId) {
return false
}
void copyNodes()
},
"mod+v": () => {
if (!safeStorage.get(CLIPBOARD_KEY)) return false
pasteNodes()
},
// ⌘P, not ⌘K: the sidebar's global search owns that everywhere, and this
// palette is the canvas's own, narrower thing.
"mod+p": () => setPaletteOpen((open) => !open),