FEATURE addind a blockVariation style for the core heading to handle a streoked after
This commit is contained in:
parent
2d24bd3a1d
commit
ae873507e2
|
|
@ -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');
|
||||
|
|
|
|||
19
plugins/carhop-blocks/src/core-heading-variant/editor.js
Normal file
19
plugins/carhop-blocks/src/core-heading-variant/editor.js
Normal file
|
|
@ -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 ",
|
||||
// });
|
||||
Loading…
Reference in New Issue
Block a user