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: '

Test

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 superfluous

inserted 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

inserted by Edge': function() { - if ( !CKEDITOR.env.edge ) { + 'test removing superfluous
inserted by Edge': function() { + if ( !CKEDITOR.env.edge || CKEDITOR.env.version >= 15 ) { assert.ignore(); } @@ -70,8 +70,8 @@ bender.test( { wait(); }, - 'Test not removing non-superfluous
in Edge': function() { - if ( !CKEDITOR.env.edge ) { + 'test not removing non-superfluous
in Edge': function() { + if ( !CKEDITOR.env.edge || CKEDITOR.env.version >= 15 ) { assert.ignore(); } @@ -95,8 +95,8 @@ bender.test( { wait(); }, - 'Test removing superfluous
when typing': function() { - if ( !CKEDITOR.env.edge ) { + 'test removing superfluous
when typing in Edge': function() { + if ( !CKEDITOR.env.edge || CKEDITOR.env.version >= 15 ) { assert.ignore(); } @@ -145,8 +145,8 @@ bender.test( { wait(); }, - 'Test not removing non-superfluous
when typing': function() { - if ( !CKEDITOR.env.edge ) { + 'test not removing non-superfluous
when typing in Edge': function() { + if ( !CKEDITOR.env.edge || CKEDITOR.env.version >= 15 ) { assert.ignore(); } @@ -179,7 +179,7 @@ bender.test( { }, // http://dev.ckeditor.com/ticket/14831 - 'Test not removing [data-cke-temp]
when typing': function() { + 'test not removing [data-cke-temp]
when typing': function() { if ( !CKEDITOR.env.edge || CKEDITOR.env.version < 14 ) { assert.ignore(); } @@ -227,5 +227,31 @@ bender.test( { } ); } ); wait(); + }, + + 'test not removing
with any attributes in Edge': function() { + if ( !CKEDITOR.env.edge || CKEDITOR.env.version >= 15 ) { + assert.ignore(); + } + + var editor = this.editor; + + editor.setData( '', function() { + resume( function() { + + editor.editable().fire( 'keydown', new CKEDITOR.dom.event( { + keyCode: 75, + ctrlKey: false, + shiftKey: false + } ) ); + + bender.tools.setHtmlWithSelection( editor, '
k^
' ); + + editor.editable().fire( 'keyup', new CKEDITOR.dom.event( {} ) ); + + assert.isInnerHtmlMatching( '
k^
', bender.tools.getHtmlWithSelection( editor ) ); + } ); + } ); + wait(); } } );