File tree Expand file tree Collapse file tree 5 files changed +40
-2
lines changed
richtext-lexical/src/field
test/lexical/collections/Lexical Expand file tree Collapse file tree 5 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -184,7 +184,6 @@ const RichTextComponent: React.FC<
184
184
/>
185
185
{ AfterInput }
186
186
</ ErrorBoundary >
187
- { Description }
188
187
< RenderCustomComponent
189
188
CustomComponent = { Description }
190
189
Fallback = { < FieldDescription description = { description } path = { path } /> }
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ export const Form: React.FC<FormProps> = (props) => {
104
104
const { startRouteTransition } = useRouteTransition ( )
105
105
const { getUploadHandler } = useUploadHandlers ( )
106
106
107
- const { config, getEntityConfig } = useConfig ( )
107
+ const { config } = useConfig ( )
108
108
109
109
const [ disabled , setDisabled ] = useState ( disabledFromProps || false )
110
110
const [ isMounted , setIsMounted ] = useState ( false )
Original file line number Diff line number Diff line change
1
+ export const Description = ( ) => {
2
+ return (
3
+ < div className = "lexical-blocks-custom-description" style = { { color : 'red' } } >
4
+ My Custom Lexical Description
5
+ </ div >
6
+ )
7
+ }
Original file line number Diff line number Diff line change @@ -1446,6 +1446,29 @@ describe('lexicalMain', () => {
1446
1446
page . getByText ( 'Creating new User' )
1447
1447
} )
1448
1448
1449
+ test ( 'ensure custom Description component is rendered only once' , async ( ) => {
1450
+ await navigateToLexicalFields ( )
1451
+ const lexicalWithBlocks = page . locator ( '.rich-text-lexical' ) . nth ( 2 )
1452
+ await lexicalWithBlocks . scrollIntoViewIfNeeded ( )
1453
+ await expect ( lexicalWithBlocks ) . toBeVisible ( )
1454
+
1455
+ await expect ( lexicalWithBlocks . locator ( '.lexical-blocks-custom-description' ) ) . toHaveCount ( 1 )
1456
+ await expect ( lexicalWithBlocks . locator ( '.lexical-blocks-custom-description' ) ) . toBeVisible ( )
1457
+
1458
+ await expect ( lexicalWithBlocks . locator ( '.field-description' ) ) . toHaveCount ( 0 )
1459
+ } )
1460
+
1461
+ test ( 'ensure admin.description property is rendered' , async ( ) => {
1462
+ await navigateToLexicalFields ( )
1463
+ const lexicalSimple = page . locator ( '.rich-text-lexical' ) . nth ( 1 )
1464
+ await lexicalSimple . scrollIntoViewIfNeeded ( )
1465
+ await expect ( lexicalSimple ) . toBeVisible ( )
1466
+
1467
+ await expect ( lexicalSimple . locator ( '.field-description' ) ) . toHaveCount ( 1 )
1468
+ await expect ( lexicalSimple . locator ( '.field-description' ) ) . toBeVisible ( )
1469
+ await expect ( lexicalSimple . locator ( '.field-description' ) ) . toHaveText ( 'A simple lexical field' )
1470
+ } )
1471
+
1449
1472
test ( 'ensure links can created from clipboard and deleted' , async ( ) => {
1450
1473
await navigateToLexicalFields ( )
1451
1474
const richTextField = page . locator ( '.rich-text-lexical' ) . first ( )
Original file line number Diff line number Diff line change @@ -309,6 +309,9 @@ export const getLexicalFieldsCollection: (args: {
309
309
{
310
310
name : 'lexicalSimple' ,
311
311
type : 'richText' ,
312
+ admin : {
313
+ description : 'A simple lexical field' ,
314
+ } ,
312
315
editor : lexicalEditor ( {
313
316
features : ( { defaultFeatures } ) => [
314
317
//TestRecorderFeature(),
@@ -347,6 +350,12 @@ export const getLexicalFieldsCollection: (args: {
347
350
{
348
351
name : 'lexicalWithBlocks' ,
349
352
type : 'richText' ,
353
+ admin : {
354
+ components : {
355
+ Description : '/collections/Lexical/components/Description.js#Description' ,
356
+ } ,
357
+ description : 'Should not be rendered' ,
358
+ } ,
350
359
editor : lexicalEditor ( {
351
360
admin : {
352
361
hideGutter : false ,
You can’t perform that action at this time.
0 commit comments