Skip to content

Commit e8a747d

Browse files
committed
Merge branch 't/12256'
2 parents 2599ba1 + 29ec90d commit e8a747d

File tree

6 files changed

+71
-2
lines changed

6 files changed

+71
-2
lines changed

CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ Fixed Issues:
1010
* [#12885](http://dev.ckeditor.com/ticket/12885): Added missing getData parameter documentation.
1111
* [#11982](http://dev.ckeditor.com/ticket/11982): Bullet added in wrong position after *enter* key pressed in nested list.
1212
* [#13027](http://dev.ckeditor.com/ticket/13027): Fixed: Keyboard Navigation in dialogs with multiple tabs not following CI 162 instructions or [ARIA Authoring practices](http://www.w3.org/TR/2013/WD-wai-aria-practices-20130307/#tabpanel).
13+
* [#12256](http://dev.ckeditor.com/ticket/12256): Fixed: Basic styles' classes are lost when pasting from MS Word if [basics styles](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-coreStyles_bold) were configured to use classes.
1314

1415
Other Changes:
1516

1617
* [#12844](http://dev.ckeditor.com/ticket/12844): Upgraded the [testing environment](http://docs.ckeditor.com/#!/guide/dev_tests) to [Bender.js](https://github.com/benderjs/benderjs) `0.2.*`.
17-
* [#12930](http://dev.ckeditor.com/ticket/12930): Because of licenses, removed truncated-mathjax from the test directory, now `bender.config.mathJaxLibPath` need to be configured manually.
18+
* [#12930](http://dev.ckeditor.com/ticket/12930): Because of licenses, removed `truncated-mathjax/` from the `tests/` directory. Now `bender.config.mathJaxLibPath` must be configured manually in order to run MathJax plugin's tests.
1819

1920
## CKEditor 4.4.7
2021

plugins/pastefromword/filter/default.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,10 @@
596596
element.name = styleDef.element;
597597
CKEDITOR.tools.extend( element.attributes, CKEDITOR.tools.clone( styleDef.attributes ) );
598598
element.addStyle( CKEDITOR.style.getStyleText( styleDef ) );
599+
// Mark style classes as allowed so they will not be filtered out (#12256).
600+
if ( styleDef.attributes && styleDef.attributes[ 'class' ] ) {
601+
element.classWhiteList = ' ' + styleDef.attributes[ 'class' ] + ' ';
602+
}
599603
} : function() {};
600604
},
601605

@@ -1058,7 +1062,13 @@
10581062
// Only Firefox carry style sheet from MS-Word, which
10591063
// will be applied by us manually. For other browsers
10601064
// the css className is useless.
1061-
'class': falsyFilter,
1065+
// We need to keep classes added as a style (#12256).
1066+
'class': function( value, element ) {
1067+
if ( element.classWhiteList && element.classWhiteList.indexOf( ' ' + value + ' ' ) != -1 ) {
1068+
return value;
1069+
}
1070+
return false;
1071+
},
10621072

10631073
// MS-Word always generate 'background-color' along with 'bgcolor',
10641074
// simply drop the deprecated attributes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.myboldclass {
2+
font-weight: bold;
3+
color: red;
4+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<textarea cols="80" id="editor1" name="editor1" rows="10">
2+
&lt;p&gt;&lt;b&gt;Apollo 11&lt;/b&gt; was the spaceflight that landed the first humans, Americans &lt;a href=&quot;http://en.wikipedia.org/wiki/Neil_Armstrong&quot; title=&quot;Neil Armstrong&quot;&gt;Neil Armstrong&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Buzz_Aldrin&quot; title=&quot;Buzz Aldrin&quot;&gt;Buzz Aldrin&lt;/a&gt;, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.&lt;/p&gt;
3+
</textarea>
4+
<script>
5+
var editor = CKEDITOR.replace( 'editor1', {
6+
coreStyles_bold: {
7+
element: 'span',
8+
attributes: { 'class': 'myboldclass' },
9+
overrides: [ 'strong', 'b' ]
10+
},
11+
contentsCss: '_assets/removedclasses.css',
12+
allowedContent: true
13+
} );
14+
15+
editor.on( 'paste', function( evt ) {
16+
console.log( evt.data.dataValue );
17+
} );
18+
</script>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@bender-ui: collapsed
2+
@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, basicstyles, pastefromword, sourcearea, elementspath
3+
4+
1. Paste bold text from word.
5+
6+
Expected result: bold text should be bold and red.

tests/plugins/pastefromword/pastefromword.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,36 @@
2323
} );
2424

2525
wait();
26+
},
27+
28+
'test keep custom class': function() {
29+
bender.editorBot.create( {
30+
name: 'keep_custom_class',
31+
config: {
32+
coreStyles_bold: {
33+
element: 'span',
34+
attributes: { 'class': 'customboldclass' },
35+
overrides: [ 'strong', 'b' ]
36+
},
37+
allowedContent: true
38+
}
39+
}, function( bot ) {
40+
var editor = bot.editor;
41+
42+
editor.once( 'paste', function( evt ) {
43+
var dataValue = evt.data.dataValue;
44+
resume( function() {
45+
assert.areSame( '<p>Foo <span class="customboldclass">bar</span> bom</p>', dataValue );
46+
} );
47+
}, null, null, 5 ); // Test PFW only.
48+
49+
editor.fire( 'paste', {
50+
type: 'auto',
51+
dataValue: '<p style="margin: 0cm 0cm 8pt;"><font face="Calibri">Foo <b style="mso-bidi-font-weight: normal;">bar</b> bom</font></p>'
52+
} );
53+
54+
wait();
55+
} );
2656
}
2757
} );
2858

0 commit comments

Comments
 (0)