From 383dfd3010b3b35d17db0806360b31aa82885c6f Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sun, 12 Jul 2020 19:32:17 -0400 Subject: [PATCH] feat: edit existing diagram data --- client/components/editor/editor-markdown.vue | 19 +++++++++-- .../components/editor/editor-modal-drawio.vue | 33 ++++++++++--------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/client/components/editor/editor-markdown.vue b/client/components/editor/editor-markdown.vue index c74e8c86..3e23655b 100644 --- a/client/components/editor/editor-markdown.vue +++ b/client/components/editor/editor-markdown.vue @@ -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) }) diff --git a/client/components/editor/editor-modal-drawio.vue b/client/components/editor/editor-modal-drawio.vue index d05319d2..9328c45e 100644 --- a/client/components/editor/editor-modal-drawio.vue +++ b/client/components/editor/editor-modal-drawio.vue @@ -10,21 +10,21 @@