Editor performance fixes

This commit is contained in:
Benoit Schweblin 2018-02-25 15:45:16 +00:00
parent 57f45f0c5f
commit 34e15ee1c4
2 changed files with 26 additions and 20 deletions

View File

@ -395,10 +395,11 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
const debouncedRefreshPreview = debounce(refreshPreview, 50); const debouncedRefreshPreview = debounce(refreshPreview, 50);
const onEditorChanged = let newSectionList;
(sectionList = this.sectionList, selectionRange = this.selectionRange) => { let newSelectionRange;
if (this.sectionList !== sectionList) { const onEditorChanged = debounce(() => {
this.sectionList = sectionList; if (this.sectionList !== newSectionList) {
this.sectionList = newSectionList;
this.$emit('sectionList', this.sectionList); this.$emit('sectionList', this.sectionList);
if (instantPreview) { if (instantPreview) {
refreshPreview(); refreshPreview();
@ -406,15 +407,17 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
debouncedRefreshPreview(); debouncedRefreshPreview();
} }
} }
if (this.selectionRange !== selectionRange) { if (this.selectionRange !== newSelectionRange) {
this.selectionRange = selectionRange; this.selectionRange = newSelectionRange;
this.$emit('selectionRange', this.selectionRange); this.$emit('selectionRange', this.selectionRange);
} }
this.saveContentState(); this.saveContentState();
}; }, 10);
this.clEditor.selectionMgr.on('selectionChanged', this.clEditor.selectionMgr.on('selectionChanged', (start, end, selectionRange) => {
(start, end, selectionRange) => onEditorChanged(undefined, selectionRange)); newSelectionRange = selectionRange;
onEditorChanged();
});
/* ----------------------------- /* -----------------------------
* Inline images * Inline images
@ -502,8 +505,10 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
triggerImgCacheGc(); triggerImgCacheGc();
}); });
this.clEditor.on('contentChanged', this.clEditor.on('contentChanged', (content, diffs, sectionList) => {
(content, diffs, sectionList) => onEditorChanged(sectionList)); newSectionList = sectionList;
onEditorChanged();
});
// clEditorSvc.setPreviewElt(element[0].querySelector('.preview__inner-2')) // clEditorSvc.setPreviewElt(element[0].querySelector('.preview__inner-2'))
// var previewElt = element[0].querySelector('.preview') // var previewElt = element[0].querySelector('.preview')

View File

@ -118,6 +118,7 @@
text-align: center; text-align: center;
background-color: #007acc; background-color: #007acc;
color: rgba(255, 255, 255, 0.75); color: rgba(255, 255, 255, 0.75);
font-size: 0.9em;
} }
.landing__footer a { .landing__footer a {