Index: _source/core/htmlparser/cdata.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- _source/core/htmlparser/cdata.js (revision 7369)
+++ _source/core/htmlparser/cdata.js (revision )
@@ -33,11 +33,11 @@
/**
* Writes write the CDATA with no special manipulations.
- * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
+ * @param {CKEDITOR.htmlWriter} [writer] The writer to which write the HTML.
*/
writeHtml : function( writer )
{
- writer.write( this.value );
+ writer && writer.write( this.value );
}
};
})();
Index: _source/core/htmlparser/comment.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- _source/core/htmlparser/comment.js (revision 7369)
+++ _source/core/htmlparser/comment.js (revision )
@@ -35,7 +35,7 @@
/**
* Writes the HTML representation of this comment to a CKEDITOR.htmlWriter.
- * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
+ * @param {CKEDITOR.htmlWriter} [writer] The writer to which write the HTML.
* @example
*/
writeHtml : function( writer, filter )
@@ -55,6 +55,6 @@
}
}
- writer.comment( comment );
+ writer && writer.comment( comment );
}
};
Index: _source/core/htmlparser/element.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- _source/core/htmlparser/element.js (revision 7369)
+++ _source/core/htmlparser/element.js (revision )
@@ -191,26 +191,29 @@
{
while ( true )
{
+ if ( writeName )
+ {
- if ( !( writeName = filter.onElementName( writeName ) ) )
- return;
+ if ( !( writeName = filter.onElementName( writeName ) ) )
+ return;
- element.name = writeName;
+ element.name = writeName;
- if ( !( element = filter.onElement( element ) ) )
- return;
+ if ( !( element = filter.onElement( element ) ) )
+ return;
- element.parent = this.parent;
+ element.parent = this.parent;
- if ( element.name == writeName )
- break;
+ if ( element.name == writeName )
+ break;
- // If the element has been replaced with something of a
- // different type, then make the replacement write itself.
- if ( element.type != CKEDITOR.NODE_ELEMENT )
- {
- element.writeHtml( writer, filter );
- return;
- }
+ // If the element has been replaced with something of a
+ // different type, then make the replacement write itself.
+ if ( element.type != CKEDITOR.NODE_ELEMENT )
+ {
+ element.writeHtml( writer, filter );
+ return;
+ }
+ }
writeName = element.name;
@@ -233,7 +236,7 @@
}
// Open element tag.
- writer.openTag( writeName, attributes );
+ writer && writer.openTag( writeName, attributes );
// Copy all attributes to an array.
var attribsArray = [];
@@ -275,26 +278,30 @@
}
}
}
+
+ if ( writer )
+ {
- // Sort the attributes by name.
- if ( writer.sortAttributes )
- attribsArray.sort( sortAttribs );
+ // Sort the attributes by name.
+ if ( writer.sortAttributes )
+ attribsArray.sort( sortAttribs );
- // Send the attributes.
- var len = attribsArray.length;
+ // Send the attributes.
+ var len = attribsArray.length;
- for ( i = 0 ; i < len ; i++ )
+ for ( i = 0; i < len; i++ )
- {
- var attrib = attribsArray[ i ];
- writer.attribute( attrib[0], attrib[1] );
- }
+ {
+ var attrib = attribsArray[ i ];
+ writer.attribute( attrib[0], attrib[1] );
+ }
- // Close the tag.
- writer.openTagClose( writeName, element.isEmpty );
+ // Close the tag.
+ writer.openTagClose( writeName, element.isEmpty );
+ }
if ( !element.isEmpty )
{
this.writeChildrenHtml.call( element, writer, isChildrenFiltered ? null : filter );
// Close the element.
- writer.closeTag( writeName );
+ writer && writer.closeTag( writeName );
}
},
Index: _source/core/htmlparser/filter.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- _source/core/htmlparser/filter.js (revision 7369)
+++ _source/core/htmlparser/filter.js (revision )
@@ -134,6 +134,14 @@
}
return value;
+ },
+
+ hasRules : function()
+ {
+ return this._.elementNames.length ||
+ this._.attributeNames.length ||
+ this._.elements.$length ||
+ this._.attributes.$length;
}
}
});
Index: _source/plugins/htmldataprocessor/plugin.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- _source/plugins/htmldataprocessor/plugin.js (revision 7369)
+++ _source/plugins/htmldataprocessor/plugin.js (revision )
@@ -447,6 +447,17 @@
});
}
+ function preProcess( event, editor, fragment )
+ {
+ // Fire the event to allow custom the filter rules.
+ var data = { filter : new CKEDITOR.htmlParser.filter() };
+ editor.fire( event, data );
+ var filter = data.filter;
+
+ // Write without any rules.
+ filter.hasRules() && fragment.writeHtml( null, filter );
+ }
+
CKEDITOR.plugins.add( 'htmldataprocessor',
{
requires : [ 'htmlwriter' ],
@@ -534,6 +545,9 @@
var fragment = CKEDITOR.htmlParser.fragment.fromHtml( data, fixForBody ),
writer = new CKEDITOR.htmlParser.basicWriter();
+ // Fires an event to allow data pre-filtering with custom rules.
+ preProcess( 'beforeProcessData', this.editor, fragment );
+
fragment.writeHtml( writer, this.dataFilter );
data = writer.getHtml( true );
@@ -549,6 +563,9 @@
fragment = CKEDITOR.htmlParser.fragment.fromHtml( html, fixForBody );
writer.reset();
+
+ // Fires an event to allow html pre-filtering with custom rules.
+ preProcess( 'beforeProcessHtml', this.editor, fragment );
fragment.writeHtml( writer, this.htmlFilter );
Index: _source/plugins/pastefromword/filter/default.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- _source/plugins/pastefromword/filter/default.js (revision 7369)
+++ _source/plugins/pastefromword/filter/default.js (revision )
@@ -1292,6 +1292,38 @@
CKEDITOR.cleanWord = function( data, editor )
{
+ editor.on( 'beforeProcessData', function( evt )
+ {
+ // DONT leak let rules remains after paste from word has completed.
+ evt.removeListener();
+ evt.data.filter.addRules(
+ {
+ attributeNames :
+ [
+ // Remove onmouseover and onmouseout events (from MS Word comments effect)
+ [ ( /^cke:.*/ ), '' ]
+ ],
+ attributes :
+ {
+ 'style' : function( value )
+ {
+ if ( !value )
+ return false;
+ }
+ },
+ elements :
+ {
+ 'span' : function( element )
+ {
+ console.count( 'remove empty span' );
+ // Remove dummy spans (attribute-less).
+ if ( CKEDITOR.tools.isEmpty( element.attributes ) )
+ element.name = '';
+ }
+ }
+ });
+ } );
+
// Firefox will be confused by those downlevel-revealed IE conditional
// comments, fixing them first( convert it to upperlevel-revealed one ).
// e.g. ...
@@ -1315,17 +1347,6 @@
{
alert( editor.lang.pastefromword.error );
}
-
- /* Below post processing those things that are unable to delivered by filter rules. */
-
- // Remove 'cke' namespaced attribute used in filter rules as marker.
- data = data.replace( /cke:.*?".*?"/g, '' );
-
- // Remove empty style attribute.
- data = data.replace( /style=""/g, '' );
-
- // Remove the dummy spans ( having no inline style ).
- data = data.replace( //g, '' );
return data;
};
Index: _source/core/htmlparser/text.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- _source/core/htmlparser/text.js (revision 7369)
+++ _source/core/htmlparser/text.js (revision )
@@ -47,7 +47,7 @@
if ( filter && !( text = filter.onText( text, this ) ) )
return;
- writer.text( text );
+ writer && writer.text( text );
}
};
})();