From 6ee97e0d3f9aabb410923345eba36da38e2886e6 Mon Sep 17 00:00:00 2001 From: Teemu Koivisto Date: Mon, 27 Nov 2017 19:49:34 +0200 Subject: [PATCH] Fix broken saving of svg in Chrome >=60 --- editor/svg-editor.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 9f33a478..95d1bbf2 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -1049,8 +1049,13 @@ TODOS return; } - // Opens the SVG in new window - var win = wind.open('data:image/svg+xml;base64,' + Utils.encode64(svg)); + // Since saving SVGs by opening a new window was removed in Chrome use artificial link-click + // https://stackoverflow.com/questions/45603201/window-is-not-allowed-to-navigate-top-frame-navigations-to-data-urls + var a = document.createElement('a'); + a.href = 'data:image/svg+xml;base64,' + Utils.encode64(svg); + a.download = 'icon.svg'; + + a.click(); // Alert will only appear the first time saved OR the first time the bug is encountered var done = $.pref('save_notice_done');