@eeacms/volto-citation 0.1.5 → 1.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/.eslintrc.js +65 -0
- package/CHANGELOG.md +21 -10
- package/jest-addon.config.js +19 -4
- package/jest.setup.js +65 -0
- package/package.json +3 -1
- package/src/Citation/Citation.jsx +88 -60
- package/src/Citation/styles.less +1 -2
- package/.project.eslintrc.js +0 -48
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const projectRootPath = fs.realpathSync(__dirname + '/../../../');
|
|
4
|
+
|
|
5
|
+
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
|
|
6
|
+
let configFile;
|
|
7
|
+
if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
|
|
8
|
+
configFile = `${projectRootPath}/tsconfig.json`;
|
|
9
|
+
else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
|
|
10
|
+
configFile = `${projectRootPath}/jsconfig.json`;
|
|
11
|
+
|
|
12
|
+
if (configFile) {
|
|
13
|
+
const jsConfig = require(configFile).compilerOptions;
|
|
14
|
+
const pathsConfig = jsConfig.paths;
|
|
15
|
+
if (pathsConfig['@plone/volto'])
|
|
16
|
+
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
|
|
20
|
+
const reg = new AddonConfigurationRegistry(projectRootPath);
|
|
21
|
+
|
|
22
|
+
// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
|
|
23
|
+
const addonAliases = Object.keys(reg.packages).map((o) => [
|
|
24
|
+
o,
|
|
25
|
+
reg.packages[o].modulePath,
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
|
|
29
|
+
|
|
30
|
+
const defaultConfig = {
|
|
31
|
+
extends: `${voltoPath}/.eslintrc`,
|
|
32
|
+
settings: {
|
|
33
|
+
'import/resolver': {
|
|
34
|
+
alias: {
|
|
35
|
+
map: [
|
|
36
|
+
['@plone/volto', '@plone/volto/src'],
|
|
37
|
+
['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
|
|
38
|
+
...addonAliases,
|
|
39
|
+
['@package', `${__dirname}/src`],
|
|
40
|
+
['@root', `${__dirname}/src`],
|
|
41
|
+
['~', `${__dirname}/src`],
|
|
42
|
+
],
|
|
43
|
+
extensions: ['.js', '.jsx', '.json'],
|
|
44
|
+
},
|
|
45
|
+
'babel-plugin-root-import': {
|
|
46
|
+
rootPathSuffix: 'src',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
rules: {
|
|
51
|
+
'react/jsx-no-target-blank': [
|
|
52
|
+
'error',
|
|
53
|
+
{
|
|
54
|
+
allowReferrer: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const config = addonExtenders.reduce(
|
|
61
|
+
(acc, extender) => extender.modify(acc),
|
|
62
|
+
defaultConfig,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
module.exports = config;
|
package/CHANGELOG.md
CHANGED
|
@@ -4,21 +4,36 @@ 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.1.0](https://github.com/eea/volto-citation/compare/1.0.0...1.1.0) - 21 May 2024
|
|
8
|
+
|
|
9
|
+
#### :bug: Bug Fixes
|
|
10
|
+
|
|
11
|
+
- fix(performance): load citation-js only when used - refs #262122 [ichim-david - [`ccddd2a`](https://github.com/eea/volto-citation/commit/ccddd2aede2df9b445fd3f447c808ef86a2608a3)]
|
|
12
|
+
|
|
13
|
+
## [1.0.0](https://github.com/eea/volto-citation/compare/0.1.5...1.0.0) - 22 April 2024
|
|
14
|
+
|
|
15
|
+
#### :rocket: New Features
|
|
16
|
+
|
|
17
|
+
- feat: Release 1.0.0 - Volto 17 support [alin - [`4b6a67d`](https://github.com/eea/volto-citation/commit/4b6a67dc1400034ab30c1d6c2054df2d025bd429)]
|
|
18
|
+
- feat: Volto 17 support - refs #264527 [EEA Jenkins - [`16d48de`](https://github.com/eea/volto-citation/commit/16d48de6f0acc5e61839479156d0bf2f553e314c)]
|
|
19
|
+
|
|
20
|
+
#### :house: Internal changes
|
|
21
|
+
|
|
22
|
+
- chore: package.json [Alin Voinea - [`2e1c298`](https://github.com/eea/volto-citation/commit/2e1c2986373e801a5bd8a7bea62fc8913a10f436)]
|
|
23
|
+
|
|
24
|
+
#### :hammer_and_wrench: Others
|
|
25
|
+
|
|
26
|
+
- test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`5a3d55d`](https://github.com/eea/volto-citation/commit/5a3d55d78d0b27d3162d442030808c88c8a2f333)]
|
|
27
|
+
- test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`3a3ba3e`](https://github.com/eea/volto-citation/commit/3a3ba3e55d9c089f44c8aac34dafaee100d5bd9e)]
|
|
7
28
|
### [0.1.5](https://github.com/eea/volto-citation/compare/0.1.4...0.1.5) - 17 January 2024
|
|
8
29
|
|
|
9
30
|
#### :house: Internal changes
|
|
10
31
|
|
|
11
|
-
- chore: [JENKINS] Refactor automated testing [valentinab25 - [`6571949`](https://github.com/eea/volto-citation/commit/6571949941593affae952a5e2539182c8937a89d)]
|
|
12
32
|
- chore: husky, lint-staged use fixed versions [valentinab25 - [`fe169f6`](https://github.com/eea/volto-citation/commit/fe169f675d540495272d60469024082aa5077095)]
|
|
13
33
|
- chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`79683d8`](https://github.com/eea/volto-citation/commit/79683d85b71803b96ef31b754bede458f7001c50)]
|
|
14
34
|
|
|
15
35
|
#### :hammer_and_wrench: Others
|
|
16
36
|
|
|
17
|
-
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`e5725a1`](https://github.com/eea/volto-citation/commit/e5725a1c8b9d7a5d0574a40fe785015db99ef33a)]
|
|
18
|
-
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`2196015`](https://github.com/eea/volto-citation/commit/2196015f5752129aebc5e35e0df465e070b9a09f)]
|
|
19
|
-
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`e0b9cf2`](https://github.com/eea/volto-citation/commit/e0b9cf2f1a8a20f4ab32ee357f6a1bab2637c9b1)]
|
|
20
|
-
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`dca3755`](https://github.com/eea/volto-citation/commit/dca375521c18d1d6fb64ece80ddb9a1db7f166f5)]
|
|
21
|
-
- test: [JENKINS] Improve cypress time [valentinab25 - [`7100915`](https://github.com/eea/volto-citation/commit/7100915a460506b44ead3295a220c0ec9caa6279)]
|
|
22
37
|
### [0.1.4](https://github.com/eea/volto-citation/compare/0.1.3...0.1.4) - 29 September 2023
|
|
23
38
|
|
|
24
39
|
#### :house: Internal changes
|
|
@@ -33,12 +48,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
33
48
|
#### :hammer_and_wrench: Others
|
|
34
49
|
|
|
35
50
|
- test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`adbc1b5`](https://github.com/eea/volto-citation/commit/adbc1b5359b70e16510b764eb42c1c52778536ab)]
|
|
36
|
-
- test: Fix eslint and yarn i18n [Alin Voinea - [`d8f5cd1`](https://github.com/eea/volto-citation/commit/d8f5cd1fab04c42e354af4ecd640e2f9d1202e38)]
|
|
37
51
|
- i18n: Add en [Alin Voinea - [`9100e04`](https://github.com/eea/volto-citation/commit/9100e04e4de63f607a3867eaf45161b90d0985be)]
|
|
38
52
|
- test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`766a456`](https://github.com/eea/volto-citation/commit/766a456f3ab988aa916feaae5fab9f2f894390fe)]
|
|
39
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`44b2af5`](https://github.com/eea/volto-citation/commit/44b2af58fe025442100ef0c52c45154b2d74e267)]
|
|
40
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`8f0a7e2`](https://github.com/eea/volto-citation/commit/8f0a7e2713a1a2a7ecf34bd3f7dc23e61b815283)]
|
|
41
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`c2597b9`](https://github.com/eea/volto-citation/commit/c2597b9778a2515e0b015b39a983add268f5c29a)]
|
|
42
53
|
### [0.1.3](https://github.com/eea/volto-citation/compare/0.1.2...0.1.3) - 3 August 2023
|
|
43
54
|
|
|
44
55
|
#### :house: Documentation changes
|
package/jest-addon.config.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require('dotenv').config({ path: __dirname + '/.env' })
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
3
5
|
collectCoverageFrom: [
|
|
@@ -9,18 +11,26 @@ module.exports = {
|
|
|
9
11
|
'@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
|
|
10
12
|
'@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
|
|
11
13
|
'@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
12
|
-
'@package/(.*)$': '<rootDir>/src/$1',
|
|
13
|
-
'@root/(.*)$': '<rootDir>/src/$1',
|
|
14
|
+
'@package/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
15
|
+
'@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
14
16
|
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
|
|
17
|
+
'@eeacms/search/(.*)$': '<rootDir>/src/addons/volto-searchlib/searchlib/$1',
|
|
18
|
+
'@eeacms/search': '<rootDir>/src/addons/volto-searchlib/searchlib',
|
|
15
19
|
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
|
|
16
|
-
'@plone/volto-slate':
|
|
20
|
+
'@plone/volto-slate$':
|
|
17
21
|
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
|
|
22
|
+
'@plone/volto-slate/(.*)$':
|
|
23
|
+
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
|
|
18
24
|
'~/(.*)$': '<rootDir>/src/$1',
|
|
19
25
|
'load-volto-addons':
|
|
20
26
|
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
|
|
21
27
|
},
|
|
28
|
+
transformIgnorePatterns: [
|
|
29
|
+
'/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
|
|
30
|
+
],
|
|
22
31
|
transform: {
|
|
23
32
|
'^.+\\.js(x)?$': 'babel-jest',
|
|
33
|
+
'^.+\\.ts(x)?$': 'babel-jest',
|
|
24
34
|
'^.+\\.(png)$': 'jest-file',
|
|
25
35
|
'^.+\\.(jpg)$': 'jest-file',
|
|
26
36
|
'^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
|
|
@@ -33,4 +43,9 @@ module.exports = {
|
|
|
33
43
|
statements: 5,
|
|
34
44
|
},
|
|
35
45
|
},
|
|
36
|
-
|
|
46
|
+
...(process.env.JEST_USE_SETUP === 'ON' && {
|
|
47
|
+
setupFilesAfterEnv: [
|
|
48
|
+
'<rootDir>/node_modules/@eeacms/volto-citation/jest.setup.js',
|
|
49
|
+
],
|
|
50
|
+
}),
|
|
51
|
+
}
|
package/jest.setup.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import configureStore from 'redux-mock-store';
|
|
3
|
+
import thunk from 'redux-thunk';
|
|
4
|
+
import { blocksConfig } from '@plone/volto/config/Blocks';
|
|
5
|
+
import installSlate from '@plone/volto-slate/index';
|
|
6
|
+
|
|
7
|
+
var mockSemanticComponents = jest.requireActual('semantic-ui-react');
|
|
8
|
+
var mockComponents = jest.requireActual('@plone/volto/components');
|
|
9
|
+
var config = jest.requireActual('@plone/volto/registry').default;
|
|
10
|
+
|
|
11
|
+
config.blocks.blocksConfig = {
|
|
12
|
+
...blocksConfig,
|
|
13
|
+
...config.blocks.blocksConfig,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
jest.doMock('semantic-ui-react', () => ({
|
|
17
|
+
__esModule: true,
|
|
18
|
+
...mockSemanticComponents,
|
|
19
|
+
Popup: ({ content, trigger }) => {
|
|
20
|
+
return (
|
|
21
|
+
<div className="popup">
|
|
22
|
+
<div className="trigger">{trigger}</div>
|
|
23
|
+
<div className="content">{content}</div>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
jest.doMock('@plone/volto/components', () => {
|
|
30
|
+
return {
|
|
31
|
+
__esModule: true,
|
|
32
|
+
...mockComponents,
|
|
33
|
+
SidebarPortal: ({ children }) => <div id="sidebar">{children}</div>,
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
jest.doMock('@plone/volto/registry', () =>
|
|
38
|
+
[installSlate].reduce((acc, apply) => apply(acc), config),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const mockStore = configureStore([thunk]);
|
|
42
|
+
|
|
43
|
+
global.fetch = jest.fn(() =>
|
|
44
|
+
Promise.resolve({
|
|
45
|
+
json: () => Promise.resolve({}),
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
global.store = mockStore({
|
|
50
|
+
intl: {
|
|
51
|
+
locale: 'en',
|
|
52
|
+
messages: {},
|
|
53
|
+
formatMessage: jest.fn(),
|
|
54
|
+
},
|
|
55
|
+
content: {
|
|
56
|
+
create: {},
|
|
57
|
+
subrequests: [],
|
|
58
|
+
},
|
|
59
|
+
connected_data_parameters: {},
|
|
60
|
+
screen: {
|
|
61
|
+
page: {
|
|
62
|
+
width: 768,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-citation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "@eeacms/volto-citation: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"@cypress/code-coverage": "^3.10.0",
|
|
25
25
|
"@plone/scripts": "*",
|
|
26
26
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
27
|
+
"cypress": "13.1.0",
|
|
27
28
|
"cypress-fail-fast": "^5.0.1",
|
|
29
|
+
"dotenv": "^16.3.2",
|
|
28
30
|
"husky": "^8.0.3",
|
|
29
31
|
"lint-staged": "^14.0.1",
|
|
30
32
|
"md5": "^2.3.0"
|
|
@@ -1,28 +1,39 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
2
|
import { Tab, Label, Menu } from 'semantic-ui-react';
|
|
3
3
|
import { useCopyToClipboard } from '@eeacms/volto-citation/helpers';
|
|
4
4
|
import { Icon } from '@plone/volto/components';
|
|
5
|
-
|
|
6
|
-
import Cite from 'citation-js';
|
|
5
|
+
import loadable from '@loadable/component';
|
|
7
6
|
|
|
8
7
|
import copySVG from '@plone/volto/icons/copy.svg';
|
|
9
8
|
import checkSVG from '@plone/volto/icons/check.svg';
|
|
10
9
|
|
|
11
10
|
import './styles.less';
|
|
12
11
|
|
|
12
|
+
const CitationJS = loadable.lib(() => import('citation-js'));
|
|
13
|
+
|
|
13
14
|
const CopyUrlButton = ({ citation, className }) => {
|
|
14
15
|
const [copyUrlStatus, copyUrl] = useCopyToClipboard(citation);
|
|
15
16
|
const [icon, setIcon] = useState(copySVG);
|
|
17
|
+
const timeoutRef = useRef(null);
|
|
16
18
|
|
|
17
19
|
useEffect(() => {
|
|
18
20
|
if (copyUrlStatus === 'copied') {
|
|
19
21
|
setIcon(checkSVG);
|
|
20
|
-
setTimeout(() => {
|
|
22
|
+
timeoutRef.current = setTimeout(() => {
|
|
21
23
|
setIcon(copySVG);
|
|
22
|
-
},
|
|
24
|
+
}, 5000);
|
|
23
25
|
}
|
|
24
26
|
}, [copyUrlStatus]);
|
|
25
27
|
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
return () => {
|
|
30
|
+
if (timeoutRef.current) {
|
|
31
|
+
clearTimeout(timeoutRef.current);
|
|
32
|
+
timeoutRef.current = null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
26
37
|
return (
|
|
27
38
|
<Label
|
|
28
39
|
floating
|
|
@@ -43,44 +54,71 @@ const CopyUrlButton = ({ citation, className }) => {
|
|
|
43
54
|
};
|
|
44
55
|
|
|
45
56
|
function Citation({ title, authors, link, type = 'article', year, mode }) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
const [htmlCitation, setHtmlCitation] = useState('');
|
|
58
|
+
const [textCitation, setTextCitation] = useState('');
|
|
59
|
+
const [risCitation, setRisCitation] = useState('');
|
|
60
|
+
const [bibtexCitation, setBibtexCitation] = useState('');
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
let isMounted = true;
|
|
64
|
+
|
|
65
|
+
const loadCitation = async () => {
|
|
66
|
+
const module = await CitationJS.load();
|
|
67
|
+
const { default: Cite } = module;
|
|
68
|
+
const citationObject = new Cite({
|
|
69
|
+
title: title,
|
|
70
|
+
type: type,
|
|
71
|
+
author: authors.map((author) => {
|
|
72
|
+
return {
|
|
73
|
+
literal: author,
|
|
74
|
+
};
|
|
75
|
+
}),
|
|
76
|
+
issued: { 'date-parts': [[year]] },
|
|
77
|
+
URL: link,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (isMounted) {
|
|
81
|
+
setHtmlCitation(`<blockquote>
|
|
62
82
|
<p>(${year}).</p>
|
|
63
83
|
<p>${title}</p>
|
|
64
84
|
<p>${authors.map((author, index) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
85
|
+
const separator = index < authors.length - 1 ? ', ' : '';
|
|
86
|
+
return (author || '') + separator;
|
|
87
|
+
})}
|
|
68
88
|
</p>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
${
|
|
90
|
+
mode !== 'edit'
|
|
91
|
+
? '<a href=' + link + '>' + link + '</a>'
|
|
92
|
+
: '<p>' + link + '</p>'
|
|
93
|
+
}
|
|
94
|
+
</blockquote>`);
|
|
95
|
+
|
|
96
|
+
setTextCitation(
|
|
97
|
+
citationObject
|
|
98
|
+
.format('bibliography', {
|
|
99
|
+
format: 'text',
|
|
100
|
+
template: 'apa',
|
|
101
|
+
})
|
|
102
|
+
.replace(/(^[ \t]*\n)/gm, ''),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
setRisCitation(citationObject.format('ris'));
|
|
106
|
+
setBibtexCitation(citationObject.format('bibtex'));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
loadCitation();
|
|
111
|
+
|
|
112
|
+
return () => {
|
|
113
|
+
isMounted = false;
|
|
114
|
+
};
|
|
115
|
+
}, [title, authors, link, type, year, mode]);
|
|
116
|
+
|
|
117
|
+
const tab_panes = [
|
|
81
118
|
{
|
|
82
119
|
menuItem: (
|
|
83
120
|
<Menu.Item
|
|
121
|
+
key="html"
|
|
84
122
|
tabIndex={0}
|
|
85
123
|
onKeyDown={(e) => {
|
|
86
124
|
if (e.key === 'Enter') e.target.click();
|
|
@@ -91,26 +129,17 @@ function Citation({ title, authors, link, type = 'article', year, mode }) {
|
|
|
91
129
|
),
|
|
92
130
|
render: () => (
|
|
93
131
|
<Tab.Pane attached={false}>
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
{authors.map((author, index) => {
|
|
99
|
-
let separator = '';
|
|
100
|
-
if (index < authors.length - 1) separator = ', ';
|
|
101
|
-
return (author || '') + separator;
|
|
102
|
-
})}
|
|
103
|
-
</p>
|
|
104
|
-
{mode === 'edit' ? <p>{link}</p> : <a href={link}>{link}</a>}
|
|
105
|
-
|
|
106
|
-
<CopyUrlButton citation={cite('html')} />
|
|
107
|
-
</blockquote>
|
|
132
|
+
<div className="text">
|
|
133
|
+
<div dangerouslySetInnerHTML={{ __html: htmlCitation }} />
|
|
134
|
+
<CopyUrlButton citation={htmlCitation} />
|
|
135
|
+
</div>
|
|
108
136
|
</Tab.Pane>
|
|
109
137
|
),
|
|
110
138
|
},
|
|
111
139
|
{
|
|
112
140
|
menuItem: (
|
|
113
141
|
<Menu.Item
|
|
142
|
+
key="text"
|
|
114
143
|
tabIndex={0}
|
|
115
144
|
onKeyDown={(e) => {
|
|
116
145
|
if (e.key === 'Enter') e.target.click();
|
|
@@ -122,9 +151,8 @@ function Citation({ title, authors, link, type = 'article', year, mode }) {
|
|
|
122
151
|
render: () => (
|
|
123
152
|
<Tab.Pane attached={false}>
|
|
124
153
|
<div className="text">
|
|
125
|
-
<pre>{
|
|
126
|
-
|
|
127
|
-
<CopyUrlButton citation={cite('bibliography', 'text')} />
|
|
154
|
+
<pre>{textCitation}</pre>
|
|
155
|
+
<CopyUrlButton citation={textCitation} />
|
|
128
156
|
</div>
|
|
129
157
|
</Tab.Pane>
|
|
130
158
|
),
|
|
@@ -132,6 +160,7 @@ function Citation({ title, authors, link, type = 'article', year, mode }) {
|
|
|
132
160
|
{
|
|
133
161
|
menuItem: (
|
|
134
162
|
<Menu.Item
|
|
163
|
+
key="ris"
|
|
135
164
|
tabIndex={0}
|
|
136
165
|
onKeyDown={(e) => {
|
|
137
166
|
if (e.key === 'Enter') e.target.click();
|
|
@@ -143,9 +172,8 @@ function Citation({ title, authors, link, type = 'article', year, mode }) {
|
|
|
143
172
|
render: () => (
|
|
144
173
|
<Tab.Pane attached={false}>
|
|
145
174
|
<div className="text">
|
|
146
|
-
<pre>{
|
|
147
|
-
|
|
148
|
-
<CopyUrlButton citation={cite('ris')} />
|
|
175
|
+
<pre>{risCitation}</pre>
|
|
176
|
+
<CopyUrlButton citation={risCitation} />
|
|
149
177
|
</div>
|
|
150
178
|
</Tab.Pane>
|
|
151
179
|
),
|
|
@@ -153,6 +181,7 @@ function Citation({ title, authors, link, type = 'article', year, mode }) {
|
|
|
153
181
|
{
|
|
154
182
|
menuItem: (
|
|
155
183
|
<Menu.Item
|
|
184
|
+
key="bibtex"
|
|
156
185
|
tabIndex={0}
|
|
157
186
|
onKeyDown={(e) => {
|
|
158
187
|
if (e.key === 'Enter') e.target.click();
|
|
@@ -164,9 +193,8 @@ function Citation({ title, authors, link, type = 'article', year, mode }) {
|
|
|
164
193
|
render: () => (
|
|
165
194
|
<Tab.Pane attached={false}>
|
|
166
195
|
<div className="text">
|
|
167
|
-
<pre>{
|
|
168
|
-
|
|
169
|
-
<CopyUrlButton citation={cite('bibtex')} />
|
|
196
|
+
<pre>{bibtexCitation}</pre>
|
|
197
|
+
<CopyUrlButton citation={bibtexCitation} />
|
|
170
198
|
</div>
|
|
171
199
|
</Tab.Pane>
|
|
172
200
|
),
|
|
@@ -176,7 +204,7 @@ function Citation({ title, authors, link, type = 'article', year, mode }) {
|
|
|
176
204
|
return (
|
|
177
205
|
<div className="citation-block tabs-block">
|
|
178
206
|
<Tab
|
|
179
|
-
panes={
|
|
207
|
+
panes={tab_panes}
|
|
180
208
|
menu={{ className: 'ui green fluid pointing secondary menu' }}
|
|
181
209
|
/>
|
|
182
210
|
</div>
|
package/src/Citation/styles.less
CHANGED
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
overflow: auto;
|
|
40
40
|
padding: 9.5px;
|
|
41
41
|
border: 1px solid #ccc;
|
|
42
|
+
border-radius: 4px;
|
|
42
43
|
margin: 0 0 10px;
|
|
43
44
|
background-color: #f5f5f5;
|
|
44
|
-
border-radius: 4px;
|
|
45
45
|
line-height: 1.428571429;
|
|
46
46
|
word-break: break-all;
|
|
47
47
|
word-wrap: break-word;
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
|
|
50
50
|
blockquote {
|
|
51
51
|
position: relative;
|
|
52
|
-
width: 80%;
|
|
53
52
|
padding: 1.2em 30px 1.2em 75px;
|
|
54
53
|
border-left: 8px solid @secondaryColor;
|
|
55
54
|
margin: 50px auto;
|
package/.project.eslintrc.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
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(projectRootPath, 'jsconfig.json')).compilerOptions;
|
|
9
|
-
|
|
10
|
-
const pathsConfig = jsConfig.paths;
|
|
11
|
-
|
|
12
|
-
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
|
|
13
|
-
|
|
14
|
-
Object.keys(pathsConfig).forEach(pkg => {
|
|
15
|
-
if (pkg === '@plone/volto') {
|
|
16
|
-
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
|
|
20
|
-
const reg = new AddonConfigurationRegistry(projectRootPath);
|
|
21
|
-
|
|
22
|
-
// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
|
|
23
|
-
const addonAliases = Object.keys(reg.packages).map(o => [
|
|
24
|
-
o,
|
|
25
|
-
reg.packages[o].modulePath,
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
module.exports = {
|
|
30
|
-
extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
|
|
31
|
-
settings: {
|
|
32
|
-
'import/resolver': {
|
|
33
|
-
alias: {
|
|
34
|
-
map: [
|
|
35
|
-
['@plone/volto', '@plone/volto/src'],
|
|
36
|
-
...addonAliases,
|
|
37
|
-
['@package', `${__dirname}/src`],
|
|
38
|
-
['~', `${__dirname}/src`],
|
|
39
|
-
],
|
|
40
|
-
extensions: ['.js', '.jsx', '.json'],
|
|
41
|
-
},
|
|
42
|
-
'babel-plugin-root-import': {
|
|
43
|
-
rootPathSuffix: 'src',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|