@lblod/ember-rdfa-editor-lblod-plugins 4.0.2 → 5.0.0

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 (27) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/addon/components/article-structure-plugin/structure-card.hbs +52 -18
  3. package/addon/components/article-structure-plugin/structure-card.ts +23 -2
  4. package/addon/components/hover-tooltip.hbs +8 -0
  5. package/addon/components/hover-tooltip.ts +36 -0
  6. package/addon/components/rdfa-date-plugin/card.hbs +1 -1
  7. package/addon/plugins/article-structure-plugin/index.ts +12 -6
  8. package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +1 -0
  9. package/addon/plugins/article-structure-plugin/structures/article.ts +1 -0
  10. package/addon/plugins/article-structure-plugin/structures/chapter.ts +1 -0
  11. package/addon/plugins/article-structure-plugin/structures/section.ts +1 -0
  12. package/addon/plugins/article-structure-plugin/structures/subsection.ts +2 -0
  13. package/addon/plugins/article-structure-plugin/structures/title.ts +1 -0
  14. package/addon/plugins/besluit-plugin/commands/insert-title.ts +2 -2
  15. package/addon/plugins/rdfa-date-plugin/index.ts +1 -3
  16. package/addon/plugins/standard-template-plugin/index.ts +2 -2
  17. package/addon/plugins/standard-template-plugin/utils/nodes.ts +2 -2
  18. package/app/components/hover-tooltip.js +1 -0
  19. package/components/article-structure-plugin/structure-card.d.ts +3 -1
  20. package/components/hover-tooltip.d.ts +18 -0
  21. package/package.json +1 -1
  22. package/plugins/article-structure-plugin/index.d.ts +6 -6
  23. package/plugins/rdfa-date-plugin/index.d.ts +1 -1
  24. package/plugins/standard-template-plugin/index.d.ts +1 -1
  25. package/plugins/standard-template-plugin/utils/nodes.d.ts +1 -1
  26. package/translations/en-US.yaml +14 -2
  27. package/translations/nl-BE.yaml +11 -2
package/CHANGELOG.md CHANGED
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [5.0.0] - 2023-04-07
11
+
12
+ ### Added
13
+ - add a hover-tooltip utility component
14
+ - docs: add tooltips to the remove structure buttons
15
+
16
+ ### Changed
17
+ - Change date labels based on designer feedback
18
+ - split out structure removal card into two buttons
19
+
20
+ ### Fixed
21
+ - BREAKING: Solve duplicate node title
22
+ - properly initialize ember-intl
23
+
10
24
  ## [4.0.2] - 2023-04-04
11
25
 
12
26
  ### Fixed
@@ -391,7 +405,8 @@ add onclick handler to pencil icon in variable plugin
391
405
 
392
406
  # Changelog
393
407
 
394
- [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.2...HEAD
408
+ [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v5.0.0...HEAD
409
+ [5.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.2...v5.0.0
395
410
  [4.0.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.1...v4.0.2
396
411
  [4.0.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.0...v4.0.1
397
412
  [4.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v3.1.0...v4.0.0
@@ -26,24 +26,58 @@
26
26
  </AuButton>
27
27
  </Item>
28
28
  <Item>
29
- {{#unless this.currentStructureType.noUnwrap}}
30
- <div class="au-u-padding-tiny">
31
- <AuToggleSwitch
32
- @label={{t "article-structure-plugin.remove.content"}}
33
- @checked={{this.removeStructureContent}}
34
- @onChange={{this.setRemoveStructureContent}}
35
- />
36
- </div>
37
- {{/unless}}
38
- <AuButton
39
- @icon="bin"
40
- @iconAlignment="left"
41
- @skin="link"
42
- @alert={{true}}
43
- @disabled={{not this.canRemoveStructure}}
44
- {{on 'click' this.removeStructure}}>
45
- {{t this.currentStructureType.translations.remove}}
46
- </AuButton>
29
+ <AuButtonGroup>
30
+ <HoverTooltip>
31
+ <:hover as |hover|>
32
+ <AuButton
33
+ @icon="bin"
34
+ @iconAlignment="left"
35
+ @skin="link"
36
+ @alert={{true}}
37
+ @disabled={{this.currentStructureType.noUnwrap}}
38
+ aria-describedby="remove-tooltip"
39
+ {{hover.velcroHook}}
40
+ {{hover.handleHover}}
41
+ {{on 'click' (fn this.removeStructure false)}}>
42
+ {{this.remove}}
43
+ </AuButton>
44
+ </:hover>
45
+ <:tooltip as |tooltip|>
46
+ <AuPill
47
+ id="remove-tooltip"
48
+ role="tooltip"
49
+ {{tooltip}}
50
+ >
51
+ {{t 'article-structure-plugin.remove.help-text'}}
52
+ </AuPill>
53
+ </:tooltip>
54
+ </HoverTooltip>
55
+ <HoverTooltip>
56
+ <:hover as |hover|>
57
+ <AuButton
58
+ @icon="bin"
59
+ @iconAlignment="left"
60
+ @skin="link"
61
+ aria-describedby="remove-content-tooltip"
62
+ @alert={{true}}
63
+ {{hover.velcroHook}}
64
+ {{hover.handleHover}}
65
+ {{on 'click' (fn this.removeStructure true)}}>
66
+ {{this.removeWithContent}}
67
+ </AuButton>
68
+ </:hover>
69
+ <:tooltip as |tooltip|>
70
+ <AuPill
71
+ id="remove-content-tooltip"
72
+ role="tooltip"
73
+ {{tooltip}}
74
+ >
75
+ {{t 'article-structure-plugin.remove-with-content.help-text'}}
76
+ </AuPill>
77
+ </:tooltip>
78
+ </HoverTooltip>
79
+
80
+ </AuButtonGroup>
47
81
  </Item>
48
82
  </AuList>
49
83
  </c.content>
@@ -35,9 +35,9 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
35
35
  }
36
36
 
37
37
  @action
38
- removeStructure() {
38
+ removeStructure(withContent: boolean) {
39
39
  if (this.structure && this.currentStructureType) {
40
- if (this.removeStructureContent || this.currentStructureType.noUnwrap) {
40
+ if (withContent || this.currentStructureType.noUnwrap) {
41
41
  this.controller.doCommand(
42
42
  removeStructure(this.structure, this.structureTypes),
43
43
  { view: this.controller.mainEditorView }
@@ -88,6 +88,27 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
88
88
  return;
89
89
  }
90
90
 
91
+ get remove() {
92
+ const translation = this.currentStructureType?.translations?.remove;
93
+ if (translation) {
94
+ return this.intl.t(translation);
95
+ } else {
96
+ return this.intl.t('article-structure-plugin.remove.default');
97
+ }
98
+ }
99
+
100
+ get removeWithContent() {
101
+ const translation =
102
+ this.currentStructureType?.translations?.removeWithContent;
103
+ if (translation) {
104
+ return this.intl.t(translation);
105
+ } else {
106
+ return this.intl.t(
107
+ 'article-structure-plugin.remove-with-content.default'
108
+ );
109
+ }
110
+ }
111
+
91
112
  get isOutsideStructure() {
92
113
  return !this.structure;
93
114
  }
@@ -0,0 +1,8 @@
1
+ <Velcro @placement={{this.placement}} as |velcro|>
2
+ {{#let velcro.loop as |loop|}}
3
+ {{yield (hash velcroHook=velcro.hook handleHover=(modifier this.hover)) to='hover' }}
4
+ {{#if this.tooltipOpen}}
5
+ {{yield loop to='tooltip'}}
6
+ {{/if}}
7
+ {{/let}}
8
+ </Velcro>
@@ -0,0 +1,36 @@
1
+ import Component from '@glimmer/component';
2
+ import { modifier } from 'ember-modifier';
3
+ import { tracked } from '@glimmer/tracking';
4
+
5
+ interface Args {
6
+ placement?: string;
7
+ }
8
+
9
+ export default class HoverTooltip extends Component<Args> {
10
+ hover = modifier((element) => {
11
+ element.addEventListener('mouseenter', this.showTooltip);
12
+ element.addEventListener('mouseleave', this.hideTooltip);
13
+ element.addEventListener('focus', this.showTooltip);
14
+ element.addEventListener('blur', this.hideTooltip);
15
+ return () => {
16
+ element.removeEventListener('mouseenter', this.showTooltip);
17
+ element.removeEventListener('mouseleave', this.hideTooltip);
18
+ element.removeEventListener('focus', this.showTooltip);
19
+ element.removeEventListener('blur', this.hideTooltip);
20
+ };
21
+ });
22
+
23
+ @tracked tooltipOpen = false;
24
+
25
+ get placement() {
26
+ return this.args.placement ?? 'top';
27
+ }
28
+
29
+ showTooltip = () => {
30
+ this.tooltipOpen = true;
31
+ };
32
+
33
+ hideTooltip = () => {
34
+ this.tooltipOpen = false;
35
+ };
36
+ }
@@ -47,7 +47,7 @@
47
47
  {{#each this.formats as |format|}}
48
48
  <AuFormRow>
49
49
  <AuControlRadio
50
- @label={{format.label}}
50
+ @label={{if format.label format.label (if this.onlyDate format.dateFormat format.dateTimeFormat)}}
51
51
  @identifier={{format.key}}
52
52
  @name="dateFormat"
53
53
  @value={{format.key}}
@@ -1,6 +1,11 @@
1
- import { Fragment, PNode, Schema, EditorState } from '@lblod/ember-rdfa-editor';
1
+ import {
2
+ EditorState,
3
+ Fragment,
4
+ PNode,
5
+ Schema,
6
+ Transaction,
7
+ } from '@lblod/ember-rdfa-editor';
2
8
  import IntlService from 'ember-intl/services/intl';
3
- import { Transaction } from '@lblod/ember-rdfa-editor';
4
9
 
5
10
  export type SpecName = string;
6
11
 
@@ -8,11 +13,12 @@ export type StructureSpec = {
8
13
  name: SpecName;
9
14
  translations: {
10
15
  insert: string;
11
- move: {
12
- up: string;
13
- down: string;
16
+ move?: {
17
+ up?: string;
18
+ down?: string;
14
19
  };
15
- remove: string;
20
+ remove?: string;
21
+ removeWithContent?: string;
16
22
  };
17
23
  constructor: (args: {
18
24
  schema: Schema;
@@ -21,6 +21,7 @@ export const articleParagraphSpec: StructureSpec = {
21
21
  down: 'article-structure-plugin.move-down.paragraph',
22
22
  },
23
23
  remove: 'article-structure-plugin.remove.paragraph',
24
+ removeWithContent: 'article-structure-plugin.remove-with-content.paragraph',
24
25
  },
25
26
  continuous: false,
26
27
  noUnwrap: true,
@@ -27,6 +27,7 @@ export const articleSpec: StructureSpec = {
27
27
  down: 'article-structure-plugin.move-down.article',
28
28
  },
29
29
  remove: 'article-structure-plugin.remove.article',
30
+ removeWithContent: 'article-structure-plugin.remove-with-content.article',
30
31
  },
31
32
  continuous: true,
32
33
  constructor: ({ schema, number, content, intl }) => {
@@ -22,6 +22,7 @@ export const chapterSpec: StructureSpec = {
22
22
  down: 'article-structure-plugin.move-down.chapter',
23
23
  },
24
24
  remove: 'article-structure-plugin.remove.chapter',
25
+ removeWithContent: 'article-structure-plugin.remove-with-content.chapter',
25
26
  },
26
27
  constructor: ({ schema, number, content, intl }) => {
27
28
  const numberConverted = romanize(number ?? 1);
@@ -22,6 +22,7 @@ export const sectionSpec: StructureSpec = {
22
22
  down: 'article-structure-plugin.move-down.section',
23
23
  },
24
24
  remove: 'article-structure-plugin.remove.section',
25
+ removeWithContent: 'article-structure-plugin.remove-with-content.section',
25
26
  },
26
27
  constructor: ({ schema, number, content, intl }) => {
27
28
  const numberConverted = romanize(number || 1);
@@ -23,6 +23,8 @@ export const subsectionSpec: StructureSpec = {
23
23
  down: 'article-structure-plugin.move-down.subsection',
24
24
  },
25
25
  remove: 'article-structure-plugin.remove.subsection',
26
+ removeWithContent:
27
+ 'article-structure-plugin.remove-with-content.subsection',
26
28
  },
27
29
  constructor: ({ schema, number, intl, content }) => {
28
30
  const numberConverted = romanize(number ?? 1);
@@ -22,6 +22,7 @@ export const titleSpec: StructureSpec = {
22
22
  down: 'article-structure-plugin.move-down.title',
23
23
  },
24
24
  remove: 'article-structure-plugin.remove.title',
25
+ removeWithContent: 'article-structure-plugin.remove-with-content.title',
25
26
  },
26
27
  constructor: ({ schema, number, content, intl }) => {
27
28
  const numberConverted = romanize(number ?? 1);
@@ -10,7 +10,7 @@ export default function insertTitle(intl: IntlService): Command {
10
10
  if (!besluit) {
11
11
  return false;
12
12
  }
13
- if (!besluit.node.canReplaceWith(0, 0, schema.nodes.title)) {
13
+ if (!besluit.node.canReplaceWith(0, 0, schema.nodes.besluit_title)) {
14
14
  return false;
15
15
  }
16
16
 
@@ -19,7 +19,7 @@ export default function insertTitle(intl: IntlService): Command {
19
19
  tr.insert(
20
20
  besluit.pos + 1,
21
21
  schema.node(
22
- 'title',
22
+ 'besluit_title',
23
23
  { __rdfaId: uuid() },
24
24
  schema.node(
25
25
  'paragraph',
@@ -1,12 +1,10 @@
1
1
  export const defaultDateFormats: DateFormat[] = [
2
2
  {
3
- label: 'Short Date',
4
3
  key: 'short',
5
4
  dateFormat: 'dd/MM/yy',
6
5
  dateTimeFormat: 'dd/MM/yy HH:mm',
7
6
  },
8
7
  {
9
- label: 'Long Date',
10
8
  key: 'long',
11
9
  dateFormat: 'EEEE dd MMMM yyyy',
12
10
  dateTimeFormat: 'PPPPp',
@@ -14,7 +12,7 @@ export const defaultDateFormats: DateFormat[] = [
14
12
  ];
15
13
 
16
14
  export type DateFormat = {
17
- label: string;
15
+ label?: string;
18
16
  key: string;
19
17
  dateFormat: string;
20
18
  dateTimeFormat: string;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  besluit,
3
- title,
3
+ besluit_title,
4
4
  description,
5
5
  motivering,
6
6
  article_container,
@@ -13,7 +13,7 @@ import {
13
13
 
14
14
  export const besluitNodes = {
15
15
  besluit,
16
- title,
16
+ besluit_title,
17
17
  description,
18
18
  motivering,
19
19
  article_container,
@@ -16,7 +16,7 @@ import { StructureSpec } from '../../article-structure-plugin';
16
16
  import { v4 as uuid } from 'uuid';
17
17
  import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
18
18
 
19
- export const title: NodeSpec = {
19
+ export const besluit_title: NodeSpec = {
20
20
  content: 'paragraph+',
21
21
  inline: false,
22
22
  defining: true,
@@ -308,7 +308,7 @@ export const besluit_article_content: NodeSpec = {
308
308
 
309
309
  export const besluit: NodeSpec = {
310
310
  group: 'block',
311
- content: 'block*title?block*description?block*motivering?block*',
311
+ content: 'block*besluit_title?block*description?block*motivering?block*',
312
312
  inline: false,
313
313
  defining: true,
314
314
  isolating: true,
@@ -0,0 +1 @@
1
+ export { default } from '@lblod/ember-rdfa-editor-lblod-plugins/components/hover-tooltip';
@@ -11,7 +11,7 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
11
11
  removeStructureContent: boolean;
12
12
  get controller(): SayController;
13
13
  moveStructure(direction: 'up' | 'down'): void;
14
- removeStructure(): void;
14
+ removeStructure(withContent: boolean): void;
15
15
  setRemoveStructureContent(value: boolean): void;
16
16
  get structureTypes(): ArticleStructurePluginOptions;
17
17
  get structureNodeSpecs(): import("prosemirror-model").NodeType[];
@@ -22,6 +22,8 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
22
22
  node: import("prosemirror-model").Node;
23
23
  } | undefined;
24
24
  get currentStructureType(): import("@lblod/ember-rdfa-editor-lblod-plugins/plugins/article-structure-plugin").StructureSpec | undefined;
25
+ get remove(): string;
26
+ get removeWithContent(): string;
25
27
  get isOutsideStructure(): boolean;
26
28
  get canMoveDown(): boolean;
27
29
  get canMoveUp(): boolean;
@@ -0,0 +1,18 @@
1
+ import Component from '@glimmer/component';
2
+ interface Args {
3
+ placement?: string;
4
+ }
5
+ export default class HoverTooltip extends Component<Args> {
6
+ hover: import("ember-modifier").FunctionBasedModifier<{
7
+ Args: {
8
+ Named: Record<string, unknown>;
9
+ Positional: unknown[];
10
+ };
11
+ Element: Element;
12
+ }>;
13
+ tooltipOpen: boolean;
14
+ get placement(): string;
15
+ showTooltip: () => void;
16
+ hideTooltip: () => void;
17
+ }
18
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "4.0.2",
3
+ "version": "5.0.0",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -1,16 +1,16 @@
1
- import { Fragment, PNode, Schema, EditorState } from '@lblod/ember-rdfa-editor';
1
+ import { EditorState, Fragment, PNode, Schema, Transaction } from '@lblod/ember-rdfa-editor';
2
2
  import IntlService from 'ember-intl/services/intl';
3
- import { Transaction } from '@lblod/ember-rdfa-editor';
4
3
  export type SpecName = string;
5
4
  export type StructureSpec = {
6
5
  name: SpecName;
7
6
  translations: {
8
7
  insert: string;
9
- move: {
10
- up: string;
11
- down: string;
8
+ move?: {
9
+ up?: string;
10
+ down?: string;
12
11
  };
13
- remove: string;
12
+ remove?: string;
13
+ removeWithContent?: string;
14
14
  };
15
15
  constructor: (args: {
16
16
  schema: Schema;
@@ -1,6 +1,6 @@
1
1
  export declare const defaultDateFormats: DateFormat[];
2
2
  export type DateFormat = {
3
- label: string;
3
+ label?: string;
4
4
  key: string;
5
5
  dateFormat: string;
6
6
  dateTimeFormat: string;
@@ -1,6 +1,6 @@
1
1
  export declare const besluitNodes: {
2
2
  besluit: import("prosemirror-model").NodeSpec;
3
- title: import("prosemirror-model").NodeSpec;
3
+ besluit_title: import("prosemirror-model").NodeSpec;
4
4
  description: import("prosemirror-model").NodeSpec;
5
5
  motivering: import("prosemirror-model").NodeSpec;
6
6
  article_container: import("prosemirror-model").NodeSpec;
@@ -1,6 +1,6 @@
1
1
  import { NodeSpec } from '@lblod/ember-rdfa-editor';
2
2
  import { StructureSpec } from '../../article-structure-plugin';
3
- export declare const title: NodeSpec;
3
+ export declare const besluit_title: NodeSpec;
4
4
  export declare const description: NodeSpec;
5
5
  export declare const motivering: NodeSpec;
6
6
  export declare const article_container: NodeSpec;
@@ -7,6 +7,7 @@ article-structure-plugin:
7
7
  section: Insert section
8
8
  subsection: Insert subsection
9
9
  move-up:
10
+ default: Move structure up
10
11
  paragraph: Move paragraph up
11
12
  article: Move article up
12
13
  title: Move title up
@@ -14,6 +15,7 @@ article-structure-plugin:
14
15
  section: Move section up
15
16
  subsection: Move subsection up
16
17
  move-down:
18
+ default: Move structure down
17
19
  paragraph: Move paragraph down
18
20
  article: Move article down
19
21
  title: Move title down
@@ -23,13 +25,23 @@ article-structure-plugin:
23
25
  title:
24
26
  structure-card: Structure Card
25
27
  remove:
28
+ default: Remove structure
26
29
  article: Remove Article
27
30
  paragraph: Remove Paragraph
28
31
  subsection: Remove subsection
29
32
  section: Remove section
30
33
  chapter: Remove chapter
31
34
  title: Remove title
32
- content: Remove content
35
+ help-text: Remove the heading, but keep the content
36
+ remove-with-content:
37
+ default: Remove structure with content
38
+ article: Remove Article with content
39
+ paragraph: Remove Paragraph with content
40
+ subsection: Remove subsection with content
41
+ section: Remove section with content
42
+ chapter: Remove chapter with content
43
+ title: Remove title with content
44
+ help-text: Remove the heading, and also remove all content up to the next heading of the same level
33
45
  placeholder:
34
46
  generic:
35
47
  heading: Insert title
@@ -166,4 +178,4 @@ variable-plugin:
166
178
 
167
179
  table-of-contents-plugin:
168
180
  title: Table of Contents
169
- toggle: Show Table of Contents
181
+ toggle: Show Table of Contents
@@ -23,13 +23,22 @@ article-structure-plugin:
23
23
  title:
24
24
  structure-card: Structuur card
25
25
  remove:
26
+ default: Structuur verwijderen
26
27
  article: Artikel verwijderen
27
28
  paragraph: Paragraaf verwijderen
28
29
  subsection: Onderafdeling verwijderen
29
30
  section: Afdeling verwijderen
30
31
  chapter: Hoofdstuk verwijderen
31
32
  title: Titel verwijderen
32
- content: Inhoud verwijderen
33
+ help-text: Verwijder de hoofding, maar behoud de inhoud
34
+ remove-with-content:
35
+ default: Structuur verwijderen met inhoud
36
+ article: Artikel en inhoud verwijderen
37
+ subsection: Onderafdeling en inhoud verwijderen
38
+ section: Afdeling en inhoud verwijderen
39
+ chapter: Hoofdstuk en inhoud verwijderen
40
+ title: Titel en inhoud verwijderen
41
+ help-text: Verwijder de hoofding, en alle inhoud tot aan de volgende hoofding van hetzelfde niveau
33
42
  placeholder:
34
43
  generic:
35
44
  heading: Voeg titel in
@@ -168,4 +177,4 @@ table-of-contents-plugin:
168
177
  variable-plugin:
169
178
  insert-variable: Voeg variabele in
170
179
  button: Voeg in
171
- enter-variable-value: Selecteer waarde
180
+ enter-variable-value: Selecteer waarde