Skip to content

Commit d5b31c1

Browse files
fix: highlight code in the editor (#1176)
1 parent 46047ba commit d5b31c1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/components/post/Editor.vue

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ import Vue from 'vue'
8989
import DOMPurify from 'dompurify'
9090
import Turndown from 'turndown'
9191
import { strikethrough } from 'turndown-plugin-gfm'
92+
import hljs from 'highlight.js'
9293
import type { RangeStatic, Quill } from 'quill'
9394
import QuillMarkdown from 'quilljs-markdown'
9495
import XIcon from '@/components/icons/X.vue'
@@ -155,6 +156,9 @@ const options = {
155156
bounds: `#editor`,
156157
scrollingContainer: `#editor`,
157158
modules: {
159+
syntax: {
160+
highlight: (code: string) => hljs.highlightAuto(code).value,
161+
},
158162
counter: true,
159163
toolbar: {
160164
container: toolbarOptions,

0 commit comments

Comments
 (0)