mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
72.07k stars 6.54k forks source link

ID modification is required when using the id generator method. #4650

Open briggssong opened 1 year ago

briggssong commented 1 year ago

Description

I am a developer who is currently developing vue. After communication with the server, if you use run with the received data through mermaid run, the IDs sometimes overlap and overlap.

Steps to reproduce

Create and run multiple mermaid tags.

Screenshots

No response

Code Sample

** before

export const initIdGenerator = class iterator {
  constructor(deterministic, seed) {
    this.deterministic = deterministic;
    // TODO: Seed is only used for length?
    this.seed = seed;

    this.count = seed ? seed.length : 0;
  }

  next() {
    if (!this.deterministic) {
      return Date.now();
    }

    return this.count++;
  }
};

** after 
export const initIdGenerator = class iterator {
  constructor(deterministic, seed) {
    this.deterministic = deterministic;
    // TODO: Seed is only used for length?
    this.seed = seed;

    this.count = seed ? seed.length : 0;
  }

  next() {
    if (!this.deterministic) {
      return Date.now() + (Math.random() * 1000).toFixed();
    }

    return this.count++;
  }
};

Setup

Suggested Solutions

No response

Additional Context

No response

briggssong commented 1 year ago

@tobie @xuanxu @dbussink @jayvdb check plz