Skip to content

Commit

Permalink
Editor: Pass meta updates from block as patch
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Oct 23, 2018
1 parent edfa989 commit f37925c
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions packages/editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,14 @@ export class BlockListBlock extends Component {

const metaAttributes = reduce( attributes, ( result, value, key ) => {
if ( get( type, [ 'attributes', key, 'source' ] ) === 'meta' ) {
const metaKey = type.attributes[ key ].meta;
result = {
previous: { [ metaKey ]: this.props.meta[ metaKey ] },
edits: { [ metaKey ]: value },
};
result[ type.attributes[ key ].meta ] = value;
}

return result;
}, {} );

if ( size( metaAttributes ) ) {
this.props.onMetaChange( {
...metaAttributes.previous,
...metaAttributes.edits,
} );
this.props.onMetaChange( metaAttributes );
}
}

Expand Down Expand Up @@ -592,7 +585,6 @@ const applyWithSelect = withSelect( ( select, { clientId, rootClientId, isLargeV
isMultiSelecting,
isTyping,
getBlockIndex,
getEditedPostAttribute,
getBlockMode,
isSelectionEnabled,
getSelectedBlocksInitialCaretPosition,
Expand All @@ -617,7 +609,6 @@ const applyWithSelect = withSelect( ( select, { clientId, rootClientId, isLargeV
// Thus to avoid unnecessary rerenders we avoid updating the prop if the block is not selected.
isTypingWithinBlock: ( isSelected || isParentOfSelectedBlock ) && isTyping(),
order: getBlockIndex( clientId, rootClientId ),
meta: getEditedPostAttribute( 'meta' ),
mode: getBlockMode( clientId ),
isSelectionEnabled: isSelectionEnabled(),
initialPosition: getSelectedBlocksInitialCaretPosition(),
Expand Down

0 comments on commit f37925c

Please sign in to comment.