@lblod/ember-rdfa-editor-lblod-plugins 0.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/LICENSE.md +9 -0
- package/README.md +37 -0
- package/addon-main.js +4 -0
- package/dist/_app_/components/besluit-type-plugin/besluit-type-select.js +1 -0
- package/dist/_app_/components/besluit-type-plugin/toolbar-dropdown.js +1 -0
- package/dist/_app_/components/citaten-plugin/citaat-card.js +1 -0
- package/dist/_app_/components/citaten-plugin/citaat-insert.js +1 -0
- package/dist/_app_/components/citaten-plugin/citations/article-list.js +1 -0
- package/dist/_app_/components/citaten-plugin/citations/article-preview.js +1 -0
- package/dist/_app_/components/citaten-plugin/citations/decision-detail.js +1 -0
- package/dist/_app_/components/citaten-plugin/citations/decision-list.js +1 -0
- package/dist/_app_/components/citaten-plugin/citations/decision-preview.js +1 -0
- package/dist/_app_/components/citaten-plugin/citations/search-modal.js +1 -0
- package/dist/_app_/components/citaten-plugin/helpers/alert-load-error.js +1 -0
- package/dist/_app_/components/citaten-plugin/helpers/alert-no-items.js +1 -0
- package/dist/_app_/components/import-snippet-plugin/card.js +1 -0
- package/dist/_app_/components/rdfa-date-plugin/rdfa-date-plugin-card.js +1 -0
- package/dist/_app_/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +1 -0
- package/dist/_app_/components/rdfa-date-plugin/rdfa-date-time-picker.js +1 -0
- package/dist/_app_/components/standard-template-plugin/template-card.js +1 -0
- package/dist/_app_/components/standard-template-plugin/template-provider.js +1 -0
- package/dist/_app_/components/table-of-contents-plugin/card.js +1 -0
- package/dist/_app_/components/table-of-contents-plugin/inline-components/outline.js +1 -0
- package/dist/_app_/components/table-of-contents-plugin/inline-components/table-of-contents.js +1 -0
- package/dist/_app_/initializers/plugin-initializer.js +1 -0
- package/dist/_app_/models/template.js +1 -0
- package/dist/_app_/serializers/application.js +1 -0
- package/dist/_app_/services/import-rdfa-snippet.js +1 -0
- package/dist/_app_/services/standard-template-plugin.js +1 -0
- package/dist/_rollupPluginBabelHelpers-537ad14b.js +48 -0
- package/dist/_rollupPluginBabelHelpers-537ad14b.js.map +1 -0
- package/dist/components/besluit-type-plugin/besluit-type-select.js +30 -0
- package/dist/components/besluit-type-plugin/besluit-type-select.js.map +1 -0
- package/dist/components/besluit-type-plugin/toolbar-dropdown.js +292 -0
- package/dist/components/besluit-type-plugin/toolbar-dropdown.js.map +1 -0
- package/dist/components/citaten-plugin/citaat-card.js +367 -0
- package/dist/components/citaten-plugin/citaat-card.js.map +1 -0
- package/dist/components/citaten-plugin/citaat-insert.js +84 -0
- package/dist/components/citaten-plugin/citaat-insert.js.map +1 -0
- package/dist/components/citaten-plugin/citations/article-list.js +10 -0
- package/dist/components/citaten-plugin/citations/article-list.js.map +1 -0
- package/dist/components/citaten-plugin/citations/article-preview.js +10 -0
- package/dist/components/citaten-plugin/citations/article-preview.js.map +1 -0
- package/dist/components/citaten-plugin/citations/decision-detail.js +123 -0
- package/dist/components/citaten-plugin/citations/decision-detail.js.map +1 -0
- package/dist/components/citaten-plugin/citations/decision-list.js +10 -0
- package/dist/components/citaten-plugin/citations/decision-list.js.map +1 -0
- package/dist/components/citaten-plugin/citations/decision-preview.js +10 -0
- package/dist/components/citaten-plugin/citations/decision-preview.js.map +1 -0
- package/dist/components/citaten-plugin/citations/search-modal.js +282 -0
- package/dist/components/citaten-plugin/citations/search-modal.js.map +1 -0
- package/dist/components/citaten-plugin/helpers/alert-load-error.js +10 -0
- package/dist/components/citaten-plugin/helpers/alert-load-error.js.map +1 -0
- package/dist/components/citaten-plugin/helpers/alert-no-items.js +10 -0
- package/dist/components/citaten-plugin/helpers/alert-no-items.js.map +1 -0
- package/dist/components/import-snippet-plugin/card.js +99 -0
- package/dist/components/import-snippet-plugin/card.js.map +1 -0
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-card.js +85 -0
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-card.js.map +1 -0
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +23 -0
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-insert.js.map +1 -0
- package/dist/components/rdfa-date-plugin/rdfa-date-time-picker.js +91 -0
- package/dist/components/rdfa-date-plugin/rdfa-date-time-picker.js.map +1 -0
- package/dist/components/standard-template-plugin/template-card.js +15 -0
- package/dist/components/standard-template-plugin/template-card.js.map +1 -0
- package/dist/components/standard-template-plugin/template-provider.js +109 -0
- package/dist/components/standard-template-plugin/template-provider.js.map +1 -0
- package/dist/components/table-of-contents-plugin/card.js +52 -0
- package/dist/components/table-of-contents-plugin/card.js.map +1 -0
- package/dist/components/table-of-contents-plugin/inline-components/outline.js +10 -0
- package/dist/components/table-of-contents-plugin/inline-components/outline.js.map +1 -0
- package/dist/components/table-of-contents-plugin/inline-components/table-of-contents.js +92 -0
- package/dist/components/table-of-contents-plugin/inline-components/table-of-contents.js.map +1 -0
- package/dist/constants-af958fcd.js +12 -0
- package/dist/constants-af958fcd.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/initializers/plugin-initializer.js +307 -0
- package/dist/initializers/plugin-initializer.js.map +1 -0
- package/dist/legislation-types-4d487cb9.js +26 -0
- package/dist/legislation-types-4d487cb9.js.map +1 -0
- package/dist/models/template.js +48 -0
- package/dist/models/template.js.map +1 -0
- package/dist/serializers/application.js +10 -0
- package/dist/serializers/application.js.map +1 -0
- package/dist/services/import-rdfa-snippet.js +178 -0
- package/dist/services/import-rdfa-snippet.js.map +1 -0
- package/dist/services/standard-template-plugin.js +53 -0
- package/dist/services/standard-template-plugin.js.map +1 -0
- package/dist/styles/citaten-plugin.scss +50 -0
- package/dist/styles/test.css +0 -0
- package/dist/vlaamse-codex-187fe526.js +304 -0
- package/dist/vlaamse-codex-187fe526.js.map +1 -0
- package/package.json +117 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { _ as _applyDecoratedDescriptor, a as _initializerDefineProperty, b as _defineProperty } from '../../_rollupPluginBabelHelpers-537ad14b.js';
|
|
2
|
+
import { setComponentTemplate } from '@ember/component';
|
|
3
|
+
import { hbs } from 'ember-cli-htmlbars';
|
|
4
|
+
import Component from '@glimmer/component';
|
|
5
|
+
import { tracked } from '@glimmer/tracking';
|
|
6
|
+
import { task, timeout } from 'ember-concurrency';
|
|
7
|
+
import { action } from '@ember/object';
|
|
8
|
+
import { capitalize } from '@ember/string';
|
|
9
|
+
import { L as LEGISLATION_TYPES, a as LEGISLATION_TYPE_CONCEPTS } from '../../legislation-types-4d487cb9.js';
|
|
10
|
+
import { isBlank } from '@ember/utils';
|
|
11
|
+
import { f as fetchDecisions, c as cleanCaches } from '../../vlaamse-codex-187fe526.js';
|
|
12
|
+
import { task as task$1 } from 'ember-resources/util/ember-concurrency';
|
|
13
|
+
|
|
14
|
+
var TEMPLATE = hbs("{{#if this.showCard}}\n <AuCard @flex={{true}} @divided={{true}} @isOpenInitially={{true}} @expandable={{true}} @shadow={{true}} @size=\"small\" as |c|>\n <c.header>\n <AuHeading @level=\"3\" @skin=\"6\">{{t \"citaten-plugin.card.title\"}}</AuHeading>\n </c.header>\n <c.content>\n <div class=\"au-o-flow au-o-flow--small\">\n <AuFormRow>\n <AuLabel for=\"typeofdocument\" @inline={{false}} @required={{false}} @error={{false}} @warning={{false}}>{{t \"citaten-plugin.search.type\"}}</AuLabel>\n <PowerSelect\n id=\"typeofdocument\"\n @allowClear={{false}}\n @disabled={{false}}\n @searchEnabled={{true}}\n @loadingMessage=\"{{t \"citaten-plugin.citaten-plugin.alert.loading\"}}\"\n @noMatchesMessage=\"{{t \"citaten-plugin.citaten-plugin.alert.no-results\"}}\"\n @searchMessage=\"{{t \"citaten-plugin.citaten-plugin.search.placeholder\"}}\"\n @options={{this.legislationTypes}}\n @selected={{this.legislationSelected}}\n @onChange={{this.selectLegislationType}}\n class=\"au-u-1-1\"\n as |type|>\n {{type}}\n </PowerSelect>\n </AuFormRow>\n <AuFormRow>\n <AuLabel for=\"searchterm\" @inline={{false}} @required={{false}} @error={{false}} @warning={{false}}>{{t \"citaten-plugin.search.term\"}}</AuLabel>\n <AuInput\n id=\"searchterm\"\n @type=\"text\"\n @width=\"block\"\n @icon=\"search\"\n @iconAlignment=\"right\"\n @value={{this.text}}\n placeholder={{t \"citaten-plugin.search.placeholder\"}}\n {{on \"input\" (perform this.updateSearch)}}/>\n </AuFormRow>\n <AuFormRow>\n <AuButton @skin=\"link\" @icon=\"search\" @iconAlignment=\"left\" {{on \"click\" this.openSearchModal}}>{{t \"citaten-plugin.search.advanced\"}}</AuButton>\n </AuFormRow>\n </div>\n </c.content>\n <c.footer class=\"au-u-background-gray-100 au-u-padding-none\">\n {{#if this.decisionResource.isRunning}}\n <AuLoader /><span class=\"au-u-hidden-visually\">{{t \"citaten-plugin.alert.loading\"}}</span>\n {{else}}\n {{#if this.error}}\n <CitatenPlugin::Helpers::AlertLoadError @fullSize={{false}} @error={{this.error}} />\n {{else}}\n <AuToolbar\n @border=\"bottom\"\n @skin=\"none\"\n class=\"au-u-padding-small\" >\n <AuHeading @skin=\"6\" @level=\"4\">{{t \"citaten-plugin.card.suggestions\"}}</AuHeading>\n </AuToolbar>\n <div class=\"citaten--decision-list au-u-margin-none au-u-padding-top-tiny au-u-padding-bottom-tiny\">\n <CitatenPlugin::Citations::DecisionList\n @decisions={{this.decisionResource.value}}\n @onCitationInsert={{this.insertDecisionCitation}}\n @onCitationDetails={{this.openDecisionDetailModal}} />\n </div>\n {{/if}}\n {{/if}}\n </c.footer>\n </AuCard>\n{{/if}}\n\n{{#if this.showModal}}\n <CitatenPlugin::Citations::SearchModal\n @closeModal={{this.closeModal}}\n @insertDecisionCitation={{this.insertDecisionCitation}}\n @insertArticleCitation={{this.insertArticleCitation}}\n @selectedDecision={{this.decision}}\n @legislationTypeUri={{this.legislationTypeUri}}\n @text={{this.text}} />\n{{/if}}\n");
|
|
15
|
+
|
|
16
|
+
const STOP_WORDS = ['het', 'de', 'van', 'tot', 'dat'];
|
|
17
|
+
const DATE_REGEX = new RegExp('(\\d{1,2})\\s(\\w+)\\s(\\d{2,4})', 'g');
|
|
18
|
+
const INVISIBLE_SPACE = '\u200B';
|
|
19
|
+
const SPACES_REGEX = new RegExp('[\\s${UNBREAKABLE_SPACE}]+');
|
|
20
|
+
function processMatch(match) {
|
|
21
|
+
const matchgroups = match.groups;
|
|
22
|
+
const type = matchgroups[2];
|
|
23
|
+
const searchTerms = matchgroups[3];
|
|
24
|
+
let cleanedSearchTerms = cleanupText(searchTerms).split(SPACES_REGEX).filter(word => !isBlank(word) && word.length > 3 && !STOP_WORDS.includes(word)).join(' ');
|
|
25
|
+
let typeLabel;
|
|
26
|
+
if (/\w+decreet/i.test(type)) {
|
|
27
|
+
typeLabel = 'decreet';
|
|
28
|
+
cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;
|
|
29
|
+
} else if (/decreet/i.test(type)) {
|
|
30
|
+
typeLabel = 'decreet';
|
|
31
|
+
} else if (/\w+wetboek/i.test(type)) {
|
|
32
|
+
typeLabel = 'wetboek';
|
|
33
|
+
cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;
|
|
34
|
+
} else if (/wetboek/i.test(type)) {
|
|
35
|
+
typeLabel = 'wetboek';
|
|
36
|
+
} else if (/geco[oö]rdineerde[^\S\n]wetten/i.test(type)) {
|
|
37
|
+
typeLabel = 'gecoördineerde wetten';
|
|
38
|
+
} else if (/grondwetswijziging/i.test(type)) {
|
|
39
|
+
typeLabel = 'grondwetswijziging';
|
|
40
|
+
} else if (/grondwet/i.test(type)) {
|
|
41
|
+
typeLabel = 'grondwet';
|
|
42
|
+
} else if (/\w+wet/i.test(type)) {
|
|
43
|
+
typeLabel = 'wet';
|
|
44
|
+
cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;
|
|
45
|
+
} else if (/wet/i.test(type)) {
|
|
46
|
+
typeLabel = 'wet';
|
|
47
|
+
} else {
|
|
48
|
+
typeLabel = type.toLowerCase().trim();
|
|
49
|
+
}
|
|
50
|
+
const typeUri = LEGISLATION_TYPES[typeLabel] || LEGISLATION_TYPES['decreet'];
|
|
51
|
+
return {
|
|
52
|
+
text: cleanedSearchTerms,
|
|
53
|
+
legislationTypeUri: typeUri,
|
|
54
|
+
range: match.groupRanges[1]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function cleanupText(text) {
|
|
58
|
+
if (!text) return '';
|
|
59
|
+
const {
|
|
60
|
+
textWithoutDates
|
|
61
|
+
} = extractDates(text);
|
|
62
|
+
const textWithoutOddChars = textWithoutDates.replace(new RegExp(`[,.:"()&${INVISIBLE_SPACE}]`, 'g'), '');
|
|
63
|
+
const articleIndex = textWithoutOddChars.indexOf('artikel');
|
|
64
|
+
return articleIndex >= 0 ? textWithoutOddChars.slice(0, articleIndex) : textWithoutOddChars;
|
|
65
|
+
}
|
|
66
|
+
function extractDates(text) {
|
|
67
|
+
let date;
|
|
68
|
+
const matches = [];
|
|
69
|
+
while ((date = DATE_REGEX.exec(text)) !== null) {
|
|
70
|
+
matches.push(date);
|
|
71
|
+
}
|
|
72
|
+
let textWithoutDates = text;
|
|
73
|
+
for (let match of matches) {
|
|
74
|
+
textWithoutDates = textWithoutDates.replace(match[0], '');
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
dates: matches,
|
|
78
|
+
textWithoutDates
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var _dec, _dec2, _dec3, _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13;
|
|
83
|
+
const BASIC_MULTIPLANE_CHARACTER = '\u0021-\uFFFF'; // most of the characters used around the world
|
|
84
|
+
|
|
85
|
+
// Regex nicely structured:
|
|
86
|
+
// (
|
|
87
|
+
// (
|
|
88
|
+
// \w*decreet |
|
|
89
|
+
// omzendbrief |
|
|
90
|
+
// verdrag |
|
|
91
|
+
// grondwetswijziging |
|
|
92
|
+
// samenwerkingsakkoord |
|
|
93
|
+
// \w*wetboek |
|
|
94
|
+
// protocol |
|
|
95
|
+
// besluit[^\S\n]van[^\S\n]de[^\S\n]vlaamse[^\S\n]regering |
|
|
96
|
+
// geco[öo]rdineerde wetten |
|
|
97
|
+
// \w*wet |
|
|
98
|
+
// koninklijk[^\S\n]?besluit |
|
|
99
|
+
// ministerieel[^\S\n]?besluit |
|
|
100
|
+
// genummerd[^\S\n]?koninklijk[^\S\n]?besluit
|
|
101
|
+
// )
|
|
102
|
+
// [^\S\n]*
|
|
103
|
+
// (
|
|
104
|
+
// ([^\S\n] | [\u0021-\uFFFF\d;:'"()&\-_]){3,}
|
|
105
|
+
// )?
|
|
106
|
+
// )
|
|
107
|
+
const NNWS = '[^\\S\\n]';
|
|
108
|
+
const CITATION_REGEX = new RegExp(`((\\w*decreet|omzendbrief|verdrag|grondwetswijziging|samenwerkingsakkoord|\\w*wetboek|protocol|besluit${NNWS}van${NNWS}de${NNWS}vlaamse${NNWS}regering|geco[öo]rdineerde${NNWS}wetten|\\w*wet|koninklijk${NNWS}?besluit|ministerieel${NNWS}?besluit|genummerd${NNWS}?koninklijk${NNWS}?besluit|\\w*${NNWS}?besluit)${NNWS}*((${NNWS}|[${BASIC_MULTIPLANE_CHARACTER};:'"()&-_]){3,})?)`, 'uig');
|
|
109
|
+
let CitaatCardComponent = (_dec = task({
|
|
110
|
+
restartable: true
|
|
111
|
+
}), _dec2 = task({
|
|
112
|
+
restartable: true
|
|
113
|
+
}), _dec3 = task({
|
|
114
|
+
restartable: true
|
|
115
|
+
}), (_class = class CitaatCardComponent extends Component {
|
|
116
|
+
constructor() {
|
|
117
|
+
super(...arguments);
|
|
118
|
+
_initializerDefineProperty(this, "pageNumber", _descriptor, this);
|
|
119
|
+
_initializerDefineProperty(this, "pageSize", _descriptor2, this);
|
|
120
|
+
_initializerDefineProperty(this, "totalSize", _descriptor3, this);
|
|
121
|
+
_initializerDefineProperty(this, "decisions", _descriptor4, this);
|
|
122
|
+
_initializerDefineProperty(this, "error", _descriptor5, this);
|
|
123
|
+
_initializerDefineProperty(this, "showModal", _descriptor6, this);
|
|
124
|
+
_initializerDefineProperty(this, "showCard", _descriptor7, this);
|
|
125
|
+
_initializerDefineProperty(this, "decision", _descriptor8, this);
|
|
126
|
+
_initializerDefineProperty(this, "legislationTypeUri", _descriptor9, this);
|
|
127
|
+
_initializerDefineProperty(this, "legislationTypeUriAfterTimeout", _descriptor10, this);
|
|
128
|
+
_initializerDefineProperty(this, "text", _descriptor11, this);
|
|
129
|
+
_initializerDefineProperty(this, "textAfterTimeout", _descriptor12, this);
|
|
130
|
+
_initializerDefineProperty(this, "markSelected", _descriptor13, this);
|
|
131
|
+
_defineProperty(this, "liveHighlights", void 0);
|
|
132
|
+
_defineProperty(this, "decisionResource", task$1(this, this.resourceSearch, () => [this.textAfterTimeout, this.legislationTypeUriAfterTimeout, this.pageNumber, this.pageSize]));
|
|
133
|
+
this.liveHighlights = this.args.controller.createLiveMarkSet({
|
|
134
|
+
datastoreQuery: datastore => {
|
|
135
|
+
const matches = datastore.match(null, '>http://data.vlaanderen.be/ns/besluit#motivering').searchTextIn('predicate', CITATION_REGEX);
|
|
136
|
+
const resultMatches = matches.filter(match => {
|
|
137
|
+
return datastore.limitToRange(match.range, {
|
|
138
|
+
type: 'rangeTouches',
|
|
139
|
+
includeEndTags: true
|
|
140
|
+
}).match(null, '>http://data.europa.eu/eli/ontology#cites').size === 0;
|
|
141
|
+
});
|
|
142
|
+
resultMatches.forEach(match => match.range = match.groupRanges[1]);
|
|
143
|
+
return resultMatches;
|
|
144
|
+
},
|
|
145
|
+
liveMarkSpecs: [{
|
|
146
|
+
name: 'citaten',
|
|
147
|
+
attributesBuilder: textMatch => {
|
|
148
|
+
const result = processMatch(textMatch);
|
|
149
|
+
return {
|
|
150
|
+
setBy: 'citaten-plugin',
|
|
151
|
+
text: result.text,
|
|
152
|
+
legislationTypeUri: result.legislationTypeUri
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}, 'highlighted']
|
|
156
|
+
});
|
|
157
|
+
this.controller.onEvent('selectionChanged', this.onSelectionChanged.bind(this));
|
|
158
|
+
}
|
|
159
|
+
onSelectionChanged() {
|
|
160
|
+
const range = this.controller.selection.lastRange;
|
|
161
|
+
if (!range) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const marks = range.getMarks();
|
|
165
|
+
let selectionMark;
|
|
166
|
+
for (let mark of marks) {
|
|
167
|
+
if (mark.name === 'citaten') {
|
|
168
|
+
selectionMark = mark;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (selectionMark) {
|
|
173
|
+
if (this.showCard) {
|
|
174
|
+
//Card was already shown, update search condition and trigger search debounced
|
|
175
|
+
this.text = selectionMark.attributes.text;
|
|
176
|
+
this.legislationTypeUri = selectionMark.attributes.legislationTypeUri;
|
|
177
|
+
this.markSelected = selectionMark;
|
|
178
|
+
this.updateSearch.perform();
|
|
179
|
+
} else {
|
|
180
|
+
//When card is renderend first time, the resource will automatically trigger, no updateSearch is needed, but make sure to first set the search conditions, before showing the card.
|
|
181
|
+
//When not first time, but reopened, search terms could not have changed yet, so also no updateSearch needed
|
|
182
|
+
this.text = selectionMark.attributes.text;
|
|
183
|
+
this.legislationTypeUri = selectionMark.attributes.legislationTypeUri;
|
|
184
|
+
if (this.legislationTypeUriAfterTimeout && (this.legislationTypeUri !== this.legislationTypeUriAfterTimeout || this.text !== this.textAfterTimeout)) {
|
|
185
|
+
//Convoluted, but this is when you switch from one reference insertion to another
|
|
186
|
+
this.updateSearchImmediate.perform();
|
|
187
|
+
}
|
|
188
|
+
this.markSelected = selectionMark;
|
|
189
|
+
this.showCard = true;
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
this.showCard = false;
|
|
193
|
+
//Would be nice, but this triggers way to often causing the cancellation of useful requests
|
|
194
|
+
//this.decisionResource.cancel();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
get controller() {
|
|
199
|
+
return this.args.controller;
|
|
200
|
+
}
|
|
201
|
+
get legislationTypes() {
|
|
202
|
+
return Object.keys(LEGISLATION_TYPES).map(capitalize);
|
|
203
|
+
}
|
|
204
|
+
get legislationSelected() {
|
|
205
|
+
const found = LEGISLATION_TYPE_CONCEPTS.find(c => c.value === this.legislationTypeUri);
|
|
206
|
+
return capitalize(found ? found.label : LEGISLATION_TYPE_CONCEPTS[0].label);
|
|
207
|
+
}
|
|
208
|
+
*updateSearch() {
|
|
209
|
+
yield timeout(500);
|
|
210
|
+
this.textAfterTimeout = this.text;
|
|
211
|
+
this.legislationTypeUriAfterTimeout = this.legislationTypeUri;
|
|
212
|
+
}
|
|
213
|
+
*updateSearchImmediate() {
|
|
214
|
+
this.textAfterTimeout = this.text;
|
|
215
|
+
this.legislationTypeUriAfterTimeout = this.legislationTypeUri;
|
|
216
|
+
yield;
|
|
217
|
+
}
|
|
218
|
+
*resourceSearch() {
|
|
219
|
+
this.error = null;
|
|
220
|
+
yield undefined; //To prevent other variables used below (this.text and this.legislationTypeUri) to trigger a retrigger.
|
|
221
|
+
const abortController = new AbortController();
|
|
222
|
+
const signal = abortController.signal;
|
|
223
|
+
try {
|
|
224
|
+
// Split search string by grouping on non-whitespace characters
|
|
225
|
+
// This probably needs to be more complex to search on group of words
|
|
226
|
+
const words = (this.textAfterTimeout || this.text || '').match(/\S+/g) || [];
|
|
227
|
+
const filter = {
|
|
228
|
+
type: this.legislationTypeUriAfterTimeout || this.legislationTypeUri
|
|
229
|
+
};
|
|
230
|
+
const results = yield fetchDecisions(words, filter, this.pageNumber, this.pageSize, signal);
|
|
231
|
+
this.totalCount = results.totalCount;
|
|
232
|
+
return results.decisions;
|
|
233
|
+
} catch (e) {
|
|
234
|
+
console.warn(e); // eslint-ignore-line no-console
|
|
235
|
+
this.totalCount = 0;
|
|
236
|
+
this.error = e;
|
|
237
|
+
return [];
|
|
238
|
+
} finally {
|
|
239
|
+
//Abort all requests now that this task has either successfully finished or has been cancelled
|
|
240
|
+
abortController.abort();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
selectLegislationType(type) {
|
|
244
|
+
type = type.toLowerCase();
|
|
245
|
+
const found = LEGISLATION_TYPE_CONCEPTS.find(c => c.label.toLowerCase() === type);
|
|
246
|
+
this.legislationTypeUri = found ? found.value : LEGISLATION_TYPE_CONCEPTS[0].value;
|
|
247
|
+
this.legislationTypeUriAfterTimeout = this.legislationTypeUri;
|
|
248
|
+
}
|
|
249
|
+
openDecisionDetailModal(decision) {
|
|
250
|
+
this.decision = decision;
|
|
251
|
+
this.showModal = true;
|
|
252
|
+
}
|
|
253
|
+
openSearchModal() {
|
|
254
|
+
this.decisionResource.cancel();
|
|
255
|
+
this.decision = null;
|
|
256
|
+
this.showModal = true;
|
|
257
|
+
}
|
|
258
|
+
closeModal(lastSearchType, lastSearchTerm) {
|
|
259
|
+
this.showModal = false;
|
|
260
|
+
this.decision = null;
|
|
261
|
+
if (lastSearchType) this.legislationTypeUri = lastSearchType;
|
|
262
|
+
if (lastSearchTerm) this.text = lastSearchTerm;
|
|
263
|
+
if (lastSearchType || lastSearchTerm) this.updateSearchImmediate.perform();
|
|
264
|
+
}
|
|
265
|
+
insertDecisionCitation(decision) {
|
|
266
|
+
const type = decision.legislationType.label;
|
|
267
|
+
const uri = decision.uri;
|
|
268
|
+
const title = decision.title;
|
|
269
|
+
const range = this.controller.rangeFactory.fromAroundNode(this.markSelected.node);
|
|
270
|
+
const citationHtml = `${type ? type : ''} <a class="annotation" href="${uri}" property="eli:cites" typeof="eli:LegalExpression">${title}</a> `;
|
|
271
|
+
this.controller.executeCommand('insert-html', citationHtml, range);
|
|
272
|
+
}
|
|
273
|
+
insertArticleCitation(decision, article) {
|
|
274
|
+
const type = decision.legislationType.label;
|
|
275
|
+
const uri = article.uri;
|
|
276
|
+
const title = `${decision.title}, ${article.number}`;
|
|
277
|
+
const range = this.controller.rangeFactory.fromAroundNode(this.markSelected.node);
|
|
278
|
+
const citationHtml = `${type ? type : ''} <a class="annotation" href="${uri}" property="eli:cites" typeof="eli:LegalExpression">${title}</a> `;
|
|
279
|
+
this.controller.executeCommand('insert-html', citationHtml, range);
|
|
280
|
+
}
|
|
281
|
+
async willDestroy() {
|
|
282
|
+
// Not necessary as ember-concurrency does this for us.
|
|
283
|
+
// this.decisionResource.cancel();
|
|
284
|
+
cleanCaches();
|
|
285
|
+
this.liveHighlights.destroy();
|
|
286
|
+
super.willDestroy();
|
|
287
|
+
}
|
|
288
|
+
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "pageNumber", [tracked], {
|
|
289
|
+
configurable: true,
|
|
290
|
+
enumerable: true,
|
|
291
|
+
writable: true,
|
|
292
|
+
initializer: function () {
|
|
293
|
+
return 0;
|
|
294
|
+
}
|
|
295
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "pageSize", [tracked], {
|
|
296
|
+
configurable: true,
|
|
297
|
+
enumerable: true,
|
|
298
|
+
writable: true,
|
|
299
|
+
initializer: function () {
|
|
300
|
+
return 5;
|
|
301
|
+
}
|
|
302
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "totalSize", [tracked], {
|
|
303
|
+
configurable: true,
|
|
304
|
+
enumerable: true,
|
|
305
|
+
writable: true,
|
|
306
|
+
initializer: null
|
|
307
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, "decisions", [tracked], {
|
|
308
|
+
configurable: true,
|
|
309
|
+
enumerable: true,
|
|
310
|
+
writable: true,
|
|
311
|
+
initializer: function () {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class.prototype, "error", [tracked], {
|
|
315
|
+
configurable: true,
|
|
316
|
+
enumerable: true,
|
|
317
|
+
writable: true,
|
|
318
|
+
initializer: null
|
|
319
|
+
}), _descriptor6 = _applyDecoratedDescriptor(_class.prototype, "showModal", [tracked], {
|
|
320
|
+
configurable: true,
|
|
321
|
+
enumerable: true,
|
|
322
|
+
writable: true,
|
|
323
|
+
initializer: function () {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
}), _descriptor7 = _applyDecoratedDescriptor(_class.prototype, "showCard", [tracked], {
|
|
327
|
+
configurable: true,
|
|
328
|
+
enumerable: true,
|
|
329
|
+
writable: true,
|
|
330
|
+
initializer: function () {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
}), _descriptor8 = _applyDecoratedDescriptor(_class.prototype, "decision", [tracked], {
|
|
334
|
+
configurable: true,
|
|
335
|
+
enumerable: true,
|
|
336
|
+
writable: true,
|
|
337
|
+
initializer: null
|
|
338
|
+
}), _descriptor9 = _applyDecoratedDescriptor(_class.prototype, "legislationTypeUri", [tracked], {
|
|
339
|
+
configurable: true,
|
|
340
|
+
enumerable: true,
|
|
341
|
+
writable: true,
|
|
342
|
+
initializer: null
|
|
343
|
+
}), _descriptor10 = _applyDecoratedDescriptor(_class.prototype, "legislationTypeUriAfterTimeout", [tracked], {
|
|
344
|
+
configurable: true,
|
|
345
|
+
enumerable: true,
|
|
346
|
+
writable: true,
|
|
347
|
+
initializer: null
|
|
348
|
+
}), _descriptor11 = _applyDecoratedDescriptor(_class.prototype, "text", [tracked], {
|
|
349
|
+
configurable: true,
|
|
350
|
+
enumerable: true,
|
|
351
|
+
writable: true,
|
|
352
|
+
initializer: null
|
|
353
|
+
}), _descriptor12 = _applyDecoratedDescriptor(_class.prototype, "textAfterTimeout", [tracked], {
|
|
354
|
+
configurable: true,
|
|
355
|
+
enumerable: true,
|
|
356
|
+
writable: true,
|
|
357
|
+
initializer: null
|
|
358
|
+
}), _descriptor13 = _applyDecoratedDescriptor(_class.prototype, "markSelected", [tracked], {
|
|
359
|
+
configurable: true,
|
|
360
|
+
enumerable: true,
|
|
361
|
+
writable: true,
|
|
362
|
+
initializer: null
|
|
363
|
+
}), _applyDecoratedDescriptor(_class.prototype, "updateSearch", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "updateSearch"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "updateSearchImmediate", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "updateSearchImmediate"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "resourceSearch", [_dec3], Object.getOwnPropertyDescriptor(_class.prototype, "resourceSearch"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "selectLegislationType", [action], Object.getOwnPropertyDescriptor(_class.prototype, "selectLegislationType"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "openDecisionDetailModal", [action], Object.getOwnPropertyDescriptor(_class.prototype, "openDecisionDetailModal"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "openSearchModal", [action], Object.getOwnPropertyDescriptor(_class.prototype, "openSearchModal"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "closeModal", [action], Object.getOwnPropertyDescriptor(_class.prototype, "closeModal"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "insertDecisionCitation", [action], Object.getOwnPropertyDescriptor(_class.prototype, "insertDecisionCitation"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "insertArticleCitation", [action], Object.getOwnPropertyDescriptor(_class.prototype, "insertArticleCitation"), _class.prototype)), _class));
|
|
364
|
+
setComponentTemplate(TEMPLATE, CitaatCardComponent);
|
|
365
|
+
|
|
366
|
+
export { CitaatCardComponent as default };
|
|
367
|
+
//# sourceMappingURL=citaat-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citaat-card.js","sources":["../../../src/components/citaten-plugin/citaat-card.hbs.js","../../../src/utils/processMatch.js","../../../src/components/citaten-plugin/citaat-card.js"],"sourcesContent":["import { hbs } from 'ember-cli-htmlbars';\nexport default hbs(\"{{#if this.showCard}}\\n <AuCard @flex={{true}} @divided={{true}} @isOpenInitially={{true}} @expandable={{true}} @shadow={{true}} @size=\\\"small\\\" as |c|>\\n <c.header>\\n <AuHeading @level=\\\"3\\\" @skin=\\\"6\\\">{{t \\\"citaten-plugin.card.title\\\"}}</AuHeading>\\n </c.header>\\n <c.content>\\n <div class=\\\"au-o-flow au-o-flow--small\\\">\\n <AuFormRow>\\n <AuLabel for=\\\"typeofdocument\\\" @inline={{false}} @required={{false}} @error={{false}} @warning={{false}}>{{t \\\"citaten-plugin.search.type\\\"}}</AuLabel>\\n <PowerSelect\\n id=\\\"typeofdocument\\\"\\n @allowClear={{false}}\\n @disabled={{false}}\\n @searchEnabled={{true}}\\n @loadingMessage=\\\"{{t \\\"citaten-plugin.citaten-plugin.alert.loading\\\"}}\\\"\\n @noMatchesMessage=\\\"{{t \\\"citaten-plugin.citaten-plugin.alert.no-results\\\"}}\\\"\\n @searchMessage=\\\"{{t \\\"citaten-plugin.citaten-plugin.search.placeholder\\\"}}\\\"\\n @options={{this.legislationTypes}}\\n @selected={{this.legislationSelected}}\\n @onChange={{this.selectLegislationType}}\\n class=\\\"au-u-1-1\\\"\\n as |type|>\\n {{type}}\\n </PowerSelect>\\n </AuFormRow>\\n <AuFormRow>\\n <AuLabel for=\\\"searchterm\\\" @inline={{false}} @required={{false}} @error={{false}} @warning={{false}}>{{t \\\"citaten-plugin.search.term\\\"}}</AuLabel>\\n <AuInput\\n id=\\\"searchterm\\\"\\n @type=\\\"text\\\"\\n @width=\\\"block\\\"\\n @icon=\\\"search\\\"\\n @iconAlignment=\\\"right\\\"\\n @value={{this.text}}\\n placeholder={{t \\\"citaten-plugin.search.placeholder\\\"}}\\n {{on \\\"input\\\" (perform this.updateSearch)}}/>\\n </AuFormRow>\\n <AuFormRow>\\n <AuButton @skin=\\\"link\\\" @icon=\\\"search\\\" @iconAlignment=\\\"left\\\" {{on \\\"click\\\" this.openSearchModal}}>{{t \\\"citaten-plugin.search.advanced\\\"}}</AuButton>\\n </AuFormRow>\\n </div>\\n </c.content>\\n <c.footer class=\\\"au-u-background-gray-100 au-u-padding-none\\\">\\n {{#if this.decisionResource.isRunning}}\\n <AuLoader /><span class=\\\"au-u-hidden-visually\\\">{{t \\\"citaten-plugin.alert.loading\\\"}}</span>\\n {{else}}\\n {{#if this.error}}\\n <CitatenPlugin::Helpers::AlertLoadError @fullSize={{false}} @error={{this.error}} />\\n {{else}}\\n <AuToolbar\\n @border=\\\"bottom\\\"\\n @skin=\\\"none\\\"\\n class=\\\"au-u-padding-small\\\" >\\n <AuHeading @skin=\\\"6\\\" @level=\\\"4\\\">{{t \\\"citaten-plugin.card.suggestions\\\"}}</AuHeading>\\n </AuToolbar>\\n <div class=\\\"citaten--decision-list au-u-margin-none au-u-padding-top-tiny au-u-padding-bottom-tiny\\\">\\n <CitatenPlugin::Citations::DecisionList\\n @decisions={{this.decisionResource.value}}\\n @onCitationInsert={{this.insertDecisionCitation}}\\n @onCitationDetails={{this.openDecisionDetailModal}} />\\n </div>\\n {{/if}}\\n {{/if}}\\n </c.footer>\\n </AuCard>\\n{{/if}}\\n\\n{{#if this.showModal}}\\n <CitatenPlugin::Citations::SearchModal\\n @closeModal={{this.closeModal}}\\n @insertDecisionCitation={{this.insertDecisionCitation}}\\n @insertArticleCitation={{this.insertArticleCitation}}\\n @selectedDecision={{this.decision}}\\n @legislationTypeUri={{this.legislationTypeUri}}\\n @text={{this.text}} />\\n{{/if}}\\n\")","import { LEGISLATION_TYPES } from './legislation-types';\nimport { isBlank } from '@ember/utils';\n\nconst STOP_WORDS = ['het', 'de', 'van', 'tot', 'dat'];\nconst DATE_REGEX = new RegExp('(\\\\d{1,2})\\\\s(\\\\w+)\\\\s(\\\\d{2,4})', 'g');\nconst INVISIBLE_SPACE = '\\u200B';\nconst SPACES_REGEX = new RegExp('[\\\\s${UNBREAKABLE_SPACE}]+');\n\nexport default function processMatch(match) {\n const matchgroups = match.groups;\n const type = matchgroups[2];\n const searchTerms = matchgroups[3];\n let cleanedSearchTerms = cleanupText(searchTerms)\n .split(SPACES_REGEX)\n .filter(\n (word) => !isBlank(word) && word.length > 3 && !STOP_WORDS.includes(word)\n )\n .join(' ');\n\n let typeLabel;\n if (/\\w+decreet/i.test(type)) {\n typeLabel = 'decreet';\n cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;\n } else if (/decreet/i.test(type)) {\n typeLabel = 'decreet';\n } else if (/\\w+wetboek/i.test(type)) {\n typeLabel = 'wetboek';\n cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;\n } else if (/wetboek/i.test(type)) {\n typeLabel = 'wetboek';\n } else if (/geco[oö]rdineerde[^\\S\\n]wetten/i.test(type)) {\n typeLabel = 'gecoördineerde wetten';\n } else if (/grondwetswijziging/i.test(type)) {\n typeLabel = 'grondwetswijziging';\n } else if (/grondwet/i.test(type)) {\n typeLabel = 'grondwet';\n } else if (/\\w+wet/i.test(type)) {\n typeLabel = 'wet';\n cleanedSearchTerms = `${type} ${cleanedSearchTerms}`;\n } else if (/wet/i.test(type)) {\n typeLabel = 'wet';\n } else {\n typeLabel = type.toLowerCase().trim();\n }\n\n const typeUri = LEGISLATION_TYPES[typeLabel] || LEGISLATION_TYPES['decreet'];\n return {\n text: cleanedSearchTerms,\n legislationTypeUri: typeUri,\n range: match.groupRanges[1],\n };\n}\n\nfunction cleanupText(text) {\n if (!text) return '';\n const { textWithoutDates } = extractDates(text);\n const textWithoutOddChars = textWithoutDates.replace(\n new RegExp(`[,.:\"()&${INVISIBLE_SPACE}]`, 'g'),\n ''\n );\n const articleIndex = textWithoutOddChars.indexOf('artikel');\n return articleIndex >= 0\n ? textWithoutOddChars.slice(0, articleIndex)\n : textWithoutOddChars;\n}\n\nfunction extractDates(text) {\n let date;\n const matches = [];\n while ((date = DATE_REGEX.exec(text)) !== null) {\n matches.push(date);\n }\n\n let textWithoutDates = text;\n for (let match of matches) {\n textWithoutDates = textWithoutDates.replace(match[0], '');\n }\n\n return { dates: matches, textWithoutDates };\n}\n","import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\n// import { task } from 'ember-concurrency-decorators';\nimport { task, timeout } from 'ember-concurrency';\nimport { action } from '@ember/object';\nimport { capitalize } from '@ember/string';\nimport processMatch from '../../utils/processMatch';\nimport { cleanCaches, fetchDecisions } from '../../utils/vlaamse-codex';\nimport {\n LEGISLATION_TYPE_CONCEPTS,\n LEGISLATION_TYPES,\n} from '../../utils/legislation-types';\nimport { task as trackedTask } from 'ember-resources/util/ember-concurrency';\n\nconst BASIC_MULTIPLANE_CHARACTER = '\\u0021-\\uFFFF'; // most of the characters used around the world\n\n// Regex nicely structured:\n// (\n// (\n// \\w*decreet |\n// omzendbrief |\n// verdrag |\n// grondwetswijziging |\n// samenwerkingsakkoord |\n// \\w*wetboek |\n// protocol |\n// besluit[^\\S\\n]van[^\\S\\n]de[^\\S\\n]vlaamse[^\\S\\n]regering |\n// geco[öo]rdineerde wetten |\n// \\w*wet |\n// koninklijk[^\\S\\n]?besluit |\n// ministerieel[^\\S\\n]?besluit |\n// genummerd[^\\S\\n]?koninklijk[^\\S\\n]?besluit\n// )\n// [^\\S\\n]*\n// (\n// ([^\\S\\n] | [\\u0021-\\uFFFF\\d;:'\"()&\\-_]){3,}\n// )?\n// )\nconst NNWS = '[^\\\\S\\\\n]';\nconst CITATION_REGEX = new RegExp(\n `((\\\\w*decreet|omzendbrief|verdrag|grondwetswijziging|samenwerkingsakkoord|\\\\w*wetboek|protocol|besluit${NNWS}van${NNWS}de${NNWS}vlaamse${NNWS}regering|geco[öo]rdineerde${NNWS}wetten|\\\\w*wet|koninklijk${NNWS}?besluit|ministerieel${NNWS}?besluit|genummerd${NNWS}?koninklijk${NNWS}?besluit|\\\\w*${NNWS}?besluit)${NNWS}*((${NNWS}|[${BASIC_MULTIPLANE_CHARACTER};:'\"()&-_]){3,})?)`,\n 'uig'\n);\n\nexport default class CitaatCardComponent extends Component {\n @tracked pageNumber = 0;\n @tracked pageSize = 5;\n @tracked totalSize;\n @tracked decisions = [];\n @tracked error;\n @tracked showModal = false;\n @tracked showCard = false;\n @tracked decision;\n @tracked legislationTypeUri;\n @tracked legislationTypeUriAfterTimeout;\n @tracked text;\n @tracked textAfterTimeout;\n @tracked markSelected;\n liveHighlights;\n\n constructor() {\n super(...arguments);\n this.liveHighlights = this.args.controller.createLiveMarkSet({\n datastoreQuery: (datastore) => {\n const matches = datastore\n .match(null, '>http://data.vlaanderen.be/ns/besluit#motivering')\n .searchTextIn('predicate', CITATION_REGEX);\n const resultMatches = matches.filter((match) => {\n return (\n datastore\n .limitToRange(match.range, {\n type: 'rangeTouches',\n includeEndTags: true,\n })\n .match(null, '>http://data.europa.eu/eli/ontology#cites').size ===\n 0\n );\n });\n resultMatches.forEach((match) => (match.range = match.groupRanges[1]));\n return resultMatches;\n },\n\n liveMarkSpecs: [\n {\n name: 'citaten',\n attributesBuilder: (textMatch) => {\n const result = processMatch(textMatch);\n return {\n setBy: 'citaten-plugin',\n text: result.text,\n legislationTypeUri: result.legislationTypeUri,\n };\n },\n },\n 'highlighted',\n ],\n });\n this.controller.onEvent(\n 'selectionChanged',\n this.onSelectionChanged.bind(this)\n );\n }\n\n onSelectionChanged() {\n const range = this.controller.selection.lastRange;\n if (!range) {\n return;\n }\n const marks = range.getMarks();\n let selectionMark;\n for (let mark of marks) {\n if (mark.name === 'citaten') {\n selectionMark = mark;\n break;\n }\n }\n if (selectionMark) {\n if (this.showCard) {\n //Card was already shown, update search condition and trigger search debounced\n this.text = selectionMark.attributes.text;\n this.legislationTypeUri = selectionMark.attributes.legislationTypeUri;\n this.markSelected = selectionMark;\n this.updateSearch.perform();\n } else {\n //When card is renderend first time, the resource will automatically trigger, no updateSearch is needed, but make sure to first set the search conditions, before showing the card.\n //When not first time, but reopened, search terms could not have changed yet, so also no updateSearch needed\n this.text = selectionMark.attributes.text;\n this.legislationTypeUri = selectionMark.attributes.legislationTypeUri;\n if (\n this.legislationTypeUriAfterTimeout &&\n (this.legislationTypeUri !== this.legislationTypeUriAfterTimeout ||\n this.text !== this.textAfterTimeout)\n ) {\n //Convoluted, but this is when you switch from one reference insertion to another\n this.updateSearchImmediate.perform();\n }\n this.markSelected = selectionMark;\n this.showCard = true;\n }\n } else {\n this.showCard = false;\n //Would be nice, but this triggers way to often causing the cancellation of useful requests\n //this.decisionResource.cancel();\n }\n }\n\n get controller() {\n return this.args.controller;\n }\n\n get legislationTypes() {\n return Object.keys(LEGISLATION_TYPES).map(capitalize);\n }\n\n get legislationSelected() {\n const found = LEGISLATION_TYPE_CONCEPTS.find(\n (c) => c.value === this.legislationTypeUri\n );\n return capitalize(found ? found.label : LEGISLATION_TYPE_CONCEPTS[0].label);\n }\n\n decisionResource = trackedTask(this, this.resourceSearch, () => [\n this.textAfterTimeout,\n this.legislationTypeUriAfterTimeout,\n this.pageNumber,\n this.pageSize,\n ]);\n\n @task({ restartable: true })\n *updateSearch() {\n yield timeout(500);\n this.textAfterTimeout = this.text;\n this.legislationTypeUriAfterTimeout = this.legislationTypeUri;\n }\n\n @task({ restartable: true })\n *updateSearchImmediate() {\n this.textAfterTimeout = this.text;\n this.legislationTypeUriAfterTimeout = this.legislationTypeUri;\n yield;\n }\n\n @task({ restartable: true })\n *resourceSearch() {\n this.error = null;\n yield undefined; //To prevent other variables used below (this.text and this.legislationTypeUri) to trigger a retrigger.\n const abortController = new AbortController();\n const signal = abortController.signal;\n try {\n // Split search string by grouping on non-whitespace characters\n // This probably needs to be more complex to search on group of words\n const words =\n (this.textAfterTimeout || this.text || '').match(/\\S+/g) || [];\n const filter = {\n type: this.legislationTypeUriAfterTimeout || this.legislationTypeUri,\n };\n const results = yield fetchDecisions(\n words,\n filter,\n this.pageNumber,\n this.pageSize,\n signal\n );\n this.totalCount = results.totalCount;\n return results.decisions;\n } catch (e) {\n console.warn(e); // eslint-ignore-line no-console\n this.totalCount = 0;\n this.error = e;\n return [];\n } finally {\n //Abort all requests now that this task has either successfully finished or has been cancelled\n abortController.abort();\n }\n }\n\n @action\n selectLegislationType(type) {\n type = type.toLowerCase();\n const found = LEGISLATION_TYPE_CONCEPTS.find(\n (c) => c.label.toLowerCase() === type\n );\n this.legislationTypeUri = found\n ? found.value\n : LEGISLATION_TYPE_CONCEPTS[0].value;\n this.legislationTypeUriAfterTimeout = this.legislationTypeUri;\n }\n\n @action\n openDecisionDetailModal(decision) {\n this.decision = decision;\n this.showModal = true;\n }\n\n @action\n openSearchModal() {\n this.decisionResource.cancel();\n this.decision = null;\n this.showModal = true;\n }\n\n @action\n closeModal(lastSearchType, lastSearchTerm) {\n this.showModal = false;\n this.decision = null;\n if (lastSearchType) this.legislationTypeUri = lastSearchType;\n if (lastSearchTerm) this.text = lastSearchTerm;\n if (lastSearchType || lastSearchTerm) this.updateSearchImmediate.perform();\n }\n\n @action\n insertDecisionCitation(decision) {\n const type = decision.legislationType.label;\n const uri = decision.uri;\n const title = decision.title;\n const range = this.controller.rangeFactory.fromAroundNode(\n this.markSelected.node\n );\n const citationHtml = `${\n type ? type : ''\n } <a class=\"annotation\" href=\"${uri}\" property=\"eli:cites\" typeof=\"eli:LegalExpression\">${title}</a> `;\n this.controller.executeCommand('insert-html', citationHtml, range);\n }\n\n @action\n insertArticleCitation(decision, article) {\n const type = decision.legislationType.label;\n const uri = article.uri;\n const title = `${decision.title}, ${article.number}`;\n const range = this.controller.rangeFactory.fromAroundNode(\n this.markSelected.node\n );\n const citationHtml = `${\n type ? type : ''\n } <a class=\"annotation\" href=\"${uri}\" property=\"eli:cites\" typeof=\"eli:LegalExpression\">${title}</a> `;\n this.controller.executeCommand('insert-html', citationHtml, range);\n }\n\n async willDestroy() {\n // Not necessary as ember-concurrency does this for us.\n // this.decisionResource.cancel();\n cleanCaches();\n this.liveHighlights.destroy();\n super.willDestroy();\n }\n}\n"],"names":["hbs","STOP_WORDS","DATE_REGEX","RegExp","INVISIBLE_SPACE","SPACES_REGEX","processMatch","match","matchgroups","groups","type","searchTerms","cleanedSearchTerms","cleanupText","split","filter","word","isBlank","length","includes","join","typeLabel","test","toLowerCase","trim","typeUri","LEGISLATION_TYPES","text","legislationTypeUri","range","groupRanges","textWithoutDates","extractDates","textWithoutOddChars","replace","articleIndex","indexOf","slice","date","matches","exec","push","dates","BASIC_MULTIPLANE_CHARACTER","NNWS","CITATION_REGEX","CitaatCardComponent","task","restartable","Component","constructor","arguments","trackedTask","resourceSearch","textAfterTimeout","legislationTypeUriAfterTimeout","pageNumber","pageSize","liveHighlights","args","controller","createLiveMarkSet","datastoreQuery","datastore","searchTextIn","resultMatches","limitToRange","includeEndTags","size","forEach","liveMarkSpecs","name","attributesBuilder","textMatch","result","setBy","onEvent","onSelectionChanged","bind","selection","lastRange","marks","getMarks","selectionMark","mark","showCard","attributes","markSelected","updateSearch","perform","updateSearchImmediate","legislationTypes","Object","keys","map","capitalize","legislationSelected","found","LEGISLATION_TYPE_CONCEPTS","find","c","value","label","timeout","error","undefined","abortController","AbortController","signal","words","results","fetchDecisions","totalCount","decisions","e","console","warn","abort","selectLegislationType","openDecisionDetailModal","decision","showModal","openSearchModal","decisionResource","cancel","closeModal","lastSearchType","lastSearchTerm","insertDecisionCitation","legislationType","uri","title","rangeFactory","fromAroundNode","node","citationHtml","executeCommand","insertArticleCitation","article","number","willDestroy","cleanCaches","destroy","tracked","action"],"mappings":";;;;;;;;;;;;;AACA,eAAeA,GAAG,CAAC,44GAA44G,CAAC;;ACEh6G,MAAMC,UAAU,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;AACrD,MAAMC,UAAU,GAAG,IAAIC,MAAM,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAA;AACtE,MAAMC,eAAe,GAAG,QAAQ,CAAA;AAChC,MAAMC,YAAY,GAAG,IAAIF,MAAM,CAAC,4BAA4B,CAAC,CAAA;AAE9C,SAASG,YAAY,CAACC,KAAK,EAAE;AAC1C,EAAA,MAAMC,WAAW,GAAGD,KAAK,CAACE,MAAM,CAAA;AAChC,EAAA,MAAMC,IAAI,GAAGF,WAAW,CAAC,CAAC,CAAC,CAAA;AAC3B,EAAA,MAAMG,WAAW,GAAGH,WAAW,CAAC,CAAC,CAAC,CAAA;AAClC,EAAA,IAAII,kB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A,CAcNA,MAAM,CAAA,EAAA,MAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,SAAA,EAAA,uBAAA,CAAA,EAAA,MAAA,CAAA,SAAA,CAAA,GAAA,MAAA,CAAA,EAAA;AA5N+B,oBAAA,CAAA,QAAA,EAAA,mBAAA,CAAA;;;;"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { _ as _applyDecoratedDescriptor, a as _initializerDefineProperty } from '../../_rollupPluginBabelHelpers-537ad14b.js';
|
|
2
|
+
import { setComponentTemplate } from '@ember/component';
|
|
3
|
+
import { hbs } from 'ember-cli-htmlbars';
|
|
4
|
+
import Component from '@glimmer/component';
|
|
5
|
+
import { action } from '@ember/object';
|
|
6
|
+
import { tracked } from '@glimmer/tracking';
|
|
7
|
+
import { L as LEGISLATION_TYPES } from '../../legislation-types-4d487cb9.js';
|
|
8
|
+
|
|
9
|
+
var TEMPLATE = hbs("<AuList::Item>\n <AuButton\n @icon=\"add\"\n @iconAlignment=\"left\"\n @skin=\"link\"\n @disabled={{this.disableInsert}}\n {{on \'click\' this.openModal}}>\n {{t \"citaten-plugin.insert.title\"}}\n </AuButton>\n</AuList::Item>\n\n{{#if this.showModal}}\n <CitatenPlugin::Citations::SearchModal\n @closeModal={{this.closeModal}}\n @insertDecisionCitation={{this.insertDecisionCitation}}\n @insertArticleCitation={{this.insertArticleCitation}}\n @legislationTypeUri={{this.legislationTypeUri}}\n @text={{this.text}}\n />\n{{/if}}\n");
|
|
10
|
+
|
|
11
|
+
var _class, _descriptor, _descriptor2, _descriptor3, _descriptor4;
|
|
12
|
+
let EditorPluginsCitaatInsertComponent = (_class = class EditorPluginsCitaatInsertComponent extends Component {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
_initializerDefineProperty(this, "disableInsert", _descriptor, this);
|
|
16
|
+
_initializerDefineProperty(this, "showModal", _descriptor2, this);
|
|
17
|
+
_initializerDefineProperty(this, "legislationTypeUri", _descriptor3, this);
|
|
18
|
+
_initializerDefineProperty(this, "text", _descriptor4, this);
|
|
19
|
+
this.args.controller.onEvent('selectionChanged', this.onSelectionChanged.bind(this));
|
|
20
|
+
}
|
|
21
|
+
onSelectionChanged() {
|
|
22
|
+
const selectedRange = this.args.controller.selection.lastRange;
|
|
23
|
+
if (!selectedRange) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const limitedDatastore = this.args.controller.datastore.limitToRange(selectedRange, 'rangeIsInside');
|
|
27
|
+
const motivering = limitedDatastore.match(null, '>http://data.vlaanderen.be/ns/besluit#motivering').asQuads().next().value;
|
|
28
|
+
this.disableInsert = motivering ? false : true;
|
|
29
|
+
}
|
|
30
|
+
openModal() {
|
|
31
|
+
this.showModal = true;
|
|
32
|
+
}
|
|
33
|
+
closeModal() {
|
|
34
|
+
this.showModal = false;
|
|
35
|
+
}
|
|
36
|
+
insertDecisionCitation(decision) {
|
|
37
|
+
const type = decision.legislationType.label;
|
|
38
|
+
const uri = decision.uri;
|
|
39
|
+
const title = decision.title;
|
|
40
|
+
const range = this.args.controller.selection.lastRange;
|
|
41
|
+
const citationHtml = `${type ? type : ''} <a class="annotation" href="${uri}" property="eli:cites" typeof="eli:LegalExpression">${title}</a> `;
|
|
42
|
+
this.args.controller.executeCommand('insert-html', citationHtml, range);
|
|
43
|
+
}
|
|
44
|
+
insertArticleCitation(decision, article) {
|
|
45
|
+
const type = decision.legislationType.label;
|
|
46
|
+
const uri = article.uri;
|
|
47
|
+
const title = `${decision.title}, ${article.number}`;
|
|
48
|
+
const range = this.args.controller.selection.lastRange;
|
|
49
|
+
const citationHtml = `${type ? type : ''} <a class="annotation" href="${uri}" property="eli:cites" typeof="eli:LegalExpression">${title}</a> `;
|
|
50
|
+
this.args.controller.executeCommand('insert-html', citationHtml, range);
|
|
51
|
+
}
|
|
52
|
+
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "disableInsert", [tracked], {
|
|
53
|
+
configurable: true,
|
|
54
|
+
enumerable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
initializer: function () {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "showModal", [tracked], {
|
|
60
|
+
configurable: true,
|
|
61
|
+
enumerable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
initializer: function () {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "legislationTypeUri", [tracked], {
|
|
67
|
+
configurable: true,
|
|
68
|
+
enumerable: true,
|
|
69
|
+
writable: true,
|
|
70
|
+
initializer: function () {
|
|
71
|
+
return LEGISLATION_TYPES.decreet;
|
|
72
|
+
}
|
|
73
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, "text", [tracked], {
|
|
74
|
+
configurable: true,
|
|
75
|
+
enumerable: true,
|
|
76
|
+
writable: true,
|
|
77
|
+
initializer: function () {
|
|
78
|
+
return '';
|
|
79
|
+
}
|
|
80
|
+
}), _applyDecoratedDescriptor(_class.prototype, "openModal", [action], Object.getOwnPropertyDescriptor(_class.prototype, "openModal"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "closeModal", [action], Object.getOwnPropertyDescriptor(_class.prototype, "closeModal"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "insertDecisionCitation", [action], Object.getOwnPropertyDescriptor(_class.prototype, "insertDecisionCitation"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "insertArticleCitation", [action], Object.getOwnPropertyDescriptor(_class.prototype, "insertArticleCitation"), _class.prototype)), _class);
|
|
81
|
+
setComponentTemplate(TEMPLATE, EditorPluginsCitaatInsertComponent);
|
|
82
|
+
|
|
83
|
+
export { EditorPluginsCitaatInsertComponent as default };
|
|
84
|
+
//# sourceMappingURL=citaat-insert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citaat-insert.js","sources":["../../../src/components/citaten-plugin/citaat-insert.hbs.js","../../../src/components/citaten-plugin/citaat-insert.js"],"sourcesContent":["import { hbs } from 'ember-cli-htmlbars';\nexport default hbs(\"<AuList::Item>\\n <AuButton\\n @icon=\\\"add\\\"\\n @iconAlignment=\\\"left\\\"\\n @skin=\\\"link\\\"\\n @disabled={{this.disableInsert}}\\n {{on \\'click\\' this.openModal}}>\\n {{t \\\"citaten-plugin.insert.title\\\"}}\\n </AuButton>\\n</AuList::Item>\\n\\n{{#if this.showModal}}\\n <CitatenPlugin::Citations::SearchModal\\n @closeModal={{this.closeModal}}\\n @insertDecisionCitation={{this.insertDecisionCitation}}\\n @insertArticleCitation={{this.insertArticleCitation}}\\n @legislationTypeUri={{this.legislationTypeUri}}\\n @text={{this.text}}\\n />\\n{{/if}}\\n\")","import Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { tracked } from '@glimmer/tracking';\nimport { LEGISLATION_TYPES } from '../../utils/legislation-types';\nexport default class EditorPluginsCitaatInsertComponent extends Component {\n @tracked disableInsert = false;\n @tracked showModal = false;\n @tracked legislationTypeUri = LEGISLATION_TYPES.decreet;\n @tracked text = '';\n\n constructor() {\n super(...arguments);\n this.args.controller.onEvent(\n 'selectionChanged',\n this.onSelectionChanged.bind(this)\n );\n }\n\n onSelectionChanged() {\n const selectedRange = this.args.controller.selection.lastRange;\n if (!selectedRange) {\n return;\n }\n const limitedDatastore = this.args.controller.datastore.limitToRange(\n selectedRange,\n 'rangeIsInside'\n );\n const motivering = limitedDatastore\n .match(null, '>http://data.vlaanderen.be/ns/besluit#motivering')\n .asQuads()\n .next().value;\n this.disableInsert = motivering ? false : true;\n }\n\n @action\n openModal() {\n this.showModal = true;\n }\n\n @action\n closeModal() {\n this.showModal = false;\n }\n\n @action\n insertDecisionCitation(decision) {\n const type = decision.legislationType.label;\n const uri = decision.uri;\n const title = decision.title;\n const range = this.args.controller.selection.lastRange;\n const citationHtml = `${\n type ? type : ''\n } <a class=\"annotation\" href=\"${uri}\" property=\"eli:cites\" typeof=\"eli:LegalExpression\">${title}</a> `;\n this.args.controller.executeCommand('insert-html', citationHtml, range);\n }\n\n @action\n insertArticleCitation(decision, article) {\n const type = decision.legislationType.label;\n const uri = article.uri;\n const title = `${decision.title}, ${article.number}`;\n const range = this.args.controller.selection.lastRange;\n const citationHtml = `${\n type ? type : ''\n } <a class=\"annotation\" href=\"${uri}\" property=\"eli:cites\" typeof=\"eli:LegalExpression\">${title}</a> `;\n this.args.controller.executeCommand('insert-html', citationHtml, range);\n }\n}\n"],"names":["hbs","EditorPluginsCitaatInsertComponent","Component","constructor","arguments","args","controller","onEvent","onSelectionChanged","bind","selectedRange","selection","lastRange","limitedDatastore","datastore","limitToRange","motivering","match","asQuads","next","value","disableInsert","openModal","showModal","closeModal","insertDecisionCitation","decision","type","legislationType","label","uri","title","range","citationHtml","executeCommand","insertArticleCitation","article","number","tracked","LEGISLATION_TYPES","decreet","action"],"mappings":";;;;;;;;AACA,eAAeA,GAAG,CAAC,wjBAAwjB,CAAC;;;ACE1gB,IAC7CC,kCAAkC,IAAxC,MAAA,GAAA,MAAMA,kCAAkC,SAASC,SAAS,CAAC;AAMxEC,EAAAA,WAAW,GAAG;IACZ,KAAK,CAAC,GAAGC,SAAS,CAAC,CAAA;AAAC,IAAA,0BAAA,CAAA,IAAA,EAAA,eAAA,EAAA,WAAA,EAAA,IAAA,CAAA,CAAA;AAAA,IAAA,0BAAA,CAAA,IAAA,EAAA,WAAA,EAAA,YAAA,EAAA,IAAA,CAAA,CAAA;AAAA,IAAA,0BAAA,CAAA,IAAA,EAAA,oBAAA,EAAA,YAAA,EAAA,IAAA,CAAA,CAAA;AAAA,IAAA,0BAAA,CAAA,IAAA,EAAA,MAAA,EAAA,YAAA,EAAA,IAAA,CAAA,CAAA;AACpB,IAAA,IAAI,CAACC,IAAI,CAACC,UAAU,CAACC,OAAO,CAC1B,kBAAkB,EAClB,IAAI,CAACC,kBAAkB,CAACC,IAAI,CAAC,IAAI,CAAC,CACnC,CAAA;AACH,GAAA;AAEA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
+
import { setComponentTemplate } from '@ember/component';
|
|
2
|
+
import { hbs } from 'ember-cli-htmlbars';
|
|
3
|
+
import templateOnly from '@ember/component/template-only';
|
|
4
|
+
|
|
5
|
+
var TEMPLATE = hbs("{{#if @articles.length}}\n <AuList @direction=\"vertical\" @divider={{true}}>\n {{#each @articles as |article|}}\n <AuList::Item>\n <CitatenPlugin::Citations::ArticlePreview\n @insertArticleCitation={{fn @insertArticleCitation article}}\n @article={{article}} />\n </AuList::Item>\n {{/each}}\n </AuList>\n{{else}}\n <CitatenPlugin::Helpers::AlertNoItems @fullSize={{@fullSize}} class={{if @fullSize \"au-u-margin\"}}/>\n{{/if}}\n");
|
|
6
|
+
|
|
7
|
+
var articleList = setComponentTemplate(TEMPLATE, templateOnly());
|
|
8
|
+
|
|
9
|
+
export { articleList as default };
|
|
10
|
+
//# sourceMappingURL=article-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article-list.js","sources":["../../../../src/components/citaten-plugin/citations/article-list.hbs.js","../../../../src/components/citaten-plugin/citations/article-list.js"],"sourcesContent":["import { hbs } from 'ember-cli-htmlbars';\nexport default hbs(\"{{#if @articles.length}}\\n <AuList @direction=\\\"vertical\\\" @divider={{true}}>\\n {{#each @articles as |article|}}\\n <AuList::Item>\\n <CitatenPlugin::Citations::ArticlePreview\\n @insertArticleCitation={{fn @insertArticleCitation article}}\\n @article={{article}} />\\n </AuList::Item>\\n {{/each}}\\n </AuList>\\n{{else}}\\n <CitatenPlugin::Helpers::AlertNoItems @fullSize={{@fullSize}} class={{if @fullSize \\\"au-u-margin\\\"}}/>\\n{{/if}}\\n\")","import templateOnly from '@ember/component/template-only';\nexport default templateOnly();\n"],"names":["hbs","templateOnly"],"mappings":";;;;AACA,eAAeA,GAAG,CAAC,4dAA4d,CAAC;;ACAhf,kBAAA,oBAAA,CAAA,QAAA,EAAeC,YAAY,EAAE,CAAA;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { setComponentTemplate } from '@ember/component';
|
|
2
|
+
import { hbs } from 'ember-cli-htmlbars';
|
|
3
|
+
import templateOnly from '@ember/component/template-only';
|
|
4
|
+
|
|
5
|
+
var TEMPLATE = hbs("<div class=\"au-u-margin\" ...attributes>\n <AuHeading @level=\"3\" @skin=\"5\" class=\"au-u-margin-bottom-small\">\n {{@article.number}} ({{@article.dateInForce}} - {{if @article.dateNoLongerInForce @article.dateNoLongerInForce \"…\"}})\n </AuHeading>\n <p>\n {{@article.content}}\n </p>\n <AuButton\n @skin=\"primary\"\n @icon=\"plus-text\"\n @iconAlignment=\"left\"\n class=\"au-u-margin-top-small\"\n {{on \"click\" @insertArticleCitation}}>\n {{t \"citaten-plugin.references.refer-article\"}}\n </AuButton>\n</div>\n");
|
|
6
|
+
|
|
7
|
+
var articlePreview = setComponentTemplate(TEMPLATE, templateOnly());
|
|
8
|
+
|
|
9
|
+
export { articlePreview as default };
|
|
10
|
+
//# sourceMappingURL=article-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article-preview.js","sources":["../../../../src/components/citaten-plugin/citations/article-preview.hbs.js","../../../../src/components/citaten-plugin/citations/article-preview.js"],"sourcesContent":["import { hbs } from 'ember-cli-htmlbars';\nexport default hbs(\"<div class=\\\"au-u-margin\\\" ...attributes>\\n <AuHeading @level=\\\"3\\\" @skin=\\\"5\\\" class=\\\"au-u-margin-bottom-small\\\">\\n {{@article.number}} ({{@article.dateInForce}} - {{if @article.dateNoLongerInForce @article.dateNoLongerInForce \\\"…\\\"}})\\n </AuHeading>\\n <p>\\n {{@article.content}}\\n </p>\\n <AuButton\\n @skin=\\\"primary\\\"\\n @icon=\\\"plus-text\\\"\\n @iconAlignment=\\\"left\\\"\\n class=\\\"au-u-margin-top-small\\\"\\n {{on \\\"click\\\" @insertArticleCitation}}>\\n {{t \\\"citaten-plugin.references.refer-article\\\"}}\\n </AuButton>\\n</div>\\n\")","import templateOnly from '@ember/component/template-only';\nexport default templateOnly();\n"],"names":["hbs","templateOnly"],"mappings":";;;;AACA,eAAeA,GAAG,CAAC,uiBAAuiB,CAAC;;ACA3jB,qBAAA,oBAAA,CAAA,QAAA,EAAeC,YAAY,EAAE,CAAA;;;;"}
|