Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit ac4dcce

Browse files
committed
fix: 修复隐藏字段在编辑界面显示的问题,修复多个 Markdown 编辑器不显示的问题
1 parent ea1771b commit ac4dcce

6 files changed

Lines changed: 17 additions & 14 deletions

File tree

packages/admin/src/components/Fields/FieldContentEditor.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ const RichTextEditor = React.lazy(() => import('@/components/Fields/RichText'))
1111
const { TextArea } = Input
1212
const { Option } = Select
1313

14-
const LazyMarkdownEditor: React.FC = (props: any) => (
14+
const LazyMarkdownEditor: React.FC<{ id: number }> = (props: any) => (
1515
<Suspense fallback={<Spin />}>
1616
<MarkdownEditor {...props} />
1717
</Suspense>
1818
)
1919

20-
const LazyRichTextEditor: React.FC = (props: any) => (
20+
const LazyRichTextEditor: React.FC<{ id: number }> = (props: any) => (
2121
<Suspense fallback={<Spin />}>
2222
<RichTextEditor {...props} />
2323
</Suspense>
@@ -192,10 +192,10 @@ export function getFieldEditor(field: SchemaField, key: number) {
192192
)
193193
break
194194
case 'Markdown':
195-
FieldEditor = <LazyMarkdownEditor key={key} />
195+
FieldEditor = <LazyMarkdownEditor id={key} />
196196
break
197197
case 'RichText':
198-
FieldEditor = <LazyRichTextEditor key={String(key)} />
198+
FieldEditor = <LazyRichTextEditor id={key} />
199199
break
200200
case 'Connect':
201201
FieldEditor = <IConnectEditor field={field} />

packages/admin/src/components/Fields/Markdown.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ const getToolBarWithoutUpload = () => {
6262
const toolbar: any[] = WX_MP ? getToolBarWithoutUpload() : DefaultToolbar
6363

6464
export const MarkdownEditor: React.FC<{
65+
id: number
6566
value?: any
66-
key: string
6767
onChange?: (...args: any) => void
6868
}> = (props) => {
69-
const { value, key = 'default', onChange = (...args: any) => {} } = props
69+
const { value, id = 'default', onChange = (...args: any) => {} } = props
7070

7171
const authHeader = getAuthHeader()
7272

7373
useEffect(() => {
7474
// eslint-disable-next-line
75-
new VditorX(`${key}-editor`, {
75+
new VditorX(`${id}-editor`, {
7676
value,
7777
toolbar,
7878
input: (text, html) => {
@@ -98,7 +98,7 @@ export const MarkdownEditor: React.FC<{
9898
})
9999
}, [authHeader?.['x-cloudbase-credentials']])
100100

101-
return <div id={`${key}-editor`} />
101+
return <div id={`${id}-editor`} />
102102
}
103103

104104
export default MarkdownEditor

packages/admin/src/components/Fields/RichText.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import 'braft-editor/dist/index.css'
88

99
const { Dragger } = Upload
1010

11-
const RichText: React.FC<{ value?: any; key: string; onChange?: (...args: any) => void }> = (
11+
const RichText: React.FC<{ value?: any; id: number; onChange?: (...args: any) => void }> = (
1212
props
1313
) => {
14-
const { key = 'default', value = '欢迎使用富文本编辑器', onChange = (...args: any) => {} } = props
14+
const { id = 'default', value = '欢迎使用富文本编辑器', onChange = (...args: any) => {} } = props
1515
const [editorState, setEditorState] = useState<any>()
1616

1717
useEffect(() => {
@@ -42,7 +42,7 @@ const RichText: React.FC<{ value?: any; key: string; onChange?: (...args: any) =
4242
return (
4343
<div style={{ border: '1px solid #d1d1d1' }}>
4444
<BraftEditor
45-
key={key}
45+
key={id}
4646
value={editorState}
4747
onChange={(s) => {
4848
setEditorState(s)

packages/admin/src/pages/project/content/ContentEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const ContentEditor: React.FC = () => {
7676
)}
7777

7878
{schema?.fields
79-
?.filter((_) => !_.isSystem)
79+
?.filter((_) => !_.isSystem && !_.isHidden)
8080
.map((filed, index) => getFieldFormItem(filed, index))}
8181

8282
<Form.Item>

packages/admin/src/pages/project/content/columns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const hideInSearchType = ['File', 'Image', 'Array', 'Date', 'DateTime']
1010
* 获取表格 column 渲染配置
1111
*/
1212
export const getTableColumns = (fields: SchemaField[] = []): ProColumns[] => {
13-
// 用户自定义字段
13+
// 用户自定义字段,过滤掉系统字段,重复字段
1414
const customFields = fields
1515
?.filter((_) => !_.isSystem)
1616
?.filter((field, i, arr) => field && arr.findIndex((_) => _.name === field.name) === i)

packages/admin/src/pages/project/schema/components/SchemaFieldEditor/SchemaFieldEdit.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ export const SchemaFieldEditorModal: React.FC<{
283283
{/* 特定字段的特殊属性 */}
284284
{SpecificAttributeFormItem}
285285

286+
{/* 必要字段 */}
286287
<Form.Item>
287288
<div className="form-item">
288289
<Form.Item style={{ marginBottom: 0 }}>
@@ -295,18 +296,20 @@ export const SchemaFieldEditorModal: React.FC<{
295296
</div>
296297
</Form.Item>
297298

299+
{/* 隐藏字段 */}
298300
<Form.Item>
299301
<div className="form-item">
300302
<Form.Item style={{ marginBottom: 0 }}>
301303
<Text>是否隐藏</Text>
302304
<Form.Item name="isHidden" valuePropName="checked" style={{ marginBottom: 0 }}>
303305
<Switch />
304306
</Form.Item>
305-
<Text type="secondary">在内容集合表格展示时隐藏该字段</Text>
307+
<Text type="secondary">在内容集合表格展示、编辑内容时隐藏该字段</Text>
306308
</Form.Item>
307309
</div>
308310
</Form.Item>
309311

312+
{/* 排序字段 */}
310313
<Form.Item>
311314
<div className="form-item">
312315
<Form.Item style={{ marginBottom: 0 }}>

0 commit comments

Comments
 (0)