@wordpress/block-library 8.12.6 → 8.14.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 +4 -0
- package/build/archives/index.js +5 -1
- package/build/archives/index.js.map +1 -1
- package/build/audio/index.js +5 -1
- package/build/audio/index.js.map +1 -1
- package/build/block/edit.native.js +2 -2
- package/build/block/edit.native.js.map +1 -1
- package/build/categories/index.js +5 -1
- package/build/categories/index.js.map +1 -1
- package/build/code/index.js +5 -1
- package/build/code/index.js.map +1 -1
- package/build/column/index.js +1 -0
- package/build/column/index.js.map +1 -1
- package/build/comments/index.js +1 -0
- package/build/comments/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/index.js +1 -0
- package/build/cover/index.js.map +1 -1
- package/build/details/index.js +5 -1
- package/build/details/index.js.map +1 -1
- package/build/embed/util.js +9 -8
- package/build/embed/util.js.map +1 -1
- package/build/file/index.js +2 -1
- package/build/file/index.js.map +1 -1
- package/build/file/view.js +15 -1
- package/build/file/view.js.map +1 -1
- package/build/gallery/index.js +3 -1
- package/build/gallery/index.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/index.js +5 -1
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +5 -1
- package/build/heading/transforms.js.map +1 -1
- package/build/image/deprecated.js +453 -175
- package/build/image/deprecated.js.map +1 -1
- package/build/image/image.js +1 -1
- package/build/image/image.js.map +1 -1
- package/build/image/save.js +3 -1
- package/build/image/save.js.map +1 -1
- package/build/image/{interactivity.js → view-interactivity.js} +86 -44
- package/build/image/view-interactivity.js.map +1 -0
- package/build/index.js +12 -3
- package/build/index.js.map +1 -1
- package/build/list/index.js +5 -1
- package/build/list/index.js.map +1 -1
- package/build/list-item/utils.js +6 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/index.js +1 -0
- package/build/media-text/index.js.map +1 -1
- package/build/missing/edit.js +22 -8
- package/build/missing/edit.js.map +1 -1
- package/build/navigation/index.js +3 -2
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/view.js +174 -50
- package/build/navigation/view.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +3 -3
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +34 -39
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list/use-convert-to-navigation-links.js +2 -15
- package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
- package/build/paragraph/index.js +1 -0
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +1 -0
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-comments-form/index.js +1 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-navigation-link/index.js +1 -0
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/post-time-to-read/index.js +5 -1
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/quote/index.js +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/site-logo/index.js +5 -1
- package/build/site-logo/index.js.map +1 -1
- package/build/site-tagline/index.js +5 -1
- package/build/site-tagline/index.js.map +1 -1
- package/build/site-title/index.js +5 -1
- package/build/site-title/index.js.map +1 -1
- package/build/social-links/index.js +3 -1
- package/build/social-links/index.js.map +1 -1
- package/build/table/index.js +5 -1
- package/build/table/index.js.map +1 -1
- package/build/term-description/index.js +1 -0
- package/build/term-description/index.js.map +1 -1
- package/build/verse/index.js +5 -1
- package/build/verse/index.js.map +1 -1
- package/build/video/deprecated.js +5 -1
- package/build/video/deprecated.js.map +1 -1
- package/build/video/index.js +5 -1
- package/build/video/index.js.map +1 -1
- package/build-module/archives/index.js +5 -1
- package/build-module/archives/index.js.map +1 -1
- package/build-module/audio/index.js +5 -1
- package/build-module/audio/index.js.map +1 -1
- package/build-module/block/edit.native.js +2 -2
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/categories/index.js +5 -1
- package/build-module/categories/index.js.map +1 -1
- package/build-module/code/index.js +5 -1
- package/build-module/code/index.js.map +1 -1
- package/build-module/column/index.js +1 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/comments/index.js +1 -0
- package/build-module/comments/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/index.js +1 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/details/index.js +5 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/embed/util.js +6 -6
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/index.js +2 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/file/view.js +15 -2
- package/build-module/file/view.js.map +1 -1
- package/build-module/gallery/index.js +3 -1
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/index.js +5 -1
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +5 -1
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/deprecated.js +454 -176
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/image.js +1 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/save.js +3 -1
- package/build-module/image/save.js.map +1 -1
- package/build-module/image/{interactivity.js → view-interactivity.js} +86 -44
- package/build-module/image/view-interactivity.js.map +1 -0
- package/build-module/index.js +12 -3
- package/build-module/index.js.map +1 -1
- package/build-module/list/index.js +5 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/list-item/utils.js +6 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/index.js +1 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/missing/edit.js +22 -8
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/navigation/index.js +3 -2
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/view.js +173 -50
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +3 -3
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +34 -39
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list/use-convert-to-navigation-links.js +3 -16
- package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
- package/build-module/paragraph/index.js +1 -0
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +1 -0
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-comments-form/index.js +1 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-navigation-link/index.js +1 -0
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/post-time-to-read/index.js +5 -1
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/quote/index.js +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/site-logo/index.js +5 -1
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/site-tagline/index.js +5 -1
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/site-title/index.js +5 -1
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-links/index.js +3 -1
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/table/index.js +5 -1
- package/build-module/table/index.js.map +1 -1
- package/build-module/term-description/index.js +1 -0
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/verse/index.js +5 -1
- package/build-module/verse/index.js.map +1 -1
- package/build-module/video/deprecated.js +5 -1
- package/build-module/video/deprecated.js.map +1 -1
- package/build-module/video/index.js +5 -1
- package/build-module/video/index.js.map +1 -1
- package/build-style/image/style-rtl.css +16 -2
- package/build-style/image/style.css +16 -2
- package/build-style/style-rtl.css +16 -2
- package/build-style/style.css +16 -2
- package/package.json +33 -38
- package/src/archives/block.json +5 -1
- package/src/audio/block.json +5 -1
- package/src/block/edit.native.js +2 -2
- package/src/block/test/edit.native.js +4 -4
- package/src/categories/block.json +5 -1
- package/src/code/block.json +5 -1
- package/src/column/block.json +1 -0
- package/src/comments/block.json +1 -0
- package/src/cover/block.json +1 -0
- package/src/cover/edit/inspector-controls.js +1 -0
- package/src/details/block.json +5 -1
- package/src/embed/util.js +4 -6
- package/src/file/block.json +2 -1
- package/src/file/index.php +0 -17
- package/src/file/view.js +14 -5
- package/src/gallery/block.json +3 -1
- package/src/group/block.json +1 -0
- package/src/heading/block.json +5 -1
- package/src/heading/test/index.native.js +18 -0
- package/src/image/deprecated.js +597 -320
- package/src/image/image.js +2 -1
- package/src/image/save.js +2 -0
- package/src/image/style.scss +15 -2
- package/src/image/{interactivity.js → view-interactivity.js} +99 -50
- package/src/index.js +18 -1
- package/src/list/block.json +5 -1
- package/src/media-text/block.json +1 -0
- package/src/missing/edit.js +31 -11
- package/src/navigation/block.json +3 -2
- package/src/navigation/index.php +15 -20
- package/src/navigation/view.js +189 -67
- package/src/navigation-submenu/index.php +0 -10
- package/src/page-list/convert-to-links-modal.js +3 -3
- package/src/page-list/edit.js +65 -62
- package/src/page-list/use-convert-to-navigation-links.js +3 -20
- package/src/paragraph/block.json +1 -0
- package/src/post-comments-form/block.json +1 -0
- package/src/post-navigation-link/block.json +1 -0
- package/src/post-time-to-read/block.json +5 -1
- package/src/quote/block.json +1 -0
- package/src/site-logo/block.json +5 -1
- package/src/site-tagline/block.json +5 -1
- package/src/site-title/block.json +5 -1
- package/src/social-links/block.json +3 -1
- package/src/table/block.json +5 -1
- package/src/term-description/block.json +1 -0
- package/src/verse/block.json +5 -1
- package/src/video/block.json +5 -1
- package/build/file/interactivity.js +0 -19
- package/build/file/interactivity.js.map +0 -1
- package/build/heading/heading-level-icon.js +0 -61
- package/build/heading/heading-level-icon.js.map +0 -1
- package/build/image/interactivity.js.map +0 -1
- package/build/navigation/interactivity.js +0 -167
- package/build/navigation/interactivity.js.map +0 -1
- package/build/navigation/view-modal.js +0 -64
- package/build/navigation/view-modal.js.map +0 -1
- package/build/utils/interactivity/constants.js +0 -9
- package/build/utils/interactivity/constants.js.map +0 -1
- package/build/utils/interactivity/directives.js +0 -222
- package/build/utils/interactivity/directives.js.map +0 -1
- package/build/utils/interactivity/hooks.js +0 -159
- package/build/utils/interactivity/hooks.js.map +0 -1
- package/build/utils/interactivity/hydration.js +0 -34
- package/build/utils/interactivity/hydration.js.map +0 -1
- package/build/utils/interactivity/index.js +0 -32
- package/build/utils/interactivity/index.js.map +0 -1
- package/build/utils/interactivity/portals.js +0 -108
- package/build/utils/interactivity/portals.js.map +0 -1
- package/build/utils/interactivity/store.js +0 -66
- package/build/utils/interactivity/store.js.map +0 -1
- package/build/utils/interactivity/utils.js +0 -87
- package/build/utils/interactivity/utils.js.map +0 -1
- package/build/utils/interactivity/vdom.js +0 -119
- package/build/utils/interactivity/vdom.js.map +0 -1
- package/build-module/file/interactivity.js +0 -15
- package/build-module/file/interactivity.js.map +0 -1
- package/build-module/heading/heading-level-icon.js +0 -53
- package/build-module/heading/heading-level-icon.js.map +0 -1
- package/build-module/image/interactivity.js.map +0 -1
- package/build-module/navigation/interactivity.js +0 -164
- package/build-module/navigation/interactivity.js.map +0 -1
- package/build-module/navigation/view-modal.js +0 -58
- package/build-module/navigation/view-modal.js.map +0 -1
- package/build-module/utils/interactivity/constants.js +0 -2
- package/build-module/utils/interactivity/constants.js.map +0 -1
- package/build-module/utils/interactivity/directives.js +0 -209
- package/build-module/utils/interactivity/directives.js.map +0 -1
- package/build-module/utils/interactivity/hooks.js +0 -145
- package/build-module/utils/interactivity/hooks.js.map +0 -1
- package/build-module/utils/interactivity/hydration.js +0 -21
- package/build-module/utils/interactivity/hydration.js.map +0 -1
- package/build-module/utils/interactivity/index.js +0 -15
- package/build-module/utils/interactivity/index.js.map +0 -1
- package/build-module/utils/interactivity/portals.js +0 -100
- package/build-module/utils/interactivity/portals.js.map +0 -1
- package/build-module/utils/interactivity/store.js +0 -55
- package/build-module/utils/interactivity/store.js.map +0 -1
- package/build-module/utils/interactivity/utils.js +0 -75
- package/build-module/utils/interactivity/utils.js.map +0 -1
- package/build-module/utils/interactivity/vdom.js +0 -107
- package/build-module/utils/interactivity/vdom.js.map +0 -1
- package/src/file/interactivity.js +0 -15
- package/src/heading/heading-level-icon.js +0 -48
- package/src/navigation/interactivity.js +0 -169
- package/src/navigation/view-modal.js +0 -78
- package/src/utils/interactivity/constants.js +0 -1
- package/src/utils/interactivity/directives.js +0 -200
- package/src/utils/interactivity/hooks.js +0 -145
- package/src/utils/interactivity/hydration.js +0 -22
- package/src/utils/interactivity/index.js +0 -15
- package/src/utils/interactivity/portals.js +0 -98
- package/src/utils/interactivity/store.js +0 -45
- package/src/utils/interactivity/utils.js +0 -66
- package/src/utils/interactivity/vdom.js +0 -111
package/src/image/image.js
CHANGED
|
@@ -607,7 +607,8 @@ export default function Image( {
|
|
|
607
607
|
const ratio =
|
|
608
608
|
( aspectRatio && evalAspectRatio( aspectRatio ) ) ||
|
|
609
609
|
( width && height && width / height ) ||
|
|
610
|
-
naturalWidth / naturalHeight
|
|
610
|
+
naturalWidth / naturalHeight ||
|
|
611
|
+
1;
|
|
611
612
|
|
|
612
613
|
const currentWidth = ! width && height ? height * ratio : width;
|
|
613
614
|
const currentHeight = ! height && width ? width / ratio : height;
|
package/src/image/save.js
CHANGED
package/src/image/style.scss
CHANGED
|
@@ -184,11 +184,12 @@
|
|
|
184
184
|
width: 100vw;
|
|
185
185
|
height: 100vh;
|
|
186
186
|
visibility: hidden;
|
|
187
|
+
cursor: zoom-out;
|
|
187
188
|
|
|
188
189
|
.close-button {
|
|
189
190
|
position: absolute;
|
|
190
|
-
top: 12.5px;
|
|
191
|
-
right: 12.5px;
|
|
191
|
+
top: calc(env(safe-area-inset-top) + 12.5px);
|
|
192
|
+
right: calc(env(safe-area-inset-right) + 12.5px);
|
|
192
193
|
padding: 0;
|
|
193
194
|
cursor: pointer;
|
|
194
195
|
z-index: 5000000;
|
|
@@ -231,6 +232,18 @@
|
|
|
231
232
|
}
|
|
232
233
|
|
|
233
234
|
&.fade {
|
|
235
|
+
.wp-block-image {
|
|
236
|
+
padding: 40px 0;
|
|
237
|
+
|
|
238
|
+
@media screen and (min-width: 480px) {
|
|
239
|
+
padding: 40px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@media screen and (min-width: 1920px) {
|
|
243
|
+
padding: 40px 80px;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
234
247
|
&.active {
|
|
235
248
|
visibility: visible;
|
|
236
249
|
animation: both turn-on-visibility 0.25s;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { store } from '
|
|
4
|
+
import { store } from '@wordpress/interactivity';
|
|
5
5
|
|
|
6
6
|
const focusableSelectors = [
|
|
7
7
|
'a[href]',
|
|
@@ -22,32 +22,43 @@ store( {
|
|
|
22
22
|
core: {
|
|
23
23
|
image: {
|
|
24
24
|
showLightbox: ( { context, event } ) => {
|
|
25
|
+
// We can't initialize the lightbox until the reference
|
|
26
|
+
// image is loaded, otherwise the UX is broken.
|
|
27
|
+
if ( ! context.core.image.imageLoaded ) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
25
30
|
context.core.image.initialized = true;
|
|
26
31
|
context.core.image.lastFocusedElement =
|
|
27
32
|
window.document.activeElement;
|
|
28
33
|
context.core.image.scrollDelta = 0;
|
|
29
34
|
|
|
35
|
+
context.core.image.lightboxEnabled = true;
|
|
36
|
+
if ( context.core.image.lightboxAnimation === 'zoom' ) {
|
|
37
|
+
setZoomStyles(
|
|
38
|
+
event.target.nextElementSibling,
|
|
39
|
+
context,
|
|
40
|
+
event
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
// Hide overflow only when the animation is in progress,
|
|
44
|
+
// otherwise the removal of the scrollbars will draw attention
|
|
45
|
+
// to itself and look like an error
|
|
46
|
+
document.documentElement.classList.add(
|
|
47
|
+
'has-lightbox-open'
|
|
48
|
+
);
|
|
49
|
+
|
|
30
50
|
// Since the img is hidden and its src not loaded until
|
|
31
51
|
// the lightbox is opened, let's create an img element on the fly
|
|
32
52
|
// so we can get the dimensions we need to calculate the styles
|
|
53
|
+
context.core.image.preloadInitialized = true;
|
|
33
54
|
const imgDom = document.createElement( 'img' );
|
|
34
|
-
|
|
35
55
|
imgDom.onload = function () {
|
|
36
|
-
|
|
37
|
-
// is loaded to prevent flashing of unstyled content
|
|
38
|
-
context.core.image.lightboxEnabled = true;
|
|
39
|
-
if ( context.core.image.lightboxAnimation === 'zoom' ) {
|
|
40
|
-
setZoomStyles( imgDom, context, event );
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Hide overflow only when the animation is in progress,
|
|
44
|
-
// otherwise the removal of the scrollbars will draw attention
|
|
45
|
-
// to itself and look like an error
|
|
46
|
-
document.documentElement.classList.add(
|
|
47
|
-
'has-lightbox-open'
|
|
48
|
-
);
|
|
56
|
+
context.core.image.activateLargeImage = true;
|
|
49
57
|
};
|
|
50
|
-
imgDom.setAttribute(
|
|
58
|
+
imgDom.setAttribute(
|
|
59
|
+
'src',
|
|
60
|
+
context.core.image.imageUploadedSrc
|
|
61
|
+
);
|
|
51
62
|
},
|
|
52
63
|
hideLightbox: async ( { context, event } ) => {
|
|
53
64
|
context.core.image.hideAnimationEnabled = true;
|
|
@@ -122,6 +133,16 @@ store( {
|
|
|
122
133
|
}
|
|
123
134
|
}
|
|
124
135
|
},
|
|
136
|
+
preloadLightboxImage: ( { context } ) => {
|
|
137
|
+
if ( ! context.core.image.preloadInitialized ) {
|
|
138
|
+
context.core.image.preloadInitialized = true;
|
|
139
|
+
const imgDom = document.createElement( 'img' );
|
|
140
|
+
imgDom.setAttribute(
|
|
141
|
+
'src',
|
|
142
|
+
context.core.image.imageUploadedSrc
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
125
146
|
},
|
|
126
147
|
},
|
|
127
148
|
},
|
|
@@ -131,9 +152,15 @@ store( {
|
|
|
131
152
|
roleAttribute: ( { context } ) => {
|
|
132
153
|
return context.core.image.lightboxEnabled ? 'dialog' : '';
|
|
133
154
|
},
|
|
134
|
-
|
|
155
|
+
responsiveImgSrc: ( { context } ) => {
|
|
156
|
+
return context.core.image.activateLargeImage &&
|
|
157
|
+
context.core.image.hideAnimationEnabled
|
|
158
|
+
? ''
|
|
159
|
+
: context.core.image.imageCurrentSrc;
|
|
160
|
+
},
|
|
161
|
+
enlargedImgSrc: ( { context } ) => {
|
|
135
162
|
return context.core.image.initialized
|
|
136
|
-
? context.core.image.
|
|
163
|
+
? context.core.image.imageUploadedSrc
|
|
137
164
|
: '';
|
|
138
165
|
},
|
|
139
166
|
},
|
|
@@ -142,6 +169,18 @@ store( {
|
|
|
142
169
|
effects: {
|
|
143
170
|
core: {
|
|
144
171
|
image: {
|
|
172
|
+
setCurrentSrc: ( { context, ref } ) => {
|
|
173
|
+
if ( ref.complete ) {
|
|
174
|
+
context.core.image.imageLoaded = true;
|
|
175
|
+
context.core.image.imageCurrentSrc = ref.currentSrc;
|
|
176
|
+
} else {
|
|
177
|
+
ref.addEventListener( 'load', function () {
|
|
178
|
+
context.core.image.imageLoaded = true;
|
|
179
|
+
context.core.image.imageCurrentSrc =
|
|
180
|
+
this.currentSrc;
|
|
181
|
+
} );
|
|
182
|
+
}
|
|
183
|
+
},
|
|
145
184
|
initLightbox: async ( { context, ref } ) => {
|
|
146
185
|
context.core.image.figureRef =
|
|
147
186
|
ref.querySelector( 'figure' );
|
|
@@ -163,51 +202,61 @@ store( {
|
|
|
163
202
|
} );
|
|
164
203
|
|
|
165
204
|
function setZoomStyles( imgDom, context, event ) {
|
|
166
|
-
|
|
167
|
-
|
|
205
|
+
// Typically, we use the image's full-sized dimensions. If those
|
|
206
|
+
// dimensions have not been set (i.e. an external image with only one size),
|
|
207
|
+
// the image's dimensions in the lightbox are the same
|
|
208
|
+
// as those of the image in the content.
|
|
209
|
+
let targetWidth =
|
|
210
|
+
context.core.image.targetWidth !== 'none'
|
|
211
|
+
? context.core.image.targetWidth
|
|
212
|
+
: event.target.nextElementSibling.naturalWidth;
|
|
213
|
+
let targetHeight =
|
|
214
|
+
context.core.image.targetHeight !== 'none'
|
|
215
|
+
? context.core.image.targetHeight
|
|
216
|
+
: event.target.nextElementSibling.naturalHeight;
|
|
168
217
|
|
|
169
|
-
|
|
218
|
+
// Since the lightbox image has `position:absolute`, it
|
|
219
|
+
// ignores its parent's padding, so we need to set padding here
|
|
220
|
+
// to calculate dimensions and positioning.
|
|
170
221
|
|
|
171
|
-
// As per the design, let's
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const
|
|
222
|
+
// As per the design, let's constrain the height with fixed padding
|
|
223
|
+
const containerOuterHeight = window.innerHeight;
|
|
224
|
+
const verticalPadding = 40;
|
|
225
|
+
const containerInnerHeight = containerOuterHeight - verticalPadding * 2;
|
|
175
226
|
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
// to be used when calculating the image width and positioning
|
|
227
|
+
// Let's set a variable horizontal padding based on the container width
|
|
228
|
+
const containerOuterWidth = window.innerWidth;
|
|
179
229
|
let horizontalPadding = 0;
|
|
180
|
-
if (
|
|
230
|
+
if ( containerOuterWidth > 480 ) {
|
|
181
231
|
horizontalPadding = 40;
|
|
182
|
-
} else if (
|
|
232
|
+
} else if ( containerOuterWidth > 1920 ) {
|
|
183
233
|
horizontalPadding = 80;
|
|
184
234
|
}
|
|
185
|
-
|
|
186
|
-
const containerHeight =
|
|
187
|
-
context.core.image.figureRef.clientHeight - verticalPadding * 2;
|
|
235
|
+
const containerInnerWidth = containerOuterWidth - horizontalPadding * 2;
|
|
188
236
|
|
|
189
237
|
// Check difference between the image and figure dimensions
|
|
190
238
|
const widthOverflow = Math.abs(
|
|
191
|
-
Math.min(
|
|
239
|
+
Math.min( containerInnerWidth - targetWidth, 0 )
|
|
192
240
|
);
|
|
193
241
|
const heightOverflow = Math.abs(
|
|
194
|
-
Math.min(
|
|
242
|
+
Math.min( containerInnerHeight - targetHeight, 0 )
|
|
195
243
|
);
|
|
196
244
|
|
|
197
|
-
// If image is larger than
|
|
198
|
-
//
|
|
245
|
+
// If the image is larger than the container, let's resize
|
|
246
|
+
// it along the greater axis relative to the container
|
|
199
247
|
if ( widthOverflow > 0 || heightOverflow > 0 ) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
248
|
+
const containerInnerAspectRatio =
|
|
249
|
+
containerInnerWidth / containerInnerHeight;
|
|
250
|
+
const imageAspectRatio = targetWidth / targetHeight;
|
|
251
|
+
|
|
252
|
+
if ( imageAspectRatio > containerInnerAspectRatio ) {
|
|
253
|
+
targetWidth = containerInnerWidth;
|
|
205
254
|
targetHeight =
|
|
206
|
-
imgDom.naturalHeight
|
|
255
|
+
( targetWidth * imgDom.naturalHeight ) / imgDom.naturalWidth;
|
|
207
256
|
} else {
|
|
208
|
-
targetHeight =
|
|
257
|
+
targetHeight = containerInnerHeight;
|
|
209
258
|
targetWidth =
|
|
210
|
-
imgDom.naturalWidth
|
|
259
|
+
( targetHeight * imgDom.naturalWidth ) / imgDom.naturalHeight;
|
|
211
260
|
}
|
|
212
261
|
}
|
|
213
262
|
|
|
@@ -221,16 +270,16 @@ function setZoomStyles( imgDom, context, event ) {
|
|
|
221
270
|
|
|
222
271
|
// Get values used to center the image
|
|
223
272
|
let targetLeft = 0;
|
|
224
|
-
if ( targetWidth >=
|
|
273
|
+
if ( targetWidth >= containerInnerWidth ) {
|
|
225
274
|
targetLeft = horizontalPadding;
|
|
226
275
|
} else {
|
|
227
|
-
targetLeft = (
|
|
276
|
+
targetLeft = ( containerOuterWidth - targetWidth ) / 2;
|
|
228
277
|
}
|
|
229
278
|
let targetTop = 0;
|
|
230
|
-
if ( targetHeight >=
|
|
279
|
+
if ( targetHeight >= containerInnerHeight ) {
|
|
231
280
|
targetTop = verticalPadding;
|
|
232
281
|
} else {
|
|
233
|
-
targetTop = (
|
|
282
|
+
targetTop = ( containerOuterHeight - targetHeight ) / 2;
|
|
234
283
|
}
|
|
235
284
|
|
|
236
285
|
const root = document.documentElement;
|
package/src/index.js
CHANGED
|
@@ -142,7 +142,6 @@ const getAllBlocks = () => {
|
|
|
142
142
|
buttons,
|
|
143
143
|
calendar,
|
|
144
144
|
categories,
|
|
145
|
-
...( window.wp && window.wp.oldEditor ? [ classic ] : [] ), // Only add the classic block in WP Context.
|
|
146
145
|
code,
|
|
147
146
|
column,
|
|
148
147
|
columns,
|
|
@@ -229,6 +228,24 @@ const getAllBlocks = () => {
|
|
|
229
228
|
queryTitle,
|
|
230
229
|
postAuthorBiography,
|
|
231
230
|
];
|
|
231
|
+
|
|
232
|
+
// When in a WordPress context, conditionally
|
|
233
|
+
// add the classic block and TinyMCE editor
|
|
234
|
+
// under any of the following conditions:
|
|
235
|
+
// - the current post contains a classic block
|
|
236
|
+
// - the experiment to disable TinyMCE isn't active.
|
|
237
|
+
// - a query argument specifies that TinyMCE should be loaded
|
|
238
|
+
if (
|
|
239
|
+
window?.wp?.oldEditor &&
|
|
240
|
+
( window?.wp?.needsClassicBlock ||
|
|
241
|
+
! window?.__experimentalDisableTinymce ||
|
|
242
|
+
!! new URLSearchParams( window?.location?.search ).get(
|
|
243
|
+
'requiresTinymce'
|
|
244
|
+
) )
|
|
245
|
+
) {
|
|
246
|
+
blocks.push( classic );
|
|
247
|
+
}
|
|
248
|
+
|
|
232
249
|
return blocks.filter( Boolean );
|
|
233
250
|
};
|
|
234
251
|
|
package/src/list/block.json
CHANGED
package/src/missing/edit.js
CHANGED
|
@@ -16,22 +16,46 @@ import { safeHTML } from '@wordpress/dom';
|
|
|
16
16
|
function MissingBlockWarning( { attributes, convertToHTML, clientId } ) {
|
|
17
17
|
const { originalName, originalUndelimitedContent } = attributes;
|
|
18
18
|
const hasContent = !! originalUndelimitedContent;
|
|
19
|
-
const hasHTMLBlock = useSelect(
|
|
19
|
+
const { hasFreeformBlock, hasHTMLBlock } = useSelect(
|
|
20
20
|
( select ) => {
|
|
21
21
|
const { canInsertBlockType, getBlockRootClientId } =
|
|
22
22
|
select( blockEditorStore );
|
|
23
23
|
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
return {
|
|
25
|
+
hasFreeformBlock: canInsertBlockType(
|
|
26
|
+
'core/freeform',
|
|
27
|
+
getBlockRootClientId( clientId )
|
|
28
|
+
),
|
|
29
|
+
hasHTMLBlock: canInsertBlockType(
|
|
30
|
+
'core/html',
|
|
31
|
+
getBlockRootClientId( clientId )
|
|
32
|
+
),
|
|
33
|
+
};
|
|
28
34
|
},
|
|
29
35
|
[ clientId ]
|
|
30
36
|
);
|
|
31
37
|
|
|
32
38
|
const actions = [];
|
|
33
39
|
let messageHTML;
|
|
34
|
-
|
|
40
|
+
|
|
41
|
+
const convertToHtmlButton = (
|
|
42
|
+
<Button key="convert" onClick={ convertToHTML } variant="primary">
|
|
43
|
+
{ __( 'Keep as HTML' ) }
|
|
44
|
+
</Button>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if ( hasContent && ! hasFreeformBlock && ! originalName ) {
|
|
48
|
+
if ( hasHTMLBlock ) {
|
|
49
|
+
messageHTML = __(
|
|
50
|
+
'It appears you are trying to use the deprecated Classic block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely. Alternatively, you can refresh the page to use the Classic block.'
|
|
51
|
+
);
|
|
52
|
+
actions.push( convertToHtmlButton );
|
|
53
|
+
} else {
|
|
54
|
+
messageHTML = __(
|
|
55
|
+
'It appears you are trying to use the deprecated Classic block. You can leave this block intact, or remove it entirely. Alternatively, you can refresh the page to use the Classic block.'
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
} else if ( hasContent && hasHTMLBlock ) {
|
|
35
59
|
messageHTML = sprintf(
|
|
36
60
|
/* translators: %s: block name */
|
|
37
61
|
__(
|
|
@@ -39,11 +63,7 @@ function MissingBlockWarning( { attributes, convertToHTML, clientId } ) {
|
|
|
39
63
|
),
|
|
40
64
|
originalName
|
|
41
65
|
);
|
|
42
|
-
actions.push(
|
|
43
|
-
<Button key="convert" onClick={ convertToHTML } variant="primary">
|
|
44
|
-
{ __( 'Keep as HTML' ) }
|
|
45
|
-
</Button>
|
|
46
|
-
);
|
|
66
|
+
actions.push( convertToHtmlButton );
|
|
47
67
|
} else {
|
|
48
68
|
messageHTML = sprintf(
|
|
49
69
|
/* translators: %s: block name */
|
|
@@ -131,9 +131,10 @@
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
}
|
|
134
|
+
},
|
|
135
|
+
"interactivity": true
|
|
135
136
|
},
|
|
136
|
-
"viewScript":
|
|
137
|
+
"viewScript": "file:./view.min.js",
|
|
137
138
|
"editorStyle": "wp-block-navigation-editor",
|
|
138
139
|
"style": "wp-block-navigation"
|
|
139
140
|
}
|
package/src/navigation/index.php
CHANGED
|
@@ -103,7 +103,7 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
|
103
103
|
) ) {
|
|
104
104
|
// Add directives to the parent `<li>`.
|
|
105
105
|
$w->set_attribute( 'data-wp-interactive', true );
|
|
106
|
-
$w->set_attribute( 'data-wp-context', '{ "core": { "navigation": { "
|
|
106
|
+
$w->set_attribute( 'data-wp-context', '{ "core": { "navigation": { "submenuOpenedBy": {}, "type": "submenu" } } }' );
|
|
107
107
|
$w->set_attribute( 'data-wp-effect', 'effects.core.navigation.initMenu' );
|
|
108
108
|
$w->set_attribute( 'data-wp-on--focusout', 'actions.core.navigation.handleMenuFocusout' );
|
|
109
109
|
$w->set_attribute( 'data-wp-on--keydown', 'actions.core.navigation.handleMenuKeydown' );
|
|
@@ -123,26 +123,21 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
|
123
123
|
$w->set_attribute( 'data-wp-bind--aria-expanded', 'selectors.core.navigation.isMenuOpen' );
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
+
// Add directives to the submenu.
|
|
127
|
+
if ( $w->next_tag(
|
|
128
|
+
array(
|
|
129
|
+
'tag_name' => 'UL',
|
|
130
|
+
'class_name' => 'wp-block-navigation__submenu-container',
|
|
131
|
+
)
|
|
132
|
+
) ) {
|
|
133
|
+
$w->set_attribute( 'data-wp-on--focusin', 'actions.core.navigation.openMenuOnFocus' );
|
|
134
|
+
}
|
|
135
|
+
|
|
126
136
|
// Iterate through subitems if exist.
|
|
127
137
|
block_core_navigation_add_directives_to_submenu( $w, $block_attributes );
|
|
128
138
|
}
|
|
129
139
|
return $w->get_updated_html();
|
|
130
140
|
};
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Replaces view script for the Navigation block with version using Interactivity API.
|
|
134
|
-
*
|
|
135
|
-
* @param array $metadata Block metadata as read in via block.json.
|
|
136
|
-
*
|
|
137
|
-
* @return array Filtered block type metadata.
|
|
138
|
-
*/
|
|
139
|
-
function gutenberg_block_core_navigation_update_interactive_view_script( $metadata ) {
|
|
140
|
-
if ( 'core/navigation' === $metadata['name'] ) {
|
|
141
|
-
$metadata['viewScript'] = array( 'file:./interactivity.min.js' );
|
|
142
|
-
}
|
|
143
|
-
return $metadata;
|
|
144
|
-
}
|
|
145
|
-
add_filter( 'block_type_metadata', 'gutenberg_block_core_navigation_update_interactive_view_script', 10, 1 );
|
|
146
141
|
}
|
|
147
142
|
|
|
148
143
|
|
|
@@ -726,7 +721,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
726
721
|
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && $should_load_view_script ) {
|
|
727
722
|
$nav_element_directives = '
|
|
728
723
|
data-wp-interactive
|
|
729
|
-
data-wp-context=\'{ "core": { "navigation": { "
|
|
724
|
+
data-wp-context=\'{ "core": { "navigation": { "overlayOpenedBy": {}, "type": "overlay", "roleAttribute": "" } } }\'
|
|
730
725
|
';
|
|
731
726
|
$open_button_directives = '
|
|
732
727
|
data-wp-on--click="actions.core.navigation.openMenuOnClick"
|
|
@@ -751,11 +746,11 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
751
746
|
}
|
|
752
747
|
|
|
753
748
|
$responsive_container_markup = sprintf(
|
|
754
|
-
'<button aria-haspopup="true" %3$s class="%6$s"
|
|
749
|
+
'<button aria-haspopup="true" %3$s class="%6$s" %11$s>%9$s</button>
|
|
755
750
|
<div class="%5$s" style="%7$s" id="%1$s" %12$s>
|
|
756
|
-
<div class="wp-block-navigation__responsive-close" tabindex="-1"
|
|
751
|
+
<div class="wp-block-navigation__responsive-close" tabindex="-1">
|
|
757
752
|
<div class="wp-block-navigation__responsive-dialog" aria-label="%8$s" %13$s>
|
|
758
|
-
<button %4$s
|
|
753
|
+
<button %4$s class="wp-block-navigation__responsive-container-close" %14$s>%10$s</button>
|
|
759
754
|
<div class="wp-block-navigation__responsive-container-content" id="%1$s-content">
|
|
760
755
|
%2$s
|
|
761
756
|
</div>
|