castle-web-cli 0.4.189 → 0.4.191

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ import {
17
17
  styles,
18
18
  useMobileSheet,
19
19
  } from '@imports/castle.physics-2d/engine/ui';
20
- import { useEditHistory } from '@imports/castle.physics-2d/editors/editorHistory';
20
+ import { useEditHistory, useHostUndoRedo } from '@imports/castle.physics-2d/editors/editorHistory';
21
21
  import { useLiveDeckFiles3D, useStableSprites, fetchMissingFile } from './modelFiles';
22
22
  import { parseModelCached, parseModel, serializeModel, STARTER_MODEL_TEXT } from './pxmodel';
23
23
  import { boxMesh, extrudeFace, roundMeshInPlace } from './meshops';
@@ -236,6 +236,7 @@ export function PxModelEditor({ path }) {
236
236
  };
237
237
 
238
238
  const readOnly = useReadOnlyFile(path);
239
+ useHostUndoRedo(history, { enabled: !readOnly });
239
240
  useEditorShortcuts({
240
241
  history,
241
242
  setMode,
@@ -350,7 +351,6 @@ export function PxModelEditor({ path }) {
350
351
  <div className={styles.stageWrap} style={{ padding: 0, position: 'relative' }}>
351
352
  <StageCanvas ref={canvasRef} />
352
353
  <StageControls
353
- history={history}
354
354
  mode={mode}
355
355
  setMode={setMode}
356
356
  readOnly={readOnly}
@@ -12,7 +12,7 @@ import {
12
12
  behaviorClasses,
13
13
  findBehaviorClass,
14
14
  } from '@imports/castle.physics-2d/editors/behaviorRegistry';
15
- import { useEditHistory } from '@imports/castle.physics-2d/editors/editorHistory';
15
+ import { useEditHistory, useHostUndoRedo } from '@imports/castle.physics-2d/editors/editorHistory';
16
16
  import { BlueprintLibrary } from '@imports/castle.physics-2d/editors/BlueprintLibrary';
17
17
  import {
18
18
  EditorBody,
@@ -87,6 +87,7 @@ export function Scene3DEditor({ path }) {
87
87
  saver.schedule(filePath, nextText);
88
88
  };
89
89
  const history = useEditHistory(text, onChangeText, path);
90
+ useHostUndoRedo(history, { enabled: !readOnly });
90
91
  const isBlueprintFile = isBlueprintPath(path);
91
92
 
92
93
  const [selectedActorIds, setSelectedActorIdsRaw] = useState(stash?.selectedActorIds ?? []);
@@ -355,7 +356,6 @@ export function Scene3DEditor({ path }) {
355
356
  <div className={styles.stageWrap} style={{ padding: 0, position: 'relative' }}>
356
357
  <StageCanvas ref={canvasRef} />
357
358
  <StageControls
358
- history={history}
359
359
  mode={mode}
360
360
  setMode={setMode}
361
361
  readOnly={readOnly}
@@ -1,7 +1,7 @@
1
1
  // Chrome shared by the kit's editors (scene + model): the debounced file
2
- // saver, the stage canvas, the undo/redo + mode/action button overlays, and
3
- // the common keyboard shortcuts. One place so the editors stay in the same
4
- // design system by construction.
2
+ // saver, the stage canvas, the mode/action button overlays, and the common
3
+ // keyboard shortcuts. One place so the editors stay in the same design
4
+ // system by construction.
5
5
  import React, { forwardRef, useEffect, useRef } from 'react';
6
6
  import { isImportedFile, onBeforeRestart, writeFile } from 'castle-web-sdk';
7
7
  import { useForkedPaths } from '@imports/castle.physics-2d/editors/SingleEditor';
@@ -60,15 +60,6 @@ export function HotbarButton({ icon, glyph, label, ...props }) {
60
60
  // Stage tool buttons run a bit bigger than the default IconButton.
61
61
  export const TOOL_BUTTON_STYLE = { width: 40, height: 40, fontSize: 17 };
62
62
 
63
- const UNDO_STYLE = {
64
- position: 'absolute',
65
- left: 10,
66
- top: 10,
67
- display: 'flex',
68
- flexDirection: 'row',
69
- gap: 6,
70
- zIndex: 5,
71
- };
72
63
  const MODE_STYLE = {
73
64
  position: 'absolute',
74
65
  right: 8,
@@ -205,10 +196,9 @@ export const StageCanvas = forwardRef(function StageCanvas(props, ref) {
205
196
  );
206
197
  });
207
198
 
208
- // Undo/redo top-left; select/move/rotate (plus duplicate/delete when handlers
209
- // are given) down the right edge.
199
+ // Select/move/rotate (plus duplicate/delete when handlers are given) down
200
+ // the right edge. Undo/redo live on the host chrome.
210
201
  export function StageControls({
211
- history,
212
202
  mode,
213
203
  setMode,
214
204
  onDuplicate,
@@ -230,47 +220,29 @@ export function StageControls({
230
220
  return <div style={MODE_STYLE}>{modeButton('select', 'marquee', 'Select (1)')}</div>;
231
221
  }
232
222
  return (
233
- <>
234
- <div style={UNDO_STYLE}>
223
+ <div style={MODE_STYLE}>
224
+ {modeButton('select', 'marquee', 'Select (1)')}
225
+ {modeButton('move', 'move', 'Move (2)')}
226
+ {modeButton('rotate', 'rotate', 'Rotate (3)')}
227
+ {onDuplicate || onDelete ? <div style={{ height: 8 }} /> : null}
228
+ {onDuplicate ? (
235
229
  <IconButton
236
- icon="undo"
237
- label="Undo"
230
+ icon="clone"
231
+ label="Duplicate"
238
232
  style={TOOL_BUTTON_STYLE}
239
- onClick={history.undo}
240
- disabled={!history.canUndo}
233
+ disabled={actionsDisabled}
234
+ onClick={onDuplicate}
241
235
  />
236
+ ) : null}
237
+ {onDelete ? (
242
238
  <IconButton
243
- icon="redo"
244
- label="Redo"
239
+ icon="trash"
240
+ label="Delete"
245
241
  style={TOOL_BUTTON_STYLE}
246
- onClick={history.redo}
247
- disabled={!history.canRedo}
242
+ disabled={actionsDisabled}
243
+ onClick={onDelete}
248
244
  />
249
- </div>
250
- <div style={MODE_STYLE}>
251
- {modeButton('select', 'marquee', 'Select (1)')}
252
- {modeButton('move', 'move', 'Move (2)')}
253
- {modeButton('rotate', 'rotate', 'Rotate (3)')}
254
- {onDuplicate || onDelete ? <div style={{ height: 8 }} /> : null}
255
- {onDuplicate ? (
256
- <IconButton
257
- icon="clone"
258
- label="Duplicate"
259
- style={TOOL_BUTTON_STYLE}
260
- disabled={actionsDisabled}
261
- onClick={onDuplicate}
262
- />
263
- ) : null}
264
- {onDelete ? (
265
- <IconButton
266
- icon="trash"
267
- label="Delete"
268
- style={TOOL_BUTTON_STYLE}
269
- disabled={actionsDisabled}
270
- onClick={onDelete}
271
- />
272
- ) : null}
273
- </div>
274
- </>
245
+ ) : null}
246
+ </div>
275
247
  );
276
248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-cli",
3
- "version": "0.4.189",
3
+ "version": "0.4.191",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/castle-xyz/castle-experimental-web.git"