@wordpress/block-library 9.26.1-next.719a03cbe.0 → 9.27.1-next.46f643fa0.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/CHANGELOG.md +2 -0
- package/build/categories/edit.js +15 -3
- package/build/categories/edit.js.map +1 -1
- package/build/cover/edit/block-controls.js +4 -2
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/index.js +6 -3
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +13 -4
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/index.js +6 -0
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +3 -1
- package/build/cover/save.js.map +1 -1
- package/build/file/edit.js +2 -1
- package/build/file/edit.js.map +1 -1
- package/build/latest-posts/edit.js +0 -2
- package/build/latest-posts/edit.js.map +1 -1
- package/build/media-text/edit.js +2 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/navigation-link/edit.js +32 -15
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/update-attributes.js +112 -14
- package/build/navigation-link/update-attributes.js.map +1 -1
- package/build/navigation-submenu/edit.js +19 -2
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/paragraph/edit.js +2 -2
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-content/edit.js +78 -16
- package/build/post-content/edit.js.map +1 -1
- package/build/post-content/index.js +6 -0
- package/build/post-content/index.js.map +1 -1
- package/build/post-date/deprecated.js +104 -1
- package/build/post-date/deprecated.js.map +1 -1
- package/build/post-date/edit.js +32 -32
- package/build/post-date/edit.js.map +1 -1
- package/build/post-date/index.js +4 -4
- package/build/post-date/index.js.map +1 -1
- package/build/post-date/variations.js +32 -3
- package/build/post-date/variations.js.map +1 -1
- package/build/separator/edit.js +5 -30
- package/build/separator/edit.js.map +1 -1
- package/build/site-tagline/index.js +1 -1
- package/build/social-link/variations.js +51 -49
- package/build/social-link/variations.js.map +1 -1
- package/build/utils/poster-image.js +93 -0
- package/build/utils/poster-image.js.map +1 -0
- package/build/video/edit.js +7 -6
- package/build/video/edit.js.map +1 -1
- package/build/video/tracks-editor.js +95 -104
- package/build/video/tracks-editor.js.map +1 -1
- package/build/video/tracks.js +6 -2
- package/build/video/tracks.js.map +1 -1
- package/build-module/categories/edit.js +15 -3
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +4 -2
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/index.js +6 -3
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +12 -4
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/index.js +6 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +3 -1
- package/build-module/cover/save.js.map +1 -1
- package/build-module/file/edit.js +2 -1
- package/build-module/file/edit.js.map +1 -1
- package/build-module/latest-posts/edit.js +0 -2
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/media-text/edit.js +2 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/navigation-link/edit.js +32 -15
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/update-attributes.js +113 -15
- package/build-module/navigation-link/update-attributes.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +20 -3
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/paragraph/edit.js +2 -2
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-content/edit.js +80 -18
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-content/index.js +6 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/post-date/deprecated.js +104 -1
- package/build-module/post-date/deprecated.js.map +1 -1
- package/build-module/post-date/edit.js +35 -35
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-date/index.js +4 -4
- package/build-module/post-date/index.js.map +1 -1
- package/build-module/post-date/variations.js +32 -3
- package/build-module/post-date/variations.js.map +1 -1
- package/build-module/separator/edit.js +6 -31
- package/build-module/separator/edit.js.map +1 -1
- package/build-module/site-tagline/index.js +1 -1
- package/build-module/social-link/variations.js +52 -50
- package/build-module/social-link/variations.js.map +1 -1
- package/build-module/utils/poster-image.js +85 -0
- package/build-module/utils/poster-image.js.map +1 -0
- package/build-module/video/edit.js +7 -6
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/tracks-editor.js +96 -105
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-module/video/tracks.js +6 -2
- package/build-module/video/tracks.js.map +1 -1
- package/build-style/archives/editor-rtl.css +0 -4
- package/build-style/archives/editor.css +0 -4
- package/build-style/editor-rtl.css +67 -18
- package/build-style/editor.css +67 -18
- package/build-style/file/style-rtl.css +1 -1
- package/build-style/file/style.css +1 -1
- package/build-style/navigation/editor-rtl.css +6 -6
- package/build-style/navigation/editor.css +6 -6
- package/build-style/navigation/style-rtl.css +1 -0
- package/build-style/navigation/style.css +1 -0
- package/build-style/page-list/editor-rtl.css +0 -4
- package/build-style/page-list/editor.css +0 -4
- package/build-style/style-rtl.css +3 -1
- package/build-style/style.css +3 -1
- package/build-style/video/editor-rtl.css +0 -4
- package/build-style/video/editor.css +0 -4
- package/build-style/video/style-rtl.css +1 -0
- package/build-style/video/style.css +1 -0
- package/package.json +35 -35
- package/src/archives/editor.scss +0 -4
- package/src/categories/edit.js +13 -1
- package/src/comments-pagination/index.php +7 -2
- package/src/cover/block.json +6 -0
- package/src/cover/edit/block-controls.js +22 -17
- package/src/cover/edit/index.js +4 -1
- package/src/cover/edit/inspector-controls.js +15 -2
- package/src/cover/save.js +2 -0
- package/src/editor.scss +1 -0
- package/src/file/edit.js +4 -1
- package/src/file/style.scss +1 -1
- package/src/latest-posts/edit.js +0 -2
- package/src/media-text/edit.js +1 -1
- package/src/navigation/style.scss +1 -0
- package/src/navigation-link/edit.js +28 -16
- package/src/navigation-link/test/edit.js +738 -6
- package/src/navigation-link/update-attributes.js +125 -12
- package/src/navigation-submenu/edit.js +21 -1
- package/src/page-list/editor.scss +0 -6
- package/src/paragraph/edit.js +2 -2
- package/src/post-content/block.json +6 -0
- package/src/post-content/edit.js +71 -19
- package/src/post-content/index.php +11 -4
- package/src/post-date/block.json +4 -4
- package/src/post-date/deprecated.js +104 -1
- package/src/post-date/edit.js +74 -86
- package/src/post-date/index.php +55 -28
- package/src/post-date/variations.js +37 -3
- package/src/post-featured-image/index.php +3 -2
- package/src/separator/edit.js +8 -43
- package/src/site-tagline/block.json +1 -1
- package/src/social-link/README.md +21 -0
- package/src/social-link/index.php +49 -49
- package/src/social-link/variations.js +51 -49
- package/src/utils/poster-image.js +131 -0
- package/src/utils/poster-image.scss +75 -0
- package/src/video/edit.js +8 -6
- package/src/video/editor.scss +0 -6
- package/src/video/index.php +91 -0
- package/src/video/style.native.scss +1 -0
- package/src/video/style.scss +1 -0
- package/src/video/tracks-editor.js +93 -103
- package/src/video/tracks.js +2 -1
- package/build/video/poster-image.js +0 -81
- package/build/video/poster-image.js.map +0 -1
- package/build-module/video/poster-image.js +0 -74
- package/build-module/video/poster-image.js.map +0 -1
- package/src/video/poster-image.js +0 -86
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_blocks","_data","_components","_keycodes","_i18n","_blockEditor","_url","_element","_dom","_htmlEntities","_icons","_coreData","_compose","_linkUi","_updateAttributes","_utils","_hooks","_jsxRuntime","DEFAULT_BLOCK","name","NESTING_BLOCK_NAMES","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","useState","useEffect","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","useIsInvalidLink","kind","type","id","enabled","isPostType","hasId","Number","isInteger","blockEditingMode","useBlockEditingMode","postStatus","useSelect","select","getEntityRecord","coreStore","status","isInvalid","isDraft","getMissingText","missingText","__","Controls","attributes","setAttributes","setIsLabelFieldFocused","label","url","description","rel","opensInNewTab","dropdownMenuProps","useToolsPanelDropdownMenuProps","jsxs","__experimentalToolsPanel","resetAll","children","jsx","__experimentalToolsPanelItem","hasValue","onDeselect","isShownByDefault","TextControl","__nextHasNoMarginBottom","__next40pxDefaultSize","value","stripHTML","onChange","labelValue","autoComplete","onFocus","onBlur","safeDecodeURI","urlValue","updateAttributes","CheckboxControl","checked","TextareaControl","descriptionValue","help","relValue","NavigationLinkEdit","isSelected","insertBlocksAfter","mergeBlocks","onReplace","context","clientId","maxNestingLevel","replaceBlock","__unstableMarkNextChangeAsNotPersistent","selectBlock","selectPreviousBlock","useDispatch","blockEditorStore","isLinkOpen","setIsLinkOpen","openedBy","setOpenedBy","popoverAnchor","setPopoverAnchor","listItemRef","useRef","itemLabelPlaceholder","ref","linkUIref","prevUrl","usePrevious","isLabelFieldFocused","isAtMaxNesting","isTopLevelLink","isParentOfSelectedBlock","hasChildren","validateLinkStatus","getBlockCount","getBlockName","getBlockRootClientId","hasSelectedInnerBlock","getBlockParentsByBlockName","getSelectedBlockClientId","rootClientId","isTopLevel","selectedBlockClientId","rootNavigationClientId","enableLinkStatusValidation","length","getBlocks","transformToSubmenu","innerBlocks","createBlock","newSubmenu","isURL","prependHTTP","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","removeLink","undefined","textColor","customTextColor","backgroundColor","customBackgroundColor","getColors","onKeyDown","isKeyboardEvent","primary","preventDefault","stopPropagation","blockProps","useBlockProps","useMergeRefs","className","clsx","getColorClassName","style","color","innerBlocksProps","useInnerBlocksProps","defaultBlock","directInsert","renderAppender","onClick","classes","placeholderText","Fragment","BlockControls","ToolbarGroup","ToolbarButton","icon","linkIcon","title","shortcut","displayShortcut","currentTarget","addSubmenu","InspectorControls","RichText","identifier","onMerge","__unstableOnSplitAtEnd","placeholder","withoutInteractiveFormatting","decodeEntities","trim","LinkUI","link","onClose","window","document","activeElement","anchor","onRemove","updatedValue"],"sources":["@wordpress/block-library/src/navigation-link/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tCheckboxControl,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n\tuseInnerBlocksProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP, safeDecodeURI } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { link as linkIcon, addSubmenu } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { LinkUI } from './link-ui';\nimport { updateAttributes } from './update-attributes';\nimport { getColors } from '../navigation/edit/utils';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst DEFAULT_BLOCK = { name: 'core/navigation-link' };\nconst NESTING_BLOCK_NAMES = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [ elementRef ] );\n\n\treturn isDraggingWithin;\n};\n\nconst useIsInvalidLink = ( kind, type, id, enabled ) => {\n\tconst isPostType =\n\t\tkind === 'post-type' || type === 'post' || type === 'page';\n\tconst hasId = Number.isInteger( id );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst postStatus = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isPostType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Fetching the posts status is an \"expensive\" operation. Especially for sites with large navigations.\n\t\t\t// When the block is rendered in a template or other disabled contexts we can skip this check in order\n\t\t\t// to avoid all these additional requests that don't really add any value in that mode.\n\t\t\tif ( blockEditingMode === 'disabled' || ! enabled ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'postType', type, id )?.status;\n\t\t},\n\t\t[ isPostType, blockEditingMode, enabled, type, id ]\n\t);\n\n\t// Check Navigation Link validity if:\n\t// 1. Link is 'post-type'.\n\t// 2. It has an id.\n\t// 3. It's neither null, nor undefined, as valid items might be either of those while loading.\n\t// If those conditions are met, check if\n\t// 1. The post status is published.\n\t// 2. The Navigation Link item has no label.\n\t// If either of those is true, invalidate.\n\tconst isInvalid =\n\t\tisPostType && hasId && postStatus && 'trash' === postStatus;\n\tconst isDraft = 'draft' === postStatus;\n\n\treturn [ isInvalid, isDraft ];\n};\n\nfunction getMissingText( type ) {\n\tlet missingText = '';\n\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\t\t/* translators: label for missing post in navigation link block */\n\t\t\tmissingText = __( 'Select post' );\n\t\t\tbreak;\n\t\tcase 'page':\n\t\t\t/* translators: label for missing page in navigation link block */\n\t\t\tmissingText = __( 'Select page' );\n\t\t\tbreak;\n\t\tcase 'category':\n\t\t\t/* translators: label for missing category in navigation link block */\n\t\t\tmissingText = __( 'Select category' );\n\t\t\tbreak;\n\t\tcase 'tag':\n\t\t\t/* translators: label for missing tag in navigation link block */\n\t\t\tmissingText = __( 'Select tag' );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t/* translators: label for missing values in navigation link block */\n\t\t\tmissingText = __( 'Add link' );\n\t}\n\n\treturn missingText;\n}\n\n/*\n * Warning, this duplicated in\n * packages/block-library/src/navigation-submenu/edit.js\n * Consider reusing this components for both blocks.\n */\nfunction Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {\n\tconst { label, url, description, rel, opensInNewTab } = attributes;\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ __( 'Settings' ) }\n\t\t\tresetAll={ () => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tlabel: '',\n\t\t\t\t\turl: '',\n\t\t\t\t\tdescription: '',\n\t\t\t\t\trel: '',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! label }\n\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { label: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\tvalue={ label ? stripHTML( label ) : '' }\n\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t} }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\tonFocus={ () => setIsLabelFieldFocused( true ) }\n\t\t\t\t\tonBlur={ () => setIsLabelFieldFocused( false ) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! url }\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { url: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\tvalue={ url ? safeDecodeURI( url ) : '' }\n\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t{ url: urlValue },\n\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\ttype=\"url\"\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! opensInNewTab }\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { opensInNewTab: false } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\tchecked={ opensInNewTab }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { opensInNewTab: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! description }\n\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { description: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextareaControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\tsetAttributes( { description: descriptionValue } );\n\t\t\t\t\t} }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! rel }\n\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { rel: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t} }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'The relationship of the linked URL as space-separated link types.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</ToolsPanel>\n\t);\n}\n\nexport default function NavigationLinkEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { id, label, type, url, description, kind } = attributes;\n\tconst { maxNestingLevel } = context;\n\n\tconst {\n\t\treplaceBlock,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tselectBlock,\n\t\tselectPreviousBlock,\n\t} = useDispatch( blockEditorStore );\n\t// Have the link editing ui open on mount when lacking a url and selected.\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( isSelected && ! url );\n\t// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add label…' );\n\tconst ref = useRef();\n\tconst linkUIref = useRef();\n\tconst prevUrl = usePrevious( url );\n\n\t// Change the label using inspector causes rich text to change focus on firefox.\n\t// This is a workaround to keep the focus on the label field when label filed is focused we don't render the rich text.\n\tconst [ isLabelFieldFocused, setIsLabelFieldFocused ] = useState( false );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t\tvalidateLinkStatus,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst isTopLevel =\n\t\t\t\tgetBlockName( rootClientId ) === 'core/navigation';\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\tconst rootNavigationClientId = isTopLevel\n\t\t\t\t? rootClientId\n\t\t\t\t: getBlockParentsByBlockName(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'core/navigation'\n\t\t\t\t )[ 0 ];\n\n\t\t\t// Enable when the root Navigation block is selected or any of its inner blocks.\n\t\t\tconst enableLinkStatusValidation =\n\t\t\t\tselectedBlockClientId === rootNavigationClientId ||\n\t\t\t\thasSelectedInnerBlock( rootNavigationClientId, true );\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, NESTING_BLOCK_NAMES )\n\t\t\t\t\t\t.length >= maxNestingLevel,\n\t\t\t\tisTopLevelLink: isTopLevel,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tvalidateLinkStatus: enableLinkStatusValidation,\n\t\t\t};\n\t\t},\n\t\t[ clientId, maxNestingLevel ]\n\t);\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink(\n\t\tkind,\n\t\ttype,\n\t\tid,\n\t\tvalidateLinkStatus\n\t);\n\n\t/**\n\t * Transform to submenu block.\n\t */\n\tconst transformToSubmenu = () => {\n\t\tlet innerBlocks = getBlocks( clientId );\n\t\tif ( innerBlocks.length === 0 ) {\n\t\t\tinnerBlocks = [ createBlock( 'core/navigation-link' ) ];\n\t\t\tselectBlock( innerBlocks[ 0 ].clientId );\n\t\t}\n\t\tconst newSubmenu = createBlock(\n\t\t\t'core/navigation-submenu',\n\t\t\tattributes,\n\t\t\tinnerBlocks\n\t\t);\n\t\treplaceBlock( clientId, newSubmenu );\n\t};\n\n\tuseEffect( () => {\n\t\t// If block has inner blocks, transform to Submenu.\n\t\tif ( hasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToSubmenu();\n\t\t}\n\t}, [ hasChildren ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\t// We only want to do this when the URL has gone from nothing to a new URL AND the label looks like a URL\n\t\tif (\n\t\t\t! prevUrl &&\n\t\t\turl &&\n\t\t\tisLinkOpen &&\n\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t) {\n\t\t\t// Focus and select the label text.\n\t\t\tselectLabelText();\n\t\t}\n\t}, [ prevUrl, url, isLinkOpen, label ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\t/**\n\t * Removes the current link if set.\n\t */\n\tfunction removeLink() {\n\t\t// Reset all attributes that comprise the link.\n\t\t// It is critical that all attributes are reset\n\t\t// to their default values otherwise this may\n\t\t// in advertently trigger side effects because\n\t\t// the values will have \"changed\".\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlabel: undefined,\n\t\t\tid: undefined,\n\t\t\tkind: undefined,\n\t\t\ttype: undefined,\n\t\t\topensInNewTab: false,\n\t\t} );\n\n\t\t// Close the link editing UI.\n\t\tsetIsLinkOpen( false );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelLink );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If this link is a child of a parent submenu item, the parent submenu item event will also open, closing this popover\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\t...blockProps,\n\t\t\tclassName: 'remove-outline', // Remove the outline from the inner blocks container.\n\t\t},\n\t\t{\n\t\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\t\tdirectInsert: true,\n\t\t\trenderAppender: false,\n\t\t}\n\t);\n\n\tif ( ! url || isInvalid || isDraft ) {\n\t\tblockProps.onClick = () => {\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t};\n\t}\n\n\tconst classes = clsx( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder': ! url || isInvalid || isDraft,\n\t} );\n\n\tconst missingText = getMissingText( type );\n\t/* translators: Whether the navigation link is Invalid or a Draft. */\n\tconst placeholderText = `(${\n\t\tisInvalid ? __( 'Invalid' ) : __( 'Draft' )\n\t})`;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\tsetOpenedBy( event.currentTarget );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! isAtMaxNesting && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"submenu\"\n\t\t\t\t\t\t\ticon={ addSubmenu }\n\t\t\t\t\t\t\ttitle={ __( 'Add submenu' ) }\n\t\t\t\t\t\t\tonClick={ transformToSubmenu }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ /* Warning, this duplicated in packages/block-library/src/navigation-submenu/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tsetIsLabelFieldFocused={ setIsLabelFieldFocused }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<a className={ classes }>\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{ ! url ? (\n\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text\">\n\t\t\t\t\t\t\t<span>{ missingText }</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isInvalid &&\n\t\t\t\t\t\t\t\t! isDraft &&\n\t\t\t\t\t\t\t\t! isLabelFieldFocused && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: labelValue,\n\t\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'core/navigation-link'\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Navigation link text'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t{ description && (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( isInvalid ||\n\t\t\t\t\t\t\t\tisDraft ||\n\t\t\t\t\t\t\t\tisLabelFieldFocused ) && (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t'wp-block-navigation-link__placeholder-text',\n\t\t\t\t\t\t\t\t\t\t'wp-block-navigation-link__label',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t'is-invalid': isInvalid,\n\t\t\t\t\t\t\t\t\t\t\t'is-draft': isDraft,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t// Some attributes are stored in an escaped form. It's a legacy issue.\n\t\t\t\t\t\t\t\t\t\t\t// Ideally they would be stored in a raw, unescaped form.\n\t\t\t\t\t\t\t\t\t\t\t// Unescape is used here to \"recover\" the escaped characters\n\t\t\t\t\t\t\t\t\t\t\t// so they display without encoding.\n\t\t\t\t\t\t\t\t\t\t\t// See `updateAttributes` for more details.\n\t\t\t\t\t\t\t\t\t\t\t`${ decodeEntities( label ) } ${\n\t\t\t\t\t\t\t\t\t\t\t\tisInvalid || isDraft\n\t\t\t\t\t\t\t\t\t\t\t\t\t? placeholderText\n\t\t\t\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t\t\t\t}`.trim()\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</div>\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\t{ isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tref={ linkUIref }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\t// If there is no link then remove the auto-inserted block.\n\t\t\t\t\t\t\t\t// This avoids empty blocks which can provided a poor UX.\n\t\t\t\t\t\t\t\tif ( ! url ) {\n\t\t\t\t\t\t\t\t\t// Fixes https://github.com/WordPress/gutenberg/issues/61361\n\t\t\t\t\t\t\t\t\t// There's a chance we're closing due to the user selecting the browse all button.\n\t\t\t\t\t\t\t\t\t// Only move focus if the focus is still within the popover ui. If it's not within\n\t\t\t\t\t\t\t\t\t// the popover, it's because something has taken the focus from the popover, and\n\t\t\t\t\t\t\t\t\t// we don't want to steal it back.\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tlinkUIref.current.contains(\n\t\t\t\t\t\t\t\t\t\t\twindow.document.activeElement\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t// Select the previous block to keep focus nearby\n\t\t\t\t\t\t\t\t\t\tselectPreviousBlock( clientId, true );\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Remove the link.\n\t\t\t\t\t\t\t\t\tonReplace( [] );\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\tif ( openedBy ) {\n\t\t\t\t\t\t\t\t\topenedBy.focus();\n\t\t\t\t\t\t\t\t\tsetOpenedBy( null );\n\t\t\t\t\t\t\t\t} else if ( ref.current ) {\n\t\t\t\t\t\t\t\t\t// select the ref when adding a new link\n\t\t\t\t\t\t\t\t\tref.current.focus();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// Fallback\n\t\t\t\t\t\t\t\t\tselectPreviousBlock( clientId, true );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ removeLink }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\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</a>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AASA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAUA,IAAAO,IAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,IAAA,GAAAT,OAAA;AACA,IAAAU,aAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,SAAA,GAAAZ,OAAA;AACA,IAAAa,QAAA,GAAAb,OAAA;AAKA,IAAAc,OAAA,GAAAd,OAAA;AACA,IAAAe,iBAAA,GAAAf,OAAA;AACA,IAAAgB,MAAA,GAAAhB,OAAA;AACA,IAAAiB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Q,CAACC,aACjB,CAAC,EACA;gBACD;gBACAzG,mBAAmB,CAAEL,QAAQ,EAAE,IAAK,CAAC;cACtC;;cAEA;cACAF,SAAS,CAAE,EAAG,CAAC;cACf;YACD;YAEAW,aAAa,CAAE,KAAM,CAAC;YACtB,IAAKC,QAAQ,EAAG;cACfA,QAAQ,CAACsC,KAAK,CAAC,CAAC;cAChBrC,WAAW,CAAE,IAAK,CAAC;YACpB,CAAC,MAAM,IAAKM,GAAG,CAAC7F,OAAO,EAAG;cACzB;cACA6F,GAAG,CAAC7F,OAAO,CAAC4H,KAAK,CAAC,CAAC;YACpB,CAAC,MAAM;cACN;cACA3C,mBAAmB,CAAEL,QAAQ,EAAE,IAAK,CAAC;YACtC;UACD,CAAG;UACH+G,MAAM,EAAGnG,aAAe;UACxBoG,QAAQ,EAAGvD,UAAY;UACvB7E,QAAQ,EAAKqI,YAAY,IAAM;YAC9B,IAAA9H,kCAAgB,EACf8H,YAAY,EACZ5J,aAAa,EACbD,UACD,CAAC;UACF;QAAG,CACH,CACD;MAAA,CACC,CAAC,eACJ,IAAA3C,WAAA,CAAAyD,GAAA;QAAA,GAAU2G;MAAgB,CAAI,CAAC;IAAA,CAC3B,CAAC;EAAA,CACL,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_blocks","_data","_components","_keycodes","_i18n","_blockEditor","_url","_element","_dom","_htmlEntities","_icons","_coreData","_compose","_linkUi","_updateAttributes","_utils","_hooks","_jsxRuntime","DEFAULT_BLOCK","name","NESTING_BLOCK_NAMES","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","useState","useEffect","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","useIsInvalidLink","kind","type","id","enabled","isPostType","hasId","Number","isInteger","blockEditingMode","useBlockEditingMode","postStatus","useSelect","select","getEntityRecord","coreStore","status","isInvalid","isDraft","getMissingText","missingText","__","Controls","attributes","setAttributes","setIsEditingControl","label","url","description","rel","opensInNewTab","lastURLRef","useRef","dropdownMenuProps","useToolsPanelDropdownMenuProps","jsxs","__experimentalToolsPanel","resetAll","children","jsx","__experimentalToolsPanelItem","hasValue","onDeselect","isShownByDefault","TextControl","__nextHasNoMarginBottom","__next40pxDefaultSize","value","stripHTML","onChange","labelValue","autoComplete","onFocus","onBlur","safeDecodeURI","urlValue","encodeURI","updateAttributes","CheckboxControl","checked","TextareaControl","descriptionValue","help","relValue","NavigationLinkEdit","isSelected","insertBlocksAfter","mergeBlocks","onReplace","context","clientId","maxNestingLevel","replaceBlock","__unstableMarkNextChangeAsNotPersistent","selectBlock","selectPreviousBlock","useDispatch","blockEditorStore","isLinkOpen","setIsLinkOpen","openedBy","setOpenedBy","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","linkUIref","prevUrl","usePrevious","isEditingControl","isAtMaxNesting","isTopLevelLink","isParentOfSelectedBlock","hasChildren","validateLinkStatus","getBlockCount","getBlockName","getBlockRootClientId","hasSelectedInnerBlock","getBlockParentsByBlockName","getSelectedBlockClientId","rootClientId","isTopLevel","selectedBlockClientId","rootNavigationClientId","enableLinkStatusValidation","length","getBlocks","transformToSubmenu","innerBlocks","createBlock","newSubmenu","isURL","prependHTTP","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","removeLink","undefined","textColor","customTextColor","backgroundColor","customBackgroundColor","getColors","onKeyDown","isKeyboardEvent","primary","preventDefault","stopPropagation","blockProps","useBlockProps","useMergeRefs","className","clsx","getColorClassName","style","color","innerBlocksProps","useInnerBlocksProps","defaultBlock","directInsert","renderAppender","onClick","classes","placeholderText","Fragment","BlockControls","ToolbarGroup","ToolbarButton","icon","linkIcon","title","shortcut","displayShortcut","currentTarget","addSubmenu","InspectorControls","RichText","identifier","onMerge","__unstableOnSplitAtEnd","placeholder","withoutInteractiveFormatting","decodeEntities","trim","LinkUI","link","onClose","window","document","activeElement","anchor","onRemove","updatedValue"],"sources":["@wordpress/block-library/src/navigation-link/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tCheckboxControl,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n\tuseInnerBlocksProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP, safeDecodeURI } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { link as linkIcon, addSubmenu } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { LinkUI } from './link-ui';\nimport { updateAttributes } from './update-attributes';\nimport { getColors } from '../navigation/edit/utils';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst DEFAULT_BLOCK = { name: 'core/navigation-link' };\nconst NESTING_BLOCK_NAMES = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [ elementRef ] );\n\n\treturn isDraggingWithin;\n};\n\nconst useIsInvalidLink = ( kind, type, id, enabled ) => {\n\tconst isPostType =\n\t\tkind === 'post-type' || type === 'post' || type === 'page';\n\tconst hasId = Number.isInteger( id );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst postStatus = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isPostType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Fetching the posts status is an \"expensive\" operation. Especially for sites with large navigations.\n\t\t\t// When the block is rendered in a template or other disabled contexts we can skip this check in order\n\t\t\t// to avoid all these additional requests that don't really add any value in that mode.\n\t\t\tif ( blockEditingMode === 'disabled' || ! enabled ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'postType', type, id )?.status;\n\t\t},\n\t\t[ isPostType, blockEditingMode, enabled, type, id ]\n\t);\n\n\t// Check Navigation Link validity if:\n\t// 1. Link is 'post-type'.\n\t// 2. It has an id.\n\t// 3. It's neither null, nor undefined, as valid items might be either of those while loading.\n\t// If those conditions are met, check if\n\t// 1. The post status is published.\n\t// 2. The Navigation Link item has no label.\n\t// If either of those is true, invalidate.\n\tconst isInvalid =\n\t\tisPostType && hasId && postStatus && 'trash' === postStatus;\n\tconst isDraft = 'draft' === postStatus;\n\n\treturn [ isInvalid, isDraft ];\n};\n\nfunction getMissingText( type ) {\n\tlet missingText = '';\n\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\t\t/* translators: label for missing post in navigation link block */\n\t\t\tmissingText = __( 'Select post' );\n\t\t\tbreak;\n\t\tcase 'page':\n\t\t\t/* translators: label for missing page in navigation link block */\n\t\t\tmissingText = __( 'Select page' );\n\t\t\tbreak;\n\t\tcase 'category':\n\t\t\t/* translators: label for missing category in navigation link block */\n\t\t\tmissingText = __( 'Select category' );\n\t\t\tbreak;\n\t\tcase 'tag':\n\t\t\t/* translators: label for missing tag in navigation link block */\n\t\t\tmissingText = __( 'Select tag' );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t/* translators: label for missing values in navigation link block */\n\t\t\tmissingText = __( 'Add link' );\n\t}\n\n\treturn missingText;\n}\n\n/*\n * Warning, this duplicated in\n * packages/block-library/src/navigation-submenu/edit.js\n * Consider reusing this components for both blocks.\n */\nfunction Controls( { attributes, setAttributes, setIsEditingControl } ) {\n\tconst { label, url, description, rel, opensInNewTab } = attributes;\n\tconst lastURLRef = useRef( url );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ __( 'Settings' ) }\n\t\t\tresetAll={ () => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tlabel: '',\n\t\t\t\t\turl: '',\n\t\t\t\t\tdescription: '',\n\t\t\t\t\trel: '',\n\t\t\t\t\topensInNewTab: false,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! label }\n\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { label: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\tvalue={ label ? stripHTML( label ) : '' }\n\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t} }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\tonFocus={ () => setIsEditingControl( true ) }\n\t\t\t\t\tonBlur={ () => setIsEditingControl( false ) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! url }\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { url: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\tvalue={ url ? safeDecodeURI( url ) : '' }\n\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\turl: encodeURI( safeDecodeURI( urlValue ) ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\ttype=\"url\"\n\t\t\t\t\tonFocus={ () => {\n\t\t\t\t\t\tlastURLRef.current = url;\n\t\t\t\t\t\tsetIsEditingControl( true );\n\t\t\t\t\t} }\n\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\t// Defer the updateAttributes call to ensure entity connection isn't severed by accident.\n\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t{ url: ! url ? lastURLRef.current : url },\n\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t{ ...attributes, url: lastURLRef.current }\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsetIsEditingControl( false );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! opensInNewTab }\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { opensInNewTab: false } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\tchecked={ opensInNewTab }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { opensInNewTab: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! description }\n\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { description: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextareaControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\tsetAttributes( { description: descriptionValue } );\n\t\t\t\t\t} }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! rel }\n\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { rel: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t} }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'The relationship of the linked URL as space-separated link types.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</ToolsPanel>\n\t);\n}\n\nexport default function NavigationLinkEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { id, label, type, url, description, kind } = attributes;\n\tconst { maxNestingLevel } = context;\n\n\tconst {\n\t\treplaceBlock,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tselectBlock,\n\t\tselectPreviousBlock,\n\t} = useDispatch( blockEditorStore );\n\t// Have the link editing ui open on mount when lacking a url and selected.\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( isSelected && ! url );\n\t// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add label…' );\n\tconst ref = useRef();\n\tconst linkUIref = useRef();\n\tconst prevUrl = usePrevious( url );\n\n\t// Change the `label` and `url` using inspector causes RichText to change focus.\n\t// This is a workaround to keep the focus on the field when it's focused we don't render the RichText.\n\t// See: https://github.com/WordPress/gutenberg/pull/61374.\n\tconst [ isEditingControl, setIsEditingControl ] = useState( false );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t\tvalidateLinkStatus,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst isTopLevel =\n\t\t\t\tgetBlockName( rootClientId ) === 'core/navigation';\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\tconst rootNavigationClientId = isTopLevel\n\t\t\t\t? rootClientId\n\t\t\t\t: getBlockParentsByBlockName(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'core/navigation'\n\t\t\t\t )[ 0 ];\n\n\t\t\t// Enable when the root Navigation block is selected or any of its inner blocks.\n\t\t\tconst enableLinkStatusValidation =\n\t\t\t\tselectedBlockClientId === rootNavigationClientId ||\n\t\t\t\thasSelectedInnerBlock( rootNavigationClientId, true );\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, NESTING_BLOCK_NAMES )\n\t\t\t\t\t\t.length >= maxNestingLevel,\n\t\t\t\tisTopLevelLink: isTopLevel,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tvalidateLinkStatus: enableLinkStatusValidation,\n\t\t\t};\n\t\t},\n\t\t[ clientId, maxNestingLevel ]\n\t);\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink(\n\t\tkind,\n\t\ttype,\n\t\tid,\n\t\tvalidateLinkStatus\n\t);\n\n\t/**\n\t * Transform to submenu block.\n\t */\n\tconst transformToSubmenu = () => {\n\t\tlet innerBlocks = getBlocks( clientId );\n\t\tif ( innerBlocks.length === 0 ) {\n\t\t\tinnerBlocks = [ createBlock( 'core/navigation-link' ) ];\n\t\t\tselectBlock( innerBlocks[ 0 ].clientId );\n\t\t}\n\t\tconst newSubmenu = createBlock(\n\t\t\t'core/navigation-submenu',\n\t\t\tattributes,\n\t\t\tinnerBlocks\n\t\t);\n\t\treplaceBlock( clientId, newSubmenu );\n\t};\n\n\tuseEffect( () => {\n\t\t// If block has inner blocks, transform to Submenu.\n\t\tif ( hasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToSubmenu();\n\t\t}\n\t}, [ hasChildren ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\t// We only want to do this when the URL has gone from nothing to a new URL AND the label looks like a URL\n\t\tif (\n\t\t\t! prevUrl &&\n\t\t\turl &&\n\t\t\tisLinkOpen &&\n\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t) {\n\t\t\t// Focus and select the label text.\n\t\t\tselectLabelText();\n\t\t}\n\t}, [ prevUrl, url, isLinkOpen, label ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\t/**\n\t * Removes the current link if set.\n\t */\n\tfunction removeLink() {\n\t\t// Reset all attributes that comprise the link.\n\t\t// It is critical that all attributes are reset\n\t\t// to their default values otherwise this may\n\t\t// in advertently trigger side effects because\n\t\t// the values will have \"changed\".\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlabel: undefined,\n\t\t\tid: undefined,\n\t\t\tkind: undefined,\n\t\t\ttype: undefined,\n\t\t\topensInNewTab: false,\n\t\t} );\n\n\t\t// Close the link editing UI.\n\t\tsetIsLinkOpen( false );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelLink );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If this link is a child of a parent submenu item, the parent submenu item event will also open, closing this popover\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\t...blockProps,\n\t\t\tclassName: 'remove-outline', // Remove the outline from the inner blocks container.\n\t\t},\n\t\t{\n\t\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\t\tdirectInsert: true,\n\t\t\trenderAppender: false,\n\t\t}\n\t);\n\n\tif ( ! url || isInvalid || isDraft ) {\n\t\tblockProps.onClick = () => {\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t};\n\t}\n\n\tconst classes = clsx( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder': ! url || isInvalid || isDraft,\n\t} );\n\n\tconst missingText = getMissingText( type );\n\t/* translators: Whether the navigation link is Invalid or a Draft. */\n\tconst placeholderText = `(${\n\t\tisInvalid ? __( 'Invalid' ) : __( 'Draft' )\n\t})`;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\tsetOpenedBy( event.currentTarget );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! isAtMaxNesting && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"submenu\"\n\t\t\t\t\t\t\ticon={ addSubmenu }\n\t\t\t\t\t\t\ttitle={ __( 'Add submenu' ) }\n\t\t\t\t\t\t\tonClick={ transformToSubmenu }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ /* Warning, this duplicated in packages/block-library/src/navigation-submenu/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tsetIsEditingControl={ setIsEditingControl }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<a className={ classes }>\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{ ! url && ! isEditingControl ? (\n\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text\">\n\t\t\t\t\t\t\t<span>{ missingText }</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isInvalid &&\n\t\t\t\t\t\t\t\t! isDraft &&\n\t\t\t\t\t\t\t\t! isEditingControl && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: labelValue,\n\t\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'core/navigation-link'\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Navigation link text'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t{ description && (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( isInvalid || isDraft || isEditingControl ) && (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t'wp-block-navigation-link__placeholder-text',\n\t\t\t\t\t\t\t\t\t\t'wp-block-navigation-link__label',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t'is-invalid': isInvalid,\n\t\t\t\t\t\t\t\t\t\t\t'is-draft': isDraft,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t// Some attributes are stored in an escaped form. It's a legacy issue.\n\t\t\t\t\t\t\t\t\t\t\t// Ideally they would be stored in a raw, unescaped form.\n\t\t\t\t\t\t\t\t\t\t\t// Unescape is used here to \"recover\" the escaped characters\n\t\t\t\t\t\t\t\t\t\t\t// so they display without encoding.\n\t\t\t\t\t\t\t\t\t\t\t// See `updateAttributes` for more details.\n\t\t\t\t\t\t\t\t\t\t\t`${ decodeEntities( label ) } ${\n\t\t\t\t\t\t\t\t\t\t\t\tisInvalid || isDraft\n\t\t\t\t\t\t\t\t\t\t\t\t\t? placeholderText\n\t\t\t\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t\t\t\t}`.trim()\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</div>\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\t{ isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tref={ linkUIref }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\t// If there is no link then remove the auto-inserted block.\n\t\t\t\t\t\t\t\t// This avoids empty blocks which can provided a poor UX.\n\t\t\t\t\t\t\t\tif ( ! url ) {\n\t\t\t\t\t\t\t\t\t// Fixes https://github.com/WordPress/gutenberg/issues/61361\n\t\t\t\t\t\t\t\t\t// There's a chance we're closing due to the user selecting the browse all button.\n\t\t\t\t\t\t\t\t\t// Only move focus if the focus is still within the popover ui. If it's not within\n\t\t\t\t\t\t\t\t\t// the popover, it's because something has taken the focus from the popover, and\n\t\t\t\t\t\t\t\t\t// we don't want to steal it back.\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tlinkUIref.current.contains(\n\t\t\t\t\t\t\t\t\t\t\twindow.document.activeElement\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t// Select the previous block to keep focus nearby\n\t\t\t\t\t\t\t\t\t\tselectPreviousBlock( clientId, true );\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Remove the link.\n\t\t\t\t\t\t\t\t\tonReplace( [] );\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\tif ( openedBy ) {\n\t\t\t\t\t\t\t\t\topenedBy.focus();\n\t\t\t\t\t\t\t\t\tsetOpenedBy( null );\n\t\t\t\t\t\t\t\t} else if ( ref.current ) {\n\t\t\t\t\t\t\t\t\t// select the ref when adding a new link\n\t\t\t\t\t\t\t\t\tref.current.focus();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// Fallback\n\t\t\t\t\t\t\t\t\tselectPreviousBlock( clientId, true );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ removeLink }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\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</a>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AASA,IAA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CAAE,IAAK,CAAC;YACpB,CAAC,MAAM,IAAKK,GAAG,CAAC/F,OAAO,EAAG;cACzB;cACA+F,GAAG,CAAC/F,OAAO,CAAC8H,KAAK,CAAC,CAAC;YACpB,CAAC,MAAM;cACN;cACA1C,mBAAmB,CAAEL,QAAQ,EAAE,IAAK,CAAC;YACtC;UACD,CAAG;UACH8G,MAAM,EAAGlG,aAAe;UACxBmG,QAAQ,EAAGvD,UAAY;UACvB7E,QAAQ,EAAKqI,YAAY,IAAM;YAC9B,IAAA7H,kCAAgB,EACf6H,YAAY,EACZ9J,aAAa,EACbD,UACD,CAAC;UACF;QAAG,CACH,CACD;MAAA,CACC,CAAC,eACJ,IAAA3C,WAAA,CAAA2D,GAAA;QAAA,GAAU2G;MAAgB,CAAI,CAAC;IAAA,CAC3B,CAAC;EAAA,CACL,CAAC;AAEL","ignoreList":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* wp:polyfill */
|
|
1
2
|
"use strict";
|
|
2
3
|
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -10,6 +11,79 @@ var _url = require("@wordpress/url");
|
|
|
10
11
|
* WordPress dependencies
|
|
11
12
|
*/
|
|
12
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Determines if an entity link should be severed based on URL changes.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} originalUrl - The original URL
|
|
18
|
+
* @param {string} newUrl - The new URL
|
|
19
|
+
* @return {boolean} True if the entity link should be severed
|
|
20
|
+
*/
|
|
21
|
+
const shouldSeverEntityLink = (originalUrl, newUrl) => {
|
|
22
|
+
if (!originalUrl || !newUrl) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const normalizePath = path => {
|
|
26
|
+
if (!path) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
return path.replace(/\/+$/, ''); // Remove trailing slashes
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Helper function to create URL objects with proper base handling
|
|
33
|
+
const createUrlObject = (url, baseUrl = null) => {
|
|
34
|
+
try {
|
|
35
|
+
// Always provide a base URL - it will be ignored for absolute URLs
|
|
36
|
+
// Use window.location.origin in browser, fallback for Node/tests
|
|
37
|
+
const base = baseUrl || (typeof window !== 'undefined' ? window.location.origin : 'https://wordpress.org');
|
|
38
|
+
return new URL(url, base);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
// If URL construction still fails, it's likely an invalid URL
|
|
41
|
+
// and we should sever the entity link
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const originalUrlObj = createUrlObject(originalUrl);
|
|
46
|
+
if (!originalUrlObj) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
const newUrlObj = createUrlObject(newUrl, originalUrl);
|
|
50
|
+
if (!newUrlObj) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Move these declarations here, after the null checks
|
|
55
|
+
const originalHostname = originalUrlObj.hostname;
|
|
56
|
+
const newHostname = newUrlObj.hostname;
|
|
57
|
+
const originalPath = normalizePath((0, _url.getPath)(originalUrlObj.toString()));
|
|
58
|
+
const newPath = normalizePath((0, _url.getPath)(newUrlObj.toString()));
|
|
59
|
+
|
|
60
|
+
// If hostname or path changed, sever the entity link
|
|
61
|
+
if (originalHostname !== newHostname || originalPath !== newPath) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Special handling for plain permalinks (query string post IDs)
|
|
66
|
+
const originalP = originalUrlObj.searchParams.get('p');
|
|
67
|
+
const newP = newUrlObj.searchParams.get('p');
|
|
68
|
+
|
|
69
|
+
// If both are plain permalinks (with ?p= or ?page_id=), compare the IDs
|
|
70
|
+
if (originalP && newP && originalP !== newP) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
const originalPageId = originalUrlObj.searchParams.get('page_id');
|
|
74
|
+
const newPageId = newUrlObj.searchParams.get('page_id');
|
|
75
|
+
if (originalPageId && newPageId && originalPageId !== newPageId) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
// If switching between ?p= and ?page_id=, or one is missing, sever
|
|
79
|
+
if (originalP && newPageId || originalPageId && newP) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// If only query string or fragment changed, preserve the entity link
|
|
84
|
+
return false;
|
|
85
|
+
};
|
|
86
|
+
|
|
13
87
|
/**
|
|
14
88
|
* @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind
|
|
15
89
|
*/
|
|
@@ -36,6 +110,7 @@ var _url = require("@wordpress/url");
|
|
|
36
110
|
*/
|
|
37
111
|
|
|
38
112
|
const updateAttributes = (updatedValue = {}, setAttributes, blockAttributes = {}) => {
|
|
113
|
+
var _newUrl$replace;
|
|
39
114
|
const {
|
|
40
115
|
label: originalLabel = '',
|
|
41
116
|
kind: originalKind = '',
|
|
@@ -44,15 +119,20 @@ const updateAttributes = (updatedValue = {}, setAttributes, blockAttributes = {}
|
|
|
44
119
|
const {
|
|
45
120
|
title: newLabel = '',
|
|
46
121
|
// the title of any provided Post.
|
|
47
|
-
|
|
122
|
+
label: newLabelFromLabel = '',
|
|
123
|
+
// alternative to title
|
|
124
|
+
url: newUrl,
|
|
48
125
|
opensInNewTab,
|
|
49
|
-
id,
|
|
126
|
+
id: newID,
|
|
50
127
|
kind: newKind = originalKind,
|
|
51
128
|
type: newType = originalType
|
|
52
129
|
} = updatedValue;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
130
|
+
|
|
131
|
+
// Use title if provided, otherwise fall back to label
|
|
132
|
+
const finalNewLabel = newLabel || newLabelFromLabel;
|
|
133
|
+
const newLabelWithoutHttp = finalNewLabel.replace(/http(s?):\/\//gi, '');
|
|
134
|
+
const newUrlWithoutHttp = (_newUrl$replace = newUrl?.replace(/http(s?):\/\//gi, '')) !== null && _newUrl$replace !== void 0 ? _newUrl$replace : '';
|
|
135
|
+
const useNewLabel = finalNewLabel && finalNewLabel !== originalLabel &&
|
|
56
136
|
// LinkControl without the title field relies
|
|
57
137
|
// on the check below. Specifically, it assumes that
|
|
58
138
|
// the URL is the same as a title.
|
|
@@ -70,34 +150,52 @@ const updateAttributes = (updatedValue = {}, setAttributes, blockAttributes = {}
|
|
|
70
150
|
// See also:
|
|
71
151
|
// - https://github.com/WordPress/gutenberg/pull/41063
|
|
72
152
|
// - https://github.com/WordPress/gutenberg/pull/18617.
|
|
73
|
-
const label = useNewLabel ? (0, _escapeHtml.escapeHTML)(
|
|
153
|
+
const label = useNewLabel ? (0, _escapeHtml.escapeHTML)(finalNewLabel) : originalLabel || (0, _escapeHtml.escapeHTML)(newUrlWithoutHttp);
|
|
74
154
|
|
|
75
155
|
// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
|
|
76
156
|
const type = newType === 'post_tag' ? 'tag' : newType.replace('-', '_');
|
|
77
157
|
const isBuiltInType = ['post', 'page', 'tag', 'category'].indexOf(type) > -1;
|
|
78
158
|
const isCustomLink = !newKind && !isBuiltInType || newKind === 'custom';
|
|
79
159
|
const kind = isCustomLink ? 'custom' : newKind;
|
|
80
|
-
|
|
160
|
+
const attributes = {
|
|
81
161
|
// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
|
|
82
|
-
...(newUrl
|
|
83
|
-
url: encodeURI((0, _url.safeDecodeURI)(newUrl))
|
|
84
|
-
}),
|
|
162
|
+
...(newUrl !== undefined ? {
|
|
163
|
+
url: newUrl ? encodeURI((0, _url.safeDecodeURI)(newUrl)) : newUrl
|
|
164
|
+
} : {}),
|
|
85
165
|
...(label && {
|
|
86
166
|
label
|
|
87
167
|
}),
|
|
88
168
|
...(undefined !== opensInNewTab && {
|
|
89
169
|
opensInNewTab
|
|
90
170
|
}),
|
|
91
|
-
...(id && Number.isInteger(id) && {
|
|
92
|
-
id
|
|
93
|
-
}),
|
|
94
171
|
...(kind && {
|
|
95
172
|
kind
|
|
96
173
|
}),
|
|
97
174
|
...(type && type !== 'URL' && {
|
|
98
175
|
type
|
|
99
176
|
})
|
|
100
|
-
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// If the block's id is set then the menu item is linking to an entity.
|
|
180
|
+
// Therefore, if the URL is set but a new ID is not provided, check if
|
|
181
|
+
// the entity link should be severed based on URL changes.
|
|
182
|
+
if (newUrl && !newID && blockAttributes.id) {
|
|
183
|
+
const shouldSever = shouldSeverEntityLink(blockAttributes.url, newUrl);
|
|
184
|
+
if (shouldSever) {
|
|
185
|
+
attributes.id = undefined; // explicitly "unset" the ID.
|
|
186
|
+
// When URL is manually changed in a way that severs the entity link,
|
|
187
|
+
// update kind and type to "custom" to indicate this is now a custom link.
|
|
188
|
+
attributes.kind = 'custom';
|
|
189
|
+
attributes.type = 'custom';
|
|
190
|
+
}
|
|
191
|
+
} else if (newID && Number.isInteger(newID)) {
|
|
192
|
+
attributes.id = newID;
|
|
193
|
+
} else if (blockAttributes.id) {
|
|
194
|
+
// If we have an existing ID and no URL change, ensure kind and type are preserved
|
|
195
|
+
attributes.kind = kind;
|
|
196
|
+
attributes.type = type;
|
|
197
|
+
}
|
|
198
|
+
setAttributes(attributes);
|
|
101
199
|
};
|
|
102
200
|
exports.updateAttributes = updateAttributes;
|
|
103
201
|
//# sourceMappingURL=update-attributes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_escapeHtml","require","_url","updateAttributes","updatedValue","setAttributes","blockAttributes","label","originalLabel","kind","originalKind","type","originalType","title","newLabel","url","newUrl","opensInNewTab","id","newKind","newType","newLabelWithoutHttp","replace","newUrlWithoutHttp","useNewLabel","escapeHTML","isBuiltInType","indexOf","isCustomLink","encodeURI","safeDecodeURI","undefined","Number","isInteger","exports"],"sources":["@wordpress/block-library/src/navigation-link/update-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { escapeHTML } from '@wordpress/escape-html';\nimport { safeDecodeURI } from '@wordpress/url';\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n */\n\nexport const updateAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\n\tconst {\n\t\ttitle: newLabel = '', // the title of any provided Post.\n\t\turl: newUrl = '',\n\t\topensInNewTab,\n\t\tid,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\tconst newLabelWithoutHttp = newLabel.replace( /http(s?):\\/\\//gi, '' );\n\tconst newUrlWithoutHttp = newUrl.replace( /http(s?):\\/\\//gi, '' );\n\n\tconst useNewLabel =\n\t\tnewLabel &&\n\t\tnewLabel !== originalLabel &&\n\t\t// LinkControl without the title field relies\n\t\t// on the check below. Specifically, it assumes that\n\t\t// the URL is the same as a title.\n\t\t// This logic a) looks suspicious and b) should really\n\t\t// live in the LinkControl and not here. It's a great\n\t\t// candidate for future refactoring.\n\t\tnewLabelWithoutHttp !== newUrlWithoutHttp;\n\n\t// Unfortunately this causes the escaping model to be inverted.\n\t// The escaped content is stored in the block attributes (and ultimately in the database),\n\t// and then the raw data is \"recovered\" when outputting into the DOM.\n\t// It would be preferable to store the **raw** data in the block attributes and escape it in JS.\n\t// Why? Because there isn't one way to escape data. Depending on the context, you need to do\n\t// different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.\n\t// See also:\n\t// - https://github.com/WordPress/gutenberg/pull/41063\n\t// - https://github.com/WordPress/gutenberg/pull/18617.\n\tconst label = useNewLabel\n\t\t? escapeHTML( newLabel )\n\t\t: originalLabel || escapeHTML( newUrlWithoutHttp );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tsetAttributes( {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...( newUrl && { url: encodeURI( safeDecodeURI( newUrl ) ) } ),\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( id && Number.isInteger( id ) && { id } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t} );\n};\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAME,gBAAgB,GAAGA,CAC/BC,YAAY,GAAG,CAAC,CAAC,EACjBC,aAAa,EACbC,eAAe,GAAG,CAAC,CAAC,KAChB;EACJ,MAAM;IACLC,KAAK,EAAEC,aAAa,GAAG,EAA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GAAG,EAAEc,SAAS,CAAE,IAAAC,kBAAa,EAAEd,MAAO,CAAE;IAAE,CAAC,CAAE;IAC9D,IAAKT,KAAK,IAAI;MAAEA;IAAM,CAAC,CAAE;IACzB,IAAKwB,SAAS,KAAKd,aAAa,IAAI;MAAEA;IAAc,CAAC,CAAE;IACvD,IAAKC,EAAE,IAAIc,MAAM,CAACC,SAAS,CAAEf,EAAG,CAAC,IAAI;MAAEA;IAAG,CAAC,CAAE;IAC7C,IAAKT,IAAI,IAAI;MAAEA;IAAK,CAAC,CAAE;IACvB,IAAKE,IAAI,IAAIA,IAAI,KAAK,KAAK,IAAI;MAAEA;IAAK,CAAC;EACxC,CAAE,CAAC;AACJ,CAAC;AAACuB,OAAA,CAAA/B,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_escapeHtml","require","_url","shouldSeverEntityLink","originalUrl","newUrl","normalizePath","path","replace","createUrlObject","url","baseUrl","base","window","location","origin","URL","error","originalUrlObj","newUrlObj","originalHostname","hostname","newHostname","originalPath","getPath","toString","newPath","originalP","searchParams","get","newP","originalPageId","newPageId","updateAttributes","updatedValue","setAttributes","blockAttributes","_newUrl$replace","label","originalLabel","kind","originalKind","type","originalType","title","newLabel","newLabelFromLabel","opensInNewTab","id","newID","newKind","newType","finalNewLabel","newLabelWithoutHttp","newUrlWithoutHttp","useNewLabel","escapeHTML","isBuiltInType","indexOf","isCustomLink","attributes","undefined","encodeURI","safeDecodeURI","shouldSever","Number","isInteger","exports"],"sources":["@wordpress/block-library/src/navigation-link/update-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { escapeHTML } from '@wordpress/escape-html';\nimport { safeDecodeURI, getPath } from '@wordpress/url';\n\n/**\n * Determines if an entity link should be severed based on URL changes.\n *\n * @param {string} originalUrl - The original URL\n * @param {string} newUrl - The new URL\n * @return {boolean} True if the entity link should be severed\n */\nconst shouldSeverEntityLink = ( originalUrl, newUrl ) => {\n\tif ( ! originalUrl || ! newUrl ) {\n\t\treturn false;\n\t}\n\n\tconst normalizePath = ( path ) => {\n\t\tif ( ! path ) {\n\t\t\treturn '';\n\t\t}\n\t\treturn path.replace( /\\/+$/, '' ); // Remove trailing slashes\n\t};\n\n\t// Helper function to create URL objects with proper base handling\n\tconst createUrlObject = ( url, baseUrl = null ) => {\n\t\ttry {\n\t\t\t// Always provide a base URL - it will be ignored for absolute URLs\n\t\t\t// Use window.location.origin in browser, fallback for Node/tests\n\t\t\tconst base =\n\t\t\t\tbaseUrl ||\n\t\t\t\t( typeof window !== 'undefined'\n\t\t\t\t\t? window.location.origin\n\t\t\t\t\t: 'https://wordpress.org' );\n\t\t\treturn new URL( url, base );\n\t\t} catch ( error ) {\n\t\t\t// If URL construction still fails, it's likely an invalid URL\n\t\t\t// and we should sever the entity link\n\t\t\treturn null;\n\t\t}\n\t};\n\n\tconst originalUrlObj = createUrlObject( originalUrl );\n\tif ( ! originalUrlObj ) {\n\t\treturn true;\n\t}\n\n\tconst newUrlObj = createUrlObject( newUrl, originalUrl );\n\tif ( ! newUrlObj ) {\n\t\treturn true;\n\t}\n\n\t// Move these declarations here, after the null checks\n\tconst originalHostname = originalUrlObj.hostname;\n\tconst newHostname = newUrlObj.hostname;\n\tconst originalPath = normalizePath( getPath( originalUrlObj.toString() ) );\n\tconst newPath = normalizePath( getPath( newUrlObj.toString() ) );\n\n\t// If hostname or path changed, sever the entity link\n\tif ( originalHostname !== newHostname || originalPath !== newPath ) {\n\t\treturn true;\n\t}\n\n\t// Special handling for plain permalinks (query string post IDs)\n\tconst originalP = originalUrlObj.searchParams.get( 'p' );\n\tconst newP = newUrlObj.searchParams.get( 'p' );\n\n\t// If both are plain permalinks (with ?p= or ?page_id=), compare the IDs\n\tif ( originalP && newP && originalP !== newP ) {\n\t\treturn true;\n\t}\n\n\tconst originalPageId = originalUrlObj.searchParams.get( 'page_id' );\n\tconst newPageId = newUrlObj.searchParams.get( 'page_id' );\n\n\tif ( originalPageId && newPageId && originalPageId !== newPageId ) {\n\t\treturn true;\n\t}\n\t// If switching between ?p= and ?page_id=, or one is missing, sever\n\tif ( ( originalP && newPageId ) || ( originalPageId && newP ) ) {\n\t\treturn true;\n\t}\n\n\t// If only query string or fragment changed, preserve the entity link\n\treturn false;\n};\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n */\n\nexport const updateAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\n\tconst {\n\t\ttitle: newLabel = '', // the title of any provided Post.\n\t\tlabel: newLabelFromLabel = '', // alternative to title\n\t\turl: newUrl,\n\t\topensInNewTab,\n\t\tid: newID,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\t// Use title if provided, otherwise fall back to label\n\tconst finalNewLabel = newLabel || newLabelFromLabel;\n\n\tconst newLabelWithoutHttp = finalNewLabel.replace( /http(s?):\\/\\//gi, '' );\n\tconst newUrlWithoutHttp = newUrl?.replace( /http(s?):\\/\\//gi, '' ) ?? '';\n\n\tconst useNewLabel =\n\t\tfinalNewLabel &&\n\t\tfinalNewLabel !== originalLabel &&\n\t\t// LinkControl without the title field relies\n\t\t// on the check below. Specifically, it assumes that\n\t\t// the URL is the same as a title.\n\t\t// This logic a) looks suspicious and b) should really\n\t\t// live in the LinkControl and not here. It's a great\n\t\t// candidate for future refactoring.\n\t\tnewLabelWithoutHttp !== newUrlWithoutHttp;\n\n\t// Unfortunately this causes the escaping model to be inverted.\n\t// The escaped content is stored in the block attributes (and ultimately in the database),\n\t// and then the raw data is \"recovered\" when outputting into the DOM.\n\t// It would be preferable to store the **raw** data in the block attributes and escape it in JS.\n\t// Why? Because there isn't one way to escape data. Depending on the context, you need to do\n\t// different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.\n\t// See also:\n\t// - https://github.com/WordPress/gutenberg/pull/41063\n\t// - https://github.com/WordPress/gutenberg/pull/18617.\n\tconst label = useNewLabel\n\t\t? escapeHTML( finalNewLabel )\n\t\t: originalLabel || escapeHTML( newUrlWithoutHttp );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tconst attributes = {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...( newUrl !== undefined\n\t\t\t? { url: newUrl ? encodeURI( safeDecodeURI( newUrl ) ) : newUrl }\n\t\t\t: {} ),\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t};\n\n\t// If the block's id is set then the menu item is linking to an entity.\n\t// Therefore, if the URL is set but a new ID is not provided, check if\n\t// the entity link should be severed based on URL changes.\n\tif ( newUrl && ! newID && blockAttributes.id ) {\n\t\tconst shouldSever = shouldSeverEntityLink(\n\t\t\tblockAttributes.url,\n\t\t\tnewUrl\n\t\t);\n\n\t\tif ( shouldSever ) {\n\t\t\tattributes.id = undefined; // explicitly \"unset\" the ID.\n\t\t\t// When URL is manually changed in a way that severs the entity link,\n\t\t\t// update kind and type to \"custom\" to indicate this is now a custom link.\n\t\t\tattributes.kind = 'custom';\n\t\t\tattributes.type = 'custom';\n\t\t}\n\t} else if ( newID && Number.isInteger( newID ) ) {\n\t\tattributes.id = newID;\n\t} else if ( blockAttributes.id ) {\n\t\t// If we have an existing ID and no URL change, ensure kind and type are preserved\n\t\tattributes.kind = kind;\n\t\tattributes.type = type;\n\t}\n\n\tsetAttributes( attributes );\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,qBAAqB,GAAGA,CAAEC,WAAW,EAAEC,MAAM,KAAM;EACxD,IAAK,CAAED,WAAW,IAAI,CAAEC,MAAM,EAAG;IAChC,OAAO,KAAK;EACb;EAEA,MAAMC,aAAa,GAAKC,IAAI,IAAM;IACjC,IAAK,CAAEA,IAAI,EAAG;MACb,OAAO,EAAE;IACV;IACA,OAAOA,IAAI,CAACC,OAAO,CAAE,MAAM,EAAE,EAAG,CAAC,CAAC,CAAC;EACpC,CAAC;;EAED;EACA,MAAMC,eAAe,GAAGA,CAAEC,GAAG,EAAEC,OAAO,GAAG,IAAI,KAAM;IAClD,IAAI;MACH;MACA;MACA,MAAMC,IAAI,GACTD,OAAO,KACL,OAAOE,MAAM,KAAK,WAAW,GAC5BA,MAAM,CAACC,QAAQ,CAACC,MAAM,GACtB,uBAAuB,CAAE;MAC7B,OAAO,IAAIC,GAAG,CAAEN,GAAG,EAAEE,IAAK,CAAC;IAC5B,CAAC,CAAC,OAAQK,KAAK,EAAG;MACjB;MAC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,UAAU,CAAClB,IAAI,GAAG,QAAQ;IAC3B;EACD,CAAC,MAAM,IAAKO,KAAK,IAAIgB,MAAM,CAACC,SAAS,CAAEjB,KAAM,CAAC,EAAG;IAChDW,UAAU,CAACZ,EAAE,GAAGC,KAAK;EACtB,CAAC,MAAM,IAAKb,eAAe,CAACY,EAAE,EAAG;IAChC;IACAY,UAAU,CAACpB,IAAI,GAAGA,IAAI;IACtBoB,UAAU,CAAClB,IAAI,GAAGA,IAAI;EACvB;EAEAP,aAAa,CAAEyB,UAAW,CAAC;AAC5B,CAAC;AAACO,OAAA,CAAAlC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -119,7 +119,8 @@ function NavigationSubmenuEdit({
|
|
|
119
119
|
label,
|
|
120
120
|
url,
|
|
121
121
|
description,
|
|
122
|
-
rel
|
|
122
|
+
rel,
|
|
123
|
+
opensInNewTab
|
|
123
124
|
} = attributes;
|
|
124
125
|
const {
|
|
125
126
|
showSubmenuIcon,
|
|
@@ -327,7 +328,8 @@ function NavigationSubmenuEdit({
|
|
|
327
328
|
label: '',
|
|
328
329
|
url: '',
|
|
329
330
|
description: '',
|
|
330
|
-
rel: ''
|
|
331
|
+
rel: '',
|
|
332
|
+
opensInNewTab: false
|
|
331
333
|
});
|
|
332
334
|
},
|
|
333
335
|
dropdownMenuProps: dropdownMenuProps,
|
|
@@ -370,6 +372,21 @@ function NavigationSubmenuEdit({
|
|
|
370
372
|
autoComplete: "off",
|
|
371
373
|
type: "url"
|
|
372
374
|
})
|
|
375
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
|
|
376
|
+
hasValue: () => !!opensInNewTab,
|
|
377
|
+
label: (0, _i18n.__)('Open in new tab'),
|
|
378
|
+
onDeselect: () => setAttributes({
|
|
379
|
+
opensInNewTab: false
|
|
380
|
+
}),
|
|
381
|
+
isShownByDefault: true,
|
|
382
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
|
|
383
|
+
__nextHasNoMarginBottom: true,
|
|
384
|
+
label: (0, _i18n.__)('Open in new tab'),
|
|
385
|
+
checked: opensInNewTab,
|
|
386
|
+
onChange: value => setAttributes({
|
|
387
|
+
opensInNewTab: value
|
|
388
|
+
})
|
|
389
|
+
})
|
|
373
390
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
|
|
374
391
|
label: (0, _i18n.__)('Description'),
|
|
375
392
|
isShownByDefault: true,
|