fix: enable copying <script> but will still go away when putting emoji
This commit is contained in:
parent
299496a871
commit
d4a220b051
|
@ -139,8 +139,10 @@ Rectangle {
|
||||||
const text = chatsModel.plainText(Emoji.deparse(messageInputField.text));
|
const text = chatsModel.plainText(Emoji.deparse(messageInputField.text));
|
||||||
var words = text.split(' ');
|
var words = text.split(' ');
|
||||||
|
|
||||||
|
let madeChanges = false
|
||||||
|
let transform = true;
|
||||||
for (var i = 0; i < words.length; i++) {
|
for (var i = 0; i < words.length; i++) {
|
||||||
var transform = true;
|
transform = true;
|
||||||
if (words[i].charAt(0) === ':') {
|
if (words[i].charAt(0) === ':') {
|
||||||
for (var j = 0; j < words[i].length; j++) {
|
for (var j = 0; j < words[i].length; j++) {
|
||||||
if (Utils.isSpace(words[i].charAt(j)) === true || Utils.isPunct(words[i].charAt(j)) === true) {
|
if (Utils.isSpace(words[i].charAt(j)) === true || Utils.isPunct(words[i].charAt(j)) === true) {
|
||||||
|
@ -149,15 +151,18 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transform) {
|
if (transform) {
|
||||||
|
madeChanges = true
|
||||||
const codePoint = Emoji.getEmojiUnicode(words[i]);
|
const codePoint = Emoji.getEmojiUnicode(words[i]);
|
||||||
words[i] = words[i].replace(words[i], (codePoint !== undefined) ? Emoji.fromCodePoint(codePoint) : words[i]);
|
words[i] = words[i].replace(words[i], (codePoint !== undefined) ? Emoji.fromCodePoint(codePoint) : words[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (madeChanges) {
|
||||||
messageInputField.remove(0, messageInputField.length);
|
messageInputField.remove(0, messageInputField.length);
|
||||||
insertInTextInput(0, Emoji.parse(words.join(' '), '26x26'));
|
insertInTextInput(0, Emoji.parse(words.join(' '), '26x26'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// since emoji length is not 1 we need to match that position that TextArea returns
|
// since emoji length is not 1 we need to match that position that TextArea returns
|
||||||
// to the actual position in the string.
|
// to the actual position in the string.
|
||||||
|
|
Loading…
Reference in New Issue