Bring the source mode back as a read-only view for collaborative documents - #3405
Merged
Merged
Conversation
AlexAndBear
force-pushed
the
editor-source-mode-readonly-with-yjs
branch
3 times, most recently
from
September 18, 2026 07:34
1ea523a to
6b2164a
Compare
AlexAndBear
force-pushed
the
editor-source-mode-readonly-with-yjs
branch
2 times, most recently
from
September 18, 2026 07:44
27778b8 to
9401141
Compare
Before Yjs, markdown and html documents had a fully editable source mode. It was dropped for collaborative documents (534f645) because the source textarea replaces the ProseMirror view and cannot write back into the CRDT, which left those documents with no way to look at the raw source at all. The action is available again whenever a Yjs session is active, but the textarea is read-only: it cannot desync the shared document, and it follows the document while peers keep typing instead of freezing the snapshot taken when it opened. That sync hangs off the Yjs session rather than off the read-only flag - the session is what makes the document move on its own. The toolbar entry says so - "Show source (read-only)" - and the textarea shows a not-allowed cursor. The source view moved out of `TextEditorContent` into its own component. It mounts and unmounts with the mode, so the snapshot, the initial focus and the update listener all hang off its lifecycle instead of watchers. The same read-only path now also covers a read-only editor, where the source textarea was editable and even wrote its edits back into the document.
AlexAndBear
force-pushed
the
editor-source-mode-readonly-with-yjs
branch
from
September 18, 2026 07:46
9401141 to
b0ef171
Compare
JammingBen
requested changes
Sep 21, 2026
JammingBen
left a comment
Member
There was a problem hiding this comment.
Also please don't forget to update the known limits in dev/docs/yjs.md.
JammingBen
approved these changes
Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Related Issue
No issue was filed for this.
How Has This Been Tested?
pnpm test:unit --run packages/web-pkgandpackages/web-app-text-editorShow source (read-only); without a session the title is unchangedsourceModeReadonlyis true for an active Yjs session (ydoc + configuredyjsServerUrl) and for a read-only editor, false otherwise, and follows thereadonlyoption when it flipsreadonlyin that case and swallows input; by default it stays editable and writes through to the document as beforepnpm check:types,pnpm lintandpnpm format:checkpass; 1788 tests inweb-pkgand 21 inweb-app-text-editorpassNot verified by hand in a live collaborative session in the browser.
Types of changes