2
2
import type { EditorState , SerializedEditorState } from 'lexical'
3
3
import type { Validate } from 'payload'
4
4
5
- import { FieldLabel , useEditDepth , useField , withCondition } from '@payloadcms/ui'
5
+ import {
6
+ FieldDescription ,
7
+ FieldError ,
8
+ FieldLabel ,
9
+ RenderCustomComponent ,
10
+ useEditDepth ,
11
+ useField ,
12
+ withCondition ,
13
+ } from '@payloadcms/ui'
6
14
import { mergeFieldStyles } from '@payloadcms/ui/shared'
7
15
import React , { useCallback , useMemo } from 'react'
8
16
import { ErrorBoundary } from 'react-error-boundary'
9
17
10
18
import type { SanitizedClientEditorConfig } from '../lexical/config/types.js'
11
19
import type { LexicalRichTextFieldProps } from '../types.js'
12
20
13
- import { LexicalProvider } from '../lexical/LexicalProvider.js'
14
21
import '../lexical/theme/EditorTheme.scss'
15
22
import './bundled.css'
16
23
import './index.scss'
24
+ import { LexicalProvider } from '../lexical/LexicalProvider.js'
17
25
18
26
const baseClass = 'rich-text-lexical'
19
27
@@ -27,7 +35,7 @@ const RichTextComponent: React.FC<
27
35
field,
28
36
field : {
29
37
name,
30
- admin : { className, readOnly : readOnlyFromAdmin } = { } ,
38
+ admin : { className, description , readOnly : readOnlyFromAdmin } = { } ,
31
39
label,
32
40
localized,
33
41
required,
@@ -95,7 +103,10 @@ const RichTextComponent: React.FC<
95
103
96
104
return (
97
105
< div className = { classes } key = { pathWithEditDepth } style = { styles } >
98
- { Error }
106
+ < RenderCustomComponent
107
+ CustomComponent = { Error }
108
+ Fallback = { < FieldError path = { path } showError = { showError } /> }
109
+ />
99
110
{ Label || < FieldLabel label = { label } localized = { localized } required = { required } /> }
100
111
< div className = { `${ baseClass } __wrap` } >
101
112
< ErrorBoundary fallbackRender = { fallbackRender } onReset = { ( ) => { } } >
@@ -112,6 +123,10 @@ const RichTextComponent: React.FC<
112
123
{ AfterInput }
113
124
</ ErrorBoundary >
114
125
{ Description }
126
+ < RenderCustomComponent
127
+ CustomComponent = { Description }
128
+ Fallback = { < FieldDescription description = { description } path = { path } /> }
129
+ />
115
130
</ div >
116
131
</ div >
117
132
)
0 commit comments