mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-05-14 03:15:11 +00:00
Allow fragments to be used in DeadDocument.
They work like React.Fragment except we don't have components yet so it has to be a special node.
This commit is contained in:
@@ -63,6 +63,7 @@ export enum NodeTag {
|
||||
BoldFace = 'b',
|
||||
ItalicFace = 'i',
|
||||
Anchor = 'a',
|
||||
Fragment = 'fragment',
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,4 +62,7 @@ HTML_RENDERER.registerRenderer<FringeLeafRenderFunction<TransactionalOutputConte
|
||||
context.output.writeString('>')
|
||||
},
|
||||
staticString('</a>')
|
||||
).registerInnerNode(NodeTag.Fragment,
|
||||
blank,
|
||||
blank
|
||||
);
|
||||
|
||||
@@ -132,4 +132,7 @@ MARKDOWN_RENDERER.registerRenderer<FringeLeafRenderFunction<TransactionalOutputC
|
||||
}
|
||||
context.output.writeString(`](${href})`);
|
||||
}
|
||||
).registerInnerNode(NodeTag.Fragment,
|
||||
blank,
|
||||
blank
|
||||
);
|
||||
|
||||
@@ -23,8 +23,13 @@ export function JSXFactory(tag: NodeTag, properties: any, ...rawChildren: (Docum
|
||||
makeLeafNode<TextNode>(NodeTag.TextNode, node, (rawChild as number).toString());
|
||||
} else if (Array.isArray(rawChild)) {
|
||||
rawChild.forEach(ensureChild);
|
||||
// Then it's a DocumentNode|LeafNode
|
||||
} else if (typeof rawChild.leafNode === 'boolean') {
|
||||
node.addChild(rawChild);
|
||||
if (rawChild.tag === NodeTag.Fragment) {
|
||||
(rawChild as DocumentNode).getChildren().forEach(node.addChild, node);
|
||||
} else {
|
||||
node.addChild(rawChild);
|
||||
}
|
||||
} else {
|
||||
const presentationType = presentationTypeOf(rawChild);
|
||||
if (presentationType !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user