mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
[MIRROR] allows to use more newline breaks for longer posts (#8503)
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
@@ -59,8 +59,9 @@
|
||||
input = copytext(input,1,max_length)
|
||||
|
||||
if(extra)
|
||||
input = replacetext(input, new/regex("^\[\\n\]+|\[\\n\]+$", "g"), "")// strip leading and trailing new lines
|
||||
var/temp_input = replace_characters(input, list("\n"=" ","\t"=" "))//one character is replaced by two
|
||||
if(length(input) < (length(temp_input) - 6))//6 is the number of linebreaks allowed per message
|
||||
if(length(input) < (length(temp_input) - 18))//18 is the number of linebreaks allowed per message
|
||||
input = replace_characters(temp_input,list(" "=" "))//replace again, this time the double spaces with single ones
|
||||
|
||||
if(encode)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { useDispatch, useSelector } from 'tgui/backend';
|
||||
import { Button, Collapsible, Flex, Knob, Section } from 'tgui/components';
|
||||
|
||||
import { useSettings } from '../settings';
|
||||
import { selectAudio } from './selectors';
|
||||
|
||||
|
||||
@@ -88,6 +88,11 @@ const interleaveMessage = (node, interleave, color) => {
|
||||
return node;
|
||||
};
|
||||
|
||||
const stripNewLineFlood = (text) => {
|
||||
text = text.replace(/((\n)\2{2})\2+/g, '$1');
|
||||
return text;
|
||||
};
|
||||
|
||||
const createReconnectedNode = () => {
|
||||
const node = document.createElement('div');
|
||||
node.className = 'Chat__reconnected';
|
||||
@@ -507,12 +512,14 @@ class ChatRenderer {
|
||||
node = createMessageNode();
|
||||
// Payload is plain text
|
||||
if (message.text) {
|
||||
message.text = stripNewLineFlood(message.text); // Do not allow more than 3 new lines in a row
|
||||
node.textContent = this.prependTimestamps
|
||||
? getChatTimestamp(message) + message.text
|
||||
: message.text;
|
||||
}
|
||||
// Payload is HTML
|
||||
else if (message.html) {
|
||||
message.html = stripNewLineFlood(message.html); // Do not allow more than 3 new lines in a row
|
||||
node.innerHTML = this.prependTimestamps
|
||||
? getChatTimestamp(message) + message.html
|
||||
: message.html;
|
||||
|
||||
@@ -359,6 +359,7 @@ const VoreSelectedBellyDescriptions = (props) => {
|
||||
message_mode,
|
||||
escapable,
|
||||
interacts,
|
||||
emote_active,
|
||||
} = belly;
|
||||
|
||||
return (
|
||||
@@ -465,10 +466,14 @@ const VoreSelectedBellyDescriptions = (props) => {
|
||||
mode={mode}
|
||||
/>
|
||||
)}
|
||||
<VoreSelectedBellyDescriptionsIdle
|
||||
message_mode={message_mode}
|
||||
mode={mode}
|
||||
/>
|
||||
{emote_active ? (
|
||||
<VoreSelectedBellyDescriptionsIdle
|
||||
message_mode={message_mode}
|
||||
mode={mode}
|
||||
/>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
<LabeledList.Item label="Reset Messages">
|
||||
<Button
|
||||
color="red"
|
||||
|
||||
Reference in New Issue
Block a user