| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 var __create = Object.create; 2 var __defProp = Object.defineProperty; 3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 4 var __getOwnPropNames = Object.getOwnPropertyNames; 5 var __getProtoOf = Object.getPrototypeOf; 6 var __hasOwnProp = Object.prototype.hasOwnProperty; 7 var __commonJS = (cb, mod) => function __require() { 8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 9 }; 10 var __copyProps = (to, from, except, desc) => { 11 if (from && typeof from === "object" || typeof from === "function") { 12 for (let key of __getOwnPropNames(from)) 13 if (!__hasOwnProp.call(to, key) && key !== except) 14 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 15 } 16 return to; 17 }; 18 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 19 // If the importer is in node compatibility mode or this is not an ESM 20 // file that has been converted to a CommonJS file using a Babel- 21 // compatible transform (i.e. "__esModule" has not been set), then set 22 // "default" to the CommonJS "module.exports" for node compatibility. 23 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 24 mod 25 )); 26 27 // package-external:@wordpress/editor 28 var require_editor = __commonJS({ 29 "package-external:@wordpress/editor"(exports, module) { 30 module.exports = window.wp.editor; 31 } 32 }); 33 34 // package-external:@wordpress/core-data 35 var require_core_data = __commonJS({ 36 "package-external:@wordpress/core-data"(exports, module) { 37 module.exports = window.wp.coreData; 38 } 39 }); 40 41 // package-external:@wordpress/data 42 var require_data = __commonJS({ 43 "package-external:@wordpress/data"(exports, module) { 44 module.exports = window.wp.data; 45 } 46 }); 47 48 // package-external:@wordpress/components 49 var require_components = __commonJS({ 50 "package-external:@wordpress/components"(exports, module) { 51 module.exports = window.wp.components; 52 } 53 }); 54 55 // package-external:@wordpress/element 56 var require_element = __commonJS({ 57 "package-external:@wordpress/element"(exports, module) { 58 module.exports = window.wp.element; 59 } 60 }); 61 62 // package-external:@wordpress/style-engine 63 var require_style_engine = __commonJS({ 64 "package-external:@wordpress/style-engine"(exports, module) { 65 module.exports = window.wp.styleEngine; 66 } 67 }); 68 69 // package-external:@wordpress/i18n 70 var require_i18n = __commonJS({ 71 "package-external:@wordpress/i18n"(exports, module) { 72 module.exports = window.wp.i18n; 73 } 74 }); 75 76 // package-external:@wordpress/blocks 77 var require_blocks = __commonJS({ 78 "package-external:@wordpress/blocks"(exports, module) { 79 module.exports = window.wp.blocks; 80 } 81 }); 82 83 // package-external:@wordpress/private-apis 84 var require_private_apis = __commonJS({ 85 "package-external:@wordpress/private-apis"(exports, module) { 86 module.exports = window.wp.privateApis; 87 } 88 }); 89 90 // vendor-external:react/jsx-runtime 91 var require_jsx_runtime = __commonJS({ 92 "vendor-external:react/jsx-runtime"(exports, module) { 93 module.exports = window.ReactJSXRuntime; 94 } 95 }); 96 97 // package-external:@wordpress/block-editor 98 var require_block_editor = __commonJS({ 99 "package-external:@wordpress/block-editor"(exports, module) { 100 module.exports = window.wp.blockEditor; 101 } 102 }); 103 104 // packages/lazy-editor/build-module/components/editor/index.js 105 var import_editor = __toESM(require_editor()); 106 var import_core_data5 = __toESM(require_core_data()); 107 var import_data6 = __toESM(require_data()); 108 var import_components = __toESM(require_components()); 109 var import_element4 = __toESM(require_element()); 110 111 // packages/lazy-editor/build-module/hooks/use-styles-id.js 112 var import_core_data = __toESM(require_core_data()); 113 var import_data = __toESM(require_data()); 114 function useStylesId({ templateId } = {}) { 115 const { globalStylesId, stylesId } = (0, import_data.useSelect)( 116 (select2) => { 117 const coreDataSelect = select2(import_core_data.store); 118 const template = templateId ? coreDataSelect.getEntityRecord( 119 "postType", 120 "wp_template", 121 templateId 122 ) : null; 123 return { 124 globalStylesId: coreDataSelect.__experimentalGetCurrentGlobalStylesId(), 125 stylesId: template?.styles_id 126 }; 127 }, 128 [templateId] 129 ); 130 return stylesId || globalStylesId; 131 } 132 133 // packages/global-styles-engine/build-module/utils/object.js 134 function setImmutably(object, path, value) { 135 path = Array.isArray(path) ? [...path] : [path]; 136 object = Array.isArray(object) ? [...object] : { ...object }; 137 const leaf = path.pop(); 138 let prev = object; 139 for (const key of path) { 140 const lvl = prev[key]; 141 prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl }; 142 } 143 prev[leaf] = value; 144 return object; 145 } 146 var getValueFromObjectPath = (object, path, defaultValue) => { 147 const arrayPath = Array.isArray(path) ? path : path.split("."); 148 let value = object; 149 arrayPath.forEach((fieldName) => { 150 value = value?.[fieldName]; 151 }); 152 return value ?? defaultValue; 153 }; 154 155 // packages/global-styles-engine/build-module/settings/get-setting.js 156 var VALID_SETTINGS = [ 157 "appearanceTools", 158 "useRootPaddingAwareAlignments", 159 "background.backgroundImage", 160 "background.backgroundRepeat", 161 "background.backgroundSize", 162 "background.backgroundPosition", 163 "border.color", 164 "border.radius", 165 "border.radiusSizes", 166 "border.style", 167 "border.width", 168 "shadow.presets", 169 "shadow.defaultPresets", 170 "color.background", 171 "color.button", 172 "color.caption", 173 "color.custom", 174 "color.customDuotone", 175 "color.customGradient", 176 "color.defaultDuotone", 177 "color.defaultGradients", 178 "color.defaultPalette", 179 "color.duotone", 180 "color.gradients", 181 "color.heading", 182 "color.link", 183 "color.palette", 184 "color.text", 185 "custom", 186 "dimensions.aspectRatio", 187 "dimensions.height", 188 "dimensions.minHeight", 189 "dimensions.width", 190 "dimensions.dimensionSizes", 191 "layout.contentSize", 192 "layout.definitions", 193 "layout.wideSize", 194 "lightbox.enabled", 195 "lightbox.allowEditing", 196 "position.fixed", 197 "position.sticky", 198 "spacing.customSpacingSize", 199 "spacing.defaultSpacingSizes", 200 "spacing.spacingSizes", 201 "spacing.spacingScale", 202 "spacing.blockGap", 203 "spacing.margin", 204 "spacing.padding", 205 "spacing.units", 206 "typography.fluid", 207 "typography.customFontSize", 208 "typography.defaultFontSizes", 209 "typography.dropCap", 210 "typography.fontFamilies", 211 "typography.fontSizes", 212 "typography.fontStyle", 213 "typography.fontWeight", 214 "typography.letterSpacing", 215 "typography.lineHeight", 216 "typography.textAlign", 217 "typography.textColumns", 218 "typography.textDecoration", 219 "typography.textTransform", 220 "typography.writingMode" 221 ]; 222 function getSetting(globalStyles, path, blockName) { 223 const appendedBlockPath = blockName ? ".blocks." + blockName : ""; 224 const appendedPropertyPath = path ? "." + path : ""; 225 const contextualPath = `settings$appendedBlockPath}$appendedPropertyPath}`; 226 const globalPath = `settings$appendedPropertyPath}`; 227 if (path) { 228 return getValueFromObjectPath(globalStyles, contextualPath) ?? getValueFromObjectPath(globalStyles, globalPath); 229 } 230 let result = {}; 231 VALID_SETTINGS.forEach((setting) => { 232 const value = getValueFromObjectPath( 233 globalStyles, 234 `settings$appendedBlockPath}.$setting}` 235 ) ?? getValueFromObjectPath(globalStyles, `settings.$setting}`); 236 if (value !== void 0) { 237 result = setImmutably(result, setting.split("."), value); 238 } 239 }); 240 return result; 241 } 242 243 // packages/global-styles-engine/build-module/utils/common.js 244 var import_style_engine = __toESM(require_style_engine()); 245 246 // packages/global-styles-engine/build-module/utils/fluid.js 247 var DEFAULT_MAXIMUM_VIEWPORT_WIDTH = "1600px"; 248 var DEFAULT_MINIMUM_VIEWPORT_WIDTH = "320px"; 249 var DEFAULT_SCALE_FACTOR = 1; 250 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25; 251 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75; 252 var DEFAULT_MINIMUM_FONT_SIZE_LIMIT = "14px"; 253 function getComputedFluidTypographyValue({ 254 minimumFontSize, 255 maximumFontSize, 256 fontSize, 257 minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH, 258 maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH, 259 scaleFactor = DEFAULT_SCALE_FACTOR, 260 minimumFontSizeLimit 261 }) { 262 minimumFontSizeLimit = !!getTypographyValueAndUnit(minimumFontSizeLimit) ? minimumFontSizeLimit : DEFAULT_MINIMUM_FONT_SIZE_LIMIT; 263 if (fontSize) { 264 const fontSizeParsed = getTypographyValueAndUnit(fontSize); 265 if (!fontSizeParsed?.unit || !fontSizeParsed?.value) { 266 return null; 267 } 268 const minimumFontSizeLimitParsed = getTypographyValueAndUnit( 269 minimumFontSizeLimit, 270 { 271 coerceTo: fontSizeParsed.unit 272 } 273 ); 274 if (!!minimumFontSizeLimitParsed?.value && !minimumFontSize && !maximumFontSize) { 275 if (fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value) { 276 return null; 277 } 278 } 279 if (!maximumFontSize) { 280 maximumFontSize = `$fontSizeParsed.value}$fontSizeParsed.unit}`; 281 } 282 if (!minimumFontSize) { 283 const fontSizeValueInPx = fontSizeParsed.unit === "px" ? fontSizeParsed.value : fontSizeParsed.value * 16; 284 const minimumFontSizeFactor = Math.min( 285 Math.max( 286 1 - 0.075 * Math.log2(fontSizeValueInPx), 287 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN 288 ), 289 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX 290 ); 291 const calculatedMinimumFontSize = roundToPrecision( 292 fontSizeParsed.value * minimumFontSizeFactor, 293 3 294 ); 295 if (!!minimumFontSizeLimitParsed?.value && calculatedMinimumFontSize < minimumFontSizeLimitParsed?.value) { 296 minimumFontSize = `$minimumFontSizeLimitParsed.value}$minimumFontSizeLimitParsed.unit}`; 297 } else { 298 minimumFontSize = `$calculatedMinimumFontSize}$fontSizeParsed.unit}`; 299 } 300 } 301 } 302 const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize); 303 const fontSizeUnit = minimumFontSizeParsed?.unit || "rem"; 304 const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, { 305 coerceTo: fontSizeUnit 306 }); 307 if (!minimumFontSizeParsed || !maximumFontSizeParsed) { 308 return null; 309 } 310 const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, { 311 coerceTo: "rem" 312 }); 313 const maximumViewportWidthParsed = getTypographyValueAndUnit( 314 maximumViewportWidth, 315 { coerceTo: fontSizeUnit } 316 ); 317 const minimumViewportWidthParsed = getTypographyValueAndUnit( 318 minimumViewportWidth, 319 { coerceTo: fontSizeUnit } 320 ); 321 if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) { 322 return null; 323 } 324 const linearDenominator = maximumViewportWidthParsed.value - minimumViewportWidthParsed.value; 325 if (!linearDenominator) { 326 return null; 327 } 328 const minViewportWidthOffsetValue = roundToPrecision( 329 minimumViewportWidthParsed.value / 100, 330 3 331 ); 332 const viewportWidthOffset = roundToPrecision(minViewportWidthOffsetValue, 3) + fontSizeUnit; 333 const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / linearDenominator); 334 const linearFactorScaled = roundToPrecision( 335 (linearFactor || 1) * scaleFactor, 336 3 337 ); 338 const fluidTargetFontSize = `$minimumFontSizeRem.value}$minimumFontSizeRem.unit} + ((1vw - $viewportWidthOffset}) * $linearFactorScaled})`; 339 return `clamp($minimumFontSize}, $fluidTargetFontSize}, $maximumFontSize})`; 340 } 341 function getTypographyValueAndUnit(rawValue, options = {}) { 342 if (typeof rawValue !== "string" && typeof rawValue !== "number") { 343 return null; 344 } 345 if (isFinite(rawValue)) { 346 rawValue = `$rawValue}px`; 347 } 348 const { coerceTo, rootSizeValue, acceptableUnits } = { 349 coerceTo: "", 350 // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`. 351 rootSizeValue: 16, 352 acceptableUnits: ["rem", "px", "em"], 353 ...options 354 }; 355 const acceptableUnitsGroup = acceptableUnits?.join("|"); 356 const regexUnits = new RegExp( 357 `^(\\d*\\.?\\d+)($acceptableUnitsGroup}){1,1}$` 358 ); 359 const matches = rawValue.toString().match(regexUnits); 360 if (!matches || matches.length < 3) { 361 return null; 362 } 363 let [, value, unit] = matches; 364 let returnValue = parseFloat(value); 365 if ("px" === coerceTo && ("em" === unit || "rem" === unit)) { 366 returnValue = returnValue * rootSizeValue; 367 unit = coerceTo; 368 } 369 if ("px" === unit && ("em" === coerceTo || "rem" === coerceTo)) { 370 returnValue = returnValue / rootSizeValue; 371 unit = coerceTo; 372 } 373 if (("em" === coerceTo || "rem" === coerceTo) && ("em" === unit || "rem" === unit)) { 374 unit = coerceTo; 375 } 376 if (!unit) { 377 return null; 378 } 379 return { 380 value: roundToPrecision(returnValue, 3), 381 unit 382 }; 383 } 384 function roundToPrecision(value, digits = 3) { 385 const base = Math.pow(10, digits); 386 return Math.round(value * base) / base; 387 } 388 389 // packages/global-styles-engine/build-module/utils/typography.js 390 function isFluidTypographyEnabled(typographySettings) { 391 const fluidSettings = typographySettings?.fluid; 392 return true === fluidSettings || fluidSettings && typeof fluidSettings === "object" && Object.keys(fluidSettings).length > 0; 393 } 394 function getFluidTypographyOptionsFromSettings(settings) { 395 const typographySettings = settings?.typography ?? {}; 396 const layoutSettings = settings?.layout; 397 const defaultMaxViewportWidth = getTypographyValueAndUnit( 398 layoutSettings?.wideSize 399 ) ? layoutSettings?.wideSize : null; 400 return isFluidTypographyEnabled(typographySettings) && defaultMaxViewportWidth ? { 401 fluid: { 402 maxViewportWidth: defaultMaxViewportWidth, 403 ...typeof typographySettings.fluid === "object" ? typographySettings.fluid : {} 404 } 405 } : { 406 fluid: typographySettings?.fluid 407 }; 408 } 409 function getTypographyFontSizeValue(preset, settings) { 410 const { size: defaultSize } = preset; 411 if (!defaultSize || "0" === defaultSize || false === preset?.fluid) { 412 return defaultSize; 413 } 414 if (!isFluidTypographyEnabled(settings?.typography) && !isFluidTypographyEnabled(preset)) { 415 return defaultSize; 416 } 417 const fluidTypographySettings = getFluidTypographyOptionsFromSettings(settings)?.fluid ?? {}; 418 const fluidFontSizeValue = getComputedFluidTypographyValue({ 419 minimumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.min, 420 maximumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.max, 421 fontSize: defaultSize, 422 minimumFontSizeLimit: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minFontSize : void 0, 423 maximumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.maxViewportWidth : void 0, 424 minimumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minViewportWidth : void 0 425 }); 426 if (!!fluidFontSizeValue) { 427 return fluidFontSizeValue; 428 } 429 return defaultSize; 430 } 431 432 // packages/global-styles-engine/build-module/utils/common.js 433 var ROOT_BLOCK_SELECTOR = "body"; 434 var ROOT_CSS_PROPERTIES_SELECTOR = ":root"; 435 var PRESET_METADATA = [ 436 { 437 path: ["color", "palette"], 438 valueKey: "color", 439 cssVarInfix: "color", 440 classes: [ 441 { classSuffix: "color", propertyName: "color" }, 442 { 443 classSuffix: "background-color", 444 propertyName: "background-color" 445 }, 446 { 447 classSuffix: "border-color", 448 propertyName: "border-color" 449 } 450 ] 451 }, 452 { 453 path: ["color", "gradients"], 454 valueKey: "gradient", 455 cssVarInfix: "gradient", 456 classes: [ 457 { 458 classSuffix: "gradient-background", 459 propertyName: "background" 460 } 461 ] 462 }, 463 { 464 path: ["color", "duotone"], 465 valueKey: "colors", 466 cssVarInfix: "duotone", 467 valueFunc: ({ slug }) => `url( '#wp-duotone-$slug}' )`, 468 classes: [] 469 }, 470 { 471 path: ["shadow", "presets"], 472 valueKey: "shadow", 473 cssVarInfix: "shadow", 474 classes: [] 475 }, 476 { 477 path: ["typography", "fontSizes"], 478 valueFunc: (preset, settings) => getTypographyFontSizeValue(preset, settings), 479 valueKey: "size", 480 cssVarInfix: "font-size", 481 classes: [{ classSuffix: "font-size", propertyName: "font-size" }] 482 }, 483 { 484 path: ["typography", "fontFamilies"], 485 valueKey: "fontFamily", 486 cssVarInfix: "font-family", 487 classes: [ 488 { classSuffix: "font-family", propertyName: "font-family" } 489 ] 490 }, 491 { 492 path: ["spacing", "spacingSizes"], 493 valueKey: "size", 494 cssVarInfix: "spacing", 495 valueFunc: ({ size }) => size, 496 classes: [] 497 }, 498 { 499 path: ["border", "radiusSizes"], 500 valueKey: "size", 501 cssVarInfix: "border-radius", 502 classes: [] 503 }, 504 { 505 path: ["dimensions", "dimensionSizes"], 506 valueKey: "size", 507 cssVarInfix: "dimension", 508 classes: [] 509 } 510 ]; 511 function scopeSelector(scope, selector) { 512 if (!scope || !selector) { 513 return selector; 514 } 515 const scopes = scope.split(","); 516 const selectors = selector.split(","); 517 const selectorsScoped = []; 518 scopes.forEach((outer) => { 519 selectors.forEach((inner) => { 520 selectorsScoped.push(`$outer.trim()} $inner.trim()}`); 521 }); 522 }); 523 return selectorsScoped.join(", "); 524 } 525 function scopeFeatureSelectors(scope, selectors) { 526 if (!scope || !selectors) { 527 return; 528 } 529 const featureSelectors = {}; 530 Object.entries(selectors).forEach(([feature, selector]) => { 531 if (typeof selector === "string") { 532 featureSelectors[feature] = scopeSelector(scope, selector); 533 } 534 if (typeof selector === "object") { 535 featureSelectors[feature] = {}; 536 Object.entries(selector).forEach( 537 ([subfeature, subfeatureSelector]) => { 538 featureSelectors[feature][subfeature] = scopeSelector( 539 scope, 540 subfeatureSelector 541 ); 542 } 543 ); 544 } 545 }); 546 return featureSelectors; 547 } 548 function appendToSelector(selector, toAppend) { 549 if (!selector.includes(",")) { 550 return selector + toAppend; 551 } 552 const selectors = selector.split(","); 553 const newSelectors = selectors.map((sel) => sel + toAppend); 554 return newSelectors.join(","); 555 } 556 function getBlockStyleVariationSelector(variation, blockSelector) { 557 const variationClass = `.is-style-$variation}`; 558 if (!blockSelector) { 559 return variationClass; 560 } 561 const ancestorRegex = /((?::\([^)]+\))?\s*)([^\s:]+)/; 562 const addVariationClass = (_match, group1, group2) => { 563 return group1 + group2 + variationClass; 564 }; 565 const result = blockSelector.split(",").map((part) => part.replace(ancestorRegex, addVariationClass)); 566 return result.join(","); 567 } 568 function getResolvedRefValue(ruleValue, tree) { 569 if (!ruleValue || !tree) { 570 return ruleValue; 571 } 572 if (typeof ruleValue === "object" && "ref" in ruleValue && ruleValue?.ref) { 573 const resolvedRuleValue = (0, import_style_engine.getCSSValueFromRawStyle)( 574 getValueFromObjectPath(tree, ruleValue.ref) 575 ); 576 if (typeof resolvedRuleValue === "object" && resolvedRuleValue !== null && "ref" in resolvedRuleValue && resolvedRuleValue?.ref) { 577 return void 0; 578 } 579 if (resolvedRuleValue === void 0) { 580 return ruleValue; 581 } 582 return resolvedRuleValue; 583 } 584 return ruleValue; 585 } 586 function getResolvedThemeFilePath(file, themeFileURIs) { 587 if (!file || !themeFileURIs || !Array.isArray(themeFileURIs)) { 588 return file; 589 } 590 const uri = themeFileURIs.find( 591 (themeFileUri) => themeFileUri?.name === file 592 ); 593 if (!uri?.href) { 594 return file; 595 } 596 return uri?.href; 597 } 598 function getResolvedValue(ruleValue, tree) { 599 if (!ruleValue || !tree) { 600 return ruleValue; 601 } 602 const resolvedValue = getResolvedRefValue(ruleValue, tree); 603 if (typeof resolvedValue === "object" && resolvedValue !== null && "url" in resolvedValue && resolvedValue?.url) { 604 resolvedValue.url = getResolvedThemeFilePath( 605 resolvedValue.url, 606 tree?._links?.["wp:theme-file"] 607 ); 608 } 609 return resolvedValue; 610 } 611 612 // packages/global-styles-engine/build-module/core/render.js 613 var import_blocks = __toESM(require_blocks()); 614 var import_style_engine2 = __toESM(require_style_engine()); 615 var import_data2 = __toESM(require_data()); 616 617 // packages/global-styles-engine/build-module/core/selectors.js 618 function getBlockSelector(blockType, target = "root", options = {}) { 619 if (!target) { 620 return null; 621 } 622 const { fallback = false } = options; 623 const { name, selectors, supports } = blockType; 624 const hasSelectors = selectors && Object.keys(selectors).length > 0; 625 const path = Array.isArray(target) ? target.join(".") : target; 626 let rootSelector = null; 627 if (hasSelectors && selectors.root) { 628 rootSelector = selectors?.root; 629 } else if (supports?.__experimentalSelector) { 630 rootSelector = supports.__experimentalSelector; 631 } else { 632 rootSelector = ".wp-block-" + name.replace("core/", "").replace("/", "-"); 633 } 634 if (path === "root") { 635 return rootSelector; 636 } 637 const pathArray = Array.isArray(target) ? target : target.split("."); 638 if (pathArray.length === 1) { 639 const fallbackSelector = fallback ? rootSelector : null; 640 if (hasSelectors) { 641 const featureSelector2 = getValueFromObjectPath( 642 selectors, 643 `$path}.root`, 644 null 645 ) || getValueFromObjectPath(selectors, path, null); 646 return featureSelector2 || fallbackSelector; 647 } 648 const featureSelector = supports ? getValueFromObjectPath( 649 supports, 650 `$path}.__experimentalSelector`, 651 null 652 ) : void 0; 653 if (!featureSelector) { 654 return fallbackSelector; 655 } 656 return scopeSelector(rootSelector, featureSelector); 657 } 658 let subfeatureSelector; 659 if (hasSelectors) { 660 subfeatureSelector = getValueFromObjectPath(selectors, path, null); 661 } 662 if (subfeatureSelector) { 663 return subfeatureSelector; 664 } 665 if (fallback) { 666 return getBlockSelector(blockType, pathArray[0], options); 667 } 668 return null; 669 } 670 671 // node_modules/colord/index.mjs 672 var r = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 673 var t = function(r2) { 674 return "string" == typeof r2 ? r2.length > 0 : "number" == typeof r2; 675 }; 676 var n = function(r2, t2, n2) { 677 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r2) / n2 + 0; 678 }; 679 var e = function(r2, t2, n2) { 680 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r2 > n2 ? n2 : r2 > t2 ? r2 : t2; 681 }; 682 var u = function(r2) { 683 return (r2 = isFinite(r2) ? r2 % 360 : 0) > 0 ? r2 : r2 + 360; 684 }; 685 var a = function(r2) { 686 return { r: e(r2.r, 0, 255), g: e(r2.g, 0, 255), b: e(r2.b, 0, 255), a: e(r2.a) }; 687 }; 688 var o = function(r2) { 689 return { r: n(r2.r), g: n(r2.g), b: n(r2.b), a: n(r2.a, 3) }; 690 }; 691 var i = /^#([0-9a-f]{3,8})$/i; 692 var s = function(r2) { 693 var t2 = r2.toString(16); 694 return t2.length < 2 ? "0" + t2 : t2; 695 }; 696 var h = function(r2) { 697 var t2 = r2.r, n2 = r2.g, e2 = r2.b, u2 = r2.a, a2 = Math.max(t2, n2, e2), o2 = a2 - Math.min(t2, n2, e2), i2 = o2 ? a2 === t2 ? (n2 - e2) / o2 : a2 === n2 ? 2 + (e2 - t2) / o2 : 4 + (t2 - n2) / o2 : 0; 698 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; 699 }; 700 var b = function(r2) { 701 var t2 = r2.h, n2 = r2.s, e2 = r2.v, u2 = r2.a; 702 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100; 703 var a2 = Math.floor(t2), o2 = e2 * (1 - n2), i2 = e2 * (1 - (t2 - a2) * n2), s2 = e2 * (1 - (1 - t2 + a2) * n2), h2 = a2 % 6; 704 return { r: 255 * [e2, i2, o2, o2, s2, e2][h2], g: 255 * [s2, e2, e2, i2, o2, o2][h2], b: 255 * [o2, o2, s2, e2, e2, i2][h2], a: u2 }; 705 }; 706 var g = function(r2) { 707 return { h: u(r2.h), s: e(r2.s, 0, 100), l: e(r2.l, 0, 100), a: e(r2.a) }; 708 }; 709 var d = function(r2) { 710 return { h: n(r2.h), s: n(r2.s), l: n(r2.l), a: n(r2.a, 3) }; 711 }; 712 var f = function(r2) { 713 return b((n2 = (t2 = r2).s, { h: t2.h, s: (n2 *= ((e2 = t2.l) < 50 ? e2 : 100 - e2) / 100) > 0 ? 2 * n2 / (e2 + n2) * 100 : 0, v: e2 + n2, a: t2.a })); 714 var t2, n2, e2; 715 }; 716 var c = function(r2) { 717 return { h: (t2 = h(r2)).h, s: (u2 = (200 - (n2 = t2.s)) * (e2 = t2.v) / 100) > 0 && u2 < 200 ? n2 * e2 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t2.a }; 718 var t2, n2, e2, u2; 719 }; 720 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 721 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 722 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 723 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 724 var y = { string: [[function(r2) { 725 var t2 = i.exec(r2); 726 return t2 ? (r2 = t2[1]).length <= 4 ? { r: parseInt(r2[0] + r2[0], 16), g: parseInt(r2[1] + r2[1], 16), b: parseInt(r2[2] + r2[2], 16), a: 4 === r2.length ? n(parseInt(r2[3] + r2[3], 16) / 255, 2) : 1 } : 6 === r2.length || 8 === r2.length ? { r: parseInt(r2.substr(0, 2), 16), g: parseInt(r2.substr(2, 2), 16), b: parseInt(r2.substr(4, 2), 16), a: 8 === r2.length ? n(parseInt(r2.substr(6, 2), 16) / 255, 2) : 1 } : null : null; 727 }, "hex"], [function(r2) { 728 var t2 = v.exec(r2) || m.exec(r2); 729 return t2 ? t2[2] !== t2[4] || t2[4] !== t2[6] ? null : a({ r: Number(t2[1]) / (t2[2] ? 100 / 255 : 1), g: Number(t2[3]) / (t2[4] ? 100 / 255 : 1), b: Number(t2[5]) / (t2[6] ? 100 / 255 : 1), a: void 0 === t2[7] ? 1 : Number(t2[7]) / (t2[8] ? 100 : 1) }) : null; 730 }, "rgb"], [function(t2) { 731 var n2 = l.exec(t2) || p.exec(t2); 732 if (!n2) return null; 733 var e2, u2, a2 = g({ h: (e2 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e2) * (r[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) }); 734 return f(a2); 735 }, "hsl"]], object: [[function(r2) { 736 var n2 = r2.r, e2 = r2.g, u2 = r2.b, o2 = r2.a, i2 = void 0 === o2 ? 1 : o2; 737 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; 738 }, "rgb"], [function(r2) { 739 var n2 = r2.h, e2 = r2.s, u2 = r2.l, a2 = r2.a, o2 = void 0 === a2 ? 1 : a2; 740 if (!t(n2) || !t(e2) || !t(u2)) return null; 741 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) }); 742 return f(i2); 743 }, "hsl"], [function(r2) { 744 var n2 = r2.h, a2 = r2.s, o2 = r2.v, i2 = r2.a, s2 = void 0 === i2 ? 1 : i2; 745 if (!t(n2) || !t(a2) || !t(o2)) return null; 746 var h2 = (function(r3) { 747 return { h: u(r3.h), s: e(r3.s, 0, 100), v: e(r3.v, 0, 100), a: e(r3.a) }; 748 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) }); 749 return b(h2); 750 }, "hsv"]] }; 751 var N = function(r2, t2) { 752 for (var n2 = 0; n2 < t2.length; n2++) { 753 var e2 = t2[n2][0](r2); 754 if (e2) return [e2, t2[n2][1]]; 755 } 756 return [null, void 0]; 757 }; 758 var x = function(r2) { 759 return "string" == typeof r2 ? N(r2.trim(), y.string) : "object" == typeof r2 && null !== r2 ? N(r2, y.object) : [null, void 0]; 760 }; 761 var M = function(r2, t2) { 762 var n2 = c(r2); 763 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a }; 764 }; 765 var H = function(r2) { 766 return (299 * r2.r + 587 * r2.g + 114 * r2.b) / 1e3 / 255; 767 }; 768 var $ = function(r2, t2) { 769 var n2 = c(r2); 770 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a }; 771 }; 772 var j = (function() { 773 function r2(r3) { 774 this.parsed = x(r3)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 775 } 776 return r2.prototype.isValid = function() { 777 return null !== this.parsed; 778 }, r2.prototype.brightness = function() { 779 return n(H(this.rgba), 2); 780 }, r2.prototype.isDark = function() { 781 return H(this.rgba) < 0.5; 782 }, r2.prototype.isLight = function() { 783 return H(this.rgba) >= 0.5; 784 }, r2.prototype.toHex = function() { 785 return r3 = o(this.rgba), t2 = r3.r, e2 = r3.g, u2 = r3.b, i2 = (a2 = r3.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t2) + s(e2) + s(u2) + i2; 786 var r3, t2, e2, u2, a2, i2; 787 }, r2.prototype.toRgb = function() { 788 return o(this.rgba); 789 }, r2.prototype.toRgbString = function() { 790 return r3 = o(this.rgba), t2 = r3.r, n2 = r3.g, e2 = r3.b, (u2 = r3.a) < 1 ? "rgba(" + t2 + ", " + n2 + ", " + e2 + ", " + u2 + ")" : "rgb(" + t2 + ", " + n2 + ", " + e2 + ")"; 791 var r3, t2, n2, e2, u2; 792 }, r2.prototype.toHsl = function() { 793 return d(c(this.rgba)); 794 }, r2.prototype.toHslString = function() { 795 return r3 = d(c(this.rgba)), t2 = r3.h, n2 = r3.s, e2 = r3.l, (u2 = r3.a) < 1 ? "hsla(" + t2 + ", " + n2 + "%, " + e2 + "%, " + u2 + ")" : "hsl(" + t2 + ", " + n2 + "%, " + e2 + "%)"; 796 var r3, t2, n2, e2, u2; 797 }, r2.prototype.toHsv = function() { 798 return r3 = h(this.rgba), { h: n(r3.h), s: n(r3.s), v: n(r3.v), a: n(r3.a, 3) }; 799 var r3; 800 }, r2.prototype.invert = function() { 801 return w({ r: 255 - (r3 = this.rgba).r, g: 255 - r3.g, b: 255 - r3.b, a: r3.a }); 802 var r3; 803 }, r2.prototype.saturate = function(r3) { 804 return void 0 === r3 && (r3 = 0.1), w(M(this.rgba, r3)); 805 }, r2.prototype.desaturate = function(r3) { 806 return void 0 === r3 && (r3 = 0.1), w(M(this.rgba, -r3)); 807 }, r2.prototype.grayscale = function() { 808 return w(M(this.rgba, -1)); 809 }, r2.prototype.lighten = function(r3) { 810 return void 0 === r3 && (r3 = 0.1), w($(this.rgba, r3)); 811 }, r2.prototype.darken = function(r3) { 812 return void 0 === r3 && (r3 = 0.1), w($(this.rgba, -r3)); 813 }, r2.prototype.rotate = function(r3) { 814 return void 0 === r3 && (r3 = 15), this.hue(this.hue() + r3); 815 }, r2.prototype.alpha = function(r3) { 816 return "number" == typeof r3 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r3 }) : n(this.rgba.a, 3); 817 var t2; 818 }, r2.prototype.hue = function(r3) { 819 var t2 = c(this.rgba); 820 return "number" == typeof r3 ? w({ h: r3, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h); 821 }, r2.prototype.isEqual = function(r3) { 822 return this.toHex() === w(r3).toHex(); 823 }, r2; 824 })(); 825 var w = function(r2) { 826 return r2 instanceof j ? r2 : new j(r2); 827 }; 828 829 // packages/global-styles-engine/build-module/utils/duotone.js 830 function getValuesFromColors(colors = []) { 831 const values = { 832 r: [], 833 g: [], 834 b: [], 835 a: [] 836 }; 837 colors.forEach((color) => { 838 const rgbColor = w(color).toRgb(); 839 values.r.push(rgbColor.r / 255); 840 values.g.push(rgbColor.g / 255); 841 values.b.push(rgbColor.b / 255); 842 values.a.push(rgbColor.a); 843 }); 844 return values; 845 } 846 function getDuotoneFilter(id, colors) { 847 const values = getValuesFromColors(colors); 848 return ` 849 <svg 850 xmlns:xlink="http://www.w3.org/1999/xlink" 851 viewBox="0 0 0 0" 852 width="0" 853 height="0" 854 focusable="false" 855 role="none" 856 aria-hidden="true" 857 style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;" 858 > 859 <defs> 860 <filter id="$id}"> 861 <!-- 862 Use sRGB instead of linearRGB so transparency looks correct. 863 Use perceptual brightness to convert to grayscale. 864 --> 865 <feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix> 866 <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. --> 867 <feComponentTransfer color-interpolation-filters="sRGB"> 868 <feFuncR type="table" tableValues="$values.r.join(" ")}"></feFuncR> 869 <feFuncG type="table" tableValues="$values.g.join(" ")}"></feFuncG> 870 <feFuncB type="table" tableValues="$values.b.join(" ")}"></feFuncB> 871 <feFuncA type="table" tableValues="$values.a.join(" ")}"></feFuncA> 872 </feComponentTransfer> 873 <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. --> 874 <feComposite in2="SourceGraphic" operator="in"></feComposite> 875 </filter> 876 </defs> 877 </svg>`; 878 } 879 880 // packages/global-styles-engine/build-module/utils/string.js 881 function kebabCase(str) { 882 return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([0-9])([a-zA-Z])/g, "$1-$2").replace(/([a-zA-Z])([0-9])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase(); 883 } 884 885 // packages/global-styles-engine/build-module/utils/spacing.js 886 function getSpacingPresetCssVar(value) { 887 if (!value) { 888 return; 889 } 890 const slug = value.match(/var:preset\|spacing\|(.+)/); 891 if (!slug) { 892 return value; 893 } 894 return `var(--wp--preset--spacing--$slug[1]})`; 895 } 896 897 // packages/global-styles-engine/build-module/utils/gap.js 898 function getGapBoxControlValueFromStyle(blockGapValue) { 899 if (!blockGapValue) { 900 return null; 901 } 902 const isValueString = typeof blockGapValue === "string"; 903 return { 904 top: isValueString ? blockGapValue : blockGapValue?.top, 905 left: isValueString ? blockGapValue : blockGapValue?.left 906 }; 907 } 908 function getGapCSSValue(blockGapValue, defaultValue = "0") { 909 const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue); 910 if (!blockGapBoxControlValue) { 911 return null; 912 } 913 const row = getSpacingPresetCssVar(blockGapBoxControlValue?.top) || defaultValue; 914 const column = getSpacingPresetCssVar(blockGapBoxControlValue?.left) || defaultValue; 915 return row === column ? row : `$row} $column}`; 916 } 917 918 // packages/global-styles-engine/build-module/utils/background.js 919 var BACKGROUND_BLOCK_DEFAULT_VALUES = { 920 backgroundSize: "cover", 921 backgroundPosition: "50% 50%" 922 // used only when backgroundSize is 'contain'. 923 }; 924 function setBackgroundStyleDefaults(backgroundStyle) { 925 if (!backgroundStyle || // @ts-expect-error 926 !backgroundStyle?.backgroundImage?.url) { 927 return; 928 } 929 let backgroundStylesWithDefaults; 930 if (!backgroundStyle?.backgroundSize) { 931 backgroundStylesWithDefaults = { 932 backgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize 933 }; 934 } 935 if ("contain" === backgroundStyle?.backgroundSize && !backgroundStyle?.backgroundPosition) { 936 backgroundStylesWithDefaults = { 937 backgroundPosition: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition 938 }; 939 } 940 return backgroundStylesWithDefaults; 941 } 942 943 // packages/global-styles-engine/build-module/utils/layout.js 944 var LAYOUT_DEFINITIONS = { 945 default: { 946 name: "default", 947 slug: "flow", 948 className: "is-layout-flow", 949 baseStyles: [ 950 { 951 selector: " > .alignleft", 952 rules: { 953 float: "left", 954 "margin-inline-start": "0", 955 "margin-inline-end": "2em" 956 } 957 }, 958 { 959 selector: " > .alignright", 960 rules: { 961 float: "right", 962 "margin-inline-start": "2em", 963 "margin-inline-end": "0" 964 } 965 }, 966 { 967 selector: " > .aligncenter", 968 rules: { 969 "margin-left": "auto !important", 970 "margin-right": "auto !important" 971 } 972 } 973 ], 974 spacingStyles: [ 975 { 976 selector: " > :first-child", 977 rules: { 978 "margin-block-start": "0" 979 } 980 }, 981 { 982 selector: " > :last-child", 983 rules: { 984 "margin-block-end": "0" 985 } 986 }, 987 { 988 selector: " > *", 989 rules: { 990 "margin-block-start": null, 991 "margin-block-end": "0" 992 } 993 } 994 ] 995 }, 996 constrained: { 997 name: "constrained", 998 slug: "constrained", 999 className: "is-layout-constrained", 1000 baseStyles: [ 1001 { 1002 selector: " > .alignleft", 1003 rules: { 1004 float: "left", 1005 "margin-inline-start": "0", 1006 "margin-inline-end": "2em" 1007 } 1008 }, 1009 { 1010 selector: " > .alignright", 1011 rules: { 1012 float: "right", 1013 "margin-inline-start": "2em", 1014 "margin-inline-end": "0" 1015 } 1016 }, 1017 { 1018 selector: " > .aligncenter", 1019 rules: { 1020 "margin-left": "auto !important", 1021 "margin-right": "auto !important" 1022 } 1023 }, 1024 { 1025 selector: " > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 1026 rules: { 1027 "max-width": "var(--wp--style--global--content-size)", 1028 "margin-left": "auto !important", 1029 "margin-right": "auto !important" 1030 } 1031 }, 1032 { 1033 selector: " > .alignwide", 1034 rules: { 1035 "max-width": "var(--wp--style--global--wide-size)" 1036 } 1037 } 1038 ], 1039 spacingStyles: [ 1040 { 1041 selector: " > :first-child", 1042 rules: { 1043 "margin-block-start": "0" 1044 } 1045 }, 1046 { 1047 selector: " > :last-child", 1048 rules: { 1049 "margin-block-end": "0" 1050 } 1051 }, 1052 { 1053 selector: " > *", 1054 rules: { 1055 "margin-block-start": null, 1056 "margin-block-end": "0" 1057 } 1058 } 1059 ] 1060 }, 1061 flex: { 1062 name: "flex", 1063 slug: "flex", 1064 className: "is-layout-flex", 1065 displayMode: "flex", 1066 baseStyles: [ 1067 { 1068 selector: "", 1069 rules: { 1070 "flex-wrap": "wrap", 1071 "align-items": "center" 1072 } 1073 }, 1074 { 1075 selector: " > :is(*, div)", 1076 // :is(*, div) instead of just * increases the specificity by 001. 1077 rules: { 1078 margin: "0" 1079 } 1080 } 1081 ], 1082 spacingStyles: [ 1083 { 1084 selector: "", 1085 rules: { 1086 gap: null 1087 } 1088 } 1089 ] 1090 }, 1091 grid: { 1092 name: "grid", 1093 slug: "grid", 1094 className: "is-layout-grid", 1095 displayMode: "grid", 1096 baseStyles: [ 1097 { 1098 selector: " > :is(*, div)", 1099 // :is(*, div) instead of just * increases the specificity by 001. 1100 rules: { 1101 margin: "0" 1102 } 1103 } 1104 ], 1105 spacingStyles: [ 1106 { 1107 selector: "", 1108 rules: { 1109 gap: null 1110 } 1111 } 1112 ] 1113 } 1114 }; 1115 1116 // packages/global-styles-engine/build-module/core/render.js 1117 var ELEMENT_CLASS_NAMES = { 1118 button: "wp-element-button", 1119 caption: "wp-element-caption" 1120 }; 1121 var BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = { 1122 __experimentalBorder: "border", 1123 color: "color", 1124 dimensions: "dimensions", 1125 spacing: "spacing", 1126 typography: "typography" 1127 }; 1128 function getPresetsDeclarations(blockPresets = {}, mergedSettings) { 1129 return PRESET_METADATA.reduce( 1130 (declarations, { path, valueKey, valueFunc, cssVarInfix }) => { 1131 const presetByOrigin = getValueFromObjectPath( 1132 blockPresets, 1133 path, 1134 [] 1135 ); 1136 ["default", "theme", "custom"].forEach((origin) => { 1137 if (presetByOrigin[origin]) { 1138 presetByOrigin[origin].forEach((value) => { 1139 if (valueKey && !valueFunc) { 1140 declarations.push( 1141 `--wp--preset--$cssVarInfix}--$kebabCase( 1142 value.slug 1143 )}: $value[valueKey]}` 1144 ); 1145 } else if (valueFunc && typeof valueFunc === "function") { 1146 declarations.push( 1147 `--wp--preset--$cssVarInfix}--$kebabCase( 1148 value.slug 1149 )}: $valueFunc(value, mergedSettings)}` 1150 ); 1151 } 1152 }); 1153 } 1154 }); 1155 return declarations; 1156 }, 1157 [] 1158 ); 1159 } 1160 function getPresetsClasses(blockSelector = "*", blockPresets = {}) { 1161 return PRESET_METADATA.reduce( 1162 (declarations, { path, cssVarInfix, classes }) => { 1163 if (!classes) { 1164 return declarations; 1165 } 1166 const presetByOrigin = getValueFromObjectPath( 1167 blockPresets, 1168 path, 1169 [] 1170 ); 1171 ["default", "theme", "custom"].forEach((origin) => { 1172 if (presetByOrigin[origin]) { 1173 presetByOrigin[origin].forEach( 1174 ({ slug }) => { 1175 classes.forEach( 1176 ({ 1177 classSuffix, 1178 propertyName 1179 }) => { 1180 const classSelectorToUse = `.has-$kebabCase( 1181 slug 1182 )}-$classSuffix}`; 1183 const selectorToUse = blockSelector.split(",").map( 1184 (selector) => `$selector}$classSelectorToUse}` 1185 ).join(","); 1186 const value = `var(--wp--preset--$cssVarInfix}--$kebabCase( 1187 slug 1188 )})`; 1189 declarations += `$selectorToUse}{$propertyName}: $value} !important;}`; 1190 } 1191 ); 1192 } 1193 ); 1194 } 1195 }); 1196 return declarations; 1197 }, 1198 "" 1199 ); 1200 } 1201 function getPresetsSvgFilters(blockPresets = {}) { 1202 return PRESET_METADATA.filter( 1203 // Duotone are the only type of filters for now. 1204 (metadata) => metadata.path.at(-1) === "duotone" 1205 ).flatMap((metadata) => { 1206 const presetByOrigin = getValueFromObjectPath( 1207 blockPresets, 1208 metadata.path, 1209 {} 1210 ); 1211 return ["default", "theme"].filter((origin) => presetByOrigin[origin]).flatMap( 1212 (origin) => presetByOrigin[origin].map( 1213 (preset) => getDuotoneFilter( 1214 `wp-duotone-$preset.slug}`, 1215 preset.colors 1216 ) 1217 ) 1218 ).join(""); 1219 }); 1220 } 1221 function flattenTree(input = {}, prefix, token) { 1222 let result = []; 1223 Object.keys(input).forEach((key) => { 1224 const newKey = prefix + kebabCase(key.replace("/", "-")); 1225 const newLeaf = input[key]; 1226 if (newLeaf instanceof Object) { 1227 const newPrefix = newKey + token; 1228 result = [...result, ...flattenTree(newLeaf, newPrefix, token)]; 1229 } else { 1230 result.push(`$newKey}: $newLeaf}`); 1231 } 1232 }); 1233 return result; 1234 } 1235 function concatFeatureVariationSelectorString(featureSelector, styleVariationSelector) { 1236 const featureSelectors = featureSelector.split(","); 1237 const combinedSelectors = []; 1238 featureSelectors.forEach((selector) => { 1239 combinedSelectors.push( 1240 `$styleVariationSelector.trim()}$selector.trim()}` 1241 ); 1242 }); 1243 return combinedSelectors.join(", "); 1244 } 1245 var getFeatureDeclarations = (selectors, styles) => { 1246 const declarations = {}; 1247 Object.entries(selectors).forEach(([feature, selector]) => { 1248 if (feature === "root" || !styles?.[feature]) { 1249 return; 1250 } 1251 const isShorthand = typeof selector === "string"; 1252 if (!isShorthand && typeof selector === "object" && selector !== null) { 1253 Object.entries(selector).forEach( 1254 ([subfeature, subfeatureSelector]) => { 1255 if (subfeature === "root" || !styles?.[feature][subfeature]) { 1256 return; 1257 } 1258 const subfeatureStyles = { 1259 [feature]: { 1260 [subfeature]: styles[feature][subfeature] 1261 } 1262 }; 1263 const newDeclarations = getStylesDeclarations(subfeatureStyles); 1264 declarations[subfeatureSelector] = [ 1265 ...declarations[subfeatureSelector] || [], 1266 ...newDeclarations 1267 ]; 1268 delete styles[feature][subfeature]; 1269 } 1270 ); 1271 } 1272 if (isShorthand || typeof selector === "object" && selector !== null && "root" in selector) { 1273 const featureSelector = isShorthand ? selector : selector.root; 1274 const featureStyles = { [feature]: styles[feature] }; 1275 const newDeclarations = getStylesDeclarations(featureStyles); 1276 declarations[featureSelector] = [ 1277 ...declarations[featureSelector] || [], 1278 ...newDeclarations 1279 ]; 1280 delete styles[feature]; 1281 } 1282 }); 1283 return declarations; 1284 }; 1285 function getStylesDeclarations(blockStyles = {}, selector = "", useRootPaddingAlign, tree = {}, disableRootPadding = false) { 1286 const isRoot = ROOT_BLOCK_SELECTOR === selector; 1287 const output = Object.entries( 1288 import_blocks.__EXPERIMENTAL_STYLE_PROPERTY 1289 ).reduce( 1290 (declarations, [key, { value, properties, useEngine, rootOnly }]) => { 1291 if (rootOnly && !isRoot) { 1292 return declarations; 1293 } 1294 const pathToValue = value; 1295 if (pathToValue[0] === "elements" || useEngine) { 1296 return declarations; 1297 } 1298 const styleValue = getValueFromObjectPath( 1299 blockStyles, 1300 pathToValue 1301 ); 1302 if (key === "--wp--style--root--padding" && (typeof styleValue === "string" || !useRootPaddingAlign)) { 1303 return declarations; 1304 } 1305 if (properties && typeof styleValue !== "string") { 1306 Object.entries(properties).forEach((entry) => { 1307 const [name, prop] = entry; 1308 if (!getValueFromObjectPath(styleValue, [prop], false)) { 1309 return; 1310 } 1311 const cssProperty = name.startsWith("--") ? name : kebabCase(name); 1312 declarations.push( 1313 `$cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)( 1314 getValueFromObjectPath(styleValue, [prop]) 1315 )}` 1316 ); 1317 }); 1318 } else if (getValueFromObjectPath(blockStyles, pathToValue, false)) { 1319 const cssProperty = key.startsWith("--") ? key : kebabCase(key); 1320 declarations.push( 1321 `$cssProperty}: ${(0, import_style_engine2.getCSSValueFromRawStyle)( 1322 getValueFromObjectPath(blockStyles, pathToValue) 1323 )}` 1324 ); 1325 } 1326 return declarations; 1327 }, 1328 [] 1329 ); 1330 if (!!blockStyles.background) { 1331 if (blockStyles.background?.backgroundImage) { 1332 blockStyles.background.backgroundImage = getResolvedValue( 1333 blockStyles.background.backgroundImage, 1334 tree 1335 ); 1336 } 1337 if (!isRoot && !!blockStyles.background?.backgroundImage?.id) { 1338 blockStyles = { 1339 ...blockStyles, 1340 background: { 1341 ...blockStyles.background, 1342 ...setBackgroundStyleDefaults(blockStyles.background) 1343 } 1344 }; 1345 } 1346 } 1347 const extraRules = (0, import_style_engine2.getCSSRules)(blockStyles); 1348 extraRules.forEach((rule) => { 1349 if (isRoot && (useRootPaddingAlign || disableRootPadding) && rule.key.startsWith("padding")) { 1350 return; 1351 } 1352 const cssProperty = rule.key.startsWith("--") ? rule.key : kebabCase(rule.key); 1353 let ruleValue = getResolvedValue(rule.value, tree); 1354 if (cssProperty === "font-size") { 1355 ruleValue = getTypographyFontSizeValue( 1356 { name: "", slug: "", size: ruleValue }, 1357 tree?.settings 1358 ); 1359 } 1360 if (cssProperty === "aspect-ratio") { 1361 output.push("min-height: unset"); 1362 } 1363 output.push(`$cssProperty}: $ruleValue}`); 1364 }); 1365 return output; 1366 } 1367 function getLayoutStyles({ 1368 layoutDefinitions = LAYOUT_DEFINITIONS, 1369 style, 1370 selector, 1371 hasBlockGapSupport, 1372 hasFallbackGapSupport, 1373 fallbackGapValue 1374 }) { 1375 let ruleset = ""; 1376 let gapValue = hasBlockGapSupport ? getGapCSSValue(style?.spacing?.blockGap) : ""; 1377 if (hasFallbackGapSupport) { 1378 if (selector === ROOT_BLOCK_SELECTOR) { 1379 gapValue = !gapValue ? "0.5em" : gapValue; 1380 } else if (!hasBlockGapSupport && fallbackGapValue) { 1381 gapValue = fallbackGapValue; 1382 } 1383 } 1384 if (gapValue && layoutDefinitions) { 1385 Object.values(layoutDefinitions).forEach( 1386 ({ className, name, spacingStyles }) => { 1387 if (!hasBlockGapSupport && "flex" !== name && "grid" !== name) { 1388 return; 1389 } 1390 if (spacingStyles?.length) { 1391 spacingStyles.forEach((spacingStyle) => { 1392 const declarations = []; 1393 if (spacingStyle.rules) { 1394 Object.entries(spacingStyle.rules).forEach( 1395 ([cssProperty, cssValue]) => { 1396 declarations.push( 1397 `$cssProperty}: $cssValue ? cssValue : gapValue}` 1398 ); 1399 } 1400 ); 1401 } 1402 if (declarations.length) { 1403 let combinedSelector = ""; 1404 if (!hasBlockGapSupport) { 1405 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:where(.$className}$spacingStyle?.selector || ""})` : `:where($selector}.$className}$spacingStyle?.selector || ""})`; 1406 } else { 1407 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:root :where(.$className})$spacingStyle?.selector || ""}` : `:root :where($selector}-$className})$spacingStyle?.selector || ""}`; 1408 } 1409 ruleset += `$combinedSelector} { $declarations.join( 1410 "; " 1411 )}; }`; 1412 } 1413 }); 1414 } 1415 } 1416 ); 1417 if (selector === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) { 1418 ruleset += `$ROOT_CSS_PROPERTIES_SELECTOR} { --wp--style--block-gap: $gapValue}; }`; 1419 } 1420 } 1421 if (selector === ROOT_BLOCK_SELECTOR && layoutDefinitions) { 1422 const validDisplayModes = ["block", "flex", "grid"]; 1423 Object.values(layoutDefinitions).forEach( 1424 ({ className, displayMode, baseStyles }) => { 1425 if (displayMode && validDisplayModes.includes(displayMode)) { 1426 ruleset += `$selector} .$className} { display:$displayMode}; }`; 1427 } 1428 if (baseStyles?.length) { 1429 baseStyles.forEach((baseStyle) => { 1430 const declarations = []; 1431 if (baseStyle.rules) { 1432 Object.entries(baseStyle.rules).forEach( 1433 ([cssProperty, cssValue]) => { 1434 declarations.push( 1435 `$cssProperty}: $cssValue}` 1436 ); 1437 } 1438 ); 1439 } 1440 if (declarations.length) { 1441 const combinedSelector = `.$className}$baseStyle?.selector || ""}`; 1442 ruleset += `$combinedSelector} { $declarations.join( 1443 "; " 1444 )}; }`; 1445 } 1446 }); 1447 } 1448 } 1449 ); 1450 } 1451 return ruleset; 1452 } 1453 var STYLE_KEYS = [ 1454 "border", 1455 "color", 1456 "dimensions", 1457 "spacing", 1458 "typography", 1459 "filter", 1460 "outline", 1461 "shadow", 1462 "background" 1463 ]; 1464 function pickStyleKeys(treeToPickFrom) { 1465 if (!treeToPickFrom) { 1466 return {}; 1467 } 1468 const entries = Object.entries(treeToPickFrom); 1469 const pickedEntries = entries.filter( 1470 ([key]) => STYLE_KEYS.includes(key) 1471 ); 1472 const clonedEntries = pickedEntries.map(([key, style]) => [ 1473 key, 1474 JSON.parse(JSON.stringify(style)) 1475 ]); 1476 return Object.fromEntries(clonedEntries); 1477 } 1478 var getNodesWithStyles = (tree, blockSelectors) => { 1479 const nodes = []; 1480 if (!tree?.styles) { 1481 return nodes; 1482 } 1483 const styles = pickStyleKeys(tree.styles); 1484 if (styles) { 1485 nodes.push({ 1486 styles, 1487 selector: ROOT_BLOCK_SELECTOR, 1488 // Root selector (body) styles should not be wrapped in `:root where()` to keep 1489 // specificity at (0,0,1) and maintain backwards compatibility. 1490 skipSelectorWrapper: true 1491 }); 1492 } 1493 Object.entries(import_blocks.__EXPERIMENTAL_ELEMENTS).forEach(([name, selector]) => { 1494 if (tree.styles?.elements?.[name]) { 1495 nodes.push({ 1496 styles: tree.styles?.elements?.[name] ?? {}, 1497 selector, 1498 // Top level elements that don't use a class name should not receive the 1499 // `:root :where()` wrapper to maintain backwards compatibility. 1500 skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name] 1501 }); 1502 } 1503 }); 1504 Object.entries(tree.styles?.blocks ?? {}).forEach( 1505 ([blockName, node]) => { 1506 const blockStyles = pickStyleKeys(node); 1507 const typedNode = node; 1508 if (typedNode?.variations) { 1509 const variations = {}; 1510 Object.entries(typedNode.variations).forEach( 1511 ([variationName, variation]) => { 1512 const typedVariation = variation; 1513 variations[variationName] = pickStyleKeys(typedVariation); 1514 if (typedVariation?.css) { 1515 variations[variationName].css = typedVariation.css; 1516 } 1517 const variationSelector = typeof blockSelectors !== "string" ? blockSelectors[blockName]?.styleVariationSelectors?.[variationName] : void 0; 1518 Object.entries( 1519 typedVariation?.elements ?? {} 1520 ).forEach(([element, elementStyles]) => { 1521 if (elementStyles && import_blocks.__EXPERIMENTAL_ELEMENTS[element]) { 1522 nodes.push({ 1523 styles: elementStyles, 1524 selector: scopeSelector( 1525 variationSelector, 1526 import_blocks.__EXPERIMENTAL_ELEMENTS[element] 1527 ) 1528 }); 1529 } 1530 }); 1531 Object.entries(typedVariation?.blocks ?? {}).forEach( 1532 ([ 1533 variationBlockName, 1534 variationBlockStyles 1535 ]) => { 1536 const variationBlockSelector = typeof blockSelectors !== "string" ? scopeSelector( 1537 variationSelector, 1538 blockSelectors[variationBlockName]?.selector 1539 ) : void 0; 1540 const variationDuotoneSelector = typeof blockSelectors !== "string" ? scopeSelector( 1541 variationSelector, 1542 blockSelectors[variationBlockName]?.duotoneSelector 1543 ) : void 0; 1544 const variationFeatureSelectors = typeof blockSelectors !== "string" ? scopeFeatureSelectors( 1545 variationSelector, 1546 blockSelectors[variationBlockName]?.featureSelectors ?? {} 1547 ) : void 0; 1548 const variationBlockStyleNodes = pickStyleKeys(variationBlockStyles); 1549 if (variationBlockStyles?.css) { 1550 variationBlockStyleNodes.css = variationBlockStyles.css; 1551 } 1552 if (!variationBlockSelector || typeof blockSelectors === "string") { 1553 return; 1554 } 1555 nodes.push({ 1556 selector: variationBlockSelector, 1557 duotoneSelector: variationDuotoneSelector, 1558 featureSelectors: variationFeatureSelectors, 1559 fallbackGapValue: blockSelectors[variationBlockName]?.fallbackGapValue, 1560 hasLayoutSupport: blockSelectors[variationBlockName]?.hasLayoutSupport, 1561 styles: variationBlockStyleNodes 1562 }); 1563 Object.entries( 1564 variationBlockStyles.elements ?? {} 1565 ).forEach( 1566 ([ 1567 variationBlockElement, 1568 variationBlockElementStyles 1569 ]) => { 1570 if (variationBlockElementStyles && import_blocks.__EXPERIMENTAL_ELEMENTS[variationBlockElement]) { 1571 nodes.push({ 1572 styles: variationBlockElementStyles, 1573 selector: scopeSelector( 1574 variationBlockSelector, 1575 import_blocks.__EXPERIMENTAL_ELEMENTS[variationBlockElement] 1576 ) 1577 }); 1578 } 1579 } 1580 ); 1581 } 1582 ); 1583 } 1584 ); 1585 blockStyles.variations = variations; 1586 } 1587 if (typeof blockSelectors !== "string" && blockSelectors?.[blockName]?.selector) { 1588 nodes.push({ 1589 duotoneSelector: blockSelectors[blockName].duotoneSelector, 1590 fallbackGapValue: blockSelectors[blockName].fallbackGapValue, 1591 hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport, 1592 selector: blockSelectors[blockName].selector, 1593 styles: blockStyles, 1594 featureSelectors: blockSelectors[blockName].featureSelectors, 1595 styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors 1596 }); 1597 } 1598 Object.entries(typedNode?.elements ?? {}).forEach( 1599 ([elementName, value]) => { 1600 if (typeof blockSelectors !== "string" && value && blockSelectors?.[blockName] && import_blocks.__EXPERIMENTAL_ELEMENTS[elementName]) { 1601 nodes.push({ 1602 styles: value, 1603 selector: blockSelectors[blockName]?.selector.split(",").map((sel) => { 1604 const elementSelectors = import_blocks.__EXPERIMENTAL_ELEMENTS[elementName].split(","); 1605 return elementSelectors.map( 1606 (elementSelector) => sel + " " + elementSelector 1607 ); 1608 }).join(",") 1609 }); 1610 } 1611 } 1612 ); 1613 } 1614 ); 1615 return nodes; 1616 }; 1617 var getNodesWithSettings = (tree, blockSelectors) => { 1618 const nodes = []; 1619 if (!tree?.settings) { 1620 return nodes; 1621 } 1622 const pickPresets = (treeToPickFrom) => { 1623 let presets2 = {}; 1624 PRESET_METADATA.forEach(({ path }) => { 1625 const value = getValueFromObjectPath(treeToPickFrom, path, false); 1626 if (value !== false) { 1627 presets2 = setImmutably(presets2, path, value); 1628 } 1629 }); 1630 return presets2; 1631 }; 1632 const presets = pickPresets(tree.settings); 1633 const custom = tree.settings?.custom; 1634 if (Object.keys(presets).length > 0 || custom) { 1635 nodes.push({ 1636 presets, 1637 custom, 1638 selector: ROOT_CSS_PROPERTIES_SELECTOR 1639 }); 1640 } 1641 Object.entries(tree.settings?.blocks ?? {}).forEach( 1642 ([blockName, node]) => { 1643 const blockCustom = node.custom; 1644 if (typeof blockSelectors === "string" || !blockSelectors[blockName]) { 1645 return; 1646 } 1647 const blockPresets = pickPresets(node); 1648 if (Object.keys(blockPresets).length > 0 || blockCustom) { 1649 nodes.push({ 1650 presets: blockPresets, 1651 custom: blockCustom, 1652 selector: blockSelectors[blockName]?.selector 1653 }); 1654 } 1655 } 1656 ); 1657 return nodes; 1658 }; 1659 var generateCustomProperties = (tree, blockSelectors) => { 1660 const settings = getNodesWithSettings(tree, blockSelectors); 1661 let ruleset = ""; 1662 settings.forEach(({ presets, custom, selector }) => { 1663 const declarations = tree?.settings ? getPresetsDeclarations(presets, tree?.settings) : []; 1664 const customProps = flattenTree(custom, "--wp--custom--", "--"); 1665 if (customProps.length > 0) { 1666 declarations.push(...customProps); 1667 } 1668 if (declarations.length > 0) { 1669 ruleset += `$selector}{$declarations.join(";")};}`; 1670 } 1671 }); 1672 return ruleset; 1673 }; 1674 var transformToStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles = false, disableRootPadding = false, styleOptions = {}) => { 1675 const options = { 1676 blockGap: true, 1677 blockStyles: true, 1678 layoutStyles: true, 1679 marginReset: true, 1680 presets: true, 1681 rootPadding: true, 1682 variationStyles: false, 1683 ...styleOptions 1684 }; 1685 const nodesWithStyles = getNodesWithStyles(tree, blockSelectors); 1686 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors); 1687 const useRootPaddingAlign = tree?.settings?.useRootPaddingAwareAlignments; 1688 const { contentSize, wideSize } = tree?.settings?.layout || {}; 1689 const hasBodyStyles = options.marginReset || options.rootPadding || options.layoutStyles; 1690 let ruleset = ""; 1691 if (options.presets && (contentSize || wideSize)) { 1692 ruleset += `$ROOT_CSS_PROPERTIES_SELECTOR} {`; 1693 ruleset = contentSize ? ruleset + ` --wp--style--global--content-size: $contentSize};` : ruleset; 1694 ruleset = wideSize ? ruleset + ` --wp--style--global--wide-size: $wideSize};` : ruleset; 1695 ruleset += "}"; 1696 } 1697 if (hasBodyStyles) { 1698 ruleset += ":where(body) {margin: 0;"; 1699 if (options.rootPadding && useRootPaddingAlign) { 1700 ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) } 1701 .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); } 1702 .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); } 1703 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; } 1704 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0; 1705 `; 1706 } 1707 ruleset += "}"; 1708 } 1709 if (options.blockStyles) { 1710 nodesWithStyles.forEach( 1711 ({ 1712 selector, 1713 duotoneSelector, 1714 styles, 1715 fallbackGapValue, 1716 hasLayoutSupport, 1717 featureSelectors, 1718 styleVariationSelectors, 1719 skipSelectorWrapper 1720 }) => { 1721 if (featureSelectors) { 1722 const featureDeclarations = getFeatureDeclarations( 1723 featureSelectors, 1724 styles 1725 ); 1726 Object.entries(featureDeclarations).forEach( 1727 ([cssSelector, declarations]) => { 1728 if (declarations.length) { 1729 const rules = declarations.join(";"); 1730 ruleset += `:root :where($cssSelector}){$rules};}`; 1731 } 1732 } 1733 ); 1734 } 1735 if (duotoneSelector) { 1736 const duotoneStyles = {}; 1737 if (styles?.filter) { 1738 duotoneStyles.filter = styles.filter; 1739 delete styles.filter; 1740 } 1741 const duotoneDeclarations = getStylesDeclarations(duotoneStyles); 1742 if (duotoneDeclarations.length) { 1743 ruleset += `$duotoneSelector}{$duotoneDeclarations.join( 1744 ";" 1745 )};}`; 1746 } 1747 } 1748 if (!disableLayoutStyles && (ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport)) { 1749 ruleset += getLayoutStyles({ 1750 style: styles, 1751 selector, 1752 hasBlockGapSupport, 1753 hasFallbackGapSupport, 1754 fallbackGapValue 1755 }); 1756 } 1757 const styleDeclarations = getStylesDeclarations( 1758 styles, 1759 selector, 1760 useRootPaddingAlign, 1761 tree, 1762 disableRootPadding 1763 ); 1764 if (styleDeclarations?.length) { 1765 const generalSelector = skipSelectorWrapper ? selector : `:root :where($selector})`; 1766 ruleset += `$generalSelector}{$styleDeclarations.join( 1767 ";" 1768 )};}`; 1769 } 1770 if (styles?.css) { 1771 ruleset += processCSSNesting( 1772 styles.css, 1773 `:root :where($selector})` 1774 ); 1775 } 1776 if (options.variationStyles && styleVariationSelectors) { 1777 Object.entries(styleVariationSelectors).forEach( 1778 ([styleVariationName, styleVariationSelector]) => { 1779 const styleVariations = styles?.variations?.[styleVariationName]; 1780 if (styleVariations) { 1781 if (featureSelectors) { 1782 const featureDeclarations = getFeatureDeclarations( 1783 featureSelectors, 1784 styleVariations 1785 ); 1786 Object.entries( 1787 featureDeclarations 1788 ).forEach( 1789 ([baseSelector, declarations]) => { 1790 if (declarations.length) { 1791 const cssSelector = concatFeatureVariationSelectorString( 1792 baseSelector, 1793 styleVariationSelector 1794 ); 1795 const rules = declarations.join(";"); 1796 ruleset += `:root :where($cssSelector}){$rules};}`; 1797 } 1798 } 1799 ); 1800 } 1801 const styleVariationDeclarations = getStylesDeclarations( 1802 styleVariations, 1803 styleVariationSelector, 1804 useRootPaddingAlign, 1805 tree 1806 ); 1807 if (styleVariationDeclarations.length) { 1808 ruleset += `:root :where($styleVariationSelector}){$styleVariationDeclarations.join( 1809 ";" 1810 )};}`; 1811 } 1812 if (styleVariations?.css) { 1813 ruleset += processCSSNesting( 1814 styleVariations.css, 1815 `:root :where($styleVariationSelector})` 1816 ); 1817 } 1818 } 1819 } 1820 ); 1821 } 1822 const pseudoSelectorStyles = Object.entries(styles).filter( 1823 ([key]) => key.startsWith(":") 1824 ); 1825 if (pseudoSelectorStyles?.length) { 1826 pseudoSelectorStyles.forEach( 1827 ([pseudoKey, pseudoStyle]) => { 1828 const pseudoDeclarations = getStylesDeclarations(pseudoStyle); 1829 if (!pseudoDeclarations?.length) { 1830 return; 1831 } 1832 const _selector = selector.split(",").map((sel) => sel + pseudoKey).join(","); 1833 const pseudoRule = `:root :where($_selector}){$pseudoDeclarations.join( 1834 ";" 1835 )};}`; 1836 ruleset += pseudoRule; 1837 } 1838 ); 1839 } 1840 } 1841 ); 1842 } 1843 if (options.layoutStyles) { 1844 ruleset = ruleset + ".wp-site-blocks > .alignleft { float: left; margin-right: 2em; }"; 1845 ruleset = ruleset + ".wp-site-blocks > .alignright { float: right; margin-left: 2em; }"; 1846 ruleset = ruleset + ".wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }"; 1847 } 1848 if (options.blockGap && hasBlockGapSupport) { 1849 const gapValue = getGapCSSValue(tree?.styles?.spacing?.blockGap) || "0.5em"; 1850 ruleset = ruleset + `:root :where(.wp-site-blocks) > * { margin-block-start: $gapValue}; margin-block-end: 0; }`; 1851 ruleset = ruleset + ":root :where(.wp-site-blocks) > :first-child { margin-block-start: 0; }"; 1852 ruleset = ruleset + ":root :where(.wp-site-blocks) > :last-child { margin-block-end: 0; }"; 1853 } 1854 if (options.presets) { 1855 nodesWithSettings.forEach(({ selector, presets }) => { 1856 if (ROOT_BLOCK_SELECTOR === selector || ROOT_CSS_PROPERTIES_SELECTOR === selector) { 1857 selector = ""; 1858 } 1859 const classes = getPresetsClasses(selector, presets); 1860 if (classes.length > 0) { 1861 ruleset += classes; 1862 } 1863 }); 1864 } 1865 return ruleset; 1866 }; 1867 function generateSvgFilters(tree, blockSelectors) { 1868 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors); 1869 return nodesWithSettings.flatMap(({ presets }) => { 1870 return getPresetsSvgFilters(presets); 1871 }); 1872 } 1873 var getSelectorsConfig = (blockType, rootSelector) => { 1874 if (blockType?.selectors && Object.keys(blockType.selectors).length > 0) { 1875 return blockType.selectors; 1876 } 1877 const config = { 1878 root: rootSelector 1879 }; 1880 Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach( 1881 ([featureKey, featureName]) => { 1882 const featureSelector = getBlockSelector(blockType, featureKey); 1883 if (featureSelector) { 1884 config[featureName] = featureSelector; 1885 } 1886 } 1887 ); 1888 return config; 1889 }; 1890 var getBlockSelectors = (blockTypes, variationInstanceId) => { 1891 const { getBlockStyles } = (0, import_data2.select)(import_blocks.store); 1892 const result = {}; 1893 blockTypes.forEach((blockType) => { 1894 const name = blockType.name; 1895 const selector = getBlockSelector(blockType); 1896 if (!selector) { 1897 return; 1898 } 1899 let duotoneSelector = getBlockSelector(blockType, "filter.duotone"); 1900 if (!duotoneSelector) { 1901 const rootSelector = getBlockSelector(blockType); 1902 const duotoneSupport = (0, import_blocks.getBlockSupport)( 1903 blockType, 1904 "color.__experimentalDuotone", 1905 false 1906 ); 1907 duotoneSelector = duotoneSupport && rootSelector && scopeSelector(rootSelector, duotoneSupport); 1908 } 1909 const hasLayoutSupport = !!blockType?.supports?.layout || !!blockType?.supports?.__experimentalLayout; 1910 const fallbackGapValue = ( 1911 // @ts-expect-error 1912 blockType?.supports?.spacing?.blockGap?.__experimentalDefault 1913 ); 1914 const blockStyleVariations = getBlockStyles(name); 1915 const styleVariationSelectors = {}; 1916 blockStyleVariations?.forEach((variation) => { 1917 const variationSuffix = variationInstanceId ? `-$variationInstanceId}` : ""; 1918 const variationName = `$variation.name}$variationSuffix}`; 1919 const styleVariationSelector = getBlockStyleVariationSelector( 1920 variationName, 1921 selector 1922 ); 1923 styleVariationSelectors[variationName] = styleVariationSelector; 1924 }); 1925 const featureSelectors = getSelectorsConfig(blockType, selector); 1926 result[name] = { 1927 duotoneSelector: duotoneSelector ?? void 0, 1928 fallbackGapValue, 1929 featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : void 0, 1930 hasLayoutSupport, 1931 name, 1932 selector, 1933 styleVariationSelectors: blockStyleVariations?.length ? styleVariationSelectors : void 0 1934 }; 1935 }); 1936 return result; 1937 }; 1938 function updateConfigWithSeparator(config) { 1939 const blocks = config.styles?.blocks; 1940 const separatorBlock = blocks?.["core/separator"]; 1941 const needsSeparatorStyleUpdate = separatorBlock && separatorBlock.color?.background && !separatorBlock.color?.text && !separatorBlock.border?.color; 1942 if (needsSeparatorStyleUpdate) { 1943 return { 1944 ...config, 1945 styles: { 1946 ...config.styles, 1947 blocks: { 1948 ...blocks, 1949 "core/separator": { 1950 ...separatorBlock, 1951 color: { 1952 ...separatorBlock.color, 1953 text: separatorBlock.color?.background 1954 } 1955 } 1956 } 1957 } 1958 }; 1959 } 1960 return config; 1961 } 1962 function processCSSNesting(css2, blockSelector) { 1963 let processedCSS = ""; 1964 if (!css2 || css2.trim() === "") { 1965 return processedCSS; 1966 } 1967 const parts = css2.split("&"); 1968 parts.forEach((part) => { 1969 if (!part || part.trim() === "") { 1970 return; 1971 } 1972 const isRootCss = !part.includes("{"); 1973 if (isRootCss) { 1974 processedCSS += `:root :where($blockSelector}){$part.trim()}}`; 1975 } else { 1976 const splitPart = part.replace("}", "").split("{"); 1977 if (splitPart.length !== 2) { 1978 return; 1979 } 1980 const [nestedSelector, cssValue] = splitPart; 1981 const matches = nestedSelector.match(/([>+~\s]*::[a-zA-Z-]+)/); 1982 const pseudoPart = matches ? matches[1] : ""; 1983 const withoutPseudoElement = matches ? nestedSelector.replace(pseudoPart, "").trim() : nestedSelector.trim(); 1984 let combinedSelector; 1985 if (withoutPseudoElement === "") { 1986 combinedSelector = blockSelector; 1987 } else { 1988 combinedSelector = nestedSelector.startsWith(" ") ? scopeSelector(blockSelector, withoutPseudoElement) : appendToSelector(blockSelector, withoutPseudoElement); 1989 } 1990 processedCSS += `:root :where($combinedSelector})$pseudoPart}{$cssValue.trim()}}`; 1991 } 1992 }); 1993 return processedCSS; 1994 } 1995 function generateGlobalStyles(config = {}, blockTypes = [], options = {}) { 1996 const { 1997 hasBlockGapSupport: hasBlockGapSupportOption, 1998 hasFallbackGapSupport: hasFallbackGapSupportOption, 1999 disableLayoutStyles = false, 2000 disableRootPadding = false, 2001 styleOptions = {} 2002 } = options; 2003 const blocks = blockTypes.length > 0 ? blockTypes : (0, import_blocks.getBlockTypes)(); 2004 const blockGap = getSetting(config, "spacing.blockGap"); 2005 const hasBlockGapSupport = hasBlockGapSupportOption ?? blockGap !== null; 2006 const hasFallbackGapSupport = hasFallbackGapSupportOption ?? !hasBlockGapSupport; 2007 if (!config?.styles || !config?.settings) { 2008 return [[], {}]; 2009 } 2010 const updatedConfig = updateConfigWithSeparator(config); 2011 const blockSelectors = getBlockSelectors(blocks); 2012 const customProperties = generateCustomProperties( 2013 updatedConfig, 2014 blockSelectors 2015 ); 2016 const globalStyles = transformToStyles( 2017 updatedConfig, 2018 blockSelectors, 2019 hasBlockGapSupport, 2020 hasFallbackGapSupport, 2021 disableLayoutStyles, 2022 disableRootPadding, 2023 styleOptions 2024 ); 2025 const svgs = generateSvgFilters(updatedConfig, blockSelectors); 2026 const styles = [ 2027 { 2028 css: customProperties, 2029 isGlobalStyles: true 2030 }, 2031 { 2032 css: globalStyles, 2033 isGlobalStyles: true 2034 }, 2035 // Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor. 2036 { 2037 css: updatedConfig?.styles?.css ?? "", 2038 isGlobalStyles: true 2039 }, 2040 { 2041 assets: svgs, 2042 __unstableType: "svg", 2043 isGlobalStyles: true 2044 } 2045 ]; 2046 blocks.forEach((blockType) => { 2047 const blockStyles = updatedConfig?.styles?.blocks?.[blockType.name]; 2048 if (blockStyles?.css) { 2049 const selector = blockSelectors[blockType.name].selector; 2050 styles.push({ 2051 css: processCSSNesting(blockStyles.css, selector), 2052 isGlobalStyles: true 2053 }); 2054 } 2055 }); 2056 return [styles, updatedConfig.settings]; 2057 } 2058 2059 // packages/lazy-editor/build-module/hooks/use-editor-settings.js 2060 var import_core_data3 = __toESM(require_core_data()); 2061 var import_element2 = __toESM(require_element()); 2062 var import_data4 = __toESM(require_data()); 2063 2064 // packages/lazy-editor/build-module/hooks/use-global-styles.js 2065 var import_core_data2 = __toESM(require_core_data()); 2066 var import_data3 = __toESM(require_data()); 2067 var import_element = __toESM(require_element()); 2068 function useUserGlobalStyles(id) { 2069 const { userGlobalStyles } = (0, import_data3.useSelect)( 2070 (select2) => { 2071 const { getEntityRecord, getEditedEntityRecord, canUser } = select2(import_core_data2.store); 2072 const userCanEditGlobalStyles = canUser("update", { 2073 kind: "root", 2074 name: "globalStyles", 2075 id 2076 }); 2077 let record; 2078 if ( 2079 /* 2080 * Test that the OPTIONS request for user capabilities is complete 2081 * before fetching the global styles entity record. 2082 * This is to avoid fetching the global styles entity unnecessarily. 2083 */ 2084 typeof userCanEditGlobalStyles === "boolean" 2085 ) { 2086 if (userCanEditGlobalStyles) { 2087 record = getEditedEntityRecord( 2088 "root", 2089 "globalStyles", 2090 id 2091 ); 2092 } else { 2093 record = getEntityRecord("root", "globalStyles", id, { 2094 context: "view" 2095 }); 2096 } 2097 } 2098 return { 2099 userGlobalStyles: record 2100 }; 2101 }, 2102 [id] 2103 ); 2104 return (0, import_element.useMemo)(() => { 2105 if (!userGlobalStyles) { 2106 return { 2107 user: void 0 2108 }; 2109 } 2110 const user = userGlobalStyles; 2111 return { 2112 user 2113 }; 2114 }, [userGlobalStyles]); 2115 } 2116 2117 // packages/lazy-editor/build-module/lock-unlock.js 2118 var import_private_apis = __toESM(require_private_apis()); 2119 var { unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 2120 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 2121 "@wordpress/lazy-editor" 2122 ); 2123 2124 // packages/lazy-editor/build-module/hooks/use-editor-settings.js 2125 function useEditorSettings({ stylesId }) { 2126 const { editorSettings } = (0, import_data4.useSelect)( 2127 (select2) => ({ 2128 editorSettings: unlock( 2129 select2(import_core_data3.store) 2130 ).getEditorSettings() 2131 }), 2132 [] 2133 ); 2134 const { user: globalStyles } = useUserGlobalStyles(stylesId); 2135 const [globalStylesCSS] = generateGlobalStyles(globalStyles); 2136 const hasEditorSettings = !!editorSettings; 2137 const styles = (0, import_element2.useMemo)(() => { 2138 if (!hasEditorSettings) { 2139 return []; 2140 } 2141 return [ 2142 ...editorSettings?.styles ?? [], 2143 ...globalStylesCSS 2144 ]; 2145 }, [hasEditorSettings, editorSettings?.styles, globalStylesCSS]); 2146 return { 2147 isReady: hasEditorSettings, 2148 editorSettings: (0, import_element2.useMemo)( 2149 () => ({ 2150 ...editorSettings ?? {}, 2151 styles 2152 }), 2153 [editorSettings, styles] 2154 ) 2155 }; 2156 } 2157 2158 // packages/asset-loader/build-module/index.js 2159 function injectImportMap(scriptModules) { 2160 if (!scriptModules || Object.keys(scriptModules).length === 0) { 2161 return; 2162 } 2163 const existingMapElement = document.querySelector( 2164 "script#wp-importmap[type=importmap]" 2165 ); 2166 if (existingMapElement) { 2167 try { 2168 const existingMap = JSON.parse(existingMapElement.text); 2169 if (!existingMap.imports) { 2170 existingMap.imports = {}; 2171 } 2172 existingMap.imports = { 2173 ...existingMap.imports, 2174 ...scriptModules 2175 }; 2176 existingMapElement.text = JSON.stringify(existingMap, null, 2); 2177 } catch (error) { 2178 console.error("Failed to parse or update import map:", error); 2179 } 2180 } else { 2181 const script = document.createElement("script"); 2182 script.type = "importmap"; 2183 script.id = "wp-importmap"; 2184 script.text = JSON.stringify( 2185 { 2186 imports: scriptModules 2187 }, 2188 null, 2189 2 2190 ); 2191 document.head.appendChild(script); 2192 } 2193 } 2194 function loadStylesheet(handle, styleData) { 2195 return new Promise((resolve) => { 2196 if (!styleData.src) { 2197 resolve(); 2198 return; 2199 } 2200 const existingLink = document.getElementById(handle + "-css"); 2201 if (existingLink) { 2202 resolve(); 2203 return; 2204 } 2205 const link = document.createElement("link"); 2206 link.rel = "stylesheet"; 2207 link.href = styleData.src + (styleData.version ? "?ver=" + styleData.version : ""); 2208 link.id = handle + "-css"; 2209 link.media = styleData.media || "all"; 2210 link.onload = () => resolve(); 2211 link.onerror = () => { 2212 console.error(`Failed to load stylesheet: $handle}`); 2213 resolve(); 2214 }; 2215 document.head.appendChild(link); 2216 }); 2217 } 2218 function loadScript(handle, scriptData) { 2219 if (!scriptData.src) { 2220 const marker = document.createElement("script"); 2221 marker.id = handle + "-js"; 2222 marker.textContent = "// Processed: " + handle; 2223 return marker; 2224 } 2225 const script = document.createElement("script"); 2226 script.src = scriptData.src + (scriptData.version ? "?ver=" + scriptData.version : ""); 2227 script.id = handle + "-js"; 2228 script.async = false; 2229 return script; 2230 } 2231 function injectInlineStyle(handle, inlineStyle, position) { 2232 let styleContent = ""; 2233 if (Array.isArray(inlineStyle)) { 2234 styleContent = inlineStyle.join("\n"); 2235 } else if (typeof inlineStyle === "string") { 2236 styleContent = inlineStyle; 2237 } 2238 if (styleContent && styleContent.trim()) { 2239 const styleId = handle + "-" + position + "-inline-css"; 2240 if (!document.getElementById(styleId)) { 2241 const style = document.createElement("style"); 2242 style.id = styleId; 2243 style.textContent = styleContent.trim(); 2244 document.head.appendChild(style); 2245 } 2246 } 2247 } 2248 function injectInlineScript(handle, inlineScript, position) { 2249 let scriptContent = inlineScript; 2250 if (Array.isArray(scriptContent)) { 2251 scriptContent = scriptContent.join("\n"); 2252 } 2253 const script = document.createElement("script"); 2254 script.id = handle + "-" + position + "-js"; 2255 script.textContent = scriptContent.trim(); 2256 return script; 2257 } 2258 function buildDependencyOrderedList(assetsData) { 2259 const visited = /* @__PURE__ */ new Set(); 2260 const visiting = /* @__PURE__ */ new Set(); 2261 const orderedList = []; 2262 function visit(handle) { 2263 if (visited.has(handle)) { 2264 return; 2265 } 2266 if (visiting.has(handle)) { 2267 console.warn( 2268 `Circular dependency detected for handle: $handle}` 2269 ); 2270 return; 2271 } 2272 visiting.add(handle); 2273 if (assetsData[handle]) { 2274 const deps = assetsData[handle].deps || []; 2275 deps.forEach((dep) => { 2276 if (assetsData[dep]) { 2277 visit(dep); 2278 } 2279 }); 2280 } 2281 visiting.delete(handle); 2282 visited.add(handle); 2283 if (assetsData[handle]) { 2284 orderedList.push(handle); 2285 } 2286 } 2287 Object.keys(assetsData).forEach((handle) => { 2288 visit(handle); 2289 }); 2290 return orderedList; 2291 } 2292 async function performScriptLoad(scriptElements, destination) { 2293 let parallel = []; 2294 for (const scriptElement of scriptElements) { 2295 if (scriptElement.src) { 2296 const loader = Promise.withResolvers(); 2297 scriptElement.onload = () => loader.resolve(); 2298 scriptElement.onerror = () => { 2299 console.error(`Failed to load script: $scriptElement.id}`); 2300 loader.resolve(); 2301 }; 2302 parallel.push(loader.promise); 2303 } else { 2304 await Promise.all(parallel); 2305 parallel = []; 2306 } 2307 destination.appendChild(scriptElement); 2308 } 2309 await Promise.all(parallel); 2310 parallel = []; 2311 } 2312 async function loadAssets(scriptsData, inlineScripts, stylesData, inlineStyles, htmlTemplates, scriptModules) { 2313 if (scriptModules) { 2314 injectImportMap(scriptModules); 2315 } 2316 const orderedStyles = buildDependencyOrderedList(stylesData); 2317 const orderedScripts = buildDependencyOrderedList(scriptsData); 2318 const stylePromises = []; 2319 for (const handle of orderedStyles) { 2320 const beforeInline = inlineStyles.before?.[handle]; 2321 if (beforeInline) { 2322 injectInlineStyle(handle, beforeInline, "before"); 2323 } 2324 stylePromises.push(loadStylesheet(handle, stylesData[handle])); 2325 const afterInline = inlineStyles.after?.[handle]; 2326 if (afterInline) { 2327 injectInlineStyle(handle, afterInline, "after"); 2328 } 2329 } 2330 const scriptElements = []; 2331 for (const handle of orderedScripts) { 2332 const beforeInline = inlineScripts.before?.[handle]; 2333 if (beforeInline) { 2334 scriptElements.push( 2335 injectInlineScript(handle, beforeInline, "before") 2336 ); 2337 } 2338 scriptElements.push(loadScript(handle, scriptsData[handle])); 2339 const afterInline = inlineScripts.after?.[handle]; 2340 if (afterInline) { 2341 scriptElements.push( 2342 injectInlineScript(handle, afterInline, "after") 2343 ); 2344 } 2345 } 2346 const scriptsPromise = performScriptLoad(scriptElements, document.body); 2347 await Promise.all([Promise.all(stylePromises), scriptsPromise]); 2348 if (htmlTemplates && htmlTemplates.length > 0) { 2349 htmlTemplates.forEach((templateHtml) => { 2350 const scriptMatch = templateHtml.match( 2351 /<script([^>]*)>(.*?)<\/script>/is 2352 ); 2353 if (scriptMatch) { 2354 const attributes = scriptMatch[1]; 2355 const content = scriptMatch[2]; 2356 const script = document.createElement("script"); 2357 const idMatch = attributes.match(/id=["']([^"']+)["']/); 2358 if (idMatch) { 2359 script.id = idMatch[1]; 2360 } 2361 const typeMatch = attributes.match(/type=["']([^"']+)["']/); 2362 if (typeMatch) { 2363 script.type = typeMatch[1]; 2364 } 2365 script.textContent = content; 2366 document.body.appendChild(script); 2367 } 2368 }); 2369 } 2370 } 2371 var index_default = loadAssets; 2372 2373 // packages/lazy-editor/build-module/hooks/use-editor-assets.js 2374 var import_core_data4 = __toESM(require_core_data()); 2375 var import_element3 = __toESM(require_element()); 2376 var import_data5 = __toESM(require_data()); 2377 var loadAssetsPromise; 2378 async function loadEditorAssets() { 2379 const load = async () => { 2380 const editorAssets = await unlock( 2381 (0, import_data5.resolveSelect)(import_core_data4.store) 2382 ).getEditorAssets(); 2383 await index_default( 2384 editorAssets.scripts || {}, 2385 editorAssets.inline_scripts || { before: {}, after: {} }, 2386 editorAssets.styles || {}, 2387 editorAssets.inline_styles || { before: {}, after: {} }, 2388 editorAssets.html_templates || [], 2389 editorAssets.script_modules || {} 2390 ); 2391 }; 2392 if (!loadAssetsPromise) { 2393 loadAssetsPromise = load(); 2394 } 2395 return loadAssetsPromise; 2396 } 2397 function useEditorAssets() { 2398 const editorAssets = (0, import_data5.useSelect)((select2) => { 2399 return unlock(select2(import_core_data4.store)).getEditorAssets(); 2400 }, []); 2401 const [assetsLoaded, setAssetsLoaded] = (0, import_element3.useState)(false); 2402 (0, import_element3.useEffect)(() => { 2403 if (editorAssets && !assetsLoaded) { 2404 loadEditorAssets().then(() => { 2405 setAssetsLoaded(true); 2406 }).catch((error) => { 2407 console.error("Failed to load editor assets:", error); 2408 }); 2409 } 2410 }, [editorAssets, assetsLoaded]); 2411 return { 2412 isReady: !!editorAssets && assetsLoaded, 2413 assetsLoaded 2414 }; 2415 } 2416 2417 // packages/lazy-editor/build-module/components/editor/index.js 2418 var import_jsx_runtime = __toESM(require_jsx_runtime()); 2419 var { Editor: PrivateEditor, BackButton } = unlock(import_editor.privateApis); 2420 function Editor({ 2421 postType, 2422 postId, 2423 settings, 2424 backButton 2425 }) { 2426 const homePage = (0, import_data6.useSelect)( 2427 (select2) => { 2428 if (postType || postId) { 2429 return null; 2430 } 2431 const { getHomePage } = unlock(select2(import_core_data5.store)); 2432 return getHomePage(); 2433 }, 2434 [postType, postId] 2435 ); 2436 const resolvedPostType = postType || homePage?.postType; 2437 const resolvedPostId = postId || homePage?.postId; 2438 const templateId = (0, import_data6.useSelect)( 2439 (select2) => { 2440 if (!resolvedPostType || !resolvedPostId) { 2441 return void 0; 2442 } 2443 if (resolvedPostType === "wp_template") { 2444 return resolvedPostId; 2445 } 2446 return unlock(select2(import_core_data5.store)).getTemplateId( 2447 resolvedPostType, 2448 resolvedPostId 2449 ); 2450 }, 2451 [resolvedPostType, resolvedPostId] 2452 ); 2453 const stylesId = useStylesId({ templateId }); 2454 const { isReady: settingsReady, editorSettings } = useEditorSettings({ 2455 stylesId 2456 }); 2457 const { isReady: assetsReady } = useEditorAssets(); 2458 const finalSettings = (0, import_element4.useMemo)( 2459 () => ({ 2460 ...editorSettings, 2461 ...settings 2462 }), 2463 [editorSettings, settings] 2464 ); 2465 if (!settingsReady || !assetsReady) { 2466 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( 2467 "div", 2468 { 2469 style: { 2470 display: "flex", 2471 justifyContent: "center", 2472 alignItems: "center", 2473 height: "100vh" 2474 }, 2475 children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) 2476 } 2477 ); 2478 } 2479 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( 2480 PrivateEditor, 2481 { 2482 postType: resolvedPostType, 2483 postId: resolvedPostId, 2484 templateId, 2485 settings: finalSettings, 2486 styles: finalSettings.styles, 2487 children: backButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BackButton, { children: backButton }) 2488 } 2489 ); 2490 } 2491 2492 // packages/lazy-editor/build-module/components/preview/index.js 2493 var import_i18n = __toESM(require_i18n()); 2494 var import_element5 = __toESM(require_element()); 2495 var import_block_editor = __toESM(require_block_editor()); 2496 var import_editor2 = __toESM(require_editor()); 2497 var import_blocks2 = __toESM(require_blocks()); 2498 var import_jsx_runtime2 = __toESM(require_jsx_runtime()); 2499 var css = `/** 2500 * SCSS Variables. 2501 * 2502 * Please use variables from this sheet to ensure consistency across the UI. 2503 * Don't add to this sheet unless you're pretty sure the value will be reused in many places. 2504 * For example, don't add rules to this sheet that affect block visuals. It's purely for UI. 2505 */ 2506 /** 2507 * Colors 2508 */ 2509 /** 2510 * Fonts & basic variables. 2511 */ 2512 /** 2513 * Typography 2514 */ 2515 /** 2516 * Grid System. 2517 * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/ 2518 */ 2519 /** 2520 * Radius scale. 2521 */ 2522 /** 2523 * Elevation scale. 2524 */ 2525 /** 2526 * Dimensions. 2527 */ 2528 /** 2529 * Mobile specific styles 2530 */ 2531 /** 2532 * Editor styles. 2533 */ 2534 /** 2535 * Block & Editor UI. 2536 */ 2537 /** 2538 * Block paddings. 2539 */ 2540 /** 2541 * React Native specific. 2542 * These variables do not appear to be used anywhere else. 2543 */ 2544 .lazy-editor-block-preview__container { 2545 display: flex; 2546 justify-content: center; 2547 align-items: center; 2548 flex-direction: column; 2549 height: 100%; 2550 border-radius: 4px; 2551 } 2552 .dataviews-view-grid .lazy-editor-block-preview__container .block-editor-block-preview__container { 2553 height: 100%; 2554 } 2555 .dataviews-view-table .lazy-editor-block-preview__container { 2556 width: 96px; 2557 flex-grow: 0; 2558 text-wrap: balance; 2559 text-wrap: pretty; 2560 } 2561 /*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VSb290IjoiL2hvbWUvc3ZuL2NoZWNrb3V0cy9kZXZlbG9wLnN2bi53b3JkcHJlc3Mub3JnL3RydW5rL2d1dGVuYmVyZy9wYWNrYWdlcy9sYXp5LWVkaXRvci9zcmMvY29tcG9uZW50cy9wcmV2aWV3Iiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9ub2RlX21vZHVsZXMvQHdvcmRwcmVzcy9iYXNlLXN0eWxlcy9fdmFyaWFibGVzLnNjc3MiLCIuLi8uLi8uLi8uLi8uLi9ub2RlX21vZHVsZXMvQHdvcmRwcmVzcy9iYXNlLXN0eWxlcy9fY29sb3JzLnNjc3MiLCJzdHlsZS5zY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FDQUE7QUFBQT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tcblx0XHR3aWR0aDogOTZweDtcblx0XHRmbGV4LWdyb3c6IDA7XG5cdFx0dGV4dC13cmFwOiBiYWxhbmNlOyAvLyBGYWxsYmFjayBmb3IgU2FmYXJpLlxuXHRcdHRleHQtd3JhcDogcHJldHR5O1xuXHR9XG59XG4iXX0= */`; 2562 document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css)); 2563 var { useStyle } = unlock(import_editor2.privateApis); 2564 function PreviewContent({ 2565 blocks, 2566 content, 2567 description 2568 }) { 2569 const descriptionId = (0, import_element5.useId)(); 2570 const backgroundColor = useStyle("color.background"); 2571 const actualBlocks = (0, import_element5.useMemo)(() => { 2572 return blocks ?? (0, import_blocks2.parse)(content, { 2573 __unstableSkipMigrationLogs: true 2574 }); 2575 }, [content, blocks]); 2576 const isEmpty = !actualBlocks?.length; 2577 return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( 2578 "div", 2579 { 2580 className: "lazy-editor-block-preview__container", 2581 style: { backgroundColor }, 2582 "aria-describedby": !!description ? descriptionId : void 0, 2583 children: [ 2584 isEmpty && (0, import_i18n.__)("Empty."), 2585 !isEmpty && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_block_editor.BlockPreview.Async, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_block_editor.BlockPreview, { blocks: actualBlocks }) }), 2586 !!description && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { hidden: true, id: descriptionId, children: description }) 2587 ] 2588 } 2589 ); 2590 } 2591 function Preview({ 2592 blocks, 2593 content, 2594 description 2595 }) { 2596 const stylesId = useStylesId(); 2597 const { isReady: settingsReady, editorSettings } = useEditorSettings({ 2598 stylesId 2599 }); 2600 const { isReady: assetsReady } = useEditorAssets(); 2601 const finalSettings = (0, import_element5.useMemo)( 2602 () => ({ 2603 ...editorSettings, 2604 isPreviewMode: true 2605 }), 2606 [editorSettings] 2607 ); 2608 if (!settingsReady || !assetsReady) { 2609 return null; 2610 } 2611 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_block_editor.BlockEditorProvider, { settings: finalSettings, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( 2612 PreviewContent, 2613 { 2614 blocks, 2615 content, 2616 description 2617 } 2618 ) }); 2619 } 2620 export { 2621 Editor, 2622 Preview, 2623 loadEditorAssets, 2624 useEditorAssets 2625 };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed Apr 15 08:20:10 2026 | Cross-referenced by PHPXref |