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 {
View, TextInput, KeyboardAvoidingView, ScrollView, FlatList,
View, TextInput, KeyboardAvoidingView, ScrollView, FlatList, Text,
} from 'react-native';
import Markdown from 'react-native-markdown-renderer';
import Markdown, { getUniqueID } from 'react-native-markdown-renderer';
// Components
import Formats from './formats/formats';
@ -63,11 +63,25 @@ export default class MarkdownEditorView extends Component {
_renderPreview = () => {
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 (
<View style={styles.textWrapper}>
<ScrollView removeClippedSubviews>
<Markdown style={markdownStyle}>{text === '' ? '...' : text}</Markdown>
<Markdown rules={rules} style={markdownStyle}>
{text === '' ? '...' : text}
</Markdown>
</ScrollView>
</View>
);

View File

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

View File

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