joint source editor

This commit is contained in:
kangwei 2020-04-22 17:45:55 +08:00
parent 79827dc8b9
commit 8b02b10e4e
3 changed files with 48 additions and 50 deletions

View File

@ -57,7 +57,7 @@ export default class SourceEditor extends Component<{
tabKey: TAB_KEY.JS_TAB, tabKey: TAB_KEY.JS_TAB,
}; };
componentWillMount() { async componentWillMount() {
const { editor } = this.props; const { editor } = this.props;
editor.on('leftPanel.show', (key: String) => { editor.on('leftPanel.show', (key: String) => {
if (key === 'sourceEditor' && !this.monocoEditer) { if (key === 'sourceEditor' && !this.monocoEditer) {
@ -79,44 +79,41 @@ export default class SourceEditor extends Component<{
this.openPluginPannel(); this.openPluginPannel();
}) })
const designer = await editor.onceGot(Designer);
// let schema = designer.project.getSchema();
editor.once('designer.mount', (designer: Designer) => { // mock data
// let schema = designer.project.getSchema(); let schema = {
// mock data componentTree: [
let schema = { {
componentTree: [ state: {
{ // 初始state 选填 对象类型/变量表达式
state: { btnText: 'submit', // 默认数据值: 选填 变量表达式
// 初始state 选填 对象类型/变量表达式 },
btnText: 'submit', // 默认数据值: 选填 变量表达式 css: 'body {font-size: 12px;} .botton{widht:100px;color:#ff00ff}', //css样式描述 选填
lifeCycles: {
//生命周期: 选填 对象类型
didMount: {
type: 'JSExpression',
value: "function() {\n \t\tconsole.log('did mount');\n\t}",
}, },
css: 'body {font-size: 12px;} .botton{widht:100px;color:#ff00ff}', //css样式描述 选填 willUnmount: {
lifeCycles: { type: 'JSExpression',
//生命周期: 选填 对象类型 value: "function() {\n \t\tconsole.log('will umount');\n\t}",
didMount: {
type: 'JSExpression',
value: "function() {\n \t\tconsole.log('did mount');\n\t}",
},
willUnmount: {
type: 'JSExpression',
value: "function() {\n \t\tconsole.log('will umount');\n\t}",
},
},
methods: {
//自定义方法对象: 选填 对象类型
getData: {
//自定义方法: 选填 函数类型
type: 'JSExpression',
value: "function() {\n \t\tconsole.log('testFunc');\n \t}",
},
}, },
}, },
], methods: {
}; //自定义方法对象: 选填 对象类型
getData: {
//自定义方法: 选填 函数类型
type: 'JSExpression',
value: "function() {\n \t\tconsole.log('testFunc');\n \t}",
},
},
},
],
};
this.initCode(schema); this.initCode(schema);
});
} }
openPluginPannel = () => { openPluginPannel = () => {

View File

@ -3,7 +3,6 @@ import { createElement } from 'react';
import { Button } from '@alifd/next'; import { Button } from '@alifd/next';
import Engine, { Panes } from '@ali/visualengine'; import Engine, { Panes } from '@ali/visualengine';
import getTrunkPane from '@ali/ve-trunk-pane'; import getTrunkPane from '@ali/ve-trunk-pane';
import SourceEditor from '@ali/lowcode-plugin-source-editor';
import EventBindDialog from '@ali/lowcode-plugin-event-bind-dialog'; import EventBindDialog from '@ali/lowcode-plugin-event-bind-dialog';
import loadUrls from './loader'; import loadUrls from './loader';
import { upgradeAssetsBundle } from './upgrade-assets'; import { upgradeAssetsBundle } from './upgrade-assets';
@ -16,20 +15,6 @@ skeleton.add({
type: 'Widget', type: 'Widget',
content: EventBindDialog, content: EventBindDialog,
}); });
skeleton.add({
name: 'sourceEditor',
type: 'PanelDock',
props: {
align: 'top',
icon: 'code',
description: '组件库',
},
panelProps: {
width: 500
// area: 'leftFixedArea'
},
content: SourceEditor,
});
skeleton.add({ skeleton.add({
area: 'leftArea', area: 'leftArea',
name: 'icon1', name: 'icon1',

View File

@ -9,6 +9,7 @@ import { Skeleton } from './skeleton/skeleton';
import Preview from '@ali/lowcode-plugin-sample-preview'; import Preview from '@ali/lowcode-plugin-sample-preview';
import SourceEditor from '@ali/lowcode-plugin-source-editor';
registerSetters(); registerSetters();
@ -53,3 +54,18 @@ skeleton.add({
}, },
content: Preview, content: Preview,
}); });
skeleton.add({
name: 'sourceEditor',
type: 'PanelDock',
props: {
align: 'top',
icon: 'code',
description: '组件库',
},
panelProps: {
width: 500
// area: 'leftFixedArea'
},
content: SourceEditor,
});