-<!DOCTYPE html>\r
-<!--\r
-Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.md or http://ckeditor.com/license\r
--->\r
-<html>\r
-<head>\r
- <meta charset="utf-8">\r
- <title>Toolbar Configuration — CKEditor Sample</title>\r
- <meta name="ckeditor-sample-name" content="Toolbar Configurations">\r
- <meta name="ckeditor-sample-group" content="Advanced Samples">\r
- <meta name="ckeditor-sample-description" content="Configuring CKEditor to display full or custom toolbar layout.">\r
- <script src="../../../ckeditor.js"></script>\r
- <link href="../../../samples/old/sample.css" rel="stylesheet">\r
-</head>\r
-<body>\r
- <h1 class="samples">\r
- <a href="../../../samples/old/index.html">CKEditor Samples</a> » Toolbar Configuration\r
- </h1>\r
- <div class="warning deprecated">\r
- This sample is not maintained anymore. Check out the <a href="../../../samples/toolbarconfigurator/index.html#basic">brand new CKEditor Toolbar Configurator</a>.\r
- </div>\r
- <div class="description">\r
- <p>\r
- This sample page demonstrates editor with loaded <a href="#fullToolbar">full toolbar</a> (all registered buttons) and, if\r
- current editor's configuration modifies default settings, also editor with <a href="#currentToolbar">modified toolbar</a>.\r
- </p>\r
-\r
- <p>Since CKEditor 4 there are two ways to configure toolbar buttons.</p>\r
-\r
- <h2 class="samples">By <a href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-toolbar">config.toolbar</a></h2>\r
-\r
- <p>\r
- You can explicitly define which buttons are displayed in which groups and in which order.\r
- This is the more precise setting, but less flexible. If newly added plugin adds its\r
- own button you'll have to add it manually to your <code>config.toolbar</code> setting as well.\r
- </p>\r
-\r
- <p>To add a CKEditor instance with custom toolbar setting, insert the following JavaScript call to your code:</p>\r
-\r
- <pre class="samples">\r
-CKEDITOR.replace( <em>'textarea_id'</em>, {\r
- <strong>toolbar:</strong> [\r
- { name: 'document', items: [ 'Source', '-', 'NewPage', 'Preview', '-', 'Templates' ] }, // Defines toolbar group with name (used to create voice label) and items in 3 subgroups.\r
- [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ], // Defines toolbar group without name.\r
- '/', // Line break - next group will be placed in new line.\r
- { name: 'basicstyles', items: [ 'Bold', 'Italic' ] }\r
- ]\r
-});</pre>\r
-\r
- <h2 class="samples">By <a href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-toolbarGroups">config.toolbarGroups</a></h2>\r
-\r
- <p>\r
- You can define which groups of buttons (like e.g. <code>basicstyles</code>, <code>clipboard</code>\r
- and <code>forms</code>) are displayed and in which order. Registered buttons are associated\r
- with toolbar groups by <code>toolbar</code> property in their definition.\r
- This setting's advantage is that you don't have to modify toolbar configuration\r
- when adding/removing plugins which register their own buttons.\r
- </p>\r
-\r
- <p>To add a CKEditor instance with custom toolbar groups setting, insert the following JavaScript call to your code:</p>\r
-\r
- <pre class="samples">\r
-CKEDITOR.replace( <em>'textarea_id'</em>, {\r
- <strong>toolbarGroups:</strong> [\r
- { name: 'document', groups: [ 'mode', 'document' ] }, // Displays document group with its two subgroups.\r
- { name: 'clipboard', groups: [ 'clipboard', 'undo' ] }, // Group's name will be used to create voice label.\r
- '/', // Line break - next group will be placed in new line.\r
- { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },\r
- { name: 'links' }\r
- ]\r
-\r
- // NOTE: Remember to leave 'toolbar' property with the default value (null).\r
-});</pre>\r
- </div>\r
-\r
- <div id="currentToolbar" style="display: none">\r
- <h2 class="samples">Current toolbar configuration</h2>\r
- <p>Below you can see editor with current toolbar definition.</p>\r
- <textarea cols="80" id="editorCurrent" name="editorCurrent" rows="10"><p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p></textarea>\r
- <pre id="editorCurrentCfg" class="samples"></pre>\r
- </div>\r
-\r
- <div id="fullToolbar">\r
- <h2 class="samples">Full toolbar configuration</h2>\r
- <p>Below you can see editor with full toolbar, generated automatically by the editor.</p>\r
- <p>\r
- <strong>Note</strong>: To create editor instance with full toolbar you don't have to set anything.\r
- Just leave <code>toolbar</code> and <code>toolbarGroups</code> with the default, <code>null</code> values.\r
- </p>\r
- <textarea cols="80" id="editorFull" name="editorFull" rows="10"><p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p></textarea>\r
- <pre id="editorFullCfg" class="samples"></pre>\r
- </div>\r
-\r
- <script>\r
-\r
-(function() {\r
- 'use strict';\r
-\r
- var buttonsNames;\r
-\r
- CKEDITOR.config.extraPlugins = 'toolbar';\r
-\r
- CKEDITOR.on( 'instanceReady', function( evt ) {\r
- var editor = evt.editor,\r
- editorCurrent = editor.name == 'editorCurrent',\r
- defaultToolbar = !( editor.config.toolbar || editor.config.toolbarGroups || editor.config.removeButtons ),\r
- pre = CKEDITOR.document.getById( editor.name + 'Cfg' ),\r
- output = '';\r
-\r
- if ( editorCurrent ) {\r
- // If default toolbar configuration has been modified, show "current toolbar" section.\r
- if ( !defaultToolbar )\r
- CKEDITOR.document.getById( 'currentToolbar' ).show();\r
- else\r
- return;\r
- }\r
-\r
- if ( !buttonsNames )\r
- buttonsNames = createButtonsNamesHash( editor.ui.items );\r
-\r
- // Toolbar isn't set explicitly, so it was created automatically from toolbarGroups.\r
- if ( !editor.config.toolbar ) {\r
- output +=\r
- '// Toolbar configuration generated automatically by the editor based on config.toolbarGroups.\n' +\r
- dumpToolbarConfiguration( editor ) +\r
- '\n\n' +\r
- '// Toolbar groups configuration.\n' +\r
- dumpToolbarConfiguration( editor, true )\r
- }\r
- // Toolbar groups doesn't count in this case - print only toolbar.\r
- else {\r
- output += '// Toolbar configuration.\n' +\r
- dumpToolbarConfiguration( editor );\r
- }\r
-\r
- // Recreate to avoid old IE from loosing whitespaces on filling <pre> content.\r
- var preOutput = pre.getOuterHtml().replace( /(?=<\/)/, output );\r
- CKEDITOR.dom.element.createFromHtml( preOutput ).replace( pre );\r
- } );\r
-\r
- CKEDITOR.replace( 'editorCurrent', { height: 100 } );\r
- CKEDITOR.replace( 'editorFull', {\r
- // Reset toolbar settings, so full toolbar will be generated automatically.\r
- toolbar: null,\r
- toolbarGroups: null,\r
- removeButtons: null,\r
- height: 100\r
- } );\r
-\r
- function dumpToolbarConfiguration( editor, printGroups ) {\r
- var output = [],\r
- toolbar = editor.toolbar;\r
-\r
- for ( var i = 0; i < toolbar.length; ++i ) {\r
- var group = dumpToolbarGroup( toolbar[ i ], printGroups );\r
- if ( group )\r
- output.push( group );\r
- }\r
-\r
- return 'config.toolbar' + ( printGroups ? 'Groups' : '' ) + ' = [\n\t' + output.join( ',\n\t' ) + '\n];';\r
- }\r
-\r
- function dumpToolbarGroup( group, printGroups ) {\r
- var output = [];\r
-\r
- if ( typeof group == 'string' )\r
- return '\'' + group + '\'';\r
- if ( CKEDITOR.tools.isArray( group ) )\r
- return dumpToolbarItems( group );\r
- // Skip group when printing entire toolbar configuration and there are no items in this group.\r
- if ( !printGroups && !group.items )\r
- return;\r
-\r
- if ( group.name )\r
- output.push( 'name: \'' + group.name + '\'' );\r
-\r
- if ( group.groups )\r
- output.push( 'groups: ' + dumpToolbarItems( group.groups ) );\r
-\r
- if ( !printGroups )\r
- output.push( 'items: ' + dumpToolbarItems( group.items ) );\r
-\r
- return '{ ' + output.join( ', ' ) + ' }';\r
- }\r
-\r
- function dumpToolbarItems( items ) {\r
- if ( typeof items == 'string' )\r
- return '\'' + items + '\'';\r
-\r
- var names = [],\r
- i, item;\r
-\r
- for ( var i = 0; i < items.length; ++i ) {\r
- item = items[ i ];\r
- if ( typeof item == 'string' )\r
- names.push( item );\r
- else {\r
- if ( item.type == CKEDITOR.UI_SEPARATOR )\r
- names.push( '-' );\r
- else\r
- names.push( buttonsNames[ item.name ] );\r
- }\r
- }\r
-\r
- return '[ \'' + names.join( '\', \'' ) + '\' ]';\r
- }\r
-\r
- // Creates { 'lowercased': 'LowerCased' } buttons names hash.\r
- function createButtonsNamesHash( items ) {\r
- var hash = {},\r
- name;\r
-\r
- for ( name in items ) {\r
- hash[ items[ name ].name ] = name;\r
- }\r
-\r
- return hash;\r
- }\r
-\r
-})();\r
- </script>\r
-\r
- <div id="footer">\r
- <hr>\r
- <p>\r
- CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>\r
- </p>\r
- <p id="copy">\r
- Copyright © 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico\r
- Knabben. All rights reserved.\r
- </p>\r
- </div>\r
-</body>\r
-</html>\r
+<!DOCTYPE html>
+<!--
+Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.md or http://ckeditor.com/license
+-->
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Toolbar Configuration — CKEditor Sample</title>
+ <meta name="ckeditor-sample-name" content="Toolbar Configurations">
+ <meta name="ckeditor-sample-group" content="Advanced Samples">
+ <meta name="ckeditor-sample-description" content="Configuring CKEditor to display full or custom toolbar layout.">
+ <script src="../../../ckeditor.js"></script>
+ <link href="../../../samples/old/sample.css" rel="stylesheet">
+</head>
+<body>
+ <h1 class="samples">
+ <a href="../../../samples/old/index.html">CKEditor Samples</a> » Toolbar Configuration
+ </h1>
+ <div class="warning deprecated">
+ This sample is not maintained anymore. Check out the <a href="../../../samples/toolbarconfigurator/index.html#basic">brand new CKEditor Toolbar Configurator</a>.
+ </div>
+ <div class="description">
+ <p>
+ This sample page demonstrates editor with loaded <a href="#fullToolbar">full toolbar</a> (all registered buttons) and, if
+ current editor's configuration modifies default settings, also editor with <a href="#currentToolbar">modified toolbar</a>.
+ </p>
+
+ <p>Since CKEditor 4 there are two ways to configure toolbar buttons.</p>
+
+ <h2 class="samples">By <a href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-toolbar">config.toolbar</a></h2>
+
+ <p>
+ You can explicitly define which buttons are displayed in which groups and in which order.
+ This is the more precise setting, but less flexible. If newly added plugin adds its
+ own button you'll have to add it manually to your <code>config.toolbar</code> setting as well.
+ </p>
+
+ <p>To add a CKEditor instance with custom toolbar setting, insert the following JavaScript call to your code:</p>
+
+ <pre class="samples">
+CKEDITOR.replace( <em>'textarea_id'</em>, {
+ <strong>toolbar:</strong> [
+ { name: 'document', items: [ 'Source', '-', 'NewPage', 'Preview', '-', 'Templates' ] }, // Defines toolbar group with name (used to create voice label) and items in 3 subgroups.
+ [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ], // Defines toolbar group without name.
+ '/', // Line break - next group will be placed in new line.
+ { name: 'basicstyles', items: [ 'Bold', 'Italic' ] }
+ ]
+});</pre>
+
+ <h2 class="samples">By <a href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-toolbarGroups">config.toolbarGroups</a></h2>
+
+ <p>
+ You can define which groups of buttons (like e.g. <code>basicstyles</code>, <code>clipboard</code>
+ and <code>forms</code>) are displayed and in which order. Registered buttons are associated
+ with toolbar groups by <code>toolbar</code> property in their definition.
+ This setting's advantage is that you don't have to modify toolbar configuration
+ when adding/removing plugins which register their own buttons.
+ </p>
+
+ <p>To add a CKEditor instance with custom toolbar groups setting, insert the following JavaScript call to your code:</p>
+
+ <pre class="samples">
+CKEDITOR.replace( <em>'textarea_id'</em>, {
+ <strong>toolbarGroups:</strong> [
+ { name: 'document', groups: [ 'mode', 'document' ] }, // Displays document group with its two subgroups.
+ { name: 'clipboard', groups: [ 'clipboard', 'undo' ] }, // Group's name will be used to create voice label.
+ '/', // Line break - next group will be placed in new line.
+ { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
+ { name: 'links' }
+ ]
+
+ // NOTE: Remember to leave 'toolbar' property with the default value (null).
+});</pre>
+ </div>
+
+ <div id="currentToolbar" style="display: none">
+ <h2 class="samples">Current toolbar configuration</h2>
+ <p>Below you can see editor with current toolbar definition.</p>
+ <textarea cols="80" id="editorCurrent" name="editorCurrent" rows="10"><p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p></textarea>
+ <pre id="editorCurrentCfg" class="samples"></pre>
+ </div>
+
+ <div id="fullToolbar">
+ <h2 class="samples">Full toolbar configuration</h2>
+ <p>Below you can see editor with full toolbar, generated automatically by the editor.</p>
+ <p>
+ <strong>Note</strong>: To create editor instance with full toolbar you don't have to set anything.
+ Just leave <code>toolbar</code> and <code>toolbarGroups</code> with the default, <code>null</code> values.
+ </p>
+ <textarea cols="80" id="editorFull" name="editorFull" rows="10"><p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p></textarea>
+ <pre id="editorFullCfg" class="samples"></pre>
+ </div>
+
+ <script>
+
+(function() {
+ 'use strict';
+
+ var buttonsNames;
+
+ CKEDITOR.config.extraPlugins = 'toolbar';
+
+ CKEDITOR.on( 'instanceReady', function( evt ) {
+ var editor = evt.editor,
+ editorCurrent = editor.name == 'editorCurrent',
+ defaultToolbar = !( editor.config.toolbar || editor.config.toolbarGroups || editor.config.removeButtons ),
+ pre = CKEDITOR.document.getById( editor.name + 'Cfg' ),
+ output = '';
+
+ if ( editorCurrent ) {
+ // If default toolbar configuration has been modified, show "current toolbar" section.
+ if ( !defaultToolbar )
+ CKEDITOR.document.getById( 'currentToolbar' ).show();
+ else
+ return;
+ }
+
+ if ( !buttonsNames )
+ buttonsNames = createButtonsNamesHash( editor.ui.items );
+
+ // Toolbar isn't set explicitly, so it was created automatically from toolbarGroups.
+ if ( !editor.config.toolbar ) {
+ output +=
+ '// Toolbar configuration generated automatically by the editor based on config.toolbarGroups.\n' +
+ dumpToolbarConfiguration( editor ) +
+ '\n\n' +
+ '// Toolbar groups configuration.\n' +
+ dumpToolbarConfiguration( editor, true )
+ }
+ // Toolbar groups doesn't count in this case - print only toolbar.
+ else {
+ output += '// Toolbar configuration.\n' +
+ dumpToolbarConfiguration( editor );
+ }
+
+ // Recreate to avoid old IE from loosing whitespaces on filling <pre> content.
+ var preOutput = pre.getOuterHtml().replace( /(?=<\/)/, output );
+ CKEDITOR.dom.element.createFromHtml( preOutput ).replace( pre );
+ } );
+
+ CKEDITOR.replace( 'editorCurrent', { height: 100 } );
+ CKEDITOR.replace( 'editorFull', {
+ // Reset toolbar settings, so full toolbar will be generated automatically.
+ toolbar: null,
+ toolbarGroups: null,
+ removeButtons: null,
+ height: 100
+ } );
+
+ function dumpToolbarConfiguration( editor, printGroups ) {
+ var output = [],
+ toolbar = editor.toolbar;
+
+ for ( var i = 0; i < toolbar.length; ++i ) {
+ var group = dumpToolbarGroup( toolbar[ i ], printGroups );
+ if ( group )
+ output.push( group );
+ }
+
+ return 'config.toolbar' + ( printGroups ? 'Groups' : '' ) + ' = [\n\t' + output.join( ',\n\t' ) + '\n];';
+ }
+
+ function dumpToolbarGroup( group, printGroups ) {
+ var output = [];
+
+ if ( typeof group == 'string' )
+ return '\'' + group + '\'';
+ if ( CKEDITOR.tools.isArray( group ) )
+ return dumpToolbarItems( group );
+ // Skip group when printing entire toolbar configuration and there are no items in this group.
+ if ( !printGroups && !group.items )
+ return;
+
+ if ( group.name )
+ output.push( 'name: \'' + group.name + '\'' );
+
+ if ( group.groups )
+ output.push( 'groups: ' + dumpToolbarItems( group.groups ) );
+
+ if ( !printGroups )
+ output.push( 'items: ' + dumpToolbarItems( group.items ) );
+
+ return '{ ' + output.join( ', ' ) + ' }';
+ }
+
+ function dumpToolbarItems( items ) {
+ if ( typeof items == 'string' )
+ return '\'' + items + '\'';
+
+ var names = [],
+ i, item;
+
+ for ( var i = 0; i < items.length; ++i ) {
+ item = items[ i ];
+ if ( typeof item == 'string' )
+ names.push( item );
+ else {
+ if ( item.type == CKEDITOR.UI_SEPARATOR )
+ names.push( '-' );
+ else
+ names.push( buttonsNames[ item.name ] );
+ }
+ }
+
+ return '[ \'' + names.join( '\', \'' ) + '\' ]';
+ }
+
+ // Creates { 'lowercased': 'LowerCased' } buttons names hash.
+ function createButtonsNamesHash( items ) {
+ var hash = {},
+ name;
+
+ for ( name in items ) {
+ hash[ items[ name ].name ] = name;
+ }
+
+ return hash;
+ }
+
+})();
+ </script>
+
+ <div id="footer">
+ <hr>
+ <p>
+ CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
+ </p>
+ <p id="copy">
+ Copyright © 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
+ Knabben. All rights reserved.
+ </p>
+ </div>
+</body>
+</html>