Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/block-components/helpers/link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
*/
import { __ } from '@wordpress/i18n'
import { useAttributeEditHandlers } from '~stackable/hooks'
import { useState } from '@wordpress/element'

export const LinkControls = props => {
const {
Expand All @@ -23,9 +24,13 @@ export const LinkControls = props => {

const {
getAttribute,
updateAttribute,
updateAttributeHandler,
} = useAttributeEditHandlers( props.attrNameTemplate )

const [ rel, setRel ] = useState( getAttribute( 'rel' ) )
const [ title, setTitle ] = useState( getAttribute( 'title' ) )

const url = getAttribute( 'url' ) || ''

const showGoogleMapHint = getAttribute( 'hasLightbox' ) &&
Expand Down Expand Up @@ -70,14 +75,20 @@ export const LinkControls = props => {
<AdvancedTextControl
label={ __( 'Link rel', i18n ) }
help={ __( 'Link relationship keywords, e.g. nofollow noreferrer prefetch', i18n ) }
value={ getAttribute( 'rel' ) }
onChange={ updateAttributeHandler( 'rel' ) }
value={ rel }
onChange={ value => {
setRel( value )
updateAttribute( 'rel', value )
} }
/>
{ ( hasTitle || getAttribute( 'hasTitle' ) ) && (
<AdvancedTextControl
label={ __( 'Link Title', i18n ) }
value={ getAttribute( 'title' ) }
onChange={ updateAttributeHandler( 'title' ) }
value={ title }
onChange={ value => {
setTitle( value )
updateAttribute( 'title', value )
} }
isDynamic={ true }
isFormatType={ false }
help={ __( 'Also used for lightbox caption', i18n ) }
Expand Down
Loading