/
index.js
52 lines (42 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pkgJson from '../package.json'
import { actionMixin, registerComponent } from 'maka'
import { Controlled as CodeMirror } from 'react-codemirror2'
import "codemirror/theme/material.css"
import "codemirror/lib/codemirror.css"
import './style.less'
const name = pkgJson.name
registerComponent('CodeMirror', CodeMirror)
const state = {
data: {
}
}
@actionMixin('base')
class action {
constructor(option) {
Object.assign(this, option.mixins)
}
onChange = (e) => {
this.base.setState({ 'data.input': e.target.value })
console.log(this.base.getState('data.input'))
}
}
const view = {
component: 'div',
className: 'code-mirror',
children: [{
component: 'CodeMirror',
options: {
mode: 'markdown',
theme: 'material',
lineNumbers: true
},
value: '{{data.content}}',
onBeforeChange: `{{(e,d,v)=>$base.ss({'data.content': v})}}`
}]
}
export {
name,
state,
action,
view
}