@plone/volto 18.0.0-alpha.17 → 18.0.0-alpha.19
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 +48 -2
- package/locales/ca/LC_MESSAGES/volto.po +17 -42
- package/locales/ca.json +1 -1
- package/locales/de/LC_MESSAGES/volto.po +15 -40
- package/locales/de.json +1 -1
- package/locales/en/LC_MESSAGES/volto.po +14 -39
- package/locales/en.json +1 -1
- package/locales/es/LC_MESSAGES/volto.po +15 -40
- package/locales/es.json +1 -1
- package/locales/eu/LC_MESSAGES/volto.po +15 -40
- package/locales/eu.json +1 -1
- package/locales/fi/LC_MESSAGES/volto.po +15 -40
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +15 -40
- package/locales/fr.json +1 -1
- package/locales/it/LC_MESSAGES/volto.po +15 -40
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +15 -40
- package/locales/ja.json +1 -1
- package/locales/nl/LC_MESSAGES/volto.po +14 -39
- package/locales/nl.json +1 -1
- package/locales/pt/LC_MESSAGES/volto.po +15 -40
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +15 -40
- package/locales/pt_BR.json +1 -1
- package/locales/ro/LC_MESSAGES/volto.po +15 -40
- package/locales/ro.json +1 -1
- package/locales/volto.pot +15 -40
- package/locales/zh_CN/LC_MESSAGES/volto.po +15 -40
- package/locales/zh_CN.json +1 -1
- package/package.json +11 -21
- package/src/components/index.js +0 -6
- package/src/components/manage/Add/Add.jsx +1 -1
- package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +8 -2
- package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +2 -2
- package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.jsx +33 -5
- package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.test.jsx +12 -0
- package/src/components/manage/Controlpanels/Groups/RenderGroups.jsx +22 -11
- package/src/components/manage/Controlpanels/Groups/RenderGroups.test.jsx +21 -0
- package/src/components/manage/Controlpanels/Users/RenderUsers.jsx +30 -21
- package/src/components/manage/Controlpanels/Users/RenderUsers.test.jsx +27 -1
- package/src/components/manage/Controlpanels/Users/UserGroupMembershipListing.jsx +29 -7
- package/src/components/manage/Controlpanels/Users/UsersControlpanel.jsx +51 -3
- package/src/components/manage/Controlpanels/Users/UsersControlpanel.test.jsx +8 -0
- package/src/components/manage/Form/Form.jsx +1 -1
- package/src/components/theme/SlotRenderer/SlotRenderer.tsx +8 -1
- package/src/config/Blocks.jsx +63 -67
- package/src/config/Loadables.jsx +0 -22
- package/src/config/Widgets.jsx +0 -2
- package/src/config/index.js +0 -13
- package/src/helpers/User/User.js +29 -0
- package/src/helpers/index.js +6 -1
- package/test-setup-config.js +0 -30
- package/types/components/index.d.ts +0 -6
- package/types/config/Blocks.d.ts +0 -51
- package/types/config/Loadables.d.ts +0 -10
- package/types/config/Widgets.d.ts +0 -2
- package/types/helpers/User/User.d.ts +18 -0
- package/types/helpers/index.d.ts +1 -1
- package/webpack-plugins/webpack-bundle-analyze-plugin.js +1 -1
- package/src/components/manage/AnchorPlugin/components/Link/index.jsx +0 -37
- package/src/components/manage/AnchorPlugin/components/LinkButton/index.jsx +0 -126
- package/src/components/manage/AnchorPlugin/index.jsx +0 -82
- package/src/components/manage/AnchorPlugin/linkStrategy.js +0 -21
- package/src/components/manage/AnchorPlugin/utils/EditorUtils.js +0 -47
- package/src/components/manage/Blocks/HeroImageLeft/Data.jsx +0 -29
- package/src/components/manage/Blocks/HeroImageLeft/Edit.jsx +0 -493
- package/src/components/manage/Blocks/HeroImageLeft/Edit.test.jsx +0 -58
- package/src/components/manage/Blocks/HeroImageLeft/View.jsx +0 -37
- package/src/components/manage/Blocks/HeroImageLeft/View.test.jsx +0 -9
- package/src/components/manage/Blocks/HeroImageLeft/schema.js +0 -43
- package/src/components/manage/Blocks/Table/Cell.jsx +0 -206
- package/src/components/manage/Blocks/Table/Cell.test.jsx +0 -19
- package/src/components/manage/Blocks/Table/Edit.jsx +0 -748
- package/src/components/manage/Blocks/Table/Edit.test.jsx +0 -44
- package/src/components/manage/Blocks/Table/Readme.md +0 -5
- package/src/components/manage/Blocks/Table/View.jsx +0 -51
- package/src/components/manage/Blocks/Table/View.test.jsx +0 -41
- package/src/components/manage/Blocks/Text/Edit.jsx +0 -372
- package/src/components/manage/Blocks/Text/Edit.test.jsx +0 -46
- package/src/components/manage/Blocks/Text/Readme.md +0 -5
- package/src/components/manage/Blocks/Text/Schema.jsx +0 -31
- package/src/components/manage/Blocks/Text/View.jsx +0 -26
- package/src/components/manage/Blocks/Text/View.test.jsx +0 -28
- package/src/components/manage/LinkDetectionPlugin/link-detection-plugin.jsx +0 -227
- package/src/components/manage/LinkDetectionPlugin/utils.js +0 -12
- package/src/components/manage/Widgets/WysiwygWidget.jsx +0 -350
- package/src/components/manage/Widgets/WysiwygWidget.stories.jsx +0 -24
- package/src/components/manage/Widgets/WysiwygWidget.test.jsx +0 -37
- package/src/config/RichTextEditor/Blocks.jsx +0 -29
- package/src/config/RichTextEditor/FromHTML.jsx +0 -8
- package/src/config/RichTextEditor/Plugins.jsx +0 -59
- package/src/config/RichTextEditor/Styles.jsx +0 -69
- package/src/config/RichTextEditor/ToHTML.jsx +0 -262
- package/src/config/RichTextEditor/index.js +0 -25
|
@@ -1,493 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Edit Hero block.
|
|
3
|
-
* @module components/manage/Blocks/Image/Edit
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React, { Component } from 'react';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
|
-
import { connect } from 'react-redux';
|
|
9
|
-
import { compose } from 'redux';
|
|
10
|
-
import { readAsDataURL } from 'promise-file-reader';
|
|
11
|
-
import { Button, Dimmer, Loader, Message } from 'semantic-ui-react';
|
|
12
|
-
import { isEqual } from 'lodash';
|
|
13
|
-
import { defineMessages, injectIntl } from 'react-intl';
|
|
14
|
-
import cx from 'classnames';
|
|
15
|
-
|
|
16
|
-
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
|
|
17
|
-
import {
|
|
18
|
-
flattenToAppURL,
|
|
19
|
-
getBaseUrl,
|
|
20
|
-
validateFileUploadSize,
|
|
21
|
-
} from '@plone/volto/helpers';
|
|
22
|
-
import { createContent } from '@plone/volto/actions';
|
|
23
|
-
import { Icon, SidebarPortal, LinkMore } from '@plone/volto/components';
|
|
24
|
-
|
|
25
|
-
import clearSVG from '@plone/volto/icons/clear.svg';
|
|
26
|
-
|
|
27
|
-
import Data from './Data';
|
|
28
|
-
|
|
29
|
-
const messages = defineMessages({
|
|
30
|
-
title: {
|
|
31
|
-
id: 'Title',
|
|
32
|
-
defaultMessage: 'Title',
|
|
33
|
-
},
|
|
34
|
-
description: {
|
|
35
|
-
id: 'Description',
|
|
36
|
-
defaultMessage: 'Description',
|
|
37
|
-
},
|
|
38
|
-
placeholder: {
|
|
39
|
-
id: 'Upload a new image',
|
|
40
|
-
defaultMessage: 'Upload a new image',
|
|
41
|
-
},
|
|
42
|
-
image: {
|
|
43
|
-
id: 'Image',
|
|
44
|
-
defaultMessage: 'Image',
|
|
45
|
-
},
|
|
46
|
-
browse: {
|
|
47
|
-
id: 'Browse',
|
|
48
|
-
defaultMessage: 'Browse',
|
|
49
|
-
},
|
|
50
|
-
uploading: {
|
|
51
|
-
id: 'Uploading image',
|
|
52
|
-
defaultMessage: 'Uploading image',
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Edit image block class.
|
|
58
|
-
* @class Edit
|
|
59
|
-
* @extends Component
|
|
60
|
-
*/
|
|
61
|
-
class EditComponent extends Component {
|
|
62
|
-
/**
|
|
63
|
-
* Property types.
|
|
64
|
-
* @property {Object} propTypes Property types.
|
|
65
|
-
* @static
|
|
66
|
-
*/
|
|
67
|
-
static propTypes = {
|
|
68
|
-
selected: PropTypes.bool.isRequired,
|
|
69
|
-
block: PropTypes.string.isRequired,
|
|
70
|
-
index: PropTypes.number.isRequired,
|
|
71
|
-
data: PropTypes.objectOf(PropTypes.any).isRequired,
|
|
72
|
-
content: PropTypes.objectOf(PropTypes.any),
|
|
73
|
-
request: PropTypes.shape({
|
|
74
|
-
loading: PropTypes.bool,
|
|
75
|
-
loaded: PropTypes.bool,
|
|
76
|
-
}).isRequired,
|
|
77
|
-
pathname: PropTypes.string.isRequired,
|
|
78
|
-
onChangeBlock: PropTypes.func.isRequired,
|
|
79
|
-
onSelectBlock: PropTypes.func.isRequired,
|
|
80
|
-
onDeleteBlock: PropTypes.func.isRequired,
|
|
81
|
-
onFocusPreviousBlock: PropTypes.func.isRequired,
|
|
82
|
-
onFocusNextBlock: PropTypes.func.isRequired,
|
|
83
|
-
handleKeyDown: PropTypes.func.isRequired,
|
|
84
|
-
createContent: PropTypes.func.isRequired,
|
|
85
|
-
editable: PropTypes.bool,
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Default properties
|
|
90
|
-
* @property {Object} defaultProps Default properties.
|
|
91
|
-
* @static
|
|
92
|
-
*/
|
|
93
|
-
static defaultProps = {
|
|
94
|
-
editable: true,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Constructor
|
|
99
|
-
* @method constructor
|
|
100
|
-
* @param {Object} props Component properties
|
|
101
|
-
* @constructs WysiwygEditor
|
|
102
|
-
*/
|
|
103
|
-
constructor(props) {
|
|
104
|
-
super(props);
|
|
105
|
-
|
|
106
|
-
this.onUploadImage = this.onUploadImage.bind(this);
|
|
107
|
-
this.state = {
|
|
108
|
-
uploading: false,
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const { Map } = this.props.immutableLib;
|
|
112
|
-
|
|
113
|
-
if (!__SERVER__) {
|
|
114
|
-
const { DefaultDraftBlockRenderMap, EditorState } = props.draftJs;
|
|
115
|
-
const { stateFromHTML } = props.draftJsImportHtml;
|
|
116
|
-
|
|
117
|
-
const blockTitleRenderMap = Map({
|
|
118
|
-
unstyled: {
|
|
119
|
-
element: 'h1',
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
const blockDescriptionRenderMap = Map({
|
|
124
|
-
unstyled: {
|
|
125
|
-
element: 'div',
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
this.extendedBlockRenderMap =
|
|
130
|
-
DefaultDraftBlockRenderMap.merge(blockTitleRenderMap);
|
|
131
|
-
|
|
132
|
-
this.extendedDescripBlockRenderMap = DefaultDraftBlockRenderMap.merge(
|
|
133
|
-
blockDescriptionRenderMap,
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
let titleEditorState;
|
|
137
|
-
let descriptionEditorState;
|
|
138
|
-
if (props.data && props.data.title) {
|
|
139
|
-
titleEditorState = EditorState.createWithContent(
|
|
140
|
-
stateFromHTML(props.data.title),
|
|
141
|
-
);
|
|
142
|
-
} else {
|
|
143
|
-
titleEditorState = EditorState.createEmpty();
|
|
144
|
-
}
|
|
145
|
-
if (props.data && props.data.description) {
|
|
146
|
-
descriptionEditorState = EditorState.createWithContent(
|
|
147
|
-
stateFromHTML(props.data.description),
|
|
148
|
-
);
|
|
149
|
-
} else {
|
|
150
|
-
descriptionEditorState = EditorState.createEmpty();
|
|
151
|
-
}
|
|
152
|
-
this.state = {
|
|
153
|
-
uploading: false,
|
|
154
|
-
titleEditorState,
|
|
155
|
-
descriptionEditorState,
|
|
156
|
-
currentFocused: 'title',
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
this.onChangeTitle = this.onChangeTitle.bind(this);
|
|
161
|
-
this.onChangeDescription = this.onChangeDescription.bind(this);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Component did mount
|
|
166
|
-
* @method componentDidMount
|
|
167
|
-
* @returns {undefined}
|
|
168
|
-
*/
|
|
169
|
-
componentDidMount() {
|
|
170
|
-
if (this.props.selected) {
|
|
171
|
-
this.titleEditor.focus();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Component will receive props
|
|
177
|
-
* @method componentWillReceiveProps
|
|
178
|
-
* @param {Object} nextProps Next properties
|
|
179
|
-
* @returns {undefined}
|
|
180
|
-
*/
|
|
181
|
-
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
182
|
-
if (
|
|
183
|
-
this.props.request.loading &&
|
|
184
|
-
nextProps.request.loaded &&
|
|
185
|
-
this.state.uploading
|
|
186
|
-
) {
|
|
187
|
-
this.setState({
|
|
188
|
-
uploading: false,
|
|
189
|
-
});
|
|
190
|
-
this.props.onChangeBlock(this.props.block, {
|
|
191
|
-
...this.props.data,
|
|
192
|
-
url: nextProps.content['@id'],
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const { EditorState } = this.props.draftJs;
|
|
197
|
-
const { stateFromHTML } = this.props.draftJsImportHtml;
|
|
198
|
-
|
|
199
|
-
if (
|
|
200
|
-
nextProps.data.title &&
|
|
201
|
-
this.props.data.title !== nextProps.data.title &&
|
|
202
|
-
!this.props.selected
|
|
203
|
-
) {
|
|
204
|
-
const contentState = stateFromHTML(nextProps.data.title);
|
|
205
|
-
this.setState({
|
|
206
|
-
titleEditorState: nextProps.data.title
|
|
207
|
-
? EditorState.createWithContent(contentState)
|
|
208
|
-
: EditorState.createEmpty(),
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (
|
|
213
|
-
nextProps.data.description &&
|
|
214
|
-
this.props.data.description !== nextProps.data.description &&
|
|
215
|
-
!this.props.selected
|
|
216
|
-
) {
|
|
217
|
-
const contentState = stateFromHTML(nextProps.data.description);
|
|
218
|
-
this.setState({
|
|
219
|
-
descriptionEditorState: nextProps.data.description
|
|
220
|
-
? EditorState.createWithContent(contentState)
|
|
221
|
-
: EditorState.createEmpty(),
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (nextProps.selected !== this.props.selected) {
|
|
226
|
-
if (this.state.currentFocused === 'title') {
|
|
227
|
-
this.titleEditor.focus();
|
|
228
|
-
} else {
|
|
229
|
-
this.descriptionEditor.focus();
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* @param {*} nextProps
|
|
236
|
-
* @param {*} nextState
|
|
237
|
-
* @returns {boolean}
|
|
238
|
-
* @memberof Edit
|
|
239
|
-
*/
|
|
240
|
-
shouldComponentUpdate(nextProps) {
|
|
241
|
-
return this.props.selected || !isEqual(this.props.data, nextProps.data);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Change Title handler
|
|
246
|
-
* @method onChangeTitle
|
|
247
|
-
* @param {object} titleEditorState Editor state.
|
|
248
|
-
* @returns {undefined}
|
|
249
|
-
*/
|
|
250
|
-
onChangeTitle(titleEditorState) {
|
|
251
|
-
this.setState({ titleEditorState }, () => {
|
|
252
|
-
this.props.onChangeBlock(this.props.block, {
|
|
253
|
-
...this.props.data,
|
|
254
|
-
title: titleEditorState.getCurrentContent().getPlainText(),
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Change Description handler
|
|
261
|
-
* @method onChangeDescription
|
|
262
|
-
* @param {object} descriptionEditorState Editor state.
|
|
263
|
-
* @returns {undefined}
|
|
264
|
-
*/
|
|
265
|
-
onChangeDescription(descriptionEditorState) {
|
|
266
|
-
this.setState({ descriptionEditorState }, () => {
|
|
267
|
-
this.props.onChangeBlock(this.props.block, {
|
|
268
|
-
...this.props.data,
|
|
269
|
-
description: descriptionEditorState.getCurrentContent().getPlainText(),
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Upload image handler
|
|
276
|
-
* @method onUploadImage
|
|
277
|
-
* @returns {undefined}
|
|
278
|
-
*/
|
|
279
|
-
onUploadImage({ target }) {
|
|
280
|
-
const file = target.files[0];
|
|
281
|
-
if (!validateFileUploadSize(file, this.props.intl.formatMessage)) return;
|
|
282
|
-
this.setState({
|
|
283
|
-
uploading: true,
|
|
284
|
-
});
|
|
285
|
-
readAsDataURL(file).then((data) => {
|
|
286
|
-
const fields = data.match(/^data:(.*);(.*),(.*)$/);
|
|
287
|
-
this.props.createContent(
|
|
288
|
-
getBaseUrl(this.props.pathname),
|
|
289
|
-
{
|
|
290
|
-
'@type': 'Image',
|
|
291
|
-
image: {
|
|
292
|
-
data: fields[3],
|
|
293
|
-
encoding: fields[2],
|
|
294
|
-
'content-type': fields[1],
|
|
295
|
-
filename: file.name,
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
this.props.block,
|
|
299
|
-
);
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Render method.
|
|
305
|
-
* @method render
|
|
306
|
-
* @returns {string} Markup for the component.
|
|
307
|
-
*/
|
|
308
|
-
render() {
|
|
309
|
-
if (__SERVER__) {
|
|
310
|
-
return <div />;
|
|
311
|
-
}
|
|
312
|
-
const { Editor } = this.props.draftJs;
|
|
313
|
-
const placeholder =
|
|
314
|
-
this.props.data.placeholder ||
|
|
315
|
-
this.props.intl.formatMessage(messages.placeholder);
|
|
316
|
-
|
|
317
|
-
return (
|
|
318
|
-
<div
|
|
319
|
-
className={cx('block hero', {
|
|
320
|
-
selected: this.props.selected,
|
|
321
|
-
})}
|
|
322
|
-
>
|
|
323
|
-
{this.props.selected &&
|
|
324
|
-
this.props.editable &&
|
|
325
|
-
!!this.props.data.url && (
|
|
326
|
-
<div className="toolbar">
|
|
327
|
-
<Button.Group>
|
|
328
|
-
<Button
|
|
329
|
-
icon
|
|
330
|
-
basic
|
|
331
|
-
onClick={() =>
|
|
332
|
-
this.props.onChangeBlock(this.props.block, {
|
|
333
|
-
...this.props.data,
|
|
334
|
-
url: '',
|
|
335
|
-
})
|
|
336
|
-
}
|
|
337
|
-
>
|
|
338
|
-
<Icon name={clearSVG} size="24px" color="#e40166" />
|
|
339
|
-
</Button>
|
|
340
|
-
</Button.Group>
|
|
341
|
-
</div>
|
|
342
|
-
)}
|
|
343
|
-
<div className="block-inner-wrapper">
|
|
344
|
-
{this.props.data.url ? (
|
|
345
|
-
<img
|
|
346
|
-
className="hero-image"
|
|
347
|
-
src={`${flattenToAppURL(this.props.data.url)}/@@images/image`}
|
|
348
|
-
alt=""
|
|
349
|
-
/>
|
|
350
|
-
) : (
|
|
351
|
-
<div className="image-add">
|
|
352
|
-
<Message className="image-message">
|
|
353
|
-
{this.state.uploading && (
|
|
354
|
-
<Dimmer active>
|
|
355
|
-
<Loader indeterminate>
|
|
356
|
-
{this.props.intl.formatMessage(messages.uploading)}
|
|
357
|
-
</Loader>
|
|
358
|
-
</Dimmer>
|
|
359
|
-
)}
|
|
360
|
-
<center>
|
|
361
|
-
<h4>{this.props.intl.formatMessage(messages.image)}</h4>
|
|
362
|
-
{this.props.editable && (
|
|
363
|
-
<>
|
|
364
|
-
<p>{placeholder}</p>
|
|
365
|
-
<p>
|
|
366
|
-
<label className="ui button file">
|
|
367
|
-
{this.props.intl.formatMessage(messages.browse)}
|
|
368
|
-
<input
|
|
369
|
-
type="file"
|
|
370
|
-
onChange={this.onUploadImage}
|
|
371
|
-
style={{ display: 'none' }}
|
|
372
|
-
/>
|
|
373
|
-
</label>
|
|
374
|
-
</p>
|
|
375
|
-
</>
|
|
376
|
-
)}
|
|
377
|
-
</center>
|
|
378
|
-
</Message>
|
|
379
|
-
</div>
|
|
380
|
-
)}
|
|
381
|
-
<div className="hero-body">
|
|
382
|
-
<div className="hero-text">
|
|
383
|
-
<Editor
|
|
384
|
-
ref={(node) => {
|
|
385
|
-
this.titleEditor = node;
|
|
386
|
-
}}
|
|
387
|
-
readOnly={!this.props.editable}
|
|
388
|
-
onChange={this.onChangeTitle}
|
|
389
|
-
editorState={this.state.titleEditorState}
|
|
390
|
-
blockRenderMap={this.extendedBlockRenderMap}
|
|
391
|
-
handleReturn={() => true}
|
|
392
|
-
placeholder={this.props.intl.formatMessage(messages.title)}
|
|
393
|
-
blockStyleFn={() => 'title-editor'}
|
|
394
|
-
onUpArrow={() => {
|
|
395
|
-
const selectionState =
|
|
396
|
-
this.state.titleEditorState.getSelection();
|
|
397
|
-
const { titleEditorState } = this.state;
|
|
398
|
-
if (
|
|
399
|
-
titleEditorState
|
|
400
|
-
.getCurrentContent()
|
|
401
|
-
.getBlockMap()
|
|
402
|
-
.first()
|
|
403
|
-
.getKey() === selectionState.getFocusKey()
|
|
404
|
-
) {
|
|
405
|
-
this.props.onFocusPreviousBlock(
|
|
406
|
-
this.props.block,
|
|
407
|
-
this.props.blockNode.current,
|
|
408
|
-
);
|
|
409
|
-
}
|
|
410
|
-
}}
|
|
411
|
-
onDownArrow={() => {
|
|
412
|
-
const selectionState =
|
|
413
|
-
this.state.titleEditorState.getSelection();
|
|
414
|
-
const { titleEditorState } = this.state;
|
|
415
|
-
if (
|
|
416
|
-
titleEditorState
|
|
417
|
-
.getCurrentContent()
|
|
418
|
-
.getBlockMap()
|
|
419
|
-
.last()
|
|
420
|
-
.getKey() === selectionState.getFocusKey()
|
|
421
|
-
) {
|
|
422
|
-
this.setState(() => ({ currentFocused: 'description' }));
|
|
423
|
-
this.descriptionEditor.focus();
|
|
424
|
-
}
|
|
425
|
-
}}
|
|
426
|
-
/>
|
|
427
|
-
<Editor
|
|
428
|
-
ref={(node) => {
|
|
429
|
-
this.descriptionEditor = node;
|
|
430
|
-
}}
|
|
431
|
-
readOnly={!this.props.editable}
|
|
432
|
-
onChange={this.onChangeDescription}
|
|
433
|
-
editorState={this.state.descriptionEditorState}
|
|
434
|
-
blockRenderMap={this.extendedDescripBlockRenderMap}
|
|
435
|
-
handleReturn={() => true}
|
|
436
|
-
placeholder={this.props.intl.formatMessage(
|
|
437
|
-
messages.description,
|
|
438
|
-
)}
|
|
439
|
-
blockStyleFn={() => 'description-editor'}
|
|
440
|
-
onUpArrow={() => {
|
|
441
|
-
const selectionState =
|
|
442
|
-
this.state.descriptionEditorState.getSelection();
|
|
443
|
-
const currentCursorPosition = selectionState.getStartOffset();
|
|
444
|
-
|
|
445
|
-
if (currentCursorPosition === 0) {
|
|
446
|
-
this.setState(() => ({ currentFocused: 'title' }));
|
|
447
|
-
this.titleEditor.focus();
|
|
448
|
-
}
|
|
449
|
-
}}
|
|
450
|
-
onDownArrow={() => {
|
|
451
|
-
const selectionState =
|
|
452
|
-
this.state.descriptionEditorState.getSelection();
|
|
453
|
-
const { descriptionEditorState } = this.state;
|
|
454
|
-
const currentCursorPosition = selectionState.getStartOffset();
|
|
455
|
-
const blockLength = descriptionEditorState
|
|
456
|
-
.getCurrentContent()
|
|
457
|
-
.getFirstBlock()
|
|
458
|
-
.getLength();
|
|
459
|
-
|
|
460
|
-
if (currentCursorPosition === blockLength) {
|
|
461
|
-
this.props.onFocusNextBlock(
|
|
462
|
-
this.props.block,
|
|
463
|
-
this.props.blockNode.current,
|
|
464
|
-
);
|
|
465
|
-
}
|
|
466
|
-
}}
|
|
467
|
-
/>
|
|
468
|
-
</div>
|
|
469
|
-
<LinkMore data={this.props.data} isEditMode={true} />
|
|
470
|
-
</div>
|
|
471
|
-
</div>
|
|
472
|
-
<SidebarPortal selected={this.props.selected}>
|
|
473
|
-
<Data {...this.props} />
|
|
474
|
-
</SidebarPortal>
|
|
475
|
-
</div>
|
|
476
|
-
);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
const Edit = injectLazyLibs(['draftJs', 'immutableLib', 'draftJsImportHtml'])(
|
|
481
|
-
EditComponent,
|
|
482
|
-
);
|
|
483
|
-
|
|
484
|
-
export default compose(
|
|
485
|
-
injectIntl,
|
|
486
|
-
connect(
|
|
487
|
-
(state, ownProps) => ({
|
|
488
|
-
request: state.content.subrequests[ownProps.block] || {},
|
|
489
|
-
content: state.content.subrequests[ownProps.block]?.data,
|
|
490
|
-
}),
|
|
491
|
-
{ createContent },
|
|
492
|
-
),
|
|
493
|
-
)(Edit);
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
import configureStore from 'redux-mock-store';
|
|
4
|
-
import { Provider } from 'react-intl-redux';
|
|
5
|
-
|
|
6
|
-
import Edit from './Edit';
|
|
7
|
-
|
|
8
|
-
jest.mock('@plone/volto/helpers/Loadable/Loadable');
|
|
9
|
-
beforeAll(
|
|
10
|
-
async () =>
|
|
11
|
-
await require('@plone/volto/helpers/Loadable/Loadable').__setLoadables(),
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
global.__SERVER__ = true; // eslint-disable-line no-underscore-dangle
|
|
15
|
-
|
|
16
|
-
const mockStore = configureStore();
|
|
17
|
-
const blockId = '1234';
|
|
18
|
-
|
|
19
|
-
test('renders an edit hero block component', () => {
|
|
20
|
-
const store = mockStore({
|
|
21
|
-
content: {
|
|
22
|
-
create: {},
|
|
23
|
-
data: {},
|
|
24
|
-
subrequests: {
|
|
25
|
-
[blockId]: {},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
intl: {
|
|
29
|
-
locale: 'en',
|
|
30
|
-
messages: {},
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
const component = renderer.create(
|
|
34
|
-
<Provider store={store}>
|
|
35
|
-
<Edit
|
|
36
|
-
data={{ url: 'hero' }}
|
|
37
|
-
selected={false}
|
|
38
|
-
block={blockId}
|
|
39
|
-
content={{}}
|
|
40
|
-
request={{
|
|
41
|
-
loading: false,
|
|
42
|
-
loaded: false,
|
|
43
|
-
}}
|
|
44
|
-
pathname="/news"
|
|
45
|
-
onChangeBlock={() => {}}
|
|
46
|
-
onSelectBlock={() => {}}
|
|
47
|
-
onDeleteBlock={() => {}}
|
|
48
|
-
createContent={() => {}}
|
|
49
|
-
onFocusPreviousBlock={() => {}}
|
|
50
|
-
onFocusNextBlock={() => {}}
|
|
51
|
-
handleKeyDown={() => {}}
|
|
52
|
-
index={1}
|
|
53
|
-
/>
|
|
54
|
-
</Provider>,
|
|
55
|
-
);
|
|
56
|
-
const json = component.toJSON();
|
|
57
|
-
expect(json).toMatchSnapshot();
|
|
58
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
4
|
-
import { LinkMore } from '@plone/volto/components';
|
|
5
|
-
|
|
6
|
-
const View = ({ data }) => (
|
|
7
|
-
<div className="block hero">
|
|
8
|
-
<div className="block-inner-wrapper">
|
|
9
|
-
{data.url && (
|
|
10
|
-
<img
|
|
11
|
-
src={`${flattenToAppURL(data.url)}/@@images/image`}
|
|
12
|
-
alt=""
|
|
13
|
-
className="hero-image"
|
|
14
|
-
loading="lazy"
|
|
15
|
-
/>
|
|
16
|
-
)}
|
|
17
|
-
<div className="hero-body">
|
|
18
|
-
<div className="hero-text">
|
|
19
|
-
{data.title && <h1>{data.title}</h1>}
|
|
20
|
-
{data.description && <p>{data.description}</p>}
|
|
21
|
-
</div>
|
|
22
|
-
<LinkMore data={data} />
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Property types.
|
|
30
|
-
* @property {Object} propTypes Property types.
|
|
31
|
-
* @static
|
|
32
|
-
*/
|
|
33
|
-
View.propTypes = {
|
|
34
|
-
data: PropTypes.objectOf(PropTypes.any).isRequired,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default View;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
import View from './View';
|
|
4
|
-
|
|
5
|
-
test('renders a view hero component', () => {
|
|
6
|
-
const component = renderer.create(<View data={{ url: 'heroimage.jpg' }} />);
|
|
7
|
-
const json = component.toJSON();
|
|
8
|
-
expect(json).toMatchSnapshot();
|
|
9
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { defineMessages } from 'react-intl';
|
|
2
|
-
|
|
3
|
-
const messages = defineMessages({
|
|
4
|
-
more: {
|
|
5
|
-
id: 'Link more',
|
|
6
|
-
defaultMessage: 'Link more',
|
|
7
|
-
},
|
|
8
|
-
LinkTitle: {
|
|
9
|
-
id: 'Link title',
|
|
10
|
-
defaultMessage: 'Link Title',
|
|
11
|
-
},
|
|
12
|
-
LinkTo: {
|
|
13
|
-
id: 'Link to',
|
|
14
|
-
defaultMessage: 'Link to',
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const schemaHero = ({ intl }) => {
|
|
19
|
-
return {
|
|
20
|
-
title: 'Block settings',
|
|
21
|
-
required: [],
|
|
22
|
-
fieldsets: [
|
|
23
|
-
{
|
|
24
|
-
id: 'default',
|
|
25
|
-
title: intl.formatMessage(messages.more),
|
|
26
|
-
fields: ['linkTitle', 'linkHref'],
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
properties: {
|
|
30
|
-
linkTitle: {
|
|
31
|
-
title: intl.formatMessage(messages.LinkTitle),
|
|
32
|
-
},
|
|
33
|
-
linkHref: {
|
|
34
|
-
title: intl.formatMessage(messages.LinkTo),
|
|
35
|
-
widget: 'object_browser',
|
|
36
|
-
mode: 'link',
|
|
37
|
-
selectedItemAttrs: ['Title', 'Description'],
|
|
38
|
-
allowExternals: true,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
export default schemaHero;
|