generator property
Implementation
static final UIComponentGenerator<UIDocument> generator =
UIComponentGenerator<UIDocument>(
'ui-document',
'div',
'ui-document',
'',
(parent, attributes, contentHolder, contentNodes) {
var src = attributes['src']?.toString();
ResourceContent? resourceContent;
if (isNotEmptyString(src)) {
resourceContent = ResourceContent.from(src);
} else {
var type = attributes['type']?.toString() ?? '.md';
resourceContent = ResourceContent.fromURI(
'file.$type',
contentHolder?.textContent,
);
}
return UIDocument(parent, resourceContent);
},
[
UIComponentAttributeHandler<UIDocument, String>(
'src',
parser: parseString,
getter: (c) => c._resourceContent?.uri?.toString(),
setter: (c, v) => c.resourceContent = v,
appender: (c, v) => c.resourceContent = v,
cleaner: (c) => c.resourceContent = null,
),
],
hasChildrenElements: false,
contentAsText: true,
);