@wordpress/block-library 7.6.0 → 7.7.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 (152) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/button/deprecated.js +175 -35
  3. package/build/button/deprecated.js.map +1 -1
  4. package/build/button/edit.js +1 -1
  5. package/build/button/edit.js.map +1 -1
  6. package/build/button/save.js +1 -1
  7. package/build/button/save.js.map +1 -1
  8. package/build/columns/index.js +3 -1
  9. package/build/columns/index.js.map +1 -1
  10. package/build/cover/deprecated.js +212 -207
  11. package/build/cover/deprecated.js.map +1 -1
  12. package/build/cover/edit/index.js +13 -3
  13. package/build/cover/edit/index.js.map +1 -1
  14. package/build/cover/save.js +18 -5
  15. package/build/cover/save.js.map +1 -1
  16. package/build/cover/shared.js +14 -17
  17. package/build/cover/shared.js.map +1 -1
  18. package/build/file/edit.js +1 -1
  19. package/build/file/edit.js.map +1 -1
  20. package/build/file/save.js +9 -1
  21. package/build/file/save.js.map +1 -1
  22. package/build/gallery/gap-styles.js +14 -4
  23. package/build/gallery/gap-styles.js.map +1 -1
  24. package/build/gallery/index.js +1 -1
  25. package/build/image/edit.js +5 -59
  26. package/build/image/edit.js.map +1 -1
  27. package/build/image/edit.native.js +56 -3
  28. package/build/image/edit.native.js.map +1 -1
  29. package/build/image/image.js +3 -13
  30. package/build/image/image.js.map +1 -1
  31. package/build/list-item/hooks/use-split.js +17 -3
  32. package/build/list-item/hooks/use-split.js.map +1 -1
  33. package/build/navigation-link/edit.js +31 -5
  34. package/build/navigation-link/edit.js.map +1 -1
  35. package/build/post-author-name/index.js +3 -0
  36. package/build/post-author-name/index.js.map +1 -1
  37. package/build/post-author-name/transforms.js +41 -0
  38. package/build/post-author-name/transforms.js.map +1 -0
  39. package/build/post-comments-form/form.js +11 -1
  40. package/build/post-comments-form/form.js.map +1 -1
  41. package/build/post-date/edit.js +13 -7
  42. package/build/post-date/edit.js.map +1 -1
  43. package/build/search/edit.js +1 -1
  44. package/build/search/edit.js.map +1 -1
  45. package/build/search/index.js +4 -0
  46. package/build/search/index.js.map +1 -1
  47. package/build/shortcode/edit.native.js +16 -13
  48. package/build/shortcode/edit.native.js.map +1 -1
  49. package/build/social-links/edit.js +2 -2
  50. package/build/social-links/edit.js.map +1 -1
  51. package/build/table-of-contents/edit.js +11 -3
  52. package/build/table-of-contents/edit.js.map +1 -1
  53. package/build-module/button/deprecated.js +175 -35
  54. package/build-module/button/deprecated.js.map +1 -1
  55. package/build-module/button/edit.js +2 -2
  56. package/build-module/button/edit.js.map +1 -1
  57. package/build-module/button/save.js +2 -2
  58. package/build-module/button/save.js.map +1 -1
  59. package/build-module/columns/index.js +3 -1
  60. package/build-module/columns/index.js.map +1 -1
  61. package/build-module/cover/deprecated.js +206 -198
  62. package/build-module/cover/deprecated.js.map +1 -1
  63. package/build-module/cover/edit/index.js +14 -4
  64. package/build-module/cover/edit/index.js.map +1 -1
  65. package/build-module/cover/save.js +19 -6
  66. package/build-module/cover/save.js.map +1 -1
  67. package/build-module/cover/shared.js +11 -12
  68. package/build-module/cover/shared.js.map +1 -1
  69. package/build-module/file/edit.js +2 -2
  70. package/build-module/file/edit.js.map +1 -1
  71. package/build-module/file/save.js +7 -2
  72. package/build-module/file/save.js.map +1 -1
  73. package/build-module/gallery/gap-styles.js +14 -4
  74. package/build-module/gallery/gap-styles.js.map +1 -1
  75. package/build-module/gallery/index.js +1 -1
  76. package/build-module/image/edit.js +5 -56
  77. package/build-module/image/edit.js.map +1 -1
  78. package/build-module/image/edit.native.js +57 -5
  79. package/build-module/image/edit.native.js.map +1 -1
  80. package/build-module/image/image.js +4 -14
  81. package/build-module/image/image.js.map +1 -1
  82. package/build-module/list-item/hooks/use-split.js +19 -5
  83. package/build-module/list-item/hooks/use-split.js.map +1 -1
  84. package/build-module/navigation-link/edit.js +31 -6
  85. package/build-module/navigation-link/edit.js.map +1 -1
  86. package/build-module/post-author-name/index.js +2 -0
  87. package/build-module/post-author-name/index.js.map +1 -1
  88. package/build-module/post-author-name/transforms.js +32 -0
  89. package/build-module/post-author-name/transforms.js.map +1 -0
  90. package/build-module/post-comments-form/form.js +7 -1
  91. package/build-module/post-comments-form/form.js.map +1 -1
  92. package/build-module/post-date/edit.js +15 -9
  93. package/build-module/post-date/edit.js.map +1 -1
  94. package/build-module/search/edit.js +2 -2
  95. package/build-module/search/edit.js.map +1 -1
  96. package/build-module/search/index.js +4 -0
  97. package/build-module/search/index.js.map +1 -1
  98. package/build-module/shortcode/edit.native.js +17 -13
  99. package/build-module/shortcode/edit.native.js.map +1 -1
  100. package/build-module/social-links/edit.js +2 -2
  101. package/build-module/social-links/edit.js.map +1 -1
  102. package/build-module/table-of-contents/edit.js +12 -4
  103. package/build-module/table-of-contents/edit.js.map +1 -1
  104. package/build-style/cover/style-rtl.css +32 -23
  105. package/build-style/cover/style.css +32 -23
  106. package/build-style/site-logo/style-rtl.css +4 -0
  107. package/build-style/site-logo/style.css +4 -0
  108. package/build-style/style-rtl.css +36 -23
  109. package/build-style/style.css +36 -23
  110. package/package.json +28 -28
  111. package/src/button/deprecated.js +145 -0
  112. package/src/button/edit.js +3 -1
  113. package/src/button/save.js +3 -1
  114. package/src/buttons/test/__snapshots__/edit.native.js.snap +1 -1
  115. package/src/buttons/test/edit.native.js +1 -1
  116. package/src/columns/block.json +3 -1
  117. package/src/cover/deprecated.js +230 -183
  118. package/src/cover/edit/index.js +25 -13
  119. package/src/cover/save.js +26 -13
  120. package/src/cover/shared.js +5 -7
  121. package/src/cover/style.scss +27 -22
  122. package/src/file/edit.js +5 -1
  123. package/src/file/save.js +14 -2
  124. package/src/gallery/block.json +1 -1
  125. package/src/gallery/gap-styles.js +21 -6
  126. package/src/gallery/index.php +23 -12
  127. package/src/image/edit.js +1 -53
  128. package/src/image/edit.native.js +65 -3
  129. package/src/image/image.js +2 -11
  130. package/src/image/styles.native.scss +11 -0
  131. package/src/list-item/hooks/use-split.js +18 -9
  132. package/src/navigation-link/edit.js +35 -5
  133. package/src/navigation-link/test/edit.js +0 -20
  134. package/src/post-author/index.php +3 -2
  135. package/src/post-author-name/index.js +2 -0
  136. package/src/post-author-name/index.php +1 -1
  137. package/src/post-author-name/transforms.js +25 -0
  138. package/src/post-comments/index.php +1 -1
  139. package/src/post-comments-form/form.js +11 -1
  140. package/src/post-comments-form/index.php +1 -1
  141. package/src/post-date/edit.js +4 -3
  142. package/src/query-pagination/index.php +0 -1
  143. package/src/search/block.json +4 -0
  144. package/src/search/edit.js +3 -1
  145. package/src/search/index.php +28 -15
  146. package/src/shortcode/edit.native.js +29 -15
  147. package/src/shortcode/style.native.scss +11 -4
  148. package/src/shortcode/test/__snapshots__/edit.native.js.snap +9 -0
  149. package/src/shortcode/test/edit.native.js +58 -40
  150. package/src/site-logo/style.scss +6 -0
  151. package/src/social-links/edit.js +11 -10
  152. package/src/table-of-contents/edit.js +19 -6
@@ -16,7 +16,13 @@ import { __ } from '@wordpress/i18n';
16
16
  * Internal dependencies
17
17
  */
18
18
 
19
- import { IMAGE_BACKGROUND_TYPE, VIDEO_BACKGROUND_TYPE, backgroundImageStyles, getPositionClassName, isContentPositionCenter, dimRatioToClass } from './shared';
19
+ import { IMAGE_BACKGROUND_TYPE, VIDEO_BACKGROUND_TYPE, getPositionClassName, isContentPositionCenter, dimRatioToClass } from './shared';
20
+
21
+ function backgroundImageStyles(url) {
22
+ return url ? {
23
+ backgroundImage: `url(${url})`
24
+ } : {};
25
+ }
20
26
  /**
21
27
  * Original function to determine the background opacity classname
22
28
  *
@@ -26,6 +32,7 @@ import { IMAGE_BACKGROUND_TYPE, VIDEO_BACKGROUND_TYPE, backgroundImageStyles, ge
26
32
  * @return {string} background opacity class .
27
33
  */
28
34
 
35
+
29
36
  function dimRatioToClassV1(ratio) {
30
37
  return ratio === 0 || ratio === 50 || !ratio ? null : 'has-background-dim-' + 10 * Math.round(ratio / 10);
31
38
  }
@@ -64,96 +71,192 @@ const blockAttributes = {
64
71
  focalPoint: {
65
72
  type: 'object'
66
73
  }
67
- }; // Deprecation for blocks with `minHeightUnit` set but no `minHeight`.
68
-
69
- const v9 = {
70
- attributes: {
71
- url: {
72
- type: 'string'
73
- },
74
- id: {
75
- type: 'number'
76
- },
77
- alt: {
78
- type: 'string',
79
- source: 'attribute',
80
- selector: 'img',
81
- attribute: 'alt',
82
- default: ''
83
- },
84
- hasParallax: {
85
- type: 'boolean',
86
- default: false
87
- },
88
- isRepeated: {
89
- type: 'boolean',
90
- default: false
91
- },
92
- dimRatio: {
93
- type: 'number',
94
- default: 100
95
- },
96
- overlayColor: {
97
- type: 'string'
98
- },
99
- customOverlayColor: {
100
- type: 'string'
101
- },
102
- backgroundType: {
103
- type: 'string',
104
- default: 'image'
105
- },
106
- focalPoint: {
107
- type: 'object'
108
- },
109
- minHeight: {
110
- type: 'number'
111
- },
112
- minHeightUnit: {
113
- type: 'string'
114
- },
115
- gradient: {
116
- type: 'string'
117
- },
118
- customGradient: {
119
- type: 'string'
120
- },
121
- contentPosition: {
122
- type: 'string'
123
- },
124
- isDark: {
125
- type: 'boolean',
126
- default: true
127
- },
128
- allowedBlocks: {
129
- type: 'array'
130
- },
131
- templateLock: {
132
- type: ['string', 'boolean'],
133
- enum: ['all', 'insert', false]
134
- }
74
+ };
75
+ const v8ToV10BlockAttributes = {
76
+ url: {
77
+ type: 'string'
135
78
  },
136
- supports: {
137
- anchor: true,
138
- align: true,
139
- html: false,
140
- spacing: {
141
- padding: true,
142
- __experimentalDefaultControls: {
143
- padding: true
144
- }
145
- },
146
- color: {
147
- __experimentalDuotone: '> .wp-block-cover__image-background, > .wp-block-cover__video-background',
148
- text: false,
149
- background: false
79
+ id: {
80
+ type: 'number'
81
+ },
82
+ alt: {
83
+ type: 'string',
84
+ source: 'attribute',
85
+ selector: 'img',
86
+ attribute: 'alt',
87
+ default: ''
88
+ },
89
+ hasParallax: {
90
+ type: 'boolean',
91
+ default: false
92
+ },
93
+ isRepeated: {
94
+ type: 'boolean',
95
+ default: false
96
+ },
97
+ dimRatio: {
98
+ type: 'number',
99
+ default: 100
100
+ },
101
+ overlayColor: {
102
+ type: 'string'
103
+ },
104
+ customOverlayColor: {
105
+ type: 'string'
106
+ },
107
+ backgroundType: {
108
+ type: 'string',
109
+ default: 'image'
110
+ },
111
+ focalPoint: {
112
+ type: 'object'
113
+ },
114
+ minHeight: {
115
+ type: 'number'
116
+ },
117
+ minHeightUnit: {
118
+ type: 'string'
119
+ },
120
+ gradient: {
121
+ type: 'string'
122
+ },
123
+ customGradient: {
124
+ type: 'string'
125
+ },
126
+ contentPosition: {
127
+ type: 'string'
128
+ },
129
+ isDark: {
130
+ type: 'boolean',
131
+ default: true
132
+ },
133
+ allowedBlocks: {
134
+ type: 'array'
135
+ },
136
+ templateLock: {
137
+ type: ['string', 'boolean'],
138
+ enum: ['all', 'insert', false]
139
+ }
140
+ };
141
+ const v7toV10BlockSupports = {
142
+ anchor: true,
143
+ align: true,
144
+ html: false,
145
+ spacing: {
146
+ padding: true,
147
+ __experimentalDefaultControls: {
148
+ padding: true
150
149
  }
151
150
  },
151
+ color: {
152
+ __experimentalDuotone: '> .wp-block-cover__image-background, > .wp-block-cover__video-background',
153
+ text: false,
154
+ background: false
155
+ }
156
+ }; // Deprecation for blocks that renders fixed background as backgroud from the main block container.
157
+
158
+ const v10 = {
159
+ attributes: v8ToV10BlockAttributes,
160
+ supports: v7toV10BlockSupports,
152
161
 
153
162
  save(_ref) {
154
163
  let {
155
164
  attributes
156
165
  } = _ref;
166
+ const {
167
+ backgroundType,
168
+ gradient,
169
+ contentPosition,
170
+ customGradient,
171
+ customOverlayColor,
172
+ dimRatio,
173
+ focalPoint,
174
+ useFeaturedImage,
175
+ hasParallax,
176
+ isDark,
177
+ isRepeated,
178
+ overlayColor,
179
+ url,
180
+ alt,
181
+ id,
182
+ minHeight: minHeightProp,
183
+ minHeightUnit
184
+ } = attributes;
185
+ const overlayColorClass = getColorClassName('background-color', overlayColor);
186
+
187
+ const gradientClass = __experimentalGetGradientClass(gradient);
188
+
189
+ const minHeight = minHeightProp && minHeightUnit ? `${minHeightProp}${minHeightUnit}` : minHeightProp;
190
+ const isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;
191
+ const isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;
192
+ const isImgElement = !(hasParallax || isRepeated);
193
+ const style = { ...(isImageBackground && !isImgElement && !useFeaturedImage ? backgroundImageStyles(url) : {}),
194
+ minHeight: minHeight || undefined
195
+ };
196
+ const bgStyle = {
197
+ backgroundColor: !overlayColorClass ? customOverlayColor : undefined,
198
+ background: customGradient ? customGradient : undefined
199
+ };
200
+ const objectPosition = // prettier-ignore
201
+ focalPoint && isImgElement ? `${Math.round(focalPoint.x * 100)}% ${Math.round(focalPoint.y * 100)}%` : undefined;
202
+ const classes = classnames({
203
+ 'is-light': !isDark,
204
+ 'has-parallax': hasParallax,
205
+ 'is-repeated': isRepeated,
206
+ 'has-custom-content-position': !isContentPositionCenter(contentPosition)
207
+ }, getPositionClassName(contentPosition));
208
+ const gradientValue = gradient || customGradient;
209
+ return createElement("div", useBlockProps.save({
210
+ className: classes,
211
+ style
212
+ }), createElement("span", {
213
+ "aria-hidden": "true",
214
+ className: classnames('wp-block-cover__background', overlayColorClass, dimRatioToClass(dimRatio), {
215
+ 'has-background-dim': dimRatio !== undefined,
216
+ // For backwards compatibility. Former versions of the Cover Block applied
217
+ // `.wp-block-cover__gradient-background` in the presence of
218
+ // media, a gradient and a dim.
219
+ 'wp-block-cover__gradient-background': url && gradientValue && dimRatio !== 0,
220
+ 'has-background-gradient': gradientValue,
221
+ [gradientClass]: gradientClass
222
+ }),
223
+ style: bgStyle
224
+ }), !useFeaturedImage && isImageBackground && isImgElement && url && createElement("img", {
225
+ className: classnames('wp-block-cover__image-background', id ? `wp-image-${id}` : null),
226
+ alt: alt,
227
+ src: url,
228
+ style: {
229
+ objectPosition
230
+ },
231
+ "data-object-fit": "cover",
232
+ "data-object-position": objectPosition
233
+ }), isVideoBackground && url && createElement("video", {
234
+ className: classnames('wp-block-cover__video-background', 'intrinsic-ignore'),
235
+ autoPlay: true,
236
+ muted: true,
237
+ loop: true,
238
+ playsInline: true,
239
+ src: url,
240
+ style: {
241
+ objectPosition
242
+ },
243
+ "data-object-fit": "cover",
244
+ "data-object-position": objectPosition
245
+ }), createElement("div", useInnerBlocksProps.save({
246
+ className: 'wp-block-cover__inner-container'
247
+ })));
248
+ }
249
+
250
+ }; // Deprecation for blocks with `minHeightUnit` set but no `minHeight`.
251
+
252
+ const v9 = {
253
+ attributes: v8ToV10BlockAttributes,
254
+ supports: v7toV10BlockSupports,
255
+
256
+ save(_ref2) {
257
+ let {
258
+ attributes
259
+ } = _ref2;
157
260
  const {
158
261
  backgroundType,
159
262
  gradient,
@@ -240,93 +343,13 @@ const v9 = {
240
343
  }; // v8: deprecated to remove duplicated gradient classes and swap `wp-block-cover__gradient-background` for `wp-block-cover__background`.
241
344
 
242
345
  const v8 = {
243
- attributes: {
244
- url: {
245
- type: 'string'
246
- },
247
- id: {
248
- type: 'number'
249
- },
250
- alt: {
251
- type: 'string',
252
- source: 'attribute',
253
- selector: 'img',
254
- attribute: 'alt',
255
- default: ''
256
- },
257
- hasParallax: {
258
- type: 'boolean',
259
- default: false
260
- },
261
- isRepeated: {
262
- type: 'boolean',
263
- default: false
264
- },
265
- dimRatio: {
266
- type: 'number',
267
- default: 100
268
- },
269
- overlayColor: {
270
- type: 'string'
271
- },
272
- customOverlayColor: {
273
- type: 'string'
274
- },
275
- backgroundType: {
276
- type: 'string',
277
- default: 'image'
278
- },
279
- focalPoint: {
280
- type: 'object'
281
- },
282
- minHeight: {
283
- type: 'number'
284
- },
285
- minHeightUnit: {
286
- type: 'string'
287
- },
288
- gradient: {
289
- type: 'string'
290
- },
291
- customGradient: {
292
- type: 'string'
293
- },
294
- contentPosition: {
295
- type: 'string'
296
- },
297
- isDark: {
298
- type: 'boolean',
299
- default: true
300
- },
301
- allowedBlocks: {
302
- type: 'array'
303
- },
304
- templateLock: {
305
- type: ['string', 'boolean'],
306
- enum: ['all', 'insert', false]
307
- }
308
- },
309
- supports: {
310
- anchor: true,
311
- align: true,
312
- html: false,
313
- spacing: {
314
- padding: true,
315
- __experimentalDefaultControls: {
316
- padding: true
317
- }
318
- },
319
- color: {
320
- __experimentalDuotone: '> .wp-block-cover__image-background, > .wp-block-cover__video-background',
321
- text: false,
322
- background: false
323
- }
324
- },
346
+ attributes: v8ToV10BlockAttributes,
347
+ supports: v7toV10BlockSupports,
325
348
 
326
- save(_ref2) {
349
+ save(_ref3) {
327
350
  let {
328
351
  attributes
329
- } = _ref2;
352
+ } = _ref3;
330
353
  const {
331
354
  backgroundType,
332
355
  gradient,
@@ -435,27 +458,12 @@ const v7 = {
435
458
  default: ''
436
459
  }
437
460
  },
438
- supports: {
439
- anchor: true,
440
- align: true,
441
- html: false,
442
- spacing: {
443
- padding: true,
444
- __experimentalDefaultControls: {
445
- padding: true
446
- }
447
- },
448
- color: {
449
- __experimentalDuotone: '> .wp-block-cover__image-background, > .wp-block-cover__video-background',
450
- text: false,
451
- background: false
452
- }
453
- },
461
+ supports: v7toV10BlockSupports,
454
462
 
455
- save(_ref3) {
463
+ save(_ref4) {
456
464
  let {
457
465
  attributes
458
- } = _ref3;
466
+ } = _ref4;
459
467
  const {
460
468
  backgroundType,
461
469
  gradient,
@@ -559,10 +567,10 @@ const v6 = {
559
567
  align: true
560
568
  },
561
569
 
562
- save(_ref4) {
570
+ save(_ref5) {
563
571
  let {
564
572
  attributes
565
- } = _ref4;
573
+ } = _ref5;
566
574
  const {
567
575
  backgroundType,
568
576
  gradient,
@@ -659,10 +667,10 @@ const v5 = {
659
667
  align: true
660
668
  },
661
669
 
662
- save(_ref5) {
670
+ save(_ref6) {
663
671
  let {
664
672
  attributes
665
- } = _ref5;
673
+ } = _ref6;
666
674
  const {
667
675
  backgroundType,
668
676
  gradient,
@@ -738,10 +746,10 @@ const v4 = {
738
746
  align: true
739
747
  },
740
748
 
741
- save(_ref6) {
749
+ save(_ref7) {
742
750
  let {
743
751
  attributes
744
- } = _ref6;
752
+ } = _ref7;
745
753
  const {
746
754
  backgroundType,
747
755
  gradient,
@@ -817,10 +825,10 @@ const v3 = {
817
825
  align: true
818
826
  },
819
827
 
820
- save(_ref7) {
828
+ save(_ref8) {
821
829
  let {
822
830
  attributes
823
- } = _ref7;
831
+ } = _ref8;
824
832
  const {
825
833
  backgroundType,
826
834
  contentAlign,
@@ -896,10 +904,10 @@ const v2 = {
896
904
  className: false
897
905
  },
898
906
 
899
- save(_ref8) {
907
+ save(_ref9) {
900
908
  let {
901
909
  attributes
902
- } = _ref8;
910
+ } = _ref9;
903
911
  const {
904
912
  url,
905
913
  title,
@@ -964,10 +972,10 @@ const v1 = {
964
972
  className: false
965
973
  },
966
974
 
967
- save(_ref9) {
975
+ save(_ref10) {
968
976
  let {
969
977
  attributes
970
- } = _ref9;
978
+ } = _ref10;
971
979
  const {
972
980
  url,
973
981
  title,
@@ -1002,5 +1010,5 @@ const v1 = {
1002
1010
  }
1003
1011
 
1004
1012
  };
1005
- export default [v9, v8, v7, v6, v5, v4, v3, v2, v1];
1013
+ export default [v10, v9, v8, v7, v6, v5, v4, v3, v2, v1];
1006
1014
  //# sourceMappingURL=deprecated.js.map