tycho-components 0.2.0-SNAPSHOT-18 → 0.2.0-SNAPSHOT-19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,6 +13,7 @@ export default function TreeView({ struct, expression, onExpand, selector = 'can
|
|
|
13
13
|
const { t } = useTranslation('tree');
|
|
14
14
|
const [cy, setCy] = useState(null);
|
|
15
15
|
const [showInfo, setShowInfo] = useState(false);
|
|
16
|
+
const [invalid, setInvalid] = useState();
|
|
16
17
|
const load = () => {
|
|
17
18
|
setCy(null);
|
|
18
19
|
const element = document.getElementById(selector);
|
|
@@ -21,15 +22,17 @@ export default function TreeView({ struct, expression, onExpand, selector = 'can
|
|
|
21
22
|
if (!struct)
|
|
22
23
|
return;
|
|
23
24
|
const tree = new CytoscapeTreeConverter().execute(struct, showInfo);
|
|
24
|
-
if (tree) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
tree,
|
|
28
|
-
onReady: (thisCy) => {
|
|
29
|
-
setCy(thisCy);
|
|
30
|
-
},
|
|
31
|
-
});
|
|
25
|
+
if (!tree) {
|
|
26
|
+
setInvalid(true);
|
|
27
|
+
return;
|
|
32
28
|
}
|
|
29
|
+
SyntreesCytoscape.init({
|
|
30
|
+
selector,
|
|
31
|
+
tree,
|
|
32
|
+
onReady: (thisCy) => {
|
|
33
|
+
setCy(thisCy);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
33
36
|
};
|
|
34
37
|
const downloadPsd = () => {
|
|
35
38
|
if (!expression)
|
|
@@ -64,9 +67,10 @@ export default function TreeView({ struct, expression, onExpand, selector = 'can
|
|
|
64
67
|
});
|
|
65
68
|
};
|
|
66
69
|
useEffect(() => {
|
|
70
|
+
setInvalid(undefined);
|
|
67
71
|
load();
|
|
68
72
|
}, [struct]);
|
|
69
|
-
if (
|
|
73
|
+
if (invalid) {
|
|
70
74
|
return _jsx(AppPlaceholder, { text: t('placeholder.sentence.notparsed') });
|
|
71
75
|
}
|
|
72
76
|
return (_jsxs("div", { className: "tree-view-container", children: [cy &&
|
|
@@ -36,9 +36,18 @@ class CytoscapeTreeConverter {
|
|
|
36
36
|
return token.v;
|
|
37
37
|
}
|
|
38
38
|
validate(struct) {
|
|
39
|
-
if (!struct.chunks || struct.chunks.length === 0)
|
|
39
|
+
if (!struct.chunks || struct.chunks.length === 0) {
|
|
40
40
|
return false;
|
|
41
|
-
|
|
41
|
+
}
|
|
42
|
+
if (!struct.tokens || struct.tokens.length === 0) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return struct.tokens.every((token) => {
|
|
46
|
+
if (token.ec) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return token.t !== undefined && token.t.trim() !== '';
|
|
50
|
+
});
|
|
42
51
|
}
|
|
43
52
|
calculatePositions(cytoscape) {
|
|
44
53
|
const converter = new CytoscapePositionCalculator();
|