forked from fedi/mastodon
Add hotkey for toggling content warning composer field (#13987)
This commit is contained in:
parent
89f40b6c3e
commit
6b6a9d0ea3
|
@ -88,6 +88,10 @@ class KeyboardShortcuts extends ImmutablePureComponent {
|
||||||
<td><kbd>alt</kbd>+<kbd>n</kbd></td>
|
<td><kbd>alt</kbd>+<kbd>n</kbd></td>
|
||||||
<td><FormattedMessage id='keyboard_shortcuts.toot' defaultMessage='to start a brand new toot' /></td>
|
<td><FormattedMessage id='keyboard_shortcuts.toot' defaultMessage='to start a brand new toot' /></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><kbd>alt</kbd>+<kbd>x</kbd></td>
|
||||||
|
<td><FormattedMessage id='keyboard_shortcuts.spoilers' defaultMessage='to show/hide CW field' /></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><kbd>backspace</kbd></td>
|
<td><kbd>backspace</kbd></td>
|
||||||
<td><FormattedMessage id='keyboard_shortcuts.back' defaultMessage='to navigate back' /></td>
|
<td><FormattedMessage id='keyboard_shortcuts.back' defaultMessage='to navigate back' /></td>
|
||||||
|
|
|
@ -10,7 +10,7 @@ import LoadingBarContainer from './containers/loading_bar_container';
|
||||||
import ModalContainer from './containers/modal_container';
|
import ModalContainer from './containers/modal_container';
|
||||||
import { isMobile } from '../../is_mobile';
|
import { isMobile } from '../../is_mobile';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import { uploadCompose, resetCompose } from '../../actions/compose';
|
import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../actions/compose';
|
||||||
import { expandHomeTimeline } from '../../actions/timelines';
|
import { expandHomeTimeline } from '../../actions/timelines';
|
||||||
import { expandNotifications } from '../../actions/notifications';
|
import { expandNotifications } from '../../actions/notifications';
|
||||||
import { fetchFilters } from '../../actions/filters';
|
import { fetchFilters } from '../../actions/filters';
|
||||||
|
@ -76,6 +76,7 @@ const keyMap = {
|
||||||
new: 'n',
|
new: 'n',
|
||||||
search: 's',
|
search: 's',
|
||||||
forceNew: 'option+n',
|
forceNew: 'option+n',
|
||||||
|
toggleComposeSpoilers: 'option+x',
|
||||||
focusColumn: ['1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
focusColumn: ['1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
||||||
reply: 'r',
|
reply: 'r',
|
||||||
favourite: 'f',
|
favourite: 'f',
|
||||||
|
@ -375,7 +376,7 @@ class UI extends React.PureComponent {
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
this.hotkeys.__mousetrap__.stopCallback = (e, element) => {
|
this.hotkeys.__mousetrap__.stopCallback = (e, element) => {
|
||||||
return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName);
|
return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName) && !e.altKey;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,6 +421,11 @@ class UI extends React.PureComponent {
|
||||||
this.props.dispatch(resetCompose());
|
this.props.dispatch(resetCompose());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleHotkeyToggleComposeSpoilers = e => {
|
||||||
|
e.preventDefault();
|
||||||
|
this.props.dispatch(changeComposeSpoilerness());
|
||||||
|
}
|
||||||
|
|
||||||
handleHotkeyFocusColumn = e => {
|
handleHotkeyFocusColumn = e => {
|
||||||
const index = (e.key * 1) + 1; // First child is drawer, skip that
|
const index = (e.key * 1) + 1; // First child is drawer, skip that
|
||||||
const column = this.node.querySelector(`.column:nth-child(${index})`);
|
const column = this.node.querySelector(`.column:nth-child(${index})`);
|
||||||
|
@ -515,6 +521,7 @@ class UI extends React.PureComponent {
|
||||||
new: this.handleHotkeyNew,
|
new: this.handleHotkeyNew,
|
||||||
search: this.handleHotkeySearch,
|
search: this.handleHotkeySearch,
|
||||||
forceNew: this.handleHotkeyForceNew,
|
forceNew: this.handleHotkeyForceNew,
|
||||||
|
toggleComposeSpoilers: this.handleHotkeyToggleComposeSpoilers,
|
||||||
focusColumn: this.handleHotkeyFocusColumn,
|
focusColumn: this.handleHotkeyFocusColumn,
|
||||||
back: this.handleHotkeyBack,
|
back: this.handleHotkeyBack,
|
||||||
goToHome: this.handleHotkeyGoToHome,
|
goToHome: this.handleHotkeyGoToHome,
|
||||||
|
|
Loading…
Reference in a new issue