@lblod/ember-rdfa-editor-lblod-plugins 35.2.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 CHANGED
@@ -1,5 +1,25 @@
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
+
13
+ ## 35.3.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#641](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/641) [`062b89a`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/062b89ad35edff9cb0963a17e606497697e7614a) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Add a way to set the required attribute of the label of the besluit type select
18
+
19
+ ### Patch Changes
20
+
21
+ - [#635](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/635) [`d2ac617`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/d2ac61769c71978bc9bc5e3ff10385057ae807bb) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Fix resetting the placeholder edit card
22
+
3
23
  ## 35.2.0
4
24
 
5
25
  ### Minor Changes
@@ -8,6 +8,7 @@ interface Sig {
8
8
  types: BesluitType[];
9
9
  selectedType?: BesluitTypeInstance;
10
10
  setType: (selected: BesluitTypeInstance) => void;
11
+ required?: boolean;
11
12
  };
12
13
  Element: HTMLDivElement;
13
14
  }
@@ -44,6 +45,7 @@ export default class BesluitTypePluginBesluitTypeSelectComponent extends Compone
44
45
  @onchange={{this.updateParentType}}
45
46
  @selected={{@selectedType.parent}}
46
47
  @showWarningWhenEmpty={{false}}
48
+ @required={{@required}}
47
49
  />
48
50
  {{#if @selectedType.parent.subTypes.length}}
49
51
  <BesluitTypeSelect
@@ -52,6 +54,7 @@ export default class BesluitTypePluginBesluitTypeSelectComponent extends Compone
52
54
  @onchange={{this.updateSubType}}
53
55
  @selected={{@selectedType.subType}}
54
56
  @showWarningWhenEmpty={{true}}
57
+ @required={{@required}}
55
58
  />
56
59
  {{/if}}
57
60
  {{#if @selectedType.subType.subTypes.length}}
@@ -61,6 +64,7 @@ export default class BesluitTypePluginBesluitTypeSelectComponent extends Compone
61
64
  @onchange={{this.updateSubSubType}}
62
65
  @selected={{@selectedType.subSubType}}
63
66
  @showWarningWhenEmpty={{true}}
67
+ @required={{@required}}
64
68
  />
65
69
  {{/if}}
66
70
  </div>
@@ -15,6 +15,7 @@ interface Sig {
15
15
  selected?: BesluitType;
16
16
  showWarningWhenEmpty: boolean;
17
17
  onchange: (selected: BesluitType) => void;
18
+ required?: boolean;
18
19
  };
19
20
  Element: HTMLDivElement;
20
21
  }
@@ -43,7 +44,7 @@ export default class BesluitTypePluginBesluitTypeSelectComponent extends Compone
43
44
  <template>
44
45
  <div ...attributes>
45
46
  {{#let (uuidv4) as |id|}}
46
- <AuLabel for={{id}}>
47
+ <AuLabel for={{id}} @required={{@required}}>
47
48
  {{t @fieldNameTranslation}}
48
49
  </AuLabel>
49
50
  <PowerSelect
@@ -1,7 +1,6 @@
1
1
  import Component from '@glimmer/component';
2
- import { tracked } from '@glimmer/tracking';
3
2
  import { type ComponentLike } from '@glint/template';
4
- import { NodeSelection, SayController } from '@lblod/ember-rdfa-editor';
3
+ import { NodeSelection, Node, SayController } from '@lblod/ember-rdfa-editor';
5
4
  import { service } from '@ember/service';
6
5
  import IntlService from 'ember-intl/services/intl';
7
6
  import AuCard from '@appuniversum/ember-appuniversum/components/au-card';
@@ -14,6 +13,8 @@ import AuNativeInput from '../au-native-input';
14
13
  import AuFormRow from '@appuniversum/ember-appuniversum/components/au-form-row';
15
14
  import checkEnterAndSubmit from '@lblod/ember-rdfa-editor-lblod-plugins/utils/check-enter-and-submit';
16
15
  import { fn } from '@ember/helper';
16
+ import { not } from 'ember-truth-helpers';
17
+ import { trackedReset } from 'tracked-toolbox';
17
18
 
18
19
  type VariableComponentArgs = {
19
20
  Args: {
@@ -34,7 +35,14 @@ type Args = {
34
35
  };
35
36
 
36
37
  export default class PlaceholderUtilsEditCardComponent extends Component<Args> {
37
- @tracked editedPlaceholderLabel?: string;
38
+ @trackedReset({
39
+ memo: 'selectedPlaceholderNode',
40
+ update(component: PlaceholderUtilsEditCardComponent) {
41
+ return component.selectedPlaceholderNode?.attrs.placeholderText;
42
+ },
43
+ })
44
+ placeholderLabel: string | null = null;
45
+ lastSelectedPlaceholder: Node | null = null;
38
46
 
39
47
  @service declare intl: IntlService;
40
48
 
@@ -50,20 +58,14 @@ export default class PlaceholderUtilsEditCardComponent extends Component<Args> {
50
58
  ) {
51
59
  return selection.node;
52
60
  } else {
53
- return;
61
+ return null;
54
62
  }
55
63
  }
56
64
  get showCard() {
57
65
  return !!this.selectedPlaceholderNode;
58
66
  }
59
- get placeholderLabel() {
60
- return (
61
- this.editedPlaceholderLabel ||
62
- this.selectedPlaceholderNode?.attrs.placeholderText
63
- );
64
- }
65
67
  updateLabelPlaceholder = (event: InputEvent) => {
66
- this.editedPlaceholderLabel = (event.target as HTMLInputElement).value;
68
+ this.placeholderLabel = (event.target as HTMLInputElement).value;
67
69
  };
68
70
  updatePlaceholder = () => {
69
71
  const { selection } = this.controller.activeEditorState;
@@ -71,7 +73,7 @@ export default class PlaceholderUtilsEditCardComponent extends Component<Args> {
71
73
  return tr.setNodeAttribute(
72
74
  selection.$from.pos,
73
75
  'placeholderText',
74
- this.editedPlaceholderLabel,
76
+ this.placeholderLabel,
75
77
  );
76
78
  });
77
79
  };
@@ -110,6 +112,7 @@ export default class PlaceholderUtilsEditCardComponent extends Component<Args> {
110
112
  <AuButton
111
113
  {{on 'click' this.updatePlaceholder}}
112
114
  class='au-u-margin-top'
115
+ @disabled={{not this.placeholderLabel}}
113
116
  >
114
117
  {{t 'editor-plugins.utils.insert'}}
115
118
  </AuButton>
@@ -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)(codelist_option_node),
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
- renderable: node,
130
- tag: 'span',
131
- attrs: {
132
- class: `${getClassnamesFromNode(node)}${className}`,
133
- 'data-say-variable': 'true',
134
- 'data-say-variable-type': 'codelist',
135
- 'data-say-node-version': '2',
136
- 'data-label': label as string | null,
137
- 'data-codelist': codelist as string,
138
- 'data-source': source as string,
139
- 'data-selection-style': selectionStyle as string,
140
- 'data-variable': variable as string,
141
- 'data-variable-instance': variableInstance as string,
142
- 'data-option-list': JSON.stringify(hardcodedOptionList),
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
- contentArray: contentArray.length ? contentArray : [label],
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
- renderable: node,
201
- attrs: {
202
- 'data-say-type': 'codelist_option',
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
- tag: 'span',
205
- content: node.textContent,
206
- });
215
+ state,
216
+ );
207
217
  },
208
218
  };
@@ -6,6 +6,7 @@ interface Sig {
6
6
  types: BesluitType[];
7
7
  selectedType?: BesluitTypeInstance;
8
8
  setType: (selected: BesluitTypeInstance) => void;
9
+ required?: boolean;
9
10
  };
10
11
  Element: HTMLDivElement;
11
12
  }
@@ -7,6 +7,7 @@ interface Sig {
7
7
  selected?: BesluitType;
8
8
  showWarningWhenEmpty: boolean;
9
9
  onchange: (selected: BesluitType) => void;
10
+ required?: boolean;
10
11
  };
11
12
  Element: HTMLDivElement;
12
13
  }
@@ -1,6 +1,6 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { type ComponentLike } from '@glint/template';
3
- import { SayController } from '@lblod/ember-rdfa-editor';
3
+ import { Node, SayController } from '@lblod/ember-rdfa-editor';
4
4
  import IntlService from 'ember-intl/services/intl';
5
5
  type VariableComponentArgs = {
6
6
  Args: {
@@ -19,12 +19,12 @@ type Args = {
19
19
  variableTypes: VariableConfig[];
20
20
  };
21
21
  export default class PlaceholderUtilsEditCardComponent extends Component<Args> {
22
- editedPlaceholderLabel?: string;
22
+ placeholderLabel: string | null;
23
+ lastSelectedPlaceholder: Node | null;
23
24
  intl: IntlService;
24
25
  get controller(): SayController;
25
- get selectedPlaceholderNode(): import("prosemirror-model").Node | undefined;
26
+ get selectedPlaceholderNode(): Node | null;
26
27
  get showCard(): boolean;
27
- get placeholderLabel(): any;
28
28
  updateLabelPlaceholder: (event: InputEvent) => void;
29
29
  updatePlaceholder: () => void;
30
30
  }
@@ -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.2.0",
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": "prettier --write .",
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
- "@graphy/content.ttl.write": "^4.3.7",
114
- "@graphy/memory.dataset.fast": "4.3.3",
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
  },