Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/i18n/locales/en_US/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
},
"editor": {
"label": "Editor",
"copy": "Copy Snippet to Clipboard",
"copySnippet": "Copy Snippet",
"copyNote": "Copy Note",
"format": "Format",
"mode": "Mode",
"modeRaw": "Raw",
Expand Down
2 changes: 2 additions & 0 deletions src/main/i18n/locales/en_US/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@
"toHtml": "Export to HTML"
},
"copy": {
"snippet": "Copy Snippet",
"snippetLink": "Copy Snippet Link",
"note": "Copy Note",
"noteLink": "Copy Note Link"
},
"select": {
Expand Down
3 changes: 2 additions & 1 deletion src/main/i18n/locales/ru_RU/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
},
"editor": {
"label": "Редактор",
"copy": "Копировать сниппет в буфер обмена",
"copySnippet": "Копировать сниппет",
"copyNote": "Копировать заметку",
"format": "Форматировать",
"mode": "Режим",
"modeRaw": "Исходный",
Expand Down
5 changes: 4 additions & 1 deletion src/main/i18n/locales/ru_RU/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@
"toHtml": "Экспорт в HTML"
},
"copy": {
"snippetLink": "Копировать ссылку на сниппет"
"snippet": "Копировать сниппет",
"snippetLink": "Копировать ссылку на сниппет",
"note": "Копировать заметку",
"noteLink": "Копировать ссылку на заметку"
},
"select": {
"directory": "Выбрать директорию"
Expand Down
10 changes: 9 additions & 1 deletion src/main/menu/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
})
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/main/types/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export type CombineWith<T extends string, U extends string> = `${U}:${T}`

type MainMenuAction =
| 'add-description'
| 'copy-note'
| 'copy-snippet'
| 'find'
| 'font-size-decrease'
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/components/editor/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { Language } from '@/components/editor/types'
import {
useApp,
useDonations,
useEditor,
useResizeHandle,
useSnippets,
Expand Down Expand Up @@ -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) => {
Expand Down
13 changes: 12 additions & 1 deletion src/renderer/components/notes/NotesEditorPane.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<script setup lang="ts">
import * as Select from '@/components/ui/shadcn/select'
import {
useDonations,
useEditableField,
useNavigationHistory,
useNotes,
useNotesApp,
useNoteUpdate,
} from '@/composables'
import { i18n } from '@/electron'
import { i18n, ipc } from '@/electron'
import { navigateBack, navigateForward } from '@/ipc/listeners/deepLinks'
import { router, RouterName } from '@/router'
import { getEntryNameConflictMessage } from '@/utils'
import { useClipboard } from '@vueuse/core'
import {
BookOpen,
ChevronLeft,
Expand Down Expand Up @@ -232,6 +234,15 @@ const content = computed({
})

const textStats = computed(() => getTextStats(content.value))

const { copy } = useClipboard()

ipc.on('main-menu:copy-note', () => {
if (!selectedNote.value)
return
copy(selectedNote.value.content)
useDonations().incrementCopy('notes')
})
</script>

<template>
Expand Down
16 changes: 15 additions & 1 deletion src/renderer/components/notes/NotesListItemContextMenu.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<script setup lang="ts">
import * as ContextMenu from '@/components/ui/shadcn/context-menu'
import { useDialog, useNotes, useNotesApp, useNoteSearch } from '@/composables'
import {
useDialog,
useDonations,
useNotes,
useNotesApp,
useNoteSearch,
} from '@/composables'
import { LibraryFilter } from '@/composables/types'
import { i18n, ipc } from '@/electron'
import { isMac } from '@/utils'
Expand Down Expand Up @@ -150,6 +156,11 @@ function onRevealInFileManager() {
function onCopyNoteLink() {
copy(`masscode://goto?noteId=${props.note.id}`)
}

function onCopyNoteContent() {
copy(props.note.content)
useDonations().incrementCopy('notes')
}
</script>

<template>
Expand All @@ -167,6 +178,9 @@ function onCopyNoteLink() {
<ContextMenu.ContextMenuItem @click="onRevealInFileManager">
{{ revealInFileManagerLabel }}
</ContextMenu.ContextMenuItem>
<ContextMenu.ContextMenuItem @click="onCopyNoteContent">
{{ i18n.t("action.copy.note") }}
</ContextMenu.ContextMenuItem>
<ContextMenu.ContextMenuItem @click="onCopyNoteLink">
{{ i18n.t("action.copy.noteLink") }}
</ContextMenu.ContextMenuItem>
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/components/snippet/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as ContextMenu from '@/components/ui/shadcn/context-menu'
import {
useApp,
useDialog,
useDonations,
useNavigationHistory,
useSnippets,
} from '@/composables'
Expand Down Expand Up @@ -201,6 +202,11 @@ function onCopySnippetLink() {
copy(`masscode://goto?snippetId=${props.snippet.id}`)
}

function onCopySnippetContent() {
copy(props.snippet.contents[0]?.value || '')
useDonations().incrementCopy('code')
}

function onDragStart(event: DragEvent) {
const ids
= selectedSnippetIds.value.length > 1
Expand Down Expand Up @@ -306,6 +312,9 @@ onClickOutside(snippetRef, () => {
}}
</ContextMenu.ContextMenuItem>
<ContextMenu.ContextMenuSeparator />
<ContextMenu.ContextMenuItem @click="onCopySnippetContent">
{{ i18n.t("action.copy.snippet") }}
</ContextMenu.ContextMenuItem>
<ContextMenu.ContextMenuItem @click="onCopySnippetLink">
{{ i18n.t("action.copy.snippetLink") }}
</ContextMenu.ContextMenuItem>
Expand Down