Pass tools to list the tools you want. A tool that's off is gone everywhere: the / and + menus, Markdown shortcuts, keyboard shortcuts, the formatting toolbar, and the mobile toolbar. Pasted content it would have produced becomes plain paragraphs, and existing content falls back the same way when it loads. Paragraphs are always on. Without tools, every built-in tool and every plugin is on.
toolbar picks the formatting toolbar's items and their order. Items for tools that are off are skipped. The default order is blockType, tableMerge, columns, file, imageLink, inlineImage, bold, italic, underline, strike, code, alignLeft, alignCenter, alignRight, linkPreview, then any plugin items.
import { BlockEditor } from "genesis-editor";
export default function ToolsMinimalToolbarExample() {
return (
<BlockEditor
tools={["bulletList", "bold", "italic", "link"]}
toolbar={["bold", "italic", "link"]}
initialContent={[
{ type: "paragraph", content: "Select some text: the toolbar has Bold, Italic, and Link." },
{ type: "bulletListItem", content: "Underline, colors, and headings are off." },
]}
/>
);
}
Set placement: "fixed" to pin the toolbar above the editor instead of showing it over the selection, or pass toolbar={false} to turn it off.
import { BlockEditor } from "genesis-editor";
export default function ToolsFixedToolbarExample() {
return (
<BlockEditor
toolbar={{
placement: "fixed",
items: ["blockType", "bold", "italic", "underline", "code", "link"],
}}
initialContent={[{ type: "paragraph", content: "The toolbar stays above the editor." }]}
/>
);
}
A plugin bundles blocks, menu items, toolbar items, and shortcuts under one name. Declare it with definePlugin and pass it in plugins. Its blocks join the same menus as the built-ins, and its name works in tools like any built-in tool. The built-in tools are plugins too, so a plugin named quote replaces the built-in quote.
import { definePlugin } from "genesis-editor";export const myPlugin = definePlugin({ name: "my-plugin", // also its tool name blocks: { … }, // block specs, e.g. createReactBlockSpec(...)() slashItems: [ … ], // entries for the / and + menus toolbarItems: { … }, // formatting toolbar components, by toolbar name markdownShortcuts: [ … ], // { find: /^!>\s$/, block: { type: "callout" } } keyboardShortcuts: { … }, // { "Mod-Shift-l": (editor) => true }});
This callout plugin adds a block with a tone you can click to change, a slash menu item, a !> Markdown shortcut, and a toolbar button. It ships with these docs, not with the package.
import { BlockEditor } from "genesis-editor";
import { calloutPlugin } from "./callout-plugin";
export default function PluginCalloutExample() {
return (
<BlockEditor
plugins={[calloutPlugin]}
initialContent={[
{ type: "callout", content: "Plugins add blocks to every menu. Click the icon to change the tone." },
{ type: "paragraph", content: 'Type /callout, or "!> " at the start of a line.' },
]}
/>
);
}
// With a tools list, plugins are active only when listed.<BlockEditor tools={["heading", "callout"]} plugins={[calloutPlugin]} />
tools and the plugin names are read when the editor is created. When they change, the editor is rebuilt with the current document, which keeps its content but loses undo history. Every field of a plugin is listed in the API reference.