Skip to content

The VS Code of video editing, built for agents.

TypeScript

Refine alt-drag interaction handling in DocumentEditor

konstantin-paulusf2d6f553b3d7
diff --git a/apps/web/src/engine/input/interactions.ts b/apps/web/src/engine/input/interactions.ts
index 252d234f..025b4a81 100644
--- a/apps/web/src/engine/input/interactions.ts
+++ b/apps/web/src/engine/input/interactions.ts
@@ -11,9 +11,9 @@
* Every change goes through `DocumentEditor`, because the source is the
* document: dragging a node writes `x`/`y` back to the element it came from,
* and dropping it into a scene moves the element under that scene's, the same
- * way the inspector or a hand edit would. Alt-drag duplication is the one
- * gesture with no spelling here: it would have to author a copy of a subtree
- * the JSX may well be generating.
+ * way the inspector or a hand edit would. Alt-dragging duplicates first
+ * (`DocumentEditor.duplicate`) and then moves the copies, leaving the
+ * originals where they were.
*/
import {
@@ -26,7 +26,8 @@ import {
getSelection, getSelectionMask, identity2D, invert2D, isPointerInEntity,
multiply2D, quadCenter, quadContainsQuad, quadsIntersect, rectToQuad,
rotate2D, scale2D,
- store, syncInteractiveState, togglePlayback, transformPoint, translate2D,
+ store, syncInteractiveState, togglePlayback, transformPoint, transformSystem,
+ translate2D,
} from '@diffusionstudio/runtime';
import { Not, Or } from 'koota';
@@ -649,6 +650,10 @@ export function handleMaskInteraction(world: World, event: DispatchedPointerEven
}
if (event.type === 'dragstart') {
+ if (keys(world).has('alt') && editor.duplicate(getSelection(world)).length) {
+ transformSystem(world);
+ }
+
snapshotSelectionMask(world);
snapshotSelectionTransforms(world);
snapshotSnapCandidates(world);