Skip to content

Get model as custom shape from dia.Cell #2810

Closed Answered by elinake
elinake asked this question in Q&A
Discussion options

You must be logged in to vote

I found out that I can have a "type guard predicate function" -

  isCustomElement(el: dia.Cell): el is CustomElement {
    return el instanceof CustomElement;
  }

and then find the cell:

    const ch = cells
      .filter(this.isCustomElement)
      .find((cell) => cell.get('meta')?.id === 1);
    ch?.setBorder(true);
  

Apparently the type guard can't be combined with another condition, so that's why filter and find need to be done separately.

So, seems this was a typescript problem rather than jointJS :)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@elinake
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by elinake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants