Markwon
Markwon copied to clipboard
Provided EditHandlers for MarkwonEditor
-
Markwon version:
4.6.0
Hi there :wave:
i'd like to use the MarkwonEditor
for the Nextcloud Notes and Nextcloud Deck apps. However i am struggling because the MarkwonEditor
seems to be a very basic version and while all punctuation seems to be working finde, one needs to implement EditHandler
s for each feature himself.
I tried to copy some of the handlers (like StrikethroughEditHandler
) and tried to integrate them. They seem to work well, but
- I am wondering why they are only in the
samples
package and not provided by default like theStrongEmphasisEditHandler
? - I have massive issues to implement a
HeadlineEditHandler
properly
Could you please give me a statement whether more features will be shipped in the future for the MarkwonEditor
?
Do you think you can find some time to help implement them for the markwon repository (I am willing in helping you if i can)?
Thank you in advance Stefan
Hello @stefan-niedermann ,
Ideally an editor would need source positions for each node. Unfortunately commonmark-java, on which Markwon is based, does not provide them. Well, support was added recently for block nodes (it is still unreleased), but not inlines (so, no emphasis, strikethroughs, links, etc). So, I had an idea to use text diffing instead. What editor
does is it takes original (source) input and compares it to rendered output. What is different - is markdown syntax. It works quite well. Until you need something more, like a strong indication or a real WYSIWYG editor. Because these would effectively mean parsing markdown again and this time manually.
So I created few edit handlers and put them in sample
as a reference, because I was not able to provide full support for all markdown syntax nodes. Hoping to raise some discussion and polish the solution later. Well, no discussion did happen and as I have no active project involving editor
, this artifact became a bit stale.
I see your HeadlineEditHandler
and think you will need to find the first new line index (or use the text length) in order to close the span. What other problems do you have with it?
I'm definitely looking forward to knowing what editor
is capable of. Unfortunately I do not have much time resources to do it alone. So if you are (or anyone else, everyone is welcome!) willing to participate, then let's do it
BTW, not having source positions information attached to nodes was initial motivation behind commonmark-java fork - flexmark-java. Flexmark-java was created to support markdown editor plugin for Intellij
🤔 ok @stefan-niedermann, uhm... Assuming we can harass @noties with a couple of questions, what about getting this actually done? I mean we had quite some results, way not perfect but we at least achieved something, so maybe we should just wiggle around and ask some questions, I think we can make this work for us and all others as well?
@noties I assume PRs are welcome?
Definitely @desperateCoder , all questions and PR are welcome
@noties for your information: We are working on the headlines right now.
If you allow, i will open a PR once it is finished which moves all EditHandler
implementations from the samples
to the actual code, so they don't have to be copy&pasted and add our EditHandler
implementation for headlines.
PR: https://github.com/noties/Markwon/pull/317 (Still a draft :warning: Do not merge yet!)
Source info on common-mark library has been released for version https://github.com/commonmark/commonmark-java/releases/tag/commonmark-parent-0.16.1