From 609d573625be035953f3782efdc0589f617b4b78 Mon Sep 17 00:00:00 2001 From: Marin Atanasov <8436925+tyxla@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:57:54 +0300 Subject: [PATCH] Footnotes: Remove extra callback when parsing content (#66370) Co-authored-by: tyxla Co-authored-by: Mamaduka Co-authored-by: mcsf --- .../core-data/src/hooks/use-entity-block-editor.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/core-data/src/hooks/use-entity-block-editor.js b/packages/core-data/src/hooks/use-entity-block-editor.js index 56238097618e1f..df213898659e7d 100644 --- a/packages/core-data/src/hooks/use-entity-block-editor.js +++ b/packages/core-data/src/hooks/use-entity-block-editor.js @@ -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; @@ -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, { @@ -124,7 +119,7 @@ export default function useEntityBlockEditor( kind, name, { id: _id } = {} ) { name, id, blocks, - updateFootnotes, + meta, __unstableCreateUndoLevel, editEntityRecord, ] @@ -133,7 +128,7 @@ 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, { @@ -141,7 +136,7 @@ export default function useEntityBlockEditor( kind, name, { id: _id } = {} ) { ...rest, } ); }, - [ kind, name, id, updateFootnotes, editEntityRecord ] + [ kind, name, id, meta, editEntityRecord ] ); return [ blocks, onInput, onChange ];