mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-05-08 08:00:10 +00:00
update apply
This commit is contained in:
@@ -5,7 +5,7 @@ import { useDarkModeContext } from '../../contexts/DarkModeContext'
|
||||
|
||||
import { MemoizedSyntaxHighlighterWrapper } from './SyntaxHighlighterWrapper'
|
||||
|
||||
export default function MarkdownCodeComponent({
|
||||
export default function MarkdownActionBlock({
|
||||
onApply,
|
||||
isApplying,
|
||||
language,
|
||||
@@ -6,59 +6,59 @@ import {
|
||||
parseinfioBlocks,
|
||||
} from '../../utils/parse-infio-block'
|
||||
|
||||
import MarkdownCodeComponent from './MarkdownCodeComponent'
|
||||
import MarkdownActionBlock from './MarkdownActionBlock'
|
||||
import MarkdownReferenceBlock from './MarkdownReferenceBlock'
|
||||
|
||||
function ReactMarkdown({
|
||||
onApply,
|
||||
isApplying,
|
||||
children,
|
||||
onApply,
|
||||
isApplying,
|
||||
children,
|
||||
}: {
|
||||
onApply: (blockInfo: {
|
||||
content: string
|
||||
filename?: string
|
||||
startLine?: number
|
||||
endLine?: number
|
||||
}) => void
|
||||
children: string
|
||||
isApplying: boolean
|
||||
onApply: (blockInfo: {
|
||||
content: string
|
||||
filename?: string
|
||||
startLine?: number
|
||||
endLine?: number
|
||||
}) => void
|
||||
children: string
|
||||
isApplying: boolean
|
||||
}) {
|
||||
const blocks: ParsedinfioBlock[] = useMemo(
|
||||
() => parseinfioBlocks(children),
|
||||
[children],
|
||||
)
|
||||
const blocks: ParsedinfioBlock[] = useMemo(
|
||||
() => parseinfioBlocks(children),
|
||||
[children],
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
{blocks.map((block, index) =>
|
||||
block.type === 'string' ? (
|
||||
<Markdown key={index} className="infio-markdown">
|
||||
{block.content}
|
||||
</Markdown>
|
||||
) : block.startLine && block.endLine && block.filename && block.action === 'reference' ? (
|
||||
<MarkdownReferenceBlock
|
||||
key={index}
|
||||
filename={block.filename}
|
||||
startLine={block.startLine}
|
||||
endLine={block.endLine}
|
||||
/>
|
||||
) : (
|
||||
<MarkdownCodeComponent
|
||||
key={index}
|
||||
onApply={onApply}
|
||||
isApplying={isApplying}
|
||||
language={block.language}
|
||||
filename={block.filename}
|
||||
startLine={block.startLine}
|
||||
endLine={block.endLine}
|
||||
action={block.action}
|
||||
>
|
||||
{block.content}
|
||||
</MarkdownCodeComponent>
|
||||
),
|
||||
)}
|
||||
</>
|
||||
)
|
||||
return (
|
||||
<>
|
||||
{blocks.map((block, index) =>
|
||||
block.type === 'string' ? (
|
||||
<Markdown key={index} className="infio-markdown">
|
||||
{block.content}
|
||||
</Markdown>
|
||||
) : block.startLine && block.endLine && block.filename && block.action === 'reference' ? (
|
||||
<MarkdownReferenceBlock
|
||||
key={index}
|
||||
filename={block.filename}
|
||||
startLine={block.startLine}
|
||||
endLine={block.endLine}
|
||||
/>
|
||||
) : (
|
||||
<MarkdownActionBlock
|
||||
key={index}
|
||||
onApply={onApply}
|
||||
isApplying={isApplying}
|
||||
language={block.language}
|
||||
filename={block.filename}
|
||||
startLine={block.startLine}
|
||||
endLine={block.endLine}
|
||||
action={block.action}
|
||||
>
|
||||
{block.content}
|
||||
</MarkdownActionBlock>
|
||||
),
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default React.memo(ReactMarkdown)
|
||||
|
||||
Reference in New Issue
Block a user