feat: edit existing diagram data

This commit is contained in:
NGPixel
2020-07-12 19:32:17 -04:00
parent f4502ccef7
commit 383dfd3010
2 changed files with 34 additions and 18 deletions

View File

@@ -678,7 +678,13 @@ export default {
foundStart = line
} else if (ln.text === '```' && found) {
switch (found) {
// ------------------------------
// -> DIAGRAM
// ------------------------------
case 'diagram': {
if (line - foundStart !== 2) {
return
}
this.addMarker({
kind: 'diagram',
from: { line: foundStart, ch: 3 },
@@ -687,8 +693,17 @@ export default {
action: ((start, end) => {
return (ev) => {
this.cm.doc.setSelection({ line: start, ch: 0 }, { line: end, ch: 3 })
// this.$store.set('editor/activeModalData', )
this.toggleModal(`editorModalDrawio`)
try {
const raw = this.cm.doc.getLine(end - 1)
this.$store.set('editor/activeModalData', Buffer.from(raw, 'base64').toString())
this.toggleModal(`editorModalDrawio`)
} catch (err) {
return this.$store.commit('showNotification', {
message: 'Failed to process diagram data.',
style: 'warning',
icon: 'warning'
})
}
}
})(foundStart, line)
})