Skip to content

Commit 05aae42

Browse files
committed
Release 7.0.1 with editor settings link improvements
1 parent 5f32b92 commit 05aae42

9 files changed

Lines changed: 80 additions & 16 deletions

File tree

build/block.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://schemas.wp.org/trunk/block.json",
33
"apiVersion": 3,
44
"name": "simpletoc/toc",
5-
"version": "7.0.0",
5+
"version": "7.0.1",
66
"title": "SimpleTOC",
77
"category": "layout",
88
"icon": "<svg clip-rule='evenodd' fill-rule='evenodd' stroke-linejoin='round' stroke-miterlimit='2' viewBox='0 0 500 500' xmlns='http://www.w3.org/2000/svg'><path d='m365.983 78.248c2.72-32.415 29.921-57.908 63.029-57.908 34.91 0 63.253 28.342 63.253 63.252s-28.343 63.252-63.253 63.252v269.582c0 25.232-20.485 45.718-45.718 45.718h-313.62c-25.233 0-45.719-20.486-45.719-45.718v-292.46c0-25.233 20.486-45.718 45.719-45.718z' fill='#070D0D'/><g fill='#fff'><path d='m423.898 112.744v-24.188h-24.008v-10.108h24.008v-24.008h10.229v24.008h24.008v10.108h-24.008v24.188z'/><path d='m120.04 403.105c-16.883 0-30.511-13.719-30.511-30.714 0-16.79 13.628-30.714 30.511-30.714 16.679 0 30.511 13.924 30.511 30.714 0 16.995-13.832 30.714-30.511 30.714z'/><path d='m170.891 362.153h183.063v20.476h-183.063z'/><path d='m120.04 300.725c-16.883 0-30.511-13.719-30.511-30.714 0-16.79 13.628-30.714 30.511-30.714 16.679 0 30.511 13.924 30.511 30.714 0 16.995-13.832 30.714-30.511 30.714z'/><path d='m170.891 259.773h183.063v20.476h-183.063z'/><path d='m120.04 198.345c-16.883 0-30.511-13.719-30.511-30.714 0-16.791 13.628-30.714 30.511-30.714 16.679 0 30.511 13.923 30.511 30.714 0 16.995-13.832 30.714-30.511 30.714z'/><path d='m170.891 157.393h183.063v20.476h-183.063z'/></g></svg>",

build/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-server-side-render'), 'version' => 'a4ade5f03c1b37ebe68f');
1+
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-server-side-render'), 'version' => 'e87d1713e351960773a2');

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simpletoc",
3-
"version": "7.0.0",
3+
"version": "7.0.1",
44
"author": "Marc Tönsing",
55
"description": "SEO-friendly Table of Contents Gutenberg block. No JavaScript or CSS by default.",
66
"main": "build/index.js",

plugin.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: SimpleTOC - Table of Contents Block
44
* Plugin URI: https://marc.tv/simpletoc-wordpress-inhaltsverzeichnis-plugin-gutenberg/
55
* Description: SEO-friendly Table of Contents Gutenberg block. No JavaScript or CSS by default.
6-
* Version: 7.0.0
6+
* Version: 7.0.1
77
* Author: Marc Tönsing
88
* Author URI: https://toensing.com
99
* Text Domain: simpletoc
@@ -50,10 +50,36 @@ function register_simpletoc_block() {
5050
'render_callback' => __NAMESPACE__ . '\render_callback_simpletoc',
5151
)
5252
);
53+
54+
wp_add_inline_script(
55+
'simpletoc-toc-editor-script',
56+
'window.simpletocEditorSettings = ' . wp_json_encode(
57+
array(
58+
'settingsUrl' => admin_url( 'options-general.php?page=simpletoc' ),
59+
)
60+
) . ';',
61+
'before'
62+
);
5363
}
5464

5565
add_action( 'init', __NAMESPACE__ . '\register_simpletoc_block' );
5666

67+
/**
68+
* Adds SimpleTOC-specific block editor settings.
69+
*
70+
* @param array $editor_settings Default editor settings.
71+
* @param \WP_Block_Editor_Context $editor_context Editor context.
72+
*
73+
* @return array
74+
*/
75+
function add_simpletoc_block_editor_settings( $editor_settings, $editor_context ) {
76+
$editor_settings['simpletocSettingsUrl'] = admin_url( 'options-general.php?page=simpletoc' );
77+
78+
return $editor_settings;
79+
}
80+
81+
add_filter( 'block_editor_settings_all', __NAMESPACE__ . '\add_simpletoc_block_editor_settings', 10, 2 );
82+
5783
/**
5884
* Inject potentially missing translations into the block-editor i18n
5985
* collection.

readme.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: MarcDK
33
Tags: TOC, Table of Contents, Block, Accessibility, Table
44
Requires at least: 5.9
55
Tested up to: 6.9
6-
Stable tag: 7.0.0
6+
Stable tag: 7.0.1
77
Requires PHP: 7.3
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -58,6 +58,7 @@ This plugin is designed & developed for WCAG 2.2 level AA conformance. The plugi
5858
* Control the maximum depth of the headings.
5959
* Choose between an ordered, bullet HTML list. Or indent the list.
6060
* Enable a box style and choose a box color directly in the block sidebar.
61+
* Open the global SimpleTOC settings directly from the Advanced Features sidebar in the editor.
6162
* Select a heading level or turn it into a paragraph.
6263
* Disable the h2 heading of the TOC block and add your own.
6364

@@ -72,6 +73,11 @@ SimpleTOC is open-source and developed on [GitHub Pages](https://github.com/mtoe
7273

7374
== Changelog ==
7475

76+
= 7.0.1 =
77+
* Added: Direct link from the Advanced Features sidebar to the global SimpleTOC settings.
78+
* Fixed: Global settings link now appears reliably in the editor sidebar.
79+
* Changed: Wrapper toggle now reflects the automatic wrapper state while box style is active.
80+
7581
= 7.0.0 =
7682
* Added: Box style option in the block sidebar with a color picker and default gray background.
7783
* Added: Global setting to force the default gray box style for all SimpleTOC blocks.

src/block.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://schemas.wp.org/trunk/block.json",
33
"apiVersion": 3,
44
"name": "simpletoc/toc",
5-
"version": "7.0.0",
5+
"version": "7.0.1",
66
"title": "SimpleTOC",
77
"category": "layout",
88
"icon": "<svg clip-rule='evenodd' fill-rule='evenodd' stroke-linejoin='round' stroke-miterlimit='2' viewBox='0 0 500 500' xmlns='http://www.w3.org/2000/svg'><path d='m365.983 78.248c2.72-32.415 29.921-57.908 63.029-57.908 34.91 0 63.253 28.342 63.253 63.252s-28.343 63.252-63.253 63.252v269.582c0 25.232-20.485 45.718-45.718 45.718h-313.62c-25.233 0-45.719-20.486-45.719-45.718v-292.46c0-25.233 20.486-45.718 45.719-45.718z' fill='#070D0D'/><g fill='#fff'><path d='m423.898 112.744v-24.188h-24.008v-10.108h24.008v-24.008h10.229v24.008h24.008v10.108h-24.008v24.188z'/><path d='m120.04 403.105c-16.883 0-30.511-13.719-30.511-30.714 0-16.79 13.628-30.714 30.511-30.714 16.679 0 30.511 13.924 30.511 30.714 0 16.995-13.832 30.714-30.511 30.714z'/><path d='m170.891 362.153h183.063v20.476h-183.063z'/><path d='m120.04 300.725c-16.883 0-30.511-13.719-30.511-30.714 0-16.79 13.628-30.714 30.511-30.714 16.679 0 30.511 13.924 30.511 30.714 0 16.995-13.832 30.714-30.511 30.714z'/><path d='m170.891 259.773h183.063v20.476h-183.063z'/><path d='m120.04 198.345c-16.883 0-30.511-13.719-30.511-30.714 0-16.791 13.628-30.714 30.511-30.714 16.679 0 30.511 13.923 30.511 30.714 0 16.995-13.832 30.714-30.511 30.714z'/><path d='m170.891 157.393h183.063v20.476h-183.063z'/></g></svg>",

src/edit.js

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,16 @@ export default function Edit( { attributes, setAttributes } ) {
6666
}, [] );
6767

6868
const { autoupdate } = attributes;
69-
const boxColors = useSelect( ( select ) => {
70-
return select( blockEditorStore ).getSettings()?.colors || [];
69+
const editorSettings = useSelect( ( select ) => {
70+
return select( blockEditorStore ).getSettings() || {};
7171
}, [] );
72+
const boxColors = editorSettings.colors || [];
7273
const selectedBoxColor = attributes.box_color;
74+
const wrapperEnabled = attributes.wrapper || attributes.box_style;
75+
const settingsUrl =
76+
editorSettings.simpletocSettingsUrl ||
77+
window.simpletocEditorSettings?.settingsUrl ||
78+
'';
7379

7480
const { returnisSaving, returnisSavingNonPostEntityChanges } = useSelect(
7581
( select ) => {
@@ -459,11 +465,19 @@ export default function Edit( { attributes, setAttributes } ) {
459465
<PanelRow>
460466
<ToggleControl
461467
label={ __( 'Wrapper div', 'simpletoc' ) }
462-
help={ __(
463-
'Additionally adds the role "navigation" and ARIA attributes.',
464-
'simpletoc'
465-
) }
466-
checked={ attributes.wrapper }
468+
help={
469+
attributes.box_style
470+
? __(
471+
'Enabled automatically while box style is active.',
472+
'simpletoc'
473+
)
474+
: __(
475+
'Additionally adds the role "navigation" and ARIA attributes.',
476+
'simpletoc'
477+
)
478+
}
479+
checked={ wrapperEnabled }
480+
disabled={ attributes.box_style }
467481
onChange={ () =>
468482
setAttributes( {
469483
wrapper: ! attributes.wrapper,
@@ -486,6 +500,24 @@ export default function Edit( { attributes, setAttributes } ) {
486500
}
487501
/>
488502
</PanelRow>
503+
{ settingsUrl && (
504+
<PanelRow>
505+
<BaseControl
506+
id="simpletoc-global-settings-link"
507+
help={ __(
508+
'Global SimpleTOC settings can enforce these options for all blocks.',
509+
'simpletoc'
510+
) }
511+
>
512+
<ExternalLink href={ settingsUrl }>
513+
{ __(
514+
'Open global SimpleTOC settings',
515+
'simpletoc'
516+
) }
517+
</ExternalLink>
518+
</BaseControl>
519+
</PanelRow>
520+
) }
489521
</PanelBody>
490522
</Panel>
491523
</InspectorControls>

0 commit comments

Comments
 (0)