GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: 复制时防止 ref 重复 · fecqs/lowcode-engine@96fe876

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/designer/src
    • component-actions.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/designer/src/component-actions.ts‎

Copy file name to clipboardExpand all lines: packages/designer/src/component-actions.ts
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ import {
1010
} from './icons';
1111
import { componentDefaults, legacyIssues } from './transducers';
1212

13+
function deduplicateRef(node: IPublicModelNode | null | undefined) {
14+
const currentRef = node?.getPropValue('ref');
15+
if (currentRef) {
16+
node?.setPropValue('ref', `${node.componentName.toLowerCase()}-${Math.random().toString(36).slice(2, 9)}`);
17+
}
18+
node?.children?.forEach(deduplicateRef);
19+
}
20+
1321
export class ComponentActions {
1422
private metadataTransducers: IPublicTypeMetadataTransducer[] = [];
1523

@@ -53,6 +61,7 @@ export class ComponentActions {
5361
const { document: doc, parent, index } = node;
5462
if (parent) {
5563
const newNode = doc?.insertNode(parent, node, (index ?? 0) + 1, true);
64+
deduplicateRef(newNode);
5665
newNode?.select();
5766
const { isRGL, rglNode } = node?.getRGL();
5867
if (isRGL) {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.