-
-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add footnotes prompt #131
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,6 +9,7 @@ import Script from 'next/script' | |||||
import type { MarkdownToJSX } from 'markdown-to-jsx' | ||||||
import type { FC, PropsWithChildren } from 'react' | ||||||
|
||||||
import { FloatPopover } from '~/components/ui/float-popover' | ||||||
import { MAIN_MARKDOWN_ID } from '~/constants/dom-id' | ||||||
import { isDev } from '~/lib/env' | ||||||
import { noopObj } from '~/lib/noop' | ||||||
|
@@ -166,24 +167,46 @@ export const Markdown: FC<MdProps & MarkdownToJSX.Options & PropsWithChildren> = | |||||
return undefined | ||||||
} | ||||||
})() | ||||||
|
||||||
const footnotes = () => { | ||||||
return ( | ||||||
<Fragment key={state?.key}> | ||||||
<a | ||||||
href={`#fn:${content}`} | ||||||
onClick={(e) => { | ||||||
e.preventDefault() | ||||||
springScrollToElement( | ||||||
document.getElementById(`fn:${content}`)!, | ||||||
-window.innerHeight / 2, | ||||||
) | ||||||
redHighlight(`fn:${content}`) | ||||||
}} | ||||||
> | ||||||
<sup id={`fnref:${content}`}>{`[^${content}]`}</sup> | ||||||
</a> | ||||||
{linkCardId && ( | ||||||
<LinkCard id={linkCardId} source="mx-space" /> | ||||||
)} | ||||||
</Fragment> | ||||||
) | ||||||
} | ||||||
return ( | ||||||
<Fragment key={state?.key}> | ||||||
<a | ||||||
href={`#fn:${content}`} | ||||||
onClick={(e) => { | ||||||
e.preventDefault() | ||||||
springScrollToElement( | ||||||
document.getElementById(`fn:${content}`)!, | ||||||
-window.innerHeight / 2, | ||||||
) | ||||||
redHighlight(`fn:${content}`) | ||||||
}} | ||||||
> | ||||||
<sup id={`fnref:${content}`}>{`[^${content}]`}</sup> | ||||||
</a> | ||||||
{linkCardId && <LinkCard id={linkCardId} source="mx-space" />} | ||||||
</Fragment> | ||||||
<FloatPopover | ||||||
as="span" | ||||||
TriggerComponent={footnotes} | ||||||
type="popover" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
wrapperClassName="footnotes_text" | ||||||
> | ||||||
<div className="space-y-2 leading-relaxed"> | ||||||
<p className="flex items-center space-x-1 opacity-80"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 好像不是很需要 |
||||||
<span | ||||||
className="font-medium" | ||||||
dangerouslySetInnerHTML={{ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不要 |
||||||
__html: footnote?.footnote?.substring(1), | ||||||
}} | ||||||
/> | ||||||
</p> | ||||||
</div> | ||||||
</FloatPopover> | ||||||
) | ||||||
}, | ||||||
}, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#fn
这种前缀太 magic 能不能封装一个函数。