feat: 1. reportModified when insert 2. handle canDropTo in hotkey

This commit is contained in:
wanying.jwy 2020-12-25 18:21:25 +08:00
parent 547d85e4eb
commit 9124aaceb9
2 changed files with 12 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import { isFormEvent } from '@ali/lowcode-utils';
import { focusing } from './focusing';
import { insertChildren, TransformStage } from '../document';
import clipboard from './clipboard';
import { NodeSchema } from '@ali/lowcode-types';
function isInLiveEditing() {
if (globalContext.has(Editor)) {
@ -155,7 +156,11 @@ hotkey.bind(['command+v', 'ctrl+v'], (e) => {
if (!target) {
return;
}
const nodes = insertChildren(target, componentsTree, index);
let canAddComponentsTree = componentsTree.filter((i) => {
return doc.checkNestingUp(target, i);
})
if (canAddComponentsTree.length === 0) return;
const nodes = insertChildren(target, canAddComponentsTree, index);
if (nodes) {
doc.selection.selectAll(nodes.map((o) => o.id));
setTimeout(() => designer.activeTracker.track(nodes[0]), 10);

View File

@ -157,7 +157,7 @@ export class NodeChildren {
/**
*
*/
insert(node: Node, at?: number | null, useMutator = true): void {
insert(node: Node, at?: number | null, useMutator = true, copy?: boolean): void {
const { children } = this;
let index = at == null || at === -1 ? children.length : at;
@ -185,7 +185,11 @@ export class NodeChildren {
this.emitter.emit('change');
this.emitter.emit('insert', node);
// this.reportModified(node, this.owner, { type: 'insert' });
// if (useMutator && copy) {
// this.reportModified(node, this.owner, {type: 'copy', copyIndex: index, copyNode: node })
// }
// this.reportModified(node, this.owner,)
this.reportModified(node, this.owner, { type: 'insert' });
// check condition group
if (node.conditionGroup) {