@lblod/ember-rdfa-editor-lblod-plugins 26.1.0 → 26.2.0-dev.16cddd6d5fcdc7aa598379fc90d0de0daf82c3f8
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 +14 -0
- package/addon/components/location-plugin/insert.gts +45 -57
- package/addon/components/variable-plugin/address/insert-variable.ts +4 -0
- package/addon/plugins/location-plugin/node-contents/address.ts +33 -26
- package/addon/plugins/location-plugin/node-contents/area.ts +1 -8
- package/addon/plugins/location-plugin/node-contents/place.ts +1 -8
- package/addon/plugins/location-plugin/node.ts +56 -8
- package/addon/plugins/location-plugin/utils/address-helpers.ts +5 -1
- package/addon/plugins/location-plugin/utils/node-utils.ts +57 -31
- package/addon/plugins/variable-plugin/variables/address.ts +8 -0
- package/declarations/addon/components/variable-plugin/address/insert-variable.d.ts +4 -0
- package/declarations/addon/plugins/location-plugin/node-contents/area.d.ts +1 -1
- package/declarations/addon/plugins/location-plugin/node-contents/index.d.ts +2 -2
- package/declarations/addon/plugins/location-plugin/node-contents/place.d.ts +1 -1
- package/declarations/addon/plugins/location-plugin/node.d.ts +2 -0
- package/declarations/addon/plugins/location-plugin/utils/address-helpers.d.ts +2 -1
- package/declarations/addon/plugins/location-plugin/utils/node-utils.d.ts +16 -1
- package/declarations/addon/plugins/variable-plugin/variables/address.d.ts +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 26.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#517](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/517) [`88cb173`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/88cb173d67ddc613ace5cc8c4c595d26e7497306) Thanks [@piemonkey](https://github.com/piemonkey)! - Add configuration option to location plugin to automatically link to resources in the wider document
|
|
8
|
+
|
|
9
|
+
- [#517](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/517) [`42b04a7`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/42b04a7414e40adf20dff16d76bdf1edff8ea5ff) Thanks [@piemonkey](https://github.com/piemonkey)! - Use prov:atLocation predicate for locations instead of dct:spatial
|
|
10
|
+
|
|
11
|
+
- [#517](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/517) [`eaf74bc`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/eaf74bc9e20a9e5922f7fa76e486d3aba3dc2881) Thanks [@piemonkey](https://github.com/piemonkey)! - Remove vestigual 'mapping' RDFa from oslo location nodes as they are no longer 'variables' so no longer need it
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#519](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/519) [`b864e08`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/b864e08ff36349331169fb3ec0c45a754ee8038d) Thanks [@piemonkey](https://github.com/piemonkey)! - Fix oslo location addresses to have correct RDFa by generating a URI instead of misusing the vlaanderen address uri
|
|
16
|
+
|
|
3
17
|
## 26.1.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
Point,
|
|
25
25
|
Polygon,
|
|
26
26
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
|
|
27
|
-
import {
|
|
27
|
+
import { replaceSelectionWithLocation } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/node-utils';
|
|
28
28
|
import { type LocationPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/node';
|
|
29
29
|
import { NodeContentsUtils } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/node-contents';
|
|
30
30
|
import Edit from './edit';
|
|
@@ -153,13 +153,11 @@ export default class LocationPluginInsertComponent extends Component<Signature>
|
|
|
153
153
|
get disableConfirm() {
|
|
154
154
|
switch (this.locationType) {
|
|
155
155
|
case 'place':
|
|
156
|
-
return
|
|
157
|
-
!this.selectedLocationNode || !this.placeName || !this.chosenPoint
|
|
158
|
-
);
|
|
156
|
+
return !this.placeName || !this.chosenPoint;
|
|
159
157
|
case 'address':
|
|
160
|
-
return !this.
|
|
158
|
+
return !this.addressToInsert;
|
|
161
159
|
default:
|
|
162
|
-
return !this.
|
|
160
|
+
return !this.placeName || !this.savedArea;
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
|
|
@@ -189,15 +187,6 @@ export default class LocationPluginInsertComponent extends Component<Signature>
|
|
|
189
187
|
|
|
190
188
|
@action
|
|
191
189
|
insertOrEditAddress() {
|
|
192
|
-
if (!this.selectedLocationNode) {
|
|
193
|
-
replaceSelectionWithAddress(
|
|
194
|
-
this.controller,
|
|
195
|
-
this.intl.t('location-plugin.default-label', {
|
|
196
|
-
locale: this.documentLanguage,
|
|
197
|
-
}),
|
|
198
|
-
this.args.templateMode,
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
190
|
this.modalOpen = true;
|
|
202
191
|
}
|
|
203
192
|
|
|
@@ -221,48 +210,47 @@ export default class LocationPluginInsertComponent extends Component<Signature>
|
|
|
221
210
|
|
|
222
211
|
@action
|
|
223
212
|
confirmLocation() {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
location:
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
213
|
+
let toInsert: Address | Place | Area | undefined;
|
|
214
|
+
if (this.locationType === 'address' && this.addressToInsert) {
|
|
215
|
+
toInsert = this.addressToInsert;
|
|
216
|
+
} else if (
|
|
217
|
+
this.locationType === 'place' &&
|
|
218
|
+
this.chosenPoint?.global &&
|
|
219
|
+
this.placeName
|
|
220
|
+
) {
|
|
221
|
+
toInsert = new Place({
|
|
222
|
+
uri: this.nodeContentsUtils.fallbackPlaceUri(),
|
|
223
|
+
name: this.placeName,
|
|
224
|
+
location: new Point({
|
|
225
|
+
uri: this.nodeContentsUtils.fallbackGeometryUri(),
|
|
226
|
+
location: {
|
|
227
|
+
lambert: convertWGS84CoordsToLambert(this.chosenPoint.global),
|
|
228
|
+
global: this.chosenPoint?.global,
|
|
229
|
+
},
|
|
230
|
+
}),
|
|
231
|
+
});
|
|
232
|
+
this.chosenPoint = undefined;
|
|
233
|
+
} else if (
|
|
234
|
+
this.locationType === 'area' &&
|
|
235
|
+
this.savedArea &&
|
|
236
|
+
this.placeName
|
|
237
|
+
) {
|
|
238
|
+
toInsert = new Area({
|
|
239
|
+
uri: this.nodeContentsUtils.fallbackPlaceUri(),
|
|
240
|
+
name: this.placeName,
|
|
241
|
+
shape: new Polygon({
|
|
242
|
+
uri: this.nodeContentsUtils.fallbackGeometryUri(),
|
|
243
|
+
locations: this.savedArea,
|
|
244
|
+
}),
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
if (toInsert) {
|
|
248
|
+
replaceSelectionWithLocation(
|
|
249
|
+
this.controller,
|
|
250
|
+
toInsert,
|
|
251
|
+
this.args.config.subjectTypesToLinkTo,
|
|
252
|
+
);
|
|
253
|
+
this.modalOpen = false;
|
|
266
254
|
}
|
|
267
255
|
}
|
|
268
256
|
|
|
@@ -11,6 +11,10 @@ type Args = {
|
|
|
11
11
|
templateMode?: boolean;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use oslo_location node instead which inserts valid OSLO model RDFa and supports
|
|
16
|
+
* linking to the document it is in.
|
|
17
|
+
*/
|
|
14
18
|
export default class VariablePluginAddressInsertVariableComponent extends Component<Args> {
|
|
15
19
|
@service declare intl: IntlService;
|
|
16
20
|
@tracked label?: string;
|
|
@@ -5,10 +5,7 @@ import {
|
|
|
5
5
|
LOCN,
|
|
6
6
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
7
7
|
import { findChildWithRdfaAttribute } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
8
|
-
import {
|
|
9
|
-
contentSpan,
|
|
10
|
-
span,
|
|
11
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/dom-output-spec-helpers';
|
|
8
|
+
import { span } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/dom-output-spec-helpers';
|
|
12
9
|
import { Address } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/address-helpers';
|
|
13
10
|
import { Point } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
|
|
14
11
|
import { constructGeometrySpec } from './point';
|
|
@@ -33,30 +30,24 @@ export const constructAddressSpec = (address: Address) => {
|
|
|
33
30
|
),
|
|
34
31
|
]
|
|
35
32
|
: [];
|
|
36
|
-
const
|
|
33
|
+
const belgianUriNode = address.belgianAddressUri
|
|
37
34
|
? [
|
|
38
35
|
span({
|
|
39
36
|
property: ADRES('verwijstNaar').full,
|
|
40
|
-
|
|
37
|
+
resource: address.belgianAddressUri,
|
|
41
38
|
}),
|
|
42
39
|
]
|
|
43
40
|
: [];
|
|
44
|
-
|
|
45
|
-
return contentSpan(
|
|
41
|
+
return span(
|
|
46
42
|
{ resource: address.uri, typeof: LOCN('Address').full },
|
|
47
43
|
span(
|
|
48
44
|
{
|
|
49
|
-
property:
|
|
45
|
+
property: LOCN('thoroughfare').full,
|
|
50
46
|
},
|
|
51
|
-
|
|
52
|
-
{
|
|
53
|
-
property: LOCN('thoroughfare').full,
|
|
54
|
-
},
|
|
55
|
-
address.street,
|
|
56
|
-
),
|
|
57
|
-
...housenumberNode,
|
|
58
|
-
...busnumberNode,
|
|
47
|
+
address.street,
|
|
59
48
|
),
|
|
49
|
+
...housenumberNode,
|
|
50
|
+
...busnumberNode,
|
|
60
51
|
', ',
|
|
61
52
|
span(
|
|
62
53
|
{
|
|
@@ -72,7 +63,7 @@ export const constructAddressSpec = (address: Address) => {
|
|
|
72
63
|
},
|
|
73
64
|
address.municipality,
|
|
74
65
|
),
|
|
75
|
-
...
|
|
66
|
+
...belgianUriNode,
|
|
76
67
|
constructGeometrySpec(address.location, ADRES('positie')),
|
|
77
68
|
);
|
|
78
69
|
};
|
|
@@ -81,7 +72,10 @@ export const constructAddressSpec = (address: Address) => {
|
|
|
81
72
|
export const parseOldAddressElement =
|
|
82
73
|
(nodeContentsUtils: NodeContentsUtils) =>
|
|
83
74
|
(addressNode: Element): Address | undefined => {
|
|
84
|
-
|
|
75
|
+
// Belgian address URI was incorrectly used as the resource URI, so we correct that by
|
|
76
|
+
// generating a new one
|
|
77
|
+
const uri = nodeContentsUtils.fallbackAddressUri();
|
|
78
|
+
const belgianAddressUri = addressNode.getAttribute('resource') ?? undefined;
|
|
85
79
|
const street = findChildWithRdfaAttribute(
|
|
86
80
|
addressNode,
|
|
87
81
|
'property',
|
|
@@ -124,7 +118,8 @@ export const parseOldAddressElement =
|
|
|
124
118
|
|
|
125
119
|
if (street && municipality && zipcode && location) {
|
|
126
120
|
return new Address({
|
|
127
|
-
uri
|
|
121
|
+
uri,
|
|
122
|
+
belgianAddressUri,
|
|
128
123
|
street,
|
|
129
124
|
housenumber: housenumber ?? undefined,
|
|
130
125
|
zipcode,
|
|
@@ -142,16 +137,27 @@ export const parseAddressElement =
|
|
|
142
137
|
(addressNode: Element | undefined): Address | undefined => {
|
|
143
138
|
if (!addressNode) return undefined;
|
|
144
139
|
|
|
145
|
-
|
|
140
|
+
let uri = addressNode.getAttribute('resource');
|
|
141
|
+
const belgianAddressNode = findChildWithRdfaAttribute(
|
|
146
142
|
addressNode,
|
|
147
143
|
'property',
|
|
148
144
|
ADRES('verwijstNaar'),
|
|
149
|
-
)?.getAttribute('content');
|
|
150
|
-
const spatialNode = findChildWithRdfaAttribute(
|
|
151
|
-
addressNode,
|
|
152
|
-
'property',
|
|
153
|
-
DCT('spatial'),
|
|
154
145
|
);
|
|
146
|
+
// In the past this was stored as a string relationship, which matches the example in the model
|
|
147
|
+
// docs but not the diagram, so look for either here
|
|
148
|
+
const belgianAddressUri =
|
|
149
|
+
belgianAddressNode?.getAttribute('resource') ??
|
|
150
|
+
belgianAddressNode?.getAttribute('content') ??
|
|
151
|
+
undefined;
|
|
152
|
+
if (uri === belgianAddressUri) {
|
|
153
|
+
// An older version of this code mistakenly used the belgian address URI as the resource URI,
|
|
154
|
+
// so if they are the same, generate a new one
|
|
155
|
+
uri = nodeContentsUtils.fallbackAddressUri();
|
|
156
|
+
}
|
|
157
|
+
// This node is no longer added, but we keep this lookup for compatibility
|
|
158
|
+
const spatialNode =
|
|
159
|
+
findChildWithRdfaAttribute(addressNode, 'property', DCT('spatial')) ||
|
|
160
|
+
addressNode;
|
|
155
161
|
const street =
|
|
156
162
|
spatialNode &&
|
|
157
163
|
findChildWithRdfaAttribute(spatialNode, 'property', LOCN('thoroughfare'))
|
|
@@ -191,6 +197,7 @@ export const parseAddressElement =
|
|
|
191
197
|
if (street && municipality && zipcode && location instanceof Point) {
|
|
192
198
|
return new Address({
|
|
193
199
|
uri: uri ?? nodeContentsUtils.fallbackAddressUri(),
|
|
200
|
+
belgianAddressUri,
|
|
194
201
|
street,
|
|
195
202
|
housenumber: housenumber ?? undefined,
|
|
196
203
|
zipcode,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
DCT,
|
|
3
2
|
LOCN,
|
|
4
3
|
RDFS,
|
|
5
4
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
@@ -17,7 +16,6 @@ export const constructAreaSpec = (area: Area) => {
|
|
|
17
16
|
{
|
|
18
17
|
resource: area.uri,
|
|
19
18
|
typeof: LOCN('Location').full,
|
|
20
|
-
property: DCT('spatial').full,
|
|
21
19
|
},
|
|
22
20
|
span(
|
|
23
21
|
{
|
|
@@ -31,12 +29,7 @@ export const constructAreaSpec = (area: Area) => {
|
|
|
31
29
|
|
|
32
30
|
export const parseAreaElement =
|
|
33
31
|
(nodeContentsUtils: NodeContentsUtils) =>
|
|
34
|
-
(
|
|
35
|
-
const placeNode = findChildWithRdfaAttribute(
|
|
36
|
-
element,
|
|
37
|
-
'typeof',
|
|
38
|
-
LOCN('Location'),
|
|
39
|
-
);
|
|
32
|
+
(placeNode: Element): Area | undefined => {
|
|
40
33
|
const placeResource = placeNode?.getAttribute('resource');
|
|
41
34
|
const label =
|
|
42
35
|
placeNode &&
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
DCT,
|
|
3
2
|
LOCN,
|
|
4
3
|
RDFS,
|
|
5
4
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
@@ -17,7 +16,6 @@ export const constructPlaceSpec = (place: Place) => {
|
|
|
17
16
|
{
|
|
18
17
|
resource: place.uri,
|
|
19
18
|
typeof: LOCN('Location').full,
|
|
20
|
-
property: DCT('spatial').full,
|
|
21
19
|
},
|
|
22
20
|
span(
|
|
23
21
|
{
|
|
@@ -31,12 +29,7 @@ export const constructPlaceSpec = (place: Place) => {
|
|
|
31
29
|
|
|
32
30
|
export const parsePlaceElement =
|
|
33
31
|
(nodeContentsUtils: NodeContentsUtils) =>
|
|
34
|
-
(
|
|
35
|
-
const placeNode = findChildWithRdfaAttribute(
|
|
36
|
-
element,
|
|
37
|
-
'typeof',
|
|
38
|
-
LOCN('Location'),
|
|
39
|
-
);
|
|
32
|
+
(placeNode: Element): Place | undefined => {
|
|
40
33
|
const placeResource = placeNode?.getAttribute('resource');
|
|
41
34
|
const label =
|
|
42
35
|
placeNode &&
|
|
@@ -18,8 +18,10 @@ import {
|
|
|
18
18
|
renderRdfaAware,
|
|
19
19
|
} from '@lblod/ember-rdfa-editor/core/schema';
|
|
20
20
|
import {
|
|
21
|
+
ADRES,
|
|
21
22
|
DCT,
|
|
22
23
|
EXT,
|
|
24
|
+
LOCN,
|
|
23
25
|
RDF,
|
|
24
26
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
25
27
|
import {
|
|
@@ -32,6 +34,7 @@ import {
|
|
|
32
34
|
import {
|
|
33
35
|
hasOutgoingNamedNodeTriple,
|
|
34
36
|
hasRDFaAttribute,
|
|
37
|
+
Resource,
|
|
35
38
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
36
39
|
import { contentSpan } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/dom-output-spec-helpers';
|
|
37
40
|
import AddressNodeviewComponent from '@lblod/ember-rdfa-editor-lblod-plugins/components/location-plugin/nodeview';
|
|
@@ -41,6 +44,7 @@ import {
|
|
|
41
44
|
Area,
|
|
42
45
|
Place,
|
|
43
46
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
|
|
47
|
+
import { findChildWithRdfaAttribute } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
44
48
|
import { NodeContentsUtils } from './node-contents';
|
|
45
49
|
import { recreateVariableUris } from '../variable-plugin/utils/recreate-variable-uris';
|
|
46
50
|
|
|
@@ -48,11 +52,49 @@ export interface LocationPluginConfig {
|
|
|
48
52
|
defaultAddressUriRoot: string;
|
|
49
53
|
defaultPlaceUriRoot: string;
|
|
50
54
|
defaultPointUriRoot: string;
|
|
55
|
+
subjectTypesToLinkTo?: Resource[];
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
const parseDOM = (config: LocationPluginConfig): TagParseRule[] => {
|
|
54
59
|
const nodeContentsUtils = new NodeContentsUtils(config);
|
|
55
60
|
return [
|
|
61
|
+
{
|
|
62
|
+
tag: 'span',
|
|
63
|
+
getAttrs(node: HTMLElement) {
|
|
64
|
+
const attrs = getRdfaAttrs(node, { rdfaAware: true });
|
|
65
|
+
if (!attrs) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const contentContainer = node.querySelector(
|
|
69
|
+
'[data-content-container="true"]',
|
|
70
|
+
);
|
|
71
|
+
if (attrs.rdfaNodeType !== 'resource') {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (contentContainer) {
|
|
75
|
+
const location =
|
|
76
|
+
nodeContentsUtils.address.parse(contentContainer.children[0]) ||
|
|
77
|
+
nodeContentsUtils.place.parse(contentContainer.children[0]) ||
|
|
78
|
+
nodeContentsUtils.area.parse(contentContainer.children[0]);
|
|
79
|
+
if (location) {
|
|
80
|
+
// In the past this was stored as a string relationship, which matches the example in the model
|
|
81
|
+
// docs but not the diagram, so correct it to a URI here
|
|
82
|
+
const properties = attrs.properties?.filter(
|
|
83
|
+
(prop) =>
|
|
84
|
+
!ADRES('verwijstNaar').matches(prop.predicate) ||
|
|
85
|
+
prop.object.termType === 'NamedNode',
|
|
86
|
+
);
|
|
87
|
+
return {
|
|
88
|
+
...attrs,
|
|
89
|
+
properties,
|
|
90
|
+
value: location,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
// Match 'variable style' node, with additional 'mapping' wrapper
|
|
56
98
|
{
|
|
57
99
|
tag: 'span',
|
|
58
100
|
getAttrs(node: HTMLElement) {
|
|
@@ -80,10 +122,20 @@ const parseDOM = (config: LocationPluginConfig): TagParseRule[] => {
|
|
|
80
122
|
const addressNode = [...dataContainer.children].find((el) =>
|
|
81
123
|
hasRDFaAttribute(el, 'property', EXT('content')),
|
|
82
124
|
);
|
|
83
|
-
|
|
84
|
-
nodeContentsUtils.address.parse(addressNode)
|
|
85
|
-
|
|
86
|
-
|
|
125
|
+
let location: Place | Area | Address | undefined =
|
|
126
|
+
nodeContentsUtils.address.parse(addressNode);
|
|
127
|
+
if (addressNode && !location) {
|
|
128
|
+
const placeNode = findChildWithRdfaAttribute(
|
|
129
|
+
addressNode,
|
|
130
|
+
'typeof',
|
|
131
|
+
LOCN('Location'),
|
|
132
|
+
);
|
|
133
|
+
if (placeNode) {
|
|
134
|
+
location =
|
|
135
|
+
nodeContentsUtils.place.parse(placeNode) ||
|
|
136
|
+
nodeContentsUtils.area.parse(placeNode);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
87
139
|
return {
|
|
88
140
|
...attrs,
|
|
89
141
|
value:
|
|
@@ -161,10 +213,6 @@ const serialize =
|
|
|
161
213
|
const { value } = node.attrs;
|
|
162
214
|
let contentNode: DOMOutputSpec | undefined;
|
|
163
215
|
if (value) {
|
|
164
|
-
// TODO we should be setting the type properly rather than using the address placeholder which
|
|
165
|
-
// does not have the correct RDFa properties but that's a bigger change, so just hack around
|
|
166
|
-
// it for now
|
|
167
|
-
// const type = getOutgoingTriple(node.attrs, RDF('type'));
|
|
168
216
|
if (value instanceof Address) {
|
|
169
217
|
contentNode = nodeContentsUtils.address.construct(value);
|
|
170
218
|
} else if (value instanceof Place) {
|
|
@@ -107,6 +107,7 @@ type AddressDetailResult = {
|
|
|
107
107
|
|
|
108
108
|
export class Address {
|
|
109
109
|
declare uri: string;
|
|
110
|
+
declare belgianAddressUri?: string;
|
|
110
111
|
declare street: string;
|
|
111
112
|
declare zipcode: string;
|
|
112
113
|
declare municipality: string;
|
|
@@ -123,6 +124,7 @@ export class Address {
|
|
|
123
124
|
| 'uri'
|
|
124
125
|
| 'busnumber'
|
|
125
126
|
| 'location'
|
|
127
|
+
| 'belgianAddressUri'
|
|
126
128
|
>,
|
|
127
129
|
) {
|
|
128
130
|
Object.assign(this, args);
|
|
@@ -264,6 +266,7 @@ export async function resolveStreet(
|
|
|
264
266
|
if (streetinfo) {
|
|
265
267
|
return new Address({
|
|
266
268
|
uri: nodeContentsUtils.fallbackAddressUri(),
|
|
269
|
+
belgianAddressUri: `https://data.vlaanderen.be/id/straatnaam/${streetinfo.ID}`,
|
|
267
270
|
street: unwrap(streetinfo.Thoroughfarename),
|
|
268
271
|
municipality: streetinfo.Municipality,
|
|
269
272
|
zipcode: unwrap(streetinfo.Zipcode),
|
|
@@ -321,7 +324,8 @@ export async function resolveAddress(
|
|
|
321
324
|
busnumber: result.busnummer,
|
|
322
325
|
zipcode: result.postinfo.objectId,
|
|
323
326
|
municipality: result.gemeente.gemeentenaam.geografischeNaam.spelling,
|
|
324
|
-
uri:
|
|
327
|
+
uri: nodeContentsUtils.fallbackAddressUri(),
|
|
328
|
+
belgianAddressUri: result.identificator.id,
|
|
325
329
|
location: new Point({
|
|
326
330
|
uri: `${result.identificator.id}/1`,
|
|
327
331
|
location: {
|
|
@@ -1,47 +1,73 @@
|
|
|
1
|
-
import { SayController, NodeSelection } from '@lblod/ember-rdfa-editor';
|
|
1
|
+
import { SayController, NodeSelection, PNode } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
EXT,
|
|
4
|
+
PROV,
|
|
6
5
|
RDF,
|
|
7
6
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
8
7
|
import { v4 as uuidv4 } from 'uuid';
|
|
8
|
+
import { findAncestors } from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
9
|
+
import {
|
|
10
|
+
Resource,
|
|
11
|
+
hasOutgoingNamedNodeTriple,
|
|
12
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
13
|
+
import { Area, Place } from './geo-helpers';
|
|
14
|
+
import { Address } from './address-helpers';
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Creates an 'OSLO location' node in place of the selection, along with the RDFa to create a triple
|
|
18
|
+
* with the nearest parent of one of the passed types as the subject and the predicate
|
|
19
|
+
* prov:atLocation. This doesn't work well with the RDFa tools, but since refactoring is required to
|
|
20
|
+
* clean up the RDFa structure inherited from variables and to make it work well with 'undo', this
|
|
21
|
+
* work was put off until then.
|
|
22
|
+
* @param controller - SayController
|
|
23
|
+
* @param toInsert - The object representing the location to insert
|
|
24
|
+
* @param subjectTypes - A list of Resources, each will be looked at in turn to compare the
|
|
25
|
+
* `rdf:type` of the resource, if no parent is found matching the first, then the second will be
|
|
26
|
+
* used, etc.
|
|
27
|
+
*/
|
|
28
|
+
export function replaceSelectionWithLocation(
|
|
11
29
|
controller: SayController,
|
|
12
|
-
|
|
13
|
-
|
|
30
|
+
toInsert: Place | Address | Area,
|
|
31
|
+
subjectTypes?: Resource[],
|
|
14
32
|
) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
let resourceToLink: { pos: number; node: PNode } | undefined;
|
|
34
|
+
subjectTypes?.forEach((subjectType) => {
|
|
35
|
+
if (!resourceToLink) {
|
|
36
|
+
resourceToLink = findAncestors(
|
|
37
|
+
controller.mainEditorState.selection.$from,
|
|
38
|
+
(node) => {
|
|
39
|
+
if ('typeof' in node.attrs) {
|
|
40
|
+
return subjectType.matches(node.attrs.typeof);
|
|
41
|
+
}
|
|
42
|
+
return hasOutgoingNamedNodeTriple(
|
|
43
|
+
node.attrs,
|
|
44
|
+
RDF('type'),
|
|
45
|
+
subjectType,
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
)[0];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const backlinks = !resourceToLink
|
|
52
|
+
? []
|
|
53
|
+
: [
|
|
54
|
+
{
|
|
55
|
+
predicate: PROV('atLocation').full,
|
|
56
|
+
subject: sayDataFactory.resourceNode(
|
|
57
|
+
resourceToLink.node.attrs.subject,
|
|
58
|
+
),
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
|
|
21
62
|
controller.withTransaction((tr) => {
|
|
22
63
|
tr.replaceSelectionWith(
|
|
23
64
|
controller.schema.node('oslo_location', {
|
|
24
|
-
subject:
|
|
65
|
+
subject: toInsert.uri,
|
|
25
66
|
rdfaNodeType: 'resource',
|
|
26
67
|
__rdfaId: uuidv4(),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
object: sayDataFactory.namedNode(EXT('Mapping').full),
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
predicate: EXT('instance').full,
|
|
34
|
-
object: sayDataFactory.namedNode(variableInstance),
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
predicate: DCT('type').full,
|
|
38
|
-
object: sayDataFactory.literal('address'),
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
predicate: EXT('label').full,
|
|
42
|
-
object: sayDataFactory.literal(label || ''),
|
|
43
|
-
},
|
|
44
|
-
],
|
|
68
|
+
value: toInsert,
|
|
69
|
+
properties: [],
|
|
70
|
+
backlinks,
|
|
45
71
|
}),
|
|
46
72
|
);
|
|
47
73
|
if (tr.selection.$anchor.nodeBefore) {
|
|
@@ -402,5 +402,13 @@ const emberNodeConfig: EmberNodeConfig = {
|
|
|
402
402
|
parseDOM,
|
|
403
403
|
};
|
|
404
404
|
|
|
405
|
+
/**
|
|
406
|
+
* @deprecated Use oslo_location node instead which inserts valid OSLO model RDFa and supports
|
|
407
|
+
* linking to the document it is in.
|
|
408
|
+
*/
|
|
405
409
|
export const address = createEmberNodeSpec(emberNodeConfig);
|
|
410
|
+
/**
|
|
411
|
+
* @deprecated Use oslo_location node instead which inserts valid OSLO model RDFa and supports
|
|
412
|
+
* linking to the document it is in.
|
|
413
|
+
*/
|
|
406
414
|
export const addressView = createEmberNodeView(emberNodeConfig);
|
|
@@ -5,6 +5,10 @@ type Args = {
|
|
|
5
5
|
controller: SayController;
|
|
6
6
|
templateMode?: boolean;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use oslo_location node instead which inserts valid OSLO model RDFa and supports
|
|
10
|
+
* linking to the document it is in.
|
|
11
|
+
*/
|
|
8
12
|
export default class VariablePluginAddressInsertVariableComponent extends Component<Args> {
|
|
9
13
|
intl: IntlService;
|
|
10
14
|
label?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Area } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
|
|
2
2
|
import { type NodeContentsUtils } from './';
|
|
3
3
|
export declare const constructAreaSpec: (area: Area) => import("prosemirror-model").DOMOutputSpec;
|
|
4
|
-
export declare const parseAreaElement: (nodeContentsUtils: NodeContentsUtils) => (
|
|
4
|
+
export declare const parseAreaElement: (nodeContentsUtils: NodeContentsUtils) => (placeNode: Element) => Area | undefined;
|
|
@@ -11,11 +11,11 @@ export declare class NodeContentsUtils {
|
|
|
11
11
|
fallbackPlaceUri: () => string;
|
|
12
12
|
place: {
|
|
13
13
|
construct: (place: import("../utils/geo-helpers").Place) => import("prosemirror-model").DOMOutputSpec;
|
|
14
|
-
parse: (
|
|
14
|
+
parse: (placeNode: Element) => import("../utils/geo-helpers").Place | undefined;
|
|
15
15
|
};
|
|
16
16
|
area: {
|
|
17
17
|
construct: (area: import("../utils/geo-helpers").Area) => import("prosemirror-model").DOMOutputSpec;
|
|
18
|
-
parse: (
|
|
18
|
+
parse: (placeNode: Element) => import("../utils/geo-helpers").Area | undefined;
|
|
19
19
|
};
|
|
20
20
|
fallbackAddressUri: () => string;
|
|
21
21
|
address: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Place } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
|
|
2
2
|
import { type NodeContentsUtils } from './';
|
|
3
3
|
export declare const constructPlaceSpec: (place: Place) => import("prosemirror-model").DOMOutputSpec;
|
|
4
|
-
export declare const parsePlaceElement: (nodeContentsUtils: NodeContentsUtils) => (
|
|
4
|
+
export declare const parsePlaceElement: (nodeContentsUtils: NodeContentsUtils) => (placeNode: Element) => Place | undefined;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Resource } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
1
2
|
export interface LocationPluginConfig {
|
|
2
3
|
defaultAddressUriRoot: string;
|
|
3
4
|
defaultPlaceUriRoot: string;
|
|
4
5
|
defaultPointUriRoot: string;
|
|
6
|
+
subjectTypesToLinkTo?: Resource[];
|
|
5
7
|
}
|
|
6
8
|
export declare const osloLocation: (config: LocationPluginConfig) => import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
7
9
|
export declare const osloLocationView: (config: LocationPluginConfig) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor/utils/ember-node").SayNodeViewConstructor;
|
|
@@ -21,13 +21,14 @@ type AddressSearchResult = {
|
|
|
21
21
|
};
|
|
22
22
|
export declare class Address {
|
|
23
23
|
uri: string;
|
|
24
|
+
belgianAddressUri?: string;
|
|
24
25
|
street: string;
|
|
25
26
|
zipcode: string;
|
|
26
27
|
municipality: string;
|
|
27
28
|
housenumber?: string;
|
|
28
29
|
busnumber?: string;
|
|
29
30
|
location: Point;
|
|
30
|
-
constructor(args: Pick<Address, 'street' | 'housenumber' | 'zipcode' | 'municipality' | 'uri' | 'busnumber' | 'location'>);
|
|
31
|
+
constructor(args: Pick<Address, 'street' | 'housenumber' | 'zipcode' | 'municipality' | 'uri' | 'busnumber' | 'location' | 'belgianAddressUri'>);
|
|
31
32
|
get formatted(): string;
|
|
32
33
|
sameAs(other?: Pick<Address, 'street' | 'housenumber' | 'busnumber' | 'municipality'> | null): boolean;
|
|
33
34
|
get hasHouseNumber(): boolean;
|
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
2
|
-
|
|
2
|
+
import { Resource } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
3
|
+
import { Area, Place } from './geo-helpers';
|
|
4
|
+
import { Address } from './address-helpers';
|
|
5
|
+
/**
|
|
6
|
+
* Creates an 'OSLO location' node in place of the selection, along with the RDFa to create a triple
|
|
7
|
+
* with the nearest parent of one of the passed types as the subject and the predicate
|
|
8
|
+
* prov:atLocation. This doesn't work well with the RDFa tools, but since refactoring is required to
|
|
9
|
+
* clean up the RDFa structure inherited from variables and to make it work well with 'undo', this
|
|
10
|
+
* work was put off until then.
|
|
11
|
+
* @param controller - SayController
|
|
12
|
+
* @param toInsert - The object representing the location to insert
|
|
13
|
+
* @param subjectTypes - A list of Resources, each will be looked at in turn to compare the
|
|
14
|
+
* `rdf:type` of the resource, if no parent is found matching the first, then the second will be
|
|
15
|
+
* used, etc.
|
|
16
|
+
*/
|
|
17
|
+
export declare function replaceSelectionWithLocation(controller: SayController, toInsert: Place | Address | Area, subjectTypes?: Resource[]): void;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Use oslo_location node instead which inserts valid OSLO model RDFa and supports
|
|
3
|
+
* linking to the document it is in.
|
|
4
|
+
*/
|
|
1
5
|
export declare const address: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use oslo_location node instead which inserts valid OSLO model RDFa and supports
|
|
8
|
+
* linking to the document it is in.
|
|
9
|
+
*/
|
|
2
10
|
export declare const addressView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor/utils/ember-node").SayNodeViewConstructor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lblod/ember-rdfa-editor-lblod-plugins",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.2.0-dev.16cddd6d5fcdc7aa598379fc90d0de0daf82c3f8",
|
|
4
4
|
"description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|