Closed burtonator closed 4 months ago
Quick status update. I have the first step done. I have a repo where I can work with lexical.
The next step is to figure out how to make it do BASIC markdown import and export. Lexical has support for this natively I think.
I think we could break this out into two spikes. This first is just lexical with BASIC markdown support. Then I can look at more advance exports later.
Another thing I realized is that if we go down this path to support Lexical directly, I think we can implement @ mentions where we popup and autocomplete widget and / (slash commands) where we can supports commands ALA Notion or github.
I think this could give us like 90% of an advanced editor but internally I'd prefer it not just be one contenteditable.
I'm still working through this though and trying to understand Lexical's model.
Other things we have to test for v1 (basic editor)
ul
element. Here's a good thread on the subject: https://stackoverflow.com/questions/3003476/get-underlined-text-with-markdownTableNode
and both Lexical and MDXEditor have implementations of these. MDXEditor is better though.We also need to discuss which features/plugins from Lexical and MDEditor we should adopt and we also need to make sure they are supported in markdown.
We could consider adding support for oembed but this would be more work in the future.
UPDATE: This is how we would build our own editor. I have a potential solution for how to use MDXEditor directly. See below.
I'm pretty much completed the research on this spike. I still want to read a bit more about the internals of lexical to help make a better decision but here is where we stand so far.
I think there are two paths we can go moving forward.
Basically we would fork the MDXEditor and customize it internally to do what we want it to do but just deal with the idiosyncrasies of that framework. We'd have to port it from RadixUI to our own UI and then figure out what to do with their store.
I don't understand how their store works and they use a proprietary store called GuruX.
pros:
cons:
I would prefer this plan. I think the main challenges here involved:
Tables: This actually turns out the be the hardest part which I didn't originally anticipate. Tables are a plugin so require a custom react UI. I think I can take the table code from MDXEditor and just use it in our editor. It's under an MIT license so that's fine.
Plugins: I don't fully understand the plugin API right now but implementing tables would give me a good feel for how hard it's going to be. We can really implement some amazing functionality here including embeds, notion-style drag and drop, autocompletion, custom toolbars, etc.
pros:
cons:
There are other issues here including:
We can fit 9-10 buttons on mobile...
I think we might be able to use MDXEditor for now if:
I think we only need to following buttons on mobile:
I think we should investigate using Lexical directly and just bypass MDXEditor.
@ForestMars
Here are the main things I need to investigate in the next spike:
... 14h total but it will probably be less than that. I'm mostly worried about the markdown functionality and I want to really investigate this to make sure we're not missing something.
The other issue is that there's no real plugin support for codemirror or mermaid.js or any other GFM extensions so we either:
There's also the issue with Github Flavored Markdown (GFM) and other extensions that we might need to support.
What I'm worried about with this issue is that unless we really support all these extensions in our editor that we might paint ourselves into a corner in the future because we standardize on Lexical. I think what MDXEditor does is implement some of this via micromark and mdast but I need to investigate.