| @@ -1,15 +1,16 @@ | ||
| 1 | 1 | === SimpleTOC - Table of Contents Block === |
| 2 | 2 | Contributors: MarcDK |
| 3 | -Tags: Gutenberg, block, TOC, Table of Contents, AMP | |
| 4 | -Requires at least: 5.9 | |
| 5 | -Donate link: https://marc.tv/out/donate | |
| 6 | -Tested up to: 6.0 | |
| 7 | -Stable tag: 5.0.22 | |
| 3 | +Tags: TOC, Table of Contents, Block, Accessibility, Table | |
| 4 | +Requires at least: 6.2 | |
| 5 | +Tested up to: 7.1 | |
| 6 | +Stable tag: 7.3.1 | |
| 7 | +Requires PHP: 7.3 | |
| 8 | 8 | License: GPLv2 or later |
| 9 | 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html |
| 10 | +Donate link: https://marc.tv/out/donate | |
| 10 | 11 | |
| 11 | -Adds a custom Table of Contents Gutenberg block. | |
| 12 | +SEO-friendly Table of Contents Gutenberg block. No JavaScript or CSS by default. | |
| 12 | 13 | |
| 13 | 14 | == Description == |
| 14 | 15 | |
| 15 | 16 | Add a Table of Contents block to your posts and pages. The TOC is a nested list of links to all heading found in the post or page. To use it, simply add a block and search for "SimpleTOC" or just "TOC". |
| @@ -15,27 +16,53 @@ | ||
| 15 | 16 | Add a Table of Contents block to your posts and pages. The TOC is a nested list of links to all heading found in the post or page. To use it, simply add a block and search for "SimpleTOC" or just "TOC". |
| 16 | 17 | |
| 17 | 18 | The maximum depth of the toc can be configured in in the blocks' sidebar among many other options. There can hide the headline "Table of Contents" and add your own by using a normal heading block. |
| 18 | 19 | |
| 19 | -SimpleTOC is open-source and developed on [GitHub Pages](https://github.com/mtoensing/SimpleTOC). If you find a bug or have an idea for a feature please feel free to contribute and create a pull request. | |
| 20 | +[Spin up](https://demo.tastewp.com/simpletoc) a new WordPress instance with the SimpleTOC plugin already installed. | |
| 20 | 21 | |
| 22 | += User Feedback = | |
| 23 | + | |
| 24 | +> "It is lightweight, stable, and fully compatible with WordPress Full Site Editing. A reliable solution that integrates seamlessly and performs exactly as expected." | |
| 25 | +— [@js100 on wordpress.org](https://wordpress.org/support/topic/good-job-1889/) | |
| 26 | + | |
| 27 | +> "Does the job perfectly, and adds no bloat." | |
| 28 | +— [@clicknathan on wordpress.org](https://wordpress.org/support/topic/does-the-job-perfectly-and-adds-no-bloat/) | |
| 29 | + | |
| 30 | +> "Simple yet powerful. Great plugin that does exactly what you need." | |
| 31 | +— [@mixey on wordpress.org](https://wordpress.org/support/topic/simple-yet-powerful-106/) | |
| 32 | + | |
| 33 | += Accessibility = | |
| 34 | + | |
| 35 | +This plugin is designed & developed for WCAG 2.2 level AA conformance. The plugin is tested with assistive technology and intended to be accessible, however some third party plugins or themes may affect the individual accessibility on a given website. If you find an accessibility issue, please [let us know](https://github.com/mtoensing/simpletoc/issues) and we'll try to address it promptly. | |
| 36 | +Hidden TOCs use native `<details>` and `<summary>` semantics without extra ARIA references that require custom IDs. | |
| 37 | + | |
| 21 | 38 | = Features = |
| 22 | 39 | |
| 40 | +* Designed for Gutenberg. | |
| 23 | 41 | * Zero configuration: Add the SimpleTOC block to your post and that's it. |
| 24 | 42 | * Minimal and valid HTML output. |
| 25 | -* No JavaScript or CSS added. | |
| 26 | -* Designed for Gutenberg. | |
| 27 | -* Style SimpleTOC with Gutenberg's native group styling options. | |
| 43 | +* Utilizes the browser's built-in details tag for a collapsible interface. | |
| 44 | +* No JavaScript or CSS by default. Optional features such as the accordion menu, smooth scrolling, or box style add minimal assets only when enabled. | |
| 45 | +* Optional Box style in Gutenberg's Styles tab with a default gray background. | |
| 46 | +* Native text, link, background, spacing, and typography controls. | |
| 47 | +* Global block styling through theme.json. | |
| 28 | 48 | * Inherits the style of your theme. |
| 29 | -* Comes with English, Chinese (Taiwan), French, Spanish, German, Latvia and Brazilian Portuguese translations. | |
| 49 | +* Smooth scrolling effect using CSS. | |
| 50 | +* Accessibility built-in by following web standards. | |
| 51 | +* Standard Gutenberg block wrapper with navigation role and ARIA label attributes. | |
| 52 | +* Translated in [multiple languages](https://translate.wordpress.org/projects/wp-plugins/simpletoc/). Including German, Japanese, Chinese (Taiwan), Dutch, Brazilian Portuguese, French, Spanish and Latvia. | |
| 53 | +* Ideal for creating a Frequently Asked Questions section on your website. | |
| 30 | 54 | |
| 31 | 55 | = Customization = |
| 32 | 56 | |
| 33 | -* Add background and text color with Gutenberg groups. | |
| 57 | +* Administrators can utilize global settings to supersede the individual block settings. | |
| 58 | +* Set text, link, and background colors in Gutenberg's Styles tab. | |
| 34 | 59 | * Native block support for wide and full width. |
| 60 | +* Set vertical margins and padding with native spacing controls. | |
| 35 | 61 | * Control the maximum depth of the headings. |
| 36 | -* Choose between an ordered and unordered HTML list. | |
| 37 | -* Toggle list indent. | |
| 62 | +* Choose between an ordered, bullet HTML list. Or indent the list. | |
| 63 | +* Select the Box style directly in Gutenberg's Styles tab. | |
| 64 | +* Select a heading level or turn it into a paragraph. | |
| 38 | 65 | * Disable the h2 heading of the TOC block and add your own. |
| 39 | 66 | |
| 40 | 67 | = Compatibility = |
| 41 | 68 | |
| @@ -41,91 +68,119 @@ | ||
| 41 | 68 | |
| 42 | 69 | * GeneratePress and Rank Math support. |
| 43 | 70 | * Works with popular AMP plugins. |
| 44 | 71 | |
| 45 | -== Changelog == | |
| 72 | += How to contribute = | |
| 46 | 73 | |
| 47 | -= 5.0.22 = | |
| 48 | -* Feature: You can set the minium level of the TOC manually. | |
| 49 | -* Feature: Automatic WordPress repository deployment with GitHub actions. | |
| 74 | +SimpleTOC is open-source and developed on [GitHub Pages](https://github.com/mtoensing/SimpleTOC). If you find a bug or have an idea for a feature please feel free to contribute and create a pull request. | |
| 50 | 75 | |
| 51 | -= 5.0.21 = | |
| 52 | -* Feature: SimpleTOC updates itself after the post is saved. | |
| 76 | +== Changelog == | |
| 77 | += 7.3.1 = | |
| 78 | +* Fixed: Heading anchors for non-Latin scripts (Japanese, Chinese, Korean, Cyrillic, etc.) were double URL-encoded, breaking externally shared or hand-written fragment links. Props to the reporter of issue #89. | |
| 53 | 79 | |
| 54 | -= 5.0.17 = | |
| 55 | -* Feature: Support for custom Anchor IDs in headings. Thank you Matthias Altmann! | |
| 80 | += 7.3.0 = | |
| 81 | +* Changed: Box is now a native Gutenberg block style in the Styles tab. | |
| 82 | +* Added: Native text, link, background color, margin, and padding controls. | |
| 83 | +* Added: theme.json styling support for colors, spacing, and typography. | |
| 84 | +* Added: WordPress 7.1 support and automated compatibility tests. | |
| 85 | +* Changed: Existing box-style blocks and the global Force box style setting remain compatible. | |
| 86 | +* Thanks: Lovro Hrust (@lovor) for the theme.json and block styling feedback. | |
| 56 | 87 | |
| 57 | -= 5.0.11 = | |
| 58 | -* Feature: Support for GeneratePress headings. | |
| 88 | +== Installation == | |
| 59 | 89 | |
| 60 | -= 5.0.9 = | |
| 61 | -* Works with WordPress 6.0 | |
| 62 | -* Support for paginated posts. | |
| 90 | +SimpleTOC can be found and installed via the Plugin menu within WordPress administration (Plugins -> Add New). Alternatively, it can be downloaded from WordPress.org and installed manually... | |
| 63 | 91 | |
| 64 | -= 5.0.8 = | |
| 92 | +In Gutenberg, add a block and search for "SimpleTOC" or just "TOC". Please save your content before you use the block. | |
| 65 | 93 | |
| 66 | -* Feature: Added "simpletoc-title" and "simpletoc-list" CSS classes. This might break existing custom CSS styles that have not been applied with Gutenberg. | |
| 67 | -* Feature: Toggle list indent. | |
| 68 | -* Feature: Better "group" support. Put SimpleTOC in a group and style it with Gutenberg. See FAQ for details. | |
| 69 | -* Feature: Native block support for wide and full width. | |
| 70 | -* Feature: Added block.json and refactoring with coding standards for Gutenberg blocks. | |
| 94 | +== Frequently Asked Questions == | |
| 71 | 95 | |
| 72 | -= 4.5 = | |
| 73 | -* Feature: Add the CSS class "smooth-scroll" to the links. This enables smooth scrolling in themes like GeneratePress. | |
| 96 | += Configuring Global Settings in SimpleTOC = | |
| 74 | 97 | |
| 75 | -= 4.4.9 = | |
| 76 | -* Feature: Support for headlines in reusable blocks. | |
| 98 | +SimpleTOC allows you to configure global settings for your WordPress website. These settings can be enforced globally, overriding any block-level configurations that may exist. To access these settings, navigate to the SimpleTOC section of the WordPress Settings. | |
| 77 | 99 | |
| 78 | -= 4.4.8 = | |
| 79 | -* Feature: Added option to toggle absolute URLs. | |
| 100 | += How do I add colors or the Box style to SimpleTOC? = | |
| 80 | 101 | |
| 81 | -= 4.4.7 = | |
| 82 | -* Feature: Added option to replace ul tag with ol tag. This will add decimal numbers to each heading in the TOC. | |
| 102 | +Select the SimpleTOC block and open Gutenberg's Styles tab. Choose the Box style or use the native color controls to set text, link, and background colors. Native spacing controls are available for vertical margins and padding. | |
| 83 | 103 | |
| 84 | -= 4.3 = | |
| 85 | -* Feature: Support for non-latin headlines. SimpleTOC now uses a character block list rather than an allow list. | |
| 86 | -* Feature: Add the CSS class "simpletoc-hidden" to the heading block to remove it from the Table of Contents. | |
| 104 | += How to exclude a single heading from the TOC? = | |
| 87 | 105 | |
| 88 | -= 4.1.1 = | |
| 89 | -* Feature: Experimental support for Arabic Text. | |
| 106 | +If you really want to hide a single heading from the table of contents, then add the CSS class "simpletoc-hidden" to a heading block. You can find this field in the same place as the HTML anchor field: In the Block > Advanced sidebar. But first, think about the reason you would like to hide a specific heading. Maybe you would like to remove all headings of a specific depth level. Then there is an option for that in the blocks options in Gutenberg. If you think this heading should not be part of the toc perhaps it is not needed in the post itself? | |
| 90 | 107 | |
| 91 | -= 3.9 = | |
| 92 | -* Added Brazilian Portuguese translations to the translations. Thanks Ralden Souza! | |
| 108 | += I would like to save my SimpleTOC settings as default. Is that possible? = | |
| 93 | 109 | |
| 94 | -= 3.5 = | |
| 95 | -* Added support for Rank Math plugin. | |
| 110 | +You can convert your configured SimpleTOC block into a reusable block in Gutenberg. It will keep its settings. This way, you can use your desired settings for each new post by adding the reusable block. | |
| 96 | 111 | |
| 97 | -== Installation == | |
| 112 | += How can I style SimpleTOC through theme.json? = | |
| 98 | 113 | |
| 99 | -SimpleTOC can be found and installed via the Plugin menu within WordPress administration (Plugins -> Add New). Alternatively, it can be downloaded from WordPress.org and installed manually... | |
| 114 | +Add styles for the `simpletoc/toc` block to your theme.json. SimpleTOC uses the standard Gutenberg block wrapper and supports native colors, vertical margins, padding, font size, and line height settings. | |
| 100 | 115 | |
| 101 | -In Gutenberg, add a block and search for "SimpleTOC" or just "TOC". Please save your content before you use the block. | |
| 116 | +The following example sets default colors, spacing, and typography for every SimpleTOC block: | |
| 102 | 117 | |
| 103 | -== Frequently Asked Questions == | |
| 118 | + { | |
| 119 | + "$schema": "https://schemas.wp.org/trunk/theme.json", | |
| 120 | + "version": 3, | |
| 121 | + "styles": { | |
| 122 | + "blocks": { | |
| 123 | + "simpletoc/toc": { | |
| 124 | + "color": { | |
| 125 | + "background": "#f5f5f5", | |
| 126 | + "text": "#1e1e1e" | |
| 127 | + }, | |
| 128 | + "elements": { | |
| 129 | + "link": { | |
| 130 | + "color": { | |
| 131 | + "text": "#0057b8" | |
| 132 | + } | |
| 133 | + } | |
| 134 | + }, | |
| 135 | + "spacing": { | |
| 136 | + "margin": { | |
| 137 | + "top": "1.5rem", | |
| 138 | + "bottom": "1.5rem" | |
| 139 | + }, | |
| 140 | + "padding": { | |
| 141 | + "top": "1rem", | |
| 142 | + "right": "1rem", | |
| 143 | + "bottom": "1rem", | |
| 144 | + "left": "1rem" | |
| 145 | + } | |
| 146 | + }, | |
| 147 | + "typography": { | |
| 148 | + "fontSize": "1rem", | |
| 149 | + "lineHeight": "1.6" | |
| 150 | + } | |
| 151 | + } | |
| 152 | + } | |
| 153 | + } | |
| 154 | + } | |
| 104 | 155 | |
| 105 | -= Why did you do this? = | |
| 156 | +Replace the example values with your theme's values or preset variables. Selecting the Box style adds the standard `is-style-boxed` class. | |
| 106 | 157 | |
| 107 | -Because I needed a simple plugin to do this job and decided to do it on his own. I believe that a Table of Contents does not need Javascript and additional css. Furthermore the plugin should work out-of-the-box without any configuration. | |
| 158 | += How to allow developers to exclude specific headings programmatically? = | |
| 108 | 159 | |
| 109 | -= How do I change the TOC heading ‘Table of contents’ to some other words? = | |
| 160 | +Use the 'simpletoc_excluded_blocks' filter. For example, this code will exclude heading blocks that are inside a column block. | |
| 110 | 161 | |
| 111 | -Hide the headline in the sidebar options of SimpleTOC and add your own heading. | |
| 162 | +Example: | |
| 112 | 163 | |
| 113 | -= How do I add SimpleTOC to all articles automatically? = | |
| 164 | + add_filter( 'simpletoc_excluded_blocks', function ( array $blocks ) { | |
| 165 | + $blocks[] = 'core/column'; | |
| 114 | 166 | |
| 115 | -I don’t see an easy solution at the moment. SimpleTOC is only a block that can be placed in your post. If there would be a plugin that adds blocks to every post then this would be the solution. I think this should be another separate plug-in to keep the code of SimpleTOC clean and … well, simple. Maybe someone knows of a plug-in that adds blocks automatically to all posts with some parameters and settings? What about site editing in WordPress? I think the core team is working on something like that. I will keep this post open. If I have gained more knowledge how to solve this I will add this feature. | |
| 167 | + return $blocks; | |
| 168 | + } ); | |
| 116 | 169 | |
| 117 | -= How do I add a background color to SimpleTOC using Gutenberg groups? = | |
| 118 | 170 | |
| 119 | -Select the block and select "group" in the context menu. Apply "background color", "link color" and "text color" to this group. SimpleTOC will inherit these styles. You would like to use this styled SimpleTOC group next time you write a post? Convert it to a reusable block. | |
| 171 | += How do I change the color of the accordion menu? = | |
| 120 | 172 | |
| 121 | -= How do I add smooth scrolling? = | |
| 173 | +The heavy plus character I used can not be colored with css without hacks. But you can change the icon to something else and change the color of the new icon. | |
| 122 | 174 | |
| 123 | -You can optionally add the css class "smooth-scroll" to each link the TOC. Then you can install plugin that uses these classes. | |
| 175 | + .simpletoc-collapsible::after { | |
| 176 | + content: "✖"; | |
| 177 | + color: #e94c89; | |
| 178 | + } | |
| 124 | 179 | |
| 125 | -= How do I hide a single heading? = | |
| 180 | += How do I add SimpleTOC to all articles automatically? = | |
| 126 | 181 | |
| 127 | -If you really want to hide a single heading from the table of contents then add the CSS class "simpletoc-hidden" to a heading block. But first of all, think about the reason you want to hide a specific heading. Maybe you want to remove all headins of a specific depth level. Then there is an option for that in the blocks options in Gutenberg. If you think this heading should not be part of the toc maybe it is not needed in the post itself? | |
| 182 | +I don’t see an easy solution at the moment. SimpleTOC is only a block that can be placed in your post. If there was a plugin that adds blocks to every post, then this would be the solution. I think this should be another separate plug-in to keep the code of SimpleTOC clean and … well, simple. | |
| 128 | 183 | |
| 129 | 184 | == Screenshots == |
| 130 | 185 | 1. SimpleTOC block in Gutenberg editor. |
| 131 | 186 | 2. SimpleTOC in the post. |
| @@ -130,14 +185,17 @@ | ||
| 130 | 185 | 1. SimpleTOC block in Gutenberg editor. |
| 131 | 186 | 2. SimpleTOC in the post. |
| 132 | 187 | 3. Simple but powerful. Customize each TOC as you like. |
| 133 | 188 | 4. Control the maximum depth of the headings. |
| 134 | -5. Style SimpleTOC with Gutenbergs native group styling options. | |
| 189 | +5. SimpleTOC styled with Gutenbergs native group styles. | |
| 190 | +6. SimpleTOC Advanced Features | |
| 191 | +7. Gutenberg Heading block: Set a custom anchor | |
| 192 | +8. SimpleTOC hidden in the accordion menu. | |
| 193 | +9. SimpleTOC global settings. | |
| 135 | 194 | |
| 136 | 195 | == Credits == |
| 137 | 196 | |
| 138 | -This plugin is forked from https://github.com/pdewouters/gutentoc by pdewouters and uses code from https://github.com/shazahm1/Easy-Table-of-Contents by shazahm1 | |
| 197 | +Many thanks to [Tom J Nowell](https://tomjn.com) and and Sally CJ who both helped me a lot with my questions over at wordpress.stackexchange.com | |
| 139 | 198 | |
| 140 | -Many thanks to Tom J Nowell https://tomjn.com and and Sally CJ who both helped me a lot with my questions over at wordpress.stackexchange.com | |
| 199 | +And many more thanks to all the [developers on GitHub](https://github.com/mtoensing/simpletoc/graphs/contributors) who helped me making SimpleTOC what it is today! | |
| 141 | 200 | |
| 142 | -Thanks to Quintus Valerius Soranus for inventing the Table of Contents around 100 BC. | |
| 143 | - | |
| 201 | +Thanks to Quintus Valerius Soranus for inventing the Table of Contents around 100 BC. | |