UNPKG

@wordpress/block-editor

Version:
58 lines (43 loc) 1.92 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.TYPOGRAPHY_SUPPORT_KEYS = exports.TYPOGRAPHY_SUPPORT_KEY = void 0; exports.TypographyPanel = TypographyPanel; var _element = require("@wordpress/element"); var _blocks = require("@wordpress/blocks"); var _components = require("@wordpress/components"); var _i18n = require("@wordpress/i18n"); var _inspectorControls = _interopRequireDefault(require("../components/inspector-controls")); var _lineHeight = require("./line-height"); var _fontSize = require("./font-size"); /** * WordPress dependencies */ /** * External dependencies */ /** * Internal dependencies */ const TYPOGRAPHY_SUPPORT_KEY = 'typography'; exports.TYPOGRAPHY_SUPPORT_KEY = TYPOGRAPHY_SUPPORT_KEY; const TYPOGRAPHY_SUPPORT_KEYS = [_lineHeight.LINE_HEIGHT_SUPPORT_KEY, _fontSize.FONT_SIZE_SUPPORT_KEY]; exports.TYPOGRAPHY_SUPPORT_KEYS = TYPOGRAPHY_SUPPORT_KEYS; function TypographyPanel(props) { const isDisabled = useIsTypographyDisabled(props); const isSupported = hasTypographySupport(props.name); if (isDisabled || !isSupported) return null; return (0, _element.createElement)(_inspectorControls.default, null, (0, _element.createElement)(_components.PanelBody, { title: (0, _i18n.__)('Typography') }, (0, _element.createElement)(_fontSize.FontSizeEdit, props), (0, _element.createElement)(_lineHeight.LineHeightEdit, props))); } const hasTypographySupport = blockName => { return TYPOGRAPHY_SUPPORT_KEYS.some(key => (0, _blocks.hasBlockSupport)(blockName, key)); }; function useIsTypographyDisabled(props = {}) { const configs = [(0, _fontSize.useIsFontSizeDisabled)(props), (0, _lineHeight.useIsLineHeightDisabled)(props)]; return configs.filter(Boolean).length === configs.length; } //# sourceMappingURL=typography.native.js.map