ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.97k stars 3.25k forks source link

Markdown (such as italics) does not apply to elements that are already headers #4575

Open justingolden21 opened 3 years ago

justingolden21 commented 3 years ago

Description Markdown (such as italics) does not apply to elements that are already headers

Recording image

https://www.slatejs.org/examples/markdown-preview


Slate is flexible enough to add **decorations** that can format text based on its content. For example, this editor has **Markdown** preview decorations on it, to make it _dead_ simple to make an editor with built-in Markdown previewing.
# *hi*
# _hi_
# **hi**
# hi
*hi*
_hi_
**hi**
hi

Environment

ricardo commented 3 years ago

@justingolden21 The markdown demo in itself is pretty limited. Having nested styles would require recursion on the Prism tokens.

Here's a demo I did: https://codesandbox.io/s/slate-0-5x-forked-75lx0?file=/src/App.tsx, notice the styles get nested.

I think I'll propose a PR to get this added.

Note: The prism tokens need to implement an inside prop in order for this to work. The markdown library from the Prismjs website has a more complete token list.