diff --git a/editor/embedapi-dom.js b/editor/embedapi-dom.js index 56750047..ed9db215 100644 --- a/editor/embedapi-dom.js +++ b/editor/embedapi-dom.js @@ -65,14 +65,17 @@ $('#save').click(saveSvg); $('#exportPNG').click(exportPNG); $('#exportPDF').click(exportPDF); -const iframe = $('' ); iframe[0].addEventListener('load', function () { - svgCanvas = new EmbeddedSVGEdit(frame); + svgCanvas = new EmbeddedSVGEdit(frame, [frameBase]); // Hide main button, as we will be controlling new, load, save, etc. from the host document let doc; try { diff --git a/editor/embedapi.js b/editor/embedapi.js index 5f1a0d11..625479b0 100644 --- a/editor/embedapi.js +++ b/editor/embedapi.js @@ -72,6 +72,7 @@ function messageListener (e) { e.source !== this.frame.contentWindow || (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) ) { + console.log(`The origin ${e.origin} was not whitelisted as an origin from which responses may be received by this ${window.origin} script.`); return; } addCallback(this, data); diff --git a/editor/extensions/ext-xdomain-messaging.js b/editor/extensions/ext-xdomain-messaging.js index 23e95b77..dbb482a7 100644 --- a/editor/extensions/ext-xdomain-messaging.js +++ b/editor/extensions/ext-xdomain-messaging.js @@ -18,10 +18,12 @@ export default { if (!data || typeof data !== 'object' || data.namespace !== 'svgCanvas') { return; } - // The default is not to allow any origins, including even the same domain or if run on a file:// URL - // See svgedit-config-es.js for an example of how to configure + // The default is not to allow any origins, including even the same domain or + // if run on a file:// URL See svgedit-config-es.js for an example of how + // to configure const {allowedOrigins} = svgEditor.curConfig; if (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) { + console.log(`Origin ${e.origin} not whitelisted for posting to ${window.origin}`); return; } const cbid = data.id; diff --git a/editor/xdomain-svg-editor-es.html b/editor/xdomain-svg-editor-es.html new file mode 100644 index 00000000..26dce092 --- /dev/null +++ b/editor/xdomain-svg-editor-es.html @@ -0,0 +1,777 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SVG-edit + + + + + + diff --git a/package.json b/package.json index 046209d9..f256e696 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "copy-deps": "cp node_modules/load-stylesheets/dist/index-es.js editor/external/load-stylesheets/index-es.js && cp node_modules/babel-polyfill/dist/polyfill.min.js editor/external/babel-polyfill/polyfill.min.js && cp node_modules/babel-polyfill/dist/polyfill.js editor/external/babel-polyfill/polyfill.js", "eslint": "eslint .", "rollup": "rollup -c", + "start-embedded": "echo \"Open file to http://localhost:8000/editor/embedapi.html\" && static -p 8000 | static -p 8001 -H '{\"Access-Control-Allow-Origin\": \"*\"}'", "start": "echo \"Open file to http://localhost:8000/test/all_tests.html\" && static -p 8000", "test-no-build": "npm run eslint && npm run build-html && npm run build-config && opn http://localhost:8000/test/all_tests.html && static -p 8000", "test-prep": "npm run eslint && npm run build-html && npm run rollup && npm run build-config",