File tree Expand file tree Collapse file tree 3 files changed +80
-1
lines changed Expand file tree Collapse file tree 3 files changed +80
-1
lines changed Original file line number Diff line number Diff line change
1
+ # 0.1.8
2
+ - Added types for more ` export ` parameters
3
+
1
4
# 0.1.7
2
5
- Added ` parentEvent ` parameters to ` onSave ` and ` onClose ` events when the callbacks are triggered by another event.
3
6
Original file line number Diff line number Diff line change @@ -239,4 +239,28 @@ export type ActionExport = {
239
239
message ?: string ;
240
240
xml ?: string ;
241
241
parentEvent ?: string ;
242
+ /** Enable a spinner while the image is being generated */
243
+ spin ?: boolean ;
244
+ /** Specify the zoom (default is 1) */
245
+ scale ?: number ;
246
+ /** Define the array of visible layer IDs */
247
+ layerIds ?: string [ ] ;
248
+ /** Specify the page to be exported */
249
+ pageId ?: string ;
250
+ /** Specify to export the current selected page */
251
+ currentPage ?: boolean ;
252
+ /** (px) Defines the width of the image to be exported */
253
+ width ?: string ;
254
+ /** (px) Defines the border */
255
+ border ?: string ;
256
+ /** Specifies if a shadow filter should be applied to the export */
257
+ shadow ?: boolean ;
258
+ /** Specifies if a grid should be added */
259
+ grid ?: boolean ;
260
+ /** Specifies if the theme should be kept (eg. for dark themes) */
261
+ keepTheme ?: boolean ;
262
+ /** Specifies if a transparent background should be used */
263
+ transparent ?: boolean ;
264
+ /** Specifies the background color */
265
+ background ?: string ;
242
266
} ;
Original file line number Diff line number Diff line change @@ -252,7 +252,7 @@ export const SetSpinner: Story = {
252
252
]
253
253
} ;
254
254
255
- export const ExportData : Story = {
255
+ export const ExportDataSvg : Story = {
256
256
args : WithData . args ,
257
257
decorators : [
258
258
( Story , context ) => {
@@ -298,6 +298,58 @@ export const ExportData: Story = {
298
298
]
299
299
} ;
300
300
301
+ export const ExportDataPng : Story = {
302
+ args : WithData . args ,
303
+ decorators : [
304
+ ( Story , context ) => {
305
+ const [ isLoaded , setIsLoaded ] = useState ( false ) ;
306
+ const [ imgData , setImgData ] = useState < string | null > ( null ) ;
307
+ const drawioRef = useRef < DrawIoEmbedRef > ( null ) ;
308
+
309
+ useEffect ( ( ) => {
310
+ if ( drawioRef . current && isLoaded ) {
311
+ drawioRef . current . exportDiagram ( {
312
+ format : 'png' ,
313
+ transparent : false ,
314
+ grid : true ,
315
+ scale : 1.5 ,
316
+ shadow : true
317
+ } ) ;
318
+ }
319
+ } , [ drawioRef . current , isLoaded ] ) ;
320
+
321
+ return (
322
+ < >
323
+ < Story
324
+ args = { {
325
+ ...context . args ,
326
+ onLoad : ( ) => setIsLoaded ( true ) ,
327
+ onExport ( data ) {
328
+ console . log ( 'onExport' , data ) ;
329
+ setImgData ( data . data ) ;
330
+ } ,
331
+ onSave ( data ) {
332
+ console . log ( 'onSave' , data ) ;
333
+ } ,
334
+ onClose ( data ) {
335
+ console . log ( 'onClose' , data ) ;
336
+ } ,
337
+ ref : drawioRef
338
+ } }
339
+ />
340
+ < div style = { { marginTop : '10px' } } >
341
+ < strong > Result as transparent PNG (with extra options)</ strong >
342
+ < br />
343
+ < div style = { { backgroundColor : '#DDD' } } >
344
+ { imgData && < img src = { imgData } /> }
345
+ </ div >
346
+ </ div >
347
+ </ >
348
+ ) ;
349
+ }
350
+ ]
351
+ } ;
352
+
301
353
export const NoSaveAndExit : Story = {
302
354
args : {
303
355
urlParameters : {
You can’t perform that action at this time.
0 commit comments