support auto complete for /commands

This commit is contained in:
Bruno Windels 2019-08-21 15:27:50 +02:00
parent 88cc1c428d
commit c5cd8b943a
4 changed files with 41 additions and 9 deletions

View file

@ -23,6 +23,7 @@ export function mdSerialize(model) {
case "newline":
return html + "\n";
case "plain":
case "command":
case "pill-candidate":
case "at-room-pill":
return html + part.text;
@ -47,6 +48,7 @@ export function textSerialize(model) {
case "newline":
return text + "\n";
case "plain":
case "command":
case "pill-candidate":
case "at-room-pill":
return text + part.text;
@ -59,7 +61,11 @@ export function textSerialize(model) {
export function containsEmote(model) {
const firstPart = model.parts[0];
return firstPart && firstPart.type === "plain" && firstPart.text.startsWith("/me ");
// part type will be "plain" while editing,
// and "command" while composing a message.
return firstPart &&
(firstPart.type === "plain" || firstPart.type === "command") &&
firstPart.text.startsWith("/me ");
}
export function stripEmoteCommand(model) {