Skip to content

Commit

Permalink
Fix: allow opening PDF with Collabora
Browse files Browse the repository at this point in the history
Signed-off-by: Raul <r.ferreira.fuentes@gmail.com>
  • Loading branch information
Raudius committed Jul 26, 2022
1 parent 49e2551 commit 4c49ca5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions css/filetypes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@
.icon-filetype-draw {
background-image: url('../img/x-office-drawing.svg');
}

.icon-richdocuments {
background-image: url(../img/app-dark.svg);
}

body.dark .icon-richdocuments {
background-image: url(../img/app.svg);
}
25 changes: 25 additions & 0 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,28 @@ if (OCA.Viewer) {
theme: 'light',
})
}

// TODO: Viewer.openWith introduced with https://github.com/nextcloud/viewer/pull/1273
// This check can be replaced with `if(OCA.Viewer)` once NC 24 is EOL.
if (OCA.Viewer.openWith) {
const supportedMimes = OC.getCapabilities().richdocuments.mimetypes.concat(OC.getCapabilities().richdocuments.mimetypesNoDefaultOpen)
const actionName = 'Edit with ' + OC.getCapabilities().richdocuments.productName
const actionDisplayName = t('richdocuments', 'Edit with {productName}', { productName: OC.getCapabilities().richdocuments.productName }, undefined, { escape: false })

for (const mime of supportedMimes) {
const action = {
name: actionName,
mime,
permissions: OC.PERMISSION_READ,
iconClass: 'icon-richdocuments',
displayName: actionDisplayName,
actionHandler: (fileName, context) => {
OCA.Viewer.openWith('richdocuments', {
path: context.fileInfoModel.getFullPath()
})
}
}

OCA.Files.fileActions.registerAction(action)
}
}

0 comments on commit 4c49ca5

Please sign in to comment.