fix(web): fix lint

pull/20177/head
xuzijie1995 1 year ago
parent 4a7d0f719a
commit 67e1ef1e3e

@ -3,8 +3,8 @@
* Extracted from the main markdown renderer for modularity. * Extracted from the main markdown renderer for modularity.
* Uses the AudioGallery component to display audio players. * Uses the AudioGallery component to display audio players.
*/ */
import React, { memo } from 'react'; import React, { memo } from 'react'
import AudioGallery from '@/app/components/base/audio-gallery'; import AudioGallery from '@/app/components/base/audio-gallery'
const AudioBlock: any = memo(({ node }: any) => { const AudioBlock: any = memo(({ node }: any) => {
const srcs = node.children.filter((child: any) => 'properties' in child).map((child: any) => (child as any).properties.src) const srcs = node.children.filter((child: any) => 'properties' in child).map((child: any) => (child as any).properties.src)
@ -18,4 +18,4 @@ const AudioBlock: any = memo(({ node }: any) => {
}) })
AudioBlock.displayName = 'AudioBlock' AudioBlock.displayName = 'AudioBlock'
export default AudioBlock; export default AudioBlock

@ -1,19 +1,19 @@
import { memo, useEffect, useMemo, useRef, useState } from 'react' import { memo, useEffect, useMemo, useRef, useState } from 'react'
import ReactEcharts from 'echarts-for-react'; import ReactEcharts from 'echarts-for-react'
import SyntaxHighlighter from 'react-syntax-highlighter'; import SyntaxHighlighter from 'react-syntax-highlighter'
import { import {
atelierHeathDark, atelierHeathDark,
atelierHeathLight, atelierHeathLight,
} from 'react-syntax-highlighter/dist/esm/styles/hljs'; } from 'react-syntax-highlighter/dist/esm/styles/hljs'
import ActionButton from '@/app/components/base/action-button'; import ActionButton from '@/app/components/base/action-button'
import CopyIcon from '@/app/components/base/copy-icon'; import CopyIcon from '@/app/components/base/copy-icon'
import SVGBtn from '@/app/components/base/svg'; import SVGBtn from '@/app/components/base/svg'
import Flowchart from '@/app/components/base/mermaid'; import Flowchart from '@/app/components/base/mermaid'
import { Theme } from '@/types/app'; import { Theme } from '@/types/app'
import useTheme from '@/hooks/use-theme'; import useTheme from '@/hooks/use-theme'
import SVGRenderer from '../svg-gallery'; // Assumes svg-gallery.tsx is in /base directory import SVGRenderer from '../svg-gallery' // Assumes svg-gallery.tsx is in /base directory
import MarkdownMusic from '@/app/components/base/markdown-blocks/music'; import MarkdownMusic from '@/app/components/base/markdown-blocks/music'
import ErrorBoundary from '@/app/components/base/markdown'; import ErrorBoundary from '@/app/components/base/markdown'
// Available language https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/AVAILABLE_LANGUAGES_HLJS.MD // Available language https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/AVAILABLE_LANGUAGES_HLJS.MD
const capitalizationLanguageNameMap: Record<string, string> = { const capitalizationLanguageNameMap: Record<string, string> = {
@ -385,4 +385,4 @@ const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any
}) })
CodeBlock.displayName = 'CodeBlock' CodeBlock.displayName = 'CodeBlock'
export default CodeBlock; export default CodeBlock

@ -3,11 +3,11 @@
* Extracted from the main markdown renderer for modularity. * Extracted from the main markdown renderer for modularity.
* Uses the ImageGallery component to display images. * Uses the ImageGallery component to display images.
*/ */
import React from 'react'; import React from 'react'
import ImageGallery from '@/app/components/base/image-gallery'; import ImageGallery from '@/app/components/base/image-gallery'
const Img = ({ src }: any) => { const Img = ({ src }: any) => {
return <div className="markdown-img-wrapper"><ImageGallery srcs={[src]} /></div> return <div className="markdown-img-wrapper"><ImageGallery srcs={[src]} /></div>
} }
export default Img; export default Img

@ -3,16 +3,16 @@
* This allows for cleaner imports in other parts of the application. * This allows for cleaner imports in other parts of the application.
*/ */
export { default as AudioBlock } from './audio-block'; export { default as AudioBlock } from './audio-block'
export { default as CodeBlock } from './code-block'; export { default as CodeBlock } from './code-block'
export { default as Img } from './img'; export { default as Img } from './img'
export { default as Link } from './link'; export { default as Link } from './link'
export { default as Paragraph } from './paragraph'; export { default as Paragraph } from './paragraph'
export { default as PreCode } from './pre-code'; export { default as PreCode } from './pre-code'
export { default as ScriptBlock } from './script-block'; export { default as ScriptBlock } from './script-block'
export { default as VideoBlock } from './video-block'; export { default as VideoBlock } from './video-block'
// Assuming these are also standalone components in this directory intended for Markdown rendering // Assuming these are also standalone components in this directory intended for Markdown rendering
export { default as MarkdownButton } from './button'; export { default as MarkdownButton } from './button'
export { default as MarkdownForm } from './form'; export { default as MarkdownForm } from './form'
export { default as ThinkBlock } from './think-block'; export { default as ThinkBlock } from './think-block'

@ -3,8 +3,8 @@
* Extracted from the main markdown renderer for modularity. * Extracted from the main markdown renderer for modularity.
* Handles special rendering for "abbr:" type links for interactive chat actions. * Handles special rendering for "abbr:" type links for interactive chat actions.
*/ */
import React from 'react'; import React from 'react'
import { useChatContext } from '@/app/components/base/chat/chat/context'; import { useChatContext } from '@/app/components/base/chat/chat/context'
const Link = ({ node, children, ...props }: any) => { const Link = ({ node, children, ...props }: any) => {
if (node.properties?.href && node.properties.href?.toString().startsWith('abbr')) { if (node.properties?.href && node.properties.href?.toString().startsWith('abbr')) {
@ -19,4 +19,4 @@ const Link = ({ node, children, ...props }: any) => {
} }
} }
export default Link; export default Link

@ -3,8 +3,8 @@
* Extracted from the main markdown renderer for modularity. * Extracted from the main markdown renderer for modularity.
* Handles special rendering for paragraphs that directly contain an image. * Handles special rendering for paragraphs that directly contain an image.
*/ */
import React from 'react'; import React from 'react'
import ImageGallery from '@/app/components/base/image-gallery'; import ImageGallery from '@/app/components/base/image-gallery'
const Paragraph = (paragraph: any) => { const Paragraph = (paragraph: any) => {
const { node }: any = paragraph const { node }: any = paragraph
@ -24,4 +24,4 @@ const Paragraph = (paragraph: any) => {
return <p>{paragraph.children}</p> return <p>{paragraph.children}</p>
} }
export default Paragraph; export default Paragraph

@ -3,7 +3,7 @@
* Extracted from the main markdown renderer for modularity. * Extracted from the main markdown renderer for modularity.
* This is a simple wrapper around the HTML <pre> element. * This is a simple wrapper around the HTML <pre> element.
*/ */
import React, { useRef } from 'react'; import React, { useRef } from 'react'
function PreCode(props: { children: any }) { function PreCode(props: { children: any }) {
const ref = useRef<HTMLPreElement>(null) const ref = useRef<HTMLPreElement>(null)
@ -18,4 +18,4 @@ function PreCode(props: { children: any }) {
) )
} }
export default PreCode; export default PreCode

@ -4,7 +4,7 @@
* Note: Current implementation returns the script tag as a string, which might not execute as expected in React. * Note: Current implementation returns the script tag as a string, which might not execute as expected in React.
* This behavior is preserved from the original implementation and may need review for security and functionality. * This behavior is preserved from the original implementation and may need review for security and functionality.
*/ */
import React, { memo } from 'react'; import { memo } from 'react'
const ScriptBlock = memo(({ node }: any) => { const ScriptBlock = memo(({ node }: any) => {
const scriptContent = node.children[0]?.value || '' const scriptContent = node.children[0]?.value || ''
@ -12,4 +12,4 @@ const ScriptBlock = memo(({ node }: any) => {
}) })
ScriptBlock.displayName = 'ScriptBlock' ScriptBlock.displayName = 'ScriptBlock'
export default ScriptBlock; export default ScriptBlock

@ -3,8 +3,8 @@
* Extracted from the main markdown renderer for modularity. * Extracted from the main markdown renderer for modularity.
* Uses the VideoGallery component to display videos. * Uses the VideoGallery component to display videos.
*/ */
import React, { memo } from 'react'; import React, { memo } from 'react'
import VideoGallery from '@/app/components/base/video-gallery'; import VideoGallery from '@/app/components/base/video-gallery'
const VideoBlock: any = memo(({ node }: any) => { const VideoBlock: any = memo(({ node }: any) => {
const srcs = node.children.filter((child: any) => 'properties' in child).map((child: any) => (child as any).properties.src) const srcs = node.children.filter((child: any) => 'properties' in child).map((child: any) => (child as any).properties.src)
@ -18,4 +18,4 @@ const VideoBlock: any = memo(({ node }: any) => {
}) })
VideoBlock.displayName = 'VideoBlock' VideoBlock.displayName = 'VideoBlock'
export default VideoBlock; export default VideoBlock

@ -5,7 +5,7 @@
* logs those errors, and displays a fallback UI instead of the crashed component tree. * logs those errors, and displays a fallback UI instead of the crashed component tree.
* Primarily used around complex rendering logic like ECharts or SVG within Markdown. * Primarily used around complex rendering logic like ECharts or SVG within Markdown.
*/ */
import React, { Component } from 'react'; import React, { Component } from 'react'
// **Add an ECharts runtime error handler // **Add an ECharts runtime error handler
// Avoid error #7832 (Crash when ECharts accesses undefined objects) // Avoid error #7832 (Crash when ECharts accesses undefined objects)
// This can happen when a component attempts to access an undefined object that references an unregistered map, causing the program to crash. // This can happen when a component attempts to access an undefined object that references an unregistered map, causing the program to crash.

@ -9,16 +9,16 @@ import { flow } from 'lodash-es'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { preprocessLaTeX, preprocessThinkTag } from './markdown-utils' import { preprocessLaTeX, preprocessThinkTag } from './markdown-utils'
import { import {
CodeBlock,
Paragraph,
VideoBlock,
AudioBlock, AudioBlock,
ScriptBlock, CodeBlock,
Img, Img,
Link, Link,
MarkdownButton, MarkdownButton,
MarkdownForm, MarkdownForm,
ThinkBlock Paragraph,
ScriptBlock,
ThinkBlock,
VideoBlock,
} from '@/app/components/base/markdown-blocks' } from '@/app/components/base/markdown-blocks'
/** /**

@ -3,7 +3,7 @@
* These functions were extracted from the main markdown renderer for better separation of concerns. * These functions were extracted from the main markdown renderer for better separation of concerns.
* Includes preprocessing for LaTeX and custom "think" tags. * Includes preprocessing for LaTeX and custom "think" tags.
*/ */
import { flow } from 'lodash-es'; import { flow } from 'lodash-es'
export const preprocessLaTeX = (content: string) => { export const preprocessLaTeX = (content: string) => {
if (typeof content !== 'string') if (typeof content !== 'string')

Loading…
Cancel
Save