@lblod/ember-rdfa-editor-lblod-plugins 22.5.2 → 23.0.0
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 +11 -0
- package/addon/components/besluit-topic-plugin/besluit-topic-toolbar-dropdown.ts +1 -1
- package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +1 -1
- package/addon/components/citation-plugin/citation-card.ts +1 -1
- package/addon/components/citation-plugin/citations/legal-document-detail.ts +1 -1
- package/addon/components/citation-plugin/citations/search-modal.ts +1 -1
- package/addon/components/lmb-plugin/search-modal.ts +1 -1
- package/addon/components/location-plugin/edit.gts +1 -1
- package/addon/components/lpdc-plugin/lpdc-modal.ts +1 -1
- package/addon/components/roadsign-regulation-plugin/measure-template.ts +1 -1
- package/addon/components/snippet-plugin/nodes/snippet.gts +28 -36
- package/addon/components/snippet-plugin/search-modal.ts +1 -1
- package/addon/components/snippet-plugin/snippet-insert.gts +9 -23
- package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +1 -1
- package/addon/components/variable-plugin/address/edit.ts +1 -1
- package/addon/components/variable-plugin/codelist/edit.ts +1 -1
- package/addon/components/variable-plugin/codelist/insert.ts +1 -1
- package/addon/components/variable-plugin/location/edit.ts +1 -1
- package/addon/components/worship-plugin/search-modal.ts +1 -1
- package/addon/plugins/snippet-plugin/commands/insert-snippet.ts +91 -0
- package/addon/plugins/snippet-plugin/nodes/snippet.ts +8 -51
- package/declarations/addon/components/besluit-topic-plugin/besluit-topic-toolbar-dropdown.d.ts +1 -1
- package/declarations/addon/components/besluit-type-plugin/toolbar-dropdown.d.ts +1 -1
- package/declarations/addon/components/citation-plugin/citation-card.d.ts +1 -1
- package/declarations/addon/components/citation-plugin/citations/legal-document-detail.d.ts +1 -1
- package/declarations/addon/components/citation-plugin/citations/search-modal.d.ts +1 -1
- package/declarations/addon/components/lmb-plugin/search-modal.d.ts +1 -1
- package/declarations/addon/components/location-plugin/edit.d.ts +1 -1
- package/declarations/addon/components/lpdc-plugin/lpdc-modal.d.ts +1 -1
- package/declarations/addon/components/roadsign-regulation-plugin/measure-template.d.ts +1 -1
- package/declarations/addon/components/snippet-plugin/search-modal.d.ts +1 -1
- package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +1 -1
- package/declarations/addon/components/variable-plugin/address/edit.d.ts +1 -1
- package/declarations/addon/components/variable-plugin/codelist/edit.d.ts +1 -1
- package/declarations/addon/components/variable-plugin/codelist/insert.d.ts +1 -1
- package/declarations/addon/components/variable-plugin/location/edit.d.ts +1 -1
- package/declarations/addon/components/worship-plugin/search-modal.d.ts +1 -1
- package/declarations/addon/plugins/snippet-plugin/commands/insert-snippet.d.ts +14 -0
- package/declarations/addon/plugins/snippet-plugin/nodes/snippet.d.ts +5 -13
- package/package.json +6 -5
- package/pnpm-lock.yaml +99 -95
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 23.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#478](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/478) [`b3cf324`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/b3cf324e6b959a50ba354e1563b04a0e12f41f67) Thanks [@abeforgit](https://github.com/abeforgit)! - Run recalculate numbers after inserting a snippet
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- [#480](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/480) [`789180f`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/789180fde786000756c2880dca9591866bf7132f) Thanks [@piemonkey](https://github.com/piemonkey)! - Internal: update to latest ember-resources 7.0.2. Requires an upgrade only if consumer app uses
|
|
12
|
+
ember dependency-lint to maintain matching versions.
|
|
13
|
+
|
|
3
14
|
## 22.5.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -2,7 +2,7 @@ import { tracked } from '@glimmer/tracking';
|
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
5
|
-
import { trackedFunction } from '
|
|
5
|
+
import { trackedFunction } from 'reactiveweb/function';
|
|
6
6
|
import { ELI } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
7
7
|
import { AlertTriangleIcon } from '@appuniversum/ember-appuniversum/components/icons/alert-triangle';
|
|
8
8
|
import { CrossIcon } from '@appuniversum/ember-appuniversum/components/icons/cross';
|
|
@@ -7,7 +7,7 @@ import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
|
7
7
|
import fetchBesluitTypes, {
|
|
8
8
|
BesluitType,
|
|
9
9
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
|
|
10
|
-
import { trackedFunction } from '
|
|
10
|
+
import { trackedFunction } from 'reactiveweb/function';
|
|
11
11
|
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
12
12
|
import { BesluitTypePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin';
|
|
13
13
|
import { RDF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
@@ -3,7 +3,7 @@ import { tracked } from '@glimmer/tracking';
|
|
|
3
3
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
5
|
import { capitalize } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
|
|
6
|
-
import { task as trackedTask } from '
|
|
6
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
7
7
|
import {
|
|
8
8
|
Option,
|
|
9
9
|
unwrap,
|
|
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
3
3
|
import { tracked } from '@glimmer/tracking';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
|
-
import { task as trackedTask } from '
|
|
5
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
6
6
|
import { CalendarIcon } from '@appuniversum/ember-appuniversum/components/icons/calendar';
|
|
7
7
|
import { PlusTextIcon } from '@appuniversum/ember-appuniversum/components/icons/plus-text';
|
|
8
8
|
import { LinkExternalIcon } from '@appuniversum/ember-appuniversum/components/icons/link-external';
|
|
@@ -4,7 +4,7 @@ import { action } from '@ember/object';
|
|
|
4
4
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
5
5
|
import { service } from '@ember/service';
|
|
6
6
|
import { capitalize } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
|
|
7
|
-
import { task as trackedTask } from '
|
|
7
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
8
8
|
import {
|
|
9
9
|
isGemeenteBesluitType,
|
|
10
10
|
LEGISLATION_TYPE_CONCEPTS,
|
|
@@ -3,7 +3,7 @@ import { tracked } from '@glimmer/tracking';
|
|
|
3
3
|
import { assert } from '@ember/debug';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
5
|
import { restartableTask } from 'ember-concurrency';
|
|
6
|
-
import { task as trackedTask } from '
|
|
6
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
7
7
|
import { LmbPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/lmb-plugin';
|
|
8
8
|
|
|
9
9
|
import Mandatee from '@lblod/ember-rdfa-editor-lblod-plugins/models/mandatee';
|
|
@@ -3,7 +3,7 @@ import Component from '@glimmer/component';
|
|
|
3
3
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
4
4
|
import perform from 'ember-concurrency/helpers/perform';
|
|
5
5
|
import { trackedReset } from 'tracked-toolbox';
|
|
6
|
-
import { trackedTask } from '
|
|
6
|
+
import { trackedTask } from 'reactiveweb/ember-concurrency';
|
|
7
7
|
import { service } from '@ember/service';
|
|
8
8
|
import { on } from '@ember/modifier';
|
|
9
9
|
import type { SafeString } from '@ember/template/-private/handlebars';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
3
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
4
|
-
import { task as trackedTask } from '
|
|
4
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
5
5
|
|
|
6
6
|
import { tracked } from '@glimmer/tracking';
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { service } from '@ember/service';
|
|
3
3
|
import includeInstructions from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/utils/includeInstructions';
|
|
4
4
|
import RoadsignRegistryService from '@lblod/ember-rdfa-editor-lblod-plugins/services/roadsign-registry';
|
|
5
|
-
import { trackedFunction } from '
|
|
5
|
+
import { trackedFunction } from 'reactiveweb/function';
|
|
6
6
|
|
|
7
7
|
type Args = {
|
|
8
8
|
template: string;
|
|
@@ -25,7 +25,10 @@ import {
|
|
|
25
25
|
RDF,
|
|
26
26
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
27
27
|
import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
28
|
-
import
|
|
28
|
+
import insertSnippet from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/commands/insert-snippet';
|
|
29
|
+
import { isNone } from '@lblod/ember-rdfa-editor/utils/_private/option';
|
|
30
|
+
import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
|
|
31
|
+
import { recalculateNumbers } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/structure-plugin/recalculate-structure-numbers';
|
|
29
32
|
|
|
30
33
|
interface ButtonSig {
|
|
31
34
|
Args: {
|
|
@@ -93,7 +96,10 @@ export default class SnippetNode extends Component<Signature> {
|
|
|
93
96
|
const position = this.args.getPos();
|
|
94
97
|
if (position !== undefined) {
|
|
95
98
|
this.controller.withTransaction((tr) => {
|
|
96
|
-
return
|
|
99
|
+
return transactionCombinator(
|
|
100
|
+
this.controller.mainEditorState,
|
|
101
|
+
tr.deleteRange(position, position + this.node.nodeSize),
|
|
102
|
+
)([recalculateNumbers]).transaction;
|
|
97
103
|
});
|
|
98
104
|
}
|
|
99
105
|
}
|
|
@@ -121,46 +127,32 @@ export default class SnippetNode extends Component<Signature> {
|
|
|
121
127
|
}
|
|
122
128
|
@action
|
|
123
129
|
onInsert(content: string, title: string) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
this.closeModal();
|
|
131
|
+
const assignedSnippetListsIds = this.node.attrs.assignedSnippetListsIds;
|
|
132
|
+
let start = 0;
|
|
133
|
+
let end = 0;
|
|
134
|
+
const pos = this.args.getPos();
|
|
135
|
+
if (isNone(pos)) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
127
138
|
if (this.mode === 'add') {
|
|
128
139
|
// Add new snippet
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
start = pos + this.node.nodeSize;
|
|
141
|
+
end = pos + this.node.nodeSize;
|
|
131
142
|
} else {
|
|
132
143
|
//Replace current snippet
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const domParser = new DOMParser();
|
|
138
|
-
const parsed = domParser.parseFromString(content, 'text/html').body;
|
|
139
|
-
const documentDiv = parsed.querySelector('div[data-say-document="true"]');
|
|
140
|
-
|
|
141
|
-
this.closeModal();
|
|
142
|
-
|
|
143
|
-
if (documentDiv) {
|
|
144
|
-
return createAndInsertSnippet(
|
|
145
|
-
{
|
|
146
|
-
controller: this.controller,
|
|
147
|
-
content,
|
|
148
|
-
title,
|
|
149
|
-
snippetListIds: this.node.attrs.assignedSnippetListsIds,
|
|
150
|
-
importedResources: this.node.attrs.importedResources,
|
|
151
|
-
},
|
|
152
|
-
(tr, snippet) => tr.replaceRangeWith(rangeStart, rangeEnd, snippet),
|
|
153
|
-
);
|
|
144
|
+
start = pos;
|
|
145
|
+
end = pos + this.node.nodeSize;
|
|
154
146
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.
|
|
161
|
-
|
|
147
|
+
this.controller.doCommand(
|
|
148
|
+
insertSnippet({
|
|
149
|
+
content,
|
|
150
|
+
title,
|
|
151
|
+
assignedSnippetListsIds,
|
|
152
|
+
importedResources: this.node.attrs.importedResources,
|
|
153
|
+
range: { start, end },
|
|
154
|
+
}),
|
|
162
155
|
);
|
|
163
|
-
this.closeModal();
|
|
164
156
|
}
|
|
165
157
|
|
|
166
158
|
<template>
|
|
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { assert } from '@ember/debug';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
5
|
-
import { task as trackedTask } from '
|
|
5
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
6
6
|
|
|
7
7
|
import { tracked } from '@glimmer/tracking';
|
|
8
8
|
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
Slice,
|
|
12
12
|
} from '@lblod/ember-rdfa-editor';
|
|
13
13
|
import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
14
|
-
import { createAndInsertSnippet } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/nodes/snippet';
|
|
15
14
|
import { type ImportedResourceMap } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
15
|
+
import insertSnippet from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/commands/insert-snippet';
|
|
16
16
|
import SearchModal from './search-modal';
|
|
17
17
|
|
|
18
18
|
interface Sig {
|
|
@@ -56,29 +56,15 @@ export default class SnippetInsertComponent extends Component<Sig> {
|
|
|
56
56
|
|
|
57
57
|
@action
|
|
58
58
|
onInsert(content: string, title: string) {
|
|
59
|
-
const domParser = new DOMParser();
|
|
60
|
-
const parsed = domParser.parseFromString(content, 'text/html').body;
|
|
61
|
-
const documentDiv = parsed.querySelector('div[data-say-document="true"]');
|
|
62
|
-
|
|
63
59
|
this.closeModal();
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
snippetListIds: assignedSnippetListProperties.listIds,
|
|
73
|
-
importedResources: assignedSnippetListProperties.importedResources,
|
|
74
|
-
},
|
|
75
|
-
(tr, snippet) => tr.replaceSelectionWith(snippet),
|
|
76
|
-
);
|
|
77
|
-
} else {
|
|
78
|
-
return this.controller.withTransaction((tr) =>
|
|
79
|
-
tr.replaceSelection(this.createSliceFromElement(parsed)),
|
|
80
|
-
);
|
|
81
|
-
}
|
|
60
|
+
this.controller.doCommand(
|
|
61
|
+
insertSnippet({
|
|
62
|
+
content,
|
|
63
|
+
title,
|
|
64
|
+
assignedSnippetListsIds: this.args.snippetListProperties?.listIds || [],
|
|
65
|
+
importedResources: this.args.snippetListProperties?.importedResources,
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
82
68
|
}
|
|
83
69
|
|
|
84
70
|
get disabled() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
3
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
4
|
-
import { task as trackedTask } from '
|
|
4
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
5
5
|
|
|
6
6
|
import { tracked } from '@glimmer/tracking';
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/address-helpers';
|
|
12
12
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
13
13
|
import { trackedReset } from 'tracked-toolbox';
|
|
14
|
-
import { trackedTask } from '
|
|
14
|
+
import { trackedTask } from 'reactiveweb/ember-concurrency';
|
|
15
15
|
import { service } from '@ember/service';
|
|
16
16
|
import IntlService from 'ember-intl/services/intl';
|
|
17
17
|
import { AlertTriangleIcon } from '@appuniversum/ember-appuniversum/components/icons/alert-triangle';
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/fetch-data';
|
|
8
8
|
import { MULTI_SELECT_CODELIST_TYPE } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/constants';
|
|
9
9
|
import { NodeSelection } from '@lblod/ember-rdfa-editor';
|
|
10
|
-
import { trackedFunction } from '
|
|
10
|
+
import { trackedFunction } from 'reactiveweb/function';
|
|
11
11
|
import { trackedReset } from 'tracked-toolbox';
|
|
12
12
|
import { updateCodelistVariable } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/codelist-utils';
|
|
13
13
|
import { getOutgoingTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/fetch-data';
|
|
10
10
|
import { service } from '@ember/service';
|
|
11
11
|
import IntlService from 'ember-intl/services/intl';
|
|
12
|
-
import { trackedFunction } from '
|
|
12
|
+
import { trackedFunction } from 'reactiveweb/function';
|
|
13
13
|
import { v4 as uuidv4 } from 'uuid';
|
|
14
14
|
import {
|
|
15
15
|
DCT,
|
|
@@ -10,7 +10,7 @@ import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
|
|
|
10
10
|
import { NodeSelection } from '@lblod/ember-rdfa-editor';
|
|
11
11
|
import { ZONAL_URI } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/roadsign-regulation-plugin/utils/constants';
|
|
12
12
|
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
13
|
-
import { trackedFunction } from '
|
|
13
|
+
import { trackedFunction } from 'reactiveweb/function';
|
|
14
14
|
import { trackedReset } from 'tracked-toolbox';
|
|
15
15
|
import { updateCodelistVariable } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/utils/codelist-utils';
|
|
16
16
|
|
|
@@ -3,7 +3,7 @@ import { tracked } from '@glimmer/tracking';
|
|
|
3
3
|
import { assert } from '@ember/debug';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
5
|
import { restartableTask, timeout } from 'ember-concurrency';
|
|
6
|
-
import { task as trackedTask } from '
|
|
6
|
+
import { task as trackedTask } from 'reactiveweb/ember-concurrency';
|
|
7
7
|
import { WorshipPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/worship-plugin';
|
|
8
8
|
import {
|
|
9
9
|
fetchWorshipServices,
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Command, ProseParser, Schema, Slice } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
|
|
3
|
+
import { addPropertyToNode } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
|
|
4
|
+
import { recalculateNumbers } from '../../structure-plugin/recalculate-structure-numbers';
|
|
5
|
+
import { createSnippet } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/nodes/snippet';
|
|
6
|
+
import { type ImportedResourceMap } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
7
|
+
import {
|
|
8
|
+
isSome,
|
|
9
|
+
unwrap,
|
|
10
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
11
|
+
|
|
12
|
+
export interface InsertSnippetCommandArgs {
|
|
13
|
+
content: string;
|
|
14
|
+
title: string;
|
|
15
|
+
assignedSnippetListsIds: string[];
|
|
16
|
+
importedResources?: ImportedResourceMap;
|
|
17
|
+
range?: { start: number; end: number };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const insertSnippet = ({
|
|
21
|
+
content,
|
|
22
|
+
title,
|
|
23
|
+
assignedSnippetListsIds,
|
|
24
|
+
importedResources,
|
|
25
|
+
range,
|
|
26
|
+
}: InsertSnippetCommandArgs): Command => {
|
|
27
|
+
return (state, dispatch) => {
|
|
28
|
+
const domParser = new DOMParser();
|
|
29
|
+
const parsed = domParser.parseFromString(content, 'text/html').body;
|
|
30
|
+
const documentDiv = parsed.querySelector('div[data-say-document="true"]');
|
|
31
|
+
|
|
32
|
+
const schema = state.schema;
|
|
33
|
+
|
|
34
|
+
let tr = state.tr;
|
|
35
|
+
const insertRange = range ?? {
|
|
36
|
+
start: state.selection.from,
|
|
37
|
+
end: state.selection.to,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (documentDiv) {
|
|
41
|
+
const [snippet, importedTriples] = createSnippet({
|
|
42
|
+
schema: state.schema,
|
|
43
|
+
content,
|
|
44
|
+
title,
|
|
45
|
+
snippetListIds: assignedSnippetListsIds,
|
|
46
|
+
importedResources,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const addImportedResourceProperties = Object.values(
|
|
50
|
+
importedResources ?? {},
|
|
51
|
+
)
|
|
52
|
+
.map((linked) => {
|
|
53
|
+
const newProperties =
|
|
54
|
+
(isSome(linked) && importedTriples.get(linked)) || [];
|
|
55
|
+
return newProperties.map((newProp) =>
|
|
56
|
+
addPropertyToNode({
|
|
57
|
+
resource: unwrap(linked),
|
|
58
|
+
property: newProp,
|
|
59
|
+
}),
|
|
60
|
+
);
|
|
61
|
+
})
|
|
62
|
+
.flat();
|
|
63
|
+
|
|
64
|
+
tr = transactionCombinator(
|
|
65
|
+
state,
|
|
66
|
+
tr.replaceRangeWith(insertRange.start, insertRange.end, snippet),
|
|
67
|
+
)([recalculateNumbers, ...addImportedResourceProperties]).transaction;
|
|
68
|
+
} else {
|
|
69
|
+
const slice = createSliceFromElement(parsed, schema);
|
|
70
|
+
tr = transactionCombinator(
|
|
71
|
+
state,
|
|
72
|
+
tr.replaceRange(insertRange.start, insertRange.end, slice),
|
|
73
|
+
)([recalculateNumbers]).transaction;
|
|
74
|
+
}
|
|
75
|
+
if (dispatch) {
|
|
76
|
+
dispatch(tr);
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
function createSliceFromElement(element: Element, schema: Schema) {
|
|
83
|
+
return new Slice(
|
|
84
|
+
ProseParser.fromSchema(schema).parse(element, {
|
|
85
|
+
preserveWhitespace: true,
|
|
86
|
+
}).content,
|
|
87
|
+
0,
|
|
88
|
+
0,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
export default insertSnippet;
|
|
@@ -5,8 +5,7 @@ import {
|
|
|
5
5
|
type PNode,
|
|
6
6
|
ProseParser,
|
|
7
7
|
rdfaAttrSpec,
|
|
8
|
-
type
|
|
9
|
-
type Transaction,
|
|
8
|
+
type Schema,
|
|
10
9
|
} from '@lblod/ember-rdfa-editor';
|
|
11
10
|
import {
|
|
12
11
|
renderRdfaAware,
|
|
@@ -23,8 +22,6 @@ import {
|
|
|
23
22
|
type EmberNodeConfig,
|
|
24
23
|
} from '@lblod/ember-rdfa-editor/utils/ember-node';
|
|
25
24
|
import { htmlToDoc } from '@lblod/ember-rdfa-editor/utils/_private/html-utils';
|
|
26
|
-
import { transactionCombinator } from '@lblod/ember-rdfa-editor/utils/transaction-utils';
|
|
27
|
-
import { addPropertyToNode } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
|
|
28
25
|
import SnippetComponent from '@lblod/ember-rdfa-editor-lblod-plugins/components/snippet-plugin/nodes/snippet';
|
|
29
26
|
import {
|
|
30
27
|
EXT,
|
|
@@ -37,10 +34,6 @@ import {
|
|
|
37
34
|
type ImportedResourceMap,
|
|
38
35
|
type SnippetPluginConfig,
|
|
39
36
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
40
|
-
import {
|
|
41
|
-
isSome,
|
|
42
|
-
unwrap,
|
|
43
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
44
37
|
|
|
45
38
|
function outgoingFromBacklink(
|
|
46
39
|
backlink: IncomingTriple,
|
|
@@ -65,11 +58,11 @@ function outgoingFromBacklink(
|
|
|
65
58
|
}
|
|
66
59
|
|
|
67
60
|
interface CreateSnippetArgs {
|
|
68
|
-
|
|
61
|
+
schema: Schema;
|
|
69
62
|
content: string;
|
|
70
63
|
title: string;
|
|
71
64
|
snippetListIds: string[];
|
|
72
|
-
importedResources
|
|
65
|
+
importedResources?: ImportedResourceMap;
|
|
73
66
|
}
|
|
74
67
|
|
|
75
68
|
/**
|
|
@@ -79,7 +72,7 @@ interface CreateSnippetArgs {
|
|
|
79
72
|
* properties that these resources will have after the snippet is inserted into the document.
|
|
80
73
|
**/
|
|
81
74
|
export function createSnippet({
|
|
82
|
-
|
|
75
|
+
schema,
|
|
83
76
|
content,
|
|
84
77
|
title,
|
|
85
78
|
snippetListIds,
|
|
@@ -94,13 +87,12 @@ export function createSnippet({
|
|
|
94
87
|
}
|
|
95
88
|
}
|
|
96
89
|
// Create the new node
|
|
97
|
-
const parser = ProseParser.fromSchema(
|
|
90
|
+
const parser = ProseParser.fromSchema(schema);
|
|
98
91
|
const contentAsNode = htmlToDoc(replacedContent, {
|
|
99
|
-
schema
|
|
92
|
+
schema,
|
|
100
93
|
parser,
|
|
101
|
-
editorView: controller.mainEditorView,
|
|
102
94
|
});
|
|
103
|
-
const node =
|
|
95
|
+
const node = schema.node(
|
|
104
96
|
'snippet',
|
|
105
97
|
{
|
|
106
98
|
assignedSnippetListsIds: snippetListIds,
|
|
@@ -112,7 +104,7 @@ export function createSnippet({
|
|
|
112
104
|
);
|
|
113
105
|
// Find all the new backlinks that refer to imported resources and generate OutgoingLinks for them
|
|
114
106
|
const importedTriples: Map<string, OutgoingTriple[]> = new Map();
|
|
115
|
-
if (Object.keys(importedResources).length > 0) {
|
|
107
|
+
if (Object.keys(importedResources ?? {}).length > 0) {
|
|
116
108
|
contentAsNode.descendants((node) => {
|
|
117
109
|
const backlinks = node.attrs.backlinks as IncomingTriple[] | undefined;
|
|
118
110
|
if (backlinks && backlinks.length > 0) {
|
|
@@ -136,41 +128,6 @@ export function createSnippet({
|
|
|
136
128
|
return [node, importedTriples];
|
|
137
129
|
}
|
|
138
130
|
|
|
139
|
-
/**
|
|
140
|
-
* Creates a Snippet node wrapping the given content while allowing for further snippets to be added
|
|
141
|
-
* or removed.
|
|
142
|
-
* Takes the same arguments object as creating a snippet but also a generator that produces a
|
|
143
|
-
* transaction that inserts the snippet into the document, so that this can be done in a way
|
|
144
|
-
* specific to the situation.
|
|
145
|
-
**/
|
|
146
|
-
export function createAndInsertSnippet(
|
|
147
|
-
createSnippetArgs: CreateSnippetArgs,
|
|
148
|
-
insertTransactionGenerator: (tr: Transaction, snippet: PNode) => Transaction,
|
|
149
|
-
) {
|
|
150
|
-
return createSnippetArgs.controller.withTransaction((tr, state) => {
|
|
151
|
-
const [snippet, importedTriples] = createSnippet(createSnippetArgs);
|
|
152
|
-
const result = transactionCombinator<boolean>(
|
|
153
|
-
state,
|
|
154
|
-
insertTransactionGenerator(tr, snippet),
|
|
155
|
-
)(
|
|
156
|
-
Object.values(createSnippetArgs.importedResources)
|
|
157
|
-
.map((linked) => {
|
|
158
|
-
const newProperties =
|
|
159
|
-
(isSome(linked) && importedTriples.get(linked)) || [];
|
|
160
|
-
return newProperties.map((newProp) =>
|
|
161
|
-
addPropertyToNode({
|
|
162
|
-
resource: unwrap(linked),
|
|
163
|
-
property: newProp,
|
|
164
|
-
}),
|
|
165
|
-
);
|
|
166
|
-
})
|
|
167
|
-
.flat(),
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
return result.transaction;
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
131
|
const emberNodeConfig = (options: SnippetPluginConfig): EmberNodeConfig => ({
|
|
175
132
|
name: 'snippet',
|
|
176
133
|
inline: false,
|
package/declarations/addon/components/besluit-topic-plugin/besluit-topic-toolbar-dropdown.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export default class BesluitTopicToolbarDropdownComponent extends Component<Args
|
|
|
20
20
|
get doc(): import("prosemirror-model").Node;
|
|
21
21
|
get decisionRange(): import("@lblod/ember-rdfa-editor/plugins/datastore").ElementPNode | undefined;
|
|
22
22
|
get showCard(): boolean;
|
|
23
|
-
topics: import("
|
|
23
|
+
topics: import("reactiveweb/function").State<Promise<BesluitTopic[]>>;
|
|
24
24
|
findBesluitTopicsByUris(uris: string[], topics?: BesluitTopic[] | null): BesluitTopic[] | undefined;
|
|
25
25
|
updateBesluitTopic(): void;
|
|
26
26
|
upsertBesluitTopic(selected: BesluitTopic[]): void;
|
|
@@ -26,7 +26,7 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
|
|
|
26
26
|
constructor(parent: unknown, args: Args);
|
|
27
27
|
get controller(): SayController;
|
|
28
28
|
get doc(): import("prosemirror-model").Node;
|
|
29
|
-
types: import("
|
|
29
|
+
types: import("reactiveweb/function").State<Promise<BesluitType[]>>;
|
|
30
30
|
get currentBesluitRange(): import("@lblod/ember-rdfa-editor/plugins/datastore").ElementPNode | undefined;
|
|
31
31
|
get currentBesluitURI(): string | undefined;
|
|
32
32
|
get showCard(): boolean;
|
|
@@ -41,7 +41,7 @@ export default class CitationCardComponent extends Component<Args> {
|
|
|
41
41
|
onCardTextChange(event: InputEvent): void;
|
|
42
42
|
get governmentName(): string | undefined;
|
|
43
43
|
resourceSearch: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, () => Promise<LegalDocument[]>>;
|
|
44
|
-
legalDocumentsResource: import("
|
|
44
|
+
legalDocumentsResource: import("reactiveweb/ember-concurrency").TaskInstance<unknown>;
|
|
45
45
|
selectLegislationType(type: string): void;
|
|
46
46
|
openLegalDocumentDetailModal(legalDocument: LegalDocument): void;
|
|
47
47
|
openSearchModal(): Promise<void>;
|
|
@@ -24,7 +24,7 @@ export default class LegalDocumentDetailComponent extends Component<Args> {
|
|
|
24
24
|
articleFilterAfterTimeout: string;
|
|
25
25
|
updateArticleFilter: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, (event: InputEvent) => Promise<void>>;
|
|
26
26
|
resourceSearch: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, () => Promise<import("@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/article").Article[]>>;
|
|
27
|
-
articleResource: import("
|
|
27
|
+
articleResource: import("reactiveweb/ember-concurrency").TaskInstance<unknown>;
|
|
28
28
|
close(): Promise<void>;
|
|
29
29
|
previousPage(): void;
|
|
30
30
|
nextPage(): void;
|
|
@@ -51,7 +51,7 @@ export default class EditorPluginsCitationsSearchModalComponent extends Componen
|
|
|
51
51
|
get searchText(): string;
|
|
52
52
|
get governmentSearchText(): string | undefined;
|
|
53
53
|
resourceSearch: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, () => Promise<LegalDocument[]>>;
|
|
54
|
-
legalDocumentResource: import("
|
|
54
|
+
legalDocumentResource: import("reactiveweb/ember-concurrency").TaskInstance<unknown>;
|
|
55
55
|
get isBesluitType(): boolean;
|
|
56
56
|
setInputSearchText(event: InputEvent): void;
|
|
57
57
|
setGovernmentSearchText(event: InputEvent): void;
|
|
@@ -22,7 +22,7 @@ export default class LmbPluginSearchModalComponent extends Component<Args> {
|
|
|
22
22
|
results: Mandatee[];
|
|
23
23
|
totalCount: number;
|
|
24
24
|
} | undefined>>;
|
|
25
|
-
servicesResource: import("
|
|
25
|
+
servicesResource: import("reactiveweb/ember-concurrency").TaskInstance<unknown>;
|
|
26
26
|
setSort(sort: SearchSort): void;
|
|
27
27
|
setInputSearchText(event: InputEvent): void;
|
|
28
28
|
previousPage(): void;
|
|
@@ -44,7 +44,7 @@ export default class LocationPluginEditComponent extends Component<Signature> {
|
|
|
44
44
|
get canUpdateBusnumber(): string | undefined;
|
|
45
45
|
get alternativeAddressFromError(): Address | undefined;
|
|
46
46
|
resolveAddressTask: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, () => Promise<Address | undefined>>;
|
|
47
|
-
newAddress: import("
|
|
47
|
+
newAddress: import("reactiveweb/ember-concurrency").TaskInstance<Address | undefined>;
|
|
48
48
|
selectMunicipality(municipality: string): void;
|
|
49
49
|
selectStreet(street: string): void;
|
|
50
50
|
updateHousenumber(event: InputEvent): void;
|
|
@@ -36,7 +36,7 @@ export default class LpdcPluginModalComponent extends Component<Signature> {
|
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
})>>;
|
|
39
|
-
lpdcResource: import("
|
|
39
|
+
lpdcResource: import("reactiveweb/ember-concurrency").TaskInstance<unknown>;
|
|
40
40
|
onSearchTextChange(event: InputEvent): void;
|
|
41
41
|
}
|
|
42
42
|
export {};
|
|
@@ -9,6 +9,6 @@ type Args = {
|
|
|
9
9
|
export default class MeasureTemplateComponent extends Component<Args> {
|
|
10
10
|
roadsignRegistry: RoadsignRegistryService;
|
|
11
11
|
get template(): string;
|
|
12
|
-
instructionData: import("
|
|
12
|
+
instructionData: import("reactiveweb/function").State<Promise<string>>;
|
|
13
13
|
}
|
|
14
14
|
export {};
|
|
@@ -18,7 +18,7 @@ export default class SnippetPluginSearchModalComponent extends Component<Args> {
|
|
|
18
18
|
setInputSearchText(event: InputEvent): void;
|
|
19
19
|
closeModal(): Promise<void>;
|
|
20
20
|
snippetsSearch: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, () => Promise<import("@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin").Snippet[]>>;
|
|
21
|
-
snippetsResource: import("
|
|
21
|
+
snippetsResource: import("reactiveweb/ember-concurrency").TaskInstance<unknown>;
|
|
22
22
|
previousPage(): void;
|
|
23
23
|
nextPage(): void;
|
|
24
24
|
}
|