Revert "feat: Paste block in viewport / near cursor (#7521)"

This reverts commit c37f4b8749.
This commit is contained in:
Maribeth Moffatt
2024-05-23 11:06:46 -07:00
parent 7c6fbec23c
commit 4040e78ffb

View File

@@ -13,8 +13,6 @@ import {Gesture} from './gesture.js';
import {ICopyData, isCopyable} from './interfaces/i_copyable.js';
import {isDeletable} from './interfaces/i_deletable.js';
import {KeyboardShortcut, ShortcutRegistry} from './shortcut_registry.js';
import {Rect} from './utils/rect.js';
import {Coordinate} from './utils/coordinate.js';
import {KeyCodes} from './utils/keycodes.js';
import type {WorkspaceSvg} from './workspace_svg.js';
import {isDraggable} from './interfaces/i_draggable.js';
@@ -92,7 +90,6 @@ export function registerDelete() {
let copyData: ICopyData | null = null;
let copyWorkspace: WorkspaceSvg | null = null;
let copyCoords: Coordinate | null = null;
/**
* Keyboard shortcut to copy a block on ctrl+c, cmd+c, or alt+c.
@@ -131,7 +128,6 @@ export function registerCopy() {
const selected = common.getSelected();
if (!selected || !isCopyable(selected)) return false;
copyData = selected.toCopyData();
copyCoords = selected.getRelativeToSurfaceXY();
copyWorkspace = workspace;
return !!copyData;
},
@@ -215,20 +211,8 @@ export function registerPaste() {
return !workspace.options.readOnly && !Gesture.inProgress();
},
callback() {
if (!copyData || !copyCoords || !copyWorkspace) return false;
const {left, top, width, height} = copyWorkspace
.getMetricsManager()
.getViewMetrics(true);
const viewportRect = new Rect(top, top + height, left, left + width);
if (viewportRect.contains(copyCoords.x, copyCoords.y)) {
// Pass the default copy coordinates when they are inside the viewport.
return !!clipboard.paste(copyData, copyWorkspace, copyCoords);
} else {
// Otherwise paste in the middle of the viewport.
const centerCoords = new Coordinate(left + width / 2, top + height / 2);
return !!clipboard.paste(copyData, copyWorkspace, centerCoords);
}
if (!copyData || !copyWorkspace) return false;
return !!clipboard.paste(copyData, copyWorkspace);
},
keyCodes: [ctrlV, altV, metaV],
};