@wordpress/block-editor 13.0.5 → 13.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/autocompleters/block.js +1 -1
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-refs.js +9 -2
- package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +1 -1
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/global-styles/hooks.js +5 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +52 -8
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/layouts/constrained.js +6 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/store/private-selectors.js +6 -7
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +5 -28
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +36 -0
- package/build/store/utils.js.map +1 -1
- package/build-module/autocompleters/block.js +1 -1
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-refs.js +11 -4
- package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +1 -1
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +5 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +52 -8
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/store/private-selectors.js +7 -8
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +7 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +35 -0
- package/build-module/store/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/autocompleters/block.js +2 -1
- package/src/components/block-list/use-block-props/use-block-refs.js +19 -3
- package/src/components/block-toolbar/shuffle.js +2 -1
- package/src/components/global-styles/hooks.js +5 -1
- package/src/components/global-styles/test/use-global-styles-output.js +18 -8
- package/src/components/global-styles/use-global-styles-output.js +57 -8
- package/src/layouts/constrained.js +10 -2
- package/src/store/private-selectors.js +5 -5
- package/src/store/selectors.js +9 -40
- package/src/store/utils.js +38 -0
- package/src/utils/test/transform-styles.js +49 -0
|
@@ -58,7 +58,7 @@ function createBlockCompleter() {
|
|
|
58
58
|
prioritizedBlocks: getBlockListSettings(_rootClientId)?.prioritizedInserterBlocks
|
|
59
59
|
};
|
|
60
60
|
}, []);
|
|
61
|
-
const [items, categories, collections] = (0, _useBlockTypesState.default)(rootClientId, noop);
|
|
61
|
+
const [items, categories, collections] = (0, _useBlockTypesState.default)(rootClientId, noop, true);
|
|
62
62
|
const filteredItems = (0, _element.useMemo)(() => {
|
|
63
63
|
const initialFilteredItems = !!filterValue.trim() ? (0, _searchItems.searchBlockItems)(items, categories, collections, filterValue) : (0, _orderInserterBlockItems.orderInserterBlockItems)((0, _sorting.orderBy)(items, 'frecency', 'desc'), prioritizedBlocks);
|
|
64
64
|
return initialFilteredItems.filter(item => item.name !== selectedBlockName).slice(0, SHOWN_BLOCK_TYPES);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_blocks","_element","_searchItems","_useBlockTypesState","_interopRequireDefault","_blockIcon","_store","_sorting","_orderInserterBlockItems","_jsxRuntime","noop","SHOWN_BLOCK_TYPES","createBlockCompleter","name","className","triggerPrefix","useItems","filterValue","rootClientId","selectedBlockName","prioritizedBlocks","useSelect","select","getSelectedBlockClientId","getBlockName","getBlockListSettings","getBlockRootClientId","blockEditorStore","selectedBlockClientId","_rootClientId","prioritizedInserterBlocks","items","categories","collections","useBlockTypesState","filteredItems","useMemo","initialFilteredItems","trim","searchBlockItems","orderInserterBlockItems","orderBy","filter","item","slice","options","map","blockItem","title","icon","isDisabled","key","id","value","label","jsxs","Fragment","children","jsx","default","showColors","allowContext","before","after","test","getOptionCompletion","inserterItem","initialAttributes","innerBlocks","syncStatus","content","action","parse","__unstableSkipMigrationLogs","createBlock","createBlocksFromInnerBlocksTemplate","_default","exports"],"sources":["@wordpress/block-editor/src/autocompleters/block.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tparse,\n} from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { searchBlockItems } from '../components/inserter/search-items';\nimport useBlockTypesState from '../components/inserter/hooks/use-block-types-state';\nimport BlockIcon from '../components/block-icon';\nimport { store as blockEditorStore } from '../store';\nimport { orderBy } from '../utils/sorting';\nimport { orderInserterBlockItems } from '../utils/order-inserter-block-items';\n\nconst noop = () => {};\nconst SHOWN_BLOCK_TYPES = 9;\n\n/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nfunction createBlockCompleter() {\n\treturn {\n\t\tname: 'blocks',\n\t\tclassName: 'block-editor-autocompleters__block',\n\t\ttriggerPrefix: '/',\n\n\t\tuseItems( filterValue ) {\n\t\t\tconst { rootClientId, selectedBlockName, prioritizedBlocks } =\n\t\t\t\tuseSelect( ( select ) => {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t\t\tgetBlockName,\n\t\t\t\t\t\tgetBlockListSettings,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\t\t\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\t\t\tselectedBlockClientId\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tselectedBlockName: selectedBlockClientId\n\t\t\t\t\t\t\t? getBlockName( selectedBlockClientId )\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\trootClientId: _rootClientId,\n\t\t\t\t\t\tprioritizedBlocks:\n\t\t\t\t\t\t\tgetBlockListSettings( _rootClientId )\n\t\t\t\t\t\t\t\t?.prioritizedInserterBlocks,\n\t\t\t\t\t};\n\t\t\t\t}, [] );\n\t\t\tconst [ items, categories, collections ] = useBlockTypesState(\n\t\t\t\trootClientId,\n\t\t\t\tnoop\n\t\t\t);\n\n\t\t\tconst filteredItems = useMemo( () => {\n\t\t\t\tconst initialFilteredItems = !! filterValue.trim()\n\t\t\t\t\t? searchBlockItems(\n\t\t\t\t\t\t\titems,\n\t\t\t\t\t\t\tcategories,\n\t\t\t\t\t\t\tcollections,\n\t\t\t\t\t\t\tfilterValue\n\t\t\t\t\t )\n\t\t\t\t\t: orderInserterBlockItems(\n\t\t\t\t\t\t\torderBy( items, 'frecency', 'desc' ),\n\t\t\t\t\t\t\tprioritizedBlocks\n\t\t\t\t\t );\n\n\t\t\t\treturn initialFilteredItems\n\t\t\t\t\t.filter( ( item ) => item.name !== selectedBlockName )\n\t\t\t\t\t.slice( 0, SHOWN_BLOCK_TYPES );\n\t\t\t}, [\n\t\t\t\tfilterValue,\n\t\t\t\tselectedBlockName,\n\t\t\t\titems,\n\t\t\t\tcategories,\n\t\t\t\tcollections,\n\t\t\t\tprioritizedBlocks,\n\t\t\t] );\n\n\t\t\tconst options = useMemo(\n\t\t\t\t() =>\n\t\t\t\t\tfilteredItems.map( ( blockItem ) => {\n\t\t\t\t\t\tconst { title, icon, isDisabled } = blockItem;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tkey: `block-${ blockItem.id }`,\n\t\t\t\t\t\t\tvalue: blockItem,\n\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tisDisabled,\n\t\t\t\t\t\t};\n\t\t\t\t\t} ),\n\t\t\t\t[ filteredItems ]\n\t\t\t);\n\n\t\t\treturn [ options ];\n\t\t},\n\t\tallowContext( before, after ) {\n\t\t\treturn ! ( /\\S/.test( before ) || /\\S/.test( after ) );\n\t\t},\n\t\tgetOptionCompletion( inserterItem ) {\n\t\t\tconst {\n\t\t\t\tname,\n\t\t\t\tinitialAttributes,\n\t\t\t\tinnerBlocks,\n\t\t\t\tsyncStatus,\n\t\t\t\tcontent,\n\t\t\t} = inserterItem;\n\n\t\t\treturn {\n\t\t\t\taction: 'replace',\n\t\t\t\tvalue:\n\t\t\t\t\tsyncStatus === 'unsynced'\n\t\t\t\t\t\t? parse( content, {\n\t\t\t\t\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t\t\t\t } )\n\t\t\t\t\t\t: createBlock(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tinitialAttributes,\n\t\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\t\tinnerBlocks\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t ),\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nexport default createBlockCompleter();\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,UAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,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QACJsD,iBAAiB;QACjBC,WAAW;QACXC,UAAU;QACVC;MACD,CAAC,GAAGJ,YAAY;MAEhB,OAAO;QACNK,MAAM,EAAE,SAAS;QACjBlB,KAAK,EACJgB,UAAU,KAAK,UAAU,GACtB,IAAAG,aAAK,EAAEF,OAAO,EAAE;UAChBG,2BAA2B,EAAE;QAC7B,CAAE,CAAC,GACH,IAAAC,mBAAW,EACX7D,IAAI,EACJsD,iBAAiB,EACjB,IAAAQ,2CAAmC,EAClCP,WACD,CACA;MACL,CAAC;IACF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AAJA,IAAAQ,QAAA,GAAAC,OAAA,CAAAlB,OAAA,GAKe/C,oBAAoB,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_data","require","_blocks","_element","_searchItems","_useBlockTypesState","_interopRequireDefault","_blockIcon","_store","_sorting","_orderInserterBlockItems","_jsxRuntime","noop","SHOWN_BLOCK_TYPES","createBlockCompleter","name","className","triggerPrefix","useItems","filterValue","rootClientId","selectedBlockName","prioritizedBlocks","useSelect","select","getSelectedBlockClientId","getBlockName","getBlockListSettings","getBlockRootClientId","blockEditorStore","selectedBlockClientId","_rootClientId","prioritizedInserterBlocks","items","categories","collections","useBlockTypesState","filteredItems","useMemo","initialFilteredItems","trim","searchBlockItems","orderInserterBlockItems","orderBy","filter","item","slice","options","map","blockItem","title","icon","isDisabled","key","id","value","label","jsxs","Fragment","children","jsx","default","showColors","allowContext","before","after","test","getOptionCompletion","inserterItem","initialAttributes","innerBlocks","syncStatus","content","action","parse","__unstableSkipMigrationLogs","createBlock","createBlocksFromInnerBlocksTemplate","_default","exports"],"sources":["@wordpress/block-editor/src/autocompleters/block.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tparse,\n} from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { searchBlockItems } from '../components/inserter/search-items';\nimport useBlockTypesState from '../components/inserter/hooks/use-block-types-state';\nimport BlockIcon from '../components/block-icon';\nimport { store as blockEditorStore } from '../store';\nimport { orderBy } from '../utils/sorting';\nimport { orderInserterBlockItems } from '../utils/order-inserter-block-items';\n\nconst noop = () => {};\nconst SHOWN_BLOCK_TYPES = 9;\n\n/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nfunction createBlockCompleter() {\n\treturn {\n\t\tname: 'blocks',\n\t\tclassName: 'block-editor-autocompleters__block',\n\t\ttriggerPrefix: '/',\n\n\t\tuseItems( filterValue ) {\n\t\t\tconst { rootClientId, selectedBlockName, prioritizedBlocks } =\n\t\t\t\tuseSelect( ( select ) => {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t\t\tgetBlockName,\n\t\t\t\t\t\tgetBlockListSettings,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\t\t\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\t\t\tselectedBlockClientId\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tselectedBlockName: selectedBlockClientId\n\t\t\t\t\t\t\t? getBlockName( selectedBlockClientId )\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\trootClientId: _rootClientId,\n\t\t\t\t\t\tprioritizedBlocks:\n\t\t\t\t\t\t\tgetBlockListSettings( _rootClientId )\n\t\t\t\t\t\t\t\t?.prioritizedInserterBlocks,\n\t\t\t\t\t};\n\t\t\t\t}, [] );\n\t\t\tconst [ items, categories, collections ] = useBlockTypesState(\n\t\t\t\trootClientId,\n\t\t\t\tnoop,\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tconst filteredItems = useMemo( () => {\n\t\t\t\tconst initialFilteredItems = !! filterValue.trim()\n\t\t\t\t\t? searchBlockItems(\n\t\t\t\t\t\t\titems,\n\t\t\t\t\t\t\tcategories,\n\t\t\t\t\t\t\tcollections,\n\t\t\t\t\t\t\tfilterValue\n\t\t\t\t\t )\n\t\t\t\t\t: orderInserterBlockItems(\n\t\t\t\t\t\t\torderBy( items, 'frecency', 'desc' ),\n\t\t\t\t\t\t\tprioritizedBlocks\n\t\t\t\t\t );\n\n\t\t\t\treturn initialFilteredItems\n\t\t\t\t\t.filter( ( item ) => item.name !== selectedBlockName )\n\t\t\t\t\t.slice( 0, SHOWN_BLOCK_TYPES );\n\t\t\t}, [\n\t\t\t\tfilterValue,\n\t\t\t\tselectedBlockName,\n\t\t\t\titems,\n\t\t\t\tcategories,\n\t\t\t\tcollections,\n\t\t\t\tprioritizedBlocks,\n\t\t\t] );\n\n\t\t\tconst options = useMemo(\n\t\t\t\t() =>\n\t\t\t\t\tfilteredItems.map( ( blockItem ) => {\n\t\t\t\t\t\tconst { title, icon, isDisabled } = blockItem;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tkey: `block-${ blockItem.id }`,\n\t\t\t\t\t\t\tvalue: blockItem,\n\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tisDisabled,\n\t\t\t\t\t\t};\n\t\t\t\t\t} ),\n\t\t\t\t[ filteredItems ]\n\t\t\t);\n\n\t\t\treturn [ options ];\n\t\t},\n\t\tallowContext( before, after ) {\n\t\t\treturn ! ( /\\S/.test( before ) || /\\S/.test( after ) );\n\t\t},\n\t\tgetOptionCompletion( inserterItem ) {\n\t\t\tconst {\n\t\t\t\tname,\n\t\t\t\tinitialAttributes,\n\t\t\t\tinnerBlocks,\n\t\t\t\tsyncStatus,\n\t\t\t\tcontent,\n\t\t\t} = inserterItem;\n\n\t\t\treturn {\n\t\t\t\taction: 'replace',\n\t\t\t\tvalue:\n\t\t\t\t\tsyncStatus === 'unsynced'\n\t\t\t\t\t\t? parse( content, {\n\t\t\t\t\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t\t\t\t } )\n\t\t\t\t\t\t: createBlock(\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tinitialAttributes,\n\t\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\t\tinnerBlocks\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t ),\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nexport default createBlockCompleter();\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,UAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,wBAAA,GAAAT,OAAA;AAA8E,IAAAU,WAAA,GAAAV,OAAA;AAnB9E;AACA;AACA;;AASA;AACA;AACA;;AAQA,MAAMW,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,iBAAiB,GAAG,CAAC;;AAE3B;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAA,EAAG;EAC/B,OAAO;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ACA;MACL,CAAC;IACF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AAJA,IAAAQ,QAAA,GAAAC,OAAA,CAAAlB,OAAA,GAKe/C,oBAAoB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -73,10 +73,17 @@ function useBlockRef(clientId) {
|
|
|
73
73
|
* @return {Element|null} The block's wrapper element.
|
|
74
74
|
*/
|
|
75
75
|
function useBlockElement(clientId) {
|
|
76
|
-
var _useObservableValue;
|
|
77
76
|
const {
|
|
78
77
|
refsMap
|
|
79
78
|
} = (0, _element.useContext)(_blockRefsProvider.BlockRefs);
|
|
80
|
-
|
|
79
|
+
const [blockElement, setBlockElement] = (0, _element.useState)(null);
|
|
80
|
+
// Delay setting the resulting `blockElement` until an effect. If the block element
|
|
81
|
+
// changes (i.e., the block is unmounted and re-mounted), this allows enough time
|
|
82
|
+
// for the ref callbacks to clean up the old element and set the new one.
|
|
83
|
+
(0, _element.useLayoutEffect)(() => {
|
|
84
|
+
setBlockElement(refsMap.get(clientId));
|
|
85
|
+
return refsMap.subscribe(clientId, () => setBlockElement(refsMap.get(clientId)));
|
|
86
|
+
}, [refsMap, clientId]);
|
|
87
|
+
return blockElement;
|
|
81
88
|
}
|
|
82
89
|
//# sourceMappingURL=use-block-refs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","_blockRefsProvider","useBlockRefProvider","clientId","refsMap","useContext","BlockRefs","useRefEffect","element","set","delete","useBlockRef","latestClientId","useRef","current","useMemo","_refsMap$get","get","useBlockElement","
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_blockRefsProvider","useBlockRefProvider","clientId","refsMap","useContext","BlockRefs","useRefEffect","element","set","delete","useBlockRef","latestClientId","useRef","current","useMemo","_refsMap$get","get","useBlockElement","blockElement","setBlockElement","useState","useLayoutEffect","subscribe"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-block-refs.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseContext,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { BlockRefs } from '../../provider/block-refs-provider';\n\n/** @typedef {import('@wordpress/element').RefCallback} RefCallback */\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * Provides a ref to the BlockRefs context.\n *\n * @param {string} clientId The client ID of the element ref.\n *\n * @return {RefCallback} Ref callback.\n */\nexport function useBlockRefProvider( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\trefsMap.set( clientId, element );\n\t\t\treturn () => refsMap.delete( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n\n/**\n * Gets a ref pointing to the current block element. Continues to return the same\n * stable ref object even if the `clientId` argument changes. This hook is not\n * reactive, i.e., it won't trigger a rerender of the calling component if the\n * ref value changes. For reactive use cases there is the `useBlockElement` hook.\n *\n * @param {string} clientId The client ID to get a ref for.\n *\n * @return {RefObject} A ref containing the element.\n */\nfunction useBlockRef( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\tconst latestClientId = useRef();\n\tlatestClientId.current = clientId;\n\n\t// Always return an object, even if no ref exists for a given client ID, so\n\t// that `current` works at a later point.\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tget current() {\n\t\t\t\treturn refsMap.get( latestClientId.current ) ?? null;\n\t\t\t},\n\t\t} ),\n\t\t[ refsMap ]\n\t);\n}\n\n/**\n * Return the element for a given client ID. Updates whenever the element\n * changes, becomes available, or disappears.\n *\n * @param {string} clientId The client ID to an element for.\n *\n * @return {Element|null} The block's wrapper element.\n */\nfunction useBlockElement( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\tconst [ blockElement, setBlockElement ] = useState( null );\n\t// Delay setting the resulting `blockElement` until an effect. If the block element\n\t// changes (i.e., the block is unmounted and re-mounted), this allows enough time\n\t// for the ref callbacks to clean up the old element and set the new one.\n\tuseLayoutEffect( () => {\n\t\tsetBlockElement( refsMap.get( clientId ) );\n\t\treturn refsMap.subscribe( clientId, () =>\n\t\t\tsetBlockElement( refsMap.get( clientId ) )\n\t\t);\n\t}, [ refsMap, clientId ] );\n\treturn blockElement;\n}\n\nexport { useBlockRef as __unstableUseBlockRef };\nexport { useBlockElement as __unstableUseBlockElement };\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAOA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,kBAAA,GAAAF,OAAA;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,mBAAmBA,CAAEC,QAAQ,EAAG;EAC/C,MAAM;IAAEC;EAAQ,CAAC,GAAG,IAAAC,mBAAU,EAAEC,4BAAU,CAAC;EAC3C,OAAO,IAAAC,qBAAY,EAChBC,OAAO,IAAM;IACdJ,OAAO,CAACK,GAAG,CAAEN,QAAQ,EAAEK,OAAQ,CAAC;IAChC,OAAO,MAAMJ,OAAO,CAACM,MAAM,CAAEP,QAAS,CAAC;EACxC,CAAC,EACD,CAAEA,QAAQ,CACX,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASQ,WAAWA,CAAER,QAAQ,EAAG;EAChC,MAAM;IAAEC;EAAQ,CAAC,GAAG,IAAAC,mBAAU,EAAEC,4BAAU,CAAC;EAC3C,MAAMM,cAAc,GAAG,IAAAC,eAAM,EAAC,CAAC;EAC/BD,cAAc,CAACE,OAAO,GAAGX,QAAQ;;EAEjC;EACA;EACA,OAAO,IAAAY,gBAAO,EACb,OAAQ;IACP,IAAID,OAAOA,CAAA,EAAG;MAAA,IAAAE,YAAA;MACb,QAAAA,YAAA,GAAOZ,OAAO,CAACa,GAAG,CAAEL,cAAc,CAACE,OAAQ,CAAC,cAAAE,YAAA,cAAAA,YAAA,GAAI,IAAI;IACrD;EACD,CAAC,CAAE,EACH,CAAEZ,OAAO,CACV,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASc,eAAeA,CAAEf,QAAQ,EAAG;EACpC,MAAM;IAAEC;EAAQ,CAAC,GAAG,IAAAC,mBAAU,EAAEC,4BAAU,CAAC;EAC3C,MAAM,CAAEa,YAAY,EAAEC,eAAe,CAAE,GAAG,IAAAC,iBAAQ,EAAE,IAAK,CAAC;EAC1D;EACA;EACA;EACA,IAAAC,wBAAe,EAAE,MAAM;IACtBF,eAAe,CAAEhB,OAAO,CAACa,GAAG,CAAEd,QAAS,CAAE,CAAC;IAC1C,OAAOC,OAAO,CAACmB,SAAS,CAAEpB,QAAQ,EAAE,MACnCiB,eAAe,CAAEhB,OAAO,CAACa,GAAG,CAAEd,QAAS,CAAE,CAC1C,CAAC;EACF,CAAC,EAAE,CAAEC,OAAO,EAAED,QAAQ,CAAG,CAAC;EAC1B,OAAOgB,YAAY;AACpB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_icons","require","_components","_i18n","_element","_data","_store","_jsxRuntime","EMPTY_ARRAY","Container","props","jsx","ToolbarGroup","children","ToolbarButton","Shuffle","clientId","as","categories","patterns","patternName","useSelect","select","getBlockAttributes","getBlockRootClientId","__experimentalGetAllowedPatterns","blockEditorStore","attributes","_categories","metadata","_patternName","rootBlock","_patterns","replaceBlocks","useDispatch","sameCategoryPatternsWithSingleWrapper","useMemo","length","filter","pattern","blocks","some","category","includes","syncStatus","id","getNextPattern","numberOfPatterns","patternIndex","findIndex","name","nextPatternIndex","ComponentToUse","label","__","icon","shuffle","onClick","nextPattern"],"sources":["@wordpress/block-editor/src/components/block-toolbar/shuffle.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { shuffle } from '@wordpress/icons';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nfunction Container( props ) {\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton { ...props } />\n\t\t</ToolbarGroup>\n\t);\n}\n\nexport default function Shuffle( { clientId, as = Container } ) {\n\tconst { categories, patterns, patternName } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetAllowedPatterns,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst _categories = attributes?.metadata?.categories || EMPTY_ARRAY;\n\t\t\tconst _patternName = attributes?.metadata?.patternName;\n\t\t\tconst rootBlock = getBlockRootClientId( clientId );\n\t\t\tconst _patterns = __experimentalGetAllowedPatterns( rootBlock );\n\t\t\treturn {\n\t\t\t\tcategories: _categories,\n\t\t\t\tpatterns: _patterns,\n\t\t\t\tpatternName: _patternName,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst sameCategoryPatternsWithSingleWrapper = useMemo( () => {\n\t\tif (\n\t\t\t! categories ||\n\t\t\tcategories.length === 0 ||\n\t\t\t! patterns ||\n\t\t\tpatterns.length === 0\n\t\t) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn patterns.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t// Check if the pattern has only one top level block,\n\t\t\t\t// otherwise we may shuffle to pattern that will not allow to continue shuffling.\n\t\t\t\tpattern.blocks.length === 1 &&\n\t\t\t\tpattern.categories?.some( ( category ) => {\n\t\t\t\t\treturn categories.includes( category );\n\t\t\t\t} ) &&\n\t\t\t\t// Check if the pattern is not a synced pattern.\n\t\t\t\t( pattern.syncStatus === 'unsynced' || ! pattern.id )\n\t\t\t);\n\t\t} );\n\t}, [ categories, patterns ] );\n\tif ( sameCategoryPatternsWithSingleWrapper.length
|
|
1
|
+
{"version":3,"names":["_icons","require","_components","_i18n","_element","_data","_store","_jsxRuntime","EMPTY_ARRAY","Container","props","jsx","ToolbarGroup","children","ToolbarButton","Shuffle","clientId","as","categories","patterns","patternName","useSelect","select","getBlockAttributes","getBlockRootClientId","__experimentalGetAllowedPatterns","blockEditorStore","attributes","_categories","metadata","_patternName","rootBlock","_patterns","replaceBlocks","useDispatch","sameCategoryPatternsWithSingleWrapper","useMemo","length","filter","pattern","blocks","some","category","includes","syncStatus","id","getNextPattern","numberOfPatterns","patternIndex","findIndex","name","nextPatternIndex","ComponentToUse","label","__","icon","shuffle","onClick","nextPattern"],"sources":["@wordpress/block-editor/src/components/block-toolbar/shuffle.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { shuffle } from '@wordpress/icons';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nfunction Container( props ) {\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton { ...props } />\n\t\t</ToolbarGroup>\n\t);\n}\n\nexport default function Shuffle( { clientId, as = Container } ) {\n\tconst { categories, patterns, patternName } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetAllowedPatterns,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst _categories = attributes?.metadata?.categories || EMPTY_ARRAY;\n\t\t\tconst _patternName = attributes?.metadata?.patternName;\n\t\t\tconst rootBlock = getBlockRootClientId( clientId );\n\t\t\tconst _patterns = __experimentalGetAllowedPatterns( rootBlock );\n\t\t\treturn {\n\t\t\t\tcategories: _categories,\n\t\t\t\tpatterns: _patterns,\n\t\t\t\tpatternName: _patternName,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst sameCategoryPatternsWithSingleWrapper = useMemo( () => {\n\t\tif (\n\t\t\t! categories ||\n\t\t\tcategories.length === 0 ||\n\t\t\t! patterns ||\n\t\t\tpatterns.length === 0\n\t\t) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn patterns.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t// Check if the pattern has only one top level block,\n\t\t\t\t// otherwise we may shuffle to pattern that will not allow to continue shuffling.\n\t\t\t\tpattern.blocks.length === 1 &&\n\t\t\t\tpattern.categories?.some( ( category ) => {\n\t\t\t\t\treturn categories.includes( category );\n\t\t\t\t} ) &&\n\t\t\t\t// Check if the pattern is not a synced pattern.\n\t\t\t\t( pattern.syncStatus === 'unsynced' || ! pattern.id )\n\t\t\t);\n\t\t} );\n\t}, [ categories, patterns ] );\n\n\tif ( sameCategoryPatternsWithSingleWrapper.length < 2 ) {\n\t\treturn null;\n\t}\n\n\tfunction getNextPattern() {\n\t\tconst numberOfPatterns = sameCategoryPatternsWithSingleWrapper.length;\n\t\tconst patternIndex = sameCategoryPatternsWithSingleWrapper.findIndex(\n\t\t\t( { name } ) => name === patternName\n\t\t);\n\t\tconst nextPatternIndex =\n\t\t\tpatternIndex + 1 < numberOfPatterns ? patternIndex + 1 : 0;\n\t\treturn sameCategoryPatternsWithSingleWrapper[ nextPatternIndex ];\n\t}\n\n\tconst ComponentToUse = as;\n\treturn (\n\t\t<ComponentToUse\n\t\t\tlabel={ __( 'Shuffle' ) }\n\t\t\ticon={ shuffle }\n\t\t\tonClick={ () => {\n\t\t\t\tconst nextPattern = getNextPattern();\n\t\t\t\tnextPattern.blocks[ 0 ].attributes = {\n\t\t\t\t\t...nextPattern.blocks[ 0 ].attributes,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...nextPattern.blocks[ 0 ].attributes.metadata,\n\t\t\t\t\t\tcategories,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treplaceBlocks( clientId, nextPattern.blocks );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAAwD,IAAAM,WAAA,GAAAN,OAAA;AAZxD;AACA;AACA;;AAOA;AACA;AACA;;AAGA,MAAMO,WAAW,GAAG,EAAE;AAEtB,SAASC,SAASA,CAAEC,KAAK,EAAG;EAC3B,oBACC,IAAAH,WAAA,CAAAI,GAAA,EAACT,WAAA,CAAAU,YAAY;IAAAC,QAAA,eACZ,IAAAN,WAAA,CAAAI,GAAA,EAACT,WAAA,CAAAY,aAAa;MAAA,GAAMJ;IAAK,CAAI;EAAC,CACjB,CAAC;AAEjB;AAEe,SAASK,OAAOA,CAAE;EAAEC,QAAQ;EAAEC,EAAE,GAAGR;AAAU,CAAC,EAAG;EAC/D,MAAM;IAAES,UAAU;IAAEC,QAAQ;IAAEC;EAAY,CAAC,GAAG,IAAAC,eAAS,EACpDC,MAAM,IAAM;IACb,MAAM;MACLC,kBAAkB;MAClBC,oBAAoB;MACpBC;IACD,CAAC,GAAGH,MAAM,CAAEI,YAAiB,CAAC;IAC9B,MAAMC,UAAU,GAAGJ,kBAAkB,CAAEP,QAAS,CAAC;IACjD,MAAMY,WAAW,GAAGD,UAAU,EAAEE,QAAQ,EAAEX,UAAU,IAAIV,WAAW;IACnE,MAAMsB,YAAY,GAAGH,UAAU,EAAEE,QAAQ,EAAET,WAAW;IACtD,MAA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AG,CAAC,GAAGD,gBAAgB,GAAGC,YAAY,GAAG,CAAC,GAAG,CAAC;IAC3D,OAAOb,qCAAqC,CAAEgB,gBAAgB,CAAE;EACjE;EAEA,MAAMC,cAAc,GAAGnC,EAAE;EACzB,oBACC,IAAAV,WAAA,CAAAI,GAAA,EAACyC,cAAc;IACdC,KAAK,EAAG,IAAAC,QAAE,EAAE,SAAU,CAAG;IACzBC,IAAI,EAAGC,cAAS;IAChBC,OAAO,EAAGA,CAAA,KAAM;MACf,MAAMC,WAAW,GAAGZ,cAAc,CAAC,CAAC;MACpCY,WAAW,CAAClB,MAAM,CAAE,CAAC,CAAE,CAACb,UAAU,GAAG;QACpC,GAAG+B,WAAW,CAAClB,MAAM,CAAE,CAAC,CAAE,CAACb,UAAU;QACrCE,QAAQ,EAAE;UACT,GAAG6B,WAAW,CAAClB,MAAM,CAAE,CAAC,CAAE,CAACb,UAAU,CAACE,QAAQ;UAC9CX;QACD;MACD,CAAC;MACDe,aAAa,CAAEjB,QAAQ,EAAE0C,WAAW,CAAClB,MAAO,CAAC;IAC9C;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -39,9 +39,13 @@ const EMPTY_CONFIG = {
|
|
|
39
39
|
const VALID_SETTINGS = ['appearanceTools', 'useRootPaddingAwareAlignments', 'background.backgroundImage', 'background.backgroundRepeat', 'background.backgroundSize', 'background.backgroundPosition', 'border.color', 'border.radius', 'border.style', 'border.width', 'shadow.presets', 'shadow.defaultPresets', 'color.background', 'color.button', 'color.caption', 'color.custom', 'color.customDuotone', 'color.customGradient', 'color.defaultDuotone', 'color.defaultGradients', 'color.defaultPalette', 'color.duotone', 'color.gradients', 'color.heading', 'color.link', 'color.palette', 'color.text', 'custom', 'dimensions.aspectRatio', 'dimensions.minHeight', 'layout.contentSize', 'layout.definitions', 'layout.wideSize', 'lightbox.enabled', 'lightbox.allowEditing', 'position.fixed', 'position.sticky', 'spacing.customSpacingSize', 'spacing.defaultSpacingSizes', 'spacing.spacingSizes', 'spacing.spacingScale', 'spacing.blockGap', 'spacing.margin', 'spacing.padding', 'spacing.units', 'typography.fluid', 'typography.customFontSize', 'typography.defaultFontSizes', 'typography.dropCap', 'typography.fontFamilies', 'typography.fontSizes', 'typography.fontStyle', 'typography.fontWeight', 'typography.letterSpacing', 'typography.lineHeight', 'typography.textAlign', 'typography.textColumns', 'typography.textDecoration', 'typography.textTransform', 'typography.writingMode'];
|
|
40
40
|
const useGlobalStylesReset = () => {
|
|
41
41
|
const {
|
|
42
|
-
user
|
|
42
|
+
user,
|
|
43
43
|
setUserConfig
|
|
44
44
|
} = (0, _element.useContext)(_context.GlobalStylesContext);
|
|
45
|
+
const config = {
|
|
46
|
+
settings: user.settings,
|
|
47
|
+
styles: user.styles
|
|
48
|
+
};
|
|
45
49
|
const canReset = !!config && !(0, _es.default)(config, EMPTY_CONFIG);
|
|
46
50
|
return [canReset, (0, _element.useCallback)(() => setUserConfig(EMPTY_CONFIG), [setUserConfig])];
|
|
47
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_es","_interopRequireDefault","require","_element","_data","_blocks","_i18n","_utils","_object","_context","_lockUnlock","EMPTY_CONFIG","settings","styles","VALID_SETTINGS","useGlobalStylesReset","user","config","setUserConfig","useContext","GlobalStylesContext","canReset","fastDeepEqual","useCallback","exports","useGlobalSetting","propertyPath","blockName","source","configs","appendedBlockPath","appendedPropertyPath","contextualPath","globalPath","sourceKey","settingValue","useMemo","configToUse","_getValueFromObjectPa","getValueFromObjectPath","result","forEach","setting","_getValueFromObjectPa2","value","undefined","setImmutably","split","setSetting","newValue","currentConfig","useGlobalStyle","path","shouldDecodeEncode","merged","mergedConfig","base","baseConfig","userConfig","appendedPath","finalPath","setStyle","getPresetVariableFromValue","rawResult","getValueFromVariable","useGlobalStyleLinks","_links","useSettingsForBlockElement","parentSettings","element","supportedStyles","supports","useSelect","select","unlock","blocksStore","getSupportedStyles","getBlockType","updatedSettings","includes","typography","fontSizes","customFontSize","defaultFontSizes","fontFamilies","color","text","background","button","heading","link","caption","gradients","customGradient","defaultDuotone","customDuotone","key","textColumns","layout","spacing","sides","Array","isArray","length","dimensions","charAt","toUpperCase","slice","border","shadow","textAlign","useColorsPerOrigin","customColors","palette","custom","themeColors","theme","defaultColors","default","shouldDisplayDefaultColors","defaultPalette","push","name","_x","colors","useGradientsPerOrigin","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients"],"sources":["@wordpress/block-editor/src/components/global-styles/hooks.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { getValueFromObjectPath, setImmutably } from '../../utils/object';\nimport { GlobalStylesContext } from './context';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'background.backgroundImage',\n\t'background.backgroundRepeat',\n\t'background.backgroundSize',\n\t'background.backgroundPosition',\n\t'border.color',\n\t'border.radius',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.button',\n\t'color.caption',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.heading',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.aspectRatio',\n\t'dimensions.minHeight',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'lightbox.enabled',\n\t'lightbox.allowEditing',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.defaultSpacingSizes',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.defaultFontSizes',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textAlign',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textTransform',\n\t'typography.writingMode',\n];\n\nexport const useGlobalStylesReset = () => {\n\tconst { user: config, setUserConfig } = useContext( GlobalStylesContext );\n\tconst canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback( () => setUserConfig( EMPTY_CONFIG ), [ setUserConfig ] ),\n\t];\n};\n\nexport function useGlobalSetting( propertyPath, blockName, source = 'all' ) {\n\tconst { setUserConfig, ...configs } = useContext( GlobalStylesContext );\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = propertyPath ? '.' + propertyPath : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\tconst sourceKey = source === 'all' ? 'merged' : source;\n\n\tconst settingValue = useMemo( () => {\n\t\tconst configToUse = configs[ sourceKey ];\n\t\tif ( ! configToUse ) {\n\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\tif ( propertyPath ) {\n\t\t\treturn (\n\t\t\t\tgetValueFromObjectPath( configToUse, contextualPath ) ??\n\t\t\t\tgetValueFromObjectPath( configToUse, globalPath )\n\t\t\t);\n\t\t}\n\n\t\tlet result = {};\n\t\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\t\tconst value =\n\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\tconfigToUse,\n\t\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t\t) ??\n\t\t\t\tgetValueFromObjectPath( configToUse, `settings.${ setting }` );\n\t\t\tif ( value !== undefined ) {\n\t\t\t\tresult = setImmutably( result, setting.split( '.' ), value );\n\t\t\t}\n\t\t} );\n\t\treturn result;\n\t}, [\n\t\tconfigs,\n\t\tsourceKey,\n\t\tpropertyPath,\n\t\tcontextualPath,\n\t\tglobalPath,\n\t\tappendedBlockPath,\n\t] );\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) =>\n\t\t\tsetImmutably( currentConfig, contextualPath.split( '.' ), newValue )\n\t\t);\n\t};\n\treturn [ settingValue, setSetting ];\n}\n\nexport function useGlobalStyle(\n\tpath,\n\tblockName,\n\tsource = 'all',\n\t{ shouldDecodeEncode = true } = {}\n) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst appendedPath = path ? '.' + path : '';\n\tconst finalPath = ! blockName\n\t\t? `styles${ appendedPath }`\n\t\t: `styles.blocks.${ blockName }${ appendedPath }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) =>\n\t\t\tsetImmutably(\n\t\t\t\tcurrentConfig,\n\t\t\t\tfinalPath.split( '.' ),\n\t\t\t\tshouldDecodeEncode\n\t\t\t\t\t? getPresetVariableFromValue(\n\t\t\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tnewValue\n\t\t\t\t\t )\n\t\t\t\t\t: newValue\n\t\t\t)\n\t\t);\n\t};\n\n\tlet rawResult, result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\trawResult = getValueFromObjectPath( mergedConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\trawResult = getValueFromObjectPath( userConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\trawResult = getValueFromObjectPath( baseConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( baseConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\nexport function useGlobalStyleLinks() {\n\tconst { merged: mergedConfig } = useContext( GlobalStylesContext );\n\treturn mergedConfig?._links;\n}\n\n/**\n * React hook that overrides a global settings object with block and element specific settings.\n *\n * @param {Object} parentSettings Settings object.\n * @param {blockName?} blockName Block name.\n * @param {element?} element Element name.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function useSettingsForBlockElement(\n\tparentSettings,\n\tblockName,\n\telement\n) {\n\tconst { supportedStyles, supports } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedStyles: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( blockName, element ),\n\t\t\t\tsupports:\n\t\t\t\t\tselect( blocksStore ).getBlockType( blockName )?.supports,\n\t\t\t};\n\t\t},\n\t\t[ blockName, element ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst updatedSettings = { ...parentSettings };\n\n\t\tif ( ! supportedStyles.includes( 'fontSize' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontSizes: {},\n\t\t\t\tcustomFontSize: false,\n\t\t\t\tdefaultFontSizes: false,\n\t\t\t};\n\t\t}\n\n\t\tif ( ! supportedStyles.includes( 'fontFamily' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontFamilies: {},\n\t\t\t};\n\t\t}\n\n\t\tupdatedSettings.color = {\n\t\t\t...updatedSettings.color,\n\t\t\ttext:\n\t\t\t\tupdatedSettings.color?.text &&\n\t\t\t\tsupportedStyles.includes( 'color' ),\n\t\t\tbackground:\n\t\t\t\tupdatedSettings.color?.background &&\n\t\t\t\t( supportedStyles.includes( 'background' ) ||\n\t\t\t\t\tsupportedStyles.includes( 'backgroundColor' ) ),\n\t\t\tbutton:\n\t\t\t\tupdatedSettings.color?.button &&\n\t\t\t\tsupportedStyles.includes( 'buttonColor' ),\n\t\t\theading:\n\t\t\t\tupdatedSettings.color?.heading &&\n\t\t\t\tsupportedStyles.includes( 'headingColor' ),\n\t\t\tlink:\n\t\t\t\tupdatedSettings.color?.link &&\n\t\t\t\tsupportedStyles.includes( 'linkColor' ),\n\t\t\tcaption:\n\t\t\t\tupdatedSettings.color?.caption &&\n\t\t\t\tsupportedStyles.includes( 'captionColor' ),\n\t\t};\n\n\t\t// Some blocks can enable background colors but disable gradients.\n\t\tif ( ! supportedStyles.includes( 'background' ) ) {\n\t\t\tupdatedSettings.color.gradients = [];\n\t\t\tupdatedSettings.color.customGradient = false;\n\t\t}\n\n\t\t// If filters are not supported by the block/element, disable duotone.\n\t\tif ( ! supportedStyles.includes( 'filter' ) ) {\n\t\t\tupdatedSettings.color.defaultDuotone = false;\n\t\t\tupdatedSettings.color.customDuotone = false;\n\t\t}\n\n\t\t[\n\t\t\t'lineHeight',\n\t\t\t'fontStyle',\n\t\t\t'fontWeight',\n\t\t\t'letterSpacing',\n\t\t\t'textAlign',\n\t\t\t'textTransform',\n\t\t\t'textDecoration',\n\t\t\t'writingMode',\n\t\t].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.typography = {\n\t\t\t\t\t...updatedSettings.typography,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// The column-count style is named text column to reduce confusion with\n\t\t// the columns block and manage expectations from the support.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/33587\n\t\tif ( ! supportedStyles.includes( 'columnCount' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextColumns: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'contentSize', 'wideSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.layout = {\n\t\t\t\t\t...updatedSettings.layout,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst sides = Array.isArray( supports?.spacing?.[ key ] )\n\t\t\t\t? supports?.spacing?.[ key ]\n\t\t\t\t: supports?.spacing?.[ key ]?.sides;\n\t\t\t// Check if spacing type is supported before adding sides.\n\t\t\tif ( sides?.length && updatedSettings.spacing?.[ key ] ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: {\n\t\t\t\t\t\t...updatedSettings.spacing?.[ key ],\n\t\t\t\t\t\tsides,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'aspectRatio', 'minHeight' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.dimensions = {\n\t\t\t\t\t...updatedSettings.dimensions,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {\n\t\t\tif (\n\t\t\t\t! supportedStyles.includes(\n\t\t\t\t\t'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedSettings.border = {\n\t\t\t\t\t...updatedSettings.border,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tupdatedSettings.shadow = supportedStyles.includes( 'shadow' )\n\t\t\t? updatedSettings.shadow\n\t\t\t: false;\n\n\t\t// Text alignment is only available for blocks.\n\t\tif ( element ) {\n\t\t\tupdatedSettings.typography.textAlign = false;\n\t\t}\n\n\t\treturn updatedSettings;\n\t}, [ parentSettings, supportedStyles, supports, element ] );\n}\n\nexport function useColorsPerOrigin( settings ) {\n\tconst customColors = settings?.color?.palette?.custom;\n\tconst themeColors = settings?.color?.palette?.theme;\n\tconst defaultColors = settings?.color?.palette?.default;\n\tconst shouldDisplayDefaultColors = settings?.color?.defaultPalette;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n}\n\nexport function useGradientsPerOrigin( settings ) {\n\tconst customGradients = settings?.color?.gradients?.custom;\n\tconst themeGradients = settings?.color?.gradients?.theme;\n\tconst defaultGradients = settings?.color?.gradients?.default;\n\tconst shouldDisplayDefaultGradients = settings?.color?.defaultGradients;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,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EACP,8CACD,CAAC;QACD/B,SAAS,EAAEmC;MACZ,CAAE,CAAC;IACJ;IACA,IACCE,6BAA6B,IAC7BD,gBAAgB,IAChBA,gBAAgB,CAACzB,MAAM,EACtB;MACD/D,MAAM,CAACiF,IAAI,CAAE;QACZC,IAAI,EAAE,IAAAC,QAAE,EACP,SAAS,EACT,8CACD,CAAC;QACD/B,SAAS,EAAEoC;MACZ,CAAE,CAAC;IACJ;IACA,IAAKF,eAAe,IAAIA,eAAe,CAACvB,MAAM,EAAG;MAChD/D,MAAM,CAACiF,IAAI,CAAE;QACZC,IAAI,EAAE,IAAAC,QAAE,EACP,QAAQ,EACR,gDACD,CAAC;QACD/B,SAAS,EAAEkC;MACZ,CAAE,CAAC;IACJ;IACA,OAAOtF,MAAM;EACd,CAAC,EAAE,CACFsF,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,6BAA6B,CAC5B,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_es","_interopRequireDefault","require","_element","_data","_blocks","_i18n","_utils","_object","_context","_lockUnlock","EMPTY_CONFIG","settings","styles","VALID_SETTINGS","useGlobalStylesReset","user","setUserConfig","useContext","GlobalStylesContext","config","canReset","fastDeepEqual","useCallback","exports","useGlobalSetting","propertyPath","blockName","source","configs","appendedBlockPath","appendedPropertyPath","contextualPath","globalPath","sourceKey","settingValue","useMemo","configToUse","_getValueFromObjectPa","getValueFromObjectPath","result","forEach","setting","_getValueFromObjectPa2","value","undefined","setImmutably","split","setSetting","newValue","currentConfig","useGlobalStyle","path","shouldDecodeEncode","merged","mergedConfig","base","baseConfig","userConfig","appendedPath","finalPath","setStyle","getPresetVariableFromValue","rawResult","getValueFromVariable","useGlobalStyleLinks","_links","useSettingsForBlockElement","parentSettings","element","supportedStyles","supports","useSelect","select","unlock","blocksStore","getSupportedStyles","getBlockType","updatedSettings","includes","typography","fontSizes","customFontSize","defaultFontSizes","fontFamilies","color","text","background","button","heading","link","caption","gradients","customGradient","defaultDuotone","customDuotone","key","textColumns","layout","spacing","sides","Array","isArray","length","dimensions","charAt","toUpperCase","slice","border","shadow","textAlign","useColorsPerOrigin","customColors","palette","custom","themeColors","theme","defaultColors","default","shouldDisplayDefaultColors","defaultPalette","push","name","_x","colors","useGradientsPerOrigin","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients"],"sources":["@wordpress/block-editor/src/components/global-styles/hooks.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { getValueFromObjectPath, setImmutably } from '../../utils/object';\nimport { GlobalStylesContext } from './context';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'background.backgroundImage',\n\t'background.backgroundRepeat',\n\t'background.backgroundSize',\n\t'background.backgroundPosition',\n\t'border.color',\n\t'border.radius',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.button',\n\t'color.caption',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.heading',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.aspectRatio',\n\t'dimensions.minHeight',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'lightbox.enabled',\n\t'lightbox.allowEditing',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.defaultSpacingSizes',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.defaultFontSizes',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textAlign',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textTransform',\n\t'typography.writingMode',\n];\n\nexport const useGlobalStylesReset = () => {\n\tconst { user, setUserConfig } = useContext( GlobalStylesContext );\n\tconst config = {\n\t\tsettings: user.settings,\n\t\tstyles: user.styles,\n\t};\n\tconst canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback( () => setUserConfig( EMPTY_CONFIG ), [ setUserConfig ] ),\n\t];\n};\n\nexport function useGlobalSetting( propertyPath, blockName, source = 'all' ) {\n\tconst { setUserConfig, ...configs } = useContext( GlobalStylesContext );\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = propertyPath ? '.' + propertyPath : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\tconst sourceKey = source === 'all' ? 'merged' : source;\n\n\tconst settingValue = useMemo( () => {\n\t\tconst configToUse = configs[ sourceKey ];\n\t\tif ( ! configToUse ) {\n\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\tif ( propertyPath ) {\n\t\t\treturn (\n\t\t\t\tgetValueFromObjectPath( configToUse, contextualPath ) ??\n\t\t\t\tgetValueFromObjectPath( configToUse, globalPath )\n\t\t\t);\n\t\t}\n\n\t\tlet result = {};\n\t\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\t\tconst value =\n\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\tconfigToUse,\n\t\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t\t) ??\n\t\t\t\tgetValueFromObjectPath( configToUse, `settings.${ setting }` );\n\t\t\tif ( value !== undefined ) {\n\t\t\t\tresult = setImmutably( result, setting.split( '.' ), value );\n\t\t\t}\n\t\t} );\n\t\treturn result;\n\t}, [\n\t\tconfigs,\n\t\tsourceKey,\n\t\tpropertyPath,\n\t\tcontextualPath,\n\t\tglobalPath,\n\t\tappendedBlockPath,\n\t] );\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) =>\n\t\t\tsetImmutably( currentConfig, contextualPath.split( '.' ), newValue )\n\t\t);\n\t};\n\treturn [ settingValue, setSetting ];\n}\n\nexport function useGlobalStyle(\n\tpath,\n\tblockName,\n\tsource = 'all',\n\t{ shouldDecodeEncode = true } = {}\n) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst appendedPath = path ? '.' + path : '';\n\tconst finalPath = ! blockName\n\t\t? `styles${ appendedPath }`\n\t\t: `styles.blocks.${ blockName }${ appendedPath }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) =>\n\t\t\tsetImmutably(\n\t\t\t\tcurrentConfig,\n\t\t\t\tfinalPath.split( '.' ),\n\t\t\t\tshouldDecodeEncode\n\t\t\t\t\t? getPresetVariableFromValue(\n\t\t\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tnewValue\n\t\t\t\t\t )\n\t\t\t\t\t: newValue\n\t\t\t)\n\t\t);\n\t};\n\n\tlet rawResult, result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\trawResult = getValueFromObjectPath( mergedConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\trawResult = getValueFromObjectPath( userConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\trawResult = getValueFromObjectPath( baseConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( baseConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\nexport function useGlobalStyleLinks() {\n\tconst { merged: mergedConfig } = useContext( GlobalStylesContext );\n\treturn mergedConfig?._links;\n}\n\n/**\n * React hook that overrides a global settings object with block and element specific settings.\n *\n * @param {Object} parentSettings Settings object.\n * @param {blockName?} blockName Block name.\n * @param {element?} element Element name.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function useSettingsForBlockElement(\n\tparentSettings,\n\tblockName,\n\telement\n) {\n\tconst { supportedStyles, supports } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedStyles: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( blockName, element ),\n\t\t\t\tsupports:\n\t\t\t\t\tselect( blocksStore ).getBlockType( blockName )?.supports,\n\t\t\t};\n\t\t},\n\t\t[ blockName, element ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst updatedSettings = { ...parentSettings };\n\n\t\tif ( ! supportedStyles.includes( 'fontSize' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontSizes: {},\n\t\t\t\tcustomFontSize: false,\n\t\t\t\tdefaultFontSizes: false,\n\t\t\t};\n\t\t}\n\n\t\tif ( ! supportedStyles.includes( 'fontFamily' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontFamilies: {},\n\t\t\t};\n\t\t}\n\n\t\tupdatedSettings.color = {\n\t\t\t...updatedSettings.color,\n\t\t\ttext:\n\t\t\t\tupdatedSettings.color?.text &&\n\t\t\t\tsupportedStyles.includes( 'color' ),\n\t\t\tbackground:\n\t\t\t\tupdatedSettings.color?.background &&\n\t\t\t\t( supportedStyles.includes( 'background' ) ||\n\t\t\t\t\tsupportedStyles.includes( 'backgroundColor' ) ),\n\t\t\tbutton:\n\t\t\t\tupdatedSettings.color?.button &&\n\t\t\t\tsupportedStyles.includes( 'buttonColor' ),\n\t\t\theading:\n\t\t\t\tupdatedSettings.color?.heading &&\n\t\t\t\tsupportedStyles.includes( 'headingColor' ),\n\t\t\tlink:\n\t\t\t\tupdatedSettings.color?.link &&\n\t\t\t\tsupportedStyles.includes( 'linkColor' ),\n\t\t\tcaption:\n\t\t\t\tupdatedSettings.color?.caption &&\n\t\t\t\tsupportedStyles.includes( 'captionColor' ),\n\t\t};\n\n\t\t// Some blocks can enable background colors but disable gradients.\n\t\tif ( ! supportedStyles.includes( 'background' ) ) {\n\t\t\tupdatedSettings.color.gradients = [];\n\t\t\tupdatedSettings.color.customGradient = false;\n\t\t}\n\n\t\t// If filters are not supported by the block/element, disable duotone.\n\t\tif ( ! supportedStyles.includes( 'filter' ) ) {\n\t\t\tupdatedSettings.color.defaultDuotone = false;\n\t\t\tupdatedSettings.color.customDuotone = false;\n\t\t}\n\n\t\t[\n\t\t\t'lineHeight',\n\t\t\t'fontStyle',\n\t\t\t'fontWeight',\n\t\t\t'letterSpacing',\n\t\t\t'textAlign',\n\t\t\t'textTransform',\n\t\t\t'textDecoration',\n\t\t\t'writingMode',\n\t\t].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.typography = {\n\t\t\t\t\t...updatedSettings.typography,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// The column-count style is named text column to reduce confusion with\n\t\t// the columns block and manage expectations from the support.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/33587\n\t\tif ( ! supportedStyles.includes( 'columnCount' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextColumns: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'contentSize', 'wideSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.layout = {\n\t\t\t\t\t...updatedSettings.layout,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst sides = Array.isArray( supports?.spacing?.[ key ] )\n\t\t\t\t? supports?.spacing?.[ key ]\n\t\t\t\t: supports?.spacing?.[ key ]?.sides;\n\t\t\t// Check if spacing type is supported before adding sides.\n\t\t\tif ( sides?.length && updatedSettings.spacing?.[ key ] ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: {\n\t\t\t\t\t\t...updatedSettings.spacing?.[ key ],\n\t\t\t\t\t\tsides,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'aspectRatio', 'minHeight' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.dimensions = {\n\t\t\t\t\t...updatedSettings.dimensions,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {\n\t\t\tif (\n\t\t\t\t! supportedStyles.includes(\n\t\t\t\t\t'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedSettings.border = {\n\t\t\t\t\t...updatedSettings.border,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tupdatedSettings.shadow = supportedStyles.includes( 'shadow' )\n\t\t\t? updatedSettings.shadow\n\t\t\t: false;\n\n\t\t// Text alignment is only available for blocks.\n\t\tif ( element ) {\n\t\t\tupdatedSettings.typography.textAlign = false;\n\t\t}\n\n\t\treturn updatedSettings;\n\t}, [ parentSettings, supportedStyles, supports, element ] );\n}\n\nexport function useColorsPerOrigin( settings ) {\n\tconst customColors = settings?.color?.palette?.custom;\n\tconst themeColors = settings?.color?.palette?.theme;\n\tconst defaultColors = settings?.color?.palette?.default;\n\tconst shouldDisplayDefaultColors = settings?.color?.defaultPalette;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n}\n\nexport function useGradientsPerOrigin( settings ) {\n\tconst customGradients = settings?.color?.gradients?.custom;\n\tconst themeGradients = settings?.color?.gradients?.theme;\n\tconst defaultGradients = settings?.color?.gradients?.default;\n\tconst shouldDisplayDefaultGradients = settings?.color?.defaultGradients;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,O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EAAG;MAC9C/D,MAAM,CAACiF,IAAI,CAAE;QACZC,IAAI,EAAE,IAAAC,QAAE,EACP,OAAO,EACP,8CACD,CAAC;QACD/B,SAAS,EAAEmC;MACZ,CAAE,CAAC;IACJ;IACA,IACCE,6BAA6B,IAC7BD,gBAAgB,IAChBA,gBAAgB,CAACzB,MAAM,EACtB;MACD/D,MAAM,CAACiF,IAAI,CAAE;QACZC,IAAI,EAAE,IAAAC,QAAE,EACP,SAAS,EACT,8CACD,CAAC;QACD/B,SAAS,EAAEoC;MACZ,CAAE,CAAC;IACJ;IACA,IAAKF,eAAe,IAAIA,eAAe,CAACvB,MAAM,EAAG;MAChD/D,MAAM,CAACiF,IAAI,CAAE;QACZC,IAAI,EAAE,IAAAC,QAAE,EACP,QAAQ,EACR,gDACD,CAAC;QACD/B,SAAS,EAAEkC;MACZ,CAAE,CAAC;IACJ;IACA,OAAOtF,MAAM;EACd,CAAC,EAAE,CACFsF,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,6BAA6B,CAC5B,CAAC;AACJ","ignoreList":[]}
|
|
@@ -37,6 +37,12 @@ var _themeFileUriUtils = require("./theme-file-uri-utils");
|
|
|
37
37
|
* Internal dependencies
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
|
+
// Elements that rely on class names in their selectors.
|
|
41
|
+
const ELEMENT_CLASS_NAMES = {
|
|
42
|
+
button: 'wp-element-button',
|
|
43
|
+
caption: 'wp-element-caption'
|
|
44
|
+
};
|
|
45
|
+
|
|
40
46
|
// List of block support features that can have their related styles
|
|
41
47
|
// generated under their own feature level selector rather than the block's.
|
|
42
48
|
const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
|
|
@@ -393,7 +399,7 @@ function getLayoutStyles({
|
|
|
393
399
|
// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
|
|
394
400
|
combinedSelector = selector === _utils.ROOT_BLOCK_SELECTOR ? `:where(.${className}${spacingStyle?.selector || ''})` : `:where(${selector}.${className}${spacingStyle?.selector || ''})`;
|
|
395
401
|
} else {
|
|
396
|
-
combinedSelector = selector === _utils.ROOT_BLOCK_SELECTOR ?
|
|
402
|
+
combinedSelector = selector === _utils.ROOT_BLOCK_SELECTOR ? `:root :where(.${className})${spacingStyle?.selector || ''}` : `:root :where(${selector}-${className})${spacingStyle?.selector || ''}`;
|
|
397
403
|
}
|
|
398
404
|
ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
|
|
399
405
|
}
|
|
@@ -458,14 +464,20 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
458
464
|
if (styles) {
|
|
459
465
|
nodes.push({
|
|
460
466
|
styles,
|
|
461
|
-
selector: _utils.ROOT_BLOCK_SELECTOR
|
|
467
|
+
selector: _utils.ROOT_BLOCK_SELECTOR,
|
|
468
|
+
// Root selector (body) styles should not be wrapped in `:root where()` to keep
|
|
469
|
+
// specificity at (0,0,1) and maintain backwards compatibility.
|
|
470
|
+
skipSelectorWrapper: true
|
|
462
471
|
});
|
|
463
472
|
}
|
|
464
473
|
Object.entries(_blocks.__EXPERIMENTAL_ELEMENTS).forEach(([name, selector]) => {
|
|
465
474
|
if (tree.styles?.elements?.[name]) {
|
|
466
475
|
nodes.push({
|
|
467
476
|
styles: tree.styles?.elements?.[name],
|
|
468
|
-
selector
|
|
477
|
+
selector,
|
|
478
|
+
// Top level elements that don't use a class name should not receive the
|
|
479
|
+
// `:root :where()` wrapper to maintain backwards compatibility.
|
|
480
|
+
skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name]
|
|
469
481
|
});
|
|
470
482
|
}
|
|
471
483
|
});
|
|
@@ -682,7 +694,8 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
682
694
|
fallbackGapValue,
|
|
683
695
|
hasLayoutSupport,
|
|
684
696
|
featureSelectors,
|
|
685
|
-
styleVariationSelectors
|
|
697
|
+
styleVariationSelectors,
|
|
698
|
+
skipSelectorWrapper
|
|
686
699
|
}) => {
|
|
687
700
|
// Process styles for block support features with custom feature level
|
|
688
701
|
// CSS selectors set.
|
|
@@ -723,7 +736,8 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
723
736
|
// Process the remaining block styles (they use either normal block class or __experimentalSelector).
|
|
724
737
|
const styleDeclarations = getStylesDeclarations(styles, selector, useRootPaddingAlign, tree, disableRootPadding);
|
|
725
738
|
if (styleDeclarations?.length) {
|
|
726
|
-
|
|
739
|
+
const generalSelector = skipSelectorWrapper ? selector : `:root :where(${selector})`;
|
|
740
|
+
ruleset += `${generalSelector}{${styleDeclarations.join(';')};}`;
|
|
727
741
|
}
|
|
728
742
|
if (styles?.css) {
|
|
729
743
|
ruleset += processCSSNesting(styles.css, `:root :where(${selector})`);
|
|
@@ -773,7 +787,12 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
773
787
|
// Split and append pseudo selector to create
|
|
774
788
|
// the proper rules to target the elements.
|
|
775
789
|
const _selector = selector.split(',').map(sel => sel + pseudoKey).join(',');
|
|
776
|
-
|
|
790
|
+
|
|
791
|
+
// As pseudo classes such as :hover, :focus etc. have class-level
|
|
792
|
+
// specificity, they must use the `:root :where()` wrapper. This.
|
|
793
|
+
// caps the specificity at `0-1-0` to allow proper nesting of variations
|
|
794
|
+
// and block type element styles.
|
|
795
|
+
const pseudoRule = `:root :where(${_selector}){${pseudoDeclarations.join(';')};}`;
|
|
777
796
|
ruleset += pseudoRule;
|
|
778
797
|
});
|
|
779
798
|
}
|
|
@@ -904,10 +923,16 @@ function updateConfigWithSeparator(config) {
|
|
|
904
923
|
}
|
|
905
924
|
function processCSSNesting(css, blockSelector) {
|
|
906
925
|
let processedCSS = '';
|
|
926
|
+
if (!css || css.trim() === '') {
|
|
927
|
+
return processedCSS;
|
|
928
|
+
}
|
|
907
929
|
|
|
908
930
|
// Split CSS nested rules.
|
|
909
931
|
const parts = css.split('&');
|
|
910
932
|
parts.forEach(part => {
|
|
933
|
+
if (!part || part.trim() === '') {
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
911
936
|
const isRootCss = !part.includes('{');
|
|
912
937
|
if (isRootCss) {
|
|
913
938
|
// If the part doesn't contain braces, it applies to the root level.
|
|
@@ -919,8 +944,27 @@ function processCSSNesting(css, blockSelector) {
|
|
|
919
944
|
return;
|
|
920
945
|
}
|
|
921
946
|
const [nestedSelector, cssValue] = splittedPart;
|
|
922
|
-
|
|
923
|
-
|
|
947
|
+
|
|
948
|
+
// Handle pseudo elements such as ::before, ::after, etc. Regex will also
|
|
949
|
+
// capture any leading combinator such as >, +, or ~, as well as spaces.
|
|
950
|
+
// This allows pseudo elements as descendants e.g. `.parent ::before`.
|
|
951
|
+
const matches = nestedSelector.match(/([>+~\s]*::[a-zA-Z-]+)/);
|
|
952
|
+
const pseudoPart = matches ? matches[1] : '';
|
|
953
|
+
const withoutPseudoElement = matches ? nestedSelector.replace(pseudoPart, '').trim() : nestedSelector.trim();
|
|
954
|
+
let combinedSelector;
|
|
955
|
+
if (withoutPseudoElement === '') {
|
|
956
|
+
// Only contained a pseudo element to use the block selector to form
|
|
957
|
+
// the final `:root :where()` selector.
|
|
958
|
+
combinedSelector = blockSelector;
|
|
959
|
+
} else {
|
|
960
|
+
// If the nested selector is a descendant of the block scope it with the
|
|
961
|
+
// block selector. Otherwise append it to the block selector.
|
|
962
|
+
combinedSelector = nestedSelector.startsWith(' ') ? (0, _utils.scopeSelector)(blockSelector, withoutPseudoElement) : (0, _utils.appendToSelector)(blockSelector, withoutPseudoElement);
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// Build final rule, re-adding any pseudo element outside the `:where()`
|
|
966
|
+
// to maintain valid CSS selector.
|
|
967
|
+
processedCSS += `:root :where(${combinedSelector})${pseudoPart}{${cssValue.trim()}}`;
|
|
924
968
|
}
|
|
925
969
|
});
|
|
926
970
|
return processedCSS;
|