Skip to Content
Liquid Glass UI
Blocks

Tiptap Editor

A Notion-style rich-text editor on Tiptap 3 with a Liquid Glass surface — slash menu, selection bubble, block drag handle, tables, columns, cards, toggles, math, code, embeds, attachments and four kinds of diagrams — plus a read-only renderer.

TiptapEditor is a block (registry:block) built on Tiptap 3:

  • Blocks: headings, lists and to-dos, quotes, highlighted code, tables (row / column handles), responsive columns, cards, toggles (details in the reader), resizable icons, KaTeX formulas, images, file attachments, video / Figma / web embeds, and Mermaid, Excalidraw, mind map and draw.io diagrams.
  • Editing: type / for the slash menu, select text for the formatting bubble, drag blocks by their handle, paste Markdown, import / export document files.
  • Liquid Glass surface: the editor is a glass panel like Card (medium material) with the toolbar on it; the slash menu and bubble are menu-material glass, and every menu and dialog opened from the editor inherits its material. glass={false} renders it 100% opaque.
  • Both platforms: on iPhone (< 768px) the toolbar wraps into iOS-size rows, the slash menu becomes a bottom drawer and the bubble docks to the bottom of the screen.
  • Lazy diagrams: Mermaid, Excalidraw, simple-mind-map and highlight.js are dynamic imports, fetched the first time a block of that kind appears. draw.io uses the official diagrams.net embed and needs network access to embed.diagrams.net.
apple-liquid-ui/preview/tiptap-editor-demo
MacBook · 16:10

Installation (Shadcn Registry)

npx shadcn@latest add @apple-liquid/tiptap-editor

Usage

'use client';

import * as React from 'react';
import { TiptapEditor } from '@/components/blocks/tiptap-editor';

export function ArticleForm() {
  const [content, setContent] = React.useState('');
  return <TiptapEditor value={content} onChange={setContent} contentClassName="h-[480px]" />;
}
  • value / onChange use ProseMirror JSON strings; legacy HTML input is accepted. onChangeMarkdown hands you the derived Markdown.
  • The editor is uncontrolled while typing: an external value is applied only when it differs from the current document, so the caret never jumps.
  • Set the editing area's height with contentClassName (e.g. h-[480px] or max-h-[60vh]); it scrolls inside the glass panel while the toolbar stays put.

File uploads

Images and attachments go through a FileStorageAdapter you provide. The document stores only the durable value returned by upload; display URLs (often short-lived signed links) come from resolve at render time.

import type { FileStorageAdapter } from '@/components/blocks/tiptap-editor';

const storage: FileStorageAdapter = {
  async upload(file, { nodeType, signal, onProgress }) {
    const { key, url } = await uploadToYourStorage(`${nodeType}/${file.name}`, file, { signal, onProgress });
    return { value: key, url };
  },
  resolve: (key, { signal }) => getSignedUrl(key, { signal }),
  validate: (file, { nodeType }) =>
    nodeType === 'image' && file.size > 20 * 1024 * 1024 ? 'Images must be under 20 MB' : undefined,
};

<TiptapEditor value={content} onChange={setContent} fileStorageAdapter={storage} />;

Every callback receives nodeType (image, file, excalidraw, drawio or mindMap), so you can use a folder, size limit or permission per node type. When an external link to a file is re-hosted it is passed as file.

With an adapter, the editor also:

  • stores pasted screenshots, dropped files and blob: / data: images automatically: images follow the resource mode (uploaded and swapped for a stored key, or embedded as a data URL — see below), attachments are always uploaded;
  • lists external files that arrive by paste or import (images, attachments, links to files) and offers to save the checked ones to your storage. Browsers can only download files that allow cross-origin reads; provide fetchRemote (usually your own server proxy) to cover the rest, and isOwnUrl for URLs that are already yours (such as a public bucket domain).

The editor never deletes stored files — not even when an image is removed, since undo can bring it back. Clean up unused files in your own save flow.

About the live demo: Because this documentation site is statically exported without a backend, the preview above uses the browser's IndexedDB to simulate server uploads (idb:<nodeType>/… keys, up to 10 MB per file). Files stay only in your local browser so you can test upload progress, storage keys, and inline/upload switching directly; in production, replace it with your own server or object storage (such as Cloudflare R2, S3, or Supabase Storage).

Inline or upload

The whole resource of an image, Excalidraw, draw.io or mind map node can live inside the document or in your storage:

NodeInlineUpload
Imagesrc is a data URLThe original file is uploaded; src is the stored key
Excalidraw / draw.io / mind mapSource data and SVG cache svg stay in the nodeThe whole diagram is uploaded as one JSON file ({ type, data, svg }); the node keeps only the src key
  • resourceMode (default "upload") decides how new nodes are stored. Any node can be switched in its block menu under Storage; the whole resource is converted and the change can be undone.
  • Existing nodes keep their mode: editing an uploaded diagram uploads a new file, editing an inline one stays inline. If an upload fails the node is saved inline instead, so nothing is lost.
  • Without a storage adapter every node is inline. Inline images must be PNG, JPEG, GIF, WebP or AVIF (the reader strips SVG data URLs).
  • The editor and the reader fetch uploaded diagrams through resolve. renderTiptapHtml outputs only the stored key and the diagram loads in the browser, so pass fileStorageAdapter to the reader as well.
  • Images added inside a diagram are always embedded as data URLs in its data. Two runtimes reach the network: the draw.io editor runs in an iframe on embed.diagrams.net (the diagram XML is posted into it), and Excalidraw loads its hand-drawn fonts from esm.sh and embeds the glyphs it uses in the SVG cache.
  • Switching modes or re-uploading never deletes the previous file; clean up in your own save flow.
  • Upload progress, failures and storage switches are reported with the library's toast; mount <Toaster /> once in your app to show them.

Reading view

apple-liquid-ui/preview/tiptap-renderer-demo
MacBook · 16:10

TiptapContentRenderer renders saved content with the same styles and rebuilds the interactive parts: code chrome with copy, Mermaid, pannable diagrams, mind maps, embeds and toggles. It is transparent, so place it on your page or inside a Card.

import { TiptapContentRenderer } from '@/components/blocks/tiptap-editor';

<TiptapContentRenderer content={article.content} fileStorageAdapter={storage} />;

For reader pages, render sanitized HTML on the server and pass it as html so the first paint doesn't wait for the editor schema:

// app/articles/[id]/page.tsx (Server Component)
import { renderTiptapHtml } from '@/components/blocks/tiptap-editor/renderer/server/render-html';
import { TiptapContentRenderer } from '@/components/blocks/tiptap-editor';

export default async function Page() {
  const article = await getArticle();
  return <TiptapContentRenderer html={renderTiptapHtml(article.content)} />;
}

The server entry imports server-only; never import it from client code.

Language

All built-in text (toolbar, menus, dialogs, placeholders) follows <LiquidGlassProvider locale> in 12 languages, and the Excalidraw and draw.io interfaces switch with it. Override individual strings with messages:

<TiptapEditor messages={{ placeholder: 'Write your answer…' }} />

Toolbar placement

showToolbar={false} hides the built-in toolbar so you can render EditorToolbar elsewhere (for example a sticky page header). Get the editor instance from onCreate:

const [editor, setEditor] = React.useState<Editor | null>(null);

<>
  {editor && <EditorToolbar editor={editor} />}
  <TiptapEditor showToolbar={false} onCreate={(instance) => setEditor(instance)} />
</>;

Props API

TiptapEditor

PropTypeDefaultDescription
valuestring—ProseMirror JSON string (legacy HTML accepted)
onChange(doc: string, context) => void—Latest document JSON on every change
onChangeMarkdown(markdown: string) => void—Derived Markdown on every change
onCreate(editor: Editor, context) => void—Called once the editor instance is ready
placeholderstringBuilt-in textEmpty-paragraph hint
editablebooleantruefalse makes it read-only and hides the toolbar
showToolbarbooleantrueRender the built-in toolbar
fileStorageAdapterFileStorageAdapter—Enables uploads and resolves stored keys
resourceMode'upload' | 'inline''upload'How new image and diagram nodes store their resource (with an adapter); switchable per node
localeLiquidGlassLocaleInputGlobal localeUI language of this instance; overrides <LiquidGlassProvider locale>
messagesPartial<TiptapEditorMessages>Built-in textText overrides, deep-merged over the built-in text and the global messages.tiptapEditor
glassbooleantrueLiquid Glass surface (medium, like Card); glass={false} is 100% opaque
className / toolbarClassName / contentClassNamestring—Root, toolbar and scrolling content area

TiptapContentRenderer

PropTypeDefaultDescription
contentstring—Document JSON (or legacy HTML), converted in the browser
htmlstring—Server-rendered HTML from renderTiptapHtml; preferred for reader pages
fileStorageAdapterFileStorageAdapter—Resolves stored images, attachments and uploaded diagrams
localeLiquidGlassLocaleInputGlobal localeUI language of this instance; overrides <LiquidGlassProvider locale>
messagesPartial<TiptapEditorMessages>Built-in textText overrides, deep-merged over the built-in text and the global messages.tiptapEditor
classNamestring—Root element

FileStorageAdapter

MemberTypeDescription
upload(file, { nodeType, signal, onProgress }) => Promise<{ value, url }>Stores a file; value goes into the document
resolve(value, { nodeType, signal }) => Promise<string>Display URL for a stored value
validate(file, { nodeType }) => string | undefinedOptional; return an error message to reject a file
fetchRemote(url, { nodeType, signal }) => Promise<Blob>Optional; downloads external files the browser can't read
isOwnUrl(url: URL, { nodeType }) => booleanOptional; URLs not offered for re-hosting

Document helpers

ExportDescription
docToHtml(json) / htmlToDoc(html)Convert between document JSON and HTML (browser only)
serializeTiptapDocument(editor) / parseTiptapDocument(raw)Versioned document file, diagrams included
downloadTiptapDocument(editor, name) / pickTiptapDocument() / loadTiptapDocument(editor, file)Save to and open from a local file
requestRemoteFileScan(editor)Re-scan for external files after replacing the whole document

On this page