feat(toc): add headings extraction, scroll-to-range, and per-editor TOC integration#89
Open
sospartan wants to merge 1 commit into
Open
feat(toc): add headings extraction, scroll-to-range, and per-editor TOC integration#89sospartan wants to merge 1 commit into
sospartan wants to merge 1 commit into
Conversation
…OC integration - DocumentHeading: public struct (level, title, source-coordinate range) - HeadingExtractor: AST-based ATX heading collection (excludes code blocks, strips inline markup from title text) - NativeTextViewWrapper.onHeadingsDidChange: closure callback for embedder TOC panels, called after text changes (deduplicated) - ScrollHandler: per-editor NSObject bridge; embedder passes to wrapper, engine fills handler in makeNSView for direct scroll invocation - scrollRangeIntoView(_:in:): shared TextKit-2 layout-fragment scroll helper (also used by find-match reveal) - HeadingsBusTests: 4 unit tests for heading extraction
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.
Summary
Adds public heading-extraction and scroll-to-heading APIs so an embedder can build an outline / TOC panel alongside the editor.
Problem
The engine rendered headings, but there was no public way to:
This made it impossible to build a navigation / TOC sidebar without re-parsing the Markdown outside the engine.
Solution
DocumentHeading— public struct describing one heading (level,title,rangein source coordinates).HeadingExtractor— AST-based collector for ATX headings; excludes headings inside code blocks and strips inline markup from the title text.NativeTextViewWrapper.onHeadingsDidChange— closure callback that fires after text changes with the current heading list (deduplicated).ScrollHandler— per-editorNSObjectbridge that the embedder owns and the engine fills inmakeNSView, so the embedder can request scrolls directly.scrollRangeIntoView(_:in:)— shared TextKit 2 layout-fragment scroll helper used by both TOC reveal and existing find-match reveal.HeadingsBusTests— unit tests covering heading extraction, code-block exclusion, and title-stripping.