From 2a8ffd77a16e12deb97b06b945d0dc7f8b119884 Mon Sep 17 00:00:00 2001 From: Sergey Kurdin Date: Thu, 29 Aug 2024 22:23:24 -0400 Subject: [PATCH 1/2] update to shortcut for quick copy paste ctrl + number --- .../ClipboardHistoryQuickPasteRow.tsx | 6 ++++- .../ClipboardHistory/ClipboardHistoryRow.tsx | 4 ++- .../src/pages/main/ClipboardHistoryPage.tsx | 27 +++++++++++++++++++ .../main/ClipboardHistoryQuickPastePage.tsx | 24 +++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx b/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx index 0acd02bf..e9062751 100644 --- a/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx +++ b/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx @@ -54,6 +54,7 @@ interface ClipboardHistoryQuickPasteRowProps { index?: number style?: CSSProperties isExpanded: boolean + isWindows?: boolean isWrapText: boolean isSelected?: boolean isDeleting?: boolean @@ -125,6 +126,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ isScrolling = false, isPinnedTop = false, isPinnedTopFirst = false, + isWindows, isDisabledPinnedMoveUp = false, isDisabledPinnedMoveDown = false, isExpanded = false, @@ -306,7 +308,9 @@ export function ClipboardHistoryQuickPasteRowComponent({ }, [clipboard?.isLink, hasLinkCard]) const showCopyPasteIndexNumber = - isKeyCtrlPressed.value && typeof index !== 'undefined' && index < 10 + (isKeyCtrlPressed.value || (isKeyAltPressed.value && !isWindows)) && + typeof index !== 'undefined' && + index < 10 const pinnedTopOffsetFirst = !isPinnedTopFirst ? 'top-[-10px]' : 'top-[5px]' const bgToolsPanel = `${ diff --git a/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryRow.tsx b/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryRow.tsx index c993f1ab..56054f7f 100644 --- a/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryRow.tsx +++ b/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryRow.tsx @@ -301,7 +301,9 @@ export function ClipboardHistoryRowComponent({ }, [clipboard?.isLink, hasLinkCard]) const showCopyPasteIndexNumber = - isKeyCtrlPressed.value && typeof index !== 'undefined' && index < 10 + (isKeyCtrlPressed.value || (isKeyAltPressed.value && !isWindows)) && + typeof index !== 'undefined' && + index < 10 const pinnedTopOffsetFirst = !isPinnedTopFirst ? 'top-[-10px]' : 'top-[5px]' const bgToolsPanel = `${ diff --git a/packages/pastebar-app-ui/src/pages/main/ClipboardHistoryPage.tsx b/packages/pastebar-app-ui/src/pages/main/ClipboardHistoryPage.tsx index d725af43..395757af 100644 --- a/packages/pastebar-app-ui/src/pages/main/ClipboardHistoryPage.tsx +++ b/packages/pastebar-app-ui/src/pages/main/ClipboardHistoryPage.tsx @@ -317,6 +317,7 @@ export default function ClipboardHistoryPage() { useHotkeys( [...Array(10).keys()].map(i => `ctrl+${i.toString()}`), e => { + e.preventDefault() const index = e.key === '0' ? 9 : Number(e.key) - 1 const itemId = clipboardHistory[Number(index)]?.historyId @@ -325,12 +326,35 @@ export default function ClipboardHistoryPage() { } setCopiedItem(itemId) + }, + { + enableOnFormTags: ['input'], + } + ) + + useHotkeys( + [...Array(10).keys()].map(i => `meta+${i.toString()}`), + e => { + e.preventDefault() + const index = e.key === '0' ? 9 : Number(e.key) - 1 + const itemId = clipboardHistory[Number(index)]?.historyId + + if (!itemId) { + return + } + + setCopiedItem(itemId) + }, + { + enabled: !isWindows, + enableOnFormTags: ['input'], } ) useHotkeys( [...Array(10).keys()].map(i => `ctrl+${isWindows ? 'alt' : 'meta'}+${i.toString()}`), e => { + e.preventDefault() const index = e.key === '0' ? 9 : Number(e.key) - 1 const itemId = clipboardHistory[Number(index)]?.historyId @@ -339,6 +363,9 @@ export default function ClipboardHistoryPage() { } setPastedItem(itemId) + }, + { + enableOnFormTags: ['input'], } ) diff --git a/packages/pastebar-app-ui/src/pages/main/ClipboardHistoryQuickPastePage.tsx b/packages/pastebar-app-ui/src/pages/main/ClipboardHistoryQuickPastePage.tsx index e91ad42e..8fe609dc 100644 --- a/packages/pastebar-app-ui/src/pages/main/ClipboardHistoryQuickPastePage.tsx +++ b/packages/pastebar-app-ui/src/pages/main/ClipboardHistoryQuickPastePage.tsx @@ -246,6 +246,28 @@ export default function ClipboardHistoryQuickPastePage() { } invokeCopyPasteHistoryItem(itemId) + }, + { + enableOnFormTags: ['input'], + } + ) + + useHotkeys( + [...Array(10).keys()].map(i => `meta+${i.toString()}`), + e => { + e.preventDefault() + const index = e.key === '0' ? 9 : Number(e.key) - 1 + const itemId = clipboardHistory[Number(index)]?.historyId + + if (!itemId) { + return + } + + invokeCopyPasteHistoryItem(itemId) + }, + { + enabled: !isWindows, + enableOnFormTags: ['input'], } ) @@ -682,6 +704,7 @@ export default function ClipboardHistoryQuickPastePage() { setSavingItem={setSavingItem} isDeleting={false} isSelected={false} + isWindows={isWindows} setBrokenImageItem={setBrokenImageItem} isBrokenImage={brokenImageItems.includes(historyId)} showTimeAgo={false} @@ -855,6 +878,7 @@ export default function ClipboardHistoryQuickPastePage() { hasGenerateLinkMetaDataInProgress={clipboardHistoryGenerateLinkMetaDataInProgress.includes( historyId )} + isWindows={isWindows} setHistoryFilters={setHistoryFilters} setAppFilters={setAppFilters} setSelectHistoryItem={() => {}} From fb264f6cf481a62d6d0e328530861a2595a2384b Mon Sep 17 00:00:00 2001 From: Sergey Kurdin Date: Thu, 29 Aug 2024 22:24:36 -0400 Subject: [PATCH 2/2] added changeset --- .changeset/grumpy-mangos-do.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/grumpy-mangos-do.md diff --git a/.changeset/grumpy-mangos-do.md b/.changeset/grumpy-mangos-do.md new file mode 100644 index 00000000..e68176f5 --- /dev/null +++ b/.changeset/grumpy-mangos-do.md @@ -0,0 +1,5 @@ +--- +'pastebar-app-ui': patch +--- + +Update to shortcut for quick copy paste ctrl + number added cmd key press on mac