-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Latex block content should be copyable
- Loading branch information
1 parent
b708bba
commit cb4ffb7
Showing
4 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useRef } from 'react' | ||
|
||
import CopyButton from '~/components/CopyButton' | ||
|
||
import 'highlight.js/styles/base16/woodland.min.css' | ||
|
||
const CustomMathBlock = (props: React.HTMLAttributes<HTMLElement>) => { | ||
const ref = useRef<HTMLDivElement>(null) | ||
|
||
const getText = () => { | ||
const text = ref.current?.getElementsByTagName('annotation')?.[0] | ||
|
||
return text?.textContent?.trim() || '' | ||
} | ||
|
||
return ( | ||
<pre className='m-0'> | ||
<div className="indicator block w-fit pr-2 pt-4"> | ||
<CopyButton | ||
className="indicator-item !absolute z-10 text-neutral-content/30 hover:text-neutral-content" | ||
getText={getText} | ||
/> | ||
|
||
<div ref={ref}> | ||
<math | ||
{...props} | ||
className="not-prose w-full overflow-x-scroll text-sm [&>*]:!text-sm" | ||
ref={ref} | ||
/> | ||
</div> | ||
</div> | ||
</pre> | ||
) | ||
} | ||
|
||
export default CustomMathBlock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
|
||
// note: this file fixes TS errors involving the LaTex ability | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
declare namespace JSX { | ||
interface IntrinsicElements { | ||
math: any | ||
} | ||
} |