tycho-components 0.4.2 → 0.4.4
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import cytoscape, { Core } from
|
|
2
|
-
import { CytoscapeTree } from
|
|
1
|
+
import cytoscape, { Core } from "cytoscape";
|
|
2
|
+
import { CytoscapeTree } from "../../configs/types/Tree";
|
|
3
3
|
type Props = {
|
|
4
4
|
selector: string;
|
|
5
5
|
tree: CytoscapeTree;
|
|
@@ -7,8 +7,9 @@ type Props = {
|
|
|
7
7
|
dagre?: boolean;
|
|
8
8
|
wheelSensitivity?: number;
|
|
9
9
|
onReady?: (cy: Core) => void;
|
|
10
|
+
autoungrabify?: boolean;
|
|
10
11
|
};
|
|
11
12
|
declare const SyntreesCytoscape: {
|
|
12
|
-
init: ({ selector, tree, dagre, stylesheet, wheelSensitivity, onReady, }: Props) => Core;
|
|
13
|
+
init: ({ selector, tree, dagre, stylesheet, wheelSensitivity, onReady, autoungrabify, }: Props) => Core;
|
|
13
14
|
};
|
|
14
15
|
export default SyntreesCytoscape;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import cytoscape from
|
|
2
|
-
import defaultStylesheet from
|
|
3
|
-
import nodeHtmlLabel from
|
|
1
|
+
import cytoscape from "cytoscape";
|
|
2
|
+
import defaultStylesheet from "./CytoscapeStylesheet";
|
|
3
|
+
import nodeHtmlLabel from "cytoscape-node-edge-html-label";
|
|
4
4
|
nodeHtmlLabel(cytoscape);
|
|
5
|
-
const init = ({ selector, tree, dagre = false, stylesheet = defaultStylesheet, wheelSensitivity = 1.5, onReady, }) => {
|
|
5
|
+
const init = ({ selector, tree, dagre = false, stylesheet = defaultStylesheet, wheelSensitivity = 1.5, onReady, autoungrabify = true, }) => {
|
|
6
6
|
destroy(selector);
|
|
7
7
|
const cy = cytoscape({
|
|
8
8
|
container: document.getElementById(selector),
|
|
9
|
-
layout: { name:
|
|
9
|
+
layout: { name: "preset" },
|
|
10
10
|
elements: { nodes: tree.nodes || [], edges: tree.edges || [] },
|
|
11
11
|
style: stylesheet,
|
|
12
12
|
zoom: 2,
|
|
@@ -17,11 +17,11 @@ const init = ({ selector, tree, dagre = false, stylesheet = defaultStylesheet, w
|
|
|
17
17
|
userZoomingEnabled: true,
|
|
18
18
|
userPanningEnabled: true,
|
|
19
19
|
boxSelectionEnabled: true,
|
|
20
|
-
selectionType:
|
|
20
|
+
selectionType: "single",
|
|
21
21
|
touchTapThreshold: 8,
|
|
22
22
|
desktopTapThreshold: 4,
|
|
23
23
|
autolock: false,
|
|
24
|
-
autoungrabify
|
|
24
|
+
autoungrabify,
|
|
25
25
|
autounselectify: false,
|
|
26
26
|
headless: false,
|
|
27
27
|
styleEnabled: true,
|
|
@@ -35,21 +35,21 @@ const init = ({ selector, tree, dagre = false, stylesheet = defaultStylesheet, w
|
|
|
35
35
|
});
|
|
36
36
|
cy.ready(() => {
|
|
37
37
|
if (!cy._htmlLabelsApplied) {
|
|
38
|
-
const nodesToLabel = cy.nodes(
|
|
38
|
+
const nodesToLabel = cy.nodes(".token");
|
|
39
39
|
// @ts-ignore (no types)
|
|
40
40
|
cy.nodeHtmlLabel([
|
|
41
41
|
{
|
|
42
42
|
query: nodesToLabel,
|
|
43
|
-
halign:
|
|
44
|
-
valign:
|
|
45
|
-
tpl: (data) => `<div class="token-data ${data.classes ||
|
|
43
|
+
halign: "center",
|
|
44
|
+
valign: "center",
|
|
45
|
+
tpl: (data) => `<div class="token-data ${data.classes || ""}">${data.label}</div>`,
|
|
46
46
|
},
|
|
47
47
|
]);
|
|
48
48
|
cy._htmlLabelsApplied = true; // mark as applied
|
|
49
49
|
}
|
|
50
50
|
cy.fit();
|
|
51
51
|
cy.center();
|
|
52
|
-
dagre && cy.layout({ name:
|
|
52
|
+
dagre && cy.layout({ name: "dagre" }).run();
|
|
53
53
|
onReady && onReady(cy);
|
|
54
54
|
});
|
|
55
55
|
return cy;
|
|
@@ -57,7 +57,7 @@ const init = ({ selector, tree, dagre = false, stylesheet = defaultStylesheet, w
|
|
|
57
57
|
const destroy = (selector) => {
|
|
58
58
|
const el = document.getElementById(selector);
|
|
59
59
|
if (el)
|
|
60
|
-
el.innerHTML =
|
|
60
|
+
el.innerHTML = "";
|
|
61
61
|
};
|
|
62
62
|
const SyntreesCytoscape = {
|
|
63
63
|
init,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Struct, Token } from
|
|
1
|
+
import { Struct, Token } from "../configs/types/Struct";
|
|
2
2
|
declare const SentenceUtils: {
|
|
3
3
|
sort: (struct: Struct) => Token[];
|
|
4
4
|
getAsText: (struct: Struct, displayTags?: boolean) => string;
|
|
@@ -7,5 +7,6 @@ declare const SentenceUtils: {
|
|
|
7
7
|
getColspan: (thisToken: Token) => number;
|
|
8
8
|
skipToken: (token: Token, splits?: boolean) => boolean;
|
|
9
9
|
getTag: (token: Token) => string;
|
|
10
|
+
getEditionTierName: (k: string) => string;
|
|
10
11
|
};
|
|
11
12
|
export default SentenceUtils;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { EditionTiers } from "../configs/types/EditionTiers";
|
|
1
2
|
const getTag = (token) => {
|
|
2
3
|
if (token.split)
|
|
3
|
-
return token.split.t ||
|
|
4
|
-
return token.t ??
|
|
4
|
+
return token.split.t || "";
|
|
5
|
+
return token.t ?? "";
|
|
5
6
|
};
|
|
6
7
|
const skipToken = (token, splits) => {
|
|
7
8
|
if (token.ec)
|
|
8
9
|
return true;
|
|
9
10
|
if (!token.v)
|
|
10
11
|
return false;
|
|
11
|
-
if (!splits && token.v.startsWith(
|
|
12
|
+
if (!splits && token.v.startsWith("@") && token.split)
|
|
12
13
|
return true;
|
|
13
14
|
return false;
|
|
14
15
|
};
|
|
@@ -17,7 +18,7 @@ const getColspan = (thisToken) => {
|
|
|
17
18
|
};
|
|
18
19
|
const getAsText = (struct, displayTags) => {
|
|
19
20
|
const tokens = sort(struct);
|
|
20
|
-
let value =
|
|
21
|
+
let value = "";
|
|
21
22
|
tokens.forEach((token, idx) => {
|
|
22
23
|
if (!isVisible(token))
|
|
23
24
|
return;
|
|
@@ -27,7 +28,7 @@ const getAsText = (struct, displayTags) => {
|
|
|
27
28
|
};
|
|
28
29
|
const getValue = (token, displayTags) => {
|
|
29
30
|
return token.split !== undefined && token.ec === undefined && !displayTags
|
|
30
|
-
? token.split.v ||
|
|
31
|
+
? token.split.v || ""
|
|
31
32
|
: token.v;
|
|
32
33
|
};
|
|
33
34
|
const sort = (struct) => {
|
|
@@ -47,6 +48,11 @@ const isFirstFromSplit = (token) => {
|
|
|
47
48
|
return false;
|
|
48
49
|
return token.split.idx !== undefined && token.split.idx === 0;
|
|
49
50
|
};
|
|
51
|
+
const getEditionTierName = (k) => {
|
|
52
|
+
const idx = Object.values(EditionTiers).indexOf(k);
|
|
53
|
+
const key = Object.keys(EditionTiers)[idx];
|
|
54
|
+
return key || k;
|
|
55
|
+
};
|
|
50
56
|
const SentenceUtils = {
|
|
51
57
|
sort,
|
|
52
58
|
getAsText,
|
|
@@ -55,5 +61,6 @@ const SentenceUtils = {
|
|
|
55
61
|
getColspan,
|
|
56
62
|
skipToken,
|
|
57
63
|
getTag,
|
|
64
|
+
getEditionTierName,
|
|
58
65
|
};
|
|
59
66
|
export default SentenceUtils;
|