Skip to content

[3/5] feat(muya): add read-only document mode - #5801

Merged
Jocs merged 1 commit into
developfrom
split/muya-reading-mode
Oct 20, 2026
Merged

Jocs merged 1 commit into
developfrom
split/muya-reading-mode

Conversation

@Jocs

@Jocs Jocs commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Relates to #3688, #4532, #3745. Split from #5793, which stays open as layer 5.

Review stack

Review and merge in this order. Each PR targets the preceding branch, so its Files changed tab contains only its own layer.

Layer PR Responsibility
1 #5799 Muya asynchronous target validation
2 #5800 Accessible code copying and clipboard feedback
3 #5801 Muya read-only mode and reading interactions
4 #5802 MarkText document state, IPC and save protection
5 #5793 MarkText controls, menus, shortcuts and shell localization

After a preceding PR merges, retarget/rebase its successor onto develop before merging it. Keep intermediate branches until their downstream PR has been retargeted. #5793 is the original PR, retained and reused.

Summary

Add Muya read-only document mode: guard mutations and async targets while allowing host document loads, preserve rendered content and Markdown source copying, follow links, open diagram previews, and disable paragraph dragging. Include the engine API, interaction regressions and all supported engine locales.

Type of change

  • New feature (non-breaking)

Test plan

  • Regression tests included with this layer.
  • Muya full unit suite: 296 files / 2793 tests passed. Chromium reading/paste E2E: 11 passed. Muya ESLint, typecheck and circular-dependency check passed.
  • Automated browser/Electron checks run on macOS where listed.

Notes for reviewers

Layer 3/5 of a linear PR stack. Review the diff against this PR’s base branch; merge in order. The next layer is rebased/retargeted after this one lands.

Follow-up review

Removed the redundant link-preparation pass before the reading presentation rerender; keep preparation after rendering. Full Muya suite: 2793 tests passed; Chromium reading/paste regressions: 11 passed.

Changes remain in their owning layer; all five existing PRs are retained. Additional IME handling was deferred as requested.

Diagram preview state

Reading-mode activation checks the render completion flag rather than searching the DOM for SVG/image nodes. Each update resets eligibility; successful renderer completion enables preview. Tests cover successful SVG/image renders, injected DOM, loading, failure and empty content. Validation: 2793 Muya unit tests, 7 Chromium reading cases, 1 Electron diagram preview case; ESLint, types and desktop build passed.

#5799 and #5800 are merged. This PR now targets develop directly.

Setter mutation guards

Code-block language, frontmatter language and table alignment setters uniformly reject mutations when canMutate is false, including same-value assignments. Language initialization invokes separate rendering methods, preserving highlighting without granting write access. Regression tests cover indented-block promotion, same-value rendering side effects, table alignment and locked initialization. Full Muya suite: 2793 tests passed; reading-mode Chromium: 7 passed; root/Muya ESLint and Muya typecheck passed.

Shared clipboard pipeline

Reading mode uses the existing getClipboardData/writeClipboardData pipeline for normal, Markdown, HTML and rich-text copying. Removed the dedicated reading clipboard module and write branch; Markdown syntax in copied text is intentional. Reading select-all uses content-block endpoints so the existing selection resolver can consume its range. Validation: 2793 Muya unit tests, 10 Chromium reading-mode cases, root/Muya ESLint and Muya typecheck passed.


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@Jocs
Jocs force-pushed the split/muya-reading-mode branch from ed4beec to 8723cec Compare October 20, 2026 08:54
@Jocs
Jocs force-pushed the split/muya-code-copy-feedback branch from 8afb5e6 to 3376f57 Compare October 20, 2026 08:54
@Jocs
Jocs force-pushed the split/muya-reading-mode branch from 8723cec to f61f872 Compare October 20, 2026 09:11
@Jocs
Jocs force-pushed the split/muya-code-copy-feedback branch 2 times, most recently from ade176c to 97454e9 Compare October 20, 2026 09:23
@Jocs
Jocs force-pushed the split/muya-reading-mode branch from f61f872 to 5320df4 Compare October 20, 2026 09:23
@Jocs
Jocs force-pushed the split/muya-code-copy-feedback branch from 97454e9 to 7a9f072 Compare October 20, 2026 09:25
@Jocs
Jocs force-pushed the split/muya-reading-mode branch from 5320df4 to 8507714 Compare October 20, 2026 09:25
@Jocs
Jocs force-pushed the split/muya-code-copy-feedback branch from 7a9f072 to 6e56326 Compare October 20, 2026 09:37
@Jocs
Jocs force-pushed the split/muya-reading-mode branch 2 times, most recently from 615f06e to 988d1bd Compare October 20, 2026 09:52
@Jocs
Jocs changed the base branch from split/muya-code-copy-feedback to develop October 20, 2026 09:52
@Jocs
Jocs force-pushed the split/muya-reading-mode branch 6 times, most recently from 223e5b2 to 8996812 Compare October 20, 2026 13:39
@Jocs
Jocs force-pushed the split/muya-reading-mode branch from 8996812 to 2a470b3 Compare October 20, 2026 13:45
@Jocs
Jocs merged commit b1b8080 into develop Oct 20, 2026
8 checks passed
@Jocs
Jocs deleted the split/muya-reading-mode branch October 23, 2026 08:32
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.

1 participant