@lblod/ember-rdfa-editor-lblod-plugins 27.0.2 → 27.0.3

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,16 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 27.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#545](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/545) [`49f902f`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/49f902f2b5c89d7799ecd4f0b6732f2e412ee2f5) Thanks [@elpoelma](https://github.com/elpoelma)! - Remove number node when backspacing/deleting inside empty input field
8
+
9
+ - [#544](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/544) [`4e5edc3`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/4e5edc35b206847be16b4417d26bac95c6ea7750) Thanks [@elpoelma](https://github.com/elpoelma)! - IRGN plugin: use `xsd:boolean` type instead of custom `mu` boolean type in SPARQL queries.
10
+ This fixes the functionality of the mobility measure code dropdown.
11
+
12
+ - [#541](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/541) [`4b7daf7`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/4b7daf7e212a2f1aea9765908ef5897f49cc9c93) Thanks [@elpoelma](https://github.com/elpoelma)! - Implement quick successive structure title changes using transaction composition
13
+
3
14
  ## 27.0.2
4
15
 
5
16
  ### Patch Changes
@@ -27,6 +27,9 @@ import { getNameForStructureType } from '@lblod/ember-rdfa-editor-lblod-plugins/
27
27
  import { StructureType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/structure-plugin/structure-types';
28
28
  import { romanize } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/structure-plugin/utils/romanize';
29
29
  import { Transaction } from '@lblod/ember-rdfa-editor';
30
+ import { v4 as uuid } from 'uuid';
31
+ import { setCompositionID } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/_private/transaction-utils';
32
+ import { isNone } from '@lblod/ember-rdfa-editor/utils/_private/option';
30
33
 
31
34
  interface Sig {
32
35
  Args: EmberNodeArgs;
@@ -64,7 +67,9 @@ export default class Structure extends Component<Sig> {
64
67
  * A time counter to store the last time an update to the title was added to
65
68
  * the history
66
69
  * */
67
- @tracked historyTimeStamp: number = 0;
70
+ historyTimeStamp: number = 0;
71
+ currentCompositionID?: string;
72
+
68
73
  innerEditor: NestedProsemirror | null = null;
69
74
 
70
75
  get showPlaceholder() {
@@ -154,7 +159,10 @@ export default class Structure extends Component<Sig> {
154
159
  }
155
160
 
156
161
  onTitleUpdate = (content: string, tr: Transaction) => {
157
- let addToHistory = false;
162
+ const pos = this.args.getPos();
163
+ if (isNone(pos)) {
164
+ return;
165
+ }
158
166
  // every character typed would normally trigger a history event
159
167
  // in normal editor operation, this is ok, as the history plugin is smart
160
168
  // enough to group adjacent edits made in a short timespan (default 500ms)
@@ -162,12 +170,19 @@ export default class Structure extends Component<Sig> {
162
170
  // but since we trigger an attribute update, the history plugin can no
163
171
  // longer recognize these edits as adjacent, so each character triggers
164
172
  // a history event. This makes undoing title edits tedious, so we mimic the
165
- // grouping here using the transaction timestamp
166
- if (tr.time - this.historyTimeStamp > 500) {
167
- addToHistory = true;
173
+ // grouping here using the transaction timestamp and compositionID
174
+ if (tr.time - this.historyTimeStamp > 500 || !this.currentCompositionID) {
168
175
  this.historyTimeStamp = tr.time;
176
+ this.currentCompositionID = uuid();
169
177
  }
170
- this.args.updateAttribute('title', content, !addToHistory);
178
+
179
+ this.controller.withTransaction(
180
+ (tr) => {
181
+ setCompositionID(tr, this.currentCompositionID);
182
+ return tr.setNodeAttribute(pos, 'title', content);
183
+ },
184
+ { view: this.args.view },
185
+ );
171
186
  };
172
187
  onInnerEditorFocus = (view: SayView) => {
173
188
  this.controller.setActiveView(view);
@@ -25,6 +25,7 @@
25
25
  placeholder={{t 'variable.number.type-number'}}
26
26
  {{did-insert this.focus}}
27
27
  {{on 'input' this.onInputNumberChange}}
28
+ {{on 'keydown' this.onInputKeydown}}
28
29
  {{leave-with-arrow-keys @controller @getPos}}
29
30
  {{leave-on-enter-key @controller @getPos}}
30
31
  />
@@ -107,6 +107,29 @@ export default class NumberNodeviewComponent extends Component<Args> {
107
107
  this.validateAndSave();
108
108
  }
109
109
 
110
+ @action
111
+ onInputKeydown(event: KeyboardEvent) {
112
+ if (
113
+ (event.key === 'Backspace' || event.key === 'Delete') &&
114
+ !this.inputNumber
115
+ ) {
116
+ event.preventDefault();
117
+ this.remove();
118
+ }
119
+ }
120
+
121
+ @action
122
+ remove() {
123
+ const pos = this.args.getPos();
124
+ if (pos !== undefined) {
125
+ this.controller.withTransaction((tr) => {
126
+ tr.deleteRange(pos, pos + this.node.nodeSize);
127
+ return tr;
128
+ });
129
+ this.controller.focus();
130
+ }
131
+ }
132
+
110
133
  @action
111
134
  changeWrittenNumber() {
112
135
  this.args.updateAttribute('writtenNumber', !this.writtenNumber);
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  executeQuery,
3
3
  objectify,
4
+ sparqlEscapeBool,
4
5
  sparqlEscapeString,
5
6
  sparqlEscapeUri,
6
7
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/sparql-helpers';
@@ -89,7 +90,7 @@ export default async function querySignCodes(
89
90
  ?uri mobiliteit:heeftMaatregelconcept ?measure.
90
91
  ?uri a ?signType;
91
92
  skos:prefLabel ?label;
92
- ext:valid "true"^^<http://mu.semte.ch/vocabularies/typed-literals/boolean>.
93
+ ext:valid ${sparqlEscapeBool(true)}.
93
94
  ${filterStatement}
94
95
  }
95
96
  ORDER BY ASC(?label)
@@ -0,0 +1,11 @@
1
+ // TODO: move these utility functions to the `@lblod/ember-rdfa-editor` package
2
+
3
+ import { Transaction } from '@lblod/ember-rdfa-editor';
4
+
5
+ export function setCompositionID(tr: Transaction, compositionID: unknown) {
6
+ return tr.setMeta('composition', compositionID);
7
+ }
8
+
9
+ export function getCompositionID(tr: Transaction): unknown {
10
+ return tr.getMeta('composition');
11
+ }
@@ -20,6 +20,10 @@ interface QueryConfig {
20
20
  export const sparqlEscapeString = (value: string) =>
21
21
  '"""' + value.replace(/[\\"]/g, (match) => '\\' + match) + '"""';
22
22
 
23
+ export const sparqlEscapeBool = (value: boolean) => {
24
+ return value ? '"true"^^xsd:boolean' : '"false"^^xsd:boolean';
25
+ };
26
+
23
27
  export const sparqlEscapeUri = (value: string) => {
24
28
  return (
25
29
  '<' +
@@ -20,6 +20,7 @@ export default class Structure extends Component<Sig> {
20
20
  * the history
21
21
  * */
22
22
  historyTimeStamp: number;
23
+ currentCompositionID?: string;
23
24
  innerEditor: NestedProsemirror | null;
24
25
  get showPlaceholder(): boolean;
25
26
  get controller(): import("@lblod/ember-rdfa-editor").SayController;
@@ -31,6 +31,8 @@ export default class NumberNodeviewComponent extends Component<Args> {
31
31
  get maxValue(): number;
32
32
  get label(): string | undefined;
33
33
  onInputNumberChange(event: InputEvent): void;
34
+ onInputKeydown(event: KeyboardEvent): void;
35
+ remove(): void;
34
36
  changeWrittenNumber(): void;
35
37
  get errorMessage(): string;
36
38
  validateAndSave(): void;
@@ -0,0 +1,3 @@
1
+ import { Transaction } from '@lblod/ember-rdfa-editor';
2
+ export declare function setCompositionID(tr: Transaction, compositionID: unknown): Transaction;
3
+ export declare function getCompositionID(tr: Transaction): unknown;
@@ -15,6 +15,7 @@ interface QueryConfig {
15
15
  abortSignal?: AbortSignal;
16
16
  }
17
17
  export declare const sparqlEscapeString: (value: string) => string;
18
+ export declare const sparqlEscapeBool: (value: boolean) => "\"true\"^^xsd:boolean" | "\"false\"^^xsd:boolean";
18
19
  export declare const sparqlEscapeUri: (value: string) => string;
19
20
  export declare function executeQuery<Binding = Record<string, RDF.Term>>({ query, endpoint, abortSignal, }: QueryConfig): Promise<QueryResult<Binding>>;
20
21
  export declare function executeCountQuery(queryConfig: QueryConfig): Promise<number>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "27.0.2",
3
+ "version": "27.0.3",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",