From 91adb913add6f4d3bc1403b4ccb3fb14a53ec1c1 Mon Sep 17 00:00:00 2001 From: Cory Chambers Date: Tue, 10 Oct 2023 07:23:53 -0400 Subject: [PATCH 1/7] Added additional markdown library to handle text --- package.json | 1 + src/components/common/SizedMarkdown.js | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 5b448908..93390db4 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "react-native-gesture-handler": "^1.10.3", "react-native-image-pan-zoom": "^2.1.12", "react-native-loading-spinner-overlay": "^3.0.1", + "react-native-markdown-package": "^1.8.2", "react-native-reanimated": "^3.4.2", "react-native-safe-area-context": "^4.7.2", "react-native-screens": "^3.25.0", diff --git a/src/components/common/SizedMarkdown.js b/src/components/common/SizedMarkdown.js index 15ca7ba8..4b29142d 100644 --- a/src/components/common/SizedMarkdown.js +++ b/src/components/common/SizedMarkdown.js @@ -3,7 +3,8 @@ import { View } from 'react-native' import DeviceInfo from 'react-native-device-info' -import Markdown from 'react-native-simple-markdown' +import Markdown from 'react-native-markdown-package'; +import MarkdownButton from 'react-native-simple-markdown' import PropTypes from 'prop-types' import { markdownImageRule } from '../../utils/markdownUtils' @@ -74,11 +75,23 @@ class SizedMarkdown extends Component { } } + /** + * The reasoning behind the two Markdown libraries. + * react-native-simple-markdown works great with buttons & buttons with markdown images. + * I cannot find a replacement library without breaking images. + * react-native-markdown-package works great with things like bold and newline characters. + */ return ( - - { this.props.children } - + {this.props.forButton ? ( + + { this.props.children } + + ): ( + + { this.props.children } + + )} ) } From ef3578d991e7268d6bc83837cbf1e08cdc80ead6 Mon Sep 17 00:00:00 2001 From: Cory Chambers Date: Wed, 11 Oct 2023 07:04:50 -0400 Subject: [PATCH 2/7] Add function to double the newline character to fix issue 412. --- package.json | 1 - src/components/common/SizedMarkdown.js | 25 ++++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 93390db4..5b448908 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "react-native-gesture-handler": "^1.10.3", "react-native-image-pan-zoom": "^2.1.12", "react-native-loading-spinner-overlay": "^3.0.1", - "react-native-markdown-package": "^1.8.2", "react-native-reanimated": "^3.4.2", "react-native-safe-area-context": "^4.7.2", "react-native-screens": "^3.25.0", diff --git a/src/components/common/SizedMarkdown.js b/src/components/common/SizedMarkdown.js index 4b29142d..b99f1851 100644 --- a/src/components/common/SizedMarkdown.js +++ b/src/components/common/SizedMarkdown.js @@ -3,8 +3,7 @@ import { View } from 'react-native' import DeviceInfo from 'react-native-device-info' -import Markdown from 'react-native-markdown-package'; -import MarkdownButton from 'react-native-simple-markdown' +import Markdown from 'react-native-simple-markdown' import PropTypes from 'prop-types' import { markdownImageRule } from '../../utils/markdownUtils' @@ -46,6 +45,14 @@ class SizedMarkdown extends Component { }) } + // Fixes: https://github.com/zooniverse/mobile/issues/412 + addLineBreak(content) { + const newContent = content.replace(/\n/g, (m) => { + return m + m; + }); + return newContent; + } + render() { const { viewDimensions } = this.state @@ -75,23 +82,11 @@ class SizedMarkdown extends Component { } } - /** - * The reasoning behind the two Markdown libraries. - * react-native-simple-markdown works great with buttons & buttons with markdown images. - * I cannot find a replacement library without breaking images. - * react-native-markdown-package works great with things like bold and newline characters. - */ return ( - {this.props.forButton ? ( - - { this.props.children } - - ): ( - { this.props.children } + {this.addLineBreak(this.props.children)} - )} ) } From aeadac2c895603d8528ea5a491bd45900a641d17 Mon Sep 17 00:00:00 2001 From: Cory Chambers Date: Wed, 11 Oct 2023 07:05:31 -0400 Subject: [PATCH 3/7] Fix spacing. --- src/components/common/SizedMarkdown.js | 4 ++-- src/containers/app.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/common/SizedMarkdown.js b/src/components/common/SizedMarkdown.js index b99f1851..9c1e1991 100644 --- a/src/components/common/SizedMarkdown.js +++ b/src/components/common/SizedMarkdown.js @@ -84,9 +84,9 @@ class SizedMarkdown extends Component { return ( - + {this.addLineBreak(this.props.children)} - + ) } diff --git a/src/containers/app.js b/src/containers/app.js index c38e0cb8..70ecb52d 100644 --- a/src/containers/app.js +++ b/src/containers/app.js @@ -39,10 +39,10 @@ import RootNavigator from "../navigation/RootNavigator"; import AsyncStorage from "@react-native-async-storage/async-storage"; import * as Sentry from '@sentry/react-native'; -Sentry.init({ - dsn: 'https://334e2b2ca1c04dc4a7fc356e394e9ea8@o274434.ingest.sentry.io/5371400', - enableNative: process.env.NODE_ENV === 'production' ? true : false, -}); +// Sentry.init({ +// dsn: 'https://334e2b2ca1c04dc4a7fc356e394e9ea8@o274434.ingest.sentry.io/5371400', +// enableNative: process.env.NODE_ENV === 'production' ? true : false, +// }); const persistConfig = { key: 'root', From e0e01145079f8b6c5257cbf7d5b768e151c883ec Mon Sep 17 00:00:00 2001 From: Cory Chambers Date: Wed, 11 Oct 2023 07:06:21 -0400 Subject: [PATCH 4/7] Revert "Fix spacing." This reverts commit aeadac2c895603d8528ea5a491bd45900a641d17. --- src/components/common/SizedMarkdown.js | 4 ++-- src/containers/app.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/common/SizedMarkdown.js b/src/components/common/SizedMarkdown.js index 9c1e1991..b99f1851 100644 --- a/src/components/common/SizedMarkdown.js +++ b/src/components/common/SizedMarkdown.js @@ -84,9 +84,9 @@ class SizedMarkdown extends Component { return ( - + {this.addLineBreak(this.props.children)} - + ) } diff --git a/src/containers/app.js b/src/containers/app.js index 70ecb52d..c38e0cb8 100644 --- a/src/containers/app.js +++ b/src/containers/app.js @@ -39,10 +39,10 @@ import RootNavigator from "../navigation/RootNavigator"; import AsyncStorage from "@react-native-async-storage/async-storage"; import * as Sentry from '@sentry/react-native'; -// Sentry.init({ -// dsn: 'https://334e2b2ca1c04dc4a7fc356e394e9ea8@o274434.ingest.sentry.io/5371400', -// enableNative: process.env.NODE_ENV === 'production' ? true : false, -// }); +Sentry.init({ + dsn: 'https://334e2b2ca1c04dc4a7fc356e394e9ea8@o274434.ingest.sentry.io/5371400', + enableNative: process.env.NODE_ENV === 'production' ? true : false, +}); const persistConfig = { key: 'root', From 837c9719a332a7c9edd787575f02aa3ec702c6c9 Mon Sep 17 00:00:00 2001 From: Cory Chambers Date: Wed, 11 Oct 2023 07:06:44 -0400 Subject: [PATCH 5/7] Revert "Add function to double the newline character to fix issue 412." This reverts commit ef3578d991e7268d6bc83837cbf1e08cdc80ead6. --- package.json | 1 + src/components/common/SizedMarkdown.js | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 5b448908..93390db4 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "react-native-gesture-handler": "^1.10.3", "react-native-image-pan-zoom": "^2.1.12", "react-native-loading-spinner-overlay": "^3.0.1", + "react-native-markdown-package": "^1.8.2", "react-native-reanimated": "^3.4.2", "react-native-safe-area-context": "^4.7.2", "react-native-screens": "^3.25.0", diff --git a/src/components/common/SizedMarkdown.js b/src/components/common/SizedMarkdown.js index b99f1851..4b29142d 100644 --- a/src/components/common/SizedMarkdown.js +++ b/src/components/common/SizedMarkdown.js @@ -3,7 +3,8 @@ import { View } from 'react-native' import DeviceInfo from 'react-native-device-info' -import Markdown from 'react-native-simple-markdown' +import Markdown from 'react-native-markdown-package'; +import MarkdownButton from 'react-native-simple-markdown' import PropTypes from 'prop-types' import { markdownImageRule } from '../../utils/markdownUtils' @@ -45,14 +46,6 @@ class SizedMarkdown extends Component { }) } - // Fixes: https://github.com/zooniverse/mobile/issues/412 - addLineBreak(content) { - const newContent = content.replace(/\n/g, (m) => { - return m + m; - }); - return newContent; - } - render() { const { viewDimensions } = this.state @@ -82,11 +75,23 @@ class SizedMarkdown extends Component { } } + /** + * The reasoning behind the two Markdown libraries. + * react-native-simple-markdown works great with buttons & buttons with markdown images. + * I cannot find a replacement library without breaking images. + * react-native-markdown-package works great with things like bold and newline characters. + */ return ( + {this.props.forButton ? ( + + { this.props.children } + + ): ( - {this.addLineBreak(this.props.children)} + { this.props.children } + )} ) } From d7aa0082993070edf998493a3e8e34149ccfb945 Mon Sep 17 00:00:00 2001 From: Cory Chambers Date: Wed, 11 Oct 2023 07:07:42 -0400 Subject: [PATCH 6/7] Added function to double the newline character and fix issue 412. --- package.json | 7 +++---- src/components/common/SizedMarkdown.js | 29 +++++++++++--------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 93390db4..3d789899 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "version": "0.0.1", "private": true, "scripts": { - "start": "npm start", - "android": "npm run android", - "ios": "npm run ios", + "start": "react-native start", + "android": "react-native run-android", + "ios": "react-native run-ios", "test": "NODE_ENV=staging jest --runInBand", "test:watch": "npm test -- --watch" }, @@ -49,7 +49,6 @@ "react-native-gesture-handler": "^1.10.3", "react-native-image-pan-zoom": "^2.1.12", "react-native-loading-spinner-overlay": "^3.0.1", - "react-native-markdown-package": "^1.8.2", "react-native-reanimated": "^3.4.2", "react-native-safe-area-context": "^4.7.2", "react-native-screens": "^3.25.0", diff --git a/src/components/common/SizedMarkdown.js b/src/components/common/SizedMarkdown.js index 4b29142d..9c1e1991 100644 --- a/src/components/common/SizedMarkdown.js +++ b/src/components/common/SizedMarkdown.js @@ -3,8 +3,7 @@ import { View } from 'react-native' import DeviceInfo from 'react-native-device-info' -import Markdown from 'react-native-markdown-package'; -import MarkdownButton from 'react-native-simple-markdown' +import Markdown from 'react-native-simple-markdown' import PropTypes from 'prop-types' import { markdownImageRule } from '../../utils/markdownUtils' @@ -46,6 +45,14 @@ class SizedMarkdown extends Component { }) } + // Fixes: https://github.com/zooniverse/mobile/issues/412 + addLineBreak(content) { + const newContent = content.replace(/\n/g, (m) => { + return m + m; + }); + return newContent; + } + render() { const { viewDimensions } = this.state @@ -75,23 +82,11 @@ class SizedMarkdown extends Component { } } - /** - * The reasoning behind the two Markdown libraries. - * react-native-simple-markdown works great with buttons & buttons with markdown images. - * I cannot find a replacement library without breaking images. - * react-native-markdown-package works great with things like bold and newline characters. - */ return ( - {this.props.forButton ? ( - - { this.props.children } - - ): ( - - { this.props.children } - - )} + + {this.addLineBreak(this.props.children)} + ) } From bb6099cd92d5601fd64f7715406f524ca0d484bc Mon Sep 17 00:00:00 2001 From: Cory Chambers Date: Wed, 11 Oct 2023 07:21:01 -0400 Subject: [PATCH 7/7] Refactored addLineBreak() to be more concise. --- src/components/common/SizedMarkdown.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/common/SizedMarkdown.js b/src/components/common/SizedMarkdown.js index 9c1e1991..4a2b2f67 100644 --- a/src/components/common/SizedMarkdown.js +++ b/src/components/common/SizedMarkdown.js @@ -47,11 +47,8 @@ class SizedMarkdown extends Component { // Fixes: https://github.com/zooniverse/mobile/issues/412 addLineBreak(content) { - const newContent = content.replace(/\n/g, (m) => { - return m + m; - }); - return newContent; - } + return content.replace(/\n/g, (n) => n + n); + } render() { const { viewDimensions } = this.state