@lblod/ember-rdfa-editor-lblod-plugins 26.2.1 → 26.2.2-dev.062c765ac0d45deacd81d63752660fc56eefffa0

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': minor
3
+ ---
4
+
5
+ Redesign of fragment nodes
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 26.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#522](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/522) [`2332962`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/23329624b10c10128c4b6cc438c2c5231579ab80) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Convert citation into a keyed plugin
8
+
9
+ - [#518](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/518) [`3188ea3`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/3188ea3ce4723f188854e8c66b37b44b1790a62c) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Add rdfa to the person variable
10
+
3
11
  ## 26.2.1
4
12
 
5
13
  ### Patch Changes
@@ -11,11 +11,12 @@ import {
11
11
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
12
12
  import {
13
13
  CitationDecoration,
14
- CitationPlugin,
15
14
  CitationPluginEmberComponentConfig,
15
+ CitationPluginState,
16
16
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
17
17
  import {
18
18
  DecorationSet,
19
+ PluginKey,
19
20
  SayController,
20
21
  Transaction,
21
22
  } from '@lblod/ember-rdfa-editor';
@@ -32,10 +33,10 @@ import {
32
33
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/legal-documents';
33
34
  import { cleanCaches } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/cache';
34
35
  import { SearchIcon } from '@appuniversum/ember-appuniversum/components/icons/search';
36
+ import { citationPluginKey } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
35
37
 
36
38
  interface Args {
37
39
  controller: SayController;
38
- plugin: CitationPlugin;
39
40
  config: CitationPluginEmberComponentConfig;
40
41
  }
41
42
 
@@ -76,8 +77,8 @@ export default class CitationCardComponent extends Component<Args> {
76
77
  return !this.controller.inEmbeddedView && this.activeDecoration;
77
78
  }
78
79
 
79
- get plugin() {
80
- return this.args.plugin;
80
+ get plugin(): PluginKey<CitationPluginState> {
81
+ return citationPluginKey;
81
82
  }
82
83
 
83
84
  get config() {
@@ -58,8 +58,6 @@ export default class LegalDocumentDetailComponent extends Component<Args> {
58
58
  });
59
59
  this.totalCount = results.totalCount;
60
60
 
61
- console.log({ result: results.articles });
62
-
63
61
  return results.articles;
64
62
  } catch (e) {
65
63
  console.warn(e); // eslint-ignore-line no-console
@@ -8,6 +8,7 @@ import t from 'ember-intl/helpers/t';
8
8
  import AuIcon, {
9
9
  type AuIconSignature,
10
10
  } from '@appuniversum/ember-appuniversum/components/au-icon';
11
+ import AuBadge from '@appuniversum/ember-appuniversum/components/au-badge';
11
12
  import { SynchronizeIcon } from '@appuniversum/ember-appuniversum/components/icons/synchronize';
12
13
  import { BinIcon } from '@appuniversum/ember-appuniversum/components/icons/bin';
13
14
  import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
@@ -219,7 +220,12 @@ export default class SnippetNode extends Component<Signature> {
219
220
  />
220
221
  {{else}}
221
222
  <div class='say-snippet-card'>
222
- <div class='say-snippet-title'>{{this.node.attrs.title}}</div>
223
+ <div class='say-snippet-title'>
224
+ <span class='au-c-badge au-c-badge--small say-snippet-title-icon'>
225
+ <AuIcon @icon='plus-text' />
226
+ </span>
227
+ {{this.node.attrs.title}}
228
+ </div>
223
229
  <div class='say-snippet-content'>{{yield}}</div>
224
230
  <div class='say-snippet-icons' contenteditable='false'>
225
231
  <SnippetButton
@@ -9,6 +9,7 @@ import {
9
9
  ProsePlugin,
10
10
  ResolvedPos,
11
11
  Schema,
12
+ PluginKey,
12
13
  } from '@lblod/ember-rdfa-editor';
13
14
  import processMatch, {
14
15
  RegexpMatchArrayWithIndices,
@@ -112,7 +113,7 @@ export interface CitationDecoration extends Decoration {
112
113
  spec: CitationDecorationSpec;
113
114
  }
114
115
 
115
- interface CitationPluginState {
116
+ export interface CitationPluginState {
116
117
  highlights: DecorationSet;
117
118
  activeRanges: [number, number][];
118
119
  }
@@ -153,8 +154,13 @@ export type CitationPluginEmberComponentConfig = CitationPluginConfig & {
153
154
  defaultDecisionsGovernmentName?: string;
154
155
  };
155
156
 
157
+ export const citationPluginKey: PluginKey<CitationPluginState> = new PluginKey(
158
+ 'say-citation-plugin',
159
+ );
160
+
156
161
  export function citationPlugin(config: CitationPluginConfig): CitationPlugin {
157
162
  const citation: CitationPlugin = new ProsePlugin({
163
+ key: citationPluginKey,
158
164
  state: {
159
165
  init(stateConfig: EditorStateConfig, state: EditorState) {
160
166
  return calculateCitationPluginState(state, config);
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  EXT,
3
+ FOAF,
3
4
  RDF,
5
+ PERSOON,
6
+ PERSON,
4
7
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
5
8
  import {
6
9
  createEmberNodeSpec,
@@ -51,22 +54,43 @@ const parseDOM = [
51
54
  return false;
52
55
  }
53
56
  let value: Person | undefined;
54
- if (node.dataset.value) {
55
- value = JSON.parse(node.dataset.value) as Person | undefined;
56
- } else if (node.dataset.mandatee) {
57
- const mandatee = JSON.parse(node.dataset.mandatee) as
58
- | {
59
- personUri: string;
60
- firstName: string;
61
- lastName: string;
62
- }
63
- | undefined;
64
- if (mandatee) {
65
- value = {
66
- uri: mandatee.personUri,
67
- firstName: mandatee.firstName,
68
- lastName: mandatee.lastName,
69
- };
57
+ const contentNode = node.querySelector(
58
+ '[data-content-container="true"]',
59
+ );
60
+ const aboutNode = contentNode?.querySelector(
61
+ `[property="${EXT('content').full}"],[property="${EXT('content').prefixed}]`,
62
+ );
63
+ if (aboutNode) {
64
+ const firstNameNode = aboutNode.querySelector(
65
+ `[property="${FOAF('gebruikteVoornaam').full}"],[property="${FOAF('gebruikteVoornaam').prefixed}"]`,
66
+ );
67
+ const lastNameNode = aboutNode.querySelector(
68
+ `[property="${PERSOON('familyName').full}"],[property="${PERSOON('familyName').prefixed}"]`,
69
+ );
70
+ value = {
71
+ uri: aboutNode.getAttribute('resource') || '',
72
+ firstName: firstNameNode?.textContent || '',
73
+ lastName: lastNameNode?.textContent || '',
74
+ };
75
+ } else {
76
+ // Backwards compatibility
77
+ if (node.dataset.value) {
78
+ value = JSON.parse(node.dataset.value) as Person | undefined;
79
+ } else if (node.dataset.mandatee) {
80
+ const mandatee = JSON.parse(node.dataset.mandatee) as
81
+ | {
82
+ personUri: string;
83
+ firstName: string;
84
+ lastName: string;
85
+ }
86
+ | undefined;
87
+ if (mandatee) {
88
+ value = {
89
+ uri: mandatee.personUri,
90
+ firstName: mandatee.firstName,
91
+ lastName: mandatee.lastName,
92
+ };
93
+ }
70
94
  }
71
95
  }
72
96
  return {
@@ -87,11 +111,9 @@ const serialize = (node: PNode, state: EditorState): DOMOutputSpec => {
87
111
  return renderRdfaAware({
88
112
  renderable: node,
89
113
  tag: 'span',
90
- attrs: {
91
- 'data-value': JSON.stringify(person),
92
- },
114
+ attrs: {},
93
115
  content: person
94
- ? `${person.firstName} ${person.lastName}`
116
+ ? generatePersonHtml(person)
95
117
  : t(
96
118
  'variable-plugin.person.nodeview-placeholder',
97
119
  TRANSLATION_FALLBACKS.nodeview_placeholder,
@@ -99,6 +121,32 @@ const serialize = (node: PNode, state: EditorState): DOMOutputSpec => {
99
121
  });
100
122
  };
101
123
 
124
+ function generatePersonHtml(person: Person): DOMOutputSpec {
125
+ return [
126
+ 'span',
127
+ {
128
+ property: EXT('content').full,
129
+ resource: person.uri,
130
+ typeof: PERSON('Person').full,
131
+ },
132
+ [
133
+ 'span',
134
+ {
135
+ property: FOAF('gebruikteVoornaam').full,
136
+ },
137
+ person.firstName,
138
+ ],
139
+ ' ',
140
+ [
141
+ 'span',
142
+ {
143
+ property: PERSOON('familyName').full,
144
+ },
145
+ person.lastName,
146
+ ],
147
+ ];
148
+ }
149
+
102
150
  const emberNodeConfig: EmberNodeConfig = {
103
151
  name: 'person-variable',
104
152
  component: PersonNodeViewComponent as unknown as ComponentLike,
@@ -46,6 +46,11 @@ export const SRO = namespace(
46
46
  'https://data.vlaanderen.be/ns/slimmeraadpleegomgeving#',
47
47
  'sro',
48
48
  );
49
+ export const PERSOON = namespace(
50
+ 'http://data.vlaanderen.be/ns/persoon#',
51
+ 'persoon',
52
+ );
53
+ export const PERSON = namespace('http://www.w3.org/ns/person#', 'person');
49
54
  export const BESTUURSPERIODES = {
50
55
  '2012-2019':
51
56
  'http://data.lblod.info/id/concept/Bestuursperiode/845dbc7f-139e-4632-b200-f90e180f1dba',
@@ -90,10 +90,17 @@
90
90
  border: 1px solid var(--au-blue-300);
91
91
  border-radius: var(--au-radius);
92
92
  .say-snippet-title {
93
- background-color: var(--au-blue-300);
93
+ background-color: var(--au-gray-100);
94
+ border-radius: 0.1em 0.1em 0 0;
94
95
  font-size: 1.6rem;
95
96
  font-weight: var(--au-medium);
96
97
  padding: 5px;
98
+ border-bottom: 1px solid var(--au-blue-300);
99
+ color: var(--au-blue-700);
100
+ .say-snippet-title-icon {
101
+ background-color: var(--au-blue-300);
102
+ color: black;
103
+ }
97
104
  }
98
105
  .say-snippet-content {
99
106
  padding: 20px;
@@ -143,6 +150,19 @@
143
150
  }
144
151
  }
145
152
 
153
+ .ember-node.say-active:has(> .say-snippet-card) {
154
+ outline: none;
155
+ }
156
+
157
+ .ember-node.say-active > .say-snippet-card {
158
+ border-color: var(--au-blue-700);
159
+ border-width: 0.2rem;
160
+ > .say-snippet-title {
161
+ border-bottom-color: var(--au-blue-700);
162
+ border-bottom-width: 0.2rem;
163
+ }
164
+ }
165
+
146
166
  .say-snippet-placeholder {
147
167
  display: flex;
148
168
  flex-direction: row;
@@ -1,12 +1,11 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
3
- import { CitationDecoration, CitationPlugin, CitationPluginEmberComponentConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
4
- import { DecorationSet, SayController } from '@lblod/ember-rdfa-editor';
3
+ import { CitationDecoration, CitationPluginEmberComponentConfig, CitationPluginState } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
4
+ import { DecorationSet, PluginKey, SayController } from '@lblod/ember-rdfa-editor';
5
5
  import { Article } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/article';
6
6
  import { LegalDocument } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/legal-documents';
7
7
  interface Args {
8
8
  controller: SayController;
9
- plugin: CitationPlugin;
10
9
  config: CitationPluginEmberComponentConfig;
11
10
  }
12
11
  export default class CitationCardComponent extends Component<Args> {
@@ -25,7 +24,7 @@ export default class CitationCardComponent extends Component<Args> {
25
24
  update(): void;
26
25
  get controller(): SayController;
27
26
  get showCard(): false | Option<CitationDecoration>;
28
- get plugin(): CitationPlugin;
27
+ get plugin(): PluginKey<CitationPluginState>;
29
28
  get config(): CitationPluginEmberComponentConfig;
30
29
  get decorations(): DecorationSet | undefined;
31
30
  get activeDecoration(): Option<CitationDecoration>;
@@ -1,4 +1,4 @@
1
- import { Decoration, DecorationSet, EditorState, InlineDecorationSpec, NodeType, PNode, ProsePlugin, Schema } from '@lblod/ember-rdfa-editor';
1
+ import { Decoration, DecorationSet, EditorState, InlineDecorationSpec, NodeType, PNode, ProsePlugin, Schema, PluginKey } from '@lblod/ember-rdfa-editor';
2
2
  /**
3
3
  * The monster regex that makes the citation plugin trigger to show `CitationCard`.
4
4
  * In restructuring, I've made sure that I didn't abstract away any of the capturing groups,
@@ -15,7 +15,7 @@ export interface CitationDecorationSpec extends InlineDecorationSpec {
15
15
  export interface CitationDecoration extends Decoration {
16
16
  spec: CitationDecorationSpec;
17
17
  }
18
- interface CitationPluginState {
18
+ export interface CitationPluginState {
19
19
  highlights: DecorationSet;
20
20
  activeRanges: [number, number][];
21
21
  }
@@ -43,5 +43,5 @@ export type CitationPluginEmberComponentConfig = CitationPluginConfig & {
43
43
  decisionsEndpoint?: string;
44
44
  defaultDecisionsGovernmentName?: string;
45
45
  };
46
+ export declare const citationPluginKey: PluginKey<CitationPluginState>;
46
47
  export declare function citationPlugin(config: CitationPluginConfig): CitationPlugin;
47
- export {};
@@ -18,6 +18,8 @@ export declare const MANDAAT: (s: string) => import("@lblod/ember-rdfa-editor-lb
18
18
  export declare const FOAF: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
19
19
  export declare const LOCN: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
20
20
  export declare const SRO: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
21
+ export declare const PERSOON: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
22
+ export declare const PERSON: (s: string) => import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
21
23
  export declare const BESTUURSPERIODES: {
22
24
  '2012-2019': string;
23
25
  '2019-2024': string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "26.2.1",
3
+ "version": "26.2.2-dev.062c765ac0d45deacd81d63752660fc56eefffa0",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
package/pnpm-lock.yaml CHANGED
@@ -4977,7 +4977,7 @@ packages:
4977
4977
  resolution: {integrity: sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==}
4978
4978
  engines: {node: '>= 4.0'}
4979
4979
  os: [darwin]
4980
- deprecated: Upgrade to fsevents v2 to mitigate potential security issues
4980
+ deprecated: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2
4981
4981
 
4982
4982
  fsevents@2.3.3:
4983
4983
  resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}