Skip to content

Commit

Permalink
Editor performance fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Schweblin committed Feb 25, 2018
1 parent 57f45f0 commit 34e15ee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
45 changes: 25 additions & 20 deletions src/services/editorSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,26 +395,29 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,

const debouncedRefreshPreview = debounce(refreshPreview, 50);

const onEditorChanged =
(sectionList = this.sectionList, selectionRange = this.selectionRange) => {
if (this.sectionList !== sectionList) {
this.sectionList = sectionList;
this.$emit('sectionList', this.sectionList);
if (instantPreview) {
refreshPreview();
} else {
debouncedRefreshPreview();
}
}
if (this.selectionRange !== selectionRange) {
this.selectionRange = selectionRange;
this.$emit('selectionRange', this.selectionRange);
let newSectionList;
let newSelectionRange;
const onEditorChanged = debounce(() => {
if (this.sectionList !== newSectionList) {
this.sectionList = newSectionList;
this.$emit('sectionList', this.sectionList);
if (instantPreview) {
refreshPreview();
} else {
debouncedRefreshPreview();
}
this.saveContentState();
};
}
if (this.selectionRange !== newSelectionRange) {
this.selectionRange = newSelectionRange;
this.$emit('selectionRange', this.selectionRange);
}
this.saveContentState();
}, 10);

this.clEditor.selectionMgr.on('selectionChanged',
(start, end, selectionRange) => onEditorChanged(undefined, selectionRange));
this.clEditor.selectionMgr.on('selectionChanged', (start, end, selectionRange) => {
newSelectionRange = selectionRange;
onEditorChanged();
});

/* -----------------------------
* Inline images
Expand Down Expand Up @@ -502,8 +505,10 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
triggerImgCacheGc();
});

this.clEditor.on('contentChanged',
(content, diffs, sectionList) => onEditorChanged(sectionList));
this.clEditor.on('contentChanged', (content, diffs, sectionList) => {
newSectionList = sectionList;
onEditorChanged();
});

// clEditorSvc.setPreviewElt(element[0].querySelector('.preview__inner-2'))
// var previewElt = element[0].querySelector('.preview')
Expand Down
1 change: 1 addition & 0 deletions static/landing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
text-align: center;
background-color: #007acc;
color: rgba(255, 255, 255, 0.75);
font-size: 0.9em;
}

.landing__footer a {
Expand Down

0 comments on commit 34e15ee

Please sign in to comment.