Add offscreen block skeletons - #37
Conversation
Native browser selection stops at contentEditable boundaries, so skeletonized editors could select only the current rendered block. Build the full-editor selection in Draft while leaving custom key bindings in control.
designlooking at this PR and https://github.com/descriptinc/descript/pull/38103, my understanding is that this approach exposes
I don't love that the script feature builder has to know when to opt in to declare a parallel one alternative is to remove the need to match skeleton height against full rendering height:
wdyt? verificationI was going to try some scrolling in the https://github.com/descriptinc/descript/pull/38103 preview build but I suppose that depends on merging and publishing this, so I'll leave the verification to you! the concern is that if the skeleton height and full render height diverge, since further notesmore claude-written notes in https://app.notion.com/p/descript/Script-skeleton-height-parity-vs-scroll-compensation-design-notes-3b2abe2e1a50819c969fcd2843131a86 |
I agree with the principle that this API is too broad!
This sounds more complex and error-prone than requiring a little bit of upfront developer effort and then relying on the browser to handle scrolling entirely on its own. But I'll noodle on it.
Agreed! There's no reason to expose a full suite of attributes when all we need is an id.
I can always publish interim versions of draft-js for testing in the descript PRs. Will do once I take another pass.
We might not even need the content visibility stuff anymore if we turn on skeletons, since the offscreen nodes will be very simple. We should profile that.
|
yeah fair, I'm probably oversimplifying it, maybe worth a quick prototype to see if it's feasible? also, my claude keeps suggesting that the native |
For sure, will try it out! |
Summary
Adds an Editor-owned block skeleton mode for large documents. Offscreen blocks keep one editable, text-containing DOM subtree while skipping block renderers, decorator components, and leaf components. Selected and near-viewport blocks use the normal renderer.
Visibility uses one
IntersectionObserverwith 500 px overscan; aMutationObserverregisters structural edits without a render-all measurement frame. Native scroll anchoring preserves position as blocks promote. Browsers that explicitly report no anchoring support retain full rendering.Decorators can expose stable DOM IDs through
getDOMAnchorIdsForRange. Draft renders the same anchor wrapper in full and skeleton output, keeping addressable IDs without exposing an arbitrary skeleton-attributes API.Skeleton text inherits the editor's
contentEditable, so native selection, select-all, caret movement, and editing work without pinned blocks or keyboard special cases.Test Plan
Full suite: 44 suites passed; 402 tests passed, 3 skipped; 500 snapshots passed.
Lint passes.
Build exits successfully.
Downstream production-mode UI coverage verifies select-all, distant caret promotion, autoscroll, typing, and timeline seek behavior.
I used AI