Converts the span and its properties into a serializable JSON map.
Map<String, dynamic> toJson() => { 'text': text, 'style': style?.toJson(), 'onTap': onTap, };