diff options
-rw-r--r-- | src/files.js | 46 | ||||
-rw-r--r-- | src/viewer.js | 9 |
2 files changed, 5 insertions, 50 deletions
diff --git a/src/files.js b/src/files.js index 834f5d0a..838d5770 100644 --- a/src/files.js +++ b/src/files.js @@ -49,52 +49,6 @@ const odfViewer = { excludeMimeFromDefaultOpen: OC.getCapabilities().richdocuments.mimetypesNoDefaultOpen, hideDownloadMimes: ['image/jpeg', 'image/svg+xml', 'image/cgm', 'image/vnd.dxf', 'image/x-emf', 'image/x-wmf', 'image/x-wpg', 'image/x-freehand', 'image/bmp', 'image/png', 'image/gif', 'image/tiff', 'image/jpg', 'image/jpeg', 'text/plain', 'application/pdf'], - registerFileActions() { - const EDIT_ACTION_NAME = 'Edit with ' + OC.getCapabilities().richdocuments.productName - for (const mime of odfViewer.supportedMimes) { - OCA.Files.fileActions.register( - mime, - EDIT_ACTION_NAME, - OC.PERMISSION_READ, - imagePath('core', 'actions/rename'), - (fileName, context) => { - // Workaround since the new template frontend doesn't pass - // the full context yet nor the filelist contains the element - // at the point when the action is triggered. - // This will be fixed by https://github.com/nextcloud/server/pull/25797 - // but this should be kept for backward compatibility for now - if (!context?.$file) { - if (context?.fileList) { - context.fileList.setViewerMode(true) - } - const filePath = (context.dir === '/' ? '/' : context.dir + '/') + fileName - OCA.Files.App.fileList.filesClient.getFileInfo(filePath).then((status, fileInfo) => { - const fileModel = context.fileList.findFile(fileName) - const shareOwnerId = fileModel?.shareOwnerId || fileInfo?.shareOwnerId - context.fileId = fileInfo.id - return this.onEdit(fileName, { - ...context, - shareOwnerId, - }) - }) - return - } - - const fileModel = context.fileList.findFile(fileName) - const shareOwnerId = fileModel?.shareOwnerId - return this.onEdit(fileName, { - ...context, - shareOwnerId, - }) - }, - t('richdocuments', 'Edit with {productName}', { productName: OC.getCapabilities().richdocuments.productName }, undefined, { escape: false }) - ) - if (odfViewer.excludeMimeFromDefaultOpen.indexOf(mime) === -1 || isDownloadHidden) { - OCA.Files.fileActions.setDefault(mime, EDIT_ACTION_NAME) - } - } - }, - onEdit(fileName, context) { let fileDir let fileId diff --git a/src/viewer.js b/src/viewer.js index 0e625911..396a4021 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -41,9 +41,10 @@ if (OCA.Viewer) { // 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.mimetypesNoDefaultOpen - const actionName = 'Edit with ' + OC.getCapabilities().richdocuments.productName - const actionDisplayName = t('richdocuments', 'Edit with {productName}', { productName: OC.getCapabilities().richdocuments.productName }, undefined, { escape: false }) + const supportedMimes = getCapabilities().richdocuments.mimetypesNoDefaultOpen + const actionName = 'Edit with ' + getCapabilities().richdocuments.productName + const actionDisplayNameEdit = t('richdocuments', 'Edit with {productName}', { productName: getCapabilities().richdocuments.productName }, undefined, { escape: false }) + const actionDisplayNameOpen = t('richdocuments', 'Open with {productName}', { productName: getCapabilities().richdocuments.productName }, undefined, { escape: false }) for (const mime of supportedMimes) { const action = { @@ -51,7 +52,7 @@ if (OCA.Viewer.openWith) { mime, permissions: OC.PERMISSION_READ, iconClass: 'icon-richdocuments', - displayName: actionDisplayName, + displayName: mime === 'application/pdf' ? actionDisplayNameOpen : actionDisplayNameEdit, actionHandler: (fileName, context) => { OCA.Viewer.openWith('richdocuments', { path: context.fileInfoModel.getFullPath() |