Removed async preview hook

This commit is contained in:
benweet 2017-11-17 22:00:26 +00:00
parent 2972ffb97f
commit 5b251b61e3
2 changed files with 7 additions and 17 deletions

View File

@ -191,9 +191,12 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
this.tocElt.classList[
this.tocElt.querySelector('.cl-toc-section *') ? 'remove' : 'add'
]('toc-tab--empty');
this.previewText = this.previewElt.textContent;
this.$emit('previewText', this.previewText);
this.makeTextToPreviewDiffs();
// Run preview async operations (image loading, mathjax...)
// Wait for images to load
const loadedPromises = loadingImages.map(imgElt => new Promise((resolve) => {
if (!imgElt.src) {
resolve();
@ -205,13 +208,9 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
img.src = imgElt.src;
}));
Promise.all(loadedPromises.concat(extensionSvc.asyncPreview(this.options)))
.then(() => {
this.previewText = this.previewElt.textContent;
this.$emit('previewText', this.previewText);
// Debounce if sections have already been mesured
this.measureSectionDimensions(!!this.sectionDescMeasuredList);
});
Promise.all(loadedPromises)
// Debounce if sections have already been measured
.then(() => this.measureSectionDimensions(!!this.sectionDescMeasuredList));
},
/**

View File

@ -1,7 +1,6 @@
const getOptionsListeners = [];
const initConverterListeners = [];
const sectionPreviewListeners = [];
const asyncPreviewListeners = [];
export default {
onGetOptions(listener) {
@ -16,10 +15,6 @@ export default {
sectionPreviewListeners.push(listener);
},
onAsyncPreview(listener) {
asyncPreviewListeners.push(listener);
},
getOptions(properties, isCurrentFile) {
return getOptionsListeners.reduce((options, listener) => {
listener(options, properties, isCurrentFile);
@ -39,8 +34,4 @@ export default {
listener(elt, options);
});
},
asyncPreview(options) {
return Promise.all(asyncPreviewListeners.map(listener => listener(options)));
},
};