@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.
- package/CHANGELOG.md +18 -0
- package/addon/components/auto-resizing-text-area.gts +43 -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/mandatee-table-plugin/configure.gts +4 -4
- package/addon/components/mandatee-table-plugin/node.gts +1 -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/mandatee-table-plugin/node.ts +5 -1
- 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/app/styles/mandatee-table-plugin.scss +5 -0
- package/declarations/addon/components/auto-resizing-text-area.d.ts +22 -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,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,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;
|