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

Should anchor hook automatically format attribute text? #25304

Closed
mkaz opened this issue Sep 14, 2020 · 2 comments
Closed

Should anchor hook automatically format attribute text? #25304

mkaz opened this issue Sep 14, 2020 · 2 comments
Labels
[Feature] Block API API that allows to express the block paradigm. [Package] Block editor /packages/block-editor [Type] Enhancement A suggestion for improvement.

Comments

@mkaz
Copy link
Member

mkaz commented Sep 14, 2020

In #23197 anchor tag support was adding using hooks, this allows adding a supports: { anchor: true } property on a block that enables a field in advanced that can be set. Additionally a block can use setAttrtbiutes: { anchor: "Anchor text" } and it will set the value for the anchor field.

However, the value does not automatically get converted to a valid value, per the spec, it should contain no whitespace.

When specified on HTML elements, the id attribute value must be unique amongst all the IDs in the element's tree and must contain at least one character. The value must not contain any ASCII whitespace.
From: https://html.spec.whatwg.org/multipage/dom.html#the-id-attribute

Question: should the anchor hook automatically format the values being set?

My thought is yes, and also lower-case, switch whitespace to "-" so something like "Anchor text" would become "anchor-text"

We could then resolve #6182 by updating the onChange: setAttributes( { content: value, anchor: value } )

Granted there is an issue for non-unique ids on the page, but that exists now regardless of heading.

Thoughts?

@mkaz mkaz added Needs Technical Feedback Needs testing from a developer perspective. [Package] Block editor /packages/block-editor labels Sep 14, 2020
@youknowriad youknowriad added [Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement. and removed Needs Technical Feedback Needs testing from a developer perspective. labels Sep 15, 2020
@youknowriad
Copy link
Contributor

it makes sense to me. For #6182 we might be able to loop over blocks and detect duplicates.

@skorasaurus
Copy link
Member

skorasaurus commented Nov 8, 2021

@mkaz can this now be closed since it's been decided upon and used in #30825 ?

@mkaz mkaz closed this as completed Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Package] Block editor /packages/block-editor [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants