2 Copyright (c) 2003-2011, 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 'background-position: top %3;'+
\r
28 'border: 1px dotted gray;'+
\r
29 'padding-top: 8px;'+
\r
55 '%1blockquote.png);'+
\r
88 var cssTemplateRegex = /%1/g, cssClassRegex = /%2/g, backgroundPositionRegex = /%3/g;
\r
90 var commandDefinition =
\r
93 preserveState : true,
\r
94 editorFocus : false,
\r
96 exec : function ( editor )
\r
99 this.refresh( editor );
\r
102 refresh : function( editor )
\r
104 if ( editor.document )
\r
106 var funcName = ( this.state == CKEDITOR.TRISTATE_ON ) ? 'addClass' : 'removeClass';
\r
107 editor.document.getBody()[ funcName ]( 'cke_show_blocks' );
\r
112 CKEDITOR.plugins.add( 'showblocks',
\r
114 requires : [ 'wysiwygarea' ],
\r
116 init : function( editor )
\r
118 var command = editor.addCommand( 'showblocks', commandDefinition );
\r
119 command.canUndo = false;
\r
121 if ( editor.config.startupOutlineBlocks )
\r
122 command.setState( CKEDITOR.TRISTATE_ON );
\r
124 editor.addCss( cssTemplate
\r
125 .replace( cssTemplateRegex, 'background-image: url(' + CKEDITOR.getUrl( this.path ) + 'images/block_' )
\r
126 .replace( cssClassRegex, 'cke_show_blocks ' )
\r
127 .replace( backgroundPositionRegex, editor.lang.dir == 'rtl' ? 'right' : 'left' ) );
\r
129 editor.ui.addButton( 'ShowBlocks',
\r
131 label : editor.lang.showBlocks,
\r
132 command : 'showblocks'
\r
135 // Refresh the command on setData.
\r
136 editor.on( 'mode', function()
\r
138 if ( command.state != CKEDITOR.TRISTATE_DISABLED )
\r
139 command.refresh( editor );
\r
142 // Refresh the command on setData.
\r
143 editor.on( 'contentDom', function()
\r
145 if ( command.state != CKEDITOR.TRISTATE_DISABLED )
\r
146 command.refresh( editor );
\r
153 * Whether to automaticaly enable the "show block" command when the editor
\r
154 * loads. (StartupShowBlocks in FCKeditor)
\r
155 * @name CKEDITOR.config.startupOutlineBlocks
\r
159 * config.startupOutlineBlocks = true;
\r