glossarist 0.4.37 → 0.4.39
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.
- package/package.json +1 -1
- package/src/models/base.ts +18 -1
- package/src/models/bibliography-data.ts +64 -0
- package/src/models/{bibliography-entry.js → bibliography-entry.ts} +18 -4
- package/src/models/citation.ts +98 -0
- package/src/models/{concept-reference.js → concept-reference.ts} +21 -7
- package/src/models/designation-relationship.ts +39 -0
- package/src/models/detailed-definition.ts +92 -0
- package/src/models/figure.ts +110 -0
- package/src/models/formula.ts +36 -0
- package/src/models/grammar-info.ts +78 -0
- package/src/models/{locality.js → locality.ts} +16 -4
- package/src/models/localized-string.ts +32 -0
- package/src/models/non-verb-rep.ts +48 -0
- package/src/models/non-verbal-entity.ts +65 -0
- package/src/models/non-verbal-reference.ts +73 -0
- package/src/models/non-verbal-references.ts +29 -0
- package/src/models/{pronunciation.js → pronunciation.ts} +18 -4
- package/src/models/registrable.ts +48 -0
- package/src/models/{related-concept.js → related-concept.ts} +49 -25
- package/src/models/shared-non-verbal-entity.ts +36 -0
- package/src/models/table.ts +36 -0
- package/src/models/bibliography-data.js +0 -48
- package/src/models/citation.js +0 -68
- package/src/models/designation-relationship.js +0 -27
- package/src/models/detailed-definition.js +0 -59
- package/src/models/figure.js +0 -75
- package/src/models/formula.js +0 -25
- package/src/models/grammar-info.js +0 -40
- package/src/models/localized-string.js +0 -19
- package/src/models/non-verb-rep.js +0 -33
- package/src/models/non-verbal-entity.js +0 -46
- package/src/models/non-verbal-reference.js +0 -35
- package/src/models/non-verbal-references.js +0 -16
- package/src/models/registrable.js +0 -25
- package/src/models/shared-non-verbal-entity.js +0 -28
- package/src/models/table.js +0 -25
package/src/models/citation.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { GlossaristModel } from './base.js';
|
|
2
|
-
import { Locality } from './locality.js';
|
|
3
|
-
|
|
4
|
-
export class Citation extends GlossaristModel {
|
|
5
|
-
constructor(data = {}) {
|
|
6
|
-
super();
|
|
7
|
-
const d = data ?? {};
|
|
8
|
-
|
|
9
|
-
this.ref = d.ref
|
|
10
|
-
? (d.ref instanceof Citation.Ref ? d.ref : new Citation.Ref(d.ref))
|
|
11
|
-
: null;
|
|
12
|
-
|
|
13
|
-
this.locality = d.locality
|
|
14
|
-
? (d.locality instanceof Locality ? d.locality : new Locality(d.locality))
|
|
15
|
-
: null;
|
|
16
|
-
this.link = d.link ?? null;
|
|
17
|
-
this.original = d.original ?? null;
|
|
18
|
-
this.customLocality = d.custom_locality ?? d.customLocality ?? null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
toString() {
|
|
22
|
-
if (this.ref) return this.ref.toString();
|
|
23
|
-
return '';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
toJSON() {
|
|
27
|
-
const obj = {};
|
|
28
|
-
if (this.ref != null) obj.ref = this.ref.toJSON();
|
|
29
|
-
if (this.locality != null) obj.locality = this.locality.toJSON();
|
|
30
|
-
if (this.link != null) obj.link = this.link;
|
|
31
|
-
if (this.original != null) obj.original = this.original;
|
|
32
|
-
if (this.customLocality != null) obj.custom_locality = this.customLocality;
|
|
33
|
-
return obj;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static fromJSON(data) {
|
|
37
|
-
return new Citation(data);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
Citation.Ref = class Ref extends GlossaristModel {
|
|
42
|
-
constructor(data = {}) {
|
|
43
|
-
super();
|
|
44
|
-
const d = data ?? {};
|
|
45
|
-
this.source = d.source ?? null;
|
|
46
|
-
this.id = d.id ?? null;
|
|
47
|
-
this.version = d.version ?? null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
toString() {
|
|
51
|
-
const parts = [];
|
|
52
|
-
if (this.source) parts.push(this.source);
|
|
53
|
-
if (this.id) parts.push(this.id);
|
|
54
|
-
return parts.join(' ');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
toJSON() {
|
|
58
|
-
const obj = {};
|
|
59
|
-
if (this.source != null) obj.source = this.source;
|
|
60
|
-
if (this.id != null) obj.id = this.id;
|
|
61
|
-
if (this.version != null) obj.version = this.version;
|
|
62
|
-
return obj;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static fromJSON(data) {
|
|
66
|
-
return new Citation.Ref(data);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { GlossaristModel } from './base.js';
|
|
2
|
-
|
|
3
|
-
export const DESIGNATION_RELATIONSHIP_TYPES = Object.freeze([
|
|
4
|
-
// TBX (ISO 30042) / ISO 12620 term-level relationships
|
|
5
|
-
'abbreviated_form_for', 'short_form_for',
|
|
6
|
-
]);
|
|
7
|
-
|
|
8
|
-
export class DesignationRelationship extends GlossaristModel {
|
|
9
|
-
constructor(data = {}) {
|
|
10
|
-
super();
|
|
11
|
-
this.type = data.type ?? null;
|
|
12
|
-
this.content = data.content ?? null;
|
|
13
|
-
this.target = data.target ?? null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
toJSON() {
|
|
17
|
-
const obj = {};
|
|
18
|
-
if (this.type != null) obj.type = this.type;
|
|
19
|
-
if (this.content != null) obj.content = this.content;
|
|
20
|
-
if (this.target != null) obj.target = this.target;
|
|
21
|
-
return obj;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static fromJSON(data) {
|
|
25
|
-
return new DesignationRelationship(data);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { GlossaristModel } from './base.js';
|
|
2
|
-
import { Citation } from './citation.js';
|
|
3
|
-
import { canonicalJson } from '../diff/canonical-json.js';
|
|
4
|
-
|
|
5
|
-
export class DetailedDefinition extends GlossaristModel {
|
|
6
|
-
constructor(data = {}) {
|
|
7
|
-
super();
|
|
8
|
-
this.content = data.content ?? '';
|
|
9
|
-
this._rawSources = data.sources ?? [];
|
|
10
|
-
this._rawExamples = data.examples ?? [];
|
|
11
|
-
this._sources = null;
|
|
12
|
-
this._examples = null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
get sources() {
|
|
16
|
-
return this._lazy('_sources', '_rawSources',
|
|
17
|
-
s => s instanceof Citation ? s : new Citation(s));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get examples() {
|
|
21
|
-
return this._lazy('_examples', '_rawExamples',
|
|
22
|
-
e => e instanceof DetailedDefinition ? e : new DetailedDefinition(e));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
toJSON() {
|
|
26
|
-
const obj = { content: this.content };
|
|
27
|
-
this._serialize(obj, 'sources', '_sources', '_rawSources');
|
|
28
|
-
this._serialize(obj, 'examples', '_examples', '_rawExamples');
|
|
29
|
-
return obj;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Yield this definition's content and the content of every nested
|
|
34
|
-
* example (recursively). Each item carries `{ text, source }` where
|
|
35
|
-
* `source` is `<path>.content` rooted at the `path` argument.
|
|
36
|
-
*/
|
|
37
|
-
*walkTexts(path) {
|
|
38
|
-
if (typeof this.content === 'string' && this.content.length > 0) {
|
|
39
|
-
yield { text: this.content, source: `${path}.content` };
|
|
40
|
-
}
|
|
41
|
-
for (let i = 0; i < this.examples.length; i++) {
|
|
42
|
-
yield* this.examples[i].walkTexts(`${path}.examples[${i}]`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static identityOf(value) {
|
|
47
|
-
if (value == null) return '';
|
|
48
|
-
if (typeof value.toJSON === 'function') return canonicalJson(value.toJSON());
|
|
49
|
-
return canonicalJson(value);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
identity() {
|
|
53
|
-
return DetailedDefinition.identityOf(this);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
static fromJSON(data) {
|
|
57
|
-
return new DetailedDefinition(data);
|
|
58
|
-
}
|
|
59
|
-
}
|
package/src/models/figure.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { SharedNonVerbalEntity } from './shared-non-verbal-entity.js';
|
|
2
|
-
import { NonVerbalEntity } from './non-verbal-entity.js';
|
|
3
|
-
|
|
4
|
-
export class FigureImage {
|
|
5
|
-
constructor(data = {}) {
|
|
6
|
-
this.src = data.src ?? null;
|
|
7
|
-
this.format = data.format ?? null;
|
|
8
|
-
this.role = data.role ?? null;
|
|
9
|
-
this.width = data.width ?? null;
|
|
10
|
-
this.height = data.height ?? null;
|
|
11
|
-
this.scale = data.scale ?? null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
toJSON() {
|
|
15
|
-
const obj = {};
|
|
16
|
-
if (this.src != null) obj.src = this.src;
|
|
17
|
-
if (this.format != null) obj.format = this.format;
|
|
18
|
-
if (this.role != null) obj.role = this.role;
|
|
19
|
-
if (this.width != null) obj.width = this.width;
|
|
20
|
-
if (this.height != null) obj.height = this.height;
|
|
21
|
-
if (this.scale != null) obj.scale = this.scale;
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static fromJSON(data) { return new FigureImage(data); }
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export class Figure extends SharedNonVerbalEntity {
|
|
29
|
-
constructor(data = {}) {
|
|
30
|
-
super(data);
|
|
31
|
-
this._rawImages = data.images ?? [];
|
|
32
|
-
this._rawSubfigures = data.subfigures ?? [];
|
|
33
|
-
this._images = null;
|
|
34
|
-
this._subfigures = null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
rdfClass() {
|
|
38
|
-
return 'Figure';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get images() {
|
|
42
|
-
return this._lazy('_images', '_rawImages',
|
|
43
|
-
i => i instanceof FigureImage ? i : new FigureImage(i));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get subfigures() {
|
|
47
|
-
return this._lazy('_subfigures', '_rawSubfigures',
|
|
48
|
-
s => s instanceof Figure ? s : new Figure(s));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
findById(targetId) {
|
|
52
|
-
if (this.id === targetId) return this;
|
|
53
|
-
for (const sub of this.subfigures) {
|
|
54
|
-
const found = sub.findById(targetId);
|
|
55
|
-
if (found) return found;
|
|
56
|
-
}
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
allIds() {
|
|
61
|
-
const ids = this.id != null ? [this.id] : [];
|
|
62
|
-
return [...ids, ...this.subfigures.flatMap(s => s.allIds())];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
toJSON() {
|
|
66
|
-
const obj = super.toJSON();
|
|
67
|
-
this._serialize(obj, 'images', '_images', '_rawImages');
|
|
68
|
-
this._serialize(obj, 'subfigures', '_subfigures', '_rawSubfigures');
|
|
69
|
-
return obj;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
static fromJSON(data) { return new Figure(data); }
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
NonVerbalEntity.register('figure', Figure);
|
package/src/models/formula.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { SharedNonVerbalEntity } from './shared-non-verbal-entity.js';
|
|
2
|
-
import { NonVerbalEntity } from './non-verbal-entity.js';
|
|
3
|
-
|
|
4
|
-
export class Formula extends SharedNonVerbalEntity {
|
|
5
|
-
constructor(data = {}) {
|
|
6
|
-
super(data);
|
|
7
|
-
this.expression = data.expression ?? null;
|
|
8
|
-
this.notation = data.notation ?? null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
rdfClass() {
|
|
12
|
-
return 'Formula';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
toJSON() {
|
|
16
|
-
const obj = super.toJSON();
|
|
17
|
-
if (this.expression != null) obj.expression = this.expression;
|
|
18
|
-
if (this.notation != null) obj.notation = this.notation;
|
|
19
|
-
return obj;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static fromJSON(data) { return new Formula(data); }
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
NonVerbalEntity.register('formula', Formula);
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { GlossaristModel } from './base.js';
|
|
2
|
-
|
|
3
|
-
export const GRAMMAR_GENDERS = Object.freeze(['m', 'f', 'n', 'c']);
|
|
4
|
-
export const GRAMMAR_NUMBERS = Object.freeze(['singular', 'dual', 'plural']);
|
|
5
|
-
export const GRAMMAR_PARTS_OF_SPEECH = Object.freeze([
|
|
6
|
-
'noun', 'verb', 'adj', 'adverb', 'preposition', 'participle',
|
|
7
|
-
]);
|
|
8
|
-
|
|
9
|
-
export class GrammarInfo extends GlossaristModel {
|
|
10
|
-
constructor(data = {}) {
|
|
11
|
-
super();
|
|
12
|
-
this.gender = data.gender ?? null;
|
|
13
|
-
this.number = data.number ?? null;
|
|
14
|
-
this.partOfSpeech = data.part_of_speech ?? data.partOfSpeech ?? null;
|
|
15
|
-
this.noun = data.noun ?? false;
|
|
16
|
-
this.verb = data.verb ?? false;
|
|
17
|
-
this.adj = data.adj ?? false;
|
|
18
|
-
this.adverb = data.adverb ?? false;
|
|
19
|
-
this.preposition = data.preposition ?? false;
|
|
20
|
-
this.participle = data.participle ?? false;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
toJSON() {
|
|
24
|
-
const obj = {};
|
|
25
|
-
if (this.gender != null) obj.gender = this.gender;
|
|
26
|
-
if (this.number != null) obj.number = this.number;
|
|
27
|
-
if (this.partOfSpeech != null) obj.part_of_speech = this.partOfSpeech;
|
|
28
|
-
if (this.noun) obj.noun = true;
|
|
29
|
-
if (this.verb) obj.verb = true;
|
|
30
|
-
if (this.adj) obj.adj = true;
|
|
31
|
-
if (this.adverb) obj.adverb = true;
|
|
32
|
-
if (this.preposition) obj.preposition = true;
|
|
33
|
-
if (this.participle) obj.participle = true;
|
|
34
|
-
return obj;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static fromJSON(data) {
|
|
38
|
-
return new GrammarInfo(data);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const FALLBACK_LANG = 'eng';
|
|
2
|
-
|
|
3
|
-
export function fetchLocalizedString(hash, lang, fallback = FALLBACK_LANG) {
|
|
4
|
-
if (hash == null || typeof hash !== 'object') return null;
|
|
5
|
-
const direct = hash[lang] ?? hash[String(lang)];
|
|
6
|
-
if (direct != null) return direct;
|
|
7
|
-
if (fallback != null && fallback !== lang) {
|
|
8
|
-
return hash[fallback] ?? hash[String(fallback)] ?? null;
|
|
9
|
-
}
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function localizedStringIsEmpty(hash) {
|
|
14
|
-
return hash == null || (typeof hash === 'object' && Object.keys(hash).length === 0);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function localizedStringIsPresent(hash) {
|
|
18
|
-
return !localizedStringIsEmpty(hash);
|
|
19
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { NonVerbalEntity } from './non-verbal-entity.js';
|
|
2
|
-
import { FigureImage } from './figure.js';
|
|
3
|
-
|
|
4
|
-
export const NON_VERBAL_TYPES = Object.freeze(['image', 'table', 'formula']);
|
|
5
|
-
|
|
6
|
-
export class NonVerbRep extends NonVerbalEntity {
|
|
7
|
-
constructor(data = {}) {
|
|
8
|
-
super(data);
|
|
9
|
-
this.type = data.type ?? null;
|
|
10
|
-
this._rawImages = data.images ?? [];
|
|
11
|
-
this._images = null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
rdfClass() {
|
|
15
|
-
return 'NonVerbalRepresentation';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
get images() {
|
|
19
|
-
return this._lazy('_images', '_rawImages',
|
|
20
|
-
i => i instanceof FigureImage ? i : new FigureImage(i));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
toJSON() {
|
|
24
|
-
const obj = super.toJSON();
|
|
25
|
-
if (this.type != null) obj.type = this.type;
|
|
26
|
-
this._serialize(obj, 'images', '_images', '_rawImages');
|
|
27
|
-
return obj;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static fromJSON(data) {
|
|
31
|
-
return new NonVerbRep(data);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { RegistrableModel } from './registrable.js';
|
|
2
|
-
import { ConceptSource } from './concept-source.js';
|
|
3
|
-
|
|
4
|
-
export class NonVerbalEntity extends RegistrableModel {
|
|
5
|
-
constructor(data = {}) {
|
|
6
|
-
super();
|
|
7
|
-
this.caption = data.caption ?? null;
|
|
8
|
-
this.description = data.description ?? null;
|
|
9
|
-
this.alt = data.alt ?? null;
|
|
10
|
-
this._rawSources = data.sources ?? [];
|
|
11
|
-
this._sources = null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
get sources() {
|
|
15
|
-
return this._lazy('_sources', '_rawSources',
|
|
16
|
-
s => s instanceof ConceptSource ? s : new ConceptSource(s));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Ontology class local-name. Subtypes override to return their specific
|
|
20
|
-
// class (Figure/Table/Formula). Used by the RDF emitter so a new subtype
|
|
21
|
-
// registers without editing the emitter (OCP).
|
|
22
|
-
rdfClass() {
|
|
23
|
-
return 'NonVerbalEntity';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
findById(_targetId) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
allIds() {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
toJSON() {
|
|
35
|
-
const obj = {};
|
|
36
|
-
if (this.caption != null) obj.caption = this.caption;
|
|
37
|
-
if (this.description != null) obj.description = this.description;
|
|
38
|
-
if (this.alt != null) obj.alt = this.alt;
|
|
39
|
-
this._serialize(obj, 'sources', '_sources', '_rawSources');
|
|
40
|
-
return obj;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static fromJSON(data) {
|
|
44
|
-
return NonVerbalEntity.fromData(data);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { RegistrableModel } from './registrable.js';
|
|
2
|
-
|
|
3
|
-
export class NonVerbalReference extends RegistrableModel {
|
|
4
|
-
constructor(data = {}) {
|
|
5
|
-
super();
|
|
6
|
-
this.entityId = data.entityId ?? data.entity_id ?? data.ref ?? data.id ?? null;
|
|
7
|
-
this.display = data.display ?? null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
get dedupKey() {
|
|
11
|
-
return [this.constructor.name, this.entityId];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
toJSON() {
|
|
15
|
-
if (this.display != null) {
|
|
16
|
-
return { ref: this.entityId, display: this.display };
|
|
17
|
-
}
|
|
18
|
-
return this.entityId;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static fromJSON(data) {
|
|
22
|
-
if (data instanceof NonVerbalReference) return data;
|
|
23
|
-
if (typeof data === 'string') {
|
|
24
|
-
return new NonVerbalReference({ entityId: data });
|
|
25
|
-
}
|
|
26
|
-
const entityId = data.entityId ?? data.entity_id ?? data.ref ?? data.id ?? null;
|
|
27
|
-
const display = data.display ?? null;
|
|
28
|
-
const type = data.type;
|
|
29
|
-
if (type && this._registry().has(type)) {
|
|
30
|
-
const Cls = this._registry().get(type);
|
|
31
|
-
return new Cls({ entityId, display });
|
|
32
|
-
}
|
|
33
|
-
return new NonVerbalReference({ entityId, display });
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { NonVerbalReference } from './non-verbal-reference.js';
|
|
2
|
-
|
|
3
|
-
export class FigureReference extends NonVerbalReference {
|
|
4
|
-
static fromJSON(data) { return NonVerbalReference.fromJSON(data); }
|
|
5
|
-
}
|
|
6
|
-
NonVerbalReference.register('figure', FigureReference);
|
|
7
|
-
|
|
8
|
-
export class TableReference extends NonVerbalReference {
|
|
9
|
-
static fromJSON(data) { return NonVerbalReference.fromJSON(data); }
|
|
10
|
-
}
|
|
11
|
-
NonVerbalReference.register('table', TableReference);
|
|
12
|
-
|
|
13
|
-
export class FormulaReference extends NonVerbalReference {
|
|
14
|
-
static fromJSON(data) { return NonVerbalReference.fromJSON(data); }
|
|
15
|
-
}
|
|
16
|
-
NonVerbalReference.register('formula', FormulaReference);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { GlossaristModel } from './base.js';
|
|
2
|
-
|
|
3
|
-
const _registries = new WeakMap();
|
|
4
|
-
|
|
5
|
-
export class RegistrableModel extends GlossaristModel {
|
|
6
|
-
static _registry() {
|
|
7
|
-
let map = _registries.get(this);
|
|
8
|
-
if (!map) {
|
|
9
|
-
map = new Map();
|
|
10
|
-
_registries.set(this, map);
|
|
11
|
-
}
|
|
12
|
-
return map;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
static register(type, cls) {
|
|
16
|
-
this._registry().set(type, cls);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static fromData(data) {
|
|
20
|
-
if (data instanceof this) return data;
|
|
21
|
-
const type = data?.type;
|
|
22
|
-
const Cls = type ? this._registry().get(type) ?? this : this;
|
|
23
|
-
return new Cls(data);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { NonVerbalEntity } from './non-verbal-entity.js';
|
|
2
|
-
|
|
3
|
-
export class SharedNonVerbalEntity extends NonVerbalEntity {
|
|
4
|
-
constructor(data = {}) {
|
|
5
|
-
super(data);
|
|
6
|
-
this.id = data.id ?? null;
|
|
7
|
-
this.identifier = data.identifier ?? null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
findById(targetId) {
|
|
11
|
-
return this.id === targetId ? this : null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
allIds() {
|
|
15
|
-
return this.id != null ? [this.id] : [];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
toJSON() {
|
|
19
|
-
const obj = super.toJSON();
|
|
20
|
-
if (this.id != null) obj.id = this.id;
|
|
21
|
-
if (this.identifier != null) obj.identifier = this.identifier;
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static fromJSON(data) {
|
|
26
|
-
return SharedNonVerbalEntity.fromData(data);
|
|
27
|
-
}
|
|
28
|
-
}
|
package/src/models/table.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { SharedNonVerbalEntity } from './shared-non-verbal-entity.js';
|
|
2
|
-
import { NonVerbalEntity } from './non-verbal-entity.js';
|
|
3
|
-
|
|
4
|
-
export class Table extends SharedNonVerbalEntity {
|
|
5
|
-
constructor(data = {}) {
|
|
6
|
-
super(data);
|
|
7
|
-
this.content = data.content ?? null;
|
|
8
|
-
this.format = data.format ?? null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
rdfClass() {
|
|
12
|
-
return 'Table';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
toJSON() {
|
|
16
|
-
const obj = super.toJSON();
|
|
17
|
-
if (this.content != null) obj.content = this.content;
|
|
18
|
-
if (this.format != null) obj.format = this.format;
|
|
19
|
-
return obj;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static fromJSON(data) { return new Table(data); }
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
NonVerbalEntity.register('table', Table);
|