Ticket #5479: 5479_9.patch

File 5479_9.patch, 9.3 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/elementspath/plugin.js

     
    179179
    180180                                                if ( name == 'body' )
    181181                                                        break;
     182                                                else if ( name == 'html' )
     183                                                        return;
    182184
    183185                                                element = element.getParent();
    184186                                        }
  • _source/core/dom/element.js

     
    234234                                this.append( new CKEDITOR.dom.text( text ) );
    235235                },
    236236
    237                 appendBogus : function()
    238                 {
    239                         var lastChild = this.getLast() ;
    240 
    241                         // Ignore empty/spaces text.
    242                         while ( lastChild && lastChild.type == CKEDITOR.NODE_TEXT && !CKEDITOR.tools.rtrim( lastChild.getText() ) )
    243                                 lastChild = lastChild.getPrevious();
    244                         if ( !lastChild || !lastChild.is || !lastChild.is( 'br' ) )
    245                         {
    246                                 var bogus = CKEDITOR.env.opera ?
    247                                                 this.getDocument().createText('') :
    248                                                 this.getDocument().createElement( 'br' );
    249 
    250                                 CKEDITOR.env.gecko && bogus.setAttribute( 'type', '_moz' );
    251 
    252                                 this.append( bogus );
    253                         }
    254                 },
    255 
    256237                /**
    257238                * Retrieve block element's filler node if existed.
    258239                */
  • _source/core/dom/walker.js

     
    449449                return false;
    450450        };
    451451
     452        // Append a filler node at the end of an element if not exists.
     453        CKEDITOR.dom.element.prototype.appendBogus = function()
     454        {
     455                var lastChild = this.getLast( fillerEvaluator ) ;
     456                if ( !lastChild || !lastChild.is || !lastChild.is( 'br' ) )
     457                {
     458                        var bogus = CKEDITOR.env.opera ?
     459                                        this.getDocument().createText('') :
     460                                        this.getDocument().createElement( 'br' );
     461
     462                        CKEDITOR.env.gecko && bogus.setAttribute( 'type', '_moz' );
     463
     464                        this.append( bogus );
     465                }
     466        };
     467
     468
    452469})();
  • _source/plugins/wysiwygarea/plugin.js

     
    304304                return block.getOuterHtml().match( emptyParagraphRegexp );
    305305        }
    306306
    307         isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true );
    308 
    309307        // Gecko need a key event to 'wake up' the editing
    310308        // ability when document is empty.(#3864, #5781)
    311309        function activateEditing( editor )
     
    359357
    360358                CKEDITOR.env.gecko && activateEditing( editor );
    361359
     360                // Remove the padding body node used in IE.
     361                if ( CKEDITOR.env.ie )
     362                {
     363                        var start = range.collapsed && range.startContainer;
     364                        if ( start.type == CKEDITOR.NODE_ELEMENT && start.is( 'span') && start.data( 'cke-bogus') )
     365                        {
     366                                range.moveToPosition( start, CKEDITOR.POSITION_BEFORE_START );
     367                                start.remove();
     368                                range.select();
     369                                return;
     370                        }
     371                }
     372
    362373                // When enterMode set to block, we'll establing new paragraph only if we're
    363374                // selecting inline contents right under body. (#3657)
    364375                if ( enterMode != CKEDITOR.ENTER_BR
     
    396407                                {
    397408                                        element = fixedBlock.getPrevious( isNotWhitespace );
    398409                                        if ( element &&
    399                                                  element.type == CKEDITOR.NODE_ELEMENT &&
    400                                                  !nonExitable( element ) )
     410                                                 element.type == CKEDITOR.NODE_ELEMENT )
    401411                                        {
    402                                                 range.moveToElementEditEnd( element );
    403                                                 fixedBlock.remove();
    404                                         }
    405                                 }
    406                         }
     412                                                if ( !nonExitable( element ) )
     413                                                {
     414                                                        range.moveToElementEditEnd( element );
     415                                                        fixedBlock.remove();
     416                                                }
     417                                                else if ( element.getDirection() )
     418                                                        fixedBlock.setAttribute( 'dir', element.getDirection() );
     419                                        }
     420                                }
     421                        }
    407422
    408423                        range.select();
    409424                        // Notify non-IE that selection has changed.
     
    414429                                editor.selectionChange();
    415430                        }
    416431                }
    417 
    418                 // All browsers are incapable to moving cursor out of certain non-exitable
    419                 // blocks (e.g. table, list, pre) at the end of document, make this happen by
    420                 // place a bogus node there, which would be later removed by dataprocessor.
    421                 var walkerRange = new CKEDITOR.dom.range( editor.document ),
    422                         walker = new CKEDITOR.dom.walker( walkerRange );
    423                 walkerRange.selectNodeContents( body );
    424                 walker.evaluator = function( node )
    425                 {
    426                         return node.type == CKEDITOR.NODE_ELEMENT && ( node.getName() in nonExitableElementNames );
    427                 };
    428                 walker.guard = function( node, isMoveout )
    429                 {
    430                         return !( ( node.type == CKEDITOR.NODE_TEXT && isNotWhitespace( node ) ) || isMoveout );
    431                 };
    432 
    433                 if ( walker.previous() )
    434                 {
    435                         editor.fire( 'updateSnapshot' );
    436                         restoreDirty( editor );
    437                         CKEDITOR.env.ie && restoreSelection( selection );
    438 
    439                         var paddingBlock;
    440                         if ( enterMode != CKEDITOR.ENTER_BR )
    441                                 paddingBlock = body.append( new CKEDITOR.dom.element( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) );
    442                         else
    443                                 paddingBlock = body;
    444 
    445                         if ( !CKEDITOR.env.ie )
    446                                 paddingBlock.appendBogus();
    447                 }
    448         }
     432        }
    449433
    450434        CKEDITOR.plugins.add( 'wysiwygarea',
    451435        {
     
    690674                                                        } );
    691675                                                }
    692676
     677                                                // In certain situation when browsers are incapable to moving cursor out of certain non-exitable
     678                                                // blocks (e.g. table, list, pre) at the end of document, make this happen by
     679                                                // placing a padding area, when clicked put a padding node at the end of body. (#5479)
     680                                                var htmlElement = domDocument.getDocumentElement(),
     681                                                        body = domDocument.getBody(),
     682                                                        nonWhiteSpaces = CKEDITOR.dom.walker.whitespaces( 1 ),
     683                                                        bodyPad = htmlElement.append( 'div' );
     684                                                bodyPad.setAttribute( 'contentEditable', false );
     685                                                bodyPad.addClass( 'cke_body_pad' );
     686                                                bodyPad.setStyles( { width : '100%', height : '1em' } );
     687                                                bodyPad.on( 'click', function()
     688                                                {
     689                                                        var last = body.getLast( nonWhiteSpaces );
     690                                                        if ( !last || last.type != CKEDITOR.NODE_ELEMENT || !nonExitable( last ) )
     691                                                                return;
     692
     693                                                        if ( !CKEDITOR.env.ie )
     694                                                                body.appendBogus();
     695                                                        else
     696                                                        {
     697                                                                // IE need at least a node to show the cursor, use a zero height br
     698                                                                // to fly under the radar, additionally wrap the br element with an extra span ,
     699                                                                // so selection change event could be easily captured when cursor move inside of it.
     700                                                                var paddingNode = CKEDITOR.dom.element.createFromHtml( '<span data-cke-bogus=1>' +
     701                                                                        '<br data-cke-temp=1 style="line-height:0"/></span>', domDocument );
     702
     703                                                                body.append( paddingNode );
     704                                                        }
     705
     706                                                        var range = new CKEDITOR.dom.range( domDocument );
     707                                                        range.moveToPosition( body, CKEDITOR.POSITION_BEFORE_END );
     708                                                        range.select();
     709                                                });
     710
    693711                                                // IE standard compliant in editing frame doesn't focus the editor when
    694712                                                // clicking outside actual content, manually apply the focus. (#1659)
    695713                                                if ( CKEDITOR.env.ie
     
    703721                                                                // Setting focus directly on editor doesn't work, we
    704722                                                                // have to use here a temporary element to 'redirect'
    705723                                                                // the focus.
    706                                                                 if ( evt.data.getTarget().equals( htmlElement ) )
     724                                                                if ( !evt.data.getTarget().getAscendant( 'body' ) )
    707725                                                                {
    708726                                                                        if ( CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900 )
    709727                                                                                blinkCursor();
     
    11671185                                }
    11681186                        });
    11691187
    1170                 }
    1171         });
     1188                        var dataProcessor = editor.dataProcessor,
     1189                                htmlFilter = dataProcessor && dataProcessor.htmlFilter;
     1190
     1191                        htmlFilter && htmlFilter.addRules(
     1192                        {
     1193                                elements :
     1194                                {
     1195                                        // Remove body pad for full page.
     1196                                        div : function( element )
     1197                                        {
     1198                                                var attributes = element.attributes;
     1199                                                if ( attributes[ 'class' ] == 'cke_body_pad' )
     1200                                                        return false;
     1201                                        }
     1202                                }
     1203                        });
     1204                }
     1205        });
    11721206
    11731207        // Fixing Firefox 'Back-Forward Cache' break design mode. (#4514)
    11741208        if ( CKEDITOR.env.gecko )
  • _source/plugins/selection/plugin.js

     
    599599                                                                return { container : parent, offset : getNodeIndex( child ) };
    600600                                                }
    601601
    602                                                 // All childs are text nodes.
    603                                                 if ( index == -1 )
     602                                                // All childs are text nodes,
     603                                                // or to the right hand of test range are all text nodes. (#6992)
     604                                                if ( index == -1 || index == siblings.length - 1 && position < 0 )
    604605                                                {
    605606                                                        // Adapt test range to embrace the entire parent contents.
    606607                                                        testRange.moveToElementText( parent );
     
    613614
    614615                                                        siblings = parent.childNodes;
    615616
    616                                                         // Actual range anchor right beside test range at the inner boundary of text node.
     617                                                        // Actual range anchor right beside test range at the boundary of text node.
    617618                                                        if ( !distance )
    618619                                                        {
    619620                                                                child = siblings[ siblings.length - 1 ];
    620                                                                 return  { container : child, offset : child.nodeValue.length };
     621
     622                                                                if ( child.nodeType == CKEDITOR.NODE_ELEMENT )
     623                                                                        return { container : parent, offset : siblings.length };
     624                                                                else
     625                                                                        return { container : child, offset : child.nodeValue.length };
    621626                                                        }
    622627
    623628                                                        // Start the measuring until distance overflows, meanwhile count the text nodes.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy