From 199b52b3e72e28897591e7111fafb01b462edda4 Mon Sep 17 00:00:00 2001 From: Artur Delura Date: Tue, 15 Jul 2014 13:24:03 +0200 Subject: [PATCH 01/14] Tests: tagged autop tests. --- tests/core/config/ignoreEmptyParagraph.js | 2 +- tests/core/editable/domfix.js | 2 +- tests/core/editable/domfix2.js | 2 +- tests/core/selection/editor.js | 2 +- tests/plugins/docprops/docprops.js | 2 +- tests/plugins/table/table.js | 2 +- tests/plugins/undo/undo.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/core/config/ignoreEmptyParagraph.js b/tests/core/config/ignoreEmptyParagraph.js index 9b50e85fa90..a56c3df2826 100644 --- a/tests/core/config/ignoreEmptyParagraph.js +++ b/tests/core/config/ignoreEmptyParagraph.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit */ +/* bender-tags: editor,unit,autop */ /* bender-ckeditor-plugins: entities */ bender.test( diff --git a/tests/core/editable/domfix.js b/tests/core/editable/domfix.js index 24a60cc8204..306f7369cc2 100644 --- a/tests/core/editable/domfix.js +++ b/tests/core/editable/domfix.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit */ +/* bender-tags: editor,unit,autop */ var doc = CKEDITOR.document, tools = bender.tools; diff --git a/tests/core/editable/domfix2.js b/tests/core/editable/domfix2.js index a076a71ee23..77931bbb42c 100644 --- a/tests/core/editable/domfix2.js +++ b/tests/core/editable/domfix2.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit */ +/* bender-tags: editor,unit,autop */ var doc = CKEDITOR.document; // This group of tests plays upon the framed content. diff --git a/tests/core/selection/editor.js b/tests/core/selection/editor.js index 773aec6c4f8..6c10bf8b7bd 100644 --- a/tests/core/selection/editor.js +++ b/tests/core/selection/editor.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit */ +/* bender-tags: editor,unit,autop */ 'use strict'; diff --git a/tests/plugins/docprops/docprops.js b/tests/plugins/docprops/docprops.js index a952d991624..3397b44c93d 100644 --- a/tests/plugins/docprops/docprops.js +++ b/tests/plugins/docprops/docprops.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit */ +/* bender-tags: editor,unit,autop */ /* bender-ckeditor-plugins: wysiwygarea,sourcearea,dialog,toolbar,docprops */ bender.editor = { config: { fullPage: 1 } }; diff --git a/tests/plugins/table/table.js b/tests/plugins/table/table.js index 484043d9f99..2c6a6915ec1 100644 --- a/tests/plugins/table/table.js +++ b/tests/plugins/table/table.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit */ +/* bender-tags: editor,unit,autop */ /* bender-ckeditor-plugins: toolbar,button,entities,dialog,table */ ( function() { diff --git a/tests/plugins/undo/undo.js b/tests/plugins/undo/undo.js index fa03dcdaf42..0be8bda1915 100644 --- a/tests/plugins/undo/undo.js +++ b/tests/plugins/undo/undo.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit */ +/* bender-tags: editor,unit,autop */ /* bender-ckeditor-plugins: undo,enterkey,horizontalrule,image,iframe,flash,basicstyles,toolbar,sourcearea */ function isActive( command ) { From 1f9dc92c6d3fa6b2172e72825f4e4d5b2e1bae42 Mon Sep 17 00:00:00 2001 From: Artur Delura Date: Tue, 15 Jul 2014 16:00:02 +0200 Subject: [PATCH 02/14] Added auto paragraphing for nested editable. --- core/editable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/editable.js b/core/editable.js index 8c713e97e8c..95d68b4e6ca 100644 --- a/core/editable.js +++ b/core/editable.js @@ -1101,7 +1101,7 @@ function shouldAutoParagraph( editor, pathBlock, pathBlockLimit ) { return editor.config.autoParagraph !== false && editor.activeEnterMode != CKEDITOR.ENTER_BR && - editor.editable().equals( pathBlockLimit ) && !pathBlock; + (editor.editable().equals( pathBlockLimit ) && !pathBlock) || ( pathBlock && pathBlock.equals( pathBlockLimit ) ); } // Matching an empty paragraph at the end of document. From 0b6ac48c1e7feda45099fda9edf2422855be46c6 Mon Sep 17 00:00:00 2001 From: Artur Delura Date: Wed, 30 Jul 2014 14:16:49 +0200 Subject: [PATCH 03/14] Fixed auto paragraphing in nested editable on enter key. --- plugins/enterkey/plugin.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/plugins/enterkey/plugin.js b/plugins/enterkey/plugin.js index ddbdd1a888b..42167d68191 100644 --- a/plugins/enterkey/plugin.js +++ b/plugins/enterkey/plugin.js @@ -4,6 +4,34 @@ */ ( function() { + + function getClosestEditable( node ) { + var ancestors = node.getParents(), + i = ancestors.length; + + while( i-- ) { + var ancestor = ancestors[ i ]; + if ( ancestor.getAttribute( 'contenteditable' ) === "true" ) { + return ancestor; + } + } + + return null; + } + + function replaceRangeWithClosestEditableRoot( range ) { + var closestEditable = getClosestEditable( range.startContainer ); + + if ( range.root.equals( closestEditable ) ) { + return range; + } else { + var newRange = new CKEDITOR.dom.range( closestEditable ); + + newRange.moveToRange( range ); + return newRange; + } + } + CKEDITOR.plugins.add( 'enterkey', { init: function( editor ) { editor.addCommand( 'enter', { @@ -42,6 +70,10 @@ if ( !range ) return; + // When range is in nested editable, we have to replace range with this one, + // which have root property set to closest editable, to make auto paragraphing work. (#12162) + range = replaceRangeWithClosestEditableRoot( range ); + var doc = range.document; var atBlockStart = range.checkStartOfBlock(), From 460fe99d6c3c9748b8f68411d8a148143a2306df Mon Sep 17 00:00:00 2001 From: Artur Delura Date: Wed, 30 Jul 2014 14:34:11 +0200 Subject: [PATCH 04/14] Fixed code style and added comment pointing to ticket. --- core/editable.js | 3 ++- tests/core/config/ignoreEmptyParagraph.js | 2 +- tests/core/editable/domfix.js | 2 +- tests/core/editable/domfix2.js | 2 +- tests/core/selection/editor.js | 2 +- tests/plugins/docprops/docprops.js | 2 +- tests/plugins/table/table.js | 2 +- tests/plugins/undo/undo.js | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/core/editable.js b/core/editable.js index 95d68b4e6ca..5fab2d8fe00 100644 --- a/core/editable.js +++ b/core/editable.js @@ -1099,9 +1099,10 @@ // Whether in given context (pathBlock, pathBlockLimit and editor settings) // editor should automatically wrap inline contents with blocks. function shouldAutoParagraph( editor, pathBlock, pathBlockLimit ) { + // Check whether pathBlock equals pathBlockLimit to support nested editable (#12162). return editor.config.autoParagraph !== false && editor.activeEnterMode != CKEDITOR.ENTER_BR && - (editor.editable().equals( pathBlockLimit ) && !pathBlock) || ( pathBlock && pathBlock.equals( pathBlockLimit ) ); + ( editor.editable().equals( pathBlockLimit ) && !pathBlock ) || ( pathBlock && pathBlock.equals( pathBlockLimit ) ); } // Matching an empty paragraph at the end of document. diff --git a/tests/core/config/ignoreEmptyParagraph.js b/tests/core/config/ignoreEmptyParagraph.js index a56c3df2826..305576c5fef 100644 --- a/tests/core/config/ignoreEmptyParagraph.js +++ b/tests/core/config/ignoreEmptyParagraph.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit,autop */ +/* bender-tags: editor,unit,autoparagraphing */ /* bender-ckeditor-plugins: entities */ bender.test( diff --git a/tests/core/editable/domfix.js b/tests/core/editable/domfix.js index 306f7369cc2..e0d35b78319 100644 --- a/tests/core/editable/domfix.js +++ b/tests/core/editable/domfix.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit,autop */ +/* bender-tags: editor,unit,autoparagraphing */ var doc = CKEDITOR.document, tools = bender.tools; diff --git a/tests/core/editable/domfix2.js b/tests/core/editable/domfix2.js index 77931bbb42c..692ea9c0609 100644 --- a/tests/core/editable/domfix2.js +++ b/tests/core/editable/domfix2.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit,autop */ +/* bender-tags: editor,unit,autoparagraphing */ var doc = CKEDITOR.document; // This group of tests plays upon the framed content. diff --git a/tests/core/selection/editor.js b/tests/core/selection/editor.js index 6c10bf8b7bd..501c612fbe2 100644 --- a/tests/core/selection/editor.js +++ b/tests/core/selection/editor.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit,autop */ +/* bender-tags: editor,unit,autoparagraphing */ 'use strict'; diff --git a/tests/plugins/docprops/docprops.js b/tests/plugins/docprops/docprops.js index 3397b44c93d..a952d991624 100644 --- a/tests/plugins/docprops/docprops.js +++ b/tests/plugins/docprops/docprops.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit,autop */ +/* bender-tags: editor,unit */ /* bender-ckeditor-plugins: wysiwygarea,sourcearea,dialog,toolbar,docprops */ bender.editor = { config: { fullPage: 1 } }; diff --git a/tests/plugins/table/table.js b/tests/plugins/table/table.js index 2c6a6915ec1..484043d9f99 100644 --- a/tests/plugins/table/table.js +++ b/tests/plugins/table/table.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit,autop */ +/* bender-tags: editor,unit */ /* bender-ckeditor-plugins: toolbar,button,entities,dialog,table */ ( function() { diff --git a/tests/plugins/undo/undo.js b/tests/plugins/undo/undo.js index 0be8bda1915..fa03dcdaf42 100644 --- a/tests/plugins/undo/undo.js +++ b/tests/plugins/undo/undo.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit,autop */ +/* bender-tags: editor,unit */ /* bender-ckeditor-plugins: undo,enterkey,horizontalrule,image,iframe,flash,basicstyles,toolbar,sourcearea */ function isActive( command ) { From 2affb897ddb89da184740bc02fb9df5931900577 Mon Sep 17 00:00:00 2001 From: Artur Delura Date: Wed, 30 Jul 2014 15:07:07 +0200 Subject: [PATCH 05/14] Changed shouldAutoParagraph condition to check just contenteditable attribute. --- core/editable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/editable.js b/core/editable.js index 5fab2d8fe00..b39271057f9 100644 --- a/core/editable.js +++ b/core/editable.js @@ -1102,7 +1102,7 @@ // Check whether pathBlock equals pathBlockLimit to support nested editable (#12162). return editor.config.autoParagraph !== false && editor.activeEnterMode != CKEDITOR.ENTER_BR && - ( editor.editable().equals( pathBlockLimit ) && !pathBlock ) || ( pathBlock && pathBlock.equals( pathBlockLimit ) ); + ( editor.editable().equals( pathBlockLimit ) && !pathBlock ) || ( pathBlock && pathBlock.getAttribute( 'contenteditable' ) == 'true' ); } // Matching an empty paragraph at the end of document. From a75fda615d6d9b390b821e0f932d7abe8b1f67e0 Mon Sep 17 00:00:00 2001 From: Artur Delura Date: Fri, 5 Sep 2014 14:05:03 +0200 Subject: [PATCH 06/14] Refactoring: Looking for closest editable uses getAscendant methodnow. --- plugins/enterkey/plugin.js | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/plugins/enterkey/plugin.js b/plugins/enterkey/plugin.js index 42167d68191..e9e06715c68 100644 --- a/plugins/enterkey/plugin.js +++ b/plugins/enterkey/plugin.js @@ -5,22 +5,10 @@ ( function() { - function getClosestEditable( node ) { - var ancestors = node.getParents(), - i = ancestors.length; - - while( i-- ) { - var ancestor = ancestors[ i ]; - if ( ancestor.getAttribute( 'contenteditable' ) === "true" ) { - return ancestor; - } - } - - return null; - } - function replaceRangeWithClosestEditableRoot( range ) { - var closestEditable = getClosestEditable( range.startContainer ); + var closestEditable = range.startContainer.getAscendant( function( node ) { + return node.getAttribute( 'contenteditable' ) === 'true'; + }, true ); if ( range.root.equals( closestEditable ) ) { return range; From ea203dcdec3a0b8dd371765f45574c45b9225ded Mon Sep 17 00:00:00 2001 From: Artur Delura Date: Fri, 5 Sep 2014 15:55:52 +0200 Subject: [PATCH 07/14] Tests: Added auto paragraphing tests for nested editable. --- tests/core/editable/domfixnestededitable.js | 85 +++++++++++++++++++++ tests/plugins/enter/enterkey.js | 20 ++++- 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 tests/core/editable/domfixnestededitable.js diff --git a/tests/core/editable/domfixnestededitable.js b/tests/core/editable/domfixnestededitable.js new file mode 100644 index 00000000000..6b2ae7dcf4f --- /dev/null +++ b/tests/core/editable/domfixnestededitable.js @@ -0,0 +1,85 @@ +/* bender-tags: editor,unit,autoparagraphing */ +/* bender-ckeditor-plugins: enterkey */ + +( function () { + 'use strict'; + + var doc = CKEDITOR.document; + + // This group of tests plays upon the framed content. + bender.test( { + // Initialize the editor instance. + 'async:init' : function() { + var that = this; + + bender.tools.setUpEditors( { + "editor1": { + name: "editor1" + }, + "editor2": { + name: "editor2", + config: { + autoParagraph: false + } + } + }, function( editors, bots ) { + that.editors = editors; + + // Allow editor creation to complete. + setTimeout( function() { that.callback(); }, 0 ); + } ); + }, + + setupEditor : function( data, callback ) { + var tc = this, editor = tc.editors.editor1; + editor.setData( data, function() { + CKEDITOR.document.getBody().focus(); + editor.focus(); + setTimeout( function() { tc.resume( callback ); }, 200 ); + } ); + tc.wait(); + }, + + // (#12162) + testDomFixNestedEditable: function() { + var tc = this, + editor = this.editors.editor1, + editable = editor.editable(), + expected = [ + '

foo

', + '
', + '
', + '

[]hello

', + '
', + '
' + ].join( '' ); + + bender.tools.selection.setWithHtml( editor, [ + '

foo

', + '
', + '
', + 'h[e]llo', + '
', + '
' + ].join( '' ) ); + + var widget = editable.findOne( 'div[contenteditable="true"]' ), + sel = editor.getSelection(), + range = sel.getRanges()[ 0 ], + firstElement = sel.getStartElement(), + currentPath = new CKEDITOR.dom.elementPath( firstElement, editor.editable() ); + + range.setStart( widget, 0 ); + range.setEnd( widget, 0 ); + sel.selectRanges( [ range ] ); + + editor.fire( 'selectionChange', { + selection : sel, + path : currentPath, + element : firstElement + } ); + + assert.areEqual( expected, bender.tools.selection.getWithHtml( editor ), 'Paragraph should be added.' ); + } + } ); +} )(); \ No newline at end of file diff --git a/tests/plugins/enter/enterkey.js b/tests/plugins/enter/enterkey.js index 58cfd68cb90..8101397e12a 100644 --- a/tests/plugins/enter/enterkey.js +++ b/tests/plugins/enter/enterkey.js @@ -187,6 +187,24 @@ assert.areSame( '

foo

bar

', bot.getData(), 'main mode was used' ); }, + // (#12162) + 'test enter key auto paragraphing in nested editable': function() { + var editor = this.editors.editor; + + bender.tools.selection.setWithHtml( editor, [ + '

foo

', + '
', + '
', + 'hell[o]', + '
', + '
' + ].join( '' ) ); + + editor.execCommand( 'enter' ); + + assert.areEqual( 1, editor.editable().find( '[contenteditable="true"]' ).count(), 'Element should not be duplicated.' ); + }, + /* // Commented out until we decide whether we want to block enter key completely and how. 'test enter key is completely blocked if neither p nor br are allowed': function() { @@ -218,7 +236,7 @@ 'test shift+enter key - end of block, inside inline element followed by bogus br': se( 'editor', '

foo{}

', '

foo
^

' ), 'test shift+enter key - end of list item, inside inline element followed by bogus br': - se( 'editor', '
  • foo{}
', '
  • foo
    ^

' ), + se( 'editor', '
  • foo{}
', '
  • foo
    ^

' ) } ); } )(); \ No newline at end of file From 2fe70f8227780a498cf424f954062cb1c5ea2f41 Mon Sep 17 00:00:00 2001 From: Artur Delura Date: Tue, 16 Sep 2014 10:51:57 +0200 Subject: [PATCH 08/14] Extra check for DOM fragments in getAncestor method. --- plugins/enterkey/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/enterkey/plugin.js b/plugins/enterkey/plugin.js index e9e06715c68..d0bca5a9c2c 100644 --- a/plugins/enterkey/plugin.js +++ b/plugins/enterkey/plugin.js @@ -7,7 +7,7 @@ function replaceRangeWithClosestEditableRoot( range ) { var closestEditable = range.startContainer.getAscendant( function( node ) { - return node.getAttribute( 'contenteditable' ) === 'true'; + return node.type == CKEDITOR.NODE_ELEMENT && node.getAttribute( 'contenteditable' ) == 'true'; }, true ); if ( range.root.equals( closestEditable ) ) { From 4c771de5704d6621a40929ff43730ce572e93d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 16 Sep 2014 13:49:28 +0200 Subject: [PATCH 09/14] Tests: Fixed number of issues in the new test. --- tests/core/editable/domfixnestededitable.js | 87 +++++++-------------- 1 file changed, 28 insertions(+), 59 deletions(-) diff --git a/tests/core/editable/domfixnestededitable.js b/tests/core/editable/domfixnestededitable.js index 6b2ae7dcf4f..c6d2f0b3f19 100644 --- a/tests/core/editable/domfixnestededitable.js +++ b/tests/core/editable/domfixnestededitable.js @@ -1,84 +1,53 @@ /* bender-tags: editor,unit,autoparagraphing */ -/* bender-ckeditor-plugins: enterkey */ ( function () { 'use strict'; var doc = CKEDITOR.document; - // This group of tests plays upon the framed content. bender.test( { // Initialize the editor instance. - 'async:init' : function() { + 'async:init': function() { var that = this; bender.tools.setUpEditors( { - "editor1": { - name: "editor1" - }, - "editor2": { - name: "editor2", - config: { - autoParagraph: false - } + editor1: { + name: 'editor1' } }, function( editors, bots ) { that.editors = editors; - - // Allow editor creation to complete. - setTimeout( function() { that.callback(); }, 0 ); + that.callback(); } ); }, - setupEditor : function( data, callback ) { - var tc = this, editor = tc.editors.editor1; - editor.setData( data, function() { - CKEDITOR.document.getBody().focus(); - editor.focus(); - setTimeout( function() { tc.resume( callback ); }, 200 ); - } ); - tc.wait(); - }, - // (#12162) - testDomFixNestedEditable: function() { - var tc = this, - editor = this.editors.editor1, + 'test autoparagraphing in nested editable': function() { + var editor = this.editors.editor1, editable = editor.editable(), - expected = [ - '

foo

', - '
', - '
', - '

[]hello

', - '
', - '
' - ].join( '' ); - - bender.tools.selection.setWithHtml( editor, [ - '

foo

', - '
', - '
', - 'h[e]llo', - '
', - '
' - ].join( '' ) ); - - var widget = editable.findOne( 'div[contenteditable="true"]' ), - sel = editor.getSelection(), - range = sel.getRanges()[ 0 ], - firstElement = sel.getStartElement(), - currentPath = new CKEDITOR.dom.elementPath( firstElement, editor.editable() ); - - range.setStart( widget, 0 ); - range.setEnd( widget, 0 ); + expected = + '

foo

' + + '
' + + '
' + + '

[]hello

' + + '
' + + '
'; + + bender.tools.selection.setWithHtml( editor, + '

f[o]o

' + + '
' + + '
' + + 'hello' + + '
' + + '
' ); + + var nestedEditable = editable.findOne( 'div[contenteditable="true"]' ), + sel = editor.getSelection(), + range = editor.createRange(); + + range.setStart( nestedEditable, 0 ); + range.setEnd( nestedEditable, 0 ); sel.selectRanges( [ range ] ); - editor.fire( 'selectionChange', { - selection : sel, - path : currentPath, - element : firstElement - } ); - assert.areEqual( expected, bender.tools.selection.getWithHtml( editor ), 'Paragraph should be added.' ); } } ); From f4a55c7e2c01aab857b7bec115740deccc3714b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 16 Sep 2014 14:01:08 +0200 Subject: [PATCH 10/14] Tests: Fixed broken HTML comparison on IE8. --- tests/core/editable/domfixnestededitable.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/core/editable/domfixnestededitable.js b/tests/core/editable/domfixnestededitable.js index c6d2f0b3f19..b6a93a491f9 100644 --- a/tests/core/editable/domfixnestededitable.js +++ b/tests/core/editable/domfixnestededitable.js @@ -25,12 +25,16 @@ var editor = this.editors.editor1, editable = editor.editable(), expected = - '

foo

' + + '

foo@

' + '
' + '
' + - '

[]hello

' + + '

^hello@

' + '
' + - '
'; + '', + htmlMatchingOpts = { + compareSelection: true, + normalizeSelection: true + }; bender.tools.selection.setWithHtml( editor, '

f[o]o

' + @@ -48,7 +52,8 @@ range.setEnd( nestedEditable, 0 ); sel.selectRanges( [ range ] ); - assert.areEqual( expected, bender.tools.selection.getWithHtml( editor ), 'Paragraph should be added.' ); + assert.isInnerHtmlMatching( expected, bender.tools.selection.getWithHtml( editor ), + htmlMatchingOpts, 'Paragraph should be added.' ); } } ); } )(); \ No newline at end of file From e9364d59045000e9af233395864c6477785ee4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 16 Sep 2014 14:05:53 +0200 Subject: [PATCH 11/14] Tests: Webkit needs focus or the selection won't behave naturally. --- tests/core/editable/domfixnestededitable.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/core/editable/domfixnestededitable.js b/tests/core/editable/domfixnestededitable.js index b6a93a491f9..be9e238bd70 100644 --- a/tests/core/editable/domfixnestededitable.js +++ b/tests/core/editable/domfixnestededitable.js @@ -48,6 +48,7 @@ sel = editor.getSelection(), range = editor.createRange(); + nestedEditable.focus(); range.setStart( nestedEditable, 0 ); range.setEnd( nestedEditable, 0 ); sel.selectRanges( [ range ] ); From e36fa168fa16bece7a8743549482ad7eddb445f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 16 Sep 2014 14:37:29 +0200 Subject: [PATCH 12/14] Tests: You don't want auto paragraphing to step in. --- tests/plugins/enter/enterkey.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/plugins/enter/enterkey.js b/tests/plugins/enter/enterkey.js index 8101397e12a..ff9b4495531 100644 --- a/tests/plugins/enter/enterkey.js +++ b/tests/plugins/enter/enterkey.js @@ -188,8 +188,8 @@ }, // (#12162) - 'test enter key auto paragraphing in nested editable': function() { - var editor = this.editors.editor; + 'test enter key directly in nested editable': function() { + var editor = this.editors.editorNoAutoParagraph; bender.tools.selection.setWithHtml( editor, [ '

foo

', From 5f435ab37c057102eae7ba01d625313b345247df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 16 Sep 2014 14:51:07 +0200 Subject: [PATCH 13/14] Tests: Made enter key test more precise. --- tests/plugins/enter/enterkey.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/plugins/enter/enterkey.js b/tests/plugins/enter/enterkey.js index ff9b4495531..c1b0adc036f 100644 --- a/tests/plugins/enter/enterkey.js +++ b/tests/plugins/enter/enterkey.js @@ -189,20 +189,27 @@ // (#12162) 'test enter key directly in nested editable': function() { - var editor = this.editors.editorNoAutoParagraph; - - bender.tools.selection.setWithHtml( editor, [ - '

foo

', - '
', - '
', - 'hell[o]', - '
', - '
' - ].join( '' ) ); + var editor = this.editors.editorNoAutoParagraph, + expected = '

foo

' + + '
' + + '
' + + '

hell@

' + + '

@

' + + '
' + + '
'; + + bender.tools.selection.setWithHtml( editor, + '

foo

' + + '
' + + '
' + + 'hell[o]' + + '
' + + '
' ); editor.execCommand( 'enter' ); - assert.areEqual( 1, editor.editable().find( '[contenteditable="true"]' ).count(), 'Element should not be duplicated.' ); + assert.isInnerHtmlMatching( expected, editor.editable().getHtml().replace( / data-cke-expando="\d+"/g, '' ), + 'New paragraphs should be created.' ); }, /* From 93d3a21d4e1005b4f659df470ff8b1af8e608823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Tue, 16 Sep 2014 15:02:16 +0200 Subject: [PATCH 14/14] Changelog entry. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index ef59cc53de5..7ab0bd3ede4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,7 @@ Fixed Issues: * [#12398](http://dev.ckeditor.com/ticket/12398): Fixed: Maximize does not work on instance without a [title](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-title). * [#12097](http://dev.ckeditor.com/ticket/12097): Fixed: JAWS not reading number of list options correctly in colors list box. * [#12411](http://dev.ckeditor.com/ticket/12411): Fixed: [Page Break](http://ckeditor.com/addon/pagebreak) used directly in the editable breaks the editor. +* [#12162](http://dev.ckeditor.com/ticket/12162): Fixed: Auto paragraphing and enter key in nested editables. ## CKEditor 4.4.4