@lblod/ember-rdfa-editor-lblod-plugins 16.3.0 → 17.0.0-dev.f473cdfb5868261b49cdae52ea2558970c082d01

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 (418) hide show
  1. package/.changeset/afraid-tips-visit.md +5 -0
  2. package/.changeset/chilly-ravens-think.md +6 -0
  3. package/.changeset/hot-owls-laugh.md +5 -0
  4. package/.changeset/olive-pets-cheer.md +5 -0
  5. package/.changeset/smooth-fireants-doubt.md +5 -0
  6. package/.changeset/tall-carrots-ring.md +5 -0
  7. package/.changeset/wet-baboons-serve.md +5 -0
  8. package/.changeset/witty-suns-speak.md +5 -0
  9. package/.woodpecker/.release-commit.yml +18 -0
  10. package/.woodpecker/.release.yml +21 -0
  11. package/.woodpecker/.verify-pr.yml +30 -0
  12. package/CHANGELOG.md +20 -0
  13. package/Dockerfile +6 -4
  14. package/addon/commands/index.ts +1 -0
  15. package/addon/commands/replace-selection-and-select-node.ts +24 -0
  16. package/addon/components/article-structure-plugin/article-structure-card.hbs +2 -1
  17. package/addon/components/article-structure-plugin/article-structure-card.ts +2 -0
  18. package/addon/components/article-structure-plugin/structure-card.hbs +7 -6
  19. package/addon/components/article-structure-plugin/structure-card.ts +49 -35
  20. package/addon/components/au-native-input.hbs +1 -0
  21. package/addon/components/au-native-input.ts +2 -1
  22. package/addon/components/besluit-type-plugin/besluit-type-select.hbs +3 -2
  23. package/addon/components/besluit-type-plugin/besluit-type-select.ts +4 -0
  24. package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +5 -4
  25. package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +48 -20
  26. package/addon/components/citation-plugin/citation-card.hbs +4 -3
  27. package/addon/components/citation-plugin/citation-card.ts +9 -2
  28. package/addon/components/citation-plugin/citation-insert.hbs +2 -1
  29. package/addon/components/citation-plugin/citation-insert.ts +3 -0
  30. package/addon/components/citation-plugin/citations/article-list.hbs +2 -2
  31. package/addon/components/citation-plugin/citations/article-preview.hbs +3 -2
  32. package/addon/components/citation-plugin/citations/article-preview.ts +2 -0
  33. package/addon/components/citation-plugin/citations/legal-document-detail.hbs +19 -11
  34. package/addon/components/citation-plugin/citations/legal-document-detail.ts +18 -1
  35. package/addon/components/citation-plugin/citations/legal-document-list.hbs +2 -2
  36. package/addon/components/citation-plugin/citations/legal-document-preview.hbs +10 -9
  37. package/addon/components/citation-plugin/citations/legal-document-preview.ts +9 -0
  38. package/addon/components/citation-plugin/citations/search-modal.hbs +7 -8
  39. package/addon/components/citation-plugin/citations/search-modal.ts +3 -0
  40. package/addon/components/common/search/alert-load-error.gts +34 -0
  41. package/addon/components/common/search/alert-no-items.gts +18 -0
  42. package/addon/components/common/search/loading.hbs +4 -0
  43. package/addon/components/confidentiality-plugin/redact.gts +13 -0
  44. package/addon/components/decision-plugin/decision-plugin-card.hbs +4 -3
  45. package/addon/components/decision-plugin/decision-plugin-card.ts +3 -0
  46. package/addon/components/document-title-plugin/insert-title-card.hbs +8 -1
  47. package/addon/components/document-title-plugin/insert-title-card.ts +3 -0
  48. package/addon/components/generic-rdfa-variable/insert-menu.hbs +2 -1
  49. package/addon/components/generic-rdfa-variable/insert-menu.ts +3 -1
  50. package/addon/components/hover-tooltip.hbs +1 -0
  51. package/addon/components/import-snippet-plugin/card.hbs +1 -0
  52. package/addon/components/import-snippet-plugin/card.ts +7 -2
  53. package/addon/components/loading-alert.hbs +2 -1
  54. package/addon/components/loading-alert.ts +5 -2
  55. package/addon/components/pagination/pagination-view.gts +55 -0
  56. package/addon/components/roadsign-regulation-plugin/expanded-measure.hbs +28 -37
  57. package/addon/components/roadsign-regulation-plugin/expanded-measure.ts +4 -13
  58. package/addon/components/roadsign-regulation-plugin/measure-template.hbs +1 -0
  59. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +2 -1
  60. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +3 -0
  61. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.hbs +1 -0
  62. package/addon/components/roadsign-regulation-plugin/roadsigns-pagination.hbs +9 -4
  63. package/addon/components/roadsign-regulation-plugin/roadsigns-pagination.ts +5 -0
  64. package/addon/components/roadsign-regulation-plugin/roadsigns-table.hbs +7 -6
  65. package/addon/components/roadsign-regulation-plugin/roadsigns-table.ts +5 -0
  66. package/addon/components/snippet-plugin/search-modal.hbs +5 -6
  67. package/addon/components/snippet-plugin/snippet-insert-rdfa.hbs +7 -0
  68. package/addon/components/snippet-plugin/snippet-insert-rdfa.ts +78 -0
  69. package/addon/components/snippet-plugin/snippet-insert.hbs +3 -1
  70. package/addon/components/snippet-plugin/snippet-insert.ts +25 -4
  71. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +4 -6
  72. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +3 -3
  73. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +3 -2
  74. package/addon/components/snippet-plugin/snippet-list-select-rdfa.hbs +8 -0
  75. package/addon/components/snippet-plugin/snippet-list-select-rdfa.ts +69 -0
  76. package/addon/components/snippet-plugin/snippet-list-select.hbs +2 -1
  77. package/addon/components/snippet-plugin/snippet-list-select.ts +2 -1
  78. package/addon/components/snippet-plugin/snippets/snippet-preview.hbs +1 -0
  79. package/addon/components/standard-template-plugin/card.hbs +2 -1
  80. package/addon/components/standard-template-plugin/card.ts +2 -0
  81. package/addon/components/standard-template-plugin/template-provider.hbs +1 -0
  82. package/addon/components/standard-template-plugin/template-provider.ts +10 -4
  83. package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.hbs +1 -0
  84. package/addon/components/table-of-contents-plugin/toolbar-button.hbs +1 -0
  85. package/addon/components/template-comments-plugin/edit-card.hbs +4 -3
  86. package/addon/components/template-comments-plugin/edit-card.ts +7 -0
  87. package/addon/components/template-comments-plugin/insert.hbs +2 -1
  88. package/addon/components/template-comments-plugin/insert.ts +3 -0
  89. package/addon/components/template-comments-plugin/template-comment.hbs +2 -1
  90. package/addon/components/template-comments-plugin/template-comment.ts +3 -0
  91. package/addon/components/validation-plugin/validation-card.hbs +1 -0
  92. package/addon/components/validation-plugin/validation-item.hbs +1 -0
  93. package/addon/components/validation-plugin/validation-item.ts +7 -4
  94. package/addon/components/variable-plugin/address/edit.hbs +1 -0
  95. package/addon/components/variable-plugin/address/edit.ts +5 -3
  96. package/addon/components/variable-plugin/address/insert-variable.hbs +1 -0
  97. package/addon/components/variable-plugin/address/insert.hbs +3 -2
  98. package/addon/components/variable-plugin/address/insert.ts +3 -0
  99. package/addon/components/variable-plugin/address/nodeview.hbs +4 -3
  100. package/addon/components/variable-plugin/address/nodeview.ts +9 -0
  101. package/addon/components/variable-plugin/address/utils.ts +28 -3
  102. package/addon/components/variable-plugin/codelist/edit.hbs +1 -0
  103. package/addon/components/variable-plugin/codelist/edit.ts +24 -7
  104. package/addon/components/variable-plugin/codelist/insert.hbs +1 -0
  105. package/addon/components/variable-plugin/codelist/insert.ts +52 -17
  106. package/addon/components/variable-plugin/date/date-time-picker.hbs +1 -0
  107. package/addon/components/variable-plugin/date/edit.hbs +27 -31
  108. package/addon/components/variable-plugin/date/edit.ts +47 -8
  109. package/addon/components/variable-plugin/date/help-modal.hbs +1 -0
  110. package/addon/components/variable-plugin/date/insert-variable.hbs +1 -0
  111. package/addon/components/variable-plugin/date/insert-variable.ts +36 -10
  112. package/addon/components/variable-plugin/date/insert.hbs +2 -1
  113. package/addon/components/variable-plugin/date/insert.ts +38 -10
  114. package/addon/components/variable-plugin/date/nodeview.hbs +4 -3
  115. package/addon/components/variable-plugin/date/nodeview.ts +11 -1
  116. package/addon/components/variable-plugin/insert-variable-card.hbs +1 -0
  117. package/addon/components/variable-plugin/insert-variable-card.ts +9 -1
  118. package/addon/components/variable-plugin/location/edit.hbs +1 -0
  119. package/addon/components/variable-plugin/location/edit.ts +1 -9
  120. package/addon/components/variable-plugin/location/insert.hbs +1 -0
  121. package/addon/components/variable-plugin/location/insert.ts +4 -7
  122. package/addon/components/variable-plugin/location/nodeview.hbs +19 -8
  123. package/addon/components/variable-plugin/location/nodeview.ts +37 -9
  124. package/addon/components/variable-plugin/number/insert.hbs +1 -0
  125. package/addon/components/variable-plugin/number/insert.ts +34 -10
  126. package/addon/components/variable-plugin/number/nodeview.hbs +7 -5
  127. package/addon/components/variable-plugin/number/nodeview.ts +32 -5
  128. package/addon/components/variable-plugin/text/insert.hbs +1 -0
  129. package/addon/components/variable-plugin/text/insert.ts +40 -12
  130. package/addon/components/variable-plugin/variable/nodeview.hbs +12 -8
  131. package/addon/components/variable-plugin/variable/nodeview.ts +16 -9
  132. package/addon/components/worship-plugin/administrative-unit-picker.hbs +16 -0
  133. package/addon/components/worship-plugin/administrative-unit-picker.ts +38 -0
  134. package/addon/components/worship-plugin/insert.hbs +18 -0
  135. package/addon/components/worship-plugin/insert.ts +41 -0
  136. package/addon/components/worship-plugin/list.hbs +46 -0
  137. package/addon/components/worship-plugin/search-modal.hbs +79 -0
  138. package/addon/components/worship-plugin/search-modal.ts +131 -0
  139. package/addon/components/worship-plugin/sortable-table-header.hbs +36 -0
  140. package/addon/components/worship-plugin/sortable-table-header.ts +45 -0
  141. package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +82 -15
  142. package/addon/plugins/article-structure-plugin/commands/move-selected-structure.ts +2 -1
  143. package/addon/plugins/article-structure-plugin/commands/recalculate-structure-numbers.ts +70 -2
  144. package/addon/plugins/article-structure-plugin/commands/remove-structure.ts +1 -1
  145. package/addon/plugins/article-structure-plugin/commands/set-structure-start-number.ts +5 -14
  146. package/addon/plugins/article-structure-plugin/commands/unwrap-structure.ts +1 -1
  147. package/addon/plugins/article-structure-plugin/commands/wrap-structure-content.ts +197 -105
  148. package/addon/plugins/article-structure-plugin/index.ts +16 -7
  149. package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +181 -71
  150. package/addon/plugins/article-structure-plugin/structures/article.ts +91 -98
  151. package/addon/plugins/article-structure-plugin/structures/chapter.ts +89 -39
  152. package/addon/plugins/article-structure-plugin/structures/index.ts +12 -1
  153. package/addon/plugins/article-structure-plugin/structures/section.ts +88 -39
  154. package/addon/plugins/article-structure-plugin/structures/structure-header-number.ts +56 -0
  155. package/addon/plugins/article-structure-plugin/structures/structure-header-title.ts +38 -0
  156. package/addon/plugins/article-structure-plugin/structures/structure-header.ts +87 -73
  157. package/addon/plugins/article-structure-plugin/structures/subsection.ts +81 -39
  158. package/addon/plugins/article-structure-plugin/structures/title.ts +91 -39
  159. package/addon/plugins/article-structure-plugin/utils/structure.ts +223 -127
  160. package/addon/plugins/citation-plugin/utils/cited-text.ts +38 -8
  161. package/addon/plugins/confidentiality-plugin/marks/redacted.ts +1 -1
  162. package/addon/plugins/document-title-plugin/nodes/document-title.ts +4 -3
  163. package/addon/plugins/roadsign-regulation-plugin/nodes.ts +4 -3
  164. package/addon/plugins/snippet-plugin/commands/index.ts +1 -0
  165. package/addon/plugins/snippet-plugin/commands/update-snippet-ids.ts +55 -0
  166. package/addon/plugins/snippet-plugin/index.ts +6 -1
  167. package/addon/plugins/snippet-plugin/utils/fetch-data.ts +1 -3
  168. package/addon/plugins/snippet-plugin/utils/rdfa-predicate.ts +33 -0
  169. package/addon/plugins/standard-template-plugin/utils/nodes.ts +293 -81
  170. package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +3 -2
  171. package/addon/plugins/variable-plugin/utils/attribute-parsers.ts +19 -1
  172. package/addon/plugins/variable-plugin/utils/dom-constructors.ts +3 -3
  173. package/addon/plugins/variable-plugin/variables/address.ts +93 -26
  174. package/addon/plugins/variable-plugin/variables/codelist.ts +99 -50
  175. package/addon/plugins/variable-plugin/variables/date.ts +143 -53
  176. package/addon/plugins/variable-plugin/variables/location.ts +1 -0
  177. package/addon/plugins/variable-plugin/variables/number.ts +99 -52
  178. package/addon/plugins/variable-plugin/variables/text.ts +80 -28
  179. package/addon/plugins/worship-plugin/index.ts +9 -0
  180. package/addon/plugins/worship-plugin/utils/fetchAdministrativeUnits.ts +52 -0
  181. package/addon/plugins/worship-plugin/utils/fetchWorshipServices.ts +109 -0
  182. package/addon/plugins/worship-plugin/utils/insertWorshipService.ts +16 -0
  183. package/addon/utils/_private/find-insertion-range.ts +18 -5
  184. package/addon/utils/dom-utils.ts +4 -0
  185. package/addon/utils/namespace.ts +63 -13
  186. package/addon/utils/sparql-helpers.ts +8 -0
  187. package/app/components/{citation-plugin/helpers/alert-no-items.js → common/search/alert-load-error.js} +1 -1
  188. package/app/components/{snippet-plugin/helpers → common/search}/alert-no-items.js +1 -1
  189. package/app/components/{snippet-plugin/helpers/alert-load-error.js → common/search/loading.js} +1 -1
  190. package/app/components/{citation-plugin/helpers/alert-load-error.js → snippet-plugin/snippet-list-insert-rdfa.js} +1 -1
  191. package/app/components/snippet-plugin/snippet-list-select-rdfa.js +1 -0
  192. package/app/components/worship-plugin/administrative-unit-picker.js +1 -0
  193. package/app/components/worship-plugin/insert.js +1 -0
  194. package/app/components/worship-plugin/list.js +1 -0
  195. package/app/components/worship-plugin/search-modal.js +1 -0
  196. package/app/components/worship-plugin/sortable-table-header.js +1 -0
  197. package/app/styles/article-structure-plugin.scss +106 -3
  198. package/app/styles/citaten-plugin.scss +1 -1
  199. package/app/styles/snippet-plugin.scss +1 -1
  200. package/app/styles/worship-plugin.scss +19 -0
  201. package/declarations/addon/commands/index.d.ts +1 -0
  202. package/declarations/addon/commands/replace-selection-and-select-node.d.ts +3 -0
  203. package/{components → declarations/addon/components}/article-structure-plugin/article-structure-card.d.ts +1 -0
  204. package/{components → declarations/addon/components}/article-structure-plugin/structure-card.d.ts +5 -2
  205. package/{components → declarations/addon/components}/au-native-input.d.ts +2 -1
  206. package/{components → declarations/addon/components}/besluit-type-plugin/besluit-type-select.d.ts +1 -0
  207. package/{components → declarations/addon/components}/besluit-type-plugin/toolbar-dropdown.d.ts +4 -5
  208. package/{components → declarations/addon/components}/citation-plugin/citation-card.d.ts +3 -2
  209. package/{components → declarations/addon/components}/citation-plugin/citation-insert.d.ts +1 -0
  210. package/declarations/addon/components/citation-plugin/citations/article-list.d.ts +1 -0
  211. package/{components → declarations/addon/components}/citation-plugin/citations/article-preview.d.ts +2 -1
  212. package/{components → declarations/addon/components}/citation-plugin/citations/legal-document-detail.d.ts +8 -1
  213. package/declarations/addon/components/citation-plugin/citations/legal-document-list.d.ts +1 -0
  214. package/declarations/addon/components/citation-plugin/citations/legal-document-preview.d.ts +14 -0
  215. package/{components → declarations/addon/components}/citation-plugin/citations/search-modal.d.ts +1 -0
  216. package/declarations/addon/components/common/search/alert-load-error.d.ts +4 -0
  217. package/declarations/addon/components/common/search/alert-no-items.d.ts +4 -0
  218. package/declarations/addon/components/common/search/loading.d.ts +1 -0
  219. package/declarations/addon/components/confidentiality-plugin/redact.d.ts +4 -0
  220. package/declarations/addon/components/confidentiality-plugin/toolbar.d.ts +1 -0
  221. package/{components → declarations/addon/components}/decision-plugin/decision-plugin-card.d.ts +1 -0
  222. package/{components → declarations/addon/components}/document-title-plugin/insert-title-card.d.ts +1 -0
  223. package/{components → declarations/addon/components}/generic-rdfa-variable/insert-menu.d.ts +1 -0
  224. package/{components → declarations/addon/components}/import-snippet-plugin/card.d.ts +6 -5
  225. package/{components → declarations/addon/components}/loading-alert.d.ts +1 -0
  226. package/declarations/addon/components/pagination/pagination-view.d.ts +4 -0
  227. package/{components → declarations/addon/components}/roadsign-regulation-plugin/expanded-measure.d.ts +2 -2
  228. package/{components → declarations/addon/components}/roadsign-regulation-plugin/roadsign-regulation-card.d.ts +1 -0
  229. package/{components → declarations/addon/components}/roadsign-regulation-plugin/roadsigns-pagination.d.ts +2 -0
  230. package/{components → declarations/addon/components}/roadsign-regulation-plugin/roadsigns-table.d.ts +2 -0
  231. package/declarations/addon/components/snippet-plugin/snippet-insert-rdfa.d.ts +19 -0
  232. package/{components → declarations/addon/components}/snippet-plugin/snippet-insert.d.ts +3 -0
  233. package/declarations/addon/components/snippet-plugin/snippet-list-select-rdfa.d.ts +21 -0
  234. package/{components → declarations/addon/components}/snippet-plugin/snippet-list-select.d.ts +1 -0
  235. package/declarations/addon/components/snippet-plugin/snippets/snippet-list.d.ts +1 -0
  236. package/{components → declarations/addon/components}/standard-template-plugin/card.d.ts +1 -0
  237. package/declarations/addon/components/table-of-contents-plugin/ember-nodes/outline.d.ts +1 -0
  238. package/{components → declarations/addon/components}/template-comments-plugin/edit-card.d.ts +3 -0
  239. package/{components → declarations/addon/components}/template-comments-plugin/insert.d.ts +1 -0
  240. package/{components → declarations/addon/components}/template-comments-plugin/template-comment.d.ts +1 -0
  241. package/{components → declarations/addon/components}/validation-plugin/validation-item.d.ts +2 -2
  242. package/{components → declarations/addon/components}/variable-plugin/address/edit.d.ts +2 -2
  243. package/{components → declarations/addon/components}/variable-plugin/address/insert.d.ts +1 -0
  244. package/{components → declarations/addon/components}/variable-plugin/address/nodeview.d.ts +2 -0
  245. package/{components → declarations/addon/components}/variable-plugin/date/edit.d.ts +4 -2
  246. package/{components → declarations/addon/components}/variable-plugin/date/insert.d.ts +1 -0
  247. package/{components → declarations/addon/components}/variable-plugin/date/nodeview.d.ts +2 -0
  248. package/{components → declarations/addon/components}/variable-plugin/insert-variable-card.d.ts +9 -1
  249. package/{components → declarations/addon/components}/variable-plugin/location/edit.d.ts +0 -1
  250. package/declarations/addon/components/variable-plugin/location/nodeview.d.ts +11 -0
  251. package/{components → declarations/addon/components}/variable-plugin/number/nodeview.d.ts +4 -1
  252. package/{components → declarations/addon/components}/variable-plugin/text/insert.d.ts +1 -1
  253. package/declarations/addon/components/variable-plugin/utils/label-input.d.ts +1 -0
  254. package/declarations/addon/components/variable-plugin/variable/nodeview.d.ts +11 -0
  255. package/declarations/addon/components/worship-plugin/administrative-unit-picker.d.ts +12 -0
  256. package/declarations/addon/components/worship-plugin/insert.d.ts +17 -0
  257. package/declarations/addon/components/worship-plugin/list.d.ts +1 -0
  258. package/declarations/addon/components/worship-plugin/search-modal.d.ts +30 -0
  259. package/declarations/addon/components/worship-plugin/sortable-table-header.d.ts +16 -0
  260. package/declarations/addon/plugins/article-structure-plugin/commands/recalculate-structure-numbers.d.ts +3 -0
  261. package/declarations/addon/plugins/article-structure-plugin/commands/set-structure-start-number.d.ts +7 -0
  262. package/{plugins → declarations/addon/plugins}/article-structure-plugin/index.d.ts +15 -7
  263. package/{plugins → declarations/addon/plugins}/article-structure-plugin/structures/article-paragraph.d.ts +2 -0
  264. package/declarations/addon/plugins/article-structure-plugin/structures/article.d.ts +5 -0
  265. package/{plugins → declarations/addon/plugins}/article-structure-plugin/structures/index.d.ts +4 -0
  266. package/declarations/addon/plugins/article-structure-plugin/structures/structure-header-number.d.ts +2 -0
  267. package/declarations/addon/plugins/article-structure-plugin/structures/structure-header-title.d.ts +2 -0
  268. package/declarations/addon/plugins/article-structure-plugin/structures/structure-header.d.ts +17 -0
  269. package/declarations/addon/plugins/article-structure-plugin/utils/structure.d.ts +42 -0
  270. package/declarations/addon/plugins/confidentiality-plugin/marks/redacted.d.ts +2 -0
  271. package/declarations/addon/plugins/snippet-plugin/commands/index.d.ts +1 -0
  272. package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-ids.d.ts +8 -0
  273. package/{plugins → declarations/addon/plugins}/snippet-plugin/index.d.ts +2 -0
  274. package/declarations/addon/plugins/snippet-plugin/utils/rdfa-predicate.d.ts +5 -0
  275. package/{plugins → declarations/addon/plugins}/table-of-contents-plugin/nodes/table-of-contents.d.ts +1 -1
  276. package/{plugins → declarations/addon/plugins}/template-comments-plugin/node.d.ts +1 -1
  277. package/{plugins → declarations/addon/plugins}/variable-plugin/utils/attribute-parsers.d.ts +3 -0
  278. package/{plugins → declarations/addon/plugins}/variable-plugin/variables/address.d.ts +1 -1
  279. package/{plugins → declarations/addon/plugins}/variable-plugin/variables/codelist.d.ts +1 -1
  280. package/{plugins → declarations/addon/plugins}/variable-plugin/variables/date.d.ts +1 -1
  281. package/{plugins → declarations/addon/plugins}/variable-plugin/variables/location.d.ts +1 -1
  282. package/{plugins → declarations/addon/plugins}/variable-plugin/variables/number.d.ts +1 -1
  283. package/{plugins → declarations/addon/plugins}/variable-plugin/variables/text.d.ts +1 -1
  284. package/declarations/addon/plugins/worship-plugin/index.d.ts +8 -0
  285. package/declarations/addon/plugins/worship-plugin/utils/fetchAdministrativeUnits.d.ts +7 -0
  286. package/declarations/addon/plugins/worship-plugin/utils/fetchWorshipServices.d.ts +23 -0
  287. package/declarations/addon/plugins/worship-plugin/utils/insertWorshipService.d.ts +3 -0
  288. package/declarations/addon/serializers/application.d.ts +3 -0
  289. package/{services → declarations/addon/services}/import-rdfa-snippet.d.ts +2 -0
  290. package/{utils → declarations/addon/utils}/_private/find-insertion-range.d.ts +7 -4
  291. package/declarations/addon/utils/dom-utils.d.ts +2 -0
  292. package/declarations/addon/utils/namespace.d.ts +21 -0
  293. package/{utils → declarations/addon/utils}/sparql-helpers.d.ts +4 -0
  294. package/package.json +54 -19
  295. package/pnpm-lock.yaml +17788 -0
  296. package/scripts/generate-type-declarations.sh +16 -0
  297. package/translations/en-US.yaml +27 -12
  298. package/translations/nl-BE.yaml +27 -12
  299. package/tsconfig.declarations.json +15 -0
  300. package/tsconfig.json +7 -57
  301. package/tsconfig.main.json +62 -0
  302. package/types/ember-intl.d.ts +15 -0
  303. package/types/graphy/memory.dataset.fast.d.ts +74 -0
  304. package/.woodpecker/.test.yml +0 -49
  305. package/addon/components/citation-plugin/helpers/alert-load-error.hbs +0 -21
  306. package/addon/components/citation-plugin/helpers/alert-no-items.hbs +0 -10
  307. package/addon/components/confidentiality-plugin/redact.hbs +0 -6
  308. package/addon/components/pagination/pagination-view.hbs +0 -39
  309. package/addon/components/snippet-plugin/helpers/alert-load-error.hbs +0 -22
  310. package/addon/components/snippet-plugin/helpers/alert-no-items.hbs +0 -8
  311. package/components/citation-plugin/citations/legal-document-preview.d.ts +0 -10
  312. package/components/variable-plugin/location/nodeview.d.ts +0 -12
  313. package/components/variable-plugin/variable/nodeview.d.ts +0 -11
  314. package/plugins/article-structure-plugin/commands/recalculate-structure-numbers.d.ts +0 -3
  315. package/plugins/article-structure-plugin/commands/set-structure-start-number.d.ts +0 -4
  316. package/plugins/article-structure-plugin/structures/article.d.ts +0 -6
  317. package/plugins/article-structure-plugin/structures/structure-header.d.ts +0 -2
  318. package/plugins/article-structure-plugin/utils/structure.d.ts +0 -36
  319. package/plugins/confidentiality-plugin/marks/redacted.d.ts +0 -2
  320. package/utils/namespace.d.ts +0 -12
  321. package/{components → declarations/addon/components}/hover-tooltip.d.ts +0 -0
  322. package/{components → declarations/addon/components}/roadsign-regulation-plugin/measure-template.d.ts +0 -0
  323. package/{components → declarations/addon/components}/roadsign-regulation-plugin/roadsigns-modal.d.ts +0 -0
  324. package/{components → declarations/addon/components}/snippet-plugin/search-modal.d.ts +0 -0
  325. package/{components → declarations/addon/components}/snippet-plugin/snippet-list/snippet-list-modal.d.ts +0 -0
  326. package/{components → declarations/addon/components}/snippet-plugin/snippet-list/snippet-list-view.d.ts +0 -0
  327. package/{components → declarations/addon/components}/snippet-plugin/snippets/snippet-preview.d.ts +0 -0
  328. package/{components → declarations/addon/components}/standard-template-plugin/template-provider.d.ts +0 -0
  329. package/{components → declarations/addon/components}/table-of-contents-plugin/ember-nodes/table-of-contents.d.ts +0 -0
  330. package/{components → declarations/addon/components}/table-of-contents-plugin/toolbar-button.d.ts +0 -0
  331. package/{components → declarations/addon/components}/validation-plugin/validation-card.d.ts +0 -0
  332. package/{components → declarations/addon/components}/variable-plugin/address/insert-variable.d.ts +0 -0
  333. package/{components → declarations/addon/components}/variable-plugin/address/utils.d.ts +0 -0
  334. package/{components → declarations/addon/components}/variable-plugin/codelist/edit.d.ts +0 -0
  335. package/{components → declarations/addon/components}/variable-plugin/codelist/insert.d.ts +0 -0
  336. package/{components → declarations/addon/components}/variable-plugin/date/date-time-picker.d.ts +0 -0
  337. package/{components → declarations/addon/components}/variable-plugin/date/help-modal.d.ts +0 -0
  338. package/{components → declarations/addon/components}/variable-plugin/date/insert-variable.d.ts +0 -0
  339. package/{components → declarations/addon/components}/variable-plugin/location/insert.d.ts +0 -0
  340. package/{components → declarations/addon/components}/variable-plugin/number/insert.d.ts +0 -0
  341. package/{helpers → declarations/addon/helpers}/capitalize.d.ts +0 -0
  342. package/{helpers → declarations/addon/helpers}/in-array.d.ts +0 -0
  343. package/{helpers → declarations/addon/helpers}/limit-text.d.ts +0 -0
  344. package/{helpers → declarations/addon/helpers}/pagination.d.ts +0 -0
  345. package/{models → declarations/addon/models}/instruction.d.ts +0 -0
  346. package/{models → declarations/addon/models}/measure.d.ts +0 -0
  347. package/{models → declarations/addon/models}/sign.d.ts +0 -0
  348. package/{models → declarations/addon/models}/template.d.ts +0 -0
  349. package/{plugins → declarations/addon/plugins}/article-structure-plugin/commands/index.d.ts +0 -0
  350. package/{plugins → declarations/addon/plugins}/article-structure-plugin/commands/insert-structure.d.ts +0 -0
  351. package/{plugins → declarations/addon/plugins}/article-structure-plugin/commands/move-selected-structure.d.ts +0 -0
  352. package/{plugins → declarations/addon/plugins}/article-structure-plugin/commands/remove-structure.d.ts +0 -0
  353. package/{plugins → declarations/addon/plugins}/article-structure-plugin/commands/unwrap-structure.d.ts +0 -0
  354. package/{plugins → declarations/addon/plugins}/article-structure-plugin/commands/wrap-structure-content.d.ts +1 -1
  355. /package/{plugins → declarations/addon/plugins}/article-structure-plugin/structures/chapter.d.ts +0 -0
  356. /package/{plugins → declarations/addon/plugins}/article-structure-plugin/structures/section.d.ts +0 -0
  357. /package/{plugins → declarations/addon/plugins}/article-structure-plugin/structures/subsection.d.ts +0 -0
  358. /package/{plugins → declarations/addon/plugins}/article-structure-plugin/structures/title.d.ts +0 -0
  359. /package/{plugins → declarations/addon/plugins}/article-structure-plugin/utils/romanize.d.ts +0 -0
  360. /package/{plugins → declarations/addon/plugins}/besluit-type-plugin/index.d.ts +0 -0
  361. /package/{plugins → declarations/addon/plugins}/besluit-type-plugin/utils/fetchBesluitTypes.d.ts +0 -0
  362. /package/{plugins → declarations/addon/plugins}/citation-plugin/index.d.ts +0 -0
  363. /package/{plugins → declarations/addon/plugins}/citation-plugin/utils/article.d.ts +0 -0
  364. /package/{plugins → declarations/addon/plugins}/citation-plugin/utils/cache.d.ts +0 -0
  365. /package/{plugins → declarations/addon/plugins}/citation-plugin/utils/cited-text.d.ts +0 -0
  366. /package/{plugins → declarations/addon/plugins}/citation-plugin/utils/legal-documents.d.ts +0 -0
  367. /package/{plugins → declarations/addon/plugins}/citation-plugin/utils/process-match.d.ts +0 -0
  368. /package/{plugins → declarations/addon/plugins}/citation-plugin/utils/public-decisions.d.ts +0 -0
  369. /package/{plugins → declarations/addon/plugins}/citation-plugin/utils/types.d.ts +0 -0
  370. /package/{plugins → declarations/addon/plugins}/citation-plugin/utils/utils.d.ts +0 -0
  371. /package/{plugins → declarations/addon/plugins}/citation-plugin/utils/vlaamse-codex.d.ts +0 -0
  372. /package/{plugins → declarations/addon/plugins}/confidentiality-plugin/index.d.ts +0 -0
  373. /package/{plugins → declarations/addon/plugins}/decision-plugin/commands/index.d.ts +0 -0
  374. /package/{plugins → declarations/addon/plugins}/decision-plugin/commands/insert-article-container.d.ts +0 -0
  375. /package/{plugins → declarations/addon/plugins}/decision-plugin/commands/insert-description.d.ts +0 -0
  376. /package/{plugins → declarations/addon/plugins}/decision-plugin/commands/insert-motivation.d.ts +0 -0
  377. /package/{plugins → declarations/addon/plugins}/decision-plugin/commands/insert-title.d.ts +0 -0
  378. /package/{plugins → declarations/addon/plugins}/decision-plugin/utils/get-title-for-decision.d.ts +0 -0
  379. /package/{plugins → declarations/addon/plugins}/decision-plugin/utils/validation-rules.d.ts +0 -0
  380. /package/{plugins → declarations/addon/plugins}/document-title-plugin/commands/insert-document-title.d.ts +0 -0
  381. /package/{plugins → declarations/addon/plugins}/document-title-plugin/nodes/document-title.d.ts +0 -0
  382. /package/{plugins → declarations/addon/plugins}/document-title-plugin/nodes/index.d.ts +0 -0
  383. /package/{plugins → declarations/addon/plugins}/generic-rdfa-variable/commands/index.d.ts +0 -0
  384. /package/{plugins → declarations/addon/plugins}/generic-rdfa-variable/commands/insert-generic-rdfa.d.ts +0 -0
  385. /package/{plugins → declarations/addon/plugins}/roadsign-regulation-plugin/index.d.ts +0 -0
  386. /package/{plugins → declarations/addon/plugins}/roadsign-regulation-plugin/nodes.d.ts +0 -0
  387. /package/{plugins → declarations/addon/plugins}/roadsign-regulation-plugin/utils/constants.d.ts +0 -0
  388. /package/{plugins → declarations/addon/plugins}/roadsign-regulation-plugin/utils/fetchData.d.ts +0 -0
  389. /package/{plugins → declarations/addon/plugins}/roadsign-regulation-plugin/utils/includeInstructions.d.ts +0 -0
  390. /package/{plugins → declarations/addon/plugins}/snippet-plugin/utils/fetch-data.d.ts +0 -0
  391. /package/{plugins → declarations/addon/plugins}/standard-template-plugin/index.d.ts +0 -0
  392. /package/{plugins → declarations/addon/plugins}/standard-template-plugin/utils/instantiate-uuids.d.ts +0 -0
  393. /package/{plugins → declarations/addon/plugins}/standard-template-plugin/utils/nodes.d.ts +0 -0
  394. /package/{plugins → declarations/addon/plugins}/table-of-contents-plugin/index.d.ts +0 -0
  395. /package/{plugins → declarations/addon/plugins}/table-of-contents-plugin/nodes/index.d.ts +0 -0
  396. /package/{plugins → declarations/addon/plugins}/table-of-contents-plugin/utils/index.d.ts +0 -0
  397. /package/{plugins → declarations/addon/plugins}/template-comments-plugin/index.d.ts +0 -0
  398. /package/{plugins → declarations/addon/plugins}/validation/index.d.ts +0 -0
  399. /package/{plugins → declarations/addon/plugins}/validation/utils/transaction-complies-with-shapes.d.ts +0 -0
  400. /package/{plugins → declarations/addon/plugins}/variable-plugin/utils/address-helpers.d.ts +0 -0
  401. /package/{plugins → declarations/addon/plugins}/variable-plugin/utils/codelist-utils.d.ts +0 -0
  402. /package/{plugins → declarations/addon/plugins}/variable-plugin/utils/constants.d.ts +0 -0
  403. /package/{plugins → declarations/addon/plugins}/variable-plugin/utils/date-helpers.d.ts +0 -0
  404. /package/{plugins → declarations/addon/plugins}/variable-plugin/utils/dom-constructors.d.ts +0 -0
  405. /package/{plugins → declarations/addon/plugins}/variable-plugin/utils/fetch-data.d.ts +0 -0
  406. /package/{plugins → declarations/addon/plugins}/variable-plugin/utils/number-to-words.d.ts +0 -0
  407. /package/{plugins → declarations/addon/plugins}/variable-plugin/variables/index.d.ts +0 -0
  408. /package/{services → declarations/addon/services}/roadsign-registry.d.ts +0 -0
  409. /package/{utils → declarations/addon/utils}/changed-descendants.d.ts +0 -0
  410. /package/{utils → declarations/addon/utils}/constants.d.ts +0 -0
  411. /package/{utils → declarations/addon/utils}/dom-output-spec-helpers.d.ts +0 -0
  412. /package/{utils → declarations/addon/utils}/find-insertion-contentmatch.d.ts +0 -0
  413. /package/{utils → declarations/addon/utils}/find-insertion-pos-in-ancestor-of-type.d.ts +0 -0
  414. /package/{utils → declarations/addon/utils}/memoize.d.ts +0 -0
  415. /package/{utils → declarations/addon/utils}/option.d.ts +0 -0
  416. /package/{utils → declarations/addon/utils}/strings.d.ts +0 -0
  417. /package/{utils → declarations/addon/utils}/translation.d.ts +0 -0
  418. /package/{utils → declarations/addon/utils}/types.d.ts +0 -0
@@ -0,0 +1,131 @@
1
+ import Component from '@glimmer/component';
2
+ import { tracked } from '@glimmer/tracking';
3
+ import { assert } from '@ember/debug';
4
+ import { action } from '@ember/object';
5
+ import { restartableTask, timeout } from 'ember-concurrency';
6
+ import { task as trackedTask } from 'ember-resources/util/ember-concurrency';
7
+ import { WorshipPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/worship-plugin';
8
+ import {
9
+ fetchWorshipServices,
10
+ SearchSort,
11
+ WorshipService,
12
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/worship-plugin/utils/fetchWorshipServices';
13
+ import { AdministrativeUnit } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/worship-plugin';
14
+
15
+ interface Args {
16
+ config: WorshipPluginConfig;
17
+ open: boolean;
18
+ closeModal: () => void;
19
+ onInsert: (service: WorshipService) => void;
20
+ }
21
+
22
+ export default class WorshipPluginSearchModalComponent extends Component<Args> {
23
+ // Filtering
24
+ @tracked sort: SearchSort = false;
25
+ @tracked inputSearchText: string | null = null;
26
+ // We're deliberately using the arg to set the initial value
27
+ // eslint-disable-next-line ember/no-tracked-properties-from-args
28
+ @tracked administrativeUnit: AdministrativeUnit | undefined =
29
+ this.args.config.defaultAdministrativeUnit;
30
+
31
+ // Display
32
+ @tracked error: unknown;
33
+
34
+ // Pagination
35
+ @tracked pageNumber = 0;
36
+ @tracked pageSize = 20;
37
+ @tracked totalCount = 0;
38
+
39
+ get config() {
40
+ return this.args.config;
41
+ }
42
+
43
+ get searchText() {
44
+ return this.inputSearchText;
45
+ }
46
+
47
+ @action
48
+ setInputSearchText(event: InputEvent) {
49
+ assert(
50
+ 'inputSearchText must be bound to an input element',
51
+ event.target instanceof HTMLInputElement,
52
+ );
53
+
54
+ this.inputSearchText = event.target.value;
55
+ }
56
+
57
+ @action
58
+ setAdministrativeUnit(unit: AdministrativeUnit) {
59
+ this.administrativeUnit = unit;
60
+ }
61
+
62
+ @action
63
+ async closeModal() {
64
+ await this.servicesResource.cancel();
65
+ this.args.closeModal();
66
+ }
67
+
68
+ search = restartableTask(async () => {
69
+ await timeout(500);
70
+
71
+ const abortController = new AbortController();
72
+
73
+ try {
74
+ const queryResult = await fetchWorshipServices({
75
+ administrativeUnitURI: this.administrativeUnit?.uri,
76
+ config: this.args.config,
77
+ searchMeta: {
78
+ abortSignal: abortController.signal,
79
+ filter: {
80
+ label: this.inputSearchText ?? undefined,
81
+ },
82
+ sort: this.sort,
83
+ page: this.pageNumber,
84
+ pageSize: this.pageSize,
85
+ },
86
+ });
87
+ this.error = undefined;
88
+
89
+ // Reset to first page if there are no results for this one e.g. when changing search
90
+ if (
91
+ this.pageNumber !== 0 &&
92
+ this.pageNumber * this.pageSize >= queryResult.totalCount
93
+ ) {
94
+ this.pageNumber = 0;
95
+ }
96
+
97
+ return queryResult;
98
+ } catch (error) {
99
+ this.error = error;
100
+ return {
101
+ results: [],
102
+ totalCount: 0,
103
+ };
104
+ } finally {
105
+ abortController.abort();
106
+ }
107
+ });
108
+
109
+ servicesResource = trackedTask(this, this.search, () => [
110
+ this.inputSearchText,
111
+ this.administrativeUnit,
112
+ this.pageNumber,
113
+ this.pageSize,
114
+ this.sort,
115
+ ]);
116
+
117
+ @action
118
+ setSort(sort: SearchSort) {
119
+ this.sort = sort;
120
+ }
121
+
122
+ @action
123
+ previousPage() {
124
+ --this.pageNumber;
125
+ }
126
+
127
+ @action
128
+ nextPage() {
129
+ ++this.pageNumber;
130
+ }
131
+ }
@@ -0,0 +1,36 @@
1
+ {{! @glint-nocheck: not typesafe yet }}
2
+ {{!-- Based on au-data-table-th-sortable from ember-appuniversum and using the same classes --}}
3
+ <span
4
+ class='au-c-data-table__header-title au-c-data-table__header-title--sortable
5
+ {{if this.order ' is-active'}}'
6
+ >
7
+ {{@label}}
8
+ {{#if (eq this.order 'DESC')}}
9
+ <button
10
+ type='button'
11
+ {{on 'click' this.changeSort}}
12
+ class='au-c-data-table__sort'
13
+ >
14
+ <span class='au-u-hidden-visually'>{{t 'worship-plugin.modal.sort.asc'}}</span>
15
+ <AuIcon @icon={{this.NavUpIcon}} />
16
+ </button>
17
+ {{else if (eq this.order 'ASC')}}
18
+ <button
19
+ type='button'
20
+ {{on 'click' this.changeSort}}
21
+ class='au-c-data-table__sort'
22
+ >
23
+ <span class='au-u-hidden-visually'>{{t 'worship-plugin.modal.sort.desc'}}</span>
24
+ <AuIcon @icon={{this.NavDownIcon}} />
25
+ </button>
26
+ {{else}}
27
+ <button
28
+ type='button'
29
+ {{on 'click' this.changeSort}}
30
+ class='au-c-data-table__sort'
31
+ >
32
+ <span class='au-u-hidden-visually'>{{t 'worship-plugin.modal.sort.sort'}}</span>
33
+ <AuIcon @icon={{this.NavUpDownIcon}} />
34
+ </button>
35
+ {{/if}}
36
+ </span>
@@ -0,0 +1,45 @@
1
+ import { action } from '@ember/object';
2
+ import Component from '@glimmer/component';
3
+ import { NavUpIcon } from '@appuniversum/ember-appuniversum/components/icons/nav-up';
4
+ import { NavDownIcon } from '@appuniversum/ember-appuniversum/components/icons/nav-down';
5
+ import { NavUpDownIcon } from '@appuniversum/ember-appuniversum/components/icons/nav-up-down';
6
+ import {
7
+ SearchSort,
8
+ WorshipService,
9
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/worship-plugin/utils/fetchWorshipServices';
10
+
11
+ interface Args {
12
+ label: string;
13
+ field: keyof WorshipService;
14
+ sort: SearchSort;
15
+ setSort: (sort: SearchSort) => void;
16
+ }
17
+
18
+ export default class SnippetInsertComponent extends Component<Args> {
19
+ NavUpIcon = NavUpIcon;
20
+ NavDownIcon = NavDownIcon;
21
+ NavUpDownIcon = NavUpDownIcon;
22
+
23
+ get order() {
24
+ if (this.args.sort) {
25
+ const [sortedField, order] = this.args.sort;
26
+ if (sortedField === this.args.field) {
27
+ return order;
28
+ }
29
+ }
30
+ return false;
31
+ }
32
+
33
+ @action changeSort() {
34
+ const order = this.order;
35
+ let newSort: SearchSort;
36
+ if (!order) {
37
+ newSort = [this.args.field, 'ASC'];
38
+ } else if (order === 'ASC') {
39
+ newSort = [this.args.field, 'DESC'];
40
+ } else {
41
+ newSort = false;
42
+ }
43
+ this.args.setSort(newSort);
44
+ }
45
+ }
@@ -1,14 +1,69 @@
1
1
  import {
2
2
  Command,
3
+ EditorState,
3
4
  Fragment,
4
5
  NodeSelection,
5
6
  TextSelection,
7
+ Transaction,
6
8
  } from '@lblod/ember-rdfa-editor';
9
+ import { getNodeByRdfaId } from '@lblod/ember-rdfa-editor/plugins/rdfa-info';
10
+ import { addProperty } from '@lblod/ember-rdfa-editor/commands';
11
+ import { isRdfaAttrs } from '@lblod/ember-rdfa-editor/core/schema';
12
+ import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
7
13
  import recalculateStructureNumbers from './recalculate-structure-numbers';
8
14
  import { StructureSpec } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
9
15
  import wrapStructureContent from './wrap-structure-content';
10
16
  import IntlService from 'ember-intl/services/intl';
11
17
  import { findInsertionRange } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/_private/find-insertion-range';
18
+ import { SAY } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
19
+
20
+ const addPropertyToContainer = ({
21
+ state,
22
+ transaction,
23
+ structureSpec,
24
+ insertionRange,
25
+ newResource,
26
+ }: {
27
+ state: EditorState;
28
+ transaction: Transaction;
29
+ structureSpec: StructureSpec;
30
+ insertionRange: Exclude<ReturnType<typeof findInsertionRange>, null>;
31
+ newResource: string;
32
+ }) => {
33
+ if (!insertionRange) {
34
+ return transaction;
35
+ }
36
+
37
+ const containerAttrs = insertionRange.containerNode.attrs;
38
+
39
+ if (!isRdfaAttrs(containerAttrs)) {
40
+ return transaction;
41
+ }
42
+
43
+ const incoming = containerAttrs.backlinks;
44
+ const subject = incoming?.find((backlink) =>
45
+ SAY('body').matches(backlink.predicate),
46
+ )?.subject;
47
+
48
+ if (!subject) {
49
+ return transaction;
50
+ }
51
+
52
+ const newState = state.apply(transaction);
53
+ addProperty({
54
+ resource: subject.value,
55
+ property: {
56
+ predicate: (structureSpec.relationshipPredicate ?? SAY('hasPart'))
57
+ .prefixed,
58
+ object: sayDataFactory.resourceNode(newResource),
59
+ },
60
+ transaction,
61
+ })(newState, (newTransaction) => {
62
+ transaction = newTransaction;
63
+ });
64
+
65
+ return transaction;
66
+ };
12
67
 
13
68
  const insertStructure = (
14
69
  structureSpec: StructureSpec,
@@ -31,28 +86,40 @@ const insertStructure = (
31
86
  return false;
32
87
  }
33
88
  if (dispatch) {
34
- const { node: newStructureNode, selectionConfig } =
35
- structureSpec.constructor({ schema, intl, content, state });
36
- const transaction = state.tr;
89
+ const {
90
+ node: newStructureNode,
91
+ selectionConfig,
92
+ newResource,
93
+ } = structureSpec.constructor({ schema, intl, content, state });
94
+ let transaction = state.tr;
37
95
 
38
96
  transaction.replaceWith(
39
97
  insertionRange.from,
40
98
  insertionRange.to,
41
99
  newStructureNode,
42
100
  );
43
- const newSelection =
44
- selectionConfig.type === 'node'
45
- ? NodeSelection.create(
46
- transaction.doc,
47
- insertionRange.from + selectionConfig.relativePos,
48
- )
49
- : TextSelection.create(
50
- transaction.doc,
51
- insertionRange.from + selectionConfig.relativePos,
52
- );
53
- transaction.setSelection(newSelection);
101
+ const target = getNodeByRdfaId(
102
+ state.apply(transaction),
103
+ selectionConfig.rdfaId,
104
+ );
105
+ if (target) {
106
+ const newSelection =
107
+ selectionConfig.type === 'node'
108
+ ? NodeSelection.create(transaction.doc, target.pos)
109
+ : TextSelection.create(transaction.doc, target.pos + 1);
110
+ transaction.setSelection(newSelection);
111
+ }
112
+
54
113
  transaction.scrollIntoView();
55
- recalculateStructureNumbers(transaction, structureSpec);
114
+ recalculateStructureNumbers(transaction, schema, structureSpec);
115
+ transaction = addPropertyToContainer({
116
+ state,
117
+ transaction,
118
+ structureSpec,
119
+ insertionRange,
120
+ newResource,
121
+ });
122
+
56
123
  dispatch(transaction);
57
124
  }
58
125
  return true;
@@ -15,6 +15,7 @@ import IntlService from 'ember-intl/services/intl';
15
15
  import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
16
16
  import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
17
17
  import { getTranslationFunction } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/translation';
18
+
18
19
  const moveSelectedStructure = (
19
20
  options: ArticleStructurePluginOptions,
20
21
  direction: 'up' | 'down',
@@ -77,7 +78,7 @@ const moveSelectedStructure = (
77
78
  : TextSelection.create(transaction.doc, newSelectionPos);
78
79
  transaction.setSelection(newSelection);
79
80
  transaction.scrollIntoView();
80
- recalculateStructureNumbers(transaction, currentStructureSpec);
81
+ recalculateStructureNumbers(transaction, schema, currentStructureSpec);
81
82
  dispatch(transaction);
82
83
  }
83
84
  return true;
@@ -1,15 +1,69 @@
1
- import { PNode, Transaction } from '@lblod/ember-rdfa-editor';
1
+ import { PNode, Schema, Transaction } from '@lblod/ember-rdfa-editor';
2
+ import { findNodeByRdfaId } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
3
+ import { isRdfaAttrs } from '@lblod/ember-rdfa-editor/core/schema';
4
+ import type { Resource } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
5
+ import { ELI } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
2
6
  import { StructureSpec } from '..';
3
7
 
8
+ type UpdateNumberProps = {
9
+ transaction: Transaction;
10
+ schema: Schema;
11
+ node: PNode;
12
+ number: string;
13
+ numberPredicate?: Resource;
14
+ };
15
+
16
+ function updateNumber({
17
+ transaction,
18
+ schema,
19
+ node,
20
+ number,
21
+ numberPredicate,
22
+ }: UpdateNumberProps) {
23
+ const { attrs } = node;
24
+
25
+ if (isRdfaAttrs(attrs) && attrs.rdfaNodeType === 'resource') {
26
+ const properties = attrs.properties;
27
+ const numberProp = properties.find((prop) =>
28
+ (numberPredicate ?? ELI('number')).matches(prop.predicate),
29
+ );
30
+ const numberRdfaId =
31
+ numberProp?.object.termType === 'LiteralNode' && numberProp.object.value;
32
+ const numberNode =
33
+ numberRdfaId && findNodeByRdfaId(transaction.doc, numberRdfaId);
34
+
35
+ if (numberNode) {
36
+ transaction.replaceWith(
37
+ numberNode.pos + 1,
38
+ numberNode.pos + numberNode.value.nodeSize - 1,
39
+ schema.text(number),
40
+ );
41
+ }
42
+ }
43
+ }
44
+
4
45
  export default function recalculateStructureNumbers(
5
46
  transaction: Transaction,
47
+ schema: Schema,
6
48
  ...structureSpecs: StructureSpec[]
7
49
  ) {
8
50
  const doc = transaction.doc;
9
51
  const indices = new Array<number>(structureSpecs.length).fill(1);
52
+
10
53
  const contexts: (PNode | null)[] = new Array<PNode | null>(
11
54
  structureSpecs.length,
12
55
  ).fill(null);
56
+
57
+ /**
58
+ * Recording all calls to `updateNumber` in an array to run them all
59
+ * _after_ we've run all the `setNumber` calls.
60
+ *
61
+ * This is necessary because `updateNumber` calls can change positions of the nodes
62
+ * in the document, and the calls to `setNumber` are dependent on the correct position
63
+ * before the change.
64
+ */
65
+ const updateNumberCalls: UpdateNumberProps[] = [];
66
+
13
67
  doc.descendants((node, pos, parent) => {
14
68
  structureSpecs.forEach((spec, i) => {
15
69
  if (node.type.name === spec.name) {
@@ -24,10 +78,24 @@ export default function recalculateStructureNumbers(
24
78
  indices[i] = startNumber;
25
79
  }
26
80
 
27
- spec.updateNumber({ number: indices[i], pos, transaction });
81
+ spec.setNumber({ transaction, pos, number: indices[i] });
82
+
83
+ if ('convertNumber' in spec.numberConfig) {
84
+ updateNumberCalls.push({
85
+ transaction,
86
+ schema,
87
+ node,
88
+ number: spec.numberConfig.convertNumber(indices[i]),
89
+ numberPredicate: spec.numberConfig.numberPredicate,
90
+ });
91
+ }
92
+
28
93
  indices[i] += 1;
29
94
  }
30
95
  });
31
96
  });
97
+
98
+ updateNumberCalls.forEach(updateNumber);
99
+
32
100
  return transaction;
33
101
  }
@@ -11,7 +11,7 @@ const removeStructure = (
11
11
  const { pos, node } = structure;
12
12
  const transaction = state.tr;
13
13
  transaction.replace(pos, pos + node.nodeSize);
14
- recalculateStructureNumbers(transaction, ...options);
14
+ recalculateStructureNumbers(transaction, state.schema, ...options);
15
15
  dispatch(transaction);
16
16
  }
17
17
  return true;
@@ -1,26 +1,17 @@
1
- import { Command } from '@lblod/ember-rdfa-editor';
1
+ import { Command, PNode } from '@lblod/ember-rdfa-editor';
2
2
 
3
- import { findAncestorOfType } from '../utils/structure';
4
3
  import type { ArticleStructurePluginOptions } from '..';
5
4
  import recalculateStructureNumbers from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/commands/recalculate-structure-numbers';
6
5
  import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
7
6
 
8
7
  const setStructureStartNumber = (
8
+ structure: { pos: number; node: PNode },
9
9
  options: ArticleStructurePluginOptions,
10
10
  startNumber: number | null,
11
11
  ): Command => {
12
12
  return (state, dispatch) => {
13
- const { selection, schema } = state;
14
-
15
- const structureSpecs = options.map((type) => schema.nodes[type.name]);
16
- const currentStructure = findAncestorOfType(selection, ...structureSpecs);
17
-
18
- if (!currentStructure || currentStructure.pos === -1) {
19
- return false;
20
- }
21
-
22
13
  const currentStructureSpec = unwrap(
23
- options.find((spec) => spec.name === currentStructure.node.type.name),
14
+ options.find((spec) => spec.name === structure.node.type.name),
24
15
  );
25
16
 
26
17
  if (dispatch) {
@@ -28,11 +19,11 @@ const setStructureStartNumber = (
28
19
 
29
20
  currentStructureSpec.setStartNumber({
30
21
  number: startNumber,
31
- pos: currentStructure.pos,
22
+ pos: structure.pos,
32
23
  transaction,
33
24
  });
34
25
 
35
- recalculateStructureNumbers(transaction, ...options);
26
+ recalculateStructureNumbers(transaction, state.schema, ...options);
36
27
 
37
28
  dispatch(transaction);
38
29
  }
@@ -30,7 +30,7 @@ const unwrapStructure = (
30
30
  if (dispatch) {
31
31
  const transaction = state.tr;
32
32
  transaction.replaceWith(pos, pos + node.nodeSize, contentToUnwrap);
33
- recalculateStructureNumbers(transaction, ...options);
33
+ recalculateStructureNumbers(transaction, state.schema, ...options);
34
34
  dispatch(transaction);
35
35
  }
36
36
  return true;