@lblod/ember-rdfa-editor-lblod-plugins 12.0.0 → 13.0.0
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/.changeset.yml +1 -2
- package/CHANGELOG.md +49 -1
- package/README.md +242 -138
- package/addon/components/citation-plugin/citations/search-modal.hbs +22 -0
- package/addon/components/citation-plugin/citations/search-modal.ts +15 -0
- package/addon/components/decision-plugin/decision-plugin-card.hbs +3 -3
- package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +2 -2
- package/addon/components/table-of-contents-plugin/ember-nodes/table-of-contents.ts +1 -0
- package/addon/components/template-comments-plugin/template-comment.hbs +4 -4
- package/addon/components/template-comments-plugin/template-comment.ts +16 -0
- package/addon/components/variable-plugin/address/edit.ts +1 -1
- package/addon/components/variable-plugin/address/insert-variable.hbs +9 -0
- package/addon/components/variable-plugin/address/insert-variable.ts +40 -0
- package/addon/components/variable-plugin/address/insert.hbs +2 -1
- package/addon/components/variable-plugin/address/insert.ts +22 -18
- package/addon/components/variable-plugin/address/nodeview.hbs +2 -2
- package/addon/components/variable-plugin/address/nodeview.ts +23 -1
- package/addon/components/variable-plugin/address/utils.ts +26 -0
- package/addon/components/variable-plugin/codelist/insert.ts +10 -1
- package/addon/components/{rdfa-date-plugin → variable-plugin/date}/date-time-picker.ts +1 -1
- package/addon/components/{rdfa-date-plugin/card.hbs → variable-plugin/date/edit.hbs} +3 -3
- package/addon/components/{rdfa-date-plugin/card.ts → variable-plugin/date/edit.ts} +10 -10
- package/addon/components/{rdfa-date-plugin → variable-plugin/date}/help-modal.ts +2 -2
- package/addon/components/variable-plugin/date/insert-variable.hbs +9 -0
- package/addon/components/variable-plugin/date/insert-variable.ts +57 -0
- package/addon/components/variable-plugin/date/insert.hbs +9 -9
- package/addon/components/variable-plugin/date/insert.ts +13 -10
- package/addon/components/{rdfa-date-plugin/date.hbs → variable-plugin/date/nodeview.hbs} +1 -1
- package/addon/components/{rdfa-date-plugin/date.ts → variable-plugin/date/nodeview.ts} +20 -6
- package/addon/components/variable-plugin/location/insert.ts +11 -2
- package/addon/components/variable-plugin/location/nodeview.hbs +8 -0
- package/addon/components/variable-plugin/location/nodeview.ts +15 -0
- package/addon/components/variable-plugin/number/insert.hbs +1 -1
- package/addon/components/variable-plugin/number/insert.ts +9 -1
- package/addon/components/variable-plugin/number/nodeview.hbs +2 -2
- package/addon/components/variable-plugin/number/nodeview.ts +17 -0
- package/addon/components/variable-plugin/text/insert.ts +14 -2
- package/addon/components/variable-plugin/variable/nodeview.hbs +1 -0
- package/addon/plugins/citation-plugin/index.ts +1 -0
- package/addon/plugins/citation-plugin/utils/legal-documents.ts +2 -0
- package/addon/plugins/citation-plugin/utils/public-decisions.ts +62 -26
- package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +8 -13
- package/addon/plugins/table-of-contents-plugin/utils/index.ts +7 -4
- package/addon/plugins/template-comments-plugin/node.ts +12 -3
- package/addon/plugins/variable-plugin/variables/address.ts +15 -8
- package/addon/plugins/variable-plugin/variables/codelist.ts +4 -4
- package/addon/plugins/variable-plugin/variables/date.ts +200 -0
- package/addon/plugins/variable-plugin/variables/index.ts +1 -0
- package/addon/plugins/variable-plugin/variables/location.ts +4 -4
- package/addon/plugins/variable-plugin/variables/number.ts +11 -8
- package/addon/plugins/variable-plugin/variables/text.ts +4 -4
- package/addon/utils/translation.ts +19 -0
- package/app/components/variable-plugin/address/insert-variable.js +1 -0
- package/app/components/variable-plugin/date/date-time-picker.js +1 -0
- package/app/components/{rdfa-date-plugin/card.js → variable-plugin/date/edit.js} +1 -1
- package/app/components/{rdfa-date-plugin → variable-plugin/date}/help-modal.js +1 -1
- package/app/components/{rdfa-date-plugin/date.js → variable-plugin/date/insert-variable.js} +1 -1
- package/app/components/{rdfa-date-plugin/insert.js → variable-plugin/date/nodeview.js} +1 -1
- package/app/components/{rdfa-date-plugin/date-time-picker.js → variable-plugin/location/nodeview.js} +1 -1
- package/app/styles/besluit-plugin.scss +2 -2
- package/app/styles/date-plugin.scss +0 -20
- package/app/styles/snippet-plugin.scss +1 -1
- package/app/styles/template-comments-plugin.scss +4 -4
- package/app/styles/variable-plugin.scss +8 -4
- package/components/citation-plugin/citations/search-modal.d.ts +3 -0
- package/components/template-comments-plugin/template-comment.d.ts +6 -0
- package/components/variable-plugin/address/insert-variable.d.ts +15 -0
- package/components/variable-plugin/address/insert.d.ts +4 -1
- package/components/variable-plugin/address/nodeview.d.ts +7 -0
- package/components/variable-plugin/address/utils.d.ts +2 -0
- package/components/variable-plugin/codelist/insert.d.ts +1 -0
- package/components/{rdfa-date-plugin → variable-plugin/date}/date-time-picker.d.ts +1 -1
- package/components/{rdfa-date-plugin/card.d.ts → variable-plugin/date/edit.d.ts} +3 -3
- package/components/{rdfa-date-plugin → variable-plugin/date}/help-modal.d.ts +1 -1
- package/components/variable-plugin/date/insert-variable.d.ts +16 -0
- package/components/variable-plugin/date/insert.d.ts +4 -3
- package/components/{rdfa-date-plugin/date.d.ts → variable-plugin/date/nodeview.d.ts} +5 -1
- package/components/variable-plugin/location/insert.d.ts +1 -0
- package/components/variable-plugin/location/nodeview.d.ts +12 -0
- package/components/variable-plugin/number/insert.d.ts +1 -0
- package/components/variable-plugin/number/nodeview.d.ts +5 -0
- package/components/variable-plugin/text/insert.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +14 -10
- package/plugins/citation-plugin/index.d.ts +1 -0
- package/plugins/citation-plugin/utils/legal-documents.d.ts +1 -0
- package/plugins/table-of-contents-plugin/utils/index.d.ts +3 -2
- package/plugins/{rdfa-date-plugin/nodes → variable-plugin/variables}/date.d.ts +10 -1
- package/plugins/variable-plugin/variables/index.d.ts +1 -0
- package/translations/en-US.yaml +12 -0
- package/translations/nl-BE.yaml +13 -0
- package/utils/translation.d.ts +3 -0
- package/addon/components/rdfa-date-plugin/insert.hbs +0 -9
- package/addon/components/rdfa-date-plugin/insert.ts +0 -52
- package/addon/plugins/rdfa-date-plugin/index.ts +0 -28
- package/addon/plugins/rdfa-date-plugin/nodes/date.ts +0 -167
- package/components/rdfa-date-plugin/insert.d.ts +0 -16
- package/plugins/rdfa-date-plugin/index.d.ts +0 -15
- /package/addon/components/{rdfa-date-plugin → variable-plugin/date}/date-time-picker.hbs +0 -0
- /package/addon/components/{rdfa-date-plugin → variable-plugin/date}/help-modal.hbs +0 -0
- /package/addon/plugins/{rdfa-date-plugin/utils.ts → variable-plugin/utils/date-helpers.ts} +0 -0
- /package/plugins/{rdfa-date-plugin/utils.d.ts → variable-plugin/utils/date-helpers.d.ts} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { DecorationSource, PNode, SayController, SayView } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import IntlService from 'ember-intl/services/intl';
|
|
3
4
|
type Args = {
|
|
4
5
|
getPos: () => number | undefined;
|
|
5
6
|
node: PNode;
|
|
@@ -9,7 +10,10 @@ type Args = {
|
|
|
9
10
|
selected: boolean;
|
|
10
11
|
contentDecorations?: DecorationSource;
|
|
11
12
|
};
|
|
12
|
-
export default class
|
|
13
|
+
export default class DateNodeviewComponent extends Component<Args> {
|
|
14
|
+
intl: IntlService;
|
|
15
|
+
get controller(): SayController;
|
|
16
|
+
get documentLanguage(): string;
|
|
13
17
|
onClick(): void;
|
|
14
18
|
get humanReadableDate(): string;
|
|
15
19
|
}
|
|
@@ -13,6 +13,7 @@ export default class LocationInsertComponent extends Component<Args> {
|
|
|
13
13
|
intl: IntlService;
|
|
14
14
|
get controller(): SayController;
|
|
15
15
|
get schema(): import("prosemirror-model").Schema<any, any>;
|
|
16
|
+
get documentLanguage(): string;
|
|
16
17
|
get endpoint(): string;
|
|
17
18
|
updateLabel(event: InputEvent): void;
|
|
18
19
|
insert(): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { SayController, SayView } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
type Args = {
|
|
4
|
+
controller: SayController;
|
|
5
|
+
};
|
|
6
|
+
export default class LocationNodeViewComponent extends Component<Args> {
|
|
7
|
+
nodeViews: {
|
|
8
|
+
address: import("prosemirror-view").NodeViewConstructor;
|
|
9
|
+
};
|
|
10
|
+
innerView?: SayView;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -27,6 +27,7 @@ export default class NumberInsertComponent extends Component<Args> {
|
|
|
27
27
|
}>;
|
|
28
28
|
get controller(): SayController;
|
|
29
29
|
get schema(): import("prosemirror-model").Schema<any, any>;
|
|
30
|
+
get documentLanguage(): string;
|
|
30
31
|
get numberVariableError(): string;
|
|
31
32
|
updateLabel(event: InputEvent): void;
|
|
32
33
|
updateMinimumValue: (event: InputEvent) => void;
|
|
@@ -16,6 +16,11 @@ export default class NumberNodeviewComponent extends Component<Args> {
|
|
|
16
16
|
intl: intlService;
|
|
17
17
|
cursorPositionKeyDown: number | null;
|
|
18
18
|
focus(element: HTMLInputElement): void;
|
|
19
|
+
get controller(): SayController;
|
|
20
|
+
get documentLanguage(): string;
|
|
21
|
+
get translations(): {
|
|
22
|
+
placeholder: string;
|
|
23
|
+
};
|
|
19
24
|
get node(): PNode;
|
|
20
25
|
get formattedNumber(): string;
|
|
21
26
|
get selected(): boolean;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import IntlService from 'ember-intl/services/intl';
|
|
3
4
|
type Args = {
|
|
4
5
|
controller: SayController;
|
|
5
6
|
};
|
|
6
7
|
export default class TextVariableInsertComponent extends Component<Args> {
|
|
8
|
+
intl: IntlService;
|
|
7
9
|
label?: string;
|
|
8
10
|
get controller(): SayController;
|
|
9
11
|
get schema(): import("prosemirror-model").Schema<any, any>;
|
|
12
|
+
get documentLanguage(): string;
|
|
10
13
|
updateLabel(event: InputEvent): void;
|
|
11
14
|
insert(): void;
|
|
12
15
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lblod/ember-rdfa-editor-lblod-plugins",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"ember-auto-import": "~2.6.3",
|
|
47
47
|
"ember-cli-babel": "^7.26.11",
|
|
48
48
|
"ember-cli-htmlbars": "^6.1.1",
|
|
49
|
-
"ember-cli-typescript": "^5.2.1",
|
|
50
49
|
"ember-concurrency": "^2.3.7",
|
|
51
50
|
"ember-mu-transform-helpers": "^2.0.0",
|
|
52
51
|
"ember-power-select": "^6.0.1",
|
|
@@ -71,7 +70,8 @@
|
|
|
71
70
|
"@embroider/test-setup": "^3.0.1",
|
|
72
71
|
"@glimmer/component": "^1.1.2",
|
|
73
72
|
"@glimmer/tracking": "^1.1.2",
|
|
74
|
-
"@
|
|
73
|
+
"@glint/template": "^1.1.0",
|
|
74
|
+
"@lblod/ember-rdfa-editor": "^6.1.0",
|
|
75
75
|
"@rdfjs/types": "^1.1.0",
|
|
76
76
|
"@release-it/keep-a-changelog": "^3.1.0",
|
|
77
77
|
"@tsconfig/ember": "^3.0.0",
|
|
@@ -106,18 +106,19 @@
|
|
|
106
106
|
"@types/rdfjs__dataset": "^2.0.0",
|
|
107
107
|
"@types/rsvp": "^4.0.4",
|
|
108
108
|
"@types/uuid": "^9.0.0",
|
|
109
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
110
|
-
"@typescript-eslint/parser": "^
|
|
109
|
+
"@typescript-eslint/eslint-plugin": "^6.6.0",
|
|
110
|
+
"@typescript-eslint/parser": "^6.6.0",
|
|
111
111
|
"babel-eslint": "^10.1.0",
|
|
112
112
|
"broccoli-asset-rev": "^3.0.0",
|
|
113
113
|
"changesets-release-it-plugin": "^0.1.1",
|
|
114
|
-
"ember-cli": "~4.
|
|
114
|
+
"ember-cli": "~4.12.0",
|
|
115
115
|
"ember-cli-dependency-checker": "^3.3.1",
|
|
116
116
|
"ember-cli-inject-live-reload": "^2.1.0",
|
|
117
117
|
"ember-cli-sass": "^11.0.1",
|
|
118
118
|
"ember-cli-sri": "^2.1.1",
|
|
119
119
|
"ember-cli-terser": "^4.0.2",
|
|
120
|
-
"ember-
|
|
120
|
+
"ember-cli-typescript": "^5.2.1",
|
|
121
|
+
"ember-data": "^4.12.0",
|
|
121
122
|
"ember-disable-prototype-extensions": "^1.1.3",
|
|
122
123
|
"ember-functions-as-helper-polyfill": "^2.1.1",
|
|
123
124
|
"ember-intl": "^5.7.2",
|
|
@@ -126,7 +127,7 @@
|
|
|
126
127
|
"ember-qunit": "^6.0.0",
|
|
127
128
|
"ember-resolver": "^8.0.3",
|
|
128
129
|
"ember-simple-auth": "4.2.2",
|
|
129
|
-
"ember-source": "~4.
|
|
130
|
+
"ember-source": "~4.12.0",
|
|
130
131
|
"ember-source-channel-url": "^3.0.0",
|
|
131
132
|
"ember-template-lint": "^4.16.1",
|
|
132
133
|
"ember-try": "^2.0.0",
|
|
@@ -149,9 +150,12 @@
|
|
|
149
150
|
},
|
|
150
151
|
"peerDependencies": {
|
|
151
152
|
"@appuniversum/ember-appuniversum": "^2.4.2",
|
|
152
|
-
"@
|
|
153
|
+
"@glint/template": "^1.1.0",
|
|
154
|
+
"@lblod/ember-rdfa-editor": "^6.0.0",
|
|
153
155
|
"ember-concurrency": "^2.3.7",
|
|
154
|
-
"ember-
|
|
156
|
+
"ember-data": "^3.28.0 || ^4.0.0",
|
|
157
|
+
"ember-modifier": "^3.2.7",
|
|
158
|
+
"ember-source": "^3.28.0 || ^4.0.0"
|
|
155
159
|
},
|
|
156
160
|
"overrides": {
|
|
157
161
|
"ember-intl": {
|
|
@@ -34,6 +34,7 @@ export type CitationPluginConfig = CitationPluginNodeConfig | CitationPluginRang
|
|
|
34
34
|
export type CitationPluginEmberComponentConfig = CitationPluginConfig & {
|
|
35
35
|
endpoint: string;
|
|
36
36
|
decisionsEndpoint?: string;
|
|
37
|
+
defaultDecisionsGovernmentName?: string;
|
|
37
38
|
};
|
|
38
39
|
export declare function citationPlugin(config: CitationPluginConfig): CitationPlugin;
|
|
39
40
|
export {};
|
|
@@ -32,6 +32,7 @@ export interface LegalDocumentsQueryFilter {
|
|
|
32
32
|
documentDateTo?: Option<string>;
|
|
33
33
|
publicationDateFrom?: Option<string>;
|
|
34
34
|
publicationDateTo?: Option<string>;
|
|
35
|
+
governmentName?: Option<string>;
|
|
35
36
|
}
|
|
36
37
|
export type LegalDocumentsQueryConfig = {
|
|
37
38
|
endpoint: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
1
|
+
import { EditorState, PNode } from '@lblod/ember-rdfa-editor';
|
|
2
2
|
export type OutlineEntry = {
|
|
3
3
|
content: string;
|
|
4
4
|
pos: number;
|
|
@@ -8,9 +8,10 @@ export declare function createTableOfContents(entries: OutlineEntry[]): [string,
|
|
|
8
8
|
type Config = {
|
|
9
9
|
nodeHierarchy: string[];
|
|
10
10
|
}[];
|
|
11
|
-
export declare function extractOutline({ node, pos, config, }: {
|
|
11
|
+
export declare function extractOutline({ node, pos, config, state, }: {
|
|
12
12
|
node: PNode;
|
|
13
13
|
pos: number;
|
|
14
14
|
config: Config;
|
|
15
|
+
state: EditorState;
|
|
15
16
|
}): OutlineEntry[];
|
|
16
17
|
export {};
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
export type DateFormat = {
|
|
2
|
+
label?: string;
|
|
3
|
+
key: string;
|
|
4
|
+
dateFormat: string;
|
|
5
|
+
dateTimeFormat: string;
|
|
6
|
+
};
|
|
7
|
+
export type DateOptions = {
|
|
8
|
+
formats: DateFormat[];
|
|
9
|
+
allowCustomFormat: boolean;
|
|
10
|
+
};
|
|
2
11
|
export declare const date: (options: DateOptions) => import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
3
12
|
export declare const dateView: (options: DateOptions) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("prosemirror-view").NodeViewConstructor;
|
package/translations/en-US.yaml
CHANGED
|
@@ -69,6 +69,7 @@ citaten-plugin:
|
|
|
69
69
|
title: Insert reference
|
|
70
70
|
search:
|
|
71
71
|
term: Search term
|
|
72
|
+
government-search: Filter by government
|
|
72
73
|
advanced: Advanced search
|
|
73
74
|
type: Type of document
|
|
74
75
|
placeholder: Type to search
|
|
@@ -191,6 +192,7 @@ document-title-plugin:
|
|
|
191
192
|
variable:
|
|
192
193
|
number:
|
|
193
194
|
placeholder: Insert number
|
|
195
|
+
label: number
|
|
194
196
|
type-number: Type a number...
|
|
195
197
|
error-not-integer: Only integers are allowed
|
|
196
198
|
error-not-number: Only numbers are allowed
|
|
@@ -202,6 +204,15 @@ variable:
|
|
|
202
204
|
codelist:
|
|
203
205
|
single-select: Single selection
|
|
204
206
|
multi-select: Multiple selection
|
|
207
|
+
label: codelist
|
|
208
|
+
location:
|
|
209
|
+
label: location
|
|
210
|
+
text:
|
|
211
|
+
label: text
|
|
212
|
+
date:
|
|
213
|
+
label: date
|
|
214
|
+
address:
|
|
215
|
+
label: address
|
|
205
216
|
variable-plugin:
|
|
206
217
|
insert-variable: Insert variable
|
|
207
218
|
button: Insert
|
|
@@ -282,6 +293,7 @@ template-comments-plugin:
|
|
|
282
293
|
remove: Remove template comment or example
|
|
283
294
|
move-up: Move comment up
|
|
284
295
|
move-down: Move comment down
|
|
296
|
+
heading: comment or example
|
|
285
297
|
|
|
286
298
|
pagination:
|
|
287
299
|
next: Next page
|
package/translations/nl-BE.yaml
CHANGED
|
@@ -70,6 +70,7 @@ citaten-plugin:
|
|
|
70
70
|
title: Citeeropschrift invoegen
|
|
71
71
|
search:
|
|
72
72
|
term: Zoekterm
|
|
73
|
+
government-search: Filter op bestuursorgaan
|
|
73
74
|
advanced: Uitgebreid zoeken
|
|
74
75
|
type: Type van document
|
|
75
76
|
placeholder: Typ om te zoeken
|
|
@@ -202,6 +203,7 @@ table-of-contents-plugin:
|
|
|
202
203
|
variable:
|
|
203
204
|
number:
|
|
204
205
|
placeholder: Voeg getal in
|
|
206
|
+
label: nummer
|
|
205
207
|
type-number: typ een nummer...
|
|
206
208
|
error-not-integer: Enkel gehele getallen zijn toegelaten
|
|
207
209
|
error-not-number: Enkel getallen zijn toegelaten
|
|
@@ -213,6 +215,15 @@ variable:
|
|
|
213
215
|
codelist:
|
|
214
216
|
single-select: Enkelvoudige selectie
|
|
215
217
|
multi-select: Meervoudige selectie
|
|
218
|
+
label: codelijst
|
|
219
|
+
location:
|
|
220
|
+
label: locatie
|
|
221
|
+
text:
|
|
222
|
+
label: tekst
|
|
223
|
+
date:
|
|
224
|
+
label: datum
|
|
225
|
+
address:
|
|
226
|
+
label: adres
|
|
216
227
|
variable-plugin:
|
|
217
228
|
insert-variable: Voeg variabele in
|
|
218
229
|
button: Voeg in
|
|
@@ -286,6 +297,8 @@ template-comments-plugin:
|
|
|
286
297
|
remove: Verwijder Toelichtings- of voorbeeldbepaling
|
|
287
298
|
move-down: Toelichtings- of voorbeeldbepaling naar onder
|
|
288
299
|
move-up: Toelichtings- of voorbeeldbepaling naar boven
|
|
300
|
+
heading: toelichtingsbepaling
|
|
301
|
+
|
|
289
302
|
pagination:
|
|
290
303
|
next: Volgende pagina
|
|
291
304
|
previous: Vorige pagina
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
import { action } from '@ember/object';
|
|
3
|
-
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
4
|
-
import { NodeSelection } from '@lblod/ember-rdfa-editor';
|
|
5
|
-
import {
|
|
6
|
-
DateFormat,
|
|
7
|
-
DateOptions,
|
|
8
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/rdfa-date-plugin';
|
|
9
|
-
import { Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
10
|
-
|
|
11
|
-
type Args = {
|
|
12
|
-
controller: SayController;
|
|
13
|
-
options: DateOptions;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default class RdfaDatePluginInsertComponent extends Component<Args> {
|
|
17
|
-
get controller() {
|
|
18
|
-
return this.args.controller;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
get schema() {
|
|
22
|
-
return this.controller.schema;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get formats(): DateFormat[] {
|
|
26
|
-
return this.args.options.formats;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get defaultDateFormat(): Option<string> {
|
|
30
|
-
return this.formats[0].dateFormat;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@action
|
|
34
|
-
insertDate() {
|
|
35
|
-
this.controller.withTransaction((tr) => {
|
|
36
|
-
tr.replaceSelectionWith(
|
|
37
|
-
this.schema.node('date', {
|
|
38
|
-
onlyDate: true,
|
|
39
|
-
format: this.defaultDateFormat,
|
|
40
|
-
value: new Date().toISOString(),
|
|
41
|
-
}),
|
|
42
|
-
);
|
|
43
|
-
if (tr.selection.$anchor.nodeBefore) {
|
|
44
|
-
const resolvedPos = tr.doc.resolve(
|
|
45
|
-
tr.selection.anchor - tr.selection.$anchor.nodeBefore?.nodeSize,
|
|
46
|
-
);
|
|
47
|
-
tr.setSelection(new NodeSelection(resolvedPos));
|
|
48
|
-
}
|
|
49
|
-
return tr;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const defaultDateFormats: DateFormat[] = [
|
|
2
|
-
{
|
|
3
|
-
key: 'short',
|
|
4
|
-
dateFormat: 'dd/MM/yy',
|
|
5
|
-
dateTimeFormat: 'dd/MM/yy HH:mm',
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
key: 'long',
|
|
9
|
-
dateFormat: 'EEEE dd MMMM yyyy',
|
|
10
|
-
dateTimeFormat: 'PPPPp',
|
|
11
|
-
},
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
export type DateFormat = {
|
|
15
|
-
label?: string;
|
|
16
|
-
key: string;
|
|
17
|
-
dateFormat: string;
|
|
18
|
-
dateTimeFormat: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type DateOptions = {
|
|
22
|
-
placeholder: {
|
|
23
|
-
insertDate: string;
|
|
24
|
-
insertDateTime: string;
|
|
25
|
-
};
|
|
26
|
-
formats: DateFormat[];
|
|
27
|
-
allowCustomFormat: boolean;
|
|
28
|
-
};
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createEmberNodeSpec,
|
|
3
|
-
createEmberNodeView,
|
|
4
|
-
EmberNodeConfig,
|
|
5
|
-
} from '@lblod/ember-rdfa-editor/utils/ember-node';
|
|
6
|
-
import {
|
|
7
|
-
EXT,
|
|
8
|
-
XSD,
|
|
9
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
10
|
-
import { hasRDFaAttribute } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
11
|
-
import { DateOptions } from '..';
|
|
12
|
-
import { formatDate, validateDateFormat } from '../utils';
|
|
13
|
-
import { PNode } from '@lblod/ember-rdfa-editor';
|
|
14
|
-
import {
|
|
15
|
-
isVariable,
|
|
16
|
-
parseLabel,
|
|
17
|
-
parseVariableType,
|
|
18
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/attribute-parsers';
|
|
19
|
-
import {
|
|
20
|
-
mappingSpan,
|
|
21
|
-
typeSpan,
|
|
22
|
-
} from '../../variable-plugin/utils/dom-constructors';
|
|
23
|
-
import { span } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/dom-output-spec-helpers';
|
|
24
|
-
|
|
25
|
-
const emberNodeConfig = (options: DateOptions): EmberNodeConfig => ({
|
|
26
|
-
name: 'date',
|
|
27
|
-
group: 'inline variable',
|
|
28
|
-
componentPath: 'rdfa-date-plugin/date',
|
|
29
|
-
inline: true,
|
|
30
|
-
selectable: true,
|
|
31
|
-
draggable: false,
|
|
32
|
-
atom: true,
|
|
33
|
-
defining: false,
|
|
34
|
-
options,
|
|
35
|
-
attrs: {
|
|
36
|
-
mappingResource: {
|
|
37
|
-
default: null,
|
|
38
|
-
},
|
|
39
|
-
humanReadableDate: {
|
|
40
|
-
default: options.placeholder.insertDate,
|
|
41
|
-
},
|
|
42
|
-
value: {},
|
|
43
|
-
format: {
|
|
44
|
-
default: options.formats[0].dateFormat,
|
|
45
|
-
},
|
|
46
|
-
onlyDate: {
|
|
47
|
-
default: true,
|
|
48
|
-
},
|
|
49
|
-
custom: {
|
|
50
|
-
default: false,
|
|
51
|
-
},
|
|
52
|
-
label: {
|
|
53
|
-
default: 'datum',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
leafText: (node: PNode) => {
|
|
57
|
-
const { value, onlyDate, format } = node.attrs;
|
|
58
|
-
const humanReadableDate = value
|
|
59
|
-
? formatDate(new Date(value), format)
|
|
60
|
-
: onlyDate
|
|
61
|
-
? options.placeholder.insertDate
|
|
62
|
-
: options.placeholder.insertDateTime;
|
|
63
|
-
return humanReadableDate;
|
|
64
|
-
},
|
|
65
|
-
toDOM: (node) => {
|
|
66
|
-
const { value, onlyDate, format, mappingResource, custom, label } =
|
|
67
|
-
node.attrs;
|
|
68
|
-
const datatype = onlyDate ? XSD('date') : XSD('dateTime');
|
|
69
|
-
let humanReadableDate: string;
|
|
70
|
-
if (value) {
|
|
71
|
-
if (validateDateFormat(format).type === 'ok') {
|
|
72
|
-
humanReadableDate = formatDate(new Date(value), format);
|
|
73
|
-
} else {
|
|
74
|
-
humanReadableDate = 'Ongeldig formaat';
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
humanReadableDate = (onlyDate as boolean)
|
|
78
|
-
? options.placeholder.insertDate
|
|
79
|
-
: options.placeholder.insertDateTime;
|
|
80
|
-
}
|
|
81
|
-
const dateAttrs = {
|
|
82
|
-
datatype: datatype.prefixed,
|
|
83
|
-
property: EXT('content').prefixed,
|
|
84
|
-
'data-format': format as string,
|
|
85
|
-
'data-custom': custom ? 'true' : 'false',
|
|
86
|
-
...(!!value && { content: value as string }),
|
|
87
|
-
};
|
|
88
|
-
if (mappingResource) {
|
|
89
|
-
return mappingSpan(
|
|
90
|
-
mappingResource,
|
|
91
|
-
{ class: 'date', 'data-label': label as string },
|
|
92
|
-
typeSpan('date'),
|
|
93
|
-
span(dateAttrs, humanReadableDate),
|
|
94
|
-
);
|
|
95
|
-
} else {
|
|
96
|
-
return span({ class: 'date', ...dateAttrs }, humanReadableDate);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
parseDOM: [
|
|
100
|
-
{
|
|
101
|
-
tag: 'span',
|
|
102
|
-
getAttrs: (node: HTMLElement) => {
|
|
103
|
-
if (
|
|
104
|
-
hasRDFaAttribute(node, 'datatype', XSD('date')) ||
|
|
105
|
-
hasRDFaAttribute(node, 'datatype', XSD('dateTime'))
|
|
106
|
-
) {
|
|
107
|
-
const onlyDate = hasRDFaAttribute(node, 'datatype', XSD('date'));
|
|
108
|
-
return {
|
|
109
|
-
value: node.getAttribute('content') ?? new Date().toISOString(),
|
|
110
|
-
onlyDate,
|
|
111
|
-
format: node.dataset.format,
|
|
112
|
-
custom: node.dataset.custom === 'true',
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
tag: 'span',
|
|
120
|
-
getAttrs: (node: HTMLElement) => {
|
|
121
|
-
if (isVariable(node) && parseVariableType(node) === 'date') {
|
|
122
|
-
const mappingResource = node.getAttribute('resource');
|
|
123
|
-
if (!mappingResource) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
const onlyDate = !![...node.children].find((el) =>
|
|
127
|
-
hasRDFaAttribute(el, 'datatype', XSD('date')),
|
|
128
|
-
);
|
|
129
|
-
const dateNode = [...node.children].find((el) =>
|
|
130
|
-
hasRDFaAttribute(el, 'property', EXT('content')),
|
|
131
|
-
) as HTMLElement | undefined;
|
|
132
|
-
let humanReadableDate: string;
|
|
133
|
-
const value = dateNode?.getAttribute('content');
|
|
134
|
-
const format = dateNode?.dataset.format;
|
|
135
|
-
if (value && format) {
|
|
136
|
-
if (validateDateFormat(format).type === 'ok') {
|
|
137
|
-
humanReadableDate = formatDate(new Date(value), format);
|
|
138
|
-
} else {
|
|
139
|
-
humanReadableDate = 'Ongeldig formaat';
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
142
|
-
humanReadableDate = onlyDate
|
|
143
|
-
? options.placeholder.insertDate
|
|
144
|
-
: options.placeholder.insertDateTime;
|
|
145
|
-
}
|
|
146
|
-
const label = parseLabel(node);
|
|
147
|
-
return {
|
|
148
|
-
mappingResource,
|
|
149
|
-
onlyDate,
|
|
150
|
-
humanReadableDate,
|
|
151
|
-
value: value,
|
|
152
|
-
format: format,
|
|
153
|
-
custom: dateNode?.dataset.custom === 'true',
|
|
154
|
-
label,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return false;
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
export const date = (options: DateOptions) =>
|
|
165
|
-
createEmberNodeSpec(emberNodeConfig(options));
|
|
166
|
-
export const dateView = (options: DateOptions) =>
|
|
167
|
-
createEmberNodeView(emberNodeConfig(options));
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
3
|
-
import { DateFormat, DateOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/rdfa-date-plugin';
|
|
4
|
-
import { Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
5
|
-
type Args = {
|
|
6
|
-
controller: SayController;
|
|
7
|
-
options: DateOptions;
|
|
8
|
-
};
|
|
9
|
-
export default class RdfaDatePluginInsertComponent extends Component<Args> {
|
|
10
|
-
get controller(): SayController;
|
|
11
|
-
get schema(): import("prosemirror-model").Schema<any, any>;
|
|
12
|
-
get formats(): DateFormat[];
|
|
13
|
-
get defaultDateFormat(): Option<string>;
|
|
14
|
-
insertDate(): void;
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare const defaultDateFormats: DateFormat[];
|
|
2
|
-
export type DateFormat = {
|
|
3
|
-
label?: string;
|
|
4
|
-
key: string;
|
|
5
|
-
dateFormat: string;
|
|
6
|
-
dateTimeFormat: string;
|
|
7
|
-
};
|
|
8
|
-
export type DateOptions = {
|
|
9
|
-
placeholder: {
|
|
10
|
-
insertDate: string;
|
|
11
|
-
insertDateTime: string;
|
|
12
|
-
};
|
|
13
|
-
formats: DateFormat[];
|
|
14
|
-
allowCustomFormat: boolean;
|
|
15
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|