feat: Trailing block extension rewrite#2733
Conversation
…tead of actual node, udpated tests & examples
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedToo many files! This PR contains 242 files, which is 92 over the limit of 150. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (33)
📒 Files selected for processing (242)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@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
commit: |
| const blockContainerType = | ||
| view.state.schema.nodes["blockContainer"]; | ||
| const paragraphType = view.state.schema.nodes["paragraph"]; | ||
| const node = blockContainerType.create( | ||
| undefined, | ||
| paragraphType.create(), | ||
| ); | ||
| const insertPos = view.state.doc.content.size - 1; | ||
| const tr = view.state.tr.insert(insertPos, node); | ||
| tr.setSelection(TextSelection.create(tr.doc, insertPos + 2)); | ||
| tr.scrollIntoView(); | ||
| view.dispatch(tr); | ||
| view.focus(); |
There was a problem hiding this comment.
why not blocknote apis for this?
| // Maps the existing DecorationSet through the transaction, then | ||
| // incrementally adds or removes the widget only if the show/hide state | ||
| // crossed over. The underlying Decoration (and its rendered DOM) stays | ||
| // reference-stable across transactions. | ||
| function nextDecorationSet( | ||
| tr: Transaction, | ||
| oldSet: DecorationSet, | ||
| ): DecorationSet { | ||
| const mapped = oldSet.map(tr.mapping, tr.doc); | ||
| const existing = mapped.find(); | ||
| const wasShowing = existing.length > 0; | ||
| const shouldShow = shouldShowTrailingWidget(tr.doc); | ||
|
|
||
| if (!lastContentNode) { | ||
| throw new Error("Expected blockContent"); | ||
| } | ||
| if (wasShowing === shouldShow) { | ||
| return mapped; | ||
| } | ||
| if (wasShowing) { | ||
| return mapped.remove(existing); | ||
| } | ||
| return mapped.add(tr.doc, [ | ||
| createTrailingWidget(tr.doc.content.size - 1), | ||
| ]); | ||
| } |
Summary
Rationale
Changes
Impact
Testing
Screenshots/Video
Checklist
Additional Notes