what's the recommend way to exec custom event

for example, let’s say we enabled tooltips and have a strong selection word function button on it, click it to make selected words wrap with <strong> immediately, I know this can be done by a basic mark decoration with keymap but how to apply this change by an anywhere button?