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

is it possible to add Custom attribute in link? #10226

Closed
nitishkaila opened this issue Sep 28, 2018 · 6 comments
Closed

is it possible to add Custom attribute in link? #10226

nitishkaila opened this issue Sep 28, 2018 · 6 comments
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@nitishkaila
Copy link
Contributor

Currently Gutenberg is not providing any type of functionality to add custom html attribute into the link/anchor tag. Also not option to track click event for current flow.

@Soean
Copy link
Member

Soean commented Sep 28, 2018

Hey @nitishkaila,
can you provide an example usage with code?

@designsimply designsimply added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Sep 28, 2018
@nitishkaila
Copy link
Contributor Author

nitishkaila commented Sep 29, 2018

Hi @Soean,

I haven't used a custom block for that. I need to add a custom attribute in the link for core/paragraph and core/list block. is there any hook or possibility to add a custom attribute in the link for existing core block?

@encipherdesign
Copy link

@Soean / @WordPress

there should be an easy way to add valid html attributes to links which would improve accessibility, usability and security. https://www.w3schools.com/tags/tag_a.asp

this could be included [in the link options dialog?] to make adding valid links easier without using the code-mode or additional content filters:

<a href="<url>" title="<link title/default_to_link_label>" rel="<nofollow,noopener _[stop using _blank]_ >" item-prop="url" data-<variable>="<string_value>" tabindex="1" ><link_label></a>

parsing/filtering the_content() leads to performance/maintenance issues as it adds one more function that should be taken care of on entry, [without a developer needed to create custom filters for a client].

these options are basic options available in CKEditor :

link-type
link_attr

feature request?

these options should be native on any legit cms.

@nitishkaila
Copy link
Contributor Author

Hi @encipherdesign,

This is CKEditor but I need to add attribute in the Gutenberg link. I have also concern about link click event. Many site has track the google event when click on the link. So I think this is limitation of Gutenberg link which we not add other attribute or not track the click event.

@nitishkaila
Copy link
Contributor Author

Hi @Soean

All most site has used google analytics event by clicking on button or link. We can embed this think underneath link box. So normal user can easily add the google tracking event or something else without help of developer.

thanks

@youknowriad
Copy link
Contributor

Attributes is something very developper related, I don't think we should expose any attribute without explanation. For example we don't say "target" we say "open in a new tab".

That said, it is still possible to add any custom attribute to link by switching back and forth to the HTML mode of the block. It is also possible to build custom toolbar buttons to allow advanced use-cases using the Format API.

I'm closing this for now. Thanks for your input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

5 participants