Skip to content

Commit f6da29f

Browse files
committed
Replace react-native-markdown-renderer with more supported react-native-markdown-display
Discovered here: mientjan/react-native-markdown-renderer#156
1 parent caae2cd commit f6da29f

File tree

3 files changed

+46
-64
lines changed

3 files changed

+46
-64
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"postinstall-postinstall": "^2.1.0",
2020
"react": "18.2.0",
2121
"react-native": "0.71.0",
22-
"react-native-markdown-renderer": "^3.2.8",
22+
"react-native-markdown-display": "^7.0.0-alpha.2",
2323
"react-native-syntax-highlighter": "^2.1.0",
2424
"react-native-windows": "0.71.1"
2525
},

src/AiResponse.tsx

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
import { StylesContext } from './Styles';
2323
import { FeedbackContext } from './Feedback';
2424
import Clipboard from '@react-native-clipboard/clipboard';
25-
import Markdown from 'react-native-markdown-renderer';
25+
import Markdown from 'react-native-markdown-display';
2626

2727
type AiImageResponseProps = {
2828
imageUrl?: string;
@@ -64,8 +64,6 @@ type AiTextResponseProps = {
6464
text?: string;
6565
};
6666
function AiTextResponse({text}: AiTextResponseProps): JSX.Element {
67-
let elements: JSX.Element[] = [];
68-
6967
const rules = {
7068
fence: (node, children, parent, styles) => {
7169
return (
@@ -77,35 +75,8 @@ function AiTextResponse({text}: AiTextResponseProps): JSX.Element {
7775
},
7876
}
7977

80-
const styles = StyleSheet.create({
81-
listItem: {
82-
// Removing these because they break the rendering of list items
83-
// flex: 1,
84-
// flexWrap: 'wrap',
85-
},
86-
paragraph: {
87-
marginTop: 0, // Removing the 10px here because they are being applied to list items too
88-
marginBottom: 0, // Removing the 10px here because they are being applied to list items too
89-
flexWrap: 'wrap',
90-
flexDirection: 'row',
91-
alignItems: 'flex-start',
92-
justifyContent: 'flex-start',
93-
},
94-
listUnorderedItemIcon: {
95-
marginLeft: 10,
96-
marginRight: 10,
97-
lineHeight: 20, // This is Platform.selected only on IOS/Android in https://github.com/mientjan/react-native-markdown-renderer/blob/master/src/lib/styles.js
98-
},
99-
listOrderedItemIcon: {
100-
marginLeft: 10,
101-
marginRight: 10,
102-
lineHeight: 30, // This is Platform.selected only on IOS/Android in https://github.com/mientjan/react-native-markdown-renderer/blob/master/src/lib/styles.js
103-
},
104-
105-
});
106-
10778
return (
108-
<Markdown rules={rules} style={styles}>{text}</Markdown>
79+
<Markdown rules={rules}>{text}</Markdown>
10980
);
11081
}
11182

yarn.lock

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,11 +1956,6 @@
19561956
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
19571957
integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==
19581958

1959-
"@types/markdown-it@^0.0.4":
1960-
version "0.0.4"
1961-
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.4.tgz#c5f67365916044b342dae8d702724788ba0b5b74"
1962-
integrity sha512-FWR7QB7EqBRq1s9BMk0ccOSOuRLfVEWYpHQYpFPaXtCoqN6dJx2ttdsdQbUxLLnAlKpYeVjveGGhQ3583TTa7g==
1963-
19641959
"@types/node@*":
19651960
version "18.11.18"
19661961
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f"
@@ -1976,13 +1971,6 @@
19761971
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf"
19771972
integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==
19781973

1979-
"@types/react-native@>=0.50.0":
1980-
version "0.71.3"
1981-
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.71.3.tgz#537f669ed6b38b5ae47444bd9d253c4cff23bed7"
1982-
integrity sha512-0Uqw1YZ0qbVla0MMWFTANFm6W8KYWNvGQmYfucdecbXivLMcQ2v4PovuYFKr7bE6Bc5nDCUEaga962Y8gcDF7A==
1983-
dependencies:
1984-
"@types/react" "*"
1985-
19861974
"@types/react-test-renderer@^18.0.0":
19871975
version "18.0.0"
19881976
resolved "https://registry.yarnpkg.com/@types/react-test-renderer/-/react-test-renderer-18.0.0.tgz#7b7f69ca98821ea5501b21ba24ea7b6139da2243"
@@ -2699,6 +2687,11 @@ camelcase@^6.0.0, camelcase@^6.2.0:
26992687
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
27002688
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
27012689

2690+
camelize@^1.0.0:
2691+
version "1.0.1"
2692+
resolved "https://registry.yarnpkg.com/camelize/-/camelize-1.0.1.tgz#89b7e16884056331a35d6b5ad064332c91daa6c3"
2693+
integrity sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==
2694+
27022695
caniuse-lite@^1.0.30001449:
27032696
version "1.0.30001450"
27042697
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001450.tgz#022225b91200589196b814b51b1bbe45144cf74f"
@@ -3038,6 +3031,20 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
30383031
shebang-command "^2.0.0"
30393032
which "^2.0.1"
30403033

3034+
css-color-keywords@^1.0.0:
3035+
version "1.0.0"
3036+
resolved "https://registry.yarnpkg.com/css-color-keywords/-/css-color-keywords-1.0.0.tgz#fea2616dc676b2962686b3af8dbdbe180b244e05"
3037+
integrity sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==
3038+
3039+
css-to-react-native@^3.0.0:
3040+
version "3.2.0"
3041+
resolved "https://registry.yarnpkg.com/css-to-react-native/-/css-to-react-native-3.2.0.tgz#cdd8099f71024e149e4f6fe17a7d46ecd55f1e32"
3042+
integrity sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==
3043+
dependencies:
3044+
camelize "^1.0.0"
3045+
css-color-keywords "^1.0.0"
3046+
postcss-value-parser "^4.0.2"
3047+
30413048
csstype@^3.0.2:
30423049
version "3.1.1"
30433050
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.1.tgz#841b532c45c758ee546a11d5bd7b7b473c8c30b9"
@@ -3252,10 +3259,10 @@ end-of-stream@^1.1.0:
32523259
dependencies:
32533260
once "^1.4.0"
32543261

3255-
entities@~1.1.1:
3256-
version "1.1.2"
3257-
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56"
3258-
integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==
3262+
entities@~2.0.0:
3263+
version "2.0.3"
3264+
resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.3.tgz#5c487e5742ab93c15abb5da22759b8590ec03b7f"
3265+
integrity sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==
32593266

32603267
envinfo@^7.5.0, envinfo@^7.7.2, envinfo@^7.8.1:
32613268
version "7.8.1"
@@ -5445,13 +5452,13 @@ map-visit@^1.0.0:
54455452
dependencies:
54465453
object-visit "^1.0.0"
54475454

5448-
markdown-it@^8.4.0:
5449-
version "8.4.2"
5450-
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54"
5451-
integrity sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==
5455+
markdown-it@^10.0.0:
5456+
version "10.0.0"
5457+
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-10.0.0.tgz#abfc64f141b1722d663402044e43927f1f50a8dc"
5458+
integrity sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==
54525459
dependencies:
54535460
argparse "^1.0.7"
5454-
entities "~1.1.1"
5461+
entities "~2.0.0"
54555462
linkify-it "^2.0.0"
54565463
mdurl "^1.0.1"
54575464
uc.micro "^1.0.5"
@@ -6494,6 +6501,11 @@ posix-character-classes@^0.1.0:
64946501
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
64956502
integrity sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==
64966503

6504+
postcss-value-parser@^4.0.2:
6505+
version "4.2.0"
6506+
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514"
6507+
integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==
6508+
64976509
postinstall-postinstall@^2.1.0:
64986510
version "2.1.0"
64996511
resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3"
@@ -6567,7 +6579,7 @@ prompts@^2.0.1, prompts@^2.4.0, prompts@^2.4.1:
65676579
kleur "^3.0.3"
65686580
sisteransi "^1.0.5"
65696581

6570-
prop-types@*, prop-types@^15.5.10, prop-types@^15.8.1:
6582+
prop-types@*, prop-types@^15.5.10, prop-types@^15.7.2, prop-types@^15.8.1:
65716583
version "15.8.1"
65726584
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
65736585
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
@@ -6639,7 +6651,7 @@ react-native-codegen@^0.71.3:
66396651
jscodeshift "^0.13.1"
66406652
nullthrows "^1.1.1"
66416653

6642-
react-native-fit-image@^1.5.2:
6654+
react-native-fit-image@^1.5.5:
66436655
version "1.5.5"
66446656
resolved "https://registry.yarnpkg.com/react-native-fit-image/-/react-native-fit-image-1.5.5.tgz#c660d1ad74b9dcaa1cba27a0d9c23837e000226c"
66456657
integrity sha512-Wl3Vq2DQzxgsWKuW4USfck9zS7YzhvLNPpkwUUCF90bL32e1a0zOVQ3WsJILJOwzmPdHfzZmWasiiAUNBkhNkg==
@@ -6651,16 +6663,15 @@ react-native-gradle-plugin@^0.71.12:
66516663
resolved "https://registry.yarnpkg.com/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.14.tgz#cc399662f04fbfcc0e352d03eae1d3efbd5f635a"
66526664
integrity sha512-nnLawTZEPPRAKq92UqDkzoGgCBl9aa9zAihFHMwmwzn4WRVdK4O6Cd4XYiyoNOiQzx3Hh9k5WOckHE80C92ivQ==
66536665

6654-
react-native-markdown-renderer@^3.2.8:
6655-
version "3.2.8"
6656-
resolved "https://registry.yarnpkg.com/react-native-markdown-renderer/-/react-native-markdown-renderer-3.2.8.tgz#217046cf198eca632a65f93cdf7dd7766f718070"
6657-
integrity sha512-gDT5r3lwecNsEfpKagSaidEGfmCbpVcmV+HHLjaGYRALJoHkpOFni0rJZW1rCerOR9sjaUNGXE66U7BUrlEw0w==
6666+
react-native-markdown-display@^7.0.0-alpha.2:
6667+
version "7.0.0-alpha.2"
6668+
resolved "https://registry.yarnpkg.com/react-native-markdown-display/-/react-native-markdown-display-7.0.0-alpha.2.tgz#a48a70d3cb5c510a52ecf7f1509a4a3d14d728aa"
6669+
integrity sha512-Od1a4wJEcVGwO1bh02sHivsEkKKpu99+ew/OtmVTPRmfT8V3B0aTut7k7ICV0Vej9F4ZjylRHvm28/maYUBeGw==
66586670
dependencies:
6659-
"@types/markdown-it" "^0.0.4"
6660-
"@types/react-native" ">=0.50.0"
6661-
markdown-it "^8.4.0"
6662-
prop-types "^15.5.10"
6663-
react-native-fit-image "^1.5.2"
6671+
css-to-react-native "^3.0.0"
6672+
markdown-it "^10.0.0"
6673+
prop-types "^15.7.2"
6674+
react-native-fit-image "^1.5.5"
66646675

66656676
react-native-syntax-highlighter@^2.1.0:
66666677
version "2.1.0"

0 commit comments

Comments
 (0)