Skip to content

Commit

Permalink
Gutenberg: When clicking on the Reset button, ensure all properties a…
Browse files Browse the repository at this point in the history
…re wiped out.

See #13.
  • Loading branch information
r-a-y committed Apr 14, 2020
1 parent 005634d commit d0246cf
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions block.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@
return '';
}

if ( attr.hasOwnProperty( 'width' ) ) {
if ( attr.hasOwnProperty( 'width' ) && attr.width ) {
width = attr.width;
}

if ( attr.hasOwnProperty( 'height' ) ) {
if ( attr.hasOwnProperty( 'height' ) && attr.height ) {
height = attr.height;
}

Expand Down Expand Up @@ -118,7 +118,7 @@
// alter the link so we're in embed mode
link = link.replace( 'pub?', 'embed?' );

if ( attr.hasOwnProperty( 'size' ) ) {
if ( attr.hasOwnProperty( 'size' ) && attr.size ) {
size = attr.size;
}

Expand Down Expand Up @@ -298,25 +298,25 @@
icon:{foreground:"#555D66",src:Object(el)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(el)("g",null,Object(el)("path",{d:"M4.433 22.396l4-6.929H24l-4 6.929H4.433zm3.566-6.929l-3.998 6.929L0 15.467 7.785 1.98l3.999 6.931-3.785 6.556zm15.784-.375h-7.999L7.999 1.605h8.002l7.785 13.486h-.003z"})))},
category: 'embed',
attributes: {
link: {
type: 'string'
},
height: {
type: 'number'
},
width: {
type: 'number'
},
seamless: {
downloadlink: {
type: 'number'
},
size: {
type: {
type: 'string'
},
downloadlink: {
seamless: {
type: 'number'
},
link: {
type: 'string'
},
type: {
size: {
type: 'string'
}
},
Expand Down Expand Up @@ -434,10 +434,14 @@
icon: 'trash',
title: i18n.__( 'Reset' ),
onClick: function( event ) {
// Wipe out our link variable so we start from scratch again.
// Reset variables to start fresh.
props.setAttributes({
link: '',
type: ''
type: '',
width: '',
height: '',
size: '',
downloadlink: ''
});
},
}]
Expand Down

0 comments on commit d0246cf

Please sign in to comment.