Map<String, dynamic> toJson() { return {'type': type, if (externalURL != null) 'externalURL': externalURL}; }