mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-08 03:27:20 +00:00
Merge branch 'release/1.0.56' of gitlab.alibaba-inc.com:ali-lowcode/ali-lowcode-engine into release/1.0.56
This commit is contained in:
commit
fe7412ae25
@ -17,7 +17,7 @@ import {
|
|||||||
} from '../simulator';
|
} from '../simulator';
|
||||||
import Viewport from './viewport';
|
import Viewport from './viewport';
|
||||||
import { createSimulator } from './create-simulator';
|
import { createSimulator } from './create-simulator';
|
||||||
import { Node, ParentalNode, contains, isRootNode } from '../document';
|
import { Node, ParentalNode, contains, isRootNode, isLowCodeComponent } from '../document';
|
||||||
import ResourceConsumer from './resource-consumer';
|
import ResourceConsumer from './resource-consumer';
|
||||||
import {
|
import {
|
||||||
AssetLevel,
|
AssetLevel,
|
||||||
@ -792,7 +792,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const node = nodeInst.node || this.project.currentDocument?.rootNode;
|
const node = nodeInst.node || this.project.currentDocument?.rootNode;
|
||||||
if (!node) {
|
if (!node || isLowCodeComponent(node)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@ 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';
|
import { IconHidden } from './icons/hidden';
|
||||||
|
import EventEmitter from 'events';
|
||||||
|
|
||||||
function ensureAList(list?: string | string[]): string[] | null {
|
function ensureAList(list?: string | string[]): string[] | null {
|
||||||
if (!list) {
|
if (!list) {
|
||||||
@ -66,6 +67,8 @@ export class ComponentMeta {
|
|||||||
|
|
||||||
private _npm?: NpmInfo;
|
private _npm?: NpmInfo;
|
||||||
|
|
||||||
|
private emitter: EventEmitter = new EventEmitter();
|
||||||
|
|
||||||
get npm() {
|
get npm() {
|
||||||
return this._npm;
|
return this._npm;
|
||||||
}
|
}
|
||||||
@ -229,6 +232,11 @@ export class ComponentMeta {
|
|||||||
this._isContainer = false;
|
this._isContainer = false;
|
||||||
this._isModal = false;
|
this._isModal = false;
|
||||||
}
|
}
|
||||||
|
this.emitter.emit('metadata_change');
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshMetadata() {
|
||||||
|
this.parseMetadata(this.getMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
private transformMetadata(metadta: ComponentMetadata): TransformedComponentMetadata {
|
private transformMetadata(metadta: ComponentMetadata): TransformedComponentMetadata {
|
||||||
@ -297,6 +305,13 @@ export class ComponentMeta {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMetadataChange(fn: (args: any) => void): () => void {
|
||||||
|
this.emitter.on('metadata_change', fn);
|
||||||
|
return () => {
|
||||||
|
this.emitter.removeListener('metadata_change', fn);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// compatiable vision
|
// compatiable vision
|
||||||
prototype?: any;
|
prototype?: any;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,6 +80,8 @@ export class SettingTopEntry implements SettingEntry {
|
|||||||
|
|
||||||
// clear fields
|
// clear fields
|
||||||
this.setupItems();
|
this.setupItems();
|
||||||
|
|
||||||
|
this.setupEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupComponentMeta() {
|
private setupComponentMeta() {
|
||||||
@ -120,6 +122,12 @@ export class SettingTopEntry implements SettingEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setupEvents() {
|
||||||
|
this.componentMeta?.onMetadataChange(() => {
|
||||||
|
this.setupItems();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前属性值
|
* 获取当前属性值
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -156,8 +156,6 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
return this.componentMeta.icon;
|
return this.componentMeta.icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly settingEntry: SettingTopEntry;
|
|
||||||
|
|
||||||
private isInited = false;
|
private isInited = false;
|
||||||
|
|
||||||
constructor(readonly document: DocumentModel, nodeSchema: Schema, options: any = {}) {
|
constructor(readonly document: DocumentModel, nodeSchema: Schema, options: any = {}) {
|
||||||
@ -168,13 +166,11 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
this.props = new Props(this, {
|
this.props = new Props(this, {
|
||||||
children: isDOMText(children) || isJSExpression(children) ? children : '',
|
children: isDOMText(children) || isJSExpression(children) ? children : '',
|
||||||
});
|
});
|
||||||
this.settingEntry = this.document.designer.createSettingEntry([this]);
|
|
||||||
} else {
|
} else {
|
||||||
// 这里 props 被初始化两次,一次 new,一次 import,new 的实例需要给 propsReducer 的钩子去使用,
|
// 这里 props 被初始化两次,一次 new,一次 import,new 的实例需要给 propsReducer 的钩子去使用,
|
||||||
// import 是为了使用钩子返回的值,并非完全幂等的操作,部分行为执行两次会有 bug,
|
// import 是为了使用钩子返回的值,并非完全幂等的操作,部分行为执行两次会有 bug,
|
||||||
// 所以在 props 里会对 new / import 做一些区别化的解析
|
// 所以在 props 里会对 new / import 做一些区别化的解析
|
||||||
this.props = new Props(this, props, extras);
|
this.props = new Props(this, props, extras);
|
||||||
this.settingEntry = this.document.designer.createSettingEntry([this]);
|
|
||||||
this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children));
|
this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children));
|
||||||
this._children.internalInitParent();
|
this._children.internalInitParent();
|
||||||
this.props.import(
|
this.props.import(
|
||||||
@ -188,6 +184,14 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
this.emitter = new EventEmitter();
|
this.emitter = new EventEmitter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_settingEntry: SettingTopEntry;
|
||||||
|
|
||||||
|
get settingEntry(): SettingTopEntry {
|
||||||
|
if (this._settingEntry) return this._settingEntry;
|
||||||
|
this._settingEntry = this.document.designer.createSettingEntry([this]);
|
||||||
|
return this._settingEntry;
|
||||||
|
}
|
||||||
|
|
||||||
private initProps(props: any): any {
|
private initProps(props: any): any {
|
||||||
return this.document.designer.transformProps(props, this, TransformStage.Init);
|
return this.document.designer.transformProps(props, this, TransformStage.Init);
|
||||||
}
|
}
|
||||||
@ -1091,6 +1095,10 @@ export function isRootNode(node: Node): node is RootNode {
|
|||||||
return node && node.isRoot();
|
return node && node.isRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isLowCodeComponent(node: Node): boolean {
|
||||||
|
return node.componentMeta.getMetadata().devMode === 'lowcode';
|
||||||
|
}
|
||||||
|
|
||||||
export function getZLevelTop(child: Node, zLevel: number): Node | null {
|
export function getZLevelTop(child: Node, zLevel: number): Node | null {
|
||||||
let l = child.zLevel;
|
let l = child.zLevel;
|
||||||
if (l < zLevel || zLevel < 0) {
|
if (l < zLevel || zLevel < 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user