diff --git a/css/filetypes.scss b/css/filetypes.scss index 6d3bbe5392..d811549b0f 100644 --- a/css/filetypes.scss +++ b/css/filetypes.scss @@ -13,3 +13,8 @@ .icon-filetype-draw { background-image: url('../img/x-office-drawing.svg'); } + +.icon-richdocuments { + background-image: url(../img/app-dark.svg); + filter: var(--background-invert-if-dark); +} diff --git a/src/viewer.js b/src/viewer.js index 92d7e57c14..344608159d 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -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 = getCapabilities().richdocuments.mimetypesNoDefaultOpen + const actionName = 'Edit with ' + getCapabilities().richdocuments.productName + const actionDisplayName = t('richdocuments', 'Edit with {productName}', { productName: 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) + } +}