@wordpress/block-library 7.8.0 → 7.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/audio/edit.js +1 -0
- package/build/audio/edit.js.map +1 -1
- package/build/audio/save.js +2 -1
- package/build/audio/save.js.map +1 -1
- package/build/avatar/hooks.js +2 -2
- package/build/avatar/hooks.js.map +1 -1
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +1 -24
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +1 -1
- package/build/button/save.js.map +1 -1
- package/build/columns/variations.js +2 -2
- package/build/columns/variations.js.map +1 -1
- package/build/comment-author-name/edit.js +3 -5
- package/build/comment-author-name/edit.js.map +1 -1
- package/build/comment-author-name/index.js +0 -4
- package/build/comment-author-name/index.js.map +1 -1
- package/build/comment-date/edit.js +4 -4
- package/build/comment-date/edit.js.map +1 -1
- package/build/comment-date/index.js +0 -4
- package/build/comment-date/index.js.map +1 -1
- package/build/comment-edit-link/index.js +0 -4
- package/build/comment-edit-link/index.js.map +1 -1
- package/build/comment-reply-link/index.js +0 -4
- package/build/comment-reply-link/index.js.map +1 -1
- package/build/comments/edit.js +10 -2
- package/build/comments/edit.js.map +1 -1
- package/build/comments-title/deprecated.js +0 -3
- package/build/comments-title/deprecated.js.map +1 -1
- package/build/cover/index.js +1 -0
- package/build/cover/index.js.map +1 -1
- package/build/embed/embed-preview.js +1 -0
- package/build/embed/embed-preview.js.map +1 -1
- package/build/embed/icons.js +21 -1
- package/build/embed/icons.js.map +1 -1
- package/build/embed/save.js +1 -0
- package/build/embed/save.js.map +1 -1
- package/build/embed/variations.js +11 -0
- package/build/embed/variations.js.map +1 -1
- package/build/file/edit.js +1 -1
- package/build/file/edit.js.map +1 -1
- package/build/file/save.js +1 -1
- package/build/file/save.js.map +1 -1
- package/build/gallery/gallery.js +1 -1
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/save.js +1 -1
- package/build/gallery/save.js.map +1 -1
- package/build/gallery/transforms.js +2 -2
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/v1/edit.js +3 -3
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/gallery/v1/gallery-image.js +1 -0
- package/build/gallery/v1/gallery-image.js.map +1 -1
- package/build/gallery/v1/gallery.js +1 -1
- package/build/gallery/v1/gallery.js.map +1 -1
- package/build/gallery/v1/save.js +10 -2
- package/build/gallery/v1/save.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/html/edit.js +11 -20
- package/build/html/edit.js.map +1 -1
- package/build/html/preview.js +48 -0
- package/build/html/preview.js.map +1 -0
- package/build/image/edit.native.js +2 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +1 -0
- package/build/image/image.js.map +1 -1
- package/build/image/save.js +1 -0
- package/build/image/save.js.map +1 -1
- package/build/list/v2/transforms.js +33 -17
- package/build/list/v2/transforms.js.map +1 -1
- package/build/list-item/hooks/use-enter.js +7 -4
- package/build/list-item/hooks/use-enter.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +36 -15
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/navigation/edit/index.js +1 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/index.js +9 -0
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +16 -74
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation/view.js +5 -3
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-submenu/view.js +5 -3
- package/build/navigation-submenu/view.js.map +1 -1
- package/build/post-comments-form/edit.js +12 -2
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/form.js +1 -1
- package/build/post-comments-form/form.js.map +1 -1
- package/build/search/edit.js +1 -1
- package/build/search/edit.js.map +1 -1
- package/build/table/edit.js +1 -0
- package/build/table/edit.js.map +1 -1
- package/build/table/save.js +2 -1
- package/build/table/save.js.map +1 -1
- package/build/video/edit.js +1 -0
- package/build/video/edit.js.map +1 -1
- package/build/video/save.js +1 -0
- package/build/video/save.js.map +1 -1
- package/build-module/audio/edit.js +2 -1
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/audio/save.js +3 -2
- package/build-module/audio/save.js.map +1 -1
- package/build-module/avatar/hooks.js +2 -2
- package/build-module/avatar/hooks.js.map +1 -1
- package/build-module/button/edit.js +2 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +1 -24
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +2 -2
- package/build-module/button/save.js.map +1 -1
- package/build-module/columns/variations.js +2 -2
- package/build-module/columns/variations.js.map +1 -1
- package/build-module/comment-author-name/edit.js +3 -5
- package/build-module/comment-author-name/edit.js.map +1 -1
- package/build-module/comment-author-name/index.js +0 -4
- package/build-module/comment-author-name/index.js.map +1 -1
- package/build-module/comment-date/edit.js +4 -4
- package/build-module/comment-date/edit.js.map +1 -1
- package/build-module/comment-date/index.js +0 -4
- package/build-module/comment-date/index.js.map +1 -1
- package/build-module/comment-edit-link/index.js +0 -4
- package/build-module/comment-edit-link/index.js.map +1 -1
- package/build-module/comment-reply-link/index.js +0 -4
- package/build-module/comment-reply-link/index.js.map +1 -1
- package/build-module/comments/edit.js +10 -2
- package/build-module/comments/edit.js.map +1 -1
- package/build-module/comments-title/deprecated.js +0 -3
- package/build-module/comments-title/deprecated.js.map +1 -1
- package/build-module/cover/index.js +1 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/embed/embed-preview.js +2 -1
- package/build-module/embed/embed-preview.js.map +1 -1
- package/build-module/embed/icons.js +19 -0
- package/build-module/embed/icons.js.map +1 -1
- package/build-module/embed/save.js +2 -1
- package/build-module/embed/save.js.map +1 -1
- package/build-module/embed/variations.js +12 -1
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/file/edit.js +2 -2
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/save.js +2 -2
- package/build-module/file/save.js.map +1 -1
- package/build-module/gallery/gallery.js +2 -2
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/save.js +2 -2
- package/build-module/gallery/save.js.map +1 -1
- package/build-module/gallery/transforms.js +3 -3
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/v1/edit.js +4 -4
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/gallery/v1/gallery-image.js +2 -1
- package/build-module/gallery/v1/gallery-image.js.map +1 -1
- package/build-module/gallery/v1/gallery.js +2 -2
- package/build-module/gallery/v1/gallery.js.map +1 -1
- package/build-module/gallery/v1/save.js +8 -3
- package/build-module/gallery/v1/save.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/html/edit.js +12 -23
- package/build-module/html/edit.js.map +1 -1
- package/build-module/html/preview.js +38 -0
- package/build-module/html/preview.js.map +1 -0
- package/build-module/image/edit.native.js +2 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +2 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/save.js +2 -1
- package/build-module/image/save.js.map +1 -1
- package/build-module/list/v2/transforms.js +32 -17
- package/build-module/list/v2/transforms.js.map +1 -1
- package/build-module/list-item/hooks/use-enter.js +7 -4
- package/build-module/list-item/hooks/use-enter.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +34 -15
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/index.js +9 -0
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +17 -75
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation/view.js +5 -3
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-submenu/view.js +5 -3
- package/build-module/navigation-submenu/view.js.map +1 -1
- package/build-module/post-comments-form/edit.js +12 -3
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +2 -2
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/search/edit.js +2 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/table/edit.js +2 -1
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table/save.js +3 -2
- package/build-module/table/save.js.map +1 -1
- package/build-module/video/edit.js +2 -1
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/save.js +2 -1
- package/build-module/video/save.js.map +1 -1
- package/build-style/button/style-rtl.css +5 -0
- package/build-style/button/style.css +5 -0
- package/build-style/editor-rtl.css +3 -0
- package/build-style/editor.css +3 -0
- package/build-style/file/style-rtl.css +5 -8
- package/build-style/file/style.css +5 -8
- package/build-style/navigation/style-rtl.css +9 -1
- package/build-style/navigation/style.css +9 -1
- package/build-style/post-comments/style-rtl.css +2 -1
- package/build-style/post-comments/style.css +2 -1
- package/build-style/post-comments-form/editor-rtl.css +3 -0
- package/build-style/post-comments-form/editor.css +3 -0
- package/build-style/post-template/style-rtl.css +9 -18
- package/build-style/post-template/style.css +9 -18
- package/build-style/search/style-rtl.css +6 -8
- package/build-style/search/style.css +6 -8
- package/build-style/style-rtl.css +36 -36
- package/build-style/style.css +36 -36
- package/package.json +28 -28
- package/src/audio/edit.js +4 -0
- package/src/audio/save.js +12 -2
- package/src/avatar/hooks.js +6 -9
- package/src/button/block.json +1 -24
- package/src/button/edit.js +2 -2
- package/src/button/save.js +2 -2
- package/src/button/style.scss +10 -0
- package/src/columns/variations.js +2 -2
- package/src/comment-author-name/block.json +0 -4
- package/src/comment-author-name/edit.js +3 -12
- package/src/comment-date/block.json +0 -4
- package/src/comment-date/edit.js +10 -14
- package/src/comment-date/index.php +0 -3
- package/src/comment-edit-link/block.json +0 -4
- package/src/comment-reply-link/block.json +0 -4
- package/src/comments/edit.js +24 -4
- package/src/comments-title/deprecated.js +0 -2
- package/src/cover/block.json +1 -0
- package/src/cover/index.php +21 -8
- package/src/embed/embed-preview.js +8 -1
- package/src/embed/icons.js +25 -0
- package/src/embed/save.js +10 -2
- package/src/embed/test/__snapshots__/index.native.js.snap +1 -1
- package/src/embed/variations.js +10 -0
- package/src/file/edit.js +4 -2
- package/src/file/save.js +2 -2
- package/src/file/style.scss +5 -5
- package/src/freeform/editor.scss +0 -2
- package/src/gallery/gallery.js +9 -2
- package/src/gallery/index.php +4 -0
- package/src/gallery/save.js +5 -1
- package/src/gallery/test/__snapshots__/index.native.js.snap +2 -2
- package/src/gallery/test/helpers.native.js +11 -198
- package/src/gallery/test/index.native.js +19 -29
- package/src/gallery/transforms.js +3 -3
- package/src/gallery/v1/edit.js +3 -4
- package/src/gallery/v1/gallery-image.js +4 -0
- package/src/gallery/v1/gallery.js +8 -2
- package/src/gallery/v1/save.js +20 -3
- package/src/group/block.json +1 -0
- package/src/html/edit.js +10 -40
- package/src/html/preview.js +46 -0
- package/src/image/edit.native.js +1 -0
- package/src/image/image.js +2 -0
- package/src/image/save.js +10 -2
- package/src/image/test/edit.native.js +51 -19
- package/src/list/v2/transforms.js +22 -7
- package/src/list-item/hooks/use-enter.js +9 -6
- package/src/list-item/hooks/use-outdent-list-item.js +48 -21
- package/src/navigation/block.json +9 -0
- package/src/navigation/edit/index.js +1 -0
- package/src/navigation/style.scss +10 -1
- package/src/navigation/test/use-navigation-menu.js +16 -11
- package/src/navigation/use-navigation-menu.js +26 -83
- package/src/navigation/view.js +7 -2
- package/src/navigation-submenu/view.js +7 -2
- package/src/post-comments/index.php +1 -1
- package/src/post-comments/style.scss +7 -3
- package/src/post-comments-form/edit.js +20 -3
- package/src/post-comments-form/editor.scss +4 -0
- package/src/post-comments-form/form.js +2 -2
- package/src/post-comments-form/index.php +1 -1
- package/src/post-featured-image/index.php +4 -2
- package/src/post-template/index.php +15 -3
- package/src/post-template/style.scss +1 -7
- package/src/search/edit.js +2 -2
- package/src/search/index.php +12 -10
- package/src/search/style.scss +9 -8
- package/src/table/edit.js +2 -0
- package/src/table/save.js +6 -1
- package/src/video/edit.js +4 -0
- package/src/video/save.js +10 -2
|
@@ -13,7 +13,11 @@ import classnames from 'classnames/dedupe';
|
|
|
13
13
|
*/
|
|
14
14
|
import { __, sprintf } from '@wordpress/i18n';
|
|
15
15
|
import { Placeholder, SandBox } from '@wordpress/components';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
RichText,
|
|
18
|
+
BlockIcon,
|
|
19
|
+
__experimentalGetElementClassName,
|
|
20
|
+
} from '@wordpress/block-editor';
|
|
17
21
|
import { Component } from '@wordpress/element';
|
|
18
22
|
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
19
23
|
|
|
@@ -140,6 +144,9 @@ class EmbedPreview extends Component {
|
|
|
140
144
|
{ ( ! RichText.isEmpty( caption ) || isSelected ) && (
|
|
141
145
|
<RichText
|
|
142
146
|
tagName="figcaption"
|
|
147
|
+
className={ __experimentalGetElementClassName(
|
|
148
|
+
'caption'
|
|
149
|
+
) }
|
|
143
150
|
placeholder={ __( 'Add caption' ) }
|
|
144
151
|
value={ caption }
|
|
145
152
|
onChange={ onCaptionChange }
|
package/src/embed/icons.js
CHANGED
|
@@ -153,3 +153,28 @@ export const embedWolframIcon = (
|
|
|
153
153
|
<Path d="M32.59521,22.001l4.31885-4.84473-6.34131-1.38379.646-6.459-5.94336,2.61035L22,6.31934l-3.27344,5.60351L12.78418,9.3125l.645,6.458L7.08643,17.15234,11.40479,21.999,7.08594,26.84375l6.34131,1.38379-.64551,6.458,5.94287-2.60938L22,37.68066l3.27344-5.60351,5.94287,2.61035-.64551-6.458,6.34277-1.38183Zm.44385,2.75244L30.772,23.97827l-1.59558-2.07391,1.97888.735Zm-8.82147,6.1579L22.75,33.424V30.88977l1.52228-2.22168ZM18.56226,13.48816,19.819,15.09534l-2.49219-.88642L15.94037,12.337Zm6.87719.00116,2.62043-1.15027-1.38654,1.86981L24.183,15.0946Zm3.59357,2.6029-1.22546,1.7381.07525-2.73486,1.44507-1.94867ZM22,29.33008l-2.16406-3.15686L22,23.23688l2.16406,2.93634Zm-4.25458-9.582-.10528-3.836,3.60986,1.284v3.73242Zm5.00458-2.552,3.60986-1.284-.10528,3.836L22.75,20.92853Zm-7.78174-1.10559-.29352-2.94263,1.44245,1.94739.07519,2.73321Zm2.30982,5.08319,3.50817,1.18164-2.16247,2.9342-3.678-1.08447Zm2.4486,7.49285L21.25,30.88977v2.53485L19.78052,30.91Zm3.48707-6.31121,3.50817-1.18164,2.33228,3.03137-3.678,1.08447Zm10.87219-4.28113-2.714,3.04529L28.16418,19.928l1.92176-2.72565ZM24.06036,12.81769l-2.06012,2.6322-2.059-2.63318L22,9.292ZM9.91455,18.07227l4.00079-.87195,1.921,2.72735-3.20794,1.19019Zm2.93024,4.565,1.9801-.73462L13.228,23.97827l-2.26838.77429Zm-1.55591,3.58819L13.701,25.4021l2.64935.78058-2.14447.67853Zm3.64868,1.977L18.19,27.17334l.08313,3.46332L14.52979,32.2793Zm10.7876,2.43549.08447-3.464,3.25165,1.03052.407,4.07684Zm4.06824-3.77478-2.14545-.68,2.65063-.781,2.41266.825Z" />
|
|
154
154
|
</SVG>
|
|
155
155
|
);
|
|
156
|
+
|
|
157
|
+
export const embedPocketCastsIcon = {
|
|
158
|
+
foreground: '#f43e37',
|
|
159
|
+
src: (
|
|
160
|
+
<SVG
|
|
161
|
+
width="24"
|
|
162
|
+
height="24"
|
|
163
|
+
viewBox="0 0 24 24"
|
|
164
|
+
fill="none"
|
|
165
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
166
|
+
>
|
|
167
|
+
<Path
|
|
168
|
+
fillRule="evenodd"
|
|
169
|
+
clipRule="evenodd"
|
|
170
|
+
d="M24,12A12,12,0,1,1,12,0,12,12,0,0,1,24,12Z"
|
|
171
|
+
/>
|
|
172
|
+
<Path
|
|
173
|
+
fillRule="evenodd"
|
|
174
|
+
clipRule="evenodd"
|
|
175
|
+
d="M2.67,12a9.33,9.33,0,0,1,18.66,0H19a7,7,0,1,0-7,7v2.33A9.33,9.33,0,0,1,2.67,12ZM12,17.6A5.6,5.6,0,1,1,17.6,12h-2A3.56,3.56,0,1,0,12,15.56Z"
|
|
176
|
+
fill="#fff"
|
|
177
|
+
/>
|
|
178
|
+
</SVG>
|
|
179
|
+
),
|
|
180
|
+
};
|
package/src/embed/save.js
CHANGED
|
@@ -6,7 +6,11 @@ import classnames from 'classnames/dedupe';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
RichText,
|
|
11
|
+
useBlockProps,
|
|
12
|
+
__experimentalGetElementClassName,
|
|
13
|
+
} from '@wordpress/block-editor';
|
|
10
14
|
|
|
11
15
|
export default function save( { attributes } ) {
|
|
12
16
|
const { url, caption, type, providerNameSlug } = attributes;
|
|
@@ -27,7 +31,11 @@ export default function save( { attributes } ) {
|
|
|
27
31
|
{ `\n${ url }\n` /* URL needs to be on its own line. */ }
|
|
28
32
|
</div>
|
|
29
33
|
{ ! RichText.isEmpty( caption ) && (
|
|
30
|
-
<RichText.Content
|
|
34
|
+
<RichText.Content
|
|
35
|
+
className={ __experimentalGetElementClassName( 'caption' ) }
|
|
36
|
+
tagName="figcaption"
|
|
37
|
+
value={ caption }
|
|
38
|
+
/>
|
|
31
39
|
) }
|
|
32
40
|
</figure>
|
|
33
41
|
);
|
|
@@ -186,6 +186,6 @@ exports[`Embed block sets block caption 1`] = `
|
|
|
186
186
|
"<!-- wp:embed {\\"url\\":\\"https://twitter.com/notnownikki\\",\\"type\\":\\"rich\\",\\"providerNameSlug\\":\\"twitter\\",\\"responsive\\":true} -->
|
|
187
187
|
<figure class=\\"wp-block-embed is-type-rich is-provider-twitter wp-block-embed-twitter\\"><div class=\\"wp-block-embed__wrapper\\">
|
|
188
188
|
https://twitter.com/notnownikki
|
|
189
|
-
</div><figcaption>Caption</figcaption></figure>
|
|
189
|
+
</div><figcaption class=\\"wp-element-caption\\">Caption</figcaption></figure>
|
|
190
190
|
<!-- /wp:embed -->"
|
|
191
191
|
`;
|
package/src/embed/variations.js
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
embedDailymotionIcon,
|
|
27
27
|
embedPinterestIcon,
|
|
28
28
|
embedWolframIcon,
|
|
29
|
+
embedPocketCastsIcon,
|
|
29
30
|
} from './icons';
|
|
30
31
|
|
|
31
32
|
/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
|
|
@@ -216,6 +217,15 @@ const variations = [
|
|
|
216
217
|
patterns: [ /^https?:\/\/(www\.)?mixcloud\.com\/.+/i ],
|
|
217
218
|
attributes: { providerNameSlug: 'mixcloud', responsive: true },
|
|
218
219
|
},
|
|
220
|
+
{
|
|
221
|
+
name: 'pocketcasts',
|
|
222
|
+
title: 'Pocket Casts',
|
|
223
|
+
icon: embedPocketCastsIcon,
|
|
224
|
+
keywords: [ __( 'podcast' ), __( 'audio' ) ],
|
|
225
|
+
description: __( 'Embed a podcast player from Pocket Casts.' ),
|
|
226
|
+
patterns: [ /^https:\/\/pca.st\/\w+/i ],
|
|
227
|
+
attributes: { providerNameSlug: 'pocketcasts', responsive: true },
|
|
228
|
+
},
|
|
219
229
|
{
|
|
220
230
|
name: 'reddit',
|
|
221
231
|
title: 'Reddit',
|
package/src/file/edit.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
RichText,
|
|
23
23
|
useBlockProps,
|
|
24
24
|
store as blockEditorStore,
|
|
25
|
-
|
|
25
|
+
__experimentalGetElementClassName,
|
|
26
26
|
} from '@wordpress/block-editor';
|
|
27
27
|
import { useEffect } from '@wordpress/element';
|
|
28
28
|
import { useCopyToClipboard } from '@wordpress/compose';
|
|
@@ -302,7 +302,9 @@ function FileEdit( {
|
|
|
302
302
|
aria-label={ __( 'Download button text' ) }
|
|
303
303
|
className={ classnames(
|
|
304
304
|
'wp-block-file__button',
|
|
305
|
-
|
|
305
|
+
__experimentalGetElementClassName(
|
|
306
|
+
'button'
|
|
307
|
+
)
|
|
306
308
|
) }
|
|
307
309
|
value={ downloadButtonText }
|
|
308
310
|
withoutInteractiveFormatting
|
package/src/file/save.js
CHANGED
|
@@ -9,7 +9,7 @@ import classnames from 'classnames';
|
|
|
9
9
|
import {
|
|
10
10
|
RichText,
|
|
11
11
|
useBlockProps,
|
|
12
|
-
|
|
12
|
+
__experimentalGetElementClassName,
|
|
13
13
|
} from '@wordpress/block-editor';
|
|
14
14
|
import { __, sprintf } from '@wordpress/i18n';
|
|
15
15
|
|
|
@@ -74,7 +74,7 @@ export default function save( { attributes } ) {
|
|
|
74
74
|
href={ href }
|
|
75
75
|
className={ classnames(
|
|
76
76
|
'wp-block-file__button',
|
|
77
|
-
|
|
77
|
+
__experimentalGetElementClassName( 'button' )
|
|
78
78
|
) }
|
|
79
79
|
download={ true }
|
|
80
80
|
aria-describedby={ describedById }
|
package/src/file/style.scss
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
.wp-block-file {
|
|
2
2
|
margin-bottom: 1.5em;
|
|
3
3
|
|
|
4
|
+
&:not(.wp-element-button) {
|
|
5
|
+
font-size: 0.8em;
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
&.aligncenter {
|
|
5
9
|
text-align: center;
|
|
6
10
|
}
|
|
@@ -20,15 +24,11 @@
|
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
//This needs a low specificity so it won't override the rules from the button element if defined in theme.json.
|
|
23
|
-
.wp-block-file__button {
|
|
24
|
-
background: #32373c;
|
|
27
|
+
:where(.wp-block-file__button) {
|
|
25
28
|
border-radius: 2em;
|
|
26
|
-
color: $white;
|
|
27
|
-
font-size: 0.8em;
|
|
28
29
|
padding: 0.5em 1em;
|
|
29
30
|
|
|
30
31
|
&:is(a) {
|
|
31
|
-
text-decoration: none;
|
|
32
32
|
|
|
33
33
|
&:hover,
|
|
34
34
|
&:visited,
|
package/src/freeform/editor.scss
CHANGED
package/src/gallery/gallery.js
CHANGED
|
@@ -6,7 +6,11 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
RichText,
|
|
11
|
+
useInnerBlocksProps,
|
|
12
|
+
__experimentalGetElementClassName,
|
|
13
|
+
} from '@wordpress/block-editor';
|
|
10
14
|
import { VisuallyHidden } from '@wordpress/components';
|
|
11
15
|
import { useState, useEffect } from '@wordpress/element';
|
|
12
16
|
import { __ } from '@wordpress/i18n';
|
|
@@ -82,7 +86,10 @@ export const Gallery = ( props ) => {
|
|
|
82
86
|
captionFocused={ captionFocused }
|
|
83
87
|
onFocusCaption={ onFocusCaption }
|
|
84
88
|
tagName="figcaption"
|
|
85
|
-
className=
|
|
89
|
+
className={ classnames(
|
|
90
|
+
'blocks-gallery-caption',
|
|
91
|
+
__experimentalGetElementClassName( 'caption' )
|
|
92
|
+
) }
|
|
86
93
|
aria-label={ __( 'Gallery caption text' ) }
|
|
87
94
|
placeholder={ __( 'Write gallery caption…' ) }
|
|
88
95
|
value={ caption }
|
package/src/gallery/index.php
CHANGED
|
@@ -50,9 +50,13 @@ function block_core_gallery_render( $attributes, $content ) {
|
|
|
50
50
|
// because we only want to match against the value, not the CSS attribute.
|
|
51
51
|
if ( is_array( $gap ) ) {
|
|
52
52
|
foreach ( $gap as $key => $value ) {
|
|
53
|
+
// Make sure $value is a string to avoid PHP 8.1 deprecation error in preg_match() when the value is null.
|
|
54
|
+
$value = is_string( $value ) ? $value : '';
|
|
53
55
|
$gap[ $key ] = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value;
|
|
54
56
|
}
|
|
55
57
|
} else {
|
|
58
|
+
// Make sure $gap is a string to avoid PHP 8.1 deprecation error in preg_match() when the value is null.
|
|
59
|
+
$gap = is_string( $gap ) ? $gap : '';
|
|
56
60
|
$gap = $gap && preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap;
|
|
57
61
|
}
|
|
58
62
|
|
package/src/gallery/save.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
RichText,
|
|
11
11
|
useBlockProps,
|
|
12
12
|
useInnerBlocksProps,
|
|
13
|
+
__experimentalGetElementClassName,
|
|
13
14
|
} from '@wordpress/block-editor';
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -39,7 +40,10 @@ export default function saveWithInnerBlocks( { attributes } ) {
|
|
|
39
40
|
{ ! RichText.isEmpty( caption ) && (
|
|
40
41
|
<RichText.Content
|
|
41
42
|
tagName="figcaption"
|
|
42
|
-
className=
|
|
43
|
+
className={ classnames(
|
|
44
|
+
'blocks-gallery-caption',
|
|
45
|
+
__experimentalGetElementClassName( 'caption' )
|
|
46
|
+
) }
|
|
43
47
|
value={ caption }
|
|
44
48
|
/>
|
|
45
49
|
) }
|
|
@@ -114,14 +114,14 @@ exports[`Gallery block sets caption to gallery 1`] = `
|
|
|
114
114
|
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
|
|
115
115
|
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":2000} -->
|
|
116
116
|
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/></figure>
|
|
117
|
-
<!-- /wp:image --><figcaption class=\\"blocks-gallery-caption\\"><strong>Bold</strong> <em>italic</em> <s>strikethrough</s> gallery caption</figcaption></figure>
|
|
117
|
+
<!-- /wp:image --><figcaption class=\\"blocks-gallery-caption wp-element-caption\\"><strong>Bold</strong> <em>italic</em> <s>strikethrough</s> gallery caption</figcaption></figure>
|
|
118
118
|
<!-- /wp:gallery -->"
|
|
119
119
|
`;
|
|
120
120
|
|
|
121
121
|
exports[`Gallery block sets caption to gallery items 1`] = `
|
|
122
122
|
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
|
|
123
123
|
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":2000} -->
|
|
124
|
-
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/><figcaption><strong>Bold</strong> <em>italic</em> <s>strikethrough</s> image caption</figcaption></figure>
|
|
124
|
+
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/><figcaption class=\\"wp-element-caption\\"><strong>Bold</strong> <em>italic</em> <s>strikethrough</s> image caption</figcaption></figure>
|
|
125
125
|
<!-- /wp:image --></figure>
|
|
126
126
|
<!-- /wp:gallery -->"
|
|
127
127
|
`;
|
|
@@ -2,28 +2,14 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
initializeEditor,
|
|
5
|
+
addBlock,
|
|
7
6
|
fireEvent,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
getBlock,
|
|
8
|
+
getInnerBlock,
|
|
9
|
+
initializeEditor,
|
|
10
|
+
triggerBlockListLayout,
|
|
11
11
|
} from 'test/helpers';
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* WordPress dependencies
|
|
15
|
-
*/
|
|
16
|
-
import {
|
|
17
|
-
requestMediaPicker,
|
|
18
|
-
subscribeMediaUpload,
|
|
19
|
-
} from '@wordpress/react-native-bridge';
|
|
20
|
-
import {
|
|
21
|
-
MEDIA_UPLOAD_STATE_UPLOADING,
|
|
22
|
-
MEDIA_UPLOAD_STATE_SUCCEEDED,
|
|
23
|
-
MEDIA_UPLOAD_STATE_FAILED,
|
|
24
|
-
MEDIA_UPLOAD_STATE_RESET,
|
|
25
|
-
} from '@wordpress/block-editor';
|
|
26
|
-
|
|
27
13
|
/**
|
|
28
14
|
* Adds a Gallery block via the block picker.
|
|
29
15
|
*
|
|
@@ -31,54 +17,10 @@ import {
|
|
|
31
17
|
*/
|
|
32
18
|
export const addGalleryBlock = async () => {
|
|
33
19
|
const screen = await initializeEditor();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
fireEvent.press( getByA11yLabel( 'Add block' ) );
|
|
37
|
-
|
|
38
|
-
const blockList = getByTestId( 'InserterUI-Blocks' );
|
|
39
|
-
// onScroll event used to force the FlatList to render all items
|
|
40
|
-
fireEvent.scroll( blockList, {
|
|
41
|
-
nativeEvent: {
|
|
42
|
-
contentOffset: { y: 0, x: 0 },
|
|
43
|
-
contentSize: { width: 100, height: 100 },
|
|
44
|
-
layoutMeasurement: { width: 100, height: 100 },
|
|
45
|
-
},
|
|
46
|
-
} );
|
|
47
|
-
|
|
48
|
-
fireEvent.press( await waitFor( () => getByText( 'Gallery' ) ) );
|
|
49
|
-
|
|
20
|
+
await addBlock( screen, 'Gallery' );
|
|
50
21
|
return screen;
|
|
51
22
|
};
|
|
52
23
|
|
|
53
|
-
/**
|
|
54
|
-
* The gallery items are rendered via the FlatList of the inner block list.
|
|
55
|
-
* In order to render the items of a FlatList, it's required to trigger the
|
|
56
|
-
* "onLayout" event. Additionally, the call is wrapped over "waitForStoreResolvers"
|
|
57
|
-
* because the gallery items request the media data associated with the image to
|
|
58
|
-
* be rendered via the "getMedia" selector.
|
|
59
|
-
*
|
|
60
|
-
* @param {import('react-test-renderer').ReactTestInstance} galleryBlock Gallery block instance to trigger layout event.
|
|
61
|
-
* @param {Object} [options] Configuration options for the event.
|
|
62
|
-
* @param {number} [options.width] Width value to be passed to the event.
|
|
63
|
-
*/
|
|
64
|
-
export const triggerGalleryLayout = async (
|
|
65
|
-
galleryBlock,
|
|
66
|
-
{ width = 320 } = {}
|
|
67
|
-
) =>
|
|
68
|
-
waitForStoreResolvers( () =>
|
|
69
|
-
fireEvent(
|
|
70
|
-
within( galleryBlock ).getByTestId( 'block-list-wrapper' ),
|
|
71
|
-
'layout',
|
|
72
|
-
{
|
|
73
|
-
nativeEvent: {
|
|
74
|
-
layout: {
|
|
75
|
-
width,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
);
|
|
81
|
-
|
|
82
24
|
/**
|
|
83
25
|
* Initialize the editor with HTML generated of Gallery block.
|
|
84
26
|
*
|
|
@@ -106,12 +48,11 @@ export const initializeWithGalleryBlock = async ( {
|
|
|
106
48
|
useLocalUrl,
|
|
107
49
|
} );
|
|
108
50
|
const screen = await initializeEditor( { initialHtml } );
|
|
109
|
-
const { getByA11yLabel } = screen;
|
|
110
51
|
|
|
111
|
-
const galleryBlock =
|
|
52
|
+
const galleryBlock = getBlock( screen, 'Gallery' );
|
|
112
53
|
|
|
113
54
|
if ( numberOfItems > 0 ) {
|
|
114
|
-
await
|
|
55
|
+
await triggerBlockListLayout( galleryBlock, { width } );
|
|
115
56
|
}
|
|
116
57
|
|
|
117
58
|
if ( selected ) {
|
|
@@ -125,109 +66,11 @@ export const initializeWithGalleryBlock = async ( {
|
|
|
125
66
|
* Gets a gallery item within a Gallery block.
|
|
126
67
|
*
|
|
127
68
|
* @param {import('react-test-renderer').ReactTestInstance} galleryBlock Gallery block instance.
|
|
128
|
-
* @param {number}
|
|
69
|
+
* @param {number} rowIndex Row position within the Gallery block.
|
|
129
70
|
* @return {import('react-test-renderer').ReactTestInstance} Gallery item.
|
|
130
71
|
*/
|
|
131
|
-
export const getGalleryItem = ( galleryBlock,
|
|
132
|
-
|
|
133
|
-
new RegExp( `Image Block\\. Row ${ rowPosition }` )
|
|
134
|
-
);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Sets up the media upload mock functions for testing.
|
|
139
|
-
*
|
|
140
|
-
* @typedef {Object} MediaUploadMockFunctions
|
|
141
|
-
* @property {Function} notifyUploadingState Notify uploading state for a media item.
|
|
142
|
-
* @property {Function} notifySucceedState Notify succeed state for a media item.
|
|
143
|
-
* @property {Function} notifyFailedState Notify failed state for a media item.
|
|
144
|
-
* @property {Function} notifyResetState Notify reset state for a media item.
|
|
145
|
-
*
|
|
146
|
-
* @return {MediaUploadMockFunctions} Notify state functions.
|
|
147
|
-
*/
|
|
148
|
-
export const setupMediaUpload = () => {
|
|
149
|
-
const mediaUploadListeners = [];
|
|
150
|
-
subscribeMediaUpload.mockImplementation( ( callback ) => {
|
|
151
|
-
mediaUploadListeners.push( callback );
|
|
152
|
-
return { remove: jest.fn() };
|
|
153
|
-
} );
|
|
154
|
-
const notifyMediaUpload = ( payload ) =>
|
|
155
|
-
mediaUploadListeners.forEach( ( listener ) => listener( payload ) );
|
|
156
|
-
|
|
157
|
-
return {
|
|
158
|
-
notifyUploadingState: async ( mediaItem ) =>
|
|
159
|
-
act( async () => {
|
|
160
|
-
notifyMediaUpload( {
|
|
161
|
-
state: MEDIA_UPLOAD_STATE_UPLOADING,
|
|
162
|
-
mediaId: mediaItem.localId,
|
|
163
|
-
progress: 0.25,
|
|
164
|
-
} );
|
|
165
|
-
} ),
|
|
166
|
-
notifySucceedState: async ( mediaItem ) =>
|
|
167
|
-
act( async () => {
|
|
168
|
-
notifyMediaUpload( {
|
|
169
|
-
state: MEDIA_UPLOAD_STATE_SUCCEEDED,
|
|
170
|
-
mediaId: mediaItem.localId,
|
|
171
|
-
mediaUrl: mediaItem.serverUrl,
|
|
172
|
-
mediaServerId: mediaItem.serverId,
|
|
173
|
-
} );
|
|
174
|
-
} ),
|
|
175
|
-
notifyFailedState: async ( mediaItem ) =>
|
|
176
|
-
act( async () => {
|
|
177
|
-
notifyMediaUpload( {
|
|
178
|
-
state: MEDIA_UPLOAD_STATE_FAILED,
|
|
179
|
-
mediaId: mediaItem.localId,
|
|
180
|
-
progress: 0.5,
|
|
181
|
-
} );
|
|
182
|
-
} ),
|
|
183
|
-
notifyResetState: async ( mediaItem ) =>
|
|
184
|
-
act( async () => {
|
|
185
|
-
notifyMediaUpload( {
|
|
186
|
-
state: MEDIA_UPLOAD_STATE_RESET,
|
|
187
|
-
mediaId: mediaItem.localId,
|
|
188
|
-
progress: 0,
|
|
189
|
-
} );
|
|
190
|
-
} ),
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
*
|
|
196
|
-
* Sets up Media Picker mock functions.
|
|
197
|
-
*
|
|
198
|
-
* @typedef {Object} MediaPickerMockFunctions
|
|
199
|
-
* @property {Function} expectMediaPickerCall Checks if the request media picker function has been called with specific arguments.
|
|
200
|
-
* @property {Function} mediaPickerCallback Callback function to notify the media items picked from the media picker.
|
|
201
|
-
*
|
|
202
|
-
* @return {MediaPickerMockFunctions} Media picker mock functions.
|
|
203
|
-
*/
|
|
204
|
-
export const setupMediaPicker = () => {
|
|
205
|
-
let mediaPickerCallback;
|
|
206
|
-
requestMediaPicker.mockImplementation(
|
|
207
|
-
( source, filter, multiple, callback ) => {
|
|
208
|
-
mediaPickerCallback = callback;
|
|
209
|
-
}
|
|
210
|
-
);
|
|
211
|
-
return {
|
|
212
|
-
expectMediaPickerCall: ( source, filter, multiple ) =>
|
|
213
|
-
expect( requestMediaPicker ).toHaveBeenCalledWith(
|
|
214
|
-
source,
|
|
215
|
-
filter,
|
|
216
|
-
multiple,
|
|
217
|
-
mediaPickerCallback
|
|
218
|
-
),
|
|
219
|
-
mediaPickerCallback: async ( ...mediaItems ) =>
|
|
220
|
-
act( async () =>
|
|
221
|
-
mediaPickerCallback(
|
|
222
|
-
mediaItems.map( ( { localId, localUrl } ) => ( {
|
|
223
|
-
type: 'image',
|
|
224
|
-
url: localUrl,
|
|
225
|
-
id: localId,
|
|
226
|
-
} ) )
|
|
227
|
-
)
|
|
228
|
-
),
|
|
229
|
-
};
|
|
230
|
-
};
|
|
72
|
+
export const getGalleryItem = ( galleryBlock, rowIndex ) =>
|
|
73
|
+
getInnerBlock( galleryBlock, 'Image', { rowIndex } );
|
|
231
74
|
|
|
232
75
|
/**
|
|
233
76
|
* Generates the HTML of a Gallery block.
|
|
@@ -261,33 +104,3 @@ export const generateGalleryBlock = (
|
|
|
261
104
|
<figure class="wp-block-gallery has-nested-images columns-default is-cropped">${ galleryItems }</figure>
|
|
262
105
|
<!-- /wp:gallery -->`;
|
|
263
106
|
};
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Sets the text of a caption.
|
|
267
|
-
*
|
|
268
|
-
* @param {import('react-test-renderer').ReactTestInstance} element Caption test instance.
|
|
269
|
-
* @param {string} text Text to be set.
|
|
270
|
-
*/
|
|
271
|
-
export const setCaption = ( element, text ) => {
|
|
272
|
-
fireEvent( element, 'focus' );
|
|
273
|
-
fireEvent( element, 'onChange', {
|
|
274
|
-
nativeEvent: {
|
|
275
|
-
eventCount: 1,
|
|
276
|
-
target: undefined,
|
|
277
|
-
text,
|
|
278
|
-
},
|
|
279
|
-
} );
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Opens the block settings of the current selected block.
|
|
284
|
-
*
|
|
285
|
-
* @param {import('@testing-library/react-native').RenderAPI} screen The Testing Library screen.
|
|
286
|
-
*/
|
|
287
|
-
export const openBlockSettings = async ( screen ) => {
|
|
288
|
-
const { getByA11yLabel, getByTestId } = screen;
|
|
289
|
-
fireEvent.press( getByA11yLabel( 'Open Settings' ) );
|
|
290
|
-
await waitFor(
|
|
291
|
-
() => getByTestId( 'block-settings-modal' ).props.isVisible
|
|
292
|
-
);
|
|
293
|
-
};
|
|
@@ -3,17 +3,22 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
act,
|
|
6
|
+
changeTextOfRichText,
|
|
7
|
+
fireEvent,
|
|
8
|
+
getBlock,
|
|
6
9
|
getEditorHtml,
|
|
7
10
|
initializeEditor,
|
|
8
|
-
|
|
11
|
+
openBlockSettings,
|
|
12
|
+
setupCoreBlocks,
|
|
13
|
+
setupMediaPicker,
|
|
14
|
+
setupMediaUpload,
|
|
15
|
+
triggerBlockListLayout,
|
|
9
16
|
within,
|
|
10
17
|
} from 'test/helpers';
|
|
11
18
|
|
|
12
19
|
/**
|
|
13
20
|
* WordPress dependencies
|
|
14
21
|
*/
|
|
15
|
-
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
16
|
-
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
17
22
|
import { Platform } from '@wordpress/element';
|
|
18
23
|
import {
|
|
19
24
|
getOtherMediaOptions,
|
|
@@ -28,12 +33,7 @@ import {
|
|
|
28
33
|
addGalleryBlock,
|
|
29
34
|
initializeWithGalleryBlock,
|
|
30
35
|
getGalleryItem,
|
|
31
|
-
setupMediaUpload,
|
|
32
36
|
generateGalleryBlock,
|
|
33
|
-
setCaption,
|
|
34
|
-
setupMediaPicker,
|
|
35
|
-
triggerGalleryLayout,
|
|
36
|
-
openBlockSettings,
|
|
37
37
|
} from './helpers';
|
|
38
38
|
|
|
39
39
|
const media = [
|
|
@@ -57,23 +57,13 @@ const media = [
|
|
|
57
57
|
},
|
|
58
58
|
];
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
// Register all core blocks
|
|
62
|
-
registerCoreBlocks();
|
|
63
|
-
} );
|
|
64
|
-
|
|
65
|
-
afterAll( () => {
|
|
66
|
-
// Clean up registered blocks
|
|
67
|
-
getBlockTypes().forEach( ( block ) => {
|
|
68
|
-
unregisterBlockType( block.name );
|
|
69
|
-
} );
|
|
70
|
-
} );
|
|
60
|
+
setupCoreBlocks();
|
|
71
61
|
|
|
72
62
|
describe( 'Gallery block', () => {
|
|
73
63
|
it( 'inserts block', async () => {
|
|
74
|
-
const
|
|
64
|
+
const screen = await addGalleryBlock();
|
|
75
65
|
|
|
76
|
-
expect(
|
|
66
|
+
expect( getBlock( screen, 'Gallery' ) ).toBeVisible();
|
|
77
67
|
expect( getEditorHtml() ).toMatchSnapshot();
|
|
78
68
|
} );
|
|
79
69
|
|
|
@@ -183,7 +173,7 @@ describe( 'Gallery block', () => {
|
|
|
183
173
|
const captionField = within(
|
|
184
174
|
getByA11yLabel( /Gallery caption. Empty/ )
|
|
185
175
|
).getByPlaceholderText( 'Add caption' );
|
|
186
|
-
|
|
176
|
+
changeTextOfRichText(
|
|
187
177
|
captionField,
|
|
188
178
|
'<strong>Bold</strong> <em>italic</em> <s>strikethrough</s> gallery caption'
|
|
189
179
|
);
|
|
@@ -207,7 +197,7 @@ describe( 'Gallery block', () => {
|
|
|
207
197
|
// Set gallery item caption
|
|
208
198
|
const captionField =
|
|
209
199
|
within( galleryItem ).getByPlaceholderText( 'Add caption' );
|
|
210
|
-
|
|
200
|
+
changeTextOfRichText(
|
|
211
201
|
captionField,
|
|
212
202
|
'<strong>Bold</strong> <em>italic</em> <s>strikethrough</s> image caption'
|
|
213
203
|
);
|
|
@@ -234,7 +224,7 @@ describe( 'Gallery block', () => {
|
|
|
234
224
|
await mediaPickerCallback( media[ 0 ], media[ 1 ] );
|
|
235
225
|
|
|
236
226
|
// Check that gallery items are visible
|
|
237
|
-
await
|
|
227
|
+
await triggerBlockListLayout( galleryBlock );
|
|
238
228
|
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
239
229
|
const galleryItem2 = getGalleryItem( galleryBlock, 2 );
|
|
240
230
|
expect( galleryItem1 ).toBeVisible();
|
|
@@ -272,7 +262,7 @@ describe( 'Gallery block', () => {
|
|
|
272
262
|
await mediaPickerCallback( media[ 0 ], media[ 1 ] );
|
|
273
263
|
|
|
274
264
|
// Check that gallery items are visible
|
|
275
|
-
await
|
|
265
|
+
await triggerBlockListLayout( galleryBlock );
|
|
276
266
|
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
277
267
|
const galleryItem2 = getGalleryItem( galleryBlock, 2 );
|
|
278
268
|
expect( galleryItem1 ).toBeVisible();
|
|
@@ -326,7 +316,7 @@ describe( 'Gallery block', () => {
|
|
|
326
316
|
await mediaPickerCallback( media[ 0 ] );
|
|
327
317
|
|
|
328
318
|
// Check gallery item is visible
|
|
329
|
-
await
|
|
319
|
+
await triggerBlockListLayout( galleryBlock );
|
|
330
320
|
const galleryItem = getGalleryItem( galleryBlock, 1 );
|
|
331
321
|
expect( galleryItem ).toBeVisible();
|
|
332
322
|
|
|
@@ -382,7 +372,7 @@ describe( 'Gallery block', () => {
|
|
|
382
372
|
);
|
|
383
373
|
|
|
384
374
|
// Check that gallery items are visible
|
|
385
|
-
await
|
|
375
|
+
await triggerBlockListLayout( galleryBlock );
|
|
386
376
|
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
387
377
|
const galleryItem2 = getGalleryItem( galleryBlock, 2 );
|
|
388
378
|
expect( galleryItem1 ).toBeVisible();
|
|
@@ -420,7 +410,7 @@ describe( 'Gallery block', () => {
|
|
|
420
410
|
await mediaPickerCallback( media[ 0 ], media[ 1 ] );
|
|
421
411
|
|
|
422
412
|
// Check that gallery items are visible
|
|
423
|
-
await
|
|
413
|
+
await triggerBlockListLayout( galleryBlock );
|
|
424
414
|
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
425
415
|
const galleryItem2 = getGalleryItem( galleryBlock, 2 );
|
|
426
416
|
expect( galleryItem1 ).toBeVisible();
|
|
@@ -519,7 +509,7 @@ describe( 'Gallery block', () => {
|
|
|
519
509
|
await mediaPickerCallback( otherAppsMedia[ 0 ], otherAppsMedia[ 1 ] );
|
|
520
510
|
|
|
521
511
|
// Check that gallery items are visible
|
|
522
|
-
await
|
|
512
|
+
await triggerBlockListLayout( galleryBlock );
|
|
523
513
|
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
524
514
|
const galleryItem2 = getGalleryItem( galleryBlock, 2 );
|
|
525
515
|
expect( galleryItem1 ).toBeVisible();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { filter, every
|
|
4
|
+
import { filter, every } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -160,7 +160,7 @@ const transforms = {
|
|
|
160
160
|
return createBlock( 'core/gallery', {
|
|
161
161
|
images: validImages.map(
|
|
162
162
|
( { id, url, alt, caption } ) => ( {
|
|
163
|
-
id: toString(
|
|
163
|
+
id: id.toString(),
|
|
164
164
|
url,
|
|
165
165
|
alt,
|
|
166
166
|
caption,
|
|
@@ -182,7 +182,7 @@ const transforms = {
|
|
|
182
182
|
shortcode: ( { named: { ids } } ) => {
|
|
183
183
|
if ( ! isGalleryV2Enabled() ) {
|
|
184
184
|
return parseShortcodeIds( ids ).map( ( id ) => ( {
|
|
185
|
-
id: toString(
|
|
185
|
+
id: id.toString(),
|
|
186
186
|
} ) );
|
|
187
187
|
}
|
|
188
188
|
},
|