Skip to content
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
14 changes: 13 additions & 1 deletion src/block-management/block-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ export default class BlockManager extends React.Component<PropsType, StateType>
return -1;
}

static getDerivedStateFromProps( props: PropsType, state: StateType ) {
if ( props.fullparse === true ) {
return {
...state,
dataSource: new DataSource( props.blocks, ( item: BlockType ) => item.clientId ),
};
}
// no state change necessary
return null;
}

onToolbarButtonPressed( button: number, clientId: string ) {
const dataSourceBlockIndex = this.getDataSourceIndexFromUid( clientId );
switch ( button ) {
Expand Down Expand Up @@ -115,7 +126,8 @@ export default class BlockManager extends React.Component<PropsType, StateType>
const index = this.getDataSourceIndexFromUid( clientId );
const dataSource = this.state.dataSource;
const block = dataSource.get( this.getDataSourceIndexFromUid( clientId ) );
dataSource.set( index, { ...block, attributes: attributes } );
block.attributes = attributes;
dataSource.set( index, block );
// Update Redux store
this.props.onChange( clientId, attributes );
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const reducer = (
}
case ActionTypes.BLOCK.PARSE: {
const parsed = parse(action.html)
return { blocks: parsed, refresh: state.refresh };
return { blocks: parsed, refresh: ! state.refresh, fullparse: true };
}
default:
return state;
Expand Down