@lblod/ember-rdfa-editor-lblod-plugins 12.1.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/CHANGELOG.md +29 -0
- package/README.md +215 -164
- 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/insert-variable.ts +14 -1
- package/addon/components/variable-plugin/address/insert.ts +15 -1
- package/addon/components/variable-plugin/address/nodeview.hbs +1 -1
- package/addon/components/variable-plugin/address/nodeview.ts +23 -1
- 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.ts → variable-plugin/date/nodeview.ts} +20 -6
- package/addon/components/variable-plugin/location/insert.ts +11 -2
- 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 +1 -1
- package/addon/components/variable-plugin/number/nodeview.ts +17 -0
- package/addon/components/variable-plugin/text/insert.ts +14 -2
- 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/{rdfa-date-plugin/date.js → variable-plugin/date/date-time-picker.js} +1 -1
- 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-time-picker.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/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 +2 -2
- package/components/template-comments-plugin/template-comment.d.ts +6 -0
- package/components/variable-plugin/address/insert-variable.d.ts +3 -0
- package/components/variable-plugin/address/insert.d.ts +3 -0
- package/components/variable-plugin/address/nodeview.d.ts +7 -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/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/package.json +8 -6
- 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 +11 -0
- package/translations/nl-BE.yaml +12 -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/components/{rdfa-date-plugin/date.hbs → variable-plugin/date/nodeview.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,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
|
|
File without changes
|