@lblod/ember-rdfa-editor-lblod-plugins 25.1.0 → 25.2.0-dev.e4ae2274de089de459ac3b495a3e5b00b7cb4279

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 (59) hide show
  1. package/.changeset/afraid-pianos-visit.md +5 -0
  2. package/.changeset/olive-parrots-crash.md +5 -0
  3. package/CHANGELOG.md +23 -0
  4. package/README.md +7 -6
  5. package/addon/components/citation-plugin/citation-insert.ts +23 -14
  6. package/addon/components/location-plugin/nodeview.gts +16 -28
  7. package/addon/components/snippet-plugin/nodes/placeholder.gts +41 -22
  8. package/addon/components/snippet-plugin/nodes/snippet.gts +52 -31
  9. package/addon/components/snippet-plugin/search-modal.hbs +4 -1
  10. package/addon/components/snippet-plugin/search-modal.ts +5 -0
  11. package/addon/components/snippet-plugin/snippet-insert-rdfa.gts +7 -12
  12. package/addon/components/snippet-plugin/snippet-insert.gts +1 -0
  13. package/addon/components/variable-plugin/address/nodeview.hbs +4 -18
  14. package/addon/components/variable-plugin/address/nodeview.ts +12 -23
  15. package/addon/components/variable-plugin/autofilled/insert.gts +3 -2
  16. package/addon/components/variable-plugin/codelist/insert.ts +1 -1
  17. package/addon/components/variable-plugin/date/nodeview.hbs +4 -12
  18. package/addon/components/variable-plugin/date/nodeview.ts +5 -23
  19. package/addon/components/variable-plugin/location/insert.ts +4 -2
  20. package/addon/components/variable-plugin/number/nodeview.hbs +4 -19
  21. package/addon/components/variable-plugin/number/nodeview.ts +12 -10
  22. package/addon/components/variable-plugin/person/nodeview.hbs +4 -18
  23. package/addon/components/variable-plugin/person/nodeview.ts +12 -19
  24. package/addon/components/variable-plugin/text/insert.ts +1 -1
  25. package/addon/components/variable-plugin/variable/nodeview.hbs +2 -8
  26. package/addon/components/variable-plugin/variable/nodeview.ts +16 -7
  27. package/addon/plugins/citation-plugin/index.ts +57 -24
  28. package/addon/plugins/snippet-plugin/index.ts +1 -0
  29. package/addon/plugins/snippet-plugin/nodes/snippet-placeholder.ts +12 -7
  30. package/addon/plugins/snippet-plugin/nodes/snippet.ts +27 -15
  31. package/addon/plugins/snippet-plugin/utils/rdfa-predicate.ts +3 -0
  32. package/addon/plugins/variable-plugin/variables/autofilled.ts +2 -2
  33. package/addon/plugins/variable-plugin/variables/location.ts +2 -3
  34. package/addon/utils/namespace.ts +4 -1
  35. package/app/styles/snippet-plugin.scss +59 -23
  36. package/app/styles/variable-plugin.scss +21 -26
  37. package/declarations/addon/components/location-plugin/nodeview.d.ts +2 -3
  38. package/declarations/addon/components/snippet-plugin/nodes/placeholder.d.ts +7 -2
  39. package/declarations/addon/components/snippet-plugin/nodes/snippet.d.ts +2 -1
  40. package/declarations/addon/components/snippet-plugin/search-modal.d.ts +2 -0
  41. package/declarations/addon/components/variable-plugin/address/nodeview.d.ts +2 -8
  42. package/declarations/addon/components/variable-plugin/date/nodeview.d.ts +2 -6
  43. package/declarations/addon/components/variable-plugin/number/nodeview.d.ts +2 -4
  44. package/declarations/addon/components/variable-plugin/person/nodeview.d.ts +2 -7
  45. package/declarations/addon/components/variable-plugin/variable/nodeview.d.ts +2 -2
  46. package/declarations/addon/plugins/citation-plugin/index.d.ts +15 -8
  47. package/declarations/addon/plugins/snippet-plugin/index.d.ts +1 -0
  48. package/declarations/addon/plugins/snippet-plugin/nodes/snippet-placeholder.d.ts +3 -3
  49. package/declarations/addon/plugins/snippet-plugin/nodes/snippet.d.ts +1 -1
  50. package/declarations/addon/plugins/snippet-plugin/utils/rdfa-predicate.d.ts +1 -0
  51. package/package.json +3 -3
  52. package/pnpm-lock.yaml +24 -17
  53. package/translations/en-US.yaml +7 -7
  54. package/translations/nl-BE.yaml +7 -7
  55. package/addon/components/variable-plugin/autofilled/nodeview.gts +0 -100
  56. package/addon/components/variable-plugin/location/nodeview.hbs +0 -24
  57. package/addon/components/variable-plugin/location/nodeview.ts +0 -46
  58. package/declarations/addon/components/variable-plugin/autofilled/nodeview.d.ts +0 -22
  59. package/declarations/addon/components/variable-plugin/location/nodeview.d.ts +0 -11
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ Redesign variable pills
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ Bump ember-rdfa-editor to 10.7.3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 25.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#496](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/496) [`2e3c09f`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/2e3c09f95db40967caaceaa791e7eefd6187c5e4) Thanks [@piemonkey](https://github.com/piemonkey)! - Redesign snippet placeholder to have more intuitive UX
8
+
9
+ - [#503](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/503) [`37ba9c3`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/37ba9c3ecd2c0452fb49ea1d0bb2704e6e716d05) Thanks [@elpoelma](https://github.com/elpoelma)! - Extension of configuration options of `citation-plugin`.
10
+ The `CitationPluginNodeConfig` is extended to allow for a `activeInNode` condition.
11
+ This allows you to specify a condition which an active/context node needs to satisfy.
12
+
13
+ ```ts
14
+ interface CitationPluginNodeConditionConfig {
15
+ type: 'nodes';
16
+ regex?: RegExp;
17
+
18
+ activeInNode(node: PNode, state?: EditorState): boolean;
19
+ }
20
+ ```
21
+
22
+ The previously expected `activeInNodeTypes` option is marked as deprecated and will be removed in a future release.
23
+
24
+ - [#501](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/501) [`997fa98`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/997fa986a7094349ad368d291cb8364e5c50a140) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Add snippet list names to the modal title
25
+
3
26
  ## 25.1.0
4
27
 
5
28
  ### Minor Changes
package/README.md CHANGED
@@ -335,9 +335,11 @@ Make `this.citationPlugin` a tracked reference to the plugin created with the fu
335
335
 
336
336
  Configuration:
337
337
 
338
- - type: it can be 'nodes' or 'ranges' if nodes is selected you are expected to pass the `activeInNodeTypes` function, otherwise you should pass the `activeInRanges` function
339
- - activeInNodeTypes: it's a function that gets the prosemirror schema and the state of the actual instance of the editor and returns a `Set` of nodetypes where the plugin should be active
340
- - activeInRanges: it's a function that gets the state of the actual instance of the editor and returns an array of ranges for the plugin to be active in, for example `[[0,50], [70,100]]`
338
+ - type (optional): it can either be 'nodes', or 'ranges'
339
+ * if 'nodes' is selected, you are expected to pass the `activeInNode` function. It's a function which expects an instance of a prosemirror node and returns whether it should be active in that node. The previously expected `activeInNodeTypes` is marked as deprecated and will be removed in a future release.
340
+ * if 'ranges' is selected, you are expected to pass the `activeInRanges` function. It's a function that gets the state of the actual instance of the editor and returns an array of ranges for the plugin to be active in, for example `[[0,50], [70,100]]`
341
+ * if no type is provided, the citation plugin will be activated document-wide
342
+
341
343
  - regex: you can provide your custom regex to detect citations, if not the default one will be used
342
344
 
343
345
  A common usecase is to have the plugin active in the entire document. Here's how to do that using each configuration type:
@@ -347,9 +349,8 @@ import { citationPlugin } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/c
347
349
 
348
350
  const configA = {
349
351
  type: 'nodes',
350
- activeInNodeTypes(schema) {
351
- // the root node of the document should always have the doc type
352
- return new Set([schema.nodes.doc]);
352
+ activeInNode(node, state) {
353
+ return node.type === state.schema.nodes.doc;
353
354
  },
354
355
  };
355
356
 
@@ -3,6 +3,7 @@ import { action } from '@ember/object';
3
3
  import { tracked } from '@glimmer/tracking';
4
4
  import {
5
5
  Fragment,
6
+ PNode,
6
7
  SayController,
7
8
  Slice,
8
9
  Transaction,
@@ -14,7 +15,7 @@ import {
14
15
  LEGISLATION_TYPES,
15
16
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/types';
16
17
  import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
17
- import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
18
+ import { findParentNode } from '@curvenote/prosemirror-utils';
18
19
  import { Article } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/article';
19
20
  import { LegalDocument } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/legal-documents';
20
21
  import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
@@ -62,10 +63,13 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
62
63
  return true;
63
64
  }
64
65
  const { selection } = this.controller.mainEditorState;
65
- if (this.config.type === 'ranges') {
66
- const ranges = this.config.activeInRanges(
67
- this.controller.mainEditorState,
68
- );
66
+ const config = this.config;
67
+ if (!('type' in config)) {
68
+ // Enable plugin document wide
69
+ return false;
70
+ }
71
+ if (config.type === 'ranges') {
72
+ const ranges = config.activeInRanges(this.controller.mainEditorState);
69
73
  for (const range of ranges) {
70
74
  if (selection.from > range[0] && selection.from < range[1]) {
71
75
  return false;
@@ -73,17 +77,22 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
73
77
  }
74
78
  return true;
75
79
  } else {
76
- const nodeTypes = this.config.activeInNodeTypes(
77
- this.controller.schema,
78
- this.controller.mainEditorState,
79
- );
80
- // if the doc node is included, the button should always be active
81
- // the findParentNodeOfType util we import does NOT consider the doc node
82
- // in its search.
83
- if (nodeTypes.has(this.controller.schema.nodes.doc)) {
80
+ let condition: (node: PNode) => boolean;
81
+ if ('activeInNodeTypes' in config) {
82
+ const nodeTypes = config.activeInNodeTypes(
83
+ this.controller.schema,
84
+ this.controller.mainEditorState,
85
+ );
86
+ condition = (node) => nodeTypes.has(node.type);
87
+ } else {
88
+ condition = (node) =>
89
+ config.activeInNode(node, this.controller.mainEditorState);
90
+ }
91
+
92
+ if (condition(this.controller.mainEditorState.doc)) {
84
93
  return false;
85
94
  }
86
- return !findParentNodeOfType([...nodeTypes])(selection);
95
+ return !findParentNode(condition)(selection);
87
96
  }
88
97
  }
89
98
 
@@ -2,7 +2,6 @@ import Component from '@glimmer/component';
2
2
  import { service } from '@ember/service';
3
3
  import { on } from '@ember/modifier';
4
4
  import IntlService from 'ember-intl/services/intl';
5
- import { PencilIcon } from '@appuniversum/ember-appuniversum/components/icons/pencil';
6
5
  import AuPill, {
7
6
  type AuPillSignature,
8
7
  } from '@appuniversum/ember-appuniversum/components/au-pill';
@@ -25,14 +24,6 @@ type Signature = {
25
24
  export default class AddressNodeviewComponent extends Component<Signature> {
26
25
  @service declare intl: IntlService;
27
26
 
28
- get translations() {
29
- return {
30
- placeholder: this.intl.t('editor-plugins.address.nodeview.placeholder', {
31
- locale: this.args.controller.documentLanguage,
32
- }),
33
- };
34
- }
35
-
36
27
  get address() {
37
28
  return this.args.node.attrs.value as Address | null;
38
29
  }
@@ -42,26 +33,23 @@ export default class AddressNodeviewComponent extends Component<Signature> {
42
33
  return getOutgoingTriple(this.args.node.attrs, EXT('label'))?.object.value;
43
34
  }
44
35
 
36
+ get filled() {
37
+ return !!this.address;
38
+ }
39
+
40
+ get content() {
41
+ if (this.filled) {
42
+ return this.address?.formatted;
43
+ } else {
44
+ return this.label;
45
+ }
46
+ }
47
+
45
48
  <template>
46
- <AuPill
47
- class='variable atomic'
48
- @icon={{PencilIcon}}
49
- @iconAlignment='right'
50
- ...attributes
51
- {{on 'click' @selectNode}}
52
- >
53
- {{#if this.address}}
54
- {{this.address.formatted}}
55
- {{else}}
56
- <span class='mark-highlight-manual'>
57
- {{this.translations.placeholder}}
58
- </span>
59
- {{/if}}
60
- {{#if this.label}}
61
- <span class='label'>
62
- ({{this.label}})
63
- </span>
64
- {{/if}}
49
+ <AuPill class='say-pill atomic' ...attributes {{on 'click' @selectNode}}>
50
+ <span class='{{unless this.filled "unfilled-variable"}}'>
51
+ {{this.content}}
52
+ </span>
65
53
  </AuPill>
66
54
  </template>
67
55
  }
@@ -1,21 +1,32 @@
1
1
  import Component from '@glimmer/component';
2
+ import { service } from '@ember/service';
2
3
  import { on } from '@ember/modifier';
4
+ import IntlService from 'ember-intl/services/intl';
3
5
  import t from 'ember-intl/helpers/t';
4
- import AuAlert from '@appuniversum/ember-appuniversum/components/au-alert';
5
6
  import { PlusTextIcon } from '@appuniversum/ember-appuniversum/components/icons/plus-text';
7
+ import AuIcon from '@appuniversum/ember-appuniversum/components/au-icon';
8
+ import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
6
9
  import { type EmberNodeArgs } from '@lblod/ember-rdfa-editor/utils/_private/ember-node';
7
- import { service } from '@ember/service';
8
- import IntlService from 'ember-intl/services/intl';
10
+ import { type SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
9
11
 
10
12
  interface Signature {
11
- Args: Pick<EmberNodeArgs, 'node' | 'selectNode'>;
13
+ Args: Pick<EmberNodeArgs, 'node' | 'selectNode'> & {
14
+ insertSnippet: () => void;
15
+ };
12
16
  }
13
17
 
14
18
  export default class SnippetPluginPlaceholder extends Component<Signature> {
15
19
  @service declare intl: IntlService;
20
+
21
+ get node() {
22
+ return this.args.node;
23
+ }
16
24
  get listNames() {
17
25
  return this.args.node.attrs.snippetListNames;
18
26
  }
27
+ get config(): SnippetPluginConfig {
28
+ return this.node.attrs.config;
29
+ }
19
30
  get isSingleList() {
20
31
  return this.listNames.length === 1;
21
32
  }
@@ -28,24 +39,32 @@ export default class SnippetPluginPlaceholder extends Component<Signature> {
28
39
  return this.intl.t('snippet-plugin.placeholder.title-multiple');
29
40
  }
30
41
  }
42
+
31
43
  <template>
32
- <AuAlert
33
- @title={{this.alertTitle}}
34
- @skin='warning'
35
- @icon={{PlusTextIcon}}
36
- @size='small'
37
- class='say-snippet-placeholder'
38
- {{on 'click' @selectNode}}
39
- >
40
- {{#unless this.isSingleList}}
41
- {{t 'snippet-plugin.placeholder.active-lists'}}
42
- <ul>
43
- {{#each this.listNames as |listName|}}
44
- <li>{{listName}}</li>
45
- {{/each}}
46
- </ul>
47
- {{/unless}}
48
- {{t 'snippet-plugin.placeholder.text'}}
49
- </AuAlert>
44
+ {{! template-lint-disable no-invalid-interactive }}
45
+ <div class='say-snippet-placeholder' {{on 'click' @selectNode}}>
46
+ <div class='say-snippet-placeholder__icon'>
47
+ <AuIcon @icon={{PlusTextIcon}} />
48
+ </div>
49
+ <div class='say-snippet-placeholder__content'>
50
+ <p class='say-snippet-placeholder__title'>{{this.alertTitle}}</p>
51
+ {{#unless this.isSingleList}}
52
+ <ul class='say-snippet-placeholder__list'>
53
+ {{#each this.listNames as |listName|}}
54
+ <li>{{listName}}</li>
55
+ {{/each}}
56
+ </ul>
57
+ {{/unless}}
58
+ {{#unless this.config.hidePlaceholderInsertButton}}
59
+ <AuButton
60
+ @skin='link'
61
+ class='say-snippet-placeholder__button'
62
+ {{on 'click' @insertSnippet}}
63
+ >
64
+ {{t 'snippet-plugin.placeholder.button'}}
65
+ </AuButton>
66
+ {{/unless}}
67
+ </div>
68
+ </div>
50
69
  </template>
51
70
  }
@@ -13,6 +13,7 @@ import { BinIcon } from '@appuniversum/ember-appuniversum/components/icons/bin';
13
13
  import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
14
14
  import { type EmberNodeArgs } from '@lblod/ember-rdfa-editor/utils/_private/ember-node';
15
15
  import {
16
+ NodeSelection,
16
17
  type PNode,
17
18
  ProseParser,
18
19
  type Selection,
@@ -30,6 +31,8 @@ import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transactio
30
31
  import { recalculateNumbers } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/structure-plugin/recalculate-structure-numbers';
31
32
  import { createSnippetPlaceholder } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/nodes/snippet-placeholder';
32
33
  import { hasDecendant } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/has-descendant';
34
+ import SnippetPlaceholder from '@lblod/ember-rdfa-editor-lblod-plugins/components/snippet-plugin/nodes/placeholder';
35
+ import { getSnippetListIdsFromNode } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
33
36
 
34
37
  interface ButtonSig {
35
38
  Args: {
@@ -76,6 +79,13 @@ export default class SnippetNode extends Component<Signature> {
76
79
  get node() {
77
80
  return this.args.node;
78
81
  }
82
+ get isPlaceholder() {
83
+ return this.node.content.size === 0;
84
+ }
85
+ get allowMultipleSnippets() {
86
+ return this.node.attrs.allowMultipleSnippets as boolean;
87
+ }
88
+
79
89
  @action
80
90
  closeModal() {
81
91
  this.showModal = false;
@@ -85,10 +95,6 @@ export default class SnippetNode extends Component<Signature> {
85
95
  this.showModal = true;
86
96
  }
87
97
 
88
- get allowMultipleSnippets() {
89
- return this.node.attrs.allowMultipleSnippets as boolean;
90
- }
91
-
92
98
  @action
93
99
  addFragment() {
94
100
  if (this.allowMultipleSnippets) {
@@ -123,7 +129,7 @@ export default class SnippetNode extends Component<Signature> {
123
129
  const node = createSnippetPlaceholder({
124
130
  listProperties: {
125
131
  placeholderId: this.node.attrs.placeholderId,
126
- listIds: this.node.attrs.snippetListIds,
132
+ listIds: getSnippetListIdsFromNode(this.node),
127
133
  names: this.node.attrs.snippetListNames,
128
134
  importedResources: this.node.attrs.importedResources,
129
135
  },
@@ -155,6 +161,12 @@ export default class SnippetNode extends Component<Signature> {
155
161
  return this.controller.mainEditorState.selection;
156
162
  }
157
163
  get isActive(): boolean {
164
+ if (
165
+ this.selection instanceof NodeSelection &&
166
+ this.selection.node === this.node
167
+ ) {
168
+ return true;
169
+ }
158
170
  const ancestor = findAncestors(this.selection.$from, (node: PNode) => {
159
171
  return hasOutgoingNamedNodeTriple(
160
172
  node.attrs,
@@ -188,7 +200,7 @@ export default class SnippetNode extends Component<Signature> {
188
200
  title,
189
201
  listProperties: {
190
202
  placeholderId: this.node.attrs.placeholderId,
191
- listIds: this.node.attrs.snippetListIds,
203
+ listIds: getSnippetListIdsFromNode(this.node),
192
204
  names: this.node.attrs.snippetListNames,
193
205
  importedResources: this.node.attrs.importedResources,
194
206
  },
@@ -199,40 +211,49 @@ export default class SnippetNode extends Component<Signature> {
199
211
  }
200
212
 
201
213
  <template>
202
- <div class='say-snippet-card'>
203
- <div class='say-snippet-title'>{{this.node.attrs.title}}</div>
204
- <div class='say-snippet-content'>{{yield}}</div>
205
- <div class='say-snippet-icons' contenteditable='false'>
206
- <SnippetButton
207
- @icon={{SynchronizeIcon}}
208
- @helpText='snippet-plugin.snippet-node.change-fragment'
209
- {{on 'click' this.editFragment}}
210
- @isActive={{this.isActive}}
211
- />
212
- <SnippetButton
213
- @icon={{BinIcon}}
214
- @helpText='snippet-plugin.snippet-node.remove-fragment'
215
- {{on 'click' this.deleteFragment}}
216
- @isActive={{this.isActive}}
217
- class='say-snippet-remove-button'
218
- />
219
- {{#if this.allowMultipleSnippets}}
214
+ {{#if this.isPlaceholder}}
215
+ <SnippetPlaceholder
216
+ @node={{@node}}
217
+ @selectNode={{@selectNode}}
218
+ @insertSnippet={{this.editFragment}}
219
+ />
220
+ {{else}}
221
+ <div class='say-snippet-card'>
222
+ <div class='say-snippet-title'>{{this.node.attrs.title}}</div>
223
+ <div class='say-snippet-content'>{{yield}}</div>
224
+ <div class='say-snippet-icons' contenteditable='false'>
220
225
  <SnippetButton
221
- @icon={{AddIcon}}
222
- @helpText='snippet-plugin.snippet-node.add-fragment'
223
- {{on 'click' this.addFragment}}
226
+ @icon={{SynchronizeIcon}}
227
+ @helpText='snippet-plugin.snippet-node.change-fragment'
228
+ {{on 'click' this.editFragment}}
224
229
  @isActive={{this.isActive}}
225
230
  />
226
- {{/if}}
227
- </div>
231
+ <SnippetButton
232
+ @icon={{BinIcon}}
233
+ @helpText='snippet-plugin.snippet-node.remove-fragment'
234
+ {{on 'click' this.deleteFragment}}
235
+ @isActive={{this.isActive}}
236
+ class='say-snippet-remove-button'
237
+ />
238
+ {{#if this.allowMultipleSnippets}}
239
+ <SnippetButton
240
+ @icon={{AddIcon}}
241
+ @helpText='snippet-plugin.snippet-node.add-fragment'
242
+ {{on 'click' this.addFragment}}
243
+ @isActive={{this.isActive}}
244
+ />
245
+ {{/if}}
246
+ </div>
228
247
 
229
- </div>
248
+ </div>
249
+ {{/if}}
230
250
  <SearchModal
231
251
  @open={{this.showModal}}
232
252
  @closeModal={{this.closeModal}}
233
253
  @config={{this.node.attrs.config}}
234
254
  @onInsert={{this.onInsert}}
235
- @snippetListIds={{this.node.attrs.snippetListIds}}
255
+ @snippetListIds={{getSnippetListIdsFromNode this.node}}
256
+ @snippetListNames={{this.node.attrs.snippetListNames}}
236
257
  />
237
258
  </template>
238
259
  }
@@ -3,7 +3,10 @@
3
3
  class='snippet-modal'
4
4
  @modalOpen={{@open}}
5
5
  @closeModal={{this.closeModal}}
6
- @title={{t 'snippet-plugin.modal.title'}}
6
+ @title={{t
7
+ 'snippet-plugin.modal.title'
8
+ snippetListNames=this.snippetListNames
9
+ }}
7
10
  @size='large'
8
11
  @padding='none'
9
12
  as |modal|
@@ -12,6 +12,7 @@ import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plug
12
12
  interface Args {
13
13
  config: SnippetPluginConfig;
14
14
  snippetListIds: string[] | undefined;
15
+ snippetListNames: string[] | undefined;
15
16
  closeModal: () => void;
16
17
  open: boolean;
17
18
  onInsert: (content: string, title: string) => void;
@@ -37,6 +38,10 @@ export default class SnippetPluginSearchModalComponent extends Component<Args> {
37
38
  return this.inputSearchText;
38
39
  }
39
40
 
41
+ get snippetListNames() {
42
+ return this.args.snippetListNames?.map((name) => `"${name}"`).join(', ');
43
+ }
44
+
40
45
  @action
41
46
  setInputSearchText(event: InputEvent) {
42
47
  assert(
@@ -7,10 +7,7 @@ import {
7
7
  type SnippetPluginConfig,
8
8
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
9
9
  import { findParentNodeClosestToPos } from '@curvenote/prosemirror-utils';
10
- import {
11
- getAssignedSnippetListsIdsFromProperties,
12
- getSnippetListIdsProperties,
13
- } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
10
+ import { getSnippetListIdsFromNode } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
14
11
  import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
15
12
  import SnippetInsert from './snippet-insert';
16
13
 
@@ -25,13 +22,11 @@ interface Sig {
25
22
  export default class SnippetInsertRdfaComponent extends Component<Sig> {
26
23
  get listProperties(): SnippetListProperties | undefined {
27
24
  const activeNode = this.args.node.value;
28
- const activeNodeSnippetListIds = getSnippetListIdsProperties(activeNode);
25
+ const listIds = getSnippetListIdsFromNode(activeNode);
29
26
 
30
- if (activeNodeSnippetListIds.length > 0) {
27
+ if (listIds.length > 0) {
31
28
  return {
32
- listIds: getAssignedSnippetListsIdsFromProperties(
33
- activeNodeSnippetListIds,
34
- ),
29
+ listIds,
35
30
  placeholderId: activeNode.attrs.placeholderId,
36
31
  names: activeNode.attrs.snippetListNames,
37
32
  importedResources: activeNode.attrs.importedResources,
@@ -49,11 +44,11 @@ export default class SnippetInsertRdfaComponent extends Component<Sig> {
49
44
  isResourceNode(node),
50
45
  );
51
46
  while (parentNode) {
52
- const properties = getSnippetListIdsProperties(parentNode.node);
47
+ const listIds = getSnippetListIdsFromNode(parentNode.node);
53
48
 
54
- if (properties.length > 0) {
49
+ if (listIds.length > 0) {
55
50
  return {
56
- listIds: getAssignedSnippetListsIdsFromProperties(properties),
51
+ listIds,
57
52
  placeholderId: parentNode.node.attrs.placeholderId,
58
53
  names: parentNode.node.attrs.snippetListNames,
59
54
  importedResources: parentNode.node.attrs.importedResources,
@@ -89,6 +89,7 @@ export default class SnippetInsertComponent extends Component<Sig> {
89
89
  @config={{@config}}
90
90
  @onInsert={{this.onInsert}}
91
91
  @snippetListIds={{@listProperties.listIds}}
92
+ @snippetListNames={{@listProperties.names}}
92
93
  />
93
94
  </template>
94
95
  }
@@ -1,20 +1,6 @@
1
1
  {{! @glint-nocheck: not typesafe yet }}
2
- <AuPill
3
- @icon={{this.PencilIcon}}
4
- @iconAlignment='right'
5
- class='variable atomic'
6
- {{on 'click' @selectNode}}
7
- >
8
- {{#if this.address}}
9
- {{this.address.formatted}}
10
- {{else}}
11
- <span class='mark-highlight-manual'>
12
- {{this.translations.placeholder}}
13
- </span>
14
- {{/if}}
15
- {{#if this.label}}
16
- <span class='label'>
17
- ({{this.label}})
18
- </span>
19
- {{/if}}
2
+ <AuPill class='say-pill atomic' {{on 'click' @selectNode}}>
3
+ <span class='{{unless this.filled "unfilled-variable"}}'>
4
+ {{this.content}}
5
+ </span>
20
6
  </AuPill>
@@ -1,7 +1,4 @@
1
1
  import Component from '@glimmer/component';
2
- import { service } from '@ember/service';
3
- import IntlService from 'ember-intl/services/intl';
4
- import { PencilIcon } from '@appuniversum/ember-appuniversum/components/icons/pencil';
5
2
 
6
3
  import { PNode, SayController } from '@lblod/ember-rdfa-editor';
7
4
  import { Address } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/address-helpers';
@@ -15,26 +12,6 @@ type Args = {
15
12
  };
16
13
 
17
14
  export default class AddressNodeviewComponent extends Component<Args> {
18
- PencilIcon = PencilIcon;
19
-
20
- @service declare intl: IntlService;
21
-
22
- get controller() {
23
- return this.args.controller;
24
- }
25
-
26
- get documentLanguage() {
27
- return this.controller.documentLanguage;
28
- }
29
-
30
- get translations() {
31
- return {
32
- placeholder: this.intl.t('editor-plugins.address.nodeview.placeholder', {
33
- locale: this.documentLanguage,
34
- }),
35
- };
36
- }
37
-
38
15
  get node() {
39
16
  return this.args.node;
40
17
  }
@@ -47,4 +24,16 @@ export default class AddressNodeviewComponent extends Component<Args> {
47
24
  if (this.address) return '';
48
25
  return getOutgoingTriple(this.node.attrs, EXT('label'))?.object.value;
49
26
  }
27
+
28
+ get filled() {
29
+ return !!this.address;
30
+ }
31
+
32
+ get content() {
33
+ if (this.filled) {
34
+ return this.address?.formatted;
35
+ } else {
36
+ return this.label;
37
+ }
38
+ }
50
39
  }
@@ -68,7 +68,8 @@ export default class AutoFilledVariableInsertComponent extends Component<Args> {
68
68
  locale: this.documentLanguage,
69
69
  });
70
70
 
71
- const label = this.label != '' ? this.label : placeholder;
71
+ const label =
72
+ this.label != '' ? this.label : this.autofillKey || placeholder;
72
73
  const node = this.schema.nodes.autofilled_variable.create(
73
74
  {
74
75
  subject: mappingSubject,
@@ -101,7 +102,7 @@ export default class AutoFilledVariableInsertComponent extends Component<Args> {
101
102
  },
102
103
 
103
104
  this.schema.node('placeholder', {
104
- placeholderText: `Autofill ${this.autofillKey}`,
105
+ placeholderText: label,
105
106
  }),
106
107
  );
107
108
  this.label = '';
@@ -137,7 +137,7 @@ export default class CodelistInsertComponent extends Component<Args> {
137
137
  ],
138
138
  },
139
139
  this.schema.node('placeholder', {
140
- placeholderText: this.selectedCodelist?.label,
140
+ placeholderText: label,
141
141
  }),
142
142
  );
143
143
 
@@ -1,14 +1,6 @@
1
1
  {{! @glint-nocheck: not typesafe yet }}
2
- <AuPill
3
- @icon={{this.PencilIcon}}
4
- @iconAlignment='right'
5
- class='variable atomic'
6
- {{on 'click' @selectNode}}
7
- >
8
- {{this.humanReadableDate}}
9
- {{#if this.label}}
10
- <span class='label'>
11
- ({{this.label}})
12
- </span>
13
- {{/if}}
2
+ <AuPill class='say-pill atomic' {{on 'click' @selectNode}}>
3
+ <span class='{{unless this.filled "unfilled-variable"}}'>
4
+ {{this.humanReadableDate}}
5
+ </span>
14
6
  </AuPill>