Skip to content

feat(app): drag a Block Type from the Block Palette onto the Worksheet (#6) - #17

Merged
rotespferd merged 4 commits into
mainfrom
feat/issue-6
Oct 18, 2026
Merged

rotespferd merged 4 commits into
mainfrom
feat/issue-6

Conversation

@rotespferd

Copy link
Copy Markdown
Contributor

Closes #6

Summary

<App>
  <WorksheetProvider>
+   <WorksheetDnd>            # dnd-kit PointerSensor, tracks the live pointer, owns the insertion index
      <BlockPalette>
+       <PaletteEntry>        # draggable; click still inserts
      <Worksheet>
+       <Page> (droppable)    # only the Page accepts drops, not the grey area
+         <InsertionLine />   # at the would-be index
          <BlockHost data-block-id>
onDragEnd
  index = dropIndex(rects of Blocks in Worksheet order, pointer Y)   # src/worksheet/drop-index.ts
  if over Page
    after two animation frames: insert(blockType, index)             # selected + focused

Two non-obvious points:

  • dnd-kit's drag delta includes scrolling, so the pointer position is tracked directly. Otherwise a mid-drag scroll puts the drop at the wrong index.
  • The Block is inserted two frames after pointer release. Inserting inside the release leaves a focused Block with no caret in WebKitGTK, so it cannot be typed into.

Evidence

  • Before: scroll 600px mid-drag over 30 Blocks (Firefox): line expected at 20, drop landed at 30. In WebKitGTK, after dropping Heading, Heading, Body Text, Body Text, typing did nothing (["", "", ...]).
    After: line and drop both at 20. Typing lands in every dropped Block: ["C","F","E","D","A","B"].
vitest: 57 passed (palette-drag.test.tsx: click inserts, insertion line, drop at index,
        append on Page remainder / empty Worksheet, outside Page, grey area, Escape)

Driven with real mouse input in Firefox (drag, drop, append, grey area, outside, Escape, click, scroll) and WebKitGTK (typing after each drop). Not run in the Tauri shell itself.

Merge Danger

Door: two-way

Blast Radius: Worksheet

Adds @dnd-kit/core. The Escape key also clears the selected Block during a drag, through the Worksheet's existing handler. The Linux Tauri criterion is verified only through WebKitGTK, not pnpm tauri dev.

🤖 Generated with Claude Code

rotespferd and others added 4 commits October 17, 2026 13:44
#6)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rksheet state (#6)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… the drop position right (#6)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…typing (#6)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@rotespferd
rotespferd merged commit 5905f3f into main Oct 18, 2026
1 check passed
@rotespferd rotespferd added the feature New feature or request label Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: drag a Block Type from the Block Palette onto the Worksheet

1 participant