Skip to content

Commit

Permalink
Remove unwanted RichText Formats (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luehrsen authored Oct 16, 2024
1 parent 5e9bb77 commit f208dda
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions theme/admin/src/js/strip_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
store as blocksStore,
} from '@wordpress/blocks';

import { unregisterFormatType } from '@wordpress/rich-text';

import { select } from '@wordpress/data';

/**
Expand Down Expand Up @@ -73,7 +75,25 @@ function removeAllBlockVariations(blockName) {
}
}

/**
* Curates the allowed formats for the RichText component.
*
* This function removes disallowed formats from the RichText component,
*
* @return {void}
*/
function curateRichTextFormats() {
// Define the allowed formats for the RichText component.
const disallowedFormats = ['core/image', 'core/footnote'];

// Unregister each disallowed format.
for (const format of disallowedFormats) {
unregisterFormatType(format);
}
}

domReady(() => {
removeAllBlockVariations('core/group');
removeAllBlockStyles('core/quote');
curateRichTextFormats();
});

0 comments on commit f208dda

Please sign in to comment.