Merge commit '3f2cd667d0fea6c741fbdc449d512650350e20ae' into def_releases_2021090110434646_ali-lowcode_ali-lowcode-engine/1.0.64

This commit is contained in:
tbfed 2021-09-01 21:10:32 +08:00
commit c3cf373159
9 changed files with 38 additions and 24 deletions

View File

@ -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;

View File

@ -1053,7 +1053,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
scrollToNode(node: Node, detail?: any /* , tryTimes = 0 */) {
this.tryScrollAgain = null;
if (this.sensing) {
// actived sensor
// active sensor
return;
}

View File

@ -308,8 +308,8 @@ export class Designer {
getSuitableInsertion(
insertNode?: Node | NodeSchema | NodeSchema[],
): { target: ParentalNode; index?: number } | null {
const activedDoc = this.project.currentDocument;
if (!activedDoc) {
const activeDoc = this.project.currentDocument;
if (!activeDoc) {
return null;
}
if (
@ -318,11 +318,11 @@ export class Designer {
this.getComponentMeta(insertNode[0].componentName).isModal
) {
return {
target: activedDoc.rootNode as ParentalNode,
target: activeDoc.rootNode as ParentalNode,
};
}
const focusNode = activedDoc.focusNode!;
const nodes = activedDoc.selection.getNodes();
const focusNode = activeDoc.focusNode!;
const nodes = activeDoc.selection.getNodes();
const refNode = nodes.find(item => focusNode.contains(item));
let target;
let index: number | undefined;

View File

@ -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;

View File

@ -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);
}

View File

@ -157,7 +157,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
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<Schema extends NodeSchema = NodeSchema> {
children: isDOMText(children) || isJSExpression(children) ? children : '',
});
} else {
// 这里 props 被初始化两次,一次 new一次 importnew 的实例需要给 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();

View File

@ -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();
}
/**

View File

@ -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) {

View File

@ -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,