mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-15 18:58:11 +00:00
feat: 1. reportModified when insert 2. handle canDropTo in hotkey 3. sort left area item
feat: enhance-tree modified feat: enhance subtree modified feat: sort left area item feat: add useMutator fix: typo isPurging fix: typo
This commit is contained in:
parent
c3bfaf09a9
commit
1b01de251f
@ -156,7 +156,11 @@ hotkey.bind(['command+v', 'ctrl+v'], (e) => {
|
|||||||
if (!target) {
|
if (!target) {
|
||||||
return;
|
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) {
|
if (nodes) {
|
||||||
doc.selection.selectAll(nodes.map((o) => o.id));
|
doc.selection.selectAll(nodes.map((o) => o.id));
|
||||||
setTimeout(() => designer.activeTracker.track(nodes[0]), 10);
|
setTimeout(() => designer.activeTracker.track(nodes[0]), 10);
|
||||||
|
|||||||
@ -122,6 +122,7 @@ export class NodeChildren {
|
|||||||
* 删除一个节点
|
* 删除一个节点
|
||||||
*/
|
*/
|
||||||
delete(node: Node, purge = false, useMutator = true, options: NodeRemoveOptions = {}): boolean {
|
delete(node: Node, purge = false, useMutator = true, options: NodeRemoveOptions = {}): boolean {
|
||||||
|
node.internalPurgeStart();
|
||||||
if (node.isParental()) {
|
if (node.isParental()) {
|
||||||
foreachReverse(node.children, (subNode: Node) => {
|
foreachReverse(node.children, (subNode: Node) => {
|
||||||
subNode.remove(useMutator, purge, options);
|
subNode.remove(useMutator, purge, options);
|
||||||
@ -150,7 +151,7 @@ export class NodeChildren {
|
|||||||
document.destroyNode(node);
|
document.destroyNode(node);
|
||||||
this.emitter.emit('change');
|
this.emitter.emit('change');
|
||||||
if (useMutator) {
|
if (useMutator) {
|
||||||
this.reportModified(node, this.owner, { type: 'remove', removeIndex: i, removeNode: node });
|
this.reportModified(node, this.owner, { type: 'remove', propagated: false, isSubDeleting: this.owner.isPurging, removeIndex: i, removeNode: node });
|
||||||
}
|
}
|
||||||
// purge 为 true 时,已在 internalSetParent 中删除了子节点
|
// purge 为 true 时,已在 internalSetParent 中删除了子节点
|
||||||
if (i > -1 && !purge) {
|
if (i > -1 && !purge) {
|
||||||
@ -200,7 +201,9 @@ export class NodeChildren {
|
|||||||
if (globalContext.has('editor')) {
|
if (globalContext.has('editor')) {
|
||||||
globalContext.get('editor').emit('node.add', { node });
|
globalContext.get('editor').emit('node.add', { node });
|
||||||
}
|
}
|
||||||
// this.reportModified(node, this.owner, { type: 'insert' });
|
if (useMutator) {
|
||||||
|
this.reportModified(node, this.owner, { type: 'insert' });
|
||||||
|
}
|
||||||
|
|
||||||
// check condition group
|
// check condition group
|
||||||
if (node.conditionGroup) {
|
if (node.conditionGroup) {
|
||||||
@ -367,14 +370,6 @@ export class NodeChildren {
|
|||||||
return 'Array';
|
return 'Array';
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @deprecated
|
|
||||||
// * 为了兼容vision体系存量api
|
|
||||||
// */
|
|
||||||
// getChildrenArray() {
|
|
||||||
// return this.children;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private reportModified(node: Node, owner: Node, options = {}) {
|
private reportModified(node: Node, owner: Node, options = {}) {
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return;
|
return;
|
||||||
@ -392,7 +387,7 @@ export class NodeChildren {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (owner.parent && !owner.parent.isRoot()) {
|
if (owner.parent && !owner.parent.isRoot()) {
|
||||||
this.reportModified(node, owner.parent, options);
|
this.reportModified(node, owner.parent, { ...options, propagated: true, });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -834,6 +834,18 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
// this.document.destroyNode(this);
|
// this.document.destroyNode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private purging: boolean = false;
|
||||||
|
internalPurgeStart() {
|
||||||
|
this.purging = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否正在销毁
|
||||||
|
*/
|
||||||
|
get isPurging() {
|
||||||
|
return this.purging;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否可执行某action
|
* 是否可执行某action
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -25,7 +25,11 @@ class Contents extends Component<{ area: Area }> {
|
|||||||
const { area } = this.props;
|
const { area } = this.props;
|
||||||
const top: any[] = [];
|
const top: any[] = [];
|
||||||
const bottom: any[] = [];
|
const bottom: any[] = [];
|
||||||
area.container.items.forEach((item) => {
|
area.container.items.sort((a, b) => {
|
||||||
|
const index1 = a.config?.index || 0;
|
||||||
|
const index2 = b.config?.index || 0;
|
||||||
|
return index1 === index2 ? 0 : (index1 > index2 ? 1 : -1);
|
||||||
|
}).forEach((item) => {
|
||||||
const content = <div key={`left-area-${item.name}`}>{item.content}</div>;
|
const content = <div key={`left-area-${item.name}`}>{item.content}</div>;
|
||||||
if (item.align === 'bottom') {
|
if (item.align === 'bottom') {
|
||||||
bottom.push(content);
|
bottom.push(content);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user