@@ -37,6 +37,7 @@ import { MFootNote } from './renderers/footnotes'
37
37
import { MHeader } from './renderers/heading'
38
38
import { MarkdownImage } from './renderers/image'
39
39
import { MTag } from './renderers/tag'
40
+ import { getFootNoteDomId } from './utils/get-id'
40
41
import { redHighlight } from './utils/redHighlight'
41
42
42
43
const CodeBlock = dynamic ( ( ) => import ( '~/components/widgets/shared/CodeBlock' ) )
@@ -167,46 +168,34 @@ export const Markdown: FC<MdProps & MarkdownToJSX.Options & PropsWithChildren> =
167
168
return undefined
168
169
}
169
170
} ) ( )
170
- const footnotes = ( ) => {
171
- return (
172
- < Fragment key = { state ?. key } >
173
- < a
174
- href = { `#fn:${ content } ` }
175
- onClick = { ( e ) => {
176
- e . preventDefault ( )
177
- springScrollToElement (
178
- document . getElementById ( `fn:${ content } ` ) ! ,
179
- - window . innerHeight / 2 ,
180
- )
181
- redHighlight ( `fn:${ content } ` )
182
- } }
183
- >
184
- < sup id = { `fnref:${ content } ` } > { `[^${ content } ]` } </ sup >
185
- </ a >
186
- { linkCardId && (
187
- < LinkCard id = { linkCardId } source = "mx-space" />
188
- ) }
189
- </ Fragment >
190
- )
191
- }
171
+
192
172
return (
193
- < FloatPopover
194
- as = "span"
195
- TriggerComponent = { footnotes }
196
- type = "popover"
197
- wrapperClassName = "footnotes_text"
198
- >
199
- < div className = "space-y-2 leading-relaxed" >
200
- < p className = "flex items-center space-x-1 opacity-80" >
201
- < span
202
- className = "font-medium"
203
- dangerouslySetInnerHTML = { {
204
- __html : footnote ?. footnote ?. substring ( 1 ) ,
173
+ < Fragment key = { state ?. key } >
174
+ < FloatPopover
175
+ wrapperClassName = "inline"
176
+ as = "span"
177
+ TriggerComponent = { ( ) => (
178
+ < a
179
+ href = { `#fn:${ content } ` }
180
+ onClick = { ( e ) => {
181
+ e . preventDefault ( )
182
+ const id = getFootNoteDomId ( content )
183
+ springScrollToElement (
184
+ document . getElementById ( id ) ! ,
185
+ - window . innerHeight / 2 ,
186
+ )
187
+ redHighlight ( id )
205
188
} }
206
- />
207
- </ p >
208
- </ div >
209
- </ FloatPopover >
189
+ >
190
+ < sup id = { `fnref:${ content } ` } > { `[^${ content } ]` } </ sup >
191
+ </ a >
192
+ ) }
193
+ type = "tooltip"
194
+ >
195
+ { footnote ?. footnote ?. substring ( 1 ) }
196
+ </ FloatPopover >
197
+ { linkCardId && < LinkCard id = { linkCardId } source = "mx-space" /> }
198
+ </ Fragment >
210
199
)
211
200
} ,
212
201
} ,
0 commit comments