fix(client): blocks are deleted when they are dragged below the current block

This commit is contained in:
chenos 2022-07-13 12:52:59 +08:00
parent 057e1d0039
commit 20ab8c1501

View File

@ -460,22 +460,6 @@ export class Designable {
} }
const opts = { onSuccess: options?.onSuccess }; const opts = { onSuccess: options?.onSuccess };
const { wrap = defaultWrap, breakRemoveOn, removeParentsIfNoChildren } = options; const { wrap = defaultWrap, breakRemoveOn, removeParentsIfNoChildren } = options;
if (Schema.isSchemaInstance(schema)) {
if (this.parentsIn(schema)) {
this.emit('error', {
code: 'parent_is_not_allowed',
schema,
});
return;
}
schema.parent.removeProperty(schema.name);
if (removeParentsIfNoChildren) {
opts['removed'] = this.recursiveRemoveIfNoChildren(schema.parent, { breakRemoveOn });
}
schema.parent = null;
} else if (schema) {
schema = cloneDeep(schema);
}
let order = 0; let order = 0;
let newOrder = 0; let newOrder = 0;
@ -496,6 +480,23 @@ export class Designable {
} }
}); });
if (Schema.isSchemaInstance(schema)) {
if (this.parentsIn(schema)) {
this.emit('error', {
code: 'parent_is_not_allowed',
schema,
});
return;
}
schema.parent.removeProperty(schema.name);
if (removeParentsIfNoChildren) {
opts['removed'] = this.recursiveRemoveIfNoChildren(schema.parent, { breakRemoveOn });
}
schema.parent = null;
} else if (schema) {
schema = cloneDeep(schema);
}
this.prepareProperty(schema); this.prepareProperty(schema);
const wrapped = wrap(schema); const wrapped = wrap(schema);
const s = this.current.parent.addProperty(wrapped.name || uid(), wrapped); const s = this.current.parent.addProperty(wrapped.name || uid(), wrapped);