Skip to content

Commit

Permalink
RichText: Remove 'Footnotes' when interactive formatting is disabled (#…
Browse files Browse the repository at this point in the history
…53474)

Introduce a new 'interactive' setting for format types
  • Loading branch information
Mamaduka authored and tellthemachines committed Aug 14, 2023
1 parent 37d184b commit 9c23d2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) => {
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/footnotes/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const format = {
attributes: {
'data-fn': 'data-fn',
},
interactive: true,
contentEditable: false,
[ usesContextKey ]: [ 'postType' ],
edit: function Edit( {
Expand Down
1 change: 1 addition & 0 deletions packages/rich-text/src/register-format-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c23d2f

Please sign in to comment.