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

Remove unused syncDerivedUpdates action #62229

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {};

Expand Down Expand Up @@ -274,18 +273,13 @@ 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(),
selectionEnd: getSelectionEnd(),
initialPosition:
getSelectedBlocksInitialCaretPosition(),
},
undoIgnore,
} );
}
previousAreBlocksDifferent = areBlocksDifferent;
Expand Down
29 changes: 0 additions & 29 deletions packages/block-editor/src/store/private-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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.
*
Expand Down
4 changes: 0 additions & 4 deletions packages/block-editor/src/store/undo-ignore.js

This file was deleted.

Loading