Skip to content

Commit cb5de8a

Browse files
authored
Merge pull request #7927 from nextcloud/backport/7889/stable31
[stable31] feat: add downloadCallback for Viewer handler
2 parents 648c479 + de4eef4 commit cb5de8a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/viewer.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,20 @@ 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', {
38+
fileId: fileInfo.fileid,
39+
})
40+
await editor.save()
41+
return
42+
}
43+
}
44+
}
45+
},
3146
})
3247
}

0 commit comments

Comments
 (0)