@lblod/ember-rdfa-editor-lblod-plugins 8.2.2 → 8.4.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/.woodpecker/.test.yml +5 -0
- package/CHANGELOG.md +31 -1
- package/addon/components/citation-plugin/citations/search-modal.hbs +18 -41
- package/addon/components/citation-plugin/citations/search-modal.ts +0 -17
- package/addon/components/document-title-plugin/insert-title-card.hbs +5 -0
- package/addon/components/document-title-plugin/insert-title-card.ts +41 -0
- package/addon/components/pagination/pagination-view.hbs +39 -0
- package/addon/components/snippet-plugin/helpers/alert-load-error.hbs +22 -0
- package/addon/components/snippet-plugin/helpers/alert-no-items.hbs +8 -0
- package/addon/components/snippet-plugin/search-modal.hbs +83 -0
- package/addon/components/snippet-plugin/search-modal.ts +97 -0
- package/addon/components/snippet-plugin/snippet-insert.hbs +17 -0
- package/addon/components/snippet-plugin/snippet-insert.ts +50 -0
- package/addon/components/snippet-plugin/snippets/snippet-list.hbs +12 -0
- package/addon/components/snippet-plugin/snippets/snippet-preview.hbs +27 -0
- package/addon/components/snippet-plugin/snippets/snippet-preview.ts +28 -0
- package/addon/helpers/pagination.ts +40 -0
- package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +2 -79
- package/addon/plugins/citation-plugin/utils/vlaamse-codex.ts +4 -34
- package/addon/plugins/document-title-plugin/commands/insert-document-title.ts +45 -0
- package/addon/plugins/document-title-plugin/nodes/document-title.ts +36 -0
- package/addon/plugins/document-title-plugin/nodes/index.ts +1 -0
- package/addon/plugins/snippet-plugin/index.ts +27 -0
- package/addon/plugins/snippet-plugin/utils/fetch-data.ts +96 -0
- package/addon/plugins/variable-plugin/nodes.ts +15 -11
- package/addon/plugins/variable-plugin/utils/fetch-data.ts +6 -6
- package/addon/utils/_private/find-insertion-range.ts +77 -0
- package/addon/utils/sparql-helpers.ts +28 -6
- package/addon/utils/strings.ts +34 -0
- package/addon/utils/types.ts +3 -0
- package/app/components/document-title-plugin/insert-title-card.js +1 -0
- package/app/components/pagination/pagination-view.js +1 -0
- package/app/components/snippet-plugin/helpers/alert-load-error.js +1 -0
- package/app/components/snippet-plugin/helpers/alert-no-items.js +1 -0
- package/app/components/snippet-plugin/search-modal.js +1 -0
- package/app/components/snippet-plugin/snippet-insert.js +1 -0
- package/app/components/snippet-plugin/snippets/snippet-list.js +1 -0
- package/app/components/snippet-plugin/snippets/snippet-preview.js +1 -0
- package/app/helpers/pagination.js +4 -0
- package/app/styles/document-title-plugin.scss +9 -0
- package/app/styles/snippet-plugin.scss +66 -0
- package/components/besluit-type-plugin/toolbar-dropdown.d.ts +1 -1
- package/components/citation-plugin/citations/search-modal.d.ts +0 -4
- package/components/document-title-plugin/insert-title-card.d.ts +12 -0
- package/components/snippet-plugin/search-modal.d.ts +22 -0
- package/components/snippet-plugin/snippet-insert.d.ts +16 -0
- package/components/snippet-plugin/snippets/snippet-preview.d.ts +14 -0
- package/helpers/pagination.d.ts +25 -0
- package/package.json +5 -5
- package/plugins/document-title-plugin/commands/insert-document-title.d.ts +6 -0
- package/plugins/document-title-plugin/nodes/document-title.d.ts +2 -0
- package/plugins/document-title-plugin/nodes/index.d.ts +1 -0
- package/plugins/snippet-plugin/index.d.ts +16 -0
- package/plugins/snippet-plugin/utils/fetch-data.d.ts +18 -0
- package/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +1 -1
- package/plugins/variable-plugin/nodes.d.ts +3 -3
- package/translations/en-US.yaml +28 -0
- package/translations/nl-BE.yaml +28 -1
- package/tsconfig.json +5 -13
- package/utils/_private/find-insertion-range.d.ts +11 -0
- package/utils/sparql-helpers.d.ts +11 -4
- package/utils/strings.d.ts +2 -0
- package/utils/types.d.ts +2 -0
package/.woodpecker/.test.yml
CHANGED
|
@@ -6,6 +6,7 @@ steps:
|
|
|
6
6
|
- git diff -wb --name-only origin/master..HEAD | grep CHANGELOG.md
|
|
7
7
|
when:
|
|
8
8
|
event: pull_request
|
|
9
|
+
evaluate: 'not (CI_COMMIT_PULL_REQUEST_LABELS contains "dependabot")'
|
|
9
10
|
install:
|
|
10
11
|
image: danlynn/ember-cli:4.8.0
|
|
11
12
|
commands:
|
|
@@ -26,6 +27,10 @@ steps:
|
|
|
26
27
|
group: check
|
|
27
28
|
commands:
|
|
28
29
|
- ember test
|
|
30
|
+
precompile:
|
|
31
|
+
image: danlynn/ember-cli:4.8.0
|
|
32
|
+
commands:
|
|
33
|
+
- ember ts:precompile
|
|
29
34
|
|
|
30
35
|
|
|
31
36
|
release:
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [8.4.0] - 2023-07-06
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- revert editor bump to 4.0.0, bump to 3.10.0 instead
|
|
15
|
+
- Addition of document-title plugin
|
|
16
|
+
|
|
17
|
+
## [8.3.0] - 2023-07-06
|
|
18
|
+
### Added
|
|
19
|
+
- Insert the snippet
|
|
20
|
+
- Addition of a precompile step to woodpecker PR check
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- fix type error due to bad tsconfig
|
|
24
|
+
### Changed
|
|
25
|
+
- Woodpecker: do not run changelog-check when PR contains `dependabot` label
|
|
26
|
+
- Made the number variable also show placeholders
|
|
27
|
+
- Extract SPARQL query tools
|
|
28
|
+
|
|
29
|
+
### Dependencies
|
|
30
|
+
- Bumps `@types/rdfjs__data-model` from 2.0.1 to 2.0.4
|
|
31
|
+
- Bumps `eslint-plugin-ember` from 11.4.6 to 11.9.0
|
|
32
|
+
- Bumps `@typescript-eslint/eslint-plugin` from 5.45.0 to 5.60.1
|
|
33
|
+
- Bumps `ember-velcro` to 2.1.0
|
|
34
|
+
- Bumps `@lblod/ember-rdfa-editor` to 4.0.0
|
|
35
|
+
- Bumps `ember-resources` from 5.6.2 to 6.1.1
|
|
36
|
+
|
|
10
37
|
## [8.2.2] - 2023-06-28
|
|
11
38
|
|
|
12
39
|
### Fixed
|
|
@@ -59,6 +86,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
59
86
|
### Fixed
|
|
60
87
|
- Change problematic type in citation that made it to break with new ember
|
|
61
88
|
|
|
89
|
+
|
|
62
90
|
## [8.0.0] - 2023-06-15
|
|
63
91
|
### Fixed
|
|
64
92
|
- Bump `@lblod/ember-rdfa-editor` package to fix annotation not present for some structures
|
|
@@ -520,7 +548,7 @@ add onclick handler to pencil icon in variable plugin
|
|
|
520
548
|
|
|
521
549
|
# Changelog
|
|
522
550
|
|
|
523
|
-
[unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.
|
|
551
|
+
[unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.4.0...HEAD
|
|
524
552
|
[8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.0.0...v8.0.1
|
|
525
553
|
[8.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.1.0...v8.0.0
|
|
526
554
|
[7.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v7.0.0...v7.1.0
|
|
@@ -536,6 +564,8 @@ add onclick handler to pencil icon in variable plugin
|
|
|
536
564
|
[3.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.2...v3.0.0
|
|
537
565
|
[2.1.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.1...v2.1.2
|
|
538
566
|
[2.1.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v2.1.0...v2.1.1
|
|
567
|
+
[8.4.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.3.0...v8.4.0
|
|
568
|
+
[8.3.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.2...v8.3.0
|
|
539
569
|
[8.2.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.1...v8.2.2
|
|
540
570
|
[8.2.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.2.0...v8.2.1
|
|
541
571
|
[8.2.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v8.1.0...v8.2.0
|
|
@@ -206,47 +206,24 @@
|
|
|
206
206
|
{{/if}}
|
|
207
207
|
{{/if}}
|
|
208
208
|
{{#if this.decisionResource.value.length}}
|
|
209
|
-
{{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
<AuButton
|
|
228
|
-
@skin='link'
|
|
229
|
-
@icon='nav-left'
|
|
230
|
-
@iconAlignment='left'
|
|
231
|
-
{{on 'click' this.previousPage}}
|
|
232
|
-
>
|
|
233
|
-
{{t 'citaten-plugin.pagination.previous'}}
|
|
234
|
-
</AuButton>
|
|
235
|
-
{{/unless}}
|
|
236
|
-
{{#unless this.isLastPage}}
|
|
237
|
-
<AuButton
|
|
238
|
-
@skin='link'
|
|
239
|
-
@icon='nav-right'
|
|
240
|
-
@iconAlignment='right'
|
|
241
|
-
{{on 'click' this.nextPage}}
|
|
242
|
-
>
|
|
243
|
-
{{t 'citaten-plugin.pagination.next'}}
|
|
244
|
-
</AuButton>
|
|
245
|
-
{{/unless}}
|
|
246
|
-
</div>
|
|
247
|
-
</div>
|
|
248
|
-
</AuToolbar>
|
|
249
|
-
</div>
|
|
209
|
+
{{#let
|
|
210
|
+
(pagination
|
|
211
|
+
page=this.pageNumber
|
|
212
|
+
pageSize=this.pageSize
|
|
213
|
+
count=this.totalCount
|
|
214
|
+
)
|
|
215
|
+
as |pg|
|
|
216
|
+
}}
|
|
217
|
+
<Pagination::PaginationView
|
|
218
|
+
@totalCount={{pg.count}}
|
|
219
|
+
@rangeStart={{pg.pageStart}}
|
|
220
|
+
@rangeEnd={{pg.pageEnd}}
|
|
221
|
+
@onNextPage={{this.nextPage}}
|
|
222
|
+
@onPreviousPage={{this.previousPage}}
|
|
223
|
+
@isFirstPage={{not pg.hasPreviousPage}}
|
|
224
|
+
@isLastPage={{not pg.hasNextPage}}
|
|
225
|
+
/>
|
|
226
|
+
{{/let}}
|
|
250
227
|
{{/if}}
|
|
251
228
|
</mc.content>
|
|
252
229
|
</AuMainContainer>
|
|
@@ -108,23 +108,6 @@ export default class EditorPluginsCitationsSearchModalComponent extends Componen
|
|
|
108
108
|
return this.inputSearchText ?? this.text;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
get rangeStart() {
|
|
112
|
-
return this.pageNumber * this.pageSize + 1;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
get rangeEnd() {
|
|
116
|
-
const end = this.rangeStart + this.pageSize - 1;
|
|
117
|
-
return end > this.totalCount ? this.totalCount : end;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
get isFirstPage() {
|
|
121
|
-
return this.pageNumber == 0;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
get isLastPage() {
|
|
125
|
-
return this.rangeEnd == this.totalCount;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
111
|
resourceSearch = restartableTask(async () => {
|
|
129
112
|
await timeout(500);
|
|
130
113
|
this.error = null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { inject as service } from '@ember/service';
|
|
4
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
5
|
+
import IntlService from 'ember-intl/services/intl';
|
|
6
|
+
import insertDocumentTitle from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/document-title-plugin/commands/insert-document-title';
|
|
7
|
+
|
|
8
|
+
type Args = {
|
|
9
|
+
controller: SayController;
|
|
10
|
+
};
|
|
11
|
+
export default class InsertTitleCardComponent extends Component<Args> {
|
|
12
|
+
@service declare intl: IntlService;
|
|
13
|
+
|
|
14
|
+
@action
|
|
15
|
+
insertTitle() {
|
|
16
|
+
this.args.controller.doCommand(
|
|
17
|
+
insertDocumentTitle({
|
|
18
|
+
placeholder: this.intl.t(
|
|
19
|
+
'document-title-plugin.document-title-placeholder'
|
|
20
|
+
),
|
|
21
|
+
}),
|
|
22
|
+
{
|
|
23
|
+
view: this.args.controller.mainEditorView,
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
this.args.controller.focus();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get canInsertTitle() {
|
|
30
|
+
return this.args.controller.checkCommand(
|
|
31
|
+
insertDocumentTitle({
|
|
32
|
+
placeholder: this.intl.t(
|
|
33
|
+
'document-title-plugin.document-title-placeholder'
|
|
34
|
+
),
|
|
35
|
+
}),
|
|
36
|
+
{
|
|
37
|
+
view: this.args.controller.mainEditorView,
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<div class='au-u-background-gray-100'>
|
|
2
|
+
<AuToolbar @border='top' @size='large' @nowrap={{true}}>
|
|
3
|
+
<div class='au-c-pagination'>
|
|
4
|
+
<p>
|
|
5
|
+
<span class='au-u-hidden-visually'>
|
|
6
|
+
{{t 'pagination.results'}}</span>
|
|
7
|
+
<strong>
|
|
8
|
+
{{@rangeStart}}
|
|
9
|
+
-
|
|
10
|
+
{{@rangeEnd}}
|
|
11
|
+
</strong>
|
|
12
|
+
{{t 'pagination.of'}}
|
|
13
|
+
{{@totalCount}}
|
|
14
|
+
</p>
|
|
15
|
+
<div class='au-u-flex'>
|
|
16
|
+
{{#unless @isFirstPage}}
|
|
17
|
+
<AuButton
|
|
18
|
+
@skin='link'
|
|
19
|
+
@icon='nav-left'
|
|
20
|
+
@iconAlignment='left'
|
|
21
|
+
{{on 'click' @onPreviousPage}}
|
|
22
|
+
>
|
|
23
|
+
{{t 'pagination.previous'}}
|
|
24
|
+
</AuButton>
|
|
25
|
+
{{/unless}}
|
|
26
|
+
{{#unless @isLastPage}}
|
|
27
|
+
<AuButton
|
|
28
|
+
@skin='link'
|
|
29
|
+
@icon='nav-right'
|
|
30
|
+
@iconAlignment='right'
|
|
31
|
+
{{on 'click' @onNextPage}}
|
|
32
|
+
>
|
|
33
|
+
{{t 'pagination.next'}}
|
|
34
|
+
</AuButton>
|
|
35
|
+
{{/unless}}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</AuToolbar>
|
|
39
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<AuAlert
|
|
2
|
+
@title='{{t "snippet-plugin.modal.alert.error-title"}}'
|
|
3
|
+
@skin='error'
|
|
4
|
+
@icon='alert-triangle'
|
|
5
|
+
@closable={{false}}
|
|
6
|
+
class='au-u-margin au-u-margin-top-none'
|
|
7
|
+
...attributes
|
|
8
|
+
>
|
|
9
|
+
<p>{{t 'snippet-plugin.modal.alert.error-intro'}}</p>
|
|
10
|
+
<code class='au-u-error snippet-modal--error-code'>{{@error}}</code>
|
|
11
|
+
<p>
|
|
12
|
+
{{t 'snippet-plugin.modal.alert.error-outro'}}
|
|
13
|
+
<AuLinkExternal
|
|
14
|
+
href='mailto:Gelinkt-Notuleren@vlaanderen.be'
|
|
15
|
+
@icon='mail'
|
|
16
|
+
@iconAlignment='left'
|
|
17
|
+
>
|
|
18
|
+
{{! template-lint-disable no-bare-strings }}
|
|
19
|
+
Gelinkt-Notuleren@vlaanderen.be
|
|
20
|
+
</AuLinkExternal>.
|
|
21
|
+
</p>
|
|
22
|
+
</AuAlert>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<AuModal
|
|
2
|
+
@modalOpen={{@open}}
|
|
3
|
+
@closeModal={{this.closeModal}}
|
|
4
|
+
@title={{t 'snippet-plugin.modal.title'}}
|
|
5
|
+
@size='large'
|
|
6
|
+
@padding='none'
|
|
7
|
+
as |modal|
|
|
8
|
+
>
|
|
9
|
+
<modal.Body>
|
|
10
|
+
<AuMainContainer class='snippet-modal--main-container' as |mc|>
|
|
11
|
+
<mc.sidebar>
|
|
12
|
+
<div class='au-c-sidebar'>
|
|
13
|
+
<div class='au-c-sidebar__content au-u-padding'>
|
|
14
|
+
<AuHeading @level='3' @skin='4' class='au-u-padding-bottom-small'>
|
|
15
|
+
{{t 'snippet-plugin.modal.search.title'}}
|
|
16
|
+
</AuHeading>
|
|
17
|
+
<AuLabel
|
|
18
|
+
class='au-margin-bottom-small'
|
|
19
|
+
for='searchTerm'
|
|
20
|
+
@inline={{false}}
|
|
21
|
+
@required={{false}}
|
|
22
|
+
@error={{false}}
|
|
23
|
+
@warning={{false}}
|
|
24
|
+
>
|
|
25
|
+
{{t 'snippet-plugin.modal.search.label'}}
|
|
26
|
+
</AuLabel>
|
|
27
|
+
<AuNativeInput
|
|
28
|
+
@type='text'
|
|
29
|
+
@width='block'
|
|
30
|
+
id='searchTerm'
|
|
31
|
+
value={{this.searchText}}
|
|
32
|
+
placeholder={{t 'snippet-plugin.modal.search.placeholder'}}
|
|
33
|
+
{{on 'input' this.setInputSearchText}}
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</mc.sidebar>
|
|
38
|
+
<mc.content @scroll={{true}}>
|
|
39
|
+
<div class='au-u-padding-top snippet-modal--list-container'>
|
|
40
|
+
{{#if this.snippetsResource.isRunning}}
|
|
41
|
+
<div class='au-u-margin'>
|
|
42
|
+
<AuLoader @padding='large' />
|
|
43
|
+
<span class='au-u-hidden-visually'>
|
|
44
|
+
{{t 'snippet-plugin.alert.loading'}}
|
|
45
|
+
</span>
|
|
46
|
+
</div>
|
|
47
|
+
{{else}}
|
|
48
|
+
{{#if this.error}}
|
|
49
|
+
<SnippetPlugin::Helpers::AlertLoadError @error={{this.error}} />
|
|
50
|
+
{{else}}
|
|
51
|
+
{{#if this.snippetsResource.value.length}}
|
|
52
|
+
<SnippetPlugin::Snippets::SnippetList
|
|
53
|
+
@snippets={{this.snippetsResource.value}}
|
|
54
|
+
@onInsert={{@onInsert}}
|
|
55
|
+
/>
|
|
56
|
+
{{else}}
|
|
57
|
+
<SnippetPlugin::Helpers::AlertNoItems />
|
|
58
|
+
{{/if}}
|
|
59
|
+
{{/if}}
|
|
60
|
+
{{/if}}
|
|
61
|
+
</div>
|
|
62
|
+
{{#if this.snippetsResource.value.length}}
|
|
63
|
+
{{#let
|
|
64
|
+
(pagination
|
|
65
|
+
page=this.pageNumber pageSize=this.pageSize count=this.totalCount
|
|
66
|
+
)
|
|
67
|
+
as |pg|
|
|
68
|
+
}}
|
|
69
|
+
<Pagination::PaginationView
|
|
70
|
+
@totalCount={{pg.count}}
|
|
71
|
+
@rangeStart={{pg.pageStart}}
|
|
72
|
+
@rangeEnd={{pg.pageEnd}}
|
|
73
|
+
@onNextPage={{this.nextPage}}
|
|
74
|
+
@onPreviousPage={{this.previousPage}}
|
|
75
|
+
@isFirstPage={{not pg.hasPreviousPage}}
|
|
76
|
+
@isLastPage={{not pg.hasNextPage}}
|
|
77
|
+
/>
|
|
78
|
+
{{/let}}
|
|
79
|
+
{{/if}}
|
|
80
|
+
</mc.content>
|
|
81
|
+
</AuMainContainer>
|
|
82
|
+
</modal.Body>
|
|
83
|
+
</AuModal>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { assert } from '@ember/debug';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import { restartableTask, timeout } from 'ember-concurrency';
|
|
5
|
+
import { task as trackedTask } from 'ember-resources/util/ember-concurrency';
|
|
6
|
+
|
|
7
|
+
import { tracked } from '@glimmer/tracking';
|
|
8
|
+
|
|
9
|
+
import { fetchSnippets } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/fetch-data';
|
|
10
|
+
import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
11
|
+
|
|
12
|
+
interface Args {
|
|
13
|
+
config: SnippetPluginConfig;
|
|
14
|
+
closeModal: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class SnippetPluginSearchModalComponent extends Component<Args> {
|
|
18
|
+
// Filtering
|
|
19
|
+
@tracked inputSearchText: string | null = null;
|
|
20
|
+
|
|
21
|
+
// Display
|
|
22
|
+
@tracked error: unknown;
|
|
23
|
+
|
|
24
|
+
// Pagination
|
|
25
|
+
@tracked pageNumber = 0;
|
|
26
|
+
@tracked pageSize = 20;
|
|
27
|
+
@tracked totalCount = 0;
|
|
28
|
+
|
|
29
|
+
get config() {
|
|
30
|
+
return this.args.config;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get searchText() {
|
|
34
|
+
return this.inputSearchText;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@action
|
|
38
|
+
setInputSearchText(event: InputEvent) {
|
|
39
|
+
assert(
|
|
40
|
+
'inputSearchText must be bound to an input element',
|
|
41
|
+
event.target instanceof HTMLInputElement
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
this.inputSearchText = event.target.value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@action
|
|
48
|
+
async closeModal() {
|
|
49
|
+
await this.snippetsResource.cancel();
|
|
50
|
+
this.args.closeModal();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
snippetsSearch = restartableTask(async () => {
|
|
54
|
+
await timeout(500);
|
|
55
|
+
|
|
56
|
+
const abortController = new AbortController();
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const queryResult = await fetchSnippets({
|
|
60
|
+
endpoint: this.args.config.endpoint,
|
|
61
|
+
abortSignal: abortController.signal,
|
|
62
|
+
filter: {
|
|
63
|
+
name: this.inputSearchText ?? undefined,
|
|
64
|
+
},
|
|
65
|
+
pagination: {
|
|
66
|
+
pageNumber: this.pageNumber,
|
|
67
|
+
pageSize: this.pageSize,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
this.totalCount = queryResult.totalCount;
|
|
72
|
+
|
|
73
|
+
return queryResult.results;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
this.error = error;
|
|
76
|
+
return [];
|
|
77
|
+
} finally {
|
|
78
|
+
abortController.abort();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
snippetsResource = trackedTask(this, this.snippetsSearch, () => [
|
|
83
|
+
this.inputSearchText,
|
|
84
|
+
this.pageNumber,
|
|
85
|
+
this.pageSize,
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
@action
|
|
89
|
+
previousPage() {
|
|
90
|
+
--this.pageNumber;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@action
|
|
94
|
+
nextPage() {
|
|
95
|
+
++this.pageNumber;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<AuList::Item>
|
|
2
|
+
<AuButton
|
|
3
|
+
@icon='add'
|
|
4
|
+
@iconAlignment='left'
|
|
5
|
+
@skin='link'
|
|
6
|
+
{{on 'click' this.openModal}}
|
|
7
|
+
>
|
|
8
|
+
{{t 'snippet-plugin.insert.title'}}
|
|
9
|
+
</AuButton>
|
|
10
|
+
</AuList::Item>
|
|
11
|
+
|
|
12
|
+
<SnippetPlugin::SearchModal
|
|
13
|
+
@open={{this.showModal}}
|
|
14
|
+
@closeModal={{this.closeModal}}
|
|
15
|
+
@config={{this.config}}
|
|
16
|
+
@onInsert={{this.onInsert}}
|
|
17
|
+
/>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
|
|
3
|
+
import Component from '@glimmer/component';
|
|
4
|
+
import { tracked } from '@glimmer/tracking';
|
|
5
|
+
|
|
6
|
+
import { ProseParser, SayController } from '@lblod/ember-rdfa-editor';
|
|
7
|
+
import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
8
|
+
|
|
9
|
+
interface Args {
|
|
10
|
+
controller: SayController;
|
|
11
|
+
config: SnippetPluginConfig;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default class SnippetInsertComponent extends Component<Args> {
|
|
15
|
+
@tracked showModal = false;
|
|
16
|
+
|
|
17
|
+
get controller() {
|
|
18
|
+
return this.args.controller;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get config() {
|
|
22
|
+
return this.args.config;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@action
|
|
26
|
+
openModal() {
|
|
27
|
+
this.controller.focus();
|
|
28
|
+
this.showModal = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@action
|
|
32
|
+
closeModal() {
|
|
33
|
+
this.showModal = false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@action
|
|
37
|
+
onInsert(content: string) {
|
|
38
|
+
const domParser = new DOMParser();
|
|
39
|
+
|
|
40
|
+
this.closeModal();
|
|
41
|
+
|
|
42
|
+
this.controller.withTransaction((tr) => {
|
|
43
|
+
return tr.replaceSelectionWith(
|
|
44
|
+
ProseParser.fromSchema(this.controller.schema).parse(
|
|
45
|
+
domParser.parseFromString(content, 'text/html')
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{{#if @snippets.length}}
|
|
2
|
+
<AuList @direction='vertical'>
|
|
3
|
+
{{#each @snippets as |snippet|}}
|
|
4
|
+
<AuList::Item>
|
|
5
|
+
<SnippetPlugin::Snippets::SnippetPreview
|
|
6
|
+
@snippet={{snippet}}
|
|
7
|
+
@onInsert={{@onInsert}}
|
|
8
|
+
/>
|
|
9
|
+
</AuList::Item>
|
|
10
|
+
{{/each}}
|
|
11
|
+
</AuList>
|
|
12
|
+
{{/if}}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<div
|
|
2
|
+
class='snippet-preview--container au-c-panel au-u-margin-right'
|
|
3
|
+
...attributes
|
|
4
|
+
>
|
|
5
|
+
<div
|
|
6
|
+
class='snippet-preview--article au-u-padding au-u-padding-right-large rdfa-annotations rdfa-annotations-highlight rdfa-annotations-hover'
|
|
7
|
+
>
|
|
8
|
+
<h3 class='snippet-preview--title au-u-margin-bottom'>
|
|
9
|
+
{{@snippet.title}}
|
|
10
|
+
</h3>
|
|
11
|
+
<div class="snippet-preview--editor-container">
|
|
12
|
+
<div class="say-container__main">
|
|
13
|
+
<div class="say-editor">
|
|
14
|
+
<div class="say-editor__inner say-content">
|
|
15
|
+
{{this.snippet.content}}
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="snippet-preview--editor-overlay"></div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
<div class='snippet-preview--button au-u-padding-small'>
|
|
23
|
+
<AuButton @skin='naked' {{on 'click' this.onInsert}}>
|
|
24
|
+
{{t 'snippet-plugin.modal.select'}}
|
|
25
|
+
</AuButton>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { action } from '@ember/object';
|
|
2
|
+
import Component from '@glimmer/component';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
|
|
5
|
+
import { SayController } from '@lblod/ember-rdfa-editor';
|
|
6
|
+
import {
|
|
7
|
+
Snippet,
|
|
8
|
+
SnippetPluginConfig,
|
|
9
|
+
} from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
|
|
10
|
+
|
|
11
|
+
interface Args {
|
|
12
|
+
config: SnippetPluginConfig;
|
|
13
|
+
snippet: Snippet;
|
|
14
|
+
onInsert: (content: string) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class SnippetPreviewComponent extends Component<Args> {
|
|
18
|
+
@tracked controller?: SayController;
|
|
19
|
+
|
|
20
|
+
get snippet(): Snippet {
|
|
21
|
+
return this.args.snippet;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@action
|
|
25
|
+
onInsert() {
|
|
26
|
+
this.args.onInsert(this.args.snippet.content?.toHTML() ?? '');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { helper } from '@ember/component/helper';
|
|
2
|
+
|
|
3
|
+
import { isSome } from '../utils/option';
|
|
4
|
+
|
|
5
|
+
interface PaginationArguments {
|
|
6
|
+
count: number;
|
|
7
|
+
pageSize: number;
|
|
8
|
+
page: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function pagination({
|
|
12
|
+
page = 0,
|
|
13
|
+
count = 0,
|
|
14
|
+
pageSize = 20,
|
|
15
|
+
}: PaginationArguments) {
|
|
16
|
+
const totalPages = count / pageSize;
|
|
17
|
+
const pageStart = page * pageSize + 1;
|
|
18
|
+
const pageEnd = Math.min((page + 1) * pageSize, count);
|
|
19
|
+
const nextPage = page < totalPages - 1 ? page + 1 : null;
|
|
20
|
+
const previousPage = page > 0 ? page - 1 : null;
|
|
21
|
+
const hasPreviousPage = isSome(previousPage);
|
|
22
|
+
const hasNextPage = isSome(nextPage);
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
count,
|
|
26
|
+
pageSize,
|
|
27
|
+
page,
|
|
28
|
+
totalPages,
|
|
29
|
+
pageStart,
|
|
30
|
+
pageEnd,
|
|
31
|
+
nextPage,
|
|
32
|
+
previousPage,
|
|
33
|
+
hasPreviousPage,
|
|
34
|
+
hasNextPage,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default helper<unknown[], PaginationArguments>((_, named) =>
|
|
39
|
+
pagination(named)
|
|
40
|
+
);
|