X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fhorizontalrule%2Fplugin.js;h=3eac31915ed66cf8655c116c89568eb9da3db6be;hb=f0610347140239143439a511ee2bd48cb784f470;hp=80ae0dcc082b340b71785cab2dffffce9d66c952;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/plugins/horizontalrule/plugin.js b/_source/plugins/horizontalrule/plugin.js index 80ae0dc..3eac319 100644 --- a/_source/plugins/horizontalrule/plugin.js +++ b/_source/plugins/horizontalrule/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -11,9 +11,22 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { var horizontalruleCmd = { + canUndo : false, // The undo snapshot will be handled by 'insertElement'. exec : function( editor ) { - editor.insertElement( editor.document.createElement( 'hr' ) ); + var hr = editor.document.createElement( 'hr' ), + range = new CKEDITOR.dom.range( editor.document ); + + editor.insertElement( hr ); + + // If there's nothing or a non-editable block followed by, establish a new paragraph + // to make sure cursor is not trapped. + range.moveToPosition( hr, CKEDITOR.POSITION_AFTER_END ); + var next = hr.getNext(); + if ( !next || next.type == CKEDITOR.NODE_ELEMENT && !next.isEditable() ) + range.fixBlock( true, editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' ); + + range.select(); } };