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

make NodeType.groups public #1489

Closed
YousefED opened this issue Oct 4, 2024 · 7 comments
Closed

make NodeType.groups public #1489

YousefED opened this issue Oct 4, 2024 · 7 comments

Comments

@YousefED
Copy link

YousefED commented Oct 4, 2024

I noticed NodeType.groups is marked as internal: https://github.com/ProseMirror/prosemirror-model/blob/a57531574336d00df43a68e3a2f69582b426033e/src/schema.ts#L62.

I think it can be quite useful for consumers in case nodes are part of multiple groups. Makes sense to expose it so that types are properly exported? Or is there a specific reason it's marked as internal?

@marijnh
Copy link
Member

marijnh commented Oct 4, 2024

What is the use case where you need to enumerate the groups a node is part of? The general idea behind groups is that they allow you query whether a node is part of a given group with .is(). I haven't run into a situation where I need to find a node's groups.

@YousefED
Copy link
Author

YousefED commented Oct 4, 2024

That'd be my use-case indeed. Which .is() do you mean? I feel like I'm missing something obvious but I don't see it on Node or NodeType

@marijnh
Copy link
Member

marijnh commented Oct 4, 2024

NodeType.is, which accepts both node names and group names.

@YousefED
Copy link
Author

YousefED commented Oct 5, 2024

I think you're referring to the lezer docs. As far as I see from browsing Prosemirror source code / types / docs it's not available in prosemirror?

@marijnh
Copy link
Member

marijnh commented Oct 5, 2024

Wow, indeed, I was somewhere else entirely—wrong NodeType class for this repository.

Would an isInGroup(group: string) => boolean method cover your use case?

@YousefED
Copy link
Author

YousefED commented Oct 5, 2024

Ha I thought I was going crazy!

Yes your suggestion would be perfect 👍

@marijnh
Copy link
Member

marijnh commented Oct 5, 2024

Done in attached patch.

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

No branches or pull requests

2 participants