diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-31 22:54:06 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-31 22:54:06 +0200 |
| commit | cc150c7cfb859dfc38372210ec5bcc8bd196bbc4 (patch) | |
| tree | 6cc57c2c54b6fd941b97c663b919f934b1445dde /apps/web/src/lib/commands/timeline/clipboard | |
| parent | 0488a6be455c225535414fd651c838c355a9d3bd (diff) | |
| parent | f8fb238b228881ef970739b7d884912058b41347 (diff) | |
| download | opencut-cc150c7cfb859dfc38372210ec5bcc8bd196bbc4.tar.gz | |
Merge branch 'refactor-selection-commands'
Diffstat (limited to 'apps/web/src/lib/commands/timeline/clipboard')
| -rw-r--r-- | apps/web/src/lib/commands/timeline/clipboard/paste.ts | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/apps/web/src/lib/commands/timeline/clipboard/paste.ts b/apps/web/src/lib/commands/timeline/clipboard/paste.ts index cd465ae7..74a88f0b 100644 --- a/apps/web/src/lib/commands/timeline/clipboard/paste.ts +++ b/apps/web/src/lib/commands/timeline/clipboard/paste.ts @@ -1,4 +1,4 @@ -import { Command } from "@/lib/commands/base-command";
+import { Command, type CommandResult } from "@/lib/commands/base-command";
import { EditorCore } from "@/core";
import type {
TimelineTrack,
@@ -17,21 +17,26 @@ import { cloneAnimations } from "@/lib/animation"; export class PasteCommand extends Command {
private savedState: TimelineTrack[] | null = null;
private pastedElements: { trackId: string; elementId: string }[] = [];
- private previousSelection: { trackId: string; elementId: string }[] = [];
+ private readonly time: number;
+ private readonly clipboardItems: ClipboardItem[];
- constructor(
- private time: number,
- private clipboardItems: ClipboardItem[],
- ) {
+ constructor({
+ time,
+ clipboardItems,
+ }: {
+ time: number;
+ clipboardItems: ClipboardItem[];
+ }) {
super();
+ this.time = time;
+ this.clipboardItems = clipboardItems;
}
- execute(): void {
+ execute(): CommandResult | undefined {
if (this.clipboardItems.length === 0) return;
const editor = EditorCore.getInstance();
this.savedState = editor.timeline.getTracks();
- this.previousSelection = editor.selection.getSelectedElements();
this.pastedElements = [];
const minStart = Math.min(
@@ -116,7 +121,7 @@ export class PasteCommand extends Command { editor.timeline.updateTracks(updatedTracks);
if (this.pastedElements.length > 0) {
- editor.selection.setSelectedElements({ elements: this.pastedElements });
+ return { select: this.pastedElements };
}
}
@@ -124,9 +129,6 @@ export class PasteCommand extends Command { if (this.savedState) {
const editor = EditorCore.getInstance();
editor.timeline.updateTracks(this.savedState);
- editor.selection.setSelectedElements({
- elements: this.previousSelection,
- });
}
}
|
