@eeacms/volto-slate-footnote 7.0.1 → 7.1.0
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 +9 -30
- package/package.json +1 -1
- package/src/Blocks/Footnote/FootnotesBlockView.jsx +34 -6
- package/src/editor/render.jsx +57 -45
- package/src/editor/utils.js +0 -9
- package/src/editor/utils.test.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ 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
|
+
### [7.1.0](https://github.com/eea/volto-slate-footnote/compare/7.0.1...7.1.0) - 13 September 2024
|
|
8
|
+
|
|
9
|
+
#### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
- feat: autodetect links and use universal link - refs #274052 [dobri1408 - [`9c13101`](https://github.com/eea/volto-slate-footnote/commit/9c13101b62b1df150e1b3dbb93807df60a074ad5)]
|
|
12
|
+
|
|
13
|
+
#### :hammer_and_wrench: Others
|
|
14
|
+
|
|
15
|
+
- Release 7.1.0 [alin - [`c15afb0`](https://github.com/eea/volto-slate-footnote/commit/c15afb0be79ba9c4e3a46e3c190a41db468e88cd)]
|
|
7
16
|
### [7.0.1](https://github.com/eea/volto-slate-footnote/compare/7.0.0...7.0.1) - 23 August 2024
|
|
8
17
|
|
|
9
18
|
#### :hammer_and_wrench: Others
|
|
@@ -18,8 +27,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
18
27
|
|
|
19
28
|
#### :hammer_and_wrench: Others
|
|
20
29
|
|
|
21
|
-
- Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`1258c37`](https://github.com/eea/volto-slate-footnote/commit/1258c370d2ce42ddff78d6b749ab8c45897991d3)]
|
|
22
|
-
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`e1031b1`](https://github.com/eea/volto-slate-footnote/commit/e1031b1db0a34679e0bb312e8f0db9433bf08498)]
|
|
23
30
|
### [6.3.0](https://github.com/eea/volto-slate-footnote/compare/6.2.3...6.3.0) - 28 March 2024
|
|
24
31
|
|
|
25
32
|
#### :hammer_and_wrench: Others
|
|
@@ -39,7 +46,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
39
46
|
|
|
40
47
|
#### :hammer_and_wrench: Others
|
|
41
48
|
|
|
42
|
-
- Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`aa335f9`](https://github.com/eea/volto-slate-footnote/commit/aa335f9eedd9d994b6fbceb57102d848dbdbae15)]
|
|
43
49
|
### [6.2.2](https://github.com/eea/volto-slate-footnote/compare/6.2.1...6.2.2) - 20 January 2024
|
|
44
50
|
|
|
45
51
|
#### :hammer_and_wrench: Others
|
|
@@ -64,15 +70,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
64
70
|
|
|
65
71
|
#### :house: Internal changes
|
|
66
72
|
|
|
67
|
-
- chore: [JENKINS] Refactor automated testing [valentinab25 - [`5a5e1ad`](https://github.com/eea/volto-slate-footnote/commit/5a5e1adf997af84e93a4015dc66b7299abba0874)]
|
|
68
73
|
|
|
69
74
|
#### :hammer_and_wrench: Others
|
|
70
75
|
|
|
71
|
-
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`af6d78f`](https://github.com/eea/volto-slate-footnote/commit/af6d78f60dd040fe61ebb225f4a689ac21ffb55c)]
|
|
72
|
-
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`7f4c07f`](https://github.com/eea/volto-slate-footnote/commit/7f4c07f1fc2e9893d1f925152a473855a7e0f064)]
|
|
73
|
-
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`0670217`](https://github.com/eea/volto-slate-footnote/commit/0670217cca01571e8a3bd64ee3d85bb53ce447be)]
|
|
74
|
-
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`ec08749`](https://github.com/eea/volto-slate-footnote/commit/ec08749f9547d2c133b2174ab8d60cf2bdb1b23a)]
|
|
75
|
-
- test: [JENKINS] Improve cypress time [valentinab25 - [`237e6a3`](https://github.com/eea/volto-slate-footnote/commit/237e6a331e3608aa35d1c93a03c435daf330c2bd)]
|
|
76
76
|
### [6.1.8](https://github.com/eea/volto-slate-footnote/compare/6.1.7...6.1.8) - 22 October 2023
|
|
77
77
|
|
|
78
78
|
#### :house: Internal changes
|
|
@@ -142,25 +142,17 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
142
142
|
|
|
143
143
|
#### :house: Internal changes
|
|
144
144
|
|
|
145
|
-
- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`ded882a`](https://github.com/eea/volto-slate-footnote/commit/ded882a1ca1183c2ba74ff4246111123ee36e6cb)]
|
|
146
145
|
|
|
147
146
|
#### :hammer_and_wrench: Others
|
|
148
147
|
|
|
149
148
|
- test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`3e0749c`](https://github.com/eea/volto-slate-footnote/commit/3e0749cc5bd7f5810ac6fd7a3feee4df0435ee0a)]
|
|
150
149
|
- test: Add unit tests for utils - refs #253277 [ana-oprea - [`a709895`](https://github.com/eea/volto-slate-footnote/commit/a709895d9953742ef6d39f8d9673c06b2efe6a64)]
|
|
151
150
|
- test: Fix test config, coverage Refs #253277 [valentinab25 - [`dc4d6dc`](https://github.com/eea/volto-slate-footnote/commit/dc4d6dc9b39bfe2c892156f32c764153d1366486)]
|
|
152
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`4f0ecee`](https://github.com/eea/volto-slate-footnote/commit/4f0ecee224d5d6604dfbb562556e45437edbb8ec)]
|
|
153
151
|
### [6.1.0](https://github.com/eea/volto-slate-footnote/compare/6.0.2...6.1.0) - 27 March 2023
|
|
154
152
|
|
|
155
153
|
#### :hammer_and_wrench: Others
|
|
156
154
|
|
|
157
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`23959ee`](https://github.com/eea/volto-slate-footnote/commit/23959ee43d45ec5eaa483590415a75fc58faae03)]
|
|
158
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`7aa6f34`](https://github.com/eea/volto-slate-footnote/commit/7aa6f3439953cc3d8f28875eff9fbcc24084cbc7)]
|
|
159
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`b117d15`](https://github.com/eea/volto-slate-footnote/commit/b117d15e51b3cf10717b9dd9dfef8304d46ad556)]
|
|
160
155
|
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`97ed8fb`](https://github.com/eea/volto-slate-footnote/commit/97ed8fbd92f76c2b3128b62cdc1a77611e79410a)]
|
|
161
|
-
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`cb22f5e`](https://github.com/eea/volto-slate-footnote/commit/cb22f5e8e9d3aed0a3b4374b6d4d80c8c2bb66e1)]
|
|
162
|
-
- yarn 3 [Alin Voinea - [`f5bb904`](https://github.com/eea/volto-slate-footnote/commit/f5bb904eecf740ffd57dbccf9a597c99ea2dfc0c)]
|
|
163
|
-
- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`59cf6d3`](https://github.com/eea/volto-slate-footnote/commit/59cf6d334a460e373dda3e2e28754fcdd9fb0281)]
|
|
164
156
|
### [6.0.2](https://github.com/eea/volto-slate-footnote/compare/6.0.1...6.0.2) - 16 November 2022
|
|
165
157
|
|
|
166
158
|
#### :hammer_and_wrench: Others
|
|
@@ -176,37 +168,27 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
176
168
|
|
|
177
169
|
#### :hammer_and_wrench: Others
|
|
178
170
|
|
|
179
|
-
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`dc3c7de`](https://github.com/eea/volto-slate-footnote/commit/dc3c7deaa8c692689ea0cec66cf019f05f9c4e22)]
|
|
180
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`133969a`](https://github.com/eea/volto-slate-footnote/commit/133969a37a6153a19af121d2f6031a70bc67cc9d)]
|
|
181
171
|
### [5.0.1](https://github.com/eea/volto-slate-footnote/compare/5.0.0...5.0.1) - 30 June 2022
|
|
182
172
|
|
|
183
173
|
#### :hammer_and_wrench: Others
|
|
184
174
|
|
|
185
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`4d5af13`](https://github.com/eea/volto-slate-footnote/commit/4d5af1345aad9071c031f7f00efd6bc5da04541f)]
|
|
186
175
|
## [5.0.0](https://github.com/eea/volto-slate-footnote/compare/4.0.5...5.0.0) - 19 May 2022
|
|
187
176
|
|
|
188
177
|
### [4.0.5](https://github.com/eea/volto-slate-footnote/compare/4.0.4...4.0.5) - 17 May 2022
|
|
189
178
|
|
|
190
179
|
#### :hammer_and_wrench: Others
|
|
191
180
|
|
|
192
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`85a16ee`](https://github.com/eea/volto-slate-footnote/commit/85a16ee73d21d696282dc24933169d3c31383027)]
|
|
193
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`418349c`](https://github.com/eea/volto-slate-footnote/commit/418349ce22d98bf5dee58130d6f1cb9f45bbaa46)]
|
|
194
181
|
### [4.0.4](https://github.com/eea/volto-slate-footnote/compare/4.0.3...4.0.4) - 3 January 2022
|
|
195
182
|
|
|
196
183
|
### [4.0.3](https://github.com/eea/volto-slate-footnote/compare/4.0.2...4.0.3) - 18 December 2021
|
|
197
184
|
|
|
198
185
|
#### :hammer_and_wrench: Others
|
|
199
186
|
|
|
200
|
-
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`ad06940`](https://github.com/eea/volto-slate-footnote/commit/ad0694074a06eb56ec1891256b262e9854c0303d)]
|
|
201
187
|
- Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`1081079`](https://github.com/eea/volto-slate-footnote/commit/1081079444f5ac806e9d56765c4ccf0b9e415a73)]
|
|
202
|
-
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`307687b`](https://github.com/eea/volto-slate-footnote/commit/307687b93d966e0df5c4a3f813dbb19442d2e169)]
|
|
203
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`0460e2a`](https://github.com/eea/volto-slate-footnote/commit/0460e2a73a4c8ede00b0c1fc3f05624eaa345a33)]
|
|
204
|
-
- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`8aecee9`](https://github.com/eea/volto-slate-footnote/commit/8aecee99f11387e4ce31825209798772d7fee060)]
|
|
205
188
|
### [4.0.2](https://github.com/eea/volto-slate-footnote/compare/4.0.1...4.0.2) - 30 September 2021
|
|
206
189
|
|
|
207
190
|
#### :hammer_and_wrench: Others
|
|
208
191
|
|
|
209
|
-
- Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`cf33efe`](https://github.com/eea/volto-slate-footnote/commit/cf33efec91b4b8d13562b8c8f660e7a78191d9e0)]
|
|
210
192
|
- Remove :asDefault dependency from volto-slate [Alin Voinea - [`13dad5e`](https://github.com/eea/volto-slate-footnote/commit/13dad5ed23043fa7a24682e1ac6addc86632bfe0)]
|
|
211
193
|
### [4.0.1](https://github.com/eea/volto-slate-footnote/compare/4.0.0...4.0.1) - 29 September 2021
|
|
212
194
|
|
|
@@ -214,7 +196,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
214
196
|
|
|
215
197
|
#### :hammer_and_wrench: Others
|
|
216
198
|
|
|
217
|
-
- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`80a159b`](https://github.com/eea/volto-slate-footnote/commit/80a159bb67698cddedadc494e7ae2da32a96faea)]
|
|
218
199
|
### [3.2.0](https://github.com/eea/volto-slate-footnote/compare/3.1.1...3.2.0) - 13 September 2021
|
|
219
200
|
|
|
220
201
|
#### :hammer_and_wrench: Others
|
|
@@ -227,7 +208,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
227
208
|
- Remove console.log [Alin Voinea - [`b5d83e7`](https://github.com/eea/volto-slate-footnote/commit/b5d83e7c13240151f602d122ecf09ba9b8e335f3)]
|
|
228
209
|
- Fix slate json field default value in DX layout [Alin Voinea - [`f2805bb`](https://github.com/eea/volto-slate-footnote/commit/f2805bbc15c51ebd914ee5f4eb9dd34ef32e095b)]
|
|
229
210
|
- Fix cypress api_url [Alin Voinea - [`6a4966a`](https://github.com/eea/volto-slate-footnote/commit/6a4966a2f92e932e1d0df35351989cda535f15c8)]
|
|
230
|
-
- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`aed3984`](https://github.com/eea/volto-slate-footnote/commit/aed39840ecd467689eaf0adb352bd00ce95bdbbe)]
|
|
231
211
|
### [3.1.0](https://github.com/eea/volto-slate-footnote/compare/3.0.0...3.1.0) - 9 September 2021
|
|
232
212
|
|
|
233
213
|
#### :hammer_and_wrench: Others
|
|
@@ -248,7 +228,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
248
228
|
- Bump version to 2.4.0 [Alin Voinea - [`bef0d34`](https://github.com/eea/volto-slate-footnote/commit/bef0d34c2b9c20915578ffaefb4fd30cbf42f0a1)]
|
|
249
229
|
- Fix Slate point from DOM crash [Alin Voinea - [`c852f79`](https://github.com/eea/volto-slate-footnote/commit/c852f7987ffe8db433235b70792002d40ade690f)]
|
|
250
230
|
- Fix crash on copy&paste beforeInsert condition [Alin Voinea - [`85172cf`](https://github.com/eea/volto-slate-footnote/commit/85172cff3e2ea95a86d4b4fb452f3c0287b80e8f)]
|
|
251
|
-
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`b471c41`](https://github.com/eea/volto-slate-footnote/commit/b471c418d198b1bde95acfe0b256f642bacc6865)]
|
|
252
231
|
### [2.3.1](https://github.com/eea/volto-slate-footnote/compare/2.3.0...2.3.1) - 25 June 2021
|
|
253
232
|
|
|
254
233
|
### [2.3.0](https://github.com/eea/volto-slate-footnote/compare/2.2.2...2.3.0) - 12 June 2021
|
package/package.json
CHANGED
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
openAccordionOrTabIfContainsFootnoteReference,
|
|
4
4
|
getAllBlocksAndSlateFields,
|
|
5
5
|
makeFootnoteListOfUniqueItems,
|
|
6
|
-
makeFootnote,
|
|
7
6
|
} from '@eeacms/volto-slate-footnote/editor/utils';
|
|
8
7
|
import './less/public.less';
|
|
9
8
|
|
|
10
9
|
import { UniversalLink } from '@plone/volto/components';
|
|
11
10
|
|
|
12
11
|
const alphabet = 'abcdefghijklmnopqrstuvwxyz';
|
|
12
|
+
const urlRegex = /https?:\/\/[^\s]+/g;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @summary The React component that displays the list of footnotes inserted
|
|
@@ -19,6 +19,7 @@ const alphabet = 'abcdefghijklmnopqrstuvwxyz';
|
|
|
19
19
|
* @param {Object} props Contains the properties `data` and `properties` as
|
|
20
20
|
* received from the Volto form.
|
|
21
21
|
*/
|
|
22
|
+
|
|
22
23
|
const FootnotesBlockView = (props) => {
|
|
23
24
|
const { data, properties, tabData, content } = props;
|
|
24
25
|
const { title, global, placeholder = 'Footnotes' } = data;
|
|
@@ -75,6 +76,30 @@ const FootnotesBlockView = (props) => {
|
|
|
75
76
|
startList = citationIndice;
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
const renderTextWithLinks = (text) => {
|
|
80
|
+
if (!text) return null;
|
|
81
|
+
const parts = text.split(urlRegex);
|
|
82
|
+
const links = text.match(urlRegex);
|
|
83
|
+
let result = [];
|
|
84
|
+
|
|
85
|
+
parts.forEach((part, index) => {
|
|
86
|
+
result.push(<span key={`text-${index}`}>{part}</span>);
|
|
87
|
+
|
|
88
|
+
if (links && links[index]) {
|
|
89
|
+
result.push(
|
|
90
|
+
<UniversalLink
|
|
91
|
+
key={`link-${index}`}
|
|
92
|
+
href={links[index]}
|
|
93
|
+
openLinkInNewTab={false}
|
|
94
|
+
>
|
|
95
|
+
{links[index]}
|
|
96
|
+
</UniversalLink>,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return result;
|
|
102
|
+
};
|
|
78
103
|
return (
|
|
79
104
|
<div className="footnotes-listing-block">
|
|
80
105
|
<h3 title={placeholder}>{title}</h3>
|
|
@@ -85,16 +110,19 @@ const FootnotesBlockView = (props) => {
|
|
|
85
110
|
const { uid, footnote, zoteroId, parentUid } = note;
|
|
86
111
|
const { refs } = note;
|
|
87
112
|
const refsList = refs ? Object.keys(refs) : null;
|
|
113
|
+
|
|
114
|
+
// const history = createBrowserHistory();
|
|
115
|
+
// const api = new Api();
|
|
116
|
+
// const store = configureStore(window.__data, history, api);
|
|
117
|
+
const footnoteText = !footnote
|
|
118
|
+
? ''
|
|
119
|
+
: footnote.replace('<?xml version="1.0"?>', '');
|
|
88
120
|
return (
|
|
89
121
|
<li
|
|
90
122
|
key={`footnote-${zoteroId || uid}`}
|
|
91
123
|
id={`footnote-${zoteroId || uid}`}
|
|
92
124
|
>
|
|
93
|
-
<div
|
|
94
|
-
dangerouslySetInnerHTML={{
|
|
95
|
-
__html: makeFootnote(footnote),
|
|
96
|
-
}}
|
|
97
|
-
/>
|
|
125
|
+
<div>{renderTextWithLinks(footnoteText)}</div>
|
|
98
126
|
{refsList ? (
|
|
99
127
|
<>
|
|
100
128
|
{/** some footnotes are never parent so we need the parent to reference */}
|
package/src/editor/render.jsx
CHANGED
|
@@ -15,9 +15,8 @@ import { UniversalLink } from '@plone/volto/components';
|
|
|
15
15
|
* @param {string} footnote
|
|
16
16
|
* @returns {string} formatted footnote
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
|
|
19
|
+
const urlRegex = /https?:\/\/[^\s]+/g;
|
|
21
20
|
|
|
22
21
|
export const FootnoteElement = (props) => {
|
|
23
22
|
const { attributes, children, element, mode, extras } = props;
|
|
@@ -37,7 +36,7 @@ export const FootnoteElement = (props) => {
|
|
|
37
36
|
const notesObjResult = isEmpty(metadata)
|
|
38
37
|
? makeFootnoteListOfUniqueItems(storeBlocks)
|
|
39
38
|
: makeFootnoteListOfUniqueItems(blocks);
|
|
40
|
-
// will
|
|
39
|
+
// will consider zotero citations and footnote
|
|
41
40
|
// notesObjResult contains all zotero/footnote as unique, and contain refs for other zotero/footnote
|
|
42
41
|
const indiceIfZoteroId = data.extra
|
|
43
42
|
? [
|
|
@@ -52,6 +51,29 @@ export const FootnoteElement = (props) => {
|
|
|
52
51
|
: // no extra citations (no multiples)
|
|
53
52
|
`[${Object.keys(notesObjResult).indexOf(zoteroId) + 1}]`;
|
|
54
53
|
|
|
54
|
+
const renderTextWithLinks = (text) => {
|
|
55
|
+
if (!text) return null;
|
|
56
|
+
const parts = text.split(urlRegex);
|
|
57
|
+
const links = text.match(urlRegex);
|
|
58
|
+
let result = [];
|
|
59
|
+
|
|
60
|
+
parts.forEach((part, index) => {
|
|
61
|
+
result.push(<span key={`text-${index}`}>{part}</span>);
|
|
62
|
+
if (links && links[index]) {
|
|
63
|
+
result.push(
|
|
64
|
+
<UniversalLink
|
|
65
|
+
key={`link-${index}`}
|
|
66
|
+
href={links[index]}
|
|
67
|
+
openLinkInNewTab={false}
|
|
68
|
+
>
|
|
69
|
+
{links[index]}
|
|
70
|
+
</UniversalLink>,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
55
77
|
const citationIndice = zoteroId // ZOTERO
|
|
56
78
|
? indiceIfZoteroId
|
|
57
79
|
: // FOOTNOTES
|
|
@@ -76,13 +98,17 @@ export const FootnoteElement = (props) => {
|
|
|
76
98
|
Object.keys(notesObjResult).find(
|
|
77
99
|
(noteKey) => notesObjResult[noteKey].uid === uid,
|
|
78
100
|
) ||
|
|
79
|
-
// if not found in parent, search in refs, it might be a footnote
|
|
101
|
+
// if not found in parent, search in refs, it might be a footnote referenced multiple times
|
|
80
102
|
Object.keys(notesObjResult).find(
|
|
81
103
|
(noteKey) =>
|
|
82
104
|
notesObjResult[noteKey].uid === uid ||
|
|
83
105
|
(notesObjResult[noteKey].refs && notesObjResult[noteKey].refs[uid]),
|
|
84
106
|
);
|
|
85
107
|
|
|
108
|
+
const footnoteText = !data.footnote
|
|
109
|
+
? ''
|
|
110
|
+
: data.footnote.replace('<?xml version="1.0"?>', '');
|
|
111
|
+
|
|
86
112
|
return (
|
|
87
113
|
<>
|
|
88
114
|
{mode === 'view' ? (
|
|
@@ -109,7 +135,6 @@ export const FootnoteElement = (props) => {
|
|
|
109
135
|
<Popup.Content>
|
|
110
136
|
<List divided relaxed selection>
|
|
111
137
|
<List.Item
|
|
112
|
-
as={UniversalLink}
|
|
113
138
|
href={`#footnote-${citationRefId}`}
|
|
114
139
|
onClick={() =>
|
|
115
140
|
openAccordionOrTabIfContainsFootnoteReference(
|
|
@@ -120,37 +145,34 @@ export const FootnoteElement = (props) => {
|
|
|
120
145
|
>
|
|
121
146
|
<List.Content>
|
|
122
147
|
<List.Description>
|
|
123
|
-
|
|
124
|
-
dangerouslySetInnerHTML={{
|
|
125
|
-
__html: makeFootnote(data.footnote),
|
|
126
|
-
}}
|
|
127
|
-
/>{' '}
|
|
148
|
+
{renderTextWithLinks(footnoteText)}
|
|
128
149
|
</List.Description>
|
|
129
150
|
</List.Content>
|
|
130
151
|
</List.Item>
|
|
131
152
|
{data.extra &&
|
|
132
|
-
data.extra.map((item) =>
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
data.extra.map((item) => {
|
|
154
|
+
const footnoteText = !item.footnote
|
|
155
|
+
? ''
|
|
156
|
+
: item.footnote.replace('<?xml version="1.0"?>', '');
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<List.Item
|
|
160
|
+
href={`#footnote-${item.zoteroId || item.uid}`}
|
|
161
|
+
onClick={() =>
|
|
162
|
+
openAccordionOrTabIfContainsFootnoteReference(
|
|
163
|
+
`#footnote-${item.zoteroId || item.uid}`,
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
key={`#footnote-${item.zoteroId || item.uid}`}
|
|
167
|
+
>
|
|
168
|
+
<List.Content>
|
|
169
|
+
<List.Description>
|
|
170
|
+
{renderTextWithLinks(footnoteText)}
|
|
171
|
+
</List.Description>
|
|
172
|
+
</List.Content>
|
|
173
|
+
</List.Item>
|
|
174
|
+
);
|
|
175
|
+
})}
|
|
154
176
|
</List>
|
|
155
177
|
</Popup.Content>
|
|
156
178
|
</Popup>
|
|
@@ -173,7 +195,6 @@ export const FootnoteElement = (props) => {
|
|
|
173
195
|
<Popup.Content>
|
|
174
196
|
<List divided relaxed selection>
|
|
175
197
|
<List.Item
|
|
176
|
-
as={UniversalLink}
|
|
177
198
|
href={`#footnote-${citationRefId}`}
|
|
178
199
|
onClick={() =>
|
|
179
200
|
openAccordionOrTabIfContainsFootnoteReference(
|
|
@@ -184,18 +205,13 @@ export const FootnoteElement = (props) => {
|
|
|
184
205
|
>
|
|
185
206
|
<List.Content>
|
|
186
207
|
<List.Description>
|
|
187
|
-
|
|
188
|
-
dangerouslySetInnerHTML={{
|
|
189
|
-
__html: makeFootnote(data.footnote),
|
|
190
|
-
}}
|
|
191
|
-
/>{' '}
|
|
208
|
+
{renderTextWithLinks(footnoteText)}
|
|
192
209
|
</List.Description>
|
|
193
210
|
</List.Content>
|
|
194
211
|
</List.Item>
|
|
195
212
|
{data.extra &&
|
|
196
213
|
data.extra.map((item) => (
|
|
197
214
|
<List.Item
|
|
198
|
-
as={UniversalLink}
|
|
199
215
|
href={`#footnote-${item.zoteroId || item.uid}`}
|
|
200
216
|
onClick={() =>
|
|
201
217
|
openAccordionOrTabIfContainsFootnoteReference(
|
|
@@ -206,11 +222,7 @@ export const FootnoteElement = (props) => {
|
|
|
206
222
|
>
|
|
207
223
|
<List.Content>
|
|
208
224
|
<List.Description>
|
|
209
|
-
|
|
210
|
-
dangerouslySetInnerHTML={{
|
|
211
|
-
__html: makeFootnote(item.footnote),
|
|
212
|
-
}}
|
|
213
|
-
/>{' '}
|
|
225
|
+
{renderTextWithLinks(item.footnote)}
|
|
214
226
|
</List.Description>
|
|
215
227
|
</List.Content>
|
|
216
228
|
</List.Item>
|
package/src/editor/utils.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import config from '@plone/volto/registry';
|
|
2
2
|
import { Node } from 'slate';
|
|
3
3
|
import { getAllBlocks } from '@plone/volto-slate/utils';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* remove <?xml version="1.0"?> from the string
|
|
7
|
-
* @param {*} footnote - xml format
|
|
8
|
-
* @returns string
|
|
9
|
-
*/
|
|
10
|
-
export const makeFootnote = (footnote) => {
|
|
11
|
-
return footnote ? footnote.replace('<?xml version="1.0"?>', '') : '';
|
|
12
|
-
};
|
|
13
4
|
/**
|
|
14
5
|
* retrive all slate children of nested objects
|
|
15
6
|
* @param {object} path - the keys that we want to extract the slate children from
|
package/src/editor/utils.test.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
makeFootnote,
|
|
3
2
|
openAccordionOrTabIfContainsFootnoteReference,
|
|
4
3
|
getAllBlocksAndSlateFields,
|
|
5
4
|
} from './utils';
|
|
@@ -9,19 +8,6 @@ jest.mock('@plone/volto-slate/utils', () => ({
|
|
|
9
8
|
getAllBlocks: jest.fn(),
|
|
10
9
|
}));
|
|
11
10
|
|
|
12
|
-
describe('makeFootnote', () => {
|
|
13
|
-
it('should remove xml version string from footnote', () => {
|
|
14
|
-
const xmlString = '<?xml version="1.0"?>Test text';
|
|
15
|
-
const expectedResult = 'Test text';
|
|
16
|
-
expect(makeFootnote(xmlString)).toEqual(expectedResult);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should return empty string when footnote is null or undefined', () => {
|
|
20
|
-
expect(makeFootnote(null)).toEqual('');
|
|
21
|
-
expect(makeFootnote(undefined)).toEqual('');
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
11
|
describe('openAccordionOrTabIfContainsFootnoteReference', () => {
|
|
26
12
|
it('should open accordion if it contains footnote reference', () => {
|
|
27
13
|
document.body.innerHTML = `
|