UBER-429 Improve keyboard help (#3389)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-06-07 20:04:28 +06:00 committed by GitHub
parent 8ccb61ab64
commit 91bbed00d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 24 additions and 14 deletions

View File

@ -452,7 +452,7 @@ export function createModel (builder: Builder): void {
}, },
label: view.string.Delete, label: view.string.Delete,
icon: view.icon.Delete, icon: view.icon.Delete,
keyBinding: ['Meta + Backspace', 'Ctrl + Backspace'], keyBinding: ['Meta + Backspace'],
category: board.category.Card, category: board.category.Card,
input: 'any', input: 'any',
target: board.class.Card, target: board.class.Card,

View File

@ -334,7 +334,7 @@ export function createModel (builder: Builder): void {
icon: view.icon.Archive, icon: view.icon.Archive,
input: 'any', input: 'any',
category: hr.category.HR, category: hr.category.HR,
keyBinding: ['Meta + Backspace', 'Ctrl + Backspace'], keyBinding: ['Meta + Backspace'],
query: { query: {
'members.length': 0, 'members.length': 0,
_id: { $nin: [hr.ids.Head] } _id: { $nin: [hr.ids.Head] }

View File

@ -1073,7 +1073,7 @@ export function createModel (builder: Builder): void {
}) })
} }
createGotoSpecialAction(builder, talentsId, 'keyG-keyE', recruit.string.GotoTalents) createGotoSpecialAction(builder, talentsId, 'keyG->keyE', recruit.string.GotoTalents)
createGotoSpecialAction(builder, vacanciesId, 'keyG->keyV', recruit.string.GotoVacancies) createGotoSpecialAction(builder, vacanciesId, 'keyG->keyV', recruit.string.GotoVacancies)
createGotoSpecialAction(builder, skillsId, 'keyG->keyS', recruit.string.GotoSkills) createGotoSpecialAction(builder, skillsId, 'keyG->keyS', recruit.string.GotoSkills)
createGotoSpecialAction(builder, myApplicationsId, 'keyG->keyM', recruit.string.GotoMyApplications) createGotoSpecialAction(builder, myApplicationsId, 'keyG->keyM', recruit.string.GotoMyApplications)

View File

@ -390,7 +390,7 @@ export function createModel (builder: Builder): void {
action: setting.actionImpl.DeleteMixin, action: setting.actionImpl.DeleteMixin,
label: view.string.Delete, label: view.string.Delete,
icon: view.icon.Delete, icon: view.icon.Delete,
keyBinding: ['Meta + Backspace', 'Ctrl + Backspace'], keyBinding: ['Meta + Backspace'],
category: view.category.General, category: view.category.General,
input: 'any', input: 'any',
target: setting.mixin.UserMixin, target: setting.mixin.UserMixin,

View File

@ -1883,7 +1883,7 @@ export function createModel (builder: Builder): void {
action: tracker.actionImpl.DeleteMilestone, action: tracker.actionImpl.DeleteMilestone,
label: view.string.Delete, label: view.string.Delete,
icon: view.icon.Delete, icon: view.icon.Delete,
keyBinding: ['Meta + Backspace', 'Ctrl + Backspace'], keyBinding: ['Meta + Backspace'],
category: tracker.category.Tracker, category: tracker.category.Tracker,
input: 'any', input: 'any',
target: tracker.class.Milestone, target: tracker.class.Milestone,

View File

@ -561,7 +561,7 @@ export function createModel (builder: Builder): void {
action: view.actionImpl.Delete, action: view.actionImpl.Delete,
label: view.string.Delete, label: view.string.Delete,
icon: view.icon.Delete, icon: view.icon.Delete,
keyBinding: ['Meta + Backspace', 'Ctrl + Backspace'], keyBinding: ['Meta + Backspace'],
category: view.category.General, category: view.category.General,
input: 'any', input: 'any',
target: core.class.Doc, target: core.class.Doc,
@ -669,7 +669,7 @@ export function createModel (builder: Builder): void {
{ {
label: view.string.SelectItemAll, label: view.string.SelectItemAll,
action: view.actionImpl.SelectItemAll, action: view.actionImpl.SelectItemAll,
keyBinding: ['meta + keyA', 'ctrl + keyA'], keyBinding: ['Meta + keyA'],
category: view.category.General, category: view.category.General,
input: 'none', input: 'none',
target: core.class.Doc, target: core.class.Doc,
@ -697,7 +697,7 @@ export function createModel (builder: Builder): void {
{ {
action: view.actionImpl.ShowActions, action: view.actionImpl.ShowActions,
label: view.string.ShowActions, label: view.string.ShowActions,
keyBinding: ['meta + keyK', 'ctrl + keyK'], keyBinding: ['Meta + keyK'],
category: view.category.GeneralNavigation, category: view.category.GeneralNavigation,
input: 'none', input: 'none',
target: core.class.Doc, target: core.class.Doc,

View File

@ -63,12 +63,14 @@
$: mode = $contextStore.getLastContext()?.mode $: mode = $contextStore.getLastContext()?.mode
$: application = $contextStore.getLastContext()?.application $: application = $contextStore.getLastContext()?.application
const isMac = /Macintosh/i.test(navigator.userAgent)
function keyPrefix (key: KeyboardEvent): string { function keyPrefix (key: KeyboardEvent): string {
return ( return (
(key.altKey ? 'Alt + ' : '') + (key.altKey ? 'Alt + ' : '') +
(key.shiftKey ? 'Shift + ' : '') + (key.shiftKey ? 'Shift + ' : '') +
(key.metaKey ? 'Meta + ' : '') + (key.metaKey ? 'Meta + ' : '') +
(key.ctrlKey ? 'Ctrl + ' : '') (key.ctrlKey ? (isMac ? 'Ctrl + ' : 'Meta + ') : '')
) )
} }
function m (s1: string, s2: string): boolean { function m (s1: string, s2: string): boolean {

View File

@ -167,6 +167,10 @@
handleSelection(key, selection) handleSelection(key, selection)
} }
} }
const capitalizeFirstLetter = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1)
const isMac = /Macintosh/i.test(navigator.userAgent)
function formatKey (key: string): string[][] { function formatKey (key: string): string[][] {
const thens = key.split('->') const thens = key.split('->')
const result: string[][] = [] const result: string[][] = []
@ -175,7 +179,7 @@
r.split('+').map((it) => r.split('+').map((it) =>
it it
.replaceAll('key', '') .replaceAll('key', '')
.replaceAll(/Meta|meta/g, '⌘') .replaceAll(/Meta|meta/g, isMac ? '⌘' : 'Ctrl')
.replaceAll('ArrowUp', '↑') .replaceAll('ArrowUp', '↑')
.replaceAll('ArrowDown', '↓') .replaceAll('ArrowDown', '↓')
.replaceAll('ArrowLeft', '←') .replaceAll('ArrowLeft', '←')
@ -300,7 +304,7 @@
{/if} {/if}
{#each k as kk, j} {#each k as kk, j}
<div class="flex-center text-sm key-box"> <div class="flex-center text-sm key-box">
{kk} {capitalizeFirstLetter(kk.trim())}
</div> </div>
{/each} {/each}
{/each} {/each}

View File

@ -34,6 +34,8 @@
navigate(loc) navigate(loc)
} }
const capitalizeFirstLetter = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1)
function formatKey (key: string): string[][] { function formatKey (key: string): string[][] {
const thens = key.split('->') const thens = key.split('->')
const result: string[][] = [] const result: string[][] = []
@ -42,7 +44,7 @@
r.split('+').map((it) => r.split('+').map((it) =>
it it
.replaceAll('key', '') .replaceAll('key', '')
.replaceAll(/Meta|meta/g, '⌘') .replaceAll(/Meta|meta/g, isMac ? '⌘' : 'Ctrl')
.replaceAll('ArrowUp', '↑') .replaceAll('ArrowUp', '↑')
.replaceAll('ArrowDown', '↓') .replaceAll('ArrowDown', '↓')
.replaceAll('ArrowLeft', '←') .replaceAll('ArrowLeft', '←')
@ -78,7 +80,9 @@
actions.sort((a, b) => a.category.localeCompare(b.category)) actions.sort((a, b) => a.category.localeCompare(b.category))
} }
$: getActions() getActions()
const isMac = /Macintosh/i.test(navigator.userAgent)
const cards = [ const cards = [
{ {
@ -174,7 +178,7 @@
{/if} {/if}
{#each k as kk, j} {#each k as kk, j}
<div class="flex-center text-sm key-box"> <div class="flex-center text-sm key-box">
{kk} {capitalizeFirstLetter(kk.trim())}
</div> </div>
{/each} {/each}
{/each} {/each}