From 9c23d2f3a9abedf35fe544c3c0fe697880d4afd1 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 10 Aug 2023 09:57:25 +0400 Subject: [PATCH] RichText: Remove 'Footnotes' when interactive formatting is disabled (#53474) Introduce a new 'interactive' setting for format types --- .../src/components/rich-text/use-format-types.js | 6 +++--- packages/block-library/src/footnotes/format.js | 1 + packages/rich-text/src/register-format-type.js | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/rich-text/use-format-types.js b/packages/block-editor/src/components/rich-text/use-format-types.js index f798e41ede4dfb..9d26d619432496 100644 --- a/packages/block-editor/src/components/rich-text/use-format-types.js +++ b/packages/block-editor/src/components/rich-text/use-format-types.js @@ -66,21 +66,21 @@ export function useFormatTypes( { } ) { const allFormatTypes = useSelect( formatTypesSelector, [] ); const formatTypes = useMemo( () => { - return allFormatTypes.filter( ( { name, tagName } ) => { + return allFormatTypes.filter( ( { name, interactive, tagName } ) => { if ( allowedFormats && ! allowedFormats.includes( name ) ) { return false; } if ( withoutInteractiveFormatting && - interactiveContentTags.has( tagName ) + ( interactive || interactiveContentTags.has( tagName ) ) ) { return false; } return true; } ); - }, [ allFormatTypes, allowedFormats, interactiveContentTags ] ); + }, [ allFormatTypes, allowedFormats, withoutInteractiveFormatting ] ); const keyedSelected = useSelect( ( select ) => formatTypes.reduce( ( accumulator, type ) => { diff --git a/packages/block-library/src/footnotes/format.js b/packages/block-library/src/footnotes/format.js index c7730c53316b77..2145845652b66e 100644 --- a/packages/block-library/src/footnotes/format.js +++ b/packages/block-library/src/footnotes/format.js @@ -37,6 +37,7 @@ export const format = { attributes: { 'data-fn': 'data-fn', }, + interactive: true, contentEditable: false, [ usesContextKey ]: [ 'postType' ], edit: function Edit( { diff --git a/packages/rich-text/src/register-format-type.js b/packages/rich-text/src/register-format-type.js index 8ea19a97f595ff..a3ca5b64903f9f 100644 --- a/packages/rich-text/src/register-format-type.js +++ b/packages/rich-text/src/register-format-type.js @@ -13,6 +13,7 @@ import { store as richTextStore } from './store'; * unique across all registered formats. * @property {string} tagName The HTML tag this format will wrap the * selection with. + * @property {boolean} interactive Whether format makes content interactive or not. * @property {string} [className] A class to match the format. * @property {string} title Name of the format. * @property {Function} edit Should return a component for the user to