Mimimum syndical pour en faire un produit zope / cmf.
[ckeditor.git] / _source / plugins / horizontalrule / plugin.js
1 /*
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
5
6 /**
7 * @file Horizontal Rule plugin.
8 */
9
10 (function()
11 {
12 var horizontalruleCmd =
13 {
14 canUndo : false, // The undo snapshot will be handled by 'insertElement'.
15 exec : function( editor )
16 {
17 var hr = editor.document.createElement( 'hr' ),
18 range = new CKEDITOR.dom.range( editor.document );
19
20 editor.insertElement( hr );
21
22 // If there's nothing or a non-editable block followed by, establish a new paragraph
23 // to make sure cursor is not trapped.
24 range.moveToPosition( hr, CKEDITOR.POSITION_AFTER_END );
25 var next = hr.getNext();
26 if ( !next || next.type == CKEDITOR.NODE_ELEMENT && !next.isEditable() )
27 range.fixBlock( true, editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' );
28
29 range.select();
30 }
31 };
32
33 var pluginName = 'horizontalrule';
34
35 // Register a plugin named "horizontalrule".
36 CKEDITOR.plugins.add( pluginName,
37 {
38 init : function( editor )
39 {
40 editor.addCommand( pluginName, horizontalruleCmd );
41 editor.ui.addButton( 'HorizontalRule',
42 {
43 label : editor.lang.horizontalrule,
44 command : pluginName
45 });
46 }
47 });
48 })();