Skip to content

Instantly share code, notes, and snippets.

@pablocubico
Created May 26, 2020 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pablocubico/b769700ebf5c0f101c5531b180abb53d to your computer and use it in GitHub Desktop.
Save pablocubico/b769700ebf5c0f101c5531b180abb53d to your computer and use it in GitHub Desktop.
// In case we find it's a Webpack/Babel config issue,
// it's possible to create a .babelrc file to override
// WP's Babel defaults, this is a sample file with no overrides,
// just the default config (i.e.: the same as without the file).
{
"presets": [ "@wordpress/default" ]
}
// We are already overriding the default Webpack config for some configurations,
// check `webpack.config.js` in the Blocks Plugin root folder.
// Maybe we could try some Webpack debugging plugins as the Circular Dependency plugin:
// https://github.com/aackerman/circular-dependency-plugin
/**
* We should be able to do something like this
* For the P4TableEdit component, but it doesn't work
* with our current setup:
*/
import { createCustomColorsHOC } from '@wordpress/block-editor';
// This requires installing the `block-library` module:
// `npm install --save @wordpress/block-library`
// It should be possible to import the component we actually need...
import { TableEdit } from '@wordpress/block-library/src/table/edit';
// ...but this line will throw:
// Uncaught TypeError: Cannot read property 'TableEdit' of undefined
console.log(TableEdit);
const BACKGROUND_COLORS = [
{
color: '#f5f7f8',
name: 'Grey',
slug: 'grey'
},
{
color: '#eafee7',
name: 'Green',
slug: 'green'
},
{
color: '#e7f5fe',
name: 'Blue',
slug: 'blue'
}
];
const withCustomBackgroundColors = createCustomColorsHOC( BACKGROUND_COLORS );
export default withCustomBackgroundColors( 'backgroundColor' )( TableEdit );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment