@lblod/ember-rdfa-editor-lblod-plugins 22.5.1 → 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 +19 -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 +83 -71
- 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/index.ts +3 -0
- package/addon/plugins/snippet-plugin/nodes/snippet.ts +10 -52
- package/app/styles/snippet-plugin.scss +5 -0
- 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/index.d.ts +2 -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,24 @@
|
|
|
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
|
+
|
|
14
|
+
## 22.5.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#476](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/476) [`6de71f8`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/6de71f8b57e1cf5297445e288e0221707f1fbc7c) Thanks [@piemonkey](https://github.com/piemonkey)! - Add configuration option to snippet plugin to set the allowed content
|
|
19
|
+
|
|
20
|
+
- [#479](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/479) [`4755750`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/47557501ed745a274cc062bd59234736bc278ded) Thanks [@piemonkey](https://github.com/piemonkey)! - Fix bug where snippet hover buttons were not always functional on Chrome
|
|
21
|
+
|
|
3
22
|
## 22.5.1
|
|
4
23
|
|
|
5
24
|
### 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;
|
|
@@ -3,8 +3,12 @@ import { on } from '@ember/modifier';
|
|
|
3
3
|
import SearchModal from '../search-modal';
|
|
4
4
|
import { tracked } from '@glimmer/tracking';
|
|
5
5
|
import { action } from '@ember/object';
|
|
6
|
+
import { TemplateOnlyComponent } from '@ember/component/template-only';
|
|
6
7
|
import t from 'ember-intl/helpers/t';
|
|
7
|
-
import
|
|
8
|
+
import { not } from 'ember-truth-helpers';
|
|
9
|
+
import AuIcon, {
|
|
10
|
+
type AuIconSignature,
|
|
11
|
+
} from '@appuniversum/ember-appuniversum/components/au-icon';
|
|
8
12
|
import { SynchronizeIcon } from '@appuniversum/ember-appuniversum/components/icons/synchronize';
|
|
9
13
|
import { BinIcon } from '@appuniversum/ember-appuniversum/components/icons/bin';
|
|
10
14
|
import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
|
|
@@ -21,7 +25,37 @@ import {
|
|
|
21
25
|
RDF,
|
|
22
26
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
23
27
|
import { hasOutgoingNamedNodeTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
24
|
-
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';
|
|
32
|
+
|
|
33
|
+
interface ButtonSig {
|
|
34
|
+
Args: {
|
|
35
|
+
isActive: boolean;
|
|
36
|
+
onClick: () => void;
|
|
37
|
+
icon: AuIconSignature['Args']['icon'];
|
|
38
|
+
helpText: string;
|
|
39
|
+
};
|
|
40
|
+
Element: HTMLButtonElement;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const SnippetButton: TemplateOnlyComponent<ButtonSig> = <template>
|
|
44
|
+
<button
|
|
45
|
+
class='say-snippet-button {{if @isActive "" "say-snippet-hidden"}}'
|
|
46
|
+
disabled={{(not @isActive)}}
|
|
47
|
+
type='button'
|
|
48
|
+
{{on 'click' @onClick}}
|
|
49
|
+
...attributes
|
|
50
|
+
>
|
|
51
|
+
{{#if @isActive}}
|
|
52
|
+
<AuIcon @icon={{@icon}} @size='large' {{on 'click' @onClick}} />
|
|
53
|
+
<div class='say-snippet-button-text'>
|
|
54
|
+
{{t @helpText}}
|
|
55
|
+
</div>
|
|
56
|
+
{{/if}}
|
|
57
|
+
</button>
|
|
58
|
+
</template>;
|
|
25
59
|
|
|
26
60
|
interface Signature {
|
|
27
61
|
Args: EmberNodeArgs;
|
|
@@ -44,6 +78,7 @@ export default class SnippetNode extends Component<Signature> {
|
|
|
44
78
|
this.showModal = false;
|
|
45
79
|
}
|
|
46
80
|
openModal() {
|
|
81
|
+
this.controller.focus();
|
|
47
82
|
this.showModal = true;
|
|
48
83
|
}
|
|
49
84
|
@action
|
|
@@ -61,7 +96,10 @@ export default class SnippetNode extends Component<Signature> {
|
|
|
61
96
|
const position = this.args.getPos();
|
|
62
97
|
if (position !== undefined) {
|
|
63
98
|
this.controller.withTransaction((tr) => {
|
|
64
|
-
return
|
|
99
|
+
return transactionCombinator(
|
|
100
|
+
this.controller.mainEditorState,
|
|
101
|
+
tr.deleteRange(position, position + this.node.nodeSize),
|
|
102
|
+
)([recalculateNumbers]).transaction;
|
|
65
103
|
});
|
|
66
104
|
}
|
|
67
105
|
}
|
|
@@ -89,85 +127,59 @@ export default class SnippetNode extends Component<Signature> {
|
|
|
89
127
|
}
|
|
90
128
|
@action
|
|
91
129
|
onInsert(content: string, title: string) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
+
}
|
|
95
138
|
if (this.mode === 'add') {
|
|
96
139
|
// Add new snippet
|
|
97
|
-
|
|
98
|
-
|
|
140
|
+
start = pos + this.node.nodeSize;
|
|
141
|
+
end = pos + this.node.nodeSize;
|
|
99
142
|
} else {
|
|
100
143
|
//Replace current snippet
|
|
101
|
-
|
|
102
|
-
|
|
144
|
+
start = pos;
|
|
145
|
+
end = pos + this.node.nodeSize;
|
|
103
146
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return createAndInsertSnippet(
|
|
113
|
-
{
|
|
114
|
-
controller: this.controller,
|
|
115
|
-
content,
|
|
116
|
-
title,
|
|
117
|
-
snippetListIds: this.node.attrs.assignedSnippetListsIds,
|
|
118
|
-
importedResources: this.node.attrs.importedResources,
|
|
119
|
-
},
|
|
120
|
-
(tr, snippet) => tr.replaceRangeWith(rangeStart, rangeEnd, snippet),
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
this.controller.withTransaction((tr) =>
|
|
125
|
-
tr.replaceRange(
|
|
126
|
-
rangeStart,
|
|
127
|
-
rangeEnd,
|
|
128
|
-
this.createSliceFromElement(parsed),
|
|
129
|
-
),
|
|
147
|
+
this.controller.doCommand(
|
|
148
|
+
insertSnippet({
|
|
149
|
+
content,
|
|
150
|
+
title,
|
|
151
|
+
assignedSnippetListsIds,
|
|
152
|
+
importedResources: this.node.attrs.importedResources,
|
|
153
|
+
range: { start, end },
|
|
154
|
+
}),
|
|
130
155
|
);
|
|
131
|
-
this.closeModal();
|
|
132
156
|
}
|
|
157
|
+
|
|
133
158
|
<template>
|
|
134
159
|
<div class='say-snippet-card'>
|
|
135
160
|
<div class='say-snippet-title'>{{this.node.attrs.title}}</div>
|
|
136
161
|
<div class='say-snippet-content'>{{yield}}</div>
|
|
137
|
-
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
</button>
|
|
159
|
-
<button
|
|
160
|
-
class='say-snippet-button'
|
|
161
|
-
type='button'
|
|
162
|
-
{{on 'click' this.addFragment}}
|
|
163
|
-
>
|
|
164
|
-
<AuIcon @icon={{AddIcon}} />
|
|
165
|
-
<div class='say-snippet-button-text'>
|
|
166
|
-
{{t 'snippet-plugin.snippet-node.add-fragment'}}
|
|
167
|
-
</div>
|
|
168
|
-
</button>
|
|
169
|
-
</div>
|
|
170
|
-
{{/if}}
|
|
162
|
+
<div class='say-snippet-icons' contenteditable='false'>
|
|
163
|
+
<SnippetButton
|
|
164
|
+
@icon={{SynchronizeIcon}}
|
|
165
|
+
@helpText='snippet-plugin.snippet-node.change-fragment'
|
|
166
|
+
@onClick={{this.editFragment}}
|
|
167
|
+
@isActive={{this.isActive}}
|
|
168
|
+
/>
|
|
169
|
+
<SnippetButton
|
|
170
|
+
@icon={{BinIcon}}
|
|
171
|
+
@helpText='snippet-plugin.snippet-node.remove-fragment'
|
|
172
|
+
@onClick={{this.deleteFragment}}
|
|
173
|
+
@isActive={{this.isActive}}
|
|
174
|
+
class='say-snippet-remove-button'
|
|
175
|
+
/>
|
|
176
|
+
<SnippetButton
|
|
177
|
+
@icon={{AddIcon}}
|
|
178
|
+
@helpText='snippet-plugin.snippet-node.add-fragment'
|
|
179
|
+
@onClick={{this.addFragment}}
|
|
180
|
+
@isActive={{this.isActive}}
|
|
181
|
+
/>
|
|
182
|
+
</div>
|
|
171
183
|
|
|
172
184
|
</div>
|
|
173
185
|
<SearchModal
|
|
@@ -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;
|
|
@@ -7,8 +7,11 @@ import {
|
|
|
7
7
|
import { dateValue } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/strings';
|
|
8
8
|
import { SafeString } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/types';
|
|
9
9
|
|
|
10
|
+
export const DEFAULT_CONTENT_STRING = 'block+';
|
|
11
|
+
|
|
10
12
|
export type SnippetPluginConfig = {
|
|
11
13
|
endpoint: string;
|
|
14
|
+
allowedContent?: string;
|
|
12
15
|
};
|
|
13
16
|
|
|
14
17
|
interface SnippetArgs {
|