X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fhorizontalrule%2Fplugin.js;h=3eac31915ed66cf8655c116c89568eb9da3db6be;hp=d4ec65a6eb40a06aa7e7f717652d5232357ba805;hb=f0610347140239143439a511ee2bd48cb784f470;hpb=4e70ea24db840898be8cc21c950363a52a2a6aba diff --git a/_source/plugins/horizontalrule/plugin.js b/_source/plugins/horizontalrule/plugin.js index d4ec65a..3eac319 100644 --- a/_source/plugins/horizontalrule/plugin.js +++ b/_source/plugins/horizontalrule/plugin.js @@ -14,7 +14,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license 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(); } };