From d76bbb29546692732aea33ca5507df886ef6cb1b Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Wed, 20 Apr 2022 23:32:02 +0100 Subject: [PATCH 1/2] Made it possible to configure draw.io/diagrams.net integration Added new editor public event to hook into draw.io configuration step. Required change of embed url to trigger the configure step. --- resources/js/services/drawio.js | 8 ++++++++ resources/views/pages/parts/form.blade.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/js/services/drawio.js b/resources/js/services/drawio.js index 6e22919fb..dfca83211 100644 --- a/resources/js/services/drawio.js +++ b/resources/js/services/drawio.js @@ -43,6 +43,8 @@ function drawReceive(event) { drawEventSave(message); } else if (message.event === 'export') { drawEventExport(message); + } else if (message.event === 'configure') { + drawEventConfigure(); } } @@ -63,6 +65,12 @@ function drawEventInit() { }); } +function drawEventConfigure() { + const config = {}; + window.$events.emitPublic(iFrame, 'editor-drawio::configure', {config}); + drawPostMessage({action: 'configure', config}); +} + function drawEventClose() { window.removeEventListener('message', drawReceive); if (iFrame) document.body.removeChild(iFrame); diff --git a/resources/views/pages/parts/form.blade.php b/resources/views/pages/parts/form.blade.php index 01f68a6c5..f199b8624 100644 --- a/resources/views/pages/parts/form.blade.php +++ b/resources/views/pages/parts/form.blade.php @@ -1,7 +1,7 @@
name === trans('entities.pages_initial_name')) option:page-editor:has-default-title="true" From 0003ce61cd5e9ea2dee8a3fcc1788943ea39d293 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Wed, 20 Apr 2022 23:42:47 +0100 Subject: [PATCH 2/2] Fixed failing test after drawio default url change --- tests/Uploads/DrawioTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Uploads/DrawioTest.php b/tests/Uploads/DrawioTest.php index 1fc3d1049..2ed4da7ca 100644 --- a/tests/Uploads/DrawioTest.php +++ b/tests/Uploads/DrawioTest.php @@ -71,7 +71,7 @@ class DrawioTest extends TestCase $editor = $this->getEditor(); $resp = $this->actingAs($editor)->get($page->getUrl('/edit')); - $resp->assertSee('drawio-url="https://embed.diagrams.net/?embed=1&proto=json&spin=1"', false); + $resp->assertSee('drawio-url="https://embed.diagrams.net/?embed=1&proto=json&spin=1&configure=1"', false); config()->set('services.drawio', false); $resp = $this->actingAs($editor)->get($page->getUrl('/edit'));