feat: support vim keybinding navigation between entry content and timeline
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -46,11 +46,13 @@ export const COMMAND_ID = {
|
||||
},
|
||||
layout: {
|
||||
toggleTimelineColumn: "layout:toggle-timeline-column",
|
||||
focusToTimeline: "layout:focus-to-timeline",
|
||||
},
|
||||
timeline: {
|
||||
switchToNext: "timeline:switch-to-next",
|
||||
switchToPrevious: "timeline:switch-to-previous",
|
||||
refetch: "timeline:refetch",
|
||||
enter: "timeline:enter",
|
||||
},
|
||||
entryRender: {
|
||||
scrollDown: "entry-render:scroll-down",
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import { EventBus } from "@follow/utils/event-bus"
|
||||
|
||||
import { setTimelineColumnShow } from "~/atoms/sidebar"
|
||||
|
||||
import { useRegisterCommandEffect } from "../hooks/use-register-command"
|
||||
import type { Command } from "../types"
|
||||
import { COMMAND_ID } from "./id"
|
||||
|
||||
declare module "@follow/utils/event-bus" {
|
||||
interface EventBusMap {
|
||||
"layout:focus-to-timeline": never
|
||||
}
|
||||
}
|
||||
|
||||
export const useRegisterLayoutCommands = () => {
|
||||
useRegisterCommandEffect([
|
||||
{
|
||||
@@ -13,6 +21,13 @@ export const useRegisterLayoutCommands = () => {
|
||||
setTimelineColumnShow((show) => !show)
|
||||
},
|
||||
},
|
||||
{
|
||||
id: COMMAND_ID.layout.focusToTimeline,
|
||||
label: "Focus to timeline",
|
||||
run: () => {
|
||||
EventBus.dispatch(COMMAND_ID.layout.focusToTimeline)
|
||||
},
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
@@ -21,4 +36,9 @@ export type ToggleTimelineColumnCommand = Command<{
|
||||
fn: () => void
|
||||
}>
|
||||
|
||||
export type LayoutCommand = ToggleTimelineColumnCommand
|
||||
export type FocusToTimelineCommand = Command<{
|
||||
id: typeof COMMAND_ID.layout.focusToTimeline
|
||||
fn: () => void
|
||||
}>
|
||||
|
||||
export type LayoutCommand = ToggleTimelineColumnCommand | FocusToTimelineCommand
|
||||
|
||||
@@ -9,6 +9,7 @@ declare module "@follow/utils/event-bus" {
|
||||
"timeline:switch-to-next": never
|
||||
"timeline:switch-to-previous": never
|
||||
"timeline:refetch": never
|
||||
"timeline:enter": never
|
||||
}
|
||||
}
|
||||
export const useRegisterTimelineCommand = () => {
|
||||
@@ -35,6 +36,13 @@ export const useRegisterTimelineCommand = () => {
|
||||
EventBus.dispatch("timeline:refetch")
|
||||
},
|
||||
},
|
||||
{
|
||||
id: COMMAND_ID.timeline.enter,
|
||||
label: "Enter Selected Entry",
|
||||
run: () => {
|
||||
EventBus.dispatch("timeline:enter")
|
||||
},
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
@@ -53,7 +61,13 @@ export type RefetchTimelineCommand = Command<{
|
||||
fn: () => void
|
||||
}>
|
||||
|
||||
export type EnterTimelineCommand = Command<{
|
||||
id: typeof COMMAND_ID.timeline.enter
|
||||
fn: () => void
|
||||
}>
|
||||
|
||||
export type TimelineCommand =
|
||||
| SwitchToNextTimelineCommand
|
||||
| SwitchToPreviousTimelineCommand
|
||||
| RefetchTimelineCommand
|
||||
| EnterTimelineCommand
|
||||
|
||||
Reference in New Issue
Block a user