mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-22 22:30:52 +01:00
Chat changes
This commit is contained in:
parent
e6522743b2
commit
a9bac2afa6
@ -1,6 +1,7 @@
|
||||
import * as joypixels from 'emoji-toolkit';
|
||||
|
||||
const allowedColours: Map<string, string> = new Map();
|
||||
|
||||
allowedColours.set('r', 'red');
|
||||
allowedColours.set('b', 'blue');
|
||||
allowedColours.set('g', 'green');
|
||||
@ -23,14 +24,13 @@ allowedColours.set('brown', 'brown');
|
||||
allowedColours.set('purple', 'purple');
|
||||
allowedColours.set('pink', 'pink');
|
||||
|
||||
function encodeHTML(str: string)
|
||||
const encodeHTML = (str: string) =>
|
||||
{
|
||||
return str.replace(/([\u00A0-\u9999<>&])(.|$)/g, function(full, char, next)
|
||||
return str.replace(/([\u00A0-\u9999<>&])(.|$)/g, (full, char, next) =>
|
||||
{
|
||||
if(char !== '&' || next !== '#')
|
||||
{
|
||||
if(/[\u00A0-\u9999<>&]/.test(next))
|
||||
next = '&#' + next.charCodeAt(0) + ';';
|
||||
if(/[\u00A0-\u9999<>&]/.test(next)) next = '&#' + next.charCodeAt(0) + ';';
|
||||
|
||||
return '&#' + char.charCodeAt(0) + ';' + next;
|
||||
}
|
||||
@ -39,12 +39,11 @@ function encodeHTML(str: string)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export function RoomChatFormatter(content: string): string
|
||||
export const RoomChatFormatter = (content: string) =>
|
||||
{
|
||||
let result = '';
|
||||
|
||||
content = encodeHTML(content)
|
||||
content = encodeHTML(content);
|
||||
content = (joypixels.shortnameToUnicode(content) as string)
|
||||
|
||||
if(content.startsWith('@') && content.indexOf('@', 1) > -1)
|
||||
|
@ -22,16 +22,17 @@ export const ChatWidgetView: FC<{}> = props =>
|
||||
{
|
||||
const collides = chatMessages[i];
|
||||
|
||||
if(!collides || (chat === collides) || (tempChats.indexOf(collides) >= 0) || ((collides.top - moved) >= (chat.top + chat.height))) continue;
|
||||
if(!collides || (chat === collides) || (tempChats.indexOf(collides) >= 0) || (((collides.top + collides.height) - moved) > (chat.top + chat.height))) continue;
|
||||
|
||||
if(DoChatsOverlap(chat, collides, -moved, 4))
|
||||
chat.skipMovement = true;
|
||||
|
||||
if(DoChatsOverlap(chat, collides, -moved, 0))
|
||||
{
|
||||
const amount = Math.abs((collides.top + collides.height) - chat.top);
|
||||
|
||||
tempChats.push(collides);
|
||||
|
||||
collides.top -= amount;
|
||||
|
||||
collides.skipMovement = true;
|
||||
|
||||
checkOverlappingChats(collides, amount, tempChats);
|
||||
|
Loading…
Reference in New Issue
Block a user