@eeacms/volto-n2k 1.0.1 → 1.0.3
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/.project.eslintrc.js +22 -19
- package/CHANGELOG.md +11 -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/components/theme/Navigation/Navigation.jsx +1 -1
- 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/.project.eslintrc.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
const fs = require(
|
|
2
|
-
const path = require(
|
|
3
|
-
|
|
4
|
-
const projectRootPath = fs.
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const projectRootPath = fs.existsSync("./project")
|
|
5
|
+
? fs.realpathSync("./project")
|
|
6
|
+
: fs.realpathSync("./../../../");
|
|
7
|
+
const packageJson = require(path.join(projectRootPath, "package.json"));
|
|
8
|
+
const jsConfig = require(path.join(
|
|
9
|
+
projectRootPath,
|
|
10
|
+
"jsconfig.json"
|
|
11
|
+
)).compilerOptions;
|
|
7
12
|
|
|
8
13
|
const pathsConfig = jsConfig.paths;
|
|
9
14
|
|
|
10
|
-
let voltoPath = path.join(projectRootPath,
|
|
15
|
+
let voltoPath = path.join(projectRootPath, "node_modules/@plone/volto");
|
|
11
16
|
|
|
12
|
-
Object.keys(pathsConfig).forEach(pkg => {
|
|
13
|
-
if (pkg ===
|
|
17
|
+
Object.keys(pathsConfig).forEach((pkg) => {
|
|
18
|
+
if (pkg === "@plone/volto") {
|
|
14
19
|
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
|
|
15
20
|
}
|
|
16
21
|
});
|
|
@@ -18,29 +23,27 @@ const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
|
|
|
18
23
|
const reg = new AddonConfigurationRegistry(projectRootPath);
|
|
19
24
|
|
|
20
25
|
// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
|
|
21
|
-
const addonAliases = Object.keys(reg.packages).map(o => [
|
|
26
|
+
const addonAliases = Object.keys(reg.packages).map((o) => [
|
|
22
27
|
o,
|
|
23
28
|
reg.packages[o].modulePath,
|
|
24
29
|
]);
|
|
25
30
|
|
|
26
|
-
|
|
27
31
|
module.exports = {
|
|
28
32
|
extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
|
|
29
33
|
settings: {
|
|
30
|
-
|
|
34
|
+
"import/resolver": {
|
|
31
35
|
alias: {
|
|
32
36
|
map: [
|
|
33
|
-
[
|
|
37
|
+
["@plone/volto", "@plone/volto/src"],
|
|
34
38
|
...addonAliases,
|
|
35
|
-
[
|
|
36
|
-
[
|
|
39
|
+
["@package", `${__dirname}/src`],
|
|
40
|
+
["~", `${__dirname}/src`],
|
|
37
41
|
],
|
|
38
|
-
extensions: [
|
|
42
|
+
extensions: [".js", ".jsx", ".json"],
|
|
39
43
|
},
|
|
40
|
-
|
|
41
|
-
rootPathSuffix:
|
|
44
|
+
"babel-plugin-root-import": {
|
|
45
|
+
rootPathSuffix: "src",
|
|
42
46
|
},
|
|
43
47
|
},
|
|
44
48
|
},
|
|
45
49
|
};
|
|
46
|
-
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@ 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.3](https://github.com/eea/volto-n2k/compare/1.0.2...1.0.3) - 10 November 2022
|
|
8
|
+
|
|
9
|
+
#### :bug: Bug Fixes
|
|
10
|
+
|
|
11
|
+
- fix: show navigation for explorer [Miu Razvan - [`3dda827`](https://github.com/eea/volto-n2k/commit/3dda82724fa04ddfb52f6c4f0f050d29a46f21e8)]
|
|
12
|
+
|
|
13
|
+
#### :hammer_and_wrench: Others
|
|
14
|
+
|
|
15
|
+
- fix error [Claudia Ifrim - [`2942ada`](https://github.com/eea/volto-n2k/commit/2942adaa55a378b9861bff6567899606fd193c8b)]
|
|
16
|
+
### [1.0.2](https://github.com/eea/volto-n2k/compare/1.0.1...1.0.2) - 4 November 2022
|
|
17
|
+
|
|
7
18
|
### [1.0.1](https://github.com/eea/volto-n2k/compare/1.0.0...1.0.1) - 2 November 2022
|
|
8
19
|
|
|
9
20
|
#### :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.3",
|
|
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;
|
|
@@ -313,7 +313,7 @@ class Navigation extends Component {
|
|
|
313
313
|
''
|
|
314
314
|
)}
|
|
315
315
|
|
|
316
|
-
{!this.state.isSdf && !this.props.isRoot
|
|
316
|
+
{(!this.state.isSdf && !this.props.isRoot) || this.props.isExplorer
|
|
317
317
|
? this.props.items.map((item) => {
|
|
318
318
|
const flatUrl = flattenToAppURL(item.url);
|
|
319
319
|
const itemID = item.title.split(' ').join('-').toLowerCase();
|
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
|