-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #734 from ckeditor/t/704
[#704] Fix broken widget after using Ctrl+Z in Edge.
- Loading branch information
Showing
5 changed files
with
136 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/plugins/widget/integration/wysiwygarea/manual/preventofremovingdiv.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<textarea id="editor1" name="editor1"> | ||
<figure class="image illustration" style="float:left"> | ||
<img alt="" height="266" src="http://c.cksource.com/a/1/img/demo/brownie.jpg" width="400" /> | ||
<figcaption>Bon Appétit!</figcaption> | ||
</figure> | ||
<p>Preheat the oven to <strong>350°F</strong> and grease the baking pan. | ||
Combine the flour, sugar and cocoa powder in a medium bowl. In another small bowl, whisk together the butter and eggs. Stir the two mixtures until just combined. | ||
Bake the brownies for 25 to 35 minutes. Remove from the oven and let it cool for 5 minutes. | ||
</p> | ||
</textarea> | ||
<pre id="output" style="background-color: lightgreen;"></pre> | ||
<script> | ||
if ( !CKEDITOR.env.edge ) { | ||
bender.ignore(); | ||
} | ||
|
||
var editor = CKEDITOR.replace( 'editor1', { | ||
height: '600px' | ||
} ); | ||
var output = document.getElementById( 'output' ); | ||
editor.on( 'instanceReady', function() { | ||
editor.editable().$.onkeyup = function() { | ||
output.innerText = editor.editable().getFirst().getName(); | ||
}; | ||
} ); | ||
</script> |
11 changes: 11 additions & 0 deletions
11
tests/plugins/widget/integration/wysiwygarea/manual/preventofremovingdiv.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@bender-ui: collapsed | ||
@bender-tags: bug, 4.8.0, 704 | ||
@bender-ckeditor-plugins: image2, wysiwygarea, undo, sourcearea | ||
|
||
---- | ||
1. Put caret in the text on the right and type some text. | ||
1. Use `Ctrl + Z` or `Cmd + Z` shortcut to make undo few times. | ||
|
||
**Expected:** Text returns to previous form. Below the editor, you should see `div` on green background. | ||
|
||
**Unexpected:** Text moves below the image. Below editor, it will be written `figure` instead of `div` on the green background. |
58 changes: 58 additions & 0 deletions
58
tests/plugins/widget/integration/wysiwygarea/superflousdoesntremovedivwrapper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* bender-ckeditor-plugins: widget,wysiwygarea,undo,toolbar */ | ||
|
||
|
||
( function() { | ||
'use strict'; | ||
|
||
bender.editor = { | ||
config: { | ||
allowedContent: true | ||
} | ||
}; | ||
|
||
bender.test( { | ||
// #704 | ||
'test keeping widget wrapper in editor when superfluous elements are checked': function() { | ||
CKEDITOR.plugins.add( 'test', { | ||
requires: 'widget', | ||
init: function( editor ) { | ||
editor.widgets.add( 'test', { | ||
upcast: function( element ) { | ||
if ( element.hasClass( 'test' ) ) { | ||
return true; | ||
} | ||
}, | ||
|
||
init: function() { | ||
this.element.setStyle( 'background-color', '#FFBB00' ); | ||
this.element.setStyle( 'padding', '30px' ); | ||
} | ||
} ); | ||
} | ||
} ); | ||
bender.editorBot.create( { | ||
name: 'test_widget', | ||
startupData: '<h2 class="test">Test</h2><p>Preheat the oven to</p>', | ||
config: { | ||
extraPlugins: 'test', | ||
allowedContent: true | ||
} | ||
}, function( bot ) { | ||
var editor = bot.editor; | ||
|
||
editor.editable().fire( 'keydown', new CKEDITOR.dom.event( { | ||
keyCode: 90, | ||
ctrlKey: true, | ||
shiftKey: false | ||
} ) ); | ||
|
||
var snap = editor.getSnapshot(); | ||
editor.loadSnapshot( snap ); | ||
|
||
editor.editable().fire( 'keyup', new CKEDITOR.dom.event( {} ) ); | ||
|
||
assert.areSame( 'div', editor.editable().getFirst().getName().toLowerCase() ); | ||
} ); | ||
} | ||
} ); | ||
} )(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters