Features
Libraries
A block that shows an external page in a responsive frame, after a URL input while it is empty.
Installation#
bash
pnpm dlx shadcn@latest add @zui/document-editor @zui/editor-embedUsage#
tsx
import type { DocJSON, IEditor } from '@zeroxsolutions/editor-core/document/core/index';
import { embed } from '@/components/editor/document/features/embed';
import { standardKit } from '@/components/editor/document/features/standard';
import { Editor } from '@/components/editor/document/react';tsx
const features = [standardKit(), embed()];
function NotesEditor({ content }: { content: DocJSON }) {
return <Editor features={features} content={content} />;
}embed adds the embed block, which draws its url in a responsive frame once one is set and asks for a URL while it is empty. Its slash item is "Embed" and its command insertEmbed takes a url and an optional title. The embedded page is not trusted: restrict which hosts a URL may name before you store it.
Run the command on the editor that Editor hands to onReady, as Document Editor shows:
tsx
function insert(editor: IEditor) {
editor.run('insertEmbed', { url: 'https://www.openstreetmap.org/export/embed.html', title: 'Map' });
}The Viewer draws the same block, with the same feature in its features, wherever a stored document is only read.