Reviewed-on: #433 Co-authored-by: miteruzo <miteruzo@naver.com>
このコミットはプルリクエスト #433 でマージされました。
このコミットが含まれているのは:
@@ -1,3 +1,6 @@
|
||||
import { unlocalisedPath } from '@/lib/locales'
|
||||
import { i18n } from '@/lib/i18n'
|
||||
|
||||
export type ShortcutScope =
|
||||
| 'global'
|
||||
| 'posts'
|
||||
@@ -37,85 +40,109 @@ export type ShortcutDefinition = {
|
||||
}
|
||||
|
||||
export const SHORTCUT_SCOPE_LABELS: Record<ShortcutScope, string> = {
|
||||
global: '全画面',
|
||||
posts: '広場',
|
||||
postSearch: '広場検索',
|
||||
tags: 'タグ',
|
||||
settings: '設定',
|
||||
wiki: 'Wiki',
|
||||
materials: '素材',
|
||||
get global () { return i18n.t ('settings:shortcuts.scopes.global') },
|
||||
get posts () { return i18n.t ('settings:shortcuts.scopes.posts') },
|
||||
get postSearch () { return i18n.t ('settings:shortcuts.scopes.postSearch') },
|
||||
get tags () { return i18n.t ('settings:shortcuts.scopes.tags') },
|
||||
get settings () { return i18n.t ('settings:shortcuts.scopes.settings') },
|
||||
get wiki () { return i18n.t ('settings:shortcuts.scopes.wiki') },
|
||||
get materials () { return i18n.t ('settings:shortcuts.scopes.materials') },
|
||||
}
|
||||
|
||||
export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [
|
||||
{
|
||||
id: 'global.openShortcutHelp',
|
||||
label: 'ショートカット一覧を開く',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.global.openShortcutHelp')
|
||||
},
|
||||
scope: 'global',
|
||||
defaultBinding: { key: '?', shift: true },
|
||||
},
|
||||
{
|
||||
id: 'global.focusSearch',
|
||||
label: '検索欄へ移動',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.global.focusSearch')
|
||||
},
|
||||
scope: 'global',
|
||||
defaultBinding: { key: '/' },
|
||||
},
|
||||
{
|
||||
id: 'navigation.posts',
|
||||
label: '広場へ移動',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.navigation.posts')
|
||||
},
|
||||
scope: 'global',
|
||||
defaultBinding: { key: 'p' },
|
||||
},
|
||||
{
|
||||
id: 'navigation.tags',
|
||||
label: 'タグへ移動',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.navigation.tags')
|
||||
},
|
||||
scope: 'global',
|
||||
defaultBinding: { key: 't' },
|
||||
},
|
||||
{
|
||||
id: 'navigation.materials',
|
||||
label: '素材へ移動',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.navigation.materials')
|
||||
},
|
||||
scope: 'global',
|
||||
defaultBinding: { key: 'm' },
|
||||
},
|
||||
{
|
||||
id: 'navigation.wiki',
|
||||
label: 'Wiki へ移動',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.navigation.wiki')
|
||||
},
|
||||
scope: 'global',
|
||||
defaultBinding: { key: 'w' },
|
||||
},
|
||||
{
|
||||
id: 'pagination.next',
|
||||
label: '次のページへ移動',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.pagination.next')
|
||||
},
|
||||
scope: 'global',
|
||||
defaultBinding: { key: 'ArrowRight' },
|
||||
},
|
||||
{
|
||||
id: 'pagination.previous',
|
||||
label: '前のページへ移動',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.pagination.previous')
|
||||
},
|
||||
scope: 'global',
|
||||
defaultBinding: { key: 'ArrowLeft' },
|
||||
},
|
||||
{
|
||||
id: 'settings.account',
|
||||
label: '設定: アカウント',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.settings.account')
|
||||
},
|
||||
scope: 'settings',
|
||||
defaultBinding: { key: '1' },
|
||||
},
|
||||
{
|
||||
id: 'settings.behavior',
|
||||
label: '設定: 動作',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.settings.behavior')
|
||||
},
|
||||
scope: 'settings',
|
||||
defaultBinding: { key: '2' },
|
||||
},
|
||||
{
|
||||
id: 'settings.theme',
|
||||
label: '設定: テーマ',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.settings.theme')
|
||||
},
|
||||
scope: 'settings',
|
||||
defaultBinding: { key: '3' },
|
||||
},
|
||||
{
|
||||
id: 'settings.keyboard',
|
||||
label: '設定: キーボード',
|
||||
get label () {
|
||||
return i18n.t ('settings:shortcuts.actions.settings.keyboard')
|
||||
},
|
||||
scope: 'settings',
|
||||
defaultBinding: { key: '4' },
|
||||
},
|
||||
@@ -249,7 +276,7 @@ const keyLabel = (key: string): string => {
|
||||
|
||||
export const formatKeyBinding = (binding: KeyBinding | null): string => {
|
||||
if (binding == null)
|
||||
return '未割当'
|
||||
return i18n.t ('settings:shortcuts.unassigned')
|
||||
|
||||
return [
|
||||
binding.ctrl ? 'Ctrl' : null,
|
||||
@@ -308,7 +335,8 @@ export const getConflictingShortcutActionIds = (
|
||||
)
|
||||
}
|
||||
|
||||
export const resolveShortcutScope = (pathname: string): ShortcutScope => {
|
||||
export const resolveShortcutScope = (fullPathname: string): ShortcutScope => {
|
||||
const pathname = unlocalisedPath (fullPathname)
|
||||
if (pathname.startsWith ('/posts/search'))
|
||||
return 'postSearch'
|
||||
if (pathname.startsWith ('/posts'))
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする