X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fnode.js;h=661154550ab0a83efd8b080952a664e8e98fb7c2;hb=614511639979907ceb0da3614122a4d8eb963ad4;hp=2ae3a134c112f8183a49457dbf9c1b9f65d4baee;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/_source/core/dom/node.js b/_source/core/dom/node.js index 2ae3a13..6611545 100644 --- a/_source/core/dom/node.js +++ b/_source/core/dom/node.js @@ -657,6 +657,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; } } );