toHtml method

String toHtml()

Converts the underlying Quill's Delta to an HTML string.

Implementation

String toHtml() {
  // Convert document to JSON format
  final List<dynamic> deltaJson = document.toDelta().toJson();

  // Iterate through each Delta operation
  for (final dynamic element in deltaJson) {
    // Modify color attribute by removing '#FF' if it exists
    _updateColorAttribute(element, 'color');

    // Modify background attribute by removing '#FF' if it exists
    _updateColorAttribute(element, 'background');
  }

  // Use the QuillDeltaToHtmlConverter to convert modified Delta to HTML
  final QuillDeltaToHtmlConverter converter =
      QuillDeltaToHtmlConverter(List.castFrom(deltaJson), ConverterOptions.forEmail());
  return converter.convert();
}