@lblod/ember-rdfa-editor-lblod-plugins 22.5.1 → 23.0.0-dev.0459b40ac0bfac80168828d9ab8afa7c1418c4fa
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/mean-deers-call.md +5 -0
- 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/autofilled/edit.gts +225 -0
- package/addon/components/variable-plugin/autofilled/insert.gts +143 -0
- package/addon/components/variable-plugin/autofilled/nodeview.gts +100 -0
- 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/variable-plugin/utils/label-input.gts +28 -0
- 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/addon/plugins/variable-plugin/plugins/autofiller.ts +98 -0
- package/addon/plugins/variable-plugin/variables/autofilled.ts +170 -0
- package/addon/plugins/variable-plugin/variables/index.ts +1 -0
- package/app/components/variable-plugin/autofilled/edit.js +1 -0
- package/app/components/variable-plugin/autofilled/insert.js +1 -0
- package/app/components/variable-plugin/autofilled/nodeview.js +1 -0
- 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/autofilled/edit.d.ts +28 -0
- package/declarations/addon/components/variable-plugin/autofilled/insert.d.ts +20 -0
- package/declarations/addon/components/variable-plugin/autofilled/nodeview.d.ts +22 -0
- 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/variable-plugin/utils/label-input.d.ts +11 -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/declarations/addon/plugins/variable-plugin/plugins/autofiller.d.ts +8 -0
- package/declarations/addon/plugins/variable-plugin/variables/autofilled.d.ts +2 -0
- package/declarations/addon/plugins/variable-plugin/variables/index.d.ts +1 -0
- package/package.json +6 -5
- package/pnpm-lock.yaml +99 -95
- package/translations/en-US.yaml +6 -0
- package/translations/nl-BE.yaml +6 -0
- package/addon/components/variable-plugin/utils/label-input.hbs +0 -11
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';
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import { service } from '@ember/service';
|
|
5
|
+
import { NodeSelection, type SayController } from '@lblod/ember-rdfa-editor';
|
|
6
|
+
import IntlService from 'ember-intl/services/intl';
|
|
7
|
+
import AuFormRow from '@appuniversum/ember-appuniversum/components/au-form-row';
|
|
8
|
+
import AuLabel from '@appuniversum/ember-appuniversum/components/au-label';
|
|
9
|
+
import AuButton from '@appuniversum/ember-appuniversum/components/au-button';
|
|
10
|
+
import AuCheckbox from '@appuniversum/ember-appuniversum/components/au-checkbox';
|
|
11
|
+
import AuNativeInput from '@lblod/ember-rdfa-editor-lblod-plugins/components/au-native-input';
|
|
12
|
+
import AuCard from '@appuniversum/ember-appuniversum/components/au-card';
|
|
13
|
+
import AuHeading from '@appuniversum/ember-appuniversum/components/au-heading';
|
|
14
|
+
import t from 'ember-intl/helpers/t';
|
|
15
|
+
import { on } from '@ember/modifier';
|
|
16
|
+
import { trackedReset } from 'tracked-toolbox';
|
|
17
|
+
import { EXT } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
|
|
18
|
+
import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory/data-factory';
|
|
19
|
+
import { getOutgoingTriple } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
|
|
20
|
+
import LabelInput from '../utils/label-input';
|
|
21
|
+
import {
|
|
22
|
+
ContentLiteralTerm,
|
|
23
|
+
SayLiteral,
|
|
24
|
+
SayNamedNode,
|
|
25
|
+
} from '@lblod/ember-rdfa-editor/core/say-data-factory';
|
|
26
|
+
type Args = {
|
|
27
|
+
controller: SayController;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type nodeProperty =
|
|
31
|
+
| {
|
|
32
|
+
predicate: string;
|
|
33
|
+
object: SayNamedNode<string>;
|
|
34
|
+
}
|
|
35
|
+
| {
|
|
36
|
+
predicate: string;
|
|
37
|
+
object: SayLiteral;
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
predicate: string;
|
|
41
|
+
object: ContentLiteralTerm;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default class AutoFilledVariableInsertComponent extends Component<Args> {
|
|
45
|
+
@service declare intl: IntlService;
|
|
46
|
+
|
|
47
|
+
// memo is the path to the trigger, which calls update
|
|
48
|
+
// see https://github.com/tracked-tools/tracked-toolbox?tab=readme-ov-file#trackedreset
|
|
49
|
+
// it's sort of badly explained in the docs, but it's a more generic version
|
|
50
|
+
// of localCopy, which we can't use here cause our derived state from the args
|
|
51
|
+
// is too complex to express as a string path
|
|
52
|
+
@trackedReset({
|
|
53
|
+
memo: 'args.controller.mainEditorState',
|
|
54
|
+
// using this as the first arg is special typescript syntax
|
|
55
|
+
// which allows you to explicitly type the this context, cause
|
|
56
|
+
// ts is not smart enough to know that
|
|
57
|
+
update(this: AutoFilledVariableInsertComponent) {
|
|
58
|
+
return this.convertToStringAttr;
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
convertToString: boolean = false;
|
|
62
|
+
|
|
63
|
+
@trackedReset({
|
|
64
|
+
memo: 'args.controller.mainEditorState',
|
|
65
|
+
update(this: AutoFilledVariableInsertComponent) {
|
|
66
|
+
return this.autofillKeyAttr;
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
autofillKey?: string;
|
|
70
|
+
|
|
71
|
+
@trackedReset({
|
|
72
|
+
memo: 'args.controller.mainEditorState',
|
|
73
|
+
update(this: AutoFilledVariableInsertComponent) {
|
|
74
|
+
return this.labelAttr;
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
label!: string;
|
|
78
|
+
|
|
79
|
+
get selectedVariable() {
|
|
80
|
+
const { selection } = this.controller.mainEditorState;
|
|
81
|
+
if (
|
|
82
|
+
selection instanceof NodeSelection &&
|
|
83
|
+
selection.node.type === this.controller.schema.nodes.autofilled_variable
|
|
84
|
+
) {
|
|
85
|
+
return {
|
|
86
|
+
node: selection.node,
|
|
87
|
+
pos: selection.from,
|
|
88
|
+
};
|
|
89
|
+
} else {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
get autofillKeyAttr() {
|
|
94
|
+
return this.selectedVariable?.node.attrs.autofillKey;
|
|
95
|
+
}
|
|
96
|
+
get convertToStringAttr() {
|
|
97
|
+
return this.selectedVariable?.node.attrs.convertToString;
|
|
98
|
+
}
|
|
99
|
+
get labelAttr() {
|
|
100
|
+
if (!this.selectedVariable) return '';
|
|
101
|
+
return getOutgoingTriple(this.selectedVariable.node.attrs, EXT('label'))
|
|
102
|
+
?.object.value;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
get showCard() {
|
|
106
|
+
return !!this.selectedVariable;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get controller() {
|
|
110
|
+
return this.args.controller;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get schema() {
|
|
114
|
+
return this.args.controller.schema;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get documentLanguage() {
|
|
118
|
+
return this.controller.documentLanguage;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@action
|
|
122
|
+
updateLabel(event: InputEvent) {
|
|
123
|
+
this.label = (event.target as HTMLInputElement).value;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@action
|
|
127
|
+
updateAutofillKey(event: InputEvent) {
|
|
128
|
+
this.autofillKey = (event.target as HTMLInputElement).value;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@action
|
|
132
|
+
updateConvertToString(value: boolean) {
|
|
133
|
+
this.convertToString = value;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@action
|
|
137
|
+
edit() {
|
|
138
|
+
if (this.selectedVariable) {
|
|
139
|
+
this.controller.withTransaction(
|
|
140
|
+
(tr) => {
|
|
141
|
+
const position = this.selectedVariable?.pos as number;
|
|
142
|
+
tr.setNodeAttribute(position, 'autofillKey', this.autofillKey);
|
|
143
|
+
tr.setNodeAttribute(
|
|
144
|
+
position,
|
|
145
|
+
'convertToString',
|
|
146
|
+
this.convertToString,
|
|
147
|
+
);
|
|
148
|
+
const oldProperties = this.selectedVariable?.node.attrs.properties;
|
|
149
|
+
const newProperties = oldProperties.filter(
|
|
150
|
+
(property: nodeProperty) =>
|
|
151
|
+
property.predicate !== EXT('label').full,
|
|
152
|
+
);
|
|
153
|
+
newProperties.push({
|
|
154
|
+
predicate: EXT('label').full,
|
|
155
|
+
object: sayDataFactory.literal(this.label || ''),
|
|
156
|
+
});
|
|
157
|
+
tr.setNodeAttribute(position, 'properties', newProperties);
|
|
158
|
+
return tr;
|
|
159
|
+
},
|
|
160
|
+
// because the variable pill contains a nested editor, when it's
|
|
161
|
+
// selected, the currentEditorView is the nested one. When you run
|
|
162
|
+
// withTransaction without the optional second argument, it defaults to using
|
|
163
|
+
// the current view.
|
|
164
|
+
//
|
|
165
|
+
// Here, we don't want that, cause we want to edit the outside node, not
|
|
166
|
+
// any node in the nested editor.
|
|
167
|
+
{ view: this.controller.mainEditorView },
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
<template>
|
|
172
|
+
{{#if this.showCard}}
|
|
173
|
+
<AuCard
|
|
174
|
+
@flex={{true}}
|
|
175
|
+
@divided={{true}}
|
|
176
|
+
@isOpenInitially={{true}}
|
|
177
|
+
@expandable={{true}}
|
|
178
|
+
@shadow={{true}}
|
|
179
|
+
@size='small'
|
|
180
|
+
as |c|
|
|
181
|
+
>
|
|
182
|
+
<c.header>
|
|
183
|
+
<AuHeading @level='3' @skin='6'>
|
|
184
|
+
{{t 'variable-plugin.enter-variable-value'}}
|
|
185
|
+
</AuHeading>
|
|
186
|
+
</c.header>
|
|
187
|
+
<c.content>
|
|
188
|
+
<AuFormRow>
|
|
189
|
+
<LabelInput
|
|
190
|
+
@label={{this.label}}
|
|
191
|
+
@updateLabel={{this.updateLabel}}
|
|
192
|
+
/>
|
|
193
|
+
</AuFormRow>
|
|
194
|
+
<AuFormRow>
|
|
195
|
+
<AuLabel for='autofill_key'>
|
|
196
|
+
{{t 'variable-plugin.autofill.autofillKey'}}
|
|
197
|
+
</AuLabel>
|
|
198
|
+
<AuNativeInput
|
|
199
|
+
id='autofill_key'
|
|
200
|
+
placeholder={{t
|
|
201
|
+
'variable-plugin.autofill.autofillKeyPlaceholder'
|
|
202
|
+
}}
|
|
203
|
+
@type='text'
|
|
204
|
+
@width='block'
|
|
205
|
+
value={{this.autofillKey}}
|
|
206
|
+
{{on 'input' this.updateAutofillKey}}
|
|
207
|
+
/>
|
|
208
|
+
</AuFormRow>
|
|
209
|
+
<AuFormRow>
|
|
210
|
+
<AuCheckbox
|
|
211
|
+
id='convert_to_string'
|
|
212
|
+
@checked={{this.convertToString}}
|
|
213
|
+
@onChange={{this.updateConvertToString}}
|
|
214
|
+
>
|
|
215
|
+
{{t 'variable-plugin.autofill.convertToString'}}
|
|
216
|
+
</AuCheckbox>
|
|
217
|
+
</AuFormRow>
|
|
218
|
+
<AuButton {{on 'click' this.edit}}>
|
|
219
|
+
{{t 'variable-plugin.button'}}
|
|
220
|
+
</AuButton>
|
|
221
|
+
</c.content>
|
|
222
|
+
</AuCard>
|
|
223
|
+
{{/if}}
|
|
224
|
+
</template>
|
|
225
|
+
}
|