Skip to content

Commit d31d1be

Browse files
committed
Merge branch 't/13199' into major
2 parents ce8ccc2 + 37806c4 commit d31d1be

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
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
* [#13118](http://dev.ckeditor.com/ticket/13118): Fixed: The [`editor.getSelectedHtml()`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-getSelectedHtml) method throws error when called in the source mode.
99
* [#13158](http://dev.ckeditor.com/ticket/13158): Fixed: Error after canceling dialog when creating a widget.
1010
* [#13197](http://dev.ckeditor.com/ticket/13197): Fixed: Linked inline image2's alignment class is not transferred to widget wrapper.
11+
* [#13199](http://dev.ckeditor.com/ticket/13199): Fixed: Embedsemantic does not support widget classes.
1112
* Toolbar configurators:
1213
* [#13185](http://dev.ckeditor.com/ticket/13185): Fixed: Wrong position of the suggestion box if there is not enough space below the caret.
1314
* [#13138](http://dev.ckeditor.com/ticket/13138): Fixed: The "Toggle empty elements" button label is unclear.

plugins/embedsemantic/plugin.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,23 @@
6868
data.loadOnReady = true;
6969
div = new CKEDITOR.htmlParser.element( 'div' );
7070
element.replaceWith( div );
71+
72+
// Transfer widget classes from data to widget element (#13199).
73+
div.attributes[ 'class' ] = element.attributes[ 'class' ];
74+
7175
return div;
7276
}
7377
},
7478

75-
downcast: function() {
79+
downcast: function( element ) {
7680
var ret = new CKEDITOR.htmlParser.element( 'oembed' );
7781
ret.add( new CKEDITOR.htmlParser.text( this.data.url ) );
7882

83+
// Transfer widget classes from widget element back to data (#13199).
84+
if ( element.attributes[ 'class' ] ) {
85+
ret.attributes[ 'class' ] = element.attributes[ 'class' ];
86+
}
87+
7988
return ret;
8089
}
8190
}, true );

tests/plugins/embed/integration.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,36 @@
88
bender.editors = {
99
classic: {
1010
name: 'editor_classic',
11-
creator: 'replace'
11+
creator: 'replace',
12+
config: {
13+
extraAllowedContent: 'div(a,b,c)'
14+
}
1215
}
1316
};
1417

18+
var obj2Array = widgetTestsTools.obj2Array;
19+
var classes2Array = widgetTestsTools.classes2Array;
20+
1521
embedTools.mockJsonp();
1622

17-
var tcs = {};
23+
var tcs = {
24+
'test support for widget classes': function() {
25+
var bot = this.editorBots.classic,
26+
editor = bot.editor,
27+
data = '<div class="a b c" data-oembed-url="http://foo.jpg">' +
28+
'<img alt="image" src="//foo.jpg" style="max-width:100%;" />' +
29+
'</div>';
30+
31+
bot.setData( data, function() {
32+
wait( function() {
33+
arrayAssert.itemsAreSame( [ 'a', 'b', 'c' ],
34+
classes2Array( obj2Array( editor.widgets.instances )[ 0 ].getClasses() ).sort(), 'classes transfered from data to widget.element' );
35+
36+
assert.areSame( data, bot.getData( 1, 1 ), 'classes transfered from widget.element back to data' );
37+
}, 100 );
38+
} );
39+
}
40+
};
1841

1942
widgetTestsTools.addTests( tcs, {
2043
name: 'basic',

tests/plugins/embedsemantic/integration.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
bender.editors = {
99
classic: {
1010
name: 'editor_classic',
11-
creator: 'replace'
11+
creator: 'replace',
12+
config: {
13+
extraAllowedContent: 'oembed(a,b,c)'
14+
}
1215
}
1316
};
1417

1518
var obj2Array = widgetTestsTools.obj2Array;
19+
var classes2Array = widgetTestsTools.classes2Array;
1620

1721
embedTools.mockJsonp();
1822

@@ -81,6 +85,20 @@ var tcs = {
8185
assert.isFalse( loadContentSpy.called, 'widget.loadContent was not called on undo' );
8286
}, 100 );
8387
} );
88+
},
89+
90+
'test support for widget classes': function() {
91+
var bot = this.editorBots.classic,
92+
editor = bot.editor;
93+
94+
bot.setData( '<p>x</p><oembed class="a c b">http://widget/classes</oembed><p>x</p>', function() {
95+
wait( function() {
96+
arrayAssert.itemsAreSame( [ 'a', 'b', 'c' ],
97+
classes2Array( obj2Array( editor.widgets.instances )[ 0 ].getClasses() ).sort(), 'classes transfered from data to widget.element' );
98+
99+
assert.areSame( '<p>x</p><oembed class="a b c">http://widget/classes</oembed><p>x</p>', bot.getData(), 'classes transfered from widget.element back to data' );
100+
}, 100 );
101+
} );
84102
}
85103
};
86104

0 commit comments

Comments
 (0)