editor: tool-defaults seeding + drawTool capability (fence presets)#346
Merged
Conversation
…umes it Adds a generic, transient `useEditor.toolDefaults` slice keyed by tool, set via `setToolDefaults(tool, params)`. A draw tool's create path merges its entry when minting a node and clears it on deactivation, so a host app can prime the next-drawn node's parameters — placing a saved preset of a drawn kind, or a future "small / medium / large" dimension picker for wall / slab / ceiling. Marks the kind with `capabilities.drawTool` (helper `isDrawnViaTool`) so host apps know to route placement through `setToolDefaults(type) + setTool(type)` instead of cloning a finished instance. Wires fence end-to-end: it declares `drawTool: true`, its create path merges `toolDefaults.fence`, and the draft preview (bar geometry, cursor, HUD label heights) reflects the seeded height/thickness so the ghost matches what will be built. The tool clears its own defaults on unmount. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
The toolDefaults-seeding commit lost the `useEditor` import (formatter stripped it), shipping a runtime ReferenceError when FenceTool mounts. Re-add it. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a generic mechanism for seeding a draw tool with build parameters, so a saved preset of a drawn kind (fence) places by re-drawing its span with the preset's parameters baked in — rather than cloning the old span at the origin.
drawToolcapability onNodeDefinition.capabilities— marks kinds that are placed by drawing a span (not by dropping an instance). Read via newisDrawnViaTool(def)/isDrawnViaToolKind(kind)helpers exported from@pascal-app/core.toolDefaultsslice onuseEditor—Partial<Record<Tool, Record<string, unknown>>>plussetToolDefaults(tool, defaults | null). Transient (not persisted). NewToolDefaultstype exported from@pascal-app/editor.fencedeclaresdrawTool: true;createFenceOnCurrentLevelmergestoolDefaults.fenceinto the minted node ahead of the user-drawnstart/end;FenceToolreads them to size its live preview and clears them on unmount so stale params can't leak into a later manual draw.The same machinery lets wall/slab/ceiling later expose a "pick small / medium / large before drawing" UI, even outside presets.
Consumed by
pascalorg/private-editor(community preset placement). Refs the community preset-system work.How to test
bun dev, open the editor.bun run check-typespasses.Screenshots / screen recording
N/A — mechanism + behavior change; the visible result (seeded fence preview) is exercised in the community shell.
Checklist
bun devbun checkto verify)mainbranch