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:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user