UNPKG

@gechiui/block-editor

Version:
61 lines (45 loc) 2.08 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("@gechiui/element"); var _blocks = require("@gechiui/blocks"); var _components = require("@gechiui/components"); var _i18n = require("@gechiui/i18n"); var _inspectorControls = _interopRequireDefault(require("../components/inspector-controls")); var _lineHeight = require("./line-height"); var _fontSize = require("./font-size"); /** * GeChiUI 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); // only enable TypographyPanel for development // eslint-disable-next-line no-undef if (isDisabled || !isSupported || !__DEV__) return null; return (0, _element.createElement)(_inspectorControls.default, null, (0, _element.createElement)(_components.PanelBody, { title: (0, _i18n.__)('排版') }, (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() { let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; const configs = [(0, _fontSize.useIsFontSizeDisabled)(props), (0, _lineHeight.useIsLineHeightDisabled)(props)]; return configs.filter(Boolean).length === configs.length; } //# sourceMappingURL=typography.native.js.map