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

Provide a nestLevel property to list prefix renderers #312

Closed
jsamr opened this issue Oct 30, 2019 · 2 comments
Closed

Provide a nestLevel property to list prefix renderers #312

jsamr opened this issue Oct 30, 2019 · 2 comments

Comments

@jsamr
Copy link
Collaborator

jsamr commented Oct 30, 2019

Is this a bug report or a feature request?

Feature Request

Have you read the guidelines regarding bug report?

Yes.

Have you read the documentation in its entirety?

Yes

Have you made sure that your issue hasn't already been reported/solved?

Yes

Description

Provide a { nestLevel } property to list prefix renderers.

Usage

const listsPrefixesRenderers = {
  ul: ({ nestLevel }) => {
    if (nestLevel === 0) return <Square />
    if (nestLevel === 1) return <Bullet />
    return <Triangle />
  }
}
@lyqht
Copy link

lyqht commented Dec 13, 2019

Agree with this

@pxmage
Copy link

pxmage commented Mar 22, 2020

Hey guys @lyqht @jsamr and anyone who runs into this problem.

I kind of figure out a work-around to share with you.

You could take advantage of alterNode Feature

try check this

alterNode={(node) => {
  const { name, parent } = node;
  if(name === 'li') {
    console.log(getParentsTagsRecursively(node))
  }
}}

and you will get output like:

["li", "ul", "li", "ul", "li", "ul"]

where there are all parent tags listed inside an array, then you count the number of uls and you get the nested level. You could apply the level data to the node.

You can do whatever you like to customize it :)

jsamr added a commit that referenced this issue Jan 14, 2021
The list renderer can now be extended with
getListStyleTypeFromNestLevel prop.

resolves #312
@jsamr jsamr closed this as completed in ddd66bb Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants