Doc page
Loading the page
npx shadcn add https://ui.klarhimmel.com/r/doc-page.jsonCopy for AIDetailsAbout, usage, props and more
The text page of every app: a large title and the body at a reading width, edited in place like Notion. A toolbar on a selection, '/' for blocks, block handles to add and drag, page-link previews and a slim outline. Markdown in and out; DocPanel shows it in a side panel.
Preview
Loading the page
Import
Import
- Files
- doc-page.tsx, doc-page.markdown.ts, in components/klarhimmel/ui/. With it: dialog, doc-host, input, sheet, theme and 2 more. npm: lucide-react, prosekit.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
DocPage.title | string | required | The page's name, shown large. |
DocPage.value | string | required | Markdown (storage). A new value from outside replaces the text. |
DocPage.onChange | (markdown: string) => void | - | Edits come back as Markdown. Absent: the page is read-only (no handles, '/' menu or selection toolbar). |
DocPage.meta | string | - | One quiet line under the title: path, version, saved. |
DocPage.lead | ReactNode | - | Above the body, under the title (a description's goal and deliverables). |
DocPage.onComment | (quote: string) => void | - | Shows Comment on a selection: the caller files the quoted words in its thread. |
DocPage.ask | { actions: string[]; onAsk(action: string, quote: string): void } | - | Shows Ask on a selection with these actions; the caller runs the assistant on the quoted words. |
DocPage.bare | boolean | - | The caller draws the title (a task card): the page is the body only. |
DocPage.labels | Partial<DocPageLabels> | - | Every name and menu line. Pass them translated. |
DocPage.className | string | - | Extra classes, merged after the component's own. |
DocPanel.open | boolean | required | |
DocPanel.onOpenChange | (open: boolean) => void | required | |
DocPanel.fullHref | string | - | Where the page opens full size: shows the full-page button. |
DocPanel.link | string | - | What Copy link copies. Default: the address in the window. |
DocPanel.star | { on: boolean; onChange(on: boolean): void } | - | Shows Star; the caller keeps whether it is starred. |
DocPanel.menu | { label: string; onSelect(): void }[] | [] | Extra lines at the top of the … menu (moving a file between folders). |
DocPanel.versions | { version: number; note: string; when: string }[] | - | Shows Version history in the … menu. |
DocPanel.source | { value: string; onChange: (markdown: string) => void } | - | The whole stored file for Markdown source, when the page edits only part of it (under frontmatter). |
DocPanel.title | string | required | The page's name, shown large. |
DocPanel.value | string | required | Markdown (storage). A new value from outside replaces the text. |
DocPanel.onChange | (markdown: string) => void | - | Edits come back as Markdown. Absent: the page is read-only (no handles, '/' menu or selection toolbar). |
DocPanel.meta | string | - | One quiet line under the title: path, version, saved. |
DocPanel.lead | ReactNode | - | Above the body, under the title (a description's goal and deliverables). |
DocPanel.onComment | (quote: string) => void | - | Shows Comment on a selection: the caller files the quoted words in its thread. |
DocPanel.ask | { actions: string[]; onAsk(action: string, quote: string): void } | - | Shows Ask on a selection with these actions; the caller runs the assistant on the quoted words. |
DocPanel.bare | boolean | - | The caller draws the title (a task card): the page is the body only. |
DocPanel.labels | Partial<DocPageLabels> | - | Every name and menu line. Pass them translated. |
DocPanel.className | string | - | Extra classes, merged after the component's own. |