| @@ -4,11 +4,21 @@ | ||
| 4 | 4 | var { InspectorControls, PanelColorSettings } = window.wp.blockEditor; |
| 5 | 5 | var { PanelBody, RangeControl, SelectControl, TextControl, TextareaControl, ToggleControl } = window.wp.components; |
| 6 | 6 | var { __ } = window.wp.i18n; |
| 7 | 7 | |
| 8 | - var _tc, _tvf; | |
| 9 | - Object.defineProperty(window, '_tc', { get: function () { return _tc || (_tc = window.bkbgTypographyControl); } }); | |
| 10 | - Object.defineProperty(window, '_tvf', { get: function () { return _tvf || (_tvf = window.bkbgTypoCssVars); } }); | |
| 8 | + // Resolve the shared components lazily without defining globals for each block. | |
| 9 | + function _tc(props, key, label) { | |
| 10 | + var Control = window.bkbgTypographyControl; | |
| 11 | + return Control ? el(Control, { | |
| 12 | + label: label, | |
| 13 | + value: props.attributes[key] || {}, | |
| 14 | + onChange: function (value) { var update = {}; update[key] = value; props.setAttributes(update); } | |
| 15 | + }) : null; | |
| 16 | + } | |
| 17 | + function _tvf(typo, prefix) { | |
| 18 | + var cssVars = window.bkbgTypoCssVars; | |
| 19 | + return cssVars ? cssVars(typo || {}, prefix) : {}; | |
| 20 | + } | |
| 11 | 21 | function getTypoControl(p, key, label) { return _tc ? _tc(p, key, label) : null; } |
| 12 | 22 | function getTypoCssVars(a) { |
| 13 | 23 | if (!_tvf) return {}; |
| 14 | 24 | return _tvf(a.textTypo || {}, '--bkte-tx-'); |