diff --git a/packages/designer/src/builtin-simulator/bem-tools/drag-resize-engine.ts b/packages/designer/src/builtin-simulator/bem-tools/drag-resize-engine.ts index 6d678f2fd..162ada1b7 100644 --- a/packages/designer/src/builtin-simulator/bem-tools/drag-resize-engine.ts +++ b/packages/designer/src/builtin-simulator/bem-tools/drag-resize-engine.ts @@ -146,8 +146,7 @@ export default class DragResizeEngine { private getMasterSensors(): ISimulatorHost[] { return this.designer.project.documents .map(doc => { - // TODO: not use actived, - if (doc.actived && doc.simulator?.sensorAvailable) { + if (doc.active && doc.simulator?.sensorAvailable) { return doc.simulator; } return null; diff --git a/packages/designer/src/builtin-simulator/host.ts b/packages/designer/src/builtin-simulator/host.ts index 7ce160fa4..713f47247 100644 --- a/packages/designer/src/builtin-simulator/host.ts +++ b/packages/designer/src/builtin-simulator/host.ts @@ -1053,7 +1053,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost focusNode.contains(item)); let target; let index: number | undefined; diff --git a/packages/designer/src/designer/dragon.ts b/packages/designer/src/designer/dragon.ts index 56c2177be..5bf5e20fb 100644 --- a/packages/designer/src/designer/dragon.ts +++ b/packages/designer/src/designer/dragon.ts @@ -195,7 +195,7 @@ export class Dragon { private sensors: ISensor[] = []; /** - * current actived sensor, 可用于感应区高亮 + * current active sensor, 可用于感应区高亮 */ @obx.ref private _activeSensor: ISensor | undefined; @@ -619,8 +619,7 @@ export class Dragon { new Set( this.designer.project.documents .map((doc) => { - // TODO: not use actived, - if (doc.actived && doc.simulator?.sensorAvailable) { + if (doc.active && doc.simulator?.sensorAvailable) { return doc.simulator; } return null; diff --git a/packages/designer/src/document/document-model.ts b/packages/designer/src/document/document-model.ts index ccba5912d..1417a0c58 100644 --- a/packages/designer/src/document/document-model.ts +++ b/packages/designer/src/document/document-model.ts @@ -446,10 +446,17 @@ export class DocumentModel { /** * 与 suspensed 相反,是否为激活状态,这个函数可能用的更多一点 */ - get actived(): boolean { + get active(): boolean { return !this._suspensed; } + /** + * @deprecated 兼容 + */ + get actived(): boolean { + return this.active; + } + /** * 是否打开 */ @@ -476,7 +483,7 @@ export class DocumentModel { this.setSuspense(true); } - active() { + activate() { this.setSuspense(false); } diff --git a/packages/designer/src/document/node/node.ts b/packages/designer/src/document/node/node.ts index 32fa5fdeb..62cb3bf84 100644 --- a/packages/designer/src/document/node/node.ts +++ b/packages/designer/src/document/node/node.ts @@ -157,7 +157,7 @@ export class Node { return this.componentMeta.icon; } - private isInited = false; + isInited = false; constructor(readonly document: DocumentModel, nodeSchema: Schema, options: any = {}) { const { componentName, id, children, props, ...extras } = nodeSchema; @@ -168,9 +168,6 @@ export class Node { children: isDOMText(children) || isJSExpression(children) ? children : '', }); } else { - // 这里 props 被初始化两次,一次 new,一次 import,new 的实例需要给 propsReducer 的钩子去使用, - // import 是为了使用钩子返回的值,并非完全幂等的操作,部分行为执行两次会有 bug, - // 所以在 props 里会对 new / import 做一些区别化的解析 this.props = new Props(this, props, extras); this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children)); this._children.internalInitParent(); diff --git a/packages/designer/src/document/node/props/prop.ts b/packages/designer/src/document/node/props/prop.ts index 448f72f9c..4a654a34a 100644 --- a/packages/designer/src/document/node/props/prop.ts +++ b/packages/designer/src/document/node/props/prop.ts @@ -55,6 +55,12 @@ export class Prop implements IPropParent { if (value !== UNSET) { this.setValue(value); } + this.setupItems(); + } + + // TODO: 先用调用方式触发子 prop 的初始化,后续须重构 + private setupItems() { + return this.items; } /** @@ -247,7 +253,9 @@ export class Prop implements IPropParent { }; } - this.dispose(); + if (this.owner.isInited) { + this.dispose(); + } if (oldValue !== this._value) { editor?.emit('node.innerProp.change', { @@ -302,7 +310,6 @@ export class Prop implements IPropParent { owner.addSlot(this._slotNode); this._slotNode.internalSetSlotFor(this); } - this.dispose(); } /** diff --git a/packages/designer/src/project/project.ts b/packages/designer/src/project/project.ts index 5a12b7e14..bce7876b4 100644 --- a/packages/designer/src/project/project.ts +++ b/packages/designer/src/project/project.ts @@ -28,7 +28,7 @@ export class Project { } @computed get currentDocument() { - return this.documents.find((doc) => doc.actived); + return this.documents.find((doc) => doc.active); } @obx private _config: any = {}; @@ -67,7 +67,7 @@ export class Project { */ setSchema(schema?: ProjectSchema) { // FIXME: 这里的行为和 getSchema 并不对等,感觉不太对 - const doc = this.documents.find((doc) => doc.actived); + const doc = this.documents.find((doc) => doc.active); doc && doc.import(schema?.componentsTree[0]); } @@ -231,13 +231,13 @@ export class Project { return doc.open(); } - checkExclusive(actived: DocumentModel) { + checkExclusive(activeDoc: DocumentModel) { this.documents.forEach((doc) => { - if (doc !== actived) { + if (doc !== activeDoc) { doc.suspense(); } }); - this.emitter.emit('current-document.change', actived); + this.emitter.emit('current-document.change', activeDoc); } closeOthers(opened: DocumentModel) { diff --git a/packages/editor-skeleton/src/transducers/addon-combine.ts b/packages/editor-skeleton/src/transducers/addon-combine.ts index c8fa496a0..fd24f49b1 100644 --- a/packages/editor-skeleton/src/transducers/addon-combine.ts +++ b/packages/editor-skeleton/src/transducers/addon-combine.ts @@ -4,6 +4,11 @@ import { getConvertedExtraKey } from '@ali/lowcode-designer'; export default function (metadata: TransformedComponentMetadata): TransformedComponentMetadata { const { componentName, configure = {} } = metadata; + + // 如果已经处理过,不再重新执行一遍 + if (configure.combined) { + return metadata; + } if (componentName === 'Leaf') { return { ...metadata,