@lblod/ember-rdfa-editor-lblod-plugins 2.0.1 → 2.1.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 +17 -0
- package/addon/components/citation-plugin/citation-insert.ts +27 -7
- package/addon/plugins/citation-plugin/index.ts +70 -23
- package/addon/plugins/citation-plugin/utils/legislation-types.ts +2 -1
- package/addon/plugins/citation-plugin/utils/process-match.ts +9 -5
- package/addon/plugins/standard-template-plugin/utils/nodes.ts +6 -0
- package/components/citation-plugin/citation-insert.d.ts +3 -1
- package/package.json +3 -3
- package/plugins/citation-plugin/index.d.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,23 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
## 2.1.0 (2023-02-06)
|
|
23
|
+
|
|
24
|
+
#### :rocket: Enhancement
|
|
25
|
+
* [#98](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/98) Improve citation plugin regex and improve citation type matching ([@elpoelma](https://github.com/elpoelma))
|
|
26
|
+
|
|
27
|
+
#### :bug: Bug Fix
|
|
28
|
+
* [#96](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/96) Fix insert-citation button not being enabled in correct context. ([@elpoelma](https://github.com/elpoelma))
|
|
29
|
+
* [#100](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/100) Prevent splitting of besluit related nodes ([@elpoelma](https://github.com/elpoelma))
|
|
30
|
+
* [#97](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/97) Fix: disallow splitting of besluit node ([@elpoelma](https://github.com/elpoelma))
|
|
31
|
+
|
|
32
|
+
#### :house: Internal
|
|
33
|
+
* [#99](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/99) Update editor to 2.1.0 ([@elpoelma](https://github.com/elpoelma))
|
|
34
|
+
|
|
35
|
+
#### Committers: 1
|
|
36
|
+
- Elena Poelman ([@elpoelma](https://github.com/elpoelma))
|
|
37
|
+
|
|
21
38
|
## 2.0.1 (2023-02-06)
|
|
22
39
|
|
|
23
40
|
#### :bug: Bug Fix
|
|
@@ -12,16 +12,20 @@ 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 {
|
|
15
|
+
import {
|
|
16
|
+
CitationPlugin,
|
|
17
|
+
CitationPluginConfig,
|
|
18
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
16
19
|
import {
|
|
17
20
|
LEGISLATION_TYPE_CONCEPTS,
|
|
18
21
|
LEGISLATION_TYPES,
|
|
19
22
|
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/legislation-types';
|
|
20
23
|
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
24
|
+
import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
|
|
21
25
|
|
|
22
26
|
interface Args {
|
|
23
27
|
controller: ProseController;
|
|
24
|
-
widgetArgs: { plugin: CitationPlugin };
|
|
28
|
+
widgetArgs: { plugin: CitationPlugin; config: CitationPluginConfig };
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
export default class EditorPluginsCitationInsertComponent extends Component<Args> {
|
|
@@ -30,6 +34,10 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
|
|
|
30
34
|
@tracked text = '';
|
|
31
35
|
@tracked legislationType: string | null = null;
|
|
32
36
|
|
|
37
|
+
get config() {
|
|
38
|
+
return this.args.widgetArgs.config;
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
get selectedLegislationTypeUri(): string {
|
|
34
42
|
return this.selectedLegislationType.value;
|
|
35
43
|
}
|
|
@@ -52,13 +60,25 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
|
|
|
52
60
|
}
|
|
53
61
|
|
|
54
62
|
get disableInsert() {
|
|
55
|
-
if (
|
|
63
|
+
if (this.controller.inEmbeddedView) {
|
|
56
64
|
return true;
|
|
57
65
|
}
|
|
58
|
-
const {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
const { selection } = this.controller.state;
|
|
67
|
+
if (this.config.type === 'ranges') {
|
|
68
|
+
const ranges = this.config.activeInRanges(this.controller.state);
|
|
69
|
+
for (const range of ranges) {
|
|
70
|
+
if (selection.from > range[0] && selection.from < range[1]) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
} else {
|
|
76
|
+
const nodeTypes = this.config.activeInNodeTypes(
|
|
77
|
+
this.controller.schema,
|
|
78
|
+
this.controller.state
|
|
79
|
+
);
|
|
80
|
+
return !findParentNodeOfType([...nodeTypes])(selection);
|
|
81
|
+
}
|
|
62
82
|
}
|
|
63
83
|
|
|
64
84
|
get plugin() {
|
|
@@ -19,31 +19,77 @@ import { changedDescendants } from '@lblod/ember-rdfa-editor-lblod-plugins/utils
|
|
|
19
19
|
|
|
20
20
|
const BASIC_MULTIPLANE_CHARACTER = '\u0021-\uFFFF'; // most of the characters used around the world
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// \w*decreet |
|
|
26
|
-
// omzendbrief |
|
|
27
|
-
// verdrag |
|
|
28
|
-
// grondwetswijziging |
|
|
29
|
-
// samenwerkingsakkoord |
|
|
30
|
-
// \w*wetboek |
|
|
31
|
-
// protocol |
|
|
32
|
-
// besluit[^\S\n]van[^\S\n]de[^\S\n]vlaamse[^\S\n]regering |
|
|
33
|
-
// geco[öo]rdineerde wetten |
|
|
34
|
-
// \w*wet |
|
|
35
|
-
// koninklijk[^\S\n]?besluit |
|
|
36
|
-
// ministerieel[^\S\n]?besluit |
|
|
37
|
-
// genummerd[^\S\n]?koninklijk[^\S\n]?besluit
|
|
38
|
-
// )
|
|
39
|
-
// [^\S\n]*
|
|
40
|
-
// (
|
|
41
|
-
// ([^\S\n] | [\u0021-\uFFFF\d;:'"()&\-_]){3,}
|
|
42
|
-
// )?
|
|
43
|
-
// )
|
|
22
|
+
/**
|
|
23
|
+
* regex for non-newline whitespace
|
|
24
|
+
*/
|
|
44
25
|
const NNWS = '[^\\S\\n]';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* match for a "decree"
|
|
29
|
+
*/
|
|
30
|
+
const DECREE = `\\w*decreet`;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* literally "letter that gets sent around"
|
|
34
|
+
*/
|
|
35
|
+
const MEMO = `omzendbrief`;
|
|
36
|
+
const TREATY = `verdrag`;
|
|
37
|
+
const CONSTITUTION_CHANGE = `grondwetswijziging`;
|
|
38
|
+
/**
|
|
39
|
+
* literally "agreement to collaborate"
|
|
40
|
+
*/
|
|
41
|
+
const COLLAB = `samenwerkingsakkoord`;
|
|
42
|
+
/**
|
|
43
|
+
* Literally "book of law", I suppose that's called a codex?
|
|
44
|
+
*/
|
|
45
|
+
const BOOK = `\\w*wetboek`;
|
|
46
|
+
const PROTOCOL = `protocol`;
|
|
47
|
+
/**
|
|
48
|
+
* match for the literal "of the flemish government"
|
|
49
|
+
*/
|
|
50
|
+
const VVR = `${NNWS}van${NNWS}de${NNWS}vlaamse${NNWS}regering`;
|
|
51
|
+
/**
|
|
52
|
+
* match for the literal "decision of the flemish government"
|
|
53
|
+
*/
|
|
54
|
+
const FLEMGOV = `besluit${VVR}`;
|
|
55
|
+
/**
|
|
56
|
+
* match for "coordinated laws"
|
|
57
|
+
* whatever that may be
|
|
58
|
+
*/
|
|
59
|
+
const COORD = `geco[öo]rdineerde${NNWS}wetten`;
|
|
60
|
+
/**
|
|
61
|
+
* Matches any kind of law
|
|
62
|
+
*/
|
|
63
|
+
const LAW = `\\w*wet`;
|
|
64
|
+
/**
|
|
65
|
+
* match for the literal "royal decision"
|
|
66
|
+
* "royal decree" might be a more meaningful translation to english, but don't read too much into these
|
|
67
|
+
* translations anyway
|
|
68
|
+
*/
|
|
69
|
+
const ROYAL = `koninklijk${NNWS}?besluit`;
|
|
70
|
+
/**
|
|
71
|
+
* same thing as above, but for ministers
|
|
72
|
+
*/
|
|
73
|
+
const MINISTERIAL = `ministerieel${NNWS}?besluit`;
|
|
74
|
+
/**
|
|
75
|
+
* match for "enumerated royal decision"
|
|
76
|
+
* no, we don't know the difference either
|
|
77
|
+
*/
|
|
78
|
+
const ENUM_ROYAL = `genummerd${NNWS}?${ROYAL}`;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The type of citation that we need to search for
|
|
82
|
+
*/
|
|
83
|
+
const TYPE = `${DECREE}|${MEMO}|${TREATY}|${CONSTITUTION_CHANGE}|${COLLAB}|${BOOK}|${PROTOCOL}|${FLEMGOV}|${COORD}|${LAW}|${ROYAL}|${MINISTERIAL}|${ENUM_ROYAL}`;
|
|
84
|
+
/**
|
|
85
|
+
* The monster regex that makes the citation plugin trigger.
|
|
86
|
+
* In restructuring, I've made sure that I didn't abstract away any of the capturing groups,
|
|
87
|
+
* only their content, so you can still see what's going on
|
|
88
|
+
*
|
|
89
|
+
* This regex uses named capturing groups, that's the "?<name>" syntax for easy parsing later
|
|
90
|
+
*/
|
|
45
91
|
export const CITATION_REGEX = new RegExp(
|
|
46
|
-
`((?<type
|
|
92
|
+
`((?<type>${TYPE})${NNWS}*(?<searchTerms>(${NNWS}|[${BASIC_MULTIPLANE_CHARACTER};:'"()&-_]){3,})?)`,
|
|
47
93
|
'uidg'
|
|
48
94
|
);
|
|
49
95
|
export type CitationSchema = Schema<string, 'citation'>;
|
|
@@ -116,6 +162,7 @@ export function setupCitationPlugin(
|
|
|
116
162
|
desiredLocation: 'insertSidebar',
|
|
117
163
|
componentName: 'citation-plugin/citation-insert',
|
|
118
164
|
widgetArgs: {
|
|
165
|
+
config,
|
|
119
166
|
plugin,
|
|
120
167
|
},
|
|
121
168
|
},
|
|
@@ -16,8 +16,9 @@ const LEGISLATION_TYPES = {
|
|
|
16
16
|
samenwerkingsakkoord:
|
|
17
17
|
'https://data.vlaanderen.be/id/concept/AardWetgeving/Samenwerkingsakkoord',
|
|
18
18
|
wetboek: 'https://data.vlaanderen.be/id/concept/AardWetgeving/Wetboek',
|
|
19
|
+
// do not change this url without doublechecking, yes they actually did encode the ö in the url
|
|
19
20
|
'gecoördineerde wetten':
|
|
20
|
-
'https://data.vlaanderen.be/id/concept/AardWetgeving/
|
|
21
|
+
'https://data.vlaanderen.be/id/concept/AardWetgeving/Geco%C3%B6rdineerde+Wet',
|
|
21
22
|
'bijzondere wet':
|
|
22
23
|
'https://data.vlaanderen.be/id/concept/AardWetgeving/BijzondereWet',
|
|
23
24
|
'genummerd koninklijk besluit':
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isBlank } from '@ember/utils';
|
|
2
|
-
import { LEGISLATION_TYPES
|
|
2
|
+
import { LEGISLATION_TYPES } from './legislation-types';
|
|
3
3
|
import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
|
|
4
4
|
|
|
5
5
|
const STOP_WORDS = ['het', 'de', 'van', 'tot', 'dat'];
|
|
@@ -46,7 +46,7 @@ export default function processMatch(
|
|
|
46
46
|
)
|
|
47
47
|
.join(' ');
|
|
48
48
|
if (type) {
|
|
49
|
-
let typeLabel:
|
|
49
|
+
let typeLabel: string;
|
|
50
50
|
if (/\w+decreet/i.test(type)) {
|
|
51
51
|
typeLabel = 'decreet';
|
|
52
52
|
cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;
|
|
@@ -59,19 +59,23 @@ export default function processMatch(
|
|
|
59
59
|
typeLabel = 'wetboek';
|
|
60
60
|
} else if (/geco[oö]rdineerde[^\S\n]wetten/i.test(type)) {
|
|
61
61
|
typeLabel = 'gecoördineerde wetten';
|
|
62
|
-
} else if (/
|
|
62
|
+
} else if (/grondwets?wijziging/i.test(type)) {
|
|
63
63
|
typeLabel = 'grondwetswijziging';
|
|
64
64
|
} else if (/grondwet/i.test(type)) {
|
|
65
65
|
typeLabel = 'grondwet';
|
|
66
|
+
} else if (/bijzondere wet/i.test(type)) {
|
|
67
|
+
typeLabel = 'bijzondere wet';
|
|
66
68
|
} else if (/\w+wet/i.test(type)) {
|
|
67
69
|
typeLabel = 'wet';
|
|
68
70
|
cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;
|
|
69
71
|
} else if (/wet/i.test(type)) {
|
|
70
72
|
typeLabel = 'wet';
|
|
71
73
|
} else {
|
|
72
|
-
typeLabel =
|
|
74
|
+
typeLabel = type.toLowerCase().trim();
|
|
73
75
|
}
|
|
74
|
-
const typeUri =
|
|
76
|
+
const typeUri =
|
|
77
|
+
(LEGISLATION_TYPES as Record<string, string>)[typeLabel] ||
|
|
78
|
+
LEGISLATION_TYPES['decreet'];
|
|
75
79
|
return {
|
|
76
80
|
text: cleanedSearchTerms,
|
|
77
81
|
legislationTypeUri: typeUri,
|
|
@@ -20,6 +20,7 @@ export const title: NodeSpec = {
|
|
|
20
20
|
content: 'paragraph+',
|
|
21
21
|
inline: false,
|
|
22
22
|
defining: true,
|
|
23
|
+
canSplit: false,
|
|
23
24
|
attrs: {
|
|
24
25
|
...rdfaAttrs,
|
|
25
26
|
property: {
|
|
@@ -49,6 +50,7 @@ export const description: NodeSpec = {
|
|
|
49
50
|
group: 'block',
|
|
50
51
|
content: 'block+',
|
|
51
52
|
inline: false,
|
|
53
|
+
canSplit: false,
|
|
52
54
|
attrs: {
|
|
53
55
|
...rdfaAttrs,
|
|
54
56
|
property: {
|
|
@@ -78,6 +80,7 @@ export const motivering: NodeSpec = {
|
|
|
78
80
|
group: 'block',
|
|
79
81
|
content: 'block+',
|
|
80
82
|
inline: false,
|
|
83
|
+
canSplit: false,
|
|
81
84
|
attrs: {
|
|
82
85
|
...rdfaAttrs,
|
|
83
86
|
property: {
|
|
@@ -107,6 +110,7 @@ export const article_container: NodeSpec = {
|
|
|
107
110
|
group: 'block',
|
|
108
111
|
content: '(block|besluit_article)+',
|
|
109
112
|
inline: false,
|
|
113
|
+
canSplit: false,
|
|
110
114
|
attrs: {
|
|
111
115
|
...rdfaAttrs,
|
|
112
116
|
property: {
|
|
@@ -301,6 +305,8 @@ export const besluit: NodeSpec = {
|
|
|
301
305
|
content: 'block*title?block*description?block*motivering?block*',
|
|
302
306
|
inline: false,
|
|
303
307
|
defining: true,
|
|
308
|
+
isolating: true,
|
|
309
|
+
canSplit: false,
|
|
304
310
|
attrs: {
|
|
305
311
|
...rdfaAttrs,
|
|
306
312
|
property: {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { ProseController } 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 { CitationPlugin } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
4
|
+
import { CitationPlugin, CitationPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
|
|
5
5
|
interface Args {
|
|
6
6
|
controller: ProseController;
|
|
7
7
|
widgetArgs: {
|
|
8
8
|
plugin: CitationPlugin;
|
|
9
|
+
config: CitationPluginConfig;
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
12
|
export default class EditorPluginsCitationInsertComponent extends Component<Args> {
|
|
@@ -13,6 +14,7 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
|
|
|
13
14
|
legislationTypeUri: string;
|
|
14
15
|
text: string;
|
|
15
16
|
legislationType: string | null;
|
|
17
|
+
get config(): CitationPluginConfig;
|
|
16
18
|
get selectedLegislationTypeUri(): string;
|
|
17
19
|
get selectedLegislationType(): {
|
|
18
20
|
label: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lblod/ember-rdfa-editor-lblod-plugins",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
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.6.0",
|
|
64
64
|
"@glimmer/component": "^1.1.2",
|
|
65
65
|
"@glimmer/tracking": "^1.1.2",
|
|
66
|
-
"@lblod/ember-rdfa-editor": "^2.0
|
|
66
|
+
"@lblod/ember-rdfa-editor": "^2.1.0",
|
|
67
67
|
"@rdfjs/types": "^1.1.0",
|
|
68
68
|
"@release-it-plugins/lerna-changelog": "^5.0.0",
|
|
69
69
|
"@tsconfig/ember": "^1.0.1",
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"node": "12.* || 14.* || >= 16"
|
|
153
153
|
},
|
|
154
154
|
"volta": {
|
|
155
|
-
"node": "
|
|
155
|
+
"node": "18.14.0"
|
|
156
156
|
},
|
|
157
157
|
"ember": {
|
|
158
158
|
"edition": "octane"
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Decoration, DecorationSet, EditorState, InlineDecorationSpec, MarkSpec, NodeType, ProsePlugin, Schema, WidgetSpec } from '@lblod/ember-rdfa-editor';
|
|
2
|
+
/**
|
|
3
|
+
* The monster regex that makes the citation plugin trigger.
|
|
4
|
+
* In restructuring, I've made sure that I didn't abstract away any of the capturing groups,
|
|
5
|
+
* only their content, so you can still see what's going on
|
|
6
|
+
*
|
|
7
|
+
* This regex uses named capturing groups, that's the "?<name>" syntax for easy parsing later
|
|
8
|
+
*/
|
|
2
9
|
export declare const CITATION_REGEX: RegExp;
|
|
3
10
|
export type CitationSchema = Schema<string, 'citation'>;
|
|
4
11
|
export interface CitationDecorationSpec extends InlineDecorationSpec {
|