@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,126 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import EditorUtils from '../../utils/EditorUtils';
|
|
5
|
-
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
|
|
6
|
-
import AddLinkForm from '@plone/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm';
|
|
7
|
-
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
8
|
-
|
|
9
|
-
import linkSVG from '@plone/volto/icons/link.svg';
|
|
10
|
-
import unlinkSVG from '@plone/volto/icons/unlink.svg';
|
|
11
|
-
|
|
12
|
-
// import unionClassNames from 'union-class-names';
|
|
13
|
-
//import EditorUtils from 'draft-js-plugins-utils';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Add link form class.
|
|
17
|
-
* @class LinkButton
|
|
18
|
-
* @extends Component
|
|
19
|
-
*/
|
|
20
|
-
class LinkButton extends Component {
|
|
21
|
-
static propTypes = {
|
|
22
|
-
placeholder: PropTypes.string,
|
|
23
|
-
theme: PropTypes.shape({}).isRequired,
|
|
24
|
-
ownTheme: PropTypes.shape({}).isRequired,
|
|
25
|
-
onRemoveLinkAtSelection: PropTypes.func.isRequired,
|
|
26
|
-
onOverrideContent: PropTypes.func.isRequired,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
constructor(props) {
|
|
30
|
-
super(props);
|
|
31
|
-
|
|
32
|
-
this.DraftEditorUtils = props.draftJsPluginsUtils.default;
|
|
33
|
-
this.EditorUtils = EditorUtils(props);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static defaultProps = {
|
|
37
|
-
placeholder: '',
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
onMouseDown = (event) => {
|
|
41
|
-
event.preventDefault();
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
onAddLinkClick = (e) => {
|
|
45
|
-
e.preventDefault();
|
|
46
|
-
e.stopPropagation();
|
|
47
|
-
const { ownTheme, placeholder, onOverrideContent } = this.props;
|
|
48
|
-
const link = this.EditorUtils.getCurrentEntity(
|
|
49
|
-
this.props.getEditorState(),
|
|
50
|
-
)?.getData()?.url;
|
|
51
|
-
|
|
52
|
-
const content = (props) => (
|
|
53
|
-
<AddLinkForm
|
|
54
|
-
{...props}
|
|
55
|
-
placeholder={placeholder}
|
|
56
|
-
theme={ownTheme}
|
|
57
|
-
block="draft-js"
|
|
58
|
-
data={{ url: link || '' }}
|
|
59
|
-
onChangeBlock={() => {}}
|
|
60
|
-
onClear={() => {
|
|
61
|
-
this.props.setEditorState(
|
|
62
|
-
this.DraftEditorUtils.removeLinkAtSelection(
|
|
63
|
-
this.props.getEditorState(),
|
|
64
|
-
),
|
|
65
|
-
);
|
|
66
|
-
}}
|
|
67
|
-
onChangeValue={(url) => {
|
|
68
|
-
this.props.setEditorState(
|
|
69
|
-
this.DraftEditorUtils.createLinkAtSelection(
|
|
70
|
-
this.props.getEditorState(),
|
|
71
|
-
url,
|
|
72
|
-
),
|
|
73
|
-
);
|
|
74
|
-
}}
|
|
75
|
-
/>
|
|
76
|
-
);
|
|
77
|
-
onOverrideContent(content);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Render method.
|
|
82
|
-
* @method render
|
|
83
|
-
* @returns {string} Markup for the component.
|
|
84
|
-
*/
|
|
85
|
-
render() {
|
|
86
|
-
const { theme } = this.props;
|
|
87
|
-
const hasLinkSelected = this.EditorUtils.hasEntity(
|
|
88
|
-
this.props.getEditorState(),
|
|
89
|
-
'LINK',
|
|
90
|
-
);
|
|
91
|
-
const className = hasLinkSelected
|
|
92
|
-
? cx(theme.button, theme.active)
|
|
93
|
-
: theme.button;
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<div
|
|
97
|
-
className={theme.buttonWrapper}
|
|
98
|
-
onMouseDown={this.onMouseDown}
|
|
99
|
-
role="presentation"
|
|
100
|
-
>
|
|
101
|
-
<button
|
|
102
|
-
className={className}
|
|
103
|
-
onClick={
|
|
104
|
-
this.onAddLinkClick
|
|
105
|
-
// hasLinkSelected
|
|
106
|
-
// ? () =>
|
|
107
|
-
// onRemoveLinkAtSelection(
|
|
108
|
-
// this.props.setEditorState,
|
|
109
|
-
// this.props.getEditorState,
|
|
110
|
-
// )
|
|
111
|
-
// : this.onAddLinkClick
|
|
112
|
-
}
|
|
113
|
-
type="button"
|
|
114
|
-
>
|
|
115
|
-
{!hasLinkSelected ? (
|
|
116
|
-
<Icon name={linkSVG} size="24px" />
|
|
117
|
-
) : (
|
|
118
|
-
<Icon name={unlinkSVG} size="24px" />
|
|
119
|
-
)}
|
|
120
|
-
</button>
|
|
121
|
-
</div>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export default injectLazyLibs(['draftJs', 'draftJsPluginsUtils'])(LinkButton);
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import decorateComponentWithProps from 'decorate-component-with-props';
|
|
2
|
-
|
|
3
|
-
import DefaultLink from './components/Link';
|
|
4
|
-
import LinkButton from './components/LinkButton';
|
|
5
|
-
import linkStrategy, { matchesEntityType } from './linkStrategy';
|
|
6
|
-
|
|
7
|
-
function unboundRemoveEntity(editorState) {
|
|
8
|
-
const contentState = editorState.getCurrentContent();
|
|
9
|
-
const selectionState = editorState.getSelection();
|
|
10
|
-
const startKey = selectionState.getStartKey();
|
|
11
|
-
const contentBlock = contentState.getBlockForKey(startKey);
|
|
12
|
-
const startOffset = selectionState.getStartOffset();
|
|
13
|
-
const entity = contentBlock.getEntityAt(startOffset);
|
|
14
|
-
|
|
15
|
-
if (!entity) {
|
|
16
|
-
return editorState;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let entitySelection = null;
|
|
20
|
-
|
|
21
|
-
contentBlock.findEntityRanges(
|
|
22
|
-
(character) => character.getEntity() === entity,
|
|
23
|
-
(start, end) => {
|
|
24
|
-
entitySelection = selectionState.merge({
|
|
25
|
-
anchorOffset: start,
|
|
26
|
-
focusOffset: end,
|
|
27
|
-
isBackward: false,
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const newContentState = this.Modifier.applyEntity(
|
|
33
|
-
contentState,
|
|
34
|
-
entitySelection,
|
|
35
|
-
null,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const newEditorState = this.EditorState.push(
|
|
39
|
-
editorState,
|
|
40
|
-
newContentState,
|
|
41
|
-
'apply-entity',
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return newEditorState;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default function AnchorPlugin(config = {}) {
|
|
48
|
-
// ToDo: Get rif of the remainings of having the original CSS modules
|
|
49
|
-
const defaultTheme = {};
|
|
50
|
-
|
|
51
|
-
const {
|
|
52
|
-
theme = defaultTheme,
|
|
53
|
-
placeholder,
|
|
54
|
-
Link,
|
|
55
|
-
linkTarget,
|
|
56
|
-
libraries,
|
|
57
|
-
} = config;
|
|
58
|
-
|
|
59
|
-
const removeEntity = unboundRemoveEntity.bind(libraries);
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
decorators: [
|
|
63
|
-
{
|
|
64
|
-
strategy: linkStrategy,
|
|
65
|
-
matchesEntityType,
|
|
66
|
-
component:
|
|
67
|
-
Link ||
|
|
68
|
-
decorateComponentWithProps(DefaultLink, {
|
|
69
|
-
className: 'link-anchorlink-theme',
|
|
70
|
-
target: linkTarget,
|
|
71
|
-
}),
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
|
|
75
|
-
LinkButton: decorateComponentWithProps(LinkButton, {
|
|
76
|
-
ownTheme: theme,
|
|
77
|
-
placeholder,
|
|
78
|
-
onRemoveLinkAtSelection: (setEditorState, getEditorState) =>
|
|
79
|
-
setEditorState(removeEntity(getEditorState())),
|
|
80
|
-
}),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const matchesEntityType = (type) => type === 'LINK';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @export strategy
|
|
7
|
-
* @param {*} contentBlock contentBlock
|
|
8
|
-
* @param {*} cb cb
|
|
9
|
-
* @param {*} contentState contentState
|
|
10
|
-
* @returns {*} string
|
|
11
|
-
*/
|
|
12
|
-
export default function strategy(contentBlock, cb, contentState) {
|
|
13
|
-
if (!contentState) return;
|
|
14
|
-
contentBlock.findEntityRanges((character) => {
|
|
15
|
-
const entityKey = character.getEntity();
|
|
16
|
-
return (
|
|
17
|
-
entityKey !== null &&
|
|
18
|
-
matchesEntityType(contentState.getEntity(entityKey).getType())
|
|
19
|
-
);
|
|
20
|
-
}, cb);
|
|
21
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const EditorUtils = ({ draftJs }) => ({
|
|
2
|
-
createLinkAtSelection(editorState, url) {
|
|
3
|
-
const contentState = editorState
|
|
4
|
-
.getCurrentContent()
|
|
5
|
-
.createEntity('LINK', 'MUTABLE', { url });
|
|
6
|
-
const entityKey = contentState.getLastCreatedEntityKey();
|
|
7
|
-
const withLink = draftJs.RichUtils.toggleLink(
|
|
8
|
-
editorState,
|
|
9
|
-
editorState.getSelection(),
|
|
10
|
-
entityKey,
|
|
11
|
-
);
|
|
12
|
-
return draftJs.EditorState.forceSelection(
|
|
13
|
-
withLink,
|
|
14
|
-
editorState.getSelection(),
|
|
15
|
-
);
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
removeLinkAtSelection(editorState) {
|
|
19
|
-
const selection = editorState.getSelection();
|
|
20
|
-
return draftJs.RichUtils.toggleLink(editorState, selection, null);
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
getCurrentEntityKey(editorState) {
|
|
24
|
-
const selection = editorState.getSelection();
|
|
25
|
-
const anchorKey = selection.getAnchorKey();
|
|
26
|
-
const contentState = editorState.getCurrentContent();
|
|
27
|
-
const anchorBlock = contentState.getBlockForKey(anchorKey);
|
|
28
|
-
const index = selection.isBackward
|
|
29
|
-
? selection.focusOffset
|
|
30
|
-
: selection.anchorOffset;
|
|
31
|
-
|
|
32
|
-
return anchorBlock.getEntityAt(index);
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
getCurrentEntity(editorState) {
|
|
36
|
-
const contentState = editorState.getCurrentContent();
|
|
37
|
-
const entityKey = this.getCurrentEntityKey(editorState);
|
|
38
|
-
return entityKey ? contentState.getEntity(entityKey) : null;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
hasEntity(editorState, entityType) {
|
|
42
|
-
const entity = this.getCurrentEntity(editorState);
|
|
43
|
-
return entity && entity.getType() === entityType;
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
export default EditorUtils;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useIntl } from 'react-intl';
|
|
3
|
-
import schemaHero from './schema.js';
|
|
4
|
-
import { BlockDataForm } from '@plone/volto/components';
|
|
5
|
-
|
|
6
|
-
const HeroImageLeftBlockData = (props) => {
|
|
7
|
-
const { block, data, onChangeBlock, navRoot, contentType } = props;
|
|
8
|
-
const intl = useIntl();
|
|
9
|
-
const schema = schemaHero({ ...props, intl });
|
|
10
|
-
return (
|
|
11
|
-
<BlockDataForm
|
|
12
|
-
schema={schema}
|
|
13
|
-
title={schema.title}
|
|
14
|
-
onChangeField={(id, value) => {
|
|
15
|
-
onChangeBlock(block, {
|
|
16
|
-
...data,
|
|
17
|
-
[id]: value,
|
|
18
|
-
});
|
|
19
|
-
}}
|
|
20
|
-
onChangeBlock={onChangeBlock}
|
|
21
|
-
formData={data}
|
|
22
|
-
block={block}
|
|
23
|
-
navRoot={navRoot}
|
|
24
|
-
contentType={contentType}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default HeroImageLeftBlockData;
|