/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
delete blockLikeTags.pre;\r
var defaultDataFilterRules =\r
{\r
- elements : {},\r
+ elements : {\r
+ a : function( element )\r
+ {\r
+ var attrs = element.attributes;\r
+ if ( attrs && attrs[ 'data-cke-saved-name' ] )\r
+ attrs[ 'class' ] = ( attrs[ 'class' ] ? attrs[ 'class' ] + ' ' : '' ) + 'cke_anchor';\r
+ }\r
+ },\r
attributeNames :\r
[\r
// Event attributes (onXYZ) must not be directly set. They can become\r
// Attributes saved for changes and protected attributes.\r
[ ( /^data-cke-(saved|pa)-/ ), '' ],\r
\r
- // All "data-cke" attributes are to be ignored.\r
- [ ( /^data-cke.*/ ), '' ],\r
+ // All "data-cke-" attributes are to be ignored.\r
+ [ ( /^data-cke-.*/ ), '' ],\r
\r
[ 'hidefocus', '' ]\r
],\r
delete element.name;\r
},\r
\r
+ // Empty <pre> in IE is reported with filler node ( ).\r
+ pre : function( element ) { CKEDITOR.env.ie && trimFillers( element ); },\r
+\r
html : function( element )\r
{\r
delete element.attributes.contenteditable;\r
if ( CKEDITOR.env.ie )\r
{\r
// IE outputs style attribute in capital letters. We should convert\r
- // them back to lower case.\r
+ // them back to lower case, while not hurting the values (#5930)\r
defaultHtmlFilterRules.attributes.style = function( value, element )\r
{\r
- return value.toLowerCase();\r
+ return value.replace( /(^|;)([^\:]+)/g, function( match )\r
+ {\r
+ return match.toLowerCase();\r
+ });\r
};\r
}\r
\r
function protectReadOnly( element )\r
{\r
- element.attributes.contenteditable = "false";\r
+ var attrs = element.attributes;\r
+\r
+ // We should flag that the element was locked by our code so\r
+ // it'll be editable by the editor functions (#6046).\r
+ if ( attrs.contenteditable != "false" )\r
+ attrs[ 'data-cke-editable' ] = attrs.contenteditable ? 'true' : 1;\r
+\r
+ attrs.contenteditable = "false";\r
}\r
function unprotectReadyOnly( element )\r
{\r
- delete element.attributes.contenteditable;\r
+ var attrs = element.attributes;\r
+ switch( attrs[ 'data-cke-editable' ] )\r
+ {\r
+ case 'true': attrs.contenteditable = 'true'; break;\r
+ case '1': delete attrs.contenteditable; break;\r
+ }\r
}\r
// Disable form elements editing mode provided by some browers. (#5746)\r
for ( i in { input : 1, textarea : 1 } )\r
defaultHtmlFilterRules.elements[ i ] = unprotectReadyOnly;\r
}\r
\r
- var protectAttributeRegex = /<((?:a|area|img|input)\b[\s\S]*?\s)((href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))([^>]*)>/gi,\r
- findSavedSrcRegex = /\sdata-cke-saved-src\s*=/;\r
+ var protectElementRegex = /<(a|area|img|input)\b([^>]*)>/gi,\r
+ protectAttributeRegex = /\b(href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi;\r
\r
var protectElementsRegex = /(?:<style(?=[ >])[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,\r
encodedElementsRegex = /<cke:encoded>([^<]*)<\/cke:encoded>/gi;\r
\r
function protectAttributes( html )\r
{\r
- return html.replace( protectAttributeRegex, function( tag, beginning, fullAttr, attrName, end )\r
+ return html.replace( protectElementRegex, function( element, tag, attributes )\r
+ {\r
+ return '<' + tag + attributes.replace( protectAttributeRegex, function( fullAttr, attrName )\r
{\r
- // We should not rewrite the _cke_saved_src attribute (#5218)\r
- if ( attrName == 'src' && findSavedSrcRegex.test( tag ) )\r
- return tag;\r
- else\r
- return '<' + beginning + fullAttr + ' data-cke-saved-' + fullAttr + end + '>';\r
- });\r
+ // We should not rewrite the existed protected attributes, e.g. clipboard content from editor. (#5218)\r
+ if ( attributes.indexOf( 'data-cke-saved-' + attrName ) == -1 )\r
+ return ' data-cke-saved-' + fullAttr + ' ' + fullAttr;\r
+\r
+ return fullAttr;\r
+ }) + '>';\r
+ });\r
}\r
\r
function protectElements( html )\r