diff --git a/plugins/wysiwygarea/plugin.js b/plugins/wysiwygarea/plugin.js index 49b9188228f..1f283a7214e 100644 --- a/plugins/wysiwygarea/plugin.js +++ b/plugins/wysiwygarea/plugin.js @@ -161,10 +161,12 @@ doc.getDocumentElement().addClass( doc.$.compatMode ); } - // Prevent IE/Edge from leaving a new paragraph/div after deleting all contents in body. (http://dev.ckeditor.com/ticket/6966, http://dev.ckeditor.com/ticket/13142) + // Prevent IE/Edge from leaving a new paragraph/div after deleting all contents in body (http://dev.ckeditor.com/ticket/6966, http://dev.ckeditor.com/ticket/13142). if ( CKEDITOR.env.ie && !CKEDITOR.env.edge && editor.enterMode != CKEDITOR.ENTER_P ) { removeSuperfluousElement( 'p' ); - } else if ( CKEDITOR.env.edge && editor.enterMode != CKEDITOR.ENTER_DIV ) { + } + // Starting from Edge 15 additional `div` is not added to the editor. + else if ( CKEDITOR.env.edge && CKEDITOR.env.version < 15 && editor.enterMode != CKEDITOR.ENTER_DIV ) { removeSuperfluousElement( 'div' ); } @@ -297,7 +299,7 @@ var elements = doc.getElementsByTag( tagName ); if ( lockRetain ) { if ( elements.count() == 1 && !elements.getItem( 0 ).getCustomData( 'retain' ) && - !elements.getItem( 0 ).hasAttribute( 'data-cke-temp' ) ) { + CKEDITOR.tools.isEmpty( elements.getItem( 0 ).getAttributes() ) ) { elements.getItem( 0 ).remove( 1 ); } lockRetain = false; diff --git a/tests/plugins/widget/integration/wysiwygarea/manual/preventofremovingdiv.html b/tests/plugins/widget/integration/wysiwygarea/manual/preventofremovingdiv.html new file mode 100644 index 00000000000..6d93fc22140 --- /dev/null +++ b/tests/plugins/widget/integration/wysiwygarea/manual/preventofremovingdiv.html @@ -0,0 +1,26 @@ + +
+ diff --git a/tests/plugins/widget/integration/wysiwygarea/manual/preventofremovingdiv.md b/tests/plugins/widget/integration/wysiwygarea/manual/preventofremovingdiv.md new file mode 100644 index 00000000000..404841304a4 --- /dev/null +++ b/tests/plugins/widget/integration/wysiwygarea/manual/preventofremovingdiv.md @@ -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. diff --git a/tests/plugins/widget/integration/wysiwygarea/superflousdoesntremovedivwrapper.js b/tests/plugins/widget/integration/wysiwygarea/superflousdoesntremovedivwrapper.js new file mode 100644 index 00000000000..4dff807327d --- /dev/null +++ b/tests/plugins/widget/integration/wysiwygarea/superflousdoesntremovedivwrapper.js @@ -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: 'Preheat the oven to
', + 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() ); + } ); + } + } ); +} )(); diff --git a/tests/plugins/wysiwygarea/superfluouselement.js b/tests/plugins/wysiwygarea/superfluouselement.js index 919416d6be0..e87568438d7 100644 --- a/tests/plugins/wysiwygarea/superfluouselement.js +++ b/tests/plugins/wysiwygarea/superfluouselement.js @@ -16,7 +16,7 @@ bender.editor = { }; bender.test( { - 'Test removing superfluousinserted by IE11': function() { + 'test removing superfluous
inserted by IE11': function() { if ( !CKEDITOR.env.ie || CKEDITOR.env.edge ) { assert.ignore(); } @@ -44,8 +44,8 @@ bender.test( { wait(); }, - 'Test removing superfluous