Fix Ctrl+V to paste from system clipboard when internal clipboard is empty

This commit is contained in:
diodiogod
2026-02-02 18:22:54 -03:00
parent 9b04729561
commit ce4d332987
2 changed files with 74 additions and 78 deletions

View File

@@ -575,10 +575,8 @@ export class CanvasInteractions {
} }
break; break;
case 'v': case 'v':
// Paste layers from internal clipboard // Paste from internal clipboard or system clipboard
if (this.canvas.canvasLayers.internalClipboard.length > 0) { this.canvas.canvasLayers.handlePaste('mouse');
this.canvas.canvasLayers.pasteLayers();
}
break; break;
default: default:
handled = false; handled = false;

View File

@@ -360,7 +360,7 @@ export class CanvasInteractions {
if (grabIconLayer) { if (grabIconLayer) {
// Start dragging the selected layer(s) without changing selection // Start dragging the selected layer(s) without changing selection
this.interaction.mode = 'potential-drag'; this.interaction.mode = 'potential-drag';
this.interaction.dragStart = {...coords.world}; this.interaction.dragStart = { ...coords.world };
return; return;
} }
@@ -704,10 +704,8 @@ export class CanvasInteractions {
} }
break; break;
case 'v': case 'v':
// Paste layers from internal clipboard // Paste from internal clipboard or system clipboard
if (this.canvas.canvasLayers.internalClipboard.length > 0) { this.canvas.canvasLayers.handlePaste('mouse');
this.canvas.canvasLayers.pasteLayers();
}
break; break;
default: default:
handled = false; handled = false;
@@ -844,7 +842,7 @@ export class CanvasInteractions {
originalHeight: layer.originalHeight, originalHeight: layer.originalHeight,
cropBounds: layer.cropBounds ? { ...layer.cropBounds } : undefined cropBounds: layer.cropBounds ? { ...layer.cropBounds } : undefined
}; };
this.interaction.dragStart = {...worldCoords}; this.interaction.dragStart = { ...worldCoords };
if (handle === 'rot') { if (handle === 'rot') {
this.interaction.mode = 'rotating'; this.interaction.mode = 'rotating';
@@ -880,7 +878,7 @@ export class CanvasInteractions {
} }
this.interaction.mode = 'potential-drag'; this.interaction.mode = 'potential-drag';
this.interaction.dragStart = {...worldCoords}; this.interaction.dragStart = { ...worldCoords };
} }
startPanning(e: MouseEvent, clearSelection: boolean = true): void { startPanning(e: MouseEvent, clearSelection: boolean = true): void {
@@ -896,8 +894,8 @@ export class CanvasInteractions {
this.interaction.mode = 'resizingCanvas'; this.interaction.mode = 'resizingCanvas';
const startX = snapToGrid(worldCoords.x); const startX = snapToGrid(worldCoords.x);
const startY = snapToGrid(worldCoords.y); const startY = snapToGrid(worldCoords.y);
this.interaction.canvasResizeStart = {x: startX, y: startY}; this.interaction.canvasResizeStart = { x: startX, y: startY };
this.interaction.canvasResizeRect = {x: startX, y: startY, width: 0, height: 0}; this.interaction.canvasResizeRect = { x: startX, y: startY, width: 0, height: 0 };
this.canvas.render(); this.canvas.render();
} }
@@ -949,7 +947,7 @@ export class CanvasInteractions {
const dy = e.clientY - this.interaction.panStart.y; const dy = e.clientY - this.interaction.panStart.y;
this.canvas.viewport.x -= dx / this.canvas.viewport.zoom; this.canvas.viewport.x -= dx / this.canvas.viewport.zoom;
this.canvas.viewport.y -= dy / this.canvas.viewport.zoom; this.canvas.viewport.y -= dy / this.canvas.viewport.zoom;
this.interaction.panStart = {x: e.clientX, y: e.clientY}; this.interaction.panStart = { x: e.clientX, y: e.clientY };
// Update stroke overlay if mask tool is drawing during pan // Update stroke overlay if mask tool is drawing during pan
if (this.canvas.maskTool.isDrawing) { if (this.canvas.maskTool.isDrawing) {
@@ -1106,9 +1104,9 @@ export class CanvasInteractions {
} else newCropBounds.height += delta_image_y; } else newCropBounds.height += delta_image_y;
} }
// Clamp crop bounds to stay within the original image and maintain minimum size // Clamp crop bounds to stay within the original image and maintain minimum size
if (newCropBounds.width < 1) { if (newCropBounds.width < 1) {
if (handle?.includes('w')) newCropBounds.x = o.cropBounds.x + o.cropBounds.width -1; if (handle?.includes('w')) newCropBounds.x = o.cropBounds.x + o.cropBounds.width - 1;
newCropBounds.width = 1; newCropBounds.width = 1;
} }
if (newCropBounds.height < 1) { if (newCropBounds.height < 1) {