-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
562 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,7 @@ | |
width: 44px; | ||
height: 44px; | ||
} | ||
.big > .emojione { | ||
width: 44px; | ||
height: 44px; | ||
} |
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
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 |
---|---|---|
|
@@ -589,6 +589,7 @@ export class Messages extends Base { | |
}, | ||
}, | ||
$unset: { | ||
md: 1, | ||
blocks: 1, | ||
tshow: 1, | ||
}, | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { BigEmoji as ASTBigEmoji } from '@rocket.chat/message-parser'; | ||
import React, { FC } from 'react'; | ||
|
||
import Emoji from '../../Emoji'; | ||
|
||
type BigEmojiProps = { | ||
value: ASTBigEmoji['value']; | ||
}; | ||
|
||
const BigEmoji: FC<BigEmojiProps> = ({ value }) => ( | ||
<> | ||
{value.map((block, index) => ( | ||
<Emoji className='big' key={index} emojiHandle={`:${block.value.value}:`} /> | ||
))} | ||
</> | ||
); | ||
|
||
export default BigEmoji; |
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,63 @@ | ||
import { BigEmoji as ASTBigEmoji, MarkdownAST as GazzodownAST } from '@rocket.chat/message-parser'; | ||
import React, { FC, memo } from 'react'; | ||
|
||
import BigEmoji from './BigEmoji'; | ||
import Code from './Code'; | ||
import Heading from './Heading'; | ||
import OrderedList from './OrderedList'; | ||
import Paragraph from './Paragraph'; | ||
import Quote from './Quote'; | ||
import TaskList from './TaskList'; | ||
import UnorderedList from './UnorderedList'; | ||
import { UserMention } from './definitions/UserMention'; | ||
|
||
type BodyProps = { | ||
tokens: GazzodownAST; | ||
mentions: UserMention[]; | ||
}; | ||
|
||
const isBigEmoji = (tokens: GazzodownAST): tokens is [ASTBigEmoji] => | ||
tokens.length === 1 && tokens[0].type === 'BIG_EMOJI'; | ||
|
||
const Body: FC<BodyProps> = ({ tokens, mentions }) => { | ||
if (isBigEmoji(tokens)) { | ||
return <BigEmoji value={tokens[0].value} />; | ||
} | ||
|
||
return ( | ||
<> | ||
{tokens.map((block, index) => { | ||
if (block.type === 'UNORDERED_LIST') { | ||
return <UnorderedList value={block.value} key={index} />; | ||
} | ||
|
||
if (block.type === 'QUOTE') { | ||
return <Quote value={block.value} key={index} />; | ||
} | ||
if (block.type === 'TASKS') { | ||
return <TaskList value={block.value} key={index} />; | ||
} | ||
|
||
if (block.type === 'ORDERED_LIST') { | ||
return <OrderedList value={block.value} key={index} />; | ||
} | ||
|
||
if (block.type === 'PARAGRAPH') { | ||
return <Paragraph mentions={mentions} value={block.value} key={index} />; | ||
} | ||
|
||
if (block.type === 'CODE') { | ||
return <Code value={block.value} key={index} />; | ||
} | ||
|
||
if (block.type === 'HEADING') { | ||
return <Heading value={block.value} key={index} />; | ||
} | ||
|
||
return null; | ||
})} | ||
</> | ||
); | ||
}; | ||
|
||
export default memo(Body); |
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,24 @@ | ||
import { Bold as ASTBold } from '@rocket.chat/message-parser'; | ||
import React, { FC } from 'react'; | ||
|
||
import Italic from './Italic'; | ||
import Strike from './Strike'; | ||
|
||
const Bold: FC<{ value: ASTBold['value'] }> = ({ value = [] }) => ( | ||
<strong> | ||
{value.map((block, index) => { | ||
switch (block.type) { | ||
case 'PLAIN_TEXT': | ||
return block.value; | ||
case 'STRIKE': | ||
return <Strike key={index} value={block.value} />; | ||
case 'ITALIC': | ||
return <Italic key={index} value={block.value} />; | ||
default: | ||
return null; | ||
} | ||
})} | ||
</strong> | ||
); | ||
|
||
export default Bold; |
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,19 @@ | ||
import { Code as ASTCode } from '@rocket.chat/message-parser'; | ||
import React, { FC } from 'react'; | ||
|
||
import CodeLine from './CodeLine'; | ||
|
||
const Code: FC<{ value: ASTCode['value'] }> = ({ value = [] }) => ( | ||
<code className='code-colors hljs'> | ||
{value.map((block, index) => { | ||
switch (block.type) { | ||
case 'CODE_LINE': | ||
return <CodeLine key={index} value={block.value} />; | ||
default: | ||
return null; | ||
} | ||
})} | ||
</code> | ||
); | ||
|
||
export default Code; |
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,8 @@ | ||
import { CodeLine as ASTCodeLine } from '@rocket.chat/message-parser'; | ||
import React, { FC } from 'react'; | ||
|
||
const CodeLine: FC<{ value: ASTCodeLine['value'] }> = ({ value }) => ( | ||
<div>{value.type === 'PLAIN_TEXT' && value.value}</div> | ||
); | ||
|
||
export default CodeLine; |
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,17 @@ | ||
import { Bold as ASTHeading } from '@rocket.chat/message-parser'; | ||
import React, { FC } from 'react'; | ||
|
||
const Heading: FC<{ value: ASTHeading['value'] }> = ({ value = [] }) => ( | ||
<h1> | ||
{value.map((block) => { | ||
switch (block.type) { | ||
case 'PLAIN_TEXT': | ||
return block.value; | ||
default: | ||
return null; | ||
} | ||
})} | ||
</h1> | ||
); | ||
|
||
export default Heading; |
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,47 @@ | ||
import { Paragraph as ASTParagraph } from '@rocket.chat/message-parser'; | ||
import React, { FC } from 'react'; | ||
|
||
import Emoji from '../../Emoji'; | ||
import Bold from './Bold'; | ||
import InlineCode from './InlineCode'; | ||
import Italic from './Italic'; | ||
import Link from './Link'; | ||
import Mention from './Mention'; | ||
import Plain from './Plain'; | ||
import Strike from './Strike'; | ||
import { UserMention } from './definitions/UserMention'; | ||
|
||
const Inline: FC<{ value: ASTParagraph['value']; mentions?: UserMention[] }> = ({ | ||
value = [], | ||
mentions = [], | ||
}) => ( | ||
<> | ||
{value.map((block) => { | ||
switch (block.type) { | ||
case 'PLAIN_TEXT': | ||
return block.value; | ||
case 'BOLD': | ||
return <Bold value={block.value} />; | ||
case 'STRIKE': | ||
return <Strike value={block.value} />; | ||
case 'ITALIC': | ||
return <Italic value={block.value} />; | ||
case 'LINK': | ||
return <Link value={block.value} />; | ||
case 'MENTION_USER': | ||
return <Mention value={block.value} mentions={mentions} />; | ||
case 'EMOJI': | ||
return <Emoji emojiHandle={`:${block.value.value}:`} />; | ||
case 'MENTION_CHANNEL': | ||
// case 'COLOR': | ||
return <Plain value={block.value} />; | ||
case 'INLINE_CODE': | ||
return <InlineCode value={block.value} />; | ||
default: | ||
return null; | ||
} | ||
})} | ||
</> | ||
); | ||
|
||
export default Inline; |
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,17 @@ | ||
import { InlineCode as ASTInlineCode } from '@rocket.chat/message-parser'; | ||
import React, { FC } from 'react'; | ||
|
||
const InlineCode: FC<{ value: ASTInlineCode['value'] }> = ({ value }) => ( | ||
<code className='code-colors inline'> | ||
{((block): string | null => { | ||
switch (block.type) { | ||
case 'PLAIN_TEXT': | ||
return block.value; | ||
default: | ||
return null; | ||
} | ||
})(value)} | ||
</code> | ||
); | ||
|
||
export default InlineCode; |
Oops, something went wrong.