Skip to content

fix(document): blocknote editor service, wrap arround#256

Merged
KevinNitroG merged 2 commits into
mainfrom
kevinnitro/document-svc-blocknote-editor-no-singleton
May 18, 2026
Merged

fix(document): blocknote editor service, wrap arround#256
KevinNitroG merged 2 commits into
mainfrom
kevinnitro/document-svc-blocknote-editor-no-singleton

Conversation

@KevinNitroG
Copy link
Copy Markdown
Member

@KevinNitroG KevinNitroG commented May 18, 2026

@coderabbitai please check

https://raw.githubusercontent.com/TypeCellOS/BlockNote/refs/heads/main/docs/content/docs/features/server-processing.mdx

https://raw.githubusercontent.com/TypeCellOS/BlockNote/refs/heads/main/docs/content/docs/reference/editor/manipulating-content.mdx

Very worry about when it need editor, when it don't. And the
transforming model

Summary by CodeRabbit

Release Notes

  • Refactor
    • Restructured document editor service architecture for improved content lifecycle management and better separation of concerns.
    • Enhanced tag and outgoing link extraction capabilities within documents.
    • Improved handling of document content conversion and persistence workflows.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@KevinNitroG has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 35 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 14b0c665-d505-4b15-a83a-eeed167be151

📥 Commits

Reviewing files that changed from the base of the PR and between 1c5104b and 56147ca.

📒 Files selected for processing (2)
  • apps/document/src/blocknote/blocknote-editor.service.ts
  • apps/search-worker/src/app.service.ts
📝 Walkthrough

Walkthrough

BlocknoteService is removed and replaced with BlocknoteEditorService, which is no longer a singleton injectable but an instance service that accepts schema and optional initial content. Type definitions are updated to support the new editor options and server-util interfaces. DocumentService now injects the schema directly and instantiates BlocknoteEditorService within commitDocument to extract blocks, tags, and link IDs for revisions and event publishing.

Changes

BlocknoteService Replacement

Layer / File(s) Summary
Type system updates for new editor service
packages/lib-server/src/block-note/types.d.ts
Module augmentations switch MySchema to createSchema, introduce MyEditorOptions interface forwarding to BlockNoteEditorOptions, and add ServerBlockNoteEditor interface from @blocknote/server-util with default schema type parameters.
BlocknoteEditorService implementation
apps/document/src/blocknote/blocknote-editor.service.ts
New service accepts schema and optional initial content (MyBlock[] or Buffer), wraps ServerBlockNoteEditor, and exposes blocks(), toYDoc(), bufferToBlockNote(), replaceContent(), and extractTagsAndOutgoingLinkIds() for document lifecycle operations.
Module exports and imports update
apps/document/src/blocknote/blocknote.module.ts, apps/document/src/blocknote/index.ts
BlockNoteModule removes BlocknoteService from providers and exports; index.ts re-exports BlocknoteEditorService instead of the removed service.
DocumentService migration to schema-driven editor creation
apps/document/src/document/document.service.ts
DocumentService replaces BlocknoteService injection with BLOCKNOTE_SCHEMA injection; commitDocument creates BlocknoteEditorService instances on-the-fly using the schema and document data to extract content blocks, tags, and outgoing link IDs for revisions and Kafka event publishing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title partially relates to the changeset—it mentions 'blocknote editor service' and 'wrap', which align with introducing BlocknoteEditorService as a wrapper. However, it contains a typo ('arround' instead of 'around') and is vague about the actual architectural change (replacing BlocknoteService singleton with instance-based service). Revise the title to be more descriptive and grammatically correct, such as: 'refactor(document): replace BlocknoteService singleton with BlocknoteEditorService instances'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kevinnitro/document-svc-blocknote-editor-no-singleton

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/document/src/blocknote/blocknote-editor.service.ts`:
- Around line 22-31: The code sets this.editor after potentially calling
replaceContent, which causes a runtime error when options.initialContent is
present; move the assignment this.editor = this.serverEditor.editor to occur
before any calls to replaceContent (including both the initialContent branch
that uses bufferToBlockNote and the other occurrence around lines 51-53) so
replaceContent always has a valid this.editor; ensure both code paths reference
the already-initialized this.editor before performing content replacement.
- Around line 43-44: Remove the conversational inline comments "// Idk, this
doesn't mutate the inner state of the editor?" and "// it just require the
editor to transform the data" from blocknote-editor.service.ts; these are
non-actionable noise—delete them or replace with a concise, factual comment if
necessary (e.g., explain the actual behavior or link to a TODO with a clear
task) and keep any real documentation in a JSDoc above the relevant
function/class (refer to the surrounding code where those comments appear to
locate the exact spot).
- Around line 63-65: The callback passed to forEachBlock in
extractTagsAndOutgoingLinkIds currently returns false when encountering a
non-array block.content, which stops traversal; change that return to true so
traversal continues through all blocks, ensuring extractTagsAndOutgoingLinkIds
visits subsequent blocks to collect tags and outgoing link ids—locate the check
on block.content in blocknote-editor.service.ts inside the forEachBlock callback
and replace the `return false;` with `return true;`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: cd60a24a-5a79-4956-9cdc-fab4c9b79396

📥 Commits

Reviewing files that changed from the base of the PR and between 8cb049b and 1c5104b.

📒 Files selected for processing (6)
  • apps/document/src/blocknote/blocknote-editor.service.ts
  • apps/document/src/blocknote/blocknote.module.ts
  • apps/document/src/blocknote/blocknote.service.ts
  • apps/document/src/blocknote/index.ts
  • apps/document/src/document/document.service.ts
  • packages/lib-server/src/block-note/types.d.ts
💤 Files with no reviewable changes (1)
  • apps/document/src/blocknote/blocknote.service.ts

Comment thread apps/document/src/blocknote/blocknote-editor.service.ts
Comment on lines +43 to +44
// Idk, this doesn't mutate the inner state of the editor?
// it just require the editor to transform the data
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Remove conversational inline comments from production code.

These comments are non-actionable and add noise.

Proposed fix
-  // Idk, this doesn't mutate the inner state of the editor?
-  // it just require the editor to transform the data
   bufferToBlockNote(data: Buffer): MyBlock[] {
As per coding guidelines, "Avoid writing unnecessary comments in code".
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Idk, this doesn't mutate the inner state of the editor?
// it just require the editor to transform the data
bufferToBlockNote(data: Buffer): MyBlock[] {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/document/src/blocknote/blocknote-editor.service.ts` around lines 43 -
44, Remove the conversational inline comments "// Idk, this doesn't mutate the
inner state of the editor?" and "// it just require the editor to transform the
data" from blocknote-editor.service.ts; these are non-actionable noise—delete
them or replace with a concise, factual comment if necessary (e.g., explain the
actual behavior or link to a TODO with a clear task) and keep any real
documentation in a JSDoc above the relevant function/class (refer to the
surrounding code where those comments appear to locate the exact spot).

Comment thread apps/document/src/blocknote/blocknote-editor.service.ts
@KevinNitroG KevinNitroG merged commit a765401 into main May 18, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant