@lblod/ember-rdfa-editor-lblod-plugins 9.1.1 → 11.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.
- package/CHANGELOG.md +65 -1
- package/README.md +213 -150
- package/addon/components/import-snippet-plugin/card.hbs +11 -5
- package/addon/components/rdfa-date-plugin/help-modal.hbs +12 -0
- package/addon/components/roadsign-regulation-plugin/expanded-measure.hbs +40 -10
- package/addon/components/roadsign-regulation-plugin/expanded-measure.ts +1 -0
- package/addon/components/roadsign-regulation-plugin/measure-template.ts +6 -12
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +1 -1
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.hbs +5 -5
- package/addon/components/roadsign-regulation-plugin/roadsigns-pagination.hbs +4 -4
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.hbs +25 -9
- package/addon/components/snippet-plugin/search-modal.ts +4 -0
- package/addon/components/snippet-plugin/snippet-insert.hbs +1 -0
- package/addon/components/snippet-plugin/snippet-insert.ts +14 -11
- package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +80 -0
- package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +98 -0
- package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +29 -0
- package/addon/components/snippet-plugin/snippet-list/snippet-list-view.ts +28 -0
- package/addon/components/snippet-plugin/snippet-list-select.hbs +16 -0
- package/addon/components/snippet-plugin/snippet-list-select.ts +27 -0
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.hbs +1 -1
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +16 -55
- package/addon/components/template-comments-plugin/edit-card.hbs +7 -9
- package/addon/components/template-comments-plugin/template-comment.hbs +2 -2
- package/addon/components/template-comments-plugin/template-comment.ts +0 -36
- package/addon/components/variable-plugin/address/edit.hbs +35 -0
- package/addon/components/variable-plugin/address/edit.ts +96 -0
- package/addon/components/variable-plugin/address/insert.hbs +9 -0
- package/addon/components/variable-plugin/address/insert.ts +37 -0
- package/addon/components/variable-plugin/address/nodeview.hbs +19 -0
- package/addon/components/variable-plugin/address/nodeview.ts +31 -0
- package/addon/components/variable-plugin/{template-variable-card.hbs → codelist/edit.hbs} +14 -12
- package/addon/components/variable-plugin/codelist/edit.ts +94 -0
- package/addon/components/variable-plugin/codelist/insert.hbs +22 -0
- package/addon/components/variable-plugin/codelist/insert.ts +84 -0
- package/addon/components/variable-plugin/date/insert.hbs +9 -0
- package/addon/components/variable-plugin/date/insert.ts +45 -0
- package/addon/components/variable-plugin/insert-variable-card.hbs +7 -40
- package/addon/components/variable-plugin/insert-variable-card.ts +18 -166
- package/addon/components/variable-plugin/location/edit.hbs +40 -0
- package/addon/components/variable-plugin/location/edit.ts +122 -0
- package/addon/components/variable-plugin/location/insert.hbs +9 -0
- package/addon/components/variable-plugin/location/insert.ts +65 -0
- package/addon/components/variable-plugin/{number-settings.hbs → number/insert.hbs} +20 -9
- package/addon/components/variable-plugin/number/insert.ts +88 -0
- package/addon/components/{variable-number/number.hbs → variable-plugin/number/nodeview.hbs} +2 -2
- package/addon/components/{variable-number/number.ts → variable-plugin/number/nodeview.ts} +3 -7
- package/addon/components/variable-plugin/text/insert.hbs +9 -0
- package/addon/components/variable-plugin/text/insert.ts +49 -0
- package/addon/components/variable-plugin/utils/label-input.hbs +11 -0
- package/addon/components/variable-plugin/{variable.ts → variable/nodeview.ts} +1 -1
- package/addon/helpers/in-array.ts +13 -0
- package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +1 -1
- package/addon/plugins/rdfa-date-plugin/nodes/date.ts +48 -51
- package/addon/plugins/snippet-plugin/index.ts +20 -0
- package/addon/plugins/snippet-plugin/utils/fetch-data.ts +127 -11
- package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +23 -17
- package/addon/plugins/table-of-contents-plugin/utils/index.ts +1 -1
- package/addon/plugins/template-comments-plugin/index.ts +1 -5
- package/addon/plugins/template-comments-plugin/node.ts +3 -16
- package/addon/plugins/variable-plugin/utils/address-helpers.ts +112 -0
- package/addon/plugins/variable-plugin/utils/attribute-parsers.ts +31 -0
- package/addon/plugins/variable-plugin/utils/codelist-utils.ts +56 -0
- package/addon/plugins/variable-plugin/utils/constants.ts +0 -120
- package/addon/plugins/variable-plugin/utils/dom-constructors.ts +66 -0
- package/addon/plugins/variable-plugin/utils/fetch-data.ts +2 -2
- package/addon/plugins/variable-plugin/variables/address.ts +322 -0
- package/addon/plugins/variable-plugin/variables/codelist.ts +120 -0
- package/addon/plugins/variable-plugin/variables/index.ts +5 -0
- package/addon/plugins/variable-plugin/variables/location.ts +98 -0
- package/addon/plugins/variable-plugin/variables/number.ts +145 -0
- package/addon/plugins/variable-plugin/variables/text.ts +90 -0
- package/addon/utils/constants.ts +7 -0
- package/addon/utils/dom-output-spec-helpers.ts +8 -0
- package/addon/utils/namespace.ts +11 -0
- package/app/components/snippet-plugin/snippet-list/snippet-list-modal.js +1 -0
- package/app/components/{variable-plugin/template-variable-card.js → snippet-plugin/snippet-list/snippet-list-view.js} +1 -1
- package/app/components/snippet-plugin/snippet-list-select.js +1 -0
- package/app/components/variable-plugin/{variable.js → address/edit.js} +1 -1
- package/app/components/variable-plugin/{number-settings.js → address/insert.js} +1 -1
- package/app/components/variable-plugin/address/nodeview.js +1 -0
- package/app/components/variable-plugin/codelist/edit.js +1 -0
- package/app/components/variable-plugin/codelist/insert.js +1 -0
- package/app/components/{address-plugin → variable-plugin/date}/insert.js +1 -1
- package/app/components/variable-plugin/location/edit.js +1 -0
- package/app/components/variable-plugin/location/insert.js +1 -0
- package/app/components/variable-plugin/number/insert.js +1 -0
- package/app/components/variable-plugin/number/nodeview.js +1 -0
- package/app/components/{variable-number/number.js → variable-plugin/text/insert.js} +1 -1
- package/app/components/variable-plugin/utils/label-input.js +1 -0
- package/app/components/variable-plugin/variable/nodeview.js +1 -0
- package/app/helpers/in-array.js +4 -0
- package/app/styles/snippet-plugin.scss +18 -1
- package/components/roadsign-regulation-plugin/expanded-measure.d.ts +1 -0
- package/components/roadsign-regulation-plugin/measure-template.d.ts +2 -4
- package/components/snippet-plugin/search-modal.d.ts +1 -0
- package/components/snippet-plugin/snippet-insert.d.ts +3 -1
- package/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +23 -0
- package/components/snippet-plugin/snippet-list/snippet-list-view.d.ts +10 -0
- package/components/snippet-plugin/snippet-list-select.d.ts +14 -0
- package/components/table-of-contents-plugin/ember-nodes/table-of-contents.d.ts +5 -12
- package/components/template-comments-plugin/template-comment.d.ts +0 -8
- package/components/variable-plugin/address/edit.d.ts +23 -0
- package/components/variable-plugin/address/insert.d.ts +11 -0
- package/components/variable-plugin/address/nodeview.d.ts +14 -0
- package/components/variable-plugin/codelist/edit.d.ts +27 -0
- package/components/variable-plugin/codelist/insert.d.ts +26 -0
- package/components/variable-plugin/date/insert.d.ts +13 -0
- package/components/variable-plugin/insert-variable-card.d.ts +10 -34
- package/components/variable-plugin/location/edit.d.ts +31 -0
- package/components/variable-plugin/location/insert.d.ts +20 -0
- package/components/variable-plugin/number/insert.d.ts +20 -0
- package/components/{variable-number/number.d.ts → variable-plugin/number/nodeview.d.ts} +1 -1
- package/components/variable-plugin/text/insert.d.ts +13 -0
- package/components/variable-plugin/{variable.d.ts → variable/nodeview.d.ts} +1 -1
- package/helpers/in-array.d.ts +9 -0
- package/package.json +5 -5
- package/plugins/snippet-plugin/index.d.ts +11 -0
- package/plugins/snippet-plugin/utils/fetch-data.d.ts +10 -1
- package/plugins/table-of-contents-plugin/utils/index.d.ts +1 -1
- package/plugins/template-comments-plugin/index.d.ts +1 -1
- package/plugins/template-comments-plugin/node.d.ts +0 -4
- package/plugins/variable-plugin/utils/address-helpers.d.ts +4 -0
- package/plugins/variable-plugin/utils/attribute-parsers.d.ts +5 -0
- package/plugins/variable-plugin/utils/codelist-utils.d.ts +6 -0
- package/plugins/variable-plugin/utils/constants.d.ts +0 -19
- package/plugins/variable-plugin/utils/dom-constructors.d.ts +24 -0
- package/plugins/variable-plugin/utils/fetch-data.d.ts +1 -1
- package/plugins/variable-plugin/variables/address.d.ts +23 -0
- package/plugins/variable-plugin/variables/codelist.d.ts +2 -0
- package/plugins/variable-plugin/variables/index.d.ts +5 -0
- package/plugins/variable-plugin/variables/location.d.ts +2 -0
- package/plugins/variable-plugin/variables/text.d.ts +2 -0
- package/translations/en-US.yaml +74 -2
- package/translations/nl-BE.yaml +73 -1
- package/types/global.d.ts +10 -0
- package/utils/constants.d.ts +3 -0
- package/utils/dom-output-spec-helpers.d.ts +2 -0
- package/utils/namespace.d.ts +1 -0
- package/addon/components/address-plugin/insert.hbs +0 -47
- package/addon/components/address-plugin/insert.ts +0 -100
- package/addon/components/address-plugin/types.ts +0 -26
- package/addon/components/address-plugin/utils.ts +0 -59
- package/addon/components/variable-plugin/template-variable-card.ts +0 -163
- package/addon/plugins/variable-plugin/index.ts +0 -5
- package/addon/plugins/variable-plugin/nodes.ts +0 -264
- package/addon/plugins/variable-plugin/number.ts +0 -50
- package/app/components/variable-plugin/variable-edit-modal.js +0 -1
- package/components/address-plugin/insert.d.ts +0 -21
- package/components/address-plugin/types.d.ts +0 -25
- package/components/address-plugin/utils.d.ts +0 -9
- package/components/variable-plugin/template-variable-card.d.ts +0 -29
- package/plugins/variable-plugin/index.d.ts +0 -5
- package/plugins/variable-plugin/nodes.d.ts +0 -37
- /package/addon/components/variable-plugin/{variable.hbs → variable/nodeview.hbs} +0 -0
- /package/plugins/variable-plugin/{number.d.ts → variables/number.d.ts} +0 -0
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Address, AddressSuggestion } from './types';
|
|
2
|
-
|
|
3
|
-
const LOC_GEOPUNT_ENDPOINT = `https://geo.api.vlaanderen.be/geolocation/v4/Location`;
|
|
4
|
-
const BASISREGISTER_ADRESMATCH = `https://basisregisters.vlaanderen.be/api/v1/adressen`;
|
|
5
|
-
|
|
6
|
-
export const replaceAccents = (string: string) =>
|
|
7
|
-
string.normalize('NFD').replace(/([\u0300-\u036f])/g, '');
|
|
8
|
-
|
|
9
|
-
export async function getSuggestedLocations(query: string) {
|
|
10
|
-
const result = await fetch(
|
|
11
|
-
`${LOC_GEOPUNT_ENDPOINT}?q=${encodeURIComponent(
|
|
12
|
-
query.replace(/^"(.*)"$/, '$1'),
|
|
13
|
-
)}&c=10&type=Housenumber`,
|
|
14
|
-
{
|
|
15
|
-
method: 'GET',
|
|
16
|
-
},
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
const jsonResult = (await result.json()) as {
|
|
20
|
-
LocationResult: AddressSuggestion[];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
if (!jsonResult) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return jsonResult.LocationResult;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function getAddressMatch({
|
|
31
|
-
municipality,
|
|
32
|
-
zipcode,
|
|
33
|
-
street,
|
|
34
|
-
housenumber,
|
|
35
|
-
}: {
|
|
36
|
-
municipality: string;
|
|
37
|
-
street: string;
|
|
38
|
-
housenumber: string;
|
|
39
|
-
zipcode: string;
|
|
40
|
-
}) {
|
|
41
|
-
const url = new URL(BASISREGISTER_ADRESMATCH);
|
|
42
|
-
|
|
43
|
-
url.searchParams.append('GemeenteNaam', replaceAccents(municipality));
|
|
44
|
-
url.searchParams.append('Straatnaam', replaceAccents(street));
|
|
45
|
-
url.searchParams.append('Huisnummer', replaceAccents(housenumber));
|
|
46
|
-
url.searchParams.append('Postcode', replaceAccents(zipcode));
|
|
47
|
-
|
|
48
|
-
const response = await fetch(url.toString(), {
|
|
49
|
-
method: 'GET',
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const result = (await response.json()) as {
|
|
53
|
-
adressen: Address[];
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
if (!result) return [];
|
|
57
|
-
|
|
58
|
-
return result.adressen;
|
|
59
|
-
}
|
|
@@ -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,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/variable-edit-modal';
|
|
@@ -1,21 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
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[]>;
|
|
@@ -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,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;
|
|
File without changes
|
|
File without changes
|