X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fhtmldataprocessor%2Fplugin.js;h=8aad224480c2ae24a686abb9ae71c1c3a98c2b4c;hb=refs%2Ftags%2Fv3.6.2;hp=f9b5deab14620bc52a86c17fff26657b7dd56c9e;hpb=9afde8772159bd3436f1f5b7862960307710ae5a;p=ckeditor.git
diff --git a/_source/plugins/htmldataprocessor/plugin.js b/_source/plugins/htmldataprocessor/plugin.js
index f9b5dea..8aad224 100644
--- a/_source/plugins/htmldataprocessor/plugin.js
+++ b/_source/plugins/htmldataprocessor/plugin.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -44,14 +44,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
typeof extendEmptyBlock == 'function' && ( extendEmptyBlock( block ) === false ) ) )
return false;
- // 1. For IE version >=8, empty blocks are displayed correctly themself in wysiwiyg;
- // 2. For the rest, at least table cell and list item need no filler space.
- // (#6248)
- if ( fromSource && CKEDITOR.env.ie &&
- ( document.documentMode > 7
- || block.name in CKEDITOR.dtd.tr
- || block.name in CKEDITOR.dtd.$listItem ) )
- return false;
+ // 1. For IE version >=8, empty blocks are displayed correctly themself in wysiwiyg;
+ // 2. For the rest, at least table cell and list item need no filler space.
+ // (#6248)
+ if ( fromSource && CKEDITOR.env.ie &&
+ ( document.documentMode > 7
+ || block.name in CKEDITOR.dtd.tr
+ || block.name in CKEDITOR.dtd.$listItem ) )
+ return false;
var lastChild = lastNoneSpaceChild( block );
@@ -80,6 +80,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var dtd = CKEDITOR.dtd;
+ // Define orders of table elements.
+ var tableOrder = [ 'caption', 'colgroup', 'col', 'thead', 'tfoot', 'tbody' ];
+
// Find out the list of block-like tags that can contain
.
var blockLikeTags = CKEDITOR.tools.extend( {}, dtd.$block, dtd.$listItem, dtd.$tableContent );
for ( var i in blockLikeTags )
@@ -122,8 +125,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// Attributes saved for changes and protected attributes.
[ ( /^data-cke-(saved|pa)-/ ), '' ],
- // All "data-cke" attributes are to be ignored.
- [ ( /^data-cke.*/ ), '' ],
+ // All "data-cke-" attributes are to be ignored.
+ [ ( /^data-cke-.*/ ), '' ],
[ 'hidefocus', '' ]
],
@@ -153,6 +156,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
return element;
},
+ // The contents of table should be in correct order (#4809).
+ table : function( element )
+ {
+ var children = element.children;
+ children.sort( function ( node1, node2 )
+ {
+ return node1.type == CKEDITOR.NODE_ELEMENT && node2.type == node1.type ?
+ CKEDITOR.tools.indexOf( tableOrder, node1.name ) > CKEDITOR.tools.indexOf( tableOrder, node2.name ) ? 1 : -1 : 0;
+ } );
+ },
+
embed : function( element )
{
var parent = element.parent;
@@ -193,6 +207,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
delete element.name;
},
+ // Empty
in IE is reported with filler node ( ). + pre : function( element ) { CKEDITOR.env.ie && trimFillers( element ); }, + html : function( element ) { delete element.attributes.contenteditable; @@ -228,43 +245,41 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Remove all class names starting with "cke_". return CKEDITOR.tools.ltrim( value.replace( /(?:^|\s+)cke_[^\s]*/g, '' ) ) || false; } - }, - - comment : function( contents ) - { - // If this is a comment for protected source. - if ( contents.substr( 0, protectedSourceMarker.length ) == protectedSourceMarker ) - { - // Remove the extra marker for real comments from it. - if ( contents.substr( protectedSourceMarker.length, 3 ) == '{C}' ) - contents = contents.substr( protectedSourceMarker.length + 3 ); - else - contents = contents.substr( protectedSourceMarker.length ); - - return new CKEDITOR.htmlParser.cdata( decodeURIComponent( contents ) ); - } - - return contents; } }; if ( CKEDITOR.env.ie ) { // IE outputs style attribute in capital letters. We should convert - // them back to lower case. + // them back to lower case, while not hurting the values (#5930) defaultHtmlFilterRules.attributes.style = function( value, element ) { - return value.toLowerCase(); + return value.replace( /(^|;)([^\:]+)/g, function( match ) + { + return match.toLowerCase(); + }); }; } function protectReadOnly( element ) { - element.attributes.contenteditable = "false"; + var attrs = element.attributes; + + // We should flag that the element was locked by our code so + // it'll be editable by the editor functions (#6046). + if ( attrs.contenteditable != "false" ) + attrs[ 'data-cke-editable' ] = attrs.contenteditable ? 'true' : 1; + + attrs.contenteditable = "false"; } function unprotectReadyOnly( element ) { - delete element.attributes.contenteditable; + var attrs = element.attributes; + switch( attrs[ 'data-cke-editable' ] ) + { + case 'true': attrs.contenteditable = 'true'; break; + case '1': delete attrs.contenteditable; break; + } } // Disable form elements editing mode provided by some browers. (#5746) for ( i in { input : 1, textarea : 1 } ) @@ -273,8 +288,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license defaultHtmlFilterRules.elements[ i ] = unprotectReadyOnly; } - var protectAttributeRegex = /<((?:a|area|img|input)\b[\s\S]*?\s)((href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))([^>]*)>/gi, - findSavedSrcRegex = /\sdata-cke-saved-src\s*=/; + var protectElementRegex = /<(a|area|img|input)\b([^>]*)>/gi, + protectAttributeRegex = /\b(on\w+|href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi; var protectElementsRegex = /(?: