UNPKG

@gechiui/block-editor

Version:
42 lines (36 loc) 1.6 kB
import { createElement } from "@gechiui/element"; /** * GeChiUI dependencies */ import { hasBlockSupport } from '@gechiui/blocks'; /** * External dependencies */ import { PanelBody } from '@gechiui/components'; import { __ } from '@gechiui/i18n'; /** * Internal dependencies */ import InspectorControls from '../components/inspector-controls'; import { LINE_HEIGHT_SUPPORT_KEY, LineHeightEdit, useIsLineHeightDisabled } from './line-height'; import { FONT_SIZE_SUPPORT_KEY, FontSizeEdit, useIsFontSizeDisabled } from './font-size'; export const TYPOGRAPHY_SUPPORT_KEY = 'typography'; export const TYPOGRAPHY_SUPPORT_KEYS = [LINE_HEIGHT_SUPPORT_KEY, FONT_SIZE_SUPPORT_KEY]; export function TypographyPanel(props) { const isDisabled = useIsTypographyDisabled(props); const isSupported = hasTypographySupport(props.name); // only enable TypographyPanel for development // eslint-disable-next-line no-undef if (isDisabled || !isSupported || !__DEV__) return null; return createElement(InspectorControls, null, createElement(PanelBody, { title: __('排版') }, createElement(FontSizeEdit, props), createElement(LineHeightEdit, props))); } const hasTypographySupport = blockName => { return TYPOGRAPHY_SUPPORT_KEYS.some(key => hasBlockSupport(blockName, key)); }; function useIsTypographyDisabled() { let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; const configs = [useIsFontSizeDisabled(props), useIsLineHeightDisabled(props)]; return configs.filter(Boolean).length === configs.length; } //# sourceMappingURL=typography.native.js.map