2021-10-20 16:32:58 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { StyleSheet, View } from 'react-native';
|
2022-08-19 19:53:40 +00:00
|
|
|
import { NavigationContainer } from '@react-navigation/native';
|
|
|
|
|
|
|
|
import NewMarkdownComponent from '.';
|
2022-11-07 16:42:42 +00:00
|
|
|
import { colors, themes } from '../../../lib/constants';
|
2022-08-19 19:53:40 +00:00
|
|
|
import { longText } from '../../../../.storybook/utils';
|
2022-11-07 16:42:42 +00:00
|
|
|
import { ThemeContext } from '../../../theme';
|
|
|
|
|
|
|
|
const theme = 'light';
|
2022-08-19 19:53:40 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'NewMarkdown',
|
|
|
|
decorators: [
|
|
|
|
(Story: any) => (
|
|
|
|
<NavigationContainer>
|
2022-11-07 16:42:42 +00:00
|
|
|
<ThemeContext.Provider value={{ theme, colors: colors[theme] }}>
|
|
|
|
<Story />
|
|
|
|
</ThemeContext.Provider>
|
2022-08-19 19:53:40 +00:00
|
|
|
</NavigationContainer>
|
|
|
|
)
|
|
|
|
]
|
|
|
|
};
|
2021-10-20 16:32:58 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
marginHorizontal: 15,
|
|
|
|
backgroundColor: themes[theme].backgroundColor,
|
|
|
|
marginVertical: 50
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
const getCustomEmoji = (content: string) => {
|
2021-10-20 16:32:58 +00:00
|
|
|
const customEmoji = {
|
|
|
|
marioparty: { name: content, extension: 'gif' },
|
|
|
|
nyan_rocket: { name: content, extension: 'png' }
|
|
|
|
}[content];
|
|
|
|
return customEmoji;
|
|
|
|
};
|
|
|
|
|
2022-10-21 18:27:55 +00:00
|
|
|
const NewMarkdown = ({ ...props }) => <NewMarkdownComponent getCustomEmoji={getCustomEmoji} username='rocket.cat' {...props} />;
|
2022-08-19 19:53:40 +00:00
|
|
|
|
2021-10-20 16:32:58 +00:00
|
|
|
const simpleTextMsg = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'This is Rocket.Chat'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const longTextMsg = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
2021-10-27 13:13:20 +00:00
|
|
|
value: longText
|
2021-10-20 16:32:58 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const lineBreakMsg = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'a'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'b'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'c'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'd'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'e'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const sequentialEmptySpacesMsg = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'a b c'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Text = () => (
|
2021-10-20 16:32:58 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<NewMarkdown tokens={simpleTextMsg} />
|
|
|
|
<NewMarkdown tokens={longTextMsg} />
|
|
|
|
<NewMarkdown tokens={lineBreakMsg} />
|
|
|
|
<NewMarkdown tokens={sequentialEmptySpacesMsg} />
|
2021-10-27 13:13:20 +00:00
|
|
|
<NewMarkdown tokens={[...simpleTextMsg, ...longTextMsg]} />
|
2021-10-20 16:32:58 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2021-10-20 16:32:58 +00:00
|
|
|
|
|
|
|
const allMentionTokens = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'MENTION_USER',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'rocket.cat'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const multipleMentionTokens = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'MENTION_USER',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'name'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' '
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'MENTION_USER',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'rocket.cat'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' '
|
|
|
|
},
|
2022-08-19 19:53:40 +00:00
|
|
|
{
|
|
|
|
type: 'MENTION_USER',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'not_a_user'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' '
|
|
|
|
},
|
2021-10-20 16:32:58 +00:00
|
|
|
{
|
|
|
|
type: 'MENTION_USER',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'here'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' '
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'MENTION_USER',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'all'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const allMentions = [
|
|
|
|
{
|
|
|
|
_id: 'rocket.cat',
|
|
|
|
username: 'rocket.cat'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const multipleMentions = [
|
|
|
|
{
|
|
|
|
_id: 'name',
|
|
|
|
username: 'name'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
_id: 'rocket.cat',
|
|
|
|
username: 'rocket.cat'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
_id: 'here',
|
|
|
|
username: 'here'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
_id: 'all',
|
|
|
|
username: 'all'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Mentions = () => (
|
2021-10-20 16:32:58 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<NewMarkdown tokens={allMentionTokens} mentions={allMentions} navToRoomInfo={() => {}} style={[]} />
|
2022-08-19 19:53:40 +00:00
|
|
|
<NewMarkdown tokens={multipleMentionTokens} mentions={multipleMentions} navToRoomInfo={() => {}} style={[]} />
|
2021-10-20 16:32:58 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2021-10-20 16:32:58 +00:00
|
|
|
|
|
|
|
const channelTokens = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'MENTION_CHANNEL',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'text_channel'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' and '
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'MENTION_CHANNEL',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'not_a_channel'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const channelMention = [
|
|
|
|
{
|
|
|
|
_id: 'text_channel',
|
|
|
|
name: 'text_channel'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Hashtag = () => (
|
2021-10-20 16:32:58 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<NewMarkdown tokens={channelTokens} channels={channelMention} navToRoomInfo={() => {}} />
|
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2021-10-20 16:32:58 +00:00
|
|
|
|
|
|
|
const bigEmojiTokens = [
|
|
|
|
{
|
|
|
|
type: 'BIG_EMOJI',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'EMOJI',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'green_heart'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'EMOJI',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'joy'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'EMOJI',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'grin'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const emojiTokens = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'EMOJI',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'rocket'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'EMOJI',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'facepalm'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'EMOJI',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'nyan_rocket'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'EMOJI',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'marioparty'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Emoji = () => (
|
2021-10-20 16:32:58 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<NewMarkdown tokens={bigEmojiTokens} />
|
2022-10-21 18:27:55 +00:00
|
|
|
<NewMarkdown tokens={emojiTokens} getCustomEmoji={getCustomEmoji} />
|
2021-10-20 16:32:58 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2021-10-20 16:32:58 +00:00
|
|
|
|
|
|
|
const blockQuoteTokens = [
|
|
|
|
{
|
|
|
|
type: 'QUOTE',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'Rocket.Chat to the moon'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2021-10-27 13:13:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'QUOTE',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: longText
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2021-10-20 16:32:58 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const BlockQuote = () => (
|
2021-10-20 16:32:58 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<NewMarkdown tokens={blockQuoteTokens} />
|
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2021-10-20 16:32:58 +00:00
|
|
|
|
|
|
|
const markdownLink = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'LINK',
|
|
|
|
value: {
|
|
|
|
src: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'https://rocket.chat'
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'Markdown link'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2022-11-07 16:42:42 +00:00
|
|
|
const markdownLinkWithEmphasis = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'LINK',
|
|
|
|
value: {
|
|
|
|
src: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'https://rocket.chat/'
|
|
|
|
},
|
|
|
|
label: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'Normal Link - '
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'BOLD',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'Bold'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' '
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'STRIKE',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'strike'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' and '
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'ITALIC',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'Italic'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' Styles'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Links = () => (
|
2021-10-20 16:32:58 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<NewMarkdown tokens={markdownLink} />
|
2022-11-07 16:42:42 +00:00
|
|
|
<NewMarkdown tokens={markdownLinkWithEmphasis} />
|
2021-10-20 16:32:58 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2021-10-20 16:32:58 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Headers = () => (
|
2021-10-20 16:32:58 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<NewMarkdown
|
|
|
|
tokens={[
|
|
|
|
{
|
|
|
|
type: 'HEADING',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: '# Header 1'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
level: 1
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
<NewMarkdown
|
|
|
|
tokens={[
|
|
|
|
{
|
|
|
|
type: 'HEADING',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: '## Header 2'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
level: 2
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
<NewMarkdown
|
|
|
|
tokens={[
|
|
|
|
{
|
|
|
|
type: 'HEADING',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: '### Header 3'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
level: 3
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
<NewMarkdown
|
|
|
|
tokens={[
|
|
|
|
{
|
|
|
|
type: 'HEADING',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: '#### Header 4'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
level: 4
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
<NewMarkdown
|
|
|
|
tokens={[
|
|
|
|
{
|
|
|
|
type: 'HEADING',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: '##### Header 5'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
level: 5
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
<NewMarkdown
|
|
|
|
tokens={[
|
|
|
|
{
|
|
|
|
type: 'HEADING',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: '###### Header 6'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
level: 6
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2021-10-20 16:32:58 +00:00
|
|
|
|
|
|
|
const inlineCodeToken = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'INLINE_CODE',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'inline code'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const multilineCodeToken = [
|
|
|
|
{
|
|
|
|
type: 'CODE',
|
|
|
|
language: 'none',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'CODE_LINE',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
2021-10-27 13:13:20 +00:00
|
|
|
value: 'Multi \nLine \nCode'
|
2021-10-20 16:32:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Code = () => (
|
2021-10-20 16:32:58 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<NewMarkdown tokens={inlineCodeToken} style={[]} />
|
|
|
|
<NewMarkdown tokens={multilineCodeToken} style={[]} />
|
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2021-10-20 16:32:58 +00:00
|
|
|
|
2021-10-27 13:13:20 +00:00
|
|
|
const items = [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'Plain text '
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'EMOJI',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'bulb'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'ITALIC',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' italic '
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'BOLD',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' bold '
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'STRIKE',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' strike '
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'MENTION_CHANNEL',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'general'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'LINK',
|
|
|
|
value: {
|
|
|
|
src: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'https://google.com'
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' link '
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'MENTION_USER',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'rocket.cat'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'INLINE_CODE',
|
|
|
|
value: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' inline code'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: longText
|
|
|
|
}
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
const listItems = [
|
|
|
|
{
|
|
|
|
type: 'LIST_ITEM',
|
|
|
|
value: items[0]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'LIST_ITEM',
|
|
|
|
value: items[1]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2021-10-20 16:32:58 +00:00
|
|
|
const unorederedListToken = [
|
|
|
|
{
|
|
|
|
type: 'UNORDERED_LIST',
|
2021-10-27 13:13:20 +00:00
|
|
|
value: listItems
|
2021-10-20 16:32:58 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const orderedListToken = [
|
|
|
|
{
|
|
|
|
type: 'ORDERED_LIST',
|
2021-10-27 13:13:20 +00:00
|
|
|
value: listItems
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const listMentions = [
|
|
|
|
{
|
|
|
|
_id: 'rocket.cat',
|
|
|
|
username: 'rocket.cat'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const listChannels = [
|
|
|
|
{
|
|
|
|
_id: 'general',
|
|
|
|
name: 'general'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const tasks = [
|
|
|
|
{
|
|
|
|
type: 'TASKS',
|
2021-10-20 16:32:58 +00:00
|
|
|
value: [
|
|
|
|
{
|
2021-10-27 13:13:20 +00:00
|
|
|
type: 'TASK',
|
|
|
|
status: true,
|
|
|
|
value: items[0]
|
2021-10-20 16:32:58 +00:00
|
|
|
},
|
|
|
|
{
|
2021-10-27 13:13:20 +00:00
|
|
|
type: 'TASK',
|
|
|
|
status: false,
|
|
|
|
value: items[1]
|
2021-10-20 16:32:58 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Lists = () => (
|
2021-10-20 16:32:58 +00:00
|
|
|
<View style={styles.container}>
|
2021-10-27 13:13:20 +00:00
|
|
|
<NewMarkdown tokens={unorederedListToken} mentions={listMentions} channels={listChannels} />
|
|
|
|
<NewMarkdown tokens={orderedListToken} mentions={listMentions} channels={listChannels} />
|
|
|
|
<NewMarkdown tokens={tasks} mentions={listMentions} channels={listChannels} />
|
2021-10-20 16:32:58 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2022-07-20 21:02:18 +00:00
|
|
|
|
|
|
|
const katex = [
|
|
|
|
{
|
|
|
|
type: 'KATEX',
|
|
|
|
value: ' f(x) = \\int_{-\\infty}^\\infty \\hat f(\\xi)\\,e^{2 \\pi i \\xi x} \\,d\\xi '
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const inlineKatex = [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'INLINE_KATEX',
|
|
|
|
value: 'This text includes math notations and should be wrapped correctly for $\\alpha$ and $\\beta$ within the view.'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'INLINE_KATEX',
|
|
|
|
value: "The following formula shouldn't be inline:$$x_{1,2} = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}$$"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'INLINE_KATEX',
|
|
|
|
value: 'However the following formula should be inline with the text: \\( a^2 + b^2 = c^2 \\)'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Katex = () => (
|
2022-07-20 21:02:18 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<NewMarkdown tokens={katex} />
|
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2022-07-20 21:02:18 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const InlineKatex = () => (
|
2022-07-20 21:02:18 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<NewMarkdown tokens={inlineKatex} />
|
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2023-02-02 03:17:09 +00:00
|
|
|
|
|
|
|
const messageQuote = {
|
|
|
|
/**
|
|
|
|
# Hello head 1
|
|
|
|
[ ](https://google.com)
|
|
|
|
*/
|
|
|
|
headAndLink: [
|
|
|
|
{ type: 'HEADING', level: 1, value: [{ type: 'PLAIN_TEXT', value: 'Hello head 1' }] },
|
|
|
|
{ type: 'LINE_BREAK' },
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'LINK',
|
|
|
|
value: { src: { type: 'PLAIN_TEXT', value: 'https://google.com' }, label: { type: 'PLAIN_TEXT', value: ' ' } }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
/**
|
|
|
|
# Head 1 as the first line then line break and after paragraph
|
|
|
|
bla bla bla bla bla bla
|
|
|
|
bla bla bla bla bla bla
|
|
|
|
[ ](https://google.com)
|
|
|
|
*/
|
|
|
|
headTextAndLink: [
|
|
|
|
{
|
|
|
|
type: 'HEADING',
|
|
|
|
level: 1,
|
|
|
|
value: [{ type: 'PLAIN_TEXT', value: 'Head 1 as the first line then line break and after paragraph' }]
|
|
|
|
},
|
|
|
|
{ type: 'LINE_BREAK' },
|
|
|
|
{ type: 'PARAGRAPH', value: [{ type: 'PLAIN_TEXT', value: 'bla bla bla bla bla bla ' }] },
|
|
|
|
{ type: 'PARAGRAPH', value: [{ type: 'PLAIN_TEXT', value: 'bla bla bla bla bla bla ' }] },
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'LINK',
|
|
|
|
value: { src: { type: 'PLAIN_TEXT', value: 'https://google.com' }, label: { type: 'PLAIN_TEXT', value: ' ' } }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
/**
|
|
|
|
[ ](permalink from message)\n# Head 1 after a forced line break
|
|
|
|
asdas asd asd asd
|
|
|
|
*/
|
|
|
|
headTextAndQuote: [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'LINK',
|
|
|
|
value: {
|
|
|
|
src: { type: 'PLAIN_TEXT', value: 'https://open.rocket.chat/direct/subaru123?msg=QB42gWcaO6BgqtLTo' },
|
|
|
|
label: { type: 'PLAIN_TEXT', value: ' ' }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ type: 'PLAIN_TEXT', value: ' ' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{ type: 'HEADING', level: 1, value: [{ type: 'PLAIN_TEXT', value: 'Head 1 after a forced line break' }] },
|
|
|
|
{ type: 'LINE_BREAK' },
|
|
|
|
{ type: 'PARAGRAPH', value: [{ type: 'PLAIN_TEXT', value: 'Description' }] }
|
|
|
|
],
|
|
|
|
/**
|
|
|
|
[ ](https://google.com) *There is a link before this bold separated by single space*
|
|
|
|
*/
|
|
|
|
linkAndBoldText: [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'LINK',
|
|
|
|
value: { src: { type: 'PLAIN_TEXT', value: 'https://google.com' }, label: { type: 'PLAIN_TEXT', value: ' ' } }
|
|
|
|
},
|
|
|
|
{ type: 'PLAIN_TEXT', value: ' ' },
|
|
|
|
{ type: 'BOLD', value: [{ type: 'PLAIN_TEXT', value: 'There is a link before this bold separated by single space' }] }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
simpleQuote: [
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'LINK',
|
|
|
|
value: {
|
|
|
|
src: {
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'https://open.rocket.chat/group/quoteeee9798789?msg=ZZp6t2dCRX4TqExht'
|
|
|
|
},
|
|
|
|
// format of label for servers greater or equal than 6.0
|
|
|
|
label: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: ' '
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'PARAGRAPH',
|
|
|
|
value: [
|
|
|
|
{
|
|
|
|
type: 'PLAIN_TEXT',
|
|
|
|
value: 'Quoting a message wrote before'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
export const MessageQuote = () => (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<NewMarkdown tokens={messageQuote.headAndLink} />
|
|
|
|
<NewMarkdown tokens={messageQuote.headTextAndLink} />
|
|
|
|
<NewMarkdown tokens={messageQuote.headTextAndQuote} />
|
|
|
|
<NewMarkdown tokens={messageQuote.linkAndBoldText} />
|
|
|
|
<NewMarkdown tokens={messageQuote.simpleQuote} />
|
|
|
|
</View>
|
|
|
|
);
|