Skip to content

Bring the source mode back as a read-only view for collaborative documents - #3405

Merged
AlexAndBear merged 4 commits into
mainfrom
editor-source-mode-readonly-with-yjs
Sep 21, 2026
Merged

AlexAndBear merged 4 commits into
mainfrom
editor-source-mode-readonly-with-yjs

Conversation

@AlexAndBear

@AlexAndBear AlexAndBear commented Sep 18, 2026

Copy link
Copy Markdown
Member

Description

Related Issue

No issue was filed for this.

  • Fixes n/a

How Has This Been Tested?

  • test environment: unit tests via pnpm test:unit --run packages/web-pkg and packages/web-app-text-editor
  • test case 1: the source mode action stays in the toolbar while a Yjs session is active, and is titled Show source (read-only); without a session the title is unchanged
  • test case 2: sourceModeReadonly is true for an active Yjs session (ydoc + configured yjsServerUrl) and for a read-only editor, false otherwise, and follows the readonly option when it flips
  • test case 3: the source textarea is readonly in that case and swallows input; by default it stays editable and writes through to the document as before
  • test case 4: the source view picks up document updates while a Yjs session is active, ignores them without one, and detaches its listener when it unmounts
  • test case 5: source mode swaps the ProseMirror view for the source view and back
  • test case 6: pnpm check:types, pnpm lint and pnpm format:check pass; 1788 tests in web-pkg and 21 in web-app-text-editor pass

Not verified by hand in a live collaborative session in the browser.

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

@AlexAndBear AlexAndBear self-assigned this Sep 18, 2026
@AlexAndBear
AlexAndBear force-pushed the editor-source-mode-readonly-with-yjs branch 3 times, most recently from 1ea523a to 6b2164a Compare September 18, 2026 07:34
@AlexAndBear
AlexAndBear requested a review from kulmann September 18, 2026 07:38
@AlexAndBear
AlexAndBear force-pushed the editor-source-mode-readonly-with-yjs branch 2 times, most recently from 27778b8 to 9401141 Compare September 18, 2026 07:44
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
AlexAndBear force-pushed the editor-source-mode-readonly-with-yjs branch from 9401141 to b0ef171 Compare September 18, 2026 07:46
@AlexAndBear AlexAndBear mentioned this pull request Sep 18, 2026
26 tasks
@github-project-automation github-project-automation Bot moved this to Qualification in OpenCloud Team Board Sep 18, 2026
@AlexAndBear AlexAndBear moved this from Qualification to In Progress in OpenCloud Team Board Sep 18, 2026

@JammingBen JammingBen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also please don't forget to update the known limits in dev/docs/yjs.md.

Comment thread packages/web-pkg/src/editor/components/TextEditorSourceView.vue Outdated
Comment thread packages/web-pkg/src/editor/components/TextEditorSourceView.vue
Comment thread packages/web-pkg/src/editor/components/TextEditorSourceView.vue
@AlexAndBear
AlexAndBear merged commit 3f1118e into main Sep 21, 2026
31 checks passed
@AlexAndBear
AlexAndBear deleted the editor-source-mode-readonly-with-yjs branch September 21, 2026 07:44
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenCloud Team Board Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants