@lblod/ember-rdfa-editor-lblod-plugins 1.0.0-alpha.3 → 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.
Files changed (124) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/addon/components/article-structure-plugin/article-structure-card.hbs +3 -1
  3. package/addon/components/au-dropdown-pill.hbs +32 -0
  4. package/addon/components/au-dropdown-pill.ts +65 -0
  5. package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +19 -12
  6. package/addon/components/citation-plugin/citation-card.hbs +2 -2
  7. package/addon/components/citation-plugin/citation-card.ts +1 -1
  8. package/addon/components/citation-plugin/citation-insert.hbs +3 -1
  9. package/addon/components/citation-plugin/citation-insert.ts +28 -2
  10. package/addon/components/citation-plugin/citations/search-modal.hbs +1 -1
  11. package/addon/components/citation-plugin/citations/search-modal.ts +3 -18
  12. package/addon/components/import-snippet-plugin/card.ts +8 -12
  13. package/addon/components/rdfa-date-plugin/card.hbs +28 -0
  14. package/addon/components/rdfa-date-plugin/card.ts +72 -38
  15. package/addon/components/rdfa-date-plugin/date-time-picker.ts +1 -0
  16. package/addon/components/rdfa-date-plugin/insert.hbs +2 -2
  17. package/addon/components/rdfa-date-plugin/insert.ts +14 -23
  18. package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +24 -25
  19. package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +37 -18
  20. package/addon/components/standard-template-plugin/template-provider.ts +54 -11
  21. package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +27 -30
  22. package/addon/components/table-of-contents-plugin/toolbar-button.hbs +8 -0
  23. package/addon/components/table-of-contents-plugin/{card.ts → toolbar-button.ts} +1 -18
  24. package/addon/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.hbs +4 -4
  25. package/addon/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.ts +26 -35
  26. package/addon/components/{template-variable-plugin → variable-plugin}/template-variable-card.hbs +6 -6
  27. package/addon/components/variable-plugin/template-variable-card.ts +174 -0
  28. package/addon/components/variable-plugin/variable.hbs +4 -0
  29. package/addon/components/variable-plugin/variable.ts +250 -0
  30. package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +58 -31
  31. package/addon/plugins/article-structure-plugin/index.ts +1 -1
  32. package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +42 -6
  33. package/addon/plugins/article-structure-plugin/structures/article.ts +14 -4
  34. package/addon/plugins/article-structure-plugin/structures/chapter.ts +2 -3
  35. package/addon/plugins/article-structure-plugin/structures/section.ts +2 -2
  36. package/addon/plugins/article-structure-plugin/structures/structure-header.ts +11 -4
  37. package/addon/plugins/article-structure-plugin/structures/subsection.ts +2 -2
  38. package/addon/plugins/article-structure-plugin/structures/title.ts +2 -3
  39. package/addon/plugins/article-structure-plugin/utils/structure.ts +29 -9
  40. package/addon/plugins/citation-plugin/index.ts +184 -113
  41. package/addon/plugins/rdfa-date-plugin/index.ts +42 -3
  42. package/addon/plugins/rdfa-date-plugin/nodes/date.ts +127 -0
  43. package/addon/plugins/rdfa-date-plugin/nodes/index.ts +1 -0
  44. package/addon/plugins/rdfa-date-plugin/utils.ts +10 -0
  45. package/addon/plugins/roadsign-regulation-plugin/nodes.ts +107 -0
  46. package/addon/plugins/standard-template-plugin/index.ts +26 -0
  47. package/addon/plugins/standard-template-plugin/utils/nodes.ts +366 -0
  48. package/addon/plugins/table-of-contents-plugin/index.ts +8 -12
  49. package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +35 -42
  50. package/addon/plugins/{insert-variable-plugin → variable-plugin}/index.ts +6 -1
  51. package/addon/plugins/variable-plugin/nodes.ts +137 -0
  52. package/addon/plugins/variable-plugin/utils/constants.ts +107 -0
  53. package/addon/plugins/{template-variable-plugin → variable-plugin}/utils/fetch-data.ts +41 -0
  54. package/addon/services/standard-template-plugin.ts +16 -12
  55. package/addon/utils/changed-descendants.ts +29 -0
  56. package/addon/utils/constants.ts +22 -0
  57. package/addon/utils/namespace.ts +60 -0
  58. package/app/components/{table-of-contents-plugin/card.js → au-dropdown-pill.js} +1 -1
  59. package/app/components/table-of-contents-plugin/toolbar-button.js +1 -0
  60. package/app/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.js +1 -1
  61. package/app/components/{template-variable-plugin → variable-plugin}/template-variable-card.js +1 -1
  62. package/app/components/variable-plugin/variable-edit-modal.js +1 -0
  63. package/app/components/variable-plugin/variable.js +1 -0
  64. package/app/styles/date-plugin.scss +17 -0
  65. package/app/styles/variable-plugin.scss +65 -0
  66. package/components/au-dropdown-pill.d.ts +19 -0
  67. package/components/au-native-input.d.ts +1 -1
  68. package/components/citation-plugin/citation-card.d.ts +1 -1
  69. package/components/citation-plugin/citation-insert.d.ts +7 -0
  70. package/components/citation-plugin/citations/search-modal.d.ts +1 -3
  71. package/components/rdfa-date-plugin/card.d.ts +14 -5
  72. package/components/rdfa-date-plugin/insert.d.ts +1 -2
  73. package/components/roadsign-regulation-plugin/roadsign-regulation-card.d.ts +1 -0
  74. package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +3 -0
  75. package/components/standard-template-plugin/template-provider.d.ts +6 -1
  76. package/components/table-of-contents-plugin/ember-nodes/table-of-contents.d.ts +1 -1
  77. package/components/table-of-contents-plugin/{card.d.ts → toolbar-button.d.ts} +0 -5
  78. package/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.d.ts +3 -4
  79. package/components/{template-variable-plugin → variable-plugin}/template-variable-card.d.ts +8 -5
  80. package/components/variable-plugin/variable.d.ts +42 -0
  81. package/package.json +6 -6
  82. package/plugins/article-structure-plugin/commands/insert-structure.d.ts +2 -2
  83. package/plugins/article-structure-plugin/index.d.ts +1 -1
  84. package/plugins/article-structure-plugin/utils/structure.d.ts +4 -3
  85. package/plugins/citation-plugin/index.d.ts +11 -4
  86. package/plugins/rdfa-date-plugin/index.d.ts +13 -1
  87. package/plugins/rdfa-date-plugin/nodes/date.d.ts +9 -0
  88. package/plugins/rdfa-date-plugin/nodes/index.d.ts +1 -0
  89. package/plugins/rdfa-date-plugin/utils.d.ts +1 -0
  90. package/plugins/roadsign-regulation-plugin/nodes.d.ts +2 -0
  91. package/plugins/standard-template-plugin/index.d.ts +12 -0
  92. package/plugins/standard-template-plugin/utils/nodes.d.ts +12 -0
  93. package/plugins/table-of-contents-plugin/index.d.ts +4 -2
  94. package/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +4 -3
  95. package/plugins/{insert-variable-plugin → variable-plugin}/index.d.ts +1 -0
  96. package/plugins/variable-plugin/nodes.d.ts +2 -0
  97. package/plugins/variable-plugin/utils/constants.d.ts +9 -0
  98. package/plugins/{template-variable-plugin → variable-plugin}/utils/fetch-data.d.ts +5 -0
  99. package/services/standard-template-plugin.d.ts +9 -10
  100. package/translations/en-US.yaml +4 -3
  101. package/translations/nl-BE.yaml +8 -7
  102. package/utils/changed-descendants.d.ts +2 -0
  103. package/utils/constants.d.ts +10 -0
  104. package/utils/namespace.d.ts +11 -0
  105. package/addon/components/table-of-contents-plugin/card.hbs +0 -16
  106. package/addon/components/template-variable-plugin/template-variable-card.ts +0 -227
  107. package/addon/plugins/article-structure-plugin/constants.ts +0 -11
  108. package/addon/plugins/article-structure-plugin/utils/namespace.ts +0 -25
  109. package/addon/plugins/insert-variable-plugin/utils/constants.ts +0 -67
  110. package/addon/plugins/insert-variable-plugin/utils/fetch-data.ts +0 -41
  111. package/addon/plugins/rdfa-date-plugin/commands/index.ts +0 -1
  112. package/addon/plugins/rdfa-date-plugin/commands/modify-date.ts +0 -48
  113. package/addon/plugins/table-of-contents-plugin/utils/constants.ts +0 -17
  114. package/addon/plugins/template-variable-plugin/index.ts +0 -6
  115. package/addon/plugins/template-variable-plugin/utils/constants.ts +0 -2
  116. package/plugins/article-structure-plugin/constants.d.ts +0 -5
  117. package/plugins/article-structure-plugin/utils/namespace.d.ts +0 -6
  118. package/plugins/insert-variable-plugin/utils/constants.d.ts +0 -7
  119. package/plugins/insert-variable-plugin/utils/fetch-data.d.ts +0 -5
  120. package/plugins/rdfa-date-plugin/commands/index.d.ts +0 -1
  121. package/plugins/rdfa-date-plugin/commands/modify-date.d.ts +0 -2
  122. package/plugins/table-of-contents-plugin/utils/constants.d.ts +0 -7
  123. package/plugins/template-variable-plugin/index.d.ts +0 -2
  124. 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
+ };
@@ -1,14 +1,10 @@
1
1
  import { WidgetSpec } from '@lblod/ember-rdfa-editor';
2
- import { TableOfContentsConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/table-of-contents-plugin/utils/constants';
3
2
 
4
- export function tableOfContentsWidget(
5
- config?: TableOfContentsConfig
6
- ): WidgetSpec {
7
- return {
8
- componentName: 'table-of-contents-plugin/card',
9
- desiredLocation: 'sidebar',
10
- widgetArgs: {
11
- config,
12
- },
13
- };
14
- }
3
+ export type TableOfContentsConfig = {
4
+ nodeHierarchy: string[];
5
+ }[];
6
+
7
+ export const tableOfContentsWidget: WidgetSpec = {
8
+ componentName: 'table-of-contents-plugin/toolbar-button',
9
+ desiredLocation: 'toolbarRight',
10
+ };
@@ -1,53 +1,46 @@
1
- import { optionMapOr } from '@lblod/ember-rdfa-editor/utils/option';
2
1
  import {
3
2
  createEmberNodeSpec,
4
3
  createEmberNodeView,
5
4
  EmberNodeConfig,
6
5
  } from '@lblod/ember-rdfa-editor/utils/ember-node';
7
- import {
8
- TableOfContentsConfig,
9
- TABLE_OF_CONTENTS_DEFAULT_CONFIG,
10
- } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/table-of-contents-plugin/utils/constants';
6
+ import { TableOfContentsConfig } from '..';
11
7
 
12
- export const emberNodeConfig: EmberNodeConfig = {
13
- name: 'table-of-contents',
14
- componentPath: 'table-of-contents-plugin/ember-nodes/table-of-contents',
15
- inline: false,
16
- group: 'table_of_contents',
17
- atom: true,
18
- attrs: {
19
- config: {
20
- default: TABLE_OF_CONTENTS_DEFAULT_CONFIG,
21
- serialize: (node) => {
22
- return JSON.stringify(node.attrs['config']);
8
+ export const emberNodeConfig: (
9
+ config: TableOfContentsConfig
10
+ ) => EmberNodeConfig = (config) => {
11
+ return {
12
+ name: 'table-of-contents',
13
+ componentPath: 'table-of-contents-plugin/ember-nodes/table-of-contents',
14
+ inline: false,
15
+ group: 'table_of_contents',
16
+ atom: true,
17
+ attrs: {
18
+ config: {
19
+ default: config,
23
20
  },
24
21
  },
25
- },
26
- parseDOM: [
27
- {
28
- tag: 'div',
29
- getAttrs(element: HTMLElement) {
30
- if (
31
- element.dataset['emberNode'] === 'table-of-contents' ||
32
- // Ensure backwards compatibility
33
- element.dataset['inlineComponent'] ===
34
- 'inline-components/table-of-contents' ||
35
- (element.classList.contains('inline-component') &&
36
- element.classList.contains('inline-components/table-of-contents'))
37
- ) {
38
- return {
39
- config: optionMapOr(
40
- TABLE_OF_CONTENTS_DEFAULT_CONFIG,
41
- JSON.parse,
42
- element.getAttribute('config')
43
- ) as TableOfContentsConfig,
44
- };
45
- }
46
- return false;
22
+ parseDOM: [
23
+ {
24
+ tag: 'div',
25
+ getAttrs(element: HTMLElement) {
26
+ if (
27
+ element.dataset['emberNode'] === 'table-of-contents' ||
28
+ // Ensure backwards compatibility
29
+ element.dataset['inlineComponent'] ===
30
+ 'inline-components/table-of-contents' ||
31
+ (element.classList.contains('inline-component') &&
32
+ element.classList.contains('inline-components/table-of-contents'))
33
+ ) {
34
+ return {};
35
+ }
36
+ return false;
37
+ },
47
38
  },
48
- },
49
- ],
39
+ ],
40
+ };
50
41
  };
51
42
 
52
- export const table_of_contents = createEmberNodeSpec(emberNodeConfig);
53
- export const tableOfContentsView = createEmberNodeView(emberNodeConfig);
43
+ export const table_of_contents = (config: TableOfContentsConfig) =>
44
+ createEmberNodeSpec(emberNodeConfig(config));
45
+ export const tableOfContentsView = (config: TableOfContentsConfig) =>
46
+ createEmberNodeView(emberNodeConfig(config));
@@ -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: 'insert-variable-plugin/insert-variable-card',
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
+ };