Use the Markdown syntax tree for inline formatting in markup mode

Abierto
#1,265 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@d3m1d0v ya está trabajando en esto.

Desde el 1/10/2026.

  • #1313 de @d3m1d0v — abierto

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
15/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
markdown, typescript
Área
frontend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
428
Forks
48
Merge medio
5 d 15 h
PR fusionados (30 d)
47

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de gravity-ui/markdown-editor

Todos los issues de gravity-ui/markdown-editor

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.