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

Shape: Default name of shape #34

Open
kanarelo opened this issue Oct 15, 2021 · 2 comments
Open

Shape: Default name of shape #34

kanarelo opened this issue Oct 15, 2021 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@kanarelo
Copy link

I know we have discussed this is #24. But I feel that we should have default names for each shape created.

In #24 you had suggested that we should pass the name such as:

const rect = editor.shapes.rect.insert({
   name: '<name>',
   // rest config
})

and access that through console.log(rect.node.name()), or change the name through rect.node.name('<new name>')

I feel that this leaves room for bugs, due to missing this in Pikaso's documentation.

I suggest we add a method renameShape() and add

public insert(config: Konva.ArrowConfig): ArrowModel {
    return super.insert({
         name: `${type}`
         ...config
    })
}

and duplicate take the name of the original, and postfix -copy, e.g, triangle to triangle-copy.

Two shapes can have the same name however...

@kanarelo kanarelo added the feature request New feature request label Oct 15, 2021
@raminious
Copy link
Contributor

Konva architecture allows multiple shapes to have the same name. This is sort of like HTML class names.
https://konvajs.org/docs/selectors/Select_by_Name.html
but id is unique. and I think Konva guarantees that. so for your use case it would be:

const rect = editor.shapes.rect.insert({
})

console.log(rect.node.id())

https://konvajs.org/api/Konva.Shape.html#id

@raminious raminious added question Further information is requested and removed feature request New feature request labels Oct 16, 2021
@kanarelo
Copy link
Author

@raminious I think the best way to approach this is explicitly have it in the pikaso documentation, like how to pass the default name. I get you.

@raminious raminious added the documentation Improvements or additions to documentation label Oct 16, 2021
@kanarelo kanarelo reopened this Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants