How can I add and use Attributes for a ActionText Attachment

I’m adding a attachment from a dialog. It works great, but I’d like to add attributes to it and then use them when rendering the attachment. Is this possible? I think it is because by default image attachments can have a caption and presentation stored in data-trix-attributes.

Is this a possible way to store and retrive attributes for an attachment? If so, How do I write to data-trix-attributes and then retrive those values in the partial?

So I can add to the data-trix-attributes values like this:

attachment.setAttributes({ 'linktext': 'my link text', 'caption': 'a caption', 'presentation': 'a-class'})

However only caption and presentation are left. Others like “linktext” are removed on save.

Can I add to the allowed attributes in a config?

How can I get at these values in my templates/partials?