@wordpress/block-editor 8.5.7 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (462) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +5 -2
  3. package/build/components/block-alignment-control/constants.js +48 -0
  4. package/build/components/block-alignment-control/constants.js.map +1 -0
  5. package/build/components/block-alignment-control/ui.js +9 -40
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.native.js +92 -0
  8. package/build/components/block-alignment-control/ui.native.js.map +1 -0
  9. package/build/components/block-alignment-matrix-control/index.js +1 -6
  10. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  11. package/build/components/block-content-overlay/index.js +5 -74
  12. package/build/components/block-content-overlay/index.js.map +1 -1
  13. package/build/components/block-draggable/draggable-chip.native.js +64 -0
  14. package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
  15. package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
  16. package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  17. package/build/components/block-draggable/index.native.js +484 -0
  18. package/build/components/block-draggable/index.native.js.map +1 -0
  19. package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
  20. package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  21. package/build/components/block-list/block-list-context.native.js +195 -0
  22. package/build/components/block-list/block-list-context.native.js.map +1 -0
  23. package/build/components/block-list/block-list-item-cell.native.js +67 -0
  24. package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
  25. package/build/components/block-list/block-list-item.native.js +12 -9
  26. package/build/components/block-list/block-list-item.native.js.map +1 -1
  27. package/build/components/block-list/block.native.js +29 -6
  28. package/build/components/block-list/block.native.js.map +1 -1
  29. package/build/components/block-list/index.native.js +75 -23
  30. package/build/components/block-list/index.native.js.map +1 -1
  31. package/build/components/block-list/use-block-props/index.js +8 -4
  32. package/build/components/block-list/use-block-props/index.js.map +1 -1
  33. package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
  34. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  35. package/build/components/block-list/use-in-between-inserter.js +1 -1
  36. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  37. package/build/components/block-lock/modal.js +34 -4
  38. package/build/components/block-lock/modal.js.map +1 -1
  39. package/build/components/block-lock/toolbar.js +2 -1
  40. package/build/components/block-lock/toolbar.js.map +1 -1
  41. package/build/components/block-lock/use-block-lock.js +4 -1
  42. package/build/components/block-lock/use-block-lock.js.map +1 -1
  43. package/build/components/block-mobile-toolbar/index.native.js +9 -3
  44. package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
  45. package/build/components/block-mover/button.js +4 -4
  46. package/build/components/block-mover/button.js.map +1 -1
  47. package/build/components/block-mover/index.js +39 -65
  48. package/build/components/block-mover/index.js.map +1 -1
  49. package/build/components/block-mover/index.native.js +17 -4
  50. package/build/components/block-mover/index.native.js.map +1 -1
  51. package/build/components/block-navigation/dropdown.js +11 -5
  52. package/build/components/block-navigation/dropdown.js.map +1 -1
  53. package/build/components/block-popover/inbetween.js +191 -0
  54. package/build/components/block-popover/inbetween.js.map +1 -0
  55. package/build/components/block-popover/index.js +85 -0
  56. package/build/components/block-popover/index.js.map +1 -0
  57. package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
  58. package/build/components/block-popover/use-popover-scroll.js.map +1 -0
  59. package/build/components/block-preview/index.js +1 -1
  60. package/build/components/block-preview/index.js.map +1 -1
  61. package/build/components/block-styles/index.js +1 -10
  62. package/build/components/block-styles/index.js.map +1 -1
  63. package/build/components/block-tools/back-compat.js +2 -2
  64. package/build/components/block-tools/back-compat.js.map +1 -1
  65. package/build/components/block-tools/block-selection-button.js +4 -2
  66. package/build/components/block-tools/block-selection-button.js.map +1 -1
  67. package/build/components/block-tools/index.js +5 -5
  68. package/build/components/block-tools/index.js.map +1 -1
  69. package/build/components/block-tools/insertion-point.js +14 -121
  70. package/build/components/block-tools/insertion-point.js.map +1 -1
  71. package/build/components/block-tools/selected-block-popover.js +216 -0
  72. package/build/components/block-tools/selected-block-popover.js.map +1 -0
  73. package/build/components/border-radius-control/input-controls.js +10 -3
  74. package/build/components/border-radius-control/input-controls.js.map +1 -1
  75. package/build/components/color-style-selector/index.js +9 -0
  76. package/build/components/color-style-selector/index.js.map +1 -1
  77. package/build/components/colors-gradients/dropdown.js +149 -44
  78. package/build/components/colors-gradients/dropdown.js.map +1 -1
  79. package/build/components/duotone-control/index.js +5 -1
  80. package/build/components/duotone-control/index.js.map +1 -1
  81. package/build/components/image-editor/use-save-image.js +3 -1
  82. package/build/components/image-editor/use-save-image.js.map +1 -1
  83. package/build/components/index.js +5 -23
  84. package/build/components/index.js.map +1 -1
  85. package/build/components/inserter/index.native.js +31 -9
  86. package/build/components/inserter/index.native.js.map +1 -1
  87. package/build/components/link-control/constants.js +11 -1
  88. package/build/components/link-control/constants.js.map +1 -1
  89. package/build/components/link-control/search-results.js +4 -3
  90. package/build/components/link-control/search-results.js.map +1 -1
  91. package/build/components/link-control/use-search-handler.js +4 -4
  92. package/build/components/link-control/use-search-handler.js.map +1 -1
  93. package/build/components/list-view/block.js +15 -15
  94. package/build/components/list-view/block.js.map +1 -1
  95. package/build/components/list-view/branch.js +9 -13
  96. package/build/components/list-view/branch.js.map +1 -1
  97. package/build/components/list-view/context.js +1 -4
  98. package/build/components/list-view/context.js.map +1 -1
  99. package/build/components/list-view/drop-indicator.js +0 -1
  100. package/build/components/list-view/drop-indicator.js.map +1 -1
  101. package/build/components/list-view/index.js +15 -32
  102. package/build/components/list-view/index.js.map +1 -1
  103. package/build/components/navigable-toolbar/index.js +12 -2
  104. package/build/components/navigable-toolbar/index.js.map +1 -1
  105. package/build/components/rich-text/format-toolbar-container.js +0 -1
  106. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  107. package/build/components/rich-text/index.js +1 -6
  108. package/build/components/rich-text/index.js.map +1 -1
  109. package/build/components/rich-text/index.native.js +0 -4
  110. package/build/components/rich-text/index.native.js.map +1 -1
  111. package/build/components/url-input/index.js +11 -4
  112. package/build/components/url-input/index.js.map +1 -1
  113. package/build/components/use-block-display-information/index.js +3 -1
  114. package/build/components/use-block-display-information/index.js.map +1 -1
  115. package/build/components/use-block-drop-zone/index.native.js +167 -0
  116. package/build/components/use-block-drop-zone/index.native.js.map +1 -0
  117. package/build/components/use-on-block-drop/index.native.js +95 -0
  118. package/build/components/use-on-block-drop/index.native.js.map +1 -0
  119. package/build/components/use-setting/index.js +42 -18
  120. package/build/components/use-setting/index.js.map +1 -1
  121. package/build/hooks/anchor.js.map +1 -1
  122. package/build/hooks/border.js +463 -44
  123. package/build/hooks/border.js.map +1 -1
  124. package/build/hooks/color-panel.js +14 -7
  125. package/build/hooks/color-panel.js.map +1 -1
  126. package/build/hooks/dimensions.js +2 -2
  127. package/build/hooks/dimensions.js.map +1 -1
  128. package/build/hooks/index.js +3 -1
  129. package/build/hooks/index.js.map +1 -1
  130. package/build/hooks/margin.js +64 -12
  131. package/build/hooks/margin.js.map +1 -1
  132. package/build/hooks/padding.js +60 -12
  133. package/build/hooks/padding.js.map +1 -1
  134. package/build/hooks/settings.js +32 -0
  135. package/build/hooks/settings.js.map +1 -0
  136. package/build/hooks/style.js +14 -13
  137. package/build/hooks/style.js.map +1 -1
  138. package/build/hooks/typography.js +6 -2
  139. package/build/hooks/typography.js.map +1 -1
  140. package/build/hooks/use-border-props.js +22 -32
  141. package/build/hooks/use-border-props.js.map +1 -1
  142. package/build/store/actions.js +14 -2
  143. package/build/store/actions.js.map +1 -1
  144. package/build/store/defaults.js +0 -1
  145. package/build/store/defaults.js.map +1 -1
  146. package/build/store/reducer.js +0 -26
  147. package/build/store/reducer.js.map +1 -1
  148. package/build/store/selectors.js +47 -15
  149. package/build/store/selectors.js.map +1 -1
  150. package/build-module/components/block-alignment-control/constants.js +36 -0
  151. package/build-module/components/block-alignment-control/constants.js.map +1 -0
  152. package/build-module/components/block-alignment-control/ui.js +4 -35
  153. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  154. package/build-module/components/block-alignment-control/ui.native.js +78 -0
  155. package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
  156. package/build-module/components/block-alignment-matrix-control/index.js +1 -6
  157. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  158. package/build-module/components/block-content-overlay/index.js +4 -70
  159. package/build-module/components/block-content-overlay/index.js.map +1 -1
  160. package/build-module/components/block-draggable/draggable-chip.native.js +50 -0
  161. package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
  162. package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
  163. package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  164. package/build-module/components/block-draggable/index.native.js +449 -0
  165. package/build-module/components/block-draggable/index.native.js.map +1 -0
  166. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
  167. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  168. package/build-module/components/block-list/block-list-context.native.js +179 -0
  169. package/build-module/components/block-list/block-list-context.native.js.map +1 -0
  170. package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
  171. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
  172. package/build-module/components/block-list/block-list-item.native.js +12 -9
  173. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  174. package/build-module/components/block-list/block.native.js +28 -6
  175. package/build-module/components/block-list/block.native.js.map +1 -1
  176. package/build-module/components/block-list/index.native.js +72 -23
  177. package/build-module/components/block-list/index.native.js.map +1 -1
  178. package/build-module/components/block-list/use-block-props/index.js +9 -5
  179. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  180. package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
  181. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  182. package/build-module/components/block-list/use-in-between-inserter.js +1 -1
  183. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  184. package/build-module/components/block-lock/modal.js +34 -5
  185. package/build-module/components/block-lock/modal.js.map +1 -1
  186. package/build-module/components/block-lock/toolbar.js +2 -1
  187. package/build-module/components/block-lock/toolbar.js.map +1 -1
  188. package/build-module/components/block-lock/use-block-lock.js +4 -1
  189. package/build-module/components/block-lock/use-block-lock.js.map +1 -1
  190. package/build-module/components/block-mobile-toolbar/index.native.js +8 -3
  191. package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
  192. package/build-module/components/block-mover/button.js +5 -5
  193. package/build-module/components/block-mover/button.js.map +1 -1
  194. package/build-module/components/block-mover/index.js +38 -63
  195. package/build-module/components/block-mover/index.js.map +1 -1
  196. package/build-module/components/block-mover/index.native.js +18 -5
  197. package/build-module/components/block-mover/index.native.js.map +1 -1
  198. package/build-module/components/block-navigation/dropdown.js +10 -5
  199. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  200. package/build-module/components/block-popover/inbetween.js +173 -0
  201. package/build-module/components/block-popover/inbetween.js.map +1 -0
  202. package/build-module/components/block-popover/index.js +72 -0
  203. package/build-module/components/block-popover/index.js.map +1 -0
  204. package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  205. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
  206. package/build-module/components/block-preview/index.js +1 -1
  207. package/build-module/components/block-preview/index.js.map +1 -1
  208. package/build-module/components/block-styles/index.js +1 -9
  209. package/build-module/components/block-styles/index.js.map +1 -1
  210. package/build-module/components/block-tools/back-compat.js +1 -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 +3 -2
  213. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  214. package/build-module/components/block-tools/index.js +3 -3
  215. package/build-module/components/block-tools/index.js.map +1 -1
  216. package/build-module/components/block-tools/insertion-point.js +16 -121
  217. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  218. package/build-module/components/block-tools/selected-block-popover.js +199 -0
  219. package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
  220. package/build-module/components/border-radius-control/input-controls.js +11 -4
  221. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  222. package/build-module/components/color-style-selector/index.js +6 -0
  223. package/build-module/components/color-style-selector/index.js.map +1 -1
  224. package/build-module/components/colors-gradients/dropdown.js +151 -46
  225. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  226. package/build-module/components/duotone-control/index.js +4 -1
  227. package/build-module/components/duotone-control/index.js.map +1 -1
  228. package/build-module/components/image-editor/use-save-image.js +2 -1
  229. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  230. package/build-module/components/index.js +1 -3
  231. package/build-module/components/index.js.map +1 -1
  232. package/build-module/components/inserter/index.native.js +32 -11
  233. package/build-module/components/inserter/index.native.js.map +1 -1
  234. package/build-module/components/link-control/constants.js +5 -0
  235. package/build-module/components/link-control/constants.js.map +1 -1
  236. package/build-module/components/link-control/search-results.js +3 -4
  237. package/build-module/components/link-control/search-results.js.map +1 -1
  238. package/build-module/components/link-control/use-search-handler.js +5 -5
  239. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  240. package/build-module/components/list-view/block.js +15 -16
  241. package/build-module/components/list-view/block.js.map +1 -1
  242. package/build-module/components/list-view/branch.js +9 -13
  243. package/build-module/components/list-view/branch.js.map +1 -1
  244. package/build-module/components/list-view/context.js +1 -4
  245. package/build-module/components/list-view/context.js.map +1 -1
  246. package/build-module/components/list-view/drop-indicator.js +0 -1
  247. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  248. package/build-module/components/list-view/index.js +15 -31
  249. package/build-module/components/list-view/index.js.map +1 -1
  250. package/build-module/components/navigable-toolbar/index.js +12 -2
  251. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  252. package/build-module/components/rich-text/format-toolbar-container.js +0 -1
  253. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  254. package/build-module/components/rich-text/index.js +1 -5
  255. package/build-module/components/rich-text/index.js.map +1 -1
  256. package/build-module/components/rich-text/index.native.js +0 -4
  257. package/build-module/components/rich-text/index.native.js.map +1 -1
  258. package/build-module/components/url-input/index.js +11 -4
  259. package/build-module/components/url-input/index.js.map +1 -1
  260. package/build-module/components/use-block-display-information/index.js +3 -1
  261. package/build-module/components/use-block-display-information/index.js.map +1 -1
  262. package/build-module/components/use-block-drop-zone/index.native.js +148 -0
  263. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
  264. package/build-module/components/use-on-block-drop/index.native.js +83 -0
  265. package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
  266. package/build-module/components/use-setting/index.js +43 -19
  267. package/build-module/components/use-setting/index.js.map +1 -1
  268. package/build-module/hooks/anchor.js.map +1 -1
  269. package/build-module/hooks/border.js +453 -44
  270. package/build-module/hooks/border.js.map +1 -1
  271. package/build-module/hooks/color-panel.js +11 -6
  272. package/build-module/hooks/color-panel.js.map +1 -1
  273. package/build-module/hooks/dimensions.js +5 -5
  274. package/build-module/hooks/dimensions.js.map +1 -1
  275. package/build-module/hooks/index.js +2 -1
  276. package/build-module/hooks/index.js.map +1 -1
  277. package/build-module/hooks/margin.js +61 -13
  278. package/build-module/hooks/margin.js.map +1 -1
  279. package/build-module/hooks/padding.js +57 -13
  280. package/build-module/hooks/padding.js.map +1 -1
  281. package/build-module/hooks/settings.js +29 -0
  282. package/build-module/hooks/settings.js.map +1 -0
  283. package/build-module/hooks/style.js +15 -14
  284. package/build-module/hooks/style.js.map +1 -1
  285. package/build-module/hooks/typography.js +6 -2
  286. package/build-module/hooks/typography.js.map +1 -1
  287. package/build-module/hooks/use-border-props.js +21 -30
  288. package/build-module/hooks/use-border-props.js.map +1 -1
  289. package/build-module/store/actions.js +14 -2
  290. package/build-module/store/actions.js.map +1 -1
  291. package/build-module/store/defaults.js +0 -1
  292. package/build-module/store/defaults.js.map +1 -1
  293. package/build-module/store/reducer.js +0 -24
  294. package/build-module/store/reducer.js.map +1 -1
  295. package/build-module/store/selectors.js +44 -15
  296. package/build-module/store/selectors.js.map +1 -1
  297. package/build-style/style-rtl.css +148 -410
  298. package/build-style/style.css +148 -410
  299. package/package.json +28 -28
  300. package/src/components/block-alignment-control/constants.js +45 -0
  301. package/src/components/block-alignment-control/ui.js +69 -109
  302. package/src/components/block-alignment-control/ui.native.js +86 -0
  303. package/src/components/block-alignment-matrix-control/index.js +1 -5
  304. package/src/components/block-content-overlay/index.js +9 -79
  305. package/src/components/block-content-overlay/style.scss +2 -11
  306. package/src/components/block-draggable/draggable-chip.native.js +49 -0
  307. package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
  308. package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
  309. package/src/components/block-draggable/index.native.js +458 -0
  310. package/src/components/block-draggable/style.native.scss +19 -0
  311. package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
  312. package/src/components/block-list/block-list-context.native.js +175 -0
  313. package/src/components/block-list/block-list-item-cell.native.js +49 -0
  314. package/src/components/block-list/block-list-item.native.js +7 -11
  315. package/src/components/block-list/block.native.js +38 -8
  316. package/src/components/block-list/index.native.js +54 -13
  317. package/src/components/block-list/style.scss +7 -18
  318. package/src/components/block-list/test/block-list-context.native.js +253 -0
  319. package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
  320. package/src/components/block-list/use-block-props/index.js +10 -5
  321. package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
  322. package/src/components/block-list/use-in-between-inserter.js +1 -1
  323. package/src/components/block-lock/modal.js +42 -3
  324. package/src/components/block-lock/toolbar.js +2 -2
  325. package/src/components/block-lock/use-block-lock.js +4 -1
  326. package/src/components/block-mobile-toolbar/index.native.js +8 -1
  327. package/src/components/block-mover/button.js +5 -7
  328. package/src/components/block-mover/index.js +37 -60
  329. package/src/components/block-mover/index.native.js +22 -6
  330. package/src/components/block-mover/stories/index.js +110 -0
  331. package/src/components/block-mover/style.scss +48 -138
  332. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +6 -0
  333. package/src/components/block-navigation/dropdown.js +12 -8
  334. package/src/components/block-popover/README.md +41 -0
  335. package/src/components/block-popover/inbetween.js +188 -0
  336. package/src/components/block-popover/index.js +75 -0
  337. package/src/components/block-popover/style.scss +28 -0
  338. package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  339. package/src/components/block-preview/index.js +1 -4
  340. package/src/components/block-styles/index.js +1 -12
  341. package/src/components/block-switcher/style.scss +2 -43
  342. package/src/components/block-toolbar/style.scss +0 -12
  343. package/src/components/block-tools/back-compat.js +1 -1
  344. package/src/components/block-tools/block-selection-button.js +3 -1
  345. package/src/components/block-tools/index.js +6 -4
  346. package/src/components/block-tools/insertion-point.js +19 -152
  347. package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -151
  348. package/src/components/block-tools/style.scss +12 -135
  349. package/src/components/border-radius-control/input-controls.js +16 -8
  350. package/src/components/border-radius-control/style.scss +7 -3
  351. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  352. package/src/components/color-style-selector/index.js +18 -9
  353. package/src/components/colors-gradients/dropdown.js +156 -62
  354. package/src/components/colors-gradients/style.scss +51 -23
  355. package/src/components/default-block-appender/style.scss +1 -2
  356. package/src/components/duotone-control/index.js +8 -1
  357. package/src/components/duotone-control/style.scss +1 -7
  358. package/src/components/gradients/README.md +29 -0
  359. package/src/components/image-editor/use-save-image.js +2 -1
  360. package/src/components/image-size-control/README.md +1 -1
  361. package/src/components/index.js +1 -3
  362. package/src/components/inserter/index.native.js +60 -25
  363. package/src/components/inserter/style.native.scss +25 -3
  364. package/src/components/inserter/style.scss +2 -1
  365. package/src/components/link-control/constants.js +11 -0
  366. package/src/components/link-control/search-results.js +4 -5
  367. package/src/components/link-control/use-search-handler.js +11 -5
  368. package/src/components/list-view/block.js +24 -34
  369. package/src/components/list-view/branch.js +10 -20
  370. package/src/components/list-view/context.js +1 -4
  371. package/src/components/list-view/drop-indicator.js +0 -1
  372. package/src/components/list-view/index.js +11 -41
  373. package/src/components/list-view/style.scss +2 -1
  374. package/src/components/navigable-toolbar/README.md +16 -0
  375. package/src/components/navigable-toolbar/index.js +12 -2
  376. package/src/components/preview-options/style.scss +0 -4
  377. package/src/components/rich-text/format-toolbar-container.js +0 -1
  378. package/src/components/rich-text/index.js +1 -3
  379. package/src/components/rich-text/index.native.js +0 -4
  380. package/src/components/rich-text/style.scss +2 -8
  381. package/src/components/url-input/index.js +9 -4
  382. package/src/components/use-block-display-information/index.js +2 -0
  383. package/src/components/use-block-drop-zone/index.native.js +173 -0
  384. package/src/components/use-on-block-drop/index.native.js +119 -0
  385. package/src/components/use-setting/index.js +57 -21
  386. package/src/hooks/anchor.js +1 -1
  387. package/src/hooks/border.js +429 -72
  388. package/src/hooks/color-panel.js +13 -9
  389. package/src/hooks/color.scss +0 -62
  390. package/src/hooks/dimensions.js +44 -38
  391. package/src/hooks/index.js +2 -1
  392. package/src/hooks/margin.js +64 -15
  393. package/src/hooks/padding.js +60 -15
  394. package/src/hooks/padding.scss +12 -0
  395. package/src/hooks/settings.js +32 -0
  396. package/src/hooks/style.js +25 -39
  397. package/src/hooks/test/settings.js +48 -0
  398. package/src/hooks/typography.js +2 -0
  399. package/src/hooks/use-border-props.js +15 -32
  400. package/src/store/actions.js +14 -2
  401. package/src/store/defaults.js +0 -1
  402. package/src/store/reducer.js +0 -21
  403. package/src/store/selectors.js +46 -15
  404. package/src/store/test/actions.js +0 -18
  405. package/src/store/test/reducer.js +0 -19
  406. package/src/store/test/selectors.js +17 -19
  407. package/src/style.scss +2 -3
  408. package/tsconfig.tsbuildinfo +1 -1
  409. package/build/components/block-mobile-toolbar/index.js +0 -42
  410. package/build/components/block-mobile-toolbar/index.js.map +0 -1
  411. package/build/components/block-tools/block-popover.js +0 -327
  412. package/build/components/block-tools/block-popover.js.map +0 -1
  413. package/build/components/block-tools/use-popover-scroll.js.map +0 -1
  414. package/build/components/border-style-control/index.js +0 -60
  415. package/build/components/border-style-control/index.js.map +0 -1
  416. package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
  417. package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  418. package/build/components/list-view/appender.js +0 -93
  419. package/build/components/list-view/appender.js.map +0 -1
  420. package/build/components/list-view/list-item.js +0 -62
  421. package/build/components/list-view/list-item.js.map +0 -1
  422. package/build/components/rich-text/use-caret-in-format.js +0 -43
  423. package/build/components/rich-text/use-caret-in-format.js.map +0 -1
  424. package/build/hooks/border-color.js +0 -302
  425. package/build/hooks/border-color.js.map +0 -1
  426. package/build/hooks/border-style.js +0 -96
  427. package/build/hooks/border-style.js.map +0 -1
  428. package/build/hooks/border-width.js +0 -162
  429. package/build/hooks/border-width.js.map +0 -1
  430. package/build-module/components/block-mobile-toolbar/index.js +0 -31
  431. package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
  432. package/build-module/components/block-tools/block-popover.js +0 -306
  433. package/build-module/components/block-tools/block-popover.js.map +0 -1
  434. package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
  435. package/build-module/components/border-style-control/index.js +0 -50
  436. package/build-module/components/border-style-control/index.js.map +0 -1
  437. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
  438. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  439. package/build-module/components/list-view/appender.js +0 -76
  440. package/build-module/components/list-view/appender.js.map +0 -1
  441. package/build-module/components/list-view/list-item.js +0 -47
  442. package/build-module/components/list-view/list-item.js.map +0 -1
  443. package/build-module/components/rich-text/use-caret-in-format.js +0 -33
  444. package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
  445. package/build-module/hooks/border-color.js +0 -276
  446. package/build-module/hooks/border-color.js.map +0 -1
  447. package/build-module/hooks/border-style.js +0 -78
  448. package/build-module/hooks/border-style.js.map +0 -1
  449. package/build-module/hooks/border-width.js +0 -143
  450. package/build-module/hooks/border-width.js.map +0 -1
  451. package/src/components/block-alignment-matrix-control/style.scss +0 -10
  452. package/src/components/block-mobile-toolbar/index.js +0 -24
  453. package/src/components/block-mobile-toolbar/style.scss +0 -29
  454. package/src/components/border-style-control/index.js +0 -47
  455. package/src/components/border-style-control/style.scss +0 -18
  456. package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
  457. package/src/components/list-view/appender.js +0 -82
  458. package/src/components/list-view/list-item.js +0 -59
  459. package/src/components/rich-text/use-caret-in-format.js +0 -28
  460. package/src/hooks/border-color.js +0 -315
  461. package/src/hooks/border-style.js +0 -64
  462. package/src/hooks/border-width.js +0 -139
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["has","addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( has( settings.attributes, [ 'anchor', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://git.io/Jtcov\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["has","addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( has( settings.attributes, [ 'anchor', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}
@@ -1,89 +1,317 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { createElement } from "@wordpress/element";
2
3
 
4
+ /**
5
+ * External dependencies
6
+ */
7
+ import classnames from 'classnames';
3
8
  /**
4
9
  * WordPress dependencies
5
10
  */
11
+
6
12
  import { getBlockSupport } from '@wordpress/blocks';
7
- import { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
13
+ import { __experimentalBorderBoxControl as BorderBoxControl, __experimentalHasSplitBorders as hasSplitBorders, __experimentalIsDefinedBorder as isDefinedBorder, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
14
+ import { createHigherOrderComponent } from '@wordpress/compose';
8
15
  import { Platform } from '@wordpress/element';
16
+ import { addFilter } from '@wordpress/hooks';
9
17
  import { __ } from '@wordpress/i18n';
10
18
  /**
11
19
  * Internal dependencies
12
20
  */
13
21
 
14
- import { BorderColorEdit, hasBorderColorValue, resetBorderColor } from './border-color';
15
22
  import { BorderRadiusEdit, hasBorderRadiusValue, resetBorderRadius } from './border-radius';
16
- import { BorderStyleEdit, hasBorderStyleValue, resetBorderStyle } from './border-style';
17
- import { BorderWidthEdit, hasBorderWidthValue, resetBorderWidth } from './border-width';
23
+ import { getColorClassName } from '../components/colors';
18
24
  import InspectorControls from '../components/inspector-controls';
25
+ import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
19
26
  import useSetting from '../components/use-setting';
20
- import { cleanEmptyObject } from './utils';
27
+ import { cleanEmptyObject, shouldSkipSerialization } from './utils';
21
28
  export const BORDER_SUPPORT_KEY = '__experimentalBorder';
29
+ const borderSides = ['top', 'right', 'bottom', 'left'];
30
+
31
+ const hasBorderValue = props => {
32
+ const {
33
+ borderColor,
34
+ style
35
+ } = props.attributes;
36
+ return isDefinedBorder(style === null || style === void 0 ? void 0 : style.border) || !!borderColor;
37
+ }; // The border color, style, and width are omitted so they get undefined. The
38
+ // border radius is separate and must retain its selection.
39
+
40
+
41
+ const resetBorder = _ref => {
42
+ var _style$border;
43
+
44
+ let {
45
+ attributes = {},
46
+ setAttributes
47
+ } = _ref;
48
+ const {
49
+ style
50
+ } = attributes;
51
+ setAttributes({
52
+ borderColor: undefined,
53
+ style: { ...style,
54
+ border: cleanEmptyObject({
55
+ radius: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius
56
+ })
57
+ }
58
+ });
59
+ };
60
+
61
+ const resetBorderFilter = newAttributes => {
62
+ var _newAttributes$style, _newAttributes$style$;
63
+
64
+ return { ...newAttributes,
65
+ borderColor: undefined,
66
+ style: { ...newAttributes.style,
67
+ border: {
68
+ radius: (_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : (_newAttributes$style$ = _newAttributes$style.border) === null || _newAttributes$style$ === void 0 ? void 0 : _newAttributes$style$.radius
69
+ }
70
+ }
71
+ };
72
+ };
73
+
74
+ const getColorByProperty = (colors, property, value) => {
75
+ let matchedColor;
76
+ colors.some(origin => origin.colors.some(color => {
77
+ if (color[property] === value) {
78
+ matchedColor = color;
79
+ return true;
80
+ }
81
+
82
+ return false;
83
+ }));
84
+ return matchedColor;
85
+ };
86
+
87
+ export const getMultiOriginColor = _ref2 => {
88
+ let {
89
+ colors,
90
+ namedColor,
91
+ customColor
92
+ } = _ref2;
93
+
94
+ // Search each origin (default, theme, or user) for matching color by name.
95
+ if (namedColor) {
96
+ const colorObject = getColorByProperty(colors, 'slug', namedColor);
97
+
98
+ if (colorObject) {
99
+ return colorObject;
100
+ }
101
+ } // Skip if no custom color or matching named color.
102
+
103
+
104
+ if (!customColor) {
105
+ return {
106
+ color: undefined
107
+ };
108
+ } // Attempt to find color via custom color value or build new object.
109
+
110
+
111
+ const colorObject = getColorByProperty(colors, 'color', customColor);
112
+ return colorObject ? colorObject : {
113
+ color: customColor
114
+ };
115
+ };
116
+
117
+ const getBorderObject = (attributes, colors) => {
118
+ const {
119
+ borderColor,
120
+ style
121
+ } = attributes;
122
+ const {
123
+ border: borderStyles
124
+ } = style || {}; // If we have a named color for a flat border. Fetch that color object and
125
+ // apply that color's value to the color property within the style object.
126
+
127
+ if (borderColor) {
128
+ const {
129
+ color
130
+ } = getMultiOriginColor({
131
+ colors,
132
+ namedColor: borderColor
133
+ });
134
+ return color ? { ...borderStyles,
135
+ color
136
+ } : borderStyles;
137
+ } // Individual side border color slugs are stored within the border style
138
+ // object. If we don't have a border styles object we have nothing further
139
+ // to hydrate.
140
+
141
+
142
+ if (!borderStyles) {
143
+ return borderStyles;
144
+ } // If we have named colors for the individual side borders, retrieve their
145
+ // related color objects and apply the real color values to the split
146
+ // border objects.
147
+
148
+
149
+ const hydratedBorderStyles = { ...borderStyles
150
+ };
151
+ borderSides.forEach(side => {
152
+ var _hydratedBorderStyles;
153
+
154
+ const colorSlug = getColorSlugFromVariable((_hydratedBorderStyles = hydratedBorderStyles[side]) === null || _hydratedBorderStyles === void 0 ? void 0 : _hydratedBorderStyles.color);
155
+
156
+ if (colorSlug) {
157
+ const {
158
+ color
159
+ } = getMultiOriginColor({
160
+ colors,
161
+ namedColor: colorSlug
162
+ });
163
+ hydratedBorderStyles[side] = { ...hydratedBorderStyles[side],
164
+ color
165
+ };
166
+ }
167
+ });
168
+ return hydratedBorderStyles;
169
+ };
170
+
171
+ function getColorSlugFromVariable(value) {
172
+ const namedColor = /var:preset\|color\|(.+)/.exec(value);
173
+
174
+ if (namedColor && namedColor[1]) {
175
+ return namedColor[1];
176
+ }
177
+
178
+ return null;
179
+ }
180
+
22
181
  export function BorderPanel(props) {
23
182
  const {
24
- clientId
183
+ attributes,
184
+ clientId,
185
+ setAttributes
25
186
  } = props;
187
+ const {
188
+ style
189
+ } = attributes;
190
+ const {
191
+ colors
192
+ } = useMultipleOriginColorsAndGradients();
193
+ const isSupported = hasBorderSupport(props.name);
26
194
  const isColorSupported = useSetting('border.color') && hasBorderSupport(props.name, 'color');
27
195
  const isRadiusSupported = useSetting('border.radius') && hasBorderSupport(props.name, 'radius');
28
196
  const isStyleSupported = useSetting('border.style') && hasBorderSupport(props.name, 'style');
29
197
  const isWidthSupported = useSetting('border.width') && hasBorderSupport(props.name, 'width');
30
198
  const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean);
31
199
 
32
- if (isDisabled) {
200
+ if (isDisabled || !isSupported) {
33
201
  return null;
34
202
  }
35
203
 
36
204
  const defaultBorderControls = getBlockSupport(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
205
+ const showBorderByDefault = (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color) || (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.width);
37
206
 
38
- const createResetAllFilter = function (borderAttribute) {
39
- let topLevelAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
40
- return newAttributes => {
41
- var _newAttributes$style;
207
+ const onBorderChange = newBorder => {
208
+ var _style$border2;
42
209
 
43
- return { ...newAttributes,
44
- ...topLevelAttributes,
45
- style: { ...newAttributes.style,
46
- border: { ...((_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : _newAttributes$style.border),
47
- [borderAttribute]: undefined
48
- }
210
+ // Filter out named colors and apply them to appropriate block
211
+ // attributes so that CSS classes can be used to apply those colors.
212
+ // e.g. has-primary-border-top-color.
213
+ let newBorderStyles = { ...newBorder
214
+ };
215
+ let newBorderColor;
216
+
217
+ if (hasSplitBorders(newBorder)) {
218
+ // For each side check if the side has a color value set
219
+ // If so, determine if it belongs to a named color, in which case
220
+ // we update the color property.
221
+ //
222
+ // This deliberately overwrites `newBorderStyles` to avoid mutating
223
+ // the passed object which causes problems otherwise.
224
+ newBorderStyles = {
225
+ top: { ...newBorder.top
226
+ },
227
+ right: { ...newBorder.right
228
+ },
229
+ bottom: { ...newBorder.bottom
230
+ },
231
+ left: { ...newBorder.left
49
232
  }
50
233
  };
51
- };
234
+ borderSides.forEach(side => {
235
+ var _newBorder$side;
236
+
237
+ if ((_newBorder$side = newBorder[side]) !== null && _newBorder$side !== void 0 && _newBorder$side.color) {
238
+ var _newBorder$side2;
239
+
240
+ const colorObject = getMultiOriginColor({
241
+ colors,
242
+ customColor: (_newBorder$side2 = newBorder[side]) === null || _newBorder$side2 === void 0 ? void 0 : _newBorder$side2.color
243
+ });
244
+
245
+ if (colorObject.slug) {
246
+ newBorderStyles[side].color = `var:preset|color|${colorObject.slug}`;
247
+ }
248
+ }
249
+ });
250
+ } else if (newBorder !== null && newBorder !== void 0 && newBorder.color) {
251
+ // We have a flat border configuration. Apply named color slug to
252
+ // `borderColor` attribute and clear color style property if found.
253
+ const customColor = newBorder === null || newBorder === void 0 ? void 0 : newBorder.color;
254
+ const colorObject = getMultiOriginColor({
255
+ colors,
256
+ customColor
257
+ });
258
+
259
+ if (colorObject.slug) {
260
+ newBorderColor = colorObject.slug;
261
+ newBorderStyles.color = undefined;
262
+ }
263
+ } // Ensure previous border radius styles are maintained and clean
264
+ // overall result for empty objects or properties.
265
+
266
+
267
+ const newStyle = cleanEmptyObject({ ...style,
268
+ border: {
269
+ radius: style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.radius,
270
+ ...newBorderStyles
271
+ }
272
+ });
273
+ setAttributes({
274
+ style: newStyle,
275
+ borderColor: newBorderColor
276
+ });
52
277
  };
53
278
 
279
+ const hydratedBorder = getBorderObject(attributes, colors);
54
280
  return createElement(InspectorControls, {
55
281
  __experimentalGroup: "border"
56
- }, isWidthSupported && createElement(ToolsPanelItem, {
57
- className: "single-column",
58
- hasValue: () => hasBorderWidthValue(props),
59
- label: __('Width'),
60
- onDeselect: () => resetBorderWidth(props),
61
- isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.width,
62
- resetAllFilter: createResetAllFilter('width'),
63
- panelId: clientId
64
- }, createElement(BorderWidthEdit, props)), isStyleSupported && createElement(ToolsPanelItem, {
65
- className: "single-column",
66
- hasValue: () => hasBorderStyleValue(props),
67
- label: __('Style'),
68
- onDeselect: () => resetBorderStyle(props),
69
- isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.style,
70
- resetAllFilter: createResetAllFilter('style'),
71
- panelId: clientId
72
- }, createElement(BorderStyleEdit, props)), isColorSupported && createElement(ToolsPanelItem, {
73
- hasValue: () => hasBorderColorValue(props),
74
- label: __('Color'),
75
- onDeselect: () => resetBorderColor(props),
76
- isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color,
77
- resetAllFilter: createResetAllFilter('color', {
78
- borderColor: undefined
79
- }),
282
+ }, (isWidthSupported || isColorSupported) && createElement(ToolsPanelItem, {
283
+ hasValue: () => hasBorderValue(props),
284
+ label: __('Border'),
285
+ onDeselect: () => resetBorder(props),
286
+ isShownByDefault: showBorderByDefault,
287
+ resetAllFilter: resetBorderFilter,
80
288
  panelId: clientId
81
- }, createElement(BorderColorEdit, props)), isRadiusSupported && createElement(ToolsPanelItem, {
289
+ }, createElement(BorderBoxControl, {
290
+ colors: colors,
291
+ enableAlpha: true,
292
+ onChange: onBorderChange,
293
+ popoverPlacement: "left-start",
294
+ popoverOffset: 40,
295
+ showStyle: isStyleSupported,
296
+ value: hydratedBorder,
297
+ __experimentalHasMultipleOrigins: true,
298
+ __experimentalIsRenderedInSidebar: true
299
+ })), isRadiusSupported && createElement(ToolsPanelItem, {
82
300
  hasValue: () => hasBorderRadiusValue(props),
83
301
  label: __('Radius'),
84
302
  onDeselect: () => resetBorderRadius(props),
85
303
  isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.radius,
86
- resetAllFilter: createResetAllFilter('radius'),
304
+ resetAllFilter: newAttributes => {
305
+ var _newAttributes$style2;
306
+
307
+ return { ...newAttributes,
308
+ style: { ...newAttributes.style,
309
+ border: { ...((_newAttributes$style2 = newAttributes.style) === null || _newAttributes$style2 === void 0 ? void 0 : _newAttributes$style2.border),
310
+ radius: undefined
311
+ }
312
+ }
313
+ };
314
+ },
87
315
  panelId: clientId
88
316
  }, createElement(BorderRadiusEdit, props)));
89
317
  }
@@ -132,4 +360,185 @@ export function removeBorderAttribute(style, attribute) {
132
360
  }
133
361
  });
134
362
  }
363
+ /**
364
+ * Filters registered block settings, extending attributes to include
365
+ * `borderColor` if needed.
366
+ *
367
+ * @param {Object} settings Original block settings.
368
+ *
369
+ * @return {Object} Updated block settings.
370
+ */
371
+
372
+ function addAttributes(settings) {
373
+ if (!hasBorderSupport(settings, 'color')) {
374
+ return settings;
375
+ } // Allow blocks to specify default value if needed.
376
+
377
+
378
+ if (settings.attributes.borderColor) {
379
+ return settings;
380
+ } // Add new borderColor attribute to block settings.
381
+
382
+
383
+ return { ...settings,
384
+ attributes: { ...settings.attributes,
385
+ borderColor: {
386
+ type: 'string'
387
+ }
388
+ }
389
+ };
390
+ }
391
+ /**
392
+ * Override props assigned to save component to inject border color.
393
+ *
394
+ * @param {Object} props Additional props applied to save element.
395
+ * @param {Object} blockType Block type definition.
396
+ * @param {Object} attributes Block's attributes.
397
+ *
398
+ * @return {Object} Filtered props to apply to save element.
399
+ */
400
+
401
+
402
+ function addSaveProps(props, blockType, attributes) {
403
+ if (!hasBorderSupport(blockType, 'color') || shouldSkipSerialization(blockType, BORDER_SUPPORT_KEY, 'color')) {
404
+ return props;
405
+ }
406
+
407
+ const borderClasses = getBorderClasses(attributes);
408
+ const newClassName = classnames(props.className, borderClasses); // If we are clearing the last of the previous classes in `className`
409
+ // set it to `undefined` to avoid rendering empty DOM attributes.
410
+
411
+ props.className = newClassName ? newClassName : undefined;
412
+ return props;
413
+ }
414
+ /**
415
+ * Generates a CSS class name consisting of all the applicable border color
416
+ * classes given the current block attributes.
417
+ *
418
+ * @param {Object} attributes Block's attributes.
419
+ *
420
+ * @return {string} CSS class name.
421
+ */
422
+
423
+
424
+ export function getBorderClasses(attributes) {
425
+ var _style$border3;
426
+
427
+ const {
428
+ borderColor,
429
+ style
430
+ } = attributes;
431
+ const borderColorClass = getColorClassName('border-color', borderColor);
432
+ return classnames({
433
+ 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border3 = style.border) === null || _style$border3 === void 0 ? void 0 : _style$border3.color),
434
+ [borderColorClass]: !!borderColorClass
435
+ });
436
+ }
437
+ /**
438
+ * Filters the registered block settings to apply border color styles and
439
+ * classnames to the block edit wrapper.
440
+ *
441
+ * @param {Object} settings Original block settings.
442
+ *
443
+ * @return {Object} Filtered block settings.
444
+ */
445
+
446
+ function addEditProps(settings) {
447
+ if (!hasBorderSupport(settings, 'color') || shouldSkipSerialization(settings, BORDER_SUPPORT_KEY, 'color')) {
448
+ return settings;
449
+ }
450
+
451
+ const existingGetEditWrapperProps = settings.getEditWrapperProps;
452
+
453
+ settings.getEditWrapperProps = attributes => {
454
+ let props = {};
455
+
456
+ if (existingGetEditWrapperProps) {
457
+ props = existingGetEditWrapperProps(attributes);
458
+ }
459
+
460
+ return addSaveProps(props, settings, attributes);
461
+ };
462
+
463
+ return settings;
464
+ }
465
+ /**
466
+ * This adds inline styles for color palette colors.
467
+ * Ideally, this is not needed and themes should load their palettes on the editor.
468
+ *
469
+ * @param {Function} BlockListBlock Original component.
470
+ *
471
+ * @return {Function} Wrapped component.
472
+ */
473
+
474
+
475
+ export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockListBlock => props => {
476
+ var _style$border4, _style$border4$top, _style$border5, _style$border5$right, _style$border6, _style$border6$bottom, _style$border7, _style$border7$left, _props$wrapperProps;
477
+
478
+ const {
479
+ name,
480
+ attributes
481
+ } = props;
482
+ const {
483
+ borderColor,
484
+ style
485
+ } = attributes;
486
+ const {
487
+ colors
488
+ } = useMultipleOriginColorsAndGradients();
489
+
490
+ if (!hasBorderSupport(name, 'color') || shouldSkipSerialization(name, BORDER_SUPPORT_KEY, 'color')) {
491
+ return createElement(BlockListBlock, props);
492
+ }
493
+
494
+ const {
495
+ color: borderColorValue
496
+ } = getMultiOriginColor({
497
+ colors,
498
+ namedColor: borderColor
499
+ });
500
+ const {
501
+ color: borderTopColor
502
+ } = getMultiOriginColor({
503
+ colors,
504
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border4 = style.border) === null || _style$border4 === void 0 ? void 0 : (_style$border4$top = _style$border4.top) === null || _style$border4$top === void 0 ? void 0 : _style$border4$top.color)
505
+ });
506
+ const {
507
+ color: borderRightColor
508
+ } = getMultiOriginColor({
509
+ colors,
510
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border5 = style.border) === null || _style$border5 === void 0 ? void 0 : (_style$border5$right = _style$border5.right) === null || _style$border5$right === void 0 ? void 0 : _style$border5$right.color)
511
+ });
512
+ const {
513
+ color: borderBottomColor
514
+ } = getMultiOriginColor({
515
+ colors,
516
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border6 = style.border) === null || _style$border6 === void 0 ? void 0 : (_style$border6$bottom = _style$border6.bottom) === null || _style$border6$bottom === void 0 ? void 0 : _style$border6$bottom.color)
517
+ });
518
+ const {
519
+ color: borderLeftColor
520
+ } = getMultiOriginColor({
521
+ colors,
522
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border7 = style.border) === null || _style$border7 === void 0 ? void 0 : (_style$border7$left = _style$border7.left) === null || _style$border7$left === void 0 ? void 0 : _style$border7$left.color)
523
+ });
524
+ const extraStyles = {
525
+ borderTopColor: borderTopColor || borderColorValue,
526
+ borderRightColor: borderRightColor || borderColorValue,
527
+ borderBottomColor: borderBottomColor || borderColorValue,
528
+ borderLeftColor: borderLeftColor || borderColorValue
529
+ };
530
+ let wrapperProps = props.wrapperProps;
531
+ wrapperProps = { ...props.wrapperProps,
532
+ style: { ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style),
533
+ ...extraStyles
534
+ }
535
+ };
536
+ return createElement(BlockListBlock, _extends({}, props, {
537
+ wrapperProps: wrapperProps
538
+ }));
539
+ });
540
+ addFilter('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
541
+ addFilter('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', addSaveProps);
542
+ addFilter('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
543
+ addFilter('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
135
544
  //# sourceMappingURL=border.js.map