Skip to content

Commit

Permalink
Remove footnote from RichText toolbar if already present
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsf committed Jul 11, 2023
1 parent 203789b commit 094b137
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/block-library/src/footnotes/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { v4 as createId } from 'uuid';
*/
import { __ } from '@wordpress/i18n';
import { formatListNumbered as icon } from '@wordpress/icons';
import { insertObject } from '@wordpress/rich-text';
import { remove, insertObject } from '@wordpress/rich-text';
import {
RichTextToolbarButton,
store as blockEditorStore,
Expand Down Expand Up @@ -40,7 +40,13 @@ export const format = {
} = useSelect( blockEditorStore );
const { selectionChange, insertBlock } =
useDispatch( blockEditorStore );

function onClick() {
if ( isObjectActive ) {
onChange( remove( value, value.start, value.end ) );
return;
}

registry.batch( () => {
const id = createId();
const newValue = insertObject(
Expand Down

0 comments on commit 094b137

Please sign in to comment.