CKEditor 4 Documentation

CKEDITOR.tools

Files

Utility functions.

Defined By

Properties

A set of array helpers.

A set of array helpers.

A set of functions for operations on styles.

A set of functions for operations on styles.

CKEDITOR.tools
view source
: Stringreadonly
The data URI of a transparent image. ...

The data URI of a transparent image. May be used e.g. in HTML as an image source or in CSS in url().

Defaults to: 'data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw=='

Available since: 4.4

Defined By

Methods

CKEDITOR.tools
view source
( fn, [scope] ) : Number
Creates a function reference that can be called later using callFunction. ...

Creates a function reference that can be called later using callFunction. This approach is especially useful to make DOM attribute function calls to JavaScript-defined functions.

var ref = CKEDITOR.tools.addFunction( function() {
    alert( 'Hello!');
} );
CKEDITOR.tools.callFunction( ref ); // 'Hello!'

Parameters

  • fn : Function

    The function to be executed on call.

  • scope : Object (optional)

    The object to have the context on fn execution.

Returns

  • Number

    A unique reference to be used in conjuction with callFunction.

CKEDITOR.tools
view source
( arrayA, arrayB ) : Boolean
Compares the elements of two arrays. ...

Compares the elements of two arrays.

var a = [ 1, 'a', 3 ];
var b = [ 1, 3, 'a' ];
var c = [ 1, 'a', 3 ];
var d = [ 1, 'a', 3, 4 ];

alert( CKEDITOR.tools.arrayCompare( a, b ) );  // false
alert( CKEDITOR.tools.arrayCompare( a, c ) );  // true
alert( CKEDITOR.tools.arrayCompare( a, d ) );  // false

Parameters

  • arrayA : Array

    An array to be compared.

  • arrayB : Array

    The other array to be compared.

Returns

  • Boolean

    true if the arrays have the same length and their elements match.

CKEDITOR.tools
view source
( func, obj ) : Function
Creates a function that will always execute in the context of a specified object. ...

Creates a function that will always execute in the context of a specified object.

var obj = { text: 'My Object' };

function alertText() {
    alert( this.text );
}

var newFunc = CKEDITOR.tools.bind( alertText, obj );
newFunc(); // Alerts 'My Object'.

Parameters

  • func : Function

    The function to be executed.

  • obj : Object

    The object to which the execution context will be bound.

Returns

  • Function

    The function that can be used to execute the func function in the context of obj.

CKEDITOR.tools
view source
( css ) : String
Builds a HTML snippet from a set of <style>/<link>. ...

Builds a HTML snippet from a set of <style>/<link>.

Parameters

  • css : String/Array

    Each of which are URLs (absolute) of a CSS file or a trunk of style text.

Returns

  • String
CKEDITOR.tools
view source
( table, startRow, startCell, endRow, endCell )
Creates a two-dimension array that reflects the actual layout of table cells, with cell spans, with mappings to the o...

Creates a two-dimension array that reflects the actual layout of table cells, with cell spans, with mappings to the original td elements.

It could also create a map for the specified fragment of the table.

Parameters

  • table : CKEDITOR.dom.element
  • startRow : Number

    Row index from which the map should be created.

  • startCell : Number

    Cell index from which the map should be created.

  • endRow : Number

    Row index to which the map should be created.

  • endCell : Number

    Cell index to which the map should be created.

CKEDITOR.tools
view source
( ref, params ) : Mixed
Executes a function based on the reference created with addFunction. ...

Executes a function based on the reference created with addFunction.

var ref = CKEDITOR.tools.addFunction( function() {
    alert( 'Hello!');
} );
CKEDITOR.tools.callFunction( ref ); // 'Hello!'

Parameters

  • ref : Number

    The function reference created with addFunction.

  • params : Mixed

    Any number of parameters to be passed to the executed function.

Returns

  • Mixed

    The return value of the function.

CKEDITOR.tools
view source
( str, [keepCase] ) : String
Turns the first letter of a string to upper-case. ...

Turns the first letter of a string to upper-case.

Parameters

  • str : String
  • keepCase : Boolean (optional)

    Keep the case of 2nd to last letter.

Returns

  • String
CKEDITOR.tools
view source
( arr, regexp ) : Boolean
Checks if any of the arr items match the provided regular expression. ...

Checks if any of the arr items match the provided regular expression.

Available since: 4.4

Parameters

  • arr : Array

    The array whose items will be checked.

  • regexp : RegExp

    The regular expression.

Returns

  • Boolean

    Returns true for the first occurrence of the search pattern.

CKEDITOR.tools
view source
( obj, regexp ) : Boolean
Checks if any of the obj properties match the provided regular expression. ...

Checks if any of the obj properties match the provided regular expression.

Available since: 4.4

Parameters

  • obj : Object

    The object whose properties will be checked.

  • regexp : RegExp

    The regular expression.

Returns

  • Boolean

    Returns true for the first occurrence of the search pattern.

CKEDITOR.tools
view source
( object ) : Object
Creates a deep copy of an object. ...

Creates a deep copy of an object.

Note: Recursive references are not supported.

var obj = {
    name: 'John',
    cars: {
        Mercedes: { color: 'blue' },
        Porsche: { color: 'red' }
    }
};
var clone = CKEDITOR.tools.clone( obj );
clone.name = 'Paul';
clone.cars.Porsche.color = 'silver';

alert( obj.name );                  // 'John'
alert( clone.name );                // 'Paul'
alert( obj.cars.Porsche.color );    // 'red'
alert( clone.cars.Porsche.color );  // 'silver'

Parameters

  • object : Object

    The object to be cloned.

Returns

  • Object

    The object clone.

CKEDITOR.tools
view source
( arr, [fillWith] )
Converts an array to an object by rewriting array items to object properties. ...

Converts an array to an object by rewriting array items to object properties.

var arr = [ 'foo', 'bar', 'foo' ];
console.log( CKEDITOR.tools.convertArrayToObject( arr ) );
// -> { foo: true, bar: true }
console.log( CKEDITOR.tools.convertArrayToObject( arr, 1 ) );
// -> { foo: 1, bar: 1 }

Available since: 4.1

Parameters

  • arr : Array

    The array to be converted to an object.

  • fillWith : Object (optional)

    Set each property of an object to fillWith value.

    Defaults to: true

CKEDITOR.tools
view source
( styleText ) : String
Finds and converts rgb(x,x,x) color definition to hexadecimal notation. ...

Finds and converts rgb(x,x,x) color definition to hexadecimal notation.

Parameters

  • styleText : String

    The style data (or just a string containing RGB colors) to be converted.

Returns

  • String

    The style data with RGB colors converted to hexadecimal equivalents.

CKEDITOR.tools
view source
( cssLength )
Converts the specified CSS length value to the calculated pixel length inside this page. ...

Converts the specified CSS length value to the calculated pixel length inside this page.

Note: Percentage-based value is left intact.

Parameters

  • cssLength : String

    CSS length value.

CKEDITOR.tools
view source
( source ) : Object
Makes fast (shallow) copy of an object. ...

Makes fast (shallow) copy of an object. This method is faster than clone which does a deep copy of an object (including arrays).

Available since: 4.1

Parameters

  • source : Object

    The object to be copied.

Returns

  • Object

    Copy of source.

CKEDITOR.tools
view source
( definition ) : Function
Class creation based on prototype inheritance which supports of the following features: Static fields Private field...

Class creation based on prototype inheritance which supports of the following features:

  • Static fields
  • Private fields
  • Public (prototype) fields
  • Chainable base class constructor

Parameters

  • definition : Object

    The class definition object.

Returns

  • Function

    A class-like JavaScript function.

CKEDITOR.tools
view source
( length )
Appends the px length unit to the size value if it is missing. ...

Appends the px length unit to the size value if it is missing.

var cssLength = CKEDITOR.tools.cssLength;
cssLength( 42 );        // '42px'
cssLength( '42' );      // '42px'
cssLength( '42px' );    // '42px'
cssLength( '42%' );     // '42%'
cssLength( 'bold' );    // 'bold'
cssLength( false );     // ''
cssLength( NaN );       // ''

Parameters

  • length : Number/String/Boolean
CKEDITOR.tools
view source
( cssName ) : String
Transforms a CSS property name to its relative DOM style name. ...

Transforms a CSS property name to its relative DOM style name.

alert( CKEDITOR.tools.cssStyleToDomStyle( 'background-color' ) );   // 'backgroundColor'
alert( CKEDITOR.tools.cssStyleToDomStyle( 'float' ) );              // 'cssFloat'

Parameters

  • cssName : String

    The CSS property name.

Returns

  • String

    The transformed name.

CKEDITOR.tools
view source
( property, value, [asString] ) : Object/String
Generates an object or a string containing vendor-specific and vendor-free CSS properties. ...

Generates an object or a string containing vendor-specific and vendor-free CSS properties.

CKEDITOR.tools.cssVendorPrefix( 'border-radius', '0', true );
// On Firefox: '-moz-border-radius:0;border-radius:0'
// On Chrome: '-webkit-border-radius:0;border-radius:0'

Parameters

  • property : String

    The CSS property name.

  • value : String

    The CSS value.

  • asString : Boolean (optional)

    If true, then the returned value will be a CSS string.

    Defaults to: false

Returns

  • Object/String

    The object containing CSS properties or its stringified version.

CKEDITOR.tools
view source
( fn ) : Function
Creates a "deferred" function which will not run immediately, but rather runs as soon as the interpreter’s call stack...

Creates a "deferred" function which will not run immediately, but rather runs as soon as the interpreter’s call stack is empty. Behaves much like window.setTimeout with a delay.

Note: The return value of the original function will be lost.

Parameters

  • fn : Function

    The callee function.

Returns

  • Function

    The new deferred function.

CKEDITOR.tools
view source
( doc, [withAppend] )
Enables HTML5 elements for older browsers (IE8) in the passed document. ...

Enables HTML5 elements for older browsers (IE8) in the passed document.

In IE8 this method can also be executed on a document fragment.

Note: This method has to be used in the <head> section of the document.

Available since: 4.3

Parameters

  • doc : Object

    Native Document or DocumentFragment in which the elements will be enabled.

  • withAppend : Boolean (optional)

    Whether to append created elements to the doc.

CKEDITOR.tools
view source
( selector ) : String
Returns an escaped CSS selector. ...

Returns an escaped CSS selector. CSS.escape() is used if defined, leading digit is escaped otherwise.

Available since: 4.5.10

Parameters

  • selector : String

    A CSS selector to escape.

Returns

  • String

    An escaped selector.

CKEDITOR.tools
view source
( minInterval, output, [scopeObj] ) : Object
Buffers input events (or any input calls) and triggers output not more often than once per minInterval. ...

Buffers input events (or any input calls) and triggers output not more often than once per minInterval.

var buffer = CKEDITOR.tools.eventsBuffer( 200, function() {
    console.log( 'foo!' );
} );

buffer.input();
// 'foo!' logged immediately.
buffer.input();
// Nothing logged.
buffer.input();
// Nothing logged.
// ... after 200ms a single 'foo!' will be logged.

Can be easily used with events:

var buffer = CKEDITOR.tools.eventsBuffer( 200, function() {
    console.log( 'foo!' );
} );

editor.on( 'key', buffer.input );
// Note: There is no need to bind buffer as a context.

Available since: 4.2.1

Parameters

  • minInterval : Number

    Minimum interval between output calls in milliseconds.

  • output : Function

    Function that will be executed as output.

  • scopeObj : Object (optional)

    The object used to scope the listener call (the this object).

Returns

  • Object
    • input : Function

      Buffer's input method.

    • reset : Function

      Resets buffered events — output will not be executed until next input is triggered.

CKEDITOR.tools
view source
( target, source, [overwrite], [properties] ) : Object
Copies the properties from one object to another. ...

Copies the properties from one object to another. By default, properties already present in the target object are not overwritten.

// Create the sample object.
var myObject = {
    prop1: true
};

// Extend the above object with two properties.
CKEDITOR.tools.extend( myObject, {
    prop2: true,
    prop3: true
} );

// Alert 'prop1', 'prop2' and 'prop3'.
for ( var p in myObject )
    alert( p );

Parameters

  • target : Object

    The object to be extended.

  • source : Object...

    The object(s) from properties will be copied. Any number of objects can be passed to this function.

  • overwrite : Boolean (optional)

    If true is specified, it indicates that properties already present in the target object could be overwritten by subsequent objects.

  • properties : Object (optional)

    Only properties within the specified names list will be received from the source object.

Returns

  • Object

    The extended object (target).

CKEDITOR.tools
view source
( ) : Boolean
Tries to fix the document.domain of the current document to match the parent window domain, avoiding "Same Origin" po...

Tries to fix the document.domain of the current document to match the parent window domain, avoiding "Same Origin" policy issues. This is an Internet Explorer only requirement.

Available since: 4.1.2

Returns

  • Boolean

    true if the current domain is already good or if it has been fixed successfully.

CKEDITOR.tools
view source
( subKey ) : String
Generates a combined key from a series of params. ...

Generates a combined key from a series of params.

var key = CKEDITOR.tools.genKey( 'key1', 'key2', 'key3' );
alert( key ); // 'key1-key2-key3'.

Parameters

  • subKey : String

    One or more strings used as subkeys.

Returns

  • String
CKEDITOR.tools
view source
( name ) : String
Returns the value of the cookie with a given name or null if the cookie is not found. ...

Returns the value of the cookie with a given name or null if the cookie is not found.

Available since: 4.5.6

Parameters

  • name : String

Returns

  • String
CKEDITOR.tools
view source
( ) : String
Returns the CSRF token value. ...

Returns the CSRF token value. The value is a hash stored in document.cookie under the ckCsrfToken key. The CSRF token can be used to secure the communication between the web browser and the server, i.e. for the file upload feature in the editor.

Available since: 4.5.6

Returns

  • String
CKEDITOR.tools
view source
( array, compareFunction ) : Number
Finds the index of the first element in an array for which the compareFunction returns true. ...

Finds the index of the first element in an array for which the compareFunction returns true.

CKEDITOR.tools.getIndex( [ 1, 2, 4, 3, 5 ], function( el ) {
    return el >= 3;
} ); // 2

Available since: 4.5

Parameters

  • array : Array

    Array to search in.

  • compareFunction : Function

    Compare function.

Returns

  • Number

    The index of the first matching element or -1 if none matches.

CKEDITOR.tools
view source
( ) : String
Gets a unique ID for CKEditor interface elements. ...

Gets a unique ID for CKEditor interface elements. It returns a string with the "cke_" prefix and a consecutive number.

alert( CKEDITOR.tools.getNextId() ); // (e.g.) 'cke_1'
alert( CKEDITOR.tools.getNextId() ); // 'cke_2'

Returns

  • String

    A unique ID.

CKEDITOR.tools
view source
( ) : Number
Gets a unique number for this CKEDITOR execution session. ...

Gets a unique number for this CKEDITOR execution session. It returns consecutive numbers starting from 1.

alert( CKEDITOR.tools.getNextNumber() ); // (e.g.) 1
alert( CKEDITOR.tools.getNextNumber() ); // 2

Returns

  • Number

    A unique number.

CKEDITOR.tools
view source
( ) : String
Gets a universally unique ID. ...

Gets a universally unique ID. It returns a random string compliant with ISO/IEC 11578:1996, without dashes, with the "e" prefix to make sure that the ID does not start with a number.

Returns

  • String

    A global unique ID.

CKEDITOR.tools
view source
( The ) : String
Decodes HTML entities that browsers tend to encode when used in text nodes. ...

Decodes HTML entities that browsers tend to encode when used in text nodes.

alert( CKEDITOR.tools.htmlDecode( '&lt;a &amp; b &gt;' ) ); // '<a & b >'

Read more about chosen entities in the research.

Parameters

  • The : String

    string to be decoded.

Returns

  • String

    The decoded string.

CKEDITOR.tools
view source
( text ) : String
Decodes HTML entities that browsers tend to encode when used in attributes. ...

Decodes HTML entities that browsers tend to encode when used in attributes.

alert( CKEDITOR.tools.htmlDecodeAttr( '&lt;a &quot; b&gt;' ) ); // '<a " b>'

Since CKEditor 4.5 this method simply executes htmlDecode which covers all necessary entities.

Parameters

  • text : String

    The text to be decoded.

Returns

  • String

    The decoded text.

CKEDITOR.tools
view source
( text ) : String
Replaces special HTML characters in a string with their relative HTML entity values. ...

Replaces special HTML characters in a string with their relative HTML entity values.

alert( CKEDITOR.tools.htmlEncode( 'A > B & C < D' ) ); // 'A &gt; B &amp; C &lt; D'

Parameters

  • text : String

    The string to be encoded.

Returns

  • String

    The encoded string.

CKEDITOR.tools
view source
( The ) : String
Replaces special HTML characters in HTMLElement attribute with their relative HTML entity values. ...

Replaces special HTML characters in HTMLElement attribute with their relative HTML entity values.

alert( CKEDITOR.tools.htmlEncodeAttr( '<a " b >' ) ); // '&lt;a &quot; b &gt;'

Parameters

  • The : String

    attribute value to be encoded.

Returns

  • String

    The encoded value.

CKEDITOR.tools
view source
( array, value ) : Number
Returns the index of an element in an array. ...

Returns the index of an element in an array.

var letters = [ 'a', 'b', 0, 'c', false ];
alert( CKEDITOR.tools.indexOf( letters, '0' ) );        // -1 because 0 !== '0'
alert( CKEDITOR.tools.indexOf( letters, false ) );      // 4 because 0 !== false

Parameters

  • array : Array

    The array to be searched.

  • value : Object/Function

    The element to be found. This can be an evaluation function which receives a single parameter call for each entry in the array, returning true if the entry matches.

Returns

  • Number

    The (zero-based) index of the first entry that matches the entry, or -1 if not found.

CKEDITOR.tools
view source
( object ) : Boolean
Checks if an object is an Array. ...

Checks if an object is an Array.

alert( CKEDITOR.tools.isArray( [] ) );      // true
alert( CKEDITOR.tools.isArray( 'Test' ) );  // false

Parameters

  • object : Object

    The object to be checked.

Returns

  • Boolean

    true if the object is an Array, otherwise false.

CKEDITOR.tools
view source
( object ) : Boolean
Whether the object contains no properties of its own. ...

Whether the object contains no properties of its own.

Parameters

  • object : Object

Returns

  • Boolean
CKEDITOR.tools
view source
( lang, keystroke ) : {display: String, aria: String}
Converts a keystroke to its string representation. ...

Converts a keystroke to its string representation. Returns an object with two fields:

  • display – A string that should be used for visible labels. For Mac devices it uses for ALT, for SHIFT and for COMMAND.
  • aria – A string that should be used for ARIA descriptions. It does not use special characters such as , or .

      var lang = editor.lang.common.keyboard;
      var shortcut = CKEDITOR.tools.keystrokeToString( lang, CKEDITOR.CTRL + 88 );
      console.log( shortcut.display ); // 'CTRL + X', on Mac '⌘ + X'.
      console.log( shortcut.aria ); // 'CTRL + X', on Mac 'COMMAND + X'.
    

Available since: 4.6.0

Parameters

  • lang : Object

    A language object with the key name translation.

  • keystroke : Number

    The keystroke to convert.

Returns

  • {display: String, aria: String}
CKEDITOR.tools
view source
( str ) : String
Removes spaces from the start (left) of a string. ...

Removes spaces from the start (left) of a string. The following characters are removed: space, tab, line break, line feed.

alert( CKEDITOR.tools.ltrim( '  example ' ); // 'example '

Parameters

  • str : String

    The text from which the spaces will be removed.

Returns

  • String

    The modified string excluding the removed spaces.

CKEDITOR.tools
view source
( styleText, [nativeNormalize] ) : String
Normalizes CSS data in order to avoid differences in the style attribute. ...

Normalizes CSS data in order to avoid differences in the style attribute.

Parameters

  • styleText : String

    The style data to be normalized.

  • nativeNormalize : Boolean (optional)

    Parse the data using the browser.

    Defaults to: false

Returns

  • String

    The normalized value.

CKEDITOR.tools
view source
( styleText ) : String
Normalizes hexadecimal notation so that the color string is always 6 characters long and lowercase. ...

Normalizes hexadecimal notation so that the color string is always 6 characters long and lowercase.

Parameters

  • styleText : String

    The style data (or just a string containing hex colors) to be converted.

Returns

  • String

    The style data with hex colors normalized.

CKEDITOR.tools
view source
( left, right, [onlyLeft] ) : Boolean
Compares two objects. ...

Compares two objects.

Note: This method performs shallow, non-strict comparison.

Available since: 4.1

Parameters

  • left : Object
  • right : Object
  • onlyLeft : Boolean (optional)

    Check only the properties that are present in the left object.

Returns

  • Boolean

    Whether objects are identical.

CKEDITOR.tools
view source
( obj ) : Array
Returns an array of passed object's keys. ...

Returns an array of passed object's keys.

console.log( CKEDITOR.tools.objectKeys( { foo: 1, bar: false } );
// -> [ 'foo', 'bar' ]

Available since: 4.1

Parameters

  • obj : Object

Returns

  • Array

    Object's keys.

CKEDITOR.tools
view source
( originalFunction, functionBuilder ) : Function
Creates a function override. ...

Creates a function override.

var obj = {
    myFunction: function( name ) {
        alert( 'Name: ' + name );
    }
};

obj.myFunction = CKEDITOR.tools.override( obj.myFunction, function( myFunctionOriginal ) {
    return function( name ) {
        alert( 'Overriden name: ' + name );
        myFunctionOriginal.call( this, name );
    };
} );

Parameters

  • originalFunction : Function

    The function to be overridden.

  • functionBuilder : Function

    A function that returns the new function. The original function reference will be passed to this function.

Returns

  • Function

    The new function.

CKEDITOR.tools
view source
( styleText, [normalize], [nativeNormalize] ) : Object
Turns inline style text properties into one hash. ...

Turns inline style text properties into one hash.

Parameters

  • styleText : String

    The style data to be parsed.

  • normalize : Boolean (optional)

    Normalize properties and values (e.g. trim spaces, convert to lower case).

    Defaults to: false

  • nativeNormalize : Boolean (optional)

    Parse the data using the browser.

    Defaults to: false

Returns

  • Object

    The object containing parsed properties.

CKEDITOR.tools
view source
( source ) : Object
Creates an object which is an instance of a class whose prototype is a predefined object. ...

Creates an object which is an instance of a class whose prototype is a predefined object. All properties defined in the source object are automatically inherited by the resulting object, including future changes to it.

Parameters

  • source : Object

    The source object to be used as the prototype for the final object.

Returns

  • Object

    The resulting copy.

CKEDITOR.tools
view source
( ref )
Removes the function reference created with addFunction. ...

Removes the function reference created with addFunction.

Parameters

  • ref : Number

    The function reference created with addFunction.

CKEDITOR.tools
view source
( str, times ) : String
String specified by str repeats times times. ...

String specified by str repeats times times.

Parameters

  • str : String
  • times : Number

Returns

  • String
CKEDITOR.tools
view source
( str ) : String
Removes spaces from the end (right) of a string. ...

Removes spaces from the end (right) of a string. The following characters are removed: space, tab, line break, line feed.

alert( CKEDITOR.tools.ltrim( '  example ' ); // '  example'

Parameters

  • str : String

    The text from which spaces will be removed.

Returns

  • String

    The modified string excluding the removed spaces.

CKEDITOR.tools
view source
( name, value )
Sets the value of the cookie with a given name. ...

Sets the value of the cookie with a given name.

Available since: 4.5.6

Parameters

  • name : String
  • value : String
CKEDITOR.tools
view source
( func, [milliseconds], [scope], [args], [ownerWindow] ) : Object
Executes a function after a specified delay. ...

Executes a function after a specified delay.

CKEDITOR.tools.setTimeout( function() {
    alert( 'Executed after 2 seconds' );
}, 2000 );

Parameters

  • func : Function

    The function to be executed.

  • milliseconds : Number (optional)

    The amount of time (in milliseconds) to wait to fire the function execution.

    Defaults to: 0

  • scope : Object (optional)

    The object to store the function execution scope (the this object).

    Defaults to: window

  • args : Object/Array (optional)

    A single object, or an array of objects, to pass as argument to the function.

  • ownerWindow : Object (optional)

    The window that will be used to set the timeout.

    Defaults to: window

Returns

  • Object

    A value that can be used to cancel the function execution.

CKEDITOR.tools
view source
( text, enterMode ) : String
Transforms text to valid HTML: creates paragraphs, replaces tabs with non-breaking spaces etc. ...

Transforms text to valid HTML: creates paragraphs, replaces tabs with non-breaking spaces etc.

Available since: 4.5

Parameters

  • text : String

    Text to transform.

  • enterMode : Number

    Editor Enter mode.

Returns

  • String

    HTML generated from the text.

CKEDITOR.tools
view source
( str ) : String
Removes spaces from the start and the end of a string. ...

Removes spaces from the start and the end of a string. The following characters are removed: space, tab, line break, line feed.

alert( CKEDITOR.tools.trim( '  example ' ); // 'example'

Parameters

  • str : String

    The text from which the spaces will be removed.

Returns

  • String

    The modified string without the boundary spaces.

CKEDITOR.tools
view source
( fn ) : Mixed
Returns the first successfully executed return value of a function that does not throw any exception. ...

Returns the first successfully executed return value of a function that does not throw any exception.

Parameters

  • fn : Function...

Returns

  • Mixed
CKEDITOR.tools
view source
( styles, [sort] ) : String
Serializes the style name => value hash to a style text. ...

Serializes the style name => value hash to a style text.

var styleObj = CKEDITOR.tools.parseCssText( 'color: red; border: none' );
console.log( styleObj.color ); // -> 'red'
CKEDITOR.tools.writeCssText( styleObj ); // -> 'color:red; border:none'
CKEDITOR.tools.writeCssText( styleObj, true ); // -> 'border:none; color:red'

Available since: 4.1

Parameters

  • styles : Object

    The object contaning style properties.

  • sort : Boolean (optional)

    Whether to sort CSS properties.

Returns

  • String

    The serialized style text.