@lblod/ember-rdfa-editor-lblod-plugins 5.0.1 → 6.0.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 +13 -1
- package/README.md +126 -70
- package/addon/components/address-plugin/insert.hbs +47 -0
- package/addon/components/address-plugin/insert.ts +100 -0
- package/addon/components/address-plugin/types.ts +26 -0
- package/addon/components/address-plugin/utils.ts +59 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +6 -5
- package/addon/components/{besluit-plugin/besluit-plugin-card.ts → decision-plugin/decision-plugin-card.ts} +22 -8
- package/addon/components/roadsign-regulation-plugin/measure-template.ts +5 -1
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +1 -1
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.hbs +1 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +24 -21
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.ts +8 -11
- package/addon/components/validation-plugin/validation-card.hbs +12 -0
- package/addon/components/validation-plugin/validation-card.ts +19 -0
- package/addon/components/validation-plugin/validation-item.hbs +2 -0
- package/addon/components/validation-plugin/validation-item.ts +55 -0
- package/addon/components/variable-plugin/template-variable-card.ts +8 -25
- package/addon/plugins/besluit-type-plugin/index.ts +3 -0
- package/addon/plugins/besluit-type-plugin/utils/fetchBesluitTypes.ts +1 -6
- package/addon/plugins/decision-plugin/commands/index.ts +4 -0
- package/addon/plugins/decision-plugin/commands/insert-article-container.ts +56 -0
- package/addon/plugins/decision-plugin/commands/insert-description.ts +53 -0
- package/addon/plugins/decision-plugin/commands/insert-motivation.ts +62 -0
- package/addon/plugins/decision-plugin/commands/insert-title.ts +54 -0
- package/addon/plugins/roadsign-regulation-plugin/index.ts +4 -0
- package/addon/plugins/standard-template-plugin/utils/nodes.ts +0 -1
- package/addon/plugins/validation/README.md +84 -0
- package/addon/plugins/validation/index.ts +427 -0
- package/addon/plugins/validation/utils/transaction-complies-with-shapes.ts +28 -0
- package/addon/plugins/variable-plugin/index.ts +5 -0
- package/addon/services/roadsign-registry.ts +54 -50
- package/addon/utils/find-insertion-pos-in-ancestor-of-type.ts +35 -0
- package/app/components/{besluit-plugin/besluit-plugin-card.js → address-plugin/insert.js} +1 -1
- package/app/components/decision-plugin/decision-plugin-card.js +1 -0
- package/app/components/{besluit-plugin/besluit-context-card.js → validation-plugin/validation-card.js} +1 -1
- package/app/components/validation-plugin/validation-item.js +1 -0
- package/app/styles/address-plugin.scss +7 -0
- package/components/address-plugin/insert.d.ts +21 -0
- package/components/address-plugin/types.d.ts +25 -0
- package/components/address-plugin/utils.d.ts +9 -0
- package/components/besluit-type-plugin/toolbar-dropdown.d.ts +2 -0
- package/components/{besluit-plugin/besluit-plugin-card.d.ts → decision-plugin/decision-plugin-card.d.ts} +4 -1
- package/components/roadsign-regulation-plugin/measure-template.d.ts +2 -0
- package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +3 -0
- package/components/roadsign-regulation-plugin/roadsigns-table.d.ts +6 -1
- package/components/validation-plugin/validation-card.d.ts +13 -0
- package/components/validation-plugin/validation-item.d.ts +18 -0
- package/components/variable-plugin/template-variable-card.d.ts +2 -4
- package/package.json +1 -1
- package/plugins/besluit-type-plugin/index.d.ts +3 -0
- package/plugins/besluit-type-plugin/utils/fetchBesluitTypes.d.ts +1 -5
- package/plugins/decision-plugin/commands/index.d.ts +4 -0
- package/plugins/decision-plugin/commands/insert-article-container.d.ts +8 -0
- package/plugins/decision-plugin/commands/insert-description.d.ts +7 -0
- package/plugins/decision-plugin/commands/insert-motivation.d.ts +7 -0
- package/plugins/decision-plugin/commands/insert-title.d.ts +7 -0
- package/plugins/roadsign-regulation-plugin/index.d.ts +4 -0
- package/plugins/validation/index.d.ts +62 -0
- package/plugins/validation/utils/transaction-complies-with-shapes.d.ts +10 -0
- package/plugins/variable-plugin/index.d.ts +5 -0
- package/services/roadsign-registry.d.ts +7 -9
- package/translations/en-US.yaml +58 -47
- package/translations/nl-BE.yaml +15 -0
- package/utils/find-insertion-pos-in-ancestor-of-type.d.ts +11 -0
- package/addon/plugins/besluit-plugin/commands/index.ts +0 -1
- package/addon/plugins/besluit-plugin/commands/insert-title.ts +0 -43
- package/config/environment.js +0 -20
- package/plugins/besluit-plugin/commands/index.d.ts +0 -1
- package/plugins/besluit-plugin/commands/insert-title.d.ts +0 -3
- /package/addon/components/{besluit-plugin/besluit-plugin-card.hbs → decision-plugin/decision-plugin-card.hbs} +0 -0
- /package/addon/plugins/{besluit-plugin → decision-plugin}/utils/get-title-for-decision.ts +0 -0
- /package/plugins/{besluit-plugin → decision-plugin}/utils/get-title-for-decision.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [6.0.0] - 2023-05-05
|
|
11
|
+
### Changed
|
|
12
|
+
- Use plugin configuration instead of ember environment in all the plugins
|
|
13
|
+
- Insert address plugin
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- validation plugin
|
|
17
|
+
|
|
18
|
+
### Deprecated
|
|
19
|
+
- the decision-plugin card component is now deprecated in favor of the host app's choice of insert button
|
|
20
|
+
|
|
10
21
|
## [5.0.1] - 2023-04-07
|
|
11
22
|
### Fixed
|
|
12
23
|
- fix deprecated use of modifier without specifying eagerness
|
|
@@ -412,7 +423,8 @@ add onclick handler to pencil icon in variable plugin
|
|
|
412
423
|
|
|
413
424
|
# Changelog
|
|
414
425
|
|
|
415
|
-
[unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/
|
|
426
|
+
[unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v6.0.0...HEAD
|
|
427
|
+
[6.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v5.0.1...v6.0.0
|
|
416
428
|
[5.0.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v5.0.0...v5.0.1
|
|
417
429
|
[5.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.2...v5.0.0
|
|
418
430
|
[4.0.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.1...v4.0.2
|
package/README.md
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
# ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Ember v2 addon which bundles a collection of [ember-rdfa-editor](https://github.com/lblod/ember-rdfa-editor) plugins
|
|
4
|
+
related to the LBLOD Project.
|
|
6
5
|
|
|
7
6
|
## Compatibility
|
|
8
7
|
|
|
9
|
-
|
|
10
8
|
* Ember.js v3.28 or above
|
|
11
9
|
* Embroider or ember-auto-import v2
|
|
12
10
|
* Node 18 or above
|
|
13
11
|
|
|
14
|
-
|
|
15
12
|
## Installation
|
|
16
13
|
|
|
17
|
-
|
|
18
14
|
```
|
|
19
15
|
ember install ember-rdfa-editor-lblod-plugins
|
|
20
16
|
```
|
|
21
17
|
|
|
22
|
-
|
|
23
18
|
## General addon information
|
|
24
19
|
|
|
25
|
-
|
|
26
20
|
This addon contains the following editor plugins:
|
|
21
|
+
|
|
27
22
|
* besluit-type-plugin
|
|
28
23
|
* citaten-plugin
|
|
29
24
|
* import-snippet-plugin
|
|
@@ -33,6 +28,7 @@ This addon contains the following editor plugins:
|
|
|
33
28
|
* standard-template-plugin
|
|
34
29
|
* table-of-contents-plugin
|
|
35
30
|
* template-variable-plugin
|
|
31
|
+
* validation-plugin
|
|
36
32
|
|
|
37
33
|
You can configure your editor like this:
|
|
38
34
|
```hbs
|
|
@@ -61,8 +57,8 @@ You can configure your editor like this:
|
|
|
61
57
|
</:aside>
|
|
62
58
|
</EditorContainer>
|
|
63
59
|
```
|
|
64
|
-
You will have 2 anchor points where to put your plugins: `top` for a toolbar, and `aside` for plugin cards.
|
|
65
60
|
|
|
61
|
+
You will have 2 anchor points where to put your plugins: `top` for a toolbar, and `aside` for plugin cards.
|
|
66
62
|
|
|
67
63
|
## besluit-type-plugin
|
|
68
64
|
|
|
@@ -70,10 +66,18 @@ Plugin which allows a user to change the type of a [besluit](https://data.vlaand
|
|
|
70
66
|
|
|
71
67
|
This plugin needs to be added to the toolbar as a dropdown with the following syntax:
|
|
72
68
|
```hbs
|
|
73
|
-
<BesluitTypePlugin::ToolbarDropdown @controller={{this.controller}}/>
|
|
69
|
+
<BesluitTypePlugin::ToolbarDropdown @controller={{this.controller}} @options={{this.config.besluitType}}/>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
You can need to specify the endpoint from which the plugin will fetch the types
|
|
73
|
+
```js
|
|
74
|
+
{
|
|
75
|
+
endpoint: 'https://centrale-vindplaats.lblod.info/sparql',
|
|
76
|
+
}
|
|
74
77
|
```
|
|
75
78
|
|
|
76
79
|
## citaten-plugin
|
|
80
|
+
|
|
77
81
|
Plugin which allows a user to insert references to a legal resource or legal expression into the document.
|
|
78
82
|
|
|
79
83
|
This plugin provides a card that needs to be added to the sidebar of the editor like
|
|
@@ -127,7 +131,10 @@ const configB = {
|
|
|
127
131
|
};
|
|
128
132
|
```
|
|
129
133
|
### Using the plugin
|
|
130
|
-
|
|
134
|
+
|
|
135
|
+
If used with the example configuration provided this plugin can be triggered by typing one of the following in the correct RDFa context (
|
|
136
|
+
the [besluit:motivering](http://data.vlaanderen.be/ns/besluit#motivering) of
|
|
137
|
+
a [besluit:Besluit](https://data.vlaanderen.be/ns/besluit#Besluit)).
|
|
131
138
|
|
|
132
139
|
* [specification]**decreet** [words to search for] *(e.g. "gemeentedecreet wijziging")*
|
|
133
140
|
* **omzendbrief** [words to search for]
|
|
@@ -143,9 +150,12 @@ If used with the example configuration provided this plugin can be triggered by
|
|
|
143
150
|
* **ministerieel besluit** [words to search for]
|
|
144
151
|
* **genummerd besluit** [words to search for]
|
|
145
152
|
|
|
146
|
-
You should be able to add a reference manually by clicking on the `Insert` > `Insert reference` item in the Insert menu
|
|
153
|
+
You should be able to add a reference manually by clicking on the `Insert` > `Insert reference` item in the Insert menu
|
|
154
|
+
located on the top right of the editor. This will open the advanced search window. **Note** that this will only be
|
|
155
|
+
avaliable in the proper context (see above in this section).
|
|
147
156
|
|
|
148
157
|
## import-snippet-plugin
|
|
158
|
+
|
|
149
159
|
Plugin allowing importing of external RDFA snippets and inserting it in the document.
|
|
150
160
|
|
|
151
161
|
The plugin has a card that needs to be added to the sidebar:
|
|
@@ -155,7 +165,8 @@ The plugin has a card that needs to be added to the sidebar:
|
|
|
155
165
|
|
|
156
166
|
### Using the plugin
|
|
157
167
|
|
|
158
|
-
This plugin provides an Ember service, `import-rdfa-snippet` which allows you to download rdfa snippets in the following
|
|
168
|
+
This plugin provides an Ember service, `import-rdfa-snippet` which allows you to download rdfa snippets in the following
|
|
169
|
+
manner:
|
|
159
170
|
|
|
160
171
|
```js
|
|
161
172
|
import { inject as service } from '@ember/service';
|
|
@@ -164,15 +175,18 @@ import { inject as service } from '@ember/service';
|
|
|
164
175
|
// An entry point to download the resouce (e.g a route) in your host app.
|
|
165
176
|
// (...)
|
|
166
177
|
|
|
167
|
-
|
|
168
|
-
|
|
178
|
+
let downloadData = { source: 'http://remote/resource.html' }
|
|
179
|
+
await this.importRdfaSnippet.downloadSnippet(downloadData);
|
|
169
180
|
```
|
|
170
181
|
|
|
171
|
-
After having downloaded a snippet, a user can use the plugin in the Gelinkt Notuleren
|
|
182
|
+
After having downloaded a snippet, a user can use the plugin in the Gelinkt Notuleren
|
|
183
|
+
application (https://github.com/lblod/frontend-gelinkt-notuleren).
|
|
172
184
|
|
|
173
|
-
When opening a new document, users will get the option to either include the snippet data in the document or as an
|
|
185
|
+
When opening a new document, users will get the option to either include the snippet data in the document or as an
|
|
186
|
+
attachment.
|
|
174
187
|
|
|
175
188
|
## insert-variable-plugin
|
|
189
|
+
|
|
176
190
|
Plugin which allows users to insert variable placeholders into a document.
|
|
177
191
|
|
|
178
192
|
The plugin provides a card that needs to be attached to the editor sidebar like
|
|
@@ -186,28 +200,39 @@ The plugin provides a card that needs to be attached to the editor sidebar like
|
|
|
186
200
|
### Configuring the plugin
|
|
187
201
|
|
|
188
202
|
The plugin can be configured through the following optional attributes that can be added as a json to the options attribute of the card:
|
|
189
|
-
|
|
190
|
-
- `
|
|
191
|
-
|
|
203
|
+
|
|
204
|
+
- `publisher`: the URI of a specific codelist publisher which you can use if you want to filter the codelists by its
|
|
205
|
+
publisher.
|
|
206
|
+
- `defaultEndpoint`: The default endpoint where the codelists are fetched, this is also the variable that gets passed to
|
|
207
|
+
the fetchSubtypes and template function
|
|
208
|
+
- `variableTypes`: a custom list of variable types you want the plugin to use. This list can contain the following
|
|
209
|
+
default variable types: `text`, `number`,`date`,`location` and `codelist`. Additionally this list can also contain
|
|
210
|
+
custom variable types, configured by the following three sub-attributes:
|
|
192
211
|
* `label`: the label of the custom variable type
|
|
193
|
-
* `fetchSubTypes` (optional): a function which returns a list of possible variable values. The function takes two
|
|
212
|
+
* `fetchSubTypes` (optional): a function which returns a list of possible variable values. The function takes two
|
|
213
|
+
optional arguments: an `endpoint` and a `publisher`.
|
|
194
214
|
* `constructor`: function which returns a prosemirror node to be inserted, the function takes three arguments, the prosemirror `schema`, the `endpoint` and the `selectedSubtype` if you are using subtypes.
|
|
195
215
|
|
|
196
216
|
#### Example
|
|
197
217
|
|
|
198
218
|
```js
|
|
199
219
|
{
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
'
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
220
|
+
|
|
221
|
+
publisher: 'http://data.lblod.info/id/bestuurseenheden/141d9d6b-54af-4d17-b313-8d1c30bc3f5b',
|
|
222
|
+
defaultEndpoint
|
|
223
|
+
:
|
|
224
|
+
'https://dev.roadsigns.lblod.info/sparql',
|
|
225
|
+
variableTypes
|
|
226
|
+
:
|
|
227
|
+
[
|
|
228
|
+
'text',
|
|
229
|
+
'number',
|
|
230
|
+
'date',
|
|
231
|
+
'location',
|
|
232
|
+
'codelist',
|
|
233
|
+
{
|
|
234
|
+
label: 'Simple Variable',
|
|
235
|
+
constructor: (schema) => {
|
|
211
236
|
const mappingURI = `http://data.lblod.info/mappings/${uuidv4()}`;
|
|
212
237
|
const variableInstance = `http://data.lblod.info/variables/${uuidv4()}`;
|
|
213
238
|
return schema.node(
|
|
@@ -220,27 +245,27 @@ The plugin can be configured through the following optional attributes that can
|
|
|
220
245
|
schema.node('placeholder', { placeholderText: 'text' })
|
|
221
246
|
);
|
|
222
247
|
},
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
label: 'Complex Variable',
|
|
226
|
-
fetchSubtypes: async (endpoint, publisher) => {
|
|
227
|
-
const subtypes = [
|
|
228
|
-
{
|
|
229
|
-
uri: '1',
|
|
230
|
-
label: '1',
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
uri: '2',
|
|
234
|
-
label: '2',
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
uri: '3',
|
|
238
|
-
label: '3',
|
|
239
|
-
},
|
|
240
|
-
];
|
|
241
|
-
return subtypes;
|
|
242
248
|
},
|
|
243
|
-
|
|
249
|
+
{
|
|
250
|
+
label: 'Complex Variable',
|
|
251
|
+
fetchSubtypes: async (endpoint, publisher) => {
|
|
252
|
+
const subtypes = [
|
|
253
|
+
{
|
|
254
|
+
uri: '1',
|
|
255
|
+
label: '1',
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
uri: '2',
|
|
259
|
+
label: '2',
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
uri: '3',
|
|
263
|
+
label: '3',
|
|
264
|
+
},
|
|
265
|
+
];
|
|
266
|
+
return subtypes;
|
|
267
|
+
},
|
|
268
|
+
constructor: (schema, endpoint, selectedSubtype) => {
|
|
244
269
|
const mappingURI = `http://data.lblod.info/mappings/${uuidv4()}`;
|
|
245
270
|
const variableInstance = `http://data.lblod.info/variables/${uuidv4()}`;
|
|
246
271
|
return schema.node(
|
|
@@ -261,12 +286,14 @@ The plugin can be configured through the following optional attributes that can
|
|
|
261
286
|
],
|
|
262
287
|
}
|
|
263
288
|
```
|
|
264
|
-
### Using the plugin
|
|
265
289
|
|
|
266
|
-
|
|
290
|
+
### Using the plugin
|
|
267
291
|
|
|
292
|
+
When the insert-variable-plugin is enabled, users will have the option to insert a variable into a document through a
|
|
293
|
+
card which pops up in the sidebar of the editor.
|
|
268
294
|
|
|
269
295
|
## rdfa-date-plugin
|
|
296
|
+
|
|
270
297
|
Plugin to insert and modify semantic dates and timestamps in an editor document.
|
|
271
298
|
|
|
272
299
|
This plugin provides a card to modify dates that needs to be added to the editor sidebar like
|
|
@@ -296,7 +323,9 @@ You will also need to add the date node with the following configuration (being
|
|
|
296
323
|
```
|
|
297
324
|
|
|
298
325
|
## roadsign-regulation-plugin
|
|
299
|
-
|
|
326
|
+
|
|
327
|
+
A plugin that fetches data from the mow regulation and roadsign registry and allows users to insert roadsign regulations
|
|
328
|
+
inside an editor document.
|
|
300
329
|
|
|
301
330
|
This plugin provides a card that needs to be added to the editor sidebar like:
|
|
302
331
|
|
|
@@ -304,10 +333,20 @@ This plugin provides a card that needs to be added to the editor sidebar like:
|
|
|
304
333
|
<RoadsignRegulationPlugin::RoadsignRegulationCard @controller={{this.controller}}/>
|
|
305
334
|
```
|
|
306
335
|
|
|
307
|
-
|
|
336
|
+
You will need to set the following configuration
|
|
337
|
+
```js
|
|
338
|
+
{
|
|
339
|
+
endpoint: 'https://dev.roadsigns.lblod.info/sparql',
|
|
340
|
+
imageBaseUrl: 'https://register.mobiliteit.vlaanderen.be/',
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
The `endpoint` from where the plugin will fetch the roadsigns, and the `imageBaseUrl` is a fallback for the images that don't have a baseUrl specified, probably you won't need it if your data is correctly constructed
|
|
308
344
|
|
|
309
345
|
## standard-template-plugin
|
|
310
|
-
|
|
346
|
+
|
|
347
|
+
Plugin which allows users to insert standard templates in the editor. Depending on the position of the cursor or
|
|
348
|
+
selected text, a dropdown will appear in the toolbar of the editor that lets you insert a template for the proper
|
|
349
|
+
context at the location of the cursor.
|
|
311
350
|
|
|
312
351
|
In order to use this plugin you will need to add its card:
|
|
313
352
|
```hbs
|
|
@@ -321,12 +360,16 @@ When creating a template in your database, the following properties are used by
|
|
|
321
360
|
* the title of the template (`title`)
|
|
322
361
|
* its HTML content (`content`)
|
|
323
362
|
* the words of the document the template should match on (`matches`)
|
|
324
|
-
* the contexts in which it should be active (`contexts`)
|
|
363
|
+
* the contexts in which it should be active (`contexts`)
|
|
325
364
|
* the contexts in which it should not be active (`disabled-in-contexts`)
|
|
326
365
|
|
|
327
366
|
### Using the plugin
|
|
328
367
|
|
|
329
|
-
The plugin will search for RDFa contexts in the content of the editor and the editor itself. Based on the contexts, the
|
|
368
|
+
The plugin will search for RDFa contexts in the content of the editor and the editor itself. Based on the contexts, the
|
|
369
|
+
plugin will show possible templates to be added at the location of the cursor. E.g. if an element in the editor has
|
|
370
|
+
the `typeof="besluit:BehandelingVanAgendapunt"` attribute, the plugin will show the templates related
|
|
371
|
+
to [`besluit:BehandelingVanAgendapunt`](http://data.vlaanderen.be/ns/besluit#BehandelingVanAgendapunt) in the dropdown
|
|
372
|
+
menu. This attribute can be set on an element in the content of the editor or predefined in the editor itself.
|
|
330
373
|
|
|
331
374
|
## table-of-contents-plugin
|
|
332
375
|
|
|
@@ -340,8 +383,6 @@ In order to enable the plugin you need to add the table of contents button to th
|
|
|
340
383
|
```
|
|
341
384
|
tableOfContentsView(this.config.tableOfContents)(controller),
|
|
342
385
|
```
|
|
343
|
-
|
|
344
|
-
|
|
345
386
|
### Configuring the plugin with a custom config
|
|
346
387
|
|
|
347
388
|
You can configure the nodeview with the hiearchy of the nodes
|
|
@@ -350,8 +391,8 @@ You can configure the nodeview with the hiearchy of the nodes
|
|
|
350
391
|
{
|
|
351
392
|
nodeHierarchy: [
|
|
352
393
|
'title|chapter|section|subsection|article',
|
|
353
|
-
|
|
354
|
-
|
|
394
|
+
'structure_header|article_header',
|
|
395
|
+
],
|
|
355
396
|
},
|
|
356
397
|
```
|
|
357
398
|
|
|
@@ -362,7 +403,7 @@ Editor plugin which allows you to interact with placeholders created by the inse
|
|
|
362
403
|
|
|
363
404
|
For enabling it, you need to add the card provided by the plugin to the editor sidebar
|
|
364
405
|
```hbs
|
|
365
|
-
<VariablePlugin::TemplateVariableCard @controller={{this.controller}}/>
|
|
406
|
+
<VariablePlugin::TemplateVariableCard @controller={{this.controller}} @options={{this.config.templateVariable}}/>
|
|
366
407
|
```
|
|
367
408
|
|
|
368
409
|
You will also need to add the variable node to the list of nodes of your prosemirror schema and the variable view to the list of nodeviews like `variable: variableView(controller)` imported from:
|
|
@@ -378,25 +419,40 @@ import {
|
|
|
378
419
|
### Configuring the plugin
|
|
379
420
|
|
|
380
421
|
|
|
381
|
-
You can configure the
|
|
422
|
+
You can configure the card with the following attributes:
|
|
382
423
|
|
|
383
424
|
```js
|
|
384
|
-
|
|
425
|
+
{
|
|
385
426
|
endpoint: 'https://dev.roadsigns.lblod.info/sparql', // the fallback endpoint which should be used for codelists which do not have a `dct:source` property.
|
|
386
427
|
zonalLocationCodelistUri:
|
|
387
428
|
'http://lblod.data.gift/concept-schemes/62331E6900730AE7B99DF7EF',
|
|
388
429
|
nonZonalLocationCodelistUri:
|
|
389
430
|
'http://lblod.data.gift/concept-schemes/62331FDD00730AE7B99DF7F2',
|
|
390
|
-
}
|
|
431
|
+
}
|
|
391
432
|
```
|
|
433
|
+
The most important attributes are `zonalLocationCodelistUri` and `nonZonalLocationCodelistUri` that are the uri that the location codelists have on your backend.
|
|
392
434
|
|
|
393
|
-
##
|
|
435
|
+
## validation-plugin
|
|
394
436
|
|
|
437
|
+
see [the plugin docs](addon/plugins/validation/README.md)
|
|
395
438
|
|
|
396
|
-
|
|
439
|
+
## address-plugin
|
|
397
440
|
|
|
441
|
+
Editor plugin which allows you to insert address based on information from
|
|
398
442
|
|
|
399
|
-
|
|
443
|
+
- https://basisregisters.vlaanderen.be/api/v1/adressen
|
|
444
|
+
- https://geo.api.vlaanderen.be/geolocation/v4/Location
|
|
445
|
+
|
|
446
|
+
For enabling it, you need to add the card provided by the plugin to the editor sidebar
|
|
447
|
+
|
|
448
|
+
```hbs
|
|
449
|
+
<AddressPlugin::Insert @controller={{this.controller}} />
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
## Contributing
|
|
400
453
|
|
|
454
|
+
See the [Contributing](CONTRIBUTING.md) guide for details.
|
|
455
|
+
|
|
456
|
+
## License
|
|
401
457
|
|
|
402
458
|
This project is licensed under the [MIT License](LICENSE.md).
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<AuList::Item>
|
|
2
|
+
<AuButton
|
|
3
|
+
@icon='add'
|
|
4
|
+
@iconAlignment='left'
|
|
5
|
+
@skin='link'
|
|
6
|
+
{{on 'click' (fn this.openModal true)}}
|
|
7
|
+
>
|
|
8
|
+
{{t 'address-plugin.insert.address'}}
|
|
9
|
+
</AuButton>
|
|
10
|
+
</AuList::Item>
|
|
11
|
+
<AuModal
|
|
12
|
+
@modalOpen={{this.modalOpen}}
|
|
13
|
+
@closeModal={{this.closeModal}}
|
|
14
|
+
class='address-plugin-modal'
|
|
15
|
+
>
|
|
16
|
+
<:title>{{t 'address-plugin.insert.address'}}</:title>
|
|
17
|
+
<:body>
|
|
18
|
+
<PowerSelect
|
|
19
|
+
@renderInPlace={{true}}
|
|
20
|
+
@searchEnabled={{true}}
|
|
21
|
+
@searchMessage={{t 'address-plugin.search.cta'}}
|
|
22
|
+
@noMatchesMessage={{t 'address-plugin.search.no-match'}}
|
|
23
|
+
@options={{this.addressSuggestion}}
|
|
24
|
+
@search={{perform this.searchAddress}}
|
|
25
|
+
@onChange={{this.selectAddress}}
|
|
26
|
+
@selected={{this.selectedAddress}}
|
|
27
|
+
as |address|
|
|
28
|
+
>
|
|
29
|
+
{{address.FormattedAddress}}
|
|
30
|
+
</PowerSelect>
|
|
31
|
+
</:body>
|
|
32
|
+
<:footer>
|
|
33
|
+
<AuButtonGroup>
|
|
34
|
+
<AuButton
|
|
35
|
+
@skin='primary'
|
|
36
|
+
@disabled={{not this.canInsertAddress}}
|
|
37
|
+
@loading={{this.isSelectingAddress}}
|
|
38
|
+
{{on 'click' (perform this.insertAddress)}}
|
|
39
|
+
>
|
|
40
|
+
{{t 'address-plugin.button.insert'}}
|
|
41
|
+
</AuButton>
|
|
42
|
+
<AuButton @skin='secondary' {{on 'click' this.closeModal}}>
|
|
43
|
+
{{t 'address-plugin.button.back'}}
|
|
44
|
+
</AuButton>
|
|
45
|
+
</AuButtonGroup>
|
|
46
|
+
</:footer>
|
|
47
|
+
</AuModal>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
4
|
+
import { tracked } from 'tracked-built-ins';
|
|
5
|
+
import { restartableTask, task, timeout } from 'ember-concurrency';
|
|
6
|
+
|
|
7
|
+
import { AddressSuggestion } from './types';
|
|
8
|
+
import { getAddressMatch, getSuggestedLocations } from './utils';
|
|
9
|
+
|
|
10
|
+
type Args = {
|
|
11
|
+
controller: SayController;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default class AddressPluginInsertComponent extends Component<Args> {
|
|
15
|
+
@tracked modalOpen = false;
|
|
16
|
+
@tracked isSelectingAddress = false;
|
|
17
|
+
|
|
18
|
+
@tracked addressSuggestions: AddressSuggestion[] = [];
|
|
19
|
+
@tracked selectedAddress: AddressSuggestion | null = null;
|
|
20
|
+
|
|
21
|
+
get controller() {
|
|
22
|
+
return this.args.controller;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get schema() {
|
|
26
|
+
return this.controller.schema;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@action
|
|
30
|
+
openModal() {
|
|
31
|
+
this.modalOpen = true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@action
|
|
35
|
+
closeModal() {
|
|
36
|
+
this.modalOpen = false;
|
|
37
|
+
this.selectedAddress = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@action
|
|
41
|
+
selectAddress(selection: AddressSuggestion) {
|
|
42
|
+
this.selectedAddress = selection;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get canInsertAddress() {
|
|
46
|
+
if (this.isSelectingAddress) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!this.selectedAddress) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
insertAddress = task(async () => {
|
|
58
|
+
if (this.selectedAddress) {
|
|
59
|
+
this.isSelectingAddress = true;
|
|
60
|
+
|
|
61
|
+
const addresses = await getAddressMatch({
|
|
62
|
+
housenumber: this.selectedAddress.Housenumber,
|
|
63
|
+
municipality: this.selectedAddress.Municipality,
|
|
64
|
+
street: this.selectedAddress.Thoroughfarename,
|
|
65
|
+
zipcode: this.selectedAddress.Zipcode,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const address = addresses[0];
|
|
69
|
+
|
|
70
|
+
this.controller.withTransaction((tr) => {
|
|
71
|
+
tr.replaceSelectionWith(
|
|
72
|
+
this.schema.node(
|
|
73
|
+
'block_rdfa',
|
|
74
|
+
{
|
|
75
|
+
typeof: 'https://data.vlaanderen.be/ns/adres#Adres',
|
|
76
|
+
resource: address.identificator.id,
|
|
77
|
+
},
|
|
78
|
+
this.schema.node('paragraph', null, [
|
|
79
|
+
this.schema.text(address.volledigAdres.geografischeNaam.spelling),
|
|
80
|
+
])
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return tr;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
this.closeModal();
|
|
88
|
+
this.selectedAddress = null;
|
|
89
|
+
this.isSelectingAddress = false;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
searchAddress = restartableTask(async (term: string) => {
|
|
94
|
+
await timeout(400);
|
|
95
|
+
|
|
96
|
+
const locations = await getSuggestedLocations(term);
|
|
97
|
+
|
|
98
|
+
return locations;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type AddressSuggestion = {
|
|
2
|
+
ID: number;
|
|
3
|
+
FormattedAddress: string;
|
|
4
|
+
Municipality: string;
|
|
5
|
+
Thoroughfarename: string; // street
|
|
6
|
+
Housenumber: string;
|
|
7
|
+
Zipcode: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type Address = {
|
|
11
|
+
identificator: {
|
|
12
|
+
id: string;
|
|
13
|
+
naamruimte: string;
|
|
14
|
+
objectId: string;
|
|
15
|
+
versieId: string;
|
|
16
|
+
};
|
|
17
|
+
detail: string;
|
|
18
|
+
huisnummer: string;
|
|
19
|
+
volledigAdres: {
|
|
20
|
+
geografischeNaam: {
|
|
21
|
+
spelling: string;
|
|
22
|
+
taal: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
adresStatus: string;
|
|
26
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Address, AddressSuggestion } from './types';
|
|
2
|
+
|
|
3
|
+
const LOC_GEOPUNT_ENDPOINT = `https://geo.api.vlaanderen.be/geolocation/v4/Location`;
|
|
4
|
+
const BASISREGISTER_ADRESMATCH = `https://basisregisters.vlaanderen.be/api/v1/adressen`;
|
|
5
|
+
|
|
6
|
+
export const replaceAccents = (string: string) =>
|
|
7
|
+
string.normalize('NFD').replace(/([\u0300-\u036f])/g, '');
|
|
8
|
+
|
|
9
|
+
export async function getSuggestedLocations(query: string) {
|
|
10
|
+
const result = await fetch(
|
|
11
|
+
`${LOC_GEOPUNT_ENDPOINT}?q=${encodeURIComponent(
|
|
12
|
+
query.replace(/^"(.*)"$/, '$1')
|
|
13
|
+
)}&c=10&type=Housenumber`,
|
|
14
|
+
{
|
|
15
|
+
method: 'GET',
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const jsonResult = (await result.json()) as {
|
|
20
|
+
LocationResult: AddressSuggestion[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
if (!jsonResult) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return jsonResult.LocationResult;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function getAddressMatch({
|
|
31
|
+
municipality,
|
|
32
|
+
zipcode,
|
|
33
|
+
street,
|
|
34
|
+
housenumber,
|
|
35
|
+
}: {
|
|
36
|
+
municipality: string;
|
|
37
|
+
street: string;
|
|
38
|
+
housenumber: string;
|
|
39
|
+
zipcode: string;
|
|
40
|
+
}) {
|
|
41
|
+
const url = new URL(BASISREGISTER_ADRESMATCH);
|
|
42
|
+
|
|
43
|
+
url.searchParams.append('GemeenteNaam', replaceAccents(municipality));
|
|
44
|
+
url.searchParams.append('Straatnaam', replaceAccents(street));
|
|
45
|
+
url.searchParams.append('Huisnummer', replaceAccents(housenumber));
|
|
46
|
+
url.searchParams.append('Postcode', replaceAccents(zipcode));
|
|
47
|
+
|
|
48
|
+
const response = await fetch(url.toString(), {
|
|
49
|
+
method: 'GET',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const result = (await response.json()) as {
|
|
53
|
+
adressen: Address[];
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
if (!result) return [];
|
|
57
|
+
|
|
58
|
+
return result.adressen;
|
|
59
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { tracked } from '@glimmer/tracking';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
|
-
import { getOwner } from '@ember/application';
|
|
5
4
|
import { inject as service } from '@ember/service';
|
|
6
5
|
import {
|
|
7
6
|
addType,
|
|
@@ -17,6 +16,7 @@ import fetchBesluitTypes, {
|
|
|
17
16
|
import { findAncestorOfType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/utils/structure';
|
|
18
17
|
import { trackedFunction } from 'ember-resources/util/function';
|
|
19
18
|
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
19
|
+
import { BesluitTypePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin';
|
|
20
20
|
|
|
21
21
|
declare module 'ember__owner' {
|
|
22
22
|
export default interface Owner {
|
|
@@ -26,6 +26,7 @@ declare module 'ember__owner' {
|
|
|
26
26
|
|
|
27
27
|
type Args = {
|
|
28
28
|
controller: SayController;
|
|
29
|
+
options: BesluitTypePluginOptions;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
export default class EditorPluginsToolbarDropdownComponent extends Component<Args> {
|
|
@@ -63,10 +64,10 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
63
64
|
// eslint-disable-next-line @typescript-eslint/await-thenable
|
|
64
65
|
const bestuurseenheid = await this.currentSession.get('group');
|
|
65
66
|
const classificatie = await bestuurseenheid.get('classificatie');
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const types = await fetchBesluitTypes(
|
|
68
|
+
classificatie.uri,
|
|
69
|
+
this.args.options.endpoint
|
|
70
|
+
);
|
|
70
71
|
return types;
|
|
71
72
|
});
|
|
72
73
|
|