Skip to content
Snippets Groups Projects
Commit fbba89d5 authored by Thilo Wischmeyer's avatar Thilo Wischmeyer Committed by Thilo Wischmeyer
Browse files

Rewrote "render math" toggle button logic

In particular, the mounted hook that caused the math to rerender when a comment
was added has been removed. The button now only controls a boolean and the
actual rendering and resetting is handled by a watcher on the boolean, making it
less likely for the two to get out of sync.
parent 616136a2
No related branches found
No related tags found
1 merge request!278Rewrote math rendering logic
...@@ -24,17 +24,8 @@ ...@@ -24,17 +24,8 @@
<v-spacer /> <v-spacer />
<toggle-feedback-visibility-button /> <toggle-feedback-visibility-button />
<div v-if="isMarkdown"> <div v-if="isMarkdown">
<v-btn <v-btn @click="mathIsRendered = !mathIsRendered">
v-if="!mathIsRendered" {{ mathIsRendered ? 'Reset Math' : 'Render Math' }}
@click="renderAsciiMath"
>
Render Math
</v-btn>
<v-btn
v-else
@click="resetSubmission"
>
Reset Math
</v-btn> </v-btn>
</div> </div>
<v-spacer /> <v-spacer />
...@@ -197,8 +188,7 @@ export default { ...@@ -197,8 +188,7 @@ export default {
copyMessage: 'Copy to clipboard', copyMessage: 'Copy to clipboard',
originalSubmissionDialog: false, originalSubmissionDialog: false,
originalSubmission: '', originalSubmission: '',
mathIsRendered: false, mathIsRendered: this.isMarkdown,
mathRerender: 0
} }
}, },
computed: { computed: {
...@@ -206,6 +196,17 @@ export default { ...@@ -206,6 +196,17 @@ export default {
return UI.state.showSubmissionType === false return UI.state.showSubmissionType === false
} }
}, },
watch: {
mathIsRendered: {
immediate: true,
handler(newValue) {
if (newValue)
this.renderAsciiMath()
else
this.resetSubmission()
}
}
},
created () { created () {
subNotesEventBus.$on('submissionChanged', () => { subNotesEventBus.$on('submissionChanged', () => {
if (this.mathIsRendered) { if (this.mathIsRendered) {
...@@ -215,18 +216,11 @@ export default { ...@@ -215,18 +216,11 @@ export default {
} }
}) })
}, },
mounted () {
if (this.isMarkdown) {
this.renderAsciiMath()
}
},
methods: { methods: {
renderAsciiMath () { renderAsciiMath () {
window.MathJax.typeset() window.MathJax.typeset()
this.mathIsRendered = true
}, },
resetSubmission () { resetSubmission () {
this.mathIsRendered = false
subNotesEventBus.$emit('resetSubmission') subNotesEventBus.$emit('resetSubmission')
}, },
async showOriginalSubmission () { async showOriginalSubmission () {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment