Rework the way buttons are added to the editor to better deal with spaces

Signed-off-by: emanuele <emanuele45@gmail.com>