CKEditor 4 reached its End of Life (EOL) in June 2023. From then on, it will receive no more updates, new features, bug fixes, and security patches. Visit CKEditor 5 Docs for the actively supported CKEditor or check Extended Support Model.
Report an issue
Class

CKEDITOR.stylesSet

class singleton since 3.2.0

Manages styles registration and loading. See also CKEDITOR.config.stylesSet.

Note This object is an instance of CKEDITOR.resourceManager.

// The set of styles for the <b>Styles</b> drop-down list.
CKEDITOR.stylesSet.add( 'default', [
    // Block Styles
    { name: 'Blue Title',       element: 'h3',      styles: { 'color': 'Blue' } },
    { name: 'Red Title',        element: 'h3',      styles: { 'color': 'Red' } },

    // Inline Styles
    { name: 'Marker: Yellow',   element: 'span',    styles: { 'background-color': 'Yellow' } },
    { name: 'Marker: Green',    element: 'span',    styles: { 'background-color': 'Lime' } },

    // Object Styles
    {
        name: 'Image on Left',
        element: 'img',
        attributes: {
            style: 'padding: 5px; margin-right: 5px',
            border: '2',
            align: 'left'
        }
    }
] );

Filtering

Properties

  • inherited

    basePath : String

    The base directory containing all resources.

  • inherited

    externals : Object

    Contains references to all resources that have already been registered with addExternal.

    Defaults to {}

  • inherited

    fileName : String

    The name used for resource files.

  • inherited

    loaded : Object

    Contains references to all resources that have already been loaded with load.

    Defaults to {}

  • inherited

    registered : Object

    Contains references to all resources that have already been registered with add.

    Defaults to {}

  • private inherited

    _ : Object

    Defaults to {waitingList: {}}

Methods

  • constructor( basePath, fileName ) → resourceManager

    Creates a resourceManager class instance.

    Parameters

    basePath : String

    The path for the resources folder.

    fileName : String

    The name used for resource files.

    Returns

    resourceManager
  • inherited

    add( name, [ definition ] )

    Registers a resource.

    CKEDITOR.plugins.add( 'sample', { ... plugin definition ... } );
    

    Parameters

    name : String

    The resource name.

    [ definition ] : Object

    The resource definition. CKEDITOR.pluginDefinition

  • inherited

    addExternal( names, path, [ fileName ] )

    Registers one or more resources to be loaded from an external path instead of the core base path.

    // Loads a plugin from '/myplugins/sample/plugin.js'.
    CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/' );
    
    // Loads a plugin from '/myplugins/sample/my_plugin.js'.
    CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/', 'my_plugin.js' );
    
    // Loads a plugin from '/myplugins/sample/my_plugin.js'.
    CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/my_plugin.js', '' );
    
    // Loads a plugin from '/myplugins/sample/my_plugin.js'.
    CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/my_plugin.js' );
    

    Parameters

    names : String

    Comma-separated resource names.

    path : String

    The path of the folder containing the resource.

    [ fileName ] : String

    The resource file name. If not provided and the path argument ends with a slash (/), the default plugin.js filename is used. Otherwise, if not provided and the path argument does not end with a slash (/) or if an empty string is provided, the function assumes that the path argument contains the full path.

  • inherited

    get( name ) → Object

    Gets the definition of a specific resource.

    var definition = CKEDITOR.plugins.get( 'sample' );
    

    Parameters

    name : String

    The resource name.

    Returns

    Object

    The registered object.

  • inherited

    getFilePath( name ) → String

    Get the file path for a specific loaded resource.

    alert( CKEDITOR.plugins.getFilePath( 'sample' ) ); // '<editor path>/plugins/sample/plugin.js'
    

    Parameters

    name : String

    The resource name.

    Returns

    String
  • inherited

    getPath( name ) → String

    Get the folder path for a specific loaded resource.

    alert( CKEDITOR.plugins.getPath( 'sample' ) ); // '<editor path>/plugins/sample/'
    

    Parameters

    name : String

    The resource name.

    Returns

    String
  • inherited

    load( name, callback, [ scope ] )

    Loads one or more resources.

    CKEDITOR.plugins.load( 'myplugin', function( plugins ) {
        alert( plugins[ 'myplugin' ] ); // object
    } );
    

    Parameters

    name : String | Array

    The name of the resource to load. It may be a string with a single resource name, or an array with several names.

    callback : Function

    A function to be called when all resources are loaded. The callback will receive an array containing all loaded names.

    [ scope ] : Object

    The scope object to be used for the callback call.