@wordpress/block-editor 12.10.1 → 12.10.3

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.
Files changed (60) hide show
  1. package/build/components/block-patterns-list/index.js +2 -2
  2. package/build/components/block-patterns-list/index.js.map +1 -1
  3. package/build/components/block-patterns-paging/index.js +1 -1
  4. package/build/components/block-patterns-paging/index.js.map +1 -1
  5. package/build/components/global-styles/hooks.js +1 -1
  6. package/build/components/global-styles/hooks.js.map +1 -1
  7. package/build/components/global-styles/use-global-styles-output.js +17 -5
  8. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  9. package/build/components/global-styles/utils.js +22 -0
  10. package/build/components/global-styles/utils.js.map +1 -1
  11. package/build/components/inserter/block-patterns-explorer/patterns-list.js +3 -3
  12. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  13. package/build/components/inserter/block-patterns-tab.js +1 -1
  14. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  15. package/build/components/inserter/search-results.js +1 -1
  16. package/build/components/inserter/search-results.js.map +1 -1
  17. package/build/components/link-control/search-item.js +36 -1
  18. package/build/components/link-control/search-item.js.map +1 -1
  19. package/build/components/tool-selector/index.js +2 -1
  20. package/build/components/tool-selector/index.js.map +1 -1
  21. package/build/hooks/block-rename-ui.js +5 -2
  22. package/build/hooks/block-rename-ui.js.map +1 -1
  23. package/build-module/components/block-patterns-list/index.js +2 -2
  24. package/build-module/components/block-patterns-list/index.js.map +1 -1
  25. package/build-module/components/block-patterns-paging/index.js +1 -1
  26. package/build-module/components/block-patterns-paging/index.js.map +1 -1
  27. package/build-module/components/global-styles/hooks.js +1 -1
  28. package/build-module/components/global-styles/hooks.js.map +1 -1
  29. package/build-module/components/global-styles/use-global-styles-output.js +17 -6
  30. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  31. package/build-module/components/global-styles/utils.js +21 -0
  32. package/build-module/components/global-styles/utils.js.map +1 -1
  33. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +4 -4
  34. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  35. package/build-module/components/inserter/block-patterns-tab.js +1 -1
  36. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  37. package/build-module/components/inserter/search-results.js +1 -1
  38. package/build-module/components/inserter/search-results.js.map +1 -1
  39. package/build-module/components/link-control/search-item.js +37 -2
  40. package/build-module/components/link-control/search-item.js.map +1 -1
  41. package/build-module/components/tool-selector/index.js +2 -1
  42. package/build-module/components/tool-selector/index.js.map +1 -1
  43. package/build-module/hooks/block-rename-ui.js +5 -2
  44. package/build-module/hooks/block-rename-ui.js.map +1 -1
  45. package/build-style/style-rtl.css +1 -0
  46. package/build-style/style.css +1 -0
  47. package/package.json +32 -32
  48. package/src/components/block-patterns-list/index.js +2 -4
  49. package/src/components/block-patterns-paging/index.js +57 -54
  50. package/src/components/global-styles/hooks.js +1 -1
  51. package/src/components/global-styles/test/use-global-styles-output.js +39 -0
  52. package/src/components/global-styles/use-global-styles-output.js +26 -6
  53. package/src/components/global-styles/utils.js +21 -0
  54. package/src/components/inserter/block-patterns-explorer/patterns-list.js +11 -9
  55. package/src/components/inserter/block-patterns-tab.js +1 -1
  56. package/src/components/inserter/search-results.js +1 -1
  57. package/src/components/inserter/style.scss +1 -0
  58. package/src/components/link-control/search-item.js +55 -2
  59. package/src/components/tool-selector/index.js +1 -1
  60. package/src/hooks/block-rename-ui.js +14 -10
@@ -1 +1 @@
1
- {"version":3,"names":["createHigherOrderComponent","useInstanceId","addFilter","__","sprintf","getBlockSupport","MenuItem","__experimentalHStack","HStack","__experimentalVStack","VStack","Button","TextControl","Modal","useState","speak","BlockSettingsMenuControls","useBlockDisplayInformation","InspectorControls","emptyString","testString","trim","length","RenameModal","blockName","originalBlockName","onClose","onSave","editedBlockName","setEditedBlockName","nameHasChanged","nameIsOriginal","nameIsEmpty","isNameValid","autoSelectInputText","event","target","select","dialogDescription","handleSubmit","createElement","title","onRequestClose","overlayClassName","aria","describedby","focusOnMount","id","onSubmit","e","preventDefault","spacing","__nextHasNoMarginBottom","value","label","hideLabelFromVision","placeholder","onChange","onFocus","justify","variant","onClick","type","BlockRenameControl","props","renamingBlock","setRenamingBlock","clientId","customName","blockInformation","Fragment","group","selectedClientIds","canRename","newName","undefined","withBlockRenameControl","BlockEdit","name","attributes","setAttributes","metaDataSupport","supportsBlockNaming","metadata","key"],"sources":["@wordpress/block-editor/src/hooks/block-rename-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\tMenuItem,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n\tModal,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\tuseBlockDisplayInformation,\n\tInspectorControls,\n} from '../components';\n\nconst emptyString = ( testString ) => testString?.trim()?.length === 0;\n\nfunction RenameModal( { blockName, originalBlockName, onClose, onSave } ) {\n\tconst [ editedBlockName, setEditedBlockName ] = useState( blockName );\n\n\tconst nameHasChanged = editedBlockName !== blockName;\n\tconst nameIsOriginal = editedBlockName === originalBlockName;\n\tconst nameIsEmpty = emptyString( editedBlockName );\n\n\tconst isNameValid = nameHasChanged || nameIsOriginal;\n\n\tconst autoSelectInputText = ( event ) => event.target.select();\n\n\tconst dialogDescription = useInstanceId(\n\t\tRenameModal,\n\t\t`block-editor-rename-modal__description`\n\t);\n\n\tconst handleSubmit = () => {\n\t\t// Must be assertive to immediately announce change.\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %1$s: type of update (either reset of changed). %2$s: new name/label for the block */\n\t\t\t\t__( 'Block name %1$s to: \"%2$s\".' ),\n\t\t\t\tnameIsOriginal || nameIsEmpty ? __( 'reset' ) : __( 'changed' ),\n\t\t\t\teditedBlockName\n\t\t\t),\n\t\t\t'assertive'\n\t\t);\n\n\t\tonSave( editedBlockName );\n\n\t\t// Immediate close avoids ability to hit save multiple times.\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-rename-modal\"\n\t\t\taria={ {\n\t\t\t\tdescribedby: dialogDescription,\n\t\t\t} }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t>\n\t\t\t<p id={ dialogDescription }>\n\t\t\t\t{ __( 'Enter a custom name for this block.' ) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif ( ! isNameValid ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thandleSubmit();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ editedBlockName }\n\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tplaceholder={ originalBlockName }\n\t\t\t\t\t\tonChange={ setEditedBlockName }\n\t\t\t\t\t\tonFocus={ autoSelectInputText }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-disabled={ ! isNameValid }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n\nfunction BlockRenameControl( props ) {\n\tconst [ renamingBlock, setRenamingBlock ] = useState( false );\n\n\tconst { clientId, customName, onChange } = props;\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\tvalue={ customName || '' }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { selectedClientIds } ) => {\n\t\t\t\t\t// Only enabled for single selections.\n\t\t\t\t\tconst canRename =\n\t\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\t\tclientId === selectedClientIds[ 0 ];\n\n\t\t\t\t\t// This check ensures the `BlockSettingsMenuControls` fill\n\t\t\t\t\t// doesn't render multiple times and also that it renders for\n\t\t\t\t\t// the block from which the menu was triggered.\n\t\t\t\t\tif ( ! canRename ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenamingBlock( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-expanded={ renamingBlock }\n\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</BlockSettingsMenuControls>\n\n\t\t\t{ renamingBlock && (\n\t\t\t\t<RenameModal\n\t\t\t\t\tblockName={ customName || '' }\n\t\t\t\t\toriginalBlockName={ blockInformation?.title }\n\t\t\t\t\tonClose={ () => setRenamingBlock( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\t// If the new value is the block's original name (e.g. `Group`)\n\t\t\t\t\t\t// or it is an empty string then assume the intent is to reset\n\t\t\t\t\t\t// the value. Therefore reset the metadata.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnewName === blockInformation?.title ||\n\t\t\t\t\t\t\temptyString( newName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewName = undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const withBlockRenameControl = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { clientId, name, attributes, setAttributes } = props;\n\n\t\tconst metaDataSupport = getBlockSupport(\n\t\t\tname,\n\t\t\t'__experimentalMetadata',\n\t\t\tfalse\n\t\t);\n\n\t\tconst supportsBlockNaming = !! (\n\t\t\ttrue === metaDataSupport || metaDataSupport?.name\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ supportsBlockNaming && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockRenameControl\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tcustomName={ attributes?.metadata?.name }\n\t\t\t\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t...( attributes?.metadata &&\n\t\t\t\t\t\t\t\t\t\t\tattributes?.metadata ),\n\t\t\t\t\t\t\t\t\t\tname: newName,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-rename-ui/with-block-rename-control',\n\twithBlockRenameControl\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC,QAAQ,EACRC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,MAAM,EACNC,WAAW,EACXC,KAAK,QACC,uBAAuB;AAC9B,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,SACCC,yBAAyB,EACzBC,0BAA0B,EAC1BC,iBAAiB,QACX,eAAe;AAEtB,MAAMC,WAAW,GAAKC,UAAU,IAAMA,UAAU,EAAEC,IAAI,CAAC,CAAC,EAAEC,MAAM,KAAK,CAAC;AAEtE,SAASC,WAAWA,CAAE;EAAEC,SAAS;EAAEC,iBAAiB;EAAEC,OAAO;EAAEC;AAAO,CAAC,EAAG;EACzE,MAAM,CAAEC,eAAe,EAAEC,kBAAkB,CAAE,GAAGf,QAAQ,CAAEU,SAAU,CAAC;EAErE,MAAMM,cAAc,GAAGF,eAAe,KAAKJ,SAAS;EACpD,MAAMO,cAAc,GAAGH,eAAe,KAAKH,iBAAiB;EAC5D,MAAMO,WAAW,GAAGb,WAAW,CAAES,eAAgB,CAAC;EAElD,MAAMK,WAAW,GAAGH,cAAc,IAAIC,cAAc;EAEpD,MAAMG,mBAAmB,GAAKC,KAAK,IAAMA,KAAK,CAACC,MAAM,CAACC,MAAM,CAAC,CAAC;EAE9D,MAAMC,iBAAiB,GAAGrC,aAAa,CACtCsB,WAAW,EACV,wCACF,CAA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AAC,EACD,qBACD,CAAC;AAED9D,SAAS,CACR,kBAAkB,EAClB,gDAAgD,EAChD0E,sBACD,CAAC"}
1
+ {"version":3,"names":["createHigherOrderComponent","useInstanceId","addFilter","__","sprintf","getBlockSupport","MenuItem","__experimentalHStack","HStack","__experimentalVStack","VStack","Button","TextControl","Modal","useState","speak","BlockSettingsMenuControls","useBlockDisplayInformation","InspectorControls","emptyString","testString","trim","length","RenameModal","blockName","originalBlockName","onClose","onSave","editedBlockName","setEditedBlockName","nameHasChanged","nameIsOriginal","nameIsEmpty","isNameValid","autoSelectInputText","event","target","select","dialogDescription","handleSubmit","message","createElement","title","onRequestClose","overlayClassName","aria","describedby","focusOnMount","id","onSubmit","e","preventDefault","spacing","__nextHasNoMarginBottom","value","label","hideLabelFromVision","placeholder","onChange","onFocus","justify","variant","onClick","type","BlockRenameControl","props","renamingBlock","setRenamingBlock","clientId","customName","blockInformation","Fragment","group","selectedClientIds","canRename","newName","undefined","withBlockRenameControl","BlockEdit","name","attributes","setAttributes","metaDataSupport","supportsBlockNaming","metadata","key"],"sources":["@wordpress/block-editor/src/hooks/block-rename-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\tMenuItem,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n\tModal,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\tuseBlockDisplayInformation,\n\tInspectorControls,\n} from '../components';\n\nconst emptyString = ( testString ) => testString?.trim()?.length === 0;\n\nfunction RenameModal( { blockName, originalBlockName, onClose, onSave } ) {\n\tconst [ editedBlockName, setEditedBlockName ] = useState( blockName );\n\n\tconst nameHasChanged = editedBlockName !== blockName;\n\tconst nameIsOriginal = editedBlockName === originalBlockName;\n\tconst nameIsEmpty = emptyString( editedBlockName );\n\n\tconst isNameValid = nameHasChanged || nameIsOriginal;\n\n\tconst autoSelectInputText = ( event ) => event.target.select();\n\n\tconst dialogDescription = useInstanceId(\n\t\tRenameModal,\n\t\t`block-editor-rename-modal__description`\n\t);\n\n\tconst handleSubmit = () => {\n\t\tconst message =\n\t\t\tnameIsOriginal || nameIsEmpty\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name reset to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name changed to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t );\n\n\t\t// Must be assertive to immediately announce change.\n\t\tspeak( message, 'assertive' );\n\t\tonSave( editedBlockName );\n\n\t\t// Immediate close avoids ability to hit save multiple times.\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-rename-modal\"\n\t\t\taria={ {\n\t\t\t\tdescribedby: dialogDescription,\n\t\t\t} }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t>\n\t\t\t<p id={ dialogDescription }>\n\t\t\t\t{ __( 'Enter a custom name for this block.' ) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif ( ! isNameValid ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thandleSubmit();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ editedBlockName }\n\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tplaceholder={ originalBlockName }\n\t\t\t\t\t\tonChange={ setEditedBlockName }\n\t\t\t\t\t\tonFocus={ autoSelectInputText }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-disabled={ ! isNameValid }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n\nfunction BlockRenameControl( props ) {\n\tconst [ renamingBlock, setRenamingBlock ] = useState( false );\n\n\tconst { clientId, customName, onChange } = props;\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\tvalue={ customName || '' }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { selectedClientIds } ) => {\n\t\t\t\t\t// Only enabled for single selections.\n\t\t\t\t\tconst canRename =\n\t\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\t\tclientId === selectedClientIds[ 0 ];\n\n\t\t\t\t\t// This check ensures the `BlockSettingsMenuControls` fill\n\t\t\t\t\t// doesn't render multiple times and also that it renders for\n\t\t\t\t\t// the block from which the menu was triggered.\n\t\t\t\t\tif ( ! canRename ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenamingBlock( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-expanded={ renamingBlock }\n\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</BlockSettingsMenuControls>\n\n\t\t\t{ renamingBlock && (\n\t\t\t\t<RenameModal\n\t\t\t\t\tblockName={ customName || '' }\n\t\t\t\t\toriginalBlockName={ blockInformation?.title }\n\t\t\t\t\tonClose={ () => setRenamingBlock( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\t// If the new value is the block's original name (e.g. `Group`)\n\t\t\t\t\t\t// or it is an empty string then assume the intent is to reset\n\t\t\t\t\t\t// the value. Therefore reset the metadata.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnewName === blockInformation?.title ||\n\t\t\t\t\t\t\temptyString( newName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewName = undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const withBlockRenameControl = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { clientId, name, attributes, setAttributes } = props;\n\n\t\tconst metaDataSupport = getBlockSupport(\n\t\t\tname,\n\t\t\t'__experimentalMetadata',\n\t\t\tfalse\n\t\t);\n\n\t\tconst supportsBlockNaming = !! (\n\t\t\ttrue === metaDataSupport || metaDataSupport?.name\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ supportsBlockNaming && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockRenameControl\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tcustomName={ attributes?.metadata?.name }\n\t\t\t\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t...( attributes?.metadata &&\n\t\t\t\t\t\t\t\t\t\t\tattributes?.metadata ),\n\t\t\t\t\t\t\t\t\t\tname: newName,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-rename-ui/with-block-rename-control',\n\twithBlockRenameControl\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC,QAAQ,EACRC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,MAAM,EACNC,WAAW,EACXC,KAAK,QACC,uBAAuB;AAC9B,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,SACCC,yBAAyB,EACzBC,0BAA0B,EAC1BC,iBAAiB,QACX,eAAe;AAEtB,MAAMC,WAAW,GAAKC,UAAU,IAAMA,UAAU,EAAEC,IAAI,CAAC,CAAC,EAAEC,MAAM,KAAK,CAAC;AAEtE,SAASC,WAAWA,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AKD,eAAe,IAAIA,eAAe,EAAEH,IAAI,CACjD;EAED,OACCtC,aAAA,CAAA8B,QAAA,QACGY,mBAAmB,IACpB1C,aAAA,CAAA8B,QAAA,QACC9B,aAAA,CAACuB,kBAAkB;IAClBI,QAAQ,EAAGA,QAAU;IACrBC,UAAU,EAAGW,UAAU,EAAEI,QAAQ,EAAEL,IAAM;IACzCrB,QAAQ,EAAKiB,OAAO,IAAM;MACzBM,aAAa,CAAE;QACdG,QAAQ,EAAE;UACT,IAAKJ,UAAU,EAAEI,QAAQ,IACxBJ,UAAU,EAAEI,QAAQ,CAAE;UACvBL,IAAI,EAAEJ;QACP;MACD,CAAE,CAAC;IACJ;EAAG,CACH,CACA,CACF,EAEDlC,aAAA,CAACqC,SAAS;IAACO,GAAG,EAAC,MAAM;IAAA,GAAMpB;EAAK,CAAI,CACnC,CAAC;AAEL,CAAC,EACD,qBACD,CAAC;AAED/D,SAAS,CACR,kBAAkB,EAClB,gDAAgD,EAChD2E,sBACD,CAAC"}
@@ -4014,6 +4014,7 @@
4014
4014
  display: grid;
4015
4015
  grid-gap: 32px;
4016
4016
  grid-template-columns: repeat(1, 1fr);
4017
+ margin-bottom: 16px;
4017
4018
  }
4018
4019
  @media (min-width: 1080px) {
4019
4020
  .block-editor-block-patterns-explorer .block-editor-block-patterns-list {
@@ -4015,6 +4015,7 @@
4015
4015
  display: grid;
4016
4016
  grid-gap: 32px;
4017
4017
  grid-template-columns: repeat(1, 1fr);
4018
+ margin-bottom: 16px;
4018
4019
  }
4019
4020
  @media (min-width: 1080px) {
4020
4021
  .block-editor-block-patterns-explorer .block-editor-block-patterns-list {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "12.10.1",
3
+ "version": "12.10.3",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -35,36 +35,36 @@
35
35
  "@emotion/react": "^11.7.1",
36
36
  "@emotion/styled": "^11.6.0",
37
37
  "@react-spring/web": "^9.4.5",
38
- "@wordpress/a11y": "^3.42.1",
39
- "@wordpress/api-fetch": "^6.39.1",
40
- "@wordpress/blob": "^3.42.1",
41
- "@wordpress/blocks": "^12.19.1",
42
- "@wordpress/commands": "^0.13.1",
43
- "@wordpress/components": "^25.8.1",
44
- "@wordpress/compose": "^6.19.1",
45
- "@wordpress/data": "^9.12.1",
46
- "@wordpress/date": "^4.42.1",
47
- "@wordpress/deprecated": "^3.42.1",
48
- "@wordpress/dom": "^3.42.1",
49
- "@wordpress/element": "^5.19.1",
50
- "@wordpress/escape-html": "^2.42.1",
51
- "@wordpress/hooks": "^3.42.1",
52
- "@wordpress/html-entities": "^3.42.1",
53
- "@wordpress/i18n": "^4.42.1",
54
- "@wordpress/icons": "^9.33.1",
55
- "@wordpress/is-shallow-equal": "^4.42.1",
56
- "@wordpress/keyboard-shortcuts": "^4.19.1",
57
- "@wordpress/keycodes": "^3.42.1",
58
- "@wordpress/notices": "^4.10.1",
59
- "@wordpress/preferences": "^3.19.1",
60
- "@wordpress/private-apis": "^0.24.1",
61
- "@wordpress/rich-text": "^6.19.1",
62
- "@wordpress/shortcode": "^3.42.1",
63
- "@wordpress/style-engine": "^1.25.1",
64
- "@wordpress/token-list": "^2.42.1",
65
- "@wordpress/url": "^3.43.1",
66
- "@wordpress/warning": "^2.42.1",
67
- "@wordpress/wordcount": "^3.42.1",
38
+ "@wordpress/a11y": "^3.42.3",
39
+ "@wordpress/api-fetch": "^6.39.3",
40
+ "@wordpress/blob": "^3.42.3",
41
+ "@wordpress/blocks": "^12.19.3",
42
+ "@wordpress/commands": "^0.13.3",
43
+ "@wordpress/components": "^25.8.3",
44
+ "@wordpress/compose": "^6.19.3",
45
+ "@wordpress/data": "^9.12.3",
46
+ "@wordpress/date": "^4.42.3",
47
+ "@wordpress/deprecated": "^3.42.3",
48
+ "@wordpress/dom": "^3.42.3",
49
+ "@wordpress/element": "^5.19.3",
50
+ "@wordpress/escape-html": "^2.42.3",
51
+ "@wordpress/hooks": "^3.42.3",
52
+ "@wordpress/html-entities": "^3.42.3",
53
+ "@wordpress/i18n": "^4.42.3",
54
+ "@wordpress/icons": "^9.33.3",
55
+ "@wordpress/is-shallow-equal": "^4.42.3",
56
+ "@wordpress/keyboard-shortcuts": "^4.19.3",
57
+ "@wordpress/keycodes": "^3.42.3",
58
+ "@wordpress/notices": "^4.10.3",
59
+ "@wordpress/preferences": "^3.19.3",
60
+ "@wordpress/private-apis": "^0.24.3",
61
+ "@wordpress/rich-text": "^6.19.3",
62
+ "@wordpress/shortcode": "^3.42.3",
63
+ "@wordpress/style-engine": "^1.25.3",
64
+ "@wordpress/token-list": "^2.42.3",
65
+ "@wordpress/url": "^3.43.3",
66
+ "@wordpress/warning": "^2.42.3",
67
+ "@wordpress/wordcount": "^3.42.3",
68
68
  "change-case": "^4.1.2",
69
69
  "classnames": "^2.3.1",
70
70
  "colord": "^2.7.0",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "4987d16acb5c41b62704dc4f88225acb97ddd698"
89
+ "gitHead": "6256f93c37705d142f75a99f1fc808540ca7dca8"
90
90
  }
@@ -149,7 +149,7 @@ function BlockPatternList(
149
149
  onHover,
150
150
  onClickPattern,
151
151
  orientation,
152
- label = __( 'Block Patterns' ),
152
+ label = __( 'Block patterns' ),
153
153
  showTitlesAsTooltip,
154
154
  pagingProps,
155
155
  },
@@ -180,9 +180,7 @@ function BlockPatternList(
180
180
  <BlockPatternPlaceholder key={ pattern.name } />
181
181
  );
182
182
  } ) }
183
- { pagingProps && pagingProps.numPages > 1 && (
184
- <BlockPatternsPaging { ...pagingProps } />
185
- ) }
183
+ { pagingProps && <BlockPatternsPaging { ...pagingProps } /> }
186
184
  </Composite>
187
185
  );
188
186
  }
@@ -27,66 +27,69 @@ export default function Pagination( {
27
27
  )
28
28
  }
29
29
  </Text>
30
- <HStack
31
- expanded={ false }
32
- spacing={ 3 }
33
- justify="flex-start"
34
- className="block-editor-patterns__grid-pagination"
35
- >
36
- <HStack
37
- expanded={ false }
38
- spacing={ 1 }
39
- className="block-editor-patterns__grid-pagination-previous"
40
- >
41
- <Button
42
- variant="tertiary"
43
- onClick={ () => changePage( 1 ) }
44
- disabled={ currentPage === 1 }
45
- aria-label={ __( 'First page' ) }
46
- >
47
- <span>«</span>
48
- </Button>
49
- <Button
50
- variant="tertiary"
51
- onClick={ () => changePage( currentPage - 1 ) }
52
- disabled={ currentPage === 1 }
53
- aria-label={ __( 'Previous page' ) }
54
- >
55
- <span>‹</span>
56
- </Button>
57
- </HStack>
58
- <Text variant="muted">
59
- { sprintf(
60
- // translators: %1$s: Current page number, %2$s: Total number of pages.
61
- _x( '%1$s of %2$s', 'paging' ),
62
- currentPage,
63
- numPages
64
- ) }
65
- </Text>
30
+
31
+ { numPages > 1 && (
66
32
  <HStack
67
33
  expanded={ false }
68
- spacing={ 1 }
69
- className="block-editor-patterns__grid-pagination-next"
34
+ spacing={ 3 }
35
+ justify="flex-start"
36
+ className="block-editor-patterns__grid-pagination"
70
37
  >
71
- <Button
72
- variant="tertiary"
73
- onClick={ () => changePage( currentPage + 1 ) }
74
- disabled={ currentPage === numPages }
75
- aria-label={ __( 'Next page' ) }
38
+ <HStack
39
+ expanded={ false }
40
+ spacing={ 1 }
41
+ className="block-editor-patterns__grid-pagination-previous"
76
42
  >
77
- <span>›</span>
78
- </Button>
79
- <Button
80
- variant="tertiary"
81
- onClick={ () => changePage( numPages ) }
82
- disabled={ currentPage === numPages }
83
- aria-label={ __( 'Last page' ) }
84
- size="default"
43
+ <Button
44
+ variant="tertiary"
45
+ onClick={ () => changePage( 1 ) }
46
+ disabled={ currentPage === 1 }
47
+ aria-label={ __( 'First page' ) }
48
+ >
49
+ <span>«</span>
50
+ </Button>
51
+ <Button
52
+ variant="tertiary"
53
+ onClick={ () => changePage( currentPage - 1 ) }
54
+ disabled={ currentPage === 1 }
55
+ aria-label={ __( 'Previous page' ) }
56
+ >
57
+ <span>‹</span>
58
+ </Button>
59
+ </HStack>
60
+ <Text variant="muted">
61
+ { sprintf(
62
+ // translators: %1$s: Current page number, %2$s: Total number of pages.
63
+ _x( '%1$s of %2$s', 'paging' ),
64
+ currentPage,
65
+ numPages
66
+ ) }
67
+ </Text>
68
+ <HStack
69
+ expanded={ false }
70
+ spacing={ 1 }
71
+ className="block-editor-patterns__grid-pagination-next"
85
72
  >
86
- <span>»</span>
87
- </Button>
73
+ <Button
74
+ variant="tertiary"
75
+ onClick={ () => changePage( currentPage + 1 ) }
76
+ disabled={ currentPage === numPages }
77
+ aria-label={ __( 'Next page' ) }
78
+ >
79
+ <span>›</span>
80
+ </Button>
81
+ <Button
82
+ variant="tertiary"
83
+ onClick={ () => changePage( numPages ) }
84
+ disabled={ currentPage === numPages }
85
+ aria-label={ __( 'Last page' ) }
86
+ size="default"
87
+ >
88
+ <span>»</span>
89
+ </Button>
90
+ </HStack>
88
91
  </HStack>
89
- </HStack>
92
+ ) }
90
93
  </VStack>
91
94
  );
92
95
  }
@@ -117,7 +117,7 @@ export function useGlobalSetting( propertyPath, blockName, source = 'all' ) {
117
117
  `settings${ appendedBlockPath }.${ setting }`
118
118
  ) ??
119
119
  getValueFromObjectPath( configToUse, `settings.${ setting }` );
120
- if ( value ) {
120
+ if ( value !== undefined ) {
121
121
  result = setImmutably( result, setting.split( '.' ), value );
122
122
  }
123
123
  } );
@@ -14,6 +14,7 @@ import {
14
14
  toCustomProperties,
15
15
  toStyles,
16
16
  getStylesDeclarations,
17
+ processCSSNesting,
17
18
  } from '../use-global-styles-output';
18
19
  import { ROOT_BLOCK_SELECTOR } from '../utils';
19
20
 
@@ -967,4 +968,42 @@ describe( 'global styles renderer', () => {
967
968
  ] );
968
969
  } );
969
970
  } );
971
+
972
+ describe( 'processCSSNesting', () => {
973
+ it( 'should return processed CSS without any nested selectors', () => {
974
+ expect(
975
+ processCSSNesting( 'color: red; margin: auto;', '.foo' )
976
+ ).toEqual( '.foo{color: red; margin: auto;}' );
977
+ } );
978
+ it( 'should return processed CSS with nested selectors', () => {
979
+ expect(
980
+ processCSSNesting(
981
+ 'color: red; margin: auto; &.one{color: blue;} & .two{color: green;}',
982
+ '.foo'
983
+ )
984
+ ).toEqual(
985
+ '.foo{color: red; margin: auto;}.foo.one{color: blue;}.foo .two{color: green;}'
986
+ );
987
+ } );
988
+ it( 'should return processed CSS with pseudo elements', () => {
989
+ expect(
990
+ processCSSNesting(
991
+ 'color: red; margin: auto; &::before{color: blue;} & ::before{color: green;} &.one::before{color: yellow;} & .two::before{color: purple;}',
992
+ '.foo'
993
+ )
994
+ ).toEqual(
995
+ '.foo{color: red; margin: auto;}.foo::before{color: blue;}.foo ::before{color: green;}.foo.one::before{color: yellow;}.foo .two::before{color: purple;}'
996
+ );
997
+ } );
998
+ it( 'should return processed CSS with multiple root selectors', () => {
999
+ expect(
1000
+ processCSSNesting(
1001
+ 'color: red; margin: auto; &.one{color: blue;} & .two{color: green;} &::before{color: yellow;} & ::before{color: purple;} &.three::before{color: orange;} & .four::before{color: skyblue;}',
1002
+ '.foo, .bar'
1003
+ )
1004
+ ).toEqual(
1005
+ '.foo, .bar{color: red; margin: auto;}.foo.one, .bar.one{color: blue;}.foo .two, .bar .two{color: green;}.foo::before, .bar::before{color: yellow;}.foo ::before, .bar ::before{color: purple;}.foo.three::before, .bar.three::before{color: orange;}.foo .four::before, .bar .four::before{color: skyblue;}'
1006
+ );
1007
+ } );
1008
+ } );
970
1009
  } );
@@ -15,7 +15,12 @@ import { getCSSRules } from '@wordpress/style-engine';
15
15
  /**
16
16
  * Internal dependencies
17
17
  */
18
- import { PRESET_METADATA, ROOT_BLOCK_SELECTOR, scopeSelector } from './utils';
18
+ import {
19
+ PRESET_METADATA,
20
+ ROOT_BLOCK_SELECTOR,
21
+ scopeSelector,
22
+ appendToSelector,
23
+ } from './utils';
19
24
  import { getBlockCSSSelector } from './get-block-css-selector';
20
25
  import {
21
26
  getTypographyFontSizeValue,
@@ -1124,18 +1129,33 @@ function updateConfigWithSeparator( config ) {
1124
1129
  return config;
1125
1130
  }
1126
1131
 
1127
- const processCSSNesting = ( css, blockSelector ) => {
1132
+ export function processCSSNesting( css, blockSelector ) {
1128
1133
  let processedCSS = '';
1129
1134
 
1130
1135
  // Split CSS nested rules.
1131
1136
  const parts = css.split( '&' );
1132
1137
  parts.forEach( ( part ) => {
1133
- processedCSS += ! part.includes( '{' )
1134
- ? blockSelector + '{' + part + '}' // If the part doesn't contain braces, it applies to the root level.
1135
- : blockSelector + part; // Prepend the selector, which effectively replaces the "&" character.
1138
+ const isRootCss = ! part.includes( '{' );
1139
+ if ( isRootCss ) {
1140
+ // If the part doesn't contain braces, it applies to the root level.
1141
+ processedCSS += `${ blockSelector }{${ part.trim() }}`;
1142
+ } else {
1143
+ // If the part contains braces, it's a nested CSS rule.
1144
+ const splittedPart = part.replace( '}', '' ).split( '{' );
1145
+ if ( splittedPart.length !== 2 ) {
1146
+ return;
1147
+ }
1148
+
1149
+ const [ nestedSelector, cssValue ] = splittedPart;
1150
+ const combinedSelector = nestedSelector.startsWith( ' ' )
1151
+ ? scopeSelector( blockSelector, nestedSelector )
1152
+ : appendToSelector( blockSelector, nestedSelector );
1153
+
1154
+ processedCSS += `${ combinedSelector }{${ cssValue.trim() }}`;
1155
+ }
1136
1156
  } );
1137
1157
  return processedCSS;
1138
- };
1158
+ }
1139
1159
 
1140
1160
  /**
1141
1161
  * Returns the global styles output using a global styles configuration.
@@ -393,6 +393,27 @@ export function scopeSelector( scope, selector ) {
393
393
  return selectorsScoped.join( ', ' );
394
394
  }
395
395
 
396
+ /**
397
+ * Appends a sub-selector to an existing one.
398
+ *
399
+ * Given the compounded `selector` "h1, h2, h3"
400
+ * and the `toAppend` selector ".some-class" the result will be
401
+ * "h1.some-class, h2.some-class, h3.some-class".
402
+ *
403
+ * @param {string} selector Original selector.
404
+ * @param {string} toAppend Selector to append.
405
+ *
406
+ * @return {string} The new selector.
407
+ */
408
+ export function appendToSelector( selector, toAppend ) {
409
+ if ( ! selector.includes( ',' ) ) {
410
+ return selector + toAppend;
411
+ }
412
+ const selectors = selector.split( ',' );
413
+ const newSelectors = selectors.map( ( sel ) => sel + toAppend );
414
+ return newSelectors.join( ',' );
415
+ }
416
+
396
417
  /**
397
418
  * Compares global style variations according to their styles and settings properties.
398
419
  *
@@ -135,15 +135,17 @@ function PatternList( { searchValue, selectedCategory, patternCategories } ) {
135
135
 
136
136
  <InserterListbox>
137
137
  { hasItems && (
138
- <BlockPatternsList
139
- shownPatterns={ pagingProps.categoryPatternsAsyncList }
140
- blockPatterns={ pagingProps.categoryPatterns }
141
- onClickPattern={ onClickPattern }
142
- isDraggable={ false }
143
- />
144
- ) }
145
- { pagingProps.numPages > 1 && (
146
- <BlockPatternsPaging { ...pagingProps } />
138
+ <>
139
+ <BlockPatternsList
140
+ shownPatterns={
141
+ pagingProps.categoryPatternsAsyncList
142
+ }
143
+ blockPatterns={ pagingProps.categoryPatterns }
144
+ onClickPattern={ onClickPattern }
145
+ isDraggable={ false }
146
+ />
147
+ <BlockPatternsPaging { ...pagingProps } />
148
+ </>
147
149
  ) }
148
150
  </InserterListbox>
149
151
  </div>
@@ -42,7 +42,7 @@ const noop = () => {};
42
42
 
43
43
  export const allPatternsCategory = {
44
44
  name: 'allPatterns',
45
- label: __( 'All Patterns' ),
45
+ label: __( 'All patterns' ),
46
46
  };
47
47
 
48
48
  export const myPatternsCategory = {
@@ -184,7 +184,7 @@ function InserterSearchResults( {
184
184
  const patternsUI = !! filteredBlockPatterns.length && (
185
185
  <InserterPanel
186
186
  title={
187
- <VisuallyHidden>{ __( 'Block Patterns' ) }</VisuallyHidden>
187
+ <VisuallyHidden>{ __( 'Block patterns' ) }</VisuallyHidden>
188
188
  }
189
189
  >
190
190
  <div className="block-editor-inserter__quick-inserter-patterns">
@@ -480,6 +480,7 @@ $block-inserter-tabs-height: 44px;
480
480
  display: grid;
481
481
  grid-gap: $grid-unit-40;
482
482
  grid-template-columns: repeat(1, 1fr);
483
+ margin-bottom: $grid-unit-20;
483
484
 
484
485
  @include break-xlarge() {
485
486
  grid-template-columns: repeat(2, 1fr);
@@ -13,7 +13,8 @@ import {
13
13
  file,
14
14
  } from '@wordpress/icons';
15
15
  import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
16
- import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
16
+ import { safeDecodeURI, filterURLForDisplay, getPath } from '@wordpress/url';
17
+ import { pipe } from '@wordpress/compose';
17
18
 
18
19
  const ICONS_MAP = {
19
20
  post: postList,
@@ -44,6 +45,58 @@ function SearchItemIcon( { isURL, suggestion } ) {
44
45
  return null;
45
46
  }
46
47
 
48
+ /**
49
+ * Adds a leading slash to a url if it doesn't already have one.
50
+ * @param {string} url the url to add a leading slash to.
51
+ * @return {string} the url with a leading slash.
52
+ */
53
+ function addLeadingSlash( url ) {
54
+ const trimmedURL = url?.trim();
55
+
56
+ if ( ! trimmedURL?.length ) return url;
57
+
58
+ return url?.replace( /^\/?/, '/' );
59
+ }
60
+
61
+ function removeTrailingSlash( url ) {
62
+ const trimmedURL = url?.trim();
63
+
64
+ if ( ! trimmedURL?.length ) return url;
65
+
66
+ return url?.replace( /\/$/, '' );
67
+ }
68
+
69
+ const partialRight =
70
+ ( fn, ...partialArgs ) =>
71
+ ( ...args ) =>
72
+ fn( ...args, ...partialArgs );
73
+
74
+ const defaultTo = ( d ) => ( v ) => {
75
+ return v === null || v === undefined || v !== v ? d : v;
76
+ };
77
+
78
+ /**
79
+ * Prepares a URL for display in the UI.
80
+ * - decodes the URL.
81
+ * - filters it (removes protocol, www, etc.).
82
+ * - truncates it if necessary.
83
+ * - adds a leading slash.
84
+ * @param {string} url the url.
85
+ * @return {string} the processed url to display.
86
+ */
87
+ function getURLForDisplay( url ) {
88
+ if ( ! url ) return url;
89
+
90
+ return pipe(
91
+ safeDecodeURI,
92
+ getPath,
93
+ defaultTo( '' ),
94
+ partialRight( filterURLForDisplay, 24 ),
95
+ removeTrailingSlash,
96
+ addLeadingSlash
97
+ )( url );
98
+ }
99
+
47
100
  export const LinkControlSearchItem = ( {
48
101
  itemProps,
49
102
  suggestion,
@@ -54,7 +107,7 @@ export const LinkControlSearchItem = ( {
54
107
  } ) => {
55
108
  const info = isURL
56
109
  ? __( 'Press ENTER to add this link' )
57
- : filterURLForDisplay( safeDecodeURI( suggestion?.url ), 24 );
110
+ : getURLForDisplay( suggestion.url );
58
111
 
59
112
  return (
60
113
  <MenuItem
@@ -51,7 +51,7 @@ function ToolSelector( props, ref ) {
51
51
  label={ __( 'Tools' ) }
52
52
  />
53
53
  ) }
54
- popoverProps={ { placement: 'bottom-start' } }
54
+ popoverProps={ { placement: 'bottom-start', variant: undefined } }
55
55
  renderContent={ () => (
56
56
  <>
57
57
  <NavigableMenu role="menu" aria-label={ __( 'Tools' ) }>
@@ -44,17 +44,21 @@ function RenameModal( { blockName, originalBlockName, onClose, onSave } ) {
44
44
  );
45
45
 
46
46
  const handleSubmit = () => {
47
- // Must be assertive to immediately announce change.
48
- speak(
49
- sprintf(
50
- /* translators: %1$s: type of update (either reset of changed). %2$s: new name/label for the block */
51
- __( 'Block name %1$s to: "%2$s".' ),
52
- nameIsOriginal || nameIsEmpty ? __( 'reset' ) : __( 'changed' ),
53
- editedBlockName
54
- ),
55
- 'assertive'
56
- );
47
+ const message =
48
+ nameIsOriginal || nameIsEmpty
49
+ ? sprintf(
50
+ /* translators: %s: new name/label for the block */
51
+ __( 'Block name reset to: "%s".' ),
52
+ editedBlockName
53
+ )
54
+ : sprintf(
55
+ /* translators: %s: new name/label for the block */
56
+ __( 'Block name changed to: "%s".' ),
57
+ editedBlockName
58
+ );
57
59
 
60
+ // Must be assertive to immediately announce change.
61
+ speak( message, 'assertive' );
58
62
  onSave( editedBlockName );
59
63
 
60
64
  // Immediate close avoids ability to hit save multiple times.