Skip to content

Fix module-scope DOM access for Node.js/SSR compatibility#4787

Open
brrichards wants to merge 3 commits intoslab:mainfrom
brrichards:fix/ssr-dom-dependencies
Open

Fix module-scope DOM access for Node.js/SSR compatibility#4787
brrichards wants to merge 3 commits intoslab:mainfrom
brrichards:fix/ssr-dom-dependencies

Conversation

@brrichards
Copy link
Copy Markdown

@brrichards brrichards commented Mar 19, 2026

Summary

Fixes #4594

Quill crashes with ReferenceError when imported in Node.js/SSR environments because several modules access browser globals at module scope (import time).

File Change
emitter.ts Defer document.addEventListener to lazy ensureDocumentListeners(), called from Quill constructor
quill.ts Call ensureDocumentListeners() after instance registration
clipboard.ts Replace Node.TEXT_NODE / Node.ELEMENT_NODE with numeric constants per DOM spec
keyboard.ts Guard navigator.platform with typeof check
uiNode.ts Guard navigator.platform with typeof check
syntax.ts Guard window.hljs with typeof check

Validated against FluidFramework, which currently requires a global-jsdom workaround to import Quill, no longer needed with these fixes.

Co-authored-by: Craig Macomber (Microsoft) <42876482+CraigMacomber@users.noreply.github.com>
Copy link
Copy Markdown

@CraigMacomber CraigMacomber left a comment

Choose a reason for hiding this comment

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

Looks good to me.

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.

"ReferenceError: document is not defined"

2 participants