refactor: stabilize widget prop updates
This commit is contained in:
parent
acf61d9bee
commit
01b55b260d
@ -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<WidgetPropsByType['text']> }
|
||||
| { type: 'updateWidgetProps'; widgetType: 'image'; id: string; props: Partial<WidgetPropsByType['image']> }
|
||||
| { type: 'updateWidgetProps'; widgetType: 'iframe'; id: string; props: Partial<WidgetPropsByType['iframe']> }
|
||||
| { type: 'updateWidgetProps'; widgetType: 'video'; id: string; props: Partial<WidgetPropsByType['video']> };
|
||||
|
||||
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<WidgetPropsByType['text']> }
|
||||
| { type: 'updateWidgetProps'; widgetType: 'image'; id: string; props: Partial<WidgetPropsByType['image']> }
|
||||
| { type: 'updateWidgetProps'; widgetType: 'iframe'; id: string; props: Partial<WidgetPropsByType['iframe']> }
|
||||
| { type: 'updateWidgetProps'; widgetType: 'video'; id: string; props: Partial<WidgetPropsByType['video']> };
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user