From 2d60109d393f46088e3e8798c8cc68b67477748f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8B=E7=BE=8A?= Date: Tue, 10 Mar 2020 15:34:16 +0800 Subject: [PATCH] daily tag --- packages/editor/package.json | 2 + packages/editor/src/config/components.js | 2 + packages/editor/src/config/skeleton.js | 27 +++- .../editor/src/plugins/designer/index.scss | 5 + .../editor/src/plugins/designer/index.tsx | 137 +++++++++++++++++- .../editor/src/plugins/undoRedo/index.scss | 0 .../editor/src/plugins/undoRedo/index.tsx | 22 +++ .../src/skeleton/layouts/CenterArea/index.tsx | 2 +- 8 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 packages/editor/src/plugins/undoRedo/index.scss create mode 100644 packages/editor/src/plugins/undoRedo/index.tsx diff --git a/packages/editor/package.json b/packages/editor/package.json index f9f4648af..3ebc396ef 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -3,6 +3,8 @@ "version": "0.0.1", "description": "低代码编辑器", "dependencies": { + "@ali/iceluna-addon-2": "^1.0.3", + "@ali/iceluna-sdk": "^1.0.5-beta.26", "@alifd/next": "^1.x", "@alife/dpl-iceluna": "^2.3.2", "@icedesign/theme": "^1.x", diff --git a/packages/editor/src/config/components.js b/packages/editor/src/config/components.js index 7c7041401..fe508c3e0 100644 --- a/packages/editor/src/config/components.js +++ b/packages/editor/src/config/components.js @@ -1,5 +1,6 @@ import logo from '../plugins/logo'; import designer from '../plugins/designer'; +import undoRedo from '../plugins/undoRedo'; import topBalloonIcon from '@ali/iceluna-addon-2'; import topDialogIcon from '@ali/iceluna-addon-2'; import leftPanelIcon from '@ali/iceluna-addon-2'; @@ -16,6 +17,7 @@ import PluginFactory from '../framework/pluginFactory'; export default { logo: PluginFactory(logo), designer: PluginFactory(designer), + undoRedo: PluginFactory(undoRedo), topBalloonIcon: PluginFactory(topBalloonIcon), topDialogIcon: PluginFactory(topDialogIcon), leftPanelIcon: PluginFactory(leftPanelIcon), diff --git a/packages/editor/src/config/skeleton.js b/packages/editor/src/config/skeleton.js index 499283d61..765aa6c10 100644 --- a/packages/editor/src/config/skeleton.js +++ b/packages/editor/src/config/skeleton.js @@ -66,6 +66,25 @@ export default { }, pluginProps: {} }, + { + pluginKey: 'undoRedo', + type: 'Custom', + props: { + align: 'right', + width: 90 + }, + config: { + package: '@ali/lowcode-plugin-undo-redo', + version: '1.0.0' + } + }, + { + pluginKey: 'divider', + type: 'Divider', + props: { + align: 'right' + } + }, { pluginKey: 'topLinkIcon', type: 'LinkIcon', @@ -234,7 +253,13 @@ export default { pluginProps: {} } ], - centerArea: [] + centerArea: [{ + pluginKey: 'designer', + config: { + package: '@ali/lowcode-plugin-designer', + version: '1.0.0' + } + }] }, hooks: [], shortCuts: [] diff --git a/packages/editor/src/plugins/designer/index.scss b/packages/editor/src/plugins/designer/index.scss index e69de29bb..0d512ea9a 100644 --- a/packages/editor/src/plugins/designer/index.scss +++ b/packages/editor/src/plugins/designer/index.scss @@ -0,0 +1,5 @@ +.lowcode-plugin-designer { + background-color: #ffffff; + width: 100%; + height: 100%; +} \ No newline at end of file diff --git a/packages/editor/src/plugins/designer/index.tsx b/packages/editor/src/plugins/designer/index.tsx index d2bbc2ff8..b5b0eda41 100644 --- a/packages/editor/src/plugins/designer/index.tsx +++ b/packages/editor/src/plugins/designer/index.tsx @@ -3,6 +3,8 @@ import React, { PureComponent } from 'react'; import Editor from '../../framework/index'; import { PluginConfig } from '../../framework/definitions'; +import Designer from '../../../../designer/src/designer/designer-view'; + import './index.scss'; export interface PluginProps { @@ -10,10 +12,141 @@ export interface PluginProps { config: PluginConfig; } +const SCHEMA = { + "componentName": "Page", + "fileName": "test", + "dataSource": { + "list": [{ + "id": "getComponentsMap", + "isInit": true, + "type": "doServer", + "options": { + "method": "POST", + "params": { + "libVersionIds": "1" + }, + "uri": "getComponentsMap" + } + }] + }, + "state": { + "text": "outter" + }, + "props": { + "ref": "outterView", + "autoLoading": true + }, + "children": [{ + "componentName": "Form", + "props": { + "labelCol": 4, + "onSubmit": function onSubmit(value, error, field) { + //form内有htmlType="submit"的元素的时候会触发 + alert(JSON.stringify(value)) + }, + "style": {}, + "ref": "testForm" + }, + "children": [{ + "componentName": "FormItem", + "props": { + "label": "姓名:", + "name": "name", + "initValue": "李雷" + }, + "children": [{ + "componentName": "Input", + "props": { + "placeholder": "请输入", + "size": "medium", + "style": { + "width": 320 + } + } + }] + }, { + "componentName": "FormItem", + "props": { + "label": "年龄:", + "name": "age", + "initValue": "22" + }, + "children": [{ + "componentName": "NumberPicker", + "props": { + "size": "medium", + "type": "normal" + } + }] + }, { + "componentName": "FormItem", + "props": { + "label": "职业:", + "name": "profession" + }, + "children": [{ + "componentName": "Select", + "props": { + "dataSource": [{ + "label": "教师", + "value": "t" + }, { + "label": "医生", + "value": "d" + }, { + "label": "歌手", + "value": "s" + }] + } + }] + }, { + "componentName": "Div", + "props": { + "style": { + "textAlign": "center" + } + }, + "children": [{ + "componentName": "ButtonGroup", + "props": {}, + "children": [{ + "componentName": "Button", + "props": { + "type": "primary", + "style": { + "margin": "0 5px 0 5px" + }, + "htmlType": "submit" + }, + "children": "提交" + }, { + "componentName": "Button", + "props": { + "type": "normal", + "style": { + "margin": "0 5px 0 5px" + }, + "htmlType": "reset" + }, + "children": "重置" + }] + }] + }] + }] +} + export default class DesignerPlugin extends PureComponent { static displayName: 'LowcodePluginDesigner'; - constructor(props) {} + constructor(props) { + super(props); + } - render() {} + render() { + return ( +
+ + +
); + } } diff --git a/packages/editor/src/plugins/undoRedo/index.scss b/packages/editor/src/plugins/undoRedo/index.scss new file mode 100644 index 000000000..e69de29bb diff --git a/packages/editor/src/plugins/undoRedo/index.tsx b/packages/editor/src/plugins/undoRedo/index.tsx new file mode 100644 index 000000000..2b1a47460 --- /dev/null +++ b/packages/editor/src/plugins/undoRedo/index.tsx @@ -0,0 +1,22 @@ +import React, {useState} from 'react'; +import './index.scss'; +import Editor from '../../framework/index'; +import { PluginConfig } from '../../framework/definitions'; +import TopIcon from '../../skeleton/components/TopIcon/index'; + +export interface PluginProps { + editor: Editor; + config: PluginConfig; + logo?: string; +} + +export default function(props: PluginProps) { + const [backEnable, setBackEnable] = useState(true); + const [forwardEnable, setForwardEnable] = useState(true); + return ( +
+ + +
+ ); +} diff --git a/packages/editor/src/skeleton/layouts/CenterArea/index.tsx b/packages/editor/src/skeleton/layouts/CenterArea/index.tsx index 21e6a7a71..1389a00e6 100644 --- a/packages/editor/src/skeleton/layouts/CenterArea/index.tsx +++ b/packages/editor/src/skeleton/layouts/CenterArea/index.tsx @@ -40,7 +40,7 @@ export default class CenterArea extends PureComponent {
{visiblePluginList.map(item => { const Comp = this.editor.components[item.pluginKey]; - return ; + return ; })}
);