File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,11 +24,15 @@ const typedocItems: SidebarItems = JSON.parse(
2424) ;
2525
2626function findSidebarCategory ( items : SidebarItems , label : string ) : SidebarCategory {
27- return items . find ( ( item ) : item is SidebarCategory =>
27+ const category = items . find ( ( item ) : item is SidebarCategory =>
2828 typeof item === 'object' &&
2929 item . type === 'category' &&
3030 item . label === label
3131 ) ;
32+ if ( ! category ) {
33+ throw new Error ( `Cannot find sidebar category "${ label } "` ) ;
34+ }
35+ return category ;
3236}
3337
3438const sidebars : SidebarsConfig = {
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
22import { HashMap } from '@reactodia/hashmap' ;
33import * as Reactodia from '@reactodia/workspace' ;
4- import { saveAs } from 'file-saver' ;
54
65export function ExampleToolbarMenu ( ) {
76 const { model, editor, overlay} = Reactodia . useWorkspace ( ) ;
@@ -56,8 +55,16 @@ export function ExampleToolbarMenu() {
5655 const diagramLayout = model . exportLayout ( ) ;
5756 const layoutString = JSON . stringify ( diagramLayout ) ;
5857 const blob = new Blob ( [ layoutString ] , { type : 'application/json' } ) ;
58+ const blobUrl = URL . createObjectURL ( blob ) ;
5959 const timestamp = new Date ( ) . toISOString ( ) . replaceAll ( / [ Z \s : - ] / g, '' ) ;
60- saveAs ( blob , `reactodia-diagram-${ timestamp } .json` ) ;
60+ try {
61+ const downloadLink = document . createElement ( 'a' ) ;
62+ downloadLink . href = blobUrl ;
63+ downloadLink . download = `reactodia-diagram-${ timestamp } .json` ;
64+ downloadLink . click ( ) ;
65+ } finally {
66+ URL . revokeObjectURL ( blobUrl ) ;
67+ }
6168 } } >
6269 Save diagram to file
6370 </ Reactodia . ToolbarActionSave >
Original file line number Diff line number Diff line change 44 "compilerOptions" : {
55 "target" : " ES2022" ,
66 "lib" : [" DOM" , " ES2022" ],
7- "baseUrl" : " ."
7+ "baseUrl" : " ." ,
8+ "strict" : true
89 },
910 "exclude" : [
1011 " ./reactodia-workspace"
You can’t perform that action at this time.
0 commit comments