mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-12 17:08:14 +00:00
fix stage
This commit is contained in:
parent
512a61e841
commit
239a8e40de
@ -95,7 +95,7 @@ export class Prop implements IPropParent {
|
||||
this.items!.forEach((prop, key) => {
|
||||
const v = prop.export(stage);
|
||||
if (v !== UNSET) {
|
||||
maps[key] = v;
|
||||
maps[prop.key == null ? key : prop.key] = v;
|
||||
}
|
||||
});
|
||||
return maps;
|
||||
|
||||
@ -59,8 +59,8 @@ export class PopupPipe {
|
||||
}
|
||||
}
|
||||
|
||||
export default class PopupService extends Component<{ actionKey?: string; safeId?: string }> {
|
||||
private popupPipe = new PopupPipe();
|
||||
export default class PopupService extends Component<{ popupPipe?: PopupPipe; actionKey?: string; safeId?: string }> {
|
||||
private popupPipe = this.props.popupPipe || new PopupPipe();
|
||||
|
||||
componentWillUnmount() {
|
||||
this.popupPipe.purge();
|
||||
@ -121,6 +121,7 @@ export class PopupContent extends PureComponent<{ safeId?: string }> {
|
||||
className="lc-ballon"
|
||||
align="l"
|
||||
id={this.props.safeId}
|
||||
alignEdge
|
||||
safeNode={id}
|
||||
visible={visible}
|
||||
style={{ width }}
|
||||
@ -135,7 +136,7 @@ export class PopupContent extends PureComponent<{ safeId?: string }> {
|
||||
trigger={<div className="lc-popup-placeholder" style={pos} />}
|
||||
triggerType="click"
|
||||
animation={false}
|
||||
// needAdjust
|
||||
needAdjust
|
||||
shouldUpdatePosition
|
||||
>
|
||||
<div className="lc-ballon-title">{title}</div>
|
||||
|
||||
@ -13,10 +13,16 @@
|
||||
}
|
||||
.lc-ballon-content {
|
||||
margin-top: 10px;
|
||||
// width: 300px;
|
||||
// FIXME: popup position is bad
|
||||
max-height: calc(60vh);
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
&.next-balloon-closable {
|
||||
padding: 10px !important;
|
||||
}
|
||||
.next-balloon-close {
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
top: 4px !important;
|
||||
right: 4px !important;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import { Component } from 'react';
|
||||
import { Component, MouseEvent } from 'react';
|
||||
import { shallowIntl, createSetterContent, observer } from '@ali/lowcode-editor-core';
|
||||
import { createContent } from '@ali/lowcode-utils';
|
||||
import { Field, createField } from '../field';
|
||||
import PopupService from '../popup';
|
||||
import PopupService, { PopupPipe } from '../popup';
|
||||
import { SkeletonContext } from '../../context';
|
||||
import { SettingField, isSettingField, SettingTopEntry, SettingEntry } from '@ali/lowcode-designer';
|
||||
import { isSetterConfig, CustomView } from '@ali/lowcode-types';
|
||||
import { intl } from '../../locale';
|
||||
import { Skeleton } from 'editor-skeleton/src/skeleton';
|
||||
|
||||
@observer
|
||||
class SettingFieldView extends Component<{ field: SettingField }> {
|
||||
@ -145,17 +147,54 @@ export function createSettingFieldView(item: SettingField | CustomView, field: S
|
||||
|
||||
@observer
|
||||
export class SettingsPane extends Component<{ target: SettingTopEntry | SettingField }> {
|
||||
static contextType = SkeletonContext;
|
||||
shouldComponentUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private popupPipe = new PopupPipe();
|
||||
private pipe = this.popupPipe.create();
|
||||
|
||||
private handleClick = (e: MouseEvent) => {
|
||||
// compatiable vision stageBox
|
||||
// TODO: optimize these codes
|
||||
const pane = e.currentTarget as HTMLDivElement;
|
||||
let entry: any;
|
||||
function getTarget(node: any): any {
|
||||
if (!pane.contains(node) || (node.nodeName === 'A' && node.getAttribute('href'))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const target = node.dataset ? node.dataset.stageTarget : null;
|
||||
if (target) {
|
||||
entry = node;
|
||||
return target;
|
||||
}
|
||||
return getTarget(node.parentNode);
|
||||
}
|
||||
const target = getTarget(e.target);
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
const skeleton = this.context as Skeleton;
|
||||
if (!skeleton || !skeleton.stages) {
|
||||
return;
|
||||
}
|
||||
const stage = skeleton.stages.container.get(target);
|
||||
if (stage) {
|
||||
this.pipe.send(stage.content, stage.title);
|
||||
this.pipe.show(entry);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { target } = this.props;
|
||||
const items = target.items;
|
||||
return (
|
||||
<div className="lc-settings-pane">
|
||||
<div className="lc-settings-pane" onClick={this.handleClick}>
|
||||
{/* todo: add head for single use */}
|
||||
<PopupService>
|
||||
<PopupService popupPipe={this.popupPipe}>
|
||||
<div className="lc-settings-content">
|
||||
{items.map((item, index) => createSettingFieldView(item, target, index))}
|
||||
</div>
|
||||
|
||||
4
packages/editor-skeleton/src/context.ts
Normal file
4
packages/editor-skeleton/src/context.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { createContext } from 'react';
|
||||
import { Skeleton } from './skeleton';
|
||||
|
||||
export const SkeletonContext = createContext<Skeleton>({} as any);
|
||||
@ -3,5 +3,6 @@ export * from './skeleton';
|
||||
export * from './types';
|
||||
export * from './components/settings';
|
||||
export * from './components/field';
|
||||
export * from './context';
|
||||
|
||||
import './register-defaults';
|
||||
|
||||
@ -11,6 +11,7 @@ import MainArea from './main-area';
|
||||
import BottomArea from './bottom-area';
|
||||
import RightArea from './right-area';
|
||||
import './workbench.less';
|
||||
import { SkeletonContext } from '../context';
|
||||
|
||||
@observer
|
||||
export class Workbench extends Component<{ skeleton: Skeleton, className?: string, topAreaItemClassName?: string }> {
|
||||
@ -22,19 +23,21 @@ export class Workbench extends Component<{ skeleton: Skeleton, className?: strin
|
||||
const { skeleton, className, topAreaItemClassName } = this.props;
|
||||
return (
|
||||
<div className={classNames('lc-workbench', className)}>
|
||||
<TopArea area={skeleton.topArea} itemClassName={topAreaItemClassName} />
|
||||
<div className="lc-workbench-body">
|
||||
<LeftArea area={skeleton.leftArea} />
|
||||
<LeftFloatPane area={skeleton.leftFloatArea} />
|
||||
<LeftFixedPane area={skeleton.leftFixedArea} />
|
||||
<div className="lc-workbench-center">
|
||||
<Toolbar area={skeleton.toolbar} />
|
||||
<MainArea area={skeleton.mainArea} />
|
||||
<BottomArea area={skeleton.bottomArea} />
|
||||
<SkeletonContext.Provider value={this.props.skeleton}>
|
||||
<TopArea area={skeleton.topArea} itemClassName={topAreaItemClassName} />
|
||||
<div className="lc-workbench-body">
|
||||
<LeftArea area={skeleton.leftArea} />
|
||||
<LeftFloatPane area={skeleton.leftFloatArea} />
|
||||
<LeftFixedPane area={skeleton.leftFixedArea} />
|
||||
<div className="lc-workbench-center">
|
||||
<Toolbar area={skeleton.toolbar} />
|
||||
<MainArea area={skeleton.mainArea} />
|
||||
<BottomArea area={skeleton.bottomArea} />
|
||||
</div>
|
||||
<RightArea area={skeleton.rightArea} />
|
||||
</div>
|
||||
<RightArea area={skeleton.rightArea} />
|
||||
</div>
|
||||
<TipContainer />
|
||||
<TipContainer />
|
||||
</SkeletonContext.Provider>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ export interface WidgetConfig extends IWidgetBaseConfig {
|
||||
props?: {
|
||||
align?: "left" | "right" | "bottom" | "center" | "top";
|
||||
onInit?: (widget: IWidget) => void;
|
||||
title?: TitleContent;
|
||||
};
|
||||
content?: string | ReactElement | ComponentType<any>; // children
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import { createContent, uniqueId } from '@ali/lowcode-utils';
|
||||
import { WidgetConfig, IWidgetBaseConfig } from '../types';
|
||||
import { Skeleton } from '../skeleton';
|
||||
import { WidgetView } from '../components/widget-views';
|
||||
import { TitleContent } from '@ali/lowcode-types';
|
||||
|
||||
export interface IWidget {
|
||||
readonly name: string;
|
||||
@ -56,10 +57,13 @@ export default class Widget implements IWidget {
|
||||
});
|
||||
}
|
||||
|
||||
readonly title: TitleContent;
|
||||
|
||||
constructor(readonly skeleton: Skeleton, readonly config: WidgetConfig) {
|
||||
const { props = {}, name } = config;
|
||||
this.name = name;
|
||||
this.align = props.align;
|
||||
this.title = props.title || name;
|
||||
if (props.onInit) {
|
||||
props.onInit.call(this, this);
|
||||
}
|
||||
|
||||
@ -132,7 +132,18 @@ function add(config: (() => OldPaneConfig) | OldPaneConfig, extraConfig?: any) {
|
||||
config = { ...config, ...extraConfig };
|
||||
}
|
||||
|
||||
skeleton.add(upgradeConfig(config));
|
||||
const upgraded = upgradeConfig(config);
|
||||
if (upgraded.area === 'stages') {
|
||||
if (upgraded.id) {
|
||||
upgraded.name = upgraded.id;
|
||||
} else if (!upgraded.name) {
|
||||
upgraded.name = uniqueId('stage');
|
||||
}
|
||||
const stage = skeleton.add(upgraded);
|
||||
return stage?.getName();
|
||||
} else {
|
||||
return skeleton.add(upgraded);
|
||||
}
|
||||
}
|
||||
|
||||
const actionPane = Object.assign(skeleton.topArea, {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user