1
1
/* eslint-disable react/no-danger */
2
-
2
+ import { useEffect , useRef } from 'react'
3
3
import { makeStyles , tokens } from '@fluentui/react-components'
4
4
import { observer } from 'mobx-react-lite'
5
5
import { store } from '@/renderer/store'
6
6
import { format as formatTime } from '@/utils/common/date'
7
+ import { openExternal } from '@/utils/browser/shell'
7
8
8
9
const { readerStore } = store
9
10
@@ -34,6 +35,21 @@ const useStyles = makeStyles({
34
35
fontSize : tokens . fontSizeBase400 ,
35
36
lineHeight : 1.2 ,
36
37
} ,
38
+
39
+ '& a' : {
40
+ color : tokens . colorBrandForegroundLink ,
41
+ textDecorationLine : 'underline' ,
42
+
43
+ ':hover' : {
44
+ color : tokens . colorBrandForegroundLinkHover ,
45
+ } ,
46
+ ':active' : {
47
+ color : tokens . colorBrandForegroundLinkSelected ,
48
+ } ,
49
+ ':visited' : {
50
+ color : tokens . colorBrandForegroundLinkPressed ,
51
+ } ,
52
+ } ,
37
53
} ,
38
54
} )
39
55
@@ -53,6 +69,27 @@ function Content() {
53
69
} = activeArticle
54
70
const feed = feeds . find ( ( v ) => v . id === feedId ) !
55
71
72
+ const containerRef = useRef < HTMLDivElement > ( null )
73
+
74
+ useEffect ( ( ) => {
75
+ const el = containerRef . current
76
+ const handler = ( e : MouseEvent ) => {
77
+ const { target } = e
78
+ if ( ! ( target instanceof HTMLAnchorElement ) || ! target . href ) {
79
+ return
80
+ }
81
+
82
+ e . preventDefault ( )
83
+ openExternal ( target . href )
84
+ }
85
+
86
+ el ?. addEventListener ( 'click' , handler )
87
+
88
+ return ( ) => {
89
+ el ?. removeEventListener ( 'click' , handler )
90
+ }
91
+ } , [ containerRef . current ] )
92
+
56
93
return (
57
94
< div >
58
95
< h1 className = "text-2xl px-5 pt-4 pb-3" >
@@ -70,6 +107,7 @@ function Content() {
70
107
</ div >
71
108
< div className = "px-5" >
72
109
< div
110
+ ref = { containerRef }
73
111
className = { styles . content }
74
112
dangerouslySetInnerHTML = { { __html : content } }
75
113
/>
0 commit comments