mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
PageScene: record color changes via HistoryManager
Color picker is the third interactive surface (after gizmo drag and outliner toggles) that mutates an object. Wire it the same way: record in the onChange handler (input type="color" fires once per committed pick, so one undo entry per user choice). Object Panel transform inputs (position/rotation/scale text fields) are still on the legacy diff path. Wiring them is one more pass — they need a coalescer because each keystroke flushes to the engine. Tracking that as a follow-up.
This commit is contained in:
1 parent
bab0f62973
commit
39f4c84241
1 file changed
+11
-5
+11
-5
@@ -220,11 +220,17 @@ export const ControlPanelSceneObject = () => {
|
||||
className="h-0 w-0 cursor-pointer opacity-0"
|
||||
id={colorInputId}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
||||
editorEngine?.activeScene.setColor(
|
||||
editorEngine?.selected?.uuid || "",
|
||||
e.target.value,
|
||||
);
|
||||
setColor(e.target.value);
|
||||
// <input type="color"> fires onChange once per committed
|
||||
// pick (when the picker closes), so recording here gives
|
||||
// exactly one undo entry per user-visible color change.
|
||||
const uuid = editorEngine?.selected?.uuid;
|
||||
const before = color;
|
||||
const after = e.target.value;
|
||||
editorEngine?.activeScene.setColor(uuid || "", after);
|
||||
if (uuid) {
|
||||
editorEngine?.history.recordSetColor(uuid, before, after);
|
||||
}
|
||||
setColor(after);
|
||||
}}
|
||||
type="color"
|
||||
value={color}
|
||||
|
||||
Reference in new issue
Block a user