Markdown Editor
WYSIWYG markdown editor on Tiptap/ProseMirror — Toolbar-driven headings, bold/italic/strike, inline code, lists, task lists, blockquote, code block, rules, links, and tables, with markdown typing shortcuts, emitting a controlled markdown string via @change; render stored markdown with the Markdown piece.
Installation
Copy the piece into your app — it compiles with your build and the code is yours. It pulls in the toolbar piece and lib/markdown-doc.js, and needs the Tiptap packages:
puzzle add piece markdown-editor
npm install @tiptap/core @tiptap/pm @tiptap/starter-kit @tiptap/extension-list @tiptap/extension-table @tiptap/markdown
Usage
import MarkdownEditor from '@/components/ui/MarkdownEditor.pzl';
<MarkdownEditor label="Post body" value={ md } @change={ setMd } />The value prop is the markdown string and the parent owns it; the @change callback fires value-first with the full markdown string on every edit. A label names the content region for assistive tech, a placeholder shows while the document is empty, a disabled flag makes it read-only, and any class is appended to the root.
The editor emits CANONICAL markdown, which may not be spelled the way you fed it: feed it asterisk bullets and the next @change hands back dashes, extra blank lines get normalized, and so on. It accepts equivalent spellings on the way in without resetting the selection or undo history — but if you store what comes out, expect the canonical form.
Live document
## Hello, markdown Select some text and use the toolbar — **bold**, *italic*, ~~strike~~, `code`, lists, quotes, and [links](https://example.com). - Type `- ` to start a bullet list - Type `# ` for a heading > Everything you type round-trips through a markdown string.
Tables
Disabled
Markdown support
The toolbar and the typing shortcuts cover H1 through H3, bold, italic, strikethrough, inline code, bullet lists, ordered lists, task lists, blockquotes, fenced code blocks, horizontal rules, links, and tables. Undo/redo use the standard shortcuts. When the caret is inside a table a second contextual toolbar appears with the row, column, and header actions.
Deliberately absent, and why:
- Underline and text alignmentMarkdown cannot express either one, so a button for them would produce formatting that the string silently drops. Reach for the Rich Text Editor piece when you need them — its JSON tree carries both.
- ImagesThe editor schema has no image node, so an image typed as markdown will NOT survive the round trip — it comes back as literal text. The Markdown RENDERER displays images fine; this is an editor-side limit only.
- H4 through H6Headings stop at three levels, which is the range a document body actually needs and keeps the toolbar honest.
Store the string and render it with the Markdown piece — the two pieces share lib/markdown-doc.js, so editor content and rendered output carry the same typography classes.