| @@ -5,11 +5,22 @@ | ||
| 5 | 5 | const { PanelBody, RangeControl, ToggleControl, TextControl, TextareaControl, Button, ColorPicker, Popover } = window.wp.components; |
| 6 | 6 | const { __ } = window.wp.i18n; |
| 7 | 7 | const { useState } = window.wp.element; |
| 8 | 8 | |
| 9 | - var _tc, _tvf; | |
| 10 | - Object.defineProperty(window, '_tc', { get: function () { return _tc || (_tc = window.bkbgTypographyControl); } }); | |
| 11 | - Object.defineProperty(window, '_tvf', { get: function () { return _tvf || (_tvf = window.bkbgTypoCssVars); } }); | |
| 9 | + // Resolve the shared components lazily without defining globals for each block. | |
| 10 | + function _tc(label, key, attrs, setA) { | |
| 11 | + var Control = window.bkbgTypographyControl; | |
| 12 | + return Control ? el(Control, { | |
| 13 | + label: label, | |
| 14 | + value: attrs[key] || {}, | |
| 15 | + onChange: function (value) { var update = {}; update[key] = value; setA(update); } | |
| 16 | + }) : null; | |
| 17 | + } | |
| 18 | + function _tvf(vars, key, attrs, prefix) { | |
| 19 | + var cssVars = window.bkbgTypoCssVars; | |
| 20 | + if (cssVars) Object.assign(vars, cssVars(attrs[key] || {}, prefix)); | |
| 21 | + return vars; | |
| 22 | + } | |
| 12 | 23 | function getTypoControl(label, key, attrs, setA) { return _tc(label, key, attrs, setA); } |
| 13 | 24 | function getTypoCssVars(attrs) { |
| 14 | 25 | var v = {}; |
| 15 | 26 | _tvf(v, 'titleTypo', attrs, '--bkvip-tt-'); |