fix: enable copying <script> but will still go away when putting emoji

This commit is contained in:
Jonathan Rainville 2020-11-19 12:53:53 -05:00 committed by Iuri Matias
parent 299496a871
commit d4a220b051
1 changed files with 8 additions and 3 deletions

View File

@ -139,8 +139,10 @@ Rectangle {
const text = chatsModel.plainText(Emoji.deparse(messageInputField.text));
var words = text.split(' ');
let madeChanges = false
let transform = true;
for (var i = 0; i < words.length; i++) {
var transform = true;
transform = true;
if (words[i].charAt(0) === ':') {
for (var j = 0; j < words[i].length; j++) {
if (Utils.isSpace(words[i].charAt(j)) === true || Utils.isPunct(words[i].charAt(j)) === true) {
@ -149,14 +151,17 @@ Rectangle {
}
if (transform) {
madeChanges = true
const codePoint = Emoji.getEmojiUnicode(words[i]);
words[i] = words[i].replace(words[i], (codePoint !== undefined) ? Emoji.fromCodePoint(codePoint) : words[i]);
}
}
}
messageInputField.remove(0, messageInputField.length);
insertInTextInput(0, Emoji.parse(words.join('&nbsp;'), '26x26'));
if (madeChanges) {
messageInputField.remove(0, messageInputField.length);
insertInTextInput(0, Emoji.parse(words.join('&nbsp;'), '26x26'));
}
}
// since emoji length is not 1 we need to match that position that TextArea returns