| @@ -12,11 +12,21 @@ | ||
| 12 | 12 | var TextControl = wp.components.TextControl; |
| 13 | 13 | var TextareaControl = wp.components.TextareaControl; |
| 14 | 14 | var Button = wp.components.Button; |
| 15 | 15 | |
| 16 | - var _tc, _tvf; | |
| 17 | - Object.defineProperty(window, '_tc', { get: function () { return _tc || (_tc = window.bkbgTypographyControl); } }); | |
| 18 | - Object.defineProperty(window, '_tvf', { get: function () { return _tvf || (_tvf = window.bkbgTypoCssVars); } }); | |
| 16 | + // Resolve the shared components lazily without defining globals for each block. | |
| 17 | + function _tc(props, key, label) { | |
| 18 | + var Control = window.bkbgTypographyControl; | |
| 19 | + return Control ? el(Control, { | |
| 20 | + label: label, | |
| 21 | + value: props.attributes[key] || {}, | |
| 22 | + onChange: function (value) { var update = {}; update[key] = value; props.setAttributes(update); } | |
| 23 | + }) : null; | |
| 24 | + } | |
| 25 | + function _tvf(typo, prefix) { | |
| 26 | + var cssVars = window.bkbgTypoCssVars; | |
| 27 | + return cssVars ? cssVars(typo || {}, prefix) : {}; | |
| 28 | + } | |
| 19 | 29 | function getTypoControl(p, key, label) { return _tc ? _tc(p, key, label) : null; } |
| 20 | 30 | function getTypoCssVars(a) { |
| 21 | 31 | if (!_tvf) return {}; |
| 22 | 32 | var v = {}; |