Skip to content

Commit ef8e3cf

Browse files
committed
chore: remove unused keyboard shortcuts
1 parent 02f39c2 commit ef8e3cf

File tree

10 files changed

+16
-129
lines changed

10 files changed

+16
-129
lines changed

web/src/components/MemoEditor/components/FocusModeOverlay.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@ import type { FocusModeExitButtonProps, FocusModeOverlayProps } from "../types";
66
export function FocusModeOverlay({ isActive, onToggle }: FocusModeOverlayProps) {
77
if (!isActive) return null;
88

9-
return (
10-
<button
11-
type="button"
12-
className={FOCUS_MODE_STYLES.backdrop}
13-
onClick={onToggle}
14-
onKeyDown={(e) => e.key === "Escape" && onToggle()}
15-
aria-label="Exit focus mode"
16-
/>
17-
);
9+
return <button type="button" className={FOCUS_MODE_STYLES.backdrop} onClick={onToggle} aria-label="Exit focus mode" />;
1810
}
1911

2012
export function FocusModeExitButton({ isActive, onToggle, title }: FocusModeExitButtonProps) {

web/src/components/MemoEditor/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ export const FOCUS_MODE_STYLES = {
1010
exitButton: "absolute top-2 right-2 z-10 opacity-60 hover:opacity-100",
1111
} as const;
1212

13-
export const FOCUS_MODE_TOGGLE_KEY = "f";
14-
export const FOCUS_MODE_EXIT_KEY = "Escape";
15-
1613
export const EDITOR_HEIGHT = {
1714
// Max height for normal mode - focus mode uses flex-1 to grow dynamically
1815
normal: "max-h-[50vh]",

web/src/components/MemoEditor/hooks/useKeyboard.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
11
import { useEffect } from "react";
2-
import { FOCUS_MODE_TOGGLE_KEY } from "../constants";
32
import type { EditorRefActions } from "../Editor";
43

54
interface UseKeyboardOptions {
65
onSave: () => void;
7-
onToggleFocusMode?: () => void;
86
}
97

108
export const useKeyboard = (_editorRef: React.RefObject<EditorRefActions | null>, options: UseKeyboardOptions) => {
119
useEffect(() => {
1210
const handleKeyDown = (event: KeyboardEvent) => {
13-
// Cmd/Ctrl + Enter to save
1411
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
1512
event.preventDefault();
1613
options.onSave();
17-
return;
18-
}
19-
20-
// 'f' key to toggle focus mode (only if no modifiers and not in input)
21-
if (event.key === FOCUS_MODE_TOGGLE_KEY && !event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey) {
22-
const target = event.target as HTMLElement;
23-
// Don't trigger if user is typing in an input/textarea
24-
if (target.tagName !== "INPUT" && target.tagName !== "TEXTAREA" && !target.isContentEditable) {
25-
event.preventDefault();
26-
options.onToggleFocusMode?.();
27-
}
2814
}
2915
};
3016

web/src/components/MemoEditor/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ const MemoEditorImpl: React.FC<MemoEditorProps> = ({
6262
dispatch(actions.toggleFocusMode());
6363
};
6464

65-
// Keyboard shortcuts
66-
useKeyboard(editorRef, { onSave: handleSave, onToggleFocusMode: handleToggleFocusMode });
65+
useKeyboard(editorRef, { onSave: handleSave });
6766

6867
async function handleSave() {
6968
// Validate before saving

web/src/components/MemoView/MemoView.tsx

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,10 @@ import MemoEditor from "../MemoEditor";
55
import PreviewImageDialog from "../PreviewImageDialog";
66
import { MemoBody, MemoHeader } from "./components";
77
import { MEMO_CARD_BASE_CLASSES } from "./constants";
8-
import { useImagePreview, useKeyboardShortcuts, useMemoActions, useMemoHandlers, useMemoViewDerivedState, useNsfwContent } from "./hooks";
8+
import { useImagePreview, useMemoActions, useMemoHandlers, useMemoViewDerivedState, useNsfwContent } from "./hooks";
99
import { MemoViewContext } from "./MemoViewContext";
1010
import type { MemoViewProps } from "./types";
1111

12-
/**
13-
* MemoView component displays a memo card with all its content, metadata, and interactive elements.
14-
*
15-
* Features:
16-
* - Displays memo content with markdown rendering
17-
* - Shows creator information and timestamps
18-
* - Supports inline editing with keyboard shortcuts (e = edit, a = archive)
19-
* - Handles NSFW content blurring
20-
* - Image preview on click
21-
* - Comments, reactions, and relations
22-
*
23-
* @example
24-
* ```tsx
25-
* <MemoView
26-
* memo={memoData}
27-
* showCreator
28-
* showVisibility
29-
* compact={false}
30-
* />
31-
* ```
32-
*/
3312
const MemoView: React.FC<MemoViewProps> = (props: MemoViewProps) => {
3413
const { memo: memoData, className } = props;
3514
const cardRef = useRef<HTMLDivElement>(null);
@@ -40,7 +19,7 @@ const MemoView: React.FC<MemoViewProps> = (props: MemoViewProps) => {
4019
const { isArchived, readonly, parentPage } = useMemoViewDerivedState(memoData, props.parentPage);
4120
const { nsfw, showNSFWContent, toggleNsfwVisibility } = useNsfwContent(memoData, props.showNsfwContent);
4221
const { previewState, openPreview, setPreviewOpen } = useImagePreview();
43-
const { archiveMemo, unpinMemo } = useMemoActions(memoData, isArchived);
22+
const { unpinMemo } = useMemoActions(memoData, isArchived);
4423

4524
const handleEditorConfirm = () => setShowEditor(false);
4625
const handleEditorCancel = () => setShowEditor(false);
@@ -53,14 +32,6 @@ const MemoView: React.FC<MemoViewProps> = (props: MemoViewProps) => {
5332
openEditor,
5433
openPreview,
5534
});
56-
useKeyboardShortcuts(cardRef, {
57-
enabled: true,
58-
readonly,
59-
showEditor,
60-
isArchived,
61-
onEdit: openEditor,
62-
onArchive: archiveMemo,
63-
});
6435

6536
const contextValue = useMemo(
6637
() => ({
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
export const MEMO_CARD_BASE_CLASSES =
22
"relative group flex flex-col justify-start items-start bg-card w-full px-4 py-3 mb-2 gap-2 text-card-foreground rounded-lg border border-border transition-colors";
33

4-
export const KEYBOARD_SHORTCUTS = { EDIT: "e", ARCHIVE: "a" } as const;
5-
6-
export const TEXT_INPUT_TYPES = ["text", "search", "email", "password", "url", "tel", "number"] as const;
7-
84
export const RELATIVE_TIME_THRESHOLD_MS = 1000 * 60 * 60 * 24;

web/src/components/MemoView/hooks/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export { useImagePreview } from "./useImagePreview";
2-
export { useKeyboardShortcuts } from "./useKeyboardShortcuts";
32
export { useMemoActions } from "./useMemoActions";
43
export { useMemoHandlers } from "./useMemoHandlers";
54
export { useMemoViewDerivedState } from "./useMemoViewDerivedState";

web/src/components/MemoView/hooks/useKeyboardShortcuts.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

web/src/components/SearchBar.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SearchIcon } from "lucide-react";
2-
import { useEffect, useRef, useState } from "react";
2+
import { useRef, useState } from "react";
33
import { useMemoFilterContext } from "@/contexts/MemoFilterContext";
44
import { cn } from "@/lib/utils";
55
import { useTranslate } from "@/utils/i18n";
@@ -11,18 +11,6 @@ const SearchBar = () => {
1111
const [queryText, setQueryText] = useState("");
1212
const inputRef = useRef<HTMLInputElement>(null);
1313

14-
useEffect(() => {
15-
const handleGlobalShortcut = (event: KeyboardEvent) => {
16-
if ((event.metaKey || event.ctrlKey) && event.key === "/") {
17-
event.preventDefault();
18-
inputRef.current?.focus();
19-
}
20-
};
21-
22-
window.addEventListener("keydown", handleGlobalShortcut);
23-
return () => window.removeEventListener("keydown", handleGlobalShortcut);
24-
}, []);
25-
2614
const onTextChange = (event: React.FormEvent<HTMLInputElement>) => {
2715
setQueryText(event.currentTarget.value);
2816
};

web/src/components/map/LocationPicker.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const LocationMarker = (props: MarkerProps) => {
2727
// Call the parent onChange function.
2828
props.onChange(e.latlng);
2929
},
30-
locationfound() { },
30+
locationfound() {},
3131
});
3232

3333
useEffect(() => {
@@ -224,12 +224,19 @@ const LeafletMap = (props: MapProps) => {
224224
const position = props.latlng || DEFAULT_CENTER_LAT_LNG;
225225

226226
return (
227-
<MapContainer className="w-full h-72" center={position} zoom={13} scrollWheelZoom={false} zoomControl={false} attributionControl={false}>
227+
<MapContainer
228+
className="w-full h-72"
229+
center={position}
230+
zoom={13}
231+
scrollWheelZoom={false}
232+
zoomControl={false}
233+
attributionControl={false}
234+
>
228235
<ThemedTileLayer />
229-
<LocationMarker position={position} readonly={props.readonly} onChange={props.onChange ? props.onChange : () => { }} />
236+
<LocationMarker position={position} readonly={props.readonly} onChange={props.onChange ? props.onChange : () => {}} />
230237
<MapControls position={props.latlng} />
231238
<MapCleanup />
232-
</MapContainer >
239+
</MapContainer>
233240
);
234241
};
235242

0 commit comments

Comments
 (0)