Skip to content

chore: Regression test for #2677#2688

Merged
matthewlipski merged 4 commits intomainfrom
shadow-copy-test
Apr 29, 2026
Merged

chore: Regression test for #2677#2688
matthewlipski merged 4 commits intomainfrom
shadow-copy-test

Conversation

@matthewlipski
Copy link
Copy Markdown
Collaborator

@matthewlipski matthewlipski commented Apr 29, 2026

This PR adds an e2e test for #2677 by copying content in a non-editable block and pasting it in the editor. A playground example is also added for this test.

Summary by CodeRabbit

  • New Features

    • Added a new "Non-Editable Block" example demonstrating how to create custom blocks with non-editable content using custom schemas. The example is now available in the playground.
  • Tests

    • Added end-to-end tests to validate copy/paste functionality with non-editable blocks.

wielinde and others added 3 commits April 25, 2026 14:58
…ibility

OpenProject embeds BlockNote inside a Shadow DOM (attachShadow({ mode: 'open' }))
to isolate it from the host Angular application. In this setup,
window.getSelection() returns null or a collapsed selection even when text is
selected (Firefox all versions, Safari ≤16.3, Chromium edge cases), causing
checkIfSelectionInNonEditableBlock to always return true and skip the
clipboard write entirely. The browser's default copy then fires, which uses
ProseMirror's DOMSerializer without semantic wrappers — so list formatting,
headings, and bold/italic are lost on paste into external apps.

Fix: use view.state.selection.empty as the primary empty-selection guard.
ProseMirror's internal state is always accurate regardless of DOM mode. The
DOM-level non-editable-island check is kept as a secondary guard, but only
when window.getSelection() actually returns a non-collapsed selection.

Fixes copy/cut for editors mounted inside attachShadow({ mode: 'open' }).
fix(clipboard): use ProseMirror selection state for Shadow DOM compatibility
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

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

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview Apr 29, 2026 4:05pm
blocknote-website Ready Ready Preview Apr 29, 2026 4:05pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

A new custom schema example is introduced for creating non-editable blocks in BlockNote, including source files, build configuration, example registration, and end-to-end test coverage with snapshots.

Changes

Cohort / File(s) Summary
Non-Editable Block Example Structure
examples/06-custom-schema/08-non-editable-block/.bnexample.json, examples/06-custom-schema/08-non-editable-block/README.md
Metadata and documentation files that configure the example as playground-enabled with author and tag information, including relevant documentation links.
Non-Editable Block Build Configuration
examples/06-custom-schema/08-non-editable-block/package.json, examples/06-custom-schema/08-non-editable-block/tsconfig.json, examples/06-custom-schema/08-non-editable-block/vite.config.ts, examples/06-custom-schema/08-non-editable-block/index.html, examples/06-custom-schema/08-non-editable-block/main.tsx
Build tooling and entry point configuration for the example project, including Vite setup, TypeScript configuration, and React DOM bootstrap.
Non-Editable Block Example Implementation
examples/06-custom-schema/08-non-editable-block/src/App.tsx, examples/06-custom-schema/08-non-editable-block/src/NonEditableBlock.tsx
Core example code that creates a custom BlockNote schema with a nonEditable block specification and initializes an editor with sample content.
Example Registry
playground/src/examples.gen.tsx
Updated generated examples registry entry for the new non-editable block example in the playground.
Copy/Paste Test Infrastructure
tests/src/utils/const.ts, tests/src/end-to-end/copypaste/copypaste.test.ts, tests/src/end-to-end/copypaste/copypaste.test.ts-snapshots/nonEditableBlock-json-chromium-linux.json
End-to-end test suite for copy/paste behavior in non-editable block regions with corresponding snapshot, plus URL constant export for test access.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #2677: Adds copy/cut clipboard logic and checkIfSelectionInNonEditableBlock selection handling that directly supports the non-editable block copy/paste test scenarios.

Suggested reviewers

  • nperez0111

Poem

🐰 A block so steady, locked in place,
No editing shall trespass here with grace,
With schemas custom, examples bloom,
BlockNote's new creation fills the room!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description is minimal but covers the core change. The template requires multiple sections, but only Summary is provided; required sections like Testing, Checklist, and others are missing. Expand the description to include Testing section detailing the test approach, a Checklist with completed items, and other relevant template sections to meet documentation standards.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly relates to the main purpose: adding a regression test for issue #2677 with a non-editable block example.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shadow-copy-test

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
Review rate limit: 5/8 reviews remaining, refill in 18 minutes and 30 seconds.

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 29, 2026

Open in StackBlitz

@blocknote/ariakit

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

@blocknote/code-block

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

@blocknote/core

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

@blocknote/mantine

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

@blocknote/react

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

@blocknote/server-util

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

@blocknote/shadcn

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

@blocknote/xl-ai

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

@blocknote/xl-docx-exporter

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

@blocknote/xl-email-exporter

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

@blocknote/xl-multi-column

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

@blocknote/xl-odt-exporter

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

@blocknote/xl-pdf-exporter

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

commit: 0a77e88

Copy link
Copy Markdown

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@examples/06-custom-schema/08-non-editable-block/index.html`:
- Line 1: Add the HTML5 doctype declaration above the existing <html lang="en">
tag in index.html by inserting <!doctype html> as the very first line so the
document satisfies doctype-first and renders in standards mode; ensure there are
no leading blank lines before the doctype.

In `@examples/06-custom-schema/08-non-editable-block/main.tsx`:
- Line 4: The import statement currently references a non-existent module
"./src/App.jsx"; update the import to point to the actual module name (e.g.,
"./src/App.tsx" or "./src/App") where the App component is exported so the App
identifier resolves correctly at runtime; locate the import of App in main.tsx
and replace the .jsx path with the existing .tsx module.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 695d4999-62a0-4845-952c-e46f098387d9

📥 Commits

Reviewing files that changed from the base of the PR and between 130a916 and 0a77e88.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (13)
  • examples/06-custom-schema/08-non-editable-block/.bnexample.json
  • examples/06-custom-schema/08-non-editable-block/README.md
  • examples/06-custom-schema/08-non-editable-block/index.html
  • examples/06-custom-schema/08-non-editable-block/main.tsx
  • examples/06-custom-schema/08-non-editable-block/package.json
  • examples/06-custom-schema/08-non-editable-block/src/App.tsx
  • examples/06-custom-schema/08-non-editable-block/src/NonEditableBlock.tsx
  • examples/06-custom-schema/08-non-editable-block/tsconfig.json
  • examples/06-custom-schema/08-non-editable-block/vite.config.ts
  • playground/src/examples.gen.tsx
  • tests/src/end-to-end/copypaste/copypaste.test.ts
  • tests/src/end-to-end/copypaste/copypaste.test.ts-snapshots/nonEditableBlock-json-chromium-linux.json
  • tests/src/utils/const.ts

Comment thread examples/06-custom-schema/08-non-editable-block/index.html
Comment thread examples/06-custom-schema/08-non-editable-block/main.tsx
@matthewlipski matthewlipski merged commit ff052c8 into main Apr 29, 2026
23 checks passed
@matthewlipski matthewlipski deleted the shadow-copy-test branch April 29, 2026 16:11
@YousefED
Copy link
Copy Markdown
Collaborator

YousefED commented May 2, 2026

@matthewlipski while this PR validates whether the original code (non-editable area copy / paste) still works, it does not test the shadow-dom scenario, right?

More specifically, if I'm not mistaken (haven't tested this), with the code change from #2677, non-editable block copy within a shadow dom would not work, right? This would mean BlockNote behaves differently in a shadow dom vs regular use. Is there a way to streamline this? e.g.: not rely on window.getSelection at all?

cc @nperez0111

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.

4 participants