@lblod/ember-rdfa-editor-lblod-plugins 22.2.2 → 22.2.3-dev.6158a7f5516c120c221e32297e3d30171a299f9f
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/CHANGELOG.md +6 -0
- package/addon/components/mandatee-table-plugin/insert.gts +0 -10
- package/addon/components/snippet-plugin/nodes/snippet.gts +12 -21
- 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 +110 -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/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 +57 -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/mandatee-table-plugin/insert.d.ts +0 -2
- 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 +12 -8
- 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 +10 -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 +26 -25
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 22.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#469](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/469) [`52c22d6`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/52c22d6042a5c8e7bc88094625c3b1136d1dcdc9) Thanks [@elpoelma](https://github.com/elpoelma)! - Remove constraint on mandatee table insertion. Mandatee table can now be inserted everywhere in a document.
|
|
8
|
+
|
|
3
9
|
## 22.2.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -3,8 +3,6 @@ import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
|
|
|
3
3
|
import { on } from '@ember/modifier';
|
|
4
4
|
import Component from '@glimmer/component';
|
|
5
5
|
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
6
|
-
import { not } from 'ember-truth-helpers';
|
|
7
|
-
import { getCurrentBesluitRange } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-topic-plugin/utils/helpers';
|
|
8
6
|
import { action } from '@ember/object';
|
|
9
7
|
import { unwrap } from '@lblod/ember-rdfa-editor/utils/_private/option';
|
|
10
8
|
import t from 'ember-intl/helpers/t';
|
|
@@ -17,9 +15,6 @@ export default class InsertMandateeTableComponent extends Component<Sig> {
|
|
|
17
15
|
get controller() {
|
|
18
16
|
return this.args.controller;
|
|
19
17
|
}
|
|
20
|
-
get decisionRange() {
|
|
21
|
-
return getCurrentBesluitRange(this.controller);
|
|
22
|
-
}
|
|
23
18
|
|
|
24
19
|
@action
|
|
25
20
|
insert() {
|
|
@@ -33,10 +28,6 @@ export default class InsertMandateeTableComponent extends Component<Sig> {
|
|
|
33
28
|
});
|
|
34
29
|
}
|
|
35
30
|
|
|
36
|
-
get canInsert() {
|
|
37
|
-
return Boolean(this.decisionRange);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
31
|
<template>
|
|
41
32
|
<li class='au-c-list__item'>
|
|
42
33
|
<AuButton
|
|
@@ -44,7 +35,6 @@ export default class InsertMandateeTableComponent extends Component<Sig> {
|
|
|
44
35
|
@icon={{AddIcon}}
|
|
45
36
|
@iconAlignment='left'
|
|
46
37
|
@skin='link'
|
|
47
|
-
@disabled={{not this.canInsert}}
|
|
48
38
|
>
|
|
49
39
|
{{t 'mandatee-table-plugin.insert.title'}}
|
|
50
40
|
</AuButton>
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { on } from '@ember/modifier';
|
|
3
|
-
import AuIcon from '@appuniversum/ember-appuniversum/components/au-icon';
|
|
4
|
-
import { type EmberNodeArgs } from '@lblod/ember-rdfa-editor/utils/_private/ember-node';
|
|
5
3
|
import SearchModal from '../search-modal';
|
|
6
4
|
import { tracked } from '@glimmer/tracking';
|
|
7
5
|
import { action } from '@ember/object';
|
|
6
|
+
import t from 'ember-intl/helpers/t';
|
|
7
|
+
import AuIcon from '@appuniversum/ember-appuniversum/components/au-icon';
|
|
8
8
|
import { SynchronizeIcon } from '@appuniversum/ember-appuniversum/components/icons/synchronize';
|
|
9
9
|
import { BinIcon } from '@appuniversum/ember-appuniversum/components/icons/bin';
|
|
10
10
|
import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
|
|
11
|
+
import { type EmberNodeArgs } from '@lblod/ember-rdfa-editor/utils/_private/ember-node';
|
|
11
12
|
import {
|
|
12
13
|
PNode,
|
|
13
14
|
ProseParser,
|
|
@@ -15,15 +16,13 @@ import {
|
|
|
15
16
|
Slice,
|
|
16
17
|
Transaction,
|
|
17
18
|
} from '@lblod/ember-rdfa-editor';
|
|
18
|
-
import {
|
|
19
|
+
import { findAncestors } from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
19
20
|
import {
|
|
20
21
|
EXT,
|
|
21
22
|
RDF,
|
|
22
23
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
23
|
-
import { findAncestors } from '@lblod/ember-rdfa-editor/utils/position-utils';
|
|
24
24
|
import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
25
|
-
import {
|
|
26
|
-
import t from 'ember-intl/helpers/t';
|
|
25
|
+
import { createSnippet } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/nodes/snippet';
|
|
27
26
|
|
|
28
27
|
interface Signature {
|
|
29
28
|
Args: EmberNodeArgs;
|
|
@@ -91,7 +90,6 @@ export default class SnippetNode extends Component<Signature> {
|
|
|
91
90
|
}
|
|
92
91
|
@action
|
|
93
92
|
onInsert(content: string, title: string) {
|
|
94
|
-
const assignedSnippetListsIds = this.node.attrs.assignedSnippetListsIds;
|
|
95
93
|
let rangeStart = 0;
|
|
96
94
|
let rangeEnd = 0;
|
|
97
95
|
if (this.args.getPos() === undefined) return;
|
|
@@ -110,26 +108,19 @@ export default class SnippetNode extends Component<Signature> {
|
|
|
110
108
|
const documentDiv = parsed.querySelector('div[data-say-document="true"]');
|
|
111
109
|
|
|
112
110
|
this.closeModal();
|
|
113
|
-
const parser = ProseParser.fromSchema(this.controller.schema);
|
|
114
111
|
|
|
115
112
|
if (documentDiv) {
|
|
116
113
|
return this.controller.withTransaction((tr: Transaction) => {
|
|
117
114
|
return tr.replaceRangeWith(
|
|
118
115
|
rangeStart,
|
|
119
116
|
rangeEnd,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
htmlToDoc(content, {
|
|
128
|
-
schema: this.controller.schema,
|
|
129
|
-
parser,
|
|
130
|
-
editorView: this.controller.mainEditorView,
|
|
131
|
-
}).content,
|
|
132
|
-
),
|
|
117
|
+
createSnippet({
|
|
118
|
+
controller: this.controller,
|
|
119
|
+
content,
|
|
120
|
+
title,
|
|
121
|
+
snippetListIds: this.node.attrs.assignedSnippetListsIds,
|
|
122
|
+
importedResources: this.node.attrs.importedResources,
|
|
123
|
+
}),
|
|
133
124
|
);
|
|
134
125
|
});
|
|
135
126
|
}
|
|
@@ -11,7 +11,7 @@ import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plug
|
|
|
11
11
|
|
|
12
12
|
interface Args {
|
|
13
13
|
config: SnippetPluginConfig;
|
|
14
|
-
assignedSnippetListsIds: string[];
|
|
14
|
+
assignedSnippetListsIds: string[] | undefined;
|
|
15
15
|
closeModal: () => void;
|
|
16
16
|
open: boolean;
|
|
17
17
|
onInsert: (content: string, title: string) => void;
|
|
@@ -7,7 +7,10 @@ import not from 'ember-truth-helpers/helpers/not';
|
|
|
7
7
|
import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
|
|
8
8
|
import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
|
|
9
9
|
import { type NodeType, type SayController } from '@lblod/ember-rdfa-editor';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
type SnippetPluginConfig,
|
|
12
|
+
type SnippetList,
|
|
13
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
11
14
|
import { createSnippetPlaceholder } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/nodes/snippet-placeholder';
|
|
12
15
|
import SnippetListModal from '@lblod/ember-rdfa-editor-lblod-plugins/components/snippet-plugin/snippet-list/snippet-list-modal';
|
|
13
16
|
|
|
@@ -35,19 +38,17 @@ export default class SnippetPluginSnippetInsertPlaceholder extends Component<Sig
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
@action
|
|
38
|
-
insertPlaceholder(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
listNames,
|
|
42
|
-
this.args.controller.schema,
|
|
43
|
-
);
|
|
41
|
+
insertPlaceholder(lists: SnippetList[] | undefined) {
|
|
42
|
+
if (lists) {
|
|
43
|
+
const node = createSnippetPlaceholder(lists, this.args.controller.schema);
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
this.args.controller.withTransaction(
|
|
46
|
+
(tr) => {
|
|
47
|
+
return tr.replaceSelectionWith(node);
|
|
48
|
+
},
|
|
49
|
+
{ view: this.args.controller.mainEditorView },
|
|
50
|
+
);
|
|
51
|
+
}
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
<template>
|
|
@@ -65,7 +66,7 @@ export default class SnippetPluginSnippetInsertPlaceholder extends Component<Sig
|
|
|
65
66
|
<SnippetListModal
|
|
66
67
|
@config={{@config}}
|
|
67
68
|
@assignedSnippetListsIds={{empty}}
|
|
68
|
-
@
|
|
69
|
+
@onSaveSnippetLists={{this.insertPlaceholder}}
|
|
69
70
|
@open={{this.isModalOpen}}
|
|
70
71
|
@closeModal={{this.closeModal}}
|
|
71
72
|
/>
|
|
@@ -0,0 +1,82 @@
|
|
|
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 {
|
|
6
|
+
type ImportedResourceMap,
|
|
7
|
+
type SnippetPluginConfig,
|
|
8
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
9
|
+
import { findParentNodeClosestToPos } from '@curvenote/prosemirror-utils';
|
|
10
|
+
import {
|
|
11
|
+
getAssignedSnippetListsIdsFromProperties,
|
|
12
|
+
getSnippetListIdsProperties,
|
|
13
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
|
|
14
|
+
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
15
|
+
import SnippetInsert from './snippet-insert';
|
|
16
|
+
|
|
17
|
+
interface Sig {
|
|
18
|
+
Args: {
|
|
19
|
+
controller: SayController;
|
|
20
|
+
config: SnippetPluginConfig;
|
|
21
|
+
node: ResolvedPNode;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default class SnippetInsertRdfaComponent extends Component<Sig> {
|
|
26
|
+
get disableInsert() {
|
|
27
|
+
return (this.snippetListProperties?.listIds.length ?? 0) === 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get snippetListProperties():
|
|
31
|
+
| { listIds: string[]; importedResources: ImportedResourceMap }
|
|
32
|
+
| undefined {
|
|
33
|
+
const activeNode = this.args.node.value;
|
|
34
|
+
const activeNodeSnippetListIds = getSnippetListIdsProperties(activeNode);
|
|
35
|
+
|
|
36
|
+
if (activeNodeSnippetListIds.length > 0) {
|
|
37
|
+
return {
|
|
38
|
+
listIds: getAssignedSnippetListsIdsFromProperties(
|
|
39
|
+
activeNodeSnippetListIds,
|
|
40
|
+
),
|
|
41
|
+
importedResources: activeNode.attrs.importedResources,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (this.args.node.pos < 0) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// If active node isn't a snippet list, go up until we find one
|
|
50
|
+
const doc = this.args.controller.mainEditorState.doc;
|
|
51
|
+
const pos = doc.resolve(this.args.node.pos);
|
|
52
|
+
let parentNode = findParentNodeClosestToPos(pos, (node) =>
|
|
53
|
+
isResourceNode(node),
|
|
54
|
+
);
|
|
55
|
+
while (parentNode) {
|
|
56
|
+
const properties = getSnippetListIdsProperties(parentNode.node);
|
|
57
|
+
|
|
58
|
+
if (properties.length > 0) {
|
|
59
|
+
return {
|
|
60
|
+
listIds: getAssignedSnippetListsIdsFromProperties(properties),
|
|
61
|
+
importedResources: parentNode.node.attrs.importedResources,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
parentNode = findParentNodeClosestToPos(
|
|
66
|
+
doc.resolve(parentNode.pos),
|
|
67
|
+
(node) => isResourceNode(node),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<SnippetInsert
|
|
76
|
+
@config={{@config}}
|
|
77
|
+
@controller={{@controller}}
|
|
78
|
+
@snippetListProperties={{this.snippetListProperties}}
|
|
79
|
+
@disabled={{this.disableInsert}}
|
|
80
|
+
/>
|
|
81
|
+
</template>
|
|
82
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
import { on } from '@ember/modifier';
|
|
3
|
+
import Component from '@glimmer/component';
|
|
4
|
+
import { tracked } from '@glimmer/tracking';
|
|
5
|
+
import t from 'ember-intl/helpers/t';
|
|
6
|
+
import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
|
|
7
|
+
import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
|
|
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 { createSnippet } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/nodes/snippet';
|
|
16
|
+
import { type ImportedResourceMap } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
17
|
+
import SearchModal from './search-modal';
|
|
18
|
+
|
|
19
|
+
interface Sig {
|
|
20
|
+
Args: {
|
|
21
|
+
controller: SayController;
|
|
22
|
+
config: SnippetPluginConfig;
|
|
23
|
+
snippetListProperties:
|
|
24
|
+
| { listIds: string[]; importedResources: ImportedResourceMap }
|
|
25
|
+
| undefined;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default class SnippetInsertComponent extends Component<Sig> {
|
|
31
|
+
@tracked showModal = false;
|
|
32
|
+
|
|
33
|
+
get controller() {
|
|
34
|
+
return this.args.controller;
|
|
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 assignedSnippetListProperties = this.args.snippetListProperties;
|
|
66
|
+
|
|
67
|
+
if (documentDiv && assignedSnippetListProperties) {
|
|
68
|
+
return this.controller.withTransaction((tr: Transaction) =>
|
|
69
|
+
tr.replaceSelectionWith(
|
|
70
|
+
createSnippet({
|
|
71
|
+
controller: this.controller,
|
|
72
|
+
content,
|
|
73
|
+
title,
|
|
74
|
+
snippetListIds: assignedSnippetListProperties.listIds,
|
|
75
|
+
importedResources: assignedSnippetListProperties.importedResources,
|
|
76
|
+
}),
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
this.controller.withTransaction((tr) =>
|
|
81
|
+
tr.replaceSelection(this.createSliceFromElement(parsed)),
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get disabled() {
|
|
86
|
+
return this.args.disabled ?? false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
<template>
|
|
90
|
+
<li class='au-c-list__item'>
|
|
91
|
+
<AuButton
|
|
92
|
+
@icon={{AddIcon}}
|
|
93
|
+
@iconAlignment='left'
|
|
94
|
+
@skin='link'
|
|
95
|
+
@disabled={{this.disabled}}
|
|
96
|
+
{{on 'click' this.openModal}}
|
|
97
|
+
>
|
|
98
|
+
{{t 'snippet-plugin.insert.title'}}
|
|
99
|
+
</AuButton>
|
|
100
|
+
</li>
|
|
101
|
+
|
|
102
|
+
<SearchModal
|
|
103
|
+
@open={{this.showModal}}
|
|
104
|
+
@closeModal={{this.closeModal}}
|
|
105
|
+
@config={{@config}}
|
|
106
|
+
@onInsert={{this.onInsert}}
|
|
107
|
+
@assignedSnippetListsIds={{@snippetListProperties.listIds}}
|
|
108
|
+
/>
|
|
109
|
+
</template>
|
|
110
|
+
}
|
|
@@ -19,8 +19,8 @@ import { trackedReset } from 'tracked-toolbox';
|
|
|
19
19
|
interface Signature {
|
|
20
20
|
Args: {
|
|
21
21
|
config: SnippetPluginConfig;
|
|
22
|
-
|
|
23
|
-
assignedSnippetListsIds: string[];
|
|
22
|
+
onSaveSnippetLists: (lists: SnippetList[]) => void;
|
|
23
|
+
assignedSnippetListsIds: string[] | undefined;
|
|
24
24
|
closeModal: () => void;
|
|
25
25
|
open: boolean;
|
|
26
26
|
};
|
|
@@ -37,7 +37,9 @@ export default class SnippetListModalComponent extends Component<Signature> {
|
|
|
37
37
|
@tracked error: unknown;
|
|
38
38
|
|
|
39
39
|
@trackedReset('args.assignedSnippetListsIds')
|
|
40
|
-
assignedSnippetListsIds: string[] = [
|
|
40
|
+
assignedSnippetListsIds: string[] = [
|
|
41
|
+
...(this.args.assignedSnippetListsIds ?? []),
|
|
42
|
+
];
|
|
41
43
|
|
|
42
44
|
get config() {
|
|
43
45
|
return this.args.config;
|
|
@@ -50,15 +52,10 @@ export default class SnippetListModalComponent extends Component<Signature> {
|
|
|
50
52
|
|
|
51
53
|
@action
|
|
52
54
|
saveAndClose() {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
this.assignedSnippetListsIds.includes(snippetList.id as string),
|
|
56
|
-
)
|
|
57
|
-
.map((snippetList) => snippetList.label) as string[];
|
|
58
|
-
this.args.onSaveSnippetListIds(
|
|
59
|
-
this.assignedSnippetListsIds,
|
|
60
|
-
snippetListNames,
|
|
55
|
+
const snippetLists = this.snippetListResource.value?.filter((snippetList) =>
|
|
56
|
+
this.assignedSnippetListsIds.includes(snippetList.id),
|
|
61
57
|
);
|
|
58
|
+
this.args.onSaveSnippetLists(snippetLists || []);
|
|
62
59
|
this.args.closeModal();
|
|
63
60
|
// Clear selection for next time
|
|
64
61
|
this.assignedSnippetListsIds = [];
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
(t 'snippet-plugin.snippet-list.modal.table.select')
|
|
7
7
|
(t 'snippet-plugin.snippet-list.modal.subtitle')
|
|
8
8
|
(t 'snippet-plugin.snippet-list.modal.search.label')
|
|
9
|
-
|
|
9
|
+
(t 'snippet-plugin.snippet-list.modal.table.imported-resources')
|
|
10
|
+
as |list created select subtitle search imported|
|
|
10
11
|
}}
|
|
11
12
|
<AuDataTable
|
|
12
13
|
@content={{this.snippetLists}}
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
@currentSorting={{@sort}}
|
|
40
41
|
@class='data-table__header-title'
|
|
41
42
|
/>
|
|
43
|
+
<th>{{imported}}</th>
|
|
42
44
|
<AuDataTableThSortable
|
|
43
45
|
@field='createdOn'
|
|
44
46
|
@label={{created}}
|
|
@@ -55,6 +57,7 @@
|
|
|
55
57
|
/>
|
|
56
58
|
</td>
|
|
57
59
|
<td>{{row.label}}</td>
|
|
60
|
+
<td>{{row.importedResources}}</td>
|
|
58
61
|
<td class='snippet-list-table-created-column'>{{row.createdOn}}</td>
|
|
59
62
|
</c.body>
|
|
60
63
|
</t.content>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TemplateOnlyComponent } from '@ember/component/template-only';
|
|
2
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
3
|
+
import { type ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
4
|
+
import { type SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
5
|
+
import SnippetListSelect from '@lblod/ember-rdfa-editor-lblod-plugins/components/snippet-plugin/snippet-list-select';
|
|
6
|
+
|
|
7
|
+
interface Sig {
|
|
8
|
+
Args: {
|
|
9
|
+
controller: SayController;
|
|
10
|
+
config: SnippetPluginConfig;
|
|
11
|
+
node: ResolvedPNode;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** @deprecated Use snippet-list-select directly */
|
|
16
|
+
const SnippetListSelectRdfaComponent: TemplateOnlyComponent<Sig> = <template>
|
|
17
|
+
<SnippetListSelect
|
|
18
|
+
@controller={{@controller}}
|
|
19
|
+
@config={{@config}}
|
|
20
|
+
@node={{@node}}
|
|
21
|
+
/>
|
|
22
|
+
</template>;
|
|
23
|
+
|
|
24
|
+
/** @deprecated Use snippet-list-select directly */
|
|
25
|
+
export default SnippetListSelectRdfaComponent;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
import Component from '@glimmer/component';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
import { on } from '@ember/modifier';
|
|
5
|
+
import t from 'ember-intl/helpers/t';
|
|
6
|
+
import { UnorderedListIcon } from '@appuniversum/ember-appuniversum/components/icons/unordered-list';
|
|
7
|
+
import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
|
|
8
|
+
import { type SayController } from '@lblod/ember-rdfa-editor';
|
|
9
|
+
import { type ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
10
|
+
import { isResourceNode } from '@lblod/ember-rdfa-editor/utils/node-utils';
|
|
11
|
+
import { type OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
|
|
12
|
+
import SnippetListModal from '@lblod/ember-rdfa-editor-lblod-plugins/components/snippet-plugin/snippet-list/snippet-list-modal';
|
|
13
|
+
import {
|
|
14
|
+
type ImportedResourceMap,
|
|
15
|
+
type SnippetPluginConfig,
|
|
16
|
+
type SnippetList,
|
|
17
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
18
|
+
import {
|
|
19
|
+
getAssignedSnippetListsIdsFromProperties,
|
|
20
|
+
getSnippetListIdsProperties,
|
|
21
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
|
|
22
|
+
import { updateSnippetPlaceholder } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/commands';
|
|
23
|
+
|
|
24
|
+
interface Signature {
|
|
25
|
+
Args: {
|
|
26
|
+
controller: SayController;
|
|
27
|
+
config: SnippetPluginConfig;
|
|
28
|
+
node: ResolvedPNode;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default class SnippetListSelect extends Component<Signature> {
|
|
33
|
+
@tracked showModal = false;
|
|
34
|
+
|
|
35
|
+
@action
|
|
36
|
+
openModal() {
|
|
37
|
+
this.showModal = true;
|
|
38
|
+
}
|
|
39
|
+
@action
|
|
40
|
+
closeModal() {
|
|
41
|
+
this.showModal = false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get currentResource() {
|
|
45
|
+
return this.args.node.value.attrs.subject as string | undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get isResourceNode() {
|
|
49
|
+
return isResourceNode(this.args.node.value);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get snippetListIdsProperties(): OutgoingTriple[] {
|
|
53
|
+
return getSnippetListIdsProperties(this.args.node.value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get assignedSnippetListsIds(): string[] {
|
|
57
|
+
return getAssignedSnippetListsIdsFromProperties(
|
|
58
|
+
this.snippetListIdsProperties,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get imported(): ImportedResourceMap {
|
|
63
|
+
return this.args.node.value.attrs['importedResources'];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@action
|
|
67
|
+
onSaveSnippetLists(lists: SnippetList[]) {
|
|
68
|
+
if (this.currentResource) {
|
|
69
|
+
this.args.controller?.doCommand(
|
|
70
|
+
updateSnippetPlaceholder({
|
|
71
|
+
resource: this.currentResource,
|
|
72
|
+
oldSnippetProperties: this.snippetListIdsProperties ?? [],
|
|
73
|
+
newSnippetLists: lists,
|
|
74
|
+
oldImportedResources: this.imported,
|
|
75
|
+
node: this.args.node,
|
|
76
|
+
}),
|
|
77
|
+
{
|
|
78
|
+
view: this.args.controller.mainEditorView,
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
<template>
|
|
85
|
+
{{#if this.isResourceNode}}
|
|
86
|
+
<AuButton
|
|
87
|
+
@icon={{UnorderedListIcon}}
|
|
88
|
+
@skin='secondary'
|
|
89
|
+
@iconAlignment='left'
|
|
90
|
+
{{on 'click' this.openModal}}
|
|
91
|
+
>
|
|
92
|
+
{{t 'snippet-plugin.snippet-list.open-modal'}}
|
|
93
|
+
</AuButton>
|
|
94
|
+
|
|
95
|
+
<SnippetListModal
|
|
96
|
+
@config={{@config}}
|
|
97
|
+
@assignedSnippetListsIds={{this.assignedSnippetListsIds}}
|
|
98
|
+
@onSaveSnippetLists={{this.onSaveSnippetLists}}
|
|
99
|
+
@open={{this.showModal}}
|
|
100
|
+
@closeModal={{this.closeModal}}
|
|
101
|
+
/>
|
|
102
|
+
{{/if}}
|
|
103
|
+
</template>
|
|
104
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { updateSnippetPlaceholder } from './update-snippet-placeholder';
|
|
@@ -3,21 +3,26 @@ import { addProperty, removeProperty } from '@lblod/ember-rdfa-editor/commands';
|
|
|
3
3
|
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
4
4
|
import { SNIPPET_LIST_RDFA_PREDICATE } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
|
|
5
5
|
import { getSnippetUriFromId } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
6
|
-
import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
|
|
7
|
-
import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
6
|
+
import { type OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
|
|
7
|
+
import { type ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
|
|
8
|
+
import {
|
|
9
|
+
type ImportedResourceMap,
|
|
10
|
+
type SnippetList,
|
|
11
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
12
|
+
import { importedResourcesFromSnippetLists } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/nodes/snippet-placeholder';
|
|
8
13
|
|
|
9
|
-
const updateSnippetPlaceholder = ({
|
|
14
|
+
export const updateSnippetPlaceholder = ({
|
|
10
15
|
resource,
|
|
11
16
|
oldSnippetProperties,
|
|
12
|
-
|
|
17
|
+
newSnippetLists,
|
|
18
|
+
oldImportedResources,
|
|
13
19
|
node,
|
|
14
|
-
snippetNames,
|
|
15
20
|
}: {
|
|
16
21
|
resource: string;
|
|
17
22
|
oldSnippetProperties: OutgoingTriple[];
|
|
18
|
-
|
|
23
|
+
newSnippetLists: SnippetList[];
|
|
24
|
+
oldImportedResources: ImportedResourceMap;
|
|
19
25
|
node: ResolvedPNode;
|
|
20
|
-
snippetNames: string[];
|
|
21
26
|
}): Command => {
|
|
22
27
|
return (state, dispatch) => {
|
|
23
28
|
if (dispatch) {
|
|
@@ -36,14 +41,14 @@ const updateSnippetPlaceholder = ({
|
|
|
36
41
|
});
|
|
37
42
|
});
|
|
38
43
|
|
|
39
|
-
|
|
44
|
+
newSnippetLists.forEach((list) => {
|
|
40
45
|
newState = state.apply(transaction);
|
|
41
46
|
|
|
42
47
|
addProperty({
|
|
43
48
|
resource,
|
|
44
49
|
property: {
|
|
45
50
|
predicate: SNIPPET_LIST_RDFA_PREDICATE.prefixed,
|
|
46
|
-
object: sayDataFactory.namedNode(getSnippetUriFromId(
|
|
51
|
+
object: sayDataFactory.namedNode(getSnippetUriFromId(list.id)),
|
|
47
52
|
},
|
|
48
53
|
transaction,
|
|
49
54
|
})(newState, (newTransaction) => {
|
|
@@ -53,7 +58,15 @@ const updateSnippetPlaceholder = ({
|
|
|
53
58
|
transaction = transaction.setNodeAttribute(
|
|
54
59
|
node.pos,
|
|
55
60
|
'listNames',
|
|
56
|
-
|
|
61
|
+
newSnippetLists.map((list) => list.label),
|
|
62
|
+
);
|
|
63
|
+
transaction = transaction.setNodeAttribute(
|
|
64
|
+
node.pos,
|
|
65
|
+
'importedResources',
|
|
66
|
+
importedResourcesFromSnippetLists(
|
|
67
|
+
newSnippetLists,
|
|
68
|
+
oldImportedResources,
|
|
69
|
+
),
|
|
57
70
|
);
|
|
58
71
|
|
|
59
72
|
dispatch(transaction);
|
|
@@ -61,5 +74,3 @@ const updateSnippetPlaceholder = ({
|
|
|
61
74
|
return true;
|
|
62
75
|
};
|
|
63
76
|
};
|
|
64
|
-
|
|
65
|
-
export default updateSnippetPlaceholder;
|