kopia lustrzana https://github.com/cheeaun/phanpy
Add g>* keyboard shortcuts
rodzic
2e20558e7f
commit
5b0471f0d0
|
|
@ -36,7 +36,7 @@
|
|||
"p-retry": "~7.1.0",
|
||||
"preact": "10.27.2",
|
||||
"punycode": "~2.3.1",
|
||||
"react-hotkeys-hook": "~5.1.0",
|
||||
"react-hotkeys-hook": "~5.2.0",
|
||||
"react-intersection-observer": "~9.16.0",
|
||||
"react-quick-pinch-zoom": "~5.1.0",
|
||||
"react-router-dom": "6.6.2",
|
||||
|
|
@ -8790,9 +8790,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/react-hotkeys-hook": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/react-hotkeys-hook/-/react-hotkeys-hook-5.1.0.tgz",
|
||||
"integrity": "sha512-GCNGXjBzV9buOS3REoQFmSmE4WTvBhYQ0YrAeeMZI83bhXg3dRWsLHXDutcVDdEjwJqJCxk5iewWYX5LtFUd7g==",
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/react-hotkeys-hook/-/react-hotkeys-hook-5.2.0.tgz",
|
||||
"integrity": "sha512-6hhPHVuofG8De4yU3jr8Q4EjHsxEnob5I1Dag+OxgDRXX1oARHbmURreXyo2CDTYyz0POmFqdBlW6eAa0MwNLw==",
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
"p-retry": "~7.1.0",
|
||||
"preact": "10.27.2",
|
||||
"punycode": "~2.3.1",
|
||||
"react-hotkeys-hook": "~5.1.0",
|
||||
"react-hotkeys-hook": "~5.2.0",
|
||||
"react-intersection-observer": "~9.16.0",
|
||||
"react-quick-pinch-zoom": "~5.1.0",
|
||||
"react-router-dom": "6.6.2",
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import { ICONS } from './components/ICONS';
|
|||
import KeyboardShortcutsHelp from './components/keyboard-shortcuts-help';
|
||||
import Loader from './components/loader';
|
||||
import Modals from './components/modals';
|
||||
import NavigationCommand from './components/navigation-command';
|
||||
import NotificationService from './components/notification-service';
|
||||
import SearchCommand from './components/search-command';
|
||||
import Shortcuts from './components/shortcuts';
|
||||
|
|
@ -514,6 +515,7 @@ function App() {
|
|||
<Modals />
|
||||
{isLoggedIn && <NotificationService />}
|
||||
<BackgroundService isLoggedIn={isLoggedIn} />
|
||||
{isLoggedIn && <NavigationCommand />}
|
||||
<SearchCommand onClose={focusDeck} />
|
||||
<KeyboardShortcutsHelp />
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,15 @@ import states from '../utils/states';
|
|||
import Icon from './icon';
|
||||
import Modal from './modal';
|
||||
|
||||
// Helper component for sequential key shortcuts
|
||||
function SequentialKeys({ key1, key2 }) {
|
||||
return (
|
||||
<Trans>
|
||||
<kbd>{key1}</kbd> then <kbd>{key2}</kbd>
|
||||
</Trans>
|
||||
);
|
||||
}
|
||||
|
||||
export default memo(function KeyboardShortcutsHelp() {
|
||||
const { t } = useLingui();
|
||||
const snapStates = useSnapshot(states);
|
||||
|
|
@ -196,6 +205,14 @@ export default memo(function KeyboardShortcutsHelp() {
|
|||
</Trans>
|
||||
),
|
||||
},
|
||||
{
|
||||
action: t`Go to Home`,
|
||||
keys: <SequentialKeys key1="g" key2="h" />,
|
||||
},
|
||||
{
|
||||
action: t`Go to Notifications`,
|
||||
keys: <SequentialKeys key1="g" key2="n" />,
|
||||
},
|
||||
].map(({ action, className, keys }) => (
|
||||
<tr key={action}>
|
||||
<th class={className}>{action}</th>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
import { memo } from 'preact/compat';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
export default memo(function NavigationCommand() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const hotkeyOptions = {
|
||||
useKey: true,
|
||||
ignoreEventWhen: (e) => {
|
||||
const hasModal = !!document.querySelector('#modal-container > *');
|
||||
return hasModal || e.metaKey || e.ctrlKey || e.altKey;
|
||||
},
|
||||
};
|
||||
|
||||
useHotkeys('g>h', () => navigate('/'), hotkeyOptions);
|
||||
useHotkeys('g>n', () => navigate('/notifications'), hotkeyOptions);
|
||||
|
||||
return null;
|
||||
});
|
||||
|
|
@ -273,7 +273,7 @@ msgstr "View post stats"
|
|||
#: src/components/embed-modal.jsx:13
|
||||
#: src/components/generic-accounts.jsx:151
|
||||
#: src/components/gif-picker-modal.jsx:71
|
||||
#: src/components/keyboard-shortcuts-help.jsx:43
|
||||
#: src/components/keyboard-shortcuts-help.jsx:52
|
||||
#: src/components/list-add-edit.jsx:37
|
||||
#: src/components/media-alt-modal.jsx:43
|
||||
#: src/components/media-attachment.jsx:353
|
||||
|
|
@ -598,7 +598,7 @@ msgid "Schedule"
|
|||
msgstr "Schedule"
|
||||
|
||||
#: src/components/compose.jsx:1975
|
||||
#: src/components/keyboard-shortcuts-help.jsx:155
|
||||
#: src/components/keyboard-shortcuts-help.jsx:164
|
||||
#: src/components/status.jsx:1073
|
||||
#: src/components/status.jsx:1107
|
||||
#: src/components/status.jsx:2091
|
||||
|
|
@ -720,7 +720,7 @@ msgid "Media"
|
|||
msgstr ""
|
||||
|
||||
#: src/components/drafts.jsx:270
|
||||
#: src/components/keyboard-shortcuts-help.jsx:184
|
||||
#: src/components/keyboard-shortcuts-help.jsx:193
|
||||
#: src/components/status.jsx:736
|
||||
msgid "Quote"
|
||||
msgstr ""
|
||||
|
|
@ -870,104 +870,108 @@ msgstr ""
|
|||
msgid "Error loading GIFs"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:47
|
||||
#: src/components/keyboard-shortcuts-help.jsx:16
|
||||
msgid "<0>{key1}</0> then <1>{key2}</1>"
|
||||
msgstr "<0>{key1}</0> then <1>{key2}</1>"
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:56
|
||||
#: src/components/nav-menu.jsx:368
|
||||
#: src/pages/catchup.jsx:1638
|
||||
msgid "Keyboard shortcuts"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:55
|
||||
#: src/components/keyboard-shortcuts-help.jsx:64
|
||||
msgid "Keyboard shortcuts help"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:59
|
||||
#: src/components/keyboard-shortcuts-help.jsx:68
|
||||
#: src/pages/catchup.jsx:1663
|
||||
msgid "Next post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:63
|
||||
#: src/components/keyboard-shortcuts-help.jsx:72
|
||||
#: src/pages/catchup.jsx:1671
|
||||
msgid "Previous post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:67
|
||||
#: src/components/keyboard-shortcuts-help.jsx:76
|
||||
msgid "Skip carousel to next post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:69
|
||||
#: src/components/keyboard-shortcuts-help.jsx:78
|
||||
msgid "<0>Shift</0> + <1>j</1>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:75
|
||||
#: src/components/keyboard-shortcuts-help.jsx:84
|
||||
msgid "Skip carousel to previous post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:77
|
||||
#: src/components/keyboard-shortcuts-help.jsx:86
|
||||
msgid "<0>Shift</0> + <1>k</1>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:83
|
||||
#: src/components/keyboard-shortcuts-help.jsx:92
|
||||
msgid "Load new posts"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:87
|
||||
#: src/components/keyboard-shortcuts-help.jsx:96
|
||||
#: src/pages/catchup.jsx:1695
|
||||
msgid "Open post details"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:89
|
||||
#: src/components/keyboard-shortcuts-help.jsx:98
|
||||
msgid "<0>Enter</0> or <1>o</1>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:96
|
||||
#: src/components/keyboard-shortcuts-help.jsx:105
|
||||
msgid "Expand content warning or<0/>toggle expanded/collapsed thread"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:105
|
||||
#: src/components/keyboard-shortcuts-help.jsx:114
|
||||
msgid "Close post or dialogs"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:107
|
||||
#: src/components/keyboard-shortcuts-help.jsx:116
|
||||
msgid "<0>Esc</0> or <1>Backspace</1>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:113
|
||||
#: src/components/keyboard-shortcuts-help.jsx:122
|
||||
msgid "Focus column in multi-column mode"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:115
|
||||
#: src/components/keyboard-shortcuts-help.jsx:124
|
||||
msgid "<0>1</0> to <1>9</1>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:121
|
||||
#: src/components/keyboard-shortcuts-help.jsx:130
|
||||
msgid "Focus next column in multi-column mode"
|
||||
msgstr "Focus next column in multi-column mode"
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:125
|
||||
#: src/components/keyboard-shortcuts-help.jsx:134
|
||||
msgid "Focus previous column in multi-column mode"
|
||||
msgstr "Focus previous column in multi-column mode"
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:129
|
||||
#: src/components/keyboard-shortcuts-help.jsx:138
|
||||
msgid "Compose new post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:133
|
||||
#: src/components/keyboard-shortcuts-help.jsx:142
|
||||
msgid "Compose new post (new window)"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:136
|
||||
#: src/components/keyboard-shortcuts-help.jsx:145
|
||||
msgid "<0>Shift</0> + <1>c</1>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:142
|
||||
#: src/components/keyboard-shortcuts-help.jsx:151
|
||||
msgid "Send post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:144
|
||||
#: src/components/keyboard-shortcuts-help.jsx:153
|
||||
msgid "<0>Ctrl</0> + <1>Enter</1> or <2>⌘</2> + <3>Enter</3>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:151
|
||||
#: src/components/keyboard-shortcuts-help.jsx:160
|
||||
#: src/components/nav-menu.jsx:337
|
||||
#: src/components/search-form.jsx:204
|
||||
#: src/components/shortcuts-settings.jsx:52
|
||||
|
|
@ -977,48 +981,56 @@ msgstr ""
|
|||
msgid "Search"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:159
|
||||
#: src/components/keyboard-shortcuts-help.jsx:168
|
||||
msgid "Reply (new window)"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:162
|
||||
#: src/components/keyboard-shortcuts-help.jsx:171
|
||||
msgid "<0>Shift</0> + <1>r</1>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:168
|
||||
#: src/components/keyboard-shortcuts-help.jsx:177
|
||||
msgid "Like (favourite)"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:170
|
||||
#: src/components/keyboard-shortcuts-help.jsx:179
|
||||
msgid "<0>l</0> or <1>f</1>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:176
|
||||
#: src/components/keyboard-shortcuts-help.jsx:185
|
||||
#: src/components/status.jsx:1143
|
||||
#: src/components/status.jsx:2865
|
||||
#: src/components/status.jsx:2920
|
||||
msgid "Boost"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:178
|
||||
#: src/components/keyboard-shortcuts-help.jsx:187
|
||||
msgid "<0>Shift</0> + <1>b</1>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:188
|
||||
#: src/components/keyboard-shortcuts-help.jsx:197
|
||||
#: src/components/status.jsx:1245
|
||||
#: src/components/status.jsx:2945
|
||||
#: src/components/status.jsx:2946
|
||||
msgid "Bookmark"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:192
|
||||
#: src/components/keyboard-shortcuts-help.jsx:201
|
||||
msgid "Toggle Cloak mode"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:194
|
||||
#: src/components/keyboard-shortcuts-help.jsx:203
|
||||
msgid "<0>Shift</0> + <1>Alt</1> + <2>k</2>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:209
|
||||
msgid "Go to Home"
|
||||
msgstr "Go to Home"
|
||||
|
||||
#: src/components/keyboard-shortcuts-help.jsx:213
|
||||
msgid "Go to Notifications"
|
||||
msgstr "Go to Notifications"
|
||||
|
||||
#: src/components/list-add-edit.jsx:41
|
||||
msgid "Edit list"
|
||||
msgstr ""
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue