import 'package:vsc_quill_delta_to_html/vsc_quill_delta_to_html.dart';
import 'package:html/parser.dart' as html_parser;
import 'package:html/dom.dart' as dom;
/// Converts a Quill Delta (as JSON ops) into an HTML string that survives a
/// round-trip back through [HtmlToDelta] (see translation_input_container.dart).
///
/// Two issues in the underlying libraries are worked around here:
/// - flutter_quill stores colors as 8-digit ARGB hex (#AARRGGBB), which
/// vsc_quill_delta_to_html's sanitizer silently drops unless truncated to
/// #RRGGBB (colors picked in this editor are always opaque).
/// - vsc_quill_delta_to_html attaches a `style` attribute (color/background)
/// to whichever inline tag (e.g. ) comes first, but
/// flutter_quill_delta_from_html only reads `style` off elements.
/// Combined bold/italic + color would otherwise render fine everywhere
/// else but vanish when the editor reopens the HTML. Wrapping any styled
/// non-span element in a fixes the round-trip.
String quillOpsToHtml(List ops) {
final normalizedOps = _normalizeColors(ops);
final html = QuillDeltaToHtmlConverter(
List