Skip to content

Commit e6d99cc

Browse files
committed
FEATURE: add support for custom icons and labels
1 parent 2aa83bc commit e6d99cc

File tree

4 files changed

+7298
-26
lines changed

4 files changed

+7298
-26
lines changed

Resources/Private/StructuredEditing/src/manifest.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33
import ReactDOM from 'react-dom';
44
import manifest from '@neos-project/neos-ui-extensibility';
55
import {selectors} from '@neos-project/neos-ui-redux-store';
6-
import {DropDown} from '@neos-project/react-ui-components';
6+
import {DropDown, Icon} from '@neos-project/react-ui-components';
77
import {withDragDropContext} from '@neos-project/neos-ui-decorators';
88
import {connect} from 'react-redux';
99
import {$transform, $get} from 'plow-js';
@@ -34,32 +34,42 @@ class InlineEditorEnvelope extends PureComponent {
3434
}
3535
render() {
3636
const {contextPath, fusionPath, propertyName, persistChange, editorOptions, getNodeByContextPath, focusedNodePath} = this.props;
37-
const value = $get(['properties', propertyName], getNodeByContextPath(contextPath));
37+
const node = getNodeByContextPath(contextPath);
38+
const nodeTypeName = $get('nodeType', node);
39+
const nodeType = this.props.nodeTypesRegistry.getNodeType(nodeTypeName);
40+
const icon = $get('icon', editorOptions) || 'pencil';
41+
const value = $get(['properties', propertyName], node);
3842
return (
3943
<div style={{display: 'inline-block'}}>
4044
<DropDown.Stateless isOpen={this.state.isOpen} padded={true} onToggle={this.handleToggle} onClose={() => null}>
4145
<DropDown.Header className="enveloper_dropdown_header">
4246
<style>{'\
4347
.enveloper_dropdown_header{\
48+
position: relative;\
4449
width: 30px;\
4550
height: 30px;\
46-
padding: 8px;\
51+
padding: 0;\
52+
}\
53+
.enveloper_dropdown_icon{\
54+
position: absolute;\
55+
top: 8px;\
56+
left: 8px;\
4757
}\
4858
.enveloper_dropdown_contents{\
4959
width: 320px;\
5060
background-color: #272727;\
5161
}\
52-
.enveloper_dropdown_header i {\
62+
.enveloper_dropdown_header i:nth-child(3) {\
5363
display: none;\
5464
}\
5565
'}</style>
56-
<svg style={{backgroundColor: '#323232', position: 'absolute', fill: 'white', width: '14px', height: '14px'}} width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M491 1536l91-91-235-235-91 91v107h128v128h107zm523-928q0-22-22-22-10 0-17 7l-542 542q-7 7-7 17 0 22 22 22 10 0 17-7l542-542q7-7 7-17zm-54-192l416 416-832 832h-416v-416zm683 96q0 53-37 90l-166 166-416-416 166-165q36-38 90-38 53 0 91 38l235 234q37 39 37 91z" /></svg>
66+
<Icon className="enveloper_dropdown_icon" icon={icon} />
5767
</DropDown.Header>
5868
<DropDown.Contents className="enveloper_dropdown_contents" scrollable={false}>
5969
<div>
6070
<EditorEnvelope
6171
identifier={propertyName}
62-
label={$get('label', editorOptions) || ''}
72+
label={$get('label', editorOptions) || $get(['properties', propertyName, 'ui', 'label'], nodeType) || ''}
6373
editor={$get('editor', editorOptions)}
6474
value={value && value.toJS ? value.toJS() : value}
6575
hooks={null}
@@ -101,6 +111,7 @@ const findParentFusionPath = (node, contextPath) => {
101111

102112
manifest('Flowpack.StructuredEditing:EditorEnvelope', {}, (globalRegistry, {routes, configuration, store}) => {
103113
const inlineEditorRegistry = globalRegistry.get('inlineEditors');
114+
const nodeTypesRegistry = globalRegistry.get('@neos-project/neos-ui-contentrepository');
104115
inlineEditorRegistry.set('Flowpack.StructuredEditing/EditorEnvelope', {
105116
bootstrap: () => null,
106117
createInlineEditor: config => {
@@ -113,6 +124,7 @@ manifest('Flowpack.StructuredEditing:EditorEnvelope', {}, (globalRegistry, {rout
113124
configuration={configuration}
114125
store={store}
115126
fusionPath={fusionPath}
127+
nodeTypesRegistry={nodeTypesRegistry}
116128
{...config}
117129
/>), domNode);
118130
},

0 commit comments

Comments
 (0)