Features
Libraries
Installation#
bash
pnpm dlx shadcn@latest add @zui/document-editor @zui/editor-imageUsage#
tsx
import type { DocJSON, IEditor } from '@zeroxsolutions/editor-core/document/core/index';
import { image } from '@/components/editor/document/features/image';
import { standardKit } from '@/components/editor/document/features/standard';
import { Editor } from '@/components/editor/document/react';tsx
const features = [standardKit(), image()];
function NotesEditor({ content }: { content: DocJSON }) {
return <Editor features={features} content={content} />;
}image adds the image block, with the attributes src, alt, title and width. Selecting it opens an Edit popover for the alt text and the width. Its slash item is "Image" and its command insertImage takes a src and an optional alt and title.
Run the command on the editor that Editor hands to onReady, as Document Editor shows:
tsx
function insert(editor: IEditor) {
editor.run('insertImage', { src: '/lantern.jpg', alt: 'A red paper lantern' });
}The Viewer draws the same block, with the same feature in its features, wherever a stored document is only read.