@lblod/ember-rdfa-editor-lblod-plugins 8.4.1 → 9.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 (100) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/README.md +132 -0
  3. package/addon/components/address-plugin/insert.ts +2 -2
  4. package/addon/components/address-plugin/utils.ts +2 -2
  5. package/addon/components/article-structure-plugin/structure-card.ts +11 -11
  6. package/addon/components/besluit-type-plugin/besluit-type-select.ts +2 -2
  7. package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +8 -8
  8. package/addon/components/citation-plugin/citation-card.ts +6 -6
  9. package/addon/components/citation-plugin/citation-insert.ts +7 -7
  10. package/addon/components/citation-plugin/citations/search-modal.ts +4 -4
  11. package/addon/components/document-title-plugin/insert-title-card.ts +4 -4
  12. package/addon/components/generic-rdfa-variable/insert-menu.ts +2 -2
  13. package/addon/components/hover-tooltip.ts +1 -1
  14. package/addon/components/import-snippet-plugin/card.ts +9 -9
  15. package/addon/components/rdfa-date-plugin/card.ts +6 -6
  16. package/addon/components/rdfa-date-plugin/date-time-picker.ts +2 -2
  17. package/addon/components/rdfa-date-plugin/date.ts +2 -2
  18. package/addon/components/rdfa-date-plugin/insert.ts +2 -2
  19. package/addon/components/roadsign-regulation-plugin/expanded-measure.ts +3 -3
  20. package/addon/components/roadsign-regulation-plugin/measure-template.ts +2 -2
  21. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +1 -1
  22. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +9 -9
  23. package/addon/components/snippet-plugin/search-modal.ts +1 -1
  24. package/addon/components/snippet-plugin/snippet-insert.ts +2 -2
  25. package/addon/components/standard-template-plugin/template-provider.ts +7 -7
  26. package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +3 -3
  27. package/addon/components/table-of-contents-plugin/toolbar-button.ts +5 -5
  28. package/addon/components/variable-number/number.ts +24 -25
  29. package/addon/components/variable-plugin/insert-variable-card.hbs +2 -0
  30. package/addon/components/variable-plugin/insert-variable-card.ts +53 -11
  31. package/addon/components/variable-plugin/number-settings.hbs +5 -0
  32. package/addon/components/variable-plugin/template-variable-card.ts +8 -8
  33. package/addon/helpers/pagination.ts +1 -1
  34. package/addon/models/instruction.ts +2 -2
  35. package/addon/models/measure.ts +2 -2
  36. package/addon/models/sign.ts +2 -2
  37. package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +4 -4
  38. package/addon/plugins/article-structure-plugin/commands/move-selected-structure.ts +5 -5
  39. package/addon/plugins/article-structure-plugin/commands/recalculate-structure-numbers.ts +1 -1
  40. package/addon/plugins/article-structure-plugin/commands/remove-structure.ts +1 -1
  41. package/addon/plugins/article-structure-plugin/commands/unwrap-structure.ts +1 -1
  42. package/addon/plugins/article-structure-plugin/commands/wrap-structure-content.ts +5 -5
  43. package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +2 -2
  44. package/addon/plugins/article-structure-plugin/structures/article.ts +4 -4
  45. package/addon/plugins/article-structure-plugin/structures/chapter.ts +4 -4
  46. package/addon/plugins/article-structure-plugin/structures/section.ts +4 -4
  47. package/addon/plugins/article-structure-plugin/structures/subsection.ts +4 -4
  48. package/addon/plugins/article-structure-plugin/structures/title.ts +4 -4
  49. package/addon/plugins/article-structure-plugin/utils/structure.ts +1 -1
  50. package/addon/plugins/besluit-type-plugin/utils/fetchBesluitTypes.ts +1 -1
  51. package/addon/plugins/citation-plugin/index.ts +17 -17
  52. package/addon/plugins/citation-plugin/utils/cited-text.ts +2 -2
  53. package/addon/plugins/citation-plugin/utils/legislation-types.ts +1 -1
  54. package/addon/plugins/citation-plugin/utils/process-match.ts +3 -3
  55. package/addon/plugins/citation-plugin/utils/vlaamse-codex.ts +14 -14
  56. package/addon/plugins/decision-plugin/commands/insert-article-container.ts +2 -2
  57. package/addon/plugins/decision-plugin/commands/insert-description.ts +3 -3
  58. package/addon/plugins/decision-plugin/commands/insert-motivation.ts +9 -9
  59. package/addon/plugins/decision-plugin/commands/insert-title.ts +3 -3
  60. package/addon/plugins/decision-plugin/utils/get-title-for-decision.ts +1 -1
  61. package/addon/plugins/document-title-plugin/commands/insert-document-title.ts +3 -3
  62. package/addon/plugins/rdfa-date-plugin/nodes/date.ts +2 -2
  63. package/addon/plugins/rdfa-date-plugin/utils.ts +1 -1
  64. package/addon/plugins/roadsign-regulation-plugin/nodes.ts +4 -4
  65. package/addon/plugins/roadsign-regulation-plugin/utils/fetchData.ts +2 -2
  66. package/addon/plugins/roadsign-regulation-plugin/utils/includeInstructions.ts +2 -2
  67. package/addon/plugins/snippet-plugin/utils/fetch-data.ts +22 -14
  68. package/addon/plugins/standard-template-plugin/utils/instantiate-uuids.ts +2 -2
  69. package/addon/plugins/standard-template-plugin/utils/nodes.ts +5 -5
  70. package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +1 -1
  71. package/addon/plugins/table-of-contents-plugin/utils/index.ts +1 -1
  72. package/addon/plugins/validation/index.ts +13 -13
  73. package/addon/plugins/validation/utils/transaction-complies-with-shapes.ts +2 -2
  74. package/addon/plugins/variable-plugin/nodes.ts +7 -6
  75. package/addon/plugins/variable-plugin/utils/constants.ts +5 -5
  76. package/addon/plugins/variable-plugin/utils/fetch-data.ts +2 -2
  77. package/addon/plugins/variable-plugin/utils/number-to-words.ts +15 -0
  78. package/addon/services/import-rdfa-snippet.ts +3 -3
  79. package/addon/services/roadsign-registry.ts +15 -15
  80. package/addon/services/standard-template-plugin.ts +1 -1
  81. package/addon/utils/_private/find-insertion-range.ts +1 -1
  82. package/addon/utils/changed-descendants.ts +1 -1
  83. package/addon/utils/constants.ts +3 -3
  84. package/addon/utils/find-insertion-pos-in-ancestor-of-type.ts +2 -2
  85. package/addon/utils/namespace.ts +3 -3
  86. package/addon/utils/option.ts +2 -2
  87. package/addon/utils/sparql-helpers.ts +2 -2
  88. package/addon/utils/strings.ts +11 -1
  89. package/app/styles/variable-plugin.scss +14 -0
  90. package/components/variable-number/number.d.ts +1 -1
  91. package/components/variable-plugin/insert-variable-card.d.ts +14 -1
  92. package/package.json +8 -8
  93. package/plugins/variable-plugin/utils/number-to-words.d.ts +8 -0
  94. package/translations/en-US.yaml +3 -2
  95. package/translations/nl-BE.yaml +3 -2
  96. package/types/global.d.ts +2 -2
  97. package/types/lblod/marawa/rdfa-attributes.d.ts +1 -1
  98. package/types/lblod/marawa/rdfa-context-scanner.d.ts +1 -1
  99. package/types/lblod/marawa/rdfa-helpers.d.ts +3 -3
  100. package/utils/strings.d.ts +1 -0
@@ -32,7 +32,7 @@ export class Decision {
32
32
  }: DecisionArgs) {
33
33
  this.uri = uri;
34
34
  this.legislationType = LEGISLATION_TYPE_CONCEPTS.find(
35
- (t) => t.value === legislationTypeUri
35
+ (t) => t.value === legislationTypeUri,
36
36
  );
37
37
  this.title = title;
38
38
  this.publicationDate = publicationDate;
@@ -81,7 +81,7 @@ export class Article {
81
81
  function replaceDiacriticsInWord(word: string): string {
82
82
  const characters =
83
83
  'Ë À Ì Â Í Ã Î Ä Ï Ç Ò È Ó É Ô Ê Õ Ö ê Ù ë Ú î Û ï Ü ô Ý õ â û ã ÿ ç'.split(
84
- ' '
84
+ ' ',
85
85
  );
86
86
  for (const char of characters) {
87
87
  word = word.replace(new RegExp(`${char}`, 'g'), `&#${char.charCodeAt(0)};`);
@@ -201,12 +201,12 @@ async function fetchDecisionsMemo({
201
201
  const excludeAdaptationFilters = [];
202
202
  if (!words.includes('houdende')) {
203
203
  excludeAdaptationFilters.push(
204
- 'FILTER(! STRSTARTS(LCASE(?title),"houdende"))'
204
+ 'FILTER(! STRSTARTS(LCASE(?title),"houdende"))',
205
205
  );
206
206
  }
207
207
  if (!words.includes('wijziging')) {
208
208
  excludeAdaptationFilters.push(
209
- 'FILTER(! STRSTARTS(LCASE(?title),"tot wijziging"))'
209
+ 'FILTER(! STRSTARTS(LCASE(?title),"tot wijziging"))',
210
210
  );
211
211
  }
212
212
  const totalCount = await executeCountQuery({
@@ -222,8 +222,8 @@ async function fetchDecisionsMemo({
222
222
  .map(
223
223
  (word) =>
224
224
  `FILTER (CONTAINS(LCASE(?title), "${replaceDiacriticsInWord(
225
- word
226
- ).toLowerCase()}"))`
225
+ word,
226
+ ).toLowerCase()}"))`,
227
227
  )
228
228
  .join('\n')}
229
229
  ${excludeAdaptationFilters.join('\n')}
@@ -247,8 +247,8 @@ async function fetchDecisionsMemo({
247
247
  .map(
248
248
  (word) =>
249
249
  `FILTER (CONTAINS(LCASE(?title), "${replaceDiacriticsInWord(
250
- word
251
- ).toLowerCase()}"))`
250
+ word,
251
+ ).toLowerCase()}"))`,
252
252
  )
253
253
  .join('\n')}
254
254
  OPTIONAL { ?expressionUri eli:date_publication ?publicationDate . }
@@ -262,10 +262,10 @@ async function fetchDecisionsMemo({
262
262
  const decisions = response.results.bindings.map((binding) => {
263
263
  const escapedTitle = escapeValue(binding.title.value);
264
264
  const publicationDate = dateValue(
265
- binding.publicationDate && binding.publicationDate.value
265
+ binding.publicationDate && binding.publicationDate.value,
266
266
  );
267
267
  const documentDate = dateValue(
268
- binding.documentDate && binding.documentDate.value
268
+ binding.documentDate && binding.documentDate.value,
269
269
  );
270
270
  return new Decision({
271
271
  uri: binding.uri.value,
@@ -439,13 +439,13 @@ async function fetchArticlesMemo({
439
439
 
440
440
  const articles = response.results.bindings.map((binding) => {
441
441
  const escapedContent = escapeValue(
442
- binding.content && binding.content.value
442
+ binding.content && binding.content.value,
443
443
  );
444
444
  const dateInForce = dateValue(
445
- binding.dateInForce && binding.dateInForce.value
445
+ binding.dateInForce && binding.dateInForce.value,
446
446
  );
447
447
  const dateNoLongerInForce = dateValue(
448
- binding.dateNoLongerInForce && binding.dateNoLongerInForce.value
448
+ binding.dateNoLongerInForce && binding.dateNoLongerInForce.value,
449
449
  );
450
450
  return new Article({
451
451
  uri: binding.article.value,
@@ -512,7 +512,7 @@ async function executeQuery<A>({
512
512
  return response.json() as Promise<QueryResponse<A>>;
513
513
  } else {
514
514
  throw new Error(
515
- `Request to Vlaamse Codex was unsuccessful: [${response.status}] ${response.statusText}`
515
+ `Request to Vlaamse Codex was unsuccessful: [${response.status}] ${response.statusText}`,
516
516
  );
517
517
  }
518
518
  }
@@ -30,13 +30,13 @@ export default function insertArticleContainer({
30
30
  besluitArticleStructure.constructor({
31
31
  schema,
32
32
  intl,
33
- }).node
33
+ }).node,
34
34
  );
35
35
 
36
36
  const insertionPos = findInsertionPosInAncestorOfType(
37
37
  selection,
38
38
  schema.nodes.besluit,
39
- nodeToInsert
39
+ nodeToInsert,
40
40
  );
41
41
  if (isNone(insertionPos)) {
42
42
  return false;
@@ -27,13 +27,13 @@ export default function insertDescription({
27
27
  null,
28
28
  schema.node('placeholder', {
29
29
  placeholderText,
30
- })
31
- )
30
+ }),
31
+ ),
32
32
  );
33
33
  const insertionPos = findInsertionPosInAncestorOfType(
34
34
  selection,
35
35
  schema.nodes.besluit,
36
- nodeToInsert
36
+ nodeToInsert,
37
37
  );
38
38
  if (isNone(insertionPos)) {
39
39
  return false;
@@ -27,21 +27,21 @@ export default function insertMotivation({
27
27
  null,
28
28
  schema.node('placeholder', {
29
29
  placeholderText: intl.t('besluit-plugin.placeholder.government-body'),
30
- })
30
+ }),
31
31
  ),
32
32
  schema.node(
33
33
  'heading',
34
34
  {
35
35
  level: 5,
36
36
  },
37
- [schema.text(intl.t('besluit-plugin.text.authority'))]
37
+ [schema.text(intl.t('besluit-plugin.text.authority'))],
38
38
  ),
39
39
  schema.node('bullet_list', null, [
40
40
  schema.node('list_item', null, [
41
41
  schema.node('paragraph', null, [
42
42
  schema.node('placeholder', {
43
43
  placeholderText: intl.t(
44
- 'besluit-plugin.placeholder.legal-jurisdiction'
44
+ 'besluit-plugin.placeholder.legal-jurisdiction',
45
45
  ),
46
46
  }),
47
47
  ]),
@@ -52,14 +52,14 @@ export default function insertMotivation({
52
52
  {
53
53
  level: 5,
54
54
  },
55
- [schema.text(intl.t('besluit-plugin.text.legal-context'))]
55
+ [schema.text(intl.t('besluit-plugin.text.legal-context'))],
56
56
  ),
57
57
  schema.node('bullet_list', null, [
58
58
  schema.node('list_item', null, [
59
59
  schema.node('paragraph', null, [
60
60
  schema.node('placeholder', {
61
61
  placeholderText: intl.t(
62
- 'besluit-plugin.placeholder.insert-legal-context'
62
+ 'besluit-plugin.placeholder.insert-legal-context',
63
63
  ),
64
64
  }),
65
65
  ]),
@@ -70,14 +70,14 @@ export default function insertMotivation({
70
70
  {
71
71
  level: 5,
72
72
  },
73
- [schema.text(intl.t('besluit-plugin.text.factual-context'))]
73
+ [schema.text(intl.t('besluit-plugin.text.factual-context'))],
74
74
  ),
75
75
  schema.node('bullet_list', null, [
76
76
  schema.node('list_item', null, [
77
77
  schema.node('paragraph', null, [
78
78
  schema.node('placeholder', {
79
79
  placeholderText: intl.t(
80
- 'besluit-plugin.placeholder.insert-factual-context'
80
+ 'besluit-plugin.placeholder.insert-factual-context',
81
81
  ),
82
82
  }),
83
83
  ]),
@@ -90,7 +90,7 @@ export default function insertMotivation({
90
90
  const insertionPos = findInsertionPosInAncestorOfType(
91
91
  selection,
92
92
  schema.nodes.besluit,
93
- nodeToInsert
93
+ nodeToInsert,
94
94
  );
95
95
  if (isNone(insertionPos)) {
96
96
  return false;
@@ -106,7 +106,7 @@ export default function insertMotivation({
106
106
  // const targetPos = tr.doc.resolve(insertionPos + cursorOffset + 1);
107
107
  // TODO figure out why I cant just set a nodeSelection here
108
108
  tr.setSelection(
109
- new NodeSelection(tr.doc.resolve(selectionPos.posAtIndex(0)))
109
+ new NodeSelection(tr.doc.resolve(selectionPos.posAtIndex(0))),
110
110
  );
111
111
  dispatch(tr);
112
112
  }
@@ -27,14 +27,14 @@ export default function insertTitle({
27
27
  null,
28
28
  schema.node('placeholder', {
29
29
  placeholderText,
30
- })
31
- )
30
+ }),
31
+ ),
32
32
  );
33
33
 
34
34
  const insertionPos = findInsertionPosInAncestorOfType(
35
35
  selection,
36
36
  schema.nodes.besluit,
37
- nodeToInsert
37
+ nodeToInsert,
38
38
  );
39
39
  if (isNone(insertionPos)) {
40
40
  return false;
@@ -18,7 +18,7 @@ export function getTitleForDecision(decisionUri: string, datastore: SayStore) {
18
18
  */
19
19
  export function getTitleNodesForDecision(
20
20
  decisionUri: string,
21
- datastore: SayStore
21
+ datastore: SayStore,
22
22
  ) {
23
23
  const mapping = datastore
24
24
  .match(`>${decisionUri}`, '>http://data.europa.eu/eli/ontology#title')
@@ -33,9 +33,9 @@ export default function insertDocumentTitle({
33
33
  null,
34
34
  schema.node('placeholder', {
35
35
  placeholderText: placeholder,
36
- })
37
- )
38
- )
36
+ }),
37
+ ),
38
+ ),
39
39
  );
40
40
  dispatch(tr);
41
41
  }
@@ -127,10 +127,10 @@ const emberNodeConfig = (options: DateOptions): EmberNodeConfig => ({
127
127
  ?.getAttribute('datatype');
128
128
  if (variableType === 'date' && datatype) {
129
129
  const onlyDate = !![...node.children].find((el) =>
130
- hasRDFaAttribute(el, 'datatype', XSD('date'))
130
+ hasRDFaAttribute(el, 'datatype', XSD('date')),
131
131
  );
132
132
  const dateNode = [...node.children].find((el) =>
133
- hasRDFaAttribute(el, 'property', EXT('content'))
133
+ hasRDFaAttribute(el, 'property', EXT('content')),
134
134
  ) as HTMLElement | undefined;
135
135
  let humanReadableDate: string;
136
136
  const value = dateNode?.getAttribute('content');
@@ -67,7 +67,7 @@ export function validateDateFormat(format?: string): ValidationResult {
67
67
  return { type: 'error', error: 'use-dd' };
68
68
  } else {
69
69
  const match = INVALID_CHAR_REGEX.exec(
70
- msg
70
+ msg,
71
71
  ) as RegexpMatchArrayWithIndices | null;
72
72
  if (match) {
73
73
  const invalidCharacters = match.groups?.char;
@@ -65,7 +65,7 @@ export const roadsign_regulation: NodeSpec = {
65
65
  hasRDFaAttribute(
66
66
  node,
67
67
  'typeof',
68
- MOBILITEIT('Mobiliteitsmaatregel')
68
+ MOBILITEIT('Mobiliteitsmaatregel'),
69
69
  ) &&
70
70
  node.querySelector(CONTENT_SELECTOR)
71
71
  ) {
@@ -73,13 +73,13 @@ export const roadsign_regulation: NodeSpec = {
73
73
  const measureUri = node
74
74
  .querySelector(
75
75
  `span[property~='${PROV('wasDerivedFrom').prefixed}'],
76
- span[property~='${PROV('wasDerivedFrom').full}']`
76
+ span[property~='${PROV('wasDerivedFrom').full}']`,
77
77
  )
78
78
  ?.getAttribute('resource');
79
79
  const zonality = node
80
80
  .querySelector(
81
81
  `span[property~='${EXT('zonality').prefixed}'],
82
- span[property~='${EXT('zonality').full}']`
82
+ span[property~='${EXT('zonality').full}']`,
83
83
  )
84
84
  ?.getAttribute('resource');
85
85
  if (!resourceUri || !measureUri || !zonality) {
@@ -88,7 +88,7 @@ export const roadsign_regulation: NodeSpec = {
88
88
  const temporal = node
89
89
  .querySelector(
90
90
  `span[property~='${EXT('temporal').prefixed}'],
91
- span[property~='${EXT('temporal').full}']`
91
+ span[property~='${EXT('temporal').full}']`,
92
92
  )
93
93
  ?.getAttribute('value');
94
94
  return {
@@ -14,7 +14,7 @@ function buildFilters({
14
14
  const filters = [];
15
15
  if (zonality) {
16
16
  filters.push(
17
- `FILTER(?zonality IN (<${zonality}>, <${POTENTIALLY_ZONAL_URI}>))`
17
+ `FILTER(?zonality IN (<${zonality}>, <${POTENTIALLY_ZONAL_URI}>))`,
18
18
  );
19
19
  }
20
20
  if (type) {
@@ -26,7 +26,7 @@ function buildFilters({
26
26
  .map(
27
27
  (uri) => `
28
28
  ?uri ext:relation/ext:concept <${uri}>.
29
- `
29
+ `,
30
30
  )
31
31
  .join(' ')}
32
32
  `);
@@ -3,13 +3,13 @@ import Instruction from '@lblod/ember-rdfa-editor-lblod-plugins/models/instructi
3
3
  export default function includeInstructions(
4
4
  html: string,
5
5
  instructions: Instruction[],
6
- annotated: boolean
6
+ annotated: boolean,
7
7
  ) {
8
8
  let finalHtml = html;
9
9
  for (const instruction of instructions) {
10
10
  finalHtml = finalHtml.replaceAll(
11
11
  `\${${instruction.name ?? ''}}`,
12
- annotated ? instruction.annotatedTemplate : instruction.template
12
+ annotated ? instruction.annotatedTemplate : instruction.template,
13
13
  );
14
14
  }
15
15
  return finalHtml;
@@ -9,17 +9,21 @@ type Pagination = { pageNumber: number; pageSize: number };
9
9
 
10
10
  const buildCountQuery = ({ name }: Filter) => {
11
11
  return `
12
+ PREFIX schema: <http://schema.org/>
12
13
  PREFIX dct: <http://purl.org/dc/terms/>
13
14
  PREFIX pav: <http://purl.org/pav/>
15
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
14
16
  PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
15
17
 
16
- SELECT (COUNT(?snippetDocument) AS ?count)
18
+ SELECT (COUNT(?publishedSnippetVersion) AS ?count)
17
19
  WHERE {
18
- ?snippetList a ext:SnippetList ;
19
- ext:hasSnippet/pav:hasCurrentVersion ?snippetDocument .
20
- ?snippetDocument dct:title ?title ;
21
- ext:editorDocumentContent ?content ;
22
- pav:createdOn ?createdOn .
20
+ ?publishedSnippetContainer a ext:PublishedSnippetContainer ;
21
+ pav:hasCurrentVersion ?publishedSnippetVersion .
22
+ ?publishedSnippetVersion dct:title ?title ;
23
+ ext:editorDocumentContent ?content ;
24
+ pav:createdOn ?createdOn .
25
+ OPTIONAL { ?publishedSnippetVersion schema:validThrough ?validThrough. }
26
+ FILTER(!BOUND(?validThrough) || xsd:dateTime(?validThrough) > now())
23
27
  ${name ? `FILTER (CONTAINS(LCASE(?title), "${name}"))` : ''}
24
28
  }
25
29
  `;
@@ -33,22 +37,26 @@ const buildFetchQuery = ({
33
37
  pagination: Pagination;
34
38
  }) => {
35
39
  return `
40
+ PREFIX schema: <http://schema.org/>
36
41
  PREFIX dct: <http://purl.org/dc/terms/>
37
42
  PREFIX pav: <http://purl.org/pav/>
43
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
38
44
  PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
39
45
 
40
46
  SELECT DISTINCT ?title ?content ?createdOn
41
47
  WHERE {
42
- ?snippetList a ext:SnippetList ;
43
- ext:hasSnippet/pav:hasCurrentVersion ?snippetDocument .
44
- ?snippetDocument dct:title ?title ;
45
- ext:editorDocumentContent ?content ;
46
- pav:createdOn ?createdOn .
48
+ ?publishedSnippetContainer a ext:PublishedSnippetContainer ;
49
+ pav:hasCurrentVersion ?publishedSnippetVersion .
50
+ ?publishedSnippetVersion dct:title ?title ;
51
+ ext:editorDocumentContent ?content ;
52
+ pav:createdOn ?createdOn .
47
53
  ${name ? `FILTER (CONTAINS(LCASE(?title), "${name}"))` : ''}
54
+ OPTIONAL { ?publishedSnippetVersion schema:validThrough ?validThrough. }
55
+ FILTER(!BOUND(?validThrough) || xsd:dateTime(?validThrough) > now())
48
56
  }
49
57
  ORDER BY DESC(?createdOn) LIMIT ${pageSize} OFFSET ${
50
- pageNumber * pageSize
51
- }
58
+ pageNumber * pageSize
59
+ }
52
60
  `;
53
61
  };
54
62
 
@@ -89,7 +97,7 @@ export const fetchSnippets = async ({
89
97
  title: binding.title?.value,
90
98
  createdOn: binding.createdOn?.value,
91
99
  content: binding.content?.value,
92
- })
100
+ }),
93
101
  );
94
102
 
95
103
  return { totalCount, results };
@@ -33,7 +33,7 @@ export default function instantiateUuids(templateString: string) {
33
33
  /\$\{(generateUuid|generateBoundUuid)\(([^()]*)\)\}/g,
34
34
  (string) => {
35
35
  const match = /\$\{(generateUuid|generateBoundUuid)\(([^()]*)\)\}/.exec(
36
- string
36
+ string,
37
37
  );
38
38
  if (match) {
39
39
  const functionName = match[1];
@@ -43,6 +43,6 @@ export default function instantiateUuids(templateString: string) {
43
43
  } else {
44
44
  return string;
45
45
  }
46
- }
46
+ },
47
47
  );
48
48
  }
@@ -202,12 +202,12 @@ export const besluitArticleStructure: StructureSpec = {
202
202
  {},
203
203
  schema.node('placeholder', {
204
204
  placeholderText: intl?.t(
205
- 'article-structure-plugin.placeholder.article.body'
205
+ 'article-structure-plugin.placeholder.article.body',
206
206
  ),
207
- })
208
- )
207
+ }),
208
+ ),
209
209
  ),
210
- ]
210
+ ],
211
211
  );
212
212
  const selectionConfig: {
213
213
  relativePos: number;
@@ -261,7 +261,7 @@ export const besluit_article_header: NodeSpec = {
261
261
  getAttrs(element: HTMLElement) {
262
262
  const numberNode = element.querySelector(
263
263
  `span[property~='${ELI('number').prefixed}'],
264
- span[property~='${ELI('number').full}']`
264
+ span[property~='${ELI('number').full}']`,
265
265
  );
266
266
  if (numberNode) {
267
267
  return {
@@ -7,7 +7,7 @@ import { TableOfContentsConfig } from '..';
7
7
  import { createTableOfContents } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/table-of-contents-plugin/utils';
8
8
 
9
9
  export const emberNodeConfig: (
10
- config: TableOfContentsConfig
10
+ config: TableOfContentsConfig,
11
11
  ) => EmberNodeConfig = (config) => {
12
12
  return {
13
13
  name: 'table-of-contents',
@@ -88,7 +88,7 @@ export function extractOutline({
88
88
  const subResults: OutlineEntry[] = [];
89
89
  node.forEach((child, offset) => {
90
90
  subResults.push(
91
- ...extractOutline({ node: child, pos: pos + 1 + offset, config })
91
+ ...extractOutline({ node: child, pos: pos + 1 + offset, config }),
92
92
  );
93
93
  });
94
94
  if (parent) {
@@ -15,7 +15,7 @@ import {
15
15
 
16
16
  export function validateTransaction(
17
17
  state: EditorState,
18
- tr: Transaction
18
+ tr: Transaction,
19
19
  ): ValidationReport {
20
20
  const validationState = VALIDATION_KEY.getState(state);
21
21
  if (!validationState) {
@@ -30,7 +30,7 @@ export function validateTransaction(
30
30
  return { conforms: true };
31
31
  }
32
32
  const cachedValidation = tr.getMeta(
33
- 'validated'
33
+ 'validated',
34
34
  ) as Option<ValidationReport>;
35
35
  if (cachedValidation) {
36
36
  return cachedValidation;
@@ -83,7 +83,7 @@ export type ConstraintMap = {
83
83
 
84
84
  export type ConstraintValidator = (
85
85
  constraint: ValidationConstraint,
86
- shapeContext: ShapeContext
86
+ shapeContext: ShapeContext,
87
87
  ) => Option<ValidationResult>;
88
88
  export type ConstraintValidatorMap = {
89
89
  [C in ValidationConstraint as C['kind']]: ConstraintValidator;
@@ -125,7 +125,7 @@ const CONSTRAINT_VALIDATOR_MAP: ConstraintValidatorMap = {
125
125
  };
126
126
 
127
127
  export function validation(
128
- configurator: (schema: Schema) => ValidationPluginConfig
128
+ configurator: (schema: Schema) => ValidationPluginConfig,
129
129
  ): ValidationPlugin {
130
130
  const validation = new ProsePlugin<ValidationState>({
131
131
  key: VALIDATION_KEY,
@@ -152,7 +152,7 @@ export function validation(
152
152
  return oldPluginState;
153
153
  }
154
154
  const cachedValidation = tr.getMeta(
155
- 'validated'
155
+ 'validated',
156
156
  ) as Option<ValidationState>;
157
157
  const firstPass = tr.getMeta('firstPass') as Option<boolean>;
158
158
 
@@ -179,7 +179,7 @@ export function validation(
179
179
  */
180
180
  function compileSpec(
181
181
  configurator: (schema: Schema) => ValidationPluginConfig,
182
- schema: Schema
182
+ schema: Schema,
183
183
  ): ValidationSpec {
184
184
  const spec: ValidationSpec = {};
185
185
  const shapes = configurator(schema).shapes;
@@ -219,7 +219,7 @@ interface ValidationContext {
219
219
  */
220
220
  function doValidation(
221
221
  newState: EditorState,
222
- spec: ValidationSpec
222
+ spec: ValidationSpec,
223
223
  ): ValidationReport {
224
224
  const results: ValidationResult[] = [];
225
225
  const context: ValidationContext = {
@@ -252,7 +252,7 @@ function recValidate(
252
252
  context: ValidationContext,
253
253
  results: ValidationResult[],
254
254
  node: PNode,
255
- currentDepth: number
255
+ currentDepth: number,
256
256
  ) {
257
257
  // keep track of the global path we're on
258
258
  context.path.push(node);
@@ -341,13 +341,13 @@ function recValidate(
341
341
  // a "this should never be null" nullcheck
342
342
  const shapeContext = expect(
343
343
  'Shapecontext not initialized',
344
- context.shapeContext.get(shape)
344
+ context.shapeContext.get(shape),
345
345
  );
346
346
  // imagine if after all that it turns out the shape has no constraints...
347
347
  if (shape.constraints) {
348
348
  // with the shape's context nicely filled, we can now validate
349
349
  for (const constraint of Object.entries(shape.constraints).map(
350
- ([kind, value]) => ({ kind, value } as ValidationConstraint)
350
+ ([kind, value]) => ({ kind, value }) as ValidationConstraint,
351
351
  )) {
352
352
  const result = validateConstraint(constraint, shapeContext);
353
353
  if (result) {
@@ -366,14 +366,14 @@ function recValidate(
366
366
 
367
367
  function validateConstraint(
368
368
  constraint: ValidationConstraint,
369
- shapeContext: ShapeContext
369
+ shapeContext: ShapeContext,
370
370
  ): Option<ValidationResult> {
371
371
  return CONSTRAINT_VALIDATOR_MAP[constraint.kind](constraint, shapeContext);
372
372
  }
373
373
 
374
374
  function validateMinCount(
375
375
  constraint: MinCountConstraint,
376
- shapeContext: ShapeContext
376
+ shapeContext: ShapeContext,
377
377
  ): Option<ValidationResult> {
378
378
  const { shape, focusNode, count, path } = shapeContext;
379
379
  if (count < constraint.value) {
@@ -394,7 +394,7 @@ function validateMinCount(
394
394
 
395
395
  function validateMaxCount(
396
396
  constraint: MaxCountConstraint,
397
- shapeContext: ShapeContext
397
+ shapeContext: ShapeContext,
398
398
  ): Option<ValidationResult> {
399
399
  const { shape, focusNode, count, path } = shapeContext;
400
400
  if (count > constraint.value) {
@@ -12,13 +12,13 @@ import { validateTransaction } from '@lblod/ember-rdfa-editor-lblod-plugins/plug
12
12
  export function transactionCompliesWithShapes(
13
13
  state: EditorState,
14
14
  tr: Transaction,
15
- validateShapes?: Set<string>
15
+ validateShapes?: Set<string>,
16
16
  ) {
17
17
  if (validateShapes?.size) {
18
18
  const report = validateTransaction(state, tr);
19
19
  if (
20
20
  report.results?.some((result) =>
21
- validateShapes.has(result.sourceShape.name)
21
+ validateShapes.has(result.sourceShape.name),
22
22
  )
23
23
  ) {
24
24
  return false;
@@ -18,7 +18,8 @@ import {
18
18
  WRITTEN_NUMBER_PNODE_KEY,
19
19
  } from './utils/constants';
20
20
  import { Attrs, DOMOutputSpec, PNode } from '@lblod/ember-rdfa-editor';
21
- import n2words from 'n2words';
21
+ import { isNumber } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
22
+ import { numberToWords } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/number-to-words';
22
23
 
23
24
  export const CONTENT_SELECTOR = `span[property~='${EXT('content').prefixed}'],
24
25
  span[property~='${EXT('content').full}']`;
@@ -60,7 +61,7 @@ export const getPNodeExtraAttributes = ({
60
61
  [MAXIMUM_VALUE_HTML_ATTRIBUTE_KEY]:
61
62
  (node.attrs[MAXIMUM_VALUE_PNODE_KEY] as string) ?? null,
62
63
  [WRITTEN_NUMBER_HTML_ATTRIBUTE_KEY]: String(
63
- node.attrs[WRITTEN_NUMBER_PNODE_KEY] ?? false
64
+ node.attrs[WRITTEN_NUMBER_PNODE_KEY] ?? false,
64
65
  ),
65
66
  };
66
67
  }
@@ -78,9 +79,9 @@ export const contentToDom = ({
78
79
  node: PNode;
79
80
  }) => {
80
81
  if (type === 'number') {
81
- if (!Number.isNaN(Number(content)) && content !== null && content !== '') {
82
+ if (isNumber(content)) {
82
83
  if (node.attrs[WRITTEN_NUMBER_PNODE_KEY]) {
83
- return n2words(Number(content), { lang: 'nl' });
84
+ return numberToWords(Number(content), { lang: 'nl' });
84
85
  } else {
85
86
  return content;
86
87
  }
@@ -102,7 +103,7 @@ export const parseAttributes = (node: HTMLElement): false | Attrs => {
102
103
  ?.getAttribute('resource');
103
104
  const mappingResource = node.getAttribute('resource');
104
105
  const codelistSpan = [...node.children].find((el) =>
105
- hasRDFaAttribute(el, 'property', EXT('codelist'))
106
+ hasRDFaAttribute(el, 'property', EXT('codelist')),
106
107
  );
107
108
  const codelistResource =
108
109
  codelistSpan?.getAttribute('resource') ??
@@ -138,7 +139,7 @@ export const parseAttributes = (node: HTMLElement): false | Attrs => {
138
139
 
139
140
  export const attributesToDOM = (
140
141
  node: PNode,
141
- content?: string | null
142
+ content?: string | null,
142
143
  ): DOMOutputSpec => {
143
144
  const {
144
145
  mappingResource,