Allow copying text from non-message events
This commit is contained in:
parent
936c49127d
commit
3f69710813
|
@ -126,9 +126,14 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! eventList.selectedCount && eventList.currentIndex !== -1) {
|
if (! eventList.selectedCount && eventList.currentIndex !== -1) {
|
||||||
Clipboard.text = JSON.parse(
|
const model = eventList.model.get(eventList.currentIndex)
|
||||||
eventList.model.get(eventList.currentIndex).source
|
const source = JSON.parse(model.source)
|
||||||
).body
|
|
||||||
|
Clipboard.text =
|
||||||
|
"body" in source ?
|
||||||
|
source.body :
|
||||||
|
utils.stripHtmlTags(utils.processedEventText(model))
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,9 +163,9 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function escapeHtml(string) {
|
function escapeHtml(text) {
|
||||||
// Replace special HTML characters by encoded alternatives
|
// Replace special HTML characters by encoded alternatives
|
||||||
return string.replace("&", "&")
|
return text.replace("&", "&")
|
||||||
.replace("<", "<")
|
.replace("<", "<")
|
||||||
.replace(">", ">")
|
.replace(">", ">")
|
||||||
.replace('"', """)
|
.replace('"', """)
|
||||||
|
@ -173,6 +173,12 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function stripHtmlTags(text) {
|
||||||
|
// XXX: Potentially unsafe!
|
||||||
|
return text.replace(/<\/?[^>]+(>|$)/g, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function processedEventText(ev) {
|
function processedEventText(ev) {
|
||||||
const type = ev.event_type
|
const type = ev.event_type
|
||||||
const unknownMsg = type === "RoomMessageUnknown"
|
const unknownMsg = type === "RoomMessageUnknown"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user