If you're building an app where people write posts, the editor becomes the hardest part of the page. Text is the easy bit. Then someone wants four photos in a row, a YouTube video in the middle, and a link that shows a preview. And all of it has to come back to your server as something you can store and render without opening an XSS hole.
This article walks through Post Canvas, the open source React editor I built for that job, and what I learned building it. It's MIT, it's on npm, and you can try it in the browser before you read any further: postcanvas.saimulislam.com.
Why I didn't use a paid editor
I looked at the editors people usually reach for, and each one came with a meter or a key.
- TinyMCE is free from Tiny Cloud up to 1,000 editor loads a month. After that the paid plans start at $79 a month, billed annually. Self-hosting needs a
license_key, which can be'gpl'if you accept the GPL. - CKEditor 5 has required a
licenseKeysince version 44. Self-hosted GPL use takes the key'GPL', and the CDN doesn't accept that. - Froala has no free plan. Professional is listed at $899 a year.
None of that is unreasonable for a company selling an editor. But I wanted a post box with photos in my app, and I didn't want a load counter, a licence key or the GPL attached to it. Tiptap, the MIT editor framework on top of ProseMirror, gave me the base. What it doesn't give you out of the box is the media: its image extension has no upload, and there's no gallery.
So the work was the media canvas, and the safe output.
I built it with Claude Code as a pair. I reviewed and tested every feature myself, and the mistakes below are mine.
Installing it and getting JSON out
npm install post-canvas import { PostCanvas } from 'post-canvas'; import 'post-canvas/styles.css'; export function Composer() { return <PostCanvas preset="social" onChange={({ json }) => console.log(json)} />; } The editor saves Tiptap JSON, not an HTML string. That was the first decision, and the one everything else depends on. JSON is a tree you can validate node by node. An HTML string from a browser is something you have to parse and clean before you can trust it, and every editor that stores HTML pushes that job onto you.
There are four presets: social (a post composer), article (adds a title and a cover), comment (a small reply box) and full. You can switch any single feature on or off on top of one.
Galleries: one block, four layouts
A gallery is one block holding several photos. The writer picks a layout from the gallery's own toolbar: carousel, grid, masonry or collage. They can drag to reorder and add alt text and a caption.
Uploads go through an adapter you write, so the files go to your S3 bucket, Cloudinary or your own route. The editor handles progress, retry and cancel.
The collage was the part I spent the longest on. The first photo is the background, and Arrange the collage opens an editor where you drag each photo into place, resize it and turn it, with a pinch on touch screens.
A mistake I left in: in 0.1.0, every photo after the first one in a gallery sat lower than the first, and galleries picked up the indent and bullet markers of text lists. Both are fixed in 0.1.1, and it's a good reminder to test a block inside every context a writer can put it in.
One I haven't fixed: on a laptop trackpad, a pinch in the collage editor zooms the whole page instead of the collage. Touch pinch works. It's in the README until it's fixed.
Embeds that load only when you click
Paste a link and the editor picks the block:
- YouTube and Vimeo become players.
- Spotify, SoundCloud, X, Instagram, TikTok, CodePen, Loom, Figma and Google Maps become embeds, and you can register your own provider.
- Any other page becomes a link card, through a link preview adapter you provide.
By default, nothing third party loads until the reader clicks. The page shows a facade (a thumbnail and a title), and the iframe only exists after the click. That keeps the page fast and keeps YouTube's scripts off it until someone asks for them.
The stored document doesn't hold an embed URL. It holds a provider and a validated id, and the player URL is built from that id at render time. Iframes are sandboxed. So a document that says "YouTube, id <script>" can't become a script on your page.
Safe output: the server gets the last word
The editor runs in a browser you don't control, so its output can't be trusted. post-canvas/server checks a document with the same schema the editor uses, and it needs no DOM:
import { sanitizeDocument } from 'post-canvas/server'; const { doc, removed } = sanitizeDocument(req.body.content); // store doc; log or show `removed` if you want to know what was dropped It removes javascript: links, unsafe image sources, attributes the schema doesn't know and any iframe that isn't a known provider. Then renderToHTML() gives you HTML, and in Next.js the Server Component PostCanvasView renders it without shipping the editor:
import { PostCanvasView } from 'post-canvas/render'; export default async function Post({ params }: { params: Promise<{ id: string }> }) { const { id } = await params; const post = await loadPost(id); // your data layer return <PostCanvasView content={post.content} />; } PostCanvasView sanitizes before it renders, so a bad document in your database still doesn't reach the page. The security model page lists what it protects against and what it doesn't.
Coming from TinyMCE, Froala or Quill
Those editors store a post as HTML. fromHTML() converts each old post once and reports what it couldn't keep, so you can check the result before you save it. The migration guide maps their options to Post Canvas features, and there are side by side pages for TinyMCE, React Quill, CKEditor and Froala, with a source for every cell.
What it doesn't do yet, and what it costs you
I'd rather you find this here than after you've installed it:
- Not yet: real-time collaboration, comments, AI features, emoji shortcodes, right-to-left layouts, and Vue or Angular wrappers.
- Size: the CDN build, which bundles everything (React included) for use on a plain HTML page, is about 381 KB gzipped. It's a full editor with media, not a textarea.
- Testing: most of it so far is in Chromium. Safari, Firefox and real touch devices have had less.
- Age: it's version 0.1.1, so expect changes before 1.0.
If you need tracked changes and comments for documents, TinyMCE and CKEditor are better fits today. If you need posts with text, photos, video and links, this is what Post Canvas is for.
Try it
The fastest check is the playground: switch every option and read the JSON and HTML it produces. The code is on GitHub, MIT licensed.
If you try it, tell me which gallery layout or embed you'd use first, and what's missing for your app. Issues are open.

![[Herdr in Practice] Build Your Own Herdr Mod: Create a "Pending Review" Queue with Labels to Instantly Track Unread Reports](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flasxwu5u1is3pu1fn6gi.png)