Skip to content

Instantly share code, notes, and snippets.

@shibacomputer
Last active August 26, 2017 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shibacomputer/3358b71e8caff66917e8f899df00a6dd to your computer and use it in GitHub Desktop.
Save shibacomputer/3358b71e8caff66917e8f899df00a6dd to your computer and use it in GitHub Desktop.
const html = require('choo/html')
const pell = require('pell')
module.exports = editor
function editor (state, emit) {
var el, editor
init()
function init() {
el = html`
<div class="editor"></div>
`
editor = pell.init({
element: el,
onChange: (contents) => {
update(contents)
},
classes: {
content: 'content'
}
})
function update(contents) {
emit('note:update', editor.content.innerText)
}
editor.content.innerText = state.note.staleBody
}
return el
}
function save (note) {
file.write(note, (err) => {
state.note.staleBody = state.note.body
emitter.emit('render')
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment