@wordpress/block-library 9.31.1-next.233ccab9b.0 → 9.32.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/edit.js +62 -12
- package/build/accordion/edit.js.map +1 -1
- package/build/accordion/index.js +15 -7
- package/build/accordion/index.js.map +1 -1
- package/build/accordion/view.js +15 -15
- package/build/accordion/view.js.map +1 -1
- package/build/accordion-heading/edit.js +68 -0
- package/build/accordion-heading/edit.js.map +1 -0
- package/build/accordion-heading/icon.js.map +1 -0
- package/build/{accordion-header → accordion-heading}/index.js +9 -12
- package/build/accordion-heading/index.js.map +1 -0
- package/build/{accordion-content → accordion-heading}/init.js.map +1 -1
- package/build/{accordion-header → accordion-heading}/save.js +6 -8
- package/build/accordion-heading/save.js.map +1 -0
- package/build/{accordion-content → accordion-item}/edit.js +8 -2
- package/build/accordion-item/edit.js.map +1 -0
- package/build/accordion-item/icon.js.map +1 -0
- package/build/{accordion-content → accordion-item}/index.js +5 -5
- package/build/accordion-item/index.js.map +1 -0
- package/build/accordion-item/init.js.map +1 -0
- package/build/accordion-item/save.js.map +1 -0
- package/build/accordion-panel/index.js +3 -2
- package/build/accordion-panel/index.js.map +1 -1
- package/build/block/index.js +1 -0
- package/build/block/index.js.map +1 -1
- package/build/index.js +24 -4
- package/build/index.js.map +1 -1
- package/build/navigation-link/edit.js +3 -140
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/shared/controls.js +171 -0
- package/build/navigation-link/shared/controls.js.map +1 -0
- package/build/navigation-link/shared/index.js +13 -0
- package/build/navigation-link/shared/index.js.map +1 -0
- package/build/navigation-submenu/edit.js +5 -110
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/pattern/index.js +1 -0
- package/build/pattern/index.js.map +1 -1
- package/build/post-time-to-read/edit.js +16 -61
- package/build/post-time-to-read/edit.js.map +1 -1
- package/build/post-time-to-read/index.js +5 -7
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/post-time-to-read/variations.js +41 -0
- package/build/post-time-to-read/variations.js.map +1 -0
- package/build/query-title/edit.js +1 -1
- package/build/query-title/edit.js.map +1 -1
- package/build/template-part/index.js +1 -0
- package/build/template-part/index.js.map +1 -1
- package/build/utils/get-transformed-metadata.js +7 -0
- package/build/utils/get-transformed-metadata.js.map +1 -1
- package/build-module/accordion/edit.js +66 -16
- package/build-module/accordion/edit.js.map +1 -1
- package/build-module/accordion/index.js +15 -7
- package/build-module/accordion/index.js.map +1 -1
- package/build-module/accordion/view.js +15 -15
- package/build-module/accordion/view.js.map +1 -1
- package/build-module/accordion-heading/edit.js +61 -0
- package/build-module/accordion-heading/edit.js.map +1 -0
- package/build-module/accordion-heading/icon.js.map +1 -0
- package/build-module/{accordion-header → accordion-heading}/index.js +9 -12
- package/build-module/accordion-heading/index.js.map +1 -0
- package/build-module/{accordion-content → accordion-heading}/init.js.map +1 -1
- package/build-module/{accordion-header → accordion-heading}/save.js +6 -8
- package/build-module/accordion-heading/save.js.map +1 -0
- package/build-module/{accordion-content → accordion-item}/edit.js +8 -2
- package/build-module/accordion-item/edit.js.map +1 -0
- package/build-module/accordion-item/icon.js.map +1 -0
- package/build-module/{accordion-content → accordion-item}/index.js +5 -5
- package/build-module/accordion-item/index.js.map +1 -0
- package/build-module/accordion-item/init.js.map +1 -0
- package/build-module/accordion-item/save.js.map +1 -0
- package/build-module/accordion-panel/index.js +3 -2
- package/build-module/accordion-panel/index.js.map +1 -1
- package/build-module/block/index.js +1 -0
- package/build-module/block/index.js.map +1 -1
- package/build-module/index.js +25 -5
- package/build-module/index.js.map +1 -1
- package/build-module/navigation-link/edit.js +4 -141
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/shared/controls.js +165 -0
- package/build-module/navigation-link/shared/controls.js.map +1 -0
- package/build-module/navigation-link/shared/index.js +9 -0
- package/build-module/navigation-link/shared/index.js.map +1 -0
- package/build-module/navigation-submenu/edit.js +6 -111
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/pattern/index.js +1 -0
- package/build-module/pattern/index.js.map +1 -1
- package/build-module/post-time-to-read/edit.js +17 -62
- package/build-module/post-time-to-read/edit.js.map +1 -1
- package/build-module/post-time-to-read/index.js +5 -7
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/post-time-to-read/variations.js +33 -0
- package/build-module/post-time-to-read/variations.js.map +1 -0
- package/build-module/query-title/edit.js +1 -1
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/template-part/index.js +1 -0
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/utils/get-transformed-metadata.js +7 -0
- package/build-module/utils/get-transformed-metadata.js.map +1 -1
- package/build-style/{accordion-header → accordion-heading}/style-rtl.css +8 -7
- package/build-style/{accordion-header → accordion-heading}/style.css +8 -7
- package/build-style/{accordion-content → accordion-item}/style-rtl.css +5 -5
- package/build-style/{accordion-content → accordion-item}/style.css +5 -5
- package/build-style/style-rtl.css +13 -12
- package/build-style/style.css +13 -12
- package/package.json +35 -35
- package/src/accordion/block.json +11 -3
- package/src/accordion/edit.js +70 -13
- package/src/accordion/index.js +4 -4
- package/src/accordion/index.php +1 -1
- package/src/accordion/view.js +15 -15
- package/src/{accordion-header → accordion-heading}/block.json +10 -12
- package/src/accordion-heading/edit.js +70 -0
- package/src/{accordion-header → accordion-heading}/save.js +6 -8
- package/src/{accordion-header → accordion-heading}/style.scss +11 -7
- package/src/{accordion-content → accordion-item}/block.json +5 -5
- package/src/{accordion-content → accordion-item}/edit.js +12 -2
- package/src/{accordion-content → accordion-item}/index.php +11 -11
- package/src/{accordion-content → accordion-item}/style.scss +3 -3
- package/src/accordion-panel/block.json +3 -2
- package/src/block/block.json +1 -0
- package/src/index.js +23 -4
- package/src/navigation-link/edit.js +3 -142
- package/src/navigation-link/shared/README.md +47 -0
- package/src/navigation-link/shared/controls.js +167 -0
- package/src/navigation-link/shared/index.js +8 -0
- package/src/navigation-link/shared/test/controls.js +210 -0
- package/src/navigation-submenu/edit.js +7 -125
- package/src/pattern/block.json +1 -0
- package/src/post-time-to-read/block.json +3 -7
- package/src/post-time-to-read/edit.js +36 -94
- package/src/post-time-to-read/index.js +2 -0
- package/src/post-time-to-read/index.php +12 -7
- package/src/post-time-to-read/variations.js +39 -0
- package/src/query-title/edit.js +2 -1
- package/src/query-title/index.php +3 -1
- package/src/style.scss +2 -2
- package/src/template-part/block.json +1 -0
- package/src/utils/get-transformed-metadata.js +8 -0
- package/build/accordion-content/edit.js.map +0 -1
- package/build/accordion-content/icon.js.map +0 -1
- package/build/accordion-content/index.js.map +0 -1
- package/build/accordion-content/save.js.map +0 -1
- package/build/accordion-header/edit.js +0 -84
- package/build/accordion-header/edit.js.map +0 -1
- package/build/accordion-header/icon.js.map +0 -1
- package/build/accordion-header/index.js.map +0 -1
- package/build/accordion-header/init.js.map +0 -1
- package/build/accordion-header/save.js.map +0 -1
- package/build-module/accordion-content/edit.js.map +0 -1
- package/build-module/accordion-content/icon.js.map +0 -1
- package/build-module/accordion-content/index.js.map +0 -1
- package/build-module/accordion-content/save.js.map +0 -1
- package/build-module/accordion-header/edit.js +0 -77
- package/build-module/accordion-header/edit.js.map +0 -1
- package/build-module/accordion-header/icon.js.map +0 -1
- package/build-module/accordion-header/index.js.map +0 -1
- package/build-module/accordion-header/init.js.map +0 -1
- package/build-module/accordion-header/save.js.map +0 -1
- package/src/accordion-header/edit.js +0 -87
- /package/build/{accordion-header → accordion-heading}/icon.js +0 -0
- /package/build/{accordion-content → accordion-heading}/init.js +0 -0
- /package/build/{accordion-content → accordion-item}/icon.js +0 -0
- /package/build/{accordion-header → accordion-item}/init.js +0 -0
- /package/build/{accordion-content → accordion-item}/save.js +0 -0
- /package/build-module/{accordion-header → accordion-heading}/icon.js +0 -0
- /package/build-module/{accordion-content → accordion-heading}/init.js +0 -0
- /package/build-module/{accordion-content → accordion-item}/icon.js +0 -0
- /package/build-module/{accordion-header → accordion-item}/init.js +0 -0
- /package/build-module/{accordion-content → accordion-item}/save.js +0 -0
- /package/src/{accordion-header → accordion-heading}/icon.js +0 -0
- /package/src/{accordion-content → accordion-heading}/index.js +0 -0
- /package/src/{accordion-content → accordion-heading}/init.js +0 -0
- /package/src/{accordion-content → accordion-item}/icon.js +0 -0
- /package/src/{accordion-header → accordion-item}/index.js +0 -0
- /package/src/{accordion-header → accordion-item}/init.js +0 -0
- /package/src/{accordion-content → accordion-item}/save.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useSelect","useDispatch","CheckboxControl","TextControl","TextareaControl","ToolbarButton","ToolbarGroup","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","displayShortcut","isKeyboardEvent","__","BlockControls","InnerBlocks","useInnerBlocksProps","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","isURL","prependHTTP","useState","useEffect","useRef","link","linkIcon","removeSubmenu","speak","createBlock","useMergeRefs","usePrevious","ItemSubmenuIcon","LinkUI","updateAttributes","getColors","getNavigationChildBlockProps","useToolsPanelDropdownMenuProps","DEFAULT_BLOCK","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ALLOWED_BLOCKS","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","NavigationSubmenuEdit","attributes","isSelected","setAttributes","mergeBlocks","onReplace","context","clientId","label","url","description","rel","opensInNewTab","showSubmenuIcon","maxNestingLevel","openSubmenusOnClick","__unstableMarkNextChangeAsNotPersistent","replaceBlock","selectBlock","isLinkOpen","setIsLinkOpen","openedBy","setOpenedBy","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","dropdownMenuProps","parentCount","isParentOfSelectedBlock","isImmediateParentOfSelectedBlock","hasChildren","selectedBlockHasChildren","onlyDescendantIsEmptyLink","select","hasSelectedInnerBlock","getSelectedBlockClientId","getBlockParentsByBlockName","getBlock","getBlockCount","getBlockOrder","_onlyDescendantIsEmptyLink","selectedBlockId","selectedBlockChildren","length","singleBlock","name","prevHasChildren","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","textColor","customTextColor","backgroundColor","customBackgroundColor","onKeyDown","primary","preventDefault","stopPropagation","blockProps","className","style","color","innerBlocksColors","allowedBlocks","filter","blockName","navigationChildBlockProps","innerBlocksProps","defaultBlock","directInsert","__experimentalCaptureToolbars","renderAppender","ButtonBlockAppender","ParentElement","transformToLink","newLinkBlock","canConvertToLink","children","icon","title","shortcut","onClick","currentTarget","disabled","resetAll","isShownByDefault","hasValue","onDeselect","__nextHasNoMarginBottom","__next40pxDefaultSize","value","onChange","labelValue","autoComplete","urlValue","type","checked","descriptionValue","help","relValue","identifier","onMerge","placeholder","withoutInteractiveFormatting","onClose","anchor","onRemove","updatedValue"],"sources":["@wordpress/block-library/src/navigation-submenu/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tCheckboxControl,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport { LinkUI } from '../navigation-link/link-ui';\nimport { updateAttributes } from '../navigation-link/update-attributes';\nimport {\n\tgetColors,\n\tgetNavigationChildBlockProps,\n} from '../navigation/edit/utils';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport { DEFAULT_BLOCK } from '../navigation/constants';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\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}, [] );\n\n\treturn isDraggingWithin;\n};\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, url, description, rel, opensInNewTab } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;\n\n\tconst {\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlock,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\t// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text…' );\n\tconst ref = useRef();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst {\n\t\tparentCount,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentCount: getBlockParentsByBlockName(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'core/navigation-submenu'\n\t\t\t\t).length,\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\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\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\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t}\n\t\t}\n\t}, [ url ] );\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\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, parentCount > 0 );\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 we don't stop propagation, this event bubbles up to the parent submenu item\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tconst allowedBlocks =\n\t\tparentCount >= maxNestingLevel\n\t\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t\t )\n\t\t\t: ALLOWED_BLOCKS;\n\n\tconst navigationChildBlockProps =\n\t\tgetNavigationChildBlockProps( innerBlocksColors );\n\tconst innerBlocksProps = useInnerBlocksProps( navigationChildBlockProps, {\n\t\tallowedBlocks,\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\tdirectInsert: true,\n\n\t\t// Ensure block toolbar is not too far removed from item\n\t\t// being edited.\n\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t__experimentalCaptureToolbars: true,\n\n\t\trenderAppender:\n\t\t\tisSelected ||\n\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\thasChildren\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: false,\n\t} );\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\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\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( event.currentTarget );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tdisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ /* Warning, this duplicated in packages/block-library/src/navigation-link/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tlabel: '',\n\t\t\t\t\t\t\turl: '',\n\t\t\t\t\t\t\tdescription: '',\n\t\t\t\t\t\t\trel: '',\n\t\t\t\t\t\t\topensInNewTab: false,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! label }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { label: '' } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvalue={ label || '' }\n\t\t\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! url }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { url: '' } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvalue={ url || '' }\n\t\t\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: urlValue } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\ttype=\"url\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! opensInNewTab }\n\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { opensInNewTab: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\tchecked={ opensInNewTab }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { opensInNewTab: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! description }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { description: '' } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tdescription: descriptionValue,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! rel }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { rel: '' } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'The relationship of the linked URL as space-separated link types.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( ref.current );\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{ description && (\n\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\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\tif ( openedBy ) {\n\t\t\t\t\t\t\t\t\topenedBy.focus();\n\t\t\t\t\t\t\t\t\tsetOpenedBy( null );\n\t\t\t\t\t\t\t\t} else {\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={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,eAAe,EACfC,WAAW,EACXC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,eAAe,EAAEC,eAAe,QAAQ,qBAAqB;AACtE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,aAAa,EACbC,WAAW,EACXC,mBAAmB,EACnBC,iBAAiB,EACjBC,QAAQ,EACRC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,iBAAiB,QACX,yBAAyB;AAChC,SAASC,KAAK,EAAEC,WAAW,QAAQ,gBAAgB;AACnD,SAASC,QAAQ,EAAEC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AAChE,SAASC,IAAI,IAAIC,QAAQ,EAAEC,aAAa,QAAQ,kBAAkB;AAClE,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,YAAY,EAAEC,WAAW,QAAQ,oBAAoB;;AAE9D;AACA;AACA;AACA,SAASC,eAAe,QAAQ,SAAS;AACzC,SAASC,MAAM,QAAQ,4BAA4B;AACnD,SAASC,gBAAgB,QAAQ,sCAAsC;AACvE,SACCC,SAAS,EACTC,4BAA4B,QACtB,0BAA0B;AACjC,SAASC,8BAA8B,QAAQ,gB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IAAA;QAAA,GAAUiG;MAAgB,CAAI,CAAC;IAAA,CAC3B,CAAC;EAAA,CACL,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useSelect","useDispatch","ToolbarButton","ToolbarGroup","displayShortcut","isKeyboardEvent","__","BlockControls","InnerBlocks","useInnerBlocksProps","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","isURL","prependHTTP","useState","useEffect","useRef","link","linkIcon","removeSubmenu","speak","createBlock","useMergeRefs","usePrevious","ItemSubmenuIcon","LinkUI","updateAttributes","Controls","getColors","getNavigationChildBlockProps","DEFAULT_BLOCK","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ALLOWED_BLOCKS","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","NavigationSubmenuEdit","attributes","isSelected","setAttributes","mergeBlocks","onReplace","context","clientId","label","url","description","showSubmenuIcon","maxNestingLevel","openSubmenusOnClick","__unstableMarkNextChangeAsNotPersistent","replaceBlock","selectBlock","isLinkOpen","setIsLinkOpen","openedBy","setOpenedBy","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","parentCount","isParentOfSelectedBlock","isImmediateParentOfSelectedBlock","hasChildren","selectedBlockHasChildren","onlyDescendantIsEmptyLink","select","hasSelectedInnerBlock","getSelectedBlockClientId","getBlockParentsByBlockName","getBlock","getBlockCount","getBlockOrder","_onlyDescendantIsEmptyLink","selectedBlockId","selectedBlockChildren","length","singleBlock","name","prevHasChildren","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","textColor","customTextColor","backgroundColor","customBackgroundColor","onKeyDown","primary","preventDefault","stopPropagation","blockProps","className","style","color","innerBlocksColors","allowedBlocks","filter","blockName","navigationChildBlockProps","innerBlocksProps","defaultBlock","directInsert","__experimentalCaptureToolbars","renderAppender","ButtonBlockAppender","ParentElement","transformToLink","newLinkBlock","canConvertToLink","children","icon","title","shortcut","onClick","currentTarget","disabled","identifier","value","onChange","labelValue","onMerge","placeholder","withoutInteractiveFormatting","onClose","anchor","onRemove","updatedValue"],"sources":["@wordpress/block-library/src/navigation-submenu/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport { LinkUI } from '../navigation-link/link-ui';\nimport { updateAttributes } from '../navigation-link/update-attributes';\nimport { Controls } from '../navigation-link/shared';\nimport {\n\tgetColors,\n\tgetNavigationChildBlockProps,\n} from '../navigation/edit/utils';\nimport { DEFAULT_BLOCK } from '../navigation/constants';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\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}, [] );\n\n\treturn isDraggingWithin;\n};\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, url, description } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;\n\n\tconst {\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlock,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\t// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text…' );\n\tconst ref = useRef();\n\n\tconst {\n\t\tparentCount,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentCount: getBlockParentsByBlockName(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'core/navigation-submenu'\n\t\t\t\t).length,\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\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\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\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t}\n\t\t}\n\t}, [ url ] );\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\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, parentCount > 0 );\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 we don't stop propagation, this event bubbles up to the parent submenu item\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tconst allowedBlocks =\n\t\tparentCount >= maxNestingLevel\n\t\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t\t )\n\t\t\t: ALLOWED_BLOCKS;\n\n\tconst navigationChildBlockProps =\n\t\tgetNavigationChildBlockProps( innerBlocksColors );\n\tconst innerBlocksProps = useInnerBlocksProps( navigationChildBlockProps, {\n\t\tallowedBlocks,\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\tdirectInsert: true,\n\n\t\t// Ensure block toolbar is not too far removed from item\n\t\t// being edited.\n\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t__experimentalCaptureToolbars: true,\n\n\t\trenderAppender:\n\t\t\tisSelected ||\n\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\thasChildren\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: false,\n\t} );\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\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\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( event.currentTarget );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tdisabled={ ! canConvertToLink }\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/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( ref.current );\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{ description && (\n\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\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\tif ( openedBy ) {\n\t\t\t\t\t\t\t\t\topenedBy.focus();\n\t\t\t\t\t\t\t\t\tsetOpenedBy( null );\n\t\t\t\t\t\t\t\t} else {\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={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,aAAa,EAAEC,YAAY,QAAQ,uBAAuB;AACnE,SAASC,eAAe,EAAEC,eAAe,QAAQ,qBAAqB;AACtE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,aAAa,EACbC,WAAW,EACXC,mBAAmB,EACnBC,iBAAiB,EACjBC,QAAQ,EACRC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,iBAAiB,QACX,yBAAyB;AAChC,SAASC,KAAK,EAAEC,WAAW,QAAQ,gBAAgB;AACnD,SAASC,QAAQ,EAAEC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AAChE,SAASC,IAAI,IAAIC,QAAQ,EAAEC,aAAa,QAAQ,kBAAkB;AAClE,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,YAAY,EAAEC,WAAW,QAAQ,oBAAoB;;AAE9D;AACA;AACA;AACA,SAASC,eAAe,QAAQ,SAAS;AACzC,SAASC,MAAM,QAAQ,4BAA4B;AACnD,SAASC,gBAAgB,QAAQ,sCAAsC;AACvE,SAASC,QAAQ,QAAQ,2BAA2B;AACpD,SACCC,SAAS,EACTC,4BAA4B,QACtB,0BAA0B;AACjC,SAASC,aAAa,QAAQ,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAExD,MAAMC,cAAc,GAAG,CACtB,sB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,QAAQ,EAAGA,CAAA,KAAM;YAChBjG,aAAa,CAAE;cAAEM,GAAG,EAAE;YAAG,CAAE,CAAC;YAC5BzC,KAAK,CAAElB,EAAE,CAAE,eAAgB,CAAC,EAAE,WAAY,CAAC;UAC5C,CAAG;UACH+I,QAAQ,EAAKQ,YAAY,IAAM;YAC9B/H,gBAAgB,CACf+H,YAAY,EACZlG,aAAa,EACbF,UACD,CAAC;UACF;QAAG,CACH,CACD;MAAA,CACa,CAAC,EACd,CAAEU,eAAe,IAAIE,mBAAmB,kBACzCjC,IAAA;QAAMsF,SAAS,EAAC,mCAAmC;QAAAkB,QAAA,eAClDxG,IAAA,CAACR,eAAe,IAAE;MAAC,CACd,CACN,eACDQ,IAAA;QAAA,GAAU8F;MAAgB,CAAI,CAAC;IAAA,CAC3B,CAAC;EAAA,CACL,CAAC;AAEL","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["initBlock","metadata","$schema","apiVersion","name","title","category","description","supports","html","inserter","renaming","interactivity","clientNavigation","textdomain","attributes","slug","type","PatternEdit","settings","edit","init"],"sources":["@wordpress/block-library/src/pattern/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport PatternEdit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\tedit: PatternEdit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,QAAA;IAAAC,aAAA;MAAAC,gBAAA;IAAA;EAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,IAAA;MAAAC,IAAA;IAAA;EAAA;AAAA;AAE5C,OAAOC,WAAW,MAAM,QAAQ;AAEhC,MAAM;
|
|
1
|
+
{"version":3,"names":["initBlock","metadata","$schema","apiVersion","name","title","category","description","supports","html","inserter","renaming","blockVisibility","interactivity","clientNavigation","textdomain","attributes","slug","type","PatternEdit","settings","edit","init"],"sources":["@wordpress/block-library/src/pattern/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport PatternEdit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\tedit: PatternEdit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,QAAA;IAAAC,eAAA;IAAAC,aAAA;MAAAC,gBAAA;IAAA;EAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,IAAA;MAAAC,IAAA;IAAA;EAAA;AAAA;AAE5C,OAAOC,WAAW,MAAM,QAAQ;AAEhC,MAAM;EAAEf;AAAK,CAAC,GAAGH,QAAQ;AACzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAMgB,QAAQ,GAAG;EACvBC,IAAI,EAAEF;AACP,CAAC;AAED,OAAO,MAAMG,IAAI,GAAGA,CAAA,KAAMtB,SAAS,CAAE;EAAEI,IAAI;EAAEH,QAAQ;EAAEmB;AAAS,CAAE,CAAC","ignoreList":[]}
|
|
@@ -18,7 +18,7 @@ import { count as wordCount } from '@wordpress/wordcount';
|
|
|
18
18
|
* Internal dependencies
|
|
19
19
|
*/
|
|
20
20
|
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
21
|
-
import { jsx as _jsx,
|
|
21
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
22
|
function PostTimeToReadEdit({
|
|
23
23
|
attributes,
|
|
24
24
|
setAttributes,
|
|
@@ -27,8 +27,7 @@ function PostTimeToReadEdit({
|
|
|
27
27
|
const {
|
|
28
28
|
textAlign,
|
|
29
29
|
displayAsRange,
|
|
30
|
-
|
|
31
|
-
showWordCount,
|
|
30
|
+
displayMode,
|
|
32
31
|
averageReadingSpeed
|
|
33
32
|
} = attributes;
|
|
34
33
|
const {
|
|
@@ -63,11 +62,9 @@ function PostTimeToReadEdit({
|
|
|
63
62
|
*/
|
|
64
63
|
const wordCountType = _x('words', 'Word count type. Do not translate!');
|
|
65
64
|
const totalWords = wordCount(content || '', wordCountType);
|
|
66
|
-
const parts = [];
|
|
67
65
|
|
|
68
66
|
// Add "time to read" part, if enabled.
|
|
69
|
-
if (
|
|
70
|
-
let timeString;
|
|
67
|
+
if (displayMode === 'time') {
|
|
71
68
|
if (displayAsRange) {
|
|
72
69
|
let maxMinutes = Math.max(1, Math.round(totalWords / averageReadingSpeed * 1.2));
|
|
73
70
|
const minMinutes = Math.max(1, Math.round(totalWords / averageReadingSpeed * 0.8));
|
|
@@ -76,28 +73,20 @@ function PostTimeToReadEdit({
|
|
|
76
73
|
}
|
|
77
74
|
// translators: %1$s: minimum minutes, %2$s: maximum minutes to read the post.
|
|
78
75
|
const rangeLabel = _x('%1$s–%2$s minutes', 'Range of minutes to read');
|
|
79
|
-
|
|
80
|
-
} else {
|
|
81
|
-
const minutesToRead = Math.max(1, Math.round(totalWords / averageReadingSpeed));
|
|
82
|
-
timeString = sprintf(/* translators: %s: the number of minutes to read the post. */
|
|
83
|
-
_n('%s minute', '%s minutes', minutesToRead), minutesToRead);
|
|
76
|
+
return sprintf(rangeLabel, minMinutes, maxMinutes);
|
|
84
77
|
}
|
|
85
|
-
|
|
78
|
+
const minutesToRead = Math.max(1, Math.round(totalWords / averageReadingSpeed));
|
|
79
|
+
return sprintf(/* translators: %s: the number of minutes to read the post. */
|
|
80
|
+
_n('%s minute', '%s minutes', minutesToRead), minutesToRead);
|
|
86
81
|
}
|
|
87
82
|
|
|
88
83
|
// Add "word count" part, if enabled.
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
_n('%s word', '%s words', totalWords), totalWords.toLocaleString())
|
|
92
|
-
|
|
84
|
+
if (displayMode === 'words') {
|
|
85
|
+
return wordCountType === 'words' ? sprintf(/* translators: %s: the number of words in the post. */
|
|
86
|
+
_n('%s word', '%s words', totalWords), totalWords.toLocaleString()) : sprintf(/* translators: %s: the number of characters in the post. */
|
|
87
|
+
_n('%s character', '%s characters', totalWords), totalWords.toLocaleString());
|
|
93
88
|
}
|
|
94
|
-
|
|
95
|
-
return parts[0];
|
|
96
|
-
}
|
|
97
|
-
return parts.map((part, index) => /*#__PURE__*/_jsxs("span", {
|
|
98
|
-
children: [part, index < parts.length - 1 && /*#__PURE__*/_jsx("br", {})]
|
|
99
|
-
}, index));
|
|
100
|
-
}, [contentStructure, blocks, displayAsRange, showTimeToRead, showWordCount, averageReadingSpeed]);
|
|
89
|
+
}, [contentStructure, blocks, displayAsRange, displayMode, averageReadingSpeed]);
|
|
101
90
|
const blockProps = useBlockProps({
|
|
102
91
|
className: clsx({
|
|
103
92
|
[`has-text-align-${textAlign}`]: textAlign
|
|
@@ -114,34 +103,16 @@ function PostTimeToReadEdit({
|
|
|
114
103
|
});
|
|
115
104
|
}
|
|
116
105
|
})
|
|
117
|
-
}), /*#__PURE__*/_jsx(InspectorControls, {
|
|
118
|
-
children: /*#__PURE__*/
|
|
106
|
+
}), displayMode === 'time' && /*#__PURE__*/_jsx(InspectorControls, {
|
|
107
|
+
children: /*#__PURE__*/_jsx(ToolsPanel, {
|
|
119
108
|
label: __('Settings'),
|
|
120
109
|
resetAll: () => {
|
|
121
110
|
setAttributes({
|
|
122
|
-
displayAsRange: true
|
|
123
|
-
showTimeToRead: true,
|
|
124
|
-
showWordCount: false
|
|
111
|
+
displayAsRange: true
|
|
125
112
|
});
|
|
126
113
|
},
|
|
127
114
|
dropdownMenuProps: dropdownMenuProps,
|
|
128
|
-
children:
|
|
129
|
-
label: __('Show time to read'),
|
|
130
|
-
hasValue: () => !showTimeToRead,
|
|
131
|
-
onDeselect: () => {
|
|
132
|
-
setAttributes({
|
|
133
|
-
showTimeToRead: true
|
|
134
|
-
});
|
|
135
|
-
},
|
|
136
|
-
children: /*#__PURE__*/_jsx(ToggleControl, {
|
|
137
|
-
__nextHasNoMarginBottom: true,
|
|
138
|
-
label: __('Show time to read'),
|
|
139
|
-
checked: !!showTimeToRead,
|
|
140
|
-
onChange: () => setAttributes({
|
|
141
|
-
showTimeToRead: !showTimeToRead
|
|
142
|
-
})
|
|
143
|
-
})
|
|
144
|
-
}), showTimeToRead && /*#__PURE__*/_jsx(ToolsPanelItem, {
|
|
115
|
+
children: /*#__PURE__*/_jsx(ToolsPanelItem, {
|
|
145
116
|
isShownByDefault: true,
|
|
146
117
|
label: _x('Display as range', 'Turns reading time range display on or off'),
|
|
147
118
|
hasValue: () => !displayAsRange,
|
|
@@ -158,23 +129,7 @@ function PostTimeToReadEdit({
|
|
|
158
129
|
displayAsRange: !displayAsRange
|
|
159
130
|
})
|
|
160
131
|
})
|
|
161
|
-
})
|
|
162
|
-
label: __('Show word count'),
|
|
163
|
-
hasValue: () => !!showWordCount,
|
|
164
|
-
onDeselect: () => {
|
|
165
|
-
setAttributes({
|
|
166
|
-
showWordCount: false
|
|
167
|
-
});
|
|
168
|
-
},
|
|
169
|
-
children: /*#__PURE__*/_jsx(ToggleControl, {
|
|
170
|
-
__nextHasNoMarginBottom: true,
|
|
171
|
-
label: __('Show word count'),
|
|
172
|
-
checked: !!showWordCount,
|
|
173
|
-
onChange: () => setAttributes({
|
|
174
|
-
showWordCount: !showWordCount
|
|
175
|
-
})
|
|
176
|
-
})
|
|
177
|
-
})]
|
|
132
|
+
})
|
|
178
133
|
})
|
|
179
134
|
}), /*#__PURE__*/_jsx("div", {
|
|
180
135
|
...blockProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","__","_x","_n","sprintf","useMemo","AlignmentControl","BlockControls","InspectorControls","useBlockProps","ToggleControl","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__unstableSerializeAndClean","useEntityProp","useEntityBlockEditor","count","wordCount","useToolsPanelDropdownMenuProps","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","PostTimeToReadEdit","attributes","setAttributes","context","textAlign","displayAsRange","showTimeToRead","showWordCount","averageReadingSpeed","postId","postType","dropdownMenuProps","contentStructure","blocks","id","displayString","content","Function","wordCountType","totalWords","parts","timeString","maxMinutes","Math","max","round","minMinutes","rangeLabel","minutesToRead","push","wordCountString","toLocaleString","length","map","part","index","children","blockProps","className","group","value","onChange","nextAlign","label","resetAll","hasValue","onDeselect","__nextHasNoMarginBottom","checked","isShownByDefault"],"sources":["@wordpress/block-library/src/post-time-to-read/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { useEntityProp, useEntityBlockEditor } from '@wordpress/core-data';\nimport { count as wordCount } from '@wordpress/wordcount';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nfunction PostTimeToReadEdit( { attributes, setAttributes, context } ) {\n\tconst {\n\t\ttextAlign,\n\t\tdisplayAsRange,\n\t\tshowTimeToRead,\n\t\tshowWordCount,\n\t\taverageReadingSpeed,\n\t} = attributes;\n\n\tconst { postId, postType } = context;\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst [ contentStructure ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\tconst displayString = useMemo( () => {\n\t\t// Replicates the logic found in getEditedPostContent().\n\t\tlet content;\n\t\tif ( contentStructure instanceof Function ) {\n\t\t\tcontent = contentStructure( { blocks } );\n\t\t} else if ( blocks ) {\n\t\t\t// If we have parsed blocks already, they should be our source of truth.\n\t\t\t// Parsing applies block deprecations and legacy block conversions that\n\t\t\t// unparsed content will not have.\n\t\t\tcontent = __unstableSerializeAndClean( blocks );\n\t\t} else {\n\t\t\tcontent = contentStructure;\n\t\t}\n\n\t\t/*\n\t\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t\t * Do not translate into your own language.\n\t\t */\n\t\tconst wordCountType = _x(\n\t\t\t'words',\n\t\t\t'Word count type. Do not translate!'\n\t\t);\n\n\t\tconst totalWords = wordCount( content || '', wordCountType );\n\n\t\tconst parts = [];\n\n\t\t// Add \"time to read\" part, if enabled.\n\t\tif ( showTimeToRead ) {\n\t\t\tlet timeString;\n\t\t\tif ( displayAsRange ) {\n\t\t\t\tlet maxMinutes = Math.max(\n\t\t\t\t\t1,\n\t\t\t\t\tMath.round( ( totalWords / averageReadingSpeed ) * 1.2 )\n\t\t\t\t);\n\t\t\t\tconst minMinutes = Math.max(\n\t\t\t\t\t1,\n\t\t\t\t\tMath.round( ( totalWords / averageReadingSpeed ) * 0.8 )\n\t\t\t\t);\n\n\t\t\t\tif ( minMinutes === maxMinutes ) {\n\t\t\t\t\tmaxMinutes = maxMinutes + 1;\n\t\t\t\t}\n\t\t\t\t// translators: %1$s: minimum minutes, %2$s: maximum minutes to read the post.\n\t\t\t\tconst rangeLabel = _x(\n\t\t\t\t\t'%1$s–%2$s minutes',\n\t\t\t\t\t'Range of minutes to read'\n\t\t\t\t);\n\t\t\t\ttimeString = sprintf( rangeLabel, minMinutes, maxMinutes );\n\t\t\t} else {\n\t\t\t\tconst minutesToRead = Math.max(\n\t\t\t\t\t1,\n\t\t\t\t\tMath.round( totalWords / averageReadingSpeed )\n\t\t\t\t);\n\n\t\t\t\ttimeString = sprintf(\n\t\t\t\t\t/* translators: %s: the number of minutes to read the post. */\n\t\t\t\t\t_n( '%s minute', '%s minutes', minutesToRead ),\n\t\t\t\t\tminutesToRead\n\t\t\t\t);\n\t\t\t}\n\t\t\tparts.push( timeString );\n\t\t}\n\n\t\t// Add \"word count\" part, if enabled.\n\t\tif ( showWordCount ) {\n\t\t\tconst wordCountString = sprintf(\n\t\t\t\t/* translators: %s: the number of words in the post. */\n\t\t\t\t_n( '%s word', '%s words', totalWords ),\n\t\t\t\ttotalWords.toLocaleString()\n\t\t\t);\n\t\t\tparts.push( wordCountString );\n\t\t}\n\n\t\tif ( parts.length === 1 ) {\n\t\t\treturn parts[ 0 ];\n\t\t}\n\t\treturn parts.map( ( part, index ) => (\n\t\t\t<span key={ index }>\n\t\t\t\t{ part }\n\t\t\t\t{ index < parts.length - 1 && <br /> }\n\t\t\t</span>\n\t\t) );\n\t}, [\n\t\tcontentStructure,\n\t\tblocks,\n\t\tdisplayAsRange,\n\t\tshowTimeToRead,\n\t\tshowWordCount,\n\t\taverageReadingSpeed,\n\t] );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tdisplayAsRange: true,\n\t\t\t\t\t\t\tshowTimeToRead: true,\n\t\t\t\t\t\t\tshowWordCount: false,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show time to read' ) }\n\t\t\t\t\t\thasValue={ () => ! showTimeToRead }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowTimeToRead: true,\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\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show time to read' ) }\n\t\t\t\t\t\t\tchecked={ !! showTimeToRead }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowTimeToRead: ! showTimeToRead,\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</ToolsPanelItem>\n\t\t\t\t\t{ showTimeToRead && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Display as range',\n\t\t\t\t\t\t\t\t'Turns reading time range display on or off'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\thasValue={ () => ! displayAsRange }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tdisplayAsRange: true,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Display as range' ) }\n\t\t\t\t\t\t\t\tchecked={ !! displayAsRange }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tdisplayAsRange: ! displayAsRange,\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</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show word count' ) }\n\t\t\t\t\t\thasValue={ () => !! showWordCount }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowWordCount: false,\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\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show word count' ) }\n\t\t\t\t\t\t\tchecked={ !! showWordCount }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowWordCount: ! showWordCount,\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</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>{ displayString }</div>\n\t\t</>\n\t);\n}\n\nexport default PostTimeToReadEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,E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AE,iBAAkB,CAAG;UACjCuE,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAEtC,aAAe;UACnCuC,UAAU,EAAGA,CAAA,KAAM;YAClB5C,aAAa,CAAE;cACdK,aAAa,EAAE;YAChB,CAAE,CAAC;UACJ,CAAG;UAAA6B,QAAA,eAEHzC,IAAA,CAACZ,aAAa;YACbgE,uBAAuB;YACvBJ,KAAK,EAAGrE,EAAE,CAAE,iBAAkB,CAAG;YACjC0E,OAAO,EAAG,CAAC,CAAEzC,aAAe;YAC5BkC,QAAQ,EAAGA,CAAA,KACVvC,aAAa,CAAE;cACdK,aAAa,EAAE,CAAEA;YAClB,CAAE;UACF,CACD;QAAC,CACa,CAAC;MAAA,CACN;IAAC,CACK,CAAC,eACpBZ,IAAA;MAAA,GAAU0C,UAAU;MAAAD,QAAA,EAAKrB;IAAa,CAAO,CAAC;EAAA,CAC7C,CAAC;AAEL;AAEA,eAAef,kBAAkB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","__","_x","_n","sprintf","useMemo","AlignmentControl","BlockControls","InspectorControls","useBlockProps","ToggleControl","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__unstableSerializeAndClean","useEntityProp","useEntityBlockEditor","count","wordCount","useToolsPanelDropdownMenuProps","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PostTimeToReadEdit","attributes","setAttributes","context","textAlign","displayAsRange","displayMode","averageReadingSpeed","postId","postType","dropdownMenuProps","contentStructure","blocks","id","displayString","content","Function","wordCountType","totalWords","maxMinutes","Math","max","round","minMinutes","rangeLabel","minutesToRead","toLocaleString","blockProps","className","children","group","value","onChange","nextAlign","label","resetAll","isShownByDefault","hasValue","onDeselect","__nextHasNoMarginBottom","checked"],"sources":["@wordpress/block-library/src/post-time-to-read/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { useEntityProp, useEntityBlockEditor } from '@wordpress/core-data';\nimport { count as wordCount } from '@wordpress/wordcount';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nfunction PostTimeToReadEdit( { attributes, setAttributes, context } ) {\n\tconst { textAlign, displayAsRange, displayMode, averageReadingSpeed } =\n\t\tattributes;\n\n\tconst { postId, postType } = context;\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst [ contentStructure ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\tconst displayString = useMemo( () => {\n\t\t// Replicates the logic found in getEditedPostContent().\n\t\tlet content;\n\t\tif ( contentStructure instanceof Function ) {\n\t\t\tcontent = contentStructure( { blocks } );\n\t\t} else if ( blocks ) {\n\t\t\t// If we have parsed blocks already, they should be our source of truth.\n\t\t\t// Parsing applies block deprecations and legacy block conversions that\n\t\t\t// unparsed content will not have.\n\t\t\tcontent = __unstableSerializeAndClean( blocks );\n\t\t} else {\n\t\t\tcontent = contentStructure;\n\t\t}\n\n\t\t/*\n\t\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t\t * Do not translate into your own language.\n\t\t */\n\t\tconst wordCountType = _x(\n\t\t\t'words',\n\t\t\t'Word count type. Do not translate!'\n\t\t);\n\n\t\tconst totalWords = wordCount( content || '', wordCountType );\n\n\t\t// Add \"time to read\" part, if enabled.\n\t\tif ( displayMode === 'time' ) {\n\t\t\tif ( displayAsRange ) {\n\t\t\t\tlet maxMinutes = Math.max(\n\t\t\t\t\t1,\n\t\t\t\t\tMath.round( ( totalWords / averageReadingSpeed ) * 1.2 )\n\t\t\t\t);\n\t\t\t\tconst minMinutes = Math.max(\n\t\t\t\t\t1,\n\t\t\t\t\tMath.round( ( totalWords / averageReadingSpeed ) * 0.8 )\n\t\t\t\t);\n\n\t\t\t\tif ( minMinutes === maxMinutes ) {\n\t\t\t\t\tmaxMinutes = maxMinutes + 1;\n\t\t\t\t}\n\t\t\t\t// translators: %1$s: minimum minutes, %2$s: maximum minutes to read the post.\n\t\t\t\tconst rangeLabel = _x(\n\t\t\t\t\t'%1$s–%2$s minutes',\n\t\t\t\t\t'Range of minutes to read'\n\t\t\t\t);\n\t\t\t\treturn sprintf( rangeLabel, minMinutes, maxMinutes );\n\t\t\t}\n\t\t\tconst minutesToRead = Math.max(\n\t\t\t\t1,\n\t\t\t\tMath.round( totalWords / averageReadingSpeed )\n\t\t\t);\n\n\t\t\treturn sprintf(\n\t\t\t\t/* translators: %s: the number of minutes to read the post. */\n\t\t\t\t_n( '%s minute', '%s minutes', minutesToRead ),\n\t\t\t\tminutesToRead\n\t\t\t);\n\t\t}\n\n\t\t// Add \"word count\" part, if enabled.\n\t\tif ( displayMode === 'words' ) {\n\t\t\treturn wordCountType === 'words'\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: the number of words in the post. */\n\t\t\t\t\t\t_n( '%s word', '%s words', totalWords ),\n\t\t\t\t\t\ttotalWords.toLocaleString()\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: the number of characters in the post. */\n\t\t\t\t\t\t_n( '%s character', '%s characters', totalWords ),\n\t\t\t\t\t\ttotalWords.toLocaleString()\n\t\t\t\t );\n\t\t}\n\t}, [\n\t\tcontentStructure,\n\t\tblocks,\n\t\tdisplayAsRange,\n\t\tdisplayMode,\n\t\taverageReadingSpeed,\n\t] );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t{ displayMode === 'time' && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdisplayAsRange: true,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Display as range',\n\t\t\t\t\t\t\t\t'Turns reading time range display on or off'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\thasValue={ () => ! displayAsRange }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tdisplayAsRange: true,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Display as range' ) }\n\t\t\t\t\t\t\t\tchecked={ !! displayAsRange }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tdisplayAsRange: ! displayAsRange,\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</ToolsPanelItem>\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<div { ...blockProps }>{ displayString }</div>\n\t\t</>\n\t);\n}\n\nexport default PostTimeToReadEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACrD,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SACCC,gBAAgB,EAChBC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,QACP,yBAAyB;AAChC,SACCC,aAAa,EACbC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,2BAA2B,QAAQ,mBAAmB;AAC/D,SAASC,aAAa,EAAEC,oBAAoB,QAAQ,sBAAsB;AAC1E,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASC,8BAA8B,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAEhE,SAASC,kBAAkBA,CAAE;EAAEC,UAAU;EAAEC,aAAa;EAAEC;AAAQ,CAAC,EAAG;EACrE,MAAM;IAAEC,SAAS;IAAEC,cAAc;IAAEC,WAAW;IAAEC;EAAoB,CAAC,GACpEN,UAAU;EAEX,MAAM;IAAEO,MAAM;IAAEC;EAAS,CAAC,GAAGN,OAAO;EACpC,MAAMO,iBAAiB,GAAGjB,8BAA8B,CAAC,CAAC;EAE1D,MAAM,CAAEkB,gBAAgB,CAAE,GAA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EAAE,CAAE,UAAW,CAAG;QAC1B6D,QAAQ,EAAGA,CAAA,KAAM;UAChBjC,aAAa,CAAE;YACdG,cAAc,EAAE;UACjB,CAAE,CAAC;QACJ,CAAG;QACHK,iBAAiB,EAAGA,iBAAmB;QAAAmB,QAAA,eAEvClC,IAAA,CAACR,cAAc;UACdiD,gBAAgB;UAChBF,KAAK,EAAG3D,EAAE,CACT,kBAAkB,EAClB,4CACD,CAAG;UACH8D,QAAQ,EAAGA,CAAA,KAAM,CAAEhC,cAAgB;UACnCiC,UAAU,EAAGA,CAAA,KAAM;YAClBpC,aAAa,CAAE;cACdG,cAAc,EAAE;YACjB,CAAE,CAAC;UACJ,CAAG;UAAAwB,QAAA,eAEHlC,IAAA,CAACZ,aAAa;YACbwD,uBAAuB;YACvBL,KAAK,EAAG5D,EAAE,CAAE,kBAAmB,CAAG;YAClCkE,OAAO,EAAG,CAAC,CAAEnC,cAAgB;YAC7B2B,QAAQ,EAAGA,CAAA,KACV9B,aAAa,CAAE;cACdG,cAAc,EAAE,CAAEA;YACnB,CAAE;UACF,CACD;QAAC,CACa;MAAC,CACN;IAAC,CACK,CACnB,eACDV,IAAA;MAAA,GAAUgC,UAAU;MAAAE,QAAA,EAAKf;IAAa,CAAO,CAAC;EAAA,CAC7C,CAAC;AAEL;AAEA,eAAed,kBAAkB","ignoreList":[]}
|
|
@@ -20,13 +20,9 @@ const metadata = {
|
|
|
20
20
|
type: "boolean",
|
|
21
21
|
"default": true
|
|
22
22
|
},
|
|
23
|
-
|
|
24
|
-
type: "
|
|
25
|
-
"default":
|
|
26
|
-
},
|
|
27
|
-
showWordCount: {
|
|
28
|
-
type: "boolean",
|
|
29
|
-
"default": false
|
|
23
|
+
displayMode: {
|
|
24
|
+
type: "string",
|
|
25
|
+
"default": "time"
|
|
30
26
|
},
|
|
31
27
|
averageReadingSpeed: {
|
|
32
28
|
type: "number",
|
|
@@ -76,6 +72,7 @@ const metadata = {
|
|
|
76
72
|
};
|
|
77
73
|
import edit from './edit';
|
|
78
74
|
import icon from './icon';
|
|
75
|
+
import variations from './variations';
|
|
79
76
|
const {
|
|
80
77
|
name
|
|
81
78
|
} = metadata;
|
|
@@ -83,6 +80,7 @@ export { metadata, name };
|
|
|
83
80
|
export const settings = {
|
|
84
81
|
icon,
|
|
85
82
|
edit,
|
|
83
|
+
variations,
|
|
86
84
|
example: {}
|
|
87
85
|
};
|
|
88
86
|
export const init = () => initBlock({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["initBlock","metadata","$schema","apiVersion","__experimental","name","title","category","description","textdomain","usesContext","attributes","textAlign","type","displayAsRange","
|
|
1
|
+
{"version":3,"names":["initBlock","metadata","$schema","apiVersion","__experimental","name","title","category","description","textdomain","usesContext","attributes","textAlign","type","displayAsRange","displayMode","averageReadingSpeed","supports","color","gradients","__experimentalDefaultControls","background","text","html","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","interactivity","clientNavigation","__experimentalBorder","radius","width","style","edit","icon","variations","settings","example","init"],"sources":["@wordpress/block-library/src/post-time-to-read/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport icon from './icon';\nimport variations from './variations';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tvariations,\n\texample: {},\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,cAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,WAAA;EAAAC,UAAA;IAAAC,SAAA;MAAAC,IAAA;IAAA;IAAAC,cAAA;MAAAD,IAAA;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: 'time-to-read',
|
|
12
|
+
title: __('Time to Read'),
|
|
13
|
+
description: __('Show minutes required to finish reading the post.'),
|
|
14
|
+
attributes: {
|
|
15
|
+
displayMode: 'time'
|
|
16
|
+
},
|
|
17
|
+
scope: ['inserter', 'transform'],
|
|
18
|
+
isActive: blockAttributes => blockAttributes?.displayMode === 'time',
|
|
19
|
+
icon,
|
|
20
|
+
isDefault: true
|
|
21
|
+
}, {
|
|
22
|
+
name: 'word-count',
|
|
23
|
+
title: __('Word Count'),
|
|
24
|
+
description: __('Show the number of words in the post.'),
|
|
25
|
+
attributes: {
|
|
26
|
+
displayMode: 'words'
|
|
27
|
+
},
|
|
28
|
+
scope: ['inserter', 'transform'],
|
|
29
|
+
isActive: blockAttributes => blockAttributes?.displayMode === 'words',
|
|
30
|
+
icon
|
|
31
|
+
}];
|
|
32
|
+
export default variations;
|
|
33
|
+
//# sourceMappingURL=variations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__","icon","variations","name","title","description","attributes","displayMode","scope","isActive","blockAttributes","isDefault"],"sources":["@wordpress/block-library/src/post-time-to-read/variations.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport icon from './icon';\n\nconst variations = [\n\t{\n\t\tname: 'time-to-read',\n\t\ttitle: __( 'Time to Read' ),\n\t\tdescription: __( 'Show minutes required to finish reading the post.' ),\n\t\tattributes: {\n\t\t\tdisplayMode: 'time',\n\t\t},\n\t\tscope: [ 'inserter', 'transform' ],\n\t\tisActive: ( blockAttributes ) =>\n\t\t\tblockAttributes?.displayMode === 'time',\n\t\ticon,\n\t\tisDefault: true,\n\t},\n\t{\n\t\tname: 'word-count',\n\t\ttitle: __( 'Word Count' ),\n\t\tdescription: __( 'Show the number of words in the post.' ),\n\t\tattributes: {\n\t\t\tdisplayMode: 'words',\n\t\t},\n\t\tscope: [ 'inserter', 'transform' ],\n\t\tisActive: ( blockAttributes ) =>\n\t\t\tblockAttributes?.displayMode === 'words',\n\t\ticon,\n\t},\n];\n\nexport default variations;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,IAAI,MAAM,QAAQ;AAEzB,MAAMC,UAAU,GAAG,CAClB;EACCC,IAAI,EAAE,cAAc;EACpBC,KAAK,EAAEJ,EAAE,CAAE,cAAe,CAAC;EAC3BK,WAAW,EAAEL,EAAE,CAAE,mDAAoD,CAAC;EACtEM,UAAU,EAAE;IACXC,WAAW,EAAE;EACd,CAAC;EACDC,KAAK,EAAE,CAAE,UAAU,EAAE,WAAW,CAAE;EAClCC,QAAQ,EAAIC,eAAe,IAC1BA,eAAe,EAAEH,WAAW,KAAK,MAAM;EACxCN,IAAI;EACJU,SAAS,EAAE;AACZ,CAAC,EACD;EACCR,IAAI,EAAE,YAAY;EAClBC,KAAK,EAAEJ,EAAE,CAAE,YAAa,CAAC;EACzBK,WAAW,EAAEL,EAAE,CAAE,uCAAwC,CAAC;EAC1DM,UAAU,EAAE;IACXC,WAAW,EAAE;EACd,CAAC;EACDC,KAAK,EAAE,CAAE,UAAU,EAAE,WAAW,CAAE;EAClCC,QAAQ,EAAIC,eAAe,IAC1BA,eAAe,EAAEH,WAAW,KAAK,OAAO;EACzCN;AACD,CAAC,CACD;AAED,eAAeC,UAAU","ignoreList":[]}
|
|
@@ -40,7 +40,7 @@ export default function QueryTitleEdit({
|
|
|
40
40
|
postTypeLabel
|
|
41
41
|
} = usePostTypeLabel(query?.postType);
|
|
42
42
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
43
|
-
const TagName = `h${level}`;
|
|
43
|
+
const TagName = level === 0 ? 'p' : `h${level}`;
|
|
44
44
|
const blockProps = useBlockProps({
|
|
45
45
|
className: clsx('wp-block-query-title__placeholder', {
|
|
46
46
|
[`has-text-align-${textAlign}`]: textAlign
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","AlignmentControl","BlockControls","InspectorControls","useBlockProps","Warning","HeadingLevelDropdown","ToggleControl","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__","_x","sprintf","useArchiveLabel","usePostTypeLabel","useToolsPanelDropdownMenuProps","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SUPPORTED_TYPES","QueryTitleEdit","attributes","type","level","levelOptions","textAlign","showPrefix","showSearchTerm","setAttributes","context","query","archiveTypeLabel","archiveNameLabel","postTypeLabel","postType","dropdownMenuProps","TagName","blockProps","className","includes","children","titleElement","title","label","resetAll","hasValue","onDeselect","isShownByDefault","__nextHasNoMarginBottom","onChange","checked","group","value","options","newLevel","nextAlign"],"sources":["@wordpress/block-library/src/query-title/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tWarning,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useArchiveLabel } from './use-archive-label';\nimport { usePostTypeLabel } from './use-post-type-label';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst SUPPORTED_TYPES = [ 'archive', 'search', 'post-type' ];\n\nexport default function QueryTitleEdit( {\n\tattributes: {\n\t\ttype,\n\t\tlevel,\n\t\tlevelOptions,\n\t\ttextAlign,\n\t\tshowPrefix,\n\t\tshowSearchTerm,\n\t},\n\tsetAttributes,\n\tcontext: { query },\n} ) {\n\tconst { archiveTypeLabel, archiveNameLabel } = useArchiveLabel();\n\tconst { postTypeLabel } = usePostTypeLabel( query?.postType );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst TagName = `h${ level }`;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( 'wp-block-query-title__placeholder', {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tif ( ! SUPPORTED_TYPES.includes( type ) ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>{ __( 'Provided type is not supported.' ) }</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tlet titleElement;\n\tif ( type === 'archive' ) {\n\t\tlet title;\n\t\tif ( archiveTypeLabel ) {\n\t\t\tif ( showPrefix ) {\n\t\t\t\tif ( archiveNameLabel ) {\n\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t/* translators: 1: Archive type title e.g: \"Category\", 2: Label of the archive e.g: \"Shoes\" */\n\t\t\t\t\t\t_x( '%1$s: %2$s', 'archive label' ),\n\t\t\t\t\t\tarchiveTypeLabel,\n\t\t\t\t\t\tarchiveNameLabel\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t/* translators: %s: Archive type title e.g: \"Category\", \"Tag\"... */\n\t\t\t\t\t\t__( '%s: Name' ),\n\t\t\t\t\t\tarchiveTypeLabel\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if ( archiveNameLabel ) {\n\t\t\t\ttitle = archiveNameLabel;\n\t\t\t} else {\n\t\t\t\ttitle = sprintf(\n\t\t\t\t\t/* translators: %s: Archive type title e.g: \"Category\", \"Tag\"... */\n\t\t\t\t\t__( '%s name' ),\n\t\t\t\t\tarchiveTypeLabel\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\ttitle = showPrefix\n\t\t\t\t? __( 'Archive type: Name' )\n\t\t\t\t: __( 'Archive title' );\n\t\t}\n\n\t\ttitleElement = (\n\t\t\t<>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowPrefix: true,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => ! showPrefix }\n\t\t\t\t\t\t\tlabel={ __( 'Show archive type in title' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showPrefix: true } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Show archive type in title' ) }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tshowPrefix: ! showPrefix,\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\tchecked={ showPrefix }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t\t<TagName { ...blockProps }>{ title }</TagName>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( type === 'search' ) {\n\t\ttitleElement = (\n\t\t\t<>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowSearchTerm: true,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => ! showSearchTerm }\n\t\t\t\t\t\t\tlabel={ __( 'Show search term in title' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showSearchTerm: true } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Show search term in title' ) }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tshowSearchTerm: ! showSearchTerm,\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\tchecked={ showSearchTerm }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t{ showSearchTerm\n\t\t\t\t\t\t? __( 'Search results for: “search term”' )\n\t\t\t\t\t\t: __( 'Search results' ) }\n\t\t\t\t</TagName>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( type === 'post-type' ) {\n\t\tlet title;\n\t\tif ( postTypeLabel ) {\n\t\t\tif ( showPrefix ) {\n\t\t\t\ttitle = sprintf(\n\t\t\t\t\t/* translators: %s: Singular post type name of the queried object */\n\t\t\t\t\t__( 'Post Type: \"%s\"' ),\n\t\t\t\t\tpostTypeLabel\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\ttitle = postTypeLabel;\n\t\t\t}\n\t\t} else {\n\t\t\ttitle = showPrefix ? __( 'Post Type: Name' ) : __( 'Name' );\n\t\t}\n\n\t\ttitleElement = (\n\t\t\t<>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowPrefix: true,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => ! showPrefix }\n\t\t\t\t\t\t\tlabel={ __( 'Show post type label' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showPrefix: true } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Show post type label' ) }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tshowPrefix: ! showPrefix,\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\tchecked={ showPrefix }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t\t<TagName { ...blockProps }>{ title }</TagName>\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\tvalue={ level }\n\t\t\t\t\toptions={ levelOptions }\n\t\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\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E,sBAAuB,CAAG;YACtCuC,UAAU,EAAGA,CAAA,KACZlB,aAAa,CAAE;cAAEF,UAAU,EAAE;YAAK,CAAE,CACpC;YACDqB,gBAAgB;YAAAP,QAAA,eAEhB1B,IAAA,CAACZ,aAAa;cACb8C,uBAAuB;cACvBL,KAAK,EAAGpC,EAAE,CAAE,sBAAuB,CAAG;cACtC0C,QAAQ,EAAGA,CAAA,KACVrB,aAAa,CAAE;gBACdF,UAAU,EAAE,CAAEA;cACf,CAAE,CACF;cACDwB,OAAO,EAAGxB;YAAY,CACtB;UAAC,CACa;QAAC,CACN;MAAC,CACK,CAAC,eACpBZ,IAAA,CAACsB,OAAO;QAAA,GAAMC,UAAU;QAAAG,QAAA,EAAKE;MAAK,CAAW,CAAC;IAAA,CAC7C,CACF;EACF;EAEA,oBACCxB,KAAA,CAAAF,SAAA;IAAAwB,QAAA,gBACCtB,KAAA,CAACrB,aAAa;MAACsD,KAAK,EAAC,OAAO;MAAAX,QAAA,gBAC3B1B,IAAA,CAACb,oBAAoB;QACpBmD,KAAK,EAAG7B,KAAO;QACf8B,OAAO,EAAG7B,YAAc;QACxByB,QAAQ,EAAKK,QAAQ,IACpB1B,aAAa,CAAE;UAAEL,KAAK,EAAE+B;QAAS,CAAE;MACnC,CACD,CAAC,eACFxC,IAAA,CAAClB,gBAAgB;QAChBwD,KAAK,EAAG3B,SAAW;QACnBwB,QAAQ,EAAKM,SAAS,IAAM;UAC3B3B,aAAa,CAAE;YAAEH,SAAS,EAAE8B;UAAU,CAAE,CAAC;QAC1C;MAAG,CACH,CAAC;IAAA,CACY,CAAC,EACdd,YAAY;EAAA,CACb,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","AlignmentControl","BlockControls","InspectorControls","useBlockProps","Warning","HeadingLevelDropdown","ToggleControl","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__","_x","sprintf","useArchiveLabel","usePostTypeLabel","useToolsPanelDropdownMenuProps","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SUPPORTED_TYPES","QueryTitleEdit","attributes","type","level","levelOptions","textAlign","showPrefix","showSearchTerm","setAttributes","context","query","archiveTypeLabel","archiveNameLabel","postTypeLabel","postType","dropdownMenuProps","TagName","blockProps","className","includes","children","titleElement","title","label","resetAll","hasValue","onDeselect","isShownByDefault","__nextHasNoMarginBottom","onChange","checked","group","value","options","newLevel","nextAlign"],"sources":["@wordpress/block-library/src/query-title/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tWarning,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useArchiveLabel } from './use-archive-label';\nimport { usePostTypeLabel } from './use-post-type-label';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst SUPPORTED_TYPES = [ 'archive', 'search', 'post-type' ];\n\nexport default function QueryTitleEdit( {\n\tattributes: {\n\t\ttype,\n\t\tlevel,\n\t\tlevelOptions,\n\t\ttextAlign,\n\t\tshowPrefix,\n\t\tshowSearchTerm,\n\t},\n\tsetAttributes,\n\tcontext: { query },\n} ) {\n\tconst { archiveTypeLabel, archiveNameLabel } = useArchiveLabel();\n\tconst { postTypeLabel } = usePostTypeLabel( query?.postType );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst TagName = level === 0 ? 'p' : `h${ level }`;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( 'wp-block-query-title__placeholder', {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tif ( ! SUPPORTED_TYPES.includes( type ) ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>{ __( 'Provided type is not supported.' ) }</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tlet titleElement;\n\tif ( type === 'archive' ) {\n\t\tlet title;\n\t\tif ( archiveTypeLabel ) {\n\t\t\tif ( showPrefix ) {\n\t\t\t\tif ( archiveNameLabel ) {\n\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t/* translators: 1: Archive type title e.g: \"Category\", 2: Label of the archive e.g: \"Shoes\" */\n\t\t\t\t\t\t_x( '%1$s: %2$s', 'archive label' ),\n\t\t\t\t\t\tarchiveTypeLabel,\n\t\t\t\t\t\tarchiveNameLabel\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t/* translators: %s: Archive type title e.g: \"Category\", \"Tag\"... */\n\t\t\t\t\t\t__( '%s: Name' ),\n\t\t\t\t\t\tarchiveTypeLabel\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if ( archiveNameLabel ) {\n\t\t\t\ttitle = archiveNameLabel;\n\t\t\t} else {\n\t\t\t\ttitle = sprintf(\n\t\t\t\t\t/* translators: %s: Archive type title e.g: \"Category\", \"Tag\"... */\n\t\t\t\t\t__( '%s name' ),\n\t\t\t\t\tarchiveTypeLabel\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\ttitle = showPrefix\n\t\t\t\t? __( 'Archive type: Name' )\n\t\t\t\t: __( 'Archive title' );\n\t\t}\n\n\t\ttitleElement = (\n\t\t\t<>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowPrefix: true,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => ! showPrefix }\n\t\t\t\t\t\t\tlabel={ __( 'Show archive type in title' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showPrefix: true } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Show archive type in title' ) }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tshowPrefix: ! showPrefix,\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\tchecked={ showPrefix }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t\t<TagName { ...blockProps }>{ title }</TagName>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( type === 'search' ) {\n\t\ttitleElement = (\n\t\t\t<>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowSearchTerm: true,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => ! showSearchTerm }\n\t\t\t\t\t\t\tlabel={ __( 'Show search term in title' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showSearchTerm: true } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Show search term in title' ) }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tshowSearchTerm: ! showSearchTerm,\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\tchecked={ showSearchTerm }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t{ showSearchTerm\n\t\t\t\t\t\t? __( 'Search results for: “search term”' )\n\t\t\t\t\t\t: __( 'Search results' ) }\n\t\t\t\t</TagName>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( type === 'post-type' ) {\n\t\tlet title;\n\t\tif ( postTypeLabel ) {\n\t\t\tif ( showPrefix ) {\n\t\t\t\ttitle = sprintf(\n\t\t\t\t\t/* translators: %s: Singular post type name of the queried object */\n\t\t\t\t\t__( 'Post Type: \"%s\"' ),\n\t\t\t\t\tpostTypeLabel\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\ttitle = postTypeLabel;\n\t\t\t}\n\t\t} else {\n\t\t\ttitle = showPrefix ? __( 'Post Type: Name' ) : __( 'Name' );\n\t\t}\n\n\t\ttitleElement = (\n\t\t\t<>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowPrefix: true,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => ! showPrefix }\n\t\t\t\t\t\t\tlabel={ __( 'Show post type label' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showPrefix: true } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Show post type label' ) }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tshowPrefix: ! showPrefix,\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\tchecked={ showPrefix }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t\t<TagName { ...blockProps }>{ title }</TagName>\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\tvalue={ level }\n\t\t\t\t\toptions={ levelOptions }\n\t\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t{ titleElement }\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA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A,eAEhB1B,IAAA,CAACZ,aAAa;cACb8C,uBAAuB;cACvBL,KAAK,EAAGpC,EAAE,CAAE,sBAAuB,CAAG;cACtC0C,QAAQ,EAAGA,CAAA,KACVrB,aAAa,CAAE;gBACdF,UAAU,EAAE,CAAEA;cACf,CAAE,CACF;cACDwB,OAAO,EAAGxB;YAAY,CACtB;UAAC,CACa;QAAC,CACN;MAAC,CACK,CAAC,eACpBZ,IAAA,CAACsB,OAAO;QAAA,GAAMC,UAAU;QAAAG,QAAA,EAAKE;MAAK,CAAW,CAAC;IAAA,CAC7C,CACF;EACF;EAEA,oBACCxB,KAAA,CAAAF,SAAA;IAAAwB,QAAA,gBACCtB,KAAA,CAACrB,aAAa;MAACsD,KAAK,EAAC,OAAO;MAAAX,QAAA,gBAC3B1B,IAAA,CAACb,oBAAoB;QACpBmD,KAAK,EAAG7B,KAAO;QACf8B,OAAO,EAAG7B,YAAc;QACxByB,QAAQ,EAAKK,QAAQ,IACpB1B,aAAa,CAAE;UAAEL,KAAK,EAAE+B;QAAS,CAAE;MACnC,CACD,CAAC,eACFxC,IAAA,CAAClB,gBAAgB;QAChBwD,KAAK,EAAG3B,SAAW;QACnBwB,QAAQ,EAAKM,SAAS,IAAM;UAC3B3B,aAAa,CAAE;YAAEH,SAAS,EAAE8B;UAAU,CAAE,CAAC;QAC1C;MAAG,CACH,CAAC;IAAA,CACY,CAAC,EACdd,YAAY;EAAA,CACb,CAAC;AAEL","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["capitalCase","store","coreDataStore","select","symbolFilled","addFilter","decodeEntities","initBlock","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","slug","type","theme","tagName","area","supports","align","html","reusable","renaming","interactivity","clientNavigation","editorStyle","edit","enhanceTemplatePartVariations","settings","icon","__experimentalLabel","getCurrentTheme","getEditedEntityRecord","entity","stylesheet","init","DISALLOWED_PARENTS","canInsert","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"sources":["@wordpress/block-library/src/template-part/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { capitalCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { select } from '@wordpress/data';\nimport { symbolFilled } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport { enhanceTemplatePartVariations } from './variations';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon: symbolFilled,\n\t__experimentalLabel: ( { slug, theme } ) => {\n\t\t// Attempt to find entity title if block is a template part.\n\t\t// Require slug to request, otherwise entity is uncreated and will throw 404.\n\t\tif ( ! slug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { getCurrentTheme, getEditedEntityRecord } =\n\t\t\tselect( coreDataStore );\n\t\tconst entity = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t( theme || getCurrentTheme()?.stylesheet ) + '//' + slug\n\t\t);\n\t\tif ( ! entity ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn (\n\t\t\tdecodeEntities( entity.title ) || capitalCase( entity.slug || '' )\n\t\t);\n\t},\n\tedit,\n};\n\nexport const init = () => {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/template-part',\n\t\tenhanceTemplatePartVariations\n\t);\n\n\t// Prevent adding template parts inside post templates.\n\tconst DISALLOWED_PARENTS = [ 'core/post-template', 'core/post-content' ];\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'core/block-library/removeTemplatePartsFromPostTemplates',\n\t\t(\n\t\t\tcanInsert,\n\t\t\tblockType,\n\t\t\trootClientId,\n\t\t\t{ getBlock, getBlockParentsByBlockName }\n\t\t) => {\n\t\t\tif ( blockType.name !== 'core/template-part' ) {\n\t\t\t\treturn canInsert;\n\t\t\t}\n\n\t\t\tfor ( const disallowedParentType of DISALLOWED_PARENTS ) {\n\t\t\t\tconst hasDisallowedParent =\n\t\t\t\t\tgetBlock( rootClientId )?.name === disallowedParentType ||\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tdisallowedParentType\n\t\t\t\t\t).length;\n\t\t\t\tif ( hasDisallowedParent ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t);\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,aAAa;;AAEzC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;AAC7D,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,IAAA;MAAAC,IAAA;IAAA;IAAAC,KAAA;MAAAD,IAAA;IAAA;IAAAE,OAAA;MAAAF,IAAA;IAAA;IAAAG,IAAA;MAAAH,IAAA;IAAA;EAAA;EAAAI,QAAA;IAAAC,KAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,QAAA;IAAAC,aAAA;MAAAC,gBAAA;IAAA;EAAA;EAAAC,WAAA;AAAA;AAE5C,OAAOC,IAAI,MAAM,QAAQ;AACzB,SAASC,6BAA6B,QAAQ,cAAc;AAE5D,MAAM;
|
|
1
|
+
{"version":3,"names":["capitalCase","store","coreDataStore","select","symbolFilled","addFilter","decodeEntities","initBlock","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","slug","type","theme","tagName","area","supports","align","html","reusable","renaming","blockVisibility","interactivity","clientNavigation","editorStyle","edit","enhanceTemplatePartVariations","settings","icon","__experimentalLabel","getCurrentTheme","getEditedEntityRecord","entity","stylesheet","init","DISALLOWED_PARENTS","canInsert","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"sources":["@wordpress/block-library/src/template-part/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { capitalCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { select } from '@wordpress/data';\nimport { symbolFilled } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport { enhanceTemplatePartVariations } from './variations';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon: symbolFilled,\n\t__experimentalLabel: ( { slug, theme } ) => {\n\t\t// Attempt to find entity title if block is a template part.\n\t\t// Require slug to request, otherwise entity is uncreated and will throw 404.\n\t\tif ( ! slug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { getCurrentTheme, getEditedEntityRecord } =\n\t\t\tselect( coreDataStore );\n\t\tconst entity = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t( theme || getCurrentTheme()?.stylesheet ) + '//' + slug\n\t\t);\n\t\tif ( ! entity ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn (\n\t\t\tdecodeEntities( entity.title ) || capitalCase( entity.slug || '' )\n\t\t);\n\t},\n\tedit,\n};\n\nexport const init = () => {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/template-part',\n\t\tenhanceTemplatePartVariations\n\t);\n\n\t// Prevent adding template parts inside post templates.\n\tconst DISALLOWED_PARENTS = [ 'core/post-template', 'core/post-content' ];\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'core/block-library/removeTemplatePartsFromPostTemplates',\n\t\t(\n\t\t\tcanInsert,\n\t\t\tblockType,\n\t\t\trootClientId,\n\t\t\t{ getBlock, getBlockParentsByBlockName }\n\t\t) => {\n\t\t\tif ( blockType.name !== 'core/template-part' ) {\n\t\t\t\treturn canInsert;\n\t\t\t}\n\n\t\t\tfor ( const disallowedParentType of DISALLOWED_PARENTS ) {\n\t\t\t\tconst hasDisallowedParent =\n\t\t\t\t\tgetBlock( rootClientId )?.name === disallowedParentType ||\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tdisallowedParentType\n\t\t\t\t\t).length;\n\t\t\t\tif ( hasDisallowedParent ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t);\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,aAAa;;AAEzC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;AAC7D,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,IAAA;MAAAC,IAAA;IAAA;IAAAC,KAAA;MAAAD,IAAA;IAAA;IAAAE,OAAA;MAAAF,IAAA;IAAA;IAAAG,IAAA;MAAAH,IAAA;IAAA;EAAA;EAAAI,QAAA;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;MAC9C,OAAO+B,SAAS;IACjB;IAEA,KAAM,MAAMK,oBAAoB,IAAIN,kBAAkB,EAAG;MACxD,MAAMO,mBAAmB,GACxBH,QAAQ,CAAED,YAAa,CAAC,EAAEjC,IAAI,KAAKoC,oBAAoB,IACvDD,0BAA0B,CACzBF,YAAY,EACZG,oBACD,CAAC,CAACE,MAAM;MACT,IAAKD,mBAAmB,EAAG;QAC1B,OAAO,KAAK;MACb;IACD;IACA,OAAO,IAAI;EACZ,CACD,CAAC;EAED,OAAOzC,SAAS,CAAE;IAAEI,IAAI;IAAEH,QAAQ;IAAEyB;EAAS,CAAE,CAAC;AACjD,CAAC","ignoreList":[]}
|
|
@@ -31,6 +31,13 @@ export function getTransformedMetadata(metadata, newBlockName, bindingsCallback)
|
|
|
31
31
|
if (supports.renaming !== false) {
|
|
32
32
|
transformSupportedProps.push('name');
|
|
33
33
|
}
|
|
34
|
+
// If it supports block visibility (true by default), add the `blockVisibility` property.
|
|
35
|
+
if (supports.blockVisibility !== false) {
|
|
36
|
+
transformSupportedProps.push('blockVisibility');
|
|
37
|
+
}
|
|
38
|
+
if (window?.__experimentalEnableBlockComment) {
|
|
39
|
+
transformSupportedProps.push('commentId');
|
|
40
|
+
}
|
|
34
41
|
|
|
35
42
|
// Return early if no supported properties.
|
|
36
43
|
if (!transformSupportedProps.length) {
|