Skip to content

feat: add block windowing support#36

Draft
srubin wants to merge 5 commits into
main-pojofrom
codex/script-block-windowing
Draft

feat: add block windowing support#36
srubin wants to merge 5 commits into
main-pojofrom
codex/script-block-windowing

Conversation

@srubin

@srubin srubin commented Jul 12, 2026

Copy link
Copy Markdown

Summary

Adds opt-in block windowing while keeping the generic lifecycle and DOM protocol inside the Draft fork:

  • useDraftEditorBlockWindowing owns measurement, resize invalidation, viewport/overscan calculation, selection-endpoint pinning, and consumer-supplied pinned block keys.
  • Stable measurements preserve object identity when ordered block heights have not changed, avoiding a redundant contents render after each edit.
  • Structural edits retain measured heights by block key and estimate only new keys from their measured neighbors until the new blocks render.
  • Height-only editor resizes no longer invalidate the entire layout; width changes still trigger a full remeasurement because text wrapping can change every block's height.
  • DraftEditor replaces omitted runs with inert height spacers while preserving custom block elements and wrapper runs across window seams.
  • Offset helpers map both directions needed by consumers: viewport positions to Draft text offsets and Draft text offsets to block keys.

Also bumps the package to 0.11.6-descript.35 for the dependent Descript PR.

Dependent PR: https://github.com/descriptinc/descript/pull/36590

Test plan

  • mise exec node@20 -- pnpm exec jest --runInBand --no-watchman src/component/hooks/__tests__/useDraftEditorBlockWindowing-test.ts src/component/contents/__tests__/getDraftEditorWindowedTextOffset-test.ts src/component/contents/__tests__/DraftEditorContents.react-test.tsx (14 tests pass)
  • ESLint passes for all changed source and test files.
  • mise exec node@20 -- pnpm build completes and emits the new declarations.

The focused tests cover window-range math, stable measurement equality, hook lifecycle and pinning, structural edits with height-only resize notifications, spacer offset mapping, and custom wrapper continuity. Repository-wide declaration checking still reports the fork's existing Node-global and old TypeScript lib-target warnings in unrelated files.

@srubin srubin self-assigned this Jul 12, 2026
@srubin srubin force-pushed the codex/script-block-windowing branch from 2c46c8f to 8fdca30 Compare July 13, 2026 13:40
@srubin srubin requested a review from marcello3d July 13, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant