Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html (revision 6677)
+++ /CKEditor/trunk/CHANGES.html (revision 6678)
@@ -46,4 +46,5 @@
- #7347 : The ENTER key will not any more be caught by the dialog cover element.
+ - #6718 : Paste from word command dominates over force paste as plain text configuration.
Index: /CKEditor/trunk/_source/plugins/clipboard/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/clipboard/plugin.js (revision 6677)
+++ /CKEditor/trunk/_source/plugins/clipboard/plugin.js (revision 6678)
@@ -215,15 +215,5 @@
// Turn off design mode temporarily before give focus to the paste bin.
if ( mode == 'text' )
- {
- if ( CKEDITOR.env.ie )
- {
- var ieRange = doc.getBody().$.createTextRange();
- ieRange.moveToElementText( pastebin.$ );
- ieRange.execCommand( 'Paste' );
- evt.data.preventDefault();
- }
- else
- pastebin.$.focus();
- }
+ pastebin.$.focus();
else
{
@@ -378,6 +368,4 @@
editor.on( 'key', onKey, editor );
- var mode = editor.config.forcePasteAsPlainText ? 'text' : 'html';
-
// We'll be catching all pasted content in one line, regardless of whether the
// it's introduced by a document command execution (e.g. toolbar buttons) or
@@ -386,11 +374,15 @@
{
var body = editor.document.getBody();
- body.on( ( ( mode == 'text' && CKEDITOR.env.ie ) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste',
- function( evt )
+ body.on( 'beforepaste', function( evt )
{
if ( depressBeforeEvent )
return;
- getClipboardData.call( editor, evt, mode, function ( data )
+ // Fire 'beforePaste' event so clipboard flavor get customized
+ // by other plugins.
+ var eventData = { mode : 'html' };
+ editor.fire( 'beforePaste', eventData );
+
+ getClipboardData.call( editor, evt, eventData.mode, function ( data )
{
// The very last guard to make sure the
@@ -400,5 +392,5 @@
var dataTransfer = {};
- dataTransfer[ mode ] = data;
+ dataTransfer[ eventData.mode ] = data;
editor.fire( 'paste', dataTransfer );
} );
Index: /CKEditor/trunk/_source/plugins/pastefromword/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/pastefromword/plugin.js (revision 6677)
+++ /CKEditor/trunk/_source/plugins/pastefromword/plugin.js (revision 6678)
@@ -5,4 +5,6 @@
(function()
{
+ function forceHtmlMode( evt ) { evt.data.mode = 'html'; }
+
CKEDITOR.plugins.add( 'pastefromword',
{
@@ -16,4 +18,5 @@
{
evt && evt.removeListener();
+ editor.removeListener( 'beforePaste', forceHtmlMode );
forceFromWord && setTimeout( function() { forceFromWord = 0; }, 0 );
};
@@ -28,6 +31,9 @@
exec : function()
{
+ // Ensure the received data format is HTML and apply content filtering. (#6718)
forceFromWord = 1;
- if ( editor.execCommand( 'paste' ) === false )
+ editor.on( 'beforePaste', forceHtmlMode );
+
+ if ( editor.execCommand( 'paste', 'html' ) === false )
{
editor.on( 'dialogShow', function ( evt )
Index: /CKEditor/trunk/_source/plugins/pastetext/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/pastetext/plugin.js (revision 6677)
+++ /CKEditor/trunk/_source/plugins/pastetext/plugin.js (revision 6678)
@@ -59,5 +59,7 @@
editor.on( 'beforeCommandExec', function ( evt )
{
- if ( evt.data.name == 'paste' )
+ var mode = evt.data.commandData;
+ // Do NOT overwrite if HTML format is explicitly requested.
+ if ( evt.data.name == 'paste' && mode != 'html' )
{
editor.execCommand( 'pastetext' );
@@ -65,4 +67,9 @@
}
}, null, null, 0 );
+
+ editor.on( 'beforePaste', function( evt )
+ {
+ evt.data.mode = 'text';
+ });
}
@@ -83,4 +90,5 @@
* editor, loosing any formatting information possibly available in the source
* text.
+ * Note: paste from word is not affected by this configuration.
* @name CKEDITOR.config.forcePasteAsPlainText
* @type Boolean