naive-ui/demo/documentation/components/docCodeEditorMixin.js
2019-09-23 19:14:15 +08:00

20 lines
521 B
JavaScript

import CodeMirror from 'codemirror'
import 'codemirror/mode/htmlmixed/htmlmixed'
import 'codemirror/theme/vibrant-ink.css'
export default {
mounted () {
const textAreaNotToRender = new Set(this.$refs.doc.querySelectorAll('.not-code textarea'))
this.$refs.doc.querySelectorAll('textarea').forEach(ta => {
if (textAreaNotToRender.has(ta)) {
return
}
CodeMirror.fromTextArea(ta, {
lineNumbers: false,
mode: 'htmlmixed',
theme: 'vibrant-ink'
})
})
}
}