mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-05 12:12:05 -07:00
feat(subtitle-sidebar): add sidebar config surface (#28)
This commit is contained in:
@@ -27,6 +27,7 @@ export function createKeyboardHandlers(
|
||||
getPlaybackPaused: () => Promise<boolean | null>;
|
||||
openControllerSelectModal: () => void;
|
||||
openControllerDebugModal: () => void;
|
||||
toggleSubtitleSidebarModal?: () => void;
|
||||
},
|
||||
) {
|
||||
// Timeout for the modal chord capture window (e.g. Y followed by H/K).
|
||||
@@ -181,6 +182,26 @@ export function createKeyboardHandlers(
|
||||
return !e.ctrlKey && !e.metaKey && e.altKey && !e.repeat && e.code === 'KeyC';
|
||||
}
|
||||
|
||||
function isSubtitleSidebarToggle(e: KeyboardEvent): boolean {
|
||||
const toggleKey = ctx.state.subtitleSidebarToggleKey;
|
||||
if (!toggleKey) return false;
|
||||
const isBackslashConfigured = toggleKey === 'Backslash' || toggleKey === '\\';
|
||||
const isBackslashLikeCode = ['Backslash', 'IntlBackslash', 'IntlYen'].includes(e.code);
|
||||
const keyMatches =
|
||||
toggleKey === e.code ||
|
||||
(isBackslashConfigured && isBackslashLikeCode) ||
|
||||
(isBackslashConfigured && e.key === '\\') ||
|
||||
(toggleKey.length === 1 && e.key === toggleKey);
|
||||
|
||||
return (
|
||||
keyMatches &&
|
||||
!e.ctrlKey &&
|
||||
!e.altKey &&
|
||||
!e.metaKey &&
|
||||
!e.repeat
|
||||
);
|
||||
}
|
||||
|
||||
function isStatsOverlayToggle(e: KeyboardEvent): boolean {
|
||||
return (
|
||||
e.code === ctx.state.statsToggleKey &&
|
||||
@@ -838,6 +859,12 @@ export function createKeyboardHandlers(
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSubtitleSidebarToggle(e)) {
|
||||
e.preventDefault();
|
||||
options.toggleSubtitleSidebarModal?.();
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
(ctx.state.yomitanPopupVisible || isYomitanPopupVisible(document)) &&
|
||||
!isControllerModalShortcut(e)
|
||||
|
||||
Reference in New Issue
Block a user