forked from RocketChat/Rocket.Chat.ReactNative
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPROVE] Add support to Linebreak and Katex on markdown (RocketChat#…
…4361) * fix enableMessageParser logic * create LineBreak component * fix code style * add KaTeX support * add Katex and Inline Katex stories * update snapshots * add color prop * update snapshot * update snapshot
- Loading branch information
Showing
15 changed files
with
248 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
import { CodeLine as CodeLineProps } from '@rocket.chat/message-parser'; | ||
import React from 'react'; | ||
import { Text } from 'react-native'; | ||
import { CodeLine as CodeLineProps } from '@rocket.chat/message-parser'; | ||
|
||
import { useTheme } from '../../../theme'; | ||
import styles from '../styles'; | ||
|
||
interface ICodeLineProps { | ||
value: CodeLineProps['value']; | ||
} | ||
|
||
const CodeLine = ({ value }: ICodeLineProps) => { | ||
const CodeLine = ({ value }: ICodeLineProps): React.ReactElement | null => { | ||
const { colors } = useTheme(); | ||
if (value.type !== 'PLAIN_TEXT') { | ||
return null; | ||
} | ||
|
||
return <Text>{value.value}</Text>; | ||
return <Text style={[styles.codeBlockText, { color: colors.bodyText }]}>{value.value}</Text>; | ||
}; | ||
|
||
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
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,20 @@ | ||
import React from 'react'; | ||
import { KaTeX as KaTeXProps } from '@rocket.chat/message-parser'; | ||
// eslint-disable-next-line import/no-unresolved | ||
import MathView, { MathText } from 'react-native-math-view'; | ||
|
||
import { useTheme } from '../../../theme'; | ||
|
||
interface IKaTeXProps { | ||
value: KaTeXProps['value']; | ||
} | ||
|
||
export const KaTeX = ({ value }: IKaTeXProps): React.ReactElement | null => { | ||
const { colors } = useTheme(); | ||
return <MathView math={value} style={{ color: colors.bodyText }} />; | ||
}; | ||
|
||
export const InlineKaTeX = ({ value }: IKaTeXProps): React.ReactElement | null => { | ||
const { colors } = useTheme(); | ||
return <MathText color value={`$$${value}$$`} direction='ltr' style={{ color: colors.bodyText }} />; | ||
}; |
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,6 @@ | ||
import React from 'react'; | ||
import { View } from 'react-native'; | ||
|
||
export default function LineBreak() { | ||
return <View style={{ height: 8 }} />; | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.