nfp_sites/nfp_moe/app/admin/editor.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-07-21 07:06:16 +00:00
const Editor = {
oninit: function(vnode) {
this.editor = null
2022-07-22 11:18:33 +00:00
this.lastData = null
2022-07-21 07:06:16 +00:00
},
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,
2022-07-22 11:18:33 +00:00
},
data: vnode.attrs.contentdata,
2022-07-21 07:06:16 +00:00
})
2022-07-22 11:18:33 +00:00
this.lastData = vnode.attrs.contentdata
},
onupdate: function(vnode) {
if (this.lastData !== vnode.attrs.contentdata) {
this.lastData = vnode.attrs.contentdata
this.editor.render(this.lastData)
}
2022-07-21 07:06:16 +00:00
},
view: function(vnode) {
return m('div')
}
}
module.exports = Editor