@wordpress/block-library 8.22.0 → 8.23.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.
Files changed (175) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/block/edit.js +3 -2
  3. package/build/block/edit.js.map +1 -1
  4. package/build/button/edit.js +57 -2
  5. package/build/button/edit.js.map +1 -1
  6. package/build/code/transforms.js +20 -7
  7. package/build/code/transforms.js.map +1 -1
  8. package/build/comments/edit/comments-inspector-controls.js +1 -0
  9. package/build/comments/edit/comments-inspector-controls.js.map +1 -1
  10. package/build/cover/edit/inspector-controls.js +1 -0
  11. package/build/cover/edit/inspector-controls.js.map +1 -1
  12. package/build/details/edit.js +1 -2
  13. package/build/details/edit.js.map +1 -1
  14. package/build/form/index.js +1 -1
  15. package/build/form/index.js.map +1 -1
  16. package/build/form-submit-button/edit.js +2 -1
  17. package/build/form-submit-button/edit.js.map +1 -1
  18. package/build/gallery/gap-styles.js +12 -7
  19. package/build/gallery/gap-styles.js.map +1 -1
  20. package/build/group/edit.js +1 -0
  21. package/build/group/edit.js.map +1 -1
  22. package/build/html/transforms.js +7 -2
  23. package/build/html/transforms.js.map +1 -1
  24. package/build/image/deprecated.js +8 -0
  25. package/build/image/deprecated.js.map +1 -1
  26. package/build/image/view.js +10 -7
  27. package/build/image/view.js.map +1 -1
  28. package/build/missing/index.js +1 -1
  29. package/build/navigation/edit/overlay-menu-preview.js +1 -1
  30. package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
  31. package/build/navigation/use-template-part-area-label.js +2 -1
  32. package/build/navigation/use-template-part-area-label.js.map +1 -1
  33. package/build/navigation-link/edit.js +1 -1
  34. package/build/navigation-link/edit.js.map +1 -1
  35. package/build/pattern/edit.js +1 -1
  36. package/build/pattern/edit.js.map +1 -1
  37. package/build/post-author/edit.js +0 -1
  38. package/build/post-author/edit.js.map +1 -1
  39. package/build/post-featured-image/edit.js +21 -6
  40. package/build/post-featured-image/edit.js.map +1 -1
  41. package/build/post-template/edit.js +2 -8
  42. package/build/post-template/edit.js.map +1 -1
  43. package/build/post-template/index.js +1 -1
  44. package/build/post-terms/edit.js +0 -2
  45. package/build/post-terms/edit.js.map +1 -1
  46. package/build/preformatted/transforms.js +1 -4
  47. package/build/preformatted/transforms.js.map +1 -1
  48. package/build/query/edit/query-content.js +1 -0
  49. package/build/query/edit/query-content.js.map +1 -1
  50. package/build/quote/index.js +6 -0
  51. package/build/quote/index.js.map +1 -1
  52. package/build/template-part/edit/advanced-controls.js +1 -0
  53. package/build/template-part/edit/advanced-controls.js.map +1 -1
  54. package/build/template-part/edit/index.js +3 -7
  55. package/build/template-part/edit/index.js.map +1 -1
  56. package/build/template-part/index.js +6 -2
  57. package/build/template-part/index.js.map +1 -1
  58. package/build/template-part/variations.js +5 -1
  59. package/build/template-part/variations.js.map +1 -1
  60. package/build-module/block/edit.js +3 -2
  61. package/build-module/block/edit.js.map +1 -1
  62. package/build-module/button/edit.js +61 -6
  63. package/build-module/button/edit.js.map +1 -1
  64. package/build-module/code/transforms.js +20 -7
  65. package/build-module/code/transforms.js.map +1 -1
  66. package/build-module/comments/edit/comments-inspector-controls.js +1 -0
  67. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
  68. package/build-module/cover/edit/inspector-controls.js +1 -0
  69. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  70. package/build-module/details/edit.js +1 -2
  71. package/build-module/details/edit.js.map +1 -1
  72. package/build-module/form/index.js +1 -1
  73. package/build-module/form/index.js.map +1 -1
  74. package/build-module/form-submit-button/edit.js +2 -1
  75. package/build-module/form-submit-button/edit.js.map +1 -1
  76. package/build-module/gallery/gap-styles.js +13 -8
  77. package/build-module/gallery/gap-styles.js.map +1 -1
  78. package/build-module/group/edit.js +1 -0
  79. package/build-module/group/edit.js.map +1 -1
  80. package/build-module/html/transforms.js +7 -2
  81. package/build-module/html/transforms.js.map +1 -1
  82. package/build-module/image/deprecated.js +8 -0
  83. package/build-module/image/deprecated.js.map +1 -1
  84. package/build-module/image/view.js +10 -7
  85. package/build-module/image/view.js.map +1 -1
  86. package/build-module/missing/index.js +1 -1
  87. package/build-module/navigation/edit/overlay-menu-preview.js +1 -1
  88. package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
  89. package/build-module/navigation/use-template-part-area-label.js +2 -1
  90. package/build-module/navigation/use-template-part-area-label.js.map +1 -1
  91. package/build-module/navigation-link/edit.js +2 -2
  92. package/build-module/navigation-link/edit.js.map +1 -1
  93. package/build-module/pattern/edit.js +1 -1
  94. package/build-module/pattern/edit.js.map +1 -1
  95. package/build-module/post-author/edit.js +0 -1
  96. package/build-module/post-author/edit.js.map +1 -1
  97. package/build-module/post-featured-image/edit.js +21 -6
  98. package/build-module/post-featured-image/edit.js.map +1 -1
  99. package/build-module/post-template/edit.js +2 -8
  100. package/build-module/post-template/edit.js.map +1 -1
  101. package/build-module/post-template/index.js +1 -1
  102. package/build-module/post-terms/edit.js +0 -2
  103. package/build-module/post-terms/edit.js.map +1 -1
  104. package/build-module/preformatted/transforms.js +1 -4
  105. package/build-module/preformatted/transforms.js.map +1 -1
  106. package/build-module/query/edit/query-content.js +1 -0
  107. package/build-module/query/edit/query-content.js.map +1 -1
  108. package/build-module/quote/index.js +6 -0
  109. package/build-module/quote/index.js.map +1 -1
  110. package/build-module/template-part/edit/advanced-controls.js +1 -0
  111. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  112. package/build-module/template-part/edit/index.js +5 -9
  113. package/build-module/template-part/edit/index.js.map +1 -1
  114. package/build-module/template-part/index.js +6 -2
  115. package/build-module/template-part/index.js.map +1 -1
  116. package/build-module/template-part/variations.js +5 -1
  117. package/build-module/template-part/variations.js.map +1 -1
  118. package/build-style/editor-rtl.css +12 -0
  119. package/build-style/editor.css +12 -0
  120. package/build-style/image/editor-rtl.css +3 -0
  121. package/build-style/image/editor.css +3 -0
  122. package/build-style/image/style-rtl.css +19 -13
  123. package/build-style/image/style.css +19 -13
  124. package/build-style/post-featured-image/editor-rtl.css +9 -0
  125. package/build-style/post-featured-image/editor.css +9 -0
  126. package/build-style/quote/style-rtl.css +3 -0
  127. package/build-style/quote/style.css +3 -0
  128. package/build-style/read-more/style-rtl.css +2 -2
  129. package/build-style/read-more/style.css +2 -2
  130. package/build-style/style-rtl.css +24 -15
  131. package/build-style/style.css +24 -15
  132. package/package.json +32 -32
  133. package/src/block/edit.js +2 -1
  134. package/src/button/edit.js +70 -4
  135. package/src/code/transforms.js +14 -8
  136. package/src/comments/edit/comments-inspector-controls.js +1 -0
  137. package/src/cover/edit/inspector-controls.js +1 -0
  138. package/src/details/edit.js +0 -1
  139. package/src/form/index.js +1 -1
  140. package/src/form-submit-button/edit.js +1 -0
  141. package/src/gallery/gap-styles.js +10 -9
  142. package/src/group/edit.js +1 -0
  143. package/src/html/transforms.js +5 -2
  144. package/src/image/deprecated.js +8 -0
  145. package/src/image/editor.scss +7 -0
  146. package/src/image/index.php +3 -4
  147. package/src/image/style.scss +18 -13
  148. package/src/image/view.js +24 -11
  149. package/src/missing/block.json +1 -1
  150. package/src/navigation/edit/overlay-menu-preview.js +1 -1
  151. package/src/navigation/index.php +37 -402
  152. package/src/navigation/use-template-part-area-label.js +4 -2
  153. package/src/navigation-link/edit.js +2 -2
  154. package/src/navigation-link/index.php +57 -0
  155. package/src/paragraph/test/__snapshots__/transforms.native.js.snap +6 -0
  156. package/src/paragraph/test/transforms.native.js +1 -0
  157. package/src/pattern/edit.js +2 -1
  158. package/src/pattern/index.php +6 -1
  159. package/src/post-author/edit.js +0 -1
  160. package/src/post-featured-image/edit.js +38 -5
  161. package/src/post-featured-image/editor.scss +19 -0
  162. package/src/post-template/block.json +0 -1
  163. package/src/post-template/edit.js +1 -5
  164. package/src/post-terms/edit.js +0 -2
  165. package/src/preformatted/transforms.js +1 -4
  166. package/src/query/edit/query-content.js +1 -0
  167. package/src/query/index.php +6 -2
  168. package/src/quote/block.json +6 -0
  169. package/src/quote/style.scss +4 -0
  170. package/src/read-more/style.scss +1 -1
  171. package/src/template-part/edit/advanced-controls.js +1 -0
  172. package/src/template-part/edit/index.js +7 -14
  173. package/src/template-part/index.js +4 -3
  174. package/src/template-part/index.php +4 -4
  175. package/src/template-part/variations.js +4 -2
@@ -2,13 +2,18 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
- BlockList,
6
5
  __experimentalGetGapCSSValue as getGapCSSValue,
6
+ privateApis as blockEditorPrivateApis,
7
7
  } from '@wordpress/block-editor';
8
- import { useContext, createPortal } from '@wordpress/element';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { unlock } from '../lock-unlock';
13
+
14
+ const { useStyleOverride } = unlock( blockEditorPrivateApis );
9
15
 
10
16
  export default function GapStyles( { blockGap, clientId } ) {
11
- const styleElement = useContext( BlockList.__unstableElementContext );
12
17
  // --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default
13
18
  // gap on the gallery.
14
19
  const fallbackValue = `var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )`;
@@ -35,11 +40,7 @@ export default function GapStyles( { blockGap, clientId } ) {
35
40
  gap: ${ gapValue }
36
41
  }`;
37
42
 
38
- const GapStyle = () => {
39
- return <style>{ gap }</style>;
40
- };
43
+ useStyleOverride( { css: gap } );
41
44
 
42
- return gap && styleElement
43
- ? createPortal( <GapStyle />, styleElement )
44
- : null;
45
+ return null;
45
46
  }
package/src/group/edit.js CHANGED
@@ -52,6 +52,7 @@ function GroupEditControls( { tagName, onSelectTagName } ) {
52
52
  <InspectorControls group="advanced">
53
53
  <SelectControl
54
54
  __nextHasNoMarginBottom
55
+ __next40pxDefaultSize
55
56
  label={ __( 'HTML element' ) }
56
57
  options={ [
57
58
  { label: __( 'Default (<div>)' ), value: 'div' },
@@ -2,15 +2,18 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { createBlock } from '@wordpress/blocks';
5
+ import { create } from '@wordpress/rich-text';
5
6
 
6
7
  const transforms = {
7
8
  from: [
8
9
  {
9
10
  type: 'block',
10
11
  blocks: [ 'core/code' ],
11
- transform: ( { content } ) => {
12
+ transform: ( { content: html } ) => {
12
13
  return createBlock( 'core/html', {
13
- content,
14
+ // The code block may output HTML formatting, so convert it
15
+ // to plain text.
16
+ content: create( { html } ).text,
14
17
  } );
15
18
  },
16
19
  },
@@ -1047,6 +1047,14 @@ const v8 = {
1047
1047
  },
1048
1048
  },
1049
1049
  migrate( { width, height, ...attributes } ) {
1050
+ // We need to perform a check here because in cases
1051
+ // where attributes are added dynamically to blocks,
1052
+ // block invalidation overrides the isEligible() method
1053
+ // and forces the migration to run, so it's not guaranteed
1054
+ // that `behaviors` or `behaviors.lightbox` will be defined.
1055
+ if ( ! attributes.behaviors?.lightbox ) {
1056
+ return attributes;
1057
+ }
1050
1058
  const {
1051
1059
  behaviors: {
1052
1060
  lightbox: { enabled },
@@ -62,6 +62,13 @@ figure.wp-block-image:not(.wp-block) {
62
62
  left: 50%;
63
63
  transform: translate(-50%, -50%);
64
64
  }
65
+
66
+ // When the Image block is linked,
67
+ // it's wrapped with a disabled <a /> tag.
68
+ // Restore cursor style so it doesn't appear 'clickable'.
69
+ > a {
70
+ cursor: default;
71
+ }
65
72
  }
66
73
 
67
74
  // This is necessary for the editor resize handles to accurately work on a non-floated, non-resized, small image.
@@ -242,10 +242,9 @@ function block_core_image_render_lightbox( $block_content, $block ) {
242
242
  data-wp-on--click="actions.core.image.showLightbox"
243
243
  data-wp-style--right="context.core.image.imageButtonRight"
244
244
  data-wp-style--top="context.core.image.imageButtonTop"
245
- style="background: #000"
246
245
  >
247
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false">
248
- <Path stroke="#FFFFFF" d="M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z" />
246
+ <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
247
+ <path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
249
248
  </svg>
250
249
  </button>';
251
250
 
@@ -303,7 +302,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
303
302
  }
304
303
  }
305
304
 
306
- $close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg>';
305
+ $close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg>';
307
306
  $close_button_label = esc_attr__( 'Close' );
308
307
 
309
308
  $lightbox_html = <<<HTML
@@ -168,22 +168,27 @@
168
168
  button {
169
169
  opacity: 0;
170
170
  border: none;
171
- background: #000;
171
+ background-color: rgb(90 90 90 / 25%);
172
+ backdrop-filter: blur($grid-unit-20) saturate(180%);
172
173
  cursor: zoom-in;
173
- width: 24px;
174
- height: 24px;
174
+ display: flex;
175
+ justify-content: center;
176
+ align-items: center;
177
+ width: 20px;
178
+ height: 20px;
175
179
  position: absolute;
176
180
  z-index: 100;
177
- top: 10px;
178
- right: 10px;
181
+ top: 16px;
182
+ right: 16px;
179
183
  text-align: center;
180
184
  padding: 0;
181
- border-radius: 10%;
185
+ border-radius: 4px;
186
+ transition: opacity 0.2s ease;
182
187
 
183
188
  &:focus-visible {
184
- outline: 5px auto #212121;
185
- outline: 5px auto -webkit-focus-ring-color;
186
- outline-offset: 5px;
189
+ outline: 3px auto rgb(90 90 90 / 25%);
190
+ outline: 3px auto -webkit-focus-ring-color;
191
+ outline-offset: 3px;
187
192
  }
188
193
 
189
194
  &:hover {
@@ -198,7 +203,7 @@
198
203
  &:hover,
199
204
  &:focus,
200
205
  &:not(:hover):not(:active):not(.has-background) {
201
- background: #000;
206
+ background-color: rgb(90 90 90 / 25%);
202
207
  border: none;
203
208
  }
204
209
  }
@@ -210,7 +215,7 @@
210
215
  left: 0;
211
216
  z-index: 100000;
212
217
  overflow: hidden;
213
- width: 100vw;
218
+ width: 100%;
214
219
  height: 100vh;
215
220
  box-sizing: border-box;
216
221
  visibility: hidden;
@@ -367,7 +372,7 @@
367
372
 
368
373
  @keyframes lightbox-zoom-in {
369
374
  0% {
370
- transform: translate(calc(-50vw + var(--wp--lightbox-initial-left-position)), calc(-50vh + var(--wp--lightbox-initial-top-position))) scale(var(--wp--lightbox-scale));
375
+ transform: translate(calc((-100vw + var(--wp--lightbox-scrollbar-width)) / 2 + var(--wp--lightbox-initial-left-position)), calc(-50vh + var(--wp--lightbox-initial-top-position))) scale(var(--wp--lightbox-scale));
371
376
  }
372
377
  100% {
373
378
  transform: translate(-50%, -50%) scale(1, 1);
@@ -384,6 +389,6 @@
384
389
  }
385
390
  100% {
386
391
  visibility: hidden;
387
- transform: translate(calc(-50vw + var(--wp--lightbox-initial-left-position)), calc(-50vh + var(--wp--lightbox-initial-top-position))) scale(var(--wp--lightbox-scale));
392
+ transform: translate(calc((-100vw + var(--wp--lightbox-scrollbar-width)) / 2 + var(--wp--lightbox-initial-left-position)), calc(-50vh + var(--wp--lightbox-initial-top-position))) scale(var(--wp--lightbox-scale));
388
393
  }
389
394
  }
package/src/image/view.js CHANGED
@@ -313,11 +313,21 @@ store(
313
313
  if ( caption ) {
314
314
  const captionComputedStyle =
315
315
  window.getComputedStyle( caption );
316
- figureHeight =
317
- figureHeight -
318
- caption.offsetHeight -
319
- parseFloat( captionComputedStyle.marginTop ) -
320
- parseFloat( captionComputedStyle.marginBottom );
316
+ if (
317
+ ! [ 'absolute', 'fixed' ].includes(
318
+ captionComputedStyle.position
319
+ )
320
+ ) {
321
+ figureHeight =
322
+ figureHeight -
323
+ caption.offsetHeight -
324
+ parseFloat(
325
+ captionComputedStyle.marginTop
326
+ ) -
327
+ parseFloat(
328
+ captionComputedStyle.marginBottom
329
+ );
330
+ }
321
331
  }
322
332
 
323
333
  const buttonOffsetTop = figureHeight - offsetHeight;
@@ -340,26 +350,26 @@ store(
340
350
  context.core.image.imageButtonTop =
341
351
  ( offsetHeight - referenceHeight ) / 2 +
342
352
  buttonOffsetTop +
343
- 10;
353
+ 16;
344
354
  context.core.image.imageButtonRight =
345
- buttonOffsetRight + 10;
355
+ buttonOffsetRight + 16;
346
356
  } else {
347
357
  // If it reaches the height first, keep
348
358
  // the height and compute the width.
349
359
  const referenceWidth =
350
360
  offsetHeight * naturalRatio;
351
361
  context.core.image.imageButtonTop =
352
- buttonOffsetTop + 10;
362
+ buttonOffsetTop + 16;
353
363
  context.core.image.imageButtonRight =
354
364
  ( offsetWidth - referenceWidth ) / 2 +
355
365
  buttonOffsetRight +
356
- 10;
366
+ 16;
357
367
  }
358
368
  } else {
359
369
  context.core.image.imageButtonTop =
360
- buttonOffsetTop + 10;
370
+ buttonOffsetTop + 16;
361
371
  context.core.image.imageButtonRight =
362
- buttonOffsetRight + 10;
372
+ buttonOffsetRight + 16;
363
373
  }
364
374
  },
365
375
  setStylesOnResize: ( { state, context, ref } ) => {
@@ -558,6 +568,9 @@ function setStyles( context, ref ) {
558
568
  --wp--lightbox-image-width: ${ lightboxImgWidth }px;
559
569
  --wp--lightbox-image-height: ${ lightboxImgHeight }px;
560
570
  --wp--lightbox-scale: ${ containerScale };
571
+ --wp--lightbox-scrollbar-width: ${
572
+ window.innerWidth - document.documentElement.clientWidth
573
+ }px;
561
574
  }
562
575
  `;
563
576
  }
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "originalContent": {
17
17
  "type": "string",
18
- "source": "html"
18
+ "source": "raw"
19
19
  }
20
20
  },
21
21
  "supports": {
@@ -20,7 +20,7 @@ export default function OverlayMenuPreview( { setAttributes, hasIcon, icon } ) {
20
20
  __nextHasNoMarginBottom
21
21
  label={ __( 'Show icon button' ) }
22
22
  help={ __(
23
- 'Configure the visual appearance of the button opening the overlay menu.'
23
+ 'Configure the visual appearance of the button that toggles the overlay menu.'
24
24
  ) }
25
25
  onChange={ ( value ) => setAttributes( { hasIcon: value } ) }
26
26
  checked={ hasIcon }