TIL that Yoast overrides core ’s inline link popover in order to add `nofollow`/`sponsored` toggles. All us folk now need is for someone to do the exact same but add a `class` input field, so we can add `u-*` classes without having to constantly fight the block editor.

I’d much prefer this over a custom block (or some kind of meta box approach), as I want to be able to add such links anywhere in a post’s content.

(Thing is, you can “Edit as HTML,” but switching back to the [visual] link editor will remove your manually added attributes.)

Found some more code examples and am now able to either add a new formatting button that will trigger a completely inaccessible “href” popover but otherwise sorta works, or replace the core link button with something that, uh, will add an `a` tag with a class. But I’m a React noob. Plus, _all_ we need is for core links to accept a class.


Folks have been wanting a way to easily extend these links forever—three years, at least; there’s several GitHub issues—so not gonna get my hopes up. I did, however, just implement a different approach, where I add, e.g., a `u-bookmark-of` class to a _paragraph_ block, and a `the_content` filter then _removes_ that class and adds it to that paragraph’s first _link_ instead. Hacky, but probably more robust than “Edit as HTML.”

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!