Merge branch 'fix/render-error-style' into 'release/0.9.3'

fix: 卡片内容不可用拖动



See merge request !932256
This commit is contained in:
高凯 2020-08-13 12:12:12 +08:00
commit c806602e2e
3 changed files with 36 additions and 11 deletions

View File

@ -839,22 +839,35 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
this.scroller.cancel(); this.scroller.cancel();
} }
// ========= drag location logic: hepler for locate ========== // ========= drag location logic: helper for locate ==========
/** /**
* @see ISensor * @see ISensor
*/ */
locate(e: LocateEvent): any { locate(e: LocateEvent): any {
const { dragObject } = e;
const { nodes } = dragObject;
const operationalNodes = nodes?.filter((node: any) => {
const onMoveHook = node.componentMeta?.getMetadata()?.experimental?.callbacks?.onMoveHook;
const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook() : true;
return canMove;
});
if (!operationalNodes || operationalNodes.length === 0) {
return;
}
this.sensing = true; this.sensing = true;
this.scroller.scrolling(e); this.scroller.scrolling(e);
const dropContainer = this.getDropContainer(e); const dropContainer = this.getDropContainer(e);
const canDropIn = dropContainer.container?.componentMeta?.prototype?.options?.canDropIn; const canDropIn = dropContainer?.container?.componentMeta?.prototype?.options?.canDropIn;
if ( if (
!dropContainer || !dropContainer ||
canDropIn === false || canDropIn === false ||
// too dirty // too dirty
(typeof canDropIn === 'function' && (typeof canDropIn === 'function' && !canDropIn(operationalNodes[0]))
!canDropIn(e.dragObject.nodes[0]))
) { ) {
return null; return null;
} }
@ -886,7 +899,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
event: e, event: e,
}; };
if (e.dragObject.type === 'node' && e.dragObject.nodes[0]?.getPrototype()?.isModal()) { if (dragObject.type === 'node' && operationalNodes[0]?.getPrototype()?.isModal()) {
return this.designer.createLocation({ return this.designer.createLocation({
target: this.document.rootNode, target: this.document.rootNode,
detail: { detail: {

View File

@ -137,13 +137,13 @@ export class ComponentMeta {
} }
} }
private parseMetadata(metadta: ComponentMetadata) { private parseMetadata(metadata: ComponentMetadata) {
const { componentName, npm } = metadta; const { componentName, npm } = metadata;
this._npm = npm; this._npm = npm;
this._componentName = componentName; this._componentName = componentName;
// 额外转换逻辑 // 额外转换逻辑
this._transformedMetadata = this.transformMetadata(metadta); this._transformedMetadata = this.transformMetadata(metadata);
const title = this._transformedMetadata.title; const title = this._transformedMetadata.title;
if (title) { if (title) {

View File

@ -122,20 +122,32 @@ export class OutlineMain implements ISensor, ITreeBoard, IScrollable {
locate(e: LocateEvent): DropLocation | undefined | null { locate(e: LocateEvent): DropLocation | undefined | null {
this.sensing = true; this.sensing = true;
this.scroller?.scrolling(e); this.scroller?.scrolling(e);
const { globalY, dragObject } = e;
const { nodes } = dragObject;
const tree = this._master?.currentTree; const tree = this._master?.currentTree;
if (!tree || !this._shell) { if (!tree || !this._shell) {
return null; return null;
} }
const operationalNodes = nodes?.filter((node: any) => {
const onMoveHook = node.componentMeta?.getMetadata()?.experimental?.callbacks?.onMoveHook;
const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook() : true;
return canMove;
});
if (!operationalNodes || operationalNodes.length === 0) {
return;
}
const document = tree.document; const document = tree.document;
const designer = document.designer; const designer = document.designer;
const { globalY, dragObject } = e;
const pos = getPosFromEvent(e, this._shell); const pos = getPosFromEvent(e, this._shell);
const irect = this.getInsertionRect(); const irect = this.getInsertionRect();
const originLoc = document.dropLocation; const originLoc = document.dropLocation;
if (e.dragObject.type === 'node' && e.dragObject.nodes[0].getPrototype().isModal()) { if (dragObject.type === 'node' && operationalNodes[0].getPrototype().isModal()) {
return designer.createLocation({ return designer.createLocation({
target: document.rootNode, target: document.rootNode,
detail: { detail: {
@ -195,7 +207,7 @@ export class OutlineMain implements ISensor, ITreeBoard, IScrollable {
let focusSlots = pos.focusSlots; let focusSlots = pos.focusSlots;
let { node } = treeNode; let { node } = treeNode;
if (isDragNodeObject(dragObject)) { if (isDragNodeObject(dragObject)) {
const nodes = dragObject.nodes; const nodes = operationalNodes;
let i = nodes.length; let i = nodes.length;
let p: any = node; let p: any = node;
while (i-- > 0) { while (i-- > 0) {