@@ -8,8 +8,7 @@ import RemarkGfm from 'remark-gfm'
8
8
import RehypeRaw from 'rehype-raw'
9
9
import SyntaxHighlighter from 'react-syntax-highlighter'
10
10
import { atelierHeathLight } from 'react-syntax-highlighter/dist/esm/styles/hljs'
11
- import type { RefObject } from 'react'
12
- import { Component , memo , useEffect , useMemo , useRef , useState } from 'react'
11
+ import { Component , memo , useMemo , useRef , useState } from 'react'
13
12
import type { CodeComponent } from 'react-markdown/lib/ast-to-react'
14
13
import cn from '@/utils/classnames'
15
14
import CopyBtn from '@/app/components/base/copy-btn'
@@ -77,29 +76,6 @@ export function PreCode(props: { children: any }) {
77
76
)
78
77
}
79
78
80
- // eslint-disable-next-line unused-imports/no-unused-vars
81
- const useLazyLoad = ( ref : RefObject < Element > ) : boolean => {
82
- const [ isIntersecting , setIntersecting ] = useState < boolean > ( false )
83
-
84
- useEffect ( ( ) => {
85
- const observer = new IntersectionObserver ( ( [ entry ] ) => {
86
- if ( entry . isIntersecting ) {
87
- setIntersecting ( true )
88
- observer . disconnect ( )
89
- }
90
- } )
91
-
92
- if ( ref . current )
93
- observer . observe ( ref . current )
94
-
95
- return ( ) => {
96
- observer . disconnect ( )
97
- }
98
- } , [ ref ] )
99
-
100
- return isIntersecting
101
- }
102
-
103
79
// **Add code block
104
80
// Avoid error #185 (Maximum update depth exceeded.
105
81
// This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate.
@@ -123,7 +99,7 @@ const CodeBlock: CodeComponent = memo(({ inline, className, children, ...props }
123
99
try {
124
100
return JSON . parse ( String ( children ) . replace ( / \n $ / , '' ) )
125
101
}
126
- catch ( error ) { }
102
+ catch ( error ) { }
127
103
}
128
104
return JSON . parse ( '{"title":{"text":"ECharts error - Wrong JSON format."}}' )
129
105
} , [ language , children ] )
@@ -181,7 +157,7 @@ const CodeBlock: CodeComponent = memo(({ inline, className, children, ...props }
181
157
>
182
158
< div className = 'text-[13px] text-gray-500 font-normal' > { languageShowName } </ div >
183
159
< div style = { { display : 'flex' } } >
184
- { ( [ 'mermaid' , 'svg' ] ) . includes ( language ! ) && < SVGBtn isSVG = { isSVG } setIsSVG = { setIsSVG } /> }
160
+ { ( [ 'mermaid' , 'svg' ] ) . includes ( language ! ) && < SVGBtn isSVG = { isSVG } setIsSVG = { setIsSVG } /> }
185
161
< CopyBtn
186
162
className = 'mr-1'
187
163
value = { String ( children ) . replace ( / \n $ / , '' ) }
@@ -261,7 +237,7 @@ export function Markdown(props: { content: string; className?: string }) {
261
237
( ) => {
262
238
return ( tree ) => {
263
239
const iterate = ( node : any ) => {
264
- if ( node . type === 'element' && ! node . properties ?. src && node . properties ?. ref && node . properties . ref . startsWith ( '{' ) && node . properties . ref . endsWith ( '}' ) )
240
+ if ( node . type === 'element' && node . properties ?. ref )
265
241
delete node . properties . ref
266
242
267
243
if ( node . children )
0 commit comments