Skip to content

Commit d4363e9

Browse files
committed
fix: URI's were always shown abbreviated
1 parent 2364d13 commit d4363e9

File tree

3 files changed

+130
-3
lines changed

3 files changed

+130
-3
lines changed

demo/index.html

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ <h1>🔷 Table Plugin Standalone Demo</h1>
116116
<option value="datatypes">Datatypes Test (10 rows)</option>
117117
<option value="large">Large Dataset (1000 rows)</option>
118118
<option value="unicode">Unicode & Special Chars</option>
119+
<option value="ontology">Ontology/RDF Types (10 rows)</option>
119120
</select>
120121
</label>
121122

@@ -245,6 +246,119 @@ <h1>🔷 Table Plugin Standalone Demo</h1>
245246
{ language: { type: 'literal', value: 'Greek', 'xml:lang': 'en' }, text: { type: 'literal', value: 'Γεια σου κόσμε', 'xml:lang': 'el' }, special: { type: 'literal', value: 'http://example.org/path?query=value&foo=bar' } }
246247
]
247248
}
249+
},
250+
251+
ontology: {
252+
head: {
253+
vars: [
254+
"sub",
255+
"obj"
256+
]
257+
},
258+
results: {
259+
bindings: [
260+
{
261+
sub: {
262+
type: "uri",
263+
value: "http://www.w3.org/2000/01/rdf-schema#Resource"
264+
},
265+
obj: {
266+
type: "uri",
267+
value: "http://www.w3.org/2002/07/owl#Class"
268+
}
269+
},
270+
{
271+
sub: {
272+
type: "uri",
273+
value: "http://www.opengis.net/ont/geosparql#asWKT"
274+
},
275+
obj: {
276+
type: "uri",
277+
value: "http://www.w3.org/2002/07/owl#DatatypeProperty"
278+
}
279+
},
280+
{
281+
sub: {
282+
type: "uri",
283+
value: "http://www.w3.org/2003/01/geo/wgs84_pos#lat"
284+
},
285+
obj: {
286+
type: "uri",
287+
value: "http://www.w3.org/2002/07/owl#AnnotationProperty"
288+
}
289+
},
290+
{
291+
sub: {
292+
type: "uri",
293+
value: "http://www.w3.org/2003/01/geo/wgs84_pos#long"
294+
},
295+
obj: {
296+
type: "uri",
297+
value: "http://www.w3.org/2002/07/owl#AnnotationProperty"
298+
}
299+
},
300+
{
301+
sub: {
302+
type: "uri",
303+
value: "http://data.europa.eu/949/contactLineSystemType"
304+
},
305+
obj: {
306+
type: "uri",
307+
value: "http://www.w3.org/2002/07/owl#ObjectProperty"
308+
}
309+
},
310+
{
311+
sub: {
312+
type: "uri",
313+
value: "http://data.europa.eu/949/functionalInfrastructure/contactLineSystems/10101_ATBh%20S11_1_ATBh%20S12_Overhead%20contact%20line%20%28OCL%29"
314+
},
315+
obj: {
316+
type: "uri",
317+
value: "http://data.europa.eu/949/ContactLineSystem"
318+
}
319+
},
320+
{
321+
sub: {
322+
type: "uri",
323+
value: "http://data.europa.eu/949/concepts/contact-line-systems/rinf/10"
324+
},
325+
obj: {
326+
type: "uri",
327+
value: "http://www.w3.org/2004/02/skos/core#Concept"
328+
}
329+
},
330+
{
331+
sub: {
332+
type: "uri",
333+
value: "http://data.europa.eu/949/currentLimitationRequired"
334+
},
335+
obj: {
336+
type: "uri",
337+
value: "http://www.w3.org/2002/07/owl#DatatypeProperty"
338+
}
339+
},
340+
{
341+
sub: {
342+
type: "uri",
343+
value: "http://data.europa.eu/949/energySupplySystem"
344+
},
345+
obj: {
346+
type: "uri",
347+
value: "http://www.w3.org/2002/07/owl#ObjectProperty"
348+
}
349+
},
350+
{
351+
sub: {
352+
type: "uri",
353+
value: "http://data.europa.eu/949/concepts/energy-supply-systems/rinf/AC20"
354+
},
355+
obj: {
356+
type: "uri",
357+
value: "http://www.w3.org/2004/02/skos/core#Concept"
358+
}
359+
}
360+
]
361+
}
248362
}
249363
};
250364

@@ -268,6 +382,11 @@ <h1>🔷 Table Plugin Standalone Demo</h1>
268382
'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
269383
'rdfs': 'http://www.w3.org/2000/01/rdf-schema#',
270384
'xsd': 'http://www.w3.org/2001/XMLSchema#',
385+
'owl': 'http://www.w3.org/2002/07/owl#',
386+
'skos': 'http://www.w3.org/2004/02/skos/core#',
387+
'geo': 'http://www.w3.org/2003/01/geo/wgs84_pos#',
388+
'geosparql': 'http://www.opengis.net/ont/geosparql#',
389+
'era': 'http://data.europa.eu/949/',
271390
'ex': 'http://example.org/'
272391
})
273392
};

src/formatters/uri-formatter.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class UriFormatter {
2727
}
2828

2929
const uri = binding.value;
30+
// Only abbreviate when displayMode is 'abbreviated'
3031
const displayText =
3132
this.displayMode === 'abbreviated' ? this.prefixResolver.abbreviate(uri) : uri;
3233

@@ -53,4 +54,11 @@ export class UriFormatter {
5354
setDisplayMode(mode: 'full' | 'abbreviated'): void {
5455
this.displayMode = mode;
5556
}
57+
58+
/**
59+
* Get current display mode
60+
*/
61+
getDisplayMode(): 'full' | 'abbreviated' {
62+
return this.displayMode;
63+
}
5664
}

src/table-renderer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,11 @@ export class TableRenderer {
298298
*/
299299
updatePrefixes(prefixMap: Record<string, string>): void {
300300
this.prefixResolver = new PrefixResolver(prefixMap);
301-
// Update URI formatter with new prefix resolver
302-
const displayConfig = this.config.displayConfig || {};
301+
// Update URI formatter with new prefix resolver while preserving current display mode
302+
const currentDisplayMode = this.uriFormatter.getDisplayMode();
303303
this.uriFormatter = new UriFormatter(
304304
this.prefixResolver,
305-
displayConfig.uriDisplayMode || 'full'
305+
currentDisplayMode
306306
);
307307
}
308308

0 commit comments

Comments
 (0)