|
3 | 3 | import { delay } from '../KeyboardEventUtil' |
4 | 4 | import { sendShortcuts } from '../backendActions' |
5 | 5 | import { events, eventsToBackend } from '../events' |
6 | | - import { currentPage, isAppHidden, isFocused, pressedKeysSizeLimit, shortcutsJson, userPreferences } from '../stores' |
| 6 | + import { currentPage, currentSearchedText, isAppHidden, isFocused, pressedKeysSizeLimit, shortcutsJson, userPreferences } from '../stores' |
7 | 7 | import { IPages, type IShortCut } from '../types' |
8 | 8 | import { clipListFiltered, currentScrollIndex, pressedKeys, selectedClipId } from './../stores' |
9 | 9 | import Button from './Button.svelte' |
|
63 | 63 |
|
64 | 64 | interface IShortcuts { |
65 | 65 | scroll: IShortCut |
| 66 | + scroll_up: IShortCut |
66 | 67 | close_and_paste: IShortCut |
67 | 68 | search: IShortCut |
68 | 69 | paste1: IShortCut |
|
115 | 116 | combinationChangeHandler: (newCombination: string[][][]) => {} |
116 | 117 | }, |
117 | 118 |
|
| 119 | + scroll_up: { |
| 120 | + combinations: [[['Left Command', 'Left Shift', '`']]], |
| 121 | + editVisible: false, |
| 122 | + delayMsBetweenTriggers: 100, |
| 123 | + handler: async () => { |
| 124 | + if ($currentPage != IPages.items) { |
| 125 | + return |
| 126 | + } |
| 127 | + if ($isAppHidden) { |
| 128 | + return |
| 129 | + } |
| 130 | + events.notifyBackend(eventsToBackend.windowUnhide) |
| 131 | + if ($clipListFiltered && $currentScrollIndex - 1 >= 0 && $clipListFiltered[$currentScrollIndex - 1][0]) { |
| 132 | + $currentScrollIndex-- |
| 133 | + $selectedClipId = $clipListFiltered[$currentScrollIndex][0] |
| 134 | + scrollIntoView($selectedClipId) |
| 135 | + } |
| 136 | + }, |
| 137 | + combinationChangeHandler: (newCombination: string[][][]) => {} |
| 138 | + }, |
| 139 | +
|
118 | 140 | close_and_paste: { |
119 | 141 | combinations: [[['Left Command', '`'], ['Left Command'], []]], |
120 | 142 | editVisible: false, |
|
124 | 146 | return |
125 | 147 | } |
126 | 148 | events.notifyBackend(eventsToBackend.pasteHash, $selectedClipId) |
| 149 | + currentSearchedText.set('') |
127 | 150 | $currentScrollIndex = -1 |
128 | 151 | $selectedClipId = '' |
129 | 152 | }, |
|
151 | 174 | combinations: [[['Left Command', '1']]], |
152 | 175 | handler: async () => { |
153 | 176 | events.notifyBackend(eventsToBackend.pasteHash, $clipListFiltered[0][1].hash) |
| 177 | + currentSearchedText.set('') |
154 | 178 | }, |
155 | 179 | combinationChangeHandler: () => {} |
156 | 180 | }, |
|
161 | 185 | combinations: [[['Left Command', '2']]], |
162 | 186 | handler: async () => { |
163 | 187 | events.notifyBackend(eventsToBackend.pasteHash, $clipListFiltered[1][1].hash) |
| 188 | + currentSearchedText.set('') |
164 | 189 | }, |
165 | 190 | combinationChangeHandler: () => {} |
166 | 191 | }, |
|
170 | 195 | combinations: [[['Left Command', '3']]], |
171 | 196 | handler: async () => { |
172 | 197 | events.notifyBackend(eventsToBackend.pasteHash, $clipListFiltered[2][1].hash) |
| 198 | + currentSearchedText.set('') |
173 | 199 | }, |
174 | 200 | combinationChangeHandler: () => {} |
175 | 201 | }, |
|
180 | 206 | combinations: [[['Left Command', '4']]], |
181 | 207 | handler: async () => { |
182 | 208 | events.notifyBackend(eventsToBackend.pasteHash, $clipListFiltered[3][1].hash) |
| 209 | + currentSearchedText.set('') |
183 | 210 | }, |
184 | 211 | combinationChangeHandler: () => {} |
185 | 212 | }, |
|
190 | 217 | combinations: [[['Left Command', '5']]], |
191 | 218 | handler: async () => { |
192 | 219 | events.notifyBackend(eventsToBackend.pasteHash, $clipListFiltered[4][1].hash) |
| 220 | + currentSearchedText.set('') |
193 | 221 | }, |
194 | 222 | combinationChangeHandler: () => {} |
195 | 223 | }, |
|
200 | 228 | combinations: [[['Left Command', '6']]], |
201 | 229 | handler: async () => { |
202 | 230 | events.notifyBackend(eventsToBackend.pasteHash, $clipListFiltered[5][1].hash) |
| 231 | + currentSearchedText.set('') |
203 | 232 | }, |
204 | 233 | combinationChangeHandler: () => {} |
205 | 234 | }, |
|
210 | 239 | combinations: [[['Left Command', '7']]], |
211 | 240 | handler: async () => { |
212 | 241 | events.notifyBackend(eventsToBackend.pasteHash, $clipListFiltered[6][1].hash) |
| 242 | + currentSearchedText.set('') |
213 | 243 | }, |
214 | 244 | combinationChangeHandler: () => {} |
215 | 245 | }, |
|
220 | 250 | combinations: [[['Left Command', '8']]], |
221 | 251 | handler: async () => { |
222 | 252 | events.notifyBackend(eventsToBackend.pasteHash, $clipListFiltered[7][1].hash) |
| 253 | + currentSearchedText.set('') |
223 | 254 | }, |
224 | 255 | combinationChangeHandler: () => {} |
225 | 256 | }, |
|
230 | 261 | combinations: [[['Left Command', '9']]], |
231 | 262 | handler: async () => { |
232 | 263 | events.notifyBackend(eventsToBackend.pasteHash, $clipListFiltered[8][1].hash) |
| 264 | + currentSearchedText.set('') |
233 | 265 | }, |
234 | 266 | combinationChangeHandler: () => {} |
235 | 267 | }, |
|
240 | 272 | combinations: [[['Left Command', '0']]], |
241 | 273 | handler: async () => { |
242 | 274 | events.notifyBackend(eventsToBackend.pasteHash, $clipListFiltered[9][1].hash) |
| 275 | + currentSearchedText.set('') |
243 | 276 | }, |
244 | 277 | combinationChangeHandler: () => {} |
245 | 278 | } |
|
304 | 337 | return { exists: false, name: '' } |
305 | 338 | } |
306 | 339 | export const getNameFromKey = (key: string): string => { |
307 | | - return key.toUpperCase().replaceAll('_', ' ') |
| 340 | + return key.toUpperCase().replace(/_/g, ' ') |
308 | 341 | } |
309 | 342 | export const resetRecorded = () => { |
310 | | - console.log('reseted!') |
311 | 343 | simplestShortcut = [] |
312 | | - // recordedShortcuts = [[]] |
313 | 344 | pressedKeys.set([[]]) |
314 | 345 | } |
315 | 346 | currentPage.subscribe((v) => { |
|
0 commit comments