@wordpress/block-editor 12.11.1 → 12.12.2-next.f8d8eceb.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (453) hide show
  1. package/CHANGELOG.md +14 -10
  2. package/README.md +35 -3
  3. package/build/components/block-alignment-control/use-available-alignments.js +30 -28
  4. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  5. package/build/components/block-controls/hook.js +4 -1
  6. package/build/components/block-controls/hook.js.map +1 -1
  7. package/build/components/block-list/block-outline.native.js +1 -1
  8. package/build/components/block-list/block-outline.native.js.map +1 -1
  9. package/build/components/block-list/block.js +2 -0
  10. package/build/components/block-list/block.js.map +1 -1
  11. package/build/components/block-list/block.native.js +4 -4
  12. package/build/components/block-list/block.native.js.map +1 -1
  13. package/build/components/block-list/layout.js +2 -3
  14. package/build/components/block-list/layout.js.map +1 -1
  15. package/build/components/block-preview/index.js +4 -1
  16. package/build/components/block-preview/index.js.map +1 -1
  17. package/build/components/block-styles/index.js +1 -2
  18. package/build/components/block-styles/index.js.map +1 -1
  19. package/build/components/block-switcher/pattern-transformations-menu.js +2 -4
  20. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  21. package/build/components/block-tools/block-contextual-toolbar.js +1 -0
  22. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  23. package/build/components/border-radius-control/index.js +3 -2
  24. package/build/components/border-radius-control/index.js.map +1 -1
  25. package/build/components/color-palette/with-color-context.js +6 -6
  26. package/build/components/color-palette/with-color-context.js.map +1 -1
  27. package/build/components/colors/with-colors.js +2 -8
  28. package/build/components/colors/with-colors.js.map +1 -1
  29. package/build/components/colors-gradients/control.js +6 -7
  30. package/build/components/colors-gradients/control.js.map +1 -1
  31. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -13
  32. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  33. package/build/components/dimensions-tool/index.js +22 -22
  34. package/build/components/dimensions-tool/index.js.map +1 -1
  35. package/build/components/dimensions-tool/scale-tool.js +1 -1
  36. package/build/components/dimensions-tool/scale-tool.js.map +1 -1
  37. package/build/components/font-family/index.js +2 -3
  38. package/build/components/font-family/index.js.map +1 -1
  39. package/build/components/font-sizes/font-size-picker.js +3 -5
  40. package/build/components/font-sizes/font-size-picker.js.map +1 -1
  41. package/build/components/font-sizes/with-font-sizes.js +3 -4
  42. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  43. package/build/components/global-styles/filters-panel.js +7 -8
  44. package/build/components/global-styles/filters-panel.js.map +1 -1
  45. package/build/components/global-styles/image-settings-panel.js +2 -2
  46. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  47. package/build/components/global-styles/typography-panel.js +1 -1
  48. package/build/components/global-styles/typography-panel.js.map +1 -1
  49. package/build/components/gradients/use-gradient.js +2 -5
  50. package/build/components/gradients/use-gradient.js.map +1 -1
  51. package/build/components/height-control/index.js +93 -5
  52. package/build/components/height-control/index.js.map +1 -1
  53. package/build/components/iframe/index.js +9 -1
  54. package/build/components/iframe/index.js.map +1 -1
  55. package/build/components/image-editor/aspect-ratio-dropdown.js +0 -6
  56. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  57. package/build/components/index.js +9 -2
  58. package/build/components/index.js.map +1 -1
  59. package/build/components/index.native.js +17 -2
  60. package/build/components/index.native.js.map +1 -1
  61. package/build/components/inner-blocks/index.js +2 -2
  62. package/build/components/inner-blocks/index.js.map +1 -1
  63. package/build/components/letter-spacing-control/index.js +3 -3
  64. package/build/components/letter-spacing-control/index.js.map +1 -1
  65. package/build/components/link-control/link-preview.js +5 -2
  66. package/build/components/link-control/link-preview.js.map +1 -1
  67. package/build/components/link-control/search-item.js +11 -0
  68. package/build/components/link-control/search-item.js.map +1 -1
  69. package/build/components/link-control/search-results.js +2 -1
  70. package/build/components/link-control/search-results.js.map +1 -1
  71. package/build/components/link-control/use-internal-value.js +14 -8
  72. package/build/components/link-control/use-internal-value.js.map +1 -1
  73. package/build/components/link-control/use-search-handler.js +10 -5
  74. package/build/components/link-control/use-search-handler.js.map +1 -1
  75. package/build/components/list-view/index.js +6 -5
  76. package/build/components/list-view/index.js.map +1 -1
  77. package/build/components/media-replace-flow/index.js +2 -4
  78. package/build/components/media-replace-flow/index.js.map +1 -1
  79. package/build/components/provider/use-block-sync.js +2 -2
  80. package/build/components/provider/use-block-sync.js.map +1 -1
  81. package/build/components/rich-text/index.js +1 -1
  82. package/build/components/rich-text/index.js.map +1 -1
  83. package/build/components/rich-text/index.native.js +14 -3
  84. package/build/components/rich-text/index.native.js.map +1 -1
  85. package/build/components/rich-text/use-delete.js +1 -1
  86. package/build/components/rich-text/use-delete.js.map +1 -1
  87. package/build/components/rich-text/use-paste-handler.js +25 -22
  88. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  89. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -3
  90. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  91. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +91 -3
  92. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  93. package/build/components/tool-selector/index.js +1 -2
  94. package/build/components/tool-selector/index.js.map +1 -1
  95. package/build/components/unit-control/index.js +3 -3
  96. package/build/components/unit-control/index.js.map +1 -1
  97. package/build/components/use-block-commands/index.js +96 -47
  98. package/build/components/use-block-commands/index.js.map +1 -1
  99. package/build/components/use-settings/index.js +212 -0
  100. package/build/components/use-settings/index.js.map +1 -0
  101. package/build/components/writing-flow/use-arrow-nav.js +4 -0
  102. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  103. package/build/hooks/align.js +51 -35
  104. package/build/hooks/align.js.map +1 -1
  105. package/build/hooks/anchor.js +37 -32
  106. package/build/hooks/anchor.js.map +1 -1
  107. package/build/hooks/background.js +4 -4
  108. package/build/hooks/background.js.map +1 -1
  109. package/build/hooks/block-rename-ui.js +5 -5
  110. package/build/hooks/block-rename-ui.js.map +1 -1
  111. package/build/hooks/{metadata-name.js → block-renaming.js} +3 -7
  112. package/build/hooks/block-renaming.js.map +1 -0
  113. package/build/hooks/color.js +2 -4
  114. package/build/hooks/color.js.map +1 -1
  115. package/build/hooks/custom-class-name.js +28 -21
  116. package/build/hooks/custom-class-name.js.map +1 -1
  117. package/build/hooks/duotone.js +33 -8
  118. package/build/hooks/duotone.js.map +1 -1
  119. package/build/hooks/font-size.js +4 -4
  120. package/build/hooks/font-size.js.map +1 -1
  121. package/build/hooks/index.js +1 -1
  122. package/build/hooks/index.js.map +1 -1
  123. package/build/hooks/layout.js +16 -17
  124. package/build/hooks/layout.js.map +1 -1
  125. package/build/hooks/line-height.js +3 -3
  126. package/build/hooks/line-height.js.map +1 -1
  127. package/build/hooks/metadata.js +6 -27
  128. package/build/hooks/metadata.js.map +1 -1
  129. package/build/hooks/position.js +2 -3
  130. package/build/hooks/position.js.map +1 -1
  131. package/build/hooks/use-color-props.js +3 -11
  132. package/build/hooks/use-color-props.js.map +1 -1
  133. package/build/hooks/utils.js +2 -43
  134. package/build/hooks/utils.js.map +1 -1
  135. package/build/layouts/constrained.js +3 -3
  136. package/build/layouts/constrained.js.map +1 -1
  137. package/build/layouts/grid.js +25 -3
  138. package/build/layouts/grid.js.map +1 -1
  139. package/build/layouts/utils.js +1 -1
  140. package/build/layouts/utils.js.map +1 -1
  141. package/build/lock-unlock.js +1 -1
  142. package/build/lock-unlock.js.map +1 -1
  143. package/build/store/actions.js +13 -5
  144. package/build/store/actions.js.map +1 -1
  145. package/build/utils/object.js +4 -1
  146. package/build/utils/object.js.map +1 -1
  147. package/build/utils/parse-css-unit-to-px.js +20 -0
  148. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  149. package/build/utils/pasting.js +1 -1
  150. package/build/utils/pasting.js.map +1 -1
  151. package/build/utils/transform-styles/index.js +19 -24
  152. package/build/utils/transform-styles/index.js.map +1 -1
  153. package/build-module/components/block-alignment-control/use-available-alignments.js +30 -28
  154. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  155. package/build-module/components/block-controls/hook.js +4 -1
  156. package/build-module/components/block-controls/hook.js.map +1 -1
  157. package/build-module/components/block-list/block-outline.native.js +1 -1
  158. package/build-module/components/block-list/block-outline.native.js.map +1 -1
  159. package/build-module/components/block-list/block.js +2 -0
  160. package/build-module/components/block-list/block.js.map +1 -1
  161. package/build-module/components/block-list/block.native.js +4 -4
  162. package/build-module/components/block-list/block.native.js.map +1 -1
  163. package/build-module/components/block-list/layout.js +2 -2
  164. package/build-module/components/block-list/layout.js.map +1 -1
  165. package/build-module/components/block-preview/index.js +4 -1
  166. package/build-module/components/block-preview/index.js.map +1 -1
  167. package/build-module/components/block-styles/index.js +1 -2
  168. package/build-module/components/block-styles/index.js.map +1 -1
  169. package/build-module/components/block-switcher/pattern-transformations-menu.js +2 -4
  170. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  171. package/build-module/components/block-tools/block-contextual-toolbar.js +1 -0
  172. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  173. package/build-module/components/border-radius-control/index.js +3 -2
  174. package/build-module/components/border-radius-control/index.js.map +1 -1
  175. package/build-module/components/color-palette/with-color-context.js +6 -5
  176. package/build-module/components/color-palette/with-color-context.js.map +1 -1
  177. package/build-module/components/colors/with-colors.js +2 -7
  178. package/build-module/components/colors/with-colors.js.map +1 -1
  179. package/build-module/components/colors-gradients/control.js +6 -7
  180. package/build-module/components/colors-gradients/control.js.map +1 -1
  181. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -12
  182. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  183. package/build-module/components/dimensions-tool/index.js +22 -22
  184. package/build-module/components/dimensions-tool/index.js.map +1 -1
  185. package/build-module/components/dimensions-tool/scale-tool.js +1 -1
  186. package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
  187. package/build-module/components/font-family/index.js +2 -2
  188. package/build-module/components/font-family/index.js.map +1 -1
  189. package/build-module/components/font-sizes/font-size-picker.js +3 -4
  190. package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
  191. package/build-module/components/font-sizes/with-font-sizes.js +3 -3
  192. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  193. package/build-module/components/global-styles/filters-panel.js +7 -8
  194. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  195. package/build-module/components/global-styles/image-settings-panel.js +2 -2
  196. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  197. package/build-module/components/global-styles/typography-panel.js +1 -1
  198. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  199. package/build-module/components/gradients/use-gradient.js +2 -4
  200. package/build-module/components/gradients/use-gradient.js.map +1 -1
  201. package/build-module/components/height-control/index.js +93 -4
  202. package/build-module/components/height-control/index.js.map +1 -1
  203. package/build-module/components/iframe/index.js +9 -1
  204. package/build-module/components/iframe/index.js.map +1 -1
  205. package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -6
  206. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  207. package/build-module/components/index.js +1 -1
  208. package/build-module/components/index.js.map +1 -1
  209. package/build-module/components/index.native.js +2 -1
  210. package/build-module/components/index.native.js.map +1 -1
  211. package/build-module/components/inner-blocks/index.js +2 -2
  212. package/build-module/components/inner-blocks/index.js.map +1 -1
  213. package/build-module/components/letter-spacing-control/index.js +3 -2
  214. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  215. package/build-module/components/link-control/link-preview.js +6 -3
  216. package/build-module/components/link-control/link-preview.js.map +1 -1
  217. package/build-module/components/link-control/search-item.js +12 -1
  218. package/build-module/components/link-control/search-item.js.map +1 -1
  219. package/build-module/components/link-control/search-results.js +2 -1
  220. package/build-module/components/link-control/search-results.js.map +1 -1
  221. package/build-module/components/link-control/use-internal-value.js +14 -9
  222. package/build-module/components/link-control/use-internal-value.js.map +1 -1
  223. package/build-module/components/link-control/use-search-handler.js +10 -5
  224. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  225. package/build-module/components/list-view/index.js +7 -6
  226. package/build-module/components/list-view/index.js.map +1 -1
  227. package/build-module/components/media-replace-flow/index.js +3 -5
  228. package/build-module/components/media-replace-flow/index.js.map +1 -1
  229. package/build-module/components/provider/use-block-sync.js +2 -2
  230. package/build-module/components/provider/use-block-sync.js.map +1 -1
  231. package/build-module/components/rich-text/index.js +1 -1
  232. package/build-module/components/rich-text/index.js.map +1 -1
  233. package/build-module/components/rich-text/index.native.js +15 -4
  234. package/build-module/components/rich-text/index.native.js.map +1 -1
  235. package/build-module/components/rich-text/use-delete.js +1 -1
  236. package/build-module/components/rich-text/use-delete.js.map +1 -1
  237. package/build-module/components/rich-text/use-paste-handler.js +25 -22
  238. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  239. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -2
  240. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  241. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +91 -2
  242. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  243. package/build-module/components/tool-selector/index.js +1 -2
  244. package/build-module/components/tool-selector/index.js.map +1 -1
  245. package/build-module/components/unit-control/index.js +3 -2
  246. package/build-module/components/unit-control/index.js.map +1 -1
  247. package/build-module/components/use-block-commands/index.js +95 -47
  248. package/build-module/components/use-block-commands/index.js.map +1 -1
  249. package/build-module/components/use-settings/index.js +203 -0
  250. package/build-module/components/use-settings/index.js.map +1 -0
  251. package/build-module/components/writing-flow/use-arrow-nav.js +4 -0
  252. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  253. package/build-module/hooks/align.js +51 -35
  254. package/build-module/hooks/align.js.map +1 -1
  255. package/build-module/hooks/anchor.js +37 -32
  256. package/build-module/hooks/anchor.js.map +1 -1
  257. package/build-module/hooks/background.js +4 -4
  258. package/build-module/hooks/background.js.map +1 -1
  259. package/build-module/hooks/block-rename-ui.js +6 -6
  260. package/build-module/hooks/block-rename-ui.js.map +1 -1
  261. package/build-module/hooks/{metadata-name.js → block-renaming.js} +3 -6
  262. package/build-module/hooks/block-renaming.js.map +1 -0
  263. package/build-module/hooks/color.js +2 -4
  264. package/build-module/hooks/color.js.map +1 -1
  265. package/build-module/hooks/custom-class-name.js +28 -21
  266. package/build-module/hooks/custom-class-name.js.map +1 -1
  267. package/build-module/hooks/duotone.js +34 -9
  268. package/build-module/hooks/duotone.js.map +1 -1
  269. package/build-module/hooks/font-size.js +4 -4
  270. package/build-module/hooks/font-size.js.map +1 -1
  271. package/build-module/hooks/index.js +1 -1
  272. package/build-module/hooks/index.js.map +1 -1
  273. package/build-module/hooks/layout.js +16 -17
  274. package/build-module/hooks/layout.js.map +1 -1
  275. package/build-module/hooks/line-height.js +3 -3
  276. package/build-module/hooks/line-height.js.map +1 -1
  277. package/build-module/hooks/metadata.js +6 -25
  278. package/build-module/hooks/metadata.js.map +1 -1
  279. package/build-module/hooks/position.js +2 -3
  280. package/build-module/hooks/position.js.map +1 -1
  281. package/build-module/hooks/use-color-props.js +3 -11
  282. package/build-module/hooks/use-color-props.js.map +1 -1
  283. package/build-module/hooks/utils.js +3 -44
  284. package/build-module/hooks/utils.js.map +1 -1
  285. package/build-module/layouts/constrained.js +3 -2
  286. package/build-module/layouts/constrained.js.map +1 -1
  287. package/build-module/layouts/grid.js +25 -3
  288. package/build-module/layouts/grid.js.map +1 -1
  289. package/build-module/layouts/utils.js +1 -1
  290. package/build-module/layouts/utils.js.map +1 -1
  291. package/build-module/lock-unlock.js +1 -1
  292. package/build-module/lock-unlock.js.map +1 -1
  293. package/build-module/store/actions.js +14 -6
  294. package/build-module/store/actions.js.map +1 -1
  295. package/build-module/utils/object.js +3 -1
  296. package/build-module/utils/object.js.map +1 -1
  297. package/build-module/utils/parse-css-unit-to-px.js +20 -0
  298. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  299. package/build-module/utils/pasting.js +1 -1
  300. package/build-module/utils/pasting.js.map +1 -1
  301. package/build-module/utils/transform-styles/index.js +20 -24
  302. package/build-module/utils/transform-styles/index.js.map +1 -1
  303. package/build-style/style-rtl.css +24 -12
  304. package/build-style/style.css +24 -12
  305. package/package.json +36 -34
  306. package/src/components/block-alignment-control/use-available-alignments.js +49 -34
  307. package/src/components/block-controls/hook.js +6 -3
  308. package/src/components/block-list/block-outline.native.js +1 -1
  309. package/src/components/block-list/block.js +2 -0
  310. package/src/components/block-list/block.native.js +4 -4
  311. package/src/components/block-list/layout.js +2 -2
  312. package/src/components/block-preview/index.js +7 -1
  313. package/src/components/block-styles/index.js +1 -4
  314. package/src/components/block-styles/style.scss +1 -1
  315. package/src/components/block-switcher/pattern-transformations-menu.js +1 -4
  316. package/src/components/block-switcher/style.scss +6 -0
  317. package/src/components/block-tools/block-contextual-toolbar.js +1 -0
  318. package/src/components/block-tools/style.scss +0 -1
  319. package/src/components/border-radius-control/index.js +3 -2
  320. package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -1
  321. package/src/components/color-palette/with-color-context.js +9 -9
  322. package/src/components/colors/with-colors.js +6 -7
  323. package/src/components/colors-gradients/control.js +10 -7
  324. package/src/components/colors-gradients/style.scss +4 -2
  325. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +29 -15
  326. package/src/components/dimensions-tool/index.js +25 -25
  327. package/src/components/dimensions-tool/scale-tool.js +1 -1
  328. package/src/components/font-family/index.js +2 -2
  329. package/src/components/font-sizes/font-size-picker.js +6 -4
  330. package/src/components/font-sizes/with-font-sizes.js +3 -5
  331. package/src/components/global-styles/filters-panel.js +9 -15
  332. package/src/components/global-styles/image-settings-panel.js +2 -2
  333. package/src/components/global-styles/typography-panel.js +1 -1
  334. package/src/components/gradients/use-gradient.js +10 -4
  335. package/src/components/height-control/index.js +53 -4
  336. package/src/components/iframe/index.js +8 -1
  337. package/src/components/image-editor/aspect-ratio-dropdown.js +0 -8
  338. package/src/components/index.js +1 -1
  339. package/src/components/index.native.js +2 -1
  340. package/src/components/inner-blocks/index.js +2 -2
  341. package/src/components/inserter/style.scss +9 -1
  342. package/src/components/letter-spacing-control/index.js +3 -2
  343. package/src/components/link-control/README.md +43 -0
  344. package/src/components/link-control/link-preview.js +11 -5
  345. package/src/components/link-control/search-item.js +14 -0
  346. package/src/components/link-control/search-results.js +1 -0
  347. package/src/components/link-control/style.scss +3 -3
  348. package/src/components/link-control/test/index.js +19 -0
  349. package/src/components/link-control/use-internal-value.js +14 -10
  350. package/src/components/link-control/use-search-handler.js +22 -15
  351. package/src/components/list-view/index.js +13 -3
  352. package/src/components/media-replace-flow/index.js +9 -14
  353. package/src/components/provider/test/use-block-sync.js +1 -1
  354. package/src/components/provider/use-block-sync.js +2 -2
  355. package/src/components/rich-text/index.js +1 -1
  356. package/src/components/rich-text/index.native.js +19 -3
  357. package/src/components/rich-text/use-delete.js +1 -1
  358. package/src/components/rich-text/use-paste-handler.js +27 -24
  359. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +7 -5
  360. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +25 -2
  361. package/src/components/tool-selector/index.js +1 -1
  362. package/src/components/unit-control/index.js +3 -8
  363. package/src/components/use-block-commands/index.js +93 -47
  364. package/src/components/{use-setting → use-settings}/README.md +9 -10
  365. package/src/components/use-settings/index.js +272 -0
  366. package/src/components/{use-setting → use-settings}/test/index.js +47 -5
  367. package/src/components/writing-flow/use-arrow-nav.js +4 -0
  368. package/src/hooks/align.js +79 -54
  369. package/src/hooks/anchor.js +75 -65
  370. package/src/hooks/background.js +7 -9
  371. package/src/hooks/block-rename-ui.js +5 -14
  372. package/src/hooks/{metadata-name.js → block-renaming.js} +4 -7
  373. package/src/hooks/color.js +7 -4
  374. package/src/hooks/custom-class-name.js +36 -31
  375. package/src/hooks/duotone.js +51 -14
  376. package/src/hooks/font-size.js +4 -4
  377. package/src/hooks/index.js +1 -1
  378. package/src/hooks/layout.js +17 -17
  379. package/src/hooks/line-height.js +3 -3
  380. package/src/hooks/metadata.js +6 -38
  381. package/src/hooks/position.js +5 -3
  382. package/src/hooks/use-color-props.js +21 -14
  383. package/src/hooks/utils.js +90 -43
  384. package/src/layouts/constrained.js +3 -8
  385. package/src/layouts/grid.js +50 -2
  386. package/src/layouts/utils.js +2 -1
  387. package/src/lock-unlock.js +1 -1
  388. package/src/store/actions.js +25 -8
  389. package/src/utils/object.js +4 -1
  390. package/src/utils/parse-css-unit-to-px.js +20 -0
  391. package/src/utils/pasting.js +1 -4
  392. package/src/utils/test/__snapshots__/transform-styles.js.snap +103 -0
  393. package/src/utils/test/pasting.js +12 -19
  394. package/src/utils/test/transform-styles.js +217 -0
  395. package/src/utils/transform-styles/index.js +25 -25
  396. package/build/components/use-setting/index.js +0 -159
  397. package/build/components/use-setting/index.js.map +0 -1
  398. package/build/hooks/metadata-name.js.map +0 -1
  399. package/build/utils/transform-styles/ast/index.js +0 -21
  400. package/build/utils/transform-styles/ast/index.js.map +0 -1
  401. package/build/utils/transform-styles/ast/parse.js +0 -660
  402. package/build/utils/transform-styles/ast/parse.js.map +0 -1
  403. package/build/utils/transform-styles/ast/stringify/compiler.js +0 -52
  404. package/build/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
  405. package/build/utils/transform-styles/ast/stringify/compress.js +0 -178
  406. package/build/utils/transform-styles/ast/stringify/compress.js.map +0 -1
  407. package/build/utils/transform-styles/ast/stringify/identity.js +0 -207
  408. package/build/utils/transform-styles/ast/stringify/identity.js.map +0 -1
  409. package/build/utils/transform-styles/ast/stringify/index.js +0 -36
  410. package/build/utils/transform-styles/ast/stringify/index.js.map +0 -1
  411. package/build/utils/transform-styles/transforms/url-rewrite.js +0 -130
  412. package/build/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
  413. package/build/utils/transform-styles/transforms/wrap.js +0 -59
  414. package/build/utils/transform-styles/transforms/wrap.js.map +0 -1
  415. package/build/utils/transform-styles/traverse.js +0 -37
  416. package/build/utils/transform-styles/traverse.js.map +0 -1
  417. package/build-module/components/use-setting/index.js +0 -152
  418. package/build-module/components/use-setting/index.js.map +0 -1
  419. package/build-module/hooks/metadata-name.js.map +0 -1
  420. package/build-module/utils/transform-styles/ast/index.js +0 -6
  421. package/build-module/utils/transform-styles/ast/index.js.map +0 -1
  422. package/build-module/utils/transform-styles/ast/parse.js +0 -654
  423. package/build-module/utils/transform-styles/ast/parse.js.map +0 -1
  424. package/build-module/utils/transform-styles/ast/stringify/compiler.js +0 -49
  425. package/build-module/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
  426. package/build-module/utils/transform-styles/ast/stringify/compress.js +0 -176
  427. package/build-module/utils/transform-styles/ast/stringify/compress.js.map +0 -1
  428. package/build-module/utils/transform-styles/ast/stringify/identity.js +0 -206
  429. package/build-module/utils/transform-styles/ast/stringify/identity.js.map +0 -1
  430. package/build-module/utils/transform-styles/ast/stringify/index.js +0 -29
  431. package/build-module/utils/transform-styles/ast/stringify/index.js.map +0 -1
  432. package/build-module/utils/transform-styles/transforms/url-rewrite.js +0 -123
  433. package/build-module/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
  434. package/build-module/utils/transform-styles/transforms/wrap.js +0 -52
  435. package/build-module/utils/transform-styles/transforms/wrap.js.map +0 -1
  436. package/build-module/utils/transform-styles/traverse.js +0 -28
  437. package/build-module/utils/transform-styles/traverse.js.map +0 -1
  438. package/src/components/use-setting/index.js +0 -213
  439. package/src/utils/transform-styles/ast/index.js +0 -5
  440. package/src/utils/transform-styles/ast/parse.js +0 -732
  441. package/src/utils/transform-styles/ast/stringify/compiler.js +0 -50
  442. package/src/utils/transform-styles/ast/stringify/compress.js +0 -238
  443. package/src/utils/transform-styles/ast/stringify/identity.js +0 -286
  444. package/src/utils/transform-styles/ast/stringify/index.js +0 -32
  445. package/src/utils/transform-styles/test/__snapshots__/traverse.js.snap +0 -7
  446. package/src/utils/transform-styles/test/traverse.js +0 -24
  447. package/src/utils/transform-styles/transforms/test/__snapshots__/url-rewrite.js.snap +0 -25
  448. package/src/utils/transform-styles/transforms/test/__snapshots__/wrap.js.snap +0 -64
  449. package/src/utils/transform-styles/transforms/test/url-rewrite.js +0 -39
  450. package/src/utils/transform-styles/transforms/test/wrap.js +0 -95
  451. package/src/utils/transform-styles/transforms/url-rewrite.js +0 -139
  452. package/src/utils/transform-styles/transforms/wrap.js +0 -56
  453. package/src/utils/transform-styles/traverse.js +0 -32
@@ -1,123 +0,0 @@
1
- /**
2
- * Return `true` if the given path is http/https.
3
- *
4
- * @param {string} filePath path
5
- *
6
- * @return {boolean} is remote path.
7
- */
8
- function isRemotePath(filePath) {
9
- return /^(?:https?:)?\/\//.test(filePath);
10
- }
11
-
12
- /**
13
- * Return `true` if the given filePath is an absolute url.
14
- *
15
- * @param {string} filePath path
16
- *
17
- * @return {boolean} is absolute path.
18
- */
19
- function isAbsolutePath(filePath) {
20
- return /^\/(?!\/)/.test(filePath);
21
- }
22
-
23
- /**
24
- * Whether or not the url should be inluded.
25
- *
26
- * @param {Object} meta url meta info
27
- *
28
- * @return {boolean} is valid.
29
- */
30
- function isValidURL(meta) {
31
- // Ignore hashes or data uris.
32
- if (meta.value.indexOf('data:') === 0 || meta.value.indexOf('#') === 0) {
33
- return false;
34
- }
35
- if (isAbsolutePath(meta.value)) {
36
- return false;
37
- }
38
-
39
- // Do not handle the http/https urls if `includeRemote` is false.
40
- if (isRemotePath(meta.value)) {
41
- return false;
42
- }
43
- return true;
44
- }
45
-
46
- /**
47
- * Get the absolute path of the url, relative to the basePath
48
- *
49
- * @param {string} str the url
50
- * @param {string} baseURL base URL
51
- *
52
- * @return {string} the full path to the file
53
- */
54
- function getResourcePath(str, baseURL) {
55
- return new URL(str, baseURL).toString();
56
- }
57
-
58
- /**
59
- * Process the single `url()` pattern
60
- *
61
- * @param {string} baseURL the base URL for relative URLs.
62
- *
63
- * @return {Promise} the Promise.
64
- */
65
- function processURL(baseURL) {
66
- return meta => ({
67
- ...meta,
68
- newUrl: 'url(' + meta.before + meta.quote + getResourcePath(meta.value, baseURL) + meta.quote + meta.after + ')'
69
- });
70
- }
71
-
72
- /**
73
- * Get all `url()`s, and return the meta info
74
- *
75
- * @param {string} value decl.value.
76
- *
77
- * @return {Array} the urls.
78
- */
79
- function getURLs(value) {
80
- const reg = /url\((\s*)(['"]?)(.+?)\2(\s*)\)/g;
81
- let match;
82
- const URLs = [];
83
- while ((match = reg.exec(value)) !== null) {
84
- const meta = {
85
- source: match[0],
86
- before: match[1],
87
- quote: match[2],
88
- value: match[3],
89
- after: match[4]
90
- };
91
- if (isValidURL(meta)) {
92
- URLs.push(meta);
93
- }
94
- }
95
- return URLs;
96
- }
97
-
98
- /**
99
- * Replace the raw value's `url()` segment to the new value
100
- *
101
- * @param {string} raw the raw value.
102
- * @param {Array} URLs the URLs to replace.
103
- *
104
- * @return {string} the new value.
105
- */
106
- function replaceURLs(raw, URLs) {
107
- URLs.forEach(item => {
108
- raw = raw.replace(item.source, item.newUrl);
109
- });
110
- return raw;
111
- }
112
- const rewrite = rootURL => node => {
113
- if (node.type === 'declaration') {
114
- const updatedURLs = getURLs(node.value).map(processURL(rootURL));
115
- return {
116
- ...node,
117
- value: replaceURLs(node.value, updatedURLs)
118
- };
119
- }
120
- return node;
121
- };
122
- export default rewrite;
123
- //# sourceMappingURL=url-rewrite.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["isRemotePath","filePath","test","isAbsolutePath","isValidURL","meta","value","indexOf","getResourcePath","str","baseURL","URL","toString","processURL","newUrl","before","quote","after","getURLs","reg","match","URLs","exec","source","push","replaceURLs","raw","forEach","item","replace","rewrite","rootURL","node","type","updatedURLs","map"],"sources":["@wordpress/block-editor/src/utils/transform-styles/transforms/url-rewrite.js"],"sourcesContent":["/**\n * Return `true` if the given path is http/https.\n *\n * @param {string} filePath path\n *\n * @return {boolean} is remote path.\n */\nfunction isRemotePath( filePath ) {\n\treturn /^(?:https?:)?\\/\\//.test( filePath );\n}\n\n/**\n * Return `true` if the given filePath is an absolute url.\n *\n * @param {string} filePath path\n *\n * @return {boolean} is absolute path.\n */\nfunction isAbsolutePath( filePath ) {\n\treturn /^\\/(?!\\/)/.test( filePath );\n}\n\n/**\n * Whether or not the url should be inluded.\n *\n * @param {Object} meta url meta info\n *\n * @return {boolean} is valid.\n */\nfunction isValidURL( meta ) {\n\t// Ignore hashes or data uris.\n\tif (\n\t\tmeta.value.indexOf( 'data:' ) === 0 ||\n\t\tmeta.value.indexOf( '#' ) === 0\n\t) {\n\t\treturn false;\n\t}\n\n\tif ( isAbsolutePath( meta.value ) ) {\n\t\treturn false;\n\t}\n\n\t// Do not handle the http/https urls if `includeRemote` is false.\n\tif ( isRemotePath( meta.value ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Get the absolute path of the url, relative to the basePath\n *\n * @param {string} str the url\n * @param {string} baseURL base URL\n *\n * @return {string} the full path to the file\n */\nfunction getResourcePath( str, baseURL ) {\n\treturn new URL( str, baseURL ).toString();\n}\n\n/**\n * Process the single `url()` pattern\n *\n * @param {string} baseURL the base URL for relative URLs.\n *\n * @return {Promise} the Promise.\n */\nfunction processURL( baseURL ) {\n\treturn ( meta ) => ( {\n\t\t...meta,\n\t\tnewUrl:\n\t\t\t'url(' +\n\t\t\tmeta.before +\n\t\t\tmeta.quote +\n\t\t\tgetResourcePath( meta.value, baseURL ) +\n\t\t\tmeta.quote +\n\t\t\tmeta.after +\n\t\t\t')',\n\t} );\n}\n\n/**\n * Get all `url()`s, and return the meta info\n *\n * @param {string} value decl.value.\n *\n * @return {Array} the urls.\n */\nfunction getURLs( value ) {\n\tconst reg = /url\\((\\s*)(['\"]?)(.+?)\\2(\\s*)\\)/g;\n\tlet match;\n\tconst URLs = [];\n\n\twhile ( ( match = reg.exec( value ) ) !== null ) {\n\t\tconst meta = {\n\t\t\tsource: match[ 0 ],\n\t\t\tbefore: match[ 1 ],\n\t\t\tquote: match[ 2 ],\n\t\t\tvalue: match[ 3 ],\n\t\t\tafter: match[ 4 ],\n\t\t};\n\t\tif ( isValidURL( meta ) ) {\n\t\t\tURLs.push( meta );\n\t\t}\n\t}\n\treturn URLs;\n}\n\n/**\n * Replace the raw value's `url()` segment to the new value\n *\n * @param {string} raw the raw value.\n * @param {Array} URLs the URLs to replace.\n *\n * @return {string} the new value.\n */\nfunction replaceURLs( raw, URLs ) {\n\tURLs.forEach( ( item ) => {\n\t\traw = raw.replace( item.source, item.newUrl );\n\t} );\n\n\treturn raw;\n}\n\nconst rewrite = ( rootURL ) => ( node ) => {\n\tif ( node.type === 'declaration' ) {\n\t\tconst updatedURLs = getURLs( node.value ).map( processURL( rootURL ) );\n\t\treturn {\n\t\t\t...node,\n\t\t\tvalue: replaceURLs( node.value, updatedURLs ),\n\t\t};\n\t}\n\n\treturn node;\n};\n\nexport default rewrite;\n"],"mappings":"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"}
@@ -1,52 +0,0 @@
1
- /**
2
- * @constant string IS_ROOT_TAG Regex to check if the selector is a root tag selector.
3
- */
4
- const IS_ROOT_TAG = /^(body|html|:root).*$/;
5
-
6
- /**
7
- * Creates a callback to modify selectors so they only apply within a certain
8
- * namespace.
9
- *
10
- * @param {string} namespace Namespace to prefix selectors with.
11
- * @param {string[]} ignore Selectors to not prefix.
12
- *
13
- * @return {(node: Object) => Object} Callback to wrap selectors.
14
- */
15
- const wrap = (namespace, ignore = []) => node => {
16
- /**
17
- * Updates selector if necessary.
18
- *
19
- * @param {string} selector Selector to modify.
20
- *
21
- * @return {string} Updated selector.
22
- */
23
- const updateSelector = selector => {
24
- if (ignore.includes(selector.trim())) {
25
- return selector;
26
- }
27
-
28
- // Skip the update when a selector already has a namespace + space (" ").
29
- if (selector.trim().startsWith(`${namespace} `)) {
30
- return selector;
31
- }
32
-
33
- // Anything other than a root tag is always prefixed.
34
- {
35
- if (!selector.match(IS_ROOT_TAG)) {
36
- return namespace + ' ' + selector;
37
- }
38
- }
39
-
40
- // HTML and Body elements cannot be contained within our container so lets extract their styles.
41
- return selector.replace(/^(body|html|:root)/, namespace);
42
- };
43
- if (node.type === 'rule') {
44
- return {
45
- ...node,
46
- selectors: node.selectors.map(updateSelector)
47
- };
48
- }
49
- return node;
50
- };
51
- export default wrap;
52
- //# sourceMappingURL=wrap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["IS_ROOT_TAG","wrap","namespace","ignore","node","updateSelector","selector","includes","trim","startsWith","match","replace","type","selectors","map"],"sources":["@wordpress/block-editor/src/utils/transform-styles/transforms/wrap.js"],"sourcesContent":["/**\n * @constant string IS_ROOT_TAG Regex to check if the selector is a root tag selector.\n */\nconst IS_ROOT_TAG = /^(body|html|:root).*$/;\n\n/**\n * Creates a callback to modify selectors so they only apply within a certain\n * namespace.\n *\n * @param {string} namespace Namespace to prefix selectors with.\n * @param {string[]} ignore Selectors to not prefix.\n *\n * @return {(node: Object) => Object} Callback to wrap selectors.\n */\nconst wrap =\n\t( namespace, ignore = [] ) =>\n\t( node ) => {\n\t\t/**\n\t\t * Updates selector if necessary.\n\t\t *\n\t\t * @param {string} selector Selector to modify.\n\t\t *\n\t\t * @return {string} Updated selector.\n\t\t */\n\t\tconst updateSelector = ( selector ) => {\n\t\t\tif ( ignore.includes( selector.trim() ) ) {\n\t\t\t\treturn selector;\n\t\t\t}\n\n\t\t\t// Skip the update when a selector already has a namespace + space (\" \").\n\t\t\tif ( selector.trim().startsWith( `${ namespace } ` ) ) {\n\t\t\t\treturn selector;\n\t\t\t}\n\n\t\t\t// Anything other than a root tag is always prefixed.\n\t\t\t{\n\t\t\t\tif ( ! selector.match( IS_ROOT_TAG ) ) {\n\t\t\t\t\treturn namespace + ' ' + selector;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// HTML and Body elements cannot be contained within our container so lets extract their styles.\n\t\t\treturn selector.replace( /^(body|html|:root)/, namespace );\n\t\t};\n\n\t\tif ( node.type === 'rule' ) {\n\t\t\treturn {\n\t\t\t\t...node,\n\t\t\t\tselectors: node.selectors.map( updateSelector ),\n\t\t\t};\n\t\t}\n\n\t\treturn node;\n\t};\n\nexport default wrap;\n"],"mappings":"AAAA;AACA;AACA;AACA,MAAMA,WAAW,GAAG,uBAAuB;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,IAAI,GACTA,CAAEC,SAAS,EAAEC,MAAM,GAAG,EAAE,KACtBC,IAAI,IAAM;EACX;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,cAAc,GAAKC,QAAQ,IAAM;IACtC,IAAKH,MAAM,CAACI,QAAQ,CAAED,QAAQ,CAACE,IAAI,CAAC,CAAE,CAAC,EAAG;MACzC,OAAOF,QAAQ;IAChB;;IAEA;IACA,IAAKA,QAAQ,CAACE,IAAI,CAAC,CAAC,CAACC,UAAU,CAAG,GAAGP,SAAW,GAAG,CAAC,EAAG;MACtD,OAAOI,QAAQ;IAChB;;IAEA;IACA;MACC,IAAK,CAAEA,QAAQ,CAACI,KAAK,CAAEV,WAAY,CAAC,EAAG;QACtC,OAAOE,SAAS,GAAG,GAAG,GAAGI,QAAQ;MAClC;IACD;;IAEA;IACA,OAAOA,QAAQ,CAACK,OAAO,CAAE,oBAAoB,EAAET,SAAU,CAAC;EAC3D,CAAC;EAED,IAAKE,IAAI,CAACQ,IAAI,KAAK,MAAM,EAAG;IAC3B,OAAO;MACN,GAAGR,IAAI;MACPS,SAAS,EAAET,IAAI,CAACS,SAAS,CAACC,GAAG,CAAET,cAAe;IAC/C,CAAC;EACF;EAEA,OAAOD,IAAI;AACZ,CAAC;AAEF,eAAeH,IAAI"}
@@ -1,28 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import traverse from 'traverse';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { parse, stringify } from './ast';
10
- function traverseCSS(css, callback) {
11
- try {
12
- const parsed = parse(css);
13
- const updated = traverse.map(parsed, function (node) {
14
- if (!node) {
15
- return node;
16
- }
17
- const updatedNode = callback(node);
18
- return this.update(updatedNode);
19
- });
20
- return stringify(updated);
21
- } catch (err) {
22
- // eslint-disable-next-line no-console
23
- console.warn('Error while traversing the CSS: ' + err);
24
- return null;
25
- }
26
- }
27
- export default traverseCSS;
28
- //# sourceMappingURL=traverse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["traverse","parse","stringify","traverseCSS","css","callback","parsed","updated","map","node","updatedNode","update","err","console","warn"],"sources":["@wordpress/block-editor/src/utils/transform-styles/traverse.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport traverse from 'traverse';\n\n/**\n * Internal dependencies\n */\nimport { parse, stringify } from './ast';\n\nfunction traverseCSS( css, callback ) {\n\ttry {\n\t\tconst parsed = parse( css );\n\n\t\tconst updated = traverse.map( parsed, function ( node ) {\n\t\t\tif ( ! node ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t\tconst updatedNode = callback( node );\n\t\t\treturn this.update( updatedNode );\n\t\t} );\n\n\t\treturn stringify( updated );\n\t} catch ( err ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn( 'Error while traversing the CSS: ' + err );\n\n\t\treturn null;\n\t}\n}\n\nexport default traverseCSS;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAQ,MAAM,UAAU;;AAE/B;AACA;AACA;AACA,SAASC,KAAK,EAAEC,SAAS,QAAQ,OAAO;AAExC,SAASC,WAAWA,CAAEC,GAAG,EAAEC,QAAQ,EAAG;EACrC,IAAI;IACH,MAAMC,MAAM,GAAGL,KAAK,CAAEG,GAAI,CAAC;IAE3B,MAAMG,OAAO,GAAGP,QAAQ,CAACQ,GAAG,CAAEF,MAAM,EAAE,UAAWG,IAAI,EAAG;MACvD,IAAK,CAAEA,IAAI,EAAG;QACb,OAAOA,IAAI;MACZ;MACA,MAAMC,WAAW,GAAGL,QAAQ,CAAEI,IAAK,CAAC;MACpC,OAAO,IAAI,CAACE,MAAM,CAAED,WAAY,CAAC;IAClC,CAAE,CAAC;IAEH,OAAOR,SAAS,CAAEK,OAAQ,CAAC;EAC5B,CAAC,CAAC,OAAQK,GAAG,EAAG;IACf;IACAC,OAAO,CAACC,IAAI,CAAE,kCAAkC,GAAGF,GAAI,CAAC;IAExD,OAAO,IAAI;EACZ;AACD;AAEA,eAAeT,WAAW"}
@@ -1,213 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useSelect } from '@wordpress/data';
5
- import {
6
- __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,
7
- hasBlockSupport,
8
- } from '@wordpress/blocks';
9
- import { applyFilters } from '@wordpress/hooks';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { useBlockEditContext } from '../block-edit';
15
- import { store as blockEditorStore } from '../../store';
16
- import { getValueFromObjectPath } from '../../utils/object';
17
-
18
- const blockedPaths = [
19
- 'color',
20
- 'border',
21
- 'dimensions',
22
- 'typography',
23
- 'spacing',
24
- ];
25
-
26
- const deprecatedFlags = {
27
- 'color.palette': ( settings ) => settings.colors,
28
- 'color.gradients': ( settings ) => settings.gradients,
29
- 'color.custom': ( settings ) =>
30
- settings.disableCustomColors === undefined
31
- ? undefined
32
- : ! settings.disableCustomColors,
33
- 'color.customGradient': ( settings ) =>
34
- settings.disableCustomGradients === undefined
35
- ? undefined
36
- : ! settings.disableCustomGradients,
37
- 'typography.fontSizes': ( settings ) => settings.fontSizes,
38
- 'typography.customFontSize': ( settings ) =>
39
- settings.disableCustomFontSizes === undefined
40
- ? undefined
41
- : ! settings.disableCustomFontSizes,
42
- 'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,
43
- 'spacing.units': ( settings ) => {
44
- if ( settings.enableCustomUnits === undefined ) {
45
- return;
46
- }
47
-
48
- if ( settings.enableCustomUnits === true ) {
49
- return [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];
50
- }
51
-
52
- return settings.enableCustomUnits;
53
- },
54
- 'spacing.padding': ( settings ) => settings.enableCustomSpacing,
55
- };
56
-
57
- const prefixedFlags = {
58
- /*
59
- * These were only available in the plugin
60
- * and can be removed when the minimum WordPress version
61
- * for the plugin is 5.9.
62
- */
63
- 'border.customColor': 'border.color',
64
- 'border.customStyle': 'border.style',
65
- 'border.customWidth': 'border.width',
66
- 'typography.customFontStyle': 'typography.fontStyle',
67
- 'typography.customFontWeight': 'typography.fontWeight',
68
- 'typography.customLetterSpacing': 'typography.letterSpacing',
69
- 'typography.customTextDecorations': 'typography.textDecoration',
70
- 'typography.customTextTransforms': 'typography.textTransform',
71
- /*
72
- * These were part of WordPress 5.8 and we need to keep them.
73
- */
74
- 'border.customRadius': 'border.radius',
75
- 'spacing.customMargin': 'spacing.margin',
76
- 'spacing.customPadding': 'spacing.padding',
77
- 'typography.customLineHeight': 'typography.lineHeight',
78
- };
79
-
80
- /**
81
- * Remove `custom` prefixes for flags that did not land in 5.8.
82
- *
83
- * This provides continued support for `custom` prefixed properties. It will
84
- * be removed once third party devs have had sufficient time to update themes,
85
- * plugins, etc.
86
- *
87
- * @see https://github.com/WordPress/gutenberg/pull/34485
88
- *
89
- * @param {string} path Path to desired value in settings.
90
- * @return {string} The value for defined setting.
91
- */
92
- const removeCustomPrefixes = ( path ) => {
93
- return prefixedFlags[ path ] || path;
94
- };
95
-
96
- /**
97
- * Hook that retrieves the given setting for the block instance in use.
98
- *
99
- * It looks up the settings first in the block instance hierarchy.
100
- * If none is found, it'll look it up in the block editor store.
101
- *
102
- * @param {string} path The path to the setting.
103
- * @return {any} Returns the value defined for the setting.
104
- * @example
105
- * ```js
106
- * const isEnabled = useSetting( 'typography.dropCap' );
107
- * ```
108
- */
109
- export default function useSetting( path ) {
110
- const { name: blockName, clientId } = useBlockEditContext();
111
-
112
- return useSelect(
113
- ( select ) => {
114
- if ( blockedPaths.includes( path ) ) {
115
- // eslint-disable-next-line no-console
116
- console.warn(
117
- 'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'
118
- );
119
- return undefined;
120
- }
121
-
122
- // 0. Allow third parties to filter the block's settings at runtime.
123
- let result = applyFilters(
124
- 'blockEditor.useSetting.before',
125
- undefined,
126
- path,
127
- clientId,
128
- blockName
129
- );
130
-
131
- if ( undefined !== result ) {
132
- return result;
133
- }
134
-
135
- const normalizedPath = removeCustomPrefixes( path );
136
-
137
- // 1. Take settings from the block instance or its ancestors.
138
- // Start from the current block and work our way up the ancestors.
139
- const candidates = [
140
- clientId,
141
- ...select( blockEditorStore ).getBlockParents(
142
- clientId,
143
- /* ascending */ true
144
- ),
145
- ];
146
-
147
- for ( const candidateClientId of candidates ) {
148
- const candidateBlockName =
149
- select( blockEditorStore ).getBlockName(
150
- candidateClientId
151
- );
152
- if (
153
- hasBlockSupport(
154
- candidateBlockName,
155
- '__experimentalSettings',
156
- false
157
- )
158
- ) {
159
- const candidateAtts =
160
- select( blockEditorStore ).getBlockAttributes(
161
- candidateClientId
162
- );
163
- result =
164
- getValueFromObjectPath(
165
- candidateAtts,
166
- `settings.blocks.${ blockName }.${ normalizedPath }`
167
- ) ??
168
- getValueFromObjectPath(
169
- candidateAtts,
170
- `settings.${ normalizedPath }`
171
- );
172
- if ( result !== undefined ) {
173
- // Stop the search for more distant ancestors and move on.
174
- break;
175
- }
176
- }
177
- }
178
-
179
- // 2. Fall back to the settings from the block editor store (__experimentalFeatures).
180
- const settings = select( blockEditorStore ).getSettings();
181
- if ( result === undefined ) {
182
- const defaultsPath = `__experimentalFeatures.${ normalizedPath }`;
183
- const blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;
184
- result =
185
- getValueFromObjectPath( settings, blockPath ) ??
186
- getValueFromObjectPath( settings, defaultsPath );
187
- }
188
-
189
- // Return if the setting was found in either the block instance or the store.
190
- if ( result !== undefined ) {
191
- if ( PATHS_WITH_MERGE[ normalizedPath ] ) {
192
- return result.custom ?? result.theme ?? result.default;
193
- }
194
- return result;
195
- }
196
-
197
- // 3. Otherwise, use deprecated settings.
198
- const deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]
199
- ? deprecatedFlags[ normalizedPath ]( settings )
200
- : undefined;
201
- if ( deprecatedSettingsValue !== undefined ) {
202
- return deprecatedSettingsValue;
203
- }
204
-
205
- // 4. Fallback for typography.dropCap:
206
- // This is only necessary to support typography.dropCap.
207
- // when __experimentalFeatures are not present (core without plugin).
208
- // To remove when __experimentalFeatures are ported to core.
209
- return normalizedPath === 'typography.dropCap' ? true : undefined;
210
- },
211
- [ blockName, clientId, path ]
212
- );
213
- }
@@ -1,5 +0,0 @@
1
- // Adapted from https://github.com/reworkcss/css
2
- // because we needed to remove source map support.
3
-
4
- export { default as parse } from './parse';
5
- export { default as stringify } from './stringify';