Commit 5fb9b45aa46 for woocommerce

commit 5fb9b45aa4674d65aeb739e11942da94bd188e2c
Author: Pavel Dohnal <pavel.dohnal@automattic.com>
Date:   Wed Dec 2 14:45:51 2026 +0100

    Make email template editing easier to find (#71534)

    * Show a direct Edit template link in the sidebar

    Edit template was hidden inside a dropdown opened from the template
    name, which looked like a plain value. Make it a visible link and keep
    the dropdown only when there is another template to swap to.

    * Let people select the template header and footer

    The template around the email content was locked: nothing showed on
    hover, and only an undiscoverable double-click opened the template.
    People couldn't find how to change the logo, header or footer.

    Treat the template blocks around the content the way core treats
    template parts: they can be selected while the blocks inside stay
    locked. They get a purple outline, and the toolbar shows the template
    name and an Edit template button. Double-click still asks before
    opening the template, and no blocks can be added to them.

    This replaces the canvas button that only showed on hover over the
    site logo or title.

    * Hide style warnings for blocks that can't be styled

    Selecting a template area showed the Background and Border email client
    warnings with no controls next to them, because the area is locked.
    Only show them for blocks whose styles can be changed.

    * Only make template groups selectable

    Making every template block around the content selectable also made a
    lone Site Title block in the WooCommerce template editable in place,
    with its settings in the sidebar. Changes there would edit the template,
    or the site name, from the email. Core avoids this by doing it only for
    template parts, whose own content can't be edited.

    Only treat groups as template areas. Other template blocks stay locked
    as before.

    * Ask before opening the template from the toolbar

    The toolbar's Edit template button opened the template straight away,
    while the sidebar link and double-click first warn that the template is
    shared by other emails. Show the same warning from all three.

    Also shorten the package changelog entry to what changed for merchants.

    * Stop shadowing select in the template area toolbar

    * Describe the template editing change without promising a header button

    The default WooCommerce template's header is a lone site title or logo,
    which stays locked, so the entry promised a header button it doesn't get.

    * Keep the header Edit template button for a lone site logo or title

    WooCommerce's default template puts a bare site logo or title above the
    email content, not a group, so it doesn't become a template area. The
    canvas button that WooCommerce 11.3.1 shows there was removed, which
    left the WooCommerce header with no way into the template.

    Bring that button back for site logos and titles that aren't inside a
    template area, so MailPoet's grouped header doesn't get both. It now
    asks before opening the template, like the other entry points.

    * Close the edit template confirmation once the template opens

    The confirmation opened the template but stayed open in state. The
    header button stays mounted while the template is open, so going back
    to the email showed the confirmation again. Close it after opening the
    template, which covers every place that uses it.

    * Make the header Edit template button look like the footer toolbar

    On the default WooCommerce template the header uses the canvas button
    while the footer uses the block toolbar, and they looked like two
    different features: a blue frame and a "Template" label against a
    purple outline and the template name. Use the same purple outline,
    outline width and template name on the canvas button.

    * Add a browser test for opening the template from the canvas

    The unit tests mock the block editing modes and block filters that the
    template area toolbar relies on, so a Gutenberg change could break it
    without a failing test. Open the template from the footer toolbar and
    from the header button on the default WooCommerce template, and check
    the template editor loads.

    * Match the header button's hover colour to the footer toolbar

    The header Edit template button turned purple on hover and focus,
    while the footer's core toolbar button turns the admin colour. Keep the
    purple on the outline only, use the admin colour and focus width on the
    button, and leave a 2px gap so the wider outline doesn't cover the logo.

    * Find a site logo or title outside a template group for the header button

    The header button looked only at the first site logo or title, and
    gave up when that one sat inside a template group. A template with a
    grouped logo and a separate site title then left the title without a
    way into the template. Use the first one outside a template group.

diff --git a/packages/js/email-editor/changelog/update-stomail-8783-template-area-toolbar b/packages/js/email-editor/changelog/update-stomail-8783-template-area-toolbar
new file mode 100644
index 00000000000..9a2790458fb
--- /dev/null
+++ b/packages/js/email-editor/changelog/update-stomail-8783-template-area-toolbar
@@ -0,0 +1,4 @@
+Significance: minor
+Type: update
+
+Make the email template easier to find, with an Edit template option in the email canvas and in the sidebar.
diff --git a/packages/js/email-editor/src/blocks/core/template-area.tsx b/packages/js/email-editor/src/blocks/core/template-area.tsx
new file mode 100644
index 00000000000..69f6d897bae
--- /dev/null
+++ b/packages/js/email-editor/src/blocks/core/template-area.tsx
@@ -0,0 +1,146 @@
+/**
+ * External dependencies
+ */
+import clsx from 'clsx';
+import { BlockControls } from '@wordpress/block-editor';
+import { ToolbarButton } from '@wordpress/components';
+import { createHigherOrderComponent } from '@wordpress/compose';
+import { select, useSelect } from '@wordpress/data';
+import { useState } from '@wordpress/element';
+import { __ } from '@wordpress/i18n';
+
+/**
+ * Internal dependencies
+ */
+import { addFilterForEmail } from '../../config-tools/filters';
+import {
+	getTemplateAreaClientIds,
+	isTemplateAreaEditingEnabled,
+	useIsTemplateArea,
+} from '../../components/template-areas';
+import { EditTemplateModal } from '../../components/sidebar/edit-template-modal';
+import { recordEvent } from '../../events';
+import { storeName } from '../../store';
+
+function TemplateAreaToolbar() {
+	const template = useSelect(
+		( sel ) => sel( storeName ).getCurrentTemplate(),
+		[]
+	);
+	const [ isModalOpen, setIsModalOpen ] = useState( false );
+
+	return (
+		<>
+			<BlockControls group="other">
+				<span className="woocommerce-email-editor-template-area__label">
+					{ template?.title }
+				</span>
+				<ToolbarButton
+					onClick={ () => {
+						recordEvent( 'template_area_edit_template_clicked', {
+							templateId: template?.id,
+						} );
+						setIsModalOpen( true );
+					} }
+				>
+					{ __( 'Edit template', __i18n_text_domain__ ) }
+				</ToolbarButton>
+			</BlockControls>
+			{ isModalOpen && (
+				<EditTemplateModal close={ () => setIsModalOpen( false ) } />
+			) }
+		</>
+	);
+}
+
+/**
+ * Adds the template name and an "Edit template" button to the toolbar of the
+ * template blocks around the email content.
+ */
+export const withTemplateAreaToolbar = createHigherOrderComponent(
+	( BlockEdit ) =>
+		function TemplateAreaBlockEdit( props ) {
+			const isTemplateArea = useIsTemplateArea( props.clientId );
+			return (
+				<>
+					{ isTemplateArea && <TemplateAreaToolbar /> }
+					<BlockEdit { ...props } />
+				</>
+			);
+		},
+	'withTemplateAreaToolbar'
+);
+
+/**
+ * Marks the template blocks for the outline styles and asks before opening the
+ * template on double-click, as core does when you double-click a template.
+ */
+export const withTemplateAreaFrame = createHigherOrderComponent(
+	( BlockListBlock ) =>
+		function TemplateAreaBlockListBlock( props ) {
+			const isTemplateArea = useIsTemplateArea( props.clientId );
+			const [ isModalOpen, setIsModalOpen ] = useState( false );
+
+			if ( ! isTemplateArea ) {
+				return <BlockListBlock { ...props } />;
+			}
+
+			return (
+				<>
+					<BlockListBlock
+						{ ...props }
+						className={ clsx(
+							props.className,
+							'is-email-template-area'
+						) }
+						wrapperProps={ {
+							...props.wrapperProps,
+							onDoubleClick: () => setIsModalOpen( true ),
+						} }
+					/>
+					{ isModalOpen && (
+						<EditTemplateModal
+							close={ () => setIsModalOpen( false ) }
+						/>
+					) }
+				</>
+			);
+		},
+	'withTemplateAreaFrame'
+);
+
+/**
+ * Template areas can be selected, but their content belongs to the template, so
+ * no blocks can be added to them from the email.
+ */
+export function preventInsertingIntoTemplateAreas(
+	canInsert: boolean,
+	_blockType: unknown,
+	rootClientId: string | null
+): boolean {
+	if ( ! canInsert || ! rootClientId ) {
+		return canInsert;
+	}
+	return ! (
+		isTemplateAreaEditingEnabled( select ) &&
+		getTemplateAreaClientIds( select ).includes( rootClientId )
+	);
+}
+
+export function enableTemplateAreaTools(): void {
+	addFilterForEmail(
+		'editor.BlockEdit',
+		'woocommerce-email-editor/template-area-toolbar',
+		withTemplateAreaToolbar
+	);
+	addFilterForEmail(
+		'editor.BlockListBlock',
+		'woocommerce-email-editor/template-area-frame',
+		withTemplateAreaFrame
+	);
+	addFilterForEmail(
+		'blockEditor.__unstableCanInsertBlockType',
+		'woocommerce-email-editor/template-area-insert',
+		preventInsertingIntoTemplateAreas
+	);
+}
diff --git a/packages/js/email-editor/src/blocks/core/test/template-area.spec.tsx b/packages/js/email-editor/src/blocks/core/test/template-area.spec.tsx
new file mode 100644
index 00000000000..c83f32044cb
--- /dev/null
+++ b/packages/js/email-editor/src/blocks/core/test/template-area.spec.tsx
@@ -0,0 +1,137 @@
+/**
+ * External dependencies
+ */
+import { fireEvent, render, screen } from '@testing-library/react';
+import '@testing-library/jest-dom';
+import { useSelect } from '@wordpress/data';
+
+/**
+ * Internal dependencies
+ */
+import {
+	preventInsertingIntoTemplateAreas,
+	withTemplateAreaFrame,
+	withTemplateAreaToolbar,
+} from '../template-area';
+import {
+	getTemplateAreaClientIds,
+	isTemplateAreaEditingEnabled,
+	useIsTemplateArea,
+} from '../../../components/template-areas';
+import { recordEvent } from '../../../events';
+
+jest.mock( '@wordpress/data', () => ( {
+	select: jest.fn(),
+	useSelect: jest.fn(),
+} ) );
+jest.mock( '@wordpress/editor', () => ( { store: 'core/editor' } ) );
+jest.mock( '../../../store', () => ( { storeName: 'email-editor' } ) );
+jest.mock( '@wordpress/block-editor', () => ( {
+	BlockControls: ( { children } ) => <div>{ children }</div>,
+	store: 'core/block-editor',
+} ) );
+jest.mock( '@wordpress/components', () => ( {
+	ToolbarButton: ( { children, onClick } ) => (
+		<button onClick={ onClick }>{ children }</button>
+	),
+} ) );
+jest.mock( '@wordpress/compose', () => ( {
+	createHigherOrderComponent: ( hoc ) => hoc,
+} ) );
+jest.mock( '../../../components/template-areas', () => ( {
+	getTemplateAreaClientIds: jest.fn(),
+	isTemplateAreaEditingEnabled: jest.fn(),
+	useIsTemplateArea: jest.fn(),
+} ) );
+jest.mock( '../../../components/sidebar/edit-template-modal', () => ( {
+	EditTemplateModal: () => <div>Confirm editing the template</div>,
+} ) );
+jest.mock( '../../../events', () => ( { recordEvent: jest.fn() } ) );
+jest.mock( '../../../config-tools/filters', () => ( {
+	addFilterForEmail: jest.fn(),
+} ) );
+
+const BlockEdit = () => <p>Block content</p>;
+const BlockListBlock = ( { className, wrapperProps } ) => (
+	<div
+		data-testid="block"
+		className={ className }
+		onDoubleClick={ wrapperProps?.onDoubleClick }
+	/>
+);
+const ToolbarBlockEdit = withTemplateAreaToolbar( BlockEdit );
+const FramedBlock = withTemplateAreaFrame( BlockListBlock );
+
+describe( 'template area tools', () => {
+	beforeEach( () => {
+		jest.clearAllMocks();
+		( useSelect as jest.Mock ).mockImplementation( ( selector ) =>
+			selector( () => ( {
+				getCurrentTemplate: () => ( {
+					id: 'theme//newsletter',
+					title: 'Newsletter',
+				} ),
+			} ) )
+		);
+	} );
+
+	it( 'shows the template name and an Edit template button that asks before opening the template', () => {
+		( useIsTemplateArea as jest.Mock ).mockReturnValue( true );
+
+		render( <ToolbarBlockEdit clientId="header" /> );
+		fireEvent.click( screen.getByText( 'Edit template' ) );
+
+		expect( screen.getByText( 'Newsletter' ) ).toBeInTheDocument();
+		expect(
+			screen.getByText( 'Confirm editing the template' )
+		).toBeInTheDocument();
+		expect( recordEvent ).toHaveBeenCalledWith(
+			'template_area_edit_template_clicked',
+			{ templateId: 'theme//newsletter' }
+		);
+	} );
+
+	it( 'adds nothing to blocks outside the template areas', () => {
+		( useIsTemplateArea as jest.Mock ).mockReturnValue( false );
+
+		render( <ToolbarBlockEdit clientId="paragraph" /> );
+		render( <FramedBlock clientId="paragraph" className="wp-block" /> );
+
+		expect( screen.queryByText( 'Edit template' ) ).not.toBeInTheDocument();
+		expect( screen.getByTestId( 'block' ) ).toHaveClass( 'wp-block', {
+			exact: true,
+		} );
+	} );
+
+	it( 'marks a template area and asks before opening the template on double-click', () => {
+		( useIsTemplateArea as jest.Mock ).mockReturnValue( true );
+
+		render( <FramedBlock clientId="footer" className="wp-block" /> );
+		fireEvent.doubleClick( screen.getByTestId( 'block' ) );
+
+		expect( screen.getByTestId( 'block' ) ).toHaveClass(
+			'wp-block',
+			'is-email-template-area'
+		);
+		expect(
+			screen.getByText( 'Confirm editing the template' )
+		).toBeInTheDocument();
+	} );
+
+	it( 'stops blocks from being added inside a template area', () => {
+		( isTemplateAreaEditingEnabled as jest.Mock ).mockReturnValue( true );
+		( getTemplateAreaClientIds as jest.Mock ).mockReturnValue( [
+			'header',
+		] );
+
+		expect( preventInsertingIntoTemplateAreas( true, {}, 'header' ) ).toBe(
+			false
+		);
+		expect( preventInsertingIntoTemplateAreas( true, {}, 'content' ) ).toBe(
+			true
+		);
+		expect(
+			preventInsertingIntoTemplateAreas( false, {}, 'content' )
+		).toBe( false );
+	} );
+} );
diff --git a/packages/js/email-editor/src/blocks/index.ts b/packages/js/email-editor/src/blocks/index.ts
index ae49c1abaef..69465890db7 100644
--- a/packages/js/email-editor/src/blocks/index.ts
+++ b/packages/js/email-editor/src/blocks/index.ts
@@ -31,6 +31,7 @@ import { enhanceSocialLinksBlock } from './core/social-links';
 import { enhanceSiteLogoBlock } from './core/site-logo';
 import { enhanceSiteTitleBlock } from './core/site-title';
 import { enableFullWidthBlocks } from './core/full-width';
+import { enableTemplateAreaTools } from './core/template-area';
 import { enableProductImageAlignment } from './woocommerce/product-image';

 export { getAllowedBlockNames } from './utils';
@@ -59,6 +60,7 @@ export function initBlocks() {
 	enhanceSiteLogoBlock();
 	enhanceSiteTitleBlock();
 	enableFullWidthBlocks();
+	enableTemplateAreaTools();
 	enableProductImageAlignment();
 	removeBlockStylesFromAllBlocks();
 }
diff --git a/packages/js/email-editor/src/components/block-editor/editor.tsx b/packages/js/email-editor/src/components/block-editor/editor.tsx
index 85ae4768168..34d6850fb73 100644
--- a/packages/js/email-editor/src/components/block-editor/editor.tsx
+++ b/packages/js/email-editor/src/components/block-editor/editor.tsx
@@ -45,6 +45,7 @@ import { PublishSave } from '../../hacks/publish-save';
 import { EditorNotices } from '../notices';
 import { BlockCompatibilityWarnings } from '../sidebar';
 import { BackButtonContent } from '../header/back-button-content';
+import { TemplateAreaEditingMode } from '../template-areas';
 import { TemplateCanvasAffordance } from '../template-canvas-affordance';
 import { recordEventOnce } from '../../events';

@@ -201,6 +202,7 @@ export function InnerEditor( {
 					<EditorKeyboardShortcutsRegister />
 					<PostLockedModal />
 					<TemplateSelection />
+					<TemplateAreaEditingMode />
 					<TemplateCanvasAffordance />
 					<StylesSidebar />
 					<SendPreview />
diff --git a/packages/js/email-editor/src/components/block-editor/style.scss b/packages/js/email-editor/src/components/block-editor/style.scss
index c7e503e23e8..12d2ea3aa5d 100644
--- a/packages/js/email-editor/src/components/block-editor/style.scss
+++ b/packages/js/email-editor/src/components/block-editor/style.scss
@@ -92,3 +92,11 @@
 	margin-left: auto;
 	margin-right: 0;
 }
+
+.woocommerce-email-editor-template-area__label {
+	align-items: center;
+	display: flex;
+	font-weight: 500;
+	padding-inline: 8px;
+	white-space: nowrap;
+}
diff --git a/packages/js/email-editor/src/components/sidebar/block-compatibility-warnings.tsx b/packages/js/email-editor/src/components/sidebar/block-compatibility-warnings.tsx
index f9589a32e66..7b4fb80cc26 100644
--- a/packages/js/email-editor/src/components/sidebar/block-compatibility-warnings.tsx
+++ b/packages/js/email-editor/src/components/sidebar/block-compatibility-warnings.tsx
@@ -16,11 +16,24 @@ export const hasBackgroundImageSupport = ( nameOrType: string ) => {
 };

 export function BlockCompatibilityWarnings(): JSX.Element {
-	// Select the currently selected block
-	const selectedBlock = useSelect(
-		( sel ) => sel( 'core/block-editor' ).getSelectedBlock(),
-		[]
-	);
+	const { selectedBlock, canChangeStyles } = useSelect( ( sel ) => {
+		const blockEditor = sel( 'core/block-editor' );
+		// getBlockEditingMode is missing from the block editor store types.
+		const { getBlockEditingMode } = blockEditor as unknown as {
+			getBlockEditingMode: ( clientId: string ) => string;
+		};
+		const clientId = blockEditor.getSelectedBlockClientId();
+		return {
+			selectedBlock: blockEditor.getSelectedBlock(),
+			// Template areas are locked, so there are no style controls to warn about.
+			canChangeStyles:
+				!! clientId && getBlockEditingMode( clientId ) === 'default',
+		};
+	}, [] );
+
+	if ( ! canChangeStyles ) {
+		return null;
+	}

 	// Check if the selected block has enabled border configuration
 	const hasBorderSupport =
diff --git a/packages/js/email-editor/src/components/sidebar/edit-template-modal.tsx b/packages/js/email-editor/src/components/sidebar/edit-template-modal.tsx
index 9fa778e82fe..ec1332a4ab3 100644
--- a/packages/js/email-editor/src/components/sidebar/edit-template-modal.tsx
+++ b/packages/js/email-editor/src/components/sidebar/edit-template-modal.tsx
@@ -60,6 +60,8 @@ export function EditTemplateModal( { close } ) {
 								postId: template.id,
 								postType: 'wp_template',
 							} );
+							// Callers can stay mounted while the template is open.
+							close();
 						} }
 						disabled={ ! template.id || ! onNavigateToEntityRecord }
 					>
diff --git a/packages/js/email-editor/src/components/sidebar/template-selection.tsx b/packages/js/email-editor/src/components/sidebar/template-selection.tsx
index 27c24cf7a2b..2ee410713cb 100644
--- a/packages/js/email-editor/src/components/sidebar/template-selection.tsx
+++ b/packages/js/email-editor/src/components/sidebar/template-selection.tsx
@@ -2,6 +2,7 @@
  * External dependencies
  */
 import {
+	Button,
 	PanelRow,
 	Flex,
 	FlexItem,
@@ -48,17 +49,11 @@ export function TemplateSelection() {
 							{ __( 'Template', __i18n_text_domain__ ) }
 						</FlexItem>
 						<FlexItem>
-							{ ! (
-								templates?.length > 1 || canUpdateTemplates
-							) && <b>{ template?.title }</b> }
-							{ ( templates?.length > 1 ||
-								canUpdateTemplates ) && (
+							{ templates?.length > 1 ? (
 								<DropdownMenu
 									icon={ null }
 									text={ template?.title }
-									toggleProps={ {
-										variant: 'tertiary',
-									} }
+									toggleProps={ { variant: 'tertiary' } }
 									label={ __(
 										'Template actions',
 										__i18n_text_domain__
@@ -75,52 +70,46 @@ export function TemplateSelection() {
 									}
 								>
 									{ ( { onClose } ) => (
-										<>
-											{ canUpdateTemplates && (
-												<MenuItem
-													onClick={ () => {
-														recordEvent(
-															'sidebar_template_actions_edit_template_clicked'
-														);
-														setEditTemplateModalOpen(
-															true
-														);
-														onClose();
-													} }
-												>
-													{ __(
-														'Edit template',
-														__i18n_text_domain__
-													) }
-												</MenuItem>
+										<MenuItem
+											onClick={ () => {
+												recordEvent(
+													'sidebar_template_actions_swap_template_clicked'
+												);
+												setSelectTemplateModalOpen(
+													true
+												);
+												onClose();
+											} }
+										>
+											{ __(
+												'Swap template',
+												__i18n_text_domain__
 											) }
-
-											{ templates?.length > 1 && (
-												<MenuItem
-													onClick={ () => {
-														recordEvent(
-															'sidebar_template_actions_swap_template_clicked'
-														);
-														setSelectTemplateModalOpen(
-															true
-														);
-														onClose();
-													} }
-												>
-													{ __(
-														'Swap template',
-														__i18n_text_domain__
-													) }
-												</MenuItem>
-											) }
-										</>
+										</MenuItem>
 									) }
 								</DropdownMenu>
+							) : (
+								<b>{ template?.title }</b>
 							) }
 						</FlexItem>
 					</Flex>
 				</PanelRow>
 			) }
+			{ template && canUpdateTemplates && (
+				<PanelRow>
+					<Button
+						variant="link"
+						onClick={ () => {
+							recordEvent(
+								'sidebar_template_actions_edit_template_clicked'
+							);
+							setEditTemplateModalOpen( true );
+						} }
+					>
+						{ __( 'Edit template', __i18n_text_domain__ ) }
+					</Button>
+				</PanelRow>
+			) }
 			{ isEditTemplateModalOpen && (
 				<EditTemplateModal
 					close={ () => {
diff --git a/packages/js/email-editor/src/components/sidebar/test/block-compatibility-warnings.spec.tsx b/packages/js/email-editor/src/components/sidebar/test/block-compatibility-warnings.spec.tsx
index 202ba31df20..83ed65c5e50 100644
--- a/packages/js/email-editor/src/components/sidebar/test/block-compatibility-warnings.spec.tsx
+++ b/packages/js/email-editor/src/components/sidebar/test/block-compatibility-warnings.spec.tsx
@@ -63,8 +63,14 @@ const BLOCK_SUPPORTS = {
 	'test/no-border': {},
 };

-function renderWithSelectedBlock( name: string ) {
-	( useSelect as jest.Mock ).mockReturnValue( { name } );
+function renderWithSelectedBlock( name: string, editingMode = 'default' ) {
+	( useSelect as jest.Mock ).mockImplementation( ( selector ) =>
+		selector( () => ( {
+			getSelectedBlock: () => ( { name } ),
+			getSelectedBlockClientId: () => 'block',
+			getBlockEditingMode: () => editingMode,
+		} ) )
+	);
 	render( <BlockCompatibilityWarnings /> );
 }

@@ -106,4 +112,12 @@ describe( 'BlockCompatibilityWarnings', () => {
 			screen.queryByText( BORDER_WARNING, { exact: false } )
 		).not.toBeInTheDocument();
 	} );
+
+	it( 'shows no warnings for a block whose styles cannot be changed', () => {
+		renderWithSelectedBlock( 'test/border', 'contentOnly' );
+
+		expect(
+			screen.queryByText( BORDER_WARNING, { exact: false } )
+		).not.toBeInTheDocument();
+	} );
 } );
diff --git a/packages/js/email-editor/src/components/sidebar/test/edit-template-modal.spec.tsx b/packages/js/email-editor/src/components/sidebar/test/edit-template-modal.spec.tsx
new file mode 100644
index 00000000000..89bd4cad3dc
--- /dev/null
+++ b/packages/js/email-editor/src/components/sidebar/test/edit-template-modal.spec.tsx
@@ -0,0 +1,48 @@
+/**
+ * External dependencies
+ */
+import { fireEvent, render, screen } from '@testing-library/react';
+import { useSelect } from '@wordpress/data';
+
+/**
+ * Internal dependencies
+ */
+import { EditTemplateModal } from '../edit-template-modal';
+
+jest.mock( '@wordpress/data', () => ( { useSelect: jest.fn() } ) );
+jest.mock( '@wordpress/editor', () => ( { store: 'core/editor' } ) );
+jest.mock( '../../../store', () => ( { storeName: 'email-editor' } ) );
+jest.mock( '../../../events', () => ( {
+	recordEvent: jest.fn(),
+	recordEventOnce: jest.fn(),
+} ) );
+jest.mock( '@wordpress/components', () => ( {
+	Button: ( { children, onClick } ) => (
+		<button onClick={ onClick }>{ children }</button>
+	),
+	Flex: ( { children } ) => <div>{ children }</div>,
+	FlexItem: ( { children } ) => <div>{ children }</div>,
+	Modal: ( { children } ) => <div>{ children }</div>,
+} ) );
+
+describe( 'EditTemplateModal', () => {
+	it( 'opens the template and closes itself, so it is not open again on the way back', () => {
+		const onNavigateToEntityRecord = jest.fn();
+		const close = jest.fn();
+		( useSelect as jest.Mock ).mockImplementation( ( selector ) =>
+			selector( () => ( {
+				getEditorSettings: () => ( { onNavigateToEntityRecord } ),
+				getCurrentTemplate: () => ( { id: 'theme//newsletter' } ),
+			} ) )
+		);
+
+		render( <EditTemplateModal close={ close } /> );
+		fireEvent.click( screen.getByText( 'Edit template' ) );
+
+		expect( onNavigateToEntityRecord ).toHaveBeenCalledWith( {
+			postId: 'theme//newsletter',
+			postType: 'wp_template',
+		} );
+		expect( close ).toHaveBeenCalled();
+	} );
+} );
diff --git a/packages/js/email-editor/src/components/sidebar/test/template-selection.spec.tsx b/packages/js/email-editor/src/components/sidebar/test/template-selection.spec.tsx
new file mode 100644
index 00000000000..2f5e51053d2
--- /dev/null
+++ b/packages/js/email-editor/src/components/sidebar/test/template-selection.spec.tsx
@@ -0,0 +1,83 @@
+import '../../test/__mocks__/setup-shared-mocks';
+
+/**
+ * External dependencies
+ */
+import { fireEvent, render, screen } from '@testing-library/react';
+import '@testing-library/jest-dom';
+import { useSelect } from '@wordpress/data';
+
+/**
+ * Internal dependencies
+ */
+import { TemplateSelection } from '../template-selection';
+import { usePreviewTemplates } from '../../../hooks';
+
+jest.mock( '@wordpress/components', () => ( {
+	Button: ( { children, onClick } ) => (
+		<button onClick={ onClick }>{ children }</button>
+	),
+	DropdownMenu: ( { text } ) => <div>{ `Dropdown: ${ text }` }</div>,
+	Flex: ( { children } ) => <div>{ children }</div>,
+	FlexItem: ( { children } ) => <div>{ children }</div>,
+	MenuItem: ( { children } ) => <div>{ children }</div>,
+	PanelRow: ( { children } ) => <div>{ children }</div>,
+} ) );
+
+jest.mock( '../../../hooks', () => ( { usePreviewTemplates: jest.fn() } ) );
+jest.mock( '../../../events', () => ( { recordEvent: jest.fn() } ) );
+jest.mock( '../../template-select', () => ( {
+	SelectTemplateModal: () => null,
+} ) );
+jest.mock( '../edit-template-modal', () => ( {
+	EditTemplateModal: () => <div>Confirm editing</div>,
+} ) );
+
+const setup = ( canUserEditTemplates: boolean, templateCount: number ) => {
+	( useSelect as jest.Mock ).mockImplementation( ( selector ) =>
+		selector( () => ( {
+			getCurrentTemplate: () => ( { title: 'Newsletter' } ),
+			getEditedEmailContent: () => '',
+			canUserEditTemplates: () => canUserEditTemplates,
+			getEmailPostType: () => 'mailpoet_email',
+		} ) )
+	);
+	( usePreviewTemplates as jest.Mock ).mockReturnValue( [
+		Array( templateCount ).fill( {} ),
+	] );
+	render( <TemplateSelection /> );
+};
+
+describe( 'TemplateSelection', () => {
+	it( 'opens the confirmation from a visible edit template link', () => {
+		setup( true, 1 );
+
+		fireEvent.click( screen.getByText( 'Edit template' ) );
+
+		expect( screen.getByText( 'Confirm editing' ) ).toBeInTheDocument();
+	} );
+
+	it( 'hides the link from users who cannot edit templates', () => {
+		setup( false, 1 );
+
+		expect( screen.queryByText( 'Edit template' ) ).not.toBeInTheDocument();
+		expect( screen.getByText( 'Newsletter' ) ).toBeInTheDocument();
+	} );
+
+	it( 'keeps the dropdown only when there is another template to swap to', () => {
+		setup( true, 2 );
+
+		expect(
+			screen.getByText( 'Dropdown: Newsletter' )
+		).toBeInTheDocument();
+	} );
+
+	it( 'shows the template name as plain text when there is nothing to swap to', () => {
+		setup( true, 1 );
+
+		expect(
+			screen.queryByText( 'Dropdown: Newsletter' )
+		).not.toBeInTheDocument();
+		expect( screen.getByText( 'Newsletter' ) ).toBeInTheDocument();
+	} );
+} );
diff --git a/packages/js/email-editor/src/components/template-areas/index.ts b/packages/js/email-editor/src/components/template-areas/index.ts
new file mode 100644
index 00000000000..c953d17c768
--- /dev/null
+++ b/packages/js/email-editor/src/components/template-areas/index.ts
@@ -0,0 +1,6 @@
+export { TemplateAreaEditingMode } from './template-area-editing-mode';
+export {
+	getTemplateAreaClientIds,
+	isTemplateAreaEditingEnabled,
+	useIsTemplateArea,
+} from './template-areas';
diff --git a/packages/js/email-editor/src/components/template-areas/template-area-editing-mode.tsx b/packages/js/email-editor/src/components/template-areas/template-area-editing-mode.tsx
new file mode 100644
index 00000000000..bfabf089565
--- /dev/null
+++ b/packages/js/email-editor/src/components/template-areas/template-area-editing-mode.tsx
@@ -0,0 +1,63 @@
+/**
+ * External dependencies
+ */
+import { store as blockEditorStore } from '@wordpress/block-editor';
+import { useDispatch, useSelect } from '@wordpress/data';
+import { useEffect } from '@wordpress/element';
+
+/**
+ * Internal dependencies
+ */
+import {
+	getTemplateAreaClientIds,
+	isTemplateAreaEditingEnabled,
+} from './template-areas';
+
+type BlockEditingModeActions = {
+	setBlockEditingMode: (
+		clientId: string,
+		mode: 'disabled' | 'contentOnly'
+	) => void;
+	unsetBlockEditingMode: ( clientId: string ) => void;
+};
+
+/**
+ * Lets people select the template blocks around the email content, the way core
+ * treats template parts in a locked template: the area itself becomes
+ * selectable, while the blocks inside it stay locked.
+ */
+export function TemplateAreaEditingMode() {
+	// Joined into strings so the effect only runs when the IDs change.
+	const { areaIds, lockedIds } = useSelect( ( select ) => {
+		if ( ! isTemplateAreaEditingEnabled( select ) ) {
+			return { areaIds: '', lockedIds: '' };
+		}
+		const areas = getTemplateAreaClientIds( select );
+		return {
+			areaIds: areas.join( ',' ),
+			lockedIds: select( blockEditorStore )
+				.getClientIdsOfDescendants( areas )
+				.join( ',' ),
+		};
+	}, [] );
+	// The editing mode actions are missing from the block editor store types.
+	const { setBlockEditingMode, unsetBlockEditingMode } = useDispatch(
+		blockEditorStore
+	) as unknown as BlockEditingModeActions;
+
+	useEffect( () => {
+		const areas = areaIds ? areaIds.split( ',' ) : [];
+		const locked = lockedIds ? lockedIds.split( ',' ) : [];
+
+		areas.forEach( ( id ) => setBlockEditingMode( id, 'contentOnly' ) );
+		locked.forEach( ( id ) => setBlockEditingMode( id, 'disabled' ) );
+
+		return () => {
+			[ ...areas, ...locked ].forEach( ( id ) =>
+				unsetBlockEditingMode( id )
+			);
+		};
+	}, [ areaIds, lockedIds, setBlockEditingMode, unsetBlockEditingMode ] );
+
+	return null;
+}
diff --git a/packages/js/email-editor/src/components/template-areas/template-areas.ts b/packages/js/email-editor/src/components/template-areas/template-areas.ts
new file mode 100644
index 00000000000..d2498ebe98d
--- /dev/null
+++ b/packages/js/email-editor/src/components/template-areas/template-areas.ts
@@ -0,0 +1,65 @@
+/**
+ * External dependencies
+ */
+import { store as blockEditorStore } from '@wordpress/block-editor';
+import { useSelect } from '@wordpress/data';
+import type { SelectFunction } from '@wordpress/data/build-types/types';
+import { store as editorStore } from '@wordpress/editor';
+
+/**
+ * Internal dependencies
+ */
+import { storeName } from '../../store';
+
+/**
+ * Returns the template groups around the email content: at each level from the
+ * root down to the post content block, every sibling group of that path. Only
+ * groups qualify, as core only does this for template parts: their own content
+ * can't be edited, while a block like the site title would become editable.
+ */
+export function getTemplateAreaClientIds( select: SelectFunction ): string[] {
+	const { getBlocksByName, getBlockName, getBlockOrder, getBlockParents } =
+		select( blockEditorStore );
+	const [ postContentId ] = getBlocksByName( 'core/post-content' );
+
+	if ( ! postContentId ) {
+		return [];
+	}
+
+	const path = [ ...getBlockParents( postContentId ), postContentId ];
+
+	return path.flatMap( ( clientId, index ) =>
+		getBlockOrder( index === 0 ? '' : path[ index - 1 ] ).filter(
+			( siblingId ) =>
+				siblingId !== clientId &&
+				getBlockName( siblingId ) === 'core/group'
+		)
+	);
+}
+
+export function isTemplateAreaEditingEnabled(
+	select: SelectFunction
+): boolean {
+	const { getRenderingMode, getCurrentPostType, getEditorSettings } =
+		select( editorStore );
+	const editorSettings = getEditorSettings() as {
+		onNavigateToEntityRecord?: unknown;
+	};
+
+	return (
+		getRenderingMode() === 'template-locked' &&
+		getCurrentPostType() !== 'wp_template' &&
+		!! editorSettings?.onNavigateToEntityRecord &&
+		!! select( storeName ).canUserEditTemplates() &&
+		!! select( storeName ).getCurrentTemplate()?.id
+	);
+}
+
+export function useIsTemplateArea( clientId: string ): boolean {
+	return useSelect(
+		( select ) =>
+			isTemplateAreaEditingEnabled( select ) &&
+			getTemplateAreaClientIds( select ).includes( clientId ),
+		[ clientId ]
+	);
+}
diff --git a/packages/js/email-editor/src/components/template-areas/test/template-area-editing-mode.spec.tsx b/packages/js/email-editor/src/components/template-areas/test/template-area-editing-mode.spec.tsx
new file mode 100644
index 00000000000..3dae2a390cf
--- /dev/null
+++ b/packages/js/email-editor/src/components/template-areas/test/template-area-editing-mode.spec.tsx
@@ -0,0 +1,74 @@
+import '../../test/__mocks__/setup-shared-mocks';
+
+/**
+ * External dependencies
+ */
+import { render } from '@testing-library/react';
+import { useDispatch, useSelect } from '@wordpress/data';
+
+/**
+ * Internal dependencies
+ */
+import { TemplateAreaEditingMode } from '../template-area-editing-mode';
+import {
+	getTemplateAreaClientIds,
+	isTemplateAreaEditingEnabled,
+} from '../template-areas';
+
+jest.mock( '../template-areas', () => ( {
+	getTemplateAreaClientIds: jest.fn(),
+	isTemplateAreaEditingEnabled: jest.fn(),
+} ) );
+
+const setBlockEditingMode = jest.fn();
+const unsetBlockEditingMode = jest.fn();
+
+const setup = ( enabled: boolean ) => {
+	( isTemplateAreaEditingEnabled as jest.Mock ).mockReturnValue( enabled );
+	( getTemplateAreaClientIds as jest.Mock ).mockReturnValue( [
+		'header',
+		'footer',
+	] );
+	( useSelect as jest.Mock ).mockImplementation( ( selector ) =>
+		selector( () => ( {
+			getClientIdsOfDescendants: ( ids: string[] ) =>
+				ids.includes( 'header' ) ? [ 'logo' ] : [],
+		} ) )
+	);
+	( useDispatch as jest.Mock ).mockReturnValue( {
+		setBlockEditingMode,
+		unsetBlockEditingMode,
+	} );
+};
+
+describe( 'TemplateAreaEditingMode', () => {
+	beforeEach( () => jest.clearAllMocks() );
+
+	it( 'makes the template areas selectable and keeps their blocks locked', () => {
+		setup( true );
+
+		const { unmount } = render( <TemplateAreaEditingMode /> );
+
+		expect( setBlockEditingMode.mock.calls ).toEqual( [
+			[ 'header', 'contentOnly' ],
+			[ 'footer', 'contentOnly' ],
+			[ 'logo', 'disabled' ],
+		] );
+
+		unmount();
+
+		expect( unsetBlockEditingMode.mock.calls ).toEqual( [
+			[ 'header' ],
+			[ 'footer' ],
+			[ 'logo' ],
+		] );
+	} );
+
+	it( 'leaves the template locked when area editing is off', () => {
+		setup( false );
+
+		render( <TemplateAreaEditingMode /> );
+
+		expect( setBlockEditingMode ).not.toHaveBeenCalled();
+	} );
+} );
diff --git a/packages/js/email-editor/src/components/template-areas/test/template-areas.spec.ts b/packages/js/email-editor/src/components/template-areas/test/template-areas.spec.ts
new file mode 100644
index 00000000000..e5c688a7472
--- /dev/null
+++ b/packages/js/email-editor/src/components/template-areas/test/template-areas.spec.ts
@@ -0,0 +1,162 @@
+/**
+ * External dependencies
+ */
+import { store as blockEditorStore } from '@wordpress/block-editor';
+import { store as editorStore } from '@wordpress/editor';
+
+/**
+ * Internal dependencies
+ */
+import {
+	getTemplateAreaClientIds,
+	isTemplateAreaEditingEnabled,
+} from '../template-areas';
+import { storeName } from '../../../store';
+
+jest.mock( '@wordpress/block-editor', () => ( {
+	store: 'core/block-editor',
+} ) );
+jest.mock( '@wordpress/editor', () => ( { store: 'core/editor' } ) );
+jest.mock( '../../../store', () => ( { storeName: 'email-editor' } ) );
+
+type Tree = Record< string, string[] >;
+
+const createSelect =
+	( tree: Tree, editor = {}, emailEditor = {} ) =>
+	( store: unknown ) => {
+		if ( store === blockEditorStore ) {
+			const parentOf = ( id: string ) =>
+				Object.keys( tree ).find( ( key ) =>
+					tree[ key ].includes( id )
+				);
+			return {
+				getBlocksByName: ( name: string ) =>
+					name === 'core/post-content' &&
+					Object.values( tree ).flat().includes( 'content' )
+						? [ 'content' ]
+						: [],
+				getBlockOrder: ( id: string ) => tree[ id ] ?? [],
+				// Blocks in the fixtures are groups unless their ID says otherwise.
+				getBlockName: ( id: string ) =>
+					[
+						'logo',
+						'powered-by',
+						'site-title',
+						'paragraph',
+					].includes( id )
+						? `core/${ id }`
+						: 'core/group',
+				getBlockParents: ( id: string ) => {
+					const parents: string[] = [];
+					let parent = parentOf( id );
+					while ( parent ) {
+						parents.unshift( parent );
+						parent = parentOf( parent );
+					}
+					return parents;
+				},
+			};
+		}
+		if ( store === editorStore ) {
+			return {
+				getRenderingMode: () => 'template-locked',
+				getCurrentPostType: () => 'mailpoet_email',
+				getEditorSettings: () => ( {
+					onNavigateToEntityRecord: jest.fn(),
+				} ),
+				...editor,
+			};
+		}
+		if ( store === storeName ) {
+			return {
+				canUserEditTemplates: () => true,
+				getCurrentTemplate: () => ( { id: 'theme//newsletter' } ),
+				...emailEditor,
+			};
+		}
+		return {};
+	};
+
+describe( 'getTemplateAreaClientIds', () => {
+	it( 'returns the template groups around the content, at every level', () => {
+		// The MailPoet newsletter template: a wrapper group with the header,
+		// the content, the footer and the "Powered by" block.
+		const select = createSelect( {
+			'': [ 'wrapper' ],
+			wrapper: [ 'header', 'content', 'footer', 'powered-by' ],
+			header: [ 'logo' ],
+		} );
+
+		expect( getTemplateAreaClientIds( select as never ) ).toEqual( [
+			'header',
+			'footer',
+		] );
+	} );
+
+	it( 'keeps template blocks that are not groups locked, so their content cannot be edited from the email', () => {
+		// The WooCommerce template puts the site title next to the content.
+		const select = createSelect( {
+			'': [ 'wrapper' ],
+			wrapper: [ 'site-title', 'content-group', 'footer' ],
+			'content-group': [ 'content' ],
+		} );
+
+		expect( getTemplateAreaClientIds( select as never ) ).toEqual( [
+			'footer',
+		] );
+	} );
+
+	it( 'skips the groups that only wrap the content', () => {
+		// The WooCommerce template wraps the content in an extra group.
+		const select = createSelect( {
+			'': [ 'wrapper' ],
+			wrapper: [ 'header', 'content-group', 'footer' ],
+			'content-group': [ 'content' ],
+		} );
+
+		expect( getTemplateAreaClientIds( select as never ) ).toEqual( [
+			'header',
+			'footer',
+		] );
+	} );
+
+	it( 'returns nothing when the canvas shows no email content', () => {
+		const select = createSelect( { '': [ 'paragraph' ] } );
+
+		expect( getTemplateAreaClientIds( select as never ) ).toEqual( [] );
+	} );
+} );
+
+describe( 'isTemplateAreaEditingEnabled', () => {
+	it( 'is on when the email is shown inside an editable template', () => {
+		expect(
+			isTemplateAreaEditingEnabled( createSelect( {} ) as never )
+		).toBe( true );
+	} );
+
+	it.each( [
+		[ 'the template is hidden', { getRenderingMode: () => 'post-only' } ],
+		[
+			'the template itself is open',
+			{ getCurrentPostType: () => 'wp_template' },
+		],
+		[
+			'the editor cannot open the template',
+			{ getEditorSettings: () => ( {} ) },
+		],
+	] )( 'is off when %s', ( _, editor ) => {
+		expect(
+			isTemplateAreaEditingEnabled( createSelect( {}, editor ) as never )
+		).toBe( false );
+	} );
+
+	it( 'is off for users who cannot edit templates', () => {
+		const select = createSelect(
+			{},
+			{},
+			{ canUserEditTemplates: () => false }
+		);
+
+		expect( isTemplateAreaEditingEnabled( select as never ) ).toBe( false );
+	} );
+} );
diff --git a/packages/js/email-editor/src/components/template-canvas-affordance/template-canvas-affordance.tsx b/packages/js/email-editor/src/components/template-canvas-affordance/template-canvas-affordance.tsx
index dcb3d129aca..4af1d392cb5 100644
--- a/packages/js/email-editor/src/components/template-canvas-affordance/template-canvas-affordance.tsx
+++ b/packages/js/email-editor/src/components/template-canvas-affordance/template-canvas-affordance.tsx
@@ -19,6 +19,7 @@ import { Icon, layout } from '@wordpress/icons';
  */
 import { storeName } from '../../store';
 import { recordEvent } from '../../events';
+import { EditTemplateModal } from '../sidebar/edit-template-modal';

 const SLOT_ID = 'woocommerce-email-editor-template-area-affordance-slot';
 const STYLE_ID = 'woocommerce-email-editor-template-area-affordance-style';
@@ -52,7 +53,7 @@ const CANVAS_STYLES = `
 .woocommerce-email-editor-template-area-affordance__frame {
 	appearance: none;
 	background: transparent;
-	border: 1.5px solid transparent;
+	border: var(--wp-admin-border-width-focus, 2px) solid transparent;
 	box-sizing: border-box;
 	cursor: pointer;
 	font: inherit;
@@ -65,7 +66,7 @@ const CANVAS_STYLES = `
 .woocommerce-email-editor-template-area-affordance__frame:hover,
 .woocommerce-email-editor-template-area-affordance__frame:focus-visible,
 .woocommerce-email-editor-template-area-affordance__frame.is-active {
-	border-color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
+	border-color: var(--wp-block-synced-color, #7a00df);
 	outline: none;
 }
 .woocommerce-email-editor-template-area-affordance__label {
@@ -84,7 +85,7 @@ const CANVAS_STYLES = `
 .woocommerce-email-editor-template-area-affordance__button.components-button {
 	border-radius: 0;
 	box-shadow: none;
-	color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
+	color: #1e1e1e;
 	height: 48px;
 	padding: 0 18px;
 	white-space: nowrap;
@@ -93,7 +94,7 @@ const CANVAS_STYLES = `
 	color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
 }
 .woocommerce-email-editor-template-area-affordance__button.components-button:focus-visible {
-	box-shadow: inset 0 0 0 1.5px var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
+	box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus, 2px) var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
 }
 `;

@@ -164,9 +165,13 @@ function getTemplateTarget( canvasDocument: Document ): Element | null {
 	// arbitrary nearby blocks produced visually misleading highlights — see
 	// https://github.com/woocommerce/woocommerce/pull/64703#discussion (manual
 	// QA on the default Woo email template).
-	const templateBlock = canvasDocument.querySelector(
-		'[data-type="core/site-logo"], [data-type="core/site-title"], .wp-block-site-logo, .wp-block-site-title'
-	);
+	// A site logo or title inside a template group gets the template area
+	// toolbar instead (see the template-areas component).
+	const templateBlock = Array.from(
+		canvasDocument.querySelectorAll(
+			'[data-type="core/site-logo"], [data-type="core/site-title"], .wp-block-site-logo, .wp-block-site-title'
+		)
+	).find( ( block ) => ! block.closest( '.is-email-template-area' ) );

 	if ( ! templateBlock ) {
 		return null;
@@ -193,6 +198,7 @@ function createSlot( canvasDocument: Document ): HTMLDivElement {

 export function TemplateCanvasAffordance() {
 	const [ isActive, setIsActive ] = useState( false );
+	const [ isModalOpen, setIsModalOpen ] = useState( false );
 	const [ portalSlot, setPortalSlot ] = useState< HTMLDivElement | null >(
 		null
 	);
@@ -254,13 +260,13 @@ export function TemplateCanvasAffordance() {

 		setPosition( {
 			frame: {
-				height: rect.height + 2,
-				left: rect.left + scrollX - 1,
-				top: rect.top + scrollY - 1,
-				width: rect.width + 2,
+				height: rect.height + 4,
+				left: rect.left + scrollX - 2,
+				top: rect.top + scrollY - 2,
+				width: rect.width + 4,
 			},
 			toolbar: {
-				left: rect.left + scrollX - 1,
+				left: rect.left + scrollX - 2,
 				top: toolbarTop,
 			},
 		} );
@@ -374,18 +380,11 @@ export function TemplateCanvasAffordance() {
 	const activate = useCallback( () => setIsActive( true ), [] );

 	const handleEditTemplate = useCallback( () => {
-		if ( ! template?.id || ! onNavigateToEntityRecord ) {
-			return;
-		}
-
 		recordEvent( 'template_canvas_affordance_edit_template_clicked', {
-			templateId: template.id,
+			templateId: template?.id,
 		} );
-		onNavigateToEntityRecord( {
-			postId: template.id,
-			postType: 'wp_template',
-		} );
-	}, [ onNavigateToEntityRecord, template?.id ] );
+		setIsModalOpen( true );
+	}, [ template?.id ] );

 	// Gutenberg’s block list installs capture-phase pointerdown/mousedown
 	// handlers on the canvas to start block selection and drag gestures. If it
@@ -440,41 +439,48 @@ export function TemplateCanvasAffordance() {

 	const toolbarId = `${ SLOT_ID }-toolbar`;

-	return createPortal(
+	return (
 		<>
-			<button
-				ref={ frameRef }
-				type="button"
-				className={
-					isActive
-						? 'woocommerce-email-editor-template-area-affordance__frame is-active'
-						: 'woocommerce-email-editor-template-area-affordance__frame'
-				}
-				aria-label={ __( 'Template area', 'woocommerce' ) }
-				aria-expanded={ isActive }
-				aria-controls={ isActive ? toolbarId : undefined }
-				style={ position.frame }
-			/>
-			{ isActive && (
-				<div
-					id={ toolbarId }
-					className="woocommerce-email-editor-template-area-affordance"
-					style={ position.toolbar }
-				>
-					<span className="woocommerce-email-editor-template-area-affordance__label">
-						<Icon icon={ layout } size={ 24 } />
-						<span>{ __( 'Template', 'woocommerce' ) }</span>
-					</span>
-					<Button
-						ref={ buttonRef }
-						className="woocommerce-email-editor-template-area-affordance__button"
-						variant="tertiary"
-					>
-						{ __( 'Edit template', 'woocommerce' ) }
-					</Button>
-				</div>
+			{ createPortal(
+				<>
+					<button
+						ref={ frameRef }
+						type="button"
+						className={
+							isActive
+								? 'woocommerce-email-editor-template-area-affordance__frame is-active'
+								: 'woocommerce-email-editor-template-area-affordance__frame'
+						}
+						aria-label={ __( 'Template area', 'woocommerce' ) }
+						aria-expanded={ isActive }
+						aria-controls={ isActive ? toolbarId : undefined }
+						style={ position.frame }
+					/>
+					{ isActive && (
+						<div
+							id={ toolbarId }
+							className="woocommerce-email-editor-template-area-affordance"
+							style={ position.toolbar }
+						>
+							<span className="woocommerce-email-editor-template-area-affordance__label">
+								<Icon icon={ layout } size={ 24 } />
+								<span>{ template?.title }</span>
+							</span>
+							<Button
+								ref={ buttonRef }
+								className="woocommerce-email-editor-template-area-affordance__button"
+								variant="tertiary"
+							>
+								{ __( 'Edit template', 'woocommerce' ) }
+							</Button>
+						</div>
+					) }
+				</>,
+				portalSlot
+			) }
+			{ isModalOpen && (
+				<EditTemplateModal close={ () => setIsModalOpen( false ) } />
 			) }
-		</>,
-		portalSlot
+		</>
 	);
 }
diff --git a/packages/js/email-editor/src/components/template-canvas-affordance/test/template-canvas-affordance.spec.tsx b/packages/js/email-editor/src/components/template-canvas-affordance/test/template-canvas-affordance.spec.tsx
index 95aa4c8e29f..bb1def3bfeb 100644
--- a/packages/js/email-editor/src/components/template-canvas-affordance/test/template-canvas-affordance.spec.tsx
+++ b/packages/js/email-editor/src/components/template-canvas-affordance/test/template-canvas-affordance.spec.tsx
@@ -3,7 +3,7 @@ import '../../test/__mocks__/setup-shared-mocks';
 /**
  * External dependencies
  */
-import { fireEvent, render, waitFor } from '@testing-library/react';
+import { fireEvent, render, screen, waitFor } from '@testing-library/react';
 import '@testing-library/jest-dom';
 import { useSelect } from '@wordpress/data';
 import { store as editorStore } from '@wordpress/editor';
@@ -40,6 +40,10 @@ jest.mock( '@wordpress/icons', () => ( {
 	layout: 'layout',
 } ) );

+jest.mock( '../../sidebar/edit-template-modal', () => ( {
+	EditTemplateModal: () => <div>Confirm editing the template</div>,
+} ) );
+
 jest.mock( '../../../events', () => ( {
 	recordEvent: jest.fn(),
 } ) );
@@ -183,7 +187,7 @@ describe( 'TemplateCanvasAffordance', () => {
 		);
 	} );

-	it( 'falls back to the admin theme color for the template area outline', async () => {
+	it( 'outlines the template area in the purple used by the template area toolbar', async () => {
 		const iframe = addEditorCanvas();
 		setupUseSelectMock();

@@ -202,9 +206,12 @@ describe( 'TemplateCanvasAffordance', () => {
 				'woocommerce-email-editor-template-area-affordance-style'
 			)?.textContent ?? '';

-		expect( css ).toContain( 'var(--wp-admin-theme-color, #3858e9)' );
-		expect( css ).not.toContain(
-			'var(--wp-components-color-accent, #3858e9)'
+		expect( css ).toContain(
+			'border-color: var(--wp-block-synced-color, #7a00df)'
+		);
+		// The button reacts like the core toolbar button next to the footer.
+		expect( css ).toContain(
+			':hover:not(:disabled) {\n\tcolor: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));'
 		);
 	} );

@@ -252,7 +259,9 @@ describe( 'TemplateCanvasAffordance', () => {
 			) as HTMLButtonElement
 		);

-		expect( iframe.contentDocument?.body ).toHaveTextContent( 'Template' );
+		expect( iframe.contentDocument?.body ).toHaveTextContent(
+			'Woo email template'
+		);
 		expect( iframe.contentDocument?.body ).toHaveTextContent(
 			'Edit template'
 		);
@@ -285,7 +294,7 @@ describe( 'TemplateCanvasAffordance', () => {
 			iframe.contentDocument?.querySelector(
 				'.woocommerce-email-editor-template-area-affordance__frame'
 			)
-		).toHaveStyle( { top: '83px' } );
+		).toHaveStyle( { top: '82px' } );
 		expect(
 			iframe.contentDocument?.querySelector(
 				'.woocommerce-email-editor-template-area-affordance'
@@ -326,7 +335,43 @@ describe( 'TemplateCanvasAffordance', () => {
 		).not.toBeInTheDocument();
 	} );

-	it( 'navigates to the current template when edit template is clicked', async () => {
+	it( 'does not render when the site title sits in a template area that has its own toolbar', async () => {
+		const iframe = addEditorCanvas();
+		iframe.contentDocument
+			?.querySelector( '[data-block="template-header"]' )
+			?.classList.add( 'is-email-template-area' );
+		setupUseSelectMock();
+
+		render( <TemplateCanvasAffordance /> );
+
+		await new Promise( ( resolve ) => setTimeout( resolve, 50 ) );
+
+		expect(
+			iframe.contentDocument?.getElementById(
+				'woocommerce-email-editor-template-area-affordance-slot'
+			)
+		).not.toBeInTheDocument();
+	} );
+
+	it( 'uses a site title outside the template areas when an earlier one is inside one', async () => {
+		const iframe = addEditorCanvas( {
+			headerContent:
+				'<div class="is-email-template-area"><div class="wp-block-site-logo">Logo</div></div><h1 class="wp-block-site-title">testingbun</h1>',
+		} );
+		setupUseSelectMock();
+
+		render( <TemplateCanvasAffordance /> );
+
+		await waitFor( () => {
+			expect(
+				iframe.contentDocument?.querySelector(
+					'.woocommerce-email-editor-template-area-affordance__frame'
+				)
+			).toBeInTheDocument();
+		} );
+	} );
+
+	it( 'asks before opening the template when edit template is clicked', async () => {
 		const iframe = addEditorCanvas();
 		const { onNavigateToEntityRecord } = setupUseSelectMock();

@@ -356,10 +401,10 @@ describe( 'TemplateCanvasAffordance', () => {
 			'template_canvas_affordance_edit_template_clicked',
 			{ templateId: template.id }
 		);
-		expect( onNavigateToEntityRecord ).toHaveBeenCalledWith( {
-			postId: template.id,
-			postType: 'wp_template',
-		} );
+		expect(
+			await screen.findByText( 'Confirm editing the template' )
+		).toBeInTheDocument();
+		expect( onNavigateToEntityRecord ).not.toHaveBeenCalled();
 	} );

 	it( 'does not render while editing a template', async () => {
diff --git a/packages/js/email-editor/src/telemetry-tracking.md b/packages/js/email-editor/src/telemetry-tracking.md
index 05abc7a6d2e..dc64937dd42 100644
--- a/packages/js/email-editor/src/telemetry-tracking.md
+++ b/packages/js/email-editor/src/telemetry-tracking.md
@@ -95,6 +95,7 @@ All events are prefixed `email_editor_events_`.
 | `template_select_modal_opened`                                               | `{ templateSelectMode }`                                                                         | Tracked when template select modal is opened                                                                                                                                |
 | `template_select_modal_start_from_scratch_clicked`                           | -                                                                                                | Tracked when the "Start from scratch" button is clicked in the template select modal                                                                                        |
 | `template_select_modal_template_selected`                                    | `{ template }`                                                                                   | Tracked when user selects a template in the template select modal                                                                                                           |
+| `template_area_edit_template_clicked`                                        | `{ templateId }`                                                                                 | Tracked when the Edit template button in the toolbar of a template area is clicked                                                                                          |
 | `template_canvas_affordance_edit_template_clicked`                           | `{ templateId }`                                                                                 | Tracked when the edit template button in the canvas template affordance is clicked                                                                                          |
 | `trash_modal_move_to_trash_button_clicked`                                   | -                                                                                                | Tracked when user clicks the move to trash button in the trash modal                                                                                                        |
 | `styles_sidebar_screen_typography_element_panel_set_letter_spacing`          | `{ element, newValue, selectedDefaultLetterSpacing }`                                            | Tracked when letter spacing is changed in typography panel                                                                                                                  |
diff --git a/packages/php/email-editor/changelog/update-stomail-8783-template-area-toolbar b/packages/php/email-editor/changelog/update-stomail-8783-template-area-toolbar
new file mode 100644
index 00000000000..3f26fff6fd7
--- /dev/null
+++ b/packages/php/email-editor/changelog/update-stomail-8783-template-area-toolbar
@@ -0,0 +1,4 @@
+Significance: patch
+Type: update
+
+Outline the template blocks around the email content in purple on hover and selection in the editor.
diff --git a/packages/php/email-editor/src/Engine/content-editor.css b/packages/php/email-editor/src/Engine/content-editor.css
index 0f29f2e78b1..57f7e2cc146 100644
--- a/packages/php/email-editor/src/Engine/content-editor.css
+++ b/packages/php/email-editor/src/Engine/content-editor.css
@@ -181,3 +181,24 @@ ol {
 .block-editor-iframe__body {
 	overflow-x: auto;
 }
+
+/*
+ * Template blocks around the email content get a purple outline on hover and
+ * selection, the color core uses for template parts. The first rule draws the
+ * outline where core draws none; the second recolors core's own outline.
+ */
+.block-editor-block-list__block.is-email-template-area.is-hovered::after,
+.block-editor-block-list__block.is-email-template-area.is-selected::after {
+	content: "";
+	position: absolute;
+	inset: 0;
+	z-index: 1;
+	pointer-events: none;
+	outline: var(--wp-admin-border-width-focus, 2px) solid var(--wp-block-synced-color, #7a00df);
+	outline-offset: calc(-1 * var(--wp-admin-border-width-focus, 2px));
+}
+
+.is-outline-mode .block-editor-block-list__block:not(.remove-outline).is-email-template-area.is-hovered:not(.is-selected)::after,
+.is-outline-mode .block-editor-block-list__block:not(.remove-outline):not(.rich-text).is-email-template-area.is-selected::after {
+	outline-color: var(--wp-block-synced-color, #7a00df);
+}
diff --git a/plugins/woocommerce/changelog/update-stomail-8783-edit-template-discoverability b/plugins/woocommerce/changelog/update-stomail-8783-edit-template-discoverability
new file mode 100644
index 00000000000..f41c957dc4f
--- /dev/null
+++ b/plugins/woocommerce/changelog/update-stomail-8783-edit-template-discoverability
@@ -0,0 +1,4 @@
+Significance: minor
+Type: update
+
+Make it easier to find how to edit the email template in the block email editor.
diff --git a/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-reset-template.spec.ts b/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-reset-template.spec.ts
index fc0eb6ad889..17668beee13 100644
--- a/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-reset-template.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-reset-template.spec.ts
@@ -37,14 +37,14 @@ async function switchToTemplateEditingMode( page: Page ) {
 			.click();
 	}

-	// Click the "Woo Email Template" button to open dropdown
-	await page.getByRole( 'button', { name: 'Template actions' } ).click();
-
-	// Click "Edit template" in the dropdown
-	await page.getByRole( 'menuitem', { name: 'Edit template' } ).click();
+	// Click the "Edit template" link in the sidebar
+	await page
+		.getByRole( 'button', { name: 'Edit template', exact: true } )
+		.click();

-	// Click "Edit template" button in the modal
+	// Confirm in the modal
 	await page
+		.getByRole( 'dialog' )
 		.getByRole( 'button', { name: 'Edit template', exact: true } )
 		.click();

diff --git a/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-template-areas.spec.ts b/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-template-areas.spec.ts
new file mode 100644
index 00000000000..88bc8369a13
--- /dev/null
+++ b/plugins/woocommerce/tests/e2e/tests/email-editor/email-editor-template-areas.spec.ts
@@ -0,0 +1,105 @@
+/**
+ * External dependencies
+ */
+import { test, expect, type Page } from '@playwright/test';
+
+/**
+ * Internal dependencies
+ */
+import { ADMIN_STATE_PATH } from '../../playwright.config';
+import {
+	enableEmailEditor,
+	disableEmailEditor,
+} from './helpers/enable-email-editor-feature';
+import { accessTheEmailEditor } from '../../utils/email';
+import { locks } from '../../fixtures/fixtures';
+
+/**
+ * Confirms the "used by multiple emails" warning.
+ *
+ * @param page The Playwright page.
+ */
+async function confirmEditTemplate( page: Page ) {
+	const dialog = page.getByRole( 'dialog' );
+	await expect( dialog ).toContainText(
+		'This template is used by multiple emails.'
+	);
+	await dialog
+		.getByRole( 'button', { name: 'Edit template', exact: true } )
+		.click();
+}
+
+/**
+ * Returns the post type open in the editor: the email or its template.
+ *
+ * @param page The Playwright page.
+ */
+function getOpenPostType( page: Page ) {
+	return page.evaluate( () =>
+		window.wp.data.select( 'core/editor' ).getCurrentPostType()
+	);
+}
+
+test.describe(
+	'WooCommerce Email Editor template areas',
+	{ lock: locks.EMAIL_FEATURE_FLAGS },
+	() => {
+		test.use( { storageState: ADMIN_STATE_PATH } );
+
+		test.beforeAll( async ( { baseURL } ) => {
+			await enableEmailEditor( baseURL );
+		} );
+
+		test.afterAll( async ( { baseURL } ) => {
+			await disableEmailEditor( baseURL );
+		} );
+
+		test( 'Opens the template from the footer toolbar', async ( {
+			page,
+		} ) => {
+			await accessTheEmailEditor( page, 'Customer note' );
+
+			const canvas = page.frameLocator( 'iframe[name="editor-canvas"]' );
+			const footer = canvas.locator( '.is-email-template-area' ).last();
+			await footer.scrollIntoViewIfNeeded();
+			await footer.click();
+
+			await page
+				.getByRole( 'toolbar', { name: 'Block tools' } )
+				.getByRole( 'button', { name: 'Edit template', exact: true } )
+				.click();
+
+			await confirmEditTemplate( page );
+
+			await expect
+				.poll( () => getOpenPostType( page ) )
+				.toBe( 'wp_template' );
+		} );
+
+		test( 'Opens the template from the header button', async ( {
+			page,
+		} ) => {
+			await accessTheEmailEditor( page, 'Customer note' );
+
+			// The default template's header is a lone site title or logo, so it
+			// gets the canvas button instead of the block toolbar.
+			const canvas = page.frameLocator( 'iframe[name="editor-canvas"]' );
+			await canvas
+				.locator(
+					'.woocommerce-email-editor-template-area-affordance__frame'
+				)
+				.click();
+			await canvas
+				.locator(
+					'.woocommerce-email-editor-template-area-affordance__button'
+				)
+				.click();
+
+			await confirmEditTemplate( page );
+
+			await expect
+				.poll( () => getOpenPostType( page ) )
+				.toBe( 'wp_template' );
+		} );
+	}
+);