Skip to content

Toolbar

The Toolbar interface provides properties and methods for rendering and manipulating the toolbar.

Example:

js
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.

Example:

js
const root = toolbar.root;

container Read only

The element where toolbar items are appended.

Example:

js
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:

js
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:

js
toolbar.render(editor);

unmount()

Destroys the toolbar instance, removing it from the DOM.

  • Parameters:

    None.

  • Return value:

    None.

Example:

js
toolbar.unmount();

Released under the MIT License.