-
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.
- Loading branch information
Showing
6 changed files
with
301 additions
and
20 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
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
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,8 @@ | ||
div { | ||
border: 1px solid red; | ||
margin: 1px; | ||
} | ||
|
||
p { | ||
border: 1px solid green; | ||
} |
44 changes: 44 additions & 0 deletions
44
tests/core/editable/manual/notwantedelementsonselectallandbackspaceedge.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,44 @@ | ||
<link rel="stylesheet" type="text/css" href="_assets/styles.css" /> | ||
<script> | ||
CKEDITOR.disableAutoInline = true; | ||
</script> | ||
<h2>Inline editor</h2> | ||
<h1 id="editor0" contenteditable="true"> | ||
Blockless inline editor | ||
</h1> | ||
|
||
<h2>Enter mode: P</h2> | ||
<textarea name="editor1"> | ||
CKEditor instance. | ||
</textarea> | ||
|
||
<h2>Enter mode: DIV</h2> | ||
<textarea name="editor2"> | ||
<div>Test</div> | ||
</textarea> | ||
|
||
<h2>Enter mode: BR</h2> | ||
<textarea name="editor3"> | ||
CKEditor instance. | ||
</textarea> | ||
<script> | ||
( function() { | ||
var cfg = { | ||
contentsCss: '_assets/styles.css', | ||
extraPlugins: 'wysiwygarea,sourcearea,htmlwriter,entities,toolbar,elementspath,undo,clipboard,format,basicstyles,enterkey,div' | ||
}; | ||
|
||
CKEDITOR.inline( 'editor0', { | ||
plugins: 'toolbar,basicstyles,floatingspace,undo,format,stylescombo,enterkey' | ||
} ); | ||
|
||
cfg.enterMode = CKEDITOR.ENTER_P; | ||
CKEDITOR.replace( 'editor1', cfg ); | ||
|
||
cfg.enterMode = CKEDITOR.ENTER_DIV; | ||
CKEDITOR.replace( 'editor2', cfg ); | ||
|
||
cfg.enterMode = CKEDITOR.ENTER_BR; | ||
CKEDITOR.replace( 'editor3', cfg ); | ||
} )(); | ||
</script> |
28 changes: 28 additions & 0 deletions
28
tests/core/editable/manual/notwantedelementsonselectallandbackspaceedge.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,28 @@ | ||
@bender-tags: 4.5.4, tc, 13142 | ||
@bender-ui: collapsed | ||
@bender-ckeditor-plugins: format, stylescombo, toolbar, wysiwygarea, undo | ||
|
||
---- | ||
|
||
For each editor instance: | ||
|
||
1. Choose one and create: | ||
1. Empty paragraph. | ||
2. Single paragraph with one line of text. | ||
3. Multiple paragraphs with text. | ||
2. Select it using Ctrl+A. | ||
3. Press one: | ||
1. backspace | ||
2. delete | ||
3. alphanumeric key | ||
4. enter key | ||
5. start typing some text. | ||
4. Repeat. | ||
|
||
**Expected result:** The editable should contain only elements typical for their respective enter modes. | ||
|
||
Notes: | ||
|
||
- <p> elements are colored green and <div> elements are colored red. | ||
- You may experience a flashing <div> (Edge) or <p> (IE) element in all but the blockless inline editor. | ||
- On Edge and Firefox an extra paragraph is created when you select all and press `Enter` it is a known bug. |
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,181 @@ | ||
/* bender-tags: 13142 */ | ||
/* bender-ckeditor-plugins: enterkey,wysiwygarea */ | ||
|
||
// This test simulates the situation that occurs when the user selects | ||
// the whole content and presses backspace/delete or starts typing. | ||
// Both IE and Edge tend to insert a superfluous element | ||
// (<p> and <div> respectively) into the empty editable. | ||
|
||
'use strict'; | ||
|
||
bender.editor = { | ||
creator: 'replace', | ||
config: { | ||
enterMode: CKEDITOR.ENTER_BR | ||
} | ||
}; | ||
|
||
bender.test( { | ||
'Test removing superfluous <p> inserted by IE11': function() { | ||
if ( !CKEDITOR.env.ie || CKEDITOR.env.edge ) { | ||
assert.ignore(); | ||
} | ||
|
||
var editor = this.editor; | ||
|
||
editor.setData( '', function() { | ||
resume( function() { | ||
|
||
bender.tools.setHtmlWithSelection( editor, '^' ); | ||
|
||
editor.editable().fire( 'keydown', new CKEDITOR.dom.event( { | ||
keyCode: 8, | ||
ctrlKey: false, | ||
shiftKey: false | ||
} ) ); | ||
|
||
bender.tools.setHtmlWithSelection( editor, '<p>^</p>' ); | ||
|
||
editor.editable().fire( 'keyup' ); | ||
|
||
assert.isInnerHtmlMatching( '^', bender.tools.getHtmlWithSelection( editor ) ); | ||
} ); | ||
} ); | ||
wait(); | ||
}, | ||
|
||
'Test removing superfluous <div> inserted by Edge': function() { | ||
if ( !CKEDITOR.env.edge ) { | ||
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, '<div>k^</div>' ); | ||
|
||
editor.editable().fire( 'keyup' ); | ||
|
||
assert.isInnerHtmlMatching( 'k^', bender.tools.getHtmlWithSelection( editor ) ); | ||
} ); | ||
} ); | ||
wait(); | ||
}, | ||
|
||
'Test not removing non-superfluous <div> in Edge': function() { | ||
if ( !CKEDITOR.env.edge ) { | ||
assert.ignore(); | ||
} | ||
|
||
var editor = this.editor; | ||
|
||
editor.setData( '', function() { | ||
resume( function() { | ||
bender.tools.setHtmlWithSelection( editor, '<div>^</div>' ); | ||
|
||
editor.editable().fire( 'keydown', new CKEDITOR.dom.event( { | ||
keyCode: 75, | ||
ctrlKey: false, | ||
shiftKey: false | ||
} ) ); | ||
|
||
editor.editable().fire( 'keyup' ); | ||
|
||
assert.isInnerHtmlMatching( '<div>^ </div>', bender.tools.getHtmlWithSelection( editor ) ); | ||
} ); | ||
} ); | ||
wait(); | ||
}, | ||
|
||
'Test removing superfluous <div> when typing': function() { | ||
if ( !CKEDITOR.env.edge ) { | ||
assert.ignore(); | ||
} | ||
|
||
var editor = this.editor; | ||
|
||
editor.setData( '', function() { | ||
resume( function() { | ||
bender.tools.setHtmlWithSelection( editor, '^' ); | ||
|
||
// Expected behaviour: | ||
// keydown <- mark divs for retention, disable marking | ||
// keydown <- do nothing | ||
// ... | ||
// keyup <- remove not marked divs, enable marking | ||
// keyup <- do nothing | ||
// ... | ||
editor.editable().fire( 'keydown', new CKEDITOR.dom.event( { | ||
keyCode: 75, | ||
ctrlKey: false, | ||
shiftKey: false | ||
} ) ); | ||
|
||
bender.tools.setHtmlWithSelection( editor, '<div>k^</div>' ); | ||
|
||
editor.editable().fire( 'keydown', new CKEDITOR.dom.event( { | ||
keyCode: 76, | ||
ctrlKey: false, | ||
shiftKey: false | ||
} ) ); | ||
|
||
editor.editable().fire( 'keydown', new CKEDITOR.dom.event( { | ||
keyCode: 77, | ||
ctrlKey: false, | ||
shiftKey: false | ||
} ) ); | ||
|
||
editor.editable().fire( 'keyup' ); | ||
|
||
editor.editable().fire( 'keyup' ); | ||
|
||
editor.editable().fire( 'keyup' ); | ||
|
||
assert.isInnerHtmlMatching( 'k^', bender.tools.getHtmlWithSelection( editor ) ); | ||
} ); | ||
} ); | ||
wait(); | ||
}, | ||
|
||
'Test not removing non-superfluous <div> when typing': function() { | ||
if ( !CKEDITOR.env.edge ) { | ||
assert.ignore(); | ||
} | ||
|
||
var editor = this.editor; | ||
|
||
editor.setData( '', function() { | ||
resume( function() { | ||
bender.tools.setHtmlWithSelection( editor, '<div>^</div>' ); | ||
|
||
editor.editable().fire( 'keydown', new CKEDITOR.dom.event( { | ||
keyCode: 75, | ||
ctrlKey: false, | ||
shiftKey: false | ||
} ) ); | ||
|
||
editor.editable().fire( 'keydown', new CKEDITOR.dom.event( { | ||
keyCode: 76, | ||
ctrlKey: false, | ||
shiftKey: false | ||
} ) ); | ||
|
||
editor.editable().fire( 'keyup' ); | ||
|
||
editor.editable().fire( 'keyup' ); | ||
|
||
assert.isInnerHtmlMatching( '<div>^ </div>', bender.tools.getHtmlWithSelection( editor ) ); | ||
} ); | ||
} ); | ||
wait(); | ||
} | ||
|
||
} ); |