@lblod/ember-rdfa-editor-lblod-plugins 1.0.0-beta.1 → 1.0.0-beta.2
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 +29 -0
- package/addon/components/article-structure-plugin/article-structure-card.hbs +3 -1
- package/addon/components/au-dropdown-pill.hbs +32 -0
- package/addon/components/au-dropdown-pill.ts +65 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +19 -12
- package/addon/components/citation-plugin/citation-card.ts +1 -1
- package/addon/components/citation-plugin/citation-insert.ts +1 -1
- package/addon/components/import-snippet-plugin/card.ts +8 -12
- package/addon/components/rdfa-date-plugin/card.hbs +28 -0
- package/addon/components/rdfa-date-plugin/card.ts +72 -38
- package/addon/components/rdfa-date-plugin/date-time-picker.ts +1 -0
- package/addon/components/rdfa-date-plugin/insert.hbs +2 -2
- package/addon/components/rdfa-date-plugin/insert.ts +14 -23
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +24 -25
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +36 -17
- package/addon/components/standard-template-plugin/template-provider.ts +54 -11
- package/addon/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.hbs +4 -4
- package/addon/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.ts +26 -35
- package/addon/components/{template-variable-plugin → variable-plugin}/template-variable-card.hbs +6 -6
- package/addon/components/variable-plugin/template-variable-card.ts +174 -0
- package/addon/components/variable-plugin/variable.hbs +4 -0
- package/addon/components/variable-plugin/variable.ts +250 -0
- package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +4 -2
- package/addon/plugins/article-structure-plugin/index.ts +1 -1
- package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +6 -2
- package/addon/plugins/article-structure-plugin/structures/article.ts +1 -1
- package/addon/plugins/article-structure-plugin/structures/chapter.ts +1 -2
- package/addon/plugins/article-structure-plugin/structures/section.ts +1 -1
- package/addon/plugins/article-structure-plugin/structures/subsection.ts +1 -1
- package/addon/plugins/article-structure-plugin/structures/title.ts +1 -2
- package/addon/plugins/citation-plugin/index.ts +184 -113
- package/addon/plugins/rdfa-date-plugin/index.ts +42 -3
- package/addon/plugins/rdfa-date-plugin/nodes/date.ts +127 -0
- package/addon/plugins/rdfa-date-plugin/nodes/index.ts +1 -0
- package/addon/plugins/rdfa-date-plugin/utils.ts +10 -0
- package/addon/plugins/roadsign-regulation-plugin/nodes.ts +107 -0
- package/addon/plugins/standard-template-plugin/index.ts +26 -0
- package/addon/plugins/standard-template-plugin/utils/nodes.ts +366 -0
- package/addon/plugins/{insert-variable-plugin → variable-plugin}/index.ts +6 -1
- package/addon/plugins/variable-plugin/nodes.ts +137 -0
- package/addon/plugins/variable-plugin/utils/constants.ts +107 -0
- package/addon/plugins/{template-variable-plugin → variable-plugin}/utils/fetch-data.ts +41 -0
- package/addon/services/standard-template-plugin.ts +16 -12
- package/addon/utils/changed-descendants.ts +29 -0
- package/addon/utils/constants.ts +11 -0
- package/addon/utils/namespace.ts +42 -7
- package/app/components/au-dropdown-pill.js +1 -0
- package/app/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.js +1 -1
- package/app/components/{template-variable-plugin → variable-plugin}/template-variable-card.js +1 -1
- package/app/components/variable-plugin/variable-edit-modal.js +1 -0
- package/app/components/variable-plugin/variable.js +1 -0
- package/app/styles/date-plugin.scss +17 -0
- package/app/styles/variable-plugin.scss +65 -0
- package/components/au-dropdown-pill.d.ts +19 -0
- package/components/au-native-input.d.ts +1 -1
- package/components/citation-plugin/citation-card.d.ts +1 -1
- package/components/rdfa-date-plugin/card.d.ts +14 -5
- package/components/rdfa-date-plugin/insert.d.ts +1 -2
- package/components/roadsign-regulation-plugin/roadsign-regulation-card.d.ts +1 -0
- package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +3 -0
- package/components/standard-template-plugin/template-provider.d.ts +6 -1
- package/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.d.ts +3 -4
- package/components/{template-variable-plugin → variable-plugin}/template-variable-card.d.ts +8 -5
- package/components/variable-plugin/variable.d.ts +42 -0
- package/package.json +4 -4
- package/plugins/article-structure-plugin/commands/insert-structure.d.ts +2 -2
- package/plugins/article-structure-plugin/index.d.ts +1 -1
- package/plugins/citation-plugin/index.d.ts +11 -4
- package/plugins/rdfa-date-plugin/index.d.ts +13 -1
- package/plugins/rdfa-date-plugin/nodes/date.d.ts +9 -0
- package/plugins/rdfa-date-plugin/nodes/index.d.ts +1 -0
- package/plugins/rdfa-date-plugin/utils.d.ts +1 -0
- package/plugins/roadsign-regulation-plugin/nodes.d.ts +2 -0
- package/plugins/standard-template-plugin/index.d.ts +12 -0
- package/plugins/standard-template-plugin/utils/nodes.d.ts +12 -0
- package/plugins/{insert-variable-plugin → variable-plugin}/index.d.ts +1 -0
- package/plugins/variable-plugin/nodes.d.ts +2 -0
- package/plugins/variable-plugin/utils/constants.d.ts +9 -0
- package/plugins/{template-variable-plugin → variable-plugin}/utils/fetch-data.d.ts +5 -0
- package/services/standard-template-plugin.d.ts +9 -10
- package/translations/en-US.yaml +4 -3
- package/translations/nl-BE.yaml +5 -4
- package/utils/changed-descendants.d.ts +2 -0
- package/utils/constants.d.ts +5 -0
- package/utils/namespace.d.ts +8 -3
- package/addon/components/template-variable-plugin/template-variable-card.ts +0 -227
- package/addon/plugins/insert-variable-plugin/utils/constants.ts +0 -67
- package/addon/plugins/insert-variable-plugin/utils/fetch-data.ts +0 -41
- package/addon/plugins/rdfa-date-plugin/commands/index.ts +0 -1
- package/addon/plugins/rdfa-date-plugin/commands/modify-date.ts +0 -48
- package/addon/plugins/template-variable-plugin/index.ts +0 -6
- package/addon/plugins/template-variable-plugin/utils/constants.ts +0 -2
- package/plugins/insert-variable-plugin/utils/constants.d.ts +0 -7
- package/plugins/insert-variable-plugin/utils/fetch-data.d.ts +0 -5
- package/plugins/rdfa-date-plugin/commands/index.d.ts +0 -1
- package/plugins/rdfa-date-plugin/commands/modify-date.d.ts +0 -2
- package/plugins/template-variable-plugin/index.d.ts +0 -2
- package/plugins/template-variable-plugin/utils/constants.d.ts +0 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { getRdfaAttrs, NodeSpec, rdfaAttrs } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import {
|
|
3
|
+
DCT,
|
|
4
|
+
EXT,
|
|
5
|
+
MOBILITEIT,
|
|
6
|
+
PROV,
|
|
7
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
8
|
+
import { hasRDFaAttribute } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
9
|
+
|
|
10
|
+
const CONTENT_SELECTOR = `div[property~='${
|
|
11
|
+
DCT('description').full
|
|
12
|
+
}'],div[property~='${DCT('description').prefixed}']`;
|
|
13
|
+
export const roadsign_regulation: NodeSpec = {
|
|
14
|
+
content: 'block+',
|
|
15
|
+
group: 'block',
|
|
16
|
+
attrs: {
|
|
17
|
+
...rdfaAttrs,
|
|
18
|
+
resourceUri: {},
|
|
19
|
+
measureUri: {},
|
|
20
|
+
zonality: {},
|
|
21
|
+
temporal: {
|
|
22
|
+
default: false,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
toDOM(node) {
|
|
26
|
+
const { resourceUri, measureUri, zonality, temporal } = node.attrs;
|
|
27
|
+
return [
|
|
28
|
+
'div',
|
|
29
|
+
{
|
|
30
|
+
property: MOBILITEIT('heeftVerkeersmaatregel'),
|
|
31
|
+
typeof: MOBILITEIT('Mobiliteitsmaatregel'),
|
|
32
|
+
resource: resourceUri as string,
|
|
33
|
+
},
|
|
34
|
+
[
|
|
35
|
+
'span',
|
|
36
|
+
{
|
|
37
|
+
style: 'display:none;',
|
|
38
|
+
property: PROV('wasDerivedFrom'),
|
|
39
|
+
resource: measureUri as string,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
'span',
|
|
44
|
+
{
|
|
45
|
+
style: 'display:none;',
|
|
46
|
+
property: EXT('zonality'),
|
|
47
|
+
resource: zonality as string,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
'span',
|
|
52
|
+
{
|
|
53
|
+
property: EXT('temporal'),
|
|
54
|
+
resource: (temporal as string) ?? false,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
['div', { property: DCT('description') }, 0],
|
|
58
|
+
];
|
|
59
|
+
},
|
|
60
|
+
parseDOM: [
|
|
61
|
+
{
|
|
62
|
+
tag: 'div',
|
|
63
|
+
getAttrs(node: HTMLElement) {
|
|
64
|
+
if (
|
|
65
|
+
hasRDFaAttribute(
|
|
66
|
+
node,
|
|
67
|
+
'typeof',
|
|
68
|
+
MOBILITEIT('Mobiliteitsmaatregel')
|
|
69
|
+
) &&
|
|
70
|
+
node.querySelector(CONTENT_SELECTOR)
|
|
71
|
+
) {
|
|
72
|
+
const resourceUri = node.getAttribute('resource');
|
|
73
|
+
const measureUri = node
|
|
74
|
+
.querySelector(
|
|
75
|
+
`span[property~='${PROV('wasDerivedFrom').prefixed}'],
|
|
76
|
+
span[property~='${PROV('wasDerivedFrom').full}']`
|
|
77
|
+
)
|
|
78
|
+
?.getAttribute('resource');
|
|
79
|
+
const zonality = node
|
|
80
|
+
.querySelector(
|
|
81
|
+
`span[property~='${EXT('zonality').prefixed}'],
|
|
82
|
+
span[property~='${EXT('zonality').full}']`
|
|
83
|
+
)
|
|
84
|
+
?.getAttribute('resource');
|
|
85
|
+
if (!resourceUri || !measureUri || !zonality) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const temporal = node
|
|
89
|
+
.querySelector(
|
|
90
|
+
`span[property~='${EXT('temporal').prefixed}'],
|
|
91
|
+
span[property~='${EXT('temporal').full}']`
|
|
92
|
+
)
|
|
93
|
+
?.getAttribute('value');
|
|
94
|
+
return {
|
|
95
|
+
resourceUri,
|
|
96
|
+
measureUri,
|
|
97
|
+
zonality,
|
|
98
|
+
temporal,
|
|
99
|
+
...getRdfaAttrs(node),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
},
|
|
104
|
+
contentElement: CONTENT_SELECTOR,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
};
|
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import { WidgetSpec } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import {
|
|
3
|
+
besluit,
|
|
4
|
+
title,
|
|
5
|
+
description,
|
|
6
|
+
motivering,
|
|
7
|
+
article_container,
|
|
8
|
+
besluit_article,
|
|
9
|
+
besluit_article_content,
|
|
10
|
+
besluit_article_header,
|
|
11
|
+
language_node,
|
|
12
|
+
besluitArticleStructure,
|
|
13
|
+
} from './utils/nodes';
|
|
2
14
|
|
|
3
15
|
export const standardTemplateWidget: WidgetSpec = {
|
|
4
16
|
desiredLocation: 'insertSidebar',
|
|
5
17
|
componentName: 'standard-template-plugin/card',
|
|
6
18
|
};
|
|
19
|
+
|
|
20
|
+
export const besluitNodes = {
|
|
21
|
+
besluit,
|
|
22
|
+
title,
|
|
23
|
+
description,
|
|
24
|
+
motivering,
|
|
25
|
+
article_container,
|
|
26
|
+
besluit_article,
|
|
27
|
+
besluit_article_content,
|
|
28
|
+
besluit_article_header,
|
|
29
|
+
language_node,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const structureSpecs = [besluitArticleStructure];
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getRdfaAttrs,
|
|
3
|
+
NodeSpec,
|
|
4
|
+
rdfaAttrs,
|
|
5
|
+
Transaction,
|
|
6
|
+
} from '@lblod/ember-rdfa-editor';
|
|
7
|
+
import {
|
|
8
|
+
BESLUIT,
|
|
9
|
+
ELI,
|
|
10
|
+
PROV,
|
|
11
|
+
SKOS,
|
|
12
|
+
XSD,
|
|
13
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
14
|
+
import { hasRDFaAttribute } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
15
|
+
import { StructureSpec } from '../../article-structure-plugin';
|
|
16
|
+
import { v4 as uuid } from 'uuid';
|
|
17
|
+
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
18
|
+
|
|
19
|
+
export const title: NodeSpec = {
|
|
20
|
+
content: 'paragraph+',
|
|
21
|
+
inline: false,
|
|
22
|
+
attrs: {
|
|
23
|
+
...rdfaAttrs,
|
|
24
|
+
property: {
|
|
25
|
+
default: 'eli:title',
|
|
26
|
+
},
|
|
27
|
+
datatype: {
|
|
28
|
+
default: 'xsd:string',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
toDOM(node) {
|
|
32
|
+
return ['h4', node.attrs, 0];
|
|
33
|
+
},
|
|
34
|
+
parseDOM: [
|
|
35
|
+
{
|
|
36
|
+
tag: 'h4',
|
|
37
|
+
getAttrs(element: HTMLElement) {
|
|
38
|
+
if (hasRDFaAttribute(element, 'property', ELI('title'))) {
|
|
39
|
+
return getRdfaAttrs(element);
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const description: NodeSpec = {
|
|
48
|
+
group: 'block',
|
|
49
|
+
content: 'block+',
|
|
50
|
+
inline: false,
|
|
51
|
+
attrs: {
|
|
52
|
+
...rdfaAttrs,
|
|
53
|
+
property: {
|
|
54
|
+
default: 'eli:description',
|
|
55
|
+
},
|
|
56
|
+
datatype: {
|
|
57
|
+
default: 'xsd:string',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
toDOM(node) {
|
|
61
|
+
return ['p', node.attrs, 0];
|
|
62
|
+
},
|
|
63
|
+
parseDOM: [
|
|
64
|
+
{
|
|
65
|
+
tag: 'p',
|
|
66
|
+
getAttrs(element: HTMLElement) {
|
|
67
|
+
if (hasRDFaAttribute(element, 'property', ELI('description'))) {
|
|
68
|
+
return getRdfaAttrs(element);
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const motivering: NodeSpec = {
|
|
77
|
+
group: 'block',
|
|
78
|
+
content: 'block+',
|
|
79
|
+
inline: false,
|
|
80
|
+
attrs: {
|
|
81
|
+
...rdfaAttrs,
|
|
82
|
+
property: {
|
|
83
|
+
default: 'besluit:motivering',
|
|
84
|
+
},
|
|
85
|
+
lang: {
|
|
86
|
+
default: 'nl',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
toDOM(node) {
|
|
90
|
+
return ['p', node.attrs, 0];
|
|
91
|
+
},
|
|
92
|
+
parseDOM: [
|
|
93
|
+
{
|
|
94
|
+
tag: 'div,p',
|
|
95
|
+
getAttrs(element: HTMLElement) {
|
|
96
|
+
if (hasRDFaAttribute(element, 'property', BESLUIT('motivering'))) {
|
|
97
|
+
return getRdfaAttrs(element);
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const article_container: NodeSpec = {
|
|
106
|
+
group: 'block',
|
|
107
|
+
content: '(block|besluit_article)+',
|
|
108
|
+
inline: false,
|
|
109
|
+
attrs: {
|
|
110
|
+
...rdfaAttrs,
|
|
111
|
+
property: {
|
|
112
|
+
default: 'prov:value',
|
|
113
|
+
},
|
|
114
|
+
datatype: {
|
|
115
|
+
default: 'xsd:string',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
toDOM(node) {
|
|
119
|
+
return ['div', node.attrs, 0];
|
|
120
|
+
},
|
|
121
|
+
parseDOM: [
|
|
122
|
+
{
|
|
123
|
+
tag: 'div',
|
|
124
|
+
getAttrs(element: HTMLElement) {
|
|
125
|
+
if (
|
|
126
|
+
hasRDFaAttribute(element, 'property', PROV('value')) &&
|
|
127
|
+
hasRDFaAttribute(element, 'typeof', BESLUIT('Besluit'))
|
|
128
|
+
) {
|
|
129
|
+
return getRdfaAttrs(element);
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const besluit_article: NodeSpec = {
|
|
138
|
+
content:
|
|
139
|
+
'besluit_article_header{1}(language_node*)besluit_article_content{1}',
|
|
140
|
+
inline: false,
|
|
141
|
+
attrs: {
|
|
142
|
+
...rdfaAttrs,
|
|
143
|
+
property: {
|
|
144
|
+
default: 'eli:has_part',
|
|
145
|
+
},
|
|
146
|
+
typeof: {
|
|
147
|
+
default: 'besluit:Artikel',
|
|
148
|
+
},
|
|
149
|
+
resource: {},
|
|
150
|
+
},
|
|
151
|
+
toDOM(node) {
|
|
152
|
+
return ['div', node.attrs, 0];
|
|
153
|
+
},
|
|
154
|
+
parseDOM: [
|
|
155
|
+
{
|
|
156
|
+
tag: 'div',
|
|
157
|
+
getAttrs(element: HTMLElement) {
|
|
158
|
+
if (
|
|
159
|
+
hasRDFaAttribute(element, 'property', ELI('has_part')) &&
|
|
160
|
+
hasRDFaAttribute(element, 'typeof', BESLUIT('Artikel'))
|
|
161
|
+
) {
|
|
162
|
+
return getRdfaAttrs(element);
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const besluitArticleStructure: StructureSpec = {
|
|
171
|
+
name: 'besluit_article',
|
|
172
|
+
translations: {
|
|
173
|
+
insert: 'article-structure-plugin.insert.article',
|
|
174
|
+
move: {
|
|
175
|
+
up: 'article-structure-plugin.moveUp.article',
|
|
176
|
+
down: 'article-structure-plugin.moveDown.article',
|
|
177
|
+
},
|
|
178
|
+
remove: 'article-structure-plugin.remove.article',
|
|
179
|
+
},
|
|
180
|
+
constructor: ({ schema, number, content, intl }) => {
|
|
181
|
+
const numberConverted = number?.toString() ?? '1';
|
|
182
|
+
const node = schema.node(
|
|
183
|
+
`besluit_article`,
|
|
184
|
+
{ resource: `http://data.lblod.info/articles/${uuid()}` },
|
|
185
|
+
[
|
|
186
|
+
schema.node('besluit_article_header', { number: numberConverted }),
|
|
187
|
+
schema.node(
|
|
188
|
+
`besluit_article_content`,
|
|
189
|
+
{},
|
|
190
|
+
content ??
|
|
191
|
+
schema.node(
|
|
192
|
+
'paragraph',
|
|
193
|
+
{},
|
|
194
|
+
schema.node('placeholder', {
|
|
195
|
+
placeholderText: intl?.t(
|
|
196
|
+
'article-structure-plugin.placeholder.article.body'
|
|
197
|
+
),
|
|
198
|
+
})
|
|
199
|
+
)
|
|
200
|
+
),
|
|
201
|
+
]
|
|
202
|
+
);
|
|
203
|
+
const selectionConfig: {
|
|
204
|
+
relativePos: number;
|
|
205
|
+
type: 'text' | 'node';
|
|
206
|
+
} = content
|
|
207
|
+
? { relativePos: 3, type: 'text' }
|
|
208
|
+
: { relativePos: 4, type: 'node' };
|
|
209
|
+
return {
|
|
210
|
+
node,
|
|
211
|
+
selectionConfig,
|
|
212
|
+
};
|
|
213
|
+
},
|
|
214
|
+
updateNumber: function ({ number, pos, transaction }): Transaction {
|
|
215
|
+
transaction.setNodeAttribute(pos + 1, 'number', number.toString());
|
|
216
|
+
return transaction;
|
|
217
|
+
},
|
|
218
|
+
content: ({ pos, state }) => {
|
|
219
|
+
const node = unwrap(state.doc.nodeAt(pos));
|
|
220
|
+
return unwrap(node.lastChild).content;
|
|
221
|
+
},
|
|
222
|
+
continuous: false,
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export const besluit_article_header: NodeSpec = {
|
|
226
|
+
inline: false,
|
|
227
|
+
attrs: {
|
|
228
|
+
...rdfaAttrs,
|
|
229
|
+
number: {
|
|
230
|
+
default: '1',
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
toDOM(node) {
|
|
234
|
+
const toplevelAttrs = { ...node.attrs };
|
|
235
|
+
delete toplevelAttrs.number;
|
|
236
|
+
delete toplevelAttrs.datatype;
|
|
237
|
+
return [
|
|
238
|
+
'p',
|
|
239
|
+
toplevelAttrs,
|
|
240
|
+
'Artikel ',
|
|
241
|
+
[
|
|
242
|
+
'span',
|
|
243
|
+
{ property: ELI('number').prefixed, datatype: XSD('string').prefixed },
|
|
244
|
+
node.attrs.number,
|
|
245
|
+
],
|
|
246
|
+
];
|
|
247
|
+
},
|
|
248
|
+
parseDOM: [
|
|
249
|
+
{
|
|
250
|
+
tag: 'p',
|
|
251
|
+
getAttrs(element: HTMLElement) {
|
|
252
|
+
const numberNode = element.querySelector(
|
|
253
|
+
`span[property~='${ELI('number').prefixed}'],
|
|
254
|
+
span[property~='${ELI('number').full}']`
|
|
255
|
+
);
|
|
256
|
+
if (numberNode) {
|
|
257
|
+
return {
|
|
258
|
+
...getRdfaAttrs(element),
|
|
259
|
+
number: numberNode.textContent,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export const besluit_article_content: NodeSpec = {
|
|
269
|
+
content: 'block+',
|
|
270
|
+
inline: false,
|
|
271
|
+
attrs: {
|
|
272
|
+
...rdfaAttrs,
|
|
273
|
+
property: {
|
|
274
|
+
default: 'prov:value',
|
|
275
|
+
},
|
|
276
|
+
datatype: {
|
|
277
|
+
default: 'xsd:string',
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
toDOM(node) {
|
|
281
|
+
return ['div', node.attrs, 0];
|
|
282
|
+
},
|
|
283
|
+
parseDOM: [
|
|
284
|
+
{
|
|
285
|
+
tag: 'div',
|
|
286
|
+
getAttrs(element: HTMLElement) {
|
|
287
|
+
if (hasRDFaAttribute(element, 'property', PROV('value'))) {
|
|
288
|
+
return getRdfaAttrs(element);
|
|
289
|
+
}
|
|
290
|
+
return false;
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export const besluit: NodeSpec = {
|
|
297
|
+
group: 'block',
|
|
298
|
+
content: 'block*title{1}block*description?block*motivering?block*',
|
|
299
|
+
inline: false,
|
|
300
|
+
attrs: {
|
|
301
|
+
...rdfaAttrs,
|
|
302
|
+
property: {
|
|
303
|
+
default: 'prov:generated',
|
|
304
|
+
},
|
|
305
|
+
typeof: {
|
|
306
|
+
default: 'besluit:Besluit ext:BesluitNieuweStijl',
|
|
307
|
+
},
|
|
308
|
+
resource: {},
|
|
309
|
+
},
|
|
310
|
+
toDOM(node) {
|
|
311
|
+
return ['div', node.attrs, 0];
|
|
312
|
+
},
|
|
313
|
+
parseDOM: [
|
|
314
|
+
{
|
|
315
|
+
tag: 'div',
|
|
316
|
+
getAttrs(element: HTMLElement) {
|
|
317
|
+
if (
|
|
318
|
+
hasRDFaAttribute(element, 'property', PROV('generated')) &&
|
|
319
|
+
hasRDFaAttribute(element, 'typeof', BESLUIT('Besluit'))
|
|
320
|
+
) {
|
|
321
|
+
return getRdfaAttrs(element);
|
|
322
|
+
}
|
|
323
|
+
return false;
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export const language_node: NodeSpec = {
|
|
330
|
+
group: 'block',
|
|
331
|
+
content: '',
|
|
332
|
+
inline: false,
|
|
333
|
+
atom: true,
|
|
334
|
+
attrs: {
|
|
335
|
+
...rdfaAttrs,
|
|
336
|
+
style: {
|
|
337
|
+
default: 'style="display:none;"',
|
|
338
|
+
},
|
|
339
|
+
property: {
|
|
340
|
+
default: 'eli:language',
|
|
341
|
+
},
|
|
342
|
+
typeof: {
|
|
343
|
+
default: 'skos:Concept',
|
|
344
|
+
},
|
|
345
|
+
resource: {
|
|
346
|
+
default: 'http://publications.europa.eu/resource/authority/language/NLD',
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
toDOM(node) {
|
|
350
|
+
return ['span', node.attrs];
|
|
351
|
+
},
|
|
352
|
+
parseDOM: [
|
|
353
|
+
{
|
|
354
|
+
tag: 'span',
|
|
355
|
+
getAttrs(element: HTMLElement) {
|
|
356
|
+
if (
|
|
357
|
+
hasRDFaAttribute(element, 'property', ELI('language')) &&
|
|
358
|
+
hasRDFaAttribute(element, 'typeof', SKOS('Concept'))
|
|
359
|
+
) {
|
|
360
|
+
return getRdfaAttrs(element);
|
|
361
|
+
}
|
|
362
|
+
return false;
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
],
|
|
366
|
+
};
|
|
@@ -2,10 +2,15 @@ import { WidgetSpec } from '@lblod/ember-rdfa-editor';
|
|
|
2
2
|
|
|
3
3
|
export function insertVariableWidget(options?: unknown): WidgetSpec {
|
|
4
4
|
return {
|
|
5
|
-
componentName: '
|
|
5
|
+
componentName: 'variable-plugin/insert-variable-card',
|
|
6
6
|
desiredLocation: 'sidebar',
|
|
7
7
|
widgetArgs: {
|
|
8
8
|
options,
|
|
9
9
|
},
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
export const templateVariableWidget: WidgetSpec = {
|
|
14
|
+
componentName: 'variable-plugin/template-variable-card',
|
|
15
|
+
desiredLocation: 'sidebar',
|
|
16
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
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
|
+
|
|
13
|
+
const CONTENT_SELECTOR = `span[property~='${EXT('content').prefixed}'],
|
|
14
|
+
span[property~='${EXT('content').full}']`;
|
|
15
|
+
|
|
16
|
+
const emberNodeConfig: EmberNodeConfig = {
|
|
17
|
+
name: 'variable',
|
|
18
|
+
componentPath: 'variable-plugin/variable',
|
|
19
|
+
inline: true,
|
|
20
|
+
group: 'inline',
|
|
21
|
+
content: 'inline*',
|
|
22
|
+
atom: true,
|
|
23
|
+
draggable: false,
|
|
24
|
+
attrs: {
|
|
25
|
+
mappingResource: {},
|
|
26
|
+
codelistResource: {
|
|
27
|
+
default: null,
|
|
28
|
+
},
|
|
29
|
+
variableInstance: {},
|
|
30
|
+
source: {
|
|
31
|
+
default: null,
|
|
32
|
+
},
|
|
33
|
+
type: {
|
|
34
|
+
default: 'text',
|
|
35
|
+
},
|
|
36
|
+
datatype: {
|
|
37
|
+
default: null,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
toDOM: (node) => {
|
|
41
|
+
const {
|
|
42
|
+
mappingResource,
|
|
43
|
+
codelistResource,
|
|
44
|
+
variableInstance,
|
|
45
|
+
type,
|
|
46
|
+
datatype,
|
|
47
|
+
source,
|
|
48
|
+
} = node.attrs;
|
|
49
|
+
const sourceSpan = source
|
|
50
|
+
? [
|
|
51
|
+
[
|
|
52
|
+
'span',
|
|
53
|
+
{ property: DCT('source').prefixed, resource: source as string },
|
|
54
|
+
],
|
|
55
|
+
]
|
|
56
|
+
: [];
|
|
57
|
+
const codelistResourceSpan = codelistResource
|
|
58
|
+
? [
|
|
59
|
+
[
|
|
60
|
+
'span',
|
|
61
|
+
{
|
|
62
|
+
property: EXT('codelist').prefixed, //becomes EXT('instance')
|
|
63
|
+
resource: codelistResource as string,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
]
|
|
67
|
+
: [];
|
|
68
|
+
return [
|
|
69
|
+
'span',
|
|
70
|
+
{
|
|
71
|
+
resource: mappingResource as string,
|
|
72
|
+
typeof: EXT('Mapping').prefixed,
|
|
73
|
+
},
|
|
74
|
+
[
|
|
75
|
+
'span',
|
|
76
|
+
{ property: EXT('instance'), resource: variableInstance as string },
|
|
77
|
+
],
|
|
78
|
+
['span', { property: DCT('type').prefixed, content: type as string }],
|
|
79
|
+
...sourceSpan,
|
|
80
|
+
...codelistResourceSpan,
|
|
81
|
+
[
|
|
82
|
+
'span',
|
|
83
|
+
{
|
|
84
|
+
property: EXT('content').prefixed,
|
|
85
|
+
...(!!datatype && { datatype: datatype as string }),
|
|
86
|
+
},
|
|
87
|
+
0,
|
|
88
|
+
],
|
|
89
|
+
];
|
|
90
|
+
},
|
|
91
|
+
parseDOM: [
|
|
92
|
+
{
|
|
93
|
+
tag: 'span',
|
|
94
|
+
getAttrs: (node: HTMLElement) => {
|
|
95
|
+
if (
|
|
96
|
+
hasRDFaAttribute(node, 'typeof', EXT('Mapping')) &&
|
|
97
|
+
node.querySelector(CONTENT_SELECTOR)
|
|
98
|
+
) {
|
|
99
|
+
const variableInstance = [...node.children]
|
|
100
|
+
.find((el) => hasRDFaAttribute(el, 'property', EXT('instance')))
|
|
101
|
+
?.getAttribute('resource');
|
|
102
|
+
const mappingResource = node.getAttribute('resource');
|
|
103
|
+
const codelistResource = [...node.children]
|
|
104
|
+
.find((el) => hasRDFaAttribute(el, 'property', EXT('codelist')))
|
|
105
|
+
?.getAttribute('resource');
|
|
106
|
+
const source = [...node.children]
|
|
107
|
+
.find((el) => hasRDFaAttribute(el, 'property', DCT('source')))
|
|
108
|
+
?.getAttribute('resource');
|
|
109
|
+
const type = [...node.children]
|
|
110
|
+
.find((el) => hasRDFaAttribute(el, 'property', DCT('type')))
|
|
111
|
+
?.getAttribute('content');
|
|
112
|
+
const datatype = [...node.children]
|
|
113
|
+
.find((el) => hasRDFaAttribute(el, 'property', EXT('content')))
|
|
114
|
+
?.getAttribute('datatype');
|
|
115
|
+
if (!mappingResource) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
variableInstance:
|
|
120
|
+
variableInstance ??
|
|
121
|
+
`http://data.lblod.info/variables/${uuidv4()}`,
|
|
122
|
+
mappingResource,
|
|
123
|
+
codelistResource,
|
|
124
|
+
source,
|
|
125
|
+
type,
|
|
126
|
+
datatype,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
},
|
|
131
|
+
contentElement: CONTENT_SELECTOR,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const variable = createEmberNodeSpec(emberNodeConfig);
|
|
137
|
+
export const variableView = createEmberNodeView(emberNodeConfig);
|