mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
M: Inverse treeView
This commit is contained in:
parent
53e93dbab0
commit
7ab1eb71c1
|
@ -27,7 +27,7 @@ function DlgShowAST({ hideWindow, syntaxTree, expression }: DlgShowASTProps) {
|
||||||
const nodes: GraphNode[] = useMemo(
|
const nodes: GraphNode[] = useMemo(
|
||||||
() =>
|
() =>
|
||||||
syntaxTree.map(node => ({
|
syntaxTree.map(node => ({
|
||||||
id: String(node.uid),
|
id: String(syntaxTree.length - node.uid), // invert order of IDs to force correct ordering in graph layout
|
||||||
label: labelSyntaxTree(node),
|
label: labelSyntaxTree(node),
|
||||||
fill: colorBgSyntaxTree(node, colors)
|
fill: colorBgSyntaxTree(node, colors)
|
||||||
})),
|
})),
|
||||||
|
@ -40,15 +40,15 @@ function DlgShowAST({ hideWindow, syntaxTree, expression }: DlgShowASTProps) {
|
||||||
if (node.parent !== node.uid) {
|
if (node.parent !== node.uid) {
|
||||||
result.push({
|
result.push({
|
||||||
id: String(node.uid),
|
id: String(node.uid),
|
||||||
source: String(node.parent),
|
source: String(syntaxTree.length - node.parent),
|
||||||
target: String(node.uid)
|
target: String(syntaxTree.length - node.uid)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}, [syntaxTree]);
|
}, [syntaxTree]);
|
||||||
|
|
||||||
const handleHoverIn = useCallback((node: GraphNode) => setHoverID(Number(node.id)), []);
|
const handleHoverIn = useCallback((node: GraphNode) => setHoverID(syntaxTree.length - Number(node.id)), [syntaxTree]);
|
||||||
|
|
||||||
const handleHoverOut = useCallback(() => setHoverID(undefined), []);
|
const handleHoverOut = useCallback(() => setHoverID(undefined), []);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user