parseReplacedElement function
Implementation
ReplacedElement parseReplacedElement(
dom.Element element,
List<StyledElement> children,
NavigationDelegate? navigationDelegateForIframe,
) {
switch (element.localName) {
case "audio":
final sources = <String?>[
if (element.attributes['src'] != null) element.attributes['src'],
...ReplacedElement.parseMediaSources(element.children),
];
if (sources.isEmpty || sources.first == null) {
return EmptyContentElement();
}
return AudioContentElement(
name: "audio",
src: sources,
showControls: element.attributes['controls'] != null,
loop: element.attributes['loop'] != null,
autoplay: element.attributes['autoplay'] != null,
muted: element.attributes['muted'] != null,
node: element,
);
case "br":
return TextContentElement(
text: "\n",
style: Style(whiteSpace: WhiteSpace.PRE),
element: element,
node: element
);
case "img":
return ImageContentElement(
name: "img",
src: element.attributes['src'],
alt: element.attributes['alt'],
node: element,
);
case "video":
final sources = <String?>[
if (element.attributes['src'] != null) element.attributes['src'],
...ReplacedElement.parseMediaSources(element.children),
];
if (sources.isEmpty || sources.first == null) {
return EmptyContentElement();
}
return VideoContentElement(
name: "video",
src: sources,
poster: element.attributes['poster'],
showControls: element.attributes['controls'] != null,
loop: element.attributes['loop'] != null,
autoplay: element.attributes['autoplay'] != null,
muted: element.attributes['muted'] != null,
width: double.tryParse(element.attributes['width'] ?? ""),
height: double.tryParse(element.attributes['height'] ?? ""),
node: element,
);
case "svg":
return SvgContentElement(
name: "svg",
data: element.outerHtml,
width: double.tryParse(element.attributes['width'] ?? ""),
height: double.tryParse(element.attributes['height'] ?? ""),
node: element,
);
case "ruby":
return RubyElement(
element: element,
children: children,
);
case "math":
return MathElement(
element: element,
);
default:
return EmptyContentElement(name: element.localName == null ? "[[No Name]]" : element.localName!);
}
}