import 'package:html/dom.dart'; import 'package:mangayomi/eval/model/element.dart'; import 'package:mangayomi/utils/extensions/dom_extensions.dart'; class MDocument { const MDocument(this._document); final Document? _document; MElement? get body => MElement(_document?.body); MElement? get documentElement => MElement(_document?.documentElement); MElement? get head => MElement(_document?.head); MElement? get parent => MElement(_document?.parent); String? get outerHtml => _document?.outerHtml; String? get text => _document?.text; List? get children => _document?.children.map((e) => MElement(e)).toList(); List? select(String selector) { return _document?.select(selector)?.map((e) => MElement(e)).toList(); } String? xpathFirst(String xpath) { return _document?.xpathFirst(xpath); } List xpath(String xpath) { return _document?.xpath(xpath) ?? []; } List? getElementsByClassName(String classNames) { return _document ?.getElementsByClassName(classNames) .map((e) => MElement(e)) .toList(); } List? getElementsByTagName(String localNames) { return _document ?.getElementsByTagName(localNames) .map((e) => MElement(e)) .toList(); } MElement? getElementById(String id) { return MElement(_document?.getElementById(id)); } MElement? selectFirst(String selector) { return MElement(_document?.selectFirst(selector)); } }