-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for: editor.insertHtml
and editor.insertElement
pollutes editable with empty spans
#2987
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
d915eef
Tests: added manual test.
engineering-this a4e4faa
Tests: added unit test.
engineering-this f46ee15
Fixed: editor.insertHtml pollutes editor with empty spans.
engineering-this e769953
Changelog: new entry.
engineering-this b068efc
Tests: manual test step corrections.
engineering-this 6966a78
Remove extra new line.
engineering-this cc224b8
Exented comments with more details and ticket id.
engineering-this 8434e51
Move variable declaration to grouped variables.
engineering-this 32c4f79
Tests: removed dash in test step.
engineering-this 969c9af
Test: renamed file.
engineering-this 9200068
Tests: added 'insert element' button.
engineering-this 817c6c7
Renamed variable.
engineering-this e4fb79b
Remove empty inline elements after insertElement.
engineering-this 17feaad
Tests: moved into existing file.
engineering-this 70c2394
Tests: reworked, added new test cases.
engineering-this a6a09d0
Fix selection after removing elements.
engineering-this 4ed576c
Tests: added steps.
engineering-this fac6751
Changelog: added info about fixing editor.insertElement a well.
engineering-this 785178f
Tests: update version tag.
engineering-this eb62804
Replace inline conditional with na if statement.
engineering-this 623f01c
Tests: add more methods to be tested.
engineering-this 3991270
Tests: refactoring.
engineering-this 7562ea7
Tests: add test case.
engineering-this 3ab4b8a
Tests: further refactoring.
engineering-this f4f2c5a
Tests: update for IE and ignore.
engineering-this 782950b
Changes: update entry.
engineering-this 8d3cfcd
Tests: add TC.
engineering-this 8c8f342
Correct conditional for Edge.
engineering-this b77b2b6
Remove IE variable space as test is ignored for IE.
engineering-this fdb2859
Tests: add case.
engineering-this ab6c760
Simplify while condition.
engineering-this 4017e77
Tests: reword test description.
engineering-this 4400615
Styling.
jacekbogdanski 6f40410
Added extensive comment.
f1ames f90f93f
Tests: Two new unit test cases added.
f1ames d1f5543
Tests: fix normalizeHtml method removing non empty paragraphs.
engineering-this efee373
Tests: added various elements to be tested.
engineering-this 940725d
Revert "Changes: update entry."
engineering-this 2c773b0
Tests: fix for IE.
engineering-this 45733e3
Updated changelog entry.
f1ames c3aa928
Refactoring.
f1ames 7f08cc6
Tests: remove empty paragraph from the end of normalized html string.
engineering-this File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,76 @@ | ||
<textarea id="editor"> | ||
<p> | ||
<span>Foo bar</span> | ||
</p> | ||
<ul> | ||
<li> | ||
<span>Foo bar</span> | ||
<ul> | ||
<li> | ||
<span>Foo bar</span> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
<div> | ||
<table border="1" cellspacing="1" cellpadding="1" style="width: 500px;"> | ||
<tbody> | ||
<tr> | ||
<td> | ||
<span>Foo bar</span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<span>Foo bar</span> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</textarea> | ||
|
||
<p id="controls"> | ||
<button data-button="insert-html">Insert html</button> | ||
<button data-button="insert-html-range">Insert html into range</button> | ||
<button data-button="insert-element">Insert element</button> | ||
<button data-button="insert-element-range">Insert element into range</button> | ||
<button data-button="insert-text">Insert text</button> | ||
<button data-button="reset">Reset editor</button> | ||
</p> | ||
|
||
<script> | ||
var initialData = CKEDITOR.document.findOne( '#editor' ).getValue(), | ||
editor = CKEDITOR.replace( 'editor', { | ||
allowedContent: true, | ||
height: 500 | ||
} ), | ||
elementHtml = '<div><div>div</div></div>'; | ||
|
||
CKEDITOR.addCss( | ||
'span{padding:10px;border:solid 1px red;}' + | ||
'li,div{margin:20px 0;}' + | ||
'td{padding:20px 0;}' | ||
); | ||
|
||
CKEDITOR.document.findOne( '#controls' ).on( 'click', function( evt ) { | ||
var editable = editor.editable(), | ||
range = editor.getSelection().getRanges()[ 0 ], | ||
element = CKEDITOR.dom.element.createFromHtml( elementHtml ); | ||
|
||
switch ( evt.data.getTarget().getAttribute( 'data-button' ) ) { | ||
case 'insert-html': | ||
return editor.insertHtml( elementHtml ); | ||
case 'insert-html-range': | ||
return editable.insertHtmlIntoRange( elementHtml, range ); | ||
case 'insert-element': | ||
return editor.insertElement( element ); | ||
case 'insert-element-range': | ||
return editable.insertElementIntoRange( element, range ); | ||
case 'insert-text': | ||
return editor.insertText( 'text' ); | ||
case 'reset': | ||
editor.setData( initialData ); | ||
} | ||
} ); | ||
</script> |
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,23 @@ | ||
@bender-tags: bug, 4.12.0, 2813 | ||
@bender-ui: collapsed | ||
@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, sourcearea, list, table | ||
|
||
## For each insert button and for each element | ||
|
||
1. After each case use `reset editor` button. | ||
|
||
1. Select the word `bar`. | ||
|
||
1. Press button. | ||
|
||
## Expected | ||
|
||
- `Insert text` button: `text` replaces selected word inside the rectangle. | ||
|
||
- Any other button: `div` replaces selected word outside the rectangle. | ||
|
||
## Unexpected | ||
|
||
Clicked button causes the creation of an additional rectangle. | ||
|
||
**NOTE:** Because of [#3042](https://github.com/ckeditor/ckeditor-dev/issues/3042) two nested divs are used for insertion. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.