X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fplugins%2Fhtmldataprocessor%2Fplugin.js;h=a55480cfdfbb37ae1affe48c087b33c981bae5e4;hb=fb481ba0a7d298e3e7b9034fcb9f2afdc6e8e796;hp=a460bba57ef742079d4cbb243195a1f562f79af8;hpb=48b1db88210b4160dce439c6e3e32e14af8c106b;p=ckeditor.git
diff --git a/_source/plugins/htmldataprocessor/plugin.js b/_source/plugins/htmldataprocessor/plugin.js
index a460bba..a55480c 100644
--- a/_source/plugins/htmldataprocessor/plugin.js
+++ b/_source/plugins/htmldataprocessor/plugin.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -21,6 +21,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
return last;
}
+ function getNodeIndex( node ) {
+ var parent = node.parent;
+ return parent ? CKEDITOR.tools.indexOf( parent.children, node ) : -1;
+ }
+
function trimFillers( block, fromSource )
{
// If the current node is a block, and if we're converting from source or
@@ -44,14 +49,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 +85,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 )
@@ -92,14 +100,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
delete blockLikeTags.pre;
var defaultDataFilterRules =
{
- elements : {
- a : function( element )
- {
- var attrs = element.attributes;
- if ( attrs && attrs[ 'data-cke-saved-name' ] )
- attrs[ 'class' ] = ( attrs[ 'class' ] ? attrs[ 'class' ] + ' ' : '' ) + 'cke_anchor';
- }
- },
+ elements : {},
attributeNames :
[
// Event attributes (onXYZ) must not be directly set. They can become
@@ -160,6 +161,34 @@ 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 )
+ {
+ // Clone the array as it would become empty during the sort call.
+ var children = element.children.slice( 0 );
+ children.sort( function ( node1, node2 )
+ {
+ var index1, index2;
+
+ // Compare in the predefined order.
+ if ( node1.type == CKEDITOR.NODE_ELEMENT &&
+ node2.type == node1.type )
+ {
+ index1 = CKEDITOR.tools.indexOf( tableOrder, node1.name );
+ index2 = CKEDITOR.tools.indexOf( tableOrder, node2.name );
+ }
+
+ // Make sure the sort is stable, if no order can be established above.
+ if ( !( index1 > -1 && index2 > -1 && index1 != index2 ) )
+ {
+ index1 = getNodeIndex( node1 );
+ index2 = getNodeIndex( node2 );
+ }
+
+ return index1 > index2 ? 1 : -1;
+ } );
+ },
+
embed : function( element )
{
var parent = element.parent;
@@ -238,23 +267,6 @@ 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;
}
};
@@ -298,8 +310,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
defaultHtmlFilterRules.elements[ i ] = unprotectReadyOnly;
}
- var protectElementRegex = /<(a|area|img|input)\b([^>]*)>/gi,
- protectAttributeRegex = /\b(href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi;
+ var protectElementRegex = /<(a|area|img|input|source)\b([^>]*)>/gi,
+ protectAttributeRegex = /\b(on\w+|href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi;
var protectElementsRegex = /(?: