From 01b55b260de70ec8ccd245e4f593e1b51d83cea7 Mon Sep 17 00:00:00 2001 From: clawdbot Date: Wed, 28 Jan 2026 20:49:58 +0800 Subject: [PATCH] refactor: stabilize widget prop updates --- packages/editor/src/editor/store.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/editor/src/editor/store.ts b/packages/editor/src/editor/store.ts index 4f1a416..414e48b 100644 --- a/packages/editor/src/editor/store.ts +++ b/packages/editor/src/editor/store.ts @@ -16,6 +16,11 @@ import { didRectsChange } from './history'; import { snapRect, snapRectResize } from './snap'; import type { EditorState, ResizeHandle } from './types'; import { clampRectToBounds } from './types'; +type UpdateWidgetPropsAction = + | { type: 'updateWidgetProps'; widgetType: 'text'; id: string; props: Partial } + | { type: 'updateWidgetProps'; widgetType: 'image'; id: string; props: Partial } + | { type: 'updateWidgetProps'; widgetType: 'iframe'; id: string; props: Partial } + | { type: 'updateWidgetProps'; widgetType: 'video'; id: string; props: Partial }; export type EditorAction = | { type: 'keyboard'; ctrl: boolean; space: boolean } @@ -55,12 +60,6 @@ export type EditorAction = | { type: 'sendToBackSelected' } | UpdateWidgetPropsAction; -type UpdateWidgetPropsAction = - | { type: 'updateWidgetProps'; widgetType: 'text'; id: string; props: Partial } - | { type: 'updateWidgetProps'; widgetType: 'image'; id: string; props: Partial } - | { type: 'updateWidgetProps'; widgetType: 'iframe'; id: string; props: Partial } - | { type: 'updateWidgetProps'; widgetType: 'video'; id: string; props: Partial }; - interface DragSession { kind: 'move' | 'resize'; startScreenX: number; @@ -264,7 +263,7 @@ export function editorReducer(state: EditorRuntimeState, action: EditorAction): case 'video': return updateWidgetProps(state, action); default: - return assertNever(action.widgetType); + return assertNever(action); } }