@wordpress/block-library 9.33.6 → 9.33.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/heading/index.js +3 -1
- package/build/heading/index.js.map +3 -3
- package/build/heading/variations.js +53 -0
- package/build/heading/variations.js.map +7 -0
- package/build/navigation-link/edit.js +31 -10
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/link-ui/index.js +8 -3
- package/build/navigation-link/link-ui/index.js.map +2 -2
- package/build/navigation-link/shared/controls.js +74 -23
- package/build/navigation-link/shared/controls.js.map +2 -2
- package/build/navigation-link/shared/index.js +4 -0
- package/build/navigation-link/shared/index.js.map +2 -2
- package/build/navigation-link/shared/use-entity-binding.js +32 -2
- package/build/navigation-link/shared/use-entity-binding.js.map +3 -3
- package/build/paragraph/index.js +3 -1
- package/build/paragraph/index.js.map +3 -3
- package/build/paragraph/variations.js +55 -0
- package/build/paragraph/variations.js.map +7 -0
- package/build/social-links/edit.js +1 -1
- package/build/social-links/edit.js.map +1 -1
- package/build-module/heading/index.js +3 -1
- package/build-module/heading/index.js.map +2 -2
- package/build-module/heading/variations.js +33 -0
- package/build-module/heading/variations.js.map +7 -0
- package/build-module/navigation-link/edit.js +45 -14
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/link-ui/index.js +8 -3
- package/build-module/navigation-link/link-ui/index.js.map +2 -2
- package/build-module/navigation-link/shared/controls.js +72 -23
- package/build-module/navigation-link/shared/controls.js.map +2 -2
- package/build-module/navigation-link/shared/index.js +3 -1
- package/build-module/navigation-link/shared/index.js.map +2 -2
- package/build-module/navigation-link/shared/use-entity-binding.js +36 -3
- package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build-module/paragraph/index.js +3 -1
- package/build-module/paragraph/index.js.map +2 -2
- package/build-module/paragraph/variations.js +35 -0
- package/build-module/paragraph/variations.js.map +7 -0
- package/build-module/social-links/edit.js +1 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-style/accordion-heading/style-rtl.css +19 -3
- package/build-style/accordion-heading/style.css +19 -3
- package/build-style/accordion-panel/style-rtl.css +4 -1
- package/build-style/accordion-panel/style.css +4 -1
- package/build-style/editor-rtl.css +7 -0
- package/build-style/editor.css +7 -0
- package/build-style/navigation-link/editor-rtl.css +7 -0
- package/build-style/navigation-link/editor.css +7 -0
- package/build-style/style-rtl.css +23 -4
- package/build-style/style.css +23 -4
- package/package.json +11 -11
- package/src/accordion-heading/style.scss +40 -7
- package/src/accordion-panel/style.scss +6 -1
- package/src/heading/index.js +2 -0
- package/src/heading/variations.js +37 -0
- package/src/navigation-link/edit.js +71 -17
- package/src/navigation-link/editor.scss +7 -0
- package/src/navigation-link/link-ui/index.js +9 -8
- package/src/navigation-link/shared/controls.js +120 -26
- package/src/navigation-link/shared/index.js +1 -1
- package/src/navigation-link/shared/test/controls.js +19 -9
- package/src/navigation-link/shared/test/use-entity-binding.js +14 -1
- package/src/navigation-link/shared/use-entity-binding.js +60 -9
- package/src/paragraph/index.js +2 -0
- package/src/paragraph/variations.js +39 -0
- package/src/social-links/edit.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/shared/controls.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalInputControl as InputControl,\n\tButton,\n\tCheckboxControl,\n\tTextControl,\n\tTextareaControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { safeDecodeURI } from '@wordpress/url';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { linkOff as unlinkIcon } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../../utils/hooks';\nimport { updateAttributes } from './update-attributes';\nimport { useEntityBinding } from './use-entity-binding';\n\n/**\n * Get a human-readable entity type name.\n *\n * @param {string} type - The entity type\n * @param {string} kind - The entity kind\n * @return {string} Human-readable entity type name\n */\nfunction getEntityTypeName( type, kind ) {\n\tif ( kind === 'post-type' ) {\n\t\tswitch ( type ) {\n\t\t\tcase 'post':\n\t\t\t\treturn __( 'post' );\n\t\t\tcase 'page':\n\t\t\t\treturn __( 'page' );\n\t\t\tdefault:\n\t\t\t\treturn type || __( 'post' );\n\t\t}\n\t}\n\tif ( kind === 'taxonomy' ) {\n\t\tswitch ( type ) {\n\t\t\tcase 'category':\n\t\t\t\treturn __( 'category' );\n\t\t\tcase 'tag':\n\t\t\t\treturn __( 'tag' );\n\t\t\tdefault:\n\t\t\t\treturn type || __( 'term' );\n\t\t}\n\t}\n\treturn type || __( 'item' );\n}\n\n/**\n * Shared Controls component for Navigation Link and Navigation Submenu blocks.\n *\n * This component provides the inspector controls (ToolsPanel) that are identical\n * between both navigation blocks.\n *\n * @param {Object} props - Component props\n * @param {Object} props.attributes - Block attributes\n * @param {Function} props.setAttributes - Function to update block attributes\n * @param {string} props.clientId - Block client ID\n */\nexport function Controls( { attributes, setAttributes, clientId } ) {\n\tconst { label, url, description, rel, opensInNewTab } = attributes;\n\tconst lastURLRef = useRef( url );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst inputId = useInstanceId( Controls, 'link-input' );\n\tconst helpTextId = `${ inputId }__help`;\n\n\t// Use the entity binding hook internally\n\tconst { hasUrlBinding, clearBinding } = useEntityBinding( {\n\t\tclientId,\n\t\tattributes,\n\t} );\n\n\t// Get direct store dispatch to bypass setBoundAttributes wrapper\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst editBoundLink = () => {\n\t\t// Clear the binding first\n\t\tclearBinding();\n\n\t\t// Use direct store dispatch to bypass block bindings safeguards\n\t\t// which prevent updates to bound attributes when calling setAttributes.\n\t\t// setAttributes is actually setBoundAttributes, a wrapper function that\n\t\t// processes attributes through the binding system.\n\t\t// See: packages/block-editor/src/components/block-edit/edit.js\n\t\tupdateBlockAttributes( clientId, { url: '', id: undefined } );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ __( 'Settings' ) }\n\t\t\tresetAll={ () => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tlabel: '',\n\t\t\t\t\turl: '',\n\t\t\t\t\tdescription: '',\n\t\t\t\t\trel: '',\n\t\t\t\t\topensInNewTab: false,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! label }\n\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { label: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\tvalue={ label ? stripHTML( label ) : '' }\n\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t} }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! url }\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { url: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<InputControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tid={ inputId }\n\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\tvalue={ url ? safeDecodeURI( url ) : '' }\n\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\tif ( hasUrlBinding ) {\n\t\t\t\t\t\t\treturn; // Prevent editing when URL is bound\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\turl: encodeURI( safeDecodeURI( urlValue ) ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\ttype=\"url\"\n\t\t\t\t\tdisabled={ hasUrlBinding }\n\t\t\t\t\tonFocus={ () => {\n\t\t\t\t\t\tif ( hasUrlBinding ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlastURLRef.current = url;\n\t\t\t\t\t} }\n\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\tif ( hasUrlBinding ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Defer the updateAttributes call to ensure entity connection isn't severed by accident.\n\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t{ url: ! url ? lastURLRef.current : url },\n\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t{ ...attributes, url: lastURLRef.current }\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t\thelp={\n\t\t\t\t\t\thasUrlBinding && (\n\t\t\t\t\t\t\t<BindingHelpText\n\t\t\t\t\t\t\t\ttype={ attributes.type }\n\t\t\t\t\t\t\t\tkind={ attributes.kind }\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\tsuffix={\n\t\t\t\t\t\thasUrlBinding && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ unlinkIcon }\n\t\t\t\t\t\t\t\tonClick={ editBoundLink }\n\t\t\t\t\t\t\t\taria-describedby={ helpTextId }\n\t\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\t\tlabel={ __( 'Unsync and edit' ) }\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\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/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! opensInNewTab }\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { opensInNewTab: false } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\tchecked={ opensInNewTab }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { opensInNewTab: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! description }\n\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { description: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextareaControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\tsetAttributes( { description: descriptionValue } );\n\t\t\t\t\t} }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! rel }\n\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { rel: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t} }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'The relationship of the linked URL as space-separated link types.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</ToolsPanel>\n\t);\n}\n\n/**\n * Component to display help text for bound URL attributes.\n *\n * @param {Object} props - Component props\n * @param {string} props.type - The entity type\n * @param {string} props.kind - The entity kind\n * @return {string} Help text for the bound URL\n */\nfunction BindingHelpText( { type, kind } ) {\n\tconst entityType = getEntityTypeName( type, kind );\n\treturn sprintf(\n\t\t/* translators: %s is the entity type (e.g., \"page\", \"post\", \"category\") */\n\t\t__( 'Synced with the selected %s.' ),\n\t\tentityType\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalInputControl as InputControl,\n\tButton,\n\tCheckboxControl,\n\tTextControl,\n\tTextareaControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { safeDecodeURI } from '@wordpress/url';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { linkOff as unlinkIcon } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../../utils/hooks';\nimport { updateAttributes } from './update-attributes';\nimport { useEntityBinding } from './use-entity-binding';\n\n/**\n * Get a human-readable entity type name.\n *\n * @param {string} type - The entity type\n * @param {string} kind - The entity kind\n * @return {string} Human-readable entity type name\n */\nfunction getEntityTypeName( type, kind ) {\n\tif ( kind === 'post-type' ) {\n\t\tswitch ( type ) {\n\t\t\tcase 'post':\n\t\t\t\treturn __( 'post' );\n\t\t\tcase 'page':\n\t\t\t\treturn __( 'page' );\n\t\t\tdefault:\n\t\t\t\treturn type || __( 'post' );\n\t\t}\n\t}\n\tif ( kind === 'taxonomy' ) {\n\t\tswitch ( type ) {\n\t\t\tcase 'category':\n\t\t\t\treturn __( 'category' );\n\t\t\tcase 'tag':\n\t\t\t\treturn __( 'tag' );\n\t\t\tdefault:\n\t\t\t\treturn type || __( 'term' );\n\t\t}\n\t}\n\treturn type || __( 'item' );\n}\n\n/**\n * Shared Controls component for Navigation Link and Navigation Submenu blocks.\n *\n * This component provides the inspector controls (ToolsPanel) that are identical\n * between both navigation blocks.\n *\n * @param {Object} props - Component props\n * @param {Object} props.attributes - Block attributes\n * @param {Function} props.setAttributes - Function to update block attributes\n * @param {string} props.clientId - Block client ID\n */\nexport function Controls( { attributes, setAttributes, clientId } ) {\n\tconst { label, url, description, rel, opensInNewTab } = attributes;\n\tconst lastURLRef = useRef( url );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst urlInputRef = useRef();\n\tconst shouldFocusURLInputRef = useRef( false );\n\tconst inputId = useInstanceId( Controls, 'link-input' );\n\tconst helpTextId = `${ inputId }__help`;\n\n\t// Local state to control the input value\n\tconst [ inputValue, setInputValue ] = useState( url );\n\n\t// Sync local state when url prop changes (e.g., from undo/redo or external updates)\n\tuseEffect( () => {\n\t\tsetInputValue( url );\n\t\tlastURLRef.current = url;\n\t}, [ url ] );\n\n\t// Use the entity binding hook internally\n\tconst { hasUrlBinding, isBoundEntityAvailable, clearBinding } =\n\t\tuseEntityBinding( {\n\t\t\tclientId,\n\t\t\tattributes,\n\t\t} );\n\n\t// Get direct store dispatch to bypass setBoundAttributes wrapper\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst unsyncBoundLink = () => {\n\t\t// Clear the binding first\n\t\tclearBinding();\n\n\t\t// Use direct store dispatch to bypass block bindings safeguards\n\t\t// which prevent updates to bound attributes when calling setAttributes.\n\t\t// setAttributes is actually setBoundAttributes, a wrapper function that\n\t\t// processes attributes through the binding system.\n\t\t// See: packages/block-editor/src/components/block-edit/edit.js\n\t\tupdateBlockAttributes( clientId, {\n\t\t\turl: lastURLRef.current, // set the lastURLRef as the new editable value so we avoid bugs from empty link states\n\t\t\tid: undefined,\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\t// Only want to focus the input if the url is not bound to an entity.\n\t\tif ( ! hasUrlBinding && shouldFocusURLInputRef.current ) {\n\t\t\t// focuses and highlights the url input value, giving the user\n\t\t\t// the ability to delete the value quickly or edit it.\n\t\t\turlInputRef.current?.select();\n\t\t}\n\t\tshouldFocusURLInputRef.current = false;\n\t}, [ hasUrlBinding ] );\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ __( 'Settings' ) }\n\t\t\tresetAll={ () => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tlabel: '',\n\t\t\t\t\turl: '',\n\t\t\t\t\tdescription: '',\n\t\t\t\t\trel: '',\n\t\t\t\t\topensInNewTab: false,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! label }\n\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { label: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\tvalue={ label ? stripHTML( label ) : '' }\n\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t} }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! url }\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { url: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<InputControl\n\t\t\t\t\tref={ urlInputRef }\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tid={ inputId }\n\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\tvalue={ ( () => {\n\t\t\t\t\t\tif ( hasUrlBinding && ! isBoundEntityAvailable ) {\n\t\t\t\t\t\t\treturn '';\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn inputValue ? safeDecodeURI( inputValue ) : '';\n\t\t\t\t\t} )() }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\ttype=\"url\"\n\t\t\t\t\tdisabled={ hasUrlBinding }\n\t\t\t\t\taria-invalid={\n\t\t\t\t\t\thasUrlBinding && ! isBoundEntityAvailable\n\t\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t\taria-describedby={ helpTextId }\n\t\t\t\t\tclassName={\n\t\t\t\t\t\thasUrlBinding && ! isBoundEntityAvailable\n\t\t\t\t\t\t\t? 'navigation-link-control__input-with-error-suffix'\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\tif ( isBoundEntityAvailable ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Defer updating the url attribute until onBlur to prevent the canvas from\n\t\t\t\t\t\t// treating a temporary empty value as a committed value, which replaces the\n\t\t\t\t\t\t// label with placeholder text.\n\t\t\t\t\t\tsetInputValue( newValue );\n\t\t\t\t\t} }\n\t\t\t\t\tonFocus={ () => {\n\t\t\t\t\t\tif ( isBoundEntityAvailable ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlastURLRef.current = url;\n\t\t\t\t\t} }\n\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\tif ( isBoundEntityAvailable ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst finalValue = ! inputValue\n\t\t\t\t\t\t\t? lastURLRef.current\n\t\t\t\t\t\t\t: inputValue;\n\n\t\t\t\t\t\t// Update local state immediately so input reflects the reverted value if the value was cleared\n\t\t\t\t\t\tsetInputValue( finalValue );\n\n\t\t\t\t\t\t// Defer the updateAttributes call to ensure entity connection isn't severed by accident.\n\t\t\t\t\t\tupdateAttributes( { url: finalValue }, setAttributes, {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\turl: lastURLRef.current,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\thelp={\n\t\t\t\t\t\thasUrlBinding && ! isBoundEntityAvailable ? (\n\t\t\t\t\t\t\t<MissingEntityHelp\n\t\t\t\t\t\t\t\tid={ helpTextId }\n\t\t\t\t\t\t\t\ttype={ attributes.type }\n\t\t\t\t\t\t\t\tkind={ attributes.kind }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tisBoundEntityAvailable && (\n\t\t\t\t\t\t\t\t<BindingHelpText\n\t\t\t\t\t\t\t\t\ttype={ attributes.type }\n\t\t\t\t\t\t\t\t\tkind={ attributes.kind }\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\tsuffix={\n\t\t\t\t\t\thasUrlBinding && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ unlinkIcon }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tunsyncBoundLink();\n\t\t\t\t\t\t\t\t\t// Focus management to send focus to the URL input\n\t\t\t\t\t\t\t\t\t// on next render after disabled state is removed.\n\t\t\t\t\t\t\t\t\tshouldFocusURLInputRef.current = true;\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taria-describedby={ helpTextId }\n\t\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\t\tlabel={ __( 'Unsync and edit' ) }\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\thasUrlBinding && ! isBoundEntityAvailable\n\t\t\t\t\t\t\t\t\t\t? 'navigation-link-control__error-suffix-button'\n\t\t\t\t\t\t\t\t\t\t: undefined\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/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! opensInNewTab }\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { opensInNewTab: false } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\tchecked={ opensInNewTab }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { opensInNewTab: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! description }\n\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { description: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextareaControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\tsetAttributes( { description: descriptionValue } );\n\t\t\t\t\t} }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! rel }\n\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { rel: '' } ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t} }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'The relationship of the linked URL as space-separated link types.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</ToolsPanel>\n\t);\n}\n\n/**\n * Component to display help text for bound URL attributes.\n *\n * @param {Object} props - Component props\n * @param {string} props.type - The entity type\n * @param {string} props.kind - The entity kind\n * @return {string} Help text for the bound URL\n */\nexport function BindingHelpText( { type, kind } ) {\n\tconst entityType = getEntityTypeName( type, kind );\n\treturn sprintf(\n\t\t/* translators: %s is the entity type (e.g., \"page\", \"post\", \"category\") */\n\t\t__( 'Synced with the selected %s.' ),\n\t\tentityType\n\t);\n}\n\n/**\n * Component to display error help text for missing entity bindings.\n *\n * @param {Object} props - Component props\n * @param {string} props.type - The entity type\n * @param {string} props.kind - The entity kind\n * @return {JSX.Element} Error help text component\n */\nexport function MissingEntityHelpText( { type, kind } ) {\n\tconst entityType = getEntityTypeName( type, kind );\n\treturn sprintf(\n\t\t/* translators: %s is the entity type (e.g., \"page\", \"post\", \"category\") */\n\t\t__( 'Synced %s is missing. Please update or remove this link.' ),\n\t\tentityType\n\t);\n}\n\nfunction MissingEntityHelp( { id, type, kind } ) {\n\treturn (\n\t\t<span id={ id } className=\"navigation-link-control__error-text\">\n\t\t\t<MissingEntityHelpText type={ type } kind={ kind } />\n\t\t</span>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4HE;AAzHF,wBAQO;AACP,kBAA4B;AAC5B,qBAA4C;AAC5C,qBAA8B;AAC9B,iBAA8B;AAC9B,iBAAiD;AACjD,mBAAsC;AACtC,kBAA4B;AAC5B,0BAA0C;AAK1C,mBAA+C;AAC/C,+BAAiC;AACjC,gCAAiC;AASjC,SAAS,kBAAmB,MAAM,MAAO;AACxC,MAAK,SAAS,aAAc;AAC3B,YAAS,MAAO;AAAA,MACf,KAAK;AACJ,mBAAO,gBAAI,MAAO;AAAA,MACnB,KAAK;AACJ,mBAAO,gBAAI,MAAO;AAAA,MACnB;AACC,eAAO,YAAQ,gBAAI,MAAO;AAAA,IAC5B;AAAA,EACD;AACA,MAAK,SAAS,YAAa;AAC1B,YAAS,MAAO;AAAA,MACf,KAAK;AACJ,mBAAO,gBAAI,UAAW;AAAA,MACvB,KAAK;AACJ,mBAAO,gBAAI,KAAM;AAAA,MAClB;AACC,eAAO,YAAQ,gBAAI,MAAO;AAAA,IAC5B;AAAA,EACD;AACA,SAAO,YAAQ,gBAAI,MAAO;AAC3B;AAaO,SAAS,SAAU,EAAE,YAAY,eAAe,SAAS,GAAI;AACnE,QAAM,EAAE,OAAO,KAAK,aAAa,KAAK,cAAc,IAAI;AACxD,QAAM,iBAAa,uBAAQ,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,SACC,4CAAC,UAAK,IAAU,WAAU,uCACzB,sDAAC,yBAAsB,MAAc,MAAc,GACpD;AAEF;",
|
|
6
6
|
"names": ["blockEditorStore", "ToolsPanel", "ToolsPanelItem", "stripHTML", "InputControl", "unlinkIcon"]
|
|
7
7
|
}
|
|
@@ -18,8 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var shared_exports = {};
|
|
20
20
|
__export(shared_exports, {
|
|
21
|
+
BindingHelpText: () => import_controls.BindingHelpText,
|
|
21
22
|
Controls: () => import_controls.Controls,
|
|
22
23
|
LinkUI: () => import_link_ui.LinkUI,
|
|
24
|
+
MissingEntityHelpText: () => import_controls.MissingEntityHelpText,
|
|
23
25
|
buildNavigationLinkEntityBinding: () => import_use_entity_binding.buildNavigationLinkEntityBinding,
|
|
24
26
|
updateAttributes: () => import_update_attributes.updateAttributes,
|
|
25
27
|
useEntityBinding: () => import_use_entity_binding.useEntityBinding
|
|
@@ -31,8 +33,10 @@ var import_use_entity_binding = require("./use-entity-binding");
|
|
|
31
33
|
var import_link_ui = require("../link-ui");
|
|
32
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
35
|
0 && (module.exports = {
|
|
36
|
+
BindingHelpText,
|
|
34
37
|
Controls,
|
|
35
38
|
LinkUI,
|
|
39
|
+
MissingEntityHelpText,
|
|
36
40
|
buildNavigationLinkEntityBinding,
|
|
37
41
|
updateAttributes,
|
|
38
42
|
useEntityBinding
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/shared/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Shared components for Navigation Link and Navigation Submenu blocks.\n *\n * This module provides common functionality that can be used by both blocks\n * to reduce code duplication and ensure consistent behavior.\n */\n\nexport { Controls } from './controls';\nexport { updateAttributes } from './update-attributes';\nexport {\n\tuseEntityBinding,\n\tbuildNavigationLinkEntityBinding,\n} from './use-entity-binding';\nexport { LinkUI } from '../link-ui';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,
|
|
4
|
+
"sourcesContent": ["/**\n * Shared components for Navigation Link and Navigation Submenu blocks.\n *\n * This module provides common functionality that can be used by both blocks\n * to reduce code duplication and ensure consistent behavior.\n */\n\nexport { Controls, BindingHelpText, MissingEntityHelpText } from './controls';\nexport { updateAttributes } from './update-attributes';\nexport {\n\tuseEntityBinding,\n\tbuildNavigationLinkEntityBinding,\n} from './use-entity-binding';\nexport { LinkUI } from '../link-ui';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,sBAAiE;AACjE,+BAAiC;AACjC,gCAGO;AACP,qBAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,6 +24,8 @@ __export(use_entity_binding_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(use_entity_binding_exports);
|
|
25
25
|
var import_element = require("@wordpress/element");
|
|
26
26
|
var import_block_editor = require("@wordpress/block-editor");
|
|
27
|
+
var import_data = require("@wordpress/data");
|
|
28
|
+
var import_core_data = require("@wordpress/core-data");
|
|
27
29
|
function buildNavigationLinkEntityBinding(kind) {
|
|
28
30
|
if (kind === void 0) {
|
|
29
31
|
throw new Error(
|
|
@@ -47,10 +49,37 @@ function buildNavigationLinkEntityBinding(kind) {
|
|
|
47
49
|
}
|
|
48
50
|
function useEntityBinding({ clientId, attributes }) {
|
|
49
51
|
const { updateBlockBindings } = (0, import_block_editor.useBlockBindingsUtils)(clientId);
|
|
50
|
-
const { metadata, id, kind } = attributes;
|
|
52
|
+
const { metadata, id, kind, type } = attributes;
|
|
53
|
+
const blockEditingMode = (0, import_block_editor.useBlockEditingMode)();
|
|
51
54
|
const hasUrlBinding = !!metadata?.bindings?.url && !!id;
|
|
52
55
|
const expectedSource = kind === "post-type" ? "core/post-data" : "core/term-data";
|
|
53
56
|
const hasCorrectBinding = hasUrlBinding && metadata?.bindings?.url?.source === expectedSource;
|
|
57
|
+
const isBoundEntityAvailable = (0, import_data.useSelect)(
|
|
58
|
+
(select) => {
|
|
59
|
+
if (!hasCorrectBinding || !id) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const isPostType = kind === "post-type";
|
|
63
|
+
const isTaxonomy = kind === "taxonomy";
|
|
64
|
+
if (!isPostType && !isTaxonomy) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (blockEditingMode === "disabled") {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
const { getEntityRecord, hasFinishedResolution } = select(import_core_data.store);
|
|
71
|
+
const entityType = isTaxonomy ? "taxonomy" : "postType";
|
|
72
|
+
const typeForAPI = type === "tag" ? "post_tag" : type;
|
|
73
|
+
const entityRecord = getEntityRecord(entityType, typeForAPI, id);
|
|
74
|
+
const hasResolved = hasFinishedResolution("getEntityRecord", [
|
|
75
|
+
entityType,
|
|
76
|
+
typeForAPI,
|
|
77
|
+
id
|
|
78
|
+
]);
|
|
79
|
+
return hasResolved ? entityRecord !== void 0 : true;
|
|
80
|
+
},
|
|
81
|
+
[kind, type, id, hasCorrectBinding, blockEditingMode]
|
|
82
|
+
);
|
|
54
83
|
const clearBinding = (0, import_element.useCallback)(() => {
|
|
55
84
|
if (hasUrlBinding) {
|
|
56
85
|
updateBlockBindings({ url: void 0 });
|
|
@@ -72,10 +101,11 @@ function useEntityBinding({ clientId, attributes }) {
|
|
|
72
101
|
);
|
|
73
102
|
}
|
|
74
103
|
},
|
|
75
|
-
[updateBlockBindings, kind
|
|
104
|
+
[updateBlockBindings, kind]
|
|
76
105
|
);
|
|
77
106
|
return {
|
|
78
107
|
hasUrlBinding: hasCorrectBinding,
|
|
108
|
+
isBoundEntityAvailable,
|
|
79
109
|
clearBinding,
|
|
80
110
|
createBinding
|
|
81
111
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/shared/use-entity-binding.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tuseBlockBindingsUtils,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Builds entity binding configuration for navigation link URLs.\n * This function generates the structure used to bind navigation link URLs to their entity sources.\n *\n * Using a function instead of a constant allows for future enhancements where the binding\n * might need dynamic data (e.g., entity ID, context-specific arguments).\n *\n * @param {('post-type'|'taxonomy')} kind - The kind of entity. Only 'post-type' and 'taxonomy' are supported.\n * @return {Object} Entity binding configuration object\n * @throws {Error} If kind is not 'post-type' or 'taxonomy'\n */\nexport function buildNavigationLinkEntityBinding( kind ) {\n\t// Validate kind parameter exists.\n\tif ( kind === undefined ) {\n\t\tthrow new Error(\n\t\t\t'buildNavigationLinkEntityBinding requires a kind parameter. ' +\n\t\t\t\t'Only \"post-type\" and \"taxonomy\" are supported.'\n\t\t);\n\t}\n\n\t// Validate kind parameter value.\n\tif ( kind !== 'post-type' && kind !== 'taxonomy' ) {\n\t\tthrow new Error(\n\t\t\t`Invalid kind \"${ kind }\" provided to buildNavigationLinkEntityBinding. ` +\n\t\t\t\t`Only 'post-type' and 'taxonomy' are supported.`\n\t\t);\n\t}\n\n\tconst source = kind === 'taxonomy' ? 'core/term-data' : 'core/post-data';\n\n\treturn {\n\t\turl: {\n\t\t\tsource,\n\t\t\targs: {\n\t\t\t\tfield: 'link',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Shared hook for entity binding functionality in Navigation blocks.\n *\n * This hook provides common entity binding logic that can be used by both\n * Navigation Link and Navigation Submenu blocks to maintain feature parity.\n *\n * @param {Object} props - Hook parameters\n * @param {string} props.clientId - Block client ID\n * @param {Object} props.attributes - Block attributes\n * @return {Object} Hook return value\n */\nexport function useEntityBinding( { clientId, attributes } ) {\n\tconst { updateBlockBindings } = useBlockBindingsUtils( clientId );\n\tconst { metadata, id, kind, type } = attributes;\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst hasUrlBinding = !! metadata?.bindings?.url && !! id;\n\tconst expectedSource =\n\t\tkind === 'post-type' ? 'core/post-data' : 'core/term-data';\n\tconst hasCorrectBinding =\n\t\thasUrlBinding && metadata?.bindings?.url?.source === expectedSource;\n\n\t// Check if the bound entity is available (not deleted).\n\tconst isBoundEntityAvailable = useSelect(\n\t\t( select ) => {\n\t\t\t// First check: metadata/binding must exist\n\t\t\tif ( ! hasCorrectBinding || ! id ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst isPostType = kind === 'post-type';\n\t\t\tconst isTaxonomy = kind === 'taxonomy';\n\n\t\t\t// Only check entity availability for post types and taxonomies.\n\t\t\tif ( ! isPostType && ! isTaxonomy ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Skip check in disabled contexts to avoid unnecessary requests.\n\t\t\tif ( blockEditingMode === 'disabled' ) {\n\t\t\t\treturn true; // Assume available in disabled contexts.\n\t\t\t}\n\n\t\t\t// Second check: entity must exist\n\t\t\tconst { getEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\n\t\t\t// Use the correct entity type based on kind.\n\t\t\tconst entityType = isTaxonomy ? 'taxonomy' : 'postType';\n\t\t\t// Convert 'tag' back to 'post_tag' for the API call\n\t\t\t// (it was converted from 'post_tag' to 'tag' for storage in updateAttributes)\n\t\t\tconst typeForAPI = type === 'tag' ? 'post_tag' : type;\n\t\t\tconst entityRecord = getEntityRecord( entityType, typeForAPI, id );\n\t\t\tconst hasResolved = hasFinishedResolution( 'getEntityRecord', [\n\t\t\t\tentityType,\n\t\t\t\ttypeForAPI,\n\t\t\t\tid,\n\t\t\t] );\n\n\t\t\t// If resolution has finished and entityRecord is undefined, the entity was deleted.\n\t\t\t// Return true if entity exists, false if deleted.\n\t\t\treturn hasResolved ? entityRecord !== undefined : true;\n\t\t},\n\t\t[ kind, type, id, hasCorrectBinding, blockEditingMode ]\n\t);\n\n\tconst clearBinding = useCallback( () => {\n\t\tif ( hasUrlBinding ) {\n\t\t\tupdateBlockBindings( { url: undefined } );\n\t\t}\n\t}, [ updateBlockBindings, hasUrlBinding, metadata, id ] );\n\n\tconst createBinding = useCallback(\n\t\t( updatedAttributes ) => {\n\t\t\t// Use updated attributes if provided, otherwise fall back to closure attributes.\n\t\t\t// updatedAttributes needed to access the most up-to-date data when called synchronously.\n\t\t\tconst kindToUse = updatedAttributes?.kind ?? kind;\n\n\t\t\t// Avoid creating binding if no kind is provided.\n\t\t\tif ( ! kindToUse ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst binding = buildNavigationLinkEntityBinding( kindToUse );\n\t\t\t\tupdateBlockBindings( binding );\n\t\t\t} catch ( error ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'Failed to create entity binding:',\n\t\t\t\t\terror.message\n\t\t\t\t);\n\t\t\t\t// Don't create binding if validation fails.\n\t\t\t}\n\t\t},\n\t\t[ updateBlockBindings, kind ]\n\t);\n\n\treturn {\n\t\thasUrlBinding: hasCorrectBinding,\n\t\tisBoundEntityAvailable,\n\t\tclearBinding,\n\t\tcreateBinding,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;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,cAAc,sBAAuB,mBAAmB;AAAA,QAC7D;AAAA,QACA;AAAA,QACA;AAAA,MACD,CAAE;AAIF,aAAO,cAAc,iBAAiB,SAAY;AAAA,IACnD;AAAA,IACA,CAAE,MAAM,MAAM,IAAI,mBAAmB,gBAAiB;AAAA,EACvD;AAEA,QAAM,mBAAe,4BAAa,MAAM;AACvC,QAAK,eAAgB;AACpB,0BAAqB,EAAE,KAAK,OAAU,CAAE;AAAA,IACzC;AAAA,EACD,GAAG,CAAE,qBAAqB,eAAe,UAAU,EAAG,CAAE;AAExD,QAAM,oBAAgB;AAAA,IACrB,CAAE,sBAAuB;AAGxB,YAAM,YAAY,mBAAmB,QAAQ;AAG7C,UAAK,CAAE,WAAY;AAClB;AAAA,MACD;AAEA,UAAI;AACH,cAAM,UAAU,iCAAkC,SAAU;AAC5D,4BAAqB,OAAQ;AAAA,MAC9B,SAAU,OAAQ;AAEjB,gBAAQ;AAAA,UACP;AAAA,UACA,MAAM;AAAA,QACP;AAAA,MAED;AAAA,IACD;AAAA,IACA,CAAE,qBAAqB,IAAK;AAAA,EAC7B;AAEA,SAAO;AAAA,IACN,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
|
+
"names": ["coreStore"]
|
|
7
7
|
}
|
package/build/paragraph/index.js
CHANGED
|
@@ -42,6 +42,7 @@ var import_edit = __toESM(require("./edit"));
|
|
|
42
42
|
var import_block = __toESM(require("./block.json"));
|
|
43
43
|
var import_save = __toESM(require("./save"));
|
|
44
44
|
var import_transforms = __toESM(require("./transforms"));
|
|
45
|
+
var import_variations = __toESM(require("./variations"));
|
|
45
46
|
const { name } = import_block.default;
|
|
46
47
|
const settings = {
|
|
47
48
|
icon: import_icons.paragraph,
|
|
@@ -73,7 +74,8 @@ const settings = {
|
|
|
73
74
|
};
|
|
74
75
|
},
|
|
75
76
|
edit: import_edit.default,
|
|
76
|
-
save: import_save.default
|
|
77
|
+
save: import_save.default,
|
|
78
|
+
variations: import_variations.default
|
|
77
79
|
};
|
|
78
80
|
const init = () => (0, import_init_block.default)({ name, metadata: import_block.default, settings });
|
|
79
81
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/paragraph/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { paragraph as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __(\n\t\t\t\t'In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.'\n\t\t\t),\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\tif ( context === 'list-view' && customName ) {\n\t\t\treturn customName;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\tif ( customName ) {\n\t\t\t\treturn customName;\n\t\t\t}\n\n\t\t\tconst { content } = attributes;\n\t\t\treturn ! content || content.length === 0 ? __( 'Empty' ) : content;\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,mBAAkC;AAKlC,wBAAsB;AACtB,wBAAuB;AACvB,kBAAiB;AACjB,mBAAqB;AACrB,kBAAiB;AACjB,wBAAuB;AAEvB,MAAM,EAAE,KAAK,IAAI,aAAAA;AAIV,MAAM,WAAW;AAAA,EACvB,mBAAAC;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,aAAS;AAAA,QACR;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,aAAa,YAAY,UAAU;AAEzC,QAAK,YAAY,eAAe,YAAa;AAC5C,aAAO;AAAA,IACR;AAEA,QAAK,YAAY,iBAAkB;AAClC,UAAK,YAAa;AACjB,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,QAAQ,IAAI;AACpB,aAAO,CAAE,WAAW,QAAQ,WAAW,QAAI,gBAAI,OAAQ,IAAI;AAAA,IAC5D;AAAA,EACD;AAAA,EACA,8BAAAC;AAAA,EACA,8BAAAC;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,UACG,WAAW,WAAW,OACtB,kBAAkB,WAAW;AAAA,IACjC;AAAA,EACD;AAAA,EACA,kBAAAC;AAAA,EACA,kBAAAC;AACD;AAEO,MAAM,OAAO,UAAM,kBAAAC,SAAW,EAAE,MAAM,
|
|
6
|
-
"names": ["metadata", "icon", "transforms", "deprecated", "edit", "save", "initBlock"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { paragraph as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __(\n\t\t\t\t'In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.'\n\t\t\t),\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\tif ( context === 'list-view' && customName ) {\n\t\t\treturn customName;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\tif ( customName ) {\n\t\t\t\treturn customName;\n\t\t\t}\n\n\t\t\tconst { content } = attributes;\n\t\t\treturn ! content || content.length === 0 ? __( 'Empty' ) : content;\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n\tvariations,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,mBAAkC;AAKlC,wBAAsB;AACtB,wBAAuB;AACvB,kBAAiB;AACjB,mBAAqB;AACrB,kBAAiB;AACjB,wBAAuB;AACvB,wBAAuB;AAEvB,MAAM,EAAE,KAAK,IAAI,aAAAA;AAIV,MAAM,WAAW;AAAA,EACvB,mBAAAC;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,aAAS;AAAA,QACR;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,aAAa,YAAY,UAAU;AAEzC,QAAK,YAAY,eAAe,YAAa;AAC5C,aAAO;AAAA,IACR;AAEA,QAAK,YAAY,iBAAkB;AAClC,UAAK,YAAa;AACjB,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,QAAQ,IAAI;AACpB,aAAO,CAAE,WAAW,QAAQ,WAAW,QAAI,gBAAI,OAAQ,IAAI;AAAA,IAC5D;AAAA,EACD;AAAA,EACA,8BAAAC;AAAA,EACA,8BAAAC;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,UACG,WAAW,WAAW,OACtB,kBAAkB,WAAW;AAAA,IACjC;AAAA,EACD;AAAA,EACA,kBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,8BAAAC;AACD;AAEO,MAAM,OAAO,UAAM,kBAAAC,SAAW,EAAE,MAAM,uBAAAP,SAAU,SAAS,CAAE;",
|
|
6
|
+
"names": ["metadata", "icon", "transforms", "deprecated", "edit", "save", "variations", "initBlock"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var variations_exports = {};
|
|
20
|
+
__export(variations_exports, {
|
|
21
|
+
default: () => variations_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(variations_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_i18n = require("@wordpress/i18n");
|
|
26
|
+
var import_primitives = require("@wordpress/primitives");
|
|
27
|
+
var import_icons = require("@wordpress/icons");
|
|
28
|
+
const variations = [
|
|
29
|
+
{
|
|
30
|
+
name: "paragraph",
|
|
31
|
+
title: (0, import_i18n.__)("Paragraph"),
|
|
32
|
+
description: (0, import_i18n.__)(
|
|
33
|
+
"Start with the basic building block of all narrative."
|
|
34
|
+
),
|
|
35
|
+
isDefault: true,
|
|
36
|
+
scope: ["block", "inserter", "transform"],
|
|
37
|
+
attributes: { fitText: void 0 },
|
|
38
|
+
icon: import_icons.paragraph
|
|
39
|
+
},
|
|
40
|
+
// There is a hardcoded workaround in packages/block-editor/src/store/selectors.js
|
|
41
|
+
// to make Stretchy variations appear as the last of their sections in the inserter.
|
|
42
|
+
{
|
|
43
|
+
name: "stretchy-paragraph",
|
|
44
|
+
title: (0, import_i18n.__)("Stretchy Paragraph"),
|
|
45
|
+
description: (0, import_i18n.__)("Paragraph that resizes to fit its container."),
|
|
46
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "M3 9c0 2.8 2.2 5 5 5v-.2V20h1.5V5.5H12V20h1.5V5.5h3V4H8C5.2 4 3 6.2 3 9Zm16.2-.2v1.5h2.2L17.7 14l1.1 1.1 3.7-3.7v2.2H24V8.8h-4.8Z" }) }),
|
|
47
|
+
attributes: {
|
|
48
|
+
fitText: true
|
|
49
|
+
},
|
|
50
|
+
scope: ["inserter", "transform"],
|
|
51
|
+
isActive: (blockAttributes) => blockAttributes.fitText === true
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
var variations_default = variations;
|
|
55
|
+
//# sourceMappingURL=variations.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/paragraph/variations.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Path, SVG } from '@wordpress/primitives';\nimport { paragraph } from '@wordpress/icons';\n\nconst variations = [\n\t{\n\t\tname: 'paragraph',\n\t\ttitle: __( 'Paragraph' ),\n\t\tdescription: __(\n\t\t\t'Start with the basic building block of all narrative.'\n\t\t),\n\t\tisDefault: true,\n\t\tscope: [ 'block', 'inserter', 'transform' ],\n\t\tattributes: { fitText: undefined },\n\t\ticon: paragraph,\n\t},\n\t// There is a hardcoded workaround in packages/block-editor/src/store/selectors.js\n\t// to make Stretchy variations appear as the last of their sections in the inserter.\n\t{\n\t\tname: 'stretchy-paragraph',\n\t\ttitle: __( 'Stretchy Paragraph' ),\n\t\tdescription: __( 'Paragraph that resizes to fit its container.' ),\n\t\ticon: (\n\t\t\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">\n\t\t\t\t<Path d=\"M3 9c0 2.8 2.2 5 5 5v-.2V20h1.5V5.5H12V20h1.5V5.5h3V4H8C5.2 4 3 6.2 3 9Zm16.2-.2v1.5h2.2L17.7 14l1.1 1.1 3.7-3.7v2.2H24V8.8h-4.8Z\" />\n\t\t\t</SVG>\n\t\t),\n\t\tattributes: {\n\t\t\tfitText: true,\n\t\t},\n\t\tscope: [ 'inserter', 'transform' ],\n\t\tisActive: ( blockAttributes ) => blockAttributes.fitText === true,\n\t},\n];\n\nexport default variations;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BI;AAxBJ,kBAAmB;AACnB,wBAA0B;AAC1B,mBAA0B;AAE1B,MAAM,aAAa;AAAA,EAClB;AAAA,IACC,MAAM;AAAA,IACN,WAAO,gBAAI,WAAY;AAAA,IACvB,iBAAa;AAAA,MACZ;AAAA,IACD;AAAA,IACA,WAAW;AAAA,IACX,OAAO,CAAE,SAAS,YAAY,WAAY;AAAA,IAC1C,YAAY,EAAE,SAAS,OAAU;AAAA,IACjC,MAAM;AAAA,EACP;AAAA;AAAA;AAAA,EAGA;AAAA,IACC,MAAM;AAAA,IACN,WAAO,gBAAI,oBAAqB;AAAA,IAChC,iBAAa,gBAAI,8CAA+C;AAAA,IAChE,MACC,4CAAC,yBAAI,OAAM,8BAA6B,SAAQ,aAC/C,sDAAC,0BAAK,GAAE,qIAAoI,GAC7I;AAAA,IAED,YAAY;AAAA,MACX,SAAS;AAAA,IACV;AAAA,IACA,OAAO,CAAE,YAAY,WAAY;AAAA,IACjC,UAAU,CAAE,oBAAqB,gBAAgB,YAAY;AAAA,EAC9D;AACD;AAEA,IAAO,qBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -169,7 +169,7 @@ function SocialLinksEdit(props) {
|
|
|
169
169
|
{
|
|
170
170
|
__next40pxDefaultSize: true,
|
|
171
171
|
__nextHasNoMarginBottom: true,
|
|
172
|
-
label: (0, import_i18n.__)("Icon
|
|
172
|
+
label: (0, import_i18n.__)("Icon size"),
|
|
173
173
|
onChange: (newSize) => {
|
|
174
174
|
setAttributes({
|
|
175
175
|
size: newSize === "" ? void 0 : newSize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/social-links/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\twithColors,\n\tInnerBlocks,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tSelectControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst sizeOptions = [\n\t{ label: __( 'Default' ), value: '' },\n\t{ label: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ label: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ label: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ label: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tshowLabels,\n\t\tsize,\n\t} = attributes;\n\n\tconst { hasSocialIcons, hasSelectedChild } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockCount, hasSelectedInnerBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\thasSocialIcons: getBlockCount( clientId ) > 0,\n\t\t\t\thasSelectedChild: hasSelectedInnerBlock( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst hasAnySelected = isSelected || hasSelectedChild;\n\n\tconst logosOnly = attributes.className?.includes( 'is-style-logos-only' );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// Remove icon background color when logos only style is selected or\n\t// restore it when any other style is selected.\n\tuseEffect( () => {\n\t\tif ( logosOnly ) {\n\t\t\tlet restore;\n\t\t\tsetAttributes( ( prev ) => {\n\t\t\t\trestore = {\n\t\t\t\t\ticonBackgroundColor: prev.iconBackgroundColor,\n\t\t\t\t\ticonBackgroundColorValue: prev.iconBackgroundColorValue,\n\t\t\t\t\tcustomIconBackgroundColor: prev.customIconBackgroundColor,\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\ticonBackgroundColor: undefined,\n\t\t\t\t\ticonBackgroundColorValue: undefined,\n\t\t\t\t\tcustomIconBackgroundColor: undefined,\n\t\t\t\t};\n\t\t\t} );\n\n\t\t\treturn () => setAttributes( { ...restore } );\n\t\t}\n\t}, [ logosOnly, setAttributes ] );\n\n\t// Fallback color values are used maintain selections in case switching\n\t// themes and named colors in palette do not match.\n\tconst className = clsx( size, {\n\t\t'has-visible-labels': showLabels,\n\t\t'has-icon-color': iconColor.color || iconColorValue,\n\t\t'has-icon-background-color':\n\t\t\ticonBackgroundColor.color || iconBackgroundColorValue,\n\t} );\n\n\tconst blockProps = useBlockProps( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplateLock: false,\n\t\torientation: attributes.layout?.orientation ?? 'horizontal',\n\t\t__experimentalAppenderTagName: 'li',\n\t\trenderAppender:\n\t\t\t! hasSocialIcons || hasAnySelected\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: undefined,\n\t} );\n\n\tconst colorSettings = [\n\t\t{\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconColor.color || iconColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconColor( colorValue );\n\t\t\t\tsetAttributes( { iconColorValue: colorValue } );\n\t\t\t},\n\t\t\tlabel: __( 'Icon color' ),\n\t\t\tresetAllFilter: () => {\n\t\t\t\tsetIconColor( undefined );\n\t\t\t\tsetAttributes( { iconColorValue: undefined } );\n\t\t\t},\n\t\t},\n\t];\n\n\tif ( ! logosOnly ) {\n\t\tcolorSettings.push( {\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconBackgroundColor.color || iconBackgroundColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconBackgroundColor( colorValue );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\ticonBackgroundColorValue: colorValue,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tlabel: __( 'Icon background' ),\n\t\t\tresetAllFilter: () => {\n\t\t\t\tsetIconBackgroundColor( undefined );\n\t\t\t\tsetAttributes( { iconBackgroundColorValue: undefined } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\n\treturn (\n\t\t<>\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\topenInNewTab: false,\n\t\t\t\t\t\t\tshowLabels: false,\n\t\t\t\t\t\t\tsize: undefined,\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\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! size }\n\t\t\t\t\t\tlabel={ __( 'Icon size' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { size: undefined } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Icon
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\twithColors,\n\tInnerBlocks,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tSelectControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst sizeOptions = [\n\t{ label: __( 'Default' ), value: '' },\n\t{ label: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ label: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ label: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ label: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tshowLabels,\n\t\tsize,\n\t} = attributes;\n\n\tconst { hasSocialIcons, hasSelectedChild } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockCount, hasSelectedInnerBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\thasSocialIcons: getBlockCount( clientId ) > 0,\n\t\t\t\thasSelectedChild: hasSelectedInnerBlock( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst hasAnySelected = isSelected || hasSelectedChild;\n\n\tconst logosOnly = attributes.className?.includes( 'is-style-logos-only' );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// Remove icon background color when logos only style is selected or\n\t// restore it when any other style is selected.\n\tuseEffect( () => {\n\t\tif ( logosOnly ) {\n\t\t\tlet restore;\n\t\t\tsetAttributes( ( prev ) => {\n\t\t\t\trestore = {\n\t\t\t\t\ticonBackgroundColor: prev.iconBackgroundColor,\n\t\t\t\t\ticonBackgroundColorValue: prev.iconBackgroundColorValue,\n\t\t\t\t\tcustomIconBackgroundColor: prev.customIconBackgroundColor,\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\ticonBackgroundColor: undefined,\n\t\t\t\t\ticonBackgroundColorValue: undefined,\n\t\t\t\t\tcustomIconBackgroundColor: undefined,\n\t\t\t\t};\n\t\t\t} );\n\n\t\t\treturn () => setAttributes( { ...restore } );\n\t\t}\n\t}, [ logosOnly, setAttributes ] );\n\n\t// Fallback color values are used maintain selections in case switching\n\t// themes and named colors in palette do not match.\n\tconst className = clsx( size, {\n\t\t'has-visible-labels': showLabels,\n\t\t'has-icon-color': iconColor.color || iconColorValue,\n\t\t'has-icon-background-color':\n\t\t\ticonBackgroundColor.color || iconBackgroundColorValue,\n\t} );\n\n\tconst blockProps = useBlockProps( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplateLock: false,\n\t\torientation: attributes.layout?.orientation ?? 'horizontal',\n\t\t__experimentalAppenderTagName: 'li',\n\t\trenderAppender:\n\t\t\t! hasSocialIcons || hasAnySelected\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: undefined,\n\t} );\n\n\tconst colorSettings = [\n\t\t{\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconColor.color || iconColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconColor( colorValue );\n\t\t\t\tsetAttributes( { iconColorValue: colorValue } );\n\t\t\t},\n\t\t\tlabel: __( 'Icon color' ),\n\t\t\tresetAllFilter: () => {\n\t\t\t\tsetIconColor( undefined );\n\t\t\t\tsetAttributes( { iconColorValue: undefined } );\n\t\t\t},\n\t\t},\n\t];\n\n\tif ( ! logosOnly ) {\n\t\tcolorSettings.push( {\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconBackgroundColor.color || iconBackgroundColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconBackgroundColor( colorValue );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\ticonBackgroundColorValue: colorValue,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tlabel: __( 'Icon background' ),\n\t\t\tresetAllFilter: () => {\n\t\t\t\tsetIconBackgroundColor( undefined );\n\t\t\t\tsetAttributes( { iconBackgroundColorValue: undefined } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\n\treturn (\n\t\t<>\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\topenInNewTab: false,\n\t\t\t\t\t\t\tshowLabels: false,\n\t\t\t\t\t\t\tsize: undefined,\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\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! size }\n\t\t\t\t\t\tlabel={ __( 'Icon size' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { size: undefined } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Icon size' ) }\n\t\t\t\t\t\t\tonChange={ ( newSize ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tsize: newSize === '' ? undefined : newSize,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tvalue={ size ?? '' }\n\t\t\t\t\t\t\toptions={ sizeOptions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tlabel={ __( 'Show text' ) }\n\t\t\t\t\t\thasValue={ () => !! showLabels }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showLabels: false } )\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 text' ) }\n\t\t\t\t\t\t\tchecked={ showLabels }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showLabels: ! showLabels } )\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<ToolsPanelItem\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tlabel={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\thasValue={ () => !! openInNewTab }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { openInNewTab: false } )\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={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\t\tchecked={ openInNewTab }\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\topenInNewTab: ! openInNewTab,\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{ colorGradientSettings.hasColorsOrGradients && (\n\t\t\t\t<InspectorControls group=\"color\">\n\t\t\t\t\t{ colorSettings.map(\n\t\t\t\t\t\t( { onChange, label, value, resetAllFilter } ) => (\n\t\t\t\t\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\t\t\t\t\tkey={ `social-links-color-${ label }` }\n\t\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t\t\tsettings={ [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcolorValue: value,\n\t\t\t\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\t\t\t\tonColorChange: onChange,\n\t\t\t\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\t\t\t\tresetAllFilter,\n\t\t\t\t\t\t\t\t\t\tenableAlpha: true,\n\t\t\t\t\t\t\t\t\t\tclearable: true,\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\tpanelId={ clientId }\n\t\t\t\t\t\t\t\t{ ...colorGradientSettings }\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{ ! logosOnly && (\n\t\t\t\t\t\t<ContrastChecker\n\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\ttextColor: iconColorValue,\n\t\t\t\t\t\t\t\tbackgroundColor: iconBackgroundColorValue,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisLargeText={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<ul { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n\nconst iconColorAttributes = {\n\ticonColor: 'icon-color',\n\ticonBackgroundColor: 'icon-background-color',\n};\n\nexport default withColors( iconColorAttributes )( SocialLinksEdit );\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiKE;AA9JF,kBAAiB;AAKjB,qBAA0B;AAC1B,0BAUO;AACP,wBAKO;AACP,kBAAmB;AACnB,kBAA0B;AAK1B,mBAA+C;AAE/C,MAAM,cAAc;AAAA,EACnB,EAAE,WAAO,gBAAI,SAAU,GAAG,OAAO,GAAG;AAAA,EACpC,EAAE,WAAO,gBAAI,OAAQ,GAAG,OAAO,sBAAsB;AAAA,EACrD,EAAE,WAAO,gBAAI,QAAS,GAAG,OAAO,uBAAuB;AAAA,EACvD,EAAE,WAAO,gBAAI,OAAQ,GAAG,OAAO,sBAAsB;AAAA,EACrD,EAAE,WAAO,gBAAI,MAAO,GAAG,OAAO,qBAAqB;AACpD;AAEO,SAAS,gBAAiB,OAAQ;AACxC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,QAAM,EAAE,gBAAgB,iBAAiB,QAAI;AAAA,IAC5C,CAAE,WAAY;AACb,YAAM,EAAE,eAAe,sBAAsB,IAC5C,OAAQ,oBAAAA,KAAiB;AAC1B,aAAO;AAAA,QACN,gBAAgB,cAAe,QAAS,IAAI;AAAA,QAC5C,kBAAkB,sBAAuB,QAAS;AAAA,MACnD;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,iBAAiB,cAAc;AAErC,QAAM,YAAY,WAAW,WAAW,SAAU,qBAAsB;AA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;AAEF;AAEA,MAAM,sBAAsB;AAAA,EAC3B,WAAW;AAAA,EACX,qBAAqB;AACtB;AAEA,IAAO,mBAAQ,gCAAY,mBAAoB,EAAG,eAAgB;",
|
|
6
6
|
"names": ["blockEditorStore", "clsx", "useMultipleOriginColorsAndGradients", "ToolsPanel", "ToolsPanelItem", "ColorGradientSettingsDropdown"]
|
|
7
7
|
}
|
|
@@ -6,6 +6,7 @@ import edit from "./edit";
|
|
|
6
6
|
import metadata from "./block.json";
|
|
7
7
|
import save from "./save";
|
|
8
8
|
import transforms from "./transforms";
|
|
9
|
+
import variations from "./variations";
|
|
9
10
|
const { name } = metadata;
|
|
10
11
|
const settings = {
|
|
11
12
|
icon,
|
|
@@ -44,7 +45,8 @@ const settings = {
|
|
|
44
45
|
};
|
|
45
46
|
},
|
|
46
47
|
edit,
|
|
47
|
-
save
|
|
48
|
+
save,
|
|
49
|
+
variations
|
|
48
50
|
};
|
|
49
51
|
const init = () => initBlock({ name, metadata, settings });
|
|
50
52
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/heading/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { heading as icon } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __( 'Code is Poetry' ),\n\t\t\tlevel: 2,\n\t\t\ttextAlign: 'center',\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { content, level } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\t\tconst hasContent = content?.trim().length > 0;\n\n\t\t// In the list view, use the block's content as the label.\n\t\t// If the content is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || hasContent ) ) {\n\t\t\treturn customName || content;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn ! hasContent\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: heading level. */\n\t\t\t\t\t\t__( 'Level %s. Empty.' ),\n\t\t\t\t\t\tlevel\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. 1: heading level. 2: heading content. */\n\t\t\t\t\t\t__( 'Level %1$s. %2$s' ),\n\t\t\t\t\t\tlevel,\n\t\t\t\t\t\tcontent\n\t\t\t\t );\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,WAAW,YAAY;AAChC,SAAS,IAAI,eAAe;AAK5B,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AAEvB,MAAM,EAAE,KAAK,IAAI;AAIV,MAAM,WAAW;AAAA,EACvB;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,SAAS,GAAI,gBAAiB;AAAA,MAC9B,OAAO;AAAA,MACP,WAAW;AAAA,IACZ;AAAA,EACD;AAAA,EACA,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,EAAE,SAAS,MAAM,IAAI;AAE3B,UAAM,aAAa,YAAY,UAAU;AACzC,UAAM,aAAa,SAAS,KAAK,EAAE,SAAS;AAI5C,QAAK,YAAY,gBAAiB,cAAc,aAAe;AAC9D,aAAO,cAAc;AAAA,IACtB;AAEA,QAAK,YAAY,iBAAkB;AAClC,aAAO,CAAE,aACN;AAAA;AAAA,QAEA,GAAI,kBAAmB;AAAA,QACvB;AAAA,MACA,IACA;AAAA;AAAA,QAEA,GAAI,kBAAmB;AAAA,QACvB;AAAA,QACA;AAAA,MACA;AAAA,IACJ;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,UACG,WAAW,WAAW,OACtB,kBAAkB,WAAW;AAAA,IACjC;AAAA,EACD;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { heading as icon } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __( 'Code is Poetry' ),\n\t\t\tlevel: 2,\n\t\t\ttextAlign: 'center',\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { content, level } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\t\tconst hasContent = content?.trim().length > 0;\n\n\t\t// In the list view, use the block's content as the label.\n\t\t// If the content is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || hasContent ) ) {\n\t\t\treturn customName || content;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn ! hasContent\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: heading level. */\n\t\t\t\t\t\t__( 'Level %s. Empty.' ),\n\t\t\t\t\t\tlevel\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. 1: heading level. 2: heading content. */\n\t\t\t\t\t\t__( 'Level %1$s. %2$s' ),\n\t\t\t\t\t\tlevel,\n\t\t\t\t\t\tcontent\n\t\t\t\t );\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n\tvariations,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,WAAW,YAAY;AAChC,SAAS,IAAI,eAAe;AAK5B,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,OAAO,gBAAgB;AAEvB,MAAM,EAAE,KAAK,IAAI;AAIV,MAAM,WAAW;AAAA,EACvB;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,SAAS,GAAI,gBAAiB;AAAA,MAC9B,OAAO;AAAA,MACP,WAAW;AAAA,IACZ;AAAA,EACD;AAAA,EACA,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,EAAE,SAAS,MAAM,IAAI;AAE3B,UAAM,aAAa,YAAY,UAAU;AACzC,UAAM,aAAa,SAAS,KAAK,EAAE,SAAS;AAI5C,QAAK,YAAY,gBAAiB,cAAc,aAAe;AAC9D,aAAO,cAAc;AAAA,IACtB;AAEA,QAAK,YAAY,iBAAkB;AAClC,aAAO,CAAE,aACN;AAAA;AAAA,QAEA,GAAI,kBAAmB;AAAA,QACvB;AAAA,MACA,IACA;AAAA;AAAA,QAEA,GAAI,kBAAmB;AAAA,QACvB;AAAA,QACA;AAAA,MACA;AAAA,IACJ;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,UACG,WAAW,WAAW,OACtB,kBAAkB,WAAW;AAAA,IACjC;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { Path, SVG } from "@wordpress/primitives";
|
|
4
|
+
import { heading } from "@wordpress/icons";
|
|
5
|
+
const variations = [
|
|
6
|
+
{
|
|
7
|
+
name: "heading",
|
|
8
|
+
title: __("Heading"),
|
|
9
|
+
description: __(
|
|
10
|
+
"Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content."
|
|
11
|
+
),
|
|
12
|
+
isDefault: true,
|
|
13
|
+
scope: ["inserter", "transform"],
|
|
14
|
+
attributes: { fitText: void 0 },
|
|
15
|
+
icon: heading
|
|
16
|
+
},
|
|
17
|
+
// There is a hardcoded workaround in packages/block-editor/src/store/selectors.js
|
|
18
|
+
// to make Stretchy variations appear as the last of their sections in the inserter.
|
|
19
|
+
{
|
|
20
|
+
name: "stretchy-heading",
|
|
21
|
+
title: __("Stretchy Heading"),
|
|
22
|
+
description: __("Heading that resizes to fit its container."),
|
|
23
|
+
icon: /* @__PURE__ */ jsx(SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx(Path, { d: "m3 18.6 6-4.7 6 4.7V5H3v13.6Zm16.2-9.8v1.5h2.2L17.7 14l1.1 1.1 3.7-3.7v2.2H24V8.8h-4.8Z" }) }),
|
|
24
|
+
attributes: { fitText: true },
|
|
25
|
+
scope: ["inserter", "transform"],
|
|
26
|
+
isActive: (blockAttributes) => blockAttributes.fitText === true
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
var variations_default = variations;
|
|
30
|
+
export {
|
|
31
|
+
variations_default as default
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=variations.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/heading/variations.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Path, SVG } from '@wordpress/primitives';\nimport { heading } from '@wordpress/icons';\n\nconst variations = [\n\t{\n\t\tname: 'heading',\n\t\ttitle: __( 'Heading' ),\n\t\tdescription: __(\n\t\t\t'Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content.'\n\t\t),\n\t\tisDefault: true,\n\t\tscope: [ 'inserter', 'transform' ],\n\t\tattributes: { fitText: undefined },\n\t\ticon: heading,\n\t},\n\t// There is a hardcoded workaround in packages/block-editor/src/store/selectors.js\n\t// to make Stretchy variations appear as the last of their sections in the inserter.\n\t{\n\t\tname: 'stretchy-heading',\n\t\ttitle: __( 'Stretchy Heading' ),\n\t\tdescription: __( 'Heading that resizes to fit its container.' ),\n\t\ticon: (\n\t\t\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">\n\t\t\t\t<Path d=\"m3 18.6 6-4.7 6 4.7V5H3v13.6Zm16.2-9.8v1.5h2.2L17.7 14l1.1 1.1 3.7-3.7v2.2H24V8.8h-4.8Z\" />\n\t\t\t</SVG>\n\t\t),\n\t\tattributes: { fitText: true },\n\t\tscope: [ 'inserter', 'transform' ],\n\t\tisActive: ( blockAttributes ) => blockAttributes.fitText === true,\n\t},\n];\n\nexport default variations;\n"],
|
|
5
|
+
"mappings": "AA2BI;AAxBJ,SAAS,UAAU;AACnB,SAAS,MAAM,WAAW;AAC1B,SAAS,eAAe;AAExB,MAAM,aAAa;AAAA,EAClB;AAAA,IACC,MAAM;AAAA,IACN,OAAO,GAAI,SAAU;AAAA,IACrB,aAAa;AAAA,MACZ;AAAA,IACD;AAAA,IACA,WAAW;AAAA,IACX,OAAO,CAAE,YAAY,WAAY;AAAA,IACjC,YAAY,EAAE,SAAS,OAAU;AAAA,IACjC,MAAM;AAAA,EACP;AAAA;AAAA;AAAA,EAGA;AAAA,IACC,MAAM;AAAA,IACN,OAAO,GAAI,kBAAmB;AAAA,IAC9B,aAAa,GAAI,4CAA6C;AAAA,IAC9D,MACC,oBAAC,OAAI,OAAM,8BAA6B,SAAQ,aAC/C,8BAAC,QAAK,GAAE,2FAA0F,GACnG;AAAA,IAED,YAAY,EAAE,SAAS,KAAK;AAAA,IAC5B,OAAO,CAAE,YAAY,WAAY;AAAA,IACjC,UAAU,CAAE,oBAAqB,gBAAgB,YAAY;AAAA,EAC9D;AACD;AAEA,IAAO,qBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,9 +2,13 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import { createBlock } from "@wordpress/blocks";
|
|
4
4
|
import { useSelect, useDispatch } from "@wordpress/data";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ToolbarButton,
|
|
7
|
+
ToolbarGroup,
|
|
8
|
+
VisuallyHidden
|
|
9
|
+
} from "@wordpress/components";
|
|
6
10
|
import { displayShortcut, isKeyboardEvent } from "@wordpress/keycodes";
|
|
7
|
-
import { __ } from "@wordpress/i18n";
|
|
11
|
+
import { __, sprintf } from "@wordpress/i18n";
|
|
8
12
|
import {
|
|
9
13
|
BlockControls,
|
|
10
14
|
InspectorControls,
|
|
@@ -20,9 +24,15 @@ import { useState, useEffect, useRef, useCallback } from "@wordpress/element";
|
|
|
20
24
|
import { decodeEntities } from "@wordpress/html-entities";
|
|
21
25
|
import { link as linkIcon, addSubmenu } from "@wordpress/icons";
|
|
22
26
|
import { store as coreStore } from "@wordpress/core-data";
|
|
23
|
-
import { useMergeRefs, usePrevious } from "@wordpress/compose";
|
|
27
|
+
import { useMergeRefs, usePrevious, useInstanceId } from "@wordpress/compose";
|
|
24
28
|
import { getColors } from "../navigation/edit/utils";
|
|
25
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
Controls,
|
|
31
|
+
LinkUI,
|
|
32
|
+
updateAttributes,
|
|
33
|
+
useEntityBinding,
|
|
34
|
+
MissingEntityHelpText
|
|
35
|
+
} from "./shared";
|
|
26
36
|
const DEFAULT_BLOCK = { name: "core/navigation-link" };
|
|
27
37
|
const NESTING_BLOCK_NAMES = [
|
|
28
38
|
"core/navigation-link",
|
|
@@ -60,20 +70,30 @@ const useIsInvalidLink = (kind, type, id, enabled) => {
|
|
|
60
70
|
const isPostType = kind === "post-type" || type === "post" || type === "page";
|
|
61
71
|
const hasId = Number.isInteger(id);
|
|
62
72
|
const blockEditingMode = useBlockEditingMode();
|
|
63
|
-
const postStatus = useSelect(
|
|
73
|
+
const { postStatus, isDeleted } = useSelect(
|
|
64
74
|
(select) => {
|
|
65
75
|
if (!isPostType) {
|
|
66
|
-
return null;
|
|
76
|
+
return { postStatus: null, isDeleted: false };
|
|
67
77
|
}
|
|
68
78
|
if (blockEditingMode === "disabled" || !enabled) {
|
|
69
|
-
return null;
|
|
79
|
+
return { postStatus: null, isDeleted: false };
|
|
70
80
|
}
|
|
71
|
-
const { getEntityRecord } = select(coreStore);
|
|
72
|
-
|
|
81
|
+
const { getEntityRecord, hasFinishedResolution } = select(coreStore);
|
|
82
|
+
const entityRecord = getEntityRecord("postType", type, id);
|
|
83
|
+
const hasResolved = hasFinishedResolution("getEntityRecord", [
|
|
84
|
+
"postType",
|
|
85
|
+
type,
|
|
86
|
+
id
|
|
87
|
+
]);
|
|
88
|
+
const deleted = hasResolved && entityRecord === void 0;
|
|
89
|
+
return {
|
|
90
|
+
postStatus: entityRecord?.status,
|
|
91
|
+
isDeleted: deleted
|
|
92
|
+
};
|
|
73
93
|
},
|
|
74
94
|
[isPostType, blockEditingMode, enabled, type, id]
|
|
75
95
|
);
|
|
76
|
-
const isInvalid = isPostType && hasId && postStatus && "trash" === postStatus;
|
|
96
|
+
const isInvalid = isPostType && hasId && (isDeleted || postStatus && "trash" === postStatus);
|
|
77
97
|
const isDraft = "draft" === postStatus;
|
|
78
98
|
return [isInvalid, isDraft];
|
|
79
99
|
};
|
|
@@ -165,7 +185,12 @@ function NavigationLinkEdit({
|
|
|
165
185
|
[clientId, maxNestingLevel]
|
|
166
186
|
);
|
|
167
187
|
const { getBlocks } = useSelect(blockEditorStore);
|
|
168
|
-
const {
|
|
188
|
+
const {
|
|
189
|
+
clearBinding,
|
|
190
|
+
createBinding,
|
|
191
|
+
hasUrlBinding,
|
|
192
|
+
isBoundEntityAvailable
|
|
193
|
+
} = useEntityBinding({
|
|
169
194
|
clientId,
|
|
170
195
|
attributes
|
|
171
196
|
});
|
|
@@ -242,6 +267,9 @@ function NavigationLinkEdit({
|
|
|
242
267
|
setIsLinkOpen(true);
|
|
243
268
|
}
|
|
244
269
|
}
|
|
270
|
+
const instanceId = useInstanceId(NavigationLinkEdit);
|
|
271
|
+
const hasMissingEntity = hasUrlBinding && !isBoundEntityAvailable;
|
|
272
|
+
const missingEntityDescriptionId = hasMissingEntity ? sprintf("navigation-link-edit-%d-desc", instanceId) : void 0;
|
|
245
273
|
const blockProps = useBlockProps({
|
|
246
274
|
ref: useMergeRefs([setPopoverAnchor, listItemRef]),
|
|
247
275
|
className: clsx("wp-block-navigation-item", {
|
|
@@ -254,6 +282,8 @@ function NavigationLinkEdit({
|
|
|
254
282
|
"has-background": !!backgroundColor || customBackgroundColor,
|
|
255
283
|
[getColorClassName("background-color", backgroundColor)]: !!backgroundColor
|
|
256
284
|
}),
|
|
285
|
+
"aria-describedby": missingEntityDescriptionId,
|
|
286
|
+
"aria-invalid": hasMissingEntity,
|
|
257
287
|
style: {
|
|
258
288
|
color: !textColor && customTextColor,
|
|
259
289
|
backgroundColor: !backgroundColor && customBackgroundColor
|
|
@@ -272,13 +302,13 @@ function NavigationLinkEdit({
|
|
|
272
302
|
renderAppender: false
|
|
273
303
|
}
|
|
274
304
|
);
|
|
275
|
-
if (!url || isInvalid || isDraft) {
|
|
305
|
+
if (!url || isInvalid || isDraft || hasUrlBinding && !isBoundEntityAvailable) {
|
|
276
306
|
blockProps.onClick = () => {
|
|
277
307
|
setIsLinkOpen(true);
|
|
278
308
|
};
|
|
279
309
|
}
|
|
280
310
|
const classes = clsx("wp-block-navigation-item__content", {
|
|
281
|
-
"wp-block-navigation-link__placeholder": !url || isInvalid || isDraft
|
|
311
|
+
"wp-block-navigation-link__placeholder": !url || isInvalid || isDraft || hasUrlBinding && !isBoundEntityAvailable
|
|
282
312
|
});
|
|
283
313
|
const missingText = getMissingText(type);
|
|
284
314
|
const placeholderText = `(${isInvalid ? __("Invalid") : __("Draft")})`;
|
|
@@ -315,6 +345,7 @@ function NavigationLinkEdit({
|
|
|
315
345
|
}
|
|
316
346
|
) }),
|
|
317
347
|
/* @__PURE__ */ jsxs("div", { ...blockProps, children: [
|
|
348
|
+
hasMissingEntity && /* @__PURE__ */ jsx(VisuallyHidden, { id: missingEntityDescriptionId, children: /* @__PURE__ */ jsx(MissingEntityHelpText, { type, kind }) }),
|
|
318
349
|
/* @__PURE__ */ jsxs("a", { className: classes, children: [
|
|
319
350
|
!url && !metadata?.bindings?.url ? /* @__PURE__ */ jsx("div", { className: "wp-block-navigation-link__placeholder-text", children: /* @__PURE__ */ jsx("span", { children: missingText }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
320
351
|
!isInvalid && !isDraft && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -374,7 +405,7 @@ function NavigationLinkEdit({
|
|
|
374
405
|
link: attributes,
|
|
375
406
|
onClose: () => {
|
|
376
407
|
setIsLinkOpen(false);
|
|
377
|
-
if (!url) {
|
|
408
|
+
if (!url && !hasUrlBinding) {
|
|
378
409
|
onReplace([]);
|
|
379
410
|
} else if (isNewLink.current) {
|
|
380
411
|
selectBlock(clientId);
|