fix(StatusChatInput): missbehavior when text exceeds 2000 chars
Closes #5107
This commit is contained in:
parent
70b6acce16
commit
8ece8e9fd1
|
@ -945,6 +945,7 @@ Rectangle {
|
||||||
TextArea {
|
TextArea {
|
||||||
id: messageInputField
|
id: messageInputField
|
||||||
property var lastClick: 0
|
property var lastClick: 0
|
||||||
|
property int cursorWhenPressed: 0
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
font.family: Style.current.fontRegular.name
|
font.family: Style.current.fontRegular.name
|
||||||
|
@ -958,6 +959,7 @@ Rectangle {
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
keyEvent = event;
|
keyEvent = event;
|
||||||
onKeyPress(event)
|
onKeyPress(event)
|
||||||
|
cursorWhenPressed = cursorPosition;
|
||||||
}
|
}
|
||||||
Keys.onReleased: onRelease(event) // gives much more up to date cursorPosition
|
Keys.onReleased: onRelease(event) // gives much more up to date cursorPosition
|
||||||
Keys.onShortcutOverride: event.accepted = isUploadFilePressed(event)
|
Keys.onShortcutOverride: event.accepted = isUploadFilePressed(event)
|
||||||
|
@ -1006,20 +1008,26 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
var symbols = ":='xX><0O;*dB8-D#%\\";
|
if (length <= control.messageLimit) {
|
||||||
if ((length > 1) && (symbols.indexOf(getText((cursorPosition - 2), (cursorPosition - 1))) !== -1)
|
var symbols = ":='xX><0O;*dB8-D#%\\";
|
||||||
&& (!getText((cursorPosition - 7), cursorPosition).includes("http"))) {
|
if ((length > 1) && (symbols.indexOf(getText((cursorPosition - 2), (cursorPosition - 1))) !== -1)
|
||||||
const emojis = EmojiJSON.emoji_json.filter(function (emoji) {
|
&& (!getText((cursorPosition - 7), cursorPosition).includes("http"))) {
|
||||||
if (emoji.aliases_ascii.includes(getText((cursorPosition - 2), cursorPosition)) ||
|
const emojis = EmojiJSON.emoji_json.filter(function (emoji) {
|
||||||
emoji.aliases_ascii.includes(getText((cursorPosition - 3), cursorPosition))) {
|
if (emoji.aliases_ascii.includes(getText((cursorPosition - 2), cursorPosition)) ||
|
||||||
var has2Chars = emoji.aliases_ascii.includes(getText((cursorPosition - 2), cursorPosition));
|
emoji.aliases_ascii.includes(getText((cursorPosition - 3), cursorPosition))) {
|
||||||
replaceWithEmoji("", getText(cursorPosition - (has2Chars ? 2 : 3), cursorPosition), emoji.unicode);
|
var has2Chars = emoji.aliases_ascii.includes(getText((cursorPosition - 2), cursorPosition));
|
||||||
}
|
replaceWithEmoji("", getText(cursorPosition - (has2Chars ? 2 : 3), cursorPosition), emoji.unicode);
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
if (text === "") {
|
}
|
||||||
mentionsPos = [];
|
if (text === "") {
|
||||||
|
mentionsPos = [];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var removeFrom = (cursorPosition < messageLimit) ? cursorWhenPressed : messageLimit;
|
||||||
|
remove(removeFrom, cursorPosition);
|
||||||
}
|
}
|
||||||
|
messageLengthLimit.remainingChars = (messageLimit - length);
|
||||||
}
|
}
|
||||||
|
|
||||||
onReleased: function (event) {
|
onReleased: function (event) {
|
||||||
|
@ -1146,15 +1154,15 @@ Rectangle {
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: messageLengthLimit
|
id: messageLengthLimit
|
||||||
property int remainingChars: messageLimit - messageInputField.length
|
property int remainingChars: -1
|
||||||
text: remainingChars.toString()
|
|
||||||
visible: remainingChars <= control.messageLimitVisible
|
|
||||||
color: (remainingChars <= 0) ? Style.current.danger : Style.current.textColor
|
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: actions.top
|
anchors.bottom: actions.top
|
||||||
anchors.rightMargin: control.isStatusUpdateInput ? Style.current.padding : Style.current.radius
|
anchors.rightMargin: control.isStatusUpdateInput ? Style.current.padding : Style.current.radius
|
||||||
leftPadding: Style.current.halfPadding
|
leftPadding: Style.current.halfPadding
|
||||||
rightPadding: Style.current.halfPadding
|
rightPadding: Style.current.halfPadding
|
||||||
|
visible: ((messageInputField.length >= control.messageLimitVisible) && (messageInputField.length <= control.messageLimit))
|
||||||
|
color: (remainingChars <= messageLimitVisible) ? Style.current.danger : Style.current.textColor
|
||||||
|
text: visible ? remainingChars.toString() : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
Loading…
Reference in New Issue