Skip to content

Commit

Permalink
Fixing #4129: [FF]Unable to remove list with Ctrl-A.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.ckeditor.com/CKEditor/trunk@4034 da63caf2-3823-0410-a1e8-d69ccee00dfb
  • Loading branch information
garry.yao committed Jul 31, 2009
1 parent b6978d0 commit 29a6952
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.html
Expand Up @@ -223,6 +223,7 @@ <h3>
<li><a href="http://dev.fckeditor.net/ticket/4150">#4150</a> : Fixed enlarge list result incorrect at the inner boundary of block.</li>
<li><a href="http://dev.fckeditor.net/ticket/4164">#4164</a> : Now it is possible to paste text
in Source mode even if forcePasteAsPlainText = true.</li>
<li><a href="http://dev.fckeditor.net/ticket/4129">#4129</a> : [FF]Unable to remove list with Ctrl-A.</li>
</ul>
<h3>
CKEditor 3.0 RC</h3>
Expand Down
15 changes: 8 additions & 7 deletions _source/core/dom/element.js
Expand Up @@ -564,14 +564,15 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
},

/**
* @param ignoreEmpty Skip empty text nodes.
* @param {Function} evaluator Filtering the result node.
*/
getLast: function( ignoreEmpty ) {
var $ = this.$.lastChild;
if ( ignoreEmpty && $ && ( $.nodeType == CKEDITOR.NODE_TEXT ) && !CKEDITOR.tools.trim( $.nodeValue ) )
return new CKEDITOR.dom.node( $ ).getPrevious( true );
else
return $ ? new CKEDITOR.dom.node( $ ) : null;
getLast: function( evaluator ) {
var last = this.$.lastChild,
retval = last && new CKEDITOR.dom.node( last );
if ( retval && evaluator && !evaluator( retval ) )
retval = retval.getPrevious( evaluator );

return retval;
},

getStyle: function( name ) {
Expand Down
17 changes: 17 additions & 0 deletions _source/core/dom/range.js
Expand Up @@ -1408,6 +1408,23 @@ CKEDITOR.dom.range = function( document ) {
return false;
},

/**
* Get the single node enclosed within the range if there's one.
*/
getEnclosedNode: function() {
var walkerRange = this.clone(),
walker = new CKEDITOR.dom.walker( walkerRange ),
isNotBookmarks = CKEDITOR.dom.walker.bookmark( true ),
isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ),
evaluator = function( node ) {
return isNotWhitespaces( node ) && isNotBookmarks( node );
};
walkerRange.evaluator = evaluator;
var node = walker.next();
walker.reset();
return node && node.equals( walker.previous() ) ? node : null;
},

getTouchedStartNode: function() {
var container = this.startContainer;

Expand Down
5 changes: 5 additions & 0 deletions _source/core/dom/walker.js
Expand Up @@ -264,6 +264,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
*/
lastBackward: function() {
return iterateToLast.call( this, true );
},

reset: function() {
delete this.current;
this._ = {};
}

}
Expand Down
3 changes: 2 additions & 1 deletion _source/plugins/domiterator/plugin.js
Expand Up @@ -72,7 +72,7 @@ CKEDITOR.plugins.add( 'domiterator' );

// Probably the document end is reached, we need a marker node.
if ( !this._.lastNode ) {
this._.lastNode = range.document.createText( '' );
this._.lastNode = this._.docEndMarker = range.document.createText( '' );
this._.lastNode.insertAfter( lastNode );
}

Expand Down Expand Up @@ -205,6 +205,7 @@ CKEDITOR.plugins.add( 'domiterator' );
if ( !block ) {
// If no range has been found, this is the end.
if ( !range ) {
this._.docEndMarker && this._.docEndMarker.remove();
this._.nextNode = null;
return null;
}
Expand Down
9 changes: 9 additions & 0 deletions _source/plugins/list/plugin.js
Expand Up @@ -346,6 +346,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
ranges[ 0 ].selectNodeContents( paragraph );
selection.selectRanges( ranges );
}
// Maybe a single range there enclosing the whole list,
// turn on the list state manually(#4129).
else {
var range = ranges.length == 1 && ranges[ 0 ],
enclosedNode = range && range.getEnclosedNode();
if ( enclosedNode && enclosedNode.is && this.type == enclosedNode.getName() ) {
setState.call( this, editor, CKEDITOR.TRISTATE_ON );
}
}
}

var bookmarks = selection.createBookmarks( true );
Expand Down
2 changes: 1 addition & 1 deletion _source/plugins/wysiwygarea/plugin.js
Expand Up @@ -165,7 +165,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license

// Inserting the padding-br before body if it's preceded by an
// unexitable block.
var lastNode = body.getLast( true );
var lastNode = body.getLast( CKEDITOR.dom.walker.whitespaces( true ) );
if ( lastNode && lastNode.getName && ( lastNode.getName() in nonExitableElementNames ) ) {
var paddingBlock = editor.document.createElement(
( CKEDITOR.env.ie && enterMode != CKEDITOR.ENTER_BR ) ? '<br _cke_bogus="true" />' : 'br' );
Expand Down
13 changes: 13 additions & 0 deletions _source/tests/core/dom/element.html
Expand Up @@ -542,6 +542,19 @@
}
},

// Test get last non-spaces child node.
test_getLast : function()
{
var element = new CKEDITOR.dom.element( document.getElementById( 'append' ) );
var span1 = new CKEDITOR.dom.element( 'span' );
element.append( span1 );
element.append( new CKEDITOR.dom.text( ' ' ) );
element.append( new CKEDITOR.dom.text( ' ' ) );
var last = element.getLast( CKEDITOR.dom.walker.whitespaces( true ) );
assert.areSame( span1.$, last.$ );
},


name : document.title
};
})() );
Expand Down
4 changes: 4 additions & 0 deletions _source/tests/plugins/list/list.html
Expand Up @@ -116,6 +116,8 @@
setRange( range, [ 1, 0, 0, 0, 0 ], true );
var sel = editor.getSelection();
sel.selectRanges( [ range ] );
editor.selectionChange();

// Waiting for 'comand state' effected.
this.wait( function(){
// Remove list.
Expand Down Expand Up @@ -148,6 +150,7 @@
setRange( range, [ 1, 1, 0 ], true );
var sel = editor.getSelection();
sel.selectRanges( [ range ] );
editor.selectionChange();

// Waiting for 'comand state' effected.
this.wait( function(){
Expand Down Expand Up @@ -181,6 +184,7 @@
setRange( range, [ 1, 1, 0, 0 ], [ 1, 1, 1, 1 ] );
var sel = editor.getSelection();
sel.selectRanges( [ range ] );
editor.selectionChange();

// Waiting for 'comand state' effected.
this.wait( function(){
Expand Down

0 comments on commit 29a6952

Please sign in to comment.