import React from "react"; import { FunctionType } from "../CodeEditor/interface"; interface IFunctionExplainProps { data: FunctionType | undefined; // 当前选中的函数; handleMouseOver: (e:any, container:string) => void; handleMouseOut: (e:any) => void; } function FunctionExplain(props: IFunctionExplainProps) { const { data,handleMouseOver, handleMouseOut} = props; // 给用法和示例中的函数名添加样式,通过匹配data.label const HighlightKeyword = ({ text, keyword }:{text:string,keyword:string}) => { // 使用正则表达式拆分文本,保留关键字 const parts = text.split(new RegExp(`(${keyword})`, 'g')); return ( <> {parts.map((part:string, index:number) => part&&part.toLowerCase() === keyword.toLowerCase() ? ( // 对关键字应用样式 {part} ) : ( // 非关键字部分保持不变 {part} ) )} ); }; return
handleMouseOver(e, "functionDetail")} onMouseOut={handleMouseOut}> { data&&Object.keys(data).length ? (<> {data?.label&&
{data?.label}
} ) : (
) }
; } export default FunctionExplain;