@@ -63,6 +63,27 @@ angular.module('workspace').controller("WorkspaceController", ['$scope', '$rootS
6363
6464 Entry . init ( workspace , initOptions ) ;
6565
66+ Entry . playground . board . _contextOptions [ 3 ] . option . callback = function ( ) {
67+ dialog . showOpenDialog ( {
68+ properties : [
69+ 'openDirectory'
70+ ] ,
71+ filters : [
72+ { name : 'Image' , extensions : [ 'png' ] }
73+ ]
74+ } , function ( paths ) {
75+ Entry . playground . board . code . getThreads ( ) . forEach ( function ( t , index ) {
76+ var topBlock = t . getFirstBlock ( ) ;
77+ if ( ! topBlock ) return ;
78+ ( function ( i ) {
79+ topBlock . view . getDataUrl ( ) . then ( function ( data ) {
80+ var savePath = path . resolve ( paths [ 0 ] , i + '.png' ) ;
81+ Entry . plugin . saveImage ( data . src , savePath ) ;
82+ } ) ;
83+ } ) ( ++ index ) ;
84+ } )
85+ } )
86+ }
6687 var beforeUnload = window . onbeforeunload ;
6788 window . onbeforeunload = function ( e ) {
6889 if ( window . isNowSaving === true ) {
@@ -200,8 +221,7 @@ angular.module('workspace').controller("WorkspaceController", ['$scope', '$rootS
200221 fs . writeFile ( filePath , stream , 'utf8' , function ( err ) {
201222 if ( err ) {
202223 alert ( "Unable to save file" ) ;
203- }
204- else {
224+ } else {
205225 console . log ( "File Saved" ) ;
206226 }
207227
@@ -822,23 +842,23 @@ angular.module('workspace').controller("WorkspaceController", ['$scope', '$rootS
822842 var maxx = 0 ;
823843 var maxy = 0 ;
824844
825- if ( pix . x . length > 0 ) {
845+ if ( pix . x . length > 0 ) {
826846 minx = pix . x [ 0 ] ;
827847 maxx = pix . x [ n ] ;
828848 w = maxx - minx ;
829- if ( w % 2 != 0 ) {
849+ if ( w % 2 != 0 ) {
830850 w += 1 ;
831851 }
832852 } else {
833853 w = 1 ;
834854 minx = 0 ;
835855 }
836856
837- if ( pix . y . length > 0 ) {
857+ if ( pix . y . length > 0 ) {
838858 miny = pix . y [ 0 ] ;
839859 maxy = pix . y [ n ]
840860 h = maxy - miny ;
841- if ( h % 2 != 0 ) {
861+ if ( h % 2 != 0 ) {
842862 h += 1 ;
843863 }
844864 } else {
@@ -920,7 +940,7 @@ angular.module('workspace').controller("WorkspaceController", ['$scope', '$rootS
920940 modalInstance . result . then ( function ( selectedItems ) {
921941 selectedItems . data . forEach ( function ( item ) {
922942 item . id = Entry . generateHash ( ) ;
923- if ( item . fileurl ) {
943+ if ( item . fileurl ) {
924944 item . fileurl = item . fileurl . replace ( / % 5 C / gi, '/' ) ;
925945 }
926946 Entry . dispatchEvent ( 'pictureImport' , item ) ;
0 commit comments