Skip to content

fix: Ignore block/inline content mutations which aren't useful (BLO-1224)#2912

Open
matthewlipski wants to merge 1 commit into
mainfrom
dark-reader
Open

fix: Ignore block/inline content mutations which aren't useful (BLO-1224)#2912
matthewlipski wants to merge 1 commit into
mainfrom
dark-reader

Conversation

@matthewlipski

@matthewlipski matthewlipski commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR makes blocks & inline content ignore all mutations which don't modify the block/inline content's content. By default, ProseMirror handles all DOM mutations to a node. This is to allow changes in the view to propagate to the state. For BlockNote, this isn't really needed - you're expected to update the state (e.g. by updating a block's props) and let those changes trigger a re-render to propagate them to the view.

This has a number of benefits. For one, interactive elements that are view-only and aren't tied to e.g. a block's props won't cause re-renders. Also, browser extensions may modify inline styles on elements in the editor. Because these are DOM mutations, ProseMirror picks them up and triggers a re-render, and ends up causing an infinite re-render loop.

Closes #2818

Rationale

We expect most people to create custom blocks using React, so these changes don't really apply there. So this PR is mostly to prevent issues with browser extensions like DarkReader.

Changes

  • Added ignoreNonContentMutations.

Impact

N/A

Testing

Added unit tests.

Screenshots/Video

N/A

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

N/A

Summary by CodeRabbit

  • Bug Fixes

    • Reduced unnecessary editor re-renders caused by irrelevant DOM changes in block and inline content views.
    • Improved compatibility with browser extensions and other tools that rewrite DOM attributes or structure.
    • Preserved updates to actual content and selection changes while ignoring unrelated mutations.
  • Tests

    • Added coverage for content, selection, attribute, and non-content DOM mutations.

@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview Jul 22, 2026 4:17pm
blocknote-website Ready Ready Preview Jul 22, 2026 4:17pm

Request Review

@matthewlipski
matthewlipski requested a review from YousefED July 22, 2026 16:17
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d5dd78f4-0cb9-4275-9319-d2b3415d1240

📥 Commits

Reviewing files that changed from the base of the PR and between dee7880 and 976944c.

📒 Files selected for processing (4)
  • packages/core/src/schema/blocks/createSpec.ts
  • packages/core/src/schema/inlineContent/createSpec.ts
  • packages/core/src/schema/nodeViewMutations.test.ts
  • packages/core/src/schema/nodeViewMutations.ts

📝 Walkthrough

Walkthrough

Changes

Node view mutation filtering

Layer / File(s) Summary
Mutation classification and filtering
packages/core/src/schema/nodeViewMutations.ts, packages/core/src/schema/nodeViewMutations.test.ts
Adds mutation classification and wraps node view handlers to ignore non-content mutations while preserving content and selection handling, with tests covering each case.
Node view integration
packages/core/src/schema/blocks/createSpec.ts, packages/core/src/schema/inlineContent/createSpec.ts
Applies mutation filtering when creating non-selectable block and custom inline-content node views.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: nperez0111, yousefed

Poem

A bunny hops through DOM-lit night,
Filtering chrome mutations bright.
Content stays, selections flow,
While needless rerenders softly go.
Hop, hop—clean views grow!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly reflects the main change: filtering non-content mutations for block and inline content.
Description check ✅ Passed The description follows the template and covers summary, rationale, changes, impact, testing, and checklist items.
Linked Issues check ✅ Passed The changes address #2818 by ignoring non-content DOM mutations in block and inline node views and adding tests.
Out of Scope Changes check ✅ Passed The PR stays focused on mutation filtering and test coverage, with no clear unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dark-reader

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.

@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@2912

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@2912

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@2912

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@2912

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@2912

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@2912

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@2912

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@2912

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@2912

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@2912

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@2912

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@2912

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@2912

commit: 976944c

@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://TypeCellOS.github.io/BlockNote/pr-preview/pr-2912/

Built to branch gh-pages at 2026-07-22 16:24 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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.

Dark reader extension memory leak

1 participant