Notes Workspace
A Notion-style notes app template for React with nested pages, slash commands, drag handles, icons and covers, search, trash and autosave. Built on Tiptap.
A Notion-style notes workspace for React, built on shadcn/ui and Tiptap. The sidebar holds a nested page tree you can drag to reorder or nest, a Favorites section, Search, Home and a Trash you can restore from. Each page has an emoji icon, a cover (pick from a gallery, upload, or paste a link) and a block editor: type / to add text, headings, lists, to-dos, quotes, callouts, dividers, images, tables, code, or a sub-page, drag any block by its handle, and select text to format it. The top bar shows breadcrumbs, save status, Share, a favorite toggle and page options (small text, full width, lock, duplicate, move to trash, word count). Home shows recently visited pages as cards.
Installation
$ pnpm dlx shadcn@latest add @editorcn-pro/notes-workspace
The CLI also installs the Block Editor, Callout, Code Block, Image Placeholder and Table extensions.
Usage
import { NotesWorkspace } from "@/components/templates/notes-workspace";
export const Workspace = ({ pages, user }) => (
<NotesWorkspace
currentUser={user}
initialPages={pages}
workspace={{ name: "Acme" }}
onPageSave={(page) => savePage(page)}
onPagesChange={(pages) => saveTree(pages)}
onUploadCover={(file) => uploadImage(file)}
/>
);Pages are a flat list. A page's parentId points at its parent, and the order of the list is the order in the sidebar.
onPageSave runs 800ms after the last edit to a page's title, icon, cover or content. Return a promise to keep the status on "Saving…" until it resolves; a rejected promise shows "Couldn't save". onPagesChange gets the whole list after any change, including moves, favorites, trash and restore, so you can store the tree in one place.
Trashing a page sets trashedAt on it and hides everything inside it. Restoring clears it, and moves the page to the top level when its parent is gone. Sub-pages added with /page are stored in the content as <div data-type="page-link" data-page-id="…">.
Press ⌘K (or Ctrl K) to search titles and content, and ⌘\ to toggle the sidebar.
Props
| Prop | Type | Description |
|---|---|---|
initialPages | NotesPage[] | Pages to start with, default a sample workspace |
initialPageId | string | Page to open first, default Home |
currentUser | NotesUser | Shown in the sidebar and the Home greeting |
workspace | { name, logo? } | Workspace name and logo in the sidebar |
onPageSave | function | Gets a page after its edits settle |
onPagesChange | function | Gets every page after a change |
onShare | function | Shows a Share button when set, gets the open page |
onUploadCover | (file) => Promise<string> | Uploads a cover image. Without it, files use a local URL |
covers | string[] | Images offered in the cover gallery |
className | string | Outer container classes |
NotesPage
| Field | Type | Description |
|---|---|---|
id | string | Unique id |
title | string | Page title |
parentId | string | null | Parent page, empty for top-level pages |
content | JSONContent | string | Tiptap JSON or HTML |
icon | string | An emoji |
cover | string | Cover image URL |
favorite | boolean | Shows the page under Favorites |
smallText, fullWidth, locked | boolean | Page options |
trashedAt, createdAt, updatedAt | string | ISO dates |