Skip to content

Commit 13fd47c

Browse files
committed
Merge branch 't/10032'
2 parents cfae144 + a9d402e commit 13fd47c

File tree

10 files changed

+99
-0
lines changed

10 files changed

+99
-0
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Fixed Issues:
88
* [#12747](http://dev.ckeditor.com/ticket/12747): [IE8-10] Fixed: Opening a drop-down for a specific selection when editor is maximized results in incorrect drop-down panel position.
99
* [#12735](http://dev.ckeditor.com/ticket/12735): Fixed: [`Config.fillEmptyBlocks`](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-fillEmptyBlocks) should only apply when outputting data.
1010
* [#12750](http://dev.ckeditor.com/ticket/12750): Fixed: [Paste from Word](http://ckeditor.com/addon/pastefromword): strikethrough and underscore should have the same color as font.
11+
* [#10032](http://dev.ckeditor.com/ticket/10032): Fixed: [Paste from Word](http://ckeditor.com/addon/pastefromword) filter is executed for every paste after using the button.
1112

1213
## CKEditor 4.4.6
1314

plugins/pastefromword/plugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
else if ( !editor.config.pasteFromWordPromptCleanup || ( forceFromWord || confirm( editor.lang.pastefromword.confirmCleanup ) ) ) // jshint ignore:line
7777
data.dataValue = CKEDITOR.cleanWord( mswordHtml, editor );
7878

79+
// Reset forceFromWord.
80+
forceFromWord = 0;
7981
} );
8082

8183
// The cleanup rules are to be loaded, we should just cancel
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/* exported testScenario */
2+
3+
'use strict';
4+
5+
// Scenario is a sequence (array) of pasted to be fired. True (1) means paste from word, false (0) means regular paste.
6+
function testScenario( scenario, filterPath ) {
7+
bender.editor = {
8+
config: {
9+
pasteFromWordCleanupFile: filterPath
10+
}
11+
};
12+
13+
var stub;
14+
15+
bender.test( {
16+
tearDown: function() {
17+
if ( stub ) {
18+
stub.restore();
19+
stub = null;
20+
}
21+
},
22+
23+
// #10032
24+
'test reset forceFromWord': function() {
25+
var editor = this.editor,
26+
pasteHtml = '<p>foo</p>',
27+
i = 0;
28+
29+
30+
stub = sinon.stub( editor, 'getClipboardData', function( options, callback ) {
31+
if ( callback ) {
32+
callback( { dataValue: pasteHtml } );
33+
}
34+
} );
35+
36+
editor.once( 'paste', paste, null, null, 999 );
37+
38+
firePaste( editor, scenario[ i ] );
39+
40+
wait();
41+
42+
function paste( evt ) {
43+
resume( function() {
44+
assertPaste( evt.data.dataValue, scenario[ i ], i );
45+
46+
if ( i == scenario.length ) {
47+
return;
48+
}
49+
50+
editor.once( 'paste', paste, null, null, 999 );
51+
52+
i++;
53+
54+
firePaste( editor, scenario[ i ] );
55+
56+
wait();
57+
} );
58+
}
59+
60+
function firePaste( editor, fromWord ) {
61+
if ( fromWord ) {
62+
editor.execCommand( 'pastefromword' );
63+
} else {
64+
editor.fire( 'paste', { dataValue: pasteHtml } );
65+
}
66+
}
67+
68+
function assertPaste( value, fromWord, index ) {
69+
var expectedFromWord = 'ok',
70+
expectedNotFromWord = '<p>foo</p>';
71+
72+
if ( fromWord ) {
73+
assert.areSame( expectedFromWord, value, 'Paste nr ' + index + ' should be from word.' );
74+
} else {
75+
assert.areSame( expectedNotFromWord, value, 'Paste nr ' + index + ' should NOT be from word.' );
76+
}
77+
}
78+
}
79+
} );
80+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* bender-tags: editor,unit,clipboard */
2+
/* bender-ckeditor-plugins: pastefromword */
3+
/* bender-include: _helpers/resetforcefromword.js */
4+
/* global testScenario */
5+
6+
'use strict';
7+
8+
testScenario( [ 1, 0, 1, 0, 0 ], '%TEST_DIR%_assets/customfilter.js' );
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* bender-tags: editor,unit,clipboard */
2+
/* bender-ckeditor-plugins: pastefromword */
3+
/* bender-include: _helpers/resetforcefromword.js */
4+
/* global testScenario */
5+
6+
'use strict';
7+
8+
testScenario( [ 0, 1, 0, 1, 1, 0 ], '%TEST_DIR%_assets/customfilter.js' );

0 commit comments

Comments
 (0)