@wordpress/block-library 8.7.0 → 8.9.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 (416) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/column/index.js +2 -1
  3. package/build/column/index.js.map +1 -1
  4. package/build/columns/edit.js +24 -6
  5. package/build/columns/edit.js.map +1 -1
  6. package/build/columns/index.js +2 -1
  7. package/build/columns/index.js.map +1 -1
  8. package/build/columns/utils.js +4 -9
  9. package/build/columns/utils.js.map +1 -1
  10. package/build/cover/edit/index.js +46 -50
  11. package/build/cover/edit/index.js.map +1 -1
  12. package/build/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +32 -6
  13. package/build/cover/edit/resizable-cover-popover.js.map +1 -0
  14. package/build/cover/index.js +12 -0
  15. package/build/cover/index.js.map +1 -1
  16. package/build/cover/transforms.js +10 -7
  17. package/build/cover/transforms.js.map +1 -1
  18. package/build/details/edit.js +67 -0
  19. package/build/details/edit.js.map +1 -0
  20. package/build/details/index.js +110 -0
  21. package/build/details/index.js.map +1 -0
  22. package/build/details/save.js +33 -0
  23. package/build/details/save.js.map +1 -0
  24. package/build/details-content/edit.js +34 -0
  25. package/build/details-content/edit.js.map +1 -0
  26. package/build/details-content/index.js +94 -0
  27. package/build/details-content/index.js.map +1 -0
  28. package/build/details-content/save.js +20 -0
  29. package/build/details-content/save.js.map +1 -0
  30. package/build/details-summary/edit.js +42 -0
  31. package/build/details-summary/edit.js.map +1 -0
  32. package/build/details-summary/index.js +97 -0
  33. package/build/details-summary/index.js.map +1 -0
  34. package/build/details-summary/save.js +24 -0
  35. package/build/details-summary/save.js.map +1 -0
  36. package/build/embed/deprecated.js +4 -1
  37. package/build/embed/deprecated.js.map +1 -1
  38. package/build/embed/embed-link-settings.native.js +1 -1
  39. package/build/embed/embed-link-settings.native.js.map +1 -1
  40. package/build/embed/embed-placeholder.js +1 -1
  41. package/build/embed/embed-placeholder.js.map +1 -1
  42. package/build/embed/index.js +4 -1
  43. package/build/embed/index.js.map +1 -1
  44. package/build/embed/transforms.js +4 -1
  45. package/build/embed/transforms.js.map +1 -1
  46. package/build/embed/util.js +4 -1
  47. package/build/embed/util.js.map +1 -1
  48. package/build/file/edit.native.js +0 -2
  49. package/build/file/edit.native.js.map +1 -1
  50. package/build/gallery/use-get-media.native.js +2 -1
  51. package/build/gallery/use-get-media.native.js.map +1 -1
  52. package/build/group/edit.js +3 -1
  53. package/build/group/edit.js.map +1 -1
  54. package/build/group/index.js +3 -0
  55. package/build/group/index.js.map +1 -1
  56. package/build/image/edit.js +16 -13
  57. package/build/image/edit.js.map +1 -1
  58. package/build/image/index.js +5 -3
  59. package/build/image/index.js.map +1 -1
  60. package/build/index.js +24 -6
  61. package/build/index.js.map +1 -1
  62. package/build/index.native.js +9 -5
  63. package/build/index.native.js.map +1 -1
  64. package/build/media-text/edit.js +4 -2
  65. package/build/media-text/edit.js.map +1 -1
  66. package/build/media-text/index.js +3 -0
  67. package/build/media-text/index.js.map +1 -1
  68. package/build/media-text/media-container.js +2 -6
  69. package/build/media-text/media-container.js.map +1 -1
  70. package/build/media-text/media-container.native.js +3 -3
  71. package/build/media-text/media-container.native.js.map +1 -1
  72. package/build/navigation/deprecated.js +8 -11
  73. package/build/navigation/deprecated.js.map +1 -1
  74. package/build/navigation/edit/index.js +32 -64
  75. package/build/navigation/edit/index.js.map +1 -1
  76. package/build/navigation/edit/unsaved-inner-blocks.js +1 -14
  77. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  78. package/build/post-author/index.js +0 -1
  79. package/build/post-author/index.js.map +1 -1
  80. package/build/post-date/edit.js +4 -2
  81. package/build/post-date/edit.js.map +1 -1
  82. package/build/post-excerpt/edit.js +2 -2
  83. package/build/post-excerpt/edit.js.map +1 -1
  84. package/build/post-featured-image/dimension-controls.js +2 -1
  85. package/build/post-featured-image/dimension-controls.js.map +1 -1
  86. package/build/post-featured-image/edit.js +16 -27
  87. package/build/post-featured-image/edit.js.map +1 -1
  88. package/build/post-time-to-read/edit.js +1 -1
  89. package/build/post-time-to-read/edit.js.map +1 -1
  90. package/build/post-time-to-read/index.js +7 -0
  91. package/build/post-time-to-read/index.js.map +1 -1
  92. package/build/query/deprecated.js +8 -6
  93. package/build/query/deprecated.js.map +1 -1
  94. package/build/query/edit/inspector-controls/create-new-post-link.js +41 -0
  95. package/build/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
  96. package/build/query/edit/inspector-controls/index.js +14 -6
  97. package/build/query/edit/inspector-controls/index.js.map +1 -1
  98. package/build/query/edit/pattern-selection-modal.js +2 -1
  99. package/build/query/edit/pattern-selection-modal.js.map +1 -1
  100. package/build/query/index.js +5 -12
  101. package/build/query/index.js.map +1 -1
  102. package/build/site-logo/edit.js +114 -16
  103. package/build/site-logo/edit.js.map +1 -1
  104. package/build/site-logo/index.js +1 -1
  105. package/build/social-link/icons/chain.js +1 -1
  106. package/build/social-link/icons/chain.js.map +1 -1
  107. package/build/social-link/icons/mail.js +1 -1
  108. package/build/social-link/icons/mail.js.map +1 -1
  109. package/build/spacer/controls.js +25 -6
  110. package/build/spacer/controls.js.map +1 -1
  111. package/build/spacer/edit.js +129 -13
  112. package/build/spacer/edit.js.map +1 -1
  113. package/build/spacer/save.js +2 -2
  114. package/build/spacer/save.js.map +1 -1
  115. package/build/table/state.js +35 -35
  116. package/build/table/state.js.map +1 -1
  117. package/build/template-part/edit/index.js +2 -1
  118. package/build/template-part/edit/index.js.map +1 -1
  119. package/build/template-part/edit/utils/hooks.js +2 -2
  120. package/build/template-part/edit/utils/hooks.js.map +1 -1
  121. package/build/term-description/index.js +1 -2
  122. package/build/term-description/index.js.map +1 -1
  123. package/build/utils/migrate-font-family.js +12 -5
  124. package/build/utils/migrate-font-family.js.map +1 -1
  125. package/build/video/edit.native.js +4 -3
  126. package/build/video/edit.native.js.map +1 -1
  127. package/build-module/column/index.js +2 -1
  128. package/build-module/column/index.js.map +1 -1
  129. package/build-module/columns/edit.js +24 -6
  130. package/build-module/columns/edit.js.map +1 -1
  131. package/build-module/columns/index.js +2 -1
  132. package/build-module/columns/index.js.map +1 -1
  133. package/build-module/columns/utils.js +4 -8
  134. package/build-module/columns/utils.js.map +1 -1
  135. package/build-module/cover/edit/index.js +48 -52
  136. package/build-module/cover/edit/index.js.map +1 -1
  137. package/build-module/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +31 -6
  138. package/build-module/cover/edit/resizable-cover-popover.js.map +1 -0
  139. package/build-module/cover/index.js +12 -0
  140. package/build-module/cover/index.js.map +1 -1
  141. package/build-module/cover/transforms.js +5 -1
  142. package/build-module/cover/transforms.js.map +1 -1
  143. package/build-module/details/edit.js +52 -0
  144. package/build-module/details/edit.js.map +1 -0
  145. package/build-module/details/index.js +91 -0
  146. package/build-module/details/index.js.map +1 -0
  147. package/build-module/details/save.js +20 -0
  148. package/build-module/details/save.js.map +1 -0
  149. package/build-module/details-content/edit.js +23 -0
  150. package/build-module/details-content/edit.js.map +1 -0
  151. package/build-module/details-content/index.js +76 -0
  152. package/build-module/details-content/index.js.map +1 -0
  153. package/build-module/details-content/save.js +11 -0
  154. package/build-module/details-content/save.js.map +1 -0
  155. package/build-module/details-summary/edit.js +30 -0
  156. package/build-module/details-summary/edit.js.map +1 -0
  157. package/build-module/details-summary/index.js +79 -0
  158. package/build-module/details-summary/index.js.map +1 -0
  159. package/build-module/details-summary/save.js +16 -0
  160. package/build-module/details-summary/save.js.map +1 -0
  161. package/build-module/embed/deprecated.js +4 -1
  162. package/build-module/embed/deprecated.js.map +1 -1
  163. package/build-module/embed/embed-link-settings.native.js +1 -1
  164. package/build-module/embed/embed-link-settings.native.js.map +1 -1
  165. package/build-module/embed/embed-placeholder.js +1 -1
  166. package/build-module/embed/embed-placeholder.js.map +1 -1
  167. package/build-module/embed/index.js +4 -1
  168. package/build-module/embed/index.js.map +1 -1
  169. package/build-module/embed/transforms.js +4 -1
  170. package/build-module/embed/transforms.js.map +1 -1
  171. package/build-module/embed/util.js +4 -1
  172. package/build-module/embed/util.js.map +1 -1
  173. package/build-module/file/edit.native.js +0 -2
  174. package/build-module/file/edit.native.js.map +1 -1
  175. package/build-module/gallery/use-get-media.native.js +2 -1
  176. package/build-module/gallery/use-get-media.native.js.map +1 -1
  177. package/build-module/group/edit.js +3 -1
  178. package/build-module/group/edit.js.map +1 -1
  179. package/build-module/group/index.js +3 -0
  180. package/build-module/group/index.js.map +1 -1
  181. package/build-module/image/edit.js +16 -13
  182. package/build-module/image/edit.js.map +1 -1
  183. package/build-module/image/index.js +5 -3
  184. package/build-module/image/index.js.map +1 -1
  185. package/build-module/index.js +21 -6
  186. package/build-module/index.js.map +1 -1
  187. package/build-module/index.native.js +9 -5
  188. package/build-module/index.native.js.map +1 -1
  189. package/build-module/media-text/edit.js +4 -2
  190. package/build-module/media-text/edit.js.map +1 -1
  191. package/build-module/media-text/index.js +3 -0
  192. package/build-module/media-text/index.js.map +1 -1
  193. package/build-module/media-text/media-container.js +1 -5
  194. package/build-module/media-text/media-container.js.map +1 -1
  195. package/build-module/media-text/media-container.native.js +1 -1
  196. package/build-module/media-text/media-container.native.js.map +1 -1
  197. package/build-module/navigation/deprecated.js +8 -10
  198. package/build-module/navigation/deprecated.js.map +1 -1
  199. package/build-module/navigation/edit/index.js +31 -63
  200. package/build-module/navigation/edit/index.js.map +1 -1
  201. package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -14
  202. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  203. package/build-module/post-author/index.js +0 -1
  204. package/build-module/post-author/index.js.map +1 -1
  205. package/build-module/post-date/edit.js +4 -2
  206. package/build-module/post-date/edit.js.map +1 -1
  207. package/build-module/post-excerpt/edit.js +2 -2
  208. package/build-module/post-excerpt/edit.js.map +1 -1
  209. package/build-module/post-featured-image/dimension-controls.js +2 -1
  210. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  211. package/build-module/post-featured-image/edit.js +16 -27
  212. package/build-module/post-featured-image/edit.js.map +1 -1
  213. package/build-module/post-time-to-read/edit.js +1 -1
  214. package/build-module/post-time-to-read/edit.js.map +1 -1
  215. package/build-module/post-time-to-read/index.js +7 -0
  216. package/build-module/post-time-to-read/index.js.map +1 -1
  217. package/build-module/query/deprecated.js +5 -2
  218. package/build-module/query/deprecated.js.map +1 -1
  219. package/build-module/query/edit/inspector-controls/create-new-post-link.js +33 -0
  220. package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
  221. package/build-module/query/edit/inspector-controls/index.js +12 -7
  222. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  223. package/build-module/query/edit/pattern-selection-modal.js +2 -1
  224. package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
  225. package/build-module/query/index.js +5 -10
  226. package/build-module/query/index.js.map +1 -1
  227. package/build-module/site-logo/edit.js +115 -18
  228. package/build-module/site-logo/edit.js.map +1 -1
  229. package/build-module/site-logo/index.js +1 -1
  230. package/build-module/social-link/icons/chain.js +1 -1
  231. package/build-module/social-link/icons/chain.js.map +1 -1
  232. package/build-module/social-link/icons/mail.js +1 -1
  233. package/build-module/social-link/icons/mail.js.map +1 -1
  234. package/build-module/spacer/controls.js +27 -9
  235. package/build-module/spacer/controls.js.map +1 -1
  236. package/build-module/spacer/edit.js +129 -14
  237. package/build-module/spacer/edit.js.map +1 -1
  238. package/build-module/spacer/save.js +3 -3
  239. package/build-module/spacer/save.js.map +1 -1
  240. package/build-module/table/state.js +35 -33
  241. package/build-module/table/state.js.map +1 -1
  242. package/build-module/template-part/edit/index.js +2 -1
  243. package/build-module/template-part/edit/index.js.map +1 -1
  244. package/build-module/template-part/edit/utils/hooks.js +2 -2
  245. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  246. package/build-module/term-description/index.js +1 -2
  247. package/build-module/term-description/index.js.map +1 -1
  248. package/build-module/utils/migrate-font-family.js +9 -1
  249. package/build-module/utils/migrate-font-family.js.map +1 -1
  250. package/build-module/video/edit.native.js +4 -3
  251. package/build-module/video/edit.native.js.map +1 -1
  252. package/build-style/columns/style-rtl.css +4 -1
  253. package/build-style/columns/style.css +4 -1
  254. package/build-style/common-rtl.css +1 -1
  255. package/build-style/common.css +1 -1
  256. package/build-style/cover/editor-rtl.css +9 -10
  257. package/build-style/cover/editor.css +9 -10
  258. package/build-style/cover/style-rtl.css +1 -1
  259. package/build-style/cover/style.css +1 -1
  260. package/build-style/details/style-rtl.css +91 -0
  261. package/build-style/details/style.css +91 -0
  262. package/build-style/details-summary/editor-rtl.css +91 -0
  263. package/build-style/details-summary/editor.css +91 -0
  264. package/build-style/details-summary/style-rtl.css +91 -0
  265. package/build-style/details-summary/style.css +91 -0
  266. package/build-style/editor-rtl.css +97 -74
  267. package/build-style/editor.css +97 -74
  268. package/build-style/file/style-rtl.css +4 -3
  269. package/build-style/file/style.css +4 -3
  270. package/build-style/html/editor-rtl.css +2 -2
  271. package/build-style/html/editor.css +2 -2
  272. package/build-style/image/editor-rtl.css +1 -1
  273. package/build-style/image/editor.css +1 -1
  274. package/build-style/post-excerpt/style-rtl.css +1 -1
  275. package/build-style/post-excerpt/style.css +1 -1
  276. package/build-style/pullquote/style-rtl.css +4 -1
  277. package/build-style/pullquote/style.css +4 -1
  278. package/build-style/query/editor-rtl.css +8 -12
  279. package/build-style/query/editor.css +8 -12
  280. package/build-style/search/style-rtl.css +2 -0
  281. package/build-style/search/style.css +2 -0
  282. package/build-style/shortcode/editor-rtl.css +15 -35
  283. package/build-style/shortcode/editor.css +15 -35
  284. package/build-style/site-logo/editor-rtl.css +46 -0
  285. package/build-style/site-logo/editor.css +46 -0
  286. package/build-style/spacer/editor-rtl.css +4 -2
  287. package/build-style/spacer/editor.css +4 -2
  288. package/build-style/style-rtl.css +25 -8
  289. package/build-style/style.css +25 -8
  290. package/build-style/template-part/editor-rtl.css +8 -12
  291. package/build-style/template-part/editor.css +8 -12
  292. package/package.json +31 -31
  293. package/src/buttons/test/__snapshots__/edit.native.js.snap +18 -0
  294. package/src/buttons/test/edit.native.js +123 -2
  295. package/src/column/block.json +2 -1
  296. package/src/columns/block.json +2 -1
  297. package/src/columns/edit.js +33 -9
  298. package/src/columns/style.scss +5 -1
  299. package/src/columns/utils.js +8 -9
  300. package/src/common.scss +1 -1
  301. package/src/cover/block.json +12 -0
  302. package/src/cover/edit/index.js +44 -37
  303. package/src/cover/edit/resizable-cover-popover.js +82 -0
  304. package/src/cover/editor.scss +20 -13
  305. package/src/cover/index.php +9 -10
  306. package/src/cover/style.scss +1 -1
  307. package/src/cover/test/edit.js +1 -1
  308. package/src/cover/transforms.js +4 -1
  309. package/src/details/block.json +54 -0
  310. package/src/details/edit.js +59 -0
  311. package/src/details/index.js +35 -0
  312. package/src/details/save.js +15 -0
  313. package/src/details/style.scss +3 -0
  314. package/src/details-content/block.json +50 -0
  315. package/src/details-content/edit.js +29 -0
  316. package/src/details-content/index.js +23 -0
  317. package/src/details-content/save.js +12 -0
  318. package/src/details-summary/block.json +53 -0
  319. package/src/details-summary/edit.js +27 -0
  320. package/src/details-summary/editor.scss +3 -0
  321. package/src/details-summary/index.js +23 -0
  322. package/src/details-summary/save.js +13 -0
  323. package/src/details-summary/style.scss +3 -0
  324. package/src/editor.scss +1 -0
  325. package/src/embed/block.json +4 -1
  326. package/src/embed/embed-link-settings.native.js +1 -1
  327. package/src/embed/embed-placeholder.js +1 -1
  328. package/src/file/edit.native.js +0 -2
  329. package/src/file/style.scss +5 -2
  330. package/src/gallery/test/index.native.js +4 -4
  331. package/src/gallery/test/use-get-media.native.js +24 -0
  332. package/src/gallery/use-get-media.native.js +1 -1
  333. package/src/group/block.json +3 -0
  334. package/src/group/edit.js +8 -2
  335. package/src/heading/test/__snapshots__/index.native.js.snap +12 -0
  336. package/src/heading/test/index.native.js +71 -0
  337. package/src/html/editor.scss +2 -21
  338. package/src/image/block.json +5 -3
  339. package/src/image/edit.js +21 -17
  340. package/src/image/editor.scss +1 -1
  341. package/src/index.js +13 -3
  342. package/src/index.native.js +9 -5
  343. package/src/list/test/edit.native.js +7 -7
  344. package/src/media-text/block.json +3 -0
  345. package/src/media-text/edit.js +2 -1
  346. package/src/media-text/media-container.js +1 -5
  347. package/src/media-text/media-container.native.js +1 -1
  348. package/src/navigation/deprecated.js +15 -19
  349. package/src/navigation/edit/index.js +32 -106
  350. package/src/navigation/edit/unsaved-inner-blocks.js +34 -46
  351. package/src/navigation/index.php +15 -12
  352. package/src/paragraph/test/edit.native.js +616 -1
  353. package/src/post-author/block.json +0 -1
  354. package/src/post-date/edit.js +4 -0
  355. package/src/post-date/index.php +17 -8
  356. package/src/post-excerpt/edit.js +1 -1
  357. package/src/post-excerpt/index.php +3 -3
  358. package/src/post-excerpt/style.scss +2 -1
  359. package/src/post-featured-image/dimension-controls.js +5 -1
  360. package/src/post-featured-image/edit.js +14 -34
  361. package/src/post-featured-image/index.php +1 -1
  362. package/src/post-time-to-read/block.json +7 -0
  363. package/src/post-time-to-read/edit.js +1 -1
  364. package/src/post-time-to-read/index.php +3 -3
  365. package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -2
  366. package/src/preformatted/test/edit.native.js +42 -2
  367. package/src/pullquote/style.scss +5 -1
  368. package/src/pullquote/test/edit.native.js +65 -0
  369. package/src/query/deprecated.js +4 -1
  370. package/src/query/edit/inspector-controls/create-new-post-link.js +26 -0
  371. package/src/query/edit/inspector-controls/index.js +13 -6
  372. package/src/query/edit/pattern-selection-modal.js +1 -0
  373. package/src/query/editor.scss +8 -11
  374. package/src/query/index.js +1 -7
  375. package/src/quote/test/edit.native.js +88 -0
  376. package/src/search/index.php +1 -1
  377. package/src/search/style.scss +3 -0
  378. package/src/shortcode/editor.scss +6 -5
  379. package/src/site-logo/block.json +1 -1
  380. package/src/site-logo/edit.js +123 -9
  381. package/src/site-logo/editor.scss +57 -0
  382. package/src/social-link/icons/chain.js +1 -1
  383. package/src/social-link/icons/mail.js +1 -1
  384. package/src/social-link/index.php +2 -2
  385. package/src/spacer/controls.js +42 -17
  386. package/src/spacer/edit.js +176 -18
  387. package/src/spacer/editor.scss +2 -1
  388. package/src/spacer/save.js +3 -3
  389. package/src/style.scss +2 -0
  390. package/src/table/state.js +83 -66
  391. package/src/template-part/edit/index.js +1 -0
  392. package/src/template-part/edit/utils/hooks.js +2 -2
  393. package/src/template-part/editor.scss +9 -11
  394. package/src/term-description/block.json +1 -2
  395. package/src/utils/migrate-font-family.js +8 -1
  396. package/src/verse/test/edit.native.js +28 -0
  397. package/src/video/edit.native.js +2 -2
  398. package/tsconfig.json +1 -0
  399. package/build/cover/edit/resizable-cover.js.map +0 -1
  400. package/build/media-text/media-container-icon.js +0 -27
  401. package/build/media-text/media-container-icon.js.map +0 -1
  402. package/build/query/hooks.js +0 -72
  403. package/build/query/hooks.js.map +0 -1
  404. package/build/utils/clean-empty-object.js +0 -34
  405. package/build/utils/clean-empty-object.js.map +0 -1
  406. package/build-module/cover/edit/resizable-cover.js.map +0 -1
  407. package/build-module/media-text/media-container-icon.js +0 -17
  408. package/build-module/media-text/media-container-icon.js.map +0 -1
  409. package/build-module/query/hooks.js +0 -59
  410. package/build-module/query/hooks.js.map +0 -1
  411. package/build-module/utils/clean-empty-object.js +0 -25
  412. package/build-module/utils/clean-empty-object.js.map +0 -1
  413. package/src/cover/edit/resizable-cover.js +0 -61
  414. package/src/media-text/media-container-icon.js +0 -12
  415. package/src/query/hooks.js +0 -53
  416. package/src/utils/clean-empty-object.js +0 -28
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/table/state.js"],"names":["INHERITED_COLUMN_ATTRIBUTES","createTable","rowCount","columnCount","body","Array","from","length","map","cells","content","tag","getFirstRow","state","isEmptyTableSection","head","foot","getCellAttribute","cellLocation","attributeName","sectionName","rowIndex","columnIndex","updateSelectedCell","selection","updateCell","tableSections","Object","fromEntries","entries","filter","key","includes","selectionSectionName","selectionRowIndex","section","row","cellAttributes","isCellSelected","type","insertRow","firstRow","cellCount","undefined","slice","_","index","firstCellInColumn","inheritedAttributes","deleteRow","insertColumn","isEmptyRow","deleteColumn","cell","to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AF;AAAeC,IAAAA,QAAQ,EAAE,CAAzB;AAA4BlB,IAAAA;AAA5B,GAAT,CAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASW,mBAAT,CAA8BqB,OAA9B,EAAwC;AAC9C,SAAO,CAAEA,OAAF,IAAa,CAAEA,OAAO,CAAC5B,MAAvB,IAAiC4B,OAAO,CAACoB,KAAR,CAAeJ,UAAf,CAAxC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASA,UAAT,CAAqBf,GAArB,EAA2B;AACjC,SAAO,EAAIA,GAAG,CAAC3B,KAAJ,IAAa2B,GAAG,CAAC3B,KAAJ,CAAUF,MAA3B,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { mapValues } from 'lodash';\n\nconst INHERITED_COLUMN_ATTRIBUTES = [ 'align' ];\n\n/**\n * Creates a table state.\n *\n * @param {Object} options\n * @param {number} options.rowCount Row count for the table to create.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function createTable( { rowCount, columnCount } ) {\n\treturn {\n\t\tbody: Array.from( { length: rowCount } ).map( () => ( {\n\t\t\tcells: Array.from( { length: columnCount } ).map( () => ( {\n\t\t\t\tcontent: '',\n\t\t\t\ttag: 'td',\n\t\t\t} ) ),\n\t\t} ) ),\n\t};\n}\n\n/**\n * Returns the first row in the table.\n *\n * @param {Object} state Current table state.\n *\n * @return {Object | undefined} The first table row.\n */\nexport function getFirstRow( state ) {\n\tif ( ! isEmptyTableSection( state.head ) ) {\n\t\treturn state.head[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.body ) ) {\n\t\treturn state.body[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.foot ) ) {\n\t\treturn state.foot[ 0 ];\n\t}\n}\n\n/**\n * Gets an attribute for a cell.\n *\n * @param {Object} state Current table state.\n * @param {Object} cellLocation The location of the cell\n * @param {string} attributeName The name of the attribute to get the value of.\n *\n * @return {*} The attribute value.\n */\nexport function getCellAttribute( state, cellLocation, attributeName ) {\n\tconst { sectionName, rowIndex, columnIndex } = cellLocation;\n\treturn state[ sectionName ]?.[ rowIndex ]?.cells?.[ columnIndex ]?.[\n\t\tattributeName\n\t];\n}\n\n/**\n * Returns updated cell attributes after applying the `updateCell` function to the selection.\n *\n * @param {Object} state The block attributes.\n * @param {Object} selection The selection of cells to update.\n * @param {Function} updateCell A function to update the selected cell attributes.\n *\n * @return {Object} New table state including the updated cells.\n */\nexport function updateSelectedCell( state, selection, updateCell ) {\n\tif ( ! selection ) {\n\t\treturn state;\n\t}\n\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\tconst { sectionName: selectionSectionName, rowIndex: selectionRowIndex } =\n\t\tselection;\n\n\treturn mapValues( tableSections, ( section, sectionName ) => {\n\t\tif ( selectionSectionName && selectionSectionName !== sectionName ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section.map( ( row, rowIndex ) => {\n\t\t\tif ( selectionRowIndex && selectionRowIndex !== rowIndex ) {\n\t\t\t\treturn row;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcells: row.cells.map( ( cellAttributes, columnIndex ) => {\n\t\t\t\t\tconst cellLocation = {\n\t\t\t\t\t\tsectionName,\n\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\trowIndex,\n\t\t\t\t\t};\n\n\t\t\t\t\tif ( ! isCellSelected( cellLocation, selection ) ) {\n\t\t\t\t\t\treturn cellAttributes;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn updateCell( cellAttributes );\n\t\t\t\t} ),\n\t\t\t};\n\t\t} );\n\t} );\n}\n\n/**\n * Returns whether the cell at `cellLocation` is included in the selection `selection`.\n *\n * @param {Object} cellLocation An object containing cell location properties.\n * @param {Object} selection An object containing selection properties.\n *\n * @return {boolean} True if the cell is selected, false otherwise.\n */\nexport function isCellSelected( cellLocation, selection ) {\n\tif ( ! cellLocation || ! selection ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection.type ) {\n\t\tcase 'column':\n\t\t\treturn (\n\t\t\t\tselection.type === 'column' &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex\n\t\t\t);\n\t\tcase 'cell':\n\t\t\treturn (\n\t\t\t\tselection.type === 'cell' &&\n\t\t\t\tcellLocation.sectionName === selection.sectionName &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex &&\n\t\t\t\tcellLocation.rowIndex === selection.rowIndex\n\t\t\t);\n\t}\n}\n\n/**\n * Inserts a row in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to insert the row.\n * @param {number} options.rowIndex Row index at which to insert the row.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function insertRow( state, { sectionName, rowIndex, columnCount } ) {\n\tconst firstRow = getFirstRow( state );\n\tconst cellCount =\n\t\tcolumnCount === undefined ? firstRow?.cells?.length : columnCount;\n\n\t// Bail early if the function cannot determine how many cells to add.\n\tif ( ! cellCount ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t[ sectionName ]: [\n\t\t\t...state[ sectionName ].slice( 0, rowIndex ),\n\t\t\t{\n\t\t\t\tcells: Array.from( { length: cellCount } ).map(\n\t\t\t\t\t( _, index ) => {\n\t\t\t\t\t\tconst firstCellInColumn =\n\t\t\t\t\t\t\tfirstRow?.cells?.[ index ] ?? {};\n\n\t\t\t\t\t\tconst inheritedAttributes = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( firstCellInColumn ).filter(\n\t\t\t\t\t\t\t\t( [ key ] ) =>\n\t\t\t\t\t\t\t\t\tINHERITED_COLUMN_ATTRIBUTES.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...inheritedAttributes,\n\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\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\t...state[ sectionName ].slice( rowIndex ),\n\t\t],\n\t};\n}\n\n/**\n * Deletes a row from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to delete the row.\n * @param {number} options.rowIndex Row index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteRow( state, { sectionName, rowIndex } ) {\n\treturn {\n\t\t[ sectionName ]: state[ sectionName ].filter(\n\t\t\t( row, index ) => index !== rowIndex\n\t\t),\n\t};\n}\n\n/**\n * Inserts a column in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index at which to insert the column.\n *\n * @return {Object} New table state.\n */\nexport function insertColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn mapValues( tableSections, ( section, sectionName ) => {\n\t\t// Bail early if the table section is empty.\n\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section.map( ( row ) => {\n\t\t\t// Bail early if the row is empty or it's an attempt to insert past\n\t\t\t// the last possible index of the array.\n\t\t\tif ( isEmptyRow( row ) || row.cells.length < columnIndex ) {\n\t\t\t\treturn row;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcells: [\n\t\t\t\t\t...row.cells.slice( 0, columnIndex ),\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t},\n\t\t\t\t\t...row.cells.slice( columnIndex ),\n\t\t\t\t],\n\t\t\t};\n\t\t} );\n\t} );\n}\n\n/**\n * Deletes a column from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn mapValues( tableSections, ( section ) => {\n\t\t// Bail early if the table section is empty.\n\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section\n\t\t\t.map( ( row ) => ( {\n\t\t\t\tcells:\n\t\t\t\t\trow.cells.length >= columnIndex\n\t\t\t\t\t\t? row.cells.filter(\n\t\t\t\t\t\t\t\t( cell, index ) => index !== columnIndex\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: row.cells,\n\t\t\t} ) )\n\t\t\t.filter( ( row ) => row.cells.length );\n\t} );\n}\n\n/**\n * Toggles the existence of a section.\n *\n * @param {Object} state Current table state.\n * @param {string} sectionName Name of the section to toggle.\n *\n * @return {Object} New table state.\n */\nexport function toggleSection( state, sectionName ) {\n\t// Section exists, replace it with an empty row to remove it.\n\tif ( ! isEmptyTableSection( state[ sectionName ] ) ) {\n\t\treturn { [ sectionName ]: [] };\n\t}\n\n\t// Get the length of the first row of the body to use when creating the header.\n\tconst columnCount = state.body?.[ 0 ]?.cells?.length ?? 1;\n\n\t// Section doesn't exist, insert an empty row to create the section.\n\treturn insertRow( state, { sectionName, rowIndex: 0, columnCount } );\n}\n\n/**\n * Determines whether a table section is empty.\n *\n * @param {Object} section Table section state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyTableSection( section ) {\n\treturn ! section || ! section.length || section.every( isEmptyRow );\n}\n\n/**\n * Determines whether a table row is empty.\n *\n * @param {Object} row Table row state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyRow( row ) {\n\treturn ! ( row.cells && row.cells.length );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/table/state.js"],"names":["INHERITED_COLUMN_ATTRIBUTES","createTable","rowCount","columnCount","body","Array","from","length","map","cells","content","tag","getFirstRow","state","isEmptyTableSection","head","foot","getCellAttribute","cellLocation","attributeName","sectionName","rowIndex","columnIndex","updateSelectedCell","selection","updateCell","tableSections","Object","fromEntries","entries","filter","key","includes","selectionSectionName","selectionRowIndex","section","row","cellAttributes","isCellSelected","type","insertRow","firstRow","cellCount","undefined","slice","_","index","firstCellInColumn","inheritedAttributes","deleteRow","insertColumn","isEmptyRow","deleteColumn","cell","toggleSection","every"],"mappings":";;;;;;;;;;;;;;;;;AAAA,MAAMA,2BAA2B,GAAG,CAAE,OAAF,CAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,WAAT,OAAkD;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACxD,SAAO;AACNC,IAAAA,IAAI,EAAEC,KAAK,CAACC,IAAN,CAAY;AAAEC,MAAAA,MAAM,EAAEL;AAAV,KAAZ,EAAmCM,GAAnC,CAAwC,OAAQ;AACrDC,MAAAA,KAAK,EAAEJ,KAAK,CAACC,IAAN,CAAY;AAAEC,QAAAA,MAAM,EAAEJ;AAAV,OAAZ,EAAsCK,GAAtC,CAA2C,OAAQ;AACzDE,QAAAA,OAAO,EAAE,EADgD;AAEzDC,QAAAA,GAAG,EAAE;AAFoD,OAAR,CAA3C;AAD8C,KAAR,CAAxC;AADA,GAAP;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,WAAT,CAAsBC,KAAtB,EAA8B;AACpC,MAAK,CAAEC,mBAAmB,CAAED,KAAK,CAACE,IAAR,CAA1B,EAA2C;AAC1C,WAAOF,KAAK,CAACE,IAAN,CAAY,CAAZ,CAAP;AACA;;AACD,MAAK,CAAED,mBAAmB,CAAED,KAAK,CAACT,IAAR,CAA1B,EAA2C;AAC1C,WAAOS,KAAK,CAACT,IAAN,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ates a table state.\n *\n * @param {Object} options\n * @param {number} options.rowCount Row count for the table to create.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function createTable( { rowCount, columnCount } ) {\n\treturn {\n\t\tbody: Array.from( { length: rowCount } ).map( () => ( {\n\t\t\tcells: Array.from( { length: columnCount } ).map( () => ( {\n\t\t\t\tcontent: '',\n\t\t\t\ttag: 'td',\n\t\t\t} ) ),\n\t\t} ) ),\n\t};\n}\n\n/**\n * Returns the first row in the table.\n *\n * @param {Object} state Current table state.\n *\n * @return {Object | undefined} The first table row.\n */\nexport function getFirstRow( state ) {\n\tif ( ! isEmptyTableSection( state.head ) ) {\n\t\treturn state.head[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.body ) ) {\n\t\treturn state.body[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.foot ) ) {\n\t\treturn state.foot[ 0 ];\n\t}\n}\n\n/**\n * Gets an attribute for a cell.\n *\n * @param {Object} state Current table state.\n * @param {Object} cellLocation The location of the cell\n * @param {string} attributeName The name of the attribute to get the value of.\n *\n * @return {*} The attribute value.\n */\nexport function getCellAttribute( state, cellLocation, attributeName ) {\n\tconst { sectionName, rowIndex, columnIndex } = cellLocation;\n\treturn state[ sectionName ]?.[ rowIndex ]?.cells?.[ columnIndex ]?.[\n\t\tattributeName\n\t];\n}\n\n/**\n * Returns updated cell attributes after applying the `updateCell` function to the selection.\n *\n * @param {Object} state The block attributes.\n * @param {Object} selection The selection of cells to update.\n * @param {Function} updateCell A function to update the selected cell attributes.\n *\n * @return {Object} New table state including the updated cells.\n */\nexport function updateSelectedCell( state, selection, updateCell ) {\n\tif ( ! selection ) {\n\t\treturn state;\n\t}\n\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\tconst { sectionName: selectionSectionName, rowIndex: selectionRowIndex } =\n\t\tselection;\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\tif (\n\t\t\t\tselectionSectionName &&\n\t\t\t\tselectionSectionName !== sectionName\n\t\t\t) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection.map( ( row, rowIndex ) => {\n\t\t\t\t\tif ( selectionRowIndex && selectionRowIndex !== rowIndex ) {\n\t\t\t\t\t\treturn row;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcells: row.cells.map(\n\t\t\t\t\t\t\t( cellAttributes, columnIndex ) => {\n\t\t\t\t\t\t\t\tconst cellLocation = {\n\t\t\t\t\t\t\t\t\tsectionName,\n\t\t\t\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\t\t\t\trowIndex,\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! isCellSelected( cellLocation, selection )\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn cellAttributes;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn updateCell( cellAttributes );\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\n/**\n * Returns whether the cell at `cellLocation` is included in the selection `selection`.\n *\n * @param {Object} cellLocation An object containing cell location properties.\n * @param {Object} selection An object containing selection properties.\n *\n * @return {boolean} True if the cell is selected, false otherwise.\n */\nexport function isCellSelected( cellLocation, selection ) {\n\tif ( ! cellLocation || ! selection ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection.type ) {\n\t\tcase 'column':\n\t\t\treturn (\n\t\t\t\tselection.type === 'column' &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex\n\t\t\t);\n\t\tcase 'cell':\n\t\t\treturn (\n\t\t\t\tselection.type === 'cell' &&\n\t\t\t\tcellLocation.sectionName === selection.sectionName &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex &&\n\t\t\t\tcellLocation.rowIndex === selection.rowIndex\n\t\t\t);\n\t}\n}\n\n/**\n * Inserts a row in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to insert the row.\n * @param {number} options.rowIndex Row index at which to insert the row.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function insertRow( state, { sectionName, rowIndex, columnCount } ) {\n\tconst firstRow = getFirstRow( state );\n\tconst cellCount =\n\t\tcolumnCount === undefined ? firstRow?.cells?.length : columnCount;\n\n\t// Bail early if the function cannot determine how many cells to add.\n\tif ( ! cellCount ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t[ sectionName ]: [\n\t\t\t...state[ sectionName ].slice( 0, rowIndex ),\n\t\t\t{\n\t\t\t\tcells: Array.from( { length: cellCount } ).map(\n\t\t\t\t\t( _, index ) => {\n\t\t\t\t\t\tconst firstCellInColumn =\n\t\t\t\t\t\t\tfirstRow?.cells?.[ index ] ?? {};\n\n\t\t\t\t\t\tconst inheritedAttributes = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( firstCellInColumn ).filter(\n\t\t\t\t\t\t\t\t( [ key ] ) =>\n\t\t\t\t\t\t\t\t\tINHERITED_COLUMN_ATTRIBUTES.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...inheritedAttributes,\n\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\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\t...state[ sectionName ].slice( rowIndex ),\n\t\t],\n\t};\n}\n\n/**\n * Deletes a row from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to delete the row.\n * @param {number} options.rowIndex Row index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteRow( state, { sectionName, rowIndex } ) {\n\treturn {\n\t\t[ sectionName ]: state[ sectionName ].filter(\n\t\t\t( row, index ) => index !== rowIndex\n\t\t),\n\t};\n}\n\n/**\n * Inserts a column in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index at which to insert the column.\n *\n * @return {Object} New table state.\n */\nexport function insertColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\t// Bail early if the table section is empty.\n\t\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection.map( ( row ) => {\n\t\t\t\t\t// Bail early if the row is empty or it's an attempt to insert past\n\t\t\t\t\t// the last possible index of the array.\n\t\t\t\t\tif ( isEmptyRow( row ) || row.cells.length < columnIndex ) {\n\t\t\t\t\t\treturn row;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcells: [\n\t\t\t\t\t\t\t...row.cells.slice( 0, columnIndex ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...row.cells.slice( columnIndex ),\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\n/**\n * Deletes a column from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\t// Bail early if the table section is empty.\n\t\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection\n\t\t\t\t\t.map( ( row ) => ( {\n\t\t\t\t\t\tcells:\n\t\t\t\t\t\t\trow.cells.length >= columnIndex\n\t\t\t\t\t\t\t\t? row.cells.filter(\n\t\t\t\t\t\t\t\t\t\t( cell, index ) => index !== columnIndex\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: row.cells,\n\t\t\t\t\t} ) )\n\t\t\t\t\t.filter( ( row ) => row.cells.length ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Toggles the existence of a section.\n *\n * @param {Object} state Current table state.\n * @param {string} sectionName Name of the section to toggle.\n *\n * @return {Object} New table state.\n */\nexport function toggleSection( state, sectionName ) {\n\t// Section exists, replace it with an empty row to remove it.\n\tif ( ! isEmptyTableSection( state[ sectionName ] ) ) {\n\t\treturn { [ sectionName ]: [] };\n\t}\n\n\t// Get the length of the first row of the body to use when creating the header.\n\tconst columnCount = state.body?.[ 0 ]?.cells?.length ?? 1;\n\n\t// Section doesn't exist, insert an empty row to create the section.\n\treturn insertRow( state, { sectionName, rowIndex: 0, columnCount } );\n}\n\n/**\n * Determines whether a table section is empty.\n *\n * @param {Object} section Table section state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyTableSection( section ) {\n\treturn ! section || ! section.length || section.every( isEmptyRow );\n}\n\n/**\n * Determines whether a table row is empty.\n *\n * @param {Object} row Table row state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyRow( row ) {\n\treturn ! ( row.cells && row.cells.length );\n}\n"]}
@@ -148,7 +148,8 @@ function TemplatePartEdit(_ref) {
148
148
  overlayClassName: "block-editor-template-part__selection-modal",
149
149
  title: (0, _i18n.sprintf)( // Translators: %s as template part area title ("Header", "Footer", etc.).
150
150
  (0, _i18n.__)('Choose a %s'), areaObject.label.toLowerCase()),
151
- onRequestClose: () => setIsTemplatePartSelectionOpen(false)
151
+ onRequestClose: () => setIsTemplatePartSelectionOpen(false),
152
+ isFullScreen: true
152
153
  }, (0, _element.createElement)(_selectionModal.default, {
153
154
  templatePartId: templatePartId,
154
155
  clientId: clientId,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"names":["TemplatePartEdit","attributes","setAttributes","clientId","isSelected","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","isResolved","innerBlocks","isMissing","area","select","getEditedEntityRecord","hasFinishedResolution","coreStore","getBlocks","blockEditorStore","getEntityArgs","entityRecord","_area","hasResolvedEntity","templateParts","blockPatterns","hasReplacements","length","areaObject","blockProps","isPlaceholder","isEntityAvailable","TagName","canReplace","BlockTitle","label","toLowerCase"],"mappings":";;;;;;;;;AAqBA;;AAlBA;;AAKA;;AACA;;AASA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;AAYe,SAASA,gBAAT,OAKX;AAAA,MALsC;AACzCC,IAAAA,UADyC;AAEzCC,IAAAA,aAFyC;AAGzCC,IAAAA,QAHyC;AAIzCC,IAAAA;AAJyC,GAKtC;AACH,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,OAAf;AAAwBC,IAAAA,MAAM,GAAG;AAAjC,MAAwCP,UAA9C;AACA,QAAMQ,cAAc,GAAG,gDAAsBH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QAAQ,EAAGN,QAFZ;AAGC,IAAA,IAAI,EAAGa,IAHR;AAIC,IAAA,aAAa,EAAGd,aAJjB;AAKC,IAAA,OAAO,EAAG,MACTU,8BAA8B,CAAE,KAAF;AANhC,IAXD,CA9DF,CADD;AAuFA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tBlockTitle,\n\tuseBlockProps,\n\tWarning,\n\tstore as blockEditorStore,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n} from '@wordpress/block-editor';\nimport { Spinner, Modal, MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPlaceholder from './placeholder';\nimport TemplatePartSelectionModal from './selection-modal';\nimport { TemplatePartAdvancedControls } from './advanced-controls';\nimport TemplatePartInnerBlocks from './inner-blocks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseTemplatePartArea,\n} from './utils/hooks';\n\nexport default function TemplatePartEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n\tisSelected,\n} ) {\n\tconst { slug, theme, tagName, layout = {} } = attributes;\n\tconst templatePartId = createTemplatePartId( theme, slug );\n\tconst hasAlreadyRendered = useHasRecursion( templatePartId );\n\tconst [ isTemplatePartSelectionOpen, setIsTemplatePartSelectionOpen ] =\n\t\tuseState( false );\n\n\t// Set the postId block attribute if it did not exist,\n\t// but wait until the inner blocks have loaded to allow\n\t// new edits to trigger this.\n\tconst { isResolved, innerBlocks, isMissing, area } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\tconst getEntityArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePartId,\n\t\t\t];\n\t\t\tconst entityRecord = templatePartId\n\t\t\t\t? getEditedEntityRecord( ...getEntityArgs )\n\t\t\t\t: null;\n\t\t\tconst _area = entityRecord?.area || attributes.area;\n\t\t\tconst hasResolvedEntity = templatePartId\n\t\t\t\t? hasFinishedResolution(\n\t\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t\tgetEntityArgs\n\t\t\t\t )\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisResolved: hasResolvedEntity,\n\t\t\t\tisMissing: hasResolvedEntity && isEmpty( entityRecord ),\n\t\t\t\tarea: _area,\n\t\t\t};\n\t\t},\n\t\t[ templatePartId, clientId ]\n\t);\n\tconst { templateParts } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\tconst hasReplacements = !! templateParts.length || !! blockPatterns.length;\n\tconst areaObject = useTemplatePartArea( area );\n\tconst blockProps = useBlockProps();\n\tconst isPlaceholder = ! slug;\n\tconst isEntityAvailable = ! isPlaceholder && ! isMissing && isResolved;\n\tconst TagName = tagName || areaObject.tagName;\n\n\t// The `isSelected` check ensures the `BlockSettingsMenuControls` fill\n\t// doesn't render multiple times. The block controls has similar internal check.\n\tconst canReplace =\n\t\tisSelected &&\n\t\tisEntityAvailable &&\n\t\thasReplacements &&\n\t\t( area === 'header' || area === 'footer' );\n\n\t// We don't want to render a missing state if we have any inner blocks.\n\t// A new template part is automatically created if we have any inner blocks but no entity.\n\tif (\n\t\tinnerBlocks.length === 0 &&\n\t\t( ( slug && ! theme ) || ( slug && isMissing ) )\n\t) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: Template part slug */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Template part has been deleted or is unavailable: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tslug\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\tif ( isEntityAvailable && hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RecursionProvider uniqueId={ templatePartId }>\n\t\t\t\t<TemplatePartAdvancedControls\n\t\t\t\t\ttagName={ tagName }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisEntityAvailable={ isEntityAvailable }\n\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\tdefaultWrapper={ areaObject.tagName }\n\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t/>\n\t\t\t\t{ isPlaceholder && (\n\t\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t\t<TemplatePartPlaceholder\n\t\t\t\t\t\t\tarea={ attributes.area }\n\t\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\tonOpenSelectionModal={ () =>\n\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</TagName>\n\t\t\t\t) }\n\t\t\t\t{ canReplace && (\n\t\t\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__( 'Replace <BlockTitle />' ),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tBlockTitle: (\n\t\t\t\t\t\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\t\t\t\t\t\tmaximumLength={ 25 }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</BlockSettingsMenuControls>\n\t\t\t\t) }\n\t\t\t\t{ isEntityAvailable && (\n\t\t\t\t\t<TemplatePartInnerBlocks\n\t\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\t\tpostId={ templatePartId }\n\t\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isPlaceholder && ! isResolved && (\n\t\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</TagName>\n\t\t\t\t) }\n\t\t\t</RecursionProvider>\n\t\t\t{ isTemplatePartSelectionOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\toverlayClassName=\"block-editor-template-part__selection-modal\"\n\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t__( 'Choose a %s' ),\n\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<TemplatePartSelectionModal\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonClose={ () =>\n\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"names":["TemplatePartEdit","attributes","setAttributes","clientId","isSelected","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","isResolved","innerBlocks","isMissing","area","select","getEditedEntityRecord","hasFinishedResolution","coreStore","getBlocks","blockEditorStore","getEntityArgs","entityRecord","_area","hasResolvedEntity","templateParts","blockPatterns","hasReplacements","length","areaObject","blockProps","isPlaceholder","isEntityAvailable","TagName","canReplace","BlockTitle","label","toLowerCase"],"mappings":";;;;;;;;;AAqBA;;AAlBA;;AAKA;;AACA;;AASA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;AAYe,SAASA,gBAAT,OAKX;AAAA,MALsC;AACzCC,IAAAA,UADyC;AAEzCC,IAAAA,aAFyC;AAGzCC,IAAAA,QAHyC;AAIzCC,IAAAA;AAJyC,GAKtC;AACH,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,OAAf;AAAwBC,IAAAA,MAAM,GAAG;AAAjC,MAAwCP,UAA9C;AACA,QAAMQ,cAAc,GAAG,gDAAsBH,KAAtB,EAA6BD,IAA7B,CAAvB;AACA,QAAMK,kBAAkB,GAA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GC,IAAA,IAAI,EAAGa,IAHR;AAIC,IAAA,aAAa,EAAGd,aAJjB;AAKC,IAAA,OAAO,EAAG,MACTU,8BAA8B,CAAE,KAAF;AANhC,IAZD,CA9DF,CADD;AAwFA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tBlockTitle,\n\tuseBlockProps,\n\tWarning,\n\tstore as blockEditorStore,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n} from '@wordpress/block-editor';\nimport { Spinner, Modal, MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPlaceholder from './placeholder';\nimport TemplatePartSelectionModal from './selection-modal';\nimport { TemplatePartAdvancedControls } from './advanced-controls';\nimport TemplatePartInnerBlocks from './inner-blocks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseTemplatePartArea,\n} from './utils/hooks';\n\nexport default function TemplatePartEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n\tisSelected,\n} ) {\n\tconst { slug, theme, tagName, layout = {} } = attributes;\n\tconst templatePartId = createTemplatePartId( theme, slug );\n\tconst hasAlreadyRendered = useHasRecursion( templatePartId );\n\tconst [ isTemplatePartSelectionOpen, setIsTemplatePartSelectionOpen ] =\n\t\tuseState( false );\n\n\t// Set the postId block attribute if it did not exist,\n\t// but wait until the inner blocks have loaded to allow\n\t// new edits to trigger this.\n\tconst { isResolved, innerBlocks, isMissing, area } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\tconst getEntityArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePartId,\n\t\t\t];\n\t\t\tconst entityRecord = templatePartId\n\t\t\t\t? getEditedEntityRecord( ...getEntityArgs )\n\t\t\t\t: null;\n\t\t\tconst _area = entityRecord?.area || attributes.area;\n\t\t\tconst hasResolvedEntity = templatePartId\n\t\t\t\t? hasFinishedResolution(\n\t\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t\tgetEntityArgs\n\t\t\t\t )\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisResolved: hasResolvedEntity,\n\t\t\t\tisMissing: hasResolvedEntity && isEmpty( entityRecord ),\n\t\t\t\tarea: _area,\n\t\t\t};\n\t\t},\n\t\t[ templatePartId, clientId ]\n\t);\n\tconst { templateParts } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\tconst hasReplacements = !! templateParts.length || !! blockPatterns.length;\n\tconst areaObject = useTemplatePartArea( area );\n\tconst blockProps = useBlockProps();\n\tconst isPlaceholder = ! slug;\n\tconst isEntityAvailable = ! isPlaceholder && ! isMissing && isResolved;\n\tconst TagName = tagName || areaObject.tagName;\n\n\t// The `isSelected` check ensures the `BlockSettingsMenuControls` fill\n\t// doesn't render multiple times. The block controls has similar internal check.\n\tconst canReplace =\n\t\tisSelected &&\n\t\tisEntityAvailable &&\n\t\thasReplacements &&\n\t\t( area === 'header' || area === 'footer' );\n\n\t// We don't want to render a missing state if we have any inner blocks.\n\t// A new template part is automatically created if we have any inner blocks but no entity.\n\tif (\n\t\tinnerBlocks.length === 0 &&\n\t\t( ( slug && ! theme ) || ( slug && isMissing ) )\n\t) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: Template part slug */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Template part has been deleted or is unavailable: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tslug\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\tif ( isEntityAvailable && hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RecursionProvider uniqueId={ templatePartId }>\n\t\t\t\t<TemplatePartAdvancedControls\n\t\t\t\t\ttagName={ tagName }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisEntityAvailable={ isEntityAvailable }\n\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\tdefaultWrapper={ areaObject.tagName }\n\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t/>\n\t\t\t\t{ isPlaceholder && (\n\t\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t\t<TemplatePartPlaceholder\n\t\t\t\t\t\t\tarea={ attributes.area }\n\t\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\tonOpenSelectionModal={ () =>\n\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</TagName>\n\t\t\t\t) }\n\t\t\t\t{ canReplace && (\n\t\t\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__( 'Replace <BlockTitle />' ),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tBlockTitle: (\n\t\t\t\t\t\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\t\t\t\t\t\tmaximumLength={ 25 }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</BlockSettingsMenuControls>\n\t\t\t\t) }\n\t\t\t\t{ isEntityAvailable && (\n\t\t\t\t\t<TemplatePartInnerBlocks\n\t\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\t\tpostId={ templatePartId }\n\t\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isPlaceholder && ! isResolved && (\n\t\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</TagName>\n\t\t\t\t) }\n\t\t\t</RecursionProvider>\n\t\t\t{ isTemplatePartSelectionOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\toverlayClassName=\"block-editor-template-part__selection-modal\"\n\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t__( 'Choose a %s' ),\n\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t}\n\t\t\t\t\tisFullScreen={ true }\n\t\t\t\t>\n\t\t\t\t\t<TemplatePartSelectionModal\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonClose={ () =>\n\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -58,7 +58,7 @@ function useAlternativeTemplateParts(area, excludedId) {
58
58
  };
59
59
  return {
60
60
  templateParts: getEntityRecords('postType', 'wp_template_part', query),
61
- isLoading: _isResolving('getEntityRecords', ['postType', 'wp_template_part', query])
61
+ isResolving: _isResolving('getEntityRecords', ['postType', 'wp_template_part', query])
62
62
  };
63
63
  }, []);
64
64
  const filteredTemplateParts = (0, _element.useMemo)(() => {
@@ -67,7 +67,7 @@ function useAlternativeTemplateParts(area, excludedId) {
67
67
  }
68
68
 
69
69
  return templateParts.filter(templatePart => (0, _createTemplatePartId.createTemplatePartId)(templatePart.theme, templatePart.slug) !== excludedId && (!area || 'uncategorized' === area || templatePart.area === area)) || [];
70
- }, [templateParts, area]);
70
+ }, [templateParts, area, excludedId]);
71
71
  return {
72
72
  templateParts: filteredTemplateParts,
73
73
  isResolving
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/template-part/edit/utils/hooks.js"],"names":["useAlternativeTemplateParts","area","excludedId","templateParts","isResolving","select","getEntityRecords","_isResolving","coreStore","query","per_page","isLoading","filteredTemplateParts","filter","templatePart","theme","slug","useAlternativeBlockPatterns","clientId","blockNameWithArea","getBlockRootClientId","getPatternsByBlockTypes","blockEditorStore","rootClientId","useCreateTemplatePartFromBlocks","setAttributes","saveEntityRecord","blocks","title","cleanSlug","replace","record","content","undefined","useTemplatePartArea","definedAreas","__experimentalGetDefaultTemplatePartAreas","selectedArea","find","definedArea","defaultArea","icon","label","tagName","area_tag"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,2BAAT,CAAsCC,IAAtC,EAA4CC,UAA5C,EAAyD;AAC/D,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAAiC,qBAAaC,MAAF,IAAc;AAC/D,UAAM;AAAEC,MAAAA,gBAAF;AAAoBF,MAAAA,WAAW,EAAEG;AAAjC,QACLF,MAAM,CAAEG,eAAF,CADP;AAEA,UAAMC,KAAK,GAAG;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAAd;AACA,WAAO;AACNP,MAAAA,aAAa,EAAEG,gBAAgB,CAC9B,UAD8B,EAE9B,kBAF8B,EAG9BG,KAH8B,CADzB;AAMNE,MAAAA,SAAS,EAAEJ,YAAY,CAAE,kBAAF,EAAsB,CAC5C,UAD4C,EAE5C,kBAF4C,EAG5CE,KAH4C,CAAtB;AANjB,KAAP;AAYA,GAhBsC,EAgBpC,EAhBoC,CAAvC;AAkBA,QAAMG,qBAAqB,GAAG,sBAAS,MAAM;AAC5C,QAAK,CAAET,aAAP,EAAuB;AACtB,aAAO,EAAP;AACA;;AACD,WACCA,aAAa,CAACU,MAAd,CACGC,YAAF,IACC,gDACCA,YAAY,CAACC,KADd,EAECD,YAAY,CAACE,IAFd,MAGMd,UAHN,KAIE,CAAED,IAAF,IACD,oBAAoBA,IADnB,IAEDa,YAAY,CAACb,IAAb,KAAsBA,IANvB,CAFF,KASK,EAVN;AAYA,GAhB6B,EAgB3B,CAAEE,aAAF,EAAiBF,IAAjB,CAhB2B,CAA9B;AAkBA,SAAO;AACNE,IAAAA,aAAa,EAAES,qBADT;AAENR,IAAAA;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Gdd,MAAAA,IAAI,EAAEgC;AAHQ,KAAF,CAAb;AAKA,GA5BD;AA6BA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,mBAAT,CAA8BjC,IAA9B,EAAqC;AAC3C,SAAO,qBACJI,MAAF,IAAc;AAAA;;AACb;AACA;;AACA;AACA,UAAM8B,YAAY,GACjB9B,MAAM,CACL,aADK,CAAN,CAEE+B,yCAFF,EADD;AAIA;;;AAEA,UAAMC,YAAY,GAAGF,YAAY,CAACG,IAAb,CAClBC,WAAF,IAAmBA,WAAW,CAACtC,IAAZ,KAAqBA,IADpB,CAArB;AAGA,UAAMuC,WAAW,GAAGL,YAAY,CAACG,IAAb,CACjBC,WAAF,IAAmBA,WAAW,CAACtC,IAAZ,KAAqB,eADrB,CAApB;AAIA,WAAO;AACNwC,MAAAA,IAAI,EAAE,CAAAJ,YAAY,SAAZ,IAAAA,YAAY,WAAZ,YAAAA,YAAY,CAAEI,IAAd,MAAsBD,WAAtB,aAAsBA,WAAtB,uBAAsBA,WAAW,CAAEC,IAAnC,CADA;AAENC,MAAAA,KAAK,EAAE,CAAAL,YAAY,SAAZ,IAAAA,YAAY,WAAZ,YAAAA,YAAY,CAAEK,KAAd,KAAuB,cAAI,eAAJ,CAFxB;AAGNC,MAAAA,OAAO,2BAAEN,YAAF,aAAEA,YAAF,uBAAEA,YAAY,CAAEO,QAAhB,yEAA4B;AAH7B,KAAP;AAKA,GAvBK,EAwBN,CAAE3C,IAAF,CAxBM,CAAP;AA0BA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useMemo } from '@wordpress/element';\nimport { serialize } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { createTemplatePartId } from './create-template-part-id';\n\n/**\n * Retrieves the available template parts for the given area.\n *\n * @param {string} area Template part area.\n * @param {string} excludedId Template part ID to exclude.\n *\n * @return {{ templateParts: Array, isResolving: boolean }} array of template parts.\n */\nexport function useAlternativeTemplateParts( area, excludedId ) {\n\tconst { templateParts, isResolving } = useSelect( ( select ) => {\n\t\tconst { getEntityRecords, isResolving: _isResolving } =\n\t\t\tselect( coreStore );\n\t\tconst query = { per_page: -1 };\n\t\treturn {\n\t\t\ttemplateParts: getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\tquery\n\t\t\t),\n\t\t\tisLoading: _isResolving( 'getEntityRecords', [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\tquery,\n\t\t\t] ),\n\t\t};\n\t}, [] );\n\n\tconst filteredTemplateParts = useMemo( () => {\n\t\tif ( ! templateParts ) {\n\t\t\treturn [];\n\t\t}\n\t\treturn (\n\t\t\ttemplateParts.filter(\n\t\t\t\t( templatePart ) =>\n\t\t\t\t\tcreateTemplatePartId(\n\t\t\t\t\t\ttemplatePart.theme,\n\t\t\t\t\t\ttemplatePart.slug\n\t\t\t\t\t) !== excludedId &&\n\t\t\t\t\t( ! area ||\n\t\t\t\t\t\t'uncategorized' === area ||\n\t\t\t\t\t\ttemplatePart.area === area )\n\t\t\t) || []\n\t\t);\n\t}, [ templateParts, area ] );\n\n\treturn {\n\t\ttemplateParts: filteredTemplateParts,\n\t\tisResolving,\n\t};\n}\n\n/**\n * Retrieves the available block patterns for the given area.\n *\n * @param {string} area Template part area.\n * @param {string} clientId Block Client ID. (The container of the block can impact allowed blocks).\n *\n * @return {Array} array of block patterns.\n */\nexport function useAlternativeBlockPatterns( area, clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst blockNameWithArea = area\n\t\t\t\t? `core/template-part/${ area }`\n\t\t\t\t: 'core/template-part';\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( blockNameWithArea, rootClientId );\n\t\t},\n\t\t[ area, clientId ]\n\t);\n}\n\nexport function useCreateTemplatePartFromBlocks( area, setAttributes ) {\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\treturn async ( blocks = [], title = __( 'Untitled Template Part' ) ) => {\n\t\t// Currently template parts only allow latin chars.\n\t\t// Fallback slug will receive suffix by default.\n\t\tconst cleanSlug =\n\t\t\tkebabCase( title ).replace( /[^\\w-]+/g, '' ) || 'wp-custom-part';\n\n\t\t// If we have `area` set from block attributes, means an exposed\n\t\t// block variation was inserted. So add this prop to the template\n\t\t// part entity on creation. Afterwards remove `area` value from\n\t\t// block attributes.\n\t\tconst record = {\n\t\t\ttitle,\n\t\t\tslug: cleanSlug,\n\t\t\tcontent: serialize( blocks ),\n\t\t\t// `area` is filterable on the server and defaults to `UNCATEGORIZED`\n\t\t\t// if provided value is not allowed.\n\t\t\tarea,\n\t\t};\n\t\tconst templatePart = await saveEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\trecord\n\t\t);\n\t\tsetAttributes( {\n\t\t\tslug: templatePart.slug,\n\t\t\ttheme: templatePart.theme,\n\t\t\tarea: undefined,\n\t\t} );\n\t};\n}\n\n/**\n * Retrieves the template part area object.\n *\n * @param {string} area Template part area identifier.\n *\n * @return {{icon: Object, label: string, tagName: string}} Template Part area.\n */\nexport function useTemplatePartArea( area ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t\t\t// Blocks can be loaded into a *non-post* block editor.\n\t\t\t/* eslint-disable @wordpress/data-no-store-string-literals */\n\t\t\tconst definedAreas =\n\t\t\t\tselect(\n\t\t\t\t\t'core/editor'\n\t\t\t\t).__experimentalGetDefaultTemplatePartAreas();\n\t\t\t/* eslint-enable @wordpress/data-no-store-string-literals */\n\n\t\t\tconst selectedArea = definedAreas.find(\n\t\t\t\t( definedArea ) => definedArea.area === area\n\t\t\t);\n\t\t\tconst defaultArea = definedAreas.find(\n\t\t\t\t( definedArea ) => definedArea.area === 'uncategorized'\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\ticon: selectedArea?.icon || defaultArea?.icon,\n\t\t\t\tlabel: selectedArea?.label || __( 'Template Part' ),\n\t\t\t\ttagName: selectedArea?.area_tag ?? 'div',\n\t\t\t};\n\t\t},\n\t\t[ area ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/template-part/edit/utils/hooks.js"],"names":["useAlternativeTemplateParts","area","excludedId","templateParts","isResolving","select","getEntityRecords","_isResolving","coreStore","query","per_page","filteredTemplateParts","filter","templatePart","theme","slug","useAlternativeBlockPatterns","clientId","blockNameWithArea","getBlockRootClientId","getPatternsByBlockTypes","blockEditorStore","rootClientId","useCreateTemplatePartFromBlocks","setAttributes","saveEntityRecord","blocks","title","cleanSlug","replace","record","content","undefined","useTemplatePartArea","definedAreas","__experimentalGetDefaultTemplatePartAreas","selectedArea","find","definedArea","defaultArea","icon","label","tagName","area_tag"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,2BAAT,CAAsCC,IAAtC,EAA4CC,UAA5C,EAAyD;AAC/D,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAAiC,qBAAaC,MAAF,IAAc;AAC/D,UAAM;AAAEC,MAAAA,gBAAF;AAAoBF,MAAAA,WAAW,EAAEG;AAAjC,QACLF,MAAM,CAAEG,eAAF,CADP;AAEA,UAAMC,KAAK,GAAG;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAAd;AACA,WAAO;AACNP,MAAAA,aAAa,EAAEG,gBAAgB,CAC9B,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AAEI,IAAd,MAAsBD,WAAtB,aAAsBA,WAAtB,uBAAsBA,WAAW,CAAEC,IAAnC,CADA;AAENC,MAAAA,KAAK,EAAE,CAAAL,YAAY,SAAZ,IAAAA,YAAY,WAAZ,YAAAA,YAAY,CAAEK,KAAd,KAAuB,cAAI,eAAJ,CAFxB;AAGNC,MAAAA,OAAO,2BAAEN,YAAF,aAAEA,YAAF,uBAAEA,YAAY,CAAEO,QAAhB,yEAA4B;AAH7B,KAAP;AAKA,GAvBK,EAwBN,CAAE1C,IAAF,CAxBM,CAAP;AA0BA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useMemo } from '@wordpress/element';\nimport { serialize } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { createTemplatePartId } from './create-template-part-id';\n\n/**\n * Retrieves the available template parts for the given area.\n *\n * @param {string} area Template part area.\n * @param {string} excludedId Template part ID to exclude.\n *\n * @return {{ templateParts: Array, isResolving: boolean }} array of template parts.\n */\nexport function useAlternativeTemplateParts( area, excludedId ) {\n\tconst { templateParts, isResolving } = useSelect( ( select ) => {\n\t\tconst { getEntityRecords, isResolving: _isResolving } =\n\t\t\tselect( coreStore );\n\t\tconst query = { per_page: -1 };\n\t\treturn {\n\t\t\ttemplateParts: getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\tquery\n\t\t\t),\n\t\t\tisResolving: _isResolving( 'getEntityRecords', [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\tquery,\n\t\t\t] ),\n\t\t};\n\t}, [] );\n\n\tconst filteredTemplateParts = useMemo( () => {\n\t\tif ( ! templateParts ) {\n\t\t\treturn [];\n\t\t}\n\t\treturn (\n\t\t\ttemplateParts.filter(\n\t\t\t\t( templatePart ) =>\n\t\t\t\t\tcreateTemplatePartId(\n\t\t\t\t\t\ttemplatePart.theme,\n\t\t\t\t\t\ttemplatePart.slug\n\t\t\t\t\t) !== excludedId &&\n\t\t\t\t\t( ! area ||\n\t\t\t\t\t\t'uncategorized' === area ||\n\t\t\t\t\t\ttemplatePart.area === area )\n\t\t\t) || []\n\t\t);\n\t}, [ templateParts, area, excludedId ] );\n\n\treturn {\n\t\ttemplateParts: filteredTemplateParts,\n\t\tisResolving,\n\t};\n}\n\n/**\n * Retrieves the available block patterns for the given area.\n *\n * @param {string} area Template part area.\n * @param {string} clientId Block Client ID. (The container of the block can impact allowed blocks).\n *\n * @return {Array} array of block patterns.\n */\nexport function useAlternativeBlockPatterns( area, clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst blockNameWithArea = area\n\t\t\t\t? `core/template-part/${ area }`\n\t\t\t\t: 'core/template-part';\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( blockNameWithArea, rootClientId );\n\t\t},\n\t\t[ area, clientId ]\n\t);\n}\n\nexport function useCreateTemplatePartFromBlocks( area, setAttributes ) {\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\treturn async ( blocks = [], title = __( 'Untitled Template Part' ) ) => {\n\t\t// Currently template parts only allow latin chars.\n\t\t// Fallback slug will receive suffix by default.\n\t\tconst cleanSlug =\n\t\t\tkebabCase( title ).replace( /[^\\w-]+/g, '' ) || 'wp-custom-part';\n\n\t\t// If we have `area` set from block attributes, means an exposed\n\t\t// block variation was inserted. So add this prop to the template\n\t\t// part entity on creation. Afterwards remove `area` value from\n\t\t// block attributes.\n\t\tconst record = {\n\t\t\ttitle,\n\t\t\tslug: cleanSlug,\n\t\t\tcontent: serialize( blocks ),\n\t\t\t// `area` is filterable on the server and defaults to `UNCATEGORIZED`\n\t\t\t// if provided value is not allowed.\n\t\t\tarea,\n\t\t};\n\t\tconst templatePart = await saveEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\trecord\n\t\t);\n\t\tsetAttributes( {\n\t\t\tslug: templatePart.slug,\n\t\t\ttheme: templatePart.theme,\n\t\t\tarea: undefined,\n\t\t} );\n\t};\n}\n\n/**\n * Retrieves the template part area object.\n *\n * @param {string} area Template part area identifier.\n *\n * @return {{icon: Object, label: string, tagName: string}} Template Part area.\n */\nexport function useTemplatePartArea( area ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t\t\t// Blocks can be loaded into a *non-post* block editor.\n\t\t\t/* eslint-disable @wordpress/data-no-store-string-literals */\n\t\t\tconst definedAreas =\n\t\t\t\tselect(\n\t\t\t\t\t'core/editor'\n\t\t\t\t).__experimentalGetDefaultTemplatePartAreas();\n\t\t\t/* eslint-enable @wordpress/data-no-store-string-literals */\n\n\t\t\tconst selectedArea = definedAreas.find(\n\t\t\t\t( definedArea ) => definedArea.area === area\n\t\t\t);\n\t\t\tconst defaultArea = definedAreas.find(\n\t\t\t\t( definedArea ) => definedArea.area === 'uncategorized'\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\ticon: selectedArea?.icon || defaultArea?.icon,\n\t\t\t\tlabel: selectedArea?.label || __( 'Template Part' ),\n\t\t\t\ttagName: selectedArea?.area_tag ?? 'div',\n\t\t\t};\n\t\t},\n\t\t[ area ]\n\t);\n}\n"]}
@@ -61,8 +61,7 @@ const metadata = {
61
61
  fontSize: true
62
62
  }
63
63
  }
64
- },
65
- editorStyle: "wp-block-term-description-editor"
64
+ }
66
65
  };
67
66
  exports.metadata = metadata;
68
67
  const {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/term-description/index.js"],"names":["name","metadata","settings","icon","edit","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,sBADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB;;;AAKA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEL,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { termDescription 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;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/term-description/index.js"],"names":["name","metadata","settings","icon","edit","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,sBADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB;;;AAKA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEL,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { termDescription 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;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
@@ -1,18 +1,24 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = _default;
9
7
 
10
- var _cleanEmptyObject = _interopRequireDefault(require("./clean-empty-object"));
8
+ var _blockEditor = require("@wordpress/block-editor");
9
+
10
+ var _privateApis = require("../private-apis");
11
11
 
12
12
  /**
13
- * Internal dependencies
13
+ * WordPress dependencies
14
14
  */
15
15
 
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+ const {
20
+ cleanEmptyObject
21
+ } = (0, _privateApis.unlock)(_blockEditor.privateApis);
16
22
  /**
17
23
  * Migrates the current style.typography.fontFamily attribute,
18
24
  * whose value was "var:preset|font-family|helvetica-arial",
@@ -21,6 +27,7 @@ var _cleanEmptyObject = _interopRequireDefault(require("./clean-empty-object"));
21
27
  * @param {Object} attributes The current attributes
22
28
  * @return {Object} The updated attributes.
23
29
  */
30
+
24
31
  function _default(attributes) {
25
32
  var _attributes$style, _attributes$style$typ;
26
33
 
@@ -33,7 +40,7 @@ function _default(attributes) {
33
40
  ...typography
34
41
  } = attributes.style.typography;
35
42
  return { ...attributes,
36
- style: (0, _cleanEmptyObject.default)({ ...attributes.style,
43
+ style: cleanEmptyObject({ ...attributes.style,
37
44
  typography
38
45
  }),
39
46
  fontFamily: fontFamily.split('|').pop()
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/migrate-font-family.js"],"names":["attributes","style","typography","fontFamily","split","pop"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,kBAAWA,UAAX,EAAwB;AAAA;;AACtC,MAAK,EAAEA,UAAF,aAAEA,UAAF,oCAAEA,UAAU,CAAEC,KAAd,uEAAE,kBAAmBC,UAArB,kDAAE,sBAA+BC,UAAjC,CAAL,EAAmD;AAClD,WAAOH,UAAP;AACA;;AAED,QAAM;AAAEG,IAAAA,UAAF;AAAc,OAAGD;AAAjB,MAAgCF,UAAU,CAACC,KAAX,CAAiBC,UAAvD;AAEA,SAAO,EACN,GAAGF,UADG;AAENC,IAAAA,KAAK,EAAE,+BAAkB,EACxB,GAAGD,UAAU,CAACC,KADU;AAExBC,MAAAA;AAFwB,KAAlB,CAFD;AAMNC,IAAAA,UAAU,EAAEA,UAAU,CAACC,KAAX,CAAkB,GAAlB,EAAwBC,GAAxB;AANN,GAAP;AAQA","sourcesContent":["/**\n * Internal dependencies\n */\nimport cleanEmptyObject from './clean-empty-object';\n\n/**\n * Migrates the current style.typography.fontFamily attribute,\n * whose value was \"var:preset|font-family|helvetica-arial\",\n * to the style.fontFamily attribute, whose value will be \"helvetica-arial\".\n *\n * @param {Object} attributes The current attributes\n * @return {Object} The updated attributes.\n */\nexport default function ( attributes ) {\n\tif ( ! attributes?.style?.typography?.fontFamily ) {\n\t\treturn attributes;\n\t}\n\n\tconst { fontFamily, ...typography } = attributes.style.typography;\n\n\treturn {\n\t\t...attributes,\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...attributes.style,\n\t\t\ttypography,\n\t\t} ),\n\t\tfontFamily: fontFamily.split( '|' ).pop(),\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/utils/migrate-font-family.js"],"names":["cleanEmptyObject","blockEditorPrivateApis","attributes","style","typography","fontFamily","split","pop"],"mappings":";;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA;AAAF,IAAuB,yBAAQC,wBAAR,CAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,kBAAWC,UAAX,EAAwB;AAAA;;AACtC,MAAK,EAAEA,UAAF,aAAEA,UAAF,oCAAEA,UAAU,CAAEC,KAAd,uEAAE,kBAAmBC,UAArB,kDAAE,sBAA+BC,UAAjC,CAAL,EAAmD;AAClD,WAAOH,UAAP;AACA;;AAED,QAAM;AAAEG,IAAAA,UAAF;AAAc,OAAGD;AAAjB,MAAgCF,UAAU,CAACC,KAAX,CAAiBC,UAAvD;AAEA,SAAO,EACN,GAAGF,UADG;AAENC,IAAAA,KAAK,EAAEH,gBAAgB,CAAE,EACxB,GAAGE,UAAU,CAACC,KADU;AAExBC,MAAAA;AAFwB,KAAF,CAFjB;AAMNC,IAAAA,UAAU,EAAEA,UAAU,CAACC,KAAX,CAAkB,GAAlB,EAAwBC,GAAxB;AANN,GAAP;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../private-apis';\n\nconst { cleanEmptyObject } = unlock( blockEditorPrivateApis );\n\n/**\n * Migrates the current style.typography.fontFamily attribute,\n * whose value was \"var:preset|font-family|helvetica-arial\",\n * to the style.fontFamily attribute, whose value will be \"helvetica-arial\".\n *\n * @param {Object} attributes The current attributes\n * @return {Object} The updated attributes.\n */\nexport default function ( attributes ) {\n\tif ( ! attributes?.style?.typography?.fontFamily ) {\n\t\treturn attributes;\n\t}\n\n\tconst { fontFamily, ...typography } = attributes.style.typography;\n\n\treturn {\n\t\t...attributes,\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...attributes.style,\n\t\t\ttypography,\n\t\t} ),\n\t\tfontFamily: fontFamily.split( '|' ).pop(),\n\t};\n}\n"]}
@@ -216,8 +216,9 @@ class VideoEdit extends _element.Component {
216
216
  }
217
217
 
218
218
  setAttributes({
219
- id: url,
220
- src: url
219
+ src: url,
220
+ id: undefined,
221
+ poster: undefined
221
222
  });
222
223
  } else {
223
224
  createErrorNotice((0, _i18n.__)('Invalid URL.'));
@@ -292,7 +293,7 @@ class VideoEdit extends _element.Component {
292
293
  }
293
294
  });
294
295
 
295
- if (!id) {
296
+ if (!src) {
296
297
  return (0, _element.createElement)(_reactNative.View, {
297
298
  style: {
298
299
  flex: 1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/video/edit.native.js"],"names":["ICON_TYPE","PLACEHOLDER","RETRY","UPLOAD","VideoEdit","Component","constructor","props","state","isCaptionSelected","videoContainerHeight","mediaUploadStateReset","bind","onSelectMediaUploadOption","onSelectURL","finishMediaUploadWithSuccess","finishMediaUploadWithFailure","updateMediaProgress","onVideoPressed","onVideoContanerLayout","onFocusCaption","componentDidMount","attributes","id","src","componentWillUnmount","isUploadInProgress","getDerivedStateFromProps","isSelected","setState","payload","setAttributes","mediaUrl","url","mediaServerId","mediaId","createErrorNotice","onReplace","embedBlock","undefined","event","width","nativeEvent","layout","height","VIDEO_ASPECT_RATIO","getIcon","iconType","iconStyle","SvgIconRetry","style","icon","getStylesFromColorScheme","iconDark","iconUploading","iconUploadingDark","SvgIcon","render","wasBlockJustInserted","toolbarEditButton","MEDIA_TYPE_VIDEO","open","getMediaOptions","replace","flex","onFocus","isUploadFailed","retryMessage","showVideo","styleIconContainer","modalIconRetry","modalIcon","iconContainer","videoStyle","video","containerStyle","containerFocused","container","videoContainer","uri","placeholderContainer","placeholderContainerDark","uploadFailedText","caption","clientId","onBlur","insertBlocksAfter","select","blockEditorStore","dispatch","noticesStore","withPreferredColorScheme"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AAKA;;AAMA;;AACA;;AAYA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA9CA;AACA;AACA;;AAGA;AACA;AACA;;AAiCA;AACA;AACA;AAMA,MAAMA,SAAS,GAAG;AACjBC,EAAAA,WAAW,EAAE,aADI;AAEjBC,EAAAA,KAAK,EAAE,OAFU;AAGjBC,EAAAA,MAAM,EAAE;AAHS,CAAlB;;AAMA,MAAMC,SAAN,SAAwBC,kBAAxB,CAAkC;AACjCC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AAEA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AS,CACvB,sBAAY,CAAEC,MAAF;AAAA,MAAU;AAAEH,IAAAA;AAAF,GAAV;AAAA,SAA8B;AACzC1B,IAAAA,oBAAoB,EAAE6B,MAAM,CAAEC,kBAAF,CAAN,CAA2B9B,oBAA3B,CACrB0B,QADqB,EAErB,eAFqB;AADmB,GAA9B;AAAA,CAAZ,CADuB,EAOvB,wBAAgBK,QAAF,IAAgB;AAC7B,QAAM;AAAErD,IAAAA;AAAF,MAAwBqD,QAAQ,CAAEC,cAAF,CAAtC;AAEA,SAAO;AAAEtD,IAAAA;AAAF,GAAP;AACA,CAJD,CAPuB,EAYvBuD,iCAZuB,CAAT,EAaVvF,SAbU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View, TouchableWithoutFeedback, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport {\n\tmediaUploadSync,\n\trequestImageFailedRetryDialog,\n\trequestImageUploadCancelDialog,\n} from '@wordpress/react-native-bridge';\nimport {\n\tIcon,\n\tToolbarButton,\n\tToolbarGroup,\n\tPanelBody,\n} from '@wordpress/components';\nimport { withPreferredColorScheme, compose } from '@wordpress/compose';\nimport {\n\tBlockCaption,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadProgress,\n\tMEDIA_TYPE_VIDEO,\n\tBlockControls,\n\tVIDEO_ASPECT_RATIO,\n\tVideoPlayer,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { isURL, getProtocol } from '@wordpress/url';\nimport { doAction, hasAction } from '@wordpress/hooks';\nimport { video as SvgIcon, replace } from '@wordpress/icons';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport style from './style.scss';\nimport SvgIconRetry from './icon-retry';\nimport VideoCommonSettings from './edit-common-settings';\n\nconst ICON_TYPE = {\n\tPLACEHOLDER: 'placeholder',\n\tRETRY: 'retry',\n\tUPLOAD: 'upload',\n};\n\nclass VideoEdit extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.state = {\n\t\t\tisCaptionSelected: false,\n\t\t\tvideoContainerHeight: 0,\n\t\t};\n\n\t\tthis.mediaUploadStateReset = this.mediaUploadStateReset.bind( this );\n\t\tthis.onSelectMediaUploadOption =\n\t\t\tthis.onSelectMediaUploadOption.bind( this );\n\t\tthis.onSelectURL = this.onSelectURL.bind( this );\n\t\tthis.finishMediaUploadWithSuccess =\n\t\t\tthis.finishMediaUploadWithSuccess.bind( this );\n\t\tthis.finishMediaUploadWithFailure =\n\t\t\tthis.finishMediaUploadWithFailure.bind( this );\n\t\tthis.updateMediaProgress = this.updateMediaProgress.bind( this );\n\t\tthis.onVideoPressed = this.onVideoPressed.bind( this );\n\t\tthis.onVideoContanerLayout = this.onVideoContanerLayout.bind( this );\n\t\tthis.onFocusCaption = this.onFocusCaption.bind( this );\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { attributes } = this.props;\n\t\tif ( attributes.id && getProtocol( attributes.src ) === 'file:' ) {\n\t\t\tmediaUploadSync();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\t// This action will only exist if the user pressed the trash button on the block holder.\n\t\tif (\n\t\t\thasAction( 'blocks.onRemoveBlockCheckUpload' ) &&\n\t\t\tthis.state.isUploadInProgress\n\t\t) {\n\t\t\tdoAction(\n\t\t\t\t'blocks.onRemoveBlockCheckUpload',\n\t\t\t\tthis.props.attributes.id\n\t\t\t);\n\t\t}\n\t}\n\n\tstatic getDerivedStateFromProps( props, state ) {\n\t\t// Avoid a UI flicker in the toolbar by insuring that isCaptionSelected\n\t\t// is updated immediately any time the isSelected prop becomes false.\n\t\treturn {\n\t\t\tisCaptionSelected: props.isSelected && state.isCaptionSelected,\n\t\t};\n\t}\n\n\tonVideoPressed() {\n\t\tconst { attributes } = this.props;\n\n\t\tif ( this.state.isUploadInProgress ) {\n\t\t\trequestImageUploadCancelDialog( attributes.id );\n\t\t} else if (\n\t\t\tattributes.id &&\n\t\t\tgetProtocol( attributes.src ) === 'file:'\n\t\t) {\n\t\t\trequestImageFailedRetryDialog( attributes.id );\n\t\t}\n\n\t\tthis.setState( {\n\t\t\tisCaptionSelected: false,\n\t\t} );\n\t}\n\n\tonFocusCaption() {\n\t\tif ( ! this.state.isCaptionSelected ) {\n\t\t\tthis.setState( { isCaptionSelected: true } );\n\t\t}\n\t}\n\n\tupdateMediaProgress( payload ) {\n\t\tconst { setAttributes } = this.props;\n\t\tif ( payload.mediaUrl ) {\n\t\t\tsetAttributes( { url: payload.mediaUrl } );\n\t\t}\n\t\tif ( ! this.state.isUploadInProgress ) {\n\t\t\tthis.setState( { isUploadInProgress: true } );\n\t\t}\n\t}\n\n\tfinishMediaUploadWithSuccess( payload ) {\n\t\tconst { setAttributes } = this.props;\n\t\tsetAttributes( { src: payload.mediaUrl, id: payload.mediaServerId } );\n\t\tthis.setState( { isUploadInProgress: false } );\n\t}\n\n\tfinishMediaUploadWithFailure( payload ) {\n\t\tconst { setAttributes } = this.props;\n\t\tsetAttributes( { id: payload.mediaId } );\n\t\tthis.setState( { isUploadInProgress: false } );\n\t}\n\n\tmediaUploadStateReset() {\n\t\tconst { setAttributes } = this.props;\n\t\tsetAttributes( { id: null, src: null } );\n\t\tthis.setState( { isUploadInProgress: false } );\n\t}\n\n\tonSelectMediaUploadOption( { id, url } ) {\n\t\tconst { setAttributes } = this.props;\n\t\tsetAttributes( { id, src: url } );\n\t}\n\n\tonSelectURL( url ) {\n\t\tconst { createErrorNotice, onReplace, setAttributes } = this.props;\n\n\t\tif ( isURL( url ) ) {\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 },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetAttributes( { id: url, src: url } );\n\t\t} else {\n\t\t\tcreateErrorNotice( __( 'Invalid URL.' ) );\n\t\t}\n\t}\n\n\tonVideoContanerLayout( event ) {\n\t\tconst { width } = event.nativeEvent.layout;\n\t\tconst height = width / VIDEO_ASPECT_RATIO;\n\t\tif ( height !== this.state.videoContainerHeight ) {\n\t\t\tthis.setState( { videoContainerHeight: height } );\n\t\t}\n\t}\n\n\tgetIcon( iconType ) {\n\t\tlet iconStyle;\n\t\tswitch ( iconType ) {\n\t\t\tcase ICON_TYPE.RETRY:\n\t\t\t\treturn <Icon icon={ SvgIconRetry } { ...style.icon } />;\n\t\t\tcase ICON_TYPE.PLACEHOLDER:\n\t\t\t\ticonStyle = this.props.getStylesFromColorScheme(\n\t\t\t\t\tstyle.icon,\n\t\t\t\t\tstyle.iconDark\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase ICON_TYPE.UPLOAD:\n\t\t\t\ticonStyle = this.props.getStylesFromColorScheme(\n\t\t\t\t\tstyle.iconUploading,\n\t\t\t\t\tstyle.iconUploadingDark\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn <Icon icon={ SvgIcon } { ...iconStyle } />;\n\t}\n\n\trender() {\n\t\tconst { setAttributes, attributes, isSelected, wasBlockJustInserted } =\n\t\t\tthis.props;\n\t\tconst { id, src } = attributes;\n\t\tconst { videoContainerHeight } = this.state;\n\n\t\tconst toolbarEditButton = (\n\t\t\t<MediaUpload\n\t\t\t\tallowedTypes={ [ MEDIA_TYPE_VIDEO ] }\n\t\t\t\tisReplacingMedia={ true }\n\t\t\t\tonSelect={ this.onSelectMediaUploadOption }\n\t\t\t\tonSelectURL={ this.onSelectURL }\n\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t{ getMediaOptions() }\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\tlabel={ __( 'Edit video' ) }\n\t\t\t\t\t\t\t\ticon={ replace }\n\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t></MediaUpload>\n\t\t);\n\n\t\tif ( ! id ) {\n\t\t\treturn (\n\t\t\t\t<View style={ { flex: 1 } }>\n\t\t\t\t\t<MediaPlaceholder\n\t\t\t\t\t\tallowedTypes={ [ MEDIA_TYPE_VIDEO ] }\n\t\t\t\t\t\tonSelect={ this.onSelectMediaUploadOption }\n\t\t\t\t\t\tonSelectURL={ this.onSelectURL }\n\t\t\t\t\t\ticon={ this.getIcon( ICON_TYPE.PLACEHOLDER ) }\n\t\t\t\t\t\tonFocus={ this.props.onFocus }\n\t\t\t\t\t\tautoOpenMediaUpload={\n\t\t\t\t\t\t\tisSelected && wasBlockJustInserted\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\taccessible={ ! isSelected }\n\t\t\t\tonPress={ this.onVideoPressed }\n\t\t\t\tdisabled={ ! isSelected }\n\t\t\t>\n\t\t\t\t<View style={ { flex: 1 } }>\n\t\t\t\t\t{ ! this.state.isCaptionSelected && (\n\t\t\t\t\t\t<BlockControls>{ toolbarEditButton }</BlockControls>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isSelected && (\n\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t\t\t<VideoCommonSettings\n\t\t\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t) }\n\t\t\t\t\t<MediaUploadProgress\n\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\tonFinishMediaUploadWithSuccess={\n\t\t\t\t\t\t\tthis.finishMediaUploadWithSuccess\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonFinishMediaUploadWithFailure={\n\t\t\t\t\t\t\tthis.finishMediaUploadWithFailure\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonUpdateMediaProgress={ this.updateMediaProgress }\n\t\t\t\t\t\tonMediaUploadStateReset={ this.mediaUploadStateReset }\n\t\t\t\t\t\trenderContent={ ( {\n\t\t\t\t\t\t\tisUploadInProgress,\n\t\t\t\t\t\t\tisUploadFailed,\n\t\t\t\t\t\t\tretryMessage,\n\t\t\t\t\t\t} ) => {\n\t\t\t\t\t\t\tconst showVideo =\n\t\t\t\t\t\t\t\tisURL( src ) &&\n\t\t\t\t\t\t\t\t! isUploadInProgress &&\n\t\t\t\t\t\t\t\t! isUploadFailed;\n\t\t\t\t\t\t\tconst icon = this.getIcon(\n\t\t\t\t\t\t\t\tisUploadFailed\n\t\t\t\t\t\t\t\t\t? ICON_TYPE.RETRY\n\t\t\t\t\t\t\t\t\t: ICON_TYPE.UPLOAD\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst styleIconContainer = isUploadFailed\n\t\t\t\t\t\t\t\t? style.modalIconRetry\n\t\t\t\t\t\t\t\t: style.modalIcon;\n\n\t\t\t\t\t\t\tconst iconContainer = (\n\t\t\t\t\t\t\t\t<View style={ styleIconContainer }>\n\t\t\t\t\t\t\t\t\t{ icon }\n\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst videoStyle = {\n\t\t\t\t\t\t\t\theight: videoContainerHeight,\n\t\t\t\t\t\t\t\t...style.video,\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tconst containerStyle =\n\t\t\t\t\t\t\t\tshowVideo && isSelected\n\t\t\t\t\t\t\t\t\t? style.containerFocused\n\t\t\t\t\t\t\t\t\t: style.container;\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\tonLayout={ this.onVideoContanerLayout }\n\t\t\t\t\t\t\t\t\tstyle={ containerStyle }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ showVideo && (\n\t\t\t\t\t\t\t\t\t\t<View style={ style.videoContainer }>\n\t\t\t\t\t\t\t\t\t\t\t<VideoPlayer\n\t\t\t\t\t\t\t\t\t\t\t\tisSelected={\n\t\t\t\t\t\t\t\t\t\t\t\t\tisSelected &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t! this.state\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t.isCaptionSelected\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={ videoStyle }\n\t\t\t\t\t\t\t\t\t\t\t\tsource={ { uri: src } }\n\t\t\t\t\t\t\t\t\t\t\t\tpaused={ true }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ! showVideo && (\n\t\t\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\theight: videoContainerHeight,\n\t\t\t\t\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\t\t\t\t\t...this.props.getStylesFromColorScheme(\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle.placeholderContainer,\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle.placeholderContainerDark\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ videoContainerHeight > 0 &&\n\t\t\t\t\t\t\t\t\t\t\t\ticonContainer }\n\t\t\t\t\t\t\t\t\t\t\t{ isUploadFailed && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstyle.uploadFailedText\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ retryMessage }\n\t\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</View>\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\t<BlockCaption\n\t\t\t\t\t\taccessible={ true }\n\t\t\t\t\t\taccessibilityLabelCreator={ ( caption ) =>\n\t\t\t\t\t\t\t! caption\n\t\t\t\t\t\t\t\t? /* translators: accessibility text. Empty video caption. */\n\t\t\t\t\t\t\t\t __( 'Video caption. Empty' )\n\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text. %s: video caption. */\n\t\t\t\t\t\t\t\t\t\t__( 'Video caption. %s' ),\n\t\t\t\t\t\t\t\t\t\tcaption\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclientId={ this.props.clientId }\n\t\t\t\t\t\tisSelected={ this.state.isCaptionSelected }\n\t\t\t\t\t\tonFocus={ this.onFocusCaption }\n\t\t\t\t\t\tonBlur={ this.props.onBlur } // Always assign onBlur as props.\n\t\t\t\t\t\tinsertBlocksAfter={ this.props.insertBlocksAfter }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select, { clientId } ) => ( {\n\t\twasBlockJustInserted: select( blockEditorStore ).wasBlockJustInserted(\n\t\t\tclientId,\n\t\t\t'inserter_menu'\n\t\t),\n\t} ) ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { createErrorNotice } = dispatch( noticesStore );\n\n\t\treturn { createErrorNotice };\n\t} ),\n\twithPreferredColorScheme,\n] )( VideoEdit );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/video/edit.native.js"],"names":["ICON_TYPE","PLACEHOLDER","RETRY","UPLOAD","VideoEdit","Component","constructor","props","state","isCaptionSelected","videoContainerHeight","mediaUploadStateReset","bind","onSelectMediaUploadOption","onSelectURL","finishMediaUploadWithSuccess","finishMediaUploadWithFailure","updateMediaProgress","onVideoPressed","onVideoContanerLayout","onFocusCaption","componentDidMount","attributes","id","src","componentWillUnmount","isUploadInProgress","getDerivedStateFromProps","isSelected","setState","payload","setAttributes","mediaUrl","url","mediaServerId","mediaId","createErrorNotice","onReplace","embedBlock","undefined","poster","event","width","nativeEvent","layout","height","VIDEO_ASPECT_RATIO","getIcon","iconType","iconStyle","SvgIconRetry","style","icon","getStylesFromColorScheme","iconDark","iconUploading","iconUploadingDark","SvgIcon","render","wasBlockJustInserted","toolbarEditButton","MEDIA_TYPE_VIDEO","open","getMediaOptions","replace","flex","onFocus","isUploadFailed","retryMessage","showVideo","styleIconContainer","modalIconRetry","modalIcon","iconContainer","videoStyle","video","containerStyle","containerFocused","container","videoContainer","uri","placeholderContainer","placeholderContainerDark","uploadFailedText","caption","clientId","onBlur","insertBlocksAfter","select","blockEditorStore","dispatch","noticesStore","withPreferredColorScheme"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AAKA;;AAMA;;AACA;;AAYA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA9CA;AACA;AACA;;AAGA;AACA;AACA;;AAiCA;AACA;AACA;AAMA,MAAMA,SAAS,GAAG;AACjBC,EAAAA,WAAW,EAAE,aADI;AAEjBC,EAAAA,KAAK,EAAE,OAFU;AAGjBC,EAAAA,MAAM,EAAE;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AAM,EAAG,KAAKb,KAAL,CAAW+E,MAfrB,CAe8B;AAf9B;AAgBC,MAAA,iBAAiB,EAAG,KAAK/E,KAAL,CAAWgF;AAhBhC,MAzGD,CALD,CADD;AAoIA;;AA5UgC;;eA+UnB,sBAAS,CACvB,sBAAY,CAAEC,MAAF;AAAA,MAAU;AAAEH,IAAAA;AAAF,GAAV;AAAA,SAA8B;AACzC1B,IAAAA,oBAAoB,EAAE6B,MAAM,CAAEC,kBAAF,CAAN,CAA2B9B,oBAA3B,CACrB0B,QADqB,EAErB,eAFqB;AADmB,GAA9B;AAAA,CAAZ,CADuB,EAOvB,wBAAgBK,QAAF,IAAgB;AAC7B,QAAM;AAAEtD,IAAAA;AAAF,MAAwBsD,QAAQ,CAAEC,cAAF,CAAtC;AAEA,SAAO;AAAEvD,IAAAA;AAAF,GAAP;AACA,CAJD,CAPuB,EAYvBwD,iCAZuB,CAAT,EAaVxF,SAbU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View, TouchableWithoutFeedback, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport {\n\tmediaUploadSync,\n\trequestImageFailedRetryDialog,\n\trequestImageUploadCancelDialog,\n} from '@wordpress/react-native-bridge';\nimport {\n\tIcon,\n\tToolbarButton,\n\tToolbarGroup,\n\tPanelBody,\n} from '@wordpress/components';\nimport { withPreferredColorScheme, compose } from '@wordpress/compose';\nimport {\n\tBlockCaption,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadProgress,\n\tMEDIA_TYPE_VIDEO,\n\tBlockControls,\n\tVIDEO_ASPECT_RATIO,\n\tVideoPlayer,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { isURL, getProtocol } from '@wordpress/url';\nimport { doAction, hasAction } from '@wordpress/hooks';\nimport { video as SvgIcon, replace } from '@wordpress/icons';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport style from './style.scss';\nimport SvgIconRetry from './icon-retry';\nimport VideoCommonSettings from './edit-common-settings';\n\nconst ICON_TYPE = {\n\tPLACEHOLDER: 'placeholder',\n\tRETRY: 'retry',\n\tUPLOAD: 'upload',\n};\n\nclass VideoEdit extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.state = {\n\t\t\tisCaptionSelected: false,\n\t\t\tvideoContainerHeight: 0,\n\t\t};\n\n\t\tthis.mediaUploadStateReset = this.mediaUploadStateReset.bind( this );\n\t\tthis.onSelectMediaUploadOption =\n\t\t\tthis.onSelectMediaUploadOption.bind( this );\n\t\tthis.onSelectURL = this.onSelectURL.bind( this );\n\t\tthis.finishMediaUploadWithSuccess =\n\t\t\tthis.finishMediaUploadWithSuccess.bind( this );\n\t\tthis.finishMediaUploadWithFailure =\n\t\t\tthis.finishMediaUploadWithFailure.bind( this );\n\t\tthis.updateMediaProgress = this.updateMediaProgress.bind( this );\n\t\tthis.onVideoPressed = this.onVideoPressed.bind( this );\n\t\tthis.onVideoContanerLayout = this.onVideoContanerLayout.bind( this );\n\t\tthis.onFocusCaption = this.onFocusCaption.bind( this );\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { attributes } = this.props;\n\t\tif ( attributes.id && getProtocol( attributes.src ) === 'file:' ) {\n\t\t\tmediaUploadSync();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\t// This action will only exist if the user pressed the trash button on the block holder.\n\t\tif (\n\t\t\thasAction( 'blocks.onRemoveBlockCheckUpload' ) &&\n\t\t\tthis.state.isUploadInProgress\n\t\t) {\n\t\t\tdoAction(\n\t\t\t\t'blocks.onRemoveBlockCheckUpload',\n\t\t\t\tthis.props.attributes.id\n\t\t\t);\n\t\t}\n\t}\n\n\tstatic getDerivedStateFromProps( props, state ) {\n\t\t// Avoid a UI flicker in the toolbar by insuring that isCaptionSelected\n\t\t// is updated immediately any time the isSelected prop becomes false.\n\t\treturn {\n\t\t\tisCaptionSelected: props.isSelected && state.isCaptionSelected,\n\t\t};\n\t}\n\n\tonVideoPressed() {\n\t\tconst { attributes } = this.props;\n\n\t\tif ( this.state.isUploadInProgress ) {\n\t\t\trequestImageUploadCancelDialog( attributes.id );\n\t\t} else if (\n\t\t\tattributes.id &&\n\t\t\tgetProtocol( attributes.src ) === 'file:'\n\t\t) {\n\t\t\trequestImageFailedRetryDialog( attributes.id );\n\t\t}\n\n\t\tthis.setState( {\n\t\t\tisCaptionSelected: false,\n\t\t} );\n\t}\n\n\tonFocusCaption() {\n\t\tif ( ! this.state.isCaptionSelected ) {\n\t\t\tthis.setState( { isCaptionSelected: true } );\n\t\t}\n\t}\n\n\tupdateMediaProgress( payload ) {\n\t\tconst { setAttributes } = this.props;\n\t\tif ( payload.mediaUrl ) {\n\t\t\tsetAttributes( { url: payload.mediaUrl } );\n\t\t}\n\t\tif ( ! this.state.isUploadInProgress ) {\n\t\t\tthis.setState( { isUploadInProgress: true } );\n\t\t}\n\t}\n\n\tfinishMediaUploadWithSuccess( payload ) {\n\t\tconst { setAttributes } = this.props;\n\t\tsetAttributes( { src: payload.mediaUrl, id: payload.mediaServerId } );\n\t\tthis.setState( { isUploadInProgress: false } );\n\t}\n\n\tfinishMediaUploadWithFailure( payload ) {\n\t\tconst { setAttributes } = this.props;\n\t\tsetAttributes( { id: payload.mediaId } );\n\t\tthis.setState( { isUploadInProgress: false } );\n\t}\n\n\tmediaUploadStateReset() {\n\t\tconst { setAttributes } = this.props;\n\t\tsetAttributes( { id: null, src: null } );\n\t\tthis.setState( { isUploadInProgress: false } );\n\t}\n\n\tonSelectMediaUploadOption( { id, url } ) {\n\t\tconst { setAttributes } = this.props;\n\t\tsetAttributes( { id, src: url } );\n\t}\n\n\tonSelectURL( url ) {\n\t\tconst { createErrorNotice, onReplace, setAttributes } = this.props;\n\n\t\tif ( isURL( url ) ) {\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 },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetAttributes( { src: url, id: undefined, poster: undefined } );\n\t\t} else {\n\t\t\tcreateErrorNotice( __( 'Invalid URL.' ) );\n\t\t}\n\t}\n\n\tonVideoContanerLayout( event ) {\n\t\tconst { width } = event.nativeEvent.layout;\n\t\tconst height = width / VIDEO_ASPECT_RATIO;\n\t\tif ( height !== this.state.videoContainerHeight ) {\n\t\t\tthis.setState( { videoContainerHeight: height } );\n\t\t}\n\t}\n\n\tgetIcon( iconType ) {\n\t\tlet iconStyle;\n\t\tswitch ( iconType ) {\n\t\t\tcase ICON_TYPE.RETRY:\n\t\t\t\treturn <Icon icon={ SvgIconRetry } { ...style.icon } />;\n\t\t\tcase ICON_TYPE.PLACEHOLDER:\n\t\t\t\ticonStyle = this.props.getStylesFromColorScheme(\n\t\t\t\t\tstyle.icon,\n\t\t\t\t\tstyle.iconDark\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase ICON_TYPE.UPLOAD:\n\t\t\t\ticonStyle = this.props.getStylesFromColorScheme(\n\t\t\t\t\tstyle.iconUploading,\n\t\t\t\t\tstyle.iconUploadingDark\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn <Icon icon={ SvgIcon } { ...iconStyle } />;\n\t}\n\n\trender() {\n\t\tconst { setAttributes, attributes, isSelected, wasBlockJustInserted } =\n\t\t\tthis.props;\n\t\tconst { id, src } = attributes;\n\t\tconst { videoContainerHeight } = this.state;\n\n\t\tconst toolbarEditButton = (\n\t\t\t<MediaUpload\n\t\t\t\tallowedTypes={ [ MEDIA_TYPE_VIDEO ] }\n\t\t\t\tisReplacingMedia={ true }\n\t\t\t\tonSelect={ this.onSelectMediaUploadOption }\n\t\t\t\tonSelectURL={ this.onSelectURL }\n\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t{ getMediaOptions() }\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\tlabel={ __( 'Edit video' ) }\n\t\t\t\t\t\t\t\ticon={ replace }\n\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t></MediaUpload>\n\t\t);\n\n\t\tif ( ! src ) {\n\t\t\treturn (\n\t\t\t\t<View style={ { flex: 1 } }>\n\t\t\t\t\t<MediaPlaceholder\n\t\t\t\t\t\tallowedTypes={ [ MEDIA_TYPE_VIDEO ] }\n\t\t\t\t\t\tonSelect={ this.onSelectMediaUploadOption }\n\t\t\t\t\t\tonSelectURL={ this.onSelectURL }\n\t\t\t\t\t\ticon={ this.getIcon( ICON_TYPE.PLACEHOLDER ) }\n\t\t\t\t\t\tonFocus={ this.props.onFocus }\n\t\t\t\t\t\tautoOpenMediaUpload={\n\t\t\t\t\t\t\tisSelected && wasBlockJustInserted\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\taccessible={ ! isSelected }\n\t\t\t\tonPress={ this.onVideoPressed }\n\t\t\t\tdisabled={ ! isSelected }\n\t\t\t>\n\t\t\t\t<View style={ { flex: 1 } }>\n\t\t\t\t\t{ ! this.state.isCaptionSelected && (\n\t\t\t\t\t\t<BlockControls>{ toolbarEditButton }</BlockControls>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isSelected && (\n\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t\t\t<VideoCommonSettings\n\t\t\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t) }\n\t\t\t\t\t<MediaUploadProgress\n\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\tonFinishMediaUploadWithSuccess={\n\t\t\t\t\t\t\tthis.finishMediaUploadWithSuccess\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonFinishMediaUploadWithFailure={\n\t\t\t\t\t\t\tthis.finishMediaUploadWithFailure\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonUpdateMediaProgress={ this.updateMediaProgress }\n\t\t\t\t\t\tonMediaUploadStateReset={ this.mediaUploadStateReset }\n\t\t\t\t\t\trenderContent={ ( {\n\t\t\t\t\t\t\tisUploadInProgress,\n\t\t\t\t\t\t\tisUploadFailed,\n\t\t\t\t\t\t\tretryMessage,\n\t\t\t\t\t\t} ) => {\n\t\t\t\t\t\t\tconst showVideo =\n\t\t\t\t\t\t\t\tisURL( src ) &&\n\t\t\t\t\t\t\t\t! isUploadInProgress &&\n\t\t\t\t\t\t\t\t! isUploadFailed;\n\t\t\t\t\t\t\tconst icon = this.getIcon(\n\t\t\t\t\t\t\t\tisUploadFailed\n\t\t\t\t\t\t\t\t\t? ICON_TYPE.RETRY\n\t\t\t\t\t\t\t\t\t: ICON_TYPE.UPLOAD\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst styleIconContainer = isUploadFailed\n\t\t\t\t\t\t\t\t? style.modalIconRetry\n\t\t\t\t\t\t\t\t: style.modalIcon;\n\n\t\t\t\t\t\t\tconst iconContainer = (\n\t\t\t\t\t\t\t\t<View style={ styleIconContainer }>\n\t\t\t\t\t\t\t\t\t{ icon }\n\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst videoStyle = {\n\t\t\t\t\t\t\t\theight: videoContainerHeight,\n\t\t\t\t\t\t\t\t...style.video,\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tconst containerStyle =\n\t\t\t\t\t\t\t\tshowVideo && isSelected\n\t\t\t\t\t\t\t\t\t? style.containerFocused\n\t\t\t\t\t\t\t\t\t: style.container;\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\tonLayout={ this.onVideoContanerLayout }\n\t\t\t\t\t\t\t\t\tstyle={ containerStyle }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ showVideo && (\n\t\t\t\t\t\t\t\t\t\t<View style={ style.videoContainer }>\n\t\t\t\t\t\t\t\t\t\t\t<VideoPlayer\n\t\t\t\t\t\t\t\t\t\t\t\tisSelected={\n\t\t\t\t\t\t\t\t\t\t\t\t\tisSelected &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t! this.state\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t.isCaptionSelected\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={ videoStyle }\n\t\t\t\t\t\t\t\t\t\t\t\tsource={ { uri: src } }\n\t\t\t\t\t\t\t\t\t\t\t\tpaused={ true }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ! showVideo && (\n\t\t\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\theight: videoContainerHeight,\n\t\t\t\t\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\t\t\t\t\t...this.props.getStylesFromColorScheme(\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle.placeholderContainer,\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle.placeholderContainerDark\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ videoContainerHeight > 0 &&\n\t\t\t\t\t\t\t\t\t\t\t\ticonContainer }\n\t\t\t\t\t\t\t\t\t\t\t{ isUploadFailed && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstyle.uploadFailedText\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ retryMessage }\n\t\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</View>\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\t<BlockCaption\n\t\t\t\t\t\taccessible={ true }\n\t\t\t\t\t\taccessibilityLabelCreator={ ( caption ) =>\n\t\t\t\t\t\t\t! caption\n\t\t\t\t\t\t\t\t? /* translators: accessibility text. Empty video caption. */\n\t\t\t\t\t\t\t\t __( 'Video caption. Empty' )\n\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text. %s: video caption. */\n\t\t\t\t\t\t\t\t\t\t__( 'Video caption. %s' ),\n\t\t\t\t\t\t\t\t\t\tcaption\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclientId={ this.props.clientId }\n\t\t\t\t\t\tisSelected={ this.state.isCaptionSelected }\n\t\t\t\t\t\tonFocus={ this.onFocusCaption }\n\t\t\t\t\t\tonBlur={ this.props.onBlur } // Always assign onBlur as props.\n\t\t\t\t\t\tinsertBlocksAfter={ this.props.insertBlocksAfter }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select, { clientId } ) => ( {\n\t\twasBlockJustInserted: select( blockEditorStore ).wasBlockJustInserted(\n\t\t\tclientId,\n\t\t\t'inserter_menu'\n\t\t),\n\t} ) ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { createErrorNotice } = dispatch( noticesStore );\n\n\t\treturn { createErrorNotice };\n\t} ),\n\twithPreferredColorScheme,\n] )( VideoEdit );\n"]}
@@ -49,7 +49,8 @@ const metadata = {
49
49
  blockGap: true,
50
50
  padding: true,
51
51
  __experimentalDefaultControls: {
52
- padding: true
52
+ padding: true,
53
+ blockGap: true
53
54
  }
54
55
  },
55
56
  __experimentalBorder: {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/column/index.js"],"names":["column","icon","initBlock","deprecated","edit","save","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,IAAIC,IAAnB,QAA+B,kBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBP,EAAAA,IADuB;AAEvBG,EAAAA,IAFuB;AAGvBC,EAAAA,IAHuB;AAIvBF,EAAAA;AAJuB,CAAjB;AAOP,OAAO,MAAMM,IAAI,GAAG,MAAMP,SAAS,CAAE;AAAEI,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAF,CAA5B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { column as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/column/index.js"],"names":["column","icon","initBlock","deprecated","edit","save","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,IAAIC,IAAnB,QAA+B,kBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBP,EAAAA,IADuB;AAEvBG,EAAAA,IAFuB;AAGvBC,EAAAA,IAHuB;AAIvBF,EAAAA;AAJuB,CAAjB;AAOP,OAAO,MAAMM,IAAI,GAAG,MAAMP,SAAS,CAAE;AAAEI,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAF,CAA5B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { column as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
@@ -45,11 +45,29 @@ function ColumnsEditContainer(_ref) {
45
45
  } = attributes;
46
46
  const {
47
47
  count,
48
- canInsertColumnBlock
48
+ canInsertColumnBlock,
49
+ minCount
49
50
  } = useSelect(select => {
51
+ const {
52
+ canInsertBlockType,
53
+ canRemoveBlock,
54
+ getBlocks,
55
+ getBlockCount
56
+ } = select(blockEditorStore);
57
+ const innerBlocks = getBlocks(clientId); // Get the indexes of columns for which removal is prevented.
58
+ // The highest index will be used to determine the minimum column count.
59
+
60
+ const preventRemovalBlockIndexes = innerBlocks.reduce((acc, block, index) => {
61
+ if (!canRemoveBlock(block.clientId)) {
62
+ acc.push(index);
63
+ }
64
+
65
+ return acc;
66
+ }, []);
50
67
  return {
51
- count: select(blockEditorStore).getBlockCount(clientId),
52
- canInsertColumnBlock: select(blockEditorStore).canInsertBlockType('core/column', clientId)
68
+ count: getBlockCount(clientId),
69
+ canInsertColumnBlock: canInsertBlockType('core/column', clientId),
70
+ minCount: Math.max(...preventRemovalBlockIndexes) + 1
53
71
  };
54
72
  }, [clientId]);
55
73
  const classes = classnames({
@@ -72,8 +90,8 @@ function ColumnsEditContainer(_ref) {
72
90
  __nextHasNoMarginBottom: true,
73
91
  label: __('Columns'),
74
92
  value: count,
75
- onChange: value => updateColumns(count, value),
76
- min: 1,
93
+ onChange: value => updateColumns(count, Math.max(minCount, value)),
94
+ min: Math.max(1, minCount),
77
95
  max: Math.max(6, count)
78
96
  }), count > 6 && createElement(Notice, {
79
97
  status: "warning",
@@ -162,7 +180,7 @@ const ColumnsEditContainerWrapper = withDispatch((dispatch, ownProps, registry)
162
180
  }).map(() => {
163
181
  return createBlock('core/column');
164
182
  })];
165
- } else {
183
+ } else if (newColumns < previousColumns) {
166
184
  // The removed column will be the last of the inner blocks.
167
185
  innerBlocks = innerBlocks.slice(0, -(previousColumns - newColumns));
168
186
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/columns/edit.js"],"names":["classnames","__","Notice","PanelBody","RangeControl","ToggleControl","InspectorControls","useInnerBlocksProps","BlockControls","BlockVerticalAlignmentToolbar","__experimentalBlockVariationPicker","useBlockProps","store","blockEditorStore","withDispatch","useDispatch","useSelect","createBlock","createBlocksFromInnerBlocksTemplate","blocksStore","hasExplicitPercentColumnWidths","getMappedColumnWidths","getRedistributedColumnWidths","toWidthPrecision","ALLOWED_BLOCKS","ColumnsEditContainer","attributes","setAttributes","updateAlignment","updateColumns","clientId","isStackedOnMobile","verticalAlignment","templateLock","count","canInsertColumnBlock","select","getBlockCount","canInsertBlockType","classes","blockProps","className","innerBlocksProps","allowedBlocks","orientation","renderAppender","value","Math","max","ColumnsEditContainerWrapper","dispatch","ownProps","registry","updateBlockAttributes","getBlockOrder","innerBlockClientIds","forEach","innerBlockClientId","previousColumns","newColumns","replaceInnerBlocks","getBlocks","innerBlocks","hasExplicitWidths","isAddingColumn","newColumnWidth","widths","Array","from","length","map","width","slice","Placeholder","name","blockType","defaultVariation","variations","getBlockVariations","getBlockType","getDefaultBlockVariation","icon","src","title","nextVariation","ColumnsEdit","props","hasInnerBlocks","Component"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,MADD,EAECC,SAFD,EAGCC,YAHD,EAICC,aAJD,QAKO,uBALP;AAOA,SACCC,iBADD,EAECC,mBAFD,EAGCC,aAHD,EAICC,6BAJD,EAKCC,kCALD,EAMCC,aAND,EAOCC,KAAK,IAAIC,gBAPV,QAQO,yBARP;AASA,SAASC,YAAT,EAAuBC,WAAvB,EAAoCC,SAApC,QAAqD,iBAArD;AACA,SACCC,WADD,EAECC,mCAFD,EAGCN,KAAK,IAAIO,WAHV,QAIO,mBAJP;AAMA;AACA;AACA;;AACA,SACCC,8BADD,EAECC,qBAFD,EAGCC,4BAHD,EAICC,gBAJD,Q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;AAIA,SAAO,cAAC,SAAD,EAAgBa,KAAhB,CAAP;AACA,CAZD;;AAcA,eAAeD,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tNotice,\n\tPanelBody,\n\tRangeControl,\n\tToggleControl,\n} from '@wordpress/components';\n\nimport {\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tBlockControls,\n\tBlockVerticalAlignmentToolbar,\n\t__experimentalBlockVariationPicker,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { withDispatch, useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\thasExplicitPercentColumnWidths,\n\tgetMappedColumnWidths,\n\tgetRedistributedColumnWidths,\n\ttoWidthPrecision,\n} from './utils';\n\n/**\n * Allowed blocks constant is passed to InnerBlocks precisely as specified here.\n * The contents of the array should never change.\n * The array should contain the name of each block that is allowed.\n * In columns block, the only block we allow is 'core/column'.\n *\n * @constant\n * @type {string[]}\n */\nconst ALLOWED_BLOCKS = [ 'core/column' ];\n\nfunction ColumnsEditContainer( {\n\tattributes,\n\tsetAttributes,\n\tupdateAlignment,\n\tupdateColumns,\n\tclientId,\n} ) {\n\tconst { isStackedOnMobile, verticalAlignment, templateLock } = attributes;\n\n\tconst { count, canInsertColumnBlock } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tcount: select( blockEditorStore ).getBlockCount( clientId ),\n\t\t\t\tcanInsertColumnBlock: select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).canInsertBlockType( 'core/column', clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst classes = classnames( {\n\t\t[ `are-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,\n\t\t[ `is-not-stacked-on-mobile` ]: ! isStackedOnMobile,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\torientation: 'horizontal',\n\t\trenderAppender: false,\n\t\ttemplateLock,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<BlockVerticalAlignmentToolbar\n\t\t\t\t\tonChange={ updateAlignment }\n\t\t\t\t\tvalue={ verticalAlignment }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t{ canInsertColumnBlock && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\tvalue={ count }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tupdateColumns( count, value )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\t\tmax={ Math.max( 6, count ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ count > 6 && (\n\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Notice>\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\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Stack on mobile' ) }\n\t\t\t\t\t\tchecked={ isStackedOnMobile }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tisStackedOnMobile: ! isStackedOnMobile,\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<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n\nconst ColumnsEditContainerWrapper = withDispatch(\n\t( dispatch, ownProps, registry ) => ( {\n\t\t/**\n\t\t * Update all child Column blocks with a new vertical alignment setting\n\t\t * based on whatever alignment is passed in. This allows change to parent\n\t\t * to overide anything set on a individual column basis.\n\t\t *\n\t\t * @param {string} verticalAlignment the vertical alignment setting\n\t\t */\n\t\tupdateAlignment( verticalAlignment ) {\n\t\t\tconst { clientId, setAttributes } = ownProps;\n\t\t\tconst { updateBlockAttributes } = dispatch( blockEditorStore );\n\t\t\tconst { getBlockOrder } = registry.select( blockEditorStore );\n\n\t\t\t// Update own alignment.\n\t\t\tsetAttributes( { verticalAlignment } );\n\n\t\t\t// Update all child Column Blocks to match.\n\t\t\tconst innerBlockClientIds = getBlockOrder( clientId );\n\t\t\tinnerBlockClientIds.forEach( ( innerBlockClientId ) => {\n\t\t\t\tupdateBlockAttributes( innerBlockClientId, {\n\t\t\t\t\tverticalAlignment,\n\t\t\t\t} );\n\t\t\t} );\n\t\t},\n\n\t\t/**\n\t\t * Updates the column count, including necessary revisions to child Column\n\t\t * blocks to grant required or redistribute available space.\n\t\t *\n\t\t * @param {number} previousColumns Previous column count.\n\t\t * @param {number} newColumns New column count.\n\t\t */\n\t\tupdateColumns( previousColumns, newColumns ) {\n\t\t\tconst { clientId } = ownProps;\n\t\t\tconst { replaceInnerBlocks } = dispatch( blockEditorStore );\n\t\t\tconst { getBlocks } = registry.select( blockEditorStore );\n\n\t\t\tlet innerBlocks = getBlocks( clientId );\n\t\t\tconst hasExplicitWidths =\n\t\t\t\thasExplicitPercentColumnWidths( innerBlocks );\n\n\t\t\t// Redistribute available width for existing inner blocks.\n\t\t\tconst isAddingColumn = newColumns > previousColumns;\n\n\t\t\tif ( isAddingColumn && hasExplicitWidths ) {\n\t\t\t\t// If adding a new column, assign width to the new column equal to\n\t\t\t\t// as if it were `1 / columns` of the total available space.\n\t\t\t\tconst newColumnWidth = toWidthPrecision( 100 / newColumns );\n\n\t\t\t\t// Redistribute in consideration of pending block insertion as\n\t\t\t\t// constraining the available working width.\n\t\t\t\tconst widths = getRedistributedColumnWidths(\n\t\t\t\t\tinnerBlocks,\n\t\t\t\t\t100 - newColumnWidth\n\t\t\t\t);\n\n\t\t\t\tinnerBlocks = [\n\t\t\t\t\t...getMappedColumnWidths( innerBlocks, widths ),\n\t\t\t\t\t...Array.from( {\n\t\t\t\t\t\tlength: newColumns - previousColumns,\n\t\t\t\t\t} ).map( () => {\n\t\t\t\t\t\treturn createBlock( 'core/column', {\n\t\t\t\t\t\t\twidth: `${ newColumnWidth }%`,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} ),\n\t\t\t\t];\n\t\t\t} else if ( isAddingColumn ) {\n\t\t\t\tinnerBlocks = [\n\t\t\t\t\t...innerBlocks,\n\t\t\t\t\t...Array.from( {\n\t\t\t\t\t\tlength: newColumns - previousColumns,\n\t\t\t\t\t} ).map( () => {\n\t\t\t\t\t\treturn createBlock( 'core/column' );\n\t\t\t\t\t} ),\n\t\t\t\t];\n\t\t\t} else {\n\t\t\t\t// The removed column will be the last of the inner blocks.\n\t\t\t\tinnerBlocks = innerBlocks.slice(\n\t\t\t\t\t0,\n\t\t\t\t\t-( previousColumns - newColumns )\n\t\t\t\t);\n\n\t\t\t\tif ( hasExplicitWidths ) {\n\t\t\t\t\t// Redistribute as if block is already removed.\n\t\t\t\t\tconst widths = getRedistributedColumnWidths(\n\t\t\t\t\t\tinnerBlocks,\n\t\t\t\t\t\t100\n\t\t\t\t\t);\n\n\t\t\t\t\tinnerBlocks = getMappedColumnWidths( innerBlocks, widths );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treplaceInnerBlocks( clientId, innerBlocks );\n\t\t},\n\t} )\n)( ColumnsEditContainer );\n\nfunction Placeholder( { clientId, name, setAttributes } ) {\n\tconst { blockType, defaultVariation, variations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetDefaultBlockVariation,\n\t\t\t} = select( blocksStore );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tdefaultVariation: getDefaultBlockVariation( name, 'block' ),\n\t\t\t\tvariations: getBlockVariations( name, 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ name ]\n\t);\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst blockProps = useBlockProps();\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<__experimentalBlockVariationPicker\n\t\t\t\ticon={ blockType?.icon?.src }\n\t\t\t\tlabel={ blockType?.title }\n\t\t\t\tvariations={ variations }\n\t\t\t\tonSelect={ ( nextVariation = defaultVariation ) => {\n\t\t\t\t\tif ( nextVariation.attributes ) {\n\t\t\t\t\t\tsetAttributes( nextVariation.attributes );\n\t\t\t\t\t}\n\t\t\t\t\tif ( nextVariation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tnextVariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\tallowSkip\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nconst ColumnsEdit = ( props ) => {\n\tconst { clientId } = props;\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlocks( clientId ).length > 0,\n\t\t[ clientId ]\n\t);\n\tconst Component = hasInnerBlocks\n\t\t? ColumnsEditContainerWrapper\n\t\t: Placeholder;\n\n\treturn <Component { ...props } />;\n};\n\nexport default ColumnsEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/columns/edit.js"],"names":["classnames","__","Notice","PanelBody","RangeControl","ToggleControl","InspectorControls","useInnerBlocksProps","BlockControls","BlockVerticalAlignmentToolbar","__experimentalBlockVariationPicker","useBlockProps","store","blockEditorStore","withDispatch","useDispatch","useSelect","createBlock","createBlocksFromInnerBlocksTemplate","blocksStore","hasExplicitPercentColumnWidths","getMappedColumnWidths","getRedistributedColumnWidths","toWidthPrecision","ALLOWED_BLOCKS","ColumnsEditContainer","attributes","setAttributes","updateAlignment","updateColumns","clientId","isStackedOnMobile","verticalAlignment","templateLock","count","canInsertColumnBlock","minCount","select","canInsertBlockType","canRemoveBlock","getBlocks","getBlockCount","innerBlocks","preventRemovalBlockIndexes","reduce","acc","block","index","push","Math","max","classes","blockProps","className","innerBlocksProps","allowedBlocks","orientation","renderAppender","value","ColumnsEditContainerWrapper","dispatch","ownProps","registry","updateBlockAttributes","getBlockOrder","innerBlockClientIds","forEach","innerBlockClientId","previousColumns","newColumns","replaceInnerBlocks","hasExplicitWidths","isAddingColumn","newColumnWidth","widths","Array","from","length","map","width","slice","Placeholder","name","blockType","defaultVariation","variations","getBlockVariations","getBlockType","getDefaultBlockVariation","icon","src","title","nextVariation","ColumnsEdit","props","hasInnerBlocks","Component"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,MADD,EAECC,SAFD,EAGCC,YAHD,EAICC,aAJD,QAKO,uBALP;AAOA,SACCC,iBADD,EAECC,mBAFD,EAGCC,aAHD,EAICC,6BAJD,EAKCC,kCALD,EAMCC,aAND,EAOCC,KAAK,IAAIC,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,IAAd,oDAAG,gBAAiBC,GADzB;AAEC,IAAA,KAAK,EAAGP,SAAH,aAAGA,SAAH,uBAAGA,SAAS,CAAEQ,KAFpB;AAGC,IAAA,UAAU,EAAGN,UAHd;AAIC,IAAA,QAAQ,EAAG,YAAwC;AAAA,UAAtCO,aAAsC,uEAAtBR,gBAAsB;;AAClD,UAAKQ,aAAa,CAAClE,UAAnB,EAAgC;AAC/BC,QAAAA,aAAa,CAAEiE,aAAa,CAAClE,UAAhB,CAAb;AACA;;AACD,UAAKkE,aAAa,CAAClD,WAAnB,EAAiC;AAChC4B,QAAAA,kBAAkB,CACjBxC,QADiB,EAEjBZ,mCAAmC,CAClC0E,aAAa,CAAClD,WADoB,CAFlB,EAKjB,IALiB,CAAlB;AAOA;AACD,KAjBF;AAkBC,IAAA,SAAS;AAlBV,IADD,CADD;AAwBA;;AAED,MAAMmD,WAAW,GAAKC,KAAF,IAAa;AAChC,QAAM;AAAEhE,IAAAA;AAAF,MAAegE,KAArB;AACA,QAAMC,cAAc,GAAG/E,SAAS,CAC7BqB,MAAF,IACCA,MAAM,CAAExB,gBAAF,CAAN,CAA2B2B,SAA3B,CAAsCV,QAAtC,EAAiD+C,MAAjD,GAA0D,CAF5B,EAG/B,CAAE/C,QAAF,CAH+B,CAAhC;AAKA,QAAMkE,SAAS,GAAGD,cAAc,GAC7BpC,2BAD6B,GAE7BsB,WAFH;AAIA,SAAO,cAAC,SAAD,EAAgBa,KAAhB,CAAP;AACA,CAZD;;AAcA,eAAeD,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tNotice,\n\tPanelBody,\n\tRangeControl,\n\tToggleControl,\n} from '@wordpress/components';\n\nimport {\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tBlockControls,\n\tBlockVerticalAlignmentToolbar,\n\t__experimentalBlockVariationPicker,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { withDispatch, useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\thasExplicitPercentColumnWidths,\n\tgetMappedColumnWidths,\n\tgetRedistributedColumnWidths,\n\ttoWidthPrecision,\n} from './utils';\n\n/**\n * Allowed blocks constant is passed to InnerBlocks precisely as specified here.\n * The contents of the array should never change.\n * The array should contain the name of each block that is allowed.\n * In columns block, the only block we allow is 'core/column'.\n *\n * @constant\n * @type {string[]}\n */\nconst ALLOWED_BLOCKS = [ 'core/column' ];\n\nfunction ColumnsEditContainer( {\n\tattributes,\n\tsetAttributes,\n\tupdateAlignment,\n\tupdateColumns,\n\tclientId,\n} ) {\n\tconst { isStackedOnMobile, verticalAlignment, templateLock } = attributes;\n\n\tconst { count, canInsertColumnBlock, minCount } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tcanRemoveBlock,\n\t\t\t\tgetBlocks,\n\t\t\t\tgetBlockCount,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst innerBlocks = getBlocks( clientId );\n\n\t\t\t// Get the indexes of columns for which removal is prevented.\n\t\t\t// The highest index will be used to determine the minimum column count.\n\t\t\tconst preventRemovalBlockIndexes = innerBlocks.reduce(\n\t\t\t\t( acc, block, index ) => {\n\t\t\t\t\tif ( ! canRemoveBlock( block.clientId ) ) {\n\t\t\t\t\t\tacc.push( index );\n\t\t\t\t\t}\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t[]\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tcount: getBlockCount( clientId ),\n\t\t\t\tcanInsertColumnBlock: canInsertBlockType(\n\t\t\t\t\t'core/column',\n\t\t\t\t\tclientId\n\t\t\t\t),\n\t\t\t\tminCount: Math.max( ...preventRemovalBlockIndexes ) + 1,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst classes = classnames( {\n\t\t[ `are-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,\n\t\t[ `is-not-stacked-on-mobile` ]: ! isStackedOnMobile,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\torientation: 'horizontal',\n\t\trenderAppender: false,\n\t\ttemplateLock,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<BlockVerticalAlignmentToolbar\n\t\t\t\t\tonChange={ updateAlignment }\n\t\t\t\t\tvalue={ verticalAlignment }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t{ canInsertColumnBlock && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\tvalue={ count }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tupdateColumns(\n\t\t\t\t\t\t\t\t\t\tcount,\n\t\t\t\t\t\t\t\t\t\tMath.max( minCount, value )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmin={ Math.max( 1, minCount ) }\n\t\t\t\t\t\t\t\tmax={ Math.max( 6, count ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ count > 6 && (\n\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Notice>\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\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Stack on mobile' ) }\n\t\t\t\t\t\tchecked={ isStackedOnMobile }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tisStackedOnMobile: ! isStackedOnMobile,\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<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n\nconst ColumnsEditContainerWrapper = withDispatch(\n\t( dispatch, ownProps, registry ) => ( {\n\t\t/**\n\t\t * Update all child Column blocks with a new vertical alignment setting\n\t\t * based on whatever alignment is passed in. This allows change to parent\n\t\t * to overide anything set on a individual column basis.\n\t\t *\n\t\t * @param {string} verticalAlignment the vertical alignment setting\n\t\t */\n\t\tupdateAlignment( verticalAlignment ) {\n\t\t\tconst { clientId, setAttributes } = ownProps;\n\t\t\tconst { updateBlockAttributes } = dispatch( blockEditorStore );\n\t\t\tconst { getBlockOrder } = registry.select( blockEditorStore );\n\n\t\t\t// Update own alignment.\n\t\t\tsetAttributes( { verticalAlignment } );\n\n\t\t\t// Update all child Column Blocks to match.\n\t\t\tconst innerBlockClientIds = getBlockOrder( clientId );\n\t\t\tinnerBlockClientIds.forEach( ( innerBlockClientId ) => {\n\t\t\t\tupdateBlockAttributes( innerBlockClientId, {\n\t\t\t\t\tverticalAlignment,\n\t\t\t\t} );\n\t\t\t} );\n\t\t},\n\n\t\t/**\n\t\t * Updates the column count, including necessary revisions to child Column\n\t\t * blocks to grant required or redistribute available space.\n\t\t *\n\t\t * @param {number} previousColumns Previous column count.\n\t\t * @param {number} newColumns New column count.\n\t\t */\n\t\tupdateColumns( previousColumns, newColumns ) {\n\t\t\tconst { clientId } = ownProps;\n\t\t\tconst { replaceInnerBlocks } = dispatch( blockEditorStore );\n\t\t\tconst { getBlocks } = registry.select( blockEditorStore );\n\n\t\t\tlet innerBlocks = getBlocks( clientId );\n\t\t\tconst hasExplicitWidths =\n\t\t\t\thasExplicitPercentColumnWidths( innerBlocks );\n\n\t\t\t// Redistribute available width for existing inner blocks.\n\t\t\tconst isAddingColumn = newColumns > previousColumns;\n\n\t\t\tif ( isAddingColumn && hasExplicitWidths ) {\n\t\t\t\t// If adding a new column, assign width to the new column equal to\n\t\t\t\t// as if it were `1 / columns` of the total available space.\n\t\t\t\tconst newColumnWidth = toWidthPrecision( 100 / newColumns );\n\n\t\t\t\t// Redistribute in consideration of pending block insertion as\n\t\t\t\t// constraining the available working width.\n\t\t\t\tconst widths = getRedistributedColumnWidths(\n\t\t\t\t\tinnerBlocks,\n\t\t\t\t\t100 - newColumnWidth\n\t\t\t\t);\n\n\t\t\t\tinnerBlocks = [\n\t\t\t\t\t...getMappedColumnWidths( innerBlocks, widths ),\n\t\t\t\t\t...Array.from( {\n\t\t\t\t\t\tlength: newColumns - previousColumns,\n\t\t\t\t\t} ).map( () => {\n\t\t\t\t\t\treturn createBlock( 'core/column', {\n\t\t\t\t\t\t\twidth: `${ newColumnWidth }%`,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} ),\n\t\t\t\t];\n\t\t\t} else if ( isAddingColumn ) {\n\t\t\t\tinnerBlocks = [\n\t\t\t\t\t...innerBlocks,\n\t\t\t\t\t...Array.from( {\n\t\t\t\t\t\tlength: newColumns - previousColumns,\n\t\t\t\t\t} ).map( () => {\n\t\t\t\t\t\treturn createBlock( 'core/column' );\n\t\t\t\t\t} ),\n\t\t\t\t];\n\t\t\t} else if ( newColumns < previousColumns ) {\n\t\t\t\t// The removed column will be the last of the inner blocks.\n\t\t\t\tinnerBlocks = innerBlocks.slice(\n\t\t\t\t\t0,\n\t\t\t\t\t-( previousColumns - newColumns )\n\t\t\t\t);\n\t\t\t\tif ( hasExplicitWidths ) {\n\t\t\t\t\t// Redistribute as if block is already removed.\n\t\t\t\t\tconst widths = getRedistributedColumnWidths(\n\t\t\t\t\t\tinnerBlocks,\n\t\t\t\t\t\t100\n\t\t\t\t\t);\n\n\t\t\t\t\tinnerBlocks = getMappedColumnWidths( innerBlocks, widths );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treplaceInnerBlocks( clientId, innerBlocks );\n\t\t},\n\t} )\n)( ColumnsEditContainer );\n\nfunction Placeholder( { clientId, name, setAttributes } ) {\n\tconst { blockType, defaultVariation, variations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetDefaultBlockVariation,\n\t\t\t} = select( blocksStore );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tdefaultVariation: getDefaultBlockVariation( name, 'block' ),\n\t\t\t\tvariations: getBlockVariations( name, 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ name ]\n\t);\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst blockProps = useBlockProps();\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<__experimentalBlockVariationPicker\n\t\t\t\ticon={ blockType?.icon?.src }\n\t\t\t\tlabel={ blockType?.title }\n\t\t\t\tvariations={ variations }\n\t\t\t\tonSelect={ ( nextVariation = defaultVariation ) => {\n\t\t\t\t\tif ( nextVariation.attributes ) {\n\t\t\t\t\t\tsetAttributes( nextVariation.attributes );\n\t\t\t\t\t}\n\t\t\t\t\tif ( nextVariation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tnextVariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\tallowSkip\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nconst ColumnsEdit = ( props ) => {\n\tconst { clientId } = props;\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlocks( clientId ).length > 0,\n\t\t[ clientId ]\n\t);\n\tconst Component = hasInnerBlocks\n\t\t? ColumnsEditContainerWrapper\n\t\t: Placeholder;\n\n\treturn <Component { ...props } />;\n};\n\nexport default ColumnsEdit;\n"]}