@lblod/ember-rdfa-editor-lblod-plugins 2.1.2 → 4.0.1
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/.woodpecker/.release.yml +1 -1
- package/.woodpecker/.test-scenarios.yml +17 -0
- package/.woodpecker/.test.yml +5 -5
- package/CHANGELOG.md +61 -1
- package/README.md +184 -141
- package/addon/components/article-structure-plugin/article-structure-card.hbs +1 -3
- package/addon/components/article-structure-plugin/article-structure-card.ts +14 -8
- package/addon/components/article-structure-plugin/structure-card.hbs +9 -4
- package/addon/components/article-structure-plugin/structure-card.ts +19 -15
- package/addon/components/besluit-plugin/besluit-plugin-card.ts +8 -4
- package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +2 -2
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +12 -10
- package/addon/components/citation-plugin/citation-card.hbs +4 -0
- package/addon/components/citation-plugin/citation-card.ts +42 -33
- package/addon/components/citation-plugin/citation-insert.ts +32 -37
- package/addon/components/import-snippet-plugin/card.ts +9 -6
- package/addon/components/rdfa-date-plugin/card.ts +16 -20
- package/addon/components/rdfa-date-plugin/insert.hbs +0 -9
- package/addon/components/rdfa-date-plugin/insert.ts +12 -20
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.ts +3 -3
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.ts +5 -4
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.ts +1 -1
- package/addon/components/standard-template-plugin/card.ts +2 -2
- package/addon/components/standard-template-plugin/template-provider.ts +6 -5
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +1 -1
- package/addon/components/table-of-contents-plugin/toolbar-button.ts +45 -8
- package/addon/components/variable-plugin/insert-variable-card.hbs +23 -9
- package/addon/components/variable-plugin/insert-variable-card.ts +19 -14
- package/addon/components/variable-plugin/template-variable-card.hbs +1 -1
- package/addon/components/variable-plugin/template-variable-card.ts +10 -7
- package/addon/components/variable-plugin/variable.hbs +8 -3
- package/addon/models/instruction.ts +1 -1
- package/addon/models/measure.ts +1 -1
- package/addon/models/sign.ts +1 -1
- package/addon/plugins/article-structure-plugin/commands/move-selected-structure.ts +1 -1
- package/addon/plugins/article-structure-plugin/index.ts +2 -32
- package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +17 -8
- package/addon/plugins/article-structure-plugin/structures/article.ts +7 -3
- package/addon/plugins/article-structure-plugin/structures/chapter.ts +1 -1
- package/addon/plugins/article-structure-plugin/structures/section.ts +1 -1
- package/addon/plugins/article-structure-plugin/structures/structure-header.ts +7 -2
- package/addon/plugins/article-structure-plugin/structures/subsection.ts +1 -1
- package/addon/plugins/article-structure-plugin/structures/title.ts +1 -1
- package/addon/plugins/besluit-plugin/utils/get-title-for-decision.ts +3 -6
- package/addon/plugins/citation-plugin/index.ts +17 -55
- package/addon/plugins/citation-plugin/utils/cited-text.ts +5 -4
- package/addon/plugins/rdfa-date-plugin/index.ts +5 -28
- package/addon/plugins/rdfa-date-plugin/nodes/date.ts +1 -6
- package/addon/plugins/standard-template-plugin/index.ts +0 -6
- package/addon/plugins/standard-template-plugin/utils/nodes.ts +1 -1
- package/addon/plugins/table-of-contents-plugin/index.ts +0 -7
- package/addon/plugins/variable-plugin/utils/constants.ts +1 -0
- package/addon/services/roadsign-registry.ts +1 -1
- package/app/styles/article-structure-plugin.scss +7 -0
- package/app/styles/besluit-plugin.scss +4 -0
- package/app/styles/variable-plugin.scss +1 -1
- package/components/article-structure-plugin/article-structure-card.d.ts +4 -5
- package/components/article-structure-plugin/structure-card.d.ts +4 -6
- package/components/besluit-plugin/besluit-plugin-card.d.ts +3 -3
- package/components/besluit-type-plugin/toolbar-dropdown.d.ts +3 -3
- package/components/citation-plugin/citation-card.d.ts +7 -8
- package/components/citation-plugin/citation-insert.d.ts +5 -10
- package/components/import-snippet-plugin/card.d.ts +3 -3
- package/components/rdfa-date-plugin/card.d.ts +6 -11
- package/components/rdfa-date-plugin/insert.d.ts +6 -12
- package/components/roadsign-regulation-plugin/roadsign-regulation-card.d.ts +3 -3
- package/components/roadsign-regulation-plugin/roadsigns-modal.d.ts +2 -2
- package/components/standard-template-plugin/card.d.ts +3 -3
- package/components/standard-template-plugin/template-provider.d.ts +3 -3
- package/components/table-of-contents-plugin/ember-nodes/table-of-contents.d.ts +1 -1
- package/components/table-of-contents-plugin/toolbar-button.d.ts +3 -3
- package/components/variable-plugin/insert-variable-card.d.ts +7 -8
- package/components/variable-plugin/template-variable-card.d.ts +3 -3
- package/package.json +26 -29
- package/plugins/article-structure-plugin/index.d.ts +2 -3
- package/plugins/besluit-plugin/utils/get-title-for-decision.d.ts +3 -3
- package/plugins/citation-plugin/index.d.ts +2 -12
- package/plugins/rdfa-date-plugin/index.d.ts +5 -5
- package/plugins/rdfa-date-plugin/nodes/date.d.ts +1 -6
- package/plugins/standard-template-plugin/index.d.ts +0 -2
- package/plugins/table-of-contents-plugin/index.d.ts +0 -2
- package/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +1 -1
- package/plugins/variable-plugin/nodes.d.ts +1 -1
- package/translations/en-US.yaml +63 -61
- package/translations/nl-BE.yaml +65 -59
- package/addon/components/variable-plugin/variable.ts +0 -262
- package/addon/plugins/besluit-plugin/index.ts +0 -6
- package/addon/plugins/besluit-type-plugin/index.ts +0 -6
- package/addon/plugins/citation-plugin/marks/citation.ts +0 -27
- package/addon/plugins/import-snippet-plugin.ts +0 -6
- package/addon/plugins/rdfa-date-plugin/nodes/index.ts +0 -1
- package/addon/plugins/roadsign-regulation-plugin/index.ts +0 -6
- package/addon/plugins/variable-plugin/index.ts +0 -16
- package/components/variable-plugin/variable.d.ts +0 -43
- package/plugins/besluit-plugin/index.d.ts +0 -2
- package/plugins/besluit-type-plugin/index.d.ts +0 -2
- package/plugins/citation-plugin/marks/citation.d.ts +0 -2
- package/plugins/import-snippet-plugin.d.ts +0 -2
- package/plugins/rdfa-date-plugin/nodes/index.d.ts +0 -1
- package/plugins/roadsign-regulation-plugin/index.d.ts +0 -2
- package/plugins/variable-plugin/index.d.ts +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
|
-
import {
|
|
3
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
4
4
|
import {
|
|
5
5
|
moveSelectedStructure,
|
|
6
6
|
removeStructure,
|
|
@@ -13,10 +13,8 @@ import { inject as service } from '@ember/service';
|
|
|
13
13
|
import IntlService from 'ember-intl/services/intl';
|
|
14
14
|
|
|
15
15
|
type Args = {
|
|
16
|
-
controller:
|
|
17
|
-
|
|
18
|
-
options: ArticleStructurePluginOptions;
|
|
19
|
-
};
|
|
16
|
+
controller: SayController;
|
|
17
|
+
options: ArticleStructurePluginOptions;
|
|
20
18
|
};
|
|
21
19
|
|
|
22
20
|
export default class EditorPluginsStructureCardComponent extends Component<Args> {
|
|
@@ -30,7 +28,8 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
|
|
|
30
28
|
@action
|
|
31
29
|
moveStructure(direction: 'up' | 'down') {
|
|
32
30
|
this.controller.doCommand(
|
|
33
|
-
moveSelectedStructure(this.structureTypes, direction, this.intl)
|
|
31
|
+
moveSelectedStructure(this.structureTypes, direction, this.intl),
|
|
32
|
+
{ view: this.controller.mainEditorView }
|
|
34
33
|
);
|
|
35
34
|
this.controller.focus();
|
|
36
35
|
}
|
|
@@ -38,9 +37,10 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
|
|
|
38
37
|
@action
|
|
39
38
|
removeStructure() {
|
|
40
39
|
if (this.structure && this.currentStructureType) {
|
|
41
|
-
if (this.removeStructureContent) {
|
|
40
|
+
if (this.removeStructureContent || this.currentStructureType.noUnwrap) {
|
|
42
41
|
this.controller.doCommand(
|
|
43
|
-
removeStructure(this.structure, this.structureTypes)
|
|
42
|
+
removeStructure(this.structure, this.structureTypes),
|
|
43
|
+
{ view: this.controller.mainEditorView }
|
|
44
44
|
);
|
|
45
45
|
} else {
|
|
46
46
|
this.controller.doCommand(
|
|
@@ -50,7 +50,8 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
|
|
|
50
50
|
type: this.currentStructureType,
|
|
51
51
|
},
|
|
52
52
|
this.structureTypes
|
|
53
|
-
)
|
|
53
|
+
),
|
|
54
|
+
{ view: this.controller.mainEditorView }
|
|
54
55
|
);
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -63,7 +64,7 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
get structureTypes() {
|
|
66
|
-
return this.args.
|
|
67
|
+
return this.args.options;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
get structureNodeSpecs() {
|
|
@@ -73,7 +74,7 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
get structure() {
|
|
76
|
-
const currentSelection = this.controller.
|
|
77
|
+
const currentSelection = this.controller.mainEditorState.selection;
|
|
77
78
|
return findAncestorOfType(currentSelection, ...this.structureNodeSpecs);
|
|
78
79
|
}
|
|
79
80
|
|
|
@@ -93,19 +94,21 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
|
|
|
93
94
|
|
|
94
95
|
get canMoveDown() {
|
|
95
96
|
return this.controller.checkCommand(
|
|
96
|
-
moveSelectedStructure(this.structureTypes, 'down', this.intl)
|
|
97
|
+
moveSelectedStructure(this.structureTypes, 'down', this.intl),
|
|
98
|
+
{ view: this.controller.mainEditorView }
|
|
97
99
|
);
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
get canMoveUp() {
|
|
101
103
|
return this.controller.checkCommand(
|
|
102
|
-
moveSelectedStructure(this.structureTypes, 'up', this.intl)
|
|
104
|
+
moveSelectedStructure(this.structureTypes, 'up', this.intl),
|
|
105
|
+
{ view: this.controller.mainEditorView }
|
|
103
106
|
);
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
get canRemoveStructure() {
|
|
107
110
|
if (this.structure && this.currentStructureType) {
|
|
108
|
-
if (this.removeStructureContent) {
|
|
111
|
+
if (this.removeStructureContent || this.currentStructureType.noUnwrap) {
|
|
109
112
|
return true;
|
|
110
113
|
} else {
|
|
111
114
|
return this.controller.checkCommand(
|
|
@@ -115,7 +118,8 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
|
|
|
115
118
|
type: this.currentStructureType,
|
|
116
119
|
},
|
|
117
120
|
this.structureTypes
|
|
118
|
-
)
|
|
121
|
+
),
|
|
122
|
+
{ view: this.controller.mainEditorView }
|
|
119
123
|
);
|
|
120
124
|
}
|
|
121
125
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
3
|
import { insertTitle } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-plugin/commands';
|
|
4
|
-
import {
|
|
4
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
5
5
|
import { inject as service } from '@ember/service';
|
|
6
6
|
import IntlService from 'ember-intl/services/intl';
|
|
7
7
|
|
|
8
8
|
type Args = {
|
|
9
|
-
controller:
|
|
9
|
+
controller: SayController;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export default class BesluitPluginCardComponent extends Component<Args> {
|
|
@@ -21,11 +21,15 @@ export default class BesluitPluginCardComponent extends Component<Args> {
|
|
|
21
21
|
|
|
22
22
|
@action
|
|
23
23
|
insertTitle() {
|
|
24
|
-
this.controller.doCommand(insertTitle(this.intl)
|
|
24
|
+
this.controller.doCommand(insertTitle(this.intl), {
|
|
25
|
+
view: this.controller.mainEditorView,
|
|
26
|
+
});
|
|
25
27
|
this.focus();
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
get canInsertTitle() {
|
|
29
|
-
return this.controller.checkCommand(insertTitle(this.intl)
|
|
31
|
+
return this.controller.checkCommand(insertTitle(this.intl), {
|
|
32
|
+
view: this.controller.mainEditorView,
|
|
33
|
+
});
|
|
30
34
|
}
|
|
31
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<div {{did-update this.updateBesluitTypes @controller.
|
|
1
|
+
<div {{did-update this.updateBesluitTypes @controller.mainEditorState}}
|
|
2
2
|
{{did-update this.updateBesluitTypes this.types.value}}>
|
|
3
3
|
{{#if this.showCard}}
|
|
4
4
|
{{#if this.types.isError}}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
@skin="error"
|
|
7
7
|
@icon="circle-x"
|
|
8
8
|
@iconAlignment="left"
|
|
9
|
-
class="au-c-pill--link"
|
|
9
|
+
class="au-c-pill--link besluit-toolbar-pill"
|
|
10
10
|
{{on "click" this.toggleCard}}>
|
|
11
11
|
{{t "besluit-type-plugin.error-short"}}
|
|
12
12
|
</AuPill>
|
|
@@ -7,16 +7,16 @@ import {
|
|
|
7
7
|
addType,
|
|
8
8
|
removeType,
|
|
9
9
|
} from '@lblod/ember-rdfa-editor/commands/type-commands';
|
|
10
|
-
import {
|
|
10
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
11
11
|
import CurrentSessionService from '@lblod/frontend-gelinkt-notuleren/services/current-session';
|
|
12
12
|
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/plugins/datastore';
|
|
13
|
-
import { unwrap } from '@lblod/ember-rdfa-editor/utils/option';
|
|
14
13
|
import { getRdfaAttribute } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
|
|
15
14
|
import fetchBesluitTypes, {
|
|
16
15
|
BesluitType,
|
|
17
16
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
|
|
18
17
|
import { findAncestorOfType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/utils/structure';
|
|
19
18
|
import { trackedFunction } from 'ember-resources/util/function';
|
|
19
|
+
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
20
20
|
|
|
21
21
|
declare module 'ember__owner' {
|
|
22
22
|
export default interface Owner {
|
|
@@ -25,7 +25,7 @@ declare module 'ember__owner' {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
type Args = {
|
|
28
|
-
controller:
|
|
28
|
+
controller: SayController;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export default class EditorPluginsToolbarDropdownComponent extends Component<Args> {
|
|
@@ -56,7 +56,7 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
get doc() {
|
|
59
|
-
return this.controller.
|
|
59
|
+
return this.controller.mainEditorState.doc;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
types = trackedFunction(this, async () => {
|
|
@@ -71,7 +71,7 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
get currentBesluitRange(): ResolvedPNode | undefined {
|
|
74
|
-
const selection = this.controller.
|
|
74
|
+
const selection = this.controller.mainEditorState.selection;
|
|
75
75
|
const besluit = findAncestorOfType(
|
|
76
76
|
selection,
|
|
77
77
|
this.controller.schema.nodes['besluit']
|
|
@@ -104,7 +104,7 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
const besluit = findAncestorOfType(
|
|
107
|
-
this.controller.
|
|
107
|
+
this.controller.mainEditorState.selection,
|
|
108
108
|
this.controller.schema.nodes['besluit']
|
|
109
109
|
);
|
|
110
110
|
const besluitTypeof = besluit?.node.attrs.typeof as string;
|
|
@@ -206,12 +206,14 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
206
206
|
if (this.besluitType && this.currentBesluitRange) {
|
|
207
207
|
this.cardExpanded = false;
|
|
208
208
|
if (this.previousBesluitType) {
|
|
209
|
-
this.controller.
|
|
210
|
-
removeType(this.currentBesluitRange.from, this.previousBesluitType)
|
|
209
|
+
this.controller.doCommand(
|
|
210
|
+
removeType(this.currentBesluitRange.from, this.previousBesluitType),
|
|
211
|
+
{ view: this.controller.mainEditorView }
|
|
211
212
|
);
|
|
212
213
|
}
|
|
213
|
-
this.controller.
|
|
214
|
-
addType(this.currentBesluitRange.from, this.besluitType.uri)
|
|
214
|
+
this.controller.doCommand(
|
|
215
|
+
addType(this.currentBesluitRange.from, this.besluitType.uri),
|
|
216
|
+
{ view: this.controller.mainEditorView }
|
|
215
217
|
);
|
|
216
218
|
}
|
|
217
219
|
}
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
CitationDecoration,
|
|
20
20
|
CitationPlugin,
|
|
21
21
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
22
|
-
import {
|
|
22
|
+
import { SayController, Transaction } from '@lblod/ember-rdfa-editor';
|
|
23
23
|
import { citedText } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/cited-text';
|
|
24
24
|
import {
|
|
25
25
|
LEGISLATION_TYPES,
|
|
@@ -27,10 +27,8 @@ import {
|
|
|
27
27
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/legislation-types';
|
|
28
28
|
|
|
29
29
|
interface Args {
|
|
30
|
-
controller:
|
|
31
|
-
|
|
32
|
-
plugin: CitationPlugin;
|
|
33
|
-
};
|
|
30
|
+
controller: SayController;
|
|
31
|
+
plugin: CitationPlugin;
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
export default class CitationCardComponent extends Component<Args> {
|
|
@@ -44,8 +42,23 @@ export default class CitationCardComponent extends Component<Args> {
|
|
|
44
42
|
@tracked decision: Decision | null = null;
|
|
45
43
|
@tracked cardText: string | null = null;
|
|
46
44
|
@tracked cardLegislationType: string | null = null;
|
|
45
|
+
@tracked documentLegislationType: Option<string>;
|
|
46
|
+
@tracked documentText: Option<string>;
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
@action
|
|
49
|
+
update() {
|
|
50
|
+
if (this.activeDecoration) {
|
|
51
|
+
const { legislationTypeUri, searchText } = this.activeDecoration?.spec;
|
|
52
|
+
if (legislationTypeUri !== this.documentLegislationType) {
|
|
53
|
+
this.documentLegislationType = legislationTypeUri;
|
|
54
|
+
}
|
|
55
|
+
if (searchText !== this.documentText) {
|
|
56
|
+
this.documentText = searchText;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get controller(): SayController {
|
|
49
62
|
return this.args.controller;
|
|
50
63
|
}
|
|
51
64
|
|
|
@@ -54,26 +67,18 @@ export default class CitationCardComponent extends Component<Args> {
|
|
|
54
67
|
}
|
|
55
68
|
|
|
56
69
|
get plugin() {
|
|
57
|
-
return this.args.
|
|
70
|
+
return this.args.plugin;
|
|
58
71
|
}
|
|
59
72
|
|
|
60
73
|
get decorations() {
|
|
61
|
-
return this.plugin.getState(this.controller.
|
|
74
|
+
return this.plugin.getState(this.controller.mainEditorState)?.highlights;
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
get activeDecoration(): Option<CitationDecoration> {
|
|
65
|
-
const { from, to } = this.controller.
|
|
78
|
+
const { from, to } = this.controller.mainEditorState.selection;
|
|
66
79
|
return this.decorations?.find(from, to)[0];
|
|
67
80
|
}
|
|
68
81
|
|
|
69
|
-
get documentLegislationType(): Option<string> {
|
|
70
|
-
return this.activeDecoration?.spec.legislationTypeUri;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get documentText(): Option<string> {
|
|
74
|
-
return this.activeDecoration?.spec.searchText;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
82
|
get searchText(): string {
|
|
78
83
|
return (this.cardText ?? this.documentText) || '';
|
|
79
84
|
}
|
|
@@ -186,14 +191,16 @@ export default class CitationCardComponent extends Component<Args> {
|
|
|
186
191
|
const uri = decision.uri;
|
|
187
192
|
const title = decision.title ?? '';
|
|
188
193
|
const { from, to } = unwrap(this.activeDecoration);
|
|
189
|
-
this.controller.withTransaction(
|
|
190
|
-
tr
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
this.controller.withTransaction(
|
|
195
|
+
(tr: Transaction) =>
|
|
196
|
+
tr
|
|
197
|
+
.replaceRangeWith(
|
|
198
|
+
from,
|
|
199
|
+
to,
|
|
200
|
+
citedText(this.controller.schema, title, uri)
|
|
201
|
+
)
|
|
202
|
+
.scrollIntoView(),
|
|
203
|
+
{ view: this.controller.mainEditorView }
|
|
197
204
|
);
|
|
198
205
|
}
|
|
199
206
|
|
|
@@ -205,14 +212,16 @@ export default class CitationCardComponent extends Component<Args> {
|
|
|
205
212
|
title = `${decision.title}, ${article.number || ''}`;
|
|
206
213
|
}
|
|
207
214
|
const { from, to } = unwrap(this.activeDecoration);
|
|
208
|
-
this.controller.withTransaction(
|
|
209
|
-
tr
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
this.controller.withTransaction(
|
|
216
|
+
(tr: Transaction) =>
|
|
217
|
+
tr
|
|
218
|
+
.replaceRangeWith(
|
|
219
|
+
from,
|
|
220
|
+
to,
|
|
221
|
+
citedText(this.controller.schema, title, uri)
|
|
222
|
+
)
|
|
223
|
+
.scrollIntoView(),
|
|
224
|
+
{ view: this.controller.mainEditorView }
|
|
216
225
|
);
|
|
217
226
|
}
|
|
218
227
|
|
|
@@ -3,7 +3,7 @@ import { action } from '@ember/object';
|
|
|
3
3
|
import { tracked } from '@glimmer/tracking';
|
|
4
4
|
import {
|
|
5
5
|
Fragment,
|
|
6
|
-
|
|
6
|
+
SayController,
|
|
7
7
|
Slice,
|
|
8
8
|
Transaction,
|
|
9
9
|
} from '@lblod/ember-rdfa-editor';
|
|
@@ -12,10 +12,7 @@ import {
|
|
|
12
12
|
Decision,
|
|
13
13
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/vlaamse-codex';
|
|
14
14
|
import { citedText } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/cited-text';
|
|
15
|
-
import {
|
|
16
|
-
CitationPlugin,
|
|
17
|
-
CitationPluginConfig,
|
|
18
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
15
|
+
import { CitationPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
19
16
|
import {
|
|
20
17
|
LEGISLATION_TYPE_CONCEPTS,
|
|
21
18
|
LEGISLATION_TYPES,
|
|
@@ -24,8 +21,8 @@ import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
|
24
21
|
import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
|
|
25
22
|
|
|
26
23
|
interface Args {
|
|
27
|
-
controller:
|
|
28
|
-
|
|
24
|
+
controller: SayController;
|
|
25
|
+
config: CitationPluginConfig;
|
|
29
26
|
}
|
|
30
27
|
|
|
31
28
|
export default class EditorPluginsCitationInsertComponent extends Component<Args> {
|
|
@@ -35,7 +32,7 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
|
|
|
35
32
|
@tracked legislationType: string | null = null;
|
|
36
33
|
|
|
37
34
|
get config() {
|
|
38
|
-
return this.args.
|
|
35
|
+
return this.args.config;
|
|
39
36
|
}
|
|
40
37
|
|
|
41
38
|
get selectedLegislationTypeUri(): string {
|
|
@@ -63,9 +60,11 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
|
|
|
63
60
|
if (this.controller.inEmbeddedView) {
|
|
64
61
|
return true;
|
|
65
62
|
}
|
|
66
|
-
const { selection } = this.controller.
|
|
63
|
+
const { selection } = this.controller.mainEditorState;
|
|
67
64
|
if (this.config.type === 'ranges') {
|
|
68
|
-
const ranges = this.config.activeInRanges(
|
|
65
|
+
const ranges = this.config.activeInRanges(
|
|
66
|
+
this.controller.mainEditorState
|
|
67
|
+
);
|
|
69
68
|
for (const range of ranges) {
|
|
70
69
|
if (selection.from > range[0] && selection.from < range[1]) {
|
|
71
70
|
return false;
|
|
@@ -75,20 +74,12 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
|
|
|
75
74
|
} else {
|
|
76
75
|
const nodeTypes = this.config.activeInNodeTypes(
|
|
77
76
|
this.controller.schema,
|
|
78
|
-
this.controller.
|
|
77
|
+
this.controller.mainEditorState
|
|
79
78
|
);
|
|
80
79
|
return !findParentNodeOfType([...nodeTypes])(selection);
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
|
|
84
|
-
get plugin() {
|
|
85
|
-
return this.args.widgetArgs.plugin;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
get activeRanges() {
|
|
89
|
-
return this.plugin.getState(this.controller.state)?.activeRanges;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
83
|
get controller() {
|
|
93
84
|
return this.args.controller;
|
|
94
85
|
}
|
|
@@ -113,19 +104,21 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
|
|
|
113
104
|
const type = decision.legislationType?.label || '';
|
|
114
105
|
const uri = decision.uri;
|
|
115
106
|
const title = decision.title ?? '';
|
|
116
|
-
this.controller.withTransaction(
|
|
117
|
-
tr
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
107
|
+
this.controller.withTransaction(
|
|
108
|
+
(tr: Transaction) =>
|
|
109
|
+
tr
|
|
110
|
+
.replaceSelection(
|
|
111
|
+
new Slice(
|
|
112
|
+
Fragment.fromArray([
|
|
113
|
+
this.controller.schema.text(`${type} `),
|
|
114
|
+
citedText(this.controller.schema, title, uri),
|
|
115
|
+
]),
|
|
116
|
+
0,
|
|
117
|
+
0
|
|
118
|
+
)
|
|
126
119
|
)
|
|
127
|
-
|
|
128
|
-
|
|
120
|
+
.scrollIntoView(),
|
|
121
|
+
{ view: this.controller.mainEditorView }
|
|
129
122
|
);
|
|
130
123
|
}
|
|
131
124
|
|
|
@@ -137,12 +130,14 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
|
|
|
137
130
|
if (decision.title) {
|
|
138
131
|
title = `${decision.title}, ${article.number ?? ''}`;
|
|
139
132
|
}
|
|
140
|
-
const { from, to } = this.
|
|
141
|
-
this.controller.withTransaction(
|
|
142
|
-
tr
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
133
|
+
const { from, to } = this.controller.mainEditorState.selection;
|
|
134
|
+
this.controller.withTransaction(
|
|
135
|
+
(tr: Transaction) =>
|
|
136
|
+
tr.replaceWith(from, to, [
|
|
137
|
+
this.controller.schema.text(`${type} `),
|
|
138
|
+
citedText(this.controller.schema, title, uri),
|
|
139
|
+
]),
|
|
140
|
+
{ view: this.controller.mainEditorView }
|
|
146
141
|
);
|
|
147
142
|
}
|
|
148
143
|
}
|
|
@@ -2,13 +2,13 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { inject as service } from '@ember/service';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { ProseParser } from '@lblod/ember-rdfa-editor';
|
|
5
|
-
import {
|
|
5
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
6
6
|
import ImportRdfaSnippet from '@lblod/ember-rdfa-editor-lblod-plugins/services/import-rdfa-snippet';
|
|
7
7
|
import { RdfaSnippet } from '@lblod/ember-rdfa-editor-lblod-plugins/services/import-rdfa-snippet';
|
|
8
8
|
import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
|
|
9
9
|
|
|
10
10
|
type Args = {
|
|
11
|
-
controller:
|
|
11
|
+
controller: SayController;
|
|
12
12
|
};
|
|
13
13
|
export default class ImportSnippetPluginCard extends Component<Args> {
|
|
14
14
|
@service declare importRdfaSnippet: ImportRdfaSnippet;
|
|
@@ -22,7 +22,7 @@ export default class ImportSnippetPluginCard extends Component<Args> {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
get insertRange() {
|
|
25
|
-
const { selection } = this.controller.
|
|
25
|
+
const { selection } = this.controller.mainEditorState;
|
|
26
26
|
const besluit = findParentNodeOfType(this.controller.schema.nodes.besluit)(
|
|
27
27
|
selection
|
|
28
28
|
);
|
|
@@ -41,9 +41,12 @@ export default class ImportSnippetPluginCard extends Component<Args> {
|
|
|
41
41
|
const insertRange = this.insertRange;
|
|
42
42
|
if (insertRange) {
|
|
43
43
|
const node = this.generateSnippetHtml(snippet, type);
|
|
44
|
-
this.controller.withTransaction(
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
this.controller.withTransaction(
|
|
45
|
+
(tr) => {
|
|
46
|
+
return tr.replaceRangeWith(insertRange.from, insertRange.to, node);
|
|
47
|
+
},
|
|
48
|
+
{ view: this.controller.mainEditorView }
|
|
49
|
+
);
|
|
47
50
|
this.importRdfaSnippet.removeSnippet(snippet);
|
|
48
51
|
} else {
|
|
49
52
|
console.warn('Could not find a range to insert, so we skipped inserting');
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
|
-
import {
|
|
4
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
5
5
|
import { NodeSelection, PNode } from '@lblod/ember-rdfa-editor';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
DateFormat,
|
|
8
|
+
DateOptions,
|
|
9
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/rdfa-date-plugin';
|
|
7
10
|
import {
|
|
8
11
|
formatContainsTime,
|
|
9
12
|
validateDateFormat,
|
|
@@ -21,13 +24,8 @@ import {
|
|
|
21
24
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
22
25
|
|
|
23
26
|
type Args = {
|
|
24
|
-
controller:
|
|
25
|
-
|
|
26
|
-
options: {
|
|
27
|
-
formats: [DateFormat];
|
|
28
|
-
allowCustomFormat: boolean;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
27
|
+
controller: SayController;
|
|
28
|
+
options: DateOptions;
|
|
31
29
|
};
|
|
32
30
|
const SECONDS_REGEX = new RegExp('[sStT]|p{2,}');
|
|
33
31
|
export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
@@ -39,7 +37,7 @@ export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
|
39
37
|
tooltipOpen = false;
|
|
40
38
|
|
|
41
39
|
get formats(): DateFormat[] {
|
|
42
|
-
return this.args.
|
|
40
|
+
return this.args.options.formats;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
get controller() {
|
|
@@ -47,13 +45,13 @@ export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
get selection() {
|
|
50
|
-
return this.controller.
|
|
48
|
+
return this.controller.activeEditorState.selection;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
get selectedDateNode(): Option<PNode> {
|
|
54
52
|
if (
|
|
55
53
|
this.selection instanceof NodeSelection &&
|
|
56
|
-
this.selection.node.type === this.
|
|
54
|
+
this.selection.node.type === this.controller.schema.nodes['date']
|
|
57
55
|
) {
|
|
58
56
|
return this.selection.node;
|
|
59
57
|
} else {
|
|
@@ -159,8 +157,8 @@ export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
|
159
157
|
return null;
|
|
160
158
|
}
|
|
161
159
|
|
|
162
|
-
get pickerDate(): Date {
|
|
163
|
-
return this.documentDate
|
|
160
|
+
get pickerDate(): Option<Date> {
|
|
161
|
+
return this.documentDate;
|
|
164
162
|
}
|
|
165
163
|
|
|
166
164
|
@action
|
|
@@ -178,15 +176,13 @@ export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
|
178
176
|
if (pos) {
|
|
179
177
|
this.controller.withTransaction((tr) => {
|
|
180
178
|
return tr.setNodeAttribute(pos, 'value', date.toISOString());
|
|
181
|
-
}
|
|
179
|
+
});
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
182
|
|
|
185
183
|
@action
|
|
186
184
|
changeIncludeTime(includeTime: boolean) {
|
|
187
|
-
console.log('Include time', includeTime);
|
|
188
185
|
if (this.isCustom) {
|
|
189
|
-
console.log("but it's custom");
|
|
190
186
|
return;
|
|
191
187
|
}
|
|
192
188
|
const dateFormatType = this.documentDateFormatType;
|
|
@@ -209,7 +205,7 @@ export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
|
209
205
|
.setNodeAttribute(pos, 'format', dateFormat)
|
|
210
206
|
.setNodeAttribute(pos, 'custom', custom)
|
|
211
207
|
.setNodeAttribute(pos, 'onlyDate', !formatContainsTime(dateFormat));
|
|
212
|
-
}
|
|
208
|
+
});
|
|
213
209
|
}
|
|
214
210
|
|
|
215
211
|
@action
|
|
@@ -221,7 +217,7 @@ export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
|
221
217
|
if (formatKey === 'custom') {
|
|
222
218
|
this.controller.withTransaction((tr) => {
|
|
223
219
|
return tr.setNodeAttribute(pos, 'custom', true);
|
|
224
|
-
}
|
|
220
|
+
});
|
|
225
221
|
} else {
|
|
226
222
|
const format = this.formats.find((format) => format.key === formatKey);
|
|
227
223
|
if (format) {
|
|
@@ -243,7 +239,7 @@ export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
|
243
239
|
return tr
|
|
244
240
|
.setNodeAttribute(pos, 'format', format)
|
|
245
241
|
.setNodeAttribute(pos, 'onlyDate', !formatContainsTime(format));
|
|
246
|
-
}
|
|
242
|
+
});
|
|
247
243
|
}
|
|
248
244
|
}
|
|
249
245
|
|
|
@@ -7,12 +7,3 @@
|
|
|
7
7
|
{{t "date-plugin.insert.date"}}
|
|
8
8
|
</AuButton>
|
|
9
9
|
</AuList::Item>
|
|
10
|
-
<AuList::Item>
|
|
11
|
-
<AuButton
|
|
12
|
-
@icon="add"
|
|
13
|
-
@iconAlignment="left"
|
|
14
|
-
@skin="link"
|
|
15
|
-
{{on 'click' (fn this.insertDate false)}}>
|
|
16
|
-
{{t "date-plugin.insert.datetime"}}
|
|
17
|
-
</AuButton>
|
|
18
|
-
</AuList::Item>
|