rich-text icon indicating copy to clipboard operation
rich-text copied to clipboard

Link embed with Assets not working

Open tobidemski opened this issue 1 year ago • 8 comments

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

tobidemski avatar May 23 '23 09:05 tobidemski

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

iamgabrielsoft avatar Jun 27 '23 03:06 iamgabrielsoft

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!

tobidemski avatar Jun 27 '23 21:06 tobidemski

For you to do this;

  • You will need to head onto the schema view and then go to the model your Rich Text field is on and click "Edit field" on it :) That's where you can enable embeds

  • Once that is enabled, you can use the embed option on the editor when editing your content entry. That option is under the "Link" icon on the toolbar of the editor.

I hope its helps

Screenshot (40)

iamgabrielsoft avatar Jun 29 '23 13:06 iamgabrielsoft

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.

tobidemski avatar Jul 01 '23 19:07 tobidemski

it's a bug on the lib not the UI

iamgabrielsoft avatar Jul 04 '23 16:07 iamgabrielsoft

@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

Shailendra1703 avatar Dec 14 '23 18:12 Shailendra1703

@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 avatar Dec 15 '23 14:12 tobidemski

@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.

Shailendra1703 avatar Dec 15 '23 16:12 Shailendra1703