diff --git a/plugins/carhop-blocks/carhop-blocks.php b/plugins/carhop-blocks/carhop-blocks.php index ea12b9c..91df22d 100644 --- a/plugins/carhop-blocks/carhop-blocks.php +++ b/plugins/carhop-blocks/carhop-blocks.php @@ -100,3 +100,28 @@ function carhop_register_blocks() ); } add_action('init', 'carhop_register_blocks'); + +/* ---------------------------------------------------------------- + ##### EDITOR EXTENSIONS + ------------------------------------------------------------------*/ +/** + * Étend le bloc Titre (core/heading) avec un attribut "carhopVariant" + * et ajoute une interface pour choisir une variante (ajoute une classe CSS). + */ +function carhop_enqueue_editor_assets() +{ + $script_path = __DIR__ . '/src/core-heading-variant/editor.js'; + if (!file_exists($script_path)) { + return; + } + + + wp_enqueue_script( + 'carhop-heading-variant', + plugins_url('src/core-heading-variant/editor.js', __FILE__), + array('wp-blocks', 'wp-element', 'wp-dom-ready', 'wp-components', 'wp-compose', 'wp-data', 'wp-hooks', 'wp-i18n', 'wp-block-editor', 'wp-edit-post'), + filemtime($script_path), + true + ); +} +add_action('enqueue_block_editor_assets', 'carhop_enqueue_editor_assets'); diff --git a/plugins/carhop-blocks/src/core-heading-variant/editor.js b/plugins/carhop-blocks/src/core-heading-variant/editor.js new file mode 100644 index 0000000..7bb97ca --- /dev/null +++ b/plugins/carhop-blocks/src/core-heading-variant/editor.js @@ -0,0 +1,19 @@ +// wp.blocks.registerBlockVariation("core/heading", { +// name: "heading-variant", +// title: "Titre + trait ", + +// attributes: { +// className: "is-styled-stroked-after", +// }, +// scope: ["inserter", "block", "transform"], +// }); + +wp.blocks.registerBlockStyle("core/heading", { + name: "stroked-after", + label: "Titre + trait ", +}); + +// wp.blocks.registerBlockStyle("carhop-blocks/heading", { +// name: "stroked-after", +// label: "Titre + trait ", +// });