Skip to content

Commit

Permalink
Post editor: Require confirmation before removing Footnotes (#52277)
Browse files Browse the repository at this point in the history
* Post editor: Require confirmation before removing Footnotes

Context: #52176

* BlockRemovalWarningModal: Limit width to 40rem

* Explain that footnotes are preserved. Add warning to Site Editor
  • Loading branch information
mcsf authored and tellthemachines committed Jul 7, 2023
1 parent 5ab9b67 commit 838485c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export function BlockRemovalWarningModal() {
<Modal
title={ __( 'Are you sure?' ) }
onRequestClose={ clearRemovalPrompt }
style={ {
maxWidth: '40rem',
} }
>
{ blockNamesForPrompt.length === 1 ? (
<p>{ blockTypePromptMessages[ blockNamesForPrompt[ 0 ] ] }</p>
Expand Down
15 changes: 14 additions & 1 deletion packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import {
store as editorStore,
} from '@wordpress/editor';
import { useSelect, useDispatch } from '@wordpress/data';
import { BlockBreadcrumb } from '@wordpress/block-editor';
import {
BlockBreadcrumb,
privateApis as blockEditorPrivateApis,
} from '@wordpress/block-editor';
import { Button, ScrollLock, Popover } from '@wordpress/components';
import { useViewportMatch } from '@wordpress/compose';
import { PluginArea } from '@wordpress/plugins';
Expand Down Expand Up @@ -49,6 +52,9 @@ import WelcomeGuide from '../welcome-guide';
import ActionsPanel from './actions-panel';
import StartPageOptions from '../start-page-options';
import { store as editPostStore } from '../../store';
import { unlock } from '../../lock-unlock';

const { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );

const interfaceLabels = {
/* translators: accessibility text for the editor top bar landmark region. */
Expand All @@ -63,6 +69,12 @@ const interfaceLabels = {
footer: __( 'Editor footer' ),
};

const blockRemovalRules = {
'core/footnotes': __(
'The Footnotes block displays all footnotes found in the content. Note that any footnotes in the content will persist after removing this block.'
),
};

function Layout( { styles } ) {
const isMobileViewport = useViewportMatch( 'medium', '<' );
const isHugeViewport = useViewportMatch( 'huge', '>=' );
Expand Down Expand Up @@ -202,6 +214,7 @@ function Layout( { styles } ) {
<LocalAutosaveMonitor />
<EditPostKeyboardShortcuts />
<EditorKeyboardShortcutsRegister />
<BlockRemovalWarningModal rules={ blockRemovalRules } />
<SettingsSidebar />
<InterfaceSkeleton
isDistractionFree={ isDistractionFree && isLargeViewport }
Expand Down

0 comments on commit 838485c

Please sign in to comment.