@wordpress/block-library 9.35.1-next.dc3f6d3c1.0 → 9.36.1-next.8b30e05b0.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 +12 -9
- package/build/audio/index.js.map +3 -3
- package/build/button/index.js +13 -10
- package/build/button/index.js.map +3 -3
- package/build/code/index.js +9 -6
- 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 +10 -4
- 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 +9 -6
- package/build/details/index.js.map +3 -3
- package/build/file/index.js +14 -14
- 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 +9 -6
- package/build/heading/index.js.map +3 -3
- package/build/html/modal.js +127 -118
- 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 +18 -18
- package/build/image/index.js.map +3 -3
- package/build/list-item/index.js +8 -6
- 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 +15 -8
- 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 +9 -6
- package/build/more/index.js.map +3 -3
- package/build/navigation-link/edit.js +36 -11
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/index.js +11 -8
- package/build/navigation-link/index.js.map +3 -3
- package/build/navigation-submenu/index.js +11 -8
- 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 +9 -6
- package/build/paragraph/index.js.map +3 -3
- package/build/pattern/block.json +1 -1
- package/build/preformatted/index.js +9 -6
- package/build/preformatted/index.js.map +3 -3
- package/build/pullquote/index.js +11 -11
- package/build/pullquote/index.js.map +3 -3
- package/build/search/index.js +14 -16
- package/build/search/index.js.map +3 -3
- package/build/social-link/index.js +11 -8
- package/build/social-link/index.js.map +3 -3
- 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 +9 -6
- package/build/verse/index.js.map +3 -3
- package/build/video/index.js +12 -9
- 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 +12 -9
- package/build-module/audio/index.js.map +2 -2
- package/build-module/button/index.js +13 -10
- package/build-module/button/index.js.map +2 -2
- package/build-module/code/index.js +9 -6
- 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 +10 -4
- 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 +9 -6
- package/build-module/details/index.js.map +2 -2
- package/build-module/file/index.js +14 -14
- 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 +9 -6
- package/build-module/heading/index.js.map +2 -2
- package/build-module/html/modal.js +128 -119
- 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 +18 -18
- package/build-module/image/index.js.map +2 -2
- package/build-module/list-item/index.js +8 -6
- 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 +15 -8
- 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 +9 -6
- package/build-module/more/index.js.map +2 -2
- package/build-module/navigation-link/edit.js +37 -12
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/index.js +11 -8
- package/build-module/navigation-link/index.js.map +2 -2
- package/build-module/navigation-submenu/index.js +11 -8
- 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 +9 -6
- package/build-module/paragraph/index.js.map +2 -2
- package/build-module/pattern/block.json +1 -1
- package/build-module/preformatted/index.js +9 -6
- package/build-module/preformatted/index.js.map +2 -2
- package/build-module/pullquote/index.js +11 -11
- package/build-module/pullquote/index.js.map +2 -2
- package/build-module/search/index.js +14 -16
- package/build-module/search/index.js.map +2 -2
- package/build-module/social-link/index.js +11 -8
- package/build-module/social-link/index.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 +9 -6
- package/build-module/verse/index.js.map +2 -2
- package/build-module/video/index.js +12 -9
- 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 +13 -9
- package/src/breadcrumbs/index.php +71 -82
- package/src/button/index.js +14 -10
- package/src/code/index.js +10 -6
- 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 +11 -4
- 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 +10 -6
- package/src/file/index.js +15 -14
- package/src/freeform/block.json +1 -1
- package/src/gallery/edit.js +0 -2
- package/src/heading/index.js +10 -6
- package/src/html/editor.scss +10 -15
- package/src/html/modal.js +15 -10
- package/src/image/edit.js +0 -1
- package/src/image/image.js +0 -1
- package/src/image/index.js +19 -18
- package/src/image/index.php +1 -0
- package/src/list-item/index.js +9 -6
- package/src/math/block.json +28 -1
- package/src/math/edit.js +4 -1
- package/src/media-text/index.js +16 -8
- 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 +10 -6
- package/src/navigation-link/edit.js +72 -26
- package/src/navigation-link/index.js +12 -8
- package/src/navigation-submenu/index.js +12 -8
- package/src/paragraph/deprecated-attributes.js +45 -0
- package/src/paragraph/edit.js +2 -0
- package/src/paragraph/index.js +10 -6
- package/src/pattern/block.json +1 -1
- package/src/preformatted/index.js +10 -6
- package/src/pullquote/index.js +12 -11
- package/src/search/index.js +14 -15
- package/src/social-link/index.js +12 -8
- package/src/style.scss +1 -0
- 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 +10 -6
- package/src/video/index.js +13 -9
|
@@ -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 {\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, usePrevious, 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\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 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\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{ 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} 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": ";AAGA,OAAO,UAAU;AAKjB,SAAS,mBAAmB;AAC5B,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,IAAI,eAAe;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,OAAO,mBAAmB;AACnC,SAAS,UAAU,WAAW,QAAQ,mBAAmB;AACzD,SAAS,sBAAsB;AAC/B,SAAS,QAAQ,UAAU,kBAAkB;AAC7C,SAAS,SAAS,iBAAiB;AACnC,SAAS,cAAc,
|
|
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": ";AAGA,OAAO,UAAU;AAKjB,SAAS,mBAAmB;AAC5B,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,IAAI,eAAe;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,OAAO,mBAAmB;AACnC,SAAS,UAAU,WAAW,QAAQ,mBAAmB;AACzD,SAAS,sBAAsB;AAC/B,SAAS,QAAQ,UAAU,kBAAkB;AAC7C,SAAS,SAAS,iBAAiB;AACnC,SAAS,cAAc,qBAAqB;AAK5C,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AA0cH,SA2CI,UA1CH,KADD;AAxcJ,IAAM,gBAAgB,EAAE,MAAM,uBAAuB;AACrD,IAAM,sBAAsB;AAAA,EAC3B;AAAA,EACA;AACD;AAWA,IAAM,sBAAsB,CAAE,eAAgB;AAC7C,QAAM,CAAE,kBAAkB,mBAAoB,IAAI,SAAU,KAAM;AAElE,YAAW,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,aA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AEF;AAAA,MACA,oBAAC,SAAM,GAAG,kBAAmB;AAAA,OAC9B;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,13 +3,16 @@ import { _x, __ } from "@wordpress/i18n";
|
|
|
3
3
|
import { customLink as linkIcon } from "@wordpress/icons";
|
|
4
4
|
import { InnerBlocks } from "@wordpress/block-editor";
|
|
5
5
|
import { addFilter } from "@wordpress/hooks";
|
|
6
|
+
import { privateApis as blocksPrivateApis } from "@wordpress/blocks";
|
|
6
7
|
import initBlock from "../utils/init-block";
|
|
7
8
|
import metadata from "./block.json";
|
|
8
9
|
import edit from "./edit";
|
|
9
10
|
import save from "./save";
|
|
10
11
|
import { enhanceNavigationLinkVariations } from "./hooks";
|
|
11
12
|
import transforms from "./transforms";
|
|
13
|
+
import { unlock } from "../lock-unlock";
|
|
12
14
|
import { jsx } from "react/jsx-runtime";
|
|
15
|
+
var { fieldsKey, formKey } = unlock(blocksPrivateApis);
|
|
13
16
|
var { name } = metadata;
|
|
14
17
|
var settings = {
|
|
15
18
|
icon: linkIcon,
|
|
@@ -71,19 +74,16 @@ var settings = {
|
|
|
71
74
|
transforms
|
|
72
75
|
};
|
|
73
76
|
if (window.__experimentalContentOnlyPatternInsertion) {
|
|
74
|
-
settings
|
|
77
|
+
settings[fieldsKey] = [
|
|
75
78
|
{
|
|
79
|
+
id: "label",
|
|
76
80
|
label: __("Label"),
|
|
77
|
-
type: "
|
|
78
|
-
shownByDefault: true,
|
|
79
|
-
mapping: {
|
|
80
|
-
value: "label"
|
|
81
|
-
}
|
|
81
|
+
type: "richtext"
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
|
+
id: "link",
|
|
84
85
|
label: __("Link"),
|
|
85
|
-
type: "
|
|
86
|
-
shownByDefault: false,
|
|
86
|
+
type: "link",
|
|
87
87
|
mapping: {
|
|
88
88
|
href: "url",
|
|
89
89
|
rel: "rel"
|
|
@@ -91,6 +91,9 @@ if (window.__experimentalContentOnlyPatternInsertion) {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
];
|
|
94
|
+
settings[formKey] = {
|
|
95
|
+
fields: ["label"]
|
|
96
|
+
};
|
|
94
97
|
}
|
|
95
98
|
var init = () => {
|
|
96
99
|
addFilter(
|
|
@@ -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\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings
|
|
5
|
-
"mappings": ";AAGA,SAAS,IAAI,UAAU;AACvB,SAAS,cAAc,gBAAgB;AACvC,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;
|
|
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\tenhanceNavigationLink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S,EAAE,UAAU,GAAG,KAAK,GAAI;AAChC,eAAO;AAAA,UACN,KAAK,WAAW,aAAa;AAAA,UAC7B,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,MAEA,OAAO;AACN,eAAO,oBAAC,YAAY,SAAZ,EAAoB;AAAA,MAC7B;AAAA,IACD;AAAA,EACD;AAAA,EACA;AACD;AAEA,IAAK,OAAO,2CAA4C;AACvD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,OAAQ;AAAA,MACnB,MAAM;AAAA,IACP;AAAA,IACA;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,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,SAAO,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;AAChD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// packages/block-library/src/navigation-submenu/index.js
|
|
2
2
|
import { page, addSubmenu } from "@wordpress/icons";
|
|
3
3
|
import { _x, __ } from "@wordpress/i18n";
|
|
4
|
+
import { privateApis as blocksPrivateApis } from "@wordpress/blocks";
|
|
4
5
|
import initBlock from "../utils/init-block";
|
|
5
6
|
import metadata from "./block.json";
|
|
6
7
|
import edit from "./edit";
|
|
7
8
|
import save from "./save";
|
|
8
9
|
import transforms from "./transforms";
|
|
10
|
+
import { unlock } from "../lock-unlock";
|
|
11
|
+
var { fieldsKey, formKey } = unlock(blocksPrivateApis);
|
|
9
12
|
var { name } = metadata;
|
|
10
13
|
var settings = {
|
|
11
14
|
icon: ({ context }) => {
|
|
@@ -33,19 +36,16 @@ var settings = {
|
|
|
33
36
|
transforms
|
|
34
37
|
};
|
|
35
38
|
if (window.__experimentalContentOnlyPatternInsertion) {
|
|
36
|
-
settings
|
|
39
|
+
settings[fieldsKey] = [
|
|
37
40
|
{
|
|
41
|
+
id: "label",
|
|
38
42
|
label: __("Label"),
|
|
39
|
-
type: "
|
|
40
|
-
shownByDefault: true,
|
|
41
|
-
mapping: {
|
|
42
|
-
value: "label"
|
|
43
|
-
}
|
|
43
|
+
type: "richtext"
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
|
+
id: "link",
|
|
46
47
|
label: __("Link"),
|
|
47
|
-
type: "
|
|
48
|
-
shownByDefault: false,
|
|
48
|
+
type: "link",
|
|
49
49
|
mapping: {
|
|
50
50
|
href: "url",
|
|
51
51
|
rel: "rel"
|
|
@@ -53,6 +53,9 @@ if (window.__experimentalContentOnlyPatternInsertion) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
];
|
|
56
|
+
settings[formKey] = {
|
|
57
|
+
fields: ["label"]
|
|
58
|
+
};
|
|
56
59
|
}
|
|
57
60
|
var init = () => initBlock({ name, metadata, settings });
|
|
58
61
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/navigation-submenu/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { page, addSubmenu } from '@wordpress/icons';\nimport { _x, __ } from '@wordpress/i18n';\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 transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon: ( { context } ) => {\n\t\tif ( context === 'list-view' ) {\n\t\t\treturn page;\n\t\t}\n\t\treturn addSubmenu;\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { label } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\t// In the list view, use the block's menu label as the label.\n\t\t// If the menu label is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || label ) ) {\n\t\t\treturn attributes?.metadata?.name || label;\n\t\t}\n\n\t\treturn label;\n\t},\n\tedit,\n\texample: {\n\t\tattributes: {\n\t\t\tlabel: _x( 'About', 'Example link text for Navigation Submenu' ),\n\t\t\ttype: 'page',\n\t\t},\n\t},\n\tsave,\n\ttransforms,\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings
|
|
5
|
-
"mappings": ";AAGA,SAAS,MAAM,kBAAkB;AACjC,SAAS,IAAI,UAAU;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { page, addSubmenu } from '@wordpress/icons';\nimport { _x, __ } from '@wordpress/i18n';\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 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: ( { context } ) => {\n\t\tif ( context === 'list-view' ) {\n\t\t\treturn page;\n\t\t}\n\t\treturn addSubmenu;\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { label } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\t// In the list view, use the block's menu label as the label.\n\t\t// If the menu label is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || label ) ) {\n\t\t\treturn attributes?.metadata?.name || label;\n\t\t}\n\n\t\treturn label;\n\t},\n\tedit,\n\texample: {\n\t\tattributes: {\n\t\t\tlabel: _x( 'About', 'Example link text for Navigation Submenu' ),\n\t\t\ttype: 'page',\n\t\t},\n\t},\n\tsave,\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 = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,MAAM,kBAAkB;AACjC,SAAS,IAAI,UAAU;AACvB,SAAS,eAAe,yBAAyB;AAKjD,OAAO,eAAe;AACtB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,SAAS,cAAc;AAEvB,IAAM,EAAE,WAAW,QAAQ,IAAI,OAAQ,iBAAkB;AAEzD,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB,MAAM,CAAE,EAAE,QAAQ,MAAO;AACxB,QAAK,YAAY,aAAc;AAC9B,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR;AAAA,EACA,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,EAAE,MAAM,IAAI;AAElB,UAAM,aAAa,YAAY,UAAU;AAIzC,QAAK,YAAY,gBAAiB,cAAc,QAAU;AACzD,aAAO,YAAY,UAAU,QAAQ;AAAA,IACtC;AAEA,WAAO;AAAA,EACR;AAAA,EACA;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,OAAO,GAAI,SAAS,0CAA2C;AAAA,MAC/D,MAAM;AAAA,IACP;AAAA,EACD;AAAA,EACA;AAAA,EACA;AACD;AAEA,IAAK,OAAO,2CAA4C;AACvD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,OAAQ;AAAA,MACnB,MAAM;AAAA,IACP;AAAA,IACA;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,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,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// packages/block-library/src/paragraph/deprecated-attributes.js
|
|
2
|
+
import { useEvent } from "@wordpress/compose";
|
|
3
|
+
import { useEffect, useRef } from "@wordpress/element";
|
|
4
|
+
import deprecated from "@wordpress/deprecated";
|
|
5
|
+
import { useDispatch } from "@wordpress/data";
|
|
6
|
+
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
7
|
+
function useDeprecatedAlign(align, style, setAttributes) {
|
|
8
|
+
const { __unstableMarkNextChangeAsNotPersistent } = useDispatch(blockEditorStore);
|
|
9
|
+
const updateStyleWithAlign = useEvent(() => {
|
|
10
|
+
deprecated("align attribute in paragraph block", {
|
|
11
|
+
alternative: "style.typography.textAlign",
|
|
12
|
+
since: "7.0"
|
|
13
|
+
});
|
|
14
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
15
|
+
setAttributes({
|
|
16
|
+
style: {
|
|
17
|
+
...style,
|
|
18
|
+
typography: {
|
|
19
|
+
...style?.typography,
|
|
20
|
+
textAlign: align
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
const lastUpdatedAlignRef = useRef();
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (align === lastUpdatedAlignRef.current) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
lastUpdatedAlignRef.current = align;
|
|
31
|
+
updateStyleWithAlign();
|
|
32
|
+
}, [align, updateStyleWithAlign]);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
useDeprecatedAlign as default
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=deprecated-attributes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/paragraph/deprecated-attributes.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEvent } from '@wordpress/compose';\nimport { useEffect, useRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\nimport { useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * If a plugin is still using the old align attribute, we need to migrate its value\n * to the new style.typography.textAlign attribute.\n *\n * @param {string?} align Align attribute value.\n * @param {Object?} style Style attribute value.\n * @param {(Object) => void} setAttributes Updater function for block attributes.\n */\nexport default function useDeprecatedAlign( align, style, setAttributes ) {\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst updateStyleWithAlign = useEvent( () => {\n\t\tdeprecated( 'align attribute in paragraph block', {\n\t\t\talternative: 'style.typography.textAlign',\n\t\t\tsince: '7.0',\n\t\t} );\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( {\n\t\t\tstyle: {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\ttextAlign: align,\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t} );\n\tconst lastUpdatedAlignRef = useRef();\n\tuseEffect( () => {\n\t\tif ( align === lastUpdatedAlignRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tlastUpdatedAlignRef.current = align;\n\t\tupdateStyleWithAlign();\n\t}, [ align, updateStyleWithAlign ] );\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,gBAAgB;AACzB,SAAS,WAAW,cAAc;AAClC,OAAO,gBAAgB;AACvB,SAAS,mBAAmB;AAC5B,SAAS,SAAS,wBAAwB;AAU3B,SAAR,mBAAqC,OAAO,OAAO,eAAgB;AACzE,QAAM,EAAE,wCAAwC,IAC/C,YAAa,gBAAiB;AAC/B,QAAM,uBAAuB,SAAU,MAAM;AAC5C,eAAY,sCAAsC;AAAA,MACjD,aAAa;AAAA,MACb,OAAO;AAAA,IACR,CAAE;AACF,4CAAwC;AACxC,kBAAe;AAAA,MACd,OAAO;AAAA,QACN,GAAG;AAAA,QACH,YAAY;AAAA,UACX,GAAG,OAAO;AAAA,UACV,WAAW;AAAA,QACZ;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH,CAAE;AACF,QAAM,sBAAsB,OAAO;AACnC,YAAW,MAAM;AAChB,QAAK,UAAU,oBAAoB,SAAU;AAC5C;AAAA,IACD;AACA,wBAAoB,UAAU;AAC9B,yBAAqB;AAAA,EACtB,GAAG,CAAE,OAAO,oBAAqB,CAAE;AACpC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { getBlockSupport } from "@wordpress/blocks";
|
|
18
18
|
import { formatLtr } from "@wordpress/icons";
|
|
19
19
|
import { useOnEnter } from "./use-enter";
|
|
20
|
+
import useDeprecatedAlign from "./deprecated-attributes";
|
|
20
21
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
22
|
function ParagraphRTLControl({ direction, setDirection }) {
|
|
22
23
|
return isRTL() && /* @__PURE__ */ jsx(
|
|
@@ -89,6 +90,7 @@ function ParagraphBlock({
|
|
|
89
90
|
}) {
|
|
90
91
|
const { content, direction, dropCap, placeholder, style } = attributes;
|
|
91
92
|
const textAlign = style?.typography?.textAlign;
|
|
93
|
+
useDeprecatedAlign(attributes.align, style, setAttributes);
|
|
92
94
|
const blockProps = useBlockProps({
|
|
93
95
|
ref: useOnEnter({ clientId, content }),
|
|
94
96
|
className: clsx({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/paragraph/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tuseSettings,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { formatLtr } from '@wordpress/icons';\n/**\n * Internal dependencies\n */\nimport { useOnEnter } from './use-enter';\n\nfunction ParagraphRTLControl( { direction, setDirection } ) {\n\treturn (\n\t\tisRTL() && (\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ formatLtr }\n\t\t\t\ttitle={ _x( 'Left to right', 'editor button' ) }\n\t\t\t\tisActive={ direction === 'ltr' }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetDirection( direction === 'ltr' ? undefined : 'ltr' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t)\n\t);\n}\n\nfunction hasDropCapDisabled( align ) {\n\treturn align === ( isRTL() ? 'left' : 'right' ) || align === 'center';\n}\n\nfunction DropCapControl( { clientId, attributes, setAttributes, name } ) {\n\t// Please do not add a useSelect call to the paragraph block unconditionally.\n\t// Every useSelect added to a (frequently used) block will degrade load\n\t// and type performance. By moving it within InspectorControls, the subscription is\n\t// now only added for the selected block(s).\n\tconst [ isDropCapFeatureEnabled ] = useSettings( 'typography.dropCap' );\n\n\tif ( ! isDropCapFeatureEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst { style, dropCap } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\n\tlet helpText;\n\tif ( hasDropCapDisabled( textAlign ) ) {\n\t\thelpText = __( 'Not available for aligned text.' );\n\t} else if ( dropCap ) {\n\t\thelpText = __( 'Showing large initial letter.' );\n\t} else {\n\t\thelpText = __( 'Show a large initial letter.' );\n\t}\n\n\tconst isDropCapControlEnabledByDefault = getBlockSupport(\n\t\tname,\n\t\t'typography.defaultControls.dropCap',\n\t\tfalse\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"typography\">\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! dropCap }\n\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\tisShownByDefault={ isDropCapControlEnabledByDefault }\n\t\t\t\tonDeselect={ () => setAttributes( { dropCap: false } ) }\n\t\t\t\tresetAllFilter={ () => ( { dropCap: false } ) }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<ToggleControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\tchecked={ !! dropCap }\n\t\t\t\t\tonChange={ () => setAttributes( { dropCap: ! dropCap } ) }\n\t\t\t\t\thelp={ helpText }\n\t\t\t\t\tdisabled={ hasDropCapDisabled( textAlign ) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction ParagraphBlock( {\n\tattributes,\n\tmergeBlocks,\n\tonReplace,\n\tonRemove,\n\tsetAttributes,\n\tclientId,\n\tisSelected: isSingleSelected,\n\tname,\n} ) {\n\tconst { content, direction, dropCap, placeholder, style } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\tconst blockProps = useBlockProps( {\n\t\tref: useOnEnter( { clientId, content } ),\n\t\tclassName: clsx( {\n\t\t\t'has-drop-cap': hasDropCapDisabled( textAlign ) ? false : dropCap,\n\t\t} ),\n\t\tstyle: { direction },\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<ParagraphRTLControl\n\t\t\t\t\t\tdirection={ direction }\n\t\t\t\t\t\tsetDirection={ ( newDirection ) =>\n\t\t\t\t\t\t\tsetAttributes( { direction: newDirection } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<DropCapControl\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName=\"p\"\n\t\t\t\t{ ...blockProps }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t}\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\taria-label={\n\t\t\t\t\tRichText.isEmpty( content )\n\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t'Empty block; start writing or type forward slash to choose a block'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Block: Paragraph' )\n\t\t\t\t}\n\t\t\t\tdata-empty={ RichText.isEmpty( content ) }\n\t\t\t\tplaceholder={ placeholder || __( 'Type / to choose a block' ) }\n\t\t\t\tdata-custom-placeholder={ placeholder ? true : undefined }\n\t\t\t\t__unstableEmbedURLOnPaste\n\t\t\t\t__unstableAllowPrefixTransformations\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default ParagraphBlock;\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,IAAI,IAAI,aAAa;AAC9B;AAAA,EACC;AAAA,EACA;AAAA,EACA,gCAAgC;AAAA,OAC1B;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAI1B,SAAS,kBAAkB;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tuseSettings,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { formatLtr } from '@wordpress/icons';\n/**\n * Internal dependencies\n */\nimport { useOnEnter } from './use-enter';\nimport useDeprecatedAlign from './deprecated-attributes';\n\nfunction ParagraphRTLControl( { direction, setDirection } ) {\n\treturn (\n\t\tisRTL() && (\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ formatLtr }\n\t\t\t\ttitle={ _x( 'Left to right', 'editor button' ) }\n\t\t\t\tisActive={ direction === 'ltr' }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetDirection( direction === 'ltr' ? undefined : 'ltr' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t)\n\t);\n}\n\nfunction hasDropCapDisabled( align ) {\n\treturn align === ( isRTL() ? 'left' : 'right' ) || align === 'center';\n}\n\nfunction DropCapControl( { clientId, attributes, setAttributes, name } ) {\n\t// Please do not add a useSelect call to the paragraph block unconditionally.\n\t// Every useSelect added to a (frequently used) block will degrade load\n\t// and type performance. By moving it within InspectorControls, the subscription is\n\t// now only added for the selected block(s).\n\tconst [ isDropCapFeatureEnabled ] = useSettings( 'typography.dropCap' );\n\n\tif ( ! isDropCapFeatureEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst { style, dropCap } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\n\tlet helpText;\n\tif ( hasDropCapDisabled( textAlign ) ) {\n\t\thelpText = __( 'Not available for aligned text.' );\n\t} else if ( dropCap ) {\n\t\thelpText = __( 'Showing large initial letter.' );\n\t} else {\n\t\thelpText = __( 'Show a large initial letter.' );\n\t}\n\n\tconst isDropCapControlEnabledByDefault = getBlockSupport(\n\t\tname,\n\t\t'typography.defaultControls.dropCap',\n\t\tfalse\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"typography\">\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! dropCap }\n\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\tisShownByDefault={ isDropCapControlEnabledByDefault }\n\t\t\t\tonDeselect={ () => setAttributes( { dropCap: false } ) }\n\t\t\t\tresetAllFilter={ () => ( { dropCap: false } ) }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<ToggleControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\tchecked={ !! dropCap }\n\t\t\t\t\tonChange={ () => setAttributes( { dropCap: ! dropCap } ) }\n\t\t\t\t\thelp={ helpText }\n\t\t\t\t\tdisabled={ hasDropCapDisabled( textAlign ) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction ParagraphBlock( {\n\tattributes,\n\tmergeBlocks,\n\tonReplace,\n\tonRemove,\n\tsetAttributes,\n\tclientId,\n\tisSelected: isSingleSelected,\n\tname,\n} ) {\n\tconst { content, direction, dropCap, placeholder, style } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\tuseDeprecatedAlign( attributes.align, style, setAttributes );\n\tconst blockProps = useBlockProps( {\n\t\tref: useOnEnter( { clientId, content } ),\n\t\tclassName: clsx( {\n\t\t\t'has-drop-cap': hasDropCapDisabled( textAlign ) ? false : dropCap,\n\t\t} ),\n\t\tstyle: { direction },\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<ParagraphRTLControl\n\t\t\t\t\t\tdirection={ direction }\n\t\t\t\t\t\tsetDirection={ ( newDirection ) =>\n\t\t\t\t\t\t\tsetAttributes( { direction: newDirection } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<DropCapControl\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName=\"p\"\n\t\t\t\t{ ...blockProps }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t}\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\taria-label={\n\t\t\t\t\tRichText.isEmpty( content )\n\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t'Empty block; start writing or type forward slash to choose a block'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Block: Paragraph' )\n\t\t\t\t}\n\t\t\t\tdata-empty={ RichText.isEmpty( content ) }\n\t\t\t\tplaceholder={ placeholder || __( 'Type / to choose a block' ) }\n\t\t\t\tdata-custom-placeholder={ placeholder ? true : undefined }\n\t\t\t\t__unstableEmbedURLOnPaste\n\t\t\t\t__unstableAllowPrefixTransformations\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default ParagraphBlock;\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,IAAI,IAAI,aAAa;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AAAA,QACR,UAAW,CAAE,eACZ,cAAe,EAAE,SAAS,WAAW,CAAE;AAAA,QAExC,SAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA,cACC,SAAS,QAAS,OAAQ,IACvB;AAAA,UACA;AAAA,QACA,IACA,GAAI,kBAAmB;AAAA,QAE3B,cAAa,SAAS,QAAS,OAAQ;AAAA,QACvC,aAAc,eAAe,GAAI,0BAA2B;AAAA,QAC5D,2BAA0B,cAAc,OAAO;AAAA,QAC/C,2BAAyB;AAAA,QACzB,sCAAoC;AAAA;AAAA,IACrC;AAAA,KACD;AAEF;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// packages/block-library/src/paragraph/index.js
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
3
|
import { paragraph as icon } from "@wordpress/icons";
|
|
4
|
+
import { privateApis as blocksPrivateApis } from "@wordpress/blocks";
|
|
4
5
|
import initBlock from "../utils/init-block";
|
|
5
6
|
import deprecated from "./deprecated";
|
|
6
7
|
import edit from "./edit";
|
|
@@ -8,6 +9,8 @@ import metadata from "./block.json";
|
|
|
8
9
|
import save from "./save";
|
|
9
10
|
import transforms from "./transforms";
|
|
10
11
|
import variations from "./variations";
|
|
12
|
+
import { unlock } from "../lock-unlock";
|
|
13
|
+
var { fieldsKey, formKey } = unlock(blocksPrivateApis);
|
|
11
14
|
var { name } = metadata;
|
|
12
15
|
var settings = {
|
|
13
16
|
icon,
|
|
@@ -43,16 +46,16 @@ var settings = {
|
|
|
43
46
|
variations
|
|
44
47
|
};
|
|
45
48
|
if (window.__experimentalContentOnlyPatternInsertion) {
|
|
46
|
-
settings
|
|
49
|
+
settings[fieldsKey] = [
|
|
47
50
|
{
|
|
51
|
+
id: "content",
|
|
48
52
|
label: __("Content"),
|
|
49
|
-
type: "
|
|
50
|
-
shownByDefault: true,
|
|
51
|
-
mapping: {
|
|
52
|
-
value: "content"
|
|
53
|
-
}
|
|
53
|
+
type: "richtext"
|
|
54
54
|
}
|
|
55
55
|
];
|
|
56
|
+
settings[formKey] = {
|
|
57
|
+
fields: ["content"]
|
|
58
|
+
};
|
|
56
59
|
}
|
|
57
60
|
var init = () => initBlock({ name, metadata, settings });
|
|
58
61
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/paragraph/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { paragraph as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __(\n\t\t\t\t'In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.'\n\t\t\t),\n\t\t},\n\t},\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\tif ( customName ) {\n\t\t\t\treturn customName;\n\t\t\t}\n\n\t\t\tconst { content } = attributes;\n\t\t\treturn ! content || content.length === 0 ? __( 'Empty' ) : content;\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n\tvariations,\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,aAAa,YAAY;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { paragraph as icon } from '@wordpress/icons';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport variations from './variations';\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\tattributes: {\n\t\t\tcontent: __(\n\t\t\t\t'In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.'\n\t\t\t),\n\t\t},\n\t},\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\tif ( customName ) {\n\t\t\t\treturn customName;\n\t\t\t}\n\n\t\t\tconst { content } = attributes;\n\t\t\treturn ! content || content.length === 0 ? __( 'Empty' ) : content;\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n\tvariations,\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'content',\n\t\t\tlabel: __( 'Content' ),\n\t\t\ttype: 'richtext',\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ '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,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// packages/block-library/src/preformatted/index.js
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
3
|
import { preformatted as icon } from "@wordpress/icons";
|
|
4
|
+
import { privateApis as blocksPrivateApis } from "@wordpress/blocks";
|
|
4
5
|
import initBlock from "../utils/init-block";
|
|
5
6
|
import edit from "./edit";
|
|
6
7
|
import metadata from "./block.json";
|
|
7
8
|
import save from "./save";
|
|
8
9
|
import transforms from "./transforms";
|
|
10
|
+
import { unlock } from "../lock-unlock";
|
|
11
|
+
var { fieldsKey, formKey } = unlock(blocksPrivateApis);
|
|
9
12
|
var { name } = metadata;
|
|
10
13
|
var settings = {
|
|
11
14
|
icon,
|
|
@@ -29,16 +32,16 @@ var settings = {
|
|
|
29
32
|
}
|
|
30
33
|
};
|
|
31
34
|
if (window.__experimentalContentOnlyPatternInsertion) {
|
|
32
|
-
settings
|
|
35
|
+
settings[fieldsKey] = [
|
|
33
36
|
{
|
|
37
|
+
id: "content",
|
|
34
38
|
label: __("Content"),
|
|
35
|
-
type: "
|
|
36
|
-
shownByDefault: true,
|
|
37
|
-
mapping: {
|
|
38
|
-
value: "content"
|
|
39
|
-
}
|
|
39
|
+
type: "richtext"
|
|
40
40
|
}
|
|
41
41
|
];
|
|
42
|
+
settings[formKey] = {
|
|
43
|
+
fields: ["content"]
|
|
44
|
+
};
|
|
42
45
|
}
|
|
43
46
|
var init = () => initBlock({ name, metadata, settings });
|
|
44
47
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/preformatted/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { preformatted 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\tattributes: {\n\t\t\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Sample content for the Preformatted block. Can be replaced with a more locale-adequate work.\n\t\t\tcontent: __(\n\t\t\t\t'EXT. XANADU - FAINT DAWN - 1940 (MINIATURE)\\nWindow, very small in the distance, illuminated.\\nAll around this is an almost totally black screen. Now, as the camera moves slowly towards the window which is almost a postage stamp in the frame, other forms appear;'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent: attributes.content + '\\n\\n' + attributesToMerge.content,\n\t\t};\n\t},\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,gBAAgB,YAAY;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { preformatted as icon } from '@wordpress/icons';\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\tattributes: {\n\t\t\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Sample content for the Preformatted block. Can be replaced with a more locale-adequate work.\n\t\t\tcontent: __(\n\t\t\t\t'EXT. XANADU - FAINT DAWN - 1940 (MINIATURE)\\nWindow, very small in the distance, illuminated.\\nAll around this is an almost totally black screen. Now, as the camera moves slowly towards the window which is almost a postage stamp in the frame, other forms appear;'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent: attributes.content + '\\n\\n' + attributesToMerge.content,\n\t\t};\n\t},\n};\n\nif ( window.__experimentalContentOnlyPatternInsertion ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'content',\n\t\t\tlabel: __( 'Content' ),\n\t\t\ttype: 'richtext',\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'content' ],\n\t};\n}\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,gBAAgB,YAAY;AACrC,SAAS,eAAe,yBAAyB;AAKjD,OAAO,eAAe;AACtB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,SAAS,cAAc;AAEvB,IAAM,EAAE,WAAW,QAAQ,IAAI,OAAQ,iBAAkB;AAEzD,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA;AAAA;AAAA,MAGX,SAAS;AAAA,QACR;AAAA,MACD;AAAA;AAAA,IAED;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,SAAS,WAAW,UAAU,SAAS,kBAAkB;AAAA,IAC1D;AAAA,EACD;AACD;AAEA,IAAK,OAAO,2CAA4C;AACvD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,SAAU;AAAA,MACrB,MAAM;AAAA,IACP;AAAA,EACD;AACA,WAAU,OAAQ,IAAI;AAAA,IACrB,QAAQ,CAAE,SAAU;AAAA,EACrB;AACD;AAEO,IAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
// packages/block-library/src/pullquote/index.js
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
3
|
import { pullquote as icon } from "@wordpress/icons";
|
|
4
|
+
import { privateApis as blocksPrivateApis } from "@wordpress/blocks";
|
|
4
5
|
import initBlock from "../utils/init-block";
|
|
5
6
|
import deprecated from "./deprecated";
|
|
6
7
|
import edit from "./edit";
|
|
7
8
|
import metadata from "./block.json";
|
|
8
9
|
import save from "./save";
|
|
9
10
|
import transforms from "./transforms";
|
|
11
|
+
import { unlock } from "../lock-unlock";
|
|
12
|
+
var { fieldsKey, formKey } = unlock(blocksPrivateApis);
|
|
10
13
|
var { name } = metadata;
|
|
11
14
|
var settings = {
|
|
12
15
|
icon,
|
|
@@ -27,24 +30,21 @@ var settings = {
|
|
|
27
30
|
deprecated
|
|
28
31
|
};
|
|
29
32
|
if (window.__experimentalContentOnlyPatternInsertion) {
|
|
30
|
-
settings
|
|
33
|
+
settings[fieldsKey] = [
|
|
31
34
|
{
|
|
35
|
+
id: "value",
|
|
32
36
|
label: __("Content"),
|
|
33
|
-
type: "
|
|
34
|
-
shownByDefault: true,
|
|
35
|
-
mapping: {
|
|
36
|
-
value: "value"
|
|
37
|
-
}
|
|
37
|
+
type: "richtext"
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
|
+
id: "citation",
|
|
40
41
|
label: __("Citation"),
|
|
41
|
-
type: "
|
|
42
|
-
shownByDefault: false,
|
|
43
|
-
mapping: {
|
|
44
|
-
value: "citation"
|
|
45
|
-
}
|
|
42
|
+
type: "richtext"
|
|
46
43
|
}
|
|
47
44
|
];
|
|
45
|
+
settings[formKey] = {
|
|
46
|
+
fields: ["value"]
|
|
47
|
+
};
|
|
48
48
|
}
|
|
49
49
|
var init = () => initBlock({ name, metadata, settings });
|
|
50
50
|
export {
|