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