Last active
August 26, 2017 20:05
-
-
Save shibacomputer/3358b71e8caff66917e8f899df00a6dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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