@lblod/ember-rdfa-editor-lblod-plugins 16.2.0 → 16.3.0-dev.424040daafe67476c487af50caab14603f802c25

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 (145) hide show
  1. package/.changeset/afraid-tips-visit.md +5 -0
  2. package/.changeset/chilly-ravens-think.md +6 -0
  3. package/.changeset/hot-owls-laugh.md +5 -0
  4. package/.changeset/olive-pets-cheer.md +5 -0
  5. package/.changeset/smooth-fireants-doubt.md +5 -0
  6. package/.changeset/tall-carrots-ring.md +5 -0
  7. package/.changeset/wet-baboons-serve.md +5 -0
  8. package/.woodpecker/.release-commit.yml +18 -0
  9. package/.woodpecker/.release.yml +21 -0
  10. package/.woodpecker/.verify-pr.yml +30 -0
  11. package/CHANGELOG.md +8 -0
  12. package/Dockerfile +6 -4
  13. package/addon/commands/index.ts +1 -0
  14. package/addon/commands/replace-selection-and-select-node.ts +24 -0
  15. package/addon/components/article-structure-plugin/structure-card.hbs +1 -1
  16. package/addon/components/article-structure-plugin/structure-card.ts +43 -35
  17. package/addon/components/besluit-type-plugin/toolbar-dropdown.ts +40 -20
  18. package/addon/components/citation-plugin/citation-card.ts +6 -2
  19. package/addon/components/import-snippet-plugin/card.ts +7 -2
  20. package/addon/components/snippet-plugin/search-modal.hbs +1 -1
  21. package/addon/components/snippet-plugin/snippet-insert-rdfa.hbs +6 -0
  22. package/addon/components/snippet-plugin/snippet-insert-rdfa.ts +78 -0
  23. package/addon/components/snippet-plugin/snippet-insert.hbs +1 -0
  24. package/addon/components/snippet-plugin/snippet-insert.ts +22 -4
  25. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.hbs +1 -1
  26. package/addon/components/snippet-plugin/snippet-list/snippet-list-modal.ts +3 -3
  27. package/addon/components/snippet-plugin/snippet-list/snippet-list-view.hbs +1 -2
  28. package/addon/components/snippet-plugin/snippet-list-select-rdfa.hbs +7 -0
  29. package/addon/components/snippet-plugin/snippet-list-select-rdfa.ts +69 -0
  30. package/addon/components/standard-template-plugin/template-provider.ts +10 -4
  31. package/addon/components/variable-plugin/address/nodeview.hbs +2 -2
  32. package/addon/components/variable-plugin/address/nodeview.ts +6 -0
  33. package/addon/components/variable-plugin/address/utils.ts +28 -3
  34. package/addon/components/variable-plugin/codelist/edit.ts +24 -7
  35. package/addon/components/variable-plugin/codelist/insert.ts +52 -17
  36. package/addon/components/variable-plugin/date/edit.ts +43 -8
  37. package/addon/components/variable-plugin/date/insert-variable.ts +36 -10
  38. package/addon/components/variable-plugin/date/insert.ts +35 -10
  39. package/addon/components/variable-plugin/date/nodeview.hbs +2 -2
  40. package/addon/components/variable-plugin/date/nodeview.ts +8 -1
  41. package/addon/components/variable-plugin/location/edit.ts +1 -9
  42. package/addon/components/variable-plugin/location/insert.ts +4 -7
  43. package/addon/components/variable-plugin/location/nodeview.hbs +18 -8
  44. package/addon/components/variable-plugin/location/nodeview.ts +35 -9
  45. package/addon/components/variable-plugin/number/insert.ts +34 -10
  46. package/addon/components/variable-plugin/number/nodeview.hbs +5 -4
  47. package/addon/components/variable-plugin/number/nodeview.ts +30 -5
  48. package/addon/components/variable-plugin/text/insert.ts +40 -12
  49. package/addon/components/variable-plugin/variable/nodeview.hbs +10 -7
  50. package/addon/components/variable-plugin/variable/nodeview.ts +13 -9
  51. package/addon/plugins/article-structure-plugin/commands/insert-structure.ts +46 -16
  52. package/addon/plugins/article-structure-plugin/commands/move-selected-structure.ts +2 -1
  53. package/addon/plugins/article-structure-plugin/commands/recalculate-structure-numbers.ts +70 -2
  54. package/addon/plugins/article-structure-plugin/commands/remove-structure.ts +1 -1
  55. package/addon/plugins/article-structure-plugin/commands/set-structure-start-number.ts +5 -14
  56. package/addon/plugins/article-structure-plugin/commands/unwrap-structure.ts +1 -1
  57. package/addon/plugins/article-structure-plugin/commands/wrap-structure-content.ts +197 -105
  58. package/addon/plugins/article-structure-plugin/index.ts +16 -7
  59. package/addon/plugins/article-structure-plugin/structures/article-paragraph.ts +181 -71
  60. package/addon/plugins/article-structure-plugin/structures/article.ts +91 -98
  61. package/addon/plugins/article-structure-plugin/structures/chapter.ts +89 -39
  62. package/addon/plugins/article-structure-plugin/structures/index.ts +12 -1
  63. package/addon/plugins/article-structure-plugin/structures/section.ts +88 -39
  64. package/addon/plugins/article-structure-plugin/structures/structure-header-number.ts +56 -0
  65. package/addon/plugins/article-structure-plugin/structures/structure-header-title.ts +38 -0
  66. package/addon/plugins/article-structure-plugin/structures/structure-header.ts +87 -73
  67. package/addon/plugins/article-structure-plugin/structures/subsection.ts +81 -39
  68. package/addon/plugins/article-structure-plugin/structures/title.ts +91 -39
  69. package/addon/plugins/article-structure-plugin/utils/structure.ts +223 -127
  70. package/addon/plugins/citation-plugin/utils/cited-text.ts +38 -8
  71. package/addon/plugins/confidentiality-plugin/marks/redacted.ts +1 -1
  72. package/addon/plugins/document-title-plugin/nodes/document-title.ts +4 -3
  73. package/addon/plugins/roadsign-regulation-plugin/nodes.ts +4 -3
  74. package/addon/plugins/snippet-plugin/commands/index.ts +1 -0
  75. package/addon/plugins/snippet-plugin/commands/update-snippet-ids.ts +55 -0
  76. package/addon/plugins/snippet-plugin/index.ts +6 -1
  77. package/addon/plugins/snippet-plugin/utils/rdfa-predicate.ts +33 -0
  78. package/addon/plugins/standard-template-plugin/utils/nodes.ts +293 -81
  79. package/addon/plugins/table-of-contents-plugin/nodes/table-of-contents.ts +3 -2
  80. package/addon/plugins/variable-plugin/utils/attribute-parsers.ts +19 -1
  81. package/addon/plugins/variable-plugin/utils/dom-constructors.ts +3 -3
  82. package/addon/plugins/variable-plugin/variables/address.ts +93 -26
  83. package/addon/plugins/variable-plugin/variables/codelist.ts +99 -50
  84. package/addon/plugins/variable-plugin/variables/date.ts +143 -53
  85. package/addon/plugins/variable-plugin/variables/location.ts +1 -0
  86. package/addon/plugins/variable-plugin/variables/number.ts +99 -52
  87. package/addon/plugins/variable-plugin/variables/text.ts +80 -28
  88. package/addon/utils/_private/find-insertion-range.ts +18 -5
  89. package/addon/utils/dom-utils.ts +4 -0
  90. package/addon/utils/namespace.ts +67 -13
  91. package/app/components/snippet-plugin/snippet-list-insert-rdfa.js +1 -0
  92. package/app/components/snippet-plugin/snippet-list-select-rdfa.js +1 -0
  93. package/app/styles/article-structure-plugin.scss +106 -3
  94. package/commands/index.d.ts +1 -0
  95. package/commands/replace-selection-and-select-node.d.ts +3 -0
  96. package/components/article-structure-plugin/structure-card.d.ts +2 -2
  97. package/components/besluit-type-plugin/toolbar-dropdown.d.ts +0 -5
  98. package/components/citation-plugin/citation-card.d.ts +2 -2
  99. package/components/citation-plugin/citations/article-preview.d.ts +1 -1
  100. package/components/import-snippet-plugin/card.d.ts +6 -5
  101. package/components/snippet-plugin/snippet-insert-rdfa.d.ts +19 -0
  102. package/components/snippet-plugin/snippet-insert.d.ts +2 -0
  103. package/components/snippet-plugin/snippet-list-select-rdfa.d.ts +21 -0
  104. package/components/variable-plugin/address/edit.d.ts +1 -1
  105. package/components/variable-plugin/address/nodeview.d.ts +1 -0
  106. package/components/variable-plugin/date/edit.d.ts +2 -2
  107. package/components/variable-plugin/date/nodeview.d.ts +1 -0
  108. package/components/variable-plugin/location/edit.d.ts +0 -1
  109. package/components/variable-plugin/location/nodeview.d.ts +7 -9
  110. package/components/variable-plugin/number/nodeview.d.ts +3 -1
  111. package/components/variable-plugin/text/insert.d.ts +1 -1
  112. package/components/variable-plugin/variable/nodeview.d.ts +5 -6
  113. package/package.json +15 -7
  114. package/plugins/article-structure-plugin/commands/recalculate-structure-numbers.d.ts +2 -2
  115. package/plugins/article-structure-plugin/commands/set-structure-start-number.d.ts +5 -2
  116. package/plugins/article-structure-plugin/commands/wrap-structure-content.d.ts +1 -1
  117. package/plugins/article-structure-plugin/index.d.ts +15 -7
  118. package/plugins/article-structure-plugin/structures/article-paragraph.d.ts +2 -0
  119. package/plugins/article-structure-plugin/structures/article.d.ts +3 -4
  120. package/plugins/article-structure-plugin/structures/index.d.ts +4 -0
  121. package/plugins/article-structure-plugin/structures/structure-header-number.d.ts +2 -0
  122. package/plugins/article-structure-plugin/structures/structure-header-title.d.ts +2 -0
  123. package/plugins/article-structure-plugin/structures/structure-header.d.ts +16 -1
  124. package/plugins/article-structure-plugin/utils/structure.d.ts +20 -14
  125. package/plugins/confidentiality-plugin/marks/redacted.d.ts +1 -1
  126. package/plugins/snippet-plugin/commands/index.d.ts +1 -0
  127. package/plugins/snippet-plugin/commands/update-snippet-ids.d.ts +8 -0
  128. package/plugins/snippet-plugin/index.d.ts +2 -0
  129. package/plugins/snippet-plugin/utils/rdfa-predicate.d.ts +5 -0
  130. package/plugins/table-of-contents-plugin/nodes/table-of-contents.d.ts +1 -1
  131. package/plugins/template-comments-plugin/node.d.ts +1 -1
  132. package/plugins/variable-plugin/utils/attribute-parsers.d.ts +3 -0
  133. package/plugins/variable-plugin/variables/address.d.ts +1 -1
  134. package/plugins/variable-plugin/variables/codelist.d.ts +1 -1
  135. package/plugins/variable-plugin/variables/date.d.ts +1 -1
  136. package/plugins/variable-plugin/variables/location.d.ts +1 -1
  137. package/plugins/variable-plugin/variables/number.d.ts +1 -1
  138. package/plugins/variable-plugin/variables/text.d.ts +1 -1
  139. package/pnpm-lock.yaml +17568 -0
  140. package/tsconfig.json +0 -3
  141. package/types/graphy/memory.dataset.fast.d.ts +74 -0
  142. package/utils/_private/find-insertion-range.d.ts +7 -4
  143. package/utils/dom-utils.d.ts +2 -0
  144. package/utils/namespace.d.ts +11 -2
  145. package/.woodpecker/.test.yml +0 -49
@@ -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
+ 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
+ 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,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,13 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 16.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#406](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/406) [`d07eb52`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/d07eb52f7be0c08ae5bb563d69020574f0931088) Thanks [@elpoelma](https://github.com/elpoelma)! - Drop support for `@lblod/ember-rdfa-editor` `10.x` range.
8
+ This support was initially introduce to support `10.x` alpha releases of the editor.
9
+ We managed to release the new editor version as a `9.x` minor release (and the `10.x` releases are thus obsolete).
10
+
3
11
  ## 16.2.0
4
12
 
5
13
  ### Minor 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;
@@ -93,7 +93,7 @@
93
93
  type="number"
94
94
  min="1"
95
95
  />
96
- {{/let}}
96
+ {{/let}}
97
97
  </AuFormRow>
98
98
  <AuButton
99
99
  @iconAlignment="left"
@@ -36,11 +36,45 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
36
36
  this.controller.focus();
37
37
  }
38
38
 
39
+ @action
40
+ removeStructure(withContent: boolean) {
41
+ if (this.structure && this.currentStructureType) {
42
+ if (withContent || this.currentStructureType.noUnwrap) {
43
+ this.controller.doCommand(
44
+ removeStructure(this.structure, this.structureTypes),
45
+ { view: this.controller.mainEditorView },
46
+ );
47
+ } else {
48
+ this.controller.doCommand(
49
+ unwrapStructure(
50
+ {
51
+ ...this.structure,
52
+ type: this.currentStructureType,
53
+ },
54
+ this.structureTypes,
55
+ ),
56
+ { view: this.controller.mainEditorView },
57
+ );
58
+ }
59
+ }
60
+ this.controller.focus();
61
+ }
62
+
63
+ @action
64
+ setRemoveStructureContent(value: boolean) {
65
+ this.removeStructureContent = value;
66
+ }
67
+
39
68
  @action
40
69
  setStructureStartNumber() {
41
- if (this.startNumber) {
70
+ if (this.startNumber && this.structure && this.currentStructureType) {
42
71
  this.controller.doCommand(
43
- setStructureStartNumber(this.structureTypes, this.startNumber),
72
+ setStructureStartNumber(
73
+ this.structure,
74
+ this.structureTypes,
75
+ this.startNumber,
76
+ ),
77
+ { view: this.controller.mainEditorView },
44
78
  );
45
79
 
46
80
  this.startNumber = null;
@@ -49,11 +83,14 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
49
83
 
50
84
  @action
51
85
  resetStructureStartNumber() {
52
- this.controller.doCommand(
53
- setStructureStartNumber(this.structureTypes, null),
54
- );
86
+ if (this.structure) {
87
+ this.controller.doCommand(
88
+ setStructureStartNumber(this.structure, this.structureTypes, null),
89
+ { view: this.controller.mainEditorView },
90
+ );
55
91
 
56
- this.startNumber = null;
92
+ this.startNumber = null;
93
+ }
57
94
  }
58
95
 
59
96
  get structureNumber() {
@@ -87,35 +124,6 @@ export default class EditorPluginsStructureCardComponent extends Component<Args>
87
124
  this.startNumber = parseInt(target.value);
88
125
  };
89
126
 
90
- @action
91
- removeStructure(withContent: boolean) {
92
- if (this.structure && this.currentStructureType) {
93
- if (withContent || this.currentStructureType.noUnwrap) {
94
- this.controller.doCommand(
95
- removeStructure(this.structure, this.structureTypes),
96
- { view: this.controller.mainEditorView },
97
- );
98
- } else {
99
- this.controller.doCommand(
100
- unwrapStructure(
101
- {
102
- ...this.structure,
103
- type: this.currentStructureType,
104
- },
105
- this.structureTypes,
106
- ),
107
- { view: this.controller.mainEditorView },
108
- );
109
- }
110
- }
111
- this.controller.focus();
112
- }
113
-
114
- @action
115
- setRemoveStructureContent(value: boolean) {
116
- this.removeStructureContent = value;
117
- }
118
-
119
127
  get structureTypes() {
120
128
  return this.args.options;
121
129
  }
@@ -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,12 +12,8 @@ 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';
18
-
19
- declare module 'ember__owner' {
20
- export default interface Owner {
21
- resolveRegistration(name: string): unknown;
22
- }
23
- }
15
+ import { RDF } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/constants';
16
+ import { getOutgoingTripleList } from '@lblod/ember-rdfa-editor-lblod-plugins/utils/namespace';
24
17
 
25
18
  type Args = {
26
19
  controller: SayController;
@@ -83,7 +76,7 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
83
76
  get currentBesluitURI() {
84
77
  if (this.currentBesluitRange) {
85
78
  const node = unwrap(this.doc.nodeAt(this.currentBesluitRange.from));
86
- return getRdfaAttribute(node, 'resource').pop();
79
+ return node.attrs['subject'] as string | undefined;
87
80
  }
88
81
  return;
89
82
  }
@@ -101,11 +94,21 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
101
94
  this.controller.mainEditorState.selection,
102
95
  this.controller.schema.nodes['besluit'],
103
96
  );
104
- const besluitTypeof = besluit?.node.attrs.typeof as string;
105
- const besluitTypesUris = besluitTypeof.split(' ');
106
- const besluitTypeRelevant = besluitTypesUris.find((type) =>
107
- type.includes('https://data.vlaanderen.be/id/concept/BesluitType/'),
108
- );
97
+ if (!besluit) {
98
+ console.warn(
99
+ `We have a besluit URI (${this.currentBesluitURI}), but can't find a besluit ancestor`,
100
+ );
101
+ return;
102
+ }
103
+ const besluitTypes = getOutgoingTripleList(besluit.node.attrs, RDF('type'));
104
+ const besluitTypeRelevant = besluitTypes.find(
105
+ (type) =>
106
+ type.object.termType === 'NamedNode' &&
107
+ type.object.value.includes(
108
+ 'https://data.vlaanderen.be/id/concept/BesluitType/',
109
+ ),
110
+ )?.object.value;
111
+
109
112
  if (besluitTypeRelevant) {
110
113
  this.previousBesluitType = besluitTypeRelevant;
111
114
  const besluitType = this.findBesluitTypeByURI(besluitTypeRelevant);
@@ -197,16 +200,33 @@ export default class EditorPluginsToolbarDropdownComponent extends Component<Arg
197
200
  }
198
201
 
199
202
  insert() {
200
- if (this.besluitType && this.currentBesluitRange) {
203
+ const resource =
204
+ (this.currentBesluitRange &&
205
+ 'node' in this.currentBesluitRange &&
206
+ (this.currentBesluitRange.node.attrs.subject as string)) ||
207
+ undefined;
208
+ if (this.besluitType && resource) {
201
209
  this.cardExpanded = false;
202
210
  if (this.previousBesluitType) {
203
211
  this.controller.doCommand(
204
- removeType(this.currentBesluitRange.from, this.previousBesluitType),
212
+ removeProperty({
213
+ resource,
214
+ property: {
215
+ predicate: RDF('type').full,
216
+ object: sayDataFactory.namedNode(this.previousBesluitType),
217
+ },
218
+ }),
205
219
  { view: this.controller.mainEditorView },
206
220
  );
207
221
  }
208
222
  this.controller.doCommand(
209
- addType(this.currentBesluitRange.from, this.besluitType.uri),
223
+ addProperty({
224
+ resource,
225
+ property: {
226
+ predicate: RDF('type').full,
227
+ object: sayDataFactory.namedNode(this.besluitType.uri),
228
+ },
229
+ }),
210
230
  { view: this.controller.mainEditorView },
211
231
  );
212
232
  }
@@ -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,
@@ -77,7 +81,7 @@ export default class CitationCardComponent extends Component<Args> {
77
81
  return this.args.config;
78
82
  }
79
83
 
80
- get decorations() {
84
+ get decorations(): DecorationSet | undefined {
81
85
  return this.plugin.getState(this.controller.mainEditorState)?.highlights;
82
86
  }
83
87
 
@@ -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,
@@ -41,7 +41,7 @@
41
41
  <div class='au-u-margin'>
42
42
  <AuLoader @padding='large' />
43
43
  <span class='au-u-hidden-visually'>
44
- {{t 'snippet-plugin.alert.loading'}}
44
+ {{t 'snippet-plugin.modal.alert.loading'}}
45
45
  </span>
46
46
  </div>
47
47
  {{else}}
@@ -0,0 +1,6 @@
1
+ <SnippetPlugin::SnippetInsert
2
+ @config={{this.config}}
3
+ @controller={{this.controller}}
4
+ @assignedSnippetListsIds={{this.assignedSnippetListsIds}}
5
+ @disabled={{not this.showInsert}}
6
+ />
@@ -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
+ }
@@ -3,6 +3,7 @@
3
3
  @icon='add'
4
4
  @iconAlignment='left'
5
5
  @skin='link'
6
+ @disabled={{this.disabled}}
6
7
  {{on 'click' this.openModal}}
7
8
  >
8
9
  {{t 'snippet-plugin.insert.title'}}
@@ -3,13 +3,20 @@ import { action } from '@ember/object';
3
3
  import Component from '@glimmer/component';
4
4
  import { tracked } from '@glimmer/tracking';
5
5
 
6
- import { ProseParser, SayController, Slice } from '@lblod/ember-rdfa-editor';
6
+ import { htmlToDoc } from '@lblod/ember-rdfa-editor/utils/_private/html-utils';
7
+ import {
8
+ ProseParser,
9
+ SayController,
10
+ Slice,
11
+ Transaction,
12
+ } from '@lblod/ember-rdfa-editor';
7
13
  import { SnippetPluginConfig } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
8
14
 
9
15
  interface Args {
10
16
  controller: SayController;
11
17
  config: SnippetPluginConfig;
12
18
  assignedSnippetListsIds: string[];
19
+ disabled?: boolean;
13
20
  }
14
21
 
15
22
  export default class SnippetInsertComponent extends Component<Args> {
@@ -51,15 +58,26 @@ export default class SnippetInsertComponent extends Component<Args> {
51
58
  const documentDiv = parsed.querySelector('div[data-say-document="true"]');
52
59
 
53
60
  this.closeModal();
61
+ const parser = ProseParser.fromSchema(this.controller.schema);
54
62
 
55
63
  if (documentDiv) {
56
- return this.controller.withTransaction((tr) =>
57
- tr.replaceSelection(this.createSliceFromElement(documentDiv)),
58
- );
64
+ return this.controller.withTransaction((tr: Transaction) => {
65
+ return tr.replaceSelectionWith(
66
+ htmlToDoc(content, {
67
+ schema: this.controller.schema,
68
+ parser,
69
+ editorView: this.controller.mainEditorView,
70
+ }),
71
+ );
72
+ });
59
73
  }
60
74
 
61
75
  this.controller.withTransaction((tr) =>
62
76
  tr.replaceSelection(this.createSliceFromElement(parsed)),
63
77
  );
64
78
  }
79
+
80
+ get disabled() {
81
+ return this.args.disabled ?? false;
82
+ }
65
83
  }
@@ -41,7 +41,7 @@
41
41
  <div class='au-u-margin'>
42
42
  <AuLoader @padding='large' />
43
43
  <span class='au-u-hidden-visually'>
44
- {{t 'snippet-plugin.alert.loading'}}
44
+ {{t 'snippet-plugin.modal.alert.loading'}}
45
45
  </span>
46
46
  </div>
47
47
  {{else}}
@@ -12,6 +12,7 @@ import {
12
12
  SnippetPluginConfig,
13
13
  SnippetList,
14
14
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/snippet-plugin';
15
+ import { trackedReset } from 'tracked-toolbox';
15
16
 
16
17
  interface Args {
17
18
  config: SnippetPluginConfig;
@@ -27,9 +28,8 @@ export default class SnippetListModalComponent extends Component<Args> {
27
28
  // Display
28
29
  @tracked error: unknown;
29
30
 
30
- @tracked assignedSnippetListsIds: string[] = [
31
- ...this.args.assignedSnippetListsIds,
32
- ];
31
+ @trackedReset('args.assignedSnippetListsIds')
32
+ assignedSnippetListsIds: string[] = [...this.args.assignedSnippetListsIds];
33
33
 
34
34
  get config() {
35
35
  return this.args.config;
@@ -14,8 +14,7 @@
14
14
  {{#each @snippetLists as |snippetList|}}
15
15
  <tr>
16
16
  <td class="selectColumn">
17
- <AuControlCheckbox
18
- @identifier={{snippetList.label}}
17
+ <AuCheckbox
19
18
  @onChange={{fn this.onChange snippetList.id}}
20
19
  @checked={{in-array @assignedSnippetListsIds snippetList.id}}
21
20
  />
@@ -0,0 +1,7 @@
1
+ {{#if this.isResourceNode}}
2
+ <SnippetPlugin::SnippetListSelect
3
+ @config={{this.config}}
4
+ @assignedSnippetListsIds={{this.assignedSnippetListsIds}}
5
+ @onSaveSnippetListIds={{this.saveChanges}}
6
+ />
7
+ {{/if}}