Skip to content

Commit 93fa5aa

Browse files
committed
feat: add downloadCallback for Viewer handler
Signed-off-by: silver <s.szmajduch@posteo.de>
1 parent 2c561dd commit 93fa5aa

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/viewer.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,18 @@ 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+
const editors = window.OCA?.Text?.editorComponents
34+
if (editors instanceof Set) {
35+
for (const editor of editors) {
36+
if (editor?.fileId === fileInfo.fileid && editor?.dirty) {
37+
logger.debug('Saving file before download', { fileId: fileInfo.fileid })
38+
await editor.save()
39+
return
40+
}
41+
}
42+
}
43+
},
3144
})
3245
}

0 commit comments

Comments
 (0)