@wordpress/block-editor 8.4.0 → 8.5.2

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 (421) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +56 -19
  3. package/build/components/alignment-control/index.js +13 -6
  4. package/build/components/alignment-control/index.js.map +1 -1
  5. package/build/components/block-alignment-control/index.js +13 -6
  6. package/build/components/block-alignment-control/index.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.js +1 -1
  8. package/build/components/block-alignment-control/ui.js.map +1 -1
  9. package/build/components/block-content-overlay/index.js +13 -4
  10. package/build/components/block-content-overlay/index.js.map +1 -1
  11. package/build/components/block-draggable/index.js +2 -3
  12. package/build/components/block-draggable/index.js.map +1 -1
  13. package/build/components/block-icon/index.js +4 -0
  14. package/build/components/block-icon/index.js.map +1 -1
  15. package/build/components/block-inspector/index.js +6 -1
  16. package/build/components/block-inspector/index.js.map +1 -1
  17. package/build/components/block-list/use-block-props/index.js +1 -6
  18. package/build/components/block-list/use-block-props/index.js.map +1 -1
  19. package/build/components/block-list/use-block-props/use-focus-first-element.js +14 -17
  20. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  21. package/build/components/block-list/use-block-props/use-focus-handler.js +7 -1
  22. package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  23. package/build/components/block-list-appender/index.js +6 -1
  24. package/build/components/block-list-appender/index.js.map +1 -1
  25. package/build/components/block-lock/index.js +8 -0
  26. package/build/components/block-lock/index.js.map +1 -1
  27. package/build/components/block-lock/menu-item.js +9 -15
  28. package/build/components/block-lock/menu-item.js.map +1 -1
  29. package/build/components/block-lock/modal.js +35 -23
  30. package/build/components/block-lock/modal.js.map +1 -1
  31. package/build/components/block-lock/toolbar.js +11 -16
  32. package/build/components/block-lock/toolbar.js.map +1 -1
  33. package/build/components/block-lock/use-block-lock.js +50 -0
  34. package/build/components/block-lock/use-block-lock.js.map +1 -0
  35. package/build/components/block-mover/index.js +4 -0
  36. package/build/components/block-mover/index.js.map +1 -1
  37. package/build/components/block-pattern-setup/index.js +37 -22
  38. package/build/components/block-pattern-setup/index.js.map +1 -1
  39. package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
  40. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  41. package/build/components/block-preview/auto.js +6 -3
  42. package/build/components/block-preview/auto.js.map +1 -1
  43. package/build/components/block-preview/index.js +4 -2
  44. package/build/components/block-preview/index.js.map +1 -1
  45. package/build/components/block-settings-menu/block-settings-dropdown.js +50 -5
  46. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  47. package/build/components/block-switcher/index.js +8 -3
  48. package/build/components/block-switcher/index.js.map +1 -1
  49. package/build/components/block-title/index.js +2 -2
  50. package/build/components/block-title/index.js.map +1 -1
  51. package/build/components/block-title/use-block-display-title.js +1 -1
  52. package/build/components/block-title/use-block-display-title.js.map +1 -1
  53. package/build/components/block-toolbar/block-name-context.js +17 -0
  54. package/build/components/block-toolbar/block-name-context.js.map +1 -0
  55. package/build/components/block-toolbar/block-toolbar-last-item.js +20 -0
  56. package/build/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  57. package/build/components/block-toolbar/index.js +20 -5
  58. package/build/components/block-toolbar/index.js.map +1 -1
  59. package/build/components/block-tools/index.js +0 -16
  60. package/build/components/block-tools/index.js.map +1 -1
  61. package/build/components/block-variation-transforms/index.js +92 -47
  62. package/build/components/block-variation-transforms/index.js.map +1 -1
  63. package/build/components/block-vertical-alignment-control/index.js +13 -6
  64. package/build/components/block-vertical-alignment-control/index.js.map +1 -1
  65. package/build/components/contrast-checker/index.js +4 -0
  66. package/build/components/contrast-checker/index.js.map +1 -1
  67. package/build/components/convert-to-group-buttons/index.js +8 -0
  68. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  69. package/build/components/convert-to-group-buttons/toolbar.js +105 -0
  70. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -0
  71. package/build/components/copy-handler/index.js +48 -9
  72. package/build/components/copy-handler/index.js.map +1 -1
  73. package/build/components/font-sizes/font-size-picker.js +4 -0
  74. package/build/components/font-sizes/font-size-picker.js.map +1 -1
  75. package/build/components/iframe/index.js +6 -9
  76. package/build/components/iframe/index.js.map +1 -1
  77. package/build/components/index.js +18 -0
  78. package/build/components/index.js.map +1 -1
  79. package/build/components/justify-content-control/index.js +13 -6
  80. package/build/components/justify-content-control/index.js.map +1 -1
  81. package/build/components/keyboard-shortcuts/index.js +1 -1
  82. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  83. package/build/components/line-height-control/index.js +10 -3
  84. package/build/components/line-height-control/index.js.map +1 -1
  85. package/build/components/link-control/index.js +6 -7
  86. package/build/components/link-control/index.js.map +1 -1
  87. package/build/components/list-view/block-select-button.js +19 -6
  88. package/build/components/list-view/block-select-button.js.map +1 -1
  89. package/build/components/list-view/block.js +18 -3
  90. package/build/components/list-view/block.js.map +1 -1
  91. package/build/components/list-view/branch.js +1 -1
  92. package/build/components/list-view/branch.js.map +1 -1
  93. package/build/components/media-replace-flow/index.js +4 -0
  94. package/build/components/media-replace-flow/index.js.map +1 -1
  95. package/build/components/multi-selection-inspector/index.js +1 -1
  96. package/build/components/multi-selection-inspector/index.js.map +1 -1
  97. package/build/components/rich-text/index.js +26 -4
  98. package/build/components/rich-text/index.js.map +1 -1
  99. package/build/components/rich-text/split-value.js +12 -2
  100. package/build/components/rich-text/split-value.js.map +1 -1
  101. package/build/components/rich-text/use-firefox-compat.js +49 -0
  102. package/build/components/rich-text/use-firefox-compat.js.map +1 -0
  103. package/build/components/rich-text/use-input-rules.js +34 -2
  104. package/build/components/rich-text/use-input-rules.js.map +1 -1
  105. package/build/components/skip-to-selected-block/index.js +4 -0
  106. package/build/components/skip-to-selected-block/index.js.map +1 -1
  107. package/build/components/writing-flow/index.js +9 -1
  108. package/build/components/writing-flow/index.js.map +1 -1
  109. package/build/components/writing-flow/use-arrow-nav.js +3 -44
  110. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  111. package/build/components/writing-flow/use-click-selection.js +68 -0
  112. package/build/components/writing-flow/use-click-selection.js.map +1 -0
  113. package/build/components/writing-flow/use-drag-selection.js +134 -0
  114. package/build/components/writing-flow/use-drag-selection.js.map +1 -0
  115. package/build/components/writing-flow/use-input.js +116 -0
  116. package/build/components/writing-flow/use-input.js.map +1 -0
  117. package/build/components/writing-flow/use-multi-selection.js +18 -38
  118. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  119. package/build/components/writing-flow/use-selection-observer.js +161 -0
  120. package/build/components/writing-flow/use-selection-observer.js.map +1 -0
  121. package/build/components/writing-flow/use-tab-nav.js +1 -8
  122. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  123. package/build/hooks/border-color.js +3 -3
  124. package/build/hooks/border-color.js.map +1 -1
  125. package/build/hooks/border.js +0 -14
  126. package/build/hooks/border.js.map +1 -1
  127. package/build/hooks/color.js +20 -17
  128. package/build/hooks/color.js.map +1 -1
  129. package/build/hooks/font-family.js +5 -1
  130. package/build/hooks/font-family.js.map +1 -1
  131. package/build/hooks/font-size.js +4 -2
  132. package/build/hooks/font-size.js.map +1 -1
  133. package/build/hooks/gap.js +23 -16
  134. package/build/hooks/gap.js.map +1 -1
  135. package/build/hooks/layout.js +7 -2
  136. package/build/hooks/layout.js.map +1 -1
  137. package/build/hooks/style.js +34 -3
  138. package/build/hooks/style.js.map +1 -1
  139. package/build/hooks/utils.js +29 -0
  140. package/build/hooks/utils.js.map +1 -1
  141. package/build/layouts/flex.js +76 -12
  142. package/build/layouts/flex.js.map +1 -1
  143. package/build/layouts/flow.js +9 -4
  144. package/build/layouts/flow.js.map +1 -1
  145. package/build/store/actions.js +290 -51
  146. package/build/store/actions.js.map +1 -1
  147. package/build/store/defaults.js +5 -2
  148. package/build/store/defaults.js.map +1 -1
  149. package/build/store/reducer.js +25 -13
  150. package/build/store/reducer.js.map +1 -1
  151. package/build/store/selectors.js +264 -21
  152. package/build/store/selectors.js.map +1 -1
  153. package/build/store/utils.js +27 -0
  154. package/build/store/utils.js.map +1 -0
  155. package/build/utils/dom.js +2 -1
  156. package/build/utils/dom.js.map +1 -1
  157. package/build-module/components/alignment-control/index.js +12 -4
  158. package/build-module/components/alignment-control/index.js.map +1 -1
  159. package/build-module/components/block-alignment-control/index.js +12 -4
  160. package/build-module/components/block-alignment-control/index.js.map +1 -1
  161. package/build-module/components/block-alignment-control/ui.js +2 -2
  162. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  163. package/build-module/components/block-content-overlay/index.js +13 -4
  164. package/build-module/components/block-content-overlay/index.js.map +1 -1
  165. package/build-module/components/block-draggable/index.js +2 -3
  166. package/build-module/components/block-draggable/index.js.map +1 -1
  167. package/build-module/components/block-icon/index.js +4 -0
  168. package/build-module/components/block-icon/index.js.map +1 -1
  169. package/build-module/components/block-inspector/index.js +6 -1
  170. package/build-module/components/block-inspector/index.js.map +1 -1
  171. package/build-module/components/block-list/use-block-props/index.js +1 -4
  172. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  173. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +15 -17
  174. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  175. package/build-module/components/block-list/use-block-props/use-focus-handler.js +7 -1
  176. package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  177. package/build-module/components/block-list-appender/index.js +6 -1
  178. package/build-module/components/block-list-appender/index.js.map +1 -1
  179. package/build-module/components/block-lock/index.js +1 -0
  180. package/build-module/components/block-lock/index.js.map +1 -1
  181. package/build-module/components/block-lock/menu-item.js +8 -13
  182. package/build-module/components/block-lock/menu-item.js.map +1 -1
  183. package/build-module/components/block-lock/modal.js +34 -24
  184. package/build-module/components/block-lock/modal.js.map +1 -1
  185. package/build-module/components/block-lock/toolbar.js +10 -14
  186. package/build-module/components/block-lock/toolbar.js.map +1 -1
  187. package/build-module/components/block-lock/use-block-lock.js +41 -0
  188. package/build-module/components/block-lock/use-block-lock.js.map +1 -0
  189. package/build-module/components/block-mover/index.js +4 -0
  190. package/build-module/components/block-mover/index.js.map +1 -1
  191. package/build-module/components/block-pattern-setup/index.js +39 -24
  192. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  193. package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
  194. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  195. package/build-module/components/block-preview/auto.js +6 -3
  196. package/build-module/components/block-preview/auto.js.map +1 -1
  197. package/build-module/components/block-preview/index.js +4 -2
  198. package/build-module/components/block-preview/index.js.map +1 -1
  199. package/build-module/components/block-settings-menu/block-settings-dropdown.js +50 -7
  200. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  201. package/build-module/components/block-switcher/index.js +9 -4
  202. package/build-module/components/block-switcher/index.js.map +1 -1
  203. package/build-module/components/block-title/index.js +2 -2
  204. package/build-module/components/block-title/index.js.map +1 -1
  205. package/build-module/components/block-title/use-block-display-title.js +1 -1
  206. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  207. package/build-module/components/block-toolbar/block-name-context.js +9 -0
  208. package/build-module/components/block-toolbar/block-name-context.js.map +1 -0
  209. package/build-module/components/block-toolbar/block-toolbar-last-item.js +11 -0
  210. package/build-module/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  211. package/build-module/components/block-toolbar/index.js +16 -4
  212. package/build-module/components/block-toolbar/index.js.map +1 -1
  213. package/build-module/components/block-tools/index.js +0 -16
  214. package/build-module/components/block-tools/index.js.map +1 -1
  215. package/build-module/components/block-variation-transforms/index.js +95 -49
  216. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  217. package/build-module/components/block-vertical-alignment-control/index.js +12 -4
  218. package/build-module/components/block-vertical-alignment-control/index.js.map +1 -1
  219. package/build-module/components/contrast-checker/index.js +4 -0
  220. package/build-module/components/contrast-checker/index.js.map +1 -1
  221. package/build-module/components/convert-to-group-buttons/index.js +2 -1
  222. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  223. package/build-module/components/convert-to-group-buttons/toolbar.js +90 -0
  224. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -0
  225. package/build-module/components/copy-handler/index.js +48 -9
  226. package/build-module/components/copy-handler/index.js.map +1 -1
  227. package/build-module/components/font-sizes/font-size-picker.js +4 -0
  228. package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
  229. package/build-module/components/iframe/index.js +6 -9
  230. package/build-module/components/iframe/index.js.map +1 -1
  231. package/build-module/components/index.js +2 -0
  232. package/build-module/components/index.js.map +1 -1
  233. package/build-module/components/justify-content-control/index.js +12 -4
  234. package/build-module/components/justify-content-control/index.js.map +1 -1
  235. package/build-module/components/keyboard-shortcuts/index.js +1 -1
  236. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  237. package/build-module/components/line-height-control/index.js +9 -2
  238. package/build-module/components/line-height-control/index.js.map +1 -1
  239. package/build-module/components/link-control/index.js +6 -7
  240. package/build-module/components/link-control/index.js.map +1 -1
  241. package/build-module/components/list-view/block-select-button.js +17 -6
  242. package/build-module/components/list-view/block-select-button.js.map +1 -1
  243. package/build-module/components/list-view/block.js +18 -3
  244. package/build-module/components/list-view/block.js.map +1 -1
  245. package/build-module/components/list-view/branch.js +1 -1
  246. package/build-module/components/list-view/branch.js.map +1 -1
  247. package/build-module/components/media-replace-flow/index.js +4 -0
  248. package/build-module/components/media-replace-flow/index.js.map +1 -1
  249. package/build-module/components/multi-selection-inspector/index.js +2 -2
  250. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  251. package/build-module/components/rich-text/index.js +25 -4
  252. package/build-module/components/rich-text/index.js.map +1 -1
  253. package/build-module/components/rich-text/split-value.js +12 -2
  254. package/build-module/components/rich-text/split-value.js.map +1 -1
  255. package/build-module/components/rich-text/use-firefox-compat.js +39 -0
  256. package/build-module/components/rich-text/use-firefox-compat.js.map +1 -0
  257. package/build-module/components/rich-text/use-input-rules.js +35 -4
  258. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  259. package/build-module/components/skip-to-selected-block/index.js +4 -0
  260. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  261. package/build-module/components/writing-flow/index.js +5 -1
  262. package/build-module/components/writing-flow/index.js.map +1 -1
  263. package/build-module/components/writing-flow/use-arrow-nav.js +4 -45
  264. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  265. package/build-module/components/writing-flow/use-click-selection.js +57 -0
  266. package/build-module/components/writing-flow/use-click-selection.js.map +1 -0
  267. package/build-module/components/writing-flow/use-drag-selection.js +124 -0
  268. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -0
  269. package/build-module/components/writing-flow/use-input.js +104 -0
  270. package/build-module/components/writing-flow/use-input.js.map +1 -0
  271. package/build-module/components/writing-flow/use-multi-selection.js +18 -37
  272. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  273. package/build-module/components/writing-flow/use-selection-observer.js +150 -0
  274. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -0
  275. package/build-module/components/writing-flow/use-tab-nav.js +1 -9
  276. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  277. package/build-module/hooks/border-color.js +5 -5
  278. package/build-module/hooks/border-color.js.map +1 -1
  279. package/build-module/hooks/border.js +0 -12
  280. package/build-module/hooks/border.js.map +1 -1
  281. package/build-module/hooks/color.js +19 -18
  282. package/build-module/hooks/color.js.map +1 -1
  283. package/build-module/hooks/font-family.js +3 -1
  284. package/build-module/hooks/font-family.js.map +1 -1
  285. package/build-module/hooks/font-size.js +4 -3
  286. package/build-module/hooks/font-size.js.map +1 -1
  287. package/build-module/hooks/gap.js +22 -15
  288. package/build-module/hooks/gap.js.map +1 -1
  289. package/build-module/hooks/layout.js +7 -2
  290. package/build-module/hooks/layout.js.map +1 -1
  291. package/build-module/hooks/style.js +33 -3
  292. package/build-module/hooks/style.js.map +1 -1
  293. package/build-module/hooks/utils.js +26 -0
  294. package/build-module/hooks/utils.js.map +1 -1
  295. package/build-module/layouts/flex.js +76 -13
  296. package/build-module/layouts/flex.js.map +1 -1
  297. package/build-module/layouts/flow.js +9 -5
  298. package/build-module/layouts/flow.js.map +1 -1
  299. package/build-module/store/actions.js +277 -49
  300. package/build-module/store/actions.js.map +1 -1
  301. package/build-module/store/defaults.js +5 -2
  302. package/build-module/store/defaults.js.map +1 -1
  303. package/build-module/store/reducer.js +25 -13
  304. package/build-module/store/reducer.js.map +1 -1
  305. package/build-module/store/selectors.js +250 -21
  306. package/build-module/store/selectors.js.map +1 -1
  307. package/build-module/store/utils.js +20 -0
  308. package/build-module/store/utils.js.map +1 -0
  309. package/build-module/utils/dom.js +2 -1
  310. package/build-module/utils/dom.js.map +1 -1
  311. package/build-style/style-rtl.css +142 -101
  312. package/build-style/style.css +142 -101
  313. package/build-types/utils/dom.d.ts.map +1 -1
  314. package/package.json +28 -28
  315. package/src/components/alignment-control/index.js +9 -4
  316. package/src/components/block-alignment-control/index.js +9 -4
  317. package/src/components/block-alignment-control/ui.js +2 -2
  318. package/src/components/block-content-overlay/index.js +19 -2
  319. package/src/components/block-draggable/index.js +2 -5
  320. package/src/components/block-icon/index.js +3 -0
  321. package/src/components/block-inspector/index.js +4 -0
  322. package/src/components/block-list/style.scss +4 -5
  323. package/src/components/block-list/use-block-props/index.js +0 -5
  324. package/src/components/block-list/use-block-props/use-focus-first-element.js +19 -26
  325. package/src/components/block-list/use-block-props/use-focus-handler.js +8 -0
  326. package/src/components/block-list-appender/index.js +5 -0
  327. package/src/components/block-lock/index.js +1 -0
  328. package/src/components/block-lock/menu-item.js +6 -19
  329. package/src/components/block-lock/modal.js +52 -23
  330. package/src/components/block-lock/style.scss +7 -5
  331. package/src/components/block-lock/toolbar.js +7 -14
  332. package/src/components/block-lock/use-block-lock.js +45 -0
  333. package/src/components/block-mover/index.js +3 -0
  334. package/src/components/block-mover/style.scss +4 -0
  335. package/src/components/block-pattern-setup/index.js +84 -59
  336. package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
  337. package/src/components/block-pattern-setup/style.scss +32 -26
  338. package/src/components/block-preview/auto.js +10 -1
  339. package/src/components/block-preview/index.js +2 -0
  340. package/src/components/block-settings-menu/block-settings-dropdown.js +62 -4
  341. package/src/components/block-switcher/index.js +15 -3
  342. package/src/components/block-switcher/style.scss +15 -4
  343. package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
  344. package/src/components/block-switcher/test/index.js +2 -2
  345. package/src/components/block-title/index.js +2 -2
  346. package/src/components/block-title/use-block-display-title.js +1 -1
  347. package/src/components/block-toolbar/block-name-context.js +8 -0
  348. package/src/components/block-toolbar/block-toolbar-last-item.js +12 -0
  349. package/src/components/block-toolbar/index.js +18 -2
  350. package/src/components/block-toolbar/style.scss +6 -0
  351. package/src/components/block-tools/index.js +0 -19
  352. package/src/components/block-tools/style.scss +3 -5
  353. package/src/components/block-variation-transforms/index.js +105 -36
  354. package/src/components/block-variation-transforms/style.scss +1 -1
  355. package/src/components/block-vertical-alignment-control/index.js +9 -4
  356. package/src/components/button-block-appender/style.scss +5 -1
  357. package/src/components/contrast-checker/index.js +3 -0
  358. package/src/components/convert-to-group-buttons/index.js +6 -1
  359. package/src/components/convert-to-group-buttons/toolbar.js +87 -0
  360. package/src/components/copy-handler/index.js +55 -10
  361. package/src/components/font-sizes/font-size-picker.js +3 -0
  362. package/src/components/iframe/index.js +5 -7
  363. package/src/components/index.js +2 -0
  364. package/src/components/justify-content-control/index.js +9 -4
  365. package/src/components/keyboard-shortcuts/index.js +1 -1
  366. package/src/components/line-height-control/index.js +8 -3
  367. package/src/components/link-control/index.js +5 -5
  368. package/src/components/list-view/block-select-button.js +13 -3
  369. package/src/components/list-view/block.js +24 -8
  370. package/src/components/list-view/branch.js +1 -1
  371. package/src/components/list-view/style.scss +56 -14
  372. package/src/components/media-placeholder/README.md +8 -0
  373. package/src/components/media-replace-flow/index.js +3 -0
  374. package/src/components/multi-selection-inspector/index.js +2 -2
  375. package/src/components/rich-text/index.js +24 -1
  376. package/src/components/rich-text/split-value.js +5 -1
  377. package/src/components/rich-text/use-firefox-compat.js +39 -0
  378. package/src/components/rich-text/use-input-rules.js +40 -3
  379. package/src/components/skip-to-selected-block/index.js +3 -0
  380. package/src/components/url-input/style.scss +3 -2
  381. package/src/components/writing-flow/index.js +8 -0
  382. package/src/components/writing-flow/readme.md +28 -0
  383. package/src/components/writing-flow/use-arrow-nav.js +4 -53
  384. package/src/components/writing-flow/use-click-selection.js +65 -0
  385. package/src/components/writing-flow/use-drag-selection.js +126 -0
  386. package/src/components/writing-flow/use-input.js +112 -0
  387. package/src/components/writing-flow/use-multi-selection.js +13 -36
  388. package/src/components/writing-flow/use-selection-observer.js +153 -0
  389. package/src/components/writing-flow/use-tab-nav.js +1 -11
  390. package/src/hooks/border-color.js +5 -5
  391. package/src/hooks/border.js +0 -13
  392. package/src/hooks/color.js +51 -24
  393. package/src/hooks/font-family.js +5 -2
  394. package/src/hooks/font-size.js +10 -7
  395. package/src/hooks/gap.js +25 -17
  396. package/src/hooks/layout.js +11 -1
  397. package/src/hooks/style.js +40 -4
  398. package/src/hooks/test/gap.js +25 -1
  399. package/src/hooks/test/style.js +94 -0
  400. package/src/hooks/test/utils.js +1 -1
  401. package/src/hooks/utils.js +26 -0
  402. package/src/layouts/flex.js +89 -5
  403. package/src/layouts/flow.js +15 -4
  404. package/src/store/actions.js +341 -32
  405. package/src/store/defaults.js +7 -2
  406. package/src/store/reducer.js +25 -10
  407. package/src/store/selectors.js +329 -26
  408. package/src/store/test/selectors.js +242 -5
  409. package/src/store/utils.js +19 -0
  410. package/src/utils/dom.js +2 -1
  411. package/tsconfig.tsbuildinfo +1 -1
  412. package/build/components/block-list/use-block-props/use-multi-selection.js +0 -205
  413. package/build/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  414. package/build/components/block-list/use-block-props/use-scroll-into-view.js +0 -77
  415. package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  416. package/build-module/components/block-list/use-block-props/use-multi-selection.js +0 -192
  417. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  418. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +0 -63
  419. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  420. package/src/components/block-list/use-block-props/use-multi-selection.js +0 -227
  421. package/src/components/block-list/use-block-props/use-scroll-into-view.js +0 -73
@@ -23,11 +23,11 @@ import {
23
23
  } from '../components/colors';
24
24
  import useSetting from '../components/use-setting';
25
25
  import {
26
+ BORDER_SUPPORT_KEY,
26
27
  hasBorderSupport,
27
28
  removeBorderAttribute,
28
- shouldSkipSerialization,
29
29
  } from './border';
30
- import { cleanEmptyObject } from './utils';
30
+ import { cleanEmptyObject, shouldSkipSerialization } from './utils';
31
31
 
32
32
  // Defining empty array here instead of inline avoids unnecessary re-renders of
33
33
  // color control.
@@ -200,7 +200,7 @@ function addAttributes( settings ) {
200
200
  function addSaveProps( props, blockType, attributes ) {
201
201
  if (
202
202
  ! hasBorderSupport( blockType, 'color' ) ||
203
- shouldSkipSerialization( blockType )
203
+ shouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )
204
204
  ) {
205
205
  return props;
206
206
  }
@@ -231,7 +231,7 @@ function addSaveProps( props, blockType, attributes ) {
231
231
  function addEditProps( settings ) {
232
232
  if (
233
233
  ! hasBorderSupport( settings, 'color' ) ||
234
- shouldSkipSerialization( settings )
234
+ shouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )
235
235
  ) {
236
236
  return settings;
237
237
  }
@@ -266,7 +266,7 @@ export const withBorderColorPaletteStyles = createHigherOrderComponent(
266
266
 
267
267
  if (
268
268
  ! hasBorderSupport( name, 'color' ) ||
269
- shouldSkipSerialization( name )
269
+ shouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )
270
270
  ) {
271
271
  return <BlockListBlock { ...props } />;
272
272
  }
@@ -171,19 +171,6 @@ export function hasBorderSupport( blockName, feature = 'any' ) {
171
171
  return !! support?.[ feature ];
172
172
  }
173
173
 
174
- /**
175
- * Check whether serialization of border classes and styles should be skipped.
176
- *
177
- * @param {string|Object} blockType Block name or block type object.
178
- *
179
- * @return {boolean} Whether serialization of border properties should occur.
180
- */
181
- export function shouldSkipSerialization( blockType ) {
182
- const support = getBlockSupport( blockType, BORDER_SUPPORT_KEY );
183
-
184
- return support?.__experimentalSkipSerialization;
185
- }
186
-
187
174
  /**
188
175
  * Returns a new style object where the specified border attribute has been
189
176
  * removed.
@@ -26,7 +26,12 @@ import {
26
26
  getGradientValueBySlug,
27
27
  getGradientSlugByValue,
28
28
  } from '../components/gradients';
29
- import { cleanEmptyObject, transformStyles, immutableSet } from './utils';
29
+ import {
30
+ cleanEmptyObject,
31
+ transformStyles,
32
+ immutableSet,
33
+ shouldSkipSerialization,
34
+ } from './utils';
30
35
  import ColorPanel from './color-panel';
31
36
  import useSetting from '../components/use-setting';
32
37
 
@@ -43,12 +48,6 @@ const hasColorSupport = ( blockType ) => {
43
48
  );
44
49
  };
45
50
 
46
- const shouldSkipSerialization = ( blockType ) => {
47
- const colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );
48
-
49
- return colorSupport?.__experimentalSkipSerialization;
50
- };
51
-
52
51
  const hasLinkColorSupport = ( blockType ) => {
53
52
  if ( Platform.OS !== 'web' ) {
54
53
  return false;
@@ -248,7 +247,7 @@ function addAttributes( settings ) {
248
247
  export function addSaveProps( props, blockType, attributes ) {
249
248
  if (
250
249
  ! hasColorSupport( blockType ) ||
251
- shouldSkipSerialization( blockType )
250
+ shouldSkipSerialization( blockType, COLOR_SUPPORT_KEY )
252
251
  ) {
253
252
  return props;
254
253
  }
@@ -258,12 +257,31 @@ export function addSaveProps( props, blockType, attributes ) {
258
257
  // I'd have preferred to avoid the "style" attribute usage here
259
258
  const { backgroundColor, textColor, gradient, style } = attributes;
260
259
 
261
- const backgroundClass = getColorClassName(
262
- 'background-color',
263
- backgroundColor
264
- );
265
- const gradientClass = __experimentalGetGradientClass( gradient );
266
- const textClass = getColorClassName( 'color', textColor );
260
+ const shouldSerialize = ( feature ) =>
261
+ ! shouldSkipSerialization( blockType, COLOR_SUPPORT_KEY, feature );
262
+
263
+ // Primary color classes must come before the `has-text-color`,
264
+ // `has-background` and `has-link-color` classes to maintain backwards
265
+ // compatibility and avoid block invalidations.
266
+ const textClass = shouldSerialize( 'text' )
267
+ ? getColorClassName( 'color', textColor )
268
+ : undefined;
269
+
270
+ const gradientClass = shouldSerialize( 'gradients' )
271
+ ? __experimentalGetGradientClass( gradient )
272
+ : undefined;
273
+
274
+ const backgroundClass = shouldSerialize( 'background' )
275
+ ? getColorClassName( 'background-color', backgroundColor )
276
+ : undefined;
277
+
278
+ const serializeHasBackground =
279
+ shouldSerialize( 'background' ) || shouldSerialize( 'gradients' );
280
+ const hasBackground =
281
+ backgroundColor ||
282
+ style?.color?.background ||
283
+ ( hasGradient && ( gradient || style?.color?.gradient ) );
284
+
267
285
  const newClassName = classnames(
268
286
  props.className,
269
287
  textClass,
@@ -273,12 +291,12 @@ export function addSaveProps( props, blockType, attributes ) {
273
291
  [ backgroundClass ]:
274
292
  ( ! hasGradient || ! style?.color?.gradient ) &&
275
293
  !! backgroundClass,
276
- 'has-text-color': textColor || style?.color?.text,
277
- 'has-background':
278
- backgroundColor ||
279
- style?.color?.background ||
280
- ( hasGradient && ( gradient || style?.color?.gradient ) ),
281
- 'has-link-color': style?.elements?.link?.color,
294
+ 'has-text-color':
295
+ shouldSerialize( 'text' ) &&
296
+ ( textColor || style?.color?.text ),
297
+ 'has-background': serializeHasBackground && hasBackground,
298
+ 'has-link-color':
299
+ shouldSerialize( 'link' ) && style?.elements?.link?.color,
282
300
  }
283
301
  );
284
302
  props.className = newClassName ? newClassName : undefined;
@@ -297,7 +315,7 @@ export function addSaveProps( props, blockType, attributes ) {
297
315
  export function addEditProps( settings ) {
298
316
  if (
299
317
  ! hasColorSupport( settings ) ||
300
- shouldSkipSerialization( settings )
318
+ shouldSkipSerialization( settings, COLOR_SUPPORT_KEY )
301
319
  ) {
302
320
  return settings;
303
321
  }
@@ -589,18 +607,27 @@ export const withColorPaletteStyles = createHigherOrderComponent(
589
607
  ],
590
608
  [ userPalette, themePalette, defaultPalette ]
591
609
  );
592
- if ( ! hasColorSupport( name ) || shouldSkipSerialization( name ) ) {
610
+ if (
611
+ ! hasColorSupport( name ) ||
612
+ shouldSkipSerialization( name, COLOR_SUPPORT_KEY )
613
+ ) {
593
614
  return <BlockListBlock { ...props } />;
594
615
  }
595
616
  const extraStyles = {};
596
617
 
597
- if ( textColor ) {
618
+ if (
619
+ textColor &&
620
+ ! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'text' )
621
+ ) {
598
622
  extraStyles.color = getColorObjectByAttributeValues(
599
623
  colors,
600
624
  textColor
601
625
  )?.color;
602
626
  }
603
- if ( backgroundColor ) {
627
+ if (
628
+ backgroundColor &&
629
+ ! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'background' )
630
+ ) {
604
631
  extraStyles.backgroundColor = getColorObjectByAttributeValues(
605
632
  colors,
606
633
  backgroundColor
@@ -15,6 +15,8 @@ import TokenList from '@wordpress/token-list';
15
15
  */
16
16
  import useSetting from '../components/use-setting';
17
17
  import FontFamilyControl from '../components/font-family';
18
+ import { shouldSkipSerialization } from './utils';
19
+ import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
18
20
 
19
21
  export const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';
20
22
 
@@ -56,9 +58,10 @@ function addSaveProps( props, blockType, attributes ) {
56
58
  }
57
59
 
58
60
  if (
59
- hasBlockSupport(
61
+ shouldSkipSerialization(
60
62
  blockType,
61
- 'typography.__experimentalSkipSerialization'
63
+ TYPOGRAPHY_SUPPORT_KEY,
64
+ 'fontFamily'
62
65
  )
63
66
  ) {
64
67
  return props;
@@ -15,7 +15,12 @@ import {
15
15
  getFontSizeObjectByValue,
16
16
  FontSizePicker,
17
17
  } from '../components/font-sizes';
18
- import { cleanEmptyObject, transformStyles } from './utils';
18
+ import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
19
+ import {
20
+ cleanEmptyObject,
21
+ transformStyles,
22
+ shouldSkipSerialization,
23
+ } from './utils';
19
24
  import useSetting from '../components/use-setting';
20
25
 
21
26
  export const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';
@@ -60,10 +65,7 @@ function addSaveProps( props, blockType, attributes ) {
60
65
  }
61
66
 
62
67
  if (
63
- hasBlockSupport(
64
- blockType,
65
- 'typography.__experimentalSkipSerialization'
66
- )
68
+ shouldSkipSerialization( blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontSize' )
67
69
  ) {
68
70
  return props;
69
71
  }
@@ -223,9 +225,10 @@ const withFontSizeInlineStyles = createHigherOrderComponent(
223
225
  // and does have a class to extract the font size from.
224
226
  if (
225
227
  ! hasBlockSupport( blockName, FONT_SIZE_SUPPORT_KEY ) ||
226
- hasBlockSupport(
228
+ shouldSkipSerialization(
227
229
  blockName,
228
- 'typography.__experimentalSkipSerialization'
230
+ TYPOGRAPHY_SUPPORT_KEY,
231
+ 'fontSize'
229
232
  ) ||
230
233
  ! fontSize ||
231
234
  style?.typography?.fontSize
package/src/hooks/gap.js CHANGED
@@ -40,34 +40,36 @@ export function hasGapValue( props ) {
40
40
  }
41
41
 
42
42
  /**
43
- * Returns a BoxControl object value from a given blockGap style.
43
+ * Returns a BoxControl object value from a given blockGap style value.
44
44
  * The string check is for backwards compatibility before Gutenberg supported
45
45
  * split gap values (row and column) and the value was a string n + unit.
46
46
  *
47
- * @param {string? | Object?} rawBlockGapValue A style object.
48
- * @return {Object?} A value to pass to the BoxControl component.
47
+ * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
48
+ * @return {Object|null} A value to pass to the BoxControl component.
49
49
  */
50
- export function getGapValueFromStyle( rawBlockGapValue ) {
51
- if ( ! rawBlockGapValue ) {
52
- return rawBlockGapValue;
50
+ export function getGapBoxControlValueFromStyle( blockGapValue ) {
51
+ if ( ! blockGapValue ) {
52
+ return null;
53
53
  }
54
54
 
55
- const isValueString = typeof rawBlockGapValue === 'string';
55
+ const isValueString = typeof blockGapValue === 'string';
56
56
  return {
57
- top: isValueString ? rawBlockGapValue : rawBlockGapValue?.top,
58
- left: isValueString ? rawBlockGapValue : rawBlockGapValue?.left,
57
+ top: isValueString ? blockGapValue : blockGapValue?.top,
58
+ left: isValueString ? blockGapValue : blockGapValue?.left,
59
59
  };
60
60
  }
61
61
 
62
62
  /**
63
63
  * Returns a CSS value for the `gap` property from a given blockGap style.
64
64
  *
65
- * @param {string? | Object?} blockGapValue A style object.
65
+ * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
66
66
  * @param {string?} defaultValue A default gap value.
67
67
  * @return {string|null} The concatenated gap value (row and column).
68
68
  */
69
69
  export function getGapCSSValue( blockGapValue, defaultValue = '0' ) {
70
- const blockGapBoxControlValue = getGapValueFromStyle( blockGapValue );
70
+ const blockGapBoxControlValue = getGapBoxControlValueFromStyle(
71
+ blockGapValue
72
+ );
71
73
  if ( ! blockGapBoxControlValue ) {
72
74
  return null;
73
75
  }
@@ -142,14 +144,22 @@ export function GapEdit( props ) {
142
144
  return null;
143
145
  }
144
146
 
147
+ const splitOnAxis =
148
+ sides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );
149
+
145
150
  const onChange = ( next ) => {
151
+ let blockGap = next;
152
+
153
+ // If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.
154
+ if ( !! next && splitOnAxis ) {
155
+ blockGap = { ...getGapBoxControlValueFromStyle( next ) };
156
+ }
157
+
146
158
  const newStyle = {
147
159
  ...style,
148
160
  spacing: {
149
161
  ...style?.spacing,
150
- blockGap: {
151
- ...getGapValueFromStyle( next ),
152
- },
162
+ blockGap,
153
163
  },
154
164
  };
155
165
 
@@ -171,9 +181,7 @@ export function GapEdit( props ) {
171
181
  }
172
182
  };
173
183
 
174
- const splitOnAxis =
175
- sides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );
176
- const gapValue = getGapValueFromStyle( style?.spacing?.blockGap );
184
+ const gapValue = getGapBoxControlValueFromStyle( style?.spacing?.blockGap );
177
185
 
178
186
  // The BoxControl component expects a full complement of side values.
179
187
  // Gap row and column values translate to top/bottom and left/right respectively.
@@ -56,6 +56,15 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
56
56
  return null;
57
57
  }
58
58
 
59
+ // Only show the inherit toggle if it's supported,
60
+ // a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),
61
+ // and that the default / flow layout type is in use, as this is the only one that supports inheritance.
62
+ const showInheritToggle = !! (
63
+ allowInheriting &&
64
+ !! defaultThemeLayout &&
65
+ ( ! layout?.type || layout?.type === 'default' || layout?.inherit )
66
+ );
67
+
59
68
  const usedLayout = layout || defaultBlockLayout || {};
60
69
  const { inherit = false, type = 'default' } = usedLayout;
61
70
  /**
@@ -77,7 +86,7 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
77
86
  <>
78
87
  <InspectorControls>
79
88
  <PanelBody title={ __( 'Layout' ) }>
80
- { allowInheriting && !! defaultThemeLayout && (
89
+ { showInheritToggle && (
81
90
  <ToggleControl
82
91
  label={ __( 'Inherit default layout' ) }
83
92
  checked={ !! inherit }
@@ -213,6 +222,7 @@ export const withLayoutStyles = createHigherOrderComponent(
213
222
  element &&
214
223
  createPortal(
215
224
  <LayoutStyle
225
+ blockName={ name }
216
226
  selector={ `.wp-container-${ id }` }
217
227
  layout={ usedLayout }
218
228
  style={ attributes?.style }
@@ -42,6 +42,7 @@ import {
42
42
  } from './typography';
43
43
  import { SPACING_SUPPORT_KEY, DimensionsPanel } from './dimensions';
44
44
  import useDisplayBlockControls from '../components/use-display-block-controls';
45
+ import { shouldSkipSerialization } from './utils';
45
46
 
46
47
  const styleSupportKeys = [
47
48
  ...TYPOGRAPHY_SUPPORT_KEYS,
@@ -200,6 +201,19 @@ const skipSerializationPathsSave = {
200
201
  [ `${ SPACING_SUPPORT_KEY }` ]: [ 'spacing.blockGap' ],
201
202
  };
202
203
 
204
+ /**
205
+ * A dictionary used to normalize feature names between support flags, style
206
+ * object properties and __experimentSkipSerialization configuration arrays.
207
+ *
208
+ * This allows not having to provide a migration for a support flag and possible
209
+ * backwards compatibility bridges, while still achieving consistency between
210
+ * the support flag and the skip serialization array.
211
+ *
212
+ * @constant
213
+ * @type {Record<string, string>}
214
+ */
215
+ const renamedFeatures = { gradients: 'gradient' };
216
+
203
217
  /**
204
218
  * Override props assigned to save component to inject the CSS variables definition.
205
219
  *
@@ -223,9 +237,18 @@ export function addSaveProps(
223
237
  let { style } = attributes;
224
238
 
225
239
  forEach( skipPaths, ( path, indicator ) => {
226
- if ( getBlockSupport( blockType, indicator ) ) {
240
+ const skipSerialization = getBlockSupport( blockType, indicator );
241
+
242
+ if ( skipSerialization === true ) {
227
243
  style = omit( style, path );
228
244
  }
245
+
246
+ if ( Array.isArray( skipSerialization ) ) {
247
+ skipSerialization.forEach( ( featureName ) => {
248
+ const feature = renamedFeatures[ featureName ] || featureName;
249
+ style = omit( style, [ [ ...path, feature ] ] );
250
+ } );
251
+ }
229
252
  } );
230
253
 
231
254
  props.style = {
@@ -304,14 +327,27 @@ export const withBlockControls = createHigherOrderComponent(
304
327
  */
305
328
  const withElementsStyles = createHigherOrderComponent(
306
329
  ( BlockListBlock ) => ( props ) => {
307
- const elements = props.attributes.style?.elements;
308
-
309
330
  const blockElementsContainerIdentifier = `wp-elements-${ useInstanceId(
310
331
  BlockListBlock
311
332
  ) }`;
333
+
334
+ const skipLinkColorSerialization = shouldSkipSerialization(
335
+ props.name,
336
+ COLOR_SUPPORT_KEY,
337
+ 'link'
338
+ );
339
+
340
+ // The Elements API only supports link colors for now,
341
+ // hence the specific omission of `link` in the elements styles.
342
+ // This might need to be refactored or removed if the Elements API
343
+ // changes or `link` supports styles beyond `color`.
344
+ const elements = skipLinkColorSerialization
345
+ ? omit( props.attributes.style?.elements, [ 'link' ] )
346
+ : props.attributes.style?.elements;
347
+
312
348
  const styles = compileElementsStyles(
313
349
  blockElementsContainerIdentifier,
314
- props.attributes.style?.elements
350
+ elements
315
351
  );
316
352
  const element = useContext( BlockList.__unstableElementContext );
317
353
 
@@ -1,9 +1,33 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import { getGapCSSValue } from '../gap';
4
+ import { getGapCSSValue, getGapBoxControlValueFromStyle } from '../gap';
5
5
 
6
6
  describe( 'gap', () => {
7
+ describe( 'getGapBoxControlValueFromStyle()', () => {
8
+ it( 'should return `null` if argument is falsey', () => {
9
+ expect( getGapBoxControlValueFromStyle( undefined ) ).toBeNull();
10
+ expect( getGapBoxControlValueFromStyle( '' ) ).toBeNull();
11
+ } );
12
+ it( 'should return box control value from string', () => {
13
+ const expectedValue = {
14
+ top: '88rem',
15
+ left: '88rem',
16
+ };
17
+ expect( getGapBoxControlValueFromStyle( '88rem' ) ).toEqual(
18
+ expectedValue
19
+ );
20
+ } );
21
+ it( 'should return box control value from object', () => {
22
+ const blockGapValue = {
23
+ top: '222em',
24
+ left: '22px',
25
+ };
26
+ expect( getGapBoxControlValueFromStyle( blockGapValue ) ).toEqual( {
27
+ ...blockGapValue,
28
+ } );
29
+ } );
30
+ } );
7
31
  describe( 'getGapCSSValue()', () => {
8
32
  it( 'should return `null` if argument is falsey', () => {
9
33
  expect( getGapCSSValue( undefined ) ).toBeNull();
@@ -1,3 +1,8 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { applyFilters } from '@wordpress/hooks';
5
+
1
6
  /**
2
7
  * Internal dependencies
3
8
  */
@@ -108,3 +113,92 @@ describe( 'getInlineStyles', () => {
108
113
  } );
109
114
  } );
110
115
  } );
116
+
117
+ describe( 'addSaveProps', () => {
118
+ const addSaveProps = applyFilters.bind(
119
+ null,
120
+ 'blocks.getSaveContent.extraProps'
121
+ );
122
+
123
+ const blockSettings = {
124
+ save: () => <div className="default" />,
125
+ category: 'text',
126
+ title: 'block title',
127
+ supports: {
128
+ spacing: { padding: true },
129
+ color: { gradients: true, text: true },
130
+ typography: {
131
+ fontSize: true,
132
+ __experimentalTextTransform: true,
133
+ __experimentalTextDecoration: true,
134
+ },
135
+ },
136
+ };
137
+
138
+ const applySkipSerialization = ( features ) => {
139
+ const updatedSettings = { ...blockSettings };
140
+ Object.keys( features ).forEach( ( key ) => {
141
+ updatedSettings.supports[ key ].__experimentalSkipSerialization =
142
+ features[ key ];
143
+ } );
144
+ return updatedSettings;
145
+ };
146
+
147
+ const attributes = {
148
+ style: {
149
+ color: {
150
+ text: '#d92828',
151
+ gradient:
152
+ 'linear-gradient(135deg,rgb(6,147,227) 0%,rgb(223,13,13) 46%,rgb(155,81,224) 100%)',
153
+ },
154
+ spacing: { padding: '10px' },
155
+ typography: {
156
+ fontSize: '1rem',
157
+ textDecoration: 'underline',
158
+ textTransform: 'uppercase',
159
+ },
160
+ },
161
+ };
162
+
163
+ it( 'should serialize all styles by default', () => {
164
+ const extraProps = addSaveProps( {}, blockSettings, attributes );
165
+
166
+ expect( extraProps.style ).toEqual( {
167
+ background:
168
+ 'linear-gradient(135deg,rgb(6,147,227) 0%,rgb(223,13,13) 46%,rgb(155,81,224) 100%)',
169
+ color: '#d92828',
170
+ padding: '10px',
171
+ fontSize: '1rem',
172
+ textDecoration: 'underline',
173
+ textTransform: 'uppercase',
174
+ } );
175
+ } );
176
+
177
+ it( 'should skip serialization of entire feature set if flag is true', () => {
178
+ const settings = applySkipSerialization( {
179
+ typography: true,
180
+ } );
181
+ const extraProps = addSaveProps( {}, settings, attributes );
182
+
183
+ expect( extraProps.style ).toEqual( {
184
+ background:
185
+ 'linear-gradient(135deg,rgb(6,147,227) 0%,rgb(223,13,13) 46%,rgb(155,81,224) 100%)',
186
+ color: '#d92828',
187
+ padding: '10px',
188
+ } );
189
+ } );
190
+
191
+ it( 'should skip serialization of individual features if flag is an array', () => {
192
+ const settings = applySkipSerialization( {
193
+ color: [ 'gradient' ],
194
+ typography: [ 'textDecoration', 'textTransform' ],
195
+ } );
196
+ const extraProps = addSaveProps( {}, settings, attributes );
197
+
198
+ expect( extraProps.style ).toEqual( {
199
+ color: '#d92828',
200
+ padding: '10px',
201
+ fontSize: '1rem',
202
+ } );
203
+ } );
204
+ } );
@@ -97,7 +97,7 @@ describe( 'anchor', () => {
97
97
  expect( extraProps.id ).toBe( 'foo' );
98
98
  } );
99
99
 
100
- it( 'should remove an anchor attribute ID when feild is cleared', () => {
100
+ it( 'should remove an anchor attribute ID when field is cleared', () => {
101
101
  const attributes = { anchor: '' };
102
102
  const extraProps = getSaveContentExtraProps(
103
103
  {},
@@ -14,6 +14,11 @@ import {
14
14
  every,
15
15
  } from 'lodash';
16
16
 
17
+ /**
18
+ * WordPress dependencies
19
+ */
20
+ import { getBlockSupport } from '@wordpress/blocks';
21
+
17
22
  /**
18
23
  * Removed falsy values from nested object.
19
24
  *
@@ -87,3 +92,24 @@ export function transformStyles(
87
92
  } );
88
93
  return returnBlock;
89
94
  }
95
+
96
+ /**
97
+ * Check whether serialization of specific block support feature or set should
98
+ * be skipped.
99
+ *
100
+ * @param {string|Object} blockType Block name or block type object.
101
+ * @param {string} featureSet Name of block support feature set.
102
+ * @param {string} feature Name of the individual feature to check.
103
+ *
104
+ * @return {boolean} Whether serialization should occur.
105
+ */
106
+ export function shouldSkipSerialization( blockType, featureSet, feature ) {
107
+ const support = getBlockSupport( blockType, featureSet );
108
+ const skipSerialization = support?.__experimentalSkipSerialization;
109
+
110
+ if ( Array.isArray( skipSerialization ) ) {
111
+ return skipSerialization.includes( feature );
112
+ }
113
+
114
+ return skipSerialization;
115
+ }