mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 03:01:16 +00:00
fix: 复制时防止 ref 重复
This commit is contained in:
parent
d56ed6bff1
commit
96fe876e33
@ -10,6 +10,14 @@ import {
|
|||||||
} from './icons';
|
} from './icons';
|
||||||
import { componentDefaults, legacyIssues } from './transducers';
|
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 {
|
export class ComponentActions {
|
||||||
private metadataTransducers: IPublicTypeMetadataTransducer[] = [];
|
private metadataTransducers: IPublicTypeMetadataTransducer[] = [];
|
||||||
|
|
||||||
@ -53,6 +61,7 @@ export class ComponentActions {
|
|||||||
const { document: doc, parent, index } = node;
|
const { document: doc, parent, index } = node;
|
||||||
if (parent) {
|
if (parent) {
|
||||||
const newNode = doc?.insertNode(parent, node, (index ?? 0) + 1, true);
|
const newNode = doc?.insertNode(parent, node, (index ?? 0) + 1, true);
|
||||||
|
deduplicateRef(newNode);
|
||||||
newNode?.select();
|
newNode?.select();
|
||||||
const { isRGL, rglNode } = node?.getRGL();
|
const { isRGL, rglNode } = node?.getRGL();
|
||||||
if (isRGL) {
|
if (isRGL) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user