@lblod/ember-rdfa-editor-lblod-plugins 22.4.1 → 22.5.0-dev.fcb046da689838b3df38c0256efef0dce73e7cd1

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 (61) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/addon/components/auto-resizing-text-area.gts +43 -0
  3. package/addon/components/lmb-plugin/list.hbs +1 -1
  4. package/addon/components/lmb-plugin/search-modal.hbs +10 -7
  5. package/addon/components/lmb-plugin/search-modal.ts +8 -1
  6. package/addon/components/mandatee-table-plugin/configure.gts +4 -4
  7. package/addon/components/mandatee-table-plugin/node.gts +1 -1
  8. package/addon/components/snippet-plugin/nodes/snippet.gts +17 -30
  9. package/addon/components/snippet-plugin/search-modal.ts +1 -1
  10. package/addon/components/snippet-plugin/snippet-insert-placeholder.gts +15 -14
  11. package/addon/components/snippet-plugin/snippet-insert-rdfa.gts +82 -0
  12. package/addon/components/snippet-plugin/snippet-insert.gts +109 -0
  13. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +1 -1
  14. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +8 -11
  15. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +4 -1
  16. package/addon/components/snippet-plugin/snippet-list-select-rdfa.gts +25 -0
  17. package/addon/components/snippet-plugin/snippet-list-select.gts +104 -0
  18. package/addon/plugins/mandatee-table-plugin/node.ts +5 -1
  19. package/addon/plugins/snippet-plugin/commands/index.ts +1 -1
  20. package/addon/plugins/snippet-plugin/commands/{update-snippet-ids.ts → update-snippet-placeholder.ts} +23 -12
  21. package/addon/plugins/snippet-plugin/index.ts +19 -11
  22. package/addon/plugins/snippet-plugin/nodes/snippet-placeholder.ts +27 -9
  23. package/addon/plugins/snippet-plugin/nodes/snippet.ts +160 -2
  24. package/addon/plugins/snippet-plugin/utils/collate-imported-resources.ts +22 -0
  25. package/addon/plugins/snippet-plugin/utils/fetch-data.ts +52 -36
  26. package/addon/plugins/snippet-plugin/utils/rdfa-predicate.ts +3 -15
  27. package/addon/utils/sparql-helpers.ts +3 -4
  28. package/addon/utils/strings.ts +13 -0
  29. package/app/styles/mandatee-table-plugin.scss +5 -0
  30. package/declarations/addon/components/auto-resizing-text-area.d.ts +22 -0
  31. package/declarations/addon/components/snippet-plugin/nodes/snippet.d.ts +1 -1
  32. package/declarations/addon/components/snippet-plugin/search-modal.d.ts +1 -1
  33. package/declarations/addon/components/snippet-plugin/snippet-insert-placeholder.d.ts +2 -2
  34. package/declarations/addon/components/snippet-plugin/snippet-insert-rdfa.d.ts +13 -13
  35. package/declarations/addon/components/snippet-plugin/snippet-insert.d.ts +13 -9
  36. package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +2 -2
  37. package/declarations/addon/components/snippet-plugin/snippet-list-select-rdfa.d.ts +15 -19
  38. package/declarations/addon/components/snippet-plugin/snippet-list-select.d.ts +13 -5
  39. package/declarations/addon/plugins/snippet-plugin/commands/index.d.ts +1 -1
  40. package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-placeholder.d.ts +11 -0
  41. package/declarations/addon/plugins/snippet-plugin/index.d.ts +12 -8
  42. package/declarations/addon/plugins/snippet-plugin/nodes/snippet-placeholder.d.ts +5 -1
  43. package/declarations/addon/plugins/snippet-plugin/nodes/snippet.d.ts +27 -2
  44. package/declarations/addon/plugins/snippet-plugin/utils/collate-imported-resources.d.ts +2 -0
  45. package/declarations/addon/plugins/snippet-plugin/utils/fetch-data.d.ts +0 -1
  46. package/declarations/addon/plugins/snippet-plugin/utils/rdfa-predicate.d.ts +1 -1
  47. package/declarations/addon/utils/sparql-helpers.d.ts +5 -3
  48. package/declarations/addon/utils/strings.d.ts +2 -0
  49. package/package.json +3 -3
  50. package/pnpm-lock.yaml +29 -29
  51. package/translations/en-US.yaml +1 -0
  52. package/translations/nl-BE.yaml +1 -0
  53. package/addon/components/snippet-plugin/snippet-insert-rdfa.hbs +0 -7
  54. package/addon/components/snippet-plugin/snippet-insert-rdfa.ts +0 -78
  55. package/addon/components/snippet-plugin/snippet-insert.hbs +0 -20
  56. package/addon/components/snippet-plugin/snippet-insert.ts +0 -95
  57. package/addon/components/snippet-plugin/snippet-list-select-rdfa.hbs +0 -8
  58. package/addon/components/snippet-plugin/snippet-list-select-rdfa.ts +0 -68
  59. package/addon/components/snippet-plugin/snippet-list-select.hbs +0 -17
  60. package/addon/components/snippet-plugin/snippet-list-select.ts +0 -29
  61. package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-ids.d.ts +0 -11
@@ -1,7 +0,0 @@
1
- {{! @glint-nocheck: not typesafe yet }}
2
- <SnippetPlugin::SnippetInsert
3
- @config={{this.config}}
4
- @controller={{this.controller}}
5
- @assignedSnippetListsIds={{this.assignedSnippetListsIds}}
6
- @disabled={{not this.showInsert}}
7
- />
@@ -1,78 +0,0 @@
1
- import { isResourceNode } from '@lblod/ember-rdfa-editor/utils/node-utils';
2
- import Component from '@glimmer/component';
3
-
4
- import { SayController } from '@lblod/ember-rdfa-editor';
5
- import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
6
- import { findParentNodeClosestToPos } from '@curvenote/prosemirror-utils';
7
- import {
8
- getAssignedSnippetListsIdsFromProperties,
9
- getSnippetListIdsProperties,
10
- } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
11
- import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
12
- import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
13
-
14
- interface Args {
15
- controller: SayController;
16
- config: SnippetPluginConfig;
17
- node: ResolvedPNode;
18
- }
19
-
20
- export default class SnippetInsertRdfaComponent extends Component<Args> {
21
- get controller() {
22
- return this.args.controller;
23
- }
24
-
25
- get config() {
26
- return this.args.config;
27
- }
28
-
29
- get node() {
30
- return this.args.node;
31
- }
32
-
33
- get showInsert() {
34
- return this.assignedSnippetListsIds.length > 0;
35
- }
36
-
37
- get snippetListIdsProperty(): OutgoingTriple[] | undefined {
38
- const activeNode = this.node.value;
39
- const activeNodeSnippetListIds = getSnippetListIdsProperties(activeNode);
40
-
41
- if (activeNodeSnippetListIds.length > 0) {
42
- return activeNodeSnippetListIds;
43
- }
44
-
45
- const doc = this.controller.mainEditorState.doc;
46
-
47
- if (this.node.pos < 0) {
48
- return undefined;
49
- }
50
-
51
- const pos = doc.resolve(this.node.pos);
52
-
53
- let parentNode = findParentNodeClosestToPos(pos, (node) =>
54
- isResourceNode(node),
55
- );
56
-
57
- while (parentNode) {
58
- const properties = getSnippetListIdsProperties(parentNode.node);
59
-
60
- if (properties.length > 0) {
61
- return properties;
62
- }
63
-
64
- parentNode = findParentNodeClosestToPos(
65
- doc.resolve(parentNode.pos),
66
- (node) => isResourceNode(node),
67
- );
68
- }
69
-
70
- return undefined;
71
- }
72
-
73
- get assignedSnippetListsIds(): string[] {
74
- return getAssignedSnippetListsIdsFromProperties(
75
- this.snippetListIdsProperty,
76
- );
77
- }
78
- }
@@ -1,20 +0,0 @@
1
- {{! @glint-nocheck: not typesafe yet }}
2
- <li class='au-c-list__item'>
3
- <AuButton
4
- @icon={{this.AddIcon}}
5
- @iconAlignment='left'
6
- @skin='link'
7
- @disabled={{this.disabled}}
8
- {{on 'click' this.openModal}}
9
- >
10
- {{t 'snippet-plugin.insert.title'}}
11
- </AuButton>
12
- </li>
13
-
14
- <SnippetPlugin::SearchModal
15
- @open={{this.showModal}}
16
- @closeModal={{this.closeModal}}
17
- @config={{this.config}}
18
- @onInsert={{this.onInsert}}
19
- @assignedSnippetListsIds={{@assignedSnippetListsIds}}
20
- />
@@ -1,95 +0,0 @@
1
- import { action } from '@ember/object';
2
- import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
3
-
4
- import Component from '@glimmer/component';
5
- import { tracked } from '@glimmer/tracking';
6
-
7
- import { htmlToDoc } from '@lblod/ember-rdfa-editor/utils/_private/html-utils';
8
- import {
9
- ProseParser,
10
- SayController,
11
- Slice,
12
- Transaction,
13
- } from '@lblod/ember-rdfa-editor';
14
- import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
15
- import { v4 as uuidv4 } from 'uuid';
16
-
17
- interface Args {
18
- controller: SayController;
19
- config: SnippetPluginConfig;
20
- assignedSnippetListsIds: string[];
21
- disabled?: boolean;
22
- }
23
-
24
- export default class SnippetInsertComponent extends Component<Args> {
25
- AddIcon = AddIcon;
26
-
27
- @tracked showModal = false;
28
-
29
- get controller() {
30
- return this.args.controller;
31
- }
32
-
33
- get config() {
34
- return this.args.config;
35
- }
36
-
37
- @action
38
- openModal() {
39
- this.controller.focus();
40
- this.showModal = true;
41
- }
42
-
43
- @action
44
- closeModal() {
45
- this.showModal = false;
46
- }
47
-
48
- createSliceFromElement(element: Element) {
49
- return new Slice(
50
- ProseParser.fromSchema(this.controller.schema).parse(element, {
51
- preserveWhitespace: true,
52
- }).content,
53
- 0,
54
- 0,
55
- );
56
- }
57
-
58
- @action
59
- onInsert(content: string, title: string) {
60
- const domParser = new DOMParser();
61
- const parsed = domParser.parseFromString(content, 'text/html').body;
62
- const documentDiv = parsed.querySelector('div[data-say-document="true"]');
63
-
64
- this.closeModal();
65
- const parser = ProseParser.fromSchema(this.controller.schema);
66
-
67
- if (documentDiv) {
68
- return this.controller.withTransaction((tr: Transaction) => {
69
- return tr.replaceSelectionWith(
70
- this.controller.schema.node(
71
- 'snippet',
72
- {
73
- assignedSnippetListsIds: this.args.assignedSnippetListsIds,
74
- title: title,
75
- subject: `http://data.lblod.info/snippets/${uuidv4()}`,
76
- },
77
- htmlToDoc(content, {
78
- schema: this.controller.schema,
79
- parser,
80
- editorView: this.controller.mainEditorView,
81
- }).content,
82
- ),
83
- );
84
- });
85
- }
86
-
87
- this.controller.withTransaction((tr) =>
88
- tr.replaceSelection(this.createSliceFromElement(parsed)),
89
- );
90
- }
91
-
92
- get disabled() {
93
- return this.args.disabled ?? false;
94
- }
95
- }
@@ -1,8 +0,0 @@
1
- {{! @glint-nocheck: not typesafe yet }}
2
- {{#if this.isResourceNode}}
3
- <SnippetPlugin::SnippetListSelect
4
- @config={{this.config}}
5
- @assignedSnippetListsIds={{this.assignedSnippetListsIds}}
6
- @onSaveSnippetListIds={{this.saveChanges}}
7
- />
8
- {{/if}}
@@ -1,68 +0,0 @@
1
- import Component from '@glimmer/component';
2
-
3
- import { isResourceNode } from '@lblod/ember-rdfa-editor/utils/node-utils';
4
-
5
- import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
6
- import {
7
- getAssignedSnippetListsIdsFromProperties,
8
- getSnippetListIdsProperties,
9
- } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
10
- import { updateSnippetPlaceholder } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/commands';
11
- import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
12
- import { SayController } from '@lblod/ember-rdfa-editor';
13
- import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
14
-
15
- interface Args {
16
- controller: SayController;
17
- config: SnippetPluginConfig;
18
- node: ResolvedPNode;
19
- }
20
-
21
- export default class SnippetListSelectRdfaComponent extends Component<Args> {
22
- get config() {
23
- return this.args.config;
24
- }
25
-
26
- get controller() {
27
- return this.args.controller;
28
- }
29
-
30
- get node() {
31
- return this.args.node;
32
- }
33
-
34
- get currentResource() {
35
- return this.node.value.attrs.subject as string | undefined;
36
- }
37
-
38
- get isResourceNode() {
39
- return isResourceNode(this.node.value);
40
- }
41
-
42
- get snippetListIdsProperties(): OutgoingTriple[] {
43
- return getSnippetListIdsProperties(this.node.value);
44
- }
45
-
46
- get assignedSnippetListsIds(): string[] {
47
- return getAssignedSnippetListsIdsFromProperties(
48
- this.snippetListIdsProperties,
49
- );
50
- }
51
-
52
- saveChanges = (snippetIds: string[], snippetNames: string[]) => {
53
- if (this.currentResource) {
54
- this.args.controller?.doCommand(
55
- updateSnippetPlaceholder({
56
- resource: this.currentResource,
57
- oldSnippetProperties: this.snippetListIdsProperties ?? [],
58
- newSnippetIds: snippetIds,
59
- node: this.node,
60
- snippetNames,
61
- }),
62
- {
63
- view: this.args.controller.mainEditorView,
64
- },
65
- );
66
- }
67
- };
68
- }
@@ -1,17 +0,0 @@
1
- {{! @glint-nocheck: not typesafe yet }}
2
- <AuButton
3
- @icon={{this.UnorderedListIcon}}
4
- @skin='secondary'
5
- @iconAlignment='left'
6
- {{on 'click' this.openModal}}
7
- >
8
- {{t 'snippet-plugin.snippet-list.open-modal'}}
9
- </AuButton>
10
-
11
- <SnippetPlugin::SnippetList::SnippetListModal
12
- @config={{@config}}
13
- @assignedSnippetListsIds={{@assignedSnippetListsIds}}
14
- @onSaveSnippetListIds={{@onSaveSnippetListIds}}
15
- @open={{this.showModal}}
16
- @closeModal={{this.closeModal}}
17
- />
@@ -1,29 +0,0 @@
1
- import { action } from '@ember/object';
2
- import Component from '@glimmer/component';
3
- import { tracked } from '@glimmer/tracking';
4
- import { UnorderedListIcon } from '@appuniversum/ember-appuniversum/components/icons/unordered-list';
5
-
6
- import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
7
-
8
- interface Signature {
9
- Args: {
10
- config: SnippetPluginConfig;
11
- assignedSnippetListsIds: string[];
12
- onSaveSnippetListIds: (listIds: string[]) => void;
13
- };
14
- }
15
-
16
- export default class SnippetListSelectComponent extends Component<Signature> {
17
- UnorderedListIcon = UnorderedListIcon;
18
- @tracked showModal = false;
19
-
20
- @action
21
- openModal() {
22
- this.showModal = true;
23
- }
24
-
25
- @action
26
- closeModal() {
27
- this.showModal = false;
28
- }
29
- }
@@ -1,11 +0,0 @@
1
- import { Command } from '@lblod/ember-rdfa-editor';
2
- import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
3
- import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
4
- declare const updateSnippetPlaceholder: ({ resource, oldSnippetProperties, newSnippetIds, node, snippetNames, }: {
5
- resource: string;
6
- oldSnippetProperties: OutgoingTriple[];
7
- newSnippetIds: string[];
8
- node: ResolvedPNode;
9
- snippetNames: string[];
10
- }) => Command;
11
- export default updateSnippetPlaceholder;