@eeacms/volto-n2k 1.0.1 → 1.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 +5 -0
- package/package.json +1 -3
- package/src/actions/hashlink.js +13 -0
- package/src/actions/index.js +1 -0
- package/src/components/manage/Blocks/ImageText/Edit.jsx +1 -1
- package/src/components/manage/Blocks/ImageText/View.jsx +1 -1
- package/src/components/manage/Blocks/NavigationAnchors/View.jsx +1 -1
- package/src/components/manage/Blocks/SlateLink/render.jsx +1 -1
- package/src/components/manage/Blocks/SlateSVG/index.js +1 -1
- package/src/components/theme/AppExtras/HashLink.jsx +52 -0
- package/src/components/theme/AppExtras/index.js +5 -0
- package/src/hocs/index.js +2 -1
- package/src/hocs/withHashLink.jsx +22 -0
- package/src/index.js +3 -3
- package/src/reducers/hashlink.js +27 -0
- package/src/reducers/index.js +2 -0
- /package/src/{store.js → reducers/store.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ 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
|
+
### [1.0.2](https://github.com/eea/volto-n2k/compare/1.0.1...1.0.2) - 4 November 2022
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- Remove volto-slate dependency [Miu Razvan - [`a966c5b`](https://github.com/eea/volto-n2k/commit/a966c5b0d79552706683fd9620161b9e5e559e10)]
|
|
7
12
|
### [1.0.1](https://github.com/eea/volto-n2k/compare/1.0.0...1.0.1) - 2 November 2022
|
|
8
13
|
|
|
9
14
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-n2k",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "volto-n2k: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"react"
|
|
14
14
|
],
|
|
15
15
|
"addons": [
|
|
16
|
-
"volto-slate",
|
|
17
16
|
"@eeacms/volto-datablocks",
|
|
18
17
|
"@eeacms/volto-openlayers-map",
|
|
19
18
|
"@eeacms/volto-resize-helper",
|
|
@@ -30,7 +29,6 @@
|
|
|
30
29
|
"@eeacms/volto-openlayers-map": "*",
|
|
31
30
|
"@eeacms/volto-tabs-block": "*",
|
|
32
31
|
"@eeacms/volto-bise": "*",
|
|
33
|
-
"volto-slate": "*",
|
|
34
32
|
"d3": "^7.6.1",
|
|
35
33
|
"d3-shape": "^3.1.0",
|
|
36
34
|
"react-lazy-load-image-component": "1.5.1",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hashlink';
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import config from '@plone/volto/registry';
|
|
3
3
|
import { SidebarPortal } from '@plone/volto/components';
|
|
4
4
|
import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
|
|
5
|
-
import SlateEditor from 'volto-slate/editor/SlateEditor';
|
|
5
|
+
import SlateEditor from '@plone/volto-slate/editor/SlateEditor';
|
|
6
6
|
import { Editor } from 'slate';
|
|
7
7
|
import getSchema from './schema';
|
|
8
8
|
import cx from 'classnames';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UniversalLink } from '@plone/volto/components';
|
|
3
|
-
import { serializeNodes } from 'volto-slate/editor/render';
|
|
3
|
+
import { serializeNodes } from '@plone/volto-slate/editor/render';
|
|
4
4
|
import { Editor } from 'slate';
|
|
5
5
|
import cx from 'classnames';
|
|
6
6
|
import './styles.less';
|
|
@@ -5,8 +5,8 @@ import { Menu, Container, Sticky } from 'semantic-ui-react';
|
|
|
5
5
|
import qs from 'querystring';
|
|
6
6
|
import cx from 'classnames';
|
|
7
7
|
import { UniversalLink } from '@plone/volto/components';
|
|
8
|
-
import { withHashLink } from 'volto-slate/hooks';
|
|
9
8
|
import { StickyContext } from '@eeacms/volto-bise/components';
|
|
9
|
+
import { withHashLink } from '@eeacms/volto-n2k/hocs';
|
|
10
10
|
import './styles.less';
|
|
11
11
|
|
|
12
12
|
const formatLink = (str, obj) => {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { UniversalLink } from '@plone/volto/components';
|
|
3
3
|
import { withRouter } from 'react-router';
|
|
4
4
|
import { useSelector } from 'react-redux';
|
|
5
|
-
import { withHashLink } from 'volto-
|
|
5
|
+
import { withHashLink } from '@eeacms/volto-n2k/hocs';
|
|
6
6
|
import qs from 'querystring';
|
|
7
7
|
import './styles.less';
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineMessages } from 'react-intl';
|
|
2
|
-
import { makeInlineElementPlugin } from 'volto-slate/
|
|
2
|
+
import { makeInlineElementPlugin } from '@plone/volto-slate/elementEditor';
|
|
3
3
|
import { SlateSvgSchema } from './schema';
|
|
4
4
|
import { withSlateSvg } from './extensions';
|
|
5
5
|
import { SLATESVG } from './constants';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withRouter } from 'react-router';
|
|
3
|
+
import { withHashLink } from '@eeacms/volto-n2k/hocs';
|
|
4
|
+
|
|
5
|
+
import config from '@plone/volto/registry';
|
|
6
|
+
|
|
7
|
+
const scrollToTarget = (target, offsetHeight = 0) => {
|
|
8
|
+
const bodyRect = document.body.getBoundingClientRect().top;
|
|
9
|
+
const targetRect = target.getBoundingClientRect().top;
|
|
10
|
+
const targetPosition = targetRect - bodyRect - offsetHeight;
|
|
11
|
+
|
|
12
|
+
return window.scrollTo({
|
|
13
|
+
top: targetPosition,
|
|
14
|
+
behavior: 'smooth',
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function HashLink({ history, pathname, hashlink, resetHashLink }) {
|
|
19
|
+
const { settings } = config;
|
|
20
|
+
const blacklist = settings.hashlinkBlacklist || [];
|
|
21
|
+
const id = hashlink.hash;
|
|
22
|
+
const type = hashlink.data.type || '';
|
|
23
|
+
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
const unlisten = history.listen((location) => {
|
|
26
|
+
if (location.pathname !== pathname) {
|
|
27
|
+
resetHashLink();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return () => {
|
|
31
|
+
unlisten();
|
|
32
|
+
};
|
|
33
|
+
/* eslint-disable-next-line */
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (hashlink.counter > 0 && blacklist.indexOf(type) === -1) {
|
|
38
|
+
const element = document.getElementById(id);
|
|
39
|
+
const headerWrapper = document.querySelector('.header-wrapper');
|
|
40
|
+
const offsetHeight =
|
|
41
|
+
hashlink.data.offsetHeight || headerWrapper?.offsetHeight || 0;
|
|
42
|
+
if (element) {
|
|
43
|
+
scrollToTarget(element, offsetHeight);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/* eslint-disable-next-line */
|
|
47
|
+
}, [hashlink.counter]);
|
|
48
|
+
|
|
49
|
+
return <React.Fragment />;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default withRouter(withHashLink(HashLink));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import CopyPaste from './CopyPaste';
|
|
2
|
+
import HashLink from './HashLink';
|
|
2
3
|
|
|
3
4
|
export default (config) => {
|
|
4
5
|
config.settings.appExtras = [
|
|
@@ -7,6 +8,10 @@ export default (config) => {
|
|
|
7
8
|
match: '/**/edit',
|
|
8
9
|
component: CopyPaste,
|
|
9
10
|
},
|
|
11
|
+
{
|
|
12
|
+
match: '',
|
|
13
|
+
component: HashLink,
|
|
14
|
+
},
|
|
10
15
|
];
|
|
11
16
|
|
|
12
17
|
return config;
|
package/src/hocs/index.js
CHANGED
|
@@ -2,5 +2,6 @@ import useResizeObserver from './useResizeObserver';
|
|
|
2
2
|
|
|
3
3
|
import withScreenSize from './withScreenSize';
|
|
4
4
|
import withLocalStorage from './withLocalStorage';
|
|
5
|
+
import withHashLink from './withHashLink';
|
|
5
6
|
|
|
6
|
-
export { useResizeObserver, withScreenSize, withLocalStorage };
|
|
7
|
+
export { useResizeObserver, withScreenSize, withLocalStorage, withHashLink };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import { setHashLink, resetHashLink } from '@eeacms/volto-n2k/actions/hashlink';
|
|
4
|
+
|
|
5
|
+
export default function withHashLink(WrappedComponent) {
|
|
6
|
+
return connect(
|
|
7
|
+
(state) => {
|
|
8
|
+
return {
|
|
9
|
+
hashlink: state.hashlink,
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
{ setHashLink, resetHashLink },
|
|
13
|
+
)((props) => {
|
|
14
|
+
return (
|
|
15
|
+
<WrappedComponent
|
|
16
|
+
{...props}
|
|
17
|
+
setHashLink={props.setHashLink}
|
|
18
|
+
resetHashLink={props.resetHashLink}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
}
|
package/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import loadable from '@loadable/component';
|
|
4
4
|
|
|
5
|
-
import localStorage from './
|
|
5
|
+
import { hashlink, localStorage } from './reducers';
|
|
6
6
|
|
|
7
7
|
import installAppExtras from './components/theme/AppExtras';
|
|
8
8
|
|
|
@@ -39,7 +39,7 @@ import installSpeciesProtectedSites from './components/manage/Blocks/SpeciesProt
|
|
|
39
39
|
import installStackedBarChart from './components/manage/Blocks/StackedBarChart';
|
|
40
40
|
import installTilesImages from './components/manage/Blocks/TilesImages';
|
|
41
41
|
|
|
42
|
-
import { LINK } from 'volto-slate/constants';
|
|
42
|
+
import { LINK } from '@plone/volto-slate/constants';
|
|
43
43
|
|
|
44
44
|
import { Header, Footer } from '@eeacms/volto-n2k/components';
|
|
45
45
|
|
|
@@ -64,6 +64,7 @@ const applyConfig = (config) => {
|
|
|
64
64
|
config.addonReducers = {
|
|
65
65
|
...config.addonReducers,
|
|
66
66
|
localStorage,
|
|
67
|
+
hashlink,
|
|
67
68
|
};
|
|
68
69
|
|
|
69
70
|
config.settings.persistentReducers.push('localStorage');
|
|
@@ -133,7 +134,6 @@ const applyConfig = (config) => {
|
|
|
133
134
|
|
|
134
135
|
return [
|
|
135
136
|
installAppExtras,
|
|
136
|
-
|
|
137
137
|
installBodyClass,
|
|
138
138
|
installBubbleChart,
|
|
139
139
|
installCarouselHorizontal,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const initialState = {
|
|
2
|
+
hash: null,
|
|
3
|
+
data: {},
|
|
4
|
+
counter: 0,
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export default function hashlink(state = initialState, action = {}) {
|
|
8
|
+
const { type, hash, data = {} } = action;
|
|
9
|
+
switch (type) {
|
|
10
|
+
case 'SET_HASH_LINK':
|
|
11
|
+
return {
|
|
12
|
+
...state,
|
|
13
|
+
hash,
|
|
14
|
+
data,
|
|
15
|
+
counter: state.counter + 1,
|
|
16
|
+
};
|
|
17
|
+
case 'RESET_HASH_LINK':
|
|
18
|
+
return {
|
|
19
|
+
...state,
|
|
20
|
+
hash: null,
|
|
21
|
+
data: {},
|
|
22
|
+
counter: 0,
|
|
23
|
+
};
|
|
24
|
+
default:
|
|
25
|
+
return state;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
File without changes
|