Re:My pain building a WYSIWYG editor with contenteditable
by thomasikzelf on Saturday September 18, 2021 @08:21AM
(#28575651)
I feel your pain. Have you seen prose mirror? It should do everything you listed. It takes some time getting it up and running and understanding the api but after that it seems really consistent. If you end up creating your own library you should read the blog from marijn haverbeke (creator of prosemirror and codemirror) it gives a lot of insights into building a WYSIWYG editor. I think another problem is that keyboard events are not fired on mobile so your solution might not work there.
https://marijnhaverbeke.nl/blog/
Re:My pain building a WYSIWYG editor with contenteditable
by jclem on Saturday September 18, 2021 @09:26AM
(#28576093)
Seconding ProseMirror [1] as the least buggy editor implementation on top of contenteditable I’ve seen yet. It also supports JSON serialization and has plenty of support for complex custom pieces of content in the document.
The ProseMirror API is quite low-level-feeling for many use cases, however, and TipTap [2] is doing a good job of building a friendlier wrapper around it.
That said, neither of these are perfect and there are bugs here and there, especially on mobile devices, but they’re better than any other solution I’ve seen so far.
Re:My pain building a WYSIWYG editor with contenteditable
by jclem on Thursday September 23, 2021 @11:18PM
(#28638247)
Ah, one of the bugs with Slate was with spell-checking. On mobile Safari, at least, its text nodes aren’t marked by spell check unless they’re interacted with by the user after they’ve been typed.
As I’d said, they all have bugs, including ProseMirror. I just found that PM solved most of the ones I cared about relatively well.
Re:My pain building a WYSIWYG editor with contenteditable
by jclem on Thursday September 23, 2021 @11:13PM
(#28638223)
Last I evaluated them, they had some bugs that wouldn’t work for my use case. For example, Quill has the annoying bug on mobile Safari of blocking the native behavior of capitalizing the first letter of a new line.
I don’t remember what I found in Slate, however, and it’s possible it may be much better now.
Re:My pain building a WYSIWYG editor with contenteditable
by pier25 on Saturday September 18, 2021 @10:28AM
(#28576530)
ProseMirror is probably the best option out there, but I found it pretty hard to wrap my head around its API.
The docs are detailed and exhaustive but did not help me much understand how to actually use it. I had to read Marijns code which I found hard to follow.
I started this introduction to PM (which is incomplete since I stopped using it) but I think will help anyone trying to use it.
Re:My pain building a WYSIWYG editor with contenteditable
by thomasikzelf on Saturday September 18, 2021 @12:57PM
(#28577599)
> The docs are detailed and exhaustive but did not help me much understand how to actually use it. I had to read Marijns code which I found hard to follow.
That was also my experience. Your examples would've helped me a lot a couple of months ago. Thanks for writing it down!
Re:My pain building a WYSIWYG editor with contenteditable
by pier25 on Sunday September 19, 2021 @09:34PM
(#28589576)
My pleasure.
I'm actually a bit embarrassed that I abandoned it considering it's my most starred repo... but I haven't touched PM in months and don't have much time to pick it up again.
Re:My pain building a WYSIWYG editor with contenteditable
by zamalek on Sunday September 19, 2021 @07:49AM
(#28583593)
I had to replicate the SharePoint people picker: "resolved" values are styled and are removed as a whole with a single backspace/delete. SP was doing something super neat: it used ::after and content with an empty tag. A pretty neat trick, if you don't need to embed HTML (as content only supports plain text).
The bulk of my time was spent removing text formatting on paste, and Safari bugs.
The ProseMirror API is quite low-level-feeling for many use cases, however, and TipTap [2] is doing a good job of building a friendlier wrapper around it.
That said, neither of these are perfect and there are bugs here and there, especially on mobile devices, but they’re better than any other solution I’ve seen so far.
[1] https://prosemirror.net/
[2] https://tiptap.dev/
As I’d said, they all have bugs, including ProseMirror. I just found that PM solved most of the ones I cared about relatively well.
I don’t remember what I found in Slate, however, and it’s possible it may be much better now.
The docs are detailed and exhaustive but did not help me much understand how to actually use it. I had to read Marijns code which I found hard to follow.
I started this introduction to PM (which is incomplete since I stopped using it) but I think will help anyone trying to use it.
https://github.com/PierBover/prosemirror-cookbook
That was also my experience. Your examples would've helped me a lot a couple of months ago. Thanks for writing it down!
I'm actually a bit embarrassed that I abandoned it considering it's my most starred repo... but I haven't touched PM in months and don't have much time to pick it up again.
The bulk of my time was spent removing text formatting on paste, and Safari bugs.