@lblod/ember-rdfa-editor-lblod-plugins 17.0.0 → 17.1.0-dev.5ef7157df31959f86fc3e3d7580e55098a911fa7

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.
Files changed (153) hide show
  1. package/.changeset/afraid-tips-visit.md +5 -0
  2. package/.changeset/chilly-ravens-think.md +6 -0
  3. package/.changeset/clean-parrots-beam.md +5 -0
  4. package/.changeset/hot-owls-laugh.md +5 -0
  5. package/.changeset/olive-pets-cheer.md +5 -0
  6. package/.changeset/smooth-fireants-doubt.md +5 -0
  7. package/.changeset/spotty-lions-notice.md +5 -0
  8. package/.changeset/tall-carrots-ring.md +5 -0
  9. package/.changeset/wet-baboons-serve.md +5 -0
  10. package/.changeset/witty-suns-speak.md +5 -0
  11. package/.woodpecker/.release-commit.yml +18 -0
  12. package/.woodpecker/.release.yml +21 -0
  13. package/.woodpecker/.verify-pr.yml +30 -0
  14. package/CHANGELOG.md +13 -0
  15. package/Dockerfile +6 -4
  16. package/addon/commands/index.ts +1 -0
  17. package/addon/commands/replace-selection-and-select-node.ts +24 -0
  18. package/addon/components/article-structure-plugin/structure-card.hbs +1 -1
  19. package/addon/components/article-structure-plugin/structure-card.ts +43 -35
  20. package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +40 -20
  21. package/addon/components/citation-plugin/citation-card.ts +6 -2
  22. package/addon/components/import-snippet-plugin/card.ts +7 -2
  23. package/addon/components/snippet-plugin/snippet-insert-rdfa.hbs +7 -0
  24. package/addon/components/snippet-plugin/snippet-insert-rdfa.ts +78 -0
  25. package/addon/components/snippet-plugin/snippet-insert.hbs +1 -0
  26. package/addon/components/snippet-plugin/snippet-insert.ts +22 -4
  27. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +11 -45
  28. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +14 -22
  29. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +56 -29
  30. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.ts +34 -1
  31. package/addon/components/snippet-plugin/snippet-list-select-rdfa.hbs +8 -0
  32. package/addon/components/snippet-plugin/snippet-list-select-rdfa.ts +69 -0
  33. package/addon/components/snippet-plugin/snippets/snippet-preview.hbs +1 -11
  34. package/addon/components/standard-template-plugin/template-provider.ts +10 -4
  35. package/addon/components/variable-plugin/address/nodeview.hbs +2 -2
  36. package/addon/components/variable-plugin/address/nodeview.ts +6 -0
  37. package/addon/components/variable-plugin/address/utils.ts +28 -3
  38. package/addon/components/variable-plugin/codelist/edit.ts +24 -7
  39. package/addon/components/variable-plugin/codelist/insert.ts +52 -17
  40. package/addon/components/variable-plugin/date/edit.ts +43 -8
  41. package/addon/components/variable-plugin/date/insert-variable.ts +36 -10
  42. package/addon/components/variable-plugin/date/insert.ts +35 -10
  43. package/addon/components/variable-plugin/date/nodeview.hbs +2 -2
  44. package/addon/components/variable-plugin/date/nodeview.ts +8 -1
  45. package/addon/components/variable-plugin/insert-variable-card.ts +8 -1
  46. package/addon/components/variable-plugin/location/edit.ts +1 -9
  47. package/addon/components/variable-plugin/location/insert.ts +4 -7
  48. package/addon/components/variable-plugin/location/nodeview.hbs +18 -8
  49. package/addon/components/variable-plugin/location/nodeview.ts +37 -9
  50. package/addon/components/variable-plugin/number/insert.ts +34 -10
  51. package/addon/components/variable-plugin/number/nodeview.hbs +2 -2
  52. package/addon/components/variable-plugin/number/nodeview.ts +30 -5
  53. package/addon/components/variable-plugin/text/insert.ts +40 -12
  54. package/addon/components/variable-plugin/variable/nodeview.hbs +5 -2
  55. package/addon/components/variable-plugin/variable/nodeview.ts +13 -9
  56. package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +86 -16
  57. package/addon/plugins/article-structure-plugin/commands/move-selected-structure.ts +2 -1
  58. package/addon/plugins/article-structure-plugin/commands/recalculate-structure-numbers.ts +70 -2
  59. package/addon/plugins/article-structure-plugin/commands/remove-structure.ts +1 -1
  60. package/addon/plugins/article-structure-plugin/commands/set-structure-start-number.ts +5 -14
  61. package/addon/plugins/article-structure-plugin/commands/unwrap-structure.ts +1 -1
  62. package/addon/plugins/article-structure-plugin/commands/wrap-structure-content.ts +197 -105
  63. package/addon/plugins/article-structure-plugin/index.ts +16 -7
  64. package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +181 -71
  65. package/addon/plugins/article-structure-plugin/structures/article.ts +91 -98
  66. package/addon/plugins/article-structure-plugin/structures/chapter.ts +89 -39
  67. package/addon/plugins/article-structure-plugin/structures/index.ts +12 -1
  68. package/addon/plugins/article-structure-plugin/structures/section.ts +88 -39
  69. package/addon/plugins/article-structure-plugin/structures/structure-header-number.ts +56 -0
  70. package/addon/plugins/article-structure-plugin/structures/structure-header-title.ts +38 -0
  71. package/addon/plugins/article-structure-plugin/structures/structure-header.ts +87 -73
  72. package/addon/plugins/article-structure-plugin/structures/subsection.ts +81 -39
  73. package/addon/plugins/article-structure-plugin/structures/title.ts +91 -39
  74. package/addon/plugins/article-structure-plugin/utils/structure.ts +223 -127
  75. package/addon/plugins/citation-plugin/utils/cited-text.ts +38 -8
  76. package/addon/plugins/confidentiality-plugin/marks/redacted.ts +1 -1
  77. package/addon/plugins/document-title-plugin/nodes/document-title.ts +4 -3
  78. package/addon/plugins/roadsign-regulation-plugin/nodes.ts +4 -3
  79. package/addon/plugins/snippet-plugin/commands/index.ts +1 -0
  80. package/addon/plugins/snippet-plugin/commands/update-snippet-ids.ts +55 -0
  81. package/addon/plugins/snippet-plugin/index.ts +6 -1
  82. package/addon/plugins/snippet-plugin/utils/fetch-data.ts +29 -2
  83. package/addon/plugins/snippet-plugin/utils/rdfa-predicate.ts +33 -0
  84. package/addon/plugins/standard-template-plugin/utils/nodes.ts +294 -81
  85. package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +3 -2
  86. package/addon/plugins/variable-plugin/utils/attribute-parsers.ts +19 -1
  87. package/addon/plugins/variable-plugin/variables/address.ts +93 -26
  88. package/addon/plugins/variable-plugin/variables/codelist.ts +99 -50
  89. package/addon/plugins/variable-plugin/variables/date.ts +138 -51
  90. package/addon/plugins/variable-plugin/variables/location.ts +2 -0
  91. package/addon/plugins/variable-plugin/variables/number.ts +99 -52
  92. package/addon/plugins/variable-plugin/variables/text.ts +80 -28
  93. package/addon/utils/_private/find-insertion-range.ts +18 -5
  94. package/addon/utils/dom-utils.ts +4 -0
  95. package/addon/utils/namespace.ts +63 -13
  96. package/app/components/snippet-plugin/snippet-list-insert-rdfa.js +1 -0
  97. package/app/components/snippet-plugin/snippet-list-select-rdfa.js +1 -0
  98. package/app/styles/article-structure-plugin.scss +106 -3
  99. package/app/styles/snippet-plugin.scss +11 -0
  100. package/declarations/addon/commands/index.d.ts +1 -0
  101. package/declarations/addon/commands/replace-selection-and-select-node.d.ts +3 -0
  102. package/declarations/addon/components/article-structure-plugin/structure-card.d.ts +2 -2
  103. package/declarations/addon/components/besluit-type-plugin/toolbar-dropdown.d.ts +0 -5
  104. package/declarations/addon/components/citation-plugin/citation-card.d.ts +2 -2
  105. package/declarations/addon/components/citation-plugin/citations/article-preview.d.ts +1 -1
  106. package/declarations/addon/components/common/search/alert-load-error.d.ts +1 -1
  107. package/declarations/addon/components/common/search/alert-no-items.d.ts +1 -1
  108. package/declarations/addon/components/confidentiality-plugin/redact.d.ts +1 -1
  109. package/declarations/addon/components/import-snippet-plugin/card.d.ts +6 -5
  110. package/declarations/addon/components/pagination/pagination-view.d.ts +1 -1
  111. package/declarations/addon/components/snippet-plugin/snippet-insert-rdfa.d.ts +19 -0
  112. package/declarations/addon/components/snippet-plugin/snippet-insert.d.ts +2 -0
  113. package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-modal.d.ts +3 -3
  114. package/declarations/addon/components/snippet-plugin/snippet-list/snippet-list-view.d.ts +6 -1
  115. package/declarations/addon/components/snippet-plugin/snippet-list-select-rdfa.d.ts +21 -0
  116. package/declarations/addon/components/variable-plugin/address/edit.d.ts +1 -1
  117. package/declarations/addon/components/variable-plugin/address/nodeview.d.ts +1 -0
  118. package/declarations/addon/components/variable-plugin/date/edit.d.ts +2 -2
  119. package/declarations/addon/components/variable-plugin/date/nodeview.d.ts +1 -0
  120. package/declarations/addon/components/variable-plugin/insert-variable-card.d.ts +8 -1
  121. package/declarations/addon/components/variable-plugin/location/edit.d.ts +0 -1
  122. package/declarations/addon/components/variable-plugin/location/nodeview.d.ts +8 -9
  123. package/declarations/addon/components/variable-plugin/number/nodeview.d.ts +3 -1
  124. package/declarations/addon/components/variable-plugin/text/insert.d.ts +1 -1
  125. package/declarations/addon/components/variable-plugin/variable/nodeview.d.ts +5 -6
  126. package/declarations/addon/plugins/article-structure-plugin/commands/recalculate-structure-numbers.d.ts +2 -2
  127. package/declarations/addon/plugins/article-structure-plugin/commands/set-structure-start-number.d.ts +5 -2
  128. package/declarations/addon/plugins/article-structure-plugin/commands/wrap-structure-content.d.ts +1 -1
  129. package/declarations/addon/plugins/article-structure-plugin/index.d.ts +15 -7
  130. package/declarations/addon/plugins/article-structure-plugin/structures/article-paragraph.d.ts +2 -0
  131. package/declarations/addon/plugins/article-structure-plugin/structures/article.d.ts +3 -4
  132. package/declarations/addon/plugins/article-structure-plugin/structures/index.d.ts +4 -0
  133. package/declarations/addon/plugins/article-structure-plugin/structures/structure-header-number.d.ts +2 -0
  134. package/declarations/addon/plugins/article-structure-plugin/structures/structure-header-title.d.ts +2 -0
  135. package/declarations/addon/plugins/article-structure-plugin/structures/structure-header.d.ts +16 -1
  136. package/declarations/addon/plugins/article-structure-plugin/utils/structure.d.ts +20 -14
  137. package/declarations/addon/plugins/confidentiality-plugin/marks/redacted.d.ts +1 -1
  138. package/declarations/addon/plugins/snippet-plugin/commands/index.d.ts +1 -0
  139. package/declarations/addon/plugins/snippet-plugin/commands/update-snippet-ids.d.ts +8 -0
  140. package/declarations/addon/plugins/snippet-plugin/index.d.ts +2 -0
  141. package/declarations/addon/plugins/snippet-plugin/utils/fetch-data.d.ts +3 -1
  142. package/declarations/addon/plugins/snippet-plugin/utils/rdfa-predicate.d.ts +5 -0
  143. package/declarations/addon/plugins/variable-plugin/utils/attribute-parsers.d.ts +3 -0
  144. package/declarations/addon/utils/_private/find-insertion-range.d.ts +7 -4
  145. package/declarations/addon/utils/dom-utils.d.ts +2 -0
  146. package/declarations/addon/utils/namespace.d.ts +11 -2
  147. package/package.json +15 -8
  148. package/pnpm-lock.yaml +17788 -0
  149. package/translations/en-US.yaml +1 -0
  150. package/translations/nl-BE.yaml +1 -0
  151. package/tsconfig.main.json +0 -3
  152. package/types/graphy/memory.dataset.fast.d.ts +74 -0
  153. package/.woodpecker/.test.yml +0 -50
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ Remove `@import "ember-appuniversum"` statements from plugin sass modules in order to prevent style overrding.
@@ -0,0 +1,6 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ - Addition of the `say-template-comment` class to the static version of template comments.
6
+ - Addition of some extra styles to the `say-template-comment` class.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@lblod/ember-rdfa-editor-lblod-plugins": patch
3
+ ---
4
+
5
+ When passing a `content` argument to the `insertStructure` command, do not run the `wrapStructureContent` command
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ GN-4650: Fix behavior of "Insert snippet" button
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ GN-4650: Snippet selection placeholder in template
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': minor
3
+ ---
4
+
5
+ Add helper function to help with locale selection and add translation note to readme
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@lblod/ember-rdfa-editor-lblod-plugins": patch
3
+ ---
4
+
5
+ GN-4816: Fix selecting snippet list when pressing on a checkbox
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@lblod/ember-rdfa-editor-lblod-plugins': patch
3
+ ---
4
+
5
+ Fix template-comment padding
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@lblod/ember-rdfa-editor-lblod-plugins": minor
3
+ ---
4
+
5
+ Ensure that variables are node-selected/focused after insertion
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@lblod/ember-rdfa-editor-lblod-plugins": patch
3
+ ---
4
+
5
+ Allow to insert structure even if insertion range does not have RDFA attributes.
@@ -0,0 +1,18 @@
1
+ steps:
2
+ install:
3
+ image: node:20-slim
4
+ commands:
5
+ - corepack enable
6
+ - pnpm i --frozen-lockfile
7
+ version:
8
+ image: node:20-slim
9
+ commands:
10
+ - npm version --no-git-tag-version $(npm pkg get version | sed 's/"//g')-dev.${CI_COMMIT_SHA}
11
+ release:
12
+ image: plugins/npm
13
+ settings:
14
+ token:
15
+ from_secret: npm_access_token
16
+ tag: dev
17
+ when:
18
+ - event: push
@@ -0,0 +1,21 @@
1
+ steps:
2
+ install:
3
+ image: node:20-slim
4
+ commands:
5
+ - corepack enable
6
+ - pnpm i --frozen-lockfile
7
+ release:
8
+ image: plugins/npm
9
+ settings:
10
+ token:
11
+ from_secret: npm_access_token
12
+ push-tagged-build:
13
+ image: plugins/docker
14
+ settings:
15
+ repo: lblod/ember-rdfa-editor-lblod-plugins
16
+ tags: '${CI_COMMIT_TAG##v}'
17
+ purge: true
18
+ secrets: [docker_username, docker_password]
19
+ when:
20
+ event: tag
21
+ ref: refs/tags/v*
@@ -0,0 +1,30 @@
1
+ steps:
2
+ install:
3
+ image: node:20-slim
4
+ commands:
5
+ - corepack enable
6
+ - pnpm i --frozen-lockfile
7
+ lint-js:
8
+ image: node:20-slim
9
+ group: lint
10
+ commands:
11
+ - corepack enable
12
+ - pnpm lint:js
13
+ lint-hbs:
14
+ image: node:20-slim
15
+ group: lint
16
+ commands:
17
+ - corepack enable
18
+ - pnpm lint:hbs
19
+ test:
20
+ image: danlynn/ember-cli:4.12.1
21
+ commands:
22
+ - corepack enable
23
+ - pnpm test:ember
24
+ precompile:
25
+ image: node:20-slim
26
+ commands:
27
+ - corepack enable
28
+ - pnpm prepack
29
+ when:
30
+ - evaluate: 'CI_PIPELINE_EVENT == "pull_request" && not (CI_COMMIT_PULL_REQUEST_LABELS contains "dependabot")'
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 17.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#411](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/411) [`aca238e`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/aca238ecc541f069b5df5c80a00481c6540b584f) Thanks [@dkozickis](https://github.com/dkozickis)! - GN-4811: Only show the titles of the snippets
8
+
9
+ In the snippet insert modal: only show the titles of the snippets
10
+
11
+ - [#412](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/412) [`4ee0e95`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/4ee0e95c71d0cedce1f867058721ef3ea7d13f35) Thanks [@dkozickis](https://github.com/dkozickis)! - GN-4816: Add sorting for snippet lists
12
+
13
+ - Use `AuDataTable`
14
+ - Add sorting for snippet lists
15
+
3
16
  ## 17.0.0
4
17
 
5
18
  ### Major Changes
package/Dockerfile CHANGED
@@ -1,12 +1,14 @@
1
- FROM madnificent/ember:4.12.1-node_18 as builder
1
+ FROM node:20-slim AS builder
2
2
 
3
3
  LABEL maintainer="info@redpencil.io"
4
4
 
5
+ RUN corepack enable
6
+ RUN corepack prepare pnpm@latest-8 --activate
5
7
  WORKDIR /app
6
- COPY package.json package-lock.json ./
7
- RUN npm ci
8
+ COPY package.json pnpm-lock.yaml ./
9
+ RUN pnpm i --frozen-lockfile
8
10
  COPY . .
9
- RUN ember build -prod
11
+ RUN pnpm build
10
12
 
11
13
  FROM semtech/static-file-service:0.2.0
12
14
  COPY --from=builder /app/dist /data
@@ -0,0 +1 @@
1
+ export { default as replaceSelectionWithAndSelectNode } from './replace-selection-and-select-node';
@@ -0,0 +1,24 @@
1
+ import { Command, NodeSelection, PNode } from '@lblod/ember-rdfa-editor';
2
+
3
+ const replaceSelectionWithAndSelectNode = (node: PNode): Command => {
4
+ return (state, dispatch) => {
5
+ if (!node.type.spec.selectable) {
6
+ return false;
7
+ }
8
+
9
+ if (dispatch) {
10
+ const tr = state.tr;
11
+ tr.replaceSelectionWith(node);
12
+ if (tr.selection.$anchor.nodeBefore) {
13
+ const resolvedPos = tr.doc.resolve(
14
+ tr.selection.anchor - tr.selection.$anchor.nodeBefore?.nodeSize,
15
+ );
16
+ tr.setSelection(new NodeSelection(resolvedPos));
17
+ }
18
+ dispatch(tr);
19
+ }
20
+ return true;
21
+ };
22
+ };
23
+
24
+ export default replaceSelectionWithAndSelectNode;
@@ -94,7 +94,7 @@
94
94
  type="number"
95
95
  min="1"
96
96
  />
97
- {{/let}}
97
+ {{/let}}
98
98
  </AuFormRow>
99
99
  <AuButton
100
100
  @iconAlignment="left"
@@ -42,11 +42,45 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
42
42
  this.controller.focus();
43
43
  }
44
44
 
45
+ @action
46
+ removeStructure(withContent: boolean) {
47
+ if (this.structure && this.currentStructureType) {
48
+ if (withContent || this.currentStructureType.noUnwrap) {
49
+ this.controller.doCommand(
50
+ removeStructure(this.structure, this.structureTypes),
51
+ { view: this.controller.mainEditorView },
52
+ );
53
+ } else {
54
+ this.controller.doCommand(
55
+ unwrapStructure(
56
+ {
57
+ ...this.structure,
58
+ type: this.currentStructureType,
59
+ },
60
+ this.structureTypes,
61
+ ),
62
+ { view: this.controller.mainEditorView },
63
+ );
64
+ }
65
+ }
66
+ this.controller.focus();
67
+ }
68
+
69
+ @action
70
+ setRemoveStructureContent(value: boolean) {
71
+ this.removeStructureContent = value;
72
+ }
73
+
45
74
  @action
46
75
  setStructureStartNumber() {
47
- if (this.startNumber) {
76
+ if (this.startNumber && this.structure && this.currentStructureType) {
48
77
  this.controller.doCommand(
49
- setStructureStartNumber(this.structureTypes, this.startNumber),
78
+ setStructureStartNumber(
79
+ this.structure,
80
+ this.structureTypes,
81
+ this.startNumber,
82
+ ),
83
+ { view: this.controller.mainEditorView },
50
84
  );
51
85
 
52
86
  this.startNumber = null;
@@ -55,11 +89,14 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
55
89
 
56
90
  @action
57
91
  resetStructureStartNumber() {
58
- this.controller.doCommand(
59
- setStructureStartNumber(this.structureTypes, null),
60
- );
92
+ if (this.structure) {
93
+ this.controller.doCommand(
94
+ setStructureStartNumber(this.structure, this.structureTypes, null),
95
+ { view: this.controller.mainEditorView },
96
+ );
61
97
 
62
- this.startNumber = null;
98
+ this.startNumber = null;
99
+ }
63
100
  }
64
101
 
65
102
  get structureNumber() {
@@ -93,35 +130,6 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
93
130
  this.startNumber = parseInt(target.value);
94
131
  };
95
132
 
96
- @action
97
- removeStructure(withContent: boolean) {
98
- if (this.structure && this.currentStructureType) {
99
- if (withContent || this.currentStructureType.noUnwrap) {
100
- this.controller.doCommand(
101
- removeStructure(this.structure, this.structureTypes),
102
- { view: this.controller.mainEditorView },
103
- );
104
- } else {
105
- this.controller.doCommand(
106
- unwrapStructure(
107
- {
108
- ...this.structure,
109
- type: this.currentStructureType,
110
- },
111
- this.structureTypes,
112
- ),
113
- { view: this.controller.mainEditorView },
114
- );
115
- }
116
- }
117
- this.controller.focus();
118
- }
119
-
120
- @action
121
- setRemoveStructureContent(value: boolean) {
122
- this.removeStructureContent = value;
123
- }
124
-
125
133
  get structureTypes() {
126
134
  return this.args.options;
127
135
  }
@@ -1,13 +1,10 @@
1
1
  import { tracked } from '@glimmer/tracking';
2
2
  import Component from '@glimmer/component';
3
3
  import { action } from '@ember/object';
4
- import {
5
- addType,
6
- removeType,
7
- } from '@lblod/ember-rdfa-editor/commands/type-commands';
4
+ import { addProperty, removeProperty } from '@lblod/ember-rdfa-editor/commands';
8
5
  import { SayController } from '@lblod/ember-rdfa-editor';
6
+ import { sayDataFactory } from '@lblod/ember-rdfa-editor/core/say-data-factory';
9
7
  import { ResolvedPNode } from '@lblod/ember-rdfa-editor/plugins/datastore';
10
- import { getRdfaAttribute } from '@lblod/ember-rdfa-editor/utils/rdfa-utils';
11
8
  import fetchBesluitTypes, {
12
9
  BesluitType,
13
10
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin/utils/fetchBesluitTypes';
@@ -15,17 +12,13 @@ import { findAncestorOfType } from '@lblod/ember-rdfa-editor-lblod-plugins/plugi
15
12
  import { trackedFunction } from 'ember-resources/util/function';
16
13
  import { unwrap } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/option';
17
14
  import { BesluitTypePluginOptions } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/besluit-type-plugin';
15
+ import { RDF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
16
+ import { getOutgoingTripleList } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
18
17
  import { AlertTriangleIcon } from '@appuniversum/ember-appuniversum/components/icons/alert-triangle';
19
18
  import { CrossIcon } from '@appuniversum/ember-appuniversum/components/icons/cross';
20
19
  import { MailIcon } from '@appuniversum/ember-appuniversum/components/icons/mail';
21
20
  import { CircleXIcon } from '@appuniversum/ember-appuniversum/components/icons/circle-x';
22
21
 
23
- declare module 'ember__owner' {
24
- export default interface Owner {
25
- resolveRegistration(name: string): unknown;
26
- }
27
- }
28
-
29
22
  type Args = {
30
23
  controller: SayController;
31
24
  options: BesluitTypePluginOptions;
@@ -91,7 +84,7 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
91
84
  get currentBesluitURI() {
92
85
  if (this.currentBesluitRange) {
93
86
  const node = unwrap(this.doc.nodeAt(this.currentBesluitRange.from));
94
- return getRdfaAttribute(node, 'resource').pop();
87
+ return node.attrs['subject'] as string | undefined;
95
88
  }
96
89
  return;
97
90
  }
@@ -109,11 +102,21 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
109
102
  this.controller.mainEditorState.selection,
110
103
  this.controller.schema.nodes['besluit'],
111
104
  );
112
- const besluitTypeof = besluit?.node.attrs.typeof as string;
113
- const besluitTypesUris = besluitTypeof.split(' ');
114
- const besluitTypeRelevant = besluitTypesUris.find((type) =>
115
- type.includes('https://data.vlaanderen.be/id/concept/BesluitType/'),
116
- );
105
+ if (!besluit) {
106
+ console.warn(
107
+ `We have a besluit URI (${this.currentBesluitURI}), but can't find a besluit ancestor`,
108
+ );
109
+ return;
110
+ }
111
+ const besluitTypes = getOutgoingTripleList(besluit.node.attrs, RDF('type'));
112
+ const besluitTypeRelevant = besluitTypes.find(
113
+ (type) =>
114
+ type.object.termType === 'NamedNode' &&
115
+ type.object.value.includes(
116
+ 'https://data.vlaanderen.be/id/concept/BesluitType/',
117
+ ),
118
+ )?.object.value;
119
+
117
120
  if (besluitTypeRelevant) {
118
121
  this.previousBesluitType = besluitTypeRelevant;
119
122
  const besluitType = this.findBesluitTypeByURI(besluitTypeRelevant);
@@ -205,16 +208,33 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
205
208
  }
206
209
 
207
210
  insert() {
208
- if (this.besluitType && this.currentBesluitRange) {
211
+ const resource =
212
+ (this.currentBesluitRange &&
213
+ 'node' in this.currentBesluitRange &&
214
+ (this.currentBesluitRange.node.attrs.subject as string)) ||
215
+ undefined;
216
+ if (this.besluitType && resource) {
209
217
  this.cardExpanded = false;
210
218
  if (this.previousBesluitType) {
211
219
  this.controller.doCommand(
212
- removeType(this.currentBesluitRange.from, this.previousBesluitType),
220
+ removeProperty({
221
+ resource,
222
+ property: {
223
+ predicate: RDF('type').full,
224
+ object: sayDataFactory.namedNode(this.previousBesluitType),
225
+ },
226
+ }),
213
227
  { view: this.controller.mainEditorView },
214
228
  );
215
229
  }
216
230
  this.controller.doCommand(
217
- addType(this.currentBesluitRange.from, this.besluitType.uri),
231
+ addProperty({
232
+ resource,
233
+ property: {
234
+ predicate: RDF('type').full,
235
+ object: sayDataFactory.namedNode(this.besluitType.uri),
236
+ },
237
+ }),
218
238
  { view: this.controller.mainEditorView },
219
239
  );
220
240
  }
@@ -14,7 +14,11 @@ import {
14
14
  CitationPlugin,
15
15
  CitationPluginEmberComponentConfig,
16
16
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin';
17
- import { SayController, Transaction } from '@lblod/ember-rdfa-editor';
17
+ import {
18
+ DecorationSet,
19
+ SayController,
20
+ Transaction,
21
+ } from '@lblod/ember-rdfa-editor';
18
22
  import { citedText } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin/utils/cited-text';
19
23
  import {
20
24
  LEGISLATION_TYPE_CONCEPTS,
@@ -80,7 +84,7 @@ export default class CitationCardComponent extends Component<Args> {
80
84
  return this.args.config;
81
85
  }
82
86
 
83
- get decorations() {
87
+ get decorations(): DecorationSet | undefined {
84
88
  return this.plugin.getState(this.controller.mainEditorState)?.highlights;
85
89
  }
86
90
 
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
2
2
  import { service } from '@ember/service';
3
3
  import { action } from '@ember/object';
4
4
  import { ProseParser } from '@lblod/ember-rdfa-editor';
5
- import { SayController } from '@lblod/ember-rdfa-editor';
5
+ import { SayController } from '@lblod/ember-rdfa-editor/index';
6
6
  import ImportRdfaSnippet from '@lblod/ember-rdfa-editor-lblod-plugins/services/import-rdfa-snippet';
7
7
  import { RdfaSnippet } from '@lblod/ember-rdfa-editor-lblod-plugins/services/import-rdfa-snippet';
8
8
  import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
@@ -10,6 +10,11 @@ import { findParentNodeOfType } from '@curvenote/prosemirror-utils';
10
10
  type Args = {
11
11
  controller: SayController;
12
12
  };
13
+
14
+ type InsertRange = {
15
+ from: number;
16
+ to: number;
17
+ };
13
18
  export default class ImportSnippetPluginCard extends Component<Args> {
14
19
  @service declare importRdfaSnippet: ImportRdfaSnippet;
15
20
 
@@ -21,7 +26,7 @@ export default class ImportSnippetPluginCard extends Component<Args> {
21
26
  return this.importRdfaSnippet.snippetsForType('roadsign');
22
27
  }
23
28
 
24
- get insertRange() {
29
+ get insertRange(): InsertRange {
25
30
  const { selection } = this.controller.mainEditorState;
26
31
  const besluit = findParentNodeOfType(this.controller.schema.nodes.besluit)(
27
32
  selection,
@@ -0,0 +1,7 @@
1
+ {{! @glint-nocheck: not typesafe yet }}
2
+ <SnippetPlugin::SnippetInsert
3
+ @config={{this.config}}
4
+ @controller={{this.controller}}
5
+ @assignedSnippetListsIds={{this.assignedSnippetListsIds}}
6
+ @disabled={{not this.showInsert}}
7
+ />
@@ -0,0 +1,78 @@
1
+ import { isResourceNode } from '@lblod/ember-rdfa-editor/utils/node-utils';
2
+ import Component from '@glimmer/component';
3
+
4
+ import { SayController } from '@lblod/ember-rdfa-editor';
5
+ import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
6
+ import { findParentNodeClosestToPos } from '@curvenote/prosemirror-utils';
7
+ import {
8
+ getAssignedSnippetListsIdsFromProperties,
9
+ getSnippetListIdsProperties,
10
+ } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin/utils/rdfa-predicate';
11
+ import { OutgoingTriple } from '@lblod/ember-rdfa-editor/core/rdfa-processor';
12
+ import { ResolvedPNode } from '@lblod/ember-rdfa-editor/utils/_private/types';
13
+
14
+ interface Args {
15
+ controller: SayController;
16
+ config: SnippetPluginConfig;
17
+ node: ResolvedPNode;
18
+ }
19
+
20
+ export default class SnippetInsertRdfaComponent extends Component<Args> {
21
+ get controller() {
22
+ return this.args.controller;
23
+ }
24
+
25
+ get config() {
26
+ return this.args.config;
27
+ }
28
+
29
+ get node() {
30
+ return this.args.node;
31
+ }
32
+
33
+ get showInsert() {
34
+ return this.assignedSnippetListsIds.length > 0;
35
+ }
36
+
37
+ get snippetListIdsProperty(): OutgoingTriple[] | undefined {
38
+ const activeNode = this.node.value;
39
+ const activeNodeSnippetListIds = getSnippetListIdsProperties(activeNode);
40
+
41
+ if (activeNodeSnippetListIds.length > 0) {
42
+ return activeNodeSnippetListIds;
43
+ }
44
+
45
+ const doc = this.controller.mainEditorState.doc;
46
+
47
+ if (this.node.pos < 0) {
48
+ return undefined;
49
+ }
50
+
51
+ const pos = doc.resolve(this.node.pos);
52
+
53
+ let parentNode = findParentNodeClosestToPos(pos, (node) =>
54
+ isResourceNode(node),
55
+ );
56
+
57
+ while (parentNode) {
58
+ const properties = getSnippetListIdsProperties(parentNode.node);
59
+
60
+ if (properties.length > 0) {
61
+ return properties;
62
+ }
63
+
64
+ parentNode = findParentNodeClosestToPos(
65
+ doc.resolve(parentNode.pos),
66
+ (node) => isResourceNode(node),
67
+ );
68
+ }
69
+
70
+ return undefined;
71
+ }
72
+
73
+ get assignedSnippetListsIds(): string[] {
74
+ return getAssignedSnippetListsIdsFromProperties(
75
+ this.snippetListIdsProperty,
76
+ );
77
+ }
78
+ }
@@ -4,6 +4,7 @@
4
4
  @icon={{this.AddIcon}}
5
5
  @iconAlignment='left'
6
6
  @skin='link'
7
+ @disabled={{this.disabled}}
7
8
  {{on 'click' this.openModal}}
8
9
  >
9
10
  {{t 'snippet-plugin.insert.title'}}
@@ -4,13 +4,20 @@ import { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';
4
4
  import Component from '@glimmer/component';
5
5
  import { tracked } from '@glimmer/tracking';
6
6
 
7
- import { ProseParser, SayController, Slice } from '@lblod/ember-rdfa-editor';
7
+ import { htmlToDoc } from '@lblod/ember-rdfa-editor/utils/_private/html-utils';
8
+ import {
9
+ ProseParser,
10
+ SayController,
11
+ Slice,
12
+ Transaction,
13
+ } from '@lblod/ember-rdfa-editor';
8
14
  import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
9
15
 
10
16
  interface Args {
11
17
  controller: SayController;
12
18
  config: SnippetPluginConfig;
13
19
  assignedSnippetListsIds: string[];
20
+ disabled?: boolean;
14
21
  }
15
22
 
16
23
  export default class SnippetInsertComponent extends Component<Args> {
@@ -54,15 +61,26 @@ export default class SnippetInsertComponent extends Component<Args> {
54
61
  const documentDiv = parsed.querySelector('div[data-say-document="true"]');
55
62
 
56
63
  this.closeModal();
64
+ const parser = ProseParser.fromSchema(this.controller.schema);
57
65
 
58
66
  if (documentDiv) {
59
- return this.controller.withTransaction((tr) =>
60
- tr.replaceSelection(this.createSliceFromElement(documentDiv)),
61
- );
67
+ return this.controller.withTransaction((tr: Transaction) => {
68
+ return tr.replaceSelectionWith(
69
+ htmlToDoc(content, {
70
+ schema: this.controller.schema,
71
+ parser,
72
+ editorView: this.controller.mainEditorView,
73
+ }),
74
+ );
75
+ });
62
76
  }
63
77
 
64
78
  this.controller.withTransaction((tr) =>
65
79
  tr.replaceSelection(this.createSliceFromElement(parsed)),
66
80
  );
67
81
  }
82
+
83
+ get disabled() {
84
+ return this.args.disabled ?? false;
85
+ }
68
86
  }