Skip to content

Commit

Permalink
Editor: Add comment clarifying why we set content to a new function o…
Browse files Browse the repository at this point in the history
…n edits.
  • Loading branch information
epiqueras committed Aug 21, 2019
1 parent 9334354 commit 79d0b6a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,9 @@ export function* resetEditorBlocks( blocks, options = {} ) {
const edits = { blocks: yield* getBlocksWithSourcedAttributes( blocks ) };

if ( options.__unstableShouldCreateUndoLevel !== false ) {
// We create a new function here on every persistent edit
// to make sure the edit makes the post dirty and creates
// a new undo level.
edits.content = ( { blocks: blocksForSerialization = [] } ) =>
serializeBlocks( blocksForSerialization );
}
Expand Down

0 comments on commit 79d0b6a

Please sign in to comment.