feat: lists UX + assets create folder UI (wip)

This commit is contained in:
Nick
2019-05-19 14:46:08 -04:00
parent 965f0ad2cd
commit 7b08c8bb31
6 changed files with 194 additions and 20 deletions

View File

@@ -396,6 +396,13 @@ export default {
}
return lvl
},
/**
* Insert content at cursor
*/
insertAtCursor({ content }) {
const cursor = this.cm.doc.getCursor('head')
this.cm.doc.replaceRange(content, cursor)
},
/**
* Insert content after current line
*/
@@ -457,6 +464,25 @@ export default {
toggleFullscreen () {
this.cm.setOption('fullScreen', true)
}
},
mounted() {
this.$root.$on('editorInsert', opts => {
switch (opts.kind) {
case 'IMAGE':
this.insertAtCursor({
content: `![${opts.text}](${opts.path})`
})
break
case 'BINARY':
this.insertAtCursor({
content: `[${opts.text}](${opts.path})`
})
break
}
})
},
beforeDestroy() {
this.$root.$off('editorInsert')
}
}
</script>