48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
|
const Editor = {
|
||
|
oninit: function(vnode) {
|
||
|
this.editor = null
|
||
|
this.lastData = null
|
||
|
},
|
||
|
|
||
|
oncreate: function(vnode) {
|
||
|
this.editor = new window.EditorJS({
|
||
|
holder: vnode.dom,
|
||
|
inlineToolbar: ['link', 'bold', 'inlineCode', 'italic'],
|
||
|
tools: {
|
||
|
inlineCode: {
|
||
|
class: window.InlineCode, //<span class="inline-code"></span>
|
||
|
shortcut: 'CMD+SHIFT+M',
|
||
|
},
|
||
|
header: window.Header,
|
||
|
image: window.SimpleImage,
|
||
|
quote: window.Quote,
|
||
|
code: window.CodeTool,
|
||
|
list: {
|
||
|
class: window.List,
|
||
|
inlineToolbar: true,
|
||
|
config: {
|
||
|
defaultStyle: 'unordered'
|
||
|
}
|
||
|
},
|
||
|
delimiter: window.Delimiter,
|
||
|
htmlraw: window.RawTool,
|
||
|
},
|
||
|
data: vnode.attrs.contentdata,
|
||
|
})
|
||
|
this.lastData = vnode.attrs.contentdata
|
||
|
},
|
||
|
|
||
|
onupdate: function(vnode) {
|
||
|
if (this.lastData !== vnode.attrs.contentdata) {
|
||
|
this.lastData = vnode.attrs.contentdata
|
||
|
this.editor.render(this.lastData)
|
||
|
}
|
||
|
},
|
||
|
|
||
|
view: function(vnode) {
|
||
|
return m('div')
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = Editor
|