buildFromExtension method

InlineSpan buildFromExtension(
  1. ExtensionContext extensionContext, {
  2. Set<HtmlExtension> extensionsToIgnore = const {},
})

Builds the StyledElement into an InlineSpan using one of the built-ins or HtmlExtensions available. If none of the extensions matches, returns an empty TextSpan.

Implementation

InlineSpan buildFromExtension(
  ExtensionContext extensionContext, {
  Set<HtmlExtension> extensionsToIgnore = const {},
}) {
  // Loop through every extension and see if it can handle this node
  for (final extension in extensions) {
    if (!extensionsToIgnore.contains(extension) &&
        extension.matches(extensionContext)) {
      return extension.build(extensionContext);
    }
  }

  // Loop through built in elements and see if they can handle this node.
  for (final builtIn in builtIns) {
    if (!extensionsToIgnore.contains(builtIn) &&
        builtIn.matches(extensionContext)) {
      return builtIn.build(extensionContext);
    }
  }

  return const TextSpan(text: "");
}