diff --git a/.eslintignore b/.eslintignore index cfc8f8b1fe..b28043da59 100644 --- a/.eslintignore +++ b/.eslintignore @@ -151,6 +151,7 @@ packages/app-desktop/app.js packages/app-desktop/bridge.js packages/app-desktop/checkForUpdates.js packages/app-desktop/commands/copyDevCommand.js +packages/app-desktop/commands/copyToClipboard.js packages/app-desktop/commands/editProfileConfig.js packages/app-desktop/commands/emptyTrash.js packages/app-desktop/commands/exportDeletionLog.test.js diff --git a/.gitignore b/.gitignore index d44e23eec1..0b26932bfe 100644 --- a/.gitignore +++ b/.gitignore @@ -125,6 +125,7 @@ packages/app-desktop/app.js packages/app-desktop/bridge.js packages/app-desktop/checkForUpdates.js packages/app-desktop/commands/copyDevCommand.js +packages/app-desktop/commands/copyToClipboard.js packages/app-desktop/commands/editProfileConfig.js packages/app-desktop/commands/emptyTrash.js packages/app-desktop/commands/exportDeletionLog.test.js diff --git a/packages/app-desktop/commands/copyToClipboard.ts b/packages/app-desktop/commands/copyToClipboard.ts new file mode 100644 index 0000000000..0b61cd8cf7 --- /dev/null +++ b/packages/app-desktop/commands/copyToClipboard.ts @@ -0,0 +1,15 @@ +import { CommandRuntime, CommandDeclaration } from '@joplin/lib/services/CommandService'; +import { clipboard } from 'electron'; + +export const declaration: CommandDeclaration = { + name: 'copyToClipboard', +}; + +export const runtime = (): CommandRuntime => { + return { + execute: async (_context, content: string) => { + if (!content || (typeof content !== 'string')) return; + clipboard.writeText(content); + }, + }; +}; diff --git a/packages/app-desktop/commands/index.ts b/packages/app-desktop/commands/index.ts index d1801e1dac..385f4da0b2 100644 --- a/packages/app-desktop/commands/index.ts +++ b/packages/app-desktop/commands/index.ts @@ -1,5 +1,6 @@ // AUTO-GENERATED using `gulp buildScriptIndexes` import * as copyDevCommand from './copyDevCommand'; +import * as copyToClipboard from './copyToClipboard'; import * as editProfileConfig from './editProfileConfig'; import * as emptyTrash from './emptyTrash'; import * as exportDeletionLog from './exportDeletionLog'; @@ -24,6 +25,7 @@ import * as toggleTabMovesFocus from './toggleTabMovesFocus'; const index: any[] = [ copyDevCommand, + copyToClipboard, editProfileConfig, emptyTrash, exportDeletionLog,