feat: add toc toolbar item#3247
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1456204222
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const containing = index.candidates.filter((c) => pos >= c.pos && pos < c.pos + c.node.nodeSize); | ||
| const anchor = | ||
| containing.length > 0 ? containing.reduce((a, b) => (a.node.nodeSize < b.node.nodeSize ? a : b)) : null; | ||
|
|
There was a problem hiding this comment.
Anchor TOC insertion outside nested TOC entry blocks
Selecting the smallest containing block here causes failures when the cursor is inside an existing TOC entry paragraph: toBlockAddress(anchor) resolves to that inner paragraph, so prepareTableOfContentsInsertion(..., { at: { kind: 'after', target } }) returns a position inside a tableOfContents node (whose content only allows paragraphs), and insertTableOfContentsAt then no-ops after a RangeError. In that context the toolbar button appears enabled but clicking it does nothing; the anchor should be promoted to an enclosing insertable block (e.g., the TOC block itself or another valid outer block).
Useful? React with 👍 / 👎.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
No description provided.