balibabu
commited on
Commit
·
6eec14a
1
Parent(s):
9c1ae34
feat: Wrap the searched chunk with a Popover #2247 (#2398)
Browse files### What problem does this PR solve?
feat: Wrap the searched chunk with a Popover #2247
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- web/src/components/highlight-markdown/index.tsx +4 -1
- web/src/components/image/index.less +6 -1
- web/src/components/image/index.tsx +2 -1
- web/src/locales/en.ts +1 -0
- web/src/locales/zh-traditional.ts +2 -1
- web/src/locales/zh.ts +1 -0
- web/src/pages/search/index.less +6 -0
- web/src/pages/search/index.tsx +17 -4
web/src/components/highlight-markdown/index.tsx
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import Markdown from 'react-markdown';
|
2 |
import SyntaxHighlighter from 'react-syntax-highlighter';
|
3 |
import rehypeRaw from 'rehype-raw';
|
@@ -7,14 +8,16 @@ import styles from './index.less';
|
|
7 |
|
8 |
const HightLightMarkdown = ({
|
9 |
children,
|
|
|
10 |
}: {
|
11 |
children: string | null | undefined;
|
|
|
12 |
}) => {
|
13 |
return (
|
14 |
<Markdown
|
15 |
remarkPlugins={[remarkGfm]}
|
16 |
rehypePlugins={[rehypeRaw]}
|
17 |
-
className={styles.text}
|
18 |
components={
|
19 |
{
|
20 |
code(props: any) {
|
|
|
1 |
+
import classNames from 'classnames';
|
2 |
import Markdown from 'react-markdown';
|
3 |
import SyntaxHighlighter from 'react-syntax-highlighter';
|
4 |
import rehypeRaw from 'rehype-raw';
|
|
|
8 |
|
9 |
const HightLightMarkdown = ({
|
10 |
children,
|
11 |
+
className,
|
12 |
}: {
|
13 |
children: string | null | undefined;
|
14 |
+
className?: string;
|
15 |
}) => {
|
16 |
return (
|
17 |
<Markdown
|
18 |
remarkPlugins={[remarkGfm]}
|
19 |
rehypePlugins={[rehypeRaw]}
|
20 |
+
className={classNames(styles.text, className)}
|
21 |
components={
|
22 |
{
|
23 |
code(props: any) {
|
web/src/components/image/index.less
CHANGED
@@ -1,5 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
.image {
|
2 |
-
width: 100px;
|
3 |
object-fit: contain;
|
4 |
}
|
5 |
|
|
|
1 |
+
.primitiveImg {
|
2 |
+
display: inline-block;
|
3 |
+
max-height: 100px;
|
4 |
+
}
|
5 |
+
|
6 |
.image {
|
7 |
+
max-width: 100px;
|
8 |
object-fit: contain;
|
9 |
}
|
10 |
|
web/src/components/image/index.tsx
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import { api_host } from '@/utils/api';
|
2 |
import { Popover } from 'antd';
|
|
|
3 |
|
4 |
import styles from './index.less';
|
5 |
|
@@ -14,7 +15,7 @@ const Image = ({ id, className, ...props }: IImage) => {
|
|
14 |
{...props}
|
15 |
src={`${api_host}/document/image/${id}`}
|
16 |
alt=""
|
17 |
-
className={className}
|
18 |
/>
|
19 |
);
|
20 |
};
|
|
|
1 |
import { api_host } from '@/utils/api';
|
2 |
import { Popover } from 'antd';
|
3 |
+
import classNames from 'classnames';
|
4 |
|
5 |
import styles from './index.less';
|
6 |
|
|
|
15 |
{...props}
|
16 |
src={`${api_host}/document/image/${id}`}
|
17 |
alt=""
|
18 |
+
className={classNames(styles.primitiveImg, className)}
|
19 |
/>
|
20 |
);
|
21 |
};
|
web/src/locales/en.ts
CHANGED
@@ -431,6 +431,7 @@ The above is the content you need to summarize.`,
|
|
431 |
tts: 'Text to speech',
|
432 |
ttsTip:
|
433 |
'To play the voice using voice conversion, please select TTS (speech conversion model) in the settings first.',
|
|
|
434 |
},
|
435 |
setting: {
|
436 |
profile: 'Profile',
|
|
|
431 |
tts: 'Text to speech',
|
432 |
ttsTip:
|
433 |
'To play the voice using voice conversion, please select TTS (speech conversion model) in the settings first.',
|
434 |
+
relatedQuestion: 'Related question',
|
435 |
},
|
436 |
setting: {
|
437 |
profile: 'Profile',
|
web/src/locales/zh-traditional.ts
CHANGED
@@ -400,6 +400,7 @@ export default {
|
|
400 |
read: '朗讀內容',
|
401 |
tts: '文字轉語音',
|
402 |
ttsTip: '是否用語音轉換播放語音,請先在設定裡面選擇TTS(語音轉換模型)。',
|
|
|
403 |
},
|
404 |
setting: {
|
405 |
profile: '概述',
|
@@ -832,7 +833,7 @@ export default {
|
|
832 |
wenCai: '問財',
|
833 |
queryType: '查詢類型',
|
834 |
wenCaiDescription:
|
835 |
-
'
|
836 |
wenCaiQueryTypeOptions: {
|
837 |
stock: '股票',
|
838 |
zhishu: '指數',
|
|
|
400 |
read: '朗讀內容',
|
401 |
tts: '文字轉語音',
|
402 |
ttsTip: '是否用語音轉換播放語音,請先在設定裡面選擇TTS(語音轉換模型)。',
|
403 |
+
relatedQuestion: '相關問題',
|
404 |
},
|
405 |
setting: {
|
406 |
profile: '概述',
|
|
|
833 |
wenCai: '問財',
|
834 |
queryType: '查詢類型',
|
835 |
wenCaiDescription:
|
836 |
+
'該組件可用於獲取廣泛的金融領域的o息,包括但不限於股票、基金等...',
|
837 |
wenCaiQueryTypeOptions: {
|
838 |
stock: '股票',
|
839 |
zhishu: '指數',
|
web/src/locales/zh.ts
CHANGED
@@ -417,6 +417,7 @@ export default {
|
|
417 |
read: '朗读内容',
|
418 |
tts: '文本转语音',
|
419 |
ttsTip: '是否用语音转换播放语音,请先在设置里面选择TTS(语音转换模型)。',
|
|
|
420 |
},
|
421 |
setting: {
|
422 |
profile: '概要',
|
|
|
417 |
read: '朗读内容',
|
418 |
tts: '文本转语音',
|
419 |
ttsTip: '是否用语音转换播放语音,请先在设置里面选择TTS(语音转换模型)。',
|
420 |
+
relatedQuestion: '相关问题',
|
421 |
},
|
422 |
setting: {
|
423 |
profile: '概要',
|
web/src/pages/search/index.less
CHANGED
@@ -168,3 +168,9 @@
|
|
168 |
background-position: 200% center;
|
169 |
}
|
170 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
background-position: 200% center;
|
169 |
}
|
170 |
}
|
171 |
+
|
172 |
+
.popupMarkdown {
|
173 |
+
width: 60vw;
|
174 |
+
max-height: 40vh;
|
175 |
+
overflow: auto;
|
176 |
+
}
|
web/src/pages/search/index.tsx
CHANGED
@@ -19,6 +19,7 @@ import {
|
|
19 |
List,
|
20 |
Pagination,
|
21 |
PaginationProps,
|
|
|
22 |
Skeleton,
|
23 |
Space,
|
24 |
Tag,
|
@@ -150,9 +151,21 @@ const SearchPage = () => {
|
|
150 |
<ImageWithPopover
|
151 |
id={item.img_id}
|
152 |
></ImageWithPopover>
|
153 |
-
<
|
154 |
-
{
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
</Space>
|
157 |
</Card>
|
158 |
</List.Item>
|
@@ -160,7 +173,7 @@ const SearchPage = () => {
|
|
160 |
/>
|
161 |
)}
|
162 |
{relatedQuestions?.length > 0 && (
|
163 |
-
<Card>
|
164 |
<Flex wrap="wrap" gap={'10px 0'}>
|
165 |
{relatedQuestions?.map((x, idx) => (
|
166 |
<Tag
|
|
|
19 |
List,
|
20 |
Pagination,
|
21 |
PaginationProps,
|
22 |
+
Popover,
|
23 |
Skeleton,
|
24 |
Space,
|
25 |
Tag,
|
|
|
151 |
<ImageWithPopover
|
152 |
id={item.img_id}
|
153 |
></ImageWithPopover>
|
154 |
+
<Popover
|
155 |
+
content={
|
156 |
+
<div className={styles.popupMarkdown}>
|
157 |
+
<HightLightMarkdown>
|
158 |
+
{item.content_with_weight}
|
159 |
+
</HightLightMarkdown>
|
160 |
+
</div>
|
161 |
+
}
|
162 |
+
>
|
163 |
+
<div>
|
164 |
+
<HightLightMarkdown>
|
165 |
+
{item.highlight}
|
166 |
+
</HightLightMarkdown>
|
167 |
+
</div>
|
168 |
+
</Popover>
|
169 |
</Space>
|
170 |
</Card>
|
171 |
</List.Item>
|
|
|
173 |
/>
|
174 |
)}
|
175 |
{relatedQuestions?.length > 0 && (
|
176 |
+
<Card title={t('chat.relatedQuestion')}>
|
177 |
<Flex wrap="wrap" gap={'10px 0'}>
|
178 |
{relatedQuestions?.map((x, idx) => (
|
179 |
<Tag
|