From bf9c6dda1c6cc8ba9760ce9d3194e53c16701ed0 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sun, 15 Mar 2020 19:31:59 -0400 Subject: [PATCH] fix: missing code highlighting when toggling markdown preview (#1484) --- client/components/editor/editor-markdown.vue | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/components/editor/editor-markdown.vue b/client/components/editor/editor-markdown.vue index 6c81a596..adcc7aee 100644 --- a/client/components/editor/editor-markdown.vue +++ b/client/components/editor/editor-markdown.vue @@ -347,6 +347,16 @@ export default { mode: get('editor/mode'), activeModal: sync('editor/activeModal') }, + watch: { + previewShown (newValue, oldValue) { + if (newValue && !oldValue) { + this.$nextTick(() => { + Prism.highlightAllUnder(this.$refs.editorPreview) + Array.from(this.$refs.editorPreview.querySelectorAll('pre.line-numbers')).forEach(pre => pre.classList.add('prismjs')) + }) + } + } + }, methods: { toggleModal(key) { this.activeModal = (this.activeModal === key) ? '' : key