@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
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Decoration,
|
|
3
|
+
DecorationSet,
|
|
4
|
+
EditorState,
|
|
5
|
+
EditorStateConfig,
|
|
6
|
+
InlineDecorationSpec,
|
|
7
|
+
MarkSpec,
|
|
8
|
+
PNode,
|
|
9
|
+
ProsePlugin,
|
|
10
|
+
Schema,
|
|
11
|
+
WidgetSpec,
|
|
12
|
+
} from '@lblod/ember-rdfa-editor';
|
|
13
|
+
import {
|
|
14
|
+
datastoreKey,
|
|
15
|
+
ProseStore,
|
|
16
|
+
} from '@lblod/ember-rdfa-editor/plugins/datastore';
|
|
17
|
+
import processMatch, {
|
|
18
|
+
RegexpMatchArrayWithIndices,
|
|
19
|
+
} from './utils/process-match';
|
|
20
|
+
import { expect } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
21
|
+
import { citation } from './marks/citation';
|
|
22
|
+
|
|
23
|
+
const BASIC_MULTIPLANE_CHARACTER = '\u0021-\uFFFF'; // most of the characters used around the world
|
|
24
|
+
|
|
25
|
+
// Regex nicely structured:
|
|
26
|
+
// (
|
|
27
|
+
// (
|
|
28
|
+
// \w*decreet |
|
|
29
|
+
// omzendbrief |
|
|
30
|
+
// verdrag |
|
|
31
|
+
// grondwetswijziging |
|
|
32
|
+
// samenwerkingsakkoord |
|
|
33
|
+
// \w*wetboek |
|
|
34
|
+
// protocol |
|
|
35
|
+
// besluit[^\S\n]van[^\S\n]de[^\S\n]vlaamse[^\S\n]regering |
|
|
36
|
+
// geco[öo]rdineerde wetten |
|
|
37
|
+
// \w*wet |
|
|
38
|
+
// koninklijk[^\S\n]?besluit |
|
|
39
|
+
// ministerieel[^\S\n]?besluit |
|
|
40
|
+
// genummerd[^\S\n]?koninklijk[^\S\n]?besluit
|
|
41
|
+
// )
|
|
42
|
+
// [^\S\n]*
|
|
43
|
+
// (
|
|
44
|
+
// ([^\S\n] | [\u0021-\uFFFF\d;:'"()&\-_]){3,}
|
|
45
|
+
// )?
|
|
46
|
+
// )
|
|
47
|
+
const NNWS = '[^\\S\\n]';
|
|
48
|
+
export const CITATION_REGEX = new RegExp(
|
|
49
|
+
`((?<type>\\w*decreet|omzendbrief|verdrag|grondwetswijziging|samenwerkingsakkoord|\\w*wetboek|protocol|besluit${NNWS}van${NNWS}de${NNWS}vlaamse${NNWS}regering|geco[öo]rdineerde${NNWS}wetten|\\w*wet|koninklijk${NNWS}?besluit|ministerieel${NNWS}?besluit|genummerd${NNWS}?koninklijk${NNWS}?besluit|\\w*${NNWS}?besluit)${NNWS}*(?<searchTerms>(${NNWS}|[${BASIC_MULTIPLANE_CHARACTER};:'"()&-_]){3,})?)`,
|
|
50
|
+
'uidg'
|
|
51
|
+
);
|
|
52
|
+
export type CitationSchema = Schema<string, 'citation'>;
|
|
53
|
+
|
|
54
|
+
export interface CitationDecorationSpec extends InlineDecorationSpec {
|
|
55
|
+
legislationTypeUri: string;
|
|
56
|
+
searchText: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface CitationDecoration extends Decoration {
|
|
60
|
+
spec: CitationDecorationSpec;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function calculateDecorations(
|
|
64
|
+
schema: CitationSchema,
|
|
65
|
+
doc: PNode,
|
|
66
|
+
activeRanges: [number, number][]
|
|
67
|
+
) {
|
|
68
|
+
const decorations: Decoration[] = [];
|
|
69
|
+
|
|
70
|
+
for (const [start, end] of activeRanges) {
|
|
71
|
+
doc.nodesBetween(start, end, (node: PNode, pos: number): boolean => {
|
|
72
|
+
if (
|
|
73
|
+
node.isText &&
|
|
74
|
+
node.text &&
|
|
75
|
+
!schema.marks.citation.isInSet(node.marks)
|
|
76
|
+
) {
|
|
77
|
+
for (const match of node.text.matchAll(CITATION_REGEX)) {
|
|
78
|
+
const processedMatch = processMatch(
|
|
79
|
+
match as RegexpMatchArrayWithIndices
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
if (processedMatch) {
|
|
83
|
+
const { text, legislationTypeUri, searchTextMatch } =
|
|
84
|
+
processedMatch;
|
|
85
|
+
const { start: matchStart, end: matchEnd } = searchTextMatch;
|
|
86
|
+
const decorationStart = pos + matchStart;
|
|
87
|
+
const decorationEnd = pos + matchEnd;
|
|
88
|
+
decorations.push(
|
|
89
|
+
Decoration.inline(
|
|
90
|
+
decorationStart,
|
|
91
|
+
decorationEnd,
|
|
92
|
+
|
|
93
|
+
{
|
|
94
|
+
'data-editor-highlight': 'true',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
searchText: text,
|
|
98
|
+
legislationTypeUri,
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return DecorationSet.create(doc, decorations);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface CitationPluginState {
|
|
112
|
+
highlights: DecorationSet;
|
|
113
|
+
activeRanges: [number, number][];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type CitationPlugin = ProsePlugin<CitationPluginState>;
|
|
117
|
+
|
|
118
|
+
function citationPlugin({
|
|
119
|
+
activeIn = defaultActiveIn,
|
|
120
|
+
}: CitationPluginConfig): CitationPlugin {
|
|
121
|
+
const citation: CitationPlugin = new ProsePlugin({
|
|
122
|
+
state: {
|
|
123
|
+
init(stateConfig: EditorStateConfig, state: EditorState) {
|
|
124
|
+
const { doc, schema } = state;
|
|
125
|
+
const activeRanges = activeIn(
|
|
126
|
+
state,
|
|
127
|
+
expect(
|
|
128
|
+
'the datastore plugin is required for this plugin',
|
|
129
|
+
datastoreKey.getState(state)
|
|
130
|
+
)
|
|
131
|
+
);
|
|
132
|
+
return {
|
|
133
|
+
highlights: calculateDecorations(schema, doc, activeRanges),
|
|
134
|
+
activeRanges,
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
apply(tr, set, oldState, newState) {
|
|
138
|
+
const { doc, schema } = newState;
|
|
139
|
+
const activeRanges = activeIn(
|
|
140
|
+
newState,
|
|
141
|
+
expect(
|
|
142
|
+
'the datastore plugin is required for this plugin',
|
|
143
|
+
datastoreKey.getState(newState)
|
|
144
|
+
)
|
|
145
|
+
);
|
|
146
|
+
return {
|
|
147
|
+
highlights: calculateDecorations(schema, doc, activeRanges),
|
|
148
|
+
activeRanges,
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
props: {
|
|
153
|
+
decorations(state): DecorationSet | undefined {
|
|
154
|
+
return citation.getState(state)?.highlights;
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
return citation;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function defaultActiveIn(
|
|
162
|
+
state: EditorState,
|
|
163
|
+
datastore: ProseStore
|
|
164
|
+
): [number, number][] {
|
|
165
|
+
const result: [number, number][] = [];
|
|
166
|
+
for (const { from, to } of datastore
|
|
167
|
+
.match(null, 'besluit:motivering')
|
|
168
|
+
.asPredicateNodeMapping()
|
|
169
|
+
.nodes()) {
|
|
170
|
+
result.push([from, to]);
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface CitationPluginBundle {
|
|
176
|
+
plugin: ProsePlugin<CitationPluginState>;
|
|
177
|
+
widgets: {
|
|
178
|
+
citationCard: WidgetSpec;
|
|
179
|
+
citationInsert: WidgetSpec;
|
|
180
|
+
};
|
|
181
|
+
marks: {
|
|
182
|
+
citation: MarkSpec;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface CitationPluginConfig {
|
|
187
|
+
activeIn?(state: EditorState, datastore: ProseStore): [number, number][];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function setupCitationPlugin(
|
|
191
|
+
config: CitationPluginConfig = {}
|
|
192
|
+
): CitationPluginBundle {
|
|
193
|
+
const plugin = citationPlugin(config);
|
|
194
|
+
return {
|
|
195
|
+
plugin,
|
|
196
|
+
widgets: {
|
|
197
|
+
citationCard: {
|
|
198
|
+
desiredLocation: 'sidebar',
|
|
199
|
+
componentName: 'citation-plugin/citation-card',
|
|
200
|
+
widgetArgs: {
|
|
201
|
+
plugin,
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
citationInsert: {
|
|
205
|
+
desiredLocation: 'insertSidebar',
|
|
206
|
+
componentName: 'citation-plugin/citation-insert',
|
|
207
|
+
widgetArgs: {
|
|
208
|
+
plugin,
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
marks: {
|
|
213
|
+
citation,
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getRdfaAttrs, MarkSpec, rdfaAttrs } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
|
|
3
|
+
export const citation: MarkSpec = {
|
|
4
|
+
attrs: { test: { default: 'yeet' }, ...rdfaAttrs },
|
|
5
|
+
inclusive: false,
|
|
6
|
+
group: 'linkmarks',
|
|
7
|
+
excludes: 'linkmarks',
|
|
8
|
+
parseDOM: [
|
|
9
|
+
{
|
|
10
|
+
tag: 'a[href]',
|
|
11
|
+
getAttrs(dom) {
|
|
12
|
+
if (typeof dom === 'string') {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const type = dom.attributes.getNamedItem('typeof')?.value;
|
|
16
|
+
const property = dom.attributes.getNamedItem('property')?.value;
|
|
17
|
+
if (type === 'eli:LegalExpression' && property === 'eli:cites') {
|
|
18
|
+
return getRdfaAttrs(dom);
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
toDOM(node) {
|
|
25
|
+
return ['a', { ...node.attrs, class: 'annotation' }, 0];
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { CitationSchema } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
3
|
+
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
4
|
+
|
|
5
|
+
export function citedText(
|
|
6
|
+
schema: CitationSchema,
|
|
7
|
+
title: string,
|
|
8
|
+
uri: string
|
|
9
|
+
): PNode {
|
|
10
|
+
return schema.text(title, [
|
|
11
|
+
unwrap(schema.marks.citation).create({
|
|
12
|
+
href: uri,
|
|
13
|
+
property: 'eli:cites',
|
|
14
|
+
typeof: 'eli:LegalExpression',
|
|
15
|
+
}),
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { isBlank } from '@ember/utils';
|
|
2
|
+
import {
|
|
3
|
+
LEGISLATION_TYPES,
|
|
4
|
+
LegislationKey,
|
|
5
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/legislation-types';
|
|
6
|
+
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
7
|
+
|
|
8
|
+
const STOP_WORDS = ['het', 'de', 'van', 'tot', 'dat'];
|
|
9
|
+
const DATE_REGEX = new RegExp('(\\d{1,2})\\s(\\w+)\\s(\\d{2,4})', 'g');
|
|
10
|
+
const INVISIBLE_SPACE = '\u200B';
|
|
11
|
+
const SPACES_REGEX = new RegExp('[\\s${UNBREAKABLE_SPACE}]+');
|
|
12
|
+
export type RegexpMatchArrayWithIndices = RegExpMatchArray & {
|
|
13
|
+
indices: Array<[number, number]> & {
|
|
14
|
+
groups: { [key: string]: [number, number] };
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
interface ProcessedMatch {
|
|
19
|
+
text: string;
|
|
20
|
+
legislationTypeUri: string;
|
|
21
|
+
typeMatch: {
|
|
22
|
+
text: string;
|
|
23
|
+
start: number;
|
|
24
|
+
end: number;
|
|
25
|
+
} | null;
|
|
26
|
+
searchTextMatch: {
|
|
27
|
+
text: string;
|
|
28
|
+
start: number;
|
|
29
|
+
end: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default function processMatch(
|
|
34
|
+
match: RegexpMatchArrayWithIndices
|
|
35
|
+
): ProcessedMatch | null {
|
|
36
|
+
const matchgroups = match.groups;
|
|
37
|
+
if (!matchgroups) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const type = matchgroups['type'];
|
|
41
|
+
const searchTerms = matchgroups['searchTerms'];
|
|
42
|
+
if (!type || !searchTerms) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
let cleanedSearchTerms = cleanupText(searchTerms)
|
|
46
|
+
.split(SPACES_REGEX)
|
|
47
|
+
.filter(
|
|
48
|
+
(word) => !isBlank(word) && word.length > 3 && !STOP_WORDS.includes(word)
|
|
49
|
+
)
|
|
50
|
+
.join(' ');
|
|
51
|
+
if (type) {
|
|
52
|
+
let typeLabel: LegislationKey;
|
|
53
|
+
if (/\w+decreet/i.test(type)) {
|
|
54
|
+
typeLabel = 'decreet';
|
|
55
|
+
cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;
|
|
56
|
+
} else if (/decreet/i.test(type)) {
|
|
57
|
+
typeLabel = 'decreet';
|
|
58
|
+
} else if (/\w+wetboek/i.test(type)) {
|
|
59
|
+
typeLabel = 'wetboek';
|
|
60
|
+
cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;
|
|
61
|
+
} else if (/wetboek/i.test(type)) {
|
|
62
|
+
typeLabel = 'wetboek';
|
|
63
|
+
} else if (/geco[oö]rdineerde[^\S\n]wetten/i.test(type)) {
|
|
64
|
+
typeLabel = 'gecoördineerde wetten';
|
|
65
|
+
} else if (/grondwetswijziging/i.test(type)) {
|
|
66
|
+
typeLabel = 'grondwetswijziging';
|
|
67
|
+
} else if (/grondwet/i.test(type)) {
|
|
68
|
+
typeLabel = 'grondwet';
|
|
69
|
+
} else if (/\w+wet/i.test(type)) {
|
|
70
|
+
typeLabel = 'wet';
|
|
71
|
+
cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;
|
|
72
|
+
} else if (/wet/i.test(type)) {
|
|
73
|
+
typeLabel = 'wet';
|
|
74
|
+
} else {
|
|
75
|
+
typeLabel = 'decreet';
|
|
76
|
+
}
|
|
77
|
+
const typeUri = LEGISLATION_TYPES[typeLabel];
|
|
78
|
+
return {
|
|
79
|
+
text: cleanedSearchTerms,
|
|
80
|
+
legislationTypeUri: typeUri,
|
|
81
|
+
typeMatch: {
|
|
82
|
+
text: type,
|
|
83
|
+
start: unwrap(match.indices.groups['type'])[0],
|
|
84
|
+
end: unwrap(match.indices.groups['type'])[1],
|
|
85
|
+
},
|
|
86
|
+
searchTextMatch: {
|
|
87
|
+
text: searchTerms,
|
|
88
|
+
start: unwrap(match.indices.groups['searchTerms'])[0],
|
|
89
|
+
end: unwrap(match.indices.groups['searchTerms'])[1],
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
} else {
|
|
93
|
+
return {
|
|
94
|
+
text: cleanedSearchTerms,
|
|
95
|
+
legislationTypeUri: LEGISLATION_TYPES['decreet'],
|
|
96
|
+
typeMatch: null,
|
|
97
|
+
searchTextMatch: {
|
|
98
|
+
text: searchTerms,
|
|
99
|
+
start: unwrap(match.indices.groups['searchTerms'])[0],
|
|
100
|
+
end: unwrap(match.indices.groups['searchTerms'])[1],
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function cleanupText(text?: string): string {
|
|
107
|
+
if (!text) return '';
|
|
108
|
+
const { textWithoutDates } = extractDates(text);
|
|
109
|
+
const textWithoutOddChars = textWithoutDates.replace(
|
|
110
|
+
new RegExp(`[,.:"()&${INVISIBLE_SPACE}]`, 'g'),
|
|
111
|
+
''
|
|
112
|
+
);
|
|
113
|
+
const articleIndex = textWithoutOddChars.indexOf('artikel');
|
|
114
|
+
return articleIndex >= 0
|
|
115
|
+
? textWithoutOddChars.slice(0, articleIndex)
|
|
116
|
+
: textWithoutOddChars;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function extractDates(text: string): {
|
|
120
|
+
dates: RegExpMatchArray[];
|
|
121
|
+
textWithoutDates: string;
|
|
122
|
+
} {
|
|
123
|
+
let date;
|
|
124
|
+
const matches: RegExpMatchArray[] = [];
|
|
125
|
+
while ((date = DATE_REGEX.exec(text)) !== null) {
|
|
126
|
+
matches.push(date);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let textWithoutDates = text;
|
|
130
|
+
for (const match of matches) {
|
|
131
|
+
textWithoutDates = textWithoutDates.replace(match[0], '');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return { dates: matches, textWithoutDates };
|
|
135
|
+
}
|