@wordpress/block-editor 12.11.1 → 12.12.2-next.f8d8eceb.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 (453) hide show
  1. package/CHANGELOG.md +14 -10
  2. package/README.md +35 -3
  3. package/build/components/block-alignment-control/use-available-alignments.js +30 -28
  4. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  5. package/build/components/block-controls/hook.js +4 -1
  6. package/build/components/block-controls/hook.js.map +1 -1
  7. package/build/components/block-list/block-outline.native.js +1 -1
  8. package/build/components/block-list/block-outline.native.js.map +1 -1
  9. package/build/components/block-list/block.js +2 -0
  10. package/build/components/block-list/block.js.map +1 -1
  11. package/build/components/block-list/block.native.js +4 -4
  12. package/build/components/block-list/block.native.js.map +1 -1
  13. package/build/components/block-list/layout.js +2 -3
  14. package/build/components/block-list/layout.js.map +1 -1
  15. package/build/components/block-preview/index.js +4 -1
  16. package/build/components/block-preview/index.js.map +1 -1
  17. package/build/components/block-styles/index.js +1 -2
  18. package/build/components/block-styles/index.js.map +1 -1
  19. package/build/components/block-switcher/pattern-transformations-menu.js +2 -4
  20. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  21. package/build/components/block-tools/block-contextual-toolbar.js +1 -0
  22. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  23. package/build/components/border-radius-control/index.js +3 -2
  24. package/build/components/border-radius-control/index.js.map +1 -1
  25. package/build/components/color-palette/with-color-context.js +6 -6
  26. package/build/components/color-palette/with-color-context.js.map +1 -1
  27. package/build/components/colors/with-colors.js +2 -8
  28. package/build/components/colors/with-colors.js.map +1 -1
  29. package/build/components/colors-gradients/control.js +6 -7
  30. package/build/components/colors-gradients/control.js.map +1 -1
  31. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -13
  32. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  33. package/build/components/dimensions-tool/index.js +22 -22
  34. package/build/components/dimensions-tool/index.js.map +1 -1
  35. package/build/components/dimensions-tool/scale-tool.js +1 -1
  36. package/build/components/dimensions-tool/scale-tool.js.map +1 -1
  37. package/build/components/font-family/index.js +2 -3
  38. package/build/components/font-family/index.js.map +1 -1
  39. package/build/components/font-sizes/font-size-picker.js +3 -5
  40. package/build/components/font-sizes/font-size-picker.js.map +1 -1
  41. package/build/components/font-sizes/with-font-sizes.js +3 -4
  42. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  43. package/build/components/global-styles/filters-panel.js +7 -8
  44. package/build/components/global-styles/filters-panel.js.map +1 -1
  45. package/build/components/global-styles/image-settings-panel.js +2 -2
  46. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  47. package/build/components/global-styles/typography-panel.js +1 -1
  48. package/build/components/global-styles/typography-panel.js.map +1 -1
  49. package/build/components/gradients/use-gradient.js +2 -5
  50. package/build/components/gradients/use-gradient.js.map +1 -1
  51. package/build/components/height-control/index.js +93 -5
  52. package/build/components/height-control/index.js.map +1 -1
  53. package/build/components/iframe/index.js +9 -1
  54. package/build/components/iframe/index.js.map +1 -1
  55. package/build/components/image-editor/aspect-ratio-dropdown.js +0 -6
  56. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  57. package/build/components/index.js +9 -2
  58. package/build/components/index.js.map +1 -1
  59. package/build/components/index.native.js +17 -2
  60. package/build/components/index.native.js.map +1 -1
  61. package/build/components/inner-blocks/index.js +2 -2
  62. package/build/components/inner-blocks/index.js.map +1 -1
  63. package/build/components/letter-spacing-control/index.js +3 -3
  64. package/build/components/letter-spacing-control/index.js.map +1 -1
  65. package/build/components/link-control/link-preview.js +5 -2
  66. package/build/components/link-control/link-preview.js.map +1 -1
  67. package/build/components/link-control/search-item.js +11 -0
  68. package/build/components/link-control/search-item.js.map +1 -1
  69. package/build/components/link-control/search-results.js +2 -1
  70. package/build/components/link-control/search-results.js.map +1 -1
  71. package/build/components/link-control/use-internal-value.js +14 -8
  72. package/build/components/link-control/use-internal-value.js.map +1 -1
  73. package/build/components/link-control/use-search-handler.js +10 -5
  74. package/build/components/link-control/use-search-handler.js.map +1 -1
  75. package/build/components/list-view/index.js +6 -5
  76. package/build/components/list-view/index.js.map +1 -1
  77. package/build/components/media-replace-flow/index.js +2 -4
  78. package/build/components/media-replace-flow/index.js.map +1 -1
  79. package/build/components/provider/use-block-sync.js +2 -2
  80. package/build/components/provider/use-block-sync.js.map +1 -1
  81. package/build/components/rich-text/index.js +1 -1
  82. package/build/components/rich-text/index.js.map +1 -1
  83. package/build/components/rich-text/index.native.js +14 -3
  84. package/build/components/rich-text/index.native.js.map +1 -1
  85. package/build/components/rich-text/use-delete.js +1 -1
  86. package/build/components/rich-text/use-delete.js.map +1 -1
  87. package/build/components/rich-text/use-paste-handler.js +25 -22
  88. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  89. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -3
  90. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  91. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +91 -3
  92. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  93. package/build/components/tool-selector/index.js +1 -2
  94. package/build/components/tool-selector/index.js.map +1 -1
  95. package/build/components/unit-control/index.js +3 -3
  96. package/build/components/unit-control/index.js.map +1 -1
  97. package/build/components/use-block-commands/index.js +96 -47
  98. package/build/components/use-block-commands/index.js.map +1 -1
  99. package/build/components/use-settings/index.js +212 -0
  100. package/build/components/use-settings/index.js.map +1 -0
  101. package/build/components/writing-flow/use-arrow-nav.js +4 -0
  102. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  103. package/build/hooks/align.js +51 -35
  104. package/build/hooks/align.js.map +1 -1
  105. package/build/hooks/anchor.js +37 -32
  106. package/build/hooks/anchor.js.map +1 -1
  107. package/build/hooks/background.js +4 -4
  108. package/build/hooks/background.js.map +1 -1
  109. package/build/hooks/block-rename-ui.js +5 -5
  110. package/build/hooks/block-rename-ui.js.map +1 -1
  111. package/build/hooks/{metadata-name.js → block-renaming.js} +3 -7
  112. package/build/hooks/block-renaming.js.map +1 -0
  113. package/build/hooks/color.js +2 -4
  114. package/build/hooks/color.js.map +1 -1
  115. package/build/hooks/custom-class-name.js +28 -21
  116. package/build/hooks/custom-class-name.js.map +1 -1
  117. package/build/hooks/duotone.js +33 -8
  118. package/build/hooks/duotone.js.map +1 -1
  119. package/build/hooks/font-size.js +4 -4
  120. package/build/hooks/font-size.js.map +1 -1
  121. package/build/hooks/index.js +1 -1
  122. package/build/hooks/index.js.map +1 -1
  123. package/build/hooks/layout.js +16 -17
  124. package/build/hooks/layout.js.map +1 -1
  125. package/build/hooks/line-height.js +3 -3
  126. package/build/hooks/line-height.js.map +1 -1
  127. package/build/hooks/metadata.js +6 -27
  128. package/build/hooks/metadata.js.map +1 -1
  129. package/build/hooks/position.js +2 -3
  130. package/build/hooks/position.js.map +1 -1
  131. package/build/hooks/use-color-props.js +3 -11
  132. package/build/hooks/use-color-props.js.map +1 -1
  133. package/build/hooks/utils.js +2 -43
  134. package/build/hooks/utils.js.map +1 -1
  135. package/build/layouts/constrained.js +3 -3
  136. package/build/layouts/constrained.js.map +1 -1
  137. package/build/layouts/grid.js +25 -3
  138. package/build/layouts/grid.js.map +1 -1
  139. package/build/layouts/utils.js +1 -1
  140. package/build/layouts/utils.js.map +1 -1
  141. package/build/lock-unlock.js +1 -1
  142. package/build/lock-unlock.js.map +1 -1
  143. package/build/store/actions.js +13 -5
  144. package/build/store/actions.js.map +1 -1
  145. package/build/utils/object.js +4 -1
  146. package/build/utils/object.js.map +1 -1
  147. package/build/utils/parse-css-unit-to-px.js +20 -0
  148. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  149. package/build/utils/pasting.js +1 -1
  150. package/build/utils/pasting.js.map +1 -1
  151. package/build/utils/transform-styles/index.js +19 -24
  152. package/build/utils/transform-styles/index.js.map +1 -1
  153. package/build-module/components/block-alignment-control/use-available-alignments.js +30 -28
  154. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  155. package/build-module/components/block-controls/hook.js +4 -1
  156. package/build-module/components/block-controls/hook.js.map +1 -1
  157. package/build-module/components/block-list/block-outline.native.js +1 -1
  158. package/build-module/components/block-list/block-outline.native.js.map +1 -1
  159. package/build-module/components/block-list/block.js +2 -0
  160. package/build-module/components/block-list/block.js.map +1 -1
  161. package/build-module/components/block-list/block.native.js +4 -4
  162. package/build-module/components/block-list/block.native.js.map +1 -1
  163. package/build-module/components/block-list/layout.js +2 -2
  164. package/build-module/components/block-list/layout.js.map +1 -1
  165. package/build-module/components/block-preview/index.js +4 -1
  166. package/build-module/components/block-preview/index.js.map +1 -1
  167. package/build-module/components/block-styles/index.js +1 -2
  168. package/build-module/components/block-styles/index.js.map +1 -1
  169. package/build-module/components/block-switcher/pattern-transformations-menu.js +2 -4
  170. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  171. package/build-module/components/block-tools/block-contextual-toolbar.js +1 -0
  172. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  173. package/build-module/components/border-radius-control/index.js +3 -2
  174. package/build-module/components/border-radius-control/index.js.map +1 -1
  175. package/build-module/components/color-palette/with-color-context.js +6 -5
  176. package/build-module/components/color-palette/with-color-context.js.map +1 -1
  177. package/build-module/components/colors/with-colors.js +2 -7
  178. package/build-module/components/colors/with-colors.js.map +1 -1
  179. package/build-module/components/colors-gradients/control.js +6 -7
  180. package/build-module/components/colors-gradients/control.js.map +1 -1
  181. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -12
  182. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  183. package/build-module/components/dimensions-tool/index.js +22 -22
  184. package/build-module/components/dimensions-tool/index.js.map +1 -1
  185. package/build-module/components/dimensions-tool/scale-tool.js +1 -1
  186. package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
  187. package/build-module/components/font-family/index.js +2 -2
  188. package/build-module/components/font-family/index.js.map +1 -1
  189. package/build-module/components/font-sizes/font-size-picker.js +3 -4
  190. package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
  191. package/build-module/components/font-sizes/with-font-sizes.js +3 -3
  192. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  193. package/build-module/components/global-styles/filters-panel.js +7 -8
  194. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  195. package/build-module/components/global-styles/image-settings-panel.js +2 -2
  196. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  197. package/build-module/components/global-styles/typography-panel.js +1 -1
  198. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  199. package/build-module/components/gradients/use-gradient.js +2 -4
  200. package/build-module/components/gradients/use-gradient.js.map +1 -1
  201. package/build-module/components/height-control/index.js +93 -4
  202. package/build-module/components/height-control/index.js.map +1 -1
  203. package/build-module/components/iframe/index.js +9 -1
  204. package/build-module/components/iframe/index.js.map +1 -1
  205. package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -6
  206. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  207. package/build-module/components/index.js +1 -1
  208. package/build-module/components/index.js.map +1 -1
  209. package/build-module/components/index.native.js +2 -1
  210. package/build-module/components/index.native.js.map +1 -1
  211. package/build-module/components/inner-blocks/index.js +2 -2
  212. package/build-module/components/inner-blocks/index.js.map +1 -1
  213. package/build-module/components/letter-spacing-control/index.js +3 -2
  214. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  215. package/build-module/components/link-control/link-preview.js +6 -3
  216. package/build-module/components/link-control/link-preview.js.map +1 -1
  217. package/build-module/components/link-control/search-item.js +12 -1
  218. package/build-module/components/link-control/search-item.js.map +1 -1
  219. package/build-module/components/link-control/search-results.js +2 -1
  220. package/build-module/components/link-control/search-results.js.map +1 -1
  221. package/build-module/components/link-control/use-internal-value.js +14 -9
  222. package/build-module/components/link-control/use-internal-value.js.map +1 -1
  223. package/build-module/components/link-control/use-search-handler.js +10 -5
  224. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  225. package/build-module/components/list-view/index.js +7 -6
  226. package/build-module/components/list-view/index.js.map +1 -1
  227. package/build-module/components/media-replace-flow/index.js +3 -5
  228. package/build-module/components/media-replace-flow/index.js.map +1 -1
  229. package/build-module/components/provider/use-block-sync.js +2 -2
  230. package/build-module/components/provider/use-block-sync.js.map +1 -1
  231. package/build-module/components/rich-text/index.js +1 -1
  232. package/build-module/components/rich-text/index.js.map +1 -1
  233. package/build-module/components/rich-text/index.native.js +15 -4
  234. package/build-module/components/rich-text/index.native.js.map +1 -1
  235. package/build-module/components/rich-text/use-delete.js +1 -1
  236. package/build-module/components/rich-text/use-delete.js.map +1 -1
  237. package/build-module/components/rich-text/use-paste-handler.js +25 -22
  238. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  239. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -2
  240. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  241. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +91 -2
  242. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  243. package/build-module/components/tool-selector/index.js +1 -2
  244. package/build-module/components/tool-selector/index.js.map +1 -1
  245. package/build-module/components/unit-control/index.js +3 -2
  246. package/build-module/components/unit-control/index.js.map +1 -1
  247. package/build-module/components/use-block-commands/index.js +95 -47
  248. package/build-module/components/use-block-commands/index.js.map +1 -1
  249. package/build-module/components/use-settings/index.js +203 -0
  250. package/build-module/components/use-settings/index.js.map +1 -0
  251. package/build-module/components/writing-flow/use-arrow-nav.js +4 -0
  252. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  253. package/build-module/hooks/align.js +51 -35
  254. package/build-module/hooks/align.js.map +1 -1
  255. package/build-module/hooks/anchor.js +37 -32
  256. package/build-module/hooks/anchor.js.map +1 -1
  257. package/build-module/hooks/background.js +4 -4
  258. package/build-module/hooks/background.js.map +1 -1
  259. package/build-module/hooks/block-rename-ui.js +6 -6
  260. package/build-module/hooks/block-rename-ui.js.map +1 -1
  261. package/build-module/hooks/{metadata-name.js → block-renaming.js} +3 -6
  262. package/build-module/hooks/block-renaming.js.map +1 -0
  263. package/build-module/hooks/color.js +2 -4
  264. package/build-module/hooks/color.js.map +1 -1
  265. package/build-module/hooks/custom-class-name.js +28 -21
  266. package/build-module/hooks/custom-class-name.js.map +1 -1
  267. package/build-module/hooks/duotone.js +34 -9
  268. package/build-module/hooks/duotone.js.map +1 -1
  269. package/build-module/hooks/font-size.js +4 -4
  270. package/build-module/hooks/font-size.js.map +1 -1
  271. package/build-module/hooks/index.js +1 -1
  272. package/build-module/hooks/index.js.map +1 -1
  273. package/build-module/hooks/layout.js +16 -17
  274. package/build-module/hooks/layout.js.map +1 -1
  275. package/build-module/hooks/line-height.js +3 -3
  276. package/build-module/hooks/line-height.js.map +1 -1
  277. package/build-module/hooks/metadata.js +6 -25
  278. package/build-module/hooks/metadata.js.map +1 -1
  279. package/build-module/hooks/position.js +2 -3
  280. package/build-module/hooks/position.js.map +1 -1
  281. package/build-module/hooks/use-color-props.js +3 -11
  282. package/build-module/hooks/use-color-props.js.map +1 -1
  283. package/build-module/hooks/utils.js +3 -44
  284. package/build-module/hooks/utils.js.map +1 -1
  285. package/build-module/layouts/constrained.js +3 -2
  286. package/build-module/layouts/constrained.js.map +1 -1
  287. package/build-module/layouts/grid.js +25 -3
  288. package/build-module/layouts/grid.js.map +1 -1
  289. package/build-module/layouts/utils.js +1 -1
  290. package/build-module/layouts/utils.js.map +1 -1
  291. package/build-module/lock-unlock.js +1 -1
  292. package/build-module/lock-unlock.js.map +1 -1
  293. package/build-module/store/actions.js +14 -6
  294. package/build-module/store/actions.js.map +1 -1
  295. package/build-module/utils/object.js +3 -1
  296. package/build-module/utils/object.js.map +1 -1
  297. package/build-module/utils/parse-css-unit-to-px.js +20 -0
  298. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  299. package/build-module/utils/pasting.js +1 -1
  300. package/build-module/utils/pasting.js.map +1 -1
  301. package/build-module/utils/transform-styles/index.js +20 -24
  302. package/build-module/utils/transform-styles/index.js.map +1 -1
  303. package/build-style/style-rtl.css +24 -12
  304. package/build-style/style.css +24 -12
  305. package/package.json +36 -34
  306. package/src/components/block-alignment-control/use-available-alignments.js +49 -34
  307. package/src/components/block-controls/hook.js +6 -3
  308. package/src/components/block-list/block-outline.native.js +1 -1
  309. package/src/components/block-list/block.js +2 -0
  310. package/src/components/block-list/block.native.js +4 -4
  311. package/src/components/block-list/layout.js +2 -2
  312. package/src/components/block-preview/index.js +7 -1
  313. package/src/components/block-styles/index.js +1 -4
  314. package/src/components/block-styles/style.scss +1 -1
  315. package/src/components/block-switcher/pattern-transformations-menu.js +1 -4
  316. package/src/components/block-switcher/style.scss +6 -0
  317. package/src/components/block-tools/block-contextual-toolbar.js +1 -0
  318. package/src/components/block-tools/style.scss +0 -1
  319. package/src/components/border-radius-control/index.js +3 -2
  320. package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -1
  321. package/src/components/color-palette/with-color-context.js +9 -9
  322. package/src/components/colors/with-colors.js +6 -7
  323. package/src/components/colors-gradients/control.js +10 -7
  324. package/src/components/colors-gradients/style.scss +4 -2
  325. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +29 -15
  326. package/src/components/dimensions-tool/index.js +25 -25
  327. package/src/components/dimensions-tool/scale-tool.js +1 -1
  328. package/src/components/font-family/index.js +2 -2
  329. package/src/components/font-sizes/font-size-picker.js +6 -4
  330. package/src/components/font-sizes/with-font-sizes.js +3 -5
  331. package/src/components/global-styles/filters-panel.js +9 -15
  332. package/src/components/global-styles/image-settings-panel.js +2 -2
  333. package/src/components/global-styles/typography-panel.js +1 -1
  334. package/src/components/gradients/use-gradient.js +10 -4
  335. package/src/components/height-control/index.js +53 -4
  336. package/src/components/iframe/index.js +8 -1
  337. package/src/components/image-editor/aspect-ratio-dropdown.js +0 -8
  338. package/src/components/index.js +1 -1
  339. package/src/components/index.native.js +2 -1
  340. package/src/components/inner-blocks/index.js +2 -2
  341. package/src/components/inserter/style.scss +9 -1
  342. package/src/components/letter-spacing-control/index.js +3 -2
  343. package/src/components/link-control/README.md +43 -0
  344. package/src/components/link-control/link-preview.js +11 -5
  345. package/src/components/link-control/search-item.js +14 -0
  346. package/src/components/link-control/search-results.js +1 -0
  347. package/src/components/link-control/style.scss +3 -3
  348. package/src/components/link-control/test/index.js +19 -0
  349. package/src/components/link-control/use-internal-value.js +14 -10
  350. package/src/components/link-control/use-search-handler.js +22 -15
  351. package/src/components/list-view/index.js +13 -3
  352. package/src/components/media-replace-flow/index.js +9 -14
  353. package/src/components/provider/test/use-block-sync.js +1 -1
  354. package/src/components/provider/use-block-sync.js +2 -2
  355. package/src/components/rich-text/index.js +1 -1
  356. package/src/components/rich-text/index.native.js +19 -3
  357. package/src/components/rich-text/use-delete.js +1 -1
  358. package/src/components/rich-text/use-paste-handler.js +27 -24
  359. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +7 -5
  360. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +25 -2
  361. package/src/components/tool-selector/index.js +1 -1
  362. package/src/components/unit-control/index.js +3 -8
  363. package/src/components/use-block-commands/index.js +93 -47
  364. package/src/components/{use-setting → use-settings}/README.md +9 -10
  365. package/src/components/use-settings/index.js +272 -0
  366. package/src/components/{use-setting → use-settings}/test/index.js +47 -5
  367. package/src/components/writing-flow/use-arrow-nav.js +4 -0
  368. package/src/hooks/align.js +79 -54
  369. package/src/hooks/anchor.js +75 -65
  370. package/src/hooks/background.js +7 -9
  371. package/src/hooks/block-rename-ui.js +5 -14
  372. package/src/hooks/{metadata-name.js → block-renaming.js} +4 -7
  373. package/src/hooks/color.js +7 -4
  374. package/src/hooks/custom-class-name.js +36 -31
  375. package/src/hooks/duotone.js +51 -14
  376. package/src/hooks/font-size.js +4 -4
  377. package/src/hooks/index.js +1 -1
  378. package/src/hooks/layout.js +17 -17
  379. package/src/hooks/line-height.js +3 -3
  380. package/src/hooks/metadata.js +6 -38
  381. package/src/hooks/position.js +5 -3
  382. package/src/hooks/use-color-props.js +21 -14
  383. package/src/hooks/utils.js +90 -43
  384. package/src/layouts/constrained.js +3 -8
  385. package/src/layouts/grid.js +50 -2
  386. package/src/layouts/utils.js +2 -1
  387. package/src/lock-unlock.js +1 -1
  388. package/src/store/actions.js +25 -8
  389. package/src/utils/object.js +4 -1
  390. package/src/utils/parse-css-unit-to-px.js +20 -0
  391. package/src/utils/pasting.js +1 -4
  392. package/src/utils/test/__snapshots__/transform-styles.js.snap +103 -0
  393. package/src/utils/test/pasting.js +12 -19
  394. package/src/utils/test/transform-styles.js +217 -0
  395. package/src/utils/transform-styles/index.js +25 -25
  396. package/build/components/use-setting/index.js +0 -159
  397. package/build/components/use-setting/index.js.map +0 -1
  398. package/build/hooks/metadata-name.js.map +0 -1
  399. package/build/utils/transform-styles/ast/index.js +0 -21
  400. package/build/utils/transform-styles/ast/index.js.map +0 -1
  401. package/build/utils/transform-styles/ast/parse.js +0 -660
  402. package/build/utils/transform-styles/ast/parse.js.map +0 -1
  403. package/build/utils/transform-styles/ast/stringify/compiler.js +0 -52
  404. package/build/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
  405. package/build/utils/transform-styles/ast/stringify/compress.js +0 -178
  406. package/build/utils/transform-styles/ast/stringify/compress.js.map +0 -1
  407. package/build/utils/transform-styles/ast/stringify/identity.js +0 -207
  408. package/build/utils/transform-styles/ast/stringify/identity.js.map +0 -1
  409. package/build/utils/transform-styles/ast/stringify/index.js +0 -36
  410. package/build/utils/transform-styles/ast/stringify/index.js.map +0 -1
  411. package/build/utils/transform-styles/transforms/url-rewrite.js +0 -130
  412. package/build/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
  413. package/build/utils/transform-styles/transforms/wrap.js +0 -59
  414. package/build/utils/transform-styles/transforms/wrap.js.map +0 -1
  415. package/build/utils/transform-styles/traverse.js +0 -37
  416. package/build/utils/transform-styles/traverse.js.map +0 -1
  417. package/build-module/components/use-setting/index.js +0 -152
  418. package/build-module/components/use-setting/index.js.map +0 -1
  419. package/build-module/hooks/metadata-name.js.map +0 -1
  420. package/build-module/utils/transform-styles/ast/index.js +0 -6
  421. package/build-module/utils/transform-styles/ast/index.js.map +0 -1
  422. package/build-module/utils/transform-styles/ast/parse.js +0 -654
  423. package/build-module/utils/transform-styles/ast/parse.js.map +0 -1
  424. package/build-module/utils/transform-styles/ast/stringify/compiler.js +0 -49
  425. package/build-module/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
  426. package/build-module/utils/transform-styles/ast/stringify/compress.js +0 -176
  427. package/build-module/utils/transform-styles/ast/stringify/compress.js.map +0 -1
  428. package/build-module/utils/transform-styles/ast/stringify/identity.js +0 -206
  429. package/build-module/utils/transform-styles/ast/stringify/identity.js.map +0 -1
  430. package/build-module/utils/transform-styles/ast/stringify/index.js +0 -29
  431. package/build-module/utils/transform-styles/ast/stringify/index.js.map +0 -1
  432. package/build-module/utils/transform-styles/transforms/url-rewrite.js +0 -123
  433. package/build-module/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
  434. package/build-module/utils/transform-styles/transforms/wrap.js +0 -52
  435. package/build-module/utils/transform-styles/transforms/wrap.js.map +0 -1
  436. package/build-module/utils/transform-styles/traverse.js +0 -28
  437. package/build-module/utils/transform-styles/traverse.js.map +0 -1
  438. package/src/components/use-setting/index.js +0 -213
  439. package/src/utils/transform-styles/ast/index.js +0 -5
  440. package/src/utils/transform-styles/ast/parse.js +0 -732
  441. package/src/utils/transform-styles/ast/stringify/compiler.js +0 -50
  442. package/src/utils/transform-styles/ast/stringify/compress.js +0 -238
  443. package/src/utils/transform-styles/ast/stringify/identity.js +0 -286
  444. package/src/utils/transform-styles/ast/stringify/index.js +0 -32
  445. package/src/utils/transform-styles/test/__snapshots__/traverse.js.snap +0 -7
  446. package/src/utils/transform-styles/test/traverse.js +0 -24
  447. package/src/utils/transform-styles/transforms/test/__snapshots__/url-rewrite.js.snap +0 -25
  448. package/src/utils/transform-styles/transforms/test/__snapshots__/wrap.js.snap +0 -64
  449. package/src/utils/transform-styles/transforms/test/url-rewrite.js +0 -39
  450. package/src/utils/transform-styles/transforms/test/wrap.js +0 -95
  451. package/src/utils/transform-styles/transforms/url-rewrite.js +0 -139
  452. package/src/utils/transform-styles/transforms/wrap.js +0 -56
  453. package/src/utils/transform-styles/traverse.js +0 -32
@@ -51,6 +51,37 @@ export function addAttribute(settings) {
51
51
  }
52
52
  return settings;
53
53
  }
54
+ function BlockEditAnchorControl({
55
+ blockName,
56
+ attributes,
57
+ setAttributes
58
+ }) {
59
+ const blockEditingMode = useBlockEditingMode();
60
+ const isWeb = Platform.OS === 'web';
61
+ const textControl = createElement(TextControl, {
62
+ __nextHasNoMarginBottom: true,
63
+ className: "html-anchor-control",
64
+ label: __('HTML anchor'),
65
+ help: createElement(Fragment, null, __('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'), isWeb && createElement(ExternalLink, {
66
+ href: __('https://wordpress.org/documentation/article/page-jumps/')
67
+ }, __('Learn more about anchors'))),
68
+ value: attributes.anchor || '',
69
+ placeholder: !isWeb ? __('Add an anchor') : null,
70
+ onChange: nextValue => {
71
+ nextValue = nextValue.replace(ANCHOR_REGEX, '-');
72
+ setAttributes({
73
+ anchor: nextValue
74
+ });
75
+ },
76
+ autoCapitalize: "none",
77
+ autoComplete: "off"
78
+ });
79
+ return createElement(Fragment, null, isWeb && blockEditingMode === 'default' && createElement(InspectorControls, {
80
+ group: "advanced"
81
+ }, textControl), !isWeb && blockName === 'core/heading' && createElement(InspectorControls, null, createElement(PanelBody, {
82
+ title: __('Heading settings')
83
+ }, textControl)));
84
+ }
54
85
 
55
86
  /**
56
87
  * Override the default edit UI to include a new block inspector control for
@@ -62,39 +93,13 @@ export function addAttribute(settings) {
62
93
  */
63
94
  export const withInspectorControl = createHigherOrderComponent(BlockEdit => {
64
95
  return props => {
65
- const hasAnchor = hasBlockSupport(props.name, 'anchor');
66
- const blockEditingMode = useBlockEditingMode();
67
- if (hasAnchor && props.isSelected) {
68
- const isWeb = Platform.OS === 'web';
69
- const textControl = createElement(TextControl, {
70
- __nextHasNoMarginBottom: true,
71
- className: "html-anchor-control",
72
- label: __('HTML anchor'),
73
- help: createElement(Fragment, null, __('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'), isWeb && createElement(ExternalLink, {
74
- href: __('https://wordpress.org/documentation/article/page-jumps/')
75
- }, __('Learn more about anchors'))),
76
- value: props.attributes.anchor || '',
77
- placeholder: !isWeb ? __('Add an anchor') : null,
78
- onChange: nextValue => {
79
- nextValue = nextValue.replace(ANCHOR_REGEX, '-');
80
- props.setAttributes({
81
- anchor: nextValue
82
- });
83
- },
84
- autoCapitalize: "none",
85
- autoComplete: "off"
86
- });
87
- return createElement(Fragment, null, createElement(BlockEdit, {
88
- ...props
89
- }), isWeb && blockEditingMode === 'default' && createElement(InspectorControls, {
90
- group: "advanced"
91
- }, textControl), !isWeb && props.name === 'core/heading' && createElement(InspectorControls, null, createElement(PanelBody, {
92
- title: __('Heading settings')
93
- }, textControl)));
94
- }
95
- return createElement(BlockEdit, {
96
+ return createElement(Fragment, null, createElement(BlockEdit, {
96
97
  ...props
97
- });
98
+ }), props.isSelected && hasBlockSupport(props.name, 'anchor') && createElement(BlockEditAnchorControl, {
99
+ blockName: props.name,
100
+ attributes: props.attributes,
101
+ setAttributes: props.setAttributes
102
+ }));
98
103
  };
99
104
  }, 'withInspectorControl');
100
105
 
@@ -1 +1 @@
1
- {"version":3,"names":["addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","useBlockEditingMode","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","_settings$attributes$","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","blockEditingMode","isSelected","isWeb","OS","textControl","createElement","__nextHasNoMarginBottom","className","label","help","Fragment","href","value","placeholder","onChange","nextValue","replace","setAttributes","autoCapitalize","autoComplete","group","title","addSaveProps","extraProps","blockType","id"],"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\t\t\tconst blockEditingMode = useBlockEditingMode();\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && blockEditingMode === 'default' && (\n\t\t\t\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QA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OC,aAAA,CAACT,SAAS;MAAA,GAAMC;IAAK,CAAI,CAAC;EAClC,CAAC;AACF,CAAC,EACD,sBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASyB,YAAYA,CAAEC,UAAU,EAAEC,SAAS,EAAE/B,UAAU,EAAG;EACjE,IAAKd,eAAe,CAAE6C,SAAS,EAAE,QAAS,CAAC,EAAG;IAC7CD,UAAU,CAACE,EAAE,GAAGhC,UAAU,CAACC,MAAM,KAAK,EAAE,GAAG,IAAI,GAAGD,UAAU,CAACC,MAAM;EACpE;EAEA,OAAO6B,UAAU;AAClB;AAEAjD,SAAS,CAAE,0BAA0B,EAAE,uBAAuB,EAAEgB,YAAa,CAAC;AAC9EhB,SAAS,CACR,kBAAkB,EAClB,2CAA2C,EAC3CqB,oBACD,CAAC;AACDrB,SAAS,CACR,kCAAkC,EAClC,wBAAwB,EACxBgD,YACD,CAAC"}
1
+ {"version":3,"names":["addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","useBlockEditingMode","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","_settings$attributes$","attributes","anchor","BlockEditAnchorControl","blockName","setAttributes","blockEditingMode","isWeb","OS","textControl","createElement","__nextHasNoMarginBottom","className","label","help","Fragment","href","value","placeholder","onChange","nextValue","replace","autoCapitalize","autoComplete","group","title","withInspectorControl","BlockEdit","props","isSelected","name","addSaveProps","extraProps","blockType","id"],"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAnchorControl( { blockName, attributes, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst isWeb = Platform.OS === 'web';\n\tconst textControl = (\n\t\t<TextControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"html-anchor-control\"\n\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\thelp={\n\t\t\t\t<>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tvalue={ attributes.anchor || '' }\n\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tanchor: nextValue,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tautoCapitalize=\"none\"\n\t\t\tautoComplete=\"off\"\n\t\t/>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ isWeb && blockEditingMode === 'default' && (\n\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t{ textControl }\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ /*\n\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t */ }\n\t\t\t{ ! isWeb && blockName === 'core/heading' && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t{ props.isSelected &&\n\t\t\t\t\t\thasBlockSupport( props.name, 'anchor' ) && (\n\t\t\t\t\t\t\t<BlockEditAnchorControl\n\t\t\t\t\t\t\t\tblockName={ props.name }\n\t\t\t\t\t\t\t\tattributes={ props.attributes }\n\t\t\t\t\t\t\t\tsetAttributes={ props.setAttributes }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t);\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,EAAEC,WAAW,EAAEC,YAAY,QAAQ,uBAAuB;AAC5E,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,mBAAmB,QAAQ,kCAAkC;;AAEtE;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAG,QAAQ;AAE7B,MAAMC,aAAa,GAAG;EACrBC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,WAAW;EACnBC,SAAS,EAAE,IAAI;EACfC,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,C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D,SAAS,CAAE,0BAA0B,EAAE,uBAAuB,EAAEgB,YAAa,CAAC;AAC9EhB,SAAS,CACR,kBAAkB,EAClB,2CAA2C,EAC3C4C,oBACD,CAAC;AACD5C,SAAS,CACR,kCAAkC,EAClC,wBAAwB,EACxBiD,YACD,CAAC"}
@@ -21,7 +21,7 @@ import { getFilename } from '@wordpress/url';
21
21
  */
22
22
  import InspectorControls from '../components/inspector-controls';
23
23
  import MediaReplaceFlow from '../components/media-replace-flow';
24
- import useSetting from '../components/use-setting';
24
+ import { useSettings } from '../components/use-settings';
25
25
  import { cleanEmptyObject } from './utils';
26
26
  import { store as blockEditorStore } from '../store';
27
27
  export const BACKGROUND_SUPPORT_KEY = 'background';
@@ -236,13 +236,13 @@ function BackgroundImagePanelItem(props) {
236
236
  })));
237
237
  }
238
238
  export function BackgroundImagePanel(props) {
239
- const isBackgroundImageSupported = useSetting('background.backgroundImage') && hasBackgroundSupport(props.name, 'backgroundImage');
240
- if (!isBackgroundImageSupported) {
239
+ const [backgroundImage] = useSettings('background.backgroundImage');
240
+ if (!backgroundImage || !hasBackgroundSupport(props.name, 'backgroundImage')) {
241
241
  return null;
242
242
  }
243
243
  return createElement(InspectorControls, {
244
244
  group: "background"
245
- }, isBackgroundImageSupported && createElement(BackgroundImagePanelItem, {
245
+ }, createElement(BackgroundImagePanelItem, {
246
246
  ...props
247
247
  }));
248
248
  }
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","isBlobURL","getBlockSupport","__experimentalToolsPanelItem","ToolsPanelItem","DropZone","FlexItem","MenuItem","VisuallyHidden","__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalTruncate","Truncate","useDispatch","useSelect","Platform","useCallback","__","sprintf","store","noticesStore","getFilename","InspectorControls","MediaReplaceFlow","useSetting","cleanEmptyObject","blockEditorStore","BACKGROUND_SUPPORT_KEY","IMAGE_BACKGROUND_TYPE","hasBackgroundImageValue","props","hasValue","attributes","style","background","backgroundImage","id","url","hasBackgroundSupport","blockName","feature","OS","support","resetBackgroundImage","setAttributes","undefined","InspectorImagePreview","label","filename","imgUrl","imgLabel","createElement","as","justify","className","numberOfLines","BackgroundImagePanelItem","clientId","title","mediaUpload","select","getSettings","createErrorNotice","onUploadError","message","type","onSelectMedia","media","newStyle","newAttributes","media_type","source","onFilesDrop","filesList","allowedTypes","onFileChange","image","onError","resetAllFilter","previousValue","onDeselect","isShownByDefault","panelId","mediaId","mediaURL","accept","onSelect","name","variant","onClick","BackgroundImagePanel","isBackgroundImageSupported","group"],"sources":["@wordpress/block-editor/src/hooks/background.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tDropZone,\n\tFlexItem,\n\tMenuItem,\n\tVisuallyHidden,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Platform, useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { getFilename } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport MediaReplaceFlow from '../components/media-replace-flow';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\nexport const IMAGE_BACKGROUND_TYPE = 'image';\n\n/**\n * Checks if there is a current value in the background image block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a background image value set.\n */\nexport function hasBackgroundImageValue( props ) {\n\tconst hasValue =\n\t\t!! props.attributes.style?.background?.backgroundImage?.id ||\n\t\t!! props.attributes.style?.background?.backgroundImage?.url;\n\n\treturn hasValue;\n}\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! support?.backgroundImage;\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Resets the background image block support attributes. This can be used when disabling\n * the background image controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBackgroundImage( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tbackgroundImage: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\nfunction InspectorImagePreview( { label, filename, url: imgUrl } ) {\n\tconst imgLabel = label || getFilename( imgUrl );\n\treturn (\n\t\t<ItemGroup as=\"span\">\n\t\t\t<HStack justify=\"flex-start\" as=\"span\">\n\t\t\t\t<span\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-hooks__background__inspector-image-indicator-wrapper',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-image': imgUrl,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\taria-hidden\n\t\t\t\t>\n\t\t\t\t\t{ imgUrl && (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-image-indicator\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tbackgroundImage: `url(${ imgUrl })`,\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</span>\n\t\t\t\t<FlexItem as=\"span\">\n\t\t\t\t\t<Truncate\n\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-media-replace-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ imgLabel }\n\t\t\t\t\t</Truncate>\n\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t{ filename\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: file name */\n\t\t\t\t\t\t\t\t\t__( 'Selected image: %s' ),\n\t\t\t\t\t\t\t\t\tfilename\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __( 'No image selected' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t</FlexItem>\n\t\t\t</HStack>\n\t\t</ItemGroup>\n\t);\n}\n\nfunction BackgroundImagePanelItem( props ) {\n\tconst { attributes, clientId, setAttributes } = props;\n\n\tconst { id, title, url } =\n\t\tattributes.style?.background?.backgroundImage || {};\n\n\tconst { mediaUpload } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t};\n\t} );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst onSelectMedia = ( media ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...attributes.style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...attributes.style?.background,\n\t\t\t\t\tbackgroundImage: undefined,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst newAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t};\n\n\t\t\tsetAttributes( newAttributes );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For media selections originated from a file upload.\n\t\tif (\n\t\t\t( media.media_type &&\n\t\t\t\tmedia.media_type !== IMAGE_BACKGROUND_TYPE ) ||\n\t\t\t( ! media.media_type &&\n\t\t\t\tmedia.type &&\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE )\n\t\t) {\n\t\t\tonUploadError(\n\t\t\t\t__( 'Only images can be used as a background image.' )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...attributes.style,\n\t\t\tbackground: {\n\t\t\t\t...attributes.style?.background,\n\t\t\t\tbackgroundImage: {\n\t\t\t\t\turl: media.url,\n\t\t\t\t\tid: media.id,\n\t\t\t\t\tsource: 'file',\n\t\t\t\t\ttitle: media.title || undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t};\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\tconst onFilesDrop = ( filesList ) => {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: [ 'image' ],\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonSelectMedia( image );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tstyle: {\n\t\t\t\t...previousValue.style,\n\t\t\t\tbackground: undefined,\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasBackgroundImageValue( props ) }\n\t\t\tlabel={ __( 'Background image' ) }\n\t\t\tonDeselect={ () => resetBackgroundImage( props ) }\n\t\t\tisShownByDefault={ true }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<div className=\"block-editor-hooks__background__inspector-media-replace-container\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\tallowedTypes={ [ IMAGE_BACKGROUND_TYPE ] }\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\tname={\n\t\t\t\t\t\t<InspectorImagePreview\n\t\t\t\t\t\t\tlabel={ __( 'Background image' ) }\n\t\t\t\t\t\t\tfilename={ title }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t>\n\t\t\t\t\t<MenuItem onClick={ () => resetBackgroundImage( props ) }>\n\t\t\t\t\t\t{ __( 'Reset ' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t<DropZone\n\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\tlabel={ __( 'Drop to upload' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nexport function BackgroundImagePanel( props ) {\n\tconst isBackgroundImageSupported =\n\t\tuseSetting( 'background.backgroundImage' ) &&\n\t\thasBackgroundSupport( props.name, 'backgroundImage' );\n\n\tif ( ! isBackgroundImageSupported ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"background\">\n\t\t\t{ isBackgroundImageSupported && (\n\t\t\t\t<BackgroundImagePanelItem { ...props } />\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC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B,CAAER,KAAK,CAACyD,IAAI,EAAE,iBAAkB,CAAC;EAEtD,IAAK,CAAEI,0BAA0B,EAAG;IACnC,OAAO,IAAI;EACZ;EAEA,OACCxC,aAAA,CAAC7B,iBAAiB;IAACsE,KAAK,EAAC;EAAY,GAClCD,0BAA0B,IAC3BxC,aAAA,CAACK,wBAAwB;IAAA,GAAM1B;EAAK,CAAI,CAEvB,CAAC;AAEtB"}
1
+ {"version":3,"names":["classnames","isBlobURL","getBlockSupport","__experimentalToolsPanelItem","ToolsPanelItem","DropZone","FlexItem","MenuItem","VisuallyHidden","__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalTruncate","Truncate","useDispatch","useSelect","Platform","useCallback","__","sprintf","store","noticesStore","getFilename","InspectorControls","MediaReplaceFlow","useSettings","cleanEmptyObject","blockEditorStore","BACKGROUND_SUPPORT_KEY","IMAGE_BACKGROUND_TYPE","hasBackgroundImageValue","props","hasValue","attributes","style","background","backgroundImage","id","url","hasBackgroundSupport","blockName","feature","OS","support","resetBackgroundImage","setAttributes","undefined","InspectorImagePreview","label","filename","imgUrl","imgLabel","createElement","as","justify","className","numberOfLines","BackgroundImagePanelItem","clientId","title","mediaUpload","select","getSettings","createErrorNotice","onUploadError","message","type","onSelectMedia","media","newStyle","newAttributes","media_type","source","onFilesDrop","filesList","allowedTypes","onFileChange","image","onError","resetAllFilter","previousValue","onDeselect","isShownByDefault","panelId","mediaId","mediaURL","accept","onSelect","name","variant","onClick","BackgroundImagePanel","group"],"sources":["@wordpress/block-editor/src/hooks/background.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tDropZone,\n\tFlexItem,\n\tMenuItem,\n\tVisuallyHidden,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Platform, useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { getFilename } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport MediaReplaceFlow from '../components/media-replace-flow';\nimport { useSettings } from '../components/use-settings';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\nexport const IMAGE_BACKGROUND_TYPE = 'image';\n\n/**\n * Checks if there is a current value in the background image block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a background image value set.\n */\nexport function hasBackgroundImageValue( props ) {\n\tconst hasValue =\n\t\t!! props.attributes.style?.background?.backgroundImage?.id ||\n\t\t!! props.attributes.style?.background?.backgroundImage?.url;\n\n\treturn hasValue;\n}\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! support?.backgroundImage;\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Resets the background image block support attributes. This can be used when disabling\n * the background image controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBackgroundImage( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tbackgroundImage: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\nfunction InspectorImagePreview( { label, filename, url: imgUrl } ) {\n\tconst imgLabel = label || getFilename( imgUrl );\n\treturn (\n\t\t<ItemGroup as=\"span\">\n\t\t\t<HStack justify=\"flex-start\" as=\"span\">\n\t\t\t\t<span\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-hooks__background__inspector-image-indicator-wrapper',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-image': imgUrl,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\taria-hidden\n\t\t\t\t>\n\t\t\t\t\t{ imgUrl && (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-image-indicator\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tbackgroundImage: `url(${ imgUrl })`,\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</span>\n\t\t\t\t<FlexItem as=\"span\">\n\t\t\t\t\t<Truncate\n\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-media-replace-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ imgLabel }\n\t\t\t\t\t</Truncate>\n\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t{ filename\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: file name */\n\t\t\t\t\t\t\t\t\t__( 'Selected image: %s' ),\n\t\t\t\t\t\t\t\t\tfilename\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __( 'No image selected' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t</FlexItem>\n\t\t\t</HStack>\n\t\t</ItemGroup>\n\t);\n}\n\nfunction BackgroundImagePanelItem( props ) {\n\tconst { attributes, clientId, setAttributes } = props;\n\n\tconst { id, title, url } =\n\t\tattributes.style?.background?.backgroundImage || {};\n\n\tconst { mediaUpload } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t};\n\t} );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst onSelectMedia = ( media ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...attributes.style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...attributes.style?.background,\n\t\t\t\t\tbackgroundImage: undefined,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst newAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t};\n\n\t\t\tsetAttributes( newAttributes );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For media selections originated from a file upload.\n\t\tif (\n\t\t\t( media.media_type &&\n\t\t\t\tmedia.media_type !== IMAGE_BACKGROUND_TYPE ) ||\n\t\t\t( ! media.media_type &&\n\t\t\t\tmedia.type &&\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE )\n\t\t) {\n\t\t\tonUploadError(\n\t\t\t\t__( 'Only images can be used as a background image.' )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...attributes.style,\n\t\t\tbackground: {\n\t\t\t\t...attributes.style?.background,\n\t\t\t\tbackgroundImage: {\n\t\t\t\t\turl: media.url,\n\t\t\t\t\tid: media.id,\n\t\t\t\t\tsource: 'file',\n\t\t\t\t\ttitle: media.title || undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t};\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\tconst onFilesDrop = ( filesList ) => {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: [ 'image' ],\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonSelectMedia( image );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tstyle: {\n\t\t\t\t...previousValue.style,\n\t\t\t\tbackground: undefined,\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasBackgroundImageValue( props ) }\n\t\t\tlabel={ __( 'Background image' ) }\n\t\t\tonDeselect={ () => resetBackgroundImage( props ) }\n\t\t\tisShownByDefault={ true }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<div className=\"block-editor-hooks__background__inspector-media-replace-container\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\tallowedTypes={ [ IMAGE_BACKGROUND_TYPE ] }\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\tname={\n\t\t\t\t\t\t<InspectorImagePreview\n\t\t\t\t\t\t\tlabel={ __( 'Background image' ) }\n\t\t\t\t\t\t\tfilename={ title }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t>\n\t\t\t\t\t<MenuItem onClick={ () => resetBackgroundImage( props ) }>\n\t\t\t\t\t\t{ __( 'Reset ' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t<DropZone\n\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\tlabel={ __( 'Drop to upload' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nexport function BackgroundImagePanel( props ) {\n\tconst [ backgroundImage ] = useSettings( 'background.backgroundImage' );\n\tif (\n\t\t! backgroundImage ||\n\t\t! hasBackgroundSupport( props.name, 'backgroundImage' )\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"background\">\n\t\t\t<BackgroundImagePanelItem { ...props } />\n\t\t</InspectorControls>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC,4BAA4B,IAAIC,cAAc,EAC9CC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,uBAAuB,IAAIC,SAAS,EACpCC,oBAAoB,IAAIC,MAAM,EAC9BC,sBAAsB,IAAIC,QAAQ,QAC5B,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,EAAEC,WAAW,QAAQ,oBAAoB;AAC1D,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,WAAW,QAAQ,gBAAgB;;AAE5C;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,kCAAkC;AAChE,OAAOC,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SAASN,KAAK,IAAIO,gBAAgB,QAAQ,UAAU;AAEpD,OAAO,MAAMC,sBAAsB,GAAG,YAAY;AAClD,OAAO,MAAMC,q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C,aAAA,CAACL,qBAAqB;MACrBC,KAAK,EAAG9B,EAAE,CAAE,kBAAmB,CAAG;MAClC+B,QAAQ,EAAGU,KAAO;MAClBrB,GAAG,EAAGA;IAAK,CACX,CACD;IACDmD,OAAO,EAAC;EAAW,GAEnBrC,aAAA,CAAC9C,QAAQ;IAACoF,OAAO,EAAGA,CAAA,KAAM9C,oBAAoB,CAAEb,KAAM;EAAG,GACtDb,EAAE,CAAE,QAAS,CACN,CACO,CAAC,EACnBkC,aAAA,CAAChD,QAAQ;IACRqE,WAAW,EAAGA,WAAa;IAC3BzB,KAAK,EAAG9B,EAAE,CAAE,gBAAiB;EAAG,CAChC,CACG,CACU,CAAC;AAEnB;AAEA,OAAO,SAASyE,oBAAoBA,CAAE5D,KAAK,EAAG;EAC7C,MAAM,CAAEK,eAAe,CAAE,GAAGX,WAAW,CAAE,4BAA6B,CAAC;EACvE,IACC,CAAEW,eAAe,IACjB,CAAEG,oBAAoB,CAAER,KAAK,CAACyD,IAAI,EAAE,iBAAkB,CAAC,EACtD;IACD,OAAO,IAAI;EACZ;EAEA,OACCpC,aAAA,CAAC7B,iBAAiB;IAACqE,KAAK,EAAC;EAAY,GACpCxC,aAAA,CAACK,wBAAwB;IAAA,GAAM1B;EAAK,CAAI,CACtB,CAAC;AAEtB"}
@@ -5,7 +5,7 @@ import { createElement, Fragment } from "react";
5
5
  import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
6
6
  import { addFilter } from '@wordpress/hooks';
7
7
  import { __, sprintf } from '@wordpress/i18n';
8
- import { getBlockSupport } from '@wordpress/blocks';
8
+ import { hasBlockSupport } from '@wordpress/blocks';
9
9
  import { MenuItem, __experimentalHStack as HStack, __experimentalVStack as VStack, Button, TextControl, Modal } from '@wordpress/components';
10
10
  import { useState } from '@wordpress/element';
11
11
  import { speak } from '@wordpress/a11y';
@@ -133,17 +133,17 @@ export const withBlockRenameControl = createHigherOrderComponent(BlockEdit => pr
133
133
  clientId,
134
134
  name,
135
135
  attributes,
136
- setAttributes
136
+ setAttributes,
137
+ isSelected
137
138
  } = props;
138
- const metaDataSupport = getBlockSupport(name, '__experimentalMetadata', false);
139
- const supportsBlockNaming = !!(true === metaDataSupport || metaDataSupport?.name);
140
- return createElement(Fragment, null, supportsBlockNaming && createElement(Fragment, null, createElement(BlockRenameControl, {
139
+ const supportsBlockNaming = hasBlockSupport(name, 'renaming', true);
140
+ return createElement(Fragment, null, isSelected && supportsBlockNaming && createElement(Fragment, null, createElement(BlockRenameControl, {
141
141
  clientId: clientId,
142
142
  customName: attributes?.metadata?.name,
143
143
  onChange: newName => {
144
144
  setAttributes({
145
145
  metadata: {
146
- ...(attributes?.metadata && attributes?.metadata),
146
+ ...attributes?.metadata,
147
147
  name: newName
148
148
  }
149
149
  });
@@ -1 +1 @@
1
- {"version":3,"names":["createHigherOrderComponent","useInstanceId","addFilter","__","sprintf","getBlockSupport","MenuItem","__experimentalHStack","HStack","__experimentalVStack","VStack","Button","TextControl","Modal","useState","speak","BlockSettingsMenuControls","useBlockDisplayInformation","InspectorControls","emptyString","testString","trim","length","RenameModal","blockName","originalBlockName","onClose","onSave","editedBlockName","setEditedBlockName","nameHasChanged","nameIsOriginal","nameIsEmpty","isNameValid","autoSelectInputText","event","target","select","dialogDescription","handleSubmit","message","createElement","title","onRequestClose","overlayClassName","aria","describedby","focusOnMount","id","onSubmit","e","preventDefault","spacing","__nextHasNoMarginBottom","value","label","hideLabelFromVision","placeholder","onChange","onFocus","justify","variant","onClick","type","BlockRenameControl","props","renamingBlock","setRenamingBlock","clientId","customName","blockInformation","Fragment","group","selectedClientIds","canRename","newName","undefined","withBlockRenameControl","BlockEdit","name","attributes","setAttributes","metaDataSupport","supportsBlockNaming","metadata","key"],"sources":["@wordpress/block-editor/src/hooks/block-rename-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\tMenuItem,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n\tModal,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\tuseBlockDisplayInformation,\n\tInspectorControls,\n} from '../components';\n\nconst emptyString = ( testString ) => testString?.trim()?.length === 0;\n\nfunction RenameModal( { blockName, originalBlockName, onClose, onSave } ) {\n\tconst [ editedBlockName, setEditedBlockName ] = useState( blockName );\n\n\tconst nameHasChanged = editedBlockName !== blockName;\n\tconst nameIsOriginal = editedBlockName === originalBlockName;\n\tconst nameIsEmpty = emptyString( editedBlockName );\n\n\tconst isNameValid = nameHasChanged || nameIsOriginal;\n\n\tconst autoSelectInputText = ( event ) => event.target.select();\n\n\tconst dialogDescription = useInstanceId(\n\t\tRenameModal,\n\t\t`block-editor-rename-modal__description`\n\t);\n\n\tconst handleSubmit = () => {\n\t\tconst message =\n\t\t\tnameIsOriginal || nameIsEmpty\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name reset to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name changed to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t );\n\n\t\t// Must be assertive to immediately announce change.\n\t\tspeak( message, 'assertive' );\n\t\tonSave( editedBlockName );\n\n\t\t// Immediate close avoids ability to hit save multiple times.\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-rename-modal\"\n\t\t\taria={ {\n\t\t\t\tdescribedby: dialogDescription,\n\t\t\t} }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t>\n\t\t\t<p id={ dialogDescription }>\n\t\t\t\t{ __( 'Enter a custom name for this block.' ) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif ( ! isNameValid ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thandleSubmit();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ editedBlockName }\n\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tplaceholder={ originalBlockName }\n\t\t\t\t\t\tonChange={ setEditedBlockName }\n\t\t\t\t\t\tonFocus={ autoSelectInputText }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-disabled={ ! isNameValid }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n\nfunction BlockRenameControl( props ) {\n\tconst [ renamingBlock, setRenamingBlock ] = useState( false );\n\n\tconst { clientId, customName, onChange } = props;\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\tvalue={ customName || '' }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { selectedClientIds } ) => {\n\t\t\t\t\t// Only enabled for single selections.\n\t\t\t\t\tconst canRename =\n\t\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\t\tclientId === selectedClientIds[ 0 ];\n\n\t\t\t\t\t// This check ensures the `BlockSettingsMenuControls` fill\n\t\t\t\t\t// doesn't render multiple times and also that it renders for\n\t\t\t\t\t// the block from which the menu was triggered.\n\t\t\t\t\tif ( ! canRename ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenamingBlock( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-expanded={ renamingBlock }\n\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</BlockSettingsMenuControls>\n\n\t\t\t{ renamingBlock && (\n\t\t\t\t<RenameModal\n\t\t\t\t\tblockName={ customName || '' }\n\t\t\t\t\toriginalBlockName={ blockInformation?.title }\n\t\t\t\t\tonClose={ () => setRenamingBlock( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\t// If the new value is the block's original name (e.g. `Group`)\n\t\t\t\t\t\t// or it is an empty string then assume the intent is to reset\n\t\t\t\t\t\t// the value. Therefore reset the metadata.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnewName === blockInformation?.title ||\n\t\t\t\t\t\t\temptyString( newName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewName = undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const withBlockRenameControl = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { clientId, name, attributes, setAttributes } = props;\n\n\t\tconst metaDataSupport = getBlockSupport(\n\t\t\tname,\n\t\t\t'__experimentalMetadata',\n\t\t\tfalse\n\t\t);\n\n\t\tconst supportsBlockNaming = !! (\n\t\t\ttrue === metaDataSupport || metaDataSupport?.name\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ supportsBlockNaming && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockRenameControl\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tcustomName={ attributes?.metadata?.name }\n\t\t\t\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t...( attributes?.metadata &&\n\t\t\t\t\t\t\t\t\t\t\tattributes?.metadata ),\n\t\t\t\t\t\t\t\t\t\tname: newName,\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/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-rename-ui/with-block-rename-control',\n\twithBlockRenameControl\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,eAAe,QAAQ,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C,EACrB;QACDA,OAAO,GAAGC,SAAS;MACpB;MAEAlB,QAAQ,CAAEiB,OAAQ,CAAC;IACpB;EAAG,CACH,CAED,CAAC;AAEL;AAEA,OAAO,MAAME,sBAAsB,GAAG7E,0BAA0B,CAC7D8E,SAAS,IAAQb,KAAK,IAAM;EAC7B,MAAM;IAAEG,QAAQ;IAAEW,IAAI;IAAEC,UAAU;IAAEC;EAAc,CAAC,GAAGhB,KAAK;EAE3D,MAAMiB,eAAe,GAAG7E,eAAe,CACtC0E,IAAI,EACJ,wBAAwB,EACxB,KACD,CAAC;EAED,MAAMI,mBAAmB,GAAG,CAAC,EAC5B,IAAI,KAAKD,eAAe,IAAIA,eAAe,EAAEH,IAAI,CACjD;EAED,OACCtC,aAAA,CAAA8B,QAAA,QACGY,mBAAmB,IACpB1C,aAAA,CAAA8B,QAAA,QACC9B,aAAA,CAACuB,kBAAkB;IAClBI,QAAQ,EAAGA,QAAU;IACrBC,UAAU,EAAGW,UAAU,EAAEI,QAAQ,EAAEL,IAAM;IACzCrB,QAAQ,EAAKiB,OAAO,IAAM;MACzBM,aAAa,CAAE;QACdG,QAAQ,EAAE;UACT,IAAKJ,UAAU,EAAEI,QAAQ,IACxBJ,UAAU,EAAEI,QAAQ,CAAE;UACvBL,IAAI,EAAEJ;QACP;MACD,CAAE,CAAC;IACJ;EAAG,CACH,CACA,CACF,EAEDlC,aAAA,CAACqC,SAAS;IAACO,GAAG,EAAC,MAAM;IAAA,GAAMpB;EAAK,CAAI,CACnC,CAAC;AAEL,CAAC,EACD,qBACD,CAAC;AAED/D,SAAS,CACR,kBAAkB,EAClB,gDAAgD,EAChD2E,sBACD,CAAC"}
1
+ {"version":3,"names":["createHigherOrderComponent","useInstanceId","addFilter","__","sprintf","hasBlockSupport","MenuItem","__experimentalHStack","HStack","__experimentalVStack","VStack","Button","TextControl","Modal","useState","speak","BlockSettingsMenuControls","useBlockDisplayInformation","InspectorControls","emptyString","testString","trim","length","RenameModal","blockName","originalBlockName","onClose","onSave","editedBlockName","setEditedBlockName","nameHasChanged","nameIsOriginal","nameIsEmpty","isNameValid","autoSelectInputText","event","target","select","dialogDescription","handleSubmit","message","createElement","title","onRequestClose","overlayClassName","aria","describedby","focusOnMount","id","onSubmit","e","preventDefault","spacing","__nextHasNoMarginBottom","value","label","hideLabelFromVision","placeholder","onChange","onFocus","justify","variant","onClick","type","BlockRenameControl","props","renamingBlock","setRenamingBlock","clientId","customName","blockInformation","Fragment","group","selectedClientIds","canRename","newName","undefined","withBlockRenameControl","BlockEdit","name","attributes","setAttributes","isSelected","supportsBlockNaming","metadata","key"],"sources":["@wordpress/block-editor/src/hooks/block-rename-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tMenuItem,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n\tModal,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\tuseBlockDisplayInformation,\n\tInspectorControls,\n} from '../components';\n\nconst emptyString = ( testString ) => testString?.trim()?.length === 0;\n\nfunction RenameModal( { blockName, originalBlockName, onClose, onSave } ) {\n\tconst [ editedBlockName, setEditedBlockName ] = useState( blockName );\n\n\tconst nameHasChanged = editedBlockName !== blockName;\n\tconst nameIsOriginal = editedBlockName === originalBlockName;\n\tconst nameIsEmpty = emptyString( editedBlockName );\n\n\tconst isNameValid = nameHasChanged || nameIsOriginal;\n\n\tconst autoSelectInputText = ( event ) => event.target.select();\n\n\tconst dialogDescription = useInstanceId(\n\t\tRenameModal,\n\t\t`block-editor-rename-modal__description`\n\t);\n\n\tconst handleSubmit = () => {\n\t\tconst message =\n\t\t\tnameIsOriginal || nameIsEmpty\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name reset to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name changed to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t );\n\n\t\t// Must be assertive to immediately announce change.\n\t\tspeak( message, 'assertive' );\n\t\tonSave( editedBlockName );\n\n\t\t// Immediate close avoids ability to hit save multiple times.\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-rename-modal\"\n\t\t\taria={ {\n\t\t\t\tdescribedby: dialogDescription,\n\t\t\t} }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t>\n\t\t\t<p id={ dialogDescription }>\n\t\t\t\t{ __( 'Enter a custom name for this block.' ) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif ( ! isNameValid ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thandleSubmit();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ editedBlockName }\n\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tplaceholder={ originalBlockName }\n\t\t\t\t\t\tonChange={ setEditedBlockName }\n\t\t\t\t\t\tonFocus={ autoSelectInputText }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-disabled={ ! isNameValid }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n\nfunction BlockRenameControl( props ) {\n\tconst [ renamingBlock, setRenamingBlock ] = useState( false );\n\n\tconst { clientId, customName, onChange } = props;\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\tvalue={ customName || '' }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { selectedClientIds } ) => {\n\t\t\t\t\t// Only enabled for single selections.\n\t\t\t\t\tconst canRename =\n\t\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\t\tclientId === selectedClientIds[ 0 ];\n\n\t\t\t\t\t// This check ensures the `BlockSettingsMenuControls` fill\n\t\t\t\t\t// doesn't render multiple times and also that it renders for\n\t\t\t\t\t// the block from which the menu was triggered.\n\t\t\t\t\tif ( ! canRename ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenamingBlock( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-expanded={ renamingBlock }\n\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</BlockSettingsMenuControls>\n\n\t\t\t{ renamingBlock && (\n\t\t\t\t<RenameModal\n\t\t\t\t\tblockName={ customName || '' }\n\t\t\t\t\toriginalBlockName={ blockInformation?.title }\n\t\t\t\t\tonClose={ () => setRenamingBlock( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\t// If the new value is the block's original name (e.g. `Group`)\n\t\t\t\t\t\t// or it is an empty string then assume the intent is to reset\n\t\t\t\t\t\t// the value. Therefore reset the metadata.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnewName === blockInformation?.title ||\n\t\t\t\t\t\t\temptyString( newName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewName = undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const withBlockRenameControl = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { clientId, name, attributes, setAttributes, isSelected } = props;\n\n\t\tconst supportsBlockNaming = hasBlockSupport( name, 'renaming', true );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ isSelected && supportsBlockNaming && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockRenameControl\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tcustomName={ attributes?.metadata?.name }\n\t\t\t\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\t\t\t\t\tname: newName,\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/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-rename-ui/with-block-rename-control',\n\twithBlockRenameControl\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC,QAAQ,EACRC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,MAAM,EACNC,WAAW,EACXC,KAAK,QACC,uBAAuB;AAC9B,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,SACCC,yBAAyB,EACzBC,0BAA0B,EAC1BC,iBAAiB,QACX,eAAe;AAEtB,MAAMC,WAAW,GAAKC,UAAU,IAAMA,UAAU,EAAEC,IAAI,CAAC,CAAC,EAAEC,MAAM,KAAK,CAAC;AAEtE,SAASC,WAAWA,CAAE;EAAEC,SAAS;EAAEC,iBAAiB;EAAEC,OAAO;EAAEC;AAAO,CAAC,EAAG;EACzE,MAAM,CAAEC,eAAe,EAAEC,kBAAkB,CAAE,GAAGf,QAAQ,CAAEU,SAAU,CAAC;EAErE,MAAMM,cAAc,GAAGF,eAAe,KAAKJ,SAAS;EACpD,MAAMO,cAAc,GAAGH,eAAe,KAAKH,iBAAiB;EAC5D,MAAMO,WAAW,GAAGb,WAAW,CAAES,eAAgB,CAAC;EAElD,MAAMK,WAAW,GAAGH,cAAc,IAAIC,cAAc;EAEpD,MAAMG,mBAAmB,GAAKC,KAAK,IAAMA,KAAK,CAACC,MAAM,CAACC,MAAM,CAAC,CAA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AAC;AAEL,CAAC,EACD,qBACD,CAAC;AAED/D,SAAS,CACR,kBAAkB,EAClB,gDAAgD,EAChD2E,sBACD,CAAC"}
@@ -2,10 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { addFilter } from '@wordpress/hooks';
5
- /**
6
- * Internal dependencies
7
- */
8
- import { hasBlockMetadataSupport } from './metadata';
5
+ import { hasBlockSupport } from '@wordpress/blocks';
9
6
 
10
7
  /**
11
8
  * Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.
@@ -19,7 +16,7 @@ export function addLabelCallback(settings) {
19
16
  if (settings.__experimentalLabel) {
20
17
  return settings;
21
18
  }
22
- const supportsBlockNaming = hasBlockMetadataSupport(settings, 'name', false // default value
19
+ const supportsBlockNaming = hasBlockSupport(settings, 'renaming', true // default value
23
20
  );
24
21
 
25
22
  // Check whether block metadata is supported before using it.
@@ -40,4 +37,4 @@ export function addLabelCallback(settings) {
40
37
  return settings;
41
38
  }
42
39
  addFilter('blocks.registerBlockType', 'core/metadata/addLabelCallback', addLabelCallback);
43
- //# sourceMappingURL=metadata-name.js.map
40
+ //# sourceMappingURL=block-renaming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["addFilter","hasBlockSupport","addLabelCallback","settings","__experimentalLabel","supportsBlockNaming","attributes","context","metadata","name"],"sources":["@wordpress/block-editor/src/hooks/block-renaming.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addLabelCallback( settings ) {\n\t// If blocks provide their own label callback, do not override it.\n\tif ( settings.__experimentalLabel ) {\n\t\treturn settings;\n\t}\n\n\tconst supportsBlockNaming = hasBlockSupport(\n\t\tsettings,\n\t\t'renaming',\n\t\ttrue // default value\n\t);\n\n\t// Check whether block metadata is supported before using it.\n\tif ( supportsBlockNaming ) {\n\t\tsettings.__experimentalLabel = ( attributes, { context } ) => {\n\t\t\tconst { metadata } = attributes;\n\n\t\t\t// In the list view, use the block's name attribute as the label.\n\t\t\tif ( context === 'list-view' && metadata?.name ) {\n\t\t\t\treturn metadata.name;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn settings;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/metadata/addLabelCallback',\n\taddLabelCallback\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,eAAe,QAAQ,mBAAmB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAEC,QAAQ,EAAG;EAC5C;EACA,IAAKA,QAAQ,CAACC,mBAAmB,EAAG;IACnC,OAAOD,QAAQ;EAChB;EAEA,MAAME,mBAAmB,GAAGJ,eAAe,CAC1CE,QAAQ,EACR,UAAU,EACV,IAAI,CAAC;EACN,CAAC;;EAED;EACA,IAAKE,mBAAmB,EAAG;IAC1BF,QAAQ,CAACC,mBAAmB,GAAG,CAAEE,UAAU,EAAE;MAAEC;IAAQ,CAAC,KAAM;MAC7D,MAAM;QAAEC;MAAS,CAAC,GAAGF,UAAU;;MAE/B;MACA,IAAKC,OAAO,KAAK,WAAW,IAAIC,QAAQ,EAAEC,IAAI,EAAG;QAChD,OAAOD,QAAQ,CAACC,IAAI;MACrB;IACD,CAAC;EACF;EAEA,OAAON,QAAQ;AAChB;AAEAH,SAAS,CACR,0BAA0B,EAC1B,gCAAgC,EAChCE,gBACD,CAAC"}
@@ -18,7 +18,7 @@ import { createHigherOrderComponent } from '@wordpress/compose';
18
18
  import { getColorClassName, getColorObjectByAttributeValues } from '../components/colors';
19
19
  import { __experimentalGetGradientClass } from '../components/gradients';
20
20
  import { cleanEmptyObject, transformStyles, shouldSkipSerialization, useBlockSettings } from './utils';
21
- import useSetting from '../components/use-setting';
21
+ import { useSettings } from '../components/use-settings';
22
22
  import InspectorControls from '../components/inspector-controls';
23
23
  import { useHasColorPanel, default as StylesColorPanel } from '../components/global-styles/color-panel';
24
24
  import BlockColorContrastChecker from './contrast-checker';
@@ -260,9 +260,7 @@ export const withColorPaletteStyles = createHigherOrderComponent(BlockListBlock
260
260
  backgroundColor,
261
261
  textColor
262
262
  } = attributes;
263
- const userPalette = useSetting('color.palette.custom');
264
- const themePalette = useSetting('color.palette.theme');
265
- const defaultPalette = useSetting('color.palette.default');
263
+ const [userPalette, themePalette, defaultPalette] = useSettings('color.palette.custom', 'color.palette.theme', 'color.palette.default');
266
264
  const colors = useMemo(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
267
265
  if (!hasColorSupport(name) || shouldSkipSerialization(name, COLOR_SUPPORT_KEY)) {
268
266
  return createElement(BlockListBlock, {
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","addFilter","getBlockSupport","useMemo","Platform","useCallback","createHigherOrderComponent","getColorClassName","getColorObjectByAttributeValues","__experimentalGetGradientClass","cleanEmptyObject","transformStyles","shouldSkipSerialization","useBlockSettings","useSetting","InspectorControls","useHasColorPanel","default","StylesColorPanel","BlockColorContrastChecker","COLOR_SUPPORT_KEY","hasColorSupport","blockType","colorSupport","link","gradient","background","text","hasLinkColorSupport","OS","hasGradientSupport","gradients","hasBackgroundColorSupport","hasTextColorSupport","addAttributes","settings","attributes","backgroundColor","Object","assign","type","textColor","addSaveProps","props","hasGradient","style","shouldSerialize","feature","textClass","undefined","gradientClass","backgroundClass","serializeHasBackground","hasBackground","color","newClassName","className","elements","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","styleToAttributes","textColorValue","textColorSlug","startsWith","substring","length","backgroundColorValue","backgroundColorSlug","gradientValue","gradientSlug","updatedStyle","attributesToStyle","ColorInspectorControl","children","resetAllFilter","attributesResetAllFilter","existingStyle","createElement","group","ColorEdit","clientId","name","setAttributes","isEnabled","value","onChange","newStyle","defaultControls","enableContrastChecking","as","panelId","enableContrastChecker","withColorPaletteStyles","BlockListBlock","userPalette","themePalette","defaultPalette","colors","extraStyles","wrapperProps","MIGRATION_PATHS","linkColor","addTransforms","result","source","index","results","destinationBlockType","activeSupports"],"sources":["@wordpress/block-editor/src/hooks/color.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useMemo, Platform, useCallback } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport { __experimentalGetGradientClass } from '../components/gradients';\nimport {\n\tcleanEmptyObject,\n\ttransformStyles,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport useSetting from '../components/use-setting';\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tuseHasColorPanel,\n\tdefault as StylesColorPanel,\n} from '../components/global-styles/color-panel';\nimport BlockColorContrastChecker from './contrast-checker';\n\nexport const COLOR_SUPPORT_KEY = 'color';\n\nconst hasColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\treturn (\n\t\tcolorSupport &&\n\t\t( colorSupport.link === true ||\n\t\t\tcolorSupport.gradient === true ||\n\t\t\tcolorSupport.background !== false ||\n\t\t\tcolorSupport.text !== false )\n\t);\n};\n\nconst hasLinkColorSupport = ( blockType ) => {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn (\n\t\tcolorSupport !== null &&\n\t\ttypeof colorSupport === 'object' &&\n\t\t!! colorSupport.link\n\t);\n};\n\nconst hasGradientSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn (\n\t\tcolorSupport !== null &&\n\t\ttypeof colorSupport === 'object' &&\n\t\t!! colorSupport.gradients\n\t);\n};\n\nconst hasBackgroundColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.background !== false;\n};\n\nconst hasTextColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.text !== false;\n};\n\n/**\n * Filters registered block settings, extending attributes to include\n * `backgroundColor` and `textColor` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasColorSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.backgroundColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tbackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\tif ( ! settings.attributes.textColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\ttextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( hasGradientSupport( settings ) && ! settings.attributes.gradient ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tgradient: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject colors classnames.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasColorSupport( blockType ) ||\n\t\tshouldSkipSerialization( blockType, COLOR_SUPPORT_KEY )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst hasGradient = hasGradientSupport( blockType );\n\n\t// I'd have preferred to avoid the \"style\" attribute usage here\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\tconst shouldSerialize = ( feature ) =>\n\t\t! shouldSkipSerialization( blockType, COLOR_SUPPORT_KEY, feature );\n\n\t// Primary color classes must come before the `has-text-color`,\n\t// `has-background` and `has-link-color` classes to maintain backwards\n\t// compatibility and avoid block invalidations.\n\tconst textClass = shouldSerialize( 'text' )\n\t\t? getColorClassName( 'color', textColor )\n\t\t: undefined;\n\n\tconst gradientClass = shouldSerialize( 'gradients' )\n\t\t? __experimentalGetGradientClass( gradient )\n\t\t: undefined;\n\n\tconst backgroundClass = shouldSerialize( 'background' )\n\t\t? getColorClassName( 'background-color', backgroundColor )\n\t\t: undefined;\n\n\tconst serializeHasBackground =\n\t\tshouldSerialize( 'background' ) || shouldSerialize( 'gradients' );\n\tconst hasBackground =\n\t\tbackgroundColor ||\n\t\tstyle?.color?.background ||\n\t\t( hasGradient && ( gradient || style?.color?.gradient ) );\n\n\tconst newClassName = classnames(\n\t\tprops.className,\n\t\ttextClass,\n\t\tgradientClass,\n\t\t{\n\t\t\t// Don't apply the background class if there's a custom gradient.\n\t\t\t[ backgroundClass ]:\n\t\t\t\t( ! hasGradient || ! style?.color?.gradient ) &&\n\t\t\t\t!! backgroundClass,\n\t\t\t'has-text-color':\n\t\t\t\tshouldSerialize( 'text' ) &&\n\t\t\t\t( textColor || style?.color?.text ),\n\t\t\t'has-background': serializeHasBackground && hasBackground,\n\t\t\t'has-link-color':\n\t\t\t\tshouldSerialize( 'link' ) && style?.elements?.link?.color,\n\t\t}\n\t);\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif (\n\t\t! hasColorSupport( settings ) ||\n\t\tshouldSkipSerialization( settings, COLOR_SUPPORT_KEY )\n\t) {\n\t\treturn settings;\n\t}\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\nfunction styleToAttributes( style ) {\n\tconst textColorValue = style?.color?.text;\n\tconst textColorSlug = textColorValue?.startsWith( 'var:preset|color|' )\n\t\t? textColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst backgroundColorValue = style?.color?.background;\n\tconst backgroundColorSlug = backgroundColorValue?.startsWith(\n\t\t'var:preset|color|'\n\t)\n\t\t? backgroundColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst gradientValue = style?.color?.gradient;\n\tconst gradientSlug = gradientValue?.startsWith( 'var:preset|gradient|' )\n\t\t? gradientValue.substring( 'var:preset|gradient|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.color = {\n\t\t...updatedStyle.color,\n\t\ttext: textColorSlug ? undefined : textColorValue,\n\t\tbackground: backgroundColorSlug ? undefined : backgroundColorValue,\n\t\tgradient: gradientSlug ? undefined : gradientValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\ttextColor: textColorSlug,\n\t\tbackgroundColor: backgroundColorSlug,\n\t\tgradient: gradientSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\treturn {\n\t\t...attributes.style,\n\t\tcolor: {\n\t\t\t...attributes.style?.color,\n\t\t\ttext: attributes.textColor\n\t\t\t\t? 'var:preset|color|' + attributes.textColor\n\t\t\t\t: attributes.style?.color?.text,\n\t\t\tbackground: attributes.backgroundColor\n\t\t\t\t? 'var:preset|color|' + attributes.backgroundColor\n\t\t\t\t: attributes.style?.color?.background,\n\t\t\tgradient: attributes.gradient\n\t\t\t\t? 'var:preset|gradient|' + attributes.gradient\n\t\t\t\t: attributes.style?.color?.gradient,\n\t\t},\n\t};\n}\n\nfunction ColorInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"color\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function ColorEdit( props ) {\n\tconst { clientId, name, attributes, setAttributes } = props;\n\tconst settings = useBlockSettings( name );\n\tconst isEnabled = useHasColorPanel( settings );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( {\n\t\t\tstyle: attributes.style,\n\t\t\ttextColor: attributes.textColor,\n\t\t\tbackgroundColor: attributes.backgroundColor,\n\t\t\tgradient: attributes.gradient,\n\t\t} );\n\t}, [\n\t\tattributes.style,\n\t\tattributes.textColor,\n\t\tattributes.backgroundColor,\n\t\tattributes.gradient,\n\t] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tCOLOR_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst enableContrastChecking =\n\t\tPlatform.OS === 'web' &&\n\t\t! value?.color?.gradient &&\n\t\t( settings?.color?.text || settings?.color?.link ) &&\n\t\t// Contrast checking is enabled by default.\n\t\t// Deactivating it requires `enableContrastChecker` to have\n\t\t// an explicit value of `false`.\n\t\tfalse !==\n\t\t\tgetBlockSupport( props.name, [\n\t\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t\t'enableContrastChecker',\n\t\t\t] );\n\n\treturn (\n\t\t<StylesColorPanel\n\t\t\tas={ ColorInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tenableContrastChecker={\n\t\t\t\tfalse !==\n\t\t\t\tgetBlockSupport( props.name, [\n\t\t\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t\t\t'enableContrastChecker',\n\t\t\t\t] )\n\t\t\t}\n\t\t>\n\t\t\t{ enableContrastChecking && (\n\t\t\t\t<BlockColorContrastChecker clientId={ clientId } />\n\t\t\t) }\n\t\t</StylesColorPanel>\n\t);\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { backgroundColor, textColor } = attributes;\n\t\tconst userPalette = useSetting( 'color.palette.custom' );\n\t\tconst themePalette = useSetting( 'color.palette.theme' );\n\t\tconst defaultPalette = useSetting( 'color.palette.default' );\n\t\tconst colors = useMemo(\n\t\t\t() => [\n\t\t\t\t...( userPalette || [] ),\n\t\t\t\t...( themePalette || [] ),\n\t\t\t\t...( defaultPalette || [] ),\n\t\t\t],\n\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t);\n\t\tif (\n\t\t\t! hasColorSupport( name ) ||\n\t\t\tshouldSkipSerialization( name, COLOR_SUPPORT_KEY )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\t\tconst extraStyles = {};\n\n\t\tif (\n\t\t\ttextColor &&\n\t\t\t! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'text' )\n\t\t) {\n\t\t\textraStyles.color = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\ttextColor\n\t\t\t)?.color;\n\t\t}\n\t\tif (\n\t\t\tbackgroundColor &&\n\t\t\t! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'background' )\n\t\t) {\n\t\t\textraStyles.backgroundColor = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\tbackgroundColor\n\t\t\t)?.color;\n\t\t}\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t},\n\t'withColorPaletteStyles'\n);\n\nconst MIGRATION_PATHS = {\n\tlinkColor: [ [ 'style', 'elements', 'link', 'color', 'text' ] ],\n\ttextColor: [ [ 'textColor' ], [ 'style', 'color', 'text' ] ],\n\tbackgroundColor: [\n\t\t[ 'backgroundColor' ],\n\t\t[ 'style', 'color', 'background' ],\n\t],\n\tgradient: [ [ 'gradient' ], [ 'style', 'color', 'gradient' ] ],\n};\n\nexport function addTransforms( result, source, index, results ) {\n\tconst destinationBlockType = result.name;\n\tconst activeSupports = {\n\t\tlinkColor: hasLinkColorSupport( destinationBlockType ),\n\t\ttextColor: hasTextColorSupport( destinationBlockType ),\n\t\tbackgroundColor: hasBackgroundColorSupport( destinationBlockType ),\n\t\tgradient: hasGradientSupport( destinationBlockType ),\n\t};\n\treturn transformStyles(\n\t\tactiveSupports,\n\t\tMIGRATION_PATHS,\n\t\tresult,\n\t\tsource,\n\t\tindex,\n\t\tresults\n\t);\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/color/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/color/with-color-palette-styles',\n\twithColorPaletteStyles\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/color/addTransforms',\n\taddTransforms\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,oBAAoB;AACnE,SAASC,0BAA0B,QAAQ,oBAAoB;;AAE/D;AACA;AACA;AACA,SACCC,iBAAiB,EACjBC,+BAA+B,QACzB,sBAAsB;AAC7B,SAASC,8BAA8B,QAAQ,yBAAyB;AACxE,SACCC,gBAAgB,EAChBC,eAAe,EACfC,uBAAuB,EACvBC,gBAAgB,QACV,SAAS;AAChB,OAAOC,UAAU,MAAM,2BAA2B;AAClD,OAAOC,iBAAiB,MAAM,kCAAkC;AAChE,SACCC,gBAAgB,EAChBC,OAAO,IAAIC,gBAAgB,QACrB,yCAAyC;AAChD,OAAOC,yBAAyB,MAAM,oBAAoB;AAE1D,OAAO,MAAMC,iBAAiB,GAAG,OAAO;AAExC,MAAMC,eAAe,GAAKC,SAAS,IAAM;EACxC,MAAMC,YAAY,GAAGrB,eAAe,CAAEoB,SAAS,EAAEF,iBAAkB,CAAC;EACpE,OACCG,YAAY,KACVA,YAAY,CAACC,IAAI,KAAK,IAAI,IAC3BD,YAAY,CAACE,QAAQ,KAAK,IAAI,IAC9BF,YAAY,CAACG,UAAU,KAAK,KAAK,IACjCH,YAAY,CAACI,IAAI,KAAK,KAAK,CAAE;AAEhC,CAAC;AAED,MAAMC,mBAAmB,GAAKN,SAAS,IAAM;EAC5C,IAAKlB,QAAQ,CAACyB,EAAE,KAAK,KAAK,EAAG;IAC5B,OAAO,KAAK;EACb;EAEA,MAAMN,YAAY,GA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E8E,oBAAqB;EACpD,CAAC;EACD,OAAOjG,eAAe,CACrBkG,cAAc,EACdR,eAAe,EACfG,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,OACD,CAAC;AACF;AAEA1G,SAAS,CACR,0BAA0B,EAC1B,yBAAyB,EACzBiC,aACD,CAAC;AAEDjC,SAAS,CACR,kCAAkC,EAClC,yBAAyB,EACzByC,YACD,CAAC;AAEDzC,SAAS,CACR,0BAA0B,EAC1B,yBAAyB,EACzByD,YACD,CAAC;AAEDzD,SAAS,CACR,uBAAuB,EACvB,sCAAsC,EACtC4F,sBACD,CAAC;AAED5F,SAAS,CACR,2CAA2C,EAC3C,0BAA0B,EAC1BsG,aACD,CAAC"}
1
+ {"version":3,"names":["classnames","addFilter","getBlockSupport","useMemo","Platform","useCallback","createHigherOrderComponent","getColorClassName","getColorObjectByAttributeValues","__experimentalGetGradientClass","cleanEmptyObject","transformStyles","shouldSkipSerialization","useBlockSettings","useSettings","InspectorControls","useHasColorPanel","default","StylesColorPanel","BlockColorContrastChecker","COLOR_SUPPORT_KEY","hasColorSupport","blockType","colorSupport","link","gradient","background","text","hasLinkColorSupport","OS","hasGradientSupport","gradients","hasBackgroundColorSupport","hasTextColorSupport","addAttributes","settings","attributes","backgroundColor","Object","assign","type","textColor","addSaveProps","props","hasGradient","style","shouldSerialize","feature","textClass","undefined","gradientClass","backgroundClass","serializeHasBackground","hasBackground","color","newClassName","className","elements","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","styleToAttributes","textColorValue","textColorSlug","startsWith","substring","length","backgroundColorValue","backgroundColorSlug","gradientValue","gradientSlug","updatedStyle","attributesToStyle","ColorInspectorControl","children","resetAllFilter","attributesResetAllFilter","existingStyle","createElement","group","ColorEdit","clientId","name","setAttributes","isEnabled","value","onChange","newStyle","defaultControls","enableContrastChecking","as","panelId","enableContrastChecker","withColorPaletteStyles","BlockListBlock","userPalette","themePalette","defaultPalette","colors","extraStyles","wrapperProps","MIGRATION_PATHS","linkColor","addTransforms","result","source","index","results","destinationBlockType","activeSupports"],"sources":["@wordpress/block-editor/src/hooks/color.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useMemo, Platform, useCallback } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport { __experimentalGetGradientClass } from '../components/gradients';\nimport {\n\tcleanEmptyObject,\n\ttransformStyles,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tuseHasColorPanel,\n\tdefault as StylesColorPanel,\n} from '../components/global-styles/color-panel';\nimport BlockColorContrastChecker from './contrast-checker';\n\nexport const COLOR_SUPPORT_KEY = 'color';\n\nconst hasColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\treturn (\n\t\tcolorSupport &&\n\t\t( colorSupport.link === true ||\n\t\t\tcolorSupport.gradient === true ||\n\t\t\tcolorSupport.background !== false ||\n\t\t\tcolorSupport.text !== false )\n\t);\n};\n\nconst hasLinkColorSupport = ( blockType ) => {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn (\n\t\tcolorSupport !== null &&\n\t\ttypeof colorSupport === 'object' &&\n\t\t!! colorSupport.link\n\t);\n};\n\nconst hasGradientSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn (\n\t\tcolorSupport !== null &&\n\t\ttypeof colorSupport === 'object' &&\n\t\t!! colorSupport.gradients\n\t);\n};\n\nconst hasBackgroundColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.background !== false;\n};\n\nconst hasTextColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.text !== false;\n};\n\n/**\n * Filters registered block settings, extending attributes to include\n * `backgroundColor` and `textColor` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasColorSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.backgroundColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tbackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\tif ( ! settings.attributes.textColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\ttextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( hasGradientSupport( settings ) && ! settings.attributes.gradient ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tgradient: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject colors classnames.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasColorSupport( blockType ) ||\n\t\tshouldSkipSerialization( blockType, COLOR_SUPPORT_KEY )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst hasGradient = hasGradientSupport( blockType );\n\n\t// I'd have preferred to avoid the \"style\" attribute usage here\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\tconst shouldSerialize = ( feature ) =>\n\t\t! shouldSkipSerialization( blockType, COLOR_SUPPORT_KEY, feature );\n\n\t// Primary color classes must come before the `has-text-color`,\n\t// `has-background` and `has-link-color` classes to maintain backwards\n\t// compatibility and avoid block invalidations.\n\tconst textClass = shouldSerialize( 'text' )\n\t\t? getColorClassName( 'color', textColor )\n\t\t: undefined;\n\n\tconst gradientClass = shouldSerialize( 'gradients' )\n\t\t? __experimentalGetGradientClass( gradient )\n\t\t: undefined;\n\n\tconst backgroundClass = shouldSerialize( 'background' )\n\t\t? getColorClassName( 'background-color', backgroundColor )\n\t\t: undefined;\n\n\tconst serializeHasBackground =\n\t\tshouldSerialize( 'background' ) || shouldSerialize( 'gradients' );\n\tconst hasBackground =\n\t\tbackgroundColor ||\n\t\tstyle?.color?.background ||\n\t\t( hasGradient && ( gradient || style?.color?.gradient ) );\n\n\tconst newClassName = classnames(\n\t\tprops.className,\n\t\ttextClass,\n\t\tgradientClass,\n\t\t{\n\t\t\t// Don't apply the background class if there's a custom gradient.\n\t\t\t[ backgroundClass ]:\n\t\t\t\t( ! hasGradient || ! style?.color?.gradient ) &&\n\t\t\t\t!! backgroundClass,\n\t\t\t'has-text-color':\n\t\t\t\tshouldSerialize( 'text' ) &&\n\t\t\t\t( textColor || style?.color?.text ),\n\t\t\t'has-background': serializeHasBackground && hasBackground,\n\t\t\t'has-link-color':\n\t\t\t\tshouldSerialize( 'link' ) && style?.elements?.link?.color,\n\t\t}\n\t);\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif (\n\t\t! hasColorSupport( settings ) ||\n\t\tshouldSkipSerialization( settings, COLOR_SUPPORT_KEY )\n\t) {\n\t\treturn settings;\n\t}\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\nfunction styleToAttributes( style ) {\n\tconst textColorValue = style?.color?.text;\n\tconst textColorSlug = textColorValue?.startsWith( 'var:preset|color|' )\n\t\t? textColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst backgroundColorValue = style?.color?.background;\n\tconst backgroundColorSlug = backgroundColorValue?.startsWith(\n\t\t'var:preset|color|'\n\t)\n\t\t? backgroundColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst gradientValue = style?.color?.gradient;\n\tconst gradientSlug = gradientValue?.startsWith( 'var:preset|gradient|' )\n\t\t? gradientValue.substring( 'var:preset|gradient|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.color = {\n\t\t...updatedStyle.color,\n\t\ttext: textColorSlug ? undefined : textColorValue,\n\t\tbackground: backgroundColorSlug ? undefined : backgroundColorValue,\n\t\tgradient: gradientSlug ? undefined : gradientValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\ttextColor: textColorSlug,\n\t\tbackgroundColor: backgroundColorSlug,\n\t\tgradient: gradientSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\treturn {\n\t\t...attributes.style,\n\t\tcolor: {\n\t\t\t...attributes.style?.color,\n\t\t\ttext: attributes.textColor\n\t\t\t\t? 'var:preset|color|' + attributes.textColor\n\t\t\t\t: attributes.style?.color?.text,\n\t\t\tbackground: attributes.backgroundColor\n\t\t\t\t? 'var:preset|color|' + attributes.backgroundColor\n\t\t\t\t: attributes.style?.color?.background,\n\t\t\tgradient: attributes.gradient\n\t\t\t\t? 'var:preset|gradient|' + attributes.gradient\n\t\t\t\t: attributes.style?.color?.gradient,\n\t\t},\n\t};\n}\n\nfunction ColorInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"color\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function ColorEdit( props ) {\n\tconst { clientId, name, attributes, setAttributes } = props;\n\tconst settings = useBlockSettings( name );\n\tconst isEnabled = useHasColorPanel( settings );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( {\n\t\t\tstyle: attributes.style,\n\t\t\ttextColor: attributes.textColor,\n\t\t\tbackgroundColor: attributes.backgroundColor,\n\t\t\tgradient: attributes.gradient,\n\t\t} );\n\t}, [\n\t\tattributes.style,\n\t\tattributes.textColor,\n\t\tattributes.backgroundColor,\n\t\tattributes.gradient,\n\t] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tCOLOR_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst enableContrastChecking =\n\t\tPlatform.OS === 'web' &&\n\t\t! value?.color?.gradient &&\n\t\t( settings?.color?.text || settings?.color?.link ) &&\n\t\t// Contrast checking is enabled by default.\n\t\t// Deactivating it requires `enableContrastChecker` to have\n\t\t// an explicit value of `false`.\n\t\tfalse !==\n\t\t\tgetBlockSupport( props.name, [\n\t\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t\t'enableContrastChecker',\n\t\t\t] );\n\n\treturn (\n\t\t<StylesColorPanel\n\t\t\tas={ ColorInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tenableContrastChecker={\n\t\t\t\tfalse !==\n\t\t\t\tgetBlockSupport( props.name, [\n\t\t\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t\t\t'enableContrastChecker',\n\t\t\t\t] )\n\t\t\t}\n\t\t>\n\t\t\t{ enableContrastChecking && (\n\t\t\t\t<BlockColorContrastChecker clientId={ clientId } />\n\t\t\t) }\n\t\t</StylesColorPanel>\n\t);\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { backgroundColor, textColor } = attributes;\n\t\tconst [ userPalette, themePalette, defaultPalette ] = useSettings(\n\t\t\t'color.palette.custom',\n\t\t\t'color.palette.theme',\n\t\t\t'color.palette.default'\n\t\t);\n\n\t\tconst colors = useMemo(\n\t\t\t() => [\n\t\t\t\t...( userPalette || [] ),\n\t\t\t\t...( themePalette || [] ),\n\t\t\t\t...( defaultPalette || [] ),\n\t\t\t],\n\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t);\n\t\tif (\n\t\t\t! hasColorSupport( name ) ||\n\t\t\tshouldSkipSerialization( name, COLOR_SUPPORT_KEY )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\t\tconst extraStyles = {};\n\n\t\tif (\n\t\t\ttextColor &&\n\t\t\t! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'text' )\n\t\t) {\n\t\t\textraStyles.color = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\ttextColor\n\t\t\t)?.color;\n\t\t}\n\t\tif (\n\t\t\tbackgroundColor &&\n\t\t\t! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'background' )\n\t\t) {\n\t\t\textraStyles.backgroundColor = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\tbackgroundColor\n\t\t\t)?.color;\n\t\t}\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t},\n\t'withColorPaletteStyles'\n);\n\nconst MIGRATION_PATHS = {\n\tlinkColor: [ [ 'style', 'elements', 'link', 'color', 'text' ] ],\n\ttextColor: [ [ 'textColor' ], [ 'style', 'color', 'text' ] ],\n\tbackgroundColor: [\n\t\t[ 'backgroundColor' ],\n\t\t[ 'style', 'color', 'background' ],\n\t],\n\tgradient: [ [ 'gradient' ], [ 'style', 'color', 'gradient' ] ],\n};\n\nexport function addTransforms( result, source, index, results ) {\n\tconst destinationBlockType = result.name;\n\tconst activeSupports = {\n\t\tlinkColor: hasLinkColorSupport( destinationBlockType ),\n\t\ttextColor: hasTextColorSupport( destinationBlockType ),\n\t\tbackgroundColor: hasBackgroundColorSupport( destinationBlockType ),\n\t\tgradient: hasGradientSupport( destinationBlockType ),\n\t};\n\treturn transformStyles(\n\t\tactiveSupports,\n\t\tMIGRATION_PATHS,\n\t\tresult,\n\t\tsource,\n\t\tindex,\n\t\tresults\n\t);\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/color/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/color/with-color-palette-styles',\n\twithColorPaletteStyles\n);\n\naddFilter(\n\t'blocks.switchToBl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yB,EACzBiC,aACD,CAAC;AAEDjC,SAAS,CACR,kCAAkC,EAClC,yBAAyB,EACzByC,YACD,CAAC;AAEDzC,SAAS,CACR,0BAA0B,EAC1B,yBAAyB,EACzByD,YACD,CAAC;AAEDzD,SAAS,CACR,uBAAuB,EACvB,sCAAsC,EACtC4F,sBACD,CAAC;AAED5F,SAAS,CACR,2CAA2C,EAC3C,0BAA0B,EAC1BsG,aACD,CAAC"}
@@ -38,6 +38,29 @@ export function addAttribute(settings) {
38
38
  }
39
39
  return settings;
40
40
  }
41
+ function CustomClassNameControls({
42
+ attributes,
43
+ setAttributes
44
+ }) {
45
+ const blockEditingMode = useBlockEditingMode();
46
+ if (blockEditingMode !== 'default') {
47
+ return null;
48
+ }
49
+ return createElement(InspectorControls, {
50
+ group: "advanced"
51
+ }, createElement(TextControl, {
52
+ __nextHasNoMarginBottom: true,
53
+ autoComplete: "off",
54
+ label: __('Additional CSS class(es)'),
55
+ value: attributes.className || '',
56
+ onChange: nextValue => {
57
+ setAttributes({
58
+ className: nextValue !== '' ? nextValue : undefined
59
+ });
60
+ },
61
+ help: __('Separate multiple classes with spaces.')
62
+ }));
63
+ }
41
64
 
42
65
  /**
43
66
  * Override the default edit UI to include a new block inspector control for
@@ -50,29 +73,13 @@ export function addAttribute(settings) {
50
73
  */
51
74
  export const withInspectorControl = createHigherOrderComponent(BlockEdit => {
52
75
  return props => {
53
- const blockEditingMode = useBlockEditingMode();
54
76
  const hasCustomClassName = hasBlockSupport(props.name, 'customClassName', true);
55
- if (hasCustomClassName && props.isSelected) {
56
- return createElement(Fragment, null, createElement(BlockEdit, {
57
- ...props
58
- }), blockEditingMode === 'default' && createElement(InspectorControls, {
59
- group: "advanced"
60
- }, createElement(TextControl, {
61
- __nextHasNoMarginBottom: true,
62
- autoComplete: "off",
63
- label: __('Additional CSS class(es)'),
64
- value: props.attributes.className || '',
65
- onChange: nextValue => {
66
- props.setAttributes({
67
- className: nextValue !== '' ? nextValue : undefined
68
- });
69
- },
70
- help: __('Separate multiple classes with spaces.')
71
- })));
72
- }
73
- return createElement(BlockEdit, {
77
+ return createElement(Fragment, null, createElement(BlockEdit, {
74
78
  ...props
75
- });
79
+ }), hasCustomClassName && props.isSelected && createElement(CustomClassNameControls, {
80
+ attributes: props.attributes,
81
+ setAttributes: props.setAttributes
82
+ }));
76
83
  };
77
84
  }, 'withInspectorControl');
78
85