Add sending notice support && tweak markdown.
This commit is contained in:
parent
06c6d7a74d
commit
a1941784eb
2
js/md.js
2
js/md.js
|
@ -54,7 +54,7 @@ var markdown_parser = function(str){
|
||||||
// bold
|
// bold
|
||||||
['/(\\*\\*|__)(.*?)\\1/g', '<strong>\\2</strong>'],
|
['/(\\*\\*|__)(.*?)\\1/g', '<strong>\\2</strong>'],
|
||||||
// emphasis
|
// emphasis
|
||||||
['/(\\*|_)(.*?)\\1/g', '<em>\\2</em>'],
|
['/(\\*|_)(.*?)\\1/g', '<i>\\2</i>'],
|
||||||
// strike
|
// strike
|
||||||
['/(\\~\\~)(.*?)\\1/g', '<del>\\2</del>'],
|
['/(\\~\\~)(.*?)\\1/g', '<del>\\2</del>'],
|
||||||
// quote
|
// quote
|
||||||
|
|
|
@ -25,7 +25,8 @@ AvatarContainer {
|
||||||
anchors.margins: 12
|
anchors.margins: 12
|
||||||
wrapMode: Label.Wrap
|
wrapMode: Label.Wrap
|
||||||
linkColor: isNotice ? Material.accent : sentByMe ? Material.accent : "white"
|
linkColor: isNotice ? Material.accent : sentByMe ? Material.accent : "white"
|
||||||
textFormat: contentType === "text/html" ? Text.RichText : Text.StyledText
|
// textFormat: contentType === "text/html" ? Text.RichText : Text.StyledText
|
||||||
|
textFormat: Text.StyledText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ Item {
|
||||||
width: delegateLoader.width
|
width: delegateLoader.width
|
||||||
height: delegateLoader.height
|
height: delegateLoader.height
|
||||||
|
|
||||||
anchors.right: (eventType === "message" || eventType === "image" || eventType === "file" || eventType === "video" || eventType === "audio") && sentByMe ? parent.right : undefined
|
anchors.right: (eventType === "message" || eventType === "image" || eventType === "file" || eventType === "video" || eventType === "audio" || eventType === "notice") && sentByMe ? parent.right : undefined
|
||||||
anchors.horizontalCenter: (eventType === "state" || eventType === "emote") ? parent.horizontalCenter : undefined
|
anchors.horizontalCenter: (eventType === "state" || eventType === "emote") ? parent.horizontalCenter : undefined
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|
|
@ -174,47 +174,23 @@ Item {
|
||||||
bottomPadding: 0
|
bottomPadding: 0
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
|
|
||||||
background: Item{
|
background: Rectangle {
|
||||||
Rectangle {
|
color: Material.theme == Material.Light ? "#eaeaea" : "#242424"
|
||||||
anchors.fill: parent
|
|
||||||
color: Material.theme == Material.Light ? "#eaeaea" : "#242424"
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id:progressIndicator
|
|
||||||
|
|
||||||
height: parent.height
|
|
||||||
width: 0
|
|
||||||
color: Material.accent
|
|
||||||
opacity: 1 - width / inputField.width
|
|
||||||
|
|
||||||
NumberAnimation on width {
|
|
||||||
id: animation
|
|
||||||
from: 0
|
|
||||||
to: inputField.width
|
|
||||||
duration: 300
|
|
||||||
easing.type: Easing.Linear
|
|
||||||
}
|
|
||||||
|
|
||||||
function animate() { animation.start() }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onReturnPressed: {
|
Keys.onReturnPressed: {
|
||||||
postMessage(inputField.text)
|
if (inputField.text) {
|
||||||
progressIndicator.animate()
|
postMessage(inputField.text)
|
||||||
inputField.text = ""
|
inputField.text = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function postMessage(text) {
|
function postMessage(text) {
|
||||||
if (text.trim().length === 0) {
|
if (text.trim().length === 0) { return }
|
||||||
return
|
if(!currentRoom) { return }
|
||||||
}
|
|
||||||
if(!currentRoom) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var PREFIX_ME = '/me '
|
var PREFIX_ME = '/me '
|
||||||
|
var PREFIX_NOTICE = '/notice '
|
||||||
var PREFIX_RAINBOW = '/rainbow '
|
var PREFIX_RAINBOW = '/rainbow '
|
||||||
var PREFIX_HTML = '/html '
|
var PREFIX_HTML = '/html '
|
||||||
var PREFIX_MARKDOWN = '/md '
|
var PREFIX_MARKDOWN = '/md '
|
||||||
|
@ -224,6 +200,11 @@ Item {
|
||||||
currentRoom.postMessage("m.emote", text)
|
currentRoom.postMessage("m.emote", text)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (text.indexOf(PREFIX_NOTICE) === 0) {
|
||||||
|
text = text.substr(PREFIX_NOTICE.length)
|
||||||
|
currentRoom.postMessage("m.notice", text)
|
||||||
|
return
|
||||||
|
}
|
||||||
if (text.indexOf(PREFIX_RAINBOW) === 0) {
|
if (text.indexOf(PREFIX_RAINBOW) === 0) {
|
||||||
text = text.substr(PREFIX_RAINBOW.length)
|
text = text.substr(PREFIX_RAINBOW.length)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue