Ticket #4973: 4973_2.patch
File 4973_2.patch, 7.8 KB (added by , 13 years ago) |
---|
-
_source/plugins/stylescombo/plugin.js
32 32 33 33 init : function() 34 34 { 35 var combo = this, 36 stylesSet = config.stylesCombo_stylesSet.split( ':' ); 35 var combo = this; 37 36 38 var stylesSetPath = stylesSet[ 1 ] ? 39 stylesSet.slice( 1 ).join( ':' ) : // #4481 40 CKEDITOR.getUrl( pluginPath + 'styles/' + stylesSet[ 0 ] + '.js' ) ; 41 42 stylesSet = stylesSet[ 0 ]; 43 44 CKEDITOR.loadStylesSet( stylesSet, stylesSetPath, function( stylesDefinitions ) 37 CKEDITOR.stylesSet.load( styleSetName, function( stylesSet ) 45 38 { 46 var style, 39 var stylesDefinitions = stylesSet[ styleSetName ], 40 style, 47 41 styleName, 48 42 stylesList = []; 49 43 … … 204 198 this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_OBJECT ) ] ); 205 199 } 206 200 }); 207 }208 });209 201 210 var stylesSets = {}; 202 var stylesSet = config.stylesCombo_stylesSet.split( ':' ), 203 styleSetName = stylesSet[ 0 ], 204 externalPath = stylesSet[ 1 ]; 211 205 212 CKEDITOR.addStylesSet = function( name, styles ) 213 { 214 stylesSets[ name ] = styles; 215 }; 206 CKEDITOR.stylesSet.addExternal( styleSetName, 207 externalPath ? stylesSet.slice( 1 ).join( ':' ) : pluginPath + 'styles/', 208 externalPath ? '' : styleSetName + '.js' ); 216 209 217 CKEDITOR.loadStylesSet = function( name, url, callback )218 {219 var stylesSet = stylesSets[ name ];220 221 if ( stylesSet )222 {223 callback( stylesSet );224 return ;225 210 } 226 227 CKEDITOR.scriptLoader.load( url, function() 228 { 229 callback( stylesSets[ name ] ); 230 }); 231 }; 211 }); 232 212 213 // Custom stylesSets as global resources. 214 CKEDITOR.stylesSet = new CKEDITOR.resourceManager( '', 'stylesSet' ); 215 233 216 function buildPreview( styleDefinition ) 234 217 { 235 218 var html = []; -
_source/plugins/stylescombo/styles/default.js
3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ 5 5 6 CKEDITOR. addStylesSet( 'default',6 CKEDITOR.stylesSet.add( 'default', 7 7 [ 8 8 /* Block Styles */ 9 9 -
_source/plugins/div/dialogs/div.js
259 259 return groups; 260 260 } 261 261 262 // Synchronous field values to other impacted fields is required, e.g. div styles 263 // change should also alter inline-style text. 264 function commitInternally( targetFields ) 265 { 266 var dialog = this.getDialog(), 267 element = new CKEDITOR.dom.element( 'div' ); 268 269 // Commit this field and broadcast to target fields. 270 this.commit( element, true ); 271 272 targetFields = [].concat( targetFields ); 273 var length = targetFields.length, field; 274 for ( var i = 0; i < length; i++ ) 275 { 276 field = dialog.getContentElement.apply( dialog, targetFields[ i ].split( ':' ) ); 277 field && field.setup && field.setup( element, true ); 278 } 279 } 280 281 282 // Registered 'CKEDITOR.style' instances. 283 var styles = {} ; 262 284 /** 263 285 * Hold a collection of created block container elements. 264 286 */ … … 290 312 label :editor.lang.div.styleSelectLabel, 291 313 'default' : '', 292 314 items : [], 315 onChange : function() 316 { 317 commitInternally .call( this, [ 'info:class', 'advanced:dir', 'advanced:style' ] ); 318 }, 293 319 setup : function( element ) 294 320 { 295 this.setValue( element.$.style.cssText || '' ); 321 for ( var name in styles ) 322 styles[ name ].checkElementRemovable( element, true ) && this.setValue( name ); 296 323 }, 297 324 commit: function( element ) 298 325 { 299 if ( this.getValue() ) 300 element.$.style.cssText = this.getValue(); 301 else 302 element.removeAttribute( 'style' ); 326 var styleName; 327 if ( styleName = this.getValue() ) 328 styles[ styleName ].applyToObject( element ) 303 329 } 304 330 }, 305 331 { … … 351 377 id :'style', 352 378 style :'width: 100%;', 353 379 label :editor.lang.common.cssStyle, 354 'default' : '' 355 } 380 'default' : '', 381 commit : function( element ) 382 { 383 var style = element.$.style; 384 // Merge with 'elementStyle', which is of higher priority. 385 style.cssText = this.getValue() + ';' + style.cssText; 386 } 387 } 356 388 ] 357 389 }, 358 390 { … … 376 408 'default' : '', 377 409 items : 378 410 [ 411 [ editor.lang.common.notSet , '' ], 379 412 [ 380 413 editor.lang.common.langDirLtr, 381 414 'ltr' … … 394 427 onLoad : function() 395 428 { 396 429 setupFields.call(this); 430 431 // Preparing for the 'elementStyle' field. 432 var dialog = this, 433 stylesField = this.getContentElement( 'info', 'elementStyle' ), 434 // Reuse the 'stylescombo' plugin's styles definition. 435 customStylesConfig = editor.config.stylesCombo_stylesSet, 436 customStylesSetName = customStylesConfig && customStylesConfig.split( ':' )[ 0 ]; 437 438 stylesField.add( editor.lang.common.notSet, '' ); 439 customStylesSetName && CKEDITOR.stylesSet.load( customStylesSetName, 440 function( stylesSet ) 441 { 442 var stylesDefinitions = stylesSet[ customStylesSetName ], 443 style, styleName; 444 445 if( stylesDefinitions ) 446 { 447 for ( var i = 0 ; i < stylesDefinitions.length ; i++ ) 448 { 449 var styleDefinition = stylesDefinitions[ i ]; 450 if( styleDefinition.element && styleDefinition.element == 'div' ) 451 { 452 styleName = styleDefinition.name; 453 style = styles[ styleName ] = new CKEDITOR.style( styleDefinition ); 454 // Populate the styles field options with style name. 455 stylesField.items.push( [ styleName, styleName ] ); 456 stylesField.add( styleName, styleName ); 457 } 458 } 459 } 460 461 // We should disable it if no styles are available. 462 var fieldBox = stylesField.getElement().getParent(); 463 stylesField.items.length ? fieldBox.removeStyle( 'display' ) : fieldBox.setStyle( 'display', 'none' ); 464 // Now setup the field value manually. 465 setTimeout( function() { stylesField.setup( dialog._element ); }, 0 ); 466 } ); 397 467 }, 398 468 onShow : function() 399 469 { … … 416 486 containers = createDiv( editor, true ); 417 487 418 488 // Update elements attributes 419 for( var i = 0 ; i < containers.length ; i++ ) 489 for ( var i = 0; i < containers.length; i++ ) 490 { 420 491 this.commitContent( containers[ i ] ); 492 // Remove empty style attribute. 493 !containers[ i ].getAttribute( 'style' ) && containers[ i ].removeAttribute( 'style' ); 494 } 495 421 496 this.hide(); 422 497 } 423 498 }; -
_source/core/resourcemanager.js
127 127 var external = this.externals[ name ]; 128 128 return CKEDITOR.getUrl( 129 129 this.getPath( name ) + 130 ( ( external && external.file ) || ( this.fileName + '.js' ) ) ); 130 // External file name could be an empty one, 131 // which indicate dir is already of the full path. 132 ( external ? external.file : this.fileName + '.js' ) ); 131 133 }, 132 134 133 135 /**