added rules for markdwon

This commit is contained in:
ue 2018-11-14 12:35:36 +01:00
parent dad00cc7bc
commit 130c9c2eed
3 changed files with 28 additions and 10 deletions

View File

@ -1,8 +1,8 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { import {
View, TextInput, KeyboardAvoidingView, ScrollView, FlatList, View, TextInput, KeyboardAvoidingView, ScrollView, FlatList, Text,
} from 'react-native'; } from 'react-native';
import Markdown from 'react-native-markdown-renderer'; import Markdown, { getUniqueID } from 'react-native-markdown-renderer';
// Components // Components
import Formats from './formats/formats'; import Formats from './formats/formats';
@ -63,11 +63,25 @@ export default class MarkdownEditorView extends Component {
_renderPreview = () => { _renderPreview = () => {
const { text } = this.state; const { text } = this.state;
const rules = {
heading1: (node, children, parent, styles) => (
<Text key={getUniqueID()} style={styles.heading1}>
{children}
</Text>
),
heading2: (node, children, parent, styles) => (
<Text key={getUniqueID()} style={styles.heading2}>
{children}
</Text>
),
};
return ( return (
<View style={styles.textWrapper}> <View style={styles.textWrapper}>
<ScrollView removeClippedSubviews> <ScrollView removeClippedSubviews>
<Markdown style={markdownStyle}>{text === '' ? '...' : text}</Markdown> <Markdown rules={rules} style={markdownStyle}>
{text === '' ? '...' : text}
</Markdown>
</ScrollView> </ScrollView>
</View> </View>
); );

View File

@ -6,7 +6,7 @@ export default EStyleSheet.create({
fontFamily: 'Courier', fontFamily: 'Courier',
fontWeight: '500', fontWeight: '500',
marginLeft: 20, marginLeft: 20,
color: '#788187', color: '$primaryDarkGray',
}, },
del: { del: {
backgroundColor: '#000000', backgroundColor: '#000000',
@ -14,18 +14,22 @@ export default EStyleSheet.create({
em: { em: {
fontStyle: 'italic', fontStyle: 'italic',
}, },
strong: {
fontWeight: 'bold',
},
text: { text: {
fontSize: 10,
color: '#3c4449', color: '#3c4449',
}, },
heading: { heading1: {
fontSize: 32, fontSize: 32,
color: 'purple', color: '$primaryBlack',
},
heading2: {
fontSize: 24,
color: '$primaryBlack',
}, },
strikethrough: { strikethrough: {
textDecorationLine: 'line-through', textDecorationLine: 'line-through',
color: '#FF0000',
}, },
link: { link: {
textDecorationLine: 'underline', textDecorationLine: 'underline',

View File

@ -77,6 +77,6 @@ export default createSwitchNavigator({
stackNavigatior, stackNavigatior,
[ROUTES.SCREENS.LOGIN]: { screen: RootComponent()(Login) }, [ROUTES.SCREENS.LOGIN]: { screen: RootComponent()(Login) },
[ROUTES.SCREENS.PINCODE]: { screen: RootComponent()(PinCode) }, [ROUTES.SCREENS.PINCODE]: { screen: RootComponent()(PinCode) },
[ROUTES.SCREENS.SPLASH]: { screen: Splash }, [ROUTES.SCREENS.SPLASH]: { screen: Editor },
[ROUTES.SCREENS.STEEM_CONNECT]: { screen: RootComponent()(SteemConnect) }, [ROUTES.SCREENS.STEEM_CONNECT]: { screen: RootComponent()(SteemConnect) },
}); });