mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00

* perf: input guide code * perf: input guide ui * Chat input guide api * Update app chat config store * perf: app chat config field * perf: app context * perf: params * fix: ts * perf: filter private config * perf: filter private config * perf: import workflow * perf: limit max tip amount
41 lines
868 B
TypeScript
41 lines
868 B
TypeScript
import { Box } from '@chakra-ui/react';
|
|
import React from 'react';
|
|
|
|
const HighlightText = ({
|
|
rawText,
|
|
matchText,
|
|
color = 'primary.600'
|
|
}: {
|
|
rawText: string;
|
|
matchText: string;
|
|
color?: string;
|
|
}) => {
|
|
const regex = new RegExp(`(${matchText})`, 'gi');
|
|
const parts = rawText.split(regex);
|
|
|
|
return (
|
|
<Box>
|
|
{parts.map((part, index) => {
|
|
let highLight = part.toLowerCase() === matchText.toLowerCase();
|
|
|
|
if (highLight) {
|
|
parts.find((item, i) => {
|
|
if (i >= index) return;
|
|
if (item.toLowerCase() === matchText.toLowerCase()) {
|
|
highLight = false;
|
|
}
|
|
});
|
|
}
|
|
|
|
return (
|
|
<Box as="span" key={index} color={highLight ? color : 'inherit'}>
|
|
{part}
|
|
</Box>
|
|
);
|
|
})}
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
export default HighlightText;
|