hygraph / rich-text

A set of companion packages for Hygraph's Rich Text Field
MIT License
93 stars 18 forks source link

Link embed with Assets not working #99

Open tobidemski opened 1 year ago

tobidemski commented 1 year ago

Hello,

I tried to link an asset (in my example image) with link embed but its getting rendered as an asset / image instead of a link. I checked the code and found the following line: https://github.com/hygraph/rich-text/blob/9e1a163dfb7d7f1adfc2faa35106a0e9db8fa6ce/packages/react-renderer/src/RichText.tsx#L147

There is a condition on type link if its not an asset. Therefor it is not possible to reference an asset in link embed.

Is this a bug or how does this work? As per documentation it should work to reference assets in links: https://hygraph.com/docs/api-reference/content-api/rich-text-field#embed-assets

Hope you can help me out :)

Best regards Tobi

iamgabrielsoft commented 1 year ago

no it's not a bug, you need to reference its mimetype

tobidemski commented 1 year ago

How can I reference its mimetype for an asset? Thats the overlay for link embed: image

If you choose an asset it will always rendered with the SDK as an image instead of a link with an image in it. I haven't found a way because of the condition I refered.

Can you give me an example what you mean?

Thanks!

iamgabrielsoft commented 1 year ago

For you to do this;

I hope its helps

Screenshot (40)

tobidemski commented 1 year ago

Im not speaking about the hygraph UI but from the head application (in my case nextjs). I know how to configure the embeds etc. but Im using this SDK which does not work as expected because if you use an asset in a link embed its not rendered like this. This means you can never have an image (referenced through an entity) with a link.

iamgabrielsoft commented 1 year ago

it's a bug on the lib not the UI

Shailendra1703 commented 11 months ago

@jpedroschmitz I'm struggling to insert the link to a word on rich text , when I click on this the field doesn't; respond, can anyone tell me why that is happening?

image

tobidemski commented 11 months ago

@jpedroschmitz I'm struggling to insert the link to a word on rich text , when I click on this the field doesn't; respond, can anyone tell me why that is happening?

image

Its looking like a different issue. Better create an own issue for that. But as I can see on your screenshot you havent set a "Link address" and only a placeholder text is shown. Also you got an error message "Please enter a valid URL". I would assume if you want to set a link you also should set an actual link in the "link address" field because its required.

Shailendra1703 commented 11 months ago

@jpedroschmitz I'm struggling to insert the link to a word on rich text , when I click on this the field doesn't; respond, can anyone tell me why that is happening? image

Its looking like a different issue. Better create an own issue for that. But as I can see on your screenshot you havent set a "Link address" and only a placeholder text is shown. Also you got an error message "Please enter a valid URL". I would assume if you want to set a link you also should set an actual link in the "link address" field because its required.

@tobidemski thanks for your response , I'll surely create a new issue for this , yes I can see that warning but the problem here is that I can't populate the data on the input URL field , this isn't taking the data.