@wordpress/block-library 9.40.2-next.v.202602271551.0 → 9.41.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 (89) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/button/block.json +11 -3
  3. package/build/button/deprecated.cjs +246 -13
  4. package/build/button/deprecated.cjs.map +2 -2
  5. package/build/button/edit.cjs +45 -58
  6. package/build/button/edit.cjs.map +3 -3
  7. package/build/button/save.cjs +3 -7
  8. package/build/button/save.cjs.map +2 -2
  9. package/build/button/utils.cjs +59 -0
  10. package/build/button/utils.cjs.map +7 -0
  11. package/build/image/image.cjs +1 -1
  12. package/build/image/image.cjs.map +2 -2
  13. package/build/navigation-link/shared/use-link-preview.cjs +2 -2
  14. package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
  15. package/build/playlist/edit.cjs +43 -136
  16. package/build/playlist/edit.cjs.map +3 -3
  17. package/build/playlist/view.cjs +56 -38
  18. package/build/playlist/view.cjs.map +2 -2
  19. package/build/playlist-track/edit.cjs +0 -1
  20. package/build/playlist-track/edit.cjs.map +2 -2
  21. package/build/post-title/block.json +3 -0
  22. package/build/post-title/edit.cjs +2 -2
  23. package/build/post-title/edit.cjs.map +2 -2
  24. package/build/utils/waveform-player.cjs +68 -0
  25. package/build/utils/waveform-player.cjs.map +7 -0
  26. package/build/utils/waveform-utils.cjs +171 -0
  27. package/build/utils/waveform-utils.cjs.map +7 -0
  28. package/build-module/button/block.json +11 -3
  29. package/build-module/button/deprecated.mjs +246 -13
  30. package/build-module/button/deprecated.mjs.map +2 -2
  31. package/build-module/button/edit.mjs +47 -63
  32. package/build-module/button/edit.mjs.map +2 -2
  33. package/build-module/button/save.mjs +3 -7
  34. package/build-module/button/save.mjs.map +2 -2
  35. package/build-module/button/utils.mjs +33 -0
  36. package/build-module/button/utils.mjs.map +7 -0
  37. package/build-module/image/image.mjs +1 -1
  38. package/build-module/image/image.mjs.map +2 -2
  39. package/build-module/navigation-link/shared/use-link-preview.mjs +2 -2
  40. package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
  41. package/build-module/playlist/edit.mjs +41 -139
  42. package/build-module/playlist/edit.mjs.map +2 -2
  43. package/build-module/playlist/view.mjs +56 -38
  44. package/build-module/playlist/view.mjs.map +2 -2
  45. package/build-module/playlist-track/edit.mjs +0 -1
  46. package/build-module/playlist-track/edit.mjs.map +2 -2
  47. package/build-module/post-title/block.json +3 -0
  48. package/build-module/post-title/edit.mjs +2 -2
  49. package/build-module/post-title/edit.mjs.map +2 -2
  50. package/build-module/utils/waveform-player.mjs +43 -0
  51. package/build-module/utils/waveform-player.mjs.map +7 -0
  52. package/build-module/utils/waveform-utils.mjs +131 -0
  53. package/build-module/utils/waveform-utils.mjs.map +7 -0
  54. package/build-style/button/style-rtl.css +6 -0
  55. package/build-style/button/style.css +6 -0
  56. package/build-style/editor-rtl.css +3 -3
  57. package/build-style/editor.css +3 -3
  58. package/build-style/playlist/editor-rtl.css +3 -3
  59. package/build-style/playlist/editor.css +3 -3
  60. package/build-style/playlist/style-rtl.css +351 -17
  61. package/build-style/playlist/style.css +351 -17
  62. package/build-style/style-rtl.css +357 -17
  63. package/build-style/style.css +357 -17
  64. package/package.json +39 -38
  65. package/src/button/block.json +11 -3
  66. package/src/button/deprecated.js +254 -16
  67. package/src/button/edit.js +50 -61
  68. package/src/button/index.php +68 -0
  69. package/src/button/save.js +2 -8
  70. package/src/button/style.scss +49 -7
  71. package/src/button/test/utils.js +84 -0
  72. package/src/button/utils.js +42 -0
  73. package/src/image/image.js +14 -15
  74. package/src/image/index.php +3 -1
  75. package/src/navigation-link/shared/test/use-link-preview.test.js +9 -0
  76. package/src/navigation-link/shared/use-link-preview.js +6 -9
  77. package/src/playlist/edit.js +60 -154
  78. package/src/playlist/editor.scss +3 -3
  79. package/src/playlist/index.php +15 -40
  80. package/src/playlist/style.scss +34 -27
  81. package/src/playlist/test/edit.js +137 -0
  82. package/src/playlist/view.js +97 -40
  83. package/src/playlist-track/edit.js +0 -1
  84. package/src/post-title/block.json +3 -0
  85. package/src/post-title/edit.js +4 -2
  86. package/src/search/index.php +1 -1
  87. package/src/utils/test/waveform-utils.js +328 -0
  88. package/src/utils/waveform-player.js +77 -0
  89. package/src/utils/waveform-utils.js +232 -0
@@ -16,6 +16,22 @@ import { compose } from "@wordpress/compose";
16
16
  import migrateFontFamily from "../utils/migrate-font-family.mjs";
17
17
  import migrateTextAlign from "../utils/migrate-text-align.mjs";
18
18
  import { jsx } from "react/jsx-runtime";
19
+ var migrateWidth = (attributes) => {
20
+ const { width, ...otherAttributes } = attributes;
21
+ if (!width) {
22
+ return otherAttributes;
23
+ }
24
+ return {
25
+ ...otherAttributes,
26
+ style: {
27
+ ...otherAttributes.style,
28
+ dimensions: {
29
+ ...otherAttributes.style?.dimensions,
30
+ width: `${width}%`
31
+ }
32
+ }
33
+ };
34
+ };
19
35
  var migrateBorderRadius = (attributes) => {
20
36
  const { borderRadius, ...newAttributes } = attributes;
21
37
  const oldBorderRadius = [
@@ -103,6 +119,205 @@ var blockAttributes = {
103
119
  selector: "a"
104
120
  }
105
121
  };
122
+ var v14 = {
123
+ attributes: {
124
+ tagName: {
125
+ type: "string",
126
+ enum: ["a", "button"],
127
+ default: "a"
128
+ },
129
+ type: {
130
+ type: "string",
131
+ default: "button"
132
+ },
133
+ url: {
134
+ type: "string",
135
+ source: "attribute",
136
+ selector: "a",
137
+ attribute: "href",
138
+ role: "content"
139
+ },
140
+ title: {
141
+ type: "string",
142
+ source: "attribute",
143
+ selector: "a,button",
144
+ attribute: "title",
145
+ role: "content"
146
+ },
147
+ text: {
148
+ type: "rich-text",
149
+ source: "rich-text",
150
+ selector: "a,button",
151
+ role: "content"
152
+ },
153
+ linkTarget: {
154
+ type: "string",
155
+ source: "attribute",
156
+ selector: "a",
157
+ attribute: "target",
158
+ role: "content"
159
+ },
160
+ rel: {
161
+ type: "string",
162
+ source: "attribute",
163
+ selector: "a",
164
+ attribute: "rel",
165
+ role: "content"
166
+ },
167
+ placeholder: {
168
+ type: "string"
169
+ },
170
+ backgroundColor: {
171
+ type: "string"
172
+ },
173
+ textColor: {
174
+ type: "string"
175
+ },
176
+ gradient: {
177
+ type: "string"
178
+ },
179
+ width: {
180
+ type: "number"
181
+ }
182
+ },
183
+ supports: {
184
+ anchor: true,
185
+ splitting: true,
186
+ align: false,
187
+ alignWide: false,
188
+ color: {
189
+ __experimentalSkipSerialization: true,
190
+ gradients: true,
191
+ __experimentalDefaultControls: {
192
+ background: true,
193
+ text: true
194
+ }
195
+ },
196
+ typography: {
197
+ __experimentalSkipSerialization: [
198
+ "fontSize",
199
+ "lineHeight",
200
+ "textAlign",
201
+ "fontFamily",
202
+ "fontWeight",
203
+ "fontStyle",
204
+ "textTransform",
205
+ "textDecoration",
206
+ "letterSpacing"
207
+ ],
208
+ fontSize: true,
209
+ lineHeight: true,
210
+ textAlign: true,
211
+ __experimentalFontFamily: true,
212
+ __experimentalFontWeight: true,
213
+ __experimentalFontStyle: true,
214
+ __experimentalTextTransform: true,
215
+ __experimentalTextDecoration: true,
216
+ __experimentalLetterSpacing: true,
217
+ __experimentalWritingMode: true,
218
+ __experimentalDefaultControls: {
219
+ fontSize: true
220
+ }
221
+ },
222
+ reusable: false,
223
+ shadow: {
224
+ __experimentalSkipSerialization: true
225
+ },
226
+ spacing: {
227
+ __experimentalSkipSerialization: true,
228
+ padding: ["horizontal", "vertical"],
229
+ __experimentalDefaultControls: {
230
+ padding: true
231
+ }
232
+ },
233
+ __experimentalBorder: {
234
+ color: true,
235
+ radius: true,
236
+ style: true,
237
+ width: true,
238
+ __experimentalSkipSerialization: true,
239
+ __experimentalDefaultControls: {
240
+ color: true,
241
+ radius: true,
242
+ style: true,
243
+ width: true
244
+ }
245
+ },
246
+ interactivity: {
247
+ clientNavigation: true
248
+ }
249
+ },
250
+ selectors: {
251
+ root: ".wp-block-button .wp-block-button__link",
252
+ typography: {
253
+ writingMode: ".wp-block-button"
254
+ }
255
+ },
256
+ save({ attributes, className }) {
257
+ const {
258
+ tagName,
259
+ type,
260
+ fontSize,
261
+ linkTarget,
262
+ rel,
263
+ style,
264
+ text,
265
+ title,
266
+ url,
267
+ width
268
+ } = attributes;
269
+ const TagName = tagName || "a";
270
+ const isButtonTag = "button" === TagName;
271
+ const buttonType = type || "button";
272
+ const borderProps = getBorderClassesAndStyles(attributes);
273
+ const colorProps = getColorClassesAndStyles(attributes);
274
+ const spacingProps = getSpacingClassesAndStyles(attributes);
275
+ const shadowProps = getShadowClassesAndStyles(attributes);
276
+ const typographyProps = getTypographyClassesAndStyles(attributes);
277
+ const buttonClasses = clsx(
278
+ "wp-block-button__link",
279
+ colorProps.className,
280
+ borderProps.className,
281
+ typographyProps.className,
282
+ {
283
+ // For backwards compatibility add style that isn't
284
+ // provided via block support.
285
+ "no-border-radius": style?.border?.radius === 0,
286
+ [`has-custom-font-size`]: fontSize || style?.typography?.fontSize
287
+ },
288
+ __experimentalGetElementClassName("button")
289
+ );
290
+ const buttonStyle = {
291
+ ...borderProps.style,
292
+ ...colorProps.style,
293
+ ...spacingProps.style,
294
+ ...shadowProps.style,
295
+ ...typographyProps.style,
296
+ writingMode: void 0
297
+ };
298
+ const wrapperClasses = clsx(className, {
299
+ [`has-custom-width wp-block-button__width-${width}`]: width
300
+ });
301
+ return /* @__PURE__ */ jsx("div", { ...useBlockProps.save({ className: wrapperClasses }), children: /* @__PURE__ */ jsx(
302
+ RichText.Content,
303
+ {
304
+ tagName: TagName,
305
+ type: isButtonTag ? buttonType : null,
306
+ className: buttonClasses,
307
+ href: isButtonTag ? null : url,
308
+ title,
309
+ style: buttonStyle,
310
+ value: text,
311
+ target: isButtonTag ? null : linkTarget,
312
+ rel: isButtonTag ? null : rel
313
+ }
314
+ ) });
315
+ },
316
+ isEligible(attributes) {
317
+ return typeof attributes.width === "number";
318
+ },
319
+ migrate: migrateWidth
320
+ };
106
321
  var v13 = {
107
322
  attributes: {
108
323
  tagName: {
@@ -300,9 +515,9 @@ var v13 = {
300
515
  ) });
301
516
  },
302
517
  isEligible(attributes) {
303
- return !!attributes.textAlign;
518
+ return !!attributes.textAlign || typeof attributes.width === "number";
304
519
  },
305
- migrate: migrateTextAlign
520
+ migrate: compose(migrateWidth, migrateTextAlign)
306
521
  };
307
522
  var v12 = {
308
523
  attributes: {
@@ -479,7 +694,11 @@ var v12 = {
479
694
  rel: isButtonTag ? null : rel
480
695
  }
481
696
  ) });
482
- }
697
+ },
698
+ isEligible(attributes) {
699
+ return typeof attributes.width === "number";
700
+ },
701
+ migrate: migrateWidth
483
702
  };
484
703
  var v11 = {
485
704
  attributes: {
@@ -720,12 +939,13 @@ var v10 = {
720
939
  }
721
940
  ) });
722
941
  },
723
- migrate: migrateFontFamily,
724
- isEligible({ style }) {
725
- return style?.typography?.fontFamily;
942
+ migrate: compose(migrateWidth, migrateFontFamily),
943
+ isEligible({ style, width }) {
944
+ return style?.typography?.fontFamily || typeof width === "number";
726
945
  }
727
946
  };
728
947
  var deprecated = [
948
+ v14,
729
949
  v13,
730
950
  v12,
731
951
  v11,
@@ -824,7 +1044,11 @@ var deprecated = [
824
1044
  }
825
1045
  ) });
826
1046
  },
827
- migrate: compose(migrateFontFamily, migrateBorderRadius)
1047
+ migrate: compose(
1048
+ migrateWidth,
1049
+ migrateFontFamily,
1050
+ migrateBorderRadius
1051
+ )
828
1052
  },
829
1053
  {
830
1054
  supports: {
@@ -904,7 +1128,11 @@ var deprecated = [
904
1128
  }
905
1129
  ) });
906
1130
  },
907
- migrate: compose(migrateFontFamily, migrateBorderRadius)
1131
+ migrate: compose(
1132
+ migrateWidth,
1133
+ migrateFontFamily,
1134
+ migrateBorderRadius
1135
+ )
908
1136
  },
909
1137
  {
910
1138
  supports: {
@@ -984,7 +1212,11 @@ var deprecated = [
984
1212
  }
985
1213
  ) });
986
1214
  },
987
- migrate: compose(migrateFontFamily, migrateBorderRadius)
1215
+ migrate: compose(
1216
+ migrateWidth,
1217
+ migrateFontFamily,
1218
+ migrateBorderRadius
1219
+ )
988
1220
  },
989
1221
  {
990
1222
  supports: {
@@ -1047,7 +1279,7 @@ var deprecated = [
1047
1279
  }
1048
1280
  );
1049
1281
  },
1050
- migrate: migrateBorderRadius
1282
+ migrate: compose(migrateWidth, migrateBorderRadius)
1051
1283
  },
1052
1284
  {
1053
1285
  supports: {
@@ -1095,6 +1327,7 @@ var deprecated = [
1095
1327
  },
1096
1328
  isEligible: (attributes) => !!attributes.customTextColor || !!attributes.customBackgroundColor || !!attributes.customGradient || !!attributes.align,
1097
1329
  migrate: compose(
1330
+ migrateWidth,
1098
1331
  migrateBorderRadius,
1099
1332
  migrateCustomColorsAndGradients,
1100
1333
  migrateAlign
@@ -1259,7 +1492,7 @@ var deprecated = [
1259
1492
  type: "string"
1260
1493
  }
1261
1494
  },
1262
- migrate: oldColorsMigration,
1495
+ migrate: compose(migrateWidth, oldColorsMigration),
1263
1496
  save({ attributes }) {
1264
1497
  const {
1265
1498
  url,
@@ -1331,7 +1564,7 @@ var deprecated = [
1331
1564
  }
1332
1565
  ) });
1333
1566
  },
1334
- migrate: oldColorsMigration
1567
+ migrate: compose(migrateWidth, oldColorsMigration)
1335
1568
  },
1336
1569
  {
1337
1570
  attributes: {
@@ -1367,7 +1600,7 @@ var deprecated = [
1367
1600
  }
1368
1601
  );
1369
1602
  },
1370
- migrate: oldColorsMigration
1603
+ migrate: compose(migrateWidth, oldColorsMigration)
1371
1604
  }
1372
1605
  ];
1373
1606
  var deprecated_default = deprecated;