Merge branch 'fix/lihao-bugs-200825' into 'release/0.9.13'

fix: 处理 function component 无法选中的问题,本质上是没有 ref

fix: 处理 filter 组件在每次重绘时 fieldId 变更的 bug

See merge request !949623
This commit is contained in:
高凯 2020-08-26 11:29:03 +08:00
commit 21c816f2d9
5 changed files with 20 additions and 11 deletions

View File

@ -461,9 +461,9 @@ export class DocumentModel {
*
*/
remove() {
this.designer.postEvent('document.remove', { id: this.id });
this.purge();
this.project.removeDocument(this);
this.designer.postEvent('document.remove', { id: this.id });
}
purge() {

View File

@ -69,8 +69,6 @@ export default class Bundle {
// invoke prototype mocker while the prototype does not exist
Object.keys(this.viewsMap).forEach((viewName) => {
const test = this;
// console.log(test, viewName);
if (!this.prototypeList.find((proto) => proto.getComponentName() === viewName)) {
const mockedPrototype = trunk.mockComponentPrototype(this.viewsMap[viewName]);
if (mockedPrototype) {

View File

@ -1,4 +1,4 @@
import { ComponentType, ReactElement } from 'react';
import { ComponentType, ReactElement, Component, FunctionComponent } from 'react';
import { ComponentMetadata, FieldConfig, InitialItem, FilterItem, AutorunItem, isI18nData } from '@ali/lowcode-types';
import {
ComponentMeta,
@ -220,14 +220,14 @@ class Prototype {
readonly isPrototype = true;
readonly meta: ComponentMeta;
readonly options: OldPrototypeConfig | ComponentMetadata;
view: ComponentType;
// componentName: string;
get componentName() {
return this.getId();
}
get packageName() {
return this.meta.npm?.package;
}
// 兼容原 vision 用法
view: ComponentType | undefined;
constructor(input: OldPrototypeConfig | ComponentMetadata | ComponentMeta, extraConfigs: any = null, lookup: boolean = false) {
if (lookup) {
@ -327,19 +327,30 @@ class Prototype {
}
setView(view: ComponentType<any>) {
this.view = view;
let wrappedView = view;
if (!view?.prototype?.isReactComponent) {
const ViewComponentClass = class extends Component {
render() {
return (view as FunctionComponent)(this.props);
}
} as any;
ViewComponentClass.displayName = view.displayName;
wrappedView = ViewComponentClass;
}
this.view = wrappedView;
const metadata = this.meta.getMetadata();
if (!metadata.experimental) {
metadata.experimental = {
view,
view: wrappedView,
};
} else {
metadata.experimental.view = view;
metadata.experimental.view = wrappedView;
}
}
getView() {
return (
this.view ||
this.meta.getMetadata().experimental?.view ||
designer.currentDocument?.simulator?.getComponent(this.getComponentName())
);

View File

@ -106,7 +106,8 @@ designer.addPropsReducer((props, node) => {
fieldIds.push(fieldId);
}
});
if (fieldIds.indexOf(props.fieldId) >= 0) {
// 全局的关闭 uniqueIdChecker 信号,在 ve-utils 中实现
if (fieldIds.indexOf(props.fieldId) >= 0 && !window.__disable_unique_id_checker__) {
newProps.fieldId = undefined;
}
}

View File

@ -98,7 +98,6 @@ export class TreeMaster {
return this.treeMap.get(id)!;
}
const tree = new Tree(doc);
// TODO: listen purge event to remove
this.treeMap.set(id, tree);
return tree;
}