X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fnode.js;h=a106810f326d23e588a218fdd97c1be1b0a2ea11;hb=9afde8772159bd3436f1f5b7862960307710ae5a;hp=2ae3a134c112f8183a49457dbf9c1b9f65d4baee;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/_source/core/dom/node.js b/_source/core/dom/node.js index 2ae3a13..a106810 100644 --- a/_source/core/dom/node.js +++ b/_source/core/dom/node.js @@ -107,24 +107,25 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, { var $clone = this.$.cloneNode( includeChildren ); - if ( !cloneId ) + var removeIds = function( node ) { - var removeIds = function( node ) - { - if ( node.nodeType != CKEDITOR.NODE_ELEMENT ) - return; + if ( node.nodeType != CKEDITOR.NODE_ELEMENT ) + return; - node.removeAttribute( 'id', false ) ; - node.removeAttribute( '_cke_expando', false ) ; + if ( !cloneId ) + node.removeAttribute( 'id', false ); + node.removeAttribute( 'data-cke-expando', false ); + if ( includeChildren ) + { var childs = node.childNodes; - for ( var i=0 ; i < childs.length ; i++ ) + for ( var i=0; i < childs.length; i++ ) removeIds( childs[ i ] ); - }; + } + }; - // The "id" attribute should never be cloned to avoid duplication. - removeIds( $clone ); - } + // The "id" attribute should never be cloned to avoid duplication. + removeIds( $clone ); return new CKEDITOR.dom.node( $clone ); }, @@ -243,13 +244,7 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, */ getDocument : function() { - var document = new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument ); - - return ( - this.getDocument = function() - { - return document; - })(); + return new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument ); }, getIndex : function() @@ -657,6 +652,45 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, child.parentNode.removeChild( child ) ; } } + }, + + /** + * Checks is this node is read-only (should not be changed). It + * additionaly returns the element, if any, which defines the read-only + * state of this node. It may be the node itself or any of its parent + * nodes. + * @returns {CKEDITOR.dom.element|Boolean} An element containing + * read-only attributes or "false" if none is found. + * @since 3.5 + * @example + * // For the following HTML: + * //
Some text
+ * + * // If "ele" is the above
+ * ele.getReadOnlyRoot(); // the
element + * + * // If "ele" is the above + * ele.getReadOnlyRoot(); // the
element + */ + isReadOnly : function() + { + var current = this; + while( current ) + { + if ( current.type == CKEDITOR.NODE_ELEMENT ) + { + if ( current.is( 'body' ) || current.getCustomData( '_cke_notReadOnly' ) ) + break; + + if ( current.getAttribute( 'contentEditable' ) == 'false' ) + return current; + else if ( current.getAttribute( 'contentEditable' ) == 'true' ) + break; + } + current = current.getParent(); + } + + return false; } } );