@lblod/ember-rdfa-editor-lblod-plugins 35.5.0 → 35.6.0-dev.e16af1eb01766a9bd664f91a9ffbbac0e85b94d7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.changeset/calm-books-protect.md +5 -0
  2. package/.changeset/hungry-rings-prove.md +5 -0
  3. package/.changeset/itchy-impalas-accept.md +5 -0
  4. package/.changeset/many-brooms-fetch.md +5 -0
  5. package/.changeset/quick-frogs-type.md +5 -0
  6. package/.changeset/serious-lies-bathe.md +5 -0
  7. package/.changeset/ten-cameras-repair.md +5 -0
  8. package/CHANGELOG.md +6 -0
  9. package/addon/components/besluit-topic-plugin/besluit-topic-select.hbs +1 -1
  10. package/addon/components/besluit-topic-plugin/besluit-topic-select.ts +5 -0
  11. package/addon/components/decision-plugin/decision-plugin-card.gts +4 -0
  12. package/addon/components/roadsign-regulation-plugin/expanded-measure.gts +85 -15
  13. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.gts +10 -0
  14. package/addon/components/roadsign-regulation-plugin/roadsigns-table.gts +3 -0
  15. package/addon/plugins/decision-plugin/actions/insert-article.ts +89 -46
  16. package/addon/plugins/decision-plugin/commands/insert-article-container.ts +3 -0
  17. package/addon/plugins/decision-plugin/commands/insert-description.ts +4 -1
  18. package/addon/plugins/decision-plugin/commands/insert-motivation.ts +3 -1
  19. package/addon/plugins/decision-plugin/commands/insert-title.ts +3 -1
  20. package/addon/plugins/document-validation-plugin/common-fixes.ts +4 -0
  21. package/addon/plugins/location-plugin/utils/get-document-locations.ts +63 -0
  22. package/addon/plugins/roadsign-regulation-plugin/actions/insert-measure.ts +7 -83
  23. package/addon/plugins/roadsign-regulation-plugin/helpers/construct-measure-fragment.ts +96 -0
  24. package/addon/plugins/variable-plugin/actions/create-classic-location-variable.ts +3 -10
  25. package/addon/plugins/variable-plugin/contextual-actions/index.ts +188 -0
  26. package/addon/plugins/variable-plugin/utils/codelist-utils.ts +1 -1
  27. package/addon/utils/document-structure-utils.ts +17 -0
  28. package/declarations/addon/components/besluit-topic-plugin/besluit-topic-select.d.ts +2 -0
  29. package/declarations/addon/components/roadsign-regulation-plugin/expanded-measure.d.ts +22 -1
  30. package/declarations/addon/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +2 -1
  31. package/declarations/addon/components/roadsign-regulation-plugin/roadsigns-table.d.ts +2 -0
  32. package/declarations/addon/plugins/decision-plugin/actions/insert-article.d.ts +1 -0
  33. package/declarations/addon/plugins/decision-plugin/commands/insert-article-container.d.ts +2 -1
  34. package/declarations/addon/plugins/decision-plugin/commands/insert-description.d.ts +2 -1
  35. package/declarations/addon/plugins/decision-plugin/commands/insert-motivation.d.ts +2 -1
  36. package/declarations/addon/plugins/decision-plugin/commands/insert-title.d.ts +2 -1
  37. package/declarations/addon/plugins/location-plugin/utils/get-document-locations.d.ts +4 -0
  38. package/declarations/addon/plugins/roadsign-regulation-plugin/actions/insert-measure.d.ts +2 -1
  39. package/declarations/addon/plugins/roadsign-regulation-plugin/helpers/construct-measure-fragment.d.ts +4 -0
  40. package/declarations/addon/plugins/variable-plugin/actions/create-classic-location-variable.d.ts +1 -1
  41. package/declarations/addon/plugins/variable-plugin/contextual-actions/index.d.ts +17 -0
  42. package/declarations/addon/plugins/variable-plugin/utils/codelist-utils.d.ts +10 -0
  43. package/declarations/addon/utils/document-structure-utils.d.ts +6 -0
  44. package/package.json +3 -3
  45. package/translations/en-US.yaml +5 -1
  46. package/translations/nl-BE.yaml +9 -5
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': major
3
+ ---
4
+
5
+ Bump editor
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ Add slash commands plugin
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': major
3
+ ---
4
+
5
+ Add contextual actions for inserting place descriptions
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ Adds ability to choose insert position for a mobility measure article
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ Add function to search the document for oslo locations
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ Translate functions that insert besluit blocks
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ fix translation mobility measure insert position
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 35.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#652](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/652) [`6a75255`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/6a752557f1e36010629ba8d2f366739a42e063ed) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Allow to modify render in place for besluit topic select
8
+
3
9
  ## 35.5.0
4
10
 
5
11
  ### Minor Changes
@@ -1,7 +1,6 @@
1
1
  {{! @glint-nocheck: not typesafe yet }}
2
2
  <div ...attributes>
3
3
  <PowerSelectMultiple
4
- @renderInPlace={{true}}
5
4
  @searchEnabled={{true}}
6
5
  @searchMessage={{t 'besluit-topic-plugin.search-message'}}
7
6
  @noMatchesMessage={{t 'besluit-topic-plugin.no-matches-message'}}
@@ -9,6 +8,7 @@
9
8
  @options={{this.besluitTopics}}
10
9
  @selected={{@selected}}
11
10
  @onChange={{@onchange}}
11
+ @renderInPlace={{this.renderInPlace}}
12
12
  as |besluitTopic|
13
13
  >
14
14
  {{besluitTopic.label}}
@@ -8,6 +8,7 @@ type Args = {
8
8
  besluitTopics: BesluitTopic[];
9
9
  selected?: BesluitTopic[];
10
10
  onchange: (topic: BesluitTopic[]) => void;
11
+ renderInPlace?: boolean;
11
12
  };
12
13
 
13
14
  export default class BesluitTopicSelectComponent extends Component<Args> {
@@ -31,4 +32,8 @@ export default class BesluitTopicSelectComponent extends Component<Args> {
31
32
  besluitTopic.label.toLowerCase().includes(lowerTerm),
32
33
  );
33
34
  }
35
+ get renderInPlace() {
36
+ if (this.args.renderInPlace === false) return false;
37
+ return true;
38
+ }
34
39
  }
@@ -78,6 +78,7 @@ export default class DecisionPluginCard extends Component<Sig> {
78
78
  'besluit-plugin.placeholder.decision-title',
79
79
  ),
80
80
  decisionLocation: this.decisionNodeLocation,
81
+ label: 'Titel',
81
82
  }),
82
83
  { view: this.controller.mainEditorView },
83
84
  );
@@ -102,6 +103,7 @@ export default class DecisionPluginCard extends Component<Sig> {
102
103
  'besluit-plugin.placeholder.decision-description',
103
104
  ),
104
105
  decisionLocation: this.decisionNodeLocation,
106
+ label: 'Beschrijving',
105
107
  }),
106
108
  {
107
109
  view: this.controller.mainEditorView,
@@ -128,6 +130,7 @@ export default class DecisionPluginCard extends Component<Sig> {
128
130
  insertMotivation({
129
131
  intl: this.intl,
130
132
  decisionLocation: this.decisionNodeLocation,
133
+ label: 'Motivering',
131
134
  }),
132
135
  {
133
136
  view: this.controller.mainEditorView,
@@ -152,6 +155,7 @@ export default class DecisionPluginCard extends Component<Sig> {
152
155
  decisionUri: this.decisionUri,
153
156
  articleUriGenerator: this.args.options?.articleUriGenerator,
154
157
  decisionLocation: this.decisionNodeLocation,
158
+ label: 'Artikels',
155
159
  }),
156
160
  {
157
161
  view: this.controller.mainEditorView,
@@ -5,7 +5,6 @@ import { tracked } from '@glimmer/tracking';
5
5
  import t from 'ember-intl/helpers/t';
6
6
  import MeasurePreview from './measure-preview';
7
7
  import AuRadioGroup from '@appuniversum/ember-appuniversum/components/au-radio-group';
8
- import AuButtonGroup from '@appuniversum/ember-appuniversum/components/au-button-group';
9
8
  import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
10
9
  import { MobilityMeasureConcept } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/schemas/mobility-measure-concept';
11
10
  import { action } from '@ember/object';
@@ -16,10 +15,15 @@ import {
16
15
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/constants';
17
16
  import { Task } from 'ember-concurrency';
18
17
  import { isSome } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
18
+ import set from '@lblod/ember-rdfa-editor-lblod-plugins/helpers/set';
19
+ import { service } from '@ember/service';
20
+ import IntlService from 'ember-intl/services/intl';
21
+ import { PNode } from '@lblod/ember-rdfa-editor';
22
+ import PowerSelect from 'ember-power-select/components/power-select';
19
23
 
20
24
  export type InsertMobilityMeasureTask = Task<
21
25
  void,
22
- [MobilityMeasureConcept, ZonalOrNot, boolean]
26
+ [MobilityMeasureConcept, ZonalOrNot, boolean, number?]
23
27
  >;
24
28
  type Signature = {
25
29
  Args: {
@@ -27,12 +31,43 @@ type Signature = {
27
31
  selectRow: (uri: string) => void;
28
32
  insert: InsertMobilityMeasureTask;
29
33
  endpoint: string;
34
+ articleNodes: PNode[];
30
35
  };
31
36
  };
32
37
 
38
+ type InsertPositionOption = {
39
+ label: string;
40
+ position: 'first' | 'last' | 'custom';
41
+ insertIndex?: number;
42
+ };
43
+
33
44
  export default class ExpandedMeasure extends Component<Signature> {
45
+ @service declare intl: IntlService;
46
+
34
47
  @tracked zonalityValue?: ZonalOrNot;
35
48
  @tracked temporalValue?: boolean;
49
+ @tracked selectedInsertPosition: InsertPositionOption;
50
+
51
+ insertPositionOptionFirst: InsertPositionOption;
52
+ insertPositionOptionLast: InsertPositionOption;
53
+
54
+ constructor(owner: unknown, args: Signature['Args']) {
55
+ super(owner, args);
56
+ this.insertPositionOptionFirst = {
57
+ label: this.intl.t(
58
+ 'editor-plugins.roadsign-regulation.expanded-measure.as-first-article',
59
+ ),
60
+ position: 'first',
61
+ insertIndex: 0,
62
+ };
63
+ this.insertPositionOptionLast = {
64
+ label: this.intl.t(
65
+ 'editor-plugins.roadsign-regulation.expanded-measure.as-last-article',
66
+ ),
67
+ position: 'last',
68
+ };
69
+ this.selectedInsertPosition = this.insertPositionOptionLast;
70
+ }
36
71
 
37
72
  get isPotentiallyZonal() {
38
73
  return this.args.concept.zonality === ZONALITY_OPTIONS.POTENTIALLY_ZONAL;
@@ -41,6 +76,7 @@ export default class ExpandedMeasure extends Component<Signature> {
41
76
  get insertButtonDisabled() {
42
77
  return (
43
78
  (this.isPotentiallyZonal && !this.zonalityValue) ||
79
+ this.args.insert.isRunning ||
44
80
  (this.args.concept.variableSignage && !isSome(this.temporalValue))
45
81
  );
46
82
  }
@@ -57,11 +93,13 @@ export default class ExpandedMeasure extends Component<Signature> {
57
93
 
58
94
  @action
59
95
  insert() {
96
+ const { insertIndex } = this.selectedInsertPosition;
60
97
  this.args.insert.perform(
61
98
  this.args.concept,
62
99
  // POTENTIALLY_ZONAL option is filtered out by requiring a zonalityValue to submit
63
100
  (this.zonalityValue ?? this.args.concept.zonality) as ZonalOrNot,
64
101
  this.temporalValue ?? false,
102
+ insertIndex,
65
103
  );
66
104
  }
67
105
 
@@ -70,6 +108,29 @@ export default class ExpandedMeasure extends Component<Signature> {
70
108
  this.args.selectRow(this.args.concept.uri);
71
109
  }
72
110
 
111
+ get articlesInDocument() {
112
+ return this.args.articleNodes;
113
+ }
114
+
115
+ get insertPositionOptions() {
116
+ return [
117
+ this.insertPositionOptionLast,
118
+ this.insertPositionOptionFirst,
119
+ ...this.articlesInDocument.slice(1).map((_, index) => ({
120
+ label: this.intl.t(
121
+ 'editor-plugins.roadsign-regulation.expanded-measure.after-article-x',
122
+ { articleNumber: index + 1 },
123
+ ),
124
+ position: 'custom',
125
+ insertIndex: index + 1,
126
+ })),
127
+ ];
128
+ }
129
+
130
+ get insertPositionDropdownTitle() {
131
+ return this.selectedInsertPosition?.label.toLowerCase();
132
+ }
133
+
73
134
  <template>
74
135
  <tr class='au-c-data-table__detail'>
75
136
  <td colspan='5' class='au-o-flow au-o-flow--small'>
@@ -135,19 +196,28 @@ export default class ExpandedMeasure extends Component<Signature> {
135
196
  </AuRadioGroup>
136
197
  </div>
137
198
  {{/if}}
138
- <AuButtonGroup>
139
- <AuButton
140
- {{on 'click' this.insert}}
141
- @loading={{@insert.isRunning}}
142
- @loadingMessage={{t 'common.loading'}}
143
- @disabled={{this.insertButtonDisabled}}
144
- >
145
- {{t 'editor-plugins.utils.insert'}}
146
- </AuButton>
147
- <AuButton @skin='secondary' {{on 'click' this.unselectRow}}>
148
- {{t 'editor-plugins.utils.cancel'}}
149
- </AuButton>
150
- </AuButtonGroup>
199
+ <AuHeading @level='6' @skin='6'>
200
+ {{t
201
+ 'editor-plugins.roadsign-regulation.expanded-measure.insert-position'
202
+ }}
203
+ </AuHeading>
204
+ <PowerSelect
205
+ class='au-u-1-5'
206
+ @allowClear={{false}}
207
+ @onChange={{set this 'selectedInsertPosition'}}
208
+ @selected={{this.selectedInsertPosition}}
209
+ @options={{this.insertPositionOptions}}
210
+ as |option|
211
+ >{{option.label}}</PowerSelect>
212
+ <AuButton
213
+ {{on 'click' this.insert}}
214
+ @skin='primary'
215
+ @loading={{@insert.isRunning}}
216
+ @loadingMessage={{t 'common.loading'}}
217
+ @disabled={{this.insertButtonDisabled}}
218
+ >
219
+ {{t 'common.insert'}}
220
+ </AuButton>
151
221
  </td>
152
222
  </tr>
153
223
  </template>
@@ -41,6 +41,7 @@ import { Variable } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsig
41
41
  import { generateVariableInstanceUri } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/variable-helpers';
42
42
  import { mapObject } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/map-object';
43
43
  import { v4 as uuid } from 'uuid';
44
+ import { getArticleNodes } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/document-structure-utils';
44
45
 
45
46
  type Option = {
46
47
  uri: string;
@@ -319,6 +320,7 @@ export default class RoadsignsModal extends Component<Signature> {
319
320
  concept: MobilityMeasureConcept,
320
321
  zonality: ZonalOrNot,
321
322
  temporal: boolean,
323
+ position?: number,
322
324
  ) => {
323
325
  if (!this.decisionLocation) {
324
326
  return;
@@ -355,6 +357,7 @@ export default class RoadsignsModal extends Component<Signature> {
355
357
  decisionUri,
356
358
  zonality,
357
359
  temporal,
360
+ position,
358
361
  })(this.controller.mainEditorState).transaction;
359
362
  },
360
363
  { view: this.controller.mainEditorView },
@@ -386,6 +389,12 @@ export default class RoadsignsModal extends Component<Signature> {
386
389
  this.pageNumber = pageNumber;
387
390
  }
388
391
 
392
+ get articleNodes() {
393
+ return getArticleNodes(this.controller.mainEditorState).map(
394
+ (node) => node.node,
395
+ );
396
+ }
397
+
389
398
  <template>
390
399
  <AuModal
391
400
  class='au-c-modal--flush'
@@ -516,6 +525,7 @@ export default class RoadsignsModal extends Component<Signature> {
516
525
  @isLoading={{this.measureConceptsQuery.isRunning}}
517
526
  @insert={{this.insertMeasure}}
518
527
  @options={{@options}}
528
+ @articleNodes={{this.articleNodes}}
519
529
  />
520
530
  {{#if this.measureConceptCount}}
521
531
  {{#let
@@ -21,6 +21,7 @@ import { on } from '@ember/modifier';
21
21
  import { fn } from '@ember/helper';
22
22
  import { TRAFFIC_SIGNAL_CONCEPT_TYPES } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/constants';
23
23
  import removeZFromLabel from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/helpers/removeZFromLabel';
24
+ import { PNode } from '@lblod/ember-rdfa-editor';
24
25
 
25
26
  type Signature = {
26
27
  Args: {
@@ -28,6 +29,7 @@ type Signature = {
28
29
  content?: MobilityMeasureConcept[];
29
30
  isLoading?: boolean;
30
31
  insert: InsertMobilityMeasureTask;
32
+ articleNodes: PNode[];
31
33
  };
32
34
  };
33
35
 
@@ -163,6 +165,7 @@ export default class RoadSignsTable extends Component<Signature> {
163
165
  @insert={{@insert}}
164
166
  @selectRow={{this.selectRow}}
165
167
  @endpoint={{@options.endpoint}}
168
+ @articleNodes={{@articleNodes}}
166
169
  />
167
170
  {{/if}}
168
171
  {{else}}
@@ -20,6 +20,7 @@ interface InsertArticleToDecisionArgs {
20
20
  node: PNode;
21
21
  decisionUri: string;
22
22
  insertFreely?: false;
23
+ position?: number;
23
24
  }
24
25
  interface InsertArticleFreelyArgs {
25
26
  node: PNode;
@@ -46,7 +47,7 @@ export function insertArticle(
46
47
  };
47
48
  }
48
49
 
49
- const { decisionUri } = args;
50
+ const { decisionUri, position } = args;
50
51
  const decision = getNodesBySubject(state, decisionUri)[0];
51
52
  if (!decision) {
52
53
  return {
@@ -55,56 +56,98 @@ export function insertArticle(
55
56
  result: false,
56
57
  };
57
58
  }
59
+
58
60
  const decisionResource = decision.value.attrs.subject;
59
61
  const container = getOutgoingTriple(decision.value.attrs, PROV('value'));
60
- if (container) {
61
- const location = findNodeByRdfaId(state.doc, container.object.value);
62
- if (location) {
63
- const insertLocation = location.pos + location.value.nodeSize - 1;
64
- const factory = new SayDataFactory();
65
- const tr = state.tr;
66
- const combiResult = transactionCombinator(
67
- state,
68
- tr.replaceWith(insertLocation, insertLocation, node),
69
- )([
70
- addPropertyToNode({
71
- resource: decisionResource,
72
- property: {
73
- predicate: ELI('has_part').full,
74
- object: factory.resourceNode(node.attrs.subject),
75
- },
76
- }),
77
- recalculateNumbers,
78
- ]);
79
-
80
- const { result, transaction } = combiResult;
81
-
82
- transaction.setSelection(
83
- TextSelection.create(
84
- transaction.doc,
85
- insertLocation + 1,
86
- insertLocation + node.nodeSize - 1,
87
- ),
88
- );
89
-
90
- transaction.scrollIntoView();
91
- return {
92
- initialState: state,
93
- transaction,
94
- result: result.every((ok) => ok),
95
- };
96
- } else {
97
- return {
98
- initialState: state,
99
- transaction: state.tr,
100
- result: false,
101
- };
102
- }
62
+ if (!container) {
63
+ return {
64
+ initialState: state,
65
+ transaction: state.tr,
66
+ result: false,
67
+ };
68
+ }
69
+
70
+ const location = findNodeByRdfaId(state.doc, container.object.value);
71
+ if (!location) {
72
+ return {
73
+ initialState: state,
74
+ transaction: state.tr,
75
+ result: false,
76
+ };
103
77
  }
78
+
79
+ const insertLocation = resolveInsertLocation(location, position);
80
+
81
+ const factory = new SayDataFactory();
82
+ const tr = state.tr;
83
+ const combiResult = transactionCombinator(
84
+ state,
85
+ tr.replaceWith(insertLocation, insertLocation, node),
86
+ )([
87
+ addPropertyToNode({
88
+ resource: decisionResource,
89
+ property: {
90
+ predicate: ELI('has_part').full,
91
+ object: factory.resourceNode(node.attrs.subject),
92
+ },
93
+ }),
94
+ recalculateNumbers,
95
+ ]);
96
+
97
+ const { result, transaction } = combiResult;
98
+
99
+ transaction.setSelection(
100
+ TextSelection.create(
101
+ transaction.doc,
102
+ insertLocation + 1,
103
+ insertLocation + node.nodeSize - 1,
104
+ ),
105
+ );
106
+
107
+ transaction.scrollIntoView();
104
108
  return {
105
109
  initialState: state,
106
- transaction: state.tr,
107
- result: false,
110
+ transaction,
111
+ result: result.every((ok) => ok),
108
112
  };
109
113
  };
110
114
  }
115
+
116
+ /**
117
+ * Resolves the document position at which to insert a new article node
118
+ *
119
+ * - If `position` is undefined, insert at the end of the container.
120
+ * - If `position` is 0, insert before the first child.
121
+ * - If `position` >= childCount, insert after the last child (append).
122
+ * - Otherwise, insert before the child at that index.
123
+ */
124
+ function resolveInsertLocation(
125
+ location: { pos: number; value: PNode },
126
+ position: number | undefined,
127
+ ): number {
128
+ const containerNode = location.value;
129
+
130
+ if (position === undefined) {
131
+ return location.pos + containerNode.nodeSize - 1;
132
+ }
133
+
134
+ const childCount = containerNode.childCount;
135
+
136
+ if (position >= childCount) {
137
+ return location.pos + containerNode.nodeSize - 1;
138
+ }
139
+
140
+ let offset = location.pos + 1; // +1 to step inside the container node
141
+ let articleIndex = 0;
142
+ for (const child of containerNode.children) {
143
+ if (articleIndex === position) {
144
+ return offset;
145
+ }
146
+ offset += child.nodeSize;
147
+ if (child.attrs.structureType === 'article') {
148
+ articleIndex += 1;
149
+ }
150
+ }
151
+
152
+ return location.pos + containerNode.nodeSize - 1;
153
+ }
@@ -15,12 +15,14 @@ interface InsertArticleContainerArgs {
15
15
  decisionUri: string;
16
16
  articleUriGenerator?: () => string;
17
17
  decisionLocation: NodeWithPos;
18
+ label?: string;
18
19
  }
19
20
 
20
21
  export default function insertArticleContainer({
21
22
  decisionUri,
22
23
  articleUriGenerator,
23
24
  decisionLocation,
25
+ label,
24
26
  }: InsertArticleContainerArgs): Command {
25
27
  return function (state: EditorState, dispatch?: (tr: Transaction) => void) {
26
28
  const { schema } = state;
@@ -29,6 +31,7 @@ export default function insertArticleContainer({
29
31
  {
30
32
  rdfaNodeType: 'literal',
31
33
  __rdfaId: articleContainerId,
34
+ label,
32
35
  },
33
36
  schema.nodes.paragraph.create(),
34
37
  );
@@ -9,18 +9,20 @@ import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transactio
9
9
  interface InsertDescriptionArgs {
10
10
  placeholderText: string;
11
11
  decisionLocation: NodeWithPos;
12
+ label?: string;
12
13
  }
13
14
 
14
15
  export default function insertDescription({
15
16
  placeholderText,
16
17
  decisionLocation,
18
+ label,
17
19
  }: InsertDescriptionArgs) {
18
20
  return function (state: EditorState, dispatch?: (tr: Transaction) => void) {
19
21
  const { schema } = state;
20
22
  const descriptionId = uuid();
21
23
  const nodeToInsert = schema.node(
22
24
  'block_rdfa',
23
- { rdfaNodeType: 'literal', __rdfaId: descriptionId },
25
+ { rdfaNodeType: 'literal', __rdfaId: descriptionId, label },
24
26
  schema.node(
25
27
  'paragraph',
26
28
  null,
@@ -30,6 +32,7 @@ export default function insertDescription({
30
32
  ),
31
33
  );
32
34
  const tr = state.tr;
35
+ console.log(nodeToInsert);
33
36
 
34
37
  if (state.selection.$from.pos === decisionLocation.pos) {
35
38
  tr.replaceRangeWith(
@@ -11,11 +11,13 @@ import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transactio
11
11
  interface InsertMotivationArgs {
12
12
  intl: IntlService;
13
13
  decisionLocation: NodeWithPos;
14
+ label?: string;
14
15
  }
15
16
 
16
17
  export default function insertMotivation({
17
18
  intl,
18
19
  decisionLocation,
20
+ label,
19
21
  }: InsertMotivationArgs): Command {
20
22
  return function (state: EditorState, dispatch?: (tr: Transaction) => void) {
21
23
  const translationWithDocLang = getTranslationFunction(state);
@@ -24,7 +26,7 @@ export default function insertMotivation({
24
26
  const motivationId = uuid();
25
27
  const nodeToInsert = schema.node(
26
28
  'block_rdfa',
27
- { rdfaNodeType: 'literal', __rdfaId: motivationId },
29
+ { rdfaNodeType: 'literal', __rdfaId: motivationId, label },
28
30
  [
29
31
  schema.node(
30
32
  'paragraph',
@@ -9,18 +9,20 @@ import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transactio
9
9
  interface InsertTitleArgs {
10
10
  placeholderText: string;
11
11
  decisionLocation: NodeWithPos;
12
+ label?: string;
12
13
  }
13
14
 
14
15
  export default function insertTitle({
15
16
  placeholderText,
16
17
  decisionLocation,
18
+ label,
17
19
  }: InsertTitleArgs) {
18
20
  return function (state: EditorState, dispatch?: (tr: Transaction) => void) {
19
21
  const { schema } = state;
20
22
  const titleId = uuid();
21
23
  const nodeToInsert = schema.node(
22
24
  'block_rdfa',
23
- { rdfaNodeType: 'literal', __rdfaId: titleId },
25
+ { rdfaNodeType: 'literal', __rdfaId: titleId, label },
24
26
  schema.node(
25
27
  'paragraph',
26
28
  null,
@@ -28,6 +28,7 @@ export function insertTitleAtCursor(
28
28
  insertTitle({
29
29
  placeholderText: intl.t('besluit-plugin.placeholder.decision-title'),
30
30
  decisionLocation: decisionNodeLocation,
31
+ label: 'Titel',
31
32
  }),
32
33
  { view: controller.mainEditorView },
33
34
  );
@@ -51,6 +52,7 @@ export function insertDescriptionAtCursor(
51
52
  'besluit-plugin.placeholder.decision-description',
52
53
  ),
53
54
  decisionLocation: decisionNodeLocation,
55
+ label: 'Beschrijving',
54
56
  }),
55
57
  {
56
58
  view: controller.mainEditorView,
@@ -74,6 +76,7 @@ export function insertMotivationAtCursor(
74
76
  insertMotivation({
75
77
  intl: intl,
76
78
  decisionLocation: decisionNodeLocation,
79
+ label: 'Motivering',
77
80
  }),
78
81
  {
79
82
  view: controller.mainEditorView,
@@ -100,6 +103,7 @@ export function insertArticleContainerAtCursor(
100
103
  decisionUri: decisionNodeLocation?.node.attrs.subject,
101
104
  articleUriGenerator: articleUriGenerator,
102
105
  decisionLocation: decisionNodeLocation,
106
+ label: 'Artikels',
103
107
  }),
104
108
  {
105
109
  view: controller.mainEditorView,