Skip to content

Commit

Permalink
Merge branch 't/13199' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed May 11, 2015
2 parents ce8ccc2 + 37806c4 commit d31d1be
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -8,6 +8,7 @@ Fixed Issues:
* [#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.
* [#13158](http://dev.ckeditor.com/ticket/13158): Fixed: Error after canceling dialog when creating a widget.
* [#13197](http://dev.ckeditor.com/ticket/13197): Fixed: Linked inline image2's alignment class is not transferred to widget wrapper.
* [#13199](http://dev.ckeditor.com/ticket/13199): Fixed: Embedsemantic does not support widget classes.
* Toolbar configurators:
* [#13185](http://dev.ckeditor.com/ticket/13185): Fixed: Wrong position of the suggestion box if there is not enough space below the caret.
* [#13138](http://dev.ckeditor.com/ticket/13138): Fixed: The "Toggle empty elements" button label is unclear.
Expand Down
11 changes: 10 additions & 1 deletion plugins/embedsemantic/plugin.js
Expand Up @@ -68,14 +68,23 @@
data.loadOnReady = true;
div = new CKEDITOR.htmlParser.element( 'div' );
element.replaceWith( div );

// Transfer widget classes from data to widget element (#13199).
div.attributes[ 'class' ] = element.attributes[ 'class' ];

return div;
}
},

downcast: function() {
downcast: function( element ) {
var ret = new CKEDITOR.htmlParser.element( 'oembed' );
ret.add( new CKEDITOR.htmlParser.text( this.data.url ) );

// Transfer widget classes from widget element back to data (#13199).
if ( element.attributes[ 'class' ] ) {
ret.attributes[ 'class' ] = element.attributes[ 'class' ];
}

return ret;
}
}, true );
Expand Down
27 changes: 25 additions & 2 deletions tests/plugins/embed/integration.js
Expand Up @@ -8,13 +8,36 @@
bender.editors = {
classic: {
name: 'editor_classic',
creator: 'replace'
creator: 'replace',
config: {
extraAllowedContent: 'div(a,b,c)'
}
}
};

var obj2Array = widgetTestsTools.obj2Array;
var classes2Array = widgetTestsTools.classes2Array;

embedTools.mockJsonp();

var tcs = {};
var tcs = {
'test support for widget classes': function() {
var bot = this.editorBots.classic,
editor = bot.editor,
data = '<div class="a b c" data-oembed-url="http://foo.jpg">' +
'<img alt="image" src="//foo.jpg" style="max-width:100%;" />' +
'</div>';

bot.setData( data, function() {
wait( function() {
arrayAssert.itemsAreSame( [ 'a', 'b', 'c' ],
classes2Array( obj2Array( editor.widgets.instances )[ 0 ].getClasses() ).sort(), 'classes transfered from data to widget.element' );

assert.areSame( data, bot.getData( 1, 1 ), 'classes transfered from widget.element back to data' );
}, 100 );
} );
}
};

widgetTestsTools.addTests( tcs, {
name: 'basic',
Expand Down
20 changes: 19 additions & 1 deletion tests/plugins/embedsemantic/integration.js
Expand Up @@ -8,11 +8,15 @@
bender.editors = {
classic: {
name: 'editor_classic',
creator: 'replace'
creator: 'replace',
config: {
extraAllowedContent: 'oembed(a,b,c)'
}
}
};

var obj2Array = widgetTestsTools.obj2Array;
var classes2Array = widgetTestsTools.classes2Array;

embedTools.mockJsonp();

Expand Down Expand Up @@ -81,6 +85,20 @@ var tcs = {
assert.isFalse( loadContentSpy.called, 'widget.loadContent was not called on undo' );
}, 100 );
} );
},

'test support for widget classes': function() {
var bot = this.editorBots.classic,
editor = bot.editor;

bot.setData( '<p>x</p><oembed class="a c b">http://widget/classes</oembed><p>x</p>', function() {
wait( function() {
arrayAssert.itemsAreSame( [ 'a', 'b', 'c' ],
classes2Array( obj2Array( editor.widgets.instances )[ 0 ].getClasses() ).sort(), 'classes transfered from data to widget.element' );

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 );
} );
}
};

Expand Down

0 comments on commit d31d1be

Please sign in to comment.