@fe-free/core 3.0.44 → 3.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 3.0.46
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: markdown
8
+ - @fe-free/icons@3.0.46
9
+ - @fe-free/tool@3.0.46
10
+
11
+ ## 3.0.45
12
+
13
+ ### Patch Changes
14
+
15
+ - feat: markdown
16
+ - @fe-free/icons@3.0.45
17
+ - @fe-free/tool@3.0.45
18
+
3
19
  ## 3.0.44
4
20
 
5
21
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "3.0.44",
3
+ "version": "3.0.46",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -46,8 +46,8 @@
46
46
  "antd": "^5.27.1",
47
47
  "dayjs": "~1.11.10",
48
48
  "react": "^19.2.0",
49
- "@fe-free/icons": "3.0.44",
50
- "@fe-free/tool": "3.0.44"
49
+ "@fe-free/icons": "3.0.46",
50
+ "@fe-free/tool": "3.0.46"
51
51
  },
52
52
  "scripts": {
53
53
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -18,9 +18,9 @@ function Markdown(props: MarkdownProps) {
18
18
 
19
19
  const newChildren = useMemo(() => {
20
20
  let processed = processWithDeepSeek(children);
21
- processed = processWithKnowledgeRef(processed);
21
+ processed = processWithKnowledgeRef(processed, knowledgeRefs);
22
22
  return processed;
23
- }, [children]);
23
+ }, [children, knowledgeRefs]);
24
24
 
25
25
  const KnowledgeRefComponent = useMemo(
26
26
  () => (p: any) => {
@@ -4,8 +4,6 @@ function KnowledgeRefBlock(props: any) {
4
4
  const { knowledgeRefs, onKnowledgeRef } = props;
5
5
  const id = props['data-id'];
6
6
 
7
- console.log('KnowledgeRefBlock', props);
8
-
9
7
  const handleClick = useCallback(() => {
10
8
  onKnowledgeRef?.(id);
11
9
  }, [id, onKnowledgeRef]);
@@ -15,7 +13,7 @@ function KnowledgeRefBlock(props: any) {
15
13
 
16
14
  // 没有数据的时候显示 id
17
15
  if (index === -1 || index === undefined) {
18
- return <span>[{id}]</span>;
16
+ return <span>[^knowledge:{id}]</span>;
19
17
  }
20
18
 
21
19
  return (
@@ -36,7 +34,7 @@ function KnowledgeRefBlock(props: any) {
36
34
  );
37
35
  }
38
36
 
39
- function processWithKnowledgeRef(text: string) {
37
+ function processWithKnowledgeRef(text: string, knowledgeRefs?: { id: string; title: string }[]) {
40
38
  // 匹配 [^knowledge:X-Y] 格式
41
39
  const knowledgeRefRegex = /\[\^knowledge:(\d+-\d+)\]/g;
42
40
 
@@ -46,7 +44,7 @@ function processWithKnowledgeRef(text: string) {
46
44
  return `<knowledge-ref data-id="${id}">${id}</knowledge-ref>`;
47
45
  });
48
46
 
49
- if (count > 0) {
47
+ if (count > 0 && knowledgeRefs && knowledgeRefs.length > 0) {
50
48
  newText = `${newText}\n<knowledge-ref>来源&gt;&gt;</knowledge>`;
51
49
  }
52
50
 
@@ -513,3 +513,14 @@ export const Knowledge: Story = {
513
513
  },
514
514
  },
515
515
  };
516
+
517
+ export const KnowledgeWithoutData: Story = {
518
+ args: {
519
+ children: `
520
+ 根据检索结果,知识库中包含多个酒店的信息。[^knowledge:1-0]例如:\n\n- **杭州城中香格里拉**:位于杭州长寿路6号,提供多种餐饮选择,包括非凡酒廊、美食汇、城中啤酒餐吧以及城中小馆中餐厅[^knowledge:0-0]。\n- **凯恩斯香格里拉**:位于澳大利亚Pierpoint Road Cairns, Queensland,提供纯正澳式待客之道,靠近马林码头与珊瑚海交汇处[^knowledge:2-0]。\n- **马斯喀特 Al Husn 香格里拉**:位于阿曼P.O. Box 644, Muscat 100,是一个成人专享的世外桃源,拥有私人海滩和海湾[^knowledge:3-0]。\n\n此外,还有一家未直接命名但详细描述了其服务特色的豪华酒店,该酒店以江南丝绸商贸之家为灵感设计,提供独特的入住体验,包括定制贴心体验、精致餐饮及新颖的康养项目[^knowledge:4-0][^knowledge:14-0]。
521
+ `,
522
+ onKnowledgeRef: (id?: string) => {
523
+ console.log('onKnowledgeRef', id);
524
+ },
525
+ },
526
+ };