@lblod/ember-rdfa-editor-lblod-plugins 12.0.0 → 13.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.
Files changed (102) hide show
  1. package/.woodpecker/.changeset.yml +1 -2
  2. package/CHANGELOG.md +49 -1
  3. package/README.md +242 -138
  4. package/addon/components/citation-plugin/citations/search-modal.hbs +22 -0
  5. package/addon/components/citation-plugin/citations/search-modal.ts +15 -0
  6. package/addon/components/decision-plugin/decision-plugin-card.hbs +3 -3
  7. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +2 -2
  8. package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +1 -0
  9. package/addon/components/template-comments-plugin/template-comment.hbs +4 -4
  10. package/addon/components/template-comments-plugin/template-comment.ts +16 -0
  11. package/addon/components/variable-plugin/address/edit.ts +1 -1
  12. package/addon/components/variable-plugin/address/insert-variable.hbs +9 -0
  13. package/addon/components/variable-plugin/address/insert-variable.ts +40 -0
  14. package/addon/components/variable-plugin/address/insert.hbs +2 -1
  15. package/addon/components/variable-plugin/address/insert.ts +22 -18
  16. package/addon/components/variable-plugin/address/nodeview.hbs +2 -2
  17. package/addon/components/variable-plugin/address/nodeview.ts +23 -1
  18. package/addon/components/variable-plugin/address/utils.ts +26 -0
  19. package/addon/components/variable-plugin/codelist/insert.ts +10 -1
  20. package/addon/components/{rdfa-date-plugin → variable-plugin/date}/date-time-picker.ts +1 -1
  21. package/addon/components/{rdfa-date-plugin/card.hbs → variable-plugin/date/edit.hbs} +3 -3
  22. package/addon/components/{rdfa-date-plugin/card.ts → variable-plugin/date/edit.ts} +10 -10
  23. package/addon/components/{rdfa-date-plugin → variable-plugin/date}/help-modal.ts +2 -2
  24. package/addon/components/variable-plugin/date/insert-variable.hbs +9 -0
  25. package/addon/components/variable-plugin/date/insert-variable.ts +57 -0
  26. package/addon/components/variable-plugin/date/insert.hbs +9 -9
  27. package/addon/components/variable-plugin/date/insert.ts +13 -10
  28. package/addon/components/{rdfa-date-plugin/date.hbs → variable-plugin/date/nodeview.hbs} +1 -1
  29. package/addon/components/{rdfa-date-plugin/date.ts → variable-plugin/date/nodeview.ts} +20 -6
  30. package/addon/components/variable-plugin/location/insert.ts +11 -2
  31. package/addon/components/variable-plugin/location/nodeview.hbs +8 -0
  32. package/addon/components/variable-plugin/location/nodeview.ts +15 -0
  33. package/addon/components/variable-plugin/number/insert.hbs +1 -1
  34. package/addon/components/variable-plugin/number/insert.ts +9 -1
  35. package/addon/components/variable-plugin/number/nodeview.hbs +2 -2
  36. package/addon/components/variable-plugin/number/nodeview.ts +17 -0
  37. package/addon/components/variable-plugin/text/insert.ts +14 -2
  38. package/addon/components/variable-plugin/variable/nodeview.hbs +1 -0
  39. package/addon/plugins/citation-plugin/index.ts +1 -0
  40. package/addon/plugins/citation-plugin/utils/legal-documents.ts +2 -0
  41. package/addon/plugins/citation-plugin/utils/public-decisions.ts +62 -26
  42. package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +8 -13
  43. package/addon/plugins/table-of-contents-plugin/utils/index.ts +7 -4
  44. package/addon/plugins/template-comments-plugin/node.ts +12 -3
  45. package/addon/plugins/variable-plugin/variables/address.ts +15 -8
  46. package/addon/plugins/variable-plugin/variables/codelist.ts +4 -4
  47. package/addon/plugins/variable-plugin/variables/date.ts +200 -0
  48. package/addon/plugins/variable-plugin/variables/index.ts +1 -0
  49. package/addon/plugins/variable-plugin/variables/location.ts +4 -4
  50. package/addon/plugins/variable-plugin/variables/number.ts +11 -8
  51. package/addon/plugins/variable-plugin/variables/text.ts +4 -4
  52. package/addon/utils/translation.ts +19 -0
  53. package/app/components/variable-plugin/address/insert-variable.js +1 -0
  54. package/app/components/variable-plugin/date/date-time-picker.js +1 -0
  55. package/app/components/{rdfa-date-plugin/card.js → variable-plugin/date/edit.js} +1 -1
  56. package/app/components/{rdfa-date-plugin → variable-plugin/date}/help-modal.js +1 -1
  57. package/app/components/{rdfa-date-plugin/date.js → variable-plugin/date/insert-variable.js} +1 -1
  58. package/app/components/{rdfa-date-plugin/insert.js → variable-plugin/date/nodeview.js} +1 -1
  59. package/app/components/{rdfa-date-plugin/date-time-picker.js → variable-plugin/location/nodeview.js} +1 -1
  60. package/app/styles/besluit-plugin.scss +2 -2
  61. package/app/styles/date-plugin.scss +0 -20
  62. package/app/styles/snippet-plugin.scss +1 -1
  63. package/app/styles/template-comments-plugin.scss +4 -4
  64. package/app/styles/variable-plugin.scss +8 -4
  65. package/components/citation-plugin/citations/search-modal.d.ts +3 -0
  66. package/components/template-comments-plugin/template-comment.d.ts +6 -0
  67. package/components/variable-plugin/address/insert-variable.d.ts +15 -0
  68. package/components/variable-plugin/address/insert.d.ts +4 -1
  69. package/components/variable-plugin/address/nodeview.d.ts +7 -0
  70. package/components/variable-plugin/address/utils.d.ts +2 -0
  71. package/components/variable-plugin/codelist/insert.d.ts +1 -0
  72. package/components/{rdfa-date-plugin → variable-plugin/date}/date-time-picker.d.ts +1 -1
  73. package/components/{rdfa-date-plugin/card.d.ts → variable-plugin/date/edit.d.ts} +3 -3
  74. package/components/{rdfa-date-plugin → variable-plugin/date}/help-modal.d.ts +1 -1
  75. package/components/variable-plugin/date/insert-variable.d.ts +16 -0
  76. package/components/variable-plugin/date/insert.d.ts +4 -3
  77. package/components/{rdfa-date-plugin/date.d.ts → variable-plugin/date/nodeview.d.ts} +5 -1
  78. package/components/variable-plugin/location/insert.d.ts +1 -0
  79. package/components/variable-plugin/location/nodeview.d.ts +12 -0
  80. package/components/variable-plugin/number/insert.d.ts +1 -0
  81. package/components/variable-plugin/number/nodeview.d.ts +5 -0
  82. package/components/variable-plugin/text/insert.d.ts +3 -0
  83. package/index.js +3 -0
  84. package/package.json +14 -10
  85. package/plugins/citation-plugin/index.d.ts +1 -0
  86. package/plugins/citation-plugin/utils/legal-documents.d.ts +1 -0
  87. package/plugins/table-of-contents-plugin/utils/index.d.ts +3 -2
  88. package/plugins/{rdfa-date-plugin/nodes → variable-plugin/variables}/date.d.ts +10 -1
  89. package/plugins/variable-plugin/variables/index.d.ts +1 -0
  90. package/translations/en-US.yaml +12 -0
  91. package/translations/nl-BE.yaml +13 -0
  92. package/utils/translation.d.ts +3 -0
  93. package/addon/components/rdfa-date-plugin/insert.hbs +0 -9
  94. package/addon/components/rdfa-date-plugin/insert.ts +0 -52
  95. package/addon/plugins/rdfa-date-plugin/index.ts +0 -28
  96. package/addon/plugins/rdfa-date-plugin/nodes/date.ts +0 -167
  97. package/components/rdfa-date-plugin/insert.d.ts +0 -16
  98. package/plugins/rdfa-date-plugin/index.d.ts +0 -15
  99. /package/addon/components/{rdfa-date-plugin → variable-plugin/date}/date-time-picker.hbs +0 -0
  100. /package/addon/components/{rdfa-date-plugin → variable-plugin/date}/help-modal.hbs +0 -0
  101. /package/addon/plugins/{rdfa-date-plugin/utils.ts → variable-plugin/utils/date-helpers.ts} +0 -0
  102. /package/plugins/{rdfa-date-plugin/utils.d.ts → variable-plugin/utils/date-helpers.d.ts} +0 -0
package/README.md CHANGED
@@ -5,9 +5,11 @@ related to the LBLOD Project.
5
5
 
6
6
  ## Compatibility
7
7
 
8
- * Ember.js v3.28 or above
9
- * Embroider or ember-auto-import v2
10
- * Node 18 or above
8
+ - Ember.js and ember data v3.28 or 4.x
9
+ note: we smoke-test for 3.28 but develop on the latest 4.x minor. The 5.x range is currently untested and not officially supported, but we accept issues and PRs to do so.
10
+
11
+ - Embroider or ember-auto-import v2
12
+ - Node 18 or above
11
13
 
12
14
  ## Installation
13
15
 
@@ -19,20 +21,20 @@ ember install ember-rdfa-editor-lblod-plugins
19
21
 
20
22
  This addon contains the following editor plugins:
21
23
 
22
- * [article-structure-plugin](#article-structure-plugin)
23
- * [besluit-type-plugin](#besluit-type-plugin)
24
- * [citaten-plugin](#citaten-plugin)
25
- * [decision-plugin](#decision-plugin)
26
- * [import-snippet-plugin](#import-snippet-plugin)
27
- * [rdfa-date-plugin](#rdfa-date-plugin)
28
- * [roadsign-regulation-plugin](#roadsign-regulation-plugin)
29
- * [standard-template-plugin](#standard-template-plugin)
30
- * [table-of-contents-plugin](#table-of-contents-plugin)
31
- * [variable-plugin](#variable-plugin)
32
- * [validation-plugin](#validation-plugin)
33
- * [template-comments-plugin](#template-comments-plugin)
24
+ - [article-structure-plugin](#article-structure-plugin)
25
+ - [besluit-type-plugin](#besluit-type-plugin)
26
+ - [citaten-plugin](#citaten-plugin)
27
+ - [decision-plugin](#decision-plugin)
28
+ - [import-snippet-plugin](#import-snippet-plugin)
29
+ - [roadsign-regulation-plugin](#roadsign-regulation-plugin)
30
+ - [standard-template-plugin](#standard-template-plugin)
31
+ - [table-of-contents-plugin](#table-of-contents-plugin)
32
+ - [variable-plugin](#variable-plugin)
33
+ - [validation-plugin](#validation-plugin)
34
+ - [template-comments-plugin](#template-comments-plugin)
34
35
 
35
36
  You can configure your editor like this:
37
+
36
38
  ```hbs
37
39
  <EditorContainer
38
40
  @editorOptions={{hash
@@ -52,7 +54,8 @@ You can configure your editor like this:
52
54
  @plugins={{this.plugins}}
53
55
  @schema={{this.schema}}
54
56
  @nodeViews={{this.nodeViews}}
55
- @rdfaEditorInit={{this.rdfaEditorInit}}/>
57
+ @rdfaEditorInit={{this.rdfaEditorInit}}
58
+ />
56
59
  </:default>
57
60
  <:aside>
58
61
  {...}
@@ -67,18 +70,22 @@ You will have 2 anchor points where to put your plugins: `top` for a toolbar, an
67
70
  Plugin which allows a user to insert different types of structures, like chapters, sections, articles etc.
68
71
 
69
72
  This plugin provides two widgets which can be added to the sidebar.
73
+
70
74
  ### The structure insertion widget
71
75
 
72
76
  This widget displays a series of buttons which allows the user to insert the configured widgets.
73
77
 
74
78
  You can add this widget to the sidebar using the following syntax:
79
+
75
80
  ```hbs
76
81
  <ArticleStructurePlugin::ArticleStructureCard
77
82
  @controller={{this.controller}}
78
83
  @options={{this.config.structures}}
79
84
  />
80
85
  ```
86
+
81
87
  The widgets accepts two properties:
88
+
82
89
  - `controller`: an instance of a `SayController` which the widgets uses two insert structures into a document
83
90
  - `options`: a list of structure configurations which are supported.
84
91
 
@@ -87,6 +94,7 @@ The widgets accepts two properties:
87
94
  This widget displays a context card in the sidebar when a structure is selected by the user. The card displays controls which allow users to move a structure around or remove it alltogether.
88
95
 
89
96
  You can add this widget to the sidebar using the following syntax:
97
+
90
98
  ```hbs
91
99
  <ArticleStructurePlugin::StructureCard
92
100
  @controller={{this.controller}}
@@ -97,6 +105,7 @@ You can add this widget to the sidebar using the following syntax:
97
105
  Just like the insertion widget, this widget also accepts the same two properties.
98
106
 
99
107
  ### Configuring the plugin
108
+
100
109
  Both widgets require an `options` property which allows you to configure which type of structures are supported, which is a list of `StructureSpec` objects.
101
110
 
102
111
  E.g. a regulatory statement document will typically have the following configuration of structures:
@@ -113,10 +122,11 @@ export const STRUCTURE_SPECS: ArticleStructurePluginOptions = [
113
122
  ```
114
123
 
115
124
  Each of these entries is a seperate `StructureSpec` object. The `StructureSpec` interface is defined as:
125
+
116
126
  ```js
117
127
  export type StructureSpec = {
118
128
  name: SpecName; // the name of the corresponding structure node-spec
119
- translations: { // the ember-intl translation keys which are to be used in the widgets
129
+ translations: { // the ember-intl translation keys which are to be used in the widgets
120
130
  insert: string;
121
131
  move?: {
122
132
  up?: string;
@@ -182,6 +192,7 @@ const STRUCTURE_NODES = {
182
192
  ```
183
193
 
184
194
  You can import these using:
195
+
185
196
  ```js
186
197
  import {
187
198
  STRUCTURE_NODES,
@@ -189,20 +200,23 @@ import {
189
200
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/structures';
190
201
  ```
191
202
 
192
-
193
203
  Additional examples can be found in the two controllers (besluit-sample and regulatory-statement-sample) of the dummy-app contained in this repository.
194
204
 
195
-
196
205
  ## besluit-type-plugin
197
206
 
198
207
  Plugin which allows a user to change the type of a [besluit](https://data.vlaanderen.be/ns/besluit#Besluit).
199
208
 
200
209
  This plugin needs to be added to the toolbar as a dropdown with the following syntax:
210
+
201
211
  ```hbs
202
- <BesluitTypePlugin::ToolbarDropdown @controller={{this.controller}} @options={{this.config.besluitType}}/>
212
+ <BesluitTypePlugin::ToolbarDropdown
213
+ @controller={{this.controller}}
214
+ @options={{this.config.besluitType}}
215
+ />
203
216
  ```
204
217
 
205
218
  You need to specify the endpoint from which the plugin will fetch the types in the config object
219
+
206
220
  ```js
207
221
  {
208
222
  endpoint: 'https://centrale-vindplaats.lblod.info/sparql',
@@ -213,13 +227,13 @@ You need to specify the endpoint from which the plugin will fetch the types in t
213
227
 
214
228
  This plugin provides some warnings to the user if the validation for a besluit fails, it need to be used with the validation plugin as it exports some validation rules for it.
215
229
  In order to use it you will need to add its card to the sidebar like
230
+
216
231
  ```hbs
217
- <DecisionPlugin::DecisionPluginCard
218
- @controller={{this.controller}}
219
- />
232
+ <DecisionPlugin::DecisionPluginCard @controller={{this.controller}} />
220
233
  ```
221
234
 
222
235
  and then import the rule and add it to the config of your validation plugin like
236
+
223
237
  ```js
224
238
  import { atLeastOneArticleContainer } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/decision-plugin/utils/validation-rules';
225
239
  ...
@@ -229,6 +243,7 @@ import { atLeastOneArticleContainer } from '@lblod/ember-rdfa-editor-lblod-plugi
229
243
  ]
230
244
  })
231
245
  ```
246
+
232
247
  With these changes you will see a warning if the decision is missing a title, a motivation block or an article block.
233
248
 
234
249
  ## citaten-plugin
@@ -236,34 +251,40 @@ With these changes you will see a warning if the decision is missing a title, a
236
251
  Plugin which allows a user to insert references to a legal resource or legal expression into the document.
237
252
 
238
253
  This plugin provides a card that shows up when using certain keywords. This needs to be added to the sidebar of the editor like
254
+
239
255
  ```hbs
240
- <CitationPlugin::CitationCard
241
- @controller={{this.controller}}
242
- @plugin={{this.citationPlugin}}
243
- @config={{this.config.citation}}
244
- />
256
+ <CitationPlugin::CitationCard
257
+ @controller={{this.controller}}
258
+ @plugin={{this.citationPlugin}}
259
+ @config={{this.config.citation}}
260
+ />
245
261
  ```
246
262
 
247
263
  Same goes for the `CitationInsert` component, with which you can directly insert a citation
264
+
248
265
  ```hbs
249
- <CitationPlugin::CitationInsert
250
- @controller={{this.controller}}
251
- @config={{this.config.citation}}
252
- />
266
+ <CitationPlugin::CitationInsert
267
+ @controller={{this.controller}}
268
+ @config={{this.config.citation}}
269
+ />
253
270
  ```
254
271
 
255
272
  You need to specify the endpoints for the plugin in the config object
273
+
256
274
  ```js
257
- {
258
- endpoint: 'https://codex.opendata.api.vlaanderen.be:8888/sparql'
259
- decisionsEndpoint: 'https://https://publicatie.gelinkt-notuleren.vlaanderen.be/sparql'
260
- }
275
+ const citationPluginConfig = {
276
+ endpoint: 'https://codex.opendata.api.vlaanderen.be:8888/sparql',
277
+ decisionsEndpoint:
278
+ 'https://publicatie.gelinkt-notuleren.vlaanderen.be/sparql',
279
+ defaultDecisionsGovernmentName: 'Edegem',
280
+ };
261
281
  ```
262
282
 
263
- The `decisionsEndpoint` is optional, and is required if you want to display decisions from the Publicatie.
264
-
283
+ The `decisionsEndpoint` is optional, and is required if you want to display decisions from the Publicatie.
284
+ The `defaultDecisionsGovernmentName` is also optional, and is used to filter the decisions from the Publicatie by government name, the government name for the filter can be changed by the user during the search.
265
285
 
266
286
  Make `this.citationPlugin` a tracked reference to the plugin created with the function exported from the package and the wished configuration
287
+
267
288
  ```js
268
289
  import { citationPlugin } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
269
290
 
@@ -276,55 +297,56 @@ Make `this.citationPlugin` a tracked reference to the plugin created with the fu
276
297
  ```
277
298
 
278
299
  Configuration:
279
- - type: it can be 'nodes' or 'ranges' if nodes is selected you are expected to pass the `activeInNodeTypes` function, otherwise you should pass the `activeInRanges` function
280
- - activeInNodeTypes: it's a function that gets the prosemirror schema and the state of the actual instance of the editor and returns a `Set` of nodetypes where the plugin should be active
281
- - activeInRanges: it's a function that gets the state of the actual instance of the editor and returns an array of ranges for the plugin to be active in, for example `[[0,50], [70,100]]`
282
- - regex: you can provide your custom regex to detect citations, if not the default one will be used
283
300
 
301
+ - type: it can be 'nodes' or 'ranges' if nodes is selected you are expected to pass the `activeInNodeTypes` function, otherwise you should pass the `activeInRanges` function
302
+ - activeInNodeTypes: it's a function that gets the prosemirror schema and the state of the actual instance of the editor and returns a `Set` of nodetypes where the plugin should be active
303
+ - activeInRanges: it's a function that gets the state of the actual instance of the editor and returns an array of ranges for the plugin to be active in, for example `[[0,50], [70,100]]`
304
+ - regex: you can provide your custom regex to detect citations, if not the default one will be used
284
305
 
285
306
  A common usecase is to have the plugin active in the entire document. Here's how to do that using each configuration type:
286
307
 
287
308
  ```js
288
- import { citationPlugin } from "@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin";
309
+ import { citationPlugin } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
289
310
 
290
311
  const configA = {
291
- type: "nodes",
292
- activeInNodeTypes(schema) {
293
- // the root node of the document should always have the doc type
294
- return new Set([schema.nodes.doc]);
295
- }
296
- };
297
-
312
+ type: 'nodes',
313
+ activeInNodeTypes(schema) {
314
+ // the root node of the document should always have the doc type
315
+ return new Set([schema.nodes.doc]);
316
+ },
317
+ };
318
+
298
319
  const configB = {
299
- type: "ranges",
320
+ type: 'ranges',
300
321
  activeInRanges(state) {
301
322
  // a node's nodeSize follows the Prosemirror definition
302
323
  // a non-leaf node's size is the sum of its children's sizes + 2
303
324
  // so to get the last valid position "inside" a node, you need to subtract two from its nodeSize
304
- // ref: https://prosemirror.net/docs/ref/#model.Node.nodeSize
325
+ // ref: https://prosemirror.net/docs/ref/#model.Node.nodeSize
305
326
  return [[0, state.doc.nodeSize - 2]];
306
- }
327
+ },
307
328
  };
308
329
  ```
330
+
309
331
  ### Using the plugin
310
332
 
311
333
  If used with the example configuration provided this plugin can be triggered by typing one of the following in the correct RDFa context (
312
334
  the [besluit:motivering](http://data.vlaanderen.be/ns/besluit#motivering) of
313
335
  a [besluit:Besluit](https://data.vlaanderen.be/ns/besluit#Besluit)).These will make `CitationCard` visible with the typed search terms.
314
336
 
315
- * [specification]**decreet** [words to search for] *(e.g. "gemeentedecreet wijziging")*
316
- * **omzendbrief** [words to search for]
317
- * **verdrag** [words to search for]
318
- * **grondwetswijziging** [words to search for]
319
- * **samenwerkingsakkoord** [words to search for]
320
- * [specification]**wetboek** [words to search for]
321
- * **protocol** [words to search for]
322
- * **besluit van de vlaamse regering** [words to search for]
323
- * **gecoordineerde wetten** [words to search for]
324
- * [specification]**wet** [words to search for] *(e.g. "kieswet wijziging", or "grondwet")*
325
- * **koninklijk besluit** [words to search for]
326
- * **ministerieel besluit** [words to search for]
327
- * **genummerd besluit** [words to search for]
337
+ - [specification]**decreet** [words to search for] _(e.g. "gemeentedecreet wijziging")_
338
+ - **omzendbrief** [words to search for]
339
+ - **verdrag** [words to search for]
340
+ - **grondwetswijziging** [words to search for]
341
+ - **samenwerkingsakkoord** [words to search for]
342
+ - [specification]**wetboek** [words to search for]
343
+ - **protocol** [words to search for]
344
+ - **besluit van de vlaamse regering** [words to search for]
345
+ - **gecoordineerde wetten** [words to search for]
346
+ - [specification]**wet** [words to search for] _(e.g. "kieswet wijziging", or "grondwet")_
347
+ - **koninklijk besluit** [words to search for]
348
+ - **ministerieel besluit** [words to search for]
349
+ - **genummerd besluit** [words to search for]
328
350
 
329
351
  You can also add a reference manually by clicking on the `Insert` > `Insert reference` item in the Insert menu located on the top right of the editor (this is the `CitationInsert` component). This will open the advanced search window. **Note** that this will only be
330
352
  avaliable in the proper context (see above in this section).
@@ -334,8 +356,9 @@ avaliable in the proper context (see above in this section).
334
356
  Plugin allowing importing of external RDFA snippets and inserting it in the document.
335
357
 
336
358
  The plugin has a card that needs to be added to the sidebar:
359
+
337
360
  ```hbs
338
- <ImportSnippetPlugin::Card @controller={{this.controller}}/>
361
+ <ImportSnippetPlugin::Card @controller={{this.controller}} />
339
362
  ```
340
363
 
341
364
  ### Using the plugin
@@ -346,11 +369,10 @@ manner:
346
369
  ```js
347
370
  import { inject as service } from '@ember/service';
348
371
 
349
-
350
372
  // An entry point to download the resouce (e.g a route) in your host app.
351
373
  // (...)
352
374
 
353
- let downloadData = { source: 'http://remote/resource.html' }
375
+ let downloadData = { source: 'http://remote/resource.html' };
354
376
  await this.importRdfaSnippet.downloadSnippet(downloadData);
355
377
  ```
356
378
 
@@ -360,36 +382,6 @@ application (https://github.com/lblod/frontend-gelinkt-notuleren).
360
382
  When opening a new document, users will get the option to either include the snippet data in the document or as an
361
383
  attachment.
362
384
 
363
- ## rdfa-date-plugin
364
-
365
- Plugin to insert and modify semantic dates and timestamps in an editor document.
366
-
367
- This plugin provides a card to modify dates that needs to be added to the editor sidebar like
368
-
369
- ```hbs
370
- <RdfaDatePlugin::Card
371
- @controller={{this.controller}}
372
- @options={{this.config.date}}/>
373
- ```
374
-
375
- And an insert button to insert new dates that needs to be added to the insert part of the sidebar:
376
- ```hbs
377
- <RdfaDatePlugin::Insert
378
- @controller={{this.controller}}
379
- @options={{this.config.date}}
380
- />
381
- ```
382
-
383
- You will also need to add the date node with the following configuration (being the insertDate and insertDateTime the placeholder strings):
384
- ```js
385
- date: date({
386
- placeholder: {
387
- insertDate: this.intl.t('date-plugin.insert.date'),
388
- insertDateTime: this.intl.t('date-plugin.insert.datetime'),
389
- },
390
- }),
391
- ```
392
-
393
385
  ## roadsign-regulation-plugin
394
386
 
395
387
  A plugin that fetches data from the mow regulation and roadsign registry and allows users to insert roadsign regulations
@@ -398,20 +390,22 @@ inside an editor document.
398
390
  This plugin provides a card that needs to be added to the editor sidebar like:
399
391
 
400
392
  ```hbs
401
- <RoadsignRegulationPlugin::RoadsignRegulationCard
402
- @controller={{this.controller}}
403
- @options={{this.config.roadsignRegulation}}
404
- />
393
+ <RoadsignRegulationPlugin::RoadsignRegulationCard
394
+ @controller={{this.controller}}
395
+ @options={{this.config.roadsignRegulation}}
396
+ />
405
397
  ```
406
398
 
407
399
  You will need to set the following configuration in the config object
400
+
408
401
  ```js
409
402
  {
410
403
  endpoint: 'https://dev.roadsigns.lblod.info/sparql',
411
404
  imageBaseUrl: 'https://register.mobiliteit.vlaanderen.be/',
412
405
  }
413
406
  ```
414
- 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.
407
+
408
+ 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. This won't be used if your data is correctly constructed.
415
409
 
416
410
  ## standard-template-plugin
417
411
 
@@ -420,19 +414,20 @@ selected text, a dropdown will appear in the toolbar of the editor that lets you
420
414
  context at the location of the cursor.
421
415
 
422
416
  In order to use this plugin you will need to add its card:
417
+
423
418
  ```hbs
424
- <StandardTemplatePlugin::Card @controller={{this.controller}}/>
419
+ <StandardTemplatePlugin::Card @controller={{this.controller}} />
425
420
  ```
426
421
 
427
422
  ### Template resource used by the plugin
428
423
 
429
424
  When creating a template in your database, the following properties are used by the plugin:
430
425
 
431
- * the title of the template (`title`)
432
- * its HTML content (`content`)
433
- * the words of the document the template should match on (`matches`)
434
- * the contexts in which it should be active (`contexts`)
435
- * the contexts in which it should not be active (`disabled-in-contexts`)
426
+ - the title of the template (`title`)
427
+ - its HTML content (`content`)
428
+ - the words of the document the template should match on (`matches`)
429
+ - the contexts in which it should be active (`contexts`)
430
+ - the contexts in which it should not be active (`disabled-in-contexts`)
436
431
 
437
432
  ### Using the plugin
438
433
 
@@ -446,14 +441,25 @@ menu. This attribute can be set on an element in the content of the editor or pr
446
441
 
447
442
  Plugin implementing an auto-refreshing table of contents using an ember-rdfa-editor inline component.
448
443
 
449
- In order to enable the plugin you need to add the table of contents button to the toolbar and the table of contents node view to the list of editor node views.
444
+ In order to enable the plugin you need to add the table of contents button to the toolbar and the table of contents node view to the list of editor node views.
445
+
450
446
  ```hbs
451
- <TableOfContentsPlugin::ToolbarButton @controller={{this.editor}}/>
447
+ <TableOfContentsPlugin::ToolbarButton @controller={{this.editor}} />
452
448
  ```
453
449
 
454
450
  ```js
455
451
  tableOfContentsView(this.config.tableOfContents)(controller),
456
452
  ```
453
+
454
+ You also need to allow this node as content by adding it to the doc node of the schema. It is _not_ part of the block group.
455
+
456
+ ```js
457
+ // example to allow the table of contents at the top and any blocks underneath
458
+ doc: docWithConfig({
459
+ content: 'table-of-contents? block+'
460
+ }),
461
+ ```
462
+
457
463
  ### Configuring the plugin with a custom config
458
464
 
459
465
  You can configure the nodeview with the hierarchy of the nodes.
@@ -470,10 +476,17 @@ For very custom setups, the plugin might be unable to find your scrollContainer
470
476
  },
471
477
  ```
472
478
 
479
+ `nodeHierarchy` is a list of _regex_ strings to specify the node structure of the document. Note that this means the order of the words does not matter. The example shows this for article structures.
480
+ The _first string_ selects the main nodes in the document that define the structure.
481
+ The strings afterwards are the sub-nodes inside main nodes that should be used to find the actual content to display in the table of contents, if the main node does not contain the content directly. In the example a title will have a `structure_header` that contains the actual text of the title.
482
+ In the case that `structure_header` contains a node `actual_title_text` that should be used as content, you'd have to add a third regex string that matches `actual_title_text`.
483
+
473
484
  ### Internationalization of the table of contents
485
+
474
486
  The dynamic version of the table of contents is internationalized based on the current document language and using the `ember-intl` service.
475
- The static (serialized) version of the table of contents can also be internationalized based on the current document language. For this to work correctly, the `emberApplication` prosemirror-plugin should be present.
487
+ The static (serialized) version of the table of contents can also be internationalized based on the current document language. For this to work correctly, the `emberApplication` prosemirror-plugin should be present.
476
488
  You can add this plugin as follows to the controller/component in which the editor is initialized:
489
+
477
490
  ```js
478
491
  import { getOwner } from '@ember/application';
479
492
  import { emberApplication } from '@lblod/ember-rdfa-editor/plugins/ember-application';
@@ -485,14 +498,15 @@ plugins = [
485
498
  ];
486
499
  ...
487
500
  ```
501
+
488
502
  As an example, the `emberApplication` plugin has been added to the regulatory-statement route of the dummy app included in this addon.
489
503
 
490
504
  The table of contents node needs this plugin to be able to translate the serialized version properly. If the plugin is not present, a default (dutch) version of the table of contents will be generated.
491
505
 
492
-
493
506
  ## variable-plugin
494
507
 
495
508
  Editor plugin which provides node-specs and components which allow you to insert and edit different types of variables in a document. The plugin provides the following variable types:
509
+
496
510
  - text variable
497
511
  - number variable
498
512
  - date variable
@@ -503,6 +517,7 @@ Editor plugin which provides node-specs and components which allow you to insert
503
517
  Additional variable types can be added in the consuming application or addon.
504
518
 
505
519
  For each of these variable types, a node-spec and node-view are defined. You can import them like this:
520
+
506
521
  ```js
507
522
  import {
508
523
  codelist,
@@ -514,55 +529,65 @@ import {
514
529
  text_variable,
515
530
  textVariableView,
516
531
  address,
517
- addressView
532
+ addressView,
533
+ date,
534
+ dateView,
518
535
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/variables';
519
536
  ```
520
537
 
521
- The date-variable node-spec and node-view are defined in the `rdfa-date-plugin`.
522
-
523
538
  For each of the variable-types you want to include in your editor instance, you should add the corresponding node-spec to your schema and the node-view to the `nodeViews` editor argument.
524
539
 
540
+ Both the `date` node-spec and `dateView` nodeview are functions which expect a `DateOptions` object, more information on how to define such a `DateOptions` object can be found in the section on the [date-edit component](#the-date-variable)
541
+
525
542
  ### Inserting variables into a document
526
543
 
527
544
  This addon includes an insert-component for each of these variable types:
545
+
528
546
  - `variable-plugin/text/insert`
529
547
  - `variable-plugin/number/insert`
530
548
  - `variable-plugin/date/insert`
531
549
  - `variable-plugin/location/insert`
532
550
  - `variable-plugin/codelist/insert`
533
- - `variable-plugin/address/insert`
551
+ - `variable-plugin/address/insert-variable`
534
552
 
535
553
  Each of these components presents a custom UI which allows a user to insert a variable of the corresponding type in a document.
536
554
 
537
555
  These insert-components can be used on their own, but can also be used in combination with the `variable-plugin/insert-variable-card` component. The responsibility of this component is two-fold:
556
+
538
557
  - It allows a user to select a variable type.
539
558
  - The correct insert component corresponding to the user-selected variable type is shown.
540
559
 
541
560
  The `variable-plugin/insert-variable-card` can be easily configured: it expects two arguments:
561
+
542
562
  - `controller`: An instance of the `SayController` class
543
563
  - `variableTypes`: A list of `VariableConfig` objects. With each `VariableConfig` containing:
544
564
  - the `label` which should be displayed in the variable-select dropdown
545
- - the `path` to the insert-variable component
565
+ - the `path` to the insert-variable component
546
566
  - _optionally_ an `options` argument object which should be passed to the insert-variable component.
547
- * The `VariableConfig` type is defined as follows:
548
- ```js
549
- type VariableConfig = {
550
- label: string;
551
- component: {
552
- path: string;
553
- options?: unknown;
554
- };
555
- };
556
- ```
567
+
568
+ * The `VariableConfig` type is defined as follows:
569
+
570
+ ```js
571
+ type VariableConfig = {
572
+ label: string;
573
+ component: {
574
+ path: string;
575
+ options?: unknown;
576
+ };
577
+ };
578
+ ```
557
579
 
558
580
  #### An example
581
+
559
582
  To allows users to insert variables into a document, add the following to the editor sidebar in your template:
583
+
560
584
  ```hbs
561
585
  <VariablePlugin::InsertVariableCard
562
586
  @controller={{this.controller}}
563
587
  @variableTypes={{this.variableTypes}}
564
588
  />
565
589
  ```
590
+
566
591
  `this.controller` is an instance of `SayController` and `this.variableTypes` is the list of `VariableConfig` objects which should be defined in your controller/component class:
567
592
 
568
593
  ```js
@@ -604,6 +629,12 @@ get variableTypes() {
604
629
  },
605
630
  },
606
631
  },
632
+ {
633
+ label: 'address',
634
+ component: {
635
+ path: 'variable-plugin/address/insert-variable',
636
+ },
637
+ },
607
638
  ];
608
639
  }
609
640
  ```
@@ -612,27 +643,76 @@ As you can see, both the `location` and `codelist` insert-components require an
612
643
  Aside from the endpoint, the `codelist` insert-component may optionally expect a publisher argument which it will use to limit the codelist fetch to a specific publisher.
613
644
 
614
645
  ### Editing variables in a document
646
+
615
647
  Each of the variables provided by this addon have a different editing experiences and use different components:
616
648
 
617
649
  #### The text variable
650
+
618
651
  Editing a text variable requires no extra components aside from its node-spec and node-view. A user can just type into the text variable directly.
619
652
 
620
653
  #### The number variable
654
+
621
655
  Editing a number variable can be done in its nodeview directly. When a user clicks on a number variable in a document, it opens a popup allow you to fill in a number.
622
656
 
623
657
  #### The date variable
624
- The edit component for the date variable can be found in the [rdfa-date-plugin section](#rdfa-date-plugin)
658
+
659
+ This addon provides a seperate edit component which allows users to fill in date variables in a document.
660
+ This component can be added to the sidebar of an editor instance in a template as follows:
661
+
662
+ ```hbs
663
+ <RdfaDatePlugin::Card
664
+ @controller={{this.controller}}
665
+ @options={{this.dateOptions}}
666
+ />
667
+ ```
668
+
669
+ Where `this.dateOptions` is a `DateOptions` object used to configure the edit component. It can be defined as e.g.:
670
+
671
+ ```js
672
+ get dateOptions(){
673
+ return {
674
+ formats: [
675
+ {
676
+ label: 'Short Date',
677
+ key: 'short',
678
+ dateFormat: 'dd/MM/yy',
679
+ dateTimeFormat: 'dd/MM/yy HH:mm',
680
+ },
681
+ {
682
+ label: 'Long Date',
683
+ key: 'long',
684
+ dateFormat: 'EEEE dd MMMM yyyy',
685
+ dateTimeFormat: 'PPPPp',
686
+ },
687
+ ],
688
+ allowCustomFormat: true,
689
+ }
690
+ }
691
+ ```
692
+
693
+ - `formats`: specify default formats to show for selection in the date card.
694
+ - `label` (optional): The label shown to the user on the card. If not provided, the format is used instead e.g.: `dd/MM/yyyy`
695
+ - `key`: A **unique** identifier used for identification in the internal code.
696
+ - `dateFormat`: The date format used when this is selected.
697
+ - `dateTimeFormat`: The datetime format to use when this is selected. Used when the user selects "Include time".
698
+ - `allowCustomFormat`: true/false, determines if the option to insert a fully custom format is available.
699
+
700
+ The syntax of formats can be found at [date-fns](https://date-fns.org/v2.29.3/docs/format).
625
701
 
626
702
  #### The location variable
703
+
627
704
  This addon provides a seperate edit component which allows users to fill in location variables in a document.
628
705
  This component can be added to the sidebar of an editor instance in a template as follows:
706
+
629
707
  ```hbs
630
- <VariablePlugin::Location::Edit
631
- @controller={{this.controller}}
708
+ <VariablePlugin::Location::Edit
709
+ @controller={{this.controller}}
632
710
  @options={{this.locationEditOptions}}
633
711
  />
634
712
  ```
713
+
635
714
  Where `this.locationEditOptions` is a `LocationEditOptions` object used to configure the edit component. It can be defined as e.g.:
715
+
636
716
  ```js
637
717
  get locationEditOptions() {
638
718
  return {
@@ -646,15 +726,19 @@ get locationEditOptions() {
646
726
  ```
647
727
 
648
728
  #### The codelist variable
729
+
649
730
  This addon provides a seperate edit component which allows users to fill in codelist variables in a document.
650
731
  This component can be added to the sidebar of an editor instance in a template as follows:
732
+
651
733
  ```hbs
652
- <VariablePlugin::Codelist::Edit
653
- @controller={{this.controller}}
734
+ <VariablePlugin::Codelist::Edit
735
+ @controller={{this.controller}}
654
736
  @options={{this.codelistEditOptions}}
655
737
  />
656
738
  ```
739
+
657
740
  Where `this.codelistEditOptions` is a `CodelistEditOptions` object used to configure the edit component. It can be defined as e.g.:
741
+
658
742
  ```js
659
743
  get codelistEditOptions() {
660
744
  return {
@@ -664,33 +748,49 @@ get codelistEditOptions() {
664
748
  ```
665
749
 
666
750
  #### The address variable
751
+
667
752
  This addon provides a seperate edit component which allows users to search for an address and update the select address variable. Additionally, they can also choose whether to include the housenumber of an address.
668
753
  You can add this edit-component to a template as follows:
754
+
669
755
  ```hbs
670
- <VariablePlugin::Address::Edit @controller={{this.controller}} @defaultMuncipality='Antwerpen'/>
756
+ <VariablePlugin::Address::Edit
757
+ @controller={{this.controller}}
758
+ @defaultMuncipality='Antwerpen'
759
+ />
671
760
  ```
672
761
 
673
762
  The edit card can be configured with two arguments:
763
+
674
764
  - An instance of a `SayController` (required)
675
765
  - A `defaultMuncipality` which should be used as the default value of the `muncipality` field in the edit-card (optional)
676
766
 
767
+ You can also add an insert component meant for use outside of `insert-variable-card` by using the `variable-plugin/address/insert` component. This has no label-input and will show a default label.
768
+
769
+ ```hbs
770
+ <VariablePlugin::Address::Insert @controller={{this.controller}} />
771
+ ```
772
+
677
773
  ## validation-plugin
678
774
 
679
775
  see [the plugin docs](addon/plugins/validation/README.md)
680
776
 
681
777
  ## template-comments-plugin
778
+
682
779
  A plugin to insert a template comment anywhere in the document.
683
780
  This is meant as a block of text for extra information to provide to a created template. It has
684
781
  the attribute `ext:TemplateComment`. This can (and should) be filtered out when publishing the document, as it is only meant as extra information while filling in a template.
685
782
  It supports basic text with indenting, list items and marks.
686
783
 
687
784
  Add it to editor by adding `templateComment` to your schema and
785
+
688
786
  ```js
689
787
  templateComment: templateCommentView(controller),
690
788
  ```
789
+
691
790
  as a nodeview.
692
791
 
693
792
  Import with:
793
+
694
794
  ```js
695
795
  import {
696
796
  templateComment,
@@ -698,26 +798,30 @@ import {
698
798
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/template-comments-plugin';
699
799
  ```
700
800
 
701
-
702
801
  Button to insert a template comment is added with
802
+
703
803
  ```hbs
704
- <TemplateCommentsPlugin::Insert @controller={{this.controller}}/>
804
+ <TemplateCommentsPlugin::Insert @controller={{this.controller}} />
705
805
  ```
706
806
 
707
807
  Buttons to remove and move it when selected can be shown with
808
+
708
809
  ```hbs
709
- <TemplateCommentsPlugin::EditCard @controller={{this.controller}}/>
810
+ <TemplateCommentsPlugin::EditCard @controller={{this.controller}} />
710
811
  ```
711
812
 
712
813
  Template comments have a specific style that can be imported in the stylesheet with
814
+
713
815
  ```css
714
816
  @import 'template-comments-plugin';
715
817
  ```
818
+
716
819
  ## Contributing
717
820
 
718
821
  See the [Contributing](CONTRIBUTING.md) guide for details.
719
822
 
720
823
  ## Releasing
824
+
721
825
  See the [Release](RELEASE.md) guide.
722
826
 
723
827
  ## License