mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 05:48:17 +00:00
Merge branch 'polyfill/vision' of gitlab.alibaba-inc.com:ali-lowcode/ali-lowcode-engine into polyfill/vision
This commit is contained in:
commit
e52b4c6bb3
@ -20,6 +20,7 @@ import { IconComponent } from './icons/component';
|
|||||||
import { IconRemove } from './icons/remove';
|
import { IconRemove } from './icons/remove';
|
||||||
import { IconClone } from './icons/clone';
|
import { IconClone } from './icons/clone';
|
||||||
import { ReactElement } from 'react';
|
import { ReactElement } from 'react';
|
||||||
|
import { IconHidden } from './icons/hidden';
|
||||||
|
|
||||||
function ensureAList(list?: string | string[]): string[] | null {
|
function ensureAList(list?: string | string[]): string[] | null {
|
||||||
if (!list) {
|
if (!list) {
|
||||||
@ -341,6 +342,20 @@ const builtinComponentActions: ComponentAction[] = [
|
|||||||
},
|
},
|
||||||
important: true,
|
important: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'hide',
|
||||||
|
content: {
|
||||||
|
icon: IconHidden,
|
||||||
|
title: intlNode('hide'),
|
||||||
|
action(node: Node) {
|
||||||
|
node.getExtraProp('hidden', true)?.setValue(true);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
condition: (node: Node) => {
|
||||||
|
return node.componentMeta.isModal;
|
||||||
|
},
|
||||||
|
important: true,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export function removeBuiltinComponentAction(name: string) {
|
export function removeBuiltinComponentAction(name: string) {
|
||||||
|
|||||||
@ -461,14 +461,16 @@ export class DocumentModel {
|
|||||||
return config.checkNestingDown(parent, obj) && this.checkNestingUp(parent, obj);
|
return config.checkNestingDown(parent, obj) && this.checkNestingUp(parent, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======= compatibles
|
// ======= compatibles for vision
|
||||||
getRoot() {
|
getRoot() {
|
||||||
return this.rootNode;
|
return this.rootNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// add toData
|
||||||
* 兼容vision
|
toData() {
|
||||||
*/
|
return { componentsTree: [this.project?.currentDocument?.export()] };
|
||||||
|
}
|
||||||
|
|
||||||
getHistory(): History {
|
getHistory(): History {
|
||||||
return this.history;
|
return this.history;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"copy": "Copy",
|
"copy": "Copy",
|
||||||
"remove": "Remove",
|
"remove": "Remove",
|
||||||
|
"hide": "Hide",
|
||||||
"Condition Group": "Condition Group",
|
"Condition Group": "Condition Group",
|
||||||
"No opened document": "No opened document, open some document to editing"
|
"No opened document": "No opened document, open some document to editing"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"copy": "复制",
|
"copy": "复制",
|
||||||
"remove": "删除",
|
"remove": "删除",
|
||||||
|
"hide": "隐藏",
|
||||||
"Condition Group": "条件组",
|
"Condition Group": "条件组",
|
||||||
"No opened document": "没有打开的页面,请选择页面打开编辑"
|
"No opened document": "没有打开的页面,请选择页面打开编辑"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,23 +4,23 @@ import { observer } from '@ali/lowcode-editor-core';
|
|||||||
import Area from '../area';
|
import Area from '../area';
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export default class TopArea extends Component<{ area: Area }> {
|
export default class TopArea extends Component<{ area: Area, itemClassName?: string }> {
|
||||||
render() {
|
render() {
|
||||||
const { area } = this.props;
|
const { area, itemClassName } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className={classNames("lc-top-area engine-actionpane", {
|
<div className={classNames("lc-top-area engine-actionpane", {
|
||||||
'lc-area-visible': area.visible
|
'lc-area-visible': area.visible
|
||||||
})}>
|
})}>
|
||||||
<Contents area={area} />
|
<Contents area={area} itemClassName={itemClassName} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
class Contents extends Component<{ area: Area }> {
|
class Contents extends Component<{ area: Area, itemClassName?: string }> {
|
||||||
render() {
|
render() {
|
||||||
const { area } = this.props;
|
const { area, itemClassName } = this.props;
|
||||||
const left: any[] = [];
|
const left: any[] = [];
|
||||||
const center: any[] = [];
|
const center: any[] = [];
|
||||||
const right: any[] = [];
|
const right: any[] = [];
|
||||||
@ -29,12 +29,17 @@ class Contents extends Component<{ area: Area }> {
|
|||||||
const index2 = b.config?.index || 0;
|
const index2 = b.config?.index || 0;
|
||||||
return index1 === index2 ? 0 : (index1 > index2 ? 1 : -1);
|
return index1 === index2 ? 0 : (index1 > index2 ? 1 : -1);
|
||||||
}).forEach(item => {
|
}).forEach(item => {
|
||||||
|
const content = (
|
||||||
|
<div className={itemClassName || ''}>
|
||||||
|
{item.content}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
if (item.align === 'center') {
|
if (item.align === 'center') {
|
||||||
center.push(item.content);
|
center.push(content);
|
||||||
} else if (item.align === 'left') {
|
} else if (item.align === 'left') {
|
||||||
left.push(item.content);
|
left.push(content);
|
||||||
} else {
|
} else {
|
||||||
right.push(item.content);
|
right.push(content);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -185,12 +185,12 @@ body {
|
|||||||
display: flex;
|
display: flex;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
.lc-top-area-left{}
|
|
||||||
.lc-top-area-center{
|
.lc-top-area-center{
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: center;
|
||||||
margin-right: 8px;
|
margin: 0 8px;
|
||||||
}
|
}
|
||||||
.lc-top-area-right{
|
.lc-top-area-right{
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -268,6 +268,13 @@ body {
|
|||||||
.lc-title{
|
.lc-title{
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
width: 46px;
|
||||||
|
height: 46px;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
fill: var(--color-icon-normal,rgba(31,56,88,.4));
|
||||||
|
}
|
||||||
|
|
||||||
&.has-tip{
|
&.has-tip{
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
@ -324,6 +331,7 @@ body {
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
z-index: 10;
|
||||||
.lc-toolbar {
|
.lc-toolbar {
|
||||||
height: var(--toolbar-height);
|
height: var(--toolbar-height);
|
||||||
background-color: var(--color-pane-background);
|
background-color: var(--color-pane-background);
|
||||||
|
|||||||
@ -13,16 +13,16 @@ import RightArea from './right-area';
|
|||||||
import './workbench.less';
|
import './workbench.less';
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class Workbench extends Component<{ skeleton: Skeleton, className?: string }> {
|
export class Workbench extends Component<{ skeleton: Skeleton, className?: string, topAreaItemClassName?: string }> {
|
||||||
shouldComponentUpdate() {
|
shouldComponentUpdate() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { skeleton, className } = this.props;
|
const { skeleton, className, topAreaItemClassName } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className={classNames('lc-workbench', className)}>
|
<div className={classNames('lc-workbench', className)}>
|
||||||
<TopArea area={skeleton.topArea} />
|
<TopArea area={skeleton.topArea} itemClassName={topAreaItemClassName} />
|
||||||
<div className="lc-workbench-body">
|
<div className="lc-workbench-body">
|
||||||
<LeftArea area={skeleton.leftArea} />
|
<LeftArea area={skeleton.leftArea} />
|
||||||
<LeftFloatPane area={skeleton.leftFloatArea} />
|
<LeftFloatPane area={skeleton.leftFloatArea} />
|
||||||
|
|||||||
@ -183,8 +183,12 @@ export default function(metadata: TransformedComponentMetadata): TransformedComp
|
|||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
name: '___condition',
|
name: '___condition',
|
||||||
title: { type: 'i18n', 'zh-CN': '条件显示', 'en-US': 'Condition' },
|
title: { type: 'i18n', 'zh-CN': '是否渲染', 'en-US': 'Condition' },
|
||||||
setter: 'ExpressionSetter',
|
setter: [{
|
||||||
|
componentName: 'BoolSetter',
|
||||||
|
}, {
|
||||||
|
componentName: 'VariableSetter'
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '#loop',
|
name: '#loop',
|
||||||
@ -193,27 +197,14 @@ export default function(metadata: TransformedComponentMetadata): TransformedComp
|
|||||||
{
|
{
|
||||||
name: '___loop',
|
name: '___loop',
|
||||||
title: { type: 'i18n', 'zh-CN': '循环数据', 'en-US': 'Loop Data' },
|
title: { type: 'i18n', 'zh-CN': '循环数据', 'en-US': 'Loop Data' },
|
||||||
setter: {
|
setter: [{
|
||||||
componentName: 'MixinSetter',
|
componentName: 'JsonSetter',
|
||||||
props: {
|
props: {
|
||||||
// TODO:
|
label: { type: 'i18n', 'zh-CN': '编辑数据', 'en-US': 'Edit Data'},
|
||||||
setters: [
|
|
||||||
{
|
|
||||||
componentName: 'JSONSetter',
|
|
||||||
props: {
|
|
||||||
mode: 'popup',
|
|
||||||
placeholder: { type: 'i18n', 'zh-CN': '编辑数据', 'en-US': 'Edit Data' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
componentName: 'ExpressionSetter',
|
|
||||||
props: {
|
|
||||||
placeholder: { type: 'i18n', 'zh-CN': '绑定数据', 'en-US': 'Bind Data' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
componentName: 'VariableSetter'
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '___loopArgs.0',
|
name: '___loopArgs.0',
|
||||||
@ -237,8 +228,12 @@ export default function(metadata: TransformedComponentMetadata): TransformedComp
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'key',
|
name: 'key',
|
||||||
title: 'Key',
|
title: '循环 Key',
|
||||||
setter: 'ExpressionSetter',
|
setter: [{
|
||||||
|
componentName: 'StringSetter',
|
||||||
|
}, {
|
||||||
|
componentName: 'VariableSetter'
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -126,7 +126,7 @@ export default class TreeTitle extends Component<{
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{isCNode && isNodeParent && <HideBtn treeNode={treeNode} />}
|
{isCNode && isNodeParent && <HideBtn treeNode={treeNode} />}
|
||||||
{isCNode && isNodeParent && <LockBtn treeNode={treeNode} />}
|
{/*isCNode && isNodeParent && <LockBtn treeNode={treeNode} />*/}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -228,6 +228,11 @@ export default class BaseEngine extends PureComponent {
|
|||||||
|
|
||||||
let Comp = components[schema.componentName] || Div;
|
let Comp = components[schema.componentName] || Div;
|
||||||
|
|
||||||
|
console.info('node schema', schema, engine.props);
|
||||||
|
if (schema.hidden) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (schema.loop !== undefined) {
|
if (schema.loop !== undefined) {
|
||||||
return this.__createLoopVirtualDom(
|
return this.__createLoopVirtualDom(
|
||||||
{
|
{
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
"@recore/obx-react": "^1.0.7",
|
"@recore/obx-react": "^1.0.7",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"react": "^16",
|
"react": "^16",
|
||||||
|
"@ali/vu-css-style": "^1.0.2",
|
||||||
"react-dom": "^16.7.0"
|
"react-dom": "^16.7.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import LowCodeRenderer from '@ali/lowcode-react-renderer';
|
import LowCodeRenderer from '@ali/lowcode-react-renderer';
|
||||||
|
import { isObject } from 'lodash';
|
||||||
import { ReactInstance, Fragment, Component, createElement } from 'react';
|
import { ReactInstance, Fragment, Component, createElement } from 'react';
|
||||||
import { observer } from '@recore/obx-react';
|
import { observer } from '@recore/obx-react';
|
||||||
import { SimulatorRenderer } from './renderer';
|
import { SimulatorRenderer } from './renderer';
|
||||||
import { host } from './host';
|
import { host } from './host';
|
||||||
import './renderer.less';
|
import './renderer.less';
|
||||||
|
import { toCss } from '@ali/vu-css-style';
|
||||||
|
|
||||||
// patch cloneElement avoid lost keyProps
|
// patch cloneElement avoid lost keyProps
|
||||||
const originCloneElement = window.React.cloneElement;
|
const originCloneElement = window.React.cloneElement;
|
||||||
@ -84,6 +86,10 @@ class Renderer extends Component<{ renderer: SimulatorRenderer }> {
|
|||||||
const { __id, __desingMode, ...viewProps } = props;
|
const { __id, __desingMode, ...viewProps } = props;
|
||||||
viewProps.componentId = __id;
|
viewProps.componentId = __id;
|
||||||
viewProps._leaf = host.document.getNode(__id);
|
viewProps._leaf = host.document.getNode(__id);
|
||||||
|
|
||||||
|
// FIXME: 此处未来使用propsReducer方式处理
|
||||||
|
this.createNodeStyleSheet(viewProps);
|
||||||
|
|
||||||
return createElement(
|
return createElement(
|
||||||
Component,
|
Component,
|
||||||
viewProps,
|
viewProps,
|
||||||
@ -99,4 +105,28 @@ class Renderer extends Component<{ renderer: SimulatorRenderer }> {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
createNodeStyleSheet(props: any) {
|
||||||
|
if (props && props.fieldId) {
|
||||||
|
let styleProp = props.__style__;
|
||||||
|
|
||||||
|
if (isObject(styleProp)) {
|
||||||
|
styleProp = toCss(styleProp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof styleProp === 'string') {
|
||||||
|
const s = document.createElement('style');
|
||||||
|
const cssId = '_style_pesudo_' + props.fieldId;
|
||||||
|
const cssClass = '_css_pesudo_' + props.fieldId;
|
||||||
|
|
||||||
|
props.className = cssClass;
|
||||||
|
s.setAttribute('type', 'text/css');
|
||||||
|
s.setAttribute('id', cssId);
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(s);
|
||||||
|
|
||||||
|
s.appendChild(document.createTextNode(styleProp.replace(/:root/g, '.' + cssClass)));
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,6 +44,7 @@ function init(container?: Element) {
|
|||||||
createElement(Workbench, {
|
createElement(Workbench, {
|
||||||
skeleton,
|
skeleton,
|
||||||
className: 'engine-main',
|
className: 'engine-main',
|
||||||
|
topAreaItemClassName: 'engine-actionitem',
|
||||||
}),
|
}),
|
||||||
container,
|
container,
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user