@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.
- package/CHANGELOG.md +48 -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.hbs +2 -2
- package/addon/components/citation-plugin/citation-card.ts +1 -1
- package/addon/components/citation-plugin/citation-insert.hbs +3 -1
- package/addon/components/citation-plugin/citation-insert.ts +28 -2
- package/addon/components/citation-plugin/citations/search-modal.hbs +1 -1
- package/addon/components/citation-plugin/citations/search-modal.ts +3 -18
- 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 +37 -18
- package/addon/components/standard-template-plugin/template-provider.ts +54 -11
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +27 -30
- package/addon/components/table-of-contents-plugin/toolbar-button.hbs +8 -0
- package/addon/components/table-of-contents-plugin/{card.ts → toolbar-button.ts} +1 -18
- 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 +58 -31
- package/addon/plugins/article-structure-plugin/index.ts +1 -1
- package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +42 -6
- package/addon/plugins/article-structure-plugin/structures/article.ts +14 -4
- package/addon/plugins/article-structure-plugin/structures/chapter.ts +2 -3
- package/addon/plugins/article-structure-plugin/structures/section.ts +2 -2
- package/addon/plugins/article-structure-plugin/structures/structure-header.ts +11 -4
- package/addon/plugins/article-structure-plugin/structures/subsection.ts +2 -2
- package/addon/plugins/article-structure-plugin/structures/title.ts +2 -3
- package/addon/plugins/article-structure-plugin/utils/structure.ts +29 -9
- 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/table-of-contents-plugin/index.ts +8 -12
- package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +35 -42
- 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 +22 -0
- package/addon/utils/namespace.ts +60 -0
- package/app/components/{table-of-contents-plugin/card.js → au-dropdown-pill.js} +1 -1
- package/app/components/table-of-contents-plugin/toolbar-button.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/citation-plugin/citation-insert.d.ts +7 -0
- package/components/citation-plugin/citations/search-modal.d.ts +1 -3
- 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/table-of-contents-plugin/ember-nodes/table-of-contents.d.ts +1 -1
- package/components/table-of-contents-plugin/{card.d.ts → toolbar-button.d.ts} +0 -5
- 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 +6 -6
- package/plugins/article-structure-plugin/commands/insert-structure.d.ts +2 -2
- package/plugins/article-structure-plugin/index.d.ts +1 -1
- package/plugins/article-structure-plugin/utils/structure.d.ts +4 -3
- 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/table-of-contents-plugin/index.d.ts +4 -2
- package/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +4 -3
- 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 +8 -7
- package/utils/changed-descendants.d.ts +2 -0
- package/utils/constants.d.ts +10 -0
- package/utils/namespace.d.ts +11 -0
- package/addon/components/table-of-contents-plugin/card.hbs +0 -16
- package/addon/components/template-variable-plugin/template-variable-card.ts +0 -227
- package/addon/plugins/article-structure-plugin/constants.ts +0 -11
- package/addon/plugins/article-structure-plugin/utils/namespace.ts +0 -25
- 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/table-of-contents-plugin/utils/constants.ts +0 -17
- package/addon/plugins/template-variable-plugin/index.ts +0 -6
- package/addon/plugins/template-variable-plugin/utils/constants.ts +0 -2
- package/plugins/article-structure-plugin/constants.d.ts +0 -5
- package/plugins/article-structure-plugin/utils/namespace.d.ts +0 -6
- 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/table-of-contents-plugin/utils/constants.d.ts +0 -7
- package/plugins/template-variable-plugin/index.d.ts +0 -2
- package/plugins/template-variable-plugin/utils/constants.d.ts +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findParentNode } from '@curvenote/prosemirror-utils';
|
|
1
2
|
import { action } from '@ember/object';
|
|
2
3
|
import Component from '@glimmer/component';
|
|
3
4
|
import { tracked } from '@glimmer/tracking';
|
|
@@ -11,13 +12,13 @@ import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
|
11
12
|
* @extends Ember.Component
|
|
12
13
|
*/
|
|
13
14
|
const acceptedTypes = [
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
15
|
+
'https://data.vlaanderen.be/id/concept/BesluitType/4d8f678a-6fa4-4d5f-a2a1-80974e43bf34',
|
|
16
|
+
'https://data.vlaanderen.be/id/concept/BesluitType/7d95fd2e-3cc9-4a4c-a58e-0fbc408c2f9b',
|
|
17
|
+
'https://data.vlaanderen.be/id/concept/BesluitType/3bba9f10-faff-49a6-acaa-85af7f2199a3',
|
|
18
|
+
'https://data.vlaanderen.be/id/concept/BesluitType/0d1278af-b69e-4152-a418-ec5cfd1c7d0b',
|
|
19
|
+
'https://data.vlaanderen.be/id/concept/BesluitType/e8afe7c5-9640-4db8-8f74-3f023bec3241',
|
|
20
|
+
'https://data.vlaanderen.be/id/concept/BesluitType/256bd04a-b74b-4f2a-8f5d-14dda4765af9',
|
|
21
|
+
'https://data.vlaanderen.be/id/concept/BesluitType/67378dd0-5413-474b-8996-d992ef81637a',
|
|
21
22
|
];
|
|
22
23
|
|
|
23
24
|
type Args = {
|
|
@@ -36,25 +37,23 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
36
37
|
return this.args.controller;
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
get schema() {
|
|
41
|
+
return this.args.controller.schema;
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
get showCard() {
|
|
40
45
|
const selection = this.controller.state.selection;
|
|
41
|
-
const
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.includes(quad.object.value)
|
|
54
|
-
);
|
|
55
|
-
})
|
|
56
|
-
.asQuadResultSet(),
|
|
57
|
-
][0];
|
|
58
|
-
return !!besluit;
|
|
46
|
+
const besluitNode = findParentNode((node) => {
|
|
47
|
+
if (node.type === this.schema.nodes['besluit']) {
|
|
48
|
+
const rdfTypes = (node.attrs['typeof'] as string | undefined)?.split(
|
|
49
|
+
' '
|
|
50
|
+
);
|
|
51
|
+
if (rdfTypes?.some((t) => acceptedTypes.includes(t))) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
})(selection);
|
|
57
|
+
return !!besluitNode;
|
|
59
58
|
}
|
|
60
59
|
}
|
|
@@ -16,7 +16,10 @@ import { assert } from '@ember/debug';
|
|
|
16
16
|
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
17
17
|
import Measure from '@lblod/ember-rdfa-editor-lblod-plugins/models/measure';
|
|
18
18
|
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
19
|
-
import {
|
|
19
|
+
import { insertStructure } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/commands';
|
|
20
|
+
import { besluitArticleStructure } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/standard-template-plugin/utils/nodes';
|
|
21
|
+
import IntlService from 'ember-intl/services/intl';
|
|
22
|
+
import { ProseParser } from '@lblod/ember-rdfa-editor';
|
|
20
23
|
|
|
21
24
|
const PAGE_SIZE = 10;
|
|
22
25
|
const SIGN_TYPE_URI =
|
|
@@ -47,6 +50,7 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
47
50
|
|
|
48
51
|
pageSize = PAGE_SIZE;
|
|
49
52
|
@service declare roadsignRegistry: RoadsignRegistryService;
|
|
53
|
+
@service declare intl: IntlService;
|
|
50
54
|
|
|
51
55
|
@tracked typeSelected?: TypeOption;
|
|
52
56
|
|
|
@@ -91,6 +95,10 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
91
95
|
this.search();
|
|
92
96
|
}
|
|
93
97
|
|
|
98
|
+
get schema() {
|
|
99
|
+
return this.args.controller.schema;
|
|
100
|
+
}
|
|
101
|
+
|
|
94
102
|
@action
|
|
95
103
|
selectTypeOrCategory(option: Option) {
|
|
96
104
|
if (!option) {
|
|
@@ -260,7 +268,7 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
260
268
|
}</span>
|
|
261
269
|
<span style="margin-left:0;margin-top:0;">${
|
|
262
270
|
sign.zonality === POTENTIALLY_ZONAL_URI && zonality === ZONAL_URI
|
|
263
|
-
? 'met zonale geldigheid'
|
|
271
|
+
? ' met zonale geldigheid'
|
|
264
272
|
: ''
|
|
265
273
|
}
|
|
266
274
|
</span>
|
|
@@ -270,24 +278,35 @@ export default class RoadsignRegulationCard extends Component<Args> {
|
|
|
270
278
|
})
|
|
271
279
|
.join('\n');
|
|
272
280
|
const regulationHTML = `<div property="mobiliteit:heeftVerkeersmaatregel" typeof="mobiliteit:Mobiliteitsmaatregel" resource="http://data.lblod.info/mobiliteitsmaatregels/${uuid()}">
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
281
|
+
<span style="display:none;" property="prov:wasDerivedFrom" resource="${
|
|
282
|
+
measure.uri
|
|
283
|
+
}"> </span>
|
|
284
|
+
<span style="display:none;" property="ext:zonality" resource="${zonality}"></span>
|
|
285
|
+
<span style="display:none;" property="ext:temporal" value="${measure.temporal.toString()}"></span>
|
|
286
|
+
<div property="dct:description">
|
|
287
|
+
${html}
|
|
288
|
+
<p>Dit wordt aangeduid door verkeerstekens:</p>
|
|
289
|
+
<ul style="list-style:none;">
|
|
290
|
+
${signsHTML}
|
|
291
|
+
</ul>
|
|
292
|
+
${
|
|
293
|
+
temporalValue === 'true'
|
|
294
|
+
? 'Deze signalisatie is dynamisch.'
|
|
295
|
+
: ''
|
|
296
|
+
}
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
`;
|
|
300
|
+
const domParser = new DOMParser();
|
|
301
|
+
const htmlNode = domParser.parseFromString(regulationHTML, 'text/html');
|
|
302
|
+
const contentFragment = ProseParser.fromSchema(
|
|
303
|
+
this.args.controller.schema
|
|
304
|
+
).parseSlice(htmlNode, {
|
|
305
|
+
preserveWhitespace: false,
|
|
306
|
+
}).content;
|
|
288
307
|
|
|
289
308
|
this.args.controller.doCommand(
|
|
290
|
-
|
|
309
|
+
insertStructure(besluitArticleStructure, this.intl, contentFragment)
|
|
291
310
|
);
|
|
292
311
|
this.args.closeModal();
|
|
293
312
|
}
|
|
@@ -6,10 +6,41 @@ import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
|
6
6
|
import TemplateModel from '@lblod/ember-rdfa-editor-lblod-plugins/models/template';
|
|
7
7
|
import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
|
|
8
8
|
import instantiateUuids from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/standard-template-plugin/utils/instantiate-uuids';
|
|
9
|
+
import { PNode, ResolvedPos } from '@lblod/ember-rdfa-editor';
|
|
10
|
+
import { BESLUIT } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
11
|
+
import {
|
|
12
|
+
pnodeHasRdfaAttribute,
|
|
13
|
+
Resource,
|
|
14
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
9
15
|
|
|
10
16
|
type Args = {
|
|
11
17
|
controller: ProseController;
|
|
12
18
|
};
|
|
19
|
+
|
|
20
|
+
const HACKY_LOOKUP: Record<string, Resource> = {
|
|
21
|
+
'http://data.vlaanderen.be/ns/besluit#BehandelingVanAgendapunt': BESLUIT(
|
|
22
|
+
'BehandelingVanAgendapunt'
|
|
23
|
+
),
|
|
24
|
+
'http://data.vlaanderen.be/ns/besluit#Besluit': BESLUIT('Besluit'),
|
|
25
|
+
'http://data.vlaanderen.be/ns/besluit#Artikel': BESLUIT('Artikel'),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function findAncestors(
|
|
29
|
+
pos: ResolvedPos,
|
|
30
|
+
predicate: (node: PNode) => boolean = () => true
|
|
31
|
+
) {
|
|
32
|
+
const result: { node: PNode; pos: number }[] = [];
|
|
33
|
+
let depth = pos.depth;
|
|
34
|
+
while (depth >= 0) {
|
|
35
|
+
const parent = pos.node(depth);
|
|
36
|
+
if (predicate(parent)) {
|
|
37
|
+
result.push({ node: parent, pos: pos.before(depth) });
|
|
38
|
+
}
|
|
39
|
+
depth -= 1;
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
|
|
13
44
|
export default class TemplateProviderComponent extends Component<Args> {
|
|
14
45
|
@service declare standardTemplatePlugin: StandardTemplatePluginService;
|
|
15
46
|
|
|
@@ -34,17 +65,29 @@ export default class TemplateProviderComponent extends Component<Args> {
|
|
|
34
65
|
}
|
|
35
66
|
|
|
36
67
|
templateIsApplicable(template: TemplateModel) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
68
|
+
const { $from } = this.controller.state.selection;
|
|
69
|
+
const containsTypes =
|
|
70
|
+
this.controller.externalContextStore
|
|
71
|
+
.match(null, 'a')
|
|
72
|
+
.dataset.some((quad) => {
|
|
73
|
+
return template.contexts.includes(quad.object.value);
|
|
74
|
+
}) ||
|
|
75
|
+
findAncestors($from, (node) => {
|
|
76
|
+
return template.contexts.some((type) =>
|
|
77
|
+
pnodeHasRdfaAttribute(node, 'typeof', HACKY_LOOKUP[type])
|
|
78
|
+
);
|
|
79
|
+
}).length;
|
|
80
|
+
const containsDisabledTypes =
|
|
81
|
+
this.controller.externalContextStore
|
|
82
|
+
.match(null, 'a')
|
|
83
|
+
.dataset.some((quad) => {
|
|
84
|
+
return template.disabledInContexts.includes(quad.object.value);
|
|
85
|
+
}) ||
|
|
86
|
+
findAncestors($from, (node) => {
|
|
87
|
+
return template.disabledInContexts.some((type) =>
|
|
88
|
+
pnodeHasRdfaAttribute(node, 'typeof', HACKY_LOOKUP[type])
|
|
89
|
+
);
|
|
90
|
+
}).length;
|
|
48
91
|
|
|
49
92
|
return containsTypes && !containsDisabledTypes;
|
|
50
93
|
}
|
|
@@ -3,9 +3,8 @@ import Component from '@glimmer/component';
|
|
|
3
3
|
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
4
4
|
import { EmberNodeArgs } from '@lblod/ember-rdfa-editor/utils/ember-node';
|
|
5
5
|
import { Selection } from '@lblod/ember-rdfa-editor';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { TableOfContentsConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/table-of-contents-plugin/utils/constants';
|
|
6
|
+
import { NodeWithPos } from '@curvenote/prosemirror-utils';
|
|
7
|
+
import { TableOfContentsConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/table-of-contents-plugin';
|
|
9
8
|
type OutlineEntry = {
|
|
10
9
|
content: string;
|
|
11
10
|
pos: number;
|
|
@@ -33,34 +32,32 @@ export default class TableOfContentsComponent extends Component<EmberNodeArgs> {
|
|
|
33
32
|
extractOutline({ node, pos }: { node: PNode; pos: number }): OutlineEntry[] {
|
|
34
33
|
let result: OutlineEntry[] = [];
|
|
35
34
|
let parent: OutlineEntry | undefined;
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
break;
|
|
48
|
-
} else {
|
|
49
|
-
const range = [
|
|
50
|
-
...this.args.controller.datastore
|
|
51
|
-
.match(`>${resource}`, `>${tocConfigEntry.value.predicate}`)
|
|
52
|
-
.asPredicateNodeMapping()
|
|
53
|
-
.nodes(),
|
|
54
|
-
][0];
|
|
55
|
-
if (range) {
|
|
56
|
-
const node = unwrap(this.controller.state.doc.nodeAt(range.from));
|
|
57
|
-
parent = {
|
|
58
|
-
content: node.textContent,
|
|
59
|
-
pos: range.from,
|
|
60
|
-
};
|
|
61
|
-
break;
|
|
35
|
+
for (const option of this.config) {
|
|
36
|
+
const { nodeHierarchy } = option;
|
|
37
|
+
if (RegExp(`^${nodeHierarchy[0]}$`).exec(node.type.name)) {
|
|
38
|
+
let i = 1;
|
|
39
|
+
let currentNode: NodeWithPos | undefined = { node, pos };
|
|
40
|
+
while (currentNode && i < nodeHierarchy.length) {
|
|
41
|
+
let newCurrentNode: NodeWithPos | undefined;
|
|
42
|
+
currentNode.node.forEach((child, offset) => {
|
|
43
|
+
if (RegExp(`^${nodeHierarchy[i]}$`).exec(child.type.name)) {
|
|
44
|
+
newCurrentNode = { pos: pos + offset, node: child };
|
|
45
|
+
return;
|
|
62
46
|
}
|
|
63
|
-
}
|
|
47
|
+
});
|
|
48
|
+
currentNode = newCurrentNode;
|
|
49
|
+
i++;
|
|
50
|
+
}
|
|
51
|
+
if (currentNode) {
|
|
52
|
+
const outlineText = currentNode.node.type.spec.outlineText as
|
|
53
|
+
| ((node: PNode) => string)
|
|
54
|
+
| undefined;
|
|
55
|
+
const content =
|
|
56
|
+
outlineText?.(currentNode.node) ?? currentNode.node.textContent;
|
|
57
|
+
parent = {
|
|
58
|
+
pos: currentNode.pos,
|
|
59
|
+
content,
|
|
60
|
+
};
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<label class="au-c-toggle-switch">
|
|
2
|
+
<input type="checkbox"
|
|
3
|
+
checked={{this.toggled}}
|
|
4
|
+
class="au-c-toggle-switch__input au-u-hidden-visually"
|
|
5
|
+
{{on "input" this.toggle}}/>
|
|
6
|
+
<span class="au-c-toggle-switch__toggle"></span>
|
|
7
|
+
<span class="au-c-toggle-switch__label">{{t "table-of-contents-plugin.toggle" }}</span>
|
|
8
|
+
</label>
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { action } from '@ember/object';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
|
-
import {
|
|
4
|
-
TableOfContentsConfig,
|
|
5
|
-
TABLE_OF_CONTENTS_DEFAULT_CONFIG,
|
|
6
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/table-of-contents-plugin/utils/constants';
|
|
7
3
|
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
8
4
|
|
|
9
5
|
type Args = {
|
|
10
6
|
controller: ProseController;
|
|
11
|
-
widgetArgs: {
|
|
12
|
-
config: TableOfContentsConfig;
|
|
13
|
-
};
|
|
14
7
|
};
|
|
15
8
|
|
|
16
9
|
export default class TableOfContentsCardComponent extends Component<Args> {
|
|
@@ -33,10 +26,6 @@ export default class TableOfContentsCardComponent extends Component<Args> {
|
|
|
33
26
|
return result;
|
|
34
27
|
}
|
|
35
28
|
|
|
36
|
-
get config() {
|
|
37
|
-
return this.args.widgetArgs.config ?? TABLE_OF_CONTENTS_DEFAULT_CONFIG;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
29
|
@action
|
|
41
30
|
toggle() {
|
|
42
31
|
if (this.tableOfContentsRange) {
|
|
@@ -47,13 +36,7 @@ export default class TableOfContentsCardComponent extends Component<Args> {
|
|
|
47
36
|
} else {
|
|
48
37
|
const { schema } = this.controller;
|
|
49
38
|
this.controller.withTransaction((tr) => {
|
|
50
|
-
return tr.replaceRangeWith(
|
|
51
|
-
0,
|
|
52
|
-
0,
|
|
53
|
-
schema.node('table_of_contents', {
|
|
54
|
-
config: this.config,
|
|
55
|
-
})
|
|
56
|
-
);
|
|
39
|
+
return tr.replaceRangeWith(0, 0, schema.node('table_of_contents'));
|
|
57
40
|
});
|
|
58
41
|
}
|
|
59
42
|
}
|
package/addon/components/{insert-variable-plugin → variable-plugin}/insert-variable-card.hbs
RENAMED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
<div {{did-update this.selectionChanged @controller.state}}>
|
|
2
1
|
{{#if this.showCard}}
|
|
3
2
|
<AuCard @flex={{true}} @divided={{true}} @isOpenInitially={{true}} @expandable={{true}} @shadow={{true}} @size="small" as |c|>
|
|
4
3
|
<c.header>
|
|
5
4
|
<AuHeading @level="3" @skin="6">
|
|
6
|
-
{{t "
|
|
5
|
+
{{t "variable-plugin.insertVariable"}}
|
|
7
6
|
</AuHeading>
|
|
8
7
|
</c.header>
|
|
9
8
|
<c.content>
|
|
@@ -27,8 +26,9 @@
|
|
|
27
26
|
{{subtype.label}}
|
|
28
27
|
</PowerSelect>
|
|
29
28
|
{{/if}}
|
|
30
|
-
<AuButton {{on 'click' this.insert}} @disabled={{or (not this.selectedVariable)
|
|
29
|
+
<AuButton {{on 'click' this.insert}} @disabled={{or (not this.selectedVariable)
|
|
30
|
+
(and this.hasSubtype (not this.selectedSubtype))}}>{{t
|
|
31
|
+
"variable-plugin.button"}}</AuButton>
|
|
31
32
|
</c.content>
|
|
32
33
|
</AuCard>
|
|
33
34
|
{{/if}}
|
|
34
|
-
</div>
|
|
@@ -2,14 +2,14 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { task } from 'ember-concurrency';
|
|
5
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
6
5
|
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
7
|
-
import { insertHtml } from '@lblod/ember-rdfa-editor/commands/insert-html-command';
|
|
8
6
|
import {
|
|
9
7
|
DEFAULT_VARIABLE_TYPES,
|
|
10
8
|
VariableType,
|
|
11
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/
|
|
12
|
-
import { CodeList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/
|
|
9
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/constants';
|
|
10
|
+
import { CodeList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/fetch-data';
|
|
11
|
+
import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
|
|
12
|
+
import { NodeSelection } from '@lblod/ember-rdfa-editor';
|
|
13
13
|
type Args = {
|
|
14
14
|
controller: ProseController;
|
|
15
15
|
widgetArgs: {
|
|
@@ -24,7 +24,6 @@ type Args = {
|
|
|
24
24
|
export default class EditorPluginsInsertCodelistCardComponent extends Component<Args> {
|
|
25
25
|
@tracked variablesArray: VariableType[];
|
|
26
26
|
@tracked selectedVariable?: VariableType;
|
|
27
|
-
@tracked showCard = true;
|
|
28
27
|
@tracked hasSubtype = false;
|
|
29
28
|
@tracked selectedSubtype?: CodeList;
|
|
30
29
|
@tracked subtypes?: CodeList[];
|
|
@@ -68,19 +67,14 @@ export default class EditorPluginsInsertCodelistCardComponent extends Component<
|
|
|
68
67
|
if (!this.selectedVariable) {
|
|
69
68
|
return;
|
|
70
69
|
}
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
variableContent = this.selectedVariable.template;
|
|
80
|
-
}
|
|
81
|
-
const htmlToInsert = `<span resource="${uri}" typeof="ext:Mapping">${variableContent}</span>`;
|
|
82
|
-
const { from, to } = this.args.controller.state.selection;
|
|
83
|
-
this.args.controller.doCommand(insertHtml(htmlToInsert, from, to));
|
|
70
|
+
const node = this.selectedVariable.constructor(
|
|
71
|
+
this.args.controller.schema,
|
|
72
|
+
this.endpoint,
|
|
73
|
+
this.selectedSubtype
|
|
74
|
+
);
|
|
75
|
+
this.args.controller.withTransaction((tr) => {
|
|
76
|
+
return tr.replaceSelectionWith(node);
|
|
77
|
+
});
|
|
84
78
|
}
|
|
85
79
|
|
|
86
80
|
@action
|
|
@@ -111,24 +105,21 @@ export default class EditorPluginsInsertCodelistCardComponent extends Component<
|
|
|
111
105
|
this.selectedSubtype = subtype;
|
|
112
106
|
}
|
|
113
107
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
const quad = limitedDatastore
|
|
125
|
-
.match(null, 'a', 'ext:Mapping')
|
|
126
|
-
.asQuadResultSet()
|
|
127
|
-
.first();
|
|
128
|
-
if (quad) {
|
|
129
|
-
this.showCard = false;
|
|
108
|
+
get showCard() {
|
|
109
|
+
if (this.args.controller.inEmbeddedView) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
const { selection } = this.args.controller.state;
|
|
113
|
+
if (
|
|
114
|
+
selection instanceof NodeSelection &&
|
|
115
|
+
selection.node.type === this.args.controller.schema.nodes.variable
|
|
116
|
+
) {
|
|
117
|
+
return false;
|
|
130
118
|
} else {
|
|
131
|
-
|
|
119
|
+
const variable = findParentNodeOfType(
|
|
120
|
+
this.args.controller.schema.nodes.variable
|
|
121
|
+
)(selection);
|
|
122
|
+
return !variable;
|
|
132
123
|
}
|
|
133
124
|
}
|
|
134
125
|
}
|
package/addon/components/{template-variable-plugin → variable-plugin}/template-variable-card.hbs
RENAMED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<AuCard @flex={{true}} @divided={{true}} @isOpenInitially={{true}} @expandable={{true}} @shadow={{true}} @size="small" as |c|>
|
|
4
4
|
<c.header>
|
|
5
5
|
<AuHeading @level="3" @skin="6">
|
|
6
|
-
|
|
6
|
+
{{t "variable-plugin.enterVariableValue"}}
|
|
7
7
|
</AuHeading>
|
|
8
8
|
</c.header>
|
|
9
9
|
<c.content>
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
@allowClear={{false}}
|
|
13
13
|
@searchEnabled={{false}}
|
|
14
14
|
@options={{this.variableOptions}}
|
|
15
|
-
@selected={{this.
|
|
16
|
-
@onChange={{this.
|
|
15
|
+
@selected={{this.selectedVariableOption}}
|
|
16
|
+
@onChange={{this.updateVariableOption}} as |variable|
|
|
17
17
|
>
|
|
18
18
|
{{variable.label}}
|
|
19
19
|
</PowerSelectMultiple>
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
@allowClear={{false}}
|
|
23
23
|
@searchEnabled={{false}}
|
|
24
24
|
@options={{this.variableOptions}}
|
|
25
|
-
@selected={{this.
|
|
26
|
-
@onChange={{this.
|
|
25
|
+
@selected={{this.selectedVariableOption}}
|
|
26
|
+
@onChange={{this.updateVariableOption}} as |variable|
|
|
27
27
|
>
|
|
28
28
|
{{variable.label}}
|
|
29
29
|
</PowerSelect>
|
|
30
30
|
{{/if}}
|
|
31
|
-
<AuButton {{on 'click' this.insert}} @disabled={{not this.
|
|
31
|
+
<AuButton {{on 'click' this.insert}} @disabled={{not this.selectedVariableOption}}>Voeg in</AuButton>
|
|
32
32
|
</c.content>
|
|
33
33
|
</AuCard>
|
|
34
34
|
{{/if}}
|