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