@wordpress/block-editor 12.10.2 → 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.
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +17 -5
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +22 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/link-control/search-item.js +36 -1
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/tool-selector/index.js +2 -1
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/hooks/block-rename-ui.js +5 -2
- package/build/hooks/block-rename-ui.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +17 -6
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +21 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/link-control/search-item.js +37 -2
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/tool-selector/index.js +2 -1
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/hooks/block-rename-ui.js +5 -2
- package/build-module/hooks/block-rename-ui.js.map +1 -1
- package/package.json +32 -32
- package/src/components/global-styles/hooks.js +1 -1
- package/src/components/global-styles/test/use-global-styles-output.js +39 -0
- package/src/components/global-styles/use-global-styles-output.js +26 -6
- package/src/components/global-styles/utils.js +21 -0
- package/src/components/link-control/search-item.js +55 -2
- package/src/components/tool-selector/index.js +1 -1
- package/src/hooks/block-rename-ui.js +14 -10
|
@@ -40,7 +40,8 @@ function ToolSelector(props, ref) {
|
|
|
40
40
|
label: __('Tools')
|
|
41
41
|
}),
|
|
42
42
|
popoverProps: {
|
|
43
|
-
placement: 'bottom-start'
|
|
43
|
+
placement: 'bottom-start',
|
|
44
|
+
variant: undefined
|
|
44
45
|
},
|
|
45
46
|
renderContent: () => createElement(Fragment, null, createElement(NavigableMenu, {
|
|
46
47
|
role: "menu",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Dropdown","Button","MenuItemsChoice","SVG","Path","NavigableMenu","__","useSelect","useDispatch","forwardRef","Icon","edit","editIcon","store","blockEditorStore","selectIcon","createElement","xmlns","width","height","viewBox","d","ToolSelector","props","ref","mode","select","__unstableGetEditorMode","__unstableSetEditorMode","renderToggle","isOpen","onToggle","icon","onClick","label","popoverProps","placement","renderContent","Fragment","role","value","onSelect","choices","className"],"sources":["@wordpress/block-editor/src/components/tool-selector/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\tButton,\n\tMenuItemsChoice,\n\tSVG,\n\tPath,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, edit as editIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst selectIcon = (\n\t<SVG\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\twidth=\"24\"\n\t\theight=\"24\"\n\t\tviewBox=\"0 0 24 24\"\n\t>\n\t\t<Path d=\"M9.4 20.5L5.2 3.8l14.6 9-2 .3c-.2 0-.4.1-.7.1-.9.2-1.6.3-2.2.5-.8.3-1.4.5-1.8.8-.4.3-.8.8-1.3 1.5-.4.5-.8 1.2-1.2 2l-.3.6-.9 1.9zM7.6 7.1l2.4 9.3c.2-.4.5-.8.7-1.1.6-.8 1.1-1.4 1.6-1.8.5-.4 1.3-.8 2.2-1.1l1.2-.3-8.1-5z\" />\n\t</SVG>\n);\n\nfunction ToolSelector( props, ref ) {\n\tconst mode = useSelect(\n\t\t( select ) => select( blockEditorStore ).__unstableGetEditorMode(),\n\t\t[]\n\t);\n\tconst { __unstableSetEditorMode } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\ticon={ mode === 'navigation' ? selectIcon : editIcon }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\tlabel={ __( 'Tools' ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\trenderContent={ () => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu role=\"menu\" aria-label={ __( 'Tools' ) }>\n\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\tmode === 'navigation' ? 'navigation' : 'edit'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonSelect={ __unstableSetEditorMode }\n\t\t\t\t\t\t\tchoices={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'edit',\n\t\t\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ editIcon } />\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t\t\t\t</>\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\t{\n\t\t\t\t\t\t\t\t\tvalue: 'navigation',\n\t\t\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{ selectIcon }\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Select' ) }\n\t\t\t\t\t\t\t\t\t\t</>\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</NavigableMenu>\n\t\t\t\t\t<div className=\"block-editor-tool-selector__help\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Tools provide different interactions for selecting, navigating, and editing blocks. Toggle between select and edit by pressing Escape and Enter.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( ToolSelector );\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,QAAQ,EACRC,MAAM,EACNC,eAAe,EACfC,GAAG,EACHC,IAAI,EACJC,aAAa,QACP,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,EAAEC,IAAI,IAAIC,QAAQ,QAAQ,kBAAkB;;AAEzD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,MAAMC,UAAU,GACfC,aAAA,CAACb,GAAG;EACHc,KAAK,EAAC,4BAA4B;EAClCC,KAAK,EAAC,IAAI;EACVC,MAAM,EAAC,IAAI;EACXC,OAAO,EAAC;AAAW,GAEnBJ,aAAA,CAACZ,IAAI;EAACiB,CAAC,EAAC;AAA2N,CAAE,CACjO,CACL;AAED,SAASC,YAAYA,CAAEC,KAAK,EAAEC,GAAG,EAAG;EACnC,MAAMC,IAAI,GAAGlB,SAAS,CACnBmB,MAAM,IAAMA,MAAM,CAAEZ,gBAAiB,CAAC,CAACa,uBAAuB,CAAC,CAAC,EAClE,EACD,CAAC;EACD,MAAM;IAAEC;EAAwB,CAAC,GAAGpB,WAAW,CAAEM,gBAAiB,CAAC;EAEnE,OACCE,aAAA,CAAChB,QAAQ;IACR6B,YAAY,EAAGA,CAAE;MAAEC,MAAM;MAAEC;IAAS,CAAC,KACpCf,aAAA,CAACf,MAAM;MAAA,GACDsB,KAAK;MACVC,GAAG,EAAGA,GAAK;MACXQ,IAAI,EAAGP,IAAI,KAAK,YAAY,GAAGV,UAAU,GAAGH,QAAU;MACtD,iBAAgBkB,MAAQ;MACxB,iBAAc,MAAM;MACpBG,OAAO,EAAGF;MACV;MACAG,KAAK,EAAG5B,EAAE,CAAE,OAAQ;IAAG,CACvB,CACC;IACH6B,YAAY,EAAG;MAAEC,SAAS,EAAE;
|
|
1
|
+
{"version":3,"names":["Dropdown","Button","MenuItemsChoice","SVG","Path","NavigableMenu","__","useSelect","useDispatch","forwardRef","Icon","edit","editIcon","store","blockEditorStore","selectIcon","createElement","xmlns","width","height","viewBox","d","ToolSelector","props","ref","mode","select","__unstableGetEditorMode","__unstableSetEditorMode","renderToggle","isOpen","onToggle","icon","onClick","label","popoverProps","placement","variant","undefined","renderContent","Fragment","role","value","onSelect","choices","className"],"sources":["@wordpress/block-editor/src/components/tool-selector/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\tButton,\n\tMenuItemsChoice,\n\tSVG,\n\tPath,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, edit as editIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst selectIcon = (\n\t<SVG\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\twidth=\"24\"\n\t\theight=\"24\"\n\t\tviewBox=\"0 0 24 24\"\n\t>\n\t\t<Path d=\"M9.4 20.5L5.2 3.8l14.6 9-2 .3c-.2 0-.4.1-.7.1-.9.2-1.6.3-2.2.5-.8.3-1.4.5-1.8.8-.4.3-.8.8-1.3 1.5-.4.5-.8 1.2-1.2 2l-.3.6-.9 1.9zM7.6 7.1l2.4 9.3c.2-.4.5-.8.7-1.1.6-.8 1.1-1.4 1.6-1.8.5-.4 1.3-.8 2.2-1.1l1.2-.3-8.1-5z\" />\n\t</SVG>\n);\n\nfunction ToolSelector( props, ref ) {\n\tconst mode = useSelect(\n\t\t( select ) => select( blockEditorStore ).__unstableGetEditorMode(),\n\t\t[]\n\t);\n\tconst { __unstableSetEditorMode } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\ticon={ mode === 'navigation' ? selectIcon : editIcon }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\tlabel={ __( 'Tools' ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\tpopoverProps={ { placement: 'bottom-start', variant: undefined } }\n\t\t\trenderContent={ () => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu role=\"menu\" aria-label={ __( 'Tools' ) }>\n\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\tmode === 'navigation' ? 'navigation' : 'edit'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonSelect={ __unstableSetEditorMode }\n\t\t\t\t\t\t\tchoices={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'edit',\n\t\t\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ editIcon } />\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t\t\t\t</>\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\t{\n\t\t\t\t\t\t\t\t\tvalue: 'navigation',\n\t\t\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{ selectIcon }\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Select' ) }\n\t\t\t\t\t\t\t\t\t\t</>\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</NavigableMenu>\n\t\t\t\t\t<div className=\"block-editor-tool-selector__help\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Tools provide different interactions for selecting, navigating, and editing blocks. Toggle between select and edit by pressing Escape and Enter.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( ToolSelector );\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,QAAQ,EACRC,MAAM,EACNC,eAAe,EACfC,GAAG,EACHC,IAAI,EACJC,aAAa,QACP,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,EAAEC,IAAI,IAAIC,QAAQ,QAAQ,kBAAkB;;AAEzD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,MAAMC,UAAU,GACfC,aAAA,CAACb,GAAG;EACHc,KAAK,EAAC,4BAA4B;EAClCC,KAAK,EAAC,IAAI;EACVC,MAAM,EAAC,IAAI;EACXC,OAAO,EAAC;AAAW,GAEnBJ,aAAA,CAACZ,IAAI;EAACiB,CAAC,EAAC;AAA2N,CAAE,CACjO,CACL;AAED,SAASC,YAAYA,CAAEC,KAAK,EAAEC,GAAG,EAAG;EACnC,MAAMC,IAAI,GAAGlB,SAAS,CACnBmB,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C9CvC,EAAE,CACH,kJACD,CACI,CACJ;EACA,CACH,CAAC;AAEJ;AAEA,eAAeG,UAAU,CAAEa,YAAa,CAAC"}
|
|
@@ -29,9 +29,12 @@ function RenameModal({
|
|
|
29
29
|
const autoSelectInputText = event => event.target.select();
|
|
30
30
|
const dialogDescription = useInstanceId(RenameModal, `block-editor-rename-modal__description`);
|
|
31
31
|
const handleSubmit = () => {
|
|
32
|
+
const message = nameIsOriginal || nameIsEmpty ? sprintf( /* translators: %s: new name/label for the block */
|
|
33
|
+
__('Block name reset to: "%s".'), editedBlockName) : sprintf( /* translators: %s: new name/label for the block */
|
|
34
|
+
__('Block name changed to: "%s".'), editedBlockName);
|
|
35
|
+
|
|
32
36
|
// Must be assertive to immediately announce change.
|
|
33
|
-
speak(
|
|
34
|
-
__('Block name %1$s to: "%2$s".'), nameIsOriginal || nameIsEmpty ? __('reset') : __('changed'), editedBlockName), 'assertive');
|
|
37
|
+
speak(message, 'assertive');
|
|
35
38
|
onSave(editedBlockName);
|
|
36
39
|
|
|
37
40
|
// Immediate close avoids ability to hit save multiple times.
|
|
@@ -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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OAAO,KAAKL,gBAAgB,EAAE5B,KAAK,IACnCtB,WAAW,CAAEuD,OAAQ,CAAC,EACrB;QACDA,OAAO,GAAGC,SAAS;MACpB;MAEAlB,QAAQ,CAAEiB,OAAQ,CAAC;IACpB;EAAG,CACH,CAED,CAAC;AAEL;AAEA,OAAO,MAAME,sBAAsB,GAAG5E,0BAA0B,CAC7D6E,SAAS,IAAQb,KAAK,IAAM;EAC7B,MAAM;IAAEG,QAAQ;IAAEW,IAAI;IAAEC,UAAU;IAAEC;EAAc,CAAC,GAAGhB,KAAK;EAE3D,MAAMiB,eAAe,GAAG5E,eAAe,CACtCyE,IAAI,EACJ,wBAAwB,EACxB,KACD,CAAC;EAED,MAAMI,mBAAmB,GAAG,CAAC,EAC5B,IAAI,KAAKD,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;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,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,M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,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "12.10.
|
|
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.
|
|
39
|
-
"@wordpress/api-fetch": "^6.39.
|
|
40
|
-
"@wordpress/blob": "^3.42.
|
|
41
|
-
"@wordpress/blocks": "^12.19.
|
|
42
|
-
"@wordpress/commands": "^0.13.
|
|
43
|
-
"@wordpress/components": "^25.8.
|
|
44
|
-
"@wordpress/compose": "^6.19.
|
|
45
|
-
"@wordpress/data": "^9.12.
|
|
46
|
-
"@wordpress/date": "^4.42.
|
|
47
|
-
"@wordpress/deprecated": "^3.42.
|
|
48
|
-
"@wordpress/dom": "^3.42.
|
|
49
|
-
"@wordpress/element": "^5.19.
|
|
50
|
-
"@wordpress/escape-html": "^2.42.
|
|
51
|
-
"@wordpress/hooks": "^3.42.
|
|
52
|
-
"@wordpress/html-entities": "^3.42.
|
|
53
|
-
"@wordpress/i18n": "^4.42.
|
|
54
|
-
"@wordpress/icons": "^9.33.
|
|
55
|
-
"@wordpress/is-shallow-equal": "^4.42.
|
|
56
|
-
"@wordpress/keyboard-shortcuts": "^4.19.
|
|
57
|
-
"@wordpress/keycodes": "^3.42.
|
|
58
|
-
"@wordpress/notices": "^4.10.
|
|
59
|
-
"@wordpress/preferences": "^3.19.
|
|
60
|
-
"@wordpress/private-apis": "^0.24.
|
|
61
|
-
"@wordpress/rich-text": "^6.19.
|
|
62
|
-
"@wordpress/shortcode": "^3.42.
|
|
63
|
-
"@wordpress/style-engine": "^1.25.
|
|
64
|
-
"@wordpress/token-list": "^2.42.
|
|
65
|
-
"@wordpress/url": "^3.43.
|
|
66
|
-
"@wordpress/warning": "^2.42.
|
|
67
|
-
"@wordpress/wordcount": "^3.42.
|
|
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": "
|
|
89
|
+
"gitHead": "6256f93c37705d142f75a99f1fc808540ca7dca8"
|
|
90
90
|
}
|
|
@@ -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 {
|
|
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
|
-
|
|
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
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
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
|
*
|
|
@@ -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
|
-
:
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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.
|