Add multiline chat message support
This commit is contained in:
parent
fd8c7fe4f7
commit
94c73a8c1f
|
@ -546,8 +546,10 @@
|
|||
</div>
|
||||
</div>
|
||||
<form data-bind="submit: submitMessageBox">
|
||||
<input id="message-box" type="text" data-bind="
|
||||
attr: { placeholder: messageBoxHint }, textInput: messageBox">
|
||||
<textarea id="message-box" row=1 data-bind="
|
||||
attr: { placeholder: messageBoxHint },
|
||||
textInput: messageBox,
|
||||
event: {keypress: submitOnEnter}"></textarea>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/html" id="channel">
|
||||
|
|
16
app/index.js
16
app/index.js
|
@ -327,6 +327,14 @@ class GlobalBindings {
|
|||
}
|
||||
})
|
||||
|
||||
this.submitOnEnter = function(data, e) {
|
||||
if (e.which == 13) {
|
||||
this.submitMessageBox();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
this.toggleToolbarOrientation = () => {
|
||||
this.toolbarHorizontal(!this.toolbarHorizontal())
|
||||
this.settings.toolbarVertical = !this.toolbarHorizontal()
|
||||
|
@ -791,10 +799,12 @@ class GlobalBindings {
|
|||
target = target.channel()
|
||||
}
|
||||
// Avoid blank message
|
||||
message = sanitize(message).trim()
|
||||
if (message.length == 0) return;
|
||||
if (sanitize(message).trim().length == 0) return;
|
||||
// Support multiline
|
||||
message = message.replace(/\n\n+/g,"\n\n");
|
||||
message = message.replace(/\n/g,"<br>");
|
||||
// Send message
|
||||
target.model.sendMessage(message)
|
||||
target.model.sendMessage(anchorme(message))
|
||||
if (target.users) { // Channel
|
||||
this.log.push({
|
||||
type: 'chat-message-self',
|
||||
|
|
Loading…
Reference in a new issue