r/javascript • u/SamysSmile • Feb 24 '26
I spent 14 months building a rich text editor from scratch as a Web Component — now open-sourcing it
https://github.com/Samyssmile/notectlHey r/javascript,
14 months ago I got tired of fighting rich text editors.
Simple requirements turned into hacks. Upgrades broke things. Customization felt like fighting the framework instead of building features.
So I built my own ;-)
What started as an internal tool for our company turned into something I’m genuinely proud of — and I’ve now open-sourced it under MIT.
It's called **notectl** — a rich text editor shipped as a single Web Component. You drop `<notectl-editor>` into your project and it just works. React, Vue, Angular, Svelte, plain HTML — doesn't matter, no wrapper libraries needed.
A few highlights:
- 34 KB core, only one dependency (DOMPurify)
- Everything is a plugin — tables, code blocks, lists, syntax highlighting, colors — you only bundle what you use
- Fully immutable state with step-based transactions — every change is traceable and undoable
- Accessibility was a priority from the start, not an afterthought
- Recently added i18n and a paper layout mode (Google Docs-style pages)
It's been one of the most challenging and rewarding side projects I've ever worked on. Building the transaction system and getting DOM reconciliation right without a virtual DOM taught me more than any tutorial ever could.
I'd love for other developers to use it, break it, and contribute to it. If you've ever been frustrated with existing editors — I built this for exactly that reason.
Fun fact: the plugin system turned out so flexible that I built a working MP3 player inside the editor — just for fun. That's when I knew the architecture was right.
- GitHub: https://github.com/Samyssmile/notectl (MIT License)
- Try it live: https://samyssmile.github.io/notectl/playground/
- Docs: https://samyssmile.github.io/notectl/
26
u/metehankasapp Feb 24 '26
Congrats, rich text is a deep rabbit hole. What’s your internal model: DOM-as-source-of-truth or a separate document model? Also, how do you handle IME/composition and clipboard pastes from Google Docs/Word?
18
u/99thLuftballon Feb 24 '26
It behaves bizarrely with a touch screen device. Random words duplicate onto the next line. The cursor jumps behind the word you just typed. Writing several words in a row puts them in the wrong order.
3
u/Beginning_One_7685 Feb 24 '26
Shouldn't it have a code view? I notice after a few bits of styling there are lots of nested span tags.
2
u/FisterMister22 Feb 24 '26
Autocorrect with mobile seem to insert a the corrected word In front of the typed incorret word
2
u/Fortyseven Feb 25 '26
Looks great!
I'd find a
.getMarkdownuseful.When I was playing around with it, I noticed tables were completely ignored in the output: https://i.imgur.com/j2DUDO2.png
I'll pull down a fresh copy locally and reproduce it, and if it's still doing it I'll write up an issue on the repo.
2
u/TobiObeck Feb 28 '26
Cool project!
Here a few things I noticed:
Tested on Android with Firefox.
2
u/No_Schedule2410 Mar 18 '26
nice contribution sir
9
u/hockeyketo Feb 24 '26
Reminds me of this: https://xkcd.com/927/
1
u/33ff00 Feb 25 '26
I get no rich text on ios. Italic/bold/font size indicate change, but the text is unchanged
1
u/ThatHappenedOneTime Feb 25 '26
Looks good! How did you tackle caret movement?
1
u/nikki969696 Feb 26 '26
My org doesn't allow inline styles (CSP) - I haven't looked at your code yet but do you support using classes or setting a nonce?
1
u/husseinkizz_official Mar 01 '26
How style-able is it or like customizing the looks? and how easy to embed?
9
u/czpl Feb 24 '26
you didn’t even write this post
0
u/[deleted] Feb 26 '26
[deleted] — view deleted comment
2
u/[deleted] Mar 03 '26
[removed] — view removed comment