@lblod/ember-rdfa-editor-lblod-plugins 0.4.0 → 1.0.0-alpha.1

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 (283) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/addon/commands/article-structure-plugin/delete-structure.ts +85 -0
  3. package/addon/commands/article-structure-plugin/index.ts +4 -0
  4. package/addon/commands/article-structure-plugin/insert-article-structure.ts +137 -0
  5. package/addon/commands/article-structure-plugin/move-structure.ts +227 -0
  6. package/addon/commands/article-structure-plugin/recalculate-structure-numbers.ts +88 -0
  7. package/addon/commands/besluit-plugin/get-article-nodes-for-besluit.ts +30 -0
  8. package/addon/commands/besluit-plugin/index.ts +4 -0
  9. package/addon/commands/besluit-plugin/insert-article.ts +94 -0
  10. package/addon/commands/besluit-plugin/insert-title.ts +67 -0
  11. package/addon/commands/besluit-plugin/move-article.ts +69 -0
  12. package/addon/commands/besluit-plugin/recalculate-article-numbers.ts +44 -0
  13. package/addon/commands/modify-date-command.ts +48 -0
  14. package/addon/components/article-structure-plugin/article-structure-card.hbs +14 -0
  15. package/addon/components/article-structure-plugin/article-structure-card.ts +83 -0
  16. package/addon/components/article-structure-plugin/structure-card.hbs +42 -0
  17. package/addon/components/article-structure-plugin/structure-card.ts +140 -0
  18. package/addon/components/au-native-input.hbs +30 -0
  19. package/addon/components/au-native-input.ts +47 -0
  20. package/addon/components/besluit-plugin/besluit-context-card.hbs +44 -0
  21. package/addon/components/besluit-plugin/besluit-context-card.ts +144 -0
  22. package/addon/components/besluit-plugin/besluit-plugin-card.hbs +20 -0
  23. package/addon/components/besluit-plugin/besluit-plugin-card.ts +42 -0
  24. package/addon/components/besluit-type-plugin/{besluit-type-select.js → besluit-type-select.ts} +9 -4
  25. package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +2 -0
  26. package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +216 -0
  27. package/addon/components/citation-plugin/citation-card.hbs +118 -0
  28. package/addon/components/citation-plugin/citation-card.ts +230 -0
  29. package/addon/components/citation-plugin/citation-insert.hbs +20 -0
  30. package/addon/components/citation-plugin/citation-insert.ts +102 -0
  31. package/addon/components/{citaten-plugin → citation-plugin}/citations/article-list.hbs +2 -2
  32. package/addon/components/{citaten-plugin → citation-plugin}/citations/article-preview.hbs +0 -0
  33. package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-detail.hbs +9 -6
  34. package/addon/components/{citaten-plugin/citations/decision-detail.js → citation-plugin/citations/decision-detail.ts} +30 -31
  35. package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-list.hbs +2 -2
  36. package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-preview.hbs +0 -0
  37. package/addon/components/citation-plugin/citations/search-modal.hbs +254 -0
  38. package/addon/components/{citaten-plugin/citations/search-modal.js → citation-plugin/citations/search-modal.ts} +116 -89
  39. package/addon/components/{citaten-plugin → citation-plugin}/helpers/alert-load-error.hbs +1 -1
  40. package/addon/components/{citaten-plugin → citation-plugin}/helpers/alert-no-items.hbs +1 -1
  41. package/addon/components/import-snippet-plugin/card.ts +119 -0
  42. package/addon/components/insert-variable-plugin/insert-variable-card.hbs +2 -1
  43. package/addon/components/insert-variable-plugin/insert-variable-card.ts +134 -0
  44. package/addon/components/rdfa-date-plugin/{rdfa-date-plugin-card.hbs → card.hbs} +3 -1
  45. package/addon/components/rdfa-date-plugin/card.ts +72 -0
  46. package/addon/components/rdfa-date-plugin/{rdfa-date-time-picker.hbs → date-time-picker.hbs} +0 -0
  47. package/addon/components/rdfa-date-plugin/{rdfa-date-time-picker.js → date-time-picker.ts} +26 -12
  48. package/addon/components/rdfa-date-plugin/{rdfa-date-plugin-insert.hbs → insert.hbs} +0 -0
  49. package/addon/components/rdfa-date-plugin/insert.ts +44 -0
  50. package/addon/components/roadsign-regulation-plugin/expanded-measure.ts +58 -0
  51. package/addon/components/roadsign-regulation-plugin/measure-template.ts +35 -0
  52. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +2 -2
  53. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +60 -0
  54. package/addon/components/roadsign-regulation-plugin/{roadsigns-modal.js → roadsigns-modal.ts} +101 -64
  55. package/addon/components/roadsign-regulation-plugin/{roadsigns-pagination.js → roadsigns-pagination.ts} +7 -3
  56. package/addon/components/roadsign-regulation-plugin/roadsigns-table.ts +32 -0
  57. package/addon/components/standard-template-plugin/{template-card.hbs → card.hbs} +0 -0
  58. package/addon/components/standard-template-plugin/card.ts +11 -0
  59. package/addon/components/standard-template-plugin/template-provider.hbs +3 -1
  60. package/addon/components/standard-template-plugin/template-provider.ts +75 -0
  61. package/addon/components/table-of-contents-plugin/card.hbs +12 -1
  62. package/addon/components/table-of-contents-plugin/card.ts +60 -0
  63. package/addon/components/table-of-contents-plugin/{inline-components → ember-nodes}/outline.hbs +2 -2
  64. package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.hbs +9 -0
  65. package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +95 -0
  66. package/addon/components/template-variable-plugin/template-variable-card.hbs +2 -1
  67. package/addon/components/template-variable-plugin/template-variable-card.ts +227 -0
  68. package/addon/{constants.js → constants.ts} +15 -3
  69. package/addon/ember-nodes/table-of-contents.ts +53 -0
  70. package/addon/helpers/{limit-text.js → limit-text.ts} +2 -2
  71. package/addon/initializers/plugin-initializer.js +0 -75
  72. package/addon/models/instruction.ts +18 -0
  73. package/addon/models/measure.ts +38 -0
  74. package/addon/models/sign.ts +36 -0
  75. package/addon/models/template.ts +14 -0
  76. package/addon/plugins/article-structure-plugin.ts +55 -0
  77. package/addon/plugins/besluit-plugin.ts +27 -0
  78. package/addon/plugins/besluit-type-plugin.ts +6 -0
  79. package/addon/plugins/citation-plugin/index.ts +216 -0
  80. package/addon/plugins/citation-plugin/marks/citation.ts +27 -0
  81. package/addon/plugins/citation-plugin/utils/cited-text.ts +17 -0
  82. package/addon/plugins/citation-plugin/utils/process-match.ts +135 -0
  83. package/addon/{utils/vlaamse-codex.js → plugins/citation-plugin/utils/vlaamse-codex.ts} +161 -42
  84. package/addon/plugins/import-snippet-plugin.ts +6 -0
  85. package/addon/plugins/insert-variable-plugin.ts +11 -0
  86. package/addon/plugins/rdfa-date-plugin.ts +11 -0
  87. package/addon/plugins/roadsign-regulation-plugin.ts +6 -0
  88. package/addon/plugins/standard-template-plugin.ts +6 -0
  89. package/addon/plugins/table-of-contents-plugin.ts +14 -0
  90. package/addon/plugins/template-variable-plugin.ts +6 -0
  91. package/addon/services/{import-rdfa-snippet.js → import-rdfa-snippet.ts} +48 -36
  92. package/addon/services/roadsign-registry.ts +288 -0
  93. package/addon/services/{standard-template-plugin.js → standard-template-plugin.ts} +17 -11
  94. package/addon/utils/article-structure-plugin/constants.ts +260 -0
  95. package/addon/utils/article-structure-plugin/defaults.ts +3 -0
  96. package/addon/utils/article-structure-plugin/options-with-defaults.ts +31 -0
  97. package/addon/utils/article-structure-plugin/validate-datastore.ts +23 -0
  98. package/addon/utils/besluit-plugin/get-title-for-decision.ts +35 -0
  99. package/addon/utils/{fetchBesluitTypes.js → fetchBesluitTypes.ts} +36 -16
  100. package/addon/utils/generate-template-plugin/{default-resources.js → default-resources.ts} +0 -0
  101. package/addon/utils/{instantiate-uuids.js → instantiate-uuids.ts} +9 -6
  102. package/addon/utils/{legislation-types.js → legislation-types.ts} +17 -3
  103. package/addon/utils/{memoize.js → memoize.ts} +4 -2
  104. package/addon/utils/option.ts +58 -0
  105. package/addon/utils/roadsign-regulation-plugin/{fetchData.js → fetchData.ts} +19 -2
  106. package/addon/utils/roadsign-regulation-plugin/includeInstructions.ts +16 -0
  107. package/addon/utils/romanize.ts +47 -0
  108. package/addon/utils/variable-plugins/{default-variable-types.js → default-variable-types.ts} +18 -7
  109. package/addon/utils/variable-plugins/{fetch-data.js → fetch-data.ts} +43 -15
  110. package/app/components/article-structure-plugin/article-structure-card.js +1 -0
  111. package/app/components/article-structure-plugin/structure-card.js +1 -0
  112. package/app/components/{citaten-plugin/citaat-card.js → au-native-input.js} +1 -1
  113. package/app/components/{citaten-plugin/citations/article-list.js → besluit-plugin/besluit-context-card.js} +1 -1
  114. package/app/components/besluit-plugin/besluit-plugin-card.js +1 -0
  115. package/app/components/{citaten-plugin/citations/modal.js → citation-plugin/citation-card.js} +1 -1
  116. package/app/components/citation-plugin/citation-insert.js +1 -0
  117. package/app/components/{citaten-plugin/citations/decision-list.js → citation-plugin/citations/article-list.js} +1 -1
  118. package/app/components/{citaten-plugin → citation-plugin}/citations/article-preview.js +1 -1
  119. package/app/components/{citaten-plugin → citation-plugin}/citations/decision-detail.js +1 -1
  120. package/app/components/citation-plugin/citations/decision-list.js +1 -0
  121. package/app/components/{citaten-plugin → citation-plugin}/citations/decision-preview.js +1 -1
  122. package/app/components/citation-plugin/citations/modal.js +1 -0
  123. package/app/components/{citaten-plugin → citation-plugin}/citations/search-modal.js +1 -1
  124. package/app/components/{citaten-plugin → citation-plugin}/helpers/alert-load-error.js +1 -1
  125. package/app/components/{citaten-plugin → citation-plugin}/helpers/alert-no-items.js +1 -1
  126. package/app/components/{citaten-plugin/citaat-insert.js → rdfa-date-plugin/card.js} +1 -1
  127. package/app/components/rdfa-date-plugin/date-time-picker.js +1 -0
  128. package/app/components/rdfa-date-plugin/insert.js +1 -0
  129. package/app/components/standard-template-plugin/card.js +1 -0
  130. package/app/components/table-of-contents-plugin/ember-nodes/outline.js +1 -0
  131. package/app/components/table-of-contents-plugin/ember-nodes/table-of-contents.js +1 -0
  132. package/app/styles/citaten-plugin.scss +1 -1
  133. package/commands/article-structure-plugin/delete-structure.d.ts +4 -0
  134. package/commands/article-structure-plugin/index.d.ts +4 -0
  135. package/commands/article-structure-plugin/insert-article-structure.d.ts +6 -0
  136. package/commands/article-structure-plugin/move-structure.d.ts +5 -0
  137. package/commands/article-structure-plugin/recalculate-structure-numbers.d.ts +7 -0
  138. package/commands/besluit-plugin/get-article-nodes-for-besluit.d.ts +5 -0
  139. package/commands/besluit-plugin/index.d.ts +4 -0
  140. package/commands/besluit-plugin/insert-article.d.ts +3 -0
  141. package/commands/besluit-plugin/insert-title.d.ts +2 -0
  142. package/commands/besluit-plugin/move-article.d.ts +2 -0
  143. package/commands/besluit-plugin/recalculate-article-numbers.d.ts +2 -0
  144. package/commands/modify-date-command.d.ts +2 -0
  145. package/components/article-structure-plugin/article-structure-card.d.ts +36 -0
  146. package/components/article-structure-plugin/structure-card.d.ts +23 -0
  147. package/components/au-native-input.d.ts +20 -0
  148. package/components/besluit-plugin/besluit-context-card.d.ts +29 -0
  149. package/components/besluit-plugin/besluit-plugin-card.d.ts +14 -0
  150. package/components/besluit-type-plugin/besluit-type-select.d.ts +11 -0
  151. package/components/besluit-type-plugin/toolbar-dropdown.d.ts +46 -0
  152. package/components/citation-plugin/citation-card.d.ts +51 -0
  153. package/components/citation-plugin/citation-insert.d.ts +24 -0
  154. package/components/citation-plugin/citations/decision-detail.d.ts +26 -0
  155. package/components/citation-plugin/citations/search-modal.d.ts +67 -0
  156. package/components/import-snippet-plugin/card.d.ts +19 -0
  157. package/components/insert-variable-plugin/insert-variable-card.d.ts +31 -0
  158. package/components/rdfa-date-plugin/card.d.ts +20 -0
  159. package/components/rdfa-date-plugin/date-time-picker.d.ts +32 -0
  160. package/components/rdfa-date-plugin/insert.d.ts +12 -0
  161. package/components/roadsign-regulation-plugin/expanded-measure.d.ts +20 -0
  162. package/components/roadsign-regulation-plugin/measure-template.d.ts +14 -0
  163. package/components/roadsign-regulation-plugin/roadsign-regulation-card.d.ts +12 -0
  164. package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +57 -0
  165. package/components/roadsign-regulation-plugin/roadsigns-pagination.d.ts +19 -0
  166. package/components/roadsign-regulation-plugin/roadsigns-table.d.ts +9 -0
  167. package/components/standard-template-plugin/card.d.ts +9 -0
  168. package/components/standard-template-plugin/template-provider.d.ts +17 -0
  169. package/components/table-of-contents-plugin/card.d.ts +20 -0
  170. package/components/table-of-contents-plugin/ember-nodes/table-of-contents.d.ts +22 -0
  171. package/components/template-variable-plugin/template-variable-card.d.ts +27 -0
  172. package/constants.d.ts +11 -0
  173. package/ember-nodes/table-of-contents.d.ts +4 -0
  174. package/helpers/limit-text.d.ts +8 -0
  175. package/index.js +5 -0
  176. package/models/instruction.d.ts +8 -0
  177. package/models/measure.d.ts +14 -0
  178. package/models/sign.d.ts +12 -0
  179. package/models/template.d.ts +13 -0
  180. package/package.json +27 -8
  181. package/plugins/article-structure-plugin.d.ts +29 -0
  182. package/plugins/besluit-plugin.d.ts +9 -0
  183. package/plugins/besluit-type-plugin.d.ts +2 -0
  184. package/plugins/citation-plugin/index.d.ts +31 -0
  185. package/plugins/citation-plugin/marks/citation.d.ts +2 -0
  186. package/plugins/citation-plugin/utils/cited-text.d.ts +3 -0
  187. package/plugins/citation-plugin/utils/process-match.d.ts +23 -0
  188. package/plugins/citation-plugin/utils/vlaamse-codex.d.ts +56 -0
  189. package/plugins/import-snippet-plugin.d.ts +2 -0
  190. package/plugins/insert-variable-plugin.d.ts +2 -0
  191. package/plugins/rdfa-date-plugin.d.ts +3 -0
  192. package/plugins/roadsign-regulation-plugin.d.ts +2 -0
  193. package/plugins/standard-template-plugin.d.ts +2 -0
  194. package/plugins/table-of-contents-plugin.d.ts +3 -0
  195. package/plugins/template-variable-plugin.d.ts +2 -0
  196. package/services/import-rdfa-snippet.d.ts +99 -0
  197. package/services/roadsign-registry.d.ts +42 -0
  198. package/services/standard-template-plugin.d.ts +21 -0
  199. package/translations/en-US.yaml +47 -1
  200. package/translations/nl-BE.yaml +49 -3
  201. package/tsconfig.json +36 -9
  202. package/types/config/environment.d.ts +22 -0
  203. package/types/ember-mu-transform-helpers/transforms/string-set.d.ts +14 -0
  204. package/types/lblod/frontend-gelinkt-notuleren/models/account.d.ts +10 -0
  205. package/types/lblod/frontend-gelinkt-notuleren/models/bestuurseenheid-classificatie-code.d.ts +10 -0
  206. package/types/lblod/frontend-gelinkt-notuleren/models/bestuurseenheid.d.ts +12 -0
  207. package/types/lblod/frontend-gelinkt-notuleren/models/gebruiker-model.d.ts +18 -0
  208. package/types/lblod/frontend-gelinkt-notuleren/services/current-session.d.ts +30 -0
  209. package/types/lblod/marawa/dom-helpers.d.ts +4 -0
  210. package/types/lblod/marawa/ember-object-mock.d.ts +3 -0
  211. package/types/lblod/marawa/node-walker.d.ts +18 -0
  212. package/types/lblod/marawa/range-helpers.d.ts +10 -0
  213. package/types/lblod/marawa/rdfa-attributes.d.ts +25 -0
  214. package/types/lblod/marawa/rdfa-block.d.ts +22 -0
  215. package/types/lblod/marawa/rdfa-context-scanner.d.ts +13 -0
  216. package/types/lblod/marawa/rdfa-helpers.d.ts +22 -0
  217. package/types/lblod/marawa/rich-node.d.ts +50 -0
  218. package/types/lblod/marawa/triple.d.ts +16 -0
  219. package/utils/article-structure-plugin/constants.d.ts +2 -0
  220. package/utils/article-structure-plugin/defaults.d.ts +4 -0
  221. package/utils/article-structure-plugin/options-with-defaults.d.ts +2 -0
  222. package/utils/article-structure-plugin/validate-datastore.d.ts +3 -0
  223. package/utils/besluit-plugin/get-title-for-decision.d.ts +10 -0
  224. package/utils/fetchBesluitTypes.d.ts +12 -0
  225. package/utils/generate-template-plugin/default-resources.d.ts +2 -0
  226. package/utils/instantiate-uuids.d.ts +1 -0
  227. package/utils/legislation-types.d.ts +24 -0
  228. package/utils/memoize.d.ts +1 -0
  229. package/utils/option.d.ts +14 -0
  230. package/utils/roadsign-regulation-plugin/fetchData.d.ts +8 -0
  231. package/utils/roadsign-regulation-plugin/includeInstructions.d.ts +2 -0
  232. package/utils/romanize.d.ts +2 -0
  233. package/utils/variable-plugins/default-variable-types.d.ts +7 -0
  234. package/utils/variable-plugins/fetch-data.d.ts +14 -0
  235. package/addon/commands/generate-template-command.js +0 -35
  236. package/addon/commands/insert-and-collapse.js +0 -32
  237. package/addon/commands/modify-date-command.js +0 -42
  238. package/addon/components/besluit-type-plugin/toolbar-dropdown.js +0 -188
  239. package/addon/components/citaten-plugin/citaat-card.hbs +0 -76
  240. package/addon/components/citaten-plugin/citaat-card.js +0 -286
  241. package/addon/components/citaten-plugin/citaat-insert.hbs +0 -20
  242. package/addon/components/citaten-plugin/citaat-insert.js +0 -68
  243. package/addon/components/citaten-plugin/citations/search-modal.hbs +0 -175
  244. package/addon/components/import-snippet-plugin/card.js +0 -95
  245. package/addon/components/insert-variable-plugin/insert-variable-card.js +0 -125
  246. package/addon/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -64
  247. package/addon/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -24
  248. package/addon/components/roadsign-regulation-plugin/expanded-measure.js +0 -38
  249. package/addon/components/roadsign-regulation-plugin/measure-template.js +0 -30
  250. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.js +0 -101
  251. package/addon/components/roadsign-regulation-plugin/roadsigns-table.js +0 -24
  252. package/addon/components/standard-template-plugin/template-card.js +0 -7
  253. package/addon/components/standard-template-plugin/template-provider.js +0 -75
  254. package/addon/components/table-of-contents-plugin/card.js +0 -53
  255. package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.hbs +0 -9
  256. package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -100
  257. package/addon/components/template-variable-plugin/template-variable-card.js +0 -230
  258. package/addon/inline-components/table-of-contents.js +0 -43
  259. package/addon/models/instruction.js +0 -19
  260. package/addon/models/measure.js +0 -46
  261. package/addon/models/sign.js +0 -37
  262. package/addon/models/template.js +0 -9
  263. package/addon/plugins/besluit-type-plugin.js +0 -16
  264. package/addon/plugins/citaten-plugin.js +0 -22
  265. package/addon/plugins/import-snippet-plugin.js +0 -16
  266. package/addon/plugins/insert-variable-plugin.js +0 -19
  267. package/addon/plugins/rdfa-date-plugin.js +0 -26
  268. package/addon/plugins/roadsign-regulation-plugin.js +0 -24
  269. package/addon/plugins/standard-template-plugin.js +0 -33
  270. package/addon/plugins/table-of-contents-plugin.js +0 -27
  271. package/addon/plugins/template-variable-plugin.js +0 -21
  272. package/addon/services/roadsign-registry.js +0 -240
  273. package/addon/utils/processMatch.js +0 -80
  274. package/addon/utils/roadsign-regulation-plugin/includeInstructions.js +0 -10
  275. package/app/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -1
  276. package/app/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -1
  277. package/app/components/rdfa-date-plugin/rdfa-date-time-picker.js +0 -1
  278. package/app/components/standard-template-plugin/template-card.js +0 -1
  279. package/app/components/table-of-contents-plugin/inline-components/outline.js +0 -1
  280. package/app/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -1
  281. package/app/initializers/plugin-initializer.js +0 -4
  282. package/types/dummy/index.d.ts +0 -1
  283. package/types/ember-data/types/registries/model.d.ts +0 -6
@@ -0,0 +1,94 @@
1
+ import { v4 as uuid } from 'uuid';
2
+ import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
3
+ import { ProseController, TextSelection } from '@lblod/ember-rdfa-editor';
4
+ import { Command } from '@lblod/ember-rdfa-editor';
5
+
6
+ export default function insertArticle(
7
+ controller: ProseController,
8
+ articleContent: string,
9
+ articleNumber: string
10
+ ): Command {
11
+ return function (_state, dispatch) {
12
+ const selection = controller.state.selection;
13
+ const limitedDatastore = controller.datastore.limitToRange(
14
+ controller.state,
15
+ selection.from,
16
+ selection.to
17
+ );
18
+ const besluitSubject = limitedDatastore
19
+ .match(null, 'a', '>http://data.vlaanderen.be/ns/besluit#Besluit')
20
+ .asQuadResultSet()
21
+ .first()?.subject;
22
+
23
+ if (!besluitSubject) {
24
+ return false;
25
+ }
26
+ const containerRange = [
27
+ ...controller.datastore
28
+ .match(besluitSubject, 'prov:value')
29
+ .asPredicateNodeMapping(),
30
+ ][0].nodes[0];
31
+
32
+ if (!containerRange) {
33
+ return false;
34
+ }
35
+ if (dispatch) {
36
+ const range = {
37
+ from: containerRange.to - 1,
38
+ to: containerRange.to - 1,
39
+ };
40
+ const articleUri = `http://data.lblod.info/artikels/${uuid()}`;
41
+ const articleHtml = `
42
+ <div property="eli:has_part" prefix="mobiliteit: https://data.vlaanderen.be/ns/mobiliteit#" typeof="besluit:Artikel" resource="${articleUri}">
43
+ <div>
44
+ Artikel
45
+ <span property="eli:number" datatype="xsd:string">
46
+ ${articleNumber ? articleNumber : generateArticleNumber(controller)}
47
+ </span></div>
48
+ <span style="display:none;" property="eli:language" resource="http://publications.europa.eu/resource/authority/language/NLD" typeof="skos:Concept">&nbsp;</span>
49
+ <div property="prov:value" datatype="xsd:string">
50
+ ${
51
+ articleContent
52
+ ? articleContent
53
+ : '<span class="mark-highlight-manual">Voer inhoud in</span>'
54
+ }
55
+ </div>
56
+ </div>
57
+ `;
58
+ controller.doCommand(insertHtml(articleHtml, range.from, range.to));
59
+
60
+ controller.withTransaction((tr) => {
61
+ const selection = TextSelection.near(
62
+ controller.state.doc.resolve(range.from)
63
+ );
64
+ return tr.setSelection(selection).scrollIntoView();
65
+ });
66
+ controller.focus();
67
+ }
68
+ return true;
69
+ };
70
+ }
71
+
72
+ function generateArticleNumber(controller: ProseController) {
73
+ const numberQuads = [
74
+ ...controller.datastore
75
+ .match(null, '>http://data.europa.eu/eli/ontology#number')
76
+ .asQuads(),
77
+ ];
78
+ let biggerNumber;
79
+ for (const numberQuad of numberQuads) {
80
+ const number = Number(removeZeroWidthSpace(numberQuad.object.value));
81
+ if (!Number.isNaN(number) && (!biggerNumber || number > biggerNumber)) {
82
+ biggerNumber = number;
83
+ }
84
+ }
85
+ if (biggerNumber) {
86
+ return biggerNumber + 1;
87
+ } else {
88
+ return '<span class="mark-highlight-manual">nummer</span>';
89
+ }
90
+ }
91
+
92
+ function removeZeroWidthSpace(text: string) {
93
+ return text.replace(/[\u200B-\u200D\uFEFF]/g, '');
94
+ }
@@ -0,0 +1,67 @@
1
+ import {
2
+ Command,
3
+ ProseController,
4
+ TextSelection,
5
+ } from '@lblod/ember-rdfa-editor';
6
+ import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
7
+
8
+ export default function insertTitle(
9
+ controller: ProseController,
10
+ title: string
11
+ ): Command {
12
+ return function (state, dispatch) {
13
+ const selection = controller.state.selection;
14
+ const limitedDatastore = controller.datastore.limitToRange(
15
+ controller.state,
16
+ selection.from,
17
+ selection.to
18
+ );
19
+
20
+ const besluit = [
21
+ ...limitedDatastore
22
+ .match(null, 'a', 'besluit:Besluit')
23
+ .asSubjectNodeMapping(),
24
+ ][0];
25
+
26
+ const besluitRange = besluit?.nodes[0];
27
+
28
+ if (!besluit || !besluitRange) {
29
+ return false;
30
+ }
31
+
32
+ const titleQuad = controller.datastore
33
+ .match(
34
+ `>${besluit.term.value}`,
35
+ '>http://data.europa.eu/eli/ontology#title'
36
+ )
37
+ .asQuadResultSet()
38
+ .first();
39
+ if (titleQuad) {
40
+ return false;
41
+ }
42
+
43
+ if (dispatch) {
44
+ const range = {
45
+ from: besluitRange.from + 1,
46
+ to: besluitRange.from + 1,
47
+ };
48
+ const articleHtml = `
49
+ <h4 class="h4" property="eli:title" datatype="xsd:string">${
50
+ title
51
+ ? title
52
+ : '<span class="mark-highlight-manual">Geef titel besluit op</span>'
53
+ }</h4>
54
+ `;
55
+ controller.doCommand(insertHtml(articleHtml, range.from, range.to));
56
+ controller.withTransaction((tr) => {
57
+ const selection = TextSelection.near(
58
+ controller.state.doc.resolve(range.from)
59
+ );
60
+ return tr.setSelection(selection).scrollIntoView();
61
+ });
62
+ dispatch(state.tr.scrollIntoView());
63
+ }
64
+
65
+ return true;
66
+ };
67
+ }
@@ -0,0 +1,69 @@
1
+ import {
2
+ Command,
3
+ ProseController,
4
+ Selection,
5
+ TextSelection,
6
+ } from '@lblod/ember-rdfa-editor';
7
+ import { recalculateArticleNumbers } from '@lblod/ember-rdfa-editor-lblod-plugins/commands/besluit-plugin';
8
+ import { ResolvedPNode } from '@lblod/ember-rdfa-editor/plugins/datastore';
9
+ import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
10
+ import getArticleNodesForBesluit from './get-article-nodes-for-besluit';
11
+
12
+ export default function moveArticleCommand(
13
+ controller: ProseController,
14
+ besluitUri: string,
15
+ articleUri: string,
16
+ moveUp: boolean
17
+ ): Command {
18
+ return (_state, dispatch) => {
19
+ const articles = getArticleNodesForBesluit(controller, besluitUri);
20
+ if (!articles) {
21
+ return false;
22
+ }
23
+ const articleIndex = articles.findIndex(({ uri }) => uri === articleUri);
24
+
25
+ if (
26
+ articleIndex === -1 ||
27
+ (moveUp && articleIndex === 0) ||
28
+ (!moveUp && articleIndex === articles.length - 1)
29
+ ) {
30
+ return false;
31
+ }
32
+
33
+ if (dispatch) {
34
+ let articleA: ResolvedPNode;
35
+ let articleB: ResolvedPNode;
36
+
37
+ if (moveUp) {
38
+ articleA = unwrap(articles[articleIndex - 1]).range;
39
+ articleB = unwrap(articles[articleIndex]).range;
40
+ } else {
41
+ articleA = unwrap(articles[articleIndex]).range;
42
+ articleB = unwrap(articles[articleIndex + 1]).range;
43
+ }
44
+ const articleBNode = unwrap(controller.state.doc.nodeAt(articleB.from));
45
+ controller.withTransaction((tr) => {
46
+ tr.delete(articleB.from, articleB.to);
47
+ return tr.replaceRangeWith(articleA.from, articleA.from, articleBNode);
48
+ });
49
+ recalculateArticleNumbers(controller, besluitUri);
50
+ let selection: Selection;
51
+ if (moveUp) {
52
+ selection = TextSelection.near(
53
+ controller.state.doc.resolve(articleA.from)
54
+ );
55
+ } else {
56
+ selection = TextSelection.near(
57
+ controller.state.doc.resolve(
58
+ articleA.from + articleB.to - articleB.from
59
+ )
60
+ );
61
+ }
62
+ controller.withTransaction((tr) => {
63
+ return tr.setSelection(selection);
64
+ });
65
+ controller.focus();
66
+ }
67
+ return true;
68
+ };
69
+ }
@@ -0,0 +1,44 @@
1
+ import { ProseController } from '@lblod/ember-rdfa-editor';
2
+ import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
3
+ import getArticleNodesForBesluit from './get-article-nodes-for-besluit';
4
+
5
+ export default function recalculateArticleNumbers(
6
+ controller: ProseController,
7
+ besluitUri: string
8
+ ) {
9
+ const articles = getArticleNodesForBesluit(controller, besluitUri);
10
+ if (articles) {
11
+ for (let i = 0; i < articles.length; i++) {
12
+ const article = unwrap(articles[i]);
13
+ replaceNumberIfNeeded(controller, article, i);
14
+ }
15
+ }
16
+ }
17
+
18
+ function replaceNumberIfNeeded(
19
+ controller: ProseController,
20
+ article: { uri: string; range: { from: number; to: number } },
21
+ index: number
22
+ ) {
23
+ const articleNumberObject = [
24
+ ...controller.datastore
25
+ .match(`>${article.uri}`, '>http://data.europa.eu/eli/ontology#number')
26
+ .asObjectNodeMapping(),
27
+ ][0];
28
+ if (!articleNumberObject) {
29
+ return;
30
+ }
31
+ const articleNumber = Number(articleNumberObject.term.value);
32
+ const articleNumberRange = unwrap(articleNumberObject.nodes[0]);
33
+ const articleNumberExpected = index + 1;
34
+
35
+ if (articleNumber !== articleNumberExpected) {
36
+ controller.withTransaction((tr) => {
37
+ return tr.insertText(
38
+ articleNumberExpected.toString(),
39
+ articleNumberRange.from,
40
+ articleNumberRange.to
41
+ );
42
+ });
43
+ }
44
+ }
@@ -0,0 +1,48 @@
1
+ import { Command, Mark } from '@lblod/ember-rdfa-editor';
2
+ import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
3
+
4
+ function formatDate(date: Date, onlyDate: boolean) {
5
+ const options: Intl.DateTimeFormatOptions = {
6
+ year: 'numeric',
7
+ month: '2-digit',
8
+ day: '2-digit',
9
+ ...(!onlyDate && {
10
+ hour: '2-digit',
11
+ minute: '2-digit',
12
+ }),
13
+ };
14
+ return date.toLocaleString('nl-BE', options);
15
+ }
16
+
17
+ export default function modifyDate(
18
+ from: number,
19
+ to: number,
20
+ dateValue: Date,
21
+ onlyDate: boolean
22
+ ): Command {
23
+ return function (state, dispatch) {
24
+ if (dispatch) {
25
+ const transaction = state.tr;
26
+ const node = unwrap(transaction.doc.nodeAt(from));
27
+ const currentRdfaMark = node.marks
28
+ .filter((mark) => mark.type.name === 'inline_rdfa')
29
+ .at(-1);
30
+ if (currentRdfaMark) {
31
+ transaction.removeMark(from, to, currentRdfaMark);
32
+ }
33
+
34
+ const newMark: Mark = currentRdfaMark
35
+ ? state.schema.mark('inline_rdfa', {
36
+ ...currentRdfaMark.attrs,
37
+ content: dateValue.toISOString(),
38
+ })
39
+ : state.schema.mark('inline_rdfa', {
40
+ content: dateValue.toISOString(),
41
+ });
42
+ transaction.addMark(from, to, newMark);
43
+ transaction.insertText(formatDate(dateValue, onlyDate), from, to);
44
+ dispatch(transaction);
45
+ }
46
+ return true;
47
+ };
48
+ }
@@ -0,0 +1,14 @@
1
+ <div>
2
+ {{#each this.structures.value as |structure|}}
3
+ <AuList::Item>
4
+ <AuButton
5
+ @icon="add"
6
+ @iconAlignment="left"
7
+ @skin="link"
8
+ @disabled={{not structure.canExecute}}
9
+ {{on 'click' (fn this.insertStructure structure.title)}}>
10
+ {{t structure.translation}}
11
+ </AuButton>
12
+ </AuList::Item>
13
+ {{/each}}
14
+ </div>
@@ -0,0 +1,83 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+ import { inject as service } from '@ember/service';
4
+ import { ProseController } from '@lblod/ember-rdfa-editor';
5
+ import { insertArticleStructure } from '@lblod/ember-rdfa-editor-lblod-plugins/commands/article-structure-plugin';
6
+ import IntlService from 'ember-intl/services/intl';
7
+ import { trackedFunction } from 'ember-resources/util/function';
8
+ import validateDatastore from '@lblod/ember-rdfa-editor-lblod-plugins/utils/article-structure-plugin/validate-datastore';
9
+ import { ResolvedArticleStructurePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
10
+
11
+ type Args = {
12
+ controller: ProseController;
13
+ widgetArgs: {
14
+ options: ResolvedArticleStructurePluginOptions;
15
+ };
16
+ };
17
+ export default class EditorPluginsArticleStructureCardComponent extends Component<Args> {
18
+ @service declare intl: IntlService;
19
+
20
+ structures = trackedFunction(this, async () => {
21
+ return Promise.all(
22
+ this.args.widgetArgs.options.structures.map(async (structure) => {
23
+ const shaclReport = await validateDatastore(
24
+ this.args.controller.datastore,
25
+ structure.shaclConstraint
26
+ );
27
+ const canExecute = this.args.controller.checkCommand(
28
+ insertArticleStructure(
29
+ this.args.controller,
30
+ structure.title,
31
+ this.args.widgetArgs.options,
32
+ shaclReport,
33
+ this.intl
34
+ )
35
+ );
36
+ return {
37
+ ...structure,
38
+ canExecute,
39
+ };
40
+ })
41
+ );
42
+ });
43
+
44
+ @action
45
+ async insertStructure(structureName: string) {
46
+ const structureToAdd = this.args.widgetArgs.options.structures.find(
47
+ (structure) => structure.title === structureName
48
+ );
49
+ if (structureToAdd) {
50
+ const shaclReport = await validateDatastore(
51
+ this.args.controller.datastore,
52
+ structureToAdd.shaclConstraint
53
+ );
54
+ this.args.controller.doCommand(
55
+ insertArticleStructure(
56
+ this.args.controller,
57
+ structureName,
58
+ this.args.widgetArgs.options,
59
+ shaclReport,
60
+ this.intl
61
+ )
62
+ );
63
+ }
64
+ }
65
+
66
+ get structureUri() {
67
+ const currentSelection = this.args.controller.state.selection;
68
+ const limitedDatastore = this.args.controller.datastore.limitToRange(
69
+ this.args.controller.state,
70
+ currentSelection.from,
71
+ currentSelection.to
72
+ );
73
+
74
+ return limitedDatastore
75
+ .match(null, 'a', '>https://say.data.gift/ns/DocumentSubdivision')
76
+ .asQuadResultSet()
77
+ .first()?.subject.value;
78
+ }
79
+
80
+ get isOutsideStructure() {
81
+ return !this.structureUri;
82
+ }
83
+ }
@@ -0,0 +1,42 @@
1
+ {{#unless this.isOutsideStructure}}
2
+ <AuCard @flex={{true}} @divided={{true}} @expandable={{false}} @shadow={{true}} @size="flush" as |c|>
3
+ <c.header class="au-u-hidden-visually">
4
+ <AuHeading @level="3" @skin="6">{{t "article-structure-plugin.title.structureCard"}}</AuHeading>
5
+ </c.header>
6
+ <c.content class="au-c-content--small">
7
+ <AuList @divider={{true}} class="au-u-padding-top-tiny au-u-padding-bottom-tiny" as |Item|>
8
+ <Item>
9
+ <AuButton
10
+ @icon="chevron-up"
11
+ @iconAlignment="left"
12
+ @skin="link"
13
+ @disabled={{not this.canMoveUp.value}}
14
+ {{on 'click' (fn this.moveStructure true)}}>
15
+ {{t this.structureTypeSelected.moveUp}}
16
+ </AuButton>
17
+ </Item>
18
+ <Item>
19
+ <AuButton
20
+ @icon="chevron-down"
21
+ @iconAlignment="left"
22
+ @skin="link"
23
+ @disabled={{not this.canMoveDown.value}}
24
+ {{on 'click' (fn this.moveStructure false)}}>
25
+ {{t this.structureTypeSelected.moveDown}}
26
+ </AuButton>
27
+ </Item>
28
+ <Item>
29
+ <AuButton
30
+ @icon="bin"
31
+ @iconAlignment="left"
32
+ @skin="link"
33
+ @alert={{true}}
34
+ @disabled={{this.isOutsideStructure}}
35
+ {{on 'click' this.removeStructure}}>
36
+ {{t "article-structure-plugin.remove.structure"}}
37
+ </AuButton>
38
+ </Item>
39
+ </AuList>
40
+ </c.content>
41
+ </AuCard>
42
+ {{/unless}}
@@ -0,0 +1,140 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+ import { ProseController } from '@lblod/ember-rdfa-editor';
4
+ import { trackedFunction } from 'ember-resources/util/function';
5
+ import {
6
+ deleteStructure,
7
+ moveStructure,
8
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/commands/article-structure-plugin';
9
+ import validateDatastore from '@lblod/ember-rdfa-editor-lblod-plugins/utils/article-structure-plugin/validate-datastore';
10
+ import { ResolvedArticleStructurePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
11
+ type Args = {
12
+ controller: ProseController;
13
+ widgetArgs: {
14
+ options: ResolvedArticleStructurePluginOptions;
15
+ };
16
+ };
17
+
18
+ export default class EditorPluginsStructureCardComponent extends Component<Args> {
19
+ get controller() {
20
+ return this.args.controller;
21
+ }
22
+
23
+ @action
24
+ async moveStructure(moveUp: boolean) {
25
+ const structureToMove = this.args.widgetArgs.options.structures.find(
26
+ (structure) => structure === this.structureTypeSelected
27
+ );
28
+ if (structureToMove && this.structure) {
29
+ const shaclReport = await validateDatastore(
30
+ this.controller.datastore,
31
+ structureToMove.shaclConstraint
32
+ );
33
+ this.controller.doCommand(
34
+ moveStructure(
35
+ this.controller,
36
+ this.structure.uri,
37
+ moveUp,
38
+ this.args.widgetArgs.options,
39
+ shaclReport
40
+ )
41
+ );
42
+ }
43
+ }
44
+
45
+ @action
46
+ removeStructure() {
47
+ if (this.structure) {
48
+ this.controller.doCommand(
49
+ deleteStructure(
50
+ this.controller,
51
+ this.structure.uri,
52
+ this.args.widgetArgs.options
53
+ )
54
+ );
55
+ }
56
+ }
57
+
58
+ get structure(): { uri: string; type: string } | undefined {
59
+ const currentSelection = this.controller.state.selection;
60
+ const limitedDatastore = this.controller.datastore.limitToRange(
61
+ this.controller.state,
62
+ currentSelection.from,
63
+ currentSelection.to
64
+ );
65
+
66
+ const quad = limitedDatastore
67
+ .match(null, 'a')
68
+ .transformDataset((dataset) => {
69
+ return dataset.filter((quad) => {
70
+ return this.args.widgetArgs.options.structureTypes.includes(
71
+ quad.object.value
72
+ );
73
+ });
74
+ })
75
+ .asQuadResultSet()
76
+ .first();
77
+ if (quad) {
78
+ return { uri: quad.subject.value, type: quad.object.value };
79
+ }
80
+ return;
81
+ }
82
+
83
+ get structureTypeSelected() {
84
+ const structureTypeof = this.structure?.type;
85
+ if (structureTypeof) {
86
+ return this.args.widgetArgs.options.structures.find((structure) =>
87
+ structureTypeof.includes(structure.type)
88
+ );
89
+ }
90
+ return;
91
+ }
92
+
93
+ get isOutsideStructure() {
94
+ return !this.structure?.uri;
95
+ }
96
+
97
+ canMoveDown = trackedFunction(this, async () => {
98
+ const structureToMove = this.args.widgetArgs.options.structures.find(
99
+ (structure) => structure === this.structureTypeSelected
100
+ );
101
+ if (structureToMove && this.structure) {
102
+ const shaclReport = await validateDatastore(
103
+ this.controller.datastore,
104
+ structureToMove.shaclConstraint
105
+ );
106
+ return this.controller.checkCommand(
107
+ moveStructure(
108
+ this.controller,
109
+ this.structure.uri,
110
+ false,
111
+ this.args.widgetArgs.options,
112
+ shaclReport
113
+ )
114
+ );
115
+ }
116
+ return false;
117
+ });
118
+
119
+ canMoveUp = trackedFunction(this, async () => {
120
+ const structureToMove = this.args.widgetArgs.options.structures.find(
121
+ (structure) => structure === this.structureTypeSelected
122
+ );
123
+ if (structureToMove && this.structure) {
124
+ const shaclReport = await validateDatastore(
125
+ this.controller.datastore,
126
+ structureToMove.shaclConstraint
127
+ );
128
+ return this.controller.checkCommand(
129
+ moveStructure(
130
+ this.controller,
131
+ this.structure.uri,
132
+ true,
133
+ this.args.widgetArgs.options,
134
+ shaclReport
135
+ )
136
+ );
137
+ }
138
+ return false;
139
+ });
140
+ }
@@ -0,0 +1,30 @@
1
+ {{#if @icon}}
2
+ <span class='au-c-input-wrapper {{this.iconAlignment}} {{this.width}}'>
3
+ <input
4
+ type={{this.type}}
5
+ class='au-c-input
6
+ {{this.error}}
7
+ {{this.warning}}
8
+ {{this.width}}
9
+ {{this.disabled}}'
10
+ disabled={{@disabled}}
11
+ ...attributes
12
+ />
13
+ {{#if (eq @iconAlignment 'right')}}
14
+ <AuIcon @icon={{@icon}} @alignment='right' />
15
+ {{else}}
16
+ <AuIcon @icon={{@icon}} @alignment='left' />
17
+ {{/if}}
18
+ </span>
19
+ {{else}}
20
+ <input
21
+ type={{this.type}}
22
+ class='au-c-input
23
+ {{this.error}}
24
+ {{this.warning}}
25
+ {{this.width}}
26
+ {{this.disabled}}'
27
+ disabled={{@disabled}}
28
+ ...attributes
29
+ />
30
+ {{/if}}
@@ -0,0 +1,47 @@
1
+ import Component from '@glimmer/component';
2
+
3
+ interface Args {
4
+ width?: 'block';
5
+ iconAlignment?: 'left' | 'right';
6
+ error?: boolean;
7
+ warning?: boolean;
8
+ disabled?: boolean;
9
+ type?: string;
10
+ icon?: string;
11
+ }
12
+
13
+ export default class AuNativeInput extends Component<Args> {
14
+ constructor(owner: unknown, args: Args) {
15
+ super(owner, args);
16
+ }
17
+
18
+ get width() {
19
+ if (this.args.width == 'block') return 'au-c-input--block';
20
+ else return '';
21
+ }
22
+
23
+ get iconAlignment() {
24
+ if (this.args.iconAlignment == 'left') return 'au-c-input-wrapper--left';
25
+ if (this.args.iconAlignment == 'right') return 'au-c-input-wrapper--right';
26
+ else return '';
27
+ }
28
+
29
+ get error() {
30
+ if (this.args.error) return 'au-c-input--error';
31
+ else return '';
32
+ }
33
+
34
+ get warning() {
35
+ if (this.args.warning) return 'au-c-input--warning';
36
+ else return '';
37
+ }
38
+
39
+ get disabled() {
40
+ if (this.args.disabled) return 'is-disabled';
41
+ else return '';
42
+ }
43
+
44
+ get type() {
45
+ return this.args.type || 'text';
46
+ }
47
+ }