-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression: Formatted text rendered by UI Kit (#28060)
- Loading branch information
Showing
13 changed files
with
100 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
apps/meteor/client/components/message/content/uikit/ParsedText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { parse } from '@rocket.chat/message-parser'; | ||
import type { ReactElement } from 'react'; | ||
import React, { memo, useMemo } from 'react'; | ||
|
||
import MessageContentBody from '../../MessageContentBody'; | ||
|
||
const ParsedText = ({ text }: { text: string }): ReactElement | null => { | ||
const md = useMemo(() => parse(text, { emoticons: true }), [text]); | ||
|
||
return <MessageContentBody md={md} />; | ||
}; | ||
|
||
export default memo(ParsedText); |
15 changes: 9 additions & 6 deletions
15
...teor/client/lib/normalizeThreadMessage.ts → ...eor/client/lib/normalizeThreadMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
import type { IMessage } from '@rocket.chat/core-typings'; | ||
import { escapeHTML } from '@rocket.chat/string-helpers'; | ||
import type { ReactElement } from 'react'; | ||
import React from 'react'; | ||
|
||
import { filterMarkdown } from '../../app/markdown/lib/markdown'; | ||
import { renderMessageBody } from './utils/renderMessageBody'; | ||
import ParsedText from '../components/message/content/uikit/ParsedText'; | ||
|
||
export function normalizeThreadMessage({ ...message }: Readonly<Pick<IMessage, 'msg' | 'mentions' | 'attachments'>>): string | undefined { | ||
export function normalizeThreadMessage({ ...message }: Readonly<Pick<IMessage, 'msg' | 'mentions' | 'attachments'>>): ReactElement | null { | ||
if (message.msg) { | ||
message.msg = filterMarkdown(message.msg); | ||
delete message.mentions; | ||
return renderMessageBody(message).replace(/<br\s?\\?>/g, ' '); | ||
return <ParsedText text={message.msg} />; | ||
} | ||
|
||
if (message.attachments) { | ||
const attachment = message.attachments.find((attachment) => attachment.title || attachment.description); | ||
|
||
if (attachment?.description) { | ||
return escapeHTML(attachment.description); | ||
return <>{attachment.description}</>; | ||
} | ||
|
||
if (attachment?.title) { | ||
return escapeHTML(attachment.title); | ||
return <>{attachment.title}</>; | ||
} | ||
} | ||
|
||
return null; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
/* eslint-disable react/no-multi-comp */ | ||
/* eslint-disable react/display-name */ | ||
import { modalParser } from '@rocket.chat/fuselage-ui-kit'; | ||
import React from 'react'; | ||
|
||
import { renderMessageBody } from '../../lib/utils/renderMessageBody'; | ||
import ParsedText from '../../components/message/content/uikit/ParsedText'; | ||
|
||
// TODO: move this to fuselage-ui-kit itself | ||
modalParser.plainText = ({ text } = {}) => text; | ||
|
||
// TODO: move this to fuselage-ui-kit itself | ||
modalParser.mrkdwn = ({ text }) => <span dangerouslySetInnerHTML={{ __html: renderMessageBody({ msg: text }) }} />; | ||
modalParser.mrkdwn = ({ text }) => <ParsedText text={text} />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
apps/meteor/client/views/room/contextualBar/Discussions/components/DiscussionMessage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Box, Message } from '@rocket.chat/fuselage'; | ||
import React, { memo } from 'react'; | ||
|
||
import UserAvatar from '../../../../../components/avatar/UserAvatar'; | ||
|
||
const DiscussionMessage = ({ | ||
_id, | ||
msg, | ||
following, | ||
username, | ||
name = username, | ||
ts, | ||
dcount, | ||
t = (text) => text, | ||
participants, | ||
handleFollowButton, | ||
unread, | ||
mention, | ||
all, | ||
formatDate = (e) => e, | ||
dlm, | ||
className = [], | ||
...props | ||
}) => ( | ||
<Box is={Message} {...props} className={className} pbs='x16' pbe='x8'> | ||
<Message.LeftContainer> | ||
<UserAvatar username={username} className='rcx-message__avatar' size='x36' /> | ||
</Message.LeftContainer> | ||
<Message.Container> | ||
<Message.Header> | ||
<Message.Name title={username}>{name}</Message.Name> | ||
<Message.Timestamp>{formatDate(ts)}</Message.Timestamp> | ||
</Message.Header> | ||
<Message.Body clamp={2}>{msg}</Message.Body> | ||
<Message.Block> | ||
<Message.Metrics> | ||
{!dcount && ( | ||
<Message.Metrics.Item> | ||
<Message.Metrics.Item.Label>{t('No_messages_yet')}</Message.Metrics.Item.Label> | ||
</Message.Metrics.Item> | ||
)} | ||
{!!dcount && ( | ||
<Message.Metrics.Item> | ||
<Message.Metrics.Item.Icon name='discussion' /> | ||
<Message.Metrics.Item.Label>{dcount}</Message.Metrics.Item.Label> | ||
</Message.Metrics.Item> | ||
)} | ||
{!!dcount && ( | ||
<Message.Metrics.Item> | ||
<Message.Metrics.Item.Icon name='clock' /> | ||
<Message.Metrics.Item.Label>{formatDate(dlm)}</Message.Metrics.Item.Label> | ||
</Message.Metrics.Item> | ||
)} | ||
</Message.Metrics> | ||
</Message.Block> | ||
</Message.Container> | ||
</Box> | ||
); | ||
|
||
export default memo(DiscussionMessage); |
63 changes: 0 additions & 63 deletions
63
apps/meteor/client/views/room/contextualBar/Discussions/components/Message.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters