mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-14 22:02:36 +00:00
The previous panel-undo fix used session boundaries (open on first edit, commit on selection change / unmount). It overshot: while editing the same object's panel without changing selection, the session never committed, so Ctrl+Z fell through to the most recent *previous* entry — typically the CreateAction that added the shape. Result: editing a shape's transform then hitting Ctrl+Z deleted the shape. Replace session boundaries with action-level coalescing: - Add optional `tryMerge(other)` to the UndoableAction interface. HistoryManager.record now offers each new action to the previous entry's tryMerge first; if absorbed, the new action drops out and the existing entry's `after` extends to cover the burst. - TransformAction: constructor now takes (editor, uuid, before, after) directly; drop the begin/commit pattern. tryMerge merges a follow-up TransformAction whose `before` matches this one's `after` (chain continuity) — same uuid only. - ColorAction: same treatment. tryMerge folds the native color picker's per-pixel onChange burst into a single undo entry. Caller-side: drop all session machinery from the panel (transformSessionRef, colorSessionRef, lastUuidRef, beginPanelTransform, commitPanelTransform, the unmount-only effect). On every input change the panel calls `transformObject` / `setObjectColor`, which snapshot before, apply, snapshot after, and record. The manager handles the rest. Gizmo path in editor.ts updated to the new TransformAction shape: capture before-snap at dragstart on a small `activeDragStart` ref, build TransformAction(before, after) at dragend. Side benefit: gizmo-drag and panel-edit bursts on the same object now coalesce into a single undo entry across input sources, since both produce TransformActions whose chain continues.
Frontend
This is an nx monorepo that can contain multiple apps and shared libraries.
All commands to run these projects are performed from this directory.
Install dependencies
npm install
Editor2d
Run dev server:
nx dev editor2d
artcraft
Run dev server:
nx dev artcraft
call when starting on main or a new branch:
./clean_modules
The names for @frontend and @storyteller come from the package.json file in the libs folder.
import { Login } from "@frontend/login";
import { api } from "@storyteller/api";
For shared UI components, import from @storyteller/ui-[componentname].
import { Button } from "@storyteller/ui-button";
import { Modal } from "@storyteller/ui-modal";
building:
npx nx build artcraft
npx nx build editor2d
dev:
npx nx dev artcraft
npx nx dev editor2d
# component build
1.
npx nx g @nx/react:library libs/components/toaster --import-path=@storyteller/ui-toaster --bundler=vite
npm install
2.import it first in code
3.nx sync
4.nx build
or
# frontend build
in frontend folder
% nx build -project type
% nx build artcraft
% nx dev artcraft