Merge pull request #160 from PasteBar/fix-quick-paste-window-shortcuts-numbers-is-wrong-when-using-search

Fix quick paste window shortcuts numbers is wrong when using search
This commit is contained in:
Sergey 2024-09-01 13:03:18 -04:00 committed by GitHub
commit 44c879b0ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 64 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
'pastebar-app-ui': patch
---
Update to shortcut for quick copy paste ctrl + number added cmd key press on mac

View File

@ -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 = `${

View File

@ -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 = `${

View File

@ -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'],
}
)

View File

@ -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={() => {}}