@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,264 +0,0 @@
1
- import { hasRDFaAttribute } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
2
- import {
3
- DCT,
4
- EXT,
5
- } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
6
- import {
7
- createEmberNodeSpec,
8
- createEmberNodeView,
9
- EmberNodeConfig,
10
- } from '@lblod/ember-rdfa-editor/utils/ember-node';
11
- import { v4 as uuidv4 } from 'uuid';
12
- import {
13
- MAXIMUM_VALUE_HTML_ATTRIBUTE_KEY,
14
- MAXIMUM_VALUE_PNODE_KEY,
15
- MINIMUM_VALUE_HTML_ATTRIBUTE_KEY,
16
- MINIMUM_VALUE_PNODE_KEY,
17
- WRITTEN_NUMBER_HTML_ATTRIBUTE_KEY,
18
- WRITTEN_NUMBER_PNODE_KEY,
19
- } from './utils/constants';
20
- import { Attrs, DOMOutputSpec, PNode } from '@lblod/ember-rdfa-editor';
21
- import { isNumber } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
22
- import { numberToWords } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/number-to-words';
23
-
24
- export const CONTENT_SELECTOR = `span[property~='${EXT('content').prefixed}'],
25
- span[property~='${EXT('content').full}']`;
26
-
27
- export const getHTMLNodeExtraAttributes = ({
28
- node,
29
- type,
30
- }: {
31
- node: HTMLElement;
32
- type: string;
33
- }) => {
34
- if (type === 'number') {
35
- return {
36
- [MINIMUM_VALUE_PNODE_KEY]:
37
- node.getAttribute(MINIMUM_VALUE_HTML_ATTRIBUTE_KEY) ?? null,
38
- [MAXIMUM_VALUE_PNODE_KEY]:
39
- node.getAttribute(MAXIMUM_VALUE_HTML_ATTRIBUTE_KEY) ?? null,
40
- [WRITTEN_NUMBER_PNODE_KEY]:
41
- node.getAttribute(WRITTEN_NUMBER_HTML_ATTRIBUTE_KEY) === 'true'
42
- ? true
43
- : false,
44
- };
45
- }
46
-
47
- return {};
48
- };
49
-
50
- export const getPNodeExtraAttributes = ({
51
- node,
52
- type,
53
- }: {
54
- node: PNode;
55
- type: string;
56
- }) => {
57
- if (type === 'number') {
58
- return {
59
- [MINIMUM_VALUE_HTML_ATTRIBUTE_KEY]:
60
- (node.attrs[MINIMUM_VALUE_PNODE_KEY] as string) ?? null,
61
- [MAXIMUM_VALUE_HTML_ATTRIBUTE_KEY]:
62
- (node.attrs[MAXIMUM_VALUE_PNODE_KEY] as string) ?? null,
63
- [WRITTEN_NUMBER_HTML_ATTRIBUTE_KEY]: String(
64
- node.attrs[WRITTEN_NUMBER_PNODE_KEY] ?? false,
65
- ),
66
- };
67
- }
68
-
69
- return {};
70
- };
71
-
72
- export const contentToDom = ({
73
- content,
74
- type,
75
- node,
76
- }: {
77
- content: string | null;
78
- type: string;
79
- node: PNode;
80
- }) => {
81
- if (type === 'number') {
82
- if (isNumber(content)) {
83
- if (node.attrs[WRITTEN_NUMBER_PNODE_KEY]) {
84
- return numberToWords(Number(content), { lang: 'nl' });
85
- } else {
86
- return content;
87
- }
88
- } else {
89
- return 'Voeg getal in';
90
- }
91
- } else {
92
- return content;
93
- }
94
- };
95
-
96
- export const parseAttributes = (node: HTMLElement): false | Attrs => {
97
- if (
98
- hasRDFaAttribute(node, 'typeof', EXT('Mapping')) &&
99
- node.querySelector(CONTENT_SELECTOR)
100
- ) {
101
- const variableInstance = [...node.children]
102
- .find((el) => hasRDFaAttribute(el, 'property', EXT('instance')))
103
- ?.getAttribute('resource');
104
- const mappingResource = node.getAttribute('resource');
105
- const codelistSpan = [...node.children].find((el) =>
106
- hasRDFaAttribute(el, 'property', EXT('codelist')),
107
- );
108
- const codelistResource =
109
- codelistSpan?.getAttribute('resource') ??
110
- codelistSpan?.getAttribute('content');
111
- const source = [...node.children]
112
- .find((el) => hasRDFaAttribute(el, 'property', DCT('source')))
113
- ?.getAttribute('resource');
114
- const type = [...node.children]
115
- .find((el) => hasRDFaAttribute(el, 'property', DCT('type')))
116
- ?.getAttribute('content');
117
- const label = node.getAttribute('data-label') || type;
118
- const datatype = [...node.children]
119
- .find((el) => hasRDFaAttribute(el, 'property', EXT('content')))
120
- ?.getAttribute('datatype');
121
- if (!mappingResource || !type) {
122
- return false;
123
- }
124
- return {
125
- variableInstance:
126
- variableInstance ?? `http://data.lblod.info/variables/${uuidv4()}`,
127
- mappingResource,
128
- codelistResource,
129
- source,
130
- type,
131
- datatype,
132
- label,
133
- ...getHTMLNodeExtraAttributes({ type, node }),
134
- };
135
- }
136
-
137
- return false;
138
- };
139
-
140
- export const attributesToDOM = (
141
- node: PNode,
142
- content?: string | null,
143
- ): DOMOutputSpec => {
144
- const {
145
- mappingResource,
146
- codelistResource,
147
- variableInstance,
148
- type,
149
- datatype,
150
- source,
151
- label,
152
- } = node.attrs;
153
-
154
- const sourceSpan = source
155
- ? [
156
- [
157
- 'span',
158
- {
159
- property: DCT('source').prefixed,
160
- resource: source as string,
161
- },
162
- ],
163
- ]
164
- : [];
165
- const codelistResourceSpan = codelistResource
166
- ? [
167
- [
168
- 'span',
169
- {
170
- property: EXT('codelist').prefixed, //becomes EXT('instance')
171
- resource: codelistResource as string,
172
- },
173
- ],
174
- ]
175
- : [];
176
- return [
177
- 'span',
178
- {
179
- resource: mappingResource as string,
180
- typeof: EXT('Mapping').prefixed,
181
- 'data-label': label as string,
182
- ...getPNodeExtraAttributes({ node, type: type as string }),
183
- },
184
- [
185
- 'span',
186
- { property: EXT('instance'), resource: variableInstance as string },
187
- ],
188
- ['span', { property: DCT('type').prefixed, content: type as string }],
189
- ...sourceSpan,
190
- ...codelistResourceSpan,
191
- [
192
- 'span',
193
- {
194
- property: EXT('content').prefixed,
195
- content: content ? content : '',
196
- ...(!!datatype && { datatype: datatype as string }),
197
- },
198
- content !== undefined
199
- ? contentToDom({ content, type: type as string, node })
200
- : 0,
201
- ],
202
- ];
203
- };
204
-
205
- export const emberNodeConfig: EmberNodeConfig = {
206
- name: 'variable',
207
- componentPath: 'variable-plugin/variable',
208
- inline: true,
209
- group: 'inline',
210
- content: 'inline*',
211
- atom: true,
212
- recreateUri: true,
213
- uriAttributes: ['variableInstance'],
214
- draggable: false,
215
- needsFFKludge: true,
216
- attrs: {
217
- mappingResource: {},
218
- codelistResource: {
219
- default: null,
220
- },
221
- variableInstance: {},
222
- source: {
223
- default: null,
224
- },
225
- type: {
226
- default: 'text',
227
- },
228
- datatype: {
229
- default: null,
230
- },
231
- label: {
232
- default: '',
233
- },
234
- minimumValue: {
235
- default: null,
236
- },
237
- maximumValue: {
238
- default: null,
239
- },
240
- writtenNumber: {
241
- default: false,
242
- },
243
- },
244
- toDOM: (node) => {
245
- return attributesToDOM(node);
246
- },
247
- parseDOM: [
248
- {
249
- tag: 'span',
250
- getAttrs: (node: HTMLElement) => {
251
- const attr = parseAttributes(node);
252
- if (attr && attr.type !== 'number') {
253
- return attr;
254
- } else {
255
- return false;
256
- }
257
- },
258
- contentElement: CONTENT_SELECTOR,
259
- },
260
- ],
261
- };
262
-
263
- export const variable = createEmberNodeSpec(emberNodeConfig);
264
- export const variableView = createEmberNodeView(emberNodeConfig);
@@ -1,50 +0,0 @@
1
- import {
2
- createEmberNodeSpec,
3
- createEmberNodeView,
4
- EmberNodeConfig,
5
- } from '@lblod/ember-rdfa-editor/utils/ember-node';
6
- import {
7
- attributesToDOM,
8
- emberNodeConfig as baseVariableConfig,
9
- CONTENT_SELECTOR,
10
- parseAttributes,
11
- } from './nodes';
12
- import { PNode } from '@lblod/ember-rdfa-editor';
13
- import { hasRDFaAttribute } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
14
- import { EXT } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
15
-
16
- const emberNodeConfig = (): EmberNodeConfig => {
17
- const { attrs, ...baseConfig } = baseVariableConfig;
18
- return {
19
- ...baseConfig,
20
- attrs: { ...attrs, value: { default: null } },
21
- componentPath: 'variable-number/number',
22
- leafText: (node: PNode) => {
23
- const { value } = node.attrs;
24
- return value as string;
25
- },
26
- parseDOM: [
27
- {
28
- tag: 'span',
29
- getAttrs: (node: HTMLElement) => {
30
- const attrs = parseAttributes(node);
31
- if (attrs && attrs.type === 'number') {
32
- const content = [...node.children]
33
- .find((el) => hasRDFaAttribute(el, 'property', EXT('content')))
34
- ?.getAttribute('content');
35
- return { ...attrs, value: content };
36
- } else {
37
- return false;
38
- }
39
- },
40
- contentElement: CONTENT_SELECTOR,
41
- },
42
- ],
43
- toDOM: (node) => {
44
- return attributesToDOM(node, node.attrs.value);
45
- },
46
- };
47
- };
48
-
49
- export const number = createEmberNodeSpec(emberNodeConfig());
50
- export const numberView = createEmberNodeView(emberNodeConfig());
@@ -1 +0,0 @@
1
- export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/variable-plugin/template-variable-card';
@@ -1,29 +0,0 @@
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
- import { PNode } from '@lblod/ember-rdfa-editor';
5
- import { TemplateVariablePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin';
6
- type Args = {
7
- controller: SayController;
8
- options: TemplateVariablePluginOptions;
9
- };
10
- export default class EditorPluginsTemplateVariableCardComponent extends Component<Args> {
11
- variableOptions: CodeListOption[];
12
- selectedVariableOption?: CodeListOption | CodeListOption[];
13
- selectedVariable: {
14
- pos: number;
15
- node: PNode;
16
- } | undefined;
17
- showCard: boolean;
18
- multiSelect: boolean;
19
- label?: string;
20
- mappingUri?: string;
21
- get controller(): SayController;
22
- insert(): void;
23
- wrapVariableInHighlight(text: string): string;
24
- selectionChanged(): void;
25
- updateVariableOption(variableOption: CodeListOption | CodeListOption[]): void;
26
- fetchCodeListOptions: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, (endpoint: string, codelistUri: string, isLocation?: boolean) => Promise<void>>;
27
- wrapInLocation(value: string): string;
28
- }
29
- export {};
@@ -1,5 +0,0 @@
1
- export type TemplateVariablePluginOptions = {
2
- endpoint: string;
3
- zonalLocationCodelistUri: string;
4
- nonZonalLocationCodelistUri: string;
5
- };
@@ -1,37 +0,0 @@
1
- import { EmberNodeConfig } from '@lblod/ember-rdfa-editor/utils/ember-node';
2
- import { Attrs, DOMOutputSpec, PNode } from '@lblod/ember-rdfa-editor';
3
- export declare const CONTENT_SELECTOR: string;
4
- export declare const getHTMLNodeExtraAttributes: ({ node, type, }: {
5
- node: HTMLElement;
6
- type: string;
7
- }) => {
8
- minimumValue: string | null;
9
- maximumValue: string | null;
10
- writtenNumber: boolean;
11
- } | {
12
- minimumValue?: undefined;
13
- maximumValue?: undefined;
14
- writtenNumber?: undefined;
15
- };
16
- export declare const getPNodeExtraAttributes: ({ node, type, }: {
17
- node: PNode;
18
- type: string;
19
- }) => {
20
- "data-minimum-value": string;
21
- "data-maximum-value": string;
22
- "data-written-number": string;
23
- } | {
24
- "data-minimum-value"?: undefined;
25
- "data-maximum-value"?: undefined;
26
- "data-written-number"?: undefined;
27
- };
28
- export declare const contentToDom: ({ content, type, node, }: {
29
- content: string | null;
30
- type: string;
31
- node: PNode;
32
- }) => string | null;
33
- export declare const parseAttributes: (node: HTMLElement) => false | Attrs;
34
- export declare const attributesToDOM: (node: PNode, content?: string | null) => DOMOutputSpec;
35
- export declare const emberNodeConfig: EmberNodeConfig;
36
- export declare const variable: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
37
- export declare const variableView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("prosemirror-view").NodeViewConstructor;