2 Copyright (c) 2003-2010, 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
92 editorFocus : false,
\r
94 exec : function ( editor )
\r
97 this.refresh( editor );
\r
100 refresh : function( editor )
\r
102 var funcName = ( this.state == CKEDITOR.TRISTATE_ON ) ? 'addClass' : 'removeClass';
\r
103 editor.document.getBody()[ funcName ]( 'cke_show_blocks' );
\r
107 CKEDITOR.plugins.add( 'showblocks',
\r
109 requires : [ 'wysiwygarea' ],
\r
111 init : function( editor )
\r
113 var command = editor.addCommand( 'showblocks', commandDefinition );
\r
114 command.canUndo = false;
\r
116 if ( editor.config.startupOutlineBlocks )
\r
117 command.setState( CKEDITOR.TRISTATE_ON );
\r
119 editor.addCss( cssTemplate
\r
120 .replace( cssTemplateRegex, 'background-image: url(' + CKEDITOR.getUrl( this.path ) + 'images/block_' )
\r
121 .replace( cssClassRegex, 'cke_show_blocks ' ) );
\r
123 editor.ui.addButton( 'ShowBlocks',
\r
125 label : editor.lang.showBlocks,
\r
126 command : 'showblocks'
\r
129 // Refresh the command on setData.
\r
130 editor.on( 'mode', function()
\r
132 if ( command.state != CKEDITOR.TRISTATE_DISABLED )
\r
133 command.refresh( editor );
\r
136 // Refresh the command on setData.
\r
137 editor.on( 'contentDom', function()
\r
139 if ( command.state != CKEDITOR.TRISTATE_DISABLED )
\r
140 command.refresh( editor );
\r
147 * Whether to automaticaly enable the "show block" command when the editor
\r
152 * config.startupOutlineBlocks = true;
\r
154 CKEDITOR.config.startupOutlineBlocks = false;
\r