@lblod/ember-rdfa-editor-lblod-plugins 35.3.0 → 35.4.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 +10 -0
- package/addon/components/variable-plugin/marcode/insert.gts +1 -0
- package/addon/plugins/variable-plugin/actions/create-codelist-variable.ts +7 -0
- package/addon/plugins/variable-plugin/utils/codelist-utils.ts +4 -0
- package/addon/plugins/variable-plugin/variables/codelist.ts +37 -27
- package/declarations/addon/plugins/variable-plugin/actions/create-codelist-variable.d.ts +3 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 35.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#636](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/636) [`867383d`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/867383d8ee85dcf30ad7338cd80dc2c0802326c7) Thanks [@piemonkey](https://github.com/piemonkey)! - Use pointer functionality to link to make linking to codelist URIs possible
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#636](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/636) [`aeb74b2`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/aeb74b22f159f0297749e430093d90a54f5f34f6) Thanks [@piemonkey](https://github.com/piemonkey)! - Update to [v13.6.0](https://github.com/lblod/ember-rdfa-editor/releases/tag/%40lblod%2Fember-rdfa-editor%4013.6.0) of the editor
|
|
12
|
+
|
|
3
13
|
## 35.3.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -50,6 +50,7 @@ export default class MarcodeInsertComponent extends Component<Sig> {
|
|
|
50
50
|
// list in code instead of in the doc?
|
|
51
51
|
hardcodedOptionList: hardcodedMarcodeList,
|
|
52
52
|
label,
|
|
53
|
+
hasNonLiteralContents: true,
|
|
53
54
|
});
|
|
54
55
|
this.controller.doCommand(replaceSelectionWithAndSelectNode(node), {
|
|
55
56
|
view: this.controller.mainEditorView,
|
|
@@ -30,6 +30,7 @@ export function createCodelistVariable(args: CreateCodelistVariableArgs) {
|
|
|
30
30
|
subject: args.value,
|
|
31
31
|
variableInstance: args.variableInstance,
|
|
32
32
|
text: args.valueLabel,
|
|
33
|
+
pointsToNode: args.__rdfaId,
|
|
33
34
|
});
|
|
34
35
|
return schema.nodes.codelist.create(attrs, [codelistOption]);
|
|
35
36
|
}
|
|
@@ -42,6 +43,7 @@ type CreateCodelistVariableAttrsArgs = {
|
|
|
42
43
|
source: string;
|
|
43
44
|
codelist: string;
|
|
44
45
|
hardcodedOptionList?: CodeListOption[];
|
|
46
|
+
hasNonLiteralContents?: boolean;
|
|
45
47
|
} & AllOrNone<{
|
|
46
48
|
variable: string;
|
|
47
49
|
variableInstance: string;
|
|
@@ -57,6 +59,7 @@ export function createCodelistVariableAttrs({
|
|
|
57
59
|
variable,
|
|
58
60
|
variableInstance,
|
|
59
61
|
hardcodedOptionList,
|
|
62
|
+
hasNonLiteralContents,
|
|
60
63
|
}: CreateCodelistVariableAttrsArgs) {
|
|
61
64
|
const externalTriples: FullTriple[] = [];
|
|
62
65
|
if (variable) {
|
|
@@ -90,6 +93,7 @@ export function createCodelistVariableAttrs({
|
|
|
90
93
|
variable,
|
|
91
94
|
variableInstance,
|
|
92
95
|
hardcodedOptionList,
|
|
96
|
+
hasNonLiteralContents: !!hasNonLiteralContents,
|
|
93
97
|
} as CodelistAttrs;
|
|
94
98
|
}
|
|
95
99
|
|
|
@@ -109,12 +113,14 @@ type CreateCodelistOptionNodeAttrsArgs = {
|
|
|
109
113
|
text: string;
|
|
110
114
|
value?: string;
|
|
111
115
|
variableInstance?: string;
|
|
116
|
+
pointsToNode?: string;
|
|
112
117
|
};
|
|
113
118
|
|
|
114
119
|
function createCodelistOptionNodeAttrs({
|
|
115
120
|
subject,
|
|
116
121
|
text,
|
|
117
122
|
variableInstance,
|
|
123
|
+
pointsToNode,
|
|
118
124
|
}: CreateCodelistOptionNodeAttrsArgs) {
|
|
119
125
|
const backlinks: IncomingTriple[] = [];
|
|
120
126
|
if (variableInstance) {
|
|
@@ -135,5 +141,6 @@ function createCodelistOptionNodeAttrs({
|
|
|
135
141
|
subject,
|
|
136
142
|
properties,
|
|
137
143
|
backlinks,
|
|
144
|
+
pointsToNode,
|
|
138
145
|
};
|
|
139
146
|
}
|
|
@@ -35,12 +35,16 @@ export function updateCodelistVariable(
|
|
|
35
35
|
const variableInstance = selectedCodelist.node.attrs['variableInstance'] as
|
|
36
36
|
| string
|
|
37
37
|
| undefined;
|
|
38
|
+
const pointerTarget = selectedCodelist.node.attrs['__rdfaId'] as
|
|
39
|
+
| string
|
|
40
|
+
| undefined;
|
|
38
41
|
const codelistOptionNodes = selectedOptions.map((option) =>
|
|
39
42
|
createCodelistOptionNode({
|
|
40
43
|
schema: controller.schema,
|
|
41
44
|
text: option.label,
|
|
42
45
|
subject: option.uri,
|
|
43
46
|
variableInstance,
|
|
47
|
+
pointsToNode: pointerTarget,
|
|
44
48
|
}),
|
|
45
49
|
);
|
|
46
50
|
const range = {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from '@lblod/ember-rdfa-editor/utils/ember-node';
|
|
6
6
|
import {
|
|
7
7
|
DOMOutputSpec,
|
|
8
|
+
EditorState,
|
|
8
9
|
Fragment,
|
|
9
10
|
PNode,
|
|
10
11
|
Schema,
|
|
@@ -102,7 +103,7 @@ const parseDOM: TagParseRule[] = [
|
|
|
102
103
|
},
|
|
103
104
|
];
|
|
104
105
|
|
|
105
|
-
const toDOM = (node: PNode): DOMOutputSpec => {
|
|
106
|
+
const toDOM = (node: PNode, state?: EditorState): DOMOutputSpec => {
|
|
106
107
|
const {
|
|
107
108
|
label = 'codelist',
|
|
108
109
|
codelist,
|
|
@@ -119,30 +120,36 @@ const toDOM = (node: PNode): DOMOutputSpec => {
|
|
|
119
120
|
for (let i = 0; i < codelist_option_nodes.length; i++) {
|
|
120
121
|
const codelist_option_node = codelist_option_nodes[i];
|
|
121
122
|
contentArray.push(
|
|
122
|
-
unwrap(codelist_option_node.type.spec.toDOM)(
|
|
123
|
+
unwrap((codelist_option_node.type.spec as SayNodeSpec).toDOM)(
|
|
124
|
+
codelist_option_node,
|
|
125
|
+
state,
|
|
126
|
+
),
|
|
123
127
|
);
|
|
124
128
|
if (i !== codelist_option_nodes.length - 1) {
|
|
125
129
|
contentArray.push(', ');
|
|
126
130
|
}
|
|
127
131
|
}
|
|
128
|
-
return renderRdfaAware(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
return renderRdfaAware(
|
|
133
|
+
{
|
|
134
|
+
renderable: node,
|
|
135
|
+
tag: 'span',
|
|
136
|
+
attrs: {
|
|
137
|
+
class: `${getClassnamesFromNode(node)}${className}`,
|
|
138
|
+
'data-say-variable': 'true',
|
|
139
|
+
'data-say-variable-type': 'codelist',
|
|
140
|
+
'data-say-node-version': '2',
|
|
141
|
+
'data-label': label as string | null,
|
|
142
|
+
'data-codelist': codelist as string,
|
|
143
|
+
'data-source': source as string,
|
|
144
|
+
'data-selection-style': selectionStyle as string,
|
|
145
|
+
'data-variable': variable as string,
|
|
146
|
+
'data-variable-instance': variableInstance as string,
|
|
147
|
+
'data-option-list': JSON.stringify(hardcodedOptionList),
|
|
148
|
+
},
|
|
149
|
+
contentArray: contentArray.length ? contentArray : [label],
|
|
143
150
|
},
|
|
144
|
-
|
|
145
|
-
|
|
151
|
+
state,
|
|
152
|
+
);
|
|
146
153
|
};
|
|
147
154
|
|
|
148
155
|
const emberNodeConfig: EmberNodeConfig = {
|
|
@@ -195,14 +202,17 @@ export const codelist_option: SayNodeSpec = {
|
|
|
195
202
|
attrs: {
|
|
196
203
|
...rdfaAttrSpec({ rdfaAware }),
|
|
197
204
|
},
|
|
198
|
-
toDOM: (node) => {
|
|
199
|
-
return renderRdfaAware(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
205
|
+
toDOM: (node, state) => {
|
|
206
|
+
return renderRdfaAware(
|
|
207
|
+
{
|
|
208
|
+
renderable: node,
|
|
209
|
+
attrs: {
|
|
210
|
+
'data-say-type': 'codelist_option',
|
|
211
|
+
},
|
|
212
|
+
tag: 'span',
|
|
213
|
+
content: node.textContent,
|
|
203
214
|
},
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
});
|
|
215
|
+
state,
|
|
216
|
+
);
|
|
207
217
|
},
|
|
208
218
|
};
|
|
@@ -14,12 +14,13 @@ type CreateCodelistVariableAttrsArgs = {
|
|
|
14
14
|
source: string;
|
|
15
15
|
codelist: string;
|
|
16
16
|
hardcodedOptionList?: CodeListOption[];
|
|
17
|
+
hasNonLiteralContents?: boolean;
|
|
17
18
|
} & AllOrNone<{
|
|
18
19
|
variable: string;
|
|
19
20
|
variableInstance: string;
|
|
20
21
|
__rdfaId?: string;
|
|
21
22
|
}>;
|
|
22
|
-
export declare function createCodelistVariableAttrs({ selectionStyle, label, source, codelist, __rdfaId, variable, variableInstance, hardcodedOptionList, }: CreateCodelistVariableAttrsArgs): CodelistAttrs;
|
|
23
|
+
export declare function createCodelistVariableAttrs({ selectionStyle, label, source, codelist, __rdfaId, variable, variableInstance, hardcodedOptionList, hasNonLiteralContents, }: CreateCodelistVariableAttrsArgs): CodelistAttrs;
|
|
23
24
|
type CreateCodelistOptionNodeArgs = {
|
|
24
25
|
schema: Schema;
|
|
25
26
|
text: string;
|
|
@@ -30,5 +31,6 @@ type CreateCodelistOptionNodeAttrsArgs = {
|
|
|
30
31
|
text: string;
|
|
31
32
|
value?: string;
|
|
32
33
|
variableInstance?: string;
|
|
34
|
+
pointsToNode?: string;
|
|
33
35
|
};
|
|
34
36
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lblod/ember-rdfa-editor-lblod-plugins",
|
|
3
|
-
"version": "35.
|
|
3
|
+
"version": "35.4.0",
|
|
4
4
|
"description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -38,8 +38,9 @@
|
|
|
38
38
|
"lint:js": "eslint . --cache",
|
|
39
39
|
"lint:js:fix": "eslint . --fix",
|
|
40
40
|
"lint:prettier": "prettier --check .",
|
|
41
|
-
"lint:prettier:fix": "
|
|
41
|
+
"lint:prettier:fix": "pnpm format",
|
|
42
42
|
"lint:types": "glint",
|
|
43
|
+
"format": "prettier --write .",
|
|
43
44
|
"start": "concurrently -c \"auto\" -P \"pnpm:serve {@}\" \"pnpm:typecheck\" --",
|
|
44
45
|
"typecheck": "glint --watch --preserveWatchOutput",
|
|
45
46
|
"serve": "ember serve",
|
|
@@ -110,9 +111,8 @@
|
|
|
110
111
|
"@glint/environment-ember-loose": "^1.5.0",
|
|
111
112
|
"@glint/environment-ember-template-imports": "^1.5.0",
|
|
112
113
|
"@glint/template": "^1.5.0",
|
|
113
|
-
"@
|
|
114
|
-
"@
|
|
115
|
-
"@lblod/ember-rdfa-editor": "13.1.1",
|
|
114
|
+
"@lblod/ember-rdfa-editor": "13.6.0",
|
|
115
|
+
"@rdfjs/to-ntriples": "^3.0.1",
|
|
116
116
|
"@rdfjs/types": "^1.1.0",
|
|
117
117
|
"@release-it/keep-a-changelog": "^4.0.0",
|
|
118
118
|
"@tsconfig/ember": "^3.0.8",
|
|
@@ -207,6 +207,7 @@
|
|
|
207
207
|
"pnpm": {
|
|
208
208
|
"overrides": {
|
|
209
209
|
"babel-plugin-ember-template-compilation": "^2.2.5",
|
|
210
|
+
"@codemirror/state": "6.5.2",
|
|
210
211
|
"prosemirror-view": "^1.41.5"
|
|
211
212
|
}
|
|
212
213
|
},
|