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[] { private getMasterSensors(): ISimulatorHost[] {
return this.designer.project.documents return this.designer.project.documents
.map(doc => { .map(doc => {
// TODO: not use actived, if (doc.active && doc.simulator?.sensorAvailable) {
if (doc.actived && doc.simulator?.sensorAvailable) {
return doc.simulator; return doc.simulator;
} }
return null; return null;

View File

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

View File

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

View File

@ -195,7 +195,7 @@ export class Dragon {
private sensors: ISensor[] = []; private sensors: ISensor[] = [];
/** /**
* current actived sensor, * current active sensor,
*/ */
@obx.ref private _activeSensor: ISensor | undefined; @obx.ref private _activeSensor: ISensor | undefined;
@ -619,8 +619,7 @@ export class Dragon {
new Set( new Set(
this.designer.project.documents this.designer.project.documents
.map((doc) => { .map((doc) => {
// TODO: not use actived, if (doc.active && doc.simulator?.sensorAvailable) {
if (doc.actived && doc.simulator?.sensorAvailable) {
return doc.simulator; return doc.simulator;
} }
return null; return null;

View File

@ -446,10 +446,17 @@ export class DocumentModel {
/** /**
* suspensed * suspensed
*/ */
get actived(): boolean { get active(): boolean {
return !this._suspensed; return !this._suspensed;
} }
/**
* @deprecated
*/
get actived(): boolean {
return this.active;
}
/** /**
* *
*/ */
@ -476,7 +483,7 @@ export class DocumentModel {
this.setSuspense(true); this.setSuspense(true);
} }
active() { activate() {
this.setSuspense(false); this.setSuspense(false);
} }

View File

@ -157,7 +157,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
return this.componentMeta.icon; return this.componentMeta.icon;
} }
private isInited = false; isInited = false;
constructor(readonly document: DocumentModel, nodeSchema: Schema, options: any = {}) { constructor(readonly document: DocumentModel, nodeSchema: Schema, options: any = {}) {
const { componentName, id, children, props, ...extras } = nodeSchema; const { componentName, id, children, props, ...extras } = nodeSchema;
@ -168,9 +168,6 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
children: isDOMText(children) || isJSExpression(children) ? children : '', children: isDOMText(children) || isJSExpression(children) ? children : '',
}); });
} else { } else {
// 这里 props 被初始化两次,一次 new一次 importnew 的实例需要给 propsReducer 的钩子去使用,
// import 是为了使用钩子返回的值,并非完全幂等的操作,部分行为执行两次会有 bug
// 所以在 props 里会对 new / import 做一些区别化的解析
this.props = new Props(this, props, extras); this.props = new Props(this, props, extras);
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();

View File

@ -55,6 +55,12 @@ export class Prop implements IPropParent {
if (value !== UNSET) { if (value !== UNSET) {
this.setValue(value); this.setValue(value);
} }
this.setupItems();
}
// TODO: 先用调用方式触发子 prop 的初始化,后续须重构
private setupItems() {
return this.items;
} }
/** /**
@ -247,7 +253,9 @@ export class Prop implements IPropParent {
}; };
} }
if (this.owner.isInited) {
this.dispose(); this.dispose();
}
if (oldValue !== this._value) { if (oldValue !== this._value) {
editor?.emit('node.innerProp.change', { editor?.emit('node.innerProp.change', {
@ -302,7 +310,6 @@ export class Prop implements IPropParent {
owner.addSlot(this._slotNode); owner.addSlot(this._slotNode);
this._slotNode.internalSetSlotFor(this); this._slotNode.internalSetSlotFor(this);
} }
this.dispose();
} }
/** /**

View File

@ -28,7 +28,7 @@ export class Project {
} }
@computed get currentDocument() { @computed get currentDocument() {
return this.documents.find((doc) => doc.actived); return this.documents.find((doc) => doc.active);
} }
@obx private _config: any = {}; @obx private _config: any = {};
@ -67,7 +67,7 @@ export class Project {
*/ */
setSchema(schema?: ProjectSchema) { setSchema(schema?: ProjectSchema) {
// FIXME: 这里的行为和 getSchema 并不对等,感觉不太对 // FIXME: 这里的行为和 getSchema 并不对等,感觉不太对
const doc = this.documents.find((doc) => doc.actived); const doc = this.documents.find((doc) => doc.active);
doc && doc.import(schema?.componentsTree[0]); doc && doc.import(schema?.componentsTree[0]);
} }
@ -231,13 +231,13 @@ export class Project {
return doc.open(); return doc.open();
} }
checkExclusive(actived: DocumentModel) { checkExclusive(activeDoc: DocumentModel) {
this.documents.forEach((doc) => { this.documents.forEach((doc) => {
if (doc !== actived) { if (doc !== activeDoc) {
doc.suspense(); doc.suspense();
} }
}); });
this.emitter.emit('current-document.change', actived); this.emitter.emit('current-document.change', activeDoc);
} }
closeOthers(opened: DocumentModel) { closeOthers(opened: DocumentModel) {

View File

@ -4,6 +4,11 @@ import { getConvertedExtraKey } from '@ali/lowcode-designer';
export default function (metadata: TransformedComponentMetadata): TransformedComponentMetadata { export default function (metadata: TransformedComponentMetadata): TransformedComponentMetadata {
const { componentName, configure = {} } = metadata; const { componentName, configure = {} } = metadata;
// 如果已经处理过,不再重新执行一遍
if (configure.combined) {
return metadata;
}
if (componentName === 'Leaf') { if (componentName === 'Leaf') {
return { return {
...metadata, ...metadata,