{"version":3,"file":"edit.cjs","names":["unlock","blockEditorPrivateApis","composePrivateApis","LinkControl","__","useDispatch","blockEditorStore","useSelect","useRefEffect","ENTER","cloneBlock","createBlock","getDefaultBlockName","useToolsPanelDropdownMenuProps","useLinkPreview","ToolsPanel","ToolsPanelItem","TextControl","stripHTML","getSuggestionsQuery","CheckboxControl","ViewLinkButton","isKeyboardEvent","useState","useBorderProps","useColorProps","useSpacingProps","useShadowProps","useBackgroundProps","useDimensionsProps","useRef","useBlockProps","useMergeRefs","useBlockEditingMode","NEW_TAB_TARGET","NOFOLLOW_REL","getBlockBindingsSource","createInterpolateElement","sprintf","removeAnchorTag","getUpdatedLinkAttributes","useMemo","useSettings","useTypographyProps","getWidthClasses","isPercentageWidth","RichText","__experimentalGetElementClassName","BlockControls","ToolbarButton","link","displayShortcut","WCPopover","InspectorControls","Link"],"sources":["../../src/button/edit.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tuseState,\n\tuseRef,\n\tuseMemo,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport {\n\tTextControl,\n\tToolbarButton,\n\tPopover as WCPopover,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tLinkControl,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\tuseBackgroundProps,\n\t__experimentalGetSpacingClassesAndStyles as useSpacingProps,\n\t__experimentalGetShadowClassesAndStyles as useShadowProps,\n\t__experimentalGetDimensionsClassesAndStyles as useDimensionsProps,\n\t__experimentalGetElementClassName,\n\tstore as blockEditorStore,\n\tuseBlockEditingMode,\n\tgetTypographyClassesAndStyles as useTypographyProps,\n\tuseSettings,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { displayShortcut, isKeyboardEvent, ENTER } from '@wordpress/keycodes';\nimport { link } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tcreateBlock,\n\tcloneBlock,\n\tgetDefaultBlockName,\n\tgetBlockBindingsSource,\n} from '@wordpress/blocks';\nimport {\n\tuseMergeRefs,\n\tuseRefEffect,\n\tprivateApis as composePrivateApis,\n} from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { CheckboxControl, Link } from '@wordpress/ui';\nimport { NEW_TAB_TARGET, NOFOLLOW_REL } from './constants';\nimport { getUpdatedLinkAttributes } from './get-updated-link-attributes';\nimport removeAnchorTag from '../utils/remove-anchor-tag';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport { getSuggestionsQuery, useLinkPreview } from '../utils/link-picker';\nimport ViewLinkButton from '../utils/view-link-button';\nimport { unlock } from '../lock-unlock';\nimport useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';\nimport { getWidthClasses, isPercentageWidth } from './utils';\n\nconst { HTMLElementControl, LinkPicker } = unlock( blockEditorPrivateApis );\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\nconst LINK_SETTINGS = [\n\t...LinkControl.DEFAULT_LINK_SETTINGS,\n\t{\n\t\tid: 'nofollow',\n\t\ttitle: __( 'Mark as nofollow' ),\n\t},\n];\n\nfunction useEnter( clientId ) {\n\tconst { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlock,\n\t\tgetBlockAttributes,\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t} = useSelect( blockEditorStore );\n\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented || event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { text } = getBlockAttributes( clientId ) ?? {};\n\t\t\tif ( text?.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\tconst topParentListBlock = getBlock(\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t\tconst blockIndex = getBlockIndex( clientId );\n\t\t\tconst head = cloneBlock( {\n\t\t\t\t...topParentListBlock,\n\t\t\t\tinnerBlocks: topParentListBlock.innerBlocks.slice(\n\t\t\t\t\t0,\n\t\t\t\t\tblockIndex\n\t\t\t\t),\n\t\t\t} );\n\t\t\tconst middle = createBlock( getDefaultBlockName() );\n\t\t\tconst after = topParentListBlock.innerBlocks.slice(\n\t\t\t\tblockIndex + 1\n\t\t\t);\n\t\t\tconst tail = after.length\n\t\t\t\t? [\n\t\t\t\t\t\tcloneBlock( {\n\t\t\t\t\t\t\t...topParentListBlock,\n\t\t\t\t\t\t\tinnerBlocks: after,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t: [];\n\t\t\treplaceBlocks(\n\t\t\t\ttopParentListBlock.clientId,\n\t\t\t\t[ head, middle, ...tail ],\n\t\t\t\t1\n\t\t\t);\n\t\t\t// We manually change the selection here because we are replacing\n\t\t\t// a different block than the selected one.\n\t\t\tselectionChange( middle.clientId );\n\t\t}\n\n\t\t// Capture phase so we run before writing-flow's ancestor-bubble\n\t\t// keydown handlers that gate on `event.defaultPrevented`.\n\t\treturn subscribeDelegatedListener(\n\t\t\telement,\n\t\t\t'keydown',\n\t\t\tonKeyDown,\n\t\t\ttrue\n\t\t);\n\t}, [] );\n}\n\n/**\n * The content controls shown in the block inspector's Content tab and in the\n * List View popover, mirroring the Navigation Link block's panel.\n *\n * The canvas, the link popover, and this panel all write through the same\n * `setText`, `setLink`, and `unlink` so the three surfaces can't drift.\n *\n * @param {Object}                   props\n * @param {string}                   props.text           The button text.\n * @param {string}                   props.url            The button link.\n * @param {boolean}                  props.opensInNewTab  Whether the link opens in a new tab.\n * @param {boolean}                  props.isTextEditable Whether the text field is enabled.\n * @param {boolean}                  props.isLinkEditable Whether the link fields are shown.\n * @param {( text: string ) => void} props.setText        Updates the button text.\n * @param {( link: Object ) => void} props.setLink        Updates the link, new tab, and nofollow attributes.\n * @param {() => void}               props.unlink         Removes the link and its attributes.\n */\nfunction ContentControls( {\n\ttext,\n\turl,\n\topensInNewTab,\n\tisTextEditable,\n\tisLinkEditable,\n\tsetText,\n\tsetLink,\n\tunlink,\n} ) {\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst preview = useLinkPreview( { url } );\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ __( 'Settings' ) }\n\t\t\tresetAll={ () => {\n\t\t\t\tsetText( '' );\n\t\t\t\tunlink();\n\t\t\t} }\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! text?.length }\n\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\tonDeselect={ () => setText( '' ) }\n\t\t\t\tisShownByDefault\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\tvalue={ text ? stripHTML( text.toString() ) : '' }\n\t\t\t\t\tonChange={ setText }\n\t\t\t\t\tdisabled={ ! isTextEditable }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t\t{ isLinkEditable && (\n\t\t\t\t<>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! url }\n\t\t\t\t\t\tlabel={ __( 'Link to' ) }\n\t\t\t\t\t\tonDeselect={ unlink }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkPicker\n\t\t\t\t\t\t\tpreview={ preview }\n\t\t\t\t\t\t\tonSelect={ ( { url: newUrl } ) =>\n\t\t\t\t\t\t\t\tsetLink( { url: newUrl } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Like a navigation link, offer pages before anything is typed.\n\t\t\t\t\t\t\tsuggestionsQuery={ getSuggestionsQuery() }\n\t\t\t\t\t\t\tlabel={ __( 'Link to' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ /* Like the toolbar link popover, only offer the new tab setting once there is a link to open. */ }\n\t\t\t\t\t{ url && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => opensInNewTab }\n\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetLink( { opensInNewTab: false } )\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<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\tchecked={ opensInNewTab }\n\t\t\t\t\t\t\t\tonCheckedChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetLink( { opensInNewTab: value } )\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<ViewLinkButton url={ url } />\n\t\t\t\t</>\n\t\t\t) }\n\t\t</ToolsPanel>\n\t);\n}\n\nfunction ButtonEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tclassName,\n\t\tisSelected,\n\t\tonReplace,\n\t\tmergeBlocks,\n\t\tclientId,\n\t\tcontext,\n\t} = props;\n\tconst {\n\t\ttagName,\n\t\tlinkTarget,\n\t\tplaceholder,\n\t\trel,\n\t\tstyle,\n\t\ttext,\n\t\turl,\n\t\tmetadata,\n\t} = attributes;\n\tconst width = style?.dimensions?.width;\n\n\tuseDeprecatedTextAlign( props );\n\n\tconst TagName = tagName || 'a';\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\tstartEditing( event );\n\t\t} else if ( isKeyboardEvent.primaryShift( event, 'k' ) ) {\n\t\t\tunlink();\n\t\t\trichTextRef.current?.focus();\n\t\t}\n\t}\n\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\n\tconst borderProps = useBorderProps( attributes );\n\tconst colorProps = useColorProps( attributes );\n\tconst spacingProps = useSpacingProps( attributes );\n\tconst shadowProps = useShadowProps( attributes );\n\tconst backgroundProps = useBackgroundProps( attributes );\n\tconst dimensionsProps = useDimensionsProps( attributes );\n\tconst ref = useRef();\n\tconst richTextRef = useRef();\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, ref ] ),\n\t\tonKeyDown,\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\t// Inside a Navigation block every item edits from a Settings panel, so a\n\t// Button there gets one too. Elsewhere it appears only in content-only\n\t// editing, where the toolbar's link controls are hidden.\n\tconst isInsideNavigation = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( blockEditorStore ).getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/navigation'\n\t\t\t).length,\n\t\t[ clientId ]\n\t);\n\tconst hasContentControls =\n\t\tblockEditingMode === 'contentOnly' || isInsideNavigation;\n\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst isURLSet = !! url;\n\tconst opensInNewTab = linkTarget === NEW_TAB_TARGET;\n\tconst nofollow = !! rel?.includes( NOFOLLOW_REL );\n\tconst isLinkTag = 'a' === TagName;\n\n\tconst {\n\t\tcreatePageEntity,\n\t\tuserCanCreatePages,\n\t\tlockUrlControls = false,\n\t\tlockTextControls = false,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst _settings = select( blockEditorStore ).getSettings();\n\n\t\t\t// A bound attribute is locked unless its source lets the user\n\t\t\t// edit the value, which is also what makes the canvas read-only.\n\t\t\tconst isLocked = ( binding ) =>\n\t\t\t\t!! binding &&\n\t\t\t\t! getBlockBindingsSource( binding.source )?.canUserEditValue?.(\n\t\t\t\t\t{\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\targs: binding.args,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tcreatePageEntity: _settings.__experimentalCreatePageEntity,\n\t\t\t\tuserCanCreatePages: _settings.__experimentalUserCanCreatePages,\n\t\t\t\tlockUrlControls: isLocked( metadata?.bindings?.url ),\n\t\t\t\tlockTextControls: isLocked( metadata?.bindings?.text ),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tcontext,\n\t\t\tisSelected,\n\t\t\tmetadata?.bindings?.url,\n\t\t\tmetadata?.bindings?.text,\n\t\t]\n\t);\n\n\tasync function handleCreate( pageTitle ) {\n\t\tconst page = await createPageEntity( {\n\t\t\ttitle: pageTitle,\n\t\t\tstatus: 'draft',\n\t\t} );\n\n\t\treturn {\n\t\t\tid: page.id,\n\t\t\ttype: page.type,\n\t\t\ttitle: page.title.rendered,\n\t\t\turl: page.link,\n\t\t\tkind: 'post-type',\n\t\t};\n\t}\n\n\tfunction createButtonText( searchTerm ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create page: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\tfunction startEditing( event ) {\n\t\tevent.preventDefault();\n\t\tsetIsEditingURL( true );\n\t}\n\n\t// The canvas, the link popover, and the content panel write through\n\t// these so the three can't drift.\n\tfunction setText( value ) {\n\t\t// A link inside the button's own link is invalid HTML.\n\t\tsetAttributes( { text: removeAnchorTag( value ) } );\n\t}\n\n\tfunction setLink( changes ) {\n\t\tsetAttributes(\n\t\t\tgetUpdatedLinkAttributes( {\n\t\t\t\trel,\n\t\t\t\turl,\n\t\t\t\topensInNewTab,\n\t\t\t\tnofollow,\n\t\t\t\t...changes,\n\t\t\t} )\n\t\t);\n\t}\n\n\tfunction unlink() {\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlinkTarget: undefined,\n\t\t\trel: undefined,\n\t\t} );\n\t\tsetIsEditingURL( false );\n\t}\n\n\t// Close the link popover when the block is deselected.\n\tif ( ! isSelected && isEditingURL ) {\n\t\tsetIsEditingURL( false );\n\t}\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/51256.\n\tconst linkValue = useMemo(\n\t\t() => ( { url, opensInNewTab, nofollow } ),\n\t\t[ url, opensInNewTab, nofollow ]\n\t);\n\n\tconst useEnterRef = useEnter( clientId );\n\tconst mergedRef = useMergeRefs( [ useEnterRef, richTextRef ] );\n\n\tconst [ fluidTypographySettings, layout, dimensionSizes ] = useSettings(\n\t\t'typography.fluid',\n\t\t'layout',\n\t\t'dimensions.dimensionSizes'\n\t);\n\tconst dimensionPresets = useMemo( () => {\n\t\tif ( ! dimensionSizes ) {\n\t\t\treturn [];\n\t\t}\n\t\treturn [\n\t\t\t...( dimensionSizes?.custom ?? [] ),\n\t\t\t...( dimensionSizes?.theme ?? [] ),\n\t\t\t...( dimensionSizes?.default ?? [] ),\n\t\t];\n\t}, [ dimensionSizes ] );\n\tconst typographyProps = useTypographyProps( attributes, {\n\t\ttypography: {\n\t\t\tfluid: fluidTypographySettings,\n\t\t},\n\t\tlayout: {\n\t\t\twideSize: layout?.wideSize,\n\t\t},\n\t} );\n\n\t// Resolve preset dimension references to their actual values.\n\tconst resolvedWidth = useMemo( () => {\n\t\tif ( ! width ) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst presetPrefix = 'var:preset|dimension|';\n\t\tif ( width.startsWith( presetPrefix ) ) {\n\t\t\tconst slug = width.slice( presetPrefix.length );\n\t\t\tconst preset = dimensionPresets?.find( ( p ) => p.slug === slug );\n\t\t\treturn preset?.size ?? width;\n\t\t}\n\t\treturn width;\n\t}, [ width, dimensionPresets ] );\n\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\tconst hasBlockControls =\n\t\thasNonContentControls || ( isLinkTag && ! lockUrlControls );\n\tconst classes = clsx(\n\t\tblockProps.className,\n\t\tgetWidthClasses( resolvedWidth )\n\t);\n\n\tconst widthStyle = useMemo( () => {\n\t\tif ( ! width ) {\n\t\t\treturn {};\n\t\t}\n\t\tif ( isPercentageWidth( resolvedWidth ) ) {\n\t\t\treturn {\n\t\t\t\t'--wp--block-button--width': parseFloat( resolvedWidth ),\n\t\t\t};\n\t\t}\n\t\treturn dimensionsProps.style;\n\t}, [ width, resolvedWidth, dimensionsProps.style ] );\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ classes }\n\t\t\t\tstyle={ { ...blockProps.style, ...widthStyle } }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tref={ mergedRef }\n\t\t\t\t\taria-label={ __( 'Button text' ) }\n\t\t\t\t\tplaceholder={ placeholder || __( 'Add text…' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tonChange={ setText }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'wp-block-button__link',\n\t\t\t\t\t\tcolorProps.className,\n\t\t\t\t\t\tbackgroundProps.className,\n\t\t\t\t\t\tborderProps.className,\n\t\t\t\t\t\ttypographyProps.className,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// For backwards compatibility add style that isn't\n\t\t\t\t\t\t\t// provided via block support.\n\t\t\t\t\t\t\t'no-border-radius': style?.border?.radius === 0,\n\t\t\t\t\t\t\t[ `has-custom-font-size` ]:\n\t\t\t\t\t\t\t\tblockProps.style.fontSize,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t__experimentalGetElementClassName( 'button' )\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t\t...colorProps.style,\n\t\t\t\t\t\t...backgroundProps.style,\n\t\t\t\t\t\t...spacingProps.style,\n\t\t\t\t\t\t...shadowProps.style,\n\t\t\t\t\t\t...typographyProps.style,\n\t\t\t\t\t\twritingMode: undefined,\n\t\t\t\t\t} }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tidentifier=\"text\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t{ hasBlockControls && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t{ isLinkTag && ! lockUrlControls && (\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={ link }\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={ () => setIsEditingURL( ! isEditingURL ) }\n\t\t\t\t\t\t\tisActive={ isURLSet }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isLinkTag && isSelected && isEditingURL && ! lockUrlControls && (\n\t\t\t\t<WCPopover\n\t\t\t\t\tplacement=\"bottom\"\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t} }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tfocusOnMount={ isEditingURL ? 'firstElement' : false }\n\t\t\t\t\t__unstableSlotName=\"__unstable-block-tools-after\"\n\t\t\t\t\tshift\n\t\t\t\t>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\tvalue={ linkValue }\n\t\t\t\t\t\tonChange={ setLink }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tunlink();\n\t\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tforceIsEditingLink={ ! isURLSet }\n\t\t\t\t\t\tsettings={ LINK_SETTINGS }\n\t\t\t\t\t\tcreateSuggestion={ createPageEntity && handleCreate }\n\t\t\t\t\t\twithCreateSuggestion={ userCanCreatePages }\n\t\t\t\t\t\tcreateSuggestionButtonText={ createButtonText }\n\t\t\t\t\t/>\n\t\t\t\t</WCPopover>\n\t\t\t) }\n\t\t\t{ hasContentControls && (\n\t\t\t\t<InspectorControls group=\"content\">\n\t\t\t\t\t<ContentControls\n\t\t\t\t\t\ttext={ text }\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\topensInNewTab={ opensInNewTab }\n\t\t\t\t\t\tisTextEditable={ ! lockTextControls }\n\t\t\t\t\t\tisLinkEditable={ isLinkTag && ! lockUrlControls }\n\t\t\t\t\t\tsetText={ setText }\n\t\t\t\t\t\tsetLink={ setLink }\n\t\t\t\t\t\tunlink={ unlink }\n\t\t\t\t\t/>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<HTMLElementControl\n\t\t\t\t\ttagName={ tagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<a>)' ), value: 'a' },\n\t\t\t\t\t\t{ label: '<button>', value: 'button' },\n\t\t\t\t\t] }\n\t\t\t\t/>\n\t\t\t\t{ isLinkTag && (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Link relation' ) }\n\t\t\t\t\t\thelp={ createInterpolateElement(\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\t\topenInNewTab\n\t\t\t\t\t\t\t\t\t\thref=\"https://developer.mozilla.org/docs/Web/HTML/Attributes/rel\"\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) }\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n}\n\nexport default ButtonEdit;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,EAAE,oBAAoB,gBAAA,GAAeA,kBAAAA,OAAAA,CAAQC,wBAAAA,WAAuB;AAC1E,MAAM,EAAE,gCAAA,GAA+BD,kBAAAA,OAAAA,CAAQE,mBAAAA,WAAmB;AAElE,MAAM,gBAAgB,CACrB,GAAGC,wBAAAA,YAAY,uBACf;CACC,IAAI;CACJ,QAAA,GAAOC,gBAAAA,GAAAA,CAAI,kBAAmB;AAC/B,CACD;AAEA,SAAS,SAAU,UAAW;CAC7B,MAAM,EAAE,eAAe,qBAAA,GAAoBC,gBAAAA,YAAAA,CAAaC,wBAAAA,KAAiB;CACzE,MAAM,EACL,UACA,oBACA,sBACA,mBAAA,GACGC,gBAAAA,UAAAA,CAAWD,wBAAAA,KAAiB;CAEhC,QAAA,GAAOE,mBAAAA,aAAAA,EAAgB,YAAa;EACnC,SAAS,UAAW,OAAQ;GAC3B,IAAK,MAAM,oBAAoB,MAAM,YAAYC,oBAAAA,OAChD;GAED,MAAM,EAAE,SAAS,mBAAoB,QAAS,KAAK,CAAC;GACpD,IAAK,MAAM,QACV;GAED,MAAM,eAAe;GACrB,MAAM,qBAAqB,SAC1B,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