diff --git a/functions.php b/functions.php index 1d7657c..f22c3b3 100644 --- a/functions.php +++ b/functions.php @@ -33,10 +33,7 @@ require_once __DIR__ . '/includes/update/index.php'; require_once __DIR__ . '/build/components/index.php'; require_once __DIR__ . '/build/edit-post/index.php'; -require_once __DIR__ . '/build/format-library/bold/index.php'; -require_once __DIR__ . '/build/format-library/code/index.php'; -require_once __DIR__ . '/build/format-library/font-size/index.php'; -require_once __DIR__ . '/build/format-library/icon/index.php'; +require_once __DIR__ . '/build/format-library/index.php'; require_once __DIR__ . '/build/utils/index.php'; require_once __DIR__ . '/build/plugins/index.php'; require_once __DIR__ . '/build/preferences/index.php'; diff --git a/readme.txt b/readme.txt index bfc2379..bbb20fa 100644 --- a/readme.txt +++ b/readme.txt @@ -10,6 +10,10 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html == Changelog == += 1.4.0 = + +- Added Format Settings + = 1.3.0 = 2024-12-30 - Added Table of Contents block diff --git a/src/format-library/block-toolbar/index.js b/src/format-library/block-toolbar/index.js new file mode 100644 index 0000000..2439da9 --- /dev/null +++ b/src/format-library/block-toolbar/index.js @@ -0,0 +1,70 @@ +/** + * External dependencies + */ +import clsx from 'clsx'; + +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { BlockFormatControls } from '@wordpress/block-editor'; +import { registerFormatType } from '@wordpress/rich-text'; +import { ToolbarItem, Slot, DropdownMenu } from '@wordpress/components'; +import { Icon } from '@wordpress/icons'; + +import { blockCategoryIcon } from '../../icons'; + +const POPOVER_PROPS = { + placement: 'bottom-start', +}; + +const BlockToolbar = () => { + return ( + + + { ( fills ) => { + if ( ! fills.length ) { + return null; + } + + const allProps = fills.map( ( [ { props } ] ) => props ); + const hasActive = allProps.some( + ( { isActive } ) => isActive + ); + + return ( + + { ( toggleProps ) => ( + } + label={ __( 'Mone Menu', 'mone' ) } + toggleProps={ { + ...toggleProps, + className: clsx( + toggleProps.className, + { 'is-pressed': hasActive } + ), + description: __( + 'Displays more mone tools' + ), + } } + controls={ fills.map( + ( [ { props } ] ) => props + ) } + popoverProps={ POPOVER_PROPS } + /> + ) } + + ); + } } + + + ); +}; + +registerFormatType( 'mone/block-toolbar', { + title: __( 'Block Toolbar', 'mone' ), + tagName: 'block-toolbar', + className: null, + edit: BlockToolbar, +} ); diff --git a/src/format-library/bold/block.json b/src/format-library/block.json similarity index 100% rename from src/format-library/bold/block.json rename to src/format-library/block.json diff --git a/src/format-library/bold/bold.js b/src/format-library/bold/bold.js index a8a8af9..56e83ea 100644 --- a/src/format-library/bold/bold.js +++ b/src/format-library/bold/bold.js @@ -36,7 +36,7 @@ export const bag = { onUse={ onToggle } /> { return ( <> { diff --git a/src/format-library/index.js b/src/format-library/index.js new file mode 100644 index 0000000..381c3a8 --- /dev/null +++ b/src/format-library/index.js @@ -0,0 +1,7 @@ +import './block-toolbar'; +import './bold'; +import './code'; +import './font-size'; +import './icon'; + +import './style.scss'; diff --git a/src/format-library/icon/index.php b/src/format-library/index.php similarity index 51% rename from src/format-library/icon/index.php rename to src/format-library/index.php index d21d954..f069add 100644 --- a/src/format-library/icon/index.php +++ b/src/format-library/index.php @@ -1,63 +1,42 @@ 'This is a value from PHP', - 'templateUri' => MONE_TEMPLATE_DIR_URL, - ); - wp_localize_script( 'mone-icon-script', 'moneData', $data_to_pass ); wp_set_script_translations( - 'mone-icon-script', + 'mone-format-script', 'mone', MONE_TEMPLATE_DIR_PATH . '/languages' ); } wp_enqueue_style( - 'mone/icon', - MONE_TEMPLATE_DIR_URL . '/build/format-library/icon/style-index.css' - ); -} -add_action( 'enqueue_block_assets', __NAMESPACE__ . '\enqueue_block_editor_icon' ); - -/** - * Enqueue_style_icon - */ -function register_format_icon() { - $asset_file = include MONE_TEMPLATE_DIR_PATH . '/build/format-library/icon/index.asset.php'; - wp_enqueue_style( - 'mone/icon', - MONE_TEMPLATE_DIR_URL . '/build/format-library/icon/style-index.css', - array(), - $asset_file['version'] + 'mone/format', + MONE_TEMPLATE_DIR_URL . '/build/format-library/style-index.css' ); } -add_action( 'init', __NAMESPACE__ . '\register_format_icon' ); +add_action( 'enqueue_block_assets', __NAMESPACE__ . '\enqueue_block_editor_format' ); /** * Mark CSS safe if it contains a "--the-icon-svg: url(data:image/svg+xml" rule. diff --git a/src/format-library/style.scss b/src/format-library/style.scss new file mode 100644 index 0000000..b9fe406 --- /dev/null +++ b/src/format-library/style.scss @@ -0,0 +1,2 @@ +@import './code/style.scss'; +@import './icon/style.scss';