summaryrefslogtreecommitdiff
path: root/apps/web/src
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/src')
-rw-r--r--apps/web/src/lib/commands/base-command.ts14
-rw-r--r--apps/web/src/lib/commands/batch-command.ts4
-rw-r--r--apps/web/src/lib/commands/timeline/clipboard/paste.ts15
-rw-r--r--apps/web/src/lib/commands/timeline/element/duplicate-elements.ts15
-rw-r--r--apps/web/src/lib/commands/timeline/element/move-elements.ts12
-rw-r--r--apps/web/src/lib/commands/timeline/element/split-elements.ts10
6 files changed, 51 insertions, 19 deletions
diff --git a/apps/web/src/lib/commands/base-command.ts b/apps/web/src/lib/commands/base-command.ts
index 2d0d04b7..b244f2f3 100644
--- a/apps/web/src/lib/commands/base-command.ts
+++ b/apps/web/src/lib/commands/base-command.ts
@@ -1,9 +1,23 @@
import type { EditorSelectionPatch } from "@/lib/selection/editor-selection";
+import type { ElementRef } from "@/lib/timeline/types";
export interface CommandResult {
selection?: EditorSelectionPatch;
}
+export function createElementSelectionResult(
+ selectedElements: ElementRef[],
+): CommandResult {
+ return {
+ selection: {
+ selectedElements,
+ selectedKeyframes: [],
+ keyframeSelectionAnchor: null,
+ selectedMaskPoints: null,
+ },
+ };
+}
+
export abstract class Command {
abstract execute(): CommandResult | undefined;
diff --git a/apps/web/src/lib/commands/batch-command.ts b/apps/web/src/lib/commands/batch-command.ts
index ea23411c..c4ee7e0b 100644
--- a/apps/web/src/lib/commands/batch-command.ts
+++ b/apps/web/src/lib/commands/batch-command.ts
@@ -10,7 +10,7 @@ export class BatchCommand extends Command {
for (const command of this.commands) {
const result = command.execute();
- if (result?.select !== undefined) {
+ if (result?.selection !== undefined) {
latestSelectionResult = result;
}
}
@@ -29,7 +29,7 @@ export class BatchCommand extends Command {
for (const command of this.commands) {
const result = command.redo();
- if (result?.select !== undefined) {
+ if (result?.selection !== undefined) {
latestSelectionResult = result;
}
}
diff --git a/apps/web/src/lib/commands/timeline/clipboard/paste.ts b/apps/web/src/lib/commands/timeline/clipboard/paste.ts
index 347c4f68..58199a94 100644
--- a/apps/web/src/lib/commands/timeline/clipboard/paste.ts
+++ b/apps/web/src/lib/commands/timeline/clipboard/paste.ts
@@ -1,9 +1,17 @@
-import { Command, type CommandResult } from "@/lib/commands/base-command";
+import {
+ Command,
+ createElementSelectionResult,
+ type CommandResult,
+} from "@/lib/commands/base-command";
import { EditorCore } from "@/core";
import type { SceneTracks, TimelineElement } from "@/lib/timeline";
import type { ElementClipboardItem } from "@/lib/clipboard";
import { generateUUID } from "@/utils/id";
-import { applyPlacement, resolveTrackPlacement, enforceMainTrackStart } from "@/lib/timeline/placement";
+import {
+ applyPlacement,
+ resolveTrackPlacement,
+ enforceMainTrackStart,
+} from "@/lib/timeline/placement";
import { cloneAnimations } from "@/lib/animation";
export class PasteCommand extends Command {
@@ -122,7 +130,7 @@ export class PasteCommand extends Command {
editor.timeline.updateTracks(updatedTracks);
if (this.pastedElements.length > 0) {
- return { select: this.pastedElements };
+ return createElementSelectionResult(this.pastedElements);
}
return undefined;
}
@@ -183,4 +191,3 @@ function buildPastedElements({
return elementsToAdd;
}
-
diff --git a/apps/web/src/lib/commands/timeline/element/duplicate-elements.ts b/apps/web/src/lib/commands/timeline/element/duplicate-elements.ts
index ab7a4a25..c044a4e3 100644
--- a/apps/web/src/lib/commands/timeline/element/duplicate-elements.ts
+++ b/apps/web/src/lib/commands/timeline/element/duplicate-elements.ts
@@ -1,8 +1,15 @@
-import { Command, type CommandResult } from "@/lib/commands/base-command";
+import {
+ Command,
+ createElementSelectionResult,
+ type CommandResult,
+} from "@/lib/commands/base-command";
import type { SceneTracks, TimelineElement } from "@/lib/timeline";
import { generateUUID } from "@/utils/id";
import { EditorCore } from "@/core";
-import { applyPlacement, resolveTrackPlacement } from "@/lib/timeline/placement";
+import {
+ applyPlacement,
+ resolveTrackPlacement,
+} from "@/lib/timeline/placement";
import { cloneAnimations } from "@/lib/animation";
interface DuplicateElementsParams {
@@ -91,9 +98,7 @@ export class DuplicateElementsCommand extends Command {
editor.timeline.updateTracks(updatedTracks);
if (this.duplicatedElements.length > 0) {
- return {
- select: this.duplicatedElements,
- };
+ return createElementSelectionResult(this.duplicatedElements);
}
return undefined;
}
diff --git a/apps/web/src/lib/commands/timeline/element/move-elements.ts b/apps/web/src/lib/commands/timeline/element/move-elements.ts
index 533c85b4..782374d5 100644
--- a/apps/web/src/lib/commands/timeline/element/move-elements.ts
+++ b/apps/web/src/lib/commands/timeline/element/move-elements.ts
@@ -1,4 +1,8 @@
-import { Command, type CommandResult } from "@/lib/commands/base-command";
+import {
+ Command,
+ createElementSelectionResult,
+ type CommandResult,
+} from "@/lib/commands/base-command";
import { EditorCore } from "@/core";
import type {
SceneTracks,
@@ -114,12 +118,12 @@ export class MoveElementCommand extends Command {
});
editor.timeline.updateTracks(updatedTracks);
- return {
- select: this.moves.map(({ elementId, targetTrackId }) => ({
+ return createElementSelectionResult(
+ this.moves.map(({ elementId, targetTrackId }) => ({
trackId: targetTrackId,
elementId,
})),
- };
+ );
}
undo(): void {
diff --git a/apps/web/src/lib/commands/timeline/element/split-elements.ts b/apps/web/src/lib/commands/timeline/element/split-elements.ts
index 0f2495f3..f172d9c4 100644
--- a/apps/web/src/lib/commands/timeline/element/split-elements.ts
+++ b/apps/web/src/lib/commands/timeline/element/split-elements.ts
@@ -1,4 +1,8 @@
-import { Command, type CommandResult } from "@/lib/commands/base-command";
+import {
+ Command,
+ createElementSelectionResult,
+ type CommandResult,
+} from "@/lib/commands/base-command";
import type { SceneTracks, TimelineElement } from "@/lib/timeline";
import { generateUUID } from "@/utils/id";
import { EditorCore } from "@/core";
@@ -164,9 +168,7 @@ export class SplitElementsCommand extends Command {
editor.timeline.updateTracks(updatedTracks);
if (this.rightSideElements.length > 0) {
- return {
- select: this.rightSideElements,
- };
+ return createElementSelectionResult(this.rightSideElements);
}
return undefined;
}