110 points · by ozanyurtsever · 4y ago · 79 comments
Until this year, draft.js was one of the mainly used libraries out there for building web based text editors, and there are lots of component libraries for React based on draft.js. However, the development team(which is facebook) has announced that the project is not under development anymore, since they have started a brand new project, which is Lexical. Lexical is a framework to build text editors and is under early development currently. By using Lexical, I have built a new component library that comes with a ready to use rich text editor. It is under very early development as well, as I am trying to make it more modular and flexible with each improvement. I hope this project can help some startups that needs to implement a highly functional text editor to their projects. All of the support(like stars) and contribution to the project is very much welcomed.
Thanks.
----
I know you're reading this, Wiktor. Say hi to the team for me.
It depends. If the editor is a central part of what your software is doing and you need/want total control, it's well worth it. General purpose libraries are mostly made of bloat when your project just need 20% of all the things they (have to) do. Focusing on that 20% could be a good time investment and yield a better software.
And that's just the start. Check what happens in different browsers when you hit backspace in a contenteditable containing a single space character.
Overall there are a lot of such changing, undocumented behaviours.
What does Verbum do differently than ProseMirror?
Back at the beginning of last year I was using TipTap v2 for a project (when it was in closed beta), one of the best open source communities I have had the pleasure of working with. I helped to contribute the Vue3 port of TipTap, required going quite deep into how both Vue3 and ProseMirror work. Was great fun, sadly not working with anything rich text related at the moment.
Using Yjs in combination with PouchDB worked really well, it effectively allows you to have conflict free auto merging for Pouch/CouchDB documents.
See here for details:
https://discuss.yjs.dev/t/distributed-offline-editing-with-c...
https://gist.github.com/samwillis/1465da23194d1ad480a5548458...
I can never expect a WYSIWYG editor from a library to work 100% without friction on every platform.
I know it's already near-impossible to implement a web-browser and adding more to the pile of standards/components to implement sounds counter-intuitive. On the other hand, a basic browser that can render just basic HTML and basic CSS is comparatively easy and I would rather have them be able to render a rich-text-field on a low-capability device than being able to do all sorts of JS/CSS magic.
I'm not even against React and all the amazing ecosystem surrounding it - given that your use-case justifies it. I just think auto-completers and rich-text editing and other stuff that nearly every website on this planet re-implements should be standard.
- Every platform (windows/macos/ios/android/linux, firefox/safari/chrome. There are all sorts of platform specific details - like windows using \r\n instead of \n. Your rich text editing component needs to feel native everywhere - even though that means something different on every platform.
- Undo / redo support
- Support for international inputs - to support Korean, Japanese and Chinese characters.
- Detailed canonicalized editing events for integration with collaborative editing libraries
Years ago I played around with the rich text editing components in Cocoa (MacOS) and coming from the web, its an utter delight. That code is all there on your machine - its just not exposed through the web browser. So we're stuck with janky half working "rich text" editors in reddit, slack and everywhere else online.
Decades of halfbaked attempts has shown that custom javascript isn't good enough to solve this.
Its is a web standards problem. Rich text editing should be built in to the web browser.
On the subject of Cocoa, I can't even find the docs anymore for the low-level text shaping layers of the system. I've looked a couple of times because I want to re-implement some parts of those APIs. Everything seemed so well-designed, but now it's lost to the sands of time as Apple archives documents and Google search deteriorates. Alas.
EDIT: blessings! I found some of the docs for Cocoa's text layout system. Just look at this. If only we had this for the web, as a standard...
https://developer.apple.com/library/archive/documentation/Co...
EDIT 2: Oh, Apple has a new text layout engine "TextKit 2". I haven't found any of the really nice technical illustrations or long-form guides for it. Instead, I'm watching this video: https://developer.apple.com/videos/play/wwdc2021/10061/
Having a rich text editor in the web standards would be nice for prototyping. However all the form elements (select, date picker, progress bar etc.) are also web standards but no one uses them because they are ugly and not customizable.
So the chances that we will get a standard rich text editor on the web that web devs would actually use are slim.
Nobody uses the built in date picker because it’s ugly, and making your own date picker is relatively easy. (Well, at least on desktop). Rich text editing is the inverse - it’s basically impossible to make your own. But theming a built in rich text editor should be really easy.
All the browser should implement is a rich text area itself. Leave it up to the web developers to add our own buttons for bold / italics / etc - since people will want to style that stuff themselves anyway. And add a clean, simple event API for “onchange” or something which gets called before any change is applied to the text area - initiated by a user or by the system. The event should tells you exactly what the change is (including styling) and let you tweak the change before it gets applied to the input element.
I think web devs would go bananas for something like that if it was designed well. I’d use it for sure.
it's the application that should decide how it's to be displayed in different contexts
you're fighting the web if you're trying to do it otherwise, but then again, everybody is nowadays...
The world wide web is a free platform where you can publish plain text or HTML, but denying that it also became an application delivery platform is fighting against the reality.
I'm an early-internet kid, and even if we are going back to discover the "spirit of the internet", those times are full of contenteditable hacks and custom applet HTML editors.
Being able to edit HTML visually is so common, be it a simple personal homepage, editor to a corporate blog, or a product management tool.
I would even go as far as suggesting WebKit compiled to WASM would be better than trying to make a rich text editor based on contenteditable work everywhere, once you have it working in one version it runs “everywhere”. Although accessibility is going to be the main disadvantage of such system.
This sort of behavior is basically impossible to reimplement in javascript for every platform in a way that feels "native".
Skia have a WASM port, I could see it being an amazing base for a graphics/rich-text product: https://skia.org/docs/user/modules/canvaskit/
I think the difference is WASM will be really good for content creation (see Figma), but we really don't want it for content consumption - unless its seriously clever visuals or background data processing.
Not great for accessibility though (yet)
In part that's due to the shortcomings of HTML itself.
And no, markdown a.k.a. whatever the interpreter accepts is decent enough at what it does but it's not what we are looking for here.
For output (the value of the field), HTML is good enough already.
I don't see the problem.
sure, the "semantic web" failed, but that's the history
you were not supposed to be able to control how content looks like on the web, this was supposed to be the choice of the browser customized by the user (eg. a user could set his browser to render sci-fi topics web pages text with font X and financial news with font Y min-size Z etc.)
"web design" is something that should't have ever existed or had any reason to even be a concept...
it all went off-the rails in the real world ofc, but this was the real context and dream of the web and its tehnologies as they were designed and standardized
I respectfully disagree. Rich text editing is more about being able to add semantics than making giant red blinking text. I want to explicitly add paragraphs, emphasis, links etc. without learning a new input method for every website.
A bulleted list is [add new element] > [buleted list] -> a container with text fields for each bullet (+ add/remove buttons) appears.
Same for table, a proper grid with separate inputs for all cells (see modern Confluence).
Playground plugin: https://github.com/facebook/lexical/blob/main/packages/lexic...
Copy paste: https://github.com/ozanyurtsever/verbum/blob/bfac38815eb0057...
Made a PR at least to credit the authors https://github.com/ozanyurtsever/verbum/pull/3/files
Am I missing something?
Its maintenance status is... questionable, although my information is out of date (see last paragraph).
* Github: https://github.com/quilljs/quill/ * It's latest release was 2019-09-09 – which is _ages_ in term of a JS library. * There's tons of open issues, the maintainer was (or still is) rather quiet. * It's pretty much a one-man-show. Although now that I look at it, the last few months a second contributor appeared. * Apparently there is a v2 in the works, but nobody know when it is due nor what its status is. * There were issue that asked whether the project was abandoned. The issues went unanswered, and then were deleted.
To be fair: development seems to have picked up again. There were sporadic commits at the end of 2021, and I now see that there are a few this year, too.
These options just improve over the document model and relevant document manipulation APIs - which won't be a requirement until your product's core is an editor.
There are lot of great react libraries which I would like to use in non-react applications and it would be great to have that same library in some X framework by just building a wrapper over it.
I'm in the process of migrating my companies RTE from Slate to Lexical.
I've been able to remove thousands of lines of custom code and increase the performance and reliability