tycho-components 0.19.5 → 0.19.7
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.
|
@@ -3,6 +3,11 @@ import { CytoscapeTreeCalculation } from './NodeCalculation';
|
|
|
3
3
|
export default class CytoscapeTreeConverter {
|
|
4
4
|
private ID_SPLITTER;
|
|
5
5
|
private extraInfo;
|
|
6
|
+
/**
|
|
7
|
+
* HTML-label extensions and similar code build `#${id}` / querySelector from cytoscape node ids.
|
|
8
|
+
* Only [a-zA-Z0-9_-] is safe unescaped; e.g. `3+VB-P` or chunk ids with `|` break selector parsing.
|
|
9
|
+
*/
|
|
10
|
+
private sanitizeGraphNodeId;
|
|
6
11
|
execute(struct: Struct, extraInfo: boolean): CytoscapeTreeCalculation | undefined;
|
|
7
12
|
getLabelLeaf(token: Token): string;
|
|
8
13
|
private splitAttributeValue;
|
|
@@ -5,6 +5,22 @@ export default class CytoscapeTreeConverter {
|
|
|
5
5
|
this.ID_SPLITTER = '|';
|
|
6
6
|
this.extraInfo = false;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* HTML-label extensions and similar code build `#${id}` / querySelector from cytoscape node ids.
|
|
10
|
+
* Only [a-zA-Z0-9_-] is safe unescaped; e.g. `3+VB-P` or chunk ids with `|` break selector parsing.
|
|
11
|
+
*/
|
|
12
|
+
sanitizeGraphNodeId(raw) {
|
|
13
|
+
let out = '';
|
|
14
|
+
for (const ch of raw) {
|
|
15
|
+
if (/[a-zA-Z0-9_-]/.test(ch)) {
|
|
16
|
+
out += ch;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
out += '_' + ch.codePointAt(0).toString(16) + '_';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
8
24
|
execute(struct, extraInfo) {
|
|
9
25
|
if (!this.validate(struct))
|
|
10
26
|
return undefined;
|
|
@@ -189,12 +205,13 @@ export default class CytoscapeTreeConverter {
|
|
|
189
205
|
}
|
|
190
206
|
}
|
|
191
207
|
generateChunkId(chunk) {
|
|
192
|
-
|
|
208
|
+
const raw = `${chunk.i}${this.ID_SPLITTER}${chunk.f}${this.ID_SPLITTER}${chunk.l}${this.ID_SPLITTER}${chunk.t}`;
|
|
209
|
+
return this.sanitizeGraphNodeId(raw);
|
|
193
210
|
}
|
|
194
211
|
generateTokenId(token) {
|
|
195
212
|
const sb = [];
|
|
196
213
|
if (token.p === null)
|
|
197
|
-
return '0';
|
|
214
|
+
return this.sanitizeGraphNodeId('0');
|
|
198
215
|
sb.push(`${token.p}`);
|
|
199
216
|
if (token.idx) {
|
|
200
217
|
sb.push('-');
|
|
@@ -204,7 +221,7 @@ export default class CytoscapeTreeConverter {
|
|
|
204
221
|
sb.push('+');
|
|
205
222
|
sb.push(token.t);
|
|
206
223
|
}
|
|
207
|
-
return sb.join('');
|
|
224
|
+
return this.sanitizeGraphNodeId(sb.join(''));
|
|
208
225
|
}
|
|
209
226
|
generateLeafId(token) {
|
|
210
227
|
if (token.p === null)
|
|
@@ -3,3 +3,5 @@ export declare const structWithMorphemes: Struct;
|
|
|
3
3
|
export declare const structNotParsed: Struct;
|
|
4
4
|
export declare const structWithEditionTiers: Struct;
|
|
5
5
|
export declare const structWithMorphemesAndSplitters: Struct;
|
|
6
|
+
/** Minimal tree where a token POS contains `+` / `-` (e.g. VB-P); ids must stay valid for `#${id}` (HTML label layer). */
|
|
7
|
+
export declare const structWithHyphenatedPosTokenId: Struct;
|
|
@@ -1297,3 +1297,25 @@ export const structWithMorphemesAndSplitters = {
|
|
|
1297
1297
|
status: 'AUTO',
|
|
1298
1298
|
parsed: '2025-09-21T17:27:38.388+00:00',
|
|
1299
1299
|
};
|
|
1300
|
+
/** Minimal tree where a token POS contains `+` / `-` (e.g. VB-P); ids must stay valid for `#${id}` (HTML label layer). */
|
|
1301
|
+
export const structWithHyphenatedPosTokenId = {
|
|
1302
|
+
uid: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
|
|
1303
|
+
parsed: '2026-05-11T12:00:00.000+00:00',
|
|
1304
|
+
tokens: [
|
|
1305
|
+
{ p: 1, v: 'they', t: 'N', l: 1 },
|
|
1306
|
+
{ p: 2, v: 'might', t: 'M', l: 1 },
|
|
1307
|
+
{ p: 3, v: 'run', t: 'VB-P', l: 1 },
|
|
1308
|
+
],
|
|
1309
|
+
chunks: [
|
|
1310
|
+
{
|
|
1311
|
+
i: 1,
|
|
1312
|
+
f: 3,
|
|
1313
|
+
t: 'IP-MAT',
|
|
1314
|
+
l: 0,
|
|
1315
|
+
},
|
|
1316
|
+
],
|
|
1317
|
+
corpus: 'C-test',
|
|
1318
|
+
document: 'D-selector',
|
|
1319
|
+
page: 'P1',
|
|
1320
|
+
psd: '(IP-MAT (N they) (M might) (VB-P run))',
|
|
1321
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tycho-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.19.
|
|
4
|
+
"version": "0.19.7",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-hook-form": "^7.45.2",
|
|
50
50
|
"react-i18next": "^13.0.2",
|
|
51
51
|
"react-router-dom": "^6.14.2",
|
|
52
|
-
"tycho-storybook": "0.7.
|
|
52
|
+
"tycho-storybook": "0.7.1",
|
|
53
53
|
"yup": "^1.2.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|