@lblod/ember-rdfa-editor-lblod-plugins 3.0.0 → 4.0.1
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 +39 -1
- package/README.md +183 -141
- package/addon/components/article-structure-plugin/structure-card.hbs +7 -4
- package/addon/components/citation-plugin/citation-card.hbs +4 -0
- package/addon/components/citation-plugin/citation-card.ts +15 -8
- package/addon/components/citation-plugin/citation-insert.ts +1 -13
- package/addon/components/rdfa-date-plugin/card.ts +2 -2
- package/addon/components/table-of-contents-plugin/toolbar-button.ts +37 -6
- package/addon/components/variable-plugin/insert-variable-card.hbs +23 -9
- package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +2 -2
- package/addon/plugins/citation-plugin/index.ts +16 -6
- package/addon/plugins/citation-plugin/utils/cited-text.ts +5 -4
- package/addon/plugins/variable-plugin/utils/constants.ts +1 -0
- package/app/styles/variable-plugin.scss +1 -1
- package/components/citation-plugin/citation-card.d.ts +3 -2
- package/components/citation-plugin/citation-insert.d.ts +1 -4
- package/components/rdfa-date-plugin/card.d.ts +1 -1
- package/package.json +3 -3
- package/addon/plugins/citation-plugin/marks/citation.ts +0 -27
- package/plugins/citation-plugin/marks/citation.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.0.1] - 2023-03-27
|
|
11
|
+
|
|
12
|
+
### Dependencies
|
|
13
|
+
- bump `ember-rdfa-editor` to v3.4.1
|
|
14
|
+
|
|
15
|
+
## [4.0.0] - 2023-03-27
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Ensure citation suggestions are only updated when search-text or document-legislation-type updates.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- Feature: make citation use the new link node
|
|
22
|
+
- BREAKING: citation mark has been removed
|
|
23
|
+
- Table of contents now is able to be inserted in the corresponding place instead of always being inserted at position 0
|
|
24
|
+
- Change paragraph symbol to §
|
|
25
|
+
- Update schema on dummy page to make articles insertable in empty document
|
|
26
|
+
- Add padding to structure card
|
|
27
|
+
- Placeholder text when inserting date
|
|
28
|
+
|
|
29
|
+
### Removed:
|
|
30
|
+
- Removal of prosemirror-plugin dependency of `CitationPlugin::CitationInsert` component.
|
|
31
|
+
|
|
32
|
+
## [3.1.0] - 2023-03-02
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
- Article paragraph numbering is no longer continuous
|
|
36
|
+
- Fixed white-space issue in variables
|
|
37
|
+
### Changed
|
|
38
|
+
- Use `AuModalContainer` component instead of #ember-appuniversum-wormhole element in dummy app
|
|
39
|
+
- Improved documentation of the plugins
|
|
40
|
+
|
|
41
|
+
### Dependencies
|
|
42
|
+
- bump `ember-rdfa-editor` to v3.3.0
|
|
43
|
+
- bump `ember-rdfa-editor` to v3.4.0
|
|
44
|
+
|
|
10
45
|
## [3.0.0] - 2023-02-27
|
|
11
46
|
|
|
12
47
|
### Changed
|
|
@@ -344,7 +379,10 @@ add onclick handler to pencil icon in variable plugin
|
|
|
344
379
|
|
|
345
380
|
# Changelog
|
|
346
381
|
|
|
347
|
-
[unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/
|
|
382
|
+
[unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.1...HEAD
|
|
383
|
+
[4.0.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.0...v4.0.1
|
|
384
|
+
[4.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v3.1.0...v4.0.0
|
|
385
|
+
[3.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v3.0.0...v3.1.0
|
|
348
386
|
[3.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.2...v3.0.0
|
|
349
387
|
[2.1.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.1...v2.1.2
|
|
350
388
|
[2.1.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.0...v2.1.1
|
package/README.md
CHANGED
|
@@ -26,7 +26,6 @@ ember install ember-rdfa-editor-lblod-plugins
|
|
|
26
26
|
This addon contains the following editor plugins:
|
|
27
27
|
* besluit-type-plugin
|
|
28
28
|
* citaten-plugin
|
|
29
|
-
* generate-template-plugin
|
|
30
29
|
* import-snippet-plugin
|
|
31
30
|
* insert-variable-plugin
|
|
32
31
|
* rdfa-date-plugin
|
|
@@ -35,40 +34,75 @@ This addon contains the following editor plugins:
|
|
|
35
34
|
* table-of-contents-plugin
|
|
36
35
|
* template-variable-plugin
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
This is typically done in the following manner:
|
|
37
|
+
You can configure your editor like this:
|
|
40
38
|
```hbs
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
<EditorContainer
|
|
40
|
+
@editorOptions={{hash
|
|
41
|
+
showRdfa='true'
|
|
42
|
+
showRdfaHighlight='true'
|
|
43
|
+
showRdfaHover='true'
|
|
44
|
+
showPaper='true'
|
|
45
|
+
showToolbarBottom=null
|
|
46
|
+
}}
|
|
47
|
+
@showRdfaBlocks={{this.controller.showRdfaBlocks}}
|
|
48
|
+
>
|
|
49
|
+
<:top>
|
|
50
|
+
{...}
|
|
51
|
+
</:top>
|
|
52
|
+
<:default>
|
|
53
|
+
<Editor
|
|
47
54
|
@plugins={{this.plugins}}
|
|
48
|
-
|
|
55
|
+
@schema={{this.schema}}
|
|
56
|
+
@nodeViews={{this.nodeViews}}
|
|
57
|
+
@rdfaEditorInit={{this.rdfaEditorInit}}/>
|
|
58
|
+
</:default>
|
|
59
|
+
<:aside>
|
|
60
|
+
{...}
|
|
61
|
+
</:aside>
|
|
62
|
+
</EditorContainer>
|
|
49
63
|
```
|
|
50
|
-
|
|
64
|
+
You will have 2 anchor points where to put your plugins: `top` for a toolbar, and `aside` for plugin cards.
|
|
65
|
+
|
|
51
66
|
|
|
52
67
|
## besluit-type-plugin
|
|
53
68
|
|
|
54
69
|
Plugin which allows a user to change the type of a [besluit](https://data.vlaanderen.be/ns/besluit#Besluit).
|
|
55
70
|
|
|
56
|
-
This plugin
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.plugins = ["besluit"];
|
|
71
|
+
This plugin needs to be added to the toolbar as a dropdown with the following syntax:
|
|
72
|
+
```hbs
|
|
73
|
+
<BesluitTypePlugin::ToolbarDropdown @controller={{this.controller}}/>
|
|
60
74
|
```
|
|
75
|
+
|
|
61
76
|
## citaten-plugin
|
|
62
77
|
Plugin which allows a user to insert references to a legal resource or legal expression into the document.
|
|
63
78
|
|
|
64
|
-
This plugin
|
|
65
|
-
|
|
79
|
+
This plugin provides a card that needs to be added to the sidebar of the editor like
|
|
80
|
+
```hbs
|
|
81
|
+
<CitationPlugin::CitationCard
|
|
82
|
+
@controller={{this.controller}}
|
|
83
|
+
@plugin={{this.citationPlugin}}
|
|
84
|
+
/>
|
|
85
|
+
```
|
|
86
|
+
Being this.citationPlugin a tracked reference to the plugin created with the function exported from the package and the wished configuration
|
|
66
87
|
```js
|
|
67
|
-
|
|
88
|
+
import { citationPlugin } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
89
|
+
|
|
90
|
+
@tracked citationPlugin = citationPlugin({
|
|
91
|
+
type: 'nodes',
|
|
92
|
+
activeInNodeTypes(schema) {
|
|
93
|
+
return new Set([schema.nodes.motivering]);
|
|
94
|
+
},
|
|
95
|
+
});
|
|
68
96
|
```
|
|
69
97
|
|
|
98
|
+
Configuration:
|
|
99
|
+
- type: it can be 'nodes' or 'ranges' if nodes is selected you are expected to pass the `activeInNodeTypes` function, otherwise you should pass the `activeInRanges` function
|
|
100
|
+
- activeInNodeTypes: it's a function that gets the prosemirror schema and the state of the actual instance of the editor and returns a `Set` of nodetypes where the plugin should be active
|
|
101
|
+
- activeInRanges: it's a function that gets the state of the actual instance of the editor and returns an array of ranges for the plugin to be active in, for example `[[0,50], [70,100]]`
|
|
102
|
+
- regex: you can provide your custom regex to detect citations, if not the default one will be used
|
|
103
|
+
|
|
70
104
|
### Using the plugin
|
|
71
|
-
|
|
105
|
+
If used with the example configuration provided this plugin can be triggered by typing one of the following in the correct RDFa context (the [besluit:motivering](http://data.vlaanderen.be/ns/besluit#motivering) of a [besluit:Besluit](https://data.vlaanderen.be/ns/besluit#Besluit)).
|
|
72
106
|
|
|
73
107
|
* [specification]**decreet** [words to search for] *(e.g. "gemeentedecreet wijziging")*
|
|
74
108
|
* **omzendbrief** [words to search for]
|
|
@@ -86,30 +120,12 @@ This plugin can be triggered by typing one of the following in the correct RDFa
|
|
|
86
120
|
|
|
87
121
|
You should be able to add a reference manually by clicking on the `Insert` > `Insert reference` item in the Insert menu located on the top right of the editor. This will open the advanced search window. **Note** that this will only be avaliable in the proper context (see above in this section).
|
|
88
122
|
|
|
89
|
-
## generate-template-plugin
|
|
90
|
-
Plugin which provides an editor command which replaces resource URIs in a document by a generic template URI containing `${generateUuid()}`. This allows for the generation of template documents. Template documents can be used by other applications, these other applications can create an instance of a template by replacing the `${generateUuid()}` keywords by real URIs.
|
|
91
|
-
|
|
92
|
-
This plugin can be configured in the following manner:
|
|
93
|
-
|
|
94
|
-
```js
|
|
95
|
-
this.plugins = ["generate-template"];
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
The command can be used by executing:
|
|
99
|
-
|
|
100
|
-
```js
|
|
101
|
-
controller.executeCommand('generateTemplate', controller);
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Where `controller` is an editor-controller.
|
|
105
|
-
|
|
106
123
|
## import-snippet-plugin
|
|
107
124
|
Plugin allowing importing of external RDFA snippets and inserting it in the document.
|
|
108
125
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this.plugins = ["import-snippet"];
|
|
126
|
+
The plugin has a card that needs to be added to the sidebar:
|
|
127
|
+
```hbs
|
|
128
|
+
<ImportSnippetPlugin::Card @controller={{this.controller}}/>
|
|
113
129
|
```
|
|
114
130
|
|
|
115
131
|
### Using the plugin
|
|
@@ -134,68 +150,90 @@ When opening a new document, users will get the option to either include the sni
|
|
|
134
150
|
## insert-variable-plugin
|
|
135
151
|
Plugin which allows users to insert variable placeholders into a document.
|
|
136
152
|
|
|
153
|
+
The plugin provides a card that needs to be attached to the editor sidebar like
|
|
154
|
+
```hbs
|
|
155
|
+
<VariablePlugin::InsertVariableCard
|
|
156
|
+
@controller={{this.controller}}
|
|
157
|
+
@options={{this.config.variable}}
|
|
158
|
+
/>
|
|
159
|
+
```
|
|
160
|
+
|
|
137
161
|
### Configuring the plugin
|
|
138
162
|
|
|
139
|
-
The plugin can be configured through the following optional attributes:
|
|
163
|
+
The plugin can be configured through the following optional attributes that can be added as a json to the options attribute of the card:
|
|
140
164
|
- `publisher`: the URI of a specific codelist publisher which you can use if you want to filter the codelists by its publisher.
|
|
141
165
|
- `defaultEndpoint`: The default endpoint where the codelists are fetched, this is also the variable that gets passed to the fetchSubtypes and template function
|
|
142
166
|
- `variableTypes`: a custom list of variable types you want the plugin to use. This list can contain the following default variable types: `text`, `number`,`date`,`location` and `codelist`. Additionally this list can also contain custom variable types, configured by the following three sub-attributes:
|
|
143
167
|
* `label`: the label of the custom variable type
|
|
144
168
|
* `fetchSubTypes` (optional): a function which returns a list of possible variable values. The function takes two optional arguments: an `endpoint` and a `publisher`.
|
|
145
|
-
* `
|
|
169
|
+
* `constructor`: function which returns a prosemirror node to be inserted, the function takes three arguments, the prosemirror `schema`, the `endpoint` and the `selectedSubtype` if you are using subtypes.
|
|
146
170
|
|
|
147
171
|
#### Example
|
|
148
172
|
|
|
149
173
|
```js
|
|
150
174
|
{
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
175
|
+
publisher: 'http://data.lblod.info/id/bestuurseenheden/141d9d6b-54af-4d17-b313-8d1c30bc3f5b',
|
|
176
|
+
defaultEndpoint: 'https://dev.roadsigns.lblod.info/sparql',
|
|
177
|
+
variableTypes: [
|
|
178
|
+
'text',
|
|
179
|
+
'number',
|
|
180
|
+
'date',
|
|
181
|
+
'location',
|
|
182
|
+
'codelist',
|
|
183
|
+
{
|
|
184
|
+
label: 'Simple Variable',
|
|
185
|
+
constructor: (schema) => {
|
|
186
|
+
const mappingURI = `http://data.lblod.info/mappings/${uuidv4()}`;
|
|
187
|
+
const variableInstance = `http://data.lblod.info/variables/${uuidv4()}`;
|
|
188
|
+
return schema.node(
|
|
189
|
+
'variable',
|
|
161
190
|
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
<span class="mark-highlight-manual">\${Simple variable}</span>
|
|
166
|
-
</span>
|
|
167
|
-
`,
|
|
191
|
+
mappingResource: mappingURI,
|
|
192
|
+
variableInstance,
|
|
193
|
+
type: 'Simple Variable',
|
|
168
194
|
},
|
|
195
|
+
schema.node('placeholder', { placeholderText: 'text' })
|
|
196
|
+
);
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
label: 'Complex Variable',
|
|
201
|
+
fetchSubtypes: async (endpoint, publisher) => {
|
|
202
|
+
const subtypes = [
|
|
169
203
|
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const codelists = [
|
|
173
|
-
{
|
|
174
|
-
uri: '1',
|
|
175
|
-
label: '1',
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
uri: '2',
|
|
179
|
-
label: '2',
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
uri: '3',
|
|
183
|
-
label: '3',
|
|
184
|
-
},
|
|
185
|
-
];
|
|
186
|
-
return codelists;
|
|
187
|
-
},
|
|
188
|
-
template: (endpoint, selectedCodelist) => `
|
|
189
|
-
<span property="ext:codelist" resource="${selectedCodelist.uri}"></span>
|
|
190
|
-
<span property="dct:type" content="location"></span>
|
|
191
|
-
<span property="dct:source" resource="${endpoint}"></span>
|
|
192
|
-
<span property="ext:content" datatype="xsd:date">
|
|
193
|
-
<span class="mark-highlight-manual">\${${selectedCodelist.label}}</span>
|
|
194
|
-
</span>
|
|
195
|
-
`,
|
|
204
|
+
uri: '1',
|
|
205
|
+
label: '1',
|
|
196
206
|
},
|
|
197
|
-
|
|
198
|
-
|
|
207
|
+
{
|
|
208
|
+
uri: '2',
|
|
209
|
+
label: '2',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
uri: '3',
|
|
213
|
+
label: '3',
|
|
214
|
+
},
|
|
215
|
+
];
|
|
216
|
+
return subtypes;
|
|
217
|
+
},
|
|
218
|
+
constructor: (schema, endpoint, selectedSubtype) => {
|
|
219
|
+
const mappingURI = `http://data.lblod.info/mappings/${uuidv4()}`;
|
|
220
|
+
const variableInstance = `http://data.lblod.info/variables/${uuidv4()}`;
|
|
221
|
+
return schema.node(
|
|
222
|
+
'variable',
|
|
223
|
+
{
|
|
224
|
+
type: 'Complex Variable',
|
|
225
|
+
mappingResource: mappingURI,
|
|
226
|
+
subTypeResource: selectedSubtype?.uri,
|
|
227
|
+
variableInstance,
|
|
228
|
+
source: endpoint,
|
|
229
|
+
},
|
|
230
|
+
schema.node('placeholder', {
|
|
231
|
+
placeholderText: selectedSubtype?.label ?? '',
|
|
232
|
+
})
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
],
|
|
199
237
|
}
|
|
200
238
|
```
|
|
201
239
|
### Using the plugin
|
|
@@ -206,21 +244,39 @@ When the insert-variable-plugin is enabled, users will have the option to insert
|
|
|
206
244
|
## rdfa-date-plugin
|
|
207
245
|
Plugin to insert and modify semantic dates and timestamps in an editor document.
|
|
208
246
|
|
|
209
|
-
This plugin
|
|
247
|
+
This plugin provides a card to modify dates that needs to be added to the editor sidebar like
|
|
210
248
|
|
|
211
|
-
```
|
|
212
|
-
|
|
249
|
+
```hbs
|
|
250
|
+
<RdfaDatePlugin::Card
|
|
251
|
+
@controller={{this.controller}}
|
|
252
|
+
@options={{this.config.date}}/>
|
|
213
253
|
```
|
|
214
254
|
|
|
255
|
+
And a insert button to insert new dates that needs to be added to the insert part of the sidebar:
|
|
256
|
+
```hbs
|
|
257
|
+
<RdfaDatePlugin::Insert
|
|
258
|
+
@controller={{this.controller}}
|
|
259
|
+
@options={{this.config.date}}
|
|
260
|
+
/>
|
|
261
|
+
```
|
|
215
262
|
|
|
263
|
+
You will also need to add the date node with the following configuration (being the insertDate and insertDateTime the placeholder strings):
|
|
264
|
+
```js
|
|
265
|
+
date: date({
|
|
266
|
+
placeholder: {
|
|
267
|
+
insertDate: this.intl.t('date-plugin.insert.date'),
|
|
268
|
+
insertDateTime: this.intl.t('date-plugin.insert.datetime'),
|
|
269
|
+
},
|
|
270
|
+
}),
|
|
271
|
+
```
|
|
216
272
|
|
|
217
273
|
## roadsign-regulation-plugin
|
|
218
274
|
A plugin that fetches data from the mow regulation and roadsign registry and allows users to insert roadsign regulations inside an editor document.
|
|
219
275
|
|
|
220
|
-
This plugin
|
|
276
|
+
This plugin provides a card that needs to be added to the editor sidebar like:
|
|
221
277
|
|
|
222
|
-
```
|
|
223
|
-
this.
|
|
278
|
+
```hbs
|
|
279
|
+
<RoadsignRegulationPlugin::RoadsignRegulationCard @controller={{this.controller}}/>
|
|
224
280
|
```
|
|
225
281
|
|
|
226
282
|
The default endpoint the plugin will query is https://roadsigns.lblod.info/sparql . This can be overwritten by setting `roadsignRegulationPlugin.endpoint` in your `config/environment.js`.
|
|
@@ -228,10 +284,9 @@ The default endpoint the plugin will query is https://roadsigns.lblod.info/sparq
|
|
|
228
284
|
## standard-template-plugin
|
|
229
285
|
Plugin which allows users to insert standard templates in the editor. Depending on the position of the cursor or selected text, a dropdown will appear in the toolbar of the editor that lets you insert a template for the proper context at the location of the cursor.
|
|
230
286
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.plugins = ["standard-template"];
|
|
287
|
+
In order to use this plugin you will need to add its card:
|
|
288
|
+
```hbs
|
|
289
|
+
<StandardTemplatePlugin::Card @controller={{this.controller}}/>
|
|
235
290
|
```
|
|
236
291
|
|
|
237
292
|
### Template resource used by the plugin
|
|
@@ -246,72 +301,59 @@ When creating a template in your database, the following properties are used by
|
|
|
246
301
|
|
|
247
302
|
### Using the plugin
|
|
248
303
|
|
|
249
|
-
|
|
250
304
|
The plugin will search for RDFa contexts in the content of the editor and the editor itself. Based on the contexts, the plugin will show possible templates to be added at the location of the cursor. E.g. if an element in the editor has the `typeof="besluit:BehandelingVanAgendapunt"` attribute, the plugin will show the templates related to [`besluit:BehandelingVanAgendapunt`](http://data.vlaanderen.be/ns/besluit#BehandelingVanAgendapunt) in the dropdown menu. This attribute can be set on an element in the content of the editor or predefined in the editor itself.
|
|
251
305
|
|
|
252
306
|
## table-of-contents-plugin
|
|
253
307
|
|
|
254
308
|
Plugin implementing an auto-refreshing table of contents using an ember-rdfa-editor inline component.
|
|
255
309
|
|
|
256
|
-
In order to enable the plugin you need to add
|
|
257
|
-
|
|
310
|
+
In order to enable the plugin you need to add the table of contents button to the toolbar and the table of contents node view to the list of editor node views.
|
|
311
|
+
```hbs
|
|
312
|
+
<TableOfContentsPlugin::ToolbarButton @controller={{this.editor}}/>
|
|
313
|
+
```
|
|
258
314
|
|
|
259
|
-
```
|
|
260
|
-
this.
|
|
261
|
-
{ name: 'table-of-contents',
|
|
262
|
-
options: {
|
|
263
|
-
config: {
|
|
264
|
-
sectionPredicate: 'https://say.data.gift/ns/hasPart',
|
|
265
|
-
value: {
|
|
266
|
-
predicate: 'https://say.data.gift/ns/heading',
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
sectionPredicate: 'https://say.data.gift/ns/hasParagraph',
|
|
271
|
-
value: '§',
|
|
272
|
-
},
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
]
|
|
315
|
+
```
|
|
316
|
+
tableOfContentsView(this.config.tableOfContents)(controller),
|
|
276
317
|
```
|
|
277
318
|
|
|
278
|
-
|
|
319
|
+
|
|
320
|
+
### Configuring the plugin with a custom config
|
|
321
|
+
|
|
322
|
+
You can configure the nodeview with the hiearchy of the nodes
|
|
279
323
|
|
|
280
324
|
```js
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
sectionPredicate: 'https://say.data.gift/ns/hasPart',
|
|
288
|
-
value: {
|
|
289
|
-
predicate: 'https://say.data.gift/ns/heading',
|
|
290
|
-
},
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
sectionPredicate: 'https://say.data.gift/ns/hasParagraph',
|
|
294
|
-
value: '§',
|
|
295
|
-
},
|
|
296
|
-
],
|
|
297
|
-
},
|
|
298
|
-
{},
|
|
299
|
-
false
|
|
300
|
-
);
|
|
325
|
+
{
|
|
326
|
+
nodeHierarchy: [
|
|
327
|
+
'title|chapter|section|subsection|article',
|
|
328
|
+
'structure_header|article_header',
|
|
329
|
+
],
|
|
330
|
+
},
|
|
301
331
|
```
|
|
332
|
+
|
|
333
|
+
|
|
302
334
|
## template-variable-plugin
|
|
303
335
|
|
|
304
336
|
Editor plugin which allows you to interact with placeholders created by the insert-variable-plugin.
|
|
305
337
|
|
|
306
|
-
|
|
338
|
+
For enabling it, you need to add the card provided by the plugin to the editor sidebar
|
|
339
|
+
```hbs
|
|
340
|
+
<VariablePlugin::TemplateVariableCard @controller={{this.controller}}/>
|
|
341
|
+
```
|
|
307
342
|
|
|
308
|
-
You
|
|
343
|
+
You will also need to add the variable node to the list of nodes of your prosemirror schema and the variable view to the list of nodeviews like `variable: variableView(controller)` imported from:
|
|
309
344
|
|
|
310
345
|
```js
|
|
311
|
-
|
|
346
|
+
import {
|
|
347
|
+
variable,
|
|
348
|
+
variableView,
|
|
349
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/variable-plugin/nodes';
|
|
350
|
+
|
|
312
351
|
```
|
|
313
352
|
|
|
314
|
-
|
|
353
|
+
### Configuring the plugin
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
You can configure the plugin in your `environment.js` file:
|
|
315
357
|
|
|
316
358
|
```js
|
|
317
359
|
templateVariablePlugin: {
|
|
@@ -27,10 +27,13 @@
|
|
|
27
27
|
</Item>
|
|
28
28
|
<Item>
|
|
29
29
|
{{#unless this.currentStructureType.noUnwrap}}
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
<div class="au-u-padding-tiny">
|
|
31
|
+
<AuToggleSwitch
|
|
32
|
+
@label={{t "article-structure-plugin.remove.content"}}
|
|
33
|
+
@checked={{this.removeStructureContent}}
|
|
34
|
+
@onChange={{this.setRemoveStructureContent}}
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
34
37
|
{{/unless}}
|
|
35
38
|
<AuButton
|
|
36
39
|
@icon="bin"
|
|
@@ -42,6 +42,21 @@ export default class CitationCardComponent extends Component<Args> {
|
|
|
42
42
|
@tracked decision: Decision | null = null;
|
|
43
43
|
@tracked cardText: string | null = null;
|
|
44
44
|
@tracked cardLegislationType: string | null = null;
|
|
45
|
+
@tracked documentLegislationType: Option<string>;
|
|
46
|
+
@tracked documentText: Option<string>;
|
|
47
|
+
|
|
48
|
+
@action
|
|
49
|
+
update() {
|
|
50
|
+
if (this.activeDecoration) {
|
|
51
|
+
const { legislationTypeUri, searchText } = this.activeDecoration?.spec;
|
|
52
|
+
if (legislationTypeUri !== this.documentLegislationType) {
|
|
53
|
+
this.documentLegislationType = legislationTypeUri;
|
|
54
|
+
}
|
|
55
|
+
if (searchText !== this.documentText) {
|
|
56
|
+
this.documentText = searchText;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
45
60
|
|
|
46
61
|
get controller(): SayController {
|
|
47
62
|
return this.args.controller;
|
|
@@ -64,14 +79,6 @@ export default class CitationCardComponent extends Component<Args> {
|
|
|
64
79
|
return this.decorations?.find(from, to)[0];
|
|
65
80
|
}
|
|
66
81
|
|
|
67
|
-
get documentLegislationType(): Option<string> {
|
|
68
|
-
return this.activeDecoration?.spec.legislationTypeUri;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
get documentText(): Option<string> {
|
|
72
|
-
return this.activeDecoration?.spec.searchText;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
82
|
get searchText(): string {
|
|
76
83
|
return (this.cardText ?? this.documentText) || '';
|
|
77
84
|
}
|
|
@@ -12,10 +12,7 @@ import {
|
|
|
12
12
|
Decision,
|
|
13
13
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/vlaamse-codex';
|
|
14
14
|
import { citedText } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/cited-text';
|
|
15
|
-
import {
|
|
16
|
-
CitationPlugin,
|
|
17
|
-
CitationPluginConfig,
|
|
18
|
-
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
15
|
+
import { CitationPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
19
16
|
import {
|
|
20
17
|
LEGISLATION_TYPE_CONCEPTS,
|
|
21
18
|
LEGISLATION_TYPES,
|
|
@@ -25,7 +22,6 @@ import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
|
|
|
25
22
|
|
|
26
23
|
interface Args {
|
|
27
24
|
controller: SayController;
|
|
28
|
-
plugin: CitationPlugin;
|
|
29
25
|
config: CitationPluginConfig;
|
|
30
26
|
}
|
|
31
27
|
|
|
@@ -84,14 +80,6 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
|
|
|
84
80
|
}
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
get plugin() {
|
|
88
|
-
return this.args.plugin;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get activeRanges() {
|
|
92
|
-
return this.plugin.getState(this.controller.mainEditorState)?.activeRanges;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
83
|
get controller() {
|
|
96
84
|
return this.args.controller;
|
|
97
85
|
}
|
|
@@ -157,8 +157,8 @@ export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
|
157
157
|
return null;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
get pickerDate(): Date {
|
|
161
|
-
return this.documentDate
|
|
160
|
+
get pickerDate(): Option<Date> {
|
|
161
|
+
return this.documentDate;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
@action
|
|
@@ -38,12 +38,43 @@ export default class TableOfContentsCardComponent extends Component<Args> {
|
|
|
38
38
|
);
|
|
39
39
|
} else {
|
|
40
40
|
const { schema } = this.controller;
|
|
41
|
-
this.controller.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
const state = this.controller.activeEditorState;
|
|
42
|
+
let replacePosition: number | undefined = undefined;
|
|
43
|
+
state.doc.descendants((node, pos, parent, index) => {
|
|
44
|
+
if (
|
|
45
|
+
replacePosition === undefined &&
|
|
46
|
+
state.doc.canReplaceWith(
|
|
47
|
+
index,
|
|
48
|
+
index,
|
|
49
|
+
schema.nodes['table_of_contents']
|
|
50
|
+
)
|
|
51
|
+
) {
|
|
52
|
+
replacePosition = pos;
|
|
53
|
+
} else if (
|
|
54
|
+
index === state.doc.childCount - 1 &&
|
|
55
|
+
replacePosition === undefined &&
|
|
56
|
+
state.doc.canReplaceWith(
|
|
57
|
+
index + 1,
|
|
58
|
+
index + 1,
|
|
59
|
+
schema.nodes['table_of_contents']
|
|
60
|
+
)
|
|
61
|
+
) {
|
|
62
|
+
replacePosition = pos + node.nodeSize;
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
});
|
|
66
|
+
if (replacePosition !== undefined) {
|
|
67
|
+
this.controller.withTransaction(
|
|
68
|
+
(transaction) => {
|
|
69
|
+
return transaction.replaceWith(
|
|
70
|
+
replacePosition as number,
|
|
71
|
+
replacePosition as number,
|
|
72
|
+
schema.node('table_of_contents')
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
{ view: this.controller.mainEditorView }
|
|
76
|
+
);
|
|
77
|
+
}
|
|
47
78
|
}
|
|
48
79
|
}
|
|
49
80
|
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{{#if this.showCard}}
|
|
2
|
-
<AuCard
|
|
2
|
+
<AuCard
|
|
3
|
+
@flex={{true}}
|
|
4
|
+
@divided={{true}}
|
|
5
|
+
@isOpenInitially={{true}}
|
|
6
|
+
@expandable={{true}}
|
|
7
|
+
@shadow={{true}}
|
|
8
|
+
@size='small'
|
|
9
|
+
as |c|
|
|
10
|
+
>
|
|
3
11
|
<c.header>
|
|
4
|
-
<AuHeading @level=
|
|
5
|
-
{{t
|
|
12
|
+
<AuHeading @level='3' @skin='6'>
|
|
13
|
+
{{t 'variable-plugin.insert-variable'}}
|
|
6
14
|
</AuHeading>
|
|
7
15
|
</c.header>
|
|
8
16
|
<c.content>
|
|
@@ -11,7 +19,8 @@
|
|
|
11
19
|
@searchEnabled={{false}}
|
|
12
20
|
@options={{this.variablesArray}}
|
|
13
21
|
@selected={{this.selectedVariable}}
|
|
14
|
-
@onChange={{this.updateSelectedVariable}}
|
|
22
|
+
@onChange={{this.updateSelectedVariable}}
|
|
23
|
+
as |variable|
|
|
15
24
|
>
|
|
16
25
|
{{variable.label}}
|
|
17
26
|
</PowerSelect>
|
|
@@ -21,14 +30,19 @@
|
|
|
21
30
|
@searchEnabled={{false}}
|
|
22
31
|
@options={{this.subtypes}}
|
|
23
32
|
@selected={{this.selectedSubtype}}
|
|
24
|
-
@onChange={{this.updateSubtype}}
|
|
33
|
+
@onChange={{this.updateSubtype}}
|
|
34
|
+
as |subtype|
|
|
25
35
|
>
|
|
26
36
|
{{subtype.label}}
|
|
27
37
|
</PowerSelect>
|
|
28
38
|
{{/if}}
|
|
29
|
-
<AuButton
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
<AuButton
|
|
40
|
+
{{on 'click' this.insert}}
|
|
41
|
+
@disabled={{or
|
|
42
|
+
(not this.selectedVariable)
|
|
43
|
+
(and this.hasSubtype (not this.selectedSubtype))
|
|
44
|
+
}}
|
|
45
|
+
>{{t 'variable-plugin.button'}}</AuButton>
|
|
32
46
|
</c.content>
|
|
33
47
|
</AuCard>
|
|
34
|
-
{{/if}}
|
|
48
|
+
{{/if}}
|
|
@@ -22,7 +22,7 @@ export const articleParagraphSpec: StructureSpec = {
|
|
|
22
22
|
},
|
|
23
23
|
remove: 'article-structure-plugin.remove.paragraph',
|
|
24
24
|
},
|
|
25
|
-
continuous:
|
|
25
|
+
continuous: false,
|
|
26
26
|
noUnwrap: true,
|
|
27
27
|
constructor: ({ schema, number, intl }) => {
|
|
28
28
|
const numberConverted = number?.toString() ?? '1';
|
|
@@ -76,7 +76,7 @@ export const article_paragraph: NodeSpec = {
|
|
|
76
76
|
typeof: node.attrs.typeof as string,
|
|
77
77
|
resource: node.attrs.resource as string,
|
|
78
78
|
},
|
|
79
|
-
['span', { contenteditable: false }, '
|
|
79
|
+
['span', { contenteditable: false }, '§'],
|
|
80
80
|
[
|
|
81
81
|
'span',
|
|
82
82
|
{
|
|
@@ -7,12 +7,14 @@ import {
|
|
|
7
7
|
NodeType,
|
|
8
8
|
PNode,
|
|
9
9
|
ProsePlugin,
|
|
10
|
+
ResolvedPos,
|
|
10
11
|
Schema,
|
|
11
12
|
} from '@lblod/ember-rdfa-editor';
|
|
12
13
|
import processMatch, {
|
|
13
14
|
RegexpMatchArrayWithIndices,
|
|
14
15
|
} from './utils/process-match';
|
|
15
16
|
import { changedDescendants } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/changed-descendants';
|
|
17
|
+
import { findParentNodeOfTypeClosestToPos } from '@curvenote/prosemirror-utils';
|
|
16
18
|
|
|
17
19
|
const BASIC_MULTIPLANE_CHARACTER = '\u0021-\uFFFF'; // most of the characters used around the world
|
|
18
20
|
|
|
@@ -206,6 +208,7 @@ function calculateDecorationsInNodes(
|
|
|
206
208
|
decsToAdd,
|
|
207
209
|
schema,
|
|
208
210
|
config.regex,
|
|
211
|
+
newDoc,
|
|
209
212
|
decsToRemove,
|
|
210
213
|
oldDecorations
|
|
211
214
|
);
|
|
@@ -254,7 +257,12 @@ function calculateDecorationsInRanges(
|
|
|
254
257
|
activeRanges: [number, number][]
|
|
255
258
|
): { decorations: DecorationSet; activeRanges: [number, number][] } {
|
|
256
259
|
const decorationsToAdd: Decoration[] = [];
|
|
257
|
-
const collector = collectDecorations(
|
|
260
|
+
const collector = collectDecorations(
|
|
261
|
+
decorationsToAdd,
|
|
262
|
+
schema,
|
|
263
|
+
config.regex,
|
|
264
|
+
doc
|
|
265
|
+
);
|
|
258
266
|
|
|
259
267
|
for (const [start, end] of activeRanges) {
|
|
260
268
|
doc.nodesBetween(start, end, collector);
|
|
@@ -269,15 +277,17 @@ function collectDecorations(
|
|
|
269
277
|
decsToAdd: Decoration[],
|
|
270
278
|
schema: CitationSchema,
|
|
271
279
|
regex: RegExp = CITATION_REGEX,
|
|
280
|
+
doc: PNode,
|
|
272
281
|
decsToRemove?: Decoration[],
|
|
273
282
|
oldDecs?: DecorationSet
|
|
274
283
|
) {
|
|
275
284
|
return function (node: PNode, pos: number): boolean {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
)
|
|
285
|
+
const resolvedPos: ResolvedPos = doc.resolve(pos);
|
|
286
|
+
const link = findParentNodeOfTypeClosestToPos(
|
|
287
|
+
resolvedPos,
|
|
288
|
+
schema.nodes.link
|
|
289
|
+
);
|
|
290
|
+
if (node.isText && node.text && !link) {
|
|
281
291
|
if (decsToRemove && oldDecs) {
|
|
282
292
|
decsToRemove.push(
|
|
283
293
|
...oldDecs.find(
|
|
@@ -8,12 +8,13 @@ export function citedText(
|
|
|
8
8
|
title: string,
|
|
9
9
|
uri: string
|
|
10
10
|
): PNode {
|
|
11
|
-
return schema.
|
|
12
|
-
|
|
11
|
+
return unwrap(schema.nodes.link).create(
|
|
12
|
+
{
|
|
13
13
|
href: uri,
|
|
14
14
|
property: 'eli:cites',
|
|
15
15
|
typeof: 'eli:LegalExpression',
|
|
16
16
|
__rdfaId: uuid(),
|
|
17
|
-
}
|
|
18
|
-
|
|
17
|
+
},
|
|
18
|
+
[schema.text(title)]
|
|
19
|
+
);
|
|
19
20
|
}
|
|
@@ -18,13 +18,14 @@ export default class CitationCardComponent extends Component<Args> {
|
|
|
18
18
|
decision: Decision | null;
|
|
19
19
|
cardText: string | null;
|
|
20
20
|
cardLegislationType: string | null;
|
|
21
|
+
documentLegislationType: Option<string>;
|
|
22
|
+
documentText: Option<string>;
|
|
23
|
+
update(): void;
|
|
21
24
|
get controller(): SayController;
|
|
22
25
|
get showCard(): false | Option<CitationDecoration>;
|
|
23
26
|
get plugin(): CitationPlugin;
|
|
24
27
|
get decorations(): import("prosemirror-view").DecorationSet | undefined;
|
|
25
28
|
get activeDecoration(): Option<CitationDecoration>;
|
|
26
|
-
get documentLegislationType(): Option<string>;
|
|
27
|
-
get documentText(): Option<string>;
|
|
28
29
|
get searchText(): string;
|
|
29
30
|
get legislationTypes(): string[];
|
|
30
31
|
get selectedLegislationType(): {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
3
3
|
import { Article, Decision } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/vlaamse-codex';
|
|
4
|
-
import {
|
|
4
|
+
import { CitationPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
5
5
|
interface Args {
|
|
6
6
|
controller: SayController;
|
|
7
|
-
plugin: CitationPlugin;
|
|
8
7
|
config: CitationPluginConfig;
|
|
9
8
|
}
|
|
10
9
|
export default class EditorPluginsCitationInsertComponent extends Component<Args> {
|
|
@@ -20,8 +19,6 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
|
|
|
20
19
|
};
|
|
21
20
|
selectLegislationType(type: string): void;
|
|
22
21
|
get disableInsert(): boolean;
|
|
23
|
-
get plugin(): CitationPlugin;
|
|
24
|
-
get activeRanges(): [number, number][] | undefined;
|
|
25
22
|
get controller(): SayController;
|
|
26
23
|
openModal(): void;
|
|
27
24
|
closeModal(): void;
|
|
@@ -28,7 +28,7 @@ export default class RdfaDatePluginCardComponent extends Component<Args> {
|
|
|
28
28
|
get dateFormatType(): string;
|
|
29
29
|
get customDateFormatError(): ValidationError | null;
|
|
30
30
|
get humanError(): string | null;
|
|
31
|
-
get pickerDate(): Date
|
|
31
|
+
get pickerDate(): Option<Date>;
|
|
32
32
|
showTooltip(): void;
|
|
33
33
|
hideTooltip(): void;
|
|
34
34
|
changeDate(date: Date): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lblod/ember-rdfa-editor-lblod-plugins",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@embroider/test-setup": "^1.8.3",
|
|
64
64
|
"@glimmer/component": "^1.1.2",
|
|
65
65
|
"@glimmer/tracking": "^1.1.2",
|
|
66
|
-
"@lblod/ember-rdfa-editor": "^3.
|
|
66
|
+
"@lblod/ember-rdfa-editor": "^3.4.1",
|
|
67
67
|
"@rdfjs/types": "^1.1.0",
|
|
68
68
|
"@release-it/keep-a-changelog": "^3.1.0",
|
|
69
69
|
"@tsconfig/ember": "^1.0.1",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
},
|
|
144
144
|
"peerDependencies": {
|
|
145
145
|
"@appuniversum/ember-appuniversum": "^2.4.2",
|
|
146
|
-
"@lblod/ember-rdfa-editor": "^3.
|
|
146
|
+
"@lblod/ember-rdfa-editor": "^3.4.1",
|
|
147
147
|
"ember-concurrency": "^2.3.7"
|
|
148
148
|
},
|
|
149
149
|
"engines": {
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { getRdfaAttrs, MarkSpec, rdfaAttrs } from '@lblod/ember-rdfa-editor';
|
|
2
|
-
|
|
3
|
-
export const citation: MarkSpec = {
|
|
4
|
-
attrs: { test: { default: 'yeet' }, ...rdfaAttrs },
|
|
5
|
-
inclusive: false,
|
|
6
|
-
group: 'linkmarks',
|
|
7
|
-
excludes: 'linkmarks',
|
|
8
|
-
parseDOM: [
|
|
9
|
-
{
|
|
10
|
-
tag: 'a[href]',
|
|
11
|
-
getAttrs(dom) {
|
|
12
|
-
if (typeof dom === 'string') {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
const type = dom.attributes.getNamedItem('typeof')?.value;
|
|
16
|
-
const property = dom.attributes.getNamedItem('property')?.value;
|
|
17
|
-
if (type === 'eli:LegalExpression' && property === 'eli:cites') {
|
|
18
|
-
return getRdfaAttrs(dom);
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
toDOM(node) {
|
|
25
|
-
return ['a', { ...node.attrs, class: 'annotation' }, 0];
|
|
26
|
-
},
|
|
27
|
-
};
|