facebook / facebook/lexical

Preserve Alignment When Converting to Markdown

Open
#7,555 0 comments 1 reaction 0 assignees View on GitHub
markdown
Dominant language
TypeScript
Stars
23.9k
Forks
2.2k
Avg merge
1d 14h
Merged PRs (30d)
55

Description

### Description
Currently, when I align text in the Lexical editor (e.g., center or right alignment) and then switch to Markdown mode, the alignment is lost. This creates inconsistencies when toggling between rich text and Markdown views.

---

### Problem
Markdown does not support native text alignment, but many use cases still require alignment (especially for presentations, documents, blog posts, etc.). Losing alignment on mode switch leads to a degraded user experience.

---

### Suggestion
Introduce a fallback to preserve alignment in Markdown mode, such as:

#### HTML fallback (commonly used):
```html


This text should stay center-aligned.


This text should stay left-aligned.


This text should stay right-aligned.

```

**OR Custom syntax (for cleaner round-trip conversion):**
```->This text is center-aligned.<-```
```<-This text is left-aligned.<-```
```->This text is right-aligned.->```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.