CKEDITOR.ui
Contains UI features related to an editor instance.
Filtering
Properties
Static properties
Methods
constructor( editor ) → uiCKEDITOR.ui#constructoradd( name, type, definition )CKEDITOR.ui#addAdds a UI item to the items collection. These items can be later used in the interface.
// Add a new button named 'MyBold'. editorInstance.ui.add( 'MyBold', CKEDITOR.UI_BUTTON, { label: 'My Bold', command: 'bold' } );Parameters
name : StringThe UI item name.
type : ObjectThe item type.
definition : ObjectThe item definition. The properties of this object depend on the item type.
addButton( name, definition )CKEDITOR.ui#addButtonAdds a button definition to the UI elements list.
editorInstance.ui.addButton( 'MyBold', { label: 'My Bold', command: 'bold', toolbar: 'basicstyles,1' } );Parameters
name : StringThe button name.
definition : ObjectThe button definition.
addHandler( type, handler )CKEDITOR.ui#addHandlerAdds a handler for a UI item type. The handler is responsible for transforming UI item definitions into UI objects.
Parameters
type : ObjectThe item type.
handler : ObjectThe handler definition.
addRichCombo( name, definition )CKEDITOR.ui#addRichComboaddToolbarGroup( name, previous, [ subgroupOf ] )CKEDITOR.ui#addToolbarGroupAdds a toolbar group. See CKEDITOR.config.toolbarGroups for more details.
Note: This method will not modify toolbar groups set explicitly by CKEDITOR.config.toolbarGroups. It will only extend the default setting.
Parameters
name : StringToolbar group name.
previous : Number | StringThe name of the toolbar group after which this one should be added or
0if this group should be the first one.[ subgroupOf ] : StringThe name of the parent group.
capture()CKEDITOR.ui#captureRegister event handler under the capturing stage on supported target.
create( name ) → ObjectCKEDITOR.ui#createdefine( name, meta )CKEDITOR.ui#definePredefine some intrinsic properties on a specific event name.
Parameters
name : StringThe event name
meta : Object
fire( eventName, [ data ], [ editor ] ) → Boolean | ObjectCKEDITOR.ui#fireFires an specific event in the object. All registered listeners are called at this point.
someObject.on( 'someEvent', function() { ... } ); someObject.on( 'someEvent', function() { ... } ); someObject.fire( 'someEvent' ); // Both listeners are called. someObject.on( 'someEvent', function( event ) { alert( event.data ); // 'Example' } ); someObject.fire( 'someEvent', 'Example' );Parameters
eventName : StringThe event name to fire.
[ data ] : ObjectData to be sent as the CKEDITOR.eventInfo.data when calling the listeners.
[ editor ] : editorThe editor instance to send as the CKEDITOR.eventInfo.editor when calling the listener.
Returns
Boolean | ObjectA boolean indicating that the event is to be canceled, or data returned by one of the listeners.
fireOnce( eventName, [ data ], [ editor ] ) → Boolean | ObjectCKEDITOR.ui#fireOnceFires an specific event in the object, releasing all listeners registered to that event. The same listeners are not called again on successive calls of it or of fire.
someObject.on( 'someEvent', function() { ... } ); someObject.fire( 'someEvent' ); // Above listener called. someObject.fireOnce( 'someEvent' ); // Above listener called. someObject.fire( 'someEvent' ); // No listeners called.Parameters
eventName : StringThe event name to fire.
[ data ] : ObjectData to be sent as the CKEDITOR.eventInfo.data when calling the listeners.
[ editor ] : editorThe editor instance to send as the CKEDITOR.eventInfo.editor when calling the listener.
Returns
Boolean | ObjectA booloan indicating that the event is to be canceled, or data returned by one of the listeners.
get( name ) → ObjectCKEDITOR.ui#getRetrieves the created UI objects by name.
Parameters
name : StringThe name of the UI definition.
Returns
ObjectThe UI object.
hasListeners( eventName ) → BooleanCKEDITOR.ui#hasListenersChecks if there is any listener registered to a given event.
var myListener = function() { ... }; someObject.on( 'someEvent', myListener ); alert( someObject.hasListeners( 'someEvent' ) ); // true alert( someObject.hasListeners( 'noEvent' ) ); // falseParameters
eventName : StringThe event name.
Returns
Boolean
on( eventName, listenerFunction, [ scopeObj ], [ listenerData ], [ priority ] ) → ObjectCKEDITOR.ui#onRegisters a listener to a specific event in the current object.
someObject.on( 'someEvent', function() { alert( this == someObject ); // true } ); someObject.on( 'someEvent', function() { alert( this == anotherObject ); // true }, anotherObject ); someObject.on( 'someEvent', function( event ) { alert( event.listenerData ); // 'Example' }, null, 'Example' ); someObject.on( 'someEvent', function() { ... } ); // 2nd called someObject.on( 'someEvent', function() { ... }, null, null, 100 ); // 3rd called someObject.on( 'someEvent', function() { ... }, null, null, 1 ); // 1st calledNote: CKEditor's event system has a limitation that one function cannot be used as a listener for the same event more than once. Hence, to reuse it with multiple listeners, it should be wrapped into additional wrapper function:
function listener( evt ) { ... }; someObject.on( 'someEvent', function() { listener(); } ); someObject.on( 'someEvent', function( evt ) { listener( evt ); } );Parameters
eventName : StringThe event name to which listen.
listenerFunction : FunctionThe function listening to the event. A single CKEDITOR.eventInfo object instanced is passed to this function containing all the event data.
[ scopeObj ] : ObjectThe object used to scope the listener call (the
thisobject). If omitted, the current object is used.[ listenerData ] : ObjectData to be sent as the CKEDITOR.eventInfo.listenerData when calling the listener.
[ priority ] : NumberThe listener priority. Lower priority listeners are called first. Listeners with the same priority value are called in registration order.
Defaults to
10
Returns
ObjectAn object containing the
removeListenerfunction, which can be used to remove the listener at any time.
once()CKEDITOR.ui#onceSimiliar with on but the listener will be called only once upon the next event firing.
removeAllListeners()CKEDITOR.ui#removeAllListenersRemove all existing listeners on this object, for cleanup purpose.
removeListener( eventName, listenerFunction )CKEDITOR.ui#removeListenerUnregisters a listener function from being called at the specified event. No errors are thrown if the listener has not been registered previously.
var myListener = function() { ... }; someObject.on( 'someEvent', myListener ); someObject.fire( 'someEvent' ); // myListener called. someObject.removeListener( 'someEvent', myListener ); someObject.fire( 'someEvent' ); // myListener not called.Parameters
eventName : StringThe event name.
listenerFunction : FunctionThe listener function to unregister.
space( name ) → elementCKEDITOR.ui#spaceReturns the unique DOM element that represents one editor's UI part, also known as "space". There are 3 main editor spaces available:
top,contentsandbottomand their availability depends on editor type.// Hide the bottom space in the UI. var bottom = editor.ui.space( 'bottom' ); bottom.setStyle( 'display', 'none' );Parameters
name : StringThe name of the space.
Returns
elementThe element that represents the space.
spaceId( name ) → StringCKEDITOR.ui#spaceIdReturns the HTML ID for a specific UI space name.
Parameters
name : StringThe name of the space.
Returns
StringThe ID of an element representing this space in the DOM.
Static methods
-
Implements the CKEDITOR.event features in an object.
var myObject = { message: 'Example' }; CKEDITOR.event.implementOn( myObject ); myObject.on( 'testEvent', function() { alert( this.message ); } ); myObject.fire( 'testEvent' ); // 'Example'Parameters
targetObject : ObjectThe object into which implement the features.
Events
ready( evt )CKEDITOR.ui#ready