@@ -10,6 +10,7 @@ import _includes from 'lodash/includes';
1010import _debounce from 'lodash/debounce' ;
1111import entryPatch from '../helper/entry/entryPatcher' ;
1212import { ModalProgress } from '@entrylabs/tool/component' ;
13+ import Constants from '../helper/constants' ;
1314import ModalHelper from '../helper/entry/entryModalHelper' ;
1415import RendererUtils from '../helper/rendererUtils' ;
1516import IpcRendererHelper from '../helper/ipcRendererHelper' ;
@@ -21,8 +22,9 @@ import { IModalState, ModalActionCreators } from '../store/modules/modal';
2122import { IMapDispatchToProps , IMapStateToProps } from '../store' ;
2223import DragAndDropContainer from './DragAndDropContainer' ;
2324import EntryModalHelper from '../helper/entry/entryModalHelper' ;
25+ import ipcRendererHelper from '../helper/ipcRendererHelper' ;
2426
25- interface IProps extends IReduxDispatch , IReduxState { }
27+ interface IProps extends IReduxDispatch , IReduxState { }
2628
2729class Workspace extends Component < IProps > {
2830 private lastHwName ?: string ;
@@ -159,6 +161,9 @@ class Workspace extends Component<IProps> {
159161 addEventListener ( 'saveCanvasImage' , ( data : any ) => {
160162 this . handleCanvasImageSave ( data ) ;
161163 } ) ;
164+ addEventListener ( 'saveBlockImages' , ( data : any ) => {
165+ this . handleBlockImageSave ( data ) ;
166+ } ) ;
162167 // exportObject
163168 addEventListener ( 'exportObject' , EntryUtils . exportObject ) ;
164169 // 리스트 Import
@@ -225,6 +230,26 @@ class Workspace extends Component<IProps> {
225230 }
226231 }
227232
233+ async handleBlockImageSave ( data : any ) {
234+ const images = data . images ;
235+ try {
236+ RendererUtils . showOpenDialog ( {
237+ properties : [ 'openDirectory' ] ,
238+ filters : [ { name : 'Image' , extensions : [ 'png' ] } ] ,
239+ } ) . then ( async ( { filePaths } ) => {
240+ const dirPath = filePaths [ 0 ] ;
241+ if ( ! dirPath ) {
242+ throw 'invalid filePaths' ;
243+ }
244+ console . log ( Constants . sep ) ;
245+ const savePath = `${ dirPath } ${ Constants . sep } ` ;
246+ await ipcRendererHelper . captureBlockImage ( images , savePath ) ;
247+ } )
248+ } catch ( err ) {
249+ console . error ( err ) ;
250+ }
251+ }
252+
228253 handleChangeWorkspaceMode ( ) {
229254 const workspace = Entry . getMainWS ( ) ;
230255 const { mode } = workspace ;
@@ -301,21 +326,21 @@ class Workspace extends Component<IProps> {
301326 if ( hw . programConnected && hw . hwModule ) {
302327 const hwName = hw . hwModule . name ;
303328 if ( _includes ( EntryStatic . hwMiniSupportList , hwName ) ) {
304- hwCategoryList . forEach ( function ( categoryName : string ) {
329+ hwCategoryList . forEach ( function ( categoryName : string ) {
305330 blockMenu . unbanCategory ( categoryName ) ;
306331 } ) ;
307332 blockMenu . banCategory ( 'arduino' ) ;
308333 blockMenu . banCategory ( 'hw_robot' ) ;
309334 } else {
310- hwCategoryList . forEach ( function ( categoryName : string ) {
335+ hwCategoryList . forEach ( function ( categoryName : string ) {
311336 blockMenu . banCategory ( categoryName ) ;
312337 } ) ;
313338 blockMenu . banCategory ( 'hw_robot' ) ;
314339 blockMenu . unbanCategory ( 'arduino' ) ;
315340 }
316341 this . lastHwName = hwName ;
317342 } else {
318- hwCategoryList . forEach ( function ( categoryName : string ) {
343+ hwCategoryList . forEach ( function ( categoryName : string ) {
319344 blockMenu . banCategory ( categoryName ) ;
320345 } ) ;
321346 blockMenu . banCategory ( 'arduino' ) ;
0 commit comments