Fix and re-implement improved text overflow logic
parent
fb9f5dad11
commit
07aac12a2b
|
@ -46,14 +46,18 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
text = text.slice(0, actionMatch.index) + text.slice(actionMatch.index + actionMatch[2].length + 4);
|
text = text.slice(0, actionMatch.index) + text.slice(actionMatch.index + actionMatch[2].length + 4);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Fix this logic not working properly, presumably with existing line breaks
|
// Predetermine overflow line breaks to avoid words breaking while displaying
|
||||||
// Predetermine overflow line breaks to avoid words breaking while displaying
|
const textWords = text.split(' ');
|
||||||
/*const textWords = text.split(' ');
|
let lastLineCount = 1;
|
||||||
let lastLineCount = 1;
|
let newText = textWords[0];
|
||||||
let newText = textWords[0];
|
for (let w = 1; w < textWords.length; w++) {
|
||||||
for (let w = 1; w < textWords.length; w++) {
|
const nextWordText = `${newText} ${textWords[w]}`;
|
||||||
const nextWordText = `${newText} ${textWords[w]}`;
|
if (textWords[w].includes('\n')) {
|
||||||
|
newText = nextWordText;
|
||||||
|
lastLineCount++;
|
||||||
|
} else {
|
||||||
const lineCount = this.message.runWordWrap(nextWordText).split(/\n/g).length;
|
const lineCount = this.message.runWordWrap(nextWordText).split(/\n/g).length;
|
||||||
if (lineCount > lastLineCount) {
|
if (lineCount > lastLineCount) {
|
||||||
lastLineCount = lineCount;
|
lastLineCount = lineCount;
|
||||||
|
@ -61,9 +65,10 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler {
|
||||||
} else
|
} else
|
||||||
newText = nextWordText;
|
newText = nextWordText;
|
||||||
}
|
}
|
||||||
|
|
||||||
text = newText;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text = newText;
|
||||||
|
|
||||||
if (this.textTimer) {
|
if (this.textTimer) {
|
||||||
this.textTimer.remove();
|
this.textTimer.remove();
|
||||||
if (this.textCallbackTimer)
|
if (this.textCallbackTimer)
|
||||||
|
|
Loading…
Reference in New Issue