Ticket #3591: 3591_3.patch
File 3591_3.patch, 2.3 KB (added by , 15 years ago) |
---|
-
_source/plugins/htmldataprocessor/plugin.js
7 7 { 8 8 var defaultDataFilterRules = 9 9 { 10 elementNames :11 [12 // Elements that cause problems in wysiwyg mode.13 [ ( /^(object|embed|param)$/ ), 'cke:$1' ]14 ],15 16 10 attributeNames : 17 11 [ 18 12 // Event attributes (onXYZ) must not be directly set. They can become … … 56 50 } 57 51 }, 58 52 53 // Restore param elements into self-closing. 54 param : function( param ) 55 { 56 param.children = []; 57 param.isEmpty = true; 58 return param; 59 }, 60 59 61 img : function( element ) 60 62 { 61 63 var attribs = element.attributes; … … 105 107 } 106 108 107 109 var protectAttributeRegex = /<(?:a|area|img|input).*?\s((?:href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))/gi; 108 110 var protectElementNamesRegex = /(<[/]?)(object|embed|param)(.*?>)/gi; 111 var protectSelfClosingRegex = /(<)(cke:param)(.*?)\/(>)/gi; 109 112 function protectAttributes( html ) 110 113 { 111 114 return html.replace( protectAttributeRegex, '$& _cke_saved_$1' ); 112 115 } 113 116 function protectElementsNames( html ) 117 { 118 return html.replace( protectElementNamesRegex, '$1cke:$2$3'); 119 } 120 function protectSelfClosingElements( html ) 121 { 122 return html.replace( protectSelfClosingRegex, '$1$2$3$4 $1/$2$4' ); 123 } 114 124 CKEDITOR.plugins.add( 'htmldataprocessor', 115 125 { 116 126 requires : [ 'htmlwriter' ], … … 145 155 // the code. 146 156 data = protectAttributes( data ); 147 157 158 // Certain elements has problem during native DOM operation, we transform them into 159 // their 'agent' intead, prefixing with 'cke:' to become a custom element. 160 data = protectElementsNames( data ); 161 162 // All none-IE browsers don't accept self-closed custom elements, treating them as 163 // an open tag, now converting them to avoid ambiguous. 164 data = protectSelfClosingElements( data ); 165 148 166 // Call the browser to help us fixing a possibly invalid HTML 149 167 // structure. 150 var div = document.createElement( ' div' );168 var div = document.createElement( 'body' ); 151 169 div.innerHTML = data; 152 170 153 171 // Now use our parser to make further fixes to the structure, as