2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
7 * @fileOverview The "showblocks" plugin. Enable it will make all block level
\r
8 * elements being decorated with a border and the element name
\r
9 * displayed on the left-right corner.
\r
14 var cssTemplate = '.%2 p,'+
\r
26 'background-repeat: no-repeat;'+
\r
27 'border: 1px dotted gray;'+
\r
28 'padding-top: 8px;'+
\r
29 'padding-left: 8px;'+
\r
54 '%1blockquote.png);'+
\r
87 var cssTemplateRegex = /%1/g, cssClassRegex = /%2/g;
\r
89 var commandDefinition =
\r
91 preserveState : true,
\r
93 exec : function ( editor )
\r
96 this.refresh( editor );
\r
99 refresh : function( editor )
\r
101 var funcName = ( this.state == CKEDITOR.TRISTATE_ON ) ? 'addClass' : 'removeClass';
\r
102 editor.document.getBody()[ funcName ]( 'cke_show_blocks' );
\r
106 CKEDITOR.plugins.add( 'showblocks',
\r
108 requires : [ 'wysiwygarea' ],
\r
110 init : function( editor )
\r
112 var command = editor.addCommand( 'showblocks', commandDefinition );
\r
113 command.canUndo = false;
\r
115 if ( editor.config.startupOutlineBlocks )
\r
116 command.setState( CKEDITOR.TRISTATE_ON );
\r
118 editor.addCss( cssTemplate
\r
119 .replace( cssTemplateRegex, 'background-image: url(' + CKEDITOR.getUrl( this.path ) + 'images/block_' )
\r
120 .replace( cssClassRegex, 'cke_show_blocks ' ) );
\r
122 editor.ui.addButton( 'ShowBlocks',
\r
124 label : editor.lang.showBlocks,
\r
125 command : 'showblocks'
\r
128 // Refresh the command on setData.
\r
129 editor.on( 'mode', function()
\r
131 if ( command.state != CKEDITOR.TRISTATE_DISABLED )
\r
132 command.refresh( editor );
\r
135 // Refresh the command on setData.
\r
136 editor.on( 'contentDom', function()
\r
138 if ( command.state != CKEDITOR.TRISTATE_DISABLED )
\r
139 command.refresh( editor );
\r
146 * Whether to automaticaly enable the "show block" command when the editor
\r
151 * config.startupOutlineBlocks = true;
\r
153 CKEDITOR.config.startupOutlineBlocks = false;
\r