Skip to content

Commit

Permalink
Check editable's content after clearing the range.
Browse files Browse the repository at this point in the history
  • Loading branch information
Comandeer committed Dec 1, 2020
1 parent c2c6c8e commit 92cc32e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions core/editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1648,11 +1648,8 @@
function insert( editable, type, data, range ) {
var editor = editable.editor,
dontFilter = false,
html = editable.getHtml(),
// Instead of getData method, we directly check the HTML
// due to the fact that internal getData operates on latest snapshot,
// not the current content (#4301).
isEmptyEditable = html === '' || html.match( emptyParagraphRegexp );
html,
isEmptyEditable;

if ( type == 'unfiltered_html' ) {
type = 'html';
Expand Down Expand Up @@ -1690,6 +1687,14 @@

prepareRangeToDataInsertion( that );

html = editable.getHtml(),
// Instead of getData method, we directly check the HTML
// due to the fact that internal getData operates on latest snapshot,
// not the current content.
// Checking it after clearing the range's content will give the
// most correct results (#4301).
isEmptyEditable = html === '' || html.match( emptyParagraphRegexp );

// When enter mode is set to div and content wrapped with div is pasted,
// we must ensure that no additional divs are created (#2751).
if ( editor.enterMode === CKEDITOR.ENTER_DIV && isEmptyEditable ) {
Expand Down

0 comments on commit 92cc32e

Please sign in to comment.