blockElementRender function

CustomRender blockElementRender({
  1. CSS3? style,
  2. List<InlineSpan>? children,
})

Implementation

CustomRender blockElementRender({
  CSS3? style,
  List<InlineSpan>? children,
}) =>
    CustomRender.inlineSpan(inlineSpan: (context, buildChildren) {
      if (context.parser.selectable) {
        return TextSpan(
          style: context.style.generateTextStyle(),
          children: (children as List<TextSpan>?) ??
              context.tree.children
                  .expandIndexed((i, childTree) => [
                        context.parser.parseTree(context, childTree),
                        if (i != context.tree.children.length - 1 &&
                            childTree.style.display == Display.block &&
                            childTree.element?.localName != "html" &&
                            childTree.element?.localName != "body")
                          const TextSpan(text: "\n"),
                      ])
                  .toList(),
        );
      }
      return WidgetSpan(
        alignment: PlaceholderAlignment.baseline,
        baseline: TextBaseline.alphabetic,
        child: CssBoxWidget.withInlineSpanChildren(
          key: context.key,
          style: style ?? context.tree.style,
          shrinkWrap: context.parser.shrinkWrap,
          childIsReplaced: HtmlElements.replacedExternalElements.contains(
            context.tree.name,
          ),
          children: children ??
              context.tree.children
                  .expandIndexed((i, childTree) => [
                        context.parser.parseTree(context, childTree),
                        if (i != context.tree.children.length - 1 &&
                            childTree.style.display == Display.block &&
                            childTree.element?.localName != "html" &&
                            childTree.element?.localName != "body")
                          const TextSpan(text: "\n"),
                      ])
                  .toList(),
        ),
      );
    });