forked from cwtch.im/ui
Forbid pasting HTML
This commit is contained in:
parent
6bca7d2a6d
commit
7c6a1ab8f1
|
@ -157,6 +157,7 @@ ColumnLayout {
|
|||
//console.log("1: " + txtMessage.getText(0, txtMessage.text.length))
|
||||
|
||||
// convert <img> tags back to their emoji form
|
||||
// Then parse out the rest of the HTML
|
||||
var nt = restoreEmoji(txtMessage.text)
|
||||
if (nt != txtMessage.text) {
|
||||
skipOneUpdate = true
|
||||
|
@ -166,27 +167,26 @@ ColumnLayout {
|
|||
//console.log("2: " + txtMessage.getText(0, txtMessage.text.length))
|
||||
|
||||
// strip all HTML tags
|
||||
var theText = txtMessage.getText(0, txtMessage.text.length)
|
||||
var theText = Utils.htmlEscaped(txtMessage.getText(0, txtMessage.text.length))
|
||||
//console.log("3: " + theText)
|
||||
|
||||
// convert emoji back to <img> tags
|
||||
nt = parse(theText, 10)
|
||||
//console.log("4: " + nt)
|
||||
|
||||
// if there were changes...
|
||||
if (nt != txtMessage.getText(0, txtMessage.text.length)) {
|
||||
// first we need to update the cursor position to be the same distance from the end
|
||||
var oldcursor = txtMessage.cursorPosition
|
||||
var oldlen = txtMessage.getText(0, txtMessage.text.length).length
|
||||
|
||||
// then we actually put the updated text in
|
||||
skipOneUpdate = true
|
||||
txtMessage.text = nt
|
||||
// first we need to update the cursor position to be the same distance from the end
|
||||
var oldcursor = txtMessage.cursorPosition
|
||||
var oldlen = txtMessage.getText(0, txtMessage.text.length).length
|
||||
|
||||
// then we actually put the updated text in
|
||||
skipOneUpdate = true
|
||||
txtMessage.text = nt
|
||||
|
||||
// and then restore the cursor
|
||||
var newlen = txtMessage.getText(0, txtMessage.text.length).length
|
||||
txtMessage.cursorPosition = newlen - (oldlen - oldcursor)
|
||||
|
||||
// and then restore the cursor
|
||||
var newlen = txtMessage.getText(0, txtMessage.text.length).length
|
||||
txtMessage.cursorPosition = newlen - (oldlen - oldcursor)
|
||||
}
|
||||
|
||||
// autoscroll down only when the scrollbar is already all the way down
|
||||
if (flkMessage.contentY + flkMessage.height >= flkMessage.contentHeight - txtMessage.height && flkMessage.contentHeight > flkMessage.height) {
|
||||
|
|
Loading…
Reference in New Issue