From 6ec4102d0ec8aa78b659db45e95ad7a2b436eb2f Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Tue, 28 Aug 2018 23:51:05 -0500 Subject: [PATCH 1/7] Output width and height attributes for all image blocks Before, images only had a width or height if the user edited the elements for those, or clicked a percentage pillbox. This sets the width and height on adding an image, and on selecting from the 'Image Size' select element. It keeps the behavior of the class: This only applied on editing the width or height , or on clicking a percentage pillbox. --- packages/block-library/src/image/edit.js | 37 ++++++++++++------- packages/block-library/src/image/index.js | 17 +++++++-- test/integration/fixtures/evernote-out.html | 2 +- .../integration/fixtures/google-docs-out.html | 2 +- .../fixtures/ms-word-online-out.html | 2 +- test/integration/fixtures/ms-word-out.html | 2 +- test/integration/fixtures/one-image-out.html | 2 +- test/integration/fixtures/two-images-out.html | 4 +- .../full-content/fixtures/core__image.html | 2 +- .../full-content/fixtures/core__image.json | 4 +- .../fixtures/core__image.parsed.json | 2 +- .../fixtures/core__image.serialized.html | 2 +- .../core__image__attachment-link.html | 2 +- .../core__image__attachment-link.json | 4 +- .../core__image__attachment-link.parsed.json | 2 +- ...re__image__attachment-link.serialized.html | 2 +- .../fixtures/core__image__center-caption.html | 2 +- .../fixtures/core__image__center-caption.json | 4 +- .../core__image__center-caption.parsed.json | 2 +- ...ore__image__center-caption.serialized.html | 2 +- .../fixtures/core__image__custom-link.json | 2 + .../core__image__custom-link.serialized.html | 2 +- .../fixtures/core__image__media-link.json | 2 + .../core__image__media-link.serialized.html | 2 +- 24 files changed, 68 insertions(+), 38 deletions(-) diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 2ae93346c923c6..a5576ee37b598f 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -4,6 +4,7 @@ import classnames from 'classnames'; import ResizableBox from 're-resizable'; import { + find, get, isEmpty, map, @@ -63,7 +64,7 @@ class ImageEdit extends Component { this.onFocusCaption = this.onFocusCaption.bind( this ); this.onImageClick = this.onImageClick.bind( this ); this.onSelectImage = this.onSelectImage.bind( this ); - this.updateImageURL = this.updateImageURL.bind( this ); + this.updateSizesAndURL = this.updateSizesAndURL.bind( this ); this.updateWidth = this.updateWidth.bind( this ); this.updateHeight = this.updateHeight.bind( this ); this.updateDimensions = this.updateDimensions.bind( this ); @@ -120,9 +121,7 @@ class ImageEdit extends Component { return; } this.props.setAttributes( { - ...pick( media, [ 'alt', 'id', 'caption', 'url' ] ), - width: undefined, - height: undefined, + ...pick( media, [ 'alt', 'id', 'caption', 'url', 'width', 'height' ] ), } ); } @@ -176,21 +175,33 @@ class ImageEdit extends Component { this.props.setAttributes( { ...extraUpdatedAttributes, align: nextAlign } ); } - updateImageURL( url ) { - this.props.setAttributes( { url, width: undefined, height: undefined } ); + updateSizesAndURL( url ) { + const newAttributes = { url, isResized: false }; + const availableSizes = this.getAvailableSizes(); + + const newSize = find( availableSizes, ( size ) => { + return url === size.source_url; + } ); + + if ( undefined !== newSize && undefined !== newSize.width && undefined !== newSize.height ) { + newAttributes.width = newSize.width; + newAttributes.height = newSize.height; + } + + this.props.setAttributes( newAttributes ); } updateWidth( width ) { - this.props.setAttributes( { width: parseInt( width, 10 ) } ); + this.props.setAttributes( { width: parseInt( width, 10 ), isResized: true } ); } updateHeight( height ) { - this.props.setAttributes( { height: parseInt( height, 10 ) } ); + this.props.setAttributes( { height: parseInt( height, 10 ), isResized: true } ); } updateDimensions( width = undefined, height = undefined ) { return () => { - this.props.setAttributes( { width, height } ); + this.props.setAttributes( { width, height, isResized: !! ( width && height ) } ); }; } @@ -209,7 +220,7 @@ class ImageEdit extends Component { render() { const { attributes, setAttributes, isLargeViewport, isSelected, className, maxWidth, noticeOperations, noticeUI, toggleSelection, isRTL } = this.props; - const { url, alt, caption, align, id, href, linkDestination, width, height } = attributes; + const { url, alt, caption, align, id, href, linkDestination, width, height, isResized } = attributes; const controls = ( @@ -259,7 +270,7 @@ class ImageEdit extends Component { const classes = classnames( className, { 'is-transient': 0 === url.indexOf( 'blob:' ), - 'is-resized': !! width || !! height, + 'is-resized': isResized, 'is-focused': isSelected, } ); @@ -284,7 +295,7 @@ class ImageEdit extends Component { value: size.source_url, label: startCase( name ), } ) ) } - onChange={ this.updateImageURL } + onChange={ this.updateSizesAndURL } /> ) } { isResizable && ( @@ -298,7 +309,6 @@ class ImageEdit extends Component { className="block-library-image__dimensions__width" label={ __( 'Width' ) } value={ width !== undefined ? width : '' } - placeholder={ imageWidth } min={ 1 } onChange={ this.updateWidth } /> @@ -307,7 +317,6 @@ class ImageEdit extends Component { className="block-library-image__dimensions__height" label={ __( 'Height' ) } value={ height !== undefined ? height : '' } - placeholder={ imageHeight } min={ 1 } onChange={ this.updateHeight } /> diff --git a/packages/block-library/src/image/index.js b/packages/block-library/src/image/index.js index e3602a45f85fa3..50a216f87c7d1b 100644 --- a/packages/block-library/src/image/index.js +++ b/packages/block-library/src/image/index.js @@ -57,9 +57,20 @@ const blockAttributes = { }, width: { type: 'number', + source: 'attribute', + selector: 'img', + attribute: 'width', + default: '', }, height: { type: 'number', + source: 'attribute', + selector: 'img', + attribute: 'height', + default: '', + }, + isResized: { + type: 'boolean', }, linkDestination: { type: 'string', @@ -69,7 +80,7 @@ const blockAttributes = { const imageSchema = { img: { - attributes: [ 'src', 'alt' ], + attributes: [ 'src', 'alt', 'width', 'height' ], classes: [ 'alignleft', 'aligncenter', 'alignright', 'alignnone', /^wp-image-\d+$/ ], }, }; @@ -200,11 +211,11 @@ export const settings = { edit, save( { attributes } ) { - const { url, alt, caption, align, href, width, height, id } = attributes; + const { url, alt, caption, align, href, width, height, id, isResized } = attributes; const classes = classnames( { [ `align${ align }` ]: align, - 'is-resized': width || height, + 'is-resized': isResized, } ); const image = ( diff --git a/test/integration/fixtures/evernote-out.html b/test/integration/fixtures/evernote-out.html index f9dee59c5259d3..2b388848dd4b11 100644 --- a/test/integration/fixtures/evernote-out.html +++ b/test/integration/fixtures/evernote-out.html @@ -27,5 +27,5 @@ -
+
diff --git a/test/integration/fixtures/google-docs-out.html b/test/integration/fixtures/google-docs-out.html index d76b19eee24887..3336b581acc139 100644 --- a/test/integration/fixtures/google-docs-out.html +++ b/test/integration/fixtures/google-docs-out.html @@ -31,6 +31,6 @@

This is a heading

-
+
diff --git a/test/integration/fixtures/ms-word-online-out.html b/test/integration/fixtures/ms-word-online-out.html index b61d20c6eb9c85..b7c27b10b542a1 100644 --- a/test/integration/fixtures/ms-word-online-out.html +++ b/test/integration/fixtures/ms-word-online-out.html @@ -23,5 +23,5 @@ -
+
diff --git a/test/integration/fixtures/ms-word-out.html b/test/integration/fixtures/ms-word-out.html index c53c5aaeba2e97..b81f0553a25c49 100644 --- a/test/integration/fixtures/ms-word-out.html +++ b/test/integration/fixtures/ms-word-out.html @@ -55,5 +55,5 @@

This is a heading level 2

-
+
diff --git a/test/integration/fixtures/one-image-out.html b/test/integration/fixtures/one-image-out.html index defa0138370faf..4f80de8db75ebc 100644 --- a/test/integration/fixtures/one-image-out.html +++ b/test/integration/fixtures/one-image-out.html @@ -1,3 +1,3 @@ -
+
diff --git a/test/integration/fixtures/two-images-out.html b/test/integration/fixtures/two-images-out.html index 4b96a052a52b7b..2c6c4e3e4b4585 100644 --- a/test/integration/fixtures/two-images-out.html +++ b/test/integration/fixtures/two-images-out.html @@ -1,7 +1,7 @@ -
+
-
+
diff --git a/test/integration/full-content/fixtures/core__image.html b/test/integration/full-content/fixtures/core__image.html index eda663561a38bf..584d3c6a52472a 100644 --- a/test/integration/full-content/fixtures/core__image.html +++ b/test/integration/full-content/fixtures/core__image.html @@ -1,3 +1,3 @@ -
+
diff --git a/test/integration/full-content/fixtures/core__image.json b/test/integration/full-content/fixtures/core__image.json index 159ec45e1a4ca6..ca57919c3bfbb7 100644 --- a/test/integration/full-content/fixtures/core__image.json +++ b/test/integration/full-content/fixtures/core__image.json @@ -5,11 +5,13 @@ "isValid": true, "attributes": { "url": "https://cldup.com/uuUqE_dXzy.jpg", + "width": 769, + "height": 511, "alt": "", "caption": [], "linkDestination": "none" }, "innerBlocks": [], - "originalContent": "
\"\"
" + "originalContent": "
\"\"
" } ] diff --git a/test/integration/full-content/fixtures/core__image.parsed.json b/test/integration/full-content/fixtures/core__image.parsed.json index eba958b3ec9a38..b4ca411360530c 100644 --- a/test/integration/full-content/fixtures/core__image.parsed.json +++ b/test/integration/full-content/fixtures/core__image.parsed.json @@ -3,7 +3,7 @@ "blockName": "core/image", "attrs": null, "innerBlocks": [], - "innerHTML": "\n
\"\"
\n" + "innerHTML": "\n
\"\"
\n" }, { "attrs": {}, diff --git a/test/integration/full-content/fixtures/core__image.serialized.html b/test/integration/full-content/fixtures/core__image.serialized.html index 5dfb0bac3e5b72..cf768750d0f49c 100644 --- a/test/integration/full-content/fixtures/core__image.serialized.html +++ b/test/integration/full-content/fixtures/core__image.serialized.html @@ -1,3 +1,3 @@ -
+
diff --git a/test/integration/full-content/fixtures/core__image__attachment-link.html b/test/integration/full-content/fixtures/core__image__attachment-link.html index 908250d8ca249c..853ee42aa1aea6 100644 --- a/test/integration/full-content/fixtures/core__image__attachment-link.html +++ b/test/integration/full-content/fixtures/core__image__attachment-link.html @@ -1,3 +1,3 @@ -
+
diff --git a/test/integration/full-content/fixtures/core__image__attachment-link.json b/test/integration/full-content/fixtures/core__image__attachment-link.json index 927d2e6699428f..c3369e40cb512e 100644 --- a/test/integration/full-content/fixtures/core__image__attachment-link.json +++ b/test/integration/full-content/fixtures/core__image__attachment-link.json @@ -6,11 +6,13 @@ "attributes": { "url": "https://cldup.com/uuUqE_dXzy.jpg", "alt": "", + "width": 769, + "height": 511, "caption": [], "href": "http://localhost:8888/?attachment_id=7", "linkDestination": "attachment" }, "innerBlocks": [], - "originalContent": "
\"\"
" + "originalContent": "
\"\"
" } ] diff --git a/test/integration/full-content/fixtures/core__image__attachment-link.parsed.json b/test/integration/full-content/fixtures/core__image__attachment-link.parsed.json index ddf8f9ba6a2642..eba8b1aa9ee525 100644 --- a/test/integration/full-content/fixtures/core__image__attachment-link.parsed.json +++ b/test/integration/full-content/fixtures/core__image__attachment-link.parsed.json @@ -5,7 +5,7 @@ "linkDestination": "attachment" }, "innerBlocks": [], - "innerHTML": "\n
\"\"
\n" + "innerHTML": "\n
\"\"
\n" }, { "attrs": {}, diff --git a/test/integration/full-content/fixtures/core__image__attachment-link.serialized.html b/test/integration/full-content/fixtures/core__image__attachment-link.serialized.html index f5ebb9af4182c5..87cc73420c137c 100644 --- a/test/integration/full-content/fixtures/core__image__attachment-link.serialized.html +++ b/test/integration/full-content/fixtures/core__image__attachment-link.serialized.html @@ -1,3 +1,3 @@ -
+
diff --git a/test/integration/full-content/fixtures/core__image__center-caption.html b/test/integration/full-content/fixtures/core__image__center-caption.html index f383e4b80b1acb..f64053d8fa82eb 100644 --- a/test/integration/full-content/fixtures/core__image__center-caption.html +++ b/test/integration/full-content/fixtures/core__image__center-caption.html @@ -1,3 +1,3 @@ -
Give it a try. Press the "really wide" button on the image toolbar.
+
Give it a try. Press the "really wide" button on the image toolbar.
diff --git a/test/integration/full-content/fixtures/core__image__center-caption.json b/test/integration/full-content/fixtures/core__image__center-caption.json index fed6af1f9f4d8b..4368e97c235fce 100644 --- a/test/integration/full-content/fixtures/core__image__center-caption.json +++ b/test/integration/full-content/fixtures/core__image__center-caption.json @@ -5,15 +5,17 @@ "isValid": true, "attributes": { "url": "https://cldup.com/YLYhpou2oq.jpg", + "width": 1322, "alt": "", "caption": [ "Give it a try. Press the \"really wide\" button on the image toolbar." ], + "height": 511, "align": "center", "linkDestination": "none", "className": "aligncenter" }, "innerBlocks": [], - "originalContent": "
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
" + "originalContent": "
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
" } ] diff --git a/test/integration/full-content/fixtures/core__image__center-caption.parsed.json b/test/integration/full-content/fixtures/core__image__center-caption.parsed.json index 36fd3de1baf561..2b96b51af5319b 100644 --- a/test/integration/full-content/fixtures/core__image__center-caption.parsed.json +++ b/test/integration/full-content/fixtures/core__image__center-caption.parsed.json @@ -5,7 +5,7 @@ "align": "center" }, "innerBlocks": [], - "innerHTML": "\n
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
\n" + "innerHTML": "\n
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
\n" }, { "attrs": {}, diff --git a/test/integration/full-content/fixtures/core__image__center-caption.serialized.html b/test/integration/full-content/fixtures/core__image__center-caption.serialized.html index 9029f4538590a7..9dc98f3214bb90 100644 --- a/test/integration/full-content/fixtures/core__image__center-caption.serialized.html +++ b/test/integration/full-content/fixtures/core__image__center-caption.serialized.html @@ -1,3 +1,3 @@ -
Give it a try. Press the "really wide" button on the image toolbar.
+
Give it a try. Press the "really wide" button on the image toolbar.
diff --git a/test/integration/full-content/fixtures/core__image__custom-link.json b/test/integration/full-content/fixtures/core__image__custom-link.json index 55e604712ac01e..4d481cebd12b45 100644 --- a/test/integration/full-content/fixtures/core__image__custom-link.json +++ b/test/integration/full-content/fixtures/core__image__custom-link.json @@ -5,8 +5,10 @@ "isValid": true, "attributes": { "url": "https://cldup.com/uuUqE_dXzy.jpg", + "width": "", "alt": "", "caption": [], + "height": "", "href": "https://wordpress.org/", "linkDestination": "custom" }, diff --git a/test/integration/full-content/fixtures/core__image__custom-link.serialized.html b/test/integration/full-content/fixtures/core__image__custom-link.serialized.html index 47357bea6b9d48..87c34741eb1bdb 100644 --- a/test/integration/full-content/fixtures/core__image__custom-link.serialized.html +++ b/test/integration/full-content/fixtures/core__image__custom-link.serialized.html @@ -1,3 +1,3 @@ -
+
diff --git a/test/integration/full-content/fixtures/core__image__media-link.json b/test/integration/full-content/fixtures/core__image__media-link.json index 7e10bde887a5f5..7cdb9904d8a4b1 100644 --- a/test/integration/full-content/fixtures/core__image__media-link.json +++ b/test/integration/full-content/fixtures/core__image__media-link.json @@ -7,6 +7,8 @@ "url": "https://cldup.com/uuUqE_dXzy.jpg", "alt": "", "caption": [], + "height": "", + "width": "", "href": "https://cldup.com/uuUqE_dXzy.jpg", "linkDestination": "media" }, diff --git a/test/integration/full-content/fixtures/core__image__media-link.serialized.html b/test/integration/full-content/fixtures/core__image__media-link.serialized.html index 721abac903ff31..86f4f1ebdea667 100644 --- a/test/integration/full-content/fixtures/core__image__media-link.serialized.html +++ b/test/integration/full-content/fixtures/core__image__media-link.serialized.html @@ -1,3 +1,3 @@ -
+
From 8a31f609bd8157846fa861c869d14b109cf0ea64 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Wed, 29 Aug 2018 11:17:47 -0500 Subject: [PATCH 2/7] Trigger Travis build, attempting to correct failed build There was a failed build, based on errors that might not have been related to this PR. --- packages/block-library/src/image/edit.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index a5576ee37b598f..0fd7d3796617dd 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -187,7 +187,6 @@ class ImageEdit extends Component { newAttributes.width = newSize.width; newAttributes.height = newSize.height; } - this.props.setAttributes( newAttributes ); } From 60b4dbcd22c7649290bf73567718b71349a0e8f1 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Wed, 29 Aug 2018 18:42:10 -0500 Subject: [PATCH 3/7] Begin to address failed tests in Travis build The build failed, with an error at test/e2e/specs/adding-blocks.test.js So begin to address this. --- test/e2e/specs/__snapshots__/adding-blocks.test.js.snap | 2 +- test/e2e/specs/__snapshots__/templates.test.js.snap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap b/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap index eaf8254a78cc85..1d027f44f1ae14 100644 --- a/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap +++ b/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap @@ -10,7 +10,7 @@ exports[`adding blocks Should insert content using the placeholder and the regul -
\\"\\"/
+
\\"\\"
diff --git a/test/e2e/specs/__snapshots__/templates.test.js.snap b/test/e2e/specs/__snapshots__/templates.test.js.snap index 137af1dfc1a270..9298fa228429a7 100644 --- a/test/e2e/specs/__snapshots__/templates.test.js.snap +++ b/test/e2e/specs/__snapshots__/templates.test.js.snap @@ -2,7 +2,7 @@ exports[`templates Using a CPT with a predefined template Should add a custom post types with a predefined template 1`] = ` " -
\\"\\"/
+
\\"\\"
From e755c07e2680b8736ef4ebe8b53eb7ca22cada4f Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Wed, 29 Aug 2018 19:05:26 -0500 Subject: [PATCH 4/7] Continue addressing e2e test errors --- test/e2e/specs/__snapshots__/templates.test.js.snap | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/__snapshots__/templates.test.js.snap b/test/e2e/specs/__snapshots__/templates.test.js.snap index 9298fa228429a7..517d2099397703 100644 --- a/test/e2e/specs/__snapshots__/templates.test.js.snap +++ b/test/e2e/specs/__snapshots__/templates.test.js.snap @@ -2,7 +2,7 @@ exports[`templates Using a CPT with a predefined template Should add a custom post types with a predefined template 1`] = ` " -
\\"\\"
+
\\"\\"
@@ -16,7 +16,7 @@ exports[`templates Using a CPT with a predefined template Should add a custom po
-
\\"\\"/
+
\\"\\"
@@ -42,7 +42,7 @@ exports[`templates Using a CPT with a predefined template Should respect user ed
-
\\"\\"/
+
\\"\\"
From 5f0207f865e5b440173d71511e1bf7aaad4feec5 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 8 Sep 2018 17:44:58 -0500 Subject: [PATCH 5/7] Revert snapshot changes, as these were done manually According to the documentation, you're not supposed to edit these files directly. --- test/e2e/specs/__snapshots__/adding-blocks.test.js.snap | 2 +- test/e2e/specs/__snapshots__/templates.test.js.snap | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap b/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap index 1d027f44f1ae14..eaf8254a78cc85 100644 --- a/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap +++ b/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap @@ -10,7 +10,7 @@ exports[`adding blocks Should insert content using the placeholder and the regul -
\\"\\"
+
\\"\\"/
diff --git a/test/e2e/specs/__snapshots__/templates.test.js.snap b/test/e2e/specs/__snapshots__/templates.test.js.snap index 959bb8d972cd49..57e3f63acf6743 100644 --- a/test/e2e/specs/__snapshots__/templates.test.js.snap +++ b/test/e2e/specs/__snapshots__/templates.test.js.snap @@ -2,7 +2,7 @@ exports[`templates Using a CPT with a predefined template Should add a custom post types with a predefined template 1`] = ` " -
\\"\\"
+
\\"\\"/
@@ -16,7 +16,7 @@ exports[`templates Using a CPT with a predefined template Should add a custom po
-
\\"\\"
+
\\"\\"/
@@ -42,7 +42,7 @@ exports[`templates Using a CPT with a predefined template Should respect user ed
-
\\"\\"
+
\\"\\"/
From dfb9fff128b95eccbf8985eb2c5bf458f64bd3ba Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 8 Sep 2018 18:03:42 -0500 Subject: [PATCH 6/7] Update snapshots via npm run test-e2e -- --updateSnapshot The e2e tests failed, so update these. --- test/e2e/specs/__snapshots__/adding-blocks.test.js.snap | 2 +- test/e2e/specs/__snapshots__/templates.test.js.snap | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap b/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap index eaf8254a78cc85..1d027f44f1ae14 100644 --- a/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap +++ b/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap @@ -10,7 +10,7 @@ exports[`adding blocks Should insert content using the placeholder and the regul -
\\"\\"/
+
\\"\\"
diff --git a/test/e2e/specs/__snapshots__/templates.test.js.snap b/test/e2e/specs/__snapshots__/templates.test.js.snap index 57e3f63acf6743..d98b757e2cd526 100644 --- a/test/e2e/specs/__snapshots__/templates.test.js.snap +++ b/test/e2e/specs/__snapshots__/templates.test.js.snap @@ -2,7 +2,7 @@ exports[`templates Using a CPT with a predefined template Should add a custom post types with a predefined template 1`] = ` " -
\\"\\"/
+
\\"\\"
@@ -16,7 +16,7 @@ exports[`templates Using a CPT with a predefined template Should add a custom po
-
\\"\\"/
+
\\"\\"
@@ -42,7 +42,7 @@ exports[`templates Using a CPT with a predefined template Should respect user ed
-
\\"\\"/
+
\\"\\"
@@ -60,6 +60,6 @@ exports[`templates With default post format assigned should not populate new pag exports[`templates With default post format assigned should populate new post with default block for format 1`] = ` " -
\\"\\"/
+
\\"\\"
" `; From 8261cf536326db0c8b7d4c48b283f180771cd5f3 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sun, 9 Sep 2018 20:28:07 -0500 Subject: [PATCH 7/7] Remove the default value of "" for width and height, update tests There was a failing test for this, and it doesn't seem meanignful to have "" values for these. --- packages/block-library/src/image/index.js | 2 -- test/e2e/specs/__snapshots__/adding-blocks.test.js.snap | 2 +- test/e2e/specs/__snapshots__/templates.test.js.snap | 8 ++++---- test/integration/fixtures/evernote-out.html | 2 +- test/integration/fixtures/ms-word-online-out.html | 2 +- .../full-content/fixtures/core__image__custom-link.html | 2 +- .../full-content/fixtures/core__image__custom-link.json | 6 +++--- .../fixtures/core__image__custom-link.parsed.json | 2 +- .../fixtures/core__image__custom-link.serialized.html | 2 +- .../full-content/fixtures/core__image__media-link.html | 2 +- .../full-content/fixtures/core__image__media-link.json | 6 +++--- .../fixtures/core__image__media-link.parsed.json | 2 +- .../fixtures/core__image__media-link.serialized.html | 2 +- 13 files changed, 19 insertions(+), 21 deletions(-) diff --git a/packages/block-library/src/image/index.js b/packages/block-library/src/image/index.js index 18a4274d35f595..953d8f75d16112 100644 --- a/packages/block-library/src/image/index.js +++ b/packages/block-library/src/image/index.js @@ -60,14 +60,12 @@ const blockAttributes = { source: 'attribute', selector: 'img', attribute: 'width', - default: '', }, height: { type: 'number', source: 'attribute', selector: 'img', attribute: 'height', - default: '', }, isResized: { type: 'boolean', diff --git a/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap b/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap index 1d027f44f1ae14..eaf8254a78cc85 100644 --- a/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap +++ b/test/e2e/specs/__snapshots__/adding-blocks.test.js.snap @@ -10,7 +10,7 @@ exports[`adding blocks Should insert content using the placeholder and the regul -
\\"\\"
+
\\"\\"/
diff --git a/test/e2e/specs/__snapshots__/templates.test.js.snap b/test/e2e/specs/__snapshots__/templates.test.js.snap index d98b757e2cd526..57e3f63acf6743 100644 --- a/test/e2e/specs/__snapshots__/templates.test.js.snap +++ b/test/e2e/specs/__snapshots__/templates.test.js.snap @@ -2,7 +2,7 @@ exports[`templates Using a CPT with a predefined template Should add a custom post types with a predefined template 1`] = ` " -
\\"\\"
+
\\"\\"/
@@ -16,7 +16,7 @@ exports[`templates Using a CPT with a predefined template Should add a custom po
-
\\"\\"
+
\\"\\"/
@@ -42,7 +42,7 @@ exports[`templates Using a CPT with a predefined template Should respect user ed
-
\\"\\"
+
\\"\\"/
@@ -60,6 +60,6 @@ exports[`templates With default post format assigned should not populate new pag exports[`templates With default post format assigned should populate new post with default block for format 1`] = ` " -
\\"\\"
+
\\"\\"/
" `; diff --git a/test/integration/fixtures/evernote-out.html b/test/integration/fixtures/evernote-out.html index 2b388848dd4b11..f9dee59c5259d3 100644 --- a/test/integration/fixtures/evernote-out.html +++ b/test/integration/fixtures/evernote-out.html @@ -27,5 +27,5 @@ -
+
diff --git a/test/integration/fixtures/ms-word-online-out.html b/test/integration/fixtures/ms-word-online-out.html index b7c27b10b542a1..b61d20c6eb9c85 100644 --- a/test/integration/fixtures/ms-word-online-out.html +++ b/test/integration/fixtures/ms-word-online-out.html @@ -23,5 +23,5 @@ -
+
diff --git a/test/integration/full-content/fixtures/core__image__custom-link.html b/test/integration/full-content/fixtures/core__image__custom-link.html index 353dc5376b7a46..8c06c007e0ae02 100644 --- a/test/integration/full-content/fixtures/core__image__custom-link.html +++ b/test/integration/full-content/fixtures/core__image__custom-link.html @@ -1,3 +1,3 @@ -
+
diff --git a/test/integration/full-content/fixtures/core__image__custom-link.json b/test/integration/full-content/fixtures/core__image__custom-link.json index 4d481cebd12b45..959b0e3a336cdd 100644 --- a/test/integration/full-content/fixtures/core__image__custom-link.json +++ b/test/integration/full-content/fixtures/core__image__custom-link.json @@ -5,14 +5,14 @@ "isValid": true, "attributes": { "url": "https://cldup.com/uuUqE_dXzy.jpg", - "width": "", + "width": 579, "alt": "", "caption": [], - "height": "", + "height": 385, "href": "https://wordpress.org/", "linkDestination": "custom" }, "innerBlocks": [], - "originalContent": "
\"\"
" + "originalContent": "
\"\"
" } ] diff --git a/test/integration/full-content/fixtures/core__image__custom-link.parsed.json b/test/integration/full-content/fixtures/core__image__custom-link.parsed.json index fc004f13447eac..2430ceed15d256 100644 --- a/test/integration/full-content/fixtures/core__image__custom-link.parsed.json +++ b/test/integration/full-content/fixtures/core__image__custom-link.parsed.json @@ -5,7 +5,7 @@ "linkDestination": "custom" }, "innerBlocks": [], - "innerHTML": "\n
\"\"
\n" + "innerHTML": "\n
\"\"
\n" }, { "attrs": {}, diff --git a/test/integration/full-content/fixtures/core__image__custom-link.serialized.html b/test/integration/full-content/fixtures/core__image__custom-link.serialized.html index 87c34741eb1bdb..4dac5182408b3e 100644 --- a/test/integration/full-content/fixtures/core__image__custom-link.serialized.html +++ b/test/integration/full-content/fixtures/core__image__custom-link.serialized.html @@ -1,3 +1,3 @@ -
+
diff --git a/test/integration/full-content/fixtures/core__image__media-link.html b/test/integration/full-content/fixtures/core__image__media-link.html index 90b3d227117b04..343f7f10dcc6f3 100644 --- a/test/integration/full-content/fixtures/core__image__media-link.html +++ b/test/integration/full-content/fixtures/core__image__media-link.html @@ -1,3 +1,3 @@ -
+
diff --git a/test/integration/full-content/fixtures/core__image__media-link.json b/test/integration/full-content/fixtures/core__image__media-link.json index 7cdb9904d8a4b1..738434c92a28ac 100644 --- a/test/integration/full-content/fixtures/core__image__media-link.json +++ b/test/integration/full-content/fixtures/core__image__media-link.json @@ -7,12 +7,12 @@ "url": "https://cldup.com/uuUqE_dXzy.jpg", "alt": "", "caption": [], - "height": "", - "width": "", + "height": 385, + "width": 579, "href": "https://cldup.com/uuUqE_dXzy.jpg", "linkDestination": "media" }, "innerBlocks": [], - "originalContent": "
\"\"
" + "originalContent": "
\"\"
" } ] diff --git a/test/integration/full-content/fixtures/core__image__media-link.parsed.json b/test/integration/full-content/fixtures/core__image__media-link.parsed.json index a7101b0afa4102..8aa26e0863b4d1 100644 --- a/test/integration/full-content/fixtures/core__image__media-link.parsed.json +++ b/test/integration/full-content/fixtures/core__image__media-link.parsed.json @@ -5,7 +5,7 @@ "linkDestination": "media" }, "innerBlocks": [], - "innerHTML": "\n
\"\"
\n" + "innerHTML": "\n
\"\"
\n" }, { "attrs": {}, diff --git a/test/integration/full-content/fixtures/core__image__media-link.serialized.html b/test/integration/full-content/fixtures/core__image__media-link.serialized.html index 86f4f1ebdea667..3456b746055255 100644 --- a/test/integration/full-content/fixtures/core__image__media-link.serialized.html +++ b/test/integration/full-content/fixtures/core__image__media-link.serialized.html @@ -1,3 +1,3 @@ -
+