Ticket #8246: 8246_3.patch

File 8246_3.patch, 4.1 KB (added by Garry Yao, 13 years ago)
  • _source/core/dom/node.js

     
    654654                },
    655655
    656656                /**
    657                  * Checks if this node is read-only (should not be changed). Additionally
    658                  * it returns the element that defines the read-only state of this node
    659                  * (if present). It may be the node itself or any of its parent
    660                  * nodes.
    661                  * @returns {CKEDITOR.dom.element|Boolean} An element containing
    662                  *              read-only attributes or "false" if none is found.
     657                 * Checks if this node is read-only (should not be changed).
     658                 * @returns {Boolean}
    663659                 * @since 3.5
    664660                 * @example
    665661                 * // For the following HTML:
    666662                 * // <div contenteditable="false">Some <b>text</b></div>
    667663                 *
    668664                 * // If "ele" is the above <div>
    669                  * ele.isReadOnly();  // the <div> element
    670                  *
    671                  * // If "ele" is the above <b>
    672                  * ele.isReadOnly();  // the <div> element
     665                 * ele.isReadOnly();  // true
    673666                 */
    674667                isReadOnly : function()
    675668                {
    676                         var current = this;
    677                         while( current )
    678                         {
    679                                 if ( current.type == CKEDITOR.NODE_ELEMENT )
    680                                 {
    681                                         if ( current.is( 'body' ) || !!current.data( 'cke-editable' ) )
    682                                                 break;
     669                        var element = this;
     670                        if ( this.type != CKEDITOR.NODE_ELEMENT )
     671                                element = this.getParent();
    683672
    684                                         if ( current.getAttribute( 'contentEditable' ) == 'false' )
    685                                                 return current;
    686                                         else if ( current.getAttribute( 'contentEditable' ) == 'true' )
    687                                                 break;
    688                                 }
    689                                 current = current.getParent();
    690                         }
    691 
    692                         return false;
     673                        if ( element
     674                                        && typeof element.$.isContentEditable != 'undefined'
     675                                        && !element.data( 'cke-editable' ) )
     676                        {
     677                                return !element.$.isContentEditable;
     678                        }
     679                        else
     680                                return false;
    693681                }
    694682        }
    695683);
  • _source/plugins/wysiwygarea/plugin.js

     
    12401240                                {
    12411241                                        // We should flag that the element was locked by our code so
    12421242                                        // it'll be editable by the editor functions (#6046).
    1243                                         if ( !element.isReadOnly() )
     1243                                        var readonly = element.getAttribute( 'contenteditable' ) == 'false';
     1244                                        if ( !readonly )
     1245                                        {
    12441246                                                element.data( 'cke-editable', element.hasAttribute( 'contenteditable' ) ? 'true' : '1' );
    1245                                         element.setAttribute( 'contentEditable', false );
    1246                                 }
     1247                                                element.setAttribute( 'contenteditable', false );
     1248                                        }
     1249                                }
    12471250                        });
    12481251
    12491252                }
  • _source/plugins/selection/plugin.js

     
    961961                                                if ( range.collapsed )
    962962                                                        continue;
    963963
     964                                                // Range may start inside a non-editable element,
     965                                                // replace the range start after it.
     966                                                if ( range.startContainer.isReadOnly() )
     967                                                {
     968                                                        var current = range.startContainer;
     969                                                        while( current )
     970                                                        {
     971                                                                if ( current.is( 'body' ) || !current.isReadOnly() )
     972                                                                        break;
     973
     974                                                                if ( current.type == CKEDITOR.NODE_ELEMENT
     975                                                                                && current.getAttribute( 'contentEditable' ) == 'false' )
     976                                                                        range.setStartAfter( current );
     977
     978                                                                current = current.getParent();
     979                                                        }
     980                                                }
     981
    964982                                                var startContainer = range.startContainer,
    965983                                                        endContainer = range.endContainer,
    966984                                                        startOffset = range.startOffset,
    967985                                                        endOffset = range.endOffset,
    968986                                                        walkerRange = range.clone();
    969987
    970                                                 // Range may start inside a non-editable element, restart range
    971                                                 // by the end of it.
    972                                                 var readOnly;
    973                                                 if ( ( readOnly = startContainer.isReadOnly() ) )
    974                                                         range.setStartAfter( readOnly );
    975 
    976988                                                // Enlarge range start/end with text node to avoid walker
    977989                                                // being DOM destructive, it doesn't interfere our checking
    978990                                                // of elements below as well.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy