diff --git a/editor/embedapi-dom.js b/editor/embedapi-dom.js
new file mode 100644
index 00000000..f0c1f51e
--- /dev/null
+++ b/editor/embedapi-dom.js
@@ -0,0 +1,76 @@
+/*globals $, EmbeddedSVGEdit*/
+/*jslint vars: true */
+var initEmbed;
+
+$(function () {'use strict';
+
+ var svgCanvas = null;
+ var frame;
+
+ initEmbed = function () {
+ var doc, mainButton;
+ svgCanvas = new EmbeddedSVGEdit(frame);
+ // Hide main button, as we will be controlling new, load, save, etc. from the host document
+ doc = frame.contentDocument || frame.contentWindow.document;
+ 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() {
+ var svgexample = '';
+ svgCanvas.setSvgString(svgexample);
+ }
+
+ function saveSvg() {
+ svgCanvas.getSvgString()(handleSvgData);
+ }
+
+ function exportPNG() {
+ var str = frame.contentWindow.svgEditor.uiStrings.notification.loadingImage;
+ var exportWindow = window.open(
+ 'data:text/html;charset=utf-8,' + encodeURIComponent('
' + str + '' + str + '
'),
+ 'svg-edit-exportWindow'
+ );
+ svgCanvas.rasterExport('PNG', null, exportWindow.name);
+ }
+
+ function exportPDF() {
+ var str = frame.contentWindow.svgEditor.uiStrings.notification.loadingImage;
+
+ /**
+ // If you want to handle the PDF blob yourself, do as follows
+ svgCanvas.bind('exportedPDF', function (win, data) {
+ alert(data.dataurlstring);
+ });
+ svgCanvas.exportPDF(); // Accepts two args: optionalWindowName supplied back to bound exportPDF handler and optionalOutputType (defaults to dataurlstring)
+ return;
+ */
+
+ var exportWindow = window.open(
+ 'data:text/html;charset=utf-8,' + encodeURIComponent('' + str + '' + str + '
'),
+ 'svg-edit-exportWindow'
+ );
+ svgCanvas.exportPDF(exportWindow.name);
+ }
+
+ // Add event handlers
+ $('#load').click(loadSvg);
+ $('#save').click(saveSvg);
+ $('#exportPNG').click(exportPNG);
+ $('#exportPDF').click(exportPDF);
+ $('body').append(
+ $(''
+ )
+ );
+ frame = document.getElementById('svgedit');
+});
diff --git a/editor/embedapi.html b/editor/embedapi.html
index d410f0d0..44ee3308 100644
--- a/editor/embedapi.html
+++ b/editor/embedapi.html
@@ -5,66 +5,13 @@
Embed API
-
+
-
+
+