Toolbar
The Toolbar
interface provides properties and methods for rendering and manipulating the toolbar.
Example:
import { Toolbar } from 'lakelib';
const toolbarItems = [
'undo',
'redo',
'|',
'bold',
'moreStyle',
];
const toolbar = new Toolbar({
root: '.my-toolbar',
items: toolbarItems,
});
Constructor
Creates a new Toolbar
instance.
Parameters:
config
A key-value object containing configuration options. See the Toolbar config page for details.
Instance properties
root Read only
The element to which the toolbar is appended.
- Type: Nodes
Example:
const root = toolbar.root;
container Read only
The element where toolbar items are appended.
- Type: Nodes
Example:
const container = toolbar.container;
Instance methods
updateState()
Updates the state of each toolbar item, such as whether it is selected or disabled.
Parameters:
state
A SelectionState object that specifies the state of the current selection.
Return value:
None.
Example:
const activeItems = editor.selection.getActiveItems();
toolbar.updateState({
activeItems,
});
render()
Renders the toolbar for the specified editor.
Parameters:
editor
An Editor object.
Return value:
None.
Example:
toolbar.render(editor);
unmount()
Destroys the toolbar instance, removing it from the DOM.
Parameters:
None.
Return value:
None.
Example:
toolbar.unmount();