Add braces to all blocks
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
3830a95af2
commit
dbe76e973e
2 changed files with 17 additions and 8 deletions
|
@ -9,24 +9,31 @@ export class MessageBodyBuilder {
|
|||
fromText(text) {
|
||||
const components = text.split("\n");
|
||||
components.flatMap(e => ["\n", e]).slice(1).forEach(e => {
|
||||
if (e === "\n")
|
||||
if (e === "\n") {
|
||||
this.insertNewline();
|
||||
else
|
||||
}
|
||||
else {
|
||||
linkify(e, this.insert.bind(this));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
insert(text, isLink) {
|
||||
if (!text.length) return;
|
||||
if (isLink)
|
||||
if (!text.length) {
|
||||
return;
|
||||
}
|
||||
if (isLink) {
|
||||
this.insertLink(text, text);
|
||||
else
|
||||
}
|
||||
else {
|
||||
this.insertText(text);
|
||||
}
|
||||
}
|
||||
|
||||
insertText(text) {
|
||||
if (text.length)
|
||||
if (text.length) {
|
||||
this._root.push({ type: "text", text: text });
|
||||
}
|
||||
}
|
||||
|
||||
insertLink(link, displayText) {
|
||||
|
|
|
@ -22,15 +22,17 @@ export class TextTile extends MessageTile {
|
|||
get _contentBody() {
|
||||
const content = this._getContent();
|
||||
let body = content?.body || "";
|
||||
if (content.msgtype === "m.emote")
|
||||
if (content.msgtype === "m.emote") {
|
||||
body = `* ${this.displayName} ${body}`;
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
get body() {
|
||||
const body = this._contentBody;
|
||||
if (body === this._body)
|
||||
if (body === this._body) {
|
||||
return this._message;
|
||||
}
|
||||
const message = new MessageBodyBuilder();
|
||||
message.fromText(body);
|
||||
[this._body, this._message] = [body, message];
|
||||
|
|
Reference in a new issue