@lblod/ember-rdfa-editor-lblod-plugins 1.0.0-alpha.3 → 1.0.0-beta.2
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/CHANGELOG.md +48 -0
- package/addon/components/article-structure-plugin/article-structure-card.hbs +3 -1
- package/addon/components/au-dropdown-pill.hbs +32 -0
- package/addon/components/au-dropdown-pill.ts +65 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +19 -12
- package/addon/components/citation-plugin/citation-card.hbs +2 -2
- package/addon/components/citation-plugin/citation-card.ts +1 -1
- package/addon/components/citation-plugin/citation-insert.hbs +3 -1
- package/addon/components/citation-plugin/citation-insert.ts +28 -2
- package/addon/components/citation-plugin/citations/search-modal.hbs +1 -1
- package/addon/components/citation-plugin/citations/search-modal.ts +3 -18
- package/addon/components/import-snippet-plugin/card.ts +8 -12
- package/addon/components/rdfa-date-plugin/card.hbs +28 -0
- package/addon/components/rdfa-date-plugin/card.ts +72 -38
- package/addon/components/rdfa-date-plugin/date-time-picker.ts +1 -0
- package/addon/components/rdfa-date-plugin/insert.hbs +2 -2
- package/addon/components/rdfa-date-plugin/insert.ts +14 -23
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +24 -25
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +37 -18
- package/addon/components/standard-template-plugin/template-provider.ts +54 -11
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +27 -30
- package/addon/components/table-of-contents-plugin/toolbar-button.hbs +8 -0
- package/addon/components/table-of-contents-plugin/{card.ts → toolbar-button.ts} +1 -18
- package/addon/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.hbs +4 -4
- package/addon/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.ts +26 -35
- package/addon/components/{template-variable-plugin → variable-plugin}/template-variable-card.hbs +6 -6
- package/addon/components/variable-plugin/template-variable-card.ts +174 -0
- package/addon/components/variable-plugin/variable.hbs +4 -0
- package/addon/components/variable-plugin/variable.ts +250 -0
- package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +58 -31
- package/addon/plugins/article-structure-plugin/index.ts +1 -1
- package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +42 -6
- package/addon/plugins/article-structure-plugin/structures/article.ts +14 -4
- package/addon/plugins/article-structure-plugin/structures/chapter.ts +2 -3
- package/addon/plugins/article-structure-plugin/structures/section.ts +2 -2
- package/addon/plugins/article-structure-plugin/structures/structure-header.ts +11 -4
- package/addon/plugins/article-structure-plugin/structures/subsection.ts +2 -2
- package/addon/plugins/article-structure-plugin/structures/title.ts +2 -3
- package/addon/plugins/article-structure-plugin/utils/structure.ts +29 -9
- package/addon/plugins/citation-plugin/index.ts +184 -113
- package/addon/plugins/rdfa-date-plugin/index.ts +42 -3
- package/addon/plugins/rdfa-date-plugin/nodes/date.ts +127 -0
- package/addon/plugins/rdfa-date-plugin/nodes/index.ts +1 -0
- package/addon/plugins/rdfa-date-plugin/utils.ts +10 -0
- package/addon/plugins/roadsign-regulation-plugin/nodes.ts +107 -0
- package/addon/plugins/standard-template-plugin/index.ts +26 -0
- package/addon/plugins/standard-template-plugin/utils/nodes.ts +366 -0
- package/addon/plugins/table-of-contents-plugin/index.ts +8 -12
- package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +35 -42
- package/addon/plugins/{insert-variable-plugin → variable-plugin}/index.ts +6 -1
- package/addon/plugins/variable-plugin/nodes.ts +137 -0
- package/addon/plugins/variable-plugin/utils/constants.ts +107 -0
- package/addon/plugins/{template-variable-plugin → variable-plugin}/utils/fetch-data.ts +41 -0
- package/addon/services/standard-template-plugin.ts +16 -12
- package/addon/utils/changed-descendants.ts +29 -0
- package/addon/utils/constants.ts +22 -0
- package/addon/utils/namespace.ts +60 -0
- package/app/components/{table-of-contents-plugin/card.js → au-dropdown-pill.js} +1 -1
- package/app/components/table-of-contents-plugin/toolbar-button.js +1 -0
- package/app/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.js +1 -1
- package/app/components/{template-variable-plugin → variable-plugin}/template-variable-card.js +1 -1
- package/app/components/variable-plugin/variable-edit-modal.js +1 -0
- package/app/components/variable-plugin/variable.js +1 -0
- package/app/styles/date-plugin.scss +17 -0
- package/app/styles/variable-plugin.scss +65 -0
- package/components/au-dropdown-pill.d.ts +19 -0
- package/components/au-native-input.d.ts +1 -1
- package/components/citation-plugin/citation-card.d.ts +1 -1
- package/components/citation-plugin/citation-insert.d.ts +7 -0
- package/components/citation-plugin/citations/search-modal.d.ts +1 -3
- package/components/rdfa-date-plugin/card.d.ts +14 -5
- package/components/rdfa-date-plugin/insert.d.ts +1 -2
- package/components/roadsign-regulation-plugin/roadsign-regulation-card.d.ts +1 -0
- package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +3 -0
- package/components/standard-template-plugin/template-provider.d.ts +6 -1
- package/components/table-of-contents-plugin/ember-nodes/table-of-contents.d.ts +1 -1
- package/components/table-of-contents-plugin/{card.d.ts → toolbar-button.d.ts} +0 -5
- package/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.d.ts +3 -4
- package/components/{template-variable-plugin → variable-plugin}/template-variable-card.d.ts +8 -5
- package/components/variable-plugin/variable.d.ts +42 -0
- package/package.json +6 -6
- package/plugins/article-structure-plugin/commands/insert-structure.d.ts +2 -2
- package/plugins/article-structure-plugin/index.d.ts +1 -1
- package/plugins/article-structure-plugin/utils/structure.d.ts +4 -3
- package/plugins/citation-plugin/index.d.ts +11 -4
- package/plugins/rdfa-date-plugin/index.d.ts +13 -1
- package/plugins/rdfa-date-plugin/nodes/date.d.ts +9 -0
- package/plugins/rdfa-date-plugin/nodes/index.d.ts +1 -0
- package/plugins/rdfa-date-plugin/utils.d.ts +1 -0
- package/plugins/roadsign-regulation-plugin/nodes.d.ts +2 -0
- package/plugins/standard-template-plugin/index.d.ts +12 -0
- package/plugins/standard-template-plugin/utils/nodes.d.ts +12 -0
- package/plugins/table-of-contents-plugin/index.d.ts +4 -2
- package/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +4 -3
- package/plugins/{insert-variable-plugin → variable-plugin}/index.d.ts +1 -0
- package/plugins/variable-plugin/nodes.d.ts +2 -0
- package/plugins/variable-plugin/utils/constants.d.ts +9 -0
- package/plugins/{template-variable-plugin → variable-plugin}/utils/fetch-data.d.ts +5 -0
- package/services/standard-template-plugin.d.ts +9 -10
- package/translations/en-US.yaml +4 -3
- package/translations/nl-BE.yaml +8 -7
- package/utils/changed-descendants.d.ts +2 -0
- package/utils/constants.d.ts +10 -0
- package/utils/namespace.d.ts +11 -0
- package/addon/components/table-of-contents-plugin/card.hbs +0 -16
- package/addon/components/template-variable-plugin/template-variable-card.ts +0 -227
- package/addon/plugins/article-structure-plugin/constants.ts +0 -11
- package/addon/plugins/article-structure-plugin/utils/namespace.ts +0 -25
- package/addon/plugins/insert-variable-plugin/utils/constants.ts +0 -67
- package/addon/plugins/insert-variable-plugin/utils/fetch-data.ts +0 -41
- package/addon/plugins/rdfa-date-plugin/commands/index.ts +0 -1
- package/addon/plugins/rdfa-date-plugin/commands/modify-date.ts +0 -48
- package/addon/plugins/table-of-contents-plugin/utils/constants.ts +0 -17
- package/addon/plugins/template-variable-plugin/index.ts +0 -6
- package/addon/plugins/template-variable-plugin/utils/constants.ts +0 -2
- package/plugins/article-structure-plugin/constants.d.ts +0 -5
- package/plugins/article-structure-plugin/utils/namespace.d.ts +0 -6
- package/plugins/insert-variable-plugin/utils/constants.d.ts +0 -7
- package/plugins/insert-variable-plugin/utils/fetch-data.d.ts +0 -5
- package/plugins/rdfa-date-plugin/commands/index.d.ts +0 -1
- package/plugins/rdfa-date-plugin/commands/modify-date.d.ts +0 -2
- package/plugins/table-of-contents-plugin/utils/constants.d.ts +0 -7
- package/plugins/template-variable-plugin/index.d.ts +0 -2
- package/plugins/template-variable-plugin/utils/constants.d.ts +0 -1
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
import { tracked } from '@glimmer/tracking';
|
|
3
|
-
import { action } from '@ember/object';
|
|
4
|
-
import { getOwner } from '@ember/application';
|
|
5
|
-
import { task } from 'ember-concurrency';
|
|
6
|
-
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
7
|
-
import { ProseStore } from '@lblod/ember-rdfa-editor/utils/datastore/prose-store';
|
|
8
|
-
import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
|
|
9
|
-
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
10
|
-
import { getAppliedMarks } from '@lblod/ember-rdfa-editor/plugins/datastore';
|
|
11
|
-
import {
|
|
12
|
-
CodeListOption,
|
|
13
|
-
fetchCodeListOptions,
|
|
14
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/template-variable-plugin/utils/fetch-data';
|
|
15
|
-
import { ZONAL_URI } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/utils/constants';
|
|
16
|
-
import { MULTI_SELECT_CODELIST_TYPE } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/template-variable-plugin/utils/constants';
|
|
17
|
-
|
|
18
|
-
type Args = {
|
|
19
|
-
controller: ProseController;
|
|
20
|
-
};
|
|
21
|
-
export default class EditorPluginsTemplateVariableCardComponent extends Component<Args> {
|
|
22
|
-
@tracked variableOptions: CodeListOption[] = [];
|
|
23
|
-
@tracked selectedVariable?: CodeListOption | CodeListOption[];
|
|
24
|
-
@tracked showCard = false;
|
|
25
|
-
@tracked multiSelect = false;
|
|
26
|
-
mappingUri?: string;
|
|
27
|
-
zonalLocationCodelistUri: string;
|
|
28
|
-
endpoint: string;
|
|
29
|
-
nonZonalLocationCodelistUri: string;
|
|
30
|
-
|
|
31
|
-
constructor(parent: unknown, args: Args) {
|
|
32
|
-
super(parent, args);
|
|
33
|
-
const config = getOwner(this)?.resolveRegistration(
|
|
34
|
-
'config:environment'
|
|
35
|
-
) as {
|
|
36
|
-
templateVariablePlugin: {
|
|
37
|
-
zonalLocationCodelistUri: string;
|
|
38
|
-
endpoint: string;
|
|
39
|
-
nonZonalLocationCodelistUri: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
const pluginConfig = config.templateVariablePlugin;
|
|
43
|
-
this.zonalLocationCodelistUri = pluginConfig.zonalLocationCodelistUri;
|
|
44
|
-
this.endpoint = pluginConfig.endpoint;
|
|
45
|
-
this.nonZonalLocationCodelistUri = pluginConfig.nonZonalLocationCodelistUri;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get controller() {
|
|
49
|
-
return this.args.controller;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@action
|
|
53
|
-
insert() {
|
|
54
|
-
const { selection } = this.controller.state;
|
|
55
|
-
if (!this.mappingUri || !this.selectedVariable) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
this.controller.datastore;
|
|
59
|
-
const limitedDatastore = this.controller.datastore.limitToRange(
|
|
60
|
-
this.controller.state,
|
|
61
|
-
selection.from,
|
|
62
|
-
selection.to
|
|
63
|
-
);
|
|
64
|
-
const insertRange = [
|
|
65
|
-
...limitedDatastore
|
|
66
|
-
.match(`>${this.mappingUri}`, 'ext:content')
|
|
67
|
-
.asObjectNodeMapping()
|
|
68
|
-
.nodes(),
|
|
69
|
-
][0];
|
|
70
|
-
if (!insertRange) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const marks = getAppliedMarks(insertRange);
|
|
74
|
-
let htmlToInsert: string;
|
|
75
|
-
if (Array.isArray(this.selectedVariable)) {
|
|
76
|
-
htmlToInsert = this.selectedVariable
|
|
77
|
-
.map((variable) => variable.value)
|
|
78
|
-
.join(', ');
|
|
79
|
-
} else {
|
|
80
|
-
htmlToInsert = unwrap(this.selectedVariable.value);
|
|
81
|
-
}
|
|
82
|
-
htmlToInsert = this.wrapVariableInHighlight(htmlToInsert);
|
|
83
|
-
if (insertRange) {
|
|
84
|
-
this.controller.doCommand(
|
|
85
|
-
insertHtml(htmlToInsert, insertRange.from, insertRange.to, marks)
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
wrapVariableInHighlight(text: string) {
|
|
91
|
-
return text.replace(
|
|
92
|
-
/\$\{(.+?)\}/g,
|
|
93
|
-
'<span class="mark-highlight-manual">${$1}</span>'
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
@action
|
|
98
|
-
selectionChanged() {
|
|
99
|
-
this.showCard = false;
|
|
100
|
-
this.selectedVariable = undefined;
|
|
101
|
-
const { selection } = this.controller.state;
|
|
102
|
-
const { from, to } = selection;
|
|
103
|
-
const fullDatastore = this.controller.datastore;
|
|
104
|
-
const limitedDatastore = this.controller.datastore.limitToRange(
|
|
105
|
-
this.controller.state,
|
|
106
|
-
from,
|
|
107
|
-
to
|
|
108
|
-
);
|
|
109
|
-
const mapping = limitedDatastore
|
|
110
|
-
.match(null, 'a', 'ext:Mapping')
|
|
111
|
-
.asQuadResultSet()
|
|
112
|
-
.single();
|
|
113
|
-
if (mapping) {
|
|
114
|
-
const mappingUri = mapping.subject.value;
|
|
115
|
-
this.mappingUri = mappingUri;
|
|
116
|
-
const mappingTypeTriple = fullDatastore
|
|
117
|
-
.match(`>${mappingUri}`, 'dct:type')
|
|
118
|
-
.asQuadResultSet()
|
|
119
|
-
.single();
|
|
120
|
-
if (mappingTypeTriple) {
|
|
121
|
-
const mappingType = mappingTypeTriple.object.value;
|
|
122
|
-
if (mappingType === 'codelist') {
|
|
123
|
-
const codelistTriple = fullDatastore
|
|
124
|
-
.match(`>${mappingUri}`, 'ext:codelist')
|
|
125
|
-
.asQuadResultSet()
|
|
126
|
-
.single();
|
|
127
|
-
if (codelistTriple) {
|
|
128
|
-
const codelistSource = this.getCodelistSource(
|
|
129
|
-
fullDatastore,
|
|
130
|
-
mappingUri
|
|
131
|
-
);
|
|
132
|
-
this.showCard = true;
|
|
133
|
-
const codelistUri = codelistTriple.object.value;
|
|
134
|
-
void this.fetchCodeListOptions.perform(codelistSource, codelistUri);
|
|
135
|
-
}
|
|
136
|
-
} else if (mappingType === 'location') {
|
|
137
|
-
const codelistSource = this.getCodelistSource(
|
|
138
|
-
fullDatastore,
|
|
139
|
-
mappingUri
|
|
140
|
-
);
|
|
141
|
-
const measureTriple = limitedDatastore
|
|
142
|
-
.match(
|
|
143
|
-
null,
|
|
144
|
-
'a',
|
|
145
|
-
'>https://data.vlaanderen.be/ns/mobiliteit#Mobiliteitsmaatregel'
|
|
146
|
-
)
|
|
147
|
-
.asQuadResultSet()
|
|
148
|
-
.single();
|
|
149
|
-
if (!measureTriple) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
const measureUri = measureTriple.subject.value;
|
|
153
|
-
const zonalityTriple = fullDatastore
|
|
154
|
-
.match(`>${measureUri}`, 'ext:zonality')
|
|
155
|
-
.asQuadResultSet()
|
|
156
|
-
.single();
|
|
157
|
-
if (!zonalityTriple) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const zonalityUri = zonalityTriple.object.value;
|
|
161
|
-
if (zonalityUri === ZONAL_URI) {
|
|
162
|
-
void this.fetchCodeListOptions.perform(
|
|
163
|
-
codelistSource,
|
|
164
|
-
this.zonalLocationCodelistUri,
|
|
165
|
-
true
|
|
166
|
-
);
|
|
167
|
-
} else {
|
|
168
|
-
void this.fetchCodeListOptions.perform(
|
|
169
|
-
codelistSource,
|
|
170
|
-
this.nonZonalLocationCodelistUri,
|
|
171
|
-
true
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
this.showCard = true;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
getCodelistSource(fullDatastore: ProseStore, mappingUri: string): string {
|
|
181
|
-
const codelistSourceTriple = fullDatastore
|
|
182
|
-
.match(`>${mappingUri}`, 'dct:source')
|
|
183
|
-
.asQuadResultSet()
|
|
184
|
-
.single();
|
|
185
|
-
|
|
186
|
-
if (codelistSourceTriple) {
|
|
187
|
-
return codelistSourceTriple.object.value;
|
|
188
|
-
} else {
|
|
189
|
-
return this.endpoint;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
@action
|
|
194
|
-
updateVariable(variable: CodeListOption | CodeListOption[]) {
|
|
195
|
-
this.selectedVariable = variable;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
fetchCodeListOptions = task(
|
|
199
|
-
async (endpoint: string, codelistUri: string, isLocation?: boolean) => {
|
|
200
|
-
const { type, options } = await fetchCodeListOptions(
|
|
201
|
-
endpoint,
|
|
202
|
-
codelistUri
|
|
203
|
-
);
|
|
204
|
-
if (isLocation) {
|
|
205
|
-
this.variableOptions = options.map((option) => ({
|
|
206
|
-
label: option.label,
|
|
207
|
-
value: this.wrapInLocation(unwrap(option.value)),
|
|
208
|
-
}));
|
|
209
|
-
} else {
|
|
210
|
-
this.variableOptions = options;
|
|
211
|
-
}
|
|
212
|
-
if (type === MULTI_SELECT_CODELIST_TYPE) {
|
|
213
|
-
this.multiSelect = true;
|
|
214
|
-
} else {
|
|
215
|
-
this.multiSelect = false;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
wrapInLocation(value: string) {
|
|
221
|
-
return `
|
|
222
|
-
<span property="https://data.vlaanderen.be/ns/mobiliteit#plaatsbepaling">
|
|
223
|
-
${value}
|
|
224
|
-
</span>
|
|
225
|
-
`;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { namespace } from './utils/namespace';
|
|
2
|
-
|
|
3
|
-
export const SAY = namespace('https://say.data.gift/ns/', 'say');
|
|
4
|
-
export const RDF = namespace(
|
|
5
|
-
'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
|
6
|
-
'rdf'
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
export const ELI = namespace('http://data.europa.eu/eli/ontology#', 'eli');
|
|
10
|
-
export const XSD = namespace('http://www.w3.org/2001/XMLSchema#', 'xsd');
|
|
11
|
-
export const EXT = namespace('http://mu.semte.ch/vocabularies/ext/', 'ext');
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export type Resource = {
|
|
2
|
-
prefixed: string;
|
|
3
|
-
full: string;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export function namespace(uri: string, prefix: string) {
|
|
7
|
-
return (s: string): Resource => {
|
|
8
|
-
return {
|
|
9
|
-
prefixed: prefix && `${prefix}:${s}`,
|
|
10
|
-
full: uri + s,
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function hasRDFaAttribute(
|
|
16
|
-
element: Element,
|
|
17
|
-
attr: string,
|
|
18
|
-
value: Resource
|
|
19
|
-
) {
|
|
20
|
-
const result = element.getAttribute(attr)?.split(' ');
|
|
21
|
-
if (result) {
|
|
22
|
-
return result.includes(value.full) || result.includes(value.prefixed);
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { CodeList, fetchCodeListsByPublisher } from './fetch-data';
|
|
2
|
-
|
|
3
|
-
export type VariableType = {
|
|
4
|
-
label: string;
|
|
5
|
-
fetchSubtypes?: (endpoint: string, publisher: string) => Promise<CodeList[]>;
|
|
6
|
-
template:
|
|
7
|
-
| string
|
|
8
|
-
| ((endpoint: string, selectedCodelist?: CodeList) => string);
|
|
9
|
-
};
|
|
10
|
-
export const DEFAULT_VARIABLE_TYPES: Record<string, VariableType> = {
|
|
11
|
-
text: {
|
|
12
|
-
label: 'text',
|
|
13
|
-
template: `
|
|
14
|
-
<span property="dct:type" content="text"></span>
|
|
15
|
-
<span property="ext:content">
|
|
16
|
-
<span class="mark-highlight-manual">\${text}</span>
|
|
17
|
-
</span>
|
|
18
|
-
`,
|
|
19
|
-
},
|
|
20
|
-
number: {
|
|
21
|
-
label: 'number',
|
|
22
|
-
template: `
|
|
23
|
-
<span property="dct:type" content="number"></span>
|
|
24
|
-
<span property="ext:content" datatype="xsd:integer">
|
|
25
|
-
<span class="mark-highlight-manual">\${number}</span>
|
|
26
|
-
</span>
|
|
27
|
-
`,
|
|
28
|
-
},
|
|
29
|
-
date: {
|
|
30
|
-
label: 'date',
|
|
31
|
-
template: `
|
|
32
|
-
<span property="dct:type" content="date"></span>
|
|
33
|
-
<span property="ext:content" datatype="xsd:date">
|
|
34
|
-
<span class="mark-highlight-manual">\${date}</span>
|
|
35
|
-
</span>
|
|
36
|
-
`,
|
|
37
|
-
},
|
|
38
|
-
location: {
|
|
39
|
-
label: 'location',
|
|
40
|
-
template: (endpoint: string) => `
|
|
41
|
-
<span property="dct:type" content="location"></span>
|
|
42
|
-
<span property="dct:source" resource="${endpoint}"></span>
|
|
43
|
-
<span property="ext:content">
|
|
44
|
-
<span class="mark-highlight-manual">\${location}</span>
|
|
45
|
-
</span>
|
|
46
|
-
`,
|
|
47
|
-
},
|
|
48
|
-
codelist: {
|
|
49
|
-
label: 'codelist',
|
|
50
|
-
fetchSubtypes: async (endpoint: string, publisher: string) => {
|
|
51
|
-
const codelists = fetchCodeListsByPublisher(endpoint, publisher);
|
|
52
|
-
return codelists;
|
|
53
|
-
},
|
|
54
|
-
template: (endpoint: string, selectedCodelist?: CodeList) => `
|
|
55
|
-
<span property="ext:codelist" resource="${
|
|
56
|
-
selectedCodelist?.uri ?? ''
|
|
57
|
-
}"></span>
|
|
58
|
-
<span property="dct:type" content="codelist"></span>
|
|
59
|
-
<span property="dct:source" resource="${endpoint}"></span>
|
|
60
|
-
<span property="ext:content">
|
|
61
|
-
<span class="mark-highlight-manual">\${${
|
|
62
|
-
selectedCodelist?.label ?? ''
|
|
63
|
-
}}</span>
|
|
64
|
-
</span>
|
|
65
|
-
`,
|
|
66
|
-
},
|
|
67
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { executeQuery } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/sparql-helpers';
|
|
2
|
-
export type CodeList = {
|
|
3
|
-
uri?: string;
|
|
4
|
-
label?: string;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
function generateCodeListsByPublisherQuery(publisher: string): string {
|
|
8
|
-
const codeListOptionsQuery = `
|
|
9
|
-
PREFIX lblodMobilitiet: <http://data.lblod.info/vocabularies/mobiliteit/>
|
|
10
|
-
PREFIX dct: <http://purl.org/dc/terms/>
|
|
11
|
-
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
|
12
|
-
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
|
|
13
|
-
SELECT DISTINCT * WHERE {
|
|
14
|
-
?uri a lblodMobilitiet:Codelist;
|
|
15
|
-
skos:prefLabel ?label.
|
|
16
|
-
${
|
|
17
|
-
publisher
|
|
18
|
-
? `
|
|
19
|
-
?uri dct:publisher <${publisher}>.
|
|
20
|
-
`
|
|
21
|
-
: ''
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
return codeListOptionsQuery;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export async function fetchCodeListsByPublisher(
|
|
29
|
-
endpoint: string,
|
|
30
|
-
publisher: string
|
|
31
|
-
): Promise<CodeList[]> {
|
|
32
|
-
const codelistsOptionsQueryResult = await executeQuery(
|
|
33
|
-
endpoint,
|
|
34
|
-
generateCodeListsByPublisherQuery(publisher)
|
|
35
|
-
);
|
|
36
|
-
const bindings = codelistsOptionsQueryResult.results.bindings;
|
|
37
|
-
return bindings.map((binding) => ({
|
|
38
|
-
uri: binding['uri']?.value,
|
|
39
|
-
label: binding['label']?.value,
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as modifyDate } from './modify-date';
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Command, Mark } from '@lblod/ember-rdfa-editor';
|
|
2
|
-
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
3
|
-
|
|
4
|
-
function formatDate(date: Date, onlyDate: boolean) {
|
|
5
|
-
const options: Intl.DateTimeFormatOptions = {
|
|
6
|
-
year: 'numeric',
|
|
7
|
-
month: '2-digit',
|
|
8
|
-
day: '2-digit',
|
|
9
|
-
...(!onlyDate && {
|
|
10
|
-
hour: '2-digit',
|
|
11
|
-
minute: '2-digit',
|
|
12
|
-
}),
|
|
13
|
-
};
|
|
14
|
-
return date.toLocaleString('nl-BE', options);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default function modifyDate(
|
|
18
|
-
from: number,
|
|
19
|
-
to: number,
|
|
20
|
-
dateValue: Date,
|
|
21
|
-
onlyDate: boolean
|
|
22
|
-
): Command {
|
|
23
|
-
return function (state, dispatch) {
|
|
24
|
-
if (dispatch) {
|
|
25
|
-
const transaction = state.tr;
|
|
26
|
-
const node = unwrap(transaction.doc.nodeAt(from));
|
|
27
|
-
const currentRdfaMark = node.marks
|
|
28
|
-
.filter((mark) => mark.type.name === 'inline_rdfa')
|
|
29
|
-
.at(-1);
|
|
30
|
-
if (currentRdfaMark) {
|
|
31
|
-
transaction.removeMark(from, to, currentRdfaMark);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const newMark: Mark = currentRdfaMark
|
|
35
|
-
? state.schema.mark('inline_rdfa', {
|
|
36
|
-
...currentRdfaMark.attrs,
|
|
37
|
-
content: dateValue.toISOString(),
|
|
38
|
-
})
|
|
39
|
-
: state.schema.mark('inline_rdfa', {
|
|
40
|
-
content: dateValue.toISOString(),
|
|
41
|
-
});
|
|
42
|
-
transaction.addMark(from, to, newMark);
|
|
43
|
-
transaction.insertText(formatDate(dateValue, onlyDate), from, to);
|
|
44
|
-
dispatch(transaction);
|
|
45
|
-
}
|
|
46
|
-
return true;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type TableOfContentsConfig = {
|
|
2
|
-
sectionPredicate: string[];
|
|
3
|
-
value:
|
|
4
|
-
| string
|
|
5
|
-
| {
|
|
6
|
-
predicate: string;
|
|
7
|
-
};
|
|
8
|
-
}[];
|
|
9
|
-
|
|
10
|
-
export const TABLE_OF_CONTENTS_DEFAULT_CONFIG: TableOfContentsConfig = [
|
|
11
|
-
{
|
|
12
|
-
sectionPredicate: ['https://say.data.gift/ns/hasPart', 'say:hasPart'],
|
|
13
|
-
value: {
|
|
14
|
-
predicate: 'https://say.data.gift/ns/heading',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const SAY: (s: string) => import("./utils/namespace").Resource;
|
|
2
|
-
export declare const RDF: (s: string) => import("./utils/namespace").Resource;
|
|
3
|
-
export declare const ELI: (s: string) => import("./utils/namespace").Resource;
|
|
4
|
-
export declare const XSD: (s: string) => import("./utils/namespace").Resource;
|
|
5
|
-
export declare const EXT: (s: string) => import("./utils/namespace").Resource;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CodeList } from './fetch-data';
|
|
2
|
-
export type VariableType = {
|
|
3
|
-
label: string;
|
|
4
|
-
fetchSubtypes?: (endpoint: string, publisher: string) => Promise<CodeList[]>;
|
|
5
|
-
template: string | ((endpoint: string, selectedCodelist?: CodeList) => string);
|
|
6
|
-
};
|
|
7
|
-
export declare const DEFAULT_VARIABLE_TYPES: Record<string, VariableType>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as modifyDate } from './modify-date';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const MULTI_SELECT_CODELIST_TYPE = "http://lblod.data.gift/concepts/57C93E12-A02C-4D4B-8B95-666B6701286C";
|