@lblod/ember-rdfa-editor-lblod-plugins 4.0.1 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [4.0.2] - 2023-04-04
11
+
12
+ ### Fixed
13
+ - Prevent decision nodes regenerating when (de)serializing
14
+ - Ensure editor is focused after inserting a citation
15
+ - fix(citation): make plugin trigger correctly when `doc` is passed as an allowed nodeType
16
+
17
+ ### Added
18
+ - docs: add examples on how to enable the citation plugin for the entire document
19
+
10
20
  ## [4.0.1] - 2023-03-27
11
21
 
12
22
  ### Dependencies
@@ -29,6 +39,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
29
39
  ### Removed:
30
40
  - Removal of prosemirror-plugin dependency of `CitationPlugin::CitationInsert` component.
31
41
 
42
+ ### Dependencies
43
+ - bump `ember-rdfa-editor` to v3.4.0
44
+
32
45
  ## [3.1.0] - 2023-03-02
33
46
 
34
47
  ### Fixed
@@ -40,7 +53,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
40
53
 
41
54
  ### Dependencies
42
55
  - bump `ember-rdfa-editor` to v3.3.0
43
- - bump `ember-rdfa-editor` to v3.4.0
44
56
 
45
57
  ## [3.0.0] - 2023-02-27
46
58
 
@@ -379,7 +391,8 @@ add onclick handler to pencil icon in variable plugin
379
391
 
380
392
  # Changelog
381
393
 
382
- [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.1...HEAD
394
+ [unreleased]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.2...HEAD
395
+ [4.0.2]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.1...v4.0.2
383
396
  [4.0.1]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v4.0.0...v4.0.1
384
397
  [4.0.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v3.1.0...v4.0.0
385
398
  [3.1.0]: https://github.com/lblod/ember-rdfa-editor-lblod-plugins/compare/v3.0.0...v3.1.0
package/README.md CHANGED
@@ -101,6 +101,31 @@ Configuration:
101
101
  - activeInRanges: it's a function that gets the state of the actual instance of the editor and returns an array of ranges for the plugin to be active in, for example `[[0,50], [70,100]]`
102
102
  - regex: you can provide your custom regex to detect citations, if not the default one will be used
103
103
 
104
+
105
+ A common usecase is to have the plugin active in the entire document. Here's how to do that using each configuration type:
106
+
107
+ ```js
108
+ import { citationPlugin } from "@lblod/ember-rdfa-editor-lblod-plugins/plugins/citation-plugin";
109
+
110
+ const configA = {
111
+ type: "nodes",
112
+ activeInNodeTypes(schema) {
113
+ // the root node of the document should always have the doc type
114
+ return new Set([schema.nodes.doc]);
115
+ }
116
+ };
117
+
118
+ const configB = {
119
+ type: "ranges",
120
+ activeInRanges(state) {
121
+ // a node's nodeSize follows the Prosemirror definition
122
+ // a non-leaf node's size is the sum of its children's sizes + 2
123
+ // so to get the last valid position "inside" a node, you need to subtract two from its nodeSize
124
+ // ref: https://prosemirror.net/docs/ref/#model.Node.nodeSize
125
+ return [[0, state.doc.nodeSize - 2]];
126
+ }
127
+ };
128
+ ```
104
129
  ### Using the plugin
105
130
  If used with the example configuration provided this plugin can be triggered by typing one of the following in the correct RDFa context (the [besluit:motivering](http://data.vlaanderen.be/ns/besluit#motivering) of a [besluit:Besluit](https://data.vlaanderen.be/ns/besluit#Besluit)).
106
131
 
@@ -202,6 +202,7 @@ export default class CitationCardComponent extends Component<Args> {
202
202
  .scrollIntoView(),
203
203
  { view: this.controller.mainEditorView }
204
204
  );
205
+ this.controller.focus();
205
206
  }
206
207
 
207
208
  @action
@@ -76,6 +76,12 @@ export default class EditorPluginsCitationInsertComponent extends Component<Args
76
76
  this.controller.schema,
77
77
  this.controller.mainEditorState
78
78
  );
79
+ // if the doc node is included, the button should always be active
80
+ // the findParentNodeOfType util we import does NOT consider the doc node
81
+ // in its search.
82
+ if (nodeTypes.has(this.controller.schema.nodes.doc)) {
83
+ return false;
84
+ }
79
85
  return !findParentNodeOfType([...nodeTypes])(selection);
80
86
  }
81
87
  }
@@ -127,14 +127,12 @@ export const article_container: NodeSpec = {
127
127
  {
128
128
  tag: 'div',
129
129
  getAttrs(element: HTMLElement) {
130
- if (
131
- hasRDFaAttribute(element, 'property', PROV('value')) &&
132
- hasRDFaAttribute(element, 'typeof', BESLUIT('Besluit'))
133
- ) {
130
+ if (hasRDFaAttribute(element, 'property', PROV('value'))) {
134
131
  return getRdfaAttrs(element);
135
132
  }
136
133
  return false;
137
134
  },
135
+ context: 'besluit/',
138
136
  },
139
137
  ],
140
138
  };
@@ -279,6 +277,7 @@ export const besluit_article_header: NodeSpec = {
279
277
  };
280
278
 
281
279
  export const besluit_article_content: NodeSpec = {
280
+ group: 'block',
282
281
  content: 'block+',
283
282
  inline: false,
284
283
  attrs: {
@@ -302,6 +301,7 @@ export const besluit_article_content: NodeSpec = {
302
301
  }
303
302
  return false;
304
303
  },
304
+ context: 'besluit_article//',
305
305
  },
306
306
  ],
307
307
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",