CKEDITOR.plugins.widget.nestedEditable
The wrapper class for editable elements inside widgets.
Do not use directly. Use CKEDITOR.plugins.widget.definition.editables or CKEDITOR.plugins.widget.initEditable.
Filtering
Properties
-
The native DOM object represented by this class instance.
var element = new CKEDITOR.dom.element( 'span' ); alert( element.$.nodeType ); // '1' -
The editor instance.
-
The enter mode active in this editable. It is determined from editable's name (whether it is a blockless editable), its allowed content rules (if defined) and the default editor's mode.
-
The filter instance if allowed content rules were defined.
-
The shift enter move active in this editable.
-
The node type. This is a constant value set to CKEDITOR.NODE_ELEMENT.
Defaults to
CKEDITOR.NODE_ELEMENT
Static properties
Methods
inherited
constructor( nativeDomObject ) → domObjectCKEDITOR.plugins.widget.nestedEditable#constructorCreates a domObject class instance.
Parameters
nativeDomObject : ObjectA native DOM object.
Returns
domObject
Adds a CSS class to the element. It appends the class to the already existing names.
var element = new CKEDITOR.dom.element( 'div' ); element.addClass( 'classA' ); // <div class="classA"> element.addClass( 'classB' ); // <div class="classA classB"> element.addClass( 'classA' ); // <div class="classA classB">Note: Since CKEditor 4.5.0 this method cannot be used with multiple classes (
'classA classB').Parameters
className : StringThe name of the class to be added.
Returns
elementthis
Append a node as a child of this element.
var p = new CKEDITOR.dom.element( 'p' ); var strong = new CKEDITOR.dom.element( 'strong' ); p.append( strong ); var em = p.append( 'em' ); // Result: '<p><strong></strong><em></em></p>'Parameters
node : node | StringThe node or element name to be appended.
[ toStart ] : BooleanIndicates that the element is to be appended at the start.
Defaults to
falseReturns
nodeThe appended node.
Appends a
<br>filler element to this element if the filler is not present already. By default filler is appended only if CKEDITOR.env.needsBrFiller istrue, however whenforceis set totruefiller will be appended regardless of the environment.Parameters
[ force ] : BooleanAppend filler regardless of the environment.
Append text to this element.
var p = new CKEDITOR.dom.element( 'p' ); p.appendText( 'This is' ); p.appendText( ' some text' ); // Result: '<p>This is some text</p>'Parameters
text : StringThe text to be appended.
Makes this node a child of another element.
var p = new CKEDITOR.dom.element( 'p' ); var strong = new CKEDITOR.dom.element( 'strong' ); strong.appendTo( p ); // Result: '<p><strong></strong></p>'.Parameters
element : elementThe target element to which this node will be appended.
Returns
elementThe target element.
Breaks one of the ancestor element in the element position, moving this element between the broken parts.
// Before breaking: // <b>This <i>is some<span /> sample</i> test text</b> // If "element" is <span /> and "parent" is <i>: // <b>This <i>is some</i><span /><i> sample</i> test text</b> element.breakParent( parent ); // Before breaking: // <b>This <i>is some<span /> sample</i> test text</b> // If "element" is <span /> and "parent" is <b>: // <b>This <i>is some</i></b><span /><b><i> sample</i> test text</b> element.breakParent( parent );Parameters
parent : elementThe anscestor element to get broken.
[ cloneId ] : BooleanWhether to preserve ancestor ID attributes while breaking.
Defaults to
falseRegister event handler under the capturing stage on supported target.
Removes any data stored in this object. To avoid memory leaks we must assure that there are no references left after the object is no longer needed.
inherited
clone( [ includeChildren ], [ cloneId ] ) → nodeCKEDITOR.plugins.widget.nestedEditable#cloneClones this node.
Note: Values set by {setCustomData} will not be available in the clone.
Parameters
[ includeChildren ] : BooleanIf
truethen all node's children will be cloned recursively.Defaults to
false[ cloneId ] : BooleanWhether ID attributes should be cloned, too.
Defaults to
falseReturns
nodeClone of this node.
inherited
copyAttributes( dest, skipAttributes )CKEDITOR.plugins.widget.nestedEditable#copyAttributesCopy all the attributes from one node to the other, kinda like a clone skipAttributes is an object with the attributes that must not be copied.
Parameters
dest : elementThe destination element.
skipAttributes : ObjectA dictionary of attributes to skip.
Gets, sets and removes custom data to be stored as HTML5 data-* attributes.
element.data( 'extra-info', 'test' ); // Appended the attribute data-extra-info="test" to the element. alert( element.data( 'extra-info' ) ); // 'test' element.data( 'extra-info', false ); // Remove the data-extra-info attribute from the element.Parameters
name : StringThe name of the attribute, excluding the
data-part.[ value ] : StringThe value to set. If set to false, the attribute will be removed.
Predefine some intrinsic properties on a specific event name.
Parameters
name : StringThe event name
meta : ObjectDisables browser's context menu in this element.
Determines whether the specified object is equal to the current object.
var doc = new CKEDITOR.dom.document( document ); alert( doc.equals( CKEDITOR.document ) ); // true alert( doc == CKEDITOR.document ); // falseParameters
object : ObjectThe object to compare with the current object.
Returns
Booleantrueif the object is equal.Returns list of elements within this element that match specified
selector.Notes:
- Not available in IE7.
- Returned list is not a live collection (like a result of native
querySelectorAll). Unlike the native
querySelectorAllthis method ensures selector contextualization. This is:HTML: '<body><div><i>foo</i></div></body>' Native: div.querySelectorAll( 'body i' ) // -> [ <i>foo</i> ] Method: div.find( 'body i' ) // -> [] div.find( 'i' ) // -> [ <i>foo</i> ]
Parameters
selector : StringA valid CSS selector.
Returns
nodeList
Returns the first element within this element that matches the specified
selector.Notes:
- Not available in IE7.
Unlike the native
querySelectorthis method ensures selector contextualization. This is:HTML: '<body><div><i>foo</i></div></body>' Native: div.querySelector( 'body i' ) // -> <i>foo</i> Method: div.findOne( 'body i' ) // -> null div.findOne( 'i' ) // -> <i>foo</i>
Parameters
selector : StringA valid CSS selector.
Returns
element
inherited
fire( eventName, [ data ], [ editor ] ) → Boolean | ObjectCKEDITOR.plugins.widget.nestedEditable#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.
since 4.13.0 inherited
fireEventHandler( element, eventName, evt )CKEDITOR.plugins.widget.nestedEditable#fireEventHandlerFires the element event handler attribute, for example:
<button onkeydown="return customFn( event )">x</button>buttonEl.fireEventHandler( 'keydown', { keyCode: 13 // Enter } );Parameters
element : element | HTMLElementAn element with an attached event handler attribute.
eventName : StringEvent name.
evt : ObjectEvent payload.
inherited
fireOnce( eventName, [ data ], [ editor ] ) → Boolean | ObjectCKEDITOR.plugins.widget.nestedEditable#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.
Moves the selection focus to this element.
var element = CKEDITOR.document.getById( 'myTextarea' ); element.focus();Parameters
defer : BooleanWhether to asynchronously defer the execution by 100 ms.
inherited
focusNext( [ ignoreChildren ], [ indexToUse ] )CKEDITOR.plugins.widget.nestedEditable#focusNextMoves the UI focus to the element following this element in the tabindex order.
var element = CKEDITOR.document.getById( 'example' ); element.focusNext();Parameters
[ ignoreChildren ] : BooleanDefaults to
false[ indexToUse ] : Numberinherited
focusPrevious( [ ignoreChildren ], [ indexToUse ] )CKEDITOR.plugins.widget.nestedEditable#focusPreviousMoves the UI focus to the element before this element in the tabindex order.
var element = CKEDITOR.document.getById( 'example' ); element.focusPrevious();Parameters
[ ignoreChildren ] : BooleanDefaults to
false[ indexToUse ] : Numbersince 4.3.0 inherited
forEach( callback, [ type ], [ skipRoot ] )CKEDITOR.plugins.widget.nestedEditable#forEachTraverse the DOM of this element (inclusive), executing a callback for each node.
var element = CKEDITOR.dom.element.createFromHtml( '<div><p>foo<b>bar</b>bom</p></div>' ); element.forEach( function( node ) { console.log( node ); } ); // Will log: // 1. <div> element, // 2. <p> element, // 3. "foo" text node, // 4. <b> element, // 5. "bar" text node, // 6. "bom" text node.Parameters
callback : FunctionFunction to be executed on every node. If
callbackreturnsfalsedescendants of the node will be ignored.[ type ] : NumberIf specified
callbackwill be executed only on nodes of this type.[ skipRoot ] : BooleanDon't execute
callbackon this element.Retrieves a uniquely identifiable tree address for this node. The tree address returned is an array of integers, with each integer indicating a child index of a DOM node, starting from
document.documentElement.For example, assuming
<body>is the second child of<html>(<head>being the first), and we would like to address the third child under the fourth child of<body>, the tree address returned would be:[1, 3, 2].The tree address cannot be used for finding back the DOM tree node once the DOM tree structure has been modified.
Parameters
[ normalized ] : BooleanSee getIndex.
Defaults to
falseReturns
ArrayThe address.
since 3.6.1 inherited
getAscendant( query, [ includeSelf ] ) → nodeCKEDITOR.plugins.widget.nestedEditable#getAscendantGets the closest ancestor node of this node, specified by its name or using an evaluator function.
// Suppose we have the following HTML structure: // <div id="outer"><div id="inner"><p><b>Some text</b></p></div></div> // If node == <b> ascendant = node.getAscendant( 'div' ); // ascendant == <div id="inner"> ascendant = node.getAscendant( 'b' ); // ascendant == null ascendant = node.getAscendant( 'b', true ); // ascendant == <b> ascendant = node.getAscendant( { div:1, p:1 } ); // Searches for the first 'div' or 'p': ascendant == <div id="inner"> // Using custom evaluator: ascendant = node.getAscendant( function( el ) { return el.getId() == 'inner'; } ); // ascendant == <div id="inner">Parameters
query : String | Function | ObjectThe name of the ancestor node to search or an object with the node names to search for or an evaluator function.
[ includeSelf ] : BooleanWhether to include the current node in the search.
Returns
nodeThe located ancestor node or
nullif not found.Gets the value of an element attribute.
var element = CKEDITOR.dom.element.createFromHtml( '<input type="text" />' ); alert( element.getAttribute( 'type' ) ); // 'text'Parameters
name : StringThe attribute name.
Returns
StringThe attribute value or null if not defined.
Gets the values of all element attributes.
Parameters
exclude : ArrayThe names of attributes to be excluded from the returned object.
Returns
ObjectAn object containing all element attributes with their values.
Checks if there is a filler node at the end of an element, and returns it.
Returns
node | BooleanBogus node or
false.Gets a DOM tree descendant under the current node.
var strong = p.getChild( 0 );Parameters
indices : Array | NumberThe child index or array of child indices under the node.
Returns
nodeThe specified DOM child under the current node. Null if child does not exist.
Retrieve the bounding rectangle of the current element, in pixels, relative to the upper-left corner of the browser's client area.
Since 4.10.0 you can pass an additional parameter if the function should return an absolute element position that can be used for positioning elements inside scrollable areas.
For example, you can use this function with the editor's window frame to calculate the absolute rectangle of the visible area of the editor viewport. The retrieved absolute rectangle can be used to position elements like toolbars or notifications (elements outside the editor) to always keep them inside the editor viewport independently from the scroll position.
var frame = editor.window.getFrame(); frame.getClientRect( true );Parameters
[ isAbsolute ] : BooleanThe function will retrieve an absolute rectangle of the element, i.e. the position relative to the upper-left corner of the topmost viewport. This option is available since 4.10.0.
Defaults to
falseReturns
rectThe dimensions of the DOM element.
Gets the element
clientWidthandclientHeight.Returns
ObjectAn object containing the width and height values.
inherited
getComputedStyle( propertyName ) → StringCKEDITOR.plugins.widget.nestedEditable#getComputedStyleGets the current computed value of one of the element CSS style properties.
var element = new CKEDITOR.dom.element( 'span' ); alert( element.getComputedStyle( 'display' ) ); // 'inline'Parameters
propertyName : StringThe style property name.
Returns
StringThe property value.
Gets the value set to a data slot in this object.
var element = new CKEDITOR.dom.element( 'span' ); alert( element.getCustomData( 'hasCustomData' ) ); // e.g. 'true' alert( element.getCustomData( 'nonExistingKey' ) ); // nullParameters
key : StringThe key used to identify the data slot.
Returns
ObjectThis value set to the data slot.
getData() → StringCKEDITOR.plugins.widget.nestedEditable#getDataGets element's direction. Supports both CSS
directionprop anddirattr.Parameters
useComputed : Object
Gets the document containing this element.
var element = CKEDITOR.document.getById( 'example' ); alert( element.getDocument().equals( CKEDITOR.document ) ); // trueReturns
documentThe document.
inherited
getDocumentPosition( [ refDocument ] ) → ObjectCKEDITOR.plugins.widget.nestedEditable#getDocumentPositionGets this element's position in document.
Parameters
[ refDocument ] : document
Returns
ObjectElement's position.
Propertiesx : Numbery : NumberrefDocument
Gets the DTD entries for this element.
Returns
ObjectAn object containing the list of elements accepted by this element.
Retrieves an editor instance which is based on this element (if any). It basically loops over CKEDITOR.instances in search for an instance that uses the element.
var element = new CKEDITOR.dom.element( 'div' ); element.appendTo( CKEDITOR.document.getBody() ); CKEDITOR.replace( element ); alert( element.getEditor().name ); // 'editor1'By default this method considers only original DOM elements upon which the editor was created. Setting
optimizedparameter tofalsewill consider editor editable and its children.Parameters
[ optimized ] : BooleanIf set to
falseit will scan every editor editable.Defaults to
trueReturns
editorAn editor instance or null if nothing has been found.
Gets the first child node of this element.
var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b></div>' ); var first = element.getFirst(); alert( first.getName() ); // 'b'Parameters
evaluator : FunctionFiltering the result node.
Returns
nodeThe first child node or null if not available.
Returns the inner document of this
<iframe>element.Returns
documentThe inner document.
Gets the inner HTML of this element.
var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b></div>' ); alert( element.getHtml() ); // '<b>Example</b>'Returns
StringThe inner HTML of this element.
Gets the value of the
idattribute of this element.var element = CKEDITOR.dom.element.createFromHtml( '<p id="myId"></p>' ); alert( element.getId() ); // 'myId'Returns
StringThe element id, or null if not available.
Gets the index of a node in an array of its
parent.childNodes. Returns-1if a node does not have a parent or when thenormalizedargument is set totrueand the text node is empty and will be removed during the normalization.Let us assume having the following
childNodesarray:[ emptyText, element1, text, text, element2, emptyText2 ] emptyText.getIndex() // 0 emptyText.getIndex( true ) // -1 element1.getIndex(); // 1 element1.getIndex( true ); // 0 element2.getIndex(); // 4 element2.getIndex( true ); // 2 emptyText2.getIndex(); // 5 emptyText2.getIndex( true ); // -1Parameters
normalized : BooleanWhen
true, adjacent text nodes are merged and empty text nodes are removed.Returns
NumberIndex of a node or
-1if a node does not have a parent or is removed during the normalization.See getFirst.
Parameters
evaluator : FunctionFiltering the result node.
Returns
node
Gets the element name (tag name). The returned name is guaranteed to be always full lowercased.
var element = new CKEDITOR.dom.element( 'span' ); alert( element.getName() ); // 'span'Returns
StringThe element name.