WidgetToolbarRepository (widget)
@ckeditor/ckeditor5-widget/src/widgettoolbarrepository
Widget toolbar repository plugin. A central point for registering widget toolbars. This plugin handles the whole toolbar rendering process and exposes a concise API.
To add a toolbar for your widget use the WidgetToolbarRepository#register()
method.
The following example comes from the ImageToolbar
plugin:
class ImageToolbar extends Plugin {
static get requires() {
return [ WidgetToolbarRepository ];
}
afterInit() {
const editor = this.editor;
const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository );
widgetToolbarRepository.register( 'image', {
items: editor.config.get( 'image.toolbar' ),
getRelatedElement: getClosestSelectedImageWidget
} );
}
}
Filtering
Properties
-
_toolbarDefinitions : Map.<String, WidgetRepositoryToolbarDefinition>
module:widget/widgettoolbarrepository~WidgetToolbarRepository#_toolbarDefinitions
protected
A map of toolbar definitions.
-
_balloon
module:widget/widgettoolbarrepository~WidgetToolbarRepository#_balloon
private
Methods
-
register( toolbarId, options = { [options.ariaLabel], options.items, options.getRelatedElement, [options.balloonClassName] } )
module:widget/widgettoolbarrepository~WidgetToolbarRepository#register
Registers toolbar in the WidgetToolbarRepository. It renders it in the
ContextualBalloon
based on the value of the invokedgetRelatedElement
function. Toolbar items are gathered fromitems
array. The balloon's CSS class is by defaultck-toolbar-container
and may be override with theballoonClassName
option.Note: This method should be called in the
Plugin#afterInit()
callback (or later) to make sure that the given toolbar items were already registered by other plugins.Parameters
toolbarId : String
An id for the toolbar. Used to
options : Object
-
Properties
[ options.ariaLabel ] : String
Label used by assistive technologies to describe this toolbar element.
options.items : Array.<String>
Array of toolbar items.
options.getRelatedElement : function
Callback which returns an element the toolbar should be attached to.
[ options.balloonClassName ] : String
CSS class for the widget balloon.
Defaults to
'ck-toolbar-container'
-
_hideToolbar( toolbarDefinition )
module:widget/widgettoolbarrepository~WidgetToolbarRepository#_hideToolbar
private
Hides the given toolbar.
Parameters
toolbarDefinition : WidgetRepositoryToolbarDefinition
-
_isToolbarInBalloon( toolbar ) → Boolean
module:widget/widgettoolbarrepository~WidgetToolbarRepository#_isToolbarInBalloon
private
Parameters
toolbar : Object
Returns
Boolean
-
_isToolbarVisible( toolbar ) → Boolean
module:widget/widgettoolbarrepository~WidgetToolbarRepository#_isToolbarVisible
private
Parameters
toolbar : Object
Returns
Boolean
-
_showToolbar( toolbarDefinition, relatedElement )
module:widget/widgettoolbarrepository~WidgetToolbarRepository#_showToolbar
private
Shows up the toolbar if the toolbar is not visible. Otherwise, repositions the toolbar's balloon when toolbar's view is the most top view in balloon stack.
It might happen here that the toolbar's view is under another view. Then do nothing as the other toolbar view should be still visible after the
event-update
.Parameters
toolbarDefinition : WidgetRepositoryToolbarDefinition
relatedElement : Element
-
_updateToolbarsVisibility()
module:widget/widgettoolbarrepository~WidgetToolbarRepository#_updateToolbarsVisibility
private
Iterates over stored toolbars and makes them visible or hidden.
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.