/* globals jQuery */ import EmbeddedSVGEdit from './embedapi.js'; const $ = jQuery; // Todo: Add iframe load listener var initEmbed; // Todo: Get rid of frame.contentWindow dependencies so can be more // easily adjusted to work cross-domain $(function () { let svgCanvas = null; initEmbed = function () { svgCanvas = new EmbeddedSVGEdit(frame); // Hide main button, as we will be controlling new, load, save, etc. from the host document const doc = frame.contentDocument || frame.contentWindow.document; const mainButton = doc.getElementById('main_button'); mainButton.style.display = 'none'; }; function handleSvgData (data, error) { if (error) { alert('error ' + error); } else { alert('Congratulations. Your SVG string is back in the host page, do with it what you will\n\n' + data); } } function loadSvg () { const svgexample = ''; svgCanvas.setSvgString(svgexample); } function saveSvg () { svgCanvas.getSvgString()(handleSvgData); } function exportPNG () { const str = frame.contentWindow.svgEditor.uiStrings.notification.loadingImage; const exportWindow = window.open( 'data:text/html;charset=utf-8,' + encodeURIComponent('