@lblod/ember-rdfa-editor-lblod-plugins 0.4.1 → 1.0.0-alpha.2

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 (316) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/addon/components/article-structure-plugin/article-structure-card.hbs +10 -0
  3. package/addon/components/article-structure-plugin/article-structure-card.ts +33 -0
  4. package/addon/components/article-structure-plugin/structure-card.hbs +46 -0
  5. package/addon/components/article-structure-plugin/structure-card.ts +124 -0
  6. package/addon/components/au-native-input.hbs +30 -0
  7. package/addon/components/au-native-input.ts +47 -0
  8. package/addon/components/besluit-plugin/besluit-context-card.hbs +44 -0
  9. package/addon/components/besluit-plugin/besluit-context-card.ts +138 -0
  10. package/addon/components/besluit-plugin/besluit-plugin-card.hbs +20 -0
  11. package/addon/components/besluit-plugin/besluit-plugin-card.ts +40 -0
  12. package/addon/components/besluit-type-plugin/{besluit-type-select.js → besluit-type-select.ts} +8 -4
  13. package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +2 -0
  14. package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +218 -0
  15. package/addon/components/citation-plugin/citation-card.hbs +118 -0
  16. package/addon/components/citation-plugin/citation-card.ts +230 -0
  17. package/addon/components/citation-plugin/citation-insert.hbs +20 -0
  18. package/addon/components/citation-plugin/citation-insert.ts +102 -0
  19. package/addon/components/{citaten-plugin → citation-plugin}/citations/article-list.hbs +2 -2
  20. package/addon/components/{citaten-plugin → citation-plugin}/citations/article-preview.hbs +0 -0
  21. package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-detail.hbs +9 -6
  22. package/addon/components/{citaten-plugin/citations/decision-detail.js → citation-plugin/citations/decision-detail.ts} +30 -31
  23. package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-list.hbs +2 -2
  24. package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-preview.hbs +0 -0
  25. package/addon/components/citation-plugin/citations/search-modal.hbs +254 -0
  26. package/addon/components/{citaten-plugin/citations/search-modal.js → citation-plugin/citations/search-modal.ts} +117 -90
  27. package/addon/components/{citaten-plugin → citation-plugin}/helpers/alert-load-error.hbs +0 -0
  28. package/addon/components/{citaten-plugin → citation-plugin}/helpers/alert-no-items.hbs +0 -0
  29. package/addon/components/import-snippet-plugin/card.ts +119 -0
  30. package/addon/components/insert-variable-plugin/insert-variable-card.hbs +2 -1
  31. package/addon/components/insert-variable-plugin/insert-variable-card.ts +134 -0
  32. package/addon/components/rdfa-date-plugin/{rdfa-date-plugin-card.hbs → card.hbs} +3 -1
  33. package/addon/components/rdfa-date-plugin/card.ts +72 -0
  34. package/addon/components/rdfa-date-plugin/{rdfa-date-time-picker.hbs → date-time-picker.hbs} +0 -0
  35. package/addon/components/rdfa-date-plugin/{rdfa-date-time-picker.js → date-time-picker.ts} +26 -12
  36. package/addon/components/rdfa-date-plugin/{rdfa-date-plugin-insert.hbs → insert.hbs} +0 -0
  37. package/addon/components/rdfa-date-plugin/insert.ts +45 -0
  38. package/addon/components/roadsign-regulation-plugin/expanded-measure.ts +58 -0
  39. package/addon/components/roadsign-regulation-plugin/measure-template.ts +35 -0
  40. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +2 -2
  41. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +60 -0
  42. package/addon/components/roadsign-regulation-plugin/{roadsigns-modal.js → roadsigns-modal.ts} +103 -66
  43. package/addon/components/roadsign-regulation-plugin/{roadsigns-pagination.js → roadsigns-pagination.ts} +7 -3
  44. package/addon/components/roadsign-regulation-plugin/roadsigns-table.ts +32 -0
  45. package/addon/components/standard-template-plugin/{template-card.hbs → card.hbs} +0 -0
  46. package/addon/components/standard-template-plugin/card.ts +11 -0
  47. package/addon/components/standard-template-plugin/template-provider.hbs +3 -1
  48. package/addon/components/standard-template-plugin/template-provider.ts +75 -0
  49. package/addon/components/table-of-contents-plugin/card.hbs +12 -1
  50. package/addon/components/table-of-contents-plugin/card.ts +60 -0
  51. package/addon/components/table-of-contents-plugin/{inline-components → ember-nodes}/outline.hbs +2 -2
  52. package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.hbs +9 -0
  53. package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +95 -0
  54. package/addon/components/template-variable-plugin/template-variable-card.hbs +2 -1
  55. package/addon/components/template-variable-plugin/template-variable-card.ts +227 -0
  56. package/addon/helpers/{limit-text.js → limit-text.ts} +2 -2
  57. package/addon/models/instruction.ts +18 -0
  58. package/addon/models/measure.ts +38 -0
  59. package/addon/models/sign.ts +36 -0
  60. package/addon/models/template.ts +14 -0
  61. package/addon/plugins/article-structure-plugin/commands/index.ts +6 -0
  62. package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +80 -0
  63. package/addon/plugins/article-structure-plugin/commands/move-selected-structure.ts +130 -0
  64. package/addon/plugins/article-structure-plugin/commands/recalculate-structure-numbers.ts +26 -0
  65. package/addon/plugins/article-structure-plugin/commands/remove-structure.ts +21 -0
  66. package/addon/plugins/article-structure-plugin/commands/unwrap-structure.ts +40 -0
  67. package/addon/plugins/article-structure-plugin/commands/wrap-structure-content.ts +66 -0
  68. package/addon/plugins/article-structure-plugin/constants.ts +11 -0
  69. package/addon/plugins/article-structure-plugin/index.ts +70 -0
  70. package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +94 -0
  71. package/addon/plugins/article-structure-plugin/structures/article.ts +129 -0
  72. package/addon/plugins/article-structure-plugin/structures/chapter.ts +83 -0
  73. package/addon/plugins/article-structure-plugin/structures/index.ts +33 -0
  74. package/addon/plugins/article-structure-plugin/structures/section.ts +82 -0
  75. package/addon/plugins/article-structure-plugin/structures/structure-header.ts +65 -0
  76. package/addon/plugins/article-structure-plugin/structures/subsection.ts +83 -0
  77. package/addon/plugins/article-structure-plugin/structures/title.ts +83 -0
  78. package/addon/plugins/article-structure-plugin/utils/namespace.ts +25 -0
  79. package/addon/plugins/article-structure-plugin/utils/structure.ts +162 -0
  80. package/addon/plugins/besluit-plugin/commands/get-article-nodes-for-besluit.ts +30 -0
  81. package/addon/plugins/besluit-plugin/commands/index.ts +4 -0
  82. package/addon/plugins/besluit-plugin/commands/insert-article.ts +70 -0
  83. package/addon/plugins/besluit-plugin/commands/insert-title.ts +67 -0
  84. package/addon/plugins/besluit-plugin/commands/move-article.ts +69 -0
  85. package/addon/plugins/besluit-plugin/commands/recalculate-article-numbers.ts +44 -0
  86. package/addon/plugins/besluit-plugin/index.ts +11 -0
  87. package/addon/plugins/besluit-plugin/utils/get-title-for-decision.ts +35 -0
  88. package/addon/plugins/besluit-type-plugin/index.ts +6 -0
  89. package/addon/{utils/fetchBesluitTypes.js → plugins/besluit-type-plugin/utils/fetchBesluitTypes.ts} +35 -16
  90. package/addon/plugins/citation-plugin/index.ts +216 -0
  91. package/addon/plugins/citation-plugin/marks/citation.ts +27 -0
  92. package/addon/plugins/citation-plugin/utils/cited-text.ts +17 -0
  93. package/addon/{utils/legislation-types.js → plugins/citation-plugin/utils/legislation-types.ts} +17 -3
  94. package/addon/plugins/citation-plugin/utils/process-match.ts +132 -0
  95. package/addon/{utils/vlaamse-codex.js → plugins/citation-plugin/utils/vlaamse-codex.ts} +160 -41
  96. package/addon/plugins/import-snippet-plugin.ts +6 -0
  97. package/addon/plugins/insert-variable-plugin/index.ts +11 -0
  98. package/addon/{utils/variable-plugins/default-variable-types.js → plugins/insert-variable-plugin/utils/constants.ts} +18 -7
  99. package/addon/plugins/insert-variable-plugin/utils/fetch-data.ts +41 -0
  100. package/addon/plugins/rdfa-date-plugin/commands/index.ts +1 -0
  101. package/addon/plugins/rdfa-date-plugin/commands/modify-date.ts +48 -0
  102. package/addon/plugins/rdfa-date-plugin/index.ts +11 -0
  103. package/addon/plugins/roadsign-regulation-plugin/index.ts +6 -0
  104. package/addon/plugins/roadsign-regulation-plugin/utils/constants.ts +8 -0
  105. package/addon/{utils/roadsign-regulation-plugin/fetchData.js → plugins/roadsign-regulation-plugin/utils/fetchData.ts} +20 -3
  106. package/addon/plugins/roadsign-regulation-plugin/utils/includeInstructions.ts +16 -0
  107. package/addon/plugins/standard-template-plugin/index.ts +6 -0
  108. package/addon/plugins/standard-template-plugin/utils/instantiate-uuids.ts +48 -0
  109. package/addon/plugins/table-of-contents-plugin/index.ts +14 -0
  110. package/addon/plugins/table-of-contents-plugin/nodes/index.ts +1 -0
  111. package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +53 -0
  112. package/addon/plugins/table-of-contents-plugin/utils/constants.ts +17 -0
  113. package/addon/plugins/template-variable-plugin/index.ts +6 -0
  114. package/addon/plugins/template-variable-plugin/utils/constants.ts +2 -0
  115. package/addon/plugins/template-variable-plugin/utils/fetch-data.ts +62 -0
  116. package/addon/services/{import-rdfa-snippet.js → import-rdfa-snippet.ts} +48 -36
  117. package/addon/services/roadsign-registry.ts +288 -0
  118. package/addon/services/{standard-template-plugin.js → standard-template-plugin.ts} +17 -11
  119. package/addon/utils/memoize.ts +8 -0
  120. package/addon/utils/option.ts +58 -0
  121. package/addon/utils/sparql-helpers.ts +27 -0
  122. package/app/components/article-structure-plugin/article-structure-card.js +1 -0
  123. package/app/components/article-structure-plugin/structure-card.js +1 -0
  124. package/app/components/{citaten-plugin/citaat-card.js → au-native-input.js} +1 -1
  125. package/app/components/{citaten-plugin/citations/article-list.js → besluit-plugin/besluit-context-card.js} +1 -1
  126. package/app/components/besluit-plugin/besluit-plugin-card.js +1 -0
  127. package/app/components/{citaten-plugin/citations/modal.js → citation-plugin/citation-card.js} +1 -1
  128. package/app/components/citation-plugin/citation-insert.js +1 -0
  129. package/app/components/{citaten-plugin/citations/decision-list.js → citation-plugin/citations/article-list.js} +1 -1
  130. package/app/components/{citaten-plugin → citation-plugin}/citations/article-preview.js +1 -1
  131. package/app/components/{citaten-plugin → citation-plugin}/citations/decision-detail.js +1 -1
  132. package/app/components/citation-plugin/citations/decision-list.js +1 -0
  133. package/app/components/{citaten-plugin → citation-plugin}/citations/decision-preview.js +1 -1
  134. package/app/components/citation-plugin/citations/modal.js +1 -0
  135. package/app/components/{citaten-plugin → citation-plugin}/citations/search-modal.js +1 -1
  136. package/app/components/{citaten-plugin → citation-plugin}/helpers/alert-load-error.js +1 -1
  137. package/app/components/{citaten-plugin → citation-plugin}/helpers/alert-no-items.js +1 -1
  138. package/app/components/{citaten-plugin/citaat-insert.js → rdfa-date-plugin/card.js} +1 -1
  139. package/app/components/rdfa-date-plugin/date-time-picker.js +1 -0
  140. package/app/components/rdfa-date-plugin/insert.js +1 -0
  141. package/app/components/standard-template-plugin/card.js +1 -0
  142. package/app/components/table-of-contents-plugin/ember-nodes/outline.js +1 -0
  143. package/app/components/table-of-contents-plugin/ember-nodes/table-of-contents.js +1 -0
  144. package/app/styles/citaten-plugin.scss +1 -1
  145. package/components/article-structure-plugin/article-structure-card.d.ts +17 -0
  146. package/components/article-structure-plugin/structure-card.d.ts +32 -0
  147. package/components/au-native-input.d.ts +20 -0
  148. package/components/besluit-plugin/besluit-context-card.d.ts +24 -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/helpers/limit-text.d.ts +8 -0
  173. package/index.js +5 -0
  174. package/models/instruction.d.ts +8 -0
  175. package/models/measure.d.ts +14 -0
  176. package/models/sign.d.ts +12 -0
  177. package/models/template.d.ts +13 -0
  178. package/package.json +29 -8
  179. package/plugins/article-structure-plugin/commands/index.d.ts +6 -0
  180. package/plugins/article-structure-plugin/commands/insert-structure.d.ts +5 -0
  181. package/plugins/article-structure-plugin/commands/move-selected-structure.d.ts +10 -0
  182. package/plugins/article-structure-plugin/commands/recalculate-structure-numbers.d.ts +3 -0
  183. package/plugins/article-structure-plugin/commands/remove-structure.d.ts +7 -0
  184. package/plugins/article-structure-plugin/commands/unwrap-structure.d.ts +8 -0
  185. package/plugins/article-structure-plugin/commands/wrap-structure-content.d.ts +8 -0
  186. package/plugins/article-structure-plugin/constants.d.ts +5 -0
  187. package/plugins/article-structure-plugin/index.d.ts +41 -0
  188. package/plugins/article-structure-plugin/structures/article-paragraph.d.ts +4 -0
  189. package/plugins/article-structure-plugin/structures/article.d.ts +6 -0
  190. package/plugins/article-structure-plugin/structures/chapter.d.ts +4 -0
  191. package/plugins/article-structure-plugin/structures/index.d.ts +17 -0
  192. package/plugins/article-structure-plugin/structures/section.d.ts +4 -0
  193. package/plugins/article-structure-plugin/structures/structure-header.d.ts +2 -0
  194. package/plugins/article-structure-plugin/structures/subsection.d.ts +4 -0
  195. package/plugins/article-structure-plugin/structures/title.d.ts +4 -0
  196. package/plugins/article-structure-plugin/utils/namespace.d.ts +6 -0
  197. package/plugins/article-structure-plugin/utils/structure.d.ts +20 -0
  198. package/plugins/besluit-plugin/commands/get-article-nodes-for-besluit.d.ts +5 -0
  199. package/plugins/besluit-plugin/commands/index.d.ts +4 -0
  200. package/plugins/besluit-plugin/commands/insert-article.d.ts +3 -0
  201. package/plugins/besluit-plugin/commands/insert-title.d.ts +2 -0
  202. package/plugins/besluit-plugin/commands/move-article.d.ts +2 -0
  203. package/plugins/besluit-plugin/commands/recalculate-article-numbers.d.ts +2 -0
  204. package/plugins/besluit-plugin/index.d.ts +3 -0
  205. package/plugins/besluit-plugin/utils/get-title-for-decision.d.ts +10 -0
  206. package/plugins/besluit-type-plugin/index.d.ts +2 -0
  207. package/plugins/besluit-type-plugin/utils/fetchBesluitTypes.d.ts +12 -0
  208. package/plugins/citation-plugin/index.d.ts +31 -0
  209. package/plugins/citation-plugin/marks/citation.d.ts +2 -0
  210. package/plugins/citation-plugin/utils/cited-text.d.ts +3 -0
  211. package/plugins/citation-plugin/utils/legislation-types.d.ts +24 -0
  212. package/plugins/citation-plugin/utils/process-match.d.ts +23 -0
  213. package/plugins/citation-plugin/utils/vlaamse-codex.d.ts +56 -0
  214. package/plugins/import-snippet-plugin.d.ts +2 -0
  215. package/plugins/insert-variable-plugin/index.d.ts +2 -0
  216. package/plugins/insert-variable-plugin/utils/constants.d.ts +7 -0
  217. package/plugins/insert-variable-plugin/utils/fetch-data.d.ts +5 -0
  218. package/plugins/rdfa-date-plugin/commands/index.d.ts +1 -0
  219. package/plugins/rdfa-date-plugin/commands/modify-date.d.ts +2 -0
  220. package/plugins/rdfa-date-plugin/index.d.ts +3 -0
  221. package/plugins/roadsign-regulation-plugin/index.d.ts +2 -0
  222. package/plugins/roadsign-regulation-plugin/utils/constants.d.ts +3 -0
  223. package/plugins/roadsign-regulation-plugin/utils/fetchData.d.ts +8 -0
  224. package/plugins/roadsign-regulation-plugin/utils/includeInstructions.d.ts +2 -0
  225. package/plugins/standard-template-plugin/index.d.ts +2 -0
  226. package/plugins/standard-template-plugin/utils/instantiate-uuids.d.ts +15 -0
  227. package/plugins/table-of-contents-plugin/index.d.ts +3 -0
  228. package/plugins/table-of-contents-plugin/nodes/index.d.ts +1 -0
  229. package/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +4 -0
  230. package/plugins/table-of-contents-plugin/utils/constants.d.ts +7 -0
  231. package/plugins/template-variable-plugin/index.d.ts +2 -0
  232. package/plugins/template-variable-plugin/utils/constants.d.ts +1 -0
  233. package/plugins/template-variable-plugin/utils/fetch-data.d.ts +9 -0
  234. package/services/import-rdfa-snippet.d.ts +99 -0
  235. package/services/roadsign-registry.d.ts +42 -0
  236. package/services/standard-template-plugin.d.ts +21 -0
  237. package/translations/en-US.yaml +64 -1
  238. package/translations/nl-BE.yaml +66 -3
  239. package/tsconfig.json +34 -9
  240. package/types/config/environment.d.ts +22 -0
  241. package/types/ember-mu-transform-helpers/transforms/string-set.d.ts +14 -0
  242. package/types/lblod/frontend-gelinkt-notuleren/models/account.d.ts +10 -0
  243. package/types/lblod/frontend-gelinkt-notuleren/models/bestuurseenheid-classificatie-code.d.ts +10 -0
  244. package/types/lblod/frontend-gelinkt-notuleren/models/bestuurseenheid.d.ts +12 -0
  245. package/types/lblod/frontend-gelinkt-notuleren/models/gebruiker-model.d.ts +18 -0
  246. package/types/lblod/frontend-gelinkt-notuleren/services/current-session.d.ts +30 -0
  247. package/types/lblod/marawa/dom-helpers.d.ts +4 -0
  248. package/types/lblod/marawa/ember-object-mock.d.ts +3 -0
  249. package/types/lblod/marawa/node-walker.d.ts +18 -0
  250. package/types/lblod/marawa/range-helpers.d.ts +10 -0
  251. package/types/lblod/marawa/rdfa-attributes.d.ts +25 -0
  252. package/types/lblod/marawa/rdfa-block.d.ts +22 -0
  253. package/types/lblod/marawa/rdfa-context-scanner.d.ts +13 -0
  254. package/types/lblod/marawa/rdfa-helpers.d.ts +22 -0
  255. package/types/lblod/marawa/rich-node.d.ts +50 -0
  256. package/types/lblod/marawa/triple.d.ts +16 -0
  257. package/utils/memoize.d.ts +1 -0
  258. package/utils/option.d.ts +14 -0
  259. package/utils/sparql-helpers.d.ts +7 -0
  260. package/addon/commands/generate-template-command.js +0 -35
  261. package/addon/commands/insert-and-collapse.js +0 -32
  262. package/addon/commands/modify-date-command.js +0 -42
  263. package/addon/components/besluit-type-plugin/toolbar-dropdown.js +0 -188
  264. package/addon/components/citaten-plugin/citaat-card.hbs +0 -76
  265. package/addon/components/citaten-plugin/citaat-card.js +0 -286
  266. package/addon/components/citaten-plugin/citaat-insert.hbs +0 -20
  267. package/addon/components/citaten-plugin/citaat-insert.js +0 -68
  268. package/addon/components/citaten-plugin/citations/search-modal.hbs +0 -175
  269. package/addon/components/import-snippet-plugin/card.js +0 -95
  270. package/addon/components/insert-variable-plugin/insert-variable-card.js +0 -125
  271. package/addon/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -71
  272. package/addon/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -24
  273. package/addon/components/roadsign-regulation-plugin/expanded-measure.js +0 -38
  274. package/addon/components/roadsign-regulation-plugin/measure-template.js +0 -30
  275. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.js +0 -101
  276. package/addon/components/roadsign-regulation-plugin/roadsigns-table.js +0 -24
  277. package/addon/components/standard-template-plugin/template-card.js +0 -7
  278. package/addon/components/standard-template-plugin/template-provider.js +0 -75
  279. package/addon/components/table-of-contents-plugin/card.js +0 -53
  280. package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.hbs +0 -9
  281. package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -100
  282. package/addon/components/template-variable-plugin/template-variable-card.js +0 -230
  283. package/addon/constants.js +0 -24
  284. package/addon/initializers/plugin-initializer.js +0 -75
  285. package/addon/inline-components/table-of-contents.js +0 -43
  286. package/addon/marks/citaten-mark.js +0 -32
  287. package/addon/models/instruction.js +0 -19
  288. package/addon/models/measure.js +0 -46
  289. package/addon/models/sign.js +0 -37
  290. package/addon/models/template.js +0 -9
  291. package/addon/plugins/besluit-type-plugin.js +0 -16
  292. package/addon/plugins/citaten-plugin.js +0 -22
  293. package/addon/plugins/generate-template-plugin.js +0 -16
  294. package/addon/plugins/import-snippet-plugin.js +0 -16
  295. package/addon/plugins/insert-variable-plugin.js +0 -19
  296. package/addon/plugins/rdfa-date-plugin.js +0 -26
  297. package/addon/plugins/roadsign-regulation-plugin.js +0 -24
  298. package/addon/plugins/standard-template-plugin.js +0 -33
  299. package/addon/plugins/table-of-contents-plugin.js +0 -27
  300. package/addon/plugins/template-variable-plugin.js +0 -21
  301. package/addon/services/roadsign-registry.js +0 -240
  302. package/addon/utils/generate-template-plugin/default-resources.js +0 -9
  303. package/addon/utils/instantiate-uuids.js +0 -34
  304. package/addon/utils/memoize.js +0 -8
  305. package/addon/utils/processMatch.js +0 -80
  306. package/addon/utils/roadsign-regulation-plugin/includeInstructions.js +0 -10
  307. package/addon/utils/variable-plugins/fetch-data.js +0 -98
  308. package/app/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -1
  309. package/app/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -1
  310. package/app/components/rdfa-date-plugin/rdfa-date-time-picker.js +0 -1
  311. package/app/components/standard-template-plugin/template-card.js +0 -1
  312. package/app/components/table-of-contents-plugin/inline-components/outline.js +0 -1
  313. package/app/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -1
  314. package/app/initializers/plugin-initializer.js +0 -4
  315. package/types/dummy/index.d.ts +0 -1
  316. package/types/ember-data/types/registries/model.d.ts +0 -6
@@ -0,0 +1,218 @@
1
+ import { tracked } from '@glimmer/tracking';
2
+ import Component from '@glimmer/component';
3
+ import { action } from '@ember/object';
4
+ import { task } from 'ember-concurrency';
5
+ import { getOwner } from '@ember/application';
6
+ import { inject as service } from '@ember/service';
7
+ import {
8
+ addType,
9
+ removeType,
10
+ } from '@lblod/ember-rdfa-editor/commands/type-commands';
11
+ import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
12
+ import CurrentSessionService from '@lblod/frontend-gelinkt-notuleren/services/current-session';
13
+ import { ResolvedPNode } from '@lblod/ember-rdfa-editor/plugins/datastore';
14
+ import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
15
+ import { getRdfaAttribute } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
16
+ import fetchBesluitTypes, {
17
+ BesluitType,
18
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
19
+ declare module 'ember__owner' {
20
+ export default interface Owner {
21
+ resolveRegistration(name: string): unknown;
22
+ }
23
+ }
24
+
25
+ type Args = {
26
+ controller: ProseController;
27
+ };
28
+
29
+ export default class EditorPluginsToolbarDropdownComponent extends Component<Args> {
30
+ @service declare currentSession: CurrentSessionService;
31
+
32
+ /**
33
+ * Actual besluit type selected
34
+ * @property besluitType
35
+ * @type BesluitType
36
+ * @private
37
+ */
38
+ @tracked besluitType?: BesluitType;
39
+ @tracked previousBesluitType?: string;
40
+ @tracked types: BesluitType[] = [];
41
+
42
+ //used to update selections since the other vars dont seem to work in octane
43
+ @tracked besluit?: BesluitType;
44
+ @tracked subBesluit?: BesluitType;
45
+ @tracked subSubBesluit?: BesluitType;
46
+
47
+ @tracked cardExpanded = false;
48
+ @tracked loadDataTaskInstance;
49
+
50
+ constructor(parent: unknown, args: Args) {
51
+ super(parent, args);
52
+ this.loadDataTaskInstance = this.loadData.perform();
53
+ }
54
+
55
+ get controller() {
56
+ return this.args.controller;
57
+ }
58
+
59
+ get doc() {
60
+ return this.controller.state.doc;
61
+ }
62
+
63
+ loadData = task(async () => {
64
+ // eslint-disable-next-line @typescript-eslint/await-thenable
65
+ const bestuurseenheid = await this.currentSession.get('group');
66
+ const classificatie = await bestuurseenheid.get('classificatie');
67
+ const ENV = getOwner(this)?.resolveRegistration('config:environment') as {
68
+ besluitTypePlugin: { endpoint: string };
69
+ };
70
+ const types = await fetchBesluitTypes(classificatie.uri, ENV);
71
+ this.types = types;
72
+ });
73
+
74
+ get currentBesluitRange(): ResolvedPNode | undefined {
75
+ const selection = this.controller.state.selection;
76
+ const currentBesluitRange = [
77
+ ...this.controller.datastore
78
+ .limitToRange(this.controller.state, selection.from, selection.to)
79
+ .match(null, 'a', '>http://data.vlaanderen.be/ns/besluit#Besluit')
80
+ .asSubjectNodeMapping()
81
+ .nodes(),
82
+ ][0];
83
+ return currentBesluitRange;
84
+ }
85
+
86
+ get currentBesluitURI() {
87
+ if (this.currentBesluitRange) {
88
+ const node = unwrap(this.doc.nodeAt(this.currentBesluitRange.from));
89
+ return getRdfaAttribute(node, 'resource').pop();
90
+ }
91
+ return;
92
+ }
93
+
94
+ get showCard() {
95
+ return !!this.currentBesluitRange;
96
+ }
97
+
98
+ @action
99
+ updateBesluitTypes() {
100
+ if (!this.currentBesluitURI) {
101
+ return;
102
+ }
103
+ const besluitTypes = this.controller.datastore
104
+ .match(`>${this.currentBesluitURI}`, 'a', undefined)
105
+ .asQuads();
106
+ const besluitTypesUris = [...besluitTypes].map((quad) => quad.object.value);
107
+ const besluitTypeRelevant = besluitTypesUris.find((type) =>
108
+ type.includes('https://data.vlaanderen.be/id/concept/BesluitType/')
109
+ );
110
+ if (besluitTypeRelevant) {
111
+ this.previousBesluitType = besluitTypeRelevant;
112
+ const besluitType = this.findBesluitTypeByURI(besluitTypeRelevant);
113
+
114
+ const firstAncestor = this.findBesluitTypeParent(besluitType);
115
+ const secondAncestor = this.findBesluitTypeParent(firstAncestor);
116
+ if (firstAncestor && secondAncestor) {
117
+ this.besluit = secondAncestor;
118
+ this.subBesluit = firstAncestor;
119
+ this.subSubBesluit = besluitType;
120
+ } else if (firstAncestor) {
121
+ this.besluit = firstAncestor;
122
+ this.subBesluit = besluitType;
123
+ this.subSubBesluit = undefined;
124
+ } else {
125
+ this.besluit = besluitType;
126
+ this.subBesluit = undefined;
127
+ this.subSubBesluit = undefined;
128
+ }
129
+ this.cardExpanded = false;
130
+ } else {
131
+ this.cardExpanded = true;
132
+ this.besluit = undefined;
133
+ this.subBesluit = undefined;
134
+ this.subSubBesluit = undefined;
135
+ }
136
+ }
137
+
138
+ @action
139
+ updateBesluitType(selected: BesluitType) {
140
+ this.besluit = selected;
141
+ this.besluitType = selected;
142
+ this.subBesluit = undefined;
143
+ this.subSubBesluit = undefined;
144
+ if (!selected.subTypes || !selected.subTypes.length) this.insert();
145
+ }
146
+
147
+ @action
148
+ updateBesluitSubType(selected: BesluitType) {
149
+ this.subBesluit = selected;
150
+ this.besluitType = selected;
151
+ this.subSubBesluit = undefined;
152
+ if (!selected.subTypes || !selected.subTypes.length) this.insert();
153
+ }
154
+
155
+ @action
156
+ updateBesluitSubSubType(selected: BesluitType) {
157
+ this.subSubBesluit = selected;
158
+ this.besluitType = selected;
159
+ if (!selected.subTypes || !selected.subTypes.length) this.insert();
160
+ }
161
+
162
+ findBesluitTypeParent(
163
+ besluitType?: BesluitType,
164
+ array: BesluitType[] = this.types,
165
+ parent?: BesluitType
166
+ ): BesluitType | undefined {
167
+ if (!besluitType || !array) {
168
+ return;
169
+ }
170
+ for (const type of array) {
171
+ if (type == besluitType) {
172
+ return parent;
173
+ } else if (type.subTypes?.length) {
174
+ parent = type;
175
+ return this.findBesluitTypeParent(besluitType, type.subTypes, parent);
176
+ }
177
+ }
178
+ return;
179
+ }
180
+
181
+ findBesluitTypeByURI(
182
+ uri: string,
183
+ types = this.types
184
+ ): BesluitType | undefined {
185
+ if (uri) {
186
+ for (const besluitType of types) {
187
+ if (besluitType.uri === uri) {
188
+ return besluitType;
189
+ } else if (besluitType.subTypes && besluitType.subTypes.length) {
190
+ const subType = this.findBesluitTypeByURI(uri, besluitType.subTypes);
191
+ if (subType) {
192
+ return subType;
193
+ }
194
+ }
195
+ }
196
+ }
197
+ return;
198
+ }
199
+
200
+ insert() {
201
+ if (this.besluitType && this.currentBesluitRange) {
202
+ this.cardExpanded = false;
203
+ this.controller.checkAndDoCommand(
204
+ addType(this.currentBesluitRange.from, this.besluitType.uri)
205
+ );
206
+ if (this.previousBesluitType) {
207
+ this.controller.checkAndDoCommand(
208
+ removeType(this.currentBesluitRange.from, this.previousBesluitType)
209
+ );
210
+ }
211
+ }
212
+ }
213
+
214
+ @action
215
+ toggleCard() {
216
+ this.cardExpanded = !this.cardExpanded;
217
+ }
218
+ }
@@ -0,0 +1,118 @@
1
+ {{#if this.showCard}}
2
+ <AuCard
3
+ @flex={{true}}
4
+ @divided={{true}}
5
+ @isOpenInitially={{true}}
6
+ @expandable={{true}}
7
+ @shadow={{true}}
8
+ @size='small'
9
+ {{did-update
10
+ this.resetToDocumentState
11
+ this.documentText
12
+ this.documentLegislationType
13
+ }}
14
+ as |c|
15
+ >
16
+ <c.header>
17
+ <AuHeading @level='3' @skin='6'>{{t
18
+ 'citaten-plugin.card.title'
19
+ }}</AuHeading>
20
+ </c.header>
21
+ <c.content>
22
+ <div class='au-o-flow au-o-flow--small'>
23
+ <AuFormRow>
24
+ <AuLabel
25
+ for='typeofdocument'
26
+ @inline={{false}}
27
+ @required={{false}}
28
+ @error={{false}}
29
+ @warning={{false}}
30
+ >{{t 'citaten-plugin.search.type'}}</AuLabel>
31
+ <PowerSelect
32
+ id='typeofdocument'
33
+ @allowClear={{false}}
34
+ @disabled={{false}}
35
+ @searchEnabled={{true}}
36
+ @loadingMessage='{{t "citaten-plugin.alert.loading"}}'
37
+ @noMatchesMessage='{{t "citaten-plugin.alert.no-results"}}'
38
+ @searchMessage='{{t "citaten-plugin.search.placeholder"}}'
39
+ @options={{this.legislationTypes}}
40
+ @selected={{this.selectedLegislationTypeLabel}}
41
+ @onChange={{this.selectLegislationType}}
42
+ class='au-u-1-1'
43
+ as |type|
44
+ >
45
+ {{type}}
46
+ </PowerSelect>
47
+ </AuFormRow>
48
+ <AuFormRow>
49
+ <AuLabel
50
+ for='searchterm'
51
+ @inline={{false}}
52
+ @required={{false}}
53
+ @error={{false}}
54
+ @warning={{false}}
55
+ >{{t 'citaten-plugin.search.term'}}</AuLabel>
56
+ <AuNativeInput
57
+ @icon='search'
58
+ @type='text'
59
+ @width='block'
60
+ @iconAlignment='right'
61
+ id='searchterm'
62
+ value={{this.searchText}}
63
+ placeholder={{t 'citaten-plugin.search.placeholder'}}
64
+ {{on 'input' this.onCardTextChange}}
65
+ />
66
+ </AuFormRow>
67
+ <AuFormRow>
68
+ <AuButton
69
+ @skin='link'
70
+ @icon='search'
71
+ @iconAlignment='left'
72
+ {{on 'click' this.openSearchModal}}
73
+ >{{t 'citaten-plugin.search.advanced'}}</AuButton>
74
+ </AuFormRow>
75
+ </div>
76
+ </c.content>
77
+ <c.footer class='au-u-background-gray-100 au-u-padding-none'>
78
+ {{#if this.decisionResource.isRunning}}
79
+ <AuLoader />
80
+ <span class='au-u-hidden-visually'>{{t
81
+ 'citaten-plugin.alert.loading'
82
+ }}</span>
83
+ {{else}}
84
+ {{#if this.error}}
85
+ <CitationPlugin::Helpers::AlertLoadError
86
+ @fullSize={{false}}
87
+ @error={{this.error}}
88
+ />
89
+ {{else}}
90
+ <AuToolbar @border='bottom' @skin='none' class='au-u-padding-small'>
91
+ <AuHeading @skin='6' @level='4'>{{t
92
+ 'citaten-plugin.card.suggestions'
93
+ }}</AuHeading>
94
+ </AuToolbar>
95
+ <div
96
+ class='citaten--decision-list au-u-margin-none au-u-padding-top-tiny au-u-padding-bottom-tiny'
97
+ >
98
+ <CitationPlugin::Citations::DecisionList
99
+ @decisions={{this.decisionResource.value}}
100
+ @onCitationInsert={{this.insertDecisionCitation}}
101
+ @onCitationDetails={{this.openDecisionDetailModal}}
102
+ />
103
+ </div>
104
+ {{/if}}
105
+ {{/if}}
106
+ </c.footer>
107
+ </AuCard>
108
+ {{/if}}
109
+
110
+ <CitationPlugin::Citations::SearchModal
111
+ @open={{this.showModal}}
112
+ @closeModal={{this.closeModal}}
113
+ @insertDecisionCitation={{this.insertDecisionCitation}}
114
+ @insertArticleCitation={{this.insertArticleCitation}}
115
+ @selectedDecision={{this.decision}}
116
+ @legislationTypeUri={{this.legislationTypeUri}}
117
+ @text={{this.searchText}}
118
+ />
@@ -0,0 +1,230 @@
1
+ import Component from '@glimmer/component';
2
+ import { tracked } from '@glimmer/tracking';
3
+ import { restartableTask, timeout } from 'ember-concurrency';
4
+ import { action } from '@ember/object';
5
+ import { capitalize } from '@ember/string';
6
+ import {
7
+ Article,
8
+ cleanCaches,
9
+ Decision,
10
+ fetchDecisions,
11
+ } from '../../plugins/citation-plugin/utils/vlaamse-codex';
12
+ import { task as trackedTask } from 'ember-resources/util/ember-concurrency';
13
+ import {
14
+ Option,
15
+ unwrap,
16
+ unwrapOr,
17
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
18
+ import {
19
+ CitationDecoration,
20
+ CitationPlugin,
21
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
22
+ import { ProseController, Transaction } from '@lblod/ember-rdfa-editor';
23
+ import { citedText } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/cited-text';
24
+ import {
25
+ LEGISLATION_TYPES,
26
+ LEGISLATION_TYPE_CONCEPTS,
27
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/legislation-types';
28
+
29
+ interface Args {
30
+ controller: ProseController;
31
+ widgetArgs: {
32
+ plugin: CitationPlugin;
33
+ };
34
+ }
35
+
36
+ export default class CitationCardComponent extends Component<Args> {
37
+ @tracked pageNumber = 0;
38
+ @tracked pageSize = 5;
39
+ @tracked totalSize = 0;
40
+ @tracked totalCount = 0;
41
+ @tracked decisions = [];
42
+ @tracked error: unknown;
43
+ @tracked showModal = false;
44
+ @tracked decision: Decision | null = null;
45
+ @tracked cardText: string | null = null;
46
+ @tracked cardLegislationType: string | null = null;
47
+
48
+ get controller(): ProseController {
49
+ return this.args.controller;
50
+ }
51
+
52
+ get showCard() {
53
+ return this.activeDecoration;
54
+ }
55
+
56
+ get plugin() {
57
+ return this.args.widgetArgs.plugin;
58
+ }
59
+
60
+ get decorations() {
61
+ return this.plugin.getState(this.controller.state)?.highlights;
62
+ }
63
+
64
+ get activeDecoration(): Option<CitationDecoration> {
65
+ const { from, to } = this.controller.state.selection;
66
+ return this.decorations?.find(from, to)[0];
67
+ }
68
+
69
+ get documentLegislationType(): Option<string> {
70
+ return this.activeDecoration?.spec.legislationTypeUri;
71
+ }
72
+
73
+ get documentText(): Option<string> {
74
+ return this.activeDecoration?.spec.searchText;
75
+ }
76
+
77
+ get searchText(): string {
78
+ return (this.cardText ?? this.documentText) || '';
79
+ }
80
+
81
+ get legislationTypes() {
82
+ return Object.keys(LEGISLATION_TYPES).map(capitalize);
83
+ }
84
+
85
+ get selectedLegislationType() {
86
+ const type = this.cardLegislationType || this.documentLegislationType;
87
+ const found = LEGISLATION_TYPE_CONCEPTS.find((c) => c.value === type);
88
+ return found || unwrap(LEGISLATION_TYPE_CONCEPTS[0]);
89
+ }
90
+
91
+ get selectedLegislationTypeLabel(): string {
92
+ return capitalize(this.selectedLegislationType.label);
93
+ }
94
+
95
+ get selectedLegislationTypeUri(): string {
96
+ return this.selectedLegislationType.value;
97
+ }
98
+
99
+ @action resetToDocumentState(): void {
100
+ this.cardText = null;
101
+ this.cardLegislationType = null;
102
+ }
103
+
104
+ @action onCardTextChange(event: InputEvent): void {
105
+ this.cardText = (event.target as HTMLInputElement).value;
106
+ }
107
+
108
+ resourceSearch = restartableTask(async () => {
109
+ await timeout(100);
110
+ this.error = null;
111
+ const abortController = new AbortController();
112
+ try {
113
+ // Split search string by grouping on non-whitespace characters
114
+ // This probably needs to be more complex to search on group of words
115
+ const words = this.searchText.match(/\S+/g) || [];
116
+ const filter = {
117
+ type: unwrapOr('', this.selectedLegislationTypeUri),
118
+ };
119
+ const results = await fetchDecisions(
120
+ words,
121
+ filter,
122
+ this.pageNumber,
123
+ this.pageSize
124
+ );
125
+ this.totalCount = results.totalCount;
126
+ return results.decisions;
127
+ } catch (e) {
128
+ console.warn(e); // eslint-ignore-line no-console
129
+ this.totalCount = 0;
130
+ this.error = e;
131
+ return [];
132
+ } finally {
133
+ //Abort all requests now that this task has either successfully finished or has been cancelled
134
+ abortController.abort();
135
+ }
136
+ });
137
+
138
+ decisionResource = trackedTask(this, this.resourceSearch, () => [
139
+ this.searchText,
140
+ this.selectedLegislationType,
141
+ this.pageNumber,
142
+ this.pageSize,
143
+ ]);
144
+
145
+ @action
146
+ selectLegislationType(type: string) {
147
+ type = type.toLowerCase();
148
+ const found = LEGISLATION_TYPE_CONCEPTS.find(
149
+ (c) => c.label.toLowerCase() === type
150
+ );
151
+ this.cardLegislationType = found
152
+ ? found.value
153
+ : unwrap(LEGISLATION_TYPE_CONCEPTS[0]).value;
154
+ }
155
+
156
+ @action
157
+ openDecisionDetailModal(decision: Decision): void {
158
+ this.decision = decision;
159
+ /** why focus? see {@link EditorPluginsCitationInsertComponent.openModal } */
160
+ this.focus();
161
+ this.showModal = true;
162
+ }
163
+
164
+ @action
165
+ async openSearchModal(): Promise<void> {
166
+ await this.decisionResource.cancel();
167
+ this.decision = null;
168
+ this.focus();
169
+ this.showModal = true;
170
+ }
171
+
172
+ @action
173
+ closeModal(lastSearchType: string, lastSearchTerm: string): void {
174
+ this.showModal = false;
175
+ this.decision = null;
176
+ if (lastSearchType) {
177
+ this.cardLegislationType = lastSearchType;
178
+ }
179
+ if (lastSearchTerm) {
180
+ this.cardText = lastSearchTerm;
181
+ }
182
+ }
183
+
184
+ @action
185
+ insertDecisionCitation(decision: Decision): void {
186
+ const uri = decision.uri;
187
+ const title = decision.title ?? '';
188
+ const { from, to } = unwrap(this.activeDecoration);
189
+ this.controller.withTransaction((tr: Transaction) =>
190
+ tr
191
+ .replaceRangeWith(
192
+ from,
193
+ to,
194
+ citedText(this.controller.schema, title, uri)
195
+ )
196
+ .scrollIntoView()
197
+ );
198
+ }
199
+
200
+ @action
201
+ insertArticleCitation(decision: Decision, article: Article): void {
202
+ const uri = article.uri;
203
+ let title = '';
204
+ if (decision.title) {
205
+ title = `${decision.title}, ${article.number || ''}`;
206
+ }
207
+ const { from, to } = unwrap(this.activeDecoration);
208
+ this.controller.withTransaction((tr: Transaction) =>
209
+ tr
210
+ .replaceRangeWith(
211
+ from,
212
+ to,
213
+ citedText(this.controller.schema, title, uri)
214
+ )
215
+ .scrollIntoView()
216
+ );
217
+ }
218
+
219
+ @action
220
+ focus(): void {
221
+ this.controller.focus();
222
+ }
223
+
224
+ willDestroy(): void {
225
+ // Not necessary as ember-concurrency does this for us.
226
+ // this.decisionResource.cancel();
227
+ cleanCaches();
228
+ super.willDestroy();
229
+ }
230
+ }
@@ -0,0 +1,20 @@
1
+ <AuList::Item>
2
+ <AuButton
3
+ @icon='add'
4
+ @iconAlignment='left'
5
+ @skin='link'
6
+ @disabled={{this.disableInsert}}
7
+ {{on 'click' this.openModal}}
8
+ >
9
+ {{t 'citaten-plugin.insert.title'}}
10
+ </AuButton>
11
+ </AuList::Item>
12
+
13
+ <CitationPlugin::Citations::SearchModal
14
+ @open={{this.showModal}}
15
+ @closeModal={{this.closeModal}}
16
+ @insertDecisionCitation={{this.insertDecisionCitation}}
17
+ @insertArticleCitation={{this.insertArticleCitation}}
18
+ @legislationTypeUri={{this.legislationTypeUri}}
19
+ @text={{this.text}}
20
+ />
@@ -0,0 +1,102 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+ import { tracked } from '@glimmer/tracking';
4
+ import {
5
+ Fragment,
6
+ ProseController,
7
+ Slice,
8
+ Transaction,
9
+ } from '@lblod/ember-rdfa-editor';
10
+ import {
11
+ Article,
12
+ Decision,
13
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/vlaamse-codex';
14
+ import { citedText } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/cited-text';
15
+ import { CitationPlugin } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
16
+ import { LEGISLATION_TYPES } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/legislation-types';
17
+
18
+ interface Args {
19
+ controller: ProseController;
20
+ widgetArgs: { plugin: CitationPlugin };
21
+ }
22
+
23
+ export default class EditorPluginsCitationInsertComponent extends Component<Args> {
24
+ @tracked showModal = false;
25
+ @tracked legislationTypeUri = LEGISLATION_TYPES.decreet;
26
+ @tracked text = '';
27
+
28
+ get disableInsert() {
29
+ if (!this.activeRanges) {
30
+ return true;
31
+ }
32
+ const { from } = this.controller.state.selection;
33
+ return !this.activeRanges.some(
34
+ ([start, end]) => from > start && from < end
35
+ );
36
+ }
37
+
38
+ get plugin() {
39
+ return this.args.widgetArgs.plugin;
40
+ }
41
+
42
+ get activeRanges() {
43
+ return this.plugin.getState(this.controller.state)?.activeRanges;
44
+ }
45
+
46
+ get controller() {
47
+ return this.args.controller;
48
+ }
49
+
50
+ @action
51
+ openModal() {
52
+ // we focus BEFORE openening the modal, since the modal uses ember-focus-trap
53
+ // that takes control of the focus, and gives it back when disabled
54
+ // so we have to reset the focus to the editor before opening (because
55
+ // we lost it upon clicking the button)
56
+ this.controller.focus();
57
+ this.showModal = true;
58
+ }
59
+
60
+ @action
61
+ closeModal() {
62
+ this.showModal = false;
63
+ }
64
+
65
+ @action
66
+ insertDecisionCitation(decision: Decision) {
67
+ const type = decision.legislationType?.label || '';
68
+ const uri = decision.uri;
69
+ const title = decision.title ?? '';
70
+ this.controller.withTransaction((tr: Transaction) =>
71
+ tr
72
+ .replaceSelection(
73
+ new Slice(
74
+ Fragment.fromArray([
75
+ this.controller.schema.text(`${type} `),
76
+ citedText(this.controller.schema, title, uri),
77
+ ]),
78
+ 0,
79
+ 0
80
+ )
81
+ )
82
+ .scrollIntoView()
83
+ );
84
+ }
85
+
86
+ @action
87
+ insertArticleCitation(decision: Decision, article: Article) {
88
+ const type = decision.legislationType?.label || '';
89
+ const uri = article.uri;
90
+ let title = '';
91
+ if (decision.title) {
92
+ title = `${decision.title}, ${article.number ?? ''}`;
93
+ }
94
+ const { from, to } = this.args.controller.state.selection;
95
+ this.controller.withTransaction((tr: Transaction) =>
96
+ tr.replaceWith(from, to, [
97
+ this.controller.schema.text(`${type} `),
98
+ citedText(this.controller.schema, title, uri),
99
+ ])
100
+ );
101
+ }
102
+ }
@@ -2,12 +2,12 @@
2
2
  <AuList @direction="vertical" @divider={{true}}>
3
3
  {{#each @articles as |article|}}
4
4
  <AuList::Item>
5
- <CitatenPlugin::Citations::ArticlePreview
5
+ <CitationPlugin::Citations::ArticlePreview
6
6
  @insertArticleCitation={{fn @insertArticleCitation article}}
7
7
  @article={{article}} />
8
8
  </AuList::Item>
9
9
  {{/each}}
10
10
  </AuList>
11
11
  {{else}}
12
- <CitatenPlugin::Helpers::AlertNoItems @fullSize={{@fullSize}} class={{if @fullSize "au-u-margin"}}/>
12
+ <CitationPlugin::Helpers::AlertNoItems @fullSize={{@fullSize}} class={{if @fullSize "au-u-margin"}}/>
13
13
  {{/if}}