Ticket #4973: 4973_4.patch
File 4973_4.patch, 10.1 KB (added by , 14 years ago) |
---|
-
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 { -
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 471 // We should disable the content element 472 // it if no options are available at all. 473 stylesField[ stylesField.items.length > 1 ? 'enable' : 'disable' ](); 474 475 // Now setup the field value manually. 476 setTimeout( function() { stylesField.setup( dialog._element ); }, 0 ); 477 } ); 478 } 397 479 }, 398 480 onShow : function() 399 481 { … … 416 498 containers = createDiv( editor, true ); 417 499 418 500 // Update elements attributes 419 for( var i = 0 ; i < containers.length ; i++ ) 501 var size = containers.length; 502 for ( var i = 0; i < size; i++ ) 503 { 420 504 this.commitContent( containers[ i ] ); 505 506 // Remove empty 'style' attribute. 507 !containers[ i ].getAttribute( 'style' ) && containers[ i ].removeAttribute( 'style' ); 508 } 509 421 510 this.hide(); 511 }, 512 onHide : function() 513 { 514 delete this._element; 422 515 } 423 516 }; 424 517 } -
plugins/div/plugin.js
12 12 { 13 13 CKEDITOR.plugins.add( 'div', 14 14 { 15 requires : [ 'editingblock', 'domiterator' ],15 requires : [ 'editingblock', 'domiterator', 'styles' ], 16 16 17 17 init : function( editor ) 18 18 { -
plugins/styles/plugin.js
1246 1246 1247 1247 return !!doc; 1248 1248 }; 1249 1250 CKEDITOR.stylesSet = new CKEDITOR.resourceManager( '', 'stylesSet' ); -
plugins/stylescombo/plugin.js
5 5 6 6 (function() 7 7 { 8 var stylesManager; 9 8 10 CKEDITOR.plugins.add( 'stylescombo', 9 11 { 10 12 requires : [ 'richcombo', 'styles' ], … … 16 18 pluginPath = this.path, 17 19 styles; 18 20 21 if ( !stylesManager ) 22 { 23 stylesManager = CKEDITOR.stylesSet; 24 25 // Backward compatibilities (#5025). 26 CKEDITOR.addStylesSet = CKEDITOR.tools.bind( stylesManager.add, stylesManager ); 27 CKEDITOR.loadStylesSet = function( name, url, callback ) 28 { 29 stylesManager.addExternal( name, url, '' ); 30 CKEDITOR.stylesSet.load( name, callback ); 31 }; 32 } 33 34 var comboStylesSet = config.stylesCombo_stylesSet.split( ':' ), 35 styleSetName = comboStylesSet[ 0 ], 36 externalPath = comboStylesSet[ 1 ]; 37 38 stylesManager.addExternal( styleSetName, 39 externalPath ? 40 comboStylesSet.slice( 1 ).join( ':' ) : 41 pluginPath + 'styles/' + styleSetName + '.js', '' ); 42 19 43 editor.ui.addRichCombo( 'Styles', 20 44 { 21 45 label : lang.label, … … 32 56 33 57 init : function() 34 58 { 35 var combo = this, 36 stylesSet = config.stylesCombo_stylesSet.split( ':' ); 59 var combo = this; 37 60 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 ) 61 CKEDITOR.stylesSet.load( styleSetName, function( stylesSet ) 45 62 { 46 var style, 63 var stylesDefinitions = stylesSet[ styleSetName ], 64 style, 47 65 styleName, 48 66 stylesList = []; 49 67 … … 207 225 } 208 226 }); 209 227 210 var stylesSets = {};211 212 CKEDITOR.addStylesSet = function( name, styles )213 {214 stylesSets[ name ] = styles;215 };216 217 CKEDITOR.loadStylesSet = function( name, url, callback )218 {219 var stylesSet = stylesSets[ name ];220 221 if ( stylesSet )222 {223 callback( stylesSet );224 return ;225 }226 227 CKEDITOR.scriptLoader.load( url, function()228 {229 callback( stylesSets[ name ] );230 });231 };232 233 228 function buildPreview( styleDefinition ) 234 229 { 235 230 var html = []; -
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