Features
Libraries
Installation#
bash
pnpm dlx shadcn@latest add @zui/document-editor @zui/editor-toggleUsage#
tsx
import type { DocJSON, IEditor } from '@zeroxsolutions/editor-core/document/core/index';
import { toggle } from '@/components/editor/document/features/toggle';
import { standardKit } from '@/components/editor/document/features/standard';
import { Editor } from '@/components/editor/document/react';tsx
const features = [standardKit(), toggle()];
function NotesEditor({ content }: { content: DocJSON }) {
return <Editor features={features} content={content} />;
}toggle adds the toggle block, which folds the blocks inside it behind a marker; its open attribute says whether it is unfolded. Its slash item is "Toggle" and its command insertToggle inserts an open one.
Run the command on the editor that Editor hands to onReady, as Document Editor shows:
tsx
function insert(editor: IEditor) {
editor.run('insertToggle');
}The Viewer draws the same block, with the same feature in its features, wherever a stored document is only read.