@wordpress/block-editor 14.1.0 → 14.2.1-next.1f6eadc42.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 (705) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -10
  3. package/build/components/block-alignment-matrix-control/index.js +2 -2
  4. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  5. package/build/components/block-breadcrumb/index.js +2 -2
  6. package/build/components/block-breadcrumb/index.js.map +1 -1
  7. package/build/components/block-canvas/index.js +8 -1
  8. package/build/components/block-canvas/index.js.map +1 -1
  9. package/build/components/block-compare/block-view.js +1 -0
  10. package/build/components/block-compare/block-view.js.map +1 -1
  11. package/build/components/block-draggable/index.js +4 -4
  12. package/build/components/block-draggable/index.js.map +1 -1
  13. package/build/components/block-draggable/use-scroll-when-dragging.js +25 -25
  14. package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  15. package/build/components/block-edit/multiple-usage-warning.js +2 -0
  16. package/build/components/block-edit/multiple-usage-warning.js.map +1 -1
  17. package/build/components/block-inspector/index.js +27 -11
  18. package/build/components/block-inspector/index.js.map +1 -1
  19. package/build/components/block-list/block-invalid-warning.js +3 -2
  20. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  21. package/build/components/block-list/block.js +5 -1
  22. package/build/components/block-list/block.js.map +1 -1
  23. package/build/components/block-list/index.js +14 -3
  24. package/build/components/block-list/index.js.map +1 -1
  25. package/build/components/block-list/use-block-props/index.js +5 -1
  26. package/build/components/block-list/use-block-props/index.js.map +1 -1
  27. package/build/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  28. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  29. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +53 -0
  30. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
  31. package/build/components/block-list/zoom-out-separator.js +98 -0
  32. package/build/components/block-list/zoom-out-separator.js.map +1 -0
  33. package/build/components/block-lock/toolbar.js +3 -3
  34. package/build/components/block-lock/toolbar.js.map +1 -1
  35. package/build/components/block-mover/button.js +1 -0
  36. package/build/components/block-mover/button.js.map +1 -1
  37. package/build/components/block-mover/index.js +1 -0
  38. package/build/components/block-mover/index.js.map +1 -1
  39. package/build/components/block-navigation/dropdown.js +4 -1
  40. package/build/components/block-navigation/dropdown.js.map +1 -1
  41. package/build/components/block-pattern-setup/index.js +2 -10
  42. package/build/components/block-pattern-setup/index.js.map +1 -1
  43. package/build/components/block-pattern-setup/setup-toolbar.js +22 -7
  44. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  45. package/build/components/block-patterns-list/index.js +12 -20
  46. package/build/components/block-patterns-list/index.js.map +1 -1
  47. package/build/components/block-patterns-paging/index.js +12 -3
  48. package/build/components/block-patterns-paging/index.js.map +1 -1
  49. package/build/components/block-popover/index.js +2 -15
  50. package/build/components/block-popover/index.js.map +1 -1
  51. package/build/components/block-quick-navigation/index.js +4 -1
  52. package/build/components/block-quick-navigation/index.js.map +1 -1
  53. package/build/components/block-settings-menu-controls/index.js +4 -0
  54. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  55. package/build/components/block-switcher/index.js +30 -19
  56. package/build/components/block-switcher/index.js.map +1 -1
  57. package/build/components/block-switcher/pattern-transformations-menu.js +2 -10
  58. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  59. package/build/components/block-toolbar/index.js +19 -12
  60. package/build/components/block-toolbar/index.js.map +1 -1
  61. package/build/components/block-toolbar/shuffle.js +6 -2
  62. package/build/components/block-toolbar/shuffle.js.map +1 -1
  63. package/build/components/block-tools/block-selection-button.js +8 -2
  64. package/build/components/block-tools/block-selection-button.js.map +1 -1
  65. package/build/components/block-tools/block-toolbar-popover.js +10 -6
  66. package/build/components/block-tools/block-toolbar-popover.js.map +1 -1
  67. package/build/components/block-tools/index.js +1 -1
  68. package/build/components/block-tools/index.js.map +1 -1
  69. package/build/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  70. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  71. package/build/components/block-tools/zoom-out-mode-inserters.js +7 -21
  72. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  73. package/build/components/block-tools/zoom-out-popover.js +3 -4
  74. package/build/components/block-tools/zoom-out-popover.js.map +1 -1
  75. package/build/components/block-tools/zoom-out-toolbar.js +26 -7
  76. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
  77. package/build/components/block-variation-picker/index.js +4 -1
  78. package/build/components/block-variation-picker/index.js.map +1 -1
  79. package/build/components/block-variation-transforms/index.js +4 -1
  80. package/build/components/block-variation-transforms/index.js.map +1 -1
  81. package/build/components/button-block-appender/index.js +20 -23
  82. package/build/components/button-block-appender/index.js.map +1 -1
  83. package/build/components/colors-gradients/dropdown.js +4 -1
  84. package/build/components/colors-gradients/dropdown.js.map +1 -1
  85. package/build/components/content-lock/index.js +13 -0
  86. package/build/components/content-lock/index.js.map +1 -0
  87. package/build/components/content-lock/modify-content-lock-menu-item.js +64 -0
  88. package/build/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
  89. package/build/components/editor-styles/index.js +4 -3
  90. package/build/components/editor-styles/index.js.map +1 -1
  91. package/build/components/global-styles/background-panel.js +8 -12
  92. package/build/components/global-styles/background-panel.js.map +1 -1
  93. package/build/components/global-styles/color-panel.js +8 -5
  94. package/build/components/global-styles/color-panel.js.map +1 -1
  95. package/build/components/global-styles/color-panel.native.js +1 -1
  96. package/build/components/global-styles/color-panel.native.js.map +1 -1
  97. package/build/components/global-styles/dimensions-panel.js +34 -37
  98. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  99. package/build/components/global-styles/filters-panel.js +4 -1
  100. package/build/components/global-styles/filters-panel.js.map +1 -1
  101. package/build/components/global-styles/shadow-panel-components.js +14 -17
  102. package/build/components/global-styles/shadow-panel-components.js.map +1 -1
  103. package/build/components/global-styles/typography-utils.js +17 -6
  104. package/build/components/global-styles/typography-utils.js.map +1 -1
  105. package/build/components/global-styles/utils.js +4 -6
  106. package/build/components/global-styles/utils.js.map +1 -1
  107. package/build/components/grid/grid-item-movers.js +2 -2
  108. package/build/components/grid/grid-item-movers.js.map +1 -1
  109. package/build/components/grid/grid-item-resizer.js +2 -2
  110. package/build/components/grid/grid-item-resizer.js.map +1 -1
  111. package/build/components/iframe/get-compatibility-styles.js +1 -1
  112. package/build/components/iframe/get-compatibility-styles.js.map +1 -1
  113. package/build/components/iframe/index.js +5 -5
  114. package/build/components/iframe/index.js.map +1 -1
  115. package/build/components/inner-blocks/index.js +2 -4
  116. package/build/components/inner-blocks/index.js.map +1 -1
  117. package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  118. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  119. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
  120. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
  121. package/build/components/inserter/block-patterns-tab/index.js +4 -1
  122. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  123. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +23 -13
  124. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  125. package/build/components/inserter/index.js +4 -11
  126. package/build/components/inserter/index.js.map +1 -1
  127. package/build/components/inserter/library.js +2 -4
  128. package/build/components/inserter/library.js.map +1 -1
  129. package/build/components/inserter/media-tab/hooks.js +3 -3
  130. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  131. package/build/components/inserter/media-tab/media-list.js +1 -8
  132. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  133. package/build/components/inserter/media-tab/media-preview.js +9 -7
  134. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  135. package/build/components/inserter/media-tab/media-tab.js +4 -1
  136. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  137. package/build/components/inserter/menu.js +7 -24
  138. package/build/components/inserter/menu.js.map +1 -1
  139. package/build/components/inserter/quick-inserter.js +4 -5
  140. package/build/components/inserter/quick-inserter.js.map +1 -1
  141. package/build/components/inserter-list-item/index.js +4 -4
  142. package/build/components/inserter-list-item/index.js.map +1 -1
  143. package/build/components/inserter-listbox/index.js +3 -13
  144. package/build/components/inserter-listbox/index.js.map +1 -1
  145. package/build/components/inserter-listbox/item.js +6 -11
  146. package/build/components/inserter-listbox/item.js.map +1 -1
  147. package/build/components/inserter-listbox/row.js +1 -9
  148. package/build/components/inserter-listbox/row.js.map +1 -1
  149. package/build/components/inspector-controls/groups.js +2 -0
  150. package/build/components/inspector-controls/groups.js.map +1 -1
  151. package/build/components/inspector-controls-tabs/index.js +4 -1
  152. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  153. package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
  154. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  155. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
  156. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  157. package/build/components/inspector-popover-header/index.js +8 -2
  158. package/build/components/inspector-popover-header/index.js.map +1 -1
  159. package/build/components/letter-spacing-control/index.js +7 -4
  160. package/build/components/letter-spacing-control/index.js.map +1 -1
  161. package/build/components/link-control/index.js +19 -10
  162. package/build/components/link-control/index.js.map +1 -1
  163. package/build/components/link-control/settings-drawer.js +4 -1
  164. package/build/components/link-control/settings-drawer.js.map +1 -1
  165. package/build/components/list-view/block-select-button.js +4 -1
  166. package/build/components/list-view/block-select-button.js.map +1 -1
  167. package/build/components/list-view/index.js +3 -7
  168. package/build/components/list-view/index.js.map +1 -1
  169. package/build/components/media-placeholder/index.js +32 -11
  170. package/build/components/media-placeholder/index.js.map +1 -1
  171. package/build/components/media-replace-flow/index.js +8 -1
  172. package/build/components/media-replace-flow/index.js.map +1 -1
  173. package/build/components/provider/use-block-sync.js +19 -19
  174. package/build/components/provider/use-block-sync.js.map +1 -1
  175. package/build/components/rich-text/event-listeners/paste-handler.js +12 -1
  176. package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  177. package/build/components/rich-text/index.js +38 -30
  178. package/build/components/rich-text/index.js.map +1 -1
  179. package/build/components/rich-text/use-mark-persistent.js +5 -5
  180. package/build/components/rich-text/use-mark-persistent.js.map +1 -1
  181. package/build/components/skip-to-selected-block/index.js +4 -1
  182. package/build/components/skip-to-selected-block/index.js.map +1 -1
  183. package/build/components/spacing-sizes-control/index.js +8 -9
  184. package/build/components/spacing-sizes-control/index.js.map +1 -1
  185. package/build/components/spacing-sizes-control/linked-button.js +35 -0
  186. package/build/components/spacing-sizes-control/linked-button.js.map +1 -0
  187. package/build/components/spacing-sizes-control/utils.js +4 -15
  188. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  189. package/build/components/tool-selector/index.js +4 -1
  190. package/build/components/tool-selector/index.js.map +1 -1
  191. package/build/components/url-input/button.js +12 -3
  192. package/build/components/url-input/button.js.map +1 -1
  193. package/build/components/url-input/index.js +4 -1
  194. package/build/components/url-input/index.js.map +1 -1
  195. package/build/components/use-block-drop-zone/index.js +31 -7
  196. package/build/components/use-block-drop-zone/index.js.map +1 -1
  197. package/build/components/writing-flow/index.js +2 -1
  198. package/build/components/writing-flow/index.js.map +1 -1
  199. package/build/components/writing-flow/use-arrow-nav.js +4 -1
  200. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  201. package/build/components/writing-flow/use-event-redirect.js +66 -0
  202. package/build/components/writing-flow/use-event-redirect.js.map +1 -0
  203. package/build/components/writing-flow/use-input.js +31 -1
  204. package/build/components/writing-flow/use-input.js.map +1 -1
  205. package/build/components/writing-flow/use-select-all.js +14 -1
  206. package/build/components/writing-flow/use-select-all.js.map +1 -1
  207. package/build/components/writing-flow/use-selection-observer.js +20 -6
  208. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  209. package/build/components/writing-flow/use-tab-nav.js +4 -4
  210. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  211. package/build/components/writing-flow/utils.js +27 -0
  212. package/build/components/writing-flow/utils.js.map +1 -1
  213. package/build/hooks/block-bindings.js +33 -29
  214. package/build/hooks/block-bindings.js.map +1 -1
  215. package/build/hooks/content-lock-ui.js +8 -26
  216. package/build/hooks/content-lock-ui.js.map +1 -1
  217. package/build/hooks/duotone.js +0 -4
  218. package/build/hooks/duotone.js.map +1 -1
  219. package/build/hooks/layout.js +4 -2
  220. package/build/hooks/layout.js.map +1 -1
  221. package/build/hooks/spacing-visualizer.js +3 -3
  222. package/build/hooks/spacing-visualizer.js.map +1 -1
  223. package/build/hooks/style.js +1 -5
  224. package/build/hooks/style.js.map +1 -1
  225. package/build/hooks/use-bindings-attributes.js +19 -20
  226. package/build/hooks/use-bindings-attributes.js.map +1 -1
  227. package/build/hooks/use-zoom-out.js +7 -7
  228. package/build/hooks/use-zoom-out.js.map +1 -1
  229. package/build/layouts/constrained.js +41 -42
  230. package/build/layouts/constrained.js.map +1 -1
  231. package/build/layouts/flex.js +4 -1
  232. package/build/layouts/flex.js.map +1 -1
  233. package/build/layouts/grid.js +19 -16
  234. package/build/layouts/grid.js.map +1 -1
  235. package/build/layouts/utils.js +1 -7
  236. package/build/layouts/utils.js.map +1 -1
  237. package/build/private-apis.js +2 -3
  238. package/build/private-apis.js.map +1 -1
  239. package/build/store/actions.js +2 -7
  240. package/build/store/actions.js.map +1 -1
  241. package/build/store/private-actions.js +1 -0
  242. package/build/store/private-actions.js.map +1 -1
  243. package/build/store/private-keys.js +2 -1
  244. package/build/store/private-keys.js.map +1 -1
  245. package/build/store/private-selectors.js +16 -18
  246. package/build/store/private-selectors.js.map +1 -1
  247. package/build/store/reducer.js +1 -10
  248. package/build/store/reducer.js.map +1 -1
  249. package/build/store/selectors.js +19 -43
  250. package/build/store/selectors.js.map +1 -1
  251. package/build/store/utils.js +48 -0
  252. package/build/store/utils.js.map +1 -1
  253. package/build/utils/block-bindings.js +16 -11
  254. package/build/utils/block-bindings.js.map +1 -1
  255. package/build/utils/dom.js +101 -0
  256. package/build/utils/dom.js.map +1 -1
  257. package/build/utils/get-font-styles-and-weights.js +4 -4
  258. package/build/utils/get-font-styles-and-weights.js.map +1 -1
  259. package/build/utils/transform-styles/index.js +120 -16
  260. package/build/utils/transform-styles/index.js.map +1 -1
  261. package/build-module/components/block-alignment-matrix-control/index.js +1 -1
  262. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  263. package/build-module/components/block-breadcrumb/index.js +2 -2
  264. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  265. package/build-module/components/block-canvas/index.js +9 -1
  266. package/build-module/components/block-canvas/index.js.map +1 -1
  267. package/build-module/components/block-compare/block-view.js +1 -0
  268. package/build-module/components/block-compare/block-view.js.map +1 -1
  269. package/build-module/components/block-draggable/index.js +4 -4
  270. package/build-module/components/block-draggable/index.js.map +1 -1
  271. package/build-module/components/block-draggable/use-scroll-when-dragging.js +25 -25
  272. package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  273. package/build-module/components/block-edit/multiple-usage-warning.js +2 -0
  274. package/build-module/components/block-edit/multiple-usage-warning.js.map +1 -1
  275. package/build-module/components/block-inspector/index.js +27 -11
  276. package/build-module/components/block-inspector/index.js.map +1 -1
  277. package/build-module/components/block-list/block-invalid-warning.js +3 -2
  278. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  279. package/build-module/components/block-list/block.js +5 -1
  280. package/build-module/components/block-list/block.js.map +1 -1
  281. package/build-module/components/block-list/index.js +14 -3
  282. package/build-module/components/block-list/index.js.map +1 -1
  283. package/build-module/components/block-list/use-block-props/index.js +5 -1
  284. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  285. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  286. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  287. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +47 -0
  288. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
  289. package/build-module/components/block-list/zoom-out-separator.js +90 -0
  290. package/build-module/components/block-list/zoom-out-separator.js.map +1 -0
  291. package/build-module/components/block-lock/toolbar.js +3 -3
  292. package/build-module/components/block-lock/toolbar.js.map +1 -1
  293. package/build-module/components/block-mover/button.js +1 -0
  294. package/build-module/components/block-mover/button.js.map +1 -1
  295. package/build-module/components/block-mover/index.js +1 -0
  296. package/build-module/components/block-mover/index.js.map +1 -1
  297. package/build-module/components/block-navigation/dropdown.js +4 -1
  298. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  299. package/build-module/components/block-pattern-setup/index.js +2 -10
  300. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  301. package/build-module/components/block-pattern-setup/setup-toolbar.js +23 -8
  302. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  303. package/build-module/components/block-patterns-list/index.js +12 -20
  304. package/build-module/components/block-patterns-list/index.js.map +1 -1
  305. package/build-module/components/block-patterns-paging/index.js +12 -3
  306. package/build-module/components/block-patterns-paging/index.js.map +1 -1
  307. package/build-module/components/block-popover/index.js +2 -15
  308. package/build-module/components/block-popover/index.js.map +1 -1
  309. package/build-module/components/block-quick-navigation/index.js +4 -1
  310. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  311. package/build-module/components/block-settings-menu-controls/index.js +4 -0
  312. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  313. package/build-module/components/block-switcher/index.js +30 -19
  314. package/build-module/components/block-switcher/index.js.map +1 -1
  315. package/build-module/components/block-switcher/pattern-transformations-menu.js +2 -10
  316. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  317. package/build-module/components/block-toolbar/index.js +19 -12
  318. package/build-module/components/block-toolbar/index.js.map +1 -1
  319. package/build-module/components/block-toolbar/shuffle.js +6 -2
  320. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  321. package/build-module/components/block-tools/block-selection-button.js +8 -2
  322. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  323. package/build-module/components/block-tools/block-toolbar-popover.js +10 -6
  324. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -1
  325. package/build-module/components/block-tools/index.js +1 -1
  326. package/build-module/components/block-tools/index.js.map +1 -1
  327. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  328. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  329. package/build-module/components/block-tools/zoom-out-mode-inserters.js +7 -22
  330. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  331. package/build-module/components/block-tools/zoom-out-popover.js +3 -4
  332. package/build-module/components/block-tools/zoom-out-popover.js.map +1 -1
  333. package/build-module/components/block-tools/zoom-out-toolbar.js +27 -8
  334. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
  335. package/build-module/components/block-variation-picker/index.js +4 -1
  336. package/build-module/components/block-variation-picker/index.js.map +1 -1
  337. package/build-module/components/block-variation-transforms/index.js +4 -1
  338. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  339. package/build-module/components/button-block-appender/index.js +22 -26
  340. package/build-module/components/button-block-appender/index.js.map +1 -1
  341. package/build-module/components/colors-gradients/dropdown.js +4 -1
  342. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  343. package/build-module/components/content-lock/index.js +2 -0
  344. package/build-module/components/content-lock/index.js.map +1 -0
  345. package/build-module/components/content-lock/modify-content-lock-menu-item.js +57 -0
  346. package/build-module/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
  347. package/build-module/components/editor-styles/index.js +4 -3
  348. package/build-module/components/editor-styles/index.js.map +1 -1
  349. package/build-module/components/global-styles/background-panel.js +8 -12
  350. package/build-module/components/global-styles/background-panel.js.map +1 -1
  351. package/build-module/components/global-styles/color-panel.js +7 -4
  352. package/build-module/components/global-styles/color-panel.js.map +1 -1
  353. package/build-module/components/global-styles/color-panel.native.js +2 -2
  354. package/build-module/components/global-styles/color-panel.native.js.map +1 -1
  355. package/build-module/components/global-styles/dimensions-panel.js +36 -39
  356. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  357. package/build-module/components/global-styles/filters-panel.js +4 -1
  358. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  359. package/build-module/components/global-styles/shadow-panel-components.js +14 -17
  360. package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
  361. package/build-module/components/global-styles/typography-utils.js +17 -6
  362. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  363. package/build-module/components/global-styles/utils.js +4 -6
  364. package/build-module/components/global-styles/utils.js.map +1 -1
  365. package/build-module/components/grid/grid-item-movers.js +3 -3
  366. package/build-module/components/grid/grid-item-movers.js.map +1 -1
  367. package/build-module/components/grid/grid-item-resizer.js +2 -2
  368. package/build-module/components/grid/grid-item-resizer.js.map +1 -1
  369. package/build-module/components/iframe/get-compatibility-styles.js +1 -1
  370. package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
  371. package/build-module/components/iframe/index.js +5 -5
  372. package/build-module/components/iframe/index.js.map +1 -1
  373. package/build-module/components/inner-blocks/index.js +2 -4
  374. package/build-module/components/inner-blocks/index.js.map +1 -1
  375. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  376. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  377. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
  378. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
  379. package/build-module/components/inserter/block-patterns-tab/index.js +4 -1
  380. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  381. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +23 -13
  382. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  383. package/build-module/components/inserter/index.js +4 -11
  384. package/build-module/components/inserter/index.js.map +1 -1
  385. package/build-module/components/inserter/library.js +2 -4
  386. package/build-module/components/inserter/library.js.map +1 -1
  387. package/build-module/components/inserter/media-tab/hooks.js +3 -3
  388. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  389. package/build-module/components/inserter/media-tab/media-list.js +1 -8
  390. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  391. package/build-module/components/inserter/media-tab/media-preview.js +10 -8
  392. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  393. package/build-module/components/inserter/media-tab/media-tab.js +4 -1
  394. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  395. package/build-module/components/inserter/menu.js +7 -24
  396. package/build-module/components/inserter/menu.js.map +1 -1
  397. package/build-module/components/inserter/quick-inserter.js +5 -6
  398. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  399. package/build-module/components/inserter-list-item/index.js +4 -4
  400. package/build-module/components/inserter-list-item/index.js.map +1 -1
  401. package/build-module/components/inserter-listbox/index.js +3 -11
  402. package/build-module/components/inserter-listbox/index.js.map +1 -1
  403. package/build-module/components/inserter-listbox/item.js +7 -12
  404. package/build-module/components/inserter-listbox/item.js.map +1 -1
  405. package/build-module/components/inserter-listbox/row.js +2 -10
  406. package/build-module/components/inserter-listbox/row.js.map +1 -1
  407. package/build-module/components/inspector-controls/groups.js +2 -0
  408. package/build-module/components/inspector-controls/groups.js.map +1 -1
  409. package/build-module/components/inspector-controls-tabs/index.js +4 -1
  410. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  411. package/build-module/components/inspector-controls-tabs/settings-tab.js +3 -1
  412. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  413. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
  414. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  415. package/build-module/components/inspector-popover-header/index.js +8 -2
  416. package/build-module/components/inspector-popover-header/index.js.map +1 -1
  417. package/build-module/components/letter-spacing-control/index.js +7 -4
  418. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  419. package/build-module/components/link-control/index.js +19 -10
  420. package/build-module/components/link-control/index.js.map +1 -1
  421. package/build-module/components/link-control/settings-drawer.js +4 -1
  422. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  423. package/build-module/components/list-view/block-select-button.js +4 -1
  424. package/build-module/components/list-view/block-select-button.js.map +1 -1
  425. package/build-module/components/list-view/index.js +3 -7
  426. package/build-module/components/list-view/index.js.map +1 -1
  427. package/build-module/components/media-placeholder/index.js +32 -11
  428. package/build-module/components/media-placeholder/index.js.map +1 -1
  429. package/build-module/components/media-replace-flow/index.js +8 -1
  430. package/build-module/components/media-replace-flow/index.js.map +1 -1
  431. package/build-module/components/provider/use-block-sync.js +19 -19
  432. package/build-module/components/provider/use-block-sync.js.map +1 -1
  433. package/build-module/components/rich-text/event-listeners/paste-handler.js +12 -1
  434. package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  435. package/build-module/components/rich-text/index.js +39 -31
  436. package/build-module/components/rich-text/index.js.map +1 -1
  437. package/build-module/components/rich-text/use-mark-persistent.js +5 -5
  438. package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
  439. package/build-module/components/skip-to-selected-block/index.js +4 -1
  440. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  441. package/build-module/components/spacing-sizes-control/index.js +9 -10
  442. package/build-module/components/spacing-sizes-control/index.js.map +1 -1
  443. package/build-module/components/spacing-sizes-control/linked-button.js +28 -0
  444. package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -0
  445. package/build-module/components/spacing-sizes-control/utils.js +4 -15
  446. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  447. package/build-module/components/tool-selector/index.js +4 -1
  448. package/build-module/components/tool-selector/index.js.map +1 -1
  449. package/build-module/components/url-input/button.js +12 -3
  450. package/build-module/components/url-input/button.js.map +1 -1
  451. package/build-module/components/url-input/index.js +4 -1
  452. package/build-module/components/url-input/index.js.map +1 -1
  453. package/build-module/components/use-block-drop-zone/index.js +31 -7
  454. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  455. package/build-module/components/writing-flow/index.js +2 -1
  456. package/build-module/components/writing-flow/index.js.map +1 -1
  457. package/build-module/components/writing-flow/use-arrow-nav.js +4 -1
  458. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  459. package/build-module/components/writing-flow/use-event-redirect.js +60 -0
  460. package/build-module/components/writing-flow/use-event-redirect.js.map +1 -0
  461. package/build-module/components/writing-flow/use-input.js +31 -1
  462. package/build-module/components/writing-flow/use-input.js.map +1 -1
  463. package/build-module/components/writing-flow/use-select-all.js +14 -1
  464. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  465. package/build-module/components/writing-flow/use-selection-observer.js +16 -2
  466. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  467. package/build-module/components/writing-flow/use-tab-nav.js +4 -4
  468. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  469. package/build-module/components/writing-flow/utils.js +26 -0
  470. package/build-module/components/writing-flow/utils.js.map +1 -1
  471. package/build-module/hooks/block-bindings.js +35 -31
  472. package/build-module/hooks/block-bindings.js.map +1 -1
  473. package/build-module/hooks/content-lock-ui.js +10 -30
  474. package/build-module/hooks/content-lock-ui.js.map +1 -1
  475. package/build-module/hooks/duotone.js +0 -4
  476. package/build-module/hooks/duotone.js.map +1 -1
  477. package/build-module/hooks/layout.js +4 -2
  478. package/build-module/hooks/layout.js.map +1 -1
  479. package/build-module/hooks/spacing-visualizer.js +3 -3
  480. package/build-module/hooks/spacing-visualizer.js.map +1 -1
  481. package/build-module/hooks/style.js +1 -5
  482. package/build-module/hooks/style.js.map +1 -1
  483. package/build-module/hooks/use-bindings-attributes.js +19 -20
  484. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  485. package/build-module/hooks/use-zoom-out.js +7 -7
  486. package/build-module/hooks/use-zoom-out.js.map +1 -1
  487. package/build-module/layouts/constrained.js +44 -45
  488. package/build-module/layouts/constrained.js.map +1 -1
  489. package/build-module/layouts/flex.js +4 -1
  490. package/build-module/layouts/flex.js.map +1 -1
  491. package/build-module/layouts/grid.js +21 -18
  492. package/build-module/layouts/grid.js.map +1 -1
  493. package/build-module/layouts/utils.js +1 -7
  494. package/build-module/layouts/utils.js.map +1 -1
  495. package/build-module/private-apis.js +3 -4
  496. package/build-module/private-apis.js.map +1 -1
  497. package/build-module/store/actions.js +2 -7
  498. package/build-module/store/actions.js.map +1 -1
  499. package/build-module/store/private-actions.js +1 -0
  500. package/build-module/store/private-actions.js.map +1 -1
  501. package/build-module/store/private-keys.js +1 -0
  502. package/build-module/store/private-keys.js.map +1 -1
  503. package/build-module/store/private-selectors.js +15 -18
  504. package/build-module/store/private-selectors.js.map +1 -1
  505. package/build-module/store/reducer.js +1 -9
  506. package/build-module/store/reducer.js.map +1 -1
  507. package/build-module/store/selectors.js +22 -46
  508. package/build-module/store/selectors.js.map +1 -1
  509. package/build-module/store/utils.js +46 -0
  510. package/build-module/store/utils.js.map +1 -1
  511. package/build-module/utils/block-bindings.js +17 -12
  512. package/build-module/utils/block-bindings.js.map +1 -1
  513. package/build-module/utils/dom.js +99 -0
  514. package/build-module/utils/dom.js.map +1 -1
  515. package/build-module/utils/get-font-styles-and-weights.js +4 -4
  516. package/build-module/utils/get-font-styles-and-weights.js.map +1 -1
  517. package/build-module/utils/transform-styles/index.js +120 -16
  518. package/build-module/utils/transform-styles/index.js.map +1 -1
  519. package/build-style/content-rtl.css +19 -11
  520. package/build-style/content.css +19 -11
  521. package/build-style/style-rtl.css +27 -117
  522. package/build-style/style.css +27 -117
  523. package/build-types/utils/dom.d.ts +25 -0
  524. package/build-types/utils/dom.d.ts.map +1 -1
  525. package/package.json +34 -32
  526. package/src/components/block-alignment-matrix-control/index.js +1 -1
  527. package/src/components/block-breadcrumb/index.js +2 -2
  528. package/src/components/block-breadcrumb/style.scss +1 -30
  529. package/src/components/block-canvas/index.js +9 -1
  530. package/src/components/block-compare/block-view.js +6 -1
  531. package/src/components/block-compare/test/__snapshots__/block-view.js.snap +1 -1
  532. package/src/components/block-draggable/content.scss +1 -1
  533. package/src/components/block-draggable/index.js +4 -4
  534. package/src/components/block-draggable/style.scss +1 -1
  535. package/src/components/block-draggable/use-scroll-when-dragging.js +25 -25
  536. package/src/components/block-edit/multiple-usage-warning.js +2 -0
  537. package/src/components/block-inspector/index.js +22 -7
  538. package/src/components/block-inspector/style.scss +2 -4
  539. package/src/components/block-list/block-invalid-warning.js +3 -2
  540. package/src/components/block-list/block.js +6 -2
  541. package/src/components/block-list/content.scss +23 -3
  542. package/src/components/block-list/index.js +59 -38
  543. package/src/components/block-list/use-block-props/index.js +3 -0
  544. package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  545. package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +56 -0
  546. package/src/components/block-list/zoom-out-separator.js +110 -0
  547. package/src/components/block-lock/style.scss +1 -1
  548. package/src/components/block-lock/toolbar.js +3 -3
  549. package/src/components/block-mover/button.js +1 -0
  550. package/src/components/block-mover/index.js +1 -0
  551. package/src/components/block-mover/style.scss +1 -1
  552. package/src/components/block-navigation/dropdown.js +2 -0
  553. package/src/components/block-pattern-setup/index.js +3 -15
  554. package/src/components/block-pattern-setup/setup-toolbar.js +17 -4
  555. package/src/components/block-pattern-setup/style.scss +2 -2
  556. package/src/components/block-patterns-list/index.js +15 -18
  557. package/src/components/block-patterns-list/style.scss +2 -2
  558. package/src/components/block-patterns-paging/index.js +6 -0
  559. package/src/components/block-popover/index.js +7 -28
  560. package/src/components/block-popover/style.scss +1 -1
  561. package/src/components/block-quick-navigation/index.js +2 -0
  562. package/src/components/block-settings-menu-controls/index.js +7 -1
  563. package/src/components/block-switcher/index.js +45 -23
  564. package/src/components/block-switcher/pattern-transformations-menu.js +3 -12
  565. package/src/components/block-switcher/style.scss +5 -30
  566. package/src/components/block-toolbar/index.js +27 -11
  567. package/src/components/block-toolbar/shuffle.js +9 -7
  568. package/src/components/block-toolbar/style.scss +4 -1
  569. package/src/components/block-tools/block-selection-button.js +4 -0
  570. package/src/components/block-tools/block-toolbar-popover.js +10 -6
  571. package/src/components/block-tools/index.js +1 -1
  572. package/src/components/block-tools/style.scss +3 -4
  573. package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  574. package/src/components/block-tools/zoom-out-mode-inserters.js +2 -17
  575. package/src/components/block-tools/zoom-out-popover.js +3 -7
  576. package/src/components/block-tools/zoom-out-toolbar.js +31 -6
  577. package/src/components/block-variation-picker/README.md +2 -2
  578. package/src/components/block-variation-picker/index.js +6 -1
  579. package/src/components/block-variation-transforms/index.js +2 -0
  580. package/src/components/block-variation-transforms/style.scss +1 -1
  581. package/src/components/button-block-appender/content.scss +0 -1
  582. package/src/components/button-block-appender/index.js +30 -28
  583. package/src/components/color-palette/test/control.js +15 -2
  584. package/src/components/colors-gradients/dropdown.js +5 -1
  585. package/src/components/colors-gradients/style.scss +4 -4
  586. package/src/components/content-lock/index.js +1 -0
  587. package/src/components/content-lock/modify-content-lock-menu-item.js +58 -0
  588. package/src/components/default-block-appender/content.scss +0 -1
  589. package/src/components/editor-styles/index.js +4 -3
  590. package/src/components/global-styles/background-panel.js +6 -14
  591. package/src/components/global-styles/color-panel.js +8 -4
  592. package/src/components/global-styles/color-panel.native.js +2 -2
  593. package/src/components/global-styles/dimensions-panel.js +40 -40
  594. package/src/components/global-styles/filters-panel.js +5 -1
  595. package/src/components/global-styles/shadow-panel-components.js +11 -15
  596. package/src/components/global-styles/style.scss +3 -4
  597. package/src/components/global-styles/test/typography-utils.js +96 -5
  598. package/src/components/global-styles/test/utils.js +10 -0
  599. package/src/components/global-styles/typography-utils.js +22 -6
  600. package/src/components/global-styles/utils.js +4 -6
  601. package/src/components/grid/grid-item-movers.js +3 -3
  602. package/src/components/grid/grid-item-resizer.js +2 -2
  603. package/src/components/grid/style.scss +1 -1
  604. package/src/components/iframe/get-compatibility-styles.js +6 -1
  605. package/src/components/iframe/index.js +5 -5
  606. package/src/components/inner-blocks/index.js +2 -2
  607. package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  608. package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +2 -0
  609. package/src/components/inserter/block-patterns-tab/index.js +2 -0
  610. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +32 -15
  611. package/src/components/inserter/index.js +4 -10
  612. package/src/components/inserter/library.js +0 -2
  613. package/src/components/inserter/media-tab/hooks.js +3 -3
  614. package/src/components/inserter/media-tab/media-list.js +1 -7
  615. package/src/components/inserter/media-tab/media-preview.js +15 -8
  616. package/src/components/inserter/media-tab/media-tab.js +2 -0
  617. package/src/components/inserter/menu.js +15 -29
  618. package/src/components/inserter/quick-inserter.js +3 -4
  619. package/src/components/inserter/style.scss +10 -17
  620. package/src/components/inserter-list-item/index.js +4 -4
  621. package/src/components/inserter-list-item/style.scss +1 -3
  622. package/src/components/inserter-listbox/index.js +2 -11
  623. package/src/components/inserter-listbox/item.js +12 -14
  624. package/src/components/inserter-listbox/row.js +2 -9
  625. package/src/components/inspector-controls/groups.js +2 -0
  626. package/src/components/inspector-controls-tabs/index.js +2 -0
  627. package/src/components/inspector-controls-tabs/settings-tab.js +1 -0
  628. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +5 -2
  629. package/src/components/inspector-popover-header/index.js +4 -0
  630. package/src/components/letter-spacing-control/README.md +8 -1
  631. package/src/components/letter-spacing-control/index.js +7 -4
  632. package/src/components/link-control/index.js +17 -8
  633. package/src/components/link-control/settings-drawer.js +2 -0
  634. package/src/components/link-control/style.scss +1 -3
  635. package/src/components/list-view/block-select-button.js +2 -0
  636. package/src/components/list-view/index.js +3 -8
  637. package/src/components/list-view/style.scss +14 -16
  638. package/src/components/media-placeholder/README.md +2 -2
  639. package/src/components/media-placeholder/index.js +21 -4
  640. package/src/components/media-replace-flow/index.js +12 -1
  641. package/src/components/provider/use-block-sync.js +20 -20
  642. package/src/components/responsive-block-control/README.md +3 -27
  643. package/src/components/rich-text/content.scss +1 -1
  644. package/src/components/rich-text/event-listeners/paste-handler.js +6 -1
  645. package/src/components/rich-text/index.js +54 -41
  646. package/src/components/rich-text/style.scss +1 -1
  647. package/src/components/rich-text/use-mark-persistent.js +5 -5
  648. package/src/components/skip-to-selected-block/index.js +2 -0
  649. package/src/components/spacing-sizes-control/index.js +10 -13
  650. package/src/components/spacing-sizes-control/linked-button.js +32 -0
  651. package/src/components/spacing-sizes-control/style.scss +1 -0
  652. package/src/components/spacing-sizes-control/test/utils.js +14 -15
  653. package/src/components/spacing-sizes-control/utils.js +5 -18
  654. package/src/components/tool-selector/index.js +2 -0
  655. package/src/components/url-input/button.js +6 -0
  656. package/src/components/url-input/index.js +2 -0
  657. package/src/components/url-popover/stories/index.story.js +7 -1
  658. package/src/components/use-block-drop-zone/index.js +37 -5
  659. package/src/components/warning/content.scss +3 -10
  660. package/src/components/writing-flow/index.js +2 -0
  661. package/src/components/writing-flow/use-arrow-nav.js +9 -2
  662. package/src/components/writing-flow/use-event-redirect.js +72 -0
  663. package/src/components/writing-flow/use-input.js +36 -1
  664. package/src/components/writing-flow/use-select-all.js +18 -1
  665. package/src/components/writing-flow/use-selection-observer.js +23 -3
  666. package/src/components/writing-flow/use-tab-nav.js +4 -4
  667. package/src/components/writing-flow/utils.js +30 -0
  668. package/src/hooks/block-bindings.js +42 -43
  669. package/src/hooks/block-bindings.scss +1 -9
  670. package/src/hooks/content-lock-ui.js +11 -36
  671. package/src/hooks/duotone.js +0 -4
  672. package/src/hooks/layout.js +2 -1
  673. package/src/hooks/layout.scss +5 -27
  674. package/src/hooks/spacing-visualizer.js +3 -3
  675. package/src/hooks/style.js +1 -4
  676. package/src/hooks/use-bindings-attributes.js +23 -24
  677. package/src/hooks/use-zoom-out.js +7 -7
  678. package/src/layouts/constrained.js +53 -48
  679. package/src/layouts/flex.js +2 -0
  680. package/src/layouts/grid.js +29 -22
  681. package/src/layouts/test/grid.js +2 -2
  682. package/src/layouts/test/utils.js +6 -8
  683. package/src/layouts/utils.js +1 -9
  684. package/src/private-apis.js +2 -2
  685. package/src/store/actions.js +4 -6
  686. package/src/store/private-actions.js +1 -0
  687. package/src/store/private-keys.js +1 -0
  688. package/src/store/private-selectors.js +18 -14
  689. package/src/store/reducer.js +0 -7
  690. package/src/store/selectors.js +32 -51
  691. package/src/store/utils.js +50 -0
  692. package/src/utils/block-bindings.js +15 -16
  693. package/src/utils/dom.js +117 -0
  694. package/src/utils/get-font-styles-and-weights.js +12 -4
  695. package/src/utils/test/get-font-styles-and-weights.js +148 -0
  696. package/src/utils/test/transform-styles.js +259 -50
  697. package/src/utils/transform-styles/index.js +132 -21
  698. package/tsconfig.json +1 -0
  699. package/tsconfig.tsbuildinfo +1 -1
  700. package/build/components/spacing-sizes-control/sides-dropdown/index.js +0 -86
  701. package/build/components/spacing-sizes-control/sides-dropdown/index.js.map +0 -1
  702. package/build-module/components/spacing-sizes-control/sides-dropdown/index.js +0 -81
  703. package/build-module/components/spacing-sizes-control/sides-dropdown/index.js.map +0 -1
  704. package/src/components/spacing-sizes-control/sides-dropdown/index.js +0 -91
  705. package/src/utils/test/__snapshots__/transform-styles.js.snap +0 -109
@@ -1,3 +1,9 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { parse } from '@wordpress/blocks';
5
+ import { parse as grammarParse } from '@wordpress/block-serialization-default-parser';
6
+
1
7
  /**
2
8
  * Internal dependencies
3
9
  */
@@ -5,6 +11,46 @@ import { selectBlockPatternsKey } from './private-keys';
5
11
  import { unlock } from '../lock-unlock';
6
12
  import { STORE_NAME } from './constants';
7
13
  export const withRootClientIdOptionKey = Symbol('withRootClientId');
14
+ const parsedPatternCache = new WeakMap();
15
+ const grammarMapCache = new WeakMap();
16
+ function parsePattern(pattern) {
17
+ const blocks = parse(pattern.content, {
18
+ __unstableSkipMigrationLogs: true
19
+ });
20
+ if (blocks.length === 1) {
21
+ blocks[0].attributes = {
22
+ ...blocks[0].attributes,
23
+ metadata: {
24
+ ...(blocks[0].attributes.metadata || {}),
25
+ categories: pattern.categories,
26
+ patternName: pattern.name,
27
+ name: blocks[0].attributes.metadata?.name || pattern.title
28
+ }
29
+ };
30
+ }
31
+ return {
32
+ ...pattern,
33
+ blocks
34
+ };
35
+ }
36
+ export function getParsedPattern(pattern) {
37
+ let parsedPattern = parsedPatternCache.get(pattern);
38
+ if (!parsedPattern) {
39
+ parsedPattern = parsePattern(pattern);
40
+ parsedPatternCache.set(pattern, parsedPattern);
41
+ }
42
+ return parsedPattern;
43
+ }
44
+ export function getGrammar(pattern) {
45
+ let grammarMap = grammarMapCache.get(pattern);
46
+ if (!grammarMap) {
47
+ grammarMap = grammarParse(pattern.content);
48
+ // Block names are null only at the top level for whitespace.
49
+ grammarMap = grammarMap.filter(block => block.blockName !== null);
50
+ grammarMapCache.set(pattern, grammarMap);
51
+ }
52
+ return grammarMap;
53
+ }
8
54
  export const checkAllowList = (list, item, defaultResult = null) => {
9
55
  if (typeof list === 'boolean') {
10
56
  return list;
@@ -1 +1 @@
1
- {"version":3,"names":["selectBlockPatternsKey","unlock","STORE_NAME","withRootClientIdOptionKey","Symbol","checkAllowList","list","item","defaultResult","Array","isArray","includes","checkAllowListRecursive","blocks","allowedBlockTypes","blocksQueue","length","block","shift","isAllowed","name","blockName","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","select","state","settings","__experimentalBlockPatterns","__experimentalUserPatternCategories","__experimentalReusableBlocks","blockPatterns","getReusableBlocks","getInsertBlockTypeDependants","rootClientId","blockListSettings","byClientId","get","templateLock","blockEditingModes"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { selectBlockPatternsKey } from './private-keys';\nimport { unlock } from '../lock-unlock';\nimport { STORE_NAME } from './constants';\n\nexport const withRootClientIdOptionKey = Symbol( 'withRootClientId' );\n\nexport const checkAllowList = ( list, item, defaultResult = null ) => {\n\tif ( typeof list === 'boolean' ) {\n\t\treturn list;\n\t}\n\tif ( Array.isArray( list ) ) {\n\t\t// TODO: when there is a canonical way to detect that we are editing a post\n\t\t// the following check should be changed to something like:\n\t\t// if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )\n\t\tif ( list.includes( 'core/post-content' ) && item === null ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn list.includes( item );\n\t}\n\treturn defaultResult;\n};\n\nexport const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {\n\tif ( typeof allowedBlockTypes === 'boolean' ) {\n\t\treturn allowedBlockTypes;\n\t}\n\n\tconst blocksQueue = [ ...blocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\n\t\tconst isAllowed = checkAllowList(\n\t\t\tallowedBlockTypes,\n\t\t\tblock.name || block.blockName,\n\t\t\ttrue\n\t\t);\n\t\tif ( ! isAllowed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\n\treturn true;\n};\n\nexport const getAllPatternsDependants = ( select ) => ( state ) => {\n\treturn [\n\t\tstate.settings.__experimentalBlockPatterns,\n\t\tstate.settings.__experimentalUserPatternCategories,\n\t\tstate.settings.__experimentalReusableBlocks,\n\t\tstate.settings[ selectBlockPatternsKey ]?.( select ),\n\t\tstate.blockPatterns,\n\t\tunlock( select( STORE_NAME ) ).getReusableBlocks(),\n\t];\n};\n\nexport function getInsertBlockTypeDependants( state, rootClientId ) {\n\treturn [\n\t\tstate.blockListSettings[ rootClientId ],\n\t\tstate.blocks.byClientId.get( rootClientId ),\n\t\tstate.settings.allowedBlockTypes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockEditingModes,\n\t];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAsB,QAAQ,gBAAgB;AACvD,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,UAAU,QAAQ,aAAa;AAExC,OAAO,MAAMC,yBAAyB,GAAGC,MAAM,CAAE,kBAAmB,CAAC;AAErE,OAAO,MAAMC,cAAc,GAAGA,CAAEC,IAAI,EAAEC,IAAI,EAAEC,aAAa,GAAG,IAAI,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O,CAAC,EACpDC,KAAK,CAACK,aAAa,EACnBhC,MAAM,CAAE0B,MAAM,CAAEzB,UAAW,CAAE,CAAC,CAACgC,iBAAiB,CAAC,CAAC,CAClD;AACF,CAAC;AAED,OAAO,SAASC,4BAA4BA,CAAEP,KAAK,EAAEQ,YAAY,EAAG;EACnE,OAAO,CACNR,KAAK,CAACS,iBAAiB,CAAED,YAAY,CAAE,EACvCR,KAAK,CAACf,MAAM,CAACyB,UAAU,CAACC,GAAG,CAAEH,YAAa,CAAC,EAC3CR,KAAK,CAACC,QAAQ,CAACf,iBAAiB,EAChCc,KAAK,CAACC,QAAQ,CAACW,YAAY,EAC3BZ,KAAK,CAACa,iBAAiB,CACvB;AACF","ignoreList":[]}
1
+ {"version":3,"names":["parse","grammarParse","selectBlockPatternsKey","unlock","STORE_NAME","withRootClientIdOptionKey","Symbol","parsedPatternCache","WeakMap","grammarMapCache","parsePattern","pattern","blocks","content","__unstableSkipMigrationLogs","length","attributes","metadata","categories","patternName","name","title","getParsedPattern","parsedPattern","get","set","getGrammar","grammarMap","filter","block","blockName","checkAllowList","list","item","defaultResult","Array","isArray","includes","checkAllowListRecursive","allowedBlockTypes","blocksQueue","shift","isAllowed","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","select","state","settings","__experimentalBlockPatterns","__experimentalUserPatternCategories","__experimentalReusableBlocks","blockPatterns","getReusableBlocks","getInsertBlockTypeDependants","rootClientId","blockListSettings","byClientId","templateLock","blockEditingModes"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse } from '@wordpress/blocks';\nimport { parse as grammarParse } from '@wordpress/block-serialization-default-parser';\n\n/**\n * Internal dependencies\n */\nimport { selectBlockPatternsKey } from './private-keys';\nimport { unlock } from '../lock-unlock';\nimport { STORE_NAME } from './constants';\n\nexport const withRootClientIdOptionKey = Symbol( 'withRootClientId' );\n\nconst parsedPatternCache = new WeakMap();\nconst grammarMapCache = new WeakMap();\n\nfunction parsePattern( pattern ) {\n\tconst blocks = parse( pattern.content, {\n\t\t__unstableSkipMigrationLogs: true,\n\t} );\n\tif ( blocks.length === 1 ) {\n\t\tblocks[ 0 ].attributes = {\n\t\t\t...blocks[ 0 ].attributes,\n\t\t\tmetadata: {\n\t\t\t\t...( blocks[ 0 ].attributes.metadata || {} ),\n\t\t\t\tcategories: pattern.categories,\n\t\t\t\tpatternName: pattern.name,\n\t\t\t\tname: blocks[ 0 ].attributes.metadata?.name || pattern.title,\n\t\t\t},\n\t\t};\n\t}\n\treturn {\n\t\t...pattern,\n\t\tblocks,\n\t};\n}\n\nexport function getParsedPattern( pattern ) {\n\tlet parsedPattern = parsedPatternCache.get( pattern );\n\tif ( ! parsedPattern ) {\n\t\tparsedPattern = parsePattern( pattern );\n\t\tparsedPatternCache.set( pattern, parsedPattern );\n\t}\n\treturn parsedPattern;\n}\n\nexport function getGrammar( pattern ) {\n\tlet grammarMap = grammarMapCache.get( pattern );\n\tif ( ! grammarMap ) {\n\t\tgrammarMap = grammarParse( pattern.content );\n\t\t// Block names are null only at the top level for whitespace.\n\t\tgrammarMap = grammarMap.filter( ( block ) => block.blockName !== null );\n\t\tgrammarMapCache.set( pattern, grammarMap );\n\t}\n\treturn grammarMap;\n}\n\nexport const checkAllowList = ( list, item, defaultResult = null ) => {\n\tif ( typeof list === 'boolean' ) {\n\t\treturn list;\n\t}\n\tif ( Array.isArray( list ) ) {\n\t\t// TODO: when there is a canonical way to detect that we are editing a post\n\t\t// the following check should be changed to something like:\n\t\t// if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )\n\t\tif ( list.includes( 'core/post-content' ) && item === null ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn list.includes( item );\n\t}\n\treturn defaultResult;\n};\n\nexport const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {\n\tif ( typeof allowedBlockTypes === 'boolean' ) {\n\t\treturn allowedBlockTypes;\n\t}\n\n\tconst blocksQueue = [ ...blocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\n\t\tconst isAllowed = checkAllowList(\n\t\t\tallowedBlockTypes,\n\t\t\tblock.name || block.blockName,\n\t\t\ttrue\n\t\t);\n\t\tif ( ! isAllowed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\n\treturn true;\n};\n\nexport const getAllPatternsDependants = ( select ) => ( state ) => {\n\treturn [\n\t\tstate.settings.__experimentalBlockPatterns,\n\t\tstate.settings.__experimentalUserPatternCategories,\n\t\tstate.settings.__experimentalReusableBlocks,\n\t\tstate.settings[ selectBlockPatternsKey ]?.( select ),\n\t\tstate.blockPatterns,\n\t\tunlock( select( STORE_NAME ) ).getReusableBlocks(),\n\t];\n};\n\nexport function getInsertBlockTypeDependants( state, rootClientId ) {\n\treturn [\n\t\tstate.blockListSettings[ rootClientId ],\n\t\tstate.blocks.byClientId.get( rootClientId ),\n\t\tstate.settings.allowedBlockTypes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockEditingModes,\n\t];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,mBAAmB;AACzC,SAASA,KAAK,IAAIC,YAAY,QAAQ,+CAA+C;;AAErF;AACA;AACA;AACA,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,UAAU,QAAQ,aAAa;AAExC,OAAO,MAAMC,yBAAyB,GAAGC,MAAM,CAAE,kBAAmB,CAAC;AAErE,MAAMC,kBAAkB,GAAG,IAAIC,OAAO,CAAC,CAAC;AACxC,MAAMC,eAAe,GAAG,IAAID,OAAO,CAAC,CAAC;AAErC,SAASE,YAAYA,CAAEC,OAAO,EAAG;EAChC,MAAMC,MAAM,GAAGZ,KAAK,CAAEW,OAAO,CAACE,OAAO,EAAE;IACtCC,2BAA2B,EAAE;E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4BAA4B,EAC3CJ,KAAK,CAACC,QAAQ,CAAEhD,sBAAsB,CAAE,GAAI8C,MAAO,CAAC,EACpDC,KAAK,CAACK,aAAa,EACnBnD,MAAM,CAAE6C,MAAM,CAAE5C,UAAW,CAAE,CAAC,CAACmD,iBAAiB,CAAC,CAAC,CAClD;AACF,CAAC;AAED,OAAO,SAASC,4BAA4BA,CAAEP,KAAK,EAAEQ,YAAY,EAAG;EACnE,OAAO,CACNR,KAAK,CAACS,iBAAiB,CAAED,YAAY,CAAE,EACvCR,KAAK,CAACrC,MAAM,CAAC+C,UAAU,CAACnC,GAAG,CAAEiC,YAAa,CAAC,EAC3CR,KAAK,CAACC,QAAQ,CAACX,iBAAiB,EAChCU,KAAK,CAACC,QAAQ,CAACU,YAAY,EAC3BX,KAAK,CAACY,iBAAiB,CACvB;AACF","ignoreList":[]}
@@ -1,13 +1,16 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useDispatch, useSelect } from '@wordpress/data';
4
+ import { useDispatch, useRegistry } from '@wordpress/data';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
9
  import { store as blockEditorStore } from '../store';
10
10
  import { useBlockEditContext } from '../components/block-edit';
11
+ function isObjectEmpty(object) {
12
+ return !object || Object.keys(object).length === 0;
13
+ }
11
14
  export function useBlockBindingsUtils() {
12
15
  const {
13
16
  clientId
@@ -17,7 +20,7 @@ export function useBlockBindingsUtils() {
17
20
  } = useDispatch(blockEditorStore);
18
21
  const {
19
22
  getBlockAttributes
20
- } = useSelect(blockEditorStore);
23
+ } = useRegistry().select(blockEditorStore);
21
24
 
22
25
  /**
23
26
  * Updates the value of the bindings connected to block attributes.
@@ -50,10 +53,13 @@ export function useBlockBindingsUtils() {
50
53
  */
51
54
  const updateBlockBindings = bindings => {
52
55
  const {
53
- metadata
56
+ metadata: {
57
+ bindings: currentBindings,
58
+ ...metadata
59
+ } = {}
54
60
  } = getBlockAttributes(clientId);
55
61
  const newBindings = {
56
- ...metadata?.bindings
62
+ ...currentBindings
57
63
  };
58
64
  Object.entries(bindings).forEach(([attribute, binding]) => {
59
65
  if (!binding && newBindings[attribute]) {
@@ -66,11 +72,11 @@ export function useBlockBindingsUtils() {
66
72
  ...metadata,
67
73
  bindings: newBindings
68
74
  };
69
- if (Object.keys(newMetadata.bindings).length === 0) {
75
+ if (isObjectEmpty(newMetadata.bindings)) {
70
76
  delete newMetadata.bindings;
71
77
  }
72
78
  updateBlockAttributes(clientId, {
73
- metadata: Object.keys(newMetadata).length === 0 ? undefined : newMetadata
79
+ metadata: isObjectEmpty(newMetadata) ? undefined : newMetadata
74
80
  });
75
81
  };
76
82
 
@@ -87,14 +93,13 @@ export function useBlockBindingsUtils() {
87
93
  */
88
94
  const removeAllBlockBindings = () => {
89
95
  const {
90
- metadata
96
+ metadata: {
97
+ bindings,
98
+ ...metadata
99
+ } = {}
91
100
  } = getBlockAttributes(clientId);
92
- const newMetadata = {
93
- ...metadata
94
- };
95
- delete newMetadata.bindings;
96
101
  updateBlockAttributes(clientId, {
97
- metadata: Object.keys(newMetadata).length === 0 ? undefined : newMetadata
102
+ metadata: isObjectEmpty(metadata) ? undefined : metadata
98
103
  });
99
104
  };
100
105
  return {
@@ -1 +1 @@
1
- {"version":3,"names":["useDispatch","useSelect","store","blockEditorStore","useBlockEditContext","useBlockBindingsUtils","clientId","updateBlockAttributes","getBlockAttributes","updateBlockBindings","bindings","metadata","newBindings","Object","entries","forEach","attribute","binding","newMetadata","keys","length","undefined","removeAllBlockBindings"],"sources":["@wordpress/block-editor/src/utils/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit';\n\nexport function useBlockBindingsUtils() {\n\tconst { clientId } = useBlockEditContext();\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\n\t/**\n\t * Updates the value of the bindings connected to block attributes.\n\t * It removes the binding when the new value is `undefined`.\n\t *\n\t * @param {Object} bindings Bindings including the attributes to update and the new object.\n\t * @param {string} bindings.source The source name to connect to.\n\t * @param {Object} [bindings.args] Object containing the arguments needed by the source.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { updateBlockBindings } = useBlockBindingsUtils();\n\t * updateBlockBindings( {\n\t * url: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'url_custom_field',\n\t * },\n\t * \t },\n\t * alt: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'text_custom_field',\n\t * },\n\t * \t }\n\t * } );\n\t * ```\n\t */\n\tconst updateBlockBindings = ( bindings ) => {\n\t\tconst { metadata } = getBlockAttributes( clientId );\n\t\tconst newBindings = { ...metadata?.bindings };\n\t\tObject.entries( bindings ).forEach( ( [ attribute, binding ] ) => {\n\t\t\tif ( ! binding && newBindings[ attribute ] ) {\n\t\t\t\tdelete newBindings[ attribute ];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnewBindings[ attribute ] = binding;\n\t\t} );\n\n\t\tconst newMetadata = {\n\t\t\t...metadata,\n\t\t\tbindings: newBindings,\n\t\t};\n\n\t\tif ( Object.keys( newMetadata.bindings ).length === 0 ) {\n\t\t\tdelete newMetadata.bindings;\n\t\t}\n\n\t\tupdateBlockAttributes( clientId, {\n\t\t\tmetadata:\n\t\t\t\tObject.keys( newMetadata ).length === 0\n\t\t\t\t\t? undefined\n\t\t\t\t\t: newMetadata,\n\t\t} );\n\t};\n\n\t/**\n\t * Removes the bindings property of the `metadata` attribute.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { removeAllBlockBindings } = useBlockBindingsUtils();\n\t * removeAllBlockBindings();\n\t * ```\n\t */\n\tconst removeAllBlockBindings = () => {\n\t\tconst { metadata } = getBlockAttributes( clientId );\n\t\tconst newMetadata = { ...metadata };\n\t\tdelete newMetadata.bindings;\n\t\tupdateBlockAttributes( clientId, {\n\t\t\tmetadata:\n\t\t\t\tObject.keys( newMetadata ).length === 0\n\t\t\t\t\t? undefined\n\t\t\t\t\t: newMetadata,\n\t\t} );\n\t};\n\n\treturn { updateBlockBindings, removeAllBlockBindings };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,OAAO,SAASC,qBAAqBA,CAAA,EAAG;EACvC,MAAM;IAAEC;EAAS,CAAC,GAAGF,mBAAmB,CAAC,CAAC;EAC1C,MAAM;IAAEG;EAAsB,CAAC,GAAGP,WAAW,CAAEG,gBAAiB,CAAC;EACjE,MAAM;IAAEK;EAAmB,CAAC,GAAGP,SAAS,CAAEE,gBAAiB,CAAC;;EAE5D;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMM,mBAAmB,GAAKC,QAAQ,IAAM;IAC3C,MAAM;MAAEC;IAAS,CAAC,GAAGH,kBAAkB,CAAEF,QAAS,CAAC;IACnD,MAAMM,WAAW,GAAG;MAAE,GAAGD,QAAQ,EAAED;IAAS,CAAC;IAC7CG,MAAM,CAACC,OAAO,CAAEJ,QAAS,CAAC,CAACK,OAAO,CAAE,CAAE,CAAEC,SAAS,EAAEC,OAAO,CAAE,KAAM;MACjE,IAAK,CAAEA,OAAO,IAAIL,WAAW,CAAEI,SAAS,CAAE,EAAG;QAC5C,OAAOJ,WAAW,CAAEI,SAAS,CAAE;QAC/B;MACD;MACAJ,WAAW,CAAEI,SAAS,CAAE,GAAGC,OAAO;IACnC,CAAE,CAAC;IAEH,MAAMC,WAAW,GAAG;MACnB,GAAGP,QAAQ;MACXD,QAAQ,EAAEE;IACX,CAAC;IAED,IAAKC,MAAM,CAACM,IAAI,CAAED,WAAW,CAACR,QAAS,CAAC,CAACU,MAAM,KAAK,CAAC,EAAG;MACvD,OAAOF,WAAW,CAACR,QAAQ;IAC5B;IAEAH,qBAAqB,CAAED,QAAQ,EAAE;MAChCK,QAAQ,EACPE,MAAM,CAACM,IAAI,CAAED,WAAY,CAAC,CAACE,MAAM,KAAK,CAAC,GACpCC,SAAS,GACTH;IACL,CAAE,CAAC;EACJ,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMI,sBAAsB,GAAGA,CAAA,KAAM;IACpC,MAAM;MAAEX;IAAS,CAAC,GAAGH,kBAAkB,CAAEF,QAAS,CAAC;IACnD,MAAMY,WAAW,GAAG;MAAE,GAAGP;IAAS,CAAC;IACnC,OAAOO,WAAW,CAACR,QAAQ;IAC3BH,qBAAqB,CAAED,QAAQ,EAAE;MAChCK,QAAQ,EACPE,MAAM,CAACM,IAAI,CAAED,WAAY,CAAC,CAACE,MAAM,KAAK,CAAC,GACpCC,SAAS,GACTH;IACL,CAAE,CAAC;EACJ,CAAC;EAED,OAAO;IAAET,mBAAmB;IAAEa;EAAuB,CAAC;AACvD","ignoreList":[]}
1
+ {"version":3,"names":["useDispatch","useRegistry","store","blockEditorStore","useBlockEditContext","isObjectEmpty","object","Object","keys","length","useBlockBindingsUtils","clientId","updateBlockAttributes","getBlockAttributes","select","updateBlockBindings","bindings","metadata","currentBindings","newBindings","entries","forEach","attribute","binding","newMetadata","undefined","removeAllBlockBindings"],"sources":["@wordpress/block-editor/src/utils/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit';\n\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\nexport function useBlockBindingsUtils() {\n\tconst { clientId } = useBlockEditContext();\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { getBlockAttributes } = useRegistry().select( blockEditorStore );\n\n\t/**\n\t * Updates the value of the bindings connected to block attributes.\n\t * It removes the binding when the new value is `undefined`.\n\t *\n\t * @param {Object} bindings Bindings including the attributes to update and the new object.\n\t * @param {string} bindings.source The source name to connect to.\n\t * @param {Object} [bindings.args] Object containing the arguments needed by the source.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { updateBlockBindings } = useBlockBindingsUtils();\n\t * updateBlockBindings( {\n\t * url: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'url_custom_field',\n\t * },\n\t * \t },\n\t * alt: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'text_custom_field',\n\t * },\n\t * \t }\n\t * } );\n\t * ```\n\t */\n\tconst updateBlockBindings = ( bindings ) => {\n\t\tconst { metadata: { bindings: currentBindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( clientId );\n\t\tconst newBindings = { ...currentBindings };\n\n\t\tObject.entries( bindings ).forEach( ( [ attribute, binding ] ) => {\n\t\t\tif ( ! binding && newBindings[ attribute ] ) {\n\t\t\t\tdelete newBindings[ attribute ];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnewBindings[ attribute ] = binding;\n\t\t} );\n\n\t\tconst newMetadata = {\n\t\t\t...metadata,\n\t\t\tbindings: newBindings,\n\t\t};\n\n\t\tif ( isObjectEmpty( newMetadata.bindings ) ) {\n\t\t\tdelete newMetadata.bindings;\n\t\t}\n\n\t\tupdateBlockAttributes( clientId, {\n\t\t\tmetadata: isObjectEmpty( newMetadata ) ? undefined : newMetadata,\n\t\t} );\n\t};\n\n\t/**\n\t * Removes the bindings property of the `metadata` attribute.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { removeAllBlockBindings } = useBlockBindingsUtils();\n\t * removeAllBlockBindings();\n\t * ```\n\t */\n\tconst removeAllBlockBindings = () => {\n\t\tconst { metadata: { bindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( clientId );\n\t\tupdateBlockAttributes( clientId, {\n\t\t\tmetadata: isObjectEmpty( metadata ) ? undefined : metadata,\n\t\t} );\n\t};\n\n\treturn { updateBlockBindings, removeAllBlockBindings };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,iBAAiB;;AAE1D;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,SAASC,aAAaA,CAAEC,MAAM,EAAG;EAChC,OAAO,CAAEA,MAAM,IAAIC,MAAM,CAACC,IAAI,CAAEF,MAAO,CAAC,CAACG,MAAM,KAAK,CAAC;AACtD;AAEA,OAAO,SAASC,qBAAqBA,CAAA,EAAG;EACvC,MAAM;IAAEC;EAAS,CAAC,GAAGP,mBAAmB,CAAC,CAAC;EAC1C,MAAM;IAAEQ;EAAsB,CAAC,GAAGZ,WAAW,CAAEG,gBAAiB,CAAC;EACjE,MAAM;IAAEU;EAAmB,CAAC,GAAGZ,WAAW,CAAC,CAAC,CAACa,MAAM,CAAEX,gBAAiB,CAAC;;EAEvE;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMY,mBAAmB,GAAKC,QAAQ,IAAM;IAC3C,MAAM;MAAEC,QAAQ,EAAE;QAAED,QAAQ,EAAEE,eAAe;QAAE,GAAGD;MAAS,CAAC,GAAG,CAAC;IAAE,CAAC,GAClEJ,kBAAkB,CAAEF,QAAS,CAAC;IAC/B,MAAMQ,WAAW,GAAG;MAAE,GAAGD;IAAgB,CAAC;IAE1CX,MAAM,CAACa,OAAO,CAAEJ,QAAS,CAAC,CAACK,OAAO,CAAE,CAAE,CAAEC,SAAS,EAAEC,OAAO,CAAE,KAAM;MACjE,IAAK,CAAEA,OAAO,IAAIJ,WAAW,CAAEG,SAAS,CAAE,EAAG;QAC5C,OAAOH,WAAW,CAAEG,SAAS,CAAE;QAC/B;MACD;MACAH,WAAW,CAAEG,SAAS,CAAE,GAAGC,OAAO;IACnC,CAAE,CAAC;IAEH,MAAMC,WAAW,GAAG;MACnB,GAAGP,QAAQ;MACXD,QAAQ,EAAEG;IACX,CAAC;IAED,IAAKd,aAAa,CAAEmB,WAAW,CAACR,QAAS,CAAC,EAAG;MAC5C,OAAOQ,WAAW,CAACR,QAAQ;IAC5B;IAEAJ,qBAAqB,CAAED,QAAQ,EAAE;MAChCM,QAAQ,EAAEZ,aAAa,CAAEmB,WAAY,CAAC,GAAGC,SAAS,GAAGD;IACtD,CAAE,CAAC;EACJ,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAME,sBAAsB,GAAGA,CAAA,KAAM;IACpC,MAAM;MAAET,QAAQ,EAAE;QAAED,QAAQ;QAAE,GAAGC;MAAS,CAAC,GAAG,CAAC;IAAE,CAAC,GACjDJ,kBAAkB,CAAEF,QAAS,CAAC;IAC/BC,qBAAqB,CAAED,QAAQ,EAAE;MAChCM,QAAQ,EAAEZ,aAAa,CAAEY,QAAS,CAAC,GAAGQ,SAAS,GAAGR;IACnD,CAAE,CAAC;EACJ,CAAC;EAED,OAAO;IAAEF,mBAAmB;IAAEW;EAAuB,CAAC;AACvD","ignoreList":[]}
@@ -51,4 +51,103 @@ export function getBlockClientId(node) {
51
51
  }
52
52
  return blockNode.id.slice('block-'.length);
53
53
  }
54
+
55
+ /**
56
+ * Calculates the union of two rectangles.
57
+ *
58
+ * @param {DOMRect} rect1 First rectangle.
59
+ * @param {DOMRect} rect2 Second rectangle.
60
+ * @return {DOMRect} Union of the two rectangles.
61
+ */
62
+ export function rectUnion(rect1, rect2) {
63
+ const left = Math.min(rect1.left, rect2.left);
64
+ const right = Math.max(rect1.right, rect2.right);
65
+ const bottom = Math.max(rect1.bottom, rect2.bottom);
66
+ const top = Math.min(rect1.top, rect2.top);
67
+ return new window.DOMRectReadOnly(left, top, right - left, bottom - top);
68
+ }
69
+
70
+ /**
71
+ * Returns whether an element is visible.
72
+ *
73
+ * @param {Element} element Element.
74
+ * @return {boolean} Whether the element is visible.
75
+ */
76
+ function isElementVisible(element) {
77
+ const viewport = element.ownerDocument.defaultView;
78
+ if (!viewport) {
79
+ return false;
80
+ }
81
+
82
+ // Check for <VisuallyHidden> component.
83
+ if (element.classList.contains('components-visually-hidden')) {
84
+ return false;
85
+ }
86
+ const bounds = element.getBoundingClientRect();
87
+ if (bounds.width === 0 || bounds.height === 0) {
88
+ return false;
89
+ }
90
+
91
+ // Older browsers, e.g. Safari < 17.4 may not support the `checkVisibility` method.
92
+ if (element.checkVisibility) {
93
+ return element.checkVisibility?.({
94
+ opacityProperty: true,
95
+ contentVisibilityAuto: true,
96
+ visibilityProperty: true
97
+ });
98
+ }
99
+ const style = viewport.getComputedStyle(element);
100
+ if (style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0') {
101
+ return false;
102
+ }
103
+ return true;
104
+ }
105
+
106
+ /**
107
+ * Returns the rect of the element including all visible nested elements.
108
+ *
109
+ * Visible nested elements, including elements that overflow the parent, are
110
+ * taken into account.
111
+ *
112
+ * This function is useful for calculating the visible area of a block that
113
+ * contains nested elements that overflow the block, e.g. the Navigation block,
114
+ * which can contain overflowing Submenu blocks.
115
+ *
116
+ * The returned rect represents the full extent of the element and its visible
117
+ * children, which may extend beyond the viewport.
118
+ *
119
+ * @param {Element} element Element.
120
+ * @return {DOMRect} Bounding client rect of the element and its visible children.
121
+ */
122
+ export function getVisibleElementBounds(element) {
123
+ const viewport = element.ownerDocument.defaultView;
124
+ if (!viewport) {
125
+ return new window.DOMRectReadOnly();
126
+ }
127
+ let bounds = element.getBoundingClientRect();
128
+ const stack = [element];
129
+ let currentElement;
130
+ while (currentElement = stack.pop()) {
131
+ for (const child of currentElement.children) {
132
+ if (isElementVisible(child)) {
133
+ const childBounds = child.getBoundingClientRect();
134
+ bounds = rectUnion(bounds, childBounds);
135
+ stack.push(child);
136
+ }
137
+ }
138
+ }
139
+
140
+ /*
141
+ * Take into account the outer horizontal limits of the container in which
142
+ * an element is supposed to be "visible". For example, if an element is
143
+ * positioned -10px to the left of the window x value (0), this function
144
+ * discounts the negative overhang because it's not visible and therefore
145
+ * not to be counted in the visibility calculations. Top and bottom values
146
+ * are not accounted for to accommodate vertical scroll.
147
+ */
148
+ const left = Math.max(bounds.left, 0);
149
+ const right = Math.min(bounds.right, viewport.innerWidth);
150
+ bounds = new window.DOMRectReadOnly(left, bounds.top, right - left, bounds.height);
151
+ return bounds;
152
+ }
54
153
  //# sourceMappingURL=dom.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BLOCK_SELECTOR","APPENDER_SELECTOR","BLOCK_APPENDER_CLASS","isInSameBlock","a","b","closest","isInsideRootBlock","blockElement","element","parentBlock","join","getBlockClientId","node","nodeType","ELEMENT_NODE","parentNode","elementNode","blockNode","id","slice","length"],"sources":["@wordpress/block-editor/src/utils/dom.js"],"sourcesContent":["const BLOCK_SELECTOR = '.block-editor-block-list__block';\nconst APPENDER_SELECTOR = '.block-list-appender';\nconst BLOCK_APPENDER_CLASS = '.block-editor-button-block-appender';\n\n/**\n * Returns true if two elements are contained within the same block.\n *\n * @param {Element} a First element.\n * @param {Element} b Second element.\n *\n * @return {boolean} Whether elements are in the same block.\n */\nexport function isInSameBlock( a, b ) {\n\treturn a.closest( BLOCK_SELECTOR ) === b.closest( BLOCK_SELECTOR );\n}\n\n/**\n * Returns true if an element is considered part of the block and not its inner\n * blocks or appender.\n *\n * @param {Element} blockElement Block container element.\n * @param {Element} element Element.\n *\n * @return {boolean} Whether an element is considered part of the block and not\n * its inner blocks or appender.\n */\nexport function isInsideRootBlock( blockElement, element ) {\n\tconst parentBlock = element.closest(\n\t\t[ BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS ].join( ',' )\n\t);\n\treturn parentBlock === blockElement;\n}\n\n/**\n * Finds the block client ID given any DOM node inside the block.\n *\n * @param {Node?} node DOM node.\n *\n * @return {string|undefined} Client ID or undefined if the node is not part of\n * a block.\n */\nexport function getBlockClientId( node ) {\n\twhile ( node && node.nodeType !== node.ELEMENT_NODE ) {\n\t\tnode = node.parentNode;\n\t}\n\n\tif ( ! node ) {\n\t\treturn;\n\t}\n\n\tconst elementNode = /** @type {Element} */ ( node );\n\tconst blockNode = elementNode.closest( BLOCK_SELECTOR );\n\n\tif ( ! blockNode ) {\n\t\treturn;\n\t}\n\n\treturn blockNode.id.slice( 'block-'.length );\n}\n"],"mappings":"AAAA,MAAMA,cAAc,GAAG,iCAAiC;AACxD,MAAMC,iBAAiB,GAAG,sBAAsB;AAChD,MAAMC,oBAAoB,GAAG,qCAAqC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACrC,OAAOD,CAAC,CAACE,OAAO,CAAEN,cAAe,CAAC,KAAKK,CAAC,CAACC,OAAO,CAAEN,cAAe,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,iBAAiBA,CAAEC,YAAY,EAAEC,OAAO,EAAG;EAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACH,OAAO,CAClC,CAAEN,cAAc,EAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,CAACS,IAAI,CAAE,GAAI,CACvE,CAAC;EACD,OAAOD,WAAW,KAAKF,YAAY;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,gBAAgBA,CAAEC,IAAI,EAAG;EACxC,OAAQA,IAAI,IAAIA,IAAI,CAACC,QAAQ,KAAKD,IAAI,CAACE,YAAY,EAAG;IACrDF,IAAI,GAAGA,IAAI,CAACG,UAAU;EACvB;EAEA,IAAK,CAAEH,IAAI,EAAG;IACb;EACD;EAEA,MAAMI,WAAW,GAAG,sBAAyBJ,IAAM;EACnD,MAAMK,SAAS,GAAGD,WAAW,CAACX,OAAO,CAAEN,cAAe,CAAC;EAEvD,IAAK,CAAEkB,SAAS,EAAG;IAClB;EACD;EAEA,OAAOA,SAAS,CAACC,EAAE,CAACC,KAAK,CAAE,QAAQ,CAACC,MAAO,CAAC;AAC7C","ignoreList":[]}
1
+ {"version":3,"names":["BLOCK_SELECTOR","APPENDER_SELECTOR","BLOCK_APPENDER_CLASS","isInSameBlock","a","b","closest","isInsideRootBlock","blockElement","element","parentBlock","join","getBlockClientId","node","nodeType","ELEMENT_NODE","parentNode","elementNode","blockNode","id","slice","length","rectUnion","rect1","rect2","left","Math","min","right","max","bottom","top","window","DOMRectReadOnly","isElementVisible","viewport","ownerDocument","defaultView","classList","contains","bounds","getBoundingClientRect","width","height","checkVisibility","opacityProperty","contentVisibilityAuto","visibilityProperty","style","getComputedStyle","display","visibility","opacity","getVisibleElementBounds","stack","currentElement","pop","child","children","childBounds","push","innerWidth"],"sources":["@wordpress/block-editor/src/utils/dom.js"],"sourcesContent":["const BLOCK_SELECTOR = '.block-editor-block-list__block';\nconst APPENDER_SELECTOR = '.block-list-appender';\nconst BLOCK_APPENDER_CLASS = '.block-editor-button-block-appender';\n\n/**\n * Returns true if two elements are contained within the same block.\n *\n * @param {Element} a First element.\n * @param {Element} b Second element.\n *\n * @return {boolean} Whether elements are in the same block.\n */\nexport function isInSameBlock( a, b ) {\n\treturn a.closest( BLOCK_SELECTOR ) === b.closest( BLOCK_SELECTOR );\n}\n\n/**\n * Returns true if an element is considered part of the block and not its inner\n * blocks or appender.\n *\n * @param {Element} blockElement Block container element.\n * @param {Element} element Element.\n *\n * @return {boolean} Whether an element is considered part of the block and not\n * its inner blocks or appender.\n */\nexport function isInsideRootBlock( blockElement, element ) {\n\tconst parentBlock = element.closest(\n\t\t[ BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS ].join( ',' )\n\t);\n\treturn parentBlock === blockElement;\n}\n\n/**\n * Finds the block client ID given any DOM node inside the block.\n *\n * @param {Node?} node DOM node.\n *\n * @return {string|undefined} Client ID or undefined if the node is not part of\n * a block.\n */\nexport function getBlockClientId( node ) {\n\twhile ( node && node.nodeType !== node.ELEMENT_NODE ) {\n\t\tnode = node.parentNode;\n\t}\n\n\tif ( ! node ) {\n\t\treturn;\n\t}\n\n\tconst elementNode = /** @type {Element} */ ( node );\n\tconst blockNode = elementNode.closest( BLOCK_SELECTOR );\n\n\tif ( ! blockNode ) {\n\t\treturn;\n\t}\n\n\treturn blockNode.id.slice( 'block-'.length );\n}\n\n/**\n * Calculates the union of two rectangles.\n *\n * @param {DOMRect} rect1 First rectangle.\n * @param {DOMRect} rect2 Second rectangle.\n * @return {DOMRect} Union of the two rectangles.\n */\nexport function rectUnion( rect1, rect2 ) {\n\tconst left = Math.min( rect1.left, rect2.left );\n\tconst right = Math.max( rect1.right, rect2.right );\n\tconst bottom = Math.max( rect1.bottom, rect2.bottom );\n\tconst top = Math.min( rect1.top, rect2.top );\n\n\treturn new window.DOMRectReadOnly( left, top, right - left, bottom - top );\n}\n\n/**\n * Returns whether an element is visible.\n *\n * @param {Element} element Element.\n * @return {boolean} Whether the element is visible.\n */\nfunction isElementVisible( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\tif ( ! viewport ) {\n\t\treturn false;\n\t}\n\n\t// Check for <VisuallyHidden> component.\n\tif ( element.classList.contains( 'components-visually-hidden' ) ) {\n\t\treturn false;\n\t}\n\n\tconst bounds = element.getBoundingClientRect();\n\tif ( bounds.width === 0 || bounds.height === 0 ) {\n\t\treturn false;\n\t}\n\n\t// Older browsers, e.g. Safari < 17.4 may not support the `checkVisibility` method.\n\tif ( element.checkVisibility ) {\n\t\treturn element.checkVisibility?.( {\n\t\t\topacityProperty: true,\n\t\t\tcontentVisibilityAuto: true,\n\t\t\tvisibilityProperty: true,\n\t\t} );\n\t}\n\n\tconst style = viewport.getComputedStyle( element );\n\n\tif (\n\t\tstyle.display === 'none' ||\n\t\tstyle.visibility === 'hidden' ||\n\t\tstyle.opacity === '0'\n\t) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns the rect of the element including all visible nested elements.\n *\n * Visible nested elements, including elements that overflow the parent, are\n * taken into account.\n *\n * This function is useful for calculating the visible area of a block that\n * contains nested elements that overflow the block, e.g. the Navigation block,\n * which can contain overflowing Submenu blocks.\n *\n * The returned rect represents the full extent of the element and its visible\n * children, which may extend beyond the viewport.\n *\n * @param {Element} element Element.\n * @return {DOMRect} Bounding client rect of the element and its visible children.\n */\nexport function getVisibleElementBounds( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\tif ( ! viewport ) {\n\t\treturn new window.DOMRectReadOnly();\n\t}\n\n\tlet bounds = element.getBoundingClientRect();\n\n\tconst stack = [ element ];\n\tlet currentElement;\n\n\twhile ( ( currentElement = stack.pop() ) ) {\n\t\tfor ( const child of currentElement.children ) {\n\t\t\tif ( isElementVisible( child ) ) {\n\t\t\t\tconst childBounds = child.getBoundingClientRect();\n\t\t\t\tbounds = rectUnion( bounds, childBounds );\n\t\t\t\tstack.push( child );\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * Take into account the outer horizontal limits of the container in which\n\t * an element is supposed to be \"visible\". For example, if an element is\n\t * positioned -10px to the left of the window x value (0), this function\n\t * discounts the negative overhang because it's not visible and therefore\n\t * not to be counted in the visibility calculations. Top and bottom values\n\t * are not accounted for to accommodate vertical scroll.\n\t */\n\tconst left = Math.max( bounds.left, 0 );\n\tconst right = Math.min( bounds.right, viewport.innerWidth );\n\tbounds = new window.DOMRectReadOnly(\n\t\tleft,\n\t\tbounds.top,\n\t\tright - left,\n\t\tbounds.height\n\t);\n\n\treturn bounds;\n}\n"],"mappings":"AAAA,MAAMA,cAAc,GAAG,iCAAiC;AACxD,MAAMC,iBAAiB,GAAG,sBAAsB;AAChD,MAAMC,oBAAoB,GAAG,qCAAqC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACrC,OAAOD,CAAC,CAACE,OAAO,CAAEN,cAAe,CAAC,KAAKK,CAAC,CAACC,OAAO,CAAEN,cAAe,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,iBAAiBA,CAAEC,YAAY,EAAEC,OAAO,EAAG;EAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACH,OAAO,CAClC,CAAEN,cAAc,EAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,CAACS,IAAI,CAAE,GAAI,CACvE,CAAC;EACD,OAAOD,WAAW,KAAKF,YAAY;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,gBAAgBA,CAAEC,IAAI,EAAG;EACxC,OAAQA,IAAI,IAAIA,IAAI,CAACC,QAAQ,KAAKD,IAAI,CAACE,YAAY,EAAG;IACrDF,IAAI,GAAGA,IAAI,CAACG,UAAU;EACvB;EAEA,IAAK,CAAEH,IAAI,EAAG;IACb;EACD;EAEA,MAAMI,WAAW,GAAG,sBAAyBJ,IAAM;EACnD,MAAMK,SAAS,GAAGD,WAAW,CAACX,OAAO,CAAEN,cAAe,CAAC;EAEvD,IAAK,CAAEkB,SAAS,EAAG;IAClB;EACD;EAEA,OAAOA,SAAS,CAACC,EAAE,CAACC,KAAK,CAAE,QAAQ,CAACC,MAAO,CAAC;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAAEC,K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,GAAG,IAAIR,MAAM,CAACC,eAAe,CAClCR,IAAI,EACJe,MAAM,CAACT,GAAG,EACVH,KAAK,GAAGH,IAAI,EACZe,MAAM,CAACG,MACR,CAAC;EAED,OAAOH,MAAM;AACd","ignoreList":[]}
@@ -62,7 +62,7 @@ export function getFontStylesAndWeights(fontFamilyFaces) {
62
62
  let isVariableFont = false;
63
63
  fontFamilyFaces?.forEach(face => {
64
64
  // Check for variable font by looking for a space in the font weight value. e.g. "100 900"
65
- if (/\s/.test(face.fontWeight.trim())) {
65
+ if ('string' === typeof face.fontWeight && /\s/.test(face.fontWeight.trim())) {
66
66
  isVariableFont = true;
67
67
 
68
68
  // Find font weight start and end values.
@@ -84,16 +84,16 @@ export function getFontStylesAndWeights(fontFamilyFaces) {
84
84
  }
85
85
 
86
86
  // Format font style and weight values.
87
- const fontWeight = formatFontWeight(face.fontWeight);
87
+ const fontWeight = formatFontWeight('number' === typeof face.fontWeight ? face.fontWeight.toString() : face.fontWeight);
88
88
  const fontStyle = formatFontStyle(face.fontStyle);
89
89
 
90
90
  // Create font style and font weight lists without duplicates.
91
- if (fontStyle) {
91
+ if (fontStyle && Object.keys(fontStyle).length) {
92
92
  if (!fontStyles.some(style => style.value === fontStyle.value)) {
93
93
  fontStyles.push(fontStyle);
94
94
  }
95
95
  }
96
- if (fontWeight) {
96
+ if (fontWeight && Object.keys(fontWeight).length) {
97
97
  if (!fontWeights.some(weight => weight.value === fontWeight.value)) {
98
98
  if (!isVariableFont) {
99
99
  fontWeights.push(fontWeight);
@@ -1 +1 @@
1
- {"version":3,"names":["_x","__","sprintf","formatFontStyle","formatFontWeight","FONT_STYLES","name","value","FONT_WEIGHTS","getFontStylesAndWeights","fontFamilyFaces","fontStyles","fontWeights","combinedStyleAndWeightOptions","isSystemFont","length","isVariableFont","forEach","face","test","fontWeight","trim","startValue","endValue","split","parseInt","slice","i","fontWeightValue","toString","some","weight","push","fontStyle","style","styleName","styleValue","weightName","weightValue","optionName","key"],"sources":["@wordpress/block-editor/src/utils/get-font-styles-and-weights.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x, __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { formatFontStyle } from './format-font-style';\nimport { formatFontWeight } from './format-font-weight';\n\nconst FONT_STYLES = [\n\t{\n\t\tname: _x( 'Regular', 'font style' ),\n\t\tvalue: 'normal',\n\t},\n\t{\n\t\tname: _x( 'Italic', 'font style' ),\n\t\tvalue: 'italic',\n\t},\n];\n\nconst FONT_WEIGHTS = [\n\t{\n\t\tname: _x( 'Thin', 'font weight' ),\n\t\tvalue: '100',\n\t},\n\t{\n\t\tname: _x( 'Extra Light', 'font weight' ),\n\t\tvalue: '200',\n\t},\n\t{\n\t\tname: _x( 'Light', 'font weight' ),\n\t\tvalue: '300',\n\t},\n\t{\n\t\tname: _x( 'Regular', 'font weight' ),\n\t\tvalue: '400',\n\t},\n\t{\n\t\tname: _x( 'Medium', 'font weight' ),\n\t\tvalue: '500',\n\t},\n\t{\n\t\tname: _x( 'Semi Bold', 'font weight' ),\n\t\tvalue: '600',\n\t},\n\t{\n\t\tname: _x( 'Bold', 'font weight' ),\n\t\tvalue: '700',\n\t},\n\t{\n\t\tname: _x( 'Extra Bold', 'font weight' ),\n\t\tvalue: '800',\n\t},\n\t{\n\t\tname: _x( 'Black', 'font weight' ),\n\t\tvalue: '900',\n\t},\n\t{\n\t\tname: _x( 'Extra Black', 'font weight' ),\n\t\tvalue: '1000',\n\t},\n];\n\n/**\n * Builds a list of font style and weight options based on font family faces.\n * Defaults to the standard font styles and weights if no font family faces are provided.\n *\n * @param {Array} fontFamilyFaces font family faces array\n * @return {Object} new object with combined and separated font style and weight properties\n */\nexport function getFontStylesAndWeights( fontFamilyFaces ) {\n\tlet fontStyles = [];\n\tlet fontWeights = [];\n\tconst combinedStyleAndWeightOptions = [];\n\tconst isSystemFont = ! fontFamilyFaces || fontFamilyFaces?.length === 0;\n\tlet isVariableFont = false;\n\n\tfontFamilyFaces?.forEach( ( face ) => {\n\t\t// Check for variable font by looking for a space in the font weight value. e.g. \"100 900\"\n\t\tif ( /\\s/.test( face.fontWeight.trim() ) ) {\n\t\t\tisVariableFont = true;\n\n\t\t\t// Find font weight start and end values.\n\t\t\tlet [ startValue, endValue ] = face.fontWeight.split( ' ' );\n\t\t\tstartValue = parseInt( startValue.slice( 0, 1 ) );\n\t\t\tif ( endValue === '1000' ) {\n\t\t\t\tendValue = 10;\n\t\t\t} else {\n\t\t\t\tendValue = parseInt( endValue.slice( 0, 1 ) );\n\t\t\t}\n\n\t\t\t// Create font weight options for available variable weights.\n\t\t\tfor ( let i = startValue; i <= endValue; i++ ) {\n\t\t\t\tconst fontWeightValue = `${ i.toString() }00`;\n\t\t\t\tif (\n\t\t\t\t\t! fontWeights.some(\n\t\t\t\t\t\t( weight ) => weight.value === fontWeightValue\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tfontWeights.push( formatFontWeight( fontWeightValue ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Format font style and weight values.\n\t\tconst fontWeight = formatFontWeight( face.fontWeight );\n\t\tconst fontStyle = formatFontStyle( face.fontStyle );\n\n\t\t// Create font style and font weight lists without duplicates.\n\t\tif ( fontStyle ) {\n\t\t\tif (\n\t\t\t\t! fontStyles.some(\n\t\t\t\t\t( style ) => style.value === fontStyle.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tfontStyles.push( fontStyle );\n\t\t\t}\n\t\t}\n\t\tif ( fontWeight ) {\n\t\t\tif (\n\t\t\t\t! fontWeights.some(\n\t\t\t\t\t( weight ) => weight.value === fontWeight.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif ( ! isVariableFont ) {\n\t\t\t\t\tfontWeights.push( fontWeight );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} );\n\n\t// If there is no font weight of 600 or above, then include faux bold as an option.\n\tif ( ! fontWeights.some( ( weight ) => weight.value >= '600' ) ) {\n\t\tfontWeights.push( {\n\t\t\tname: _x( 'Bold', 'font weight' ),\n\t\t\tvalue: '700',\n\t\t} );\n\t}\n\n\t// If there is no italic font style, then include faux italic as an option.\n\tif ( ! fontStyles.some( ( style ) => style.value === 'italic' ) ) {\n\t\tfontStyles.push( {\n\t\t\tname: _x( 'Italic', 'font style' ),\n\t\t\tvalue: 'italic',\n\t\t} );\n\t}\n\n\t// Use default font styles and weights for system fonts.\n\tif ( isSystemFont ) {\n\t\tfontStyles = FONT_STYLES;\n\t\tfontWeights = FONT_WEIGHTS;\n\t}\n\n\t// Use default styles and weights if there are no available styles or weights from the provided font faces.\n\tfontStyles = fontStyles.length === 0 ? FONT_STYLES : fontStyles;\n\tfontWeights = fontWeights.length === 0 ? FONT_WEIGHTS : fontWeights;\n\n\t// Generate combined font style and weight options for available fonts.\n\tfontStyles.forEach( ( { name: styleName, value: styleValue } ) => {\n\t\tfontWeights.forEach( ( { name: weightName, value: weightValue } ) => {\n\t\t\tconst optionName =\n\t\t\t\tstyleValue === 'normal'\n\t\t\t\t\t? weightName\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: 1: Font weight name. 2: Font style name. */\n\t\t\t\t\t\t\t__( '%1$s %2$s' ),\n\t\t\t\t\t\t\tweightName,\n\t\t\t\t\t\t\tstyleName\n\t\t\t\t\t );\n\n\t\t\tcombinedStyleAndWeightOptions.push( {\n\t\t\t\tkey: `${ styleValue }-${ weightValue }`,\n\t\t\t\tname: optionName,\n\t\t\t\tstyle: {\n\t\t\t\t\tfontStyle: styleValue,\n\t\t\t\t\tfontWeight: weightValue,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t} );\n\n\treturn {\n\t\tfontStyles,\n\t\tfontWeights,\n\t\tcombinedStyleAndWeightOptions,\n\t\tisSystemFont,\n\t\tisVariableFont,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAEj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W,CAACG,MAAM,KAAK,CAAC,GAAGP,YAAY,GAAGI,WAAW;;EAEnE;EACAD,UAAU,CAACM,OAAO,CAAE,CAAE;IAAEX,IAAI,EAAE6B,SAAS;IAAE5B,KAAK,EAAE6B;EAAW,CAAC,KAAM;IACjExB,WAAW,CAACK,OAAO,CAAE,CAAE;MAAEX,IAAI,EAAE+B,UAAU;MAAE9B,KAAK,EAAE+B;IAAY,CAAC,KAAM;MACpE,MAAMC,UAAU,GACfH,UAAU,KAAK,QAAQ,GACpBC,UAAU,GACVnC,OAAO,EACP;MACAD,EAAE,CAAE,WAAY,CAAC,EACjBoC,UAAU,EACVF,SACA,CAAC;MAELtB,6BAA6B,CAACmB,IAAI,CAAE;QACnCQ,GAAG,EAAG,GAAGJ,UAAY,IAAIE,WAAa,EAAC;QACvChC,IAAI,EAAEiC,UAAU;QAChBL,KAAK,EAAE;UACND,SAAS,EAAEG,UAAU;UACrBhB,UAAU,EAAEkB;QACb;MACD,CAAE,CAAC;IACJ,CAAE,CAAC;EACJ,CAAE,CAAC;EAEH,OAAO;IACN3B,UAAU;IACVC,WAAW;IACXC,6BAA6B;IAC7BC,YAAY;IACZE;EACD,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_x","__","sprintf","formatFontStyle","formatFontWeight","FONT_STYLES","name","value","FONT_WEIGHTS","getFontStylesAndWeights","fontFamilyFaces","fontStyles","fontWeights","combinedStyleAndWeightOptions","isSystemFont","length","isVariableFont","forEach","face","fontWeight","test","trim","startValue","endValue","split","parseInt","slice","i","fontWeightValue","toString","some","weight","push","fontStyle","Object","keys","style","styleName","styleValue","weightName","weightValue","optionName","key"],"sources":["@wordpress/block-editor/src/utils/get-font-styles-and-weights.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x, __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { formatFontStyle } from './format-font-style';\nimport { formatFontWeight } from './format-font-weight';\n\nconst FONT_STYLES = [\n\t{\n\t\tname: _x( 'Regular', 'font style' ),\n\t\tvalue: 'normal',\n\t},\n\t{\n\t\tname: _x( 'Italic', 'font style' ),\n\t\tvalue: 'italic',\n\t},\n];\n\nconst FONT_WEIGHTS = [\n\t{\n\t\tname: _x( 'Thin', 'font weight' ),\n\t\tvalue: '100',\n\t},\n\t{\n\t\tname: _x( 'Extra Light', 'font weight' ),\n\t\tvalue: '200',\n\t},\n\t{\n\t\tname: _x( 'Light', 'font weight' ),\n\t\tvalue: '300',\n\t},\n\t{\n\t\tname: _x( 'Regular', 'font weight' ),\n\t\tvalue: '400',\n\t},\n\t{\n\t\tname: _x( 'Medium', 'font weight' ),\n\t\tvalue: '500',\n\t},\n\t{\n\t\tname: _x( 'Semi Bold', 'font weight' ),\n\t\tvalue: '600',\n\t},\n\t{\n\t\tname: _x( 'Bold', 'font weight' ),\n\t\tvalue: '700',\n\t},\n\t{\n\t\tname: _x( 'Extra Bold', 'font weight' ),\n\t\tvalue: '800',\n\t},\n\t{\n\t\tname: _x( 'Black', 'font weight' ),\n\t\tvalue: '900',\n\t},\n\t{\n\t\tname: _x( 'Extra Black', 'font weight' ),\n\t\tvalue: '1000',\n\t},\n];\n\n/**\n * Builds a list of font style and weight options based on font family faces.\n * Defaults to the standard font styles and weights if no font family faces are provided.\n *\n * @param {Array} fontFamilyFaces font family faces array\n * @return {Object} new object with combined and separated font style and weight properties\n */\nexport function getFontStylesAndWeights( fontFamilyFaces ) {\n\tlet fontStyles = [];\n\tlet fontWeights = [];\n\tconst combinedStyleAndWeightOptions = [];\n\tconst isSystemFont = ! fontFamilyFaces || fontFamilyFaces?.length === 0;\n\tlet isVariableFont = false;\n\n\tfontFamilyFaces?.forEach( ( face ) => {\n\t\t// Check for variable font by looking for a space in the font weight value. e.g. \"100 900\"\n\t\tif (\n\t\t\t'string' === typeof face.fontWeight &&\n\t\t\t/\\s/.test( face.fontWeight.trim() )\n\t\t) {\n\t\t\tisVariableFont = true;\n\n\t\t\t// Find font weight start and end values.\n\t\t\tlet [ startValue, endValue ] = face.fontWeight.split( ' ' );\n\t\t\tstartValue = parseInt( startValue.slice( 0, 1 ) );\n\t\t\tif ( endValue === '1000' ) {\n\t\t\t\tendValue = 10;\n\t\t\t} else {\n\t\t\t\tendValue = parseInt( endValue.slice( 0, 1 ) );\n\t\t\t}\n\n\t\t\t// Create font weight options for available variable weights.\n\t\t\tfor ( let i = startValue; i <= endValue; i++ ) {\n\t\t\t\tconst fontWeightValue = `${ i.toString() }00`;\n\t\t\t\tif (\n\t\t\t\t\t! fontWeights.some(\n\t\t\t\t\t\t( weight ) => weight.value === fontWeightValue\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tfontWeights.push( formatFontWeight( fontWeightValue ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Format font style and weight values.\n\t\tconst fontWeight = formatFontWeight(\n\t\t\t'number' === typeof face.fontWeight\n\t\t\t\t? face.fontWeight.toString()\n\t\t\t\t: face.fontWeight\n\t\t);\n\t\tconst fontStyle = formatFontStyle( face.fontStyle );\n\n\t\t// Create font style and font weight lists without duplicates.\n\t\tif ( fontStyle && Object.keys( fontStyle ).length ) {\n\t\t\tif (\n\t\t\t\t! fontStyles.some(\n\t\t\t\t\t( style ) => style.value === fontStyle.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tfontStyles.push( fontStyle );\n\t\t\t}\n\t\t}\n\n\t\tif ( fontWeight && Object.keys( fontWeight ).length ) {\n\t\t\tif (\n\t\t\t\t! fontWeights.some(\n\t\t\t\t\t( weight ) => weight.value === fontWeight.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif ( ! isVariableFont ) {\n\t\t\t\t\tfontWeights.push( fontWeight );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} );\n\n\t// If there is no font weight of 600 or above, then include faux bold as an option.\n\tif ( ! fontWeights.some( ( weight ) => weight.value >= '600' ) ) {\n\t\tfontWeights.push( {\n\t\t\tname: _x( 'Bold', 'font weight' ),\n\t\t\tvalue: '700',\n\t\t} );\n\t}\n\n\t// If there is no italic font style, then include faux italic as an option.\n\tif ( ! fontStyles.some( ( style ) => style.value === 'italic' ) ) {\n\t\tfontStyles.push( {\n\t\t\tname: _x( 'Italic', 'font style' ),\n\t\t\tvalue: 'italic',\n\t\t} );\n\t}\n\n\t// Use default font styles and weights for system fonts.\n\tif ( isSystemFont ) {\n\t\tfontStyles = FONT_STYLES;\n\t\tfontWeights = FONT_WEIGHTS;\n\t}\n\n\t// Use default styles and weights if there are no available styles or weights from the provided font faces.\n\tfontStyles = fontStyles.length === 0 ? FONT_STYLES : fontStyles;\n\tfontWeights = fontWeights.length === 0 ? FONT_WEIGHTS : fontWeights;\n\n\t// Generate combined font style and weight options for available fonts.\n\tfontStyles.forEach( ( { name: styleName, value: styleValue } ) => {\n\t\tfontWeights.forEach( ( { name: weightName, value: weightValue } ) => {\n\t\t\tconst optionName =\n\t\t\t\tstyleValue === 'normal'\n\t\t\t\t\t? weightName\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: 1: Font weight name. 2: Font style name. */\n\t\t\t\t\t\t\t__( '%1$s %2$s' ),\n\t\t\t\t\t\t\tweightName,\n\t\t\t\t\t\t\tstyleName\n\t\t\t\t\t );\n\n\t\t\tcombinedStyleAndWeightOptions.push( {\n\t\t\t\tkey: `${ styleValue }-${ weightValue }`,\n\t\t\t\tname: optionName,\n\t\t\t\tstyle: {\n\t\t\t\t\tfontStyle: styleValue,\n\t\t\t\t\tfontWeight: weightValue,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t} );\n\n\treturn {\n\t\tfontStyles,\n\t\tfontWeights,\n\t\tcombinedStyleAndWeightOptions,\n\t\tisSystemFont,\n\t\tisVariableFont,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAEjD;AACA;AACA;AACA,SAASC,eAAe,QAAQ,qBAAqB;AACrD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EACJ;;EAEA;EACA,IAAKO,YAAY,EAAG;IACnBH,UAAU,GAAGN,WAAW;IACxBO,WAAW,GAAGJ,YAAY;EAC3B;;EAEA;EACAG,UAAU,GAAGA,UAAU,CAACI,MAAM,KAAK,CAAC,GAAGV,WAAW,GAAGM,UAAU;EAC/DC,WAAW,GAAGA,WAAW,CAACG,MAAM,KAAK,CAAC,GAAGP,YAAY,GAAGI,WAAW;;EAEnE;EACAD,UAAU,CAACM,OAAO,CAAE,CAAE;IAAEX,IAAI,EAAE+B,SAAS;IAAE9B,KAAK,EAAE+B;EAAW,CAAC,KAAM;IACjE1B,WAAW,CAACK,OAAO,CAAE,CAAE;MAAEX,IAAI,EAAEiC,UAAU;MAAEhC,KAAK,EAAEiC;IAAY,CAAC,KAAM;MACpE,MAAMC,UAAU,GACfH,UAAU,KAAK,QAAQ,GACpBC,UAAU,GACVrC,OAAO,EACP;MACAD,EAAE,CAAE,WAAY,CAAC,EACjBsC,UAAU,EACVF,SACA,CAAC;MAELxB,6BAA6B,CAACmB,IAAI,CAAE;QACnCU,GAAG,EAAG,GAAGJ,UAAY,IAAIE,WAAa,EAAC;QACvClC,IAAI,EAAEmC,UAAU;QAChBL,KAAK,EAAE;UACNH,SAAS,EAAEK,UAAU;UACrBnB,UAAU,EAAEqB;QACb;MACD,CAAE,CAAC;IACJ,CAAE,CAAC;EACJ,CAAE,CAAC;EAEH,OAAO;IACN7B,UAAU;IACVC,WAAW;IACXC,6BAA6B;IAC7BC,YAAY;IACZE;EACD,CAAC;AACF","ignoreList":[]}
@@ -1,29 +1,125 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
+ import * as parsel from 'parsel-js';
4
5
  import postcss, { CssSyntaxError } from 'postcss';
5
- import wrap from 'postcss-prefixwrap';
6
+ import prefixSelector from 'postcss-prefix-selector';
6
7
  import rebaseUrl from 'postcss-urlrebase';
7
8
  const cacheByWrapperSelector = new Map();
9
+ const ROOT_SELECTOR_TOKENS = [{
10
+ type: 'type',
11
+ content: 'body'
12
+ }, {
13
+ type: 'type',
14
+ content: 'html'
15
+ }, {
16
+ type: 'pseudo-class',
17
+ content: ':root'
18
+ }, {
19
+ type: 'pseudo-class',
20
+ content: ':where(body)'
21
+ }, {
22
+ type: 'pseudo-class',
23
+ content: ':where(:root)'
24
+ }, {
25
+ type: 'pseudo-class',
26
+ content: ':where(html)'
27
+ }];
28
+
29
+ /**
30
+ * Prefixes root selectors in a way that ensures consistent specificity.
31
+ * This requires special handling, since prefixing a classname before
32
+ * html, body, or :root will generally result in an invalid selector.
33
+ *
34
+ * Some libraries will simply replace the root selector with the prefix
35
+ * instead, but this results in inconsistent specificity.
36
+ *
37
+ * This function instead inserts the prefix after the root tags but before
38
+ * any other part of the selector. This results in consistent specificity:
39
+ * - If a `:where()` selector is used for the prefix, all selectors output
40
+ * by `transformStyles` will have no specificity increase.
41
+ * - If a classname, id, or something else is used as the prefix, all selectors
42
+ * will have the same specificity bump when transformed.
43
+ *
44
+ * @param {string} prefix The prefix.
45
+ * @param {string} selector The selector.
46
+ *
47
+ * @return {string} The prefixed root selector.
48
+ */
49
+ function prefixRootSelector(prefix, selector) {
50
+ // Use a tokenizer, since regular expressions are unreliable.
51
+ const tokenized = parsel.tokenize(selector);
52
+
53
+ // Find the last token that contains a root selector by walking back
54
+ // through the tokens.
55
+ const lastRootIndex = tokenized.findLastIndex(({
56
+ content,
57
+ type
58
+ }) => {
59
+ return ROOT_SELECTOR_TOKENS.some(rootSelector => content === rootSelector.content && type === rootSelector.type);
60
+ });
61
+
62
+ // Walk forwards to find the combinator after the last root.
63
+ // This is where the root ends and the rest of the selector begins,
64
+ // and the index to insert before.
65
+ // Doing it this way takes into account that a root selector like
66
+ // 'body' may have additional id/class/pseudo-class/attribute-selector
67
+ // parts chained to it, which is difficult to quantify using a regex.
68
+ let insertionPoint = -1;
69
+ for (let i = lastRootIndex + 1; i < tokenized.length; i++) {
70
+ if (tokenized[i].type === 'combinator') {
71
+ insertionPoint = i;
72
+ break;
73
+ }
74
+ }
75
+
76
+ // Tokenize and insert the prefix with a ' ' combinator before it.
77
+ const tokenizedPrefix = parsel.tokenize(prefix);
78
+ tokenized.splice(
79
+ // Insert at the insertion point, or the end.
80
+ insertionPoint === -1 ? tokenized.length : insertionPoint, 0, {
81
+ type: 'combinator',
82
+ content: ' '
83
+ }, ...tokenizedPrefix);
84
+ return parsel.stringify(tokenized);
85
+ }
8
86
  function transformStyle({
9
87
  css,
10
88
  ignoredSelectors = [],
11
89
  baseURL
12
- }, wrapperSelector = '') {
13
- // When there is no wrapper selector or base URL, there is no need
90
+ }, wrapperSelector = '', transformOptions) {
91
+ // When there is no wrapper selector and no base URL, there is no need
14
92
  // to transform the CSS. This is most cases because in the default
15
93
  // iframed editor, no wrapping is needed, and not many styles
16
94
  // provide a base URL.
17
95
  if (!wrapperSelector && !baseURL) {
18
96
  return css;
19
97
  }
20
- const postcssFriendlyCSS = css.replace(/:root :where\(body\)/g, 'body').replace(/:where\(body\)/g, 'body');
21
98
  try {
22
- return postcss([wrapperSelector && wrap(wrapperSelector, {
23
- ignoredSelectors: [...ignoredSelectors, wrapperSelector]
99
+ var _transformOptions$ign;
100
+ const excludedSelectors = [...ignoredSelectors, ...((_transformOptions$ign = transformOptions?.ignoredSelectors) !== null && _transformOptions$ign !== void 0 ? _transformOptions$ign : []), wrapperSelector];
101
+ return postcss([wrapperSelector && prefixSelector({
102
+ prefix: wrapperSelector,
103
+ transform(prefix, selector, prefixedSelector) {
104
+ // For backwards compatibility, don't use the `exclude` option
105
+ // of postcss-prefix-selector, instead handle it here to match
106
+ // the behavior of the old library (postcss-prefix-wrap) that
107
+ // `transformStyle` previously used.
108
+ if (excludedSelectors.some(excludedSelector => excludedSelector instanceof RegExp ? selector.match(excludedSelector) : selector.includes(excludedSelector))) {
109
+ return selector;
110
+ }
111
+ const hasRootSelector = ROOT_SELECTOR_TOKENS.some(rootSelector => selector.startsWith(rootSelector.content));
112
+
113
+ // Reorganize root selectors such that the root part comes before the prefix,
114
+ // but the prefix still comes before the remaining part of the selector.
115
+ if (hasRootSelector) {
116
+ return prefixRootSelector(prefix, selector);
117
+ }
118
+ return prefixedSelector;
119
+ }
24
120
  }), baseURL && rebaseUrl({
25
121
  rootUrl: baseURL
26
- })].filter(Boolean)).process(postcssFriendlyCSS, {}).css; // use sync PostCSS API
122
+ })].filter(Boolean)).process(css, {}).css; // use sync PostCSS API
27
123
  } catch (error) {
28
124
  if (error instanceof CssSyntaxError) {
29
125
  // eslint-disable-next-line no-console
@@ -37,18 +133,26 @@ function transformStyle({
37
133
  }
38
134
 
39
135
  /**
40
- * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.
41
- *
42
136
  * @typedef {Object} EditorStyle
43
- * @property {string} css the CSS block(s), as a single string.
44
- * @property {?string} baseURL the base URL to be used as the reference when rewritting urls.
45
- * @property {?string[]} ignoredSelectors the selectors not to wrap.
137
+ * @property {string} css the CSS block(s), as a single string.
138
+ * @property {?string} baseURL the base URL to be used as the reference when rewritting urls.
139
+ * @property {?string[]} ignoredSelectors the selectors not to wrap.
140
+ */
141
+
142
+ /**
143
+ * @typedef {Object} TransformOptions
144
+ * @property {?string[]} ignoredSelectors the selectors not to wrap.
145
+ */
146
+
147
+ /**
148
+ * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.
46
149
  *
47
- * @param {EditorStyle[]} styles CSS rules.
48
- * @param {string} wrapperSelector Wrapper selector.
150
+ * @param {EditorStyle[]} styles CSS rules.
151
+ * @param {string} wrapperSelector Wrapper selector.
152
+ * @param {TransformOptions} transformOptions Additional options for style transformation.
49
153
  * @return {Array} converted rules.
50
154
  */
51
- const transformStyles = (styles, wrapperSelector = '') => {
155
+ const transformStyles = (styles, wrapperSelector = '', transformOptions) => {
52
156
  let cache = cacheByWrapperSelector.get(wrapperSelector);
53
157
  if (!cache) {
54
158
  cache = new WeakMap();
@@ -57,7 +161,7 @@ const transformStyles = (styles, wrapperSelector = '') => {
57
161
  return styles.map(style => {
58
162
  let css = cache.get(style);
59
163
  if (!css) {
60
- css = transformStyle(style, wrapperSelector);
164
+ css = transformStyle(style, wrapperSelector, transformOptions);
61
165
  cache.set(style, css);
62
166
  }
63
167
  return css;
@@ -1 +1 @@
1
- {"version":3,"names":["postcss","CssSyntaxError","wrap","rebaseUrl","cacheByWrapperSelector","Map","transformStyle","css","ignoredSelectors","baseURL","wrapperSelector","postcssFriendlyCSS","replace","rootUrl","filter","Boolean","process","error","console","warn","message","showSourceCode","transformStyles","styles","cache","get","WeakMap","set","map","style"],"sources":["@wordpress/block-editor/src/utils/transform-styles/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport postcss, { CssSyntaxError } from 'postcss';\nimport wrap from 'postcss-prefixwrap';\nimport rebaseUrl from 'postcss-urlrebase';\n\nconst cacheByWrapperSelector = new Map();\n\nfunction transformStyle(\n\t{ css, ignoredSelectors = [], baseURL },\n\twrapperSelector = ''\n) {\n\t// When there is no wrapper selector or base URL, there is no need\n\t// to transform the CSS. This is most cases because in the default\n\t// iframed editor, no wrapping is needed, and not many styles\n\t// provide a base URL.\n\tif ( ! wrapperSelector && ! baseURL ) {\n\t\treturn css;\n\t}\n\tconst postcssFriendlyCSS = css\n\t\t.replace( /:root :where\\(body\\)/g, 'body' )\n\t\t.replace( /:where\\(body\\)/g, 'body' );\n\ttry {\n\t\treturn postcss(\n\t\t\t[\n\t\t\t\twrapperSelector &&\n\t\t\t\t\twrap( wrapperSelector, {\n\t\t\t\t\t\tignoredSelectors: [\n\t\t\t\t\t\t\t...ignoredSelectors,\n\t\t\t\t\t\t\twrapperSelector,\n\t\t\t\t\t\t],\n\t\t\t\t\t} ),\n\t\t\t\tbaseURL && rebaseUrl( { rootUrl: baseURL } ),\n\t\t\t].filter( Boolean )\n\t\t).process( postcssFriendlyCSS, {} ).css; // use sync PostCSS API\n\t} catch ( error ) {\n\t\tif ( error instanceof CssSyntaxError ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror.message + '\\n' + error.showSourceCode( false )\n\t\t\t);\n\t\t} else {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\n/**\n * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.\n *\n * @typedef {Object} EditorStyle\n * @property {string} css the CSS block(s), as a single string.\n * @property {?string} baseURL the base URL to be used as the reference when rewritting urls.\n * @property {?string[]} ignoredSelectors the selectors not to wrap.\n *\n * @param {EditorStyle[]} styles CSS rules.\n * @param {string} wrapperSelector Wrapper selector.\n * @return {Array} converted rules.\n */\nconst transformStyles = ( styles, wrapperSelector = '' ) => {\n\tlet cache = cacheByWrapperSelector.get( wrapperSelector );\n\tif ( ! cache ) {\n\t\tcache = new WeakMap();\n\t\tcacheByWrapperSelector.set( wrapperSelector, cache );\n\t}\n\treturn styles.map( ( style ) => {\n\t\tlet css = cache.get( style );\n\t\tif ( ! css ) {\n\t\t\tcss = transformStyle( style, wrapperSelector );\n\t\t\tcache.set( style, css );\n\t\t}\n\t\treturn css;\n\t} );\n};\n\nexport default transformStyles;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,OAAO,IAAIC,cAAc,QAAQ,SAAS;AACjD,OAAOC,IAAI,MAAM,oBAAoB;AACrC,OAAOC,SAAS,MAAM,mBAAmB;AAEzC,MAAMC,sBAAsB,GAAG,IAAIC,GAAG,CAAC,CAAC;AAExC,SAASC,cAAcA,CACtB;EAAEC,GAAG;EAAEC,gBAAgB,GAAG,EAAE;EAAEC;AAAQ,CAAC,EACvCC,eAAe,GAAG,EAAE,EACnB;EACD;EACA;EACA;EACA;EACA,IAAK,CAAEA,eAAe,IAAI,CAAED,OAAO,EAAG;IACrC,OA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AAGiB,KAAK,CAACC,GAAG,CAAEI,KAAM,CAAC;IAC5B,IAAK,CAAEtB,GAAG,EAAG;MACZA,GAAG,GAAGD,cAAc,CAAEuB,KAAK,EAAEnB,eAAgB,CAAC;MAC9Cc,KAAK,CAACG,GAAG,CAAEE,KAAK,EAAEtB,GAAI,CAAC;IACxB;IACA,OAAOA,GAAG;EACX,CAAE,CAAC;AACJ,CAAC;AAED,eAAee,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["parsel","postcss","CssSyntaxError","prefixSelector","rebaseUrl","cacheByWrapperSelector","Map","ROOT_SELECTOR_TOKENS","type","content","prefixRootSelector","prefix","selector","tokenized","tokenize","lastRootIndex","findLastIndex","some","rootSelector","insertionPoint","i","length","tokenizedPrefix","splice","stringify","transformStyle","css","ignoredSelectors","baseURL","wrapperSelector","transformOptions","_transformOptions$ign","excludedSelectors","transform","prefixedSelector","excludedSelector","RegExp","match","includes","hasRootSelector","startsWith","rootUrl","filter","Boolean","process","error","console","warn","message","showSourceCode","transformStyles","styles","cache","get","WeakMap","set","map","style"],"sources":["@wordpress/block-editor/src/utils/transform-styles/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport * as parsel from 'parsel-js';\nimport postcss, { CssSyntaxError } from 'postcss';\nimport prefixSelector from 'postcss-prefix-selector';\nimport rebaseUrl from 'postcss-urlrebase';\n\nconst cacheByWrapperSelector = new Map();\n\nconst ROOT_SELECTOR_TOKENS = [\n\t{ type: 'type', content: 'body' },\n\t{ type: 'type', content: 'html' },\n\t{ type: 'pseudo-class', content: ':root' },\n\t{ type: 'pseudo-class', content: ':where(body)' },\n\t{ type: 'pseudo-class', content: ':where(:root)' },\n\t{ type: 'pseudo-class', content: ':where(html)' },\n];\n\n/**\n * Prefixes root selectors in a way that ensures consistent specificity.\n * This requires special handling, since prefixing a classname before\n * html, body, or :root will generally result in an invalid selector.\n *\n * Some libraries will simply replace the root selector with the prefix\n * instead, but this results in inconsistent specificity.\n *\n * This function instead inserts the prefix after the root tags but before\n * any other part of the selector. This results in consistent specificity:\n * - If a `:where()` selector is used for the prefix, all selectors output\n * by `transformStyles` will have no specificity increase.\n * - If a classname, id, or something else is used as the prefix, all selectors\n * will have the same specificity bump when transformed.\n *\n * @param {string} prefix The prefix.\n * @param {string} selector The selector.\n *\n * @return {string} The prefixed root selector.\n */\nfunction prefixRootSelector( prefix, selector ) {\n\t// Use a tokenizer, since regular expressions are unreliable.\n\tconst tokenized = parsel.tokenize( selector );\n\n\t// Find the last token that contains a root selector by walking back\n\t// through the tokens.\n\tconst lastRootIndex = tokenized.findLastIndex( ( { content, type } ) => {\n\t\treturn ROOT_SELECTOR_TOKENS.some(\n\t\t\t( rootSelector ) =>\n\t\t\t\tcontent === rootSelector.content && type === rootSelector.type\n\t\t);\n\t} );\n\n\t// Walk forwards to find the combinator after the last root.\n\t// This is where the root ends and the rest of the selector begins,\n\t// and the index to insert before.\n\t// Doing it this way takes into account that a root selector like\n\t// 'body' may have additional id/class/pseudo-class/attribute-selector\n\t// parts chained to it, which is difficult to quantify using a regex.\n\tlet insertionPoint = -1;\n\tfor ( let i = lastRootIndex + 1; i < tokenized.length; i++ ) {\n\t\tif ( tokenized[ i ].type === 'combinator' ) {\n\t\t\tinsertionPoint = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Tokenize and insert the prefix with a ' ' combinator before it.\n\tconst tokenizedPrefix = parsel.tokenize( prefix );\n\ttokenized.splice(\n\t\t// Insert at the insertion point, or the end.\n\t\tinsertionPoint === -1 ? tokenized.length : insertionPoint,\n\t\t0,\n\t\t{\n\t\t\ttype: 'combinator',\n\t\t\tcontent: ' ',\n\t\t},\n\t\t...tokenizedPrefix\n\t);\n\n\treturn parsel.stringify( tokenized );\n}\n\nfunction transformStyle(\n\t{ css, ignoredSelectors = [], baseURL },\n\twrapperSelector = '',\n\ttransformOptions\n) {\n\t// When there is no wrapper selector and no base URL, there is no need\n\t// to transform the CSS. This is most cases because in the default\n\t// iframed editor, no wrapping is needed, and not many styles\n\t// provide a base URL.\n\tif ( ! wrapperSelector && ! baseURL ) {\n\t\treturn css;\n\t}\n\n\ttry {\n\t\tconst excludedSelectors = [\n\t\t\t...ignoredSelectors,\n\t\t\t...( transformOptions?.ignoredSelectors ?? [] ),\n\t\t\twrapperSelector,\n\t\t];\n\n\t\treturn postcss(\n\t\t\t[\n\t\t\t\twrapperSelector &&\n\t\t\t\t\tprefixSelector( {\n\t\t\t\t\t\tprefix: wrapperSelector,\n\t\t\t\t\t\ttransform( prefix, selector, prefixedSelector ) {\n\t\t\t\t\t\t\t// For backwards compatibility, don't use the `exclude` option\n\t\t\t\t\t\t\t// of postcss-prefix-selector, instead handle it here to match\n\t\t\t\t\t\t\t// the behavior of the old library (postcss-prefix-wrap) that\n\t\t\t\t\t\t\t// `transformStyle` previously used.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\texcludedSelectors.some( ( excludedSelector ) =>\n\t\t\t\t\t\t\t\t\texcludedSelector instanceof RegExp\n\t\t\t\t\t\t\t\t\t\t? selector.match( excludedSelector )\n\t\t\t\t\t\t\t\t\t\t: selector.includes( excludedSelector )\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn selector;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst hasRootSelector = ROOT_SELECTOR_TOKENS.some(\n\t\t\t\t\t\t\t\t( rootSelector ) =>\n\t\t\t\t\t\t\t\t\tselector.startsWith( rootSelector.content )\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Reorganize root selectors such that the root part comes before the prefix,\n\t\t\t\t\t\t\t// but the prefix still comes before the remaining part of the selector.\n\t\t\t\t\t\t\tif ( hasRootSelector ) {\n\t\t\t\t\t\t\t\treturn prefixRootSelector( prefix, selector );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn prefixedSelector;\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t\tbaseURL && rebaseUrl( { rootUrl: baseURL } ),\n\t\t\t].filter( Boolean )\n\t\t).process( css, {} ).css; // use sync PostCSS API\n\t} catch ( error ) {\n\t\tif ( error instanceof CssSyntaxError ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror.message + '\\n' + error.showSourceCode( false )\n\t\t\t);\n\t\t} else {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\n/**\n * @typedef {Object} EditorStyle\n * @property {string} css the CSS block(s), as a single string.\n * @property {?string} baseURL the base URL to be used as the reference when rewritting urls.\n * @property {?string[]} ignoredSelectors the selectors not to wrap.\n */\n\n/**\n * @typedef {Object} TransformOptions\n * @property {?string[]} ignoredSelectors the selectors not to wrap.\n */\n\n/**\n * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.\n *\n * @param {EditorStyle[]} styles CSS rules.\n * @param {string} wrapperSelector Wrapper selector.\n * @param {TransformOptions} transformOptions Additional options for style transformation.\n * @return {Array} converted rules.\n */\nconst transformStyles = ( styles, wrapperSelector = '', transformOptions ) => {\n\tlet cache = cacheByWrapperSelector.get( wrapperSelector );\n\tif ( ! cache ) {\n\t\tcache = new WeakMap();\n\t\tcacheByWrapperSelector.set( wrapperSelector, cache );\n\t}\n\treturn styles.map( ( style ) => {\n\t\tlet css = cache.get( style );\n\t\tif ( ! css ) {\n\t\t\tcss = transformStyle( style, wrapperSelector, transformOptions );\n\t\t\tcache.set( style, css );\n\t\t}\n\t\treturn css;\n\t} );\n};\n\nexport default transformStyles;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,KAAKA,MAAM,MAAM,WAAW;AACnC,OAAOC,OAAO,IAAIC,cAAc,QAAQ,SAAS;AACjD,OAAOC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