@wordpress/block-editor
Version:
76 lines (72 loc) • 2.4 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TypographyPanel = exports.TYPOGRAPHY_SUPPORT_KEYS = exports.TYPOGRAPHY_SUPPORT_KEY = void 0;
var _data = require("@wordpress/data");
var _element = require("@wordpress/element");
var _components = require("@wordpress/components");
var _i18n = require("@wordpress/i18n");
var _inspectorControls = _interopRequireDefault(require("../components/inspector-controls"));
var _typographyPanel = require("../components/global-styles/typography-panel");
var _store = require("../store");
var _lineHeight = require("./line-height");
var _fontSize = require("./font-size");
var _jsxRuntime = require("react/jsx-runtime");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const TYPOGRAPHY_SUPPORT_KEY = exports.TYPOGRAPHY_SUPPORT_KEY = 'typography';
const TYPOGRAPHY_SUPPORT_KEYS = exports.TYPOGRAPHY_SUPPORT_KEYS = [_lineHeight.LINE_HEIGHT_SUPPORT_KEY, _fontSize.FONT_SIZE_SUPPORT_KEY];
function TypographyPanelPure({
clientId,
setAttributes,
settings
}) {
function selector(select) {
const {
style,
fontFamily,
fontSize
} = select(_store.store).getBlockAttributes(clientId) || {};
return {
style,
fontFamily,
fontSize
};
}
const {
style,
fontSize
} = (0, _data.useSelect)(selector, [clientId]);
const isEnabled = (0, _typographyPanel.useHasTypographyPanel)(settings);
if (!isEnabled) {
return null;
}
const props = {
attributes: {
fontSize,
style
},
setAttributes
};
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_inspectorControls.default, {
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.PanelBody, {
title: (0, _i18n.__)('Typography'),
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_fontSize.FontSizeEdit, {
...props
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_lineHeight.LineHeightEdit, {
...props
})]
})
});
}
// We don't want block controls to re-render when typing inside a block. `pure`
// will prevent re-renders unless props change, so only pass the needed props
// and not the whole attributes object.
const TypographyPanel = exports.TypographyPanel = (0, _element.memo)(TypographyPanelPure);
//# sourceMappingURL=typography.native.js.map
;