Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Footnotes: Remove extra callback when parsing content #66370

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading