diff options
author | 2024-05-13 22:47:35 +0100 | |
---|---|---|
committer | 2024-05-13 22:47:35 +0100 | |
commit | 6167b6c7e9f49adee065646e2d28e28500753ebd (patch) | |
tree | 15d4746188e95af98ae7cf6e426c82ffdfed7ee1 /src/jsUtils.ts | |
parent | Fix notifications on all services (#1593) (diff) | |
download | ferdium-app-6167b6c7e9f49adee065646e2d28e28500753ebd.tar.gz ferdium-app-6167b6c7e9f49adee065646e2d28e28500753ebd.tar.zst ferdium-app-6167b6c7e9f49adee065646e2d28e28500753ebd.zip |
Fix accelerators (#1752)
* fix: accelerators with numbers
* fix: control zoom in
* fix logic on macOS
* fix for linux
* chore: prepare-code
* chore: adjust comments
Diffstat (limited to 'src/jsUtils.ts')
-rw-r--r-- | src/jsUtils.ts | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/jsUtils.ts b/src/jsUtils.ts index 0befb8d56..145875cfa 100644 --- a/src/jsUtils.ts +++ b/src/jsUtils.ts | |||
@@ -28,12 +28,21 @@ export const safeParseInt = (text?: string | number | null) => { | |||
28 | return Math.max(adjustedNumber, 0); | 28 | return Math.max(adjustedNumber, 0); |
29 | }; | 29 | }; |
30 | 30 | ||
31 | export const acceleratorString = ( | 31 | interface IAcceleratorString { |
32 | index: number, | 32 | keyCombo: string; |
33 | keyCombo: string, | 33 | index: number; |
34 | prefix: string = '(', | 34 | prefix?: string; |
35 | suffix: string = ')', | 35 | suffix?: string; |
36 | ) => (index <= 10 ? `${prefix}${keyCombo}+${index % 10}${suffix}` : ''); | 36 | maxIndex?: number; |
37 | } | ||
38 | export const acceleratorString = ({ | ||
39 | index, | ||
40 | keyCombo, | ||
41 | prefix = '(', | ||
42 | suffix = ')', | ||
43 | maxIndex = 9, | ||
44 | }: IAcceleratorString) => | ||
45 | index <= maxIndex ? `${prefix}${keyCombo}+${index % 10}${suffix}` : ''; | ||
37 | 46 | ||
38 | export const removeNewLines = (input: string): string => | 47 | export const removeNewLines = (input: string): string => |
39 | input.replaceAll(/\r?\n|\r/g, ''); | 48 | input.replaceAll(/\r?\n|\r/g, ''); |