From 6e8ea2e1568680c29fa975faec98218d760ef642 Mon Sep 17 00:00:00 2001
From: Zebulan Stanphill <zebulanstanphill@protonmail.com>
Date: Fri, 22 May 2020 00:05:27 -0500
Subject: [PATCH] Add RichText split/merge/remove to Navigation Links.

---
 packages/block-library/src/navigation-link/edit.js  | 11 +++++++++++
 packages/block-library/src/navigation-link/index.js | 11 +++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js
index d5ec274a05470b..a2f50b80dd1f89 100644
--- a/packages/block-library/src/navigation-link/edit.js
+++ b/packages/block-library/src/navigation-link/edit.js
@@ -57,6 +57,9 @@ function NavigationLinkEdit( {
 	saveEntityRecord,
 	selectedBlockHasDescendants,
 	userCanCreatePages = false,
+	insertBlocksAfter,
+	mergeBlocks,
+	onReplace,
 } ) {
 	const { label, opensInNewTab, url, nofollow, description } = attributes;
 	const link = {
@@ -221,11 +224,19 @@ function NavigationLinkEdit( {
 				<div className="wp-block-navigation-link__content">
 					<RichText
 						ref={ ref }
+						identifier="label"
 						className="wp-block-navigation-link__label"
 						value={ label }
 						onChange={ ( labelValue ) =>
 							setAttributes( { label: labelValue } )
 						}
+						onMerge={ mergeBlocks }
+						onReplace={ onReplace }
+						__unstableOnSplitAtEnd={ () =>
+							insertBlocksAfter(
+								createBlock( 'core/navigation-link' )
+							)
+						}
 						placeholder={ itemLabelPlaceholder }
 						keepPlaceholderOnFocus
 						withoutInteractiveFormatting
diff --git a/packages/block-library/src/navigation-link/index.js b/packages/block-library/src/navigation-link/index.js
index 05269059437104..99ab5ebfb193e0 100644
--- a/packages/block-library/src/navigation-link/index.js
+++ b/packages/block-library/src/navigation-link/index.js
@@ -12,17 +12,20 @@ import edit from './edit';
 import save from './save';
 
 const { name } = metadata;
+
 export { metadata, name };
 
 export const settings = {
 	title: __( 'Navigation Link' ),
-
 	icon,
-
 	description: __( 'Add a page, link, or another item to your navigation.' ),
-
 	__experimentalLabel: ( { label } ) => label,
-
+	merge( leftAttributes, { label: rightLabel = '' } ) {
+		return {
+			...leftAttributes,
+			label: leftAttributes.label + rightLabel,
+		};
+	},
 	edit,
 	save,
 };