@eeacms/volto-embed 7.0.2 → 8.0.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/locales/volto.pot CHANGED
@@ -1,7 +1,7 @@
1
1
  msgid ""
2
2
  msgstr ""
3
3
  "Project-Id-Version: Plone\n"
4
- "POT-Creation-Date: 2023-08-29T17:13:33.263Z\n"
4
+ "POT-Creation-Date: 2023-11-15T18:20:32.637Z\n"
5
5
  "Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
6
6
  "Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
7
7
  "MIME-Version: 1.0\n"
@@ -13,37 +13,70 @@ msgstr ""
13
13
  "Preferred-Encodings: utf-8\n"
14
14
  "Domain: volto\n"
15
15
 
16
- #: Iframe/EditIframe
16
+ #: Blocks/EmbedMaps/schema
17
+ #: Blocks/Maps/schema
18
+ # defaultMessage: Alignment
19
+ msgid "Alignment"
20
+ msgstr ""
21
+
22
+ #: Blocks/EmbedMaps/schema
23
+ #: Blocks/Maps/schema
24
+ # defaultMessage: Alt text
25
+ msgid "Alt text"
26
+ msgstr ""
27
+
28
+ #: Blocks/EmbedMaps/schema
29
+ #: Blocks/Maps/schema
30
+ # defaultMessage: undefined
31
+ msgid "CSSHeight"
32
+ msgstr ""
33
+
34
+ #: Blocks/EmbedMaps/schema
35
+ #: Blocks/Maps/schema
36
+ # defaultMessage: undefined
37
+ msgid "CSSHeightDescription"
38
+ msgstr ""
39
+
40
+ #: Blocks/EmbedMaps/Edit
41
+ #: Blocks/Maps/Edit
17
42
  # defaultMessage: Center
18
43
  msgid "Center"
19
44
  msgstr ""
20
45
 
21
- #: Iframe/EditIframe
46
+ #: Blocks/EmbedMaps/Edit
47
+ #: Blocks/Maps/Edit
48
+ #: Widgets/MapsWidget
22
49
  # defaultMessage: Embed code error, please follow the instructions and try again.
23
50
  msgid "Embed code error, please follow the instructions and try again."
24
51
  msgstr ""
25
52
 
26
- #: Iframe/ViewIframe
53
+ #: Blocks/EmbedMaps/View
54
+ #: Blocks/Maps/View
55
+ #: Map/Map
27
56
  # defaultMessage: Embeded Google Maps
28
57
  msgid "Embeded Google Maps"
29
58
  msgstr ""
30
59
 
31
- #: Iframe/EditIframe
60
+ #: Blocks/EmbedMaps/Edit
61
+ #: Blocks/Maps/Edit
32
62
  # defaultMessage: Enter map Embed Code
33
63
  msgid "Enter map Embed Code"
34
64
  msgstr ""
35
65
 
36
- #: Iframe/EditIframe
66
+ #: Blocks/EmbedMaps/Edit
67
+ #: Blocks/Maps/Edit
37
68
  # defaultMessage: Full
38
69
  msgid "Full"
39
70
  msgstr ""
40
71
 
41
- #: Iframe/EditIframe
72
+ #: Blocks/EmbedMaps/Edit
73
+ #: Blocks/Maps/Edit
42
74
  # defaultMessage: Google Maps Embedded Block
43
75
  msgid "Google Maps Embedded Block"
44
76
  msgstr ""
45
77
 
46
- #: Iframe/EditIframe
78
+ #: Blocks/EmbedMaps/Edit
79
+ #: Blocks/Maps/Edit
47
80
  # defaultMessage: Left
48
81
  msgid "Left"
49
82
  msgstr ""
@@ -53,12 +86,35 @@ msgstr ""
53
86
  msgid "Live image generated"
54
87
  msgstr ""
55
88
 
56
- #: Iframe/EditIframe
89
+ #: Blocks/EmbedMaps/MapsSidebar
90
+ #: Blocks/EmbedMaps/schema
91
+ #: Blocks/Maps/MapsSidebar
92
+ #: Blocks/Maps/schema
93
+ # defaultMessage: Maps
94
+ msgid "Maps"
95
+ msgstr ""
96
+
97
+ #: Blocks/EmbedMaps/schema
98
+ #: Blocks/Maps/schema
99
+ # defaultMessage: Maps URL
100
+ msgid "Maps URL"
101
+ msgstr ""
102
+
103
+ #: Blocks/EmbedMaps/MapsSidebar
104
+ #: Blocks/Maps/MapsSidebar
105
+ # defaultMessage: No map selected
106
+ msgid "No map selected"
107
+ msgstr ""
108
+
109
+ #: Blocks/EmbedMaps/Edit
110
+ #: Blocks/Maps/Edit
111
+ #: Widgets/MapsWidget
57
112
  # defaultMessage: Please enter the Embed Code provided by Google Maps -> Share -> Embed map. It should contain the <iframe> code on it.
58
113
  msgid "Please enter the Embed Code provided by Google Maps -> Share -> Embed map. It should contain the <iframe> code on it."
59
114
  msgstr ""
60
115
 
61
- #: Iframe/EditIframe
116
+ #: Blocks/EmbedMaps/Edit
117
+ #: Blocks/Maps/Edit
62
118
  # defaultMessage: Right
63
119
  msgid "Right"
64
120
  msgstr ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-embed",
3
- "version": "7.0.2",
3
+ "version": "8.0.0",
4
4
  "description": "Embed external content",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
3
+ import { SidebarPortal } from '@plone/volto/components';
4
+ import View from './View';
5
+ import getSchema from './schema';
6
+
7
+ const Edit = (props) => {
8
+ const schema = React.useMemo(() => getSchema(props), [props]);
9
+
10
+ return (
11
+ <React.Fragment>
12
+ <View {...props} mode="edit" />
13
+ <SidebarPortal selected={props.selected}>
14
+ <BlockDataForm
15
+ block={props.block}
16
+ schema={schema}
17
+ title={schema.title}
18
+ onChangeField={(id, value) => {
19
+ props.onChangeBlock(props.block, {
20
+ ...props.data,
21
+ [id]: value,
22
+ });
23
+ }}
24
+ formData={props.data}
25
+ />
26
+ </SidebarPortal>
27
+ </React.Fragment>
28
+ );
29
+ };
30
+
31
+ export default Edit;
@@ -0,0 +1,76 @@
1
+ import React, { useEffect, useMemo } from 'react';
2
+ import { connect } from 'react-redux';
3
+ import { Message } from 'semantic-ui-react';
4
+ import { flattenToAppURL } from '@plone/volto/helpers';
5
+ import Map from '@eeacms/volto-embed/Map/Map';
6
+
7
+ import { getContent } from '@plone/volto/actions';
8
+
9
+ function View(props) {
10
+ const {
11
+ url,
12
+ with_notes = true,
13
+ with_sources = true,
14
+ with_more_info = true,
15
+ with_share = true,
16
+ with_enlarge = true,
17
+ } = props.data;
18
+
19
+ const maps = useMemo(() => {
20
+ if (props.data.maps) {
21
+ return props.data.maps;
22
+ }
23
+ if (props.mapsContent?.maps) {
24
+ return {
25
+ ...props.mapsContent.maps,
26
+ '@id': props.mapsContent['@id'],
27
+ title: props.mapsContent['title'],
28
+ publisher: props.mapsContent['publisher'],
29
+ geo_coverage: props.mapsContent['geo_coverage'],
30
+ temporal_coverage: props.mapsContent['temporal_coverage'],
31
+ other_organisations: props.mapsContent['other_organisations'],
32
+ data_provenance: props.mapsContent['data_provenance'],
33
+ figure_note: props.mapsContent['figure_note'],
34
+ };
35
+ }
36
+ return undefined;
37
+ }, [props.data.maps, props.mapsContent]);
38
+
39
+ useEffect(() => {
40
+ if (props.data.url && !props.data.maps) {
41
+ props.getContent(flattenToAppURL(props.data.url), null, props.id);
42
+ }
43
+ /* eslint-disable-next-line */
44
+ }, [props.data.url]);
45
+
46
+ if (props.mode === 'edit' && !url) {
47
+ return <Message>Please select a map from block editor.</Message>;
48
+ }
49
+
50
+ if (!maps) {
51
+ return null;
52
+ }
53
+
54
+ return (
55
+ <div className="embed-map">
56
+ <Map
57
+ data={{
58
+ ...maps,
59
+ with_notes,
60
+ with_sources,
61
+ with_more_info,
62
+ with_share,
63
+ with_enlarge,
64
+ }}
65
+ id={props.id}
66
+ />
67
+ </div>
68
+ );
69
+ }
70
+
71
+ export default connect(
72
+ (state, props) => ({
73
+ mapsContent: state.content.subrequests?.[props.id]?.data,
74
+ }),
75
+ { getContent },
76
+ )(View);
@@ -0,0 +1,22 @@
1
+ import EmbedMap from './Edit';
2
+ import EmbedView from './View';
3
+
4
+ import sliderSVG from '@plone/volto/icons/slider.svg';
5
+
6
+ const embedConfig = (config) => {
7
+ config.blocks.blocksConfig.embed_maps = {
8
+ id: 'embed_maps',
9
+ title: 'Embed Map',
10
+ icon: sliderSVG,
11
+ group: 'common',
12
+ edit: EmbedMap,
13
+ view: EmbedView,
14
+ restricted: false,
15
+ mostUsed: false,
16
+ sidebarTab: 1,
17
+ };
18
+
19
+ return config;
20
+ };
21
+
22
+ export default embedConfig;
@@ -0,0 +1,62 @@
1
+ export default () => {
2
+ return {
3
+ title: 'Embed Map',
4
+ fieldsets: [
5
+ {
6
+ id: 'default',
7
+ title: 'Default',
8
+ fields: ['url'],
9
+ },
10
+ {
11
+ id: 'toolbar',
12
+ title: 'Toolbar',
13
+ fields: [
14
+ 'with_notes',
15
+ 'with_sources',
16
+ 'with_more_info',
17
+ 'with_share',
18
+ 'with_enlarge',
19
+ ],
20
+ },
21
+ ],
22
+ properties: {
23
+ url: {
24
+ title: 'Map url',
25
+ widget: 'url',
26
+ },
27
+ with_notes: {
28
+ title: 'Show note',
29
+ type: 'boolean',
30
+ defaultValue: true,
31
+ },
32
+ with_sources: {
33
+ title: 'Show sources',
34
+ description: 'Will show sources set in this page Data provenance',
35
+ type: 'boolean',
36
+ defaultValue: true,
37
+ },
38
+ with_more_info: {
39
+ title: 'Show more info',
40
+ type: 'boolean',
41
+ defaultValue: true,
42
+ },
43
+ with_enlarge: {
44
+ title: 'Show enlarge button',
45
+ type: 'boolean',
46
+ defaultValue: true,
47
+ },
48
+ with_share: {
49
+ title: 'Show share button',
50
+ type: 'boolean',
51
+ defaultValue: true,
52
+ },
53
+ tableau_height: {
54
+ title: 'Height',
55
+ type: 'text',
56
+ defaultValue: '700',
57
+ },
58
+ },
59
+
60
+ required: ['tableau_vis_url'],
61
+ };
62
+ };
@@ -1,67 +1,53 @@
1
1
  import { defineMessages } from 'react-intl';
2
2
 
3
3
  const messages = defineMessages({
4
- Maps: {
5
- id: 'Maps',
6
- defaultMessage: 'Maps',
7
- },
8
- AltText: {
9
- id: 'Alt text',
10
- defaultMessage: 'Alt text',
11
- },
12
- MapsURL: {
13
- id: 'Maps URL',
14
- defaultMessage: 'Maps URL',
15
- },
16
- Alignment: {
17
- id: 'Alignment',
18
- defaultMessage: 'Alignment',
19
- },
20
4
  CSSHeight: {
21
- id: 'CSSHeight',
5
+ id: 'CSS height',
22
6
  defineMessages: 'CSS height',
23
7
  },
24
8
  CSSHeightDescription: {
25
- id: 'CSSHeightDescription',
9
+ id: 'Iframe height',
26
10
  defineMessages: 'Iframe height',
27
11
  },
28
12
  });
29
13
 
30
- export const MapsSchema = (props) => ({
31
- title: props.intl.formatMessage(messages.Maps),
32
- block: 'Maps',
33
- fieldsets: [
34
- {
35
- id: 'default',
36
- title: 'Default',
37
- fields: ['url', 'title', 'align', 'height'],
38
- },
39
- ],
14
+ export const MapsSchema = (props) => {
15
+ return {
16
+ title: props.intl.messages['Maps'],
17
+ block: 'Maps',
18
+ fieldsets: [
19
+ {
20
+ id: 'default',
21
+ title: 'Default',
22
+ fields: ['url', 'title', 'align', 'height'],
23
+ },
24
+ ],
40
25
 
41
- properties: {
42
- url: {
43
- title: props.intl.formatMessage(messages.MapsURL),
44
- widget: 'url',
26
+ properties: {
27
+ url: {
28
+ title: props.intl.messages['Maps URL'],
29
+ widget: 'url',
30
+ },
31
+ title: {
32
+ title: props.intl.messages['Alt text'],
33
+ },
34
+ align: {
35
+ title: props.intl.messages['Alignment'],
36
+ widget: 'align',
37
+ },
38
+ height: {
39
+ title: (
40
+ <a
41
+ rel="noreferrer"
42
+ target="_blank"
43
+ href="https://developer.mozilla.org/en-US/docs/Web/CSS/height"
44
+ >
45
+ {props.intl.formatMessage(messages.CSSHeight)}
46
+ </a>
47
+ ),
48
+ description: props.intl.formatMessage(messages.CSSHeightDescription),
49
+ },
45
50
  },
46
- title: {
47
- title: props.intl.formatMessage(messages.AltText),
48
- },
49
- align: {
50
- title: props.intl.formatMessage(messages.Alignment),
51
- widget: 'align',
52
- },
53
- height: {
54
- title: (
55
- <a
56
- rel="noreferrer"
57
- target="_blank"
58
- href="https://developer.mozilla.org/en-US/docs/Web/CSS/height"
59
- >
60
- {props.intl.formatMessage(messages.CSSHeight)}
61
- </a>
62
- ),
63
- description: props.intl.formatMessage(messages.CSSHeightDescription),
64
- },
65
- },
66
- required: [],
67
- });
51
+ required: [],
52
+ };
53
+ };
@@ -1,5 +1,9 @@
1
1
  import installMaps from './Maps';
2
+ import installEmbedMaps from './EmbedMaps';
2
3
 
3
4
  export default function installBlocks(config) {
4
- return [installMaps].reduce((acc, apply) => apply(acc), config);
5
+ return [installMaps, installEmbedMaps].reduce(
6
+ (acc, apply) => apply(acc),
7
+ config,
8
+ );
5
9
  }
@@ -0,0 +1,101 @@
1
+ import React, { useEffect, useState, useRef } from 'react';
2
+ import { compose } from 'redux';
3
+ import { connect } from 'react-redux';
4
+ import { defineMessages, injectIntl } from 'react-intl';
5
+ import cx from 'classnames';
6
+ import {
7
+ FigureNote,
8
+ Sources,
9
+ MoreInfo,
10
+ Share,
11
+ Enlarge,
12
+ } from '@eeacms/volto-embed/Toolbar';
13
+ import PrivacyProtection from '@eeacms/volto-embed/PrivacyProtection/PrivacyProtection';
14
+
15
+ import './style.less';
16
+
17
+ const messages = defineMessages({
18
+ EmbededGoogleMaps: {
19
+ id: 'Embeded Google Maps',
20
+ defaultMessage: 'Embeded Google Maps',
21
+ },
22
+ });
23
+
24
+ function Map({ data, intl, id, screen }) {
25
+ const el = useRef();
26
+ const [mobile, setMobile] = useState(false);
27
+
28
+ useEffect(() => {
29
+ if (el.current) {
30
+ const visWidth = el.current.offsetWidth;
31
+
32
+ if (visWidth < 600 && !mobile) {
33
+ setMobile(true);
34
+ } else if (visWidth >= 600 && mobile) {
35
+ setMobile(false);
36
+ }
37
+ }
38
+ }, [screen, mobile]);
39
+
40
+ return (
41
+ <div
42
+ ref={el}
43
+ className={cx(
44
+ 'block maps align',
45
+ {
46
+ center: !Boolean(data.align),
47
+ },
48
+ data.align,
49
+ )}
50
+ >
51
+ <div
52
+ className={cx('maps-inner', {
53
+ 'full-width': data.align === 'full',
54
+ })}
55
+ >
56
+ <PrivacyProtection data={data} id={id} height={data.height}>
57
+ <iframe
58
+ title={intl.formatMessage(messages.EmbededGoogleMaps)}
59
+ src={data.url}
60
+ className="google-map"
61
+ frameBorder="0"
62
+ allowFullScreen
63
+ style={data.height ? { height: data.height } : {}}
64
+ />
65
+ </PrivacyProtection>
66
+ </div>
67
+ <div className={cx('visualization-toolbar', { mobile })}>
68
+ <div className="left-col">
69
+ {data.with_notes && <FigureNote note={data.figure_note || []} />}
70
+ {data.with_sources && <Sources sources={data.sources} />}
71
+ {data.with_more_info && <MoreInfo href={data['@id']} />}
72
+ </div>
73
+ <div className="right-col">
74
+ {data.with_enlarge && (
75
+ <Enlarge className="enlarge-embed-maps">
76
+ <Map
77
+ data={{
78
+ ...data,
79
+ height: '100%',
80
+ with_notes: false,
81
+ with_sources: false,
82
+ with_more_info: false,
83
+ with_share: false,
84
+ with_enlarge: false,
85
+ }}
86
+ id={id}
87
+ intl={intl}
88
+ />
89
+ </Enlarge>
90
+ )}
91
+ {data.with_share && <Share href={data['@id']} />}
92
+ </div>
93
+ </div>
94
+ </div>
95
+ );
96
+ }
97
+
98
+ export default compose(
99
+ injectIntl,
100
+ connect((state) => ({ screen: state.screen })),
101
+ )(Map);
@@ -0,0 +1,16 @@
1
+ .embed-map .block.maps .maps-inner {
2
+ margin-bottom: 1rem;
3
+ }
4
+
5
+ .ui.modal.enlarge-modal.enlarge-embed-maps {
6
+ .content,
7
+ .content .block.maps,
8
+ .content .block.maps .maps-inner {
9
+ height: 100%;
10
+ }
11
+
12
+ .close.icon {
13
+ top: 2rem;
14
+ right: 2rem;
15
+ }
16
+ }