@wordpress/block-editor 12.9.0 → 12.10.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 (463) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +33 -3
  3. package/build/components/block-canvas/index.js +107 -0
  4. package/build/components/block-canvas/index.js.map +1 -0
  5. package/build/components/block-inspector/index.js +4 -1
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-patterns-list/index.js +19 -4
  8. package/build/components/block-patterns-list/index.js.map +1 -1
  9. package/build/components/block-patterns-paging/index.js +66 -0
  10. package/build/components/block-patterns-paging/index.js.map +1 -0
  11. package/build/components/block-settings-menu/block-settings-dropdown.js +28 -0
  12. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  13. package/build/components/block-settings-menu-controls/index.js +4 -7
  14. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  15. package/build/components/block-styles/index.js +1 -0
  16. package/build/components/block-styles/index.js.map +1 -1
  17. package/build/components/block-toolbar/block-toolbar-menu.native.js +3 -7
  18. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  19. package/build/components/block-tools/block-contextual-toolbar.js +18 -7
  20. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  21. package/build/components/block-tools/block-selection-button.js +5 -1
  22. package/build/components/block-tools/block-selection-button.js.map +1 -1
  23. package/build/components/border-radius-control/input-controls.js +1 -1
  24. package/build/components/border-radius-control/input-controls.js.map +1 -1
  25. package/build/components/border-radius-control/linked-button.js +2 -4
  26. package/build/components/border-radius-control/linked-button.js.map +1 -1
  27. package/build/components/colors/with-colors.js.map +1 -1
  28. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
  29. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  30. package/build/components/default-block-appender/index.native.js +20 -1
  31. package/build/components/default-block-appender/index.native.js.map +1 -1
  32. package/build/components/duotone/utils.js +68 -0
  33. package/build/components/duotone/utils.js.map +1 -1
  34. package/build/components/editor-styles/index.js +28 -9
  35. package/build/components/editor-styles/index.js.map +1 -1
  36. package/build/components/global-styles/hooks.js +2 -101
  37. package/build/components/global-styles/hooks.js.map +1 -1
  38. package/build/components/global-styles/image-settings-panel.js +61 -0
  39. package/build/components/global-styles/image-settings-panel.js.map +1 -0
  40. package/build/components/global-styles/index.js +11 -17
  41. package/build/components/global-styles/index.js.map +1 -1
  42. package/build/components/global-styles/use-global-styles-output.js +19 -15
  43. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  44. package/build/components/global-styles/utils.js +1 -1
  45. package/build/components/global-styles/utils.js.map +1 -1
  46. package/build/components/iframe/index.js +67 -33
  47. package/build/components/iframe/index.js.map +1 -1
  48. package/build/components/image-editor/use-save-image.js +2 -5
  49. package/build/components/image-editor/use-save-image.js.map +1 -1
  50. package/build/components/image-editor/use-transform-image.js +9 -9
  51. package/build/components/image-editor/use-transform-image.js.map +1 -1
  52. package/build/components/index.js +8 -12
  53. package/build/components/index.js.map +1 -1
  54. package/build/components/index.native.js +6 -5
  55. package/build/components/index.native.js.map +1 -1
  56. package/build/components/inner-blocks/use-nested-settings-update.js +13 -7
  57. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  58. package/build/components/inserter/block-patterns-explorer/explorer.js +12 -6
  59. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  60. package/build/components/inserter/block-patterns-explorer/patterns-list.js +57 -23
  61. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  62. package/build/components/inserter/block-patterns-explorer/sidebar.js +24 -9
  63. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  64. package/build/components/inserter/block-patterns-source-filter.js +54 -0
  65. package/build/components/inserter/block-patterns-source-filter.js.map +1 -0
  66. package/build/components/inserter/block-patterns-sync-filter.js +46 -0
  67. package/build/components/inserter/block-patterns-sync-filter.js.map +1 -0
  68. package/build/components/inserter/block-patterns-tab.js +91 -45
  69. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  70. package/build/components/inserter/hooks/use-patterns-paging.js +57 -0
  71. package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -0
  72. package/build/components/inserter/hooks/use-patterns-state.js +21 -10
  73. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  74. package/build/components/inserter/menu.js +13 -11
  75. package/build/components/inserter/menu.js.map +1 -1
  76. package/build/components/inserter/search-results.js +4 -3
  77. package/build/components/inserter/search-results.js.map +1 -1
  78. package/build/components/inserter/tabs.js +1 -12
  79. package/build/components/inserter/tabs.js.map +1 -1
  80. package/build/components/inspector-controls/block-support-slot-container.js +12 -1
  81. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
  82. package/build/components/inspector-controls/fill.js +24 -13
  83. package/build/components/inspector-controls/fill.js.map +1 -1
  84. package/build/components/inspector-controls/groups.js +5 -3
  85. package/build/components/inspector-controls/groups.js.map +1 -1
  86. package/build/components/inspector-controls/slot.js +13 -0
  87. package/build/components/inspector-controls/slot.js.map +1 -1
  88. package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
  89. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  90. package/build/components/link-control/index.js +13 -2
  91. package/build/components/link-control/index.js.map +1 -1
  92. package/build/components/link-control/settings.js +2 -1
  93. package/build/components/link-control/settings.js.map +1 -1
  94. package/build/components/list-view/block-select-button.js +1 -3
  95. package/build/components/list-view/block-select-button.js.map +1 -1
  96. package/build/components/list-view/block.js +13 -1
  97. package/build/components/list-view/block.js.map +1 -1
  98. package/build/components/list-view/use-block-selection.js +29 -24
  99. package/build/components/list-view/use-block-selection.js.map +1 -1
  100. package/build/components/media-placeholder/index.js +2 -2
  101. package/build/components/media-placeholder/index.js.map +1 -1
  102. package/build/components/media-placeholder/index.native.js +11 -11
  103. package/build/components/media-placeholder/index.native.js.map +1 -1
  104. package/build/components/media-replace-flow/index.js +2 -3
  105. package/build/components/media-replace-flow/index.js.map +1 -1
  106. package/build/components/media-upload/constants.js +30 -0
  107. package/build/components/media-upload/constants.js.map +1 -0
  108. package/build/components/media-upload/index.native.js +63 -53
  109. package/build/components/media-upload/index.native.js.map +1 -1
  110. package/build/components/preview-options/index.js +1 -1
  111. package/build/components/preview-options/index.js.map +1 -1
  112. package/build/components/rich-text/index.js +34 -35
  113. package/build/components/rich-text/index.js.map +1 -1
  114. package/build/components/rich-text/index.native.js +14 -32
  115. package/build/components/rich-text/index.native.js.map +1 -1
  116. package/build/components/rich-text/multiline.js +95 -0
  117. package/build/components/rich-text/multiline.js.map +1 -0
  118. package/build/components/rich-text/split-value.js +10 -16
  119. package/build/components/rich-text/split-value.js.map +1 -1
  120. package/build/components/rich-text/use-enter.js +31 -40
  121. package/build/components/rich-text/use-enter.js.map +1 -1
  122. package/build/components/rich-text/use-paste-handler.js +18 -33
  123. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  124. package/build/components/spacing-sizes-control/utils.js +1 -1
  125. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  126. package/build/components/use-block-commands/index.js +30 -18
  127. package/build/components/use-block-commands/index.js.map +1 -1
  128. package/build/components/use-block-display-information/index.js +5 -2
  129. package/build/components/use-block-display-information/index.js.map +1 -1
  130. package/build/hooks/background.js +258 -0
  131. package/build/hooks/background.js.map +1 -0
  132. package/build/hooks/block-hooks.js +188 -0
  133. package/build/hooks/block-hooks.js.map +1 -0
  134. package/build/hooks/block-rename-ui.js +160 -0
  135. package/build/hooks/block-rename-ui.js.map +1 -0
  136. package/build/hooks/duotone.js +29 -42
  137. package/build/hooks/duotone.js.map +1 -1
  138. package/build/hooks/index.js +2 -2
  139. package/build/hooks/index.js.map +1 -1
  140. package/build/hooks/layout.js +31 -14
  141. package/build/hooks/layout.js.map +1 -1
  142. package/build/hooks/position.js +4 -2
  143. package/build/hooks/position.js.map +1 -1
  144. package/build/hooks/style.js +74 -25
  145. package/build/hooks/style.js.map +1 -1
  146. package/build/hooks/utils.js +4 -0
  147. package/build/hooks/utils.js.map +1 -1
  148. package/build/private-apis.js +2 -0
  149. package/build/private-apis.js.map +1 -1
  150. package/build/store/actions.js +33 -10
  151. package/build/store/actions.js.map +1 -1
  152. package/build/store/private-actions.js +42 -8
  153. package/build/store/private-actions.js.map +1 -1
  154. package/build/store/private-selectors.js +23 -0
  155. package/build/store/private-selectors.js.map +1 -1
  156. package/build/store/reducer.js +43 -1
  157. package/build/store/reducer.js.map +1 -1
  158. package/build/store/selectors.js +84 -23
  159. package/build/store/selectors.js.map +1 -1
  160. package/build/store/utils.js +0 -4
  161. package/build/store/utils.js.map +1 -1
  162. package/build-module/components/block-canvas/index.js +97 -0
  163. package/build-module/components/block-canvas/index.js.map +1 -0
  164. package/build-module/components/block-inspector/index.js +4 -1
  165. package/build-module/components/block-inspector/index.js.map +1 -1
  166. package/build-module/components/block-patterns-list/index.js +20 -5
  167. package/build-module/components/block-patterns-list/index.js.map +1 -1
  168. package/build-module/components/block-patterns-paging/index.js +59 -0
  169. package/build-module/components/block-patterns-paging/index.js.map +1 -0
  170. package/build-module/components/block-settings-menu/block-settings-dropdown.js +28 -0
  171. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  172. package/build-module/components/block-settings-menu-controls/index.js +4 -7
  173. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  174. package/build-module/components/block-styles/index.js +1 -0
  175. package/build-module/components/block-styles/index.js.map +1 -1
  176. package/build-module/components/block-toolbar/block-toolbar-menu.native.js +3 -7
  177. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  178. package/build-module/components/block-tools/block-contextual-toolbar.js +18 -7
  179. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  180. package/build-module/components/block-tools/block-selection-button.js +5 -1
  181. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  182. package/build-module/components/border-radius-control/input-controls.js +1 -1
  183. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  184. package/build-module/components/border-radius-control/linked-button.js +2 -4
  185. package/build-module/components/border-radius-control/linked-button.js.map +1 -1
  186. package/build-module/components/colors/with-colors.js.map +1 -1
  187. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
  188. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  189. package/build-module/components/default-block-appender/index.native.js +20 -1
  190. package/build-module/components/default-block-appender/index.native.js.map +1 -1
  191. package/build-module/components/duotone/utils.js +65 -0
  192. package/build-module/components/duotone/utils.js.map +1 -1
  193. package/build-module/components/editor-styles/index.js +28 -9
  194. package/build-module/components/editor-styles/index.js.map +1 -1
  195. package/build-module/components/global-styles/hooks.js +3 -100
  196. package/build-module/components/global-styles/hooks.js.map +1 -1
  197. package/build-module/components/global-styles/image-settings-panel.js +53 -0
  198. package/build-module/components/global-styles/image-settings-panel.js.map +1 -0
  199. package/build-module/components/global-styles/index.js +2 -2
  200. package/build-module/components/global-styles/index.js.map +1 -1
  201. package/build-module/components/global-styles/use-global-styles-output.js +18 -16
  202. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  203. package/build-module/components/global-styles/utils.js +1 -1
  204. package/build-module/components/global-styles/utils.js.map +1 -1
  205. package/build-module/components/iframe/index.js +66 -33
  206. package/build-module/components/iframe/index.js.map +1 -1
  207. package/build-module/components/image-editor/use-save-image.js +2 -5
  208. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  209. package/build-module/components/image-editor/use-transform-image.js +9 -9
  210. package/build-module/components/image-editor/use-transform-image.js.map +1 -1
  211. package/build-module/components/index.js +1 -1
  212. package/build-module/components/index.js.map +1 -1
  213. package/build-module/components/index.native.js +2 -1
  214. package/build-module/components/index.native.js.map +1 -1
  215. package/build-module/components/inner-blocks/use-nested-settings-update.js +14 -8
  216. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  217. package/build-module/components/inserter/block-patterns-explorer/explorer.js +12 -6
  218. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  219. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +59 -25
  220. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  221. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +23 -9
  222. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  223. package/build-module/components/inserter/block-patterns-source-filter.js +44 -0
  224. package/build-module/components/inserter/block-patterns-source-filter.js.map +1 -0
  225. package/build-module/components/inserter/block-patterns-sync-filter.js +38 -0
  226. package/build-module/components/inserter/block-patterns-sync-filter.js.map +1 -0
  227. package/build-module/components/inserter/block-patterns-tab.js +87 -46
  228. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  229. package/build-module/components/inserter/hooks/use-patterns-paging.js +50 -0
  230. package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -0
  231. package/build-module/components/inserter/hooks/use-patterns-state.js +22 -10
  232. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  233. package/build-module/components/inserter/menu.js +13 -11
  234. package/build-module/components/inserter/menu.js.map +1 -1
  235. package/build-module/components/inserter/search-results.js +4 -3
  236. package/build-module/components/inserter/search-results.js.map +1 -1
  237. package/build-module/components/inserter/tabs.js +1 -12
  238. package/build-module/components/inserter/tabs.js.map +1 -1
  239. package/build-module/components/inspector-controls/block-support-slot-container.js +13 -2
  240. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
  241. package/build-module/components/inspector-controls/fill.js +25 -14
  242. package/build-module/components/inspector-controls/fill.js.map +1 -1
  243. package/build-module/components/inspector-controls/groups.js +5 -3
  244. package/build-module/components/inspector-controls/groups.js.map +1 -1
  245. package/build-module/components/inspector-controls/slot.js +15 -1
  246. package/build-module/components/inspector-controls/slot.js.map +1 -1
  247. package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
  248. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  249. package/build-module/components/link-control/index.js +13 -2
  250. package/build-module/components/link-control/index.js.map +1 -1
  251. package/build-module/components/link-control/settings.js +2 -1
  252. package/build-module/components/link-control/settings.js.map +1 -1
  253. package/build-module/components/list-view/block-select-button.js +1 -3
  254. package/build-module/components/list-view/block-select-button.js.map +1 -1
  255. package/build-module/components/list-view/block.js +13 -1
  256. package/build-module/components/list-view/block.js.map +1 -1
  257. package/build-module/components/list-view/use-block-selection.js +30 -25
  258. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  259. package/build-module/components/media-placeholder/index.js +2 -2
  260. package/build-module/components/media-placeholder/index.js.map +1 -1
  261. package/build-module/components/media-placeholder/index.native.js +7 -7
  262. package/build-module/components/media-placeholder/index.native.js.map +1 -1
  263. package/build-module/components/media-replace-flow/index.js +2 -3
  264. package/build-module/components/media-replace-flow/index.js.map +1 -1
  265. package/build-module/components/media-upload/constants.js +14 -0
  266. package/build-module/components/media-upload/constants.js.map +1 -0
  267. package/build-module/components/media-upload/index.native.js +53 -34
  268. package/build-module/components/media-upload/index.native.js.map +1 -1
  269. package/build-module/components/preview-options/index.js +1 -1
  270. package/build-module/components/preview-options/index.js.map +1 -1
  271. package/build-module/components/rich-text/index.js +35 -37
  272. package/build-module/components/rich-text/index.js.map +1 -1
  273. package/build-module/components/rich-text/index.native.js +15 -33
  274. package/build-module/components/rich-text/index.native.js.map +1 -1
  275. package/build-module/components/rich-text/multiline.js +87 -0
  276. package/build-module/components/rich-text/multiline.js.map +1 -0
  277. package/build-module/components/rich-text/split-value.js +10 -16
  278. package/build-module/components/rich-text/split-value.js.map +1 -1
  279. package/build-module/components/rich-text/use-enter.js +33 -42
  280. package/build-module/components/rich-text/use-enter.js.map +1 -1
  281. package/build-module/components/rich-text/use-paste-handler.js +19 -34
  282. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  283. package/build-module/components/spacing-sizes-control/utils.js +2 -2
  284. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  285. package/build-module/components/use-block-commands/index.js +28 -16
  286. package/build-module/components/use-block-commands/index.js.map +1 -1
  287. package/build-module/components/use-block-display-information/index.js +5 -2
  288. package/build-module/components/use-block-display-information/index.js.map +1 -1
  289. package/build-module/hooks/background.js +244 -0
  290. package/build-module/hooks/background.js.map +1 -0
  291. package/build-module/hooks/block-hooks.js +181 -0
  292. package/build-module/hooks/block-hooks.js.map +1 -0
  293. package/build-module/hooks/block-rename-ui.js +153 -0
  294. package/build-module/hooks/block-rename-ui.js.map +1 -0
  295. package/build-module/hooks/duotone.js +26 -39
  296. package/build-module/hooks/duotone.js.map +1 -1
  297. package/build-module/hooks/index.js +2 -2
  298. package/build-module/hooks/index.js.map +1 -1
  299. package/build-module/hooks/layout.js +33 -16
  300. package/build-module/hooks/layout.js.map +1 -1
  301. package/build-module/hooks/position.js +4 -2
  302. package/build-module/hooks/position.js.map +1 -1
  303. package/build-module/hooks/style.js +73 -24
  304. package/build-module/hooks/style.js.map +1 -1
  305. package/build-module/hooks/utils.js +4 -0
  306. package/build-module/hooks/utils.js.map +1 -1
  307. package/build-module/private-apis.js +2 -0
  308. package/build-module/private-apis.js.map +1 -1
  309. package/build-module/store/actions.js +33 -10
  310. package/build-module/store/actions.js.map +1 -1
  311. package/build-module/store/private-actions.js +39 -8
  312. package/build-module/store/private-actions.js.map +1 -1
  313. package/build-module/store/private-selectors.js +21 -0
  314. package/build-module/store/private-selectors.js.map +1 -1
  315. package/build-module/store/reducer.js +41 -1
  316. package/build-module/store/reducer.js.map +1 -1
  317. package/build-module/store/selectors.js +78 -22
  318. package/build-module/store/selectors.js.map +1 -1
  319. package/build-module/store/utils.js +0 -4
  320. package/build-module/store/utils.js.map +1 -1
  321. package/build-style/content-rtl.css +0 -1
  322. package/build-style/content.css +0 -1
  323. package/build-style/style-rtl.css +174 -131
  324. package/build-style/style.css +174 -131
  325. package/package.json +32 -32
  326. package/src/components/block-canvas/index.js +108 -0
  327. package/src/components/block-inspector/index.js +5 -1
  328. package/src/components/block-list/content.scss +0 -1
  329. package/src/components/block-patterns-list/index.js +32 -7
  330. package/src/components/block-patterns-list/style.scss +26 -9
  331. package/src/components/block-patterns-paging/index.js +92 -0
  332. package/src/components/block-patterns-paging/style.scss +42 -0
  333. package/src/components/block-settings-menu/block-settings-dropdown.js +44 -0
  334. package/src/components/block-settings-menu-controls/index.js +4 -9
  335. package/src/components/block-styles/index.js +1 -0
  336. package/src/components/block-styles/style.scss +3 -3
  337. package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -6
  338. package/src/components/block-tools/block-contextual-toolbar.js +16 -5
  339. package/src/components/block-tools/block-selection-button.js +9 -1
  340. package/src/components/block-tools/style.scss +0 -98
  341. package/src/components/border-radius-control/input-controls.js +1 -1
  342. package/src/components/border-radius-control/linked-button.js +8 -11
  343. package/src/components/color-palette/test/__snapshots__/control.js.snap +34 -21
  344. package/src/components/colors/with-colors.js +3 -2
  345. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -35
  346. package/src/components/default-block-appender/index.native.js +26 -3
  347. package/src/components/duotone/utils.js +65 -0
  348. package/src/components/editor-styles/index.js +32 -23
  349. package/src/components/global-styles/hooks.js +4 -112
  350. package/src/components/global-styles/image-settings-panel.js +71 -0
  351. package/src/components/global-styles/index.js +4 -3
  352. package/src/components/global-styles/use-global-styles-output.js +25 -16
  353. package/src/components/global-styles/utils.js +1 -2
  354. package/src/components/iframe/index.js +72 -33
  355. package/src/components/image-editor/use-save-image.js +2 -9
  356. package/src/components/image-editor/use-transform-image.js +9 -9
  357. package/src/components/index.js +1 -1
  358. package/src/components/index.native.js +2 -2
  359. package/src/components/inner-blocks/use-nested-settings-update.js +15 -10
  360. package/src/components/inserter/block-patterns-explorer/explorer.js +17 -5
  361. package/src/components/inserter/block-patterns-explorer/patterns-list.js +109 -40
  362. package/src/components/inserter/block-patterns-explorer/sidebar.js +23 -8
  363. package/src/components/inserter/block-patterns-source-filter.js +40 -0
  364. package/src/components/inserter/block-patterns-sync-filter.js +35 -0
  365. package/src/components/inserter/block-patterns-tab.js +168 -57
  366. package/src/components/inserter/hooks/use-patterns-paging.js +65 -0
  367. package/src/components/inserter/hooks/use-patterns-state.js +27 -16
  368. package/src/components/inserter/menu.js +15 -17
  369. package/src/components/inserter/search-results.js +6 -4
  370. package/src/components/inserter/style.scss +23 -2
  371. package/src/components/inserter/tabs.js +2 -12
  372. package/src/components/inserter/test/index.native.js +8 -12
  373. package/src/components/inspector-controls/block-support-slot-container.js +19 -3
  374. package/src/components/inspector-controls/fill.js +28 -14
  375. package/src/components/inspector-controls/groups.js +6 -2
  376. package/src/components/inspector-controls/slot.js +28 -3
  377. package/src/components/inspector-controls-tabs/styles-tab.js +4 -0
  378. package/src/components/link-control/index.js +14 -0
  379. package/src/components/link-control/settings.js +1 -0
  380. package/src/components/link-control/style.scss +28 -7
  381. package/src/components/link-control/test/index.js +88 -6
  382. package/src/components/list-view/block-select-button.js +1 -3
  383. package/src/components/list-view/block.js +19 -1
  384. package/src/components/list-view/style.scss +1 -2
  385. package/src/components/list-view/use-block-selection.js +38 -32
  386. package/src/components/media-placeholder/README.md +2 -2
  387. package/src/components/media-placeholder/index.js +2 -2
  388. package/src/components/media-placeholder/index.native.js +11 -12
  389. package/src/components/media-replace-flow/index.js +2 -2
  390. package/src/components/media-replace-flow/test/index.js +5 -23
  391. package/src/components/media-upload/README.md +3 -2
  392. package/src/components/media-upload/constants.js +15 -0
  393. package/src/components/media-upload/index.native.js +66 -40
  394. package/src/components/media-upload/style.native.scss +4 -0
  395. package/src/components/media-upload/test/index.native.js +2 -2
  396. package/src/components/preview-options/README.md +7 -0
  397. package/src/components/preview-options/index.js +1 -1
  398. package/src/components/rich-text/index.js +48 -44
  399. package/src/components/rich-text/index.native.js +14 -42
  400. package/src/components/rich-text/multiline.js +121 -0
  401. package/src/components/rich-text/split-value.js +10 -35
  402. package/src/components/rich-text/use-enter.js +32 -42
  403. package/src/components/rich-text/use-paste-handler.js +16 -40
  404. package/src/components/spacing-sizes-control/style.scss +5 -7
  405. package/src/components/spacing-sizes-control/utils.js +1 -2
  406. package/src/components/use-block-commands/index.js +28 -20
  407. package/src/components/use-block-display-information/index.js +3 -0
  408. package/src/hooks/background.js +288 -0
  409. package/src/hooks/background.scss +57 -0
  410. package/src/hooks/block-hooks.js +257 -0
  411. package/src/hooks/block-hooks.scss +16 -0
  412. package/src/hooks/block-rename-ui.js +230 -0
  413. package/src/hooks/block-rename-ui.scss +3 -0
  414. package/src/hooks/duotone.js +42 -43
  415. package/src/hooks/index.js +2 -2
  416. package/src/hooks/layout.js +31 -33
  417. package/src/hooks/position.js +4 -3
  418. package/src/hooks/style.js +96 -37
  419. package/src/hooks/test/align.native.js +4 -3
  420. package/src/hooks/utils.js +4 -0
  421. package/src/private-apis.js +2 -0
  422. package/src/store/actions.js +52 -10
  423. package/src/store/private-actions.js +37 -6
  424. package/src/store/private-selectors.js +21 -0
  425. package/src/store/reducer.js +38 -0
  426. package/src/store/selectors.js +107 -26
  427. package/src/store/test/actions.js +19 -8
  428. package/src/store/test/private-actions.js +17 -0
  429. package/src/store/test/reducer.js +25 -0
  430. package/src/store/test/selectors.js +130 -123
  431. package/src/store/utils.js +3 -10
  432. package/src/style.scss +4 -0
  433. package/build/components/duotone/components.js +0 -135
  434. package/build/components/duotone/components.js.map +0 -1
  435. package/build/components/duotone/index.js +0 -38
  436. package/build/components/duotone/index.js.map +0 -1
  437. package/build/components/global-styles/behaviors-panel.js +0 -64
  438. package/build/components/global-styles/behaviors-panel.js.map +0 -1
  439. package/build/components/inserter/reusable-blocks-tab.js +0 -85
  440. package/build/components/inserter/reusable-blocks-tab.js.map +0 -1
  441. package/build/hooks/auto-inserting-blocks.js +0 -174
  442. package/build/hooks/auto-inserting-blocks.js.map +0 -1
  443. package/build/hooks/behaviors.js +0 -173
  444. package/build/hooks/behaviors.js.map +0 -1
  445. package/build-module/components/duotone/components.js +0 -126
  446. package/build-module/components/duotone/components.js.map +0 -1
  447. package/build-module/components/duotone/index.js +0 -3
  448. package/build-module/components/duotone/index.js.map +0 -1
  449. package/build-module/components/global-styles/behaviors-panel.js +0 -57
  450. package/build-module/components/global-styles/behaviors-panel.js.map +0 -1
  451. package/build-module/components/inserter/reusable-blocks-tab.js +0 -76
  452. package/build-module/components/inserter/reusable-blocks-tab.js.map +0 -1
  453. package/build-module/hooks/auto-inserting-blocks.js +0 -167
  454. package/build-module/hooks/auto-inserting-blocks.js.map +0 -1
  455. package/build-module/hooks/behaviors.js +0 -166
  456. package/build-module/hooks/behaviors.js.map +0 -1
  457. package/src/components/duotone/components.js +0 -133
  458. package/src/components/duotone/index.js +0 -7
  459. package/src/components/global-styles/behaviors-panel.js +0 -71
  460. package/src/components/inserter/reusable-blocks-tab.js +0 -84
  461. package/src/components/inserter/test/reusable-blocks-tab.js +0 -73
  462. package/src/hooks/auto-inserting-blocks.js +0 -232
  463. package/src/hooks/behaviors.js +0 -206
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","dragHandle","Button","Flex","FlexItem","useSelect","useDispatch","useEffect","useRef","BACKSPACE","DELETE","UP","DOWN","LEFT","RIGHT","TAB","ESCAPE","ENTER","SPACE","getBlockType","__experimentalGetAccessibleBlockLabel","getAccessibleBlockLabel","speak","focus","__","BlockTitle","BlockIcon","store","blockEditorStore","BlockDraggable","useBlockDisplayInformation","__unstableUseBlockElement","useBlockElement","BlockMover","BlockSelectionButton","clientId","rootClientId","blockInformation","selected","select","getBlock","getBlockIndex","hasBlockMovingClientId","getBlockListSettings","__unstableGetEditorMode","index","name","attributes","blockMovingMode","orientation","editorMode","setNavigationMode","removeBlock","ref","blockType","label","current","blockElement","getBlockRootClientId","getClientIdsOfDescendants","getSelectedBlockClientId","getMultiSelectedBlocksEndClientId","getPreviousBlockClientId","getNextBlockClientId","selectBlock","clearSelectedBlock","setBlockMovingClientId","moveBlockToPosition","onKeyDown","event","keyCode","isUp","isDown","isLeft","isRight","isTab","isEscape","isEnter","isSpace","isShift","shiftKey","preventDefault","selectedBlockClientId","selectionEndClientId","selectionBeforeEndClientId","selectionAfterEndClientId","navigateUp","navigateDown","navigateOut","navigateIn","focusedBlockUid","_getBlockRootClientId","_getClientIdsOfDescen","startingBlockClientId","defaultPrevented","sourceRoot","destRoot","sourceBlockIndex","destinationBlockIndex","nextTabbable","tabbable","findNext","contains","ownerDocument","defaultView","frameElement","findPrevious","classNames","dragHandleLabel","createElement","className","justify","icon","showColors","clientIds","hideDragHandle","draggableProps","tabIndex","onClick","undefined","showTooltip","maximumLength"],"sources":["@wordpress/block-editor/src/components/block-tools/block-selection-button.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { dragHandle } from '@wordpress/icons';\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport {\n\tBACKSPACE,\n\tDELETE,\n\tUP,\n\tDOWN,\n\tLEFT,\n\tRIGHT,\n\tTAB,\n\tESCAPE,\n\tENTER,\n\tSPACE,\n} from '@wordpress/keycodes';\nimport {\n\tgetBlockType,\n\t__experimentalGetAccessibleBlockLabel as getAccessibleBlockLabel,\n} from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { focus } from '@wordpress/dom';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockTitle from '../block-title';\nimport BlockIcon from '../block-icon';\nimport { store as blockEditorStore } from '../../store';\nimport BlockDraggable from '../block-draggable';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport BlockMover from '../block-mover';\n\n/**\n * Block selection button component, displaying the label of the block. If the block\n * descends from a root block, a button is displayed enabling the user to select\n * the root block.\n *\n * @param {string} props Component props.\n * @param {string} props.clientId Client ID of block.\n *\n * @return {WPComponent} The component to be rendered.\n */\nfunction BlockSelectionButton( { clientId, rootClientId } ) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst selected = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockIndex,\n\t\t\t\thasBlockMovingClientId,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst index = getBlockIndex( clientId );\n\t\t\tconst { name, attributes } = getBlock( clientId );\n\t\t\tconst blockMovingMode = hasBlockMovingClientId();\n\t\t\treturn {\n\t\t\t\tindex,\n\t\t\t\tname,\n\t\t\t\tattributes,\n\t\t\t\tblockMovingMode,\n\t\t\t\torientation: getBlockListSettings( rootClientId )?.orientation,\n\t\t\t\teditorMode: __unstableGetEditorMode(),\n\t\t\t};\n\t\t},\n\t\t[ clientId, rootClientId ]\n\t);\n\tconst {\n\t\tindex,\n\t\tname,\n\t\tattributes,\n\t\tblockMovingMode,\n\t\torientation,\n\t\teditorMode,\n\t} = selected;\n\tconst { setNavigationMode, removeBlock } = useDispatch( blockEditorStore );\n\tconst ref = useRef();\n\n\tconst blockType = getBlockType( name );\n\tconst label = getAccessibleBlockLabel(\n\t\tblockType,\n\t\tattributes,\n\t\tindex + 1,\n\t\torientation\n\t);\n\n\t// Focus the breadcrumb in navigation mode.\n\tuseEffect( () => {\n\t\tref.current.focus();\n\n\t\tspeak( label );\n\t}, [ label ] );\n\tconst blockElement = useBlockElement( clientId );\n\n\tconst {\n\t\thasBlockMovingClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockRootClientId,\n\t\tgetClientIdsOfDescendants,\n\t\tgetSelectedBlockClientId,\n\t\tgetMultiSelectedBlocksEndClientId,\n\t\tgetPreviousBlockClientId,\n\t\tgetNextBlockClientId,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tselectBlock,\n\t\tclearSelectedBlock,\n\t\tsetBlockMovingClientId,\n\t\tmoveBlockToPosition,\n\t} = useDispatch( blockEditorStore );\n\n\tfunction onKeyDown( event ) {\n\t\tconst { keyCode } = event;\n\t\tconst isUp = keyCode === UP;\n\t\tconst isDown = keyCode === DOWN;\n\t\tconst isLeft = keyCode === LEFT;\n\t\tconst isRight = keyCode === RIGHT;\n\t\tconst isTab = keyCode === TAB;\n\t\tconst isEscape = keyCode === ESCAPE;\n\t\tconst isEnter = keyCode === ENTER;\n\t\tconst isSpace = keyCode === SPACE;\n\t\tconst isShift = event.shiftKey;\n\n\t\tif ( keyCode === BACKSPACE || keyCode === DELETE ) {\n\t\t\tremoveBlock( clientId );\n\t\t\tevent.preventDefault();\n\t\t\treturn;\n\t\t}\n\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\tconst selectionEndClientId = getMultiSelectedBlocksEndClientId();\n\t\tconst selectionBeforeEndClientId = getPreviousBlockClientId(\n\t\t\tselectionEndClientId || selectedBlockClientId\n\t\t);\n\t\tconst selectionAfterEndClientId = getNextBlockClientId(\n\t\t\tselectionEndClientId || selectedBlockClientId\n\t\t);\n\n\t\tconst navigateUp = ( isTab && isShift ) || isUp;\n\t\tconst navigateDown = ( isTab && ! isShift ) || isDown;\n\t\t// Move out of current nesting level (no effect if at root level).\n\t\tconst navigateOut = isLeft;\n\t\t// Move into next nesting level (no effect if the current block has no innerBlocks).\n\t\tconst navigateIn = isRight;\n\n\t\tlet focusedBlockUid;\n\t\tif ( navigateUp ) {\n\t\t\tfocusedBlockUid = selectionBeforeEndClientId;\n\t\t} else if ( navigateDown ) {\n\t\t\tfocusedBlockUid = selectionAfterEndClientId;\n\t\t} else if ( navigateOut ) {\n\t\t\tfocusedBlockUid =\n\t\t\t\tgetBlockRootClientId( selectedBlockClientId ) ??\n\t\t\t\tselectedBlockClientId;\n\t\t} else if ( navigateIn ) {\n\t\t\tfocusedBlockUid =\n\t\t\t\tgetClientIdsOfDescendants( [ selectedBlockClientId ] )[ 0 ] ??\n\t\t\t\tselectedBlockClientId;\n\t\t}\n\t\tconst startingBlockClientId = hasBlockMovingClientId();\n\t\tif ( isEscape && startingBlockClientId && ! event.defaultPrevented ) {\n\t\t\tsetBlockMovingClientId( null );\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tif ( ( isEnter || isSpace ) && startingBlockClientId ) {\n\t\t\tconst sourceRoot = getBlockRootClientId( startingBlockClientId );\n\t\t\tconst destRoot = getBlockRootClientId( selectedBlockClientId );\n\t\t\tconst sourceBlockIndex = getBlockIndex( startingBlockClientId );\n\t\t\tlet destinationBlockIndex = getBlockIndex( selectedBlockClientId );\n\t\t\tif (\n\t\t\t\tsourceBlockIndex < destinationBlockIndex &&\n\t\t\t\tsourceRoot === destRoot\n\t\t\t) {\n\t\t\t\tdestinationBlockIndex -= 1;\n\t\t\t}\n\t\t\tmoveBlockToPosition(\n\t\t\t\tstartingBlockClientId,\n\t\t\t\tsourceRoot,\n\t\t\t\tdestRoot,\n\t\t\t\tdestinationBlockIndex\n\t\t\t);\n\t\t\tselectBlock( startingBlockClientId );\n\t\t\tsetBlockMovingClientId( null );\n\t\t}\n\t\tif ( navigateDown || navigateUp || navigateOut || navigateIn ) {\n\t\t\tif ( focusedBlockUid ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tselectBlock( focusedBlockUid );\n\t\t\t} else if ( isTab && selectedBlockClientId ) {\n\t\t\t\tlet nextTabbable;\n\n\t\t\t\tif ( navigateDown ) {\n\t\t\t\t\tnextTabbable = blockElement;\n\t\t\t\t\tdo {\n\t\t\t\t\t\tnextTabbable = focus.tabbable.findNext( nextTabbable );\n\t\t\t\t\t} while (\n\t\t\t\t\t\tnextTabbable &&\n\t\t\t\t\t\tblockElement.contains( nextTabbable )\n\t\t\t\t\t);\n\n\t\t\t\t\tif ( ! nextTabbable ) {\n\t\t\t\t\t\tnextTabbable =\n\t\t\t\t\t\t\tblockElement.ownerDocument.defaultView.frameElement;\n\t\t\t\t\t\tnextTabbable = focus.tabbable.findNext( nextTabbable );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tnextTabbable = focus.tabbable.findPrevious( blockElement );\n\t\t\t\t}\n\n\t\t\t\tif ( nextTabbable ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tnextTabbable.focus();\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst classNames = classnames(\n\t\t'block-editor-block-list__block-selection-button',\n\t\t{\n\t\t\t'is-block-moving-mode': !! blockMovingMode,\n\t\t}\n\t);\n\n\tconst dragHandleLabel = __( 'Drag' );\n\n\treturn (\n\t\t<div className={ classNames }>\n\t\t\t<Flex\n\t\t\t\tjustify=\"center\"\n\t\t\t\tclassName=\"block-editor-block-list__block-selection-button__content\"\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<BlockIcon icon={ blockInformation?.icon } showColors />\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t{ editorMode === 'zoom-out' && (\n\t\t\t\t\t\t<BlockMover clientIds={ [ clientId ] } hideDragHandle />\n\t\t\t\t\t) }\n\t\t\t\t\t{ editorMode === 'navigation' && (\n\t\t\t\t\t\t<BlockDraggable clientIds={ [ clientId ] }>\n\t\t\t\t\t\t\t{ ( draggableProps ) => (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\ticon={ dragHandle }\n\t\t\t\t\t\t\t\t\tclassName=\"block-selection-button_drag-handle\"\n\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\tlabel={ dragHandleLabel }\n\t\t\t\t\t\t\t\t\t// Should not be able to tab to drag handle as this\n\t\t\t\t\t\t\t\t\t// button can only be used with a pointer device.\n\t\t\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t\t\t\t{ ...draggableProps }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BlockDraggable>\n\t\t\t\t\t) }\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\teditorMode === 'navigation'\n\t\t\t\t\t\t\t\t? () => setNavigationMode( false )\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tshowTooltip={ false }\n\t\t\t\t\t\tclassName=\"block-selection-button_select-button\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</div>\n\t);\n}\n\nexport default BlockSelectionButton;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,uBAAuB;AAC9D,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACtD,SACCC,SAAS,EACTC,MAAM,EACNC,EAAE,EACFC,IAAI,EACJC,IAAI,EACJC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,KAAK,EACLC,KAAK,QACC,qBAAqB;AAC5B,SACCC,YAAY,EACZC,qCAAqC,IAAIC,uBAAuB,QAC1D,mBAAmB;AAC1B,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AACvC,OAAOC,SAAS,MAAM,eAAe;AACrC,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,OAAOC,0BAA0B,MAAM,kCAAkC;AACzE,SAASC,yBAAyB,IAAIC,eAAe,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rBV,SAAS,EAAC;EAAsC,GAEhDD,aAAA,CAACpF,UAAU;IACVU,QAAQ,EAAGA,QAAU;IACrBsF,aAAa,EAAG;EAAI,CACpB,CACM,CACC,CACL,CACF,CAAC;AAER;AAEA,eAAevF,oBAAoB"}
1
+ {"version":3,"names":["classnames","dragHandle","Button","Flex","FlexItem","useSelect","useDispatch","useEffect","useRef","BACKSPACE","DELETE","UP","DOWN","LEFT","RIGHT","TAB","ESCAPE","ENTER","SPACE","getBlockType","__experimentalGetAccessibleBlockLabel","getAccessibleBlockLabel","speak","focus","__","BlockTitle","BlockIcon","store","blockEditorStore","BlockDraggable","useBlockDisplayInformation","__unstableUseBlockElement","useBlockElement","BlockMover","BlockSelectionButton","clientId","rootClientId","blockInformation","selected","select","getBlock","getBlockIndex","hasBlockMovingClientId","getBlockListSettings","__unstableGetEditorMode","index","name","attributes","blockMovingMode","orientation","editorMode","setNavigationMode","removeBlock","ref","blockType","label","current","blockElement","getBlockRootClientId","getClientIdsOfDescendants","getSelectedBlockClientId","getMultiSelectedBlocksEndClientId","getPreviousBlockClientId","getNextBlockClientId","selectBlock","clearSelectedBlock","setBlockMovingClientId","moveBlockToPosition","onKeyDown","event","keyCode","isUp","isDown","isLeft","isRight","isTab","isEscape","isEnter","isSpace","isShift","shiftKey","preventDefault","selectedBlockClientId","selectionEndClientId","selectionBeforeEndClientId","selectionAfterEndClientId","navigateUp","navigateDown","navigateOut","navigateIn","focusedBlockUid","_getBlockRootClientId","_getClientIdsOfDescen","startingBlockClientId","defaultPrevented","sourceRoot","destRoot","sourceBlockIndex","destinationBlockIndex","nextTabbable","tabbable","findNext","contains","ownerDocument","defaultView","frameElement","findPrevious","classNames","dragHandleLabel","createElement","className","justify","icon","showColors","clientIds","hideDragHandle","draggableProps","tabIndex","onClick","undefined","showTooltip","maximumLength"],"sources":["@wordpress/block-editor/src/components/block-tools/block-selection-button.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { dragHandle } from '@wordpress/icons';\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport {\n\tBACKSPACE,\n\tDELETE,\n\tUP,\n\tDOWN,\n\tLEFT,\n\tRIGHT,\n\tTAB,\n\tESCAPE,\n\tENTER,\n\tSPACE,\n} from '@wordpress/keycodes';\nimport {\n\tgetBlockType,\n\t__experimentalGetAccessibleBlockLabel as getAccessibleBlockLabel,\n} from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { focus } from '@wordpress/dom';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockTitle from '../block-title';\nimport BlockIcon from '../block-icon';\nimport { store as blockEditorStore } from '../../store';\nimport BlockDraggable from '../block-draggable';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport BlockMover from '../block-mover';\n\n/**\n * Block selection button component, displaying the label of the block. If the block\n * descends from a root block, a button is displayed enabling the user to select\n * the root block.\n *\n * @param {string} props Component props.\n * @param {string} props.clientId Client ID of block.\n *\n * @return {WPComponent} The component to be rendered.\n */\nfunction BlockSelectionButton( { clientId, rootClientId } ) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst selected = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockIndex,\n\t\t\t\thasBlockMovingClientId,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst index = getBlockIndex( clientId );\n\t\t\tconst { name, attributes } = getBlock( clientId );\n\t\t\tconst blockMovingMode = hasBlockMovingClientId();\n\t\t\treturn {\n\t\t\t\tindex,\n\t\t\t\tname,\n\t\t\t\tattributes,\n\t\t\t\tblockMovingMode,\n\t\t\t\torientation: getBlockListSettings( rootClientId )?.orientation,\n\t\t\t\teditorMode: __unstableGetEditorMode(),\n\t\t\t};\n\t\t},\n\t\t[ clientId, rootClientId ]\n\t);\n\tconst {\n\t\tindex,\n\t\tname,\n\t\tattributes,\n\t\tblockMovingMode,\n\t\torientation,\n\t\teditorMode,\n\t} = selected;\n\tconst { setNavigationMode, removeBlock } = useDispatch( blockEditorStore );\n\tconst ref = useRef();\n\n\tconst blockType = getBlockType( name );\n\tconst label = getAccessibleBlockLabel(\n\t\tblockType,\n\t\tattributes,\n\t\tindex + 1,\n\t\torientation\n\t);\n\n\t// Focus the breadcrumb in navigation mode.\n\tuseEffect( () => {\n\t\tref.current.focus();\n\n\t\tspeak( label );\n\t}, [ label ] );\n\tconst blockElement = useBlockElement( clientId );\n\n\tconst {\n\t\thasBlockMovingClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockRootClientId,\n\t\tgetClientIdsOfDescendants,\n\t\tgetSelectedBlockClientId,\n\t\tgetMultiSelectedBlocksEndClientId,\n\t\tgetPreviousBlockClientId,\n\t\tgetNextBlockClientId,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tselectBlock,\n\t\tclearSelectedBlock,\n\t\tsetBlockMovingClientId,\n\t\tmoveBlockToPosition,\n\t} = useDispatch( blockEditorStore );\n\n\tfunction onKeyDown( event ) {\n\t\tconst { keyCode } = event;\n\t\tconst isUp = keyCode === UP;\n\t\tconst isDown = keyCode === DOWN;\n\t\tconst isLeft = keyCode === LEFT;\n\t\tconst isRight = keyCode === RIGHT;\n\t\tconst isTab = keyCode === TAB;\n\t\tconst isEscape = keyCode === ESCAPE;\n\t\tconst isEnter = keyCode === ENTER;\n\t\tconst isSpace = keyCode === SPACE;\n\t\tconst isShift = event.shiftKey;\n\n\t\tif ( keyCode === BACKSPACE || keyCode === DELETE ) {\n\t\t\tremoveBlock( clientId );\n\t\t\tevent.preventDefault();\n\t\t\treturn;\n\t\t}\n\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\tconst selectionEndClientId = getMultiSelectedBlocksEndClientId();\n\t\tconst selectionBeforeEndClientId = getPreviousBlockClientId(\n\t\t\tselectionEndClientId || selectedBlockClientId\n\t\t);\n\t\tconst selectionAfterEndClientId = getNextBlockClientId(\n\t\t\tselectionEndClientId || selectedBlockClientId\n\t\t);\n\n\t\tconst navigateUp = ( isTab && isShift ) || isUp;\n\t\tconst navigateDown = ( isTab && ! isShift ) || isDown;\n\t\t// Move out of current nesting level (no effect if at root level).\n\t\tconst navigateOut = isLeft;\n\t\t// Move into next nesting level (no effect if the current block has no innerBlocks).\n\t\tconst navigateIn = isRight;\n\n\t\tlet focusedBlockUid;\n\t\tif ( navigateUp ) {\n\t\t\tfocusedBlockUid = selectionBeforeEndClientId;\n\t\t} else if ( navigateDown ) {\n\t\t\tfocusedBlockUid = selectionAfterEndClientId;\n\t\t} else if ( navigateOut ) {\n\t\t\tfocusedBlockUid =\n\t\t\t\tgetBlockRootClientId( selectedBlockClientId ) ??\n\t\t\t\tselectedBlockClientId;\n\t\t} else if ( navigateIn ) {\n\t\t\tfocusedBlockUid =\n\t\t\t\tgetClientIdsOfDescendants( selectedBlockClientId )[ 0 ] ??\n\t\t\t\tselectedBlockClientId;\n\t\t}\n\t\tconst startingBlockClientId = hasBlockMovingClientId();\n\t\tif ( isEscape && startingBlockClientId && ! event.defaultPrevented ) {\n\t\t\tsetBlockMovingClientId( null );\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tif ( ( isEnter || isSpace ) && startingBlockClientId ) {\n\t\t\tconst sourceRoot = getBlockRootClientId( startingBlockClientId );\n\t\t\tconst destRoot = getBlockRootClientId( selectedBlockClientId );\n\t\t\tconst sourceBlockIndex = getBlockIndex( startingBlockClientId );\n\t\t\tlet destinationBlockIndex = getBlockIndex( selectedBlockClientId );\n\t\t\tif (\n\t\t\t\tsourceBlockIndex < destinationBlockIndex &&\n\t\t\t\tsourceRoot === destRoot\n\t\t\t) {\n\t\t\t\tdestinationBlockIndex -= 1;\n\t\t\t}\n\t\t\tmoveBlockToPosition(\n\t\t\t\tstartingBlockClientId,\n\t\t\t\tsourceRoot,\n\t\t\t\tdestRoot,\n\t\t\t\tdestinationBlockIndex\n\t\t\t);\n\t\t\tselectBlock( startingBlockClientId );\n\t\t\tsetBlockMovingClientId( null );\n\t\t}\n\t\t// Prevent the block from being moved into itself.\n\t\tif (\n\t\t\tstartingBlockClientId &&\n\t\t\tselectedBlockClientId === startingBlockClientId &&\n\t\t\tnavigateIn\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tif ( navigateDown || navigateUp || navigateOut || navigateIn ) {\n\t\t\tif ( focusedBlockUid ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tselectBlock( focusedBlockUid );\n\t\t\t} else if ( isTab && selectedBlockClientId ) {\n\t\t\t\tlet nextTabbable;\n\n\t\t\t\tif ( navigateDown ) {\n\t\t\t\t\tnextTabbable = blockElement;\n\t\t\t\t\tdo {\n\t\t\t\t\t\tnextTabbable = focus.tabbable.findNext( nextTabbable );\n\t\t\t\t\t} while (\n\t\t\t\t\t\tnextTabbable &&\n\t\t\t\t\t\tblockElement.contains( nextTabbable )\n\t\t\t\t\t);\n\n\t\t\t\t\tif ( ! nextTabbable ) {\n\t\t\t\t\t\tnextTabbable =\n\t\t\t\t\t\t\tblockElement.ownerDocument.defaultView.frameElement;\n\t\t\t\t\t\tnextTabbable = focus.tabbable.findNext( nextTabbable );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tnextTabbable = focus.tabbable.findPrevious( blockElement );\n\t\t\t\t}\n\n\t\t\t\tif ( nextTabbable ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tnextTabbable.focus();\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst classNames = classnames(\n\t\t'block-editor-block-list__block-selection-button',\n\t\t{\n\t\t\t'is-block-moving-mode': !! blockMovingMode,\n\t\t}\n\t);\n\n\tconst dragHandleLabel = __( 'Drag' );\n\n\treturn (\n\t\t<div className={ classNames }>\n\t\t\t<Flex\n\t\t\t\tjustify=\"center\"\n\t\t\t\tclassName=\"block-editor-block-list__block-selection-button__content\"\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<BlockIcon icon={ blockInformation?.icon } showColors />\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t{ editorMode === 'zoom-out' && (\n\t\t\t\t\t\t<BlockMover clientIds={ [ clientId ] } hideDragHandle />\n\t\t\t\t\t) }\n\t\t\t\t\t{ editorMode === 'navigation' && (\n\t\t\t\t\t\t<BlockDraggable clientIds={ [ clientId ] }>\n\t\t\t\t\t\t\t{ ( draggableProps ) => (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\ticon={ dragHandle }\n\t\t\t\t\t\t\t\t\tclassName=\"block-selection-button_drag-handle\"\n\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\tlabel={ dragHandleLabel }\n\t\t\t\t\t\t\t\t\t// Should not be able to tab to drag handle as this\n\t\t\t\t\t\t\t\t\t// button can only be used with a pointer device.\n\t\t\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t\t\t\t{ ...draggableProps }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BlockDraggable>\n\t\t\t\t\t) }\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\teditorMode === 'navigation'\n\t\t\t\t\t\t\t\t? () => setNavigationMode( false )\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tshowTooltip={ false }\n\t\t\t\t\t\tclassName=\"block-selection-button_select-button\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</div>\n\t);\n}\n\nexport default BlockSelectionButton;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,uBAAuB;AAC9D,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACtD,SACCC,SAAS,EACTC,MAAM,EACNC,EAAE,EACFC,IAAI,EACJC,IAAI,EACJC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,KAAK,EACLC,KAAK,QACC,qBAAqB;AAC5B,SACCC,YAAY,EACZC,qCAAqC,IAAIC,uBAAuB,QAC1D,mBAAmB;AAC1B,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AACvC,OAAOC,SAAS,MAAM,eAAe;AACrC,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,OAAOC,0BAA0B,MAAM,kCAAkC;AACzE,SAASC,yBAAyB,IAAIC,eAAe,QAAQ,8CAA8C;AAC3G,OAAOC,UAAU,MAAM,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAE;EAAEC,QAAQ;EAAEC;AAAa,CAAC,EAAG;EAC3D,MAAMC,gBAAgB,GA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ACL,CACF,CAAC;AAER;AAEA,eAAevF,oBAAoB"}
@@ -56,7 +56,7 @@ export default function BoxInputControls({
56
56
  const computedUnit = values[corner] ? parsedUnit : selectedUnits[corner] || selectedUnits.flat;
57
57
  return createElement(Tooltip, {
58
58
  text: label,
59
- position: "top",
59
+ placement: "top",
60
60
  key: corner
61
61
  }, createElement("div", {
62
62
  className: "components-border-radius-control__tooltip-wrapper"
@@ -1 +1 @@
1
- {"version":3,"names":["__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","__experimentalUnitControl","UnitControl","Tooltip","__","CORNERS","topLeft","topRight","bottomLeft","bottomRight","BoxInputControls","onChange","selectedUnits","setSelectedUnits","values","valuesProp","props","createHandleOnChange","corner","next","isNumeric","isNaN","parseFloat","nextValue","undefined","createHandleOnUnitChange","side","newUnits","createElement","className","Object","entries","map","label","parsedQuantity","parsedUnit","computedUnit","flat","text","position","key","value","join","onUnitChange","size"],"sources":["@wordpress/block-editor/src/components/border-radius-control/input-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalUnitControl as UnitControl,\n\tTooltip,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst CORNERS = {\n\ttopLeft: __( 'Top left' ),\n\ttopRight: __( 'Top right' ),\n\tbottomLeft: __( 'Bottom left' ),\n\tbottomRight: __( 'Bottom right' ),\n};\n\nexport default function BoxInputControls( {\n\tonChange,\n\tselectedUnits,\n\tsetSelectedUnits,\n\tvalues: valuesProp,\n\t...props\n} ) {\n\tconst createHandleOnChange = ( corner ) => ( next ) => {\n\t\tif ( ! onChange ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Filter out CSS-unit-only values to prevent invalid styles.\n\t\tconst isNumeric = ! isNaN( parseFloat( next ) );\n\t\tconst nextValue = isNumeric ? next : undefined;\n\n\t\tonChange( {\n\t\t\t...values,\n\t\t\t[ corner ]: nextValue,\n\t\t} );\n\t};\n\n\tconst createHandleOnUnitChange = ( side ) => ( next ) => {\n\t\tconst newUnits = { ...selectedUnits };\n\t\tnewUnits[ side ] = next;\n\t\tsetSelectedUnits( newUnits );\n\t};\n\n\t// For shorthand style & backwards compatibility, handle flat string value.\n\tconst values =\n\t\ttypeof valuesProp !== 'string'\n\t\t\t? valuesProp\n\t\t\t: {\n\t\t\t\t\ttopLeft: valuesProp,\n\t\t\t\t\ttopRight: valuesProp,\n\t\t\t\t\tbottomLeft: valuesProp,\n\t\t\t\t\tbottomRight: valuesProp,\n\t\t\t };\n\n\t// Controls are wrapped in tooltips as visible labels aren't desired here.\n\t// Tooltip rendering also requires the UnitControl to be wrapped. See:\n\t// https://github.com/WordPress/gutenberg/pull/24966#issuecomment-685875026\n\treturn (\n\t\t<div className=\"components-border-radius-control__input-controls-wrapper\">\n\t\t\t{ Object.entries( CORNERS ).map( ( [ corner, label ] ) => {\n\t\t\t\tconst [ parsedQuantity, parsedUnit ] =\n\t\t\t\t\tparseQuantityAndUnitFromRawValue( values[ corner ] );\n\n\t\t\t\tconst computedUnit = values[ corner ]\n\t\t\t\t\t? parsedUnit\n\t\t\t\t\t: selectedUnits[ corner ] || selectedUnits.flat;\n\n\t\t\t\treturn (\n\t\t\t\t\t<Tooltip text={ label } position=\"top\" key={ corner }>\n\t\t\t\t\t\t<div className=\"components-border-radius-control__tooltip-wrapper\">\n\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\t\t\tvalue={ [ parsedQuantity, computedUnit ].join(\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\tonChange={ createHandleOnChange( corner ) }\n\t\t\t\t\t\t\t\tonUnitChange={ createHandleOnUnitChange(\n\t\t\t\t\t\t\t\t\tcorner\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ts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IACAT,OAAO,EAAES,UAAU;IACnBR,QAAQ,EAAEQ,UAAU;IACpBP,UAAU,EAAEO,UAAU;IACtBN,WAAW,EAAEM;EACb,CAAC;;EAEL;EACA;EACA;EACA,OACCa,aAAA;IAAKC,SAAS,EAAC;EAA0D,GACtEC,MAAM,CAACC,OAAO,CAAE1B,OAAQ,CAAC,CAAC2B,GAAG,CAAE,CAAE,CAAEd,MAAM,EAAEe,KAAK,CAAE,KAAM;IACzD,MAAM,CAAEC,cAAc,EAAEC,UAAU,CAAE,GACnCnC,gCAAgC,CAAEc,MAAM,CAAEI,MAAM,CAAG,CAAC;IAErD,MAAMkB,YAAY,GAAGtB,MAAM,CAAEI,MAAM,CAAE,GAClCiB,UAAU,GACVvB,aAAa,CAAEM,MAAM,CAAE,IAAIN,aAAa,CAACyB,IAAI;IAEhD,OACCT,aAAA,CAACzB,OAAO;MAACmC,IAAI,EAAGL,KAAO;MAACM,QAAQ,EAAC,KAAK;MAACC,GAAG,EAAGtB;IAAQ,GACpDU,aAAA;MAAKC,SAAS,EAAC;IAAmD,GACjED,aAAA,CAAC1B,WAAW;MAAA,GACNc,KAAK;MACV,cAAaiB,KAAO;MACpBQ,KAAK,EAAG,CAAEP,cAAc,EAAEE,YAAY,CAAE,CAACM,IAAI,CAC5C,EACD,CAAG;MACH/B,QAAQ,EAAGM,oBAAoB,CAAEC,MAAO,CAAG;MAC3CyB,YAAY,EAAGlB,wBAAwB,CACtCP,MACD,CAAG;MACH0B,IAAI,EAAG;IAAoB,CAC3B,CACG,CACG,CAAC;EAEZ,CAAE,CACE,CAAC;AAER"}
1
+ {"version":3,"names":["__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","__experimentalUnitControl","UnitControl","Tooltip","__","CORNERS","topLeft","topRight","bottomLeft","bottomRight","BoxInputControls","onChange","selectedUnits","setSelectedUnits","values","valuesProp","props","createHandleOnChange","corner","next","isNumeric","isNaN","parseFloat","nextValue","undefined","createHandleOnUnitChange","side","newUnits","createElement","className","Object","entries","map","label","parsedQuantity","parsedUnit","computedUnit","flat","text","placement","key","value","join","onUnitChange","size"],"sources":["@wordpress/block-editor/src/components/border-radius-control/input-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalUnitControl as UnitControl,\n\tTooltip,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst CORNERS = {\n\ttopLeft: __( 'Top left' ),\n\ttopRight: __( 'Top right' ),\n\tbottomLeft: __( 'Bottom left' ),\n\tbottomRight: __( 'Bottom right' ),\n};\n\nexport default function BoxInputControls( {\n\tonChange,\n\tselectedUnits,\n\tsetSelectedUnits,\n\tvalues: valuesProp,\n\t...props\n} ) {\n\tconst createHandleOnChange = ( corner ) => ( next ) => {\n\t\tif ( ! onChange ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Filter out CSS-unit-only values to prevent invalid styles.\n\t\tconst isNumeric = ! isNaN( parseFloat( next ) );\n\t\tconst nextValue = isNumeric ? next : undefined;\n\n\t\tonChange( {\n\t\t\t...values,\n\t\t\t[ corner ]: nextValue,\n\t\t} );\n\t};\n\n\tconst createHandleOnUnitChange = ( side ) => ( next ) => {\n\t\tconst newUnits = { ...selectedUnits };\n\t\tnewUnits[ side ] = next;\n\t\tsetSelectedUnits( newUnits );\n\t};\n\n\t// For shorthand style & backwards compatibility, handle flat string value.\n\tconst values =\n\t\ttypeof valuesProp !== 'string'\n\t\t\t? valuesProp\n\t\t\t: {\n\t\t\t\t\ttopLeft: valuesProp,\n\t\t\t\t\ttopRight: valuesProp,\n\t\t\t\t\tbottomLeft: valuesProp,\n\t\t\t\t\tbottomRight: valuesProp,\n\t\t\t };\n\n\t// Controls are wrapped in tooltips as visible labels aren't desired here.\n\t// Tooltip rendering also requires the UnitControl to be wrapped. See:\n\t// https://github.com/WordPress/gutenberg/pull/24966#issuecomment-685875026\n\treturn (\n\t\t<div className=\"components-border-radius-control__input-controls-wrapper\">\n\t\t\t{ Object.entries( CORNERS ).map( ( [ corner, label ] ) => {\n\t\t\t\tconst [ parsedQuantity, parsedUnit ] =\n\t\t\t\t\tparseQuantityAndUnitFromRawValue( values[ corner ] );\n\n\t\t\t\tconst computedUnit = values[ corner ]\n\t\t\t\t\t? parsedUnit\n\t\t\t\t\t: selectedUnits[ corner ] || selectedUnits.flat;\n\n\t\t\t\treturn (\n\t\t\t\t\t<Tooltip text={ label } placement=\"top\" key={ corner }>\n\t\t\t\t\t\t<div className=\"components-border-radius-control__tooltip-wrapper\">\n\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\t\t\tvalue={ [ parsedQuantity, computedUnit ].join(\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\tonChange={ createHandleOnChange( corner ) }\n\t\t\t\t\t\t\t\tonUnitChange={ createHandleOnUnitChange(\n\t\t\t\t\t\t\t\t\tcorner\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</Tooltip>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,8CAA8C,IAAIC,gCAAgC,EAClFC,yBAAyB,IAAIC,WAAW,EACxCC,OAAO,QACD,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AAEpC,MAAMC,OAAO,GAAG;EACfC,OAAO,EAAEF,EAAE,CAAE,UAAW,CAAC;EACzBG,QAAQ,EAAEH,EAAE,CAAE,WAAY,CAAC;EAC3BI,UAAU,EAAEJ,EAAE,CAAE,aAAc,CAAC;EAC/BK,WAAW,EAAEL,EAAE,CAAE,cAAe;AACjC,CAAC;AAED,eAAe,SAASM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IAEhD,OACCT,aAAA,CAACzB,OAAO;MAACmC,IAAI,EAAGL,KAAO;MAACM,SAAS,EAAC,KAAK;MAACC,GAAG,EAAGtB;IAAQ,GACrDU,aAAA;MAAKC,SAAS,EAAC;IAAmD,GACjED,aAAA,CAAC1B,WAAW;MAAA,GACNc,KAAK;MACV,cAAaiB,KAAO;MACpBQ,KAAK,EAAG,CAAEP,cAAc,EAAEE,YAAY,CAAE,CAACM,IAAI,CAC5C,EACD,CAAG;MACH/B,QAAQ,EAAGM,oBAAoB,CAAEC,MAAO,CAAG;MAC3CyB,YAAY,EAAGlB,wBAAwB,CACtCP,MACD,CAAG;MACH0B,IAAI,EAAG;IAAoB,CAC3B,CACG,CACG,CAAC;EAEZ,CAAE,CACE,CAAC;AAER"}
@@ -10,17 +10,15 @@ export default function LinkedButton({
10
10
  ...props
11
11
  }) {
12
12
  const label = isLinked ? __('Unlink radii') : __('Link radii');
13
-
14
- // TODO: Remove span after merging https://github.com/WordPress/gutenberg/pull/44198
15
13
  return createElement(Tooltip, {
16
14
  text: label
17
- }, createElement("span", null, createElement(Button, {
15
+ }, createElement(Button, {
18
16
  ...props,
19
17
  className: "component-border-radius-control__linked-button",
20
18
  isSmall: true,
21
19
  icon: isLinked ? link : linkOff,
22
20
  iconSize: 24,
23
21
  "aria-label": label
24
- })));
22
+ }));
25
23
  }
26
24
  //# sourceMappingURL=linked-button.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Button","Tooltip","link","linkOff","__","LinkedButton","isLinked","props","label","createElement","text","className","isSmall","icon","iconSize"],"sources":["@wordpress/block-editor/src/components/border-radius-control/linked-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Tooltip } from '@wordpress/components';\nimport { link, linkOff } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nexport default function LinkedButton( { isLinked, ...props } ) {\n\tconst label = isLinked ? __( 'Unlink radii' ) : __( 'Link radii' );\n\n\t// TODO: Remove span after merging https://github.com/WordPress/gutenberg/pull/44198\n\treturn (\n\t\t<Tooltip text={ label }>\n\t\t\t<span>\n\t\t\t\t<Button\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tclassName=\"component-border-radius-control__linked-button\"\n\t\t\t\t\tisSmall\n\t\t\t\t\ticon={ isLinked ? link : linkOff }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\taria-label={ label }\n\t\t\t\t/>\n\t\t\t</span>\n\t\t</Tooltip>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,OAAO,QAAQ,uBAAuB;AACvD,SAASC,IAAI,EAAEC,OAAO,QAAQ,kBAAkB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AAEpC,eAAe,SAASC,YAAYA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAG;EAC9D,MAAMC,KAAK,GAAGF,QAAQ,GAAGF,EAAE,CAAE,cAAe,CAAC,GAAGA,EAAE,CAAE,YAAa,CAAC;;EAElE;EACA,OACCK,aAAA,CAACR,OAAO;IAACS,IAAI,EAAGF;EAAO,GACtBC,aAAA,eACCA,aAAA,CAACT,MAAM;IAAA,GACDO,KAAK;IACVI,SAAS,EAAC,gDAAgD;IAC1DC,OAAO;IACPC,IAAI,EAAGP,QAAQ,GAAGJ,IAAI,GAAGC,OAAS;IAClCW,QAAQ,EAAG,EAAI;IACf,cAAaN;EAAO,CACpB,CACI,CACE,CAAC;AAEZ"}
1
+ {"version":3,"names":["Button","Tooltip","link","linkOff","__","LinkedButton","isLinked","props","label","createElement","text","className","isSmall","icon","iconSize"],"sources":["@wordpress/block-editor/src/components/border-radius-control/linked-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Tooltip } from '@wordpress/components';\nimport { link, linkOff } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nexport default function LinkedButton( { isLinked, ...props } ) {\n\tconst label = isLinked ? __( 'Unlink radii' ) : __( 'Link radii' );\n\n\treturn (\n\t\t<Tooltip text={ label }>\n\t\t\t<Button\n\t\t\t\t{ ...props }\n\t\t\t\tclassName=\"component-border-radius-control__linked-button\"\n\t\t\t\tisSmall\n\t\t\t\ticon={ isLinked ? link : linkOff }\n\t\t\t\ticonSize={ 24 }\n\t\t\t\taria-label={ label }\n\t\t\t/>\n\t\t</Tooltip>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,OAAO,QAAQ,uBAAuB;AACvD,SAASC,IAAI,EAAEC,OAAO,QAAQ,kBAAkB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AAEpC,eAAe,SAASC,YAAYA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAG;EAC9D,MAAMC,KAAK,GAAGF,QAAQ,GAAGF,EAAE,CAAE,cAAe,CAAC,GAAGA,EAAE,CAAE,YAAa,CAAC;EAElE,OACCK,aAAA,CAACR,OAAO;IAACS,IAAI,EAAGF;EAAO,GACtBC,aAAA,CAACT,MAAM;IAAA,GACDO,KAAK;IACVI,SAAS,EAAC,gDAAgD;IAC1DC,OAAO;IACPC,IAAI,EAAGP,QAAQ,GAAGJ,IAAI,GAAGC,OAAS;IAClCW,QAAQ,EAAG,EAAI;IACf,cAAaN;EAAO,CACpB,CACO,CAAC;AAEZ"}
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","Component","compose","createHigherOrderComponent","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","getMostReadableColor","useSetting","kebabCase","upperFirst","firstLetter","rest","toUpperCase","join","withCustomColorPalette","colorsArray","WrappedComponent","props","createElement","colors","withEditorColorPalette","userPalette","themePalette","defaultPalette","allColors","createColorHOC","colorTypes","withColorPalette","colorMap","reduce","colorObject","colorType","constructor","setters","createSetters","colorUtils","bind","state","colorValue","Object","keys","settersAccumulator","colorAttributeName","upperFirstColorAttributeName","customColorAttributeName","createSetColor","setAttributes","slug","undefined","getDerivedStateFromProps","attributes","previousState","entries","newState","colorContext","previousColorObject","previousColor","color","class","render","createCustomColorsHOC","withColors"],"sources":["@wordpress/block-editor/src/components/colors/with-colors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, Component } from '@wordpress/element';\nimport { compose, createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tgetMostReadableColor,\n} from './utils';\nimport useSetting from '../use-setting';\nimport { kebabCase } from '../../utils/object';\n\n/**\n * Capitalizes the first letter in a string.\n *\n * @param {string} str The string whose first letter the function will capitalize.\n *\n * @return {string} Capitalized string.\n */\nconst upperFirst = ( [ firstLetter, ...rest ] ) =>\n\tfirstLetter.toUpperCase() + rest.join( '' );\n\n/**\n * Higher order component factory for injecting the `colorsArray` argument as\n * the colors prop in the `withCustomColors` HOC.\n *\n * @param {Array} colorsArray An array of color objects.\n *\n * @return {Function} The higher order component.\n */\nconst withCustomColorPalette = ( colorsArray ) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) =>\n\t\t\t<WrappedComponent { ...props } colors={ colorsArray } />,\n\t\t'withCustomColorPalette'\n\t);\n\n/**\n * Higher order component factory for injecting the editor colors as the\n * `colors` prop in the `withColors` HOC.\n *\n * @return {Function} The higher order component.\n */\nconst withEditorColorPalette = () =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) => {\n\t\t\t// Some color settings have a special handling for deprecated flags in `useSetting`,\n\t\t\t// so we can't unwrap them by doing const { ... } = useSetting('color')\n\t\t\t// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.\n\t\t\tconst userPalette = useSetting( 'color.palette.custom' );\n\t\t\tconst themePalette = useSetting( 'color.palette.theme' );\n\t\t\tconst defaultPalette = useSetting( 'color.palette.default' );\n\t\t\tconst allColors = useMemo(\n\t\t\t\t() => [\n\t\t\t\t\t...( userPalette || [] ),\n\t\t\t\t\t...( themePalette || [] ),\n\t\t\t\t\t...( defaultPalette || [] ),\n\t\t\t\t],\n\t\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t\t);\n\t\t\treturn <WrappedComponent { ...props } colors={ allColors } />;\n\t\t},\n\t\t'withEditorColorPalette'\n\t);\n\n/**\n * Helper function used with `createHigherOrderComponent` to create\n * higher order components for managing color logic.\n *\n * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).\n * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.\n *\n * @return {WPComponent} The component that can be used as a HOC.\n */\nfunction createColorHOC( colorTypes, withColorPalette ) {\n\tconst colorMap = colorTypes.reduce( ( colorObject, colorType ) => {\n\t\treturn {\n\t\t\t...colorObject,\n\t\t\t...( typeof colorType === 'string'\n\t\t\t\t? { [ colorType ]: kebabCase( colorType ) }\n\t\t\t\t: colorType ),\n\t\t};\n\t}, {} );\n\n\treturn compose( [\n\t\twithColorPalette,\n\t\t( WrappedComponent ) => {\n\t\t\treturn class extends Component {\n\t\t\t\tconstructor( props ) {\n\t\t\t\t\tsuper( props );\n\n\t\t\t\t\tthis.setters = this.createSetters();\n\t\t\t\t\tthis.colorUtils = {\n\t\t\t\t\t\tgetMostReadableColor:\n\t\t\t\t\t\t\tthis.getMostReadableColor.bind( this ),\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.state = {};\n\t\t\t\t}\n\n\t\t\t\tgetMostReadableColor( colorValue ) {\n\t\t\t\t\tconst { colors } = this.props;\n\t\t\t\t\treturn getMostReadableColor( colors, colorValue );\n\t\t\t\t}\n\n\t\t\t\tcreateSetters() {\n\t\t\t\t\treturn Object.keys( colorMap ).reduce(\n\t\t\t\t\t\t( settersAccumulator, colorAttributeName ) => {\n\t\t\t\t\t\t\tconst upperFirstColorAttributeName =\n\t\t\t\t\t\t\t\tupperFirst( colorAttributeName );\n\t\t\t\t\t\t\tconst customColorAttributeName = `custom${ upperFirstColorAttributeName }`;\n\t\t\t\t\t\t\tsettersAccumulator[\n\t\t\t\t\t\t\t\t`set${ upperFirstColorAttributeName }`\n\t\t\t\t\t\t\t] = this.createSetColor(\n\t\t\t\t\t\t\t\tcolorAttributeName,\n\t\t\t\t\t\t\t\tcustomColorAttributeName\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn settersAccumulator;\n\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\n\t\t\t\tcreateSetColor( colorAttributeName, customColorAttributeName ) {\n\t\t\t\t\treturn ( colorValue ) => {\n\t\t\t\t\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\t\t\t\t\tthis.props.colors,\n\t\t\t\t\t\t\tcolorValue\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.props.setAttributes( {\n\t\t\t\t\t\t\t[ colorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? colorObject.slug\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t[ customColorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t: colorValue,\n\t\t\t\t\t\t} );\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tstatic getDerivedStateFromProps(\n\t\t\t\t\t{ attributes, colors },\n\t\t\t\t\tpreviousState\n\t\t\t\t) {\n\t\t\t\t\treturn Object.entries( colorMap ).reduce(\n\t\t\t\t\t\t( newState, [ colorAttributeName, colorContext ] ) => {\n\t\t\t\t\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\tcolors,\n\t\t\t\t\t\t\t\tattributes[ colorAttributeName ],\n\t\t\t\t\t\t\t\tattributes[\n\t\t\t\t\t\t\t\t\t`custom${ upperFirst(\n\t\t\t\t\t\t\t\t\t\tcolorAttributeName\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);\n\n\t\t\t\t\t\t\tconst previousColorObject =\n\t\t\t\t\t\t\t\tpreviousState[ colorAttributeName ];\n\t\t\t\t\t\t\tconst previousColor = previousColorObject?.color;\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * The \"and previousColorObject\" condition checks that a previous color object was already computed.\n\t\t\t\t\t\t\t * At the start previousColorObject and colorValue are both equal to undefined\n\t\t\t\t\t\t\t * bus as previousColorObject does not exist we should compute the object.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpreviousColor === colorObject.color &&\n\t\t\t\t\t\t\t\tpreviousColorObject\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] =\n\t\t\t\t\t\t\t\t\tpreviousColorObject;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] = {\n\t\t\t\t\t\t\t\t\t...colorObject,\n\t\t\t\t\t\t\t\t\tclass: getColorClassName(\n\t\t\t\t\t\t\t\t\t\tcolorContext,\n\t\t\t\t\t\t\t\t\t\tcolorObject.slug\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}\n\t\t\t\t\t\t\treturn newState;\n\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\n\t\t\t\trender() {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\t...this.props,\n\t\t\t\t\t\t\t\tcolors: undefined,\n\t\t\t\t\t\t\t\t...this.state,\n\t\t\t\t\t\t\t\t...this.setters,\n\t\t\t\t\t\t\t\tcolorUtils: this.colorUtils,\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 * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic\n * for class generation color value, retrieval and color attribute setting.\n *\n * Use this higher-order component to work with a custom set of colors.\n *\n * @example\n *\n * ```jsx\n * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];\n * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );\n * // ...\n * export default compose(\n * withCustomColors( 'backgroundColor', 'borderColor' ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).\n *\n * @return {Function} Higher-order component.\n */\nexport function createCustomColorsHOC( colorsArray ) {\n\treturn ( ...colorTypes ) => {\n\t\tconst withColorPalette = withCustomColorPalette( colorsArray );\n\t\treturn createHigherOrderComponent(\n\t\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t\t'withCustomColors'\n\t\t);\n\t};\n}\n\n/**\n * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.\n *\n * For use with the default editor/theme color palette.\n *\n * @example\n *\n * ```jsx\n * export default compose(\n * withColors( 'backgroundColor', { textColor: 'color' } ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,\n * it should contain the color attribute name as key and the color context as value.\n * If the argument is a string the value should be the color attribute name,\n * the color context is computed by applying a kebab case transform to the value.\n * Color context represents the context/place where the color is going to be used.\n * The class name of the color is generated using 'has' followed by the color name\n * and ending with the color context all in kebab case e.g: has-green-background-color.\n *\n * @return {Function} Higher-order component.\n */\nexport default function withColors( ...colorTypes ) {\n\tconst withColorPalette = withEditorColorPalette();\n\treturn createHigherOrderComponent(\n\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t'withColors'\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACvD,SAASC,OAAO,EAAEC,0BAA0B,QAAQ,oBAAoB;;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D,iBAAiB,CACvBmD,YAAY,EACZxB,WAAW,CAACiB,IACb;YACD,CAAC;UACF;UACA,OAAOM,QAAQ;QAChB,CAAC,EACD,CAAC,CACF,CAAC;MACF;MAEAM,MAAMA,CAAA,EAAG;QACR,OACCzC,aAAA,CAACF,gBAAgB;UAEf,GAAG,IAAI,CAACC,KAAK;UACbE,MAAM,EAAE6B,SAAS;UACjB,GAAG,IAAI,CAACX,KAAK;UACb,GAAG,IAAI,CAACJ,OAAO;UACfE,UAAU,EAAE,IAAI,CAACA;QAAU,CAE5B,CAAC;MAEJ;IACD,CAAC;EACF,CAAC,CACA,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASyB,qBAAqBA,CAAE7C,WAAW,EAAG;EACpD,OAAO,CAAE,GAAGW,UAAU,KAAM;IAC3B,MAAMC,gBAAgB,GAAGb,sBAAsB,CAAEC,WAAY,CAAC;IAC9D,OAAOb,0BAA0B,CAChCuB,cAAc,CAAEC,UAAU,EAAEC,gBAAiB,CAAC,EAC9C,kBACD,CAAC;EACF,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASkC,UAAUA,CAAE,GAAGnC,UAAU,EAAG;EACnD,MAAMC,gBAAgB,GAAGP,sBAAsB,CAAC,CAAC;EACjD,OAAOlB,0BAA0B,CAChCuB,cAAc,CAAEC,UAAU,EAAEC,gBAAiB,CAAC,EAC9C,YACD,CAAC;AACF"}
1
+ {"version":3,"names":["useMemo","Component","compose","createHigherOrderComponent","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","getMostReadableColor","useSetting","kebabCase","upperFirst","firstLetter","rest","toUpperCase","join","withCustomColorPalette","colorsArray","WrappedComponent","props","createElement","colors","withEditorColorPalette","userPalette","themePalette","defaultPalette","allColors","createColorHOC","colorTypes","withColorPalette","colorMap","reduce","colorObject","colorType","constructor","setters","createSetters","colorUtils","bind","state","colorValue","Object","keys","settersAccumulator","colorAttributeName","upperFirstColorAttributeName","customColorAttributeName","createSetColor","setAttributes","slug","undefined","getDerivedStateFromProps","attributes","previousState","entries","newState","colorContext","previousColorObject","previousColor","color","class","render","createCustomColorsHOC","withColors"],"sources":["@wordpress/block-editor/src/components/colors/with-colors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, Component } from '@wordpress/element';\nimport { compose, createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tgetMostReadableColor,\n} from './utils';\nimport useSetting from '../use-setting';\nimport { kebabCase } from '../../utils/object';\n\n/**\n * Capitalizes the first letter in a string.\n *\n * @param {string} str The string whose first letter the function will capitalize.\n *\n * @return {string} Capitalized string.\n */\nconst upperFirst = ( [ firstLetter, ...rest ] ) =>\n\tfirstLetter.toUpperCase() + rest.join( '' );\n\n/**\n * Higher order component factory for injecting the `colorsArray` argument as\n * the colors prop in the `withCustomColors` HOC.\n *\n * @param {Array} colorsArray An array of color objects.\n *\n * @return {Function} The higher order component.\n */\nconst withCustomColorPalette = ( colorsArray ) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) => (\n\t\t\t<WrappedComponent { ...props } colors={ colorsArray } />\n\t\t),\n\t\t'withCustomColorPalette'\n\t);\n\n/**\n * Higher order component factory for injecting the editor colors as the\n * `colors` prop in the `withColors` HOC.\n *\n * @return {Function} The higher order component.\n */\nconst withEditorColorPalette = () =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) => {\n\t\t\t// Some color settings have a special handling for deprecated flags in `useSetting`,\n\t\t\t// so we can't unwrap them by doing const { ... } = useSetting('color')\n\t\t\t// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.\n\t\t\tconst userPalette = useSetting( 'color.palette.custom' );\n\t\t\tconst themePalette = useSetting( 'color.palette.theme' );\n\t\t\tconst defaultPalette = useSetting( 'color.palette.default' );\n\t\t\tconst allColors = useMemo(\n\t\t\t\t() => [\n\t\t\t\t\t...( userPalette || [] ),\n\t\t\t\t\t...( themePalette || [] ),\n\t\t\t\t\t...( defaultPalette || [] ),\n\t\t\t\t],\n\t\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t\t);\n\t\t\treturn <WrappedComponent { ...props } colors={ allColors } />;\n\t\t},\n\t\t'withEditorColorPalette'\n\t);\n\n/**\n * Helper function used with `createHigherOrderComponent` to create\n * higher order components for managing color logic.\n *\n * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).\n * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.\n *\n * @return {WPComponent} The component that can be used as a HOC.\n */\nfunction createColorHOC( colorTypes, withColorPalette ) {\n\tconst colorMap = colorTypes.reduce( ( colorObject, colorType ) => {\n\t\treturn {\n\t\t\t...colorObject,\n\t\t\t...( typeof colorType === 'string'\n\t\t\t\t? { [ colorType ]: kebabCase( colorType ) }\n\t\t\t\t: colorType ),\n\t\t};\n\t}, {} );\n\n\treturn compose( [\n\t\twithColorPalette,\n\t\t( WrappedComponent ) => {\n\t\t\treturn class extends Component {\n\t\t\t\tconstructor( props ) {\n\t\t\t\t\tsuper( props );\n\n\t\t\t\t\tthis.setters = this.createSetters();\n\t\t\t\t\tthis.colorUtils = {\n\t\t\t\t\t\tgetMostReadableColor:\n\t\t\t\t\t\t\tthis.getMostReadableColor.bind( this ),\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.state = {};\n\t\t\t\t}\n\n\t\t\t\tgetMostReadableColor( colorValue ) {\n\t\t\t\t\tconst { colors } = this.props;\n\t\t\t\t\treturn getMostReadableColor( colors, colorValue );\n\t\t\t\t}\n\n\t\t\t\tcreateSetters() {\n\t\t\t\t\treturn Object.keys( colorMap ).reduce(\n\t\t\t\t\t\t( settersAccumulator, colorAttributeName ) => {\n\t\t\t\t\t\t\tconst upperFirstColorAttributeName =\n\t\t\t\t\t\t\t\tupperFirst( colorAttributeName );\n\t\t\t\t\t\t\tconst customColorAttributeName = `custom${ upperFirstColorAttributeName }`;\n\t\t\t\t\t\t\tsettersAccumulator[\n\t\t\t\t\t\t\t\t`set${ upperFirstColorAttributeName }`\n\t\t\t\t\t\t\t] = this.createSetColor(\n\t\t\t\t\t\t\t\tcolorAttributeName,\n\t\t\t\t\t\t\t\tcustomColorAttributeName\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn settersAccumulator;\n\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\n\t\t\t\tcreateSetColor( colorAttributeName, customColorAttributeName ) {\n\t\t\t\t\treturn ( colorValue ) => {\n\t\t\t\t\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\t\t\t\t\tthis.props.colors,\n\t\t\t\t\t\t\tcolorValue\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.props.setAttributes( {\n\t\t\t\t\t\t\t[ colorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? colorObject.slug\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t[ customColorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t: colorValue,\n\t\t\t\t\t\t} );\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tstatic getDerivedStateFromProps(\n\t\t\t\t\t{ attributes, colors },\n\t\t\t\t\tpreviousState\n\t\t\t\t) {\n\t\t\t\t\treturn Object.entries( colorMap ).reduce(\n\t\t\t\t\t\t( newState, [ colorAttributeName, colorContext ] ) => {\n\t\t\t\t\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\tcolors,\n\t\t\t\t\t\t\t\tattributes[ colorAttributeName ],\n\t\t\t\t\t\t\t\tattributes[\n\t\t\t\t\t\t\t\t\t`custom${ upperFirst(\n\t\t\t\t\t\t\t\t\t\tcolorAttributeName\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);\n\n\t\t\t\t\t\t\tconst previousColorObject =\n\t\t\t\t\t\t\t\tpreviousState[ colorAttributeName ];\n\t\t\t\t\t\t\tconst previousColor = previousColorObject?.color;\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * The \"and previousColorObject\" condition checks that a previous color object was already computed.\n\t\t\t\t\t\t\t * At the start previousColorObject and colorValue are both equal to undefined\n\t\t\t\t\t\t\t * bus as previousColorObject does not exist we should compute the object.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpreviousColor === colorObject.color &&\n\t\t\t\t\t\t\t\tpreviousColorObject\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] =\n\t\t\t\t\t\t\t\t\tpreviousColorObject;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] = {\n\t\t\t\t\t\t\t\t\t...colorObject,\n\t\t\t\t\t\t\t\t\tclass: getColorClassName(\n\t\t\t\t\t\t\t\t\t\tcolorContext,\n\t\t\t\t\t\t\t\t\t\tcolorObject.slug\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}\n\t\t\t\t\t\t\treturn newState;\n\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\n\t\t\t\trender() {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\t...this.props,\n\t\t\t\t\t\t\t\tcolors: undefined,\n\t\t\t\t\t\t\t\t...this.state,\n\t\t\t\t\t\t\t\t...this.setters,\n\t\t\t\t\t\t\t\tcolorUtils: this.colorUtils,\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 * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic\n * for class generation color value, retrieval and color attribute setting.\n *\n * Use this higher-order component to work with a custom set of colors.\n *\n * @example\n *\n * ```jsx\n * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];\n * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );\n * // ...\n * export default compose(\n * withCustomColors( 'backgroundColor', 'borderColor' ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).\n *\n * @return {Function} Higher-order component.\n */\nexport function createCustomColorsHOC( colorsArray ) {\n\treturn ( ...colorTypes ) => {\n\t\tconst withColorPalette = withCustomColorPalette( colorsArray );\n\t\treturn createHigherOrderComponent(\n\t\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t\t'withCustomColors'\n\t\t);\n\t};\n}\n\n/**\n * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.\n *\n * For use with the default editor/theme color palette.\n *\n * @example\n *\n * ```jsx\n * export default compose(\n * withColors( 'backgroundColor', { textColor: 'color' } ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,\n * it should contain the color attribute name as key and the color context as value.\n * If the argument is a string the value should be the color attribute name,\n * the color context is computed by applying a kebab case transform to the value.\n * Color context represents the context/place where the color is going to be used.\n * The class name of the color is generated using 'has' followed by the color name\n * and ending with the color context all in kebab case e.g: has-green-background-color.\n *\n * @return {Function} Higher-order component.\n */\nexport default function withColors( ...colorTypes ) {\n\tconst withColorPalette = withEditorColorPalette();\n\treturn createHigherOrderComponent(\n\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t'withColors'\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACvD,SAASC,OAAO,EAAEC,0BAA0B,QAAQ,oBAAoB;;AAExE;AACA;AACA;AACA,SACCC,iBAAiB,EACjBC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,oBAAoB,QACd,SAAS;AAChB,OAAOC,UAAU,MAAM,gBAAgB;AACvC,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAGA,CAAE,CAAEC,WAAW,EAAE,GAAGC,IAAI,CAAE,KAC5CD,WAAW,CAACE,WAAW,CAAC,CAAC,GAAGD,IAAI,CAACE,IAAI,CAAE,EAAG,CAAC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GAAKC,WAAW,IAC3Cb,0BAA0B,CACvBc,gBAAgB,IAAQC,KAAK,IAC9BC,aAAA,CAACF,gBAAgB;EAAA,GAAMC,KAAK;EAAGE,MAAM,EAAGJ;AAAa,CAAE,CACvD,EACD,wBACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,sBAAsB,GAAGA,CAAA,KAC9BlB,0BAA0B,CACvBc,gBAAgB,IAAQC,KAAK,IAAM;EACpC;EACA;EACA;EACA,MAAMI,WAAW,GAAGd,UAAU,CAAE,sBAAuB,CAAC;EACxD,MAAMe,YAAY,GAAGf,UAAU,CAAE,qBAAsB,CAAC;EACxD,MAAMgB,cAAc,GAAGhB,UAAU,CAAE,uBAAwB,CAAC;EAC5D,MAAMiB,SAAS,GAAGzB,OAAO,CACxB,MAAM,CACL,IAAKsB,WAAW,IAAI,EAAE,CAAE,EACxB,IAAKC,YAAY,IAAI,EAA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BAA0B,CAChCuB,cAAc,CAAEC,UAAU,EAAEC,gBAAiB,CAAC,EAC9C,YACD,CAAC;AACF"}
@@ -33,39 +33,26 @@ import { store as blockEditorStore } from '../../store';
33
33
  export default function useConvertToGroupButtonProps(selectedClientIds) {
34
34
  return useSelect(select => {
35
35
  const {
36
- getBlockRootClientId,
37
36
  getBlocksByClientId,
38
- canInsertBlockType,
39
- getSelectedBlockClientIds
37
+ getSelectedBlockClientIds,
38
+ isUngroupable,
39
+ isGroupable
40
40
  } = select(blockEditorStore);
41
41
  const {
42
42
  getGroupingBlockName,
43
43
  getBlockType
44
44
  } = select(blocksStore);
45
45
  const clientIds = selectedClientIds?.length ? selectedClientIds : getSelectedBlockClientIds();
46
- const groupingBlockName = getGroupingBlockName();
47
- const rootClientId = clientIds?.length ? getBlockRootClientId(clientIds[0]) : undefined;
48
- const groupingBlockAvailable = canInsertBlockType(groupingBlockName, rootClientId);
49
46
  const blocksSelection = getBlocksByClientId(clientIds);
50
- const isSingleBlockSelected = blocksSelection.length === 1;
51
47
  const [firstSelectedBlock] = blocksSelection;
52
- // A block is ungroupable if it is a single grouping block with inner blocks.
53
- // If a block has an `ungroup` transform, it is also ungroupable, without the
54
- // requirement of being the default grouping block.
55
- // Do we have a single grouping Block selected and does that group have inner blocks?
56
- const isUngroupable = isSingleBlockSelected && (firstSelectedBlock.name === groupingBlockName || getBlockType(firstSelectedBlock.name)?.transforms?.ungroup) && !!firstSelectedBlock.innerBlocks.length;
57
-
58
- // Do we have
59
- // 1. Grouping block available to be inserted?
60
- // 2. One or more blocks selected
61
- const isGroupable = groupingBlockAvailable && blocksSelection.length;
48
+ const _isUngroupable = clientIds.length === 1 && isUngroupable(clientIds[0]);
62
49
  return {
63
50
  clientIds,
64
- isGroupable,
65
- isUngroupable,
51
+ isGroupable: isGroupable(clientIds),
52
+ isUngroupable: _isUngroupable,
66
53
  blocksSelection,
67
- groupingBlockName,
68
- onUngroup: isUngroupable && getBlockType(firstSelectedBlock.name)?.transforms?.ungroup
54
+ groupingBlockName: getGroupingBlockName(),
55
+ onUngroup: _isUngroupable && getBlockType(firstSelectedBlock.name)?.transforms?.ungroup
69
56
  };
70
57
  }, [selectedClientIds]);
71
58
  }
@@ -1 +1 @@
1
- {"version":3,"names":["store","blocksStore","useSelect","blockEditorStore","useConvertToGroupButtonProps","selectedClientIds","select","getBlockRootClientId","getBlocksByClientId","canInsertBlockType","getSelectedBlockClientIds","getGroupingBlockName","getBlockType","clientIds","length","groupingBlockName","rootClientId","undefined","groupingBlockAvailable","blocksSelection","isSingleBlockSelected","firstSelectedBlock","isUngroupable","name","transforms","ungroup","innerBlocks","isGroupable","onUngroup"],"sources":["@wordpress/block-editor/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Contains the properties `ConvertToGroupButton` component needs.\n *\n * @typedef {Object} ConvertToGroupButtonProps\n * @property {string[]} clientIds An array of the selected client ids.\n * @property {boolean} isGroupable Indicates if the selected blocks can be grouped.\n * @property {boolean} isUngroupable Indicates if the selected blocks can be ungrouped.\n * @property {WPBlock[]} blocksSelection An array of the selected blocks.\n * @property {string} groupingBlockName The name of block used for handling grouping interactions.\n */\n\n/**\n * Returns the properties `ConvertToGroupButton` component needs to work properly.\n * It is used in `BlockSettingsMenuControls` to know if `ConvertToGroupButton`\n * should be rendered, to avoid ending up with an empty MenuGroup.\n *\n * @param {?string[]} selectedClientIds An optional array of clientIds to group. The selected blocks\n * from the block editor store are used if this is not provided.\n *\n * @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`.\n */\nexport default function useConvertToGroupButtonProps( selectedClientIds ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getGroupingBlockName, getBlockType } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst clientIds = selectedClientIds?.length\n\t\t\t\t? selectedClientIds\n\t\t\t\t: getSelectedBlockClientIds();\n\t\t\tconst groupingBlockName = getGroupingBlockName();\n\n\t\t\tconst rootClientId = clientIds?.length\n\t\t\t\t? getBlockRootClientId( clientIds[ 0 ] )\n\t\t\t\t: undefined;\n\n\t\t\tconst groupingBlockAvailable = canInsertBlockType(\n\t\t\t\tgroupingBlockName,\n\t\t\t\trootClientId\n\t\t\t);\n\n\t\t\tconst blocksSelection = getBlocksByClientId( clientIds );\n\t\t\tconst isSingleBlockSelected = blocksSelection.length === 1;\n\t\t\tconst [ firstSelectedBlock ] = blocksSelection;\n\t\t\t// A block is ungroupable if it is a single grouping block with inner blocks.\n\t\t\t// If a block has an `ungroup` transform, it is also ungroupable, without the\n\t\t\t// requirement of being the default grouping block.\n\t\t\t// Do we have a single grouping Block selected and does that group have inner blocks?\n\t\t\tconst isUngroupable =\n\t\t\t\tisSingleBlockSelected &&\n\t\t\t\t( firstSelectedBlock.name === groupingBlockName ||\n\t\t\t\t\tgetBlockType( firstSelectedBlock.name )?.transforms\n\t\t\t\t\t\t?.ungroup ) &&\n\t\t\t\t!! firstSelectedBlock.innerBlocks.length;\n\n\t\t\t// Do we have\n\t\t\t// 1. Grouping block available to be inserted?\n\t\t\t// 2. One or more blocks selected\n\t\t\tconst isGroupable =\n\t\t\t\tgroupingBlockAvailable && blocksSelection.length;\n\n\t\t\treturn {\n\t\t\t\tclientIds,\n\t\t\t\tisGroupable,\n\t\t\t\tisUngroupable,\n\t\t\t\tblocksSelection,\n\t\t\t\tgroupingBlockName,\n\t\t\t\tonUngroup:\n\t\t\t\t\tisUngroupable &&\n\t\t\t\t\tgetBlockType( firstSelectedBlock.name )?.transforms\n\t\t\t\t\t\t?.ung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CAAC,EAAEC,UAAU,EAChDC,OAAO,CAAE,IACb,CAAC,CAAEJ,kBAAkB,CAACK,WAAW,CAACZ,MAAM;;IAEzC;IACA;IACA;IACA,MAAMa,WAAW,GAChBT,sBAAsB,IAAIC,eAAe,CAACL,MAAM;IAEjD,OAAO;MACND,SAAS;MACTc,WAAW;MACXL,aAAa;MACbH,eAAe;MACfJ,iBAAiB;MACjBa,SAAS,EACRN,aAAa,IACbV,YAAY,CAAES,kBAAkB,CAACE,IAAK,CAAC,EAAEC,UAAU,EAChDC;IACL,CAAC;EACF,CAAC,EACD,CAAEpB,iBAAiB,CACpB,CAAC;AACF"}
1
+ {"version":3,"names":["store","blocksStore","useSelect","blockEditorStore","useConvertToGroupButtonProps","selectedClientIds","select","getBlocksByClientId","getSelectedBlockClientIds","isUngroupable","isGroupable","getGroupingBlockName","getBlockType","clientIds","length","blocksSelection","firstSelectedBlock","_isUngroupable","groupingBlockName","onUngroup","name","transforms","ungroup"],"sources":["@wordpress/block-editor/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Contains the properties `ConvertToGroupButton` component needs.\n *\n * @typedef {Object} ConvertToGroupButtonProps\n * @property {string[]} clientIds An array of the selected client ids.\n * @property {boolean} isGroupable Indicates if the selected blocks can be grouped.\n * @property {boolean} isUngroupable Indicates if the selected blocks can be ungrouped.\n * @property {WPBlock[]} blocksSelection An array of the selected blocks.\n * @property {string} groupingBlockName The name of block used for handling grouping interactions.\n */\n\n/**\n * Returns the properties `ConvertToGroupButton` component needs to work properly.\n * It is used in `BlockSettingsMenuControls` to know if `ConvertToGroupButton`\n * should be rendered, to avoid ending up with an empty MenuGroup.\n *\n * @param {?string[]} selectedClientIds An optional array of clientIds to group. The selected blocks\n * from the block editor store are used if this is not provided.\n *\n * @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`.\n */\nexport default function useConvertToGroupButtonProps( selectedClientIds ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tisUngroupable,\n\t\t\t\tisGroupable,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getGroupingBlockName, getBlockType } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst clientIds = selectedClientIds?.length\n\t\t\t\t? selectedClientIds\n\t\t\t\t: getSelectedBlockClientIds();\n\t\t\tconst blocksSelection = getBlocksByClientId( clientIds );\n\t\t\tconst [ firstSelectedBlock ] = blocksSelection;\n\t\t\tconst _isUngroupable =\n\t\t\t\tclientIds.length === 1 && isUngroupable( clientIds[ 0 ] );\n\t\t\treturn {\n\t\t\t\tclientIds,\n\t\t\t\tisGroupable: isGroupable( clientIds ),\n\t\t\t\tisUngroupable: _isUngroupable,\n\t\t\t\tblocksSelection,\n\t\t\t\tgroupingBlockName: getGroupingBlockName(),\n\t\t\t\tonUngroup:\n\t\t\t\t\t_isUngroupable &&\n\t\t\t\t\tgetBlockType( firstSelectedBlock.name )?.transforms\n\t\t\t\t\t\t?.ungroup,\n\t\t\t};\n\t\t},\n\t\t[ selectedClientIds ]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASF,KAAK,IAAIG,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,4BAA4BA,CAAEC,iBAAiB,EAAG;EACzE,OAAOH,SAAS,CACbI,MAAM,IAAM;IACb,MAAM;MACLC,mBAAmB;MACnBC,yBAAyB;MACzBC,aAAa;MACbC;IACD,CAAC,GAAGJ,MAAM,CAAEH,gBAAiB,CAAC;IAC9B,MAAM;MAAEQ,oBAAoB;MAAEC;IAAa,CAAC,GAC3CN,MAAM,CAAEL,WAAY,CAAC;IACtB,MAAMY,SAAS,GAAGR,iBAAiB,EAAES,MAAM,GACxCT,iBAAiB,GACjBG,yBAAyB,CAAC,CAAC;IAC9B,MAAMO,eAAe,GAAGR,mBAAmB,CAAEM,SAAU,CAAC;IACxD,MAAM,CAAEG,kBAAkB,CAAE,GAAGD,eAAe;IAC9C,MAAME,cAAc,GACnBJ,SAAS,CAACC,MAAM,KAAK,CAAC,IAAIL,aAAa,CAAEI,SAAS,CAAE,CAAC,CAAG,CAAC;IAC1D,OAAO;MACNA,SAAS;MACTH,WAAW,EAAEA,WAAW,CAAEG,SAAU,CAAC;MACrCJ,aAAa,EAAEQ,cAAc;MAC7BF,eAAe;MACfG,iBAAiB,EAAEP,oBAAoB,CAAC,CAAC;MACzCQ,SAAS,EACRF,cAAc,IACdL,YAAY,CAAEI,kBAAkB,CAACI,IAAK,CAAC,EAAEC,UAAU,EAChDC;IACL,CAAC;EACF,CAAC,EACD,CAAEjB,iBAAiB,CACpB,CAAC;AACF"}
@@ -28,6 +28,7 @@ const hitSlop = {
28
28
  };
29
29
  const noop = () => {};
30
30
  export function DefaultBlockAppender({
31
+ baseGlobalStyles,
31
32
  isLocked,
32
33
  isVisible,
33
34
  onAppend,
@@ -38,6 +39,19 @@ export function DefaultBlockAppender({
38
39
  if (isLocked || !isVisible) {
39
40
  return null;
40
41
  }
42
+ const blockGlobalStyles = baseGlobalStyles?.blocks?.['core/paragraph'];
43
+ const {
44
+ fontSize,
45
+ lineHeight
46
+ } = blockGlobalStyles?.typography || {};
47
+ const textStyles = blockGlobalStyles?.typography ? {
48
+ ...(fontSize && {
49
+ fontSize
50
+ }),
51
+ ...(lineHeight && {
52
+ lineHeight
53
+ })
54
+ } : undefined;
41
55
  const value = typeof placeholder === 'string' ? decodeEntities(placeholder) : __('Start writing…');
42
56
  const appenderStyles = [styles.blockHolder, showSeparator && containerStyle];
43
57
  return createElement(Pressable, {
@@ -48,20 +62,25 @@ export function DefaultBlockAppender({
48
62
  pointerEvents: "box-only"
49
63
  }, showSeparator ? createElement(BlockInsertionPoint, null) : createElement(RichText, {
50
64
  placeholder: value,
51
- onChange: noop
65
+ onChange: noop,
66
+ tagName: "p",
67
+ style: textStyles
52
68
  })));
53
69
  }
54
70
  export default compose(withSelect((select, ownProps) => {
55
71
  const {
56
72
  getBlockCount,
57
73
  getBlockName,
74
+ getSettings,
58
75
  isBlockValid,
59
76
  getTemplateLock
60
77
  } = select(blockEditorStore);
61
78
  const isEmpty = !getBlockCount(ownProps.rootClientId);
62
79
  const isLastBlockDefault = getBlockName(ownProps.lastBlockClientId) === getDefaultBlockName();
63
80
  const isLastBlockValid = isBlockValid(ownProps.lastBlockClientId);
81
+ const globalStylesBaseStyles = getSettings()?.__experimentalGlobalStylesBaseStyles;
64
82
  return {
83
+ baseGlobalStyles: globalStylesBaseStyles,
65
84
  isVisible: isEmpty || !isLastBlockDefault || !isLastBlockValid,
66
85
  isLocked: !!getTemplateLock(ownProps.rootClientId)
67
86
  };
@@ -1 +1 @@
1
- {"version":3,"names":["Pressable","View","__","RichText","compose","decodeEntities","withSelect","withDispatch","getDefaultBlockName","BlockInsertionPoint","styles","store","blockEditorStore","hitSlop","top","bottom","left","right","noop","DefaultBlockAppender","isLocked","isVisible","onAppend","placeholder","containerStyle","showSeparator","value","appenderStyles","blockHolder","createElement","onPress","style","pointerEvents","onChange","select","ownProps","getBlockCount","getBlockName","isBlockValid","getTemplateLock","isEmpty","rootClientId","isLastBlockDefault","lastBlockClientId","isLastBlockValid","dispatch","insertDefaultBlock","startTyping","undefined"],"sources":["@wordpress/block-editor/src/components/default-block-appender/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Pressable, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { RichText } from '@wordpress/block-editor';\nimport { compose } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport BlockInsertionPoint from '../block-list/insertion-point';\nimport styles from './style.scss';\nimport { store as blockEditorStore } from '../../store';\n\nconst hitSlop = { top: 22, bottom: 22, left: 22, right: 22 };\nconst noop = () => {};\n\nexport function DefaultBlockAppender( {\n\tisLocked,\n\tisVisible,\n\tonAppend,\n\tplaceholder,\n\tcontainerStyle,\n\tshowSeparator,\n} ) {\n\tif ( isLocked || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\tconst value =\n\t\ttypeof placeholder === 'string'\n\t\t\t? decodeEntities( placeholder )\n\t\t\t: __( 'Start writing…' );\n\n\tconst appenderStyles = [\n\t\tstyles.blockHolder,\n\t\tshowSeparator && containerStyle,\n\t];\n\n\treturn (\n\t\t<Pressable onPress={ onAppend } hitSlop={ hitSlop }>\n\t\t\t<View style={ appenderStyles } pointerEvents=\"box-only\">\n\t\t\t\t{ showSeparator ? (\n\t\t\t\t\t<BlockInsertionPoint />\n\t\t\t\t) : (\n\t\t\t\t\t<RichText placeholder={ value } onChange={ noop } />\n\t\t\t\t) }\n\t\t\t</View>\n\t\t</Pressable>\n\t);\n}\n\nexport default compose(\n\twithSelect( ( select, ownProps ) => {\n\t\tconst { getBlockCount, getBlockName, isBlockValid, getTemplateLock } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst isEmpty = ! getBlockCount( ownProps.rootClientId );\n\t\tconst isLastBlockDefault =\n\t\t\tgetBlockName( ownProps.lastBlockClientId ) ===\n\t\t\tgetDefaultBlockName();\n\t\tconst isLastBlockValid = isBlockValid( ownProps.lastBlockClientId );\n\n\t\treturn {\n\t\t\tisVisible: isEmpty || ! isLastBlockDefault || ! isLastBlockValid,\n\t\t\tisLocked: !! getTemplateLock( ownProps.rootClientId ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, ownProps ) => {\n\t\tconst { insertDefaultBlock, startTyping } =\n\t\t\tdispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\tonAppend() {\n\t\t\t\tconst { rootClientId } = ownProps;\n\n\t\t\t\tinsertDefaultBlock( undefined, rootClientId );\n\t\t\t\tstartTyping();\n\t\t\t},\n\t\t};\n\t} )\n)( DefaultBlockAppender );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,IAAI,QAAQ,cAAc;;AAE9C;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,yBAAyB;AAClD,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAC1D,SAASC,mBAAmB,QAAQ,mBAAmB;;AAEvD;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,+BAA+B;AAC/D,OAAOC,MAAM,MAAM,cAAc;AACjC,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,MAAMC,OAAO,GAAG;EAAEC,GAAG,EAAE,EAAE;EAAEC,MAAM,EAAE,EAAE;EAAEC,IAAI,EAAE,EAAE;EAAEC,KAAK,EAAE;AAAG,CAAC;AAC5D,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,OAAO,SAASC,oBAAoBA,CAAE;EACrCC,QAAQ;EACRC,SAAS;EACTC,QAAQ;EACRC,WAAW;EACXC,cAAc;EACdC;AACD,CAAC,EAAG;EACH,IAAKL,QAAQ,IAAI,CAAEC,SAAS,EAAG;IAC9B,OAAO,IAAI;EACZ;EAEA,MAAMK,KAAK,GACV,OAAOH,WAAW,KAAK,QAAQ,GAC5BlB,cAAc,CAAEkB,WAAY,CAAC,GAC7BrB,EAAE,CAAE,gBAAiB,CAAC;EAE1B,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,GAAGN,QAAQ;MAEjCW,kBAAkB,CAAEE,SAAS,EAAEP,YAAa,CAAC;MAC7CM,WAAW,CAAC,CAAC;IACd;EACD,CAAC;AACF,CAAE,CACH,CAAC,CAAE5B,oBAAqB,CAAC"}
1
+ {"version":3,"names":["Pressable","View","__","RichText","compose","decodeEntities","withSelect","withDispatch","getDefaultBlockName","BlockInsertionPoint","styles","store","blockEditorStore","hitSlop","top","bottom","left","right","noop","DefaultBlockAppender","baseGlobalStyles","isLocked","isVisible","onAppend","placeholder","containerStyle","showSeparator","blockGlobalStyles","blocks","fontSize","lineHeight","typography","textStyles","undefined","value","appenderStyles","blockHolder","createElement","onPress","style","pointerEvents","onChange","tagName","select","ownProps","getBlockCount","getBlockName","getSettings","isBlockValid","getTemplateLock","isEmpty","rootClientId","isLastBlockDefault","lastBlockClientId","isLastBlockValid","globalStylesBaseStyles","__experimentalGlobalStylesBaseStyles","dispatch","insertDefaultBlock","startTyping"],"sources":["@wordpress/block-editor/src/components/default-block-appender/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Pressable, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { RichText } from '@wordpress/block-editor';\nimport { compose } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport BlockInsertionPoint from '../block-list/insertion-point';\nimport styles from './style.scss';\nimport { store as blockEditorStore } from '../../store';\n\nconst hitSlop = { top: 22, bottom: 22, left: 22, right: 22 };\nconst noop = () => {};\n\nexport function DefaultBlockAppender( {\n\tbaseGlobalStyles,\n\tisLocked,\n\tisVisible,\n\tonAppend,\n\tplaceholder,\n\tcontainerStyle,\n\tshowSeparator,\n} ) {\n\tif ( isLocked || ! isVisible ) {\n\t\treturn null;\n\t}\n\tconst blockGlobalStyles = baseGlobalStyles?.blocks?.[ 'core/paragraph' ];\n\tconst { fontSize, lineHeight } = blockGlobalStyles?.typography || {};\n\n\tconst textStyles = blockGlobalStyles?.typography\n\t\t? {\n\t\t\t\t...( fontSize && { fontSize } ),\n\t\t\t\t...( lineHeight && { lineHeight } ),\n\t\t }\n\t\t: undefined;\n\n\tconst value =\n\t\ttypeof placeholder === 'string'\n\t\t\t? decodeEntities( placeholder )\n\t\t\t: __( 'Start writing…' );\n\n\tconst appenderStyles = [\n\t\tstyles.blockHolder,\n\t\tshowSeparator && containerStyle,\n\t];\n\n\treturn (\n\t\t<Pressable onPress={ onAppend } hitSlop={ hitSlop }>\n\t\t\t<View style={ appenderStyles } pointerEvents=\"box-only\">\n\t\t\t\t{ showSeparator ? (\n\t\t\t\t\t<BlockInsertionPoint />\n\t\t\t\t) : (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tplaceholder={ value }\n\t\t\t\t\t\tonChange={ noop }\n\t\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\t\tstyle={ textStyles }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</View>\n\t\t</Pressable>\n\t);\n}\n\nexport default compose(\n\twithSelect( ( select, ownProps ) => {\n\t\tconst {\n\t\t\tgetBlockCount,\n\t\t\tgetBlockName,\n\t\t\tgetSettings,\n\t\t\tisBlockValid,\n\t\t\tgetTemplateLock,\n\t\t} = select( blockEditorStore );\n\n\t\tconst isEmpty = ! getBlockCount( ownProps.rootClientId );\n\t\tconst isLastBlockDefault =\n\t\t\tgetBlockName( ownProps.lastBlockClientId ) ===\n\t\t\tgetDefaultBlockName();\n\t\tconst isLastBlockValid = isBlockValid( ownProps.lastBlockClientId );\n\t\tconst globalStylesBaseStyles =\n\t\t\tgetSettings()?.__experimentalGlobalStylesBaseStyles;\n\n\t\treturn {\n\t\t\tbaseGlobalStyles: globalStylesBaseStyles,\n\t\t\tisVisible: isEmpty || ! isLastBlockDefault || ! isLastBlockValid,\n\t\t\tisLocked: !! getTemplateLock( ownProps.rootClientId ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, ownProps ) => {\n\t\tconst { insertDefaultBlock, startTyping } =\n\t\t\tdispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\tonAppend() {\n\t\t\t\tconst { rootClientId } = ownProps;\n\n\t\t\t\tinsertDefaultBlock( undefined, rootClientId );\n\t\t\t\tstartTyping();\n\t\t\t},\n\t\t};\n\t} )\n)( DefaultBlockAppender );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,IAAI,QAAQ,cAAc;;AAE9C;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,yBAAyB;AAClD,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAC1D,SAASC,mBAAmB,QAAQ,mBAAmB;;AAEvD;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,+BAA+B;AAC/D,OAAOC,MAAM,MAAM,cAAc;AACjC,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,MAAMC,OAAO,GAAG;EAAEC,GAAG,EAAE,EAAE;EAAEC,MAAM,EAAE,EAAE;EAAEC,IAAI,EAAE,EAAE;EAAEC,KAAK,EAAE;AAAG,CAAC;AAC5D,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,OAAO,SAASC,oBAAoBA,CAAE;EACrCC,gBAAgB;EAChBC,QAAQ;EACRC,SAAS;EACTC,QAAQ;EACRC,WAAW;EACXC,cAAc;EACdC;AACD,CAAC,EAAG;EACH,IAAKL,QAAQ,IAAI,CAAEC,SAAS,EAAG;IAC9B,OAAO,IAAI;EACZ;EACA,MAAMK,iBAAiB,GAAGP,gBAAgB,EAAEQ,MAAM,GAAI,gBAAgB,CAAE;EACxE,MAAM;IAAEC,QAAQ;IAAEC;EAAW,CAAC,GAAGH,iBAAiB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AAC;EACnE,MAAME,sBAAsB,GAC3BR,WAAW,CAAC,CAAC,EAAES,oCAAoC;EAEpD,OAAO;IACNpC,gBAAgB,EAAEmC,sBAAsB;IACxCjC,SAAS,EAAE4B,OAAO,IAAI,CAAEE,kBAAkB,IAAI,CAAEE,gBAAgB;IAChEjC,QAAQ,EAAE,CAAC,CAAE4B,eAAe,CAAEL,QAAQ,CAACO,YAAa;EACrD,CAAC;AACF,CAAE,CAAC,EACH5C,YAAY,CAAE,CAAEkD,QAAQ,EAAEb,QAAQ,KAAM;EACvC,MAAM;IAAEc,kBAAkB;IAAEC;EAAY,CAAC,GACxCF,QAAQ,CAAE7C,gBAAiB,CAAC;EAE7B,OAAO;IACNW,QAAQA,CAAA,EAAG;MACV,MAAM;QAAE4B;MAAa,CAAC,GAAGP,QAAQ;MAEjCc,kBAAkB,CAAEzB,SAAS,EAAEkB,YAAa,CAAC;MAC7CQ,WAAW,CAAC,CAAC;IACd;EACD,CAAC;AACF,CAAE,CACH,CAAC,CAAExC,oBAAqB,CAAC"}
@@ -26,4 +26,69 @@ export function getValuesFromColors(colors = []) {
26
26
  });
27
27
  return values;
28
28
  }
29
+
30
+ /**
31
+ * Stylesheet for disabling a global styles duotone filter.
32
+ *
33
+ * @param {string} selector Selector to disable the filter for.
34
+ *
35
+ * @return {string} Filter none style.
36
+ */
37
+ export function getDuotoneUnsetStylesheet(selector) {
38
+ return `${selector}{filter:none}`;
39
+ }
40
+
41
+ /**
42
+ * SVG and stylesheet needed for rendering the duotone filter.
43
+ *
44
+ * @param {string} selector Selector to apply the filter to.
45
+ * @param {string} id Unique id for this duotone filter.
46
+ *
47
+ * @return {string} Duotone filter style.
48
+ */
49
+ export function getDuotoneStylesheet(selector, id) {
50
+ return `${selector}{filter:url(#${id})}`;
51
+ }
52
+
53
+ /**
54
+ * The SVG part of the duotone filter.
55
+ *
56
+ * @param {string} id Unique id for this duotone filter.
57
+ * @param {string[]} colors Color strings from dark to light.
58
+ *
59
+ * @return {string} Duotone SVG.
60
+ */
61
+ export function getDuotoneFilter(id, colors) {
62
+ const values = getValuesFromColors(colors);
63
+ return `
64
+ <svg
65
+ xmlns:xlink="http://www.w3.org/1999/xlink"
66
+ viewBox="0 0 0 0"
67
+ width="0"
68
+ height="0"
69
+ focusable="false"
70
+ role="none"
71
+ aria-hidden="true"
72
+ style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
73
+ >
74
+ <defs>
75
+ <filter id="${id}">
76
+ <!--
77
+ Use sRGB instead of linearRGB so transparency looks correct.
78
+ Use perceptual brightness to convert to grayscale.
79
+ -->
80
+ <feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>
81
+ <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
82
+ <feComponentTransfer color-interpolation-filters="sRGB">
83
+ <feFuncR type="table" tableValues="${values.r.join(' ')}"></feFuncR>
84
+ <feFuncG type="table" tableValues="${values.g.join(' ')}"></feFuncG>
85
+ <feFuncB type="table" tableValues="${values.b.join(' ')}"></feFuncB>
86
+ <feFuncA type="table" tableValues="${values.a.join(' ')}"></feFuncA>
87
+ </feComponentTransfer>
88
+ <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
89
+ <feComposite in2="SourceGraphic" operator="in"></feComposite>
90
+ </filter>
91
+ </defs>
92
+ </svg>`;
93
+ }
29
94
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["colord","getValuesFromColors","colors","values","r","g","b","a","forEach","color","rgbColor","toRgb","push"],"sources":["@wordpress/block-editor/src/components/duotone/utils.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { colord } from 'colord';\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [], a: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\tconst rgbColor = colord( color ).toRgb();\n\t\tvalues.r.push( rgbColor.r / 255 );\n\t\tvalues.g.push( rgbColor.g / 255 );\n\t\tvalues.b.push( rgbColor.b / 255 );\n\t\tvalues.a.push( rgbColor.a );\n\t} );\n\n\treturn values;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,QAAQ;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAEC,MAAM,GAAG,EAAE,EAAG;EAClD,MAAMC,MAAM,GAAG;IAAEC,CAAC,EAAE,EAAE;IAAEC,CAAC,EAAE,EAAE;IAAEC,CAAC,EAAE,EAAE;IAAEC,CAAC,EAAE;EAAG,CAAC;EAE7CL,MAAM,CAACM,OAAO,CAAIC,KAAK,IAAM;IAC5B,MAAMC,QAAQ,GAAGV,MAAM,CAAES,KAAM,CAAC,CAACE,KAAK,CAAC,CAAC;IACxCR,MAAM,CAACC,CAAC,CAACQ,IAAI,CAAEF,QAAQ,CAACN,CAAC,GAAG,GAAI,CAAC;IACjCD,MAAM,CAACE,CAAC,CAACO,IAAI,CAAEF,QAAQ,CAACL,CAAC,GAAG,GAAI,CAAC;IACjCF,MAAM,CAACG,CAAC,CAACM,IAAI,CAAEF,QAAQ,CAACJ,CAAC,GAAG,GAAI,CAAC;IACjCH,MAAM,CAACI,CAAC,CAACK,IAAI,CAAEF,QAAQ,CAACH,CAAE,CAAC;EAC5B,CAAE,CAAC;EAEH,OAAOJ,MAAM;AACd"}
1
+ {"version":3,"names":["colord","getValuesFromColors","colors","values","r","g","b","a","forEach","color","rgbColor","toRgb","push","getDuotoneUnsetStylesheet","selector","getDuotoneStylesheet","id","getDuotoneFilter","join"],"sources":["@wordpress/block-editor/src/components/duotone/utils.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { colord } from 'colord';\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [], a: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\tconst rgbColor = colord( color ).toRgb();\n\t\tvalues.r.push( rgbColor.r / 255 );\n\t\tvalues.g.push( rgbColor.g / 255 );\n\t\tvalues.b.push( rgbColor.b / 255 );\n\t\tvalues.a.push( rgbColor.a );\n\t} );\n\n\treturn values;\n}\n\n/**\n * Stylesheet for disabling a global styles duotone filter.\n *\n * @param {string} selector Selector to disable the filter for.\n *\n * @return {string} Filter none style.\n */\nexport function getDuotoneUnsetStylesheet( selector ) {\n\treturn `${ selector }{filter:none}`;\n}\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {string} selector Selector to apply the filter to.\n * @param {string} id Unique id for this duotone filter.\n *\n * @return {string} Duotone filter style.\n */\nexport function getDuotoneStylesheet( selector, id ) {\n\treturn `${ selector }{filter:url(#${ id })}`;\n}\n\n/**\n * The SVG part of the duotone filter.\n *\n * @param {string} id Unique id for this duotone filter.\n * @param {string[]} colors Color strings from dark to light.\n *\n * @return {string} Duotone SVG.\n */\nexport function getDuotoneFilter( id, colors ) {\n\tconst values = getValuesFromColors( colors );\n\treturn `\n<svg\n\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n\tviewBox=\"0 0 0 0\"\n\twidth=\"0\"\n\theight=\"0\"\n\tfocusable=\"false\"\n\trole=\"none\"\n\taria-hidden=\"true\"\n\tstyle=\"visibility: hidden; position: absolute; left: -9999px; overflow: hidden;\"\n>\n\t<defs>\n\t\t<filter id=\"${ id }\">\n\t\t\t<!--\n\t\t\t\tUse sRGB instead of linearRGB so transparency looks correct.\n\t\t\t\tUse perceptual brightness to convert to grayscale.\n\t\t\t-->\n\t\t\t<feColorMatrix color-interpolation-filters=\"sRGB\" type=\"matrix\" values=\" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 \"></feColorMatrix>\n\t\t\t<!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->\n\t\t\t<feComponentTransfer color-interpolation-filters=\"sRGB\">\n\t\t\t\t<feFuncR type=\"table\" tableValues=\"${ values.r.join( ' ' ) }\"></feFuncR>\n\t\t\t\t<feFuncG type=\"table\" tableValues=\"${ values.g.join( ' ' ) }\"></feFuncG>\n\t\t\t\t<feFuncB type=\"table\" tableValues=\"${ values.b.join( ' ' ) }\"></feFuncB>\n\t\t\t\t<feFuncA type=\"table\" tableValues=\"${ values.a.join( ' ' ) }\"></feFuncA>\n\t\t\t</feComponentTransfer>\n\t\t\t<!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->\n\t\t\t<feComposite in2=\"SourceGraphic\" operator=\"in\"></feComposite>\n\t\t</filter>\n\t</defs>\n</svg>`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,QAAQ;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAEC,MAAM,GAAG,EAAE,EAAG;EAClD,MAAMC,MAAM,GAAG;IAAEC,CAAC,EAAE,EAAE;IAAEC,CAAC,EAAE,EAAE;IAAEC,CAAC,EAAE,EAAE;IAAEC,CAAC,EAAE;EAAG,CAAC;EAE7CL,MAAM,CAACM,OAAO,CAAIC,KAAK,IAAM;IAC5B,MAAMC,QAAQ,GAAGV,MAAM,CAAES,KAAM,CAAC,CAACE,KAAK,CAAC,CAAC;IACxCR,MAAM,CAACC,CAAC,CAACQ,IAAI,CAAEF,QAAQ,CAACN,CAAC,GAAG,GAAI,CAAC;IACjCD,MAAM,CAACE,CAAC,CAACO,IAAI,CAAEF,QAAQ,CAACL,CAAC,GAAG,GAAI,CAAC;IACjCF,MAAM,CAACG,CAAC,CAACM,IAAI,CAAEF,QAAQ,CAACJ,CAAC,GAAG,GAAI,CAAC;IACjCH,MAAM,CAACI,CAAC,CAACK,IAAI,CAAEF,QAAQ,CAACH,CAAE,CAAC;EAC5B,CAAE,CAAC;EAEH,OAAOJ,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASU,yBAAyBA,CAAEC,QAAQ,EAAG;EACrD,OAAQ,GAAGA,QAAU,eAAc;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAAED,QAAQ,EAAEE,EAAE,EAAG;EACpD,OAAQ,GAAGF,QAAU,gBAAgBE,EAAI,IAAG;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAED,EAAE,EAAEd,MAAM,EAAG;EAC9C,MAAMC,MAAM,GAAGF,mBAAmB,CAAEC,MAAO,CAAC;EAC5C,OAAQ;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAiBc,EAAI;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAA0Cb,MAAM,CAACC,CAAC,CAACc,IAAI,CAAE,GAAI,CAAG;AAChE,yCAA0Cf,MAAM,CAACE,CAAC,CAACa,IAAI,CAAE,GAAI,CAAG;AAChE,yCAA0Cf,MAAM,CAACG,CAAC,CAACY,IAAI,CAAE,GAAI,CAAG;AAChE,yCAA0Cf,MAAM,CAACI,CAAC,CAACW,IAAI,CAAE,GAAI,CAAG;AAChE;AACA;AACA;AACA;AACA;AACA,OAAO;AACP"}
@@ -11,14 +11,16 @@ import a11yPlugin from 'colord/plugins/a11y';
11
11
  */
12
12
  import { SVG } from '@wordpress/components';
13
13
  import { useCallback, useMemo } from '@wordpress/element';
14
+ import { useSelect } from '@wordpress/data';
14
15
 
15
16
  /**
16
17
  * Internal dependencies
17
18
  */
18
19
  import transformStyles from '../../utils/transform-styles';
19
- const EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';
20
+ import { store as blockEditorStore } from '../../store';
21
+ import { unlock } from '../../lock-unlock';
20
22
  extend([namesPlugin, a11yPlugin]);
21
- function useDarkThemeBodyClassName(styles) {
23
+ function useDarkThemeBodyClassName(styles, scope) {
22
24
  return useCallback(node => {
23
25
  if (!node) {
24
26
  return;
@@ -30,7 +32,7 @@ function useDarkThemeBodyClassName(styles) {
30
32
  defaultView,
31
33
  body
32
34
  } = ownerDocument;
33
- const canvas = ownerDocument.querySelector(EDITOR_STYLES_SELECTOR);
35
+ const canvas = scope ? ownerDocument.querySelector(scope) : body;
34
36
  let backgroundColor;
35
37
  if (!canvas) {
36
38
  // The real .editor-styles-wrapper element might not exist in the
@@ -51,16 +53,33 @@ function useDarkThemeBodyClassName(styles) {
51
53
  } else {
52
54
  body.classList.add('is-dark-theme');
53
55
  }
54
- }, [styles]);
56
+ }, [styles, scope]);
55
57
  }
56
58
  export default function EditorStyles({
57
- styles
59
+ styles,
60
+ scope
58
61
  }) {
59
- const stylesArray = useMemo(() => Object.values(styles !== null && styles !== void 0 ? styles : []), [styles]);
60
- const transformedStyles = useMemo(() => transformStyles(stylesArray.filter(style => style?.css), EDITOR_STYLES_SELECTOR), [stylesArray]);
61
- const transformedSvgs = useMemo(() => stylesArray.filter(style => style.__unstableType === 'svgs').map(style => style.assets).join(''), [stylesArray]);
62
+ const overrides = useSelect(select => unlock(select(blockEditorStore)).getStyleOverrides(), []);
63
+ const [transformedStyles, transformedSvgs] = useMemo(() => {
64
+ const _styles = Object.values(styles !== null && styles !== void 0 ? styles : []);
65
+ for (const [id, override] of overrides) {
66
+ const index = _styles.findIndex(({
67
+ id: _id
68
+ }) => id === _id);
69
+ const overrideWithId = {
70
+ ...override,
71
+ id
72
+ };
73
+ if (index === -1) {
74
+ _styles.push(overrideWithId);
75
+ } else {
76
+ _styles[index] = overrideWithId;
77
+ }
78
+ }
79
+ return [transformStyles(_styles.filter(style => style?.css), scope), _styles.filter(style => style.__unstableType === 'svgs').map(style => style.assets).join('')];
80
+ }, [styles, overrides, scope]);
62
81
  return createElement(Fragment, null, createElement("style", {
63
- ref: useDarkThemeBodyClassName(stylesArray)
82
+ ref: useDarkThemeBodyClassName(transformedStyles, scope)
64
83
  }), transformedStyles.map((css, index) => createElement("style", {
65
84
  key: index
66
85
  }, css)), createElement(SVG, {