@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.
- package/.changeset/mighty-guests-peel.md +5 -0
- package/CHANGELOG.md +8 -0
- package/README.md +16 -0
- 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-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 +17 -9
- 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 +4 -1
- package/addon/plugins/snippet-plugin/utils/rdfa-predicate.ts +3 -15
- package/addon/utils/strings.ts +13 -0
- package/app/styles/document-title-plugin.scss +8 -6
- 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 +10 -6
- 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/rdfa-predicate.d.ts +1 -1
- package/declarations/addon/utils/strings.d.ts +2 -0
- package/package.json +3 -3
- package/pnpm-lock.yaml +26 -25
- 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/pnpm-lock.yaml
CHANGED
|
@@ -160,8 +160,8 @@ importers:
|
|
|
160
160
|
specifier: 4.3.3
|
|
161
161
|
version: 4.3.3
|
|
162
162
|
'@lblod/ember-rdfa-editor':
|
|
163
|
-
specifier: 10.0.
|
|
164
|
-
version: 10.0.
|
|
163
|
+
specifier: 10.1.0-dev.de48fb9f9ce504aea28da86b465bb5bf05816d96
|
|
164
|
+
version: 10.1.0-dev.de48fb9f9ce504aea28da86b465bb5bf05816d96(2ef3gpurqxbttnmniw6grhzpuy)
|
|
165
165
|
'@rdfjs/types':
|
|
166
166
|
specifier: ^1.1.0
|
|
167
167
|
version: 1.1.0
|
|
@@ -1586,8 +1586,8 @@ packages:
|
|
|
1586
1586
|
'@jridgewell/trace-mapping@0.3.25':
|
|
1587
1587
|
resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}
|
|
1588
1588
|
|
|
1589
|
-
'@lblod/ember-rdfa-editor@10.0.
|
|
1590
|
-
resolution: {integrity: sha512-
|
|
1589
|
+
'@lblod/ember-rdfa-editor@10.1.0-dev.de48fb9f9ce504aea28da86b465bb5bf05816d96':
|
|
1590
|
+
resolution: {integrity: sha512-07y/7rAHXH75y9sGu0AzKeqg/9cr6RoF4dtw6449mjf6sNurET6PuiPUBwR4p/uNEpMNksU57XKc/5CUlUB6Zw==}
|
|
1591
1591
|
engines: {node: 16.* || 18.* || >= 20}
|
|
1592
1592
|
peerDependencies:
|
|
1593
1593
|
'@appuniversum/ember-appuniversum': ^3.4.2
|
|
@@ -3885,8 +3885,8 @@ packages:
|
|
|
3885
3885
|
resolution: {integrity: sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==}
|
|
3886
3886
|
engines: {node: '>=0.4', npm: '>=1.2'}
|
|
3887
3887
|
|
|
3888
|
-
dompurify@3.1.
|
|
3889
|
-
resolution: {integrity: sha512-
|
|
3888
|
+
dompurify@3.1.6:
|
|
3889
|
+
resolution: {integrity: sha512-cTOAhc36AalkjtBpfG6O8JimdTMWNXjiePT2xQH/ppBGi/4uIpmj8eKyIkMJErXWARyINV/sB38yf8JCLF5pbQ==}
|
|
3890
3890
|
|
|
3891
3891
|
dot-case@3.0.4:
|
|
3892
3892
|
resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==}
|
|
@@ -7265,8 +7265,8 @@ packages:
|
|
|
7265
7265
|
property-expr@2.0.6:
|
|
7266
7266
|
resolution: {integrity: sha512-SVtmxhRE/CGkn3eZY1T6pC8Nln6Fr/lu1mKSgRud0eC73whjGfoAogbn78LkD8aFL0zz3bAFerKSnOl7NlErBA==}
|
|
7267
7267
|
|
|
7268
|
-
prosemirror-commands@1.
|
|
7269
|
-
resolution: {integrity: sha512-
|
|
7268
|
+
prosemirror-commands@1.6.0:
|
|
7269
|
+
resolution: {integrity: sha512-xn1U/g36OqXn2tn5nGmvnnimAj/g1pUx2ypJJIe8WkVX83WyJVC5LTARaxZa2AtQRwntu9Jc5zXs9gL9svp/mg==}
|
|
7270
7270
|
|
|
7271
7271
|
prosemirror-dev-tools@4.1.0:
|
|
7272
7272
|
resolution: {integrity: sha512-TqMyXLiY8EUoq4f4LV+8dQVuRejwGfeOJdJWjrHNXR9ttKy3MVYBCqmiu3CDULgjv8gtLsqoZY6+ab6BZRmr1g==}
|
|
@@ -7278,8 +7278,8 @@ packages:
|
|
|
7278
7278
|
prosemirror-dropcursor@1.8.1:
|
|
7279
7279
|
resolution: {integrity: sha512-M30WJdJZLyXHi3N8vxN6Zh5O8ZBbQCz0gURTfPmTIBNQ5pxrdU7A58QkNqfa98YEjSAL1HUyyU34f6Pm5xBSGw==}
|
|
7280
7280
|
|
|
7281
|
-
prosemirror-history@1.4.
|
|
7282
|
-
resolution: {integrity: sha512-
|
|
7281
|
+
prosemirror-history@1.4.1:
|
|
7282
|
+
resolution: {integrity: sha512-2JZD8z2JviJrboD9cPuX/Sv/1ChFng+xh2tChQ2X4bB2HeK+rra/bmJ3xGntCcjhOqIzSDG6Id7e8RJ9QPXLEQ==}
|
|
7283
7283
|
|
|
7284
7284
|
prosemirror-inputrules@1.4.0:
|
|
7285
7285
|
resolution: {integrity: sha512-6ygpPRuTJ2lcOXs9JkefieMst63wVJBgHZGl5QOytN7oSZs3Co/BYbc3Yx9zm9H37Bxw8kVzCnDsihsVsL4yEg==}
|
|
@@ -7290,11 +7290,11 @@ packages:
|
|
|
7290
7290
|
prosemirror-model@1.21.3:
|
|
7291
7291
|
resolution: {integrity: sha512-nt2Xs/RNGepD9hrrkzXvtCm1mpGJoQfFSPktGa0BF/aav6XsnmVGZ9sTXNWRLupAz5SCLa3EyKlFeK7zJWROKg==}
|
|
7292
7292
|
|
|
7293
|
-
prosemirror-schema-basic@1.2.
|
|
7294
|
-
resolution: {integrity: sha512
|
|
7293
|
+
prosemirror-schema-basic@1.2.3:
|
|
7294
|
+
resolution: {integrity: sha512-h+H0OQwZVqMon1PNn0AG9cTfx513zgIG2DY00eJ00Yvgb3UD+GQ/VlWW5rcaxacpCGT1Yx8nuhwXk4+QbXUfJA==}
|
|
7295
7295
|
|
|
7296
|
-
prosemirror-schema-list@1.4.
|
|
7297
|
-
resolution: {integrity: sha512-
|
|
7296
|
+
prosemirror-schema-list@1.4.1:
|
|
7297
|
+
resolution: {integrity: sha512-jbDyaP/6AFfDfu70VzySsD75Om2t3sXTOdl5+31Wlxlg62td1haUpty/ybajSfJ1pkGadlOfwQq9kgW5IMo1Rg==}
|
|
7298
7298
|
|
|
7299
7299
|
prosemirror-state@1.4.3:
|
|
7300
7300
|
resolution: {integrity: sha512-goFKORVbvPuAQaXhpbemJFRKJ2aixr+AZMGiquiqKxaucC6hlpHNZHWgz5R7dS4roHiwq9vDctE//CZ++o0W1Q==}
|
|
@@ -10718,7 +10718,7 @@ snapshots:
|
|
|
10718
10718
|
'@jridgewell/resolve-uri': 3.1.2
|
|
10719
10719
|
'@jridgewell/sourcemap-codec': 1.4.15
|
|
10720
10720
|
|
|
10721
|
-
'@lblod/ember-rdfa-editor@10.0.
|
|
10721
|
+
'@lblod/ember-rdfa-editor@10.1.0-dev.de48fb9f9ce504aea28da86b465bb5bf05816d96(2ef3gpurqxbttnmniw6grhzpuy)':
|
|
10722
10722
|
dependencies:
|
|
10723
10723
|
'@appuniversum/ember-appuniversum': 3.4.2(yenc6o4wruytt4u2jbwlbsqcl4)
|
|
10724
10724
|
'@babel/core': 7.24.7
|
|
@@ -10741,7 +10741,7 @@ snapshots:
|
|
|
10741
10741
|
common-tags: 1.8.2
|
|
10742
10742
|
crypto-browserify: 3.12.0
|
|
10743
10743
|
debug: 4.3.5
|
|
10744
|
-
dompurify: 3.1.
|
|
10744
|
+
dompurify: 3.1.6
|
|
10745
10745
|
ember-auto-import: 2.7.4(@glint/template@1.4.0)(webpack@5.92.1)
|
|
10746
10746
|
ember-changeset: 4.1.2(@glint/template@1.4.0)(webpack@5.92.1)
|
|
10747
10747
|
ember-cli-babel: 8.2.0(@babel/core@7.24.7)
|
|
@@ -10761,14 +10761,14 @@ snapshots:
|
|
|
10761
10761
|
linkifyjs: 4.1.3
|
|
10762
10762
|
mdn-polyfills: 5.20.0
|
|
10763
10763
|
process: 0.11.10
|
|
10764
|
-
prosemirror-commands: 1.
|
|
10764
|
+
prosemirror-commands: 1.6.0
|
|
10765
10765
|
prosemirror-dropcursor: 1.8.1
|
|
10766
|
-
prosemirror-history: 1.4.
|
|
10766
|
+
prosemirror-history: 1.4.1
|
|
10767
10767
|
prosemirror-inputrules: 1.4.0
|
|
10768
10768
|
prosemirror-keymap: 1.2.2
|
|
10769
10769
|
prosemirror-model: 1.21.3
|
|
10770
|
-
prosemirror-schema-basic: 1.2.
|
|
10771
|
-
prosemirror-schema-list: 1.4.
|
|
10770
|
+
prosemirror-schema-basic: 1.2.3
|
|
10771
|
+
prosemirror-schema-list: 1.4.1
|
|
10772
10772
|
prosemirror-state: 1.4.3
|
|
10773
10773
|
prosemirror-transform: 1.9.0
|
|
10774
10774
|
prosemirror-view: 1.33.8
|
|
@@ -10778,6 +10778,7 @@ snapshots:
|
|
|
10778
10778
|
tracked-built-ins: 3.3.0
|
|
10779
10779
|
tracked-toolbox: 2.0.0(@babel/core@7.24.7)(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))
|
|
10780
10780
|
uuid: 9.0.1
|
|
10781
|
+
vm-browserify: 1.1.2
|
|
10781
10782
|
yup: 1.4.0
|
|
10782
10783
|
optionalDependencies:
|
|
10783
10784
|
'@floating-ui/dom': 1.6.7
|
|
@@ -13763,7 +13764,7 @@ snapshots:
|
|
|
13763
13764
|
|
|
13764
13765
|
domain-browser@1.2.0: {}
|
|
13765
13766
|
|
|
13766
|
-
dompurify@3.1.
|
|
13767
|
+
dompurify@3.1.6: {}
|
|
13767
13768
|
|
|
13768
13769
|
dot-case@3.0.4:
|
|
13769
13770
|
dependencies:
|
|
@@ -18266,7 +18267,7 @@ snapshots:
|
|
|
18266
18267
|
|
|
18267
18268
|
property-expr@2.0.6: {}
|
|
18268
18269
|
|
|
18269
|
-
prosemirror-commands@1.
|
|
18270
|
+
prosemirror-commands@1.6.0:
|
|
18270
18271
|
dependencies:
|
|
18271
18272
|
prosemirror-model: 1.21.3
|
|
18272
18273
|
prosemirror-state: 1.4.3
|
|
@@ -18306,7 +18307,7 @@ snapshots:
|
|
|
18306
18307
|
prosemirror-transform: 1.9.0
|
|
18307
18308
|
prosemirror-view: 1.33.8
|
|
18308
18309
|
|
|
18309
|
-
prosemirror-history@1.4.
|
|
18310
|
+
prosemirror-history@1.4.1:
|
|
18310
18311
|
dependencies:
|
|
18311
18312
|
prosemirror-state: 1.4.3
|
|
18312
18313
|
prosemirror-transform: 1.9.0
|
|
@@ -18327,11 +18328,11 @@ snapshots:
|
|
|
18327
18328
|
dependencies:
|
|
18328
18329
|
orderedmap: 2.1.1
|
|
18329
18330
|
|
|
18330
|
-
prosemirror-schema-basic@1.2.
|
|
18331
|
+
prosemirror-schema-basic@1.2.3:
|
|
18331
18332
|
dependencies:
|
|
18332
18333
|
prosemirror-model: 1.21.3
|
|
18333
18334
|
|
|
18334
|
-
prosemirror-schema-list@1.4.
|
|
18335
|
+
prosemirror-schema-list@1.4.1:
|
|
18335
18336
|
dependencies:
|
|
18336
18337
|
prosemirror-model: 1.21.3
|
|
18337
18338
|
prosemirror-state: 1.4.3
|
|
@@ -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;
|