payload icon indicating copy to clipboard operation
payload copied to clipboard

refactor: extract hasText helper in richTextValidateHOC

Open 58bits opened this issue 1 year ago • 1 comments
trafficstars

@AlessioGr

What?

Extracted hasText helper method in richTextValidateHOC

Why?

The new exported hasText helper method can now also be used during front-end serialization - for example, to check whether a caption element should be rendered when text is optional and therefore possibly empty (which would allow us to prevent rendering an empty caption element).

58bits avatar Nov 24 '24 11:11 58bits

Are you expecting this to be used on the frontend?

AlessioGr avatar Nov 26 '24 05:11 AlessioGr

Are you expecting this to be used on the frontend?

We use this in a couple of places, including our Solr plugin for Payload. It was useful for us. No worries if you'd rather not.

58bits avatar Nov 26 '24 17:11 58bits

I'm happy the export it, it's just important to know where. If we export it from the root barrel file, that function can't be used on the client. And if we export it from /client, that function can't be used on the server.

I think this might be useful for both server & client. Could you export this function inside packages/richtext-lexical/src/exports/shared.ts ? Also make sure to move it to its own file

AlessioGr avatar Nov 27 '24 00:11 AlessioGr

I'm happy the export it, it's just important to know where. If we export it from the root barrel file, that function can't be used on the client. And if we export it from /client, that function can't be used on the server.

I think this might be useful for both server & client. Could you export this function inside packages/richtext-lexical/src/exports/shared.ts ? Also make sure to move it to its own file

Okay sure. That sounds good.

58bits avatar Nov 27 '24 00:11 58bits

🚀 This is included in version v3.2.0

github-actions[bot] avatar Nov 27 '24 01:11 github-actions[bot]