Skip to content

Commit e047c8c

Browse files
committed
fixed issue mientjan#24
1 parent e51ef8c commit e047c8c

File tree

8 files changed

+165
-160
lines changed

8 files changed

+165
-160
lines changed

example/App.js

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import React, { Component } from 'react';
7-
import {Platform, Picker, ScrollView, StyleSheet, Text, View, Alert} from "react-native";
7+
import { Platform, Picker, ScrollView, StyleSheet, Text, View, Alert } from 'react-native';
88

99
import Markdown, {
1010
AstRenderer,
@@ -26,38 +26,38 @@ const instructions = Platform.select({
2626
});
2727

2828
const rules = {
29-
// added custom block element defined by plugin
30-
block: (node, children, parents, style) => {
31-
return (
32-
<Text key={getUniqueID()} style={{ backgroundColor: "green" }}>
33-
{children}
34-
</Text>
35-
);
36-
},
29+
// added custom block element defined by plugin
30+
block: (node, children, parents, style) => {
31+
return (
32+
<Text key={getUniqueID()} style={{ backgroundColor: 'green' }}>
33+
{children}
34+
</Text>
35+
);
36+
},
3737

38-
checkbox: (node, children, parents, style) => {
39-
return (
40-
<Text key={getUniqueID()} style={{ backgroundColor: "green" }}>
41-
{children}
42-
</Text>
43-
);
44-
}
38+
checkbox: (node, children, parents, style) => {
39+
return (
40+
<Text key={getUniqueID()} style={{ backgroundColor: 'green' }}>
41+
{children}
42+
</Text>
43+
);
44+
},
4545
};
4646

4747
/**
4848
* i'm overriding the default h1 render function.
4949
*/
5050
const renderer = new AstRenderer(
51-
{
52-
...renderRules,
53-
...rules
54-
},
55-
styles
51+
{
52+
...renderRules,
53+
...rules,
54+
},
55+
styles
5656
);
5757

5858
export default class App extends Component {
5959
state = {
60-
view: 5,
60+
view: 0,
6161
};
6262

6363
list = [
@@ -103,19 +103,20 @@ export default class App extends Component {
103103
}
104104
}
105105

106+
handleChangeValue = (itemValue, itemIndex) => {
107+
this.setState({ view: itemIndex });
108+
};
109+
106110
render() {
107-
console.log(this.state.view);
111+
let currentView = this.state.view;
108112

109113
return (
110114
<View style={styleSheet.container}>
111-
<Picker
112-
selectedValue={this.state.view}
113-
onValueChange={(itemValue, itemIndex) => this.setState({ view: itemIndex })}
114-
>
115+
<Text>{currentView}</Text>
116+
<Picker selectedValue={currentView} onValueChange={this.handleChangeValue}>
115117
{this.list.map((val, index) => <Picker.Item key={val.description} label={val.description} value={index} />)}
116118
</Picker>
117-
118-
<ScrollView>{this.getView(this.state.view)}</ScrollView>
119+
<ScrollView>{this.getView(currentView)}</ScrollView>
119120
</View>
120121
);
121122
}

example/react-native-markdown-renderer/lib/parser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function parser(source, renderer, markdownIt) {
2121
tokens = groupTextTokens(tokens);
2222

2323
const astTree = tokensToAST(tokens);
24+
console.log(astTree);
2425

2526
return renderer(astTree);
2627
}

example/react-native-markdown-renderer/lib/renderRules.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,9 @@ const renderRules = {
6060
},
6161
// a with a non text element nested inside
6262
blocklink: (node, children, parent, styles) => {
63-
64-
console.log(children);
6563
return (
6664
<TouchableWithoutFeedback key={node.key} onPress={() => openUrl(node.attributes.href)} style={styles.blocklink}>
67-
<View>
68-
<Text>Test</Text>
69-
</View>
65+
<View style={styles.image}>{children}</View>
7066
</TouchableWithoutFeedback>
7167
);
7268
},
Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Platform, StyleSheet } from "react-native";
2-
import PlatformEnum from "./enum/PlatformEnum";
1+
import { Platform, StyleSheet } from 'react-native';
2+
import PlatformEnum from './enum/PlatformEnum';
33

44
/**
55
*
@@ -8,164 +8,166 @@ export const styles = StyleSheet.create({
88
view: {},
99
codeBlock: {
1010
borderWidth: 1,
11-
borderColor: "#CCCCCC",
12-
backgroundColor: "#f5f5f5",
11+
borderColor: '#CCCCCC',
12+
backgroundColor: '#f5f5f5',
1313
padding: 10,
14-
borderRadius: 4
14+
borderRadius: 4,
1515
},
1616
codeInline: {
1717
borderWidth: 1,
18-
borderColor: "#CCCCCC",
19-
backgroundColor: "#f5f5f5",
18+
borderColor: '#CCCCCC',
19+
backgroundColor: '#f5f5f5',
2020
padding: 10,
21-
borderRadius: 4
21+
borderRadius: 4,
2222
},
2323
del: {
24-
backgroundColor: "#000000"
24+
backgroundColor: '#000000',
2525
},
2626
em: {
27-
fontStyle: "italic"
27+
fontStyle: 'italic',
2828
},
2929
headingContainer: {
30-
flexDirection: "row"
30+
flexDirection: 'row',
3131
},
3232
heading: {},
3333
heading1: {
34-
fontSize: 32
34+
fontSize: 32,
3535
},
3636
heading2: {
37-
fontSize: 24
37+
fontSize: 24,
3838
},
3939
heading3: {
40-
fontSize: 18
40+
fontSize: 18,
4141
},
4242
heading4: {
43-
fontSize: 16
43+
fontSize: 16,
4444
},
4545
heading5: {
46-
fontSize: 13
46+
fontSize: 13,
4747
},
4848
heading6: {
49-
fontSize: 11
49+
fontSize: 11,
5050
},
5151
hr: {
52-
backgroundColor: "#000000",
53-
height: 1
52+
backgroundColor: '#000000',
53+
height: 1,
5454
},
5555
blockquote: {
5656
paddingHorizontal: 20,
5757
paddingVertical: 10,
5858
margin: 20,
59-
backgroundColor: "#CCCCCC"
59+
backgroundColor: '#CCCCCC',
6060
},
6161
inlineCode: {
6262
borderRadius: 3,
6363
borderWidth: 1,
64-
fontFamily: "Courier",
65-
fontWeight: "bold"
64+
fontFamily: 'Courier',
65+
fontWeight: 'bold',
6666
},
6767
list: {},
6868
listItem: {
69-
flex: 1,
70-
flexWrap: "wrap"
69+
flex: 1,
70+
flexWrap: 'wrap',
7171
// backgroundColor: 'green',
7272
},
7373
listUnordered: {},
7474

7575
listUnorderedItem: {
76-
flexDirection: "row",
77-
justifyContent: "flex-start"
76+
flexDirection: 'row',
77+
justifyContent: 'flex-start',
7878
},
7979

8080
listUnorderedItemIcon: {
8181
marginLeft: 10,
8282
marginRight: 10,
8383
...Platform.select({
8484
[PlatformEnum.IOS]: {
85-
lineHeight: 36
85+
lineHeight: 36,
8686
},
8787
[PlatformEnum.ANDROID]: {
88-
lineHeight: 30
89-
}
90-
})
88+
lineHeight: 30,
89+
},
90+
}),
9191
},
9292
listUnorderedItemText: {
9393
fontSize: 20,
94-
lineHeight: 20
94+
lineHeight: 20,
9595
},
9696

9797
listOrdered: {},
9898
listOrderedItem: {
99-
flexDirection: "row"
99+
flexDirection: 'row',
100100
},
101101
listOrderedItemIcon: {
102102
marginLeft: 10,
103103
marginRight: 10,
104104
...Platform.select({
105105
[PlatformEnum.IOS]: {
106-
lineHeight: 36
106+
lineHeight: 36,
107107
},
108108
[PlatformEnum.ANDROID]: {
109-
lineHeight: 30
110-
}
111-
})
109+
lineHeight: 30,
110+
},
111+
}),
112112
},
113113
listOrderedItemText: {
114-
fontWeight: "bold",
115-
lineHeight: 20
114+
fontWeight: 'bold',
115+
lineHeight: 20,
116116
},
117117
paragraph: {
118118
marginTop: 10,
119119
marginBottom: 10,
120-
flexWrap: "wrap",
121-
flexDirection: "row",
122-
alignItems: "flex-start",
123-
justifyContent: "flex-start"
120+
flexWrap: 'wrap',
121+
flexDirection: 'row',
122+
alignItems: 'flex-start',
123+
justifyContent: 'flex-start',
124124
},
125125
hardbreak: {
126126
width: '100%',
127-
height: 1
127+
height: 1,
128128
},
129129
strong: {
130-
fontWeight: "bold"
130+
fontWeight: 'bold',
131131
},
132132
table: {
133133
borderWidth: 1,
134-
borderColor: "#000000",
135-
borderRadius: 3
134+
borderColor: '#000000',
135+
borderRadius: 3,
136136
},
137137
tableHeader: {},
138138
tableHeaderCell: {
139139
flex: 1,
140140
// color: '#000000',
141-
padding: 5
141+
padding: 5,
142142
// backgroundColor: 'green',
143143
},
144144
tableRow: {
145145
borderBottomWidth: 1,
146-
borderColor: "#000000",
147-
flexDirection: "row"
146+
borderColor: '#000000',
147+
flexDirection: 'row',
148148
},
149149
tableRowCell: {
150150
flex: 1,
151-
padding: 5
151+
padding: 5,
152152
},
153153
text: {},
154154
strikethrough: {
155-
textDecorationLine: "line-through"
155+
textDecorationLine: 'line-through',
156156
},
157157
link: {
158-
textDecorationLine: "underline"
158+
textDecorationLine: 'underline',
159159
},
160160
blocklink: {
161-
borderColor: "#000000",
162-
borderBottomWidth: 1
161+
flex: 1,
162+
borderColor: '#000000',
163+
borderBottomWidth: 1,
164+
163165
},
164166
u: {
165-
borderColor: "#000000",
166-
borderBottomWidth: 1
167+
borderColor: '#000000',
168+
borderBottomWidth: 1,
167169
},
168170
image: {
169-
flex: 1
170-
}
171+
flex: 1,
172+
},
171173
});

example/src/copyAll.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
const markdownText = `
2+
[![Minion](https://octodex.github.com/images/minion.png)](https://google.com)
3+
![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg)
4+
5+
`;
6+
const markdownText2 = `
27
# Syntax Support
38
49
__Advertisement :)__

example/src/copyAllCheckboxPlugin.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
const markdownText = `
22
3+
4+
## Images
5+
6+
![Minion](https://octodex.github.com/images/minion.png)
7+
![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg)
8+
9+
310
+ Selected third parties include:
411
- Service providers assigned to carrying out your service contract when placing a booking on the company. Ac tristique libero volutpat at Ac tristique libero volutpat at Ac tristique libero volutpat at Ac tristique libero volutpat at Ac tristique libero volutpat at
512
- Service providers assigned to carrying out your service contract when placing a booking on the company. Ac tristique libero volutpat at Ac tristique libero volutpat at Ac tristique libero volutpat at Ac tristique libero volutpat at Ac tristique libero volutpat at
@@ -12,11 +19,6 @@ const markdownText = `
1219
- Nulla volutpat aliquam velit
1320
+ Very easy!
1421
15-
## ![loading](https://www.hippomundo.com/images/loading.gif) Images
16-
17-
![Minion](https://octodex.github.com/images/minion.png)
18-
![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg "The Stormtroopocat")
19-
2022
# Syntax __Support__
2123
2224
__Advertisement :)__

0 commit comments

Comments
 (0)