mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 21:24:59 +08:00
fix Control-Backspace after select-all
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> (cherry picked from commit 0f32ec0) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
faf17f06c6
commit
43204ea177
@ -713,22 +713,6 @@ export default class MessageComposerInput extends React.Component {
|
||||
this.direction = '';
|
||||
}
|
||||
|
||||
if (isOnlyCtrlOrCmdKeyEvent(ev)) {
|
||||
const ctrlCmdCommand = {
|
||||
// C-m => Toggles between rich text and markdown modes
|
||||
[KeyCode.KEY_M]: 'toggle-mode',
|
||||
[KeyCode.KEY_B]: 'bold',
|
||||
[KeyCode.KEY_I]: 'italic',
|
||||
[KeyCode.KEY_U]: 'underlined',
|
||||
[KeyCode.KEY_J]: 'inline-code',
|
||||
}[ev.keyCode];
|
||||
|
||||
if (ctrlCmdCommand) {
|
||||
return this.handleKeyCommand(ctrlCmdCommand);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
switch (ev.keyCode) {
|
||||
case KeyCode.ENTER:
|
||||
return this.handleReturn(ev, change);
|
||||
@ -744,9 +728,21 @@ export default class MessageComposerInput extends React.Component {
|
||||
return this.onEscape(ev);
|
||||
case KeyCode.SPACE:
|
||||
return this.onSpace(ev, change);
|
||||
default:
|
||||
// don't intercept it
|
||||
return;
|
||||
}
|
||||
|
||||
if (isOnlyCtrlOrCmdKeyEvent(ev)) {
|
||||
const ctrlCmdCommand = {
|
||||
// C-m => Toggles between rich text and markdown modes
|
||||
[KeyCode.KEY_M]: 'toggle-mode',
|
||||
[KeyCode.KEY_B]: 'bold',
|
||||
[KeyCode.KEY_I]: 'italic',
|
||||
[KeyCode.KEY_U]: 'underlined',
|
||||
[KeyCode.KEY_J]: 'inline-code',
|
||||
}[ev.keyCode];
|
||||
|
||||
if (ctrlCmdCommand) {
|
||||
return this.handleKeyCommand(ctrlCmdCommand);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -757,15 +753,22 @@ export default class MessageComposerInput extends React.Component {
|
||||
return change.setOperationFlag("skip", false).setOperationFlag("merge", false).insertText(ev.key);
|
||||
};
|
||||
|
||||
onBackspace = (ev: Event, change: Change): Change => {
|
||||
if (ev.ctrlKey || ev.metaKey || ev.altKey || ev.ctrlKey || ev.shiftKey) {
|
||||
onBackspace = (ev: KeyboardEvent, change: Change): Change => {
|
||||
if (ev.metaKey || ev.altKey || ev.shiftKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { editorState } = this.state;
|
||||
|
||||
// Allow Ctrl/Cmd-Backspace when focus starts at the start of the composer (e.g select-all)
|
||||
// for some reason if slate sees you Ctrl-backspace and your anchorOffset=0 it just resets your focus
|
||||
if (!editorState.isCollapsed && editorState.anchorOffset === 0) {
|
||||
return change.delete();
|
||||
}
|
||||
|
||||
if (this.state.isRichTextEnabled) {
|
||||
// let backspace exit lists
|
||||
const isList = this.hasBlock('list-item');
|
||||
const { editorState } = this.state;
|
||||
|
||||
if (isList && editorState.anchorOffset == 0) {
|
||||
change
|
||||
|
Loading…
Reference in New Issue
Block a user