You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-20 16:22:28 +03:00
let backspace delete list nodes in RTE
This commit is contained in:
@@ -77,6 +77,10 @@ const ENTITY_TYPES = {
|
|||||||
AT_ROOM_PILL: 'ATROOMPILL',
|
AT_ROOM_PILL: 'ATROOMPILL',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// the Slate node type to default to for unstyled text when in RTE mode.
|
||||||
|
// (we use 'line' for oneliners however)
|
||||||
|
const DEFAULT_NODE = 'paragraph';
|
||||||
|
|
||||||
|
|
||||||
function onSendMessageFailed(err, room) {
|
function onSendMessageFailed(err, room) {
|
||||||
// XXX: temporary logging to try to diagnose
|
// XXX: temporary logging to try to diagnose
|
||||||
@@ -548,6 +552,8 @@ export default class MessageComposerInput extends React.Component {
|
|||||||
switch (ev.keyCode) {
|
switch (ev.keyCode) {
|
||||||
case KeyCode.ENTER:
|
case KeyCode.ENTER:
|
||||||
return this.handleReturn(ev);
|
return this.handleReturn(ev);
|
||||||
|
case KeyCode.BACKSPACE:
|
||||||
|
return this.onBackspace(ev);
|
||||||
case KeyCode.UP:
|
case KeyCode.UP:
|
||||||
return this.onVerticalArrow(ev, true);
|
return this.onVerticalArrow(ev, true);
|
||||||
case KeyCode.DOWN:
|
case KeyCode.DOWN:
|
||||||
@@ -562,6 +568,23 @@ export default class MessageComposerInput extends React.Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onBackspace = (ev: Event): boolean => {
|
||||||
|
if (this.state.isRichtextEnabled) {
|
||||||
|
// let backspace exit lists
|
||||||
|
const isList = this.hasBlock('list-item');
|
||||||
|
if (isList) {
|
||||||
|
const change = this.state.editorState.change();
|
||||||
|
change
|
||||||
|
.setBlocks(DEFAULT_NODE)
|
||||||
|
.unwrapBlock('bulleted-list')
|
||||||
|
.unwrapBlock('numbered-list');
|
||||||
|
this.onChange(change);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
handleKeyCommand = (command: string): boolean => {
|
handleKeyCommand = (command: string): boolean => {
|
||||||
if (command === 'toggle-mode') {
|
if (command === 'toggle-mode') {
|
||||||
this.enableRichtext(!this.state.isRichtextEnabled);
|
this.enableRichtext(!this.state.isRichtextEnabled);
|
||||||
@@ -570,8 +593,6 @@ export default class MessageComposerInput extends React.Component {
|
|||||||
|
|
||||||
let newState: ?Value = null;
|
let newState: ?Value = null;
|
||||||
|
|
||||||
const DEFAULT_NODE = 'paragraph';
|
|
||||||
|
|
||||||
// Draft handles rich text mode commands by default but we need to do it ourselves for Markdown.
|
// Draft handles rich text mode commands by default but we need to do it ourselves for Markdown.
|
||||||
if (this.state.isRichtextEnabled) {
|
if (this.state.isRichtextEnabled) {
|
||||||
const type = command;
|
const type = command;
|
||||||
|
|||||||
Reference in New Issue
Block a user