diff --git a/src/services/editorSvc.js b/src/services/editorSvc.js index db2fe9ee..5e99f10d 100644 --- a/src/services/editorSvc.js +++ b/src/services/editorSvc.js @@ -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)); }, /** diff --git a/src/services/extensionSvc.js b/src/services/extensionSvc.js index 54c4b683..2eb6d35f 100644 --- a/src/services/extensionSvc.js +++ b/src/services/extensionSvc.js @@ -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))); - }, };