@fe-free/core 1.6.1 → 2.0.0
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 +10 -0
- package/package.json +2 -3
- package/src/editor_json/editor_json.stories.tsx +60 -76
- package/src/form/pro_form_javascript.tsx +6 -6
- package/src/index.ts +0 -4
- package/src/editor_javascript/editor_javascript.stories.tsx +0 -50
- package/src/editor_javascript/index.tsx +0 -38
- package/src/editor_markdown/editor_markdown.stories.tsx +0 -32
- package/src/editor_markdown/index.tsx +0 -40
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"@uiw/codemirror-theme-basic": "^4.23.12",
|
|
26
26
|
"@uiw/codemirror-themes": "^4.23.12",
|
|
27
27
|
"@uiw/react-codemirror": "^4.23.12",
|
|
28
|
-
"ace-builds": "^1.33.1",
|
|
29
28
|
"ahooks": "^3.7.8",
|
|
30
29
|
"axios": "^1.6.5",
|
|
31
30
|
"classnames": "^2.5.1",
|
|
@@ -39,7 +38,7 @@
|
|
|
39
38
|
"remark-gfm": "^4.0.1",
|
|
40
39
|
"vanilla-jsoneditor": "^0.23.1",
|
|
41
40
|
"zustand": "^4.5.4",
|
|
42
|
-
"@fe-free/tool": "
|
|
41
|
+
"@fe-free/tool": "2.0.0"
|
|
43
42
|
},
|
|
44
43
|
"peerDependencies": {
|
|
45
44
|
"@ant-design/pro-components": "^2.8.7",
|
|
@@ -11,94 +11,78 @@ const meta: Meta<typeof EditorJSON> = {
|
|
|
11
11
|
export default meta;
|
|
12
12
|
type Story = StoryObj<typeof EditorJSON>;
|
|
13
13
|
|
|
14
|
-
// 基础示例
|
|
15
|
-
const BasicDemo = () => {
|
|
16
|
-
const [value, setValue] = useState(
|
|
17
|
-
JSON.stringify(
|
|
18
|
-
{
|
|
19
|
-
name: 'world',
|
|
20
|
-
},
|
|
21
|
-
null,
|
|
22
|
-
2,
|
|
23
|
-
),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<div style={{ width: '500px', height: '500px' }}>
|
|
28
|
-
<EditorJSON value={value} onChange={setValue} />
|
|
29
|
-
</div>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
14
|
export const Basic: Story = {
|
|
34
|
-
render: () =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// 只读模式
|
|
38
|
-
const ReadonlyDemo = () => {
|
|
39
|
-
const [value, setValue] = useState(
|
|
40
|
-
JSON.stringify(
|
|
41
|
-
{
|
|
15
|
+
render: (args) => {
|
|
16
|
+
const [value, setValue] = useState(
|
|
17
|
+
JSON.stringify({
|
|
42
18
|
name: 'world',
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
2,
|
|
46
|
-
),
|
|
47
|
-
);
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
48
21
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
22
|
+
return (
|
|
23
|
+
<div style={{ width: '500px', height: '500px' }}>
|
|
24
|
+
<EditorJSON {...args} value={value} onChange={setValue} />
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
},
|
|
54
28
|
};
|
|
55
29
|
|
|
56
30
|
export const Readonly: Story = {
|
|
57
|
-
render: () =>
|
|
58
|
-
|
|
31
|
+
render: () => {
|
|
32
|
+
const [value, setValue] = useState(
|
|
33
|
+
JSON.stringify(
|
|
34
|
+
{
|
|
35
|
+
name: 'world',
|
|
36
|
+
},
|
|
37
|
+
null,
|
|
38
|
+
2,
|
|
39
|
+
),
|
|
40
|
+
);
|
|
59
41
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
null,
|
|
68
|
-
2,
|
|
69
|
-
),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<div style={{ width: '500px', height: '500px' }}>
|
|
74
|
-
<EditorJSON value={value} onChange={setValue} mode="tree" readonly />
|
|
75
|
-
</div>
|
|
76
|
-
);
|
|
42
|
+
return (
|
|
43
|
+
<div style={{ width: '500px', height: '500px' }}>
|
|
44
|
+
<EditorJSON value={value} onChange={setValue} readonly />
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
77
48
|
};
|
|
78
49
|
|
|
79
50
|
export const TreeMode: Story = {
|
|
80
|
-
render: () =>
|
|
81
|
-
|
|
51
|
+
render: () => {
|
|
52
|
+
const [value, setValue] = useState(
|
|
53
|
+
JSON.stringify(
|
|
54
|
+
{
|
|
55
|
+
name: 'world',
|
|
56
|
+
},
|
|
57
|
+
null,
|
|
58
|
+
2,
|
|
59
|
+
),
|
|
60
|
+
);
|
|
82
61
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
null,
|
|
91
|
-
2,
|
|
92
|
-
),
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<div style={{ width: '500px', height: '500px' }}>
|
|
97
|
-
<EditorJSON value={value} onChange={setValue} readonly mode="tree" mainMenuBar={false} />
|
|
98
|
-
</div>
|
|
99
|
-
);
|
|
62
|
+
return (
|
|
63
|
+
<div style={{ width: '500px', height: '500px' }}>
|
|
64
|
+
<EditorJSON value={value} onChange={setValue} mode="tree" readonly />
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
},
|
|
100
68
|
};
|
|
101
69
|
|
|
102
70
|
export const NoMenuBar: Story = {
|
|
103
|
-
render: () =>
|
|
71
|
+
render: () => {
|
|
72
|
+
const [value, setValue] = useState(
|
|
73
|
+
JSON.stringify(
|
|
74
|
+
{
|
|
75
|
+
name: 'world',
|
|
76
|
+
},
|
|
77
|
+
null,
|
|
78
|
+
2,
|
|
79
|
+
),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div style={{ width: '500px', height: '500px' }}>
|
|
84
|
+
<EditorJSON value={value} onChange={setValue} readonly mode="tree" mainMenuBar={false} />
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
},
|
|
104
88
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { ProFormItemProps } from '@ant-design/pro-components';
|
|
2
2
|
import { ProForm } from '@ant-design/pro-components';
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
3
|
+
import type { EditorProps } from '../editor';
|
|
4
|
+
import { Editor } from '../editor';
|
|
5
5
|
|
|
6
|
-
function JavascriptItem(props:
|
|
6
|
+
function JavascriptItem(props: EditorProps) {
|
|
7
7
|
return (
|
|
8
8
|
<div style={{ height: '300px' }}>
|
|
9
|
-
<
|
|
9
|
+
<Editor {...props} language="javascript" />
|
|
10
10
|
</div>
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function ProFormJavascript(props: ProFormItemProps<
|
|
14
|
+
function ProFormJavascript(props: ProFormItemProps<EditorProps>) {
|
|
15
15
|
const { fieldProps, ...rest } = props;
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
18
|
<ProForm.Item {...rest}>
|
|
19
|
-
<JavascriptItem {...(fieldProps as
|
|
19
|
+
<JavascriptItem {...(fieldProps as EditorProps)} />
|
|
20
20
|
</ProForm.Item>
|
|
21
21
|
);
|
|
22
22
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,14 +5,10 @@ export { CRUD, CRUDDetail, CRUDOfSimple, OperateDelete, useDelete } from './crud
|
|
|
5
5
|
export type { CRUDDetailProps, CRUDMethods, CRUDOfSimpleProps, CRUDProps } from './crud';
|
|
6
6
|
export { Editor } from './editor';
|
|
7
7
|
export type { EditorProps } from './editor';
|
|
8
|
-
export { EditorJavascript } from './editor_javascript';
|
|
9
|
-
export type { EditorJavascriptProps } from './editor_javascript';
|
|
10
8
|
export { EditorJSON } from './editor_json';
|
|
11
9
|
export type { EditorJSONProps } from './editor_json';
|
|
12
10
|
export { EditorLogs } from './editor_logs';
|
|
13
11
|
export type { EditorLogsProps } from './editor_logs';
|
|
14
|
-
export { EditorMarkdown } from './editor_markdown';
|
|
15
|
-
export type { EditorMarkdownProps } from './editor_markdown';
|
|
16
12
|
export {
|
|
17
13
|
ProFormEditor,
|
|
18
14
|
ProFormJSON,
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { EditorJavascript } from '@fe-free/core';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof EditorJavascript> = {
|
|
6
|
-
title: '@fe-free/core/EditorJavascript',
|
|
7
|
-
component: EditorJavascript,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default meta;
|
|
12
|
-
type Story = StoryObj<typeof EditorJavascript>;
|
|
13
|
-
|
|
14
|
-
// 常规示例
|
|
15
|
-
const BasicDemo = () => {
|
|
16
|
-
const [value, setValue] = useState(
|
|
17
|
-
`const name = 'world';
|
|
18
|
-
console.log('hello', name);
|
|
19
|
-
`,
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div style={{ width: '500px', height: '500px' }}>
|
|
24
|
-
<EditorJavascript value={value} onChange={setValue} />
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const Basic: Story = {
|
|
30
|
-
render: () => <BasicDemo />,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// readonly 示例
|
|
34
|
-
const ReadonlyDemo = () => {
|
|
35
|
-
const [value, setValue] = useState(
|
|
36
|
-
`const name = 'world';
|
|
37
|
-
console.log('hello', name);
|
|
38
|
-
`,
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<div style={{ width: '500px', height: '500px' }}>
|
|
43
|
-
<EditorJavascript value={value} onChange={setValue} readonly />
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const Readonly: Story = {
|
|
49
|
-
render: () => <ReadonlyDemo />,
|
|
50
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import AceEditor from 'react-ace';
|
|
2
|
-
|
|
3
|
-
import 'ace-builds/src-noconflict/ext-language_tools';
|
|
4
|
-
import 'ace-builds/src-noconflict/mode-javascript';
|
|
5
|
-
import 'ace-builds/src-noconflict/theme-monokai';
|
|
6
|
-
|
|
7
|
-
const fullStyle = { width: '100%', height: '100%' };
|
|
8
|
-
|
|
9
|
-
interface EditorJavascriptProps {
|
|
10
|
-
value: string;
|
|
11
|
-
onChange?: (value: string, event?: any) => void;
|
|
12
|
-
readonly?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function EditorJavascript({ value, onChange, readonly }: EditorJavascriptProps) {
|
|
16
|
-
return (
|
|
17
|
-
<AceEditor
|
|
18
|
-
style={fullStyle}
|
|
19
|
-
mode="javascript"
|
|
20
|
-
theme="monokai"
|
|
21
|
-
value={value}
|
|
22
|
-
onChange={onChange}
|
|
23
|
-
readOnly={readonly}
|
|
24
|
-
name="javascript_editor"
|
|
25
|
-
editorProps={{ $blockScrolling: true }}
|
|
26
|
-
setOptions={{
|
|
27
|
-
enableBasicAutocompletion: true,
|
|
28
|
-
enableLiveAutocompletion: true,
|
|
29
|
-
enableSnippets: true,
|
|
30
|
-
showLineNumbers: true,
|
|
31
|
-
tabSize: 2,
|
|
32
|
-
}}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { EditorJavascript };
|
|
38
|
-
export type { EditorJavascriptProps };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { EditorMarkdown } from '@fe-free/core';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof EditorMarkdown> = {
|
|
6
|
-
title: '@fe-free/core/EditorMarkdown',
|
|
7
|
-
component: EditorMarkdown,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default meta;
|
|
12
|
-
type Story = StoryObj<typeof EditorMarkdown>;
|
|
13
|
-
|
|
14
|
-
// 常规示例
|
|
15
|
-
const BasicDemo = () => {
|
|
16
|
-
const [value] = useState(
|
|
17
|
-
`# hello
|
|
18
|
-
|
|
19
|
-
world
|
|
20
|
-
`,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div style={{ width: '500px', height: '500px' }}>
|
|
25
|
-
<EditorMarkdown value={value} />
|
|
26
|
-
</div>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const Basic: Story = {
|
|
31
|
-
render: () => <BasicDemo />,
|
|
32
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import Markdown from 'react-markdown';
|
|
2
|
-
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
3
|
-
|
|
4
|
-
interface EditorMarkdownProps {
|
|
5
|
-
value: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function EditorMarkdown({ value }: EditorMarkdownProps) {
|
|
9
|
-
return (
|
|
10
|
-
<Markdown
|
|
11
|
-
unwrapDisallowed
|
|
12
|
-
components={{
|
|
13
|
-
code(props) {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
|
-
const { children, className, node, ...rest } = props;
|
|
16
|
-
const match = /language-(\w+)/.exec(className || '');
|
|
17
|
-
return match ? (
|
|
18
|
-
<SyntaxHighlighter
|
|
19
|
-
{...rest}
|
|
20
|
-
PreTag="div"
|
|
21
|
-
wrapLongLines
|
|
22
|
-
// eslint-disable-next-line react/no-children-prop
|
|
23
|
-
children={String(children).replace(/\n$/, '')}
|
|
24
|
-
language={match[1].toLowerCase()}
|
|
25
|
-
/>
|
|
26
|
-
) : (
|
|
27
|
-
<code {...rest} className={className}>
|
|
28
|
-
{children}
|
|
29
|
-
</code>
|
|
30
|
-
);
|
|
31
|
-
},
|
|
32
|
-
}}
|
|
33
|
-
>
|
|
34
|
-
{value || ''}
|
|
35
|
-
</Markdown>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { EditorMarkdown };
|
|
40
|
-
export type { EditorMarkdownProps };
|