Skip to content

Commit

Permalink
feat: 支持自定义节点/边的唯一标识 antvis#4442
Browse files Browse the repository at this point in the history
  • Loading branch information
Caaalabash committed Sep 14, 2024
1 parent 003491b commit bf844e6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/x6/src/model/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ export class Cell<
}, metadata)
}

// eslint-disable-next-line
public static customId(metadata: Cell.Metadata = {}) {
return StringExt.uuid()
}

// #endregion

protected get [Symbol.toStringTag]() {
Expand All @@ -107,7 +112,7 @@ export class Cell<
this.preprocess(metadata),
)

this.id = props.id || StringExt.uuid()
this.id = props.id || Cell.customId(metadata)
this.store = new Store(props)
this.animation = new Animation(this)
this.setup()
Expand Down Expand Up @@ -140,7 +145,7 @@ export class Cell<
const props = ctor.applyPropHooks(this, metadata)

if (id == null && ignoreIdCheck !== true) {
props.id = StringExt.uuid()
props.id = Cell.customId(metadata)
}

return props as Properties
Expand Down

0 comments on commit bf844e6

Please sign in to comment.