Fix highlight.js in editor

This commit is contained in:
kolaente 2021-08-06 22:22:14 +02:00
parent 5e82e75e1b
commit f2c29d42dd
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -58,6 +58,7 @@ import VueEasymde from 'vue-easymde'
import EasyMDE from 'easymde' import EasyMDE from 'easymde'
import marked from 'marked' import marked from 'marked'
import DOMPurify from 'dompurify' import DOMPurify from 'dompurify'
import hljs from 'highlight.js'
import AttachmentModel from '../../models/attachment' import AttachmentModel from '../../models/attachment'
import AttachmentService from '../../services/attachment' import AttachmentService from '../../services/attachment'
@ -370,7 +371,6 @@ export default {
}, },
}, },
highlight: function (code, language) { highlight: function (code, language) {
const hljs = require('highlight.js')
const validLanguage = hljs.getLanguage(language) ? language : 'plaintext' const validLanguage = hljs.getLanguage(language) ? language : 'plaintext'
return hljs.highlight(code, {language: validLanguage}).value return hljs.highlight(code, {language: validLanguage}).value
}, },