This commit is contained in:
kangwei 2020-05-05 01:41:05 +08:00
commit 7c3d9ca248
21 changed files with 242 additions and 66 deletions

View File

@ -33,11 +33,15 @@
"@ali/ve-trunk-pane": "^5.1.0-beta.14", "@ali/ve-trunk-pane": "^5.1.0-beta.14",
"@ali/vs-variable-setter": "^3.1.0", "@ali/vs-variable-setter": "^3.1.0",
"@ali/vu-legao-design-fetch-context": "^1.0.3", "@ali/vu-legao-design-fetch-context": "^1.0.3",
"@ali/ve-page-history": "1.2.0",
"@ali/ve-history-pane": "4.0.0",
"@ali/ve-page-history-pane": "^5.0.0-beta.0",
"@alifd/next": "^1.19.12", "@alifd/next": "^1.19.12",
"@alife/theme-lowcode-dark": "^0.1.0", "@alife/theme-lowcode-dark": "^0.1.0",
"@alife/theme-lowcode-light": "^0.1.0", "@alife/theme-lowcode-light": "^0.1.0",
"react": "^16.8.1", "react": "^16.8.1",
"react-dom": "^16.8.1" "react-dom": "^16.8.1",
"@ali/vu-function-parser": "^2.5.0-beta.0"
}, },
"devDependencies": { "devDependencies": {
"@ali/iceluna-cli": "^0.0.16", "@ali/iceluna-cli": "^0.0.16",

View File

@ -2,7 +2,8 @@
"componentName": "Page", "componentName": "Page",
"fileName": "test", "fileName": "test",
"dataSource": { "dataSource": {
"list": [] "list": [],
"online": []
}, },
"state": { "state": {
"text": "outter" "text": "outter"

View File

@ -1,10 +1,13 @@
/* eslint-disable */ /* eslint-disable */
import { createElement } from 'react'; import { createElement } from 'react';
import { Button } from '@alifd/next'; import { Button } from '@alifd/next';
import Engine, { Panes } from '@ali/visualengine'; import Engine, { Panes, Prototype } from '@ali/visualengine';
import { ActionUtil as actionUtil } from '@ali/visualengine-utils'; import { ActionUtil as actionUtil } from '@ali/visualengine-utils';
import getTrunkPane from '@ali/ve-trunk-pane'; import getTrunkPane from '@ali/ve-trunk-pane';
import DatapoolPane from '@ali/ve-datapool-pane'; import DatapoolPane from '@ali/ve-datapool-pane';
import PageHistoryManager from '@ali/ve-page-history';
import HistoryPane from '@ali/ve-history-pane';
import PageHistoryPane from '@ali/ve-page-history-pane';
// import I18nPane from '@ali/ve-i18n-pane'; // import I18nPane from '@ali/ve-i18n-pane';
import I18nManagePane from '@ali/ve-i18n-manage-pane'; import I18nManagePane from '@ali/ve-i18n-manage-pane';
import ActionPane from '@ali/ve-action-pane'; import ActionPane from '@ali/ve-action-pane';
@ -15,6 +18,9 @@ import { upgradeAssetsBundle } from './upgrade-assets';
import { isCSSUrl } from '@ali/lowcode-utils'; import { isCSSUrl } from '@ali/lowcode-utils';
import { I18nSetter } from '@ali/visualengine-utils'; import { I18nSetter } from '@ali/visualengine-utils';
import VariableSetter from '@ali/vs-variable-setter'; import VariableSetter from '@ali/vs-variable-setter';
import { isObject, isArray } from 'lodash';
import funcParser from '@ali/vu-function-parser';
const { editor, skeleton, context, HOOKS, Trunk } = Engine; const { editor, skeleton, context, HOOKS, Trunk } = Engine;
@ -137,20 +143,20 @@ function initDemoPanes() {
children: '保存', children: '保存',
}), }),
}); });
skeleton.add({ // skeleton.add({
area: 'topArea', // area: 'topArea',
type: 'Dock', // type: 'Dock',
name: 'preview4', // name: 'preview4',
props: { // props: {
align: 'center', // align: 'center',
}, // },
content: createElement('img', { // content: createElement('img', {
src: 'https://img.alicdn.com/tfs/TB1WW.VC.z1gK0jSZLeXXb9kVXa-486-64.png', // src: 'https://img.alicdn.com/tfs/TB1WW.VC.z1gK0jSZLeXXb9kVXa-486-64.png',
style: { // style: {
height: 32, // height: 32,
}, // },
}), // }),
}); // });
skeleton.add({ skeleton.add({
area: 'topArea', area: 'topArea',
type: 'Dock', type: 'Dock',
@ -321,6 +327,87 @@ function initActionPane() {
props, props,
}); });
} }
function replaceFuncProp(props?: any){
const replaceProps = {};
for (const name in props) {
const prop = props[name];
if (!prop) {
continue;
}
if ((prop.compiled && prop.source) || prop.type === 'actionRef' || prop.type === 'js') {
replaceProps[name] = funcParser(prop);
} else if (isObject(prop)) {
replaceFuncProp(prop);
} else if (isArray(prop)) {
prop.map((propItem) => {
replaceFuncProp(propItem);
});
}
}
for (const name in replaceProps) {
props[name] = replaceProps[name];
}
return props;
};
// 操作历史与页面历史面板
function initHistoryPane() {
// let historyConfigs = {getDesignerModuleConfigs(
// this.designerConfigs,
// 'history',
// )};
let historyConfigs = {
enableRedoAndUndo: true,
enablePageHistory: true,
};;
const isDemoMode = false;
const isEnvSupportsHistoryPane = true;
const historyManager = PageHistoryManager.getManager();
console.log('PageHistoryManager', historyManager);
console.log('PageHistoryManager.onOpenPane', historyManager.onOpenPane);
// 历史撤销、重做以及唤起页面历史按钮
if (typeof HistoryPane === 'function') {
Panes.add(HistoryPane, {
props : {
showPageHistory:
isEnvSupportsHistoryPane
// && this.app.isForm()
&& !isDemoMode,
historyManager,
historyConfigs,
index: -940,
}
});
} else {
Panes.add(HistoryPane, {
index: -940,
});
}
// 页面历史 UI 面板
if (
PageHistoryPane
&& !isDemoMode
&& isEnvSupportsHistoryPane
) {
Panes.add(PageHistoryPane, {
props : {
historyManager: {
historyManager,
app: {
}
},
index: -940,
},
});
}
}
async function init() { async function init() {
Engine.Env.setEnv('RE_VERSION', '7.2.0'); Engine.Env.setEnv('RE_VERSION', '7.2.0');
@ -328,6 +415,7 @@ async function init() {
subview: true, subview: true,
i18nPane: true, i18nPane: true,
}); });
Prototype.addGlobalPropsReducer(replaceFuncProp);
await loadAssets(); await loadAssets();
await loadSchema(); await loadSchema();
await initTrunkPane(); await initTrunkPane();
@ -335,7 +423,7 @@ async function init() {
initI18nPane(); initI18nPane();
initActionPane(); initActionPane();
initDemoPanes(); initDemoPanes();
initHistoryPane();
Engine.init(); Engine.init();
} }
init(); init();

View File

@ -1,8 +1,12 @@
declare module "@ali/visualengine"; declare module '@ali/visualengine';
declare module "@ali/visualengine-utils"; declare module '@ali/visualengine-utils';
declare module "@ali/ve-trunk-pane"; declare module '@ali/ve-trunk-pane';
declare module "@ali/vs-variable-setter"; declare module '@ali/vs-variable-setter';
declare module "@ali/ve-datapool-pane"; declare module '@ali/ve-datapool-pane';
declare module "@ali/ve-i18n-manage-pane"; declare module '@ali/ve-history-pane';
declare module "@ali/ve-action-pane"; declare module '@ali/ve-page-history-pane';
declare module "@ali/vu-legao-design-fetch-context"; declare module '@ali/ve-page-history';
declare module '@ali/ve-i18n-manage-pane';
declare module '@ali/ve-action-pane';
declare module '@ali/vu-legao-design-fetch-context';
declare module "@ali/vu-function-parser";

View File

@ -1,12 +1,16 @@
// all this file for polyfill vision logic
import { isValidElement } from 'react';
function getHotterFromSetter(setter) { function getHotterFromSetter(setter) {
return setter && (setter.Hotter || (setter.type && setter.type.Hotter)) || []; // eslint-disable-line return setter && (setter.Hotter || (setter.type && setter.type.Hotter)) || []; // eslint-disable-line
} }
function getTransducerFromSetter(setter) { function getTransducerFromSetter(setter) {
return setter && ( return setter && (
setter.transducer || setter.Transducer setter.transducer || setter.Transducer
|| (setter.type && (setter.type.transducer || setter.type.Transducer)) || (setter.type && (setter.type.transducer || setter.type.Transducer))
) || null; // eslint-disable-line ) || null; // eslint-disable-line
} }
function combineTransducer(transducer, arr, context) { function combineTransducer(transducer, arr, context) {
@ -23,9 +27,22 @@ function combineTransducer(transducer, arr, context) {
export class Transducer { export class Transducer {
constructor(context, config) { constructor(context, config) {
let { setter } = config;
// 1. validElement
// 2. SetterConfig
// 3. SetterConfig[]
if (Array.isArray(setter)) {
setter = setter[0];
} else if (isValidElement(setter) && setter.type.displayName === 'MixedSetter') {
setter = setter.props.setters[0];
} else if (typeof setter === 'object' && setter.componentName === 'MixedSetter') {
setter = setter.props.setters[0];
}
this.setterTransducer = combineTransducer( this.setterTransducer = combineTransducer(
getTransducerFromSetter(config.setter), getTransducerFromSetter(setter),
getHotterFromSetter(config.setter), getHotterFromSetter(setter),
context, context,
); );
this.context = context; this.context = context;

View File

@ -12,8 +12,8 @@ import { uniqueId } from '@ali/lowcode-utils';
export type GetDataType<T, NodeType> = T extends undefined export type GetDataType<T, NodeType> = T extends undefined
? NodeType extends { ? NodeType extends {
schema: infer R; schema: infer R;
} }
? R ? R
: any : any
: T; : T;
@ -465,6 +465,14 @@ export class DocumentModel {
getRoot() { getRoot() {
return this.rootNode; return this.rootNode;
} }
/**
* vision
*/
getHistory(): History {
return this.history;
}
get root() { get root() {
return this.rootNode; return this.rootNode;
} }

View File

@ -155,6 +155,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
private transformProps(props: any): any { private transformProps(props: any): any {
// FIXME! support PropsList // FIXME! support PropsList
return this.document.designer.transformProps(props, this, TransformStage.Init); return this.document.designer.transformProps(props, this, TransformStage.Init);
// TODO: run transducers in metadata.experimental // TODO: run transducers in metadata.experimental
} }

View File

@ -115,6 +115,8 @@ export default class MixedSetter extends Component<{
className?: string; className?: string;
}> { }> {
private setters = nomalizeSetters(this.props.setters); private setters = nomalizeSetters(this.props.setters);
// set name ,used in setting Transducer
static displayName = 'MixedSetter';
@obx.ref private used?: string; @obx.ref private used?: string;
@computed private getCurrentSetter() { @computed private getCurrentSetter() {
const { field } = this.props; const { field } = this.props;

View File

@ -25,7 +25,7 @@
border-radius: 3px; border-radius: 3px;
} }
} }
.next-input,.next-date-picker { .next-input,.next-date-picker,.next-month-picker {
width: 100%; width: 100%;
} }
&.lc-block-setter { &.lc-block-setter {

View File

@ -1,6 +1,7 @@
import { Component, ReactElement } from 'react'; import { Component, ReactElement } from 'react';
import { Icon } from '@alifd/next';
import classNames from 'classnames'; import classNames from 'classnames';
import { Title, observer } from '@ali/lowcode-editor-core'; import { Title, observer, Tip } from '@ali/lowcode-editor-core';
import { DockProps } from '../types'; import { DockProps } from '../types';
import PanelDock from '../widget/panel-dock'; import PanelDock from '../widget/panel-dock';
import { composeTitle } from '../widget/utils'; import { composeTitle } from '../widget/utils';
@ -21,6 +22,25 @@ export function DockView({ title, icon, description, size, className, onClick }:
); );
} }
function HelpTip({ tip }: any) {
if (tip && tip.url) {
return (
<div>
<a href={tip.url} target="_blank" rel="noopener noreferrer">
<Icon type="help" size="small" className="lc-help-tip"/>
</a>
<Tip>{tip.content}</Tip>
</div>
);
}
return (
<div>
<Icon type="help" size="small" className="lc-help-tip"/>
<Tip>{tip.content}</Tip>
</div>
)
}
@observer @observer
export class PanelDockView extends Component<DockProps & { dock: PanelDock }> { export class PanelDockView extends Component<DockProps & { dock: PanelDock }> {
componentDidMount() { componentDidMount() {
@ -196,7 +216,7 @@ class PanelTitle extends Component<{ panel: Panel; className?: string }> {
data-name={panel.name} data-name={panel.name}
> >
<Title title={panel.title || panel.name} /> <Title title={panel.title || panel.name} />
{/*pane.help ? <HelpTip tip={panel.help} /> : null*/} {panel.help ? <HelpTip tip={panel.help} /> : null}
</div> </div>
); );
} }

View File

@ -13,21 +13,26 @@ export default class LeftFixedPane extends Component<{ area: Area<PanelConfig, P
} }
render() { render() {
const { area } = this.props; const { area } = this.props;
const hideTitleBar = area.current?.config.props?.hideTitleBar;
return ( return (
<div <div
className={classNames('lc-left-fixed-pane', { className={classNames('lc-left-fixed-pane', {
'lc-area-visible': area.visible, 'lc-area-visible': area.visible,
})} })}
> >
<Button {
text !hideTitleBar && (
className="lc-pane-close" <Button
onClick={() => { text
area.setVisible(false); className="lc-pane-close"
}} onClick={() => {
> area.setVisible(false);
<Icon type="close" /> }}
</Button> >
<Icon type="close" />
</Button>
)
}
<Contents area={area} /> <Contents area={area} />
</div> </div>
); );

View File

@ -32,6 +32,7 @@ export default class LeftFloatPane extends Component<{ area: Area<any, Panel> }>
// focusout remove focus // focusout remove focus
// onEsc // onEsc
const width = area.current?.config.props?.width; const width = area.current?.config.props?.width;
const hideTitleBar = area.current?.config.props?.hideTitleBar;
const style = width ? { const style = width ? {
width width
} : undefined; } : undefined;
@ -42,15 +43,19 @@ export default class LeftFloatPane extends Component<{ area: Area<any, Panel> }>
})} })}
style={style} style={style}
> >
<Button {
text !hideTitleBar && (
className="lc-pane-close" <Button
onClick={() => { text
area.setVisible(false); className="lc-pane-close"
}} onClick={() => {
> area.setVisible(false);
<Icon type="close" /> }}
</Button> >
<Icon type="close" />
</Button>
)
}
<Contents area={area} /> <Contents area={area} />
</div> </div>
); );

View File

@ -57,4 +57,6 @@
--color-block-background-deep-dark: @normal-5; --color-block-background-deep-dark: @normal-5;
--color-layer-mask-background: @dark-alpha-7; --color-layer-mask-background: @dark-alpha-7;
--color-layer-tooltip-background: rgba(44,47,51,0.8); --color-layer-tooltip-background: rgba(44,47,51,0.8);
--pane-title-bg-color: rgba(31,56,88,.04);
} }

View File

@ -24,7 +24,11 @@ class Contents extends Component<{ area: Area }> {
const left: any[] = []; const left: any[] = [];
const center: any[] = []; const center: any[] = [];
const right: any[] = []; const right: any[] = [];
area.container.items.forEach(item => { area.container.items.sort((a,b) => {
const index1 = a.config?.index || 0;
const index2 = b.config?.index || 0;
return index1 === index2 ? 0 : (index1 > index2 ? 1 : -1);
}).forEach(item => {
if (item.align === 'center') { if (item.align === 'center') {
center.push(item.content); center.push(item.content);
} else if (item.align === 'left') { } else if (item.align === 'left') {

View File

@ -54,19 +54,25 @@ body {
display: none; display: none;
} }
.lc-panel-title { .lc-panel-title {
height: 32px; height: 38px;
background-color: var(--pane-title-bg-color); font-size: 14px;
background-color: var(--pane-title-bg-color,rgba(31,56,88,.04));
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center;
padding: 0 15px; padding: 0 15px;
border-bottom: 1px solid var(--color-line-normal,rgba(31,56,88,.1));
.lc-help-tip { .lc-help-tip {
margin-left: 4px; margin-left: 4px;
color: rgba(0,0,0,0.4);
cursor: pointer;
} }
} }
.lc-panel-body { .lc-panel-body {
position: absolute; position: absolute;
top: 32px; top: 38px;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;

View File

@ -64,7 +64,7 @@ export default class PanelDock implements IWidget {
name: this.panelName, name: this.panelName,
props: { props: {
// FIXME! give default title for panel // FIXME! give default title for panel
// title: props ? composeTitle(props?.title, props?.icon, props?.description, true) : '', title: props ? composeTitle(props?.title, props?.icon, props?.description, true) : '',
...panelProps, ...panelProps,
}, },
contentProps, contentProps,

View File

@ -74,8 +74,6 @@ export default class Panel implements IWidget {
); );
content.forEach((item) => this.add(item)); content.forEach((item) => this.add(item));
} }
// compatiable for vision, init at first
this.initBody();
// todo: process shortcut // todo: process shortcut
} }

View File

@ -334,7 +334,7 @@ class Calendar extends Component {
[CALENDAR_MODE_MONTH]: <MonthPanelHeader {...headerProps} />, [CALENDAR_MODE_MONTH]: <MonthPanelHeader {...headerProps} />,
[CALENDAR_MODE_YEAR]: <YearPanelHeader {...headerProps} />, [CALENDAR_MODE_YEAR]: <YearPanelHeader {...headerProps} />,
}; };
return ( return (
<div <div
{...obj.pickOthers(Calendar.propTypes, others)} {...obj.pickOthers(Calendar.propTypes, others)}

View File

@ -5,6 +5,7 @@ import {
addBuiltinComponentAction, addBuiltinComponentAction,
isComponentMeta, isComponentMeta,
registerMetadataTransducer, registerMetadataTransducer,
TransformStage,
} from '@ali/lowcode-designer'; } from '@ali/lowcode-designer';
import { import {
OldPropConfig, OldPropConfig,
@ -112,9 +113,10 @@ function addGlobalExtraActions(action: () => ReactElement) {
upgradeActions(action)?.forEach(addBuiltinComponentAction); upgradeActions(action)?.forEach(addBuiltinComponentAction);
} }
const GlobalPropsReducers: any[] = []; // const GlobalPropsReducers: any[] = [];
function addGlobalPropsReducer(reducer: () => any) { function addGlobalPropsReducer(reducer: () => any) {
GlobalPropsReducers.push(reducer); // GlobalPropsReducers.push(reducer);
designer.addPropsReducer(reducer, TransformStage.Render);
} }
export interface OldGlobalPropConfig extends OldPropConfig { export interface OldGlobalPropConfig extends OldPropConfig {

View File

@ -1,6 +1,6 @@
import { skeleton, editor } from './editor'; import { skeleton, editor } from './editor';
import { ReactElement } from 'react'; import { ReactElement } from 'react';
import { IWidgetBaseConfig } from '@ali/lowcode-editor-skeleton'; import { IWidgetBaseConfig, Skeleton } from '@ali/lowcode-editor-skeleton';
import { uniqueId } from '@ali/lowcode-utils'; import { uniqueId } from '@ali/lowcode-utils';
export interface IContentItemConfig { export interface IContentItemConfig {
@ -63,7 +63,7 @@ function upgradeConfig(config: OldPaneConfig): IWidgetBaseConfig & { area: strin
onDestroy: destroy, onDestroy: destroy,
}, },
contentProps: props, contentProps: props,
index, index: index || props?.index,
}; };
if (type === 'dock') { if (type === 'dock') {
newConfig.type = 'PanelDock'; newConfig.type = 'PanelDock';
@ -85,6 +85,7 @@ function upgradeConfig(config: OldPaneConfig): IWidgetBaseConfig & { area: strin
} }
if (!isAction) { if (!isAction) {
newConfig.panelProps = { newConfig.panelProps = {
title,
hideTitleBar, hideTitleBar,
help: tip, help: tip,
width, width,
@ -156,6 +157,10 @@ const dockPane = Object.assign(skeleton.leftArea, {
* compatible *VE.dockPane.activeDock* * compatible *VE.dockPane.activeDock*
*/ */
activeDock(item: any) { activeDock(item: any) {
if (!item) {
skeleton.leftFloatArea?.current?.hide();
return;
}
const name = item.name || item; const name = item.name || item;
skeleton.getPanel(name)?.active(); skeleton.getPanel(name)?.active();
}, },

View File

@ -96,3 +96,7 @@ html.engine-blur #engine {
pointer-events: auto !important; pointer-events: auto !important;
} }
} }
.lc-left-float-pane {
font-size: 14px;
}