refboard: restore clipboard copy and native paste flows
This commit is contained in:
@@ -61,8 +61,7 @@ export async function writeCanvasToClipboard(
|
|||||||
outputCanvas.width = sw;
|
outputCanvas.width = sw;
|
||||||
outputCanvas.height = sh;
|
outputCanvas.height = sh;
|
||||||
const ctx2d = outputCanvas.getContext('2d')!;
|
const ctx2d = outputCanvas.getContext('2d')!;
|
||||||
ctx2d.fillStyle = '#1e1e1e';
|
ctx2d.clearRect(0, 0, outputCanvas.width, outputCanvas.height);
|
||||||
ctx2d.fillRect(0, 0, outputCanvas.width, outputCanvas.height);
|
|
||||||
ctx2d.drawImage(sourceCanvas, sx, sy, sw, sh, 0, 0, sw, sh);
|
ctx2d.drawImage(sourceCanvas, sx, sy, sw, sh, 0, 0, sw, sh);
|
||||||
} else {
|
} else {
|
||||||
// Full current view copy.
|
// Full current view copy.
|
||||||
@@ -70,8 +69,7 @@ export async function writeCanvasToClipboard(
|
|||||||
outputCanvas.width = sourceCanvas.width;
|
outputCanvas.width = sourceCanvas.width;
|
||||||
outputCanvas.height = sourceCanvas.height;
|
outputCanvas.height = sourceCanvas.height;
|
||||||
const ctx2d = outputCanvas.getContext('2d')!;
|
const ctx2d = outputCanvas.getContext('2d')!;
|
||||||
ctx2d.fillStyle = '#1e1e1e';
|
ctx2d.clearRect(0, 0, outputCanvas.width, outputCanvas.height);
|
||||||
ctx2d.fillRect(0, 0, outputCanvas.width, outputCanvas.height);
|
|
||||||
ctx2d.drawImage(sourceCanvas, 0, 0);
|
ctx2d.drawImage(sourceCanvas, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -492,6 +492,7 @@ export const shortcuts: ShortcutDef[] = [
|
|||||||
{
|
{
|
||||||
id: 'paste', keys: { key: 'v', ctrl: true },
|
id: 'paste', keys: { key: 'v', ctrl: true },
|
||||||
category: 'editing', description: 'Paste',
|
category: 'editing', description: 'Paste',
|
||||||
|
preventDefault: false,
|
||||||
handler: async (ctx) => {
|
handler: async (ctx) => {
|
||||||
// Only handle recent internal copies here.
|
// Only handle recent internal copies here.
|
||||||
// For external clipboard content (images, text, HTML), do NOT call
|
// For external clipboard content (images, text, HTML), do NOT call
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export interface ShortcutDef {
|
|||||||
category: 'alignment' | 'arrangement' | 'normalize' | 'navigation' | 'editing' | 'view' | 'tools' | 'image';
|
category: 'alignment' | 'arrangement' | 'normalize' | 'navigation' | 'editing' | 'view' | 'tools' | 'image';
|
||||||
needsSelection?: boolean; // skip if no objects selected
|
needsSelection?: boolean; // skip if no objects selected
|
||||||
minSelection?: number; // minimum selected objects (default 1 if needsSelection)
|
minSelection?: number; // minimum selected objects (default 1 if needsSelection)
|
||||||
|
preventDefault?: boolean; // defaults to true
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShortcutContext {
|
export interface ShortcutContext {
|
||||||
|
|||||||
@@ -141,7 +141,9 @@ export function useShortcutHandler(deps: ShortcutHandlerDeps) {
|
|||||||
if (def.needsSelection && activeCount === 0) continue;
|
if (def.needsSelection && activeCount === 0) continue;
|
||||||
if (def.minSelection && activeCount < def.minSelection) continue;
|
if (def.minSelection && activeCount < def.minSelection) continue;
|
||||||
|
|
||||||
|
if (def.preventDefault !== false) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
}
|
||||||
await def.handler(ctx);
|
await def.handler(ctx);
|
||||||
|
|
||||||
// Update zoom display after any action
|
// Update zoom display after any action
|
||||||
|
|||||||
Reference in New Issue
Block a user