facebook / lexical

Lexical is an extensible text editor framework that provides excellent reliability, accessibility and performance.
https://lexical.dev
MIT License
19.64k stars 1.67k forks source link

Bug: Styling format should be removed from the whitespace #6526

Open demonzmahmood opened 2 months ago

demonzmahmood commented 2 months ago

Hello , There an issue that I found out after I copy paste from Microsoft word. If you apply a styling to a whitespace, it results with asterisk **** or ~~~~ in the markdown.

Lexical version: 0.17.0

The current behavior

Screen Shot 2024-08-19 at 9 31 41 PM Screen Shot 2024-08-19 at 9 31 52 PM

The expected behavior

Screen Shot 2024-08-19 at 9 32 07 PM

Impact of fix

I am new to lexical, and I am having a hard time to fix the issue for a company. Is there a solution such as Markdown Transformer to add it to the array of transformers ?

export const PLAYGROUND_TRANSFORMERS: Array<Transformer> = [
  HR,
  ...ELEMENT_TRANSFORMERS,
  ...TEXT_FORMAT_TRANSFORMERS,
  ...TEXT_MATCH_TRANSFORMERS
];
keiseiTi commented 2 months ago

The reason seems to be that this whitespace is bolded

etrepum commented 2 months ago

The issue here is that **** usually means something else in Markdown, there's no provision for applying styles to an empty string, so the emitter should be special cased for that. A CommonMark parser would interpret this as a thematic break (rendered as an hr tag)