@lblod/ember-rdfa-editor-lblod-plugins 22.2.0 → 22.2.1-dev.7a3a7c0f54fef43445cfab79cb69ee4e9615cc8e

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 (48) hide show
  1. package/.changeset/mighty-guests-peel.md +5 -0
  2. package/CHANGELOG.md +8 -0
  3. package/README.md +16 -0
  4. package/addon/components/snippet-plugin/nodes/snippet.gts +12 -21
  5. package/addon/components/snippet-plugin/search-modal.ts +1 -1
  6. package/addon/components/snippet-plugin/snippet-insert-placeholder.gts +15 -14
  7. package/addon/components/snippet-plugin/snippet-insert-rdfa.gts +82 -0
  8. package/addon/components/snippet-plugin/snippet-insert.gts +110 -0
  9. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +1 -1
  10. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +8 -11
  11. package/addon/components/snippet-plugin/snippet-list-select-rdfa.gts +25 -0
  12. package/addon/components/snippet-plugin/snippet-list-select.gts +104 -0
  13. package/addon/plugins/snippet-plugin/commands/index.ts +1 -1
  14. package/addon/plugins/snippet-plugin/commands/{update-snippet-ids.ts → update-snippet-placeholder.ts} +23 -12
  15. package/addon/plugins/snippet-plugin/index.ts +17 -9
  16. package/addon/plugins/snippet-plugin/nodes/snippet-placeholder.ts +27 -9
  17. package/addon/plugins/snippet-plugin/nodes/snippet.ts +57 -2
  18. package/addon/plugins/snippet-plugin/utils/collate-imported-resources.ts +22 -0
  19. package/addon/plugins/snippet-plugin/utils/fetch-data.ts +4 -1
  20. package/addon/plugins/snippet-plugin/utils/rdfa-predicate.ts +3 -15
  21. package/addon/utils/strings.ts +13 -0
  22. package/app/styles/document-title-plugin.scss +8 -6
  23. package/declarations/addon/components/snippet-plugin/search-modal.d.ts +1 -1
  24. package/declarations/addon/components/snippet-plugin/snippet-insert-placeholder.d.ts +2 -2
  25. package/declarations/addon/components/snippet-plugin/snippet-insert-rdfa.d.ts +13 -13
  26. package/declarations/addon/components/snippet-plugin/snippet-insert.d.ts +12 -8
  27. package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +2 -2
  28. package/declarations/addon/components/snippet-plugin/snippet-list-select-rdfa.d.ts +15 -19
  29. package/declarations/addon/components/snippet-plugin/snippet-list-select.d.ts +13 -5
  30. package/declarations/addon/plugins/snippet-plugin/commands/index.d.ts +1 -1
  31. package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-placeholder.d.ts +11 -0
  32. package/declarations/addon/plugins/snippet-plugin/index.d.ts +10 -6
  33. package/declarations/addon/plugins/snippet-plugin/nodes/snippet-placeholder.d.ts +5 -1
  34. package/declarations/addon/plugins/snippet-plugin/nodes/snippet.d.ts +10 -2
  35. package/declarations/addon/plugins/snippet-plugin/utils/collate-imported-resources.d.ts +2 -0
  36. package/declarations/addon/plugins/snippet-plugin/utils/rdfa-predicate.d.ts +1 -1
  37. package/declarations/addon/utils/strings.d.ts +2 -0
  38. package/package.json +3 -3
  39. package/pnpm-lock.yaml +26 -25
  40. package/addon/components/snippet-plugin/snippet-insert-rdfa.hbs +0 -7
  41. package/addon/components/snippet-plugin/snippet-insert-rdfa.ts +0 -78
  42. package/addon/components/snippet-plugin/snippet-insert.hbs +0 -20
  43. package/addon/components/snippet-plugin/snippet-insert.ts +0 -95
  44. package/addon/components/snippet-plugin/snippet-list-select-rdfa.hbs +0 -8
  45. package/addon/components/snippet-plugin/snippet-list-select-rdfa.ts +0 -68
  46. package/addon/components/snippet-plugin/snippet-list-select.hbs +0 -17
  47. package/addon/components/snippet-plugin/snippet-list-select.ts +0 -29
  48. package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-ids.d.ts +0 -11
@@ -1,6 +1,9 @@
1
1
  import { htmlSafe } from '@ember/template';
2
2
 
3
- import { optionMapOr } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
3
+ import {
4
+ type Option,
5
+ optionMapOr,
6
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
4
7
  import { dateValue } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
5
8
  import { SafeString } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/types';
6
9
 
@@ -26,10 +29,13 @@ export class Snippet {
26
29
  }
27
30
  }
28
31
 
32
+ export type ImportedResourceMap = Record<string, Option<string>>;
33
+
29
34
  interface SnippetListArgs {
30
- id: string | null;
31
- label: string | null;
32
- createdOn: string | null;
35
+ id: string;
36
+ label: string;
37
+ createdOn: string;
38
+ importedResources: string[];
33
39
  }
34
40
 
35
41
  const snippetListBase = 'http://lblod.data.gift/snippet-lists/';
@@ -40,13 +46,15 @@ export const getSnippetIdFromUri = (uri: string) =>
40
46
  uri.replace(snippetListBase, '');
41
47
 
42
48
  export class SnippetList {
43
- id: string | null;
44
- label: string | null;
49
+ id: string;
50
+ label: string;
45
51
  createdOn: string | null;
52
+ importedResources: string[];
46
53
 
47
- constructor({ id, label, createdOn }: SnippetListArgs) {
48
- this.id = id ? getSnippetIdFromUri(id) : null;
54
+ constructor({ id, label, createdOn, importedResources }: SnippetListArgs) {
55
+ this.id = getSnippetIdFromUri(id);
49
56
  this.label = label;
50
- this.createdOn = dateValue(createdOn ?? undefined);
57
+ this.createdOn = dateValue(createdOn);
58
+ this.importedResources = importedResources;
51
59
  }
52
60
  }
@@ -18,30 +18,43 @@ import {
18
18
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
19
19
  import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
20
20
  import { getTranslationFunction } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/translation';
21
- import { getSnippetUriFromId } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
21
+ import { jsonParse } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
22
+ import {
23
+ getSnippetUriFromId,
24
+ type ImportedResourceMap,
25
+ type SnippetList,
26
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
22
27
  import { SNIPPET_LIST_RDFA_PREDICATE } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
23
28
 
24
- export function createSnippetPlaceholder(
25
- listIds: string[],
26
- listNames: string[],
27
- schema: Schema,
29
+ export function importedResourcesFromSnippetLists(
30
+ lists: SnippetList[],
31
+ existing: ImportedResourceMap = {},
28
32
  ) {
29
- const mappingResource = `http://example.net/lblod-snippet-placeholder/${uuidv4()}`;
33
+ return Object.fromEntries<ImportedResourceMap[string]>(
34
+ lists
35
+ .flatMap((list) => list.importedResources)
36
+ // Null is important (in place of undefined) in order to keep the unlinked entries
37
+ .map((res) => [res, existing[res] ?? null]),
38
+ );
39
+ }
30
40
 
41
+ export function createSnippetPlaceholder(lists: SnippetList[], schema: Schema) {
42
+ const mappingResource = `http://example.net/lblod-snippet-placeholder/${uuidv4()}`;
31
43
  return schema.nodes.snippet_placeholder.create({
32
44
  rdfaNodeType: 'resource',
33
- listNames,
45
+ listNames: lists.map((list) => list.label),
34
46
  subject: mappingResource,
35
47
  properties: [
36
48
  {
37
49
  predicate: RDF('type').full,
38
50
  object: sayDataFactory.namedNode(EXT('SnippetPlaceholder').full),
39
51
  },
40
- ...listIds.map((listId) => ({
52
+ ...lists.map((list) => ({
41
53
  predicate: SNIPPET_LIST_RDFA_PREDICATE.full,
42
- object: sayDataFactory.namedNode(getSnippetUriFromId(listId)),
54
+ object: sayDataFactory.namedNode(getSnippetUriFromId(list.id)),
43
55
  })),
44
56
  ],
57
+ importedResources: importedResourcesFromSnippetLists(lists),
45
58
  });
46
59
  }
47
60
 
@@ -56,6 +69,7 @@ const emberNodeConfig: EmberNodeConfig = {
56
69
  ...rdfaAttrSpec({ rdfaAware: true }),
57
70
  typeof: { default: EXT('SnippetPlaceholder') },
58
71
  listNames: { default: [] },
72
+ importedResources: { default: {} },
59
73
  },
60
74
  component: SnippetPlaceholderComponent,
61
75
  serialize(node, editorState) {
@@ -67,6 +81,7 @@ const emberNodeConfig: EmberNodeConfig = {
67
81
  ...node.attrs,
68
82
  class: 'say-snippet-placeholder-node',
69
83
  'data-list-names': (node.attrs.listNames as string[]).join(','),
84
+ 'data-imported-resources': JSON.stringify(node.attrs.importedResources),
70
85
  },
71
86
  content: [
72
87
  'text',
@@ -93,6 +108,9 @@ const emberNodeConfig: EmberNodeConfig = {
93
108
  return {
94
109
  ...rdfaAttrs,
95
110
  listNames: node.getAttribute('data-list-names')?.split(','),
111
+ importedResources: jsonParse(
112
+ node.getAttribute('data-imported-resources'),
113
+ ),
96
114
  };
97
115
  }
98
116
  return false;
@@ -1,4 +1,10 @@
1
- import { getRdfaAttrs, rdfaAttrSpec } from '@lblod/ember-rdfa-editor';
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ import {
3
+ getRdfaAttrs,
4
+ ProseParser,
5
+ rdfaAttrSpec,
6
+ type SayController,
7
+ } from '@lblod/ember-rdfa-editor';
2
8
  import {
3
9
  renderRdfaAware,
4
10
  getRdfaContentElement,
@@ -9,13 +15,57 @@ import {
9
15
  createEmberNodeView,
10
16
  type EmberNodeConfig,
11
17
  } from '@lblod/ember-rdfa-editor/utils/ember-node';
18
+ import { htmlToDoc } from '@lblod/ember-rdfa-editor/utils/_private/html-utils';
12
19
  import SnippetComponent from '@lblod/ember-rdfa-editor-lblod-plugins/components/snippet-plugin/nodes/snippet';
13
20
  import {
14
21
  EXT,
15
22
  RDF,
16
23
  } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
17
24
  import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
18
- import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
25
+ import { jsonParse } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
26
+ import {
27
+ type ImportedResourceMap,
28
+ type SnippetPluginConfig,
29
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
30
+
31
+ export function createSnippet({
32
+ controller,
33
+ content,
34
+ title,
35
+ snippetListIds,
36
+ importedResources,
37
+ }: {
38
+ controller: SayController;
39
+ content: string;
40
+ title: string;
41
+ snippetListIds: string[];
42
+ importedResources: ImportedResourceMap;
43
+ }) {
44
+ // Replace instances of linked to uris with the resources that exist in the outer document.
45
+ let replacedContent = content;
46
+ for (const imported in importedResources) {
47
+ const linked = importedResources[imported];
48
+ if (linked) {
49
+ replacedContent = replacedContent.replaceAll(imported, linked);
50
+ }
51
+ }
52
+ const parser = ProseParser.fromSchema(controller.schema);
53
+
54
+ return controller.schema.node(
55
+ 'snippet',
56
+ {
57
+ assignedSnippetListsIds: snippetListIds,
58
+ title,
59
+ subject: `http://data.lblod.info/snippets/${uuidv4()}`,
60
+ importedResources,
61
+ },
62
+ htmlToDoc(replacedContent, {
63
+ schema: controller.schema,
64
+ parser,
65
+ editorView: controller.mainEditorView,
66
+ }).content,
67
+ );
68
+ }
19
69
 
20
70
  const emberNodeConfig = (options: SnippetPluginConfig): EmberNodeConfig => ({
21
71
  name: 'snippet',
@@ -37,6 +87,7 @@ const emberNodeConfig = (options: SnippetPluginConfig): EmberNodeConfig => ({
37
87
  },
38
88
  rdfaNodeType: { default: 'resource' },
39
89
  assignedSnippetListsIds: { default: [] },
90
+ importedResources: { default: {} },
40
91
  title: { default: '' },
41
92
  config: { default: options },
42
93
  },
@@ -51,6 +102,7 @@ const emberNodeConfig = (options: SnippetPluginConfig): EmberNodeConfig => ({
51
102
  'data-assigned-snippet-ids': (
52
103
  node.attrs.assignedSnippetListsIds as string[]
53
104
  ).join(','),
105
+ 'data-imported-resources': JSON.stringify(node.attrs.importedResources),
54
106
  'data-snippet-title': node.attrs.title,
55
107
  },
56
108
  content: 0,
@@ -70,6 +122,9 @@ const emberNodeConfig = (options: SnippetPluginConfig): EmberNodeConfig => ({
70
122
  assignedSnippetListsIds: node
71
123
  .getAttribute('data-assigned-snippet-ids')
72
124
  ?.split(','),
125
+ importedResources: jsonParse(
126
+ node.getAttribute('data-imported-resources'),
127
+ ),
73
128
  title: node.getAttribute('data-snippet-title'),
74
129
  };
75
130
  }
@@ -0,0 +1,22 @@
1
+ import { IMPORTED_RESOURCES_ATTR } from '@lblod/ember-rdfa-editor/plugins/imported-resources';
2
+ import { jsonParse } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
3
+ import { type Snippet } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
4
+
5
+ export function collateImportedResources(snippets: Snippet[]): string[] {
6
+ const domParser = new DOMParser();
7
+ return [
8
+ ...new Set(
9
+ snippets.flatMap(({ content }) => {
10
+ const htmlNode =
11
+ content && domParser.parseFromString(content.toString(), 'text/html');
12
+ const imports = jsonParse(
13
+ htmlNode
14
+ ?.querySelector('[data-say-document]')
15
+ ?.getAttribute(IMPORTED_RESOURCES_ATTR),
16
+ );
17
+
18
+ return Array.isArray(imports) ? (imports as string[]) : [];
19
+ }),
20
+ ).values(),
21
+ ];
22
+ }
@@ -142,10 +142,11 @@ const buildSnippetListFetchQuery = ({
142
142
  PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
143
143
  PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
144
144
 
145
- SELECT (?snippetLists as ?id) ?label ?createdOn WHERE {
145
+ SELECT (?snippetLists as ?id) ?label ?createdOn ?importedResources WHERE {
146
146
  ?snippetLists a ext:SnippetList;
147
147
  skos:prefLabel ?label;
148
148
  pav:createdOn ?createdOn.
149
+ OPTIONAL { ?snippetLists ext:SnippetImportedResource ?importedResources . }
149
150
  ${
150
151
  name
151
152
  ? `FILTER (CONTAINS(LCASE(?label), "${name.toLowerCase()}"))`
@@ -228,6 +229,7 @@ export const fetchSnippetLists = async ({
228
229
  id: { value: string };
229
230
  label: { value: string };
230
231
  createdOn: { value: string };
232
+ importedResources: { value: string[] };
231
233
  }>({
232
234
  endpoint,
233
235
  query: buildSnippetListFetchQuery({ filter, orderBy }),
@@ -240,6 +242,7 @@ export const fetchSnippetLists = async ({
240
242
  id: binding.id?.value,
241
243
  label: binding.label?.value,
242
244
  createdOn: binding.createdOn?.value,
245
+ importedResources: binding.importedResources?.value || [],
243
246
  }),
244
247
  );
245
248
 
@@ -11,23 +11,11 @@ export const getSnippetListIdsProperties = (node: PNode) => {
11
11
  };
12
12
 
13
13
  export const getAssignedSnippetListsIdsFromProperties = (
14
- snippetListIdsProperty: OutgoingTriple[] | undefined,
14
+ snippetListIdsProperty: OutgoingTriple[] | undefined = [],
15
15
  ) => {
16
- if (!snippetListIdsProperty) {
17
- return [];
18
- }
19
-
20
- const snippetListUris = snippetListIdsProperty
16
+ return snippetListIdsProperty
21
17
  .map((property) => property.object.value)
22
- .filter((object) => object !== undefined);
23
-
24
- if (snippetListUris.length === 0) {
25
- return [];
26
- }
27
-
28
- const snippetListIds = snippetListUris
18
+ .filter((object) => object !== undefined)
29
19
  .map(getSnippetIdFromUri)
30
20
  .filter((id) => id !== undefined);
31
-
32
- return snippetListIds;
33
21
  };
@@ -1,4 +1,5 @@
1
1
  import { warn } from '@ember/debug';
2
+ import { isNone, type Option } from './option';
2
3
 
3
4
  const STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z\u00C0-\u024F])/g;
4
5
  export function capitalize(value: string): string {
@@ -48,3 +49,15 @@ export function isNumber(value: string | number | null | undefined): boolean {
48
49
  value !== '')
49
50
  );
50
51
  }
52
+
53
+ export function jsonParse<T = unknown>(json: Option<string>): T | undefined {
54
+ if (isNone(json)) {
55
+ return undefined;
56
+ }
57
+ try {
58
+ return JSON.parse(json);
59
+ } catch (err) {
60
+ console.warn('unable to parse JSON', json, err);
61
+ return undefined;
62
+ }
63
+ }
@@ -1,9 +1,11 @@
1
- [property='eli:title']:before {
2
- content: 'Document-titel' !important;
3
- }
4
-
5
- [lang='en-US'] {
1
+ .rdfa-annotations-hover {
6
2
  [property='eli:title']:before {
7
- content: 'Document title' !important;
3
+ content: 'Document-titel' !important;
4
+ }
5
+
6
+ [lang='en-US'] {
7
+ [property='eli:title']:before {
8
+ content: 'Document title' !important;
9
+ }
8
10
  }
9
11
  }
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
2
2
  import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
3
3
  interface Args {
4
4
  config: SnippetPluginConfig;
5
- assignedSnippetListsIds: string[];
5
+ assignedSnippetListsIds: string[] | undefined;
6
6
  closeModal: () => void;
7
7
  open: boolean;
8
8
  onInsert: (content: string, title: string) => void;
@@ -1,6 +1,6 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { type NodeType, type SayController } from '@lblod/ember-rdfa-editor';
3
- import { type SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
3
+ import { type SnippetPluginConfig, type SnippetList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
4
4
  interface Signature {
5
5
  Args: {
6
6
  controller: SayController;
@@ -12,6 +12,6 @@ export default class SnippetPluginSnippetInsertPlaceholder extends Component<Sig
12
12
  get placeholderNode(): NodeType | undefined;
13
13
  openModal(): void;
14
14
  closeModal(): void;
15
- insertPlaceholder(listIds: string[], listNames: string[]): void;
15
+ insertPlaceholder(lists: SnippetList[] | undefined): void;
16
16
  }
17
17
  export {};
@@ -1,19 +1,19 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { SayController } from '@lblod/ember-rdfa-editor';
3
- import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
4
- import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
3
+ import { type ImportedResourceMap, type SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
5
4
  import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
6
- interface Args {
7
- controller: SayController;
8
- config: SnippetPluginConfig;
9
- node: ResolvedPNode;
5
+ interface Sig {
6
+ Args: {
7
+ controller: SayController;
8
+ config: SnippetPluginConfig;
9
+ node: ResolvedPNode;
10
+ };
10
11
  }
11
- export default class SnippetInsertRdfaComponent extends Component<Args> {
12
- get controller(): SayController;
13
- get config(): SnippetPluginConfig;
14
- get node(): ResolvedPNode;
15
- get showInsert(): boolean;
16
- get snippetListIdsProperty(): OutgoingTriple[] | undefined;
17
- get assignedSnippetListsIds(): string[];
12
+ export default class SnippetInsertRdfaComponent extends Component<Sig> {
13
+ get disableInsert(): boolean;
14
+ get snippetListProperties(): {
15
+ listIds: string[];
16
+ importedResources: ImportedResourceMap;
17
+ } | undefined;
18
18
  }
19
19
  export {};
@@ -1,17 +1,21 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { SayController, Slice } from '@lblod/ember-rdfa-editor';
3
3
  import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
4
- interface Args {
5
- controller: SayController;
6
- config: SnippetPluginConfig;
7
- assignedSnippetListsIds: string[];
8
- disabled?: boolean;
4
+ import { type ImportedResourceMap } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
5
+ interface Sig {
6
+ Args: {
7
+ controller: SayController;
8
+ config: SnippetPluginConfig;
9
+ snippetListProperties: {
10
+ listIds: string[];
11
+ importedResources: ImportedResourceMap;
12
+ } | undefined;
13
+ disabled?: boolean;
14
+ };
9
15
  }
10
- export default class SnippetInsertComponent extends Component<Args> {
11
- AddIcon: TOC<import("@appuniversum/ember-appuniversum/components/icons/add").AddIconSignature>;
16
+ export default class SnippetInsertComponent extends Component<Sig> {
12
17
  showModal: boolean;
13
18
  get controller(): SayController;
14
- get config(): SnippetPluginConfig;
15
19
  openModal(): void;
16
20
  closeModal(): void;
17
21
  createSliceFromElement(element: Element): Slice;
@@ -4,8 +4,8 @@ import { SnippetPluginConfig, SnippetList } from '@lblod/ember-rdfa-editor-lblod
4
4
  interface Signature {
5
5
  Args: {
6
6
  config: SnippetPluginConfig;
7
- onSaveSnippetListIds: (listIds: string[], listNames: string[]) => void;
8
- assignedSnippetListsIds: string[];
7
+ onSaveSnippetLists: (lists: SnippetList[]) => void;
8
+ assignedSnippetListsIds: string[] | undefined;
9
9
  closeModal: () => void;
10
10
  open: boolean;
11
11
  };
@@ -1,21 +1,17 @@
1
- import Component from '@glimmer/component';
2
- import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
3
- import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
1
+ /// <reference types=".pnpm/ember-source@4.12.0_@babel+core@7.24.7_@glimmer+component@1.1.2_@babel+core@7.24.7__@glint+template@1.4.0_webpack@5.92.1/node_modules/ember-source/types/stable/@ember/component/template-only" />
2
+ /// <reference types="@glint/environment-ember-loose/-private/dsl/integration-declarations" />
3
+ import { TemplateOnlyComponent } from '@ember/component/template-only';
4
4
  import { SayController } from '@lblod/ember-rdfa-editor';
5
- import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
6
- interface Args {
7
- controller: SayController;
8
- config: SnippetPluginConfig;
9
- node: ResolvedPNode;
5
+ import { type ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
6
+ import { type SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
7
+ interface Sig {
8
+ Args: {
9
+ controller: SayController;
10
+ config: SnippetPluginConfig;
11
+ node: ResolvedPNode;
12
+ };
10
13
  }
11
- export default class SnippetListSelectRdfaComponent extends Component<Args> {
12
- get config(): SnippetPluginConfig;
13
- get controller(): SayController;
14
- get node(): ResolvedPNode;
15
- get currentResource(): string | undefined;
16
- get isResourceNode(): boolean;
17
- get snippetListIdsProperties(): OutgoingTriple[];
18
- get assignedSnippetListsIds(): string[];
19
- saveChanges: (snippetIds: string[], snippetNames: string[]) => void;
20
- }
21
- export {};
14
+ /** @deprecated Use snippet-list-select directly */
15
+ declare const SnippetListSelectRdfaComponent: TemplateOnlyComponent<Sig>;
16
+ /** @deprecated Use snippet-list-select directly */
17
+ export default SnippetListSelectRdfaComponent;
@@ -1,16 +1,24 @@
1
1
  import Component from '@glimmer/component';
2
- import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
2
+ import { type SayController } from '@lblod/ember-rdfa-editor';
3
+ import { type ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
4
+ import { type OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
5
+ import { type ImportedResourceMap, type SnippetPluginConfig, type SnippetList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
3
6
  interface Signature {
4
7
  Args: {
8
+ controller: SayController;
5
9
  config: SnippetPluginConfig;
6
- assignedSnippetListsIds: string[];
7
- onSaveSnippetListIds: (listIds: string[]) => void;
10
+ node: ResolvedPNode;
8
11
  };
9
12
  }
10
- export default class SnippetListSelectComponent extends Component<Signature> {
11
- UnorderedListIcon: TOC<import("@appuniversum/ember-appuniversum/components/icons/unordered-list").UnorderedListIconSignature>;
13
+ export default class SnippetListSelect extends Component<Signature> {
12
14
  showModal: boolean;
13
15
  openModal(): void;
14
16
  closeModal(): void;
17
+ get currentResource(): string | undefined;
18
+ get isResourceNode(): boolean;
19
+ get snippetListIdsProperties(): OutgoingTriple[];
20
+ get assignedSnippetListsIds(): string[];
21
+ get imported(): ImportedResourceMap;
22
+ onSaveSnippetLists(lists: SnippetList[]): void;
15
23
  }
16
24
  export {};
@@ -1 +1 @@
1
- export { default as updateSnippetPlaceholder } from './update-snippet-ids';
1
+ export { updateSnippetPlaceholder } from './update-snippet-placeholder';
@@ -0,0 +1,11 @@
1
+ import { Command } from '@lblod/ember-rdfa-editor';
2
+ import { type OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
3
+ import { type ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
4
+ import { type ImportedResourceMap, type SnippetList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
5
+ export declare const updateSnippetPlaceholder: ({ resource, oldSnippetProperties, newSnippetLists, oldImportedResources, node, }: {
6
+ resource: string;
7
+ oldSnippetProperties: OutgoingTriple[];
8
+ newSnippetLists: SnippetList[];
9
+ oldImportedResources: ImportedResourceMap;
10
+ node: ResolvedPNode;
11
+ }) => Command;
@@ -1,3 +1,4 @@
1
+ import { type Option } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
1
2
  import { SafeString } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/types';
2
3
  export type SnippetPluginConfig = {
3
4
  endpoint: string;
@@ -13,17 +14,20 @@ export declare class Snippet {
13
14
  title: string | null;
14
15
  constructor({ title, createdOn, content }: SnippetArgs);
15
16
  }
17
+ export type ImportedResourceMap = Record<string, Option<string>>;
16
18
  interface SnippetListArgs {
17
- id: string | null;
18
- label: string | null;
19
- createdOn: string | null;
19
+ id: string;
20
+ label: string;
21
+ createdOn: string;
22
+ importedResources: string[];
20
23
  }
21
24
  export declare const getSnippetUriFromId: (id: string) => string;
22
25
  export declare const getSnippetIdFromUri: (uri: string) => string;
23
26
  export declare class SnippetList {
24
- id: string | null;
25
- label: string | null;
27
+ id: string;
28
+ label: string;
26
29
  createdOn: string | null;
27
- constructor({ id, label, createdOn }: SnippetListArgs);
30
+ importedResources: string[];
31
+ constructor({ id, label, createdOn, importedResources }: SnippetListArgs);
28
32
  }
29
33
  export {};
@@ -1,4 +1,8 @@
1
1
  import { type Schema } from '@lblod/ember-rdfa-editor';
2
- export declare function createSnippetPlaceholder(listIds: string[], listNames: string[], schema: Schema): import("prosemirror-model").Node;
2
+ import { type ImportedResourceMap, type SnippetList } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
3
+ export declare function importedResourcesFromSnippetLists(lists: SnippetList[], existing?: ImportedResourceMap): {
4
+ [k: string]: import("../../../utils/option").Option<string>;
5
+ };
6
+ export declare function createSnippetPlaceholder(lists: SnippetList[], schema: Schema): import("prosemirror-model").Node;
3
7
  export declare const snippetPlaceholder: import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
4
8
  export declare const snippetPlaceholderView: (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor/utils/ember-node").SayNodeViewConstructor;
@@ -1,3 +1,11 @@
1
- import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
1
+ import { type SayController } from '@lblod/ember-rdfa-editor';
2
+ import { type ImportedResourceMap, type SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
3
+ export declare function createSnippet({ controller, content, title, snippetListIds, importedResources, }: {
4
+ controller: SayController;
5
+ content: string;
6
+ title: string;
7
+ snippetListIds: string[];
8
+ importedResources: ImportedResourceMap;
9
+ }): import("prosemirror-model").Node;
2
10
  export declare const snippet: (config: SnippetPluginConfig) => import("@lblod/ember-rdfa-editor/core/say-node-spec").default;
3
- export declare const snippetView: (config: SnippetPluginConfig) => (controller: import("@lblod/ember-rdfa-editor").SayController) => import("@lblod/ember-rdfa-editor/utils/ember-node").SayNodeViewConstructor;
11
+ export declare const snippetView: (config: SnippetPluginConfig) => (controller: SayController) => import("@lblod/ember-rdfa-editor/utils/ember-node").SayNodeViewConstructor;
@@ -0,0 +1,2 @@
1
+ import { type Snippet } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
2
+ export declare function collateImportedResources(snippets: Snippet[]): string[];
@@ -2,4 +2,4 @@ import { PNode } from '@lblod/ember-rdfa-editor';
2
2
  import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
3
3
  export declare const SNIPPET_LIST_RDFA_PREDICATE: import("@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace").Resource;
4
4
  export declare const getSnippetListIdsProperties: (node: PNode) => OutgoingTriple[];
5
- export declare const getAssignedSnippetListsIdsFromProperties: (snippetListIdsProperty: OutgoingTriple[] | undefined) => string[];
5
+ export declare const getAssignedSnippetListsIdsFromProperties: (snippetListIdsProperty?: OutgoingTriple[] | undefined) => string[];
@@ -1,4 +1,6 @@
1
+ import { type Option } from './option';
1
2
  export declare function capitalize(value: string): string;
2
3
  export declare function escapeValue(value?: string): string | null;
3
4
  export declare function dateValue(value?: string): string | null;
4
5
  export declare function isNumber(value: string | number | null | undefined): boolean;
6
+ export declare function jsonParse<T = unknown>(json: Option<string>): T | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "22.2.0",
3
+ "version": "22.2.1-dev.7a3a7c0f54fef43445cfab79cb69ee4e9615cc8e",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -102,7 +102,7 @@
102
102
  "@glint/template": "^1.4.0",
103
103
  "@graphy/content.ttl.write": "^4.3.7",
104
104
  "@graphy/memory.dataset.fast": "4.3.3",
105
- "@lblod/ember-rdfa-editor": "10.0.2",
105
+ "@lblod/ember-rdfa-editor": "10.1.0-dev.de48fb9f9ce504aea28da86b465bb5bf05816d96",
106
106
  "@rdfjs/types": "^1.1.0",
107
107
  "@release-it/keep-a-changelog": "^4.0.0",
108
108
  "@tsconfig/ember": "^3.0.8",
@@ -189,7 +189,7 @@
189
189
  "@appuniversum/ember-appuniversum": "^3.4.1",
190
190
  "@ember/string": "3.x",
191
191
  "@glint/template": "^1.4.0",
192
- "@lblod/ember-rdfa-editor": "^10.0.0",
192
+ "@lblod/ember-rdfa-editor": "10.1.0-dev.de48fb9f9ce504aea28da86b465bb5bf05816d96",
193
193
  "ember-concurrency": "^3.1.0",
194
194
  "ember-element-helper": "^0.8.6",
195
195
  "ember-intl": "^7.0.0",