From 85b6e40d8c4b35132a416980f15ac36522060426 Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Thu, 3 May 2018 12:46:15 +0100 Subject: [PATCH] Finished up Draw.io integration --- domain/section/flowchart/flowchart.go | 2 +- .../section/flowchart/type-editor.js | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/domain/section/flowchart/flowchart.go b/domain/section/flowchart/flowchart.go index e054d30a..d39a9ff7 100644 --- a/domain/section/flowchart/flowchart.go +++ b/domain/section/flowchart/flowchart.go @@ -30,7 +30,7 @@ func (*Provider) Meta() provider.TypeMeta { section := provider.TypeMeta{} section.ID = "d46a18f6-49fb-11e8-842f-0ed5f89f718b" - section.Title = "Graphical Diagram" + section.Title = "Draw.io Diagram" section.Description = "Draw.io powered flowcharts and diagrams" section.ContentType = "flowchart" section.PageType = "tab" diff --git a/gui/app/components/section/flowchart/type-editor.js b/gui/app/components/section/flowchart/type-editor.js index c0b54769..81da1604 100644 --- a/gui/app/components/section/flowchart/type-editor.js +++ b/gui/app/components/section/flowchart/type-editor.js @@ -67,9 +67,18 @@ export default Component.extend({ let self = this; let flowCallback = function(evt) { - if (self.get('isDestroyed') || self.get('isDestroying')) return; - if (evt.origin !== 'https://www.draw.io') return; - if (evt.data.length === 0) return; + if (self.get('isDestroyed') || self.get('isDestroying')) { + console.log('draw.io component destroyed'); // eslint-disable-line no-console + return; + } + // if (evt.origin !== 'https://www.draw.io') { + // console.log('draw.io incorrect message source: ' + evt.source); // eslint-disable-line no-console + // return; + // } + if (evt.data.length === 0) { + console.log('draw.io no event data'); // eslint-disable-line no-console + return; + } let editorFrame = document.getElementById(self.get('editorId')); var msg = JSON.parse(evt.data); @@ -127,7 +136,9 @@ export default Component.extend({ this.set('title', title); let editorFrame = document.getElementById(this.get('editorId')); - editorFrame.contentWindow.postMessage(JSON.stringify({action: 'export', format: 'xmlpng', xml: this.get('diagramXML'), spin: 'Updating'}), '*'); + editorFrame.contentWindow.postMessage( + JSON.stringify({action: 'export', format: 'xmlpng', + xml: this.get('diagramXML'), spin: 'Updating'}), '*'); } } });