@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
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,35 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
|
|
15
|
+
## 1.0.0-beta.2 (2023-01-23)
|
|
16
|
+
|
|
17
|
+
#### :boom: Breaking Change
|
|
18
|
+
* [#67](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/67) New version of the variable plugin ([@elpoelma](https://github.com/elpoelma))
|
|
19
|
+
* [#62](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/62) feat(citation): make citation plugin datastore-independent ([@abeforgit](https://github.com/abeforgit))
|
|
20
|
+
|
|
21
|
+
#### :rocket: Enhancement
|
|
22
|
+
* [#69](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/69) Add enter handler to variable editor view ([@elpoelma](https://github.com/elpoelma))
|
|
23
|
+
* [#66](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/66) make the template plugin independent of the datastore ([@abeforgit](https://github.com/abeforgit))
|
|
24
|
+
* [#43](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/43) Feature/template nodes ([@lagartoverde](https://github.com/lagartoverde))
|
|
25
|
+
* [#62](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/62) feat(citation): make citation plugin datastore-independent ([@abeforgit](https://github.com/abeforgit))
|
|
26
|
+
* [#49](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/49) Avoid using the datastore on the besluit type plugin ([@lagartoverde](https://github.com/lagartoverde))
|
|
27
|
+
* [#47](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/47) Implement besluit articles using article-structure plugin ([@elpoelma](https://github.com/elpoelma))
|
|
28
|
+
* [#48](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/48) Roadsign regulation plugin rework ([@elpoelma](https://github.com/elpoelma))
|
|
29
|
+
|
|
30
|
+
#### :bug: Bug Fix
|
|
31
|
+
* [#63](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/63) Preserve date format across reloads ([@elpoelma](https://github.com/elpoelma))
|
|
32
|
+
|
|
33
|
+
#### :house: Internal
|
|
34
|
+
* [#68](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/68) Update editor to 1.0.0-beta.5 ([@elpoelma](https://github.com/elpoelma))
|
|
35
|
+
* [#65](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/65) Update editor to 1.0.0-beta.4 ([@elpoelma](https://github.com/elpoelma))
|
|
36
|
+
|
|
37
|
+
#### Committers: 3
|
|
38
|
+
- Arne Bertrand ([@abeforgit](https://github.com/abeforgit))
|
|
39
|
+
- Elena Poelman ([@elpoelma](https://github.com/elpoelma))
|
|
40
|
+
- Oscar Rodriguez Villalobos ([@lagartoverde](https://github.com/lagartoverde))
|
|
41
|
+
|
|
42
|
+
|
|
14
43
|
## 1.0.0-beta.1 (2023-01-17)
|
|
15
44
|
|
|
16
45
|
#### :rocket: Enhancement
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<div class="au-c-dropdown" ...attributes>
|
|
2
|
+
<AuPill
|
|
3
|
+
@skin={{this.skin}}
|
|
4
|
+
@size={{@size}}
|
|
5
|
+
@actionIcon={{this.icon}}
|
|
6
|
+
@iconAlignment={{this.iconAlignment}}
|
|
7
|
+
@hideText={{@hideText}}
|
|
8
|
+
aria-haspopup="true"
|
|
9
|
+
aria-expanded="{{if this.dropdownOpen 'true' 'false'}}"
|
|
10
|
+
@onClickAction={{this.toggleDropdown}}
|
|
11
|
+
data-test-dropdown-button
|
|
12
|
+
data-au-dropdown-toggle
|
|
13
|
+
>
|
|
14
|
+
<span class="au-c-dropdown__name" data-test-dropdown-title>
|
|
15
|
+
{{@title}}
|
|
16
|
+
</span>
|
|
17
|
+
</AuPill>
|
|
18
|
+
<div
|
|
19
|
+
class="au-c-dropdown__menu {{this.alignment}} {{if this.dropdownOpen 'is-visible'}}"
|
|
20
|
+
role="menu"
|
|
21
|
+
tabindex="-1"
|
|
22
|
+
{{focus-trap
|
|
23
|
+
isActive=this.dropdownOpen
|
|
24
|
+
shouldSelfFocus=true
|
|
25
|
+
focusTrapOptions=(hash
|
|
26
|
+
clickOutsideDeactivates=this.clickOutsideDeactivates
|
|
27
|
+
)
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
{{yield}}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
|
|
5
|
+
type Args = {
|
|
6
|
+
alignment: 'left' | 'right';
|
|
7
|
+
icon: string;
|
|
8
|
+
iconAlignment: 'left' | 'right';
|
|
9
|
+
skin?: string;
|
|
10
|
+
};
|
|
11
|
+
export default class AuDropdownPill extends Component<Args> {
|
|
12
|
+
@tracked dropdownOpen = false;
|
|
13
|
+
|
|
14
|
+
@action
|
|
15
|
+
openDropdown() {
|
|
16
|
+
this.dropdownOpen = true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@action
|
|
20
|
+
closeDropdown() {
|
|
21
|
+
this.dropdownOpen = false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@action
|
|
25
|
+
toggleDropdown() {
|
|
26
|
+
this.dropdownOpen = !this.dropdownOpen;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@action
|
|
30
|
+
clickOutsideDeactivates(event: InputEvent) {
|
|
31
|
+
const toggleButton = document.querySelector('[data-au-dropdown-toggle]');
|
|
32
|
+
const isClosedByToggleButton = toggleButton?.contains(
|
|
33
|
+
event.target as HTMLInputElement
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (!isClosedByToggleButton) {
|
|
37
|
+
this.closeDropdown();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Dropdown alignment
|
|
44
|
+
get alignment() {
|
|
45
|
+
if (this.args.alignment == 'left') return 'au-c-dropdown__menu--left';
|
|
46
|
+
if (this.args.alignment == 'right') return 'au-c-dropdown__menu--right';
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get skin() {
|
|
51
|
+
return this.args.skin || 'default';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Set default button icon
|
|
55
|
+
get icon() {
|
|
56
|
+
if (this.args.icon) return this.args.icon;
|
|
57
|
+
else return 'chevron-down';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Set default icon alignment
|
|
61
|
+
get iconAlignment() {
|
|
62
|
+
if (this.args.iconAlignment) return this.args.iconAlignment;
|
|
63
|
+
else return 'right';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -16,6 +16,7 @@ import { getRdfaAttribute } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
|
|
|
16
16
|
import fetchBesluitTypes, {
|
|
17
17
|
BesluitType,
|
|
18
18
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
|
|
19
|
+
import { findAncestorOfType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin/utils/structure';
|
|
19
20
|
declare module 'ember__owner' {
|
|
20
21
|
export default interface Owner {
|
|
21
22
|
resolveRegistration(name: string): unknown;
|
|
@@ -73,14 +74,18 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
73
74
|
|
|
74
75
|
get currentBesluitRange(): ResolvedPNode | undefined {
|
|
75
76
|
const selection = this.controller.state.selection;
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
77
|
+
const besluit = findAncestorOfType(
|
|
78
|
+
selection,
|
|
79
|
+
this.controller.schema.nodes['besluit']
|
|
80
|
+
);
|
|
81
|
+
if (!besluit) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
node: besluit.node,
|
|
86
|
+
from: besluit.start - 1,
|
|
87
|
+
to: besluit.start + besluit.node.nodeSize - 1,
|
|
88
|
+
};
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
get currentBesluitURI() {
|
|
@@ -100,10 +105,12 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
100
105
|
if (!this.currentBesluitURI) {
|
|
101
106
|
return;
|
|
102
107
|
}
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
.
|
|
106
|
-
|
|
108
|
+
const besluit = findAncestorOfType(
|
|
109
|
+
this.controller.state.selection,
|
|
110
|
+
this.controller.schema.nodes['besluit']
|
|
111
|
+
);
|
|
112
|
+
const besluitTypeof = besluit?.node.attrs.typeof as string;
|
|
113
|
+
const besluitTypesUris = besluitTypeof.split(' ');
|
|
107
114
|
const besluitTypeRelevant = besluitTypesUris.find((type) =>
|
|
108
115
|
type.includes('https://data.vlaanderen.be/id/concept/BesluitType/')
|
|
109
116
|
);
|
|
@@ -52,7 +52,7 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
get disableInsert() {
|
|
55
|
-
if (!this.activeRanges) {
|
|
55
|
+
if (!this.activeRanges || this.controller.inEmbeddedView) {
|
|
56
56
|
return true;
|
|
57
57
|
}
|
|
58
58
|
const { from } = this.controller.state.selection;
|
|
@@ -5,6 +5,7 @@ import { ProseParser } from '@lblod/ember-rdfa-editor';
|
|
|
5
5
|
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
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
|
+
import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
|
|
8
9
|
|
|
9
10
|
type Args = {
|
|
10
11
|
controller: ProseController;
|
|
@@ -21,19 +22,14 @@ export default class ImportSnippetPluginCard extends Component<Args> {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
get insertRange() {
|
|
24
|
-
const selection = this.controller.state
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.asSubjectNodeMapping()
|
|
30
|
-
.nodes(),
|
|
31
|
-
][0];
|
|
32
|
-
if (besluitRange) {
|
|
33
|
-
const { to } = besluitRange;
|
|
25
|
+
const { selection } = this.controller.state;
|
|
26
|
+
const besluit = findParentNodeOfType(this.controller.schema.nodes.besluit)(
|
|
27
|
+
selection
|
|
28
|
+
);
|
|
29
|
+
if (besluit) {
|
|
34
30
|
return {
|
|
35
|
-
from:
|
|
36
|
-
to:
|
|
31
|
+
from: besluit.pos + besluit.node.nodeSize - 1,
|
|
32
|
+
to: besluit.pos + besluit.node.nodeSize - 1,
|
|
37
33
|
};
|
|
38
34
|
} else {
|
|
39
35
|
return selection;
|
|
@@ -10,6 +10,34 @@
|
|
|
10
10
|
@onChange={{this.changeDate}}
|
|
11
11
|
@value={{this.dateValue}}
|
|
12
12
|
@onlyDate={{this.onlyDate}}/>
|
|
13
|
+
{{#each @widgetArgs.options.formats as |format|}}
|
|
14
|
+
<AuFormRow>
|
|
15
|
+
<AuControlRadio
|
|
16
|
+
@label={{format.label}}
|
|
17
|
+
@identifier={{format.key}}
|
|
18
|
+
@name="dateFormat"
|
|
19
|
+
@value={{format.key}}
|
|
20
|
+
checked={{eq this.dateFormat format.key}}
|
|
21
|
+
@onChange={{this.setDateFormat}}
|
|
22
|
+
/>
|
|
23
|
+
</AuFormRow>
|
|
24
|
+
{{/each}}
|
|
25
|
+
<AuFormRow>
|
|
26
|
+
<AuControlRadio
|
|
27
|
+
@label="Custom Date"
|
|
28
|
+
@identifier="custom"
|
|
29
|
+
@name="dateFormat"
|
|
30
|
+
@value="custom"
|
|
31
|
+
checked={{eq this.dateFormat "custom"}}
|
|
32
|
+
@onChange={{this.setDateFormat}}
|
|
33
|
+
/>
|
|
34
|
+
{{#if (eq this.dateFormat "custom")}}
|
|
35
|
+
<AuInput
|
|
36
|
+
@value={{this.customDateFormat}}
|
|
37
|
+
{{on "input" this.setCustomDateFormat}}
|
|
38
|
+
/>
|
|
39
|
+
{{/if}}
|
|
40
|
+
</AuFormRow>
|
|
13
41
|
{{#unless this.dateInDocument}}
|
|
14
42
|
<AuFormRow class="au-u-margin-top">
|
|
15
43
|
<AuButton {{on 'click' this.modifyDate}}>
|
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
|
-
import { modifyDate } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/rdfa-date-plugin/commands';
|
|
5
4
|
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
6
|
-
import {
|
|
5
|
+
import { NodeSelection } from '@lblod/ember-rdfa-editor';
|
|
6
|
+
import { DateFormat } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/rdfa-date-plugin';
|
|
7
|
+
|
|
7
8
|
type Args = {
|
|
8
9
|
controller: ProseController;
|
|
10
|
+
widgetArgs: {
|
|
11
|
+
options: {
|
|
12
|
+
formats: [DateFormat];
|
|
13
|
+
allowCustomFormat: boolean;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
9
16
|
};
|
|
10
17
|
export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
11
18
|
@tracked dateValue?: Date;
|
|
12
|
-
@tracked
|
|
19
|
+
@tracked datePos?: number;
|
|
13
20
|
@tracked dateInDocument = false;
|
|
14
21
|
@tracked onlyDate = false;
|
|
15
|
-
@tracked
|
|
22
|
+
@tracked dateFormat = '';
|
|
23
|
+
@tracked customDateFormat = 'dd/MM/yyyy';
|
|
24
|
+
|
|
25
|
+
constructor(owner: unknown, args: Args) {
|
|
26
|
+
super(owner, args);
|
|
27
|
+
const formats = this.args.widgetArgs.options.formats;
|
|
28
|
+
const firstKey = [...formats.keys()][0];
|
|
29
|
+
this.dateFormat = formats[firstKey].key;
|
|
30
|
+
}
|
|
16
31
|
|
|
17
32
|
get controller() {
|
|
18
33
|
return this.args.controller;
|
|
@@ -20,15 +35,13 @@ export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
|
20
35
|
|
|
21
36
|
@action
|
|
22
37
|
modifyDate() {
|
|
23
|
-
if (this.
|
|
24
|
-
this.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
31
|
-
);
|
|
38
|
+
if (this.datePos && this.dateValue) {
|
|
39
|
+
const pos = this.datePos;
|
|
40
|
+
const value = this.dateValue;
|
|
41
|
+
this.controller.withTransaction((tr) => {
|
|
42
|
+
tr.setNodeAttribute(pos, 'format', this.customDateFormat);
|
|
43
|
+
return tr.setNodeAttribute(pos, 'value', value.toISOString());
|
|
44
|
+
}, true);
|
|
32
45
|
}
|
|
33
46
|
}
|
|
34
47
|
|
|
@@ -39,34 +52,55 @@ export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
@action
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
setDateFormat(dateFormat: string) {
|
|
56
|
+
this.dateFormat = dateFormat;
|
|
57
|
+
if (dateFormat !== 'custom') {
|
|
58
|
+
const format = this.args.widgetArgs.options.formats.find(
|
|
59
|
+
(format) => format.key === dateFormat
|
|
60
|
+
);
|
|
61
|
+
if (format) {
|
|
62
|
+
if (this.onlyDate) {
|
|
63
|
+
this.customDateFormat = format.dateFormat;
|
|
64
|
+
} else {
|
|
65
|
+
this.customDateFormat = format.dateTimeFormat;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
54
68
|
}
|
|
55
|
-
|
|
69
|
+
if (this.dateInDocument) this.modifyDate();
|
|
70
|
+
}
|
|
71
|
+
@action
|
|
72
|
+
setCustomDateFormat(event: InputEvent) {
|
|
73
|
+
this.customDateFormat = (event.target as HTMLInputElement).value;
|
|
74
|
+
if (this.dateInDocument) this.modifyDate();
|
|
75
|
+
}
|
|
56
76
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
get showCard() {
|
|
78
|
+
return this.datePos !== undefined && this.datePos !== null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@action
|
|
82
|
+
onSelectionChanged() {
|
|
83
|
+
const selection = this.controller.getState(true).selection;
|
|
84
|
+
if (
|
|
85
|
+
selection instanceof NodeSelection &&
|
|
86
|
+
selection.node.type === this.args.controller.schema.nodes['date']
|
|
87
|
+
) {
|
|
88
|
+
this.dateInDocument = !!selection.node.attrs.value;
|
|
89
|
+
this.onlyDate = selection.node.attrs.onlyDate as boolean;
|
|
90
|
+
this.dateValue = this.dateInDocument
|
|
91
|
+
? new Date(selection.node.attrs.value)
|
|
92
|
+
: new Date();
|
|
93
|
+
if (this.dateInDocument) {
|
|
94
|
+
this.dateValue = new Date(selection.node.attrs.value);
|
|
95
|
+
} else {
|
|
96
|
+
this.dateValue = new Date();
|
|
97
|
+
if (this.onlyDate) {
|
|
98
|
+
this.dateValue.setHours(0, 0, 0, 0);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
this.datePos = selection.from;
|
|
67
102
|
} else {
|
|
68
|
-
this.
|
|
69
|
-
this.showCard = false;
|
|
103
|
+
this.datePos = undefined;
|
|
70
104
|
}
|
|
71
105
|
}
|
|
72
106
|
}
|
|
@@ -46,6 +46,7 @@ export default class RdfaDatePluginDateTimePicker extends Component<Args> {
|
|
|
46
46
|
if (!wasDateInputCleared) {
|
|
47
47
|
if (!this.date) {
|
|
48
48
|
this.date = new Date();
|
|
49
|
+
this.date.setHours(0, 0, 0, 0);
|
|
49
50
|
}
|
|
50
51
|
this.date.setDate(date.getDate());
|
|
51
52
|
this.date.setMonth(date.getMonth());
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
@icon="add"
|
|
4
4
|
@iconAlignment="left"
|
|
5
5
|
@skin="link"
|
|
6
|
-
{{on 'click' this.insertDate}}>
|
|
6
|
+
{{on 'click' (fn this.insertDate true)}}>
|
|
7
7
|
{{t "date-plugin.insert.date"}}
|
|
8
8
|
</AuButton>
|
|
9
9
|
</AuList::Item>
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
@icon="add"
|
|
13
13
|
@iconAlignment="left"
|
|
14
14
|
@skin="link"
|
|
15
|
-
{{on 'click' this.
|
|
15
|
+
{{on 'click' (fn this.insertDate false)}}>
|
|
16
16
|
{{t "date-plugin.insert.datetime"}}
|
|
17
17
|
</AuButton>
|
|
18
18
|
</AuList::Item>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
3
|
import { ProseController } from '@lblod/ember-rdfa-editor/core/prosemirror';
|
|
4
|
+
import { NodeSelection } from '@lblod/ember-rdfa-editor';
|
|
4
5
|
|
|
5
6
|
type Args = {
|
|
6
7
|
controller: ProseController;
|
|
@@ -16,30 +17,20 @@ export default class RdfaDatePluginInsertComponent extends Component<Args> {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
@action
|
|
19
|
-
insertDate() {
|
|
20
|
+
insertDate(onlyDate: boolean) {
|
|
20
21
|
this.controller.withTransaction((tr) => {
|
|
21
|
-
|
|
22
|
-
this.schema.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}),
|
|
26
|
-
]);
|
|
27
|
-
return tr.replaceSelectionWith(dateNode, false);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@action
|
|
32
|
-
insertDateTime() {
|
|
33
|
-
this.controller.withTransaction((tr) => {
|
|
34
|
-
return tr.replaceSelectionWith(
|
|
35
|
-
this.schema.text('${date and time}', [
|
|
36
|
-
this.schema.mark('inline_rdfa', {
|
|
37
|
-
datatype: 'xsd:dateTime',
|
|
38
|
-
property: 'ext:content',
|
|
39
|
-
}),
|
|
40
|
-
]),
|
|
41
|
-
false
|
|
22
|
+
tr.replaceSelectionWith(
|
|
23
|
+
this.schema.node('date', {
|
|
24
|
+
onlyDate,
|
|
25
|
+
})
|
|
42
26
|
);
|
|
43
|
-
|
|
27
|
+
if (tr.selection.$anchor.nodeBefore) {
|
|
28
|
+
const resolvedPos = tr.doc.resolve(
|
|
29
|
+
tr.selection.anchor - tr.selection.$anchor.nodeBefore?.nodeSize
|
|
30
|
+
);
|
|
31
|
+
tr.setSelection(new NodeSelection(resolvedPos));
|
|
32
|
+
}
|
|
33
|
+
return tr;
|
|
34
|
+
}, true);
|
|
44
35
|
}
|
|
45
36
|
}
|
|
@@ -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) {
|
|
@@ -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
|
}
|