From 6e6432bfee840eed5a8bca5bd8db003d14248e49 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 27 Dec 2021 17:40:46 +0100 Subject: [PATCH] Plugins: Added revealResourceFile command --- .eslintignore | 3 +++ .gitignore | 3 +++ .../gui/MainScreen/commands/index.ts | 2 ++ .../MainScreen/commands/revealResourceFile.ts | 20 +++++++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 packages/app-desktop/gui/MainScreen/commands/revealResourceFile.ts diff --git a/.eslintignore b/.eslintignore index 0d8588a015..8770d3931d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -313,6 +313,9 @@ packages/app-desktop/gui/MainScreen/commands/renameFolder.js.map packages/app-desktop/gui/MainScreen/commands/renameTag.d.ts packages/app-desktop/gui/MainScreen/commands/renameTag.js packages/app-desktop/gui/MainScreen/commands/renameTag.js.map +packages/app-desktop/gui/MainScreen/commands/revealResourceFile.d.ts +packages/app-desktop/gui/MainScreen/commands/revealResourceFile.js +packages/app-desktop/gui/MainScreen/commands/revealResourceFile.js.map packages/app-desktop/gui/MainScreen/commands/search.d.ts packages/app-desktop/gui/MainScreen/commands/search.js packages/app-desktop/gui/MainScreen/commands/search.js.map diff --git a/.gitignore b/.gitignore index 481ccb8c41..314e1146f7 100644 --- a/.gitignore +++ b/.gitignore @@ -303,6 +303,9 @@ packages/app-desktop/gui/MainScreen/commands/renameFolder.js.map packages/app-desktop/gui/MainScreen/commands/renameTag.d.ts packages/app-desktop/gui/MainScreen/commands/renameTag.js packages/app-desktop/gui/MainScreen/commands/renameTag.js.map +packages/app-desktop/gui/MainScreen/commands/revealResourceFile.d.ts +packages/app-desktop/gui/MainScreen/commands/revealResourceFile.js +packages/app-desktop/gui/MainScreen/commands/revealResourceFile.js.map packages/app-desktop/gui/MainScreen/commands/search.d.ts packages/app-desktop/gui/MainScreen/commands/search.js packages/app-desktop/gui/MainScreen/commands/search.js.map diff --git a/packages/app-desktop/gui/MainScreen/commands/index.ts b/packages/app-desktop/gui/MainScreen/commands/index.ts index 88eb61c1b5..97743f6c2a 100644 --- a/packages/app-desktop/gui/MainScreen/commands/index.ts +++ b/packages/app-desktop/gui/MainScreen/commands/index.ts @@ -17,6 +17,7 @@ import * as openTag from './openTag'; import * as print from './print'; import * as renameFolder from './renameFolder'; import * as renameTag from './renameTag'; +import * as revealResourceFile from './revealResourceFile'; import * as search from './search'; import * as setTags from './setTags'; import * as showModalMessage from './showModalMessage'; @@ -54,6 +55,7 @@ const index:any[] = [ print, renameFolder, renameTag, + revealResourceFile, search, setTags, showModalMessage, diff --git a/packages/app-desktop/gui/MainScreen/commands/revealResourceFile.ts b/packages/app-desktop/gui/MainScreen/commands/revealResourceFile.ts new file mode 100644 index 0000000000..6b50e019ba --- /dev/null +++ b/packages/app-desktop/gui/MainScreen/commands/revealResourceFile.ts @@ -0,0 +1,20 @@ +import { CommandRuntime, CommandDeclaration, CommandContext } from '@joplin/lib/services/CommandService'; +import { _ } from '@joplin/lib/locale'; +import Resource from '@joplin/lib/models/Resource'; +import bridge from '../../../services/bridge'; + +export const declaration: CommandDeclaration = { + name: 'revealResourceFile', + label: _('Reveal file in folder'), +}; + +export const runtime = (): CommandRuntime => { + return { + execute: async (_context: CommandContext, itemId: string) => { + const resource = await Resource.load(itemId); + if (!resource) throw new Error(`No such resource: ${itemId}`); + const fullPath = Resource.fullPath(resource); + bridge().showItemInFolder(fullPath); + }, + }; +};