@eeacms/volto-slate-footnote 4.0.4 → 5.0.1
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 +17 -0
- package/Jenkinsfile +6 -5
- package/cypress/support/index.js +1 -1
- package/package.json +1 -1
- package/src/constants.js +1 -0
- package/src/editor/FootnoteEditor.jsx +20 -10
- package/src/editor/utils.js +45 -31
- package/src/index.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +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
|
+
#### [5.0.1](https://github.com/eea/volto-slate-footnote/compare/5.0.0...5.0.1)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### [5.0.0](https://github.com/eea/volto-slate-footnote/compare/4.0.5...5.0.0)
|
|
11
|
+
|
|
12
|
+
> 19 May 2022
|
|
13
|
+
|
|
14
|
+
- feat(footnotes): Add blocksWithFootnotesSupport config settings [`#32`](https://github.com/eea/volto-slate-footnote/pull/32)
|
|
15
|
+
|
|
16
|
+
#### [4.0.5](https://github.com/eea/volto-slate-footnote/compare/4.0.4...4.0.5)
|
|
17
|
+
|
|
18
|
+
> 17 May 2022
|
|
19
|
+
|
|
20
|
+
- Allow other block types to define footnotes - refs #148688 [`#31`](https://github.com/eea/volto-slate-footnote/pull/31)
|
|
21
|
+
|
|
7
22
|
#### [4.0.4](https://github.com/eea/volto-slate-footnote/compare/4.0.3...4.0.4)
|
|
8
23
|
|
|
24
|
+
> 3 January 2022
|
|
25
|
+
|
|
9
26
|
|
|
10
27
|
#### [4.0.3](https://github.com/eea/volto-slate-footnote/compare/4.0.2...4.0.3)
|
|
11
28
|
|
package/Jenkinsfile
CHANGED
|
@@ -4,8 +4,9 @@ pipeline {
|
|
|
4
4
|
environment {
|
|
5
5
|
GIT_NAME = "volto-slate-footnote"
|
|
6
6
|
NAMESPACE = "@eeacms"
|
|
7
|
-
SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater"
|
|
7
|
+
SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu"
|
|
8
8
|
DEPENDENCIES = "volto-slate:asDefault"
|
|
9
|
+
VOLTO = "alpha"
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
stages {
|
|
@@ -124,8 +125,8 @@ pipeline {
|
|
|
124
125
|
node(label: 'docker') {
|
|
125
126
|
script {
|
|
126
127
|
try {
|
|
127
|
-
sh '''docker pull plone; docker run -d --
|
|
128
|
-
sh '''docker pull plone/volto-addon-ci; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" plone/volto-addon-ci cypress'''
|
|
128
|
+
sh '''docker pull eeacms/plone-backend; docker run --rm -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="eea.kitkat:testing" eeacms/plone-backend'''
|
|
129
|
+
sh '''docker pull plone/volto-addon-ci; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" -e NODE_ENV=development -e VOLTO="$VOLTO" plone/volto-addon-ci cypress'''
|
|
129
130
|
} finally {
|
|
130
131
|
try {
|
|
131
132
|
sh '''rm -rf cypress-reports cypress-results cypress-coverage'''
|
|
@@ -184,10 +185,10 @@ pipeline {
|
|
|
184
185
|
unstash "xunit-reports"
|
|
185
186
|
unstash "cypress-coverage"
|
|
186
187
|
def scannerHome = tool 'SonarQubeScanner';
|
|
187
|
-
def nodeJS = tool '
|
|
188
|
+
def nodeJS = tool 'NodeJS';
|
|
188
189
|
withSonarQubeEnv('Sonarqube') {
|
|
189
190
|
sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
|
|
190
|
-
sh "export PATH=$
|
|
191
|
+
sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
|
|
191
192
|
sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done'''
|
|
192
193
|
}
|
|
193
194
|
}
|
package/cypress/support/index.js
CHANGED
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -11,6 +11,7 @@ import { Node } from 'slate';
|
|
|
11
11
|
import { useSelector } from 'react-redux';
|
|
12
12
|
import { isEmpty } from 'lodash';
|
|
13
13
|
import { getAllBlocksAndSlateFields } from '@eeacms/volto-slate-footnote/editor/utils';
|
|
14
|
+
import config from '@plone/volto/registry';
|
|
14
15
|
|
|
15
16
|
const FootnoteEditor = (props) => {
|
|
16
17
|
const {
|
|
@@ -66,18 +67,27 @@ const FootnoteEditor = (props) => {
|
|
|
66
67
|
// add label and value for the multi search widget
|
|
67
68
|
// flatten blocks to add all extra in the list
|
|
68
69
|
flatAllBlocks
|
|
69
|
-
.filter((b) => b['@type']
|
|
70
|
-
.forEach((
|
|
71
|
-
|
|
70
|
+
.filter((b) => b['@type'] in config.settings.blocksWithFootnotesSupport)
|
|
71
|
+
.forEach((element) => {
|
|
72
|
+
const mapping = config.settings.blocksWithFootnotesSupport[
|
|
73
|
+
element['@type']
|
|
74
|
+
] || ['value'];
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
mapping.forEach((key) => {
|
|
77
|
+
const value = element[key];
|
|
78
|
+
if (!value) return;
|
|
79
|
+
|
|
80
|
+
value.forEach((item) => {
|
|
81
|
+
Array.from(Node.elements(item)).forEach(([block]) => {
|
|
82
|
+
block.children.forEach((node) => {
|
|
83
|
+
if (node.data && node.type === 'footnote') {
|
|
84
|
+
manageAddBlockToUniqueBlocks(uniqueFootnoteBlocks, node.data);
|
|
85
|
+
(node.data.extra || []).forEach((ftitem) => {
|
|
86
|
+
manageAddBlockToUniqueBlocks(uniqueFootnoteBlocks, ftitem);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
79
89
|
});
|
|
80
|
-
}
|
|
90
|
+
});
|
|
81
91
|
});
|
|
82
92
|
});
|
|
83
93
|
});
|
package/src/editor/utils.js
CHANGED
|
@@ -118,38 +118,52 @@ export const makeFootnoteListOfUniqueItems = (blocks) => {
|
|
|
118
118
|
let notesObjResult = {};
|
|
119
119
|
|
|
120
120
|
blocks
|
|
121
|
-
.filter((b) => b['@type']
|
|
122
|
-
.forEach((
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
)
|
|
121
|
+
.filter((b) => b['@type'] in config.settings.blocksWithFootnotesSupport)
|
|
122
|
+
.forEach((element) => {
|
|
123
|
+
const mapping = config.settings.blocksWithFootnotesSupport[
|
|
124
|
+
element['@type']
|
|
125
|
+
] || ['value'];
|
|
126
|
+
|
|
127
|
+
mapping.forEach((key) => {
|
|
128
|
+
const value = element[key];
|
|
129
|
+
if (!value) return;
|
|
130
|
+
|
|
131
|
+
value.forEach((item) => {
|
|
132
|
+
// Node.elements(item) returns an iterable generator of nodes
|
|
133
|
+
Array.from(Node.elements(item)).forEach(([node]) => {
|
|
134
|
+
if (footnotes.includes(node.type) && node.data) {
|
|
135
|
+
// for citations (Zotero items) create refs for same zoteroId
|
|
136
|
+
if (node.data.zoteroId) {
|
|
137
|
+
iterateZoteroObj(notesObjResult, node.data);
|
|
138
|
+
// itereate the extra obj for multiple citations
|
|
139
|
+
if (node.data.extra) {
|
|
140
|
+
node.data.extra.forEach((zoteroObjItem) =>
|
|
141
|
+
// send the uid of the parent
|
|
142
|
+
// of the word the will have the reference indice
|
|
143
|
+
iterateZoteroObj(
|
|
144
|
+
notesObjResult,
|
|
145
|
+
zoteroObjItem,
|
|
146
|
+
node.data.uid,
|
|
147
|
+
),
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
// for footnotes - create refs, on identical text
|
|
151
|
+
} else {
|
|
152
|
+
iterateFootnoteObj(notesObjResult, node.data);
|
|
153
|
+
if (node.data.extra) {
|
|
154
|
+
node.data.extra.forEach((footnoteObjItem) =>
|
|
155
|
+
// since is called in case of extra, the parent is needed
|
|
156
|
+
iterateFootnoteObj(
|
|
157
|
+
notesObjResult,
|
|
158
|
+
footnoteObjItem,
|
|
159
|
+
node.data.uid,
|
|
160
|
+
),
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
137
164
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
iterateFootnoteObj(notesObjResult, node.data);
|
|
141
|
-
if (node.data.extra) {
|
|
142
|
-
node.data.extra.forEach((footnoteObjItem) =>
|
|
143
|
-
// since is called in case of extra, the parent is needed
|
|
144
|
-
iterateFootnoteObj(
|
|
145
|
-
notesObjResult,
|
|
146
|
-
footnoteObjItem,
|
|
147
|
-
node.data.uid,
|
|
148
|
-
),
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
153
167
|
});
|
|
154
168
|
});
|
|
155
169
|
|
package/src/index.js
CHANGED
|
@@ -36,5 +36,15 @@ export default function install(config) {
|
|
|
36
36
|
config.widgets.widget.searchInput = SearchWidget;
|
|
37
37
|
config = installFootnoteEditor(config);
|
|
38
38
|
|
|
39
|
+
// Some blocks may have multiple slate fields,
|
|
40
|
+
// thus provide these fields per block type in order to lookup for footnotes:
|
|
41
|
+
//
|
|
42
|
+
// 'my-custom-block-type': ['value', 'field1', 'field2']
|
|
43
|
+
//
|
|
44
|
+
config.settings.blocksWithFootnotesSupport = {
|
|
45
|
+
...(config.settings.blocksWithFootnotesSupport || {}),
|
|
46
|
+
slate: ['value'],
|
|
47
|
+
};
|
|
48
|
+
|
|
39
49
|
return config;
|
|
40
50
|
}
|