Editor shortcut to wrap selected text with html tag & end tag?

I’ve written an add-on that adds editor shortcuts to change the foreground (text) color and/or toggle a font format.

I’d like to enhance it, or write a new one, that adds an editor shortcut to insert constant <span style=[…]> and </style> tags around user-selected text. How can I do that?

The add-on you’re intending to create already exists :v:
Take a look at Custom Styles (font color, background colour, classes) - AnkiWeb. It enables you to wrap selections with styled <span> tags (inline-styling or with classes) or with arbitrary text snippets via user-defined shortcuts, buttons and context menu entries.


Yes, it does what I asked for – thanks!