@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
package/build/store/utils.js
CHANGED
|
@@ -5,15 +5,51 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getAllPatternsDependants = exports.checkAllowListRecursive = exports.checkAllowList = void 0;
|
|
7
7
|
exports.getInsertBlockTypeDependants = getInsertBlockTypeDependants;
|
|
8
|
+
exports.getParsedPattern = getParsedPattern;
|
|
8
9
|
exports.withRootClientIdOptionKey = void 0;
|
|
10
|
+
var _blocks = require("@wordpress/blocks");
|
|
9
11
|
var _privateKeys = require("./private-keys");
|
|
10
12
|
var _lockUnlock = require("../lock-unlock");
|
|
11
13
|
var _constants = require("./constants");
|
|
14
|
+
/**
|
|
15
|
+
* WordPress dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* Internal dependencies
|
|
14
20
|
*/
|
|
15
21
|
|
|
16
22
|
const withRootClientIdOptionKey = exports.withRootClientIdOptionKey = Symbol('withRootClientId');
|
|
23
|
+
const parsedPatternCache = new WeakMap();
|
|
24
|
+
function parsePattern(pattern) {
|
|
25
|
+
const blocks = (0, _blocks.parse)(pattern.content, {
|
|
26
|
+
__unstableSkipMigrationLogs: true
|
|
27
|
+
});
|
|
28
|
+
if (blocks.length === 1) {
|
|
29
|
+
blocks[0].attributes = {
|
|
30
|
+
...blocks[0].attributes,
|
|
31
|
+
metadata: {
|
|
32
|
+
...(blocks[0].attributes.metadata || {}),
|
|
33
|
+
categories: pattern.categories,
|
|
34
|
+
patternName: pattern.name,
|
|
35
|
+
name: blocks[0].attributes.metadata?.name || pattern.title
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...pattern,
|
|
41
|
+
blocks
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function getParsedPattern(pattern) {
|
|
45
|
+
let parsedPattern = parsedPatternCache.get(pattern);
|
|
46
|
+
if (parsedPattern) {
|
|
47
|
+
return parsedPattern;
|
|
48
|
+
}
|
|
49
|
+
parsedPattern = parsePattern(pattern);
|
|
50
|
+
parsedPatternCache.set(pattern, parsedPattern);
|
|
51
|
+
return parsedPattern;
|
|
52
|
+
}
|
|
17
53
|
const checkAllowList = (list, item, defaultResult = null) => {
|
|
18
54
|
if (typeof list === 'boolean') {
|
|
19
55
|
return list;
|
package/build/store/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_blocks","require","_privateKeys","_lockUnlock","_constants","withRootClientIdOptionKey","exports","Symbol","parsedPatternCache","WeakMap","parsePattern","pattern","blocks","parse","content","__unstableSkipMigrationLogs","length","attributes","metadata","categories","patternName","name","title","getParsedPattern","parsedPattern","get","set","checkAllowList","list","item","defaultResult","Array","isArray","includes","checkAllowListRecursive","allowedBlockTypes","blocksQueue","block","shift","isAllowed","blockName","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","select","state","settings","__experimentalBlockPatterns","__experimentalUserPatternCategories","__experimentalReusableBlocks","selectBlockPatternsKey","blockPatterns","unlock","STORE_NAME","getReusableBlocks","getInsertBlockTypeDependants","rootClientId","blockListSettings","byClientId","templateLock","blockEditingModes"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { selectBlockPatternsKey } from './private-keys';\nimport { unlock } from '../lock-unlock';\nimport { STORE_NAME } from './constants';\n\nexport const withRootClientIdOptionKey = Symbol( 'withRootClientId' );\n\nconst parsedPatternCache = new WeakMap();\n\nfunction parsePattern( pattern ) {\n\tconst blocks = parse( pattern.content, {\n\t\t__unstableSkipMigrationLogs: true,\n\t} );\n\tif ( blocks.length === 1 ) {\n\t\tblocks[ 0 ].attributes = {\n\t\t\t...blocks[ 0 ].attributes,\n\t\t\tmetadata: {\n\t\t\t\t...( blocks[ 0 ].attributes.metadata || {} ),\n\t\t\t\tcategories: pattern.categories,\n\t\t\t\tpatternName: pattern.name,\n\t\t\t\tname: blocks[ 0 ].attributes.metadata?.name || pattern.title,\n\t\t\t},\n\t\t};\n\t}\n\treturn {\n\t\t...pattern,\n\t\tblocks,\n\t};\n}\n\nexport function getParsedPattern( pattern ) {\n\tlet parsedPattern = parsedPatternCache.get( pattern );\n\tif ( parsedPattern ) {\n\t\treturn parsedPattern;\n\t}\n\tparsedPattern = parsePattern( pattern );\n\tparsedPatternCache.set( pattern, parsedPattern );\n\treturn parsedPattern;\n}\n\nexport const checkAllowList = ( list, item, defaultResult = null ) => {\n\tif ( typeof list === 'boolean' ) {\n\t\treturn list;\n\t}\n\tif ( Array.isArray( list ) ) {\n\t\t// TODO: when there is a canonical way to detect that we are editing a post\n\t\t// the following check should be changed to something like:\n\t\t// if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )\n\t\tif ( list.includes( 'core/post-content' ) && item === null ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn list.includes( item );\n\t}\n\treturn defaultResult;\n};\n\nexport const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {\n\tif ( typeof allowedBlockTypes === 'boolean' ) {\n\t\treturn allowedBlockTypes;\n\t}\n\n\tconst blocksQueue = [ ...blocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\n\t\tconst isAllowed = checkAllowList(\n\t\t\tallowedBlockTypes,\n\t\t\tblock.name || block.blockName,\n\t\t\ttrue\n\t\t);\n\t\tif ( ! isAllowed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\n\treturn true;\n};\n\nexport const getAllPatternsDependants = ( select ) => ( state ) => {\n\treturn [\n\t\tstate.settings.__experimentalBlockPatterns,\n\t\tstate.settings.__experimentalUserPatternCategories,\n\t\tstate.settings.__experimentalReusableBlocks,\n\t\tstate.settings[ selectBlockPatternsKey ]?.( select ),\n\t\tstate.blockPatterns,\n\t\tunlock( select( STORE_NAME ) ).getReusableBlocks(),\n\t];\n};\n\nexport function getInsertBlockTypeDependants( state, rootClientId ) {\n\treturn [\n\t\tstate.blockListSettings[ rootClientId ],\n\t\tstate.blocks.byClientId.get( rootClientId ),\n\t\tstate.settings.allowedBlockTypes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockEditingModes,\n\t];\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKO,MAAMI,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAGE,MAAM,CAAE,kBAAmB,CAAC;AAErE,MAAMC,kBAAkB,GAAG,IAAIC,OAAO,CAAC,CAAC;AAExC,SAASC,YAAYA,CAAEC,OAAO,EAAG;EAChC,MAAMC,MAAM,GAAG,IAAAC,aAAK,EAAEF,OAAO,CAACG,OAAO,EAAE;IACtCC,2BAA2B,EAAE;EAC9B,CAAE,CAAC;EACH,IAAKH,MAAM,CAACI,MAAM,KAAK,CAAC,EAAG;IAC1BJ,MAAM,CAAE,CAAC,CAAE,CAACK,UAAU,GAAG;MACxB,GAAGL,MAAM,CAAE,CAAC,CAAE,CAACK,UAAU;MACzBC,QAAQ,EAAE;QACT,IAAKN,MAAM,CAAE,CAAC,CAAE,CAACK,UAAU,CAACC,QAAQ,IAAI,CA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52,7 +52,7 @@ function createBlockCompleter() {
|
|
|
52
52
|
prioritizedBlocks: getBlockListSettings(_rootClientId)?.prioritizedInserterBlocks
|
|
53
53
|
};
|
|
54
54
|
}, []);
|
|
55
|
-
const [items, categories, collections] = useBlockTypesState(rootClientId, noop);
|
|
55
|
+
const [items, categories, collections] = useBlockTypesState(rootClientId, noop, true);
|
|
56
56
|
const filteredItems = useMemo(() => {
|
|
57
57
|
const initialFilteredItems = !!filterValue.trim() ? searchBlockItems(items, categories, collections, filterValue) : orderInserterBlockItems(orderBy(items, 'frecency', 'desc'), prioritizedBlocks);
|
|
58
58
|
return initialFilteredItems.filter(item => item.name !== selectedBlockName).slice(0, SHOWN_BLOCK_TYPES);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","createBlock","createBlocksFromInnerBlocksTemplate","parse","useMemo","searchBlockItems","useBlockTypesState","BlockIcon","store","blockEditorStore","orderBy","orderInserterBlockItems","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","noop","SHOWN_BLOCK_TYPES","createBlockCompleter","name","className","triggerPrefix","useItems","filterValue","rootClientId","selectedBlockName","prioritizedBlocks","select","getSelectedBlockClientId","getBlockName","getBlockListSettings","getBlockRootClientId","selectedBlockClientId","_rootClientId","prioritizedInserterBlocks","items","categories","collections","filteredItems","initialFilteredItems","trim","filter","item","slice","options","map","blockItem","title","icon","isDisabled","key","id","value","label","children","showColors","allowContext","before","after","test","getOptionCompletion","inserterItem","initialAttributes","innerBlocks","syncStatus","content","action","__unstableSkipMigrationLogs"],"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":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,mCAAmC,EACnCC,KAAK,QACC,mBAAmB;AAC1B,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,qCAAqC;AACtE,OAAOC,kBAAkB,MAAM,oDAAoD;AACnF,OAAOC,SAAS,MAAM,0BAA0B;AAChD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,uBAAuB,QAAQ,qCAAqC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE9E,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,iBAAiB,GAAG,CAAC;;AAE3B;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAA,EAAG;EAC/B,O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["useSelect","createBlock","createBlocksFromInnerBlocksTemplate","parse","useMemo","searchBlockItems","useBlockTypesState","BlockIcon","store","blockEditorStore","orderBy","orderInserterBlockItems","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","noop","SHOWN_BLOCK_TYPES","createBlockCompleter","name","className","triggerPrefix","useItems","filterValue","rootClientId","selectedBlockName","prioritizedBlocks","select","getSelectedBlockClientId","getBlockName","getBlockListSettings","getBlockRootClientId","selectedBlockClientId","_rootClientId","prioritizedInserterBlocks","items","categories","collections","filteredItems","initialFilteredItems","trim","filter","item","slice","options","map","blockItem","title","icon","isDisabled","key","id","value","label","children","showColors","allowContext","before","after","test","getOptionCompletion","inserterItem","initialAttributes","innerBlocks","syncStatus","content","action","__unstableSkipMigrationLogs"],"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":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,mCAAmC,EACnCC,KAAK,QACC,mBAAmB;AAC1B,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,qCAAqC;AACtE,OAAOC,kBAAkB,MAAM,oDAAoD;AACnF,OAAOC,SAAS,MAAM,0BAA0B;AAChD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,uBAAuB,QAAQ,qCAAqC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE9E,MAAMC,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;IACNC,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE,oCAAoC;IAC/CC,aAAa,EAAE,GAAG;IAElBC,QAAQA,CAAEC,WAAW,EAAG;MACvB,MAAM;QAAEC,YAAY;QAAEC,iBAAiB;QAAEC;MAAkB,CAAC,GAC3D5B,SAAS,CAAI6B,MAAM,IAAM;QACxB,MAAM;UACLC,wBAAwB;UACxBC,YAAY;UACZC,oBAAoB;UACpBC;QACD,CAAC,GAAGJ,MAAM,CAAEpB,gBAAiB,CAAC;QAC9B,MAAMyB,qBAAqB,GAAGJ,wBAAwB,CAAC,CAAC;QACxD,MAAMK,aAAa,GAAGF,oBAAoB,CACzCC,qBACD,CAAC;QACD,OAAO;UACNP,iBAAiB,EAAEO,qBAAqB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UAAA,CACN,CACF;UACDE;QACD,CAAC;MACF,CAAE,CAAC,EACJ,CAAEX,aAAa,CAChB,CAAC;MAED,OAAO,CAAEM,OAAO,CAAE;IACnB,CAAC;IACDY,YAAYA,CAAEC,MAAM,EAAEC,KAAK,EAAG;MAC7B,OAAO,EAAI,IAAI,CAACC,IAAI,CAAEF,MAAO,CAAC,IAAI,IAAI,CAACE,IAAI,CAAED,KAAM,CAAC,CAAE;IACvD,CAAC;IACDE,mBAAmBA,CAAEC,YAAY,EAAG;MACnC,MAAM;QACL1C,IAAI;QACJ2C,iBAAiB;QACjBC,WAAW;QACXC,UAAU;QACVC;MACD,CAAC,GAAGJ,YAAY;MAEhB,OAAO;QACNK,MAAM,EAAE,SAAS;QACjBd,KAAK,EACJY,UAAU,KAAK,UAAU,GACtB/D,KAAK,CAAEgE,OAAO,EAAE;UAChBE,2BAA2B,EAAE;QAC7B,CAAE,CAAC,GACHpE,WAAW,CACXoB,IAAI,EACJ2C,iBAAiB,EACjB9D,mCAAmC,CAClC+D,WACD,CACA;MACL,CAAC;IACF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe7C,oBAAoB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useContext, useMemo, useRef } from '@wordpress/element';
|
|
5
|
-
import { useRefEffect
|
|
4
|
+
import { useContext, useMemo, useRef, useState, useLayoutEffect } from '@wordpress/element';
|
|
5
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
@@ -65,11 +65,18 @@ function useBlockRef(clientId) {
|
|
|
65
65
|
* @return {Element|null} The block's wrapper element.
|
|
66
66
|
*/
|
|
67
67
|
function useBlockElement(clientId) {
|
|
68
|
-
var _useObservableValue;
|
|
69
68
|
const {
|
|
70
69
|
refsMap
|
|
71
70
|
} = useContext(BlockRefs);
|
|
72
|
-
|
|
71
|
+
const [blockElement, setBlockElement] = useState(null);
|
|
72
|
+
// Delay setting the resulting `blockElement` until an effect. If the block element
|
|
73
|
+
// changes (i.e., the block is unmounted and re-mounted), this allows enough time
|
|
74
|
+
// for the ref callbacks to clean up the old element and set the new one.
|
|
75
|
+
useLayoutEffect(() => {
|
|
76
|
+
setBlockElement(refsMap.get(clientId));
|
|
77
|
+
return refsMap.subscribe(clientId, () => setBlockElement(refsMap.get(clientId)));
|
|
78
|
+
}, [refsMap, clientId]);
|
|
79
|
+
return blockElement;
|
|
73
80
|
}
|
|
74
81
|
export { useBlockRef as __unstableUseBlockRef };
|
|
75
82
|
export { useBlockElement as __unstableUseBlockElement };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useContext","useMemo","useRef","
|
|
1
|
+
{"version":3,"names":["useContext","useMemo","useRef","useState","useLayoutEffect","useRefEffect","BlockRefs","useBlockRefProvider","clientId","refsMap","element","set","delete","useBlockRef","latestClientId","current","_refsMap$get","get","useBlockElement","blockElement","setBlockElement","subscribe","__unstableUseBlockRef","__unstableUseBlockElement"],"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":"AAAA;AACA;AACA;AACA,SACCA,UAAU,EACVC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,eAAe,QACT,oBAAoB;AAC3B,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,SAAS,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C,OAAO,CAACY,SAAS,CAAEb,QAAQ,EAAE,MACnCY,eAAe,CAAEX,OAAO,CAACQ,GAAG,CAAET,QAAS,CAAE,CAC1C,CAAC;EACF,CAAC,EAAE,CAAEC,OAAO,EAAED,QAAQ,CAAG,CAAC;EAC1B,OAAOW,YAAY;AACpB;AAEA,SAASN,WAAW,IAAIS,qBAAqB;AAC7C,SAASJ,eAAe,IAAIK,yBAAyB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["shuffle","ToolbarButton","ToolbarGroup","__","useMemo","useSelect","useDispatch","store","blockEditorStore","jsx","_jsx","EMPTY_ARRAY","Container","props","children","Shuffle","clientId","as","categories","patterns","patternName","select","getBlockAttributes","getBlockRootClientId","__experimentalGetAllowedPatterns","attributes","_categories","metadata","_patternName","rootBlock","_patterns","replaceBlocks","sameCategoryPatternsWithSingleWrapper","length","filter","pattern","blocks","some","category","includes","syncStatus","id","getNextPattern","numberOfPatterns","patternIndex","findIndex","name","nextPatternIndex","ComponentToUse","label","icon","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":["shuffle","ToolbarButton","ToolbarGroup","__","useMemo","useSelect","useDispatch","store","blockEditorStore","jsx","_jsx","EMPTY_ARRAY","Container","props","children","Shuffle","clientId","as","categories","patterns","patternName","select","getBlockAttributes","getBlockRootClientId","__experimentalGetAllowedPatterns","attributes","_categories","metadata","_patternName","rootBlock","_patterns","replaceBlocks","sameCategoryPatternsWithSingleWrapper","length","filter","pattern","blocks","some","category","includes","syncStatus","id","getNextPattern","numberOfPatterns","patternIndex","findIndex","name","nextPatternIndex","ComponentToUse","label","icon","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":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,aAAa,EAAEC,YAAY,QAAQ,uBAAuB;AACnE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iB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ACT,GAAGyB,WAAW,CAAChB,MAAM,CAAE,CAAC,CAAE,CAACX,UAAU,CAACE,QAAQ;UAC9CT;QACD;MACD,CAAC;MACDa,aAAa,CAAEf,QAAQ,EAAEoC,WAAW,CAAChB,MAAO,CAAC;IAC9C;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -25,9 +25,13 @@ const EMPTY_CONFIG = {
|
|
|
25
25
|
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'];
|
|
26
26
|
export const useGlobalStylesReset = () => {
|
|
27
27
|
const {
|
|
28
|
-
user
|
|
28
|
+
user,
|
|
29
29
|
setUserConfig
|
|
30
30
|
} = useContext(GlobalStylesContext);
|
|
31
|
+
const config = {
|
|
32
|
+
settings: user.settings,
|
|
33
|
+
styles: user.styles
|
|
34
|
+
};
|
|
31
35
|
const canReset = !!config && !fastDeepEqual(config, EMPTY_CONFIG);
|
|
32
36
|
return [canReset, useCallback(() => setUserConfig(EMPTY_CONFIG), [setUserConfig])];
|
|
33
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fastDeepEqual","useContext","useCallback","useMemo","useSelect","store","blocksStore","_x","getValueFromVariable","getPresetVariableFromValue","getValueFromObjectPath","setImmutably","GlobalStylesContext","unlock","EMPTY_CONFIG","settings","styles","VALID_SETTINGS","useGlobalStylesReset","user","config","setUserConfig","canReset","useGlobalSetting","propertyPath","blockName","source","configs","appendedBlockPath","appendedPropertyPath","contextualPath","globalPath","sourceKey","settingValue","configToUse","_getValueFromObjectPa","result","forEach","setting","_getValueFromObjectPa2","value","undefined","split","setSetting","newValue","currentConfig","useGlobalStyle","path","shouldDecodeEncode","merged","mergedConfig","base","baseConfig","userConfig","appendedPath","finalPath","setStyle","rawResult","useGlobalStyleLinks","_links","useSettingsForBlockElement","parentSettings","element","supportedStyles","supports","select","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","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":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;;AAE/C;AACA;AACA;AACA,SAASC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACrE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,oBAAoB,EAAEC,0BAA0B,QAAQ,SAAS;AAC1E,SAASC,sBAAsB,EAAEC,YAAY,QAAQ,oBAAoB;AACzE,SAASC,mBAAmB,QAAQ,WAAW;AAC/C,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAMC,YAAY,GAAG;EAAEC,QAAQ,EAAE,CAAC,CAAC;EAAEC,MAAM,EAAE,CAAC;AAAE,CAAC;AAEjD,MAAMC,cAAc,GAAG,CACtB,iBAAiB,EACjB,+BAA+B,EAC/B,4BAA4B,EAC5B,6BAA6B,EAC7B,2BAA2B,EAC3B,+BAA+B,EAC/B,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACt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0B,CACzB,CAAC;AACJ;AAEA,OAAO,SAASK,qBAAqBA,CAAEnG,QAAQ,EAAG;EACjD,MAAMoG,eAAe,GAAGpG,QAAQ,EAAE4D,KAAK,EAAEO,SAAS,EAAEsB,MAAM;EAC1D,MAAMY,cAAc,GAAGrG,QAAQ,EAAE4D,KAAK,EAAEO,SAAS,EAAEwB,KAAK;EACxD,MAAMW,gBAAgB,GAAGtG,QAAQ,EAAE4D,KAAK,EAAEO,SAAS,EAAE0B,OAAO;EAC5D,MAAMU,6BAA6B,GAAGvG,QAAQ,EAAE4D,KAAK,EAAE0C,gBAAgB;EAEvE,OAAOlH,OAAO,CAAE,MAAM;IACrB,MAAMiC,MAAM,GAAG,EAAE;IACjB,IAAKgF,cAAc,IAAIA,cAAc,CAACvB,MAAM,EAAG;MAC9CzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,OAAO,EACP,8CACD,CAAC;QACD2E,SAAS,EAAEkC;MACZ,CAAE,CAAC;IACJ;IACA,IACCE,6BAA6B,IAC7BD,gBAAgB,IAChBA,gBAAgB,CAACxB,MAAM,EACtB;MACDzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,SAAS,EACT,8CACD,CAAC;QACD2E,SAAS,EAAEmC;MACZ,CAAE,CAAC;IACJ;IACA,IAAKF,eAAe,IAAIA,eAAe,CAACtB,MAAM,EAAG;MAChDzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,QAAQ,EACR,gDACD,CAAC;QACD2E,SAAS,EAAEiC;MACZ,CAAE,CAAC;IACJ;IACA,OAAO/E,MAAM;EACd,CAAC,EAAE,CACF+E,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,6BAA6B,CAC5B,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["fastDeepEqual","useContext","useCallback","useMemo","useSelect","store","blocksStore","_x","getValueFromVariable","getPresetVariableFromValue","getValueFromObjectPath","setImmutably","GlobalStylesContext","unlock","EMPTY_CONFIG","settings","styles","VALID_SETTINGS","useGlobalStylesReset","user","setUserConfig","config","canReset","useGlobalSetting","propertyPath","blockName","source","configs","appendedBlockPath","appendedPropertyPath","contextualPath","globalPath","sourceKey","settingValue","configToUse","_getValueFromObjectPa","result","forEach","setting","_getValueFromObjectPa2","value","undefined","split","setSetting","newValue","currentConfig","useGlobalStyle","path","shouldDecodeEncode","merged","mergedConfig","base","baseConfig","userConfig","appendedPath","finalPath","setStyle","rawResult","useGlobalStyleLinks","_links","useSettingsForBlockElement","parentSettings","element","supportedStyles","supports","select","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","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":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;;AAE/C;AACA;AACA;AACA,SAASC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACrE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,oBAAoB,EAAEC,0BAA0B,QAAQ,SAAS;AAC1E,SAASC,sBAAsB,EAAEC,YAAY,QAAQ,oBAAoB;AACzE,SAASC,mBAAmB,QAAQ,WAAW;AAC/C,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAMC,YAAY,GAAG;EAAEC,QAAQ,EAAE,CAAC,CAAC;EAAEC,MAAM,EAAE,CAAC;AAAE,CAAC;AAEjD,MAAMC,cAAc,GAAG,CACtB,iBAAiB,EACjB,+BAA+B,EAC/B,4BAA4B,EAC5B,6BAA6B,EAC7B,2BAA2B,EAC3B,+BAA+B,EAC/B,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,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EAAG;EACjD,MAAMoG,eAAe,GAAGpG,QAAQ,EAAE4D,KAAK,EAAEO,SAAS,EAAEsB,MAAM;EAC1D,MAAMY,cAAc,GAAGrG,QAAQ,EAAE4D,KAAK,EAAEO,SAAS,EAAEwB,KAAK;EACxD,MAAMW,gBAAgB,GAAGtG,QAAQ,EAAE4D,KAAK,EAAEO,SAAS,EAAE0B,OAAO;EAC5D,MAAMU,6BAA6B,GAAGvG,QAAQ,EAAE4D,KAAK,EAAE0C,gBAAgB;EAEvE,OAAOlH,OAAO,CAAE,MAAM;IACrB,MAAMiC,MAAM,GAAG,EAAE;IACjB,IAAKgF,cAAc,IAAIA,cAAc,CAACvB,MAAM,EAAG;MAC9CzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,OAAO,EACP,8CACD,CAAC;QACD2E,SAAS,EAAEkC;MACZ,CAAE,CAAC;IACJ;IACA,IACCE,6BAA6B,IAC7BD,gBAAgB,IAChBA,gBAAgB,CAACxB,MAAM,EACtB;MACDzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,SAAS,EACT,8CACD,CAAC;QACD2E,SAAS,EAAEmC;MACZ,CAAE,CAAC;IACJ;IACA,IAAKF,eAAe,IAAIA,eAAe,CAACtB,MAAM,EAAG;MAChDzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,QAAQ,EACR,gDACD,CAAC;QACD2E,SAAS,EAAEiC;MACZ,CAAE,CAAC;IACJ;IACA,OAAO/E,MAAM;EACd,CAAC,EAAE,CACF+E,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,6BAA6B,CAC5B,CAAC;AACJ","ignoreList":[]}
|
|
@@ -23,6 +23,12 @@ import { getValueFromObjectPath, setImmutably } from '../../utils/object';
|
|
|
23
23
|
import { unlock } from '../../lock-unlock';
|
|
24
24
|
import { setThemeFileUris } from './theme-file-uri-utils';
|
|
25
25
|
|
|
26
|
+
// Elements that rely on class names in their selectors.
|
|
27
|
+
const ELEMENT_CLASS_NAMES = {
|
|
28
|
+
button: 'wp-element-button',
|
|
29
|
+
caption: 'wp-element-caption'
|
|
30
|
+
};
|
|
31
|
+
|
|
26
32
|
// List of block support features that can have their related styles
|
|
27
33
|
// generated under their own feature level selector rather than the block's.
|
|
28
34
|
const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
|
|
@@ -379,7 +385,7 @@ export function getLayoutStyles({
|
|
|
379
385
|
// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
|
|
380
386
|
combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:where(.${className}${spacingStyle?.selector || ''})` : `:where(${selector}.${className}${spacingStyle?.selector || ''})`;
|
|
381
387
|
} else {
|
|
382
|
-
combinedSelector = selector === ROOT_BLOCK_SELECTOR ?
|
|
388
|
+
combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:root :where(.${className})${spacingStyle?.selector || ''}` : `:root :where(${selector}-${className})${spacingStyle?.selector || ''}`;
|
|
383
389
|
}
|
|
384
390
|
ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
|
|
385
391
|
}
|
|
@@ -444,14 +450,20 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
444
450
|
if (styles) {
|
|
445
451
|
nodes.push({
|
|
446
452
|
styles,
|
|
447
|
-
selector: ROOT_BLOCK_SELECTOR
|
|
453
|
+
selector: ROOT_BLOCK_SELECTOR,
|
|
454
|
+
// Root selector (body) styles should not be wrapped in `:root where()` to keep
|
|
455
|
+
// specificity at (0,0,1) and maintain backwards compatibility.
|
|
456
|
+
skipSelectorWrapper: true
|
|
448
457
|
});
|
|
449
458
|
}
|
|
450
459
|
Object.entries(ELEMENTS).forEach(([name, selector]) => {
|
|
451
460
|
if (tree.styles?.elements?.[name]) {
|
|
452
461
|
nodes.push({
|
|
453
462
|
styles: tree.styles?.elements?.[name],
|
|
454
|
-
selector
|
|
463
|
+
selector,
|
|
464
|
+
// Top level elements that don't use a class name should not receive the
|
|
465
|
+
// `:root :where()` wrapper to maintain backwards compatibility.
|
|
466
|
+
skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name]
|
|
455
467
|
});
|
|
456
468
|
}
|
|
457
469
|
});
|
|
@@ -665,7 +677,8 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGa
|
|
|
665
677
|
fallbackGapValue,
|
|
666
678
|
hasLayoutSupport,
|
|
667
679
|
featureSelectors,
|
|
668
|
-
styleVariationSelectors
|
|
680
|
+
styleVariationSelectors,
|
|
681
|
+
skipSelectorWrapper
|
|
669
682
|
}) => {
|
|
670
683
|
// Process styles for block support features with custom feature level
|
|
671
684
|
// CSS selectors set.
|
|
@@ -706,7 +719,8 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGa
|
|
|
706
719
|
// Process the remaining block styles (they use either normal block class or __experimentalSelector).
|
|
707
720
|
const styleDeclarations = getStylesDeclarations(styles, selector, useRootPaddingAlign, tree, disableRootPadding);
|
|
708
721
|
if (styleDeclarations?.length) {
|
|
709
|
-
|
|
722
|
+
const generalSelector = skipSelectorWrapper ? selector : `:root :where(${selector})`;
|
|
723
|
+
ruleset += `${generalSelector}{${styleDeclarations.join(';')};}`;
|
|
710
724
|
}
|
|
711
725
|
if (styles?.css) {
|
|
712
726
|
ruleset += processCSSNesting(styles.css, `:root :where(${selector})`);
|
|
@@ -756,7 +770,12 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGa
|
|
|
756
770
|
// Split and append pseudo selector to create
|
|
757
771
|
// the proper rules to target the elements.
|
|
758
772
|
const _selector = selector.split(',').map(sel => sel + pseudoKey).join(',');
|
|
759
|
-
|
|
773
|
+
|
|
774
|
+
// As pseudo classes such as :hover, :focus etc. have class-level
|
|
775
|
+
// specificity, they must use the `:root :where()` wrapper. This.
|
|
776
|
+
// caps the specificity at `0-1-0` to allow proper nesting of variations
|
|
777
|
+
// and block type element styles.
|
|
778
|
+
const pseudoRule = `:root :where(${_selector}){${pseudoDeclarations.join(';')};}`;
|
|
760
779
|
ruleset += pseudoRule;
|
|
761
780
|
});
|
|
762
781
|
}
|
|
@@ -885,10 +904,16 @@ function updateConfigWithSeparator(config) {
|
|
|
885
904
|
}
|
|
886
905
|
export function processCSSNesting(css, blockSelector) {
|
|
887
906
|
let processedCSS = '';
|
|
907
|
+
if (!css || css.trim() === '') {
|
|
908
|
+
return processedCSS;
|
|
909
|
+
}
|
|
888
910
|
|
|
889
911
|
// Split CSS nested rules.
|
|
890
912
|
const parts = css.split('&');
|
|
891
913
|
parts.forEach(part => {
|
|
914
|
+
if (!part || part.trim() === '') {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
892
917
|
const isRootCss = !part.includes('{');
|
|
893
918
|
if (isRootCss) {
|
|
894
919
|
// If the part doesn't contain braces, it applies to the root level.
|
|
@@ -900,8 +925,27 @@ export function processCSSNesting(css, blockSelector) {
|
|
|
900
925
|
return;
|
|
901
926
|
}
|
|
902
927
|
const [nestedSelector, cssValue] = splittedPart;
|
|
903
|
-
|
|
904
|
-
|
|
928
|
+
|
|
929
|
+
// Handle pseudo elements such as ::before, ::after, etc. Regex will also
|
|
930
|
+
// capture any leading combinator such as >, +, or ~, as well as spaces.
|
|
931
|
+
// This allows pseudo elements as descendants e.g. `.parent ::before`.
|
|
932
|
+
const matches = nestedSelector.match(/([>+~\s]*::[a-zA-Z-]+)/);
|
|
933
|
+
const pseudoPart = matches ? matches[1] : '';
|
|
934
|
+
const withoutPseudoElement = matches ? nestedSelector.replace(pseudoPart, '').trim() : nestedSelector.trim();
|
|
935
|
+
let combinedSelector;
|
|
936
|
+
if (withoutPseudoElement === '') {
|
|
937
|
+
// Only contained a pseudo element to use the block selector to form
|
|
938
|
+
// the final `:root :where()` selector.
|
|
939
|
+
combinedSelector = blockSelector;
|
|
940
|
+
} else {
|
|
941
|
+
// If the nested selector is a descendant of the block scope it with the
|
|
942
|
+
// block selector. Otherwise append it to the block selector.
|
|
943
|
+
combinedSelector = nestedSelector.startsWith(' ') ? scopeSelector(blockSelector, withoutPseudoElement) : appendToSelector(blockSelector, withoutPseudoElement);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
// Build final rule, re-adding any pseudo element outside the `:where()`
|
|
947
|
+
// to maintain valid CSS selector.
|
|
948
|
+
processedCSS += `:root :where(${combinedSelector})${pseudoPart}{${cssValue.trim()}}`;
|
|
905
949
|
}
|
|
906
950
|
});
|
|
907
951
|
return processedCSS;
|