Skip to content

Commit 15439a2

Browse files
author
- -
committed
add theme support
1 parent 59cb695 commit 15439a2

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,23 @@ export default {
9595
}
9696
```
9797

98-
## [Editor Theme](https://github.com/xcatliu/simplemde-theme-base/wiki/List-of-themes)
98+
## Editor Theme ([simplemde-theme-base](https://github.com/xcatliu/simplemde-theme-base/wiki/List-of-themes))
99+
> e.g. 使用simplemde-theme-base主题
100+
101+
### install
102+
```
103+
$ npm install --save simplemde-theme-base
104+
```
105+
106+
### use
107+
``` html
108+
<markdown-editor :custom-theme="true"></markdown-editor>
109+
```
110+
111+
``` javascript
112+
import 'simplemde-theme-base/dist/simplemde-theme-base.min.css'
113+
```
114+
99115

100116
## Markdown style
101117
> e.g. 使用Github的markdown样式

markdown-editor.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66

77
<script>
88
import SimpleMDE from 'simplemde'
9-
import 'simplemde/dist/simplemde.min.css'
109
1110
export default {
1211
name: 'markdown-editor',
1312
props: {
1413
value: String,
1514
previewClass: String,
15+
customTheme: {
16+
type: Boolean,
17+
default () {
18+
return false
19+
}
20+
},
1621
configs: {
1722
type: Object,
1823
default () {
@@ -32,7 +37,7 @@ export default {
3237
// 实例化编辑器
3338
this.simplemde = new SimpleMDE(configs)
3439
35-
// 开启代码高亮
40+
// 判断是否开启代码高亮
3641
if (configs.renderingConfig && configs.renderingConfig.codeSyntaxHighlighting) {
3742
require.ensure([], () => {
3843
var theme = configs.renderingConfig.highlightingTheme || 'default'
@@ -41,6 +46,11 @@ export default {
4146
}, 'highlight')
4247
}
4348
49+
// 判断是否引入样式文件
50+
if (!this.customTheme) {
51+
require('simplemde/dist/simplemde.min.css')
52+
}
53+
4454
// 添加自定义 previewClass
4555
var _class = this.previewClass || ''
4656
if (configs.renderingConfig && configs.renderingConfig.codeSyntaxHighlighting) {

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.6",
3+
"version": "0.2.9",
44
"description": "SimpleMDE - Markdown Editor component for Vue.js",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)