@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/addon/components/roadsign-regulation-plugin/{roadsigns-modal.js → roadsigns-modal.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { action } from '@ember/object';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { tracked } from '@glimmer/tracking';
|
|
4
|
-
import {
|
|
4
|
+
import { task } from 'ember-concurrency';
|
|
5
5
|
import { getOwner } from '@ember/application';
|
|
6
6
|
import { v4 as uuid } from 'uuid';
|
|
7
7
|
import { inject as service } from '@ember/service';
|
|
@@ -11,6 +11,12 @@ import {
|
|
|
11
11
|
POTENTIALLY_ZONAL_URI,
|
|
12
12
|
ZONAL_URI,
|
|
13
13
|
} from '../../constants';
|
|
14
|
+
import RoadsignRegistryService from '@lblod/ember-rdfa-editor-lblod-plugins/services/roadsign-registry';
|
|
15
|
+
import { assert } from '@ember/debug';
|
|
16
|
+
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
17
|
+
import Measure from '@lblod/ember-rdfa-editor-lblod-plugins/models/measure';
|
|
18
|
+
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
19
|
+
import { insertArticle } from '@lblod/ember-rdfa-editor-lblod-plugins/commands/besluit-plugin';
|
|
14
20
|
|
|
15
21
|
const PAGE_SIZE = 10;
|
|
16
22
|
const SIGN_TYPE_URI =
|
|
@@ -20,17 +26,33 @@ const ROAD_MARKING_URI =
|
|
|
20
26
|
const TRAFFIC_LIGHT_URI =
|
|
21
27
|
'https://data.vlaanderen.be/ns/mobiliteit#Verkeerslichtconcept';
|
|
22
28
|
const measureTypes = [SIGN_TYPE_URI, ROAD_MARKING_URI, TRAFFIC_LIGHT_URI];
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
|
|
30
|
+
type Option = {
|
|
31
|
+
label: string;
|
|
32
|
+
value: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type Zonality = Option;
|
|
36
|
+
type TypeOption = Option;
|
|
37
|
+
type Code = Option;
|
|
38
|
+
type Category = Option;
|
|
39
|
+
|
|
40
|
+
type Args = {
|
|
41
|
+
closeModal: () => void;
|
|
42
|
+
controller: ProseController;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default class RoadsignRegulationCard extends Component<Args> {
|
|
46
|
+
endpoint: string;
|
|
25
47
|
|
|
26
48
|
pageSize = PAGE_SIZE;
|
|
27
|
-
@service roadsignRegistry;
|
|
49
|
+
@service declare roadsignRegistry: RoadsignRegistryService;
|
|
28
50
|
|
|
29
|
-
@tracked typeSelected;
|
|
51
|
+
@tracked typeSelected?: TypeOption;
|
|
30
52
|
|
|
31
|
-
@tracked categorySelected;
|
|
53
|
+
@tracked categorySelected?: Category;
|
|
32
54
|
|
|
33
|
-
@tracked zonalityOptions = [
|
|
55
|
+
@tracked zonalityOptions: Zonality[] = [
|
|
34
56
|
{
|
|
35
57
|
label: 'Zonaal',
|
|
36
58
|
value: ZONAL_URI,
|
|
@@ -40,13 +62,15 @@ export default class RoadsignRegulationCard extends Component {
|
|
|
40
62
|
value: NON_ZONAL_URI,
|
|
41
63
|
},
|
|
42
64
|
];
|
|
43
|
-
@tracked zonalitySelected;
|
|
65
|
+
@tracked zonalitySelected?: Zonality;
|
|
44
66
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
@tracked
|
|
48
|
-
@tracked
|
|
49
|
-
@tracked
|
|
67
|
+
descriptionFilter?: string;
|
|
68
|
+
|
|
69
|
+
@tracked selectedCode?: Code;
|
|
70
|
+
@tracked selectedCodeCombination?: Code[];
|
|
71
|
+
@tracked codeCombinationOptions: Code[] = [];
|
|
72
|
+
@tracked tableData: Measure[] = [];
|
|
73
|
+
@tracked count?: number;
|
|
50
74
|
@tracked pageStart = 0;
|
|
51
75
|
|
|
52
76
|
get isNotTypeSign() {
|
|
@@ -54,15 +78,21 @@ export default class RoadsignRegulationCard extends Component {
|
|
|
54
78
|
return this.typeSelected.value !== SIGN_TYPE_URI;
|
|
55
79
|
}
|
|
56
80
|
|
|
57
|
-
constructor() {
|
|
58
|
-
super(
|
|
59
|
-
const config = getOwner(this).resolveRegistration(
|
|
81
|
+
constructor(parent: unknown, args: Args) {
|
|
82
|
+
super(parent, args);
|
|
83
|
+
const config = unwrap(getOwner(this)).resolveRegistration(
|
|
84
|
+
'config:environment'
|
|
85
|
+
) as {
|
|
86
|
+
roadsignRegulationPlugin: {
|
|
87
|
+
endpoint: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
60
90
|
this.endpoint = config.roadsignRegulationPlugin.endpoint;
|
|
61
91
|
this.search();
|
|
62
92
|
}
|
|
63
93
|
|
|
64
94
|
@action
|
|
65
|
-
selectTypeOrCategory(option) {
|
|
95
|
+
selectTypeOrCategory(option: Option) {
|
|
66
96
|
if (!option) {
|
|
67
97
|
this.typeSelected = undefined;
|
|
68
98
|
this.categorySelected = undefined;
|
|
@@ -81,34 +111,38 @@ export default class RoadsignRegulationCard extends Component {
|
|
|
81
111
|
}
|
|
82
112
|
|
|
83
113
|
@action
|
|
84
|
-
changeCode(value) {
|
|
114
|
+
changeCode(value: Code) {
|
|
85
115
|
this.selectedCode = value;
|
|
86
116
|
this.selectedCodeCombination = undefined;
|
|
87
|
-
this.fetchCodeCombinations();
|
|
117
|
+
void this.fetchCodeCombinations();
|
|
88
118
|
this.search();
|
|
89
119
|
}
|
|
90
120
|
|
|
91
121
|
@action
|
|
92
|
-
changeCodeCombination(value) {
|
|
122
|
+
changeCodeCombination(value: Code[]) {
|
|
93
123
|
this.selectedCodeCombination = value;
|
|
94
|
-
this.fetchCodeCombinations();
|
|
124
|
+
void this.fetchCodeCombinations();
|
|
95
125
|
this.search();
|
|
96
126
|
}
|
|
97
127
|
|
|
98
128
|
@action
|
|
99
|
-
changeDescription(
|
|
100
|
-
|
|
129
|
+
changeDescription(event: InputEvent) {
|
|
130
|
+
assert(
|
|
131
|
+
'changeDescriptionValue must be bound to an input element',
|
|
132
|
+
event.target instanceof HTMLInputElement
|
|
133
|
+
);
|
|
134
|
+
this.descriptionFilter = event.target.value;
|
|
101
135
|
this.search();
|
|
102
136
|
}
|
|
103
137
|
|
|
104
138
|
@action
|
|
105
|
-
selectCategory(value) {
|
|
139
|
+
selectCategory(value: Category) {
|
|
106
140
|
this.categorySelected = value;
|
|
107
141
|
this.search();
|
|
108
142
|
}
|
|
109
143
|
|
|
110
144
|
@action
|
|
111
|
-
selectZonality(value) {
|
|
145
|
+
selectZonality(value: Zonality) {
|
|
112
146
|
this.zonalitySelected = value;
|
|
113
147
|
this.search();
|
|
114
148
|
}
|
|
@@ -118,19 +152,18 @@ export default class RoadsignRegulationCard extends Component {
|
|
|
118
152
|
this.args.closeModal();
|
|
119
153
|
}
|
|
120
154
|
@action
|
|
121
|
-
searchCodes(term) {
|
|
122
|
-
const category = this.categorySelected
|
|
123
|
-
|
|
124
|
-
: undefined;
|
|
125
|
-
const type = this.typeSelected ? this.typeSelected.value : undefined;
|
|
155
|
+
searchCodes(term: string) {
|
|
156
|
+
const category = this.categorySelected?.value;
|
|
157
|
+
const type = this.typeSelected?.value;
|
|
126
158
|
return this.roadsignRegistry.searchCode.perform(term, category, type);
|
|
127
159
|
}
|
|
128
160
|
|
|
129
161
|
async fetchCodeCombinations() {
|
|
130
|
-
|
|
162
|
+
const selectedCodeValue = unwrap(this.selectedCode?.value);
|
|
163
|
+
let signs: string[] = [selectedCodeValue];
|
|
131
164
|
if (this.selectedCodeCombination) {
|
|
132
165
|
signs = [
|
|
133
|
-
|
|
166
|
+
selectedCodeValue,
|
|
134
167
|
...this.selectedCodeCombination.map((s) => s.value),
|
|
135
168
|
];
|
|
136
169
|
}
|
|
@@ -143,7 +176,10 @@ export default class RoadsignRegulationCard extends Component {
|
|
|
143
176
|
this.codeCombinationOptions = codes;
|
|
144
177
|
}
|
|
145
178
|
|
|
146
|
-
get typeOptions() {
|
|
179
|
+
get typeOptions(): {
|
|
180
|
+
groupName: string;
|
|
181
|
+
options: TypeOption[];
|
|
182
|
+
}[] {
|
|
147
183
|
return [
|
|
148
184
|
{
|
|
149
185
|
groupName: 'Types',
|
|
@@ -171,9 +207,8 @@ export default class RoadsignRegulationCard extends Component {
|
|
|
171
207
|
];
|
|
172
208
|
}
|
|
173
209
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
let codes = [];
|
|
210
|
+
fetchSigns = task({ restartable: true }, async () => {
|
|
211
|
+
const codes: Code[] = [];
|
|
177
212
|
if (this.selectedCodeCombination) {
|
|
178
213
|
codes.push(...this.selectedCodeCombination);
|
|
179
214
|
}
|
|
@@ -181,7 +216,7 @@ export default class RoadsignRegulationCard extends Component {
|
|
|
181
216
|
codes.push(this.selectedCode);
|
|
182
217
|
}
|
|
183
218
|
const { measures, count } =
|
|
184
|
-
|
|
219
|
+
await this.roadsignRegistry.fetchMeasures.perform({
|
|
185
220
|
zonality: this.zonalitySelected
|
|
186
221
|
? this.zonalitySelected.value
|
|
187
222
|
: undefined,
|
|
@@ -194,10 +229,14 @@ export default class RoadsignRegulationCard extends Component {
|
|
|
194
229
|
});
|
|
195
230
|
this.tableData = measures;
|
|
196
231
|
this.count = count;
|
|
197
|
-
}
|
|
232
|
+
});
|
|
198
233
|
|
|
199
234
|
@action
|
|
200
|
-
async insertHtml(
|
|
235
|
+
async insertHtml(
|
|
236
|
+
measure: Measure,
|
|
237
|
+
zonalityValue: string,
|
|
238
|
+
temporalValue: string
|
|
239
|
+
) {
|
|
201
240
|
const instructions =
|
|
202
241
|
await this.roadsignRegistry.fetchInstructionsForMeasure.perform(
|
|
203
242
|
measure.uri
|
|
@@ -211,7 +250,8 @@ export default class RoadsignRegulationCard extends Component {
|
|
|
211
250
|
const signsHTML = measure.signs
|
|
212
251
|
.map((sign) => {
|
|
213
252
|
const roadSignUri = 'http://data.lblod.info/verkeerstekens/' + uuid();
|
|
214
|
-
return `<li style="margin-bottom:1rem;"
|
|
253
|
+
return `<li style="margin-bottom:1rem;">
|
|
254
|
+
<span property="mobiliteit:wordtAangeduidDoor" resource=${roadSignUri} typeof="mobiliteit:Verkeersbord-Verkeersteken">
|
|
215
255
|
<span property="mobiliteit:heeftVerkeersbordconcept" resource="${
|
|
216
256
|
sign.uri
|
|
217
257
|
}" typeof="mobiliteit:Verkeersbordconcept" style="display:flex;align-items:center;">
|
|
@@ -229,40 +269,37 @@ export default class RoadsignRegulationCard extends Component {
|
|
|
229
269
|
</li>`;
|
|
230
270
|
})
|
|
231
271
|
.join('\n');
|
|
272
|
+
const regulationHTML = `<div property="mobiliteit:heeftVerkeersmaatregel" typeof="mobiliteit:Mobiliteitsmaatregel" resource="http://data.lblod.info/mobiliteitsmaatregels/${uuid()}">
|
|
273
|
+
<span style="display:none;" property="prov:wasDerivedFrom" resource="${
|
|
274
|
+
measure.uri
|
|
275
|
+
}"> </span>
|
|
276
|
+
<span style="display:none;" property="ext:zonality" resource="${zonality}"></span>
|
|
277
|
+
<span style="display:none;" property="ext:temporal" value="${measure.temporal.toString()}"></span>
|
|
278
|
+
<div property="dct:description">
|
|
279
|
+
${html}
|
|
280
|
+
<p>Dit wordt aangeduid door verkeerstekens:</p>
|
|
281
|
+
<ul style="list-style:none;">
|
|
282
|
+
${signsHTML}
|
|
283
|
+
</ul>
|
|
284
|
+
${temporalValue === 'true' ? 'Deze signalisatie is dynamisch.' : ''}
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
`;
|
|
232
288
|
|
|
233
|
-
this.args.controller.
|
|
234
|
-
'
|
|
235
|
-
this.args.controller,
|
|
236
|
-
`<div property="mobiliteit:heeftVerkeersmaatregel" typeof="mobiliteit:Mobiliteitsmaatregel" resource="http://data.lblod.info/mobiliteitsmaatregels/${uuid()}">
|
|
237
|
-
<span style="display:none;" property="prov:wasDerivedFrom" resource="${
|
|
238
|
-
measure.uri
|
|
239
|
-
}"> </span>
|
|
240
|
-
<span style="display:none;" property="ext:zonality" resource="${zonality}"></span>
|
|
241
|
-
<span style="display:none;" property="ext:temporal" value="${
|
|
242
|
-
measure.temporal
|
|
243
|
-
}"></span>
|
|
244
|
-
<div property="dct:description">
|
|
245
|
-
${html}
|
|
246
|
-
<p>Dit wordt aangeduid door verkeerstekens:</p>
|
|
247
|
-
<ul style="list-style:none;">
|
|
248
|
-
${signsHTML}
|
|
249
|
-
</ul>
|
|
250
|
-
${temporalValue === 'true' ? 'Deze signalisatie is dynamisch.' : ''}
|
|
251
|
-
</div>
|
|
252
|
-
</div>
|
|
253
|
-
`
|
|
289
|
+
this.args.controller.doCommand(
|
|
290
|
+
insertArticle(this.args.controller, regulationHTML, '')
|
|
254
291
|
);
|
|
255
292
|
this.args.closeModal();
|
|
256
293
|
}
|
|
257
294
|
|
|
258
295
|
@action
|
|
259
|
-
goToPage(pageStart) {
|
|
296
|
+
goToPage(pageStart: number) {
|
|
260
297
|
this.pageStart = pageStart;
|
|
261
|
-
this.fetchSigns.perform();
|
|
298
|
+
void this.fetchSigns.perform();
|
|
262
299
|
}
|
|
263
300
|
@action
|
|
264
301
|
search() {
|
|
265
302
|
this.pageStart = 0;
|
|
266
|
-
this.fetchSigns.perform();
|
|
303
|
+
void this.fetchSigns.perform();
|
|
267
304
|
}
|
|
268
305
|
}
|
|
@@ -2,7 +2,12 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Args = {
|
|
6
|
+
count: number;
|
|
7
|
+
pageSize: number;
|
|
8
|
+
goToPage: (n: number) => void;
|
|
9
|
+
};
|
|
10
|
+
export default class RoadsignsPagination extends Component<Args> {
|
|
6
11
|
@tracked actualPageStart = 0;
|
|
7
12
|
@tracked actualPageEnd = 10;
|
|
8
13
|
|
|
@@ -31,8 +36,7 @@ export default class RoadsignsPagination extends Component {
|
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
@action
|
|
34
|
-
onUpdateCount(_element,
|
|
35
|
-
const pageStart = params[1];
|
|
39
|
+
onUpdateCount(_element: HTMLElement, [_, pageStart]: [number, number]) {
|
|
36
40
|
this.actualPageStart = pageStart;
|
|
37
41
|
this.actualPageEnd = pageStart + this.args.pageSize;
|
|
38
42
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
import Component from '@glimmer/component';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
import { getOwner } from '@ember/application';
|
|
5
|
+
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
6
|
+
|
|
7
|
+
type Args = Record<string, never>;
|
|
8
|
+
export default class RoadsignsTable extends Component<Args> {
|
|
9
|
+
@tracked selected?: string;
|
|
10
|
+
imageBaseUrl: string;
|
|
11
|
+
|
|
12
|
+
constructor(parent: unknown, args: Args) {
|
|
13
|
+
super(parent, args);
|
|
14
|
+
const config = unwrap(getOwner(this)).resolveRegistration(
|
|
15
|
+
'config:environment'
|
|
16
|
+
) as {
|
|
17
|
+
roadsignRegulationPlugin: {
|
|
18
|
+
imageBaseUrl: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
this.imageBaseUrl = config.roadsignRegulationPlugin.imageBaseUrl;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@action
|
|
25
|
+
selectRow(id: string) {
|
|
26
|
+
if (this.selected === id) {
|
|
27
|
+
this.selected = undefined;
|
|
28
|
+
} else {
|
|
29
|
+
this.selected = id;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
3
|
+
|
|
4
|
+
type Args = {
|
|
5
|
+
controller: ProseController;
|
|
6
|
+
};
|
|
7
|
+
export default class StandardTemplatePluginCardComponent extends Component<Args> {
|
|
8
|
+
get controller() {
|
|
9
|
+
return this.args.controller;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { inject as service } from '@ember/service';
|
|
4
|
+
import instantiateUuids from '../../utils/instantiate-uuids';
|
|
5
|
+
import StandardTemplatePluginService from '@lblod/ember-rdfa-editor-lblod-plugins/services/standard-template-plugin';
|
|
6
|
+
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
7
|
+
import TemplateModel from '@lblod/ember-rdfa-editor-lblod-plugins/models/template';
|
|
8
|
+
import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
|
|
9
|
+
|
|
10
|
+
type Args = {
|
|
11
|
+
controller: ProseController;
|
|
12
|
+
};
|
|
13
|
+
export default class TemplateProviderComponent extends Component<Args> {
|
|
14
|
+
@service declare standardTemplatePlugin: StandardTemplatePluginService;
|
|
15
|
+
|
|
16
|
+
get busy() {
|
|
17
|
+
return this.standardTemplatePlugin.fetchTemplates.isRunning;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get controller() {
|
|
21
|
+
return this.args.controller;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get hasApplicableTemplates() {
|
|
25
|
+
return this.applicableTemplates.length > 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get applicableTemplates() {
|
|
29
|
+
return (
|
|
30
|
+
this.standardTemplatePlugin.fetchTemplates.last?.value?.filter(
|
|
31
|
+
(template) => this.templateIsApplicable(template)
|
|
32
|
+
) || []
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
templateIsApplicable(template: TemplateModel) {
|
|
37
|
+
const containsTypes = this.controller.datastore
|
|
38
|
+
.match(null, 'a')
|
|
39
|
+
.dataset.some((quad) => {
|
|
40
|
+
return template.contexts.includes(quad.object.value);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const containsDisabledTypes = this.controller.datastore
|
|
44
|
+
.match(null, 'a')
|
|
45
|
+
.dataset.some((quad) =>
|
|
46
|
+
template.disabledInContexts.includes(quad.object.value)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return containsTypes && !containsDisabledTypes;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@action
|
|
53
|
+
async insert(template: TemplateModel) {
|
|
54
|
+
await template.reload();
|
|
55
|
+
const selection = this.controller.state.selection;
|
|
56
|
+
let insertRange: { from: number; to: number } = selection;
|
|
57
|
+
const { $from, $to } = selection;
|
|
58
|
+
if (
|
|
59
|
+
$from.parent.type === this.controller.schema.nodes['placeholder'] &&
|
|
60
|
+
$from.sameParent($to)
|
|
61
|
+
) {
|
|
62
|
+
insertRange = {
|
|
63
|
+
from: $from.start($from.depth - 1),
|
|
64
|
+
to: $from.end($from.depth - 1),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
this.controller.doCommand(
|
|
68
|
+
insertHtml(
|
|
69
|
+
instantiateUuids(template.body),
|
|
70
|
+
insertRange.from,
|
|
71
|
+
insertRange.to
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
<AuCard @flex={{true}} @divided={{true}} @expandable={{false}} @shadow={{true}} @size="flush" as |c|>
|
|
2
2
|
<c.content class="au-c-content--small">
|
|
3
|
-
<
|
|
3
|
+
<label
|
|
4
|
+
class="au-c-toggle-switch"
|
|
5
|
+
>
|
|
6
|
+
<input
|
|
7
|
+
type="checkbox"
|
|
8
|
+
checked={{this.toggled}}
|
|
9
|
+
class="au-c-toggle-switch__input au-u-hidden-visually"
|
|
10
|
+
{{on "input" this.toggle}}
|
|
11
|
+
/>
|
|
12
|
+
<span class="au-c-toggle-switch__toggle"></span>
|
|
13
|
+
<span class="au-c-toggle-switch__label">{{t "table-of-contents-plugin.toggle" }}</span>
|
|
14
|
+
</label>
|
|
4
15
|
</c.content>
|
|
5
16
|
</AuCard>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
import Component from '@glimmer/component';
|
|
3
|
+
import {
|
|
4
|
+
TableOfContentsConfig,
|
|
5
|
+
TABLE_OF_CONTENTS_DEFAULT_CONFIG,
|
|
6
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/constants';
|
|
7
|
+
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
8
|
+
|
|
9
|
+
type Args = {
|
|
10
|
+
controller: ProseController;
|
|
11
|
+
widgetArgs: {
|
|
12
|
+
config: TableOfContentsConfig;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default class TableOfContentsCardComponent extends Component<Args> {
|
|
17
|
+
get toggled() {
|
|
18
|
+
return !!this.tableOfContentsRange;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get controller() {
|
|
22
|
+
return this.args.controller;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get tableOfContentsRange() {
|
|
26
|
+
let result: { from: number; to: number } | undefined;
|
|
27
|
+
this.controller.state.doc.descendants((node, pos) => {
|
|
28
|
+
if (node.type === this.controller.schema.nodes['tableOfContents']) {
|
|
29
|
+
result = { from: pos, to: pos + node.nodeSize };
|
|
30
|
+
}
|
|
31
|
+
return !result;
|
|
32
|
+
});
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get config() {
|
|
37
|
+
return this.args.widgetArgs.config ?? TABLE_OF_CONTENTS_DEFAULT_CONFIG;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@action
|
|
41
|
+
toggle() {
|
|
42
|
+
if (this.tableOfContentsRange) {
|
|
43
|
+
const { from, to } = this.tableOfContentsRange;
|
|
44
|
+
this.controller.withTransaction((tr) => {
|
|
45
|
+
return tr.deleteRange(from, to);
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
const { schema } = this.controller;
|
|
49
|
+
this.controller.withTransaction((tr) => {
|
|
50
|
+
return tr.replaceRangeWith(
|
|
51
|
+
0,
|
|
52
|
+
0,
|
|
53
|
+
schema.node('tableOfContents', {
|
|
54
|
+
config: this.config,
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
package/addon/components/table-of-contents-plugin/{inline-components → ember-nodes}/outline.hbs
RENAMED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
{{! template-lint-disable no-capital-arguments }}
|
|
7
7
|
@block={{true}}
|
|
8
8
|
@skin='link-secondary'
|
|
9
|
-
onclick={{fn @onEntryClick outlineEntry.
|
|
9
|
+
onclick={{(fn @onEntryClick outlineEntry.pos)}}
|
|
10
10
|
>
|
|
11
11
|
{{outlineEntry.content}}
|
|
12
12
|
</AuButton>
|
|
13
13
|
{{#if outlineEntry.children}}
|
|
14
|
-
<TableOfContentsPlugin::
|
|
14
|
+
<TableOfContentsPlugin::EmberNodes::Outline
|
|
15
15
|
@entries={{outlineEntry.children}}
|
|
16
16
|
@onEntryClick={{@onEntryClick}}
|
|
17
17
|
/>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div class='au-u-background-gray-100 au-u-padding-tiny table-of-contents'>
|
|
2
|
+
<h3>{{t "table-of-contents-plugin.title"}}</h3>
|
|
3
|
+
{{#if this.outline}}
|
|
4
|
+
<TableOfContentsPlugin::EmberNodes::Outline
|
|
5
|
+
@entries={{this.outline.entries}}
|
|
6
|
+
@onEntryClick={{this.moveToPosition}}
|
|
7
|
+
/>
|
|
8
|
+
{{/if}}
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
import Component from '@glimmer/component';
|
|
3
|
+
import { TableOfContentsConfig } from '../../../constants';
|
|
4
|
+
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
5
|
+
import { EmberNodeArgs } from '@lblod/ember-rdfa-editor/utils/ember-node';
|
|
6
|
+
import { Selection } from '@lblod/ember-rdfa-editor';
|
|
7
|
+
import { getRdfaAttribute } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
|
|
8
|
+
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
9
|
+
type OutlineEntry = {
|
|
10
|
+
content: string;
|
|
11
|
+
pos: number;
|
|
12
|
+
children?: OutlineEntry[];
|
|
13
|
+
};
|
|
14
|
+
export default class TableOfContentsComponent extends Component<EmberNodeArgs> {
|
|
15
|
+
get config() {
|
|
16
|
+
return this.args.node.attrs['config'] as TableOfContentsConfig;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get controller() {
|
|
20
|
+
return this.args.controller;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get outline() {
|
|
24
|
+
const entries = this.extractOutline({
|
|
25
|
+
node: this.controller.state.doc,
|
|
26
|
+
pos: -1,
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
entries,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
extractOutline({ node, pos }: { node: PNode; pos: number }): OutlineEntry[] {
|
|
34
|
+
let result: OutlineEntry[] = [];
|
|
35
|
+
let parent: OutlineEntry | undefined;
|
|
36
|
+
const properties = getRdfaAttribute(node, 'property').pop();
|
|
37
|
+
const resource = getRdfaAttribute(node, 'resource').pop();
|
|
38
|
+
if (properties && resource) {
|
|
39
|
+
for (const tocConfigEntry of this.config) {
|
|
40
|
+
if (
|
|
41
|
+
tocConfigEntry.sectionPredicate.some((pred) =>
|
|
42
|
+
properties.includes(pred)
|
|
43
|
+
)
|
|
44
|
+
) {
|
|
45
|
+
if (typeof tocConfigEntry.value === 'string') {
|
|
46
|
+
parent = { content: tocConfigEntry.value, pos };
|
|
47
|
+
break;
|
|
48
|
+
} else {
|
|
49
|
+
const range = [
|
|
50
|
+
...this.args.controller.datastore
|
|
51
|
+
.match(`>${resource}`, `>${tocConfigEntry.value.predicate}`)
|
|
52
|
+
.asPredicateNodeMapping()
|
|
53
|
+
.nodes(),
|
|
54
|
+
][0];
|
|
55
|
+
if (range) {
|
|
56
|
+
const node = unwrap(this.controller.state.doc.nodeAt(range.from));
|
|
57
|
+
parent = {
|
|
58
|
+
content: node.textContent,
|
|
59
|
+
pos: range.from,
|
|
60
|
+
};
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const subResults: OutlineEntry[] = [];
|
|
68
|
+
node.forEach((child, offset) => {
|
|
69
|
+
subResults.push(
|
|
70
|
+
...this.extractOutline({ node: child, pos: pos + 1 + offset })
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
if (parent) {
|
|
74
|
+
parent.children = subResults;
|
|
75
|
+
result = [parent];
|
|
76
|
+
} else {
|
|
77
|
+
result = subResults;
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@action
|
|
83
|
+
moveToPosition(pos: number) {
|
|
84
|
+
this.controller.withTransaction((tr) => {
|
|
85
|
+
const resolvedPos = tr.doc.resolve(pos);
|
|
86
|
+
const selection = Selection.near(resolvedPos, 1);
|
|
87
|
+
if (selection) {
|
|
88
|
+
tr.setSelection(selection);
|
|
89
|
+
tr.scrollIntoView();
|
|
90
|
+
}
|
|
91
|
+
return tr;
|
|
92
|
+
});
|
|
93
|
+
this.controller.focus();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<div {{did-update this.selectionChanged @controller.state}}>
|
|
1
2
|
{{#if this.showCard}}
|
|
2
3
|
<AuCard @flex={{true}} @divided={{true}} @isOpenInitially={{true}} @expandable={{true}} @shadow={{true}} @size="small" as |c|>
|
|
3
4
|
<c.header>
|
|
@@ -31,4 +32,4 @@
|
|
|
31
32
|
</c.content>
|
|
32
33
|
</AuCard>
|
|
33
34
|
{{/if}}
|
|
34
|
-
|
|
35
|
+
</div>
|