From 4ebe33e0d7fed04631f9222616ab5a527ce6883d Mon Sep 17 00:00:00 2001 From: Ron Lucke <lucke@elan-ev.de> Date: Tue, 5 Oct 2021 10:01:45 +0000 Subject: [PATCH] fix #266 --- .../courseware/CoursewareTextBlock.vue | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/resources/vue/components/courseware/CoursewareTextBlock.vue b/resources/vue/components/courseware/CoursewareTextBlock.vue index 12cc5461043..26303727fdb 100755 --- a/resources/vue/components/courseware/CoursewareTextBlock.vue +++ b/resources/vue/components/courseware/CoursewareTextBlock.vue @@ -10,7 +10,7 @@ @closeEdit="closeEdit" > <template #content> - <section class="cw-block-content" v-html="currentText"></section> + <section class="cw-block-content" v-html="currentText" ref="content"></section> </template> <template v-if="canEdit" #edit> <studip-wysiwyg v-model="currentText"></studip-wysiwyg> @@ -48,6 +48,7 @@ export default { }, mounted() { this.currentText = this.text; + this.loadMathjax(); }, methods: { ...mapActions({ @@ -55,6 +56,7 @@ export default { }), closeEdit() { this.currentText = this.text; + this.loadMathjax(); }, async storeText() { let attributes = this.block.attributes; @@ -65,7 +67,26 @@ export default { containerId: this.block.relationships.container.data.id, }); this.$refs.defaultBlock.displayFeature(false); + this.loadMathjax(); }, + loadMathjax() { + let mathjaxP; + let view = this; + + if (window.MathJax && window.MathJax.Hub) { + mathjaxP = Promise.resolve(window.MathJax); + } else if (window.STUDIP && window.STUDIP.loadChunk) { + mathjaxP = window.STUDIP.loadChunk('mathjax'); + } + + mathjaxP && mathjaxP + .then(({ Hub }) => { + Hub.Queue(['Typeset', Hub, view.$refs.content]); + }) + .catch(() => { + console.log('Warning: Could not load MathJax.'); + }); + } }, }; </script> -- GitLab