@fe-free/core 1.4.14 → 1.4.17
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,26 @@
|
|
|
1
1
|
# @fe-free/core
|
|
2
2
|
|
|
3
|
+
## 1.4.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: re
|
|
8
|
+
- @fe-free/tool@1.4.17
|
|
9
|
+
|
|
10
|
+
## 1.4.16
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- feat: modify EditorLogs
|
|
15
|
+
- @fe-free/tool@1.4.16
|
|
16
|
+
|
|
17
|
+
## 1.4.15
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- feat: editor
|
|
22
|
+
- @fe-free/tool@1.4.15
|
|
23
|
+
|
|
3
24
|
## 1.4.14
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"react-syntax-highlighter": "^15.5.0",
|
|
37
37
|
"vanilla-jsoneditor": "^0.23.1",
|
|
38
38
|
"zustand": "^4.5.4",
|
|
39
|
-
"@fe-free/tool": "1.4.
|
|
39
|
+
"@fe-free/tool": "1.4.17"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@ant-design/pro-components": "^2.8.7",
|
|
@@ -39,6 +39,14 @@ export const ReadOnly: Story = {
|
|
|
39
39
|
render: (props) => <BasicDemo {...props} />,
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
export const Wrap: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
value:
|
|
45
|
+
'hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!',
|
|
46
|
+
},
|
|
47
|
+
render: (props) => <BasicDemo {...props} />,
|
|
48
|
+
};
|
|
49
|
+
|
|
42
50
|
// 不可编辑模式
|
|
43
51
|
export const Editable: Story = {
|
|
44
52
|
args: {
|
package/src/editor/index.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { javascript } from '@codemirror/lang-javascript';
|
|
|
2
2
|
import { json } from '@codemirror/lang-json';
|
|
3
3
|
import { markdown } from '@codemirror/lang-markdown';
|
|
4
4
|
import { python } from '@codemirror/lang-python';
|
|
5
|
+
import { EditorView } from '@codemirror/view';
|
|
5
6
|
import { basicDarkInit } from '@uiw/codemirror-theme-basic/dark';
|
|
6
7
|
import type { ReactCodeMirrorProps } from '@uiw/react-codemirror';
|
|
7
8
|
import CodeMirror from '@uiw/react-codemirror';
|
|
@@ -47,7 +48,7 @@ function Editor(props: EditorProps) {
|
|
|
47
48
|
} = props;
|
|
48
49
|
|
|
49
50
|
const extensions = useMemo(() => {
|
|
50
|
-
const result: ReactCodeMirrorProps['extensions'] = [];
|
|
51
|
+
const result: ReactCodeMirrorProps['extensions'] = [EditorView.lineWrapping];
|
|
51
52
|
|
|
52
53
|
if (originExtensions) {
|
|
53
54
|
result.push(...originExtensions);
|
|
@@ -42,6 +42,38 @@ export const Basic: Story = {
|
|
|
42
42
|
message:
|
|
43
43
|
'This is a debug log message. This is a debug log message This is a debug log message This is a debug log message This is a debug log message',
|
|
44
44
|
},
|
|
45
|
+
{
|
|
46
|
+
timestamp: '2023-01-01 12:00:00',
|
|
47
|
+
message: 'This is an log message.',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
level: 'info',
|
|
51
|
+
message: 'This is an log message.',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
message: 'This is an log message.',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
render: (props) => (
|
|
59
|
+
<div style={{ width: '500px', height: '500px' }}>
|
|
60
|
+
<EditorLogs {...props} />
|
|
61
|
+
</div>
|
|
62
|
+
),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const Pure: Story = {
|
|
66
|
+
args: {
|
|
67
|
+
logs: [
|
|
68
|
+
{
|
|
69
|
+
message: 'This is an info log message.',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
message: 'This is a warning log message.',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
message: 'This is an error log message.',
|
|
76
|
+
},
|
|
45
77
|
],
|
|
46
78
|
},
|
|
47
79
|
render: (props) => (
|
|
@@ -6,19 +6,35 @@ import { Editor } from '../editor';
|
|
|
6
6
|
|
|
7
7
|
interface EditorLogsProps {
|
|
8
8
|
logs: {
|
|
9
|
-
timestamp
|
|
10
|
-
level
|
|
9
|
+
timestamp?: string;
|
|
10
|
+
level?: 'info' | 'warn' | 'error' | 'system';
|
|
11
11
|
message: string;
|
|
12
12
|
}[];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const EditorLogs: React.FC<EditorLogsProps> = ({ logs }) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const notPure = logs.find((item) => item.timestamp || item.level);
|
|
17
|
+
|
|
18
|
+
let formattedLogs = '';
|
|
19
|
+
if (notPure) {
|
|
20
|
+
formattedLogs = logs
|
|
21
|
+
.map((log) => {
|
|
22
|
+
const arr: string[] = [];
|
|
23
|
+
|
|
24
|
+
arr.push((log.timestamp || '').padEnd(19, ' '));
|
|
25
|
+
|
|
26
|
+
arr.push(`[${log.level || ''}]`.padEnd(8, ' ').toUpperCase());
|
|
27
|
+
|
|
28
|
+
if (log.message) {
|
|
29
|
+
arr.push(log.message);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return arr.join(' ');
|
|
33
|
+
})
|
|
34
|
+
.join('\n');
|
|
35
|
+
} else {
|
|
36
|
+
formattedLogs = logs.map((log) => log.message).join('\n');
|
|
37
|
+
}
|
|
22
38
|
|
|
23
39
|
const logExtension = [
|
|
24
40
|
StreamLanguage.define({
|