@wordpress/block-editor 13.0.6 → 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.
@@ -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;
@@ -1 +1 @@
1
- {"version":3,"names":["_privateKeys","require","_lockUnlock","_constants","withRootClientIdOptionKey","exports","Symbol","checkAllowList","list","item","defaultResult","Array","isArray","includes","checkAllowListRecursive","blocks","allowedBlockTypes","blocksQueue","length","block","shift","isAllowed","name","blockName","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","select","state","settings","__experimentalBlockPatterns","__experimentalUserPatternCategories","__experimentalReusableBlocks","selectBlockPatternsKey","blockPatterns","unlock","STORE_NAME","getReusableBlocks","getInsertBlockTypeDependants","rootClientId","blockListSettings","byClientId","get","templateLock","blockEditingModes"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\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\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,YAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKO,MAAMG,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAGE,MAAM,CAAE,kBAAmB,CAAC;AAE9D,MAAMC,cAAc,GAAGA,CAAEC,IAAI,EAAEC,IAAI,EAAEC,aAAa,GAAG,IAAI,KAAM;EACrE,IAAK,OAAOF,IAAI,KAAK,SAAS,EAAG;IAChC,OAAOA,IAAI;EACZ;EACA,IAAKG,KAAK,CAACC,OAAO,CAAEJ,IAAK,CAAC,EAAG;IAC5B;IACA;IACA;IACA,IAAKA,IAAI,CAACK,QAAQ,CAAE,mBAAoB,CAAC,IAAIJ,IAAI,KAAK,IAAI,EAAG;MAC5D,OAAO,IAAI;IACZ;IACA,OAAOD,IAAI,CAACK,QAAQ,CAAEJ,IAAK,CAAC;EAC7B;EACA,OAAOC,aAAa;AACrB,CAAC;AAACL,OAAA,CAAAE,cAAA,GAAAA,cAAA;AAEK,MAAMO,uBAAuB,GAAGA,CAAEC,MAAM,EAAEC,iBAAiB,KAAM;EACvE,IAAK,OAAOA,iBAAiB,KAAK,SAAS,EAAG;IAC7C,OAAOA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Y,EAC3Bf,KAAK,CAACgB,iBAAiB,CACvB;AACF","ignoreList":[]}
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.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,wBAAwB,GAAKC,MAAM,IAAQC,KAAK,IAAM;EAClE,OAAO,CACNA,KAAK,CAACC,QAAQ,CAACC,2BAA2B,EAC1CF,KAAK,CAACC,QAAQ,CAACE,mCAAmC,EAClDH,KAAK,CAACC,QAAQ,CAACG,4BAA4B,EAC3CJ,KAAK,CAACC,QAAQ,CAAEI,mCAAsB,CAAE,GAAIN,MAAO,CAAC,EACpDC,KAAK,CAACM,aAAa,EACnB,IAAAC,kBAAM,EAAER,MAAM,CAAES,qBAAW,CAAE,CAAC,CAACC,iBAAiB,CAAC,CAAC,CAClD;AACF,CAAC;AAAClD,OAAA,CAAAuC,wBAAA,GAAAA,wBAAA;AAEK,SAASY,4BAA4BA,CAAEV,KAAK,EAAEW,YAAY,EAAG;EACnE,OAAO,CACNX,KAAK,CAACY,iBAAiB,CAAED,YAAY,CAAE,EACvCX,KAAK,CAACnC,MAAM,CAACgD,UAAU,CAACnC,GAAG,CAAEiC,YAAa,CAAC,EAC3CX,KAAK,CAACC,QAAQ,CAACb,iBAAiB,EAChCY,KAAK,CAACC,QAAQ,CAACa,YAAY,EAC3Bd,KAAK,CAACe,iBAAiB,CACvB;AACF","ignoreList":[]}
@@ -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 */\n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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
+ {"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\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;AA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ACHpE,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":[]}
@@ -385,7 +385,7 @@ export function getLayoutStyles({
385
385
  // For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
386
386
  combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:where(.${className}${spacingStyle?.selector || ''})` : `:where(${selector}.${className}${spacingStyle?.selector || ''})`;
387
387
  } else {
388
- combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `.${className}${spacingStyle?.selector || ''}` : `${selector}-${className}${spacingStyle?.selector || ''}`;
388
+ combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:root :where(.${className})${spacingStyle?.selector || ''}` : `:root :where(${selector}-${className})${spacingStyle?.selector || ''}`;
389
389
  }
390
390
  ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
391
391
  }
@@ -450,7 +450,10 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
450
450
  if (styles) {
451
451
  nodes.push({
452
452
  styles,
453
- 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
454
457
  });
455
458
  }
456
459
  Object.entries(ELEMENTS).forEach(([name, selector]) => {
@@ -901,10 +904,16 @@ function updateConfigWithSeparator(config) {
901
904
  }
902
905
  export function processCSSNesting(css, blockSelector) {
903
906
  let processedCSS = '';
907
+ if (!css || css.trim() === '') {
908
+ return processedCSS;
909
+ }
904
910
 
905
911
  // Split CSS nested rules.
906
912
  const parts = css.split('&');
907
913
  parts.forEach(part => {
914
+ if (!part || part.trim() === '') {
915
+ return;
916
+ }
908
917
  const isRootCss = !part.includes('{');
909
918
  if (isRootCss) {
910
919
  // If the part doesn't contain braces, it applies to the root level.
@@ -916,8 +925,27 @@ export function processCSSNesting(css, blockSelector) {
916
925
  return;
917
926
  }
918
927
  const [nestedSelector, cssValue] = splittedPart;
919
- const combinedSelector = nestedSelector.startsWith(' ') ? scopeSelector(blockSelector, nestedSelector) : appendToSelector(blockSelector, nestedSelector);
920
- processedCSS += `:root :where(${combinedSelector}){${cssValue.trim()}}`;
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()}}`;
921
949
  }
922
950
  });
923
951
  return processedCSS;