From b252a80a8ebe6428e6637fcef6699e72c6465f92 Mon Sep 17 00:00:00 2001 From: clawdbot Date: Thu, 29 Jan 2026 06:50:03 +0800 Subject: [PATCH] feat(editor): inspector rect x/y/w/h --- packages/editor/src/editor/EditorApp.tsx | 1 + packages/editor/src/editor/Inspector.tsx | 65 +++++++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/packages/editor/src/editor/EditorApp.tsx b/packages/editor/src/editor/EditorApp.tsx index e3bf740..6c007d7 100644 --- a/packages/editor/src/editor/EditorApp.tsx +++ b/packages/editor/src/editor/EditorApp.tsx @@ -563,6 +563,7 @@ export function EditorApp() { dispatch({ type: 'updateWidgetRect', id, rect: patch })} onUpdateTextProps={(id, props) => dispatch({ type: 'updateWidgetProps', widgetType: 'text', id, props }) } diff --git a/packages/editor/src/editor/Inspector.tsx b/packages/editor/src/editor/Inspector.tsx index 331ffe1..0be4b6a 100644 --- a/packages/editor/src/editor/Inspector.tsx +++ b/packages/editor/src/editor/Inspector.tsx @@ -1,4 +1,4 @@ -import { Input, InputNumber, Select, Space, Typography } from 'antd'; +import { Divider, Input, InputNumber, Select, Space, Typography } from 'antd'; import { assertNever, type WidgetNode, type TextWidgetNode, type WidgetNodeByType } from '@astralview/sdk'; type ImageWidgetNode = WidgetNodeByType['image']; @@ -7,6 +7,7 @@ type VideoWidgetNode = WidgetNodeByType['video']; export function Inspector(props: { selected?: WidgetNode; + onUpdateRect: (id: string, patch: Partial) => void; onUpdateTextProps: (id: string, patch: Partial) => void; onUpdateImageProps: (id: string, patch: Partial) => void; onUpdateIframeProps: (id: string, patch: Partial) => void; @@ -18,6 +19,60 @@ export function Inspector(props: { return No selection.; } + const rectDisabled = !!node.locked; + + const RectSection = ( +
+ Rect + + props.onUpdateRect(node.id, { x: typeof v === 'number' ? v : node.rect.x })} + style={{ width: 90 }} + addonBefore="X" + /> + props.onUpdateRect(node.id, { y: typeof v === 'number' ? v : node.rect.y })} + style={{ width: 90 }} + addonBefore="Y" + /> + props.onUpdateRect(node.id, { w: typeof v === 'number' ? v : node.rect.w })} + style={{ width: 96 }} + addonBefore="W" + /> + props.onUpdateRect(node.id, { h: typeof v === 'number' ? v : node.rect.h })} + style={{ width: 96 }} + addonBefore="H" + /> + + {rectDisabled ? ( + + Locked layer: rect editing disabled. + + ) : null} + +
+ ); + switch (node.type) { case 'image': return ( @@ -26,6 +81,8 @@ export function Inspector(props: { Image + {RectSection} + Source + {RectSection} + Source + {RectSection} + Source + {RectSection} + Content