@lblod/ember-rdfa-editor-lblod-plugins 9.1.0 → 10.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 (104) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/README.md +159 -131
  3. package/addon/components/citation-plugin/helpers/alert-load-error.hbs +2 -2
  4. package/addon/components/import-snippet-plugin/card.hbs +11 -5
  5. package/addon/components/rdfa-date-plugin/help-modal.hbs +12 -0
  6. package/addon/components/roadsign-regulation-plugin/expanded-measure.hbs +40 -10
  7. package/addon/components/roadsign-regulation-plugin/expanded-measure.ts +1 -0
  8. package/addon/components/roadsign-regulation-plugin/measure-template.ts +6 -12
  9. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +1 -1
  10. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.hbs +5 -5
  11. package/addon/components/roadsign-regulation-plugin/roadsigns-pagination.hbs +4 -4
  12. package/addon/components/roadsign-regulation-plugin/roadsigns-table.hbs +25 -9
  13. package/addon/components/snippet-plugin/helpers/alert-load-error.hbs +2 -2
  14. package/addon/components/snippet-plugin/snippet-insert.ts +13 -11
  15. package/addon/components/template-comments-plugin/edit-card.hbs +7 -9
  16. package/addon/components/template-comments-plugin/template-comment.hbs +2 -2
  17. package/addon/components/template-comments-plugin/template-comment.ts +0 -36
  18. package/addon/components/variable-plugin/{template-variable-card.hbs → codelist/edit.hbs} +14 -12
  19. package/addon/components/variable-plugin/codelist/edit.ts +94 -0
  20. package/addon/components/variable-plugin/codelist/insert.hbs +22 -0
  21. package/addon/components/variable-plugin/codelist/insert.ts +84 -0
  22. package/addon/components/variable-plugin/date/insert.hbs +9 -0
  23. package/addon/components/variable-plugin/date/insert.ts +45 -0
  24. package/addon/components/variable-plugin/insert-variable-card.hbs +7 -40
  25. package/addon/components/variable-plugin/insert-variable-card.ts +18 -166
  26. package/addon/components/variable-plugin/location/edit.hbs +40 -0
  27. package/addon/components/variable-plugin/location/edit.ts +122 -0
  28. package/addon/components/variable-plugin/location/insert.hbs +9 -0
  29. package/addon/components/variable-plugin/location/insert.ts +65 -0
  30. package/addon/components/variable-plugin/{number-settings.hbs → number/insert.hbs} +14 -5
  31. package/addon/components/variable-plugin/number/insert.ts +78 -0
  32. package/addon/components/{variable-number/number.ts → variable-plugin/number/nodeview.ts} +3 -7
  33. package/addon/components/variable-plugin/text/insert.hbs +9 -0
  34. package/addon/components/variable-plugin/text/insert.ts +49 -0
  35. package/addon/components/variable-plugin/utils/label-input.hbs +11 -0
  36. package/addon/components/variable-plugin/{variable.ts → variable/nodeview.ts} +1 -1
  37. package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +1 -1
  38. package/addon/plugins/rdfa-date-plugin/nodes/date.ts +48 -51
  39. package/addon/plugins/snippet-plugin/utils/fetch-data.ts +10 -2
  40. package/addon/plugins/template-comments-plugin/index.ts +1 -5
  41. package/addon/plugins/template-comments-plugin/node.ts +3 -16
  42. package/addon/plugins/variable-plugin/utils/attribute-parsers.ts +31 -0
  43. package/addon/plugins/variable-plugin/utils/codelist-utils.ts +56 -0
  44. package/addon/plugins/variable-plugin/utils/constants.ts +0 -120
  45. package/addon/plugins/variable-plugin/utils/dom-constructors.ts +66 -0
  46. package/addon/plugins/variable-plugin/utils/fetch-data.ts +2 -2
  47. package/addon/plugins/variable-plugin/variables/codelist.ts +120 -0
  48. package/addon/plugins/variable-plugin/variables/index.ts +4 -0
  49. package/addon/plugins/variable-plugin/variables/location.ts +98 -0
  50. package/addon/plugins/variable-plugin/variables/number.ts +145 -0
  51. package/addon/plugins/variable-plugin/variables/text.ts +90 -0
  52. package/addon/utils/dom-output-spec-helpers.ts +8 -0
  53. package/app/components/variable-plugin/{number-settings.js → codelist/edit.js} +1 -1
  54. package/app/components/variable-plugin/{variable-edit-modal.js → codelist/insert.js} +1 -1
  55. package/app/components/{variable-number/number.js → variable-plugin/date/insert.js} +1 -1
  56. package/app/components/variable-plugin/location/edit.js +1 -0
  57. package/app/components/variable-plugin/location/insert.js +1 -0
  58. package/app/components/variable-plugin/number/insert.js +1 -0
  59. package/app/components/variable-plugin/number/nodeview.js +1 -0
  60. package/app/components/variable-plugin/{variable.js → text/insert.js} +1 -1
  61. package/app/components/variable-plugin/utils/label-input.js +1 -0
  62. package/app/components/variable-plugin/variable/nodeview.js +1 -0
  63. package/app/styles/snippet-plugin.scss +7 -1
  64. package/components/roadsign-regulation-plugin/expanded-measure.d.ts +1 -0
  65. package/components/roadsign-regulation-plugin/measure-template.d.ts +2 -4
  66. package/components/snippet-plugin/snippet-insert.d.ts +2 -1
  67. package/components/template-comments-plugin/template-comment.d.ts +0 -8
  68. package/components/variable-plugin/codelist/edit.d.ts +27 -0
  69. package/components/variable-plugin/codelist/insert.d.ts +26 -0
  70. package/components/variable-plugin/date/insert.d.ts +13 -0
  71. package/components/variable-plugin/insert-variable-card.d.ts +10 -34
  72. package/components/variable-plugin/location/edit.d.ts +31 -0
  73. package/components/variable-plugin/location/insert.d.ts +20 -0
  74. package/components/variable-plugin/number/insert.d.ts +18 -0
  75. package/components/{variable-number/number.d.ts → variable-plugin/number/nodeview.d.ts} +1 -1
  76. package/components/variable-plugin/text/insert.d.ts +13 -0
  77. package/components/variable-plugin/{variable.d.ts → variable/nodeview.d.ts} +1 -1
  78. package/package.json +2 -2
  79. package/plugins/template-comments-plugin/index.d.ts +1 -1
  80. package/plugins/template-comments-plugin/node.d.ts +0 -4
  81. package/plugins/variable-plugin/utils/attribute-parsers.d.ts +5 -0
  82. package/plugins/variable-plugin/utils/codelist-utils.d.ts +6 -0
  83. package/plugins/variable-plugin/utils/constants.d.ts +0 -19
  84. package/plugins/variable-plugin/utils/dom-constructors.d.ts +24 -0
  85. package/plugins/variable-plugin/utils/fetch-data.d.ts +1 -1
  86. package/plugins/variable-plugin/variables/codelist.d.ts +2 -0
  87. package/plugins/variable-plugin/variables/index.d.ts +4 -0
  88. package/plugins/variable-plugin/variables/location.d.ts +2 -0
  89. package/plugins/variable-plugin/variables/text.d.ts +4 -0
  90. package/translations/en-US.yaml +46 -0
  91. package/translations/nl-BE.yaml +46 -0
  92. package/types/global.d.ts +3 -0
  93. package/utils/dom-output-spec-helpers.d.ts +2 -0
  94. package/addon/components/variable-plugin/template-variable-card.ts +0 -163
  95. package/addon/plugins/variable-plugin/index.ts +0 -5
  96. package/addon/plugins/variable-plugin/nodes.ts +0 -264
  97. package/addon/plugins/variable-plugin/number.ts +0 -50
  98. package/app/components/variable-plugin/template-variable-card.js +0 -1
  99. package/components/variable-plugin/template-variable-card.d.ts +0 -29
  100. package/plugins/variable-plugin/index.d.ts +0 -5
  101. package/plugins/variable-plugin/nodes.d.ts +0 -37
  102. /package/addon/components/{variable-number/number.hbs → variable-plugin/number/nodeview.hbs} +0 -0
  103. /package/addon/components/variable-plugin/{variable.hbs → variable/nodeview.hbs} +0 -0
  104. /package/plugins/variable-plugin/{number.d.ts → variables/number.d.ts} +0 -0
@@ -1,46 +1,22 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { SayController } from '@lblod/ember-rdfa-editor';
3
- import { VariableType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/constants';
4
- import { CodeList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/fetch-data';
5
3
  import IntlService from 'ember-intl/services/intl';
6
- type Args = {
7
- controller: SayController;
8
- options: {
9
- publisher: string;
10
- variableTypes: (VariableType | string)[];
11
- defaultEndpoint: string;
4
+ export type VariableConfig = {
5
+ label: string;
6
+ component: {
7
+ path: string;
8
+ options?: unknown;
12
9
  };
13
10
  };
14
- type minMaxObj = {
15
- minimumValue?: number;
16
- maximumValue?: number;
11
+ type Args = {
12
+ controller: SayController;
13
+ variableTypes: VariableConfig[];
17
14
  };
18
- declare class ExtraAttributes {
19
- minimumValue: string;
20
- maximumValue: string;
21
- asObject(): minMaxObj;
22
- reset(): void;
23
- }
24
15
  export default class EditorPluginsInsertCodelistCardComponent extends Component<Args> {
25
- variablesArray: VariableType[];
26
- selectedVariable?: VariableType;
27
- hasSubtype: boolean;
28
- selectedSubtype?: CodeList;
29
- subtypes?: CodeList[];
30
- variableLabel?: string;
31
- extraAttributes: ExtraAttributes;
32
- publisher: string;
33
- endpoint: string;
16
+ selectedVariable?: VariableConfig;
34
17
  intl: IntlService;
35
- constructor(parent: unknown, args: Args);
36
18
  get controller(): SayController;
37
- get numberVariableError(): string;
38
- updateVariableLabel(event: InputEvent): void;
39
- insert(): void;
40
- updateSelectedVariable(variable: VariableType): void;
41
- fetchSubtypes: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, (fetchFunction: (endpoint: string, publisher: string) => Promise<CodeList[]>) => Promise<void>>;
42
- updateSubtype(subtype: CodeList): void;
43
- get type(): string | undefined;
19
+ updateSelectedVariable(variable: VariableConfig): void;
44
20
  get showCard(): boolean;
45
21
  }
46
22
  export {};
@@ -0,0 +1,31 @@
1
+ import Component from '@glimmer/component';
2
+ import { SayController } from '@lblod/ember-rdfa-editor';
3
+ import { CodeListOption } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/fetch-data';
4
+ export type LocationEditOptions = {
5
+ endpoint: string;
6
+ zonalLocationCodelistUri: string;
7
+ nonZonalLocationCodelistUri: string;
8
+ };
9
+ type Args = {
10
+ controller: SayController;
11
+ options: LocationEditOptions;
12
+ };
13
+ export default class LocationEditComponent extends Component<Args> {
14
+ selectedLocationOption?: CodeListOption | CodeListOption[];
15
+ get controller(): SayController;
16
+ get options(): LocationEditOptions;
17
+ insert(): void;
18
+ get selectedLocation(): {
19
+ node: import("prosemirror-model").Node;
20
+ pos: number;
21
+ } | undefined;
22
+ get showCard(): boolean;
23
+ get source(): string;
24
+ get label(): string | undefined;
25
+ get isZonal(): boolean;
26
+ locationOptions: import("ember-resources/util/function").State<Promise<import("@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/fetch-data").CodeListOptions>>;
27
+ get multiSelect(): boolean;
28
+ updateLocationOption(locationOption: CodeListOption | CodeListOption[]): void;
29
+ wrapInLocation(value: string): string;
30
+ }
31
+ export {};
@@ -0,0 +1,20 @@
1
+ import Component from '@glimmer/component';
2
+ import { SayController } from '@lblod/ember-rdfa-editor';
3
+ import IntlService from 'ember-intl/services/intl';
4
+ export type LocationInsertOptions = {
5
+ endpoint: string;
6
+ };
7
+ type Args = {
8
+ controller: SayController;
9
+ options: LocationInsertOptions;
10
+ };
11
+ export default class LocationInsertComponent extends Component<Args> {
12
+ label?: string;
13
+ intl: IntlService;
14
+ get controller(): SayController;
15
+ get schema(): import("prosemirror-model").Schema<any, any>;
16
+ get endpoint(): string;
17
+ updateLabel(event: InputEvent): void;
18
+ insert(): void;
19
+ }
20
+ export {};
@@ -0,0 +1,18 @@
1
+ import Component from '@glimmer/component';
2
+ import { SayController } from '@lblod/ember-rdfa-editor';
3
+ import IntlService from 'ember-intl/services/intl';
4
+ type Args = {
5
+ controller: SayController;
6
+ };
7
+ export default class NumberInsertComponent extends Component<Args> {
8
+ intl: IntlService;
9
+ label?: string;
10
+ minimumValue: string;
11
+ maximumValue: string;
12
+ get controller(): SayController;
13
+ get schema(): import("prosemirror-model").Schema<any, any>;
14
+ get numberVariableError(): string;
15
+ updateLabel(event: InputEvent): void;
16
+ insert(): void;
17
+ }
18
+ export {};
@@ -10,7 +10,7 @@ type Args = {
10
10
  selected: boolean;
11
11
  contentDecorations?: DecorationSource;
12
12
  };
13
- export default class VariableNumberPluginNumberComponent extends Component<Args> {
13
+ export default class NumberNodeviewComponent extends Component<Args> {
14
14
  inputNumber: string;
15
15
  writtenNumber: boolean;
16
16
  intl: intlService;
@@ -0,0 +1,13 @@
1
+ import Component from '@glimmer/component';
2
+ import { SayController } from '@lblod/ember-rdfa-editor';
3
+ type Args = {
4
+ controller: SayController;
5
+ };
6
+ export default class TextVariableInsertComponent extends Component<Args> {
7
+ label?: string;
8
+ get controller(): SayController;
9
+ get schema(): import("prosemirror-model").Schema<any, any>;
10
+ updateLabel(event: InputEvent): void;
11
+ insert(): void;
12
+ }
13
+ export {};
@@ -3,7 +3,7 @@ import { SayController, SayView } from '@lblod/ember-rdfa-editor';
3
3
  type Args = {
4
4
  controller: SayController;
5
5
  };
6
- export default class VariableComponent extends Component<Args> {
6
+ export default class VariableNodeViewComponent extends Component<Args> {
7
7
  innerView?: SayView;
8
8
  onClick(): void;
9
9
  initEditor(view: SayView): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "9.1.0",
3
+ "version": "10.0.0",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -66,7 +66,7 @@
66
66
  "@appuniversum/ember-appuniversum": "^2.4.2",
67
67
  "@ember/optional-features": "^2.0.0",
68
68
  "@ember/test-helpers": "^2.8.1",
69
- "@embroider/test-setup": "^1.8.3",
69
+ "@embroider/test-setup": "^3.0.1",
70
70
  "@glimmer/component": "^1.1.2",
71
71
  "@glimmer/tracking": "^1.1.2",
72
72
  "@lblod/ember-rdfa-editor": "^4.2.0",
@@ -1 +1 @@
1
- export { templateComment, templateCommentView, templateCommentNodes, } from './node';
1
+ export { templateComment, templateCommentView } from './node';
@@ -2,7 +2,3 @@ import { EmberNodeConfig } from '@lblod/ember-rdfa-editor/utils/ember-node';
2
2
  export declare const emberNodeConfig: () => EmberNodeConfig;
3
3
  export declare const templateComment: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
4
4
  export declare const templateCommentView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("prosemirror-view").NodeViewConstructor;
5
- export declare const templateCommentNodes: {
6
- templateComment: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
7
- templateCommentParagraph: import("prosemirror-model").NodeSpec;
8
- };
@@ -0,0 +1,5 @@
1
+ export declare function isVariable(element: HTMLElement): boolean;
2
+ export declare function parseVariableType(variableNode: HTMLElement): string | null | undefined;
3
+ export declare function parseVariableInstance(variableNode: HTMLElement): string | null | undefined;
4
+ export declare function parseLabel(variableNode: HTMLElement): string | null;
5
+ export declare function parseVariableSource(variableNode: HTMLElement): string | null | undefined;
@@ -0,0 +1,6 @@
1
+ import { CodeListOption } from './fetch-data';
2
+ import { PNode, SayController } from '@lblod/ember-rdfa-editor';
3
+ export declare function updateCodelistVariable(selectedCodelist: {
4
+ node: PNode;
5
+ pos: number;
6
+ }, selectedOption: CodeListOption | CodeListOption[], controller: SayController): void;
@@ -1,20 +1 @@
1
- import { Attrs, PNode, Schema } from '@lblod/ember-rdfa-editor';
2
- import { CodeList } from './fetch-data';
3
1
  export declare const MULTI_SELECT_CODELIST_TYPE = "http://lblod.data.gift/concepts/57C93E12-A02C-4D4B-8B95-666B6701286C";
4
- export type VariableType = {
5
- label: string;
6
- fetchSubtypes?: (endpoint: string, publisher: string) => Promise<CodeList[]>;
7
- constructor: (props: {
8
- schema: Schema;
9
- label?: string;
10
- attributes?: Attrs;
11
- codelist?: CodeList;
12
- }) => PNode;
13
- };
14
- export declare const DEFAULT_VARIABLE_TYPES: Record<string, VariableType>;
15
- export declare const MINIMUM_VALUE_PNODE_KEY = "minimumValue";
16
- export declare const MAXIMUM_VALUE_PNODE_KEY = "maximumValue";
17
- export declare const WRITTEN_NUMBER_PNODE_KEY = "writtenNumber";
18
- export declare const MINIMUM_VALUE_HTML_ATTRIBUTE_KEY = "data-minimum-value";
19
- export declare const MAXIMUM_VALUE_HTML_ATTRIBUTE_KEY = "data-maximum-value";
20
- export declare const WRITTEN_NUMBER_HTML_ATTRIBUTE_KEY = "data-written-number";
@@ -0,0 +1,24 @@
1
+ type Attributes = Record<string, unknown>;
2
+ type Children = unknown[];
3
+ /**
4
+ * Constructs a variable mapping span based on a mapping resource.
5
+ * This function also accepts additional attributes which are added to the span attributes, and a series of children.
6
+ */
7
+ export declare const mappingSpan: (mapping: string, attributes: Attributes, ...children: Children) => import("prosemirror-model").DOMOutputSpec;
8
+ /**
9
+ * Constructs a variable instance span based on a variable-instance resource.
10
+ */
11
+ export declare const instanceSpan: (variableInstance: string) => import("prosemirror-model").DOMOutputSpec;
12
+ /**
13
+ * Constructs a variable type span based on a variable type.
14
+ */
15
+ export declare const typeSpan: (variableType: string) => import("prosemirror-model").DOMOutputSpec;
16
+ /**
17
+ * Constructs a variable source span based on a variable source.
18
+ */
19
+ export declare const sourceSpan: (variableSource: string) => import("prosemirror-model").DOMOutputSpec;
20
+ /**
21
+ * Constructs a variable content span. Accepts optional additional attributes and a series of children.
22
+ */
23
+ export declare const contentSpan: (attributes: Attributes, ...children: Children) => import("prosemirror-model").DOMOutputSpec;
24
+ export {};
@@ -11,4 +11,4 @@ export type CodeList = {
11
11
  uri?: string;
12
12
  label?: string;
13
13
  };
14
- export declare function fetchCodeListsByPublisher(endpoint: string, publisher: string): Promise<CodeList[]>;
14
+ export declare function fetchCodeListsByPublisher(endpoint: string, publisher?: string): Promise<CodeList[]>;
@@ -0,0 +1,2 @@
1
+ export declare const codelist: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
2
+ export declare const codelistView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("prosemirror-view").NodeViewConstructor;
@@ -0,0 +1,4 @@
1
+ export * from './number';
2
+ export * from './text';
3
+ export * from './codelist';
4
+ export * from './location';
@@ -0,0 +1,2 @@
1
+ export declare const location: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
2
+ export declare const locationView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("prosemirror-view").NodeViewConstructor;
@@ -0,0 +1,4 @@
1
+ import { EmberNodeConfig } from '@lblod/ember-rdfa-editor/utils/ember-node';
2
+ export declare const emberNodeConfig: EmberNodeConfig;
3
+ export declare const text_variable: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
4
+ export declare const textVariableView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("prosemirror-view").NodeViewConstructor;
@@ -266,3 +266,49 @@ pagination:
266
266
  previous: Previous page
267
267
  of: of
268
268
  results: Results
269
+
270
+ editor-plugins:
271
+ roadsign-regulation:
272
+ expanded-measure:
273
+ insert-measure: "Insert measure:"
274
+ select-zonality:
275
+ label: "Select zonal validity:"
276
+ zonal: Zonal
277
+ non-zonal: Non zonal
278
+ varying-signalisation:
279
+ label: Varying signalisation
280
+ varying: Varying
281
+ non-varying: Non varying
282
+ card:
283
+ insert-measure: Insert traffic measure
284
+ modal:
285
+ title: Insert traffic measure
286
+ filter:
287
+ type: Filter on type
288
+ code: Filter on code
289
+ zonal-validity: Filter op zonal validity
290
+ combine-with-code: Combine with code
291
+ pagination:
292
+ publications: Publications
293
+ table:
294
+ header:
295
+ code: Code
296
+ image: Image
297
+ template: Template
298
+ category: Category
299
+ content:
300
+ image:
301
+ alt: traffic sign {code}
302
+ no-data-message: No measures could be found.
303
+ import-snippet:
304
+ card:
305
+ title: Import document
306
+ body:
307
+ document-available: There is a <a href="{source}" target="_blank" rel="noopener noreferrer">document</a> available.
308
+ confirmation: Do you wish to insert this document?
309
+ insert-attachment: Insert attachment
310
+ insert-document: Insert document
311
+ utils:
312
+ insert: Insert
313
+ cancel: Cancel
314
+ loading: Loading
@@ -269,3 +269,49 @@ pagination:
269
269
  previous: Vorige pagina
270
270
  of: van
271
271
  results: Resultaten
272
+
273
+ editor-plugins:
274
+ roadsign-regulation:
275
+ expanded-measure:
276
+ insert-measure: "Voeg maatregel in:"
277
+ select-zonality:
278
+ label: "Selecteer zonale geldigheid:"
279
+ zonal: Zonaal
280
+ non-zonal: Niet zonaal
281
+ varying-signalisation:
282
+ label: Variabele signalisatie
283
+ varying: Variabel
284
+ non-varying: Niet variabel
285
+ card:
286
+ insert-measure: Voeg mobiliteitsmaatregel in
287
+ modal:
288
+ title: Mobiliteitsmaatregel toevoegen
289
+ filter:
290
+ type: Filter op type
291
+ code: Filter op code
292
+ zonal-validity: Filter op zonale geldigheid
293
+ combine-with-code: Combineer met code
294
+ pagination:
295
+ publications: Publicaties
296
+ table:
297
+ header:
298
+ code: Code
299
+ image: Afbeelding
300
+ template: Template
301
+ category: Categorie
302
+ content:
303
+ image:
304
+ alt: verkeersteken {code}
305
+ no-data-message: Er werden geen maatregelen gevonden.
306
+ import-snippet:
307
+ card:
308
+ title: Document importeren
309
+ body:
310
+ document-available: Er is een <a href="{source}" target="_blank" rel="noopener noreferrer">document</a> beschikbaar.
311
+ confirmation: Wenst u dit document in te voegen?
312
+ insert-attachment: Bijlage invoegen
313
+ insert-document: Document invoegen
314
+ utils:
315
+ insert: Voeg in
316
+ cancel: Annuleer
317
+ loading: Aan het laden
package/types/global.d.ts CHANGED
@@ -17,4 +17,7 @@ declare module 'tracked-toolbox' {
17
17
  memo: UsefulPropsOf<C>,
18
18
  initializer?: T | (() => T),
19
19
  ): PropertyDecorator;
20
+ export function trackedReset<C extends Component = Component>(
21
+ memo: UsefulPropsOf<C>,
22
+ ): PropertyDecorator;
20
23
  }
@@ -0,0 +1,2 @@
1
+ import { DOMOutputSpec } from '@lblod/ember-rdfa-editor';
2
+ export declare const span: (attributes?: Record<string, unknown>, ...children: unknown[]) => DOMOutputSpec;
@@ -1,163 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { tracked } from '@glimmer/tracking';
3
- import { action } from '@ember/object';
4
- import { task } from 'ember-concurrency';
5
- import { SayController } from '@lblod/ember-rdfa-editor';
6
- import {
7
- CodeListOption,
8
- fetchCodeListOptions,
9
- } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/fetch-data';
10
- import { MULTI_SELECT_CODELIST_TYPE } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/constants';
11
- import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
12
- import { NodeSelection, PNode, ProseParser } from '@lblod/ember-rdfa-editor';
13
- import { ZONAL_URI } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/utils/constants';
14
- import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
15
- import { TemplateVariablePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin';
16
-
17
- type Args = {
18
- controller: SayController;
19
- options: TemplateVariablePluginOptions;
20
- };
21
- export default class EditorPluginsTemplateVariableCardComponent extends Component<Args> {
22
- @tracked variableOptions: CodeListOption[] = [];
23
- @tracked selectedVariableOption?: CodeListOption | CodeListOption[];
24
- @tracked selectedVariable: { pos: number; node: PNode } | undefined;
25
- @tracked showCard = false;
26
- @tracked multiSelect = false;
27
- @tracked label?: string;
28
- mappingUri?: string;
29
-
30
- get controller() {
31
- return this.args.controller;
32
- }
33
-
34
- @action
35
- insert() {
36
- if (!this.selectedVariable || !this.selectedVariableOption) {
37
- return;
38
- }
39
- let htmlToInsert: string;
40
- if (Array.isArray(this.selectedVariableOption)) {
41
- htmlToInsert = this.selectedVariableOption
42
- .map((variable) => variable.value)
43
- .join(', ');
44
- } else {
45
- htmlToInsert = unwrap(this.selectedVariableOption.value);
46
- }
47
- htmlToInsert = this.wrapVariableInHighlight(htmlToInsert);
48
- const domParser = new DOMParser();
49
- const htmlNode = domParser.parseFromString(htmlToInsert, 'text/html');
50
- const contentFragment = ProseParser.fromSchema(
51
- this.args.controller.schema,
52
- ).parseSlice(htmlNode, {
53
- preserveWhitespace: false,
54
- }).content;
55
- const range = {
56
- from: this.selectedVariable.pos + 1,
57
- to: this.selectedVariable.pos + this.selectedVariable.node.nodeSize - 1,
58
- };
59
- this.controller.withTransaction(
60
- (tr) => {
61
- return tr.replaceWith(range.from, range.to, contentFragment);
62
- },
63
- { view: this.controller.mainEditorView },
64
- );
65
- }
66
-
67
- wrapVariableInHighlight(text: string) {
68
- return text.replace(
69
- /\$\{(.+?)\}/g,
70
- '<span class="mark-highlight-manual">${$1}</span>',
71
- );
72
- }
73
-
74
- @action
75
- selectionChanged() {
76
- this.showCard = false;
77
- this.selectedVariableOption = undefined;
78
- const { selection } = this.controller.mainEditorState;
79
- if (
80
- selection instanceof NodeSelection &&
81
- selection.node.type === this.controller.schema.nodes.variable
82
- ) {
83
- const variable = {
84
- node: selection.node,
85
- pos: selection.from,
86
- };
87
- this.selectedVariable = variable;
88
- if (variable) {
89
- const type = variable.node.attrs.type as string;
90
- if (type === 'codelist') {
91
- const source =
92
- (variable.node.attrs.source as string | undefined) ??
93
- this.args.options.endpoint;
94
- const codelistURI = variable.node.attrs.codelistResource as string;
95
- void this.fetchCodeListOptions.perform(source, codelistURI);
96
- this.showCard = true;
97
- this.label = variable.node.attrs.label as string;
98
- } else if (type === 'location') {
99
- const source =
100
- (variable.node.attrs.source as string | undefined) ??
101
- this.args.options.endpoint;
102
- const roadSignRegulation = findParentNodeOfType(
103
- this.controller.schema.nodes.roadsign_regulation,
104
- )(selection);
105
- const zonalityUri = roadSignRegulation?.node.attrs.zonality as
106
- | string
107
- | undefined;
108
- this.label = variable.node.attrs.label as string;
109
- if (zonalityUri === ZONAL_URI) {
110
- void this.fetchCodeListOptions.perform(
111
- source,
112
- this.args.options.zonalLocationCodelistUri,
113
- true,
114
- );
115
- } else {
116
- void this.fetchCodeListOptions.perform(
117
- source,
118
- this.args.options.nonZonalLocationCodelistUri,
119
- true,
120
- );
121
- }
122
-
123
- this.showCard = true;
124
- }
125
- }
126
- }
127
- }
128
-
129
- @action
130
- updateVariableOption(variableOption: CodeListOption | CodeListOption[]) {
131
- this.selectedVariableOption = variableOption;
132
- }
133
-
134
- fetchCodeListOptions = task(
135
- async (endpoint: string, codelistUri: string, isLocation?: boolean) => {
136
- const { type, options } = await fetchCodeListOptions(
137
- endpoint,
138
- codelistUri,
139
- );
140
- if (isLocation) {
141
- this.variableOptions = options.map((option) => ({
142
- label: option.label,
143
- value: this.wrapInLocation(unwrap(option.value)),
144
- }));
145
- } else {
146
- this.variableOptions = options;
147
- }
148
- if (type === MULTI_SELECT_CODELIST_TYPE) {
149
- this.multiSelect = true;
150
- } else {
151
- this.multiSelect = false;
152
- }
153
- },
154
- );
155
-
156
- wrapInLocation(value: string) {
157
- return `
158
- <span property="https://data.vlaanderen.be/ns/mobiliteit#plaatsbepaling">
159
- ${value}
160
- </span>
161
- `;
162
- }
163
- }
@@ -1,5 +0,0 @@
1
- export type TemplateVariablePluginOptions = {
2
- endpoint: string;
3
- zonalLocationCodelistUri: string;
4
- nonZonalLocationCodelistUri: string;
5
- };