chore: Regression test for #2677#2688
Conversation
…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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughA 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Review rate limit: 5/8 reviews remaining, refill in 18 minutes and 30 seconds.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: |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (13)
examples/06-custom-schema/08-non-editable-block/.bnexample.jsonexamples/06-custom-schema/08-non-editable-block/README.mdexamples/06-custom-schema/08-non-editable-block/index.htmlexamples/06-custom-schema/08-non-editable-block/main.tsxexamples/06-custom-schema/08-non-editable-block/package.jsonexamples/06-custom-schema/08-non-editable-block/src/App.tsxexamples/06-custom-schema/08-non-editable-block/src/NonEditableBlock.tsxexamples/06-custom-schema/08-non-editable-block/tsconfig.jsonexamples/06-custom-schema/08-non-editable-block/vite.config.tsplayground/src/examples.gen.tsxtests/src/end-to-end/copypaste/copypaste.test.tstests/src/end-to-end/copypaste/copypaste.test.ts-snapshots/nonEditableBlock-json-chromium-linux.jsontests/src/utils/const.ts
|
@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 |
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
Tests