@eeacms/volto-slate-footnote 6.1.4 → 6.1.6

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.
@@ -0,0 +1,2 @@
1
+ [ -n "$CI" ] && exit 0
2
+ yarn lint-staged
package/CHANGELOG.md CHANGED
@@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [6.1.6](https://github.com/eea/volto-slate-footnote/compare/6.1.5...6.1.6) - 29 September 2023
8
+
9
+ #### :house: Documentation changes
10
+
11
+ - docs: Update README and DEVELOP [Alin Voinea - [`982fcbc`](https://github.com/eea/volto-slate-footnote/commit/982fcbc29cf82b428532138f948d9038b021b149)]
12
+
13
+ ### [6.1.5](https://github.com/eea/volto-slate-footnote/compare/6.1.4...6.1.5) - 19 September 2023
14
+
15
+ #### :bug: Bug Fixes
16
+
17
+ - fix: index not showing on diff - refs #257191 [dobri1408 - [`bd6eb19`](https://github.com/eea/volto-slate-footnote/commit/bd6eb197213e23420fdd2f185447cb92a8156fc9)]
18
+
19
+ #### :house: Internal changes
20
+
21
+ - style: lint-staged reorder in package.json [Alin Voinea - [`c618c3c`](https://github.com/eea/volto-slate-footnote/commit/c618c3c12a878cc87fb9c3fd658eeb5d1241e871)]
22
+
23
+ #### :hammer_and_wrench: Others
24
+
25
+ - test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`6886cf7`](https://github.com/eea/volto-slate-footnote/commit/6886cf796c58d38fcce7c515bda1d3586420a58a)]
7
26
  ### [6.1.4](https://github.com/eea/volto-slate-footnote/compare/6.1.3...6.1.4) - 1 September 2023
8
27
 
9
28
  #### :bug: Bug Fixes
package/DEVELOP.md CHANGED
@@ -16,12 +16,14 @@
16
16
 
17
17
  1. Go to http://localhost:3000
18
18
 
19
- 1. Happy hacking!
19
+ 1. Initialize git hooks
20
20
 
21
21
  ```Bash
22
- cd src/addons/volto-slate-footnote/
22
+ yarn prepare
23
23
  ```
24
24
 
25
+ 1. Happy hacking!
26
+
25
27
  ### Or add @eeacms/volto-slate-footnote to your Volto project
26
28
 
27
29
  Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/)
@@ -32,10 +34,7 @@ Before starting make sure your development environment is properly set. See [Vol
32
34
 
33
35
  1. Create new volto app
34
36
 
35
- yo @plone/volto my-volto-project \
36
- --workspace src/addons/volto-slate-footnote \
37
- --addon @eeacms/volto-slate-footnote \
38
- --skip-install
37
+ yo @plone/volto my-volto-project --addon @eeacms/volto-slate-footnote --skip-install
39
38
  cd my-volto-project
40
39
 
41
40
  1. Add the following to `mrs.developer.json`:
@@ -51,17 +50,15 @@ Before starting make sure your development environment is properly set. See [Vol
51
50
 
52
51
  1. Install
53
52
 
54
- yarn develop
53
+ make develop
55
54
  yarn
56
55
 
57
56
  1. Start backend
58
57
 
59
- docker run -d --name plone -p 8080:8080 -e SITE=Plone plone
58
+ docker run --pull always -it --rm --name plone -p 8080:8080 -e SITE=Plone plone/plone-backend
60
59
 
61
60
  ...wait for backend to setup and start - `Ready to handle requests`:
62
61
 
63
- docker logs -f plone
64
-
65
62
  ...you can also check http://localhost:8080/Plone
66
63
 
67
64
  1. Start frontend
package/Jenkinsfile CHANGED
@@ -62,11 +62,17 @@ pipeline {
62
62
 
63
63
  stage('Tests') {
64
64
  when {
65
- allOf {
66
- environment name: 'CHANGE_ID', value: ''
67
- anyOf {
68
- not { changelog '.*^Automated release [0-9\\.]+$' }
69
- branch 'master'
65
+ anyOf {
66
+ allOf {
67
+ not { environment name: 'CHANGE_ID', value: '' }
68
+ environment name: 'CHANGE_TARGET', value: 'develop'
69
+ }
70
+ allOf {
71
+ environment name: 'CHANGE_ID', value: ''
72
+ anyOf {
73
+ not { changelog '.*^Automated release [0-9\\.]+$' }
74
+ branch 'master'
75
+ }
70
76
  }
71
77
  }
72
78
  }
@@ -110,11 +116,17 @@ pipeline {
110
116
 
111
117
  stage('Integration tests') {
112
118
  when {
113
- allOf {
114
- environment name: 'CHANGE_ID', value: ''
115
- anyOf {
116
- not { changelog '.*^Automated release [0-9\\.]+$' }
117
- branch 'master'
119
+ anyOf {
120
+ allOf {
121
+ not { environment name: 'CHANGE_ID', value: '' }
122
+ environment name: 'CHANGE_TARGET', value: 'develop'
123
+ }
124
+ allOf {
125
+ environment name: 'CHANGE_ID', value: ''
126
+ anyOf {
127
+ not { changelog '.*^Automated release [0-9\\.]+$' }
128
+ branch 'master'
129
+ }
118
130
  }
119
131
  }
120
132
  }
@@ -167,13 +179,19 @@ pipeline {
167
179
 
168
180
  stage('Report to SonarQube') {
169
181
  when {
170
- allOf {
171
- environment name: 'CHANGE_ID', value: ''
172
- anyOf {
173
- branch 'master'
174
- allOf {
175
- branch 'develop'
176
- not { changelog '.*^Automated release [0-9\\.]+$' }
182
+ anyOf {
183
+ allOf {
184
+ not { environment name: 'CHANGE_ID', value: '' }
185
+ environment name: 'CHANGE_TARGET', value: 'develop'
186
+ }
187
+ allOf {
188
+ environment name: 'CHANGE_ID', value: ''
189
+ anyOf {
190
+ allOf {
191
+ branch 'develop'
192
+ not { changelog '.*^Automated release [0-9\\.]+$' }
193
+ }
194
+ branch 'master'
177
195
  }
178
196
  }
179
197
  }
@@ -199,10 +217,16 @@ pipeline {
199
217
 
200
218
  stage('SonarQube compare to master') {
201
219
  when {
202
- allOf {
203
- environment name: 'CHANGE_ID', value: ''
204
- branch 'develop'
205
- not { changelog '.*^Automated release [0-9\\.]+$' }
220
+ anyOf {
221
+ allOf {
222
+ not { environment name: 'CHANGE_ID', value: '' }
223
+ environment name: 'CHANGE_TARGET', value: 'develop'
224
+ }
225
+ allOf {
226
+ environment name: 'CHANGE_ID', value: ''
227
+ branch 'develop'
228
+ not { changelog '.*^Automated release [0-9\\.]+$' }
229
+ }
206
230
  }
207
231
  }
208
232
  steps {
package/README.md CHANGED
@@ -44,25 +44,25 @@ Go to http://localhost:3000
44
44
 
45
45
  1. Make sure you have a [Plone backend](https://plone.org/download) up-and-running at http://localhost:8080/Plone
46
46
 
47
- ```Bash
48
- docker compose up backend
49
- ```
47
+ ```Bash
48
+ docker compose up backend
49
+ ```
50
50
 
51
51
  1. Start Volto frontend
52
52
 
53
- - If you already have a volto project, just update `package.json`:
53
+ * If you already have a volto project, just update `package.json`:
54
54
 
55
55
  ```JSON
56
56
  "addons": [
57
- "@eeacms/volto-slate-footnote"
57
+ "@eeacms/volto-slate-footnote"
58
58
  ],
59
59
 
60
60
  "dependencies": {
61
- "@eeacms/volto-slate-footnote": "*"
61
+ "@eeacms/volto-slate-footnote": "*"
62
62
  }
63
63
  ```
64
64
 
65
- 1. If not, create one:
65
+ * If not, create one:
66
66
 
67
67
  ```
68
68
  npm install -g yo @plone/generator-volto
@@ -70,7 +70,6 @@ Go to http://localhost:3000
70
70
  cd my-volto-project
71
71
  ```
72
72
 
73
-
74
73
  1. Install new add-ons and restart Volto:
75
74
 
76
75
  ```
package/cypress.config.js CHANGED
@@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');
2
2
 
3
3
  module.exports = defineConfig({
4
4
  viewportWidth: 1280,
5
- defaultCommandTimeout: 8888,
5
+ defaultCommandTimeout: 5000,
6
6
  chromeWebSecurity: false,
7
7
  reporter: 'junit',
8
8
  video: true,
9
9
  retries: {
10
- runMode: 8,
10
+ runMode: 1,
11
11
  openMode: 0,
12
12
  },
13
13
  reporterOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-slate-footnote",
3
- "version": "6.1.4",
3
+ "version": "6.1.6",
4
4
  "description": "volto-slate-footnote: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -23,8 +23,31 @@
23
23
  "@cypress/code-coverage": "^3.10.0",
24
24
  "@plone/scripts": "*",
25
25
  "babel-plugin-transform-class-properties": "^6.24.1",
26
+ "husky": "*",
27
+ "lint-staged": "*",
26
28
  "md5": "^2.3.0"
27
29
  },
30
+ "lint-staged": {
31
+ "src/**/*.{js,jsx,ts,tsx,json}": [
32
+ "make lint-fix",
33
+ "make prettier-fix"
34
+ ],
35
+ "src/**/*.{jsx}": [
36
+ "make i18n"
37
+ ],
38
+ "theme/**/*.{css,less}": [
39
+ "make stylelint-fix"
40
+ ],
41
+ "src/**/*.{css,less}": [
42
+ "make stylelint-fix"
43
+ ],
44
+ "theme/**/*.overrides": [
45
+ "make stylelint-fix"
46
+ ],
47
+ "src/**/*.overrides": [
48
+ "make stylelint-fix"
49
+ ]
50
+ },
28
51
  "scripts": {
29
52
  "release": "release-it",
30
53
  "release-major-beta": "release-it major --preRelease=beta",
@@ -42,6 +65,7 @@
42
65
  "lint:fix": "make lint-fix",
43
66
  "i18n": "make i18n",
44
67
  "cypress:run": "make cypress-run",
45
- "cypress:open": "make cypress-open"
68
+ "cypress:open": "make cypress-open",
69
+ "prepare": "husky install"
46
70
  }
47
71
  }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import SearchWidget from './SearchWidget';
4
+ describe('Test SearchWidget', () => {
5
+ it('check html content', () => {
6
+ const component = renderer.create(<SearchWidget />);
7
+ const json = component.toJSON();
8
+ expect(json).toMatchSnapshot();
9
+ });
10
+ });
@@ -0,0 +1,72 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Test SearchWidget check html content 1`] = `
4
+ <div
5
+ id="blockform-fieldset-default"
6
+ >
7
+ <div
8
+ className="ui segment attached"
9
+ fluid={true}
10
+ >
11
+ <div
12
+ className="ui fluid card"
13
+ onClick={[Function]}
14
+ >
15
+ <div
16
+ className="content"
17
+ fluid={true}
18
+ >
19
+ <div
20
+ className="header"
21
+ >
22
+ Citation
23
+ </div>
24
+ <div
25
+ className="description"
26
+ fluid={true}
27
+ >
28
+ <div
29
+ className="ui fluid search"
30
+ onBlur={[Function]}
31
+ onFocus={[Function]}
32
+ onMouseDown={[Function]}
33
+ >
34
+ <div
35
+ className="ui fluid right icon input"
36
+ >
37
+ <input
38
+ autoComplete="off"
39
+ className="prompt"
40
+ id="field-footnote"
41
+ onChange={[Function]}
42
+ onClick={[Function]}
43
+ tabIndex="0"
44
+ type="text"
45
+ value=""
46
+ />
47
+ <i
48
+ aria-hidden="true"
49
+ className="search icon"
50
+ onClick={[Function]}
51
+ />
52
+ </div>
53
+ <div
54
+ className="results transition"
55
+ >
56
+ <div
57
+ className="message empty"
58
+ >
59
+ <div
60
+ className="header"
61
+ >
62
+ No results found.
63
+ </div>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ `;
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React from 'react';
2
2
  import { Popup, List } from 'semantic-ui-react';
3
3
  import { useEditorContext } from '@plone/volto-slate/hooks';
4
4
  import { getAllBlocksAndSlateFields } from '@eeacms/volto-slate-footnote/editor/utils';
@@ -24,71 +24,61 @@ export const FootnoteElement = (props) => {
24
24
  const { data = {} } = element;
25
25
  const { uid, zoteroId } = data;
26
26
  const editor = useEditorContext();
27
- const [citationIndice, setCitationIndice] = useState(null); // list of indices to reference
28
- const [citationRefId, setCitationRefId] = useState(null); // indice of element to be referenced
29
- const initialFormData = useSelector((state) => state?.content?.data || {});
30
-
31
- useEffect(() => {
32
- const blockProps = editor?.getBlockProps ? editor.getBlockProps() : null;
33
- const metadata = blockProps
34
- ? blockProps.metadata || blockProps.properties
35
- : extras?.metadata || {};
36
- const blocks = getAllBlocksAndSlateFields(metadata);
37
- const storeBlocks = getAllBlocksAndSlateFields(initialFormData);
38
27
 
39
- const notesObjResult = isEmpty(metadata)
40
- ? makeFootnoteListOfUniqueItems(storeBlocks)
41
- : makeFootnoteListOfUniqueItems(blocks);
28
+ const initialFormData = useSelector((state) => state?.content?.data || {});
29
+ const blockProps = editor?.getBlockProps ? editor.getBlockProps() : null;
30
+ const metadata = blockProps
31
+ ? blockProps.metadata || blockProps.properties
32
+ : extras?.metadata || {};
33
+ const blocks = getAllBlocksAndSlateFields(metadata);
34
+ const storeBlocks = getAllBlocksAndSlateFields(initialFormData);
42
35
 
43
- // will cosider zotero citations and footnote
44
- // notesObjResult contains all zotero/footnote as unique, and contain refs for other zotero/footnote
45
- const indiceIfZoteroId = data.extra
46
- ? [
47
- `[${Object.keys(notesObjResult).indexOf(zoteroId) + 1}]`, // parent footnote
48
- ...data.extra.map(
49
- // citations from extra
50
- (zoteroObj, _index) =>
51
- // all zotero citation are indexed by zoteroId in notesObjResult
52
- `[${
53
- Object.keys(notesObjResult).indexOf(zoteroObj.zoteroId) + 1
54
- }]`,
55
- ),
56
- ].join('')
57
- : // no extra citations (no multiples)
58
- `[${Object.keys(notesObjResult).indexOf(zoteroId) + 1}]`;
36
+ const notesObjResult = isEmpty(metadata)
37
+ ? makeFootnoteListOfUniqueItems(storeBlocks)
38
+ : makeFootnoteListOfUniqueItems(blocks);
59
39
 
60
- const indice = zoteroId // ZOTERO
61
- ? indiceIfZoteroId
62
- : // FOOTNOTES
63
- // parent footnote
64
- [data, ...(data.extra || [])]
65
- .map((footnoteObj, _index) => {
66
- return `[${
67
- Object.keys(notesObjResult).indexOf(
68
- Object.keys(notesObjResult).find(
69
- (key) =>
70
- notesObjResult[key].footnote === footnoteObj.footnote,
71
- ),
72
- ) + 1
73
- }]`;
74
- })
75
- .join('');
40
+ // will cosider zotero citations and footnote
41
+ // notesObjResult contains all zotero/footnote as unique, and contain refs for other zotero/footnote
42
+ const indiceIfZoteroId = data.extra
43
+ ? [
44
+ `[${Object.keys(notesObjResult).indexOf(zoteroId) + 1}]`, // parent footnote
45
+ ...data.extra.map(
46
+ // citations from extra
47
+ (zoteroObj, _index) =>
48
+ // all zotero citation are indexed by zoteroId in notesObjResult
49
+ `[${Object.keys(notesObjResult).indexOf(zoteroObj.zoteroId) + 1}]`,
50
+ ),
51
+ ].join('')
52
+ : // no extra citations (no multiples)
53
+ `[${Object.keys(notesObjResult).indexOf(zoteroId) + 1}]`;
76
54
 
77
- const findReferenceId =
78
- // search within parent citations first, otherwise the uid might be inside a refs obj that comes before
79
- Object.keys(notesObjResult).find(
80
- (noteKey) => notesObjResult[noteKey].uid === uid,
81
- ) ||
82
- // if not found in parent, search in refs, it might be a footnote references multiple times
83
- Object.keys(notesObjResult).find(
84
- (noteKey) =>
85
- notesObjResult[noteKey].uid === uid ||
86
- (notesObjResult[noteKey].refs && notesObjResult[noteKey].refs[uid]),
87
- );
55
+ const citationIndice = zoteroId // ZOTERO
56
+ ? indiceIfZoteroId
57
+ : // FOOTNOTES
58
+ // parent footnote
59
+ [data, ...(data.extra || [])]
60
+ .map((footnoteObj, _index) => {
61
+ return `[${
62
+ Object.keys(notesObjResult).indexOf(
63
+ Object.keys(notesObjResult).find(
64
+ (key) => notesObjResult[key].footnote === footnoteObj.footnote,
65
+ ),
66
+ ) + 1
67
+ }]`;
68
+ })
69
+ .join('');
88
70
 
89
- setCitationIndice(indice);
90
- setCitationRefId(findReferenceId);
91
- }, [editor, element, children]); // eslint-disable-line
71
+ const citationRefId =
72
+ // search within parent citations first, otherwise the uid might be inside a refs obj that comes before
73
+ Object.keys(notesObjResult).find(
74
+ (noteKey) => notesObjResult[noteKey].uid === uid,
75
+ ) ||
76
+ // if not found in parent, search in refs, it might be a footnote references multiple times
77
+ Object.keys(notesObjResult).find(
78
+ (noteKey) =>
79
+ notesObjResult[noteKey].uid === uid ||
80
+ (notesObjResult[noteKey].refs && notesObjResult[noteKey].refs[uid]),
81
+ );
92
82
 
93
83
  return (
94
84
  <>