@wordpress/block-library 9.30.0 → 9.30.1-next.6870dfe5b.0

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 (85) hide show
  1. package/build/accordion-content/edit.js +8 -8
  2. package/build/accordion-content/edit.js.map +1 -1
  3. package/build/accordion-content/index.js +2 -1
  4. package/build/accordion-content/index.js.map +1 -1
  5. package/build/accordion-panel/index.js +2 -1
  6. package/build/accordion-panel/index.js.map +1 -1
  7. package/build/navigation/constants.js +5 -1
  8. package/build/navigation/constants.js.map +1 -1
  9. package/build/navigation/edit/index.js +45 -1
  10. package/build/navigation/edit/index.js.map +1 -1
  11. package/build/navigation/edit/leaf-more-menu.js +0 -1
  12. package/build/navigation/edit/leaf-more-menu.js.map +1 -1
  13. package/build/navigation/edit/menu-inspector-controls.js +40 -5
  14. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  15. package/build/navigation-link/block-inserter.js +69 -0
  16. package/build/navigation-link/block-inserter.js.map +1 -0
  17. package/build/navigation-link/dialog-wrapper.js +80 -0
  18. package/build/navigation-link/dialog-wrapper.js.map +1 -0
  19. package/build/navigation-link/link-ui.js +80 -120
  20. package/build/navigation-link/link-ui.js.map +1 -1
  21. package/build/navigation-link/page-creator.js +137 -0
  22. package/build/navigation-link/page-creator.js.map +1 -0
  23. package/build/search/edit.js +22 -14
  24. package/build/search/edit.js.map +1 -1
  25. package/build-module/accordion-content/edit.js +8 -8
  26. package/build-module/accordion-content/edit.js.map +1 -1
  27. package/build-module/accordion-content/index.js +2 -1
  28. package/build-module/accordion-content/index.js.map +1 -1
  29. package/build-module/accordion-panel/index.js +2 -1
  30. package/build-module/accordion-panel/index.js.map +1 -1
  31. package/build-module/navigation/constants.js +5 -1
  32. package/build-module/navigation/constants.js.map +1 -1
  33. package/build-module/navigation/edit/index.js +50 -4
  34. package/build-module/navigation/edit/index.js.map +1 -1
  35. package/build-module/navigation/edit/leaf-more-menu.js +0 -1
  36. package/build-module/navigation/edit/leaf-more-menu.js.map +1 -1
  37. package/build-module/navigation/edit/menu-inspector-controls.js +40 -5
  38. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  39. package/build-module/navigation-link/block-inserter.js +61 -0
  40. package/build-module/navigation-link/block-inserter.js.map +1 -0
  41. package/build-module/navigation-link/dialog-wrapper.js +75 -0
  42. package/build-module/navigation-link/dialog-wrapper.js.map +1 -0
  43. package/build-module/navigation-link/link-ui.js +85 -125
  44. package/build-module/navigation-link/link-ui.js.map +1 -1
  45. package/build-module/navigation-link/page-creator.js +130 -0
  46. package/build-module/navigation-link/page-creator.js.map +1 -0
  47. package/build-module/search/edit.js +22 -14
  48. package/build-module/search/edit.js.map +1 -1
  49. package/build-style/accordion/style-rtl.css +5 -6
  50. package/build-style/accordion/style.css +5 -6
  51. package/build-style/editor-rtl.css +14 -0
  52. package/build-style/editor.css +14 -0
  53. package/build-style/form-input/style-rtl.css +4 -3
  54. package/build-style/form-input/style.css +4 -3
  55. package/build-style/navigation-link/editor-rtl.css +14 -0
  56. package/build-style/navigation-link/editor.css +14 -0
  57. package/build-style/navigation-link/style-rtl.css +1 -1
  58. package/build-style/navigation-link/style.css +1 -1
  59. package/build-style/post-comments-form/style-rtl.css +8 -5
  60. package/build-style/post-comments-form/style.css +8 -5
  61. package/build-style/search/style-rtl.css +11 -12
  62. package/build-style/search/style.css +11 -12
  63. package/build-style/style-rtl.css +29 -27
  64. package/build-style/style.css +29 -27
  65. package/package.json +35 -35
  66. package/src/accordion/style.scss +6 -6
  67. package/src/accordion-content/block.json +2 -1
  68. package/src/accordion-content/edit.js +21 -27
  69. package/src/accordion-panel/block.json +2 -1
  70. package/src/cover/test/edit.js +1 -5
  71. package/src/form-input/style.scss +3 -2
  72. package/src/navigation/constants.js +4 -0
  73. package/src/navigation/edit/index.js +50 -1
  74. package/src/navigation/edit/leaf-more-menu.js +0 -1
  75. package/src/navigation/edit/menu-inspector-controls.js +40 -5
  76. package/src/navigation-link/block-inserter.js +65 -0
  77. package/src/navigation-link/dialog-wrapper.js +74 -0
  78. package/src/navigation-link/editor.scss +17 -0
  79. package/src/navigation-link/link-ui.js +108 -164
  80. package/src/navigation-link/page-creator.js +157 -0
  81. package/src/navigation-link/style.scss +1 -1
  82. package/src/post-comments-form/style.scss +11 -11
  83. package/src/search/edit.js +44 -13
  84. package/src/search/index.php +16 -2
  85. package/src/search/style.scss +15 -16
@@ -1 +1 @@
1
- {"version":3,"names":["privateApis","blockEditorPrivateApis","InspectorControls","store","blockEditorStore","PanelBody","__experimentalHStack","HStack","__experimentalHeading","Heading","Spinner","useSelect","useDispatch","__","sprintf","NavigationMenuSelector","unlock","DeletedNavigationWarning","useNavigationMenu","LeafMoreMenu","updateAttributes","LinkUI","jsx","_jsx","jsxs","_jsxs","actionLabel","BLOCKS_WITH_LINK_UI_SUPPORT","PrivateListView","AdditionalBlockContent","block","insertedBlock","setInsertedBlock","updateBlockAttributes","supportsLinkControls","includes","name","blockWasJustInserted","clientId","showLinkControls","setInsertedBlockAttributes","_insertedBlockClientId","_updatedAttributes","link","attributes","onClose","onChange","updatedValue","onCancel","MainContent","currentMenuId","isLoading","isNavigationMenuMissing","onCreateNew","hasChildren","select","getBlockCount","navigationMenu","isNotice","description","title","className","children","rootClientId","isExpanded","showAppender","blockSettingsMenu","additionalBlockContent","MenuInspectorControls","props","createNavigationMenuIsSuccess","createNavigationMenuIsError","onSelectClassicMenu","onSelectNavigationMenu","isManageMenusButtonDisabled","blockEditingMode","group","level"],"sources":["@wordpress/block-library/src/navigation/edit/menu-inspector-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenuSelector from './navigation-menu-selector';\nimport { unlock } from '../../lock-unlock';\nimport DeletedNavigationWarning from './deleted-navigation-warning';\nimport useNavigationMenu from '../use-navigation-menu';\nimport LeafMoreMenu from './leaf-more-menu';\nimport { updateAttributes } from '../../navigation-link/update-attributes';\nimport { LinkUI } from '../../navigation-link/link-ui';\n\nconst actionLabel =\n\t/* translators: %s: The name of a menu. */ __( \"Switch to '%s'\" );\nconst BLOCKS_WITH_LINK_UI_SUPPORT = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\nconst { PrivateListView } = unlock( blockEditorPrivateApis );\n\nfunction AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst supportsLinkControls = BLOCKS_WITH_LINK_UI_SUPPORT?.includes(\n\t\tinsertedBlock?.name\n\t);\n\tconst blockWasJustInserted = insertedBlock?.clientId === block.clientId;\n\tconst showLinkControls = supportsLinkControls && blockWasJustInserted;\n\n\tif ( ! showLinkControls ) {\n\t\treturn null;\n\t}\n\n\tconst setInsertedBlockAttributes =\n\t\t( _insertedBlockClientId ) => ( _updatedAttributes ) => {\n\t\t\tif ( ! _insertedBlockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tupdateBlockAttributes( _insertedBlockClientId, _updatedAttributes );\n\t\t};\n\n\treturn (\n\t\t<LinkUI\n\t\t\tclientId={ insertedBlock?.clientId }\n\t\t\tlink={ insertedBlock?.attributes }\n\t\t\tonClose={ () => {\n\t\t\t\tsetInsertedBlock( null );\n\t\t\t} }\n\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\tupdateAttributes(\n\t\t\t\t\tupdatedValue,\n\t\t\t\t\tsetInsertedBlockAttributes( insertedBlock?.clientId ),\n\t\t\t\t\tinsertedBlock?.attributes\n\t\t\t\t);\n\t\t\t\tsetInsertedBlock( null );\n\t\t\t} }\n\t\t\tonCancel={ () => {\n\t\t\t\tsetInsertedBlock( null );\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nconst MainContent = ( {\n\tclientId,\n\tcurrentMenuId,\n\tisLoading,\n\tisNavigationMenuMissing,\n\tonCreateNew,\n} ) => {\n\tconst hasChildren = useSelect(\n\t\t( select ) => {\n\t\t\treturn !! select( blockEditorStore ).getBlockCount( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { navigationMenu } = useNavigationMenu( currentMenuId );\n\n\tif ( currentMenuId && isNavigationMenuMissing ) {\n\t\treturn (\n\t\t\t<DeletedNavigationWarning onCreateNew={ onCreateNew } isNotice />\n\t\t);\n\t}\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\tconst description = navigationMenu\n\t\t? sprintf(\n\t\t\t\t/* translators: %s: The name of a menu. */\n\t\t\t\t__( 'Structure for Navigation Menu: %s' ),\n\t\t\t\tnavigationMenu?.title || __( 'Untitled menu' )\n\t\t )\n\t\t: __(\n\t\t\t\t'You have not yet created any menus. Displaying a list of your Pages'\n\t\t );\n\n\treturn (\n\t\t<div className=\"wp-block-navigation__menu-inspector-controls\">\n\t\t\t{ ! hasChildren && (\n\t\t\t\t<p className=\"wp-block-navigation__menu-inspector-controls__empty-message\">\n\t\t\t\t\t{ __( 'This Navigation Menu is empty.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t<PrivateListView\n\t\t\t\trootClientId={ clientId }\n\t\t\t\tisExpanded\n\t\t\t\tdescription={ description }\n\t\t\t\tshowAppender\n\t\t\t\tblockSettingsMenu={ LeafMoreMenu }\n\t\t\t\tadditionalBlockContent={ AdditionalBlockContent }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nconst MenuInspectorControls = ( props ) => {\n\tconst {\n\t\tcreateNavigationMenuIsSuccess,\n\t\tcreateNavigationMenuIsError,\n\t\tcurrentMenuId = null,\n\t\tonCreateNew,\n\t\tonSelectClassicMenu,\n\t\tonSelectNavigationMenu,\n\t\tisManageMenusButtonDisabled,\n\t\tblockEditingMode,\n\t} = props;\n\n\treturn (\n\t\t<InspectorControls group=\"list\">\n\t\t\t<PanelBody title={ null }>\n\t\t\t\t<HStack className=\"wp-block-navigation-off-canvas-editor__header\">\n\t\t\t\t\t<Heading\n\t\t\t\t\t\tclassName=\"wp-block-navigation-off-canvas-editor__title\"\n\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Menu' ) }\n\t\t\t\t\t</Heading>\n\t\t\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t\t\t<NavigationMenuSelector\n\t\t\t\t\t\t\tcurrentMenuId={ currentMenuId }\n\t\t\t\t\t\t\tonSelectClassicMenu={ onSelectClassicMenu }\n\t\t\t\t\t\t\tonSelectNavigationMenu={ onSelectNavigationMenu }\n\t\t\t\t\t\t\tonCreateNew={ onCreateNew }\n\t\t\t\t\t\t\tcreateNavigationMenuIsSuccess={\n\t\t\t\t\t\t\t\tcreateNavigationMenuIsSuccess\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcreateNavigationMenuIsError={\n\t\t\t\t\t\t\t\tcreateNavigationMenuIsError\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tactionLabel={ actionLabel }\n\t\t\t\t\t\t\tisManageMenusButtonDisabled={\n\t\t\t\t\t\t\t\tisManageMenusButtonDisabled\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</HStack>\n\t\t\t\t<MainContent { ...props } />\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default MenuInspectorControls;\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WAAW,IAAIC,sBAAsB,EACrCC,iBAAiB,EACjBC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SACCC,SAAS,EACTC,oBAAoB,IAAIC,MAAM,EAC9BC,qBAAqB,IAAIC,OAAO,EAChCC,OAAO,QAC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2B,EAC1BA;QACA,CACD,CACD;MAAA,CACM,CAAC,eACTnD,IAAA,CAAC0B,WAAW;QAAA,GAAMoB;MAAK,CAAI,CAAC;IAAA,CAClB;EAAC,CACM,CAAC;AAEtB,CAAC;AAED,eAAeD,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["privateApis","blockEditorPrivateApis","InspectorControls","store","blockEditorStore","PanelBody","__experimentalHStack","HStack","__experimentalHeading","Heading","Spinner","useSelect","useDispatch","__","sprintf","NavigationMenuSelector","unlock","DeletedNavigationWarning","useNavigationMenu","LeafMoreMenu","updateAttributes","LinkUI","jsx","_jsx","jsxs","_jsxs","actionLabel","BLOCKS_WITH_LINK_UI_SUPPORT","PrivateListView","AdditionalBlockContent","block","insertedBlock","setInsertedBlock","updateBlockAttributes","removeBlock","supportsLinkControls","includes","name","blockWasJustInserted","clientId","showLinkControls","cleanupInsertedBlock","shouldAutoSelectBlock","attributes","url","setInsertedBlockAttributes","_insertedBlockClientId","_updatedAttributes","handleSetInsertedBlock","newBlock","link","onBlockInsert","onClose","onChange","updatedValue","MainContent","currentMenuId","isLoading","isNavigationMenuMissing","onCreateNew","hasChildren","select","getBlockCount","navigationMenu","isNotice","description","title","className","children","rootClientId","isExpanded","showAppender","blockSettingsMenu","additionalBlockContent","MenuInspectorControls","props","createNavigationMenuIsSuccess","createNavigationMenuIsError","onSelectClassicMenu","onSelectNavigationMenu","isManageMenusButtonDisabled","blockEditingMode","group","level"],"sources":["@wordpress/block-library/src/navigation/edit/menu-inspector-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenuSelector from './navigation-menu-selector';\nimport { unlock } from '../../lock-unlock';\nimport DeletedNavigationWarning from './deleted-navigation-warning';\nimport useNavigationMenu from '../use-navigation-menu';\nimport LeafMoreMenu from './leaf-more-menu';\nimport { updateAttributes } from '../../navigation-link/update-attributes';\nimport { LinkUI } from '../../navigation-link/link-ui';\n\nconst actionLabel =\n\t/* translators: %s: The name of a menu. */ __( \"Switch to '%s'\" );\nconst BLOCKS_WITH_LINK_UI_SUPPORT = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\nconst { PrivateListView } = unlock( blockEditorPrivateApis );\n\nfunction AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) {\n\tconst { updateBlockAttributes, removeBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst supportsLinkControls = BLOCKS_WITH_LINK_UI_SUPPORT?.includes(\n\t\tinsertedBlock?.name\n\t);\n\tconst blockWasJustInserted = insertedBlock?.clientId === block.clientId;\n\tconst showLinkControls = supportsLinkControls && blockWasJustInserted;\n\n\tif ( ! showLinkControls ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Cleanup function for auto-inserted Navigation Link blocks.\n\t *\n\t * Removes the block if it has no URL and clears the inserted block state.\n\t * This ensures consistent cleanup behavior across different contexts.\n\t */\n\tconst cleanupInsertedBlock = () => {\n\t\t// Prevent automatic block selection when removing blocks in list view context\n\t\t// This avoids focus stealing that would close the list view and switch to canvas\n\t\tconst shouldAutoSelectBlock = false;\n\n\t\t// Follows the exact same pattern as Navigation Link block's onClose handler\n\t\t// If there is no URL then remove the auto-inserted block to avoid empty blocks\n\t\tif ( ! insertedBlock?.attributes?.url && insertedBlock?.clientId ) {\n\t\t\t// Remove the block entirely to avoid poor UX\n\t\t\t// This matches the Navigation Link block's behavior\n\t\t\tremoveBlock( insertedBlock.clientId, shouldAutoSelectBlock );\n\t\t}\n\t\tsetInsertedBlock( null );\n\t};\n\n\tconst setInsertedBlockAttributes =\n\t\t( _insertedBlockClientId ) => ( _updatedAttributes ) => {\n\t\t\tif ( ! _insertedBlockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tupdateBlockAttributes( _insertedBlockClientId, _updatedAttributes );\n\t\t};\n\n\t// Wrapper function to clean up original block when a new block is selected\n\tconst handleSetInsertedBlock = ( newBlock ) => {\n\t\t// Prevent automatic block selection when removing blocks in list view context\n\t\t// This avoids focus stealing that would close the list view and switch to canvas\n\t\tconst shouldAutoSelectBlock = false;\n\n\t\t// If we have an existing inserted block and a new block is being set,\n\t\t// remove the original block to avoid duplicates\n\t\tif ( insertedBlock?.clientId && newBlock ) {\n\t\t\tremoveBlock( insertedBlock.clientId, shouldAutoSelectBlock );\n\t\t}\n\t\tsetInsertedBlock( newBlock );\n\t};\n\n\treturn (\n\t\t<LinkUI\n\t\t\tclientId={ insertedBlock?.clientId }\n\t\t\tlink={ insertedBlock?.attributes }\n\t\t\tonBlockInsert={ handleSetInsertedBlock }\n\t\t\tonClose={ () => {\n\t\t\t\t// Use cleanup function\n\t\t\t\tcleanupInsertedBlock();\n\t\t\t} }\n\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\tupdateAttributes(\n\t\t\t\t\tupdatedValue,\n\t\t\t\t\tsetInsertedBlockAttributes( insertedBlock?.clientId ),\n\t\t\t\t\tinsertedBlock?.attributes\n\t\t\t\t);\n\t\t\t\tsetInsertedBlock( null );\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nconst MainContent = ( {\n\tclientId,\n\tcurrentMenuId,\n\tisLoading,\n\tisNavigationMenuMissing,\n\tonCreateNew,\n} ) => {\n\tconst hasChildren = useSelect(\n\t\t( select ) => {\n\t\t\treturn !! select( blockEditorStore ).getBlockCount( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { navigationMenu } = useNavigationMenu( currentMenuId );\n\n\tif ( currentMenuId && isNavigationMenuMissing ) {\n\t\treturn (\n\t\t\t<DeletedNavigationWarning onCreateNew={ onCreateNew } isNotice />\n\t\t);\n\t}\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\tconst description = navigationMenu\n\t\t? sprintf(\n\t\t\t\t/* translators: %s: The name of a menu. */\n\t\t\t\t__( 'Structure for Navigation Menu: %s' ),\n\t\t\t\tnavigationMenu?.title || __( 'Untitled menu' )\n\t\t )\n\t\t: __(\n\t\t\t\t'You have not yet created any menus. Displaying a list of your Pages'\n\t\t );\n\n\treturn (\n\t\t<div className=\"wp-block-navigation__menu-inspector-controls\">\n\t\t\t{ ! hasChildren && (\n\t\t\t\t<p className=\"wp-block-navigation__menu-inspector-controls__empty-message\">\n\t\t\t\t\t{ __( 'This Navigation Menu is empty.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t<PrivateListView\n\t\t\t\trootClientId={ clientId }\n\t\t\t\tisExpanded\n\t\t\t\tdescription={ description }\n\t\t\t\tshowAppender\n\t\t\t\tblockSettingsMenu={ LeafMoreMenu }\n\t\t\t\tadditionalBlockContent={ AdditionalBlockContent }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nconst MenuInspectorControls = ( props ) => {\n\tconst {\n\t\tcreateNavigationMenuIsSuccess,\n\t\tcreateNavigationMenuIsError,\n\t\tcurrentMenuId = null,\n\t\tonCreateNew,\n\t\tonSelectClassicMenu,\n\t\tonSelectNavigationMenu,\n\t\tisManageMenusButtonDisabled,\n\t\tblockEditingMode,\n\t} = props;\n\n\treturn (\n\t\t<InspectorControls group=\"list\">\n\t\t\t<PanelBody title={ null }>\n\t\t\t\t<HStack className=\"wp-block-navigation-off-canvas-editor__header\">\n\t\t\t\t\t<Heading\n\t\t\t\t\t\tclassName=\"wp-block-navigation-off-canvas-editor__title\"\n\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Menu' ) }\n\t\t\t\t\t</Heading>\n\t\t\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t\t\t<NavigationMenuSelector\n\t\t\t\t\t\t\tcurrentMenuId={ currentMenuId }\n\t\t\t\t\t\t\tonSelectClassicMenu={ onSelectClassicMenu }\n\t\t\t\t\t\t\tonSelectNavigationMenu={ onSelectNavigationMenu }\n\t\t\t\t\t\t\tonCreateNew={ onCreateNew }\n\t\t\t\t\t\t\tcreateNavigationMenuIsSuccess={\n\t\t\t\t\t\t\t\tcreateNavigationMenuIsSuccess\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcreateNavigationMenuIsError={\n\t\t\t\t\t\t\t\tcreateNavigationMenuIsError\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tactionLabel={ actionLabel }\n\t\t\t\t\t\t\tisManageMenusButtonDisabled={\n\t\t\t\t\t\t\t\tisManageMenusButtonDisabled\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</HStack>\n\t\t\t\t<MainContent { ...props } />\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default MenuInspectorControls;\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WAAW,IAAIC,sBAAsB,EACrCC,iBAAiB,EACjBC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SACCC,SAAS,EACTC,oBAAoB,IAAIC,MAAM,EAC9BC,qBAAqB,IAAIC,OAAO,EAChCC,OAAO,QACD,uBAAuB;AAC9B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,sBAAsB,MAAM,4BAA4B;AAC/D,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,wBAAwB,MAAM,8BAA8B;AACnE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,SAASC,gBAAgB,QAAQ,yCAAyC;AAC1E,SAASC,MAAM,QAAQ,+BAA+B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EA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GA,mBAAqB;UAC3CC,sBAAsB,EAAGA,sBAAwB;UACjDpB,WAAW,EAAGA,WAAa;UAC3BiB,6BAA6B,EAC5BA,6BACA;UACDC,2BAA2B,EAC1BA,2BACA;UACDnD,WAAW,EAAGA,WAAa;UAC3BsD,2BAA2B,EAC1BA;QACA,CACD,CACD;MAAA,CACM,CAAC,eACTzD,IAAA,CAACgC,WAAW;QAAA,GAAMoB;MAAK,CAAI,CAAC;IAAA,CAClB;EAAC,CACM,CAAC;AAEtB,CAAC;AAED,eAAeD,qBAAqB","ignoreList":[]}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { store as blockEditorStore, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import DialogWrapper from './dialog-wrapper';
12
+ import { unlock } from '../lock-unlock';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ const {
15
+ PrivateQuickInserter: QuickInserter
16
+ } = unlock(blockEditorPrivateApis);
17
+
18
+ /**
19
+ * Component for inserting blocks within the Navigation Link UI.
20
+ *
21
+ * @param {Object} props Component props.
22
+ * @param {string} props.clientId Client ID of the navigation link block.
23
+ * @param {Function} props.onBack Callback when user wants to go back.
24
+ * @param {Function} props.onBlockInsert Callback when a block is inserted.
25
+ */
26
+ function LinkUIBlockInserter({
27
+ clientId,
28
+ onBack,
29
+ onBlockInsert
30
+ }) {
31
+ const {
32
+ rootBlockClientId
33
+ } = useSelect(select => {
34
+ const {
35
+ getBlockRootClientId
36
+ } = select(blockEditorStore);
37
+ return {
38
+ rootBlockClientId: getBlockRootClientId(clientId)
39
+ };
40
+ }, [clientId]);
41
+ if (!clientId) {
42
+ return null;
43
+ }
44
+ return /*#__PURE__*/_jsx(DialogWrapper, {
45
+ className: "link-ui-block-inserter",
46
+ title: __('Add block'),
47
+ description: __('Choose a block to add to your Navigation.'),
48
+ onBack: onBack,
49
+ children: /*#__PURE__*/_jsx(QuickInserter, {
50
+ rootClientId: rootBlockClientId,
51
+ clientId: clientId,
52
+ isAppender: false,
53
+ prioritizePatterns: false,
54
+ selectBlockOnInsert: !onBlockInsert,
55
+ onSelect: onBlockInsert ? onBlockInsert : undefined,
56
+ hasSearch: false
57
+ })
58
+ });
59
+ }
60
+ export default LinkUIBlockInserter;
61
+ //# sourceMappingURL=block-inserter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","useSelect","store","blockEditorStore","privateApis","blockEditorPrivateApis","DialogWrapper","unlock","jsx","_jsx","PrivateQuickInserter","QuickInserter","LinkUIBlockInserter","clientId","onBack","onBlockInsert","rootBlockClientId","select","getBlockRootClientId","className","title","description","children","rootClientId","isAppender","prioritizePatterns","selectBlockOnInsert","onSelect","undefined","hasSearch"],"sources":["@wordpress/block-library/src/navigation-link/block-inserter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport DialogWrapper from './dialog-wrapper';\nimport { unlock } from '../lock-unlock';\n\nconst { PrivateQuickInserter: QuickInserter } = unlock(\n\tblockEditorPrivateApis\n);\n\n/**\n * Component for inserting blocks within the Navigation Link UI.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Client ID of the navigation link block.\n * @param {Function} props.onBack Callback when user wants to go back.\n * @param {Function} props.onBlockInsert Callback when a block is inserted.\n */\nfunction LinkUIBlockInserter( { clientId, onBack, onBlockInsert } ) {\n\tconst { rootBlockClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\trootBlockClientId: getBlockRootClientId( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! clientId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DialogWrapper\n\t\t\tclassName=\"link-ui-block-inserter\"\n\t\t\ttitle={ __( 'Add block' ) }\n\t\t\tdescription={ __( 'Choose a block to add to your Navigation.' ) }\n\t\t\tonBack={ onBack }\n\t\t>\n\t\t\t<QuickInserter\n\t\t\t\trootClientId={ rootBlockClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ false }\n\t\t\t\tprioritizePatterns={ false }\n\t\t\t\tselectBlockOnInsert={ ! onBlockInsert }\n\t\t\t\tonSelect={ onBlockInsert ? onBlockInsert : undefined }\n\t\t\t\thasSearch={ false }\n\t\t\t/>\n\t\t</DialogWrapper>\n\t);\n}\n\nexport default LinkUIBlockInserter;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;;AAEhC;AACA;AACA;AACA,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,SAASC,MAAM,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExC,MAAM;EAAEC,oBAAoB,EAAEC;AAAc,CAAC,GAAGJ,MAAM,CACrDF,sBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASO,mBAAmBA,CAAE;EAAEC,QAAQ;EAAEC,MAAM;EAAEC;AAAc,CAAC,EAAG;EACnE,MAAM;IAAEC;EAAkB,CAAC,GAAGf,SAAS,CACpCgB,MAAM,IAAM;IACb,MAAM;MAAEC;IAAqB,CAAC,GAAGD,MAAM,CAAEd,gBAAiB,CAAC;IAE3D,OAAO;MACNa,iBAAiB,EAAEE,oBAAoB,CAAEL,QAAS;IACnD,CAAC;EACF,CAAC,EACD,CAAEA,QAAQ,CACX,CAAC;EAED,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,oBACCJ,IAAA,CAACH,aAAa;IACba,SAAS,EAAC,wBAAwB;IAClCC,KAAK,EAAGpB,EAAE,CAAE,WAAY,CAAG;IAC3BqB,WAAW,EAAGrB,EAAE,CAAE,2CAA4C,CAAG;IACjEc,MAAM,EAAGA,MAAQ;IAAAQ,QAAA,eAEjBb,IAAA,CAACE,aAAa;MACbY,YAAY,EAAGP,iBAAmB;MAClCH,QAAQ,EAAGA,QAAU;MACrBW,UAAU,EAAG,KAAO;MACpBC,kBAAkB,EAAG,KAAO;MAC5BC,mBAAmB,EAAG,CAAEX,aAAe;MACvCY,QAAQ,EAAGZ,aAAa,GAAGA,aAAa,GAAGa,SAAW;MACtDC,SAAS,EAAG;IAAO,CACnB;EAAC,CACY,CAAC;AAElB;AAEA,eAAejB,mBAAmB","ignoreList":[]}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Button, VisuallyHidden } from '@wordpress/components';
5
+ import { __, isRTL } from '@wordpress/i18n';
6
+ import { chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';
7
+ import { useInstanceId, useFocusOnMount } from '@wordpress/compose';
8
+
9
+ /**
10
+ * Shared BackButton component for consistent navigation across LinkUI sub-components.
11
+ *
12
+ * @param {Object} props Component props.
13
+ * @param {string} props.className CSS class name for the button.
14
+ * @param {Function} props.onBack Callback when user wants to go back.
15
+ */
16
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
+ function BackButton({
18
+ className,
19
+ onBack
20
+ }) {
21
+ return /*#__PURE__*/_jsx(Button, {
22
+ className: className,
23
+ icon: isRTL() ? chevronRightSmall : chevronLeftSmall,
24
+ onClick: e => {
25
+ e.preventDefault();
26
+ onBack();
27
+ },
28
+ size: "small",
29
+ children: __('Back')
30
+ });
31
+ }
32
+
33
+ /**
34
+ * Shared DialogWrapper component for consistent dialog structure across LinkUI sub-components.
35
+ *
36
+ * @param {Object} props Component props.
37
+ * @param {string} props.className CSS class name for the dialog container.
38
+ * @param {string} props.title Dialog title for accessibility.
39
+ * @param {string} props.description Dialog description for accessibility.
40
+ * @param {Function} props.onBack Callback when user wants to go back.
41
+ * @param {Object} props.children Child components to render inside the dialog.
42
+ */
43
+ function DialogWrapper({
44
+ className,
45
+ title,
46
+ description,
47
+ onBack,
48
+ children
49
+ }) {
50
+ const dialogTitleId = useInstanceId(DialogWrapper, 'link-ui-dialog-title');
51
+ const dialogDescriptionId = useInstanceId(DialogWrapper, 'link-ui-dialog-description');
52
+ const focusOnMountRef = useFocusOnMount('firstElement');
53
+ const backButtonClassName = `${className}__back`;
54
+ return /*#__PURE__*/_jsxs("div", {
55
+ className: className,
56
+ role: "dialog",
57
+ "aria-labelledby": dialogTitleId,
58
+ "aria-describedby": dialogDescriptionId,
59
+ ref: focusOnMountRef,
60
+ children: [/*#__PURE__*/_jsxs(VisuallyHidden, {
61
+ children: [/*#__PURE__*/_jsx("h2", {
62
+ id: dialogTitleId,
63
+ children: title
64
+ }), /*#__PURE__*/_jsx("p", {
65
+ id: dialogDescriptionId,
66
+ children: description
67
+ })]
68
+ }), /*#__PURE__*/_jsx(BackButton, {
69
+ className: backButtonClassName,
70
+ onBack: onBack
71
+ }), children]
72
+ });
73
+ }
74
+ export default DialogWrapper;
75
+ //# sourceMappingURL=dialog-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Button","VisuallyHidden","__","isRTL","chevronLeftSmall","chevronRightSmall","useInstanceId","useFocusOnMount","jsx","_jsx","jsxs","_jsxs","BackButton","className","onBack","icon","onClick","e","preventDefault","size","children","DialogWrapper","title","description","dialogTitleId","dialogDescriptionId","focusOnMountRef","backButtonClassName","role","ref","id"],"sources":["@wordpress/block-library/src/navigation-link/dialog-wrapper.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';\nimport { useInstanceId, useFocusOnMount } from '@wordpress/compose';\n\n/**\n * Shared BackButton component for consistent navigation across LinkUI sub-components.\n *\n * @param {Object} props Component props.\n * @param {string} props.className CSS class name for the button.\n * @param {Function} props.onBack Callback when user wants to go back.\n */\nfunction BackButton( { className, onBack } ) {\n\treturn (\n\t\t<Button\n\t\t\tclassName={ className }\n\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\tonClick={ ( e ) => {\n\t\t\t\te.preventDefault();\n\t\t\t\tonBack();\n\t\t\t} }\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t{ __( 'Back' ) }\n\t\t</Button>\n\t);\n}\n\n/**\n * Shared DialogWrapper component for consistent dialog structure across LinkUI sub-components.\n *\n * @param {Object} props Component props.\n * @param {string} props.className CSS class name for the dialog container.\n * @param {string} props.title Dialog title for accessibility.\n * @param {string} props.description Dialog description for accessibility.\n * @param {Function} props.onBack Callback when user wants to go back.\n * @param {Object} props.children Child components to render inside the dialog.\n */\nfunction DialogWrapper( { className, title, description, onBack, children } ) {\n\tconst dialogTitleId = useInstanceId(\n\t\tDialogWrapper,\n\t\t'link-ui-dialog-title'\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tDialogWrapper,\n\t\t'link-ui-dialog-description'\n\t);\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\tconst backButtonClassName = `${ className }__back`;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ className }\n\t\t\trole=\"dialog\"\n\t\t\taria-labelledby={ dialogTitleId }\n\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\tref={ focusOnMountRef }\n\t\t>\n\t\t\t<VisuallyHidden>\n\t\t\t\t<h2 id={ dialogTitleId }>{ title }</h2>\n\t\t\t\t<p id={ dialogDescriptionId }>{ description }</p>\n\t\t\t</VisuallyHidden>\n\n\t\t\t<BackButton className={ backButtonClassName } onBack={ onBack } />\n\n\t\t\t{ children }\n\t\t</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I,GAAG,EAAGH,eAAiB;IAAAN,QAAA,gBAEvBT,KAAA,CAACV,cAAc;MAAAmB,QAAA,gBACdX,IAAA;QAAIqB,EAAE,EAAGN,aAAe;QAAAJ,QAAA,EAAGE;MAAK,CAAM,CAAC,eACvCb,IAAA;QAAGqB,EAAE,EAAGL,mBAAqB;QAAAL,QAAA,EAAGG;MAAW,CAAK,CAAC;IAAA,CAClC,CAAC,eAEjBd,IAAA,CAACG,UAAU;MAACC,SAAS,EAAGc,mBAAqB;MAACb,MAAM,EAAGA;IAAQ,CAAE,CAAC,EAEhEM,QAAQ;EAAA,CACN,CAAC;AAER;AAEA,eAAeC,aAAa","ignoreList":[]}
@@ -3,23 +3,18 @@
3
3
  */
4
4
  import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
5
5
  import { Popover, Button, VisuallyHidden, __experimentalVStack as VStack } from '@wordpress/components';
6
- import { __, sprintf, isRTL } from '@wordpress/i18n';
7
- import { LinkControl, store as blockEditorStore, privateApis as blockEditorPrivateApis, useBlockEditingMode } from '@wordpress/block-editor';
8
- import { createInterpolateElement, useMemo, useState, useRef, useEffect, forwardRef } from '@wordpress/element';
9
- import { store as coreStore, useResourcePermissions } from '@wordpress/core-data';
10
- import { decodeEntities } from '@wordpress/html-entities';
11
- import { useSelect, useDispatch } from '@wordpress/data';
12
- import { chevronLeftSmall, chevronRightSmall, plus } from '@wordpress/icons';
13
- import { useInstanceId, useFocusOnMount } from '@wordpress/compose';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { LinkControl, useBlockEditingMode } from '@wordpress/block-editor';
8
+ import { useMemo, useState, useRef, useEffect, forwardRef } from '@wordpress/element';
9
+ import { useResourcePermissions } from '@wordpress/core-data';
10
+ import { plus } from '@wordpress/icons';
11
+ import { useInstanceId } from '@wordpress/compose';
14
12
 
15
13
  /**
16
14
  * Internal dependencies
17
15
  */
18
- import { unlock } from '../lock-unlock';
19
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
- const {
21
- PrivateQuickInserter: QuickInserter
22
- } = unlock(blockEditorPrivateApis);
16
+ import { LinkUIPageCreator } from './page-creator';
17
+ import LinkUIBlockInserter from './block-inserter';
23
18
 
24
19
  /**
25
20
  * Given the Link block's type attribute, return the query params to give to
@@ -29,6 +24,7 @@ const {
29
24
  * @param {string} kind Link block's entity of kind (post-type|taxonomy)
30
25
  * @return {{ type?: string, subtype?: string }} Search query params.
31
26
  */
27
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
32
28
  export function getSuggestionsQuery(type, kind) {
33
29
  switch (type) {
34
30
  case 'post':
@@ -75,59 +71,6 @@ export function getSuggestionsQuery(type, kind) {
75
71
  };
76
72
  }
77
73
  }
78
- function LinkUIBlockInserter({
79
- clientId,
80
- onBack
81
- }) {
82
- const {
83
- rootBlockClientId
84
- } = useSelect(select => {
85
- const {
86
- getBlockRootClientId
87
- } = select(blockEditorStore);
88
- return {
89
- rootBlockClientId: getBlockRootClientId(clientId)
90
- };
91
- }, [clientId]);
92
- const focusOnMountRef = useFocusOnMount('firstElement');
93
- const dialogTitleId = useInstanceId(LinkControl, `link-ui-block-inserter__title`);
94
- const dialogDescriptionId = useInstanceId(LinkControl, `link-ui-block-inserter__description`);
95
- if (!clientId) {
96
- return null;
97
- }
98
- return /*#__PURE__*/_jsxs("div", {
99
- className: "link-ui-block-inserter",
100
- role: "dialog",
101
- "aria-labelledby": dialogTitleId,
102
- "aria-describedby": dialogDescriptionId,
103
- ref: focusOnMountRef,
104
- children: [/*#__PURE__*/_jsxs(VisuallyHidden, {
105
- children: [/*#__PURE__*/_jsx("h2", {
106
- id: dialogTitleId,
107
- children: __('Add block')
108
- }), /*#__PURE__*/_jsx("p", {
109
- id: dialogDescriptionId,
110
- children: __('Choose a block to add to your Navigation.')
111
- })]
112
- }), /*#__PURE__*/_jsx(Button, {
113
- className: "link-ui-block-inserter__back",
114
- icon: isRTL() ? chevronRightSmall : chevronLeftSmall,
115
- onClick: e => {
116
- e.preventDefault();
117
- onBack();
118
- },
119
- size: "small",
120
- children: __('Back')
121
- }), /*#__PURE__*/_jsx(QuickInserter, {
122
- rootClientId: rootBlockClientId,
123
- clientId: clientId,
124
- isAppender: false,
125
- prioritizePatterns: false,
126
- selectBlockOnInsert: true,
127
- hasSearch: false
128
- })]
129
- });
130
- }
131
74
  function UnforwardedLinkUI(props, ref) {
132
75
  const {
133
76
  label,
@@ -138,42 +81,14 @@ function UnforwardedLinkUI(props, ref) {
138
81
  } = props.link;
139
82
  const postType = type || 'page';
140
83
  const [addingBlock, setAddingBlock] = useState(false);
84
+ const [addingPage, setAddingPage] = useState(false);
141
85
  const [focusAddBlockButton, setFocusAddBlockButton] = useState(false);
142
- const {
143
- saveEntityRecord
144
- } = useDispatch(coreStore);
86
+ const [focusAddPageButton, setFocusAddPageButton] = useState(false);
145
87
  const permissions = useResourcePermissions({
146
88
  kind: 'postType',
147
89
  name: postType
148
90
  });
149
91
 
150
- // Check if we're in contentOnly mode
151
- const blockEditingMode = useBlockEditingMode();
152
- const isDefaultBlockEditingMode = blockEditingMode === 'default';
153
- async function handleCreate(pageTitle) {
154
- const page = await saveEntityRecord('postType', postType, {
155
- title: pageTitle,
156
- status: 'draft'
157
- });
158
- return {
159
- id: page.id,
160
- type: postType,
161
- // Make `title` property consistent with that in `fetchLinkSuggestions` where the `rendered` title (containing HTML entities)
162
- // is also being decoded. By being consistent in both locations we avoid having to branch in the rendering output code.
163
- // Ideally in the future we will update both APIs to utilise the "raw" form of the title which is better suited to edit contexts.
164
- // e.g.
165
- // - title.raw = "Yes & No"
166
- // - title.rendered = "Yes &#038; No"
167
- // - decodeEntities( title.rendered ) = "Yes & No"
168
- // See:
169
- // - https://github.com/WordPress/gutenberg/pull/41063
170
- // - https://github.com/WordPress/gutenberg/blob/a1e1fdc0e6278457e9f4fc0b31ac6d2095f5450b/packages/core-data/src/fetch/__experimental-fetch-link-suggestions.js#L212-L218
171
- title: decodeEntities(page.title.rendered),
172
- url: page.link,
173
- kind: 'post-type'
174
- };
175
- }
176
-
177
92
  // Memoize link value to avoid overriding the LinkControl's internal state.
178
93
  // This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/50976#issuecomment-1568226407.
179
94
  const link = useMemo(() => ({
@@ -181,15 +96,22 @@ function UnforwardedLinkUI(props, ref) {
181
96
  opensInNewTab,
182
97
  title: label && stripHTML(label)
183
98
  }), [label, opensInNewTab, url]);
184
- const dialogTitleId = useInstanceId(LinkUI, `link-ui-link-control__title`);
185
- const dialogDescriptionId = useInstanceId(LinkUI, `link-ui-link-control__description`);
99
+ const handlePageCreated = pageLink => {
100
+ // Set the new page as the current link
101
+ props.onChange(pageLink);
102
+ // Return to main Link UI
103
+ setAddingPage(false);
104
+ };
105
+ const dialogTitleId = useInstanceId(LinkUI, 'link-ui-link-control__title');
106
+ const dialogDescriptionId = useInstanceId(LinkUI, 'link-ui-link-control__description');
107
+ const blockEditingMode = useBlockEditingMode();
186
108
  return /*#__PURE__*/_jsxs(Popover, {
187
109
  ref: ref,
188
110
  placement: "bottom",
189
111
  onClose: props.onClose,
190
112
  anchor: props.anchor,
191
113
  shift: true,
192
- children: [!addingBlock && /*#__PURE__*/_jsxs("div", {
114
+ children: [!addingBlock && !addingPage && /*#__PURE__*/_jsxs("div", {
193
115
  role: "dialog",
194
116
  "aria-labelledby": dialogTitleId,
195
117
  "aria-describedby": dialogDescriptionId,
@@ -206,51 +128,66 @@ function UnforwardedLinkUI(props, ref) {
206
128
  hasRichPreviews: true,
207
129
  value: link,
208
130
  showInitialSuggestions: true,
209
- withCreateSuggestion: permissions.canCreate,
210
- createSuggestion: handleCreate,
211
- createSuggestionButtonText: searchTerm => {
212
- let format;
213
- if (type === 'post') {
214
- /* translators: %s: search term. */
215
- format = __('Create draft post: <mark>%s</mark>');
216
- } else {
217
- /* translators: %s: search term. */
218
- format = __('Create draft page: <mark>%s</mark>');
219
- }
220
- return createInterpolateElement(sprintf(format, searchTerm), {
221
- mark: /*#__PURE__*/_jsx("mark", {})
222
- });
223
- },
131
+ withCreateSuggestion: false,
224
132
  noDirectEntry: !!type,
225
133
  noURLSuggestion: !!type,
226
134
  suggestionsQuery: getSuggestionsQuery(type, kind),
227
135
  onChange: props.onChange,
228
136
  onRemove: props.onRemove,
229
137
  onCancel: props.onCancel,
230
- renderControlBottom: () => !link?.url?.length && isDefaultBlockEditingMode && /*#__PURE__*/_jsx(LinkUITools, {
231
- focusAddBlockButton: focusAddBlockButton,
232
- setAddingBlock: () => {
233
- setAddingBlock(true);
234
- setFocusAddBlockButton(false);
138
+ renderControlBottom: () => {
139
+ // Don't show the tools when there is submitted link (preview state).
140
+ if (link?.url?.length) {
141
+ return null;
235
142
  }
236
- })
143
+ return /*#__PURE__*/_jsx(LinkUITools, {
144
+ focusAddBlockButton: focusAddBlockButton,
145
+ focusAddPageButton: focusAddPageButton,
146
+ setAddingBlock: () => {
147
+ setAddingBlock(true);
148
+ setFocusAddBlockButton(false);
149
+ },
150
+ setAddingPage: () => {
151
+ setAddingPage(true);
152
+ setFocusAddPageButton(false);
153
+ },
154
+ canAddPage: permissions?.canCreate && type === 'page',
155
+ canAddBlock: blockEditingMode === 'default'
156
+ });
157
+ }
237
158
  })]
238
159
  }), addingBlock && /*#__PURE__*/_jsx(LinkUIBlockInserter, {
239
160
  clientId: props.clientId,
240
161
  onBack: () => {
241
162
  setAddingBlock(false);
242
163
  setFocusAddBlockButton(true);
243
- }
164
+ setFocusAddPageButton(false);
165
+ },
166
+ onBlockInsert: props?.onBlockInsert
167
+ }), addingPage && /*#__PURE__*/_jsx(LinkUIPageCreator, {
168
+ postType: postType,
169
+ onBack: () => {
170
+ setAddingPage(false);
171
+ setFocusAddPageButton(true);
172
+ setFocusAddBlockButton(false);
173
+ },
174
+ onPageCreated: handlePageCreated,
175
+ initialTitle: link?.url || ''
244
176
  })]
245
177
  });
246
178
  }
247
179
  export const LinkUI = forwardRef(UnforwardedLinkUI);
248
180
  const LinkUITools = ({
249
181
  setAddingBlock,
250
- focusAddBlockButton
182
+ setAddingPage,
183
+ focusAddBlockButton,
184
+ focusAddPageButton,
185
+ canAddPage,
186
+ canAddBlock
251
187
  }) => {
252
188
  const blockInserterAriaRole = 'listbox';
253
189
  const addBlockButtonRef = useRef();
190
+ const addPageButtonRef = useRef();
254
191
 
255
192
  // Focus the add block button when the popover is opened.
256
193
  useEffect(() => {
@@ -258,9 +195,32 @@ const LinkUITools = ({
258
195
  addBlockButtonRef.current?.focus();
259
196
  }
260
197
  }, [focusAddBlockButton]);
261
- return /*#__PURE__*/_jsx(VStack, {
198
+
199
+ // Focus the add page button when the popover is opened.
200
+ useEffect(() => {
201
+ if (focusAddPageButton) {
202
+ addPageButtonRef.current?.focus();
203
+ }
204
+ }, [focusAddPageButton]);
205
+
206
+ // Don't render anything if neither button should be shown
207
+ if (!canAddPage && !canAddBlock) {
208
+ return null;
209
+ }
210
+ return /*#__PURE__*/_jsxs(VStack, {
211
+ spacing: 0,
262
212
  className: "link-ui-tools",
263
- children: /*#__PURE__*/_jsx(Button, {
213
+ children: [canAddPage && /*#__PURE__*/_jsx(Button, {
214
+ __next40pxDefaultSize: true,
215
+ ref: addPageButtonRef,
216
+ icon: plus,
217
+ onClick: e => {
218
+ e.preventDefault();
219
+ setAddingPage(true);
220
+ },
221
+ "aria-haspopup": blockInserterAriaRole,
222
+ children: __('Create page')
223
+ }), canAddBlock && /*#__PURE__*/_jsx(Button, {
264
224
  __next40pxDefaultSize: true,
265
225
  ref: addBlockButtonRef,
266
226
  icon: plus,
@@ -270,7 +230,7 @@ const LinkUITools = ({
270
230
  },
271
231
  "aria-haspopup": blockInserterAriaRole,
272
232
  children: __('Add block')
273
- })
233
+ })]
274
234
  });
275
235
  };
276
236
  export default LinkUITools;
@@ -1 +1 @@
1
- {"version":3,"names":["__unstableStripHTML","stripHTML","Popover","Button","VisuallyHidden","__experimentalVStack","VStack","__","sprintf","isRTL","LinkControl","store","blockEditorStore","privateApis","blockEditorPrivateApis","useBlockEditingMode","createInterpolateElement","useMemo","useState","useRef","useEffect","forwardRef","coreStore","useResourcePermissions","decodeEntities","useSelect","useDispatch","chevronLeftSmall","chevronRightSmall","plus","useInstanceId","useFocusOnMount","unlock","jsx","_jsx","jsxs","_jsxs","PrivateQuickInserter","QuickInserter","getSuggestionsQuery","type","kind","subtype","initialSuggestionsSearchOptions","perPage","LinkUIBlockInserter","clientId","onBack","rootBlockClientId","select","getBlockRootClientId","focusOnMountRef","dialogTitleId","dialogDescriptionId","className","role","ref","children","id","icon","onClick","e","preventDefault","size","rootClientId","isAppender","prioritizePatterns","selectBlockOnInsert","hasSearch","UnforwardedLinkUI","props","label","url","opensInNewTab","link","postType","addingBlock","setAddingBlock","focusAddBlockButton","setFocusAddBlockButton","saveEntityRecord","permissions","name","blockEditingMode","isDefaultBlockEditingMode","handleCreate","pageTitle","page","title","status","rendered","LinkUI","placement","onClose","anchor","shift","hasTextControl","hasRichPreviews","value","showInitialSuggestions","withCreateSuggestion","canCreate","createSuggestion","createSuggestionButtonText","searchTerm","format","mark","noDirectEntry","noURLSuggestion","suggestionsQuery","onChange","onRemove","onCancel","renderControlBottom","length","LinkUITools","blockInserterAriaRole","addBlockButtonRef","current","focus","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/navigation-link/link-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tPopover,\n\tButton,\n\tVisuallyHidden,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __, sprintf, isRTL } from '@wordpress/i18n';\nimport {\n\tLinkControl,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport {\n\tcreateInterpolateElement,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n} from '@wordpress/element';\nimport {\n\tstore as coreStore,\n\tuseResourcePermissions,\n} from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { chevronLeftSmall, chevronRightSmall, plus } from '@wordpress/icons';\nimport { useInstanceId, useFocusOnMount } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { PrivateQuickInserter: QuickInserter } = unlock(\n\tblockEditorPrivateApis\n);\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// for custom link which has no type\n\t\t\t\t// always show pages as initial suggestions\n\t\t\t\tinitialSuggestionsSearchOptions: {\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype: 'page',\n\t\t\t\t\tperPage: 20,\n\t\t\t\t},\n\t\t\t};\n\t}\n}\n\nfunction LinkUIBlockInserter( { clientId, onBack } ) {\n\tconst { rootBlockClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\trootBlockClientId: getBlockRootClientId( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\n\tconst dialogTitleId = useInstanceId(\n\t\tLinkControl,\n\t\t`link-ui-block-inserter__title`\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tLinkControl,\n\t\t`link-ui-block-inserter__description`\n\t);\n\n\tif ( ! clientId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"link-ui-block-inserter\"\n\t\t\trole=\"dialog\"\n\t\t\taria-labelledby={ dialogTitleId }\n\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\tref={ focusOnMountRef }\n\t\t>\n\t\t\t<VisuallyHidden>\n\t\t\t\t<h2 id={ dialogTitleId }>{ __( 'Add block' ) }</h2>\n\n\t\t\t\t<p id={ dialogDescriptionId }>\n\t\t\t\t\t{ __( 'Choose a block to add to your Navigation.' ) }\n\t\t\t\t</p>\n\t\t\t</VisuallyHidden>\n\n\t\t\t<Button\n\t\t\t\tclassName=\"link-ui-block-inserter__back\"\n\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tonBack();\n\t\t\t\t} }\n\t\t\t\tsize=\"small\"\n\t\t\t>\n\t\t\t\t{ __( 'Back' ) }\n\t\t\t</Button>\n\n\t\t\t<QuickInserter\n\t\t\t\trootClientId={ rootBlockClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ false }\n\t\t\t\tprioritizePatterns={ false }\n\t\t\t\tselectBlockOnInsert\n\t\t\t\thasSearch={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction UnforwardedLinkUI( props, ref ) {\n\tconst { label, url, opensInNewTab, type, kind } = props.link;\n\tconst postType = type || 'page';\n\n\tconst [ addingBlock, setAddingBlock ] = useState( false );\n\tconst [ focusAddBlockButton, setFocusAddBlockButton ] = useState( false );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst permissions = useResourcePermissions( {\n\t\tkind: 'postType',\n\t\tname: postType,\n\t} );\n\n\t// Check if we're in contentOnly mode\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isDefaultBlockEditingMode = blockEditingMode === 'default';\n\n\tasync function handleCreate( pageTitle ) {\n\t\tconst page = await saveEntityRecord( 'postType', postType, {\n\t\t\ttitle: pageTitle,\n\t\t\tstatus: 'draft',\n\t\t} );\n\n\t\treturn {\n\t\t\tid: page.id,\n\t\t\ttype: postType,\n\t\t\t// Make `title` property consistent with that in `fetchLinkSuggestions` where the `rendered` title (containing HTML entities)\n\t\t\t// is also being decoded. By being consistent in both locations we avoid having to branch in the rendering output code.\n\t\t\t// Ideally in the future we will update both APIs to utilise the \"raw\" form of the title which is better suited to edit contexts.\n\t\t\t// e.g.\n\t\t\t// - title.raw = \"Yes & No\"\n\t\t\t// - title.rendered = \"Yes &#038; No\"\n\t\t\t// - decodeEntities( title.rendered ) = \"Yes & No\"\n\t\t\t// See:\n\t\t\t// - https://github.com/WordPress/gutenberg/pull/41063\n\t\t\t// - https://github.com/WordPress/gutenberg/blob/a1e1fdc0e6278457e9f4fc0b31ac6d2095f5450b/packages/core-data/src/fetch/__experimental-fetch-link-suggestions.js#L212-L218\n\t\t\ttitle: decodeEntities( page.title.rendered ),\n\t\t\turl: page.link,\n\t\t\tkind: 'post-type',\n\t\t};\n\t}\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/50976#issuecomment-1568226407.\n\tconst link = useMemo(\n\t\t() => ( {\n\t\t\turl,\n\t\t\topensInNewTab,\n\t\t\ttitle: label && stripHTML( label ),\n\t\t} ),\n\t\t[ label, opensInNewTab, url ]\n\t);\n\n\tconst dialogTitleId = useInstanceId(\n\t\tLinkUI,\n\t\t`link-ui-link-control__title`\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tLinkUI,\n\t\t`link-ui-link-control__description`\n\t);\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ ref }\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t{ ! addingBlock && (\n\t\t\t\t<div\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-labelledby={ dialogTitleId }\n\t\t\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<h2 id={ dialogTitleId }>{ __( 'Add link' ) }</h2>\n\n\t\t\t\t\t\t<p id={ dialogDescriptionId }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Search for and add a link to your Navigation.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\thasTextControl\n\t\t\t\t\t\thasRichPreviews\n\t\t\t\t\t\tvalue={ link }\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t\twithCreateSuggestion={ permissions.canCreate }\n\t\t\t\t\t\tcreateSuggestion={ handleCreate }\n\t\t\t\t\t\tcreateSuggestionButtonText={ ( searchTerm ) => {\n\t\t\t\t\t\t\tlet format;\n\n\t\t\t\t\t\t\tif ( type === 'post' ) {\n\t\t\t\t\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t\t\t\t\tformat = __(\n\t\t\t\t\t\t\t\t\t'Create draft post: <mark>%s</mark>'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t\t\t\t\tformat = __(\n\t\t\t\t\t\t\t\t\t'Create draft page: <mark>%s</mark>'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn createInterpolateElement(\n\t\t\t\t\t\t\t\tsprintf( format, searchTerm ),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmark: <mark />,\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\tnoDirectEntry={ !! type }\n\t\t\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\t\t\tonCancel={ props.onCancel }\n\t\t\t\t\t\trenderControlBottom={ () =>\n\t\t\t\t\t\t\t! link?.url?.length &&\n\t\t\t\t\t\t\tisDefaultBlockEditingMode && (\n\t\t\t\t\t\t\t\t<LinkUITools\n\t\t\t\t\t\t\t\t\tfocusAddBlockButton={ focusAddBlockButton }\n\t\t\t\t\t\t\t\t\tsetAddingBlock={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t\t\t\t\t\tsetFocusAddBlockButton( false );\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</div>\n\t\t\t) }\n\n\t\t\t{ addingBlock && (\n\t\t\t\t<LinkUIBlockInserter\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingBlock( false );\n\t\t\t\t\t\tsetFocusAddBlockButton( true );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nexport const LinkUI = forwardRef( UnforwardedLinkUI );\n\nconst LinkUITools = ( { setAddingBlock, focusAddBlockButton } ) => {\n\tconst blockInserterAriaRole = 'listbox';\n\tconst addBlockButtonRef = useRef();\n\n\t// Focus the add block button when the popover is opened.\n\tuseEffect( () => {\n\t\tif ( focusAddBlockButton ) {\n\t\t\taddBlockButtonRef.current?.focus();\n\t\t}\n\t}, [ focusAddBlockButton ] );\n\n\treturn (\n\t\t<VStack className=\"link-ui-tools\">\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tref={ addBlockButtonRef }\n\t\t\t\ticon={ plus }\n\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t} }\n\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t>\n\t\t\t\t{ __( 'Add block' ) }\n\t\t\t</Button>\n\t\t</VStack>\n\t);\n};\n\nexport default LinkUITools;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SACCC,OAAO,EACPC,MAAM,EACNC,cAAc,EACdC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,OAAO,EAAEC,KAAK,QAAQ,iBAAiB;AACpD,SACCC,WAAW,EACXC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,EACrCC,mBAAmB,QACb,yBAAyB;AAChC,SACCC,wBAAwB,EACxBC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,SAAS,EACTC,UAAU,QACJ,oBAAoB;AAC3B,SACCV,KAAK,IAAIW,SAAS,EAClBC,sBAAsB,QAChB,sBAAsB;AAC7B,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,IAAI,QAAQ,kBAAkB;AAC5E,SAASC,aAAa,EAAEC,eAAe,QAAQ,oBAAoB;;AAEnE;AACA;AACA;AACA,SAASC,MAAM,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAExC,MAAM;EAAEC,oBAAoB,EAAEC;AAAc,CAAC,GAAGN,MAAM,CACrDlB,sBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASyB,mBAAmBA,C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,EAAG6D,iBAAmB;MACzB1D,IAAI,EAAG9B,IAAM;MACb+B,OAAO,EAAKC,CAAC,IAAM;QAClBA,CAAC,CAACC,cAAc,CAAC,CAAC;QAClBe,cAAc,CAAE,IAAK,CAAC;MACvB,CAAG;MACH,iBAAgBuC,qBAAuB;MAAA3D,QAAA,EAErClD,EAAE,CAAE,WAAY;IAAC,CACZ;EAAC,CACF,CAAC;AAEX,CAAC;AAED,eAAe4G,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["__unstableStripHTML","stripHTML","Popover","Button","VisuallyHidden","__experimentalVStack","VStack","__","LinkControl","useBlockEditingMode","useMemo","useState","useRef","useEffect","forwardRef","useResourcePermissions","plus","useInstanceId","LinkUIPageCreator","LinkUIBlockInserter","jsx","_jsx","jsxs","_jsxs","getSuggestionsQuery","type","kind","subtype","initialSuggestionsSearchOptions","perPage","UnforwardedLinkUI","props","ref","label","url","opensInNewTab","link","postType","addingBlock","setAddingBlock","addingPage","setAddingPage","focusAddBlockButton","setFocusAddBlockButton","focusAddPageButton","setFocusAddPageButton","permissions","name","title","handlePageCreated","pageLink","onChange","dialogTitleId","LinkUI","dialogDescriptionId","blockEditingMode","placement","onClose","anchor","shift","children","role","id","hasTextControl","hasRichPreviews","value","showInitialSuggestions","withCreateSuggestion","noDirectEntry","noURLSuggestion","suggestionsQuery","onRemove","onCancel","renderControlBottom","length","LinkUITools","canAddPage","canCreate","canAddBlock","clientId","onBack","onBlockInsert","onPageCreated","initialTitle","blockInserterAriaRole","addBlockButtonRef","addPageButtonRef","current","focus","spacing","className","__next40pxDefaultSize","icon","onClick","e","preventDefault"],"sources":["@wordpress/block-library/src/navigation-link/link-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tPopover,\n\tButton,\n\tVisuallyHidden,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { LinkControl, useBlockEditingMode } from '@wordpress/block-editor';\nimport {\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n} from '@wordpress/element';\nimport { useResourcePermissions } from '@wordpress/core-data';\nimport { plus } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { LinkUIPageCreator } from './page-creator';\nimport LinkUIBlockInserter from './block-inserter';\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// for custom link which has no type\n\t\t\t\t// always show pages as initial suggestions\n\t\t\t\tinitialSuggestionsSearchOptions: {\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype: 'page',\n\t\t\t\t\tperPage: 20,\n\t\t\t\t},\n\t\t\t};\n\t}\n}\n\nfunction UnforwardedLinkUI( props, ref ) {\n\tconst { label, url, opensInNewTab, type, kind } = props.link;\n\tconst postType = type || 'page';\n\n\tconst [ addingBlock, setAddingBlock ] = useState( false );\n\tconst [ addingPage, setAddingPage ] = useState( false );\n\tconst [ focusAddBlockButton, setFocusAddBlockButton ] = useState( false );\n\tconst [ focusAddPageButton, setFocusAddPageButton ] = useState( false );\n\tconst permissions = useResourcePermissions( {\n\t\tkind: 'postType',\n\t\tname: postType,\n\t} );\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/50976#issuecomment-1568226407.\n\tconst link = useMemo(\n\t\t() => ( {\n\t\t\turl,\n\t\t\topensInNewTab,\n\t\t\ttitle: label && stripHTML( label ),\n\t\t} ),\n\t\t[ label, opensInNewTab, url ]\n\t);\n\n\tconst handlePageCreated = ( pageLink ) => {\n\t\t// Set the new page as the current link\n\t\tprops.onChange( pageLink );\n\t\t// Return to main Link UI\n\t\tsetAddingPage( false );\n\t};\n\n\tconst dialogTitleId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__title'\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__description'\n\t);\n\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ ref }\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t{ ! addingBlock && ! addingPage && (\n\t\t\t\t<div\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-labelledby={ dialogTitleId }\n\t\t\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<h2 id={ dialogTitleId }>{ __( 'Add link' ) }</h2>\n\n\t\t\t\t\t\t<p id={ dialogDescriptionId }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Search for and add a link to your Navigation.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\thasTextControl\n\t\t\t\t\t\thasRichPreviews\n\t\t\t\t\t\tvalue={ link }\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t\twithCreateSuggestion={ false }\n\t\t\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\t\t\tonCancel={ props.onCancel }\n\t\t\t\t\t\trenderControlBottom={ () => {\n\t\t\t\t\t\t\t// Don't show the tools when there is submitted link (preview state).\n\t\t\t\t\t\t\tif ( link?.url?.length ) {\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<LinkUITools\n\t\t\t\t\t\t\t\t\tfocusAddBlockButton={ focusAddBlockButton }\n\t\t\t\t\t\t\t\t\tfocusAddPageButton={ focusAddPageButton }\n\t\t\t\t\t\t\t\t\tsetAddingBlock={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t\t\t\t\t\tsetFocusAddBlockButton( false );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tsetAddingPage={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t\t\t\t\t\tsetFocusAddPageButton( false );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tcanAddPage={\n\t\t\t\t\t\t\t\t\t\tpermissions?.canCreate &&\n\t\t\t\t\t\t\t\t\t\ttype === 'page'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcanAddBlock={\n\t\t\t\t\t\t\t\t\t\tblockEditingMode === 'default'\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</div>\n\t\t\t) }\n\n\t\t\t{ addingBlock && (\n\t\t\t\t<LinkUIBlockInserter\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingBlock( false );\n\t\t\t\t\t\tsetFocusAddBlockButton( true );\n\t\t\t\t\t\tsetFocusAddPageButton( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonBlockInsert={ props?.onBlockInsert }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ addingPage && (\n\t\t\t\t<LinkUIPageCreator\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingPage( false );\n\t\t\t\t\t\tsetFocusAddPageButton( true );\n\t\t\t\t\t\tsetFocusAddBlockButton( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonPageCreated={ handlePageCreated }\n\t\t\t\t\tinitialTitle={ link?.url || '' }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nexport const LinkUI = forwardRef( UnforwardedLinkUI );\n\nconst LinkUITools = ( {\n\tsetAddingBlock,\n\tsetAddingPage,\n\tfocusAddBlockButton,\n\tfocusAddPageButton,\n\tcanAddPage,\n\tcanAddBlock,\n} ) => {\n\tconst blockInserterAriaRole = 'listbox';\n\tconst addBlockButtonRef = useRef();\n\tconst addPageButtonRef = useRef();\n\n\t// Focus the add block button when the popover is opened.\n\tuseEffect( () => {\n\t\tif ( focusAddBlockButton ) {\n\t\t\taddBlockButtonRef.current?.focus();\n\t\t}\n\t}, [ focusAddBlockButton ] );\n\n\t// Focus the add page button when the popover is opened.\n\tuseEffect( () => {\n\t\tif ( focusAddPageButton ) {\n\t\t\taddPageButtonRef.current?.focus();\n\t\t}\n\t}, [ focusAddPageButton ] );\n\n\t// Don't render anything if neither button should be shown\n\tif ( ! canAddPage && ! canAddBlock ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 0 } className=\"link-ui-tools\">\n\t\t\t{ canAddPage && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addPageButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Create page' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ canAddBlock && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addBlockButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Add block' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</VStack>\n\t);\n};\n\nexport default LinkUITools;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SACCC,OAAO,EACPC,MAAM,EACNC,cAAc,EACdC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,yBAAyB;AAC1E,SACCC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,SAAS,EACTC,UAAU,QACJ,oBAAoB;AAC3B,SAASC,sBAAsB,QAAQ,sBAAsB;AAC7D,SAASC,IAAI,QAAQ,kBAAkB;AACvC,SAASC,aAAa,QAAQ,oBAAoB;;AAElD;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,gBAAgB;AAClD,OAAOC,mBAAmB,MAAM,kBAAkB;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,SAAAC,GAAA,IAAAC,IA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