I would like to modify text that is being converted to a link within CKEditor, using the Linkit plugin. Eg. When linking to a Media Document, append the file type and size.
I am using
hook_form_editor_link_dialog_alter in order to modify the dialog form and capture and populate additional attributes on the resulting
a element. But there does not appear to be a field for modifying the text.
Drupal 9.5.9, CKEditor 4, Linkit 6-rc1
$form['attributes']['data-foo']in the hook you mentioned; that in turn gets added to the link,
<a data-foo="...">, and then you create a custom filter plugin which looks for that data attribute in the DOM and adds to or modifies the HTML based on the attribute values. If you want to manipulate the HTML in the editor at edit time, I'm pretty sure you need to create a new CKEditor plugin