Ticket #7915: 7915_2.patch
File 7915_2.patch, 19.5 KB (added by , 14 years ago) |
---|
-
_source/plugins/iframe/dialogs/iframe.js
35 35 value = this.getValue(); 36 36 if ( isRemove ) 37 37 iframeNode.removeAttribute( this.att || this.id ); 38 else if ( this.id == 'height' || this.id == 'width' ) 39 iframeNode.setStyle( this.id, value ); 38 40 else if ( isCheckbox ) 39 41 iframeNode.setAttribute( this.id, checkboxValues[ this.id ][ value ] ); 40 42 else -
_source/plugins/flash/plugin.js
7 7 { 8 8 var flashFilenameRegex = /\.swf(?:$|\?)/i; 9 9 10 var cssifyLength = CKEDITOR.tools.cssLength;11 12 10 function isFlashEmbed( element ) 13 11 { 14 12 var attributes = element.attributes; … … 18 16 19 17 function createFakeElement( editor, realElement ) 20 18 { 21 var fakeElement = editor.createFakeParserElement( realElement, 'cke_flash', 'flash', true ), 22 fakeStyle = fakeElement.attributes.style || ''; 23 24 var width = realElement.attributes.width, 25 height = realElement.attributes.height; 26 27 if ( typeof width != 'undefined' ) 28 fakeStyle = fakeElement.attributes.style = fakeStyle + 'width:' + cssifyLength( width ) + ';'; 29 30 if ( typeof height != 'undefined' ) 31 fakeStyle = fakeElement.attributes.style = fakeStyle + 'height:' + cssifyLength( height ) + ';'; 32 33 return fakeElement; 19 return editor.createFakeParserElement( realElement, 'cke_flash', 'flash', true ); 34 20 } 35 21 36 22 CKEDITOR.plugins.add( 'flash', … … 94 80 afterInit : function( editor ) 95 81 { 96 82 var dataProcessor = editor.dataProcessor, 97 dataFilter = dataProcessor && dataProcessor.dataFilter; 83 dataFilter = dataProcessor && dataProcessor.dataFilter, 84 htmlFilter = dataProcessor && dataProcessor.htmlFilter; 98 85 99 86 if ( dataFilter ) 100 87 { … … 136 123 } 137 124 }, 138 125 5); 139 } 126 127 // Align embed and object dimensions. 128 htmlFilter.addRules( 129 { 130 elements : { 131 'embed' : function( element ) 132 { 133 if ( isFlashEmbed( element ) && element.parent.name == 'object' ) 134 { 135 var object = element.parent, 136 objStyles = new CKEDITOR.htmlParser.cssStyle( object ).rules, 137 embedStyle = new CKEDITOR.htmlParser.cssStyle( element ); 138 139 embedStyle.rules.width = objStyles.width; 140 embedStyle.rules.height = objStyles.height; 141 element.attributes.style = String( embedStyle ); 142 } 143 } 144 } 145 }); 146 } 140 147 }, 141 148 142 149 requires : [ 'fakeobjects' ] -
_source/plugins/dialogadvtab/plugin.js
19 19 function commitAdvParams() 20 20 { 21 21 // Dialogs may use different parameters in the commit list, so, by 22 // definition, we take the firstCKEDITOR.dom.element available.22 // definition, we take all CKEDITOR.dom.element available. 23 23 var element; 24 24 25 25 for ( var i = 0 ; i < arguments.length ; i++ ) 26 26 { 27 if ( arguments[ i ]instanceof CKEDITOR.dom.element )27 if ( ( element = arguments[ i ] ) instanceof CKEDITOR.dom.element ) 28 28 { 29 element = arguments[ i ]; 30 break; 31 } 32 } 33 34 if ( element ) 35 { 36 var attrName = this.att, 37 value = this.getValue(); 29 var attrName = this.att, 30 value = this.getValue(); 38 31 39 if ( value ) 40 element.setAttribute( attrName, value ); 41 else 42 element.removeAttribute( attrName, value ); 43 } 44 } 32 if ( value ) 33 element.setAttribute( attrName, value ); 34 else 35 element.removeAttribute( attrName, value ); 36 } 37 } 38 } 45 39 46 40 CKEDITOR.plugins.add( 'dialogadvtab', 47 41 { … … 200 194 }); 201 195 } 202 196 197 if ( tabConfig.title ) 198 { 199 contents = []; 200 201 contents.push( 202 { 203 id : 'txtGenTitle', 204 att : 'title', 205 type : 'text', 206 label : editor.lang.common.advisoryTitle, 207 'default' : '', 208 setup : setupAdvParams, 209 commit : commitAdvParams 210 }); 211 212 result.elements[ 0 ].children.push( 213 { 214 type : 'hbox', 215 widths : [ '50%', '50%' ], 216 children : contents 217 }); 218 } 219 203 220 return result; 204 221 } 205 222 }); -
_source/plugins/iframe/plugin.js
1 /* 1 /* 2 2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ 5 5 6 6 (function() 7 7 { 8 function createFakeElement( editor, realElement )9 {10 var fakeElement = editor.createFakeParserElement( realElement, 'cke_iframe', 'iframe', true ),11 fakeStyle = fakeElement.attributes.style || '';12 13 var width = realElement.attributes.width,14 height = realElement.attributes.height;15 16 if ( typeof width != 'undefined' )17 fakeStyle += 'width:' + CKEDITOR.tools.cssLength( width ) + ';';18 19 if ( typeof height != 'undefined' )20 fakeStyle += 'height:' + CKEDITOR.tools.cssLength( height ) + ';';21 22 fakeElement.attributes.style = fakeStyle;23 24 return fakeElement;25 }26 27 8 CKEDITOR.plugins.add( 'iframe', 28 9 { 29 10 requires : [ 'dialog', 'fakeobjects' ], … … 96 77 { 97 78 iframe : function( element ) 98 79 { 99 return createFakeElement( editor, element);80 return editor.createFakeParserElement( element, 'cke_iframe', 'iframe', true ); 100 81 } 101 82 } 102 83 }); -
_source/plugins/flash/dialogs/flash.js
20 20 */ 21 21 var ATTRTYPE_OBJECT = 1, 22 22 ATTRTYPE_PARAM = 2, 23 ATTRTYPE_EMBED = 4; 23 STYLE_OBJECT = 3, 24 ATTRTYPE_EMBED = 4, 25 STYLE_EMBED = 5; 24 26 25 27 var attributesMap = 26 28 { … … 31 33 src : [ { type : ATTRTYPE_PARAM, name : 'movie' }, { type : ATTRTYPE_EMBED, name : 'src' }, { type : ATTRTYPE_OBJECT, name : 'data' } ], 32 34 name : [ { type : ATTRTYPE_EMBED, name : 'name' } ], 33 35 align : [ { type : ATTRTYPE_OBJECT, name : 'align' } ], 34 title : [ { type : ATTRTYPE_OBJECT, name : 'title' }, { type : ATTRTYPE_EMBED, name : 'title' } ], 35 'class' : [ { type : ATTRTYPE_OBJECT, name : 'class' }, { type : ATTRTYPE_EMBED, name : 'class'} ], 36 width : [ { type : ATTRTYPE_OBJECT, name : 'width' }, { type : ATTRTYPE_EMBED, name : 'width' } ], 37 height : [ { type : ATTRTYPE_OBJECT, name : 'height' }, { type : ATTRTYPE_EMBED, name : 'height' } ], 36 width : [ { type : STYLE_OBJECT, name : 'width' }, { type : STYLE_EMBED, name : 'width' } ], 37 height : [ { type : STYLE_OBJECT, name : 'height' }, { type : STYLE_EMBED, name : 'height' } ], 38 38 hSpace : [ { type : ATTRTYPE_OBJECT, name : 'hSpace' }, { type : ATTRTYPE_EMBED, name : 'hSpace' } ], 39 39 vSpace : [ { type : ATTRTYPE_OBJECT, name : 'vSpace' }, { type : ATTRTYPE_EMBED, name : 'vSpace' } ], 40 style : [ { type : ATTRTYPE_OBJECT, name : 'style' }, { type : ATTRTYPE_EMBED, name : 'style' } ],41 40 type : [ { type : ATTRTYPE_EMBED, name : 'type' } ] 42 41 }; 43 42 … … 167 166 embedNode.removeAttribute( attrDef.name ); 168 167 else 169 168 embedNode.setAttribute( attrDef.name, value ); 169 break; 170 case STYLE_EMBED: 171 case STYLE_OBJECT: 172 var target = attrDef.type == STYLE_OBJECT ? objectNode : embedNode; 173 target.setStyle( attrDef.name, this.getValue() ); 170 174 } 171 175 } 172 176 } 173 177 174 178 CKEDITOR.dialog.add( 'flash', function( editor ) 175 179 { 180 var advtab = editor.plugins.dialogadvtab; 176 181 var makeObjectTag = !editor.config.flashEmbedTagOnly, 177 182 makeEmbedTag = editor.config.flashAddEmbedTag || editor.config.flashEmbedTagOnly; 178 183 … … 185 190 title : editor.lang.flash.title, 186 191 minWidth : 420, 187 192 minHeight : 310, 193 onLoad : function() 194 { 195 var dialog = this, 196 styles = dialog.getContentElement( 'advanced', 'advStyles' ); 197 198 styles && styles.on( 'change', function() 199 { 200 // Synchronize width value. 201 var width = this.getStyle( 'width', '' ), 202 txtWidth = dialog.getContentElement( 'info', 'width' ); 203 204 txtWidth && txtWidth.setValue( width, true ); 205 206 // Synchronize height value. 207 var height = this.getStyle( 'height', '' ), 208 txtHeight = dialog.getContentElement( 'info', 'height' ); 209 210 txtHeight && txtHeight.setValue( height, true ); 211 }); 212 }, 188 213 onShow : function() 189 214 { 190 215 // Clear previously saved elements. … … 370 395 style : 'width:95px', 371 396 label : editor.lang.common.width, 372 397 validate : CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength ), 398 getValue : CKEDITOR.tools.cssLength, 373 399 setup : function( objectNode, embedNode, paramMap, fakeImage ) 374 400 { 375 401 loadValue.apply( this, arguments ); … … 380 406 commitValue.apply( this, arguments ); 381 407 var val = this.getValue(); 382 408 val && ( extraStyles.width = defaultToPixel( val ) ); 409 }, 410 onChange : function() 411 { 412 var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' ), 413 value = this.getValue(); 414 styles && styles.updateStyle( 'width', value ); 383 415 } 384 416 }, 385 417 { … … 387 419 id : 'height', 388 420 style : 'width:95px', 389 421 label : editor.lang.common.height, 422 getValue : CKEDITOR.tools.cssLength, 390 423 validate : CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength ), 391 424 setup : function( objectNode, embedNode, paramMap, fakeImage ) 392 425 { … … 398 431 commitValue.apply( this, arguments ); 399 432 var val = this.getValue(); 400 433 val && ( extraStyles.height = defaultToPixel( val ) ); 434 }, 435 onChange : function() 436 { 437 var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' ), 438 value = this.getValue(); 439 styles && styles.updateStyle( 'height', value ); 401 440 } 402 441 }, 403 442 { … … 629 668 } 630 669 ] 631 670 }, 632 { 633 id : 'advanced', 634 label : editor.lang.common.advancedTab, 635 elements : 636 [ 637 { 638 type : 'hbox', 639 widths : [ '45%', '55%' ], 640 children : 641 [ 642 { 643 type : 'text', 644 id : 'id', 645 label : editor.lang.common.id, 646 setup : loadValue, 647 commit : commitValue 648 }, 649 { 650 type : 'text', 651 id : 'title', 652 label : editor.lang.common.advisoryTitle, 653 setup : loadValue, 654 commit : commitValue 655 } 656 ] 657 }, 658 { 659 type : 'hbox', 660 widths : [ '45%', '55%' ], 661 children : 662 [ 663 { 664 type : 'text', 665 id : 'bgcolor', 666 label : editor.lang.flash.bgcolor, 667 setup : loadValue, 668 commit : commitValue 669 }, 670 { 671 type : 'text', 672 id : 'class', 673 label : editor.lang.common.cssClass, 674 setup : loadValue, 675 commit : commitValue 676 } 677 ] 678 }, 679 { 680 type : 'text', 681 id : 'style', 682 label : editor.lang.common.cssStyle, 683 setup : loadValue, 684 commit : commitValue 685 } 686 ] 687 } 688 ] 671 advtab && advtab.createAdvancedTab( editor, { id:1, title:1, classes:1, styles:1 } ) 672 ] 689 673 }; 690 674 } ); 691 675 })(); -
_source/core/htmlparser/element.js
60 60 }; 61 61 }; 62 62 63 /** 64 * Object presentation of CSS style declaration text. 65 * @param {CKEDITOR.htmlParser.element|String} elementOrStyleText A html parser element or the inline style text. 66 */ 67 CKEDITOR.htmlParser.cssStyle = function() 68 { 69 var styleText, arg = arguments[ 0 ],rules = {}; 70 styleText = arg instanceof CKEDITOR.htmlParser.element ? arg.attributes.style : arg; 71 72 // html-encoded quote might be introduced by 'font-family' 73 // from MS-Word which confused the following regexp. e.g. 74 //'font-family: "Lucida, Console"' 75 ( styleText || '' ) 76 .replace( /"/g, '"' ) 77 .replace( /\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g, 78 function( match, name, value ) 79 { 80 name == 'font-family' && ( value = value.replace( /["']/g, '' ) ); 81 rules[ name.toLowerCase() ] = value; 82 }); 83 84 return { 85 rules : rules, 86 toString :function() 87 { 88 var output = []; 89 for ( var i in rules ) 90 rules[ i ] && output.push( i, ':', rules[ i ], ';' ); 91 return output.join( '' ); 92 } 93 }; 94 }; 95 63 96 (function() 64 97 { 65 98 // Used to sort attribute entries in an array, where the first element of -
_source/plugins/fakeobjects/plugin.js
1 /* 1 /* 2 2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ 5 5 6 6 (function() 7 7 { 8 var CssStyle = CKEDITOR.htmlParser.cssStyle; 8 9 var htmlFilterRules = 9 10 { 10 11 elements : … … 16 17 realFragment = realHtml && new CKEDITOR.htmlParser.fragment.fromHtml( decodeURIComponent( realHtml ) ), 17 18 realElement = realFragment && realFragment.children[ 0 ]; 18 19 19 // If we have width/height in the element, we must move it into 20 // the real element. 20 // Width/height in the fake object are subjected to clone into the real element. 21 21 if ( realElement && element.attributes[ 'data-cke-resizable' ] ) 22 22 { 23 var style = element.attributes.style; 23 var styles = new CssStyle( element ).rules, 24 realStyle = new CssStyle( realElement ), 25 width = styles.width, 26 height = styles.height; 24 27 25 if ( style ) 26 { 27 // Get the width from the style. 28 var match = /(?:^|\s)width\s*:\s*(.*?)(:?;|$)/i.exec( style ), 29 width = match && match[1]; 30 31 // Get the height from the style. 32 match = /(?:^|\s)height\s*:\s*(.*?)(:?;|$)/i.exec( style ); 33 var height = match && match[1]; 34 35 if ( width ) 36 realElement.attributes.width = width; 37 38 if ( height ) 39 realElement.attributes.height = height; 40 } 41 } 28 width && ( realStyle.rules.width = width ); 29 height && ( realStyle.rules.height = height ); 30 realElement.attributes.style = String( realStyle ); 31 } 42 32 43 33 return realElement; 44 34 } … … 58 48 htmlFilter.addRules( htmlFilterRules ); 59 49 } 60 50 }); 61 })();62 51 63 CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable )64 {65 var lang = this.lang.fakeobjects,66 label = lang[ realElementType ] || lang.unknown;52 CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable ) 53 { 54 var lang = this.lang.fakeobjects, 55 label = lang[ realElementType ] || lang.unknown; 67 56 68 var attributes =69 {70 'class' : className,71 src : CKEDITOR.getUrl( 'images/spacer.gif' ),72 'data-cke-realelement' : encodeURIComponent( realElement.getOuterHtml() ),73 'data-cke-real-node-type' : realElement.type,74 alt : label,75 title : label,76 align : realElement.getAttribute( 'align' ) || ''77 };57 var attributes = 58 { 59 'class' : className, 60 src : CKEDITOR.getUrl( 'images/spacer.gif' ), 61 'data-cke-realelement' : encodeURIComponent( realElement.getOuterHtml() ), 62 'data-cke-real-node-type' : realElement.type, 63 alt : label, 64 title : label, 65 align : realElement.getAttribute( 'align' ) || '' 66 }; 78 67 79 if ( realElementType )80 attributes[ 'data-cke-real-element-type' ] = realElementType;68 if ( realElementType ) 69 attributes[ 'data-cke-real-element-type' ] = realElementType; 81 70 82 if ( isResizable )83 attributes[ 'data-cke-resizable' ] = isResizable;71 if ( isResizable ) 72 attributes[ 'data-cke-resizable' ] = isResizable; 84 73 85 return this.document.createElement( 'img', { attributes : attributes } );86 };74 return this.document.createElement( 'img', { attributes : attributes } ); 75 }; 87 76 88 CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, className, realElementType, isResizable )89 {90 var lang = this.lang.fakeobjects,91 label = lang[ realElementType ] || lang.unknown,92 html;77 CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, className, realElementType, isResizable ) 78 { 79 var lang = this.lang.fakeobjects, 80 label = lang[ realElementType ] || lang.unknown, 81 html; 93 82 94 var writer = new CKEDITOR.htmlParser.basicWriter();95 realElement.writeHtml( writer );96 html = writer.getHtml();83 var writer = new CKEDITOR.htmlParser.basicWriter(); 84 realElement.writeHtml( writer ); 85 html = writer.getHtml(); 97 86 98 var attributes =99 {100 'class' : className,101 src : CKEDITOR.getUrl( 'images/spacer.gif' ),102 'data-cke-realelement' : encodeURIComponent( html ),103 'data-cke-real-node-type' : realElement.type,104 alt : label,105 title : label,106 align : realElement.attributes.align || ''107 };87 var attributes = 88 { 89 'class' : className, 90 src : CKEDITOR.getUrl( 'images/spacer.gif' ), 91 'data-cke-realelement' : encodeURIComponent( html ), 92 'data-cke-real-node-type' : realElement.type, 93 alt : label, 94 title : label, 95 align : realElement.attributes.align || '' 96 }; 108 97 109 if ( realElementType )110 attributes[ 'data-cke-real-element-type' ] = realElementType;98 if ( realElementType ) 99 attributes[ 'data-cke-real-element-type' ] = realElementType; 111 100 112 if ( isResizable ) 113 attributes[ 'data-cke-resizable' ] = isResizable; 101 if ( isResizable ) 102 { 103 attributes[ 'data-cke-resizable' ] = isResizable; 104 var fakeStyle = new CssStyle(), 105 realStyles = new CssStyle( realElement ).rules; 114 106 115 return new CKEDITOR.htmlParser.element( 'img', attributes ); 116 }; 107 var width = realStyles.width, 108 height = realStyles.height; 109 110 width != undefined && ( fakeStyle.rules.width = width ); 111 height != undefined && ( fakeStyle.rules.height = height ); 112 attributes.style = String( fakeStyle ); 113 } 114 115 return new CKEDITOR.htmlParser.element( 'img', attributes ); 116 }; 117 117 118 CKEDITOR.editor.prototype.restoreRealElement = function( fakeElement )119 {120 if ( fakeElement.data( 'cke-real-node-type' ) != CKEDITOR.NODE_ELEMENT )121 return null;118 CKEDITOR.editor.prototype.restoreRealElement = function( fakeElement ) 119 { 120 if ( fakeElement.data( 'cke-real-node-type' ) != CKEDITOR.NODE_ELEMENT ) 121 return null; 122 122 123 return CKEDITOR.dom.element.createFromHtml( 124 decodeURIComponent( fakeElement.data( 'cke-realelement' ) ), 125 this.document ); 126 }; 123 return CKEDITOR.dom.element.createFromHtml( 124 decodeURIComponent( fakeElement.data( 'cke-realelement' ) ), 125 this.document ); 126 } 127 128 })();