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

Display heading levels dynamically in Heading Options when Heading block is selected #14688

Open
igmoweb opened this issue Mar 28, 2019 · 1 comment
Labels
[Block] Heading Affects the Headings Block [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.

Comments

@igmoweb
Copy link

igmoweb commented Mar 28, 2019

So far, the heading levels are hardcoded in the Heading Edit component.

Captura de pantalla 2019-03-28 a las 18 13 33

Here are the current lines of code in public_html/wp-content/plugins/gutenberg/packages/block-library/src/heading:

<HeadingToolbar minLevel={ 2 } maxLevel={ 5 } selectedLevel={ level } onChange={ ( newLevel ) => setAttributes( { level: newLevel } ) } />

And

<HeadingToolbar minLevel={ 1 } maxLevel={ 7 } selectedLevel={ level } onChange={ ( newLevel ) => setAttributes( { level: newLevel } ) } />

However, under some circumstances, this selection could be limited by using blocks.registerBlockType filter to a reduced set of headings. Right now this is tricky due to the hardcoded numbers.

Describe the solution you'd like
Dynamically, extract the level numbers from selector attribute in attributes.content for Heading Block and generate the range of selectors based on that list.

I'm pushing a PR to demonstrate in a sec.

@igmoweb
Copy link
Author

igmoweb commented Mar 28, 2019

PR: #14689

@gziolo gziolo added [Block] Heading Affects the Headings Block [Feature] Extensibility The ability to extend blocks or the editing experience [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement. labels Apr 10, 2019
@skorasaurus skorasaurus removed the [Status] In Progress Tracking issues with work in progress label May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Heading Affects the Headings Block [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants