Skip to content

Commit 0b648e5

Browse files
committed
TASK: init
0 parents  commit 0b648e5

File tree

9 files changed

+1238
-0
lines changed

9 files changed

+1238
-0
lines changed

Configuration/Settings.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Neos:
2+
Neos:
3+
Ui:
4+
resources:
5+
javascript:
6+
'Flowpack.StructuredEditing:StructuredEditing':
7+
resource: resource://Flowpack.StructuredEditing/Public/JavaScript/StructuredEditing/Plugin.js
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "@neos-project/eslint-config-neos",
3+
"globals": {
4+
"expect": true,
5+
"sinon": false
6+
},
7+
"env": {
8+
"node": true,
9+
"mocha": true
10+
}
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"description": "Structured editing for Neos",
3+
"private": true,
4+
"scripts": {
5+
"build": "neos-react-scripts build",
6+
"watch": "neos-react-scripts watch"
7+
},
8+
"devDependencies": {
9+
"@neos-project/neos-ui-extensibility": "*"
10+
},
11+
"neos": {
12+
"buildTargetDirectory": "../../Public/JavaScript/StructuredEditing"
13+
},
14+
"dependencies": {
15+
"@neos-project/eslint-config-neos": "^2.1.2",
16+
"lodash.upperfirst": "^4.3.1"
17+
}
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./manifest');
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import React, {PureComponent} from 'react';
2+
import PropTypes from 'prop-types';
3+
import ReactDOM from 'react-dom';
4+
import manifest from '@neos-project/neos-ui-extensibility';
5+
import {selectors} from '@neos-project/neos-ui-redux-store';
6+
import {DropDown} from '@neos-project/react-ui-components';
7+
import {connect} from 'react-redux';
8+
import {$transform, $get} from 'plow-js';
9+
import EditorEnvelope from '@neos-project/neos-ui-editors';
10+
import style from './style.css';
11+
12+
@connect($transform({
13+
currentlyEditedPropertyName: selectors.UI.ContentCanvas.currentlyEditedPropertyName,
14+
getNodeByContextPath: selectors.CR.Nodes.nodeByContextPath,
15+
focusedNodePath: selectors.CR.Nodes.focusedNodePathSelector
16+
}))
17+
class InlineEditorEnvelope extends PureComponent {
18+
state = {
19+
isOpen: false
20+
}
21+
static childContextTypes = {
22+
store: PropTypes.object.isRequired,
23+
globalRegistry: PropTypes.object.isRequired,
24+
configuration: PropTypes.object.isRequired,
25+
routes: PropTypes.object.isRequired
26+
};
27+
getChildContext() {
28+
const {configuration, globalRegistry, routes, store} = this.props;
29+
return {configuration, globalRegistry, routes, store};
30+
}
31+
handleToggle = () => {
32+
this.setState({isOpen: !this.state.isOpen});
33+
}
34+
render() {
35+
const {contextPath, fusionPath, propertyName, persistChange, editorOptions, getNodeByContextPath, focusedNodePath} = this.props;
36+
const value = $get(['properties', propertyName], getNodeByContextPath(contextPath));
37+
return (
38+
<div style={{display: 'inline-block'}}>
39+
<DropDown.Stateless isOpen={this.state.isOpen} padded={true} onToggle={this.handleToggle} onClose={() => null}>
40+
<DropDown.Header className="enveloper_dropdown_header">
41+
<style>{'\
42+
.enveloper_dropdown_header{\
43+
width: 30px;\
44+
height: 30px;\
45+
padding: 8px;\
46+
}\
47+
.enveloper_dropdown_contents{\
48+
width: 320px;\
49+
background-color: #272727;\
50+
}\
51+
.enveloper_dropdown_header i {\
52+
display: none;\
53+
}\
54+
'}</style>
55+
<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>
56+
</DropDown.Header>
57+
<DropDown.Contents className="enveloper_dropdown_contents" scrollable={false}>
58+
<div>
59+
<EditorEnvelope
60+
identifier={propertyName}
61+
label={$get('label', editorOptions)}
62+
editor={$get('editor', editorOptions)}
63+
value={value && value.toJS ? value.toJS() : value}
64+
hooks={null}
65+
options={editorOptions}
66+
commit={value => {
67+
persistChange({
68+
type: 'Neos.Neos.Ui:Property',
69+
subject: contextPath,
70+
payload: {
71+
propertyName,
72+
value,
73+
nodeDomAddress: {
74+
contextPath,
75+
fusionPath
76+
}
77+
}
78+
});
79+
}}
80+
renderSecondaryInspector={() => null}
81+
/>
82+
</div>
83+
</DropDown.Contents>
84+
</DropDown.Stateless>
85+
</div>
86+
);
87+
}
88+
}
89+
90+
const findParentFusionPath = (node, contextPath) => {
91+
if (node) {
92+
const fusionPath = node.getAttribute('data-__neos-fusion-path');
93+
if (fusionPath && node.getAttribute('data-__neos-node-contextpath') === contextPath) {
94+
return fusionPath;
95+
}
96+
return findParentFusionPath(node.parentNode, contextPath);
97+
}
98+
return null;
99+
};
100+
101+
manifest('Flowpack.StructuredEditing:EditorEnvelope', {}, (globalRegistry, {routes, configuration, store}) => {
102+
const inlineEditorRegistry = globalRegistry.get('inlineEditors');
103+
inlineEditorRegistry.set('Flowpack.StructuredEditing/EditorEnvelope', {
104+
bootstrap: () => null,
105+
createInlineEditor: config => {
106+
const domNode = config.propertyDomNode;
107+
const fusionPath = findParentFusionPath(domNode, config.contextPath);
108+
ReactDOM.render(
109+
(<InlineEditorEnvelope
110+
globalRegistry={globalRegistry}
111+
routes={routes}
112+
configuration={configuration}
113+
store={store}
114+
fusionPath={fusionPath}
115+
{...config}
116+
/>), domNode);
117+
},
118+
ToolbarComponent: () => null
119+
});
120+
});

0 commit comments

Comments
 (0)