Lurker News
Hi HN! I got so frustrated with modern WYSIWYG editors that I started to play around with building my own.

The problem I had was simple: I wanted a low-tech way to type styled text, but I didn't want to load a complex 500KB library, especially if I was going to initialize it dozens of times on the same page.
Markdown in a plain was the best alternative to a full WYSIWYG, but its main drawback is how ugly it looks without any formatting. I can handle it, but my clients certainly can't.
I went down the ContentEditable rabbit hole for a few years, but always came to realize others had solved it better than I ever could.
I kept coming back to this problem: why can't I have a simple, performant, beautiful markdown editor? The best solution I ever saw was Ghost's split-screen editor: markdown on the left, preview on the right, with synchronized scrolling.
Then, about a year ago, an idea popped into my head: what if we layered a preview pane behind a ? If we aligned them perfectly, then even though you were only editing plain text, it would look and feel like you were editing rich text!
Of course, there would be downsides: you'd have to use a monospace font, all content would have to have the same font size, and all the markdown markup would have to be displayed in the final preview.
But those were tradeoffs I could live with.
Anyways, version 1 didn't go so well... it turns out it's harder to keep a textarea and a rendered preview in alignment than I thought. Here's what I discovered:
- Lists were hard to align - bullet points threw off character alignment. Solved with HTML entities (• for bullets) that maintain monospace width
- Not all monospace fonts are truly monospace - bold and italic text can have different widths even in "monospace" fonts, breaking the perfect overlay
- Embedding was a nightmare - any inherited CSS from parent pages (margin, padding, line-height) would shift alignment. Even a 1px shift completely broke the illusion
The solution was obsessive normalization:

    // The entire trick: a transparent textarea over a preview div
    layerElements(textarea, preview)
    applyIdenticalSpacing(textarea, preview)

    // Make textarea invisible but keep the cursor
    textarea.style.background = 'transparent'
    textarea.style.color = 'transparent'
    textarea.style.caretColor = 'black'

    // Keep them in sync
    textarea.addEventListener('input', () => {
      preview.innerHTML = parseMarkdown(textarea.value)
      syncScroll(textarea, preview)
    })
A week ago I started playing with version 2 and discovered GitHub's element, which handles markdown formatting in a plain really well.

That experiment turned into OverType (https://overtype.dev), which I'm showing to you today -- it's a rich markdown editor that's really just a . The key insight was that once you solve the alignment challenges, you get everything native textareas provide for free: undo/redo, mobile keyboard, accessibility, and native performance.
So far it works surprisingly well across browsers and mobile. I get performant rich text editing in one small package (45KB total). It's kind of a dumb idea, but it works! I'm planning to use it in all my projects and I'd like to keep it simple and minimal.
I would love it if you would kick the tires and let me know what you think of it. Happy editing!
---
Demo & docs: https://overtype.dev
GitHub: https://github.com/panphora/overtype

Comments (99) 66 threads

Earlier comments
Imustaskforhelp1 reply#
what is this tom foolery. I am so amazed by it, this also seems to be a WYSIWYG but though it doesn't support markdown exactly per se but it has way more features than overtype (no offense to overtype which is also a really really cool project)

My mind is utterly blown with what you can do with 912 bytes.
I imagine that I can create a really simple blog post that can load under 14 kb so that it can be sent in a (single request?) while still having comment feature with this one while also being super fast..
So good that words can't explain lol

WA#
It uses queryCommandState(), which is a deprecated browser feature [1]. It's quite common in many simpler WYSIWYG editors. Thing is, it might be so widespread that some people claim that it will never be truly deprecated.

OverType doesn't use this and the result is that you gotta build all the features in JS.
[1]: https://developer.mozilla.org/en-US/docs/Web/API/Document/qu...

vmurthy3 replies#
Went down the rabbit hole which is the overtype.dev website (nice work btw!) and found and even nicer rabbit hole - https://hyperclay.com/ Single HTML apps :). Enjoy!
runako#
This reminds me of some of the better experiments in mid-aughts Web dev, and is exactly the kind of project that helps push standards & user expectations forward.
dcreater#
I don't say this often or lightly: my mind is blown.

Why is this not catching fire? Especially in the day of vibe coding this is a far better and far more effective route to app building

pavlov#
This is coming close to WWW's original vision because the very first web browser was also an editor. Tim Berners-Lee's application on the NeXT was basically a wrapper for the operating system's built-in rich text editing class named TextView. (It later became NSTextView on Apple's Mac OS X and still powers the TextEdit app on Mac.)

We lost editing for two reasons:
1) The HTTP PUT method didn't exist yet, so edited HTML files could only be saved locally.
2) Mosaic built a cross-platform web browser that defined what the WWW was for 99% of users, and they didn't include editing because that would have been too complex to build from scratch in their multi-platform code base.

janwilmake1 reply#
Really cool! I just love the simplicity of it: has no drawbacks compared to regular textarea, but has lots of benefits. you basically improved textarea, by a lot!

I also made a similar thing a while ago called contextarea.com, maybe, I should add overtype!

ikurei#
Having to use a monospaced font is a pretty big drawback. To me, it means I wouldn't use this for a product that wasn't intended for a techie programmer audience.

Not that it isn't a really cool project! I'm only saying it has clear drawbacks.

garbageoverflow3 replies#
If it were a WYSIWYG editor, there'd be previews for images. But it seems like it's just syntax highlighting for textareas. Nice project either way, but false advertising.
calmworm1 reply#
I didn’t see an option for images. Am I missing something?
macintux#
I assume that was the point. The parent commenter feels "WYSIWYG" by definition includes images.
WA2 replies#
I can type text, mark it, click "B" for bold and it works. This is WYSIWYG minus images.
clippyplz1 reply#
WYSIWYG does not refer to the icons in the toolbar, but rather the text itself. This is not WYSIWYG because when I make something bold, I see a bunch of asterisks around it.

Still a cool project, but someone who does not understand markdown would wonder why pressing the heading button makes my text into a hashtag instead of making it bigger.

WA#
I see both. It's bold and has asterisks around the bolded text.
eviks#
You see _ text _, but instead of 2 underscores you get formatted text. That's a definitional violation of WYSIWYG editing style
ricardobeat#
Indeed it is a misuse of the term. An actual WYSIWYG editor would not show any of the formatting markers.

By definition a “Markdown editor” cannot be WYSIWYG - you can have a WYSIWYG editor that is powered by markdown underneath though, which this is not.

Load more comments