Skip to content

editor: tool-defaults seeding + drawTool capability (fence presets)#346

Merged
wass08 merged 2 commits into
mainfrom
feat/tool-defaults-fence-preset
May 29, 2026
Merged

editor: tool-defaults seeding + drawTool capability (fence presets)#346
wass08 merged 2 commits into
mainfrom
feat/tool-defaults-fence-preset

Conversation

@wass08
Copy link
Copy Markdown
Collaborator

@wass08 wass08 commented May 29, 2026

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.

  • drawTool capability on NodeDefinition.capabilities — marks kinds that are placed by drawing a span (not by dropping an instance). Read via new isDrawnViaTool(def) / isDrawnViaToolKind(kind) helpers exported from @pascal-app/core.
  • toolDefaults slice on useEditorPartial<Record<Tool, Record<string, unknown>>> plus setToolDefaults(tool, defaults | null). Transient (not persisted). New ToolDefaults type exported from @pascal-app/editor.
  • Fence consumes it: fence declares drawTool: true; createFenceOnCurrentLevel merges toolDefaults.fence into the minted node ahead of the user-drawn start/end; FenceTool reads 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

  1. bun dev, open the editor.
  2. Draw a fence, customize it (height, style, post spacing), and save it as a preset (via the community shell).
  3. Place the preset: the fence tool activates and the live preview reflects the preset's height/thickness.
  4. Click two points — the new fence is built with the preset's build parameters at the span you drew.
  5. Activate the fence tool manually afterward: it draws with plain defaults (preset params were cleared on tool unmount).
  6. bun run check-types passes.

Screenshots / screen recording

N/A — mechanism + behavior change; the visible result (seeded fence preview) is exercised in the community shell.

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

…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>
@mintlify
Copy link
Copy Markdown

mintlify Bot commented May 29, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
pascal 🔴 Failed May 29, 2026, 12:24 PM

💡 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>
@wass08 wass08 merged commit b8d94a6 into main May 29, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant