@wordpress/block-editor 16.0.0 → 16.1.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 (368) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +8 -0
  3. package/build/components/alignment-control/ui.cjs +2 -4
  4. package/build/components/alignment-control/ui.cjs.map +2 -2
  5. package/build/components/background-image-control/index.cjs +40 -10
  6. package/build/components/background-image-control/index.cjs.map +2 -2
  7. package/build/components/block-alignment-control/ui.cjs +5 -3
  8. package/build/components/block-alignment-control/ui.cjs.map +2 -2
  9. package/build/components/block-inspector/index.cjs +73 -46
  10. package/build/components/block-inspector/index.cjs.map +2 -2
  11. package/build/components/block-list/block-html.cjs +4 -1
  12. package/build/components/block-list/block-html.cjs.map +2 -2
  13. package/build/components/block-list/use-block-props/index.cjs +5 -2
  14. package/build/components/block-list/use-block-props/index.cjs.map +2 -2
  15. package/build/components/block-list/use-block-props/use-focus-handler.cjs +2 -3
  16. package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +2 -2
  17. package/build/components/block-list/use-block-props/use-register-block-event-handlers.cjs +48 -0
  18. package/build/components/block-list/use-block-props/use-register-block-event-handlers.cjs.map +7 -0
  19. package/build/components/block-parent-selector/index.cjs +2 -2
  20. package/build/components/block-parent-selector/index.cjs.map +2 -2
  21. package/build/components/block-toolbar/switch-section-style.cjs +4 -2
  22. package/build/components/block-toolbar/switch-section-style.cjs.map +3 -3
  23. package/build/components/block-tools/empty-block-inserter.cjs +2 -7
  24. package/build/components/block-tools/empty-block-inserter.cjs.map +2 -2
  25. package/build/components/block-vertical-alignment-control/ui.cjs +3 -5
  26. package/build/components/block-vertical-alignment-control/ui.cjs.map +2 -2
  27. package/build/components/border-radius-control/utils.cjs +8 -58
  28. package/build/components/border-radius-control/utils.cjs.map +2 -2
  29. package/build/components/colors-gradients/control.cjs +5 -3
  30. package/build/components/colors-gradients/control.cjs.map +2 -2
  31. package/build/components/dimension-control/index.cjs +30 -20
  32. package/build/components/dimension-control/index.cjs.map +3 -3
  33. package/build/components/dimensions-tool/aspect-ratio-tool.cjs +9 -2
  34. package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +3 -3
  35. package/build/components/editor-styles/index.cjs +9 -1
  36. package/build/components/editor-styles/index.cjs.map +2 -2
  37. package/build/components/global-styles/background-panel.cjs +66 -25
  38. package/build/components/global-styles/background-panel.cjs.map +3 -3
  39. package/build/components/global-styles/border-panel.cjs +153 -55
  40. package/build/components/global-styles/border-panel.cjs.map +3 -3
  41. package/build/components/global-styles/color-gradient-dropdown-item.cjs +46 -14
  42. package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +3 -3
  43. package/build/components/global-styles/color-panel.cjs +63 -17
  44. package/build/components/global-styles/color-panel.cjs.map +2 -2
  45. package/build/components/global-styles/dimensions-panel.cjs +242 -64
  46. package/build/components/global-styles/dimensions-panel.cjs.map +3 -3
  47. package/build/components/global-styles/filters-panel.cjs +59 -20
  48. package/build/components/global-styles/filters-panel.cjs.map +3 -3
  49. package/build/components/global-styles/hooks.cjs +4 -1
  50. package/build/components/global-styles/hooks.cjs.map +2 -2
  51. package/build/components/global-styles/inheritance/index.cjs +142 -0
  52. package/build/components/global-styles/inheritance/index.cjs.map +7 -0
  53. package/build/components/global-styles/inherited-value-context.cjs +173 -0
  54. package/build/components/global-styles/inherited-value-context.cjs.map +7 -0
  55. package/build/components/global-styles/shadow-panel-components.cjs +38 -20
  56. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  57. package/build/components/global-styles/state-control.cjs +1 -1
  58. package/build/components/global-styles/state-control.cjs.map +2 -2
  59. package/build/components/global-styles/typography-panel.cjs +271 -78
  60. package/build/components/global-styles/typography-panel.cjs.map +3 -3
  61. package/build/components/inspector-controls-tabs/styles-tab.cjs +10 -1
  62. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  63. package/build/components/line-height-control/index.cjs +1 -1
  64. package/build/components/line-height-control/index.cjs.map +2 -2
  65. package/build/components/link-control/index.cjs +3 -1
  66. package/build/components/link-control/index.cjs.map +2 -2
  67. package/build/components/preset-input-control/index.cjs +2 -1
  68. package/build/components/preset-input-control/index.cjs.map +2 -2
  69. package/build/components/provider/block-refs-provider.cjs +8 -2
  70. package/build/components/provider/block-refs-provider.cjs.map +2 -2
  71. package/build/components/provider/index.cjs +1 -1
  72. package/build/components/provider/index.cjs.map +2 -2
  73. package/build/components/provider/use-block-sync.cjs +18 -6
  74. package/build/components/provider/use-block-sync.cjs.map +2 -2
  75. package/build/components/provider/use-media-upload-settings.cjs +3 -1
  76. package/build/components/provider/use-media-upload-settings.cjs.map +2 -2
  77. package/build/components/rich-text/index.cjs +23 -13
  78. package/build/components/rich-text/index.cjs.map +2 -2
  79. package/build/components/spacing-sizes-control/utils.cjs +6 -19
  80. package/build/components/spacing-sizes-control/utils.cjs.map +2 -2
  81. package/build/components/text-indent-control/index.cjs +8 -2
  82. package/build/components/text-indent-control/index.cjs.map +2 -2
  83. package/build/components/url-input/index.cjs +303 -344
  84. package/build/components/url-input/index.cjs.map +3 -3
  85. package/build/components/writing-flow/index.cjs +2 -0
  86. package/build/components/writing-flow/index.cjs.map +3 -3
  87. package/build/components/writing-flow/use-arrow-nav.cjs +24 -1
  88. package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
  89. package/build/components/writing-flow/use-click-selection.cjs +28 -2
  90. package/build/components/writing-flow/use-click-selection.cjs.map +2 -2
  91. package/build/components/writing-flow/use-editable-root-event-handlers.cjs +179 -0
  92. package/build/components/writing-flow/use-editable-root-event-handlers.cjs.map +7 -0
  93. package/build/components/writing-flow/use-editable-root.cjs +5 -42
  94. package/build/components/writing-flow/use-editable-root.cjs.map +2 -2
  95. package/build/components/writing-flow/use-home-end.cjs +1 -1
  96. package/build/components/writing-flow/use-home-end.cjs.map +2 -2
  97. package/build/components/writing-flow/use-selection-observer.cjs +17 -13
  98. package/build/components/writing-flow/use-selection-observer.cjs.map +2 -2
  99. package/build/components/writing-flow/utils.cjs +3 -14
  100. package/build/components/writing-flow/utils.cjs.map +2 -2
  101. package/build/hooks/background.cjs +13 -10
  102. package/build/hooks/background.cjs.map +2 -2
  103. package/build/hooks/block-style-variation.cjs +4 -45
  104. package/build/hooks/block-style-variation.cjs.map +3 -3
  105. package/build/hooks/border.cjs +19 -4
  106. package/build/hooks/border.cjs.map +2 -2
  107. package/build/hooks/custom-css.cjs +6 -2
  108. package/build/hooks/custom-css.cjs.map +2 -2
  109. package/build/hooks/dimensions.cjs +15 -4
  110. package/build/hooks/dimensions.cjs.map +2 -2
  111. package/build/hooks/duotone.cjs +26 -14
  112. package/build/hooks/duotone.cjs.map +3 -3
  113. package/build/hooks/elements.cjs +14 -4
  114. package/build/hooks/elements.cjs.map +2 -2
  115. package/build/hooks/line-height.cjs +1 -2
  116. package/build/hooks/line-height.cjs.map +2 -2
  117. package/build/hooks/typography.cjs +13 -4
  118. package/build/hooks/typography.cjs.map +2 -2
  119. package/build/private-apis.cjs +9 -5
  120. package/build/private-apis.cjs.map +3 -3
  121. package/build/store/actions.cjs +9 -4
  122. package/build/store/actions.cjs.map +2 -2
  123. package/build/store/private-selectors.cjs +28 -1
  124. package/build/store/private-selectors.cjs.map +2 -2
  125. package/build/store/reducer.cjs +6 -6
  126. package/build/store/reducer.cjs.map +2 -2
  127. package/build/store/selectors.cjs +23 -0
  128. package/build/store/selectors.cjs.map +2 -2
  129. package/build/utils/native-undo.cjs +55 -0
  130. package/build/utils/native-undo.cjs.map +7 -0
  131. package/build-module/components/alignment-control/ui.mjs +2 -4
  132. package/build-module/components/alignment-control/ui.mjs.map +2 -2
  133. package/build-module/components/background-image-control/index.mjs +43 -10
  134. package/build-module/components/background-image-control/index.mjs.map +2 -2
  135. package/build-module/components/block-alignment-control/ui.mjs +5 -3
  136. package/build-module/components/block-alignment-control/ui.mjs.map +2 -2
  137. package/build-module/components/block-inspector/index.mjs +74 -46
  138. package/build-module/components/block-inspector/index.mjs.map +2 -2
  139. package/build-module/components/block-list/block-html.mjs +4 -1
  140. package/build-module/components/block-list/block-html.mjs.map +2 -2
  141. package/build-module/components/block-list/use-block-props/index.mjs +5 -2
  142. package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
  143. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +2 -3
  144. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
  145. package/build-module/components/block-list/use-block-props/use-register-block-event-handlers.mjs +28 -0
  146. package/build-module/components/block-list/use-block-props/use-register-block-event-handlers.mjs.map +7 -0
  147. package/build-module/components/block-parent-selector/index.mjs +2 -2
  148. package/build-module/components/block-parent-selector/index.mjs.map +2 -2
  149. package/build-module/components/block-toolbar/switch-section-style.mjs +4 -2
  150. package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
  151. package/build-module/components/block-tools/empty-block-inserter.mjs +2 -7
  152. package/build-module/components/block-tools/empty-block-inserter.mjs.map +2 -2
  153. package/build-module/components/block-vertical-alignment-control/ui.mjs +4 -6
  154. package/build-module/components/block-vertical-alignment-control/ui.mjs.map +2 -2
  155. package/build-module/components/border-radius-control/utils.mjs +11 -53
  156. package/build-module/components/border-radius-control/utils.mjs.map +2 -2
  157. package/build-module/components/colors-gradients/control.mjs +5 -3
  158. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  159. package/build-module/components/dimension-control/index.mjs +30 -20
  160. package/build-module/components/dimension-control/index.mjs.map +2 -2
  161. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +10 -6
  162. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
  163. package/build-module/components/editor-styles/index.mjs +9 -1
  164. package/build-module/components/editor-styles/index.mjs.map +2 -2
  165. package/build-module/components/global-styles/background-panel.mjs +71 -29
  166. package/build-module/components/global-styles/background-panel.mjs.map +2 -2
  167. package/build-module/components/global-styles/border-panel.mjs +157 -56
  168. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  169. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +51 -15
  170. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +2 -2
  171. package/build-module/components/global-styles/color-panel.mjs +63 -17
  172. package/build-module/components/global-styles/color-panel.mjs.map +2 -2
  173. package/build-module/components/global-styles/dimensions-panel.mjs +248 -66
  174. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  175. package/build-module/components/global-styles/filters-panel.mjs +64 -21
  176. package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
  177. package/build-module/components/global-styles/hooks.mjs +4 -1
  178. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  179. package/build-module/components/global-styles/inheritance/index.mjs +108 -0
  180. package/build-module/components/global-styles/inheritance/index.mjs.map +7 -0
  181. package/build-module/components/global-styles/inherited-value-context.mjs +141 -0
  182. package/build-module/components/global-styles/inherited-value-context.mjs.map +7 -0
  183. package/build-module/components/global-styles/shadow-panel-components.mjs +38 -20
  184. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  185. package/build-module/components/global-styles/state-control.mjs +1 -1
  186. package/build-module/components/global-styles/state-control.mjs.map +2 -2
  187. package/build-module/components/global-styles/typography-panel.mjs +276 -79
  188. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  189. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +6 -1
  190. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  191. package/build-module/components/line-height-control/index.mjs +1 -1
  192. package/build-module/components/line-height-control/index.mjs.map +2 -2
  193. package/build-module/components/link-control/index.mjs +4 -2
  194. package/build-module/components/link-control/index.mjs.map +2 -2
  195. package/build-module/components/preset-input-control/index.mjs +2 -1
  196. package/build-module/components/preset-input-control/index.mjs.map +2 -2
  197. package/build-module/components/provider/block-refs-provider.mjs +8 -2
  198. package/build-module/components/provider/block-refs-provider.mjs.map +2 -2
  199. package/build-module/components/provider/index.mjs +1 -1
  200. package/build-module/components/provider/index.mjs.map +2 -2
  201. package/build-module/components/provider/use-block-sync.mjs +18 -6
  202. package/build-module/components/provider/use-block-sync.mjs.map +2 -2
  203. package/build-module/components/provider/use-media-upload-settings.mjs +3 -1
  204. package/build-module/components/provider/use-media-upload-settings.mjs.map +2 -2
  205. package/build-module/components/rich-text/index.mjs +28 -14
  206. package/build-module/components/rich-text/index.mjs.map +2 -2
  207. package/build-module/components/spacing-sizes-control/utils.mjs +6 -18
  208. package/build-module/components/spacing-sizes-control/utils.mjs.map +2 -2
  209. package/build-module/components/text-indent-control/index.mjs +8 -2
  210. package/build-module/components/text-indent-control/index.mjs.map +2 -2
  211. package/build-module/components/url-input/index.mjs +306 -353
  212. package/build-module/components/url-input/index.mjs.map +2 -2
  213. package/build-module/components/writing-flow/index.mjs +2 -0
  214. package/build-module/components/writing-flow/index.mjs.map +2 -2
  215. package/build-module/components/writing-flow/use-arrow-nav.mjs +24 -1
  216. package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
  217. package/build-module/components/writing-flow/use-click-selection.mjs +28 -2
  218. package/build-module/components/writing-flow/use-click-selection.mjs.map +2 -2
  219. package/build-module/components/writing-flow/use-editable-root-event-handlers.mjs +154 -0
  220. package/build-module/components/writing-flow/use-editable-root-event-handlers.mjs.map +7 -0
  221. package/build-module/components/writing-flow/use-editable-root.mjs +5 -37
  222. package/build-module/components/writing-flow/use-editable-root.mjs.map +2 -2
  223. package/build-module/components/writing-flow/use-home-end.mjs +1 -1
  224. package/build-module/components/writing-flow/use-home-end.mjs.map +2 -2
  225. package/build-module/components/writing-flow/use-selection-observer.mjs +18 -14
  226. package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
  227. package/build-module/components/writing-flow/utils.mjs +2 -11
  228. package/build-module/components/writing-flow/utils.mjs.map +2 -2
  229. package/build-module/hooks/background.mjs +13 -10
  230. package/build-module/hooks/background.mjs.map +2 -2
  231. package/build-module/hooks/block-style-variation.mjs +8 -44
  232. package/build-module/hooks/block-style-variation.mjs.map +2 -2
  233. package/build-module/hooks/border.mjs +19 -4
  234. package/build-module/hooks/border.mjs.map +2 -2
  235. package/build-module/hooks/custom-css.mjs +7 -3
  236. package/build-module/hooks/custom-css.mjs.map +2 -2
  237. package/build-module/hooks/dimensions.mjs +15 -4
  238. package/build-module/hooks/dimensions.mjs.map +2 -2
  239. package/build-module/hooks/duotone.mjs +20 -9
  240. package/build-module/hooks/duotone.mjs.map +2 -2
  241. package/build-module/hooks/elements.mjs +14 -4
  242. package/build-module/hooks/elements.mjs.map +2 -2
  243. package/build-module/hooks/line-height.mjs +1 -2
  244. package/build-module/hooks/line-height.mjs.map +2 -2
  245. package/build-module/hooks/typography.mjs +13 -4
  246. package/build-module/hooks/typography.mjs.map +2 -2
  247. package/build-module/private-apis.mjs +7 -3
  248. package/build-module/private-apis.mjs.map +2 -2
  249. package/build-module/store/actions.mjs +9 -4
  250. package/build-module/store/actions.mjs.map +2 -2
  251. package/build-module/store/private-selectors.mjs +29 -1
  252. package/build-module/store/private-selectors.mjs.map +2 -2
  253. package/build-module/store/reducer.mjs +6 -6
  254. package/build-module/store/reducer.mjs.map +2 -2
  255. package/build-module/store/selectors.mjs +23 -0
  256. package/build-module/store/selectors.mjs.map +2 -2
  257. package/build-module/utils/native-undo.mjs +29 -0
  258. package/build-module/utils/native-undo.mjs.map +7 -0
  259. package/build-style/content-rtl.css +10 -18
  260. package/build-style/content.css +10 -18
  261. package/build-style/style-rtl.css +150 -7
  262. package/build-style/style.css +150 -7
  263. package/package.json +40 -41
  264. package/src/components/alignment-control/test/__snapshots__/index.js.snap +1 -1
  265. package/src/components/alignment-control/ui.js +2 -4
  266. package/src/components/background-image-control/index.js +74 -37
  267. package/src/components/background-image-control/style.scss +13 -4
  268. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +3 -3
  269. package/src/components/block-alignment-control/test/index.js +1 -1
  270. package/src/components/block-alignment-control/ui.js +4 -2
  271. package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +1 -1
  272. package/src/components/block-compare/test/__snapshots__/block-view.js.snap +1 -1
  273. package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -1
  274. package/src/components/block-inspector/index.js +60 -31
  275. package/src/components/block-list/block-html.js +5 -0
  276. package/src/components/block-list/content.scss +1 -11
  277. package/src/components/block-list/use-block-props/index.js +5 -1
  278. package/src/components/block-list/use-block-props/use-focus-handler.js +9 -8
  279. package/src/components/block-list/use-block-props/use-register-block-event-handlers.js +45 -0
  280. package/src/components/block-parent-selector/index.js +5 -2
  281. package/src/components/block-toolbar/switch-section-style.js +5 -2
  282. package/src/components/block-tools/empty-block-inserter.js +3 -7
  283. package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +3 -3
  284. package/src/components/block-vertical-alignment-control/test/index.js +18 -2
  285. package/src/components/block-vertical-alignment-control/ui.js +3 -5
  286. package/src/components/border-radius-control/test/utils.js +0 -41
  287. package/src/components/border-radius-control/utils.js +16 -107
  288. package/src/components/button-block-appender/content.scss +6 -2
  289. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  290. package/src/components/colors-gradients/control.js +6 -3
  291. package/src/components/default-block-appender/test/__snapshots__/index.js.snap +1 -1
  292. package/src/components/dimension-control/index.js +13 -1
  293. package/src/components/dimensions-tool/aspect-ratio-tool.js +13 -6
  294. package/src/components/editor-styles/index.js +16 -1
  295. package/src/components/global-styles/background-panel.js +107 -34
  296. package/src/components/global-styles/border-panel.js +219 -48
  297. package/src/components/global-styles/color-gradient-dropdown-item.js +93 -28
  298. package/src/components/global-styles/color-panel.js +92 -11
  299. package/src/components/global-styles/dimensions-panel.js +422 -71
  300. package/src/components/global-styles/filters-panel.js +88 -28
  301. package/src/components/global-styles/hooks.js +8 -1
  302. package/src/components/global-styles/inheritance/index.js +204 -0
  303. package/src/components/global-styles/inheritance/style.scss +184 -0
  304. package/src/components/global-styles/inheritance/test/index.js +281 -0
  305. package/src/components/global-styles/inherited-value-context.js +271 -0
  306. package/src/components/global-styles/shadow-panel-components.js +48 -26
  307. package/src/components/global-styles/state-control.js +2 -2
  308. package/src/components/global-styles/test/background-panel.js +338 -1
  309. package/src/components/global-styles/test/border-panel.js +441 -0
  310. package/src/components/global-styles/test/color-panel.js +182 -2
  311. package/src/components/global-styles/test/dimensions-panel.js +753 -0
  312. package/src/components/global-styles/test/filters-panel.js +194 -0
  313. package/src/components/global-styles/test/inherited-value-context-core.js +98 -0
  314. package/src/components/global-styles/test/inherited-value-context.js +454 -0
  315. package/src/components/global-styles/test/typography-panel-core.js +185 -0
  316. package/src/components/global-styles/test/typography-panel.js +849 -12
  317. package/src/components/global-styles/typography-panel.js +449 -100
  318. package/src/components/image-editor/style.scss +33 -0
  319. package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
  320. package/src/components/inspector-controls-tabs/styles-tab.js +5 -1
  321. package/src/components/line-height-control/index.js +1 -1
  322. package/src/components/link-control/index.js +7 -2
  323. package/src/components/preset-input-control/index.js +4 -1
  324. package/src/components/provider/block-refs-provider.js +12 -2
  325. package/src/components/provider/index.js +2 -2
  326. package/src/components/provider/use-block-sync.js +18 -6
  327. package/src/components/provider/use-media-upload-settings.js +2 -0
  328. package/src/components/rich-text/index.js +37 -16
  329. package/src/components/spacing-sizes-control/test/utils.js +16 -5
  330. package/src/components/spacing-sizes-control/utils.js +11 -28
  331. package/src/components/text-indent-control/index.js +8 -0
  332. package/src/components/url-input/index.js +363 -431
  333. package/src/components/url-input/test/index.js +592 -0
  334. package/src/components/warning/test/__snapshots__/index.js.snap +1 -1
  335. package/src/components/writing-flow/index.js +2 -0
  336. package/src/components/writing-flow/use-arrow-nav.js +51 -1
  337. package/src/components/writing-flow/use-click-selection.js +54 -3
  338. package/src/components/writing-flow/use-editable-root-event-handlers.js +266 -0
  339. package/src/components/writing-flow/use-editable-root.js +7 -77
  340. package/src/components/writing-flow/use-home-end.js +17 -9
  341. package/src/components/writing-flow/use-selection-observer.js +32 -15
  342. package/src/components/writing-flow/utils.js +3 -24
  343. package/src/hooks/background.js +26 -21
  344. package/src/hooks/block-fields/rich-text/styles.scss +1 -1
  345. package/src/hooks/block-style-variation.js +8 -74
  346. package/src/hooks/border.js +19 -4
  347. package/src/hooks/custom-css.js +15 -6
  348. package/src/hooks/dimensions.js +17 -4
  349. package/src/hooks/duotone.js +26 -8
  350. package/src/hooks/elements.js +14 -3
  351. package/src/hooks/line-height.js +0 -1
  352. package/src/hooks/test/inherited-value-wiring.js +411 -0
  353. package/src/hooks/test/preset-round-trip.js +456 -0
  354. package/src/hooks/typography.js +35 -23
  355. package/src/private-apis.js +11 -2
  356. package/src/store/actions.js +10 -4
  357. package/src/store/private-selectors.js +57 -1
  358. package/src/store/reducer.js +9 -9
  359. package/src/store/selectors.js +56 -8
  360. package/src/store/test/private-selectors.js +160 -1
  361. package/src/style.scss +2 -0
  362. package/src/utils/native-undo.js +56 -0
  363. package/build/components/duotone/utils.cjs +0 -87
  364. package/build/components/duotone/utils.cjs.map +0 -7
  365. package/build-module/components/duotone/utils.mjs +0 -59
  366. package/build-module/components/duotone/utils.mjs.map +0 -7
  367. package/src/components/duotone/utils.js +0 -90
  368. package/src/hooks/test/get-variation-styles-with-ref-values.js +0 -91
@@ -1442,19 +1442,19 @@ export function selection( state = {}, action ) {
1442
1442
  selectionEnd,
1443
1443
  };
1444
1444
  case 'MULTI_SELECT':
1445
- const { start, end } = action;
1445
+ const nextSelection = {
1446
+ selectionStart: { clientId: action.start },
1447
+ selectionEnd: { clientId: action.end },
1448
+ };
1446
1449
 
1447
- if (
1448
- start === state.selectionStart?.clientId &&
1449
- end === state.selectionEnd?.clientId
1450
- ) {
1450
+ // A text selection between the same blocks is not the same
1451
+ // selection: it carries attribute keys and offsets, making it
1452
+ // partial rather than a block multi-selection.
1453
+ if ( fastDeepEqual( state, nextSelection ) ) {
1451
1454
  return state;
1452
1455
  }
1453
1456
 
1454
- return {
1455
- selectionStart: { clientId: start },
1456
- selectionEnd: { clientId: end },
1457
- };
1457
+ return nextSelection;
1458
1458
  case 'RESET_BLOCKS':
1459
1459
  const startClientId = state?.selectionStart?.clientId;
1460
1460
  const endClientId = state?.selectionEnd?.clientId;
@@ -149,14 +149,26 @@ export function getBlockAttributes( state, clientId ) {
149
149
  * blocks module registration store.
150
150
  *
151
151
  * getBlock recurses through its inner blocks until all its children blocks have
152
- * been retrieved. Note that getBlock will not return the child inner blocks of
153
- * an inner block controller. This is because an inner block controller syncs
154
- * itself with its own entity, and should therefore not be included with the
155
- * blocks of a different entity. For example, say you call `getBlocks( TP )` to
156
- * get the blocks of a template part. If another template part is a child of TP,
157
- * then the nested template part's child blocks will not be returned. This way,
158
- * the template block itself is considered part of the parent, but the children
159
- * are not.
152
+ * been retrieved, with one exception: the children of an "inner block
153
+ * controller" are not part of its tree, so `innerBlocks` usually comes back
154
+ * empty even though the block clearly has children in the editor. Never rely on
155
+ * a controller's `innerBlocks`; ask for its children directly:
156
+ *
157
+ * ```js
158
+ * getBlock( syncedPatternClientId ).innerBlocks; // Usually [].
159
+ * getBlocks( syncedPatternClientId ); // The pattern's blocks.
160
+ * ```
161
+ *
162
+ * A block is an inner block controller when its children belong to, and are
163
+ * synced with, an entity other than the one being edited. Synced patterns
164
+ * (`core/block`) and template parts (`core/template-part`) are the usual
165
+ * examples: each owns its own blocks, and editing them saves to that pattern or
166
+ * template part, not to the post or template it sits in. Leaving their children
167
+ * out of the tree is what keeps the two entities separate, so walking a
168
+ * template's blocks stops at a template part placed inside it.
169
+ *
170
+ * `areInnerBlocksControlled( clientId )` tells whether a block is such a
171
+ * controller.
160
172
  *
161
173
  * @param {Object} state Editor state.
162
174
  * @param {string} clientId Block client ID.
@@ -789,6 +801,30 @@ export function getSelectedBlocksInitialCaretPosition( state ) {
789
801
  return state.initialPosition;
790
802
  }
791
803
 
804
+ /**
805
+ * Returns the ancestor client ID when one selection endpoint is nested
806
+ * inside the other, or undefined for any other selection shape. Such a
807
+ * selection has no sibling range; the ancestor contains all of it.
808
+ *
809
+ * @param {Object} state Editor state.
810
+ * @return {?string} The ancestor client ID, if any.
811
+ */
812
+ function getSelectionNestingAncestor( state ) {
813
+ const { selectionStart, selectionEnd } = state.selection;
814
+ const startClientId = selectionStart.clientId;
815
+ const endClientId = selectionEnd.clientId;
816
+ if ( ! startClientId || ! endClientId || startClientId === endClientId ) {
817
+ return undefined;
818
+ }
819
+ if ( getBlockParents( state, endClientId ).includes( startClientId ) ) {
820
+ return startClientId;
821
+ }
822
+ if ( getBlockParents( state, startClientId ).includes( endClientId ) ) {
823
+ return endClientId;
824
+ }
825
+ return undefined;
826
+ }
827
+
792
828
  /**
793
829
  * Returns the current selection set of block client IDs (multiselection or single selection).
794
830
  *
@@ -808,6 +844,11 @@ export const getSelectedBlockClientIds = createSelector(
808
844
  return [ selectionStart.clientId ];
809
845
  }
810
846
 
847
+ const nestingAncestorClientId = getSelectionNestingAncestor( state );
848
+ if ( nestingAncestorClientId ) {
849
+ return [ nestingAncestorClientId ];
850
+ }
851
+
811
852
  // Retrieve root client ID to aid in retrieving relevant nested block
812
853
  // order, being careful to allow the falsey empty string top-level root
813
854
  // by explicitly testing against null.
@@ -832,6 +873,7 @@ export const getSelectedBlockClientIds = createSelector(
832
873
  },
833
874
  ( state ) => [
834
875
  state.blocks.order,
876
+ state.blocks.parents,
835
877
  state.selection.selectionStart.clientId,
836
878
  state.selection.selectionEnd.clientId,
837
879
  ]
@@ -1014,6 +1056,12 @@ export function getMultiSelectedBlocksEndClientId( state ) {
1014
1056
  * @return {boolean} Whether the selection is mergeable.
1015
1057
  */
1016
1058
  export function __unstableIsFullySelected( state ) {
1059
+ // A text selection with one endpoint nested inside the other has no
1060
+ // sibling range; it resolves to the ancestor, which is presented and
1061
+ // treated as fully selected.
1062
+ if ( getSelectionNestingAncestor( state ) ) {
1063
+ return true;
1064
+ }
1017
1065
  const selectionAnchor = getSelectionStart( state );
1018
1066
  const selectionFocus = getSelectionEnd( state );
1019
1067
  return (
@@ -1,7 +1,11 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
4
+ import {
5
+ registerBlockType,
6
+ unregisterBlockType,
7
+ privateApis as blocksPrivateApis,
8
+ } from '@wordpress/blocks';
5
9
 
6
10
  /**
7
11
  * Internal dependencies
@@ -29,9 +33,15 @@ import {
29
33
  hasSelectedStyleState,
30
34
  isSelectedBlockStyleStateShownOnCanvas,
31
35
  shouldRenderBlockListView,
36
+ getStyleOverrides,
37
+ canHostEditableRoot,
32
38
  } from '../private-selectors';
33
39
  import { getBlockEditingMode } from '../selectors';
34
40
  import { deviceTypeKey } from '../private-keys';
41
+ import reducer from '../reducer';
42
+ import { unlock } from '../../lock-unlock';
43
+
44
+ const { editableRootKey } = unlock( blocksPrivateApis );
35
45
 
36
46
  describe( 'private selectors', () => {
37
47
  describe( 'isBlockInterfaceHidden', () => {
@@ -1349,6 +1359,27 @@ describe( 'private selectors', () => {
1349
1359
  } );
1350
1360
  } );
1351
1361
 
1362
+ describe( 'getStyleOverrides', () => {
1363
+ it( 'sorts overrides by the order of the blocks they belong to', () => {
1364
+ const state = {
1365
+ blocks: {
1366
+ order: new Map( [ [ '', [ 'block-1', 'block-2' ] ] ] ),
1367
+ },
1368
+ styleOverrides: new Map( [
1369
+ [ 'override-2', { clientId: 'block-2', css: '.b{}' } ],
1370
+ [ 'override-1', { clientId: 'block-1', css: '.a{}' } ],
1371
+ [ 'override-global', { css: '.global{}' } ],
1372
+ ] ),
1373
+ };
1374
+
1375
+ expect( getStyleOverrides( state ) ).toEqual( [
1376
+ [ 'override-global', { css: '.global{}' } ],
1377
+ [ 'override-1', { clientId: 'block-1', css: '.a{}' } ],
1378
+ [ 'override-2', { clientId: 'block-2', css: '.b{}' } ],
1379
+ ] );
1380
+ } );
1381
+ } );
1382
+
1352
1383
  describe( 'getBlockStyles', () => {
1353
1384
  it( 'should return an empty object when no client IDs are provided', () => {
1354
1385
  const state = {
@@ -2528,4 +2559,132 @@ describe( 'private selectors', () => {
2528
2559
  );
2529
2560
  } );
2530
2561
  } );
2562
+
2563
+ describe( 'canHostEditableRoot', () => {
2564
+ beforeEach( () => {
2565
+ registerBlockType( 'core/test-editable-root', {
2566
+ apiVersion: 3,
2567
+ save: () => null,
2568
+ category: 'text',
2569
+ title: 'Editable root',
2570
+ [ editableRootKey ]: true,
2571
+ } );
2572
+ registerBlockType( 'core/test-plain', {
2573
+ apiVersion: 3,
2574
+ save: () => null,
2575
+ category: 'text',
2576
+ title: 'Plain',
2577
+ } );
2578
+ } );
2579
+
2580
+ afterEach( () => {
2581
+ unregisterBlockType( 'core/test-editable-root' );
2582
+ unregisterBlockType( 'core/test-plain' );
2583
+ } );
2584
+
2585
+ const createState = () => ( {
2586
+ blocks: {
2587
+ byClientId: new Map( [
2588
+ [ 'a', { name: 'core/test-editable-root' } ],
2589
+ [ 'b', { name: 'core/test-editable-root' } ],
2590
+ ] ),
2591
+ attributes: new Map( [
2592
+ [ 'a', { content: 'a' } ],
2593
+ [ 'b', { content: 'b' } ],
2594
+ ] ),
2595
+ order: new Map( [
2596
+ [ '', [ 'a', 'b' ] ],
2597
+ [ 'a', [] ],
2598
+ [ 'b', [] ],
2599
+ ] ),
2600
+ parents: new Map( [
2601
+ [ 'a', '' ],
2602
+ [ 'b', '' ],
2603
+ ] ),
2604
+ blockEditingModes: new Map(),
2605
+ },
2606
+ derivedBlockEditingModes: new Map(),
2607
+ blocksMode: {},
2608
+ } );
2609
+
2610
+ it( 'should return true for a block supporting editableRoot with editable siblings', () => {
2611
+ expect( canHostEditableRoot( createState(), 'a' ) ).toBe( true );
2612
+ } );
2613
+
2614
+ it( 'should return false for a lone block', () => {
2615
+ const state = createState();
2616
+ state.blocks.order = new Map( [
2617
+ [ '', [ 'a' ] ],
2618
+ [ 'a', [] ],
2619
+ ] );
2620
+
2621
+ expect( canHostEditableRoot( state, 'a' ) ).toBe( false );
2622
+ } );
2623
+
2624
+ it( 'should return false when a sibling is not editable', () => {
2625
+ const state = createState();
2626
+ state.derivedBlockEditingModes = new Map( [ [ 'b', 'disabled' ] ] );
2627
+
2628
+ expect( canHostEditableRoot( state, 'a' ) ).toBe( false );
2629
+ } );
2630
+
2631
+ // The sibling scan is O(siblings) and runs in every rich text instance.
2632
+ it( 'should not recompute when only block attributes change', () => {
2633
+ const state = createState();
2634
+ expect( canHostEditableRoot( state, 'a' ) ).toBe( true );
2635
+
2636
+ // Change the uncached result without touching a dependant.
2637
+ state.blocks.byClientId.set( 'a', { name: 'core/test-plain' } );
2638
+
2639
+ const nextState = {
2640
+ ...state,
2641
+ blocks: {
2642
+ ...state.blocks,
2643
+ attributes: new Map( [
2644
+ [ 'a', { content: 'typed' } ],
2645
+ [ 'b', { content: 'b' } ],
2646
+ ] ),
2647
+ },
2648
+ };
2649
+
2650
+ expect( canHostEditableRoot( nextState, 'a' ) ).toBe( true );
2651
+
2652
+ nextState.blocks.byClientId = new Map( state.blocks.byClientId );
2653
+ expect( canHostEditableRoot( nextState, 'a' ) ).toBe( false );
2654
+ } );
2655
+
2656
+ // The memoization above is only reachable if the reducer preserves
2657
+ // these references through a keystroke.
2658
+ it( 'should keep its dependants referentially stable while typing', () => {
2659
+ const block = ( clientId ) => ( {
2660
+ clientId,
2661
+ name: 'core/test-editable-root',
2662
+ attributes: { content: clientId },
2663
+ innerBlocks: [],
2664
+ } );
2665
+ const state = reducer( reducer( undefined, { type: '@@init' } ), {
2666
+ type: 'RESET_BLOCKS',
2667
+ blocks: [ block( 'a' ), block( 'b' ) ],
2668
+ } );
2669
+
2670
+ const next = reducer( state, {
2671
+ type: 'UPDATE_BLOCK_ATTRIBUTES',
2672
+ clientIds: [ 'a' ],
2673
+ attributes: { content: 'typed' },
2674
+ } );
2675
+
2676
+ // Guards against the assertions below passing vacuously.
2677
+ expect( next.blocks.attributes ).not.toBe(
2678
+ state.blocks.attributes
2679
+ );
2680
+
2681
+ const before = canHostEditableRoot.getDependants( state );
2682
+ const after = canHostEditableRoot.getDependants( next );
2683
+
2684
+ expect( after ).toHaveLength( before.length );
2685
+ after.forEach( ( dependant, index ) => {
2686
+ expect( dependant ).toBe( before[ index ] );
2687
+ } );
2688
+ } );
2689
+ } );
2531
2690
  } );
package/src/style.scss CHANGED
@@ -35,9 +35,11 @@
35
35
  @use "./components/fit-text-size-warning/style.scss" as *;
36
36
  @use "./components/font-appearance-control/style.scss" as *;
37
37
  @use "./components/global-styles/style.scss" as *;
38
+ @use "./components/global-styles/inheritance/style.scss" as *;
38
39
  @use "./components/grid/style.scss" as *;
39
40
  @use "./components/height-control/style.scss" as *;
40
41
  @use "./components/iframe/style.scss" as *;
42
+ @use "./components/image-editor/style.scss" as *;
41
43
  @use "./components/inserter-list-item/style.scss" as *;
42
44
  @use "./components/inspector-controls/styles.scss" as *;
43
45
  @use "./components/inspector-controls-tabs/style.scss" as *;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useRefEffect } from '@wordpress/compose';
5
+
6
+ /**
7
+ * Elements whose content the browser's own undo acts on (a dialog input, an
8
+ * HTML editing field, a search field), registered through `useNativeUndo`.
9
+ * The editor history must not act on events originating within them.
10
+ */
11
+ const nativeUndoNodes = new WeakSet();
12
+
13
+ /**
14
+ * Returns a ref that marks an element (and its descendants) as relying on
15
+ * the browser's own undo, so the editor history leaves the undo and redo
16
+ * shortcuts alone within it.
17
+ *
18
+ * @return {Function} Ref callback.
19
+ */
20
+ export function useNativeUndo() {
21
+ return useRefEffect( ( node ) => {
22
+ nativeUndoNodes.add( node );
23
+ return () => {
24
+ nativeUndoNodes.delete( node );
25
+ };
26
+ }, [] );
27
+ }
28
+
29
+ /**
30
+ * Returns true when the event originates from an element registered through
31
+ * `useNativeUndo`.
32
+ *
33
+ * Events coming from the editor canvas are re-dispatched on the iframe
34
+ * element, so the real target is resolved through the frame's focused
35
+ * element.
36
+ *
37
+ * @param {KeyboardEvent} event Keyboard event.
38
+ *
39
+ * @return {boolean} Whether the element relies on the browser's own undo.
40
+ */
41
+ export function usesNativeUndo( event ) {
42
+ let { target } = event;
43
+
44
+ if ( target?.nodeName === 'IFRAME' ) {
45
+ target = target.contentDocument?.activeElement;
46
+ }
47
+
48
+ while ( target ) {
49
+ if ( nativeUndoNodes.has( target ) ) {
50
+ return true;
51
+ }
52
+ target = target.parentElement;
53
+ }
54
+
55
+ return false;
56
+ }
@@ -1,87 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/block-editor/src/components/duotone/utils.js
21
- var utils_exports = {};
22
- __export(utils_exports, {
23
- getDuotoneFilter: () => getDuotoneFilter,
24
- getDuotoneStylesheet: () => getDuotoneStylesheet,
25
- getDuotoneUnsetStylesheet: () => getDuotoneUnsetStylesheet,
26
- getValuesFromColors: () => getValuesFromColors
27
- });
28
- module.exports = __toCommonJS(utils_exports);
29
- var import_colord = require("colord");
30
- function getValuesFromColors(colors = []) {
31
- const values = { r: [], g: [], b: [], a: [] };
32
- colors.forEach((color) => {
33
- const rgbColor = (0, import_colord.colord)(color).toRgb();
34
- values.r.push(rgbColor.r / 255);
35
- values.g.push(rgbColor.g / 255);
36
- values.b.push(rgbColor.b / 255);
37
- values.a.push(rgbColor.a);
38
- });
39
- return values;
40
- }
41
- function getDuotoneUnsetStylesheet(selector) {
42
- return `${selector}{filter:none}`;
43
- }
44
- function getDuotoneStylesheet(selector, id) {
45
- return `${selector}{filter:url(#${id})}`;
46
- }
47
- function getDuotoneFilter(id, colors) {
48
- const values = getValuesFromColors(colors);
49
- return `
50
- <svg
51
- xmlns:xlink="http://www.w3.org/1999/xlink"
52
- viewBox="0 0 0 0"
53
- width="0"
54
- height="0"
55
- focusable="false"
56
- role="none"
57
- aria-hidden="true"
58
- style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
59
- >
60
- <defs>
61
- <filter id="${id}">
62
- <!--
63
- Use sRGB instead of linearRGB so transparency looks correct.
64
- Use perceptual brightness to convert to grayscale.
65
- -->
66
- <feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>
67
- <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
68
- <feComponentTransfer color-interpolation-filters="sRGB">
69
- <feFuncR type="table" tableValues="${values.r.join(" ")}"></feFuncR>
70
- <feFuncG type="table" tableValues="${values.g.join(" ")}"></feFuncG>
71
- <feFuncB type="table" tableValues="${values.b.join(" ")}"></feFuncB>
72
- <feFuncA type="table" tableValues="${values.a.join(" ")}"></feFuncA>
73
- </feComponentTransfer>
74
- <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
75
- <feComposite in2="SourceGraphic" operator="in"></feComposite>
76
- </filter>
77
- </defs>
78
- </svg>`;
79
- }
80
- // Annotate the CommonJS export names for ESM import in node:
81
- 0 && (module.exports = {
82
- getDuotoneFilter,
83
- getDuotoneStylesheet,
84
- getDuotoneUnsetStylesheet,
85
- getValuesFromColors
86
- });
87
- //# sourceMappingURL=utils.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/duotone/utils.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { colord } from 'colord';\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [], a: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\tconst rgbColor = colord( color ).toRgb();\n\t\tvalues.r.push( rgbColor.r / 255 );\n\t\tvalues.g.push( rgbColor.g / 255 );\n\t\tvalues.b.push( rgbColor.b / 255 );\n\t\tvalues.a.push( rgbColor.a );\n\t} );\n\n\treturn values;\n}\n\n/**\n * Stylesheet for disabling a global styles duotone filter.\n *\n * @param {string} selector Selector to disable the filter for.\n *\n * @return {string} Filter none style.\n */\nexport function getDuotoneUnsetStylesheet( selector ) {\n\treturn `${ selector }{filter:none}`;\n}\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {string} selector Selector to apply the filter to.\n * @param {string} id Unique id for this duotone filter.\n *\n * @return {string} Duotone filter style.\n */\nexport function getDuotoneStylesheet( selector, id ) {\n\treturn `${ selector }{filter:url(#${ id })}`;\n}\n\n/**\n * The SVG part of the duotone filter.\n *\n * @param {string} id Unique id for this duotone filter.\n * @param {string[]} colors Color strings from dark to light.\n *\n * @return {string} Duotone SVG.\n */\nexport function getDuotoneFilter( id, colors ) {\n\tconst values = getValuesFromColors( colors );\n\treturn `\n<svg\n\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n\tviewBox=\"0 0 0 0\"\n\twidth=\"0\"\n\theight=\"0\"\n\tfocusable=\"false\"\n\trole=\"none\"\n\taria-hidden=\"true\"\n\tstyle=\"visibility: hidden; position: absolute; left: -9999px; overflow: hidden;\"\n>\n\t<defs>\n\t\t<filter id=\"${ id }\">\n\t\t\t<!--\n\t\t\t\tUse sRGB instead of linearRGB so transparency looks correct.\n\t\t\t\tUse perceptual brightness to convert to grayscale.\n\t\t\t-->\n\t\t\t<feColorMatrix color-interpolation-filters=\"sRGB\" type=\"matrix\" values=\" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 \"></feColorMatrix>\n\t\t\t<!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->\n\t\t\t<feComponentTransfer color-interpolation-filters=\"sRGB\">\n\t\t\t\t<feFuncR type=\"table\" tableValues=\"${ values.r.join( ' ' ) }\"></feFuncR>\n\t\t\t\t<feFuncG type=\"table\" tableValues=\"${ values.g.join( ' ' ) }\"></feFuncG>\n\t\t\t\t<feFuncB type=\"table\" tableValues=\"${ values.b.join( ' ' ) }\"></feFuncB>\n\t\t\t\t<feFuncA type=\"table\" tableValues=\"${ values.a.join( ' ' ) }\"></feFuncA>\n\t\t\t</feComponentTransfer>\n\t\t\t<!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->\n\t\t\t<feComposite in2=\"SourceGraphic\" operator=\"in\"></feComposite>\n\t\t</filter>\n\t</defs>\n</svg>`;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAuB;AAShB,SAAS,oBAAqB,SAAS,CAAC,GAAI;AAClD,QAAM,SAAS,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE;AAE5C,SAAO,QAAS,CAAE,UAAW;AAC5B,UAAM,eAAW,sBAAQ,KAAM,EAAE,MAAM;AACvC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,CAAE;AAAA,EAC3B,CAAE;AAEF,SAAO;AACR;AASO,SAAS,0BAA2B,UAAW;AACrD,SAAO,GAAI,QAAS;AACrB;AAUO,SAAS,qBAAsB,UAAU,IAAK;AACpD,SAAO,GAAI,QAAS,gBAAiB,EAAG;AACzC;AAUO,SAAS,iBAAkB,IAAI,QAAS;AAC9C,QAAM,SAAS,oBAAqB,MAAO;AAC3C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAYS,EAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAQsB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO/D;",
6
- "names": []
7
- }
@@ -1,59 +0,0 @@
1
- // packages/block-editor/src/components/duotone/utils.js
2
- import { colord } from "colord";
3
- function getValuesFromColors(colors = []) {
4
- const values = { r: [], g: [], b: [], a: [] };
5
- colors.forEach((color) => {
6
- const rgbColor = colord(color).toRgb();
7
- values.r.push(rgbColor.r / 255);
8
- values.g.push(rgbColor.g / 255);
9
- values.b.push(rgbColor.b / 255);
10
- values.a.push(rgbColor.a);
11
- });
12
- return values;
13
- }
14
- function getDuotoneUnsetStylesheet(selector) {
15
- return `${selector}{filter:none}`;
16
- }
17
- function getDuotoneStylesheet(selector, id) {
18
- return `${selector}{filter:url(#${id})}`;
19
- }
20
- function getDuotoneFilter(id, colors) {
21
- const values = getValuesFromColors(colors);
22
- return `
23
- <svg
24
- xmlns:xlink="http://www.w3.org/1999/xlink"
25
- viewBox="0 0 0 0"
26
- width="0"
27
- height="0"
28
- focusable="false"
29
- role="none"
30
- aria-hidden="true"
31
- style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
32
- >
33
- <defs>
34
- <filter id="${id}">
35
- <!--
36
- Use sRGB instead of linearRGB so transparency looks correct.
37
- Use perceptual brightness to convert to grayscale.
38
- -->
39
- <feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>
40
- <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
41
- <feComponentTransfer color-interpolation-filters="sRGB">
42
- <feFuncR type="table" tableValues="${values.r.join(" ")}"></feFuncR>
43
- <feFuncG type="table" tableValues="${values.g.join(" ")}"></feFuncG>
44
- <feFuncB type="table" tableValues="${values.b.join(" ")}"></feFuncB>
45
- <feFuncA type="table" tableValues="${values.a.join(" ")}"></feFuncA>
46
- </feComponentTransfer>
47
- <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
48
- <feComposite in2="SourceGraphic" operator="in"></feComposite>
49
- </filter>
50
- </defs>
51
- </svg>`;
52
- }
53
- export {
54
- getDuotoneFilter,
55
- getDuotoneStylesheet,
56
- getDuotoneUnsetStylesheet,
57
- getValuesFromColors
58
- };
59
- //# sourceMappingURL=utils.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/duotone/utils.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { colord } from 'colord';\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [], a: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\tconst rgbColor = colord( color ).toRgb();\n\t\tvalues.r.push( rgbColor.r / 255 );\n\t\tvalues.g.push( rgbColor.g / 255 );\n\t\tvalues.b.push( rgbColor.b / 255 );\n\t\tvalues.a.push( rgbColor.a );\n\t} );\n\n\treturn values;\n}\n\n/**\n * Stylesheet for disabling a global styles duotone filter.\n *\n * @param {string} selector Selector to disable the filter for.\n *\n * @return {string} Filter none style.\n */\nexport function getDuotoneUnsetStylesheet( selector ) {\n\treturn `${ selector }{filter:none}`;\n}\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {string} selector Selector to apply the filter to.\n * @param {string} id Unique id for this duotone filter.\n *\n * @return {string} Duotone filter style.\n */\nexport function getDuotoneStylesheet( selector, id ) {\n\treturn `${ selector }{filter:url(#${ id })}`;\n}\n\n/**\n * The SVG part of the duotone filter.\n *\n * @param {string} id Unique id for this duotone filter.\n * @param {string[]} colors Color strings from dark to light.\n *\n * @return {string} Duotone SVG.\n */\nexport function getDuotoneFilter( id, colors ) {\n\tconst values = getValuesFromColors( colors );\n\treturn `\n<svg\n\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n\tviewBox=\"0 0 0 0\"\n\twidth=\"0\"\n\theight=\"0\"\n\tfocusable=\"false\"\n\trole=\"none\"\n\taria-hidden=\"true\"\n\tstyle=\"visibility: hidden; position: absolute; left: -9999px; overflow: hidden;\"\n>\n\t<defs>\n\t\t<filter id=\"${ id }\">\n\t\t\t<!--\n\t\t\t\tUse sRGB instead of linearRGB so transparency looks correct.\n\t\t\t\tUse perceptual brightness to convert to grayscale.\n\t\t\t-->\n\t\t\t<feColorMatrix color-interpolation-filters=\"sRGB\" type=\"matrix\" values=\" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 \"></feColorMatrix>\n\t\t\t<!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->\n\t\t\t<feComponentTransfer color-interpolation-filters=\"sRGB\">\n\t\t\t\t<feFuncR type=\"table\" tableValues=\"${ values.r.join( ' ' ) }\"></feFuncR>\n\t\t\t\t<feFuncG type=\"table\" tableValues=\"${ values.g.join( ' ' ) }\"></feFuncG>\n\t\t\t\t<feFuncB type=\"table\" tableValues=\"${ values.b.join( ' ' ) }\"></feFuncB>\n\t\t\t\t<feFuncA type=\"table\" tableValues=\"${ values.a.join( ' ' ) }\"></feFuncA>\n\t\t\t</feComponentTransfer>\n\t\t\t<!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->\n\t\t\t<feComposite in2=\"SourceGraphic\" operator=\"in\"></feComposite>\n\t\t</filter>\n\t</defs>\n</svg>`;\n}\n"],
5
- "mappings": ";AAGA,SAAS,cAAc;AAShB,SAAS,oBAAqB,SAAS,CAAC,GAAI;AAClD,QAAM,SAAS,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE;AAE5C,SAAO,QAAS,CAAE,UAAW;AAC5B,UAAM,WAAW,OAAQ,KAAM,EAAE,MAAM;AACvC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,CAAE;AAAA,EAC3B,CAAE;AAEF,SAAO;AACR;AASO,SAAS,0BAA2B,UAAW;AACrD,SAAO,GAAI,QAAS;AACrB;AAUO,SAAS,qBAAsB,UAAU,IAAK;AACpD,SAAO,GAAI,QAAS,gBAAiB,EAAG;AACzC;AAUO,SAAS,iBAAkB,IAAI,QAAS;AAC9C,QAAM,SAAS,oBAAqB,MAAO;AAC3C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAYS,EAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAQsB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO/D;",
6
- "names": []
7
- }
@@ -1,90 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { colord } from 'colord';
5
-
6
- /**
7
- * Convert a list of colors to an object of R, G, and B values.
8
- *
9
- * @param {string[]} colors Array of RBG color strings.
10
- *
11
- * @return {Object} R, G, and B values.
12
- */
13
- export function getValuesFromColors( colors = [] ) {
14
- const values = { r: [], g: [], b: [], a: [] };
15
-
16
- colors.forEach( ( color ) => {
17
- const rgbColor = colord( color ).toRgb();
18
- values.r.push( rgbColor.r / 255 );
19
- values.g.push( rgbColor.g / 255 );
20
- values.b.push( rgbColor.b / 255 );
21
- values.a.push( rgbColor.a );
22
- } );
23
-
24
- return values;
25
- }
26
-
27
- /**
28
- * Stylesheet for disabling a global styles duotone filter.
29
- *
30
- * @param {string} selector Selector to disable the filter for.
31
- *
32
- * @return {string} Filter none style.
33
- */
34
- export function getDuotoneUnsetStylesheet( selector ) {
35
- return `${ selector }{filter:none}`;
36
- }
37
-
38
- /**
39
- * SVG and stylesheet needed for rendering the duotone filter.
40
- *
41
- * @param {string} selector Selector to apply the filter to.
42
- * @param {string} id Unique id for this duotone filter.
43
- *
44
- * @return {string} Duotone filter style.
45
- */
46
- export function getDuotoneStylesheet( selector, id ) {
47
- return `${ selector }{filter:url(#${ id })}`;
48
- }
49
-
50
- /**
51
- * The SVG part of the duotone filter.
52
- *
53
- * @param {string} id Unique id for this duotone filter.
54
- * @param {string[]} colors Color strings from dark to light.
55
- *
56
- * @return {string} Duotone SVG.
57
- */
58
- export function getDuotoneFilter( id, colors ) {
59
- const values = getValuesFromColors( colors );
60
- return `
61
- <svg
62
- xmlns:xlink="http://www.w3.org/1999/xlink"
63
- viewBox="0 0 0 0"
64
- width="0"
65
- height="0"
66
- focusable="false"
67
- role="none"
68
- aria-hidden="true"
69
- style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
70
- >
71
- <defs>
72
- <filter id="${ id }">
73
- <!--
74
- Use sRGB instead of linearRGB so transparency looks correct.
75
- Use perceptual brightness to convert to grayscale.
76
- -->
77
- <feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>
78
- <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
79
- <feComponentTransfer color-interpolation-filters="sRGB">
80
- <feFuncR type="table" tableValues="${ values.r.join( ' ' ) }"></feFuncR>
81
- <feFuncG type="table" tableValues="${ values.g.join( ' ' ) }"></feFuncG>
82
- <feFuncB type="table" tableValues="${ values.b.join( ' ' ) }"></feFuncB>
83
- <feFuncA type="table" tableValues="${ values.a.join( ' ' ) }"></feFuncA>
84
- </feComponentTransfer>
85
- <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
86
- <feComposite in2="SourceGraphic" operator="in"></feComposite>
87
- </filter>
88
- </defs>
89
- </svg>`;
90
- }