1 /*
  2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
  3 For licensing, see LICENSE.html or http://ckeditor.com/license
  4 */
  5
  6 /**
  7  * @file Horizontal Page Break
  8  */
  9
 10 // Register a plugin named "newpage".
 11 CKEDITOR.plugins.add( 'newpage',
 12 {
 13 	init : function( editor )
 14 	{
 15 		editor.addCommand( 'newpage',
 16 			{
 17 				modes : { wysiwyg:1, source:1 },
 18
 19 				exec : function( editor )
 20 				{
 21 					var command = this;
 22 					function afterCommand()
 23 					{
 24 						// Defer to happen after 'selectionChange'.
 25 						setTimeout( function()
 26 						{
 27 							editor.fire( 'afterCommandExec',
 28 							{
 29 								name: command.name,
 30 								command: command
 31 							} );
 32 						}, 500 );
 33 					}
 34 					if ( editor.mode == 'wysiwyg')
 35 						editor.on( 'contentDom', function( evt ){
 36
 37 							evt.removeListener();
 38 	                        afterCommand();
 39 						} );
 40
 41 					editor.setData( editor.config.newpage_html );
 42 					editor.focus();
 43
 44 					if( editor.mode == 'source' )
 45 						afterCommand();
 46
 47 				},
 48 				async : true
 49 			});
 50
 51 		editor.ui.addButton( 'NewPage',
 52 			{
 53 				label : editor.lang.newPage,
 54 				command : 'newpage'
 55 			});
 56 	}
 57 });
 58
 59 CKEDITOR.config.newpage_html = '';
 60