@wordpress/block-editor 15.22.1-next.v.202606191442.0 → 15.22.1

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 (352) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +2 -2
  3. package/build/components/block-editing-mode/index.cjs +13 -7
  4. package/build/components/block-editing-mode/index.cjs.map +2 -2
  5. package/build/components/block-inspector/index.cjs +32 -16
  6. package/build/components/block-inspector/index.cjs.map +2 -2
  7. package/build/components/block-rename/modal.cjs +0 -1
  8. package/build/components/block-rename/modal.cjs.map +2 -2
  9. package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
  10. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  11. package/build/components/colors-gradients/control.cjs +25 -14
  12. package/build/components/colors-gradients/control.cjs.map +2 -2
  13. package/build/components/colors-gradients/dropdown.cjs +4 -1
  14. package/build/components/colors-gradients/dropdown.cjs.map +3 -3
  15. package/build/components/contrast-checker/index.cjs +22 -4
  16. package/build/components/contrast-checker/index.cjs.map +2 -2
  17. package/build/components/date-format-picker/index.cjs +0 -1
  18. package/build/components/date-format-picker/index.cjs.map +2 -2
  19. package/build/components/global-styles/background-panel.cjs +153 -25
  20. package/build/components/global-styles/background-panel.cjs.map +3 -3
  21. package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
  22. package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
  23. package/build/components/global-styles/color-panel.cjs +98 -375
  24. package/build/components/global-styles/color-panel.cjs.map +3 -3
  25. package/build/components/global-styles/dimensions-panel.cjs +0 -3
  26. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  27. package/build/components/global-styles/hooks.cjs +34 -0
  28. package/build/components/global-styles/hooks.cjs.map +2 -2
  29. package/build/components/global-styles/typography-panel.cjs +82 -10
  30. package/build/components/global-styles/typography-panel.cjs.map +3 -3
  31. package/build/components/inspector-controls/groups.cjs +2 -0
  32. package/build/components/inspector-controls/groups.cjs.map +2 -2
  33. package/build/components/inspector-controls-tabs/styles-tab.cjs +75 -31
  34. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  35. package/build/components/link-control/index.cjs +1 -2
  36. package/build/components/link-control/index.cjs.map +2 -2
  37. package/build/components/list-view/block-select-button.cjs +1 -10
  38. package/build/components/list-view/block-select-button.cjs.map +3 -3
  39. package/build/components/provider/use-block-sync.cjs +3 -1
  40. package/build/components/provider/use-block-sync.cjs.map +2 -2
  41. package/build/components/url-popover/image-url-input-ui.cjs +0 -2
  42. package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
  43. package/build/components/use-block-display-information/index.cjs +10 -3
  44. package/build/components/use-block-display-information/index.cjs.map +2 -2
  45. package/build/hooks/anchor.cjs +0 -1
  46. package/build/hooks/anchor.cjs.map +2 -2
  47. package/build/hooks/background.cjs +124 -75
  48. package/build/hooks/background.cjs.map +3 -3
  49. package/build/hooks/color.cjs +0 -162
  50. package/build/hooks/color.cjs.map +3 -3
  51. package/build/hooks/contrast-checker.cjs +31 -28
  52. package/build/hooks/contrast-checker.cjs.map +3 -3
  53. package/build/hooks/custom-class-name.cjs +0 -1
  54. package/build/hooks/custom-class-name.cjs.map +2 -2
  55. package/build/hooks/elements.cjs +142 -0
  56. package/build/hooks/elements.cjs.map +7 -0
  57. package/build/hooks/grid-visualizer.cjs +21 -11
  58. package/build/hooks/grid-visualizer.cjs.map +2 -2
  59. package/build/hooks/layout-child.cjs +38 -8
  60. package/build/hooks/layout-child.cjs.map +2 -2
  61. package/build/hooks/layout.cjs +6 -3
  62. package/build/hooks/layout.cjs.map +2 -2
  63. package/build/hooks/states.cjs +2 -2
  64. package/build/hooks/states.cjs.map +2 -2
  65. package/build/hooks/style.cjs +8 -4
  66. package/build/hooks/style.cjs.map +2 -2
  67. package/build/hooks/typography.cjs +62 -10
  68. package/build/hooks/typography.cjs.map +3 -3
  69. package/build/layouts/flex.cjs +99 -6
  70. package/build/layouts/flex.cjs.map +2 -2
  71. package/build/utils/block-bindings.cjs +9 -9
  72. package/build/utils/block-bindings.cjs.map +3 -3
  73. package/build/utils/color-values.cjs +10 -1
  74. package/build/utils/color-values.cjs.map +3 -3
  75. package/build/utils/dom.cjs +2 -5
  76. package/build/utils/dom.cjs.map +3 -3
  77. package/build/utils/fit-text-frontend.cjs +6 -2
  78. package/build/utils/fit-text-frontend.cjs.map +3 -3
  79. package/build/utils/fit-text-utils.cjs +1 -1
  80. package/build/utils/fit-text-utils.cjs.map +3 -3
  81. package/build/utils/format-font-style.cjs +1 -1
  82. package/build/utils/format-font-style.cjs.map +3 -3
  83. package/build/utils/format-font-weight.cjs +1 -1
  84. package/build/utils/format-font-weight.cjs.map +3 -3
  85. package/build/utils/get-editor-region.cjs +4 -2
  86. package/build/utils/get-editor-region.cjs.map +3 -3
  87. package/build/utils/get-font-styles-and-weights.cjs +8 -12
  88. package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
  89. package/build/utils/get-px-from-css-unit.cjs +1 -1
  90. package/build/utils/get-px-from-css-unit.cjs.map +1 -1
  91. package/build/utils/index.cjs +1 -1
  92. package/build/utils/index.cjs.map +1 -1
  93. package/build/utils/math.cjs +1 -1
  94. package/build/utils/math.cjs.map +3 -3
  95. package/build/utils/object.cjs +8 -8
  96. package/build/utils/object.cjs.map +3 -3
  97. package/build/utils/order-inserter-block-items.cjs +1 -1
  98. package/build/utils/order-inserter-block-items.cjs.map +3 -3
  99. package/build/utils/pasting.cjs +4 -2
  100. package/build/utils/pasting.cjs.map +3 -3
  101. package/build/utils/selection.cjs +2 -1
  102. package/build/utils/selection.cjs.map +3 -3
  103. package/build/utils/sorting.cjs +9 -3
  104. package/build/utils/sorting.cjs.map +3 -3
  105. package/build/utils/transform-styles/index.cjs +3 -2
  106. package/build/utils/transform-styles/index.cjs.map +3 -3
  107. package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
  108. package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
  109. package/build/utils/transform-styles/types.cjs +19 -0
  110. package/build/utils/transform-styles/types.cjs.map +7 -0
  111. package/build/utils/types.cjs +19 -0
  112. package/build/utils/types.cjs.map +7 -0
  113. package/build-module/components/block-editing-mode/index.mjs +14 -8
  114. package/build-module/components/block-editing-mode/index.mjs.map +2 -2
  115. package/build-module/components/block-inspector/index.mjs +32 -16
  116. package/build-module/components/block-inspector/index.mjs.map +2 -2
  117. package/build-module/components/block-rename/modal.mjs +0 -1
  118. package/build-module/components/block-rename/modal.mjs.map +2 -2
  119. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
  120. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  121. package/build-module/components/colors-gradients/control.mjs +27 -15
  122. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  123. package/build-module/components/colors-gradients/dropdown.mjs +4 -1
  124. package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
  125. package/build-module/components/contrast-checker/index.mjs +18 -4
  126. package/build-module/components/contrast-checker/index.mjs.map +2 -2
  127. package/build-module/components/date-format-picker/index.mjs +0 -1
  128. package/build-module/components/date-format-picker/index.mjs.map +2 -2
  129. package/build-module/components/global-styles/background-panel.mjs +155 -27
  130. package/build-module/components/global-styles/background-panel.mjs.map +2 -2
  131. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
  132. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
  133. package/build-module/components/global-styles/color-panel.mjs +106 -387
  134. package/build-module/components/global-styles/color-panel.mjs.map +3 -3
  135. package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
  136. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  137. package/build-module/components/global-styles/hooks.mjs +33 -0
  138. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  139. package/build-module/components/global-styles/typography-panel.mjs +84 -10
  140. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  141. package/build-module/components/inspector-controls/groups.mjs +2 -0
  142. package/build-module/components/inspector-controls/groups.mjs.map +2 -2
  143. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +75 -31
  144. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  145. package/build-module/components/link-control/index.mjs +1 -2
  146. package/build-module/components/link-control/index.mjs.map +2 -2
  147. package/build-module/components/list-view/block-select-button.mjs +2 -17
  148. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  149. package/build-module/components/provider/use-block-sync.mjs +3 -1
  150. package/build-module/components/provider/use-block-sync.mjs.map +2 -2
  151. package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
  152. package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
  153. package/build-module/components/use-block-display-information/index.mjs +10 -3
  154. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  155. package/build-module/hooks/anchor.mjs +0 -1
  156. package/build-module/hooks/anchor.mjs.map +2 -2
  157. package/build-module/hooks/background.mjs +123 -75
  158. package/build-module/hooks/background.mjs.map +2 -2
  159. package/build-module/hooks/color.mjs +2 -175
  160. package/build-module/hooks/color.mjs.map +2 -2
  161. package/build-module/hooks/contrast-checker.mjs +32 -19
  162. package/build-module/hooks/contrast-checker.mjs.map +2 -2
  163. package/build-module/hooks/custom-class-name.mjs +0 -1
  164. package/build-module/hooks/custom-class-name.mjs.map +2 -2
  165. package/build-module/hooks/elements.mjs +115 -0
  166. package/build-module/hooks/elements.mjs.map +7 -0
  167. package/build-module/hooks/grid-visualizer.mjs +21 -11
  168. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  169. package/build-module/hooks/layout-child.mjs +41 -8
  170. package/build-module/hooks/layout-child.mjs.map +2 -2
  171. package/build-module/hooks/layout.mjs +6 -3
  172. package/build-module/hooks/layout.mjs.map +2 -2
  173. package/build-module/hooks/states.mjs +2 -2
  174. package/build-module/hooks/states.mjs.map +2 -2
  175. package/build-module/hooks/style.mjs +9 -5
  176. package/build-module/hooks/style.mjs.map +2 -2
  177. package/build-module/hooks/typography.mjs +62 -10
  178. package/build-module/hooks/typography.mjs.map +2 -2
  179. package/build-module/layouts/flex.mjs +105 -7
  180. package/build-module/layouts/flex.mjs.map +2 -2
  181. package/build-module/utils/block-bindings.mjs +9 -9
  182. package/build-module/utils/block-bindings.mjs.map +3 -3
  183. package/build-module/utils/color-values.mjs +9 -1
  184. package/build-module/utils/color-values.mjs.map +3 -3
  185. package/build-module/utils/dom.mjs +2 -5
  186. package/build-module/utils/dom.mjs.map +3 -3
  187. package/build-module/utils/fit-text-frontend.mjs +6 -2
  188. package/build-module/utils/fit-text-frontend.mjs.map +3 -3
  189. package/build-module/utils/fit-text-utils.mjs +1 -1
  190. package/build-module/utils/fit-text-utils.mjs.map +3 -3
  191. package/build-module/utils/format-font-style.mjs +1 -1
  192. package/build-module/utils/format-font-style.mjs.map +3 -3
  193. package/build-module/utils/format-font-weight.mjs +1 -1
  194. package/build-module/utils/format-font-weight.mjs.map +3 -3
  195. package/build-module/utils/get-editor-region.mjs +4 -2
  196. package/build-module/utils/get-editor-region.mjs.map +3 -3
  197. package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
  198. package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
  199. package/build-module/utils/get-px-from-css-unit.mjs +1 -1
  200. package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
  201. package/build-module/utils/index.mjs +1 -1
  202. package/build-module/utils/index.mjs.map +1 -1
  203. package/build-module/utils/math.mjs +1 -1
  204. package/build-module/utils/math.mjs.map +3 -3
  205. package/build-module/utils/object.mjs +8 -8
  206. package/build-module/utils/object.mjs.map +3 -3
  207. package/build-module/utils/order-inserter-block-items.mjs +1 -1
  208. package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
  209. package/build-module/utils/pasting.mjs +4 -2
  210. package/build-module/utils/pasting.mjs.map +3 -3
  211. package/build-module/utils/selection.mjs +2 -1
  212. package/build-module/utils/selection.mjs.map +3 -3
  213. package/build-module/utils/sorting.mjs +9 -3
  214. package/build-module/utils/sorting.mjs.map +3 -3
  215. package/build-module/utils/transform-styles/index.mjs +3 -2
  216. package/build-module/utils/transform-styles/index.mjs.map +3 -3
  217. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
  218. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
  219. package/build-module/utils/transform-styles/types.mjs +1 -0
  220. package/build-module/utils/transform-styles/types.mjs.map +7 -0
  221. package/build-module/utils/types.mjs +1 -0
  222. package/build-module/utils/types.mjs.map +7 -0
  223. package/build-style/content-rtl.css +2 -0
  224. package/build-style/content.css +2 -0
  225. package/build-style/style-rtl.css +34 -41
  226. package/build-style/style.css +34 -41
  227. package/build-types/utils/block-bindings.d.ts +27 -0
  228. package/build-types/utils/block-bindings.d.ts.map +1 -0
  229. package/build-types/utils/color-values.d.ts +40 -0
  230. package/build-types/utils/color-values.d.ts.map +1 -0
  231. package/build-types/utils/dom.d.ts +19 -19
  232. package/build-types/utils/dom.d.ts.map +1 -1
  233. package/build-types/utils/fit-text-frontend.d.ts +7 -0
  234. package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
  235. package/build-types/utils/fit-text-utils.d.ts +15 -0
  236. package/build-types/utils/fit-text-utils.d.ts.map +1 -0
  237. package/build-types/utils/format-font-style.d.ts +12 -0
  238. package/build-types/utils/format-font-style.d.ts.map +1 -0
  239. package/build-types/utils/format-font-weight.d.ts +12 -0
  240. package/build-types/utils/format-font-weight.d.ts.map +1 -0
  241. package/build-types/utils/get-editor-region.d.ts +9 -0
  242. package/build-types/utils/get-editor-region.d.ts.map +1 -0
  243. package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
  244. package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
  245. package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
  246. package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
  247. package/build-types/utils/index.d.ts +3 -0
  248. package/build-types/utils/index.d.ts.map +1 -0
  249. package/build-types/utils/math.d.ts +61 -0
  250. package/build-types/utils/math.d.ts.map +1 -0
  251. package/build-types/utils/object.d.ts +39 -0
  252. package/build-types/utils/object.d.ts.map +1 -0
  253. package/build-types/utils/order-inserter-block-items.d.ts +13 -0
  254. package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
  255. package/build-types/utils/pasting.d.ts +28 -0
  256. package/build-types/utils/pasting.d.ts.map +1 -0
  257. package/build-types/utils/selection.d.ts +21 -0
  258. package/build-types/utils/selection.d.ts.map +1 -0
  259. package/build-types/utils/sorting.d.ts +17 -0
  260. package/build-types/utils/sorting.d.ts.map +1 -0
  261. package/build-types/utils/transform-styles/index.d.ts +15 -0
  262. package/build-types/utils/transform-styles/index.d.ts.map +1 -0
  263. package/build-types/utils/transform-styles/types.d.ts +13 -0
  264. package/build-types/utils/transform-styles/types.d.ts.map +1 -0
  265. package/build-types/utils/types.d.ts +28 -0
  266. package/build-types/utils/types.d.ts.map +1 -0
  267. package/package.json +40 -39
  268. package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
  269. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
  270. package/src/components/block-editing-mode/index.js +17 -9
  271. package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
  272. package/src/components/block-inspector/index.js +20 -10
  273. package/src/components/block-rename/modal.js +0 -1
  274. package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
  275. package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
  276. package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
  277. package/src/components/colors-gradients/control.js +29 -12
  278. package/src/components/colors-gradients/dropdown.js +4 -1
  279. package/src/components/colors-gradients/style.scss +39 -2
  280. package/src/components/contrast-checker/README.md +9 -0
  281. package/src/components/contrast-checker/index.js +42 -3
  282. package/src/components/date-format-picker/index.js +0 -1
  283. package/src/components/default-block-appender/content.scss +3 -0
  284. package/src/components/global-styles/background-panel.js +201 -34
  285. package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
  286. package/src/components/global-styles/color-panel.js +125 -487
  287. package/src/components/global-styles/dimensions-panel.js +0 -3
  288. package/src/components/global-styles/hooks.js +45 -0
  289. package/src/components/global-styles/test/background-panel.js +56 -0
  290. package/src/components/global-styles/test/color-panel.js +172 -118
  291. package/src/components/global-styles/test/typography-panel.js +167 -0
  292. package/src/components/global-styles/typography-panel.js +100 -11
  293. package/src/components/inspector-controls/README.md +0 -2
  294. package/src/components/inspector-controls/groups.js +2 -0
  295. package/src/components/inspector-controls-tabs/styles-tab.js +74 -28
  296. package/src/components/link-control/index.js +0 -1
  297. package/src/components/link-control/test/index.js +2 -3
  298. package/src/components/list-view/block-select-button.js +2 -17
  299. package/src/components/provider/use-block-sync.js +3 -1
  300. package/src/components/rich-text/content.scss +2 -0
  301. package/src/components/url-popover/image-url-input-ui.js +0 -2
  302. package/src/components/use-block-display-information/index.js +15 -2
  303. package/src/components/use-block-display-information/test/index.js +140 -0
  304. package/src/hooks/anchor.js +0 -1
  305. package/src/hooks/background.js +210 -133
  306. package/src/hooks/background.scss +0 -35
  307. package/src/hooks/color.js +2 -205
  308. package/src/hooks/color.scss +3 -9
  309. package/src/hooks/contrast-checker.js +60 -17
  310. package/src/hooks/custom-class-name.js +0 -1
  311. package/src/hooks/elements.js +140 -0
  312. package/src/hooks/elements.scss +8 -0
  313. package/src/hooks/grid-visualizer.js +59 -45
  314. package/src/hooks/layout-child.js +51 -12
  315. package/src/hooks/layout.js +6 -3
  316. package/src/hooks/states.js +2 -2
  317. package/src/hooks/style.js +11 -7
  318. package/src/hooks/test/background.js +59 -0
  319. package/src/hooks/test/block-style-state.js +14 -14
  320. package/src/hooks/test/layout.js +6 -6
  321. package/src/hooks/test/style.js +8 -8
  322. package/src/hooks/typography.js +70 -6
  323. package/src/layouts/flex.js +118 -15
  324. package/src/store/test/private-selectors.js +28 -7
  325. package/src/store/test/reducer.js +61 -10
  326. package/src/style.scss +1 -0
  327. package/src/utils/block-bindings.ts +51 -0
  328. package/src/utils/color-values.ts +63 -0
  329. package/src/utils/{dom.js → dom.ts} +27 -27
  330. package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
  331. package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
  332. package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
  333. package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
  334. package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
  335. package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
  336. package/src/utils/{math.js → math.ts} +37 -30
  337. package/src/utils/object.ts +89 -0
  338. package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
  339. package/src/utils/{pasting.js → pasting.ts} +18 -11
  340. package/src/utils/{selection.js → selection.ts} +11 -4
  341. package/src/utils/sorting.ts +81 -0
  342. package/src/utils/test/color-values.js +44 -1
  343. package/src/utils/transform-styles/{index.js → index.ts} +25 -25
  344. package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
  345. package/src/utils/transform-styles/types.ts +13 -0
  346. package/src/utils/types.ts +29 -0
  347. package/src/utils/block-bindings.js +0 -46
  348. package/src/utils/color-values.js +0 -28
  349. package/src/utils/object.js +0 -67
  350. package/src/utils/sorting.js +0 -54
  351. /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
  352. /package/src/utils/{index.js → index.ts} +0 -0
@@ -227,12 +227,12 @@ describe( 'private selectors', () => {
227
227
  const state = {
228
228
  selectedBlockStyleState: {
229
229
  clientId: 'client-1',
230
- value: { viewport: 'mobile', pseudo: ':hover' },
230
+ value: { viewport: '@mobile', pseudo: ':hover' },
231
231
  },
232
232
  };
233
233
 
234
234
  expect( getSelectedBlockStyleState( state, 'client-1' ) ).toEqual( {
235
- viewport: 'mobile',
235
+ viewport: '@mobile',
236
236
  pseudo: ':hover',
237
237
  } );
238
238
  } );
@@ -287,7 +287,7 @@ describe( 'private selectors', () => {
287
287
  const state = {
288
288
  selectedBlockStyleState: {
289
289
  clientId: 'client-1',
290
- value: { viewport: 'mobile', pseudo: 'default' },
290
+ value: { viewport: '@mobile', pseudo: 'default' },
291
291
  },
292
292
  };
293
293
 
@@ -309,7 +309,7 @@ describe( 'private selectors', () => {
309
309
  const state = {
310
310
  selectedBlockStyleState: {
311
311
  clientId: 'client-1',
312
- value: { viewport: 'mobile', pseudo: ':hover' },
312
+ value: { viewport: '@mobile', pseudo: ':hover' },
313
313
  },
314
314
  };
315
315
 
@@ -1661,6 +1661,7 @@ describe( 'private selectors', () => {
1661
1661
  blockName = 'core/group',
1662
1662
  patternName,
1663
1663
  disableContentOnlyForUnsyncedPatterns,
1664
+ disableContentOnlyForTemplateParts,
1664
1665
  templateLock,
1665
1666
  rootTemplateLock,
1666
1667
  } = {} ) => {
@@ -1685,10 +1686,14 @@ describe( 'private selectors', () => {
1685
1686
  : {},
1686
1687
  ],
1687
1688
  ] ),
1688
- settings:
1689
- disableContentOnlyForUnsyncedPatterns !== undefined
1689
+ settings: {
1690
+ ...( disableContentOnlyForUnsyncedPatterns !== undefined
1690
1691
  ? { disableContentOnlyForUnsyncedPatterns }
1691
- : {},
1692
+ : {} ),
1693
+ ...( disableContentOnlyForTemplateParts !== undefined
1694
+ ? { disableContentOnlyForTemplateParts }
1695
+ : {} ),
1696
+ },
1692
1697
  editedContentOnlySection: undefined,
1693
1698
  };
1694
1699
  };
@@ -1732,6 +1737,22 @@ describe( 'private selectors', () => {
1732
1737
  expect( isSectionBlock( state, 'block-1' ) ).toBe( true );
1733
1738
  } );
1734
1739
 
1740
+ it( 'should return false for template parts when disableContentOnlyForTemplateParts is true', () => {
1741
+ const state = createState( {
1742
+ blockName: 'core/template-part',
1743
+ disableContentOnlyForTemplateParts: true,
1744
+ } );
1745
+ expect( isSectionBlock( state, 'block-1' ) ).toBe( false );
1746
+ } );
1747
+
1748
+ it( 'should return true for template parts when disableContentOnlyForTemplateParts is false', () => {
1749
+ const state = createState( {
1750
+ blockName: 'core/template-part',
1751
+ disableContentOnlyForTemplateParts: false,
1752
+ } );
1753
+ expect( isSectionBlock( state, 'block-1' ) ).toBe( true );
1754
+ } );
1755
+
1735
1756
  it( 'returns false when nested inside another section block', () => {
1736
1757
  const state = {
1737
1758
  blocks: {
@@ -5860,6 +5860,57 @@ describe( 'state', () => {
5860
5860
  );
5861
5861
  } );
5862
5862
  } );
5863
+
5864
+ describe( 'template parts with disableContentOnlyForTemplateParts enabled', () => {
5865
+ let initialState;
5866
+ beforeAll( () => {
5867
+ initialState = dispatchActions(
5868
+ [
5869
+ {
5870
+ type: 'UPDATE_SETTINGS',
5871
+ settings: {
5872
+ disableContentOnlyForTemplateParts: true,
5873
+ },
5874
+ },
5875
+ {
5876
+ type: 'RESET_BLOCKS',
5877
+ blocks: [
5878
+ {
5879
+ name: 'core/template-part',
5880
+ clientId: 'template-part',
5881
+ attributes: {},
5882
+ innerBlocks: [],
5883
+ },
5884
+ ],
5885
+ },
5886
+ {
5887
+ type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
5888
+ clientId: 'template-part',
5889
+ hasControlledInnerBlocks: true,
5890
+ },
5891
+ {
5892
+ type: 'REPLACE_INNER_BLOCKS',
5893
+ rootClientId: 'template-part',
5894
+ blocks: [
5895
+ {
5896
+ name: 'core/paragraph',
5897
+ clientId: 'template-part-paragraph',
5898
+ attributes: {},
5899
+ innerBlocks: [],
5900
+ },
5901
+ ],
5902
+ },
5903
+ ],
5904
+ testReducer
5905
+ );
5906
+ } );
5907
+
5908
+ it( 'returns no derived editing modes for template parts when disableContentOnlyForTemplateParts is true', () => {
5909
+ expect( initialState.derivedBlockEditingModes ).toEqual(
5910
+ new Map()
5911
+ );
5912
+ } );
5913
+ } );
5863
5914
  } );
5864
5915
 
5865
5916
  describe( 'selectedBlockStyleState', () => {
@@ -5873,14 +5924,14 @@ describe( 'state', () => {
5873
5924
  const state = selectedBlockStyleState( undefined, {
5874
5925
  type: 'SET_SELECTED_BLOCK_STYLE_STATE',
5875
5926
  clientId: 'client-1',
5876
- value: { viewport: 'mobile' },
5927
+ value: { viewport: '@mobile' },
5877
5928
  } );
5878
5929
 
5879
5930
  expect( state ).toEqual( {
5880
5931
  clientId: 'client-1',
5881
5932
  showStateOnCanvas: true,
5882
5933
  value: {
5883
- viewport: 'mobile',
5934
+ viewport: '@mobile',
5884
5935
  pseudo: 'default',
5885
5936
  },
5886
5937
  } );
@@ -5907,7 +5958,7 @@ describe( 'state', () => {
5907
5958
  const state = selectedBlockStyleState(
5908
5959
  {
5909
5960
  clientId: 'client-1',
5910
- value: { viewport: 'mobile', pseudo: 'default' },
5961
+ value: { viewport: '@mobile', pseudo: 'default' },
5911
5962
  },
5912
5963
  {
5913
5964
  type: 'SET_SELECTED_BLOCK_STYLE_STATE',
@@ -5920,7 +5971,7 @@ describe( 'state', () => {
5920
5971
  clientId: 'client-1',
5921
5972
  showStateOnCanvas: true,
5922
5973
  value: {
5923
- viewport: 'mobile',
5974
+ viewport: '@mobile',
5924
5975
  pseudo: ':hover',
5925
5976
  },
5926
5977
  } );
@@ -5930,7 +5981,7 @@ describe( 'state', () => {
5930
5981
  const state = selectedBlockStyleState(
5931
5982
  {
5932
5983
  clientId: 'client-1',
5933
- value: { viewport: 'mobile', pseudo: ':hover' },
5984
+ value: { viewport: '@mobile', pseudo: ':hover' },
5934
5985
  },
5935
5986
  {
5936
5987
  type: 'SET_SELECTED_BLOCK_STYLE_STATE',
@@ -5953,7 +6004,7 @@ describe( 'state', () => {
5953
6004
  const state = selectedBlockStyleState(
5954
6005
  {
5955
6006
  clientId: 'client-1',
5956
- value: { viewport: 'mobile', pseudo: ':hover' },
6007
+ value: { viewport: '@mobile', pseudo: ':hover' },
5957
6008
  },
5958
6009
  {
5959
6010
  type: 'SET_SELECTED_BLOCK_STYLE_STATE',
@@ -6186,7 +6237,7 @@ describe( 'state', () => {
6186
6237
  const state = selectedBlockStyleState(
6187
6238
  {
6188
6239
  clientId: 'client-1',
6189
- value: { viewport: 'mobile', pseudo: ':hover' },
6240
+ value: { viewport: '@mobile', pseudo: ':hover' },
6190
6241
  },
6191
6242
  {
6192
6243
  type: 'SET_SELECTED_BLOCK_STYLE_STATE_CANVAS_PREVIEW',
@@ -6198,7 +6249,7 @@ describe( 'state', () => {
6198
6249
  expect( state ).toEqual( {
6199
6250
  clientId: 'client-1',
6200
6251
  showStateOnCanvas: false,
6201
- value: { viewport: 'mobile', pseudo: ':hover' },
6252
+ value: { viewport: '@mobile', pseudo: ':hover' },
6202
6253
  } );
6203
6254
  } );
6204
6255
 
@@ -6207,7 +6258,7 @@ describe( 'state', () => {
6207
6258
  {
6208
6259
  clientId: 'client-1',
6209
6260
  showStateOnCanvas: false,
6210
- value: { viewport: 'mobile', pseudo: 'default' },
6261
+ value: { viewport: '@mobile', pseudo: 'default' },
6211
6262
  },
6212
6263
  {
6213
6264
  type: 'SET_SELECTED_BLOCK_STYLE_STATE',
@@ -6219,7 +6270,7 @@ describe( 'state', () => {
6219
6270
  expect( state ).toEqual( {
6220
6271
  clientId: 'client-1',
6221
6272
  showStateOnCanvas: false,
6222
- value: { viewport: 'mobile', pseudo: ':hover' },
6273
+ value: { viewport: '@mobile', pseudo: ':hover' },
6223
6274
  } );
6224
6275
  } );
6225
6276
  } );
package/src/style.scss CHANGED
@@ -61,6 +61,7 @@
61
61
  @use "./hooks/block-bindings.scss" as *;
62
62
  @use "./hooks/border.scss" as *;
63
63
  @use "./hooks/color.scss" as *;
64
+ @use "./hooks/elements.scss" as *;
64
65
  @use "./hooks/dimensions.scss" as *;
65
66
  @use "./hooks/layout.scss" as *;
66
67
  @use "./hooks/spacing.scss" as *;
@@ -0,0 +1,51 @@
1
+ type Binding = { source?: string };
2
+ type Bindings = Record< string, Binding >;
3
+
4
+ const DEFAULT_ATTRIBUTE = '__default';
5
+ const PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';
6
+
7
+ /**
8
+ * Checks if the block has the `__default` binding for pattern overrides.
9
+ *
10
+ * @param bindings A block's bindings from the metadata attribute.
11
+ *
12
+ * @return Whether the block has the `__default` binding for pattern overrides.
13
+ */
14
+ export function hasPatternOverridesDefaultBinding(
15
+ bindings: Bindings | undefined | null
16
+ ): bindings is Bindings {
17
+ return bindings?.[ DEFAULT_ATTRIBUTE ]?.source === PATTERN_OVERRIDES_SOURCE;
18
+ }
19
+
20
+ /**
21
+ * Returns the bindings with the `__default` binding for pattern overrides
22
+ * replaced with the full-set of supported attributes. e.g.:
23
+ *
24
+ * - bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`
25
+ * - bindings returned: `{ content: { source: 'core/pattern-overrides' } }`
26
+ *
27
+ * @param bindings A block's bindings from the metadata attribute.
28
+ * @param supportedAttributes The block's attributes which are supported by block bindings.
29
+ *
30
+ * @return The bindings with default replaced for pattern overrides.
31
+ */
32
+ export function replacePatternOverridesDefaultBinding(
33
+ bindings: Bindings | undefined | null,
34
+ supportedAttributes: string[]
35
+ ) {
36
+ // The `__default` binding currently only works for pattern overrides.
37
+ if ( ! hasPatternOverridesDefaultBinding( bindings ) ) {
38
+ return bindings;
39
+ }
40
+
41
+ const bindingsWithDefaults: Bindings = {};
42
+ for ( const attributeName of supportedAttributes ) {
43
+ // If the block has mixed binding sources, retain any non pattern override bindings.
44
+ const bindingSource = bindings[ attributeName ]
45
+ ? bindings[ attributeName ]
46
+ : { source: PATTERN_OVERRIDES_SOURCE };
47
+ bindingsWithDefaults[ attributeName ] = bindingSource;
48
+ }
49
+
50
+ return bindingsWithDefaults;
51
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Extracts the palette slug from a style value for any preset type, supporting
3
+ * both the user preset format and the theme CSS-variable format:
4
+ *
5
+ * - User format: `var:preset|<type>|slug`
6
+ * - Theme format: `var(--wp--preset--<type>--slug)`
7
+ *
8
+ * Returns `undefined` for plain values, non-strings, or any other
9
+ * unrecognised format.
10
+ *
11
+ * @param rawValue Raw style value stored in the style object.
12
+ * @param type Preset type, e.g. `'color'` or `'gradient'`.
13
+ * @return The palette slug, or undefined.
14
+ */
15
+ export function extractPresetSlug(
16
+ rawValue: unknown,
17
+ type: 'color' | 'gradient'
18
+ ) {
19
+ if ( typeof rawValue !== 'string' ) {
20
+ return undefined;
21
+ }
22
+ const userPrefix = `var:preset|${ type }|`;
23
+ if ( rawValue.startsWith( userPrefix ) ) {
24
+ return rawValue.slice( userPrefix.length );
25
+ }
26
+ const cssVarPrefix = `--wp--preset--${ type }--`;
27
+ const themeFormatMatch = rawValue.match(
28
+ new RegExp( `^var\\(${ cssVarPrefix }([^)]+)\\)$` )
29
+ );
30
+ return themeFormatMatch?.[ 1 ];
31
+ }
32
+
33
+ /**
34
+ * Encodes a color value for storage in the style object.
35
+ *
36
+ * When a `slug` is provided it is used directly (the slug-based selection
37
+ * path). This is important because two palette entries can share the same
38
+ * hex value (e.g. two custom colors both set to `#e10000`); relying on a
39
+ * hex lookup alone would collapse them onto whichever entry appears first
40
+ * in the palette and silently discard the user's actual choice. Only when
41
+ * no slug is supplied does the function fall back to matching the hex value
42
+ * against the palette; if a match is found the slug is encoded, otherwise
43
+ * the raw value is stored as-is.
44
+ *
45
+ * Callers pass the flattened palette (`allColors`), typically computed once
46
+ * per render from the per-origin `colors` array.
47
+ *
48
+ * @param allColors Flat array of `{ color, slug }` objects.
49
+ * @param colorValue Hex or CSS color string.
50
+ * @param slug Optional palette slug from slug-aware selection.
51
+ * @return Encoded value suitable for the style object.
52
+ */
53
+ export function encodeColorValueWithPalette(
54
+ allColors: { color: string; slug: string }[],
55
+ colorValue?: string,
56
+ slug?: string
57
+ ) {
58
+ if ( slug ) {
59
+ return 'var:preset|color|' + slug;
60
+ }
61
+ const colorObject = allColors.find( ( { color } ) => color === colorValue );
62
+ return colorObject ? 'var:preset|color|' + colorObject.slug : colorValue;
63
+ }
@@ -5,12 +5,12 @@ const BLOCK_APPENDER_CLASS = '.block-editor-button-block-appender';
5
5
  /**
6
6
  * Returns true if two elements are contained within the same block.
7
7
  *
8
- * @param {Element} a First element.
9
- * @param {Element} b Second element.
8
+ * @param a First element.
9
+ * @param b Second element.
10
10
  *
11
- * @return {boolean} Whether elements are in the same block.
11
+ * @return Whether elements are in the same block.
12
12
  */
13
- export function isInSameBlock( a, b ) {
13
+ export function isInSameBlock( a: Element, b: Element ) {
14
14
  return a.closest( BLOCK_SELECTOR ) === b.closest( BLOCK_SELECTOR );
15
15
  }
16
16
 
@@ -18,13 +18,13 @@ export function isInSameBlock( a, b ) {
18
18
  * Returns true if an element is considered part of the block and not its inner
19
19
  * blocks or appender.
20
20
  *
21
- * @param {Element} blockElement Block container element.
22
- * @param {Element} element Element.
21
+ * @param blockElement Block container element.
22
+ * @param element Element.
23
23
  *
24
- * @return {boolean} Whether an element is considered part of the block and not
25
- * its inner blocks or appender.
24
+ * @return Whether an element is considered part of the block and not
25
+ * its inner blocks or appender.
26
26
  */
27
- export function isInsideRootBlock( blockElement, element ) {
27
+ export function isInsideRootBlock( blockElement: Element, element: Element ) {
28
28
  const parentBlock = element.closest(
29
29
  [ BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS ].join( ',' )
30
30
  );
@@ -34,12 +34,12 @@ export function isInsideRootBlock( blockElement, element ) {
34
34
  /**
35
35
  * Finds the block client ID given any DOM node inside the block.
36
36
  *
37
- * @param {Node?} node DOM node.
37
+ * @param node DOM node.
38
38
  *
39
- * @return {string|undefined} Client ID or undefined if the node is not part of
40
- * a block.
39
+ * @return Client ID or undefined if the node is not part of
40
+ * a block.
41
41
  */
42
- export function getBlockClientId( node ) {
42
+ export function getBlockClientId( node: Node | null ) {
43
43
  while ( node && node.nodeType !== node.ELEMENT_NODE ) {
44
44
  node = node.parentNode;
45
45
  }
@@ -48,7 +48,7 @@ export function getBlockClientId( node ) {
48
48
  return;
49
49
  }
50
50
 
51
- const elementNode = /** @type {Element} */ ( node );
51
+ const elementNode = node as Element;
52
52
  const blockNode = elementNode.closest( BLOCK_SELECTOR );
53
53
 
54
54
  if ( ! blockNode ) {
@@ -61,11 +61,11 @@ export function getBlockClientId( node ) {
61
61
  /**
62
62
  * Calculates the union of two rectangles.
63
63
  *
64
- * @param {DOMRect} rect1 First rectangle.
65
- * @param {DOMRect} rect2 Second rectangle.
66
- * @return {DOMRect} Union of the two rectangles.
64
+ * @param rect1 First rectangle.
65
+ * @param rect2 Second rectangle.
66
+ * @return Union of the two rectangles.
67
67
  */
68
- export function rectUnion( rect1, rect2 ) {
68
+ export function rectUnion( rect1: DOMRect, rect2: DOMRect ) {
69
69
  const left = Math.min( rect1.left, rect2.left );
70
70
  const right = Math.max( rect1.right, rect2.right );
71
71
  const bottom = Math.max( rect1.bottom, rect2.bottom );
@@ -77,10 +77,10 @@ export function rectUnion( rect1, rect2 ) {
77
77
  /**
78
78
  * Returns whether an element is visible.
79
79
  *
80
- * @param {Element} element Element.
81
- * @return {boolean} Whether the element is visible.
80
+ * @param element Element.
81
+ * @return Whether the element is visible.
82
82
  */
83
- export function isElementVisible( element ) {
83
+ export function isElementVisible( element: Element ) {
84
84
  const viewport = element.ownerDocument.defaultView;
85
85
  if ( ! viewport ) {
86
86
  return false;
@@ -121,10 +121,10 @@ export function isElementVisible( element ) {
121
121
  /**
122
122
  * Checks if the element is scrollable.
123
123
  *
124
- * @param {Element} element Element.
125
- * @return {boolean} True if the element is scrollable.
124
+ * @param element Element.
125
+ * @return True if the element is scrollable.
126
126
  */
127
- function isScrollable( element ) {
127
+ function isScrollable( element: Element ) {
128
128
  const style = window.getComputedStyle( element );
129
129
  return (
130
130
  style.overflowX === 'auto' ||
@@ -145,10 +145,10 @@ export const WITH_OVERFLOW_ELEMENT_BLOCKS = [ 'core/navigation' ];
145
145
  * The returned rect represents the full extent of the element and its visible
146
146
  * children, which may extend beyond the viewport.
147
147
  *
148
- * @param {Element} element Element.
149
- * @return {DOMRect} Bounding client rect of the element and its visible children.
148
+ * @param element Element.
149
+ * @return Bounding client rect of the element and its visible children.
150
150
  */
151
- export function getElementBounds( element ) {
151
+ export function getElementBounds( element: Element ) {
152
152
  const viewport = element.ownerDocument.defaultView;
153
153
 
154
154
  if ( ! viewport ) {
@@ -14,14 +14,21 @@ import { store, getElement, getContext } from '@wordpress/interactivity';
14
14
  */
15
15
  import { optimizeFitText } from './fit-text-utils';
16
16
 
17
+ interface FitTextContext {
18
+ fontSize?: number;
19
+ }
20
+
17
21
  // Initialize via Interactivity API for client-side navigation
18
22
  store( 'core/fit-text', {
19
23
  callbacks: {
20
24
  init() {
21
- const context = getContext();
22
- const { ref } = getElement();
25
+ const context = getContext< FitTextContext >();
26
+ const { ref } = getElement() as { ref: HTMLElement | null };
23
27
 
24
- const applyFontSize = ( fontSize ) => {
28
+ const applyFontSize = ( fontSize: number ) => {
29
+ if ( ! ref ) {
30
+ return;
31
+ }
25
32
  if ( fontSize === 0 ) {
26
33
  ref.style.fontSize = '';
27
34
  } else {
@@ -33,7 +40,7 @@ store( 'core/fit-text', {
33
40
  context.fontSize = optimizeFitText( ref, applyFontSize );
34
41
 
35
42
  // Starts ResizeObserver to handle dynamic resizing.
36
- if ( window.ResizeObserver && ref.parentElement ) {
43
+ if ( window.ResizeObserver && ref?.parentElement ) {
37
44
  const resizeObserver = new window.ResizeObserver( () => {
38
45
  context.fontSize = optimizeFitText( ref, applyFontSize );
39
46
  } );
@@ -47,6 +54,7 @@ store( 'core/fit-text', {
47
54
  }
48
55
  };
49
56
  }
57
+ return undefined;
50
58
  },
51
59
  },
52
60
  } );
@@ -3,14 +3,19 @@
3
3
  * Uses callback-based approach for maximum code reuse between editor and frontend.
4
4
  */
5
5
 
6
+ type ApplyFontSize = ( size: number ) => void;
7
+
6
8
  /**
7
9
  * Find optimal font size using simple binary search between 0-2400px.
8
10
  *
9
- * @param {HTMLElement} textElement The text element
10
- * @param {Function} applyFontSize Function that receives font size in pixels
11
- * @return {number} Optimal font size
11
+ * @param textElement The text element
12
+ * @param applyFontSize Function that receives font size in pixels
13
+ * @return Optimal font size
12
14
  */
13
- function findOptimalFontSize( textElement, applyFontSize ) {
15
+ function findOptimalFontSize(
16
+ textElement: HTMLElement,
17
+ applyFontSize: ApplyFontSize
18
+ ) {
14
19
  const alreadyHasScrollableHeight =
15
20
  textElement.scrollHeight > textElement.clientHeight;
16
21
  let minSize = 0;
@@ -85,10 +90,13 @@ function findOptimalFontSize( textElement, applyFontSize ) {
85
90
  * Complete fit text optimization for a single text element.
86
91
  * Handles the full flow using callbacks for font size application.
87
92
  *
88
- * @param {HTMLElement} textElement The text element (paragraph, heading, etc.)
89
- * @param {Function} applyFontSize Function that receives font size in pixels (0 to clear, >0 to apply)
93
+ * @param textElement The text element (paragraph, heading, etc.)
94
+ * @param applyFontSize Function that receives font size in pixels (0 to clear, >0 to apply)
90
95
  */
91
- export function optimizeFitText( textElement, applyFontSize ) {
96
+ export function optimizeFitText(
97
+ textElement: HTMLElement | null,
98
+ applyFontSize: ApplyFontSize
99
+ ) {
92
100
  if ( ! textElement ) {
93
101
  return;
94
102
  }
@@ -3,13 +3,20 @@
3
3
  */
4
4
  import { _x } from '@wordpress/i18n';
5
5
 
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import type { FormattedFont } from './types';
10
+
6
11
  /**
7
12
  * Formats font styles to human readable names.
8
13
  *
9
- * @param {string} fontStyle font style string
10
- * @return {Object} new object with formatted font style
14
+ * @param fontStyle font style string
15
+ * @return new object with formatted font style
11
16
  */
12
- export function formatFontStyle( fontStyle ) {
17
+ export function formatFontStyle(
18
+ fontStyle: FormattedFont | string | undefined
19
+ ): FormattedFont {
13
20
  if ( ! fontStyle ) {
14
21
  return {};
15
22
  }
@@ -3,13 +3,20 @@
3
3
  */
4
4
  import { _x } from '@wordpress/i18n';
5
5
 
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import type { FormattedFont } from './types';
10
+
6
11
  /**
7
12
  * Formats font weights to human readable names.
8
13
  *
9
- * @param {string} fontWeight font weight string
10
- * @return {Object} new object with formatted font weight
14
+ * @param fontWeight font weight string
15
+ * @return new object with formatted font weight
11
16
  */
12
- export function formatFontWeight( fontWeight ) {
17
+ export function formatFontWeight(
18
+ fontWeight: FormattedFont | string | undefined
19
+ ): FormattedFont {
13
20
  if ( ! fontWeight ) {
14
21
  return {};
15
22
  }
@@ -2,23 +2,27 @@
2
2
  * Gets the editor region for a given editor canvas element or
3
3
  * returns the passed element if no region is found
4
4
  *
5
- * @param { Object } editor The editor canvas element.
6
- * @return { Object } The editor region or given editor element
5
+ * @param editor The editor canvas element.
6
+ * @return The editor region or given editor element
7
7
  */
8
- export default function getEditorRegion( editor ) {
8
+ export default function getEditorRegion( editor: Element | null | undefined ) {
9
9
  if ( ! editor ) {
10
10
  return null;
11
11
  }
12
12
 
13
13
  // If there are multiple editors, we need to find the iframe that contains our contentRef to make sure
14
14
  // we're focusing the region that contains this editor.
15
- const editorCanvas =
15
+ const editorCanvas: Element =
16
16
  Array.from(
17
- document.querySelectorAll( 'iframe[name="editor-canvas"]' ).values()
17
+ document
18
+ .querySelectorAll< HTMLIFrameElement >(
19
+ 'iframe[name="editor-canvas"]'
20
+ )
21
+ .values()
18
22
  ).find( ( iframe ) => {
19
23
  // Find the iframe that contains our contentRef
20
24
  const iframeDocument =
21
- iframe.contentDocument || iframe.contentWindow.document;
25
+ iframe.contentDocument || iframe.contentWindow!.document;
22
26
 
23
27
  return iframeDocument === editor.ownerDocument;
24
28
  } ) ?? editor;