Allow de-selecting of nodes.
This commit is contained in:
parent
5d31d50863
commit
f89e62b9e1
@ -38,7 +38,6 @@
|
|||||||
.OrgAstNode.hovered:not(.selected) {
|
.OrgAstNode.hovered:not(.selected) {
|
||||||
> .OrgAstNodeType {
|
> .OrgAstNodeType {
|
||||||
background: #70f8ba;
|
background: #70f8ba;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +45,7 @@
|
|||||||
background: #6ccff6;
|
background: #6ccff6;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
> span:first-child {
|
> span:first-child {
|
||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
|
@ -14,9 +14,16 @@ const OrgAst = (props: {
|
|||||||
const [hoveredNode, setHoveredNode] = useState<OrgNodeReference | null>(null);
|
const [hoveredNode, setHoveredNode] = useState<OrgNodeReference | null>(null);
|
||||||
|
|
||||||
function selectNode(uid: string, start: number, end: number) {
|
function selectNode(uid: string, start: number, end: number) {
|
||||||
const new_node: OrgNodeReference = { uid: uid, start: start, end: end };
|
if (selectedNode !== null && selectedNode.uid === uid) {
|
||||||
props.setHighlight([new_node, hoveredNode].filter((node) => node !== null));
|
props.setHighlight([hoveredNode].filter((node) => node !== null));
|
||||||
setSelectedNode({ uid: uid, start: start, end: end });
|
setSelectedNode(null);
|
||||||
|
} else {
|
||||||
|
const new_node: OrgNodeReference = { uid: uid, start: start, end: end };
|
||||||
|
props.setHighlight(
|
||||||
|
[new_node, hoveredNode].filter((node) => node !== null),
|
||||||
|
);
|
||||||
|
setSelectedNode({ uid: uid, start: start, end: end });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function startHoverNode(uid: string, start: number, end: number) {
|
function startHoverNode(uid: string, start: number, end: number) {
|
||||||
|
Loading…
Reference in New Issue
Block a user