@wordpress/block-editor 15.21.0 → 15.22.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 (836) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/README.md +2 -2
  3. package/build/components/block-card/index.cjs +4 -5
  4. package/build/components/block-card/index.cjs.map +2 -2
  5. package/build/components/block-compare/index.cjs +2 -2
  6. package/build/components/block-compare/index.cjs.map +2 -2
  7. package/build/components/block-editing-mode/index.cjs +13 -7
  8. package/build/components/block-editing-mode/index.cjs.map +2 -2
  9. package/build/components/block-inspector/index.cjs +35 -20
  10. package/build/components/block-inspector/index.cjs.map +2 -2
  11. package/build/components/block-mover/mover-description.cjs +6 -6
  12. package/build/components/block-mover/mover-description.cjs.map +1 -1
  13. package/build/components/block-patterns-list/index.cjs +1 -1
  14. package/build/components/block-patterns-list/index.cjs.map +2 -2
  15. package/build/components/block-patterns-paging/index.cjs +4 -4
  16. package/build/components/block-patterns-paging/index.cjs.map +2 -2
  17. package/build/components/block-popover/use-popover-scroll.cjs.map +1 -1
  18. package/build/components/block-quick-navigation/index.cjs +7 -5
  19. package/build/components/block-quick-navigation/index.cjs.map +2 -2
  20. package/build/components/block-rename/modal.cjs +0 -1
  21. package/build/components/block-rename/modal.cjs.map +2 -2
  22. package/build/components/block-switcher/block-transformations-menu.cjs +16 -15
  23. package/build/components/block-switcher/block-transformations-menu.cjs.map +2 -2
  24. package/build/components/block-switcher/index.cjs +4 -4
  25. package/build/components/block-switcher/index.cjs.map +2 -2
  26. package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
  27. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  28. package/build/components/block-toolbar/edit-section-button.cjs.map +1 -1
  29. package/build/components/block-tools/use-block-toolbar-popover-props.cjs +10 -4
  30. package/build/components/block-tools/use-block-toolbar-popover-props.cjs.map +2 -2
  31. package/build/components/child-layout-control/index.cjs +51 -19
  32. package/build/components/child-layout-control/index.cjs.map +2 -2
  33. package/build/components/colors-gradients/control.cjs +25 -14
  34. package/build/components/colors-gradients/control.cjs.map +2 -2
  35. package/build/components/colors-gradients/dropdown.cjs +4 -1
  36. package/build/components/colors-gradients/dropdown.cjs.map +3 -3
  37. package/build/components/contrast-checker/index.cjs +22 -4
  38. package/build/components/contrast-checker/index.cjs.map +2 -2
  39. package/build/components/date-format-picker/index.cjs +0 -1
  40. package/build/components/date-format-picker/index.cjs.map +2 -2
  41. package/build/components/dimensions-tool/index.cjs +4 -5
  42. package/build/components/dimensions-tool/index.cjs.map +2 -2
  43. package/build/components/dimensions-tool/scale-tool.cjs +1 -1
  44. package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
  45. package/build/components/global-styles/advanced-panel.cjs +23 -15
  46. package/build/components/global-styles/advanced-panel.cjs.map +2 -2
  47. package/build/components/global-styles/background-panel.cjs +154 -26
  48. package/build/components/global-styles/background-panel.cjs.map +3 -3
  49. package/build/components/global-styles/border-panel.cjs +2 -0
  50. package/build/components/global-styles/border-panel.cjs.map +2 -2
  51. package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
  52. package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
  53. package/build/components/global-styles/color-panel.cjs +98 -375
  54. package/build/components/global-styles/color-panel.cjs.map +3 -3
  55. package/build/components/global-styles/dimensions-panel.cjs +2 -5
  56. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  57. package/build/components/global-styles/hooks.cjs +34 -0
  58. package/build/components/global-styles/hooks.cjs.map +2 -2
  59. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  60. package/build/components/global-styles/typography-panel.cjs +82 -10
  61. package/build/components/global-styles/typography-panel.cjs.map +3 -3
  62. package/build/components/grid/grid-item-resizer.cjs.map +1 -1
  63. package/build/components/grid/grid-visualizer.cjs.map +1 -1
  64. package/build/components/iframe/index.cjs +6 -3
  65. package/build/components/iframe/index.cjs.map +3 -3
  66. package/build/components/image-editor/use-transform-image.cjs.map +1 -1
  67. package/build/components/inner-blocks/use-inner-block-template-sync.cjs +3 -1
  68. package/build/components/inner-blocks/use-inner-block-template-sync.cjs.map +2 -2
  69. package/build/components/inserter/get-appender-label.cjs.map +1 -1
  70. package/build/components/inserter/hooks/use-patterns-state.cjs +1 -1
  71. package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
  72. package/build/components/inserter/index.cjs +179 -220
  73. package/build/components/inserter/index.cjs.map +3 -3
  74. package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
  75. package/build/components/inserter/search-items.cjs.map +1 -1
  76. package/build/components/inserter/search-results.cjs +1 -1
  77. package/build/components/inserter/search-results.cjs.map +2 -2
  78. package/build/components/inspector-controls/fill.cjs +1 -3
  79. package/build/components/inspector-controls/fill.cjs.map +2 -2
  80. package/build/components/inspector-controls/groups.cjs +2 -0
  81. package/build/components/inspector-controls/groups.cjs.map +2 -2
  82. package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
  83. package/build/components/inspector-controls-tabs/styles-tab.cjs +76 -32
  84. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  85. package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
  86. package/build/components/line-height-control/index.cjs.map +1 -1
  87. package/build/components/link-control/index.cjs +2 -3
  88. package/build/components/link-control/index.cjs.map +2 -2
  89. package/build/components/link-control/normalize-url.cjs.map +1 -1
  90. package/build/components/list-view/block-select-button.cjs +9 -20
  91. package/build/components/list-view/block-select-button.cjs.map +3 -3
  92. package/build/components/list-view/block.cjs +2 -1
  93. package/build/components/list-view/block.cjs.map +2 -2
  94. package/build/components/list-view/utils.cjs.map +1 -1
  95. package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
  96. package/build/components/provider/index.cjs.map +1 -1
  97. package/build/components/provider/use-block-sync.cjs +14 -3
  98. package/build/components/provider/use-block-sync.cjs.map +2 -2
  99. package/build/components/rich-text/event-listeners/before-input-rules.cjs +5 -5
  100. package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
  101. package/build/components/rich-text/event-listeners/delete.cjs +4 -4
  102. package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
  103. package/build/components/rich-text/event-listeners/enter.cjs +7 -2
  104. package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
  105. package/build/components/rich-text/event-listeners/input-events.cjs +4 -4
  106. package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
  107. package/build/components/rich-text/event-listeners/input-rules.cjs +17 -4
  108. package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
  109. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +4 -4
  110. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
  111. package/build/components/rich-text/event-listeners/paste-handler.cjs.map +1 -1
  112. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +4 -4
  113. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
  114. package/build/components/rich-text/event-listeners/shortcuts.cjs +4 -4
  115. package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
  116. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +4 -4
  117. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
  118. package/build/components/rich-text/index.cjs +1 -23
  119. package/build/components/rich-text/index.cjs.map +2 -2
  120. package/build/components/rich-text/prevent-event-discovery.cjs +1 -1
  121. package/build/components/rich-text/prevent-event-discovery.cjs.map +1 -1
  122. package/build/components/url-popover/image-url-input-ui.cjs +0 -2
  123. package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
  124. package/build/components/use-block-commands/index.cjs +5 -5
  125. package/build/components/use-block-commands/index.cjs.map +2 -2
  126. package/build/components/use-block-display-information/index.cjs +10 -3
  127. package/build/components/use-block-display-information/index.cjs.map +2 -2
  128. package/build/components/writing-flow/use-tab-nav.cjs.map +1 -1
  129. package/build/hooks/anchor.cjs +12 -17
  130. package/build/hooks/anchor.cjs.map +2 -2
  131. package/build/hooks/background.cjs +124 -75
  132. package/build/hooks/background.cjs.map +3 -3
  133. package/build/hooks/block-fields/index.cjs +13 -2
  134. package/build/hooks/block-fields/index.cjs.map +2 -2
  135. package/build/hooks/border.cjs +0 -3
  136. package/build/hooks/border.cjs.map +2 -2
  137. package/build/hooks/color.cjs +0 -165
  138. package/build/hooks/color.cjs.map +3 -3
  139. package/build/hooks/contrast-checker.cjs +31 -28
  140. package/build/hooks/contrast-checker.cjs.map +3 -3
  141. package/build/hooks/custom-class-name.cjs +0 -1
  142. package/build/hooks/custom-class-name.cjs.map +2 -2
  143. package/build/hooks/dimensions.cjs +13 -5
  144. package/build/hooks/dimensions.cjs.map +2 -2
  145. package/build/hooks/elements.cjs +142 -0
  146. package/build/hooks/elements.cjs.map +7 -0
  147. package/build/hooks/fit-text.cjs +11 -0
  148. package/build/hooks/fit-text.cjs.map +2 -2
  149. package/build/hooks/grid-visualizer.cjs +21 -11
  150. package/build/hooks/grid-visualizer.cjs.map +2 -2
  151. package/build/hooks/layout-child.cjs +65 -10
  152. package/build/hooks/layout-child.cjs.map +2 -2
  153. package/build/hooks/layout.cjs +6 -3
  154. package/build/hooks/layout.cjs.map +2 -2
  155. package/build/hooks/list-view.cjs +10 -7
  156. package/build/hooks/list-view.cjs.map +2 -2
  157. package/build/hooks/position.cjs +19 -22
  158. package/build/hooks/position.cjs.map +2 -2
  159. package/build/hooks/spacing-visualizer.cjs.map +1 -1
  160. package/build/hooks/state-utils.cjs.map +1 -1
  161. package/build/hooks/states.cjs +2 -2
  162. package/build/hooks/states.cjs.map +2 -2
  163. package/build/hooks/style.cjs +50 -6
  164. package/build/hooks/style.cjs.map +2 -2
  165. package/build/hooks/supports.cjs +0 -7
  166. package/build/hooks/supports.cjs.map +2 -2
  167. package/build/hooks/typography.cjs +62 -10
  168. package/build/hooks/typography.cjs.map +3 -3
  169. package/build/layouts/flex.cjs +99 -6
  170. package/build/layouts/flex.cjs.map +2 -2
  171. package/build/private-apis.cjs +4 -0
  172. package/build/private-apis.cjs.map +2 -2
  173. package/build/store/actions.cjs +7 -3
  174. package/build/store/actions.cjs.map +2 -2
  175. package/build/store/private-actions.cjs +1 -2
  176. package/build/store/private-actions.cjs.map +2 -2
  177. package/build/store/private-selectors.cjs +42 -2
  178. package/build/store/private-selectors.cjs.map +2 -2
  179. package/build/store/reducer.cjs +14 -6
  180. package/build/store/reducer.cjs.map +2 -2
  181. package/build/store/selectors.cjs +60 -41
  182. package/build/store/selectors.cjs.map +2 -2
  183. package/build/utils/block-bindings.cjs +9 -9
  184. package/build/utils/block-bindings.cjs.map +3 -3
  185. package/build/utils/color-values.cjs +10 -1
  186. package/build/utils/color-values.cjs.map +3 -3
  187. package/build/utils/dom.cjs +2 -5
  188. package/build/utils/dom.cjs.map +3 -3
  189. package/build/utils/fit-text-frontend.cjs +6 -2
  190. package/build/utils/fit-text-frontend.cjs.map +3 -3
  191. package/build/utils/fit-text-utils.cjs +1 -1
  192. package/build/utils/fit-text-utils.cjs.map +3 -3
  193. package/build/utils/format-font-style.cjs +1 -1
  194. package/build/utils/format-font-style.cjs.map +3 -3
  195. package/build/utils/format-font-weight.cjs +1 -1
  196. package/build/utils/format-font-weight.cjs.map +3 -3
  197. package/build/utils/get-editor-region.cjs +4 -2
  198. package/build/utils/get-editor-region.cjs.map +3 -3
  199. package/build/utils/get-font-styles-and-weights.cjs +8 -12
  200. package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
  201. package/build/utils/get-px-from-css-unit.cjs +1 -1
  202. package/build/utils/get-px-from-css-unit.cjs.map +1 -1
  203. package/build/utils/index.cjs +1 -1
  204. package/build/utils/index.cjs.map +1 -1
  205. package/build/utils/math.cjs +1 -1
  206. package/build/utils/math.cjs.map +3 -3
  207. package/build/utils/object.cjs +8 -8
  208. package/build/utils/object.cjs.map +3 -3
  209. package/build/utils/order-inserter-block-items.cjs +1 -1
  210. package/build/utils/order-inserter-block-items.cjs.map +3 -3
  211. package/build/utils/pasting.cjs +4 -2
  212. package/build/utils/pasting.cjs.map +3 -3
  213. package/build/utils/selection.cjs +3 -2
  214. package/build/utils/selection.cjs.map +3 -3
  215. package/build/utils/sorting.cjs +9 -3
  216. package/build/utils/sorting.cjs.map +3 -3
  217. package/build/utils/transform-styles/index.cjs +3 -2
  218. package/build/utils/transform-styles/index.cjs.map +3 -3
  219. package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
  220. package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
  221. package/build/{components/rich-text/native/index.cjs → utils/transform-styles/types.cjs} +4 -13
  222. package/build/utils/transform-styles/types.cjs.map +7 -0
  223. package/build/utils/types.cjs +19 -0
  224. package/build/utils/types.cjs.map +7 -0
  225. package/build-module/components/block-card/index.mjs +5 -6
  226. package/build-module/components/block-card/index.mjs.map +2 -2
  227. package/build-module/components/block-compare/index.mjs +1 -1
  228. package/build-module/components/block-compare/index.mjs.map +2 -2
  229. package/build-module/components/block-editing-mode/index.mjs +14 -8
  230. package/build-module/components/block-editing-mode/index.mjs.map +2 -2
  231. package/build-module/components/block-inspector/index.mjs +35 -21
  232. package/build-module/components/block-inspector/index.mjs.map +2 -2
  233. package/build-module/components/block-mover/mover-description.mjs +6 -6
  234. package/build-module/components/block-mover/mover-description.mjs.map +1 -1
  235. package/build-module/components/block-patterns-list/index.mjs +1 -1
  236. package/build-module/components/block-patterns-list/index.mjs.map +2 -2
  237. package/build-module/components/block-patterns-paging/index.mjs +4 -4
  238. package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
  239. package/build-module/components/block-popover/use-popover-scroll.mjs.map +1 -1
  240. package/build-module/components/block-quick-navigation/index.mjs +8 -6
  241. package/build-module/components/block-quick-navigation/index.mjs.map +2 -2
  242. package/build-module/components/block-rename/modal.mjs +0 -1
  243. package/build-module/components/block-rename/modal.mjs.map +2 -2
  244. package/build-module/components/block-switcher/block-transformations-menu.mjs +16 -15
  245. package/build-module/components/block-switcher/block-transformations-menu.mjs.map +2 -2
  246. package/build-module/components/block-switcher/index.mjs +4 -4
  247. package/build-module/components/block-switcher/index.mjs.map +2 -2
  248. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
  249. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  250. package/build-module/components/block-toolbar/edit-section-button.mjs.map +1 -1
  251. package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs +10 -4
  252. package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs.map +2 -2
  253. package/build-module/components/child-layout-control/index.mjs +51 -19
  254. package/build-module/components/child-layout-control/index.mjs.map +2 -2
  255. package/build-module/components/colors-gradients/control.mjs +27 -15
  256. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  257. package/build-module/components/colors-gradients/dropdown.mjs +4 -1
  258. package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
  259. package/build-module/components/contrast-checker/index.mjs +18 -4
  260. package/build-module/components/contrast-checker/index.mjs.map +2 -2
  261. package/build-module/components/date-format-picker/index.mjs +0 -1
  262. package/build-module/components/date-format-picker/index.mjs.map +2 -2
  263. package/build-module/components/dimensions-tool/index.mjs +4 -5
  264. package/build-module/components/dimensions-tool/index.mjs.map +2 -2
  265. package/build-module/components/dimensions-tool/scale-tool.mjs +1 -1
  266. package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
  267. package/build-module/components/global-styles/advanced-panel.mjs +23 -15
  268. package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
  269. package/build-module/components/global-styles/background-panel.mjs +157 -29
  270. package/build-module/components/global-styles/background-panel.mjs.map +2 -2
  271. package/build-module/components/global-styles/border-panel.mjs +2 -0
  272. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  273. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
  274. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
  275. package/build-module/components/global-styles/color-panel.mjs +106 -387
  276. package/build-module/components/global-styles/color-panel.mjs.map +3 -3
  277. package/build-module/components/global-styles/dimensions-panel.mjs +3 -7
  278. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  279. package/build-module/components/global-styles/hooks.mjs +33 -0
  280. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  281. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  282. package/build-module/components/global-styles/typography-panel.mjs +84 -10
  283. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  284. package/build-module/components/grid/grid-item-resizer.mjs.map +1 -1
  285. package/build-module/components/grid/grid-visualizer.mjs.map +1 -1
  286. package/build-module/components/iframe/index.mjs +6 -3
  287. package/build-module/components/iframe/index.mjs.map +2 -2
  288. package/build-module/components/image-editor/use-transform-image.mjs.map +1 -1
  289. package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs +3 -1
  290. package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs.map +2 -2
  291. package/build-module/components/inserter/get-appender-label.mjs.map +1 -1
  292. package/build-module/components/inserter/hooks/use-patterns-state.mjs +1 -1
  293. package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
  294. package/build-module/components/inserter/index.mjs +185 -222
  295. package/build-module/components/inserter/index.mjs.map +3 -3
  296. package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
  297. package/build-module/components/inserter/search-items.mjs.map +1 -1
  298. package/build-module/components/inserter/search-results.mjs +1 -1
  299. package/build-module/components/inserter/search-results.mjs.map +2 -2
  300. package/build-module/components/inspector-controls/fill.mjs +1 -3
  301. package/build-module/components/inspector-controls/fill.mjs.map +2 -2
  302. package/build-module/components/inspector-controls/groups.mjs +2 -0
  303. package/build-module/components/inspector-controls/groups.mjs.map +2 -2
  304. package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
  305. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +76 -32
  306. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  307. package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -1
  308. package/build-module/components/line-height-control/index.mjs.map +1 -1
  309. package/build-module/components/link-control/index.mjs +2 -3
  310. package/build-module/components/link-control/index.mjs.map +2 -2
  311. package/build-module/components/link-control/normalize-url.mjs.map +1 -1
  312. package/build-module/components/list-view/block-select-button.mjs +10 -27
  313. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  314. package/build-module/components/list-view/block.mjs +2 -1
  315. package/build-module/components/list-view/block.mjs.map +2 -2
  316. package/build-module/components/list-view/utils.mjs.map +1 -1
  317. package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
  318. package/build-module/components/provider/index.mjs.map +1 -1
  319. package/build-module/components/provider/use-block-sync.mjs +14 -3
  320. package/build-module/components/provider/use-block-sync.mjs.map +2 -2
  321. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +5 -5
  322. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
  323. package/build-module/components/rich-text/event-listeners/delete.mjs +4 -4
  324. package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
  325. package/build-module/components/rich-text/event-listeners/enter.mjs +7 -2
  326. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  327. package/build-module/components/rich-text/event-listeners/input-events.mjs +4 -4
  328. package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
  329. package/build-module/components/rich-text/event-listeners/input-rules.mjs +17 -4
  330. package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
  331. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +4 -4
  332. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
  333. package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +1 -1
  334. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +4 -4
  335. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
  336. package/build-module/components/rich-text/event-listeners/shortcuts.mjs +4 -4
  337. package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
  338. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +4 -4
  339. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
  340. package/build-module/components/rich-text/index.mjs +1 -23
  341. package/build-module/components/rich-text/index.mjs.map +2 -2
  342. package/build-module/components/rich-text/prevent-event-discovery.mjs +1 -1
  343. package/build-module/components/rich-text/prevent-event-discovery.mjs.map +1 -1
  344. package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
  345. package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
  346. package/build-module/components/use-block-commands/index.mjs +5 -5
  347. package/build-module/components/use-block-commands/index.mjs.map +2 -2
  348. package/build-module/components/use-block-display-information/index.mjs +10 -3
  349. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  350. package/build-module/components/writing-flow/use-tab-nav.mjs.map +1 -1
  351. package/build-module/hooks/anchor.mjs +12 -17
  352. package/build-module/hooks/anchor.mjs.map +2 -2
  353. package/build-module/hooks/background.mjs +123 -75
  354. package/build-module/hooks/background.mjs.map +2 -2
  355. package/build-module/hooks/block-fields/index.mjs +13 -2
  356. package/build-module/hooks/block-fields/index.mjs.map +2 -2
  357. package/build-module/hooks/border.mjs +1 -4
  358. package/build-module/hooks/border.mjs.map +2 -2
  359. package/build-module/hooks/color.mjs +2 -178
  360. package/build-module/hooks/color.mjs.map +2 -2
  361. package/build-module/hooks/contrast-checker.mjs +32 -19
  362. package/build-module/hooks/contrast-checker.mjs.map +2 -2
  363. package/build-module/hooks/custom-class-name.mjs +0 -1
  364. package/build-module/hooks/custom-class-name.mjs.map +2 -2
  365. package/build-module/hooks/dimensions.mjs +13 -6
  366. package/build-module/hooks/dimensions.mjs.map +2 -2
  367. package/build-module/hooks/elements.mjs +115 -0
  368. package/build-module/hooks/elements.mjs.map +7 -0
  369. package/build-module/hooks/fit-text.mjs +11 -0
  370. package/build-module/hooks/fit-text.mjs.map +2 -2
  371. package/build-module/hooks/grid-visualizer.mjs +21 -11
  372. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  373. package/build-module/hooks/layout-child.mjs +68 -10
  374. package/build-module/hooks/layout-child.mjs.map +2 -2
  375. package/build-module/hooks/layout.mjs +6 -3
  376. package/build-module/hooks/layout.mjs.map +2 -2
  377. package/build-module/hooks/list-view.mjs +10 -7
  378. package/build-module/hooks/list-view.mjs.map +2 -2
  379. package/build-module/hooks/position.mjs +20 -23
  380. package/build-module/hooks/position.mjs.map +2 -2
  381. package/build-module/hooks/spacing-visualizer.mjs.map +1 -1
  382. package/build-module/hooks/state-utils.mjs.map +1 -1
  383. package/build-module/hooks/states.mjs +2 -2
  384. package/build-module/hooks/states.mjs.map +2 -2
  385. package/build-module/hooks/style.mjs +53 -8
  386. package/build-module/hooks/style.mjs.map +2 -2
  387. package/build-module/hooks/supports.mjs +0 -7
  388. package/build-module/hooks/supports.mjs.map +2 -2
  389. package/build-module/hooks/typography.mjs +62 -10
  390. package/build-module/hooks/typography.mjs.map +2 -2
  391. package/build-module/layouts/flex.mjs +105 -7
  392. package/build-module/layouts/flex.mjs.map +2 -2
  393. package/build-module/private-apis.mjs +8 -0
  394. package/build-module/private-apis.mjs.map +2 -2
  395. package/build-module/store/actions.mjs +7 -3
  396. package/build-module/store/actions.mjs.map +2 -2
  397. package/build-module/store/private-actions.mjs +1 -2
  398. package/build-module/store/private-actions.mjs.map +2 -2
  399. package/build-module/store/private-selectors.mjs +39 -1
  400. package/build-module/store/private-selectors.mjs.map +2 -2
  401. package/build-module/store/reducer.mjs +14 -6
  402. package/build-module/store/reducer.mjs.map +2 -2
  403. package/build-module/store/selectors.mjs +62 -42
  404. package/build-module/store/selectors.mjs.map +2 -2
  405. package/build-module/utils/block-bindings.mjs +9 -9
  406. package/build-module/utils/block-bindings.mjs.map +3 -3
  407. package/build-module/utils/color-values.mjs +9 -1
  408. package/build-module/utils/color-values.mjs.map +3 -3
  409. package/build-module/utils/dom.mjs +2 -5
  410. package/build-module/utils/dom.mjs.map +3 -3
  411. package/build-module/utils/fit-text-frontend.mjs +6 -2
  412. package/build-module/utils/fit-text-frontend.mjs.map +3 -3
  413. package/build-module/utils/fit-text-utils.mjs +1 -1
  414. package/build-module/utils/fit-text-utils.mjs.map +3 -3
  415. package/build-module/utils/format-font-style.mjs +1 -1
  416. package/build-module/utils/format-font-style.mjs.map +3 -3
  417. package/build-module/utils/format-font-weight.mjs +1 -1
  418. package/build-module/utils/format-font-weight.mjs.map +3 -3
  419. package/build-module/utils/get-editor-region.mjs +4 -2
  420. package/build-module/utils/get-editor-region.mjs.map +3 -3
  421. package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
  422. package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
  423. package/build-module/utils/get-px-from-css-unit.mjs +1 -1
  424. package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
  425. package/build-module/utils/index.mjs +1 -1
  426. package/build-module/utils/index.mjs.map +1 -1
  427. package/build-module/utils/math.mjs +1 -1
  428. package/build-module/utils/math.mjs.map +3 -3
  429. package/build-module/utils/object.mjs +8 -8
  430. package/build-module/utils/object.mjs.map +3 -3
  431. package/build-module/utils/order-inserter-block-items.mjs +1 -1
  432. package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
  433. package/build-module/utils/pasting.mjs +4 -2
  434. package/build-module/utils/pasting.mjs.map +3 -3
  435. package/build-module/utils/selection.mjs +3 -2
  436. package/build-module/utils/selection.mjs.map +3 -3
  437. package/build-module/utils/sorting.mjs +9 -3
  438. package/build-module/utils/sorting.mjs.map +3 -3
  439. package/build-module/utils/transform-styles/index.mjs +3 -2
  440. package/build-module/utils/transform-styles/index.mjs.map +3 -3
  441. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
  442. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
  443. package/build-module/utils/transform-styles/types.mjs +1 -0
  444. package/build-module/utils/transform-styles/types.mjs.map +7 -0
  445. package/build-module/utils/types.mjs +1 -0
  446. package/build-module/utils/types.mjs.map +7 -0
  447. package/build-style/content-rtl.css +14 -0
  448. package/build-style/content.css +14 -0
  449. package/build-style/style-rtl.css +60 -49
  450. package/build-style/style.css +60 -49
  451. package/build-types/utils/block-bindings.d.ts +27 -0
  452. package/build-types/utils/block-bindings.d.ts.map +1 -0
  453. package/build-types/utils/color-values.d.ts +40 -0
  454. package/build-types/utils/color-values.d.ts.map +1 -0
  455. package/build-types/utils/dom.d.ts +19 -19
  456. package/build-types/utils/dom.d.ts.map +1 -1
  457. package/build-types/utils/fit-text-frontend.d.ts +7 -0
  458. package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
  459. package/build-types/utils/fit-text-utils.d.ts +15 -0
  460. package/build-types/utils/fit-text-utils.d.ts.map +1 -0
  461. package/build-types/utils/format-font-style.d.ts +12 -0
  462. package/build-types/utils/format-font-style.d.ts.map +1 -0
  463. package/build-types/utils/format-font-weight.d.ts +12 -0
  464. package/build-types/utils/format-font-weight.d.ts.map +1 -0
  465. package/build-types/utils/get-editor-region.d.ts +9 -0
  466. package/build-types/utils/get-editor-region.d.ts.map +1 -0
  467. package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
  468. package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
  469. package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
  470. package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
  471. package/build-types/utils/index.d.ts +3 -0
  472. package/build-types/utils/index.d.ts.map +1 -0
  473. package/build-types/utils/math.d.ts +61 -0
  474. package/build-types/utils/math.d.ts.map +1 -0
  475. package/build-types/utils/object.d.ts +39 -0
  476. package/build-types/utils/object.d.ts.map +1 -0
  477. package/build-types/utils/order-inserter-block-items.d.ts +13 -0
  478. package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
  479. package/build-types/utils/pasting.d.ts +28 -0
  480. package/build-types/utils/pasting.d.ts.map +1 -0
  481. package/build-types/utils/selection.d.ts +21 -0
  482. package/build-types/utils/selection.d.ts.map +1 -0
  483. package/build-types/utils/sorting.d.ts +17 -0
  484. package/build-types/utils/sorting.d.ts.map +1 -0
  485. package/build-types/utils/transform-styles/index.d.ts +15 -0
  486. package/build-types/utils/transform-styles/index.d.ts.map +1 -0
  487. package/build-types/utils/transform-styles/types.d.ts +13 -0
  488. package/build-types/utils/transform-styles/types.d.ts.map +1 -0
  489. package/build-types/utils/types.d.ts +28 -0
  490. package/build-types/utils/types.d.ts.map +1 -0
  491. package/package.json +55 -46
  492. package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
  493. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
  494. package/src/components/block-breadcrumb/README.md +2 -2
  495. package/src/components/block-card/index.js +7 -13
  496. package/src/components/block-compare/README.md +6 -6
  497. package/src/components/block-compare/index.js +1 -3
  498. package/src/components/block-editing-mode/index.js +17 -9
  499. package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
  500. package/src/components/block-inspector/index.js +22 -20
  501. package/src/components/block-patterns-list/index.js +1 -2
  502. package/src/components/block-preview/README.md +1 -1
  503. package/src/components/block-quick-navigation/index.js +7 -7
  504. package/src/components/block-rename/modal.js +0 -1
  505. package/src/components/block-switcher/block-transformations-menu.js +16 -18
  506. package/src/components/block-switcher/index.js +4 -4
  507. package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
  508. package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
  509. package/src/components/block-tools/use-block-toolbar-popover-props.js +10 -4
  510. package/src/components/block-types-list/README.md +0 -19
  511. package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
  512. package/src/components/child-layout-control/index.js +65 -20
  513. package/src/components/child-layout-control/test/index.js +64 -0
  514. package/src/components/colors-gradients/control.js +29 -12
  515. package/src/components/colors-gradients/dropdown.js +4 -1
  516. package/src/components/colors-gradients/style.scss +39 -2
  517. package/src/components/contrast-checker/README.md +9 -0
  518. package/src/components/contrast-checker/index.js +42 -3
  519. package/src/components/date-format-picker/index.js +0 -1
  520. package/src/components/default-block-appender/content.scss +3 -0
  521. package/src/components/dimensions-tool/index.js +4 -9
  522. package/src/components/dimensions-tool/scale-tool.js +1 -2
  523. package/src/components/dimensions-tool/test/index.js +89 -11
  524. package/src/components/global-styles/advanced-panel.js +5 -1
  525. package/src/components/global-styles/background-panel.js +203 -36
  526. package/src/components/global-styles/border-panel.js +2 -0
  527. package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
  528. package/src/components/global-styles/color-panel.js +125 -487
  529. package/src/components/global-styles/dimensions-panel.js +13 -18
  530. package/src/components/global-styles/hooks.js +45 -0
  531. package/src/components/global-styles/shadow-panel-components.js +0 -1
  532. package/src/components/global-styles/test/background-panel.js +56 -0
  533. package/src/components/global-styles/test/color-panel.js +172 -118
  534. package/src/components/global-styles/test/typography-panel.js +167 -0
  535. package/src/components/global-styles/typography-panel.js +100 -11
  536. package/src/components/iframe/index.js +8 -3
  537. package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -1
  538. package/src/components/inserter/hooks/use-patterns-state.js +1 -1
  539. package/src/components/inserter/index.js +257 -288
  540. package/src/components/inserter/media-tab/media-preview.js +0 -1
  541. package/src/components/inserter/search-results.js +1 -3
  542. package/src/components/inspector-controls/README.md +0 -2
  543. package/src/components/inspector-controls/fill.js +6 -8
  544. package/src/components/inspector-controls/groups.js +2 -0
  545. package/src/components/inspector-controls-tabs/index.js +0 -1
  546. package/src/components/inspector-controls-tabs/styles-tab.js +78 -28
  547. package/src/components/justify-content-control/README.md +1 -1
  548. package/src/components/link-control/index.js +0 -1
  549. package/src/components/link-control/test/index.js +2 -3
  550. package/src/components/list-view/block-select-button.js +9 -29
  551. package/src/components/list-view/block.js +1 -0
  552. package/src/components/media-placeholder/README.md +1 -29
  553. package/src/components/media-upload/README.md +0 -19
  554. package/src/components/preset-input-control/custom-value-controls.js +0 -1
  555. package/src/components/provider/test/use-block-sync.js +40 -0
  556. package/src/components/provider/use-block-sync.js +15 -3
  557. package/src/components/rich-text/content.scss +2 -0
  558. package/src/components/rich-text/event-listeners/before-input-rules.js +5 -4
  559. package/src/components/rich-text/event-listeners/delete.js +9 -4
  560. package/src/components/rich-text/event-listeners/enter.js +9 -2
  561. package/src/components/rich-text/event-listeners/input-events.js +13 -4
  562. package/src/components/rich-text/event-listeners/input-rules.js +20 -4
  563. package/src/components/rich-text/event-listeners/insert-replacement-text.js +9 -4
  564. package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +9 -4
  565. package/src/components/rich-text/event-listeners/shortcuts.js +13 -4
  566. package/src/components/rich-text/event-listeners/undo-automatic-change.js +5 -4
  567. package/src/components/rich-text/index.js +1 -33
  568. package/src/components/unit-control/README.md +1 -1
  569. package/src/components/url-popover/README.md +1 -1
  570. package/src/components/url-popover/image-url-input-ui.js +0 -2
  571. package/src/components/use-block-commands/index.js +5 -5
  572. package/src/components/use-block-display-information/index.js +15 -2
  573. package/src/components/use-block-display-information/test/index.js +140 -0
  574. package/src/hooks/anchor.js +9 -18
  575. package/src/hooks/background.js +210 -133
  576. package/src/hooks/background.scss +0 -35
  577. package/src/hooks/block-fields/index.js +27 -2
  578. package/src/hooks/border.js +1 -5
  579. package/src/hooks/color.js +2 -210
  580. package/src/hooks/color.scss +3 -9
  581. package/src/hooks/contrast-checker.js +60 -17
  582. package/src/hooks/custom-class-name.js +0 -1
  583. package/src/hooks/dimensions.js +15 -8
  584. package/src/hooks/elements.js +140 -0
  585. package/src/hooks/elements.scss +8 -0
  586. package/src/hooks/fit-text.js +16 -0
  587. package/src/hooks/grid-visualizer.js +59 -45
  588. package/src/hooks/layout-child.js +92 -14
  589. package/src/hooks/layout.js +6 -3
  590. package/src/hooks/list-view.js +10 -11
  591. package/src/hooks/position.js +23 -27
  592. package/src/hooks/states.js +2 -2
  593. package/src/hooks/style.js +91 -9
  594. package/src/hooks/supports.js +0 -9
  595. package/src/hooks/test/background.js +59 -0
  596. package/src/hooks/test/block-style-state.js +14 -14
  597. package/src/hooks/test/dimensions.js +71 -0
  598. package/src/hooks/test/layout-child.js +165 -0
  599. package/src/hooks/test/layout.js +6 -6
  600. package/src/hooks/test/style.js +133 -11
  601. package/src/hooks/typography.js +70 -6
  602. package/src/layouts/flex.js +118 -15
  603. package/src/private-apis.js +8 -0
  604. package/src/store/actions.js +13 -3
  605. package/src/store/private-actions.js +1 -4
  606. package/src/store/private-selectors.js +89 -0
  607. package/src/store/reducer.js +19 -7
  608. package/src/store/selectors.js +91 -53
  609. package/src/store/test/actions.js +21 -0
  610. package/src/store/test/private-selectors.js +166 -7
  611. package/src/store/test/reducer.js +107 -10
  612. package/src/store/test/selectors.js +77 -0
  613. package/src/style.scss +1 -0
  614. package/src/utils/block-bindings.ts +51 -0
  615. package/src/utils/color-values.ts +63 -0
  616. package/src/utils/{dom.js → dom.ts} +27 -27
  617. package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
  618. package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
  619. package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
  620. package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
  621. package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
  622. package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
  623. package/src/utils/{math.js → math.ts} +37 -30
  624. package/src/utils/object.ts +89 -0
  625. package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
  626. package/src/utils/{pasting.js → pasting.ts} +18 -11
  627. package/src/utils/{selection.js → selection.ts} +11 -4
  628. package/src/utils/sorting.ts +81 -0
  629. package/src/utils/test/color-values.js +44 -1
  630. package/src/utils/transform-styles/{index.js → index.ts} +25 -25
  631. package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
  632. package/src/utils/transform-styles/types.ts +13 -0
  633. package/src/utils/types.ts +29 -0
  634. package/build/components/media-upload-progress/constants.cjs +0 -46
  635. package/build/components/media-upload-progress/constants.cjs.map +0 -7
  636. package/build/components/rich-text/native/format-edit.cjs +0 -60
  637. package/build/components/rich-text/native/format-edit.cjs.map +0 -7
  638. package/build/components/rich-text/native/index.cjs.map +0 -7
  639. package/build/components/rich-text/native/use-format-types.cjs +0 -139
  640. package/build/components/rich-text/native/use-format-types.cjs.map +0 -7
  641. package/build-module/components/media-upload-progress/constants.mjs +0 -16
  642. package/build-module/components/media-upload-progress/constants.mjs.map +0 -7
  643. package/build-module/components/rich-text/native/format-edit.mjs +0 -39
  644. package/build-module/components/rich-text/native/format-edit.mjs.map +0 -7
  645. package/build-module/components/rich-text/native/index.mjs +0 -7
  646. package/build-module/components/rich-text/native/index.mjs.map +0 -7
  647. package/build-module/components/rich-text/native/use-format-types.mjs +0 -114
  648. package/build-module/components/rich-text/native/use-format-types.mjs.map +0 -7
  649. package/src/components/audio-player/audio-url-parser.native.js +0 -20
  650. package/src/components/audio-player/index.native.js +0 -225
  651. package/src/components/audio-player/styles.native.scss +0 -114
  652. package/src/components/audio-player/test/audio-url-parser.native.js +0 -53
  653. package/src/components/block-alignment-control/test/index.native.js +0 -37
  654. package/src/components/block-alignment-control/ui.native.js +0 -86
  655. package/src/components/block-caption/README.md +0 -104
  656. package/src/components/block-caption/index.native.js +0 -89
  657. package/src/components/block-caption/styles.native.scss +0 -7
  658. package/src/components/block-controls/slot.native.js +0 -33
  659. package/src/components/block-draggable/draggable-chip.native.js +0 -49
  660. package/src/components/block-draggable/dropping-insertion-point.native.js +0 -181
  661. package/src/components/block-draggable/dropping-insertion-point.native.scss +0 -8
  662. package/src/components/block-draggable/index.native.js +0 -467
  663. package/src/components/block-draggable/style.native.scss +0 -19
  664. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +0 -73
  665. package/src/components/block-draggable/test/helpers.native.js +0 -182
  666. package/src/components/block-draggable/test/index.native.js +0 -419
  667. package/src/components/block-draggable/use-scroll-when-dragging.native.js +0 -135
  668. package/src/components/block-edit/edit.native.js +0 -49
  669. package/src/components/block-edit/test/edit.native.js +0 -65
  670. package/src/components/block-heading-level-dropdown/index.native.js +0 -68
  671. package/src/components/block-icon/index.native.js +0 -47
  672. package/src/components/block-icon/style.native.scss +0 -7
  673. package/src/components/block-list/block-crash-boundary.native.js +0 -43
  674. package/src/components/block-list/block-crash-warning.native.js +0 -21
  675. package/src/components/block-list/block-invalid-warning.native.js +0 -70
  676. package/src/components/block-list/block-list-context.native.js +0 -172
  677. package/src/components/block-list/block-list-item-cell.native.js +0 -62
  678. package/src/components/block-list/block-list-item.native.js +0 -209
  679. package/src/components/block-list/block-list-item.native.scss +0 -16
  680. package/src/components/block-list/block-outline.native.js +0 -77
  681. package/src/components/block-list/block-selection-button.native.js +0 -100
  682. package/src/components/block-list/block-selection-button.native.scss +0 -34
  683. package/src/components/block-list/block.native.js +0 -716
  684. package/src/components/block-list/block.native.scss +0 -62
  685. package/src/components/block-list/grid-item.native.js +0 -58
  686. package/src/components/block-list/index.native.js +0 -437
  687. package/src/components/block-list/insertion-point.native.js +0 -36
  688. package/src/components/block-list/style.native.scss +0 -117
  689. package/src/components/block-list/test/block-invalid-warning.native.js +0 -62
  690. package/src/components/block-list/test/block-list-context.native.js +0 -243
  691. package/src/components/block-list/test/block-outline.native.js +0 -255
  692. package/src/components/block-list/test/fixtures/block-list-context.native.js +0 -79
  693. package/src/components/block-list/test/index.native.js +0 -205
  694. package/src/components/block-list/use-block-props/index.native.js +0 -10
  695. package/src/components/block-list/use-scroll-upon-insertion.native.js +0 -52
  696. package/src/components/block-list-appender/index.native.js +0 -70
  697. package/src/components/block-list-appender/style.native.scss +0 -8
  698. package/src/components/block-media-update-progress/README.md +0 -100
  699. package/src/components/block-media-update-progress/index.native.js +0 -299
  700. package/src/components/block-media-update-progress/styles.native.scss +0 -9
  701. package/src/components/block-media-update-progress/test/index.native.js +0 -543
  702. package/src/components/block-mover/index.native.js +0 -193
  703. package/src/components/block-mover/mover-description.native.js +0 -155
  704. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -218
  705. package/src/components/block-mover/test/index.native.js +0 -186
  706. package/src/components/block-settings/button.native.js +0 -41
  707. package/src/components/block-settings/container.native.js +0 -91
  708. package/src/components/block-settings/container.native.scss +0 -4
  709. package/src/components/block-settings/index.native.js +0 -5
  710. package/src/components/block-styles/index.native.js +0 -94
  711. package/src/components/block-styles/preview.native.js +0 -109
  712. package/src/components/block-styles/style.native.scss +0 -64
  713. package/src/components/block-switcher/block-transformations-menu.native.js +0 -91
  714. package/src/components/block-toolbar/block-toolbar-menu.native.js +0 -477
  715. package/src/components/block-toolbar/index.native.js +0 -126
  716. package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +0 -125
  717. package/src/components/block-toolbar/test/block-toolbar-menu.native.js +0 -405
  718. package/src/components/block-toolbar/test/index.native.js +0 -36
  719. package/src/components/block-types-list/index.native.js +0 -175
  720. package/src/components/block-types-list/style.native.scss +0 -25
  721. package/src/components/block-variation-picker/index.native.js +0 -107
  722. package/src/components/block-variation-picker/style.native.scss +0 -32
  723. package/src/components/button-block-appender/index.native.js +0 -92
  724. package/src/components/button-block-appender/styles.native.scss +0 -43
  725. package/src/components/caption/README.md +0 -44
  726. package/src/components/caption/index.native.js +0 -61
  727. package/src/components/colors-gradients/panel-color-gradient-settings.native.js +0 -59
  728. package/src/components/contrast-checker/index.native.js +0 -113
  729. package/src/components/contrast-checker/style.native.scss +0 -26
  730. package/src/components/convert-to-group-buttons/index.native.js +0 -79
  731. package/src/components/default-block-appender/index.native.js +0 -113
  732. package/src/components/default-block-appender/style.native.scss +0 -18
  733. package/src/components/floating-toolbar/floatingToolbar.android.scss +0 -4
  734. package/src/components/floating-toolbar/floatingToolbar.ios.scss +0 -3
  735. package/src/components/floating-toolbar/index.native.js +0 -141
  736. package/src/components/floating-toolbar/styles.native.scss +0 -43
  737. package/src/components/font-sizes/index.native.js +0 -7
  738. package/src/components/global-styles/color-panel.native.js +0 -207
  739. package/src/components/global-styles/test/use-global-styles-context.native.js +0 -435
  740. package/src/components/global-styles/use-global-styles-context.native.js +0 -592
  741. package/src/components/gradients/index.native.js +0 -2
  742. package/src/components/image-link-destinations/index.native.js +0 -152
  743. package/src/components/image-link-destinations/style.native.scss +0 -16
  744. package/src/components/index.native.js +0 -108
  745. package/src/components/inner-blocks/constants.native.js +0 -5
  746. package/src/components/inner-blocks/index.native.js +0 -221
  747. package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +0 -124
  748. package/src/components/inserter/block-types-tab.native.js +0 -76
  749. package/src/components/inserter/hooks/use-block-type-impressions.native.js +0 -47
  750. package/src/components/inserter/hooks/use-clipboard-block.native.js +0 -40
  751. package/src/components/inserter/index.native.js +0 -424
  752. package/src/components/inserter/menu.native.js +0 -237
  753. package/src/components/inserter/no-results.native.js +0 -49
  754. package/src/components/inserter/reusable-blocks-tab.native.js +0 -45
  755. package/src/components/inserter/search-results.native.js +0 -67
  756. package/src/components/inserter/style.native.scss +0 -83
  757. package/src/components/inserter/tabs.native.js +0 -152
  758. package/src/components/inserter/test/__snapshots__/index.native.js.snap +0 -117
  759. package/src/components/inserter/test/fixtures/index.native.js +0 -12
  760. package/src/components/inserter/test/index.native.js +0 -273
  761. package/src/components/inserter/test/reusable-blocks-tab.native.js +0 -62
  762. package/src/components/inserter/test/utils.native.js +0 -37
  763. package/src/components/inserter/utils.native.js +0 -46
  764. package/src/components/inserter-button/index.native.js +0 -108
  765. package/src/components/inserter-button/style.native.scss +0 -72
  766. package/src/components/inspector-controls/fill.native.js +0 -62
  767. package/src/components/inspector-controls/slot.native.js +0 -35
  768. package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +0 -31
  769. package/src/components/line-height-control/index.native.js +0 -28
  770. package/src/components/media-placeholder/index.native.js +0 -258
  771. package/src/components/media-placeholder/styles.native.scss +0 -108
  772. package/src/components/media-replace-flow/index.native.js +0 -12
  773. package/src/components/media-upload/constants.native.js +0 -14
  774. package/src/components/media-upload/index.native.js +0 -356
  775. package/src/components/media-upload/style.native.scss +0 -4
  776. package/src/components/media-upload/test/index.native.js +0 -172
  777. package/src/components/media-upload-progress/README.md +0 -100
  778. package/src/components/media-upload-progress/constants.js +0 -6
  779. package/src/components/media-upload-progress/index.native.js +0 -233
  780. package/src/components/media-upload-progress/styles.native.scss +0 -15
  781. package/src/components/media-upload-progress/test/index.native.js +0 -220
  782. package/src/components/plain-text/index.native.js +0 -164
  783. package/src/components/plain-text/style.native.scss +0 -10
  784. package/src/components/provider/index.native.js +0 -32
  785. package/src/components/rich-text/embed-handler-picker.native.js +0 -65
  786. package/src/components/rich-text/file-paste-handler.native.js +0 -3
  787. package/src/components/rich-text/format-toolbar/index.native.js +0 -21
  788. package/src/components/rich-text/format-toolbar-container.native.js +0 -16
  789. package/src/components/rich-text/index.native.js +0 -701
  790. package/src/components/rich-text/input-event.native.js +0 -10
  791. package/src/components/rich-text/native/format-edit.js +0 -44
  792. package/src/components/rich-text/native/get-format-colors.native.js +0 -47
  793. package/src/components/rich-text/native/index.js +0 -1
  794. package/src/components/rich-text/native/index.native.js +0 -1389
  795. package/src/components/rich-text/native/style.native.scss +0 -28
  796. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +0 -79
  797. package/src/components/rich-text/native/test/index.native.js +0 -345
  798. package/src/components/rich-text/native/test/performance/rich-text.native.js +0 -44
  799. package/src/components/rich-text/native/toolbar-button-with-options.native.js +0 -61
  800. package/src/components/rich-text/native/use-format-types.js +0 -146
  801. package/src/components/rich-text/remove-browser-shortcuts.native.js +0 -1
  802. package/src/components/rich-text/shortcut.native.js +0 -10
  803. package/src/components/ungroup-button/README.md +0 -23
  804. package/src/components/ungroup-button/index.native.js +0 -77
  805. package/src/components/unsupported-block-details/index.native.js +0 -187
  806. package/src/components/unsupported-block-details/style.native.scss +0 -56
  807. package/src/components/url-input/index.native.js +0 -33
  808. package/src/components/use-block-drop-zone/index.native.js +0 -207
  809. package/src/components/use-on-block-drop/index.native.js +0 -115
  810. package/src/components/use-unsupported-block-editor/index.native.js +0 -59
  811. package/src/components/video-player/gridicon-play.native.js +0 -13
  812. package/src/components/video-player/index.native.js +0 -133
  813. package/src/components/video-player/styles.native.scss +0 -29
  814. package/src/components/warning/index.native.js +0 -64
  815. package/src/components/warning/style.native.scss +0 -47
  816. package/src/hooks/align.native.js +0 -49
  817. package/src/hooks/custom-class-name.native.js +0 -70
  818. package/src/hooks/index.native.js +0 -36
  819. package/src/hooks/layout.native.js +0 -23
  820. package/src/hooks/test/__snapshots__/align.native.js.snap +0 -73
  821. package/src/hooks/test/__snapshots__/anchor.native.js.snap +0 -7
  822. package/src/hooks/test/align.native.js +0 -134
  823. package/src/hooks/test/anchor.native.js +0 -32
  824. package/src/hooks/test/use-editor-wrapper-styles.native.js +0 -282
  825. package/src/hooks/typography.native.js +0 -60
  826. package/src/hooks/use-editor-wrapper-styles.native.js +0 -250
  827. package/src/hooks/use-editor-wrapper-styles.native.scss +0 -12
  828. package/src/index.native.js +0 -6
  829. package/src/private-apis.native.js +0 -21
  830. package/src/store/defaults.native.js +0 -23
  831. package/src/utils/block-bindings.js +0 -46
  832. package/src/utils/color-values.js +0 -28
  833. package/src/utils/object.js +0 -67
  834. package/src/utils/sorting.js +0 -54
  835. /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
  836. /package/src/utils/{index.js → index.ts} +0 -0
@@ -1,19 +1,19 @@
1
- // packages/block-editor/src/utils/block-bindings.js
1
+ // packages/block-editor/src/utils/block-bindings.ts
2
2
  var DEFAULT_ATTRIBUTE = "__default";
3
3
  var PATTERN_OVERRIDES_SOURCE = "core/pattern-overrides";
4
4
  function hasPatternOverridesDefaultBinding(bindings) {
5
5
  return bindings?.[DEFAULT_ATTRIBUTE]?.source === PATTERN_OVERRIDES_SOURCE;
6
6
  }
7
7
  function replacePatternOverridesDefaultBinding(bindings, supportedAttributes) {
8
- if (hasPatternOverridesDefaultBinding(bindings)) {
9
- const bindingsWithDefaults = {};
10
- for (const attributeName of supportedAttributes) {
11
- const bindingSource = bindings[attributeName] ? bindings[attributeName] : { source: PATTERN_OVERRIDES_SOURCE };
12
- bindingsWithDefaults[attributeName] = bindingSource;
13
- }
14
- return bindingsWithDefaults;
8
+ if (!hasPatternOverridesDefaultBinding(bindings)) {
9
+ return bindings;
15
10
  }
16
- return bindings;
11
+ const bindingsWithDefaults = {};
12
+ for (const attributeName of supportedAttributes) {
13
+ const bindingSource = bindings[attributeName] ? bindings[attributeName] : { source: PATTERN_OVERRIDES_SOURCE };
14
+ bindingsWithDefaults[attributeName] = bindingSource;
15
+ }
16
+ return bindingsWithDefaults;
17
17
  }
18
18
  export {
19
19
  hasPatternOverridesDefaultBinding,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/block-bindings.js"],
4
- "sourcesContent": ["const DEFAULT_ATTRIBUTE = '__default';\nconst PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';\n\n/**\n * Checks if the block has the `__default` binding for pattern overrides.\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {boolean} Whether the block has the `__default` binding for pattern overrides.\n */\nexport function hasPatternOverridesDefaultBinding( bindings ) {\n\treturn bindings?.[ DEFAULT_ATTRIBUTE ]?.source === PATTERN_OVERRIDES_SOURCE;\n}\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * - bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * - bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n * @param {string[]} supportedAttributes The block's attributes which are supported by block bindings.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nexport function replacePatternOverridesDefaultBinding(\n\tbindings,\n\tsupportedAttributes\n) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif ( hasPatternOverridesDefaultBinding( bindings ) ) {\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: PATTERN_OVERRIDES_SOURCE };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n"],
5
- "mappings": ";AAAA,IAAM,oBAAoB;AAC1B,IAAM,2BAA2B;AAS1B,SAAS,kCAAmC,UAAW;AAC7D,SAAO,WAAY,iBAAkB,GAAG,WAAW;AACpD;AAcO,SAAS,sCACf,UACA,qBACC;AAED,MAAK,kCAAmC,QAAS,GAAI;AACpD,UAAM,uBAAuB,CAAC;AAC9B,eAAY,iBAAiB,qBAAsB;AAElD,YAAM,gBAAgB,SAAU,aAAc,IAC3C,SAAU,aAAc,IACxB,EAAE,QAAQ,yBAAyB;AACtC,2BAAsB,aAAc,IAAI;AAAA,IACzC;AAEA,WAAO;AAAA,EACR;AAEA,SAAO;AACR;",
3
+ "sources": ["../../src/utils/block-bindings.ts"],
4
+ "sourcesContent": ["type Binding = { source?: string };\ntype Bindings = Record< string, Binding >;\n\nconst DEFAULT_ATTRIBUTE = '__default';\nconst PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';\n\n/**\n * Checks if the block has the `__default` binding for pattern overrides.\n *\n * @param bindings A block's bindings from the metadata attribute.\n *\n * @return Whether the block has the `__default` binding for pattern overrides.\n */\nexport function hasPatternOverridesDefaultBinding(\n\tbindings: Bindings | undefined | null\n): bindings is Bindings {\n\treturn bindings?.[ DEFAULT_ATTRIBUTE ]?.source === PATTERN_OVERRIDES_SOURCE;\n}\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * - bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * - bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param bindings A block's bindings from the metadata attribute.\n * @param supportedAttributes The block's attributes which are supported by block bindings.\n *\n * @return The bindings with default replaced for pattern overrides.\n */\nexport function replacePatternOverridesDefaultBinding(\n\tbindings: Bindings | undefined | null,\n\tsupportedAttributes: string[]\n) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif ( ! hasPatternOverridesDefaultBinding( bindings ) ) {\n\t\treturn bindings;\n\t}\n\n\tconst bindingsWithDefaults: Bindings = {};\n\tfor ( const attributeName of supportedAttributes ) {\n\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t? bindings[ attributeName ]\n\t\t\t: { source: PATTERN_OVERRIDES_SOURCE };\n\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t}\n\n\treturn bindingsWithDefaults;\n}\n"],
5
+ "mappings": ";AAGA,IAAM,oBAAoB;AAC1B,IAAM,2BAA2B;AAS1B,SAAS,kCACf,UACuB;AACvB,SAAO,WAAY,iBAAkB,GAAG,WAAW;AACpD;AAcO,SAAS,sCACf,UACA,qBACC;AAED,MAAK,CAAE,kCAAmC,QAAS,GAAI;AACtD,WAAO;AAAA,EACR;AAEA,QAAM,uBAAiC,CAAC;AACxC,aAAY,iBAAiB,qBAAsB;AAElD,UAAM,gBAAgB,SAAU,aAAc,IAC3C,SAAU,aAAc,IACxB,EAAE,QAAQ,yBAAyB;AACtC,yBAAsB,aAAc,IAAI;AAAA,EACzC;AAEA,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/block-editor/src/utils/color-values.js
1
+ // packages/block-editor/src/utils/color-values.ts
2
2
  function extractPresetSlug(rawValue, type) {
3
3
  if (typeof rawValue !== "string") {
4
4
  return void 0;
@@ -13,7 +13,15 @@ function extractPresetSlug(rawValue, type) {
13
13
  );
14
14
  return themeFormatMatch?.[1];
15
15
  }
16
+ function encodeColorValueWithPalette(allColors, colorValue, slug) {
17
+ if (slug) {
18
+ return "var:preset|color|" + slug;
19
+ }
20
+ const colorObject = allColors.find(({ color }) => color === colorValue);
21
+ return colorObject ? "var:preset|color|" + colorObject.slug : colorValue;
22
+ }
16
23
  export {
24
+ encodeColorValueWithPalette,
17
25
  extractPresetSlug
18
26
  };
19
27
  //# sourceMappingURL=color-values.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/color-values.js"],
4
- "sourcesContent": ["/**\n * Extracts the palette slug from a style value for any preset type, supporting\n * both the user preset format and the theme CSS-variable format:\n *\n * - User format: `var:preset|<type>|slug`\n * - Theme format: `var(--wp--preset--<type>--slug)`\n *\n * Returns `undefined` for plain values, non-strings, or any other\n * unrecognised format.\n *\n * @param {*} rawValue Raw style value stored in the style object.\n * @param {'color'|'gradient'} type Preset type, e.g. `'color'` or `'gradient'`.\n * @return {string|undefined} The palette slug, or undefined.\n */\nexport function extractPresetSlug( rawValue, type ) {\n\tif ( typeof rawValue !== 'string' ) {\n\t\treturn undefined;\n\t}\n\tconst userPrefix = `var:preset|${ type }|`;\n\tif ( rawValue.startsWith( userPrefix ) ) {\n\t\treturn rawValue.slice( userPrefix.length );\n\t}\n\tconst cssVarPrefix = `--wp--preset--${ type }--`;\n\tconst themeFormatMatch = rawValue.match(\n\t\tnew RegExp( `^var\\\\(${ cssVarPrefix }([^)]+)\\\\)$` )\n\t);\n\treturn themeFormatMatch?.[ 1 ];\n}\n"],
5
- "mappings": ";AAcO,SAAS,kBAAmB,UAAU,MAAO;AACnD,MAAK,OAAO,aAAa,UAAW;AACnC,WAAO;AAAA,EACR;AACA,QAAM,aAAa,cAAe,IAAK;AACvC,MAAK,SAAS,WAAY,UAAW,GAAI;AACxC,WAAO,SAAS,MAAO,WAAW,MAAO;AAAA,EAC1C;AACA,QAAM,eAAe,iBAAkB,IAAK;AAC5C,QAAM,mBAAmB,SAAS;AAAA,IACjC,IAAI,OAAQ,UAAW,YAAa,aAAc;AAAA,EACnD;AACA,SAAO,mBAAoB,CAAE;AAC9B;",
3
+ "sources": ["../../src/utils/color-values.ts"],
4
+ "sourcesContent": ["/**\n * Extracts the palette slug from a style value for any preset type, supporting\n * both the user preset format and the theme CSS-variable format:\n *\n * - User format: `var:preset|<type>|slug`\n * - Theme format: `var(--wp--preset--<type>--slug)`\n *\n * Returns `undefined` for plain values, non-strings, or any other\n * unrecognised format.\n *\n * @param rawValue Raw style value stored in the style object.\n * @param type Preset type, e.g. `'color'` or `'gradient'`.\n * @return The palette slug, or undefined.\n */\nexport function extractPresetSlug(\n\trawValue: unknown,\n\ttype: 'color' | 'gradient'\n) {\n\tif ( typeof rawValue !== 'string' ) {\n\t\treturn undefined;\n\t}\n\tconst userPrefix = `var:preset|${ type }|`;\n\tif ( rawValue.startsWith( userPrefix ) ) {\n\t\treturn rawValue.slice( userPrefix.length );\n\t}\n\tconst cssVarPrefix = `--wp--preset--${ type }--`;\n\tconst themeFormatMatch = rawValue.match(\n\t\tnew RegExp( `^var\\\\(${ cssVarPrefix }([^)]+)\\\\)$` )\n\t);\n\treturn themeFormatMatch?.[ 1 ];\n}\n\n/**\n * Encodes a color value for storage in the style object.\n *\n * When a `slug` is provided it is used directly (the slug-based selection\n * path). This is important because two palette entries can share the same\n * hex value (e.g. two custom colors both set to `#e10000`); relying on a\n * hex lookup alone would collapse them onto whichever entry appears first\n * in the palette and silently discard the user's actual choice. Only when\n * no slug is supplied does the function fall back to matching the hex value\n * against the palette; if a match is found the slug is encoded, otherwise\n * the raw value is stored as-is.\n *\n * Callers pass the flattened palette (`allColors`), typically computed once\n * per render from the per-origin `colors` array.\n *\n * @param allColors Flat array of `{ color, slug }` objects.\n * @param colorValue Hex or CSS color string.\n * @param slug Optional palette slug from slug-aware selection.\n * @return Encoded value suitable for the style object.\n */\nexport function encodeColorValueWithPalette(\n\tallColors: { color: string; slug: string }[],\n\tcolorValue?: string,\n\tslug?: string\n) {\n\tif ( slug ) {\n\t\treturn 'var:preset|color|' + slug;\n\t}\n\tconst colorObject = allColors.find( ( { color } ) => color === colorValue );\n\treturn colorObject ? 'var:preset|color|' + colorObject.slug : colorValue;\n}\n"],
5
+ "mappings": ";AAcO,SAAS,kBACf,UACA,MACC;AACD,MAAK,OAAO,aAAa,UAAW;AACnC,WAAO;AAAA,EACR;AACA,QAAM,aAAa,cAAe,IAAK;AACvC,MAAK,SAAS,WAAY,UAAW,GAAI;AACxC,WAAO,SAAS,MAAO,WAAW,MAAO;AAAA,EAC1C;AACA,QAAM,eAAe,iBAAkB,IAAK;AAC5C,QAAM,mBAAmB,SAAS;AAAA,IACjC,IAAI,OAAQ,UAAW,YAAa,aAAc;AAAA,EACnD;AACA,SAAO,mBAAoB,CAAE;AAC9B;AAsBO,SAAS,4BACf,WACA,YACA,MACC;AACD,MAAK,MAAO;AACX,WAAO,sBAAsB;AAAA,EAC9B;AACA,QAAM,cAAc,UAAU,KAAM,CAAE,EAAE,MAAM,MAAO,UAAU,UAAW;AAC1E,SAAO,cAAc,sBAAsB,YAAY,OAAO;AAC/D;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/block-editor/src/utils/dom.js
1
+ // packages/block-editor/src/utils/dom.ts
2
2
  var BLOCK_SELECTOR = ".block-editor-block-list__block";
3
3
  var APPENDER_SELECTOR = ".block-list-appender";
4
4
  var BLOCK_APPENDER_CLASS = ".block-editor-button-block-appender";
@@ -18,10 +18,7 @@ function getBlockClientId(node) {
18
18
  if (!node) {
19
19
  return;
20
20
  }
21
- const elementNode = (
22
- /** @type {Element} */
23
- node
24
- );
21
+ const elementNode = node;
25
22
  const blockNode = elementNode.closest(BLOCK_SELECTOR);
26
23
  if (!blockNode) {
27
24
  return;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/dom.js"],
4
- "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 */\nexport function isElementVisible( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\tif ( ! viewport ) {\n\t\treturn false;\n\t}\n\n\t// Check for <VisuallyHidden> components.\n\tif ( element.hasAttribute( 'data-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 * Checks if the element is scrollable.\n *\n * @param {Element} element Element.\n * @return {boolean} True if the element is scrollable.\n */\nfunction isScrollable( element ) {\n\tconst style = window.getComputedStyle( element );\n\treturn (\n\t\tstyle.overflowX === 'auto' ||\n\t\tstyle.overflowX === 'scroll' ||\n\t\tstyle.overflowY === 'auto' ||\n\t\tstyle.overflowY === 'scroll'\n\t);\n}\n\nexport const WITH_OVERFLOW_ELEMENT_BLOCKS = [ 'core/navigation' ];\n/**\n * Returns the bounding rectangle of an element, with special handling for blocks\n * that have visible overflowing children (defined in WITH_OVERFLOW_ELEMENT_BLOCKS).\n *\n * For blocks like Navigation that can have overflowing elements (e.g. submenus),\n * this function calculates the combined bounds of both the parent and its visible\n * children. The returned rect may extend beyond the viewport.\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 getElementBounds( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\n\tif ( ! viewport ) {\n\t\treturn new window.DOMRectReadOnly();\n\t}\n\n\tlet bounds = element.getBoundingClientRect();\n\tconst dataType = element.getAttribute( 'data-type' );\n\n\t/*\n\t * For blocks with overflowing elements (like Navigation), include the bounds\n\t * of visible children that extend beyond the parent container.\n\t */\n\tif ( dataType && WITH_OVERFLOW_ELEMENT_BLOCKS.includes( dataType ) ) {\n\t\tconst stack = [ element ];\n\t\tlet currentElement;\n\n\t\twhile ( ( currentElement = stack.pop() ) ) {\n\t\t\t// Children won\u2019t affect bounds unless the element is not scrollable.\n\t\t\tif ( ! isScrollable( currentElement ) ) {\n\t\t\t\tfor ( const child of currentElement.children ) {\n\t\t\t\t\tif ( isElementVisible( child ) ) {\n\t\t\t\t\t\tconst childBounds = child.getBoundingClientRect();\n\t\t\t\t\t\tbounds = rectUnion( bounds, childBounds );\n\t\t\t\t\t\tstack.push( child );\n\t\t\t\t\t}\n\t\t\t\t}\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"],
5
- "mappings": "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",
3
+ "sources": ["../../src/utils/dom.ts"],
4
+ "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 a First element.\n * @param b Second element.\n *\n * @return Whether elements are in the same block.\n */\nexport function isInSameBlock( a: Element, b: Element ) {\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 blockElement Block container element.\n * @param element Element.\n *\n * @return Whether an element is considered part of the block and not\n * its inner blocks or appender.\n */\nexport function isInsideRootBlock( blockElement: Element, element: 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 DOM node.\n *\n * @return Client ID or undefined if the node is not part of\n * a block.\n */\nexport function getBlockClientId( node: Node | null ) {\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 = node as Element;\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 rect1 First rectangle.\n * @param rect2 Second rectangle.\n * @return Union of the two rectangles.\n */\nexport function rectUnion( rect1: DOMRect, rect2: DOMRect ) {\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.\n * @return Whether the element is visible.\n */\nexport function isElementVisible( element: Element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\tif ( ! viewport ) {\n\t\treturn false;\n\t}\n\n\t// Check for <VisuallyHidden> components.\n\tif ( element.hasAttribute( 'data-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 * Checks if the element is scrollable.\n *\n * @param element Element.\n * @return True if the element is scrollable.\n */\nfunction isScrollable( element: Element ) {\n\tconst style = window.getComputedStyle( element );\n\treturn (\n\t\tstyle.overflowX === 'auto' ||\n\t\tstyle.overflowX === 'scroll' ||\n\t\tstyle.overflowY === 'auto' ||\n\t\tstyle.overflowY === 'scroll'\n\t);\n}\n\nexport const WITH_OVERFLOW_ELEMENT_BLOCKS = [ 'core/navigation' ];\n/**\n * Returns the bounding rectangle of an element, with special handling for blocks\n * that have visible overflowing children (defined in WITH_OVERFLOW_ELEMENT_BLOCKS).\n *\n * For blocks like Navigation that can have overflowing elements (e.g. submenus),\n * this function calculates the combined bounds of both the parent and its visible\n * children. The returned rect may extend beyond the viewport.\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.\n * @return Bounding client rect of the element and its visible children.\n */\nexport function getElementBounds( element: Element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\n\tif ( ! viewport ) {\n\t\treturn new window.DOMRectReadOnly();\n\t}\n\n\tlet bounds = element.getBoundingClientRect();\n\tconst dataType = element.getAttribute( 'data-type' );\n\n\t/*\n\t * For blocks with overflowing elements (like Navigation), include the bounds\n\t * of visible children that extend beyond the parent container.\n\t */\n\tif ( dataType && WITH_OVERFLOW_ELEMENT_BLOCKS.includes( dataType ) ) {\n\t\tconst stack = [ element ];\n\t\tlet currentElement;\n\n\t\twhile ( ( currentElement = stack.pop() ) ) {\n\t\t\t// Children won’t affect bounds unless the element is not scrollable.\n\t\t\tif ( ! isScrollable( currentElement ) ) {\n\t\t\t\tfor ( const child of currentElement.children ) {\n\t\t\t\t\tif ( isElementVisible( child ) ) {\n\t\t\t\t\t\tconst childBounds = child.getBoundingClientRect();\n\t\t\t\t\t\tbounds = rectUnion( bounds, childBounds );\n\t\t\t\t\t\tstack.push( child );\n\t\t\t\t\t}\n\t\t\t\t}\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"],
5
+ "mappings": "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",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/block-editor/src/utils/fit-text-frontend.js
1
+ // packages/block-editor/src/utils/fit-text-frontend.ts
2
2
  import { store, getElement, getContext } from "@wordpress/interactivity";
3
3
  import { optimizeFitText } from "./fit-text-utils.mjs";
4
4
  store("core/fit-text", {
@@ -7,6 +7,9 @@ store("core/fit-text", {
7
7
  const context = getContext();
8
8
  const { ref } = getElement();
9
9
  const applyFontSize = (fontSize) => {
10
+ if (!ref) {
11
+ return;
12
+ }
10
13
  if (fontSize === 0) {
11
14
  ref.style.fontSize = "";
12
15
  } else {
@@ -14,7 +17,7 @@ store("core/fit-text", {
14
17
  }
15
18
  };
16
19
  context.fontSize = optimizeFitText(ref, applyFontSize);
17
- if (window.ResizeObserver && ref.parentElement) {
20
+ if (window.ResizeObserver && ref?.parentElement) {
18
21
  const resizeObserver = new window.ResizeObserver(() => {
19
22
  context.fontSize = optimizeFitText(ref, applyFontSize);
20
23
  });
@@ -26,6 +29,7 @@ store("core/fit-text", {
26
29
  }
27
30
  };
28
31
  }
32
+ return void 0;
29
33
  }
30
34
  }
31
35
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/fit-text-frontend.js"],
4
- "sourcesContent": ["/**\n * Frontend fit text functionality.\n * Automatically detects and initializes fit text on blocks with the has-fit-text class.\n * Supports both initial page load and Interactivity API client-side navigation.\n */\n\n/**\n * WordPress dependencies\n */\nimport { store, getElement, getContext } from '@wordpress/interactivity';\n\n/**\n * Internal dependencies\n */\nimport { optimizeFitText } from './fit-text-utils';\n\n// Initialize via Interactivity API for client-side navigation\nstore( 'core/fit-text', {\n\tcallbacks: {\n\t\tinit() {\n\t\t\tconst context = getContext();\n\t\t\tconst { ref } = getElement();\n\n\t\t\tconst applyFontSize = ( fontSize ) => {\n\t\t\t\tif ( fontSize === 0 ) {\n\t\t\t\t\tref.style.fontSize = '';\n\t\t\t\t} else {\n\t\t\t\t\tref.style.fontSize = `${ fontSize }px`;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Initial fit text optimization.\n\t\t\tcontext.fontSize = optimizeFitText( ref, applyFontSize );\n\n\t\t\t// Starts ResizeObserver to handle dynamic resizing.\n\t\t\tif ( window.ResizeObserver && ref.parentElement ) {\n\t\t\t\tconst resizeObserver = new window.ResizeObserver( () => {\n\t\t\t\t\tcontext.fontSize = optimizeFitText( ref, applyFontSize );\n\t\t\t\t} );\n\t\t\t\tresizeObserver.observe( ref.parentElement );\n\t\t\t\tresizeObserver.observe( ref );\n\n\t\t\t\t// Return cleanup function to be called when element is removed.\n\t\t\t\treturn () => {\n\t\t\t\t\tif ( resizeObserver ) {\n\t\t\t\t\t\tresizeObserver.disconnect();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t},\n} );\n"],
5
- "mappings": ";AASA,SAAS,OAAO,YAAY,kBAAkB;AAK9C,SAAS,uBAAuB;AAGhC,MAAO,iBAAiB;AAAA,EACvB,WAAW;AAAA,IACV,OAAO;AACN,YAAM,UAAU,WAAW;AAC3B,YAAM,EAAE,IAAI,IAAI,WAAW;AAE3B,YAAM,gBAAgB,CAAE,aAAc;AACrC,YAAK,aAAa,GAAI;AACrB,cAAI,MAAM,WAAW;AAAA,QACtB,OAAO;AACN,cAAI,MAAM,WAAW,GAAI,QAAS;AAAA,QACnC;AAAA,MACD;AAGA,cAAQ,WAAW,gBAAiB,KAAK,aAAc;AAGvD,UAAK,OAAO,kBAAkB,IAAI,eAAgB;AACjD,cAAM,iBAAiB,IAAI,OAAO,eAAgB,MAAM;AACvD,kBAAQ,WAAW,gBAAiB,KAAK,aAAc;AAAA,QACxD,CAAE;AACF,uBAAe,QAAS,IAAI,aAAc;AAC1C,uBAAe,QAAS,GAAI;AAG5B,eAAO,MAAM;AACZ,cAAK,gBAAiB;AACrB,2BAAe,WAAW;AAAA,UAC3B;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD,CAAE;",
3
+ "sources": ["../../src/utils/fit-text-frontend.ts"],
4
+ "sourcesContent": ["/**\n * Frontend fit text functionality.\n * Automatically detects and initializes fit text on blocks with the has-fit-text class.\n * Supports both initial page load and Interactivity API client-side navigation.\n */\n\n/**\n * WordPress dependencies\n */\nimport { store, getElement, getContext } from '@wordpress/interactivity';\n\n/**\n * Internal dependencies\n */\nimport { optimizeFitText } from './fit-text-utils';\n\ninterface FitTextContext {\n\tfontSize?: number;\n}\n\n// Initialize via Interactivity API for client-side navigation\nstore( 'core/fit-text', {\n\tcallbacks: {\n\t\tinit() {\n\t\t\tconst context = getContext< FitTextContext >();\n\t\t\tconst { ref } = getElement() as { ref: HTMLElement | null };\n\n\t\t\tconst applyFontSize = ( fontSize: number ) => {\n\t\t\t\tif ( ! ref ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( fontSize === 0 ) {\n\t\t\t\t\tref.style.fontSize = '';\n\t\t\t\t} else {\n\t\t\t\t\tref.style.fontSize = `${ fontSize }px`;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Initial fit text optimization.\n\t\t\tcontext.fontSize = optimizeFitText( ref, applyFontSize );\n\n\t\t\t// Starts ResizeObserver to handle dynamic resizing.\n\t\t\tif ( window.ResizeObserver && ref?.parentElement ) {\n\t\t\t\tconst resizeObserver = new window.ResizeObserver( () => {\n\t\t\t\t\tcontext.fontSize = optimizeFitText( ref, applyFontSize );\n\t\t\t\t} );\n\t\t\t\tresizeObserver.observe( ref.parentElement );\n\t\t\t\tresizeObserver.observe( ref );\n\n\t\t\t\t// Return cleanup function to be called when element is removed.\n\t\t\t\treturn () => {\n\t\t\t\t\tif ( resizeObserver ) {\n\t\t\t\t\t\tresizeObserver.disconnect();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn undefined;\n\t\t},\n\t},\n} );\n"],
5
+ "mappings": ";AASA,SAAS,OAAO,YAAY,kBAAkB;AAK9C,SAAS,uBAAuB;AAOhC,MAAO,iBAAiB;AAAA,EACvB,WAAW;AAAA,IACV,OAAO;AACN,YAAM,UAAU,WAA6B;AAC7C,YAAM,EAAE,IAAI,IAAI,WAAW;AAE3B,YAAM,gBAAgB,CAAE,aAAsB;AAC7C,YAAK,CAAE,KAAM;AACZ;AAAA,QACD;AACA,YAAK,aAAa,GAAI;AACrB,cAAI,MAAM,WAAW;AAAA,QACtB,OAAO;AACN,cAAI,MAAM,WAAW,GAAI,QAAS;AAAA,QACnC;AAAA,MACD;AAGA,cAAQ,WAAW,gBAAiB,KAAK,aAAc;AAGvD,UAAK,OAAO,kBAAkB,KAAK,eAAgB;AAClD,cAAM,iBAAiB,IAAI,OAAO,eAAgB,MAAM;AACvD,kBAAQ,WAAW,gBAAiB,KAAK,aAAc;AAAA,QACxD,CAAE;AACF,uBAAe,QAAS,IAAI,aAAc;AAC1C,uBAAe,QAAS,GAAI;AAG5B,eAAO,MAAM;AACZ,cAAK,gBAAiB;AACrB,2BAAe,WAAW;AAAA,UAC3B;AAAA,QACD;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AACD,CAAE;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/block-editor/src/utils/fit-text-utils.js
1
+ // packages/block-editor/src/utils/fit-text-utils.ts
2
2
  function findOptimalFontSize(textElement, applyFontSize) {
3
3
  const alreadyHasScrollableHeight = textElement.scrollHeight > textElement.clientHeight;
4
4
  let minSize = 0;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/fit-text-utils.js"],
4
- "sourcesContent": ["/**\n * Shared utility functions for fit text functionality.\n * Uses callback-based approach for maximum code reuse between editor and frontend.\n */\n\n/**\n * Find optimal font size using simple binary search between 0-2400px.\n *\n * @param {HTMLElement} textElement The text element\n * @param {Function} applyFontSize Function that receives font size in pixels\n * @return {number} Optimal font size\n */\nfunction findOptimalFontSize( textElement, applyFontSize ) {\n\tconst alreadyHasScrollableHeight =\n\t\ttextElement.scrollHeight > textElement.clientHeight;\n\tlet minSize = 0;\n\tlet maxSize = 2400;\n\tlet bestSize = minSize;\n\n\tconst computedStyle = window.getComputedStyle( textElement );\n\tlet paddingLeft = parseFloat( computedStyle.paddingLeft ) || 0;\n\tlet paddingRight = parseFloat( computedStyle.paddingRight ) || 0;\n\tconst range = document.createRange();\n\trange.selectNodeContents( textElement );\n\n\tlet referenceElement = textElement;\n\tconst parentElement = textElement.parentElement;\n\tif ( parentElement ) {\n\t\tconst parentElementComputedStyle =\n\t\t\twindow.getComputedStyle( parentElement );\n\t\tif ( parentElementComputedStyle?.display === 'flex' ) {\n\t\t\treferenceElement = parentElement;\n\t\t\tpaddingLeft +=\n\t\t\t\tparseFloat( parentElementComputedStyle.paddingLeft ) || 0;\n\t\t\tpaddingRight +=\n\t\t\t\tparseFloat( parentElementComputedStyle.paddingRight ) || 0;\n\t\t}\n\t}\n\tlet maxclientHeight = referenceElement.clientHeight;\n\n\twhile ( minSize <= maxSize ) {\n\t\tconst midSize = Math.floor( ( minSize + maxSize ) / 2 );\n\t\tapplyFontSize( midSize );\n\n\t\t// When there is padding if the text overflows to the\n\t\t// padding area, it should be considered overflowing.\n\t\t// Use Range API to measure actual text content dimensions.\n\t\tconst rect = range.getBoundingClientRect();\n\t\tconst textWidth = rect.width;\n\n\t\t// Check if text fits within the element's width and is not\n\t\t// overflowing into the padding area.\n\t\tconst fitsWidth =\n\t\t\ttextElement.scrollWidth <= referenceElement.clientWidth &&\n\t\t\ttextWidth <=\n\t\t\t\treferenceElement.clientWidth - paddingLeft - paddingRight;\n\t\t// Check if text fits within the element's height.\n\t\tconst fitsHeight =\n\t\t\talreadyHasScrollableHeight ||\n\t\t\ttextElement.scrollHeight <= referenceElement.clientHeight ||\n\t\t\ttextElement.scrollHeight <= maxclientHeight;\n\n\t\t// When there are calculated line heights, text may jump in height\n\t\t// the available space may decrease while the font size decreases,\n\t\t// making text not fit.\n\t\t// We store a maximum reference height: the maximum reference element height that was observed\n\t\t// during the loop to avoid issues with such jumps.\n\t\tif ( referenceElement.clientHeight > maxclientHeight ) {\n\t\t\tmaxclientHeight = referenceElement.clientHeight;\n\t\t}\n\n\t\tif ( fitsWidth && fitsHeight ) {\n\t\t\tbestSize = midSize;\n\t\t\tminSize = midSize + 1;\n\t\t} else {\n\t\t\tmaxSize = midSize - 1;\n\t\t}\n\t}\n\trange.detach();\n\n\treturn bestSize;\n}\n\n/**\n * Complete fit text optimization for a single text element.\n * Handles the full flow using callbacks for font size application.\n *\n * @param {HTMLElement} textElement The text element (paragraph, heading, etc.)\n * @param {Function} applyFontSize Function that receives font size in pixels (0 to clear, >0 to apply)\n */\nexport function optimizeFitText( textElement, applyFontSize ) {\n\tif ( ! textElement ) {\n\t\treturn;\n\t}\n\n\tapplyFontSize( 0 );\n\n\tconst optimalSize = findOptimalFontSize( textElement, applyFontSize );\n\n\tapplyFontSize( optimalSize );\n\treturn optimalSize;\n}\n"],
5
- "mappings": ";AAYA,SAAS,oBAAqB,aAAa,eAAgB;AAC1D,QAAM,6BACL,YAAY,eAAe,YAAY;AACxC,MAAI,UAAU;AACd,MAAI,UAAU;AACd,MAAI,WAAW;AAEf,QAAM,gBAAgB,OAAO,iBAAkB,WAAY;AAC3D,MAAI,cAAc,WAAY,cAAc,WAAY,KAAK;AAC7D,MAAI,eAAe,WAAY,cAAc,YAAa,KAAK;AAC/D,QAAM,QAAQ,SAAS,YAAY;AACnC,QAAM,mBAAoB,WAAY;AAEtC,MAAI,mBAAmB;AACvB,QAAM,gBAAgB,YAAY;AAClC,MAAK,eAAgB;AACpB,UAAM,6BACL,OAAO,iBAAkB,aAAc;AACxC,QAAK,4BAA4B,YAAY,QAAS;AACrD,yBAAmB;AACnB,qBACC,WAAY,2BAA2B,WAAY,KAAK;AACzD,sBACC,WAAY,2BAA2B,YAAa,KAAK;AAAA,IAC3D;AAAA,EACD;AACA,MAAI,kBAAkB,iBAAiB;AAEvC,SAAQ,WAAW,SAAU;AAC5B,UAAM,UAAU,KAAK,OAAS,UAAU,WAAY,CAAE;AACtD,kBAAe,OAAQ;AAKvB,UAAM,OAAO,MAAM,sBAAsB;AACzC,UAAM,YAAY,KAAK;AAIvB,UAAM,YACL,YAAY,eAAe,iBAAiB,eAC5C,aACC,iBAAiB,cAAc,cAAc;AAE/C,UAAM,aACL,8BACA,YAAY,gBAAgB,iBAAiB,gBAC7C,YAAY,gBAAgB;AAO7B,QAAK,iBAAiB,eAAe,iBAAkB;AACtD,wBAAkB,iBAAiB;AAAA,IACpC;AAEA,QAAK,aAAa,YAAa;AAC9B,iBAAW;AACX,gBAAU,UAAU;AAAA,IACrB,OAAO;AACN,gBAAU,UAAU;AAAA,IACrB;AAAA,EACD;AACA,QAAM,OAAO;AAEb,SAAO;AACR;AASO,SAAS,gBAAiB,aAAa,eAAgB;AAC7D,MAAK,CAAE,aAAc;AACpB;AAAA,EACD;AAEA,gBAAe,CAAE;AAEjB,QAAM,cAAc,oBAAqB,aAAa,aAAc;AAEpE,gBAAe,WAAY;AAC3B,SAAO;AACR;",
3
+ "sources": ["../../src/utils/fit-text-utils.ts"],
4
+ "sourcesContent": ["/**\n * Shared utility functions for fit text functionality.\n * Uses callback-based approach for maximum code reuse between editor and frontend.\n */\n\ntype ApplyFontSize = ( size: number ) => void;\n\n/**\n * Find optimal font size using simple binary search between 0-2400px.\n *\n * @param textElement The text element\n * @param applyFontSize Function that receives font size in pixels\n * @return Optimal font size\n */\nfunction findOptimalFontSize(\n\ttextElement: HTMLElement,\n\tapplyFontSize: ApplyFontSize\n) {\n\tconst alreadyHasScrollableHeight =\n\t\ttextElement.scrollHeight > textElement.clientHeight;\n\tlet minSize = 0;\n\tlet maxSize = 2400;\n\tlet bestSize = minSize;\n\n\tconst computedStyle = window.getComputedStyle( textElement );\n\tlet paddingLeft = parseFloat( computedStyle.paddingLeft ) || 0;\n\tlet paddingRight = parseFloat( computedStyle.paddingRight ) || 0;\n\tconst range = document.createRange();\n\trange.selectNodeContents( textElement );\n\n\tlet referenceElement = textElement;\n\tconst parentElement = textElement.parentElement;\n\tif ( parentElement ) {\n\t\tconst parentElementComputedStyle =\n\t\t\twindow.getComputedStyle( parentElement );\n\t\tif ( parentElementComputedStyle?.display === 'flex' ) {\n\t\t\treferenceElement = parentElement;\n\t\t\tpaddingLeft +=\n\t\t\t\tparseFloat( parentElementComputedStyle.paddingLeft ) || 0;\n\t\t\tpaddingRight +=\n\t\t\t\tparseFloat( parentElementComputedStyle.paddingRight ) || 0;\n\t\t}\n\t}\n\tlet maxclientHeight = referenceElement.clientHeight;\n\n\twhile ( minSize <= maxSize ) {\n\t\tconst midSize = Math.floor( ( minSize + maxSize ) / 2 );\n\t\tapplyFontSize( midSize );\n\n\t\t// When there is padding if the text overflows to the\n\t\t// padding area, it should be considered overflowing.\n\t\t// Use Range API to measure actual text content dimensions.\n\t\tconst rect = range.getBoundingClientRect();\n\t\tconst textWidth = rect.width;\n\n\t\t// Check if text fits within the element's width and is not\n\t\t// overflowing into the padding area.\n\t\tconst fitsWidth =\n\t\t\ttextElement.scrollWidth <= referenceElement.clientWidth &&\n\t\t\ttextWidth <=\n\t\t\t\treferenceElement.clientWidth - paddingLeft - paddingRight;\n\t\t// Check if text fits within the element's height.\n\t\tconst fitsHeight =\n\t\t\talreadyHasScrollableHeight ||\n\t\t\ttextElement.scrollHeight <= referenceElement.clientHeight ||\n\t\t\ttextElement.scrollHeight <= maxclientHeight;\n\n\t\t// When there are calculated line heights, text may jump in height\n\t\t// the available space may decrease while the font size decreases,\n\t\t// making text not fit.\n\t\t// We store a maximum reference height: the maximum reference element height that was observed\n\t\t// during the loop to avoid issues with such jumps.\n\t\tif ( referenceElement.clientHeight > maxclientHeight ) {\n\t\t\tmaxclientHeight = referenceElement.clientHeight;\n\t\t}\n\n\t\tif ( fitsWidth && fitsHeight ) {\n\t\t\tbestSize = midSize;\n\t\t\tminSize = midSize + 1;\n\t\t} else {\n\t\t\tmaxSize = midSize - 1;\n\t\t}\n\t}\n\trange.detach();\n\n\treturn bestSize;\n}\n\n/**\n * Complete fit text optimization for a single text element.\n * Handles the full flow using callbacks for font size application.\n *\n * @param textElement The text element (paragraph, heading, etc.)\n * @param applyFontSize Function that receives font size in pixels (0 to clear, >0 to apply)\n */\nexport function optimizeFitText(\n\ttextElement: HTMLElement | null,\n\tapplyFontSize: ApplyFontSize\n) {\n\tif ( ! textElement ) {\n\t\treturn;\n\t}\n\n\tapplyFontSize( 0 );\n\n\tconst optimalSize = findOptimalFontSize( textElement, applyFontSize );\n\n\tapplyFontSize( optimalSize );\n\treturn optimalSize;\n}\n"],
5
+ "mappings": ";AAcA,SAAS,oBACR,aACA,eACC;AACD,QAAM,6BACL,YAAY,eAAe,YAAY;AACxC,MAAI,UAAU;AACd,MAAI,UAAU;AACd,MAAI,WAAW;AAEf,QAAM,gBAAgB,OAAO,iBAAkB,WAAY;AAC3D,MAAI,cAAc,WAAY,cAAc,WAAY,KAAK;AAC7D,MAAI,eAAe,WAAY,cAAc,YAAa,KAAK;AAC/D,QAAM,QAAQ,SAAS,YAAY;AACnC,QAAM,mBAAoB,WAAY;AAEtC,MAAI,mBAAmB;AACvB,QAAM,gBAAgB,YAAY;AAClC,MAAK,eAAgB;AACpB,UAAM,6BACL,OAAO,iBAAkB,aAAc;AACxC,QAAK,4BAA4B,YAAY,QAAS;AACrD,yBAAmB;AACnB,qBACC,WAAY,2BAA2B,WAAY,KAAK;AACzD,sBACC,WAAY,2BAA2B,YAAa,KAAK;AAAA,IAC3D;AAAA,EACD;AACA,MAAI,kBAAkB,iBAAiB;AAEvC,SAAQ,WAAW,SAAU;AAC5B,UAAM,UAAU,KAAK,OAAS,UAAU,WAAY,CAAE;AACtD,kBAAe,OAAQ;AAKvB,UAAM,OAAO,MAAM,sBAAsB;AACzC,UAAM,YAAY,KAAK;AAIvB,UAAM,YACL,YAAY,eAAe,iBAAiB,eAC5C,aACC,iBAAiB,cAAc,cAAc;AAE/C,UAAM,aACL,8BACA,YAAY,gBAAgB,iBAAiB,gBAC7C,YAAY,gBAAgB;AAO7B,QAAK,iBAAiB,eAAe,iBAAkB;AACtD,wBAAkB,iBAAiB;AAAA,IACpC;AAEA,QAAK,aAAa,YAAa;AAC9B,iBAAW;AACX,gBAAU,UAAU;AAAA,IACrB,OAAO;AACN,gBAAU,UAAU;AAAA,IACrB;AAAA,EACD;AACA,QAAM,OAAO;AAEb,SAAO;AACR;AASO,SAAS,gBACf,aACA,eACC;AACD,MAAK,CAAE,aAAc;AACpB;AAAA,EACD;AAEA,gBAAe,CAAE;AAEjB,QAAM,cAAc,oBAAqB,aAAa,aAAc;AAEpE,gBAAe,WAAY;AAC3B,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/block-editor/src/utils/format-font-style.js
1
+ // packages/block-editor/src/utils/format-font-style.ts
2
2
  import { _x } from "@wordpress/i18n";
3
3
  function formatFontStyle(fontStyle) {
4
4
  if (!fontStyle) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/format-font-style.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Formats font styles to human readable names.\n *\n * @param {string} fontStyle font style string\n * @return {Object} new object with formatted font style\n */\nexport function formatFontStyle( fontStyle ) {\n\tif ( ! fontStyle ) {\n\t\treturn {};\n\t}\n\n\tif ( typeof fontStyle === 'object' ) {\n\t\treturn fontStyle;\n\t}\n\n\tlet name;\n\n\tswitch ( fontStyle ) {\n\t\tcase 'normal':\n\t\t\tname = _x( 'Regular', 'font style' );\n\t\t\tbreak;\n\t\tcase 'italic':\n\t\t\tname = _x( 'Italic', 'font style' );\n\t\t\tbreak;\n\t\tcase 'oblique':\n\t\t\tname = _x( 'Oblique', 'font style' );\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tname = fontStyle;\n\t\t\tbreak;\n\t}\n\n\treturn { name, value: fontStyle };\n}\n"],
5
- "mappings": ";AAGA,SAAS,UAAU;AAQZ,SAAS,gBAAiB,WAAY;AAC5C,MAAK,CAAE,WAAY;AAClB,WAAO,CAAC;AAAA,EACT;AAEA,MAAK,OAAO,cAAc,UAAW;AACpC,WAAO;AAAA,EACR;AAEA,MAAI;AAEJ,UAAS,WAAY;AAAA,IACpB,KAAK;AACJ,aAAO,GAAI,WAAW,YAAa;AACnC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,UAAU,YAAa;AAClC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,WAAW,YAAa;AACnC;AAAA,IAED;AACC,aAAO;AACP;AAAA,EACF;AAEA,SAAO,EAAE,MAAM,OAAO,UAAU;AACjC;",
3
+ "sources": ["../../src/utils/format-font-style.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { FormattedFont } from './types';\n\n/**\n * Formats font styles to human readable names.\n *\n * @param fontStyle font style string\n * @return new object with formatted font style\n */\nexport function formatFontStyle(\n\tfontStyle: FormattedFont | string | undefined\n): FormattedFont {\n\tif ( ! fontStyle ) {\n\t\treturn {};\n\t}\n\n\tif ( typeof fontStyle === 'object' ) {\n\t\treturn fontStyle;\n\t}\n\n\tlet name;\n\n\tswitch ( fontStyle ) {\n\t\tcase 'normal':\n\t\t\tname = _x( 'Regular', 'font style' );\n\t\t\tbreak;\n\t\tcase 'italic':\n\t\t\tname = _x( 'Italic', 'font style' );\n\t\t\tbreak;\n\t\tcase 'oblique':\n\t\t\tname = _x( 'Oblique', 'font style' );\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tname = fontStyle;\n\t\t\tbreak;\n\t}\n\n\treturn { name, value: fontStyle };\n}\n"],
5
+ "mappings": ";AAGA,SAAS,UAAU;AAaZ,SAAS,gBACf,WACgB;AAChB,MAAK,CAAE,WAAY;AAClB,WAAO,CAAC;AAAA,EACT;AAEA,MAAK,OAAO,cAAc,UAAW;AACpC,WAAO;AAAA,EACR;AAEA,MAAI;AAEJ,UAAS,WAAY;AAAA,IACpB,KAAK;AACJ,aAAO,GAAI,WAAW,YAAa;AACnC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,UAAU,YAAa;AAClC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,WAAW,YAAa;AACnC;AAAA,IAED;AACC,aAAO;AACP;AAAA,EACF;AAEA,SAAO,EAAE,MAAM,OAAO,UAAU;AACjC;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/block-editor/src/utils/format-font-weight.js
1
+ // packages/block-editor/src/utils/format-font-weight.ts
2
2
  import { _x } from "@wordpress/i18n";
3
3
  function formatFontWeight(fontWeight) {
4
4
  if (!fontWeight) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/format-font-weight.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Formats font weights to human readable names.\n *\n * @param {string} fontWeight font weight string\n * @return {Object} new object with formatted font weight\n */\nexport function formatFontWeight( fontWeight ) {\n\tif ( ! fontWeight ) {\n\t\treturn {};\n\t}\n\n\tif ( typeof fontWeight === 'object' ) {\n\t\treturn fontWeight;\n\t}\n\n\tlet name;\n\n\tswitch ( fontWeight ) {\n\t\tcase 'normal':\n\t\tcase '400':\n\t\t\tname = _x( 'Regular', 'font weight' );\n\t\t\tbreak;\n\t\tcase 'bold':\n\t\tcase '700':\n\t\t\tname = _x( 'Bold', 'font weight' );\n\t\t\tbreak;\n\t\tcase '100':\n\t\t\tname = _x( 'Thin', 'font weight' );\n\t\t\tbreak;\n\t\tcase '200':\n\t\t\tname = _x( 'Extra Light', 'font weight' );\n\t\t\tbreak;\n\t\tcase '300':\n\t\t\tname = _x( 'Light', 'font weight' );\n\t\t\tbreak;\n\t\tcase '500':\n\t\t\tname = _x( 'Medium', 'font weight' );\n\t\t\tbreak;\n\t\tcase '600':\n\t\t\tname = _x( 'Semi Bold', 'font weight' );\n\t\t\tbreak;\n\t\tcase '800':\n\t\t\tname = _x( 'Extra Bold', 'font weight' );\n\t\t\tbreak;\n\t\tcase '900':\n\t\t\tname = _x( 'Black', 'font weight' );\n\t\t\tbreak;\n\t\tcase '1000':\n\t\t\tname = _x( 'Extra Black', 'font weight' );\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tname = fontWeight;\n\t\t\tbreak;\n\t}\n\n\treturn { name, value: fontWeight };\n}\n"],
5
- "mappings": ";AAGA,SAAS,UAAU;AAQZ,SAAS,iBAAkB,YAAa;AAC9C,MAAK,CAAE,YAAa;AACnB,WAAO,CAAC;AAAA,EACT;AAEA,MAAK,OAAO,eAAe,UAAW;AACrC,WAAO;AAAA,EACR;AAEA,MAAI;AAEJ,UAAS,YAAa;AAAA,IACrB,KAAK;AAAA,IACL,KAAK;AACJ,aAAO,GAAI,WAAW,aAAc;AACpC;AAAA,IACD,KAAK;AAAA,IACL,KAAK;AACJ,aAAO,GAAI,QAAQ,aAAc;AACjC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,QAAQ,aAAc;AACjC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,eAAe,aAAc;AACxC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,SAAS,aAAc;AAClC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,UAAU,aAAc;AACnC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,aAAa,aAAc;AACtC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,cAAc,aAAc;AACvC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,SAAS,aAAc;AAClC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,eAAe,aAAc;AACxC;AAAA,IAED;AACC,aAAO;AACP;AAAA,EACF;AAEA,SAAO,EAAE,MAAM,OAAO,WAAW;AAClC;",
3
+ "sources": ["../../src/utils/format-font-weight.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { FormattedFont } from './types';\n\n/**\n * Formats font weights to human readable names.\n *\n * @param fontWeight font weight string\n * @return new object with formatted font weight\n */\nexport function formatFontWeight(\n\tfontWeight: FormattedFont | string | undefined\n): FormattedFont {\n\tif ( ! fontWeight ) {\n\t\treturn {};\n\t}\n\n\tif ( typeof fontWeight === 'object' ) {\n\t\treturn fontWeight;\n\t}\n\n\tlet name;\n\n\tswitch ( fontWeight ) {\n\t\tcase 'normal':\n\t\tcase '400':\n\t\t\tname = _x( 'Regular', 'font weight' );\n\t\t\tbreak;\n\t\tcase 'bold':\n\t\tcase '700':\n\t\t\tname = _x( 'Bold', 'font weight' );\n\t\t\tbreak;\n\t\tcase '100':\n\t\t\tname = _x( 'Thin', 'font weight' );\n\t\t\tbreak;\n\t\tcase '200':\n\t\t\tname = _x( 'Extra Light', 'font weight' );\n\t\t\tbreak;\n\t\tcase '300':\n\t\t\tname = _x( 'Light', 'font weight' );\n\t\t\tbreak;\n\t\tcase '500':\n\t\t\tname = _x( 'Medium', 'font weight' );\n\t\t\tbreak;\n\t\tcase '600':\n\t\t\tname = _x( 'Semi Bold', 'font weight' );\n\t\t\tbreak;\n\t\tcase '800':\n\t\t\tname = _x( 'Extra Bold', 'font weight' );\n\t\t\tbreak;\n\t\tcase '900':\n\t\t\tname = _x( 'Black', 'font weight' );\n\t\t\tbreak;\n\t\tcase '1000':\n\t\t\tname = _x( 'Extra Black', 'font weight' );\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tname = fontWeight;\n\t\t\tbreak;\n\t}\n\n\treturn { name, value: fontWeight };\n}\n"],
5
+ "mappings": ";AAGA,SAAS,UAAU;AAaZ,SAAS,iBACf,YACgB;AAChB,MAAK,CAAE,YAAa;AACnB,WAAO,CAAC;AAAA,EACT;AAEA,MAAK,OAAO,eAAe,UAAW;AACrC,WAAO;AAAA,EACR;AAEA,MAAI;AAEJ,UAAS,YAAa;AAAA,IACrB,KAAK;AAAA,IACL,KAAK;AACJ,aAAO,GAAI,WAAW,aAAc;AACpC;AAAA,IACD,KAAK;AAAA,IACL,KAAK;AACJ,aAAO,GAAI,QAAQ,aAAc;AACjC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,QAAQ,aAAc;AACjC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,eAAe,aAAc;AACxC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,SAAS,aAAc;AAClC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,UAAU,aAAc;AACnC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,aAAa,aAAc;AACtC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,cAAc,aAAc;AACvC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,SAAS,aAAc;AAClC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,eAAe,aAAc;AACxC;AAAA,IAED;AACC,aAAO;AACP;AAAA,EACF;AAEA,SAAO,EAAE,MAAM,OAAO,WAAW;AAClC;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,12 @@
1
- // packages/block-editor/src/utils/get-editor-region.js
1
+ // packages/block-editor/src/utils/get-editor-region.ts
2
2
  function getEditorRegion(editor) {
3
3
  if (!editor) {
4
4
  return null;
5
5
  }
6
6
  const editorCanvas = Array.from(
7
- document.querySelectorAll('iframe[name="editor-canvas"]').values()
7
+ document.querySelectorAll(
8
+ 'iframe[name="editor-canvas"]'
9
+ ).values()
8
10
  ).find((iframe) => {
9
11
  const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
10
12
  return iframeDocument === editor.ownerDocument;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/get-editor-region.js"],
4
- "sourcesContent": ["/**\n * Gets the editor region for a given editor canvas element or\n * returns the passed element if no region is found\n *\n * @param { Object } editor The editor canvas element.\n * @return { Object } The editor region or given editor element\n */\nexport default function getEditorRegion( editor ) {\n\tif ( ! editor ) {\n\t\treturn null;\n\t}\n\n\t// If there are multiple editors, we need to find the iframe that contains our contentRef to make sure\n\t// we're focusing the region that contains this editor.\n\tconst editorCanvas =\n\t\tArray.from(\n\t\t\tdocument.querySelectorAll( 'iframe[name=\"editor-canvas\"]' ).values()\n\t\t).find( ( iframe ) => {\n\t\t\t// Find the iframe that contains our contentRef\n\t\t\tconst iframeDocument =\n\t\t\t\tiframe.contentDocument || iframe.contentWindow.document;\n\n\t\t\treturn iframeDocument === editor.ownerDocument;\n\t\t} ) ?? editor;\n\n\t// The region is provided by the editor, not the block-editor.\n\t// We should send focus to the region if one is available to reuse the\n\t// same interface for navigating landmarks. If no region is available,\n\t// use the canvas instead.\n\treturn editorCanvas?.closest( '[role=\"region\"]' ) ?? editorCanvas;\n}\n"],
5
- "mappings": ";AAOe,SAAR,gBAAkC,QAAS;AACjD,MAAK,CAAE,QAAS;AACf,WAAO;AAAA,EACR;AAIA,QAAM,eACL,MAAM;AAAA,IACL,SAAS,iBAAkB,8BAA+B,EAAE,OAAO;AAAA,EACpE,EAAE,KAAM,CAAE,WAAY;AAErB,UAAM,iBACL,OAAO,mBAAmB,OAAO,cAAc;AAEhD,WAAO,mBAAmB,OAAO;AAAA,EAClC,CAAE,KAAK;AAMR,SAAO,cAAc,QAAS,iBAAkB,KAAK;AACtD;",
3
+ "sources": ["../../src/utils/get-editor-region.ts"],
4
+ "sourcesContent": ["/**\n * Gets the editor region for a given editor canvas element or\n * returns the passed element if no region is found\n *\n * @param editor The editor canvas element.\n * @return The editor region or given editor element\n */\nexport default function getEditorRegion( editor: Element | null | undefined ) {\n\tif ( ! editor ) {\n\t\treturn null;\n\t}\n\n\t// If there are multiple editors, we need to find the iframe that contains our contentRef to make sure\n\t// we're focusing the region that contains this editor.\n\tconst editorCanvas: Element =\n\t\tArray.from(\n\t\t\tdocument\n\t\t\t\t.querySelectorAll< HTMLIFrameElement >(\n\t\t\t\t\t'iframe[name=\"editor-canvas\"]'\n\t\t\t\t)\n\t\t\t\t.values()\n\t\t).find( ( iframe ) => {\n\t\t\t// Find the iframe that contains our contentRef\n\t\t\tconst iframeDocument =\n\t\t\t\tiframe.contentDocument || iframe.contentWindow!.document;\n\n\t\t\treturn iframeDocument === editor.ownerDocument;\n\t\t} ) ?? editor;\n\n\t// The region is provided by the editor, not the block-editor.\n\t// We should send focus to the region if one is available to reuse the\n\t// same interface for navigating landmarks. If no region is available,\n\t// use the canvas instead.\n\treturn editorCanvas?.closest( '[role=\"region\"]' ) ?? editorCanvas;\n}\n"],
5
+ "mappings": ";AAOe,SAAR,gBAAkC,QAAqC;AAC7E,MAAK,CAAE,QAAS;AACf,WAAO;AAAA,EACR;AAIA,QAAM,eACL,MAAM;AAAA,IACL,SACE;AAAA,MACA;AAAA,IACD,EACC,OAAO;AAAA,EACV,EAAE,KAAM,CAAE,WAAY;AAErB,UAAM,iBACL,OAAO,mBAAmB,OAAO,cAAe;AAEjD,WAAO,mBAAmB,OAAO;AAAA,EAClC,CAAE,KAAK;AAMR,SAAO,cAAc,QAAS,iBAAkB,KAAK;AACtD;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/block-editor/src/utils/get-font-styles-and-weights.js
1
+ // packages/block-editor/src/utils/get-font-styles-and-weights.ts
2
2
  import { _x, sprintf } from "@wordpress/i18n";
3
3
  import { formatFontStyle } from "./format-font-style.mjs";
4
4
  import { formatFontWeight } from "./format-font-weight.mjs";
@@ -63,13 +63,9 @@ function getFontStylesAndWeights(fontFamilyFaces) {
63
63
  fontFamilyFaces?.forEach((face) => {
64
64
  if ("string" === typeof face.fontWeight && /\s/.test(face.fontWeight.trim())) {
65
65
  isVariableFont = true;
66
- let [startValue, endValue] = face.fontWeight.split(" ");
67
- startValue = parseInt(startValue.slice(0, 1));
68
- if (endValue === "1000") {
69
- endValue = 10;
70
- } else {
71
- endValue = parseInt(endValue.slice(0, 1));
72
- }
66
+ const [startStr, endStr] = face.fontWeight.split(" ");
67
+ const startValue = parseInt(startStr.slice(0, 1));
68
+ const endValue = endStr === "1000" ? 10 : parseInt(endStr.slice(0, 1));
73
69
  for (let i = startValue; i <= endValue; i++) {
74
70
  const fontWeightValue = `${i.toString()}00`;
75
71
  if (!fontWeights.some(
@@ -100,7 +96,7 @@ function getFontStylesAndWeights(fontFamilyFaces) {
100
96
  }
101
97
  }
102
98
  });
103
- if (!fontWeights.some((weight) => weight.value >= "600")) {
99
+ if (!fontWeights.some((weight) => (weight.value ?? "") >= "600")) {
104
100
  fontWeights.push({
105
101
  name: _x("Bold", "font weight"),
106
102
  value: "700"
@@ -123,12 +119,12 @@ function getFontStylesAndWeights(fontFamilyFaces) {
123
119
  const optionName = styleValue === "normal" ? weightName : sprintf(
124
120
  /* translators: 1: Font weight name. 2: Font style name. */
125
121
  _x("%1$s %2$s", "font"),
126
- weightName,
127
- styleName
122
+ weightName ?? "",
123
+ styleName ?? ""
128
124
  );
129
125
  combinedStyleAndWeightOptions.push({
130
126
  key: `${styleValue}-${weightValue}`,
131
- name: optionName,
127
+ name: optionName ?? "",
132
128
  style: {
133
129
  fontStyle: styleValue,
134
130
  fontWeight: weightValue
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/get-font-styles-and-weights.js"],
4
- "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_x( '%1$s %2$s', 'font' ),\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"],
5
- "mappings": ";AAGA,SAAS,IAAI,eAAe;AAK5B,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AAEjC,IAAM,cAAc;AAAA,EACnB;AAAA,IACC,MAAM,GAAI,WAAW,YAAa;AAAA,IAClC,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,MAAM,GAAI,UAAU,YAAa;AAAA,IACjC,OAAO;AAAA,EACR;AACD;AAEA,IAAM,eAAe;AAAA,EACpB;AAAA,IACC,MAAM,GAAI,QAAQ,aAAc;AAAA,IAChC,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,MAAM,GAAI,eAAe,aAAc;AAAA,IACvC,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,MAAM,GAAI,SAAS,aAAc;AAAA,IACjC,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,MAAM,GAAI,WAAW,aAAc;AAAA,IACnC,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,MAAM,GAAI,UAAU,aAAc;AAAA,IAClC,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,MAAM,GAAI,aAAa,aAAc;AAAA,IACrC,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,MAAM,GAAI,QAAQ,aAAc;AAAA,IAChC,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,MAAM,GAAI,cAAc,aAAc;AAAA,IACtC,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,MAAM,GAAI,SAAS,aAAc;AAAA,IACjC,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,MAAM,GAAI,eAAe,aAAc;AAAA,IACvC,OAAO;AAAA,EACR;AACD;AASO,SAAS,wBAAyB,iBAAkB;AAC1D,MAAI,aAAa,CAAC;AAClB,MAAI,cAAc,CAAC;AACnB,QAAM,gCAAgC,CAAC;AACvC,QAAM,eAAe,CAAE,mBAAmB,iBAAiB,WAAW;AACtE,MAAI,iBAAiB;AAErB,mBAAiB,QAAS,CAAE,SAAU;AAErC,QACC,aAAa,OAAO,KAAK,cACzB,KAAK,KAAM,KAAK,WAAW,KAAK,CAAE,GACjC;AACD,uBAAiB;AAGjB,UAAI,CAAE,YAAY,QAAS,IAAI,KAAK,WAAW,MAAO,GAAI;AAC1D,mBAAa,SAAU,WAAW,MAAO,GAAG,CAAE,CAAE;AAChD,UAAK,aAAa,QAAS;AAC1B,mBAAW;AAAA,MACZ,OAAO;AACN,mBAAW,SAAU,SAAS,MAAO,GAAG,CAAE,CAAE;AAAA,MAC7C;AAGA,eAAU,IAAI,YAAY,KAAK,UAAU,KAAM;AAC9C,cAAM,kBAAkB,GAAI,EAAE,SAAS,CAAE;AACzC,YACC,CAAE,YAAY;AAAA,UACb,CAAE,WAAY,OAAO,UAAU;AAAA,QAChC,GACC;AACD,sBAAY,KAAM,iBAAkB,eAAgB,CAAE;AAAA,QACvD;AAAA,MACD;AAAA,IACD;AAGA,UAAM,aAAa;AAAA,MAClB,aAAa,OAAO,KAAK,aACtB,KAAK,WAAW,SAAS,IACzB,KAAK;AAAA,IACT;AACA,UAAM,YAAY,gBAAiB,KAAK,SAAU;AAGlD,QAAK,aAAa,OAAO,KAAM,SAAU,EAAE,QAAS;AACnD,UACC,CAAE,WAAW;AAAA,QACZ,CAAE,UAAW,MAAM,UAAU,UAAU;AAAA,MACxC,GACC;AACD,mBAAW,KAAM,SAAU;AAAA,MAC5B;AAAA,IACD;AAEA,QAAK,cAAc,OAAO,KAAM,UAAW,EAAE,QAAS;AACrD,UACC,CAAE,YAAY;AAAA,QACb,CAAE,WAAY,OAAO,UAAU,WAAW;AAAA,MAC3C,GACC;AACD,YAAK,CAAE,gBAAiB;AACvB,sBAAY,KAAM,UAAW;AAAA,QAC9B;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAE;AAGF,MAAK,CAAE,YAAY,KAAM,CAAE,WAAY,OAAO,SAAS,KAAM,GAAI;AAChE,gBAAY,KAAM;AAAA,MACjB,MAAM,GAAI,QAAQ,aAAc;AAAA,MAChC,OAAO;AAAA,IACR,CAAE;AAAA,EACH;AAGA,MAAK,CAAE,WAAW,KAAM,CAAE,UAAW,MAAM,UAAU,QAAS,GAAI;AACjE,eAAW,KAAM;AAAA,MAChB,MAAM,GAAI,UAAU,YAAa;AAAA,MACjC,OAAO;AAAA,IACR,CAAE;AAAA,EACH;AAGA,MAAK,cAAe;AACnB,iBAAa;AACb,kBAAc;AAAA,EACf;AAGA,eAAa,WAAW,WAAW,IAAI,cAAc;AACrD,gBAAc,YAAY,WAAW,IAAI,eAAe;AAGxD,aAAW,QAAS,CAAE,EAAE,MAAM,WAAW,OAAO,WAAW,MAAO;AACjE,gBAAY,QAAS,CAAE,EAAE,MAAM,YAAY,OAAO,YAAY,MAAO;AACpE,YAAM,aACL,eAAe,WACZ,aACA;AAAA;AAAA,QAEA,GAAI,aAAa,MAAO;AAAA,QACxB;AAAA,QACA;AAAA,MACA;AAEJ,oCAA8B,KAAM;AAAA,QACnC,KAAK,GAAI,UAAW,IAAK,WAAY;AAAA,QACrC,MAAM;AAAA,QACN,OAAO;AAAA,UACN,WAAW;AAAA,UACX,YAAY;AAAA,QACb;AAAA,MACD,CAAE;AAAA,IACH,CAAE;AAAA,EACH,CAAE;AAEF,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
3
+ "sources": ["../../src/utils/get-font-styles-and-weights.ts"],
4
+ "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';\nimport type {\n\tFontFamilyFace,\n\tFormattedFont,\n\tCombinedStyleAndWeightOption,\n} from './types';\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 fontFamilyFaces font family faces array\n * @return new object with combined and separated font style and weight properties\n */\nexport function getFontStylesAndWeights(\n\tfontFamilyFaces: FontFamilyFace[] | undefined\n) {\n\tlet fontStyles: FormattedFont[] = [];\n\tlet fontWeights: FormattedFont[] = [];\n\tconst combinedStyleAndWeightOptions: CombinedStyleAndWeightOption[] = [];\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\tconst [ startStr, endStr ] = face.fontWeight.split( ' ' );\n\t\t\tconst startValue = parseInt( startStr.slice( 0, 1 ) );\n\t\t\tconst endValue =\n\t\t\t\tendStr === '1000' ? 10 : parseInt( endStr.slice( 0, 1 ) );\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_x( '%1$s %2$s', 'font' ),\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"],
5
+ "mappings": "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",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/block-editor/src/utils/get-px-from-css-unit.js
1
+ // packages/block-editor/src/utils/get-px-from-css-unit.ts
2
2
  var get_px_from_css_unit_default = () => "";
3
3
  export {
4
4
  get_px_from_css_unit_default as default
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/get-px-from-css-unit.js"],
3
+ "sources": ["../../src/utils/get-px-from-css-unit.ts"],
4
4
  "sourcesContent": ["/**\n * This function was accidentally exposed for mobile/native usage.\n *\n * @deprecated\n *\n * @return {string} Empty string.\n */\nexport default () => '';\n"],
5
5
  "mappings": ";AAOA,IAAO,+BAAQ,MAAM;",
6
6
  "names": []
@@ -1,4 +1,4 @@
1
- // packages/block-editor/src/utils/index.js
1
+ // packages/block-editor/src/utils/index.ts
2
2
  import { default as default2 } from "./transform-styles/index.mjs";
3
3
  import { default as default3 } from "./get-px-from-css-unit.mjs";
4
4
  export {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/index.js"],
3
+ "sources": ["../../src/utils/index.ts"],
4
4
  "sourcesContent": ["export { default as transformStyles } from './transform-styles';\nexport { default as getPxFromCssUnit } from './get-px-from-css-unit';\n"],
5
5
  "mappings": ";AAAA,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAAmC;",
6
6
  "names": ["default"]
@@ -1,4 +1,4 @@
1
- // packages/block-editor/src/utils/math.js
1
+ // packages/block-editor/src/utils/math.ts
2
2
  function getDistanceFromPointToEdge(point, rect, edge) {
3
3
  const isHorizontal = edge === "top" || edge === "bottom";
4
4
  const { x, y } = point;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/math.js"],
4
- "sourcesContent": ["/**\n * A string representing the name of an edge.\n *\n * @typedef {'top'|'right'|'bottom'|'left'} WPEdgeName\n */\n\n/**\n * @typedef {Object} WPPoint\n * @property {number} x The horizontal position.\n * @property {number} y The vertical position.\n */\n\n/**\n * Given a point, a DOMRect and the name of an edge, returns the distance to\n * that edge of the rect.\n *\n * This function works for edges that are horizontal or vertical (e.g. not\n * rotated), the following terms are used so that the function works in both\n * orientations:\n *\n * - Forward, meaning the axis running horizontally when an edge is vertical\n * and vertically when an edge is horizontal.\n * - Lateral, meaning the axis running vertically when an edge is vertical\n * and horizontally when an edge is horizontal.\n *\n * @param {WPPoint} point The point to measure distance from.\n * @param {DOMRect} rect A DOM Rect containing edge positions.\n * @param {WPEdgeName} edge The edge to measure to.\n */\nexport function getDistanceFromPointToEdge( point, rect, edge ) {\n\tconst isHorizontal = edge === 'top' || edge === 'bottom';\n\tconst { x, y } = point;\n\tconst pointLateralPosition = isHorizontal ? x : y;\n\tconst pointForwardPosition = isHorizontal ? y : x;\n\tconst edgeStart = isHorizontal ? rect.left : rect.top;\n\tconst edgeEnd = isHorizontal ? rect.right : rect.bottom;\n\tconst edgeForwardPosition = rect[ edge ];\n\n\t// Measure the straight line distance to the edge of the rect, when the\n\t// point is adjacent to the edge.\n\t// Else, if the point is positioned diagonally to the edge of the rect,\n\t// measure diagonally to the nearest corner that the edge meets.\n\tlet edgeLateralPosition;\n\tif (\n\t\tpointLateralPosition >= edgeStart &&\n\t\tpointLateralPosition <= edgeEnd\n\t) {\n\t\tedgeLateralPosition = pointLateralPosition;\n\t} else if ( pointLateralPosition < edgeEnd ) {\n\t\tedgeLateralPosition = edgeStart;\n\t} else {\n\t\tedgeLateralPosition = edgeEnd;\n\t}\n\n\treturn Math.sqrt(\n\t\t( pointLateralPosition - edgeLateralPosition ) ** 2 +\n\t\t\t( pointForwardPosition - edgeForwardPosition ) ** 2\n\t);\n}\n\n/**\n * Given a point, a DOMRect and a list of allowed edges returns the name of and\n * distance to the nearest edge.\n *\n * @param {WPPoint} point The point to measure distance from.\n * @param {DOMRect} rect A DOM Rect containing edge positions.\n * @param {WPEdgeName[]} allowedEdges A list of the edges included in the\n * calculation. Defaults to all edges.\n *\n * @return {[number, string]} An array where the first value is the distance\n * and a second is the edge name.\n */\nexport function getDistanceToNearestEdge(\n\tpoint,\n\trect,\n\tallowedEdges = [ 'top', 'bottom', 'left', 'right' ]\n) {\n\tlet candidateDistance;\n\tlet candidateEdge;\n\n\tallowedEdges.forEach( ( edge ) => {\n\t\tconst distance = getDistanceFromPointToEdge( point, rect, edge );\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateEdge = edge;\n\t\t}\n\t} );\n\n\treturn [ candidateDistance, candidateEdge ];\n}\n\n/**\n * Is the point contained by the rectangle.\n *\n * @param {WPPoint} point The point.\n * @param {DOMRect} rect The rectangle.\n *\n * @return {boolean} True if the point is contained by the rectangle, false otherwise.\n */\nexport function isPointContainedByRect( point, rect ) {\n\treturn (\n\t\trect.left <= point.x &&\n\t\trect.right >= point.x &&\n\t\trect.top <= point.y &&\n\t\trect.bottom >= point.y\n\t);\n}\n\n/**\n * Is the point within the top and bottom boundaries of the rectangle.\n *\n * @param {WPPoint} point The point.\n * @param {DOMRect} rect The rectangle.\n *\n * @return {boolean} True if the point is within top and bottom of rectangle, false otherwise.\n */\nexport function isPointWithinTopAndBottomBoundariesOfRect( point, rect ) {\n\treturn rect.top <= point.y && rect.bottom >= point.y;\n}\n"],
5
- "mappings": ";AA6BO,SAAS,2BAA4B,OAAO,MAAM,MAAO;AAC/D,QAAM,eAAe,SAAS,SAAS,SAAS;AAChD,QAAM,EAAE,GAAG,EAAE,IAAI;AACjB,QAAM,uBAAuB,eAAe,IAAI;AAChD,QAAM,uBAAuB,eAAe,IAAI;AAChD,QAAM,YAAY,eAAe,KAAK,OAAO,KAAK;AAClD,QAAM,UAAU,eAAe,KAAK,QAAQ,KAAK;AACjD,QAAM,sBAAsB,KAAM,IAAK;AAMvC,MAAI;AACJ,MACC,wBAAwB,aACxB,wBAAwB,SACvB;AACD,0BAAsB;AAAA,EACvB,WAAY,uBAAuB,SAAU;AAC5C,0BAAsB;AAAA,EACvB,OAAO;AACN,0BAAsB;AAAA,EACvB;AAEA,SAAO,KAAK;AAAA,KACT,uBAAuB,wBAAyB,KAC/C,uBAAuB,wBAAyB;AAAA,EACpD;AACD;AAcO,SAAS,yBACf,OACA,MACA,eAAe,CAAE,OAAO,UAAU,QAAQ,OAAQ,GACjD;AACD,MAAI;AACJ,MAAI;AAEJ,eAAa,QAAS,CAAE,SAAU;AACjC,UAAM,WAAW,2BAA4B,OAAO,MAAM,IAAK;AAE/D,QAAK,sBAAsB,UAAa,WAAW,mBAAoB;AACtE,0BAAoB;AACpB,sBAAgB;AAAA,IACjB;AAAA,EACD,CAAE;AAEF,SAAO,CAAE,mBAAmB,aAAc;AAC3C;AAUO,SAAS,uBAAwB,OAAO,MAAO;AACrD,SACC,KAAK,QAAQ,MAAM,KACnB,KAAK,SAAS,MAAM,KACpB,KAAK,OAAO,MAAM,KAClB,KAAK,UAAU,MAAM;AAEvB;AAUO,SAAS,0CAA2C,OAAO,MAAO;AACxE,SAAO,KAAK,OAAO,MAAM,KAAK,KAAK,UAAU,MAAM;AACpD;",
3
+ "sources": ["../../src/utils/math.ts"],
4
+ "sourcesContent": ["/**\n * A string representing the name of an edge.\n */\ntype EdgeName = 'top' | 'right' | 'bottom' | 'left';\n\ninterface Point {\n\t/** The horizontal position. */\n\tx: number;\n\t/** The vertical position. */\n\ty: number;\n}\n\n/**\n * Given a point, a DOMRect and the name of an edge, returns the distance to\n * that edge of the rect.\n *\n * This function works for edges that are horizontal or vertical (e.g. not\n * rotated), the following terms are used so that the function works in both\n * orientations:\n *\n * - Forward, meaning the axis running horizontally when an edge is vertical\n * and vertically when an edge is horizontal.\n * - Lateral, meaning the axis running vertically when an edge is vertical\n * and horizontally when an edge is horizontal.\n *\n * @param point The point to measure distance from.\n * @param rect A DOM Rect containing edge positions.\n * @param edge The edge to measure to.\n */\nexport function getDistanceFromPointToEdge(\n\tpoint: Point,\n\trect: DOMRect,\n\tedge: EdgeName\n) {\n\tconst isHorizontal = edge === 'top' || edge === 'bottom';\n\tconst { x, y } = point;\n\tconst pointLateralPosition = isHorizontal ? x : y;\n\tconst pointForwardPosition = isHorizontal ? y : x;\n\tconst edgeStart = isHorizontal ? rect.left : rect.top;\n\tconst edgeEnd = isHorizontal ? rect.right : rect.bottom;\n\tconst edgeForwardPosition = rect[ edge ];\n\n\t// Measure the straight line distance to the edge of the rect, when the\n\t// point is adjacent to the edge.\n\t// Else, if the point is positioned diagonally to the edge of the rect,\n\t// measure diagonally to the nearest corner that the edge meets.\n\tlet edgeLateralPosition;\n\tif (\n\t\tpointLateralPosition >= edgeStart &&\n\t\tpointLateralPosition <= edgeEnd\n\t) {\n\t\tedgeLateralPosition = pointLateralPosition;\n\t} else if ( pointLateralPosition < edgeEnd ) {\n\t\tedgeLateralPosition = edgeStart;\n\t} else {\n\t\tedgeLateralPosition = edgeEnd;\n\t}\n\n\treturn Math.sqrt(\n\t\t( pointLateralPosition - edgeLateralPosition ) ** 2 +\n\t\t\t( pointForwardPosition - edgeForwardPosition ) ** 2\n\t);\n}\n\n/**\n * Given a point, a DOMRect and a list of allowed edges returns the name of and\n * distance to the nearest edge.\n *\n * @param point The point to measure distance from.\n * @param rect A DOM Rect containing edge positions.\n * @param allowedEdges A list of the edges included in the\n * calculation. Defaults to all edges.\n *\n * @return An array where the first value is the distance\n * and a second is the edge name.\n */\nexport function getDistanceToNearestEdge(\n\tpoint: Point,\n\trect: DOMRect,\n\tallowedEdges: EdgeName[] = [ 'top', 'bottom', 'left', 'right' ]\n) {\n\tlet candidateDistance: number | undefined;\n\tlet candidateEdge: EdgeName | undefined;\n\n\tallowedEdges.forEach( ( edge ) => {\n\t\tconst distance = getDistanceFromPointToEdge( point, rect, edge );\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateEdge = edge;\n\t\t}\n\t} );\n\n\treturn [ candidateDistance, candidateEdge ];\n}\n\n/**\n * Is the point contained by the rectangle.\n *\n * @param point The point.\n * @param rect The rectangle.\n *\n * @return True if the point is contained by the rectangle, false otherwise.\n */\nexport function isPointContainedByRect( point: Point, rect: DOMRect ) {\n\treturn (\n\t\trect.left <= point.x &&\n\t\trect.right >= point.x &&\n\t\trect.top <= point.y &&\n\t\trect.bottom >= point.y\n\t);\n}\n\n/**\n * Is the point within the top and bottom boundaries of the rectangle.\n *\n * @param point The point.\n * @param rect The rectangle.\n *\n * @return True if the point is within top and bottom of rectangle, false otherwise.\n */\nexport function isPointWithinTopAndBottomBoundariesOfRect(\n\tpoint: Point,\n\trect: DOMRect\n) {\n\treturn rect.top <= point.y && rect.bottom >= point.y;\n}\n"],
5
+ "mappings": ";AA6BO,SAAS,2BACf,OACA,MACA,MACC;AACD,QAAM,eAAe,SAAS,SAAS,SAAS;AAChD,QAAM,EAAE,GAAG,EAAE,IAAI;AACjB,QAAM,uBAAuB,eAAe,IAAI;AAChD,QAAM,uBAAuB,eAAe,IAAI;AAChD,QAAM,YAAY,eAAe,KAAK,OAAO,KAAK;AAClD,QAAM,UAAU,eAAe,KAAK,QAAQ,KAAK;AACjD,QAAM,sBAAsB,KAAM,IAAK;AAMvC,MAAI;AACJ,MACC,wBAAwB,aACxB,wBAAwB,SACvB;AACD,0BAAsB;AAAA,EACvB,WAAY,uBAAuB,SAAU;AAC5C,0BAAsB;AAAA,EACvB,OAAO;AACN,0BAAsB;AAAA,EACvB;AAEA,SAAO,KAAK;AAAA,KACT,uBAAuB,wBAAyB,KAC/C,uBAAuB,wBAAyB;AAAA,EACpD;AACD;AAcO,SAAS,yBACf,OACA,MACA,eAA2B,CAAE,OAAO,UAAU,QAAQ,OAAQ,GAC7D;AACD,MAAI;AACJ,MAAI;AAEJ,eAAa,QAAS,CAAE,SAAU;AACjC,UAAM,WAAW,2BAA4B,OAAO,MAAM,IAAK;AAE/D,QAAK,sBAAsB,UAAa,WAAW,mBAAoB;AACtE,0BAAoB;AACpB,sBAAgB;AAAA,IACjB;AAAA,EACD,CAAE;AAEF,SAAO,CAAE,mBAAmB,aAAc;AAC3C;AAUO,SAAS,uBAAwB,OAAc,MAAgB;AACrE,SACC,KAAK,QAAQ,MAAM,KACnB,KAAK,SAAS,MAAM,KACpB,KAAK,OAAO,MAAM,KAClB,KAAK,UAAU,MAAM;AAEvB;AAUO,SAAS,0CACf,OACA,MACC;AACD,SAAO,KAAK,OAAO,MAAM,KAAK,KAAK,UAAU,MAAM;AACpD;",
6
6
  "names": []
7
7
  }
@@ -1,15 +1,15 @@
1
- // packages/block-editor/src/utils/object.js
1
+ // packages/block-editor/src/utils/object.ts
2
2
  function setImmutably(object, path, value) {
3
- path = Array.isArray(path) ? [...path] : [path];
4
- object = Array.isArray(object) ? [...object] : { ...object };
5
- const leaf = path.pop();
6
- let prev = object;
7
- for (const key of path) {
3
+ const pathArray = Array.isArray(path) ? [...path] : [path];
4
+ const result = Array.isArray(object) ? [...object] : { ...object };
5
+ const leaf = pathArray.pop();
6
+ let prev = result;
7
+ for (const key of pathArray) {
8
8
  const lvl = prev[key];
9
- prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl };
9
+ prev[key] = prev = Array.isArray(lvl) ? [...lvl] : { ...lvl };
10
10
  }
11
11
  prev[leaf] = value;
12
- return object;
12
+ return result;
13
13
  }
14
14
  var getValueFromObjectPath = (object, path, defaultValue) => {
15
15
  const arrayPath = Array.isArray(path) ? path : path.split(".");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/object.js"],
4
- "sourcesContent": ["/**\n * Immutably sets a value inside an object. Like `lodash#set`, but returning a\n * new object. Treats nullish initial values as empty objects. Clones any\n * nested objects. Supports arrays, too.\n *\n * @param {Object} object Object to set a value in.\n * @param {number|string|Array} path Path in the object to modify.\n * @param {*} value New value to set.\n * @return {Object} Cloned object with the new value set.\n */\nexport function setImmutably( object, path, value ) {\n\t// Normalize path\n\tpath = Array.isArray( path ) ? [ ...path ] : [ path ];\n\n\t// Shallowly clone the base of the object\n\tobject = Array.isArray( object ) ? [ ...object ] : { ...object };\n\n\tconst leaf = path.pop();\n\n\t// Traverse object from root to leaf, shallowly cloning at each level\n\tlet prev = object;\n\tfor ( const key of path ) {\n\t\tconst lvl = prev[ key ];\n\t\tprev = prev[ key ] = Array.isArray( lvl ) ? [ ...lvl ] : { ...lvl };\n\t}\n\n\tprev[ leaf ] = value;\n\n\treturn object;\n}\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n * You can also specify a default value in case the result is nullish.\n *\n * @param {Object} object Input object.\n * @param {string|Array} path Path to the object property.\n * @param {*} defaultValue Default value if the value at the specified path is nullish.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path, defaultValue ) => {\n\tconst arrayPath = Array.isArray( path ) ? path : path.split( '.' );\n\tlet value = object;\n\tarrayPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value ?? defaultValue;\n};\n\n/**\n * Helper util to filter out objects with duplicate values for a given property.\n *\n * @param {Object[]} array Array of objects to filter.\n * @param {string} property Property to filter unique values by.\n *\n * @return {Object[]} Array of objects with unique values for the specified property.\n */\nexport function uniqByProperty( array, property ) {\n\tconst seen = new Set();\n\treturn array.filter( ( item ) => {\n\t\tconst value = item[ property ];\n\t\treturn seen.has( value ) ? false : seen.add( value );\n\t} );\n}\n"],
5
- "mappings": ";AAUO,SAAS,aAAc,QAAQ,MAAM,OAAQ;AAEnD,SAAO,MAAM,QAAS,IAAK,IAAI,CAAE,GAAG,IAAK,IAAI,CAAE,IAAK;AAGpD,WAAS,MAAM,QAAS,MAAO,IAAI,CAAE,GAAG,MAAO,IAAI,EAAE,GAAG,OAAO;AAE/D,QAAM,OAAO,KAAK,IAAI;AAGtB,MAAI,OAAO;AACX,aAAY,OAAO,MAAO;AACzB,UAAM,MAAM,KAAM,GAAI;AACtB,WAAO,KAAM,GAAI,IAAI,MAAM,QAAS,GAAI,IAAI,CAAE,GAAG,GAAI,IAAI,EAAE,GAAG,IAAI;AAAA,EACnE;AAEA,OAAM,IAAK,IAAI;AAEf,SAAO;AACR;AAcO,IAAM,yBAAyB,CAAE,QAAQ,MAAM,iBAAkB;AACvE,QAAM,YAAY,MAAM,QAAS,IAAK,IAAI,OAAO,KAAK,MAAO,GAAI;AACjE,MAAI,QAAQ;AACZ,YAAU,QAAS,CAAE,cAAe;AACnC,YAAQ,QAAS,SAAU;AAAA,EAC5B,CAAE;AACF,SAAO,SAAS;AACjB;AAUO,SAAS,eAAgB,OAAO,UAAW;AACjD,QAAM,OAAO,oBAAI,IAAI;AACrB,SAAO,MAAM,OAAQ,CAAE,SAAU;AAChC,UAAM,QAAQ,KAAM,QAAS;AAC7B,WAAO,KAAK,IAAK,KAAM,IAAI,QAAQ,KAAK,IAAK,KAAM;AAAA,EACpD,CAAE;AACH;",
3
+ "sources": ["../../src/utils/object.ts"],
4
+ "sourcesContent": ["type AnyObject = Record< string, unknown >;\ntype ObjectOrArray = AnyObject | unknown[];\ntype ObjectPathKey = number | string;\ntype ObjectPath = ObjectPathKey | ObjectPathKey[];\n\n/**\n * Immutably sets a value inside an object. Like `lodash#set`, but returning a\n * new object. Treats nullish initial values as empty objects. Clones any\n * nested objects. Supports arrays, too.\n *\n * @param object Object to set a value in.\n * @param path Path in the object to modify.\n * @param value New value to set.\n * @return Cloned object with the new value set.\n */\nexport function setImmutably(\n\tobject: ObjectOrArray | null | undefined,\n\tpath: ObjectPath,\n\tvalue: unknown\n): ObjectOrArray {\n\t// Normalize path\n\tconst pathArray: ObjectPathKey[] = Array.isArray( path )\n\t\t? [ ...path ]\n\t\t: [ path ];\n\n\t// Shallowly clone the base of the object\n\tconst result: ObjectOrArray = Array.isArray( object )\n\t\t? [ ...object ]\n\t\t: { ...object };\n\n\tconst leaf = pathArray.pop() as ObjectPathKey;\n\n\t// Traverse object from root to leaf, shallowly cloning at each level\n\tlet prev: ObjectOrArray = result;\n\tfor ( const key of pathArray ) {\n\t\tconst lvl = ( prev as AnyObject )[ key ];\n\t\t( prev as AnyObject )[ key ] = prev = Array.isArray( lvl )\n\t\t\t? [ ...lvl ]\n\t\t\t: { ...( lvl as AnyObject ) };\n\t}\n\n\t( prev as AnyObject )[ leaf ] = value;\n\n\treturn result;\n}\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n * You can also specify a default value in case the result is nullish.\n *\n * @param object Input object.\n * @param path Path to the object property.\n * @param defaultValue Default value if the value at the specified path is nullish.\n * @return Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = (\n\tobject: AnyObject | undefined | null,\n\tpath: string | string[],\n\tdefaultValue?: unknown\n) => {\n\tconst arrayPath = Array.isArray( path ) ? path : path.split( '.' );\n\tlet value: unknown = object;\n\tarrayPath.forEach( ( fieldName ) => {\n\t\tvalue = ( value as AnyObject | undefined | null )?.[ fieldName ];\n\t} );\n\treturn value ?? defaultValue;\n};\n\n/**\n * Helper util to filter out objects with duplicate values for a given property.\n *\n * @param array Array of objects to filter.\n * @param property Property to filter unique values by.\n *\n * @return Array of objects with unique values for the specified property.\n */\nexport function uniqByProperty< T extends AnyObject >(\n\tarray: T[],\n\tproperty: string\n) {\n\tconst seen = new Set();\n\treturn array.filter( ( item ) => {\n\t\tconst value = item[ property ];\n\t\treturn seen.has( value ) ? false : seen.add( value );\n\t} );\n}\n"],
5
+ "mappings": ";AAeO,SAAS,aACf,QACA,MACA,OACgB;AAEhB,QAAM,YAA6B,MAAM,QAAS,IAAK,IACpD,CAAE,GAAG,IAAK,IACV,CAAE,IAAK;AAGV,QAAM,SAAwB,MAAM,QAAS,MAAO,IACjD,CAAE,GAAG,MAAO,IACZ,EAAE,GAAG,OAAO;AAEf,QAAM,OAAO,UAAU,IAAI;AAG3B,MAAI,OAAsB;AAC1B,aAAY,OAAO,WAAY;AAC9B,UAAM,MAAQ,KAAqB,GAAI;AACvC,IAAE,KAAqB,GAAI,IAAI,OAAO,MAAM,QAAS,GAAI,IACtD,CAAE,GAAG,GAAI,IACT,EAAE,GAAK,IAAmB;AAAA,EAC9B;AAEA,EAAE,KAAqB,IAAK,IAAI;AAEhC,SAAO;AACR;AAcO,IAAM,yBAAyB,CACrC,QACA,MACA,iBACI;AACJ,QAAM,YAAY,MAAM,QAAS,IAAK,IAAI,OAAO,KAAK,MAAO,GAAI;AACjE,MAAI,QAAiB;AACrB,YAAU,QAAS,CAAE,cAAe;AACnC,YAAU,QAA2C,SAAU;AAAA,EAChE,CAAE;AACF,SAAO,SAAS;AACjB;AAUO,SAAS,eACf,OACA,UACC;AACD,QAAM,OAAO,oBAAI,IAAI;AACrB,SAAO,MAAM,OAAQ,CAAE,SAAU;AAChC,UAAM,QAAQ,KAAM,QAAS;AAC7B,WAAO,KAAK,IAAK,KAAM,IAAI,QAAQ,KAAK,IAAK,KAAM;AAAA,EACpD,CAAE;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- // packages/block-editor/src/utils/order-inserter-block-items.js
1
+ // packages/block-editor/src/utils/order-inserter-block-items.ts
2
2
  var orderInserterBlockItems = (items, priority) => {
3
3
  if (!priority) {
4
4
  return items;