Use the Markdown syntax tree for inline formatting in markup mode

Aperta
#1,265 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@d3m1d0v ci sta già lavorando.

Dal 1/10/2026.

  • #1313 di @d3m1d0v — aperta

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
15/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
markdown, typescript
Ambito
frontend

Direzione di ricerca

The issue asks to replace the text-splitting inline formatting logic in markup mode with ranges built from the Markdown syntax tree, using ensureSyntaxTree from @codemirror/language. Read the current formatting command code and the Markdown language setup first, then check linked pull request #1313 before starting. Done means every listed block type and command keeps its markers intact, with tests for each case and for undo and redo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Inline formatting currently splits selections at blank lines and checks markers at range edges. It does not use the Markdown structure.

This can place formatting markers around block syntax, mix markers from separate elements, or produce invalid Markdown.

Examples:

  • List markers become part of bold or italic text.
  • Heading markers lose their meaning.
  • A selection across table cells can wrap table separators.
  • Code content can receive formatting markers as literal text.
  • Existing nested formatting can be detected incorrectly.

Proposed solution:
Use ensureSyntaxTree from @codemirror/language to read the existing Markdown syntax tree and build formatting ranges from syntax nodes.

Expected behavior:

  • Format text in each paragraph, list item, heading, or table cell separately.
  • Keep list markers, heading markers, quote prefixes, table separators, and code fences intact.
  • Support nested blocks, task lists, and multiline text.
  • Define handling for inline code, fenced code, and indented code. Formatting must not silently change literal code content.
  • Check which YFM blocks the existing parser supports and define a fallback for unsupported syntax.
  • Use syntax nodes to detect existing formatting where possible.
  • Preserve partial selections, selection direction, multiple selections, and cursor placement.
  • Keep formatting markers selected so users can apply several styles in sequence.
  • Apply each command as one undoable transaction.
  • Do not apply changes based on an incomplete syntax tree.

Apply the shared range logic to text styles, text color, inline math, and inline code. Keep command-specific rules where needed.

Add tests for each block type, mixed selections across blocks, nested formatting, consecutive commands, undo, and redo. Test states must use the same Markdown language configuration as the editor.

Lingua principale
TypeScript
Stelle
428
Fork
48
Merge medio
5g 15h
PR unite (30g)
47

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di gravity-ui/markdown-editor

Tutte le issue di gravity-ui/markdown-editor

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.