Move embedapi.html code which is not part of the API into embedapi-dom.js; demo export PDF in embedded editor; add new exportPDF method to canvas (and exposed to embedded editor) which can support JSON-able data URI string response, removing PDF exporting from rasterExport; JSLint; move dependency checking code for canvg and jsPDF to utilities; simplify Utils calls; allow for custom PDF export handler (but not yet implemented in server-based extensions); import PDF todo

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2860 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Brett Zamir
2014-05-22 10:21:29 +00:00
parent 36dfb2bd17
commit abc9cd6ffb
8 changed files with 216 additions and 150 deletions

View File

@@ -14,7 +14,7 @@
svgEditor.addExtension("server_opensave", {
callback: function() {'use strict';
var Utils = svgedit.utilities;
var save_svg_action = '/+modify';
// Create upload target (hidden iframe)
@@ -25,18 +25,18 @@ svgEditor.addExtension("server_opensave", {
var svg = "<?xml version=\"1.0\"?>\n" + data;
var qstr = $.param.querystring();
var name = qstr.substr(9).split('/+get/')[1];
var svg_data = svgedit.utilities.encode64(svg);
var svg_data = Utils.encode64(svg);
if(!$('#export_canvas').length) {
$('<canvas>', {id: 'export_canvas'}).hide().appendTo('body');
}
var c = $('#export_canvas')[0];
c.width = svgCanvas.contentW;
c.height = svgCanvas.contentH;
svgEditor.buildCanvgCallback(function () {
Utils.buildCanvgCallback(function () {
canvg(c, svg, {renderCallback: function() {
var datauri = c.toDataURL('image/png');
// var uiStrings = svgEditor.uiStrings;
var png_data = svgedit.utilities.encode64(datauri);
var png_data = Utils.encode64(datauri);
var form = $('<form>').attr({
method: 'post',
action: save_svg_action + '/' + name,

View File

@@ -34,7 +34,8 @@ svgEditor.addExtension("server_opensave", {
save_svg_action = svgEditor.curConfig.extPath + 'filesave.php',
save_img_action = svgEditor.curConfig.extPath + 'filesave.php',
// Create upload target (hidden iframe)
cancelled = false;
cancelled = false,
Utils = svgedit.utilities;
$('<iframe name="output_frame" src="#"/>').hide().appendTo('body');
svgEditor.setCustomHandlers({
@@ -42,7 +43,7 @@ svgEditor.addExtension("server_opensave", {
var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data, // Firefox doesn't seem to know it is UTF-8 (no matter whether we use or skip the clientDownload code) despite the Content-Disposition header containing UTF-8, but adding the encoding works
filename = getFileNameFromTitle();
if (clientDownloadSupport(filename, '.svg', 'data:image/svg+xml;charset=UTF-8;base64,' + svgedit.utilities.encode64(svg))) {
if (clientDownloadSupport(filename, '.svg', 'data:image/svg+xml;charset=UTF-8;base64,' + Utils.encode64(svg))) {
return;
}
@@ -68,7 +69,7 @@ svgEditor.addExtension("server_opensave", {
c.width = svgCanvas.contentW;
c.height = svgCanvas.contentH;
svgEditor.buildCanvgCallback(function () {
Utils.buildCanvgCallback(function () {
canvg(c, data.svg, {renderCallback: function() {
var pre, filename, suffix,
datauri = quality ? c.toDataURL(mimeType, quality) : c.toDataURL(mimeType),
@@ -125,7 +126,7 @@ svgEditor.addExtension("server_opensave", {
$('#dialog_box').hide();
if (type !== 'import_img') {
xmlstr = svgedit.utilities.decode64(str64);
xmlstr = Utils.decode64(str64);
}
switch (type) {