mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 18:42:56 +00:00
fix: 复制时防止 ref 重复
This commit is contained in:
parent
d56ed6bff1
commit
96fe876e33
@ -10,6 +10,14 @@ import {
|
||||
} from './icons';
|
||||
import { componentDefaults, legacyIssues } from './transducers';
|
||||
|
||||
function deduplicateRef(node: IPublicModelNode | null | undefined) {
|
||||
const currentRef = node?.getPropValue('ref');
|
||||
if (currentRef) {
|
||||
node?.setPropValue('ref', `${node.componentName.toLowerCase()}-${Math.random().toString(36).slice(2, 9)}`);
|
||||
}
|
||||
node?.children?.forEach(deduplicateRef);
|
||||
}
|
||||
|
||||
export class ComponentActions {
|
||||
private metadataTransducers: IPublicTypeMetadataTransducer[] = [];
|
||||
|
||||
@ -53,6 +61,7 @@ export class ComponentActions {
|
||||
const { document: doc, parent, index } = node;
|
||||
if (parent) {
|
||||
const newNode = doc?.insertNode(parent, node, (index ?? 0) + 1, true);
|
||||
deduplicateRef(newNode);
|
||||
newNode?.select();
|
||||
const { isRGL, rglNode } = node?.getRGL();
|
||||
if (isRGL) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user