Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add heading hierarchy checker notice #14889
Add heading hierarchy checker notice #14889
Changes from 2 commits
ec509c3
3d28ae5
df75f91
e997892
c2dcb6b
3fa3845
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jorgefilipecosta - is there a way to get all heading blocks only so we didn't have to use
computeOutlineHeadings
in the first place?There is getGlobalBlockCount, so something similar would be nice.
That way we could share the same selector in both places and remove this
computeOutlineHeadings
helper altogether.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact,
headings
has been computed ingutenberg/packages/editor/src/components/document-outline/index.js
Lines 67 to 69 in 8722f49
I am not sure whether we could avoid computing it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can if we create memoized shared selector, similar to how
getBlocks
is cached as of today. It might be a complicated task and that's why I asked @jorgefilipecosta for help.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could create a generic selector that returns the blocks of a given type, so it is not specific to this functionality.
But I'm not sure if it would fit our needs, computeOutlineHeadings does more than just returning the heading blocks, it computes, for example, the heading path required to show the path where a heading is nested on.
I think in this specific case just the selector would work, but in the checks, we do in the Content Structure we would still need something like computeOutlineHeadings to associate a path to each heading.
Exposing a selector that does what computeOutlineHeadings does (or similar functionality with paths) seems very specific to this functionality.
I guess a possible path here is just implementing level-checker.js as part of the editor module and reusing computeOutlineHeadings there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It no longer should be exported: