fix: insertInlineContent adding content after cursor (BLO-1356) - #3112
matthewlipski wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughBlockNoteEditor now tracks content initialization during mount and unmount. A React browser test checks typing after styled text insertion, including after an API remount. The React Vitest configuration excludes browser test files. ChangesReact style caret positioning
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change preserves the initialization ordering needed for styled React marks, and its regression test remains in the CI browser suite. No merge-blocking risk is established. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change appears limited to editor mounting and caret behavior. No new security exposure was identified, but the renderer’s failure behavior has not been fully verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit taps the editor pane, Comment |
|
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/diagram-block
@blocknote/mantine
@blocknote/math-block
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
@blocknote/xl-typst-exporter
commit: |
| const tiptapEditor: ReactRenderer["editor"] = editor._tiptapEditor; | ||
| tiptapEditor.contentComponent = portalManager; | ||
| if (element) { | ||
| editor.mount(element); | ||
| // Render subsequent React node/mark views synchronously so their | ||
| // contentDOM is attached when ProseMirror places the selection. | ||
| tiptapEditor.isEditorContentInitialized = true; | ||
| } else { | ||
| tiptapEditor.isEditorContentInitialized = false; | ||
| editor.unmount(); |
There was a problem hiding this comment.
I'm confused how the issue relates to this fix. Also, shouldn't this be done as part of the editor.mount & editor.unmount functions?
There was a problem hiding this comment.
When inserting a React mark, is attaches contentDOM async via a ref. When isEditorContentInitialized = false, the PM state/view correctly update the document and view, and the issue comes when PM tries to sync its selection with the browser. Because the content is not yet rendered, the browser is unable to set the selection to the given offset, so the whole selection update is rejected. Rendering synchronously causes the content to be rendered straight away, so you don't get issues with PM syncing its internal selection with the browser's.
Summary
This PR makes it so that
insertInlineContentinserts the content just before the cursor rather than just after.Closes #3064
Rationale
This is more in-line with expected behavior.
Changes
tiptapEditor.isEditorContentInitializedflag on mount.Impact
N/A
Testing
Added component test.
Screenshots/Video
N/A
Checklist
Additional Notes
N/A
Summary by CodeRabbit