Skip to content

Commit 2ae148c

Browse files
committed
fix(editor2): support move camera action
1 parent bf76b98 commit 2ae148c

File tree

2 files changed

+88
-4
lines changed

2 files changed

+88
-4
lines changed

src/components/editor2/action/ActionItem.tsx

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,11 @@ export const ActionItem: FC<ActionItemProps> = memo(
198198
<NumericInput2
199199
intOnly
200200
buttonPosition="none"
201-
inputClassName="!w-9 mx-px mt-1 !p-0 !leading-3 hover:!bg-gray-100 focus:!bg-gray-100 dark:hover:!bg-gray-600 dark:focus:!bg-gray-600 !border-0 !rounded [&:not(:focus)]:!shadow-none !text-inherit text-3xl font-semibold text-center"
201+
inputClassName="!min-w-[2ch] mx-px mt-1 !p-0 !leading-3 hover:!bg-gray-100 focus:!bg-gray-100 dark:hover:!bg-gray-600 dark:focus:!bg-gray-600 !border-0 !rounded [&:not(:focus)]:!shadow-none !text-inherit text-3xl font-semibold text-center"
202+
style={{
203+
width:
204+
String(action.location?.[0] ?? 0).length + 'ch',
205+
}}
202206
value={action.location?.[0] ?? ''}
203207
wheelStepSize={1}
204208
onValueChange={(v) => {
@@ -209,7 +213,7 @@ export const ActionItem: FC<ActionItemProps> = memo(
209213
return {
210214
action: 'set-action-location-x-' + action.id,
211215
desc: i18n.actions.editor2.set_action_location,
212-
squash: false,
216+
squash: true,
213217
}
214218
})
215219
}}
@@ -220,7 +224,11 @@ export const ActionItem: FC<ActionItemProps> = memo(
220224
<NumericInput2
221225
intOnly
222226
buttonPosition="none"
223-
inputClassName="!w-9 mx-px mt-1 !p-0 !leading-3 hover:!bg-gray-100 focus:!bg-gray-100 dark:hover:!bg-gray-600 dark:focus:!bg-gray-600 !border-0 !rounded [&:not(:focus)]:!shadow-none !text-inherit text-3xl font-semibold text-center"
227+
inputClassName="!min-w-[2ch] mx-px mt-1 !p-0 !leading-3 hover:!bg-gray-100 focus:!bg-gray-100 dark:hover:!bg-gray-600 dark:focus:!bg-gray-600 !border-0 !rounded [&:not(:focus)]:!shadow-none !text-inherit text-3xl font-semibold text-center"
228+
style={{
229+
width:
230+
String(action.location?.[1] ?? 0).length + 'ch',
231+
}}
224232
value={action.location?.[1] ?? ''}
225233
wheelStepSize={1}
226234
onValueChange={(v) => {
@@ -231,7 +239,7 @@ export const ActionItem: FC<ActionItemProps> = memo(
231239
return {
232240
action: 'set-action-location-y-' + action.id,
233241
desc: i18n.actions.editor2.set_action_location,
234-
squash: false,
242+
squash: true,
235243
}
236244
})
237245
}}
@@ -247,6 +255,78 @@ export const ActionItem: FC<ActionItemProps> = memo(
247255
</>
248256
),
249257
)}
258+
{renderForTypes(
259+
[CopilotDocV1.Type.MoveCamera],
260+
({ action, setAction }) => (
261+
<>
262+
<div className="grow self-stretch max-w-10 flex flex-col items-center text-xs">
263+
<Divider className="grow rotate-12" />
264+
</div>
265+
<div className="shrink-0">
266+
<div className="flex items-center text-3xl">
267+
<span className="text-gray-300 dark:text-gray-600">
268+
{'('}
269+
</span>
270+
<NumericInput2
271+
intOnly
272+
buttonPosition="none"
273+
inputClassName="!min-w-[2ch] mx-px mt-1 !p-0 !leading-3 hover:!bg-gray-100 focus:!bg-gray-100 dark:hover:!bg-gray-600 dark:focus:!bg-gray-600 !border-0 !rounded [&:not(:focus)]:!shadow-none !text-inherit text-3xl font-semibold text-center"
274+
value={action.distance?.[0] ?? ''}
275+
style={{
276+
width:
277+
String(action.distance?.[0] ?? 0).length + 'ch',
278+
}}
279+
wheelStepSize={1}
280+
onValueChange={(v) => {
281+
edit(() => {
282+
setAction((draft) => {
283+
draft.distance = [v, draft.distance?.[1] ?? 0]
284+
})
285+
return {
286+
action: 'set-action-distance-x-' + action.id,
287+
desc: i18n.actions.editor2.set_action_distance,
288+
squash: true,
289+
}
290+
})
291+
}}
292+
/>
293+
<span className="mt-3 text-gray-300 dark:text-gray-600 text-xl font-serif">
294+
,
295+
</span>
296+
<NumericInput2
297+
intOnly
298+
buttonPosition="none"
299+
inputClassName="!min-w-[2ch] mx-px mt-1 !p-0 !leading-3 hover:!bg-gray-100 focus:!bg-gray-100 dark:hover:!bg-gray-600 dark:focus:!bg-gray-600 !border-0 !rounded [&:not(:focus)]:!shadow-none !text-inherit text-3xl font-semibold text-center"
300+
value={action.distance?.[1] ?? ''}
301+
style={{
302+
width:
303+
String(action.distance?.[1] ?? 0).length + 'ch',
304+
}}
305+
wheelStepSize={1}
306+
onValueChange={(v) => {
307+
edit(() => {
308+
setAction((draft) => {
309+
draft.distance = [draft.distance?.[0] ?? 0, v]
310+
})
311+
return {
312+
action: 'set-action-distance-y-' + action.id,
313+
desc: i18n.actions.editor2.set_action_distance,
314+
squash: true,
315+
}
316+
})
317+
}}
318+
/>
319+
<span className="text-gray-300 dark:text-gray-600">
320+
{')'}
321+
</span>
322+
</div>
323+
<div className="text-xs text-gray-500">
324+
{t.components.editor2.label.operation.actions.distance}
325+
</div>
326+
</div>
327+
</>
328+
),
329+
)}
250330
{renderForTypes(
251331
[CopilotDocV1.Type.Deploy],
252332
({ action, setAction }) => (

src/i18n/translations.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
"cn": "修改动作的位置",
106106
"en": "Change Action's Location"
107107
},
108+
"set_action_distance": {
109+
"cn": "修改动作的距离",
110+
"en": "Change Action's Distance"
111+
},
108112
"set_action_direction": {
109113
"cn": "修改动作的朝向",
110114
"en": "Change Action's Direction"

0 commit comments

Comments
 (0)