@lblod/ember-rdfa-editor-lblod-plugins 6.1.0 → 7.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.
Files changed (27) hide show
  1. package/.woodpecker/.release.yml +8 -1
  2. package/CHANGELOG.md +13 -1
  3. package/Dockerfile +10 -0
  4. package/README.md +18 -0
  5. package/addon/components/article-structure-plugin/structure-card.hbs +1 -1
  6. package/addon/components/citation-plugin/citation-card.hbs +1 -0
  7. package/addon/components/citation-plugin/citation-card.ts +14 -6
  8. package/addon/components/citation-plugin/citation-insert.hbs +1 -0
  9. package/addon/components/citation-plugin/citation-insert.ts +2 -2
  10. package/addon/components/citation-plugin/citations/decision-detail.ts +8 -6
  11. package/addon/components/citation-plugin/citations/search-modal.hbs +1 -0
  12. package/addon/components/citation-plugin/citations/search-modal.ts +12 -6
  13. package/addon/components/rdfa-date-plugin/date-time-picker.ts +5 -5
  14. package/addon/components/rdfa-date-plugin/insert.ts +1 -0
  15. package/addon/plugins/citation-plugin/index.ts +4 -0
  16. package/addon/plugins/citation-plugin/utils/vlaamse-codex.ts +93 -59
  17. package/addon/plugins/rdfa-date-plugin/nodes/date.ts +8 -9
  18. package/addon/plugins/variable-plugin/nodes.ts +1 -0
  19. package/app/styles/variable-plugin.scss +5 -1
  20. package/components/citation-plugin/citation-card.d.ts +6 -0
  21. package/components/citation-plugin/citation-insert.d.ts +3 -3
  22. package/components/citation-plugin/citations/decision-detail.d.ts +3 -0
  23. package/components/citation-plugin/citations/search-modal.d.ts +6 -0
  24. package/components/rdfa-date-plugin/date-time-picker.d.ts +5 -5
  25. package/package.json +3 -3
  26. package/plugins/citation-plugin/index.d.ts +3 -0
  27. package/plugins/citation-plugin/utils/vlaamse-codex.d.ts +18 -2
@@ -8,8 +8,15 @@ pipeline:
8
8
  settings:
9
9
  token:
10
10
  from_secret: npm_access_token
11
+ push-tagged-build:
12
+ image: plugins/docker
13
+ settings:
14
+ repo: lblod/ember-rdfa-editor-lblod-plugins
15
+ tags: "${CI_COMMIT_TAG##v}"
16
+ purge: true
17
+ secrets: [ docker_username, docker_password ]
11
18
  # Pipeline level conditions aren't supported yet:
12
19
  # https://github.com/woodpecker-ci/woodpecker/issues/283
13
20
  when:
14
21
  event: tag
15
- tag: v*
22
+ tag: v*
package/CHANGELOG.md CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [7.0.0] - 2023-05-17
11
+ ### Added
12
+ - add docker build for easy demo environments
13
+ ### Change
14
+ - BREAKING: Endpoint config for `CitationPlugin`
15
+ ### Fixed
16
+ - Remove structure doesn't always work - disable the "Remove <structure>" button correctly
17
+
18
+ ### Fixed
19
+ - Fix initialization of default date properties
10
20
  ## [6.1.0] - 2023-05-11
11
21
 
12
22
  ### Added
@@ -18,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
28
 
19
29
  ### Added
20
30
  - validation plugin
31
+ - Enable Firefox cursor fix for variables
21
32
 
22
33
  ### Deprecated
23
34
  - the decision-plugin card component is now deprecated in favor of the host app's choice of insert button
@@ -427,7 +438,8 @@ add onclick handler to pencil icon in variable plugin
427
438
 
428
439
  # Changelog
429
440
 
430
- [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v6.1.0...HEAD
441
+ [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.0.0...HEAD
442
+ [7.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v6.1.0...v7.0.0
431
443
  [6.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v6.0.0...v6.1.0
432
444
  [6.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v5.0.1...v6.0.0
433
445
  [5.0.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v5.0.0...v5.0.1
package/Dockerfile ADDED
@@ -0,0 +1,10 @@
1
+ FROM madnificent/ember:4.9.2 as builder
2
+
3
+ LABEL maintainer="info@redpencil.io"
4
+
5
+ WORKDIR /app
6
+ COPY package.json package-lock.json ./
7
+ RUN npm ci
8
+ COPY . .
9
+ EXPOSE 80
10
+ CMD ["ember", "s", "--port", "80"]
package/README.md CHANGED
@@ -85,8 +85,26 @@ This plugin provides a card that needs to be added to the sidebar of the editor
85
85
  <CitationPlugin::CitationCard
86
86
  @controller={{this.controller}}
87
87
  @plugin={{this.citationPlugin}}
88
+ @config={{this.config.citation}}
88
89
  />
89
90
  ```
91
+
92
+ You need to specify the endpoint for the plugin in the config object
93
+ ```js
94
+ {
95
+ endpoint: 'https://codex.opendata.api.vlaanderen.be:8888/sparql'
96
+ }
97
+ ```
98
+
99
+ Same goes for the `CitationInsert` component
100
+ ```hbs
101
+ <CitationPlugin::CitationInsert
102
+ @controller={{this.controller}}
103
+ @config={{this.config.citation}}
104
+ />
105
+ ```
106
+
107
+
90
108
  Being this.citationPlugin a tracked reference to the plugin created with the function exported from the package and the wished configuration
91
109
  ```js
92
110
  import { citationPlugin } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
@@ -34,7 +34,7 @@
34
34
  @iconAlignment="left"
35
35
  @skin="link"
36
36
  @alert={{true}}
37
- @disabled={{this.currentStructureType.noUnwrap}}
37
+ @disabled={{not this.canRemoveStructure}}
38
38
  aria-describedby="remove-tooltip"
39
39
  {{hover.velcroHook}}
40
40
  {{hover.handleHover}}
@@ -119,4 +119,5 @@
119
119
  @legislationTypeUri={{this.selectedLegislationTypeUri}}
120
120
  @selectLegislationType={{this.selectLegislationType}}
121
121
  @text={{this.searchText}}
122
+ @config={{this.config}}
122
123
  />
@@ -29,6 +29,9 @@ import {
29
29
  interface Args {
30
30
  controller: SayController;
31
31
  plugin: CitationPlugin;
32
+ config: {
33
+ endpoint: string;
34
+ };
32
35
  }
33
36
 
34
37
  export default class CitationCardComponent extends Component<Args> {
@@ -70,6 +73,10 @@ export default class CitationCardComponent extends Component<Args> {
70
73
  return this.args.plugin;
71
74
  }
72
75
 
76
+ get config() {
77
+ return this.args.config;
78
+ }
79
+
73
80
  get decorations() {
74
81
  return this.plugin.getState(this.controller.mainEditorState)?.highlights;
75
82
  }
@@ -121,12 +128,13 @@ export default class CitationCardComponent extends Component<Args> {
121
128
  const filter = {
122
129
  type: unwrapOr('', this.selectedLegislationTypeUri),
123
130
  };
124
- const results = await fetchDecisions(
125
- words,
126
- filter,
127
- this.pageNumber,
128
- this.pageSize
129
- );
131
+ const results = await fetchDecisions({
132
+ words: words,
133
+ filter: filter,
134
+ pageNumber: this.pageNumber,
135
+ pageSize: this.pageSize,
136
+ config: this.args.config,
137
+ });
130
138
  this.totalCount = results.totalCount;
131
139
  return results.decisions;
132
140
  } catch (e) {
@@ -19,4 +19,5 @@
19
19
 
20
20
  @selectLegislationType={{this.selectLegislationType}}
21
21
  @text={{this.text}}
22
+ @config={{this.config}}
22
23
  />
@@ -12,7 +12,7 @@ import {
12
12
  Decision,
13
13
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/vlaamse-codex';
14
14
  import { citedText } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/cited-text';
15
- import { CitationPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
15
+ import { CitationPluginEmberComponentConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
16
16
  import {
17
17
  LEGISLATION_TYPE_CONCEPTS,
18
18
  LEGISLATION_TYPES,
@@ -22,7 +22,7 @@ import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
22
22
 
23
23
  interface Args {
24
24
  controller: SayController;
25
- config: CitationPluginConfig;
25
+ config: CitationPluginEmberComponentConfig;
26
26
  }
27
27
 
28
28
  export default class EditorPluginsCitationInsertComponent extends Component<Args> {
@@ -11,6 +11,7 @@ import { task as trackedTask } from 'ember-resources/util/ember-concurrency';
11
11
  interface Args {
12
12
  decision: Decision;
13
13
  close: () => void;
14
+ config: { endpoint: string };
14
15
  }
15
16
 
16
17
  export default class EditorPluginsCitationsDecisionDetailComponent extends Component<Args> {
@@ -32,12 +33,13 @@ export default class EditorPluginsCitationsDecisionDetailComponent extends Compo
32
33
  this.error = null;
33
34
  const abortController = new AbortController();
34
35
  try {
35
- const results = await fetchArticles(
36
- this.args.decision.uri,
37
- this.pageNumber,
38
- this.pageSize,
39
- this.articleFilterAfterTimeout
40
- );
36
+ const results = await fetchArticles({
37
+ legalExpression: this.args.decision.uri,
38
+ pageNumber: this.pageNumber,
39
+ pageSize: this.pageSize,
40
+ articleFilter: this.articleFilterAfterTimeout,
41
+ config: this.args.config,
42
+ });
41
43
  this.totalCount = results.totalCount;
42
44
  return results.articles;
43
45
  } catch (e) {
@@ -13,6 +13,7 @@
13
13
  @insertArticleCitation={{this.insertArticleCitation}}
14
14
  @close={{this.closeDecisionDetail}}
15
15
  @decision={{this.selectedDecision}}
16
+ @config={{this.config}}
16
17
  />
17
18
  </modal.Body>
18
19
  {{else}}
@@ -40,6 +40,7 @@ interface Args {
40
40
  insertDecisionCitation: (decision: Decision) => void;
41
41
  insertArticleCitation: (decision: Decision, article: Article) => void;
42
42
  closeModal: (legislationTypeUri?: string, text?: string) => void;
43
+ config: { endpoint: string };
43
44
  }
44
45
 
45
46
  export default class EditorPluginsCitationsSearchModalComponent extends Component<Args> {
@@ -99,6 +100,10 @@ export default class EditorPluginsCitationsSearchModalComponent extends Componen
99
100
  return this.args.text;
100
101
  }
101
102
 
103
+ get config() {
104
+ return this.args.config;
105
+ }
106
+
102
107
  get searchText() {
103
108
  return this.inputSearchText ?? this.text;
104
109
  }
@@ -135,12 +140,13 @@ export default class EditorPluginsCitationsSearchModalComponent extends Componen
135
140
  publicationDateFrom: getISODate(this.publicationDateFrom),
136
141
  publicationDateTo: getISODate(this.publicationDateTo),
137
142
  };
138
- const results = await fetchDecisions(
139
- words,
140
- filter,
141
- this.pageNumber,
142
- this.pageSize
143
- );
143
+ const results = await fetchDecisions({
144
+ words: words,
145
+ filter: filter,
146
+ pageNumber: this.pageNumber,
147
+ pageSize: this.pageSize,
148
+ config: this.args.config,
149
+ });
144
150
  this.totalCount = results.totalCount;
145
151
  return results.decisions;
146
152
  } catch (e) {
@@ -7,25 +7,25 @@ import { localCopy } from 'tracked-toolbox';
7
7
  import Intl from 'ember-intl/services/intl';
8
8
 
9
9
  type Args = {
10
- value: Date;
10
+ value?: Date;
11
11
  onChange: (date: Date) => void;
12
12
  };
13
13
 
14
14
  export default class RdfaDatePluginDateTimePicker extends Component<Args> {
15
15
  @service declare intl: Intl;
16
16
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
17
- @localCopy('args.value') declare date: Date;
17
+ @localCopy('args.value') declare date?: Date;
18
18
 
19
19
  get hours() {
20
- return this.date.getHours();
20
+ return this.date?.getHours();
21
21
  }
22
22
 
23
23
  get minutes() {
24
- return this.date.getMinutes();
24
+ return this.date?.getMinutes();
25
25
  }
26
26
 
27
27
  get seconds() {
28
- return this.date.getSeconds();
28
+ return this.date?.getSeconds();
29
29
  }
30
30
 
31
31
  get datePickerLocalization() {
@@ -37,6 +37,7 @@ export default class RdfaDatePluginInsertComponent extends Component<Args> {
37
37
  this.schema.node('date', {
38
38
  onlyDate: true,
39
39
  format: this.defaultDateFormat,
40
+ value: new Date().toISOString(),
40
41
  })
41
42
  );
42
43
  if (tr.selection.$anchor.nodeBefore) {
@@ -132,6 +132,10 @@ export type CitationPluginConfig =
132
132
  | CitationPluginNodeConfig
133
133
  | CitationPluginRangeConfig;
134
134
 
135
+ export type CitationPluginEmberComponentConfig = CitationPluginConfig & {
136
+ endpoint: string;
137
+ };
138
+
135
139
  export function citationPlugin(config: CitationPluginConfig): CitationPlugin {
136
140
  const citation: CitationPlugin = new ProsePlugin({
137
141
  state: {
@@ -8,10 +8,6 @@ import {
8
8
  import Ember from 'ember';
9
9
  import SafeString = Ember.Handlebars.SafeString;
10
10
 
11
- const SPARQL_ENDPOINT = '/codex/sparql/';
12
-
13
- //const SPARQL_ENDPOINT = 'https://codex.opendata.api.vlaanderen.be:8888/sparql';
14
-
15
11
  interface DecisionArgs {
16
12
  uri: string;
17
13
  legislationTypeUri: Option<string>;
@@ -106,13 +102,20 @@ export interface QueryFilter {
106
102
  publicationDateTo?: Option<string>;
107
103
  }
108
104
 
109
- async function fetchDecisions(
110
- words: string[],
111
- filter: QueryFilter,
105
+ async function fetchDecisions({
106
+ words,
107
+ filter,
112
108
  pageNumber = 0,
113
- pageSize = 5
109
+ pageSize = 5,
110
+ config,
111
+ }: {
112
+ words: string[];
113
+ filter: QueryFilter;
114
+ pageNumber: number;
115
+ pageSize: number;
116
+ config: CodexQueryConfig;
117
+ }) {
114
118
  /*abortSignal*/
115
- ) {
116
119
  //This is silly, but null != undefined, so we have to be careful and include the correct value here
117
120
  //Also, reconstruct the whole filter object to always have the same ordering, hopefully.
118
121
  filter = {
@@ -132,12 +135,13 @@ async function fetchDecisions(
132
135
  if (results) {
133
136
  return results;
134
137
  } else {
135
- const newResults = await fetchDecisionsMemo(
138
+ const newResults = await fetchDecisionsMemo({
136
139
  words,
137
140
  filter,
138
141
  pageNumber,
139
- pageSize
140
- );
142
+ pageSize,
143
+ config,
144
+ });
141
145
  fetchDecisionsMemory.set(stringArguments, newResults);
142
146
  return newResults;
143
147
  }
@@ -148,13 +152,19 @@ interface DecisionCollection {
148
152
  decisions: Decision[];
149
153
  }
150
154
 
151
- async function fetchDecisionsMemo(
152
- words: string[],
153
- filter: QueryFilter,
155
+ async function fetchDecisionsMemo({
156
+ words,
157
+ filter,
154
158
  pageNumber = 0,
155
159
  pageSize = 5,
156
- abortSignal?: AbortSignal
157
- ): Promise<DecisionCollection> {
160
+ config,
161
+ }: {
162
+ words: string[];
163
+ filter: QueryFilter;
164
+ config: CodexQueryConfig;
165
+ pageNumber?: number;
166
+ pageSize?: number;
167
+ }): Promise<DecisionCollection> {
158
168
  // TBD/NOTE: in the context of a <http://data.europa.eu/eli/ontology#LegalResource>
159
169
  // the eli:cites can have either a <http://xmlns.com/foaf/0.1/Document> or <http://data.europa.eu/eli/ontology#LegalResource>
160
170
  // as range (see AP https://data.vlaanderen.be/doc/applicatieprofiel/besluit-publicatie/#Rechtsgrond),
@@ -199,8 +209,8 @@ async function fetchDecisionsMemo(
199
209
  'FILTER(! STRSTARTS(LCASE(?title),"tot wijziging"))'
200
210
  );
201
211
  }
202
- const totalCount = await executeCountQuery(
203
- `PREFIX eli: <http://data.europa.eu/eli/ontology#>
212
+ const totalCount = await executeCountQuery({
213
+ query: `PREFIX eli: <http://data.europa.eu/eli/ontology#>
204
214
 
205
215
  SELECT COUNT(DISTINCT(?expressionUri)) as ?count
206
216
  WHERE {
@@ -220,12 +230,12 @@ async function fetchDecisionsMemo(
220
230
  ${documentDateFilter}
221
231
  ${publicationDateFilter}
222
232
  }`,
223
- abortSignal
224
- );
233
+ config,
234
+ });
225
235
 
226
236
  if (totalCount > 0) {
227
- const response = await executeQuery<DecisionBinding>(
228
- `PREFIX eli: <http://data.europa.eu/eli/ontology#>
237
+ const response = await executeQuery<DecisionBinding>({
238
+ query: `PREFIX eli: <http://data.europa.eu/eli/ontology#>
229
239
 
230
240
  SELECT DISTINCT ?expressionUri as ?uri ?title ?publicationDate ?documentDate
231
241
  WHERE {
@@ -246,8 +256,8 @@ async function fetchDecisionsMemo(
246
256
  ${documentDateFilter}
247
257
  ${publicationDateFilter}
248
258
  } ORDER BY ?title LIMIT ${pageSize} OFFSET ${pageNumber * pageSize}`,
249
- abortSignal
250
- );
259
+ config,
260
+ });
251
261
 
252
262
  const decisions = response.results.bindings.map((binding) => {
253
263
  const escapedTitle = escapeValue(binding.title.value);
@@ -291,13 +301,19 @@ interface DecisionBinding {
291
301
 
292
302
  const fetchArticlesMemory = new Map<string, ArticleCollection>();
293
303
 
294
- async function fetchArticles(
295
- legalExpression: string,
296
- pageNumber: number,
297
- pageSize: number,
298
- articleFilter: string
299
- /*abortSignal*/
300
- ): Promise<ArticleCollection> {
304
+ async function fetchArticles({
305
+ legalExpression,
306
+ pageNumber,
307
+ pageSize,
308
+ articleFilter,
309
+ config,
310
+ }: {
311
+ legalExpression: string;
312
+ pageNumber: number;
313
+ pageSize: number;
314
+ articleFilter: string;
315
+ config: CodexQueryConfig;
316
+ }): Promise<ArticleCollection> {
301
317
  //Simpler here, only one way arguments are set up
302
318
  const stringArguments = JSON.stringify({
303
319
  legalExpression,
@@ -309,12 +325,13 @@ async function fetchArticles(
309
325
  if (results) {
310
326
  return results;
311
327
  } else {
312
- const newResults = await fetchArticlesMemo(
328
+ const newResults = await fetchArticlesMemo({
313
329
  legalExpression,
314
330
  pageNumber,
315
331
  pageSize,
316
- articleFilter
317
- );
332
+ articleFilter,
333
+ config,
334
+ });
318
335
  fetchArticlesMemory.set(stringArguments, newResults);
319
336
  return newResults;
320
337
  }
@@ -352,18 +369,24 @@ interface ArticleCollection {
352
369
  articles: Article[];
353
370
  }
354
371
 
355
- async function fetchArticlesMemo(
356
- legalExpression: string,
372
+ async function fetchArticlesMemo({
373
+ legalExpression,
357
374
  pageNumber = 0,
358
375
  pageSize = 10,
359
- articleFilter: string,
360
- abortSignal?: AbortSignal
361
- ): Promise<ArticleCollection> {
376
+ articleFilter,
377
+ config,
378
+ }: {
379
+ legalExpression: string;
380
+ pageNumber: number;
381
+ pageSize: number;
382
+ articleFilter: string;
383
+ config: CodexQueryConfig;
384
+ }): Promise<ArticleCollection> {
362
385
  const numberFilter = articleFilter
363
386
  ? `FILTER( !BOUND(?number) || CONTAINS(?number, "${articleFilter}"))`
364
387
  : '';
365
- const totalCount = await executeCountQuery(
366
- `PREFIX eli: <http://data.europa.eu/eli/ontology#>
388
+ const totalCount = await executeCountQuery({
389
+ query: `PREFIX eli: <http://data.europa.eu/eli/ontology#>
367
390
  PREFIX dct: <http://purl.org/dc/terms/>
368
391
 
369
392
  SELECT COUNT(DISTINCT(?article)) as ?count
@@ -381,14 +404,14 @@ async function fetchArticlesMemo(
381
404
  OPTIONAL { ?article eli:number ?number . }
382
405
  ${numberFilter}
383
406
  }`,
384
- abortSignal
385
- );
407
+ config,
408
+ });
386
409
 
387
410
  if (totalCount > 0) {
388
411
  // ?number has format like "Artikel 12." We parse the number from the string for ordering
389
412
  // Second degree ordering on ?numberStr to make sure "Artikel 3/1." comes after "Artikel 3."
390
- const response = await executeQuery<ArticleBinding>(
391
- `PREFIX eli: <http://data.europa.eu/eli/ontology#>
413
+ const response = await executeQuery<ArticleBinding>({
414
+ query: `PREFIX eli: <http://data.europa.eu/eli/ontology#>
392
415
  PREFIX prov: <http://www.w3.org/ns/prov#>
393
416
  PREFIX dct: <http://purl.org/dc/terms/>
394
417
 
@@ -411,8 +434,8 @@ async function fetchArticlesMemo(
411
434
  } ORDER BY ?numberInt ?numberStr LIMIT ${pageSize} OFFSET ${
412
435
  pageNumber * pageSize
413
436
  }`,
414
- abortSignal
415
- );
437
+ config,
438
+ });
416
439
 
417
440
  const articles = response.results.bindings.map((binding) => {
418
441
  const escapedContent = escapeValue(
@@ -483,28 +506,39 @@ function dateValue(value?: string): string | null {
483
506
  }
484
507
  }
485
508
 
486
- async function executeCountQuery(query: string, abortSignal?: AbortSignal) {
487
- const response = await executeQuery<{ count: { value: string } }>(
509
+ async function executeCountQuery({
510
+ query,
511
+ config,
512
+ }: {
513
+ query: string;
514
+ config: CodexQueryConfig;
515
+ }) {
516
+ const response = await executeQuery<{ count: { value: string } }>({
488
517
  query,
489
- abortSignal
490
- );
518
+ config,
519
+ });
491
520
  return optionMapOr(0, parseInt, response.results.bindings[0]?.count.value);
492
521
  }
493
522
 
494
- async function executeQuery<A>(
495
- query: string,
496
- abortSignal?: AbortSignal
497
- ): Promise<QueryResponse<A>> {
523
+ type CodexQueryConfig = { endpoint: string; abortSignal?: AbortSignal };
524
+
525
+ async function executeQuery<A>({
526
+ query,
527
+ config,
528
+ }: {
529
+ query: string;
530
+ config: CodexQueryConfig;
531
+ }): Promise<QueryResponse<A>> {
498
532
  const encodedQuery = encodeURIComponent(query.trim());
499
- const endpoint = `${SPARQL_ENDPOINT}`;
500
- const response = await fetch(endpoint, {
533
+
534
+ const response = await fetch(config.endpoint, {
501
535
  method: 'POST',
502
536
  headers: {
503
537
  Accept: 'application/sparql-results+json',
504
538
  'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
505
539
  },
506
540
  body: `query=${encodedQuery}`,
507
- signal: abortSignal,
541
+ signal: config.abortSignal,
508
542
  });
509
543
 
510
544
  if (response.ok) {
@@ -16,11 +16,9 @@ const date: (options: DateOptions) => NodeSpec = (options) => {
16
16
  mappingResource: {
17
17
  default: null,
18
18
  },
19
- value: {
20
- default: new Date().toISOString(),
21
- },
19
+ value: {},
22
20
  format: {
23
- default: 'dd/MM/yyyy',
21
+ default: options.formats[0].dateFormat,
24
22
  },
25
23
  onlyDate: {
26
24
  default: true,
@@ -86,7 +84,7 @@ const date: (options: DateOptions) => NodeSpec = (options) => {
86
84
  ) {
87
85
  const onlyDate = hasRDFaAttribute(node, 'datatype', XSD('date'));
88
86
  return {
89
- value: node.getAttribute('content'),
87
+ value: node.getAttribute('content') ?? new Date().toISOString(),
90
88
  onlyDate,
91
89
  format: node.dataset.format,
92
90
  custom: node.dataset.custom === 'true',
@@ -115,13 +113,14 @@ const date: (options: DateOptions) => NodeSpec = (options) => {
115
113
  );
116
114
  const dateNode = [...node.children].find((el) =>
117
115
  hasRDFaAttribute(el, 'property', EXT('content'))
118
- );
116
+ ) as HTMLElement | undefined;
119
117
  return {
120
118
  mappingResource,
121
119
  onlyDate,
122
- value: dateNode?.getAttribute('content'),
123
- format: dateNode?.getAttribute('data-format'),
124
- custom: dateNode?.getAttribute('data-custom') === 'true',
120
+ value:
121
+ dateNode?.getAttribute('content') ?? new Date().toISOString(),
122
+ format: dateNode?.dataset.format,
123
+ custom: dateNode?.dataset.custom === 'true',
125
124
  };
126
125
  }
127
126
  }
@@ -23,6 +23,7 @@ const emberNodeConfig: EmberNodeConfig = {
23
23
  recreateUri: true,
24
24
  uriAttributes: ['variableInstance'],
25
25
  draggable: false,
26
+ needsFFKludge: true,
26
27
  attrs: {
27
28
  mappingResource: {},
28
29
  codelistResource: {
@@ -2,6 +2,10 @@
2
2
  margin-left: 0.3rem;
3
3
  }
4
4
 
5
+ .mark-highlight-manual + .ProseMirror-firefox-fake-cursor {
6
+ margin-left: -0.5rem;
7
+ }
8
+
5
9
  [typeof='ext:Mapping'] {
6
10
  border-bottom: 0 !important;
7
11
 
@@ -63,4 +67,4 @@
63
67
  background-color: var(--au-blue-300);
64
68
  }
65
69
  }
66
- }
70
+ }
@@ -6,6 +6,9 @@ import { SayController } from '@lblod/ember-rdfa-editor';
6
6
  interface Args {
7
7
  controller: SayController;
8
8
  plugin: CitationPlugin;
9
+ config: {
10
+ endpoint: string;
11
+ };
9
12
  }
10
13
  export default class CitationCardComponent extends Component<Args> {
11
14
  pageNumber: number;
@@ -24,6 +27,9 @@ export default class CitationCardComponent extends Component<Args> {
24
27
  get controller(): SayController;
25
28
  get showCard(): false | Option<CitationDecoration>;
26
29
  get plugin(): CitationPlugin;
30
+ get config(): {
31
+ endpoint: string;
32
+ };
27
33
  get decorations(): import("prosemirror-view").DecorationSet | undefined;
28
34
  get activeDecoration(): Option<CitationDecoration>;
29
35
  get searchText(): string;
@@ -1,17 +1,17 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { SayController } from '@lblod/ember-rdfa-editor';
3
3
  import { Article, Decision } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/vlaamse-codex';
4
- import { CitationPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
4
+ import { CitationPluginEmberComponentConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
5
5
  interface Args {
6
6
  controller: SayController;
7
- config: CitationPluginConfig;
7
+ config: CitationPluginEmberComponentConfig;
8
8
  }
9
9
  export default class EditorPluginsCitationInsertComponent extends Component<Args> {
10
10
  showModal: boolean;
11
11
  legislationTypeUri: string;
12
12
  text: string;
13
13
  legislationType: string | null;
14
- get config(): CitationPluginConfig;
14
+ get config(): CitationPluginEmberComponentConfig;
15
15
  get selectedLegislationTypeUri(): string;
16
16
  get selectedLegislationType(): {
17
17
  label: string;
@@ -3,6 +3,9 @@ import { Decision } from '../../../plugins/citation-plugin/utils/vlaamse-codex';
3
3
  interface Args {
4
4
  decision: Decision;
5
5
  close: () => void;
6
+ config: {
7
+ endpoint: string;
8
+ };
6
9
  }
7
10
  export default class EditorPluginsCitationsDecisionDetailComponent extends Component<Args> {
8
11
  error: unknown;
@@ -8,6 +8,9 @@ interface Args {
8
8
  insertDecisionCitation: (decision: Decision) => void;
9
9
  insertArticleCitation: (decision: Decision, article: Article) => void;
10
10
  closeModal: (legislationTypeUri?: string, text?: string) => void;
11
+ config: {
12
+ endpoint: string;
13
+ };
11
14
  }
12
15
  export default class EditorPluginsCitationsSearchModalComponent extends Component<Args> {
13
16
  intl: IntlService;
@@ -42,6 +45,9 @@ export default class EditorPluginsCitationsSearchModalComponent extends Componen
42
45
  get legislationTypes(): string[];
43
46
  get legislationSelected(): string;
44
47
  get text(): string;
48
+ get config(): {
49
+ endpoint: string;
50
+ };
45
51
  get searchText(): string;
46
52
  get rangeStart(): number;
47
53
  get rangeEnd(): number;
@@ -1,15 +1,15 @@
1
1
  import Component from '@glimmer/component';
2
2
  import Intl from 'ember-intl/services/intl';
3
3
  type Args = {
4
- value: Date;
4
+ value?: Date;
5
5
  onChange: (date: Date) => void;
6
6
  };
7
7
  export default class RdfaDatePluginDateTimePicker extends Component<Args> {
8
8
  intl: Intl;
9
- date: Date;
10
- get hours(): number;
11
- get minutes(): number;
12
- get seconds(): number;
9
+ date?: Date;
10
+ get hours(): number | undefined;
11
+ get minutes(): number | undefined;
12
+ get seconds(): number | undefined;
13
13
  get datePickerLocalization(): {
14
14
  buttonLabel: string;
15
15
  selectedDateMessage: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "6.1.0",
3
+ "version": "7.0.0",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -63,7 +63,7 @@
63
63
  "@embroider/test-setup": "^1.8.3",
64
64
  "@glimmer/component": "^1.1.2",
65
65
  "@glimmer/tracking": "^1.1.2",
66
- "@lblod/ember-rdfa-editor": "^3.4.1",
66
+ "@lblod/ember-rdfa-editor": "^3.7.0",
67
67
  "@rdfjs/types": "^1.1.0",
68
68
  "@release-it/keep-a-changelog": "^3.1.0",
69
69
  "@tsconfig/ember": "^1.0.1",
@@ -143,7 +143,7 @@
143
143
  },
144
144
  "peerDependencies": {
145
145
  "@appuniversum/ember-appuniversum": "^2.4.2",
146
- "@lblod/ember-rdfa-editor": "^3.4.1",
146
+ "@lblod/ember-rdfa-editor": "^3.7.0",
147
147
  "ember-concurrency": "^2.3.7"
148
148
  },
149
149
  "engines": {
@@ -31,5 +31,8 @@ export interface CitationPluginRangeConfig {
31
31
  activeInRanges(state: EditorState): [number, number][];
32
32
  }
33
33
  export type CitationPluginConfig = CitationPluginNodeConfig | CitationPluginRangeConfig;
34
+ export type CitationPluginEmberComponentConfig = CitationPluginConfig & {
35
+ endpoint: string;
36
+ };
34
37
  export declare function citationPlugin(config: CitationPluginConfig): CitationPlugin;
35
38
  export {};
@@ -42,15 +42,31 @@ export interface QueryFilter {
42
42
  publicationDateFrom?: Option<string>;
43
43
  publicationDateTo?: Option<string>;
44
44
  }
45
- declare function fetchDecisions(words: string[], filter: QueryFilter, pageNumber?: number, pageSize?: number): Promise<DecisionCollection>;
45
+ declare function fetchDecisions({ words, filter, pageNumber, pageSize, config, }: {
46
+ words: string[];
47
+ filter: QueryFilter;
48
+ pageNumber: number;
49
+ pageSize: number;
50
+ config: CodexQueryConfig;
51
+ }): Promise<DecisionCollection>;
46
52
  interface DecisionCollection {
47
53
  totalCount: number;
48
54
  decisions: Decision[];
49
55
  }
50
- declare function fetchArticles(legalExpression: string, pageNumber: number, pageSize: number, articleFilter: string): Promise<ArticleCollection>;
56
+ declare function fetchArticles({ legalExpression, pageNumber, pageSize, articleFilter, config, }: {
57
+ legalExpression: string;
58
+ pageNumber: number;
59
+ pageSize: number;
60
+ articleFilter: string;
61
+ config: CodexQueryConfig;
62
+ }): Promise<ArticleCollection>;
51
63
  interface ArticleCollection {
52
64
  totalCount: number;
53
65
  articles: Article[];
54
66
  }
55
67
  declare function cleanCaches(): void;
68
+ type CodexQueryConfig = {
69
+ endpoint: string;
70
+ abortSignal?: AbortSignal;
71
+ };
56
72
  export { fetchDecisions, fetchArticles, cleanCaches };