Skip to content

feat: Placeholder DOM elements - #3205

Draft
matthewlipski wants to merge 2 commits into
a11y-testingfrom
placeholder-element
Draft

matthewlipski wants to merge 2 commits into
a11y-testingfrom
placeholder-element

Conversation

@matthewlipski

@matthewlipski matthewlipski commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Currently, DOM elements are rendered as CSS pseudo elements. This is a problem for a11y accessibility testing as we cannot use an axe-core scan to check its contrast. This is because axe only checks contrast for DOM elements. Therefore, this PR changes the implementation to use real DOM elements for placeholders.

This comes with a performance overhead. A script has been added in this PR which benchmarks the render time between the old & new implementations, using a document of 1000 empty paragraphs and 1000 empty list items. It measures the initial render times, as well as re-renders on selection and content changes. The table below shows the performance overhead tested locally.

Document Operation Old New
Paragraphs Initial render 32.80 ms 32.55 ms
Paragraphs Selection change 1.30 ms 1.60 ms
Paragraphs Content change 1.75 ms 2.00 ms
List items Initial render 50.25 ms 68.95 ms
List items Selection change 1.20 ms 2.70 ms
List items Content change 1.95 ms 4.00 ms

The alternative solution to this problem is to have additional contrast check tests just for placeholders. To be honest, both that solution and the one in this PR don't seem the cleanest, so I would appreciate feedback r.e. this.

This PR is currently more of an experimental change as I'm unsure whether we want this.

Rationale

TODO

Changes

TODO

Impact

TODO

Testing

TODO

Screenshots/Video

TODO

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

TODO

@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
blocknote Ready Ready Preview Oct 19, 2026 5:21pm UTC
blocknote-website Ready Ready Preview Oct 19, 2026 5:21pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

// positions are hardcoded for now
if (state.doc.content.size === 6) {
decs.push(
Decoration.node(2, 4, {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think (had a quick look), you should be able to keep the old code, but change Decoration.node into Decoration.widget (in the right position)?

Your performance regression is likely that the new version loops the document (doc.descendents). From a quick look, I don't understand why all the code needed to change and not just the decoration type

@matthewlipski matthewlipski mentioned this pull request Oct 15, 2026
2 of 4 tasks

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — 5efd6125 Deployed Oct 19, 2026 by vercel[bot]
Preview – blocknote — 5efd6125 Deployed Oct 19, 2026 by vercel[bot]
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.

2 participants