Ticket #7981: 7981.patch
File 7981.patch, 15.6 KB (added by , 12 years ago) |
---|
-
_source/plugins/dialog/plugin.js
2329 2329 { 2330 2330 this.setValue = CKEDITOR.tools.override( this.setValue, function( org ) 2331 2331 { 2332 return function( val ){ org.call( this, elementDefinition.setValue.call( this, val )); };2332 return function( val, noChange ){ org.call( this, elementDefinition.setValue.apply( this, arguments ), noChange ); }; 2333 2333 } ); 2334 2334 } 2335 2335 -
_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 /** 87 * Apply the styles onto the specified element or object. 88 * @param {CKEDITOR.htmlParser.element|CKEDITOR.dom.element|Object} obj 89 */ 90 populate : function( obj ){ 91 var style = this.toString(); 92 if ( style ) 93 { 94 obj instanceof CKEDITOR.dom.element ? 95 obj.setAttribute( 'style', style ) : 96 obj instanceof CKEDITOR.htmlParser.element ? 97 obj.attributes.style = style : 98 obj.style = style; 99 } 100 }, 101 toString :function() 102 { 103 var output = []; 104 for ( var i in rules ) 105 rules[ i ] && output.push( i, ':', rules[ i ], ';' ); 106 return output.join( '' ); 107 } 108 }; 109 }; 110 63 111 (function() 64 112 { 65 113 // Used to sort attribute entries in an array, where the first element of -
_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/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', -
_source/plugins/iframe/dialogs/iframe.js
50 50 title : iframeLang.title, 51 51 minWidth : 350, 52 52 minHeight : 260, 53 onLoad : function()54 {55 var dialog = this,56 styles = dialog.getContentElement( 'advanced', 'advStyles' );57 58 styles && styles.on( 'change', function()59 {60 // Synchronize width value.61 var width = this.getStyle( 'width', '' ),62 txtWidth = dialog.getContentElement( 'info', 'width' );63 64 txtWidth && txtWidth.setValue( width, true );65 66 // Synchronize height value.67 var height = this.getStyle( 'height', '' ),68 txtHeight = dialog.getContentElement( 'info', 'height' );69 70 txtHeight && txtHeight.setValue( height, true );71 });72 },73 53 onShow : function() 74 54 { 75 55 // Clear previously saved elements. … … 83 63 var iframeNode = editor.restoreRealElement( fakeImage ); 84 64 this.iframeNode = iframeNode; 85 65 86 this.setupContent( iframeNode , fakeImage);66 this.setupContent( iframeNode ); 87 67 } 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 68 }, 96 69 onOk : function() 97 70 { … … 152 125 style : 'width:100%', 153 126 labelLayout : 'vertical', 154 127 label : commonLang.width, 155 validate : CKEDITOR.dialog.validate. cssLength( editor.lang.common.invalidCssLength ),128 validate : CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength ), 156 129 getValue : defaultToPixel, 157 setup : function( iframeNode, fakeImage ) 158 { 159 loadValue.apply( this, arguments ); 160 fakeImage && this.setValue( fakeImage.getStyle( 'width' ) ); 161 }, 162 commit : function( iframeNode, extraStyles ) 163 { 164 commitValue.apply( this, arguments ); 165 var val = this.getValue(); 166 val && ( extraStyles.width = val ); 167 }, 168 onChange : function() 169 { 170 var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' ), 171 value = this.getValue(); 172 styles && styles.updateStyle( 'width', value ); 173 } 174 }, 175 { 130 setup : loadValue, 131 commit : commitValue 132 }, 133 { 176 134 id : 'height', 177 135 type : 'text', 178 136 style : 'width:100%', 179 137 labelLayout : 'vertical', 180 138 label : commonLang.height, 181 validate : CKEDITOR.dialog.validate. cssLength( editor.lang.common.invalidCssLength ),139 validate : CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength ), 182 140 getValue : defaultToPixel, 183 setup : function( iframeNode, fakeImage ) 184 { 185 loadValue.apply( this, arguments ); 186 fakeImage && this.setValue( fakeImage.getStyle( 'height' ) ); 187 }, 188 commit : function( iframeNode, extraStyles ) 189 { 190 commitValue.apply( this, arguments ); 191 var val = this.getValue(); 192 val && ( extraStyles.height = val ); 193 }, 194 onChange : function() 195 { 196 var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' ), 197 value = this.getValue(); 198 styles && styles.updateStyle( 'height', value ); 199 } 200 }, 201 { 141 setup : loadValue, 142 commit : commitValue 143 }, 144 { 202 145 id : 'align', 203 146 type : 'select', 204 147 'default' : '', -
_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, 9 cssLength = CKEDITOR.tools.cssLength; 10 8 11 var htmlFilterRules = 9 12 { 10 13 elements : … … 16 19 realFragment = realHtml && new CKEDITOR.htmlParser.fragment.fromHtml( decodeURIComponent( realHtml ) ), 17 20 realElement = realFragment && realFragment.children[ 0 ]; 18 21 19 // If we have width/height in the element, we must move it into 20 // the real element. 22 // Width/height in the fake object are subjected to clone into the real element. 21 23 if ( realElement && element.attributes[ 'data-cke-resizable' ] ) 22 24 { 23 var style = element.attributes.style; 25 var styles = new cssStyle( element ).rules, 26 realAttrs = realElement.attributes, 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]; 28 width = styles.width, 29 height = styles.height; 30 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 } 31 width && ( realAttrs.width = width ); 32 height && ( realAttrs.height = height ); 33 } 42 34 43 35 return realElement; 44 36 } … … 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' ) || ''77 };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 }; 78 69 79 if ( realElementType )80 attributes[ 'data-cke-real-element-type' ] = realElementType;70 if ( realElementType ) 71 attributes[ 'data-cke-real-element-type' ] = realElementType; 81 72 82 if ( isResizable ) 83 attributes[ 'data-cke-resizable' ] = isResizable; 73 if ( isResizable ) 74 { 75 attributes[ 'data-cke-resizable' ] = isResizable; 84 76 85 return this.document.createElement( 'img', { attributes : attributes } ); 86 }; 77 var fakeStyle = new cssStyle(); 78 79 var width = realElement.getAttribute( 'width' ), 80 height = realElement.getAttribute( 'height' ); 81 82 width && ( fakeStyle.rules.width = cssLength( width ) ); 83 height && ( fakeStyle.rules.height = cssLength( height ) ); 84 fakeStyle.populate( attributes ); 85 } 86 87 return this.document.createElement( 'img', { attributes : attributes } ); 88 }; 87 89 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;90 CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, className, realElementType, isResizable ) 91 { 92 var lang = this.lang.fakeobjects, 93 label = lang[ realElementType ] || lang.unknown, 94 html; 93 95 94 var writer = new CKEDITOR.htmlParser.basicWriter();95 realElement.writeHtml( writer );96 html = writer.getHtml();96 var writer = new CKEDITOR.htmlParser.basicWriter(); 97 realElement.writeHtml( writer ); 98 html = writer.getHtml(); 97 99 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 };100 var attributes = 101 { 102 'class' : className, 103 src : CKEDITOR.getUrl( 'images/spacer.gif' ), 104 'data-cke-realelement' : encodeURIComponent( html ), 105 'data-cke-real-node-type' : realElement.type, 106 alt : label, 107 title : label, 108 align : realElement.attributes.align || '' 109 }; 108 110 109 if ( realElementType )110 attributes[ 'data-cke-real-element-type' ] = realElementType;111 if ( realElementType ) 112 attributes[ 'data-cke-real-element-type' ] = realElementType; 111 113 112 if ( isResizable ) 113 attributes[ 'data-cke-resizable' ] = isResizable; 114 if ( isResizable ) 115 { 116 attributes[ 'data-cke-resizable' ] = isResizable; 117 var realAttrs = realElement.attributes, 118 fakeStyle = new cssStyle(); 114 119 115 return new CKEDITOR.htmlParser.element( 'img', attributes ); 116 }; 120 var width = realAttrs.width, 121 height = realAttrs.height; 122 123 width != undefined && ( fakeStyle.rules.width = cssLength( width ) ); 124 height != undefined && ( fakeStyle.rules.height = cssLength ( height ) ); 125 fakeStyle.populate( attributes ); 126 } 127 128 return new CKEDITOR.htmlParser.element( 'img', attributes ); 129 }; 117 130 118 CKEDITOR.editor.prototype.restoreRealElement = function( fakeElement )119 {120 if ( fakeElement.data( 'cke-real-node-type' ) != CKEDITOR.NODE_ELEMENT )121 return null;131 CKEDITOR.editor.prototype.restoreRealElement = function( fakeElement ) 132 { 133 if ( fakeElement.data( 'cke-real-node-type' ) != CKEDITOR.NODE_ELEMENT ) 134 return null; 122 135 123 return CKEDITOR.dom.element.createFromHtml( 124 decodeURIComponent( fakeElement.data( 'cke-realelement' ) ), 125 this.document ); 126 }; 136 var element = CKEDITOR.dom.element.createFromHtml( 137 decodeURIComponent( fakeElement.data( 'cke-realelement' ) ), 138 this.document ); 139 140 if ( fakeElement.data( 'cke-resizable') ) 141 { 142 var width = fakeElement.getStyle( 'width' ), 143 height = fakeElement.getStyle( 'height' ); 144 145 width && element.setAttribute( 'width', width ); 146 height && element.setAttribute( 'height', height ); 147 } 148 149 return element; 150 } 151 152 })();