@wordpress/block-editor 15.22.1-next.v.202606191442.0 → 15.23.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 (383) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/README.md +2 -2
  3. package/build/components/block-editing-mode/index.cjs +13 -7
  4. package/build/components/block-editing-mode/index.cjs.map +2 -2
  5. package/build/components/block-inspector/index.cjs +50 -51
  6. package/build/components/block-inspector/index.cjs.map +2 -2
  7. package/build/components/block-rename/modal.cjs +0 -1
  8. package/build/components/block-rename/modal.cjs.map +2 -2
  9. package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
  10. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  11. package/build/components/colors-gradients/control.cjs +25 -14
  12. package/build/components/colors-gradients/control.cjs.map +2 -2
  13. package/build/components/colors-gradients/dropdown.cjs +4 -1
  14. package/build/components/colors-gradients/dropdown.cjs.map +3 -3
  15. package/build/components/contrast-checker/index.cjs +22 -4
  16. package/build/components/contrast-checker/index.cjs.map +2 -2
  17. package/build/components/date-format-picker/index.cjs +0 -1
  18. package/build/components/date-format-picker/index.cjs.map +2 -2
  19. package/build/components/global-styles/background-panel.cjs +153 -25
  20. package/build/components/global-styles/background-panel.cjs.map +3 -3
  21. package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
  22. package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
  23. package/build/components/global-styles/color-panel.cjs +98 -375
  24. package/build/components/global-styles/color-panel.cjs.map +3 -3
  25. package/build/components/global-styles/dimensions-panel.cjs +0 -3
  26. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  27. package/build/components/global-styles/hooks.cjs +34 -0
  28. package/build/components/global-styles/hooks.cjs.map +2 -2
  29. package/build/components/global-styles/typography-panel.cjs +82 -10
  30. package/build/components/global-styles/typography-panel.cjs.map +3 -3
  31. package/build/components/inspector-controls/groups.cjs +2 -0
  32. package/build/components/inspector-controls/groups.cjs.map +2 -2
  33. package/build/components/inspector-controls-tabs/styles-tab.cjs +75 -31
  34. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  35. package/build/components/link-control/index.cjs +1 -2
  36. package/build/components/link-control/index.cjs.map +2 -2
  37. package/build/components/list-view/block-select-button.cjs +1 -10
  38. package/build/components/list-view/block-select-button.cjs.map +3 -3
  39. package/build/components/provider/use-block-sync.cjs +3 -1
  40. package/build/components/provider/use-block-sync.cjs.map +2 -2
  41. package/build/components/url-popover/image-url-input-ui.cjs +0 -2
  42. package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
  43. package/build/components/use-block-display-information/index.cjs +10 -3
  44. package/build/components/use-block-display-information/index.cjs.map +2 -2
  45. package/build/components/use-resize-canvas/index.cjs +16 -53
  46. package/build/components/use-resize-canvas/index.cjs.map +3 -3
  47. package/build/hooks/anchor.cjs +0 -1
  48. package/build/hooks/anchor.cjs.map +2 -2
  49. package/build/hooks/background.cjs +124 -75
  50. package/build/hooks/background.cjs.map +3 -3
  51. package/build/hooks/color.cjs +0 -162
  52. package/build/hooks/color.cjs.map +3 -3
  53. package/build/hooks/contrast-checker.cjs +31 -28
  54. package/build/hooks/contrast-checker.cjs.map +3 -3
  55. package/build/hooks/custom-class-name.cjs +0 -1
  56. package/build/hooks/custom-class-name.cjs.map +2 -2
  57. package/build/hooks/elements.cjs +142 -0
  58. package/build/hooks/elements.cjs.map +7 -0
  59. package/build/hooks/grid-visualizer.cjs +21 -11
  60. package/build/hooks/grid-visualizer.cjs.map +2 -2
  61. package/build/hooks/layout-child.cjs +38 -8
  62. package/build/hooks/layout-child.cjs.map +2 -2
  63. package/build/hooks/layout.cjs +6 -3
  64. package/build/hooks/layout.cjs.map +2 -2
  65. package/build/hooks/states.cjs +15 -23
  66. package/build/hooks/states.cjs.map +2 -2
  67. package/build/hooks/style.cjs +8 -4
  68. package/build/hooks/style.cjs.map +2 -2
  69. package/build/hooks/typography.cjs +62 -10
  70. package/build/hooks/typography.cjs.map +3 -3
  71. package/build/layouts/flex.cjs +99 -6
  72. package/build/layouts/flex.cjs.map +2 -2
  73. package/build/private-apis.cjs +0 -1
  74. package/build/private-apis.cjs.map +2 -2
  75. package/build/store/private-actions.cjs +16 -0
  76. package/build/store/private-actions.cjs.map +2 -2
  77. package/build/store/private-keys.cjs +0 -3
  78. package/build/store/private-keys.cjs.map +2 -2
  79. package/build/store/private-selectors.cjs +24 -6
  80. package/build/store/private-selectors.cjs.map +2 -2
  81. package/build/store/reducer.cjs +19 -3
  82. package/build/store/reducer.cjs.map +2 -2
  83. package/build/utils/block-bindings.cjs +9 -9
  84. package/build/utils/block-bindings.cjs.map +3 -3
  85. package/build/utils/color-values.cjs +10 -1
  86. package/build/utils/color-values.cjs.map +3 -3
  87. package/build/utils/dom.cjs +2 -5
  88. package/build/utils/dom.cjs.map +3 -3
  89. package/build/utils/fit-text-frontend.cjs +6 -2
  90. package/build/utils/fit-text-frontend.cjs.map +3 -3
  91. package/build/utils/fit-text-utils.cjs +1 -1
  92. package/build/utils/fit-text-utils.cjs.map +3 -3
  93. package/build/utils/format-font-style.cjs +1 -1
  94. package/build/utils/format-font-style.cjs.map +3 -3
  95. package/build/utils/format-font-weight.cjs +1 -1
  96. package/build/utils/format-font-weight.cjs.map +3 -3
  97. package/build/utils/get-editor-region.cjs +4 -2
  98. package/build/utils/get-editor-region.cjs.map +3 -3
  99. package/build/utils/get-font-styles-and-weights.cjs +8 -12
  100. package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
  101. package/build/utils/get-px-from-css-unit.cjs +1 -1
  102. package/build/utils/get-px-from-css-unit.cjs.map +1 -1
  103. package/build/utils/index.cjs +1 -1
  104. package/build/utils/index.cjs.map +1 -1
  105. package/build/utils/math.cjs +1 -1
  106. package/build/utils/math.cjs.map +3 -3
  107. package/build/utils/object.cjs +8 -8
  108. package/build/utils/object.cjs.map +3 -3
  109. package/build/utils/order-inserter-block-items.cjs +1 -1
  110. package/build/utils/order-inserter-block-items.cjs.map +3 -3
  111. package/build/utils/pasting.cjs +4 -2
  112. package/build/utils/pasting.cjs.map +3 -3
  113. package/build/utils/selection.cjs +2 -1
  114. package/build/utils/selection.cjs.map +3 -3
  115. package/build/utils/sorting.cjs +9 -3
  116. package/build/utils/sorting.cjs.map +3 -3
  117. package/build/utils/transform-styles/index.cjs +3 -2
  118. package/build/utils/transform-styles/index.cjs.map +3 -3
  119. package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
  120. package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
  121. package/build/utils/transform-styles/types.cjs +19 -0
  122. package/build/utils/transform-styles/types.cjs.map +7 -0
  123. package/build/utils/types.cjs +19 -0
  124. package/build/utils/types.cjs.map +7 -0
  125. package/build-module/components/block-editing-mode/index.mjs +14 -8
  126. package/build-module/components/block-editing-mode/index.mjs.map +2 -2
  127. package/build-module/components/block-inspector/index.mjs +50 -51
  128. package/build-module/components/block-inspector/index.mjs.map +2 -2
  129. package/build-module/components/block-rename/modal.mjs +0 -1
  130. package/build-module/components/block-rename/modal.mjs.map +2 -2
  131. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
  132. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  133. package/build-module/components/colors-gradients/control.mjs +27 -15
  134. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  135. package/build-module/components/colors-gradients/dropdown.mjs +4 -1
  136. package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
  137. package/build-module/components/contrast-checker/index.mjs +18 -4
  138. package/build-module/components/contrast-checker/index.mjs.map +2 -2
  139. package/build-module/components/date-format-picker/index.mjs +0 -1
  140. package/build-module/components/date-format-picker/index.mjs.map +2 -2
  141. package/build-module/components/global-styles/background-panel.mjs +155 -27
  142. package/build-module/components/global-styles/background-panel.mjs.map +2 -2
  143. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
  144. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
  145. package/build-module/components/global-styles/color-panel.mjs +106 -387
  146. package/build-module/components/global-styles/color-panel.mjs.map +3 -3
  147. package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
  148. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  149. package/build-module/components/global-styles/hooks.mjs +33 -0
  150. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  151. package/build-module/components/global-styles/typography-panel.mjs +84 -10
  152. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  153. package/build-module/components/inspector-controls/groups.mjs +2 -0
  154. package/build-module/components/inspector-controls/groups.mjs.map +2 -2
  155. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +75 -31
  156. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  157. package/build-module/components/link-control/index.mjs +1 -2
  158. package/build-module/components/link-control/index.mjs.map +2 -2
  159. package/build-module/components/list-view/block-select-button.mjs +2 -17
  160. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  161. package/build-module/components/provider/use-block-sync.mjs +3 -1
  162. package/build-module/components/provider/use-block-sync.mjs.map +2 -2
  163. package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
  164. package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
  165. package/build-module/components/use-block-display-information/index.mjs +10 -3
  166. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  167. package/build-module/components/use-resize-canvas/index.mjs +6 -53
  168. package/build-module/components/use-resize-canvas/index.mjs.map +2 -2
  169. package/build-module/hooks/anchor.mjs +0 -1
  170. package/build-module/hooks/anchor.mjs.map +2 -2
  171. package/build-module/hooks/background.mjs +123 -75
  172. package/build-module/hooks/background.mjs.map +2 -2
  173. package/build-module/hooks/color.mjs +2 -175
  174. package/build-module/hooks/color.mjs.map +2 -2
  175. package/build-module/hooks/contrast-checker.mjs +32 -19
  176. package/build-module/hooks/contrast-checker.mjs.map +2 -2
  177. package/build-module/hooks/custom-class-name.mjs +0 -1
  178. package/build-module/hooks/custom-class-name.mjs.map +2 -2
  179. package/build-module/hooks/elements.mjs +115 -0
  180. package/build-module/hooks/elements.mjs.map +7 -0
  181. package/build-module/hooks/grid-visualizer.mjs +21 -11
  182. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  183. package/build-module/hooks/layout-child.mjs +41 -8
  184. package/build-module/hooks/layout-child.mjs.map +2 -2
  185. package/build-module/hooks/layout.mjs +6 -3
  186. package/build-module/hooks/layout.mjs.map +2 -2
  187. package/build-module/hooks/states.mjs +15 -23
  188. package/build-module/hooks/states.mjs.map +2 -2
  189. package/build-module/hooks/style.mjs +9 -5
  190. package/build-module/hooks/style.mjs.map +2 -2
  191. package/build-module/hooks/typography.mjs +62 -10
  192. package/build-module/hooks/typography.mjs.map +2 -2
  193. package/build-module/layouts/flex.mjs +105 -7
  194. package/build-module/layouts/flex.mjs.map +2 -2
  195. package/build-module/private-apis.mjs +0 -2
  196. package/build-module/private-apis.mjs.map +2 -2
  197. package/build-module/store/private-actions.mjs +14 -0
  198. package/build-module/store/private-actions.mjs.map +2 -2
  199. package/build-module/store/private-keys.mjs +0 -2
  200. package/build-module/store/private-keys.mjs.map +2 -2
  201. package/build-module/store/private-selectors.mjs +22 -6
  202. package/build-module/store/private-selectors.mjs.map +2 -2
  203. package/build-module/store/reducer.mjs +17 -3
  204. package/build-module/store/reducer.mjs.map +2 -2
  205. package/build-module/utils/block-bindings.mjs +9 -9
  206. package/build-module/utils/block-bindings.mjs.map +3 -3
  207. package/build-module/utils/color-values.mjs +9 -1
  208. package/build-module/utils/color-values.mjs.map +3 -3
  209. package/build-module/utils/dom.mjs +2 -5
  210. package/build-module/utils/dom.mjs.map +3 -3
  211. package/build-module/utils/fit-text-frontend.mjs +6 -2
  212. package/build-module/utils/fit-text-frontend.mjs.map +3 -3
  213. package/build-module/utils/fit-text-utils.mjs +1 -1
  214. package/build-module/utils/fit-text-utils.mjs.map +3 -3
  215. package/build-module/utils/format-font-style.mjs +1 -1
  216. package/build-module/utils/format-font-style.mjs.map +3 -3
  217. package/build-module/utils/format-font-weight.mjs +1 -1
  218. package/build-module/utils/format-font-weight.mjs.map +3 -3
  219. package/build-module/utils/get-editor-region.mjs +4 -2
  220. package/build-module/utils/get-editor-region.mjs.map +3 -3
  221. package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
  222. package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
  223. package/build-module/utils/get-px-from-css-unit.mjs +1 -1
  224. package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
  225. package/build-module/utils/index.mjs +1 -1
  226. package/build-module/utils/index.mjs.map +1 -1
  227. package/build-module/utils/math.mjs +1 -1
  228. package/build-module/utils/math.mjs.map +3 -3
  229. package/build-module/utils/object.mjs +8 -8
  230. package/build-module/utils/object.mjs.map +3 -3
  231. package/build-module/utils/order-inserter-block-items.mjs +1 -1
  232. package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
  233. package/build-module/utils/pasting.mjs +4 -2
  234. package/build-module/utils/pasting.mjs.map +3 -3
  235. package/build-module/utils/selection.mjs +2 -1
  236. package/build-module/utils/selection.mjs.map +3 -3
  237. package/build-module/utils/sorting.mjs +9 -3
  238. package/build-module/utils/sorting.mjs.map +3 -3
  239. package/build-module/utils/transform-styles/index.mjs +3 -2
  240. package/build-module/utils/transform-styles/index.mjs.map +3 -3
  241. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
  242. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
  243. package/build-module/utils/transform-styles/types.mjs +1 -0
  244. package/build-module/utils/transform-styles/types.mjs.map +7 -0
  245. package/build-module/utils/types.mjs +1 -0
  246. package/build-module/utils/types.mjs.map +7 -0
  247. package/build-style/content-rtl.css +2 -0
  248. package/build-style/content.css +2 -0
  249. package/build-style/style-rtl.css +34 -41
  250. package/build-style/style.css +34 -41
  251. package/build-types/utils/block-bindings.d.ts +27 -0
  252. package/build-types/utils/block-bindings.d.ts.map +1 -0
  253. package/build-types/utils/color-values.d.ts +40 -0
  254. package/build-types/utils/color-values.d.ts.map +1 -0
  255. package/build-types/utils/dom.d.ts +19 -19
  256. package/build-types/utils/dom.d.ts.map +1 -1
  257. package/build-types/utils/fit-text-frontend.d.ts +7 -0
  258. package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
  259. package/build-types/utils/fit-text-utils.d.ts +15 -0
  260. package/build-types/utils/fit-text-utils.d.ts.map +1 -0
  261. package/build-types/utils/format-font-style.d.ts +12 -0
  262. package/build-types/utils/format-font-style.d.ts.map +1 -0
  263. package/build-types/utils/format-font-weight.d.ts +12 -0
  264. package/build-types/utils/format-font-weight.d.ts.map +1 -0
  265. package/build-types/utils/get-editor-region.d.ts +9 -0
  266. package/build-types/utils/get-editor-region.d.ts.map +1 -0
  267. package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
  268. package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
  269. package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
  270. package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
  271. package/build-types/utils/index.d.ts +3 -0
  272. package/build-types/utils/index.d.ts.map +1 -0
  273. package/build-types/utils/math.d.ts +61 -0
  274. package/build-types/utils/math.d.ts.map +1 -0
  275. package/build-types/utils/object.d.ts +39 -0
  276. package/build-types/utils/object.d.ts.map +1 -0
  277. package/build-types/utils/order-inserter-block-items.d.ts +13 -0
  278. package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
  279. package/build-types/utils/pasting.d.ts +28 -0
  280. package/build-types/utils/pasting.d.ts.map +1 -0
  281. package/build-types/utils/selection.d.ts +21 -0
  282. package/build-types/utils/selection.d.ts.map +1 -0
  283. package/build-types/utils/sorting.d.ts +17 -0
  284. package/build-types/utils/sorting.d.ts.map +1 -0
  285. package/build-types/utils/transform-styles/index.d.ts +15 -0
  286. package/build-types/utils/transform-styles/index.d.ts.map +1 -0
  287. package/build-types/utils/transform-styles/types.d.ts +13 -0
  288. package/build-types/utils/transform-styles/types.d.ts.map +1 -0
  289. package/build-types/utils/types.d.ts +28 -0
  290. package/build-types/utils/types.d.ts.map +1 -0
  291. package/package.json +40 -39
  292. package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
  293. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
  294. package/src/components/block-editing-mode/index.js +17 -9
  295. package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
  296. package/src/components/block-inspector/index.js +43 -53
  297. package/src/components/block-rename/modal.js +0 -1
  298. package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
  299. package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
  300. package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
  301. package/src/components/colors-gradients/control.js +29 -12
  302. package/src/components/colors-gradients/dropdown.js +4 -1
  303. package/src/components/colors-gradients/style.scss +39 -2
  304. package/src/components/contrast-checker/README.md +9 -0
  305. package/src/components/contrast-checker/index.js +42 -3
  306. package/src/components/date-format-picker/index.js +0 -1
  307. package/src/components/default-block-appender/content.scss +3 -0
  308. package/src/components/global-styles/background-panel.js +201 -34
  309. package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
  310. package/src/components/global-styles/color-panel.js +125 -487
  311. package/src/components/global-styles/dimensions-panel.js +0 -3
  312. package/src/components/global-styles/hooks.js +45 -0
  313. package/src/components/global-styles/test/background-panel.js +56 -0
  314. package/src/components/global-styles/test/color-panel.js +172 -118
  315. package/src/components/global-styles/test/typography-panel.js +167 -0
  316. package/src/components/global-styles/typography-panel.js +100 -11
  317. package/src/components/inspector-controls/README.md +0 -2
  318. package/src/components/inspector-controls/groups.js +2 -0
  319. package/src/components/inspector-controls-tabs/styles-tab.js +74 -28
  320. package/src/components/link-control/index.js +0 -1
  321. package/src/components/link-control/test/index.js +2 -3
  322. package/src/components/list-view/block-select-button.js +2 -17
  323. package/src/components/provider/use-block-sync.js +3 -1
  324. package/src/components/rich-text/content.scss +2 -0
  325. package/src/components/url-popover/image-url-input-ui.js +0 -2
  326. package/src/components/use-block-display-information/index.js +15 -2
  327. package/src/components/use-block-display-information/test/index.js +140 -0
  328. package/src/components/use-resize-canvas/index.js +10 -71
  329. package/src/hooks/anchor.js +0 -1
  330. package/src/hooks/background.js +210 -133
  331. package/src/hooks/background.scss +0 -35
  332. package/src/hooks/color.js +2 -205
  333. package/src/hooks/color.scss +3 -9
  334. package/src/hooks/contrast-checker.js +60 -17
  335. package/src/hooks/custom-class-name.js +0 -1
  336. package/src/hooks/elements.js +140 -0
  337. package/src/hooks/elements.scss +8 -0
  338. package/src/hooks/grid-visualizer.js +59 -45
  339. package/src/hooks/layout-child.js +51 -12
  340. package/src/hooks/layout.js +6 -3
  341. package/src/hooks/states.js +32 -28
  342. package/src/hooks/style.js +11 -7
  343. package/src/hooks/test/background.js +59 -0
  344. package/src/hooks/test/block-style-state.js +14 -14
  345. package/src/hooks/test/layout.js +6 -6
  346. package/src/hooks/test/style.js +8 -8
  347. package/src/hooks/typography.js +70 -6
  348. package/src/layouts/flex.js +118 -15
  349. package/src/private-apis.js +0 -2
  350. package/src/store/private-actions.js +31 -0
  351. package/src/store/private-keys.js +0 -1
  352. package/src/store/private-selectors.js +43 -7
  353. package/src/store/reducer.js +37 -2
  354. package/src/store/test/private-selectors.js +39 -14
  355. package/src/store/test/reducer.js +91 -12
  356. package/src/style.scss +1 -0
  357. package/src/utils/block-bindings.ts +51 -0
  358. package/src/utils/color-values.ts +63 -0
  359. package/src/utils/{dom.js → dom.ts} +27 -27
  360. package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
  361. package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
  362. package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
  363. package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
  364. package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
  365. package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
  366. package/src/utils/{math.js → math.ts} +37 -30
  367. package/src/utils/object.ts +89 -0
  368. package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
  369. package/src/utils/{pasting.js → pasting.ts} +18 -11
  370. package/src/utils/{selection.js → selection.ts} +11 -4
  371. package/src/utils/sorting.ts +81 -0
  372. package/src/utils/test/color-values.js +44 -1
  373. package/src/utils/transform-styles/{index.js → index.ts} +25 -25
  374. package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
  375. package/src/utils/transform-styles/types.ts +13 -0
  376. package/src/utils/types.ts +29 -0
  377. package/src/components/use-resize-canvas/README.md +0 -37
  378. package/src/utils/block-bindings.js +0 -46
  379. package/src/utils/color-values.js +0 -28
  380. package/src/utils/object.js +0 -67
  381. package/src/utils/sorting.js +0 -54
  382. /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
  383. /package/src/utils/{index.js → index.ts} +0 -0
@@ -4,6 +4,7 @@
4
4
  import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
5
5
  import { useMemo, useCallback } from '@wordpress/element';
6
6
  import { useSelect } from '@wordpress/data';
7
+ import { __ } from '@wordpress/i18n';
7
8
 
8
9
  /**
9
10
  * Internal dependencies
@@ -20,6 +21,7 @@ import { FONT_SIZE_SUPPORT_KEY } from './font-size';
20
21
  import { TEXT_ALIGN_SUPPORT_KEY } from './text-align';
21
22
  import { FIT_TEXT_SUPPORT_KEY } from './fit-text';
22
23
  import { cleanEmptyObject } from './utils';
24
+ import { extractPresetSlug } from '../utils/color-values';
23
25
  import { store as blockEditorStore } from '../store';
24
26
  import {
25
27
  getStyleForState,
@@ -27,6 +29,7 @@ import {
27
29
  setStyleForState,
28
30
  useBlockStyleState,
29
31
  } from './block-style-state';
32
+ import useBlockColorContrastWarning from './contrast-checker';
30
33
 
31
34
  function omit( object, keys ) {
32
35
  return Object.fromEntries(
@@ -63,6 +66,7 @@ function styleToAttributes( style ) {
63
66
  const updatedStyle = { ...omit( style, [ 'fontFamily' ] ) };
64
67
  const fontSizeValue = style?.typography?.fontSize;
65
68
  const fontFamilyValue = style?.typography?.fontFamily;
69
+ const textColorValue = style?.color?.text;
66
70
  const fontSizeSlug =
67
71
  typeof fontSizeValue === 'string' &&
68
72
  fontSizeValue?.startsWith( 'var:preset|font-size|' )
@@ -73,14 +77,20 @@ function styleToAttributes( style ) {
73
77
  )
74
78
  ? fontFamilyValue.substring( 'var:preset|font-family|'.length )
75
79
  : undefined;
80
+ const textColorSlug = extractPresetSlug( textColorValue, 'color' );
76
81
  updatedStyle.typography = {
77
82
  ...omit( updatedStyle.typography, [ 'fontFamily' ] ),
78
83
  fontSize: fontSizeSlug ? undefined : fontSizeValue,
79
84
  };
85
+ updatedStyle.color = {
86
+ ...updatedStyle.color,
87
+ text: textColorSlug ? undefined : textColorValue,
88
+ };
80
89
  return {
81
90
  style: cleanEmptyObject( updatedStyle ),
82
91
  fontFamily: fontFamilySlug,
83
92
  fontSize: fontSizeSlug,
93
+ textColor: textColorSlug,
84
94
  };
85
95
  }
86
96
 
@@ -96,6 +106,12 @@ function attributesToStyle( attributes ) {
96
106
  ? 'var:preset|font-size|' + attributes.fontSize
97
107
  : attributes.style?.typography?.fontSize,
98
108
  },
109
+ color: {
110
+ ...attributes.style?.color,
111
+ text: attributes.textColor
112
+ ? 'var:preset|color|' + attributes.textColor
113
+ : attributes.style?.color?.text,
114
+ },
99
115
  };
100
116
  }
101
117
 
@@ -122,11 +138,20 @@ function TypographyInspectorControl( { children, resetAllFilter } ) {
122
138
  );
123
139
  }
124
140
 
125
- export function TypographyPanel( { clientId, name, setAttributes, settings } ) {
141
+ export function TypographyPanel( {
142
+ clientId,
143
+ name,
144
+ setAttributes,
145
+ settings,
146
+ // Allows rendering outside the `typography` inspector group (e.g. section
147
+ // blocks direct-render this panel because their support fills are gated
148
+ // off by editing mode). Defaults to the slot-based wrapper.
149
+ asWrapper,
150
+ } ) {
126
151
  const selectedState = useBlockStyleState();
127
152
  const isEnabled = useHasTypographyPanel( settings );
128
153
 
129
- const { style, fontFamily, fontSize, fitText } = useSelect(
154
+ const { style, fontFamily, fontSize, fitText, textColor } = useSelect(
130
155
  ( select ) => {
131
156
  // Early return to avoid subscription when disabled.
132
157
  if ( ! isEnabled ) {
@@ -137,12 +162,14 @@ export function TypographyPanel( { clientId, name, setAttributes, settings } ) {
137
162
  fontFamily: _fontFamily,
138
163
  fontSize: _fontSize,
139
164
  fitText: _fitText,
165
+ textColor: _textColor,
140
166
  } = select( blockEditorStore ).getBlockAttributes( clientId ) || {};
141
167
  return {
142
168
  style: _style,
143
169
  fontFamily: _fontFamily,
144
170
  fontSize: _fontSize,
145
171
  fitText: _fitText,
172
+ textColor: _textColor,
146
173
  };
147
174
  },
148
175
  [ clientId, isEnabled ]
@@ -154,8 +181,15 @@ export function TypographyPanel( { clientId, name, setAttributes, settings } ) {
154
181
  if ( isStateSelected ) {
155
182
  return getStyleForState( style, selectedState );
156
183
  }
157
- return attributesToStyle( { style, fontFamily, fontSize } );
158
- }, [ isStateSelected, selectedState, style, fontSize, fontFamily ] );
184
+ return attributesToStyle( { style, fontFamily, fontSize, textColor } );
185
+ }, [
186
+ isStateSelected,
187
+ selectedState,
188
+ style,
189
+ fontSize,
190
+ fontFamily,
191
+ textColor,
192
+ ] );
159
193
 
160
194
  const onChange = isStateSelected
161
195
  ? ( newStyle ) => {
@@ -177,23 +211,53 @@ export function TypographyPanel( { clientId, name, setAttributes, settings } ) {
177
211
  setAttributes( newAttributes );
178
212
  };
179
213
 
214
+ // Link color failures are reported by the Elements panel, which owns the
215
+ // link color selection.
216
+ const enableContrastChecking =
217
+ ! isStateSelected &&
218
+ ! value?.color?.gradient &&
219
+ !! value?.color?.text &&
220
+ settings?.color?.text &&
221
+ false !== getBlockSupport( name, [ 'color', 'enableContrastChecker' ] );
222
+
223
+ const contrastWarning = useBlockColorContrastWarning( {
224
+ clientId,
225
+ name,
226
+ enabled: !! enableContrastChecking,
227
+ checkLinkColor: false,
228
+ messageOverride: __(
229
+ 'This color has poor contrast against the background. Consider increasing contrast.'
230
+ ),
231
+ } );
232
+
180
233
  if ( ! isEnabled ) {
181
234
  return null;
182
235
  }
183
236
 
184
- const defaultControls = getBlockSupport( name, [
237
+ const typographyDefaultControls = getBlockSupport( name, [
185
238
  TYPOGRAPHY_SUPPORT_KEY,
186
239
  '__experimentalDefaultControls',
187
240
  ] );
241
+ const colorDefaultControls = getBlockSupport( name, [
242
+ 'color',
243
+ '__experimentalDefaultControls',
244
+ ] );
245
+ const defaultControls = {
246
+ ...typographyDefaultControls,
247
+ textColor: colorDefaultControls?.text,
248
+ };
249
+
250
+ const Wrapper = asWrapper || TypographyInspectorControl;
188
251
 
189
252
  return (
190
253
  <StylesTypographyPanel
191
- as={ TypographyInspectorControl }
254
+ as={ Wrapper }
192
255
  panelId={ clientId }
193
256
  settings={ settings }
194
257
  value={ value }
195
258
  onChange={ onChange }
196
259
  defaultControls={ defaultControls }
260
+ contrastWarning={ contrastWarning }
197
261
  />
198
262
  );
199
263
  }
@@ -1,13 +1,18 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { __ } from '@wordpress/i18n';
4
+ import { __, _x } from '@wordpress/i18n';
5
5
  import {
6
6
  justifyLeft,
7
7
  justifyCenter,
8
8
  justifyRight,
9
9
  justifySpaceBetween,
10
10
  justifyStretch,
11
+ justifyTop,
12
+ justifyCenterVertical,
13
+ justifyBottom,
14
+ justifyStretchVertical,
15
+ justifySpaceBetweenVertical,
11
16
  arrowRight,
12
17
  arrowDown,
13
18
  } from '@wordpress/icons';
@@ -62,6 +67,29 @@ const defaultAlignments = {
62
67
  vertical: 'top',
63
68
  };
64
69
 
70
+ const verticalAlignmentOptions = {
71
+ top: {
72
+ icon: justifyTop,
73
+ label: _x( 'Align top', 'Block vertical alignment setting' ),
74
+ },
75
+ center: {
76
+ icon: justifyCenterVertical,
77
+ label: _x( 'Align middle', 'Block vertical alignment setting' ),
78
+ },
79
+ bottom: {
80
+ icon: justifyBottom,
81
+ label: _x( 'Align bottom', 'Block vertical alignment setting' ),
82
+ },
83
+ stretch: {
84
+ icon: justifyStretchVertical,
85
+ label: _x( 'Stretch to fill', 'Block vertical alignment setting' ),
86
+ },
87
+ 'space-between': {
88
+ icon: justifySpaceBetweenVertical,
89
+ label: _x( 'Space between', 'Block vertical alignment setting' ),
90
+ },
91
+ };
92
+
65
93
  const flexWrapOptions = [ 'wrap', 'nowrap' ];
66
94
 
67
95
  export default {
@@ -77,6 +105,7 @@ export default {
77
105
  const {
78
106
  allowOrientation = true,
79
107
  allowJustification = true,
108
+ allowVerticalAlignment = true,
80
109
  allowWrap = true,
81
110
  } = layoutBlockSupport;
82
111
  const hasLayoutValue = ( key, defaultValue ) =>
@@ -84,6 +113,11 @@ export default {
84
113
  ( resetLayout?.[ key ] ?? defaultValue );
85
114
  const hasJustificationValue = () =>
86
115
  hasLayoutValue( 'justifyContent', 'left' );
116
+ const hasVerticalAlignmentValue = () =>
117
+ hasLayoutValue(
118
+ 'verticalAlignment',
119
+ getDefaultVerticalAlignment( layout )
120
+ );
87
121
  const hasOrientationValue = () =>
88
122
  hasLayoutValue( 'orientation', 'horizontal' );
89
123
  const hasWrapValue = () => hasLayoutValue( 'flexWrap', 'wrap' );
@@ -94,6 +128,16 @@ export default {
94
128
  justifyContent: resetLayout?.justifyContent,
95
129
  } )
96
130
  );
131
+ const resetVerticalAlignment = () =>
132
+ onChange(
133
+ cleanEmptyObject( {
134
+ ...layout,
135
+ verticalAlignment: getCompatibleVerticalAlignment(
136
+ resetLayout?.verticalAlignment,
137
+ layout?.orientation
138
+ ),
139
+ } )
140
+ );
97
141
  const resetOrientation = () => {
98
142
  const { verticalAlignment, justifyContent } = layout;
99
143
  const nextOrientation = resetLayout?.orientation;
@@ -163,6 +207,19 @@ export default {
163
207
  ) }
164
208
  </Flex>
165
209
  ) }
210
+ { allowVerticalAlignment && (
211
+ <ToolsPanelItem
212
+ label={ __( 'Alignment' ) }
213
+ hasValue={ hasVerticalAlignmentValue }
214
+ onDeselect={ resetVerticalAlignment }
215
+ panelId={ clientId }
216
+ >
217
+ <FlexLayoutVerticalAlignmentControl
218
+ layout={ layout }
219
+ onChange={ onChange }
220
+ />
221
+ </ToolsPanelItem>
222
+ ) }
166
223
  { allowWrap && (
167
224
  <ToolsPanelItem
168
225
  label={ __( 'Wrapping' ) }
@@ -204,6 +261,7 @@ export default {
204
261
  <FlexLayoutVerticalAlignmentControl
205
262
  layout={ layout }
206
263
  onChange={ onChange }
264
+ isToolbar
207
265
  />
208
266
  ) }
209
267
  </BlockControls>
@@ -325,15 +383,39 @@ export default {
325
383
  },
326
384
  };
327
385
 
328
- function FlexLayoutVerticalAlignmentControl( { layout, onChange } ) {
329
- const { orientation = 'horizontal' } = layout;
386
+ function getDefaultVerticalAlignment( { orientation = 'horizontal' } = {} ) {
387
+ return orientation === 'horizontal'
388
+ ? defaultAlignments.horizontal
389
+ : defaultAlignments.vertical;
390
+ }
330
391
 
331
- const defaultVerticalAlignment =
332
- orientation === 'horizontal'
333
- ? defaultAlignments.horizontal
334
- : defaultAlignments.vertical;
392
+ function getCompatibleVerticalAlignment( verticalAlignment, orientation ) {
393
+ if (
394
+ ( orientation === 'horizontal' &&
395
+ verticalAlignment === 'space-between' ) ||
396
+ ( orientation === 'vertical' && verticalAlignment === 'stretch' )
397
+ ) {
398
+ return undefined;
399
+ }
335
400
 
336
- const { verticalAlignment = defaultVerticalAlignment } = layout;
401
+ return verticalAlignment;
402
+ }
403
+
404
+ function getVerticalAlignmentControls( orientation ) {
405
+ return orientation === 'horizontal'
406
+ ? [ 'top', 'center', 'bottom', 'stretch' ]
407
+ : [ 'top', 'center', 'bottom', 'space-between' ];
408
+ }
409
+
410
+ function FlexLayoutVerticalAlignmentControl( {
411
+ layout,
412
+ onChange,
413
+ isToolbar = false,
414
+ } ) {
415
+ const { orientation = 'horizontal' } = layout;
416
+
417
+ const { verticalAlignment = getDefaultVerticalAlignment( layout ) } =
418
+ layout;
337
419
 
338
420
  const onVerticalAlignmentChange = ( value ) => {
339
421
  onChange( {
@@ -341,17 +423,38 @@ function FlexLayoutVerticalAlignmentControl( { layout, onChange } ) {
341
423
  verticalAlignment: value,
342
424
  } );
343
425
  };
426
+ const controls = getVerticalAlignmentControls( orientation );
427
+
428
+ if ( isToolbar ) {
429
+ return (
430
+ <BlockVerticalAlignmentControl
431
+ onChange={ onVerticalAlignmentChange }
432
+ value={ verticalAlignment }
433
+ controls={ controls }
434
+ />
435
+ );
436
+ }
344
437
 
345
438
  return (
346
- <BlockVerticalAlignmentControl
439
+ <ToggleGroupControl
440
+ __next40pxDefaultSize
441
+ label={ __( 'Alignment' ) }
347
442
  onChange={ onVerticalAlignmentChange }
348
443
  value={ verticalAlignment }
349
- controls={
350
- orientation === 'horizontal'
351
- ? [ 'top', 'center', 'bottom', 'stretch' ]
352
- : [ 'top', 'center', 'bottom', 'space-between' ]
353
- }
354
- />
444
+ className="block-editor-hooks__flex-layout-alignment-controls"
445
+ >
446
+ { controls.map( ( control ) => {
447
+ const { icon, label } = verticalAlignmentOptions[ control ];
448
+ return (
449
+ <ToggleGroupControlOptionIcon
450
+ key={ control }
451
+ value={ control }
452
+ icon={ icon }
453
+ label={ label }
454
+ />
455
+ );
456
+ } ) }
457
+ </ToggleGroupControl>
355
458
  );
356
459
  }
357
460
 
@@ -52,7 +52,6 @@ import {
52
52
  mediaEditKey,
53
53
  getMediaSelectKey,
54
54
  deviceTypeKey,
55
- onViewportStateChangeKey,
56
55
  isIsolatedEditorKey,
57
56
  isNavigationOverlayContextKey,
58
57
  isNavigationPostEditorKey,
@@ -141,7 +140,6 @@ lock( privateApis, {
141
140
  mediaEditKey,
142
141
  getMediaSelectKey,
143
142
  deviceTypeKey,
144
- onViewportStateChangeKey,
145
143
  isIsolatedEditorKey,
146
144
  isNavigationOverlayContextKey,
147
145
  isNavigationPostEditorKey,
@@ -558,3 +558,34 @@ export function setSelectedBlockStyleStateCanvasPreview( clientId, value ) {
558
558
  value,
559
559
  };
560
560
  }
561
+
562
+ /**
563
+ * Sets the globally selected viewport style state. When set to a value other
564
+ * than 'default', block style edits in the inspector apply to that viewport.
565
+ * Driven by the editor's device preview while Responsive editing is enabled.
566
+ *
567
+ * @param {string} viewport The selected viewport state (e.g. 'default', 'tablet', 'mobile').
568
+ *
569
+ * @return {Object} Action object.
570
+ */
571
+ export function setStyleStateViewport( viewport ) {
572
+ return {
573
+ type: 'SET_STYLE_STATE_VIEWPORT',
574
+ viewport,
575
+ };
576
+ }
577
+
578
+ /**
579
+ * Sets whether Responsive editing is enabled. When enabled, the device preview
580
+ * also drives which viewport block style edits are applied to. Session-only.
581
+ *
582
+ * @param {boolean} enabled Whether Responsive editing is enabled.
583
+ *
584
+ * @return {Object} Action object.
585
+ */
586
+ export function setResponsiveEditing( enabled ) {
587
+ return {
588
+ type: 'SET_RESPONSIVE_EDITING',
589
+ enabled,
590
+ };
591
+ }
@@ -10,7 +10,6 @@ export const mediaEditKey = Symbol( 'mediaEditKey' );
10
10
  export const getMediaSelectKey = Symbol( 'getMediaSelect' );
11
11
  export const isIsolatedEditorKey = Symbol( 'isIsolatedEditor' );
12
12
  export const deviceTypeKey = Symbol( 'deviceTypeKey' );
13
- export const onViewportStateChangeKey = Symbol( 'onViewportStateChangeKey' );
14
13
  export const isNavigationOverlayContextKey = Symbol(
15
14
  'isNavigationOverlayContext'
16
15
  );
@@ -1152,6 +1152,30 @@ const DEFAULT_BLOCK_STYLE_STATE = {
1152
1152
  pseudo: 'default',
1153
1153
  };
1154
1154
 
1155
+ /**
1156
+ * Returns the globally selected viewport style state. When set to a value other
1157
+ * than 'default', block style edits in the inspector apply to that viewport.
1158
+ *
1159
+ * @param {Object} state Global application state.
1160
+ *
1161
+ * @return {string} The selected viewport style state.
1162
+ */
1163
+ export function getStyleStateViewport( state ) {
1164
+ return state.styleStateViewport ?? DEFAULT_BLOCK_STYLE_STATE.viewport;
1165
+ }
1166
+
1167
+ /**
1168
+ * Returns whether Responsive editing is enabled. When enabled, the device
1169
+ * preview also drives which viewport block style edits are applied to.
1170
+ *
1171
+ * @param {Object} state Global application state.
1172
+ *
1173
+ * @return {boolean} Whether Responsive editing is enabled.
1174
+ */
1175
+ export function isResponsiveEditing( state ) {
1176
+ return state.isResponsiveEditing;
1177
+ }
1178
+
1155
1179
  /**
1156
1180
  * Returns the selected style state for a block's style controls.
1157
1181
  *
@@ -1160,13 +1184,25 @@ const DEFAULT_BLOCK_STYLE_STATE = {
1160
1184
  *
1161
1185
  * @return {Object} The selected block style state.
1162
1186
  */
1163
- export function getSelectedBlockStyleState( state, clientId ) {
1164
- if ( state.selectedBlockStyleState?.clientId !== clientId ) {
1165
- return DEFAULT_BLOCK_STYLE_STATE;
1166
- }
1167
-
1168
- return state.selectedBlockStyleState.value ?? DEFAULT_BLOCK_STYLE_STATE;
1169
- }
1187
+ export const getSelectedBlockStyleState = createSelector(
1188
+ ( state, clientId ) => {
1189
+ const perBlockState =
1190
+ state.selectedBlockStyleState?.clientId === clientId
1191
+ ? state.selectedBlockStyleState.value ??
1192
+ DEFAULT_BLOCK_STYLE_STATE
1193
+ : DEFAULT_BLOCK_STYLE_STATE;
1194
+
1195
+ return {
1196
+ ...perBlockState,
1197
+ // The viewport is tracked globally, so inject it here. This way
1198
+ // consumers receive a single combined state object instead of
1199
+ // merging the global viewport themselves, and selectors derived
1200
+ // from this stay consistent.
1201
+ viewport: getStyleStateViewport( state ),
1202
+ };
1203
+ },
1204
+ ( state ) => [ state.styleStateViewport, state.selectedBlockStyleState ]
1205
+ );
1170
1206
 
1171
1207
  /**
1172
1208
  * Returns whether a non-default style state is selected for a block.
@@ -2312,7 +2312,6 @@ export function selectedBlockStyleState( state = undefined, action ) {
2312
2312
  clientId: action.clientId,
2313
2313
  showStateOnCanvas,
2314
2314
  value: {
2315
- viewport: 'default',
2316
2315
  pseudo: 'default',
2317
2316
  ...previousValue,
2318
2317
  ...action.value,
@@ -2332,7 +2331,6 @@ export function selectedBlockStyleState( state = undefined, action ) {
2332
2331
  clientId: action.clientId,
2333
2332
  showStateOnCanvas: action.value,
2334
2333
  value: {
2335
- viewport: 'default',
2336
2334
  pseudo: 'default',
2337
2335
  ...previousValue,
2338
2336
  },
@@ -2390,6 +2388,41 @@ export function selectedBlockStyleState( state = undefined, action ) {
2390
2388
  return state;
2391
2389
  }
2392
2390
 
2391
+ /**
2392
+ * Reducer holding the globally selected viewport style state. When set to a
2393
+ * value other than 'default', block style edits in the inspector are applied to
2394
+ * that viewport. Driven by the editor's device preview (Responsive editing).
2395
+ *
2396
+ * @param {string} state Current state.
2397
+ * @param {Object} action Dispatched action.
2398
+ *
2399
+ * @return {string} Updated state.
2400
+ */
2401
+ export function styleStateViewport( state = 'default', action ) {
2402
+ if ( action.type === 'SET_STYLE_STATE_VIEWPORT' ) {
2403
+ return action.viewport ?? 'default';
2404
+ }
2405
+
2406
+ return state;
2407
+ }
2408
+
2409
+ /**
2410
+ * Reducer for whether Responsive editing is enabled. When enabled, the device
2411
+ * preview also drives which viewport block style edits are applied to.
2412
+ *
2413
+ * @param {boolean} state Current state.
2414
+ * @param {Object} action Dispatched action.
2415
+ *
2416
+ * @return {boolean} Updated state.
2417
+ */
2418
+ export function isResponsiveEditing( state = false, action ) {
2419
+ if ( action.type === 'SET_RESPONSIVE_EDITING' ) {
2420
+ return action.enabled;
2421
+ }
2422
+
2423
+ return state;
2424
+ }
2425
+
2393
2426
  const combinedReducers = combineReducers( {
2394
2427
  blocks,
2395
2428
  isDragging,
@@ -2426,6 +2459,8 @@ const combinedReducers = combineReducers( {
2426
2459
  listViewContentPanelOpen,
2427
2460
  requestedInspectorTab,
2428
2461
  selectedBlockStyleState,
2462
+ styleStateViewport,
2463
+ isResponsiveEditing,
2429
2464
  } );
2430
2465
 
2431
2466
  /**
@@ -223,21 +223,22 @@ describe( 'private selectors', () => {
223
223
  } );
224
224
  } );
225
225
 
226
- it( 'returns the selected state for the block', () => {
226
+ it( 'returns the per-block pseudo with the global viewport', () => {
227
227
  const state = {
228
+ styleStateViewport: '@mobile',
228
229
  selectedBlockStyleState: {
229
230
  clientId: 'client-1',
230
- value: { viewport: 'mobile', pseudo: ':hover' },
231
+ value: { pseudo: ':hover' },
231
232
  },
232
233
  };
233
234
 
234
235
  expect( getSelectedBlockStyleState( state, 'client-1' ) ).toEqual( {
235
- viewport: 'mobile',
236
+ viewport: '@mobile',
236
237
  pseudo: ':hover',
237
238
  } );
238
239
  } );
239
240
 
240
- it( 'returns default when the selected state has no value', () => {
241
+ it( 'returns default pseudo when the selected state has no value', () => {
241
242
  const state = {
242
243
  selectedBlockStyleState: {
243
244
  clientId: 'client-1',
@@ -250,16 +251,17 @@ describe( 'private selectors', () => {
250
251
  } );
251
252
  } );
252
253
 
253
- it( 'returns default when another block has the selected state', () => {
254
+ it( 'returns the global viewport even when another block holds the per-block state', () => {
254
255
  const state = {
256
+ styleStateViewport: '@mobile',
255
257
  selectedBlockStyleState: {
256
258
  clientId: 'client-2',
257
- value: { viewport: 'default', pseudo: ':hover' },
259
+ value: { pseudo: ':hover' },
258
260
  },
259
261
  };
260
262
 
261
263
  expect( getSelectedBlockStyleState( state, 'client-1' ) ).toEqual( {
262
- viewport: 'default',
264
+ viewport: '@mobile',
263
265
  pseudo: 'default',
264
266
  } );
265
267
  } );
@@ -283,11 +285,12 @@ describe( 'private selectors', () => {
283
285
  expect( hasSelectedStyleState( state, 'client-1' ) ).toBe( false );
284
286
  } );
285
287
 
286
- it( 'returns true when a viewport state is selected', () => {
288
+ it( 'returns true when a global viewport state is selected', () => {
287
289
  const state = {
290
+ styleStateViewport: '@mobile',
288
291
  selectedBlockStyleState: {
289
292
  clientId: 'client-1',
290
- value: { viewport: 'mobile', pseudo: 'default' },
293
+ value: { pseudo: 'default' },
291
294
  },
292
295
  };
293
296
 
@@ -305,11 +308,12 @@ describe( 'private selectors', () => {
305
308
  expect( hasSelectedStyleState( state, 'client-1' ) ).toBe( true );
306
309
  } );
307
310
 
308
- it( 'returns true when viewport and pseudo states are selected', () => {
311
+ it( 'returns true when global viewport and per-block pseudo states are selected', () => {
309
312
  const state = {
313
+ styleStateViewport: '@mobile',
310
314
  selectedBlockStyleState: {
311
315
  clientId: 'client-1',
312
- value: { viewport: 'mobile', pseudo: ':hover' },
316
+ value: { pseudo: ':hover' },
313
317
  },
314
318
  };
315
319
 
@@ -1661,6 +1665,7 @@ describe( 'private selectors', () => {
1661
1665
  blockName = 'core/group',
1662
1666
  patternName,
1663
1667
  disableContentOnlyForUnsyncedPatterns,
1668
+ disableContentOnlyForTemplateParts,
1664
1669
  templateLock,
1665
1670
  rootTemplateLock,
1666
1671
  } = {} ) => {
@@ -1685,10 +1690,14 @@ describe( 'private selectors', () => {
1685
1690
  : {},
1686
1691
  ],
1687
1692
  ] ),
1688
- settings:
1689
- disableContentOnlyForUnsyncedPatterns !== undefined
1693
+ settings: {
1694
+ ...( disableContentOnlyForUnsyncedPatterns !== undefined
1690
1695
  ? { disableContentOnlyForUnsyncedPatterns }
1691
- : {},
1696
+ : {} ),
1697
+ ...( disableContentOnlyForTemplateParts !== undefined
1698
+ ? { disableContentOnlyForTemplateParts }
1699
+ : {} ),
1700
+ },
1692
1701
  editedContentOnlySection: undefined,
1693
1702
  };
1694
1703
  };
@@ -1732,6 +1741,22 @@ describe( 'private selectors', () => {
1732
1741
  expect( isSectionBlock( state, 'block-1' ) ).toBe( true );
1733
1742
  } );
1734
1743
 
1744
+ it( 'should return false for template parts when disableContentOnlyForTemplateParts is true', () => {
1745
+ const state = createState( {
1746
+ blockName: 'core/template-part',
1747
+ disableContentOnlyForTemplateParts: true,
1748
+ } );
1749
+ expect( isSectionBlock( state, 'block-1' ) ).toBe( false );
1750
+ } );
1751
+
1752
+ it( 'should return true for template parts when disableContentOnlyForTemplateParts is false', () => {
1753
+ const state = createState( {
1754
+ blockName: 'core/template-part',
1755
+ disableContentOnlyForTemplateParts: false,
1756
+ } );
1757
+ expect( isSectionBlock( state, 'block-1' ) ).toBe( true );
1758
+ } );
1759
+
1735
1760
  it( 'returns false when nested inside another section block', () => {
1736
1761
  const state = {
1737
1762
  blocks: {