From 368286ad67436e379324be9f81f9e2949ebff12c Mon Sep 17 00:00:00 2001
From: Paul Frazee <pfrazee@gmail.com>
Date: Fri, 18 Nov 2022 11:37:25 -0600
Subject: Fix richtext link rendering

---
 src/view/com/util/Link.tsx | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

(limited to 'src/view/com/util/Link.tsx')

diff --git a/src/view/com/util/Link.tsx b/src/view/com/util/Link.tsx
index 1d8ec2309..4931438b8 100644
--- a/src/view/com/util/Link.tsx
+++ b/src/view/com/util/Link.tsx
@@ -1,6 +1,12 @@
 import React from 'react'
 import {observer} from 'mobx-react-lite'
-import {StyleProp, Text, TouchableOpacity, ViewStyle} from 'react-native'
+import {
+  StyleProp,
+  Text,
+  TouchableOpacity,
+  TextStyle,
+  ViewStyle,
+} from 'react-native'
 import {useStores} from '../../../state'
 import {LinkActionsModel} from '../../../state/models/shell-ui'
 
@@ -21,6 +27,7 @@ export const Link = observer(function Link({
     store.nav.navigate(href)
   }
   const onLongPress = () => {
+    store.shell.closeModal() // close any active modals
     store.nav.newTab(href, title)
     // store.shell.openModal(new LinkActionsModel(href, title || href))
   }
@@ -34,3 +41,30 @@ export const Link = observer(function Link({
     </TouchableOpacity>
   )
 })
+
+export const TextLink = observer(function Link({
+  style,
+  href,
+  title,
+  text,
+}: {
+  style?: StyleProp<TextStyle>
+  href: string
+  title?: string
+  text: string
+}) {
+  const store = useStores()
+  const onPress = () => {
+    store.shell.closeModal() // close any active modals
+    store.nav.navigate(href)
+  }
+  const onLongPress = () => {
+    store.shell.closeModal() // close any active modals
+    store.nav.newTab(href, title)
+  }
+  return (
+    <Text style={style} onPress={onPress} onLongPress={onLongPress}>
+      {text}
+    </Text>
+  )
+})
-- 
cgit 1.4.1

