spanToOp method

  1. @override
List<Operation> spanToOp(
  1. Element element
)
override

Converts a span HTML element (<span>) to Delta operations.

Implementation

@override
List<Operation> spanToOp(dom.Element element) {
  final Delta delta = Delta();
  final attributes = element.attributes;
  Map<String, dynamic> inlineAttributes = {};
  // Process the style attribute
  if (attributes.containsKey('style')) {
    final String? style = attributes['style'];
    final styleAttributes = parseStyleAttribute(
      element.localName!,
      style ?? '',
      onDetectLineheightCssVariable: onDetectLineheightCssVariable,
    );
    if (styleAttributes.containsKey('align')) {
      styleAttributes.remove('align');
    }
    inlineAttributes.addAll(styleAttributes);
  }
  final nodes = element.nodes;
  //this store into all nodes into a paragraph, and
  //ensure getting all attributes or tags into a paragraph
  for (final node in nodes) {
    processNode(
      node,
      inlineAttributes,
      delta,
      addSpanAttrs: false,
      customBlocks: customBlocks,
      onDetectLineheightCssVariable: onDetectLineheightCssVariable,
    );
  }

  return delta.toList();
}