@wordpress/block-library 8.24.0 → 8.25.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 (327) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/audio/edit.js +7 -52
  3. package/build/audio/edit.js.map +1 -1
  4. package/build/audio/edit.native.js +1 -1
  5. package/build/audio/edit.native.js.map +1 -1
  6. package/build/audio/index.js +2 -2
  7. package/build/block/edit.js +102 -11
  8. package/build/block/edit.js.map +1 -1
  9. package/build/block/index.js +3 -2
  10. package/build/block/index.js.map +1 -1
  11. package/build/block/v1/edit.js +116 -0
  12. package/build/block/v1/edit.js.map +1 -0
  13. package/build/block/{edit.native.js → v1/edit.native.js} +2 -2
  14. package/build/block/v1/edit.native.js.map +1 -0
  15. package/build/button/index.js +2 -2
  16. package/build/button/save.js +1 -1
  17. package/build/button/save.js.map +1 -1
  18. package/build/code/edit.native.js +13 -14
  19. package/build/code/edit.native.js.map +1 -1
  20. package/build/code/index.js +2 -2
  21. package/build/code/save.js +6 -2
  22. package/build/code/save.js.map +1 -1
  23. package/build/details/index.js +2 -2
  24. package/build/embed/deprecated.js +2 -2
  25. package/build/embed/embed-preview.native.js +1 -1
  26. package/build/embed/embed-preview.native.js.map +1 -1
  27. package/build/embed/icons.js +1 -1
  28. package/build/embed/icons.js.map +1 -1
  29. package/build/embed/index.js +2 -2
  30. package/build/embed/transforms.js +2 -2
  31. package/build/embed/util.js +2 -2
  32. package/build/file/edit.js +1 -1
  33. package/build/file/edit.js.map +1 -1
  34. package/build/file/edit.native.js +1 -1
  35. package/build/file/edit.native.js.map +1 -1
  36. package/build/file/index.js +4 -4
  37. package/build/file/save.js +4 -1
  38. package/build/file/save.js.map +1 -1
  39. package/build/form-input/deprecated.js +147 -0
  40. package/build/form-input/deprecated.js.map +1 -0
  41. package/build/form-input/edit.js +1 -1
  42. package/build/form-input/edit.js.map +1 -1
  43. package/build/form-input/index.js +4 -2
  44. package/build/form-input/index.js.map +1 -1
  45. package/build/form-input/save.js +7 -9
  46. package/build/form-input/save.js.map +1 -1
  47. package/build/gallery/edit.js +2 -41
  48. package/build/gallery/edit.js.map +1 -1
  49. package/build/gallery/gallery.js +18 -24
  50. package/build/gallery/gallery.js.map +1 -1
  51. package/build/gallery/gallery.native.js +1 -1
  52. package/build/gallery/gallery.native.js.map +1 -1
  53. package/build/gallery/index.js +4 -4
  54. package/build/gallery/v1/gallery.native.js +1 -1
  55. package/build/gallery/v1/gallery.native.js.map +1 -1
  56. package/build/group/edit.js +6 -1
  57. package/build/group/edit.js.map +1 -1
  58. package/build/heading/index.js +3 -6
  59. package/build/heading/index.js.map +1 -1
  60. package/build/image/edit.native.js +1 -1
  61. package/build/image/edit.native.js.map +1 -1
  62. package/build/image/image.js +14 -51
  63. package/build/image/image.js.map +1 -1
  64. package/build/image/index.js +2 -2
  65. package/build/image/save.js +3 -1
  66. package/build/image/save.js.map +1 -1
  67. package/build/list-item/index.js +10 -3
  68. package/build/list-item/index.js.map +1 -1
  69. package/build/navigation/edit/index.js +1 -1
  70. package/build/navigation/edit/index.js.map +1 -1
  71. package/build/page-list/convert-to-links-modal.js +2 -2
  72. package/build/page-list/convert-to-links-modal.js.map +1 -1
  73. package/build/paragraph/edit.js +54 -32
  74. package/build/paragraph/edit.js.map +1 -1
  75. package/build/paragraph/index.js +2 -3
  76. package/build/paragraph/index.js.map +1 -1
  77. package/build/paragraph/transforms.js +2 -3
  78. package/build/paragraph/transforms.js.map +1 -1
  79. package/build/post-title/index.js +1 -3
  80. package/build/post-title/index.js.map +1 -1
  81. package/build/preformatted/index.js +2 -3
  82. package/build/preformatted/index.js.map +1 -1
  83. package/build/pullquote/index.js +5 -7
  84. package/build/pullquote/index.js.map +1 -1
  85. package/build/query/edit/inspector-controls/taxonomy-controls.js +2 -0
  86. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  87. package/build/query-title/index.js +1 -3
  88. package/build/query-title/index.js.map +1 -1
  89. package/build/quote/index.js +3 -5
  90. package/build/quote/index.js.map +1 -1
  91. package/build/quote/transforms.js +7 -6
  92. package/build/quote/transforms.js.map +1 -1
  93. package/build/site-title/index.js +1 -5
  94. package/build/site-title/index.js.map +1 -1
  95. package/build/social-link/icons/gravatar.js +22 -0
  96. package/build/social-link/icons/gravatar.js.map +1 -0
  97. package/build/social-link/icons/index.js +11 -0
  98. package/build/social-link/icons/index.js.map +1 -1
  99. package/build/social-link/variations.js +7 -0
  100. package/build/social-link/variations.js.map +1 -1
  101. package/build/table/edit.js +3 -1
  102. package/build/table/edit.js.map +1 -1
  103. package/build/table/index.js +9 -10
  104. package/build/table/index.js.map +1 -1
  105. package/build/table-of-contents/edit.js +2 -2
  106. package/build/table-of-contents/edit.js.map +1 -1
  107. package/build/table-of-contents/index.js +5 -2
  108. package/build/table-of-contents/index.js.map +1 -1
  109. package/build/utils/caption.js +90 -0
  110. package/build/utils/caption.js.map +1 -0
  111. package/build/utils/remove-anchor-tag.js +2 -1
  112. package/build/utils/remove-anchor-tag.js.map +1 -1
  113. package/build/verse/index.js +3 -5
  114. package/build/verse/index.js.map +1 -1
  115. package/build/video/deprecated.js +2 -2
  116. package/build/video/edit.js +8 -52
  117. package/build/video/edit.js.map +1 -1
  118. package/build/video/edit.native.js +1 -1
  119. package/build/video/edit.native.js.map +1 -1
  120. package/build/video/index.js +2 -2
  121. package/build-module/audio/edit.js +11 -56
  122. package/build-module/audio/edit.js.map +1 -1
  123. package/build-module/audio/edit.native.js +2 -2
  124. package/build-module/audio/edit.native.js.map +1 -1
  125. package/build-module/audio/index.js +2 -2
  126. package/build-module/block/edit.js +104 -13
  127. package/build-module/block/edit.js.map +1 -1
  128. package/build-module/block/index.js +3 -2
  129. package/build-module/block/index.js.map +1 -1
  130. package/build-module/block/v1/edit.js +108 -0
  131. package/build-module/block/v1/edit.js.map +1 -0
  132. package/build-module/block/{edit.native.js → v1/edit.native.js} +2 -2
  133. package/build-module/block/v1/edit.native.js.map +1 -0
  134. package/build-module/button/index.js +2 -2
  135. package/build-module/button/save.js +1 -1
  136. package/build-module/button/save.js.map +1 -1
  137. package/build-module/code/edit.native.js +14 -16
  138. package/build-module/code/edit.native.js.map +1 -1
  139. package/build-module/code/index.js +2 -2
  140. package/build-module/code/save.js +6 -2
  141. package/build-module/code/save.js.map +1 -1
  142. package/build-module/details/index.js +2 -2
  143. package/build-module/embed/deprecated.js +2 -2
  144. package/build-module/embed/embed-preview.native.js +2 -2
  145. package/build-module/embed/embed-preview.native.js.map +1 -1
  146. package/build-module/embed/icons.js +1 -1
  147. package/build-module/embed/icons.js.map +1 -1
  148. package/build-module/embed/index.js +2 -2
  149. package/build-module/embed/transforms.js +2 -2
  150. package/build-module/embed/util.js +2 -2
  151. package/build-module/file/edit.js +1 -1
  152. package/build-module/file/edit.js.map +1 -1
  153. package/build-module/file/edit.native.js +1 -1
  154. package/build-module/file/edit.native.js.map +1 -1
  155. package/build-module/file/index.js +4 -4
  156. package/build-module/file/save.js +4 -1
  157. package/build-module/file/save.js.map +1 -1
  158. package/build-module/form-input/deprecated.js +138 -0
  159. package/build-module/form-input/deprecated.js.map +1 -0
  160. package/build-module/form-input/edit.js +1 -1
  161. package/build-module/form-input/edit.js.map +1 -1
  162. package/build-module/form-input/index.js +4 -2
  163. package/build-module/form-input/index.js.map +1 -1
  164. package/build-module/form-input/save.js +8 -10
  165. package/build-module/form-input/save.js.map +1 -1
  166. package/build-module/gallery/edit.js +5 -44
  167. package/build-module/gallery/edit.js.map +1 -1
  168. package/build-module/gallery/gallery.js +17 -21
  169. package/build-module/gallery/gallery.js.map +1 -1
  170. package/build-module/gallery/gallery.native.js +2 -2
  171. package/build-module/gallery/gallery.native.js.map +1 -1
  172. package/build-module/gallery/index.js +4 -4
  173. package/build-module/gallery/v1/gallery.native.js +2 -2
  174. package/build-module/gallery/v1/gallery.native.js.map +1 -1
  175. package/build-module/group/edit.js +6 -1
  176. package/build-module/group/edit.js.map +1 -1
  177. package/build-module/heading/index.js +3 -6
  178. package/build-module/heading/index.js.map +1 -1
  179. package/build-module/image/edit.native.js +2 -2
  180. package/build-module/image/edit.native.js.map +1 -1
  181. package/build-module/image/image.js +19 -56
  182. package/build-module/image/image.js.map +1 -1
  183. package/build-module/image/index.js +2 -2
  184. package/build-module/image/save.js +3 -1
  185. package/build-module/image/save.js.map +1 -1
  186. package/build-module/list-item/index.js +10 -3
  187. package/build-module/list-item/index.js.map +1 -1
  188. package/build-module/navigation/edit/index.js +2 -2
  189. package/build-module/navigation/edit/index.js.map +1 -1
  190. package/build-module/page-list/convert-to-links-modal.js +2 -2
  191. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  192. package/build-module/paragraph/edit.js +54 -32
  193. package/build-module/paragraph/edit.js.map +1 -1
  194. package/build-module/paragraph/index.js +2 -3
  195. package/build-module/paragraph/index.js.map +1 -1
  196. package/build-module/paragraph/transforms.js +2 -3
  197. package/build-module/paragraph/transforms.js.map +1 -1
  198. package/build-module/post-title/index.js +1 -3
  199. package/build-module/post-title/index.js.map +1 -1
  200. package/build-module/preformatted/index.js +2 -3
  201. package/build-module/preformatted/index.js.map +1 -1
  202. package/build-module/pullquote/index.js +5 -7
  203. package/build-module/pullquote/index.js.map +1 -1
  204. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +2 -0
  205. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  206. package/build-module/query-title/index.js +1 -3
  207. package/build-module/query-title/index.js.map +1 -1
  208. package/build-module/quote/index.js +3 -5
  209. package/build-module/quote/index.js.map +1 -1
  210. package/build-module/quote/transforms.js +7 -6
  211. package/build-module/quote/transforms.js.map +1 -1
  212. package/build-module/site-title/index.js +1 -5
  213. package/build-module/site-title/index.js.map +1 -1
  214. package/build-module/social-link/icons/gravatar.js +14 -0
  215. package/build-module/social-link/icons/gravatar.js.map +1 -0
  216. package/build-module/social-link/icons/index.js +1 -0
  217. package/build-module/social-link/icons/index.js.map +1 -1
  218. package/build-module/social-link/variations.js +8 -1
  219. package/build-module/social-link/variations.js.map +1 -1
  220. package/build-module/table/edit.js +3 -1
  221. package/build-module/table/edit.js.map +1 -1
  222. package/build-module/table/index.js +9 -10
  223. package/build-module/table/index.js.map +1 -1
  224. package/build-module/table-of-contents/edit.js +1 -1
  225. package/build-module/table-of-contents/edit.js.map +1 -1
  226. package/build-module/table-of-contents/index.js +5 -1
  227. package/build-module/table-of-contents/index.js.map +1 -1
  228. package/build-module/utils/caption.js +82 -0
  229. package/build-module/utils/caption.js.map +1 -0
  230. package/build-module/utils/remove-anchor-tag.js +2 -1
  231. package/build-module/utils/remove-anchor-tag.js.map +1 -1
  232. package/build-module/verse/index.js +3 -5
  233. package/build-module/verse/index.js.map +1 -1
  234. package/build-module/video/deprecated.js +2 -2
  235. package/build-module/video/edit.js +13 -57
  236. package/build-module/video/edit.js.map +1 -1
  237. package/build-module/video/edit.native.js +2 -2
  238. package/build-module/video/edit.native.js.map +1 -1
  239. package/build-module/video/index.js +2 -2
  240. package/build-style/editor-rtl.css +1 -11
  241. package/build-style/editor.css +1 -11
  242. package/build-style/social-links/style-rtl.css +14 -2
  243. package/build-style/social-links/style.css +14 -2
  244. package/build-style/style-rtl.css +14 -2
  245. package/build-style/style.css +14 -2
  246. package/build-style/table/editor-rtl.css +1 -11
  247. package/build-style/table/editor.css +1 -11
  248. package/package.json +32 -32
  249. package/src/audio/block.json +2 -2
  250. package/src/audio/edit.js +11 -74
  251. package/src/audio/edit.native.js +2 -1
  252. package/src/block/edit.js +143 -16
  253. package/src/block/index.js +3 -2
  254. package/src/block/index.php +48 -0
  255. package/src/block/v1/edit.js +163 -0
  256. package/src/block/{edit.native.js → v1/edit.native.js} +2 -2
  257. package/src/button/block.json +2 -2
  258. package/src/button/save.js +1 -1
  259. package/src/code/block.json +2 -2
  260. package/src/code/edit.native.js +11 -13
  261. package/src/code/save.js +4 -1
  262. package/src/code/test/edit.native.js +2 -2
  263. package/src/cover/test/edit.native.js +7 -1
  264. package/src/details/block.json +2 -2
  265. package/src/embed/block.json +2 -2
  266. package/src/embed/embed-preview.native.js +2 -1
  267. package/src/embed/icons.js +1 -1
  268. package/src/file/block.json +4 -4
  269. package/src/file/edit.js +1 -1
  270. package/src/file/edit.native.js +1 -1
  271. package/src/file/save.js +5 -1
  272. package/src/form-input/block.json +2 -2
  273. package/src/form-input/deprecated.js +142 -0
  274. package/src/form-input/edit.js +1 -1
  275. package/src/form-input/index.js +2 -0
  276. package/src/form-input/save.js +27 -24
  277. package/src/gallery/block.json +4 -4
  278. package/src/gallery/edit.js +4 -59
  279. package/src/gallery/gallery.js +19 -36
  280. package/src/gallery/gallery.native.js +6 -2
  281. package/src/gallery/v1/gallery.native.js +2 -1
  282. package/src/group/edit.js +4 -1
  283. package/src/heading/block.json +3 -6
  284. package/src/image/block.json +2 -2
  285. package/src/image/edit.native.js +2 -3
  286. package/src/image/image.js +24 -93
  287. package/src/image/save.js +3 -1
  288. package/src/list-item/block.json +10 -3
  289. package/src/navigation/edit/index.js +7 -2
  290. package/src/navigation/index.php +1 -1
  291. package/src/navigation-link/test/__snapshots__/hooks.js.snap +6 -3
  292. package/src/page-list/convert-to-links-modal.js +2 -2
  293. package/src/paragraph/block.json +2 -3
  294. package/src/paragraph/edit.js +53 -40
  295. package/src/post-title/block.json +1 -3
  296. package/src/preformatted/block.json +2 -3
  297. package/src/pullquote/block.json +5 -7
  298. package/src/query/edit/inspector-controls/taxonomy-controls.js +2 -0
  299. package/src/query-title/block.json +1 -3
  300. package/src/quote/block.json +3 -5
  301. package/src/quote/transforms.js +12 -11
  302. package/src/site-title/block.json +1 -5
  303. package/src/social-link/icons/gravatar.js +10 -0
  304. package/src/social-link/icons/index.js +1 -0
  305. package/src/social-link/index.php +4 -0
  306. package/src/social-link/socials-with-bg.scss +5 -0
  307. package/src/social-link/socials-without-bg.scss +4 -0
  308. package/src/social-link/variations.js +7 -0
  309. package/src/social-links/style.scss +14 -8
  310. package/src/table/block.json +9 -10
  311. package/src/table/edit.js +3 -1
  312. package/src/table/editor.scss +1 -14
  313. package/src/table-of-contents/edit.js +1 -1
  314. package/src/table-of-contents/index.js +5 -1
  315. package/src/utils/caption.js +108 -0
  316. package/src/utils/remove-anchor-tag.js +2 -1
  317. package/src/verse/block.json +3 -5
  318. package/src/video/block.json +2 -2
  319. package/src/video/edit.js +12 -74
  320. package/src/video/edit.native.js +2 -1
  321. package/build/block/edit.native.js.map +0 -1
  322. package/build/table-of-contents/icon.js +0 -22
  323. package/build/table-of-contents/icon.js.map +0 -1
  324. package/build-module/block/edit.native.js.map +0 -1
  325. package/build-module/table-of-contents/icon.js +0 -15
  326. package/build-module/table-of-contents/icon.js.map +0 -1
  327. package/src/table-of-contents/icon.js +0 -18
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 8.25.0 (2023-12-13)
6
+
5
7
  ## 8.24.0 (2023-11-29)
6
8
 
7
9
  ## 8.23.0 (2023-11-16)
@@ -14,10 +14,9 @@ var _element = require("@wordpress/element");
14
14
  var _i18n = require("@wordpress/i18n");
15
15
  var _data = require("@wordpress/data");
16
16
  var _icons = require("@wordpress/icons");
17
- var _blocks = require("@wordpress/blocks");
18
17
  var _notices = require("@wordpress/notices");
19
- var _compose = require("@wordpress/compose");
20
18
  var _util = require("../embed/util");
19
+ var _caption = require("../utils/caption");
21
20
  /**
22
21
  * External dependencies
23
22
  */
@@ -42,13 +41,10 @@ function AudioEdit({
42
41
  const {
43
42
  id,
44
43
  autoplay,
45
- caption,
46
44
  loop,
47
45
  preload,
48
46
  src
49
47
  } = attributes;
50
- const prevCaption = (0, _compose.usePrevious)(caption);
51
- const [showCaption, setShowCaption] = (0, _element.useState)(!!caption);
52
48
  const isTemporaryAudio = !id && (0, _blob.isBlobURL)(src);
53
49
  const mediaUpload = (0, _data.useSelect)(select => {
54
50
  const {
@@ -69,26 +65,6 @@ function AudioEdit({
69
65
  }
70
66
  }
71
67
  }, []);
72
-
73
- // We need to show the caption when changes come from
74
- // history navigation(undo/redo).
75
- (0, _element.useEffect)(() => {
76
- if (caption && !prevCaption) {
77
- setShowCaption(true);
78
- }
79
- }, [caption, prevCaption]);
80
-
81
- // Focus the caption when we click to add one.
82
- const captionRef = (0, _element.useCallback)(node => {
83
- if (node && !caption) {
84
- node.focus();
85
- }
86
- }, [caption]);
87
- (0, _element.useEffect)(() => {
88
- if (!isSelected && !caption) {
89
- setShowCaption(false);
90
- }
91
- }, [isSelected, caption]);
92
68
  function toggleAttribute(attribute) {
93
69
  return newValue => {
94
70
  setAttributes({
@@ -168,20 +144,6 @@ function AudioEdit({
168
144
  }));
169
145
  }
170
146
  return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_blockEditor.BlockControls, {
171
- group: "block"
172
- }, (0, _react.createElement)(_components.ToolbarButton, {
173
- onClick: () => {
174
- setShowCaption(!showCaption);
175
- if (showCaption && caption) {
176
- setAttributes({
177
- caption: undefined
178
- });
179
- }
180
- },
181
- icon: _icons.caption,
182
- isPressed: showCaption,
183
- label: showCaption ? (0, _i18n.__)('Remove caption') : (0, _i18n.__)('Add caption')
184
- })), (0, _react.createElement)(_blockEditor.BlockControls, {
185
147
  group: "other"
186
148
  }, (0, _react.createElement)(_blockEditor.MediaReplaceFlow, {
187
149
  mediaId: id,
@@ -233,19 +195,12 @@ function AudioEdit({
233
195
  }, (0, _react.createElement)("audio", {
234
196
  controls: "controls",
235
197
  src: src
236
- })), isTemporaryAudio && (0, _react.createElement)(_components.Spinner, null), showCaption && (!_blockEditor.RichText.isEmpty(caption) || isSelected) && (0, _react.createElement)(_blockEditor.RichText, {
237
- identifier: "caption",
238
- tagName: "figcaption",
239
- className: (0, _blockEditor.__experimentalGetElementClassName)('caption'),
240
- ref: captionRef,
241
- "aria-label": (0, _i18n.__)('Audio caption text'),
242
- placeholder: (0, _i18n.__)('Add caption'),
243
- value: caption,
244
- onChange: value => setAttributes({
245
- caption: value
246
- }),
247
- inlineToolbar: true,
248
- __unstableOnSplitAtEnd: () => insertBlocksAfter((0, _blocks.createBlock)((0, _blocks.getDefaultBlockName)()))
198
+ })), isTemporaryAudio && (0, _react.createElement)(_components.Spinner, null), (0, _react.createElement)(_caption.Caption, {
199
+ attributes: attributes,
200
+ setAttributes: setAttributes,
201
+ isSelected: isSelected,
202
+ insertBlocksAfter: insertBlocksAfter,
203
+ label: (0, _i18n.__)('Audio caption text')
249
204
  })));
250
205
  }
251
206
  var _default = AudioEdit;
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_blob","_components","_blockEditor","_element","_i18n","_data","_icons","_blocks","_notices","_compose","_util","ALLOWED_MEDIA_TYPES","AudioEdit","attributes","className","setAttributes","onReplace","isSelected","insertBlocksAfter","id","autoplay","caption","loop","preload","src","prevCaption","usePrevious","showCaption","setShowCaption","useState","isTemporaryAudio","isBlobURL","mediaUpload","useSelect","select","getSettings","blockEditorStore","useEffect","file","getBlobByURL","filesList","onFileChange","media","onSelectAudio","onError","e","onUploadError","allowedTypes","captionRef","useCallback","node","focus","toggleAttribute","attribute","newValue","onSelectURL","newSrc","embedBlock","createUpgradedEmbedBlock","url","undefined","createErrorNotice","useDispatch","noticesStore","message","type","getAutoplayHelp","checked","__","classes","classnames","blockProps","useBlockProps","_react","createElement","MediaPlaceholder","icon","BlockIcon","onSelect","accept","value","Fragment","BlockControls","group","ToolbarButton","onClick","captionIcon","isPressed","label","MediaReplaceFlow","mediaId","mediaURL","InspectorControls","PanelBody","title","ToggleControl","__nextHasNoMarginBottom","onChange","help","SelectControl","_x","options","Disabled","isDisabled","controls","Spinner","RichText","isEmpty","identifier","tagName","__experimentalGetElementClassName","ref","placeholder","inlineToolbar","__unstableOnSplitAtEnd","createBlock","getDefaultBlockName","_default","exports","default"],"sources":["@wordpress/block-library/src/audio/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tDisabled,\n\tPanelBody,\n\tSelectControl,\n\tSpinner,\n\tToggleControl,\n\tToolbarButton,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { audio as icon, caption as captionIcon } from '@wordpress/icons';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tonReplace,\n\tisSelected,\n\tinsertBlocksAfter,\n} ) {\n\tconst { id, autoplay, caption, loop, preload, src } = attributes;\n\tconst prevCaption = usePrevious( caption );\n\tconst [ showCaption, setShowCaption ] = useState( !! caption );\n\tconst isTemporaryAudio = ! id && isBlobURL( src );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! id && isBlobURL( src ) ) {\n\t\t\tconst file = getBlobByURL( src );\n\n\t\t\tif ( file ) {\n\t\t\t\tmediaUpload( {\n\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\tonFileChange: ( [ media ] ) => onSelectAudio( media ),\n\t\t\t\t\tonError: ( e ) => onUploadError( e ),\n\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\t// We need to show the caption when changes come from\n\t// history navigation(undo/redo).\n\tuseEffect( () => {\n\t\tif ( caption && ! prevCaption ) {\n\t\t\tsetShowCaption( true );\n\t\t}\n\t}, [ caption, prevCaption ] );\n\n\t// Focus the caption when we click to add one.\n\tconst captionRef = useCallback(\n\t\t( node ) => {\n\t\t\tif ( node && ! caption ) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t},\n\t\t[ caption ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected && ! caption ) {\n\t\t\tsetShowCaption( false );\n\t\t}\n\t}, [ isSelected, caption ] );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\t// Set the block's src from the edit component's state, and switch off\n\t\t// the editing UI.\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t}\n\t}\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\tfunction getAutoplayHelp( checked ) {\n\t\treturn checked\n\t\t\t? __( 'Autoplay may cause usability issues for some users.' )\n\t\t\t: null;\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( {\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tcaption: media.caption,\n\t\t} );\n\t}\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': isTemporaryAudio,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCaption( ! showCaption );\n\t\t\t\t\t\tif ( showCaption && caption ) {\n\t\t\t\t\t\t\tsetAttributes( { caption: undefined } );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\ticon={ captionIcon }\n\t\t\t\t\tisPressed={ showCaption }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCaption\n\t\t\t\t\t\t\t? __( 'Remove caption' )\n\t\t\t\t\t\t\t: __( 'Add caption' )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\thelp={ getAutoplayHelp }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t/>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ _x( 'Preload', 'noun; Audio block parameter' ) }\n\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\tlabel: _x( 'None', 'Preload value' ),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n\t\t\t\t\tDisable the audio tag if the block is not selected\n\t\t\t\t\tso the user clicking on it won't play the\n\t\t\t\t\tfile or change the position slider when the controls are enabled.\n\t\t\t\t*/ }\n\t\t\t\t<Disabled isDisabled={ ! isSelected }>\n\t\t\t\t\t<audio controls=\"controls\" src={ src } />\n\t\t\t\t</Disabled>\n\t\t\t\t{ isTemporaryAudio && <Spinner /> }\n\t\t\t\t{ showCaption &&\n\t\t\t\t\t( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\tidentifier=\"caption\"\n\t\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\t\tclassName={ __experimentalGetElementClassName(\n\t\t\t\t\t\t\t\t'caption'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tref={ captionRef }\n\t\t\t\t\t\t\taria-label={ __( 'Audio caption text' ) }\n\t\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default AudioEdit;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAQA,IAAAG,YAAA,GAAAH,OAAA;AAWA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAA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AAAC,aAAA;IAAA,GAAaH;EAAU,GAMtB,IAAAE,MAAA,CAAAC,aAAA,EAACzE,WAAA,CAAAqG,QAAQ;IAACC,UAAU,EAAG,CAAEtF;EAAY,GACpC,IAAAwD,MAAA,CAAAC,aAAA;IAAO8B,QAAQ,EAAC,UAAU;IAAChF,GAAG,EAAGA;EAAK,CAAE,CAC/B,CAAC,EACTM,gBAAgB,IAAI,IAAA2C,MAAA,CAAAC,aAAA,EAACzE,WAAA,CAAAwG,OAAO,MAAE,CAAC,EAC/B9E,WAAW,KACV,CAAE+E,qBAAQ,CAACC,OAAO,CAAEtF,OAAQ,CAAC,IAAIJ,UAAU,CAAE,IAC9C,IAAAwD,MAAA,CAAAC,aAAA,EAACxE,YAAA,CAAAwG,QAAQ;IACRE,UAAU,EAAC,SAAS;IACpBC,OAAO,EAAC,YAAY;IACpB/F,SAAS,EAAG,IAAAgG,8CAAiC,EAC5C,SACD,CAAG;IACHC,GAAG,EAAG/D,UAAY;IAClB,cAAa,IAAAoB,QAAE,EAAE,oBAAqB,CAAG;IACzC4C,WAAW,EAAG,IAAA5C,QAAE,EAAE,aAAc,CAAG;IACnCY,KAAK,EAAG3D,OAAS;IACjB4E,QAAQ,EAAKjB,KAAK,IACjBjE,aAAa,CAAE;MAAEM,OAAO,EAAE2D;IAAM,CAAE,CAClC;IACDiC,aAAa;IACbC,sBAAsB,EAAGA,CAAA,KACxBhG,iBAAiB,CAChB,IAAAiG,mBAAW,EAAE,IAAAC,2BAAmB,EAAC,CAAE,CACpC;EACA,CACD,CAEI,CACP,CAAC;AAEL;AAAC,IAAAC,QAAA,GAEczG,SAAS;AAAA0G,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_blob","_components","_blockEditor","_element","_i18n","_data","_icons","_notices","_util","_caption","ALLOWED_MEDIA_TYPES","AudioEdit","attributes","className","setAttributes","onReplace","isSelected","insertBlocksAfter","id","autoplay","loop","preload","src","isTemporaryAudio","isBlobURL","mediaUpload","useSelect","select","getSettings","blockEditorStore","useEffect","file","getBlobByURL","filesList","onFileChange","media","onSelectAudio","onError","e","onUploadError","allowedTypes","toggleAttribute","attribute","newValue","onSelectURL","newSrc","embedBlock","createUpgradedEmbedBlock","url","undefined","createErrorNotice","useDispatch","noticesStore","message","type","getAutoplayHelp","checked","__","caption","classes","classnames","blockProps","useBlockProps","_react","createElement","MediaPlaceholder","icon","BlockIcon","onSelect","accept","value","Fragment","BlockControls","group","MediaReplaceFlow","mediaId","mediaURL","InspectorControls","PanelBody","title","ToggleControl","__nextHasNoMarginBottom","label","onChange","help","SelectControl","_x","options","Disabled","isDisabled","controls","Spinner","Caption","_default","exports","default"],"sources":["@wordpress/block-library/src/audio/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tDisabled,\n\tPanelBody,\n\tSelectControl,\n\tSpinner,\n\tToggleControl,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { audio as icon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport { Caption } from '../utils/caption';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tonReplace,\n\tisSelected,\n\tinsertBlocksAfter,\n} ) {\n\tconst { id, autoplay, loop, preload, src } = attributes;\n\tconst isTemporaryAudio = ! id && isBlobURL( src );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! id && isBlobURL( src ) ) {\n\t\t\tconst file = getBlobByURL( src );\n\n\t\t\tif ( file ) {\n\t\t\t\tmediaUpload( {\n\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\tonFileChange: ( [ media ] ) => onSelectAudio( media ),\n\t\t\t\t\tonError: ( e ) => onUploadError( e ),\n\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\t// Set the block's src from the edit component's state, and switch off\n\t\t// the editing UI.\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t}\n\t}\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\tfunction getAutoplayHelp( checked ) {\n\t\treturn checked\n\t\t\t? __( 'Autoplay may cause usability issues for some users.' )\n\t\t\t: null;\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( {\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tcaption: media.caption,\n\t\t} );\n\t}\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': isTemporaryAudio,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\thelp={ getAutoplayHelp }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t/>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ _x( 'Preload', 'noun; Audio block parameter' ) }\n\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\tlabel: _x( 'None', 'Preload value' ),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n\t\t\t\t\tDisable the audio tag if the block is not selected\n\t\t\t\t\tso the user clicking on it won't play the\n\t\t\t\t\tfile or change the position slider when the controls are enabled.\n\t\t\t\t*/ }\n\t\t\t\t<Disabled isDisabled={ ! isSelected }>\n\t\t\t\t\t<audio controls=\"controls\" src={ src } />\n\t\t\t\t</Disabled>\n\t\t\t\t{ isTemporaryAudio && <Spinner /> }\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocks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,KAAK,EAAE,MAAM;MAAEY,KAAK,EAAE,IAAAzB,QAAE,EAAE,MAAO;IAAE,CAAC,EACtC;MAAEa,KAAK,EAAE,UAAU;MAAEY,KAAK,EAAE,IAAAzB,QAAE,EAAE,UAAW;IAAE,CAAC,EAC9C;MACCa,KAAK,EAAE,MAAM;MACbY,KAAK,EAAE,IAAAI,QAAE,EAAE,MAAM,EAAE,eAAgB;IACpC,CAAC;EACC,CACH,CACS,CACO,CAAC,EACpB,IAAAvB,MAAA,CAAAC,aAAA;IAAA,GAAaH;EAAU,GAMtB,IAAAE,MAAA,CAAAC,aAAA,EAAC/D,WAAA,CAAAuF,QAAQ;IAACC,UAAU,EAAG,CAAEzE;EAAY,GACpC,IAAA+C,MAAA,CAAAC,aAAA;IAAO0B,QAAQ,EAAC,UAAU;IAACpE,GAAG,EAAGA;EAAK,CAAE,CAC/B,CAAC,EACTC,gBAAgB,IAAI,IAAAwC,MAAA,CAAAC,aAAA,EAAC/D,WAAA,CAAA0F,OAAO,MAAE,CAAC,EACjC,IAAA5B,MAAA,CAAAC,aAAA,EAACvD,QAAA,CAAAmF,OAAO;IACPhF,UAAU,EAAGA,UAAY;IACzBE,aAAa,EAAGA,aAAe;IAC/BE,UAAU,EAAGA,UAAY;IACzBC,iBAAiB,EAAGA,iBAAmB;IACvCiE,KAAK,EAAG,IAAAzB,QAAE,EAAE,oBAAqB;EAAG,CACpC,CACM,CACP,CAAC;AAEL;AAAC,IAAAoC,QAAA,GAEclF,SAAS;AAAAmF,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -202,7 +202,7 @@ function AudioEdit({
202
202
  }
203
203
  }), (0, _react.createElement)(_blockEditor.BlockCaption, {
204
204
  accessible: true,
205
- accessibilityLabelCreator: caption => !caption ? /* translators: accessibility text. Empty Audio caption. */
205
+ accessibilityLabelCreator: caption => _blockEditor.RichText.isEmpty(caption) ? /* translators: accessibility text. Empty Audio caption. */
206
206
  (0, _i18n.__)('Audio caption. Empty') : (0, _i18n.sprintf)( /* translators: accessibility text. %s: Audio caption. */
207
207
  (0, _i18n.__)('Audio caption. %s'), caption),
208
208
  clientId: clientId,
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_primitives","_components","_blockEditor","_i18n","_icons","_element","_data","_notices","_url","_style","_interopRequireDefault","ALLOWED_MEDIA_TYPES","AudioEdit","attributes","setAttributes","isSelected","insertBlocksAfter","onFocus","onBlur","clientId","id","autoplay","loop","preload","src","isCaptionSelected","setIsCaptionSelected","useState","onFileChange","mediaId","mediaUrl","wasBlockJustInserted","useSelect","select","blockEditorStore","createErrorNotice","useDispatch","noticesStore","toggleAttribute","attribute","newValue","onSelectURL","newSrc","isURL","test","getProtocol","undefined","__","onSelectAudio","media","url","onAudioPress","onFocusCaption","_react","createElement","View","MediaPlaceholder","icon","BlockIcon","onSelect","accept","allowedTypes","value","autoOpenMediaUpload","getBlockControls","open","BlockControls","ToolbarGroup","ToolbarButton","title","replace","onClick","getBlockUI","getMediaOptions","MediaUploadProgress","onFinishMediaUploadWithSuccess","onMediaUploadStateReset","containerStyle","styles","progressContainer","progressBarStyle","progressBar","spinnerStyle","spinner","renderContent","isUploadInProgress","isUploadFailed","retryMessage","Fragment","AudioPlayer","TouchableWithoutFeedback","accessible","onPress","disabled","InspectorControls","PanelBody","ToggleControl","label","onChange","checked","help","SelectControl","_x","options","hideCancelButton","MediaUpload","isReplacingMedia","render","BlockCaption","accessibilityLabelCreator","caption","sprintf","_default","exports","default"],"sources":["@wordpress/block-library/src/audio/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { TouchableWithoutFeedback } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { View } from '@wordpress/primitives';\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\tToolbarButton,\n\tToolbarGroup,\n\tAudioPlayer,\n} from '@wordpress/components';\nimport {\n\tBlockCaption,\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadProgress,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { audio as icon, replace } from '@wordpress/icons';\nimport { useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { isURL, getProtocol } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonFocus,\n\tonBlur,\n\tclientId,\n} ) {\n\tconst { id, autoplay, loop, preload, src } = attributes;\n\n\tconst [ isCaptionSelected, setIsCaptionSelected ] = useState( false );\n\n\tconst onFileChange = ( { mediaId, mediaUrl } ) => {\n\t\tsetAttributes( { id: mediaId, src: mediaUrl } );\n\t};\n\n\tconst { wasBlockJustInserted } = useSelect( ( select ) => ( {\n\t\twasBlockJustInserted: select( blockEditorStore ).wasBlockJustInserted(\n\t\t\tclientId,\n\t\t\t'inserter_menu'\n\t\t),\n\t} ) );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\tif ( isURL( newSrc ) && /^https?:/.test( getProtocol( newSrc ) ) ) {\n\t\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t\t} else {\n\t\t\t\tcreateErrorNotice( __( 'Invalid URL. Audio file not found.' ) );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( { src: media.url, id: media.id } );\n\t}\n\n\tfunction onAudioPress() {\n\t\tsetIsCaptionSelected( false );\n\t}\n\n\tfunction onFocusCaption() {\n\t\tif ( ! isCaptionSelected ) {\n\t\t\tsetIsCaptionSelected( true );\n\t\t}\n\t}\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<View>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tautoOpenMediaUpload={ isSelected && wasBlockJustInserted }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\tfunction getBlockControls( open ) {\n\t\treturn (\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ttitle={ __( 'Replace audio' ) }\n\t\t\t\t\t\ticon={ replace }\n\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t);\n\t}\n\n\tfunction getBlockUI( open, getMediaOptions ) {\n\t\treturn (\n\t\t\t<MediaUploadProgress\n\t\t\t\tmediaId={ id }\n\t\t\t\tonFinishMediaUploadWithSuccess={ onFileChange }\n\t\t\t\tonMediaUploadStateReset={ onFileChange }\n\t\t\t\tcontainerStyle={ styles.progressContainer }\n\t\t\t\tprogressBarStyle={ styles.progressBar }\n\t\t\t\tspinnerStyle={ styles.spinner }\n\t\t\t\trenderContent={ ( {\n\t\t\t\t\tisUploadInProgress,\n\t\t\t\t\tisUploadFailed,\n\t\t\t\t\tretryMessage,\n\t\t\t\t} ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isCaptionSelected &&\n\t\t\t\t\t\t\t\t! isUploadInProgress &&\n\t\t\t\t\t\t\t\tgetBlockControls( open ) }\n\t\t\t\t\t\t\t{ getMediaOptions() }\n\t\t\t\t\t\t\t<AudioPlayer\n\t\t\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\t\t\tisUploadFailed={ isUploadFailed }\n\t\t\t\t\t\t\t\tretryMessage={ retryMessage }\n\t\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<TouchableWithoutFeedback\n\t\t\taccessible={ ! isSelected }\n\t\t\tonPress={ onAudioPress }\n\t\t\tdisabled={ ! isSelected }\n\t\t>\n\t\t\t<View>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Autoplay may cause usability issues for some users.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Preload',\n\t\t\t\t\t\t\t\t'noun; Audio block parameter'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\t\tlabel: _x( 'None', '\"Preload\" value' ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\thideCancelButton={ true }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t\t<MediaUpload\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tisReplacingMedia={ true }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\t\treturn getBlockUI( open, getMediaOptions );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t<BlockCaption\n\t\t\t\t\taccessible={ true }\n\t\t\t\t\taccessibilityLabelCreator={ ( caption ) =>\n\t\t\t\t\t\t! caption\n\t\t\t\t\t\t\t? /* translators: accessibility text. Empty Audio caption. */\n\t\t\t\t\t\t\t __( 'Audio caption. Empty' )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: accessibility text. %s: Audio caption. */\n\t\t\t\t\t\t\t\t\t__( 'Audio caption. %s' ),\n\t\t\t\t\t\t\t\t\tcaption\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisSelected={ isCaptionSelected }\n\t\t\t\t\tonFocus={ onFocusCaption }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n}\nexport default AudioEdit;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAQA,IAAAG,YAAA,GAAAH,OAAA;AAUA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,IAAA,GAAAT,OAAA;AAKA,IAAAU,MAAA,GAAAC,sBAAA,CAAAX,OAAA;AArCA;AACA;AACA;;AAGA;AACA;AACA;;AA2BA;AACA;AACA;;AAGA,MAAMY,mBAAmB,GAAG,CAAE,OAAO,CAAE;AAEvC,SAASC,SAASA,CAAE;EACnBC,UAAU;EACVC,aAAa;EACbC,UAAU;EACVC,iBAAiB;EACjBC,OAAO;EACPC,MAAM;EACNC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC,EAAE;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAI,CAAC,GAAGX,UAAU;EAEvD,MAAM,CAAEY,iBAAiB,EAAEC,oBAAoB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EAErE,MAAMC,YAAY,GAAGA,CAAE;IAAEC,OAAO;IAAEC;EAAS,CAAC,KAAM;IACjDhB,aAAa,CAAE;MAA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OAAOD,UAAU,CAAEP,IAAI,EAAEQ,eAAgB,CAAC;IAC3C;EAAG,CACH,CAAC,EACF,IAAApB,MAAA,CAAAC,aAAA,EAACpD,YAAA,CAAA0G,YAAY;IACZjB,UAAU,EAAG,IAAM;IACnBkB,yBAAyB,EAAKC,OAAO,IACpC,CAAEA,OAAO,GACN;IACA,IAAA/D,QAAE,EAAE,sBAAuB,CAAC,GAC5B,IAAAgE,aAAO,GACP;IACA,IAAAhE,QAAE,EAAE,mBAAoB,CAAC,EACzB+D,OACA,CACH;IACD3F,QAAQ,EAAGA,QAAU;IACrBJ,UAAU,EAAGU,iBAAmB;IAChCR,OAAO,EAAGmC,cAAgB;IAC1BlC,MAAM,EAAGA,MAAQ;IACjBF,iBAAiB,EAAGA;EAAmB,CACvC,CACI,CACmB,CAAC;AAE7B;AAAC,IAAAgG,QAAA,GACcpG,SAAS;AAAAqG,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_reactNative","require","_primitives","_components","_blockEditor","_i18n","_icons","_element","_data","_notices","_url","_style","_interopRequireDefault","ALLOWED_MEDIA_TYPES","AudioEdit","attributes","setAttributes","isSelected","insertBlocksAfter","onFocus","onBlur","clientId","id","autoplay","loop","preload","src","isCaptionSelected","setIsCaptionSelected","useState","onFileChange","mediaId","mediaUrl","wasBlockJustInserted","useSelect","select","blockEditorStore","createErrorNotice","useDispatch","noticesStore","toggleAttribute","attribute","newValue","onSelectURL","newSrc","isURL","test","getProtocol","undefined","__","onSelectAudio","media","url","onAudioPress","onFocusCaption","_react","createElement","View","MediaPlaceholder","icon","BlockIcon","onSelect","accept","allowedTypes","value","autoOpenMediaUpload","getBlockControls","open","BlockControls","ToolbarGroup","ToolbarButton","title","replace","onClick","getBlockUI","getMediaOptions","MediaUploadProgress","onFinishMediaUploadWithSuccess","onMediaUploadStateReset","containerStyle","styles","progressContainer","progressBarStyle","progressBar","spinnerStyle","spinner","renderContent","isUploadInProgress","isUploadFailed","retryMessage","Fragment","AudioPlayer","TouchableWithoutFeedback","accessible","onPress","disabled","InspectorControls","PanelBody","ToggleControl","label","onChange","checked","help","SelectControl","_x","options","hideCancelButton","MediaUpload","isReplacingMedia","render","BlockCaption","accessibilityLabelCreator","caption","RichText","isEmpty","sprintf","_default","exports","default"],"sources":["@wordpress/block-library/src/audio/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { TouchableWithoutFeedback } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { View } from '@wordpress/primitives';\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\tToolbarButton,\n\tToolbarGroup,\n\tAudioPlayer,\n} from '@wordpress/components';\nimport {\n\tBlockCaption,\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadProgress,\n\tRichText,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { audio as icon, replace } from '@wordpress/icons';\nimport { useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { isURL, getProtocol } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonFocus,\n\tonBlur,\n\tclientId,\n} ) {\n\tconst { id, autoplay, loop, preload, src } = attributes;\n\n\tconst [ isCaptionSelected, setIsCaptionSelected ] = useState( false );\n\n\tconst onFileChange = ( { mediaId, mediaUrl } ) => {\n\t\tsetAttributes( { id: mediaId, src: mediaUrl } );\n\t};\n\n\tconst { wasBlockJustInserted } = useSelect( ( select ) => ( {\n\t\twasBlockJustInserted: select( blockEditorStore ).wasBlockJustInserted(\n\t\t\tclientId,\n\t\t\t'inserter_menu'\n\t\t),\n\t} ) );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\tif ( isURL( newSrc ) && /^https?:/.test( getProtocol( newSrc ) ) ) {\n\t\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t\t} else {\n\t\t\t\tcreateErrorNotice( __( 'Invalid URL. Audio file not found.' ) );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( { src: media.url, id: media.id } );\n\t}\n\n\tfunction onAudioPress() {\n\t\tsetIsCaptionSelected( false );\n\t}\n\n\tfunction onFocusCaption() {\n\t\tif ( ! isCaptionSelected ) {\n\t\t\tsetIsCaptionSelected( true );\n\t\t}\n\t}\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<View>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tautoOpenMediaUpload={ isSelected && wasBlockJustInserted }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\tfunction getBlockControls( open ) {\n\t\treturn (\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ttitle={ __( 'Replace audio' ) }\n\t\t\t\t\t\ticon={ replace }\n\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t);\n\t}\n\n\tfunction getBlockUI( open, getMediaOptions ) {\n\t\treturn (\n\t\t\t<MediaUploadProgress\n\t\t\t\tmediaId={ id }\n\t\t\t\tonFinishMediaUploadWithSuccess={ onFileChange }\n\t\t\t\tonMediaUploadStateReset={ onFileChange }\n\t\t\t\tcontainerStyle={ styles.progressContainer }\n\t\t\t\tprogressBarStyle={ styles.progressBar }\n\t\t\t\tspinnerStyle={ styles.spinner }\n\t\t\t\trenderContent={ ( {\n\t\t\t\t\tisUploadInProgress,\n\t\t\t\t\tisUploadFailed,\n\t\t\t\t\tretryMessage,\n\t\t\t\t} ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isCaptionSelected &&\n\t\t\t\t\t\t\t\t! isUploadInProgress &&\n\t\t\t\t\t\t\t\tgetBlockControls( open ) }\n\t\t\t\t\t\t\t{ getMediaOptions() }\n\t\t\t\t\t\t\t<AudioPlayer\n\t\t\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\t\t\tisUploadFailed={ isUploadFailed }\n\t\t\t\t\t\t\t\tretryMessage={ retryMessage }\n\t\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<TouchableWithoutFeedback\n\t\t\taccessible={ ! isSelected }\n\t\t\tonPress={ onAudioPress }\n\t\t\tdisabled={ ! isSelected }\n\t\t>\n\t\t\t<View>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Autoplay may cause usability issues for some users.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Preload',\n\t\t\t\t\t\t\t\t'noun; Audio block parameter'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\t\tlabel: _x( 'None', '\"Preload\" value' ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\thideCancelButton={ true }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t\t<MediaUpload\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tisReplacingMedia={ true }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\t\treturn getBlockUI( open, getMediaOptions );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t<BlockCaption\n\t\t\t\t\taccessible={ true }\n\t\t\t\t\taccessibilityLabelCreator={ ( caption ) =>\n\t\t\t\t\t\tRichText.isEmpty( caption )\n\t\t\t\t\t\t\t? /* translators: accessibility text. Empty Audio caption. */\n\t\t\t\t\t\t\t __( 'Audio caption. Empty' )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: accessibility text. %s: Audio caption. */\n\t\t\t\t\t\t\t\t\t__( 'Audio caption. %s' ),\n\t\t\t\t\t\t\t\t\tcaption\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisSelected={ isCaptionSelected }\n\t\t\t\t\tonFocus={ onFocusCaption }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n}\nexport default AudioEdit;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAQA,IAAAG,YAAA,GAAAH,OAAA;AAWA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,IAAA,GAAAT,OAAA;AAKA,IAAAU,MAAA,GAAAC,sBAAA,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E,MAAO;IAAE,CAAC,EACtC;MAAEe,KAAK,EAAE,UAAU;MAAEmC,KAAK,EAAE,IAAAlD,QAAE,EAAE,UAAW;IAAE,CAAC,EAC9C;MACCe,KAAK,EAAE,MAAM;MACbmC,KAAK,EAAE,IAAAK,QAAE,EAAE,MAAM,EAAE,iBAAkB;IACtC,CAAC,CACC;IACHE,gBAAgB,EAAG;EAAM,CACzB,CACS,CACO,CAAC,EACpB,IAAAnD,MAAA,CAAAC,aAAA,EAACpD,YAAA,CAAAuG,WAAW;IACX5C,YAAY,EAAGlD,mBAAqB;IACpC+F,gBAAgB,EAAG,IAAM;IACzB/C,QAAQ,EAAGX,aAAe;IAC1BP,WAAW,EAAGA,WAAa;IAC3BkE,MAAM,EAAGA,CAAE;MAAE1C,IAAI;MAAEQ;IAAgB,CAAC,KAAM;MACzC,OAAOD,UAAU,CAAEP,IAAI,EAAEQ,eAAgB,CAAC;IAC3C;EAAG,CACH,CAAC,EACF,IAAApB,MAAA,CAAAC,aAAA,EAACpD,YAAA,CAAA0G,YAAY;IACZjB,UAAU,EAAG,IAAM;IACnBkB,yBAAyB,EAAKC,OAAO,IACpCC,qBAAQ,CAACC,OAAO,CAAEF,OAAQ,CAAC,GACxB;IACA,IAAA/D,QAAE,EAAE,sBAAuB,CAAC,GAC5B,IAAAkE,aAAO,GACP;IACA,IAAAlE,QAAE,EAAE,mBAAoB,CAAC,EACzB+D,OACA,CACH;IACD3F,QAAQ,EAAGA,QAAU;IACrBJ,UAAU,EAAGU,iBAAmB;IAChCR,OAAO,EAAGmC,cAAgB;IAC1BlC,MAAM,EAAGA,MAAQ;IACjBF,iBAAiB,EAAGA;EAAmB,CACvC,CACI,CACmB,CAAC;AAE7B;AAAC,IAAAkG,QAAA,GACctG,SAAS;AAAAuG,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -35,8 +35,8 @@ const metadata = {
35
35
  __experimentalRole: "content"
36
36
  },
37
37
  caption: {
38
- type: "string",
39
- source: "html",
38
+ type: "rich-text",
39
+ source: "rich-text",
40
40
  selector: "figcaption",
41
41
  __experimentalRole: "content"
42
42
  },
@@ -7,11 +7,13 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = ReusableBlockEdit;
8
8
  var _react = require("react");
9
9
  var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _data = require("@wordpress/data");
11
+ var _element = require("@wordpress/element");
10
12
  var _coreData = require("@wordpress/core-data");
11
13
  var _components = require("@wordpress/components");
12
14
  var _i18n = require("@wordpress/i18n");
13
15
  var _blockEditor = require("@wordpress/block-editor");
14
- var _element = require("@wordpress/element");
16
+ var _blocks = require("@wordpress/blocks");
15
17
  var _lockUnlock = require("../lock-unlock");
16
18
  /**
17
19
  * External dependencies
@@ -28,6 +30,12 @@ var _lockUnlock = require("../lock-unlock");
28
30
  const {
29
31
  useLayoutClasses
30
32
  } = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
33
+ function isPartiallySynced(block) {
34
+ return !!(0, _blocks.getBlockSupport)(block.name, '__experimentalConnections', false) && !!block.attributes.connections?.attributes && Object.values(block.attributes.connections.attributes).some(connection => connection.source === 'pattern_attributes');
35
+ }
36
+ function getPartiallySyncedAttributes(block) {
37
+ return Object.entries(block.attributes.connections.attributes).filter(([, connection]) => connection.source === 'pattern_attributes').map(([attributeKey]) => attributeKey);
38
+ }
31
39
  const fullAlignments = ['full', 'wide', 'left', 'right'];
32
40
  const useInferredLayout = (blocks, parentLayout) => {
33
41
  const initialInferredAlignmentRef = (0, _element.useRef)();
@@ -53,27 +61,90 @@ const useInferredLayout = (blocks, parentLayout) => {
53
61
  };
54
62
  }, [blocks, parentLayout]);
55
63
  };
64
+ function applyInitialOverrides(blocks, overrides = {}, defaultValues) {
65
+ return blocks.map(block => {
66
+ const innerBlocks = applyInitialOverrides(block.innerBlocks, overrides, defaultValues);
67
+ const blockId = block.attributes.metadata?.id;
68
+ if (!isPartiallySynced(block) || !blockId) return {
69
+ ...block,
70
+ innerBlocks
71
+ };
72
+ const attributes = getPartiallySyncedAttributes(block);
73
+ const newAttributes = {
74
+ ...block.attributes
75
+ };
76
+ for (const attributeKey of attributes) {
77
+ defaultValues[blockId] = block.attributes[attributeKey];
78
+ if (overrides[blockId]) {
79
+ newAttributes[attributeKey] = overrides[blockId];
80
+ }
81
+ }
82
+ return {
83
+ ...block,
84
+ attributes: newAttributes,
85
+ innerBlocks
86
+ };
87
+ });
88
+ }
89
+ function getOverridesFromBlocks(blocks, defaultValues) {
90
+ /** @type {Record<string, unknown>} */
91
+ const overrides = {};
92
+ for (const block of blocks) {
93
+ Object.assign(overrides, getOverridesFromBlocks(block.innerBlocks, defaultValues));
94
+ const blockId = block.attributes.metadata?.id;
95
+ if (!isPartiallySynced(block) || !blockId) continue;
96
+ const attributes = getPartiallySyncedAttributes(block);
97
+ for (const attributeKey of attributes) {
98
+ if (block.attributes[attributeKey] !== defaultValues[blockId]) {
99
+ overrides[blockId] = block.attributes[attributeKey];
100
+ }
101
+ }
102
+ }
103
+ return Object.keys(overrides).length > 0 ? overrides : undefined;
104
+ }
56
105
  function ReusableBlockEdit({
57
106
  name,
58
107
  attributes: {
59
- ref
108
+ ref,
109
+ overrides
60
110
  },
61
- __unstableParentLayout: parentLayout
111
+ __unstableParentLayout: parentLayout,
112
+ clientId: patternClientId
62
113
  }) {
114
+ const registry = (0, _data.useRegistry)();
63
115
  const hasAlreadyRendered = (0, _blockEditor.__experimentalUseHasRecursion)(ref);
64
116
  const {
65
117
  record,
66
118
  hasResolved
67
119
  } = (0, _coreData.useEntityRecord)('postType', 'wp_block', ref);
68
120
  const isMissing = hasResolved && !record;
69
- const [blocks, onInput, onChange] = (0, _coreData.useEntityBlockEditor)('postType', 'wp_block', {
70
- id: ref
71
- });
121
+ const initialOverrides = (0, _element.useRef)(overrides);
122
+ const defaultValuesRef = (0, _element.useRef)({});
123
+ const {
124
+ replaceInnerBlocks,
125
+ __unstableMarkNextChangeAsNotPersistent,
126
+ setBlockEditingMode
127
+ } = (0, _data.useDispatch)(_blockEditor.store);
128
+ const {
129
+ getBlockEditingMode
130
+ } = (0, _data.useSelect)(_blockEditor.store);
131
+ (0, _element.useEffect)(() => {
132
+ if (!record?.content?.raw) return;
133
+ const initialBlocks = (0, _blocks.parse)(record.content.raw);
134
+ const editingMode = getBlockEditingMode(patternClientId);
135
+ registry.batch(() => {
136
+ setBlockEditingMode(patternClientId, 'default');
137
+ __unstableMarkNextChangeAsNotPersistent();
138
+ replaceInnerBlocks(patternClientId, applyInitialOverrides(initialBlocks, initialOverrides.current, defaultValuesRef.current));
139
+ setBlockEditingMode(patternClientId, editingMode);
140
+ });
141
+ }, [__unstableMarkNextChangeAsNotPersistent, patternClientId, record, replaceInnerBlocks, registry, getBlockEditingMode, setBlockEditingMode]);
142
+ const innerBlocks = (0, _data.useSelect)(select => select(_blockEditor.store).getBlocks(patternClientId), [patternClientId]);
72
143
  const [title, setTitle] = (0, _coreData.useEntityProp)('postType', 'wp_block', 'title', ref);
73
144
  const {
74
145
  alignment,
75
146
  layout
76
- } = useInferredLayout(blocks, parentLayout);
147
+ } = useInferredLayout(innerBlocks, parentLayout);
77
148
  const layoutClasses = useLayoutClasses({
78
149
  layout
79
150
  }, name);
@@ -83,12 +154,32 @@ function ReusableBlockEdit({
83
154
  })
84
155
  });
85
156
  const innerBlocksProps = (0, _blockEditor.useInnerBlocksProps)(blockProps, {
86
- value: blocks,
87
157
  layout,
88
- onInput,
89
- onChange,
90
- renderAppender: blocks?.length ? undefined : _blockEditor.InnerBlocks.ButtonBlockAppender
158
+ renderAppender: innerBlocks?.length ? undefined : _blockEditor.InnerBlocks.ButtonBlockAppender
91
159
  });
160
+
161
+ // Sync the `overrides` attribute from the updated blocks.
162
+ // `syncDerivedBlockAttributes` is an action that just like `updateBlockAttributes`
163
+ // but won't create an undo level.
164
+ // This can be abstracted into a `useSyncDerivedAttributes` hook if needed.
165
+ (0, _element.useEffect)(() => {
166
+ const {
167
+ getBlocks
168
+ } = registry.select(_blockEditor.store);
169
+ const {
170
+ syncDerivedBlockAttributes
171
+ } = (0, _lockUnlock.unlock)(registry.dispatch(_blockEditor.store));
172
+ let prevBlocks = getBlocks(patternClientId);
173
+ return registry.subscribe(() => {
174
+ const blocks = getBlocks(patternClientId);
175
+ if (blocks !== prevBlocks) {
176
+ prevBlocks = blocks;
177
+ syncDerivedBlockAttributes(patternClientId, {
178
+ overrides: getOverridesFromBlocks(blocks, defaultValuesRef.current)
179
+ });
180
+ }
181
+ }, _blockEditor.store);
182
+ }, [patternClientId, registry]);
92
183
  let children = null;
93
184
  if (hasAlreadyRendered) {
94
185
  children = (0, _react.createElement)(_blockEditor.Warning, null, (0, _i18n.__)('Block cannot be rendered inside itself.'));
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_coreData","_components","_i18n","_blockEditor","_element","_lockUnlock","useLayoutClasses","unlock","blockEditorPrivateApis","fullAlignments","useInferredLayout","blocks","parentLayout","initialInferredAlignmentRef","useRef","useMemo","length","alignment","current","undefined","isConstrained","type","hasFullAlignment","some","block","includes","attributes","align","layout","ReusableBlockEdit","name","ref","__unstableParentLayout","hasAlreadyRendered","useHasRecursion","record","hasResolved","useEntityRecord","isMissing","onInput","onChange","useEntityBlockEditor","id","title","setTitle","useEntityProp","layoutClasses","blockProps","useBlockProps","className","classnames","innerBlocksProps","useInnerBlocksProps","value","renderAppender","InnerBlocks","ButtonBlockAppender","children","_react","createElement","Warning","__","Placeholder","Spinner","__experimentalRecursionProvider","uniqueId","InspectorControls","PanelBody","TextControl","label","__nextHasNoMarginBottom","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/block/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseEntityBlockEditor,\n\tuseEntityProp,\n\tuseEntityRecord,\n} from '@wordpress/core-data';\nimport {\n\tPlaceholder,\n\tSpinner,\n\tTextControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseInnerBlocksProps,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tInnerBlocks,\n\tInspectorControls,\n\tuseBlockProps,\n\tWarning,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useRef, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { useLayoutClasses } = unlock( blockEditorPrivateApis );\nconst fullAlignments = [ 'full', 'wide', 'left', 'right' ];\n\nconst useInferredLayout = ( blocks, parentLayout ) => {\n\tconst initialInferredAlignmentRef = useRef();\n\n\treturn useMemo( () => {\n\t\t// Exit early if the pattern's blocks haven't loaded yet.\n\t\tif ( ! blocks?.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet alignment = initialInferredAlignmentRef.current;\n\n\t\t// Only track the initial alignment so that temporarily removed\n\t\t// alignments can be reapplied.\n\t\tif ( alignment === undefined ) {\n\t\t\tconst isConstrained = parentLayout?.type === 'constrained';\n\t\t\tconst hasFullAlignment = blocks.some( ( block ) =>\n\t\t\t\tfullAlignments.includes( block.attributes.align )\n\t\t\t);\n\n\t\t\talignment = isConstrained && hasFullAlignment ? 'full' : null;\n\t\t\tinitialInferredAlignmentRef.current = alignment;\n\t\t}\n\n\t\tconst layout = alignment ? parentLayout : undefined;\n\n\t\treturn { alignment, layout };\n\t}, [ blocks, parentLayout ] );\n};\n\nexport default function ReusableBlockEdit( {\n\tname,\n\tattributes: { ref },\n\t__unstableParentLayout: parentLayout,\n} ) {\n\tconst hasAlreadyRendered = useHasRecursion( ref );\n\tconst { record, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_block',\n\t\tref\n\t);\n\tconst isMissing = hasResolved && ! record;\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_block',\n\t\t{ id: ref }\n\t);\n\n\tconst [ title, setTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_block',\n\t\t'title',\n\t\tref\n\t);\n\n\tconst { alignment, layout } = useInferredLayout( blocks, parentLayout );\n\tconst layoutClasses = useLayoutClasses( { layout }, name );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames(\n\t\t\t'block-library-block__reusable-block-container',\n\t\t\tlayout && layoutClasses,\n\t\t\t{ [ `align${ alignment }` ]: alignment }\n\t\t),\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tvalue: blocks,\n\t\tlayout,\n\t\tonInput,\n\t\tonChange,\n\t\trenderAppender: blocks?.length\n\t\t\t? undefined\n\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t} );\n\n\tlet children = null;\n\tif ( hasAlreadyRendered ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( isMissing ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block has been deleted or is unavailable.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( ! hasResolved ) {\n\t\tchildren = (\n\t\t\t<Placeholder>\n\t\t\t\t<Spinner />\n\t\t\t</Placeholder>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ ref }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ children === null ? (\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t) : (\n\t\t\t\t<div { ...blockProps }>{ children }</div>\n\t\t\t) }\n\t\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Default","require","_data","_element","_coreData","_components","_i18n","_blockEditor","_blocks","_lockUnlock","useLayoutClasses","unlock","blockEditorPrivateApis","isPartiallySynced","block","getBlockSupport","name","attributes","connections","Object","values","some","connection","source","getPartiallySyncedAttributes","entries","filter","map","attributeKey","fullAlignments","useInferredLayout","blocks","parentLayout","initialInferredAlignmentRef","useRef","useMemo","length","alignment","current","undefined","isConstrained","type","hasFullAlignment","includes","align","layout","applyInitialOverrides","overrides","defaultValues","innerBlocks","blockId","metadata","id","newAttributes","getOverridesFromBlocks","assign","keys","ReusableBlockEdit","ref","__unstableParentLayout","clientId","patternClientId","registry","useRegistry","hasAlreadyRendered","useHasRecursion","record","hasResolved","useEntityRecord","isMissing","initialOverrides","defaultValuesRef","replaceInnerBlocks","__unstableMarkNextChangeAsNotPersistent","setBlockEditingMode","useDispatch","blockEditorStore","getBlockEditingMode","useSelect","useEffect","content","raw","initialBlocks","parse","editingMode","batch","select","getBlocks","title","setTitle","useEntityProp","layoutClasses","blockProps","useBlockProps","className","classnames","innerBlocksProps","useInnerBlocksProps","renderAppender","InnerBlocks","ButtonBlockAppender","syncDerivedBlockAttributes","dispatch","prevBlocks","subscribe","children","_react","createElement","Warning","__","Placeholder","Spinner","__experimentalRecursionProvider","uniqueId","InspectorControls","PanelBody","TextControl","label","value","onChange","__nextHasNoMarginBottom","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/block/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect, useDispatch } from '@wordpress/data';\nimport { useRef, useMemo, useEffect } from '@wordpress/element';\nimport { useEntityProp, useEntityRecord } from '@wordpress/core-data';\nimport {\n\tPlaceholder,\n\tSpinner,\n\tTextControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseInnerBlocksProps,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tInnerBlocks,\n\tInspectorControls,\n\tuseBlockProps,\n\tWarning,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { getBlockSupport, parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { useLayoutClasses } = unlock( blockEditorPrivateApis );\n\nfunction isPartiallySynced( block ) {\n\treturn (\n\t\t!! getBlockSupport( block.name, '__experimentalConnections', false ) &&\n\t\t!! block.attributes.connections?.attributes &&\n\t\tObject.values( block.attributes.connections.attributes ).some(\n\t\t\t( connection ) => connection.source === 'pattern_attributes'\n\t\t)\n\t);\n}\nfunction getPartiallySyncedAttributes( block ) {\n\treturn Object.entries( block.attributes.connections.attributes )\n\t\t.filter(\n\t\t\t( [ , connection ] ) => connection.source === 'pattern_attributes'\n\t\t)\n\t\t.map( ( [ attributeKey ] ) => attributeKey );\n}\n\nconst fullAlignments = [ 'full', 'wide', 'left', 'right' ];\n\nconst useInferredLayout = ( blocks, parentLayout ) => {\n\tconst initialInferredAlignmentRef = useRef();\n\n\treturn useMemo( () => {\n\t\t// Exit early if the pattern's blocks haven't loaded yet.\n\t\tif ( ! blocks?.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet alignment = initialInferredAlignmentRef.current;\n\n\t\t// Only track the initial alignment so that temporarily removed\n\t\t// alignments can be reapplied.\n\t\tif ( alignment === undefined ) {\n\t\t\tconst isConstrained = parentLayout?.type === 'constrained';\n\t\t\tconst hasFullAlignment = blocks.some( ( block ) =>\n\t\t\t\tfullAlignments.includes( block.attributes.align )\n\t\t\t);\n\n\t\t\talignment = isConstrained && hasFullAlignment ? 'full' : null;\n\t\t\tinitialInferredAlignmentRef.current = alignment;\n\t\t}\n\n\t\tconst layout = alignment ? parentLayout : undefined;\n\n\t\treturn { alignment, layout };\n\t}, [ blocks, parentLayout ] );\n};\n\nfunction applyInitialOverrides( blocks, overrides = {}, defaultValues ) {\n\treturn blocks.map( ( block ) => {\n\t\tconst innerBlocks = applyInitialOverrides(\n\t\t\tblock.innerBlocks,\n\t\t\toverrides,\n\t\t\tdefaultValues\n\t\t);\n\t\tconst blockId = block.attributes.metadata?.id;\n\t\tif ( ! isPartiallySynced( block ) || ! blockId )\n\t\t\treturn { ...block, innerBlocks };\n\t\tconst attributes = getPartiallySyncedAttributes( block );\n\t\tconst newAttributes = { ...block.attributes };\n\t\tfor ( const attributeKey of attributes ) {\n\t\t\tdefaultValues[ blockId ] = block.attributes[ attributeKey ];\n\t\t\tif ( overrides[ blockId ] ) {\n\t\t\t\tnewAttributes[ attributeKey ] = overrides[ blockId ];\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t...block,\n\t\t\tattributes: newAttributes,\n\t\t\tinnerBlocks,\n\t\t};\n\t} );\n}\n\nfunction getOverridesFromBlocks( blocks, defaultValues ) {\n\t/** @type {Record<string, unknown>} */\n\tconst overrides = {};\n\tfor ( const block of blocks ) {\n\t\tObject.assign(\n\t\t\toverrides,\n\t\t\tgetOverridesFromBlocks( block.innerBlocks, defaultValues )\n\t\t);\n\t\tconst blockId = block.attributes.metadata?.id;\n\t\tif ( ! isPartiallySynced( block ) || ! blockId ) continue;\n\t\tconst attributes = getPartiallySyncedAttributes( block );\n\t\tfor ( const attributeKey of attributes ) {\n\t\t\tif (\n\t\t\t\tblock.attributes[ attributeKey ] !== defaultValues[ blockId ]\n\t\t\t) {\n\t\t\t\toverrides[ blockId ] = block.attributes[ attributeKey ];\n\t\t\t}\n\t\t}\n\t}\n\treturn Object.keys( overrides ).length > 0 ? overrides : undefined;\n}\n\nexport default function ReusableBlockEdit( {\n\tname,\n\tattributes: { ref, overrides },\n\t__unstableParentLayout: parentLayout,\n\tclientId: patternClientId,\n} ) {\n\tconst registry = useRegistry();\n\tconst hasAlreadyRendered = useHasRecursion( ref );\n\tconst { record, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_block',\n\t\tref\n\t);\n\tconst isMissing = hasResolved && ! record;\n\tconst initialOverrides = useRef( overrides );\n\tconst defaultValuesRef = useRef( {} );\n\tconst {\n\t\treplaceInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tsetBlockEditingMode,\n\t} = useDispatch( blockEditorStore );\n\tconst { getBlockEditingMode } = useSelect( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( ! record?.content?.raw ) return;\n\t\tconst initialBlocks = parse( record.content.raw );\n\n\t\tconst editingMode = getBlockEditingMode( patternClientId );\n\t\tregistry.batch( () => {\n\t\t\tsetBlockEditingMode( patternClientId, 'default' );\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\treplaceInnerBlocks(\n\t\t\t\tpatternClientId,\n\t\t\t\tapplyInitialOverrides(\n\t\t\t\t\tinitialBlocks,\n\t\t\t\t\tinitialOverrides.current,\n\t\t\t\t\tdefaultValuesRef.current\n\t\t\t\t)\n\t\t\t);\n\t\t\tsetBlockEditingMode( patternClientId, editingMode );\n\t\t} );\n\t}, [\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tpatternClientId,\n\t\trecord,\n\t\treplaceInnerBlocks,\n\t\tregistry,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t] );\n\n\tconst innerBlocks = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlocks( patternClientId ),\n\t\t[ patternClientId ]\n\t);\n\n\tconst [ title, setTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_block',\n\t\t'title',\n\t\tref\n\t);\n\n\tconst { alignment, layout } = useInferredLayout(\n\t\tinnerBlocks,\n\t\tparentLayout\n\t);\n\tconst layoutClasses = useLayoutClasses( { layout }, name );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames(\n\t\t\t'block-library-block__reusable-block-container',\n\t\t\tlayout && layoutClasses,\n\t\t\t{ [ `align${ alignment }` ]: alignment }\n\t\t),\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tlayout,\n\t\trenderAppender: innerBlocks?.length\n\t\t\t? undefined\n\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t} );\n\n\t// Sync the `overrides` attribute from the updated blocks.\n\t// `syncDerivedBlockAttributes` is an action that just like `updateBlockAttributes`\n\t// but won't create an undo level.\n\t// This can be abstracted into a `useSyncDerivedAttributes` hook if needed.\n\tuseEffect( () => {\n\t\tconst { getBlocks } = registry.select( blockEditorStore );\n\t\tconst { syncDerivedBlockAttributes } = unlock(\n\t\t\tregistry.dispatch( blockEditorStore )\n\t\t);\n\t\tlet prevBlocks = getBlocks( patternClientId );\n\t\treturn registry.subscribe( () => {\n\t\t\tconst blocks = getBlocks( patternClientId );\n\t\t\tif ( blocks !== prevBlocks ) {\n\t\t\t\tprevBlocks = blocks;\n\t\t\t\tsyncDerivedBlockAttributes( patternClientId, {\n\t\t\t\t\toverrides: getOverridesFromBlocks(\n\t\t\t\t\t\tblocks,\n\t\t\t\t\t\tdefaultValuesRef.current\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t}\n\t\t}, blockEditorStore );\n\t}, [ patternClientId, registry ] );\n\n\tlet children = null;\n\n\tif ( hasAlreadyRendered ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( isMissing ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block has been deleted or is unavailable.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( ! hasResolved ) {\n\t\tchildren = (\n\t\t\t<Placeholder>\n\t\t\t\t<Spinner />\n\t\t\t</Placeholder>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ ref }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ children === null ? (\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t) : (\n\t\t\t\t<div { ...blockProps }>{ children }</div>\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAWA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,WAAA,GAAAR,OAAA;AAlCA;AACA;AACA;;AAGA;AACA;AACA;;AAwBA;AACA;AACA;;AAGA,MAAM;EAAES;AAAiB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAE7D,SAASC,iBAAiBA,CAAEC,KAAK,EAAG;EACnC,OACC,CAAC,CAAE,IAAAC,uBAAe,EAAED,KAAK,CAACE,IAAI,EAAE,2BAA2B,EAAE,KAAM,CAAC,IACpE,CAAC,CAAEF,KAAK,CAACG,UAAU,CAACC,WAAW,EAAED,UAAU,IAC3CE,MAAM,CAACC,MAAM,CAAEN,KAAK,CAACG,UAAU,CAACC,WAAW,CAACD,UAAW,CAAC,CAACI,IAAI,CAC1DC,UAAU,IAAMA,UAAU,CAACC,MAAM,KAAK,oBACzC,CAAC;AAEH;AACA,SAASC,4BAA4BA,CAAEV,KAAK,EAAG;EAC9C,OAAOK,MAAM,CAACM,OAAO,CAAEX,KAAK,CAACG,UAAU,CAACC,WAAW,CAACD,UAAW,CAAC,CAC9DS,MAAM,CACN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G,WAAA,CAAA0G,OAAO,MAAE,CACE,CACb;EACF;EAEA,OACC,IAAAL,MAAA,CAAAC,aAAA,EAACpG,YAAA,CAAAyG,+BAAiB;IAACC,QAAQ,EAAGvD;EAAK,GAClC,IAAAgD,MAAA,CAAAC,aAAA,EAACpG,YAAA,CAAA2G,iBAAiB,QACjB,IAAAR,MAAA,CAAAC,aAAA,EAACtG,WAAA,CAAA8G,SAAS,QACT,IAAAT,MAAA,CAAAC,aAAA,EAACtG,WAAA,CAAA+G,WAAW;IACXC,KAAK,EAAG,IAAAR,QAAE,EAAE,MAAO,CAAG;IACtBS,KAAK,EAAG9B,KAAO;IACf+B,QAAQ,EAAG9B,QAAU;IACrB+B,uBAAuB;IACvBC,qBAAqB;EAAA,CACrB,CACS,CACO,CAAC,EAClBhB,QAAQ,KAAK,IAAI,GAClB,IAAAC,MAAA,CAAAC,aAAA;IAAA,GAAUX;EAAgB,CAAI,CAAC,GAE/B,IAAAU,MAAA,CAAAC,aAAA;IAAA,GAAUf;EAAU,GAAKa,QAAe,CAEvB,CAAC;AAEtB"}
@@ -7,7 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.settings = exports.name = exports.metadata = exports.init = void 0;
8
8
  var _icons = require("@wordpress/icons");
9
9
  var _initBlock = _interopRequireDefault(require("../utils/init-block"));
10
- var _edit = _interopRequireDefault(require("./edit"));
10
+ var _edit = _interopRequireDefault(require("./v1/edit"));
11
+ var _edit2 = _interopRequireDefault(require("./edit"));
11
12
  /**
12
13
  * WordPress dependencies
13
14
  */
@@ -41,7 +42,7 @@ const {
41
42
  } = metadata;
42
43
  exports.name = name;
43
44
  const settings = {
44
- edit: _edit.default,
45
+ edit: window.__experimentalPatternPartialSyncing ? _edit2.default : _edit.default,
45
46
  icon: _icons.symbol
46
47
  };
47
48
  exports.settings = settings;
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_initBlock","_interopRequireDefault","_edit","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","ref","type","supports","customClassName","html","inserter","renaming","exports","settings","edit","icon","init","initBlock"],"sources":["@wordpress/block-library/src/block/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { symbol as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\tedit,\n\ticon,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;AAGA;AACA;AACA;AAFA,MAAAI,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,GAAA;MAAAC,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,eAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,QAAA;EAAA;AAAA;AAAAC,OAAA,CAAAjB,QAAA,GAAAA,QAAA;AAOA,MAAM;EAAEG;AAAK,CAAC,GAAGH,QAAQ;AAACiB,OAAA,CAAAd,IAAA,GAAAA,IAAA;AAInB,MAAMe,QAAQ,GAAG;EACvBC,IAAI,EAAJA,aAAI;EACJC,IAAI,EAAJA;AACD,CAAC;AAACH,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMG,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAEnB,IAAI;EAAEH,QAAQ;EAAEkB;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAI,IAAA,GAAAA,IAAA"}
1
+ {"version":3,"names":["_icons","require","_initBlock","_interopRequireDefault","_edit","_edit2","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","ref","type","supports","customClassName","html","inserter","renaming","exports","settings","edit","window","__experimentalPatternPartialSyncing","editV2","editV1","icon","init","initBlock"],"sources":["@wordpress/block-library/src/block/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { symbol as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport editV1 from './v1/edit';\nimport editV2 from './edit';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\tedit: window.__experimentalPatternPartialSyncing ? editV2 : editV1,\n\ticon,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,MAAA,GAAAF,sBAAA,CAAAF,OAAA;AAXA;AACA;AACA;AAGA;AACA;AACA;AAFA,MAAAK,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,GAAA;MAAAC,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,eAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,QAAA;EAAA;AAAA;AAAAC,OAAA,CAAAjB,QAAA,GAAAA,QAAA;AAQA,MAAM;EAAEG;AAAK,CAAC,GAAGH,QAAQ;AAACiB,OAAA,CAAAd,IAAA,GAAAA,IAAA;AAInB,MAAMe,QAAQ,GAAG;EACvBC,IAAI,EAAEC,MAAM,CAACC,mCAAmC,GAAGC,cAAM,GAAGC,aAAM;EAClEC,IAAI,EAAJA;AACD,CAAC;AAACP,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMO,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAEvB,IAAI;EAAEH,QAAQ;EAAEkB;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAQ,IAAA,GAAAA,IAAA"}