In reply to Anh Tran.

Sorry for stating "no Javascript". A small Javascript file was in the example to define edit and save actions, but I just kept it as the example.

All the work creating the custom output was done in the PHP file, just like for shortcodes. Just added register_block_type()

Example presented here.