Report an issue
Class

CKEDITOR.plugins.balloontoolbar.contextManager

class

A class for managers that take care of handling multiple contexts.

The manager also makes sure that only one toolbar is active (per manager) at a time and implement the logic used to determine the best fitting context for a given selection. Default priorities are as follows:

  1. Callback – options.refresh
  2. Widgets matching – options.widgets
  3. CSS matching – options.cssSelector

It is worth noting that priorities could be further customized by explicitly providing CKEDITOR.plugins.balloontoolbar.contextDefinition.priority, so that it is possible to match a widget over a refresh callback.

Filtering

Properties

  • editor : editor

    The editor that the manager was created for.

  • private

    _contexts : context[]

    A list of contexts controlled by this manager.

    Defaults to []

  • private

    _listeners : Object[]

    An array of event listener references created by the manager.An array of objects returned by the CKEDITOR.event.on method.

    Defaults to []

Methods

  • since 4.8.0

    constructor( editor ) → contextManager

    Parameters

    editor : editor

    The editor instance which the toolbar is created for.

    Returns

    contextManager
  • add( context )

    Adds a context to the tracked contexts list.

    Parameters

    context : context
  • check( [ selection ] )

    Checks each registered context against selection to find the best match. By default only one toolbar per manager will be shown.

    Parameters

    [ selection ] : selection | null

    The selection to be used for probing the toolbar. If none provided, a shrunk selection of the current editor will be used.

    Defaults to null

  • create( options ) → context

    Creates a toolbar context based on provided options, registers it in the manager and returns.

    // Shows Bold and Underline button for any selection.
    var context = contextManager.create( {
        buttons: 'Bold,Underline',
        refresh: function() {
            return true;
        }
    } );
    

    Parameters

    options : contextDefinition

    A configuration object that determines the conditions used to display the toolbar.

    Returns

    context

    A context object created for this balloon toolbar configuration.

  • destroy()

    Destroys every context controlled by the manager and clears the context list.

  • hide()

    Hides every visible context controlled by the manager.

  • private

    _attachListeners()

    Adds a set of listeners integrating the manager with the editor, like the CKEDITOR.editor.selectionChange listener.

  • private

    _clear()

    Destroys any context in _contexts and empties the managed contexts list.

  • private

    _refresh()

    Refreshes all contexts from _contexts.