Ticket #9386: 9386.patch

File 9386.patch, 5.2 KB (added by Garry Yao, 12 years ago)
  • _source/plugins/selection/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    7878                                        && node.getName() in CKEDITOR.dtd.$removeEmpty;
    7979                }
    8080
    81                 var start = range.startContainer,
    82                         offset = range.startOffset;
     81                var container = range.startContainer;
    8382
    84                 if ( start.type == CKEDITOR.NODE_TEXT )
     83                // <body> is free of the fix.
     84                if ( container.is( 'body' ) )
    8585                        return false;
    8686
    87                 // 1. Empty inline element. <span>^</span>
    88                 // 2. Empty block. <p>^</p> (#7222)
    89                 // 3. Adjoin to inline element. <p><strong>text</strong>^</p>
    90                 return !CKEDITOR.tools.trim( start.getHtml() ) ? isInlineCt( start ) || start.isBlockBoundary()
    91                                 : isInlineCt( start.getChild( offset - 1 ) ) || isInlineCt( start.getChild( offset ) );
     87                // After inline element. <p><strong>text</strong>^foo</p>
     88                var previous = range.getPreviousNode( isVisible, null, container );
     89                if ( isInlineCt( previous ) )
     90                        return true;
     91
     92                var next = range.getNextNode( isVisible, null, container );
     93                // Empty element. <span>^</span>, <p>^</p> (#7222)
     94                if ( !( previous || next ) )
     95                        return true;
     96
     97                return false;
    9298        }
    9399
    94100        var selectAllCmd =
     
    17371743                        start.scrollIntoView();
    17381744                }
    17391745        };
    1740 })();
    17411746
    1742 ( function()
    1743 {
    17441747        var notWhitespaces = CKEDITOR.dom.walker.whitespaces( true ),
     1748                        isVisible = CKEDITOR.dom.walker.invisible( 1 );
    17451749                        fillerTextRegex = /\ufeff|\u00a0/,
    17461750                        nonCells = { table:1,tbody:1,tr:1 };
    17471751
  • _source/core/dom/walker.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    428428                var whitespace = CKEDITOR.dom.walker.whitespaces();
    429429                return function( node )
    430430                {
    431                         // Nodes that take no spaces in wysiwyg:
    432                         // 1. White-spaces but not including NBSP;
    433                         // 2. Empty inline elements, e.g. <b></b> we're checking here
    434                         // 'offsetHeight' instead of 'offsetWidth' for properly excluding
    435                         // all sorts of empty paragraph, e.g. <br />.
    436                         var isInvisible = whitespace( node ) || node.is && !node.$.offsetHeight;
    437                         return !! ( isReject ^ isInvisible );
     431                        var invisible;
     432
     433                        if ( whitespace( node ) )
     434                                invisible = 1;
     435                        else
     436                        {
     437                                // Visibility should be checked on element.
     438                                if ( node.type == CKEDITOR.NODE_TEXT )
     439                                        node = node.getParent();
     440
     441                                // Nodes that take no spaces in wysiwyg:
     442                                // 1. White-spaces but not including NBSP;
     443                                // 2. Empty inline elements, e.g. <b></b> we're checking here
     444                                // 'offsetHeight' instead of 'offsetWidth' for properly excluding
     445                                // all sorts of empty paragraph, e.g. <br />.
     446                                invisible = !node.$.offsetHeight;
     447                        }
     448
     449                        return !! ( isReject ^ invisible );
    438450                };
    439451        };
    440452
  • _source/core/dom/range.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    18761876                },
    18771877
    18781878                /**
    1879                  * Check if elements at which the range boundaries anchor are read-only,
    1880                  * with respect to "contenteditable" attribute.
     1879                 * Traverse with {@link CKEDITOR.dom.walker} to retrieve the previous element before the range start.
     1880                 * @param {Function} evaluator Function used as the walker's evaluator.
     1881                 * @param {Function} [guard] Function used as the walker's guard.
     1882                 * @param {CKEDITOR.dom.element} [boundary] A range ancestor element in which the traversal is limited,
     1883                 * default to the root editable if not defined.
     1884                 *
     1885                 * @return {CKEDITOR.dom.element|null} The returned node from the traversal.
    18811886                 */
     1887                getPreviousNode : function( evaluator, guard, boundary ) {
     1888
     1889                        var walkerRange = this.clone();
     1890                        walkerRange.collapse( 1 );
     1891                        walkerRange.setStartAt( boundary || this.document.getBody(), CKEDITOR.POSITION_AFTER_START );
     1892
     1893                        var walker = new CKEDITOR.dom.walker( walkerRange );
     1894                        walker.evaluator = evaluator;
     1895                        walker.guard = guard;
     1896                        return walker.previous();
     1897                },
     1898
     1899                /**
     1900                 * Traverse with {@link CKEDITOR.dom.walker} to retrieve the next element before the range start.
     1901                 * @param {Function} evaluator Function used as the walker's evaluator.
     1902                 * @param {Function} [guard] Function used as the walker's guard.
     1903                 * @param {CKEDITOR.dom.element} [boundary] A range ancestor element in which the traversal is limited,
     1904                 * default to the root editable if not defined.
     1905                 *
     1906                 * @return {CKEDITOR.dom.element|null} The returned node from the traversal.
     1907                 */
     1908                getNextNode: function( evaluator, guard, boundary )
     1909                {
     1910                        var walkerRange = this.clone();
     1911                        walkerRange.collapse();
     1912                        walkerRange.setEndAt( boundary || this.document.getBody(), CKEDITOR.POSITION_BEFORE_END );
     1913
     1914                        var walker = new CKEDITOR.dom.walker( walkerRange );
     1915                        walker.evaluator = evaluator;
     1916                        walker.guard = guard;
     1917                        return walker.next();
     1918                },
     1919
    18821920                checkReadOnly : ( function()
    18831921                {
    18841922                        function checkNodesEditable( node, anotherEnd )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy