@@ -95,6 +95,8 @@ <h2 class="samples">Full toolbar configuration</h2>
95
95
( function ( ) {
96
96
'use strict' ;
97
97
98
+ var buttonsNames ;
99
+
98
100
CKEDITOR . config . extraPlugins = 'toolbar' ;
99
101
100
102
CKEDITOR . on ( 'instanceReady' , function ( evt ) {
@@ -112,6 +114,9 @@ <h2 class="samples">Full toolbar configuration</h2>
112
114
return ;
113
115
}
114
116
117
+ if ( ! buttonsNames )
118
+ buttonsNames = createButtonsNamesHash ( editor . ui . items ) ;
119
+
115
120
// Toolbar isn't set explicitly, so it was created automatically from toolbarGroups.
116
121
if ( ! editor . config . toolbar ) {
117
122
output +=
@@ -132,7 +137,6 @@ <h2 class="samples">Full toolbar configuration</h2>
132
137
CKEDITOR . dom . element . createFromHtml ( preOutput ) . replace ( pre ) ;
133
138
} ) ;
134
139
135
-
136
140
CKEDITOR . replace ( 'editorCurrent' , { height : 100 } ) ;
137
141
CKEDITOR . replace ( 'editorFull' , {
138
142
// Reset toolbar settings, so full toolbar will be generated automatically.
@@ -180,7 +184,35 @@ <h2 class="samples">Full toolbar configuration</h2>
180
184
function dumpToolbarItems ( items ) {
181
185
if ( typeof items == 'string' )
182
186
return '\'' + items + '\'' ;
183
- return '[ \'' + items . join ( '\', \'' ) + '\' ]' ;
187
+
188
+ var names = [ ] ,
189
+ i , item ;
190
+
191
+ for ( var i = 0 ; i < items . length ; ++ i ) {
192
+ item = items [ i ] ;
193
+ if ( typeof item == 'string' )
194
+ names . push ( item ) ;
195
+ else {
196
+ if ( item . type == CKEDITOR . UI_SEPARATOR )
197
+ names . push ( '-' ) ;
198
+ else
199
+ names . push ( buttonsNames [ item . name ] ) ;
200
+ }
201
+ }
202
+
203
+ return '[ \'' + names . join ( '\', \'' ) + '\' ]' ;
204
+ }
205
+
206
+ // Creates { 'lowercased': 'LowerCased' } buttons names hash.
207
+ function createButtonsNamesHash ( items ) {
208
+ var hash = { } ,
209
+ name ;
210
+
211
+ for ( name in items ) {
212
+ hash [ items [ name ] . name ] = name ;
213
+ }
214
+
215
+ return hash ;
184
216
}
185
217
186
218
} ) ( ) ;
0 commit comments