feat: the advanced.autoruns parameter uses a shell wrapper

This commit is contained in:
liujuping 2023-01-30 11:13:40 +08:00 committed by 林熠
parent 6482609ac1
commit 5cf395957c
3 changed files with 29 additions and 3 deletions

View File

@ -27,6 +27,7 @@ import { ExclusiveGroup, isExclusiveGroup } from './exclusive-group';
import { includeSlot, removeSlot } from '../../utils/slot';
import { foreachReverse } from '../../utils/tree';
import { NodeRemoveOptions, EDITOR_EVENT } from '../../types';
import { Prop as ShellProp } from '@alilc/lowcode-shell';
export interface NodeStatus {
locking: boolean;
@ -376,7 +377,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
}
this.autoruns = autoruns.map((item) => {
return autorun(() => {
item.autorun(this.props.get(item.name, true) as any);
item.autorun(ShellProp.create(this.props.get(item.name, true))!);
});
});
}

View File

@ -44,6 +44,8 @@ export interface IProps extends Omit<IPublicModelProps, 'getProp' | 'getExtraPro
getNode(): INode;
getProp(path: string): IProp | null;
get(path: string, createIfNone: boolean): Prop;
}
export class Props implements IProps, IPropParent {

View File

@ -1,31 +1,37 @@
import { IPublicTypePropType, IPublicTypeComponentAction } from './';
import { IPublicModelSettingTarget } from '../model';
import { IPublicModelProp, IPublicModelSettingTarget } from '../model';
/**
* 嵌套控制函数
*/
export type IPublicTypeNestingFilter = (testNode: any, currentNode: any) => boolean;
/**
* 嵌套控制
* 防止错误的节点嵌套,比如 a 嵌套 a, FormField 只能在 Form 容器下,Column 只能在 Table 下等
*/
export interface IPublicTypeNestingRule {
/**
* 子级白名单
*/
childWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/**
* 父级白名单
*/
parentWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/**
* 后裔白名单
*/
descendantWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/**
* 后裔黑名单
*/
descendantBlacklist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/**
* 祖先白名单 可用来做区域高亮
*/
@ -36,22 +42,27 @@ export interface IPublicTypeNestingRule {
* 组件能力配置
*/
export interface IPublicTypeComponentConfigure {
/**
* 是否容器组件
*/
isContainer?: boolean;
/**
* 组件是否带浮层,浮层组件拖入设计器时会遮挡画布区域,此时应当辅助一些交互以防止阻挡
*/
isModal?: boolean;
/**
* 是否存在渲染的根节点
*/
isNullNode?: boolean;
/**
* 组件树描述信息
*/
descriptor?: string;
/**
* 嵌套控制:防止错误的节点嵌套
* 比如 a 嵌套 a, FormField 只能在 Form 容器下,Column 只能在 Table 下等
@ -68,10 +79,12 @@ export interface IPublicTypeComponentConfigure {
* 组件选中框的 cssSelector
*/
rootSelector?: string;
/**
* 禁用的行为,可以为 `'copy'`, `'move'`, `'remove'` 或它们组成的数组
*/
disableBehaviors?: string[] | string;
/**
* 用于详细配置上述操作项的内容
*/
@ -88,7 +101,7 @@ export interface IPublicTypeFilterItem {
}
export interface IPublicTypeAutorunItem {
name: string;
autorun: (target: IPublicModelSettingTarget) => any;
autorun: (prop: IPublicModelProp) => any;
}
// thinkof Array
@ -96,19 +109,23 @@ export interface IPublicTypeAutorunItem {
* Live Text Editing(如果 children 内容是纯文本,支持双击直接编辑)的可配置项目
*/
export interface IPublicTypeLiveTextEditingConfig {
/**
* @todo 待补充文档
*/
propTarget: string;
/**
* @todo 待补充文档
*/
selector?: string;
/**
* 编辑模式 纯文本 | 段落编辑 | 文章编辑(默认纯文本,无跟随工具条)
* @default 'plaintext'
*/
mode?: 'plaintext' | 'paragraph' | 'article';
/**
* 从 contentEditable 获取内容并设置到属性
*/
@ -125,27 +142,33 @@ export type ConfigureSupportEvent = string | {
* 通用扩展面板支持性配置
*/
export interface ConfigureSupport {
/**
* 支持事件列表
*/
events?: ConfigureSupportEvent[];
/**
* 支持 className 设置
*/
className?: boolean;
/**
* 支持样式设置
*/
style?: boolean;
/**
* 支持生命周期设置
*/
lifecycles?: any[];
// general?: boolean;
/**
* 支持循环设置
*/
loop?: boolean;
/**
* 支持条件式渲染设置
*/