AI agents
Add a block or feature
Agent playbook for adding an own block or feature to @skaile/forge-editor: an ordered checklist where each step links to the tutorial chapter that shows it.
Two ways to add a block: Path A passes extensions and a commands transformer to SimpleEditor (no feature object); Path B ships an EditorFeature that composes with any preset. The tutorial builds the same „Hinweis" callout both ways; follow the chapters in order and use this list as the checklist.
- Node.
Node.createin a Vue-freenode.ts;group,content, attributes withparseHTML/renderHTML, commands and a free shortcut. Tutorial: own block, path A - Block IDs.
editorBlock: trueif AI operations, flash/reveal, paste de-duplication or the server ID backfill should reach it. Tutorial: own block, path A - Abilities.
abilitieson the node for what is allowed inside; for a custom ability id, grant it through theabilitiesprop (root). Tutorial: own feature, path B - Markdown.
renderMarkdown,markdownTokenName,markdownTokenizer,parseMarkdownwith syntax no other stage claims; test the round trip (getMarkdown()→parseBlocks), including multi-block bodies. Tutorial: own block, path A - View and CSS. Node view in a separate
index.ts(Node.extend), stylesheet imported aftercore.css. Tutorial: own block, path A, CSS order: CSS and UI-provider requirements - Path A.
extensions(constant) and thecommandstransformer prop (a command withslash: {}), nothing else needed. Tutorial: own block, path A - Path B. An
EditorFeature:extensions, thencommands(oneCommandDefper command withtoolbarand/orslashplacement,creates,ability) andtoolbarGroupsif you need a new group,blockActionswith yourability,conversionswith acustomtarget;requiresfor features you depend on. Tutorial: own feature, path B, every member: Feature contract - Compose.
defineEditor({ features: [...advancedEditor().features, yourFeature()] })in setup (advancedEditorfrom/vue/advancedor/react/advanced); mount withEditorSurfaceand passabilitiesfor custom ability ids; addblockUiFeature()to a smaller list when you use hover actions. Tutorial: compose features, Tutorial: own feature, path B - Server. When documents with your block are collaborative, pass
YourNodein the server'sschemaoption (provideEditorServer({ ports, schema: () => [...advancedSchemaExtensions(), YourNode] }); the collab server uses it instead ofadvancedSchemaExtensions()), or buildgetSchema([...advancedSchemaExtensions(), YourNode])in your own Hocuspocus server. Tutorial: backend and collaboration, Vue-free schema for servers - AI. Decide what the model should see (
renderMarkdown) and write; describe the block inaiContext.blocks(id,label,description,syntax,example, matching your Markdown);aiContextis additive, a block id may be described only once; add acustomconversion provider if the block should be aconverttarget. Tutorial: AI, AI guide - Bundle proof. If you ship the block in a package, add a fixture and a
FIXTURESentry forbun run check:editor-entries(Dependency rules);bun run check:editor-compositioncoversdefineEditorvalidation. Verify
Then check the invariants.
Integrate the editor
Agent playbook for adding @skaile/forge-editor to an app: choose the surface, then the entry to import, then follow the matching setup page.
Pitfalls and invariants
Rules that must stay true when integrating or changing @skaile/forge-editor: CSS order, mandatory context, SSR, mount-time props, bundle isolation, entries.