2020-03-04 13:57:07 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { ScrollView, StyleSheet, View } from 'react-native';
|
2022-08-19 19:53:40 +00:00
|
|
|
import { NavigationContainer } from '@react-navigation/native';
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
import Markdown, { MarkdownPreview } from '.';
|
|
|
|
import { themes } from '../../lib/constants';
|
2022-10-21 18:27:55 +00:00
|
|
|
import { TGetCustomEmoji, ICustomEmoji } from '../../definitions/IEmoji';
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
const theme = 'light';
|
|
|
|
|
2020-03-04 13:57:07 +00:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
2021-04-19 16:57:19 +00:00
|
|
|
marginHorizontal: 15,
|
|
|
|
backgroundColor: themes[theme].backgroundColor,
|
|
|
|
marginVertical: 50
|
2020-03-04 13:57:07 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
const longText =
|
|
|
|
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
|
2020-03-04 13:57:07 +00:00
|
|
|
const lineBreakText = `a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
|
|
|
d
|
|
|
|
|
|
|
|
|
|
|
|
e`;
|
2020-12-18 14:14:25 +00:00
|
|
|
const sequentialEmptySpacesText = 'a b c';
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-02-17 15:27:01 +00:00
|
|
|
const getCustomEmoji: TGetCustomEmoji = content => {
|
2020-03-04 13:57:07 +00:00
|
|
|
const customEmoji = {
|
|
|
|
marioparty: { name: content, extension: 'gif' },
|
|
|
|
react_rocket: { name: content, extension: 'png' },
|
|
|
|
nyan_rocket: { name: content, extension: 'png' }
|
2022-10-21 18:27:55 +00:00
|
|
|
}[content] as ICustomEmoji;
|
2020-03-04 13:57:07 +00:00
|
|
|
return customEmoji;
|
|
|
|
};
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export default {
|
|
|
|
title: 'Markdown',
|
|
|
|
decorators: [
|
|
|
|
(Story: any) => (
|
|
|
|
<NavigationContainer>
|
|
|
|
<Story />
|
|
|
|
</NavigationContainer>
|
|
|
|
)
|
|
|
|
]
|
|
|
|
};
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Text = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<View style={styles.container}>
|
2022-07-04 18:10:14 +00:00
|
|
|
<Markdown msg='This is Rocket.Chat' theme={theme} />
|
|
|
|
<Markdown msg={longText} theme={theme} />
|
|
|
|
<Markdown msg={lineBreakText} theme={theme} />
|
|
|
|
<Markdown msg={sequentialEmptySpacesText} theme={theme} />
|
|
|
|
<Markdown msg='Strong emphasis, aka bold, with **asterisks** or __underscores__' theme={theme} />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-12-18 14:14:25 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Preview = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<View style={styles.container}>
|
2022-02-17 15:27:01 +00:00
|
|
|
<MarkdownPreview msg={longText} />
|
|
|
|
<MarkdownPreview msg={lineBreakText} />
|
|
|
|
<MarkdownPreview msg={sequentialEmptySpacesText} />
|
|
|
|
<MarkdownPreview msg='@rocket.cat @name1 @all @here @unknown #general #unknown' />
|
|
|
|
<MarkdownPreview msg='Testing: 😃 :+1: :marioparty:' />
|
|
|
|
<MarkdownPreview msg='Fallback from new md to old' />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Mentions = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<ScrollView style={styles.container}>
|
|
|
|
<Markdown
|
|
|
|
msg='@rocket.cat @name1 @all @here @unknown'
|
2022-07-04 18:10:14 +00:00
|
|
|
theme={theme}
|
2021-04-19 16:57:19 +00:00
|
|
|
mentions={[
|
|
|
|
{ _id: 'random', name: 'Rocket Cat', username: 'rocket.cat' },
|
|
|
|
{ _id: 'random2', name: 'Name', username: 'name1' },
|
|
|
|
{ _id: 'here', username: 'here' },
|
|
|
|
{ _id: 'all', username: 'all' }
|
|
|
|
]}
|
|
|
|
username='rocket.cat'
|
|
|
|
/>
|
|
|
|
<Markdown
|
|
|
|
msg='@rocket.cat @name1 @all @here @unknown'
|
2022-07-04 18:10:14 +00:00
|
|
|
theme={theme}
|
2021-04-19 16:57:19 +00:00
|
|
|
mentions={[
|
|
|
|
{ _id: 'random', name: 'Rocket Cat', username: 'rocket.cat' },
|
|
|
|
{ _id: 'random2', name: 'Name', username: 'name1' },
|
|
|
|
{ _id: 'here', username: 'here' },
|
|
|
|
{ _id: 'all', username: 'all' }
|
|
|
|
]}
|
|
|
|
username='rocket.cat'
|
|
|
|
useRealName
|
|
|
|
/>
|
|
|
|
</ScrollView>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Hashtag = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<View style={styles.container}>
|
2022-07-04 18:10:14 +00:00
|
|
|
<Markdown msg='#test-channel #unknown' theme={theme} channels={[{ _id: '123', name: 'test-channel' }]} />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Emoji = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<View style={styles.container}>
|
2022-07-04 18:10:14 +00:00
|
|
|
<Markdown msg='Unicode: 😃😇👍' theme={theme} />
|
|
|
|
<Markdown msg='Shortnames: :joy::+1:' theme={theme} />
|
2022-10-21 18:27:55 +00:00
|
|
|
<Markdown msg='Custom emojis: :react_rocket: :nyan_rocket: :marioparty:' theme={theme} getCustomEmoji={getCustomEmoji} />
|
|
|
|
<Markdown msg='😃 :+1: :marioparty:' theme={theme} getCustomEmoji={getCustomEmoji} />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const BlockQuote = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<Markdown
|
|
|
|
msg={`> This is block quote
|
2020-03-04 13:57:07 +00:00
|
|
|
this is a normal line`}
|
2022-07-04 18:10:14 +00:00
|
|
|
theme={theme}
|
2021-04-19 16:57:19 +00:00
|
|
|
/>
|
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Links = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<View style={styles.container}>
|
2022-07-04 18:10:14 +00:00
|
|
|
<Markdown msg='[Markdown link](https://rocket.chat): `[description](url)`' theme={theme} />
|
|
|
|
<Markdown msg='<https://rocket.chat|Formatted Link>: `<url|description>`' theme={theme} />
|
2023-03-16 14:12:46 +00:00
|
|
|
<Markdown msg='[Markdown link](https://rocket.chat) and the text with default style' theme={theme} />
|
|
|
|
<Markdown
|
|
|
|
msg='[Markdown link](https://rocket.chat) and the text with a color specific as auxiliaryText'
|
|
|
|
theme={theme}
|
|
|
|
style={[{ color: themes[theme].auxiliaryText }]}
|
|
|
|
/>
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Image = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<View style={styles.container}>
|
2022-07-04 18:10:14 +00:00
|
|
|
<Markdown msg='![alt text](https://play.google.com/intl/en_us/badges/images/badge_new.png)' theme={theme} />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Headers = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<View style={styles.container}>
|
2022-07-04 18:10:14 +00:00
|
|
|
<Markdown msg='# Header 1' theme={theme} />
|
|
|
|
<Markdown msg='## Header 2' theme={theme} />
|
|
|
|
<Markdown msg='### Header 3' theme={theme} />
|
|
|
|
<Markdown msg='#### Header 4' theme={theme} />
|
|
|
|
<Markdown msg='##### Header 5' theme={theme} />
|
|
|
|
<Markdown msg='###### Header 6' theme={theme} />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Code = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<View style={styles.container}>
|
2022-07-04 18:10:14 +00:00
|
|
|
<Markdown msg='This is `inline code`' theme={theme} />
|
2021-04-19 16:57:19 +00:00
|
|
|
<Markdown
|
|
|
|
msg='Inline `code` has `back-ticks around` it.
|
2020-03-04 13:57:07 +00:00
|
|
|
```
|
|
|
|
Code block
|
|
|
|
```'
|
2022-07-04 18:10:14 +00:00
|
|
|
theme={theme}
|
2021-04-19 16:57:19 +00:00
|
|
|
/>
|
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Lists = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<View style={styles.container}>
|
2022-07-04 18:10:14 +00:00
|
|
|
<Markdown msg={'* Open Source\n* Rocket.Chat\n - nodejs\n - ReactNative'} theme={theme} />
|
|
|
|
<Markdown msg={'1. Open Source\n2. Rocket.Chat'} theme={theme} />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Table = () => (
|
2021-04-19 16:57:19 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<Markdown
|
|
|
|
msg='First Header | Second Header
|
2020-03-04 13:57:07 +00:00
|
|
|
------------ | -------------
|
|
|
|
Content from cell 1 | Content from cell 2
|
|
|
|
Content in the first column | Content in the second column'
|
2022-07-04 18:10:14 +00:00
|
|
|
theme={theme}
|
2021-04-19 16:57:19 +00:00
|
|
|
/>
|
|
|
|
</View>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|