Skip to content

Commit 97e5804

Browse files
author
- -
committed
fix previewClass
1 parent a003a3d commit 97e5804

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

markdown-editor.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export default {
1414
value: String,
1515
previewClass: String,
1616
configs: {
17-
type: Object
17+
type: Object,
18+
default () {
19+
return {}
20+
}
1821
}
1922
},
2023
mounted () {
@@ -27,7 +30,7 @@ export default {
2730
configs.initialValue = configs.initialValue || this.value
2831
2932
// 开启代码高亮
30-
if (configs.renderingConfig.codeSyntaxHighlighting) {
33+
if (configs.renderingConfig && configs.renderingConfig.codeSyntaxHighlighting) {
3134
require.ensure([], () => {
3235
var theme = configs.renderingConfig.highlightingTheme || 'default'
3336
window.hljs = require('highlight.js')
@@ -47,10 +50,10 @@ export default {
4750
})
4851
},
4952
addPreviewClass () {
50-
var _class = this.configs.renderingConfig.codeSyntaxHighlighting ? this.previewClass + ' hljs' : this.previewClass
53+
var _class = (this.configs.renderingConfig && this.configs.renderingConfig.codeSyntaxHighlighting) ? (this.previewClass || '') + ' hljs' : (this.previewClass || '')
5154
var wrapper = this.simplemde.codemirror.getWrapperElement()
5255
var preview = document.createElement('div')
53-
this.$el.lastChild.className += ' ' + _class
56+
wrapper.nextSibling.className += ' ' + _class
5457
preview.className = 'editor-preview ' + _class
5558
wrapper.appendChild(preview)
5659
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-simplemde",
3-
"version": "0.2.4",
3+
"version": "0.2.5",
44
"description": "SimpleMDE - Markdown Editor component for Vue.js",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)