-
Notifications
You must be signed in to change notification settings - Fork 4.9k
ToC block: re-enable + use static markup and only support core Heading and Page Break blocks #29739
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
Changes from all commits
c53df83
afadefa
2796c70
f564667
4b7bbc6
0ff623d
8ba556a
dc2730a
8f7db2d
4282578
3080087
803eddc
6a724bf
1eb8d22
e7e866a
6221796
38bb612
a8a1cbd
6d9c653
21adec5
fa6cc7d
2ed8a4a
c439c5b
425109f
327338f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -208,6 +208,13 @@ const transforms = { | |
| } ); | ||
| }, | ||
| }, | ||
| { | ||
| type: 'block', | ||
| blocks: [ 'core/table-of-contents' ], | ||
| transform: () => { | ||
| return createBlock( 'core/table-of-contents' ); | ||
| }, | ||
| }, | ||
|
Comment on lines
211
to
217
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what value this brings!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think of it as serving a similar function to the transforms for the Navigation Link that let you convert a Page Link to a Category Link (and etc.)... obviously, the block just gets replaced with little to nothing kept from the original block, but the purpose is to make replacing the block easier. If you convert a Table of Contents to a static list, but then want to go back later, a transform is more convenient than deleting the List and inserting a ToC. Or at least that's the idea. (In the future, some simple stuff like background/text color from the List could be transferred over, but I decided against adding those to the ToC right now to avoid making this PR even bigger.) |
||
| ], | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,13 +8,19 @@ | |
| "keywords": [ "document outline", "summary" ], | ||
| "textdomain": "default", | ||
| "attributes": { | ||
| "headings": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "object" | ||
| } | ||
| }, | ||
| "onlyIncludeCurrentPage": { | ||
| "type": "boolean", | ||
| "default": false | ||
| } | ||
| }, | ||
| "usesContext": [ "postId" ], | ||
| "supports": { | ||
| "html": false | ||
| } | ||
| }, | ||
| "example": {} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be cool to have something basic here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because of how the block updates itself, any dummy heading data put in here would be quickly overwritten (I think). Perhaps if there was a way to detect if the block was being rendered in "example-preview mode" or whatever, this could be worked around. It would be kinda hacky to do something like that, though. A somewhat less weird solution would be to add the ability for examples to include "context" blocks that aren't shown in the preview, but are still part of the simulated document the previewed block is a part of. No clue what the schema changes necessary would be, nor if such a thing is even worth considering. It seems perhaps a bit too convoluted. |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.