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 { includeSlot, removeSlot } from '../../utils/slot';
import { foreachReverse } from '../../utils/tree'; import { foreachReverse } from '../../utils/tree';
import { NodeRemoveOptions, EDITOR_EVENT } from '../../types'; import { NodeRemoveOptions, EDITOR_EVENT } from '../../types';
import { Prop as ShellProp } from '@alilc/lowcode-shell';
export interface NodeStatus { export interface NodeStatus {
locking: boolean; locking: boolean;
@ -376,7 +377,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
} }
this.autoruns = autoruns.map((item) => { this.autoruns = autoruns.map((item) => {
return autorun(() => { 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; getNode(): INode;
getProp(path: string): IProp | null; getProp(path: string): IProp | null;
get(path: string, createIfNone: boolean): Prop;
} }
export class Props implements IProps, IPropParent { export class Props implements IProps, IPropParent {

View File

@ -1,31 +1,37 @@
import { IPublicTypePropType, IPublicTypeComponentAction } from './'; import { IPublicTypePropType, IPublicTypeComponentAction } from './';
import { IPublicModelSettingTarget } from '../model'; import { IPublicModelProp, IPublicModelSettingTarget } from '../model';
/** /**
* *
*/ */
export type IPublicTypeNestingFilter = (testNode: any, currentNode: any) => boolean; export type IPublicTypeNestingFilter = (testNode: any, currentNode: any) => boolean;
/** /**
* *
* a a, FormField Form Column Table * a a, FormField Form Column Table
*/ */
export interface IPublicTypeNestingRule { export interface IPublicTypeNestingRule {
/** /**
* *
*/ */
childWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter; childWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/** /**
* *
*/ */
parentWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter; parentWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/** /**
* *
*/ */
descendantWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter; descendantWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/** /**
* *
*/ */
descendantBlacklist?: string[] | string | RegExp | IPublicTypeNestingFilter; descendantBlacklist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/** /**
* *
*/ */
@ -36,22 +42,27 @@ export interface IPublicTypeNestingRule {
* *
*/ */
export interface IPublicTypeComponentConfigure { export interface IPublicTypeComponentConfigure {
/** /**
* *
*/ */
isContainer?: boolean; isContainer?: boolean;
/** /**
* *
*/ */
isModal?: boolean; isModal?: boolean;
/** /**
* *
*/ */
isNullNode?: boolean; isNullNode?: boolean;
/** /**
* *
*/ */
descriptor?: string; descriptor?: string;
/** /**
* *
* a a, FormField Form Column Table * a a, FormField Form Column Table
@ -68,10 +79,12 @@ export interface IPublicTypeComponentConfigure {
* cssSelector * cssSelector
*/ */
rootSelector?: string; rootSelector?: string;
/** /**
* `'copy'`, `'move'`, `'remove'` * `'copy'`, `'move'`, `'remove'`
*/ */
disableBehaviors?: string[] | string; disableBehaviors?: string[] | string;
/** /**
* *
*/ */
@ -88,7 +101,7 @@ export interface IPublicTypeFilterItem {
} }
export interface IPublicTypeAutorunItem { export interface IPublicTypeAutorunItem {
name: string; name: string;
autorun: (target: IPublicModelSettingTarget) => any; autorun: (prop: IPublicModelProp) => any;
} }
// thinkof Array // thinkof Array
@ -96,19 +109,23 @@ export interface IPublicTypeAutorunItem {
* Live Text Editing children * Live Text Editing children
*/ */
export interface IPublicTypeLiveTextEditingConfig { export interface IPublicTypeLiveTextEditingConfig {
/** /**
* @todo * @todo
*/ */
propTarget: string; propTarget: string;
/** /**
* @todo * @todo
*/ */
selector?: string; selector?: string;
/** /**
* | | * | |
* @default 'plaintext' * @default 'plaintext'
*/ */
mode?: 'plaintext' | 'paragraph' | 'article'; mode?: 'plaintext' | 'paragraph' | 'article';
/** /**
* contentEditable * contentEditable
*/ */
@ -125,27 +142,33 @@ export type ConfigureSupportEvent = string | {
* *
*/ */
export interface ConfigureSupport { export interface ConfigureSupport {
/** /**
* *
*/ */
events?: ConfigureSupportEvent[]; events?: ConfigureSupportEvent[];
/** /**
* className * className
*/ */
className?: boolean; className?: boolean;
/** /**
* *
*/ */
style?: boolean; style?: boolean;
/** /**
* *
*/ */
lifecycles?: any[]; lifecycles?: any[];
// general?: boolean; // general?: boolean;
/** /**
* *
*/ */
loop?: boolean; loop?: boolean;
/** /**
* *
*/ */