I'm not sure I understand.
If I paste a number, and then click a button, I will get
12345[player=XXX]
If I paste a number, select the number, and then click a button, I will get
[player=XXX] with the number replaced.
If I click the button, and then select the XXX, and then past, I get what I want,
(12345)but that is the opposite of how bolding, italicizing, or underlining works,