@wordpress/block-editor 8.0.17 → 8.1.2-next.f435e9e01b.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 (496) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +19 -6
  4. package/build/components/block-caption/index.native.js +14 -3
  5. package/build/components/block-caption/index.native.js.map +1 -1
  6. package/build/components/block-edit/index.js +9 -0
  7. package/build/components/block-edit/index.js.map +1 -1
  8. package/build/components/block-inspector/index.js +14 -19
  9. package/build/components/block-inspector/index.js.map +1 -1
  10. package/build/components/block-list-appender/index.js +3 -11
  11. package/build/components/block-list-appender/index.js.map +1 -1
  12. package/build/components/block-media-update-progress/index.native.js +2 -1
  13. package/build/components/block-media-update-progress/index.native.js.map +1 -1
  14. package/build/components/block-preview/auto.js +10 -2
  15. package/build/components/block-preview/auto.js.map +1 -1
  16. package/build/components/block-settings/container.native.js +2 -1
  17. package/build/components/block-settings/container.native.js.map +1 -1
  18. package/build/components/block-styles/index.js +110 -134
  19. package/build/components/block-styles/index.js.map +1 -1
  20. package/build/components/block-styles/menu-items.js +63 -0
  21. package/build/components/block-styles/menu-items.js.map +1 -0
  22. package/build/components/block-styles/preview-panel.js +45 -0
  23. package/build/components/block-styles/preview-panel.js.map +1 -0
  24. package/build/components/block-styles/preview.native.js +2 -2
  25. package/build/components/block-styles/preview.native.js.map +1 -1
  26. package/build/components/block-styles/use-styles-for-block.js +119 -0
  27. package/build/components/block-styles/use-styles-for-block.js.map +1 -0
  28. package/build/components/block-styles/utils.js +39 -0
  29. package/build/components/block-styles/utils.js.map +1 -1
  30. package/build/components/block-switcher/block-styles-menu.js +3 -23
  31. package/build/components/block-switcher/block-styles-menu.js.map +1 -1
  32. package/build/components/block-tools/back-compat.js +2 -1
  33. package/build/components/block-tools/back-compat.js.map +1 -1
  34. package/build/components/block-tools/block-selection-button.js +5 -1
  35. package/build/components/block-tools/block-selection-button.js.map +1 -1
  36. package/build/components/block-tools/insertion-point.js +11 -1
  37. package/build/components/block-tools/insertion-point.js.map +1 -1
  38. package/build/components/block-types-list/index.native.js +2 -2
  39. package/build/components/block-types-list/index.native.js.map +1 -1
  40. package/build/components/button-block-appender/index.js +2 -1
  41. package/build/components/button-block-appender/index.js.map +1 -1
  42. package/build/components/colors-gradients/dropdown.js +1 -1
  43. package/build/components/colors-gradients/dropdown.js.map +1 -1
  44. package/build/components/colors-gradients/panel-color-gradient-settings.native.js +6 -3
  45. package/build/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
  46. package/build/components/colors-gradients/tools-panel-color-dropdown.js +89 -0
  47. package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
  48. package/build/components/contrast-checker/index.js +80 -44
  49. package/build/components/contrast-checker/index.js.map +1 -1
  50. package/build/components/contrast-checker/index.native.js +108 -0
  51. package/build/components/contrast-checker/index.native.js.map +1 -0
  52. package/build/components/default-block-appender/index.js +16 -19
  53. package/build/components/default-block-appender/index.js.map +1 -1
  54. package/build/components/default-style-picker/index.js +18 -3
  55. package/build/components/default-style-picker/index.js.map +1 -1
  56. package/build/components/iframe/index.js +4 -5
  57. package/build/components/iframe/index.js.map +1 -1
  58. package/build/components/index.js +18 -18
  59. package/build/components/index.js.map +1 -1
  60. package/build/components/index.native.js +18 -0
  61. package/build/components/index.native.js.map +1 -1
  62. package/build/components/inner-blocks/default-block-appender.js +2 -4
  63. package/build/components/inner-blocks/default-block-appender.js.map +1 -1
  64. package/build/components/inner-blocks/use-nested-settings-update.js +16 -14
  65. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  66. package/build/components/inserter/index.js +61 -3
  67. package/build/components/inserter/index.js.map +1 -1
  68. package/build/components/inserter/index.native.js +1 -1
  69. package/build/components/inserter/index.native.js.map +1 -1
  70. package/build/components/inserter/library.js +5 -3
  71. package/build/components/inserter/library.js.map +1 -1
  72. package/build/components/inserter/menu.js +11 -3
  73. package/build/components/inserter/menu.js.map +1 -1
  74. package/build/components/inserter/search-items.js +3 -1
  75. package/build/components/inserter/search-items.js.map +1 -1
  76. package/build/components/inserter/tabs.native.js +7 -4
  77. package/build/components/inserter/tabs.native.js.map +1 -1
  78. package/build/components/inspector-controls/block-support-slot-container.js +2 -1
  79. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
  80. package/build/components/inspector-controls/block-support-tools-panel.js +14 -44
  81. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  82. package/build/components/inspector-controls/fill.native.js +3 -5
  83. package/build/components/inspector-controls/fill.native.js.map +1 -1
  84. package/build/components/inspector-controls/groups.js +4 -0
  85. package/build/components/inspector-controls/groups.js.map +1 -1
  86. package/build/components/inspector-controls/slot.js +1 -3
  87. package/build/components/inspector-controls/slot.js.map +1 -1
  88. package/build/components/letter-spacing-control/index.js +6 -6
  89. package/build/components/letter-spacing-control/index.js.map +1 -1
  90. package/build/components/line-height-control/index.native.js +3 -2
  91. package/build/components/line-height-control/index.native.js.map +1 -1
  92. package/build/components/link-control/link-preview.js +1 -1
  93. package/build/components/link-control/link-preview.js.map +1 -1
  94. package/build/components/link-control/search-item.js +11 -1
  95. package/build/components/link-control/search-item.js.map +1 -1
  96. package/build/components/link-control/search-results.js +2 -1
  97. package/build/components/link-control/search-results.js.map +1 -1
  98. package/build/components/link-control/use-search-handler.js +18 -5
  99. package/build/components/link-control/use-search-handler.js.map +1 -1
  100. package/build/components/list-view/block-contents.js +3 -1
  101. package/build/components/list-view/block-contents.js.map +1 -1
  102. package/build/components/list-view/block-select-button.js +26 -4
  103. package/build/components/list-view/block-select-button.js.map +1 -1
  104. package/build/components/list-view/block.js +10 -1
  105. package/build/components/list-view/block.js.map +1 -1
  106. package/build/components/media-placeholder/index.js +3 -11
  107. package/build/components/media-placeholder/index.js.map +1 -1
  108. package/build/components/media-replace-flow/index.js +32 -6
  109. package/build/components/media-replace-flow/index.js.map +1 -1
  110. package/build/components/media-replace-flow/index.native.js +13 -0
  111. package/build/components/media-replace-flow/index.native.js.map +1 -0
  112. package/build/components/media-upload-progress/index.native.js +2 -1
  113. package/build/components/media-upload-progress/index.native.js.map +1 -1
  114. package/build/components/panel-color-settings/index.js +7 -3
  115. package/build/components/panel-color-settings/index.js.map +1 -1
  116. package/build/components/provider/block-refs-provider.js +4 -1
  117. package/build/components/provider/block-refs-provider.js.map +1 -1
  118. package/build/components/rich-text/file-paste-handler.js +1 -1
  119. package/build/components/rich-text/file-paste-handler.js.map +1 -1
  120. package/build/components/rich-text/index.js +2 -1
  121. package/build/components/rich-text/index.js.map +1 -1
  122. package/build/components/rich-text/index.native.js +2 -1
  123. package/build/components/rich-text/index.native.js.map +1 -1
  124. package/build/components/rich-text/prevent-event-discovery.js +33 -0
  125. package/build/components/rich-text/prevent-event-discovery.js.map +1 -0
  126. package/build/components/rich-text/use-input-rules.js +3 -1
  127. package/build/components/rich-text/use-input-rules.js.map +1 -1
  128. package/build/components/rich-text/use-paste-handler.js +14 -5
  129. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  130. package/build/components/rich-text/utils.js +2 -1
  131. package/build/components/rich-text/utils.js.map +1 -1
  132. package/build/components/selection-scroll-into-view/index.js +2 -1
  133. package/build/components/selection-scroll-into-view/index.js.map +1 -1
  134. package/build/components/use-display-block-controls/index.native.js +45 -0
  135. package/build/components/use-display-block-controls/index.native.js.map +1 -0
  136. package/build/components/use-on-block-drop/index.js +7 -3
  137. package/build/components/use-on-block-drop/index.js.map +1 -1
  138. package/build/components/writing-flow/use-multi-selection.js +3 -1
  139. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  140. package/build/hooks/border-color.js +63 -5
  141. package/build/hooks/border-color.js.map +1 -1
  142. package/build/hooks/border-radius.js +47 -0
  143. package/build/hooks/border-radius.js.map +1 -1
  144. package/build/hooks/border-style.js +41 -0
  145. package/build/hooks/border-style.js.map +1 -1
  146. package/build/hooks/border-width.js +70 -31
  147. package/build/hooks/border-width.js.map +1 -1
  148. package/build/hooks/border.js +81 -11
  149. package/build/hooks/border.js.map +1 -1
  150. package/build/hooks/color-panel.js +25 -16
  151. package/build/hooks/color-panel.js.map +1 -1
  152. package/build/hooks/color-panel.native.js +77 -0
  153. package/build/hooks/color-panel.native.js.map +1 -0
  154. package/build/hooks/color.js +179 -12
  155. package/build/hooks/color.js.map +1 -1
  156. package/build/hooks/font-size.js +14 -0
  157. package/build/hooks/font-size.js.map +1 -1
  158. package/build/hooks/index.native.js +2 -0
  159. package/build/hooks/index.native.js.map +1 -1
  160. package/build/hooks/layout.native.js +20 -0
  161. package/build/hooks/layout.native.js.map +1 -0
  162. package/build/hooks/letter-spacing.js +1 -1
  163. package/build/hooks/letter-spacing.js.map +1 -1
  164. package/build/hooks/typography.js +1 -1
  165. package/build/hooks/typography.js.map +1 -1
  166. package/build/hooks/typography.native.js +2 -4
  167. package/build/hooks/typography.native.js.map +1 -1
  168. package/build/hooks/utils.js +55 -0
  169. package/build/hooks/utils.js.map +1 -1
  170. package/build/store/actions.js +1 -2
  171. package/build/store/actions.js.map +1 -1
  172. package/build/store/defaults.js +5 -2
  173. package/build/store/defaults.js.map +1 -1
  174. package/build/store/defaults.native.js +2 -6
  175. package/build/store/defaults.native.js.map +1 -1
  176. package/build/store/selectors.js +10 -5
  177. package/build/store/selectors.js.map +1 -1
  178. package/build/utils/get-paste-event-data.js +1 -1
  179. package/build/utils/get-paste-event-data.js.map +1 -1
  180. package/build/utils/parse-css-unit-to-px.js +1 -1
  181. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  182. package/build-module/components/block-caption/index.native.js +13 -3
  183. package/build-module/components/block-caption/index.native.js.map +1 -1
  184. package/build-module/components/block-edit/index.js +9 -0
  185. package/build-module/components/block-edit/index.js.map +1 -1
  186. package/build-module/components/block-inspector/index.js +14 -19
  187. package/build-module/components/block-inspector/index.js.map +1 -1
  188. package/build-module/components/block-list-appender/index.js +3 -10
  189. package/build-module/components/block-list-appender/index.js.map +1 -1
  190. package/build-module/components/block-media-update-progress/index.native.js +2 -1
  191. package/build-module/components/block-media-update-progress/index.native.js.map +1 -1
  192. package/build-module/components/block-preview/auto.js +10 -2
  193. package/build-module/components/block-preview/auto.js.map +1 -1
  194. package/build-module/components/block-settings/container.native.js +2 -1
  195. package/build-module/components/block-settings/container.native.js.map +1 -1
  196. package/build-module/components/block-styles/index.js +112 -133
  197. package/build-module/components/block-styles/index.js.map +1 -1
  198. package/build-module/components/block-styles/menu-items.js +50 -0
  199. package/build-module/components/block-styles/menu-items.js.map +1 -0
  200. package/build-module/components/block-styles/preview-panel.js +35 -0
  201. package/build-module/components/block-styles/preview-panel.js.map +1 -0
  202. package/build-module/components/block-styles/preview.native.js +2 -2
  203. package/build-module/components/block-styles/preview.native.js.map +1 -1
  204. package/build-module/components/block-styles/use-styles-for-block.js +107 -0
  205. package/build-module/components/block-styles/use-styles-for-block.js.map +1 -0
  206. package/build-module/components/block-styles/utils.js +34 -0
  207. package/build-module/components/block-styles/utils.js.map +1 -1
  208. package/build-module/components/block-switcher/block-styles-menu.js +3 -21
  209. package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
  210. package/build-module/components/block-tools/back-compat.js +2 -1
  211. package/build-module/components/block-tools/back-compat.js.map +1 -1
  212. package/build-module/components/block-tools/block-selection-button.js +5 -1
  213. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  214. package/build-module/components/block-tools/insertion-point.js +11 -1
  215. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  216. package/build-module/components/block-types-list/index.native.js +2 -2
  217. package/build-module/components/block-types-list/index.native.js.map +1 -1
  218. package/build-module/components/button-block-appender/index.js +2 -1
  219. package/build-module/components/button-block-appender/index.js.map +1 -1
  220. package/build-module/components/colors-gradients/dropdown.js +1 -1
  221. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  222. package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js +7 -4
  223. package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
  224. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +75 -0
  225. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
  226. package/build-module/components/contrast-checker/index.js +80 -45
  227. package/build-module/components/contrast-checker/index.js.map +1 -1
  228. package/build-module/components/contrast-checker/index.native.js +90 -0
  229. package/build-module/components/contrast-checker/index.native.js.map +1 -0
  230. package/build-module/components/default-block-appender/index.js +15 -18
  231. package/build-module/components/default-block-appender/index.js.map +1 -1
  232. package/build-module/components/default-style-picker/index.js +17 -3
  233. package/build-module/components/default-style-picker/index.js.map +1 -1
  234. package/build-module/components/iframe/index.js +4 -5
  235. package/build-module/components/iframe/index.js.map +1 -1
  236. package/build-module/components/index.js +2 -2
  237. package/build-module/components/index.js.map +1 -1
  238. package/build-module/components/index.native.js +2 -0
  239. package/build-module/components/index.native.js.map +1 -1
  240. package/build-module/components/inner-blocks/default-block-appender.js +2 -4
  241. package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
  242. package/build-module/components/inner-blocks/use-nested-settings-update.js +16 -14
  243. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  244. package/build-module/components/inserter/index.js +61 -3
  245. package/build-module/components/inserter/index.js.map +1 -1
  246. package/build-module/components/inserter/index.native.js +2 -2
  247. package/build-module/components/inserter/index.native.js.map +1 -1
  248. package/build-module/components/inserter/library.js +5 -3
  249. package/build-module/components/inserter/library.js.map +1 -1
  250. package/build-module/components/inserter/menu.js +11 -4
  251. package/build-module/components/inserter/menu.js.map +1 -1
  252. package/build-module/components/inserter/search-items.js +3 -1
  253. package/build-module/components/inserter/search-items.js.map +1 -1
  254. package/build-module/components/inserter/tabs.native.js +7 -4
  255. package/build-module/components/inserter/tabs.native.js.map +1 -1
  256. package/build-module/components/inspector-controls/block-support-slot-container.js +2 -1
  257. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
  258. package/build-module/components/inspector-controls/block-support-tools-panel.js +15 -44
  259. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  260. package/build-module/components/inspector-controls/fill.native.js +3 -5
  261. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  262. package/build-module/components/inspector-controls/groups.js +4 -0
  263. package/build-module/components/inspector-controls/groups.js.map +1 -1
  264. package/build-module/components/inspector-controls/slot.js +1 -3
  265. package/build-module/components/inspector-controls/slot.js.map +1 -1
  266. package/build-module/components/letter-spacing-control/index.js +6 -6
  267. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  268. package/build-module/components/line-height-control/index.native.js +3 -2
  269. package/build-module/components/line-height-control/index.native.js.map +1 -1
  270. package/build-module/components/link-control/link-preview.js +1 -1
  271. package/build-module/components/link-control/link-preview.js.map +1 -1
  272. package/build-module/components/link-control/search-item.js +11 -1
  273. package/build-module/components/link-control/search-item.js.map +1 -1
  274. package/build-module/components/link-control/search-results.js +2 -1
  275. package/build-module/components/link-control/search-results.js.map +1 -1
  276. package/build-module/components/link-control/use-search-handler.js +18 -5
  277. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  278. package/build-module/components/list-view/block-contents.js +3 -1
  279. package/build-module/components/list-view/block-contents.js.map +1 -1
  280. package/build-module/components/list-view/block-select-button.js +25 -4
  281. package/build-module/components/list-view/block-select-button.js.map +1 -1
  282. package/build-module/components/list-view/block.js +8 -1
  283. package/build-module/components/list-view/block.js.map +1 -1
  284. package/build-module/components/media-placeholder/index.js +3 -10
  285. package/build-module/components/media-placeholder/index.js.map +1 -1
  286. package/build-module/components/media-replace-flow/index.js +32 -6
  287. package/build-module/components/media-replace-flow/index.js.map +1 -1
  288. package/build-module/components/media-replace-flow/index.native.js +4 -0
  289. package/build-module/components/media-replace-flow/index.native.js.map +1 -0
  290. package/build-module/components/media-upload-progress/index.native.js +2 -1
  291. package/build-module/components/media-upload-progress/index.native.js.map +1 -1
  292. package/build-module/components/panel-color-settings/index.js +7 -3
  293. package/build-module/components/panel-color-settings/index.js.map +1 -1
  294. package/build-module/components/provider/block-refs-provider.js +4 -1
  295. package/build-module/components/provider/block-refs-provider.js.map +1 -1
  296. package/build-module/components/rich-text/file-paste-handler.js +1 -1
  297. package/build-module/components/rich-text/file-paste-handler.js.map +1 -1
  298. package/build-module/components/rich-text/index.js +2 -1
  299. package/build-module/components/rich-text/index.js.map +1 -1
  300. package/build-module/components/rich-text/index.native.js +2 -1
  301. package/build-module/components/rich-text/index.native.js.map +1 -1
  302. package/build-module/components/rich-text/prevent-event-discovery.js +25 -0
  303. package/build-module/components/rich-text/prevent-event-discovery.js.map +1 -0
  304. package/build-module/components/rich-text/use-input-rules.js +2 -1
  305. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  306. package/build-module/components/rich-text/use-paste-handler.js +14 -5
  307. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  308. package/build-module/components/rich-text/utils.js +2 -1
  309. package/build-module/components/rich-text/utils.js.map +1 -1
  310. package/build-module/components/selection-scroll-into-view/index.js +2 -1
  311. package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
  312. package/build-module/components/use-display-block-controls/index.native.js +34 -0
  313. package/build-module/components/use-display-block-controls/index.native.js.map +1 -0
  314. package/build-module/components/use-on-block-drop/index.js +7 -3
  315. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  316. package/build-module/components/writing-flow/use-multi-selection.js +3 -4
  317. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  318. package/build-module/hooks/border-color.js +61 -7
  319. package/build-module/hooks/border-color.js.map +1 -1
  320. package/build-module/hooks/border-radius.js +42 -0
  321. package/build-module/hooks/border-radius.js.map +1 -1
  322. package/build-module/hooks/border-style.js +36 -0
  323. package/build-module/hooks/border-style.js.map +1 -1
  324. package/build-module/hooks/border-width.js +66 -32
  325. package/build-module/hooks/border-width.js.map +1 -1
  326. package/build-module/hooks/border.js +80 -12
  327. package/build-module/hooks/border.js.map +1 -1
  328. package/build-module/hooks/color-panel.js +24 -14
  329. package/build-module/hooks/color-panel.js.map +1 -1
  330. package/build-module/hooks/color-panel.native.js +62 -0
  331. package/build-module/hooks/color-panel.native.js.map +1 -0
  332. package/build-module/hooks/color.js +177 -13
  333. package/build-module/hooks/color.js.map +1 -1
  334. package/build-module/hooks/font-size.js +12 -1
  335. package/build-module/hooks/font-size.js.map +1 -1
  336. package/build-module/hooks/index.native.js +1 -0
  337. package/build-module/hooks/index.native.js.map +1 -1
  338. package/build-module/hooks/layout.native.js +16 -0
  339. package/build-module/hooks/layout.native.js.map +1 -0
  340. package/build-module/hooks/letter-spacing.js +1 -1
  341. package/build-module/hooks/letter-spacing.js.map +1 -1
  342. package/build-module/hooks/typography.js +1 -1
  343. package/build-module/hooks/typography.js.map +1 -1
  344. package/build-module/hooks/typography.native.js +2 -4
  345. package/build-module/hooks/typography.native.js.map +1 -1
  346. package/build-module/hooks/utils.js +52 -1
  347. package/build-module/hooks/utils.js.map +1 -1
  348. package/build-module/store/actions.js +1 -2
  349. package/build-module/store/actions.js.map +1 -1
  350. package/build-module/store/defaults.js +5 -2
  351. package/build-module/store/defaults.js.map +1 -1
  352. package/build-module/store/defaults.native.js +2 -5
  353. package/build-module/store/defaults.native.js.map +1 -1
  354. package/build-module/store/selectors.js +10 -5
  355. package/build-module/store/selectors.js.map +1 -1
  356. package/build-module/utils/get-paste-event-data.js +1 -1
  357. package/build-module/utils/get-paste-event-data.js.map +1 -1
  358. package/build-module/utils/parse-css-unit-to-px.js +1 -1
  359. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  360. package/build-style/style-rtl.css +256 -191
  361. package/build-style/style.css +256 -191
  362. package/package.json +30 -30
  363. package/src/components/block-caption/index.native.js +22 -4
  364. package/src/components/block-card/README.md +1 -1
  365. package/src/components/block-edit/index.js +8 -0
  366. package/src/components/block-edit/test/edit.native.js +10 -9
  367. package/src/components/block-inspector/index.js +18 -16
  368. package/src/components/block-list-appender/index.js +5 -21
  369. package/src/components/block-media-update-progress/index.native.js +1 -1
  370. package/src/components/block-media-update-progress/test/index.native.js +136 -93
  371. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +108 -47
  372. package/src/components/block-mover/test/index.native.js +5 -5
  373. package/src/components/block-preview/README.md +14 -26
  374. package/src/components/block-preview/auto.js +7 -2
  375. package/src/components/block-preview/test/index.js +2 -0
  376. package/src/components/block-settings/container.native.js +1 -0
  377. package/src/components/block-styles/index.js +125 -145
  378. package/src/components/block-styles/menu-items.js +49 -0
  379. package/src/components/block-styles/preview-panel.js +36 -0
  380. package/src/components/block-styles/preview.native.js +5 -2
  381. package/src/components/block-styles/style.scss +59 -51
  382. package/src/components/block-styles/test/{index.js → utils.js} +60 -1
  383. package/src/components/block-styles/use-styles-for-block.js +99 -0
  384. package/src/components/block-styles/utils.js +39 -0
  385. package/src/components/block-switcher/block-styles-menu.js +3 -38
  386. package/src/components/block-tools/back-compat.js +1 -0
  387. package/src/components/block-tools/block-selection-button.js +7 -1
  388. package/src/components/block-tools/insertion-point.js +10 -1
  389. package/src/components/block-types-list/index.native.js +5 -2
  390. package/src/components/border-radius-control/style.scss +1 -1
  391. package/src/components/border-style-control/style.scss +0 -1
  392. package/src/components/button-block-appender/index.js +1 -0
  393. package/src/components/color-palette/test/__snapshots__/control.js.snap +9 -5
  394. package/src/components/colors-gradients/dropdown.js +48 -43
  395. package/src/components/colors-gradients/panel-color-gradient-settings.native.js +13 -2
  396. package/src/components/colors-gradients/style.scss +10 -5
  397. package/src/components/colors-gradients/tools-panel-color-dropdown.js +85 -0
  398. package/src/components/contrast-checker/README.md +3 -1
  399. package/src/components/contrast-checker/index.js +107 -64
  400. package/src/components/contrast-checker/index.native.js +113 -0
  401. package/src/components/contrast-checker/style.native.scss +26 -0
  402. package/src/components/contrast-checker/test/index.js +236 -2
  403. package/src/components/default-block-appender/index.js +17 -24
  404. package/src/components/default-block-appender/style.scss +4 -0
  405. package/src/components/default-block-appender/test/__snapshots__/index.js.snap +12 -24
  406. package/src/components/default-block-appender/test/index.js +4 -14
  407. package/src/components/default-style-picker/index.js +18 -6
  408. package/src/components/iframe/index.js +7 -3
  409. package/src/components/index.js +2 -2
  410. package/src/components/index.native.js +2 -0
  411. package/src/components/inner-blocks/README.md +2 -0
  412. package/src/components/inner-blocks/default-block-appender.js +2 -7
  413. package/src/components/inner-blocks/use-nested-settings-update.js +16 -14
  414. package/src/components/inserter/index.js +77 -5
  415. package/src/components/inserter/index.native.js +2 -2
  416. package/src/components/inserter/library.js +17 -12
  417. package/src/components/inserter/menu.js +31 -13
  418. package/src/components/inserter/search-items.js +3 -1
  419. package/src/components/inserter/tabs.native.js +5 -4
  420. package/src/components/inserter/test/block-types-tab.native.js +9 -10
  421. package/src/components/inserter/test/index.native.js +3 -7
  422. package/src/components/inserter/test/reusable-blocks-tab.native.js +8 -10
  423. package/src/components/inspector-controls/block-support-slot-container.js +3 -1
  424. package/src/components/inspector-controls/block-support-tools-panel.js +41 -58
  425. package/src/components/inspector-controls/fill.native.js +4 -3
  426. package/src/components/inspector-controls/groups.js +4 -0
  427. package/src/components/inspector-controls/slot.js +2 -7
  428. package/src/components/letter-spacing-control/index.js +6 -6
  429. package/src/components/line-height-control/index.native.js +2 -1
  430. package/src/components/link-control/README.md +1 -1
  431. package/src/components/link-control/link-preview.js +1 -1
  432. package/src/components/link-control/search-item.js +11 -2
  433. package/src/components/link-control/search-results.js +1 -0
  434. package/src/components/link-control/style.scss +5 -10
  435. package/src/components/link-control/test/index.js +4 -0
  436. package/src/components/link-control/use-search-handler.js +25 -4
  437. package/src/components/list-view/block-contents.js +2 -0
  438. package/src/components/list-view/block-select-button.js +22 -1
  439. package/src/components/list-view/block.js +11 -0
  440. package/src/components/media-placeholder/index.js +3 -10
  441. package/src/components/media-replace-flow/index.js +35 -5
  442. package/src/components/media-replace-flow/index.native.js +3 -0
  443. package/src/components/media-upload/test/index.native.js +28 -47
  444. package/src/components/media-upload-progress/index.native.js +1 -0
  445. package/src/components/media-upload-progress/test/index.native.js +60 -47
  446. package/src/components/panel-color-settings/index.js +8 -4
  447. package/src/components/provider/block-refs-provider.js +4 -1
  448. package/src/components/rich-text/file-paste-handler.js +3 -1
  449. package/src/components/rich-text/index.js +1 -0
  450. package/src/components/rich-text/index.native.js +1 -0
  451. package/src/components/rich-text/prevent-event-discovery.js +23 -0
  452. package/src/components/rich-text/use-input-rules.js +2 -1
  453. package/src/components/rich-text/use-paste-handler.js +16 -3
  454. package/src/components/rich-text/utils.js +1 -0
  455. package/src/components/selection-scroll-into-view/index.js +1 -0
  456. package/src/components/url-input/README.md +5 -0
  457. package/src/components/use-display-block-controls/index.native.js +38 -0
  458. package/src/components/use-on-block-drop/index.js +7 -3
  459. package/src/components/writing-flow/test/use-multi-selection.js +36 -0
  460. package/src/components/writing-flow/use-multi-selection.js +12 -9
  461. package/src/hooks/border-color.js +55 -3
  462. package/src/hooks/border-radius.js +32 -0
  463. package/src/hooks/border-style.js +26 -0
  464. package/src/hooks/border-width.js +56 -32
  465. package/src/hooks/border.js +115 -20
  466. package/src/hooks/border.scss +3 -17
  467. package/src/hooks/color-panel.js +25 -19
  468. package/src/hooks/color-panel.native.js +63 -0
  469. package/src/hooks/color.js +182 -12
  470. package/src/hooks/color.scss +85 -0
  471. package/src/hooks/font-size.js +29 -1
  472. package/src/hooks/index.native.js +1 -0
  473. package/src/hooks/layout.native.js +23 -0
  474. package/src/hooks/letter-spacing.js +1 -1
  475. package/src/hooks/typography.js +1 -1
  476. package/src/hooks/typography.native.js +1 -3
  477. package/src/hooks/utils.js +69 -1
  478. package/src/store/actions.js +1 -2
  479. package/src/store/defaults.js +2 -1
  480. package/src/store/defaults.native.js +2 -6
  481. package/src/store/selectors.js +10 -5
  482. package/src/style.scss +4 -3
  483. package/src/utils/get-paste-event-data.js +1 -1
  484. package/src/utils/parse-css-unit-to-px.js +1 -1
  485. package/src/utils/test/parse-css-unit-to-px.js +3 -0
  486. package/tsconfig.tsbuildinfo +1 -1
  487. package/build/components/preserve-scroll-in-reorder/index.js +0 -22
  488. package/build/components/preserve-scroll-in-reorder/index.js.map +0 -1
  489. package/build/components/use-canvas-click-redirect/index.js +0 -66
  490. package/build/components/use-canvas-click-redirect/index.js.map +0 -1
  491. package/build-module/components/preserve-scroll-in-reorder/index.js +0 -12
  492. package/build-module/components/preserve-scroll-in-reorder/index.js.map +0 -1
  493. package/build-module/components/use-canvas-click-redirect/index.js +0 -54
  494. package/build-module/components/use-canvas-click-redirect/index.js.map +0 -1
  495. package/src/components/preserve-scroll-in-reorder/index.js +0 -12
  496. package/src/components/use-canvas-click-redirect/index.js +0 -57
@@ -21,7 +21,8 @@ var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
21
21
  */
22
22
  function MultiSelectScrollIntoView() {
23
23
  (0, _deprecated.default)('wp.blockEditor.MultiSelectScrollIntoView', {
24
- hint: 'This behaviour is now built-in.'
24
+ hint: 'This behaviour is now built-in.',
25
+ since: '5.8'
25
26
  });
26
27
  return null;
27
28
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/selection-scroll-into-view/index.js"],"names":["MultiSelectScrollIntoView","hint"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,yBAAT,GAAqC;AAC3C,2BAAY,0CAAZ,EAAwD;AACvDC,IAAAA,IAAI,EAAE;AADiD,GAAxD;AAGA,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Scrolls the multi block selection end into view if not in view already. This\n * is important to do after selection by keyboard.\n *\n * @deprecated\n */\nexport function MultiSelectScrollIntoView() {\n\tdeprecated( 'wp.blockEditor.MultiSelectScrollIntoView', {\n\t\thint: 'This behaviour is now built-in.',\n\t} );\n\treturn null;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/selection-scroll-into-view/index.js"],"names":["MultiSelectScrollIntoView","hint","since"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,yBAAT,GAAqC;AAC3C,2BAAY,0CAAZ,EAAwD;AACvDC,IAAAA,IAAI,EAAE,iCADiD;AAEvDC,IAAAA,KAAK,EAAE;AAFgD,GAAxD;AAIA,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Scrolls the multi block selection end into view if not in view already. This\n * is important to do after selection by keyboard.\n *\n * @deprecated\n */\nexport function MultiSelectScrollIntoView() {\n\tdeprecated( 'wp.blockEditor.MultiSelectScrollIntoView', {\n\t\thint: 'This behaviour is now built-in.',\n\t\tsince: '5.8',\n\t} );\n\treturn null;\n}\n"]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useDisplayBlockControls;
7
+
8
+ var _data = require("@wordpress/data");
9
+
10
+ var _blocks = require("@wordpress/blocks");
11
+
12
+ var _context = require("../block-edit/context");
13
+
14
+ var _store = require("../../store");
15
+
16
+ /**
17
+ * WordPress dependencies
18
+ */
19
+
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+ function useDisplayBlockControls() {
24
+ const {
25
+ isSelected,
26
+ clientId,
27
+ name
28
+ } = (0, _context.useBlockEditContext)();
29
+ return (0, _data.useSelect)(select => {
30
+ const {
31
+ getBlockName,
32
+ getBlockRootClientId
33
+ } = select(_store.store);
34
+ const parentId = getBlockRootClientId(clientId);
35
+ const parentBlockName = getBlockName(parentId);
36
+ const hideControls = (0, _blocks.hasBlockSupport)(parentBlockName, '__experimentalHideChildBlockControls', false);
37
+
38
+ if (!hideControls && isSelected) {
39
+ return true;
40
+ }
41
+
42
+ return false;
43
+ }, [clientId, isSelected, name]);
44
+ }
45
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-display-block-controls/index.native.js"],"names":["useDisplayBlockControls","isSelected","clientId","name","select","getBlockName","getBlockRootClientId","blockEditorStore","parentId","parentBlockName","hideControls"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,uBAAT,GAAmC;AACjD,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,QAAd;AAAwBC,IAAAA;AAAxB,MAAiC,mCAAvC;AACA,SAAO,qBACJC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QAAyCF,MAAM,CACpDG,YADoD,CAArD;AAIA,UAAMC,QAAQ,GAAGF,oBAAoB,CAAEJ,QAAF,CAArC;AACA,UAAMO,eAAe,GAAGJ,YAAY,CAAEG,QAAF,CAApC;AAEA,UAAME,YAAY,GAAG,6BACpBD,eADoB,EAEpB,sCAFoB,EAGpB,KAHoB,CAArB;;AAMA,QAAK,CAAEC,YAAF,IAAkBT,UAAvB,EAAoC;AACnC,aAAO,IAAP;AACA;;AAED,WAAO,KAAP;AACA,GApBK,EAqBN,CAAEC,QAAF,EAAYD,UAAZ,EAAwBE,IAAxB,CArBM,CAAP;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit/context';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useDisplayBlockControls() {\n\tconst { isSelected, clientId, name } = useBlockEditContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockRootClientId } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\n\t\t\tconst parentId = getBlockRootClientId( clientId );\n\t\t\tconst parentBlockName = getBlockName( parentId );\n\n\t\t\tconst hideControls = hasBlockSupport(\n\t\t\t\tparentBlockName,\n\t\t\t\t'__experimentalHideChildBlockControls',\n\t\t\t\tfalse\n\t\t\t);\n\n\t\t\tif ( ! hideControls && isSelected ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t\t[ clientId, isSelected, name ]\n\t);\n}\n"]}
@@ -193,11 +193,15 @@ function useOnBlockDrop(targetRootClientId, targetBlockIndex) {
193
193
  return event => {
194
194
  const files = (0, _dom.getFilesFromDataTransfer)(event.dataTransfer);
195
195
  const html = event.dataTransfer.getData('text/html');
196
+ /**
197
+ * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
198
+ * The order of the checks is important to recognise the HTML drop.
199
+ */
196
200
 
197
- if (files.length) {
198
- _onFilesDrop(files);
199
- } else if (html) {
201
+ if (html) {
200
202
  _onHTMLDrop(html);
203
+ } else if (files.length) {
204
+ _onFilesDrop(files);
201
205
  } else {
202
206
  _onDrop(event);
203
207
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.js"],"names":["parseDropEvent","event","result","srcRootClientId","srcClientIds","srcIndex","type","blocks","dataTransfer","Object","assign","JSON","parse","getData","err","onBlockDrop","targetRootClientId","targetBlockIndex","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","sourceRootClientId","sourceClientIds","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","onFilesDrop","hasUploadPermissions","updateBlockAttributes","canInsertBlockType","files","transformation","transform","blockName","isMatch","onHTMLDrop","HTML","mode","useOnBlockDrop","select","blockEditorStore","getSettings","mediaUpload","_onDrop","_onFilesDrop","_onHTMLDrop","html"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,KAAzB,EAAiC;AACvC,MAAIC,MAAM,GAAG;AACZC,IAAAA,eAAe,EAAE,IADL;AAEZC,IAAAA,YAAY,EAAE,IAFF;AAGZC,IAAAA,QAAQ,EAAE,IAHE;AAIZC,IAAAA,IAAI,EAAE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a;AACnB,UAAMwC,KAAK,GAAG,mCAA0BxC,KAAK,CAACO,YAAhC,CAAd;AACA,UAAMiD,IAAI,GAAGxD,KAAK,CAACO,YAAN,CAAmBK,OAAnB,CAA4B,WAA5B,CAAb;;AAEA,QAAK4B,KAAK,CAACN,MAAX,EAAoB;AACnBoB,MAAAA,YAAY,CAAEd,KAAF,CAAZ;AACA,KAFD,MAEO,IAAKgB,IAAL,EAAY;AAClBD,MAAAA,WAAW,CAAEC,IAAF,CAAX;AACA,KAFM,MAEA;AACNH,MAAAA,OAAO,CAAErD,KAAF,CAAP;AACA;AACD,GAXD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcloneBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {WPSyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch ( err ) {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocksToPosition A function that moves blocks.\n * @param {Function} insertBlocks A function that inserts blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertBlocks(\n\t\t\t\tblocksToInsert,\n\t\t\t\ttargetBlockIndex,\n\t\t\t\ttargetRootClientId,\n\t\t\t\ttrue,\n\t\t\t\tnull\n\t\t\t);\n\t\t}\n\n\t\t// If the user is moving a block\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocksToPosition(\n\t\t\t\tsourceClientIds,\n\t\t\t\tsourceRootClientId,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tinsertIndex\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {boolean} hasUploadPermissions Whether the user has upload permissions.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\thasUploadPermissions,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! hasUploadPermissions ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tinsertBlocks\n) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n *\n * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.\n */\nexport default function useOnBlockDrop( targetRootClientId, targetBlockIndex ) {\n\tconst hasUploadPermissions = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t} = useDispatch( blockEditorStore );\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\thasUploadPermissions,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tinsertBlocks\n\t);\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\tif ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else if ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.js"],"names":["parseDropEvent","event","result","srcRootClientId","srcClientIds","srcIndex","type","blocks","dataTransfer","Object","assign","JSON","parse","getData","err","onBlockDrop","targetRootClientId","targetBlockIndex","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","sourceRootClientId","sourceClientIds","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","onFilesDrop","hasUploadPermissions","updateBlockAttributes","canInsertBlockType","files","transformation","transform","blockName","isMatch","onHTMLDrop","HTML","mode","useOnBlockDrop","select","blockEditorStore","getSettings","mediaUpload","_onDrop","_onFilesDrop","_onHTMLDrop","html"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,KAAzB,EAAiC;AACvC,MAAIC,MAAM,GAAG;AACZC,IAAAA,eAAe,EAAE,IADL;AAEZC,IAAAA,YAAY,EAAE,IAFF;AAGZC,IAAAA,QAAQ,EAAE,IAHE;AAIZC,IAAAA,IAAI,EAAE,IAJM;AAKZC,IAAAA,MAAM,EAAE;AALI,GAAb;;AAQA,MAAK,CAAEN,KAAK,CAACO,YAAb,EAA4B;AAC3B,WAAON,MAAP;AACA;;AAED,MAAI;AACHA,IAAAA,MAAM,GAAGO,MAAM,CAACC,MAAP,CACRR,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K4C,IAAL,EAAY;AACXD,MAAAA,WAAW,CAAEC,IAAF,CAAX;AACA,KAFD,MAEO,IAAKhB,KAAK,CAACN,MAAX,EAAoB;AAC1BoB,MAAAA,YAAY,CAAEd,KAAF,CAAZ;AACA,KAFM,MAEA;AACNa,MAAAA,OAAO,CAAErD,KAAF,CAAP;AACA;AACD,GAfD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcloneBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {WPSyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch ( err ) {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocksToPosition A function that moves blocks.\n * @param {Function} insertBlocks A function that inserts blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertBlocks(\n\t\t\t\tblocksToInsert,\n\t\t\t\ttargetBlockIndex,\n\t\t\t\ttargetRootClientId,\n\t\t\t\ttrue,\n\t\t\t\tnull\n\t\t\t);\n\t\t}\n\n\t\t// If the user is moving a block\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocksToPosition(\n\t\t\t\tsourceClientIds,\n\t\t\t\tsourceRootClientId,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tinsertIndex\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {boolean} hasUploadPermissions Whether the user has upload permissions.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\thasUploadPermissions,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! hasUploadPermissions ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tinsertBlocks\n) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n *\n * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.\n */\nexport default function useOnBlockDrop( targetRootClientId, targetBlockIndex ) {\n\tconst hasUploadPermissions = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t} = useDispatch( blockEditorStore );\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\thasUploadPermissions,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tinsertBlocks\n\t);\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"]}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useMultiSelection;
7
+ exports.toggleRichText = toggleRichText;
7
8
 
8
9
  var _lodash = require("lodash");
9
10
 
@@ -27,7 +28,8 @@ var _useBlockRefs = require("../block-list/use-block-props/use-block-refs");
27
28
  * Internal dependencies
28
29
  */
29
30
  function toggleRichText(container, toggle) {
30
- Array.from(container.querySelectorAll('.rich-text')).forEach(node => {
31
+ Array.from(container.querySelectorAll( // Exclude the Post Title from multi-select disable.
32
+ '.rich-text:not( .editor-post-title__input )')).forEach(node => {
31
33
  if (toggle) {
32
34
  node.setAttribute('contenteditable', true);
33
35
  } else {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-multi-selection.js"],"names":["toggleRichText","container","toggle","Array","from","querySelectorAll","forEach","node","setAttribute","removeAttribute","getDeepestNode","type","child","sibling","nodeType","TEXT_NODE","test","data","selector","select","isMultiSelecting","getMultiSelectedBlockClientIds","hasMultiSelection","getSelectedBlockClientId","blockEditorStore","multiSelectedBlockClientIds","selectedBlockClientId","useMultiSelection","selectedRef","startRef","endRef","ownerDocument","defaultView","selection","getSelection","rangeCount","isCollapsed","blockNode","current","startContainer","endContainer","getRangeAt","contains","removeAllRanges","length","focus","range","createRange","startNode","endNode","setStartBefore","setEndAfter","addRange"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,cAAT,CAAyBC,SAAzB,EAAoCC,MAApC,EAA6C;AAC5CC,E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,MAAM,CAACQ,OAApC,EAA8C;AAC7C;AACA,KAxCU,CA0CX;AACA;;;AACA/B,IAAAA,IAAI,CAACsC,KAAL;AAEA,UAAMZ,SAAS,GAAGD,WAAW,CAACE,YAAZ,EAAlB;AACA,UAAMY,KAAK,GAAGf,aAAa,CAACgB,WAAd,EAAd,CA/CW,CAiDX;AACA;AACA;;AACA,UAAMC,SAAS,GAAGtC,cAAc,CAAEmB,QAAQ,CAACS,OAAX,EAAoB,OAApB,CAAhC;AACA,UAAMW,OAAO,GAAGvC,cAAc,CAAEoB,MAAM,CAACQ,OAAT,EAAkB,KAAlB,CAA9B,CArDW,CAuDX;AACA;AACA;;AACAtC,IAAAA,cAAc,CAAEO,IAAF,EAAQ,KAAR,CAAd;AAEAuC,IAAAA,KAAK,CAACI,cAAN,CAAsBF,SAAtB;AACAF,IAAAA,KAAK,CAACK,WAAN,CAAmBF,OAAnB;AAEAhB,IAAAA,SAAS,CAACU,eAAV;AACAV,IAAAA,SAAS,CAACmB,QAAV,CAAoBN,KAApB;AACA,GAlEK,EAmEN,CACCxB,iBADD,EAECF,gBAFD,EAGCK,2BAHD,EAICC,qBAJD,CAnEM,CAAP;AA0EA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\n\nfunction toggleRichText( container, toggle ) {\n\tArray.from( container.querySelectorAll( '.rich-text' ) ).forEach(\n\t\t( node ) => {\n\t\t\tif ( toggle ) {\n\t\t\t\tnode.setAttribute( 'contenteditable', true );\n\t\t\t} else {\n\t\t\t\tnode.removeAttribute( 'contenteditable' );\n\t\t\t}\n\t\t}\n\t);\n}\n\n/**\n * Returns for the deepest node at the start or end of a container node. Ignores\n * any text nodes that only contain HTML formatting whitespace.\n *\n * @param {Element} node Container to search.\n * @param {string} type 'start' or 'end'.\n */\nfunction getDeepestNode( node, type ) {\n\tconst child = type === 'start' ? 'firstChild' : 'lastChild';\n\tconst sibling = type === 'start' ? 'nextSibling' : 'previousSibling';\n\n\twhile ( node[ child ] ) {\n\t\tnode = node[ child ];\n\n\t\twhile (\n\t\t\tnode.nodeType === node.TEXT_NODE &&\n\t\t\t/^[ \\t\\n]*$/.test( node.data ) &&\n\t\t\tnode[ sibling ]\n\t\t) {\n\t\t\tnode = node[ sibling ];\n\t\t}\n\t}\n\n\treturn node;\n}\n\nfunction selector( select ) {\n\tconst {\n\t\tisMultiSelecting,\n\t\tgetMultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tmultiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\tselectedBlockClientId: getSelectedBlockClientId(),\n\t};\n}\n\nexport default function useMultiSelection() {\n\tconst {\n\t\tisMultiSelecting,\n\t\tmultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tselectedBlockClientId,\n\t} = useSelect( selector, [] );\n\tconst selectedRef = useBlockRef( selectedBlockClientId );\n\t// These must be in the right DOM order.\n\tconst startRef = useBlockRef( first( multiSelectedBlockClientIds ) );\n\tconst endRef = useBlockRef( last( multiSelectedBlockClientIds ) );\n\n\t/**\n\t * When the component updates, and there is multi selection, we need to\n\t * select the entire block contents.\n\t */\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! hasMultiSelection || isMultiSelecting ) {\n\t\t\t\tif ( ! selectedBlockClientId || isMultiSelecting ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( selection.rangeCount && ! selection.isCollapsed ) {\n\t\t\t\t\tconst blockNode = selectedRef.current;\n\t\t\t\t\tconst {\n\t\t\t\t\t\tstartContainer,\n\t\t\t\t\t\tendContainer,\n\t\t\t\t\t} = selection.getRangeAt( 0 );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t!! blockNode &&\n\t\t\t\t\t\t( ! blockNode.contains( startContainer ) ||\n\t\t\t\t\t\t\t! blockNode.contains( endContainer ) )\n\t\t\t\t\t) {\n\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { length } = multiSelectedBlockClientIds;\n\n\t\t\tif ( length < 2 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The block refs might not be immediately available\n\t\t\t// when dragging blocks into another block.\n\t\t\tif ( ! startRef.current || ! endRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// For some browsers, like Safari, it is important that focus happens\n\t\t\t// BEFORE selection.\n\t\t\tnode.focus();\n\n\t\t\tconst selection = defaultView.getSelection();\n\t\t\tconst range = ownerDocument.createRange();\n\n\t\t\t// These must be in the right DOM order.\n\t\t\t// The most stable way to select the whole block contents is to start\n\t\t\t// and end at the deepest points.\n\t\t\tconst startNode = getDeepestNode( startRef.current, 'start' );\n\t\t\tconst endNode = getDeepestNode( endRef.current, 'end' );\n\n\t\t\t// While rich text will be disabled with a delay when there is a multi\n\t\t\t// selection, we must do it immediately because it's not possible to set\n\t\t\t// selection across editable hosts.\n\t\t\ttoggleRichText( node, false );\n\n\t\t\trange.setStartBefore( startNode );\n\t\t\trange.setEndAfter( endNode );\n\n\t\t\tselection.removeAllRanges();\n\t\t\tselection.addRange( range );\n\t\t},\n\t\t[\n\t\t\thasMultiSelection,\n\t\t\tisMultiSelecting,\n\t\t\tmultiSelectedBlockClientIds,\n\t\t\tselectedBlockClientId,\n\t\t]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-multi-selection.js"],"names":["toggleRichText","container","toggle","Array","from","querySelectorAll","forEach","node","setAttribute","removeAttribute","getDeepestNode","type","child","sibling","nodeType","TEXT_NODE","test","data","selector","select","isMultiSelecting","getMultiSelectedBlockClientIds","hasMultiSelection","getSelectedBlockClientId","blockEditorStore","multiSelectedBlockClientIds","selectedBlockClientId","useMultiSelection","selectedRef","startRef","endRef","ownerDocument","defaultView","selection","getSelection","rangeCount","isCollapsed","blockNode","current","startContainer","endContainer","getRangeAt","contains","removeAllRanges","length","focus","range","createRange","startNode","endNode","setStartBefore","setEndAfter","addRange"],"mappings":";;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAIO,SAASA,cAAT,CAAyBC,SAAzB,EAAoCC,MAApC,EAA6C;AACnDC,EAAAA,KAAK,CAACC,IAAN,CACCH,SAAS,CAACI,gBAAV,EACC;AACA,+CAFD,CADD,EAKEC,OALF,CAKaC,IAAF,IAAY;AACtB,QAAKL,MAAL,EAAc;AACbK,MAAAA,IAAI,CAACC,YAAL,CAAmB,iBAAnB,EAAsC,IAAtC;AACA,KAFD,MAEO;AACND,MAAAA,IAAI,CAACE,eAAL,CAAsB,iBAAtB;AACA;AACD,GAXD;AAYA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,cAAT,CAAyBH,IAAzB,EAA+BI,IAA/B,EAAsC;AACrC,QAAMC,KAAK,GAAGD,IAAI,KAAK,OAAT,GAAmB,YAAnB,GAAkC,WAAhD;AACA,QAAME,OAAO,GAAGF,IAAI,KAAK,OAAT,GAAmB,aAAnB,GAAmC,iBAAnD;;AAEA,SAAQJ,IAAI,CAAEK,KAAF,CAAZ,EAAwB;AACvBL,IAAAA,IAAI,GAAGA,IAAI,CAAEK,KAAF,CAAX;;AAEA,WACCL,IAAI,CAACO,QAAL,KAAkBP,IAAI,CAACQ,SAAvB,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EAECF,gBAFD,EAGCK,2BAHD,EAICC,qBAJD,CAnEM,CAAP;AA0EA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\n\nexport function toggleRichText( container, toggle ) {\n\tArray.from(\n\t\tcontainer.querySelectorAll(\n\t\t\t// Exclude the Post Title from multi-select disable.\n\t\t\t'.rich-text:not( .editor-post-title__input )'\n\t\t)\n\t).forEach( ( node ) => {\n\t\tif ( toggle ) {\n\t\t\tnode.setAttribute( 'contenteditable', true );\n\t\t} else {\n\t\t\tnode.removeAttribute( 'contenteditable' );\n\t\t}\n\t} );\n}\n\n/**\n * Returns for the deepest node at the start or end of a container node. Ignores\n * any text nodes that only contain HTML formatting whitespace.\n *\n * @param {Element} node Container to search.\n * @param {string} type 'start' or 'end'.\n */\nfunction getDeepestNode( node, type ) {\n\tconst child = type === 'start' ? 'firstChild' : 'lastChild';\n\tconst sibling = type === 'start' ? 'nextSibling' : 'previousSibling';\n\n\twhile ( node[ child ] ) {\n\t\tnode = node[ child ];\n\n\t\twhile (\n\t\t\tnode.nodeType === node.TEXT_NODE &&\n\t\t\t/^[ \\t\\n]*$/.test( node.data ) &&\n\t\t\tnode[ sibling ]\n\t\t) {\n\t\t\tnode = node[ sibling ];\n\t\t}\n\t}\n\n\treturn node;\n}\n\nfunction selector( select ) {\n\tconst {\n\t\tisMultiSelecting,\n\t\tgetMultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tmultiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\tselectedBlockClientId: getSelectedBlockClientId(),\n\t};\n}\n\nexport default function useMultiSelection() {\n\tconst {\n\t\tisMultiSelecting,\n\t\tmultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tselectedBlockClientId,\n\t} = useSelect( selector, [] );\n\tconst selectedRef = useBlockRef( selectedBlockClientId );\n\t// These must be in the right DOM order.\n\tconst startRef = useBlockRef( first( multiSelectedBlockClientIds ) );\n\tconst endRef = useBlockRef( last( multiSelectedBlockClientIds ) );\n\n\t/**\n\t * When the component updates, and there is multi selection, we need to\n\t * select the entire block contents.\n\t */\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! hasMultiSelection || isMultiSelecting ) {\n\t\t\t\tif ( ! selectedBlockClientId || isMultiSelecting ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( selection.rangeCount && ! selection.isCollapsed ) {\n\t\t\t\t\tconst blockNode = selectedRef.current;\n\t\t\t\t\tconst {\n\t\t\t\t\t\tstartContainer,\n\t\t\t\t\t\tendContainer,\n\t\t\t\t\t} = selection.getRangeAt( 0 );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t!! blockNode &&\n\t\t\t\t\t\t( ! blockNode.contains( startContainer ) ||\n\t\t\t\t\t\t\t! blockNode.contains( endContainer ) )\n\t\t\t\t\t) {\n\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { length } = multiSelectedBlockClientIds;\n\n\t\t\tif ( length < 2 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The block refs might not be immediately available\n\t\t\t// when dragging blocks into another block.\n\t\t\tif ( ! startRef.current || ! endRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// For some browsers, like Safari, it is important that focus happens\n\t\t\t// BEFORE selection.\n\t\t\tnode.focus();\n\n\t\t\tconst selection = defaultView.getSelection();\n\t\t\tconst range = ownerDocument.createRange();\n\n\t\t\t// These must be in the right DOM order.\n\t\t\t// The most stable way to select the whole block contents is to start\n\t\t\t// and end at the deepest points.\n\t\t\tconst startNode = getDeepestNode( startRef.current, 'start' );\n\t\t\tconst endNode = getDeepestNode( endRef.current, 'end' );\n\n\t\t\t// While rich text will be disabled with a delay when there is a multi\n\t\t\t// selection, we must do it immediately because it's not possible to set\n\t\t\t// selection across editable hosts.\n\t\t\ttoggleRichText( node, false );\n\n\t\t\trange.setStartBefore( startNode );\n\t\t\trange.setEndAfter( endNode );\n\n\t\t\tselection.removeAllRanges();\n\t\t\tselection.addRange( range );\n\t\t},\n\t\t[\n\t\t\thasMultiSelection,\n\t\t\tisMultiSelecting,\n\t\t\tmultiSelectedBlockClientIds,\n\t\t\tselectedBlockClientId,\n\t\t]\n\t);\n}\n"]}
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.BorderColorEdit = BorderColorEdit;
9
+ exports.hasBorderColorValue = hasBorderColorValue;
10
+ exports.resetBorderColor = resetBorderColor;
9
11
  exports.withBorderColorPaletteStyles = void 0;
10
12
 
11
13
  var _element = require("@wordpress/element");
@@ -70,11 +72,23 @@ function BorderColorEdit(props) {
70
72
  } = props;
71
73
  const colorGradientSettings = (0, _useMultipleOriginColorsAndGradients.default)();
72
74
  const availableColors = colorGradientSettings.colors.reduce((colors, origin) => colors.concat(origin.colors), []);
75
+ const {
76
+ color: customBorderColor
77
+ } = (style === null || style === void 0 ? void 0 : style.border) || {};
73
78
  const [colorValue, setColorValue] = (0, _element.useState)(() => {
74
- var _getColorObjectByAttr, _style$border;
79
+ var _getColorObjectByAttr;
75
80
 
76
- return (_getColorObjectByAttr = (0, _colors.getColorObjectByAttributeValues)(availableColors, borderColor, style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
77
- });
81
+ return (_getColorObjectByAttr = (0, _colors.getColorObjectByAttributeValues)(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
82
+ }); // Detect changes in the color attributes and update the colorValue to keep the
83
+ // UI in sync. This is necessary for situations when border controls interact with
84
+ // each other: eg, setting the border width to zero causes the color and style
85
+ // selections to be cleared.
86
+
87
+ (0, _element.useEffect)(() => {
88
+ var _getColorObjectByAttr2;
89
+
90
+ setColorValue((_getColorObjectByAttr2 = (0, _colors.getColorObjectByAttributeValues)(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color);
91
+ }, [borderColor, customBorderColor, availableColors]);
78
92
 
79
93
  const onChangeColor = value => {
80
94
  setColorValue(value);
@@ -107,6 +121,50 @@ function BorderColorEdit(props) {
107
121
  enableAlpha: true
108
122
  }, colorGradientSettings));
109
123
  }
124
+ /**
125
+ * Checks if there is a current value in the border color block support
126
+ * attributes.
127
+ *
128
+ * @param {Object} props Block props.
129
+ * @return {boolean} Whether or not the block has a border color value set.
130
+ */
131
+
132
+
133
+ function hasBorderColorValue(props) {
134
+ var _style$border;
135
+
136
+ const {
137
+ attributes: {
138
+ borderColor,
139
+ style
140
+ }
141
+ } = props;
142
+ return !!borderColor || !!(style !== null && style !== void 0 && (_style$border = style.border) !== null && _style$border !== void 0 && _style$border.color);
143
+ }
144
+ /**
145
+ * Resets the border color block support attributes. This can be used when
146
+ * disabling the border color support controls for a block via a progressive
147
+ * discovery panel.
148
+ *
149
+ * @param {Object} props Block props.
150
+ * @param {Object} props.attributes Block's attributes.
151
+ * @param {Object} props.setAttributes Function to set block's attributes.
152
+ */
153
+
154
+
155
+ function resetBorderColor(_ref) {
156
+ let {
157
+ attributes = {},
158
+ setAttributes
159
+ } = _ref;
160
+ const {
161
+ style
162
+ } = attributes;
163
+ setAttributes({
164
+ borderColor: undefined,
165
+ style: (0, _border.removeBorderAttribute)(style, 'color')
166
+ });
167
+ }
110
168
  /**
111
169
  * Filters registered block settings, extending attributes to include
112
170
  * `borderColor` if needed.
@@ -208,7 +266,7 @@ function addEditProps(settings) {
208
266
 
209
267
 
210
268
  const withBorderColorPaletteStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock => props => {
211
- var _getColorObjectByAttr2, _props$wrapperProps;
269
+ var _getColorObjectByAttr3, _props$wrapperProps;
212
270
 
213
271
  const {
214
272
  name,
@@ -224,7 +282,7 @@ const withBorderColorPaletteStyles = (0, _compose.createHigherOrderComponent)(Bl
224
282
  }
225
283
 
226
284
  const extraStyles = {
227
- borderColor: borderColor ? (_getColorObjectByAttr2 = (0, _colors.getColorObjectByAttributeValues)(colors, borderColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color : undefined
285
+ borderColor: borderColor ? (_getColorObjectByAttr3 = (0, _colors.getColorObjectByAttributeValues)(colors, borderColor)) === null || _getColorObjectByAttr3 === void 0 ? void 0 : _getColorObjectByAttr3.color : undefined
228
286
  };
229
287
  let wrapperProps = props.wrapperProps;
230
288
  wrapperProps = { ...props.wrapperProps,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-color.js"],"names":["EMPTY_ARRAY","BorderColorEdit","props","attributes","borderColor","style","setAttributes","colorGradientSettings","availableColors","colors","reduce","origin","concat","colorValue","setColorValue","border","color","onChangeColor","value","colorObject","newStyle","slug","undefined","newNamedColor","settings","label","onColorChange","clearable","addAttributes","type","addSaveProps","blockType","borderColorClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","name","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAzBA;AACA;AACA;;AA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AA7B;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAkBD,UAAxB;AACA,QAAMM,MAAM,GAAG,yBAAY,eAAZ,KAAiCT,WAAhD;;AAEA,MACC,CAAE,8BAAkBwC,IAAlB,EAAwB,OAAxB,CAAF,IACA,qCAAyBA,IAAzB,CAFD,EAGE;AACD,WAAO,4BAAC,cAAD,EAAqBtC,KAArB,CAAP;AACA;;AAED,QAAMuC,WAAW,GAAG;AACnBrC,IAAAA,WAAW,EAAEA,WAAW,6BACrB,6CAAiCK,MAAjC,EAAyCL,WAAzC,CADqB,2DACrB,uBAAwDY,KADnC,GAErBM;AAHgB,GAApB;AAMA,MAAIoB,YAAY,GAAGxC,KAAK,CAACwC,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAGxC,KAAK,CAACwC,YADK;AAEdrC,IAAAA,KAAK,EAAE,EACN,GAAGoC,WADG;AAEN,iCAAGvC,KAAK,CAACwC,YAAT,wDAAG,oBAAoBrC,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,4BAAC,cAAD,6BAAqBH,KAArB;AAA6B,IAAA,YAAY,EAAGwC;AAA5C,KAAP;AACA,CA7B0C,CAArC;;AAgCP,sBACC,0BADD,EAEC,2BAFD,EAGCd,aAHD;AAMA,sBACC,kCADD,EAEC,0BAFD,EAGCE,YAHD;AAMA,sBACC,0BADD,EAEC,0BAFD,EAGCK,YAHD;AAMA,sBACC,uBADD,EAEC,8CAFD,EAGCG,4BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport useSetting from '../components/use-setting';\nimport { hasBorderSupport, shouldSkipSerialization } from './border';\nimport { cleanEmptyObject } from './utils';\n\n// Defining empty array here instead of inline avoids unnecessary re-renders of\n// color control.\nconst EMPTY_ARRAY = [];\n\n/**\n * Inspector control panel containing the border color related configuration.\n *\n * There is deliberate overlap between the colors and borders block supports\n * relating to border color. It can be argued the border color controls could\n * be included within either, or both, the colors and borders panels in the\n * inspector controls. If they share the same block attributes it should not\n * matter.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border color edit element.\n */\nexport function BorderColorEdit( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst availableColors = colorGradientSettings.colors.reduce(\n\t\t( colors, origin ) => colors.concat( origin.colors ),\n\t\t[]\n\t);\n\tconst [ colorValue, setColorValue ] = useState(\n\t\t() =>\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tstyle?.border?.color\n\t\t\t)?.color\n\t);\n\n\tconst onChangeColor = ( value ) => {\n\t\tsetColorValue( value );\n\n\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\tavailableColors,\n\t\t\tvalue\n\t\t);\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tcolor: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\t// If empty slug, ensure undefined to remove attribute.\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\tborderColor: newNamedColor,\n\t\t} );\n\t};\n\n\tconst settings = [\n\t\t{\n\t\t\tlabel: __( 'Color' ),\n\t\t\tonColorChange: onChangeColor,\n\t\t\tcolorValue,\n\t\t\tclearable: false,\n\t\t},\n\t];\n\treturn (\n\t\t<ColorGradientSettingsDropdown\n\t\t\tsettings={ settings }\n\t\t\tdisableCustomColors\n\t\t\tdisableCustomGradients\n\t\t\t__experimentalHasMultipleOrigins\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t\tenableAlpha\n\t\t\t{ ...colorGradientSettings }\n\t\t/>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\tconst newClassName = classnames( props.className, {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor } = attributes;\n\t\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst extraStyles = {\n\t\t\tborderColor: borderColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, borderColor )?.color\n\t\t\t\t: undefined,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-color.js"],"names":["EMPTY_ARRAY","BorderColorEdit","props","attributes","borderColor","style","setAttributes","colorGradientSettings","availableColors","colors","reduce","origin","concat","color","customBorderColor","border","colorValue","setColorValue","onChangeColor","value","colorObject","newStyle","slug","undefined","newNamedColor","settings","label","onColorChange","clearable","hasBorderColorValue","resetBorderColor","addAttributes","type","addSaveProps","blockType","borderColorClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","name","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AAKA;;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAgBA;AACA;AACA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,WAAF;AAAeC,MAAAA;AAAf,KADP;AAELC,IAAAA;AAFK,MAGFJ,KAHJ;AAIA,QAAMK,qBAAqB,GAAG,mDAA9B;AACA,QAAMC,eAAe,GAAGD,qBAAqB,CAACE,MAAtB,CAA6BC,MAA7B,CACvB,CAAED,MAAF,EAAUE,MAAV,KAAsBF,MAAM,CAACG,MAAP,CAAeD,MAAM,CAACF,MAAtB,CADC,EAEvB,EAFuB,CAAxB;AAIA,QAAM;AAAEI,IAAAA,KAAK,EAAEC;AAAT,MAA+B,CAAAT,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEU,MAAP,KAAiB,EAAtD;AACA,QAAM,CAAEC,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n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport useSetting from '../components/use-setting';\nimport {\n\thasBorderSupport,\n\tremoveBorderAttribute,\n\tshouldSkipSerialization,\n} from './border';\nimport { cleanEmptyObject } from './utils';\n\n// Defining empty array here instead of inline avoids unnecessary re-renders of\n// color control.\nconst EMPTY_ARRAY = [];\n\n/**\n * Inspector control panel containing the border color related configuration.\n *\n * There is deliberate overlap between the colors and borders block supports\n * relating to border color. It can be argued the border color controls could\n * be included within either, or both, the colors and borders panels in the\n * inspector controls. If they share the same block attributes it should not\n * matter.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border color edit element.\n */\nexport function BorderColorEdit( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst availableColors = colorGradientSettings.colors.reduce(\n\t\t( colors, origin ) => colors.concat( origin.colors ),\n\t\t[]\n\t);\n\tconst { color: customBorderColor } = style?.border || {};\n\tconst [ colorValue, setColorValue ] = useState(\n\t\t() =>\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tcustomBorderColor\n\t\t\t)?.color\n\t);\n\n\t// Detect changes in the color attributes and update the colorValue to keep the\n\t// UI in sync. This is necessary for situations when border controls interact with\n\t// each other: eg, setting the border width to zero causes the color and style\n\t// selections to be cleared.\n\tuseEffect( () => {\n\t\tsetColorValue(\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tcustomBorderColor\n\t\t\t)?.color\n\t\t);\n\t}, [ borderColor, customBorderColor, availableColors ] );\n\n\tconst onChangeColor = ( value ) => {\n\t\tsetColorValue( value );\n\n\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\tavailableColors,\n\t\t\tvalue\n\t\t);\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tcolor: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\t// If empty slug, ensure undefined to remove attribute.\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\tborderColor: newNamedColor,\n\t\t} );\n\t};\n\n\tconst settings = [\n\t\t{\n\t\t\tlabel: __( 'Color' ),\n\t\t\tonColorChange: onChangeColor,\n\t\t\tcolorValue,\n\t\t\tclearable: false,\n\t\t},\n\t];\n\treturn (\n\t\t<ColorGradientSettingsDropdown\n\t\t\tsettings={ settings }\n\t\t\tdisableCustomColors\n\t\t\tdisableCustomGradients\n\t\t\t__experimentalHasMultipleOrigins\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t\tenableAlpha\n\t\t\t{ ...colorGradientSettings }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if there is a current value in the border color block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border color value set.\n */\nexport function hasBorderColorValue( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t} = props;\n\n\treturn !! borderColor || !! style?.border?.color;\n}\n\n/**\n * Resets the border color block support attributes. This can be used when\n * disabling the border color support controls for a block via a progressive\n * 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 resetBorderColor( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tborderColor: undefined,\n\t\tstyle: removeBorderAttribute( style, 'color' ),\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\tconst newClassName = classnames( props.className, {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor } = attributes;\n\t\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst extraStyles = {\n\t\t\tborderColor: borderColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, borderColor )?.color\n\t\t\t\t: undefined,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.BorderRadiusEdit = BorderRadiusEdit;
9
+ exports.hasBorderRadiusValue = hasBorderRadiusValue;
10
+ exports.resetBorderRadius = resetBorderRadius;
9
11
 
10
12
  var _element = require("@wordpress/element");
11
13
 
@@ -13,6 +15,8 @@ var _borderRadiusControl = _interopRequireDefault(require("../components/border-
13
15
 
14
16
  var _utils = require("./utils");
15
17
 
18
+ var _border = require("./border");
19
+
16
20
  /**
17
21
  * Internal dependencies
18
22
  */
@@ -55,4 +59,47 @@ function BorderRadiusEdit(props) {
55
59
  onChange: onChange
56
60
  });
57
61
  }
62
+ /**
63
+ * Checks if there is a current value in the border radius block support
64
+ * attributes.
65
+ *
66
+ * @param {Object} props Block props.
67
+ * @return {boolean} Whether or not the block has a border radius value set.
68
+ */
69
+
70
+
71
+ function hasBorderRadiusValue(props) {
72
+ var _props$attributes$sty, _props$attributes$sty2;
73
+
74
+ const borderRadius = (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.border) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.radius;
75
+
76
+ if (typeof borderRadius === 'object') {
77
+ return Object.entries(borderRadius).some(Boolean);
78
+ }
79
+
80
+ return !!borderRadius;
81
+ }
82
+ /**
83
+ * Resets the border radius block support attributes. This can be used when
84
+ * disabling the border radius support controls for a block via a progressive
85
+ * discovery panel.
86
+ *
87
+ * @param {Object} props Block props.
88
+ * @param {Object} props.attributes Block's attributes.
89
+ * @param {Object} props.setAttributes Function to set block's attributes.
90
+ */
91
+
92
+
93
+ function resetBorderRadius(_ref) {
94
+ let {
95
+ attributes = {},
96
+ setAttributes
97
+ } = _ref;
98
+ const {
99
+ style
100
+ } = attributes;
101
+ setAttributes({
102
+ style: (0, _border.removeBorderAttribute)(style, 'radius')
103
+ });
104
+ }
58
105
  //# sourceMappingURL=border-radius.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-radius.js"],"names":["BorderRadiusEdit","props","attributes","style","setAttributes","onChange","newRadius","newStyle","border","radius","undefined"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,KAA3B,EAAmC;AAAA;;AACzC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,QAAMI,QAAQ,GAAKC,SAAF,IAAiB;AACjC,QAAIC,QAAQ,GAAG,EACd,GAAGJ,KADW;AAEdK,MAAAA,MAAM,EAAE,EACP,IAAGL,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEK,MAAV,CADO;AAEPC,QAAAA,MAAM,EAAEH;AAFD;AAFM,KAAf;;AAQA,QAAKA,SAAS,KAAKI,SAAd,IAA2BJ,SAAS,KAAK,EAA9C,EAAmD;AAClDC,MAAAA,QAAQ,GAAG,6BAAkBA,QAAlB,CAAX;AACA;;AAEDH,IAAAA,aAAa,CAAE;AAAED,MAAAA,KAAK,EAAEI;AAAT,KAAF,CAAb;AACA,GAdD;;AAgBA,SACC,4BAAC,4BAAD;AACC,IAAA,MAAM,EAAGJ,KAAH,aAAGA,KAAH,wCAAGA,KAAK,CAAEK,MAAV,kDAAG,cAAeC,MADzB;AAEC,IAAA,QAAQ,EAAGJ;AAFZ,IADD;AAMA","sourcesContent":["/**\n * Internal dependencies\n */\nimport BorderRadiusControl from '../components/border-radius-control';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Inspector control panel containing the border radius related configuration.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border radius edit element.\n */\nexport function BorderRadiusEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newRadius ) => {\n\t\tlet newStyle = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tradius: newRadius,\n\t\t\t},\n\t\t};\n\n\t\tif ( newRadius === undefined || newRadius === '' ) {\n\t\t\tnewStyle = cleanEmptyObject( newStyle );\n\t\t}\n\n\t\tsetAttributes( { style: newStyle } );\n\t};\n\n\treturn (\n\t\t<BorderRadiusControl\n\t\t\tvalues={ style?.border?.radius }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-radius.js"],"names":["BorderRadiusEdit","props","attributes","style","setAttributes","onChange","newRadius","newStyle","border","radius","undefined","hasBorderRadiusValue","borderRadius","Object","entries","some","Boolean","resetBorderRadius"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,KAA3B,EAAmC;AAAA;;AACzC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,QAAMI,QAAQ,GAAKC,SAAF,IAAiB;AACjC,QAAIC,QAAQ,GAAG,EACd,GAAGJ,KADW;AAEdK,MAAAA,MAAM,EAAE,EACP,IAAGL,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEK,MAAV,CADO;AAEPC,QAAAA,MAAM,EAAEH;AAFD;AAFM,KAAf;;AAQA,QAAKA,SAAS,KAAKI,SAAd,IAA2BJ,SAAS,KAAK,EAA9C,EAAmD;AAClDC,MAAAA,QAAQ,GAAG,6BAAkBA,QAAlB,CAAX;AACA;;AAEDH,IAAAA,aAAa,CAAE;AAAED,MAAAA,KAAK,EAAEI;AAAT,KAAF,CAAb;AACA,GAdD;;AAgBA,SACC,4BAAC,4BAAD;AACC,IAAA,MAAM,EAAGJ,KAAH,aAAGA,KAAH,wCAAGA,KAAK,CAAEK,MAAV,kDAAG,cAAeC,MADzB;AAEC,IAAA,QAAQ,EAAGJ;AAFZ,IADD;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASM,oBAAT,CAA+BV,KAA/B,EAAuC;AAAA;;AAC7C,QAAMW,YAAY,4BAAGX,KAAK,CAACC,UAAN,CAAiBC,KAApB,oFAAG,sBAAwBK,MAA3B,2DAAG,uBAAgCC,MAArD;;AAEA,MAAK,OAAOG,YAAP,KAAwB,QAA7B,EAAwC;AACvC,WAAOC,MAAM,CAACC,OAAP,CAAgBF,YAAhB,EAA+BG,IAA/B,CAAqCC,OAArC,CAAP;AACA;;AAED,SAAO,CAAC,CAAEJ,YAAV;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,iBAAT,OAAiE;AAAA,MAArC;AAAEf,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACvE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AACAE,EAAAA,aAAa,CAAE;AAAED,IAAAA,KAAK,EAAE,mCAAuBA,KAAvB,EAA8B,QAA9B;AAAT,GAAF,CAAb;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport BorderRadiusControl from '../components/border-radius-control';\nimport { cleanEmptyObject } from './utils';\nimport { removeBorderAttribute } from './border';\n\n/**\n * Inspector control panel containing the border radius related configuration.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border radius edit element.\n */\nexport function BorderRadiusEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newRadius ) => {\n\t\tlet newStyle = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tradius: newRadius,\n\t\t\t},\n\t\t};\n\n\t\tif ( newRadius === undefined || newRadius === '' ) {\n\t\t\tnewStyle = cleanEmptyObject( newStyle );\n\t\t}\n\n\t\tsetAttributes( { style: newStyle } );\n\t};\n\n\treturn (\n\t\t<BorderRadiusControl\n\t\t\tvalues={ style?.border?.radius }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if there is a current value in the border radius block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border radius value set.\n */\nexport function hasBorderRadiusValue( props ) {\n\tconst borderRadius = props.attributes.style?.border?.radius;\n\n\tif ( typeof borderRadius === 'object' ) {\n\t\treturn Object.entries( borderRadius ).some( Boolean );\n\t}\n\n\treturn !! borderRadius;\n}\n\n/**\n * Resets the border radius block support attributes. This can be used when\n * disabling the border radius support controls for a block via a progressive\n * 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 resetBorderRadius( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\tsetAttributes( { style: removeBorderAttribute( style, 'radius' ) } );\n}\n"]}
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.BorderStyleEdit = void 0;
9
+ exports.hasBorderStyleValue = hasBorderStyleValue;
10
+ exports.resetBorderStyle = resetBorderStyle;
9
11
 
10
12
  var _element = require("@wordpress/element");
11
13
 
@@ -13,6 +15,8 @@ var _borderStyleControl = _interopRequireDefault(require("../components/border-s
13
15
 
14
16
  var _utils = require("./utils");
15
17
 
18
+ var _border = require("./border");
19
+
16
20
  /**
17
21
  * Internal dependencies
18
22
  */
@@ -50,6 +54,43 @@ const BorderStyleEdit = props => {
50
54
  onChange: onChange
51
55
  });
52
56
  };
57
+ /**
58
+ * Checks if there is a current value in the border style block support
59
+ * attributes.
60
+ *
61
+ * @param {Object} props Block props.
62
+ * @return {boolean} Whether or not the block has a border style value set.
63
+ */
64
+
53
65
 
54
66
  exports.BorderStyleEdit = BorderStyleEdit;
67
+
68
+ function hasBorderStyleValue(props) {
69
+ var _props$attributes$sty, _props$attributes$sty2;
70
+
71
+ return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.border) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.style);
72
+ }
73
+ /**
74
+ * Resets the border style block support attribute. This can be used when
75
+ * disabling the border style support control for a block via a progressive
76
+ * discovery panel.
77
+ *
78
+ * @param {Object} props Block props.
79
+ * @param {Object} props.attributes Block's attributes.
80
+ * @param {Object} props.setAttributes Function to set block's attributes.
81
+ */
82
+
83
+
84
+ function resetBorderStyle(_ref) {
85
+ let {
86
+ attributes = {},
87
+ setAttributes
88
+ } = _ref;
89
+ const {
90
+ style
91
+ } = attributes;
92
+ setAttributes({
93
+ style: (0, _border.removeBorderAttribute)(style, 'style')
94
+ });
95
+ }
55
96
  //# sourceMappingURL=border-style.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-style.js"],"names":["BorderStyleEdit","props","attributes","style","setAttributes","onChange","newBorderStyle","newStyleAttributes","border"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAKC,KAAF,IAAa;AAAA;;AAC3C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,QAAMI,QAAQ,GAAKC,cAAF,IAAsB;AACtC,UAAMC,kBAAkB,GAAG,EAC1B,GAAGJ,KADuB;AAE1BK,MAAAA,MAAM,EAAE,EACP,IAAGL,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEK,MAAV,CADO;AAEPL,QAAAA,KAAK,EAAEG;AAFA;AAFkB,KAA3B;AAQAF,IAAAA,aAAa,CAAE;AAAED,MAAAA,KAAK,EAAE,6BAAkBI,kBAAlB;AAAT,KAAF,CAAb;AACA,GAVD;;AAYA,SACC,4BAAC,2BAAD;AACC,IAAA,KAAK,EAAGJ,KAAH,aAAGA,KAAH,wCAAGA,KAAK,CAAEK,MAAV,kDAAG,cAAeL,KADxB;AAEC,IAAA,QAAQ,EAAGE;AAFZ,IADD;AAMA,CAxBM","sourcesContent":["/**\n * Internal dependencies\n */\nimport BorderStyleControl from '../components/border-style-control';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Inspector control for configuring border style property.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border style edit element.\n */\nexport const BorderStyleEdit = ( props ) => {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newBorderStyle ) => {\n\t\tconst newStyleAttributes = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tstyle: newBorderStyle,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( { style: cleanEmptyObject( newStyleAttributes ) } );\n\t};\n\n\treturn (\n\t\t<BorderStyleControl\n\t\t\tvalue={ style?.border?.style }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-style.js"],"names":["BorderStyleEdit","props","attributes","style","setAttributes","onChange","newBorderStyle","newStyleAttributes","border","hasBorderStyleValue","resetBorderStyle"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAKC,KAAF,IAAa;AAAA;;AAC3C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,QAAMI,QAAQ,GAAKC,cAAF,IAAsB;AACtC,UAAMC,kBAAkB,GAAG,EAC1B,GAAGJ,KADuB;AAE1BK,MAAAA,MAAM,EAAE,EACP,IAAGL,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEK,MAAV,CADO;AAEPL,QAAAA,KAAK,EAAEG;AAFA;AAFkB,KAA3B;AAQAF,IAAAA,aAAa,CAAE;AAAED,MAAAA,KAAK,EAAE,6BAAkBI,kBAAlB;AAAT,KAAF,CAAb;AACA,GAVD;;AAYA,SACC,4BAAC,2BAAD;AACC,IAAA,KAAK,EAAGJ,KAAH,aAAGA,KAAH,wCAAGA,KAAK,CAAEK,MAAV,kDAAG,cAAeL,KADxB;AAEC,IAAA,QAAQ,EAAGE;AAFZ,IADD;AAMA,CAxBM;AA0BP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASI,mBAAT,CAA8BR,KAA9B,EAAsC;AAAA;;AAC5C,SAAO,CAAC,2BAAEA,KAAK,CAACC,UAAN,CAAiBC,KAAnB,4EAAE,sBAAwBK,MAA1B,mDAAE,uBAAgCL,KAAlC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASO,gBAAT,OAAgE;AAAA,MAArC;AAAER,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACtE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AACAE,EAAAA,aAAa,CAAE;AAAED,IAAAA,KAAK,EAAE,mCAAuBA,KAAvB,EAA8B,OAA9B;AAAT,GAAF,CAAb;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport BorderStyleControl from '../components/border-style-control';\nimport { cleanEmptyObject } from './utils';\nimport { removeBorderAttribute } from './border';\n\n/**\n * Inspector control for configuring border style property.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border style edit element.\n */\nexport const BorderStyleEdit = ( props ) => {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newBorderStyle ) => {\n\t\tconst newStyleAttributes = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tstyle: newBorderStyle,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( { style: cleanEmptyObject( newStyleAttributes ) } );\n\t};\n\n\treturn (\n\t\t<BorderStyleControl\n\t\t\tvalue={ style?.border?.style }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n};\n\n/**\n * Checks if there is a current value in the border style block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border style value set.\n */\nexport function hasBorderStyleValue( props ) {\n\treturn !! props.attributes.style?.border?.style;\n}\n\n/**\n * Resets the border style block support attribute. This can be used when\n * disabling the border style support control for a block via a progressive\n * 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 resetBorderStyle( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\tsetAttributes( { style: removeBorderAttribute( style, 'style' ) } );\n}\n"]}