@lblod/ember-rdfa-editor-lblod-plugins 22.4.0 → 22.4.1-dev.231e70cba3693ffca0bf8b8cfa53c06efaf0e451
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.
- package/.changeset/mighty-guests-peel.md +5 -0
- package/.changeset/yellow-tables-live.md +5 -0
- package/CHANGELOG.md +6 -0
- package/addon/components/lmb-plugin/list.hbs +1 -1
- package/addon/components/lmb-plugin/search-modal.hbs +10 -7
- package/addon/components/lmb-plugin/search-modal.ts +8 -1
- package/addon/components/snippet-plugin/nodes/snippet.gts +17 -30
- package/addon/components/snippet-plugin/search-modal.ts +1 -1
- package/addon/components/snippet-plugin/snippet-insert-placeholder.gts +15 -14
- package/addon/components/snippet-plugin/snippet-insert-rdfa.gts +82 -0
- package/addon/components/snippet-plugin/snippet-insert.gts +109 -0
- package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +1 -1
- package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +8 -11
- package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +4 -1
- package/addon/components/snippet-plugin/snippet-list-select-rdfa.gts +25 -0
- package/addon/components/snippet-plugin/snippet-list-select.gts +104 -0
- package/addon/plugins/lmb-plugin/utils/fetchMandatees.ts +7 -18
- package/addon/plugins/snippet-plugin/commands/index.ts +1 -1
- package/addon/plugins/snippet-plugin/commands/{update-snippet-ids.ts → update-snippet-placeholder.ts} +23 -12
- package/addon/plugins/snippet-plugin/index.ts +19 -11
- package/addon/plugins/snippet-plugin/nodes/snippet-placeholder.ts +27 -9
- package/addon/plugins/snippet-plugin/nodes/snippet.ts +160 -2
- package/addon/plugins/snippet-plugin/utils/collate-imported-resources.ts +22 -0
- package/addon/plugins/snippet-plugin/utils/fetch-data.ts +52 -36
- package/addon/plugins/snippet-plugin/utils/rdfa-predicate.ts +3 -15
- package/addon/utils/sparql-helpers.ts +3 -4
- package/addon/utils/strings.ts +13 -0
- package/declarations/addon/components/snippet-plugin/nodes/snippet.d.ts +1 -1
- package/declarations/addon/components/snippet-plugin/search-modal.d.ts +1 -1
- package/declarations/addon/components/snippet-plugin/snippet-insert-placeholder.d.ts +2 -2
- package/declarations/addon/components/snippet-plugin/snippet-insert-rdfa.d.ts +13 -13
- package/declarations/addon/components/snippet-plugin/snippet-insert.d.ts +13 -9
- package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +2 -2
- package/declarations/addon/components/snippet-plugin/snippet-list-select-rdfa.d.ts +15 -19
- package/declarations/addon/components/snippet-plugin/snippet-list-select.d.ts +13 -5
- package/declarations/addon/plugins/snippet-plugin/commands/index.d.ts +1 -1
- package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-placeholder.d.ts +11 -0
- package/declarations/addon/plugins/snippet-plugin/index.d.ts +12 -8
- package/declarations/addon/plugins/snippet-plugin/nodes/snippet-placeholder.d.ts +5 -1
- package/declarations/addon/plugins/snippet-plugin/nodes/snippet.d.ts +27 -2
- package/declarations/addon/plugins/snippet-plugin/utils/collate-imported-resources.d.ts +2 -0
- package/declarations/addon/plugins/snippet-plugin/utils/fetch-data.d.ts +0 -1
- package/declarations/addon/plugins/snippet-plugin/utils/rdfa-predicate.d.ts +1 -1
- package/declarations/addon/utils/sparql-helpers.d.ts +5 -3
- package/declarations/addon/utils/strings.d.ts +2 -0
- package/package.json +3 -3
- package/pnpm-lock.yaml +29 -29
- package/translations/en-US.yaml +1 -0
- package/translations/nl-BE.yaml +1 -0
- package/addon/components/snippet-plugin/snippet-insert-rdfa.hbs +0 -7
- package/addon/components/snippet-plugin/snippet-insert-rdfa.ts +0 -78
- package/addon/components/snippet-plugin/snippet-insert.hbs +0 -20
- package/addon/components/snippet-plugin/snippet-insert.ts +0 -95
- package/addon/components/snippet-plugin/snippet-list-select-rdfa.hbs +0 -8
- package/addon/components/snippet-plugin/snippet-list-select-rdfa.ts +0 -68
- package/addon/components/snippet-plugin/snippet-list-select.hbs +0 -17
- package/addon/components/snippet-plugin/snippet-list-select.ts +0 -29
- package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-ids.d.ts +0 -11
|
@@ -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,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;
|