@fe-free/core 4.1.40 → 4.1.42

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.
@@ -31,21 +31,23 @@ function Render(text, props: ProFormItemProps<JSONModalProps>) {
31
31
  return (
32
32
  <>
33
33
  <a onClick={() => setShow(true)}>{title}</a>
34
- <Modal
35
- title={title}
36
- open={show}
37
- onCancel={() => setShow(false)}
38
- onOk={() => setShow(false)}
39
- cancelButtonProps={{
40
- style: {
41
- display: 'none',
42
- },
43
- }}
44
- >
45
- <div className="h-[500px]">
46
- <EditorJSON value={jsonText} readonly />
47
- </div>
48
- </Modal>
34
+ {show && (
35
+ <Modal
36
+ title={title}
37
+ open
38
+ onCancel={() => setShow(false)}
39
+ onOk={() => setShow(false)}
40
+ cancelButtonProps={{
41
+ style: {
42
+ display: 'none',
43
+ },
44
+ }}
45
+ >
46
+ <div className="h-[500px]">
47
+ <EditorJSON value={jsonText} readonly />
48
+ </div>
49
+ </Modal>
50
+ )}
49
51
  </>
50
52
  );
51
53
  }
@@ -0,0 +1,44 @@
1
+ import { Modal } from 'antd';
2
+ import { useState } from 'react';
3
+ import { Markdown } from '../markdown';
4
+
5
+ function Render(text) {
6
+ const [show, setShow] = useState(false);
7
+
8
+ if (!text) {
9
+ return <div>-</div>;
10
+ }
11
+
12
+ return (
13
+ <>
14
+ <div onClick={() => setShow(true)} className="flex cursor-pointer items-center">
15
+ <div className="truncate">{text}</div>
16
+ <span className="text-primary">查看</span>
17
+ </div>
18
+ {show && (
19
+ <Modal
20
+ title="Markdown"
21
+ open
22
+ onCancel={() => setShow(false)}
23
+ onOk={() => setShow(false)}
24
+ cancelButtonProps={{
25
+ style: {
26
+ display: 'none',
27
+ },
28
+ }}
29
+ >
30
+ <div className="h-[500px]">
31
+ <Markdown content={text} />
32
+ </div>
33
+ </Modal>
34
+ )}
35
+ </>
36
+ );
37
+ }
38
+
39
+ const markdownModalRender = {
40
+ render: Render,
41
+ renderFormItem: () => <></>,
42
+ };
43
+
44
+ export { markdownModalRender };
@@ -25,6 +25,7 @@ async function fakeRequest() {
25
25
  dateNumber: +dayjs('2024-10-01'),
26
26
  seconds: Math.abs(+dayjs('2024-10-01') / 1000),
27
27
  jsonText: JSON.stringify({ name: 'hello world hello world hello world' }),
28
+ markdownText: `# Hello World\n\nThis is a markdown text.`,
28
29
  switchNumber: Math.random() > 0.5 ? 1 : 0,
29
30
  switchOptions: Math.random() > 0.5 ? 'ON' : 'OFF',
30
31
  }));
@@ -84,6 +85,12 @@ const Table = () => {
84
85
  ellipsis: true,
85
86
  valueType: CustomValueTypeEnum.CustomJSONModal,
86
87
  },
88
+ {
89
+ title: 'markdownModal',
90
+ dataIndex: 'markdownText',
91
+ ellipsis: true,
92
+ valueType: CustomValueTypeEnum.CustomMarkdownModal,
93
+ },
87
94
  {
88
95
  title: '开关 number',
89
96
  dataIndex: 'switchNumber',
@@ -104,6 +111,7 @@ const Table = () => {
104
111
  <CRUD
105
112
  actions={[]}
106
113
  tableProps={{
114
+ rowKey: 'id',
107
115
  columns,
108
116
  request: fakeRequest,
109
117
  }}
@@ -1,53 +0,0 @@
1
- import { DownOutlined, UpOutlined } from '@fe-free/icons';
2
- import { useState } from 'react';
3
-
4
- function DeepSeekBlock(props: { children: string }) {
5
- const [show, setShow] = useState(true);
6
-
7
- return (
8
- <div className="markdown-body-block-deep-seek mb-3 flex flex-col gap-2 text-[12px] text-03">
9
- <div
10
- className="cursor-pointer"
11
- onClick={() => {
12
- setShow((v) => !v);
13
- }}
14
- >
15
- 深度思考 {show ? <UpOutlined /> : <DownOutlined />}
16
- </div>
17
- {show && (
18
- <div className="relative pl-[15px]">
19
- <div className="top=0 absolute left-0 h-full w-[2px] bg-[#00000014]" />
20
- {props.children === '<br/>' ? undefined : props.children}
21
- </div>
22
- )}
23
- </div>
24
- );
25
- }
26
-
27
- function processWithDeepSeek(text: string) {
28
- // 开始 <think> 才算开始
29
- if (!text.startsWith('<think>')) {
30
- return text;
31
- }
32
-
33
- const [left, right] = text.split('</think>');
34
-
35
- let newText = text;
36
-
37
- // 如果 think 部分是 <think>\n\n</think>,相当于没有,则直接返回 right
38
- if (text.startsWith('<think>\n\n</think>')) {
39
- newText = right;
40
- }
41
- // 否则做一些处理
42
- else {
43
- newText =
44
- left
45
- .replace('<think>\n', '<think>')
46
- .replace('\n</think>', '</think>')
47
- .replace(/\n/g, '<br/>') + (right || '');
48
- }
49
-
50
- return newText;
51
- }
52
-
53
- export { DeepSeekBlock, processWithDeepSeek };
@@ -1,46 +0,0 @@
1
- .markdown-body {
2
- font-size: 14px;
3
-
4
- pre {
5
- padding: 0;
6
- }
7
-
8
- .markdown-body-block-code {
9
- margin: 0.5rem 0;
10
-
11
- & > div {
12
- margin: 0 !important;
13
- }
14
- }
15
-
16
- .markdown-body-block-chart {
17
- background: white;
18
- border-radius: 6px;
19
- margin: 0.5rem;
20
-
21
- .markdown-body-block-chart-title {
22
- font-size: 16px;
23
- font-weight: bold;
24
- padding: 10px;
25
- }
26
- }
27
-
28
- .markdown-body-block-knowledge-ref[data-id] {
29
- height: 16px;
30
- min-width: 16px;
31
- cursor: pointer;
32
- display: inline-flex;
33
- align-items: center;
34
- justify-content: center;
35
- border-radius: 999px;
36
- border: 1px solid #0374e9;
37
- color: #0374e9;
38
- font-size: 12px;
39
- padding: 0 4px;
40
- }
41
-
42
- .markdown-body-block-knowledge-ref-source {
43
- color: #0374e9;
44
- cursor: pointer;
45
- }
46
- }