core.use(...) registers UI components/plugins by static type (values from ToolType for tools, PluginType.Adapter for adapters, and PluginType.Plugin for general plugins).
Tools are registered via core.use(ToolConstructor, options) during setup. The tools config field provides tool settings/options that ToolsManager applies during initialize().
| Type | Interface / Source | Purpose |
|---|---|---|
| UI Plugin | EditorjsPlugin |
UI component/behavior registered via core.use(...) |
| Block Tool | BlockTool (from config tools) |
Block rendering and block-specific behavior |
| Inline Tool | InlineTool (from config tools) |
Selection formatting actions |
| Block Tune | BlockTune (from config tools) |
Per-block tune behavior |
Canonical startup order:
- Initialize the adapter (
DOMAdapters/PluginType.Adapter). - Instantiate registered UI plugins.
- Prepare tools and emit
ToolLoadedCoreEventfor each available tool. - Resolve
SelectionManager,BlocksManager, andBlockRenderer.BlockRenderersubscribes to model block events and createsBlockToolAdapterinstances per block when aBlockAddedEventfires. - Initialize model with configured blocks (triggers
BlockAddedEventfor each block). - Connect collaboration manager.
- Plugins receive dependencies via constructor params (
config,api,eventBus). - Plugin instances may implement
destroy(), butCorecurrently does not expose a globaldestroy()lifecycle hook.
Every plugin and tool receives an api object of type EditorAPI in its constructor. It is composed of three namespaces:
Programmatic block management — delegates to BlocksManager.
| Method | Description |
|---|---|
insert(type?, data?, index?, id?, focus?, replace?) |
Insert a block of the given tool type |
insertMany(blocks, index?) |
Insert multiple serialised blocks |
delete(index?) |
Remove a block (defaults to caret block) |
move(toIndex, fromIndex?) |
Move a block to a new position |
render(document) |
Re-initialize the document from serialised data |
clear() |
Remove all blocks |
getBlocksCount() |
Return the total number of blocks |
Inline tool application — delegates to SelectionManager.
| Method | Description |
|---|---|
applyInlineToolForCurrentSelection(toolName, data?) |
Apply or toggle an inline tool on the current caret selection |
Document access and mutations — delegates to DocumentAPI.
| Method | Description |
|---|---|
data |
Returns EditorDocumentSerialized — the current serialised document state |
insertData(params) |
Insert data at the specified index |
removeData(params) |
Remove data at the specified index |
modifyData(params) |
Modify data at the specified index |
undo() |
Undo the last change in the document (dispatches UndoCoreEvent) |
redo() |
Redo the last undone change (dispatches RedoCoreEvent) |
→ diagrams/plugin-lifecycle-flow.mmd
new Core wires services; use() registers UI plugins; initialize() prepares tools, initializes document, and starts collaboration.