import './reveal';
import './pro-effects';
import { BlockControls, InspectorControls } from '@wordpress/block-editor';
import { hasBlockSupport } from '@wordpress/blocks';
import {
__experimentalToolsPanel as ExperimentalToolsPanel,
__stableToolsPanel as StableToolsPanel,
Button,
MenuGroup,
ToolbarDropdownMenu,
} from '@wordpress/components';
import { addFilter } from '@wordpress/hooks';
import { __ } from '@wordpress/i18n';
import ApplyFilters from '../../components/apply-filters';
import getIcon from '../../utils/get-icon';
const ToolsPanel = StableToolsPanel || ExperimentalToolsPanel;
/**
* Add inspector controls.
*
* @param original
* @param root0
* @param root0.props
*/
function GhostKitExtensionEffectsInspector(original, { props }) {
const { name, attributes, setAttributes } = props;
const hasEffectsSupport = hasBlockSupport(name, ['ghostkit', 'effects']);
if (!hasEffectsSupport) {
return original;
}
return (
<>
{original}
{getIcon('extension-sr')}
{__('Effects', 'ghostkit')}
>
}
resetAll={() => {
const ghostkitData = {
...(attributes?.ghostkit || {}),
};
if (typeof ghostkitData?.effects !== 'undefined') {
delete ghostkitData?.effects;
setAttributes({ ghostkit: ghostkitData });
}
}}
>
>
);
}
/**
* Add toolbar controls.
*
* @param original
* @param root0
* @param root0.props
*/
function GhostKitExtensionEffectsToolbar(original, { props }) {
const { name, attributes, setAttributes } = props;
const hasEffectsSupport = hasBlockSupport(name, ['ghostkit', 'effects']);
if (!hasEffectsSupport) {
return original;
}
const hasEffects = attributes?.ghostkit?.effects;
if (!hasEffects) {
return original;
}
return (
<>
{original}
{() => (
<>
{__(
'There are effects added to the current block. To change these options open the "Effects" block settings panel.',
'ghostkit'
)}
{__(
'Reset all effects of the current block:',
'ghostkit'
)}
>
)}
>
);
}
// Init filters.
addFilter(
'ghostkit.editor.extensions',
'ghostkit/extension/effects/inspector',
GhostKitExtensionEffectsInspector,
11
);
addFilter(
'ghostkit.editor.extensions',
'ghostkit/extension/effects/toolbar',
GhostKitExtensionEffectsToolbar
);