| 1 |
import './opacity'; |
| 2 |
import './overflow'; |
| 3 |
import './cursor'; |
| 4 |
import './userSelect'; |
| 5 |
import './clipPath'; |
| 6 |
import './pro-transition'; |
| 7 |
import './custom'; |
| 8 |
|
| 9 |
import { InspectorControls } from '@wordpress/block-editor'; |
| 10 |
import { hasBlockSupport } from '@wordpress/blocks'; |
| 11 |
import { |
| 12 |
__experimentalToolsPanel as ExperimentalToolsPanel, |
| 13 |
__stableToolsPanel as StableToolsPanel, |
| 14 |
} from '@wordpress/components'; |
| 15 |
import { addFilter } from '@wordpress/hooks'; |
| 16 |
import { __ } from '@wordpress/i18n'; |
| 17 |
|
| 18 |
import ApplyFilters from '../../components/apply-filters'; |
| 19 |
import useStyles from '../../hooks/use-styles'; |
| 20 |
import getIcon from '../../utils/get-icon'; |
| 21 |
import { EXTENSIONS } from '../constants'; |
| 22 |
|
| 23 |
const ToolsPanel = StableToolsPanel || ExperimentalToolsPanel; |
| 24 |
|
| 25 |
const allCustomCSS = EXTENSIONS.customCSS.styles; |
| 26 |
|
| 27 |
/** |
| 28 |
* Add inspector controls. |
| 29 |
* |
| 30 |
* @param original |
| 31 |
* @param root0 |
| 32 |
* @param root0.props |
| 33 |
*/ |
| 34 |
function GhostKitExtensionCustomCSSInspector(original, { props }) { |
| 35 |
const { name } = props; |
| 36 |
|
| 37 |
const hasCustomCSSSupport = hasBlockSupport(name, [ |
| 38 |
'ghostkit', |
| 39 |
'customCSS', |
| 40 |
]); |
| 41 |
|
| 42 |
if (!hasCustomCSSSupport) { |
| 43 |
return original; |
| 44 |
} |
| 45 |
|
| 46 |
const { resetStyles } = useStyles(props); |
| 47 |
|
| 48 |
return ( |
| 49 |
<> |
| 50 |
{original} |
| 51 |
<InspectorControls group="styles"> |
| 52 |
<ToolsPanel |
| 53 |
label={ |
| 54 |
<> |
| 55 |
<span className="ghostkit-ext-icon"> |
| 56 |
{getIcon('extension-custom-css')} |
| 57 |
</span> |
| 58 |
<span>{__('Custom CSS', 'ghostkit')}</span> |
| 59 |
</> |
| 60 |
} |
| 61 |
resetAll={() => { |
| 62 |
resetStyles(allCustomCSS, true); |
| 63 |
}} |
| 64 |
> |
| 65 |
<div className="ghostkit-tools-panel-custom-css"> |
| 66 |
<ApplyFilters |
| 67 |
name="ghostkit.extension.customCSS.tools" |
| 68 |
props={props} |
| 69 |
/> |
| 70 |
</div> |
| 71 |
</ToolsPanel> |
| 72 |
</InspectorControls> |
| 73 |
</> |
| 74 |
); |
| 75 |
} |
| 76 |
|
| 77 |
// Init filters. |
| 78 |
addFilter( |
| 79 |
'ghostkit.editor.extensions', |
| 80 |
'ghostkit/extension/customCSS/inspector', |
| 81 |
GhostKitExtensionCustomCSSInspector, |
| 82 |
16 |
| 83 |
); |
| 84 |
|