fix: 使用 componentMeta.isModal 代替 protoType.isModal()

This commit is contained in:
mario.gk 2020-09-27 10:44:20 +08:00
parent 3742a04405
commit b787dc436c
6 changed files with 10 additions and 14 deletions

View File

@ -975,12 +975,11 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
event: e,
};
// if (e.dragObject.type === 'node' && e.dragObject.nodes[0]?.getPrototype()?.isModal()) {
if (
e.dragObject &&
e.dragObject.nodes &&
e.dragObject.nodes.length &&
e.dragObject.nodes[0].getPrototype()?.isModal()
e.dragObject.nodes[0].componentMeta.isModal
) {
return this.designer.createLocation({
target: document.rootNode,
@ -1397,4 +1396,4 @@ function getMatched(elements: Array<Element | Text>, selector: string): Element
interface DropContainer {
container: ParentalNode;
instance: ComponentInstance;
}
}

View File

@ -4,8 +4,7 @@ import { DocumentModel } from '../document-model';
function getModalNodes(node: Node) {
let nodes: any = [];
const prototype = node.getPrototype();
if (prototype && prototype.isModal()) {
if (node.componentMeta.isModal) {
nodes.push(node);
}
const children = node.getChildren();
@ -85,8 +84,7 @@ export class ModalNodesManager {
}
private addNode(node: Node) {
const prototype = node.getPrototype();
if (prototype && prototype.isModal()) {
if (node.componentMeta.isModal) {
this.hideModalNodes();
this.modalNodes.push(node);
this.addNodeEvent(node);
@ -96,8 +94,7 @@ export class ModalNodesManager {
}
private removeNode(node: Node) {
const prototype = node.getPrototype();
if (prototype && prototype.isModal()) {
if (node.componentMeta.isModal) {
const index = this.modalNodes.indexOf(node);
if (index >= 0) {
this.modalNodes.splice(index, 1);

View File

@ -158,8 +158,8 @@ export class OutlineMain implements ISensor, ITreeBoard, IScrollable {
const irect = this.getInsertionRect();
const originLoc = document.dropLocation;
const prop = e.dragObject.nodes ? e.dragObject.nodes[0].getPrototype() : null;
if (e.dragObject.type === 'node' && prop && prop.isModal()) {
const componentMeta = e.dragObject.nodes ? e.dragObject.nodes[0].componentMeta : null;
if (e.dragObject.type === 'node' && componentMeta && componentMeta.isModal) {
return designer.createLocation({
target: document.rootNode,
detail: {

View File

@ -29,7 +29,7 @@ class ModalTreeNodeView extends Component<{ treeNode: TreeNode }> {
render() {
const { treeNode } = this.props;
const modalNodes = treeNode.children?.filter((item) => {
return item.node.getPrototype()?.isModal();
return item.node.componentMeta.isModal;
});
if (!modalNodes || modalNodes.length === 0) {
return null;

View File

@ -72,7 +72,7 @@ class TreeNodeChildren extends Component<{
/>
);
treeNode.children?.forEach((child, index) => {
const childIsModal = child.node.getPrototype()?.isModal() || false;
const childIsModal = child.node.componentMeta.isModal || false;
if (isModal != childIsModal) {
return;
}

View File

@ -508,7 +508,7 @@ class ComponentCreator extends React.Component<{ schema: any; propsMap: any, com
constructor(props: any) {
super(props);
const componentMeta = host.currentDocument?.getComponentMeta(props.schema.componentName);
if (componentMeta?.prototype?.isModal()) {
if (componentMeta?.isModal) {
this.isModal = true;
}
}