@eeacms/volto-slate-footnote 7.1.0 → 7.2.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
CHANGED
|
@@ -4,6 +4,10 @@ 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.2.0](https://github.com/eea/volto-slate-footnote/compare/7.1.1...7.2.0) - 28 November 2024
|
|
8
|
+
|
|
9
|
+
### [7.1.1](https://github.com/eea/volto-slate-footnote/compare/7.1.0...7.1.1) - 16 September 2024
|
|
10
|
+
|
|
7
11
|
### [7.1.0](https://github.com/eea/volto-slate-footnote/compare/7.0.1...7.1.0) - 13 September 2024
|
|
8
12
|
|
|
9
13
|
#### :rocket: New Features
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { escapeRegExp } from 'lodash';
|
|
2
3
|
import {
|
|
3
4
|
openAccordionOrTabIfContainsFootnoteReference,
|
|
4
5
|
getAllBlocksAndSlateFields,
|
|
@@ -9,7 +10,8 @@ import './less/public.less';
|
|
|
9
10
|
import { UniversalLink } from '@plone/volto/components';
|
|
10
11
|
|
|
11
12
|
const alphabet = 'abcdefghijklmnopqrstuvwxyz';
|
|
12
|
-
const urlRegex =
|
|
13
|
+
const urlRegex =
|
|
14
|
+
/\b((http|https|ftp):\/\/)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?\b/g;
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* @summary The React component that displays the list of footnotes inserted
|
|
@@ -78,27 +80,44 @@ const FootnotesBlockView = (props) => {
|
|
|
78
80
|
|
|
79
81
|
const renderTextWithLinks = (text) => {
|
|
80
82
|
if (!text) return null;
|
|
81
|
-
const parts = text.split(urlRegex);
|
|
82
83
|
const links = text.match(urlRegex);
|
|
84
|
+
if (!links) {
|
|
85
|
+
return (
|
|
86
|
+
<div
|
|
87
|
+
dangerouslySetInnerHTML={{
|
|
88
|
+
__html: text,
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
83
93
|
let result = [];
|
|
84
|
-
|
|
94
|
+
const parts = text.split(
|
|
95
|
+
new RegExp(`(${links.map((link) => escapeRegExp(link)).join('|')})`),
|
|
96
|
+
);
|
|
85
97
|
parts.forEach((part, index) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (links && links[index]) {
|
|
98
|
+
if (links.includes(part)) {
|
|
89
99
|
result.push(
|
|
90
100
|
<UniversalLink
|
|
91
101
|
key={`link-${index}`}
|
|
92
|
-
href={
|
|
102
|
+
href={part}
|
|
93
103
|
openLinkInNewTab={false}
|
|
94
104
|
>
|
|
95
|
-
{
|
|
105
|
+
{part}
|
|
96
106
|
</UniversalLink>,
|
|
97
107
|
);
|
|
108
|
+
return;
|
|
98
109
|
}
|
|
110
|
+
|
|
111
|
+
result.push(
|
|
112
|
+
<span
|
|
113
|
+
dangerouslySetInnerHTML={{
|
|
114
|
+
__html: part,
|
|
115
|
+
}}
|
|
116
|
+
/>,
|
|
117
|
+
);
|
|
99
118
|
});
|
|
100
119
|
|
|
101
|
-
return result
|
|
120
|
+
return <div>{result}</div>;
|
|
102
121
|
};
|
|
103
122
|
return (
|
|
104
123
|
<div className="footnotes-listing-block">
|
package/src/editor/render.jsx
CHANGED
|
@@ -58,7 +58,14 @@ export const FootnoteElement = (props) => {
|
|
|
58
58
|
let result = [];
|
|
59
59
|
|
|
60
60
|
parts.forEach((part, index) => {
|
|
61
|
-
result.push(
|
|
61
|
+
result.push(
|
|
62
|
+
<div
|
|
63
|
+
dangerouslySetInnerHTML={{
|
|
64
|
+
__html: part,
|
|
65
|
+
}}
|
|
66
|
+
/>,
|
|
67
|
+
);
|
|
68
|
+
|
|
62
69
|
if (links && links[index]) {
|
|
63
70
|
result.push(
|
|
64
71
|
<UniversalLink
|
|
@@ -71,7 +78,6 @@ export const FootnoteElement = (props) => {
|
|
|
71
78
|
);
|
|
72
79
|
}
|
|
73
80
|
});
|
|
74
|
-
|
|
75
81
|
return result;
|
|
76
82
|
};
|
|
77
83
|
const citationIndice = zoteroId // ZOTERO
|