summaryrefslogtreecommitdiff
path: root/apps/web/src/stores
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2025-07-09 23:59:39 +0200
committerMaze Winther <mazewinther@gmail.com>2025-07-09 23:59:39 +0200
commit8dd6f9a9b3da6a5c683d91bd647a60198955317f (patch)
treec354f2614ff4f0e3785635b842c22f3e9456e264 /apps/web/src/stores
parentb6aa8e10d69ccf547f3cb0051d10fda014a2d01e (diff)
downloadopencut-8dd6f9a9b3da6a5c683d91bd647a60198955317f.tar.gz
feat: add conditional rendering to properties panel with text change functionality
Diffstat (limited to 'apps/web/src/stores')
-rw-r--r--apps/web/src/stores/timeline-store.ts41
1 files changed, 41 insertions, 0 deletions
diff --git a/apps/web/src/stores/timeline-store.ts b/apps/web/src/stores/timeline-store.ts
index 7431e085..8c934392 100644
--- a/apps/web/src/stores/timeline-store.ts
+++ b/apps/web/src/stores/timeline-store.ts
@@ -4,6 +4,7 @@ import {
TimelineElement,
CreateTimelineElement,
TimelineTrack,
+ TextElement,
sortTracksByOrder,
ensureMainTrack,
validateElementTrackCompatibility,
@@ -136,6 +137,28 @@ interface TimelineStore {
loadProjectTimeline: (projectId: string) => Promise<void>;
saveProjectTimeline: (projectId: string) => Promise<void>;
clearTimeline: () => void;
+ updateTextElement: (
+ trackId: string,
+ elementId: string,
+ updates: Partial<
+ Pick<
+ TextElement,
+ | "content"
+ | "fontSize"
+ | "fontFamily"
+ | "color"
+ | "backgroundColor"
+ | "textAlign"
+ | "fontWeight"
+ | "fontStyle"
+ | "textDecoration"
+ | "x"
+ | "y"
+ | "rotation"
+ | "opacity"
+ >
+ >
+ ) => void;
}
export const useTimelineStore = create<TimelineStore>((set, get) => {
@@ -494,6 +517,24 @@ export const useTimelineStore = create<TimelineStore>((set, get) => {
);
},
+ updateTextElement: (trackId, elementId, updates) => {
+ get().pushHistory();
+ updateTracksAndSave(
+ get()._tracks.map((track) =>
+ track.id === trackId
+ ? {
+ ...track,
+ elements: track.elements.map((element) =>
+ element.id === elementId && element.type === "text"
+ ? { ...element, ...updates }
+ : element
+ ),
+ }
+ : track
+ )
+ );
+ },
+
splitElement: (trackId, elementId, splitTime) => {
const { _tracks } = get();
const track = _tracks.find((t) => t.id === trackId);