Commit e601b7b8 authored by Akikonata's avatar Akikonata

export

parent c392ce30
Subproject commit df7b361ae5098710eca0fec1080dce4bc822bf24 Subproject commit a9630e638b29633f62cdc2df239bc702118b231a
...@@ -35,15 +35,17 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -35,15 +35,17 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
var svghtml = $( "#kityminder .kmui-editor-body" ).html(); var svghtml = $( "#kityminder .kmui-editor-body" ).html();
var bgImg = $( "#kityminder .kmui-editor-body" ).css( "backgroundImage" ).replace( /"/g, "" ).replace( /url\(|\)$/ig, "" ); var bgImg = $( "#kityminder .kmui-editor-body" ).css( "backgroundImage" ).replace( /"/g, "" ).replace( /url\(|\)$/ig, "" );
var renderBox = me.getRenderContainer().getRenderBox( "top" ); var renderBox = me.getRenderContainer().getRenderBox( "top" );
//debugger; var renderContainer = me.getRenderContainer();
var transform = renderContainer.getTransform();
renderContainer.resetTransform();
var svg = $( svghtml ).attr( { var svg = $( svghtml ).attr( {
width: renderBox.x + me.getRenderContainer().getWidth(), width: renderBox.x + renderBox.width,
height: renderBox.y + me.getRenderContainer().getHeight(), height: renderBox.y + renderBox.height,
viewBox: null viewBox: null
} ); } );
var div = $( "<div></div>" ).append( svg ); var div = $( "<div></div>" ).append( svg );
svghtml = div.html(); svghtml = div.html();
var canvas = $( '<canvas width="' + renderBox.width + '" height="' + renderBox.height + '"></canvas>' ); var canvas = $( '<canvas width="' + ( parseInt( renderBox.width ) + 40 ) + '" height="' + ( parseInt( renderBox.height ) + 40 ) + '"></canvas>' );
var ctx = canvas[ 0 ].getContext( "2d" ); var ctx = canvas[ 0 ].getContext( "2d" );
var DOMURL = self.URL || self.webkitURL || self; var DOMURL = self.URL || self.webkitURL || self;
var img = new Image(); var img = new Image();
...@@ -57,8 +59,8 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -57,8 +59,8 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
bgTexture.onload = function () { bgTexture.onload = function () {
var bgfill = ctx.createPattern( bgTexture, "repeat" ); var bgfill = ctx.createPattern( bgTexture, "repeat" );
ctx.fillStyle = bgfill; ctx.fillStyle = bgfill;
ctx.fillRect( 0, 0, renderBox.width, renderBox.height ); ctx.fillRect( 0, 0, renderBox.width + 40, renderBox.height + 40 );
ctx.drawImage( img, -renderBox.x, -renderBox.y ); ctx.drawImage( img, -renderBox.x + 20, -renderBox.y + 20 );
DOMURL.revokeObjectURL( url ); DOMURL.revokeObjectURL( url );
var type = 'png'; var type = 'png';
var imgData = canvas[ 0 ].toDataURL( type ); var imgData = canvas[ 0 ].toDataURL( type );
...@@ -82,6 +84,7 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -82,6 +84,7 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
var filename = 'kityminder_' + ( new Date() ).getTime() + '.' + type; var filename = 'kityminder_' + ( new Date() ).getTime() + '.' + type;
// download // download
saveFile( imgData, filename ); saveFile( imgData, filename );
renderContainer.setTransform( transform );
}; };
}; };
img.src = url; img.src = url;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment