]> git.immae.eu Git - perso/Immae/Projets/packagist/ludivine-ckeditor-component.git/blame - sources/plugins/toolbar/plugin.js
Validation initiale
[perso/Immae/Projets/packagist/ludivine-ckeditor-component.git] / sources / plugins / toolbar / plugin.js
CommitLineData
c63493c8
IB
1/**\r
2 * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.\r
3 * For licensing, see LICENSE.md or http://ckeditor.com/license\r
4 */\r
5\r
6/**\r
7 * @fileOverview The "toolbar" plugin. Renders the default toolbar interface in\r
8 * the editor.\r
9 */\r
10\r
11( function() {\r
12 var toolbox = function() {\r
13 this.toolbars = [];\r
14 this.focusCommandExecuted = false;\r
15 };\r
16\r
17 toolbox.prototype.focus = function() {\r
18 for ( var t = 0, toolbar; toolbar = this.toolbars[ t++ ]; ) {\r
19 for ( var i = 0, item; item = toolbar.items[ i++ ]; ) {\r
20 if ( item.focus ) {\r
21 item.focus();\r
22 return;\r
23 }\r
24 }\r
25 }\r
26 };\r
27\r
28 var commands = {\r
29 toolbarFocus: {\r
30 modes: { wysiwyg: 1, source: 1 },\r
31 readOnly: 1,\r
32\r
33 exec: function( editor ) {\r
34 if ( editor.toolbox ) {\r
35 editor.toolbox.focusCommandExecuted = true;\r
36\r
37 // Make the first button focus accessible for IE. (#3417)\r
38 // Adobe AIR instead need while of delay.\r
39 if ( CKEDITOR.env.ie || CKEDITOR.env.air ) {\r
40 setTimeout( function() {\r
41 editor.toolbox.focus();\r
42 }, 100 );\r
43 } else {\r
44 editor.toolbox.focus();\r
45 }\r
46 }\r
47 }\r
48 }\r
49 };\r
50\r
51 CKEDITOR.plugins.add( 'toolbar', {\r
52 requires: 'button',\r
53 // jscs:disable maximumLineLength\r
54 lang: 'af,ar,az,bg,bn,bs,ca,cs,cy,da,de,de-ch,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,oc,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE%\r
55 // jscs:enable maximumLineLength\r
56\r
57 init: function( editor ) {\r
58 var endFlag;\r
59\r
60 var itemKeystroke = function( item, keystroke ) {\r
61 var next, toolbar;\r
62 var rtl = editor.lang.dir == 'rtl',\r
63 toolbarGroupCycling = editor.config.toolbarGroupCycling,\r
64 // Picking right/left key codes.\r
65 rightKeyCode = rtl ? 37 : 39,\r
66 leftKeyCode = rtl ? 39 : 37;\r
67\r
68 toolbarGroupCycling = toolbarGroupCycling === undefined || toolbarGroupCycling;\r
69\r
70 switch ( keystroke ) {\r
71 case 9: // TAB\r
72 case CKEDITOR.SHIFT + 9: // SHIFT + TAB\r
73 // Cycle through the toolbars, starting from the one\r
74 // closest to the current item.\r
75 while ( !toolbar || !toolbar.items.length ) {\r
76 if ( keystroke == 9 ) {\r
77 toolbar = ( ( toolbar ? toolbar.next : item.toolbar.next ) || editor.toolbox.toolbars[ 0 ] );\r
78 } else {\r
79 toolbar = ( ( toolbar ? toolbar.previous : item.toolbar.previous ) || editor.toolbox.toolbars[ editor.toolbox.toolbars.length - 1 ] );\r
80 }\r
81\r
82 // Look for the first item that accepts focus.\r
83 if ( toolbar.items.length ) {\r
84 item = toolbar.items[ endFlag ? ( toolbar.items.length - 1 ) : 0 ];\r
85 while ( item && !item.focus ) {\r
86 item = endFlag ? item.previous : item.next;\r
87\r
88 if ( !item )\r
89 toolbar = 0;\r
90 }\r
91 }\r
92 }\r
93\r
94 if ( item )\r
95 item.focus();\r
96\r
97 return false;\r
98\r
99 case rightKeyCode:\r
100 next = item;\r
101 do {\r
102 // Look for the next item in the toolbar.\r
103 next = next.next;\r
104\r
105 // If it's the last item, cycle to the first one.\r
106 if ( !next && toolbarGroupCycling ) next = item.toolbar.items[ 0 ];\r
107 }\r
108 while ( next && !next.focus );\r
109\r
110 // If available, just focus it, otherwise focus the\r
111 // first one.\r
112 if ( next )\r
113 next.focus();\r
114 else\r
115 // Send a TAB.\r
116 itemKeystroke( item, 9 );\r
117\r
118 return false;\r
119 case 40: // DOWN-ARROW\r
120 if ( item.button && item.button.hasArrow ) {\r
121 // Note: code is duplicated in plugins\richcombo\plugin.js in keyDownFn().\r
122 editor.once( 'panelShow', function( evt ) {\r
123 evt.data._.panel._.currentBlock.onKeyDown( 40 );\r
124 } );\r
125 item.execute();\r
126 } else {\r
127 // Send left arrow key.\r
128 itemKeystroke( item, keystroke == 40 ? rightKeyCode : leftKeyCode );\r
129 }\r
130 return false;\r
131 case leftKeyCode:\r
132 case 38: // UP-ARROW\r
133 next = item;\r
134 do {\r
135 // Look for the previous item in the toolbar.\r
136 next = next.previous;\r
137\r
138 // If it's the first item, cycle to the last one.\r
139 if ( !next && toolbarGroupCycling ) next = item.toolbar.items[ item.toolbar.items.length - 1 ];\r
140 }\r
141 while ( next && !next.focus );\r
142\r
143 // If available, just focus it, otherwise focus the\r
144 // last one.\r
145 if ( next )\r
146 next.focus();\r
147 else {\r
148 endFlag = 1;\r
149 // Send a SHIFT + TAB.\r
150 itemKeystroke( item, CKEDITOR.SHIFT + 9 );\r
151 endFlag = 0;\r
152 }\r
153\r
154 return false;\r
155\r
156 case 27: // ESC\r
157 editor.focus();\r
158 return false;\r
159\r
160 case 13: // ENTER\r
161 case 32: // SPACE\r
162 item.execute();\r
163 return false;\r
164 }\r
165 return true;\r
166 };\r
167\r
168 editor.on( 'uiSpace', function( event ) {\r
169 if ( event.data.space != editor.config.toolbarLocation )\r
170 return;\r
171\r
172 // Create toolbar only once.\r
173 event.removeListener();\r
174\r
175 editor.toolbox = new toolbox();\r
176\r
177 var labelId = CKEDITOR.tools.getNextId();\r
178\r
179 var output = [\r
180 '<span id="', labelId, '" class="cke_voice_label">', editor.lang.toolbar.toolbars, '</span>',\r
181 '<span id="' + editor.ui.spaceId( 'toolbox' ) + '" class="cke_toolbox" role="group" aria-labelledby="', labelId, '" onmousedown="return false;">'\r
182 ];\r
183\r
184 var expanded = editor.config.toolbarStartupExpanded !== false,\r
185 groupStarted, pendingSeparator;\r
186\r
187 // If the toolbar collapser will be available, we'll have\r
188 // an additional container for all toolbars.\r
189 if ( editor.config.toolbarCanCollapse && editor.elementMode != CKEDITOR.ELEMENT_MODE_INLINE )\r
190 output.push( '<span class="cke_toolbox_main"' + ( expanded ? '>' : ' style="display:none">' ) );\r
191\r
192 var toolbars = editor.toolbox.toolbars,\r
193 toolbar = getToolbarConfig( editor ),\r
194 toolbarLength = toolbar.length;\r
195\r
196 for ( var r = 0; r < toolbarLength; r++ ) {\r
197 var toolbarId,\r
198 toolbarObj = 0,\r
199 toolbarName,\r
200 row = toolbar[ r ],\r
201 lastToolbarInRow = row !== '/' && ( toolbar[ r + 1 ] === '/' || r == toolbarLength - 1 ),\r
202 items;\r
203\r
204 // It's better to check if the row object is really\r
205 // available because it's a common mistake to leave\r
206 // an extra comma in the toolbar definition\r
207 // settings, which leads on the editor not loading\r
208 // at all in IE. (#3983)\r
209 if ( !row )\r
210 continue;\r
211\r
212 if ( groupStarted ) {\r
213 output.push( '</span>' );\r
214 groupStarted = 0;\r
215 pendingSeparator = 0;\r
216 }\r
217\r
218 if ( row === '/' ) {\r
219 output.push( '<span class="cke_toolbar_break"></span>' );\r
220 continue;\r
221 }\r
222\r
223 items = row.items || row;\r
224\r
225 // Create all items defined for this toolbar.\r
226 for ( var i = 0; i < items.length; i++ ) {\r
227 var item = items[ i ],\r
228 canGroup;\r
229\r
230 if ( item ) {\r
231 if ( item.type == CKEDITOR.UI_SEPARATOR ) {\r
232 // Do not add the separator immediately. Just save\r
233 // it be included if we already have something in\r
234 // the toolbar and if a new item is to be added (later).\r
235 pendingSeparator = groupStarted && item;\r
236 continue;\r
237 }\r
238\r
239 canGroup = item.canGroup !== false;\r
240\r
241 // Initialize the toolbar first, if needed.\r
242 if ( !toolbarObj ) {\r
243 // Create the basic toolbar object.\r
244 toolbarId = CKEDITOR.tools.getNextId();\r
245 toolbarObj = { id: toolbarId, items: [] };\r
246 toolbarName = row.name && ( editor.lang.toolbar.toolbarGroups[ row.name ] || row.name );\r
247\r
248 // Output the toolbar opener.\r
249 output.push( '<span id="', toolbarId, '" class="cke_toolbar' + ( lastToolbarInRow ? ' cke_toolbar_last"' : '"' ),\r
250 ( toolbarName ? ' aria-labelledby="' + toolbarId + '_label"' : '' ), ' role="toolbar">' );\r
251\r
252 // If a toolbar name is available, send the voice label.\r
253 toolbarName && output.push( '<span id="', toolbarId, '_label" class="cke_voice_label">', toolbarName, '</span>' );\r
254\r
255 output.push( '<span class="cke_toolbar_start"></span>' );\r
256\r
257 // Add the toolbar to the "editor.toolbox.toolbars"\r
258 // array.\r
259 var index = toolbars.push( toolbarObj ) - 1;\r
260\r
261 // Create the next/previous reference.\r
262 if ( index > 0 ) {\r
263 toolbarObj.previous = toolbars[ index - 1 ];\r
264 toolbarObj.previous.next = toolbarObj;\r
265 }\r
266 }\r
267\r
268 if ( canGroup ) {\r
269 if ( !groupStarted ) {\r
270 output.push( '<span class="cke_toolgroup" role="presentation">' );\r
271 groupStarted = 1;\r
272 }\r
273 } else if ( groupStarted ) {\r
274 output.push( '</span>' );\r
275 groupStarted = 0;\r
276 }\r
277\r
278 function addItem( item ) { // jshint ignore:line\r
279 var itemObj = item.render( editor, output );\r
280 index = toolbarObj.items.push( itemObj ) - 1;\r
281\r
282 if ( index > 0 ) {\r
283 itemObj.previous = toolbarObj.items[ index - 1 ];\r
284 itemObj.previous.next = itemObj;\r
285 }\r
286\r
287 itemObj.toolbar = toolbarObj;\r
288 itemObj.onkey = itemKeystroke;\r
289\r
290 // Fix for #3052:\r
291 // Prevent JAWS from focusing the toolbar after document load.\r
292 itemObj.onfocus = function() {\r
293 if ( !editor.toolbox.focusCommandExecuted )\r
294 editor.focus();\r
295 };\r
296 }\r
297\r
298 if ( pendingSeparator ) {\r
299 addItem( pendingSeparator );\r
300 pendingSeparator = 0;\r
301 }\r
302\r
303 addItem( item );\r
304 }\r
305 }\r
306\r
307 if ( groupStarted ) {\r
308 output.push( '</span>' );\r
309 groupStarted = 0;\r
310 pendingSeparator = 0;\r
311 }\r
312\r
313 if ( toolbarObj )\r
314 output.push( '<span class="cke_toolbar_end"></span></span>' );\r
315 }\r
316\r
317 if ( editor.config.toolbarCanCollapse )\r
318 output.push( '</span>' );\r
319\r
320 // Not toolbar collapser for inline mode.\r
321 if ( editor.config.toolbarCanCollapse && editor.elementMode != CKEDITOR.ELEMENT_MODE_INLINE ) {\r
322 var collapserFn = CKEDITOR.tools.addFunction( function() {\r
323 editor.execCommand( 'toolbarCollapse' );\r
324 } );\r
325\r
326 editor.on( 'destroy', function() {\r
327 CKEDITOR.tools.removeFunction( collapserFn );\r
328 } );\r
329\r
330 editor.addCommand( 'toolbarCollapse', {\r
331 readOnly: 1,\r
332 exec: function( editor ) {\r
333 var collapser = editor.ui.space( 'toolbar_collapser' ),\r
334 toolbox = collapser.getPrevious(),\r
335 contents = editor.ui.space( 'contents' ),\r
336 toolboxContainer = toolbox.getParent(),\r
337 contentHeight = parseInt( contents.$.style.height, 10 ),\r
338 previousHeight = toolboxContainer.$.offsetHeight,\r
339 minClass = 'cke_toolbox_collapser_min',\r
340 collapsed = collapser.hasClass( minClass );\r
341\r
342 if ( !collapsed ) {\r
343 toolbox.hide();\r
344 collapser.addClass( minClass );\r
345 collapser.setAttribute( 'title', editor.lang.toolbar.toolbarExpand );\r
346 } else {\r
347 toolbox.show();\r
348 collapser.removeClass( minClass );\r
349 collapser.setAttribute( 'title', editor.lang.toolbar.toolbarCollapse );\r
350 }\r
351\r
352 // Update collapser symbol.\r
353 collapser.getFirst().setText( collapsed ? '\u25B2' : // BLACK UP-POINTING TRIANGLE\r
354 '\u25C0' ); // BLACK LEFT-POINTING TRIANGLE\r
355\r
356 var dy = toolboxContainer.$.offsetHeight - previousHeight;\r
357 contents.setStyle( 'height', ( contentHeight - dy ) + 'px' );\r
358\r
359 editor.fire( 'resize', {\r
360 outerHeight: editor.container.$.offsetHeight,\r
361 contentsHeight: contents.$.offsetHeight,\r
362 outerWidth: editor.container.$.offsetWidth\r
363 } );\r
364 },\r
365\r
366 modes: { wysiwyg: 1, source: 1 }\r
367 } );\r
368\r
369 editor.setKeystroke( CKEDITOR.ALT + ( CKEDITOR.env.ie || CKEDITOR.env.webkit ? 189 : 109 ) /*-*/, 'toolbarCollapse' );\r
370\r
371 output.push( '<a title="' + ( expanded ? editor.lang.toolbar.toolbarCollapse : editor.lang.toolbar.toolbarExpand ) +\r
372 '" id="' + editor.ui.spaceId( 'toolbar_collapser' ) +\r
373 '" tabIndex="-1" class="cke_toolbox_collapser' );\r
374\r
375 if ( !expanded )\r
376 output.push( ' cke_toolbox_collapser_min' );\r
377\r
378 output.push( '" onclick="CKEDITOR.tools.callFunction(' + collapserFn + ')">', '<span class="cke_arrow">&#9650;</span>', // BLACK UP-POINTING TRIANGLE\r
379 '</a>' );\r
380 }\r
381\r
382 output.push( '</span>' );\r
383 event.data.html += output.join( '' );\r
384 } );\r
385\r
386 editor.on( 'destroy', function() {\r
387 if ( this.toolbox ) {\r
388 var toolbars,\r
389 index = 0,\r
390 i, items, instance;\r
391 toolbars = this.toolbox.toolbars;\r
392 for ( ; index < toolbars.length; index++ ) {\r
393 items = toolbars[ index ].items;\r
394 for ( i = 0; i < items.length; i++ ) {\r
395 instance = items[ i ];\r
396 if ( instance.clickFn )\r
397 CKEDITOR.tools.removeFunction( instance.clickFn );\r
398 if ( instance.keyDownFn )\r
399 CKEDITOR.tools.removeFunction( instance.keyDownFn );\r
400 }\r
401 }\r
402 }\r
403 } );\r
404\r
405 // Manage editor focus when navigating the toolbar.\r
406 editor.on( 'uiReady', function() {\r
407 var toolbox = editor.ui.space( 'toolbox' );\r
408 toolbox && editor.focusManager.add( toolbox, 1 );\r
409 } );\r
410\r
411 editor.addCommand( 'toolbarFocus', commands.toolbarFocus );\r
412 editor.setKeystroke( CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' );\r
413\r
414 editor.ui.add( '-', CKEDITOR.UI_SEPARATOR, {} );\r
415 editor.ui.addHandler( CKEDITOR.UI_SEPARATOR, {\r
416 create: function() {\r
417 return {\r
418 render: function( editor, output ) {\r
419 output.push( '<span class="cke_toolbar_separator" role="separator"></span>' );\r
420 return {};\r
421 }\r
422 };\r
423 }\r
424 } );\r
425 }\r
426 } );\r
427\r
428 function getToolbarConfig( editor ) {\r
429 var removeButtons = editor.config.removeButtons;\r
430\r
431 removeButtons = removeButtons && removeButtons.split( ',' );\r
432\r
433 function buildToolbarConfig() {\r
434\r
435 // Object containing all toolbar groups used by ui items.\r
436 var lookup = getItemDefinedGroups();\r
437\r
438 // Take the base for the new toolbar, which is basically a toolbar\r
439 // definition without items.\r
440 var toolbar = CKEDITOR.tools.clone( editor.config.toolbarGroups ) || getPrivateToolbarGroups( editor );\r
441\r
442 // Fill the toolbar groups with the available ui items.\r
443 for ( var i = 0; i < toolbar.length; i++ ) {\r
444 var toolbarGroup = toolbar[ i ];\r
445\r
446 // Skip toolbar break.\r
447 if ( toolbarGroup == '/' )\r
448 continue;\r
449 // Handle simply group name item.\r
450 else if ( typeof toolbarGroup == 'string' )\r
451 toolbarGroup = toolbar[ i ] = { name: toolbarGroup };\r
452\r
453 var items, subGroups = toolbarGroup.groups;\r
454\r
455 // Look for items that match sub groups.\r
456 if ( subGroups ) {\r
457 for ( var j = 0, sub; j < subGroups.length; j++ ) {\r
458 sub = subGroups[ j ];\r
459\r
460 // If any ui item is registered for this subgroup.\r
461 items = lookup[ sub ];\r
462 items && fillGroup( toolbarGroup, items );\r
463 }\r
464 }\r
465\r
466 // Add the main group items as well.\r
467 items = lookup[ toolbarGroup.name ];\r
468 items && fillGroup( toolbarGroup, items );\r
469 }\r
470\r
471 return toolbar;\r
472 }\r
473\r
474 // Returns an object containing all toolbar groups used by ui items.\r
475 function getItemDefinedGroups() {\r
476 var groups = {},\r
477 itemName, item, itemToolbar, group, order;\r
478\r
479 for ( itemName in editor.ui.items ) {\r
480 item = editor.ui.items[ itemName ];\r
481 itemToolbar = item.toolbar || 'others';\r
482 if ( itemToolbar ) {\r
483 // Break the toolbar property into its parts: "group_name[,order]".\r
484 itemToolbar = itemToolbar.split( ',' );\r
485 group = itemToolbar[ 0 ];\r
486 order = parseInt( itemToolbar[ 1 ] || -1, 10 );\r
487\r
488 // Initialize the group, if necessary.\r
489 groups[ group ] || ( groups[ group ] = [] );\r
490\r
491 // Push the data used to build the toolbar later.\r
492 groups[ group ].push( { name: itemName, order: order } );\r
493 }\r
494 }\r
495\r
496 // Put the items in the right order.\r
497 for ( group in groups ) {\r
498 groups[ group ] = groups[ group ].sort( function( a, b ) {\r
499 return a.order == b.order ? 0 :\r
500 b.order < 0 ? -1 :\r
501 a.order < 0 ? 1 :\r
502 a.order < b.order ? -1 :\r
503 1;\r
504 } );\r
505 }\r
506\r
507 return groups;\r
508 }\r
509\r
510 function fillGroup( toolbarGroup, uiItems ) {\r
511 if ( uiItems.length ) {\r
512 if ( toolbarGroup.items )\r
513 toolbarGroup.items.push( editor.ui.create( '-' ) );\r
514 else\r
515 toolbarGroup.items = [];\r
516\r
517 var item, name;\r
518 while ( ( item = uiItems.shift() ) ) {\r
519 name = typeof item == 'string' ? item : item.name;\r
520\r
521 // Ignore items that are configured to be removed.\r
522 if ( !removeButtons || CKEDITOR.tools.indexOf( removeButtons, name ) == -1 ) {\r
523 item = editor.ui.create( name );\r
524\r
525 if ( !item )\r
526 continue;\r
527\r
528 if ( !editor.addFeature( item ) )\r
529 continue;\r
530\r
531 toolbarGroup.items.push( item );\r
532 }\r
533 }\r
534 }\r
535 }\r
536\r
537 function populateToolbarConfig( config ) {\r
538 var toolbar = [],\r
539 i, group, newGroup;\r
540\r
541 for ( i = 0; i < config.length; ++i ) {\r
542 group = config[ i ];\r
543 newGroup = {};\r
544\r
545 if ( group == '/' )\r
546 toolbar.push( group );\r
547 else if ( CKEDITOR.tools.isArray( group ) ) {\r
548 fillGroup( newGroup, CKEDITOR.tools.clone( group ) );\r
549 toolbar.push( newGroup );\r
550 }\r
551 else if ( group.items ) {\r
552 fillGroup( newGroup, CKEDITOR.tools.clone( group.items ) );\r
553 newGroup.name = group.name;\r
554 toolbar.push( newGroup );\r
555 }\r
556 }\r
557\r
558 return toolbar;\r
559 }\r
560\r
561 var toolbar = editor.config.toolbar;\r
562\r
563 // If it is a string, return the relative "toolbar_name" config.\r
564 if ( typeof toolbar == 'string' )\r
565 toolbar = editor.config[ 'toolbar_' + toolbar ];\r
566\r
567 return ( editor.toolbar = toolbar ? populateToolbarConfig( toolbar ) : buildToolbarConfig() );\r
568 }\r
569\r
570 /**\r
571 * Adds a toolbar group. See {@link CKEDITOR.config#toolbarGroups} for more details.\r
572 *\r
573 * **Note:** This method will not modify toolbar groups set explicitly by\r
574 * {@link CKEDITOR.config#toolbarGroups}. It will only extend the default setting.\r
575 *\r
576 * @param {String} name Toolbar group name.\r
577 * @param {Number/String} previous The name of the toolbar group after which this one\r
578 * should be added or `0` if this group should be the first one.\r
579 * @param {String} [subgroupOf] The name of the parent group.\r
580 * @member CKEDITOR.ui\r
581 */\r
582 CKEDITOR.ui.prototype.addToolbarGroup = function( name, previous, subgroupOf ) {\r
583 // The toolbarGroups from the privates is the one we gonna use for automatic toolbar creation.\r
584 var toolbarGroups = getPrivateToolbarGroups( this.editor ),\r
585 atStart = previous === 0,\r
586 newGroup = { name: name };\r
587\r
588 if ( subgroupOf ) {\r
589 // Transform the subgroupOf name in the real subgroup object.\r
590 subgroupOf = CKEDITOR.tools.search( toolbarGroups, function( group ) {\r
591 return group.name == subgroupOf;\r
592 } );\r
593\r
594 if ( subgroupOf ) {\r
595 !subgroupOf.groups && ( subgroupOf.groups = [] ) ;\r
596\r
597 if ( previous ) {\r
598 // Search the "previous" item and add the new one after it.\r
599 previous = CKEDITOR.tools.indexOf( subgroupOf.groups, previous );\r
600 if ( previous >= 0 ) {\r
601 subgroupOf.groups.splice( previous + 1, 0, name );\r
602 return;\r
603 }\r
604 }\r
605\r
606 // If no previous found.\r
607\r
608 if ( atStart )\r
609 subgroupOf.groups.splice( 0, 0, name );\r
610 else\r
611 subgroupOf.groups.push( name );\r
612 return;\r
613 } else {\r
614 // Ignore "previous" if subgroupOf has not been found.\r
615 previous = null;\r
616 }\r
617 }\r
618\r
619 if ( previous ) {\r
620 // Transform the "previous" name into its index.\r
621 previous = CKEDITOR.tools.indexOf( toolbarGroups, function( group ) {\r
622 return group.name == previous;\r
623 } );\r
624 }\r
625\r
626 if ( atStart )\r
627 toolbarGroups.splice( 0, 0, name );\r
628 else if ( typeof previous == 'number' )\r
629 toolbarGroups.splice( previous + 1, 0, newGroup );\r
630 else\r
631 toolbarGroups.push( name );\r
632 };\r
633\r
634 function getPrivateToolbarGroups( editor ) {\r
635 return editor._.toolbarGroups || ( editor._.toolbarGroups = [\r
636 { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },\r
637 { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },\r
638 { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },\r
639 { name: 'forms' },\r
640 '/',\r
641 { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },\r
642 { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },\r
643 { name: 'links' },\r
644 { name: 'insert' },\r
645 '/',\r
646 { name: 'styles' },\r
647 { name: 'colors' },\r
648 { name: 'tools' },\r
649 { name: 'others' },\r
650 { name: 'about' }\r
651 ] );\r
652 }\r
653} )();\r
654\r
655/**\r
656 * Separator UI element.\r
657 *\r
658 * @readonly\r
659 * @property {String} [='separator']\r
660 * @member CKEDITOR\r
661 */\r
662CKEDITOR.UI_SEPARATOR = 'separator';\r
663\r
664/**\r
665 * The part of the user interface where the toolbar will be rendered. For the default\r
666 * editor implementation, the recommended options are `'top'` and `'bottom'`.\r
667 *\r
668 * Please note that this option is only applicable to [classic](#!/guide/dev_framed)\r
669 * (`iframe`-based) editor. In case of [inline](#!/guide/dev_inline) editor the toolbar\r
670 * position is set dynamically depending on the position of the editable element on the screen.\r
671 *\r
672 * Read more in the [documentation](#!/guide/dev_toolbarlocation)\r
673 * and see the [SDK sample](http://sdk.ckeditor.com/samples/toolbarlocation.html).\r
674 *\r
675 * config.toolbarLocation = 'bottom';\r
676 *\r
677 * @cfg\r
678 * @member CKEDITOR.config\r
679 */\r
680CKEDITOR.config.toolbarLocation = 'top';\r
681\r
682/**\r
683 * The toolbox (alias toolbar) definition. It is a toolbar name or an array of\r
684 * toolbars (strips), each one being also an array, containing a list of UI items.\r
685 *\r
686 * If set to `null`, the toolbar will be generated automatically using all available buttons\r
687 * and {@link #toolbarGroups} as a toolbar groups layout.\r
688 *\r
689 * In CKEditor 4.5+ you can generate your toolbar customization code by using the [visual\r
690 * toolbar configurator](http://docs.ckeditor.com/#!/guide/dev_toolbar).\r
691 *\r
692 * // Defines a toolbar with only one strip containing the "Source" button, a\r
693 * // separator, and the "Bold" and "Italic" buttons.\r
694 * config.toolbar = [\r
695 * [ 'Source', '-', 'Bold', 'Italic' ]\r
696 * ];\r
697 *\r
698 * // Similar to the example above, defines a "Basic" toolbar with only one strip containing three buttons.\r
699 * // Note that this setting is composed by "toolbar_" added to the toolbar name, which in this case is called "Basic".\r
700 * // This second part of the setting name can be anything. You must use this name in the CKEDITOR.config.toolbar setting\r
701 * // in order to instruct the editor which `toolbar_(name)` setting should be used.\r
702 * config.toolbar_Basic = [\r
703 * [ 'Source', '-', 'Bold', 'Italic' ]\r
704 * ];\r
705 * // Load toolbar_Name where Name = Basic.\r
706 * config.toolbar = 'Basic';\r
707 *\r
708 * @cfg {Array/String} [toolbar=null]\r
709 * @member CKEDITOR.config\r
710 */\r
711\r
712/**\r
713 * The toolbar groups definition.\r
714 *\r
715 * If the toolbar layout is not explicitly defined by the {@link #toolbar} setting, then\r
716 * this setting is used to group all defined buttons (see {@link CKEDITOR.ui#addButton}).\r
717 * Buttons are associated with toolbar groups by the `toolbar` property in their definition objects.\r
718 *\r
719 * New groups may be dynamically added during the editor and plugin initialization by\r
720 * {@link CKEDITOR.ui#addToolbarGroup}. This is only possible if the default setting was used.\r
721 *\r
722 * // Default setting.\r
723 * config.toolbarGroups = [\r
724 * { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },\r
725 * { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },\r
726 * { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },\r
727 * { name: 'forms' },\r
728 * '/',\r
729 * { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },\r
730 * { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },\r
731 * { name: 'links' },\r
732 * { name: 'insert' },\r
733 * '/',\r
734 * { name: 'styles' },\r
735 * { name: 'colors' },\r
736 * { name: 'tools' },\r
737 * { name: 'others' },\r
738 * { name: 'about' }\r
739 * ];\r
740 *\r
741 * @cfg {Array} [toolbarGroups=see example]\r
742 * @member CKEDITOR.config\r
743 */\r
744\r
745/**\r
746 * Whether the toolbar can be collapsed by the user. If disabled, the Collapse Toolbar\r
747 * button will not be displayed.\r
748 *\r
749 * config.toolbarCanCollapse = true;\r
750 *\r
751 * @cfg {Boolean} [toolbarCanCollapse=false]\r
752 * @member CKEDITOR.config\r
753 */\r
754\r
755/**\r
756 * Whether the toolbar must start expanded when the editor is loaded.\r
757 *\r
758 * Setting this option to `false` will affect the toolbar only when\r
759 * {@link #toolbarCanCollapse} is set to `true`:\r
760 *\r
761 * config.toolbarCanCollapse = true;\r
762 * config.toolbarStartupExpanded = false;\r
763 *\r
764 * @cfg {Boolean} [toolbarStartupExpanded=true]\r
765 * @member CKEDITOR.config\r
766 */\r
767\r
768/**\r
769 * When enabled, causes the *Arrow* keys navigation to cycle within the current\r
770 * toolbar group. Otherwise the *Arrow* keys will move through all items available in\r
771 * the toolbar. The *Tab* key will still be used to quickly jump among the\r
772 * toolbar groups.\r
773 *\r
774 * config.toolbarGroupCycling = false;\r
775 *\r
776 * @since 3.6\r
777 * @cfg {Boolean} [toolbarGroupCycling=true]\r
778 * @member CKEDITOR.config\r
779 */\r
780\r
781/**\r
782 * List of toolbar button names that must not be rendered. This will also work\r
783 * for non-button toolbar items, like the Font drop-down list.\r
784 *\r
785 * config.removeButtons = 'Underline,JustifyCenter';\r
786 *\r
787 * This configuration option should not be overused. The recommended way is to use the\r
788 * {@link CKEDITOR.config#removePlugins} setting to remove features from the editor\r
789 * or even better, [create a custom editor build](http://ckeditor.com/builder) with\r
790 * just the features that you will use.\r
791 * In some cases though, a single plugin may define a set of toolbar buttons and\r
792 * `removeButtons` may be useful when just a few of them are to be removed.\r
793 *\r
794 * @cfg {String} [removeButtons]\r
795 * @member CKEDITOR.config\r
796 */\r
797\r
798/**\r
799 * The toolbar definition used by the editor. It is created from the\r
800 * {@link CKEDITOR.config#toolbar} option if it is set or automatically\r
801 * based on {@link CKEDITOR.config#toolbarGroups}.\r
802 *\r
803 * @readonly\r
804 * @property {Object} toolbar\r
805 * @member CKEDITOR.editor\r
806 */\r