@lblod/ember-rdfa-editor-lblod-plugins 0.4.1 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/addon/components/article-structure-plugin/article-structure-card.hbs +10 -0
- package/addon/components/article-structure-plugin/article-structure-card.ts +33 -0
- package/addon/components/article-structure-plugin/structure-card.hbs +46 -0
- package/addon/components/article-structure-plugin/structure-card.ts +124 -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 +138 -0
- package/addon/components/besluit-plugin/besluit-plugin-card.hbs +20 -0
- package/addon/components/besluit-plugin/besluit-plugin-card.ts +40 -0
- package/addon/components/besluit-type-plugin/{besluit-type-select.js → besluit-type-select.ts} +8 -4
- package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +2 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +218 -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} +117 -90
- 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 +45 -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} +103 -66
- 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/helpers/{limit-text.js → limit-text.ts} +2 -2
- 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/commands/index.ts +6 -0
- package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +80 -0
- package/addon/plugins/article-structure-plugin/commands/move-selected-structure.ts +130 -0
- package/addon/plugins/article-structure-plugin/commands/recalculate-structure-numbers.ts +26 -0
- package/addon/plugins/article-structure-plugin/commands/remove-structure.ts +21 -0
- package/addon/plugins/article-structure-plugin/commands/unwrap-structure.ts +40 -0
- package/addon/plugins/article-structure-plugin/commands/wrap-structure-content.ts +66 -0
- package/addon/plugins/article-structure-plugin/constants.ts +11 -0
- package/addon/plugins/article-structure-plugin/index.ts +70 -0
- package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +94 -0
- package/addon/plugins/article-structure-plugin/structures/article.ts +129 -0
- package/addon/plugins/article-structure-plugin/structures/chapter.ts +83 -0
- package/addon/plugins/article-structure-plugin/structures/index.ts +33 -0
- package/addon/plugins/article-structure-plugin/structures/section.ts +82 -0
- package/addon/plugins/article-structure-plugin/structures/structure-header.ts +65 -0
- package/addon/plugins/article-structure-plugin/structures/subsection.ts +83 -0
- package/addon/plugins/article-structure-plugin/structures/title.ts +83 -0
- package/addon/plugins/article-structure-plugin/utils/namespace.ts +25 -0
- package/addon/plugins/article-structure-plugin/utils/structure.ts +162 -0
- package/addon/plugins/besluit-plugin/commands/get-article-nodes-for-besluit.ts +30 -0
- package/addon/plugins/besluit-plugin/commands/index.ts +4 -0
- package/addon/plugins/besluit-plugin/commands/insert-article.ts +70 -0
- package/addon/plugins/besluit-plugin/commands/insert-title.ts +67 -0
- package/addon/plugins/besluit-plugin/commands/move-article.ts +69 -0
- package/addon/plugins/besluit-plugin/commands/recalculate-article-numbers.ts +44 -0
- package/addon/plugins/besluit-plugin/index.ts +11 -0
- package/addon/plugins/besluit-plugin/utils/get-title-for-decision.ts +35 -0
- package/addon/plugins/besluit-type-plugin/index.ts +6 -0
- package/addon/{utils/fetchBesluitTypes.js → plugins/besluit-type-plugin/utils/fetchBesluitTypes.ts} +35 -16
- 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/{utils/legislation-types.js → plugins/citation-plugin/utils/legislation-types.ts} +17 -3
- package/addon/plugins/citation-plugin/utils/process-match.ts +132 -0
- package/addon/{utils/vlaamse-codex.js → plugins/citation-plugin/utils/vlaamse-codex.ts} +160 -41
- package/addon/plugins/import-snippet-plugin.ts +6 -0
- package/addon/plugins/insert-variable-plugin/index.ts +11 -0
- package/addon/{utils/variable-plugins/default-variable-types.js → plugins/insert-variable-plugin/utils/constants.ts} +18 -7
- package/addon/plugins/insert-variable-plugin/utils/fetch-data.ts +41 -0
- package/addon/plugins/rdfa-date-plugin/commands/index.ts +1 -0
- package/addon/plugins/rdfa-date-plugin/commands/modify-date.ts +48 -0
- package/addon/plugins/rdfa-date-plugin/index.ts +11 -0
- package/addon/plugins/roadsign-regulation-plugin/index.ts +6 -0
- package/addon/plugins/roadsign-regulation-plugin/utils/constants.ts +8 -0
- package/addon/{utils/roadsign-regulation-plugin/fetchData.js → plugins/roadsign-regulation-plugin/utils/fetchData.ts} +20 -3
- package/addon/plugins/roadsign-regulation-plugin/utils/includeInstructions.ts +16 -0
- package/addon/plugins/standard-template-plugin/index.ts +6 -0
- package/addon/plugins/standard-template-plugin/utils/instantiate-uuids.ts +48 -0
- package/addon/plugins/table-of-contents-plugin/index.ts +14 -0
- package/addon/plugins/table-of-contents-plugin/nodes/index.ts +1 -0
- package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +53 -0
- package/addon/plugins/table-of-contents-plugin/utils/constants.ts +17 -0
- package/addon/plugins/template-variable-plugin/index.ts +6 -0
- package/addon/plugins/template-variable-plugin/utils/constants.ts +2 -0
- package/addon/plugins/template-variable-plugin/utils/fetch-data.ts +62 -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/memoize.ts +8 -0
- package/addon/utils/option.ts +58 -0
- package/addon/utils/sparql-helpers.ts +27 -0
- 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/components/article-structure-plugin/article-structure-card.d.ts +17 -0
- package/components/article-structure-plugin/structure-card.d.ts +32 -0
- package/components/au-native-input.d.ts +20 -0
- package/components/besluit-plugin/besluit-context-card.d.ts +24 -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/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 +29 -8
- package/plugins/article-structure-plugin/commands/index.d.ts +6 -0
- package/plugins/article-structure-plugin/commands/insert-structure.d.ts +5 -0
- package/plugins/article-structure-plugin/commands/move-selected-structure.d.ts +10 -0
- package/plugins/article-structure-plugin/commands/recalculate-structure-numbers.d.ts +3 -0
- package/plugins/article-structure-plugin/commands/remove-structure.d.ts +7 -0
- package/plugins/article-structure-plugin/commands/unwrap-structure.d.ts +8 -0
- package/plugins/article-structure-plugin/commands/wrap-structure-content.d.ts +8 -0
- package/plugins/article-structure-plugin/constants.d.ts +5 -0
- package/plugins/article-structure-plugin/index.d.ts +41 -0
- package/plugins/article-structure-plugin/structures/article-paragraph.d.ts +4 -0
- package/plugins/article-structure-plugin/structures/article.d.ts +6 -0
- package/plugins/article-structure-plugin/structures/chapter.d.ts +4 -0
- package/plugins/article-structure-plugin/structures/index.d.ts +17 -0
- package/plugins/article-structure-plugin/structures/section.d.ts +4 -0
- package/plugins/article-structure-plugin/structures/structure-header.d.ts +2 -0
- package/plugins/article-structure-plugin/structures/subsection.d.ts +4 -0
- package/plugins/article-structure-plugin/structures/title.d.ts +4 -0
- package/plugins/article-structure-plugin/utils/namespace.d.ts +6 -0
- package/plugins/article-structure-plugin/utils/structure.d.ts +20 -0
- package/plugins/besluit-plugin/commands/get-article-nodes-for-besluit.d.ts +5 -0
- package/plugins/besluit-plugin/commands/index.d.ts +4 -0
- package/plugins/besluit-plugin/commands/insert-article.d.ts +3 -0
- package/plugins/besluit-plugin/commands/insert-title.d.ts +2 -0
- package/plugins/besluit-plugin/commands/move-article.d.ts +2 -0
- package/plugins/besluit-plugin/commands/recalculate-article-numbers.d.ts +2 -0
- package/plugins/besluit-plugin/index.d.ts +3 -0
- package/plugins/besluit-plugin/utils/get-title-for-decision.d.ts +10 -0
- package/plugins/besluit-type-plugin/index.d.ts +2 -0
- package/plugins/besluit-type-plugin/utils/fetchBesluitTypes.d.ts +12 -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/legislation-types.d.ts +24 -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/index.d.ts +2 -0
- package/plugins/insert-variable-plugin/utils/constants.d.ts +7 -0
- package/plugins/insert-variable-plugin/utils/fetch-data.d.ts +5 -0
- package/plugins/rdfa-date-plugin/commands/index.d.ts +1 -0
- package/plugins/rdfa-date-plugin/commands/modify-date.d.ts +2 -0
- package/plugins/rdfa-date-plugin/index.d.ts +3 -0
- package/plugins/roadsign-regulation-plugin/index.d.ts +2 -0
- package/plugins/roadsign-regulation-plugin/utils/constants.d.ts +3 -0
- package/plugins/roadsign-regulation-plugin/utils/fetchData.d.ts +8 -0
- package/plugins/roadsign-regulation-plugin/utils/includeInstructions.d.ts +2 -0
- package/plugins/standard-template-plugin/index.d.ts +2 -0
- package/plugins/standard-template-plugin/utils/instantiate-uuids.d.ts +15 -0
- package/plugins/table-of-contents-plugin/index.d.ts +3 -0
- package/plugins/table-of-contents-plugin/nodes/index.d.ts +1 -0
- package/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +4 -0
- package/plugins/table-of-contents-plugin/utils/constants.d.ts +7 -0
- package/plugins/template-variable-plugin/index.d.ts +2 -0
- package/plugins/template-variable-plugin/utils/constants.d.ts +1 -0
- package/plugins/template-variable-plugin/utils/fetch-data.d.ts +9 -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 +64 -1
- package/translations/nl-BE.yaml +66 -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/memoize.d.ts +1 -0
- package/utils/option.d.ts +14 -0
- package/utils/sparql-helpers.d.ts +7 -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/constants.js +0 -24
- package/addon/initializers/plugin-initializer.js +0 -75
- package/addon/inline-components/table-of-contents.js +0 -43
- package/addon/marks/citaten-mark.js +0 -32
- 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/generate-template-plugin.js +0 -16
- 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/generate-template-plugin/default-resources.js +0 -9
- package/addon/utils/instantiate-uuids.js +0 -34
- package/addon/utils/memoize.js +0 -8
- package/addon/utils/processMatch.js +0 -80
- package/addon/utils/roadsign-regulation-plugin/includeInstructions.js +0 -10
- package/addon/utils/variable-plugins/fetch-data.js +0 -98
- 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,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Command,
|
|
3
|
+
NodeSelection,
|
|
4
|
+
TextSelection,
|
|
5
|
+
} from '@lblod/ember-rdfa-editor';
|
|
6
|
+
import recalculateStructureNumbers from './recalculate-structure-numbers';
|
|
7
|
+
import { StructureSpec } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
|
|
8
|
+
import { findAncestorOfType } from '../utils/structure';
|
|
9
|
+
import wrapStructureContent from './wrap-structure-content';
|
|
10
|
+
import IntlService from 'ember-intl/services/intl';
|
|
11
|
+
|
|
12
|
+
const insertStructure = (
|
|
13
|
+
structureSpec: StructureSpec,
|
|
14
|
+
intl: IntlService
|
|
15
|
+
): Command => {
|
|
16
|
+
return (state, dispatch) => {
|
|
17
|
+
const { schema, selection } = state;
|
|
18
|
+
const contextNodeTypes = structureSpec.context
|
|
19
|
+
.map((nodeType) => schema.nodes[nodeType])
|
|
20
|
+
.filter((nodeSpec) => !!nodeSpec);
|
|
21
|
+
const parent = findAncestorOfType(selection, ...contextNodeTypes);
|
|
22
|
+
if (!parent) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const { depth } = parent;
|
|
26
|
+
const index = selection.$from.index(depth);
|
|
27
|
+
if (
|
|
28
|
+
!parent.node.canReplaceWith(
|
|
29
|
+
index + 1,
|
|
30
|
+
index + 1,
|
|
31
|
+
schema.nodes[structureSpec.name]
|
|
32
|
+
)
|
|
33
|
+
) {
|
|
34
|
+
return wrapStructureContent(structureSpec, parent, intl)(state, dispatch);
|
|
35
|
+
}
|
|
36
|
+
if (dispatch) {
|
|
37
|
+
const { node: newStructureNode, selectionConfig } =
|
|
38
|
+
structureSpec.constructor({ schema, intl });
|
|
39
|
+
const transaction = state.tr;
|
|
40
|
+
let insertRange: { from: number; to: number };
|
|
41
|
+
if (
|
|
42
|
+
parent.node.childCount === 1 &&
|
|
43
|
+
parent.node.firstChild?.type === schema.nodes['paragraph'] &&
|
|
44
|
+
parent.node.firstChild.firstChild?.type === schema.nodes['placeholder']
|
|
45
|
+
) {
|
|
46
|
+
insertRange = {
|
|
47
|
+
from: parent.pos + 1,
|
|
48
|
+
to: parent.pos + parent.node.nodeSize - 1,
|
|
49
|
+
};
|
|
50
|
+
} else {
|
|
51
|
+
insertRange = {
|
|
52
|
+
from: selection.$from.after(depth + 1),
|
|
53
|
+
to: selection.$from.after(depth + 1),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
transaction.replaceWith(
|
|
58
|
+
insertRange.from,
|
|
59
|
+
insertRange.to,
|
|
60
|
+
newStructureNode
|
|
61
|
+
);
|
|
62
|
+
const newSelection =
|
|
63
|
+
selectionConfig.type === 'node'
|
|
64
|
+
? NodeSelection.create(
|
|
65
|
+
transaction.doc,
|
|
66
|
+
insertRange.from + selectionConfig.relativePos
|
|
67
|
+
)
|
|
68
|
+
: TextSelection.create(
|
|
69
|
+
transaction.doc,
|
|
70
|
+
insertRange.from + selectionConfig.relativePos
|
|
71
|
+
);
|
|
72
|
+
transaction.setSelection(newSelection);
|
|
73
|
+
recalculateStructureNumbers(transaction, structureSpec);
|
|
74
|
+
dispatch(transaction);
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default insertStructure;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Command,
|
|
3
|
+
NodeSelection,
|
|
4
|
+
NodeType,
|
|
5
|
+
PNode,
|
|
6
|
+
Schema,
|
|
7
|
+
TextSelection,
|
|
8
|
+
} from '@lblod/ember-rdfa-editor';
|
|
9
|
+
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
10
|
+
import { ArticleStructurePluginOptions } from '..';
|
|
11
|
+
import { findAncestorOfType } from '../utils/structure';
|
|
12
|
+
import recalculateStructureNumbers from './recalculate-structure-numbers';
|
|
13
|
+
import { findNodes } from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
14
|
+
import IntlService from 'ember-intl/services/intl';
|
|
15
|
+
const moveSelectedStructure = (
|
|
16
|
+
options: ArticleStructurePluginOptions,
|
|
17
|
+
direction: 'up' | 'down',
|
|
18
|
+
intl: IntlService
|
|
19
|
+
): Command => {
|
|
20
|
+
return (state, dispatch) => {
|
|
21
|
+
const { doc, selection, schema } = state;
|
|
22
|
+
const structureSpecs = options.map((type) => schema.nodes[type.name]);
|
|
23
|
+
const currentStructure = findAncestorOfType(selection, ...structureSpecs);
|
|
24
|
+
if (!currentStructure || currentStructure.pos === -1) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const insertionRange = calculateInsertionRange(
|
|
28
|
+
doc,
|
|
29
|
+
currentStructure.pos,
|
|
30
|
+
currentStructure.node.type,
|
|
31
|
+
direction,
|
|
32
|
+
schema
|
|
33
|
+
);
|
|
34
|
+
if (insertionRange === null || insertionRange === undefined) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const isNodeSelection = selection instanceof NodeSelection;
|
|
38
|
+
const relativeSelectionOffset = selection.from - currentStructure.pos;
|
|
39
|
+
const currentStructureSpec = unwrap(
|
|
40
|
+
options.find((spec) => spec.name === currentStructure.node.type.name)
|
|
41
|
+
);
|
|
42
|
+
if (dispatch) {
|
|
43
|
+
const transaction = state.tr;
|
|
44
|
+
transaction.delete(
|
|
45
|
+
currentStructure.pos,
|
|
46
|
+
currentStructure.pos + currentStructure.node.nodeSize
|
|
47
|
+
);
|
|
48
|
+
const parent = doc.resolve(currentStructure.pos).parent;
|
|
49
|
+
if (parent.childCount === 1) {
|
|
50
|
+
transaction.insert(
|
|
51
|
+
currentStructure.pos,
|
|
52
|
+
schema.node(schema.nodes['placeholder'], {
|
|
53
|
+
placeholderText: intl.t(
|
|
54
|
+
'article-structure-plugin.placeholder.generic.body'
|
|
55
|
+
),
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const mappedFrom = transaction.mapping.map(insertionRange.from);
|
|
60
|
+
const mappedTo =
|
|
61
|
+
insertionRange.from === insertionRange.to
|
|
62
|
+
? mappedFrom
|
|
63
|
+
: transaction.mapping.map(insertionRange.to);
|
|
64
|
+
transaction.replaceWith(mappedFrom, mappedTo, currentStructure.node);
|
|
65
|
+
const newSelectionPos = mappedFrom + relativeSelectionOffset;
|
|
66
|
+
const newSelection = isNodeSelection
|
|
67
|
+
? NodeSelection.create(transaction.doc, newSelectionPos)
|
|
68
|
+
: TextSelection.create(transaction.doc, newSelectionPos);
|
|
69
|
+
transaction.setSelection(newSelection);
|
|
70
|
+
recalculateStructureNumbers(transaction, currentStructureSpec);
|
|
71
|
+
dispatch(transaction);
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export function calculateInsertionRange(
|
|
78
|
+
doc: PNode,
|
|
79
|
+
pos: number, // position of structure we want to move
|
|
80
|
+
nodeType: NodeType,
|
|
81
|
+
direction: 'up' | 'down',
|
|
82
|
+
schema: Schema
|
|
83
|
+
): { from: number; to: number } | null {
|
|
84
|
+
const resolvedPosition = doc.resolve(pos);
|
|
85
|
+
const containerNode = resolvedPosition.parent;
|
|
86
|
+
const index = resolvedPosition.index();
|
|
87
|
+
if (direction === 'up' && index !== 0) {
|
|
88
|
+
const position = resolvedPosition.posAtIndex(index - 1);
|
|
89
|
+
return { from: position, to: position };
|
|
90
|
+
} else if (direction === 'down' && index !== containerNode.childCount - 1) {
|
|
91
|
+
// We need to insert after the node below so we do index + 2 instead of index + 1
|
|
92
|
+
const position = resolvedPosition.posAtIndex(index + 2);
|
|
93
|
+
return { from: position, to: position };
|
|
94
|
+
} else {
|
|
95
|
+
const containerRange = findNodes(
|
|
96
|
+
doc,
|
|
97
|
+
pos,
|
|
98
|
+
true,
|
|
99
|
+
direction === 'up',
|
|
100
|
+
({ from }) => {
|
|
101
|
+
const node = doc.nodeAt(from);
|
|
102
|
+
if (node && node !== containerNode) {
|
|
103
|
+
const indexToTest = direction === 'up' ? node.childCount : 0;
|
|
104
|
+
if (node.canReplaceWith(indexToTest, indexToTest, nodeType)) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
).next().value;
|
|
111
|
+
if (containerRange) {
|
|
112
|
+
const { from, to } = containerRange;
|
|
113
|
+
const containerNode = doc.nodeAt(from);
|
|
114
|
+
if (!containerNode) return null;
|
|
115
|
+
if (
|
|
116
|
+
containerNode.firstChild?.type === schema.nodes['paragraph'] &&
|
|
117
|
+
containerNode.firstChild.firstChild?.type ===
|
|
118
|
+
schema.nodes['placeholder']
|
|
119
|
+
) {
|
|
120
|
+
return { from: from + 1, to: to - 1 };
|
|
121
|
+
} else {
|
|
122
|
+
const position = direction === 'up' ? to - 1 : from + 1;
|
|
123
|
+
return { from: position, to: position };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export default moveSelectedStructure;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PNode, Transaction } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { StructureSpec } from '..';
|
|
3
|
+
|
|
4
|
+
export default function recalculateStructureNumbers(
|
|
5
|
+
transaction: Transaction,
|
|
6
|
+
...structureSpecs: StructureSpec[]
|
|
7
|
+
) {
|
|
8
|
+
const doc = transaction.doc;
|
|
9
|
+
const indices = new Array<number>(structureSpecs.length).fill(1);
|
|
10
|
+
const contexts: (PNode | null)[] = new Array<PNode | null>(
|
|
11
|
+
structureSpecs.length
|
|
12
|
+
).fill(null);
|
|
13
|
+
doc.descendants((node, pos, parent) => {
|
|
14
|
+
structureSpecs.forEach((spec, i) => {
|
|
15
|
+
if (node.type.name === spec.name) {
|
|
16
|
+
if (!spec.continuous && !(parent === contexts[i])) {
|
|
17
|
+
indices[i] = 1;
|
|
18
|
+
contexts[i] = parent;
|
|
19
|
+
}
|
|
20
|
+
spec.updateNumber({ number: indices[i], pos, transaction });
|
|
21
|
+
indices[i] += 1;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
return transaction;
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Command, PNode } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { ArticleStructurePluginOptions } from '..';
|
|
3
|
+
import recalculateStructureNumbers from './recalculate-structure-numbers';
|
|
4
|
+
|
|
5
|
+
const removeStructure = (
|
|
6
|
+
structure: { pos: number; node: PNode },
|
|
7
|
+
options: ArticleStructurePluginOptions
|
|
8
|
+
): Command => {
|
|
9
|
+
return (state, dispatch) => {
|
|
10
|
+
if (dispatch) {
|
|
11
|
+
const { pos, node } = structure;
|
|
12
|
+
const transaction = state.tr;
|
|
13
|
+
transaction.replace(pos, pos + node.nodeSize);
|
|
14
|
+
recalculateStructureNumbers(transaction, ...options);
|
|
15
|
+
dispatch(transaction);
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default removeStructure;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Command, PNode } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import {
|
|
3
|
+
ArticleStructurePluginOptions,
|
|
4
|
+
StructureSpec,
|
|
5
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
|
|
6
|
+
import recalculateStructureNumbers from './recalculate-structure-numbers';
|
|
7
|
+
|
|
8
|
+
const unwrapStructure = (
|
|
9
|
+
structure: {
|
|
10
|
+
pos: number;
|
|
11
|
+
node: PNode;
|
|
12
|
+
type: StructureSpec;
|
|
13
|
+
},
|
|
14
|
+
options: ArticleStructurePluginOptions
|
|
15
|
+
): Command => {
|
|
16
|
+
return (state, dispatch) => {
|
|
17
|
+
const { doc } = state;
|
|
18
|
+
const { pos, node, type } = structure;
|
|
19
|
+
if (!type.content) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const contentToUnwrap = type.content({ pos, state });
|
|
23
|
+
|
|
24
|
+
const resolvedPos = doc.resolve(pos);
|
|
25
|
+
const parent = resolvedPos.parent;
|
|
26
|
+
const index = resolvedPos.index();
|
|
27
|
+
if (!parent.canReplace(index, index + 1, contentToUnwrap)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (dispatch) {
|
|
31
|
+
const transaction = state.tr;
|
|
32
|
+
transaction.replaceWith(pos, pos + node.nodeSize, contentToUnwrap);
|
|
33
|
+
recalculateStructureNumbers(transaction, ...options);
|
|
34
|
+
dispatch(transaction);
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default unwrapStructure;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Command,
|
|
3
|
+
NodeSelection,
|
|
4
|
+
PNode,
|
|
5
|
+
TextSelection,
|
|
6
|
+
} from '@lblod/ember-rdfa-editor';
|
|
7
|
+
import { StructureSpec } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin';
|
|
8
|
+
import IntlService from 'ember-intl/services/intl';
|
|
9
|
+
import recalculateStructureNumbers from './recalculate-structure-numbers';
|
|
10
|
+
|
|
11
|
+
const wrapStructureContent = (
|
|
12
|
+
structureSpec: StructureSpec,
|
|
13
|
+
parent: {
|
|
14
|
+
node: PNode;
|
|
15
|
+
pos: number;
|
|
16
|
+
},
|
|
17
|
+
intl: IntlService
|
|
18
|
+
): Command => {
|
|
19
|
+
return (state, dispatch) => {
|
|
20
|
+
const { schema } = state;
|
|
21
|
+
const { node, pos } = parent;
|
|
22
|
+
if (
|
|
23
|
+
!node.canReplaceWith(0, node.childCount, schema.nodes[structureSpec.name])
|
|
24
|
+
) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const contentToWrap = node?.content;
|
|
28
|
+
let result: {
|
|
29
|
+
node: PNode;
|
|
30
|
+
selectionConfig: {
|
|
31
|
+
relativePos: number;
|
|
32
|
+
type: 'node' | 'text';
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
try {
|
|
36
|
+
result = structureSpec.constructor({
|
|
37
|
+
schema,
|
|
38
|
+
content: contentToWrap,
|
|
39
|
+
intl,
|
|
40
|
+
});
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const { node: wrappingNode, selectionConfig } = result;
|
|
45
|
+
if (dispatch) {
|
|
46
|
+
const transaction = state.tr;
|
|
47
|
+
transaction.replaceWith(pos + 1, pos + node.nodeSize - 1, wrappingNode);
|
|
48
|
+
const newSelection =
|
|
49
|
+
selectionConfig.type === 'node'
|
|
50
|
+
? NodeSelection.create(
|
|
51
|
+
transaction.doc,
|
|
52
|
+
pos + 1 + selectionConfig.relativePos
|
|
53
|
+
)
|
|
54
|
+
: TextSelection.create(
|
|
55
|
+
transaction.doc,
|
|
56
|
+
pos + 1 + selectionConfig.relativePos
|
|
57
|
+
);
|
|
58
|
+
transaction.setSelection(newSelection);
|
|
59
|
+
recalculateStructureNumbers(transaction, structureSpec);
|
|
60
|
+
dispatch(transaction);
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default wrapStructureContent;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { namespace } from './utils/namespace';
|
|
2
|
+
|
|
3
|
+
export const SAY = namespace('https://say.data.gift/ns/', 'say');
|
|
4
|
+
export const RDF = namespace(
|
|
5
|
+
'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
|
6
|
+
'rdf'
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export const ELI = namespace('http://data.europa.eu/eli/ontology#', 'eli');
|
|
10
|
+
export const XSD = namespace('http://www.w3.org/2001/XMLSchema#', 'xsd');
|
|
11
|
+
export const EXT = namespace('http://mu.semte.ch/vocabularies/ext/', 'ext');
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Fragment,
|
|
3
|
+
PNode,
|
|
4
|
+
Schema,
|
|
5
|
+
WidgetSpec,
|
|
6
|
+
EditorState,
|
|
7
|
+
} from '@lblod/ember-rdfa-editor';
|
|
8
|
+
import IntlService from 'ember-intl/services/intl';
|
|
9
|
+
import { Transaction } from 'prosemirror-state';
|
|
10
|
+
import { STRUCTURE_SPECS } from './structures';
|
|
11
|
+
|
|
12
|
+
export type SpecName = string;
|
|
13
|
+
|
|
14
|
+
export type StructureSpec = {
|
|
15
|
+
name: SpecName;
|
|
16
|
+
context: SpecName[];
|
|
17
|
+
translations: {
|
|
18
|
+
insert: string;
|
|
19
|
+
move: {
|
|
20
|
+
up: string;
|
|
21
|
+
down: string;
|
|
22
|
+
};
|
|
23
|
+
remove: string;
|
|
24
|
+
};
|
|
25
|
+
constructor: (args: {
|
|
26
|
+
schema: Schema;
|
|
27
|
+
number?: number;
|
|
28
|
+
intl?: IntlService;
|
|
29
|
+
content?: PNode | Fragment;
|
|
30
|
+
}) => {
|
|
31
|
+
node: PNode;
|
|
32
|
+
selectionConfig: {
|
|
33
|
+
relativePos: number;
|
|
34
|
+
type: 'node' | 'text';
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
updateNumber: (args: {
|
|
38
|
+
number: number;
|
|
39
|
+
pos: number;
|
|
40
|
+
transaction: Transaction;
|
|
41
|
+
}) => Transaction;
|
|
42
|
+
content?: (args: { pos: number; state: EditorState }) => Fragment;
|
|
43
|
+
continuous: boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type ArticleStructurePluginOptions = StructureSpec[];
|
|
47
|
+
|
|
48
|
+
export const articleStructureInsertWidget: (
|
|
49
|
+
options?: ArticleStructurePluginOptions
|
|
50
|
+
) => WidgetSpec = (options) => {
|
|
51
|
+
return {
|
|
52
|
+
componentName: 'article-structure-plugin/article-structure-card',
|
|
53
|
+
desiredLocation: 'insertSidebar',
|
|
54
|
+
widgetArgs: {
|
|
55
|
+
options: options ?? STRUCTURE_SPECS,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const articleStructureContextWidget: (
|
|
61
|
+
options?: ArticleStructurePluginOptions
|
|
62
|
+
) => WidgetSpec = (options) => {
|
|
63
|
+
return {
|
|
64
|
+
componentName: 'article-structure-plugin/structure-card',
|
|
65
|
+
desiredLocation: 'sidebar',
|
|
66
|
+
widgetArgs: {
|
|
67
|
+
options: options ?? STRUCTURE_SPECS,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { NodeSpec } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { StructureSpec } from '..';
|
|
3
|
+
import { v4 as uuid } from 'uuid';
|
|
4
|
+
import { ELI, SAY, XSD } from '../constants';
|
|
5
|
+
import { hasRDFaAttribute } from '../utils/namespace';
|
|
6
|
+
|
|
7
|
+
const PLACEHOLDERS = {
|
|
8
|
+
body: 'article-structure-plugin.placeholder.paragraph.body',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const articleParagraphSpec: StructureSpec = {
|
|
12
|
+
name: 'article_paragraph',
|
|
13
|
+
context: ['article_body'],
|
|
14
|
+
translations: {
|
|
15
|
+
insert: 'article-structure-plugin.insert.paragraph',
|
|
16
|
+
move: {
|
|
17
|
+
up: 'article-structure-plugin.moveUp.paragraph',
|
|
18
|
+
down: 'article-structure-plugin.moveDown.paragraph',
|
|
19
|
+
},
|
|
20
|
+
remove: 'article-structure-plugin.remove.paragraph',
|
|
21
|
+
},
|
|
22
|
+
continuous: true,
|
|
23
|
+
constructor: ({ schema, number, intl }) => {
|
|
24
|
+
const numberConverted = number?.toString() ?? '1';
|
|
25
|
+
const node = schema.node(
|
|
26
|
+
`article_paragraph`,
|
|
27
|
+
{
|
|
28
|
+
resource: `http://data.lblod.info/paragraphs/${uuid()}`,
|
|
29
|
+
number: numberConverted,
|
|
30
|
+
},
|
|
31
|
+
schema.node('placeholder', {
|
|
32
|
+
placeholderText: intl?.t(PLACEHOLDERS.body),
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
return { node, selectionConfig: { relativePos: 1, type: 'node' } };
|
|
36
|
+
},
|
|
37
|
+
updateNumber: ({ number, pos, transaction }) => {
|
|
38
|
+
const numberConverted = number.toString();
|
|
39
|
+
return transaction.setNodeAttribute(pos, 'number', numberConverted);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const article_paragraph: NodeSpec = {
|
|
44
|
+
content: 'text*|placeholder',
|
|
45
|
+
inline: false,
|
|
46
|
+
attrs: {
|
|
47
|
+
resource: {},
|
|
48
|
+
number: {
|
|
49
|
+
default: '1',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
toDOM(node) {
|
|
53
|
+
return [
|
|
54
|
+
'div',
|
|
55
|
+
{
|
|
56
|
+
property: SAY('hasParagraph').prefixed,
|
|
57
|
+
typeof: SAY('Paragraph').prefixed,
|
|
58
|
+
resource: node.attrs.resource as string,
|
|
59
|
+
},
|
|
60
|
+
'$',
|
|
61
|
+
[
|
|
62
|
+
'span',
|
|
63
|
+
{ property: ELI('number').prefixed, datatype: XSD('integer').prefixed },
|
|
64
|
+
node.attrs.number,
|
|
65
|
+
],
|
|
66
|
+
'. ',
|
|
67
|
+
['span', { property: SAY('body').prefixed }, 0],
|
|
68
|
+
];
|
|
69
|
+
},
|
|
70
|
+
parseDOM: [
|
|
71
|
+
{
|
|
72
|
+
tag: 'div',
|
|
73
|
+
getAttrs(element: HTMLElement) {
|
|
74
|
+
const numberSpan = element.querySelector(`
|
|
75
|
+
span[property~='${ELI('number').prefixed}'],
|
|
76
|
+
span[property~='${ELI('number').full}']`);
|
|
77
|
+
if (
|
|
78
|
+
hasRDFaAttribute(element, 'property', SAY('hasParagraph')) &&
|
|
79
|
+
hasRDFaAttribute(element, 'typeof', SAY('Paragraph')) &&
|
|
80
|
+
element.getAttribute('resource') &&
|
|
81
|
+
numberSpan
|
|
82
|
+
) {
|
|
83
|
+
return {
|
|
84
|
+
resource: element.getAttribute('resource'),
|
|
85
|
+
number: numberSpan.textContent,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
},
|
|
90
|
+
contentElement: `span[property~='${SAY('body').prefixed}'],
|
|
91
|
+
span[property~='${SAY('body').full}']`,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { NodeSpec } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { StructureSpec } from '..';
|
|
3
|
+
import {
|
|
4
|
+
constructStructureBodyNodeSpec,
|
|
5
|
+
constructStructureNodeSpec,
|
|
6
|
+
getStructureHeaderAttrs,
|
|
7
|
+
} from '../utils/structure';
|
|
8
|
+
import { v4 as uuid } from 'uuid';
|
|
9
|
+
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
10
|
+
import { ELI, EXT, SAY, XSD } from '../constants';
|
|
11
|
+
|
|
12
|
+
const PLACEHOLDERS = {
|
|
13
|
+
title: 'article-structure-plugin.placeholder.article.heading',
|
|
14
|
+
body: 'article-structure-plugin.placeholder.article.body',
|
|
15
|
+
};
|
|
16
|
+
export const articleSpec: StructureSpec = {
|
|
17
|
+
name: 'article',
|
|
18
|
+
context: ['title_body', 'chapter_body', 'section_body', 'subsection_body'],
|
|
19
|
+
translations: {
|
|
20
|
+
insert: 'article-structure-plugin.insert.article',
|
|
21
|
+
move: {
|
|
22
|
+
up: 'article-structure-plugin.moveUp.article',
|
|
23
|
+
down: 'article-structure-plugin.moveDown.article',
|
|
24
|
+
},
|
|
25
|
+
remove: 'article-structure-plugin.remove.article',
|
|
26
|
+
},
|
|
27
|
+
continuous: true,
|
|
28
|
+
constructor: ({ schema, number, content, intl }) => {
|
|
29
|
+
const numberConverted = number?.toString() ?? '1';
|
|
30
|
+
const node = schema.node(
|
|
31
|
+
`article`,
|
|
32
|
+
{ resource: `http://data.lblod.info/articles/${uuid()}` },
|
|
33
|
+
[
|
|
34
|
+
schema.node(
|
|
35
|
+
'article_header',
|
|
36
|
+
{ level: 4, number: numberConverted },
|
|
37
|
+
schema.node('placeholder', {
|
|
38
|
+
placeholderText: intl?.t(PLACEHOLDERS.title),
|
|
39
|
+
})
|
|
40
|
+
),
|
|
41
|
+
schema.node(
|
|
42
|
+
`article_body`,
|
|
43
|
+
{},
|
|
44
|
+
content ??
|
|
45
|
+
schema.node(
|
|
46
|
+
'paragraph',
|
|
47
|
+
{},
|
|
48
|
+
schema.node('placeholder', {
|
|
49
|
+
placeholderText: intl?.t(PLACEHOLDERS.body),
|
|
50
|
+
})
|
|
51
|
+
)
|
|
52
|
+
),
|
|
53
|
+
]
|
|
54
|
+
);
|
|
55
|
+
const selectionConfig: {
|
|
56
|
+
relativePos: number;
|
|
57
|
+
type: 'text' | 'node';
|
|
58
|
+
} = content
|
|
59
|
+
? { relativePos: 5, type: 'text' }
|
|
60
|
+
: { relativePos: 6, type: 'node' };
|
|
61
|
+
return {
|
|
62
|
+
node,
|
|
63
|
+
selectionConfig,
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
updateNumber: ({ number, pos, transaction }) => {
|
|
67
|
+
const numberConverted = number.toString();
|
|
68
|
+
return transaction.setNodeAttribute(pos + 1, 'number', numberConverted);
|
|
69
|
+
},
|
|
70
|
+
content: ({ pos, state }) => {
|
|
71
|
+
const node = unwrap(state.doc.nodeAt(pos));
|
|
72
|
+
return node.child(1).content;
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const article = constructStructureNodeSpec({
|
|
77
|
+
type: SAY('Article'),
|
|
78
|
+
content: 'article_header article_body',
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const article_header: NodeSpec = {
|
|
82
|
+
content: 'text*|placeholder',
|
|
83
|
+
inline: false,
|
|
84
|
+
attrs: {
|
|
85
|
+
number: {
|
|
86
|
+
default: '1',
|
|
87
|
+
},
|
|
88
|
+
property: {
|
|
89
|
+
default: SAY('heading').prefixed,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
toDOM(node) {
|
|
93
|
+
return [
|
|
94
|
+
'div',
|
|
95
|
+
{ property: node.attrs.property as string },
|
|
96
|
+
'Artikel ',
|
|
97
|
+
[
|
|
98
|
+
'span',
|
|
99
|
+
{ property: ELI('number').prefixed, datatype: XSD('string').prefixed },
|
|
100
|
+
node.attrs.number,
|
|
101
|
+
],
|
|
102
|
+
': ',
|
|
103
|
+
[
|
|
104
|
+
'span',
|
|
105
|
+
{
|
|
106
|
+
property: EXT('title').prefixed,
|
|
107
|
+
},
|
|
108
|
+
0,
|
|
109
|
+
],
|
|
110
|
+
];
|
|
111
|
+
},
|
|
112
|
+
parseDOM: [
|
|
113
|
+
{
|
|
114
|
+
tag: 'div',
|
|
115
|
+
getAttrs(element: HTMLElement) {
|
|
116
|
+
const headerAttrs = getStructureHeaderAttrs(element);
|
|
117
|
+
if (headerAttrs) {
|
|
118
|
+
return headerAttrs;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
},
|
|
122
|
+
contentElement: `span[property~='${EXT('title').prefixed}']`,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const article_body = constructStructureBodyNodeSpec({
|
|
128
|
+
content: '(paragraph|article_paragraph)+',
|
|
129
|
+
});
|