-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathpost_text.tsx
56 lines (44 loc) · 1.39 KB
/
post_text.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react';
import {useSelector} from 'react-redux';
import {GlobalState} from '@mattermost/types/store';
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {Post} from '@mattermost/types/posts';
export type ChannelNamesMap = {
[name: string]: {
display_name: string;
team_name?: string;
} | Channel;
};
interface Props {
message: string;
channelID: string;
}
const PostText = (props: Props) => {
const channel = useSelector<GlobalState, Channel>((state) => state.entities.channels.channels[props.channelID]);
const team = useSelector<GlobalState, Team>((state) => state.entities.teams.teams[channel?.team_id]);
//const channelNamesMap = useSelector<GlobalState, ChannelNamesMap>(getChannelsNameMapInCurrentTeam);
// @ts-ignore
const {formatText, messageHtmlToComponent} = window.PostUtils;
const markdownOptions = {
singleline: false,
mentionHighlight: true,
atMentions: true,
team,
//channelNamesMap,
};
const messageHtmlToComponentOptions = {
hasPluginTooltips: true,
};
const text = messageHtmlToComponent(
formatText(props.message, markdownOptions),
true,
messageHtmlToComponentOptions,
);
return (
<div>
{text}
</div>
);
};
export default PostText;