| @@ -14,11 +14,22 @@ | ||
| 14 | 14 | var RangeControl = wp.components.RangeControl; |
| 15 | 15 | var SelectControl = wp.components.SelectControl; |
| 16 | 16 | var Button = wp.components.Button; |
| 17 | 17 | |
| 18 | - var _tc, _tvf; | |
| 19 | - Object.defineProperty(window, '_tc', { get: function () { return _tc || (_tc = window.bkbgTypographyControl); } }); | |
| 20 | - Object.defineProperty(window, '_tvf', { get: function () { return _tvf || (_tvf = window.bkbgTypoCssVars); } }); | |
| 18 | + // Resolve the shared components lazily without defining globals for each block. | |
| 19 | + function _tc(label, key, attrs, setA) { | |
| 20 | + var Control = window.bkbgTypographyControl; | |
| 21 | + return Control ? el(Control, { | |
| 22 | + label: label, | |
| 23 | + value: attrs[key] || {}, | |
| 24 | + onChange: function (value) { var update = {}; update[key] = value; setA(update); } | |
| 25 | + }) : null; | |
| 26 | + } | |
| 27 | + function _tvf(vars, key, attrs, prefix) { | |
| 28 | + var cssVars = window.bkbgTypoCssVars; | |
| 29 | + if (cssVars) Object.assign(vars, cssVars(attrs[key] || {}, prefix)); | |
| 30 | + return vars; | |
| 31 | + } | |
| 21 | 32 | function getTypoControl(label, key, attrs, setA) { return _tc(label, key, attrs, setA); } |
| 22 | 33 | function getTypoCssVars(attrs) { |
| 23 | 34 | var v = {}; |
| 24 | 35 | _tvf(v, 'labelTypo', attrs, '--bkvsi-lb-'); |