@lblod/ember-rdfa-editor-lblod-plugins 0.4.1 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/addon/commands/article-structure-plugin/delete-structure.ts +85 -0
- package/addon/commands/article-structure-plugin/index.ts +4 -0
- package/addon/commands/article-structure-plugin/insert-article-structure.ts +137 -0
- package/addon/commands/article-structure-plugin/move-structure.ts +227 -0
- package/addon/commands/article-structure-plugin/recalculate-structure-numbers.ts +88 -0
- package/addon/commands/besluit-plugin/get-article-nodes-for-besluit.ts +30 -0
- package/addon/commands/besluit-plugin/index.ts +4 -0
- package/addon/commands/besluit-plugin/insert-article.ts +94 -0
- package/addon/commands/besluit-plugin/insert-title.ts +67 -0
- package/addon/commands/besluit-plugin/move-article.ts +69 -0
- package/addon/commands/besluit-plugin/recalculate-article-numbers.ts +44 -0
- package/addon/commands/modify-date-command.ts +48 -0
- package/addon/components/article-structure-plugin/article-structure-card.hbs +14 -0
- package/addon/components/article-structure-plugin/article-structure-card.ts +83 -0
- package/addon/components/article-structure-plugin/structure-card.hbs +42 -0
- package/addon/components/article-structure-plugin/structure-card.ts +140 -0
- package/addon/components/au-native-input.hbs +30 -0
- package/addon/components/au-native-input.ts +47 -0
- package/addon/components/besluit-plugin/besluit-context-card.hbs +44 -0
- package/addon/components/besluit-plugin/besluit-context-card.ts +144 -0
- package/addon/components/besluit-plugin/besluit-plugin-card.hbs +20 -0
- package/addon/components/besluit-plugin/besluit-plugin-card.ts +42 -0
- package/addon/components/besluit-type-plugin/{besluit-type-select.js → besluit-type-select.ts} +9 -4
- package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +2 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +216 -0
- package/addon/components/citation-plugin/citation-card.hbs +118 -0
- package/addon/components/citation-plugin/citation-card.ts +230 -0
- package/addon/components/citation-plugin/citation-insert.hbs +20 -0
- package/addon/components/citation-plugin/citation-insert.ts +102 -0
- package/addon/components/{citaten-plugin → citation-plugin}/citations/article-list.hbs +2 -2
- package/addon/components/{citaten-plugin → citation-plugin}/citations/article-preview.hbs +0 -0
- package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-detail.hbs +9 -6
- package/addon/components/{citaten-plugin/citations/decision-detail.js → citation-plugin/citations/decision-detail.ts} +30 -31
- package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-list.hbs +2 -2
- package/addon/components/{citaten-plugin → citation-plugin}/citations/decision-preview.hbs +0 -0
- package/addon/components/citation-plugin/citations/search-modal.hbs +254 -0
- package/addon/components/{citaten-plugin/citations/search-modal.js → citation-plugin/citations/search-modal.ts} +116 -89
- package/addon/components/{citaten-plugin → citation-plugin}/helpers/alert-load-error.hbs +0 -0
- package/addon/components/{citaten-plugin → citation-plugin}/helpers/alert-no-items.hbs +0 -0
- package/addon/components/import-snippet-plugin/card.ts +119 -0
- package/addon/components/insert-variable-plugin/insert-variable-card.hbs +2 -1
- package/addon/components/insert-variable-plugin/insert-variable-card.ts +134 -0
- package/addon/components/rdfa-date-plugin/{rdfa-date-plugin-card.hbs → card.hbs} +3 -1
- package/addon/components/rdfa-date-plugin/card.ts +72 -0
- package/addon/components/rdfa-date-plugin/{rdfa-date-time-picker.hbs → date-time-picker.hbs} +0 -0
- package/addon/components/rdfa-date-plugin/{rdfa-date-time-picker.js → date-time-picker.ts} +26 -12
- package/addon/components/rdfa-date-plugin/{rdfa-date-plugin-insert.hbs → insert.hbs} +0 -0
- package/addon/components/rdfa-date-plugin/insert.ts +44 -0
- package/addon/components/roadsign-regulation-plugin/expanded-measure.ts +58 -0
- package/addon/components/roadsign-regulation-plugin/measure-template.ts +35 -0
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +2 -2
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +60 -0
- package/addon/components/roadsign-regulation-plugin/{roadsigns-modal.js → roadsigns-modal.ts} +101 -64
- package/addon/components/roadsign-regulation-plugin/{roadsigns-pagination.js → roadsigns-pagination.ts} +7 -3
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.ts +32 -0
- package/addon/components/standard-template-plugin/{template-card.hbs → card.hbs} +0 -0
- package/addon/components/standard-template-plugin/card.ts +11 -0
- package/addon/components/standard-template-plugin/template-provider.hbs +3 -1
- package/addon/components/standard-template-plugin/template-provider.ts +75 -0
- package/addon/components/table-of-contents-plugin/card.hbs +12 -1
- package/addon/components/table-of-contents-plugin/card.ts +60 -0
- package/addon/components/table-of-contents-plugin/{inline-components → ember-nodes}/outline.hbs +2 -2
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.hbs +9 -0
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +95 -0
- package/addon/components/template-variable-plugin/template-variable-card.hbs +2 -1
- package/addon/components/template-variable-plugin/template-variable-card.ts +227 -0
- package/addon/{constants.js → constants.ts} +15 -3
- package/addon/ember-nodes/table-of-contents.ts +53 -0
- package/addon/helpers/{limit-text.js → limit-text.ts} +2 -2
- package/addon/initializers/plugin-initializer.js +0 -75
- package/addon/models/instruction.ts +18 -0
- package/addon/models/measure.ts +38 -0
- package/addon/models/sign.ts +36 -0
- package/addon/models/template.ts +14 -0
- package/addon/plugins/article-structure-plugin.ts +55 -0
- package/addon/plugins/besluit-plugin.ts +27 -0
- package/addon/plugins/besluit-type-plugin.ts +6 -0
- package/addon/plugins/citation-plugin/index.ts +216 -0
- package/addon/plugins/citation-plugin/marks/citation.ts +27 -0
- package/addon/plugins/citation-plugin/utils/cited-text.ts +17 -0
- package/addon/plugins/citation-plugin/utils/process-match.ts +135 -0
- package/addon/{utils/vlaamse-codex.js → plugins/citation-plugin/utils/vlaamse-codex.ts} +161 -42
- package/addon/plugins/import-snippet-plugin.ts +6 -0
- package/addon/plugins/insert-variable-plugin.ts +11 -0
- package/addon/plugins/rdfa-date-plugin.ts +11 -0
- package/addon/plugins/roadsign-regulation-plugin.ts +6 -0
- package/addon/plugins/standard-template-plugin.ts +6 -0
- package/addon/plugins/table-of-contents-plugin.ts +14 -0
- package/addon/plugins/template-variable-plugin.ts +6 -0
- package/addon/services/{import-rdfa-snippet.js → import-rdfa-snippet.ts} +48 -36
- package/addon/services/roadsign-registry.ts +288 -0
- package/addon/services/{standard-template-plugin.js → standard-template-plugin.ts} +17 -11
- package/addon/utils/article-structure-plugin/constants.ts +260 -0
- package/addon/utils/article-structure-plugin/defaults.ts +3 -0
- package/addon/utils/article-structure-plugin/options-with-defaults.ts +31 -0
- package/addon/utils/article-structure-plugin/validate-datastore.ts +23 -0
- package/addon/utils/besluit-plugin/get-title-for-decision.ts +35 -0
- package/addon/utils/{fetchBesluitTypes.js → fetchBesluitTypes.ts} +36 -16
- package/addon/utils/generate-template-plugin/{default-resources.js → default-resources.ts} +0 -0
- package/addon/utils/{instantiate-uuids.js → instantiate-uuids.ts} +9 -6
- package/addon/utils/{legislation-types.js → legislation-types.ts} +17 -3
- package/addon/utils/{memoize.js → memoize.ts} +4 -2
- package/addon/utils/option.ts +58 -0
- package/addon/utils/roadsign-regulation-plugin/{fetchData.js → fetchData.ts} +19 -2
- package/addon/utils/roadsign-regulation-plugin/includeInstructions.ts +16 -0
- package/addon/utils/romanize.ts +47 -0
- package/addon/utils/variable-plugins/{default-variable-types.js → default-variable-types.ts} +18 -7
- package/addon/utils/variable-plugins/{fetch-data.js → fetch-data.ts} +43 -15
- package/app/components/article-structure-plugin/article-structure-card.js +1 -0
- package/app/components/article-structure-plugin/structure-card.js +1 -0
- package/app/components/{citaten-plugin/citaat-card.js → au-native-input.js} +1 -1
- package/app/components/{citaten-plugin/citations/article-list.js → besluit-plugin/besluit-context-card.js} +1 -1
- package/app/components/besluit-plugin/besluit-plugin-card.js +1 -0
- package/app/components/{citaten-plugin/citations/modal.js → citation-plugin/citation-card.js} +1 -1
- package/app/components/citation-plugin/citation-insert.js +1 -0
- package/app/components/{citaten-plugin/citations/decision-list.js → citation-plugin/citations/article-list.js} +1 -1
- package/app/components/{citaten-plugin → citation-plugin}/citations/article-preview.js +1 -1
- package/app/components/{citaten-plugin → citation-plugin}/citations/decision-detail.js +1 -1
- package/app/components/citation-plugin/citations/decision-list.js +1 -0
- package/app/components/{citaten-plugin → citation-plugin}/citations/decision-preview.js +1 -1
- package/app/components/citation-plugin/citations/modal.js +1 -0
- package/app/components/{citaten-plugin → citation-plugin}/citations/search-modal.js +1 -1
- package/app/components/{citaten-plugin → citation-plugin}/helpers/alert-load-error.js +1 -1
- package/app/components/{citaten-plugin → citation-plugin}/helpers/alert-no-items.js +1 -1
- package/app/components/{citaten-plugin/citaat-insert.js → rdfa-date-plugin/card.js} +1 -1
- package/app/components/rdfa-date-plugin/date-time-picker.js +1 -0
- package/app/components/rdfa-date-plugin/insert.js +1 -0
- package/app/components/standard-template-plugin/card.js +1 -0
- package/app/components/table-of-contents-plugin/ember-nodes/outline.js +1 -0
- package/app/components/table-of-contents-plugin/ember-nodes/table-of-contents.js +1 -0
- package/app/styles/citaten-plugin.scss +1 -1
- package/commands/article-structure-plugin/delete-structure.d.ts +4 -0
- package/commands/article-structure-plugin/index.d.ts +4 -0
- package/commands/article-structure-plugin/insert-article-structure.d.ts +6 -0
- package/commands/article-structure-plugin/move-structure.d.ts +5 -0
- package/commands/article-structure-plugin/recalculate-structure-numbers.d.ts +7 -0
- package/commands/besluit-plugin/get-article-nodes-for-besluit.d.ts +5 -0
- package/commands/besluit-plugin/index.d.ts +4 -0
- package/commands/besluit-plugin/insert-article.d.ts +3 -0
- package/commands/besluit-plugin/insert-title.d.ts +2 -0
- package/commands/besluit-plugin/move-article.d.ts +2 -0
- package/commands/besluit-plugin/recalculate-article-numbers.d.ts +2 -0
- package/commands/modify-date-command.d.ts +2 -0
- package/components/article-structure-plugin/article-structure-card.d.ts +36 -0
- package/components/article-structure-plugin/structure-card.d.ts +23 -0
- package/components/au-native-input.d.ts +20 -0
- package/components/besluit-plugin/besluit-context-card.d.ts +29 -0
- package/components/besluit-plugin/besluit-plugin-card.d.ts +14 -0
- package/components/besluit-type-plugin/besluit-type-select.d.ts +11 -0
- package/components/besluit-type-plugin/toolbar-dropdown.d.ts +46 -0
- package/components/citation-plugin/citation-card.d.ts +51 -0
- package/components/citation-plugin/citation-insert.d.ts +24 -0
- package/components/citation-plugin/citations/decision-detail.d.ts +26 -0
- package/components/citation-plugin/citations/search-modal.d.ts +67 -0
- package/components/import-snippet-plugin/card.d.ts +19 -0
- package/components/insert-variable-plugin/insert-variable-card.d.ts +31 -0
- package/components/rdfa-date-plugin/card.d.ts +20 -0
- package/components/rdfa-date-plugin/date-time-picker.d.ts +32 -0
- package/components/rdfa-date-plugin/insert.d.ts +12 -0
- package/components/roadsign-regulation-plugin/expanded-measure.d.ts +20 -0
- package/components/roadsign-regulation-plugin/measure-template.d.ts +14 -0
- package/components/roadsign-regulation-plugin/roadsign-regulation-card.d.ts +12 -0
- package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +57 -0
- package/components/roadsign-regulation-plugin/roadsigns-pagination.d.ts +19 -0
- package/components/roadsign-regulation-plugin/roadsigns-table.d.ts +9 -0
- package/components/standard-template-plugin/card.d.ts +9 -0
- package/components/standard-template-plugin/template-provider.d.ts +17 -0
- package/components/table-of-contents-plugin/card.d.ts +20 -0
- package/components/table-of-contents-plugin/ember-nodes/table-of-contents.d.ts +22 -0
- package/components/template-variable-plugin/template-variable-card.d.ts +27 -0
- package/constants.d.ts +11 -0
- package/ember-nodes/table-of-contents.d.ts +4 -0
- package/helpers/limit-text.d.ts +8 -0
- package/index.js +5 -0
- package/models/instruction.d.ts +8 -0
- package/models/measure.d.ts +14 -0
- package/models/sign.d.ts +12 -0
- package/models/template.d.ts +13 -0
- package/package.json +27 -8
- package/plugins/article-structure-plugin.d.ts +29 -0
- package/plugins/besluit-plugin.d.ts +9 -0
- package/plugins/besluit-type-plugin.d.ts +2 -0
- package/plugins/citation-plugin/index.d.ts +31 -0
- package/plugins/citation-plugin/marks/citation.d.ts +2 -0
- package/plugins/citation-plugin/utils/cited-text.d.ts +3 -0
- package/plugins/citation-plugin/utils/process-match.d.ts +23 -0
- package/plugins/citation-plugin/utils/vlaamse-codex.d.ts +56 -0
- package/plugins/import-snippet-plugin.d.ts +2 -0
- package/plugins/insert-variable-plugin.d.ts +2 -0
- package/plugins/rdfa-date-plugin.d.ts +3 -0
- package/plugins/roadsign-regulation-plugin.d.ts +2 -0
- package/plugins/standard-template-plugin.d.ts +2 -0
- package/plugins/table-of-contents-plugin.d.ts +3 -0
- package/plugins/template-variable-plugin.d.ts +2 -0
- package/services/import-rdfa-snippet.d.ts +99 -0
- package/services/roadsign-registry.d.ts +42 -0
- package/services/standard-template-plugin.d.ts +21 -0
- package/translations/en-US.yaml +47 -1
- package/translations/nl-BE.yaml +49 -3
- package/tsconfig.json +34 -9
- package/types/config/environment.d.ts +22 -0
- package/types/ember-mu-transform-helpers/transforms/string-set.d.ts +14 -0
- package/types/lblod/frontend-gelinkt-notuleren/models/account.d.ts +10 -0
- package/types/lblod/frontend-gelinkt-notuleren/models/bestuurseenheid-classificatie-code.d.ts +10 -0
- package/types/lblod/frontend-gelinkt-notuleren/models/bestuurseenheid.d.ts +12 -0
- package/types/lblod/frontend-gelinkt-notuleren/models/gebruiker-model.d.ts +18 -0
- package/types/lblod/frontend-gelinkt-notuleren/services/current-session.d.ts +30 -0
- package/types/lblod/marawa/dom-helpers.d.ts +4 -0
- package/types/lblod/marawa/ember-object-mock.d.ts +3 -0
- package/types/lblod/marawa/node-walker.d.ts +18 -0
- package/types/lblod/marawa/range-helpers.d.ts +10 -0
- package/types/lblod/marawa/rdfa-attributes.d.ts +25 -0
- package/types/lblod/marawa/rdfa-block.d.ts +22 -0
- package/types/lblod/marawa/rdfa-context-scanner.d.ts +13 -0
- package/types/lblod/marawa/rdfa-helpers.d.ts +22 -0
- package/types/lblod/marawa/rich-node.d.ts +50 -0
- package/types/lblod/marawa/triple.d.ts +16 -0
- package/utils/article-structure-plugin/constants.d.ts +2 -0
- package/utils/article-structure-plugin/defaults.d.ts +4 -0
- package/utils/article-structure-plugin/options-with-defaults.d.ts +2 -0
- package/utils/article-structure-plugin/validate-datastore.d.ts +3 -0
- package/utils/besluit-plugin/get-title-for-decision.d.ts +10 -0
- package/utils/fetchBesluitTypes.d.ts +12 -0
- package/utils/generate-template-plugin/default-resources.d.ts +2 -0
- package/utils/instantiate-uuids.d.ts +1 -0
- package/utils/legislation-types.d.ts +24 -0
- package/utils/memoize.d.ts +1 -0
- package/utils/option.d.ts +14 -0
- package/utils/roadsign-regulation-plugin/fetchData.d.ts +8 -0
- package/utils/roadsign-regulation-plugin/includeInstructions.d.ts +2 -0
- package/utils/romanize.d.ts +2 -0
- package/utils/variable-plugins/default-variable-types.d.ts +7 -0
- package/utils/variable-plugins/fetch-data.d.ts +14 -0
- package/addon/commands/generate-template-command.js +0 -35
- package/addon/commands/insert-and-collapse.js +0 -32
- package/addon/commands/modify-date-command.js +0 -42
- package/addon/components/besluit-type-plugin/toolbar-dropdown.js +0 -188
- package/addon/components/citaten-plugin/citaat-card.hbs +0 -76
- package/addon/components/citaten-plugin/citaat-card.js +0 -286
- package/addon/components/citaten-plugin/citaat-insert.hbs +0 -20
- package/addon/components/citaten-plugin/citaat-insert.js +0 -68
- package/addon/components/citaten-plugin/citations/search-modal.hbs +0 -175
- package/addon/components/import-snippet-plugin/card.js +0 -95
- package/addon/components/insert-variable-plugin/insert-variable-card.js +0 -125
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -71
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -24
- package/addon/components/roadsign-regulation-plugin/expanded-measure.js +0 -38
- package/addon/components/roadsign-regulation-plugin/measure-template.js +0 -30
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.js +0 -101
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.js +0 -24
- package/addon/components/standard-template-plugin/template-card.js +0 -7
- package/addon/components/standard-template-plugin/template-provider.js +0 -75
- package/addon/components/table-of-contents-plugin/card.js +0 -53
- package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.hbs +0 -9
- package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -100
- package/addon/components/template-variable-plugin/template-variable-card.js +0 -230
- package/addon/inline-components/table-of-contents.js +0 -43
- package/addon/models/instruction.js +0 -19
- package/addon/models/measure.js +0 -46
- package/addon/models/sign.js +0 -37
- package/addon/models/template.js +0 -9
- package/addon/plugins/besluit-type-plugin.js +0 -16
- package/addon/plugins/citaten-plugin.js +0 -22
- package/addon/plugins/import-snippet-plugin.js +0 -16
- package/addon/plugins/insert-variable-plugin.js +0 -19
- package/addon/plugins/rdfa-date-plugin.js +0 -26
- package/addon/plugins/roadsign-regulation-plugin.js +0 -24
- package/addon/plugins/standard-template-plugin.js +0 -33
- package/addon/plugins/table-of-contents-plugin.js +0 -27
- package/addon/plugins/template-variable-plugin.js +0 -21
- package/addon/services/roadsign-registry.js +0 -240
- package/addon/utils/processMatch.js +0 -80
- package/addon/utils/roadsign-regulation-plugin/includeInstructions.js +0 -10
- package/app/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -1
- package/app/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -1
- package/app/components/rdfa-date-plugin/rdfa-date-time-picker.js +0 -1
- package/app/components/standard-template-plugin/template-card.js +0 -1
- package/app/components/table-of-contents-plugin/inline-components/outline.js +0 -1
- package/app/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -1
- package/app/initializers/plugin-initializer.js +0 -4
- package/types/dummy/index.d.ts +0 -1
- package/types/ember-data/types/registries/model.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,31 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
|
|
11
|
+
## 1.0.0-alpha.1 (2022-12-22)
|
|
12
|
+
|
|
13
|
+
#### :rocket: Enhancement
|
|
14
|
+
* [#35](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/35) converting the besluit-plugin to new API ([@usrtim](https://github.com/usrtim))
|
|
15
|
+
* [#34](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/34) Add and convert citation plugin ([@abeforgit](https://github.com/abeforgit))
|
|
16
|
+
* [#32](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/32) Convert table-of-contents plugin to prosemirror based editor. ([@elpoelma](https://github.com/elpoelma))
|
|
17
|
+
* [#33](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/33) feature/dev utils ([@abeforgit](https://github.com/abeforgit))
|
|
18
|
+
* [#31](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/31) Convert roadsign-regulation plugin to prosemirror based editor. ([@elpoelma](https://github.com/elpoelma))
|
|
19
|
+
* [#28](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/28) Convert insert-variable plugin to prosemirror based editor. ([@elpoelma](https://github.com/elpoelma))
|
|
20
|
+
* [#29](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/29) Convert template-variable plugin to prosemirror based editor. ([@elpoelma](https://github.com/elpoelma))
|
|
21
|
+
* [#20](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/20) Convert standard-template plugin to prosemirror based editor plugin ([@elpoelma](https://github.com/elpoelma))
|
|
22
|
+
* [#19](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/19) Convert import-snippet plugin to prosemirror based editor plugin ([@elpoelma](https://github.com/elpoelma))
|
|
23
|
+
* [#18](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/18) Convert besluit-type plugin to prosemirror based editor plugin ([@elpoelma](https://github.com/elpoelma))
|
|
24
|
+
* [#17](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/17) Convert rdfa-date plugin to prosemirror based editor plugin ([@elpoelma](https://github.com/elpoelma))
|
|
25
|
+
|
|
26
|
+
#### :house: Internal
|
|
27
|
+
* [#26](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/26) Convert besluit-type, import-snippet, rdfa-date and standard-template plugins to typescript ([@elpoelma](https://github.com/elpoelma))
|
|
28
|
+
|
|
29
|
+
#### Committers: 4
|
|
30
|
+
- Arne Bertrand ([@abeforgit](https://github.com/abeforgit))
|
|
31
|
+
- Elena Poelman ([@elpoelma](https://github.com/elpoelma))
|
|
32
|
+
- Oscar Rodriguez Villalobos ([@lagartoverde](https://github.com/lagartoverde))
|
|
33
|
+
- [@usrtim](https://github.com/usrtim)
|
|
34
|
+
|
|
10
35
|
## 0.4.1 (2022-12-02)
|
|
11
36
|
|
|
12
37
|
#### :bug: Bug Fix
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ProseController } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { ResolvedArticleStructurePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
|
|
3
|
+
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
4
|
+
import { Command } from 'prosemirror-state';
|
|
5
|
+
import recalculateStructureNumbers from './recalculate-structure-numbers';
|
|
6
|
+
|
|
7
|
+
export default function deleteStructure(
|
|
8
|
+
controller: ProseController,
|
|
9
|
+
uri: string,
|
|
10
|
+
options: ResolvedArticleStructurePluginOptions
|
|
11
|
+
): Command {
|
|
12
|
+
return (state, dispatch) => {
|
|
13
|
+
if (dispatch) {
|
|
14
|
+
const structureToDeleteRange = [
|
|
15
|
+
...controller.datastore.match(`>${uri}`).asSubjectNodeMapping().nodes(),
|
|
16
|
+
][0];
|
|
17
|
+
const structureToDeleteTypes = [
|
|
18
|
+
...controller.datastore
|
|
19
|
+
.match(`>${uri}`, 'a')
|
|
20
|
+
.asQuadResultSet()
|
|
21
|
+
.map((quad) => quad.object.value),
|
|
22
|
+
];
|
|
23
|
+
if (!structureToDeleteRange) {
|
|
24
|
+
throw new Error(`No node found for resource ${uri}`);
|
|
25
|
+
}
|
|
26
|
+
if (!structureToDeleteTypes) {
|
|
27
|
+
throw new Error(`No type found for resource ${uri}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const resolvedPos = state.doc.resolve(structureToDeleteRange.from);
|
|
31
|
+
const container = resolvedPos.parent;
|
|
32
|
+
let containerRange = {
|
|
33
|
+
from: resolvedPos.before(),
|
|
34
|
+
to: resolvedPos.before() + container.nodeSize,
|
|
35
|
+
};
|
|
36
|
+
const tr = state.tr;
|
|
37
|
+
if (container.childCount === 1) {
|
|
38
|
+
const placeholder = controller.schema.node('placeholder', {
|
|
39
|
+
placeholderText: 'Voer inhoud in',
|
|
40
|
+
});
|
|
41
|
+
tr.replaceRangeWith(
|
|
42
|
+
structureToDeleteRange.from,
|
|
43
|
+
structureToDeleteRange.to,
|
|
44
|
+
placeholder
|
|
45
|
+
);
|
|
46
|
+
} else {
|
|
47
|
+
tr.delete(structureToDeleteRange.from, structureToDeleteRange.to);
|
|
48
|
+
}
|
|
49
|
+
dispatch(tr);
|
|
50
|
+
containerRange = {
|
|
51
|
+
from: tr.mapping.map(containerRange.from),
|
|
52
|
+
to: tr.mapping.map(containerRange.to),
|
|
53
|
+
};
|
|
54
|
+
const currentStructureIndex = options.structures.findIndex((structure) =>
|
|
55
|
+
structureToDeleteTypes.includes(structure.type)
|
|
56
|
+
);
|
|
57
|
+
const currentStructure = unwrap(
|
|
58
|
+
options.structures[currentStructureIndex]
|
|
59
|
+
);
|
|
60
|
+
controller.doCommand(
|
|
61
|
+
recalculateStructureNumbers(
|
|
62
|
+
controller,
|
|
63
|
+
containerRange,
|
|
64
|
+
currentStructure,
|
|
65
|
+
options
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
recalculateContinuousStructures(controller, options);
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function recalculateContinuousStructures(
|
|
75
|
+
controller: ProseController,
|
|
76
|
+
options: ResolvedArticleStructurePluginOptions
|
|
77
|
+
) {
|
|
78
|
+
for (const structure of options.structures) {
|
|
79
|
+
if (structure.numbering === 'continuous') {
|
|
80
|
+
controller.doCommand(
|
|
81
|
+
recalculateStructureNumbers(controller, null, structure, options)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as deleteStructure } from './delete-structure';
|
|
2
|
+
export { default as insertArticleStructure } from './insert-article-structure';
|
|
3
|
+
export { default as moveStructure } from './move-structure';
|
|
4
|
+
export { default as recalculateStructureNumbers } from './recalculate-structure-numbers';
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { v4 as uuid } from 'uuid';
|
|
2
|
+
import { ProseController, TextSelection } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import IntlService from 'ember-intl/services/intl';
|
|
4
|
+
import { Command } from 'prosemirror-state';
|
|
5
|
+
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
6
|
+
import ValidationReport from 'rdf-validate-shacl/src/validation-report';
|
|
7
|
+
import { findNodes } from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
8
|
+
import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
|
|
9
|
+
import recalculateStructureNumbers from './recalculate-structure-numbers';
|
|
10
|
+
import { ResolvedArticleStructurePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
|
|
11
|
+
import { getRdfaAttribute } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
|
|
12
|
+
|
|
13
|
+
export default function insertArticleStructureV2(
|
|
14
|
+
controller: ProseController,
|
|
15
|
+
structureName: string,
|
|
16
|
+
options: ResolvedArticleStructurePluginOptions,
|
|
17
|
+
report: ValidationReport,
|
|
18
|
+
intlService: IntlService
|
|
19
|
+
): Command {
|
|
20
|
+
return (_state, dispatch) => {
|
|
21
|
+
const structureTypeToAdd = options.structures.find(
|
|
22
|
+
(structure) => structure.title === structureName
|
|
23
|
+
);
|
|
24
|
+
if (!structureTypeToAdd) {
|
|
25
|
+
console.warn(`Structure type ${structureName} not recognized`);
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const structureUri = `${structureTypeToAdd.uriBase}${uuid()}`;
|
|
29
|
+
const urisNotAllowedToInsert = report.results.map(
|
|
30
|
+
(result) => result.focusNode?.value
|
|
31
|
+
);
|
|
32
|
+
const { selection } = controller.state;
|
|
33
|
+
const filterFunction = ({ from }: { from: number }) => {
|
|
34
|
+
const node = unwrap(controller.state.doc.nodeAt(from));
|
|
35
|
+
const nodeUri = getRdfaAttribute(node, 'resource').pop();
|
|
36
|
+
if (nodeUri && !urisNotAllowedToInsert.includes(nodeUri)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
let structureContainerRange =
|
|
43
|
+
findNodes(
|
|
44
|
+
controller.state.doc,
|
|
45
|
+
selection.from,
|
|
46
|
+
true,
|
|
47
|
+
false,
|
|
48
|
+
filterFunction
|
|
49
|
+
).next().value ??
|
|
50
|
+
findNodes(
|
|
51
|
+
controller.state.doc,
|
|
52
|
+
selection.from,
|
|
53
|
+
true,
|
|
54
|
+
true,
|
|
55
|
+
filterFunction
|
|
56
|
+
).next().value;
|
|
57
|
+
|
|
58
|
+
if (!structureContainerRange) return false;
|
|
59
|
+
const structureContainerNode = unwrap(
|
|
60
|
+
controller.state.doc.nodeAt(structureContainerRange.from)
|
|
61
|
+
);
|
|
62
|
+
if (structureTypeToAdd.insertPredicate) {
|
|
63
|
+
const structureContainerUri = getRdfaAttribute(
|
|
64
|
+
structureContainerNode,
|
|
65
|
+
'resource'
|
|
66
|
+
).pop();
|
|
67
|
+
if (!structureContainerUri) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
structureContainerRange = [
|
|
71
|
+
...controller.datastore
|
|
72
|
+
.match(
|
|
73
|
+
`>${structureContainerUri}`,
|
|
74
|
+
`>${structureTypeToAdd.insertPredicate.long}`
|
|
75
|
+
)
|
|
76
|
+
.asPredicateNodeMapping()
|
|
77
|
+
.nodes(),
|
|
78
|
+
][0];
|
|
79
|
+
}
|
|
80
|
+
if (!structureContainerRange) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (dispatch) {
|
|
84
|
+
const structureHtml = structureTypeToAdd.template(
|
|
85
|
+
structureUri,
|
|
86
|
+
intlService
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
//Detect if structureContainer only contains a placeholder, if so replace the full content of the structureContainer
|
|
90
|
+
let insertRange: { from: number; to: number };
|
|
91
|
+
if (
|
|
92
|
+
structureContainerNode.childCount === 1 &&
|
|
93
|
+
structureContainerNode.child(0).childCount === 1 &&
|
|
94
|
+
structureContainerNode.child(0).child(0).type ===
|
|
95
|
+
controller.schema.nodes['placeholder']
|
|
96
|
+
) {
|
|
97
|
+
insertRange = {
|
|
98
|
+
from: structureContainerRange.from + 1,
|
|
99
|
+
to: structureContainerRange.to - 1,
|
|
100
|
+
};
|
|
101
|
+
} else {
|
|
102
|
+
insertRange = {
|
|
103
|
+
from: structureContainerRange.to - 1,
|
|
104
|
+
to: structureContainerRange.to - 1,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
controller.doCommand(
|
|
108
|
+
insertHtml(structureHtml, insertRange.from, insertRange.to)
|
|
109
|
+
);
|
|
110
|
+
const containerNode = unwrap(
|
|
111
|
+
controller.state.doc.nodeAt(structureContainerRange.from)
|
|
112
|
+
);
|
|
113
|
+
const containerRange = {
|
|
114
|
+
from: structureContainerRange.from,
|
|
115
|
+
to: structureContainerRange.from + containerNode.nodeSize,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
controller.doCommand(
|
|
119
|
+
recalculateStructureNumbers(
|
|
120
|
+
controller,
|
|
121
|
+
containerRange,
|
|
122
|
+
structureTypeToAdd,
|
|
123
|
+
options
|
|
124
|
+
)
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const selection = TextSelection.near(
|
|
128
|
+
controller.state.doc.resolve(insertRange.from)
|
|
129
|
+
);
|
|
130
|
+
controller.withTransaction((tr) => {
|
|
131
|
+
return tr.setSelection(selection);
|
|
132
|
+
});
|
|
133
|
+
controller.focus();
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/* eslint-disable prettier/prettier */
|
|
2
|
+
import {
|
|
3
|
+
ProseController,
|
|
4
|
+
TextSelection,
|
|
5
|
+
} from '@lblod/ember-rdfa-editor';
|
|
6
|
+
import { Command } from 'prosemirror-state';
|
|
7
|
+
import ValidationReport from 'rdf-validate-shacl/src/validation-report';
|
|
8
|
+
import {
|
|
9
|
+
findChildren,
|
|
10
|
+
findNodes,
|
|
11
|
+
} from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
12
|
+
import recalculateStructureNumbers from './recalculate-structure-numbers';
|
|
13
|
+
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
14
|
+
import { ResolvedArticleStructurePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
|
|
15
|
+
import { getRdfaAttribute } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
|
|
16
|
+
export default function moveStructure(
|
|
17
|
+
controller: ProseController,
|
|
18
|
+
structureURI: string,
|
|
19
|
+
moveUp: boolean,
|
|
20
|
+
options: ResolvedArticleStructurePluginOptions,
|
|
21
|
+
report: ValidationReport
|
|
22
|
+
): Command {
|
|
23
|
+
return (state, dispatch) => {
|
|
24
|
+
const structureRange = controller.datastore
|
|
25
|
+
.match(`>${structureURI}`)
|
|
26
|
+
.asSubjectNodeMapping()
|
|
27
|
+
.single()?.nodes[0];
|
|
28
|
+
if (!structureRange) {
|
|
29
|
+
console.warn(`Structure with URI ${structureURI} not found, cancelling move command`);
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const resolvedStructurePos = state.doc.resolve(structureRange?.from);
|
|
34
|
+
const structureContainer = resolvedStructurePos.parent;
|
|
35
|
+
let structureContainerRange = { from: resolvedStructurePos.before(), to: resolvedStructurePos.before() + structureContainer.nodeSize};
|
|
36
|
+
const structures = [
|
|
37
|
+
...findChildren(
|
|
38
|
+
controller.state.doc,
|
|
39
|
+
structureContainerRange.from,
|
|
40
|
+
false,
|
|
41
|
+
false,
|
|
42
|
+
({ from }) => !controller.state.doc.nodeAt(from)?.isText
|
|
43
|
+
),
|
|
44
|
+
];
|
|
45
|
+
const structureIndex = structures.findIndex(
|
|
46
|
+
(structure) => structure.from === structureRange.from && structure.to === structureRange.to
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// The type of the structure we want to move
|
|
50
|
+
const currentStructureType = controller.datastore
|
|
51
|
+
.match(`>${structureURI}`, 'a')
|
|
52
|
+
.asQuadResultSet()
|
|
53
|
+
.first()?.object.value;
|
|
54
|
+
|
|
55
|
+
// The spec describing the structure we want to move
|
|
56
|
+
const currentStructureSpec = options.structures.find(
|
|
57
|
+
(structureSpec) => structureSpec.type === currentStructureType
|
|
58
|
+
);
|
|
59
|
+
if(!currentStructureSpec){
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if (
|
|
63
|
+
((structureIndex !== 0 && moveUp) ||
|
|
64
|
+
(structureIndex !== structures.length - 1 && !moveUp)) &&
|
|
65
|
+
structures.length > 1
|
|
66
|
+
) {
|
|
67
|
+
if (dispatch) {
|
|
68
|
+
let structureARange: { from: number, to: number };
|
|
69
|
+
let structureBRange: { from: number, to: number };
|
|
70
|
+
if (moveUp) {
|
|
71
|
+
structureARange = unwrap(structures[structureIndex - 1]);
|
|
72
|
+
structureBRange = unwrap(structures[structureIndex]);
|
|
73
|
+
} else {
|
|
74
|
+
structureARange = unwrap(structures[structureIndex]);
|
|
75
|
+
structureBRange = unwrap(structures[structureIndex + 1]);
|
|
76
|
+
}
|
|
77
|
+
const structureBNode = unwrap(controller.state.doc.nodeAt(structureBRange.from));
|
|
78
|
+
controller.withTransaction((tr) => {
|
|
79
|
+
tr.delete(structureBRange.from, structureBRange.to);
|
|
80
|
+
return tr.replaceRangeWith(structureARange.from, structureARange.from, structureBNode);
|
|
81
|
+
});
|
|
82
|
+
const structureContainer = unwrap(
|
|
83
|
+
controller.state.doc.nodeAt(structureContainerRange.from)
|
|
84
|
+
);
|
|
85
|
+
structureContainerRange = {
|
|
86
|
+
from: structureContainerRange.from,
|
|
87
|
+
to: structureContainerRange.from + structureContainer.nodeSize,
|
|
88
|
+
};
|
|
89
|
+
controller.doCommand(
|
|
90
|
+
recalculateStructureNumbers(
|
|
91
|
+
controller,
|
|
92
|
+
structureContainerRange,
|
|
93
|
+
currentStructureSpec,
|
|
94
|
+
options
|
|
95
|
+
)
|
|
96
|
+
);
|
|
97
|
+
recalculateContinuousStructures(controller, options);
|
|
98
|
+
|
|
99
|
+
// We place our resulting selection in the title of the structure
|
|
100
|
+
const headingRange = unwrap([
|
|
101
|
+
...controller.datastore
|
|
102
|
+
.match(`>${structureURI}`, 'ext:title')
|
|
103
|
+
.asPredicateNodeMapping()
|
|
104
|
+
.nodes(),
|
|
105
|
+
][0]);
|
|
106
|
+
const newSelection = TextSelection.near(
|
|
107
|
+
controller.state.doc.resolve(headingRange.to)
|
|
108
|
+
);
|
|
109
|
+
controller.withTransaction((tr) => {
|
|
110
|
+
return tr.setSelection(newSelection);
|
|
111
|
+
});
|
|
112
|
+
controller.focus();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return true;
|
|
116
|
+
} else {
|
|
117
|
+
const urisNotAllowedToInsert = report.results.map(
|
|
118
|
+
(result) => result.focusNode?.value
|
|
119
|
+
);
|
|
120
|
+
const structureContainerURI = (getRdfaAttribute(structureContainer, 'resource').pop()) ?? (getRdfaAttribute(resolvedStructurePos.node(resolvedStructurePos.depth - 1), 'resource').pop());
|
|
121
|
+
const filterFunction = ({ from }: { from: number }) => {
|
|
122
|
+
const node = unwrap(controller.state.doc.nodeAt(from));
|
|
123
|
+
const nodeUri = getRdfaAttribute(node, 'resource').pop();
|
|
124
|
+
if(structureContainerURI === nodeUri) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return !!nodeUri && !urisNotAllowedToInsert.includes(nodeUri);
|
|
128
|
+
};
|
|
129
|
+
// The new structure container we want to move our structure in to.
|
|
130
|
+
let newStructureContainerRange: { from: number, to: number } | void = findNodes(
|
|
131
|
+
controller.state.doc,
|
|
132
|
+
structureRange.from,
|
|
133
|
+
true,
|
|
134
|
+
moveUp,
|
|
135
|
+
filterFunction
|
|
136
|
+
).next().value;
|
|
137
|
+
if (!newStructureContainerRange) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
const newStructureContainerNode = unwrap(controller.state.doc.nodeAt(newStructureContainerRange.from));
|
|
141
|
+
|
|
142
|
+
const newStructureContainerURI = getRdfaAttribute(newStructureContainerNode, 'resource').pop();
|
|
143
|
+
// Check if there is a specific predicate container we need to insert inside
|
|
144
|
+
if (currentStructureSpec.insertPredicate) {
|
|
145
|
+
newStructureContainerRange = findChildren(controller.state.doc, newStructureContainerRange.from, false, false, ({ from }) => getRdfaAttribute(unwrap(controller.state.doc.nodeAt(from)), 'property').pop() === currentStructureSpec.insertPredicate?.short).next().value;
|
|
146
|
+
}
|
|
147
|
+
if(!newStructureContainerRange){
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if(dispatch){
|
|
151
|
+
let insertRange: {from: number, to: number};
|
|
152
|
+
|
|
153
|
+
// Check if the newStructureContainer we want to insert to only contains a placeholder
|
|
154
|
+
if (
|
|
155
|
+
newStructureContainerNode.childCount === 1 &&
|
|
156
|
+
newStructureContainerNode.child(0).childCount === 1 &&
|
|
157
|
+
newStructureContainerNode.child(0).child(0).type ===
|
|
158
|
+
controller.schema.nodes['placeholder']
|
|
159
|
+
) {
|
|
160
|
+
insertRange = {from: newStructureContainerRange.from + 1, to: newStructureContainerRange.to - 1};
|
|
161
|
+
} else {
|
|
162
|
+
insertRange = {from: newStructureContainerRange.to - 1, to: newStructureContainerRange.to - 1};
|
|
163
|
+
}
|
|
164
|
+
const structureNode = unwrap(controller.state.doc.nodeAt(structureRange.from));
|
|
165
|
+
controller.withTransaction((tr) => {
|
|
166
|
+
tr.replaceRangeWith(insertRange.from, insertRange.to, structureNode);
|
|
167
|
+
const oldStructureRange = { from: tr.mapping.map(structureRange.from), to: tr.mapping.map(structureRange.to)};
|
|
168
|
+
const replacementNode = structureContainer.childCount === 0 && controller.schema.node('placeholder', { placeholderText: 'Voer inhoud in'});
|
|
169
|
+
if(replacementNode){
|
|
170
|
+
tr.replaceRangeWith(oldStructureRange.from, oldStructureRange.to, replacementNode);
|
|
171
|
+
} else {
|
|
172
|
+
tr.delete(oldStructureRange.from, oldStructureRange.to);
|
|
173
|
+
}
|
|
174
|
+
return tr;
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const originalContainerRange = unwrap([...controller.datastore.match(`>${structureContainerURI as string}`).asSubjectNodeMapping().nodes()][0]);
|
|
178
|
+
const newContainerRange = unwrap([...controller.datastore.match(`>${newStructureContainerURI as string}`).asSubjectNodeMapping().nodes()][0]);
|
|
179
|
+
controller.doCommand(
|
|
180
|
+
recalculateStructureNumbers(
|
|
181
|
+
controller,
|
|
182
|
+
originalContainerRange,
|
|
183
|
+
currentStructureSpec,
|
|
184
|
+
options
|
|
185
|
+
)
|
|
186
|
+
);
|
|
187
|
+
controller.doCommand(
|
|
188
|
+
recalculateStructureNumbers(
|
|
189
|
+
controller,
|
|
190
|
+
newContainerRange,
|
|
191
|
+
currentStructureSpec,
|
|
192
|
+
options
|
|
193
|
+
)
|
|
194
|
+
);
|
|
195
|
+
recalculateContinuousStructures(controller, options);
|
|
196
|
+
const headingRange = unwrap([
|
|
197
|
+
...controller.datastore
|
|
198
|
+
.match(`>${structureURI}`, 'ext:title')
|
|
199
|
+
.asPredicateNodeMapping()
|
|
200
|
+
.nodes(),
|
|
201
|
+
][0]);
|
|
202
|
+
const newSelection = TextSelection.near(
|
|
203
|
+
controller.state.doc.resolve(headingRange.to)
|
|
204
|
+
);
|
|
205
|
+
controller.withTransaction((tr) => {
|
|
206
|
+
return tr.setSelection(newSelection);
|
|
207
|
+
});
|
|
208
|
+
controller.focus();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function recalculateContinuousStructures(
|
|
217
|
+
controller: ProseController,
|
|
218
|
+
options: ResolvedArticleStructurePluginOptions
|
|
219
|
+
) {
|
|
220
|
+
for (const structure of options.structures) {
|
|
221
|
+
if (structure.numbering === 'continuous') {
|
|
222
|
+
controller.doCommand(
|
|
223
|
+
recalculateStructureNumbers(controller, null, structure, options)
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ProseController } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import defaults from '@lblod/ember-rdfa-editor-lblod-plugins/utils/article-structure-plugin/defaults';
|
|
3
|
+
import { Command } from 'prosemirror-state';
|
|
4
|
+
import { ProseStore } from '@lblod/ember-rdfa-editor/utils/datastore/prose-store';
|
|
5
|
+
import { expect } from '@lblod/ember-rdfa-editor/utils/option';
|
|
6
|
+
import {
|
|
7
|
+
ResolvedArticleStructurePluginOptions,
|
|
8
|
+
StructureSpec,
|
|
9
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
|
|
10
|
+
|
|
11
|
+
export default function recalculateStructureNumbers(
|
|
12
|
+
controller: ProseController,
|
|
13
|
+
containerRange: { from: number; to: number } | undefined | null,
|
|
14
|
+
structureType: StructureSpec,
|
|
15
|
+
options: ResolvedArticleStructurePluginOptions
|
|
16
|
+
): Command {
|
|
17
|
+
return (_state, dispatch) => {
|
|
18
|
+
if (dispatch) {
|
|
19
|
+
let datastore: ProseStore;
|
|
20
|
+
if (structureType.numbering !== 'continuous' && containerRange) {
|
|
21
|
+
datastore = controller.datastore.limitToRange(
|
|
22
|
+
controller.state,
|
|
23
|
+
containerRange.from,
|
|
24
|
+
containerRange.to,
|
|
25
|
+
'rangeContains'
|
|
26
|
+
);
|
|
27
|
+
} else {
|
|
28
|
+
datastore = controller.datastore;
|
|
29
|
+
}
|
|
30
|
+
const structureMatch = [
|
|
31
|
+
...datastore
|
|
32
|
+
.match(null, 'a', `>${structureType.type}`)
|
|
33
|
+
.transformDataset((dataset) => {
|
|
34
|
+
return dataset.filter((quad) => {
|
|
35
|
+
return options.structureTypes.includes(quad.object.value);
|
|
36
|
+
});
|
|
37
|
+
})
|
|
38
|
+
.asSubjectNodeMapping(),
|
|
39
|
+
];
|
|
40
|
+
const structures = structureMatch.map((match) => {
|
|
41
|
+
return {
|
|
42
|
+
uri: match.term.value,
|
|
43
|
+
range: match.nodes[0],
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
if (!structures.length) return true;
|
|
47
|
+
for (let i = 0; i < structures.length; i++) {
|
|
48
|
+
replaceNumberIfNeeded(controller, structures[i], i, structureType);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function replaceNumberIfNeeded(
|
|
56
|
+
controller: ProseController,
|
|
57
|
+
structure: { range: { from: number; to: number }; uri: string },
|
|
58
|
+
index: number,
|
|
59
|
+
structureType: StructureSpec
|
|
60
|
+
) {
|
|
61
|
+
const numberPredicate =
|
|
62
|
+
structureType.numberPredicate || defaults.numberPredicate;
|
|
63
|
+
let structureNumberObjectNode = controller.datastore
|
|
64
|
+
.match(`>${structure.uri}`, `>${numberPredicate}`)
|
|
65
|
+
.asObjectNodeMapping()
|
|
66
|
+
.single();
|
|
67
|
+
structureNumberObjectNode = expect(
|
|
68
|
+
`${structure.uri} expected to have the predicate ${numberPredicate}`,
|
|
69
|
+
structureNumberObjectNode
|
|
70
|
+
);
|
|
71
|
+
const structureNumber = structureNumberObjectNode.term.value;
|
|
72
|
+
const structureNumberElement = structureNumberObjectNode.nodes[0];
|
|
73
|
+
if (!structureNumberElement) {
|
|
74
|
+
throw new Error('Could not find object node');
|
|
75
|
+
}
|
|
76
|
+
let structureNumberExpected: string;
|
|
77
|
+
if (structureType.numberingFunction) {
|
|
78
|
+
structureNumberExpected = structureType.numberingFunction(index + 1);
|
|
79
|
+
} else {
|
|
80
|
+
structureNumberExpected = (index + 1).toString();
|
|
81
|
+
}
|
|
82
|
+
if (structureNumber !== structureNumberExpected) {
|
|
83
|
+
const { from, to } = structureNumberElement;
|
|
84
|
+
controller.withTransaction((tr) => {
|
|
85
|
+
return tr.insertText(String(structureNumberExpected), from, to);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ProseController } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
3
|
+
|
|
4
|
+
export default function getArticleNodesForBesluit(
|
|
5
|
+
controller: ProseController,
|
|
6
|
+
besluitUri?: string
|
|
7
|
+
) {
|
|
8
|
+
if (!besluitUri) {
|
|
9
|
+
const selection = controller.state.selection;
|
|
10
|
+
besluitUri = controller.datastore
|
|
11
|
+
.limitToRange(controller.state, selection.from, selection.to)
|
|
12
|
+
.match(null, 'a', 'besluit:Besluit')
|
|
13
|
+
.asQuadResultSet()
|
|
14
|
+
.first()?.subject.value;
|
|
15
|
+
}
|
|
16
|
+
if (!besluitUri) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const articles = controller.datastore
|
|
20
|
+
.match(`>${besluitUri}`, 'eli:has_part')
|
|
21
|
+
.asObjectNodeMapping();
|
|
22
|
+
return [
|
|
23
|
+
...articles.map((article) => {
|
|
24
|
+
return {
|
|
25
|
+
uri: article.term.value,
|
|
26
|
+
range: unwrap(article.nodes.shift()),
|
|
27
|
+
};
|
|
28
|
+
}),
|
|
29
|
+
];
|
|
30
|
+
}
|