UNPKG

@wordpress/block-library

Version:
101 lines (85 loc) 1.76 kB
/** * WordPress dependencies */ import { _x } from '@wordpress/i18n'; import { customLink as linkIcon } from '@wordpress/icons'; import { InnerBlocks } from '@wordpress/block-editor'; import { addFilter } from '@wordpress/hooks'; /** * Internal dependencies */ import initBlock from '../utils/init-block'; import metadata from './block.json'; import edit from './edit'; import save from './save'; import { enhanceNavigationLinkVariations } from './hooks'; import transforms from './transforms'; const { name } = metadata; export { metadata, name }; export const settings = { icon: linkIcon, __experimentalLabel: ( { label } ) => label, merge( leftAttributes, { label: rightLabel = '' } ) { return { ...leftAttributes, label: leftAttributes.label + rightLabel, }; }, edit, save, example: { attributes: { label: _x( 'Example Link', 'navigation link preview example' ), url: 'https://example.com', }, }, deprecated: [ { isEligible( attributes ) { return attributes.nofollow; }, attributes: { label: { type: 'string', }, type: { type: 'string', }, nofollow: { type: 'boolean', }, description: { type: 'string', }, id: { type: 'number', }, opensInNewTab: { type: 'boolean', default: false, }, url: { type: 'string', }, }, migrate( { nofollow, ...rest } ) { return { rel: nofollow ? 'nofollow' : '', ...rest, }; }, save() { return <InnerBlocks.Content />; }, }, ], transforms, }; export const init = () => { addFilter( 'blocks.registerBlockType', 'core/navigation-link', enhanceNavigationLinkVariations ); return initBlock( { name, metadata, settings } ); };