Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get element svg #942

Closed
wants to merge 1 commit into from
Closed

feat: get element svg #942

wants to merge 1 commit into from

Conversation

sandrewTx08
Copy link

@sandrewTx08 sandrewTx08 commented Oct 22, 2024

Proposed Changes

This feature allows rendering a specific element from the diagram.

This pull request introduces a new method to the ElementRegistry class and updates the corresponding unit tests. The most important changes include the addition of the getGraphicsSvg method and its usage in the test file.

How I use it on my Angular application:

Component:

getElementById(id: string) {
    const elementRegistry: any = this.viewer.get('elementRegistry');
    const element = elementRegistry.get(id);
    return element ? elementRegistry.getGraphicsSvg(element).outerHTML : '';
}

Template:

      <h2>
        <span
          [innerHTML]="
            domSanitizer.bypassSecurityTrustHtml(
              appViewer.getElementById(documentation.id)
            )
          "
        ></span>
        {{ documentation.name || documentation.id }}
      </h2>

My application looks like:

image
image

Enhancements to ElementRegistry:

Unit test updates:

Add relevant context (issue fixed or related to),
a capture of the UI changes (if any) as well as
steps to try out your changes.

Checklist

  • Brief textual description of the changes present
  • Visual demo attached
  • Steps to try out present, i.e. using the @bpmn-io/sr tool
  • Related issue linked via Closes {LINK_TO_ISSUE} or Related to {LINK_TO_ISSUE}

@CLAassistant
Copy link

CLAassistant commented Oct 22, 2024

CLA assistant check
All committers have signed the CLA.

@nikku
Copy link
Member

nikku commented Oct 28, 2024

Thanks for your contribution! From what I understand you want to retrieve an SVG from a given element on the diagram.

We have not seen this use-case in the past, hence I'm hesitant to make this an addition of the core editor API. If we added it to the core editor, then ElementRegistry would not be the right place as we want to keep it a simple registry, not a graphics generator.

I'm inclined to not have this as part of the core. You can easily add this as a (well tested!) utility to your application.

@nikku nikku added the needs discussion Needs further discussion label Oct 28, 2024
@nikku nikku closed this Oct 30, 2024
@nikku nikku removed the needs discussion Needs further discussion label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants