@lblod/ember-rdfa-editor-lblod-plugins 5.0.1 → 6.0.0

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 (73) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/README.md +126 -70
  3. package/addon/components/address-plugin/insert.hbs +47 -0
  4. package/addon/components/address-plugin/insert.ts +100 -0
  5. package/addon/components/address-plugin/types.ts +26 -0
  6. package/addon/components/address-plugin/utils.ts +59 -0
  7. package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +6 -5
  8. package/addon/components/{besluit-plugin/besluit-plugin-card.ts → decision-plugin/decision-plugin-card.ts} +22 -8
  9. package/addon/components/roadsign-regulation-plugin/measure-template.ts +5 -1
  10. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +1 -1
  11. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.hbs +1 -0
  12. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +24 -21
  13. package/addon/components/roadsign-regulation-plugin/roadsigns-table.ts +8 -11
  14. package/addon/components/validation-plugin/validation-card.hbs +12 -0
  15. package/addon/components/validation-plugin/validation-card.ts +19 -0
  16. package/addon/components/validation-plugin/validation-item.hbs +2 -0
  17. package/addon/components/validation-plugin/validation-item.ts +55 -0
  18. package/addon/components/variable-plugin/template-variable-card.ts +8 -25
  19. package/addon/plugins/besluit-type-plugin/index.ts +3 -0
  20. package/addon/plugins/besluit-type-plugin/utils/fetchBesluitTypes.ts +1 -6
  21. package/addon/plugins/decision-plugin/commands/index.ts +4 -0
  22. package/addon/plugins/decision-plugin/commands/insert-article-container.ts +56 -0
  23. package/addon/plugins/decision-plugin/commands/insert-description.ts +53 -0
  24. package/addon/plugins/decision-plugin/commands/insert-motivation.ts +62 -0
  25. package/addon/plugins/decision-plugin/commands/insert-title.ts +54 -0
  26. package/addon/plugins/roadsign-regulation-plugin/index.ts +4 -0
  27. package/addon/plugins/standard-template-plugin/utils/nodes.ts +0 -1
  28. package/addon/plugins/validation/README.md +84 -0
  29. package/addon/plugins/validation/index.ts +427 -0
  30. package/addon/plugins/validation/utils/transaction-complies-with-shapes.ts +28 -0
  31. package/addon/plugins/variable-plugin/index.ts +5 -0
  32. package/addon/services/roadsign-registry.ts +54 -50
  33. package/addon/utils/find-insertion-pos-in-ancestor-of-type.ts +35 -0
  34. package/app/components/{besluit-plugin/besluit-plugin-card.js → address-plugin/insert.js} +1 -1
  35. package/app/components/decision-plugin/decision-plugin-card.js +1 -0
  36. package/app/components/{besluit-plugin/besluit-context-card.js → validation-plugin/validation-card.js} +1 -1
  37. package/app/components/validation-plugin/validation-item.js +1 -0
  38. package/app/styles/address-plugin.scss +7 -0
  39. package/components/address-plugin/insert.d.ts +21 -0
  40. package/components/address-plugin/types.d.ts +25 -0
  41. package/components/address-plugin/utils.d.ts +9 -0
  42. package/components/besluit-type-plugin/toolbar-dropdown.d.ts +2 -0
  43. package/components/{besluit-plugin/besluit-plugin-card.d.ts → decision-plugin/decision-plugin-card.d.ts} +4 -1
  44. package/components/roadsign-regulation-plugin/measure-template.d.ts +2 -0
  45. package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +3 -0
  46. package/components/roadsign-regulation-plugin/roadsigns-table.d.ts +6 -1
  47. package/components/validation-plugin/validation-card.d.ts +13 -0
  48. package/components/validation-plugin/validation-item.d.ts +18 -0
  49. package/components/variable-plugin/template-variable-card.d.ts +2 -4
  50. package/package.json +1 -1
  51. package/plugins/besluit-type-plugin/index.d.ts +3 -0
  52. package/plugins/besluit-type-plugin/utils/fetchBesluitTypes.d.ts +1 -5
  53. package/plugins/decision-plugin/commands/index.d.ts +4 -0
  54. package/plugins/decision-plugin/commands/insert-article-container.d.ts +8 -0
  55. package/plugins/decision-plugin/commands/insert-description.d.ts +7 -0
  56. package/plugins/decision-plugin/commands/insert-motivation.d.ts +7 -0
  57. package/plugins/decision-plugin/commands/insert-title.d.ts +7 -0
  58. package/plugins/roadsign-regulation-plugin/index.d.ts +4 -0
  59. package/plugins/validation/index.d.ts +62 -0
  60. package/plugins/validation/utils/transaction-complies-with-shapes.d.ts +10 -0
  61. package/plugins/variable-plugin/index.d.ts +5 -0
  62. package/services/roadsign-registry.d.ts +7 -9
  63. package/translations/en-US.yaml +58 -47
  64. package/translations/nl-BE.yaml +15 -0
  65. package/utils/find-insertion-pos-in-ancestor-of-type.d.ts +11 -0
  66. package/addon/plugins/besluit-plugin/commands/index.ts +0 -1
  67. package/addon/plugins/besluit-plugin/commands/insert-title.ts +0 -43
  68. package/config/environment.js +0 -20
  69. package/plugins/besluit-plugin/commands/index.d.ts +0 -1
  70. package/plugins/besluit-plugin/commands/insert-title.d.ts +0 -3
  71. /package/addon/components/{besluit-plugin/besluit-plugin-card.hbs → decision-plugin/decision-plugin-card.hbs} +0 -0
  72. /package/addon/plugins/{besluit-plugin → decision-plugin}/utils/get-title-for-decision.ts +0 -0
  73. /package/plugins/{besluit-plugin → decision-plugin}/utils/get-title-for-decision.d.ts +0 -0
@@ -1,7 +1,6 @@
1
1
  import Service from '@ember/service';
2
2
  import { task, timeout } from 'ember-concurrency';
3
3
  import { tracked } from '@glimmer/tracking';
4
- import { getOwner } from '@ember/application';
5
4
  import { generateMeasuresQuery } from '../plugins/roadsign-regulation-plugin/utils/fetchData';
6
5
  import Instruction from '../models/instruction';
7
6
  import Measure from '../models/measure';
@@ -26,32 +25,24 @@ const DEBOUNCE_MS = 100;
26
25
  export default class RoadsignRegistryService extends Service {
27
26
  @tracked classifications: { value: string; label: string }[] = [];
28
27
  instructions: Map<string, Instruction[]> = new Map();
29
- endpoint: string;
30
- imageBaseUrl: string;
31
28
 
32
29
  constructor() {
33
30
  // eslint-disable-next-line prefer-rest-params
34
31
  super(...arguments);
35
- const config = getOwner(this).resolveRegistration('config:environment') as {
36
- roadsignRegulationPlugin: {
37
- imageBaseUrl: string;
38
- endpoint: string;
39
- };
40
- };
41
- this.imageBaseUrl = config.roadsignRegulationPlugin.imageBaseUrl;
42
- this.endpoint = config.roadsignRegulationPlugin.endpoint;
43
- void this.loadClassifications.perform();
44
32
  }
45
33
 
46
- loadClassifications = task(async () => {
47
- const result = await this.executeQuery.perform(`
34
+ loadClassifications = task(async (endpoint: string) => {
35
+ const result = await this.executeQuery.perform(
36
+ `
48
37
  SELECT DISTINCT ?classificationUri ?classificationLabel WHERE {
49
38
  ?measure ext:relation/ext:concept ?signUri.
50
39
  ?signUri org:classification ?classificationUri.
51
40
  ?classificationUri a mobiliteit:Verkeersbordcategorie;
52
41
  skos:prefLabel ?classificationLabel.
53
42
  }
54
- `);
43
+ `,
44
+ endpoint
45
+ );
55
46
  const bindings = result.results.bindings;
56
47
  this.classifications = bindings.map((binding) => ({
57
48
  value: unwrap(binding['classificationUri']?.value),
@@ -60,12 +51,13 @@ export default class RoadsignRegistryService extends Service {
60
51
  });
61
52
 
62
53
  getInstructionsForMeasure = task(
63
- async (uri: string): Promise<Instruction[]> => {
54
+ async (uri: string, endpoint: string): Promise<Instruction[]> => {
64
55
  if (this.instructions.has(uri)) {
65
56
  return unwrap(this.instructions.get(uri));
66
57
  } else {
67
58
  const instructions = await this.fetchInstructionsForMeasure.perform(
68
- uri
59
+ uri,
60
+ endpoint
69
61
  );
70
62
  this.instructions.set(uri, instructions);
71
63
  return instructions;
@@ -76,6 +68,7 @@ export default class RoadsignRegistryService extends Service {
76
68
  searchCode = task(
77
69
  { restartable: true },
78
70
  async (
71
+ endpoint: string,
79
72
  codeString?: string,
80
73
  category?: string,
81
74
  type?: string,
@@ -125,7 +118,7 @@ export default class RoadsignRegistryService extends Service {
125
118
  }
126
119
  ORDER BY ASC(?signCode)
127
120
  `;
128
- const result = await this.executeQuery.perform(query);
121
+ const result = await this.executeQuery.perform(query, endpoint);
129
122
  const codes = result.results.bindings.map((binding) => ({
130
123
  value: unwrap(binding['signUri']?.value),
131
124
  label: unwrap(binding['signCode']?.value),
@@ -136,14 +129,15 @@ export default class RoadsignRegistryService extends Service {
136
129
 
137
130
  executeQuery = task(
138
131
  async (
139
- query: string
132
+ query: string,
133
+ endpoint: string
140
134
  ): Promise<{
141
135
  results: {
142
136
  bindings: IBindings[];
143
137
  };
144
138
  }> => {
145
139
  const encodedQuery = encodeURIComponent(`${PREFIXES}\n${query.trim()}`);
146
- const response = await fetch(this.endpoint, {
140
+ const response = await fetch(endpoint, {
147
141
  method: 'POST',
148
142
  mode: 'cors',
149
143
  headers: {
@@ -167,7 +161,7 @@ export default class RoadsignRegistryService extends Service {
167
161
  );
168
162
 
169
163
  fetchInstructionsForMeasure = task(
170
- async (uri: string): Promise<Instruction[]> => {
164
+ async (uri: string, endpoint: string): Promise<Instruction[]> => {
171
165
  const query = `SELECT ?name ?template ?annotatedTemplate
172
166
  WHERE {
173
167
  <${uri}> ext:template/ext:mapping ?mapping.
@@ -178,7 +172,7 @@ export default class RoadsignRegistryService extends Service {
178
172
  ext:value ?template.
179
173
  }
180
174
  `;
181
- const result = await this.executeQuery.perform(query);
175
+ const result = await this.executeQuery.perform(query, endpoint);
182
176
  const instructions = result.results.bindings.map((binding) =>
183
177
  Instruction.fromBinding(binding)
184
178
  );
@@ -188,19 +182,23 @@ export default class RoadsignRegistryService extends Service {
188
182
 
189
183
  fetchMeasures = task(
190
184
  { restartable: true },
191
- async ({
192
- zonality,
193
- type,
194
- codes,
195
- category,
196
- pageStart,
197
- }: {
198
- zonality?: string;
199
- type?: string;
200
- codes?: string[];
201
- category?: string;
202
- pageStart?: number;
203
- } = {}) => {
185
+ async (
186
+ endpoint: string,
187
+ imageBaseUrl: string,
188
+ {
189
+ zonality,
190
+ type,
191
+ codes,
192
+ category,
193
+ pageStart,
194
+ }: {
195
+ zonality?: string;
196
+ type?: string;
197
+ codes?: string[];
198
+ category?: string;
199
+ pageStart?: number;
200
+ } = {}
201
+ ) => {
204
202
  const selectQuery = generateMeasuresQuery({
205
203
  zonality,
206
204
  type,
@@ -215,7 +213,7 @@ export default class RoadsignRegistryService extends Service {
215
213
  category,
216
214
  count: true,
217
215
  });
218
- const countResult = await this.executeQuery.perform(countQuery);
216
+ const countResult = await this.executeQuery.perform(countQuery, endpoint);
219
217
 
220
218
  const count = optionMapOr(
221
219
  0,
@@ -223,10 +221,14 @@ export default class RoadsignRegistryService extends Service {
223
221
  countResult.results.bindings[0]?.['count']?.value
224
222
  );
225
223
  const measures = [];
226
- const result = await this.executeQuery.perform(selectQuery);
224
+ const result = await this.executeQuery.perform(selectQuery, endpoint);
227
225
  for (const binding of result.results.bindings) {
228
226
  const measure = Measure.fromBinding(binding);
229
- measure.signs = await this.fetchSignsForMeasure.perform(measure.uri);
227
+ measure.signs = await this.fetchSignsForMeasure.perform(
228
+ measure.uri,
229
+ endpoint,
230
+ imageBaseUrl
231
+ );
230
232
  measure.classifications = makeClassificationSet(measure.signs);
231
233
  measures.push(measure);
232
234
  }
@@ -234,8 +236,9 @@ export default class RoadsignRegistryService extends Service {
234
236
  }
235
237
  );
236
238
 
237
- fetchSignsForMeasure = task(async (uri: string) => {
238
- const query = `
239
+ fetchSignsForMeasure = task(
240
+ async (uri: string, endpoint: string, imageBaseUrl: string) => {
241
+ const query = `
239
242
  SELECT ?uri ?code ?image ?zonality ?order (GROUP_CONCAT(?classification; SEPARATOR="|") AS ?classifications)
240
243
  WHERE {
241
244
  <${uri}> ext:relation ?relation.
@@ -251,17 +254,18 @@ WHERE {
251
254
  }
252
255
  } ORDER BY ASC(?order)
253
256
  `;
254
- const result = await this.executeQuery.perform(query);
255
- const signs = [];
256
- for (const binding of result.results.bindings) {
257
- const sign = Sign.fromBinding({
258
- ...binding,
259
- imageBaseUrl: dataFactory.namedNode(this.imageBaseUrl),
260
- });
261
- signs.push(sign);
257
+ const result = await this.executeQuery.perform(query, endpoint);
258
+ const signs = [];
259
+ for (const binding of result.results.bindings) {
260
+ const sign = Sign.fromBinding({
261
+ ...binding,
262
+ imageBaseUrl: dataFactory.namedNode(imageBaseUrl),
263
+ });
264
+ signs.push(sign);
265
+ }
266
+ return signs;
262
267
  }
263
- return signs;
264
- });
268
+ );
265
269
  }
266
270
 
267
271
  function makeClassificationSet(signs: Iterable<Sign>) {
@@ -0,0 +1,35 @@
1
+ import { NodeType, PNode, Selection } from '@lblod/ember-rdfa-editor';
2
+ import { Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
3
+ import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
4
+
5
+ /**
6
+ * Starting from the given selection, find a suitable position within an ancestor node
7
+ * of a given type to insert a given node into. Returns null when this fails, aka when
8
+ * suitable ancestor is found, or when within the found ancestor no suitable position can be found
9
+ * @param selection
10
+ * @param ancestorType
11
+ * @param nodeToInsert
12
+ */
13
+ export function findInsertionPosInAncestorOfType(
14
+ selection: Selection,
15
+ ancestorType: NodeType,
16
+ nodeToInsert: PNode
17
+ ): Option<number> {
18
+ const { $from } = selection;
19
+ const ancestor = findParentNodeOfType(ancestorType)(selection);
20
+ if (!ancestor) {
21
+ return null;
22
+ }
23
+ const insertionIndex = $from.indexAfter(ancestor.depth);
24
+ const insertionPos = $from.posAtIndex(insertionIndex, ancestor.depth);
25
+ if (
26
+ !ancestor.node.canReplaceWith(
27
+ insertionIndex,
28
+ insertionIndex,
29
+ nodeToInsert.type
30
+ )
31
+ ) {
32
+ return null;
33
+ }
34
+ return insertionPos;
35
+ }
@@ -1 +1 @@
1
- export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/besluit-plugin/besluit-plugin-card';
1
+ export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/address-plugin/insert';
@@ -0,0 +1 @@
1
+ export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/decision-plugin/decision-plugin-card';
@@ -1 +1 @@
1
- export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/besluit-plugin/besluit-context-card';
1
+ export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/validation-plugin/validation-card';
@@ -0,0 +1 @@
1
+ export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/validation-plugin/validation-item';
@@ -0,0 +1,7 @@
1
+ .address-plugin-modal {
2
+ overflow: visible;
3
+
4
+ .au-c-modal__body {
5
+ overflow: visible;
6
+ }
7
+ }
@@ -0,0 +1,21 @@
1
+ import Component from '@glimmer/component';
2
+ import { SayController } from '@lblod/ember-rdfa-editor';
3
+ import { AddressSuggestion } from './types';
4
+ type Args = {
5
+ controller: SayController;
6
+ };
7
+ export default class AddressPluginInsertComponent extends Component<Args> {
8
+ modalOpen: boolean;
9
+ isSelectingAddress: boolean;
10
+ addressSuggestions: AddressSuggestion[];
11
+ selectedAddress: AddressSuggestion | null;
12
+ get controller(): SayController;
13
+ get schema(): import("prosemirror-model").Schema<any, any>;
14
+ openModal(): void;
15
+ closeModal(): void;
16
+ selectAddress(selection: AddressSuggestion): void;
17
+ get canInsertAddress(): boolean;
18
+ insertAddress: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, () => Promise<void>>;
19
+ searchAddress: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, (term: string) => Promise<AddressSuggestion[]>>;
20
+ }
21
+ export {};
@@ -0,0 +1,25 @@
1
+ export type AddressSuggestion = {
2
+ ID: number;
3
+ FormattedAddress: string;
4
+ Municipality: string;
5
+ Thoroughfarename: string;
6
+ Housenumber: string;
7
+ Zipcode: string;
8
+ };
9
+ export type Address = {
10
+ identificator: {
11
+ id: string;
12
+ naamruimte: string;
13
+ objectId: string;
14
+ versieId: string;
15
+ };
16
+ detail: string;
17
+ huisnummer: string;
18
+ volledigAdres: {
19
+ geografischeNaam: {
20
+ spelling: string;
21
+ taal: string;
22
+ };
23
+ };
24
+ adresStatus: string;
25
+ };
@@ -0,0 +1,9 @@
1
+ import { Address, AddressSuggestion } from './types';
2
+ export declare const replaceAccents: (string: string) => string;
3
+ export declare function getSuggestedLocations(query: string): Promise<AddressSuggestion[]>;
4
+ export declare function getAddressMatch({ municipality, zipcode, street, housenumber, }: {
5
+ municipality: string;
6
+ street: string;
7
+ housenumber: string;
8
+ zipcode: string;
9
+ }): Promise<Address[]>;
@@ -3,6 +3,7 @@ import { SayController } from '@lblod/ember-rdfa-editor';
3
3
  import CurrentSessionService from '@lblod/frontend-gelinkt-notuleren/services/current-session';
4
4
  import { ResolvedPNode } from '@lblod/ember-rdfa-editor/plugins/datastore';
5
5
  import { BesluitType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
6
+ import { BesluitTypePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin';
6
7
  declare module 'ember__owner' {
7
8
  export default interface Owner {
8
9
  resolveRegistration(name: string): unknown;
@@ -10,6 +11,7 @@ declare module 'ember__owner' {
10
11
  }
11
12
  type Args = {
12
13
  controller: SayController;
14
+ options: BesluitTypePluginOptions;
13
15
  };
14
16
  export default class EditorPluginsToolbarDropdownComponent extends Component<Args> {
15
17
  currentSession: CurrentSessionService;
@@ -4,7 +4,10 @@ import IntlService from 'ember-intl/services/intl';
4
4
  type Args = {
5
5
  controller: SayController;
6
6
  };
7
- export default class BesluitPluginCardComponent extends Component<Args> {
7
+ /**
8
+ * @deprecated
9
+ */
10
+ export default class DecisionPluginCard extends Component<Args> {
8
11
  intl: IntlService;
9
12
  get controller(): SayController;
10
13
  focus(): void;
@@ -4,10 +4,12 @@ type Args = {
4
4
  template: string;
5
5
  measure: string;
6
6
  annotated: boolean;
7
+ endpoint: string;
7
8
  };
8
9
  export default class MeasureTemplateComponent extends Component<Args> {
9
10
  roadsignRegistry: RoadsignRegistryService;
10
11
  template: string;
12
+ endpoint: string;
11
13
  constructor(parent: unknown, args: Args);
12
14
  fetchData: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, () => Promise<void>>;
13
15
  }
@@ -3,6 +3,7 @@ import RoadsignRegistryService from '@lblod/ember-rdfa-editor-lblod-plugins/serv
3
3
  import Measure from '@lblod/ember-rdfa-editor-lblod-plugins/models/measure';
4
4
  import { SayController } from '@lblod/ember-rdfa-editor';
5
5
  import IntlService from 'ember-intl/services/intl';
6
+ import { RoadsignRegulationPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin';
6
7
  type Option = {
7
8
  label: string;
8
9
  value: string;
@@ -14,9 +15,11 @@ type Category = Option;
14
15
  type Args = {
15
16
  closeModal: () => void;
16
17
  controller: SayController;
18
+ options: RoadsignRegulationPluginOptions;
17
19
  };
18
20
  export default class RoadsignRegulationCard extends Component<Args> {
19
21
  endpoint: string;
22
+ imageBaseUrl: string;
20
23
  pageSize: number;
21
24
  roadsignRegistry: RoadsignRegistryService;
22
25
  intl: IntlService;
@@ -1,5 +1,10 @@
1
1
  import Component from '@glimmer/component';
2
- type Args = Record<string, never>;
2
+ import { SayController } from '@lblod/ember-rdfa-editor';
3
+ import { RoadsignRegulationPluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin';
4
+ type Args = {
5
+ controller: SayController;
6
+ options: RoadsignRegulationPluginOptions;
7
+ };
3
8
  export default class RoadsignsTable extends Component<Args> {
4
9
  selected?: string;
5
10
  imageBaseUrl: string;
@@ -0,0 +1,13 @@
1
+ import Component from '@glimmer/component';
2
+ import { SayController } from '@lblod/ember-rdfa-editor';
3
+ import { ValidationReport } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/validation';
4
+ interface Args {
5
+ report: ValidationReport;
6
+ controller?: SayController;
7
+ title: string;
8
+ }
9
+ export default class ValidationCardComponent extends Component<Args> {
10
+ get shouldShow(): boolean;
11
+ get results(): import("@lblod/ember-rdfa-editor-lblod-plugins/plugins/validation").ValidationResult[];
12
+ }
13
+ export {};
@@ -0,0 +1,18 @@
1
+ import Component from '@glimmer/component';
2
+ import { SayController } from '@lblod/ember-rdfa-editor';
3
+ import { ValidationResult } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/validation';
4
+ import IntlService from 'ember-intl/services/intl';
5
+ interface Args {
6
+ icon?: string;
7
+ result: ValidationResult;
8
+ controller?: SayController;
9
+ }
10
+ export default class ValidationItem extends Component<Args> {
11
+ intl: IntlService;
12
+ get result(): ValidationResult;
13
+ get message(): string;
14
+ get skin(): "error" | "info" | "warning";
15
+ get icon(): "info-circle" | "alert-triangle" | "cross";
16
+ get controller(): SayController | undefined;
17
+ }
18
+ export {};
@@ -2,8 +2,10 @@ import Component from '@glimmer/component';
2
2
  import { SayController } from '@lblod/ember-rdfa-editor';
3
3
  import { CodeListOption } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/fetch-data';
4
4
  import { PNode } from '@lblod/ember-rdfa-editor';
5
+ import { TemplateVariablePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin';
5
6
  type Args = {
6
7
  controller: SayController;
8
+ options: TemplateVariablePluginOptions;
7
9
  };
8
10
  export default class EditorPluginsTemplateVariableCardComponent extends Component<Args> {
9
11
  variableOptions: CodeListOption[];
@@ -15,10 +17,6 @@ export default class EditorPluginsTemplateVariableCardComponent extends Componen
15
17
  showCard: boolean;
16
18
  multiSelect: boolean;
17
19
  mappingUri?: string;
18
- zonalLocationCodelistUri: string;
19
- endpoint: string;
20
- nonZonalLocationCodelistUri: string;
21
- constructor(parent: unknown, args: Args);
22
20
  get controller(): SayController;
23
21
  insert(): void;
24
22
  wrapVariableInHighlight(text: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "5.0.1",
3
+ "version": "6.0.0",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -0,0 +1,3 @@
1
+ export type BesluitTypePluginOptions = {
2
+ endpoint: string;
3
+ };
@@ -5,8 +5,4 @@ export type BesluitType = {
5
5
  broader: string;
6
6
  subTypes?: BesluitType[];
7
7
  };
8
- export default function fetchBesluitTypes(classificationUri: string, ENV: {
9
- besluitTypePlugin: {
10
- endpoint: string;
11
- };
12
- }): Promise<BesluitType[]>;
8
+ export default function fetchBesluitTypes(classificationUri: string, endpoint: string): Promise<BesluitType[]>;
@@ -0,0 +1,4 @@
1
+ export { default as insertTitle } from './insert-title';
2
+ export { default as insertArticleContainer } from './insert-article-container';
3
+ export { default as insertDescription } from './insert-description';
4
+ export { default as insertMotivation } from './insert-motivation';
@@ -0,0 +1,8 @@
1
+ import { Command } from '@lblod/ember-rdfa-editor';
2
+ import IntlService from 'ember-intl/services/intl';
3
+ interface InsertArticleContainerArgs {
4
+ intl: IntlService;
5
+ validateShapes?: Set<string>;
6
+ }
7
+ export default function insertArticleContainer({ intl, validateShapes, }: InsertArticleContainerArgs): Command;
8
+ export {};
@@ -0,0 +1,7 @@
1
+ import { EditorState, Transaction } from '@lblod/ember-rdfa-editor';
2
+ interface InsertDescriptionArgs {
3
+ placeholderText: string;
4
+ validateShapes?: Set<string>;
5
+ }
6
+ export default function insertDescription({ placeholderText, validateShapes, }: InsertDescriptionArgs): (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Command } from '@lblod/ember-rdfa-editor';
2
+ interface InsertMotivationArgs {
3
+ placeholderText?: string;
4
+ validateShapes?: Set<string>;
5
+ }
6
+ export default function insertMotivation({ validateShapes, placeholderText, }?: InsertMotivationArgs): Command;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { EditorState, Transaction } from '@lblod/ember-rdfa-editor';
2
+ interface InsertTitleArgs {
3
+ placeholderText: string;
4
+ validateShapes?: Set<string>;
5
+ }
6
+ export default function insertTitle({ placeholderText, validateShapes, }: InsertTitleArgs): (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
7
+ export {};
@@ -0,0 +1,4 @@
1
+ export type RoadsignRegulationPluginOptions = {
2
+ endpoint: string;
3
+ imageBaseUrl: string;
4
+ };
@@ -0,0 +1,62 @@
1
+ import { EditorState, NodeType, PluginKey, PNode, ProsePlugin, Schema, Transaction } from '@lblod/ember-rdfa-editor';
2
+ import { Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
3
+ export declare function validateTransaction(state: EditorState, tr: Transaction): ValidationReport;
4
+ export declare const VALIDATION_KEY: PluginKey<ValidationState>;
5
+ export interface ValidationSpec {
6
+ [key: string]: ValidationShape[];
7
+ }
8
+ export type ValidationState = {
9
+ report: ValidationReport;
10
+ spec: ValidationSpec;
11
+ };
12
+ export type PropertyPath = string[];
13
+ export type Severity = 'info' | 'warning' | 'violation';
14
+ export interface ValidationReport {
15
+ conforms: boolean;
16
+ results?: ValidationResult[];
17
+ }
18
+ export type ValidationPlugin = ProsePlugin<ValidationState>;
19
+ export interface MinCountConstraint {
20
+ kind: 'minCount';
21
+ value: number;
22
+ }
23
+ export interface MaxCountConstraint {
24
+ kind: 'maxCount';
25
+ value: number;
26
+ }
27
+ export type ValidationConstraint = MinCountConstraint | MaxCountConstraint;
28
+ export type ConstraintMap = {
29
+ [C in ValidationConstraint as C['kind']]?: C['value'];
30
+ };
31
+ export type ConstraintValidator = (constraint: ValidationConstraint, shapeContext: ShapeContext) => Option<ValidationResult>;
32
+ export type ConstraintValidatorMap = {
33
+ [C in ValidationConstraint as C['kind']]: ConstraintValidator;
34
+ };
35
+ export interface ValidationShape {
36
+ name: string;
37
+ focusNodeType: NodeType;
38
+ path: string[] | number[];
39
+ message?: string;
40
+ constraints?: ConstraintMap;
41
+ severity?: Severity;
42
+ }
43
+ export interface ValidationResult {
44
+ focusNode: PNode;
45
+ resultPath: PNode[];
46
+ value?: unknown;
47
+ sourceShape: ValidationShape;
48
+ sourceConstraint: ValidationConstraint;
49
+ message: string;
50
+ severity: Severity;
51
+ }
52
+ export interface ValidationPluginConfig {
53
+ shapes: ValidationShape[];
54
+ }
55
+ export declare function validation(configurator: (schema: Schema) => ValidationPluginConfig): ValidationPlugin;
56
+ interface ShapeContext {
57
+ shape: ValidationShape;
58
+ focusNode: PNode;
59
+ count: number;
60
+ path: PNode[];
61
+ }
62
+ export {};
@@ -0,0 +1,10 @@
1
+ import { EditorState, Transaction } from '@lblod/ember-rdfa-editor';
2
+ /**
3
+ * Validate a given transaction against a given set of shapes. Returns true when the
4
+ * state after applying the transaction is valid according to all given shapes,
5
+ * false otherwise.
6
+ * @param state the state the transaction was created from
7
+ * @param tr
8
+ * @param validateShapes
9
+ */
10
+ export declare function transactionCompliesWithShapes(state: EditorState, tr: Transaction, validateShapes?: Set<string>): boolean;
@@ -0,0 +1,5 @@
1
+ export type TemplateVariablePluginOptions = {
2
+ endpoint: string;
3
+ zonalLocationCodelistUri: string;
4
+ nonZonalLocationCodelistUri: string;
5
+ };