From 0c25edbf172fb613e0f8e4f3b41cda6cea59f09f Mon Sep 17 00:00:00 2001 From: Anton Reshetov Date: Wed, 29 Apr 2026 17:50:27 +0300 Subject: [PATCH] feat: copy snippet/note content actions --- src/main/i18n/locales/en_US/menu.json | 3 ++- src/main/i18n/locales/en_US/ui.json | 2 ++ src/main/i18n/locales/ru_RU/menu.json | 3 ++- src/main/i18n/locales/ru_RU/ui.json | 5 ++++- src/main/menu/main.ts | 10 +++++++++- src/main/types/ipc.ts | 1 + src/renderer/components/editor/Editor.vue | 2 ++ .../components/notes/NotesEditorPane.vue | 13 ++++++++++++- .../notes/NotesListItemContextMenu.vue | 16 +++++++++++++++- src/renderer/components/snippet/Item.vue | 9 +++++++++ 10 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/main/i18n/locales/en_US/menu.json b/src/main/i18n/locales/en_US/menu.json index 65ebcb25..d0ea0d63 100644 --- a/src/main/i18n/locales/en_US/menu.json +++ b/src/main/i18n/locales/en_US/menu.json @@ -60,7 +60,8 @@ }, "editor": { "label": "Editor", - "copy": "Copy Snippet to Clipboard", + "copySnippet": "Copy Snippet", + "copyNote": "Copy Note", "format": "Format", "mode": "Mode", "modeRaw": "Raw", diff --git a/src/main/i18n/locales/en_US/ui.json b/src/main/i18n/locales/en_US/ui.json index 81e80d89..a234a33d 100644 --- a/src/main/i18n/locales/en_US/ui.json +++ b/src/main/i18n/locales/en_US/ui.json @@ -203,7 +203,9 @@ "toHtml": "Export to HTML" }, "copy": { + "snippet": "Copy Snippet", "snippetLink": "Copy Snippet Link", + "note": "Copy Note", "noteLink": "Copy Note Link" }, "select": { diff --git a/src/main/i18n/locales/ru_RU/menu.json b/src/main/i18n/locales/ru_RU/menu.json index 54824f52..1f33f05f 100644 --- a/src/main/i18n/locales/ru_RU/menu.json +++ b/src/main/i18n/locales/ru_RU/menu.json @@ -60,7 +60,8 @@ }, "editor": { "label": "Редактор", - "copy": "Копировать сниппет в буфер обмена", + "copySnippet": "Копировать сниппет", + "copyNote": "Копировать заметку", "format": "Форматировать", "mode": "Режим", "modeRaw": "Исходный", diff --git a/src/main/i18n/locales/ru_RU/ui.json b/src/main/i18n/locales/ru_RU/ui.json index 533ad96c..5c52d382 100644 --- a/src/main/i18n/locales/ru_RU/ui.json +++ b/src/main/i18n/locales/ru_RU/ui.json @@ -203,7 +203,10 @@ "toHtml": "Экспорт в HTML" }, "copy": { - "snippetLink": "Копировать ссылку на сниппет" + "snippet": "Копировать сниппет", + "snippetLink": "Копировать ссылку на сниппет", + "note": "Копировать заметку", + "noteLink": "Копировать ссылку на заметку" }, "select": { "directory": "Выбрать директорию" diff --git a/src/main/menu/main.ts b/src/main/menu/main.ts index 769a3bb2..8a364d79 100644 --- a/src/main/menu/main.ts +++ b/src/main/menu/main.ts @@ -487,7 +487,7 @@ function createEditorMenuItems(context: MainMenuContext): MenuConfig[] { if (context.editor.kind === 'code') { items.push({ - label: i18n.t('menu:editor.copy'), + label: i18n.t('menu:editor.copySnippet'), click: () => send('main-menu:copy-snippet'), accelerator: 'CommandOrControl+Shift+C', }) @@ -514,6 +514,14 @@ function createEditorMenuItems(context: MainMenuContext): MenuConfig[] { }) } + if (context.editor.kind === 'notes') { + items.push({ + label: i18n.t('menu:editor.copyNote'), + click: () => send('main-menu:copy-note'), + accelerator: 'CommandOrControl+Shift+C', + }) + } + const notesModeItems = createNotesEditorModeItems(context) if (notesModeItems.length) { if (items.length) { diff --git a/src/main/types/ipc.ts b/src/main/types/ipc.ts index 1a58c25f..6c48f3fc 100644 --- a/src/main/types/ipc.ts +++ b/src/main/types/ipc.ts @@ -4,6 +4,7 @@ export type CombineWith = `${U}:${T}` type MainMenuAction = | 'add-description' + | 'copy-note' | 'copy-snippet' | 'find' | 'font-size-decrease' diff --git a/src/renderer/components/editor/Editor.vue b/src/renderer/components/editor/Editor.vue index c6de56aa..3375a724 100644 --- a/src/renderer/components/editor/Editor.vue +++ b/src/renderer/components/editor/Editor.vue @@ -2,6 +2,7 @@ import type { Language } from '@/components/editor/types' import { useApp, + useDonations, useEditor, useResizeHandle, useSnippets, @@ -202,6 +203,7 @@ async function init() { ipc.on('main-menu:copy-snippet', () => { const { copy } = useClipboard({ source: editor?.getValue() || '' }) copy() + useDonations().incrementCopy('code') }) watch(selectedSnippetContent, (v, oldV) => { diff --git a/src/renderer/components/notes/NotesEditorPane.vue b/src/renderer/components/notes/NotesEditorPane.vue index bf374fda..be01b4b1 100644 --- a/src/renderer/components/notes/NotesEditorPane.vue +++ b/src/renderer/components/notes/NotesEditorPane.vue @@ -1,16 +1,18 @@