Ticket #4973: 4973_3.patch
File 4973_3.patch, 9.3 KB (added by , 13 years ago) |
---|
-
_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 && external.file != null ) ? external.file : this.fileName + '.js' ) ); 131 131 }, 132 132 133 133 /** … … 136 136 * @param {String} names The resource names, separated by commas. 137 137 * @param {String} path The path of the folder containing the resource. 138 138 * @param {String} [fileName] The resource file name. If not provided, the 139 * default name is used. 139 * default name is used; If provided with a empty string, will implicitly indicates that {@param path} 140 * is already the full path. 140 141 * @example 141 142 * // Loads a plugin from '/myplugin/samples/plugin.js'. 142 143 * CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/' ); 143 144 * @example 144 145 * // Loads a plugin from '/myplugin/samples/my_plugin.js'. 145 146 * CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/', 'my_plugin.js' ); 147 * @example 148 * // Loads a plugin from '/myplugin/samples/my_plugin.js'. 149 * CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/my_plugin.js', '' ); 146 150 */ 147 151 addExternal : function( names, path, fileName ) 148 152 { -
_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 = dialog._element && dialog._element.clone() 268 || new CKEDITOR.dom.element( 'div', editor.document ); 269 270 // Commit this field and broadcast to target fields. 271 this.commit( element, true ); 272 273 targetFields = [].concat( targetFields ); 274 var length = targetFields.length, field; 275 for ( var i = 0; i < length; i++ ) 276 { 277 field = dialog.getContentElement.apply( dialog, targetFields[ i ].split( ':' ) ); 278 field && field.setup && field.setup( element, true ); 279 } 280 } 281 282 283 // Registered 'CKEDITOR.style' instances. 284 var styles = {} ; 262 285 /** 263 286 * Hold a collection of created block container elements. 264 287 */ … … 289 312 style :'width: 100%;', 290 313 label :editor.lang.div.styleSelectLabel, 291 314 'default' : '', 292 items : [], 315 // Options are loaded dynamically. 316 items : 317 [ 318 [ editor.lang.common.notSet , '' ] 319 ], 320 onChange : function() 321 { 322 commitInternally.call( this, [ 'info:class', 'advanced:dir', 'advanced:style' ] ); 323 }, 293 324 setup : function( element ) 294 325 { 295 this.setValue( element.$.style.cssText || '' ); 326 for ( var name in styles ) 327 styles[ name ].checkElementRemovable( element, true ) && this.setValue( name ); 296 328 }, 297 329 commit: function( element ) 298 330 { 299 if ( this.getValue() ) 300 element.$.style.cssText = this.getValue(); 301 else 302 element.removeAttribute( 'style' ); 331 var styleName; 332 if ( styleName = this.getValue() ) 333 styles[ styleName ].applyToObject( element ) 303 334 } 304 335 }, 305 336 { … … 351 382 id :'style', 352 383 style :'width: 100%;', 353 384 label :editor.lang.common.cssStyle, 354 'default' : '' 385 'default' : '', 386 commit : function( element ) 387 { 388 // Merge with 'elementStyle', which is of higher priority. 389 var value = this.getValue(), 390 merged = [ value, element.getAttribute( 'style' ) ].join( ';' ); 391 value && element.setAttribute( 'style', merged ); 392 } 355 393 } 356 394 ] 357 395 }, … … 376 414 'default' : '', 377 415 items : 378 416 [ 417 [ editor.lang.common.notSet , '' ], 379 418 [ 380 419 editor.lang.common.langDirLtr, 381 420 'ltr' … … 394 433 onLoad : function() 395 434 { 396 435 setupFields.call(this); 436 437 // Preparing for the 'elementStyle' field. 438 var dialog = this, 439 stylesField = this.getContentElement( 'info', 'elementStyle' ), 440 // Reuse the 'stylescombo' plugin's styles definition. 441 customStylesConfig = editor.config.stylesCombo_stylesSet, 442 stylesSetName = customStylesConfig && customStylesConfig.split( ':' )[ 0 ]; 443 444 if( stylesSetName ) 445 { 446 CKEDITOR.stylesSet.load( stylesSetName, 447 function( stylesSet ) 448 { 449 var stylesDefinitions = stylesSet[ stylesSetName ], 450 styleName; 451 452 if ( stylesDefinitions ) 453 { 454 // Digg only those styles that apply to 'div'. 455 for ( var i = 0 ; i < stylesDefinitions.length ; i++ ) 456 { 457 var styleDefinition = stylesDefinitions[ i ]; 458 if( styleDefinition.element && styleDefinition.element == 'div' ) 459 { 460 styleName = styleDefinition.name; 461 styles[ styleName ] = new CKEDITOR.style( styleDefinition ); 462 463 // Populate the styles field options with style name. 464 stylesField.items.push( [ styleName, styleName ] ); 465 stylesField.add( styleName, styleName ); 466 } 467 } 468 } 469 470 var fieldBox = stylesField.getElement().getParent(); 471 472 // We should disable the content element 473 // it if no options are available at all. 474 stylesField.items.length ? 475 fieldBox.removeStyle( 'display' ) : 476 fieldBox.setStyle( 'display', 'none' ); 477 478 // Now setup the field value manually. 479 setTimeout( function() { stylesField.setup( dialog._element ); }, 0 ); 480 } ); 481 } 397 482 }, 398 483 onShow : function() 399 484 { … … 416 501 containers = createDiv( editor, true ); 417 502 418 503 // Update elements attributes 419 for( var i = 0 ; i < containers.length ; i++ ) 504 var size = containers.length; 505 for ( var i = 0; i < size; i++ ) 506 { 420 507 this.commitContent( containers[ i ] ); 508 509 // Remove empty 'style' attribute. 510 !containers[ i ].getAttribute( 'style' ) && containers[ i ].removeAttribute( 'style' ); 511 } 512 421 513 this.hide(); 422 514 } 423 515 }; -
_source/plugins/stylescombo/plugin.js
16 16 pluginPath = this.path, 17 17 styles; 18 18 19 var stylesSet = config.stylesCombo_stylesSet.split( ':' ), 20 styleSetName = stylesSet[ 0 ], 21 externalPath = stylesSet[ 1 ]; 22 23 CKEDITOR.stylesSet.addExternal( styleSetName, 24 externalPath ? 25 stylesSet.slice( 1 ).join( ':' ) : 26 pluginPath + 'styles/' + styleSetName + '.js', '' ); 27 19 28 editor.ui.addRichCombo( 'Styles', 20 29 { 21 30 label : lang.label, … … 32 41 33 42 init : function() 34 43 { 35 var combo = this, 36 stylesSet = config.stylesCombo_stylesSet.split( ':' ); 44 var combo = this; 37 45 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 ) 46 CKEDITOR.stylesSet.load( styleSetName, function( stylesSet ) 45 47 { 46 var style, 48 var stylesDefinitions = stylesSet[ styleSetName ], 49 style, 47 50 styleName, 48 51 stylesList = []; 49 52 … … 207 210 } 208 211 }); 209 212 210 var stylesSet s = {};213 var stylesSet = (CKEDITOR.stylesSet = new CKEDITOR.resourceManager( '', 'stylesSet' ) ); 211 214 212 CKEDITOR.addStylesSet = function( name, styles ) 213 { 214 stylesSets[ name ] = styles; 215 }; 216 215 // Backward compatibilities (#5025). 216 CKEDITOR.addStylesSet = CKEDITOR.tools.bind( stylesSet.add, stylesSet ); 217 217 CKEDITOR.loadStylesSet = function( name, url, callback ) 218 {219 var stylesSet = stylesSets[ name ];220 221 if ( stylesSet )222 218 { 223 callback( stylesSet ); 224 return ; 225 } 226 227 CKEDITOR.scriptLoader.load( url, function() 228 { 229 callback( stylesSets[ name ] ); 230 }); 231 }; 232 219 stylesSet.addExternal( name, url, '' ); 220 CKEDITOR.stylesSet.load( name, callback ); 221 }; 222 233 223 function buildPreview( styleDefinition ) 234 224 { 235 225 var html = []; -
_source/plugins/stylescombo/styles/default.js
1 /*1 /* 2 2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. 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