@fe-free/core 1.4.12 → 1.4.13

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,12 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 1.4.13
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: ProFormEditor
8
+ - @fe-free/tool@1.4.13
9
+
3
10
  ## 1.4.12
4
11
 
5
12
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "1.4.12",
3
+ "version": "1.4.13",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -35,7 +35,7 @@
35
35
  "react-syntax-highlighter": "^15.5.0",
36
36
  "vanilla-jsoneditor": "^0.23.1",
37
37
  "zustand": "^4.5.4",
38
- "@fe-free/tool": "1.4.12"
38
+ "@fe-free/tool": "1.4.13"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@ant-design/pro-components": "^2.8.7",
package/src/crud/crud.tsx CHANGED
@@ -205,13 +205,13 @@ function CRUDComponent<
205
205
  tableProps.columns,
206
206
  operateColumnProps,
207
207
  actions,
208
+ deleteProps,
208
209
  handleReload,
209
210
  readProps?.operateText,
210
211
  readProps?.target,
211
212
  detailProps,
212
213
  detailIdIndex,
213
- updateProps?.operateText,
214
- deleteProps,
214
+ updateProps,
215
215
  getHandleDelete,
216
216
  ]);
217
217
 
@@ -15,6 +15,9 @@ interface EditorProps {
15
15
  readOnly?: boolean;
16
16
  editable?: boolean;
17
17
 
18
+ height?: string;
19
+ width?: string;
20
+
18
21
  // 不对外
19
22
  theme?: ReactCodeMirrorProps['theme'];
20
23
  extensions?: ReactCodeMirrorProps['extensions'];
@@ -29,6 +32,8 @@ function Editor(props: EditorProps) {
29
32
  editable,
30
33
  autoFocus,
31
34
  placeholder,
35
+ height,
36
+ width,
32
37
  theme,
33
38
  extensions: originExtensions,
34
39
  } = props;
@@ -70,8 +75,8 @@ function Editor(props: EditorProps) {
70
75
  return (
71
76
  <CodeMirror
72
77
  className="w-full h-full"
73
- height="100%"
74
- width="100%"
78
+ height={height || '100%'}
79
+ width={width || '100%'}
75
80
  value={value}
76
81
  onChange={handleChange}
77
82
  extensions={extensions}
@@ -1,5 +1,5 @@
1
1
  import { ProForm } from '@ant-design/pro-components';
2
- import { ProFormJSON, ProFormJavascript, ProFormSwitchNumber } from '@fe-free/core';
2
+ import { ProFormEditor, ProFormJSON, ProFormJavascript, ProFormSwitchNumber } from '@fe-free/core';
3
3
  import type { Meta, StoryObj } from '@storybook/react';
4
4
  import { useState } from 'react';
5
5
 
@@ -37,6 +37,20 @@ function ProFormBase({
37
37
  );
38
38
  }
39
39
 
40
+ export const ProFormEditorComponent: Story = {
41
+ render: () => (
42
+ <ProFormBase
43
+ initialValues={{
44
+ code: `const name = 'world';
45
+ console.log('hello', name);
46
+ `,
47
+ }}
48
+ >
49
+ <ProFormEditor name="code" fieldProps={{ language: 'javascript', height: '50vh' }} />
50
+ </ProFormBase>
51
+ ),
52
+ };
53
+
40
54
  // ProFormJSON 基础示例
41
55
  export const ProFormJSONComponent: Story = {
42
56
  render: () => (
@@ -1,3 +1,4 @@
1
+ export { ProFormEditor } from './pro_form_editor';
1
2
  export { ProFormJavascript } from './pro_form_javascript';
2
3
  export { ProFormJSON } from './pro_form_json';
3
4
  export {
@@ -5,6 +6,7 @@ export {
5
6
  SwitchNumber,
6
7
  type SwitchNumberProps,
7
8
  } from './pro_form_switch_number';
9
+
8
10
  import { pinyinMatch } from '@fe-free/tool';
9
11
 
10
12
  /** ProFromSelect 搜索相关 props。 支持 1 搜索 2 拼音过滤 */
@@ -0,0 +1,21 @@
1
+ import type { ProFormItemProps } from '@ant-design/pro-components';
2
+ import { ProForm } from '@ant-design/pro-components';
3
+ import type { EditorProps } from '../editor';
4
+ import { Editor } from '../editor';
5
+
6
+ function EditorItem(props: EditorProps) {
7
+ return <Editor height="300px" {...props} />;
8
+ }
9
+
10
+ function ProFormEditor(props: ProFormItemProps<EditorProps>) {
11
+ /* eslint-disable-next-line */
12
+ const { fieldProps, readonly, ...rest } = props;
13
+
14
+ return (
15
+ <ProForm.Item {...rest}>
16
+ <EditorItem readOnly={readonly} {...(fieldProps as EditorProps)} />
17
+ </ProForm.Item>
18
+ );
19
+ }
20
+
21
+ export { ProFormEditor };
package/src/index.ts CHANGED
@@ -18,6 +18,7 @@ export { EditorMarkdown } from './editor_markdown';
18
18
  export type { EditorMarkdownProps } from './editor_markdown';
19
19
 
20
20
  export {
21
+ ProFormEditor,
21
22
  ProFormJSON,
22
23
  ProFormJavascript,
23
24
  ProFormSwitchNumber,