@wordpress/block-library 9.30.1-next.6870dfe5b.0 → 9.30.1-next.836ecdcae.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.
- package/build/navigation-link/link-ui.js +82 -34
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/navigation-link/page-creator.js +18 -12
- package/build/navigation-link/page-creator.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +85 -37
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/navigation-link/page-creator.js +19 -12
- package/build-module/navigation-link/page-creator.js.map +1 -1
- package/package.json +35 -35
- package/src/navigation-link/link-ui.js +95 -32
- package/src/navigation-link/page-creator.js +20 -13
- package/build/navigation-link/block-inserter.js +0 -69
- package/build/navigation-link/block-inserter.js.map +0 -1
- package/build/navigation-link/dialog-wrapper.js +0 -80
- package/build/navigation-link/dialog-wrapper.js.map +0 -1
- package/build-module/navigation-link/block-inserter.js +0 -61
- package/build-module/navigation-link/block-inserter.js.map +0 -1
- package/build-module/navigation-link/dialog-wrapper.js +0 -75
- package/build-module/navigation-link/dialog-wrapper.js.map +0 -1
- package/src/navigation-link/block-inserter.js +0 -65
- package/src/navigation-link/dialog-wrapper.js +0 -74
|
@@ -1 +1 @@
|
|
|
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,SAC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AC,CACZ,CACR;EAAA,CACM,CAAC;AAEX,CAAC;AAED,eAAeoE,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["__unstableStripHTML","stripHTML","Popover","Button","VisuallyHidden","__experimentalVStack","VStack","__","isRTL","LinkControl","store","blockEditorStore","privateApis","blockEditorPrivateApis","useBlockEditingMode","useMemo","useState","useRef","useEffect","forwardRef","useResourcePermissions","useSelect","chevronLeftSmall","chevronRightSmall","plus","useInstanceId","useFocusOnMount","unlock","LinkUIPageCreator","jsx","_jsx","jsxs","_jsxs","PrivateQuickInserter","QuickInserter","getSuggestionsQuery","type","kind","subtype","initialSuggestionsSearchOptions","perPage","LinkUIBlockInserter","clientId","onBack","onBlockInsert","rootBlockClientId","select","getBlockRootClientId","focusOnMountRef","dialogTitleId","dialogDescriptionId","className","role","ref","children","id","icon","onClick","e","preventDefault","size","rootClientId","isAppender","prioritizePatterns","selectBlockOnInsert","onSelect","undefined","hasSearch","UnforwardedLinkUI","props","label","url","opensInNewTab","link","postType","addingBlock","setAddingBlock","addingPage","setAddingPage","focusAddBlockButton","setFocusAddBlockButton","focusAddPageButton","setFocusAddPageButton","permissions","name","title","handlePageCreated","pageLink","onChange","LinkUI","blockEditingMode","placement","onClose","anchor","shift","hasTextControl","hasRichPreviews","value","showInitialSuggestions","withCreateSuggestion","noDirectEntry","noURLSuggestion","suggestionsQuery","onRemove","onCancel","renderControlBottom","length","LinkUITools","canCreatePage","canCreate","onPageCreated","initialTitle","blockInserterAriaRole","addBlockButtonRef","addPageButtonRef","current","focus","spacing","__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 { __, isRTL } from '@wordpress/i18n';\nimport {\n\tLinkControl,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n\tuseBlockEditingMode,\n} 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 { useSelect } 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';\nimport { LinkUIPageCreator } from './page-creator';\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, 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\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={ ! onBlockInsert }\n\t\t\t\tonSelect={ onBlockInsert ? onBlockInsert : undefined }\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 [ 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! link?.url?.length && (\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\tcanCreatePage={ permissions.canCreate }\n\t\t\t\t\t\t\t\t\tblockEditingMode={ blockEditingMode }\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\tcanCreatePage,\n\tblockEditingMode,\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\treturn (\n\t\t<VStack spacing={ 0 } className=\"link-ui-tools\">\n\t\t\t{ canCreatePage && (\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{ blockEditingMode === 'default' && (\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,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,EACrCC,mBAAmB,QACb,yBAAyB;AAChC,SACCC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,SAAS,EACTC,UAAU,QACJ,oBAAoB;AAC3B,SAASC,sBAAsB,QAAQ,sBAAsB;AAC7D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,IAAI,QAAQ,kBAAkB;AAC5E,SAASC,aAAa,EAAEC,eAAe,QAAQ,oBAAoB;;AAEnE;AACA;AACA;AACA,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,iBAAiB,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,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
|
|
4
4
|
import { Button, TextControl, Notice, CheckboxControl, __experimentalVStack as VStack, __experimentalHStack as HStack } from '@wordpress/components';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { __, isRTL } from '@wordpress/i18n';
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { store as coreStore } from '@wordpress/core-data';
|
|
8
8
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
9
|
import { useState } from '@wordpress/element';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import DialogWrapper from './dialog-wrapper';
|
|
10
|
+
import { chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';
|
|
11
|
+
import { useFocusOnMount } from '@wordpress/compose';
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* Component for creating new pages within the Navigation Link UI.
|
|
@@ -32,6 +29,9 @@ export function LinkUIPageCreator({
|
|
|
32
29
|
const [title, setTitle] = useState(initialTitle);
|
|
33
30
|
const [shouldPublish, setShouldPublish] = useState(false);
|
|
34
31
|
|
|
32
|
+
// Focus the first element when the component mounts
|
|
33
|
+
const focusOnMountRef = useFocusOnMount('firstElement');
|
|
34
|
+
|
|
35
35
|
// Check if the title is valid for submission
|
|
36
36
|
const isTitleValid = title.trim().length > 0;
|
|
37
37
|
|
|
@@ -74,12 +74,19 @@ export function LinkUIPageCreator({
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
const isSubmitDisabled = isSaving || !isTitleValid;
|
|
77
|
-
return /*#__PURE__*/
|
|
77
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
78
78
|
className: "link-ui-page-creator",
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
ref: focusOnMountRef,
|
|
80
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
81
|
+
className: "link-ui-page-creator__back",
|
|
82
|
+
icon: isRTL() ? chevronRightSmall : chevronLeftSmall,
|
|
83
|
+
onClick: e => {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
onBack();
|
|
86
|
+
},
|
|
87
|
+
size: "small",
|
|
88
|
+
children: __('Back')
|
|
89
|
+
}), /*#__PURE__*/_jsx(VStack, {
|
|
83
90
|
className: "link-ui-page-creator__inner",
|
|
84
91
|
spacing: 4,
|
|
85
92
|
children: /*#__PURE__*/_jsx("form", {
|
|
@@ -124,7 +131,7 @@ export function LinkUIPageCreator({
|
|
|
124
131
|
})]
|
|
125
132
|
})
|
|
126
133
|
})
|
|
127
|
-
})
|
|
134
|
+
})]
|
|
128
135
|
});
|
|
129
136
|
}
|
|
130
137
|
//# sourceMappingURL=page-creator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","TextControl","Notice","CheckboxControl","__experimentalVStack","VStack","__experimentalHStack","HStack","__","useSelect","useDispatch","store","coreStore","decodeEntities","useState","
|
|
1
|
+
{"version":3,"names":["Button","TextControl","Notice","CheckboxControl","__experimentalVStack","VStack","__experimentalHStack","HStack","__","isRTL","useSelect","useDispatch","store","coreStore","decodeEntities","useState","chevronLeftSmall","chevronRightSmall","useFocusOnMount","jsx","_jsx","jsxs","_jsxs","LinkUIPageCreator","postType","onBack","onPageCreated","initialTitle","title","setTitle","shouldPublish","setShouldPublish","focusOnMountRef","isTitleValid","trim","length","lastError","isSaving","select","getLastEntitySaveError","isSavingEntityRecord","saveEntityRecord","createPage","event","preventDefault","savedRecord","status","throwOnError","pageLink","id","type","rendered","url","link","kind","error","isSubmitDisabled","className","ref","children","icon","onClick","e","size","spacing","onSubmit","__next40pxDefaultSize","__nextHasNoMarginBottom","label","onChange","placeholder","value","help","checked","isDismissible","message","justify","variant","disabled","accessibleWhenDisabled","isBusy"],"sources":["@wordpress/block-library/src/navigation-link/page-creator.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tTextControl,\n\tNotice,\n\tCheckboxControl,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useState } from '@wordpress/element';\nimport { chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';\nimport { useFocusOnMount } from '@wordpress/compose';\n\n/**\n * Component for creating new pages within the Navigation Link UI.\n *\n * @param {Object} props Component props.\n * @param {string} props.postType The post type to create.\n * @param {Function} props.onBack Callback when user wants to go back.\n * @param {Function} props.onPageCreated Callback when page is successfully created.\n * @param {string} [props.initialTitle] Initial title to pre-fill the form.\n */\nexport function LinkUIPageCreator( {\n\tpostType,\n\tonBack,\n\tonPageCreated,\n\tinitialTitle = '',\n} ) {\n\tconst [ title, setTitle ] = useState( initialTitle );\n\tconst [ shouldPublish, setShouldPublish ] = useState( false );\n\n\t// Focus the first element when the component mounts\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\n\t// Check if the title is valid for submission\n\tconst isTitleValid = title.trim().length > 0;\n\n\t// Get the last created entity record (without ID) to track creation state\n\tconst { lastError, isSaving } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlastError: select( coreStore ).getLastEntitySaveError(\n\t\t\t\t'postType',\n\t\t\t\tpostType\n\t\t\t),\n\t\t\tisSaving: select( coreStore ).isSavingEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType\n\t\t\t),\n\t\t} ),\n\t\t[ postType ]\n\t);\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tasync function createPage( event ) {\n\t\tevent.preventDefault();\n\t\tif ( isSaving || ! isTitleValid ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\ttitle,\n\t\t\t\t\tstatus: shouldPublish ? 'publish' : 'draft',\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tif ( savedRecord ) {\n\t\t\t\t// Create the page link object from the saved record\n\t\t\t\tconst pageLink = {\n\t\t\t\t\tid: savedRecord.id,\n\t\t\t\t\ttype: postType,\n\t\t\t\t\ttitle: decodeEntities( savedRecord.title.rendered ),\n\t\t\t\t\turl: savedRecord.link,\n\t\t\t\t\tkind: 'post-type',\n\t\t\t\t};\n\n\t\t\t\tonPageCreated( pageLink );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\t// Error handling is done via the data store selectors\n\t\t}\n\t}\n\n\tconst isSubmitDisabled = isSaving || ! isTitleValid;\n\n\treturn (\n\t\t<div className=\"link-ui-page-creator\" ref={ focusOnMountRef }>\n\t\t\t<Button\n\t\t\t\tclassName=\"link-ui-page-creator__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<VStack className=\"link-ui-page-creator__inner\" spacing={ 4 }>\n\t\t\t\t<form onSubmit={ createPage }>\n\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\tplaceholder={ __( 'No title' ) }\n\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Publish immediately' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'If unchecked, the page will be created as a draft.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tchecked={ shouldPublish }\n\t\t\t\t\t\t\tonChange={ setShouldPublish }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t{ lastError && (\n\t\t\t\t\t\t\t<Notice status=\"error\" isDismissible={ false }>\n\t\t\t\t\t\t\t\t{ lastError.message }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<HStack spacing={ 2 } justify=\"flex-end\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\tonClick={ onBack }\n\t\t\t\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\tisBusy={ isSaving }\n\t\t\t\t\t\t\t\taria-disabled={ isSubmitDisabled }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Create page' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</VStack>\n\t\t\t\t</form>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,eAAe,EACfC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,SAAS,EAAEC,WAAW,Q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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "9.30.1-next.
|
|
3
|
+
"version": "9.30.1-next.836ecdcae.0",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -42,39 +42,39 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/runtime": "7.25.7",
|
|
45
|
-
"@wordpress/a11y": "^4.30.1-next.
|
|
46
|
-
"@wordpress/api-fetch": "^7.30.1-next.
|
|
47
|
-
"@wordpress/autop": "^4.30.1-next.
|
|
48
|
-
"@wordpress/blob": "^4.30.1-next.
|
|
49
|
-
"@wordpress/block-editor": "^15.3.1-next.
|
|
50
|
-
"@wordpress/blocks": "^15.3.1-next.
|
|
51
|
-
"@wordpress/components": "^30.3.2-next.
|
|
52
|
-
"@wordpress/compose": "^7.30.1-next.
|
|
53
|
-
"@wordpress/core-data": "^7.30.1-next.
|
|
54
|
-
"@wordpress/data": "^10.30.1-next.
|
|
55
|
-
"@wordpress/date": "^5.30.1-next.
|
|
56
|
-
"@wordpress/deprecated": "^4.30.1-next.
|
|
57
|
-
"@wordpress/dom": "^4.30.1-next.
|
|
58
|
-
"@wordpress/element": "^6.30.1-next.
|
|
59
|
-
"@wordpress/escape-html": "^3.30.1-next.
|
|
60
|
-
"@wordpress/hooks": "^4.30.1-next.
|
|
61
|
-
"@wordpress/html-entities": "^4.30.1-next.
|
|
62
|
-
"@wordpress/i18n": "^6.3.1-next.
|
|
63
|
-
"@wordpress/icons": "^10.30.1-next.
|
|
64
|
-
"@wordpress/interactivity": "^6.30.1-next.
|
|
65
|
-
"@wordpress/interactivity-router": "^2.30.1-next.
|
|
66
|
-
"@wordpress/keyboard-shortcuts": "^5.30.1-next.
|
|
67
|
-
"@wordpress/keycodes": "^4.30.1-next.
|
|
68
|
-
"@wordpress/notices": "^5.30.1-next.
|
|
69
|
-
"@wordpress/patterns": "^2.30.1-next.
|
|
70
|
-
"@wordpress/primitives": "^4.30.1-next.
|
|
71
|
-
"@wordpress/private-apis": "^1.30.1-next.
|
|
72
|
-
"@wordpress/reusable-blocks": "^5.30.1-next.
|
|
73
|
-
"@wordpress/rich-text": "^7.30.1-next.
|
|
74
|
-
"@wordpress/server-side-render": "^6.6.1-next.
|
|
75
|
-
"@wordpress/url": "^4.30.1-next.
|
|
76
|
-
"@wordpress/viewport": "^6.30.1-next.
|
|
77
|
-
"@wordpress/wordcount": "^4.30.1-next.
|
|
45
|
+
"@wordpress/a11y": "^4.30.1-next.836ecdcae.0",
|
|
46
|
+
"@wordpress/api-fetch": "^7.30.1-next.836ecdcae.0",
|
|
47
|
+
"@wordpress/autop": "^4.30.1-next.836ecdcae.0",
|
|
48
|
+
"@wordpress/blob": "^4.30.1-next.836ecdcae.0",
|
|
49
|
+
"@wordpress/block-editor": "^15.3.1-next.836ecdcae.0",
|
|
50
|
+
"@wordpress/blocks": "^15.3.1-next.836ecdcae.0",
|
|
51
|
+
"@wordpress/components": "^30.3.2-next.836ecdcae.0",
|
|
52
|
+
"@wordpress/compose": "^7.30.1-next.836ecdcae.0",
|
|
53
|
+
"@wordpress/core-data": "^7.30.1-next.836ecdcae.0",
|
|
54
|
+
"@wordpress/data": "^10.30.1-next.836ecdcae.0",
|
|
55
|
+
"@wordpress/date": "^5.30.1-next.836ecdcae.0",
|
|
56
|
+
"@wordpress/deprecated": "^4.30.1-next.836ecdcae.0",
|
|
57
|
+
"@wordpress/dom": "^4.30.1-next.836ecdcae.0",
|
|
58
|
+
"@wordpress/element": "^6.30.1-next.836ecdcae.0",
|
|
59
|
+
"@wordpress/escape-html": "^3.30.1-next.836ecdcae.0",
|
|
60
|
+
"@wordpress/hooks": "^4.30.1-next.836ecdcae.0",
|
|
61
|
+
"@wordpress/html-entities": "^4.30.1-next.836ecdcae.0",
|
|
62
|
+
"@wordpress/i18n": "^6.3.1-next.836ecdcae.0",
|
|
63
|
+
"@wordpress/icons": "^10.30.1-next.836ecdcae.0",
|
|
64
|
+
"@wordpress/interactivity": "^6.30.1-next.836ecdcae.0",
|
|
65
|
+
"@wordpress/interactivity-router": "^2.30.1-next.836ecdcae.0",
|
|
66
|
+
"@wordpress/keyboard-shortcuts": "^5.30.1-next.836ecdcae.0",
|
|
67
|
+
"@wordpress/keycodes": "^4.30.1-next.836ecdcae.0",
|
|
68
|
+
"@wordpress/notices": "^5.30.1-next.836ecdcae.0",
|
|
69
|
+
"@wordpress/patterns": "^2.30.1-next.836ecdcae.0",
|
|
70
|
+
"@wordpress/primitives": "^4.30.1-next.836ecdcae.0",
|
|
71
|
+
"@wordpress/private-apis": "^1.30.1-next.836ecdcae.0",
|
|
72
|
+
"@wordpress/reusable-blocks": "^5.30.1-next.836ecdcae.0",
|
|
73
|
+
"@wordpress/rich-text": "^7.30.1-next.836ecdcae.0",
|
|
74
|
+
"@wordpress/server-side-render": "^6.6.1-next.836ecdcae.0",
|
|
75
|
+
"@wordpress/url": "^4.30.1-next.836ecdcae.0",
|
|
76
|
+
"@wordpress/viewport": "^6.30.1-next.836ecdcae.0",
|
|
77
|
+
"@wordpress/wordcount": "^4.30.1-next.836ecdcae.0",
|
|
78
78
|
"change-case": "^4.1.2",
|
|
79
79
|
"clsx": "^2.1.1",
|
|
80
80
|
"colord": "^2.7.0",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "3e60b4c1e78d7b27acbf1d7dd172bbd64358a0f2"
|
|
96
96
|
}
|
|
@@ -8,8 +8,13 @@ import {
|
|
|
8
8
|
VisuallyHidden,
|
|
9
9
|
__experimentalVStack as VStack,
|
|
10
10
|
} from '@wordpress/components';
|
|
11
|
-
import { __ } from '@wordpress/i18n';
|
|
12
|
-
import {
|
|
11
|
+
import { __, isRTL } from '@wordpress/i18n';
|
|
12
|
+
import {
|
|
13
|
+
LinkControl,
|
|
14
|
+
store as blockEditorStore,
|
|
15
|
+
privateApis as blockEditorPrivateApis,
|
|
16
|
+
useBlockEditingMode,
|
|
17
|
+
} from '@wordpress/block-editor';
|
|
13
18
|
import {
|
|
14
19
|
useMemo,
|
|
15
20
|
useState,
|
|
@@ -18,14 +23,19 @@ import {
|
|
|
18
23
|
forwardRef,
|
|
19
24
|
} from '@wordpress/element';
|
|
20
25
|
import { useResourcePermissions } from '@wordpress/core-data';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
26
|
+
import { useSelect } from '@wordpress/data';
|
|
27
|
+
import { chevronLeftSmall, chevronRightSmall, plus } from '@wordpress/icons';
|
|
28
|
+
import { useInstanceId, useFocusOnMount } from '@wordpress/compose';
|
|
23
29
|
|
|
24
30
|
/**
|
|
25
31
|
* Internal dependencies
|
|
26
32
|
*/
|
|
33
|
+
import { unlock } from '../lock-unlock';
|
|
27
34
|
import { LinkUIPageCreator } from './page-creator';
|
|
28
|
-
|
|
35
|
+
|
|
36
|
+
const { PrivateQuickInserter: QuickInserter } = unlock(
|
|
37
|
+
blockEditorPrivateApis
|
|
38
|
+
);
|
|
29
39
|
|
|
30
40
|
/**
|
|
31
41
|
* Given the Link block's type attribute, return the query params to give to
|
|
@@ -65,6 +75,74 @@ export function getSuggestionsQuery( type, kind ) {
|
|
|
65
75
|
}
|
|
66
76
|
}
|
|
67
77
|
|
|
78
|
+
function LinkUIBlockInserter( { clientId, onBack, onBlockInsert } ) {
|
|
79
|
+
const { rootBlockClientId } = useSelect(
|
|
80
|
+
( select ) => {
|
|
81
|
+
const { getBlockRootClientId } = select( blockEditorStore );
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
rootBlockClientId: getBlockRootClientId( clientId ),
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
[ clientId ]
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
91
|
+
|
|
92
|
+
const dialogTitleId = useInstanceId(
|
|
93
|
+
LinkControl,
|
|
94
|
+
`link-ui-block-inserter__title`
|
|
95
|
+
);
|
|
96
|
+
const dialogDescriptionId = useInstanceId(
|
|
97
|
+
LinkControl,
|
|
98
|
+
`link-ui-block-inserter__description`
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
if ( ! clientId ) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<div
|
|
107
|
+
className="link-ui-block-inserter"
|
|
108
|
+
role="dialog"
|
|
109
|
+
aria-labelledby={ dialogTitleId }
|
|
110
|
+
aria-describedby={ dialogDescriptionId }
|
|
111
|
+
ref={ focusOnMountRef }
|
|
112
|
+
>
|
|
113
|
+
<VisuallyHidden>
|
|
114
|
+
<h2 id={ dialogTitleId }>{ __( 'Add block' ) }</h2>
|
|
115
|
+
|
|
116
|
+
<p id={ dialogDescriptionId }>
|
|
117
|
+
{ __( 'Choose a block to add to your Navigation.' ) }
|
|
118
|
+
</p>
|
|
119
|
+
</VisuallyHidden>
|
|
120
|
+
|
|
121
|
+
<Button
|
|
122
|
+
className="link-ui-block-inserter__back"
|
|
123
|
+
icon={ isRTL() ? chevronRightSmall : chevronLeftSmall }
|
|
124
|
+
onClick={ ( e ) => {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
onBack();
|
|
127
|
+
} }
|
|
128
|
+
size="small"
|
|
129
|
+
>
|
|
130
|
+
{ __( 'Back' ) }
|
|
131
|
+
</Button>
|
|
132
|
+
|
|
133
|
+
<QuickInserter
|
|
134
|
+
rootClientId={ rootBlockClientId }
|
|
135
|
+
clientId={ clientId }
|
|
136
|
+
isAppender={ false }
|
|
137
|
+
prioritizePatterns={ false }
|
|
138
|
+
selectBlockOnInsert={ ! onBlockInsert }
|
|
139
|
+
onSelect={ onBlockInsert ? onBlockInsert : undefined }
|
|
140
|
+
hasSearch={ false }
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
68
146
|
function UnforwardedLinkUI( props, ref ) {
|
|
69
147
|
const { label, url, opensInNewTab, type, kind } = props.link;
|
|
70
148
|
const postType = type || 'page';
|
|
@@ -98,11 +176,11 @@ function UnforwardedLinkUI( props, ref ) {
|
|
|
98
176
|
|
|
99
177
|
const dialogTitleId = useInstanceId(
|
|
100
178
|
LinkUI,
|
|
101
|
-
|
|
179
|
+
`link-ui-link-control__title`
|
|
102
180
|
);
|
|
103
181
|
const dialogDescriptionId = useInstanceId(
|
|
104
182
|
LinkUI,
|
|
105
|
-
|
|
183
|
+
`link-ui-link-control__description`
|
|
106
184
|
);
|
|
107
185
|
|
|
108
186
|
const blockEditingMode = useBlockEditingMode();
|
|
@@ -142,13 +220,8 @@ function UnforwardedLinkUI( props, ref ) {
|
|
|
142
220
|
onChange={ props.onChange }
|
|
143
221
|
onRemove={ props.onRemove }
|
|
144
222
|
onCancel={ props.onCancel }
|
|
145
|
-
renderControlBottom={ () =>
|
|
146
|
-
|
|
147
|
-
if ( link?.url?.length ) {
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return (
|
|
223
|
+
renderControlBottom={ () =>
|
|
224
|
+
! link?.url?.length && (
|
|
152
225
|
<LinkUITools
|
|
153
226
|
focusAddBlockButton={ focusAddBlockButton }
|
|
154
227
|
focusAddPageButton={ focusAddPageButton }
|
|
@@ -160,16 +233,11 @@ function UnforwardedLinkUI( props, ref ) {
|
|
|
160
233
|
setAddingPage( true );
|
|
161
234
|
setFocusAddPageButton( false );
|
|
162
235
|
} }
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
type === 'page'
|
|
166
|
-
}
|
|
167
|
-
canAddBlock={
|
|
168
|
-
blockEditingMode === 'default'
|
|
169
|
-
}
|
|
236
|
+
canCreatePage={ permissions.canCreate }
|
|
237
|
+
blockEditingMode={ blockEditingMode }
|
|
170
238
|
/>
|
|
171
|
-
)
|
|
172
|
-
}
|
|
239
|
+
)
|
|
240
|
+
}
|
|
173
241
|
/>
|
|
174
242
|
</div>
|
|
175
243
|
) }
|
|
@@ -209,8 +277,8 @@ const LinkUITools = ( {
|
|
|
209
277
|
setAddingPage,
|
|
210
278
|
focusAddBlockButton,
|
|
211
279
|
focusAddPageButton,
|
|
212
|
-
|
|
213
|
-
|
|
280
|
+
canCreatePage,
|
|
281
|
+
blockEditingMode,
|
|
214
282
|
} ) => {
|
|
215
283
|
const blockInserterAriaRole = 'listbox';
|
|
216
284
|
const addBlockButtonRef = useRef();
|
|
@@ -230,14 +298,9 @@ const LinkUITools = ( {
|
|
|
230
298
|
}
|
|
231
299
|
}, [ focusAddPageButton ] );
|
|
232
300
|
|
|
233
|
-
// Don't render anything if neither button should be shown
|
|
234
|
-
if ( ! canAddPage && ! canAddBlock ) {
|
|
235
|
-
return null;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
301
|
return (
|
|
239
302
|
<VStack spacing={ 0 } className="link-ui-tools">
|
|
240
|
-
{
|
|
303
|
+
{ canCreatePage && (
|
|
241
304
|
<Button
|
|
242
305
|
__next40pxDefaultSize
|
|
243
306
|
ref={ addPageButtonRef }
|
|
@@ -251,7 +314,7 @@ const LinkUITools = ( {
|
|
|
251
314
|
{ __( 'Create page' ) }
|
|
252
315
|
</Button>
|
|
253
316
|
) }
|
|
254
|
-
{
|
|
317
|
+
{ blockEditingMode === 'default' && (
|
|
255
318
|
<Button
|
|
256
319
|
__next40pxDefaultSize
|
|
257
320
|
ref={ addBlockButtonRef }
|
|
@@ -9,16 +9,13 @@ import {
|
|
|
9
9
|
__experimentalVStack as VStack,
|
|
10
10
|
__experimentalHStack as HStack,
|
|
11
11
|
} from '@wordpress/components';
|
|
12
|
-
import { __ } from '@wordpress/i18n';
|
|
12
|
+
import { __, isRTL } from '@wordpress/i18n';
|
|
13
13
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
14
|
import { store as coreStore } from '@wordpress/core-data';
|
|
15
15
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
16
16
|
import { useState } from '@wordpress/element';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* Internal dependencies
|
|
20
|
-
*/
|
|
21
|
-
import DialogWrapper from './dialog-wrapper';
|
|
17
|
+
import { chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';
|
|
18
|
+
import { useFocusOnMount } from '@wordpress/compose';
|
|
22
19
|
|
|
23
20
|
/**
|
|
24
21
|
* Component for creating new pages within the Navigation Link UI.
|
|
@@ -38,6 +35,9 @@ export function LinkUIPageCreator( {
|
|
|
38
35
|
const [ title, setTitle ] = useState( initialTitle );
|
|
39
36
|
const [ shouldPublish, setShouldPublish ] = useState( false );
|
|
40
37
|
|
|
38
|
+
// Focus the first element when the component mounts
|
|
39
|
+
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
40
|
+
|
|
41
41
|
// Check if the title is valid for submission
|
|
42
42
|
const isTitleValid = title.trim().length > 0;
|
|
43
43
|
|
|
@@ -95,12 +95,19 @@ export function LinkUIPageCreator( {
|
|
|
95
95
|
const isSubmitDisabled = isSaving || ! isTitleValid;
|
|
96
96
|
|
|
97
97
|
return (
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
<div className="link-ui-page-creator" ref={ focusOnMountRef }>
|
|
99
|
+
<Button
|
|
100
|
+
className="link-ui-page-creator__back"
|
|
101
|
+
icon={ isRTL() ? chevronRightSmall : chevronLeftSmall }
|
|
102
|
+
onClick={ ( e ) => {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
onBack();
|
|
105
|
+
} }
|
|
106
|
+
size="small"
|
|
107
|
+
>
|
|
108
|
+
{ __( 'Back' ) }
|
|
109
|
+
</Button>
|
|
110
|
+
|
|
104
111
|
<VStack className="link-ui-page-creator__inner" spacing={ 4 }>
|
|
105
112
|
<form onSubmit={ createPage }>
|
|
106
113
|
<VStack spacing={ 4 }>
|
|
@@ -152,6 +159,6 @@ export function LinkUIPageCreator( {
|
|
|
152
159
|
</VStack>
|
|
153
160
|
</form>
|
|
154
161
|
</VStack>
|
|
155
|
-
</
|
|
162
|
+
</div>
|
|
156
163
|
);
|
|
157
164
|
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _i18n = require("@wordpress/i18n");
|
|
9
|
-
var _data = require("@wordpress/data");
|
|
10
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
11
|
-
var _dialogWrapper = _interopRequireDefault(require("./dialog-wrapper"));
|
|
12
|
-
var _lockUnlock = require("../lock-unlock");
|
|
13
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
/**
|
|
15
|
-
* WordPress dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Internal dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const {
|
|
23
|
-
PrivateQuickInserter: QuickInserter
|
|
24
|
-
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Component for inserting blocks within the Navigation Link UI.
|
|
28
|
-
*
|
|
29
|
-
* @param {Object} props Component props.
|
|
30
|
-
* @param {string} props.clientId Client ID of the navigation link block.
|
|
31
|
-
* @param {Function} props.onBack Callback when user wants to go back.
|
|
32
|
-
* @param {Function} props.onBlockInsert Callback when a block is inserted.
|
|
33
|
-
*/
|
|
34
|
-
function LinkUIBlockInserter({
|
|
35
|
-
clientId,
|
|
36
|
-
onBack,
|
|
37
|
-
onBlockInsert
|
|
38
|
-
}) {
|
|
39
|
-
const {
|
|
40
|
-
rootBlockClientId
|
|
41
|
-
} = (0, _data.useSelect)(select => {
|
|
42
|
-
const {
|
|
43
|
-
getBlockRootClientId
|
|
44
|
-
} = select(_blockEditor.store);
|
|
45
|
-
return {
|
|
46
|
-
rootBlockClientId: getBlockRootClientId(clientId)
|
|
47
|
-
};
|
|
48
|
-
}, [clientId]);
|
|
49
|
-
if (!clientId) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_dialogWrapper.default, {
|
|
53
|
-
className: "link-ui-block-inserter",
|
|
54
|
-
title: (0, _i18n.__)('Add block'),
|
|
55
|
-
description: (0, _i18n.__)('Choose a block to add to your Navigation.'),
|
|
56
|
-
onBack: onBack,
|
|
57
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(QuickInserter, {
|
|
58
|
-
rootClientId: rootBlockClientId,
|
|
59
|
-
clientId: clientId,
|
|
60
|
-
isAppender: false,
|
|
61
|
-
prioritizePatterns: false,
|
|
62
|
-
selectBlockOnInsert: !onBlockInsert,
|
|
63
|
-
onSelect: onBlockInsert ? onBlockInsert : undefined,
|
|
64
|
-
hasSearch: false
|
|
65
|
-
})
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
var _default = exports.default = LinkUIBlockInserter;
|
|
69
|
-
//# sourceMappingURL=block-inserter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_data","_blockEditor","_dialogWrapper","_interopRequireDefault","_lockUnlock","_jsxRuntime","PrivateQuickInserter","QuickInserter","unlock","blockEditorPrivateApis","LinkUIBlockInserter","clientId","onBack","onBlockInsert","rootBlockClientId","useSelect","select","getBlockRootClientId","blockEditorStore","jsx","default","className","title","__","description","children","rootClientId","isAppender","prioritizePatterns","selectBlockOnInsert","onSelect","undefined","hasSearch","_default","exports"],"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":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAQA,IAAAG,cAAA,GAAAC,sB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