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
92 preserveState : true,
\r
93 editorFocus : false,
\r
95 exec : function ( editor )
\r
98 this.refresh( editor );
\r
101 refresh : function( editor )
\r
103 var funcName = ( this.state == CKEDITOR.TRISTATE_ON ) ? 'addClass' : 'removeClass';
\r
104 editor.document.getBody()[ funcName ]( 'cke_show_blocks' );
\r
108 CKEDITOR.plugins.add( 'showblocks',
\r
110 requires : [ 'wysiwygarea' ],
\r
112 init : function( editor )
\r
114 var command = editor.addCommand( 'showblocks', commandDefinition );
\r
115 command.canUndo = false;
\r
117 if ( editor.config.startupOutlineBlocks )
\r
118 command.setState( CKEDITOR.TRISTATE_ON );
\r
120 editor.addCss( cssTemplate
\r
121 .replace( cssTemplateRegex, 'background-image: url(' + CKEDITOR.getUrl( this.path ) + 'images/block_' )
\r
122 .replace( cssClassRegex, 'cke_show_blocks ' )
\r
123 .replace( backgroundPositionRegex, editor.lang.dir == 'rtl' ? 'right' : 'left' ) );
\r
125 editor.ui.addButton( 'ShowBlocks',
\r
127 label : editor.lang.showBlocks,
\r
128 command : 'showblocks'
\r
131 // Refresh the command on setData.
\r
132 editor.on( 'mode', function()
\r
134 if ( command.state != CKEDITOR.TRISTATE_DISABLED )
\r
135 command.refresh( editor );
\r
138 // Refresh the command on setData.
\r
139 editor.on( 'contentDom', function()
\r
141 if ( command.state != CKEDITOR.TRISTATE_DISABLED )
\r
142 command.refresh( editor );
\r
149 * Whether to automaticaly enable the "show block" command when the editor
\r
150 * loads. (StartupShowBlocks in FCKeditor)
\r
151 * @name CKEDITOR.config.startupOutlineBlocks
\r
155 * config.startupOutlineBlocks = true;
\r