You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should anchor hook automatically format attribute text? #25304
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.
Activity
youknowriad commentedon Sep 15, 2020
it makes sense to me. For #6182 we might be able to loop over blocks and detect duplicates.
skorasaurus commentedon Nov 8, 2021
@mkaz can this now be closed since it's been decided upon and used in #30825 ?