Merge branch 'components-panel' of gitlab.alibaba-inc.com:ali-lowcode/ali-lowcode-engine into components-panel

This commit is contained in:
春希 2020-07-16 20:31:45 +08:00
commit 7ecf137800
4 changed files with 31 additions and 18 deletions

View File

@ -19,12 +19,14 @@
"value": "function() {\n \t\tconsole.log('will umount');\n\t}" "value": "function() {\n \t\tconsole.log('will umount');\n\t}"
} }
}, },
"methods": { "methods": {
"testFunc": { "testFunc": {
"type": "JSFunction", "type": "JSFunction",
"value": "function() {console.log('test func');}" "value": "function() {console.log('test func');}"
} }
}, },
"props": { "props": {
"ref": "outterView", "ref": "outterView",
"autoLoading": true, "autoLoading": true,

View File

@ -268,9 +268,19 @@ export default class EventsSetter extends Component<{
onRelatedEventNameClick = (eventName:String) => { onRelatedEventNameClick = (eventName:String) => {
const {editor} = this.props.field; const {editor} = this.props.field;
editor.get('skeleton').getPanel('sourceEditor').show();
setTimeout(()=>{
editor.emit('sourceEditor.focusByFunction',{ editor.emit('sourceEditor.focusByFunction',{
functionName:eventName functionName:eventName
}) })
},300)
// editor.emit('sourceEditor.focusByFunction',{
// functionName:eventName
// })
} }
closeEventMenu = () => { closeEventMenu = () => {
@ -324,6 +334,7 @@ export default class EventsSetter extends Component<{
eventDataList eventDataList
}) })
this.props.onChange(eventDataList); this.props.onChange(eventDataList);
//this.closeDialog(); //this.closeDialog();

View File

@ -99,16 +99,6 @@ export default class SourceEditor extends Component<{
//}); //});
} }
componentDidMount() {}
openPluginPannel = () => {
const { editor } = this.props;
// 判断面板是否处于激活状态
if (!editor.leftNav || editor.leftNav != 'sourceEditor') {
// 打开面板
editor.emit('leftNav.change', 'sourceEditor');
}
};
/** /**
* *
@ -122,7 +112,6 @@ export default class SourceEditor extends Component<{
return; return;
} }
debugger;
if (this.state.selectTab == TAB_KEY.CSS_TAB) { if (this.state.selectTab == TAB_KEY.CSS_TAB) {
this.setState({ this.setState({
selectTab: TAB_KEY.JS_TAB, selectTab: TAB_KEY.JS_TAB,
@ -173,7 +162,6 @@ export default class SourceEditor extends Component<{
this.monocoEditor.focus(); this.monocoEditor.focus();
}, 100); }, 100);
debugger;
this.updateCode(this.monocoEditor.getModel().getValue()); this.updateCode(this.monocoEditor.getModel().getValue());
} }
@ -213,6 +201,10 @@ export default class SourceEditor extends Component<{
} }
onTabChange = (key) => { onTabChange = (key) => {
const { editor } = this.props;
let schema = editor.get('designer').project.getSchema();
console.log(schema);
this.setState({ this.setState({
selectTab: key, selectTab: key,
}); });

View File

@ -59,7 +59,15 @@ const transfrom = {
setFunction2Schema(functionMap,schema){ setFunction2Schema(functionMap,schema){
let pageNode = schema.componentsTree[0]; let pageNode = schema.componentsTree[0];
pageNode.state = functionMap.state; for (let key in functionMap){
if (key == 'state'){
pageNode.state = functionMap[key];
}else{
if (LIFECYCLES_FUNCTION_MAP.react.indexOf(key)>=0){
// 判断有没有lifecycles节点
}
}
}
} }
}; };
@ -104,7 +112,7 @@ function initMethodsCode(componentSchema: Object) {
} }
function createFunctionCode(functionName: String, functionNode: Object) { function createFunctionCode(functionName: String, functionNode: Object) {
if (functionNode.type === 'JSExpression') { if (functionNode.type === 'JSExpression' || functionNode.type === 'JSFunction') {
let functionCode = functionNode.value; let functionCode = functionNode.value;
functionCode = functionCode.replace(/function/, functionName); functionCode = functionCode.replace(/function/, functionName);
return functionCode; return functionCode;