@lblod/ember-rdfa-editor-lblod-plugins 35.0.0 → 35.0.1-dev.784b5c72babe3b47e2830dc91103f5b493e82a56

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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ For the document-validator-plugin: check if document has decision, hide correct property messages if true
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ Add plugin to add and edit placeholders
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 35.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#628](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/628) [`ef95ac6`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/ef95ac6afb3fcb00ab62c346376dbf5a88380bc2) Thanks [@kobemertens](https://github.com/kobemertens)! - Fix bug where snippet was not inserted if cursor was placed in link
8
+
9
+ - [#629](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/629) [`bbbbaa1`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/bbbbaa1109bc60cde8affcd8d54dff97b59dfd9b) Thanks [@piemonkey](https://github.com/piemonkey)! - Update tracked-built-ins dependency
10
+
3
11
  ## 35.0.0
4
12
 
5
13
  ### Major 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
+ }
@@ -209,6 +209,7 @@ export default class SnippetNode extends Component<Signature> {
209
209
  range: { start, end },
210
210
  allowMultipleSnippets: this.allowMultipleSnippets,
211
211
  }),
212
+ { view: this.args.controller.mainEditorView },
212
213
  );
213
214
  }
214
215
  get class() {
@@ -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.0",
3
+ "version": "35.0.1-dev.784b5c72babe3b47e2830dc91103f5b493e82a56",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -56,7 +56,8 @@
56
56
  "@codemirror/state": "^6.4.1",
57
57
  "@codemirror/view": "^6.28.3",
58
58
  "@curvenote/prosemirror-utils": "^1.0.5",
59
- "@embroider/macros": "^1.16.5",
59
+ "@embroider/macros": "^1.19.7",
60
+ "@lblod/lib-decision-shapes": "^0.0.25",
60
61
  "@lblod/marawa": "0.8.0-beta.6",
61
62
  "@lblod/template-uuid-instantiator": "1.0.3",
62
63
  "@rdfjs/data-model": "^2.0.2",
@@ -73,9 +74,8 @@
73
74
  "ember-cli-htmlbars": "^6.3.0",
74
75
  "ember-cli-version-checker": "^5.1.2",
75
76
  "ember-resources": "^7.0.2",
76
- "ember-template-imports": "^4.3.0",
77
+ "ember-template-imports": "^4.4.0",
77
78
  "ember-velcro": "^2.2.0",
78
- "@lblod/lib-decision-shapes": "^0.0.25",
79
79
  "n2words": "^1.21.0",
80
80
  "n3": "^1.26.0",
81
81
  "process": "0.11.10",
@@ -83,26 +83,26 @@
83
83
  "rdf-ext": "^2.5.2",
84
84
  "rdf-validate-shacl": "^0.4.5",
85
85
  "rdfa-streaming-parser": "^3.0.2",
86
- "reactiveweb": "^1.3.0",
86
+ "reactiveweb": "^1.9.1",
87
87
  "stream-browserify": "^3.0.0",
88
- "tracked-built-ins": "^3.3.0",
88
+ "tracked-built-ins": "^4.1.0",
89
89
  "tracked-toolbox": "^2.0.0",
90
90
  "uuid": "^9.0.1",
91
91
  "zod": "^3.24.1"
92
92
  },
93
93
  "devDependencies": {
94
- "@appuniversum/ember-appuniversum": "~3.15.1",
94
+ "@appuniversum/ember-appuniversum": "~3.17.0",
95
95
  "@changesets/changelog-github": "^0.5.0",
96
96
  "@changesets/cli": "^2.27.7",
97
- "@ember/optional-features": "^2.1.0",
98
- "@ember/render-modifiers": "^2.1.0",
97
+ "@ember/optional-features": "^2.3.0",
98
+ "@ember/render-modifiers": "^3.0.0",
99
99
  "@ember/string": "^3.1.1",
100
100
  "@ember/test-helpers": "^3.3.1",
101
- "@embroider/broccoli-side-watch": "^1.0.1",
102
- "@embroider/compat": "^3.8.4",
103
- "@embroider/core": "^3.5.4",
101
+ "@embroider/broccoli-side-watch": "^1.1.0",
102
+ "@embroider/compat": "^3.9.3",
103
+ "@embroider/core": "^3.5.9",
104
104
  "@embroider/test-setup": "^4.0.0",
105
- "@embroider/webpack": "^4.1.0",
105
+ "@embroider/webpack": "^4.1.2",
106
106
  "@gavant/glint-template-types": "^0.4.0",
107
107
  "@glimmer/component": "^1.1.2",
108
108
  "@glimmer/tracking": "^1.1.2",
@@ -222,5 +222,5 @@
222
222
  "ember-addon": {
223
223
  "configPath": "tests/dummy/config"
224
224
  },
225
- "packageManager": "pnpm@9.4.0"
225
+ "packageManager": "pnpm@10.28.2"
226
226
  }
@@ -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
@@ -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