@eeacms/volto-eea-website-policy 0.2.1 → 0.2.4
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 +31 -0
- package/jest-addon.config.js +1 -0
- package/package.json +6 -2
- package/src/components/Blocks/Item/Edit.jsx +98 -0
- package/src/components/Blocks/Item/Item.jsx +50 -0
- package/src/components/Blocks/Item/View.jsx +9 -0
- package/src/components/Blocks/Item/index.js +32 -0
- package/src/components/Blocks/Item/schema.js +101 -0
- package/src/components/Blocks/Teaser/Card.jsx +73 -0
- package/src/components/Blocks/Teaser/Schema.js +57 -0
- package/src/components/Blocks/Teaser/index.js +26 -0
- package/src/components/Blocks/Teaser/utils.js +18 -0
- package/src/helpers.js +11 -0
- package/src/index.js +52 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,39 @@ 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
|
+
#### [0.2.4](https://github.com/eea/volto-eea-website-policy/compare/0.2.3...0.2.4)
|
|
8
|
+
|
|
9
|
+
- Fix listing block title: Listing (Content) [`cec2760`](https://github.com/eea/volto-eea-website-policy/commit/cec276082c3fc1b5486c996c3746a6958fb3a1a9)
|
|
10
|
+
- Add theme to teaser stylewrapper [`60eeb28`](https://github.com/eea/volto-eea-website-policy/commit/60eeb28b7793708c59d0af73ffb09895e8f2c87d)
|
|
11
|
+
- Fix className vs class warning [`fea1603`](https://github.com/eea/volto-eea-website-policy/commit/fea1603eefd628d57640a6b94ddbbb7edfb0d841)
|
|
12
|
+
- Custom card view for teaser [`c8eded0`](https://github.com/eea/volto-eea-website-policy/commit/c8eded011b8317cce9f842526f5d86771f54797b)
|
|
13
|
+
|
|
14
|
+
#### [0.2.3](https://github.com/eea/volto-eea-website-policy/compare/0.2.2...0.2.3)
|
|
15
|
+
|
|
16
|
+
> 10 June 2022
|
|
17
|
+
|
|
18
|
+
- Add Item block [`#9`](https://github.com/eea/volto-eea-website-policy/pull/9)
|
|
19
|
+
- prettier fix [`c2a6d2d`](https://github.com/eea/volto-eea-website-policy/commit/c2a6d2d3b12ce771b9b4413c5a6db157ccd9d1fc)
|
|
20
|
+
- Update index.js [`fb73895`](https://github.com/eea/volto-eea-website-policy/commit/fb7389509bc7e207942762c5e02a93d0168a6fba)
|
|
21
|
+
- removed change from commit 719e3778 [`29e636b`](https://github.com/eea/volto-eea-website-policy/commit/29e636b34ab02992c67cc5960f4dc6b21b1b4e71)
|
|
22
|
+
- added navDepth to level 4 in order to fill mega menu [`719e377`](https://github.com/eea/volto-eea-website-policy/commit/719e37785cfa2ed37568c82a34dc470b52483d04)
|
|
23
|
+
- Rearrange Block Chooser [`9a5c118`](https://github.com/eea/volto-eea-website-policy/commit/9a5c1187ba21fa1898394a4b6cf6dd68bd68f258)
|
|
24
|
+
- Move Item block un components folder [`9fb6ab2`](https://github.com/eea/volto-eea-website-policy/commit/9fb6ab2fb02cc5c1a7e25367de5ebe7109bd3dc4)
|
|
25
|
+
- Set default sizes for image & icon in Item block [`af22ec7`](https://github.com/eea/volto-eea-website-policy/commit/af22ec78b2c6fd1d033dc1acfec5e64f8926cd77)
|
|
26
|
+
- Add helpers functions [`353581c`](https://github.com/eea/volto-eea-website-policy/commit/353581cc6602b5e573eee93c74a67656203c0968)
|
|
27
|
+
- Add Teaser block folder's structure [`9457dd4`](https://github.com/eea/volto-eea-website-policy/commit/9457dd4ffaa2631eceb46bfd1ec2d201e8b3d7a8)
|
|
28
|
+
|
|
29
|
+
#### [0.2.2](https://github.com/eea/volto-eea-website-policy/compare/0.2.1...0.2.2)
|
|
30
|
+
|
|
31
|
+
> 24 May 2022
|
|
32
|
+
|
|
33
|
+
- Install callout and remove blockquote - refs #148688 [`#8`](https://github.com/eea/volto-eea-website-policy/pull/8)
|
|
34
|
+
|
|
7
35
|
#### [0.2.1](https://github.com/eea/volto-eea-website-policy/compare/0.2.0...0.2.1)
|
|
8
36
|
|
|
37
|
+
> 25 March 2022
|
|
38
|
+
|
|
39
|
+
- 137187 keycloak integration for plone6 (#3) [`#6`](https://github.com/eea/volto-eea-website-policy/pull/6)
|
|
9
40
|
- 137187 keycloak integration for plone6 [`#3`](https://github.com/eea/volto-eea-website-policy/pull/3)
|
|
10
41
|
|
|
11
42
|
#### [0.2.0](https://github.com/eea/volto-eea-website-policy/compare/0.1.1...0.2.0)
|
package/jest-addon.config.js
CHANGED
|
@@ -9,6 +9,7 @@ module.exports = {
|
|
|
9
9
|
'@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
|
|
10
10
|
'@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
11
11
|
'@package/(.*)$': '<rootDir>/src/$1',
|
|
12
|
+
'@root/(.*)$': '<rootDir>/src/$1',
|
|
12
13
|
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
|
|
13
14
|
'@eeacms/(.*?)/(.*)$': '<rootDir>/src/addons/$1/src/$2',
|
|
14
15
|
'volto-slate/(.*)$': '<rootDir>/src/addons/volto-slate/src/$1',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-eea-website-policy",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "@eeacms/volto-eea-website-policy: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -16,8 +16,12 @@
|
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "git@github.com:eea/volto-eea-website-policy.git"
|
|
18
18
|
},
|
|
19
|
+
"addons": [
|
|
20
|
+
"volto-slate"
|
|
21
|
+
],
|
|
19
22
|
"dependencies": {
|
|
20
|
-
"@plone/scripts": "*"
|
|
23
|
+
"@plone/scripts": "*",
|
|
24
|
+
"volto-slate": "*"
|
|
21
25
|
},
|
|
22
26
|
"devDependencies": {
|
|
23
27
|
"@cypress/code-coverage": "^3.9.5",
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import config from '@plone/volto/registry';
|
|
4
|
+
import { BlockDataForm, SidebarPortal } from '@plone/volto/components';
|
|
5
|
+
import SlateEditor from 'volto-slate/editor/SlateEditor';
|
|
6
|
+
import { handleKey } from 'volto-slate/blocks/Text/keyboard';
|
|
7
|
+
import { uploadContent, saveSlateBlockSelection } from 'volto-slate/actions';
|
|
8
|
+
|
|
9
|
+
import { createSlateParagraph } from '@eeacms/volto-eea-website-policy/helpers';
|
|
10
|
+
|
|
11
|
+
import Item from './Item';
|
|
12
|
+
import getSchema from './schema';
|
|
13
|
+
|
|
14
|
+
const Edit = (props) => {
|
|
15
|
+
const { slate } = config.settings;
|
|
16
|
+
const {
|
|
17
|
+
data = {},
|
|
18
|
+
block = null,
|
|
19
|
+
selected = false,
|
|
20
|
+
index,
|
|
21
|
+
properties,
|
|
22
|
+
onChangeBlock,
|
|
23
|
+
onSelectBlock,
|
|
24
|
+
} = props;
|
|
25
|
+
const { description } = data;
|
|
26
|
+
const schema = React.useMemo(() => getSchema(props), [props]);
|
|
27
|
+
|
|
28
|
+
const withBlockProperties = React.useCallback(
|
|
29
|
+
(editor) => {
|
|
30
|
+
editor.getBlockProps = () => props;
|
|
31
|
+
return editor;
|
|
32
|
+
},
|
|
33
|
+
[props],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const handleFocus = React.useCallback(() => {
|
|
37
|
+
if (!selected) {
|
|
38
|
+
onSelectBlock(block);
|
|
39
|
+
}
|
|
40
|
+
}, [onSelectBlock, selected, block]);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<Item {...data} mode="edit">
|
|
45
|
+
<SlateEditor
|
|
46
|
+
index={index}
|
|
47
|
+
properties={properties}
|
|
48
|
+
extensions={slate.textblockExtensions}
|
|
49
|
+
renderExtensions={[withBlockProperties]}
|
|
50
|
+
value={createSlateParagraph(description)}
|
|
51
|
+
onChange={(description) => {
|
|
52
|
+
onChangeBlock(block, {
|
|
53
|
+
...data,
|
|
54
|
+
description,
|
|
55
|
+
});
|
|
56
|
+
}}
|
|
57
|
+
block={block}
|
|
58
|
+
onFocus={handleFocus}
|
|
59
|
+
onKeyDown={handleKey}
|
|
60
|
+
selected={selected}
|
|
61
|
+
placeholder="Add item description..."
|
|
62
|
+
slateSettings={slate}
|
|
63
|
+
/>
|
|
64
|
+
</Item>
|
|
65
|
+
<SidebarPortal selected={selected}>
|
|
66
|
+
<BlockDataForm
|
|
67
|
+
block={block}
|
|
68
|
+
schema={schema}
|
|
69
|
+
title={schema.title}
|
|
70
|
+
onChangeField={(id, value) => {
|
|
71
|
+
onChangeBlock(block, {
|
|
72
|
+
...data,
|
|
73
|
+
[id]: value,
|
|
74
|
+
});
|
|
75
|
+
}}
|
|
76
|
+
formData={data}
|
|
77
|
+
/>
|
|
78
|
+
</SidebarPortal>
|
|
79
|
+
</>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default connect(
|
|
84
|
+
(state, props) => {
|
|
85
|
+
const blockId = props.block;
|
|
86
|
+
return {
|
|
87
|
+
defaultSelection: blockId
|
|
88
|
+
? state.slate_block_selections?.[blockId]
|
|
89
|
+
: null,
|
|
90
|
+
uploadRequest: state.upload_content?.[props.block]?.upload || {},
|
|
91
|
+
uploadedContent: state.upload_content?.[props.block]?.data || {},
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
uploadContent,
|
|
96
|
+
saveSlateBlockSelection, // needed as editor blockProps
|
|
97
|
+
},
|
|
98
|
+
)(Edit);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import { Item as UiItem, Icon } from 'semantic-ui-react';
|
|
3
|
+
import { serializeText } from '@eeacms/volto-eea-website-policy/helpers';
|
|
4
|
+
|
|
5
|
+
function Item({
|
|
6
|
+
assetType,
|
|
7
|
+
children,
|
|
8
|
+
description,
|
|
9
|
+
extra,
|
|
10
|
+
header,
|
|
11
|
+
icon,
|
|
12
|
+
iconSize = 'huge',
|
|
13
|
+
iconTheme,
|
|
14
|
+
image,
|
|
15
|
+
imageSize = 'tile',
|
|
16
|
+
meta,
|
|
17
|
+
mode = 'view',
|
|
18
|
+
styles = {},
|
|
19
|
+
}) {
|
|
20
|
+
const { verticalAlign } = styles;
|
|
21
|
+
return (
|
|
22
|
+
<UiItem.Group unstackable className="row">
|
|
23
|
+
<UiItem className={cx(styles?.theme)}>
|
|
24
|
+
{assetType === 'image' && image && (
|
|
25
|
+
<UiItem.Image
|
|
26
|
+
src={`${image}/@@images/image/preview`}
|
|
27
|
+
className={cx('ui', imageSize)}
|
|
28
|
+
alt={header || 'Item image'}
|
|
29
|
+
/>
|
|
30
|
+
)}
|
|
31
|
+
{assetType === 'icon' && icon && (
|
|
32
|
+
<Icon className={cx(icon, iconTheme)} size={iconSize} />
|
|
33
|
+
)}
|
|
34
|
+
<UiItem.Content verticalAlign={verticalAlign}>
|
|
35
|
+
{header && <UiItem.Header>{header}</UiItem.Header>}
|
|
36
|
+
{meta && <UiItem.Meta>{meta}</UiItem.Meta>}
|
|
37
|
+
{description && mode === 'view' && (
|
|
38
|
+
<UiItem.Description>
|
|
39
|
+
{serializeText(description)}
|
|
40
|
+
</UiItem.Description>
|
|
41
|
+
)}
|
|
42
|
+
{mode === 'edit' && children}
|
|
43
|
+
{extra && <UiItem.Extra>{extra}</UiItem.Extra>}
|
|
44
|
+
</UiItem.Content>
|
|
45
|
+
</UiItem>
|
|
46
|
+
</UiItem.Group>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default Item;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import codeSVG from '@plone/volto/icons/code.svg';
|
|
2
|
+
import ItemEdit from './Edit';
|
|
3
|
+
import ItemView from './View';
|
|
4
|
+
import { stylingSchema } from './schema';
|
|
5
|
+
|
|
6
|
+
export default (config) => {
|
|
7
|
+
config.blocks.blocksConfig.item = {
|
|
8
|
+
id: 'item',
|
|
9
|
+
title: 'Item',
|
|
10
|
+
icon: codeSVG,
|
|
11
|
+
group: 'common',
|
|
12
|
+
edit: ItemEdit,
|
|
13
|
+
view: ItemView,
|
|
14
|
+
blockHasOwnFocusManagement: true,
|
|
15
|
+
stylesSchema: stylingSchema,
|
|
16
|
+
enableStyling: true,
|
|
17
|
+
restricted: false,
|
|
18
|
+
mostUsed: false,
|
|
19
|
+
sidebarTab: 1,
|
|
20
|
+
security: {
|
|
21
|
+
addPermission: [],
|
|
22
|
+
view: [],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
config.settings.blocksWithFootnotesSupport = {
|
|
27
|
+
...(config.settings.blocksWithFootnotesSupport || {}),
|
|
28
|
+
item: ['description'],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return config;
|
|
32
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export default ({ data }) => {
|
|
2
|
+
const { assetType = 'image' } = data;
|
|
3
|
+
return {
|
|
4
|
+
title: 'Item',
|
|
5
|
+
fieldsets: [
|
|
6
|
+
{
|
|
7
|
+
id: 'default',
|
|
8
|
+
title: 'Default',
|
|
9
|
+
fields: ['assetType'],
|
|
10
|
+
},
|
|
11
|
+
...(assetType === 'image'
|
|
12
|
+
? [{ id: 'image', title: 'Image', fields: ['image', 'imageSize'] }]
|
|
13
|
+
: []),
|
|
14
|
+
...(assetType === 'icon'
|
|
15
|
+
? [{ id: 'icon', title: 'Icon', fields: ['icon', 'iconSize'] }]
|
|
16
|
+
: []),
|
|
17
|
+
],
|
|
18
|
+
properties: {
|
|
19
|
+
assetType: {
|
|
20
|
+
title: 'Asset type',
|
|
21
|
+
choices: [
|
|
22
|
+
['image', 'Image'],
|
|
23
|
+
['icon', 'Icon'],
|
|
24
|
+
],
|
|
25
|
+
default: 'image',
|
|
26
|
+
},
|
|
27
|
+
image: {
|
|
28
|
+
title: 'Image',
|
|
29
|
+
widget: 'attachedimage',
|
|
30
|
+
},
|
|
31
|
+
imageSize: {
|
|
32
|
+
title: 'Image size',
|
|
33
|
+
choices: [
|
|
34
|
+
['mini', 'Mini'],
|
|
35
|
+
['tile', 'Tile'],
|
|
36
|
+
['tiny', 'Tiny'],
|
|
37
|
+
['small', 'Small'],
|
|
38
|
+
['large', 'Large'],
|
|
39
|
+
['big', 'Big'],
|
|
40
|
+
['huge', 'Huge'],
|
|
41
|
+
['massive', 'Massive'],
|
|
42
|
+
],
|
|
43
|
+
default: 'tile',
|
|
44
|
+
},
|
|
45
|
+
icon: {
|
|
46
|
+
title: 'Icon name',
|
|
47
|
+
},
|
|
48
|
+
iconSize: {
|
|
49
|
+
title: 'Icon size',
|
|
50
|
+
choices: [
|
|
51
|
+
['mini', 'Mini'],
|
|
52
|
+
['tiny', 'Tiny'],
|
|
53
|
+
['small', 'Small'],
|
|
54
|
+
['large', 'Large'],
|
|
55
|
+
['big', 'Big'],
|
|
56
|
+
['huge', 'Huge'],
|
|
57
|
+
['massive', 'Massive'],
|
|
58
|
+
],
|
|
59
|
+
default: 'huge',
|
|
60
|
+
},
|
|
61
|
+
iconTheme: {
|
|
62
|
+
title: 'Icon theme',
|
|
63
|
+
choices: [
|
|
64
|
+
['primary', 'Primary'],
|
|
65
|
+
['secondary', 'Secondary'],
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
required: [],
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const stylingSchema = ({ intl }) => ({
|
|
74
|
+
title: 'Item style',
|
|
75
|
+
block: 'item',
|
|
76
|
+
fieldsets: [
|
|
77
|
+
{
|
|
78
|
+
id: 'default',
|
|
79
|
+
title: 'Default',
|
|
80
|
+
fields: ['theme', 'verticalAlign'],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
properties: {
|
|
84
|
+
theme: {
|
|
85
|
+
title: 'Theme',
|
|
86
|
+
choices: [
|
|
87
|
+
['primary', 'Primary'],
|
|
88
|
+
['secondary', 'Secondary'],
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
verticalAlign: {
|
|
92
|
+
title: 'Vertical align',
|
|
93
|
+
choices: [
|
|
94
|
+
['top', 'Top'],
|
|
95
|
+
['middle', 'Middle'],
|
|
96
|
+
['bottom', 'Bottom'],
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: [],
|
|
101
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Message } from 'semantic-ui-react';
|
|
4
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
5
|
+
import imageBlockSVG from '@plone/volto/components/manage/Blocks/Image/block-image.svg';
|
|
6
|
+
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
7
|
+
import { getTeaserImageURL } from './utils';
|
|
8
|
+
import { MaybeWrap } from '@plone/volto/components';
|
|
9
|
+
import { UniversalLink } from '@plone/volto/components';
|
|
10
|
+
import cx from 'classnames';
|
|
11
|
+
|
|
12
|
+
const messages = defineMessages({
|
|
13
|
+
PleaseChooseContent: {
|
|
14
|
+
id: 'Please choose an existing content as source for this element',
|
|
15
|
+
defaultMessage:
|
|
16
|
+
'Please choose an existing content as source for this element',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const TeaserCardTemplate = (props) => {
|
|
21
|
+
const { data, isEditMode } = props;
|
|
22
|
+
const intl = useIntl();
|
|
23
|
+
const href = data.href?.[0];
|
|
24
|
+
const image = data.preview_image?.[0];
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
{!href && isEditMode && (
|
|
29
|
+
<Message>
|
|
30
|
+
<div className="grid-teaser-item placeholder">
|
|
31
|
+
<img src={imageBlockSVG} alt="" />
|
|
32
|
+
<p>{intl.formatMessage(messages.PleaseChooseContent)}</p>
|
|
33
|
+
</div>
|
|
34
|
+
</Message>
|
|
35
|
+
)}
|
|
36
|
+
{href && (
|
|
37
|
+
<MaybeWrap
|
|
38
|
+
condition={!isEditMode}
|
|
39
|
+
as={UniversalLink}
|
|
40
|
+
href={href['@id']}
|
|
41
|
+
target={data.openLinkInNewTab ? '_blank' : null}
|
|
42
|
+
>
|
|
43
|
+
<div className={cx('ui fluid card', data?.styles?.theme)}>
|
|
44
|
+
{(href.hasPreviewImage || href.image_field || image) && (
|
|
45
|
+
<div className="image">
|
|
46
|
+
<img
|
|
47
|
+
src={flattenToAppURL(getTeaserImageURL(href, image))}
|
|
48
|
+
alt="a"
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
)}
|
|
52
|
+
<div className="content">
|
|
53
|
+
{data?.head_title && (
|
|
54
|
+
<div className="meta">{data?.head_title}</div>
|
|
55
|
+
)}
|
|
56
|
+
<div className="header">{data?.title}</div>
|
|
57
|
+
{!data.hide_description && (
|
|
58
|
+
<p className="description">{data?.description}</p>
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</MaybeWrap>
|
|
63
|
+
)}
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
TeaserCardTemplate.propTypes = {
|
|
69
|
+
data: PropTypes.objectOf(PropTypes.any).isRequired,
|
|
70
|
+
isEditMode: PropTypes.bool,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default TeaserCardTemplate;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
Type: {
|
|
5
|
+
id: 'Teaser',
|
|
6
|
+
defaultMessage: 'Teaser',
|
|
7
|
+
},
|
|
8
|
+
Theme: {
|
|
9
|
+
id: 'Theme',
|
|
10
|
+
defaultMessage: 'Theme',
|
|
11
|
+
},
|
|
12
|
+
ThemeHelp: {
|
|
13
|
+
id: 'Theme',
|
|
14
|
+
defaultMessage: 'Theme',
|
|
15
|
+
},
|
|
16
|
+
ThemeDefault: {
|
|
17
|
+
id: 'Default',
|
|
18
|
+
defaultMessage: 'Default',
|
|
19
|
+
},
|
|
20
|
+
ThemePrimary: {
|
|
21
|
+
id: 'Primary',
|
|
22
|
+
defaultMessage: 'Primary',
|
|
23
|
+
},
|
|
24
|
+
ThemeSecondary: {
|
|
25
|
+
id: 'Secondary',
|
|
26
|
+
defaultMessage: 'Secondary',
|
|
27
|
+
},
|
|
28
|
+
ThemeTertiary: {
|
|
29
|
+
id: 'Tertiary',
|
|
30
|
+
defaultMessage: 'Tertiary',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const StylingSchema = ({ intl }) => ({
|
|
35
|
+
title: intl.formatMessage(messages.Type),
|
|
36
|
+
block: 'teaserGrid',
|
|
37
|
+
fieldsets: [
|
|
38
|
+
{
|
|
39
|
+
id: 'default',
|
|
40
|
+
title: 'Default',
|
|
41
|
+
fields: ['theme'],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
properties: {
|
|
45
|
+
theme: {
|
|
46
|
+
title: intl.formatMessage(messages.Theme),
|
|
47
|
+
description: intl.formatMessage(messages.ThemeHelp),
|
|
48
|
+
choices: [
|
|
49
|
+
['', intl.formatMessage(messages.ThemeDefault)],
|
|
50
|
+
['primary', intl.formatMessage(messages.ThemePrimary)],
|
|
51
|
+
['secondary', intl.formatMessage(messages.ThemeSecondary)],
|
|
52
|
+
['tertiary', intl.formatMessage(messages.ThemeTertiary)],
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
required: [],
|
|
57
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import TeaserCardTemplate from './Card';
|
|
2
|
+
import { StylingSchema } from './Schema';
|
|
3
|
+
|
|
4
|
+
export default (config) => {
|
|
5
|
+
// Teaser
|
|
6
|
+
if (config.blocks.blocksConfig.teaser) {
|
|
7
|
+
config.blocks.blocksConfig.teaser.variations = [
|
|
8
|
+
...(config.blocks.blocksConfig.teaser.variations || []),
|
|
9
|
+
{
|
|
10
|
+
id: 'card',
|
|
11
|
+
isDefault: true,
|
|
12
|
+
title: 'Card (top image)',
|
|
13
|
+
template: TeaserCardTemplate,
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
config.blocks.blocksConfig.teaser.enableStyling = true;
|
|
17
|
+
config.blocks.blocksConfig.teaser.stylesSchema = StylingSchema;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Teaser Grid
|
|
21
|
+
if (config.blocks.blocksConfig.teaserGrid) {
|
|
22
|
+
config.blocks.blocksConfig.teaserGrid.title = 'Teaser (Cards)';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return config;
|
|
26
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isInternalURL } from '@plone/volto/helpers';
|
|
2
|
+
import config from '@plone/volto/registry';
|
|
3
|
+
|
|
4
|
+
export function getTeaserImageURL(href, image) {
|
|
5
|
+
const imageScale =
|
|
6
|
+
config.blocks.blocksConfig['teaser'].imageScale || 'preview';
|
|
7
|
+
if (image) {
|
|
8
|
+
if (isInternalURL(image['@id'])) {
|
|
9
|
+
return `${image['@id']}/@@images/image/${imageScale}`;
|
|
10
|
+
} else {
|
|
11
|
+
return image['@id'];
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
return `${href['@id']}/@@images/${
|
|
15
|
+
href.image_field || 'preview_image'
|
|
16
|
+
}/${imageScale}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/helpers.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isArray } from 'lodash';
|
|
2
|
+
import config from '@plone/volto/registry';
|
|
3
|
+
import { serializeNodes } from 'volto-slate/editor/render';
|
|
4
|
+
|
|
5
|
+
export const createSlateParagraph = (text) => {
|
|
6
|
+
return isArray(text) ? text : config.settings.slate.defaultValue();
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const serializeText = (text) => {
|
|
10
|
+
return isArray(text) ? serializeNodes(text) : text;
|
|
11
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { runtimeConfig } from '@plone/volto/runtime_config';
|
|
2
|
+
import installCallout from 'volto-slate/editor/plugins/Callout';
|
|
3
|
+
import installItemBlock from '@eeacms/volto-eea-website-policy/components/Blocks/Item';
|
|
4
|
+
import customizeTeaserBlock from '@eeacms/volto-eea-website-policy/components/Blocks/Teaser';
|
|
2
5
|
|
|
3
6
|
const applyConfig = (config) => {
|
|
4
7
|
// if (process.env.NODE_ENV === 'production') {
|
|
@@ -7,6 +10,13 @@ const applyConfig = (config) => {
|
|
|
7
10
|
// // Restrict slate metadata mentions to Layout only
|
|
8
11
|
// config.settings.layoutOnlySlateMetadataMentions = true;
|
|
9
12
|
// }
|
|
13
|
+
// Callout slate button
|
|
14
|
+
config = installCallout(config);
|
|
15
|
+
|
|
16
|
+
// Remove blockquote slate button
|
|
17
|
+
config.settings.slate.toolbarButtons = config.settings.slate.toolbarButtons.filter(
|
|
18
|
+
(item) => item !== 'blockquote',
|
|
19
|
+
);
|
|
10
20
|
|
|
11
21
|
// Disable tags on View
|
|
12
22
|
config.settings.showTags = false;
|
|
@@ -53,6 +63,48 @@ const applyConfig = (config) => {
|
|
|
53
63
|
(item) => item.code,
|
|
54
64
|
) || ['en'];
|
|
55
65
|
|
|
66
|
+
// Block chooser
|
|
67
|
+
config.blocks.blocksConfig.image.mostUsed = false;
|
|
68
|
+
config.blocks.blocksConfig.video.mostUsed = false;
|
|
69
|
+
|
|
70
|
+
// Grid/Teaser block (kitconcept)
|
|
71
|
+
if (config.blocks.blocksConfig.__grid) {
|
|
72
|
+
config.blocks.blocksConfig.__grid.restricted = true;
|
|
73
|
+
}
|
|
74
|
+
if (config.blocks.blocksConfig.imagesGrid) {
|
|
75
|
+
config.blocks.blocksConfig.imagesGrid.restricted = true;
|
|
76
|
+
}
|
|
77
|
+
if (config.blocks.blocksConfig.teaser) {
|
|
78
|
+
config.blocks.blocksConfig.teaser.restricted = true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Divider
|
|
82
|
+
if (config.blocks.blocksConfig.dividerBlock) {
|
|
83
|
+
config.blocks.blocksConfig.dividerBlock.mostUsed = true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Call to Action
|
|
87
|
+
if (config.blocks.blocksConfig.callToActionBlock) {
|
|
88
|
+
config.blocks.blocksConfig.callToActionBlock.mostUsed = true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Columns
|
|
92
|
+
if (config.blocks.blocksConfig.columnsBlock) {
|
|
93
|
+
config.blocks.blocksConfig.columnsBlock.mostUsed = true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Listing
|
|
97
|
+
if (config.blocks.blocksConfig.listing) {
|
|
98
|
+
config.blocks.blocksConfig.listing.title = 'Listing (Content)';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Custom blocks
|
|
102
|
+
config = [installItemBlock, customizeTeaserBlock].reduce(
|
|
103
|
+
(acc, apply) => apply(acc),
|
|
104
|
+
config,
|
|
105
|
+
);
|
|
106
|
+
config.blocks.blocksConfig.item.mostUsed = true;
|
|
107
|
+
|
|
56
108
|
// Done
|
|
57
109
|
return config;
|
|
58
110
|
};
|