@@ -42,6 +42,7 @@ interface ModuleOutlineProps {
4242 blocksEditor : editor . Editor | null ;
4343 currentModule : commonStorage . Module | null ;
4444 setCurrentModule : ( module : commonStorage . Module | null ) => void ;
45+ saveBlocks : ( ) => Promise < boolean > ;
4546}
4647
4748export default function ModuleOutline ( props : ModuleOutlineProps ) {
@@ -274,7 +275,7 @@ export default function ModuleOutline(props: ModuleOutlineProps) {
274275 // Set the function to be executed if the user clicks 'ok'.
275276 afterPopconfirmOk . current = async ( ) => {
276277 setPopconfirmLoading ( true ) ;
277- const success = await saveBlocks ( ) ;
278+ const success = await props . saveBlocks ( ) ;
278279 setOpenPopconfirm ( false ) ;
279280 setPopconfirmLoading ( false ) ;
280281 if ( success ) {
@@ -644,30 +645,7 @@ export default function ModuleOutline(props: ModuleOutlineProps) {
644645 }
645646 } ;
646647 const handleSaveClicked = async ( ) => {
647- saveBlocks ( ) ;
648- } ;
649-
650- const saveBlocks = async ( ) : Promise < boolean > => {
651- return new Promise ( async ( resolve , reject ) => {
652- if ( ! props . blocksEditor || ! currentModulePath ) {
653- reject ( new Error ( ) ) ;
654- return ;
655- }
656- try {
657- await props . blocksEditor . saveBlocks ( ) ;
658- props . messageApi . open ( {
659- type : 'success' ,
660- content : 'Save completed successfully.' ,
661- } ) ;
662- resolve ( true ) ;
663- } catch ( e ) {
664- console . log ( 'Failed to save the blocks. Caught the following error...' ) ;
665- console . log ( e ) ;
666- props . setAlertErrorMessage ( 'Failed to save the blocks.' ) ;
667- reject ( new Error ( 'Failed to save the blocks.' ) ) ;
668- }
669-
670- } ) ;
648+ props . saveBlocks ( ) ;
671649 } ;
672650
673651 const initializeModules = async ( ) => {
0 commit comments