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)
|
input = copytext(input,1,max_length)
|
||||||
|
|
||||||
if(extra)
|
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
|
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
|
input = replace_characters(temp_input,list(" "=" "))//replace again, this time the double spaces with single ones
|
||||||
|
|
||||||
if(encode)
|
if(encode)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
import { toFixed } from 'common/math';
|
import { toFixed } from 'common/math';
|
||||||
import { useDispatch, useSelector } from 'tgui/backend';
|
import { useDispatch, useSelector } from 'tgui/backend';
|
||||||
import { Button, Collapsible, Flex, Knob, Section } from 'tgui/components';
|
import { Button, Collapsible, Flex, Knob, Section } from 'tgui/components';
|
||||||
|
|
||||||
import { useSettings } from '../settings';
|
import { useSettings } from '../settings';
|
||||||
import { selectAudio } from './selectors';
|
import { selectAudio } from './selectors';
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,11 @@ const interleaveMessage = (node, interleave, color) => {
|
|||||||
return node;
|
return node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const stripNewLineFlood = (text) => {
|
||||||
|
text = text.replace(/((\n)\2{2})\2+/g, '$1');
|
||||||
|
return text;
|
||||||
|
};
|
||||||
|
|
||||||
const createReconnectedNode = () => {
|
const createReconnectedNode = () => {
|
||||||
const node = document.createElement('div');
|
const node = document.createElement('div');
|
||||||
node.className = 'Chat__reconnected';
|
node.className = 'Chat__reconnected';
|
||||||
@@ -507,12 +512,14 @@ class ChatRenderer {
|
|||||||
node = createMessageNode();
|
node = createMessageNode();
|
||||||
// Payload is plain text
|
// Payload is plain text
|
||||||
if (message.text) {
|
if (message.text) {
|
||||||
|
message.text = stripNewLineFlood(message.text); // Do not allow more than 3 new lines in a row
|
||||||
node.textContent = this.prependTimestamps
|
node.textContent = this.prependTimestamps
|
||||||
? getChatTimestamp(message) + message.text
|
? getChatTimestamp(message) + message.text
|
||||||
: message.text;
|
: message.text;
|
||||||
}
|
}
|
||||||
// Payload is HTML
|
// Payload is HTML
|
||||||
else if (message.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
|
node.innerHTML = this.prependTimestamps
|
||||||
? getChatTimestamp(message) + message.html
|
? getChatTimestamp(message) + message.html
|
||||||
: message.html;
|
: message.html;
|
||||||
|
|||||||
@@ -359,6 +359,7 @@ const VoreSelectedBellyDescriptions = (props) => {
|
|||||||
message_mode,
|
message_mode,
|
||||||
escapable,
|
escapable,
|
||||||
interacts,
|
interacts,
|
||||||
|
emote_active,
|
||||||
} = belly;
|
} = belly;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -465,10 +466,14 @@ const VoreSelectedBellyDescriptions = (props) => {
|
|||||||
mode={mode}
|
mode={mode}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<VoreSelectedBellyDescriptionsIdle
|
{emote_active ? (
|
||||||
message_mode={message_mode}
|
<VoreSelectedBellyDescriptionsIdle
|
||||||
mode={mode}
|
message_mode={message_mode}
|
||||||
/>
|
mode={mode}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
<LabeledList.Item label="Reset Messages">
|
<LabeledList.Item label="Reset Messages">
|
||||||
<Button
|
<Button
|
||||||
color="red"
|
color="red"
|
||||||
|
|||||||
Reference in New Issue
Block a user