@lblod/ember-rdfa-editor-lblod-plugins 22.3.0 → 22.4.0
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 +10 -0
- package/addon/components/decision-plugin/insert-article.gts +57 -7
- package/addon/plugins/location-plugin/utils/geo-helpers.ts +5 -5
- package/addon/plugins/variable-plugin/utils/address-helpers.ts +4 -4
- package/declarations/addon/components/decision-plugin/insert-article.d.ts +12 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 22.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#471](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/471) [`8132a55`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/8132a550124cf90b47c3d1c759ce43bd9f72cfab) Thanks [@elpoelma](https://github.com/elpoelma)! - Introduce opt-in option to `insert-article` component to allow for inserting decision articles everywhere in a document (not just to the article-container of a decision). Useful when e.g. creating snippets.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#470](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/470) [`fdfd8b8`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/fdfd8b80c58adc07e968d131dce7618b57b27e49) Thanks [@piemonkey](https://github.com/piemonkey)! - Correct CRS URI used in location plugin to correctly use http: instead of https:
|
|
12
|
+
|
|
3
13
|
## 22.3.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -3,36 +3,69 @@ import { on } from '@ember/modifier';
|
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import Component from '@glimmer/component';
|
|
5
5
|
import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
|
|
6
|
-
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
6
|
+
import { PNode, SayController } from '@lblod/ember-rdfa-editor';
|
|
7
7
|
import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/helpers';
|
|
8
8
|
import insertArticle from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/commands/insert-article-command';
|
|
9
9
|
import { buildArticleStructure } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/utils/build-article-structure';
|
|
10
|
-
import t from 'ember-intl/helpers/t';
|
|
11
10
|
import { not } from 'ember-truth-helpers';
|
|
11
|
+
import { service } from '@ember/service';
|
|
12
|
+
import IntlService from 'ember-intl/services/intl';
|
|
13
|
+
import { recalculateNumbers } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/structure-plugin/recalculate-structure-numbers';
|
|
14
|
+
import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
|
|
12
15
|
|
|
13
16
|
export interface InsertArticleOptions {
|
|
14
17
|
uriGenerator?: () => string;
|
|
18
|
+
insertFreely?: boolean;
|
|
15
19
|
}
|
|
16
20
|
interface Sig {
|
|
17
|
-
Args: {
|
|
21
|
+
Args: {
|
|
22
|
+
controller: SayController;
|
|
23
|
+
label: string;
|
|
24
|
+
options?: InsertArticleOptions;
|
|
25
|
+
};
|
|
18
26
|
}
|
|
19
27
|
export default class InsertArticleComponent extends Component<Sig> {
|
|
28
|
+
@service declare intl: IntlService;
|
|
29
|
+
|
|
20
30
|
get controller() {
|
|
21
31
|
return this.args.controller;
|
|
22
32
|
}
|
|
23
33
|
|
|
34
|
+
get options() {
|
|
35
|
+
return this.args.options;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get label() {
|
|
39
|
+
return this.args.label ?? this.intl.t('besluit-plugin.insert.article');
|
|
40
|
+
}
|
|
41
|
+
|
|
24
42
|
get schema() {
|
|
25
43
|
return this.controller.schema;
|
|
26
44
|
}
|
|
45
|
+
|
|
27
46
|
get decisionRange() {
|
|
28
47
|
return getCurrentBesluitRange(this.controller);
|
|
29
48
|
}
|
|
49
|
+
|
|
30
50
|
get decisionLocation() {
|
|
31
51
|
return this.decisionRange
|
|
32
52
|
? { pos: this.decisionRange.from, node: this.decisionRange.node }
|
|
33
53
|
: null;
|
|
34
54
|
}
|
|
55
|
+
|
|
35
56
|
get canInsert() {
|
|
57
|
+
if (this.options?.insertFreely) {
|
|
58
|
+
return this.canInsertFreely;
|
|
59
|
+
} else {
|
|
60
|
+
return this.canInsertInDecision;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get canInsertFreely() {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get canInsertInDecision() {
|
|
36
69
|
if (!this.decisionLocation) {
|
|
37
70
|
return false;
|
|
38
71
|
}
|
|
@@ -51,15 +84,32 @@ export default class InsertArticleComponent extends Component<Sig> {
|
|
|
51
84
|
this.schema,
|
|
52
85
|
this.args.options?.uriGenerator,
|
|
53
86
|
);
|
|
54
|
-
if (
|
|
55
|
-
|
|
87
|
+
if (this.args.options?.insertFreely) {
|
|
88
|
+
this.insertFreely(structureNode);
|
|
89
|
+
} else {
|
|
90
|
+
this.insertInDecision(structureNode);
|
|
56
91
|
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@action
|
|
95
|
+
insertFreely(node: PNode) {
|
|
96
|
+
this.controller.withTransaction((tr) => {
|
|
97
|
+
return transactionCombinator(
|
|
98
|
+
this.controller.activeEditorState,
|
|
99
|
+
tr.replaceSelectionWith(node),
|
|
100
|
+
)([recalculateNumbers]).transaction;
|
|
101
|
+
});
|
|
102
|
+
this.controller.focus();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@action
|
|
106
|
+
insertInDecision(node: PNode) {
|
|
57
107
|
if (!this.decisionLocation) {
|
|
58
108
|
return;
|
|
59
109
|
}
|
|
60
110
|
this.controller.doCommand(
|
|
61
111
|
insertArticle({
|
|
62
|
-
node
|
|
112
|
+
node,
|
|
63
113
|
decisionLocation: this.decisionLocation,
|
|
64
114
|
}),
|
|
65
115
|
);
|
|
@@ -75,7 +125,7 @@ export default class InsertArticleComponent extends Component<Sig> {
|
|
|
75
125
|
@disabled={{not this.canInsert}}
|
|
76
126
|
{{on 'click' this.doInsert}}
|
|
77
127
|
>
|
|
78
|
-
{{
|
|
128
|
+
{{this.label}}
|
|
79
129
|
</AuButton>
|
|
80
130
|
</li>
|
|
81
131
|
</template>
|
|
@@ -110,7 +110,7 @@ export type GeoPos = {
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
export function constructLambert72GMLString({ x, y }: Lambert72Coordinates) {
|
|
113
|
-
return `<gml:Point srsName="
|
|
113
|
+
return `<gml:Point srsName="http://www.opengis.net/def/crs/EPSG/0/31370" xmlns:gml="http://www.opengis.net/gml/3.2"><gml:pos>${x} ${y}</gml:pos></gml:Point>`;
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* Use a regex to parse a simple point as a GML string and return the coordinates.
|
|
@@ -122,7 +122,7 @@ export function parseLambert72GMLString(gml: string): GeoPos {
|
|
|
122
122
|
// which can be represented. Since we handle only simple points, it's much less complex to just
|
|
123
123
|
// use a simple regex.
|
|
124
124
|
const [_, crs, x, y] =
|
|
125
|
-
/<gml.Point .*srsName="https
|
|
125
|
+
/<gml.Point .*srsName="https?:\/\/www.opengis.net\/def\/crs\/([^"]+)".+<gml.pos>(\S+) ([^<]+)<\/gml:pos>/.exec(
|
|
126
126
|
gml,
|
|
127
127
|
) || [];
|
|
128
128
|
if (!crs || crs !== 'EPSG/0/31370') {
|
|
@@ -144,11 +144,11 @@ export function constructLambert72WKTString(
|
|
|
144
144
|
) {
|
|
145
145
|
if (!Array.isArray(coords)) {
|
|
146
146
|
const { x, y } = coords;
|
|
147
|
-
return `<
|
|
147
|
+
return `<http://www.opengis.net/def/crs/EPSG/0/31370> POINT(${x} ${y})`;
|
|
148
148
|
} else {
|
|
149
149
|
const points = coords.map(({ x, y }) => `${x} ${y}`).join(', ');
|
|
150
150
|
// Double brackets are not a mistake...
|
|
151
|
-
return `<
|
|
151
|
+
return `<http://www.opengis.net/def/crs/EPSG/0/31370> POLYGON((${points}))`;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -171,7 +171,7 @@ export function parseLambert72WKTString(gml: string): GeoPos | GeoPos[] {
|
|
|
171
171
|
// cases, it's much less complex to just use a simple regex.
|
|
172
172
|
|
|
173
173
|
const [_, crs, shape, dimensions] =
|
|
174
|
-
/<https
|
|
174
|
+
/<https?:\/\/www.opengis.net\/def\/crs\/([^"]+)> (POLYGON|POINT)\(\(?([\d,. ]+)\)\)?/.exec(
|
|
175
175
|
gml,
|
|
176
176
|
) || [];
|
|
177
177
|
if (crs && crs === 'EPSG/0/31370') {
|
|
@@ -342,7 +342,7 @@ export type Lambert72Coordinates = {
|
|
|
342
342
|
};
|
|
343
343
|
|
|
344
344
|
export function constructLambert72GMLString({ x, y }: Lambert72Coordinates) {
|
|
345
|
-
return `<gml:Point srsName="
|
|
345
|
+
return `<gml:Point srsName="http://www.opengis.net/def/crs/EPSG/0/31370" xmlns:gml="http://www.opengis.net/gml/3.2"><gml:pos>${x} ${y}</gml:pos></gml:Point>`;
|
|
346
346
|
}
|
|
347
347
|
/**
|
|
348
348
|
* Use a regex to parse a simple point as a GML string and return the coordinates.
|
|
@@ -354,7 +354,7 @@ export function parseLambert72GMLString(gml: string): Lambert72Coordinates {
|
|
|
354
354
|
// which can be represented. Since we handle only simple points, it's much less complex to just
|
|
355
355
|
// use a simple regex.
|
|
356
356
|
const [_, crs, x, y] =
|
|
357
|
-
/<gml.Point .*srsName="https
|
|
357
|
+
/<gml.Point .*srsName="https?:\/\/www.opengis.net\/def\/crs\/([^"]+)".+<gml.pos>(\S+) ([^<]+)<\/gml:pos>/.exec(
|
|
358
358
|
gml,
|
|
359
359
|
) || [];
|
|
360
360
|
if (!crs || crs !== 'EPSG/0/31370') {
|
|
@@ -370,7 +370,7 @@ export function parseLambert72GMLString(gml: string): Lambert72Coordinates {
|
|
|
370
370
|
* [the GeoSPARQL spec]{@link https://docs.ogc.org/is/22-047r1/22-047r1.html#10-8-1-%C2%A0-well-known-text}
|
|
371
371
|
*/
|
|
372
372
|
export function constructLambert72WKTString({ x, y }: Lambert72Coordinates) {
|
|
373
|
-
return `<
|
|
373
|
+
return `<http://www.opengis.net/def/crs/EPSG/0/31370> POINT(${x} ${y})`;
|
|
374
374
|
}
|
|
375
375
|
/**
|
|
376
376
|
* Use a regex to parse a simple point as a WKT string and return the coordinates.
|
|
@@ -382,7 +382,7 @@ export function parseLambert72WKTString(gml: string): Lambert72Coordinates {
|
|
|
382
382
|
// which can be represented or within untyped libraries (e.g. wicket). Since we handle only simple
|
|
383
383
|
// points, it's much less complex to just use a simple regex.
|
|
384
384
|
const [_, crs, x, y] =
|
|
385
|
-
/<https
|
|
385
|
+
/<https?:\/\/www.opengis.net\/def\/crs\/([^"]+)> POINT\((\S+) ([^)]+)\)/.exec(
|
|
386
386
|
gml,
|
|
387
387
|
) || [];
|
|
388
388
|
if (!crs || crs !== 'EPSG/0/31370') {
|
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
-
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { PNode, SayController } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import IntlService from 'ember-intl/services/intl';
|
|
3
4
|
export interface InsertArticleOptions {
|
|
4
5
|
uriGenerator?: () => string;
|
|
6
|
+
insertFreely?: boolean;
|
|
5
7
|
}
|
|
6
8
|
interface Sig {
|
|
7
9
|
Args: {
|
|
8
10
|
controller: SayController;
|
|
11
|
+
label: string;
|
|
9
12
|
options?: InsertArticleOptions;
|
|
10
13
|
};
|
|
11
14
|
}
|
|
12
15
|
export default class InsertArticleComponent extends Component<Sig> {
|
|
16
|
+
intl: IntlService;
|
|
13
17
|
get controller(): SayController;
|
|
18
|
+
get options(): InsertArticleOptions | undefined;
|
|
19
|
+
get label(): string;
|
|
14
20
|
get schema(): import("prosemirror-model").Schema<any, any>;
|
|
15
21
|
get decisionRange(): import("@lblod/ember-rdfa-editor/plugins/datastore").ElementPNode | undefined;
|
|
16
22
|
get decisionLocation(): {
|
|
17
23
|
pos: number;
|
|
18
|
-
node:
|
|
24
|
+
node: PNode;
|
|
19
25
|
} | null;
|
|
20
26
|
get canInsert(): boolean;
|
|
27
|
+
get canInsertFreely(): boolean;
|
|
28
|
+
get canInsertInDecision(): boolean;
|
|
21
29
|
doInsert(): void;
|
|
30
|
+
insertFreely(node: PNode): void;
|
|
31
|
+
insertInDecision(node: PNode): void;
|
|
22
32
|
}
|
|
23
33
|
export {};
|