@lblod/ember-rdfa-editor-lblod-plugins 22.2.1 → 22.2.2-dev.4e13adb111a8710927eedefb6e57ae8397b236c4

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
+ Update `snippet-preview` component to include a collapsible (by default not shown) preview of the snippet
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 22.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#465](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/465) [`83b95db`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/83b95db9991f6b5ef090cd77765d8c09eac90db7) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Correctly export empty person nodes
8
+
9
+ - [#465](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/465) [`be233e8`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/be233e8bc70aee1db00644ad6f956157da8d3a20) Thanks [@lagartoverde](https://github.com/lagartoverde)! - Correctly export empty person node
10
+
3
11
  ## 22.2.1
4
12
 
5
13
  ### Patch Changes
@@ -0,0 +1,93 @@
1
+ import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
2
+ import AuIcon from '@appuniversum/ember-appuniversum/components/au-icon';
3
+ import { NavDownIcon } from '@appuniversum/ember-appuniversum/components/icons/nav-down';
4
+ import { NavUpIcon } from '@appuniversum/ember-appuniversum/components/icons/nav-up';
5
+ import { on } from '@ember/modifier';
6
+ import { action } from '@ember/object';
7
+ import Component from '@glimmer/component';
8
+ import { tracked } from '@glimmer/tracking';
9
+
10
+ import { SayController } from '@lblod/ember-rdfa-editor';
11
+ import {
12
+ Snippet,
13
+ SnippetPluginConfig,
14
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
15
+ import t from 'ember-intl/helpers/t';
16
+
17
+ interface Signature {
18
+ Args: {
19
+ config: SnippetPluginConfig;
20
+ snippet: Snippet;
21
+ onInsert: (content: string, title: string) => void;
22
+ };
23
+ Element: HTMLDivElement;
24
+ }
25
+
26
+ export default class SnippetPreviewComponent extends Component<Signature> {
27
+ @tracked controller?: SayController;
28
+ @tracked isExpanded = false;
29
+
30
+ get snippet(): Snippet {
31
+ return this.args.snippet;
32
+ }
33
+
34
+ @action
35
+ onInsert() {
36
+ this.args.onInsert(
37
+ this.args.snippet.content?.toHTML() ?? '',
38
+ this.args.snippet.title ?? '',
39
+ );
40
+ }
41
+
42
+ @action
43
+ togglePreview() {
44
+ this.isExpanded = !this.isExpanded;
45
+ }
46
+
47
+ <template>
48
+ <div class='snippet-preview' ...attributes>
49
+ <div class='snippet-preview__header'>
50
+ <div
51
+ role='button'
52
+ title={{t 'snippet-plugin.modal.preview-button.title'}}
53
+ {{on 'click' this.togglePreview}}
54
+ {{! template-lint-disable require-presentational-children}}
55
+ >
56
+ <AuButton @skin='link' class='snippet-preview__toggle'>
57
+ {{#if this.isExpanded}}
58
+ <AuIcon @icon={{NavUpIcon}} @size='large' />
59
+ {{else}}
60
+ <AuIcon @icon={{NavDownIcon}} @size='large' />
61
+ {{/if}}
62
+ </AuButton>
63
+ {{! template-lint-disable no-heading-inside-button}}
64
+ <h3 class='snippet-preview__title'>
65
+ {{@snippet.title}}
66
+ </h3>
67
+ </div>
68
+ <div
69
+ role='button'
70
+ title={{t 'snippet-plugin.modal.select-button.title'}}
71
+ {{on 'click' this.onInsert}}
72
+ {{! template-lint-disable require-presentational-children}}
73
+ >
74
+ <AuButton class='snippet-preview__insert-button' @skin='naked'>
75
+ {{t 'snippet-plugin.modal.select-button.label'}}
76
+ </AuButton>
77
+ </div>
78
+
79
+ </div>
80
+ {{#if this.isExpanded}}
81
+ <div
82
+ class='say-editor say-content rdfa-annotations rdfa-annotations-highlight rdfa-annotations-hover snippet-preview__content'
83
+ >
84
+ {{#if @snippet.content}}
85
+ {{@snippet.content}}
86
+ {{else}}
87
+ <p class='au-u-italic'>{{t 'snippet-plugin.modal.no-content'}}</p>
88
+ {{/if}}
89
+ </div>
90
+ {{/if}}
91
+ </div>
92
+ </template>
93
+ }
@@ -9,6 +9,7 @@ import {
9
9
  } from '@lblod/ember-rdfa-editor/utils/ember-node';
10
10
  import {
11
11
  DOMOutputSpec,
12
+ EditorState,
12
13
  getRdfaAttrs,
13
14
  PNode,
14
15
  rdfaAttrSpec,
@@ -19,6 +20,11 @@ import type { ComponentLike } from '@glint/template';
19
20
  import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
20
21
  import { renderRdfaAware } from '@lblod/ember-rdfa-editor/core/schema';
21
22
  import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
23
+ import { getTranslationFunction } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/translation';
24
+
25
+ const TRANSLATION_FALLBACKS = {
26
+ nodeview_placeholder: 'persoon',
27
+ };
22
28
 
23
29
  const rdfaAware = true;
24
30
  const parseDOM = [
@@ -50,7 +56,8 @@ const parseDOM = [
50
56
  },
51
57
  ];
52
58
 
53
- const toDOM = (node: PNode): DOMOutputSpec => {
59
+ const serialize = (node: PNode, state: EditorState): DOMOutputSpec => {
60
+ const t = getTranslationFunction(state);
54
61
  const mandatee = node.attrs.mandatee as Mandatee;
55
62
  return renderRdfaAware({
56
63
  renderable: node,
@@ -59,7 +66,12 @@ const toDOM = (node: PNode): DOMOutputSpec => {
59
66
  ...node.attrs,
60
67
  'data-mandatee': JSON.stringify(mandatee),
61
68
  },
62
- content: mandatee ? `${mandatee.fullName}` : '',
69
+ content: mandatee
70
+ ? `${mandatee.fullName}`
71
+ : t(
72
+ 'variable-plugin.person.nodeview-placeholder',
73
+ TRANSLATION_FALLBACKS.nodeview_placeholder,
74
+ ),
63
75
  });
64
76
  };
65
77
 
@@ -85,7 +97,7 @@ const emberNodeConfig: EmberNodeConfig = {
85
97
  default: null,
86
98
  },
87
99
  },
88
- toDOM,
100
+ serialize,
89
101
  parseDOM,
90
102
  };
91
103
 
@@ -34,51 +34,39 @@
34
34
  }
35
35
 
36
36
  .snippet-preview {
37
- // double specificity fix
38
- // https://stackoverflow.com/a/47781599/20388916
39
- // compiles to .snippet-preview--container.snippet-preview--container { flex-direction: row; }
40
- // need this to override the default flex-direction: column of the panel container
41
- &--container {
42
- &#{&} {
43
- flex-direction: row;
44
- }
45
- }
37
+ display: flex;
38
+ flex-direction: column;
39
+ background-color: var(--au-white);
40
+ border: 0.1rem solid var(--au-gray-200);
41
+ border-radius: var(--au-radius);
46
42
 
47
- &--article {
48
- flex-grow: 1;
43
+ &__header {
44
+ display: flex;
45
+ flex-direction: row;
46
+ align-items: center;
49
47
 
50
- .say-editor__paper,
51
- .say-editor__inner {
52
- min-height: auto;
53
- white-space: inherit;
48
+ > :nth-child(1) {
49
+ flex-grow: 1;
50
+ display: flex;
51
+ flex-direction: row;
52
+ align-items: center;
53
+ padding: $au-unit-small;
54
+ cursor: pointer;
54
55
  }
55
-
56
- .say-editor,
57
- .say-editor__inner {
58
- padding: 0;
56
+ > :nth-child(2) {
57
+ border-left: 1px solid var(--au-gray-200);
58
+ padding: $au-unit-small;
59
+ cursor: pointer;
59
60
  }
60
61
  }
61
62
 
62
- &--title {
63
+ &__title {
63
64
  color: var(--au-gray-700);
64
65
  font-weight: var(--au-medium);
65
66
  }
66
67
 
67
- &--button {
68
- border-left: 1px solid var(--au-gray-200);
69
- display: flex;
70
- align-items: center;
71
- }
72
-
73
- &--editor-overlay {
74
- position: absolute !important;
75
- top: 0;
76
- width: 100%;
77
- height: 100%;
78
- }
79
-
80
- &--editor-container {
81
- position: relative;
68
+ &__content {
69
+ padding: $au-unit-small $au-unit $au-unit-small $au-unit;
82
70
  }
83
71
  }
84
72
 
@@ -1,14 +1,19 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { SayController } from '@lblod/ember-rdfa-editor';
3
3
  import { Snippet, SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
4
- interface Args {
5
- config: SnippetPluginConfig;
6
- snippet: Snippet;
7
- onInsert: (content: string, title: string) => void;
4
+ interface Signature {
5
+ Args: {
6
+ config: SnippetPluginConfig;
7
+ snippet: Snippet;
8
+ onInsert: (content: string, title: string) => void;
9
+ };
10
+ Element: HTMLDivElement;
8
11
  }
9
- export default class SnippetPreviewComponent extends Component<Args> {
12
+ export default class SnippetPreviewComponent extends Component<Signature> {
10
13
  controller?: SayController;
14
+ isExpanded: boolean;
11
15
  get snippet(): Snippet;
12
16
  onInsert(): void;
17
+ togglePreview(): void;
13
18
  }
14
19
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "22.2.1",
3
+ "version": "22.2.2-dev.4e13adb111a8710927eedefb6e57ae8397b236c4",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -268,7 +268,7 @@ variable-plugin:
268
268
  to: to
269
269
  person:
270
270
  card-title: Insert person
271
- nodeview-placeholder: person
271
+ nodeview-placeholder: Insert person
272
272
 
273
273
  table-of-contents-plugin:
274
274
  title: Table of Contents
@@ -297,11 +297,16 @@ snippet-plugin:
297
297
  active-lists: 'Active lists:'
298
298
  modal:
299
299
  title: Choose a snippet
300
- select: Select
300
+ preview-button:
301
+ title: Show snippet preview
302
+ select-button:
303
+ label: Select
304
+ title: Insert snippet
301
305
  search:
302
306
  title: Filter on
303
307
  label: Snippet name
304
308
  placeholder: Type something...
309
+ no-content: Snippet does not contain any content
305
310
  snippet-list:
306
311
  open-modal: Manage snippet lists
307
312
  modal:
@@ -272,7 +272,7 @@ variable-plugin:
272
272
  to: tot
273
273
  person:
274
274
  card-title: Persoon invoegen
275
- nodeview-placeholder: persoon
275
+ nodeview-placeholder: Voeg persoon in
276
276
  dummy:
277
277
  validation-card:
278
278
  title: Documentvalidatie
@@ -296,11 +296,16 @@ snippet-plugin:
296
296
  active-lists: 'Actieve lijsten:'
297
297
  modal:
298
298
  title: Kies een fragment
299
- select: Selecteer
299
+ preview-button:
300
+ title: Preview van fragment tonen
301
+ select-button:
302
+ label: Selecteer
303
+ title: Fragment invoegen
300
304
  search:
301
305
  title: Filter op
302
306
  label: Fragmentnaam
303
307
  placeholder: Typ iets...
308
+ no-content: Fragment bevat geen inhoud
304
309
  snippet-list:
305
310
  open-modal: Fragmentlijsten beheren
306
311
  modal:
@@ -1,18 +0,0 @@
1
- {{! @glint-nocheck: not typesafe yet }}
2
- <div
3
- class='snippet-preview--container au-c-panel au-u-margin-right'
4
- ...attributes
5
- >
6
- <div
7
- class='snippet-preview--article au-u-padding au-u-padding-right-large rdfa-annotations rdfa-annotations-highlight rdfa-annotations-hover'
8
- >
9
- <h3 class='snippet-preview--title'>
10
- {{@snippet.title}}
11
- </h3>
12
- </div>
13
- <div class='snippet-preview--button au-u-padding-small'>
14
- <AuButton @skin='naked' {{on 'click' this.onInsert}}>
15
- {{t 'snippet-plugin.modal.select'}}
16
- </AuButton>
17
- </div>
18
- </div>
@@ -1,31 +0,0 @@
1
- import { action } from '@ember/object';
2
- import Component from '@glimmer/component';
3
- import { tracked } from '@glimmer/tracking';
4
-
5
- import { SayController } from '@lblod/ember-rdfa-editor';
6
- import {
7
- Snippet,
8
- SnippetPluginConfig,
9
- } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
10
-
11
- interface Args {
12
- config: SnippetPluginConfig;
13
- snippet: Snippet;
14
- onInsert: (content: string, title: string) => void;
15
- }
16
-
17
- export default class SnippetPreviewComponent extends Component<Args> {
18
- @tracked controller?: SayController;
19
-
20
- get snippet(): Snippet {
21
- return this.args.snippet;
22
- }
23
-
24
- @action
25
- onInsert() {
26
- this.args.onInsert(
27
- this.args.snippet.content?.toHTML() ?? '',
28
- this.args.snippet.title ?? '',
29
- );
30
- }
31
- }