Skip to content

[4/5] feat: integrate per-tab document modes and protected saves - #5802

Merged
Jocs merged 1 commit into
developfrom
split/marktext-document-mode
Oct 20, 2026
Merged

Jocs merged 1 commit into
developfrom
split/marktext-document-mode

Conversation

@Jocs

@Jocs Jocs commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Relates to #3688, #4532, #3745.

Existing documents can open in reading mode per tab while retaining unsaved buffers, rendered content, selection and copying. Integrate Muya's reading mode with document state, typed IPC, buffered restore and source-view handoff.

Save and Save As share the existing save handler, including the main-process write barrier and saved-content acknowledgement. Locking waits for active writes and rejects queued or stale saves. Explicit close-and-save unlocks dirty documents; external changes retain dirty buffers and suspend automatic overwrites.

Entering reading from source closes the runtime source view through its normal unmount handoff. Unlocking stays in live editing; the startup source-mode preference is unchanged. Source tabs retain independent undo histories across tab switches and later manual source entry, including tabs with identical content. New and pending documents remain editable by default. Mode-switch failures restore the editor and report the failure even if rollback IPC also fails.

Validation:

  • Desktop unit suite: 107 files / 1154 tests passed.
  • Electron reading-mode and existing source undo/caret/save-marker regressions: 18 passed on macOS.
  • The identical-content source-tab regression fails against the previous implementation and passes with the fix.
  • ESLint, typecheck and desktop build passed.

Targets develop after merged #5799, #5800 and #5801. #5793 remains open as the downstream UI layer for switches, menus, shortcuts, tab indicators and shell localization. Reading-context and state notifications include all 12 desktop locales.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Build artifacts for PR #5802:

Run: https://github.com/marktext/marktext/actions/runs/39446463668

Artifact Size Link
marktext-windows-arm64 291.1 MB Download
marktext-macos-x64 313.7 MB Download
marktext-linux-arm64 522.6 MB Download
marktext-linux-x64 667.8 MB Download
marktext-macos-arm64 300.4 MB Download
marktext-windows-x64 299.2 MB Download

@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/marktext-document-mode branch 2 times, most recently from 7916492 to 1ae6697 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/marktext-document-mode branch from 1ae6697 to caec78a 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/marktext-document-mode branch from caec78a to a0403d9 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 force-pushed the split/marktext-document-mode branch from a0403d9 to 74bbad0 Compare October 20, 2026 09:52
@Jocs
Jocs force-pushed the split/muya-reading-mode branch from 988d1bd to 6814f27 Compare October 20, 2026 09:57
@Jocs
Jocs force-pushed the split/marktext-document-mode branch from 74bbad0 to 2faeaf5 Compare October 20, 2026 09:58
@Jocs
Jocs force-pushed the split/muya-reading-mode branch from 6814f27 to 5a93018 Compare October 20, 2026 10:11
@Jocs
Jocs force-pushed the split/marktext-document-mode branch from 2faeaf5 to 7f6545b Compare October 20, 2026 10:11
@Jocs
Jocs force-pushed the split/muya-reading-mode branch from 5a93018 to 8a327c9 Compare October 20, 2026 10:15
@Jocs
Jocs force-pushed the split/marktext-document-mode branch 2 times, most recently from 39b4068 to a48c98a Compare October 20, 2026 10:22
@Jocs
Jocs force-pushed the split/muya-reading-mode branch from 8a327c9 to abbd4c1 Compare October 20, 2026 10:22
@Jocs
Jocs force-pushed the split/marktext-document-mode branch from a48c98a to 13022a2 Compare October 20, 2026 13:22
@Jocs
Jocs force-pushed the split/muya-reading-mode branch 2 times, most recently from 223e5b2 to 8996812 Compare October 20, 2026 13:39
@Jocs
Jocs force-pushed the split/marktext-document-mode branch 2 times, most recently from bff2cdb to 8403db9 Compare October 20, 2026 13:45
@Jocs
Jocs force-pushed the split/marktext-document-mode branch from 8403db9 to 3d4b2b9 Compare October 20, 2026 14:14
@Jocs
Jocs changed the base branch from split/muya-reading-mode to develop October 20, 2026 14:14
@Jocs
Jocs force-pushed the split/marktext-document-mode branch 2 times, most recently from 5bbbae7 to 663fe06 Compare October 20, 2026 15:04
@Jocs
Jocs force-pushed the split/marktext-document-mode branch from 663fe06 to ed6369d Compare October 20, 2026 15:13
@Jocs
Jocs merged commit ba03411 into develop Oct 20, 2026
13 checks passed
@Jocs
Jocs deleted the split/marktext-document-mode branch October 23, 2026 08:32
Zane-0x5a added a commit to Zane-0x5a/marktext that referenced this pull request Oct 27, 2026
Brings in v0.22.0 and v0.23.0 and the start of 0.24.0: Electron 45,
GitHub Alerts, foldable headings, per-tab reading mode and --read-only,
the docked document outline, multiple folder roots, preview tabs, recent
files in quick open, Italian, and the large-document fixes of marktext#4942 and
marktext#5863.

Conflicts:

- muya state/inlineRenderer: marktext#4942 caches reference definitions per
  candidate state, which supersedes the fork's per-revision cache. Took
  upstream's; the fork's display math cache in mathPreview stays.
- editor.vue: kept the fork's deferred content snapshot (no getState()
  deep clone per keystroke), document virtualization and camera, on top
  of upstream's reading mode, shortcut resolvers and image drop. The
  json-change handler keeps upstream's loadingContent/readOnly guard,
  the source handoff and reload take upstream's loadingContent blocks,
  and scrollToHeader reveals folded headings before following the
  target. publishContentChange uses getSelectionState().
- Print/PDF: the fork's paged preview replaces MarkdownPrint and the
  printToPDF export path, so printService, its specs and the pdf branch
  of handleResponseForExport keep the fork's side. marktext#3323 moved image
  resolution into the engine; exportHtml drops its own image rewrite and
  keeps the fork's rendered-heading TOC.
- marktext#5802's assertExportDestination moves to main/filesystem so Save PDF in
  the preview refuses the source document too.
- syntheticHistory keeps the 53-bit cyrb53 hash over upstream's BigInt
  FNV-64 (~6 ms per key on a 500 KB note); the store keeps isSameList
  and drops deep-equal.
- Sidebar rows keep draggable alongside preview tabs; locales keep both
  printPreview and readingMode, and it.json gets the printPreview strings.

Merge adjustments:

- SET_READ_ONLY publishes the pending snapshot first: a read-only tab
  drops content changes, so an edit made within 150 ms of entering
  reading mode would otherwise be missing from the tab.
- marktext#5798 moved notices to the bottom-right corner, over the preview's
  Save PDF and Print buttons, and an export notice stays while hovered.
  The preview lifts notices clear of its actions while it is open.
- Specs: the docked outline is expanded by default and narrows the
  column, so the virtualization specs open it only when it is closed,
  measure the settled position and place their target inside the
  viewport. The camera specs press Control once before measuring,
  because since marktext#5878 the first key press re-renders the caret's heading
  with its marks shown.

Verified on Windows 11 (175%): typecheck, lint, the desktop unit suite
(1467) and the muya unit suite (3978) pass. In background windows the
e2e suite (514 passed, 45 failed) fails only where a build of
upstream/develop fails on this machine too (copy-anchor-link,
document-outline, image clipboard/relative path, 5394, 5685,
toc-active-heading, outline-layout, ...: 56 cases in 19 specs there),
plus media-viewer cases that flake on both when the 1 px image's resize
bar takes the click. print-preview, export-pdf, document-virtualization
and sidebar-file-drag pass, and editor-camera passes on screen.
reading-mode:54 needs the camera focus fix in the next commit.
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