2 Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
7 * @file Horizontal Rule plugin.
\r
12 var horizontalruleCmd =
\r
14 canUndo : false, // The undo snapshot will be handled by 'insertElement'.
\r
15 exec : function( editor )
\r
17 var hr = editor.document.createElement( 'hr' ),
\r
18 range = new CKEDITOR.dom.range( editor.document );
\r
20 editor.insertElement( hr );
\r
22 // If there's nothing or a non-editable block followed by, establish a new paragraph
\r
23 // to make sure cursor is not trapped.
\r
24 range.moveToPosition( hr, CKEDITOR.POSITION_AFTER_END );
\r
25 var next = hr.getNext();
\r
26 if ( !next || next.type == CKEDITOR.NODE_ELEMENT && !next.isEditable() )
\r
27 range.fixBlock( true, editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' );
\r
33 var pluginName = 'horizontalrule';
\r
35 // Register a plugin named "horizontalrule".
\r
36 CKEDITOR.plugins.add( pluginName,
\r
38 init : function( editor )
\r
40 editor.addCommand( pluginName, horizontalruleCmd );
\r
41 editor.ui.addButton( 'HorizontalRule',
\r
43 label : editor.lang.horizontalrule,
\r
44 command : pluginName
\r