File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,5 +28,26 @@ if (typeof OCA.Viewer === 'undefined') {
2828 group : null ,
2929 theme : 'default' ,
3030 canCompare : true ,
31+ downloadCallback : async ( fileInfo ) => {
32+ // Save any unsaved changes before download
33+ logger . debug ( 'Download callback triggered' , { fileInfo } )
34+ const editors = window . OCA ?. Text ?. editorComponents
35+ logger . debug ( 'Active editors' , { editors, count : editors ?. size } )
36+ if ( editors instanceof Set ) {
37+ for ( const editor of editors ) {
38+ logger . debug ( 'Checking editor' , {
39+ editorFileId : editor ?. fileId ,
40+ fileInfoId : fileInfo . fileid ,
41+ dirty : editor ?. dirty
42+ } )
43+ if ( editor ?. fileId === fileInfo . fileid && editor ?. dirty ) {
44+ logger . debug ( 'Saving file before download' , { fileId : fileInfo . fileid } )
45+ await editor . save ( )
46+ return
47+ }
48+ }
49+ }
50+ logger . debug ( 'No matching editor found or no unsaved changes' )
51+ } ,
3152 } )
3253}
You can’t perform that action at this time.
0 commit comments