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 { snapRect, snapRectResize } from './snap';
|
||||||
import type { EditorState, ResizeHandle } from './types';
|
import type { EditorState, ResizeHandle } from './types';
|
||||||
import { clampRectToBounds } 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 =
|
export type EditorAction =
|
||||||
| { type: 'keyboard'; ctrl: boolean; space: boolean }
|
| { type: 'keyboard'; ctrl: boolean; space: boolean }
|
||||||
@ -55,12 +60,6 @@ export type EditorAction =
|
|||||||
| { type: 'sendToBackSelected' }
|
| { type: 'sendToBackSelected' }
|
||||||
| UpdateWidgetPropsAction;
|
| 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 {
|
interface DragSession {
|
||||||
kind: 'move' | 'resize';
|
kind: 'move' | 'resize';
|
||||||
startScreenX: number;
|
startScreenX: number;
|
||||||
@ -264,7 +263,7 @@ export function editorReducer(state: EditorRuntimeState, action: EditorAction):
|
|||||||
case 'video':
|
case 'video':
|
||||||
return updateWidgetProps(state, action);
|
return updateWidgetProps(state, action);
|
||||||
default:
|
default:
|
||||||
return assertNever(action.widgetType);
|
return assertNever(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user