mirror of https://github.com/vector-im/riot-web
allow escaping the first slash to not write a command
parent
5565eca0cb
commit
712c3e5450
|
@ -18,7 +18,7 @@ import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import dis from '../../../dispatcher';
|
import dis from '../../../dispatcher';
|
||||||
import EditorModel from '../../../editor/model';
|
import EditorModel from '../../../editor/model';
|
||||||
import {htmlSerializeIfNeeded, textSerialize, containsEmote, stripEmoteCommand} from '../../../editor/serialize';
|
import {htmlSerializeIfNeeded, textSerialize, containsEmote, stripEmoteCommand, unescapeMessage} from '../../../editor/serialize';
|
||||||
import {CommandPartCreator} from '../../../editor/parts';
|
import {CommandPartCreator} from '../../../editor/parts';
|
||||||
import {MatrixClient} from 'matrix-js-sdk';
|
import {MatrixClient} from 'matrix-js-sdk';
|
||||||
import BasicMessageComposer from "./BasicMessageComposer";
|
import BasicMessageComposer from "./BasicMessageComposer";
|
||||||
|
@ -54,6 +54,7 @@ function createMessageContent(model, permalinkCreator) {
|
||||||
if (isEmote) {
|
if (isEmote) {
|
||||||
model = stripEmoteCommand(model);
|
model = stripEmoteCommand(model);
|
||||||
}
|
}
|
||||||
|
model = unescapeMessage(model);
|
||||||
const repliedToEvent = RoomViewStore.getQuotingEvent();
|
const repliedToEvent = RoomViewStore.getQuotingEvent();
|
||||||
|
|
||||||
const body = textSerialize(model);
|
const body = textSerialize(model);
|
||||||
|
|
|
@ -74,3 +74,16 @@ export function stripEmoteCommand(model) {
|
||||||
model.removeText({index: 0, offset: 0}, 4);
|
model.removeText({index: 0, offset: 0}, 4);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function unescapeMessage(model) {
|
||||||
|
const {parts} = model;
|
||||||
|
if (parts.length) {
|
||||||
|
const firstPart = parts[0];
|
||||||
|
// only unescape \/ to / at start of editor
|
||||||
|
if (firstPart.type === "plain" && firstPart.text.startsWith("\\/")) {
|
||||||
|
model = model.clone();
|
||||||
|
model.removeText({index: 0, offset: 0}, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue