@wordpress/block-editor 9.2.0 → 9.5.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 (693) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -8
  3. package/build/autocompleters/block.js +3 -1
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/components/block-actions/index.js.map +1 -1
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-matrix-control/index.js +3 -7
  8. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  9. package/build/components/block-breadcrumb/index.js.map +1 -1
  10. package/build/components/block-content-overlay/index.js.map +1 -1
  11. package/build/components/block-context/index.js.map +1 -1
  12. package/build/components/block-controls/hook.js.map +1 -1
  13. package/build/components/block-draggable/index.js.map +1 -1
  14. package/build/components/block-draggable/index.native.js.map +1 -1
  15. package/build/components/block-list/block-invalid-warning.native.js +54 -6
  16. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  17. package/build/components/block-list/block-list-item.native.js.map +1 -1
  18. package/build/components/block-list/block-selection-button.native.js.map +1 -1
  19. package/build/components/block-list/block.js +2 -2
  20. package/build/components/block-list/block.js.map +1 -1
  21. package/build/components/block-list/block.native.js +2 -1
  22. package/build/components/block-list/block.native.js.map +1 -1
  23. package/build/components/block-list/index.js.map +1 -1
  24. package/build/components/block-list/index.native.js +4 -3
  25. package/build/components/block-list/index.native.js.map +1 -1
  26. package/build/components/block-list/layout.js +20 -5
  27. package/build/components/block-list/layout.js.map +1 -1
  28. package/build/components/block-list/use-block-props/index.js.map +1 -1
  29. package/build/components/block-list/use-block-props/use-block-class-names.js +5 -2
  30. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  31. package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
  32. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  33. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  34. package/build/components/block-list-appender/index.js.map +1 -1
  35. package/build/components/block-list-appender/index.native.js.map +1 -1
  36. package/build/components/block-lock/modal.js +35 -5
  37. package/build/components/block-lock/modal.js.map +1 -1
  38. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  39. package/build/components/block-mover/button.js.map +1 -1
  40. package/build/components/block-mover/index.native.js.map +1 -1
  41. package/build/components/block-parent-selector/index.js.map +1 -1
  42. package/build/components/block-pattern-setup/index.js +8 -26
  43. package/build/components/block-pattern-setup/index.js.map +1 -1
  44. package/build/components/block-pattern-setup/setup-toolbar.js +3 -8
  45. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  46. package/build/components/block-popover/inbetween.js +1 -1
  47. package/build/components/block-popover/inbetween.js.map +1 -1
  48. package/build/components/block-popover/index.js +1 -1
  49. package/build/components/block-popover/index.js.map +1 -1
  50. package/build/components/block-preview/auto.js +21 -5
  51. package/build/components/block-preview/auto.js.map +1 -1
  52. package/build/components/block-selection-clearer/index.js.map +1 -1
  53. package/build/components/block-settings-menu/block-edit-visually-button.js +70 -0
  54. package/build/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
  55. package/build/components/block-settings-menu/block-mode-toggle.js +4 -8
  56. package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  57. package/build/components/block-settings-menu/block-settings-dropdown.js +10 -4
  58. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  59. package/build/components/block-settings-menu/index.js +6 -2
  60. package/build/components/block-settings-menu/index.js.map +1 -1
  61. package/build/components/block-settings-menu-controls/index.js +4 -1
  62. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  63. package/build/components/block-styles/index.js +6 -3
  64. package/build/components/block-styles/index.js.map +1 -1
  65. package/build/components/block-styles/menu-items.js +3 -7
  66. package/build/components/block-styles/menu-items.js.map +1 -1
  67. package/build/components/block-styles/preview.native.js +3 -1
  68. package/build/components/block-styles/preview.native.js.map +1 -1
  69. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  70. package/build/components/block-switcher/index.js +7 -1
  71. package/build/components/block-switcher/index.js.map +1 -1
  72. package/build/components/block-title/index.js +8 -2
  73. package/build/components/block-title/index.js.map +1 -1
  74. package/build/components/block-title/use-block-display-title.js +15 -15
  75. package/build/components/block-title/use-block-display-title.js.map +1 -1
  76. package/build/components/block-toolbar/index.native.js.map +1 -1
  77. package/build/components/block-toolbar/utils.js +5 -8
  78. package/build/components/block-toolbar/utils.js.map +1 -1
  79. package/build/components/block-tools/block-contextual-toolbar.js +1 -1
  80. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  81. package/build/components/block-tools/index.js.map +1 -1
  82. package/build/components/block-types-list/index.native.js.map +1 -1
  83. package/build/components/block-variation-transforms/index.js.map +1 -1
  84. package/build/components/border-radius-control/index.js +2 -0
  85. package/build/components/border-radius-control/index.js.map +1 -1
  86. package/build/components/color-style-selector/index.js.map +1 -1
  87. package/build/components/colors/with-colors.js +1 -1
  88. package/build/components/colors/with-colors.js.map +1 -1
  89. package/build/components/colors-gradients/control.js +45 -39
  90. package/build/components/colors-gradients/control.js.map +1 -1
  91. package/build/components/colors-gradients/dropdown.js +2 -1
  92. package/build/components/colors-gradients/dropdown.js.map +1 -1
  93. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
  94. package/build/components/copy-handler/index.js +17 -1
  95. package/build/components/copy-handler/index.js.map +1 -1
  96. package/build/components/date-format-picker/index.js +1 -1
  97. package/build/components/date-format-picker/index.js.map +1 -1
  98. package/build/components/default-block-appender/index.js.map +1 -1
  99. package/build/components/default-block-appender/index.native.js.map +1 -1
  100. package/build/components/default-style-picker/index.js.map +1 -1
  101. package/build/components/duotone/components.js +145 -0
  102. package/build/components/duotone/components.js.map +1 -0
  103. package/build/components/duotone/index.js +40 -0
  104. package/build/components/duotone/index.js.map +1 -0
  105. package/build/components/duotone/utils.js +38 -0
  106. package/build/components/duotone/utils.js.map +1 -0
  107. package/build/components/duotone-control/index.js +17 -5
  108. package/build/components/duotone-control/index.js.map +1 -1
  109. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  110. package/build/components/iframe/index.js +19 -6
  111. package/build/components/iframe/index.js.map +1 -1
  112. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  113. package/build/components/image-size-control/index.js +3 -1
  114. package/build/components/image-size-control/index.js.map +1 -1
  115. package/build/components/index.js +32 -0
  116. package/build/components/index.js.map +1 -1
  117. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  118. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  119. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  120. package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  121. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  122. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  123. package/build/components/inserter/index.js +3 -3
  124. package/build/components/inserter/index.js.map +1 -1
  125. package/build/components/inserter/index.native.js.map +1 -1
  126. package/build/components/inserter/library.js +3 -7
  127. package/build/components/inserter/library.js.map +1 -1
  128. package/build/components/inserter/menu.js.map +1 -1
  129. package/build/components/inserter/menu.native.js.map +1 -1
  130. package/build/components/inserter/no-results.native.js.map +1 -1
  131. package/build/components/inserter/quick-inserter.js.map +1 -1
  132. package/build/components/inserter/search-items.js +1 -1
  133. package/build/components/inserter/search-items.js.map +1 -1
  134. package/build/components/inserter/search-results.native.js.map +1 -1
  135. package/build/components/inspector-popover-header/index.js +56 -0
  136. package/build/components/inspector-popover-header/index.js.map +1 -0
  137. package/build/components/line-height-control/index.js.map +1 -1
  138. package/build/components/link-control/index.js +5 -5
  139. package/build/components/link-control/index.js.map +1 -1
  140. package/build/components/link-control/search-create-button.js +1 -3
  141. package/build/components/link-control/search-create-button.js.map +1 -1
  142. package/build/components/link-control/search-input.js +5 -3
  143. package/build/components/link-control/search-input.js.map +1 -1
  144. package/build/components/link-control/settings-drawer.js +3 -7
  145. package/build/components/link-control/settings-drawer.js.map +1 -1
  146. package/build/components/link-control/use-search-handler.js.map +1 -1
  147. package/build/components/list-view/block-contents.js.map +1 -1
  148. package/build/components/list-view/block-select-button.js +15 -7
  149. package/build/components/list-view/block-select-button.js.map +1 -1
  150. package/build/components/list-view/branch.js.map +1 -1
  151. package/build/components/list-view/drop-indicator.js +1 -1
  152. package/build/components/list-view/drop-indicator.js.map +1 -1
  153. package/build/components/list-view/index.js.map +1 -1
  154. package/build/components/list-view/use-block-selection.js.map +1 -1
  155. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  156. package/build/components/list-view/utils.js +1 -7
  157. package/build/components/list-view/utils.js.map +1 -1
  158. package/build/components/media-placeholder/index.js +18 -6
  159. package/build/components/media-placeholder/index.js.map +1 -1
  160. package/build/components/media-placeholder/index.native.js +4 -4
  161. package/build/components/media-placeholder/index.native.js.map +1 -1
  162. package/build/components/media-replace-flow/index.js +25 -17
  163. package/build/components/media-replace-flow/index.js.map +1 -1
  164. package/build/components/media-upload/index.native.js +1 -1
  165. package/build/components/media-upload/index.native.js.map +1 -1
  166. package/build/components/navigable-toolbar/index.js.map +1 -1
  167. package/build/components/plain-text/index.native.js.map +1 -1
  168. package/build/components/preview-options/index.js +4 -0
  169. package/build/components/preview-options/index.js.map +1 -1
  170. package/build/components/provider/use-block-sync.js +5 -3
  171. package/build/components/provider/use-block-sync.js.map +1 -1
  172. package/build/components/publish-date-time-picker/index.js +17 -16
  173. package/build/components/publish-date-time-picker/index.js.map +1 -1
  174. package/build/components/rich-text/embed-handler-picker.native.js +4 -8
  175. package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
  176. package/build/components/rich-text/index.js.map +1 -1
  177. package/build/components/rich-text/use-format-types.js.map +1 -1
  178. package/build/components/rich-text/use-input-rules.js +4 -13
  179. package/build/components/rich-text/use-input-rules.js.map +1 -1
  180. package/build/components/rich-text/use-mark-persistent.js.map +1 -1
  181. package/build/components/rich-text/use-paste-handler.js +20 -5
  182. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  183. package/build/components/skip-to-selected-block/index.js.map +1 -1
  184. package/build/components/ungroup-button/index.native.js +3 -7
  185. package/build/components/ungroup-button/index.native.js.map +1 -1
  186. package/build/components/url-input/index.js +14 -3
  187. package/build/components/url-input/index.js.map +1 -1
  188. package/build/components/url-popover/index.js +2 -1
  189. package/build/components/url-popover/index.js.map +1 -1
  190. package/build/components/use-block-display-information/index.js.map +1 -1
  191. package/build/components/use-block-drop-zone/index.js.map +1 -1
  192. package/build/components/use-block-drop-zone/index.native.js.map +1 -1
  193. package/build/components/use-display-block-controls/index.native.js.map +1 -1
  194. package/build/components/use-on-block-drop/index.js.map +1 -1
  195. package/build/components/use-on-block-drop/index.native.js.map +1 -1
  196. package/build/components/use-setting/index.js.map +1 -1
  197. package/build/components/writing-flow/use-arrow-nav.js +46 -14
  198. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  199. package/build/components/writing-flow/use-click-selection.js.map +1 -1
  200. package/build/components/writing-flow/use-drag-selection.js.map +1 -1
  201. package/build/components/writing-flow/use-multi-selection.js +3 -47
  202. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  203. package/build/components/writing-flow/use-select-all.js.map +1 -1
  204. package/build/components/writing-flow/use-selection-observer.js +1 -3
  205. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  206. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  207. package/build/elements/index.js +11 -3
  208. package/build/elements/index.js.map +1 -1
  209. package/build/hooks/aria-label.js +71 -0
  210. package/build/hooks/aria-label.js.map +1 -0
  211. package/build/hooks/color-panel.js.map +1 -1
  212. package/build/hooks/color-panel.native.js.map +1 -1
  213. package/build/hooks/color.js +2 -4
  214. package/build/hooks/color.js.map +1 -1
  215. package/build/hooks/duotone.js +33 -160
  216. package/build/hooks/duotone.js.map +1 -1
  217. package/build/hooks/font-family.js.map +1 -1
  218. package/build/hooks/gap.js.map +1 -1
  219. package/build/hooks/index.js +11 -7
  220. package/build/hooks/index.js.map +1 -1
  221. package/build/hooks/layout.js +74 -8
  222. package/build/hooks/layout.js.map +1 -1
  223. package/build/hooks/utils.js +5 -3
  224. package/build/hooks/utils.js.map +1 -1
  225. package/build/index.js +7 -7
  226. package/build/index.js.map +1 -1
  227. package/build/layouts/flex.js +42 -38
  228. package/build/layouts/flex.js.map +1 -1
  229. package/build/layouts/flow.js +10 -35
  230. package/build/layouts/flow.js.map +1 -1
  231. package/build/layouts/utils.js +35 -3
  232. package/build/layouts/utils.js.map +1 -1
  233. package/build/store/actions.js +24 -31
  234. package/build/store/actions.js.map +1 -1
  235. package/build/store/index.js +0 -4
  236. package/build/store/index.js.map +1 -1
  237. package/build/store/reducer.js +23 -12
  238. package/build/store/reducer.js.map +1 -1
  239. package/build/store/selectors.js +4 -4
  240. package/build/store/selectors.js.map +1 -1
  241. package/build/utils/pasting.js.map +1 -1
  242. package/build/utils/selection.js +34 -0
  243. package/build/utils/selection.js.map +1 -0
  244. package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
  245. package/build-module/autocompleters/block.js +4 -1
  246. package/build-module/autocompleters/block.js.map +1 -1
  247. package/build-module/components/block-actions/index.js.map +1 -1
  248. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  249. package/build-module/components/block-alignment-matrix-control/index.js +2 -5
  250. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  251. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  252. package/build-module/components/block-content-overlay/index.js.map +1 -1
  253. package/build-module/components/block-context/index.js.map +1 -1
  254. package/build-module/components/block-controls/hook.js.map +1 -1
  255. package/build-module/components/block-draggable/index.js.map +1 -1
  256. package/build-module/components/block-draggable/index.native.js.map +1 -1
  257. package/build-module/components/block-list/block-invalid-warning.native.js +50 -6
  258. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  259. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  260. package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
  261. package/build-module/components/block-list/block.js +2 -2
  262. package/build-module/components/block-list/block.js.map +1 -1
  263. package/build-module/components/block-list/block.native.js +2 -1
  264. package/build-module/components/block-list/block.native.js.map +1 -1
  265. package/build-module/components/block-list/index.js.map +1 -1
  266. package/build-module/components/block-list/index.native.js +3 -1
  267. package/build-module/components/block-list/index.native.js.map +1 -1
  268. package/build-module/components/block-list/layout.js +19 -4
  269. package/build-module/components/block-list/layout.js.map +1 -1
  270. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  271. package/build-module/components/block-list/use-block-props/use-block-class-names.js +5 -2
  272. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  273. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
  274. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  275. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  276. package/build-module/components/block-list-appender/index.js.map +1 -1
  277. package/build-module/components/block-list-appender/index.native.js.map +1 -1
  278. package/build-module/components/block-lock/modal.js +37 -6
  279. package/build-module/components/block-lock/modal.js.map +1 -1
  280. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  281. package/build-module/components/block-mover/button.js.map +1 -1
  282. package/build-module/components/block-mover/index.native.js.map +1 -1
  283. package/build-module/components/block-parent-selector/index.js.map +1 -1
  284. package/build-module/components/block-pattern-setup/index.js +9 -27
  285. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  286. package/build-module/components/block-pattern-setup/setup-toolbar.js +3 -8
  287. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  288. package/build-module/components/block-popover/inbetween.js +1 -1
  289. package/build-module/components/block-popover/inbetween.js.map +1 -1
  290. package/build-module/components/block-popover/index.js +1 -1
  291. package/build-module/components/block-popover/index.js.map +1 -1
  292. package/build-module/components/block-preview/auto.js +20 -5
  293. package/build-module/components/block-preview/auto.js.map +1 -1
  294. package/build-module/components/block-selection-clearer/index.js.map +1 -1
  295. package/build-module/components/block-settings-menu/block-edit-visually-button.js +56 -0
  296. package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
  297. package/build-module/components/block-settings-menu/block-mode-toggle.js +4 -6
  298. package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  299. package/build-module/components/block-settings-menu/block-settings-dropdown.js +10 -3
  300. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  301. package/build-module/components/block-settings-menu/index.js +6 -3
  302. package/build-module/components/block-settings-menu/index.js.map +1 -1
  303. package/build-module/components/block-settings-menu-controls/index.js +5 -2
  304. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  305. package/build-module/components/block-styles/index.js +5 -2
  306. package/build-module/components/block-styles/index.js.map +1 -1
  307. package/build-module/components/block-styles/menu-items.js +3 -5
  308. package/build-module/components/block-styles/menu-items.js.map +1 -1
  309. package/build-module/components/block-styles/preview.native.js +3 -2
  310. package/build-module/components/block-styles/preview.native.js.map +1 -1
  311. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  312. package/build-module/components/block-switcher/index.js +7 -1
  313. package/build-module/components/block-switcher/index.js.map +1 -1
  314. package/build-module/components/block-title/index.js +8 -2
  315. package/build-module/components/block-title/index.js.map +1 -1
  316. package/build-module/components/block-title/use-block-display-title.js +15 -14
  317. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  318. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  319. package/build-module/components/block-toolbar/utils.js +3 -5
  320. package/build-module/components/block-toolbar/utils.js.map +1 -1
  321. package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
  322. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  323. package/build-module/components/block-tools/index.js.map +1 -1
  324. package/build-module/components/block-types-list/index.native.js.map +1 -1
  325. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  326. package/build-module/components/border-radius-control/index.js +2 -0
  327. package/build-module/components/border-radius-control/index.js.map +1 -1
  328. package/build-module/components/color-style-selector/index.js.map +1 -1
  329. package/build-module/components/colors/with-colors.js +2 -2
  330. package/build-module/components/colors/with-colors.js.map +1 -1
  331. package/build-module/components/colors-gradients/control.js +46 -40
  332. package/build-module/components/colors-gradients/control.js.map +1 -1
  333. package/build-module/components/colors-gradients/dropdown.js +2 -1
  334. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  335. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
  336. package/build-module/components/copy-handler/index.js +18 -2
  337. package/build-module/components/copy-handler/index.js.map +1 -1
  338. package/build-module/components/date-format-picker/index.js +1 -1
  339. package/build-module/components/date-format-picker/index.js.map +1 -1
  340. package/build-module/components/default-block-appender/index.js.map +1 -1
  341. package/build-module/components/default-block-appender/index.native.js.map +1 -1
  342. package/build-module/components/default-style-picker/index.js.map +1 -1
  343. package/build-module/components/duotone/components.js +130 -0
  344. package/build-module/components/duotone/components.js.map +1 -0
  345. package/build-module/components/duotone/index.js +3 -0
  346. package/build-module/components/duotone/index.js.map +1 -0
  347. package/build-module/components/duotone/utils.js +30 -0
  348. package/build-module/components/duotone/utils.js.map +1 -0
  349. package/build-module/components/duotone-control/index.js +18 -6
  350. package/build-module/components/duotone-control/index.js.map +1 -1
  351. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  352. package/build-module/components/iframe/index.js +19 -6
  353. package/build-module/components/iframe/index.js.map +1 -1
  354. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  355. package/build-module/components/image-size-control/index.js +4 -1
  356. package/build-module/components/image-size-control/index.js.map +1 -1
  357. package/build-module/components/index.js +3 -0
  358. package/build-module/components/index.js.map +1 -1
  359. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  360. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  361. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  362. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  363. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  364. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  365. package/build-module/components/inserter/index.js +3 -2
  366. package/build-module/components/inserter/index.js.map +1 -1
  367. package/build-module/components/inserter/index.native.js.map +1 -1
  368. package/build-module/components/inserter/library.js +2 -5
  369. package/build-module/components/inserter/library.js.map +1 -1
  370. package/build-module/components/inserter/menu.js.map +1 -1
  371. package/build-module/components/inserter/menu.native.js.map +1 -1
  372. package/build-module/components/inserter/no-results.native.js.map +1 -1
  373. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  374. package/build-module/components/inserter/search-items.js +2 -2
  375. package/build-module/components/inserter/search-items.js.map +1 -1
  376. package/build-module/components/inserter/search-results.native.js.map +1 -1
  377. package/build-module/components/inspector-popover-header/index.js +46 -0
  378. package/build-module/components/inspector-popover-header/index.js.map +1 -0
  379. package/build-module/components/line-height-control/index.js.map +1 -1
  380. package/build-module/components/link-control/index.js +3 -2
  381. package/build-module/components/link-control/index.js.map +1 -1
  382. package/build-module/components/link-control/search-create-button.js +1 -2
  383. package/build-module/components/link-control/search-create-button.js.map +1 -1
  384. package/build-module/components/link-control/search-input.js +3 -1
  385. package/build-module/components/link-control/search-input.js.map +1 -1
  386. package/build-module/components/link-control/settings-drawer.js +2 -5
  387. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  388. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  389. package/build-module/components/list-view/block-contents.js.map +1 -1
  390. package/build-module/components/list-view/block-select-button.js +16 -8
  391. package/build-module/components/list-view/block-select-button.js.map +1 -1
  392. package/build-module/components/list-view/branch.js.map +1 -1
  393. package/build-module/components/list-view/drop-indicator.js +1 -1
  394. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  395. package/build-module/components/list-view/index.js.map +1 -1
  396. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  397. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  398. package/build-module/components/list-view/utils.js +1 -6
  399. package/build-module/components/list-view/utils.js.map +1 -1
  400. package/build-module/components/media-placeholder/index.js +16 -3
  401. package/build-module/components/media-placeholder/index.js.map +1 -1
  402. package/build-module/components/media-placeholder/index.native.js +5 -3
  403. package/build-module/components/media-placeholder/index.native.js.map +1 -1
  404. package/build-module/components/media-replace-flow/index.js +27 -18
  405. package/build-module/components/media-replace-flow/index.js.map +1 -1
  406. package/build-module/components/media-upload/index.native.js +1 -1
  407. package/build-module/components/media-upload/index.native.js.map +1 -1
  408. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  409. package/build-module/components/plain-text/index.native.js.map +1 -1
  410. package/build-module/components/preview-options/index.js +4 -0
  411. package/build-module/components/preview-options/index.js.map +1 -1
  412. package/build-module/components/provider/use-block-sync.js +4 -1
  413. package/build-module/components/provider/use-block-sync.js.map +1 -1
  414. package/build-module/components/publish-date-time-picker/index.js +16 -16
  415. package/build-module/components/publish-date-time-picker/index.js.map +1 -1
  416. package/build-module/components/rich-text/embed-handler-picker.native.js +3 -5
  417. package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
  418. package/build-module/components/rich-text/index.js.map +1 -1
  419. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  420. package/build-module/components/rich-text/use-input-rules.js +3 -11
  421. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  422. package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
  423. package/build-module/components/rich-text/use-paste-handler.js +20 -5
  424. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  425. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  426. package/build-module/components/ungroup-button/index.native.js +3 -5
  427. package/build-module/components/ungroup-button/index.native.js.map +1 -1
  428. package/build-module/components/url-input/index.js +11 -1
  429. package/build-module/components/url-input/index.js.map +1 -1
  430. package/build-module/components/url-popover/index.js +2 -1
  431. package/build-module/components/url-popover/index.js.map +1 -1
  432. package/build-module/components/use-block-display-information/index.js.map +1 -1
  433. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  434. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
  435. package/build-module/components/use-display-block-controls/index.native.js.map +1 -1
  436. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  437. package/build-module/components/use-on-block-drop/index.native.js.map +1 -1
  438. package/build-module/components/use-setting/index.js.map +1 -1
  439. package/build-module/components/writing-flow/use-arrow-nav.js +47 -14
  440. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  441. package/build-module/components/writing-flow/use-click-selection.js.map +1 -1
  442. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
  443. package/build-module/components/writing-flow/use-multi-selection.js +3 -45
  444. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  445. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  446. package/build-module/components/writing-flow/use-selection-observer.js +1 -3
  447. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  448. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  449. package/build-module/elements/index.js +7 -1
  450. package/build-module/elements/index.js.map +1 -1
  451. package/build-module/hooks/aria-label.js +59 -0
  452. package/build-module/hooks/aria-label.js.map +1 -0
  453. package/build-module/hooks/color-panel.js.map +1 -1
  454. package/build-module/hooks/color-panel.native.js.map +1 -1
  455. package/build-module/hooks/color.js +2 -3
  456. package/build-module/hooks/color.js.map +1 -1
  457. package/build-module/hooks/duotone.js +22 -140
  458. package/build-module/hooks/duotone.js.map +1 -1
  459. package/build-module/hooks/font-family.js.map +1 -1
  460. package/build-module/hooks/gap.js.map +1 -1
  461. package/build-module/hooks/index.js +2 -1
  462. package/build-module/hooks/index.js.map +1 -1
  463. package/build-module/hooks/layout.js +76 -10
  464. package/build-module/hooks/layout.js.map +1 -1
  465. package/build-module/hooks/utils.js +5 -2
  466. package/build-module/hooks/utils.js.map +1 -1
  467. package/build-module/index.js +1 -1
  468. package/build-module/index.js.map +1 -1
  469. package/build-module/layouts/flex.js +43 -35
  470. package/build-module/layouts/flex.js.map +1 -1
  471. package/build-module/layouts/flow.js +11 -36
  472. package/build-module/layouts/flow.js.map +1 -1
  473. package/build-module/layouts/utils.js +33 -3
  474. package/build-module/layouts/utils.js.map +1 -1
  475. package/build-module/store/actions.js +14 -20
  476. package/build-module/store/actions.js.map +1 -1
  477. package/build-module/store/index.js +0 -4
  478. package/build-module/store/index.js.map +1 -1
  479. package/build-module/store/reducer.js +23 -11
  480. package/build-module/store/reducer.js.map +1 -1
  481. package/build-module/store/selectors.js +5 -5
  482. package/build-module/store/selectors.js.map +1 -1
  483. package/build-module/utils/pasting.js.map +1 -1
  484. package/build-module/utils/selection.js +24 -0
  485. package/build-module/utils/selection.js.map +1 -0
  486. package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
  487. package/build-style/style-rtl.css +57 -34
  488. package/build-style/style.css +57 -34
  489. package/package.json +28 -28
  490. package/src/autocompleters/block.js +2 -1
  491. package/src/components/block-actions/index.js +2 -3
  492. package/src/components/block-alignment-control/ui.js +4 -6
  493. package/src/components/block-alignment-matrix-control/index.js +2 -4
  494. package/src/components/block-breadcrumb/index.js +2 -5
  495. package/src/components/block-compare/test/block-view.js +2 -1
  496. package/src/components/block-content-overlay/index.js +2 -5
  497. package/src/components/block-context/index.js +4 -4
  498. package/src/components/block-controls/hook.js +2 -3
  499. package/src/components/block-draggable/index.js +6 -13
  500. package/src/components/block-draggable/index.native.js +6 -14
  501. package/src/components/block-draggable/test/helpers.native.js +3 -3
  502. package/src/components/block-draggable/test/index.native.js +12 -15
  503. package/src/components/block-edit/test/edit.js +2 -1
  504. package/src/components/block-list/block-invalid-warning.native.js +42 -7
  505. package/src/components/block-list/block-list-item.native.js +4 -12
  506. package/src/components/block-list/block-selection-button.native.js +2 -3
  507. package/src/components/block-list/block.js +10 -12
  508. package/src/components/block-list/block.native.js +11 -15
  509. package/src/components/block-list/index.js +2 -3
  510. package/src/components/block-list/index.native.js +13 -22
  511. package/src/components/block-list/layout.js +15 -3
  512. package/src/components/block-list/style.scss +2 -2
  513. package/src/components/block-list/test/block-list-context.native.js +8 -16
  514. package/src/components/block-list/use-block-props/index.js +6 -3
  515. package/src/components/block-list/use-block-props/use-block-class-names.js +5 -1
  516. package/src/components/block-list/use-block-props/use-block-custom-class-name.js +2 -3
  517. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +2 -3
  518. package/src/components/block-list/use-in-between-inserter.js +2 -3
  519. package/src/components/block-list-appender/index.js +2 -5
  520. package/src/components/block-list-appender/index.native.js +2 -3
  521. package/src/components/block-lock/modal.js +42 -4
  522. package/src/components/block-lock/style.scss +10 -0
  523. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +4 -6
  524. package/src/components/block-mover/button.js +2 -3
  525. package/src/components/block-mover/index.native.js +4 -6
  526. package/src/components/block-parent-selector/index.js +2 -3
  527. package/src/components/block-pattern-setup/index.js +5 -27
  528. package/src/components/block-pattern-setup/setup-toolbar.js +2 -9
  529. package/src/components/block-pattern-setup/style.scss +4 -2
  530. package/src/components/block-popover/inbetween.js +1 -1
  531. package/src/components/block-popover/index.js +1 -1
  532. package/src/components/block-preview/auto.js +21 -11
  533. package/src/components/block-selection-clearer/index.js +2 -3
  534. package/src/components/block-settings-menu/block-edit-visually-button.js +52 -0
  535. package/src/components/block-settings-menu/block-mode-toggle.js +5 -8
  536. package/src/components/block-settings-menu/block-settings-dropdown.js +13 -9
  537. package/src/components/block-settings-menu/index.js +15 -11
  538. package/src/components/block-settings-menu-controls/index.js +3 -2
  539. package/src/components/block-styles/index.js +3 -1
  540. package/src/components/block-styles/menu-items.js +2 -5
  541. package/src/components/block-styles/preview.native.js +3 -2
  542. package/src/components/block-switcher/block-transformations-menu.js +2 -4
  543. package/src/components/block-switcher/index.js +7 -1
  544. package/src/components/block-title/index.js +3 -2
  545. package/src/components/block-title/use-block-display-title.js +20 -12
  546. package/src/components/block-toolbar/index.native.js +2 -5
  547. package/src/components/block-toolbar/utils.js +3 -11
  548. package/src/components/block-tools/block-contextual-toolbar.js +5 -6
  549. package/src/components/block-tools/index.js +2 -3
  550. package/src/components/block-types-list/index.native.js +2 -4
  551. package/src/components/block-variation-transforms/index.js +4 -6
  552. package/src/components/border-radius-control/index.js +2 -0
  553. package/src/components/color-palette/test/control.js +2 -1
  554. package/src/components/color-style-selector/index.js +27 -28
  555. package/src/components/colors/test/with-colors.js +14 -14
  556. package/src/components/colors/with-colors.js +10 -14
  557. package/src/components/colors-gradients/control.js +77 -65
  558. package/src/components/colors-gradients/dropdown.js +22 -16
  559. package/src/components/colors-gradients/style.scss +4 -0
  560. package/src/components/colors-gradients/test/control.js +25 -32
  561. package/src/components/convert-to-group-buttons/toolbar.js +2 -6
  562. package/src/components/copy-handler/README.md +7 -2
  563. package/src/components/copy-handler/index.js +26 -6
  564. package/src/components/date-format-picker/index.js +1 -0
  565. package/src/components/default-block-appender/index.js +4 -6
  566. package/src/components/default-block-appender/index.native.js +4 -9
  567. package/src/components/default-style-picker/index.js +20 -21
  568. package/src/components/duotone/components.js +133 -0
  569. package/src/components/duotone/index.js +7 -0
  570. package/src/components/duotone/utils.js +25 -0
  571. package/src/components/duotone-control/index.js +12 -7
  572. package/src/components/duotone-control/style.scss +5 -0
  573. package/src/components/font-sizes/with-font-sizes.js +2 -3
  574. package/src/components/iframe/index.js +25 -6
  575. package/src/components/image-editor/aspect-ratio-dropdown.js +2 -6
  576. package/src/components/image-size-control/index.js +4 -7
  577. package/src/components/index.js +3 -0
  578. package/src/components/inner-blocks/use-inner-block-template-sync.js +2 -3
  579. package/src/components/inner-blocks/use-nested-settings-update.js +6 -9
  580. package/src/components/inserter/block-types-tab.native.js +2 -3
  581. package/src/components/inserter/hooks/use-block-type-impressions.native.js +2 -3
  582. package/src/components/inserter/hooks/use-insertion-point.js +3 -2
  583. package/src/components/inserter/hooks/use-patterns-state.js +4 -5
  584. package/src/components/inserter/index.js +7 -11
  585. package/src/components/inserter/index.native.js +6 -11
  586. package/src/components/inserter/library.js +2 -5
  587. package/src/components/inserter/menu.js +14 -19
  588. package/src/components/inserter/menu.native.js +8 -6
  589. package/src/components/inserter/no-results.native.js +2 -1
  590. package/src/components/inserter/quick-inserter.js +2 -3
  591. package/src/components/inserter/search-items.js +6 -6
  592. package/src/components/inserter/search-results.native.js +4 -6
  593. package/src/components/inserter/style.scss +1 -1
  594. package/src/components/inspector-popover-header/README.md +76 -0
  595. package/src/components/inspector-popover-header/index.js +56 -0
  596. package/src/components/inspector-popover-header/style.scss +16 -0
  597. package/src/components/line-height-control/index.js +1 -2
  598. package/src/components/link-control/index.js +5 -4
  599. package/src/components/link-control/search-create-button.js +4 -2
  600. package/src/components/link-control/search-input.js +3 -1
  601. package/src/components/link-control/settings-drawer.js +2 -5
  602. package/src/components/link-control/test/fixtures/index.js +5 -7
  603. package/src/components/link-control/test/index.js +85 -106
  604. package/src/components/link-control/use-search-handler.js +2 -2
  605. package/src/components/list-view/block-contents.js +2 -4
  606. package/src/components/list-view/block-select-button.js +29 -14
  607. package/src/components/list-view/branch.js +22 -23
  608. package/src/components/list-view/drop-indicator.js +1 -1
  609. package/src/components/list-view/index.js +4 -8
  610. package/src/components/list-view/style.scss +18 -4
  611. package/src/components/list-view/use-block-selection.js +5 -5
  612. package/src/components/list-view/use-list-view-drop-zone.js +2 -1
  613. package/src/components/list-view/utils.js +1 -6
  614. package/src/components/media-placeholder/index.js +22 -1
  615. package/src/components/media-placeholder/index.native.js +9 -5
  616. package/src/components/media-replace-flow/index.js +78 -56
  617. package/src/components/media-replace-flow/test/index.js +14 -4
  618. package/src/components/media-upload/README.md +8 -0
  619. package/src/components/media-upload/index.native.js +1 -1
  620. package/src/components/navigable-toolbar/index.js +1 -2
  621. package/src/components/panel-color-settings/test/index.js +2 -1
  622. package/src/components/plain-text/index.native.js +2 -6
  623. package/src/components/preview-options/index.js +4 -0
  624. package/src/components/provider/use-block-sync.js +5 -2
  625. package/src/components/publish-date-time-picker/README.md +1 -1
  626. package/src/components/publish-date-time-picker/index.js +18 -27
  627. package/src/components/responsive-block-control/README.md +3 -1
  628. package/src/components/responsive-block-control/test/index.js +4 -4
  629. package/src/components/rich-text/embed-handler-picker.native.js +2 -5
  630. package/src/components/rich-text/index.js +7 -4
  631. package/src/components/rich-text/use-format-types.js +16 -16
  632. package/src/components/rich-text/use-input-rules.js +6 -15
  633. package/src/components/rich-text/use-mark-persistent.js +2 -3
  634. package/src/components/rich-text/use-paste-handler.js +17 -5
  635. package/src/components/skip-to-selected-block/index.js +2 -3
  636. package/src/components/ungroup-button/index.native.js +4 -8
  637. package/src/components/url-input/index.js +21 -20
  638. package/src/components/url-popover/index.js +1 -0
  639. package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -0
  640. package/src/components/use-block-display-information/index.js +4 -6
  641. package/src/components/use-block-drop-zone/index.js +2 -3
  642. package/src/components/use-block-drop-zone/index.native.js +2 -4
  643. package/src/components/use-block-drop-zone/test/index.js +22 -23
  644. package/src/components/use-display-block-controls/index.native.js +2 -3
  645. package/src/components/use-no-recursive-renders/test/use-no-recursive-renders.js +2 -3
  646. package/src/components/use-on-block-drop/index.js +2 -5
  647. package/src/components/use-on-block-drop/index.native.js +4 -8
  648. package/src/components/use-setting/index.js +8 -6
  649. package/src/components/writing-flow/test/index.js +22 -4
  650. package/src/components/writing-flow/use-arrow-nav.js +54 -11
  651. package/src/components/writing-flow/use-click-selection.js +2 -5
  652. package/src/components/writing-flow/use-drag-selection.js +6 -9
  653. package/src/components/writing-flow/use-multi-selection.js +1 -50
  654. package/src/components/writing-flow/use-select-all.js +2 -5
  655. package/src/components/writing-flow/use-selection-observer.js +6 -9
  656. package/src/components/writing-flow/use-tab-nav.js +2 -5
  657. package/src/elements/index.js +8 -1
  658. package/src/elements/test/index.js +18 -0
  659. package/src/hooks/aria-label.js +67 -0
  660. package/src/hooks/color-panel.js +4 -4
  661. package/src/hooks/color-panel.native.js +2 -2
  662. package/src/hooks/color.js +12 -5
  663. package/src/hooks/duotone.js +18 -139
  664. package/src/hooks/font-family.js +4 -2
  665. package/src/hooks/gap.js +2 -3
  666. package/src/hooks/index.js +2 -1
  667. package/src/hooks/layout.js +102 -15
  668. package/src/hooks/test/align.js +2 -1
  669. package/src/hooks/test/generated-class-name.js +2 -5
  670. package/src/hooks/test/utils.js +2 -5
  671. package/src/hooks/utils.js +7 -3
  672. package/src/index.js +1 -1
  673. package/src/layouts/flex.js +49 -43
  674. package/src/layouts/flow.js +14 -35
  675. package/src/layouts/test/flex.js +21 -0
  676. package/src/layouts/test/flow.js +21 -0
  677. package/src/layouts/test/utils.js +138 -0
  678. package/src/layouts/utils.js +44 -3
  679. package/src/store/actions.js +763 -733
  680. package/src/store/index.js +0 -4
  681. package/src/store/reducer.js +208 -184
  682. package/src/store/selectors.js +57 -58
  683. package/src/store/test/actions.js +2 -1
  684. package/src/store/test/reducer.js +140 -10
  685. package/src/store/test/selectors.js +20 -27
  686. package/src/style.scss +1 -1
  687. package/src/utils/pasting.js +3 -3
  688. package/src/utils/selection.js +26 -0
  689. package/src/utils/test/selection.js +39 -0
  690. package/src/utils/transform-styles/transforms/wrap.js +30 -28
  691. package/tsconfig.json +2 -1
  692. package/tsconfig.tsbuildinfo +1 -1
  693. package/src/components/publish-date-time-picker/style.scss +0 -20
@@ -2,12 +2,6 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.PresetDuotoneFilter = PresetDuotoneFilter;
9
- exports.getValuesFromColors = getValuesFromColors;
10
-
11
5
  var _element = require("@wordpress/element");
12
6
 
13
7
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
@@ -20,16 +14,16 @@ var _names = _interopRequireDefault(require("colord/plugins/names"));
20
14
 
21
15
  var _blocks = require("@wordpress/blocks");
22
16
 
23
- var _components = require("@wordpress/components");
24
-
25
17
  var _compose = require("@wordpress/compose");
26
18
 
27
19
  var _hooks = require("@wordpress/hooks");
28
20
 
29
- var _components2 = require("../components");
21
+ var _components = require("../components");
30
22
 
31
23
  var _blockList = _interopRequireDefault(require("../components/block-list"));
32
24
 
25
+ var _duotone = require("../components/duotone");
26
+
33
27
  /**
34
28
  * External dependencies
35
29
  */
@@ -44,167 +38,57 @@ var _blockList = _interopRequireDefault(require("../components/block-list"));
44
38
  const EMPTY_ARRAY = [];
45
39
  (0, _colord.extend)([_names.default]);
46
40
  /**
47
- * Convert a list of colors to an object of R, G, and B values.
48
- *
49
- * @param {string[]} colors Array of RBG color strings.
50
- *
51
- * @return {Object} R, G, and B values.
52
- */
53
-
54
- function getValuesFromColors() {
55
- let colors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
56
- const values = {
57
- r: [],
58
- g: [],
59
- b: [],
60
- a: []
61
- };
62
- colors.forEach(color => {
63
- const rgbColor = (0, _colord.colord)(color).toRgb();
64
- values.r.push(rgbColor.r / 255);
65
- values.g.push(rgbColor.g / 255);
66
- values.b.push(rgbColor.b / 255);
67
- values.a.push(rgbColor.a);
68
- });
69
- return values;
70
- }
71
- /**
72
- * Values for the SVG `feComponentTransfer`.
73
- *
74
- * @typedef Values {Object}
75
- * @property {number[]} r Red values.
76
- * @property {number[]} g Green values.
77
- * @property {number[]} b Blue values.
78
- * @property {number[]} a Alpha values.
79
- */
80
-
81
- /**
82
- * Stylesheet for rendering the duotone filter.
41
+ * SVG and stylesheet needed for rendering the duotone filter.
83
42
  *
84
- * @param {Object} props Duotone props.
43
+ * @param {Object} props Duotone props.
85
44
  * @param {string} props.selector Selector to apply the filter to.
86
- * @param {string} props.id Unique id for this duotone filter.
45
+ * @param {string} props.id Unique id for this duotone filter.
46
+ * @param {string[]|"unset"} props.colors Array of RGB color strings ordered from dark to light.
87
47
  *
88
48
  * @return {WPElement} Duotone element.
89
49
  */
90
50
 
91
-
92
- function DuotoneStylesheet(_ref) {
51
+ function InlineDuotone(_ref) {
93
52
  let {
94
53
  selector,
95
- id
96
- } = _ref;
97
- const css = `
98
- ${selector} {
99
- filter: url( #${id} );
100
- }
101
- `;
102
- return (0, _element.createElement)("style", null, css);
103
- }
104
- /**
105
- * SVG for rendering the duotone filter.
106
- *
107
- * @param {Object} props Duotone props.
108
- * @param {string} props.id Unique id for this duotone filter.
109
- * @param {Values} props.values R, G, B, and A values to filter with.
110
- *
111
- * @return {WPElement} Duotone element.
112
- */
113
-
114
-
115
- function DuotoneFilter(_ref2) {
116
- let {
117
54
  id,
118
- values
119
- } = _ref2;
120
- return (0, _element.createElement)(_components.SVG, {
121
- xmlnsXlink: "http://www.w3.org/1999/xlink",
122
- viewBox: "0 0 0 0",
123
- width: "0",
124
- height: "0",
125
- focusable: "false",
126
- role: "none",
127
- style: {
128
- visibility: 'hidden',
129
- position: 'absolute',
130
- left: '-9999px',
131
- overflow: 'hidden'
132
- }
133
- }, (0, _element.createElement)("defs", null, (0, _element.createElement)("filter", {
134
- id: id
135
- }, (0, _element.createElement)("feColorMatrix", {
136
- // Use sRGB instead of linearRGB so transparency looks correct.
137
- colorInterpolationFilters: "sRGB",
138
- type: "matrix" // Use perceptual brightness to convert to grayscale.
139
- ,
140
- values: " .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "
141
- }), (0, _element.createElement)("feComponentTransfer", {
142
- // Use sRGB instead of linearRGB to be consistent with how CSS gradients work.
143
- colorInterpolationFilters: "sRGB"
144
- }, (0, _element.createElement)("feFuncR", {
145
- type: "table",
146
- tableValues: values.r.join(' ')
147
- }), (0, _element.createElement)("feFuncG", {
148
- type: "table",
149
- tableValues: values.g.join(' ')
150
- }), (0, _element.createElement)("feFuncB", {
151
- type: "table",
152
- tableValues: values.b.join(' ')
153
- }), (0, _element.createElement)("feFuncA", {
154
- type: "table",
155
- tableValues: values.a.join(' ')
156
- })), (0, _element.createElement)("feComposite", {
157
- // Re-mask the image with the original transparency since the feColorMatrix above loses that information.
158
- in2: "SourceGraphic",
159
- operator: "in"
160
- }))));
161
- }
162
- /**
163
- * SVG and stylesheet needed for rendering the duotone filter.
164
- *
165
- * @param {Object} props Duotone props.
166
- * @param {string} props.selector Selector to apply the filter to.
167
- * @param {string} props.id Unique id for this duotone filter.
168
- * @param {Values} props.values R, G, B, and A values to filter with.
169
- *
170
- * @return {WPElement} Duotone element.
171
- */
55
+ colors
56
+ } = _ref;
172
57
 
58
+ if (colors === 'unset') {
59
+ return (0, _element.createElement)(_duotone.__unstableDuotoneUnsetStylesheet, {
60
+ selector: selector
61
+ });
62
+ }
173
63
 
174
- function InlineDuotone(_ref3) {
175
- let {
176
- selector,
177
- id,
178
- values
179
- } = _ref3;
180
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(DuotoneFilter, {
64
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_duotone.__unstableDuotoneFilter, {
181
65
  id: id,
182
- values: values
183
- }), (0, _element.createElement)(DuotoneStylesheet, {
66
+ colors: colors
67
+ }), (0, _element.createElement)(_duotone.__unstableDuotoneStylesheet, {
184
68
  id: id,
185
69
  selector: selector
186
70
  }));
187
71
  }
188
72
 
189
- function useMultiOriginPresets(_ref4) {
73
+ function useMultiOriginPresets(_ref2) {
190
74
  let {
191
75
  presetSetting,
192
76
  defaultSetting
193
- } = _ref4;
194
- const disableDefault = !(0, _components2.useSetting)(defaultSetting);
195
- const userPresets = (0, _components2.useSetting)(`${presetSetting}.custom`) || EMPTY_ARRAY;
196
- const themePresets = (0, _components2.useSetting)(`${presetSetting}.theme`) || EMPTY_ARRAY;
197
- const defaultPresets = (0, _components2.useSetting)(`${presetSetting}.default`) || EMPTY_ARRAY;
77
+ } = _ref2;
78
+ const disableDefault = !(0, _components.useSetting)(defaultSetting);
79
+ const userPresets = (0, _components.useSetting)(`${presetSetting}.custom`) || EMPTY_ARRAY;
80
+ const themePresets = (0, _components.useSetting)(`${presetSetting}.theme`) || EMPTY_ARRAY;
81
+ const defaultPresets = (0, _components.useSetting)(`${presetSetting}.default`) || EMPTY_ARRAY;
198
82
  return (0, _element.useMemo)(() => [...userPresets, ...themePresets, ...(disableDefault ? EMPTY_ARRAY : defaultPresets)], [disableDefault, userPresets, themePresets, defaultPresets]);
199
83
  }
200
84
 
201
- function DuotonePanel(_ref5) {
85
+ function DuotonePanel(_ref3) {
202
86
  var _style$color;
203
87
 
204
88
  let {
205
89
  attributes,
206
90
  setAttributes
207
- } = _ref5;
91
+ } = _ref3;
208
92
  const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
209
93
  const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
210
94
  const duotonePalette = useMultiOriginPresets({
@@ -215,17 +99,17 @@ function DuotonePanel(_ref5) {
215
99
  presetSetting: 'color.palette',
216
100
  defaultSetting: 'color.defaultPalette'
217
101
  });
218
- const disableCustomColors = !(0, _components2.useSetting)('color.custom');
219
- const disableCustomDuotone = !(0, _components2.useSetting)('color.customDuotone') || (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) === 0 && disableCustomColors;
102
+ const disableCustomColors = !(0, _components.useSetting)('color.custom');
103
+ const disableCustomDuotone = !(0, _components.useSetting)('color.customDuotone') || (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) === 0 && disableCustomColors;
220
104
 
221
105
  if ((duotonePalette === null || duotonePalette === void 0 ? void 0 : duotonePalette.length) === 0 && disableCustomDuotone) {
222
106
  return null;
223
107
  }
224
108
 
225
- return (0, _element.createElement)(_components2.BlockControls, {
109
+ return (0, _element.createElement)(_components.BlockControls, {
226
110
  group: "block",
227
111
  __experimentalShareWithChildBlocks: true
228
- }, (0, _element.createElement)(_components2.__experimentalDuotoneControl, {
112
+ }, (0, _element.createElement)(_components.__experimentalDuotoneControl, {
229
113
  duotonePalette: duotonePalette,
230
114
  colorPalette: colorPalette,
231
115
  disableCustomDuotone: disableCustomDuotone,
@@ -326,9 +210,9 @@ const withDuotoneStyles = (0, _compose.createHigherOrderComponent)(BlockListBloc
326
210
  var _props$attributes, _props$attributes$sty, _props$attributes$sty2;
327
211
 
328
212
  const duotoneSupport = (0, _blocks.getBlockSupport)(props.name, 'color.__experimentalDuotone');
329
- const values = props === null || props === void 0 ? void 0 : (_props$attributes = props.attributes) === null || _props$attributes === void 0 ? void 0 : (_props$attributes$sty = _props$attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.color) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.duotone;
213
+ const colors = props === null || props === void 0 ? void 0 : (_props$attributes = props.attributes) === null || _props$attributes === void 0 ? void 0 : (_props$attributes$sty = _props$attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.color) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.duotone;
330
214
 
331
- if (!duotoneSupport || !values) {
215
+ if (!duotoneSupport || !colors) {
332
216
  return (0, _element.createElement)(BlockListBlock, props);
333
217
  }
334
218
 
@@ -342,22 +226,11 @@ const withDuotoneStyles = (0, _compose.createHigherOrderComponent)(BlockListBloc
342
226
  return (0, _element.createElement)(_element.Fragment, null, element && (0, _element.createPortal)((0, _element.createElement)(InlineDuotone, {
343
227
  selector: selectorsGroup,
344
228
  id: id,
345
- values: getValuesFromColors(values)
229
+ colors: colors
346
230
  }), element), (0, _element.createElement)(BlockListBlock, (0, _extends2.default)({}, props, {
347
231
  className: className
348
232
  })));
349
233
  }, 'withDuotoneStyles');
350
-
351
- function PresetDuotoneFilter(_ref6) {
352
- let {
353
- preset
354
- } = _ref6;
355
- return (0, _element.createElement)(DuotoneFilter, {
356
- id: `wp-duotone-${preset.slug}`,
357
- values: getValuesFromColors(preset.colors)
358
- });
359
- }
360
-
361
234
  (0, _hooks.addFilter)('blocks.registerBlockType', 'core/editor/duotone/add-attributes', addDuotoneAttributes);
362
235
  (0, _hooks.addFilter)('editor.BlockEdit', 'core/editor/duotone/with-editor-controls', withDuotoneControls);
363
236
  (0, _hooks.addFilter)('editor.BlockListBlock', 'core/editor/duotone/with-styles', withDuotoneStyles);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["EMPTY_ARRAY","namesPlugin","getValuesFromColors","colors","values","r","g","b","a","forEach","color","rgbColor","toRgb","push","DuotoneStylesheet","selector","id","css","DuotoneFilter","visibility","position","left","overflow","join","InlineDuotone","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","userPresets","themePresets","defaultPresets","DuotonePanel","attributes","setAttributes","style","duotone","duotonePalette","colorPalette","disableCustomColors","disableCustomDuotone","length","newDuotone","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","scopeSelector","scope","scopes","split","selectors","selectorsScoped","outer","inner","trim","withDuotoneStyles","BlockListBlock","duotoneSupport","selectorsGroup","className","element","BlockList","__unstableElementContext","PresetDuotoneFilter","preset","slug"],"mappings":";;;;;;;;;;AAcA;;;;AAXA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AAxBA;AACA;AACA;;AAKA;AACA;AACA;;AAOA;AACA;AACA;AAQA,MAAMA,WAAW,GAAG,EAApB;AAEA,oBAAQ,CAAEC,cAAF,CAAR;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,mBAAT,GAA4C;AAAA,MAAdC,MAAc,uEAAL,EAAK;AAClD,QAAMC,MAAM,GAAG;AAAEC,IAAAA,CAAC,EAAE,EAAL;AAASC,IAAAA,CAAC,EAAE,EAAZ;AAAgBC,IAAAA,CAAC,EAAE,EAAnB;AAAuBC,IAAAA,CAAC,EAAE;AAA1B,GAAf;AAEAL,EAAAA,MAAM,CAACM,OAAP,CAAkBC,KAAF,IAAa;AAC5B,UAAMC,QAAQ,GAAG,oBAAQD,KAAR,EAAgBE,KAAhB,EAAjB;AACAR,IAAAA,MAAM,CAACC,CAAP,CAASQ,IAAT,CAAeF,QAAQ,CAACN,CAAT,GAAa,GAA5B;AACAD,IAAAA,MAAM,CAACE,CAAP,CAASO,IAAT,CAAeF,QAAQ,CAACL,CAAT,GAAa,GAA5B;A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,aAAYA,KAAZ,uBAAYA,KAAK,CAAEgB,SAAnB,EAA8BnD,EAA9B,CAAlB;AAEA,QAAMoD,OAAO,GAAG,yBAAYC,mBAAUC,wBAAtB,CAAhB;AAEA,SACC,qDACGF,OAAO,IACR,2BACC,4BAAC,aAAD;AACC,IAAA,QAAQ,EAAGF,cADZ;AAEC,IAAA,EAAE,EAAGlD,EAFN;AAGC,IAAA,MAAM,EAAGd,mBAAmB,CAAEE,MAAF;AAH7B,IADD,EAMCgE,OAND,CAFF,EAUC,4BAAC,cAAD,6BAAqBjB,KAArB;AAA6B,IAAA,SAAS,EAAGgB;AAAzC,KAVD,CADD;AAcA,CAxCwB,EAyCzB,mBAzCyB,CAA1B;;AA4CO,SAASI,mBAAT,QAA2C;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AACjD,SACC,4BAAC,aAAD;AACC,IAAA,EAAE,EAAI,cAAcA,MAAM,CAACC,IAAM,EADlC;AAEC,IAAA,MAAM,EAAGvE,mBAAmB,CAAEsE,MAAM,CAACrE,MAAT;AAF7B,IADD;AAMA;;AAED,sBACC,0BADD,EAEC,oCAFD,EAGCyC,oBAHD;AAKA,sBACC,kBADD,EAEC,0CAFD,EAGCK,mBAHD;AAKA,sBACC,uBADD,EAEC,iCAFD,EAGCc,iBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { SVG } from '@wordpress/components';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport BlockList from '../components/block-list';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\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 * Values for the SVG `feComponentTransfer`.\n *\n * @typedef Values {Object}\n * @property {number[]} r Red values.\n * @property {number[]} g Green values.\n * @property {number[]} b Blue values.\n * @property {number[]} a Alpha values.\n */\n\n/**\n * Stylesheet for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n *\n * @return {WPElement} Duotone element.\n */\nfunction DuotoneStylesheet( { selector, id } ) {\n\tconst css = `\n${ selector } {\n\tfilter: url( #${ id } );\n}\n`;\n\treturn <style>{ css }</style>;\n}\n\n/**\n * SVG for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {Values} props.values R, G, B, and A values to filter with.\n *\n * @return {WPElement} Duotone element.\n */\nfunction DuotoneFilter( { id, values } ) {\n\treturn (\n\t\t<SVG\n\t\t\txmlnsXlink=\"http://www.w3.org/1999/xlink\"\n\t\t\tviewBox=\"0 0 0 0\"\n\t\t\twidth=\"0\"\n\t\t\theight=\"0\"\n\t\t\tfocusable=\"false\"\n\t\t\trole=\"none\"\n\t\t\tstyle={ {\n\t\t\t\tvisibility: 'hidden',\n\t\t\t\tposition: 'absolute',\n\t\t\t\tleft: '-9999px',\n\t\t\t\toverflow: 'hidden',\n\t\t\t} }\n\t\t>\n\t\t\t<defs>\n\t\t\t\t<filter id={ id }>\n\t\t\t\t\t<feColorMatrix\n\t\t\t\t\t\t// Use sRGB instead of linearRGB so transparency looks correct.\n\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t\ttype=\"matrix\"\n\t\t\t\t\t\t// Use perceptual brightness to convert to grayscale.\n\t\t\t\t\t\tvalues=\"\n\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\"\n\t\t\t\t\t/>\n\t\t\t\t\t<feComponentTransfer\n\t\t\t\t\t\t// Use sRGB instead of linearRGB to be consistent with how CSS gradients work.\n\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<feFuncR\n\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\ttableValues={ values.r.join( ' ' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<feFuncG\n\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\ttableValues={ values.g.join( ' ' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<feFuncB\n\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\ttableValues={ values.b.join( ' ' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<feFuncA\n\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\ttableValues={ values.a.join( ' ' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</feComponentTransfer>\n\t\t\t\t\t<feComposite\n\t\t\t\t\t\t// Re-mask the image with the original transparency since the feColorMatrix above loses that information.\n\t\t\t\t\t\tin2=\"SourceGraphic\"\n\t\t\t\t\t\toperator=\"in\"\n\t\t\t\t\t/>\n\t\t\t\t</filter>\n\t\t\t</defs>\n\t\t</SVG>\n\t);\n}\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {Values} props.values R, G, B, and A values to filter with.\n *\n * @return {WPElement} Duotone element.\n */\nfunction InlineDuotone( { selector, id, values } ) {\n\treturn (\n\t\t<>\n\t\t\t<DuotoneFilter id={ id } values={ values } />\n\t\t\t<DuotoneStylesheet id={ id } selector={ selector } />\n\t\t</>\n\t);\n}\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotone = style?.color?.duotone;\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotone }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: newDuotone,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ hasDuotoneSupport && <DuotonePanel { ...props } /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nfunction scopeSelector( scope, selector ) {\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst values = props?.attributes?.style?.color?.duotone;\n\n\t\tif ( ! duotoneSupport || ! values ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst id = `wp-duotone-${ useInstanceId( BlockListBlock ) }`;\n\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\t\tconst selectorsGroup = scopeSelector(\n\t\t\t`.editor-styles-wrapper .${ id }`,\n\t\t\tduotoneSupport\n\t\t);\n\n\t\tconst className = classnames( props?.className, id );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<InlineDuotone\n\t\t\t\t\t\t\tselector={ selectorsGroup }\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tvalues={ getValuesFromColors( values ) }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\nexport function PresetDuotoneFilter( { preset } ) {\n\treturn (\n\t\t<DuotoneFilter\n\t\t\tid={ `wp-duotone-${ preset.slug }` }\n\t\t\tvalues={ getValuesFromColors( preset.colors ) }\n\t\t/>\n\t);\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["EMPTY_ARRAY","namesPlugin","InlineDuotone","selector","id","colors","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","userPresets","themePresets","defaultPresets","DuotonePanel","attributes","setAttributes","style","duotone","color","duotonePalette","colorPalette","disableCustomColors","disableCustomDuotone","length","newDuotone","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","scopeSelector","scope","scopes","split","selectors","selectorsScoped","forEach","outer","inner","push","trim","join","withDuotoneStyles","BlockListBlock","duotoneSupport","selectorsGroup","className","element","BlockList","__unstableElementContext"],"mappings":";;;;AAaA;;;;AAVA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAMA;;AAKA;;AACA;;AAxBA;AACA;AACA;;AAKA;AACA;AACA;;AAMA;AACA;AACA;AAaA,MAAMA,WAAW,GAAG,EAApB;AAEA,oBAAQ,CAAEC,cAAF,CAAR;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,aAAT,OAAmD;AAAA,MAA3B;AAAEC,IAAAA,QAAF;AAAYC,IA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Content":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport BlockList from '../components/block-list';\nimport {\n\t__unstableDuotoneFilter as DuotoneFilter,\n\t__unstableDuotoneStylesheet as DuotoneStylesheet,\n\t__unstableDuotoneUnsetStylesheet as DuotoneUnsetStylesheet,\n} from '../components/duotone';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {string[]|\"unset\"} props.colors Array of RGB color strings ordered from dark to light.\n *\n * @return {WPElement} Duotone element.\n */\nfunction InlineDuotone( { selector, id, colors } ) {\n\tif ( colors === 'unset' ) {\n\t\treturn <DuotoneUnsetStylesheet selector={ selector } />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DuotoneFilter id={ id } colors={ colors } />\n\t\t\t<DuotoneStylesheet id={ id } selector={ selector } />\n\t\t</>\n\t);\n}\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotone = style?.color?.duotone;\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotone }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: newDuotone,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ hasDuotoneSupport && <DuotonePanel { ...props } /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nfunction scopeSelector( scope, selector ) {\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst colors = props?.attributes?.style?.color?.duotone;\n\n\t\tif ( ! duotoneSupport || ! colors ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst id = `wp-duotone-${ useInstanceId( BlockListBlock ) }`;\n\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\t\tconst selectorsGroup = scopeSelector(\n\t\t\t`.editor-styles-wrapper .${ id }`,\n\t\t\tduotoneSupport\n\t\t);\n\n\t\tconst className = classnames( props?.className, id );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<InlineDuotone\n\t\t\t\t\t\t\tselector={ selectorsGroup }\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/font-family.js"],"names":["FONT_FAMILY_SUPPORT_KEY","addAttributes","settings","attributes","fontFamily","Object","assign","type","addSaveProps","props","blockType","TYPOGRAPHY_SUPPORT_KEY","classes","TokenList","className","add","newClassName","value","undefined","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","FontFamilyEdit","setAttributes","fontFamilies","slug","onChange","newValue","predefinedFontFamily","f","useIsFontFamilyDisabled","name","length","hasFontFamilyValue","resetFontFamily"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAMO,MAAMA,uBAAuB,GAAG,qCAAhC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,aAAT,CAAwBC,QAAxB,EAAmC;AAClC,MAAK,CAAE,6BAAiBA,QAAjB,EAA2BF,uBAA3B,CAAP,EAA8D;AAC7D,WAAOE,QAAP;AACA,GAHiC,CAKlC;;;AACA,MAAK,CAAEA,QAAQ,CAACC,UAAT,CAAoBC,UAA3B,EAAwC;AACvCC,IAAAA,MAAM,CAACC,MAAP,CAAeJ,QAAQ,CAACC,UAAxB,EAAoC;AACnCC,MAAAA,UAAU,EAAE;AACXG,QAAAA,IAAI,EAAE;AADK;AADuB,KAApC;AAKA;;AAED,SAAOL,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASM,YAAT,CAAuBC,KAAvB,EAA8BC,SAA9B,EAAyCP,UAAzC,EAAsD;AACrD,MAAK,CAAE,6BAAiBO,SAAjB,EAA4BV,uBAA5B,CAAP,EAA+D;AAC9D,WAAOS,KAAP;AACA;;AAED,MACC,oCACCC,SADD,EAECC,kCAFD,EAGC,YAHD,CADD,EAME;AACD,WAAOF,KAAP;AACA;;AAED,MAAK,EAAEN,UAAF,aAAEA,UAAF,eAAEA,UAAU,CAAEC,UAAd,CAAL,EAAgC;AAC/B,WAAOK,KAAP;AACA,GAjBoD,CAmBrD;;;AACA,QAAMG,OAAO,GAAG,IAAIC,kBAAJ,CAAeJ,KAAK,CAACK,SAArB,CAAhB;AACAF,EAAAA,OAAO,CAACG,GAAR,CAAc,OAAO,uBAAWZ,UAAX,aAAWA,UAAX,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AF4B,CAA7B;AAIAJ,IAAAA,aAAa,CAAE;AACdnB,MAAAA,UAAU,EAAEwB,oBAAF,aAAEA,oBAAF,uBAAEA,oBAAoB,CAAEH;AADpB,KAAF,CAAb;AAGA;;AAED,SACC,4BAAC,mBAAD;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,YAAY,EAAGD,YAFhB;AAGC,IAAA,KAAK,EAAGP,KAHT;AAIC,IAAA,QAAQ,EAAGS;AAJZ,IADD;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,uBAAT,QAA6C;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AACnD,QAAMP,YAAY,GAAG,yBAAY,yBAAZ,CAArB;AACA,SACC,CAAEA,YAAF,IACAA,YAAY,CAACQ,MAAb,KAAwB,CADxB,IAEA,CAAE,6BAAiBD,IAAjB,EAAuB/B,uBAAvB,CAHH;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASiC,kBAAT,CAA6BxB,KAA7B,EAAqC;AAC3C,SAAO,CAAC,CAAEA,KAAK,CAACN,UAAN,CAAiBC,UAA3B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAAS8B,eAAT,QAA8C;AAAA,MAApB;AAAEX,IAAAA;AAAF,GAAoB;AACpDA,EAAAA,aAAa,CAAE;AAAEnB,IAAAA,UAAU,EAAEc;AAAd,GAAF,CAAb;AACA;;AAED,sBACC,0BADD,EAEC,8BAFD,EAGCjB,aAHD;AAMA,sBACC,kCADD,EAEC,8BAFD,EAGCO,YAHD;AAMA,sBACC,0BADD,EAEC,8BAFD,EAGCW,YAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { find, kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport TokenList from '@wordpress/token-list';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\nimport FontFamilyControl from '../components/font-family';\nimport { shouldSkipSerialization } from './utils';\nimport { TYPOGRAPHY_SUPPORT_KEY } from './typography';\n\nexport const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `fontFamily` attribute.\n *\n * @param {Object} settings Original block settings\n * @return {Object} Filtered block settings\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_FAMILY_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify a default value if needed.\n\tif ( ! settings.attributes.fontFamily ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tfontFamily: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject font family.\n *\n * @param {Object} props Additional props applied to save element\n * @param {Object} blockType Block type\n * @param {Object} attributes Block attributes\n * @return {Object} Filtered props applied to save element\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, FONT_FAMILY_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tif (\n\t\tshouldSkipSerialization(\n\t\t\tblockType,\n\t\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t\t\t'fontFamily'\n\t\t)\n\t) {\n\t\treturn props;\n\t}\n\n\tif ( ! attributes?.fontFamily ) {\n\t\treturn props;\n\t}\n\n\t// Use TokenList to dedupe classes.\n\tconst classes = new TokenList( props.className );\n\tclasses.add( `has-${ kebabCase( attributes?.fontFamily ) }-font-family` );\n\tconst newClassName = classes.value;\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to expand the block edit wrapper\n * by applying the desired styles and classnames.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_FAMILY_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\nexport function FontFamilyEdit( {\n\tsetAttributes,\n\tattributes: { fontFamily },\n} ) {\n\tconst fontFamilies = useSetting( 'typography.fontFamilies' );\n\n\tconst value = find( fontFamilies, ( { slug } ) => fontFamily === slug )\n\t\t?.fontFamily;\n\n\tfunction onChange( newValue ) {\n\t\tconst predefinedFontFamily = find(\n\t\t\tfontFamilies,\n\t\t\t( { fontFamily: f } ) => f === newValue\n\t\t);\n\t\tsetAttributes( {\n\t\t\tfontFamily: predefinedFontFamily?.slug,\n\t\t} );\n\t}\n\n\treturn (\n\t\t<FontFamilyControl\n\t\t\tclassName=\"block-editor-hooks-font-family-control\"\n\t\t\tfontFamilies={ fontFamilies }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Custom hook that checks if font-family functionality is disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether setting is disabled.\n */\nexport function useIsFontFamilyDisabled( { name } ) {\n\tconst fontFamilies = useSetting( 'typography.fontFamilies' );\n\treturn (\n\t\t! fontFamilies ||\n\t\tfontFamilies.length === 0 ||\n\t\t! hasBlockSupport( name, FONT_FAMILY_SUPPORT_KEY )\n\t);\n}\n\n/**\n * Checks if there is a current value set for the font family block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a font family value set.\n */\nexport function hasFontFamilyValue( props ) {\n\treturn !! props.attributes.fontFamily;\n}\n\n/**\n * Resets the font family block support attribute. This can be used when\n * disabling the font family support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetFontFamily( { setAttributes } ) {\n\tsetAttributes( { fontFamily: undefined } );\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/fontFamily/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/fontFamily/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/fontFamily/addEditProps',\n\taddEditProps\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/font-family.js"],"names":["FONT_FAMILY_SUPPORT_KEY","addAttributes","settings","attributes","fontFamily","Object","assign","type","addSaveProps","props","blockType","TYPOGRAPHY_SUPPORT_KEY","classes","TokenList","className","add","newClassName","value","undefined","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","FontFamilyEdit","setAttributes","fontFamilies","slug","onChange","newValue","predefinedFontFamily","f","useIsFontFamilyDisabled","name","length","hasFontFamilyValue","resetFontFamily"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAMO,MAAMA,uBAAuB,GAAG,qCAAhC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,aAAT,CAAwBC,QAAxB,EAAmC;AAClC,MAAK,CAAE,6BAAiBA,QAAjB,EAA2BF,uBAA3B,CAAP,EAA8D;AAC7D,WAAOE,QAAP;AACA,GAHiC,CAKlC;;;AACA,MAAK,CAAEA,QAAQ,CAACC,UAAT,CAAoBC,UAA3B,EAAwC;AACvCC,IAAAA,MAAM,CAACC,MAAP,CAAeJ,QAAQ,CAACC,UAAxB,EAAoC;AACnCC,MAAAA,UAAU,EAAE;AACXG,QAAAA,IAAI,EAAE;AADK;AADuB,KAApC;AAKA;;AAED,SAAOL,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASM,YAAT,CAAuBC,KAAvB,EAA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AAT,QAA8C;AAAA,MAApB;AAAEX,IAAAA;AAAF,GAAoB;AACpDA,EAAAA,aAAa,CAAE;AAAEnB,IAAAA,UAAU,EAAEc;AAAd,GAAF,CAAb;AACA;;AAED,sBACC,0BADD,EAEC,8BAFD,EAGCjB,aAHD;AAMA,sBACC,kCADD,EAEC,8BAFD,EAGCO,YAHD;AAMA,sBACC,0BADD,EAEC,8BAFD,EAGCW,YAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { find, kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport TokenList from '@wordpress/token-list';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\nimport FontFamilyControl from '../components/font-family';\nimport { shouldSkipSerialization } from './utils';\nimport { TYPOGRAPHY_SUPPORT_KEY } from './typography';\n\nexport const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `fontFamily` attribute.\n *\n * @param {Object} settings Original block settings\n * @return {Object} Filtered block settings\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_FAMILY_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify a default value if needed.\n\tif ( ! settings.attributes.fontFamily ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tfontFamily: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject font family.\n *\n * @param {Object} props Additional props applied to save element\n * @param {Object} blockType Block type\n * @param {Object} attributes Block attributes\n * @return {Object} Filtered props applied to save element\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, FONT_FAMILY_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tif (\n\t\tshouldSkipSerialization(\n\t\t\tblockType,\n\t\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t\t\t'fontFamily'\n\t\t)\n\t) {\n\t\treturn props;\n\t}\n\n\tif ( ! attributes?.fontFamily ) {\n\t\treturn props;\n\t}\n\n\t// Use TokenList to dedupe classes.\n\tconst classes = new TokenList( props.className );\n\tclasses.add( `has-${ kebabCase( attributes?.fontFamily ) }-font-family` );\n\tconst newClassName = classes.value;\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to expand the block edit wrapper\n * by applying the desired styles and classnames.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_FAMILY_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\nexport function FontFamilyEdit( {\n\tsetAttributes,\n\tattributes: { fontFamily },\n} ) {\n\tconst fontFamilies = useSetting( 'typography.fontFamilies' );\n\n\tconst value = find(\n\t\tfontFamilies,\n\t\t( { slug } ) => fontFamily === slug\n\t)?.fontFamily;\n\n\tfunction onChange( newValue ) {\n\t\tconst predefinedFontFamily = find(\n\t\t\tfontFamilies,\n\t\t\t( { fontFamily: f } ) => f === newValue\n\t\t);\n\t\tsetAttributes( {\n\t\t\tfontFamily: predefinedFontFamily?.slug,\n\t\t} );\n\t}\n\n\treturn (\n\t\t<FontFamilyControl\n\t\t\tclassName=\"block-editor-hooks-font-family-control\"\n\t\t\tfontFamilies={ fontFamilies }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Custom hook that checks if font-family functionality is disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether setting is disabled.\n */\nexport function useIsFontFamilyDisabled( { name } ) {\n\tconst fontFamilies = useSetting( 'typography.fontFamilies' );\n\treturn (\n\t\t! fontFamilies ||\n\t\tfontFamilies.length === 0 ||\n\t\t! hasBlockSupport( name, FONT_FAMILY_SUPPORT_KEY )\n\t);\n}\n\n/**\n * Checks if there is a current value set for the font family block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a font family value set.\n */\nexport function hasFontFamilyValue( props ) {\n\treturn !! props.attributes.fontFamily;\n}\n\n/**\n * Resets the font family block support attribute. This can be used when\n * disabling the font family support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetFontFamily( { setAttributes } ) {\n\tsetAttributes( { fontFamily: undefined } );\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/fontFamily/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/fontFamily/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/fontFamily/addEditProps',\n\taddEditProps\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/gap.js"],"names":["hasGapSupport","blockType","support","SPACING_SUPPORT_KEY","blockGap","hasGapValue","props","attributes","style","spacing","undefined","getGapBoxControlValueFromStyle","blockGapValue","isValueString","top","left","getGapCSSValue","defaultValue","blockGapBoxControlValue","row","column","resetGap","setAttributes","useIsGapDisabled","name","blockName","isDisabled","GapEdit","clientId","units","availableUnits","sides","ref","splitOnAxis","some","side","AXIAL_SIDES","includes","onChange","next","newStyle","isSafari","window","navigator","userAgent","current","parentNode","replaceChild","gapValue","boxControlGapValue","right","bottom","Platform","select","web","native"],"mappings":";;;;;;;;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AASA;;AACA;;AACA;;AACA;;AAlBA;AACA;AAC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":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Platform } from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';\nimport useSetting from '../components/use-setting';\nimport { AXIAL_SIDES, SPACING_SUPPORT_KEY, useCustomSides } from './dimensions';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Determines if there is gap support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n * @return {boolean} Whether there is support.\n */\nexport function hasGapSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );\n\treturn !! ( true === support || support?.blockGap );\n}\n\n/**\n * Checks if there is a current value in the gap block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a gap value set.\n */\nexport function hasGapValue( props ) {\n\treturn props.attributes.style?.spacing?.blockGap !== undefined;\n}\n\n/**\n * Returns a BoxControl object value from a given blockGap style value.\n * The string check is for backwards compatibility before Gutenberg supported\n * split gap values (row and column) and the value was a string n + unit.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @return {Object|null} A value to pass to the BoxControl component.\n */\nexport function getGapBoxControlValueFromStyle( blockGapValue ) {\n\tif ( ! blockGapValue ) {\n\t\treturn null;\n\t}\n\n\tconst isValueString = typeof blockGapValue === 'string';\n\treturn {\n\t\ttop: isValueString ? blockGapValue : blockGapValue?.top,\n\t\tleft: isValueString ? blockGapValue : blockGapValue?.left,\n\t};\n}\n\n/**\n * Returns a CSS value for the `gap` property from a given blockGap style.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @param {string?} defaultValue A default gap value.\n * @return {string|null} The concatenated gap value (row and column).\n */\nexport function getGapCSSValue( blockGapValue, defaultValue = '0' ) {\n\tconst blockGapBoxControlValue = getGapBoxControlValueFromStyle(\n\t\tblockGapValue\n\t);\n\tif ( ! blockGapBoxControlValue ) {\n\t\treturn null;\n\t}\n\n\tconst row = blockGapBoxControlValue?.top || defaultValue;\n\tconst column = blockGapBoxControlValue?.left || defaultValue;\n\n\treturn row === column ? row : `${ row } ${ column }`;\n}\n\n/**\n * Resets the gap block support attribute. This can be used when disabling\n * the gap support controls for a block via a progressive discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetGap( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap: undefined,\n\t\t\t},\n\t\t},\n\t} );\n}\n\n/**\n * Custom hook that checks if gap settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether the gap setting is disabled.\n */\nexport function useIsGapDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'spacing.blockGap' );\n\treturn ! hasGapSupport( blockName ) || isDisabled;\n}\n\n/**\n * Inspector control panel containing the gap related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Gap edit element.\n */\nexport function GapEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes: { style },\n\t\tname: blockName,\n\t\tsetAttributes,\n\t} = props;\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t],\n\t} );\n\tconst sides = useCustomSides( blockName, 'blockGap' );\n\tconst ref = useBlockRef( clientId );\n\n\tif ( useIsGapDisabled( props ) ) {\n\t\treturn null;\n\t}\n\n\tconst splitOnAxis =\n\t\tsides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tconst onChange = ( next ) => {\n\t\tlet blockGap = next;\n\n\t\t// If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.\n\t\tif ( !! next && splitOnAxis ) {\n\t\t\tblockGap = { ...getGapBoxControlValueFromStyle( next ) };\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\n\t\t// In Safari, changing the `gap` CSS value on its own will not trigger the layout\n\t\t// to be recalculated / re-rendered. To force the updated gap to re-render, here\n\t\t// we replace the block's node with itself.\n\t\tconst isSafari =\n\t\t\twindow?.navigator.userAgent &&\n\t\t\twindow.navigator.userAgent.includes( 'Safari' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chrome ' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chromium ' );\n\n\t\tif ( ref.current && isSafari ) {\n\t\t\tref.current.parentNode?.replaceChild( ref.current, ref.current );\n\t\t}\n\t};\n\n\tconst gapValue = getGapBoxControlValueFromStyle( style?.spacing?.blockGap );\n\n\t// The BoxControl component expects a full complement of side values.\n\t// Gap row and column values translate to top/bottom and left/right respectively.\n\tconst boxControlGapValue = splitOnAxis\n\t\t? {\n\t\t\t\t...gapValue,\n\t\t\t\tright: gapValue?.left,\n\t\t\t\tbottom: gapValue?.top,\n\t\t }\n\t\t: gapValue?.top;\n\n\treturn Platform.select( {\n\t\tweb: (\n\t\t\t<>\n\t\t\t\t{ splitOnAxis ? (\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\tvalues={ boxControlGapValue }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t// Default to `row` for combined values.\n\t\t\t\t\t\tvalue={ boxControlGapValue }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t),\n\t\tnative: null,\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/gap.js"],"names":["hasGapSupport","blockType","support","SPACING_SUPPORT_KEY","blockGap","hasGapValue","props","attributes","style","spacing","undefined","getGapBoxControlValueFromStyle","blockGapValue","isValueString","top","left","getGapCSSValue","defaultValue","blockGapBoxControlValue","row","column","resetGap","setAttributes","useIsGapDisabled","name","blockName","isDisabled","GapEdit","clientId","units","availableUnits","sides","ref","splitOnAxis","some","side","AXIAL_SIDES","includes","onChange","next","newStyle","isSafari","window","navigator","userAgent","current","parentNode","replaceChild","gapValue","boxControlGapValue","right","bottom","Platform","select","web","native"],"mappings":";;;;;;;;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AASA;;AACA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAUA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAwBC,SAAxB,EAAoC;AAC1C,QAAMC,OAAO,GAAG,6BAAiBD,SAAjB,EAA4BE,+BAA5B,CAAhB;AACA,SAAO,CAAC,EAAI,SAASD,OAAT,IAAoBA,OAApB,aAAoBA,OAApB,eAAoBA,OAAO,CAAEE,QAAjC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,WAAT,CAAsBC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GACnC,EACA,GAAGe,QADH;AAEAE,IAAAA,KAAK,EAAEF,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEjC,IAFjB;AAGAoC,IAAAA,MAAM,EAAEH,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAElC;AAHlB,GADmC,GAMnCkC,QANmC,aAMnCA,QANmC,uBAMnCA,QAAQ,CAAElC,GANb;AAQA,SAAOsC,kBAASC,MAAT,CAAiB;AACvBC,IAAAA,GAAG,EACF,qDACGrB,WAAW,GACZ,4BAAC,oCAAD;AACC,MAAA,KAAK,EAAG,cAAI,eAAJ,CADT;AAEC,MAAA,GAAG,EAAG,CAFP;AAGC,MAAA,QAAQ,EAAGK,QAHZ;AAIC,MAAA,KAAK,EAAGT,KAJT;AAKC,MAAA,KAAK,EAAGE,KALT;AAMC,MAAA,MAAM,EAAGkB,kBANV;AAOC,MAAA,UAAU,EAAG,KAPd;AAQC,MAAA,WAAW,EAAGhB;AARf,MADY,GAYZ,4BAAC,qCAAD;AACC,MAAA,KAAK,EAAG,cAAI,eAAJ,CADT;AAEC,MAAA,oBAAoB,EAAC,MAFtB;AAGC,MAAA,GAAG,EAAG,CAHP;AAIC,MAAA,QAAQ,EAAGK,QAJZ;AAKC,MAAA,KAAK,EAAGT,KALT,CAMC;AAND;AAOC,MAAA,KAAK,EAAGoB;AAPT,MAbF,CAFsB;AA2BvBM,IAAAA,MAAM,EAAE;AA3Be,GAAjB,CAAP;AA6BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Platform } from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';\nimport useSetting from '../components/use-setting';\nimport { AXIAL_SIDES, SPACING_SUPPORT_KEY, useCustomSides } from './dimensions';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Determines if there is gap support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n * @return {boolean} Whether there is support.\n */\nexport function hasGapSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );\n\treturn !! ( true === support || support?.blockGap );\n}\n\n/**\n * Checks if there is a current value in the gap block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a gap value set.\n */\nexport function hasGapValue( props ) {\n\treturn props.attributes.style?.spacing?.blockGap !== undefined;\n}\n\n/**\n * Returns a BoxControl object value from a given blockGap style value.\n * The string check is for backwards compatibility before Gutenberg supported\n * split gap values (row and column) and the value was a string n + unit.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @return {Object|null} A value to pass to the BoxControl component.\n */\nexport function getGapBoxControlValueFromStyle( blockGapValue ) {\n\tif ( ! blockGapValue ) {\n\t\treturn null;\n\t}\n\n\tconst isValueString = typeof blockGapValue === 'string';\n\treturn {\n\t\ttop: isValueString ? blockGapValue : blockGapValue?.top,\n\t\tleft: isValueString ? blockGapValue : blockGapValue?.left,\n\t};\n}\n\n/**\n * Returns a CSS value for the `gap` property from a given blockGap style.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @param {string?} defaultValue A default gap value.\n * @return {string|null} The concatenated gap value (row and column).\n */\nexport function getGapCSSValue( blockGapValue, defaultValue = '0' ) {\n\tconst blockGapBoxControlValue =\n\t\tgetGapBoxControlValueFromStyle( blockGapValue );\n\tif ( ! blockGapBoxControlValue ) {\n\t\treturn null;\n\t}\n\n\tconst row = blockGapBoxControlValue?.top || defaultValue;\n\tconst column = blockGapBoxControlValue?.left || defaultValue;\n\n\treturn row === column ? row : `${ row } ${ column }`;\n}\n\n/**\n * Resets the gap block support attribute. This can be used when disabling\n * the gap support controls for a block via a progressive discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetGap( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap: undefined,\n\t\t\t},\n\t\t},\n\t} );\n}\n\n/**\n * Custom hook that checks if gap settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether the gap setting is disabled.\n */\nexport function useIsGapDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'spacing.blockGap' );\n\treturn ! hasGapSupport( blockName ) || isDisabled;\n}\n\n/**\n * Inspector control panel containing the gap related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Gap edit element.\n */\nexport function GapEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes: { style },\n\t\tname: blockName,\n\t\tsetAttributes,\n\t} = props;\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t],\n\t} );\n\tconst sides = useCustomSides( blockName, 'blockGap' );\n\tconst ref = useBlockRef( clientId );\n\n\tif ( useIsGapDisabled( props ) ) {\n\t\treturn null;\n\t}\n\n\tconst splitOnAxis =\n\t\tsides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tconst onChange = ( next ) => {\n\t\tlet blockGap = next;\n\n\t\t// If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.\n\t\tif ( !! next && splitOnAxis ) {\n\t\t\tblockGap = { ...getGapBoxControlValueFromStyle( next ) };\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\n\t\t// In Safari, changing the `gap` CSS value on its own will not trigger the layout\n\t\t// to be recalculated / re-rendered. To force the updated gap to re-render, here\n\t\t// we replace the block's node with itself.\n\t\tconst isSafari =\n\t\t\twindow?.navigator.userAgent &&\n\t\t\twindow.navigator.userAgent.includes( 'Safari' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chrome ' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chromium ' );\n\n\t\tif ( ref.current && isSafari ) {\n\t\t\tref.current.parentNode?.replaceChild( ref.current, ref.current );\n\t\t}\n\t};\n\n\tconst gapValue = getGapBoxControlValueFromStyle( style?.spacing?.blockGap );\n\n\t// The BoxControl component expects a full complement of side values.\n\t// Gap row and column values translate to top/bottom and left/right respectively.\n\tconst boxControlGapValue = splitOnAxis\n\t\t? {\n\t\t\t\t...gapValue,\n\t\t\t\tright: gapValue?.left,\n\t\t\t\tbottom: gapValue?.top,\n\t\t }\n\t\t: gapValue?.top;\n\n\treturn Platform.select( {\n\t\tweb: (\n\t\t\t<>\n\t\t\t\t{ splitOnAxis ? (\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\tvalues={ boxControlGapValue }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t// Default to `row` for combined values.\n\t\t\t\t\t\tvalue={ boxControlGapValue }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t),\n\t\tnative: null,\n\t} );\n}\n"]}
@@ -3,12 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "PresetDuotoneFilter", {
7
- enumerable: true,
8
- get: function () {
9
- return _duotone.PresetDuotoneFilter;
10
- }
11
- });
12
6
  Object.defineProperty(exports, "getBorderClassesAndStyles", {
13
7
  enumerable: true,
14
8
  get: function () {
@@ -21,6 +15,12 @@ Object.defineProperty(exports, "getColorClassesAndStyles", {
21
15
  return _useColorProps.getColorClassesAndStyles;
22
16
  }
23
17
  });
18
+ Object.defineProperty(exports, "getGapCSSValue", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _gap.getGapCSSValue;
22
+ }
23
+ });
24
24
  Object.defineProperty(exports, "getSpacingClassesAndStyles", {
25
25
  enumerable: true,
26
26
  get: function () {
@@ -60,6 +60,8 @@ require("./lock");
60
60
 
61
61
  require("./anchor");
62
62
 
63
+ require("./aria-label");
64
+
63
65
  require("./custom-class-name");
64
66
 
65
67
  require("./generated-class-name");
@@ -70,7 +72,7 @@ require("./settings");
70
72
 
71
73
  require("./color");
72
74
 
73
- var _duotone = require("./duotone");
75
+ require("./duotone");
74
76
 
75
77
  require("./font-size");
76
78
 
@@ -86,5 +88,7 @@ var _useColorProps = require("./use-color-props");
86
88
 
87
89
  var _useSpacingProps = require("./use-spacing-props");
88
90
 
91
+ var _gap = require("./gap");
92
+
89
93
  var _useCachedTruthy = require("./use-cached-truthy");
90
94
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport './compat';\nimport './align';\nimport './lock';\nimport './anchor';\nimport './custom-class-name';\nimport './generated-class-name';\nimport './style';\nimport './settings';\nimport './color';\nimport './duotone';\nimport './font-size';\nimport './border';\nimport './layout';\n\nexport { useCustomSides } from './dimensions';\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\nexport { useCachedTruthy } from './use-cached-truthy';\nexport { PresetDuotoneFilter } from './duotone';\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport './compat';\nimport './align';\nimport './lock';\nimport './anchor';\nimport './aria-label';\nimport './custom-class-name';\nimport './generated-class-name';\nimport './style';\nimport './settings';\nimport './color';\nimport './duotone';\nimport './font-size';\nimport './border';\nimport './layout';\n\nexport { useCustomSides } from './dimensions';\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\nexport { getGapCSSValue } from './gap';\nexport { useCachedTruthy } from './use-cached-truthy';\n"]}
@@ -52,6 +52,45 @@ var _layouts = require("../layouts");
52
52
  * Internal dependencies
53
53
  */
54
54
  const layoutBlockSupportKey = '__experimentalLayout';
55
+ /**
56
+ * Generates the utility classnames for the given blocks layout attributes.
57
+ * This method was primarily added to reintroduce classnames that were removed
58
+ * in the 5.9 release (https://github.com/WordPress/gutenberg/issues/38719), rather
59
+ * than providing an extensive list of all possible layout classes. The plan is to
60
+ * have the style engine generate a more extensive list of utility classnames which
61
+ * will then replace this method.
62
+ *
63
+ * @param { Object } layout Layout object.
64
+ * @param { Object } layoutDefinitions An object containing layout definitions, stored in theme.json.
65
+ *
66
+ * @return { Array } Array of CSS classname strings.
67
+ */
68
+
69
+ function getLayoutClasses(layout, layoutDefinitions) {
70
+ var _layoutDefinitions;
71
+
72
+ const layoutClassnames = [];
73
+
74
+ if (layoutDefinitions !== null && layoutDefinitions !== void 0 && (_layoutDefinitions = layoutDefinitions[(layout === null || layout === void 0 ? void 0 : layout.type) || 'default']) !== null && _layoutDefinitions !== void 0 && _layoutDefinitions.className) {
75
+ var _layoutDefinitions2;
76
+
77
+ layoutClassnames.push(layoutDefinitions === null || layoutDefinitions === void 0 ? void 0 : (_layoutDefinitions2 = layoutDefinitions[(layout === null || layout === void 0 ? void 0 : layout.type) || 'default']) === null || _layoutDefinitions2 === void 0 ? void 0 : _layoutDefinitions2.className);
78
+ }
79
+
80
+ if (layout !== null && layout !== void 0 && layout.orientation) {
81
+ layoutClassnames.push(`is-${(0, _lodash.kebabCase)(layout.orientation)}`);
82
+ }
83
+
84
+ if (layout !== null && layout !== void 0 && layout.justifyContent) {
85
+ layoutClassnames.push(`is-content-justification-${(0, _lodash.kebabCase)(layout.justifyContent)}`);
86
+ }
87
+
88
+ if (layout !== null && layout !== void 0 && layout.flexWrap && layout.flexWrap === 'nowrap') {
89
+ layoutClassnames.push('is-nowrap');
90
+ }
91
+
92
+ return layoutClassnames;
93
+ }
55
94
 
56
95
  function LayoutPanel(_ref) {
57
96
  let {
@@ -114,15 +153,17 @@ function LayoutPanel(_ref) {
114
153
 
115
154
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components2.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
116
155
  title: (0, _i18n.__)('Layout')
117
- }, showInheritToggle && (0, _element.createElement)(_components.ToggleControl, {
118
- label: (0, _i18n.__)('Inherit default layout'),
119
- checked: !!inherit,
156
+ }, showInheritToggle && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.ToggleControl, {
157
+ label: (0, _i18n.__)('Inner blocks use full width'),
158
+ checked: !inherit,
120
159
  onChange: () => setAttributes({
121
160
  layout: {
122
161
  inherit: !inherit
123
162
  }
124
163
  })
125
- }), !inherit && allowSwitching && (0, _element.createElement)(LayoutTypeSwitcher, {
164
+ }), (0, _element.createElement)("p", {
165
+ className: "block-editor-hooks__layout-controls-helptext"
166
+ }, !!inherit ? (0, _i18n.__)('Nested blocks use theme content width with options for full and wide widths.') : (0, _i18n.__)('Nested blocks will fill the width of this container.'))), !inherit && allowSwitching && (0, _element.createElement)(LayoutTypeSwitcher, {
126
167
  type: type,
127
168
  onChange: onChangeType
128
169
  }), !inherit && layoutType && (0, _element.createElement)(layoutType.inspectorControls, {
@@ -222,12 +263,37 @@ const withLayoutStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock
222
263
  default: defaultBlockLayout
223
264
  } = (0, _blocks.getBlockSupport)(name, layoutBlockSupportKey) || {};
224
265
  const usedLayout = layout !== null && layout !== void 0 && layout.inherit ? defaultThemeLayout : layout || defaultBlockLayout || {};
266
+ const layoutClasses = shouldRenderLayoutStyles ? getLayoutClasses(usedLayout, defaultThemeLayout === null || defaultThemeLayout === void 0 ? void 0 : defaultThemeLayout.definitions) : null;
267
+ const selector = `.${(0, _blocks.getBlockDefaultClassName)(name)}.wp-container-${id}`;
268
+ const blockGapSupport = (0, _useSetting.default)('spacing.blockGap');
269
+ const hasBlockGapSupport = blockGapSupport !== null; // Get CSS string for the current layout type.
270
+ // The CSS and `style` element is only output if it is not empty.
271
+
272
+ let css;
273
+
274
+ if (shouldRenderLayoutStyles) {
275
+ var _fullLayoutType$getLa;
276
+
277
+ const fullLayoutType = (0, _layouts.getLayoutType)((usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) || 'default');
278
+ css = fullLayoutType === null || fullLayoutType === void 0 ? void 0 : (_fullLayoutType$getLa = fullLayoutType.getLayoutStyle) === null || _fullLayoutType$getLa === void 0 ? void 0 : _fullLayoutType$getLa.call(fullLayoutType, {
279
+ blockName: name,
280
+ selector,
281
+ layout: usedLayout,
282
+ layoutDefinitions: defaultThemeLayout === null || defaultThemeLayout === void 0 ? void 0 : defaultThemeLayout.definitions,
283
+ style: attributes === null || attributes === void 0 ? void 0 : attributes.style,
284
+ hasBlockGapSupport
285
+ });
286
+ } // Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.
287
+
288
+
225
289
  const className = (0, _classnames.default)(props === null || props === void 0 ? void 0 : props.className, {
226
- [`wp-container-${id}`]: shouldRenderLayoutStyles
227
- });
228
- return (0, _element.createElement)(_element.Fragment, null, shouldRenderLayoutStyles && element && (0, _element.createPortal)((0, _element.createElement)(_layout.LayoutStyle, {
290
+ [`wp-container-${id}`]: shouldRenderLayoutStyles && !!css // Only attach a container class if there is generated CSS to be attached.
291
+
292
+ }, layoutClasses);
293
+ return (0, _element.createElement)(_element.Fragment, null, shouldRenderLayoutStyles && element && !!css && (0, _element.createPortal)((0, _element.createElement)(_layout.LayoutStyle, {
229
294
  blockName: name,
230
- selector: `.wp-container-${id}`,
295
+ selector: selector,
296
+ css: css,
231
297
  layout: usedLayout,
232
298
  style: attributes === null || attributes === void 0 ? void 0 : attributes.style
233
299
  }), element), (0, _element.createElement)(BlockListBlock, (0, _extends2.default)({}, props, {