Rich Text Editor
WYSIWYG editing on Tiptap/ProseMirror with a block-style dropdown (Normal text, Heading 1-4) and the Toolbar piece as its formatting bar. The value is not HTML — it is a structured JSON document tree (Shopify's rich text metafield shape, extended with alignment and more), controlled via value and @change. Render stored documents with the Rich Text piece.
Installation
Copy the piece into your app — it compiles with your build and the code is yours. It pulls in the toolbar piece, lib/rich-text-doc.js and lib/rich-text-blocks.js, and needs the Tiptap packages:
puzzle add piece rich-text-editor
npm install @tiptap/core @tiptap/pm @tiptap/starter-kit @tiptap/extension-text-align
Usage
import RichTextEditor from '@/components/ui/RichTextEditor.pzl';
<RichTextEditor label="Post body" value={ doc } @change={ setDoc } />Live document
Disabled
Data format
The document is a node tree — a superset of Shopify's rich text metafield format (their format plus align, underline/strike, blockquote, code-block, and the image and link-preview atoms). Store it as JSON; render it with the Rich Text piece or your own tree walker.
{
"type": "root",
"children": [
{ "type": "heading", "level": 2,
"children": [{ "type": "text", "value": "Shipping" }] },
{ "type": "paragraph", "align": "center",
"children": [
{ "type": "text", "value": "Orders ship in " },
{ "type": "text", "value": "2 days", "bold": true },
{ "type": "link", "url": "/policy",
"children": [{ "type": "text", "value": "details" }] }
] },
{ "type": "list", "listType": "unordered",
"children": [
{ "type": "list-item",
"children": [{ "type": "text", "value": "Free returns" }] }
] }
]
}