Skip to content

perf(editor): reduce live preview typing latency - #638

Merged
murongg merged 2 commits into
v2from
fix/issue-636-editor-performance
Aug 3, 2026
Merged

perf(editor): reduce live preview typing latency#638
murongg merged 2 commits into
v2from
fix/issue-636-editor-performance

Conversation

@murongg

@murongg murongg commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • keep unchanged Mermaid and table previews mounted while editing elsewhere in the document
  • incrementally map live-preview, block-control, math, footnote, raw HTML, heading, and code-highlight state for safe non-structural edits
  • preserve automatic syntax highlighting for code blocks without a recognized language while caching unchanged highlight results
  • persist the first dirty draft immediately, then coalesce continuous workspace writes; defer document summaries from 64 KB

Why

Issue #636 reports severe typing lag in Markdown documents. Profiling also reproduced the problem in small documents when expensive preview blocks were located after the caret. The input path was rebuilding preview state and, on desktop, queueing a settings-store read/write/save for every character.

Validation

  • pnpm --filter @markra/editor exec vitest run --environment jsdom --globals --maxWorkers=1 --no-file-parallelism — 35 files, 430 tests passed after the compatibility adjustment
  • pnpm --filter @markra/app exec vitest run --environment jsdom --globals --maxWorkers=1 --no-file-parallelism — 130 files, 1486 tests passed
  • pnpm --filter @markra/editor build && pnpm --filter @markra/editor typecheck:test — passed after the compatibility adjustment
  • pnpm --filter @markra/app build && pnpm --filter @markra/app typecheck:test — passed
  • desktop runtime check with the supplied small Mermaid document: a 20-character batch took 48.4 ms above the diagram, 50.9 ms below it, and 51.3 ms with the diagram removed

Risk

  • incremental mapping is restricted to edits that cannot create Markdown structure; structural edits and custom renderer nodes fall back to rebuilding decorations
  • code blocks without a recognized language retain the existing automatic language detection behavior
  • the first dirty draft is still persisted immediately, limiting the coalescing window to later continuous input

Closes #636

Keep expensive visual block previews mounted when edits do not touch them. Coalesce draft persistence and defer document summaries off the input path.

Closes #636
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
markra-web Ready Ready Preview Aug 3, 2026 6:37am

@murongg
murongg merged commit 5ec7d7b into v2 Aug 3, 2026
21 checks passed
@murongg
murongg deleted the fix/issue-636-editor-performance branch August 3, 2026 06:39
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.

在250kb的markdown文件的末尾编辑很卡

1 participant