@lblod/ember-rdfa-editor-lblod-plugins 35.0.1 → 35.1.0-dev.dc388e78b8aeb974a9101e49e557215c4b8c458d

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,17 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 35.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#631](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/631) [`784b5c7`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/784b5c72babe3b47e2830dc91103f5b493e82a56) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Add plugin to add and edit placeholders
8
+
9
+ ### Patch Changes
10
+
11
+ - [#630](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/630) [`1688755`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/168875521b1a0bc0927323a9eb64073efb66b1f1) Thanks [@kobemertens](https://github.com/kobemertens)! - For the document-validator-plugin: check if document has decision, hide correct property messages if true
12
+
13
+ - [`3e72235`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/3e72235c9b7822030b17e2533ed9d98e17df5735) Thanks [@kobemertens](https://github.com/kobemertens)! - change "variable" to "input field" in the UI
14
+
3
15
  ## 35.0.1
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,120 @@
1
+ import Component from '@glimmer/component';
2
+ import { tracked } from '@glimmer/tracking';
3
+ import { type ComponentLike } from '@glint/template';
4
+ import { NodeSelection, SayController } from '@lblod/ember-rdfa-editor';
5
+ import { service } from '@ember/service';
6
+ import IntlService from 'ember-intl/services/intl';
7
+ import AuCard from '@appuniversum/ember-appuniversum/components/au-card';
8
+ import AuLabel from '@appuniversum/ember-appuniversum/components/au-label';
9
+ import t from 'ember-intl/helpers/t';
10
+ import { on } from '@ember/modifier';
11
+ import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
12
+ import AuHeading from '@appuniversum/ember-appuniversum/components/au-heading';
13
+ import AuNativeInput from '../au-native-input';
14
+ import AuFormRow from '@appuniversum/ember-appuniversum/components/au-form-row';
15
+ import checkEnterAndSubmit from '@lblod/ember-rdfa-editor-lblod-plugins/utils/check-enter-and-submit';
16
+ import { fn } from '@ember/helper';
17
+
18
+ type VariableComponentArgs = {
19
+ Args: {
20
+ Named: {
21
+ controller: SayController;
22
+ };
23
+ };
24
+ };
25
+ export type VariableConfig = {
26
+ label: string;
27
+ component: ComponentLike<VariableComponentArgs>;
28
+ options?: unknown;
29
+ };
30
+
31
+ type Args = {
32
+ controller: SayController;
33
+ variableTypes: VariableConfig[];
34
+ };
35
+
36
+ export default class PlaceholderUtilsEditCardComponent extends Component<Args> {
37
+ @tracked editedPlaceholderLabel?: string;
38
+
39
+ @service declare intl: IntlService;
40
+
41
+ get controller() {
42
+ return this.args.controller;
43
+ }
44
+
45
+ get selectedPlaceholderNode() {
46
+ const { selection, schema } = this.controller.activeEditorState;
47
+ if (
48
+ selection instanceof NodeSelection &&
49
+ selection.node.type === schema.nodes.placeholder
50
+ ) {
51
+ return selection.node;
52
+ } else {
53
+ return;
54
+ }
55
+ }
56
+ get showCard() {
57
+ return !!this.selectedPlaceholderNode;
58
+ }
59
+ get placeholderLabel() {
60
+ return (
61
+ this.editedPlaceholderLabel ||
62
+ this.selectedPlaceholderNode?.attrs.placeholderText
63
+ );
64
+ }
65
+ updateLabelPlaceholder = (event: InputEvent) => {
66
+ this.editedPlaceholderLabel = (event.target as HTMLInputElement).value;
67
+ };
68
+ updatePlaceholder = () => {
69
+ const { selection } = this.controller.activeEditorState;
70
+ this.controller.withTransaction((tr) => {
71
+ return tr.setNodeAttribute(
72
+ selection.$from.pos,
73
+ 'placeholderText',
74
+ this.editedPlaceholderLabel,
75
+ );
76
+ });
77
+ };
78
+
79
+ <template>
80
+ {{#if this.showCard}}
81
+ <AuCard
82
+ @flex={{true}}
83
+ @divided={{true}}
84
+ @isOpenInitially={{true}}
85
+ @expandable={{true}}
86
+ @shadow={{true}}
87
+ @size='small'
88
+ @disableAuContent={{true}}
89
+ as |c|
90
+ >
91
+ <c.header>
92
+ <AuHeading @level='3' @skin='6'>
93
+ {{t 'placeholder-utils-plugin.card-title'}}
94
+ </AuHeading>
95
+ </c.header>
96
+ <c.content>
97
+ <AuFormRow>
98
+ <AuLabel for='label'>
99
+ {{t 'placeholder-utils-plugin.placeholder-text'}}
100
+ </AuLabel>
101
+ <AuNativeInput
102
+ id='label'
103
+ @type='text'
104
+ @width='block'
105
+ value={{this.placeholderLabel}}
106
+ {{on 'input' this.updateLabelPlaceholder}}
107
+ {{on 'keypress' (fn checkEnterAndSubmit this.updatePlaceholder)}}
108
+ />
109
+ </AuFormRow>
110
+ <AuButton
111
+ {{on 'click' this.updatePlaceholder}}
112
+ class='au-u-margin-top'
113
+ >
114
+ {{t 'editor-plugins.utils.insert'}}
115
+ </AuButton>
116
+ </c.content>
117
+ </AuCard>
118
+ {{/if}}
119
+ </template>
120
+ }
@@ -0,0 +1,72 @@
1
+ import Component from '@glimmer/component';
2
+ import { on } from '@ember/modifier';
3
+ import not from 'ember-truth-helpers/helpers/not';
4
+ import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
5
+ import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
6
+ import { NodeSelection, SayController } from '@lblod/ember-rdfa-editor';
7
+ import { type LocationPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/node';
8
+ import { action } from '@ember/object';
9
+ import t from 'ember-intl/helpers/t';
10
+
11
+ interface Signature {
12
+ Args: {
13
+ controller: SayController;
14
+ config: LocationPluginConfig;
15
+ templateMode?: boolean;
16
+ };
17
+ Element: HTMLLIElement;
18
+ }
19
+
20
+ export default class PlaceholderUtilsPluginInsertComponent extends Component<Signature> {
21
+ get selectedPlaceholderNode() {
22
+ const { selection, schema } = this.controller.activeEditorState;
23
+ if (
24
+ selection instanceof NodeSelection &&
25
+ selection.node.type === schema.nodes.placeholder
26
+ ) {
27
+ return selection.node;
28
+ } else {
29
+ return;
30
+ }
31
+ }
32
+
33
+ get controller() {
34
+ return this.args.controller;
35
+ }
36
+
37
+ get canInsert() {
38
+ return !this.selectedPlaceholderNode;
39
+ }
40
+
41
+ @action
42
+ insertPlaceholder() {
43
+ this.controller.withTransaction((tr) => {
44
+ tr.replaceSelectionWith(
45
+ this.controller.schema.node('placeholder', {
46
+ placeholderText: 'placeholder',
47
+ }),
48
+ );
49
+ if (tr.selection.$anchor.nodeBefore) {
50
+ const resolvedPos = tr.doc.resolve(
51
+ tr.selection.anchor - tr.selection.$anchor.nodeBefore?.nodeSize,
52
+ );
53
+ tr.setSelection(new NodeSelection(resolvedPos));
54
+ }
55
+ return tr;
56
+ });
57
+ }
58
+
59
+ <template>
60
+ <li class='au-c-list__item' ...attributes>
61
+ <AuButton
62
+ @icon={{AddIcon}}
63
+ @iconAlignment='left'
64
+ @skin='link'
65
+ {{on 'click' this.insertPlaceholder}}
66
+ @disabled={{not this.canInsert}}
67
+ >
68
+ {{t 'placeholder-utils-plugin.button-title'}}
69
+ </AuButton>
70
+ </li>
71
+ </template>
72
+ }
@@ -17,6 +17,10 @@ import {
17
17
  } from '@rdfjs/types';
18
18
  import ValidationReport from 'rdf-validate-shacl/src/validation-report';
19
19
  import { SayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
20
+ import {
21
+ BESLUIT,
22
+ RDF,
23
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
20
24
 
21
25
  export const documentValidationPluginKey =
22
26
  new PluginKey<DocumentValidationPluginState>('DOCUMENT_VALIDATION');
@@ -122,6 +126,10 @@ async function validationCallback(view: EditorView, documentHtml: string) {
122
126
  const { documentShape } = documentValidationState;
123
127
  const rdf = await htmlToRdf(documentHtml);
124
128
 
129
+ const documentHasDecision =
130
+ rdf.match(null, RDF('type').namedNode, BESLUIT('Besluit').namedNode).size >
131
+ 0;
132
+
125
133
  const shacl = await parse(documentShape);
126
134
 
127
135
  const validator = new SHACLValidator(shacl, {
@@ -157,11 +165,13 @@ async function validationCallback(view: EditorView, documentHtml: string) {
157
165
  }
158
166
  }
159
167
 
160
- const propertiesWithoutErrorsArray = propertyNodes.filter((propertyNode) =>
161
- propertiesWithErrors.every(
162
- (propertyWithError) => propertyWithError.shape !== propertyNode.value,
163
- ),
164
- );
168
+ const propertiesWithoutErrorsArray = documentHasDecision
169
+ ? propertyNodes.filter((propertyNode) =>
170
+ propertiesWithErrors.every(
171
+ (propertyWithError) => propertyWithError.shape !== propertyNode.value,
172
+ ),
173
+ )
174
+ : [];
165
175
 
166
176
  const successMessagePred = sayFactory.namedNode(
167
177
  'http://mu.semte.ch/vocabularies/ext/successMessage',
@@ -0,0 +1,8 @@
1
+ export default function checkEnterAndSubmit(
2
+ callback: (event: Event) => void,
3
+ event: KeyboardEvent,
4
+ ) {
5
+ if (event.key === 'Enter') {
6
+ callback(event);
7
+ }
8
+ }
@@ -0,0 +1 @@
1
+ export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/placeholder-utils-plugin/edit';
@@ -0,0 +1 @@
1
+ export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/placeholder-utils-plugin/insert';
@@ -0,0 +1,31 @@
1
+ import Component from '@glimmer/component';
2
+ import { type ComponentLike } from '@glint/template';
3
+ import { SayController } from '@lblod/ember-rdfa-editor';
4
+ import IntlService from 'ember-intl/services/intl';
5
+ type VariableComponentArgs = {
6
+ Args: {
7
+ Named: {
8
+ controller: SayController;
9
+ };
10
+ };
11
+ };
12
+ export type VariableConfig = {
13
+ label: string;
14
+ component: ComponentLike<VariableComponentArgs>;
15
+ options?: unknown;
16
+ };
17
+ type Args = {
18
+ controller: SayController;
19
+ variableTypes: VariableConfig[];
20
+ };
21
+ export default class PlaceholderUtilsEditCardComponent extends Component<Args> {
22
+ editedPlaceholderLabel?: string;
23
+ intl: IntlService;
24
+ get controller(): SayController;
25
+ get selectedPlaceholderNode(): import("prosemirror-model").Node | undefined;
26
+ get showCard(): boolean;
27
+ get placeholderLabel(): any;
28
+ updateLabelPlaceholder: (event: InputEvent) => void;
29
+ updatePlaceholder: () => void;
30
+ }
31
+ export {};
@@ -0,0 +1,18 @@
1
+ import Component from '@glimmer/component';
2
+ import { SayController } from '@lblod/ember-rdfa-editor';
3
+ import { type LocationPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/node';
4
+ interface Signature {
5
+ Args: {
6
+ controller: SayController;
7
+ config: LocationPluginConfig;
8
+ templateMode?: boolean;
9
+ };
10
+ Element: HTMLLIElement;
11
+ }
12
+ export default class PlaceholderUtilsPluginInsertComponent extends Component<Signature> {
13
+ get selectedPlaceholderNode(): import("prosemirror-model").Node | undefined;
14
+ get controller(): SayController;
15
+ get canInsert(): boolean;
16
+ insertPlaceholder(): void;
17
+ }
18
+ export {};
@@ -0,0 +1 @@
1
+ export default function checkEnterAndSubmit(callback: (event: Event) => void, event: KeyboardEvent): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "35.0.1",
3
+ "version": "35.1.0-dev.dc388e78b8aeb974a9101e49e557215c4b8c458d",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -223,7 +223,7 @@ variable:
223
223
  insert: Insert marcode
224
224
  label: Marcode
225
225
  variable-plugin:
226
- insert-variable: Insert variable
226
+ insert-variable: Insert input field
227
227
  button: Insert
228
228
  enter-variable-value: Select value
229
229
  unknown-codelist: Unable to find possible values for this codelist
@@ -524,3 +524,8 @@ document-validation-plugin:
524
524
  decision-node-not-found: Please put the cursor inside a decision node
525
525
  developer-modal-title: Developer info
526
526
  developer-modal-button: Close
527
+
528
+ placeholder-utils-plugin:
529
+ card-title: Edit placeholder
530
+ button-title: Insert placeholder
531
+ placeholder-text: Placeholder Text
@@ -227,7 +227,7 @@ variable:
227
227
  insert: Marcode invoegen
228
228
  label: Marcode
229
229
  variable-plugin:
230
- insert-variable: Voeg variabele in
230
+ insert-variable: Voeg invulveld in
231
231
  button: Voeg in
232
232
  enter-variable-value: Selecteer waarde
233
233
  unknown-codelist: Er werden geen mogelijke waarden voor deze codelijst gevonden
@@ -432,7 +432,7 @@ lmb-plugin:
432
432
  location-plugin:
433
433
  insert-placeholder: Voeg locatie-placeholder in
434
434
  modal:
435
- insert: locatie invoegen
435
+ insert: Locatie invoegen
436
436
  edit: Bewerk locatie
437
437
  confirm: Locatie instellen
438
438
  checkbox-message: Verkort adres tonen?
@@ -521,3 +521,8 @@ document-validation-plugin:
521
521
  decision-node-not-found: Plaats de cursor in een besluit
522
522
  developer-modal-title: Ontwikkelaarsinformatie
523
523
  developer-modal-button: Sluiten
524
+
525
+ placeholder-utils-plugin:
526
+ card-title: Plaatshouder bewerken
527
+ button-title: Plaatshouder invoegen
528
+ placeholder-text: Plaatshoudertekst