editorcn pro

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

PropTypeDescription
initialPagesNotesPage[]Pages to start with, default a sample workspace
initialPageIdstringPage to open first, default Home
currentUserNotesUserShown in the sidebar and the Home greeting
workspace{ name, logo? }Workspace name and logo in the sidebar
onPageSavefunctionGets a page after its edits settle
onPagesChangefunctionGets every page after a change
onSharefunctionShows a Share button when set, gets the open page
onUploadCover(file) => Promise<string>Uploads a cover image. Without it, files use a local URL
coversstring[]Images offered in the cover gallery
classNamestringOuter container classes

NotesPage

FieldTypeDescription
idstringUnique id
titlestringPage title
parentIdstring | nullParent page, empty for top-level pages
contentJSONContent | stringTiptap JSON or HTML
iconstringAn emoji
coverstringCover image URL
favoritebooleanShows the page under Favorites
smallText, fullWidth, lockedbooleanPage options
trashedAt, createdAt, updatedAtstringISO dates