UCLA-IRL / ndn-workspace-solid

NDN workspace in Solid JS
https://ndn-workspace.web.app
ISC License
5 stars 15 forks source link

Support Markdown for document #125

Closed zjkmxy closed 3 weeks ago

zjkmxy commented 1 month ago

There are requests on supporting Markdown documents. Let's discuss about this.

Background

Currently, the rich document is of XML format, which is supported by Tiptap core and several extensions, and rendered as HTML.

Reason Markdown was not used

Consider the following case:

#section 1
Some text.

Suppose Alice injected another section title:

#section 1
#section 2
Some text.

And Bob wrote some text into the existing section:

#section 1
Write more. Some text.

Then, in the worst case, the final result will be

#section 1
#section 2Write more. 
Some text.

This is because when a user inserts a Markdown section, one usually presses Enter to insert the line break first, and then goes back to write the title. However, a lot of CRDT implementations (including Yjs) have problems handling text inserted in reverse order. Therefore, in the CRDT's view, Alice made two separate changes. And since they are non-continuous, Bob's change may be put in the middle of them. This leads to the strange result. This does not apply to XML documents, because the section title is surrounded with XML tags, which are specially handled by CRDT to make sure others' changes cannot easily get into the tag pairs.

Benefits of Markdown

Editor Candidates

Unfortunately TipTap does not support Markdown, so we need another editor. We may have two workflows: (1) WYSIWYG, with one panel showing the Markdown result which is also editable; (2) LaTeX-like two-panel mode, one showing the editable Markdown source and the other showing the rendered result. There are a lot of WYSIWYG editors like:

Things to consider

zjkmxy commented 1 month ago

We decided that the issue described here is not a big deal and we plan to move forward with Markdown support.

zjkmxy commented 1 month ago

See new branch: https://github.com/UCLA-IRL/ndn-workspace-solid/tree/markdown

TODOs before merge:

AnoldGH commented 1 month ago

There is a GitHub-flavour plugin, but it depends on remark-gfm 4.0. The chat Markdown is incompatible with this version (https://github.com/UCLA-IRL/ndn-workspace-solid/issues/127). Seek a way to handle this.

I pushed an update in #132 so the old version of remark-gfm is aliased now, this should resolve this incompatibility.