@wordpress/block-library 9.35.1-next.16d95556a.0 → 9.36.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/accordion/view.js +46 -4
- package/build/accordion/view.js.map +2 -2
- package/build/accordion-heading/block.json +1 -1
- package/build/accordion-heading/deprecated.js +1 -1
- package/build/accordion-heading/deprecated.js.map +2 -2
- package/build/accordion-panel/block.json +1 -1
- package/build/audio/index.js +29 -0
- package/build/audio/index.js.map +3 -3
- package/build/breadcrumbs/edit.js +1 -1
- package/build/breadcrumbs/edit.js.map +2 -2
- package/build/button/index.js +25 -0
- package/build/button/index.js.map +3 -3
- package/build/code/index.js +15 -0
- package/build/code/index.js.map +3 -3
- package/build/cover/edit/block-controls.js +37 -3
- package/build/cover/edit/block-controls.js.map +3 -3
- package/build/cover/edit/cover-placeholder.js +0 -1
- package/build/cover/edit/cover-placeholder.js.map +2 -2
- package/build/cover/edit/embed-video-url-input.js +83 -0
- package/build/cover/edit/embed-video-url-input.js.map +7 -0
- package/build/cover/edit/index.js +60 -0
- package/build/cover/edit/index.js.map +2 -2
- package/build/cover/embed-video-utils.js +151 -0
- package/build/cover/embed-video-utils.js.map +7 -0
- package/build/cover/index.js +28 -0
- package/build/cover/index.js.map +3 -3
- package/build/cover/save.js +12 -0
- package/build/cover/save.js.map +2 -2
- package/build/cover/shared.js +3 -0
- package/build/cover/shared.js.map +2 -2
- package/build/details/index.js +15 -0
- package/build/details/index.js.map +3 -3
- package/build/file/index.js +33 -0
- package/build/file/index.js.map +3 -3
- package/build/freeform/block.json +1 -1
- package/build/gallery/edit.js +0 -2
- package/build/gallery/edit.js.map +2 -2
- package/build/heading/index.js +15 -0
- package/build/heading/index.js.map +3 -3
- package/build/html/modal.js +139 -148
- package/build/html/modal.js.map +3 -3
- package/build/image/edit.js +0 -1
- package/build/image/edit.js.map +2 -2
- package/build/image/image.js +0 -1
- package/build/image/image.js.map +2 -2
- package/build/image/index.js +46 -0
- package/build/image/index.js.map +3 -3
- package/build/list-item/index.js +15 -0
- package/build/list-item/index.js.map +3 -3
- package/build/math/block.json +28 -1
- package/build/math/edit.js +4 -1
- package/build/math/edit.js.map +2 -2
- package/build/media-text/index.js +35 -0
- package/build/media-text/index.js.map +3 -3
- package/build/media-text/media-container.js +0 -2
- package/build/media-text/media-container.js.map +2 -2
- package/build/missing/block.json +1 -1
- package/build/missing/edit.js +2 -2
- package/build/missing/edit.js.map +1 -1
- package/build/more/index.js +16 -0
- package/build/more/index.js.map +3 -3
- package/build/navigation/block.json +2 -2
- package/build/navigation-link/block.json +2 -1
- package/build/navigation-link/edit.js +42 -11
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/index.js +25 -0
- package/build/navigation-link/index.js.map +3 -3
- package/build/navigation-link/shared/controls.js +15 -19
- package/build/navigation-link/shared/controls.js.map +2 -2
- package/build/navigation-link/shared/index.js +4 -0
- package/build/navigation-link/shared/index.js.map +2 -2
- package/build/navigation-link/shared/use-entity-binding.js +3 -2
- package/build/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build/navigation-submenu/block.json +2 -1
- package/build/navigation-submenu/index.js +25 -0
- package/build/navigation-submenu/index.js.map +3 -3
- package/build/paragraph/deprecated-attributes.js +68 -0
- package/build/paragraph/deprecated-attributes.js.map +7 -0
- package/build/paragraph/edit.js +2 -0
- package/build/paragraph/edit.js.map +3 -3
- package/build/paragraph/index.js +15 -0
- package/build/paragraph/index.js.map +3 -3
- package/build/pattern/block.json +1 -1
- package/build/post-comments-count/edit.js +1 -2
- package/build/post-comments-count/edit.js.map +2 -2
- package/build/post-comments-link/edit.js +10 -7
- package/build/post-comments-link/edit.js.map +2 -2
- package/build/preformatted/index.js +15 -0
- package/build/preformatted/index.js.map +3 -3
- package/build/pullquote/index.js +20 -0
- package/build/pullquote/index.js.map +3 -3
- package/build/search/index.js +26 -0
- package/build/search/index.js.map +3 -3
- package/build/social-link/index.js +25 -0
- package/build/social-link/index.js.map +3 -3
- package/build/social-links/edit.js +1 -1
- package/build/social-links/edit.js.map +1 -1
- package/build/tabs/view.js +17 -4
- package/build/tabs/view.js.map +2 -2
- package/build/template-part/edit/index.js +37 -7
- package/build/template-part/edit/index.js.map +2 -2
- package/build/template-part/edit/utils/hooks.js +2 -3
- package/build/template-part/edit/utils/hooks.js.map +2 -2
- package/build/term-count/index.js +1 -0
- package/build/term-count/index.js.map +2 -2
- package/build/term-name/index.js +1 -0
- package/build/term-name/index.js.map +2 -2
- package/build/verse/index.js +15 -0
- package/build/verse/index.js.map +3 -3
- package/build/video/index.js +30 -0
- package/build/video/index.js.map +3 -3
- package/build-module/accordion/view.js +46 -4
- package/build-module/accordion/view.js.map +2 -2
- package/build-module/accordion-heading/block.json +1 -1
- package/build-module/accordion-heading/deprecated.js +1 -1
- package/build-module/accordion-heading/deprecated.js.map +2 -2
- package/build-module/accordion-panel/block.json +1 -1
- package/build-module/audio/index.js +29 -0
- package/build-module/audio/index.js.map +2 -2
- package/build-module/breadcrumbs/edit.js +1 -1
- package/build-module/breadcrumbs/edit.js.map +2 -2
- package/build-module/button/index.js +25 -0
- package/build-module/button/index.js.map +2 -2
- package/build-module/code/index.js +15 -0
- package/build-module/code/index.js.map +2 -2
- package/build-module/cover/edit/block-controls.js +27 -3
- package/build-module/cover/edit/block-controls.js.map +2 -2
- package/build-module/cover/edit/cover-placeholder.js +0 -1
- package/build-module/cover/edit/cover-placeholder.js.map +2 -2
- package/build-module/cover/edit/embed-video-url-input.js +67 -0
- package/build-module/cover/edit/embed-video-url-input.js.map +7 -0
- package/build-module/cover/edit/index.js +61 -0
- package/build-module/cover/edit/index.js.map +2 -2
- package/build-module/cover/embed-video-utils.js +122 -0
- package/build-module/cover/embed-video-utils.js.map +7 -0
- package/build-module/cover/index.js +28 -0
- package/build-module/cover/index.js.map +2 -2
- package/build-module/cover/save.js +13 -0
- package/build-module/cover/save.js.map +2 -2
- package/build-module/cover/shared.js +2 -0
- package/build-module/cover/shared.js.map +2 -2
- package/build-module/details/index.js +15 -0
- package/build-module/details/index.js.map +2 -2
- package/build-module/file/index.js +34 -1
- package/build-module/file/index.js.map +2 -2
- package/build-module/freeform/block.json +1 -1
- package/build-module/gallery/edit.js +0 -2
- package/build-module/gallery/edit.js.map +2 -2
- package/build-module/heading/index.js +15 -0
- package/build-module/heading/index.js.map +2 -2
- package/build-module/html/modal.js +141 -150
- package/build-module/html/modal.js.map +2 -2
- package/build-module/image/edit.js +0 -1
- package/build-module/image/edit.js.map +2 -2
- package/build-module/image/image.js +0 -1
- package/build-module/image/image.js.map +2 -2
- package/build-module/image/index.js +46 -0
- package/build-module/image/index.js.map +2 -2
- package/build-module/list-item/index.js +15 -0
- package/build-module/list-item/index.js.map +2 -2
- package/build-module/math/block.json +28 -1
- package/build-module/math/edit.js +4 -1
- package/build-module/math/edit.js.map +2 -2
- package/build-module/media-text/index.js +35 -0
- package/build-module/media-text/index.js.map +2 -2
- package/build-module/media-text/media-container.js +0 -2
- package/build-module/media-text/media-container.js.map +2 -2
- package/build-module/missing/block.json +1 -1
- package/build-module/missing/edit.js +2 -2
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/more/index.js +16 -0
- package/build-module/more/index.js.map +2 -2
- package/build-module/navigation/block.json +2 -2
- package/build-module/navigation-link/block.json +2 -1
- package/build-module/navigation-link/edit.js +56 -15
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/index.js +26 -1
- package/build-module/navigation-link/index.js.map +2 -2
- package/build-module/navigation-link/shared/controls.js +12 -18
- package/build-module/navigation-link/shared/controls.js.map +2 -2
- package/build-module/navigation-link/shared/index.js +3 -1
- package/build-module/navigation-link/shared/index.js.map +2 -2
- package/build-module/navigation-link/shared/use-entity-binding.js +3 -2
- package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build-module/navigation-submenu/block.json +2 -1
- package/build-module/navigation-submenu/index.js +26 -1
- package/build-module/navigation-submenu/index.js.map +2 -2
- package/build-module/paragraph/deprecated-attributes.js +37 -0
- package/build-module/paragraph/deprecated-attributes.js.map +7 -0
- package/build-module/paragraph/edit.js +2 -0
- package/build-module/paragraph/edit.js.map +2 -2
- package/build-module/paragraph/index.js +15 -0
- package/build-module/paragraph/index.js.map +2 -2
- package/build-module/pattern/block.json +1 -1
- package/build-module/post-comments-count/edit.js +1 -3
- package/build-module/post-comments-count/edit.js.map +2 -2
- package/build-module/post-comments-link/edit.js +10 -8
- package/build-module/post-comments-link/edit.js.map +2 -2
- package/build-module/preformatted/index.js +15 -0
- package/build-module/preformatted/index.js.map +2 -2
- package/build-module/pullquote/index.js +20 -0
- package/build-module/pullquote/index.js.map +2 -2
- package/build-module/search/index.js +26 -0
- package/build-module/search/index.js.map +2 -2
- package/build-module/social-link/index.js +25 -0
- package/build-module/social-link/index.js.map +2 -2
- package/build-module/social-links/edit.js +1 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/tabs/view.js +17 -4
- package/build-module/tabs/view.js.map +2 -2
- package/build-module/template-part/edit/index.js +37 -7
- package/build-module/template-part/edit/index.js.map +2 -2
- package/build-module/template-part/edit/utils/hooks.js +2 -3
- package/build-module/template-part/edit/utils/hooks.js.map +2 -2
- package/build-module/term-count/index.js +1 -0
- package/build-module/term-count/index.js.map +2 -2
- package/build-module/term-name/index.js +1 -0
- package/build-module/term-name/index.js.map +2 -2
- package/build-module/verse/index.js +15 -0
- package/build-module/verse/index.js.map +2 -2
- package/build-module/video/index.js +30 -0
- package/build-module/video/index.js.map +2 -2
- package/build-style/accordion/style-rtl.css +3 -0
- package/build-style/accordion/style.css +3 -0
- package/build-style/accordion-heading/style-rtl.css +1 -2
- package/build-style/accordion-heading/style.css +1 -2
- package/build-style/accordion-item/style-rtl.css +0 -7
- package/build-style/accordion-item/style.css +0 -7
- package/build-style/accordion-panel/style-rtl.css +1 -4
- package/build-style/accordion-panel/style.css +1 -4
- package/build-style/cover/style-rtl.css +47 -0
- package/build-style/cover/style.css +47 -0
- package/build-style/editor-rtl.css +11 -13
- package/build-style/editor.css +11 -13
- package/build-style/html/editor-rtl.css +11 -13
- package/build-style/html/editor.css +11 -13
- package/build-style/style-rtl.css +52 -12
- package/build-style/style.css +52 -12
- package/package.json +37 -37
- package/src/accordion/style.scss +4 -0
- package/src/accordion/view.js +60 -3
- package/src/accordion-heading/block.json +1 -1
- package/src/accordion-heading/deprecated.js +1 -1
- package/src/accordion-heading/style.scss +1 -9
- package/src/accordion-item/index.php +1 -0
- package/src/accordion-item/style.scss +2 -9
- package/src/accordion-panel/block.json +1 -1
- package/src/accordion-panel/style.scss +1 -5
- package/src/audio/index.js +31 -0
- package/src/breadcrumbs/edit.js +4 -2
- package/src/breadcrumbs/index.php +171 -100
- package/src/button/index.js +27 -0
- package/src/code/index.js +17 -0
- package/src/cover/edit/block-controls.js +26 -2
- package/src/cover/edit/cover-placeholder.js +0 -1
- package/src/cover/edit/embed-video-url-input.js +74 -0
- package/src/cover/edit/index.js +81 -0
- package/src/cover/embed-video-utils.js +196 -0
- package/src/cover/index.js +30 -0
- package/src/cover/index.php +106 -0
- package/src/cover/save.js +14 -0
- package/src/cover/shared.js +1 -0
- package/src/cover/style.scss +47 -0
- package/src/details/index.js +17 -0
- package/src/file/index.js +36 -1
- package/src/freeform/block.json +1 -1
- package/src/gallery/edit.js +0 -2
- package/src/heading/index.js +17 -0
- package/src/html/editor.scss +10 -15
- package/src/html/modal.js +23 -38
- package/src/image/edit.js +0 -1
- package/src/image/image.js +0 -1
- package/src/image/index.js +48 -0
- package/src/image/index.php +1 -0
- package/src/list-item/index.js +17 -0
- package/src/math/block.json +28 -1
- package/src/math/edit.js +4 -1
- package/src/media-text/index.js +37 -0
- package/src/media-text/media-container.js +0 -2
- package/src/missing/block.json +1 -1
- package/src/missing/edit.js +2 -2
- package/src/more/index.js +18 -0
- package/src/navigation/block.json +2 -2
- package/src/navigation-link/block.json +2 -1
- package/src/navigation-link/edit.js +98 -29
- package/src/navigation-link/index.js +28 -1
- package/src/navigation-link/shared/controls.js +13 -17
- package/src/navigation-link/shared/index.js +1 -1
- package/src/navigation-link/shared/use-entity-binding.js +5 -2
- package/src/navigation-submenu/block.json +2 -1
- package/src/navigation-submenu/index.js +28 -1
- package/src/paragraph/deprecated-attributes.js +45 -0
- package/src/paragraph/edit.js +2 -0
- package/src/paragraph/index.js +17 -0
- package/src/pattern/block.json +1 -1
- package/src/post-comments-count/edit.js +1 -9
- package/src/post-comments-link/edit.js +8 -18
- package/src/preformatted/index.js +17 -0
- package/src/pullquote/index.js +22 -0
- package/src/search/index.js +28 -0
- package/src/social-link/index.js +27 -0
- package/src/social-links/edit.js +1 -1
- package/src/style.scss +1 -0
- package/src/tabs/view.js +19 -4
- package/src/template-part/edit/index.js +44 -6
- package/src/template-part/edit/utils/hooks.js +2 -4
- package/src/term-count/index.js +1 -0
- package/src/term-name/index.js +1 -0
- package/src/verse/index.js +17 -0
- package/src/video/index.js +32 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/media-text/media-container.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { ResizableBox, Spinner, Placeholder } from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { media as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { imageFillStyles } from './image-fill';\n\n/**\n * Constants\n */\nconst ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];\nconst noop = () => {};\n\nconst ResizableBoxContainer = forwardRef(\n\t( { isSelected, isStackedOnMobile, ...props }, ref ) => {\n\t\tconst isMobile = useViewportMatch( 'small', '<' );\n\t\treturn (\n\t\t\t<ResizableBox\n\t\t\t\tref={ ref }\n\t\t\t\tshowHandle={\n\t\t\t\t\tisSelected && ( ! isMobile || ! isStackedOnMobile )\n\t\t\t\t}\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t}\n);\n\nfunction ToolbarEditButton( {\n\tmediaId,\n\tmediaUrl,\n\tonSelectMedia,\n\ttoggleUseFeaturedImage,\n\tuseFeaturedImage,\n} ) {\n\treturn (\n\t\t<BlockControls group=\"other\">\n\t\t\t<MediaReplaceFlow\n\t\t\t\tmediaId={ mediaId }\n\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,wBAAmD;AACnD,0BAMO;AACP,kBAAmB;AACnB,qBAAiC;AACjC,kBAA4B;AAC5B,qBAA2B;AAC3B,kBAA0B;AAC1B,qBAAsC;AACtC,mBAA8B;AAK9B,wBAAgC;AAY7B;AAPH,IAAM,sBAAsB,CAAE,SAAS,OAAQ;AAC/C,IAAM,OAAO,MAAM;AAAC;AAEpB,IAAM,4BAAwB;AAAA,EAC7B,CAAE,EAAE,YAAY,mBAAmB,GAAG,MAAM,GAAG,QAAS;AACvD,UAAM,eAAW,iCAAkB,SAAS,GAAI;AAChD,WACC;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,YACC,eAAgB,CAAE,YAAY,CAAE;AAAA,QAE/B,GAAG;AAAA;AAAA,IACN;AAAA,EAEF;AACD;AAEA,SAAS,kBAAmB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC,4CAAC,qCAAc,OAAM,SACpB;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,UAAW;AAAA,MACX,cAAe;AAAA,MACf,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { ResizableBox, Spinner, Placeholder } from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { media as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { imageFillStyles } from './image-fill';\n\n/**\n * Constants\n */\nconst ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];\nconst noop = () => {};\n\nconst ResizableBoxContainer = forwardRef(\n\t( { isSelected, isStackedOnMobile, ...props }, ref ) => {\n\t\tconst isMobile = useViewportMatch( 'small', '<' );\n\t\treturn (\n\t\t\t<ResizableBox\n\t\t\t\tref={ ref }\n\t\t\t\tshowHandle={\n\t\t\t\t\tisSelected && ( ! isMobile || ! isStackedOnMobile )\n\t\t\t\t}\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t}\n);\n\nfunction ToolbarEditButton( {\n\tmediaId,\n\tmediaUrl,\n\tonSelectMedia,\n\ttoggleUseFeaturedImage,\n\tuseFeaturedImage,\n} ) {\n\treturn (\n\t\t<BlockControls group=\"other\">\n\t\t\t<MediaReplaceFlow\n\t\t\t\tmediaId={ mediaId }\n\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\tonToggleFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\tuseFeaturedImage={ useFeaturedImage }\n\t\t\t\tonReset={ () => onSelectMedia( undefined ) }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\nfunction PlaceholderContainer( {\n\tclassName,\n\tmediaUrl,\n\tonSelectMedia,\n\ttoggleUseFeaturedImage,\n} ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\treturn (\n\t\t<MediaPlaceholder\n\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\tlabels={ {\n\t\t\t\ttitle: __( 'Media area' ),\n\t\t\t} }\n\t\t\tclassName={ className }\n\t\t\tonSelect={ onSelectMedia }\n\t\t\tonToggleFeaturedImage={ toggleUseFeaturedImage }\n\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\tonError={ onUploadError }\n\t\t\tdisableMediaButtons={ mediaUrl }\n\t\t/>\n\t);\n}\n\nfunction MediaContainer( props, ref ) {\n\tconst {\n\t\tclassName,\n\t\tcommitWidthChange,\n\t\tfocalPoint,\n\t\timageFill,\n\t\tisSelected,\n\t\tisStackedOnMobile,\n\t\tmediaAlt,\n\t\tmediaId,\n\t\tmediaPosition,\n\t\tmediaType,\n\t\tmediaUrl,\n\t\tmediaWidth,\n\t\tonSelectMedia,\n\t\tonWidthChange,\n\t\tenableResize,\n\t\ttoggleUseFeaturedImage,\n\t\tuseFeaturedImage,\n\t\tfeaturedImageURL,\n\t\tfeaturedImageAlt,\n\t\trefMedia,\n\t} = props;\n\n\tconst isTemporaryMedia = ! mediaId && isBlobURL( mediaUrl );\n\n\tconst { toggleSelection } = useDispatch( blockEditorStore );\n\n\tif ( mediaUrl || featuredImageURL || useFeaturedImage ) {\n\t\tconst onResizeStart = () => {\n\t\t\ttoggleSelection( false );\n\t\t};\n\t\tconst onResize = ( event, direction, elt ) => {\n\t\t\tonWidthChange( parseInt( elt.style.width ) );\n\t\t};\n\t\tconst onResizeStop = ( event, direction, elt ) => {\n\t\t\ttoggleSelection( true );\n\t\t\tcommitWidthChange( parseInt( elt.style.width ) );\n\t\t};\n\t\tconst enablePositions = {\n\t\t\tright: enableResize && mediaPosition === 'left',\n\t\t\tleft: enableResize && mediaPosition === 'right',\n\t\t};\n\n\t\tconst positionStyles =\n\t\t\tmediaType === 'image' && imageFill\n\t\t\t\t? imageFillStyles( mediaUrl || featuredImageURL, focalPoint )\n\t\t\t\t: {};\n\n\t\tconst mediaTypeRenderers = {\n\t\t\timage: () =>\n\t\t\t\tuseFeaturedImage && featuredImageURL ? (\n\t\t\t\t\t<img\n\t\t\t\t\t\tref={ refMedia }\n\t\t\t\t\t\tsrc={ featuredImageURL }\n\t\t\t\t\t\talt={ featuredImageAlt }\n\t\t\t\t\t\tstyle={ positionStyles }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\tmediaUrl && (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tref={ refMedia }\n\t\t\t\t\t\t\tsrc={ mediaUrl }\n\t\t\t\t\t\t\talt={ mediaAlt }\n\t\t\t\t\t\t\tstyle={ positionStyles }\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\tvideo: () => <video controls ref={ refMedia } src={ mediaUrl } />,\n\t\t};\n\n\t\treturn (\n\t\t\t<ResizableBoxContainer\n\t\t\t\tas=\"figure\"\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\tclassName,\n\t\t\t\t\t'editor-media-container__resizer',\n\t\t\t\t\t{ 'is-transient': isTemporaryMedia }\n\t\t\t\t) }\n\t\t\t\tsize={ { width: mediaWidth + '%' } }\n\t\t\t\tminWidth=\"10%\"\n\t\t\t\tmaxWidth=\"100%\"\n\t\t\t\tenable={ enablePositions }\n\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\tonResize={ onResize }\n\t\t\t\tonResizeStop={ onResizeStop }\n\t\t\t\taxis=\"x\"\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tisStackedOnMobile={ isStackedOnMobile }\n\t\t\t\tref={ ref }\n\t\t\t>\n\t\t\t\t<ToolbarEditButton\n\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\tmediaUrl={\n\t\t\t\t\t\tuseFeaturedImage && featuredImageURL\n\t\t\t\t\t\t\t? featuredImageURL\n\t\t\t\t\t\t\t: mediaUrl\n\t\t\t\t\t}\n\t\t\t\t\tmediaId={ mediaId }\n\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t\tuseFeaturedImage={ useFeaturedImage }\n\t\t\t\t/>\n\t\t\t\t{ ( mediaTypeRenderers[ mediaType ] || noop )() }\n\t\t\t\t{ isTemporaryMedia && <Spinner /> }\n\t\t\t\t{ ! useFeaturedImage && <PlaceholderContainer { ...props } /> }\n\t\t\t\t{ ! featuredImageURL && useFeaturedImage && (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\tclassName=\"wp-block-media-text--placeholder-image\"\n\t\t\t\t\t\tstyle={ positionStyles }\n\t\t\t\t\t\twithIllustration\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</ResizableBoxContainer>\n\t\t);\n\t}\n\n\treturn <PlaceholderContainer { ...props } />;\n}\n\nexport default forwardRef( MediaContainer );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,wBAAmD;AACnD,0BAMO;AACP,kBAAmB;AACnB,qBAAiC;AACjC,kBAA4B;AAC5B,qBAA2B;AAC3B,kBAA0B;AAC1B,qBAAsC;AACtC,mBAA8B;AAK9B,wBAAgC;AAY7B;AAPH,IAAM,sBAAsB,CAAE,SAAS,OAAQ;AAC/C,IAAM,OAAO,MAAM;AAAC;AAEpB,IAAM,4BAAwB;AAAA,EAC7B,CAAE,EAAE,YAAY,mBAAmB,GAAG,MAAM,GAAG,QAAS;AACvD,UAAM,eAAW,iC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AA,QACA;AAAA,QACA;AAAA,QAEA;AAAA;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA,UACC,oBAAoB,mBACjB,mBACA;AAAA,cAEJ;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD;AAAA,WACI,mBAAoB,SAAU,KAAK,MAAO;AAAA,UAC5C,oBAAoB,4CAAC,6BAAQ;AAAA,UAC7B,CAAE,oBAAoB,4CAAC,wBAAuB,GAAG,OAAQ;AAAA,UACzD,CAAE,oBAAoB,oBACvB;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,OAAQ;AAAA,cACR,kBAAgB;AAAA;AAAA,UACjB;AAAA;AAAA;AAAA,IAEF;AAAA,EAEF;AAEA,SAAO,4CAAC,wBAAuB,GAAG,OAAQ;AAC3C;AAEA,IAAO,8BAAQ,2BAAY,cAAe;",
|
|
6
6
|
"names": ["noticesStore", "icon", "blockEditorStore", "clsx"]
|
|
7
7
|
}
|
package/build/missing/block.json
CHANGED
package/build/missing/edit.js
CHANGED
|
@@ -74,12 +74,12 @@ function MissingEdit({ attributes, clientId }) {
|
|
|
74
74
|
if (hasContent && !hasFreeformBlock && (!originalName || originalName === "core/freeform")) {
|
|
75
75
|
if (hasHTMLBlock) {
|
|
76
76
|
messageHTML = (0, import_i18n.__)(
|
|
77
|
-
"It appears you are trying to use the deprecated Classic block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely. Alternatively, you can
|
|
77
|
+
"It appears you are trying to use the deprecated Classic block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely. Alternatively, if you have unsaved changes, you can save them and refresh to use the Classic block."
|
|
78
78
|
);
|
|
79
79
|
actions.push(convertToHtmlButton);
|
|
80
80
|
} else {
|
|
81
81
|
messageHTML = (0, import_i18n.__)(
|
|
82
|
-
"It appears you are trying to use the deprecated Classic block. You can leave this block intact, or remove it entirely. Alternatively, you can
|
|
82
|
+
"It appears you are trying to use the deprecated Classic block. You can leave this block intact, or remove it entirely. Alternatively, if you have unsaved changes, you can save them and refresh to use the Classic block."
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
85
|
} else if (hasContent && hasHTMLBlock) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/missing/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { RawHTML } from '@wordpress/element';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { safeHTML } from '@wordpress/dom';\n\nexport default function MissingEdit( { attributes, clientId } ) {\n\tconst { originalName, originalUndelimitedContent } = attributes;\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst { hasFreeformBlock, hasHTMLBlock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\thasFreeformBlock: canInsertBlockType(\n\t\t\t\t\t'core/freeform',\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t\thasHTMLBlock: canInsertBlockType(\n\t\t\t\t\t'core/html',\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\tfunction convertToHTML() {\n\t\treplaceBlock(\n\t\t\tclientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst actions = [];\n\tlet messageHTML;\n\n\tconst convertToHtmlButton = (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tkey=\"convert\"\n\t\t\tonClick={ convertToHTML }\n\t\t\tvariant=\"primary\"\n\t\t>\n\t\t\t{ __( 'Keep as HTML' ) }\n\t\t</Button>\n\t);\n\n\tif (\n\t\thasContent &&\n\t\t! hasFreeformBlock &&\n\t\t( ! originalName || originalName === 'core/freeform' )\n\t) {\n\t\tif ( hasHTMLBlock ) {\n\t\t\tmessageHTML = __(\n\t\t\t\t'It appears you are trying to use the deprecated Classic block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely. Alternatively, you can
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { RawHTML } from '@wordpress/element';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { safeHTML } from '@wordpress/dom';\n\nexport default function MissingEdit( { attributes, clientId } ) {\n\tconst { originalName, originalUndelimitedContent } = attributes;\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst { hasFreeformBlock, hasHTMLBlock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\thasFreeformBlock: canInsertBlockType(\n\t\t\t\t\t'core/freeform',\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t\thasHTMLBlock: canInsertBlockType(\n\t\t\t\t\t'core/html',\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\tfunction convertToHTML() {\n\t\treplaceBlock(\n\t\t\tclientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst actions = [];\n\tlet messageHTML;\n\n\tconst convertToHtmlButton = (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tkey=\"convert\"\n\t\t\tonClick={ convertToHTML }\n\t\t\tvariant=\"primary\"\n\t\t>\n\t\t\t{ __( 'Keep as HTML' ) }\n\t\t</Button>\n\t);\n\n\tif (\n\t\thasContent &&\n\t\t! hasFreeformBlock &&\n\t\t( ! originalName || originalName === 'core/freeform' )\n\t) {\n\t\tif ( hasHTMLBlock ) {\n\t\t\tmessageHTML = __(\n\t\t\t\t'It appears you are trying to use the deprecated Classic block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely. Alternatively, if you have unsaved changes, you can save them and refresh to use the Classic block.'\n\t\t\t);\n\t\t\tactions.push( convertToHtmlButton );\n\t\t} else {\n\t\t\tmessageHTML = __(\n\t\t\t\t'It appears you are trying to use the deprecated Classic block. You can leave this block intact, or remove it entirely. Alternatively, if you have unsaved changes, you can save them and refresh to use the Classic block.'\n\t\t\t);\n\t\t}\n\t} else if ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn\u2019t include support for the \"%s\" block. You can leave it as-is, convert it to custom HTML, or remove it.'\n\t\t\t),\n\t\t\toriginalName\n\t\t);\n\t\tactions.push( convertToHtmlButton );\n\t} else {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn\u2019t include support for the \"%s\" block. You can leave it as-is or remove it.'\n\t\t\t),\n\t\t\toriginalName\n\t\t);\n\t}\n\n\treturn (\n\t\t<div { ...useBlockProps( { className: 'has-warning' } ) }>\n\t\t\t<Warning actions={ actions }>{ messageHTML }</Warning>\n\t\t\t<RawHTML>{ safeHTML( originalUndelimitedContent ) }</RawHTML>\n\t\t</div>\n\t);\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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AoB;AAAA,EACnC,OAAO;AACN,sBAAc;AAAA;AAAA,UAEb;AAAA,QACC;AAAA,MACD;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,SACC,6CAAC,SAAM,OAAG,mCAAe,EAAE,WAAW,cAAc,CAAE,GACrD;AAAA,gDAAC,+BAAQ,SAAsB,uBAAa;AAAA,IAC5C,4CAAC,0BAAU,mCAAU,0BAA2B,GAAG;AAAA,KACpD;AAEF;",
|
|
6
6
|
"names": ["blockEditorStore"]
|
|
7
7
|
}
|
package/build/more/index.js
CHANGED
|
@@ -37,11 +37,15 @@ __export(more_exports, {
|
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(more_exports);
|
|
39
39
|
var import_icons = require("@wordpress/icons");
|
|
40
|
+
var import_i18n = require("@wordpress/i18n");
|
|
41
|
+
var import_blocks = require("@wordpress/blocks");
|
|
40
42
|
var import_init_block = __toESM(require("../utils/init-block"));
|
|
41
43
|
var import_edit = __toESM(require("./edit"));
|
|
42
44
|
var import_block = __toESM(require("./block.json"));
|
|
43
45
|
var import_save = __toESM(require("./save"));
|
|
44
46
|
var import_transforms = __toESM(require("./transforms"));
|
|
47
|
+
var import_lock_unlock = require("../lock-unlock");
|
|
48
|
+
var { fieldsKey, formKey } = (0, import_lock_unlock.unlock)(import_blocks.privateApis);
|
|
45
49
|
var { name } = import_block.default;
|
|
46
50
|
var settings = {
|
|
47
51
|
icon: import_icons.more,
|
|
@@ -59,6 +63,18 @@ var settings = {
|
|
|
59
63
|
edit: import_edit.default,
|
|
60
64
|
save: import_save.default
|
|
61
65
|
};
|
|
66
|
+
if (window.__experimentalContentOnlyPatternInsertion) {
|
|
67
|
+
settings[fieldsKey] = [
|
|
68
|
+
{
|
|
69
|
+
id: "customText",
|
|
70
|
+
label: (0, import_i18n.__)("Content"),
|
|
71
|
+
type: "richtext"
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
settings[formKey] = {
|
|
75
|
+
fields: ["customText"]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
62
78
|
var init = () => (0, import_init_block.default)({ name, metadata: import_block.default, settings });
|
|
63
79
|
// Annotate the CommonJS export names for ESM import in node:
|
|
64
80
|
0 && (module.exports = {
|
package/build/more/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/more/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { more as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\tif ( context === 'list-view' && customName ) {\n\t\t\treturn customName;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn attributes.customText;\n\t\t}\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAGA,mBAA6B;
|
|
6
|
-
"names": ["metadata", "icon", "transforms", "edit", "save", "initBlock", "metadata"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { more as icon } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\tif ( context === 'list-view' && customName ) {\n\t\t\treturn customName;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn attributes.customText;\n\t\t}\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'customText',\n\t\t\tlabel: __( 'Content' ),\n\t\t\ttype: 'richtext',\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'customText' ],\n\t};\n}\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAGA,mBAA6B;AAC7B,kBAAmB;AACnB,oBAAiD;AAKjD,wBAAsB;AACtB,kBAAiB;AACjB,mBAAqB;AACrB,kBAAiB;AACjB,wBAAuB;AACvB,yBAAuB;AAEvB,IAAM,EAAE,WAAW,QAAQ,QAAI,2BAAQ,cAAAC,WAAkB;AAEzD,IAAM,EAAE,KAAK,IAAI,aAAAD;AAIV,IAAM,WAAW;AAAA,EACvB,mBAAAE;AAAA,EACA,SAAS,CAAC;AAAA,EACV,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,aAAa,YAAY,UAAU;AAEzC,QAAK,YAAY,eAAe,YAAa;AAC5C,aAAO;AAAA,IACR;AAEA,QAAK,YAAY,iBAAkB;AAClC,aAAO,WAAW;AAAA,IACnB;AAAA,EACD;AAAA,EACA,8BAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,kBAAAC;AACD;AAEA,IAAK,OAAO,2CAA4C;AACvD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,WAAO,gBAAI,SAAU;AAAA,MACrB,MAAM;AAAA,IACP;AAAA,EACD;AACA,WAAU,OAAQ,IAAI;AAAA,IACrB,QAAQ,CAAE,YAAa;AAAA,EACxB;AACD;AAEO,IAAM,OAAO,UAAM,kBAAAC,SAAW,EAAE,MAAM,uBAAAC,SAAU,SAAS,CAAE;",
|
|
6
|
+
"names": ["metadata", "blocksPrivateApis", "icon", "transforms", "edit", "save", "initBlock", "metadata"]
|
|
7
7
|
}
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"supports": {
|
|
106
106
|
"align": [ "wide", "full" ],
|
|
107
107
|
"ariaLabel": true,
|
|
108
|
+
"contentRole": true,
|
|
108
109
|
"html": false,
|
|
109
110
|
"inserter": true,
|
|
110
111
|
"typography": {
|
|
@@ -138,8 +139,7 @@
|
|
|
138
139
|
}
|
|
139
140
|
},
|
|
140
141
|
"interactivity": true,
|
|
141
|
-
"renaming": false
|
|
142
|
-
"contentRole": true
|
|
142
|
+
"renaming": false
|
|
143
143
|
},
|
|
144
144
|
"editorStyle": "wp-block-navigation-editor",
|
|
145
145
|
"style": "wp-block-navigation"
|
|
@@ -157,15 +157,16 @@ function NavigationLinkEdit({
|
|
|
157
157
|
const itemLabelPlaceholder = (0, import_i18n.__)("Add label\u2026");
|
|
158
158
|
const ref = (0, import_element.useRef)();
|
|
159
159
|
const linkUIref = (0, import_element.useRef)();
|
|
160
|
-
const
|
|
161
|
-
const
|
|
160
|
+
const isNewLink = (0, import_element.useRef)(label === void 0);
|
|
161
|
+
const shouldSelectSubmenuAppenderOnClose = (0, import_element.useRef)(false);
|
|
162
162
|
const {
|
|
163
163
|
isAtMaxNesting,
|
|
164
164
|
isTopLevelLink,
|
|
165
165
|
isParentOfSelectedBlock,
|
|
166
166
|
hasChildren,
|
|
167
167
|
validateLinkStatus,
|
|
168
|
-
parentBlockClientId
|
|
168
|
+
parentBlockClientId,
|
|
169
|
+
isSubmenu
|
|
169
170
|
} = (0, import_data.useSelect)(
|
|
170
171
|
(select) => {
|
|
171
172
|
const {
|
|
@@ -195,7 +196,8 @@ function NavigationLinkEdit({
|
|
|
195
196
|
),
|
|
196
197
|
hasChildren: !!getBlockCount(clientId),
|
|
197
198
|
validateLinkStatus: enableLinkStatusValidation,
|
|
198
|
-
parentBlockClientId: parentBlockId
|
|
199
|
+
parentBlockClientId: parentBlockId,
|
|
200
|
+
isSubmenu: parentBlockName === "core/navigation-submenu"
|
|
199
201
|
};
|
|
200
202
|
},
|
|
201
203
|
[clientId, maxNestingLevel]
|
|
@@ -230,7 +232,7 @@ function NavigationLinkEdit({
|
|
|
230
232
|
replaceBlock(clientId, newSubmenu);
|
|
231
233
|
}, [getBlocks, clientId, selectBlock, replaceBlock, attributes]);
|
|
232
234
|
(0, import_element.useEffect)(() => {
|
|
233
|
-
if (isNewLink.current && isSelected
|
|
235
|
+
if (isNewLink.current && isSelected) {
|
|
234
236
|
selectBlock(parentBlockClientId);
|
|
235
237
|
}
|
|
236
238
|
}, []);
|
|
@@ -245,10 +247,22 @@ function NavigationLinkEdit({
|
|
|
245
247
|
transformToSubmenu
|
|
246
248
|
]);
|
|
247
249
|
(0, import_element.useEffect)(() => {
|
|
248
|
-
if (!
|
|
250
|
+
if (!isNewLink.current || !url || !isLinkOpen) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
isNewLink.current = false;
|
|
254
|
+
if ((0, import_url.isURL)((0, import_url.prependHTTP)(label)) && /^.+\.[a-z]+/.test(label)) {
|
|
249
255
|
selectLabelText();
|
|
256
|
+
} else {
|
|
257
|
+
selectBlock(clientId, null);
|
|
258
|
+
if (isSubmenu) {
|
|
259
|
+
const parentBlocks = getBlocks(parentBlockClientId);
|
|
260
|
+
if (parentBlocks.length === 1 && parentBlocks[0].clientId === clientId) {
|
|
261
|
+
shouldSelectSubmenuAppenderOnClose.current = true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
250
264
|
}
|
|
251
|
-
}, [
|
|
265
|
+
}, [url, isLinkOpen, isNewLink, label]);
|
|
252
266
|
function selectLabelText() {
|
|
253
267
|
ref.current.focus();
|
|
254
268
|
const { ownerDocument } = ref.current;
|
|
@@ -283,6 +297,9 @@ function NavigationLinkEdit({
|
|
|
283
297
|
setIsLinkOpen(true);
|
|
284
298
|
}
|
|
285
299
|
}
|
|
300
|
+
const instanceId = (0, import_compose.useInstanceId)(NavigationLinkEdit);
|
|
301
|
+
const hasMissingEntity = hasUrlBinding && !isBoundEntityAvailable;
|
|
302
|
+
const missingEntityDescriptionId = hasMissingEntity ? (0, import_i18n.sprintf)("navigation-link-edit-%d-desc", instanceId) : void 0;
|
|
286
303
|
const blockProps = (0, import_block_editor.useBlockProps)({
|
|
287
304
|
ref: (0, import_compose.useMergeRefs)([setPopoverAnchor, listItemRef]),
|
|
288
305
|
className: (0, import_clsx.default)("wp-block-navigation-item", {
|
|
@@ -295,6 +312,8 @@ function NavigationLinkEdit({
|
|
|
295
312
|
"has-background": !!backgroundColor || customBackgroundColor,
|
|
296
313
|
[(0, import_block_editor.getColorClassName)("background-color", backgroundColor)]: !!backgroundColor
|
|
297
314
|
}),
|
|
315
|
+
"aria-describedby": missingEntityDescriptionId,
|
|
316
|
+
"aria-invalid": hasMissingEntity,
|
|
298
317
|
style: {
|
|
299
318
|
color: !textColor && customTextColor,
|
|
300
319
|
backgroundColor: !backgroundColor && customBackgroundColor
|
|
@@ -313,13 +332,14 @@ function NavigationLinkEdit({
|
|
|
313
332
|
renderAppender: false
|
|
314
333
|
}
|
|
315
334
|
);
|
|
316
|
-
|
|
335
|
+
const needsValidLink = !url && !(hasUrlBinding && isBoundEntityAvailable) || isInvalid || isDraft || hasUrlBinding && !isBoundEntityAvailable;
|
|
336
|
+
if (needsValidLink) {
|
|
317
337
|
blockProps.onClick = () => {
|
|
318
338
|
setIsLinkOpen(true);
|
|
319
339
|
};
|
|
320
340
|
}
|
|
321
341
|
const classes = (0, import_clsx.default)("wp-block-navigation-item__content", {
|
|
322
|
-
"wp-block-navigation-link__placeholder":
|
|
342
|
+
"wp-block-navigation-link__placeholder": needsValidLink
|
|
323
343
|
});
|
|
324
344
|
const missingText = getMissingText(type);
|
|
325
345
|
const placeholderText = `(${isInvalid ? (0, import_i18n.__)("Invalid") : (0, import_i18n.__)("Draft")})`;
|
|
@@ -356,6 +376,7 @@ function NavigationLinkEdit({
|
|
|
356
376
|
}
|
|
357
377
|
) }),
|
|
358
378
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...blockProps, children: [
|
|
379
|
+
hasMissingEntity && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.VisuallyHidden, { id: missingEntityDescriptionId, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared.MissingEntityHelpText, { type, kind }) }),
|
|
359
380
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", { className: classes, children: [
|
|
360
381
|
!url && !metadata?.bindings?.url ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wp-block-navigation-link__placeholder-text", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: missingText }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
361
382
|
!isInvalid && !isDraft && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
@@ -417,8 +438,18 @@ function NavigationLinkEdit({
|
|
|
417
438
|
setIsLinkOpen(false);
|
|
418
439
|
if (!url && !hasUrlBinding) {
|
|
419
440
|
onReplace([]);
|
|
420
|
-
|
|
421
|
-
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
if (shouldSelectSubmenuAppenderOnClose.current) {
|
|
444
|
+
shouldSelectSubmenuAppenderOnClose.current = false;
|
|
445
|
+
if (listItemRef.current?.nextElementSibling) {
|
|
446
|
+
const appenderButton = listItemRef.current.nextElementSibling.querySelector(
|
|
447
|
+
".block-editor-button-block-appender"
|
|
448
|
+
);
|
|
449
|
+
if (appenderButton) {
|
|
450
|
+
appenderButton.focus();
|
|
451
|
+
}
|
|
452
|
+
}
|
|
422
453
|
}
|
|
423
454
|
},
|
|
424
455
|
anchor: popoverAnchor,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/navigation-link/edit.js"],
|
|
4
|
-
"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 { ToolbarButton, ToolbarGroup } 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 } from '@wordpress/url';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\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 { getColors } from '../navigation/edit/utils';\nimport { Controls, LinkUI, updateAttributes, useEntityBinding } from './shared';\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, isDeleted } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isPostType ) {\n\t\t\t\treturn { postStatus: null, isDeleted: false };\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 { postStatus: null, isDeleted: false };\n\t\t\t}\n\n\t\t\tconst { getEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst entityRecord = getEntityRecord( 'postType', type, id );\n\t\t\tconst hasResolved = hasFinishedResolution( 'getEntityRecord', [\n\t\t\t\t'postType',\n\t\t\t\ttype,\n\t\t\t\tid,\n\t\t\t] );\n\n\t\t\t// If resolution has finished and entityRecord is undefined, the entity was deleted.\n\t\t\tconst deleted = hasResolved && entityRecord === undefined;\n\n\t\t\treturn {\n\t\t\t\tpostStatus: entityRecord?.status,\n\t\t\t\tisDeleted: deleted,\n\t\t\t};\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 trash (trashed).\n\t// 2. The entity doesn't exist (deleted).\n\t// If either of those is true, invalidate.\n\tconst isInvalid =\n\t\tisPostType &&\n\t\thasId &&\n\t\t( isDeleted || ( 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\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, metadata } = attributes;\n\tconst { maxNestingLevel } = context;\n\n\tconst {\n\t\treplaceBlock,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tselectBlock,\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// 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\u2026' );\n\tconst ref = useRef();\n\tconst linkUIref = useRef();\n\tconst prevUrl = usePrevious( url );\n\tconst isNewLink = useRef( ! url );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t\tvalidateLinkStatus,\n\t\tparentBlockClientId,\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 parentBlockName = getBlockName( rootClientId );\n\t\t\tconst isTopLevel = parentBlockName === '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// Get the immediate parent - if it's a submenu, use it; otherwise use the navigation block\n\t\t\tconst parentBlockId =\n\t\t\t\tparentBlockName === 'core/navigation-submenu'\n\t\t\t\t\t? rootClientId\n\t\t\t\t\t: rootNavigationClientId;\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\tparentBlockClientId: parentBlockId,\n\t\t\t};\n\t\t},\n\t\t[ clientId, maxNestingLevel ]\n\t);\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\t// URL binding logic\n\tconst {\n\t\tclearBinding,\n\t\tcreateBinding,\n\t\thasUrlBinding,\n\t\tisBoundEntityAvailable,\n\t} = useEntityBinding( {\n\t\tclientId,\n\t\tattributes,\n\t} );\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 = useCallback( () => {\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}, [ getBlocks, clientId, selectBlock, replaceBlock, attributes ] );\n\n\t// On mount, if this is a new link without a URL and it's selected,\n\t// select the parent block (submenu or navigation) instead to keep the appender visible.\n\t// This helps us return focus to the appender if the user closes the link ui without creating a link.\n\t// If we leave focus on this block, then when we close the link without creating a link, focus will\n\t// be lost during the new block selection process.\n\tuseEffect( () => {\n\t\tif ( isNewLink.current && isSelected && ! url ) {\n\t\t\tselectBlock( parentBlockClientId );\n\t\t}\n\t}, [] ); // eslint-disable-line react-hooks/exhaustive-deps\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}, [\n\t\thasChildren,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\ttransformToSubmenu,\n\t] );\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}\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 (\n\t\t! url ||\n\t\tisInvalid ||\n\t\tisDraft ||\n\t\t( hasUrlBinding && ! isBoundEntityAvailable )\n\t) {\n\t\tblockProps.onClick = () => {\n\t\t\tsetIsLinkOpen( true );\n\t\t};\n\t}\n\n\tconst classes = clsx( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder':\n\t\t\t! url ||\n\t\t\tisInvalid ||\n\t\t\tisDraft ||\n\t\t\t( hasUrlBinding && ! isBoundEntityAvailable ),\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={ () => {\n\t\t\t\t\t\t\tsetIsLinkOpen( true );\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<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\tclientId={ clientId }\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 && ! metadata?.bindings?.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 && ! isDraft && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\t\tidentifier=\"label\"\n\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\tvalue={ label }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\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} )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\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'core/navigation-link'\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}\n\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\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) }\n\t\t\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ description && (\n\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{ description }\n\t\t\t\t\t\t\t\t\t\t</span>\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\t{ ( isInvalid || isDraft ) && (\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\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\t// If there is no link and no binding, 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\t// Don't remove if binding exists (even if entity is unavailable) so user can fix it.\n\t\t\t\t\t\t\t\tif ( ! url && ! hasUrlBinding ) {\n\t\t\t\t\t\t\t\t\tonReplace( [] );\n\t\t\t\t\t\t\t\t} else if ( isNewLink.current ) {\n\t\t\t\t\t\t\t\t\t// If we just created a new link, select it\n\t\t\t\t\t\t\t\t\tselectBlock( clientId );\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\tconst {\n\t\t\t\t\t\t\t\t\tisEntityLink,\n\t\t\t\t\t\t\t\t\tattributes: updatedAttributes,\n\t\t\t\t\t\t\t\t} = updateAttributes(\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\n\t\t\t\t\t\t\t\t// Handle URL binding based on the final computed state\n\t\t\t\t\t\t\t\t// Only create bindings for entity links (posts, pages, taxonomies)\n\t\t\t\t\t\t\t\t// Never create bindings for custom links (manual URLs)\n\t\t\t\t\t\t\t\tif ( isEntityLink ) {\n\t\t\t\t\t\t\t\t\tcreateBinding( updatedAttributes );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tclearBinding();\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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAA4B;AAC5B,kBAAuC;AACvC,
|
|
4
|
+
"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\tToolbarButton,\n\tToolbarGroup,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __, sprintf } 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 } from '@wordpress/url';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { link as linkIcon, addSubmenu } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMergeRefs, useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getColors } from '../navigation/edit/utils';\nimport {\n\tControls,\n\tLinkUI,\n\tupdateAttributes,\n\tuseEntityBinding,\n\tMissingEntityHelpText,\n} from './shared';\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, isDeleted } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isPostType ) {\n\t\t\t\treturn { postStatus: null, isDeleted: false };\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 { postStatus: null, isDeleted: false };\n\t\t\t}\n\n\t\t\tconst { getEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst entityRecord = getEntityRecord( 'postType', type, id );\n\t\t\tconst hasResolved = hasFinishedResolution( 'getEntityRecord', [\n\t\t\t\t'postType',\n\t\t\t\ttype,\n\t\t\t\tid,\n\t\t\t] );\n\n\t\t\t// If resolution has finished and entityRecord is undefined, the entity was deleted.\n\t\t\tconst deleted = hasResolved && entityRecord === undefined;\n\n\t\t\treturn {\n\t\t\t\tpostStatus: entityRecord?.status,\n\t\t\t\tisDeleted: deleted,\n\t\t\t};\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 trash (trashed).\n\t// 2. The entity doesn't exist (deleted).\n\t// If either of those is true, invalidate.\n\tconst isInvalid =\n\t\tisPostType &&\n\t\thasId &&\n\t\t( isDeleted || ( 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\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, metadata } = attributes;\n\tconst { maxNestingLevel } = context;\n\n\tconst {\n\t\treplaceBlock,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tselectBlock,\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// 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\u2026' );\n\tconst ref = useRef();\n\tconst linkUIref = useRef();\n\t// A link is \"new\" only if it has an undefined label\n\t// After the link is created, even if no label is provided, it's set to an empty string.\n\tconst isNewLink = useRef( label === undefined );\n\t// Track whether we should focus the submenu appender when closing the link UI\n\tconst shouldSelectSubmenuAppenderOnClose = useRef( false );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t\tvalidateLinkStatus,\n\t\tparentBlockClientId,\n\t\tisSubmenu,\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 parentBlockName = getBlockName( rootClientId );\n\t\t\tconst isTopLevel = parentBlockName === '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// Get the immediate parent - if it's a submenu, use it; otherwise use the navigation block\n\t\t\tconst parentBlockId =\n\t\t\t\tparentBlockName === 'core/navigation-submenu'\n\t\t\t\t\t? rootClientId\n\t\t\t\t\t: rootNavigationClientId;\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\tparentBlockClientId: parentBlockId,\n\t\t\t\tisSubmenu: parentBlockName === 'core/navigation-submenu',\n\t\t\t};\n\t\t},\n\t\t[ clientId, maxNestingLevel ]\n\t);\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\t// URL binding logic\n\tconst {\n\t\tclearBinding,\n\t\tcreateBinding,\n\t\thasUrlBinding,\n\t\tisBoundEntityAvailable,\n\t} = useEntityBinding( {\n\t\tclientId,\n\t\tattributes,\n\t} );\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 = useCallback( () => {\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}, [ getBlocks, clientId, selectBlock, replaceBlock, attributes ] );\n\n\t// On mount, if this is a new link without a URL and it's selected,\n\t// select the parent block (submenu or navigation) instead to keep the appender visible.\n\t// This helps us return focus to the appender if the user closes the link ui without creating a link.\n\t// If we leave focus on this block, then when we close the link without creating a link, focus will\n\t// be lost during the new block selection process.\n\tuseEffect( () => {\n\t\tif ( isNewLink.current && isSelected ) {\n\t\t\tselectBlock( parentBlockClientId );\n\t\t}\n\t}, [] ); // eslint-disable-line react-hooks/exhaustive-deps\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}, [\n\t\thasChildren,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\ttransformToSubmenu,\n\t] );\n\n\t// Handle link UI when a new link is created\n\tuseEffect( () => {\n\t\t// We know if a link was just created from our link UI if\n\t\t// 1. isNewLink.current is true\n\t\t// 2. url has a value\n\t\t// 3. isLinkOpen is true\n\t\tif ( ! isNewLink.current || ! url || ! isLinkOpen ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Ensure this only runs once\n\t\tisNewLink.current = false;\n\n\t\t// We just created a link and the block is now selected.\n\t\t// If the label looks like a URL, focus and select the label text.\n\t\tif ( isURL( prependHTTP( label ) ) && /^.+\\.[a-z]+/.test( label ) ) {\n\t\t\t// Focus and select the label text.\n\t\t\tselectLabelText();\n\t\t} else {\n\t\t\t// If the link was just created, we want to select the block so the inspector controls\n\t\t\t// are accurate.\n\t\t\tselectBlock( clientId, null );\n\n\t\t\t// Edge case: When the created link is the first child of a submenu, the focus will have\n\t\t\t// originated from the add submenu toolbar button. In this case, we need to return focus\n\t\t\t// to the submenu appender if the user closes the link ui using the keyboard.\n\t\t\t// Check if this is the first and only child of a newly created submenu.\n\t\t\tif ( isSubmenu ) {\n\t\t\t\tconst parentBlocks = getBlocks( parentBlockClientId );\n\t\t\t\t// If this is the only child, then this is a new submenu.\n\t\t\t\t// Set the flag to select the submenu appender when the link ui is closed.\n\t\t\t\tif (\n\t\t\t\t\tparentBlocks.length === 1 &&\n\t\t\t\t\tparentBlocks[ 0 ].clientId === clientId\n\t\t\t\t) {\n\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ url, isLinkOpen, isNewLink, 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}\n\t}\n\n\tconst instanceId = useInstanceId( NavigationLinkEdit );\n\tconst hasMissingEntity = hasUrlBinding && ! isBoundEntityAvailable;\n\tconst missingEntityDescriptionId = hasMissingEntity\n\t\t? sprintf( 'navigation-link-edit-%d-desc', instanceId )\n\t\t: undefined;\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\t'aria-describedby': missingEntityDescriptionId,\n\t\t'aria-invalid': hasMissingEntity,\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\tconst needsValidLink =\n\t\t( ! url && ! ( hasUrlBinding && isBoundEntityAvailable ) ) ||\n\t\tisInvalid ||\n\t\tisDraft ||\n\t\t( hasUrlBinding && ! isBoundEntityAvailable );\n\n\tif ( needsValidLink ) {\n\t\tblockProps.onClick = () => {\n\t\t\tsetIsLinkOpen( true );\n\t\t};\n\t}\n\n\tconst classes = clsx( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder': needsValidLink,\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={ () => {\n\t\t\t\t\t\t\tsetIsLinkOpen( true );\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<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\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ hasMissingEntity && (\n\t\t\t\t\t<VisuallyHidden id={ missingEntityDescriptionId }>\n\t\t\t\t\t\t<MissingEntityHelpText type={ type } kind={ kind } />\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\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 && ! metadata?.bindings?.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 && ! isDraft && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\t\tidentifier=\"label\"\n\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\tvalue={ label }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\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} )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\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'core/navigation-link'\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}\n\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\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) }\n\t\t\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ description && (\n\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{ description }\n\t\t\t\t\t\t\t\t\t\t</span>\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\t{ ( isInvalid || isDraft ) && (\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\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\t// If there is no link and no binding, 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\t// Don't remove if binding exists (even if entity is unavailable) so user can fix it.\n\t\t\t\t\t\t\t\tif ( ! url && ! hasUrlBinding ) {\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\t// Edge case: If this is the first child of a new submenu, focus the submenu's appender\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current = false;\n\n\t\t\t\t\t\t\t\t\t// The appender is the next sibling in the DOM after the current block\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tlistItemRef.current?.nextElementSibling\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tconst appenderButton =\n\t\t\t\t\t\t\t\t\t\t\tlistItemRef.current.nextElementSibling.querySelector(\n\t\t\t\t\t\t\t\t\t\t\t\t'.block-editor-button-block-appender'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tif ( appenderButton ) {\n\t\t\t\t\t\t\t\t\t\t\tappenderButton.focus();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\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\tconst {\n\t\t\t\t\t\t\t\t\tisEntityLink,\n\t\t\t\t\t\t\t\t\tattributes: updatedAttributes,\n\t\t\t\t\t\t\t\t} = updateAttributes(\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\n\t\t\t\t\t\t\t\t// Handle URL binding based on the final computed state\n\t\t\t\t\t\t\t\t// Only create bindings for entity links (posts, pages, taxonomies)\n\t\t\t\t\t\t\t\t// Never create bindings for custom links (manual URLs)\n\t\t\t\t\t\t\t\tif ( isEntityLink ) {\n\t\t\t\t\t\t\t\t\tcreateBinding( updatedAttributes );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tclearBinding();\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAA4B;AAC5B,kBAAuC;AACvC,wBAIO;AACP,sBAAiD;AACjD,kBAA4B;AAC5B,0BASO;AACP,iBAAmC;AACnC,qBAAyD;AACzD,2BAA+B;AAC/B,mBAA6C;AAC7C,uBAAmC;AACnC,qBAA4C;AAK5C,mBAA0B;AAC1B,oBAMO;AA0cH;AAxcJ,IAAM,gBAAgB,EAAE,MAAM,uBAAuB;AACrD,IAAM,sBAAsB;AAAA,EAC3B;AAAA,EACA;AACD;AAWA,IAAM,sBAAsB,CAAE,eAAgB;AAC7C,QAAM,CAAE,kBAAkB,mBAAoB,QAAI,yBAAU,KAAM;AAElE,gCAAW,MAAM;AAChB,UAAM,EAAE,cAAc,IAAI,WAAW;AAErC,aAAS,gBAAiB,OAAQ;AAEjC,sBAAiB,KAAM;AAAA,IACxB;AAGA,aAAS,gBAAgB;AACxB,0BAAqB,KAAM;AAAA,IAC5B;AAEA,aAAS,gBAAiB,OAAQ;AAEjC,UAAK,WAAW,QAAQ,SAAU,MAAM,MAAO,GAAI;AAClD,4BAAqB,IAAK;AAAA,MAC3B,OAAO;AACN,4BAAqB,KAAM;AAAA,MAC5B;AAAA,IACD;AAK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,OAC9B;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": ["coreStore", "blockEditorStore", "clsx", "linkIcon"]
|
|
7
7
|
}
|
|
@@ -40,13 +40,16 @@ var import_i18n = require("@wordpress/i18n");
|
|
|
40
40
|
var import_icons = require("@wordpress/icons");
|
|
41
41
|
var import_block_editor = require("@wordpress/block-editor");
|
|
42
42
|
var import_hooks = require("@wordpress/hooks");
|
|
43
|
+
var import_blocks = require("@wordpress/blocks");
|
|
43
44
|
var import_init_block = __toESM(require("../utils/init-block"));
|
|
44
45
|
var import_block = __toESM(require("./block.json"));
|
|
45
46
|
var import_edit = __toESM(require("./edit"));
|
|
46
47
|
var import_save = __toESM(require("./save"));
|
|
47
48
|
var import_hooks2 = require("./hooks");
|
|
48
49
|
var import_transforms = __toESM(require("./transforms"));
|
|
50
|
+
var import_lock_unlock = require("../lock-unlock");
|
|
49
51
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
+
var { fieldsKey, formKey } = (0, import_lock_unlock.unlock)(import_blocks.privateApis);
|
|
50
53
|
var { name } = import_block.default;
|
|
51
54
|
var settings = {
|
|
52
55
|
icon: import_icons.customLink,
|
|
@@ -107,6 +110,28 @@ var settings = {
|
|
|
107
110
|
],
|
|
108
111
|
transforms: import_transforms.default
|
|
109
112
|
};
|
|
113
|
+
if (window.__experimentalContentOnlyPatternInsertion) {
|
|
114
|
+
settings[fieldsKey] = [
|
|
115
|
+
{
|
|
116
|
+
id: "label",
|
|
117
|
+
label: (0, import_i18n.__)("Label"),
|
|
118
|
+
type: "richtext"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: "link",
|
|
122
|
+
label: (0, import_i18n.__)("Link"),
|
|
123
|
+
type: "link",
|
|
124
|
+
mapping: {
|
|
125
|
+
href: "url",
|
|
126
|
+
rel: "rel"
|
|
127
|
+
// TODO - opens in new tab? id?
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
settings[formKey] = {
|
|
132
|
+
fields: ["label"]
|
|
133
|
+
};
|
|
134
|
+
}
|
|
110
135
|
var init = () => {
|
|
111
136
|
(0, import_hooks.addFilter)(
|
|
112
137
|
"blocks.registerBlockType",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/navigation-link/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { customLink as linkIcon } from '@wordpress/icons';\nimport { InnerBlocks } from '@wordpress/block-editor';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport { enhanceNavigationLinkVariations } from './hooks';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon: linkIcon,\n\n\t__experimentalLabel: ( { label } ) => label,\n\n\tmerge( leftAttributes, { label: rightLabel = '' } ) {\n\t\treturn {\n\t\t\t...leftAttributes,\n\t\t\tlabel: leftAttributes.label + rightLabel,\n\t\t};\n\t},\n\n\tedit,\n\n\tsave,\n\n\texample: {\n\t\tattributes: {\n\t\t\tlabel: _x( 'Example Link', 'navigation link preview example' ),\n\t\t\turl: 'https://example.com',\n\t\t},\n\t},\n\n\tdeprecated: [\n\t\t{\n\t\t\tisEligible( attributes ) {\n\t\t\t\treturn attributes.nofollow;\n\t\t\t},\n\n\t\t\tattributes: {\n\t\t\t\tlabel: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t},\n\t\t\t\ttype: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t},\n\t\t\t\tnofollow: {\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t},\n\t\t\t\tdescription: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t},\n\t\t\t\tid: {\n\t\t\t\t\ttype: 'number',\n\t\t\t\t},\n\t\t\t\topensInNewTab: {\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t},\n\t\t\t\turl: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t},\n\t\t\t},\n\n\t\t\tmigrate( { nofollow, ...rest } ) {\n\t\t\t\treturn {\n\t\t\t\t\trel: nofollow ? 'nofollow' : '',\n\t\t\t\t\t...rest,\n\t\t\t\t};\n\t\t\t},\n\n\t\t\tsave() {\n\t\t\t\treturn <InnerBlocks.Content />;\n\t\t\t},\n\t\t},\n\t],\n\ttransforms,\n};\n\nexport const init = () => {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/navigation-link',\n\t\tenhanceNavigationLinkVariations\n\t);\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAGA,
|
|
6
|
-
"names": ["metadata", "import_hooks", "linkIcon", "edit", "save", "transforms", "initBlock", "metadata"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x, __ } from '@wordpress/i18n';\nimport { customLink as linkIcon } from '@wordpress/icons';\nimport { InnerBlocks } from '@wordpress/block-editor';\nimport { addFilter } from '@wordpress/hooks';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport { enhanceNavigationLinkVariations } from './hooks';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon: linkIcon,\n\n\t__experimentalLabel: ( { label } ) => label,\n\n\tmerge( leftAttributes, { label: rightLabel = '' } ) {\n\t\treturn {\n\t\t\t...leftAttributes,\n\t\t\tlabel: leftAttributes.label + rightLabel,\n\t\t};\n\t},\n\n\tedit,\n\n\tsave,\n\n\texample: {\n\t\tattributes: {\n\t\t\tlabel: _x( 'Example Link', 'navigation link preview example' ),\n\t\t\turl: 'https://example.com',\n\t\t},\n\t},\n\n\tdeprecated: [\n\t\t{\n\t\t\tisEligible( attributes ) {\n\t\t\t\treturn attributes.nofollow;\n\t\t\t},\n\n\t\t\tattributes: {\n\t\t\t\tlabel: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t},\n\t\t\t\ttype: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t},\n\t\t\t\tnofollow: {\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t},\n\t\t\t\tdescription: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t},\n\t\t\t\tid: {\n\t\t\t\t\ttype: 'number',\n\t\t\t\t},\n\t\t\t\topensInNewTab: {\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t},\n\t\t\t\turl: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t},\n\t\t\t},\n\n\t\t\tmigrate( { nofollow, ...rest } ) {\n\t\t\t\treturn {\n\t\t\t\t\trel: nofollow ? 'nofollow' : '',\n\t\t\t\t\t...rest,\n\t\t\t\t};\n\t\t\t},\n\n\t\t\tsave() {\n\t\t\t\treturn <InnerBlocks.Content />;\n\t\t\t},\n\t\t},\n\t],\n\ttransforms,\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'label',\n\t\t\tlabel: __( 'Label' ),\n\t\t\ttype: 'richtext',\n\t\t},\n\t\t{\n\t\t\tid: 'link',\n\t\t\tlabel: __( 'Link' ),\n\t\t\ttype: 'link',\n\t\t\tmapping: {\n\t\t\t\thref: 'url',\n\t\t\t\trel: 'rel',\n\t\t\t\t// TODO - opens in new tab? id?\n\t\t\t},\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'label' ],\n\t};\n}\n\nexport const init = () => {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/navigation-link',\n\t\tenhanceNavigationLinkVariations\n\t);\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAGA,kBAAuB;AACvB,mBAAuC;AACvC,0BAA4B;AAC5B,mBAA0B;AAC1B,oBAAiD;AAKjD,wBAAsB;AACtB,mBAAqB;AACrB,kBAAiB;AACjB,kBAAiB;AACjB,IAAAC,gBAAgD;AAChD,wBAAuB;AACvB,yBAAuB;AAsEZ;AApEX,IAAM,EAAE,WAAW,QAAQ,QAAI,2BAAQ,cAAAC,WAAkB;AAEzD,IAAM,EAAE,KAAK,IAAI,aAAAF;AAIV,IAAM,WAAW;AAAA,EACvB,MAAM,aAAAG;AAAA,EAEN,qBAAqB,CAAE,EAAE,MAAM,MAAO;AAAA,EAEtC,MAAO,gBAAgB,EAAE,OAAO,aAAa,GAAG,GAAI;AACnD,WAAO;AAAA,MACN,GAAG;AAAA,MACH,OAAO,eAAe,QAAQ;AAAA,IAC/B;AAAA,EACD;AAAA,EAEA,kBAAAC;AAAA,EAEA,kBAAAC;AAAA,EAEA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,WAAO,gBAAI,gBAAgB,iCAAkC;AAAA,MAC7D,KAAK;AAAA,IACN;AAAA,EACD;AAAA,EAEA,YAAY;AAAA,IACX;AAAA,MACC,WAAY,YAAa;AACxB,eAAO,WAAW;AAAA,MACnB;AAAA,MAEA,YAAY;AAAA,QACX,OAAO;AAAA,UACN,MAAM;AAAA,QACP;AAAA,QACA,MAAM;AAAA,UACL,MAAM;AAAA,QACP;AAAA,QACA,UAAU;AAAA,UACT,MAAM;AAAA,QACP;AAAA,QACA,aAAa;AAAA,UACZ,MAAM;AAAA,QACP;AAAA,QACA,IAAI;AAAA,UACH,MAAM;AAAA,QACP;AAAA,QACA,eAAe;AAAA,UACd,MAAM;AAAA,UACN,SAAS;AAAA,QACV;AAAA,QACA,KAAK;AAAA,UACJ,MAAM;AAAA,QACP;AAAA,MACD;AAAA,MAEA,QAAS,EAAE,UAAU,GAAG,KAAK,GAAI;AAChC,eAAO;AAAA,UACN,KAAK,WAAW,aAAa;AAAA,UAC7B,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,MAEA,OAAO;AACN,eAAO,4CAAC,gCAAY,SAAZ,EAAoB;AAAA,MAC7B;AAAA,IACD;AAAA,EACD;AAAA,EACA,8BAAAC;AACD;AAEA,IAAK,OAAO,2CAA4C;AACvD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,WAAO,gBAAI,OAAQ;AAAA,MACnB,MAAM;AAAA,IACP;AAAA,IACA;AAAA,MACC,IAAI;AAAA,MACJ,WAAO,gBAAI,MAAO;AAAA,MAClB,MAAM;AAAA,MACN,SAAS;AAAA,QACR,MAAM;AAAA,QACN,KAAK;AAAA;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AACA,WAAU,OAAQ,IAAI;AAAA,IACrB,QAAQ,CAAE,OAAQ;AAAA,EACnB;AACD;AAEO,IAAM,OAAO,MAAM;AACzB;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,aAAO,kBAAAC,SAAW,EAAE,MAAM,uBAAAC,SAAU,SAAS,CAAE;AAChD;",
|
|
6
|
+
"names": ["metadata", "import_hooks", "blocksPrivateApis", "linkIcon", "edit", "save", "transforms", "initBlock", "metadata"]
|
|
7
7
|
}
|
|
@@ -20,7 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// packages/block-library/src/navigation-link/shared/controls.js
|
|
21
21
|
var controls_exports = {};
|
|
22
22
|
__export(controls_exports, {
|
|
23
|
-
|
|
23
|
+
BindingHelpText: () => BindingHelpText,
|
|
24
|
+
Controls: () => Controls,
|
|
25
|
+
MissingEntityHelpText: () => MissingEntityHelpText
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(controls_exports);
|
|
26
28
|
var import_components = require("@wordpress/components");
|
|
@@ -179,7 +181,7 @@ function Controls({ attributes, setAttributes, clientId }) {
|
|
|
179
181
|
});
|
|
180
182
|
},
|
|
181
183
|
help: hasUrlBinding && !isBoundEntityAvailable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
182
|
-
|
|
184
|
+
MissingEntityHelp,
|
|
183
185
|
{
|
|
184
186
|
id: helpTextId,
|
|
185
187
|
type: attributes.type,
|
|
@@ -289,27 +291,21 @@ function BindingHelpText({ type, kind }) {
|
|
|
289
291
|
entityType
|
|
290
292
|
);
|
|
291
293
|
}
|
|
292
|
-
function MissingEntityHelpText({
|
|
294
|
+
function MissingEntityHelpText({ type, kind }) {
|
|
293
295
|
const entityType = getEntityTypeName(type, kind);
|
|
294
|
-
return
|
|
295
|
-
"
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
className: "navigation-link-control__error-text",
|
|
299
|
-
role: "alert",
|
|
300
|
-
"aria-live": "polite",
|
|
301
|
-
children: (0, import_i18n.sprintf)(
|
|
302
|
-
/* translators: %s is the entity type (e.g., "page", "post", "category") */
|
|
303
|
-
(0, import_i18n.__)(
|
|
304
|
-
"Synced %s is missing. Please update or remove this link."
|
|
305
|
-
),
|
|
306
|
-
entityType
|
|
307
|
-
)
|
|
308
|
-
}
|
|
296
|
+
return (0, import_i18n.sprintf)(
|
|
297
|
+
/* translators: %s is the entity type (e.g., "page", "post", "category") */
|
|
298
|
+
(0, import_i18n.__)("Synced %s is missing. Please update or remove this link."),
|
|
299
|
+
entityType
|
|
309
300
|
);
|
|
310
301
|
}
|
|
302
|
+
function MissingEntityHelp({ id, type, kind }) {
|
|
303
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { id, className: "navigation-link-control__error-text", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MissingEntityHelpText, { type, kind }) });
|
|
304
|
+
}
|
|
311
305
|
// Annotate the CommonJS export names for ESM import in node:
|
|
312
306
|
0 && (module.exports = {
|
|
313
|
-
|
|
307
|
+
BindingHelpText,
|
|
308
|
+
Controls,
|
|
309
|
+
MissingEntityHelpText
|
|
314
310
|
});
|
|
315
311
|
//# sourceMappingURL=controls.js.map
|