Ticket #7216: 7216.patch

File 7216.patch, 5.9 KB (added by Alfonso Martínez de Lizarrondo, 13 years ago)

Proposed plugin

  • _source/core/dom/node.js

     
    648648                        }
    649649                },
    650650
    651                 /**
    652                  * Checks is this node is read-only (should not be changed). It
    653                  * additionaly returns the element, if any, which defines the read-only
    654                  * state of this node. It may be the node itself or any of its parent
    655                  * nodes.
    656                  * @returns {CKEDITOR.dom.element|Boolean} An element containing
    657                  *              read-only attributes or "false" if none is found.
    658                  * @since 3.5
    659                  * @example
    660                  * // For the following HTML:
    661                  * // <div contenteditable="false">Some <b>text</b></div>
    662                  *
    663                  * // If "ele" is the above <div>
    664                  * ele.isReadOnly();  // the <div> element
    665                  *
    666                  * // If "ele" is the above <b>
    667                  * ele.isReadOnly();  // the <div> element
    668                  */
    669651                isReadOnly : function()
    670652                {
    671                         var current = this;
    672                         while( current )
    673                         {
    674                                 if ( current.type == CKEDITOR.NODE_ELEMENT )
    675                                 {
    676                                         if ( current.is( 'body' ) || !!current.data( 'cke-editable' ) )
    677                                                 break;
    678 
    679                                         if ( current.getAttribute( 'contentEditable' ) == 'false' )
    680                                                 return current;
    681                                         else if ( current.getAttribute( 'contentEditable' ) == 'true' )
    682                                                 break;
    683                                 }
    684                                 current = current.getParent();
    685                         }
    686 
     653                        // The full implementation is in the "noneditable" plugin
    687654                        return false;
    688655                }
    689656        }
  • _source/plugins/noneditable/plugin.js

    Property changes on: _source\plugins\noneditable
    ___________________________________________________________________
    Added: bugtraq:label
       + Ticket
    Added: bugtraq:url
       + http://dev.ckeditor.com/ticket/%BUGID%
    Added: webviewer:pathrevision
       + http://dev.fckeditor.net/browser/%PATH%?rev=%REVISION% 
    Added: webviewer:revision
       + http://dev.fckeditor.net/changeset/%REVISION%
    Added: bugtraq:logregex
       + (?:ticket: *|#)(\d+) *(?:, *(\d+))*
    
    
     
     1/*
     2Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6/**
     7 * @fileOverview The "non-Editable" plugin. Adds additional styles, functions
     8 * and event handlers to provide correct support for contentEditable=false
     9 * elements.
     10 */
     11
     12CKEDITOR.plugins.add( 'noneditable',
     13{
     14        init : function( editor )
     15        {
     16
     17                // IE>=8 stricts mode doesn't have 'contentEditable' in effect
     18                // on element unless it has layout. (#5562)
     19                if ( CKEDITOR.document.$.documentMode >= 8 )
     20                {
     21                        editor.addCss( 'html.CSS1Compat [contenteditable=false]{ min-height:0 !important;}' );
     22
     23                        var selectors = [];
     24                        for ( var tag in CKEDITOR.dtd.$removeEmpty )
     25                                selectors.push( 'html.CSS1Compat ' + tag + '[contenteditable=false]' );
     26                        editor.addCss( selectors.join( ',' ) + '{ display:inline-block;}' );
     27                }
     28
     29        }
     30});
     31
     32
     33/**
     34 * Checks if this node is read-only (should not be changed). It
     35 * additionaly returns the element, if any, which defines the read-only
     36 * state of this node. It may be the node itself or any of its parent
     37 * nodes.
     38 * Since 3.x the default implementation is a placeholder, to get the full
     39 * functionality the 'noneditable' plugin must be loaded.
     40 * @returns {CKEDITOR.dom.element|Boolean} An element containing
     41 *              read-only attributes or "false" if none is found.
     42 * @since 3.5
     43 * @example
     44 * // For the following HTML:
     45 * // <div contenteditable="false">Some <b>text</b></div>
     46 *
     47 * // If "ele" is the above <div>
     48 * ele.isReadOnly();  // the <div> element
     49 *
     50 * // If "ele" is the above <b>
     51 * ele.isReadOnly();  // the <div> element
     52 */
     53CKEDITOR.dom.node.prototype.isReadOnly = function()
     54{
     55        var current = this;
     56        while( current )
     57        {
     58                if ( current.type == CKEDITOR.NODE_ELEMENT )
     59                {
     60                        if ( current.is( 'body' ) || !!current.data( 'cke-editable' ) )
     61                                break;
     62
     63                        if ( current.getAttribute( 'contentEditable' ) == 'false' )
     64                                return current;
     65                        else if ( current.getAttribute( 'contentEditable' ) == 'true' )
     66                                break;
     67                }
     68                current = current.getParent();
     69        }
     70
     71        return false;
     72}
     73
  • _source/plugins/placeholder/plugin.js

     
    1313        var placeholderReplaceRegex = /\[\[[^\]]+\]\]/g;
    1414        CKEDITOR.plugins.add( 'placeholder',
    1515        {
    16                 requires : [ 'dialog' ],
     16                requires : [ 'dialog', 'noneditable' ],
    1717                lang : [ 'en' ],
    1818                init : function( editor )
    1919                {
  • _source/plugins/wysiwygarea/plugin.js

     
    11091109                                        editor.document.$.title = frameLabel;
    11101110                                });
    11111111
    1112                         // IE>=8 stricts mode doesn't have 'contentEditable' in effect
    1113                         // on element unless it has layout. (#5562)
    1114                         if ( CKEDITOR.document.$.documentMode >= 8 )
    1115                         {
    1116                                 editor.addCss( 'html.CSS1Compat [contenteditable=false]{ min-height:0 !important;}' );
    1117 
    1118                                 var selectors = [];
    1119                                 for ( var tag in CKEDITOR.dtd.$removeEmpty )
    1120                                         selectors.push( 'html.CSS1Compat ' + tag + '[contenteditable=false]' );
    1121                                 editor.addCss( selectors.join( ',' ) + '{ display:inline-block;}' );
    1122                         }
    11231112                        // Set the HTML style to 100% to have the text cursor in affect (#6341)
    1124                         else if ( CKEDITOR.env.gecko )
     1113                        if ( CKEDITOR.env.gecko )
    11251114                                editor.addCss( 'html { height: 100% !important; }' );
    11261115
    11271116                        // Switch on design mode for a short while and close it after then.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy