Hoping to revive this topic since A) Iām really interested in it and B) I donāt understand it so Iād like to write my thoughts out.
Starting with the website example for markdown: http://prosemirror.net/examples/markdown/
As I understand it, this example is not really applicable to collaboration because the editor is either a textArea with markdown in it, or a Prosemirror instance, but it is never a Prosemirror instance with markdown in it.
Now the example could instead convert the Prosemirror code into markdown and replace the state of the existing Prosemirror instance with the markdown code, but this is a naive delete and update of the entire previous state of the document (not that that is any worse than what the example is doing, it just doesnāt get us any closer to collaboration).
To seamlessly collaborate the same content across two editors instances⦠First instance has the document formatted in Markdown, and Second instance has the document formatted in HTML, you need to normalize the transformations that happen between the two. This is very difficult though because so many things are different between the two editor doc formats. The most basic of them being node position/index.
The first line in a Markdown Prosemirror document might be something this:
[weblink](http://web.link)
Whereas in an HTML Prosemirror document it would be:
weblink
The internal Prosemirror schema representation would have the former be represented as plain-text node and the latter a node with marks propties of text=āweblinkā type.name=ālinkā attrs.href=āhttp://web.linkā etcā¦
letās say you change the text of the link. When modifying this in one type of editor, the position/index is different than in the other, so the transforms are not shareable without some type of fancy normalization.
Now Iām not sure if what I say above is actually true. Even if it is, this is where I totally get lost on what the next step towards a solution would even be. It seems like youād need some fancy way of parsing an interpreting the changes on the markdown documentā¦
Letās say you had written [weblink(http://web.link)
in the Markdown based editor. This plain text would be propagated over to the HTML Prosemirror editor. Then you realize your mistake and add the closing ]
on the right side of weblink.
In the Markdown editor, this change just represents a single step transformation of adding a character to a specific position in a plain text node. In the HTML editor wouldnāt it be necessary for the transformation to be a deletion of the the text node: [weblink(http://web.link)
and the insertion of a link node: weblink??
Now looking at this in a slightly different way. Would it be a lot more straightforward if we allowed for markdown to be written in a standard Prosemirror instance, but automatically convert said markdown to HTML. So as soon as someone wrote [weblink](http://web.link)
it would be converted into a transformation step that deleted that text node and inserted weblink. Now a user could write either way and doing the collaboration not next to impossible. You could still do read-only conversion of the text to Markdown if you wanted to copy paste Markdown⦠the only limitation would be that you canāt write and view the native markdown representation.
Would appreciate any feedback on where I am totally not getting things!