@fe-free/core 4.1.2 → 4.1.4

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
+ ## 4.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: editor
8
+ - @fe-free/icons@4.1.4
9
+ - @fe-free/tool@4.1.4
10
+
11
+ ## 4.1.3
12
+
13
+ ### Patch Changes
14
+
15
+ - fix some
16
+ - @fe-free/icons@4.1.3
17
+ - @fe-free/tool@4.1.3
18
+
3
19
  ## 4.1.2
4
20
 
5
21
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "4.1.2",
3
+ "version": "4.1.4",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -50,8 +50,8 @@
50
50
  "i18next-icu": "^2.4.1",
51
51
  "react": "^19.2.0",
52
52
  "react-i18next": "^16.4.0",
53
- "@fe-free/icons": "4.1.2",
54
- "@fe-free/tool": "4.1.2"
53
+ "@fe-free/tool": "4.1.4",
54
+ "@fe-free/icons": "4.1.4"
55
55
  },
56
56
  "scripts": {
57
57
  "i18n-extract": "rm -rf ./src/locales/zh-CN && npx i18next-cli extract"
@@ -115,3 +115,11 @@ This is a markdown file.
115
115
  },
116
116
  render: (props) => <BasicDemo {...props} />,
117
117
  };
118
+
119
+ export const HTML: Story = {
120
+ args: {
121
+ language: 'html',
122
+ value: '<html><body><h1>Hello, World!</h1></body></html>',
123
+ },
124
+ render: (props) => <BasicDemo {...props} />,
125
+ };
@@ -1,3 +1,4 @@
1
+ import { html } from '@codemirror/lang-html';
1
2
  import { javascript } from '@codemirror/lang-javascript';
2
3
  import { json } from '@codemirror/lang-json';
3
4
  import { markdown } from '@codemirror/lang-markdown';
@@ -9,7 +10,7 @@ import CodeMirror from '@uiw/react-codemirror';
9
10
  import { useCallback, useMemo } from 'react';
10
11
 
11
12
  interface EditorProps {
12
- language?: 'javascript' | 'python' | 'json' | 'markdown';
13
+ language?: 'javascript' | 'python' | 'json' | 'markdown' | 'html';
13
14
  value?: string;
14
15
  onChange?: (value: string) => void;
15
16
  autoFocus?: boolean;
@@ -73,12 +74,15 @@ function Editor(props: EditorProps) {
73
74
  case 'markdown':
74
75
  result.push(markdown());
75
76
  break;
77
+ case 'html':
78
+ result.push(html());
79
+ break;
76
80
  default:
77
81
  break;
78
82
  }
79
83
 
80
84
  return result;
81
- }, [language, originExtensions]);
85
+ }, [language, originExtensions, lineWrapping]);
82
86
 
83
87
  const handleChange = useCallback(
84
88
  (value: string) => {
@@ -89,7 +93,7 @@ function Editor(props: EditorProps) {
89
93
 
90
94
  return (
91
95
  <CodeMirror
92
- className="w-full h-full"
96
+ className="h-full w-full"
93
97
  height={height || '100%'}
94
98
  width={width || '100%'}
95
99
  value={value}
@@ -1,4 +1,4 @@
1
- import { DeleteOutlined, InboxOutlined, PlusOutlined, UploadOutlined } from '@fe-free/icons';
1
+ import { CloseOutlined, InboxOutlined, PlusOutlined, UploadOutlined } from '@fe-free/icons';
2
2
  import type { UploadProps as AntdUploadProps, UploadFile } from 'antd';
3
3
  import { Upload as AntdUpload, App, Avatar, Button } from 'antd';
4
4
  import type { UploadChangeParam } from 'antd/es/upload';
@@ -272,37 +272,39 @@ interface AvatarImageUploadProps {
272
272
  }
273
273
  function AvatarImageUpload(props: AvatarImageUploadProps) {
274
274
  const { value, onChange, action, customRequest, accept = 'image/*', headers } = props;
275
- const { t } = useTranslation();
276
275
 
277
276
  return (
278
- <div className="flex gap-2">
279
- <Avatar size={80} src={value} shape="square" className="bg-01 shadow" />
280
-
281
- <div className="flex flex-1 flex-col justify-between">
282
- <div className="text-03">{t('@fe-free/core.upload.pleaseSelect', '请选择')}</div>
283
- <div className="flex gap-2">
284
- <AntdUpload
285
- action={action}
286
- customRequest={customRequest}
287
- onChange={(info) => {
288
- const url = info.file.response?.data?.url;
289
- if (url) {
290
- onChange?.(url);
291
- }
292
- }}
293
- itemRender={() => null}
294
- accept={accept}
295
- headers={headers}
296
- >
297
- <Button icon={<UploadOutlined />}>
298
- {t('@fe-free/core.upload.localUpload', '本地上传')}
299
- </Button>
300
- </AntdUpload>
301
- <Button icon={<DeleteOutlined />} danger onClick={() => onChange?.()}>
302
- {t('@fe-free/core.upload.delete', '删除')}
303
- </Button>
304
- </div>
305
- </div>
277
+ <div>
278
+ <AntdUpload
279
+ action={action}
280
+ customRequest={customRequest}
281
+ onChange={(info) => {
282
+ const url = info.file.response?.data?.url;
283
+ if (url) {
284
+ onChange?.(url);
285
+ }
286
+ }}
287
+ accept={accept}
288
+ headers={headers}
289
+ itemRender={() => null}
290
+ >
291
+ {value ? (
292
+ <div className="group relative h-20 w-20 cursor-pointer">
293
+ <Avatar size={80} src={value} shape="square" className="bg-01 shadow" />
294
+ <CloseOutlined
295
+ className="absolute right-1 top-1 cursor-pointer rounded-full bg-black/50 p-1 text-[10px] text-white opacity-0 transition-opacity group-hover:opacity-100"
296
+ onClick={(e) => {
297
+ e.stopPropagation();
298
+ onChange?.();
299
+ }}
300
+ />
301
+ </div>
302
+ ) : (
303
+ <div className="flex h-20 w-20 cursor-pointer items-center justify-center rounded bg-01 shadow transition-colors hover:bg-02">
304
+ <PlusOutlined className="text-xl text-02" />
305
+ </div>
306
+ )}
307
+ </AntdUpload>
306
308
  </div>
307
309
  );
308
310
  }