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

Add a Table of Contents block #2871

Closed
wants to merge 5 commits into from
Closed

Conversation

pento
Copy link
Member

@pento pento commented Oct 4, 2017

Description

This is a first pass at creating a dynamically generated table of contents block. It still lacks... most things, and is at least partially a sandbox for me to play around with creating more complex blocks. 🙂

Fixes #1760.

@pento pento added [Feature] Blocks Overall functionality of blocks New Block Suggestion for a new block [Status] Horrible Hack [Status] In Progress Tracking issues with work in progress labels Oct 4, 2017
@mtias
Copy link
Member

mtias commented Oct 4, 2017

Interesting approach. When I was going to tackle this one I thought it might be interesting to make it static—it'd update whenever you interact with the editor, and would save HTML directly. That would be regenerated whenever you edited headings in the editor.

@pento
Copy link
Member Author

pento commented Oct 9, 2017

Yah, I thought about that - having to write duplicate code (one for the block render in JS, one for the frontend render in PHP) isn't ideal, but it means that any headers added by not-Gutenberg will be correctly rendered.

I tend to lean towards implementing this kind of logic in the server side, instead of requiring every editor that interacts with a WordPress site to implement it.

@codecov
Copy link

codecov bot commented Oct 9, 2017

Codecov Report

Merging #2871 into master will decrease coverage by <.01%.
The diff coverage is 42.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2871      +/-   ##
==========================================
- Coverage   34.07%   34.07%   -0.01%     
==========================================
  Files         192      193       +1     
  Lines        5675     5681       +6     
  Branches      996      997       +1     
==========================================
+ Hits         1934     1936       +2     
- Misses       3165     3169       +4     
  Partials      576      576
Impacted Files Coverage Δ
blocks/editable/index.js 10.5% <100%> (ø) ⬆️
blocks/library/table-of-contents/index.js 33.33% <33.33%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 27cd1f5...1dae5ea. Read the comment docs.

@pento pento force-pushed the add/1760-block-table-of-contents branch from c1c600c to 69e87d4 Compare October 9, 2017 05:51
@pento
Copy link
Member Author

pento commented Oct 9, 2017

In order to show the ToC in the block render inside Gutenberg, I believe I'm blocked on #2473.

@gziolo
Copy link
Member

gziolo commented Mar 8, 2018

I think you are no longer blocked. It is possible to access every piece of the state through data module as described here: https://github.com/WordPress/gutenberg/tree/master/data.

@mcsf
Copy link
Contributor

mcsf commented Apr 2, 2018

@pento, feel free to reopen this one. For now, with the branch stale, I'll close it as we're making sense of all open PRs. 🙇

@mcsf mcsf closed this Apr 2, 2018
@mcsf mcsf deleted the add/1760-block-table-of-contents branch April 2, 2018 17:56
@mtias mtias mentioned this pull request Jun 4, 2018
@ghost ghost mentioned this pull request Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks New Block Suggestion for a new block [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants