Skip to content

Commit

Permalink
Merge branch 't/13158' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed May 4, 2015
2 parents 3127f92 + df6b3a0 commit 24d1c51
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CKEditor 4 Changelog
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.
* 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
6 changes: 4 additions & 2 deletions plugins/widget/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1814,8 +1814,10 @@
// Finalize creation AFTER (20) new data was set.
okListener = dialog.once( 'ok', finalizeCreation, null, null, 20 );

cancelListener = dialog.once( 'cancel', function() {
editor.widgets.destroy( instance, true );
cancelListener = dialog.once( 'cancel', function( evt ) {
if ( !( evt.data && evt.data.hide === false ) ) {
editor.widgets.destroy( instance, true );
}
} );

dialog.once( 'hide', function() {
Expand Down
44 changes: 42 additions & 2 deletions tests/plugins/widget/editing.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@

widget.focus();

widget.on( 'edit', function( evt ) {
widget.once( 'edit', function( evt ) {
editFired += 1;
evt.cancel();
} );
Expand All @@ -650,6 +650,46 @@

assert.areSame( 1, editFired, 'Widget.edit was called' );
} );
},

'test cancelling cancel widget dialog does not destroy widget (#13158).': function() {
var editor = this.editor,
originalConfirm = window.confirm;

// Setup.
window.confirm = function() {
return false;
};

this.editorBot.setData( '<p>foo</p>', function() {
editor.once( 'dialogShow', function( evt ) {
var spy = sinon.stub( editor.widgets, 'destroy' ),
dialog = evt.data;

dialog.once( 'cancel', function() {
resume( function() {
assert.isFalse( spy.called );

// Teardown.
window.confirm = function() {
return true;
};
dialog.getButton( 'cancel' ).click();
window.confirm = originalConfirm;
} );
} );

// We have to wait here because of this:
// https://github.com/cksource/ckeditor-dev/blob/4fbe94b5fb4be9b1d440462cbc8f0c75e00350a5/plugins/dialog/plugin.js#L910
setTimeout( function() {
dialog.getContentElement( 'info', 'value1' ).setValue( 'bar' );
dialog.getButton( 'cancel' ).click();
}, 200 );
} );

editor.execCommand( 'test1' );
wait();
} );
}
} );
} )();
} )();
7 changes: 7 additions & 0 deletions tests/tickets/13158/1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="editor" contenteditable="true" >
<p>Some proper link: http://i.imgur.com/Z3ilPBI.jpg</p>
</div>

<script>
CKEDITOR.replace( 'editor' );
</script>
12 changes: 12 additions & 0 deletions tests/tickets/13158/1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@bender-tags: 4.5.0, tc, widget, widgetcore
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, embed

1. Copy some proper link into clipboard.
2. Click "embed" button to open dialog.
3. Paste link into text input.
4. Click "cancel" (system popup will be shown).
5. Click "cancel" in the system popup.
6. Click "ok" in the embed popup.

**Expected:** Embed media should be added.

0 comments on commit 24d1c51

Please sign in to comment.