Skip to content

Commit

Permalink
Footnotes: Remove extra callback when parsing content (#66370)
Browse files Browse the repository at this point in the history
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: mcsf <mcsf@git.wordpress.org>
  • Loading branch information
4 people authored Oct 23, 2024
1 parent 77f62e0 commit 609d573
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions packages/core-data/src/hooks/use-entity-block-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ export default function useEntityBlockEditor( kind, name, { id: _id } = {} ) {
getEntityRecordEdits,
] );

const updateFootnotes = useCallback(
( _blocks ) => updateFootnotesFromMeta( _blocks, meta ),
[ meta ]
);

const onChange = useCallback(
( newBlocks, options ) => {
const noChange = blocks === newBlocks;
Expand All @@ -111,7 +106,7 @@ export default function useEntityBlockEditor( kind, name, { id: _id } = {} ) {
selection,
content: ( { blocks: blocksForSerialization = [] } ) =>
__unstableSerializeAndClean( blocksForSerialization ),
...updateFootnotes( newBlocks ),
...updateFootnotesFromMeta( newBlocks, meta ),
};

editEntityRecord( kind, name, id, edits, {
Expand All @@ -124,7 +119,7 @@ export default function useEntityBlockEditor( kind, name, { id: _id } = {} ) {
name,
id,
blocks,
updateFootnotes,
meta,
__unstableCreateUndoLevel,
editEntityRecord,
]
Expand All @@ -133,15 +128,15 @@ export default function useEntityBlockEditor( kind, name, { id: _id } = {} ) {
const onInput = useCallback(
( newBlocks, options ) => {
const { selection, ...rest } = options;
const footnotesChanges = updateFootnotes( newBlocks );
const footnotesChanges = updateFootnotesFromMeta( newBlocks, meta );
const edits = { selection, ...footnotesChanges };

editEntityRecord( kind, name, id, edits, {
isCached: true,
...rest,
} );
},
[ kind, name, id, updateFootnotes, editEntityRecord ]
[ kind, name, id, meta, editEntityRecord ]
);

return [ blocks, onInput, onChange ];
Expand Down

0 comments on commit 609d573

Please sign in to comment.