Ticket #7915: 7915_4.patch
File 7915_4.patch, 21.8 KB (added by , 12 years ago) |
---|
-
_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 arg = arguments[ 0 ], 70 styleText = arg instanceof CKEDITOR.htmlParser.element ? arg.attributes.style : arg, 71 rules = {}; 72 73 // html-encoded quote might be introduced by 'font-family' 74 // from MS-Word which confused the following regexp. e.g. 75 //'font-family: "Lucida, Console"' 76 ( styleText || '' ) 77 .replace( /"/g, '"' ) 78 .replace( /\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g, 79 function( match, name, value ) 80 { 81 name == 'font-family' && ( value = value.replace( /["']/g, '' ) ); 82 rules[ name.toLowerCase() ] = value; 83 }); 84 85 return { 86 rules : rules, 87 toString :function() 88 { 89 var output = []; 90 for ( var i in rules ) 91 rules[ i ] && output.push( i, ':', rules[ i ], ';' ); 92 return output.join( '' ); 93 } 94 }; 95 }; 96 63 97 (function() 64 98 { 65 99 // Used to sort attribute entries in an array, where the first element of -
_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; 29 var attrName = this.att, 30 value = this.getValue(); 31 32 value ? element.setAttribute( attrName, value ) : element.removeAttribute( attrName ); 31 33 } 32 34 } 33 34 if ( element )35 {36 var attrName = this.att,37 value = this.getValue();38 39 if ( value )40 element.setAttribute( attrName, value );41 else42 element.removeAttribute( attrName, value );43 }44 35 } 45 36 46 37 CKEDITOR.plugins.add( 'dialogadvtab', … … 200 191 }); 201 192 } 202 193 194 if ( tabConfig.title ) 195 { 196 result.elements[ 0 ].children.push( 197 { 198 type : 'hbox', 199 widths : [ '50%', '50%' ], 200 children : 201 [ 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 }); 213 } 214 203 215 return result; 204 216 } 205 217 }); -
_source/plugins/fakeobjects/plugin.js
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, 27 styleStr; 24 28 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 } 29 width && ( realStyle.rules.width = width ); 30 height && ( realStyle.rules.height = height ); 31 if ( ( styleStr = String( realStyle ) ) ) 32 realElement.attributes.style = styleStr; 41 33 } 42 34 43 35 return realElement; … … 58 50 htmlFilter.addRules( htmlFilterRules ); 59 51 } 60 52 }); 61 })();62 53 63 CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable )64 {65 var lang = this.lang.fakeobjects,66 label = lang[ realElementType ] || lang.unknown;54 CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable ) 55 { 56 var lang = this.lang.fakeobjects, 57 label = lang[ realElementType ] || lang.unknown; 67 58 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' ) || '' 59 var attributes = 60 { 61 'class' : className, 62 src : CKEDITOR.getUrl( 'images/spacer.gif' ), 63 'data-cke-realelement' : encodeURIComponent( realElement.getOuterHtml() ), 64 'data-cke-real-node-type' : realElement.type, 65 alt : label, 66 title : label, 67 align : realElement.getAttribute( 'align' ) || '' 68 }; 69 70 if ( realElementType ) 71 attributes[ 'data-cke-real-element-type' ] = realElementType; 72 73 if ( isResizable ) 74 attributes[ 'data-cke-resizable' ] = isResizable; 75 76 return this.document.createElement( 'img', { attributes : attributes } ); 77 77 }; 78 78 79 if ( realElementType ) 80 attributes[ 'data-cke-real-element-type' ] = realElementType; 79 CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, className, realElementType, isResizable ) 80 { 81 var lang = this.lang.fakeobjects, 82 label = lang[ realElementType ] || lang.unknown, 83 html; 81 84 82 if ( isResizable ) 83 attributes[ 'data-cke-resizable' ] = isResizable; 85 var writer = new CKEDITOR.htmlParser.basicWriter(); 86 realElement.writeHtml( writer ); 87 html = writer.getHtml(); 84 88 85 return this.document.createElement( 'img', { attributes : attributes } ); 86 }; 89 var attributes = 90 { 91 'class' : className, 92 src : CKEDITOR.getUrl( 'images/spacer.gif' ), 93 'data-cke-realelement' : encodeURIComponent( html ), 94 'data-cke-real-node-type' : realElement.type, 95 alt : label, 96 title : label, 97 align : realElement.attributes.align || '' 98 }; 87 99 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; 100 if ( realElementType ) 101 attributes[ 'data-cke-real-element-type' ] = realElementType; 93 102 94 var writer = new CKEDITOR.htmlParser.basicWriter(); 95 realElement.writeHtml( writer ); 96 html = writer.getHtml(); 103 if ( isResizable ) 104 { 105 attributes[ 'data-cke-resizable' ] = isResizable; 106 var fakeStyle = new cssStyle(), 107 realStyles = new cssStyle( realElement ).rules; 97 108 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 || '' 109 var width = realStyles.width || CKEDITOR.tools.cssLength( realElement.attributes.width || '' ), 110 height = realStyles.height || CKEDITOR.tools.cssLength( realElement.attributes.height || '' ), 111 styleStr; 112 113 width != undefined && ( fakeStyle.rules.width = width ); 114 height != undefined && ( fakeStyle.rules.height = height ); 115 if ( ( styleStr = String( fakeStyle ) ) ) 116 attributes.style = styleStr; 117 } 118 119 return new CKEDITOR.htmlParser.element( 'img', attributes ); 107 120 }; 108 121 109 if ( realElementType ) 110 attributes[ 'data-cke-real-element-type' ] = realElementType; 122 CKEDITOR.editor.prototype.restoreRealElement = function( fakeElement ) 123 { 124 if ( fakeElement.data( 'cke-real-node-type' ) != CKEDITOR.NODE_ELEMENT ) 125 return null; 111 126 112 if ( isResizable ) 113 attributes[ 'data-cke-resizable' ] = isResizable; 127 var element = CKEDITOR.dom.element.createFromHtml( 128 decodeURIComponent( fakeElement.data( 'cke-realelement' ) ), 129 this.document ); 114 130 115 return new CKEDITOR.htmlParser.element( 'img', attributes ); 116 }; 131 if ( fakeElement.data( 'cke-resizable' ) ) 132 { 133 var width = fakeElement.getStyle( 'width' ), 134 height = fakeElement.getStyle( 'height' ); 117 135 118 CKEDITOR.editor.prototype.restoreRealElement = function( fakeElement ) 119 { 120 if ( fakeElement.data( 'cke-real-node-type' ) != CKEDITOR.NODE_ELEMENT ) 121 return null; 136 width != undefined && element.setStyle( 'width', width ); 137 height != undefined && element.setStyle( 'height', height ); 138 } 139 140 return element; 141 } 122 142 123 return CKEDITOR.dom.element.createFromHtml( 124 decodeURIComponent( fakeElement.data( 'cke-realelement' ) ), 125 this.document ); 126 }; 143 })(); -
_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 && 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 ); … … 378 404 commit : function( objectNode, embedNode, paramMap, extraStyles ) 379 405 { 380 406 commitValue.apply( this, arguments ); 407 408 objectNode && objectNode.removeAttribute( 'width' ); 409 embedNode && embedNode.removeAttribute( 'width' ); 410 381 411 var val = this.getValue(); 382 412 val && ( extraStyles.width = defaultToPixel( val ) ); 413 }, 414 onChange : function() 415 { 416 var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' ), 417 value = this.getValue(); 418 styles && styles.updateStyle( 'width', value ); 383 419 } 384 420 }, 385 421 { … … 387 423 id : 'height', 388 424 style : 'width:95px', 389 425 label : editor.lang.common.height, 426 getValue : CKEDITOR.tools.cssLength, 390 427 validate : CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength ), 391 428 setup : function( objectNode, embedNode, paramMap, fakeImage ) 392 429 { … … 396 433 commit : function( objectNode, embedNode, paramMap, extraStyles ) 397 434 { 398 435 commitValue.apply( this, arguments ); 436 437 objectNode && objectNode.removeAttribute( 'height' ); 438 embedNode && embedNode.removeAttribute( 'height' ); 439 399 440 var val = this.getValue(); 400 441 val && ( extraStyles.height = defaultToPixel( val ) ); 442 }, 443 onChange : function() 444 { 445 var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' ), 446 value = this.getValue(); 447 styles && styles.updateStyle( 'height', value ); 401 448 } 402 449 }, 403 450 { … … 629 676 } 630 677 ] 631 678 }, 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 } 679 advtab && advtab.createAdvancedTab( editor, { id:1, title:1, classes:1, styles:1 } ) 688 680 ] 689 681 }; 690 682 } ); -
_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); 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 styleStr; 139 140 embedStyle.rules.width = objStyles.width; 141 embedStyle.rules.height = objStyles.height; 142 143 if ( ( styleStr = String( embedStyle ) ) ) 144 element.attributes.style = styleStr; 145 } 146 } 147 } 148 }); 139 149 } 140 150 }, 141 151 -
_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 … … 83 85 var iframeNode = editor.restoreRealElement( fakeImage ); 84 86 this.iframeNode = iframeNode; 85 87 86 this.setupContent( iframeNode , fakeImage);88 this.setupContent( iframeNode ); 87 89 } 88 89 // Call the onChange method for the widht and height fields so90 // they get reflected into the Advanced tab.91 var widthInput = this.getContentElement( 'info', 'width' ),92 heightInput = this.getContentElement( 'info', 'height' );93 widthInput && widthInput.onChange();94 heightInput && heightInput.onChange();95 90 }, 96 91 onOk : function() 97 92 { … … 154 149 label : commonLang.width, 155 150 validate : CKEDITOR.dialog.validate.cssLength( editor.lang.common.invalidCssLength ), 156 151 getValue : defaultToPixel, 157 setup : function( iframeNode, fakeImage ) 158 { 159 loadValue.apply( this, arguments ); 160 fakeImage && this.setValue( fakeImage.getStyle( 'width' ) ); 161 }, 152 setup : loadValue, 162 153 commit : function( iframeNode, extraStyles ) 163 154 { 164 155 commitValue.apply( this, arguments ); … … 180 171 label : commonLang.height, 181 172 validate : CKEDITOR.dialog.validate.cssLength( editor.lang.common.invalidCssLength ), 182 173 getValue : defaultToPixel, 183 setup : function( iframeNode, fakeImage ) 184 { 185 loadValue.apply( this, arguments ); 186 fakeImage && this.setValue( fakeImage.getStyle( 'height' ) ); 187 }, 174 setup : loadValue, 188 175 commit : function( iframeNode, extraStyles ) 189 176 { 190 177 commitValue.apply( this, arguments ); -
_source/plugins/iframe/plugin.js
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 });