Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Smart text nodes rerendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
f1ames committed Mar 22, 2018
1 parent 6866256 commit 52c8c2c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/view/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import remove from '@ckeditor/ckeditor5-utils/src/dom/remove';
import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import isText from '@ckeditor/ckeditor5-utils/src/dom/istext';
import diffToChanges from '@ckeditor/ckeditor5-utils/src/difftochanges';

/**
* Renderer updates DOM structure and selection, to make them a reflection of the view structure and selection.
Expand Down Expand Up @@ -426,7 +427,15 @@ export default class Renderer {
}

if ( actualText != expectedText ) {
domText.data = expectedText;
const actions = diffToChanges( diff( actualText, expectedText ), expectedText );

for ( const action of actions ) {
if ( action.type === 'insert' ) {
domText.insertData( action.index, action.values.join( '' ) );
} else { // 'delete'
domText.deleteData( action.index, action.howMany );
}
}
}
}

Expand Down

0 comments on commit 52c8c2c

Please sign in to comment.