DEV Community

Discussion on: Build your own WYSIWYG markdown editor for Vue 📝👀

Collapse
 
bogdaniel profile image
Bogdan Olteanu

Selection API is something really nice but as it states is experimental, second option would be range combined with a tree-like structure as you said and contenteditable since it's closest to what we want. prob's textarea would work fine too. The Range API I don't really like it for the moment .. :-) specially if you would want to combine it with a tree structure or maybe I'm missing a few things here and there. :D

Thread Thread
 
thormeier profile image
Pascal Thormeier

To be honest, I would have to read a lot deeper into the range API to really understand it, but it does look promising! I hope that the Selection API will get some more attention and leave the "experimental" state soon, since it has a lot of potential. What's the reason for you not liking the Range API at the moment?

Thread Thread
 
hasnaindev profile image
Muhammad Hasnain

Despite being experimental, the selection API has the same support as the range API. Perhaps an abstraction layer would do the trick but will take a lot of time and careful engineering.

About a year ago I really wanted to create my own WYSIWYG editor. Things I read about document exec were not good. For instance, what happens when someone tries to paste text from outside, how are we going to handle the tags in the pasted text.

Moreover, it is deprecated which is literally a mood killer. Someday I'll create a really simple WYSIWYG editor using range and or selection API. I have general knowledge of trees but working with nodes, correctly inserting and removing nodes is NOT an easy thing.

Thread Thread
 
bogdaniel profile image
Bogdan Olteanu • Edited

Yeap, same here would really love to build my own WYSIWYG even for testing / learning purposes I know a great range of editors but still want to dive in this part and build one from scratch..
document exec is great and easy to use most of the editors these days are based on them except the very new ones. but as you said it's deprecated and you can't count on it + building with exec it's a 20 - 30 minutes jobs to do simple things. Diving into selection and range that's the real stuff to play with.

Thread Thread
 
hasnaindev profile image
Muhammad Hasnain

Indeed. When I was looking into this initially an agency shared a kind of a case study saying that making a WYSIWYG was one of the most difficult things that they had ever done. They even went on to say that it is one of the most complicated thing on the front-end.

Thread Thread
 
thormeier profile image
Pascal Thormeier

Oh yes, it absolutely is. I find it an absolute pity that execCommand got deprecated. This thing shows how simple it could be, but ultimately isn't when you want to have support on all browsers and not rewrite that thing in a year or two.