From f1a4125941beaa5d5bfcdf394a44d3b14a0d268c Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Mon, 3 Jun 2024 12:52:08 +0200 Subject: [PATCH 1/3] Remove `syncDerivedUpdates` function --- .../block-editor/src/store/private-actions.js | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/packages/block-editor/src/store/private-actions.js b/packages/block-editor/src/store/private-actions.js index 28a7b1da98f73f..5e4e0c7a222b0b 100644 --- a/packages/block-editor/src/store/private-actions.js +++ b/packages/block-editor/src/store/private-actions.js @@ -6,7 +6,6 @@ import { Platform } from '@wordpress/element'; /** * Internal dependencies */ -import { undoIgnoreBlocks } from './undo-ignore'; import { store as blockEditorStore } from './index'; import { unlock } from '../lock-unlock'; @@ -292,34 +291,6 @@ export function deleteStyleOverride( id ) { }; } -/** - * A higher-order action that mark every change inside a callback as "non-persistent" - * and ignore pushing to the undo history stack. It's primarily used for synchronized - * derived updates from the block editor without affecting the undo history. - * - * @param {() => void} callback The synchronous callback to derive updates. - */ -export function syncDerivedUpdates( callback ) { - return ( { dispatch, select, registry } ) => { - registry.batch( () => { - // Mark every change in the `callback` as non-persistent. - dispatch( { - type: 'SET_EXPLICIT_PERSISTENT', - isPersistentChange: false, - } ); - callback(); - dispatch( { - type: 'SET_EXPLICIT_PERSISTENT', - isPersistentChange: undefined, - } ); - - // Ignore pushing undo stack for the updated blocks. - const updatedBlocks = select.getBlocks(); - undoIgnoreBlocks.add( updatedBlocks ); - } ); - }; -} - /** * Action that sets the element that had focus when focus leaves the editor canvas. * From 758adcf3fa252449023c15bc8f51440dcda52510 Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Mon, 3 Jun 2024 12:52:33 +0200 Subject: [PATCH 2/3] Remove `syncDerivedUpdates` mention --- packages/block-editor/src/store/undo-ignore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/store/undo-ignore.js b/packages/block-editor/src/store/undo-ignore.js index f0a64428ea7c26..9cf191396e943b 100644 --- a/packages/block-editor/src/store/undo-ignore.js +++ b/packages/block-editor/src/store/undo-ignore.js @@ -1,4 +1,4 @@ // Keep track of the blocks that should not be pushing an additional // undo stack when editing the entity. -// See the implementation of `syncDerivedUpdates` and `useBlockSync`. +// See the implementation of `useBlockSync`. export const undoIgnoreBlocks = new WeakSet(); From d76e28872d72fd983b95f539e07f980774755b85 Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Tue, 4 Jun 2024 09:47:05 +0200 Subject: [PATCH 3/3] Remove unused `undoIgnoreBlocks` --- .../block-editor/src/components/provider/use-block-sync.js | 6 ------ packages/block-editor/src/store/undo-ignore.js | 4 ---- 2 files changed, 10 deletions(-) delete mode 100644 packages/block-editor/src/store/undo-ignore.js diff --git a/packages/block-editor/src/components/provider/use-block-sync.js b/packages/block-editor/src/components/provider/use-block-sync.js index 300c108a70cf1a..4e9cc9784554f5 100644 --- a/packages/block-editor/src/components/provider/use-block-sync.js +++ b/packages/block-editor/src/components/provider/use-block-sync.js @@ -9,7 +9,6 @@ import { cloneBlock } from '@wordpress/blocks'; * Internal dependencies */ import { store as blockEditorStore } from '../../store'; -import { undoIgnoreBlocks } from '../../store/undo-ignore'; const noop = () => {}; @@ -274,10 +273,6 @@ export default function useBlockSync( { const updateParent = isPersistent ? onChangeRef.current : onInputRef.current; - const undoIgnore = undoIgnoreBlocks.has( blocks ); - if ( undoIgnore ) { - undoIgnoreBlocks.delete( blocks ); - } updateParent( blocks, { selection: { selectionStart: getSelectionStart(), @@ -285,7 +280,6 @@ export default function useBlockSync( { initialPosition: getSelectedBlocksInitialCaretPosition(), }, - undoIgnore, } ); } previousAreBlocksDifferent = areBlocksDifferent; diff --git a/packages/block-editor/src/store/undo-ignore.js b/packages/block-editor/src/store/undo-ignore.js deleted file mode 100644 index 9cf191396e943b..00000000000000 --- a/packages/block-editor/src/store/undo-ignore.js +++ /dev/null @@ -1,4 +0,0 @@ -// Keep track of the blocks that should not be pushing an additional -// undo stack when editing the entity. -// See the implementation of `useBlockSync`. -export const undoIgnoreBlocks = new WeakSet();