Skip to content

Commit

Permalink
Try to filter document styles before creating canvas
Browse files Browse the repository at this point in the history
See: #2.
  • Loading branch information
Mamaduka committed Jan 27, 2020
1 parent e0a868b commit 770f4b3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build/index.asset.php
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-plugins', 'wp-polyfill'), 'version' => '83aa0425765d185c8aad13caae124610');
<?php return array('dependencies' => array('lodash', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-plugins', 'wp-polyfill'), 'version' => '148c2420ee5d0556bf0e3e0245ccf4b0');
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/index.js.map

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion src/util.js
Expand Up @@ -36,7 +36,16 @@ export function captureBlock( id, name ) {
const filename = kebabCase( name ) + '-screenshot';
const block = document.querySelector( `[data-block="${ id }"]` );

html2canvas( block ).then( ( canvas ) => {
// Remove some styles before creating canvas.
const options = {
onclone: ( document ) => {
document.getElementById( `block-${ id }` )
.classList
.remove( 'has-child-selected' );
},
};

html2canvas( block, options ).then( ( canvas ) => {
download( canvas, filename );
} );
}

0 comments on commit 770f4b3

Please sign in to comment.