@lblod/ember-rdfa-editor-lblod-plugins 38.0.2 → 38.0.3-dev.8a844bd88a2bc1786034136bb02c3d7891ef57ac
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/.changeset/four-kiwis-smash.md +5 -0
- package/.changeset/khaki-poets-remain.md +5 -0
- package/.changeset/kind-humans-allow.md +5 -0
- package/.changeset/soft-rabbits-jump.md +8 -0
- package/CHANGELOG.md +6 -0
- package/addon/plugins/variable-plugin/contextual-actions/codelist.ts +132 -0
- package/addon/plugins/variable-plugin/contextual-actions/index.ts +6 -217
- package/addon/plugins/variable-plugin/contextual-actions/place-description.ts +222 -0
- package/addon/plugins/variable-plugin/utils/codelist-utils.ts +46 -25
- package/declarations/addon/plugins/location-plugin/node.d.ts +1 -1
- package/declarations/addon/plugins/locked-placeholder-plugin/nodes/block-locked-placeholder.d.ts +1 -1
- package/declarations/addon/plugins/locked-placeholder-plugin/nodes/inline-locked-placeholder.d.ts +1 -1
- package/declarations/addon/plugins/mandatee-table-plugin/node.d.ts +1 -1
- package/declarations/addon/plugins/snippet-plugin/nodes/snippet-placeholder.d.ts +1 -1
- package/declarations/addon/plugins/snippet-plugin/nodes/snippet.d.ts +1 -1
- package/declarations/addon/plugins/structure-plugin/node.d.ts +2 -2
- package/declarations/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +1 -1
- package/declarations/addon/plugins/template-comments-plugin/node.d.ts +1 -1
- package/declarations/addon/plugins/variable-plugin/contextual-actions/codelist.d.ts +14 -0
- package/declarations/addon/plugins/variable-plugin/contextual-actions/index.d.ts +5 -15
- package/declarations/addon/plugins/variable-plugin/contextual-actions/place-description.d.ts +15 -0
- package/declarations/addon/plugins/variable-plugin/utils/codelist-utils.d.ts +3 -1
- package/declarations/addon/plugins/variable-plugin/variables/address.d.ts +1 -1
- package/declarations/addon/plugins/variable-plugin/variables/autofilled.d.ts +1 -1
- package/declarations/addon/plugins/variable-plugin/variables/codelist.d.ts +1 -1
- package/declarations/addon/plugins/variable-plugin/variables/date.d.ts +1 -1
- package/declarations/addon/plugins/variable-plugin/variables/legacy-codelist.d.ts +1 -1
- package/declarations/addon/plugins/variable-plugin/variables/location.d.ts +1 -1
- package/declarations/addon/plugins/variable-plugin/variables/number.d.ts +1 -1
- package/declarations/addon/plugins/variable-plugin/variables/person.d.ts +1 -1
- package/declarations/addon/plugins/variable-plugin/variables/text.d.ts +1 -1
- package/package.json +3 -3
- package/pnpm-workspace.yaml +1 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
'@lblod/ember-rdfa-editor-lblod-plugins': minor
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Add contextual actions for filling in codelist values. This introduces new contextual actions for
|
|
6
|
+
the variable-plugin, so the import for place description actions has moved to
|
|
7
|
+
`@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/contextual-actions/place-description`.
|
|
8
|
+
The old import location remains for backwards compatibility.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 38.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`448e7e3`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/448e7e324996d4422d2ba236bd3fba8970a8bb5d) Thanks [@abeforgit](https://github.com/abeforgit)! - Republish 38.0.2
|
|
8
|
+
|
|
3
9
|
## 38.0.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { EditorState } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import { getActiveEditableNode } from '@lblod/ember-rdfa-editor/plugins/editable-node';
|
|
4
|
+
import { isRdfaAttrs } from '@lblod/ember-rdfa-editor/core/rdfa-types';
|
|
5
|
+
import { ContextualActionGroup } from '@lblod/ember-rdfa-editor/plugins/contextual-actions';
|
|
6
|
+
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
7
|
+
import { getTranslationFunction } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/translation';
|
|
8
|
+
import { updateCodelistVariableCommand } from '../utils/codelist-utils';
|
|
9
|
+
import {
|
|
10
|
+
type CodeListOptions,
|
|
11
|
+
fetchCodeListOptions,
|
|
12
|
+
CodeListOption,
|
|
13
|
+
} from '../utils/fetch-data';
|
|
14
|
+
import { CodelistAttrs } from '../variables';
|
|
15
|
+
|
|
16
|
+
const codelistGroupId = 'codelist-db36f85d-edbf-45dc-85fc-9fb67649fe00';
|
|
17
|
+
|
|
18
|
+
const codelistOptionsCache: Map<string, CodeListOptions> = new Map();
|
|
19
|
+
|
|
20
|
+
function getSource(codelistAttrs: CodelistAttrs, fallback?: string) {
|
|
21
|
+
if (codelistAttrs) {
|
|
22
|
+
const source = codelistAttrs['source'];
|
|
23
|
+
if (source && source !== 'UNKNOWN') {
|
|
24
|
+
return source;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return fallback;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type GetContextualActionsAttrs = {
|
|
31
|
+
endpoint?: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function humanReadableLabel(label: string) {
|
|
35
|
+
return label.replace(/\$\{[^}]+\}/g, '…');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function getCodelistOptionsCached(
|
|
39
|
+
activeNode: ResolvedPNode,
|
|
40
|
+
{ endpoint }: GetContextualActionsAttrs,
|
|
41
|
+
) {
|
|
42
|
+
const codelistAttrs = activeNode.value.attrs as CodelistAttrs | undefined;
|
|
43
|
+
const source = codelistAttrs && getSource(codelistAttrs, endpoint);
|
|
44
|
+
const codelistUri = codelistAttrs?.codelist;
|
|
45
|
+
|
|
46
|
+
let result = codelistUri && codelistOptionsCache.get(codelistUri);
|
|
47
|
+
if (!result && codelistAttrs?.hardcodedOptionList) {
|
|
48
|
+
result = {
|
|
49
|
+
type: '',
|
|
50
|
+
options: codelistAttrs.hardcodedOptionList,
|
|
51
|
+
} as CodeListOptions;
|
|
52
|
+
}
|
|
53
|
+
if (!result && source && codelistUri) {
|
|
54
|
+
result = await fetchCodeListOptions(source, codelistUri);
|
|
55
|
+
codelistOptionsCache.set(codelistUri, result);
|
|
56
|
+
if (!result) {
|
|
57
|
+
console.warn(
|
|
58
|
+
`Failed to fetch codelist options for ${codelistUri} from ${source}`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return result || { type: '', options: [] };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function getContextualActions(attrs: GetContextualActionsAttrs) {
|
|
67
|
+
return async function (state: EditorState, searchQuery?: string) {
|
|
68
|
+
const activeNode = getActiveEditableNode(state);
|
|
69
|
+
if (!activeNode) return [];
|
|
70
|
+
const result = await getCodelistOptionsCached(activeNode, attrs);
|
|
71
|
+
const isMultiSelect = activeNode.value.attrs['selectionStyle'] === 'multi';
|
|
72
|
+
const selectedOptions: CodeListOption[] = [];
|
|
73
|
+
activeNode.value.content.forEach((contentNode) => {
|
|
74
|
+
selectedOptions.push({
|
|
75
|
+
uri: contentNode.attrs.subject,
|
|
76
|
+
label: contentNode.textContent,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return result.options
|
|
81
|
+
.filter(
|
|
82
|
+
(option) =>
|
|
83
|
+
!searchQuery ||
|
|
84
|
+
option.label.toLowerCase().includes(searchQuery.toLowerCase()),
|
|
85
|
+
)
|
|
86
|
+
.map((option) => {
|
|
87
|
+
const selected = selectedOptions.some(
|
|
88
|
+
(selOption) => selOption.uri === option.uri,
|
|
89
|
+
);
|
|
90
|
+
const newOptions = selected
|
|
91
|
+
? selectedOptions.filter((selOption) => selOption.uri !== option.uri)
|
|
92
|
+
: isMultiSelect
|
|
93
|
+
? [...selectedOptions, option]
|
|
94
|
+
: option;
|
|
95
|
+
return {
|
|
96
|
+
id: uuidv4(),
|
|
97
|
+
label: humanReadableLabel(option.label),
|
|
98
|
+
group: codelistGroupId,
|
|
99
|
+
command: updateCodelistVariableCommand(activeNode, newOptions),
|
|
100
|
+
selected,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function contextualGroupIsVisible(state: EditorState) {
|
|
107
|
+
const activeNode = getActiveEditableNode(state);
|
|
108
|
+
const isCodelist =
|
|
109
|
+
activeNode &&
|
|
110
|
+
isRdfaAttrs(activeNode.value.attrs) &&
|
|
111
|
+
activeNode?.value.type.name === 'codelist';
|
|
112
|
+
|
|
113
|
+
return isCodelist;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function getCodelistActionGroups(attrs: GetContextualActionsAttrs) {
|
|
117
|
+
return function (state: EditorState): ContextualActionGroup[] {
|
|
118
|
+
return contextualGroupIsVisible(state)
|
|
119
|
+
? [
|
|
120
|
+
{
|
|
121
|
+
id: codelistGroupId,
|
|
122
|
+
label: getTranslationFunction(state)(
|
|
123
|
+
'variable.codelist.label',
|
|
124
|
+
'Codelijst',
|
|
125
|
+
),
|
|
126
|
+
keepOpen: true,
|
|
127
|
+
getActions: getContextualActions(attrs),
|
|
128
|
+
},
|
|
129
|
+
]
|
|
130
|
+
: [];
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -1,217 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { findParentNode } from '@curvenote/prosemirror-utils';
|
|
8
|
-
import {
|
|
9
|
-
getOutgoingTriple,
|
|
10
|
-
hasOutgoingNamedNodeTriple,
|
|
11
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
12
|
-
import {
|
|
13
|
-
EXT,
|
|
14
|
-
MOBILITEIT,
|
|
15
|
-
RDF,
|
|
16
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
17
|
-
import {
|
|
18
|
-
ZONALITY_OPTIONS,
|
|
19
|
-
ZONALITY_OPTIONS_LEGACY,
|
|
20
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/constants';
|
|
21
|
-
import { ProseParser } from '@lblod/ember-rdfa-editor';
|
|
22
|
-
import { wrapVariableInHighlight } from '../utils/codelist-utils';
|
|
23
|
-
import { getActiveEditableNode } from '@lblod/ember-rdfa-editor/plugins/editable-node';
|
|
24
|
-
import { isRdfaAttrs } from '@lblod/ember-rdfa-editor/core/rdfa-types';
|
|
25
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
26
|
-
import { getTranslationFunction } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/translation';
|
|
27
|
-
import { type CodeListOptions } from '../utils/fetch-data';
|
|
28
|
-
import { ContextualActionGroup } from '@lblod/ember-rdfa-editor/plugins/contextual-actions';
|
|
29
|
-
|
|
30
|
-
const plaatsbepalingGroupId =
|
|
31
|
-
'plaatsbepaling-1d8563d6-bfd8-487f-a2a0-6d7a6ab01cb5';
|
|
32
|
-
|
|
33
|
-
const placeDescriptionCodelistCache: {
|
|
34
|
-
placeDescriptions: CodeListOptions | null;
|
|
35
|
-
} = {
|
|
36
|
-
placeDescriptions: null,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
function getSelectedLocation(state: EditorState) {
|
|
40
|
-
const { selection } = state;
|
|
41
|
-
if (
|
|
42
|
-
selection instanceof NodeSelection &&
|
|
43
|
-
selection.node.type === state.schema.nodes.location
|
|
44
|
-
) {
|
|
45
|
-
return {
|
|
46
|
-
node: selection.node,
|
|
47
|
-
pos: selection.from,
|
|
48
|
-
};
|
|
49
|
-
} else {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function getSource(state: EditorState, fallback?: string) {
|
|
55
|
-
const selectedLocation = getSelectedLocation(state);
|
|
56
|
-
if (selectedLocation) {
|
|
57
|
-
const { node } = selectedLocation;
|
|
58
|
-
const source = node.attrs.source;
|
|
59
|
-
if (source) {
|
|
60
|
-
return source;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return fallback;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function getIsZonal(state: EditorState) {
|
|
68
|
-
const { selection } = state;
|
|
69
|
-
const mobilityMeasureNode = findParentNode((node) =>
|
|
70
|
-
hasOutgoingNamedNodeTriple(
|
|
71
|
-
node.attrs,
|
|
72
|
-
RDF('type'),
|
|
73
|
-
MOBILITEIT('Mobiliteitsmaatregel'),
|
|
74
|
-
),
|
|
75
|
-
)(selection)?.node;
|
|
76
|
-
if (!mobilityMeasureNode) {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
const zonalityTriple = getOutgoingTriple(
|
|
80
|
-
mobilityMeasureNode.attrs,
|
|
81
|
-
EXT('zonality'),
|
|
82
|
-
);
|
|
83
|
-
if (!zonalityTriple) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
return (
|
|
87
|
-
zonalityTriple.object.value === ZONALITY_OPTIONS.ZONAL ||
|
|
88
|
-
zonalityTriple.object.value === ZONALITY_OPTIONS_LEGACY.ZONAL
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
type GetContextualActionsAttrs = {
|
|
93
|
-
zonalLocationCodelistUri: string;
|
|
94
|
-
nonZonalLocationCodelistUri: string;
|
|
95
|
-
endpoint?: string;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
function humanReadableLabel(label: string) {
|
|
99
|
-
return label.replace(/\$\{[^}]+\}/g, '…');
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function createInsertPlaceDescriptionCommand(label: string) {
|
|
103
|
-
return (state: EditorState, dispatch?: (tr: Transaction) => void) => {
|
|
104
|
-
if (dispatch) {
|
|
105
|
-
let htmlToInsert = label;
|
|
106
|
-
htmlToInsert = wrapVariableInHighlight(htmlToInsert);
|
|
107
|
-
const domParser = new DOMParser();
|
|
108
|
-
const htmlNode = domParser.parseFromString(htmlToInsert, 'text/html');
|
|
109
|
-
const contentFragment = ProseParser.fromSchema(state.schema).parseSlice(
|
|
110
|
-
htmlNode,
|
|
111
|
-
{
|
|
112
|
-
preserveWhitespace: false,
|
|
113
|
-
},
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const tr = state.tr;
|
|
117
|
-
const startPos = tr.selection.from;
|
|
118
|
-
tr.replaceSelection(contentFragment);
|
|
119
|
-
|
|
120
|
-
let highlightPos: number | null = null;
|
|
121
|
-
|
|
122
|
-
contentFragment.content.descendants((child, pos) => {
|
|
123
|
-
if (highlightPos !== null) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
if (child.type.name === state.schema.nodes.placeholder.name) {
|
|
127
|
-
highlightPos = startPos + pos;
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
return true;
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
if (highlightPos !== null) {
|
|
134
|
-
tr.setSelection(NodeSelection.create(tr.doc, highlightPos));
|
|
135
|
-
}
|
|
136
|
-
dispatch(tr);
|
|
137
|
-
}
|
|
138
|
-
return true;
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async function getPlaceDescriptionsCached(
|
|
143
|
-
state: EditorState,
|
|
144
|
-
{
|
|
145
|
-
zonalLocationCodelistUri,
|
|
146
|
-
nonZonalLocationCodelistUri,
|
|
147
|
-
endpoint,
|
|
148
|
-
}: GetContextualActionsAttrs,
|
|
149
|
-
) {
|
|
150
|
-
const source = getSource(state, endpoint);
|
|
151
|
-
const isZonal = getIsZonal(state);
|
|
152
|
-
let options;
|
|
153
|
-
if (!placeDescriptionCodelistCache.placeDescriptions) {
|
|
154
|
-
options = await fetchCodeListOptions(
|
|
155
|
-
source,
|
|
156
|
-
isZonal ? zonalLocationCodelistUri : nonZonalLocationCodelistUri,
|
|
157
|
-
);
|
|
158
|
-
placeDescriptionCodelistCache.placeDescriptions = options;
|
|
159
|
-
} else {
|
|
160
|
-
options = placeDescriptionCodelistCache.placeDescriptions;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return options;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export function getContextualActions(attrs: GetContextualActionsAttrs) {
|
|
167
|
-
return async function (state: EditorState, searchQuery?: string) {
|
|
168
|
-
const result = await getPlaceDescriptionsCached(state, attrs);
|
|
169
|
-
return result.options
|
|
170
|
-
.filter(
|
|
171
|
-
(option) =>
|
|
172
|
-
!searchQuery ||
|
|
173
|
-
option.label.toLowerCase().includes(searchQuery.toLowerCase()),
|
|
174
|
-
)
|
|
175
|
-
.map((option) => {
|
|
176
|
-
return {
|
|
177
|
-
id: uuidv4(),
|
|
178
|
-
label: humanReadableLabel(option.label),
|
|
179
|
-
group: plaatsbepalingGroupId,
|
|
180
|
-
command: createInsertPlaceDescriptionCommand(option.label),
|
|
181
|
-
};
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function contextualGroupIsVisible(state: EditorState) {
|
|
187
|
-
const activeNode = getActiveEditableNode(state);
|
|
188
|
-
const isPlaatsbepaling =
|
|
189
|
-
activeNode &&
|
|
190
|
-
isRdfaAttrs(activeNode.value.attrs) &&
|
|
191
|
-
activeNode.value.attrs.backlinks.some((value) =>
|
|
192
|
-
MOBILITEIT('plaatsbepaling').matches(value.predicate),
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
const isEmptySelection = state.selection.empty;
|
|
196
|
-
return (
|
|
197
|
-
(activeNode?.value.type.name === 'location' || isPlaatsbepaling) &&
|
|
198
|
-
isEmptySelection
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function getContextualActionGroups(attrs: GetContextualActionsAttrs) {
|
|
203
|
-
return function (state: EditorState): ContextualActionGroup[] {
|
|
204
|
-
return contextualGroupIsVisible(state)
|
|
205
|
-
? [
|
|
206
|
-
{
|
|
207
|
-
id: plaatsbepalingGroupId,
|
|
208
|
-
label: getTranslationFunction(state)(
|
|
209
|
-
'variable.location.label',
|
|
210
|
-
'Plaatsbeschrijving',
|
|
211
|
-
),
|
|
212
|
-
getActions: getContextualActions(attrs),
|
|
213
|
-
},
|
|
214
|
-
]
|
|
215
|
-
: [];
|
|
216
|
-
};
|
|
217
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
/** @deprecated these imports have been moved to contextual-actions/place-description.ts */
|
|
3
|
+
getContextualActions,
|
|
4
|
+
/** @deprecated these imports have been moved to contextual-actions/place-description.ts */
|
|
5
|
+
getPlaceDescriptionActionGroups as getContextualActionGroups,
|
|
6
|
+
} from './place-description';
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EditorState,
|
|
3
|
+
NodeSelection,
|
|
4
|
+
Transaction,
|
|
5
|
+
} from '@lblod/ember-rdfa-editor';
|
|
6
|
+
import { fetchCodeListOptions } from '../utils/fetch-data';
|
|
7
|
+
import { findParentNode } from '@curvenote/prosemirror-utils';
|
|
8
|
+
import {
|
|
9
|
+
getOutgoingTriple,
|
|
10
|
+
hasOutgoingNamedNodeTriple,
|
|
11
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
12
|
+
import {
|
|
13
|
+
EXT,
|
|
14
|
+
MOBILITEIT,
|
|
15
|
+
RDF,
|
|
16
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
17
|
+
import {
|
|
18
|
+
ZONALITY_OPTIONS,
|
|
19
|
+
ZONALITY_OPTIONS_LEGACY,
|
|
20
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/constants';
|
|
21
|
+
import { ProseParser } from '@lblod/ember-rdfa-editor';
|
|
22
|
+
import { wrapVariableInHighlight } from '../utils/codelist-utils';
|
|
23
|
+
import { getActiveEditableNode } from '@lblod/ember-rdfa-editor/plugins/editable-node';
|
|
24
|
+
import { isRdfaAttrs } from '@lblod/ember-rdfa-editor/core/rdfa-types';
|
|
25
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
26
|
+
import { getTranslationFunction } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/translation';
|
|
27
|
+
import { type CodeListOptions } from '../utils/fetch-data';
|
|
28
|
+
import { ContextualActionGroup } from '@lblod/ember-rdfa-editor/plugins/contextual-actions';
|
|
29
|
+
|
|
30
|
+
const plaatsbepalingGroupId =
|
|
31
|
+
'plaatsbepaling-1d8563d6-bfd8-487f-a2a0-6d7a6ab01cb5';
|
|
32
|
+
|
|
33
|
+
const placeDescriptionCodelistCache: {
|
|
34
|
+
zonal: CodeListOptions | null;
|
|
35
|
+
nonZonal: CodeListOptions | null;
|
|
36
|
+
} = {
|
|
37
|
+
zonal: null,
|
|
38
|
+
nonZonal: null,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function getSelectedLocation(state: EditorState) {
|
|
42
|
+
const { selection } = state;
|
|
43
|
+
if (
|
|
44
|
+
selection instanceof NodeSelection &&
|
|
45
|
+
selection.node.type === state.schema.nodes.location
|
|
46
|
+
) {
|
|
47
|
+
return {
|
|
48
|
+
node: selection.node,
|
|
49
|
+
pos: selection.from,
|
|
50
|
+
};
|
|
51
|
+
} else {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getSource(state: EditorState, fallback: string) {
|
|
57
|
+
const selectedLocation = getSelectedLocation(state);
|
|
58
|
+
if (selectedLocation) {
|
|
59
|
+
const { node } = selectedLocation;
|
|
60
|
+
const source = node.attrs.source as string | undefined;
|
|
61
|
+
if (source) {
|
|
62
|
+
return source;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return fallback;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getIsZonal(state: EditorState) {
|
|
70
|
+
const { selection } = state;
|
|
71
|
+
const mobilityMeasureNode = findParentNode((node) =>
|
|
72
|
+
hasOutgoingNamedNodeTriple(
|
|
73
|
+
node.attrs,
|
|
74
|
+
RDF('type'),
|
|
75
|
+
MOBILITEIT('Mobiliteitsmaatregel'),
|
|
76
|
+
),
|
|
77
|
+
)(selection)?.node;
|
|
78
|
+
if (!mobilityMeasureNode) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const zonalityTriple = getOutgoingTriple(
|
|
82
|
+
mobilityMeasureNode.attrs,
|
|
83
|
+
EXT('zonality'),
|
|
84
|
+
);
|
|
85
|
+
if (!zonalityTriple) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return (
|
|
89
|
+
zonalityTriple.object.value === ZONALITY_OPTIONS.ZONAL ||
|
|
90
|
+
zonalityTriple.object.value === ZONALITY_OPTIONS_LEGACY.ZONAL
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
type GetContextualActionsAttrs = {
|
|
95
|
+
zonalLocationCodelistUri: string;
|
|
96
|
+
nonZonalLocationCodelistUri: string;
|
|
97
|
+
endpoint: string;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
function humanReadableLabel(label: string) {
|
|
101
|
+
return label.replace(/\$\{[^}]+\}/g, '…');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function createInsertPlaceDescriptionCommand(label: string) {
|
|
105
|
+
return (state: EditorState, dispatch?: (tr: Transaction) => void) => {
|
|
106
|
+
if (dispatch) {
|
|
107
|
+
let htmlToInsert = label;
|
|
108
|
+
htmlToInsert = wrapVariableInHighlight(htmlToInsert);
|
|
109
|
+
const domParser = new DOMParser();
|
|
110
|
+
const htmlNode = domParser.parseFromString(htmlToInsert, 'text/html');
|
|
111
|
+
const contentFragment = ProseParser.fromSchema(state.schema).parseSlice(
|
|
112
|
+
htmlNode,
|
|
113
|
+
{
|
|
114
|
+
preserveWhitespace: false,
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const tr = state.tr;
|
|
119
|
+
const startPos = tr.selection.from;
|
|
120
|
+
tr.replaceSelection(contentFragment);
|
|
121
|
+
|
|
122
|
+
let highlightPos: number | null = null;
|
|
123
|
+
|
|
124
|
+
contentFragment.content.descendants((child, pos) => {
|
|
125
|
+
if (highlightPos !== null) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
if (child.type.name === state.schema.nodes.placeholder.name) {
|
|
129
|
+
highlightPos = startPos + pos;
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (highlightPos !== null) {
|
|
136
|
+
tr.setSelection(NodeSelection.create(tr.doc, highlightPos));
|
|
137
|
+
}
|
|
138
|
+
dispatch(tr);
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function getPlaceDescriptionsCached(
|
|
145
|
+
state: EditorState,
|
|
146
|
+
{
|
|
147
|
+
zonalLocationCodelistUri,
|
|
148
|
+
nonZonalLocationCodelistUri,
|
|
149
|
+
endpoint,
|
|
150
|
+
}: GetContextualActionsAttrs,
|
|
151
|
+
) {
|
|
152
|
+
const source = getSource(state, endpoint);
|
|
153
|
+
const isZonal = getIsZonal(state);
|
|
154
|
+
const zonality = isZonal ? 'zonal' : 'nonZonal';
|
|
155
|
+
let options;
|
|
156
|
+
if (!placeDescriptionCodelistCache[zonality]) {
|
|
157
|
+
options = await fetchCodeListOptions(
|
|
158
|
+
source,
|
|
159
|
+
isZonal ? zonalLocationCodelistUri : nonZonalLocationCodelistUri,
|
|
160
|
+
);
|
|
161
|
+
placeDescriptionCodelistCache[zonality] = options;
|
|
162
|
+
} else {
|
|
163
|
+
options = placeDescriptionCodelistCache[zonality];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return options;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function getContextualActions(attrs: GetContextualActionsAttrs) {
|
|
170
|
+
return async function (state: EditorState, searchQuery?: string) {
|
|
171
|
+
const result = await getPlaceDescriptionsCached(state, attrs);
|
|
172
|
+
return result.options
|
|
173
|
+
.filter(
|
|
174
|
+
(option) =>
|
|
175
|
+
!searchQuery ||
|
|
176
|
+
option.label.toLowerCase().includes(searchQuery.toLowerCase()),
|
|
177
|
+
)
|
|
178
|
+
.map((option) => {
|
|
179
|
+
return {
|
|
180
|
+
id: uuidv4(),
|
|
181
|
+
label: humanReadableLabel(option.label),
|
|
182
|
+
group: plaatsbepalingGroupId,
|
|
183
|
+
command: createInsertPlaceDescriptionCommand(option.label),
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function contextualGroupIsVisible(state: EditorState) {
|
|
190
|
+
const activeNode = getActiveEditableNode(state);
|
|
191
|
+
const isPlaatsbepaling =
|
|
192
|
+
activeNode &&
|
|
193
|
+
isRdfaAttrs(activeNode.value.attrs) &&
|
|
194
|
+
activeNode.value.attrs.backlinks.some((value) =>
|
|
195
|
+
MOBILITEIT('plaatsbepaling').matches(value.predicate),
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const isEmptySelection = state.selection.empty;
|
|
199
|
+
return (
|
|
200
|
+
(activeNode?.value.type.name === 'location' || isPlaatsbepaling) &&
|
|
201
|
+
isEmptySelection
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function getPlaceDescriptionActionGroups(
|
|
206
|
+
attrs: GetContextualActionsAttrs,
|
|
207
|
+
) {
|
|
208
|
+
return function (state: EditorState): ContextualActionGroup[] {
|
|
209
|
+
return contextualGroupIsVisible(state)
|
|
210
|
+
? [
|
|
211
|
+
{
|
|
212
|
+
id: plaatsbepalingGroupId,
|
|
213
|
+
label: getTranslationFunction(state)(
|
|
214
|
+
'variable.location.label',
|
|
215
|
+
'Plaatsbeschrijving',
|
|
216
|
+
),
|
|
217
|
+
getActions: getContextualActions(attrs),
|
|
218
|
+
},
|
|
219
|
+
]
|
|
220
|
+
: [];
|
|
221
|
+
};
|
|
222
|
+
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
// This file contains helpers for both the codelist and location variable types
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
EditorState,
|
|
5
|
+
PNode,
|
|
6
|
+
ProseParser,
|
|
7
|
+
SayController,
|
|
8
|
+
Transaction,
|
|
9
|
+
} from '@lblod/ember-rdfa-editor';
|
|
10
|
+
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
3
11
|
import { CodeListOption } from './fetch-data';
|
|
4
|
-
import { PNode, ProseParser, SayController } from '@lblod/ember-rdfa-editor';
|
|
5
12
|
import { createCodelistOptionNode } from '../actions/create-codelist-variable';
|
|
6
13
|
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
7
14
|
|
|
@@ -21,6 +28,40 @@ export function wrapVariableInHighlight(text: string) {
|
|
|
21
28
|
);
|
|
22
29
|
}
|
|
23
30
|
|
|
31
|
+
export function updateCodelistVariableCommand(
|
|
32
|
+
selectedCodelist: ResolvedPNode,
|
|
33
|
+
selectedOption: CodeListOption | CodeListOption[],
|
|
34
|
+
) {
|
|
35
|
+
return (state: EditorState, dispatch?: (tr: Transaction) => void) => {
|
|
36
|
+
const selectedOptions = Array.isArray(selectedOption)
|
|
37
|
+
? selectedOption
|
|
38
|
+
: [selectedOption];
|
|
39
|
+
const variableInstance = selectedCodelist.value.attrs[
|
|
40
|
+
'variableInstance'
|
|
41
|
+
] as string | undefined;
|
|
42
|
+
const pointerTarget = selectedCodelist.value.attrs['__rdfaId'] as
|
|
43
|
+
| string
|
|
44
|
+
| undefined;
|
|
45
|
+
const codelistOptionNodes = selectedOptions.map((option) =>
|
|
46
|
+
createCodelistOptionNode({
|
|
47
|
+
schema: state.schema,
|
|
48
|
+
text: option.label,
|
|
49
|
+
subject: option.uri,
|
|
50
|
+
variableInstance,
|
|
51
|
+
pointsToNode: pointerTarget,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
const range = {
|
|
55
|
+
from: selectedCodelist.pos + 1,
|
|
56
|
+
to: selectedCodelist.pos + selectedCodelist.value.nodeSize - 1,
|
|
57
|
+
};
|
|
58
|
+
if (dispatch) {
|
|
59
|
+
dispatch(state.tr.replaceWith(range.from, range.to, codelistOptionNodes));
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
24
65
|
export function updateCodelistVariable(
|
|
25
66
|
selectedCodelist: {
|
|
26
67
|
node: PNode;
|
|
@@ -29,31 +70,11 @@ export function updateCodelistVariable(
|
|
|
29
70
|
selectedOption: CodeListOption | CodeListOption[],
|
|
30
71
|
controller: SayController,
|
|
31
72
|
) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const variableInstance = selectedCodelist.node.attrs['variableInstance'] as
|
|
36
|
-
| string
|
|
37
|
-
| undefined;
|
|
38
|
-
const pointerTarget = selectedCodelist.node.attrs['__rdfaId'] as
|
|
39
|
-
| string
|
|
40
|
-
| undefined;
|
|
41
|
-
const codelistOptionNodes = selectedOptions.map((option) =>
|
|
42
|
-
createCodelistOptionNode({
|
|
43
|
-
schema: controller.schema,
|
|
44
|
-
text: option.label,
|
|
45
|
-
subject: option.uri,
|
|
46
|
-
variableInstance,
|
|
47
|
-
pointsToNode: pointerTarget,
|
|
48
|
-
}),
|
|
73
|
+
const command = updateCodelistVariableCommand(
|
|
74
|
+
{ value: selectedCodelist.node, pos: selectedCodelist.pos },
|
|
75
|
+
selectedOption,
|
|
49
76
|
);
|
|
50
|
-
|
|
51
|
-
from: selectedCodelist.pos + 1,
|
|
52
|
-
to: selectedCodelist.pos + selectedCodelist.node.nodeSize - 1,
|
|
53
|
-
};
|
|
54
|
-
controller.withTransaction((tr) => {
|
|
55
|
-
return tr.replaceWith(range.from, range.to, codelistOptionNodes);
|
|
56
|
-
});
|
|
77
|
+
controller.doCommand(command, { view: controller.mainEditorView });
|
|
57
78
|
}
|
|
58
79
|
|
|
59
80
|
/**
|
|
@@ -9,4 +9,4 @@ export interface LocationPluginConfig {
|
|
|
9
9
|
additionalRDFTypes?: NamedNode[];
|
|
10
10
|
}
|
|
11
11
|
export declare const osloLocation: (config: LocationPluginConfig) => import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
12
|
-
export declare const osloLocationView: (config: LocationPluginConfig) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
12
|
+
export declare const osloLocationView: (config: LocationPluginConfig) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
package/declarations/addon/plugins/locked-placeholder-plugin/nodes/block-locked-placeholder.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const blockLockedPlaceholder: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
2
|
-
export declare const blockLockedPlaceholderView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
2
|
+
export declare const blockLockedPlaceholderView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
package/declarations/addon/plugins/locked-placeholder-plugin/nodes/inline-locked-placeholder.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const inlineLockedPlaceholder: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
2
|
-
export declare const inlineLockedPlaceholderView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
2
|
+
export declare const inlineLockedPlaceholderView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { EmberNodeConfig } from '@lblod/ember-rdfa-editor/utils/ember-node';
|
|
2
2
|
export declare const emberNodeConfig: () => EmberNodeConfig;
|
|
3
3
|
export declare const mandatee_table: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
4
|
-
export declare const mandateeTableView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
4
|
+
export declare const mandateeTableView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -13,5 +13,5 @@ type CreateSnippetPlaceholderArgs = {
|
|
|
13
13
|
});
|
|
14
14
|
export declare function createSnippetPlaceholder({ schema, allowMultipleSnippets, ...args }: CreateSnippetPlaceholderArgs): import("prosemirror-model").Node;
|
|
15
15
|
export declare const snippetPlaceholder: (config: SnippetPluginConfig) => import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
16
|
-
export declare const snippetPlaceholderView: (config: SnippetPluginConfig) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
16
|
+
export declare const snippetPlaceholderView: (config: SnippetPluginConfig) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
17
17
|
export {};
|
|
@@ -16,5 +16,5 @@ interface CreateSnippetArgs {
|
|
|
16
16
|
**/
|
|
17
17
|
export declare function createSnippet({ schema, content, title, allowMultipleSnippets, listProperties: { listUris, names: snippetListNames, importedResources, placeholderId, }, }: CreateSnippetArgs): [PNode, Map<string, OutgoingTriple[]>];
|
|
18
18
|
export declare const snippet: (config: SnippetPluginConfig) => import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
19
|
-
export declare const snippetView: (config: SnippetPluginConfig) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
19
|
+
export declare const snippetView: (config: SnippetPluginConfig) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
20
20
|
export {};
|
|
@@ -4,6 +4,6 @@ import { StructurePluginOptions, StructureType } from './structure-types';
|
|
|
4
4
|
export declare function getNameForStructureType(structureType: StructureType, number: number, fullLengthArticles?: boolean, intl?: IntlService, locale?: string): string;
|
|
5
5
|
export declare const emberNodeConfig: (config?: StructurePluginOptions) => EmberNodeConfig;
|
|
6
6
|
export declare const structure: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
7
|
-
export declare const structureView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
7
|
+
export declare const structureView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
8
8
|
export declare const structureWithConfig: (config?: StructurePluginOptions) => import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
9
|
-
export declare const structureViewWithConfig: (config?: StructurePluginOptions) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
9
|
+
export declare const structureViewWithConfig: (config?: StructurePluginOptions) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -2,4 +2,4 @@ import { EmberNodeConfig } from '@lblod/ember-rdfa-editor/utils/ember-node';
|
|
|
2
2
|
import { TableOfContentsConfig } from '..';
|
|
3
3
|
export declare const emberNodeConfig: (config?: TableOfContentsConfig) => EmberNodeConfig;
|
|
4
4
|
export declare const table_of_contents: (config?: TableOfContentsConfig) => import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
5
|
-
export declare const tableOfContentsView: (config?: TableOfContentsConfig) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
5
|
+
export declare const tableOfContentsView: (config?: TableOfContentsConfig) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { EmberNodeConfig } from '@lblod/ember-rdfa-editor/utils/ember-node';
|
|
2
2
|
export declare const emberNodeConfig: () => EmberNodeConfig;
|
|
3
3
|
export declare const templateComment: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
4
|
-
export declare const templateCommentView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
4
|
+
export declare const templateCommentView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EditorState } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { ContextualActionGroup } from '@lblod/ember-rdfa-editor/plugins/contextual-actions';
|
|
3
|
+
type GetContextualActionsAttrs = {
|
|
4
|
+
endpoint?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function getContextualActions(attrs: GetContextualActionsAttrs): (state: EditorState, searchQuery?: string) => Promise<{
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
group: string;
|
|
10
|
+
command: (state: EditorState, dispatch?: (tr: import("@lblod/ember-rdfa-editor").Transaction) => void) => boolean;
|
|
11
|
+
selected: boolean;
|
|
12
|
+
}[]>;
|
|
13
|
+
export declare function getCodelistActionGroups(attrs: GetContextualActionsAttrs): (state: EditorState) => ContextualActionGroup[];
|
|
14
|
+
export {};
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
endpoint?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function getContextualActions(attrs: GetContextualActionsAttrs): (state: EditorState, searchQuery?: string) => Promise<{
|
|
9
|
-
id: string;
|
|
10
|
-
label: string;
|
|
11
|
-
group: string;
|
|
12
|
-
command: (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
13
|
-
}[]>;
|
|
14
|
-
export declare function getContextualActionGroups(attrs: GetContextualActionsAttrs): (state: EditorState) => ContextualActionGroup[];
|
|
15
|
-
export {};
|
|
1
|
+
export {
|
|
2
|
+
/** @deprecated these imports have been moved to contextual-actions/place-description.ts */
|
|
3
|
+
getContextualActions,
|
|
4
|
+
/** @deprecated these imports have been moved to contextual-actions/place-description.ts */
|
|
5
|
+
getPlaceDescriptionActionGroups as getContextualActionGroups, } from './place-description';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EditorState, Transaction } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { ContextualActionGroup } from '@lblod/ember-rdfa-editor/plugins/contextual-actions';
|
|
3
|
+
type GetContextualActionsAttrs = {
|
|
4
|
+
zonalLocationCodelistUri: string;
|
|
5
|
+
nonZonalLocationCodelistUri: string;
|
|
6
|
+
endpoint: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function getContextualActions(attrs: GetContextualActionsAttrs): (state: EditorState, searchQuery?: string) => Promise<{
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
group: string;
|
|
12
|
+
command: (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
13
|
+
}[]>;
|
|
14
|
+
export declare function getPlaceDescriptionActionGroups(attrs: GetContextualActionsAttrs): (state: EditorState) => ContextualActionGroup[];
|
|
15
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { EditorState, PNode, SayController, Transaction } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
1
3
|
import { CodeListOption } from './fetch-data';
|
|
2
|
-
import { PNode, SayController } from '@lblod/ember-rdfa-editor';
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
5
6
|
* @param text content of variable option which needs to be inserted
|
|
@@ -10,6 +11,7 @@ import { PNode, SayController } from '@lblod/ember-rdfa-editor';
|
|
|
10
11
|
* `This is a variable with <span class="mark-highlight-manual">${placeholder}</span>`
|
|
11
12
|
*/
|
|
12
13
|
export declare function wrapVariableInHighlight(text: string): string;
|
|
14
|
+
export declare function updateCodelistVariableCommand(selectedCodelist: ResolvedPNode, selectedOption: CodeListOption | CodeListOption[]): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
13
15
|
export declare function updateCodelistVariable(selectedCodelist: {
|
|
14
16
|
node: PNode;
|
|
15
17
|
pos: number;
|
|
@@ -7,4 +7,4 @@ export declare const address: import("@lblod/ember-rdfa-editor/core/say-node-spe
|
|
|
7
7
|
* @deprecated Use oslo_location node instead which inserts valid OSLO model RDFa and supports
|
|
8
8
|
* linking to the document it is in.
|
|
9
9
|
*/
|
|
10
|
-
export declare const addressView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
10
|
+
export declare const addressView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const autofilled_variable: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
2
|
-
export declare const autofilledVariableView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
2
|
+
export declare const autofilledVariableView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -11,5 +11,5 @@ export type CodelistAttrs = {
|
|
|
11
11
|
hardcodedOptionList: Option<CodeListOption[]>;
|
|
12
12
|
};
|
|
13
13
|
export declare const codelist: SayNodeSpec;
|
|
14
|
-
export declare const codelistView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
14
|
+
export declare const codelistView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
15
15
|
export declare const codelist_option: SayNodeSpec;
|
|
@@ -9,4 +9,4 @@ export type DateOptions = {
|
|
|
9
9
|
allowCustomFormat: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare const date: (options: DateOptions) => import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
12
|
-
export declare const dateView: (options: DateOptions) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
12
|
+
export declare const dateView: (options: DateOptions) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const legacy_codelist: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
2
|
-
export declare const legacyCodelistView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
2
|
+
export declare const legacyCodelistView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const location: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
2
|
-
export declare const locationView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
2
|
+
export declare const locationView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const number: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
2
|
-
export declare const numberView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
2
|
+
export declare const numberView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -4,4 +4,4 @@ export type Person = {
|
|
|
4
4
|
lastName: string;
|
|
5
5
|
};
|
|
6
6
|
export declare const person_variable: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
7
|
-
export declare const personVariableView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
7
|
+
export declare const personVariableView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const text_variable: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
|
|
2
|
-
export declare const textVariableView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor
|
|
2
|
+
export declare const textVariableView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor").NodeViewConstructor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lblod/ember-rdfa-editor-lblod-plugins",
|
|
3
|
-
"version": "38.0.
|
|
3
|
+
"version": "38.0.3-dev.8a844bd88a2bc1786034136bb02c3d7891ef57ac",
|
|
4
4
|
"description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/core": "^7.25.2",
|
|
56
56
|
"@codemirror/lang-html": "^6.4.9",
|
|
57
|
-
"@codemirror/state": "^6.
|
|
57
|
+
"@codemirror/state": "^6.7.0",
|
|
58
58
|
"@codemirror/view": "^6.28.3",
|
|
59
59
|
"@curvenote/prosemirror-utils": "^1.0.5",
|
|
60
60
|
"@embroider/macros": "^1.19.7",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"@glint/ember-tsc": "^1.5.0",
|
|
111
111
|
"@glint/environment-ember-loose": "^1.5.0",
|
|
112
112
|
"@glint/environment-ember-template-imports": "^1.5.0",
|
|
113
|
-
"@lblod/ember-rdfa-editor": "13.
|
|
113
|
+
"@lblod/ember-rdfa-editor": "13.15.1-dev.c5cefcf9a50117c08ff14a54a8b585d176b0654c",
|
|
114
114
|
"@glint/template": "^1.7.7",
|
|
115
115
|
"@rdfjs/to-ntriples": "^3.0.1",
|
|
116
116
|
"@rdfjs/types": "^2.0.1",
|
package/pnpm-workspace.yaml
CHANGED