fix: fix being unable to put multiple spaces in a row

This commit is contained in:
Jonathan Rainville 2021-04-01 13:07:26 -04:00 committed by Iuri Matias
parent 6c0fce5b0c
commit a01e851070
3 changed files with 6 additions and 7 deletions

View File

@ -17,7 +17,7 @@ proc mention(self: ChatMessageList, pubKey: string): string =
# See render-inline in status-react/src/status_im/ui/screens/chat/message/message.cljs
proc renderInline(self: ChatMessageList, elem: TextItem): string =
let value = escape_html(elem.literal).multiReplace(("\r\n", "<br/>")).multiReplace(("\n", "<br/>"))
let value = escape_html(elem.literal).multiReplace(("\r\n", "<br/>")).multiReplace(("\n", "<br/>")).multiReplace((" ", "&nbsp;&nbsp;"))
case elem.textType:
of "": result = value
of "code": result = fmt("<code>{value}</code>")

View File

@ -335,7 +335,6 @@ StackLayout {
chatInput.textInput.textFormat = TextEdit.PlainText;
chatInput.textInput.textFormat = TextEdit.RichText;
}
}
}
}

View File

@ -146,14 +146,14 @@ Rectangle {
// handle new line in blockquote
if ((event.key === Qt.Key_Enter || event.key === Qt.Key_Return) && (event.modifiers & Qt.ShiftModifier) && message.data.startsWith(">")) {
if(message.data.startsWith(">") && !message.data.endsWith("\n\n")) {
let newMessage = ""
let newMessage1 = ""
if (message.data.endsWith("\n> ")) {
newMessage = message.data.substr(0, message.data.lastIndexOf("> ")) + "\n\n"
newMessage1 = message.data.substr(0, message.data.lastIndexOf("> ")) + "\n\n"
} else {
newMessage = message.data + "\n> ";
newMessage1 = message.data + "\n> ";
}
messageInputField.remove(0, messageInputField.cursorPosition);
insertInTextInput(0, Emoji.parse(newMessage));
insertInTextInput(0, Emoji.parse(newMessage1));
}
event.accepted = true
}
@ -223,7 +223,7 @@ Rectangle {
const posBeforeEnd = messageInputField.length - messageInputField.cursorPosition;
const plainText = getPlainText()
const formatted = parseBackText(plainText)
messageInputField.text = formatted
messageInputField.text = formatted.replace(/ /g, '&nbsp;&nbsp;')
messageInputField.cursorPosition = messageInputField.length - posBeforeEnd;
}