Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link embed with Assets not working #99

Open
tobidemski opened this issue May 23, 2023 · 8 comments
Open

Link embed with Assets not working #99

tobidemski opened this issue May 23, 2023 · 8 comments
Labels
react-renderer Issues and PR's related to @graphcms/rich-text-react-renderer

Comments

@tobidemski
Copy link

tobidemski commented May 23, 2023

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:

if (isEmbed && nodeType !== 'Asset') {

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
Copy link

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

@tobidemski
Copy link
Author

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
Copy link

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)

@tobidemski
Copy link
Author

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
Copy link

it's a bug on the lib not the UI

@jpedroschmitz jpedroschmitz added the react-renderer Issues and PR's related to @graphcms/rich-text-react-renderer label Nov 20, 2023
@Shailendra1703
Copy link

Shailendra1703 commented Dec 14, 2023

@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
Copy link
Author

tobidemski commented Dec 15, 2023

@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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
react-renderer Issues and PR's related to @graphcms/rich-text-react-renderer
Projects
None yet
Development

No branches or pull requests

4 participants