@wordpress/block-editor 8.5.4 → 9.0.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 (299) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +4 -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-content-overlay/index.js +13 -4
  10. package/build/components/block-content-overlay/index.js.map +1 -1
  11. package/build/components/block-list/block.native.js +3 -1
  12. package/build/components/block-list/block.native.js.map +1 -1
  13. package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
  14. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  15. package/build/components/block-lock/modal.js +34 -4
  16. package/build/components/block-lock/modal.js.map +1 -1
  17. package/build/components/block-lock/toolbar.js +2 -1
  18. package/build/components/block-lock/toolbar.js.map +1 -1
  19. package/build/components/block-lock/use-block-lock.js +4 -1
  20. package/build/components/block-lock/use-block-lock.js.map +1 -1
  21. package/build/components/block-mover/button.js +4 -4
  22. package/build/components/block-mover/button.js.map +1 -1
  23. package/build/components/block-mover/index.js +39 -65
  24. package/build/components/block-mover/index.js.map +1 -1
  25. package/build/components/block-navigation/dropdown.js +11 -5
  26. package/build/components/block-navigation/dropdown.js.map +1 -1
  27. package/build/components/block-popover/inbetween.js +183 -0
  28. package/build/components/block-popover/inbetween.js.map +1 -0
  29. package/build/components/block-popover/index.js +97 -0
  30. package/build/components/block-popover/index.js.map +1 -0
  31. package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
  32. package/build/components/block-popover/use-popover-scroll.js.map +1 -0
  33. package/build/components/block-styles/index.js +1 -10
  34. package/build/components/block-styles/index.js.map +1 -1
  35. package/build/components/block-tools/back-compat.js +2 -2
  36. package/build/components/block-tools/back-compat.js.map +1 -1
  37. package/build/components/block-tools/block-selection-button.js +4 -2
  38. package/build/components/block-tools/block-selection-button.js.map +1 -1
  39. package/build/components/block-tools/index.js +5 -5
  40. package/build/components/block-tools/index.js.map +1 -1
  41. package/build/components/block-tools/insertion-point.js +14 -121
  42. package/build/components/block-tools/insertion-point.js.map +1 -1
  43. package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
  44. package/build/components/block-tools/selected-block-popover.js.map +1 -0
  45. package/build/components/color-style-selector/index.js +9 -0
  46. package/build/components/color-style-selector/index.js.map +1 -1
  47. package/build/components/duotone-control/index.js +5 -1
  48. package/build/components/duotone-control/index.js.map +1 -1
  49. package/build/components/index.js +0 -9
  50. package/build/components/index.js.map +1 -1
  51. package/build/components/inserter/index.native.js +30 -8
  52. package/build/components/inserter/index.native.js.map +1 -1
  53. package/build/components/list-view/block.js +15 -15
  54. package/build/components/list-view/block.js.map +1 -1
  55. package/build/components/list-view/branch.js +9 -13
  56. package/build/components/list-view/branch.js.map +1 -1
  57. package/build/components/list-view/context.js +1 -4
  58. package/build/components/list-view/context.js.map +1 -1
  59. package/build/components/list-view/index.js +15 -32
  60. package/build/components/list-view/index.js.map +1 -1
  61. package/build/components/rich-text/index.js +0 -5
  62. package/build/components/rich-text/index.js.map +1 -1
  63. package/build/components/rich-text/index.native.js +0 -4
  64. package/build/components/rich-text/index.native.js.map +1 -1
  65. package/build/components/url-input/index.js +7 -3
  66. package/build/components/url-input/index.js.map +1 -1
  67. package/build/components/use-block-display-information/index.js +3 -1
  68. package/build/components/use-block-display-information/index.js.map +1 -1
  69. package/build/components/use-setting/index.js +42 -18
  70. package/build/components/use-setting/index.js.map +1 -1
  71. package/build/hooks/border.js +468 -44
  72. package/build/hooks/border.js.map +1 -1
  73. package/build/hooks/dimensions.js +2 -2
  74. package/build/hooks/dimensions.js.map +1 -1
  75. package/build/hooks/index.js +3 -1
  76. package/build/hooks/index.js.map +1 -1
  77. package/build/hooks/margin.js +64 -12
  78. package/build/hooks/margin.js.map +1 -1
  79. package/build/hooks/padding.js +60 -12
  80. package/build/hooks/padding.js.map +1 -1
  81. package/build/hooks/settings.js +32 -0
  82. package/build/hooks/settings.js.map +1 -0
  83. package/build/hooks/use-border-props.js +22 -32
  84. package/build/hooks/use-border-props.js.map +1 -1
  85. package/build/store/actions.js +14 -2
  86. package/build/store/actions.js.map +1 -1
  87. package/build/store/defaults.js +0 -1
  88. package/build/store/defaults.js.map +1 -1
  89. package/build/store/reducer.js +0 -26
  90. package/build/store/reducer.js.map +1 -1
  91. package/build/store/selectors.js +47 -15
  92. package/build/store/selectors.js.map +1 -1
  93. package/build-module/components/block-alignment-control/constants.js +36 -0
  94. package/build-module/components/block-alignment-control/constants.js.map +1 -0
  95. package/build-module/components/block-alignment-control/ui.js +4 -35
  96. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  97. package/build-module/components/block-alignment-control/ui.native.js +78 -0
  98. package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
  99. package/build-module/components/block-content-overlay/index.js +13 -4
  100. package/build-module/components/block-content-overlay/index.js.map +1 -1
  101. package/build-module/components/block-list/block.native.js +3 -1
  102. package/build-module/components/block-list/block.native.js.map +1 -1
  103. package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
  104. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  105. package/build-module/components/block-lock/modal.js +34 -5
  106. package/build-module/components/block-lock/modal.js.map +1 -1
  107. package/build-module/components/block-lock/toolbar.js +2 -1
  108. package/build-module/components/block-lock/toolbar.js.map +1 -1
  109. package/build-module/components/block-lock/use-block-lock.js +4 -1
  110. package/build-module/components/block-lock/use-block-lock.js.map +1 -1
  111. package/build-module/components/block-mover/button.js +5 -5
  112. package/build-module/components/block-mover/button.js.map +1 -1
  113. package/build-module/components/block-mover/index.js +38 -63
  114. package/build-module/components/block-mover/index.js.map +1 -1
  115. package/build-module/components/block-navigation/dropdown.js +10 -5
  116. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  117. package/build-module/components/block-popover/inbetween.js +165 -0
  118. package/build-module/components/block-popover/inbetween.js.map +1 -0
  119. package/build-module/components/block-popover/index.js +83 -0
  120. package/build-module/components/block-popover/index.js.map +1 -0
  121. package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  122. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
  123. package/build-module/components/block-styles/index.js +1 -9
  124. package/build-module/components/block-styles/index.js.map +1 -1
  125. package/build-module/components/block-tools/back-compat.js +1 -1
  126. package/build-module/components/block-tools/back-compat.js.map +1 -1
  127. package/build-module/components/block-tools/block-selection-button.js +3 -2
  128. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  129. package/build-module/components/block-tools/index.js +3 -3
  130. package/build-module/components/block-tools/index.js.map +1 -1
  131. package/build-module/components/block-tools/insertion-point.js +16 -121
  132. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  133. package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
  134. package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
  135. package/build-module/components/color-style-selector/index.js +6 -0
  136. package/build-module/components/color-style-selector/index.js.map +1 -1
  137. package/build-module/components/duotone-control/index.js +4 -1
  138. package/build-module/components/duotone-control/index.js.map +1 -1
  139. package/build-module/components/index.js +0 -1
  140. package/build-module/components/index.js.map +1 -1
  141. package/build-module/components/inserter/index.native.js +31 -10
  142. package/build-module/components/inserter/index.native.js.map +1 -1
  143. package/build-module/components/list-view/block.js +15 -16
  144. package/build-module/components/list-view/block.js.map +1 -1
  145. package/build-module/components/list-view/branch.js +9 -13
  146. package/build-module/components/list-view/branch.js.map +1 -1
  147. package/build-module/components/list-view/context.js +1 -4
  148. package/build-module/components/list-view/context.js.map +1 -1
  149. package/build-module/components/list-view/index.js +15 -31
  150. package/build-module/components/list-view/index.js.map +1 -1
  151. package/build-module/components/rich-text/index.js +0 -4
  152. package/build-module/components/rich-text/index.js.map +1 -1
  153. package/build-module/components/rich-text/index.native.js +0 -4
  154. package/build-module/components/rich-text/index.native.js.map +1 -1
  155. package/build-module/components/url-input/index.js +7 -3
  156. package/build-module/components/url-input/index.js.map +1 -1
  157. package/build-module/components/use-block-display-information/index.js +3 -1
  158. package/build-module/components/use-block-display-information/index.js.map +1 -1
  159. package/build-module/components/use-setting/index.js +43 -19
  160. package/build-module/components/use-setting/index.js.map +1 -1
  161. package/build-module/hooks/border.js +458 -44
  162. package/build-module/hooks/border.js.map +1 -1
  163. package/build-module/hooks/dimensions.js +5 -5
  164. package/build-module/hooks/dimensions.js.map +1 -1
  165. package/build-module/hooks/index.js +2 -1
  166. package/build-module/hooks/index.js.map +1 -1
  167. package/build-module/hooks/margin.js +61 -13
  168. package/build-module/hooks/margin.js.map +1 -1
  169. package/build-module/hooks/padding.js +57 -13
  170. package/build-module/hooks/padding.js.map +1 -1
  171. package/build-module/hooks/settings.js +29 -0
  172. package/build-module/hooks/settings.js.map +1 -0
  173. package/build-module/hooks/use-border-props.js +21 -30
  174. package/build-module/hooks/use-border-props.js.map +1 -1
  175. package/build-module/store/actions.js +14 -2
  176. package/build-module/store/actions.js.map +1 -1
  177. package/build-module/store/defaults.js +0 -1
  178. package/build-module/store/defaults.js.map +1 -1
  179. package/build-module/store/reducer.js +0 -24
  180. package/build-module/store/reducer.js.map +1 -1
  181. package/build-module/store/selectors.js +44 -15
  182. package/build-module/store/selectors.js.map +1 -1
  183. package/build-style/style-rtl.css +128 -276
  184. package/build-style/style.css +128 -276
  185. package/package.json +28 -28
  186. package/src/components/block-alignment-control/constants.js +45 -0
  187. package/src/components/block-alignment-control/ui.js +69 -109
  188. package/src/components/block-alignment-control/ui.native.js +86 -0
  189. package/src/components/block-content-overlay/index.js +19 -2
  190. package/src/components/block-list/block.native.js +2 -0
  191. package/src/components/block-list/style.scss +7 -18
  192. package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
  193. package/src/components/block-lock/modal.js +42 -3
  194. package/src/components/block-lock/toolbar.js +2 -2
  195. package/src/components/block-lock/use-block-lock.js +4 -1
  196. package/src/components/block-mover/button.js +5 -7
  197. package/src/components/block-mover/index.js +37 -60
  198. package/src/components/block-mover/stories/index.js +110 -0
  199. package/src/components/block-mover/style.scss +48 -138
  200. package/src/components/block-navigation/dropdown.js +12 -8
  201. package/src/components/block-popover/README.md +41 -0
  202. package/src/components/block-popover/inbetween.js +180 -0
  203. package/src/components/block-popover/index.js +90 -0
  204. package/src/components/block-popover/style.scss +27 -0
  205. package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  206. package/src/components/block-styles/index.js +1 -12
  207. package/src/components/block-switcher/style.scss +0 -4
  208. package/src/components/block-toolbar/style.scss +0 -12
  209. package/src/components/block-tools/back-compat.js +1 -1
  210. package/src/components/block-tools/block-selection-button.js +3 -1
  211. package/src/components/block-tools/index.js +6 -4
  212. package/src/components/block-tools/insertion-point.js +19 -152
  213. package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
  214. package/src/components/block-tools/style.scss +11 -123
  215. package/src/components/border-radius-control/style.scss +5 -2
  216. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  217. package/src/components/color-style-selector/index.js +18 -9
  218. package/src/components/default-block-appender/style.scss +1 -2
  219. package/src/components/duotone-control/index.js +8 -1
  220. package/src/components/gradients/README.md +29 -0
  221. package/src/components/image-size-control/README.md +1 -1
  222. package/src/components/index.js +0 -1
  223. package/src/components/inserter/index.native.js +60 -25
  224. package/src/components/inserter/style.native.scss +25 -3
  225. package/src/components/list-view/block.js +24 -34
  226. package/src/components/list-view/branch.js +10 -20
  227. package/src/components/list-view/context.js +1 -4
  228. package/src/components/list-view/index.js +11 -41
  229. package/src/components/navigable-toolbar/README.md +16 -0
  230. package/src/components/rich-text/index.js +0 -2
  231. package/src/components/rich-text/index.native.js +0 -4
  232. package/src/components/url-input/index.js +6 -3
  233. package/src/components/use-block-display-information/index.js +2 -0
  234. package/src/components/use-setting/index.js +57 -21
  235. package/src/hooks/border.js +438 -72
  236. package/src/hooks/border.scss +48 -0
  237. package/src/hooks/dimensions.js +44 -38
  238. package/src/hooks/index.js +2 -1
  239. package/src/hooks/margin.js +64 -15
  240. package/src/hooks/padding.js +60 -15
  241. package/src/hooks/padding.scss +12 -0
  242. package/src/hooks/settings.js +32 -0
  243. package/src/hooks/test/settings.js +48 -0
  244. package/src/hooks/use-border-props.js +15 -32
  245. package/src/store/actions.js +14 -2
  246. package/src/store/defaults.js +0 -1
  247. package/src/store/reducer.js +0 -21
  248. package/src/store/selectors.js +46 -15
  249. package/src/store/test/actions.js +0 -18
  250. package/src/store/test/reducer.js +0 -19
  251. package/src/store/test/selectors.js +17 -19
  252. package/src/style.scss +2 -2
  253. package/tsconfig.tsbuildinfo +1 -1
  254. package/build/components/block-mobile-toolbar/index.js +0 -42
  255. package/build/components/block-mobile-toolbar/index.js.map +0 -1
  256. package/build/components/block-tools/block-popover.js.map +0 -1
  257. package/build/components/block-tools/use-popover-scroll.js.map +0 -1
  258. package/build/components/border-style-control/index.js +0 -60
  259. package/build/components/border-style-control/index.js.map +0 -1
  260. package/build/components/list-view/appender.js +0 -93
  261. package/build/components/list-view/appender.js.map +0 -1
  262. package/build/components/list-view/list-item.js +0 -62
  263. package/build/components/list-view/list-item.js.map +0 -1
  264. package/build/components/rich-text/use-caret-in-format.js +0 -43
  265. package/build/components/rich-text/use-caret-in-format.js.map +0 -1
  266. package/build/hooks/border-color.js +0 -302
  267. package/build/hooks/border-color.js.map +0 -1
  268. package/build/hooks/border-style.js +0 -96
  269. package/build/hooks/border-style.js.map +0 -1
  270. package/build/hooks/border-width.js +0 -162
  271. package/build/hooks/border-width.js.map +0 -1
  272. package/build-module/components/block-mobile-toolbar/index.js +0 -31
  273. package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
  274. package/build-module/components/block-tools/block-popover.js.map +0 -1
  275. package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
  276. package/build-module/components/border-style-control/index.js +0 -50
  277. package/build-module/components/border-style-control/index.js.map +0 -1
  278. package/build-module/components/list-view/appender.js +0 -76
  279. package/build-module/components/list-view/appender.js.map +0 -1
  280. package/build-module/components/list-view/list-item.js +0 -47
  281. package/build-module/components/list-view/list-item.js.map +0 -1
  282. package/build-module/components/rich-text/use-caret-in-format.js +0 -33
  283. package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
  284. package/build-module/hooks/border-color.js +0 -276
  285. package/build-module/hooks/border-color.js.map +0 -1
  286. package/build-module/hooks/border-style.js +0 -78
  287. package/build-module/hooks/border-style.js.map +0 -1
  288. package/build-module/hooks/border-width.js +0 -143
  289. package/build-module/hooks/border-width.js.map +0 -1
  290. package/src/components/block-mobile-toolbar/index.js +0 -24
  291. package/src/components/block-mobile-toolbar/style.scss +0 -29
  292. package/src/components/border-style-control/index.js +0 -47
  293. package/src/components/border-style-control/style.scss +0 -18
  294. package/src/components/list-view/appender.js +0 -82
  295. package/src/components/list-view/list-item.js +0 -59
  296. package/src/components/rich-text/use-caret-in-format.js +0 -28
  297. package/src/hooks/border-color.js +0 -315
  298. package/src/hooks/border-style.js +0 -64
  299. package/src/hooks/border-width.js +0 -139
@@ -3,3 +3,51 @@
3
3
  grid-column: span 1;
4
4
  }
5
5
  }
6
+
7
+ .block-editor__border-box-control__popover,
8
+ .block-editor__border-box-control__popover-top,
9
+ .block-editor__border-box-control__popover-right,
10
+ .block-editor__border-box-control__popover-bottom,
11
+ .block-editor__border-box-control__popover-left {
12
+ .components-popover__content {
13
+ width: 282px;
14
+ }
15
+ }
16
+
17
+ $split-border-control-offset: 55px;
18
+
19
+ @include break-medium() {
20
+ .block-editor__border-box-control__popover,
21
+ .block-editor__border-box-control__popover-left {
22
+ .components-popover__content {
23
+ margin-right: #{ $grid-unit-50 + $grid-unit-15 } !important;
24
+ }
25
+ }
26
+
27
+ .block-editor__border-box-control__popover-top,
28
+ .block-editor__border-box-control__popover-bottom {
29
+ .components-popover__content {
30
+ margin-right: #{ $grid-unit-50 + $grid-unit-15 + $split-border-control-offset } !important;
31
+ }
32
+ }
33
+
34
+ .block-editor__border-box-control__popover-right {
35
+ .components-popover__content {
36
+ margin-right: #{ $grid-unit-50 + $grid-unit-15 + ( $split-border-control-offset * 2 )} !important;
37
+ }
38
+ }
39
+
40
+ .block-editor__border-box-control__popover,
41
+ .block-editor__border-box-control__popover-top,
42
+ .block-editor__border-box-control__popover-right,
43
+ .block-editor__border-box-control__popover-bottom,
44
+ .block-editor__border-box-control__popover-left {
45
+ &.is-from-top .components-popover__content {
46
+ margin-top: #{ -($grid-unit-50 + $grid-unit-15) } !important;
47
+ }
48
+
49
+ &.is-from-bottom .components-popover__content {
50
+ margin-bottom: #{ -($grid-unit-50 + $grid-unit-15) } !important;
51
+ }
52
+ }
53
+ }
@@ -19,6 +19,7 @@ import {
19
19
  } from './gap';
20
20
  import {
21
21
  MarginEdit,
22
+ MarginVisualizer,
22
23
  hasMarginSupport,
23
24
  hasMarginValue,
24
25
  resetMargin,
@@ -26,6 +27,7 @@ import {
26
27
  } from './margin';
27
28
  import {
28
29
  PaddingEdit,
30
+ PaddingVisualizer,
29
31
  hasPaddingSupport,
30
32
  hasPaddingValue,
31
33
  resetPadding,
@@ -71,44 +73,48 @@ export function DimensionsPanel( props ) {
71
73
  } );
72
74
 
73
75
  return (
74
- <InspectorControls __experimentalGroup="dimensions">
75
- { ! isPaddingDisabled && (
76
- <ToolsPanelItem
77
- hasValue={ () => hasPaddingValue( props ) }
78
- label={ __( 'Padding' ) }
79
- onDeselect={ () => resetPadding( props ) }
80
- resetAllFilter={ createResetAllFilter( 'padding' ) }
81
- isShownByDefault={ defaultSpacingControls?.padding }
82
- panelId={ props.clientId }
83
- >
84
- <PaddingEdit { ...props } />
85
- </ToolsPanelItem>
86
- ) }
87
- { ! isMarginDisabled && (
88
- <ToolsPanelItem
89
- hasValue={ () => hasMarginValue( props ) }
90
- label={ __( 'Margin' ) }
91
- onDeselect={ () => resetMargin( props ) }
92
- resetAllFilter={ createResetAllFilter( 'margin' ) }
93
- isShownByDefault={ defaultSpacingControls?.margin }
94
- panelId={ props.clientId }
95
- >
96
- <MarginEdit { ...props } />
97
- </ToolsPanelItem>
98
- ) }
99
- { ! isGapDisabled && (
100
- <ToolsPanelItem
101
- hasValue={ () => hasGapValue( props ) }
102
- label={ __( 'Block spacing' ) }
103
- onDeselect={ () => resetGap( props ) }
104
- resetAllFilter={ createResetAllFilter( 'blockGap' ) }
105
- isShownByDefault={ defaultSpacingControls?.blockGap }
106
- panelId={ props.clientId }
107
- >
108
- <GapEdit { ...props } />
109
- </ToolsPanelItem>
110
- ) }
111
- </InspectorControls>
76
+ <>
77
+ <InspectorControls __experimentalGroup="dimensions">
78
+ { ! isPaddingDisabled && (
79
+ <ToolsPanelItem
80
+ hasValue={ () => hasPaddingValue( props ) }
81
+ label={ __( 'Padding' ) }
82
+ onDeselect={ () => resetPadding( props ) }
83
+ resetAllFilter={ createResetAllFilter( 'padding' ) }
84
+ isShownByDefault={ defaultSpacingControls?.padding }
85
+ panelId={ props.clientId }
86
+ >
87
+ <PaddingEdit { ...props } />
88
+ </ToolsPanelItem>
89
+ ) }
90
+ { ! isMarginDisabled && (
91
+ <ToolsPanelItem
92
+ hasValue={ () => hasMarginValue( props ) }
93
+ label={ __( 'Margin' ) }
94
+ onDeselect={ () => resetMargin( props ) }
95
+ resetAllFilter={ createResetAllFilter( 'margin' ) }
96
+ isShownByDefault={ defaultSpacingControls?.margin }
97
+ panelId={ props.clientId }
98
+ >
99
+ <MarginEdit { ...props } />
100
+ </ToolsPanelItem>
101
+ ) }
102
+ { ! isGapDisabled && (
103
+ <ToolsPanelItem
104
+ hasValue={ () => hasGapValue( props ) }
105
+ label={ __( 'Block spacing' ) }
106
+ onDeselect={ () => resetGap( props ) }
107
+ resetAllFilter={ createResetAllFilter( 'blockGap' ) }
108
+ isShownByDefault={ defaultSpacingControls?.blockGap }
109
+ panelId={ props.clientId }
110
+ >
111
+ <GapEdit { ...props } />
112
+ </ToolsPanelItem>
113
+ ) }
114
+ </InspectorControls>
115
+ { ! isPaddingDisabled && <PaddingVisualizer { ...props } /> }
116
+ { ! isMarginDisabled && <MarginVisualizer { ...props } /> }
117
+ </>
112
118
  );
113
119
  }
114
120
 
@@ -8,10 +8,11 @@ import './anchor';
8
8
  import './custom-class-name';
9
9
  import './generated-class-name';
10
10
  import './style';
11
+ import './settings';
11
12
  import './color';
12
13
  import './duotone';
13
14
  import './font-size';
14
- import './border-color';
15
+ import './border';
15
16
  import './layout';
16
17
 
17
18
  export { useCustomSides } from './dimensions';
@@ -2,12 +2,19 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { Platform } from '@wordpress/element';
5
+ import {
6
+ Platform,
7
+ useMemo,
8
+ useRef,
9
+ useState,
10
+ useEffect,
11
+ } from '@wordpress/element';
6
12
  import { getBlockSupport } from '@wordpress/blocks';
7
13
  import {
8
14
  __experimentalUseCustomUnits as useCustomUnits,
9
15
  __experimentalBoxControl as BoxControl,
10
16
  } from '@wordpress/components';
17
+ import isShallowEqual from '@wordpress/is-shallow-equal';
11
18
 
12
19
  /**
13
20
  * Internal dependencies
@@ -20,6 +27,7 @@ import {
20
27
  useIsDimensionsSupportValid,
21
28
  } from './dimensions';
22
29
  import { cleanEmptyObject } from './utils';
30
+ import BlockPopover from '../components/block-popover';
23
31
 
24
32
  /**
25
33
  * Determines if there is margin support.
@@ -124,26 +132,12 @@ export function MarginEdit( props ) {
124
132
  } );
125
133
  };
126
134
 
127
- const onChangeShowVisualizer = ( next ) => {
128
- const newStyle = {
129
- ...style,
130
- visualizers: {
131
- margin: next,
132
- },
133
- };
134
-
135
- setAttributes( {
136
- style: cleanEmptyObject( newStyle ),
137
- } );
138
- };
139
-
140
135
  return Platform.select( {
141
136
  web: (
142
137
  <>
143
138
  <BoxControl
144
139
  values={ style?.spacing?.margin }
145
140
  onChange={ onChange }
146
- onChangeShowVisualizer={ onChangeShowVisualizer }
147
141
  label={ __( 'Margin' ) }
148
142
  sides={ sides }
149
143
  units={ units }
@@ -155,3 +149,58 @@ export function MarginEdit( props ) {
155
149
  native: null,
156
150
  } );
157
151
  }
152
+
153
+ export function MarginVisualizer( { clientId, attributes } ) {
154
+ const margin = attributes?.style?.spacing?.margin;
155
+ const style = useMemo( () => {
156
+ return {
157
+ borderTopWidth: margin?.top ?? 0,
158
+ borderRightWidth: margin?.right ?? 0,
159
+ borderBottomWidth: margin?.bottom ?? 0,
160
+ borderLeftWidth: margin?.left ?? 0,
161
+ top: margin?.top ? `-${ margin.top }` : 0,
162
+ right: margin?.right ? `-${ margin.right }` : 0,
163
+ bottom: margin?.bottom ? `-${ margin.bottom }` : 0,
164
+ left: margin?.left ? `-${ margin.left }` : 0,
165
+ };
166
+ }, [ margin ] );
167
+
168
+ const [ isActive, setIsActive ] = useState( false );
169
+ const valueRef = useRef( margin );
170
+ const timeoutRef = useRef();
171
+
172
+ const clearTimer = () => {
173
+ if ( timeoutRef.current ) {
174
+ window.clearTimeout( timeoutRef.current );
175
+ }
176
+ };
177
+
178
+ useEffect( () => {
179
+ if ( ! isShallowEqual( margin, valueRef.current ) ) {
180
+ setIsActive( true );
181
+ valueRef.current = margin;
182
+
183
+ clearTimer();
184
+
185
+ timeoutRef.current = setTimeout( () => {
186
+ setIsActive( false );
187
+ }, 400 );
188
+ }
189
+
190
+ return () => clearTimer();
191
+ }, [ margin ] );
192
+
193
+ if ( ! isActive ) {
194
+ return null;
195
+ }
196
+
197
+ return (
198
+ <BlockPopover
199
+ clientId={ clientId }
200
+ __unstableCoverTarget
201
+ __unstableRefreshSize={ margin }
202
+ >
203
+ <div className="block-editor__padding-visualizer" style={ style } />
204
+ </BlockPopover>
205
+ );
206
+ }
@@ -2,12 +2,19 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { Platform } from '@wordpress/element';
5
+ import {
6
+ Platform,
7
+ useState,
8
+ useRef,
9
+ useEffect,
10
+ useMemo,
11
+ } from '@wordpress/element';
6
12
  import { getBlockSupport } from '@wordpress/blocks';
7
13
  import {
8
14
  __experimentalUseCustomUnits as useCustomUnits,
9
15
  __experimentalBoxControl as BoxControl,
10
16
  } from '@wordpress/components';
17
+ import isShallowEqual from '@wordpress/is-shallow-equal';
11
18
 
12
19
  /**
13
20
  * Internal dependencies
@@ -20,6 +27,7 @@ import {
20
27
  useIsDimensionsSupportValid,
21
28
  } from './dimensions';
22
29
  import { cleanEmptyObject } from './utils';
30
+ import BlockPopover from '../components/block-popover';
23
31
 
24
32
  /**
25
33
  * Determines if there is padding support.
@@ -124,26 +132,12 @@ export function PaddingEdit( props ) {
124
132
  } );
125
133
  };
126
134
 
127
- const onChangeShowVisualizer = ( next ) => {
128
- const newStyle = {
129
- ...style,
130
- visualizers: {
131
- padding: next,
132
- },
133
- };
134
-
135
- setAttributes( {
136
- style: cleanEmptyObject( newStyle ),
137
- } );
138
- };
139
-
140
135
  return Platform.select( {
141
136
  web: (
142
137
  <>
143
138
  <BoxControl
144
139
  values={ style?.spacing?.padding }
145
140
  onChange={ onChange }
146
- onChangeShowVisualizer={ onChangeShowVisualizer }
147
141
  label={ __( 'Padding' ) }
148
142
  sides={ sides }
149
143
  units={ units }
@@ -155,3 +149,54 @@ export function PaddingEdit( props ) {
155
149
  native: null,
156
150
  } );
157
151
  }
152
+
153
+ export function PaddingVisualizer( { clientId, attributes } ) {
154
+ const padding = attributes?.style?.spacing?.padding;
155
+ const style = useMemo( () => {
156
+ return {
157
+ borderTopWidth: padding?.top ?? 0,
158
+ borderRightWidth: padding?.right ?? 0,
159
+ borderBottomWidth: padding?.bottom ?? 0,
160
+ borderLeftWidth: padding?.left ?? 0,
161
+ };
162
+ }, [ padding ] );
163
+
164
+ const [ isActive, setIsActive ] = useState( false );
165
+ const valueRef = useRef( padding );
166
+ const timeoutRef = useRef();
167
+
168
+ const clearTimer = () => {
169
+ if ( timeoutRef.current ) {
170
+ window.clearTimeout( timeoutRef.current );
171
+ }
172
+ };
173
+
174
+ useEffect( () => {
175
+ if ( ! isShallowEqual( padding, valueRef.current ) ) {
176
+ setIsActive( true );
177
+ valueRef.current = padding;
178
+
179
+ clearTimer();
180
+
181
+ timeoutRef.current = setTimeout( () => {
182
+ setIsActive( false );
183
+ }, 400 );
184
+ }
185
+
186
+ return () => clearTimer();
187
+ }, [ padding ] );
188
+
189
+ if ( ! isActive ) {
190
+ return null;
191
+ }
192
+
193
+ return (
194
+ <BlockPopover
195
+ clientId={ clientId }
196
+ __unstableCoverTarget
197
+ __unstableRefreshSize={ padding }
198
+ >
199
+ <div className="block-editor__padding-visualizer" style={ style } />
200
+ </BlockPopover>
201
+ );
202
+ }
@@ -0,0 +1,12 @@
1
+ .block-editor__padding-visualizer {
2
+ position: absolute;
3
+ top: 0;
4
+ bottom: 0;
5
+ left: 0;
6
+ right: 0;
7
+ opacity: 0.5;
8
+ border-color: var(--wp-admin-theme-color);
9
+ border-style: solid;
10
+ pointer-events: none;
11
+ box-sizing: border-box;
12
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { addFilter } from '@wordpress/hooks';
5
+ import { hasBlockSupport } from '@wordpress/blocks';
6
+
7
+ const hasSettingsSupport = ( blockType ) =>
8
+ hasBlockSupport( blockType, '__experimentalSettings', false );
9
+
10
+ function addAttribute( settings ) {
11
+ if ( ! hasSettingsSupport( settings ) ) {
12
+ return settings;
13
+ }
14
+
15
+ // Allow blocks to specify their own attribute definition with default values if needed.
16
+ if ( ! settings?.attributes?.settings ) {
17
+ settings.attributes = {
18
+ ...settings.attributes,
19
+ settings: {
20
+ type: 'object',
21
+ },
22
+ };
23
+ }
24
+
25
+ return settings;
26
+ }
27
+
28
+ addFilter(
29
+ 'blocks.registerBlockType',
30
+ 'core/settings/addAttribute',
31
+ addAttribute
32
+ );
@@ -0,0 +1,48 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { applyFilters } from '@wordpress/hooks';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import '../settings';
10
+
11
+ describe( 'with settings', () => {
12
+ const blockSettings = {
13
+ save: () => <div className="default" />,
14
+ category: 'text',
15
+ title: 'block title',
16
+ };
17
+
18
+ describe( 'addAttribute', () => {
19
+ const addAttribute = applyFilters.bind(
20
+ null,
21
+ 'blocks.registerBlockType'
22
+ );
23
+
24
+ it( 'does not have settings att if settings block support is not enabled', () => {
25
+ const settings = addAttribute( {
26
+ ...blockSettings,
27
+ supports: {
28
+ __experimentalSettings: false,
29
+ },
30
+ } );
31
+
32
+ expect( settings.attributes ).toBe( undefined );
33
+ } );
34
+
35
+ it( 'has settings att if settings block supports is enabled', () => {
36
+ const settings = addAttribute( {
37
+ ...blockSettings,
38
+ supports: {
39
+ __experimentalSettings: true,
40
+ },
41
+ } );
42
+
43
+ expect( settings.attributes ).toStrictEqual( {
44
+ settings: { type: 'object' },
45
+ } );
46
+ } );
47
+ } );
48
+ } );
@@ -1,46 +1,28 @@
1
- /**
2
- * External dependencies
3
- */
4
- import classnames from 'classnames';
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
9
4
  import { getInlineStyles } from './style';
10
- import {
11
- getColorClassName,
12
- getColorObjectByAttributeValues,
13
- } from '../components/colors';
14
- import useSetting from '../components/use-setting';
5
+ import { getBorderClasses, getMultiOriginColor } from './border';
6
+ import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
15
7
 
16
8
  // This utility is intended to assist where the serialization of the border
17
9
  // block support is being skipped for a block but the border related CSS classes
18
10
  // & styles still need to be generated so they can be applied to inner elements.
19
11
 
20
- const EMPTY_ARRAY = [];
21
-
22
12
  /**
23
13
  * Provides the CSS class names and inline styles for a block's border support
24
14
  * attributes.
25
15
  *
26
- * @param {Object} attributes Block attributes.
27
- * @param {string} attributes.borderColor Selected named border color.
28
- * @param {Object} attributes.style Block's styles attribute.
29
- *
16
+ * @param {Object} attributes Block attributes.
30
17
  * @return {Object} Border block support derived CSS classes & styles.
31
18
  */
32
- export function getBorderClassesAndStyles( { borderColor, style } ) {
33
- const borderStyles = style?.border || {};
34
- const borderClass = getColorClassName( 'border-color', borderColor );
35
-
36
- const className = classnames( {
37
- [ borderClass ]: !! borderClass,
38
- 'has-border-color': borderColor || style?.border?.color,
39
- } );
19
+ export function getBorderClassesAndStyles( attributes ) {
20
+ const border = attributes.style?.border || {};
21
+ const className = getBorderClasses( attributes );
40
22
 
41
23
  return {
42
24
  className: className || undefined,
43
- style: getInlineStyles( { border: borderStyles } ),
25
+ style: getInlineStyles( { border } ),
44
26
  };
45
27
  }
46
28
 
@@ -56,16 +38,17 @@ export function getBorderClassesAndStyles( { borderColor, style } ) {
56
38
  * @return {Object} ClassName & style props from border block support.
57
39
  */
58
40
  export function useBorderProps( attributes ) {
59
- const colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;
41
+ const { colors } = useMultipleOriginColorsAndGradients();
60
42
  const borderProps = getBorderClassesAndStyles( attributes );
43
+ const { borderColor } = attributes;
61
44
 
62
- // Force inline style to apply border color when themes do not load their
63
- // color stylesheets in the editor.
64
- if ( attributes.borderColor ) {
65
- const borderColorObject = getColorObjectByAttributeValues(
45
+ // Force inline styles to apply named border colors when themes do not load
46
+ // their color stylesheets in the editor.
47
+ if ( borderColor ) {
48
+ const borderColorObject = getMultiOriginColor( {
66
49
  colors,
67
- attributes.borderColor
68
- );
50
+ namedColor: borderColor,
51
+ } );
69
52
 
70
53
  borderProps.style.borderColor = borderColorObject.color;
71
54
  }
@@ -1261,22 +1261,34 @@ export function stopDraggingBlocks() {
1261
1261
  /**
1262
1262
  * Returns an action object used in signalling that the caret has entered formatted text.
1263
1263
  *
1264
+ * @deprecated
1265
+ *
1264
1266
  * @return {Object} Action object.
1265
1267
  */
1266
1268
  export function enterFormattedText() {
1269
+ deprecated( 'wp.data.dispatch( "core/block-editor" ).enterFormattedText', {
1270
+ since: '6.1',
1271
+ version: '6.3',
1272
+ } );
1267
1273
  return {
1268
- type: 'ENTER_FORMATTED_TEXT',
1274
+ type: 'DO_NOTHING',
1269
1275
  };
1270
1276
  }
1271
1277
 
1272
1278
  /**
1273
1279
  * Returns an action object used in signalling that the user caret has exited formatted text.
1274
1280
  *
1281
+ * @deprecated
1282
+ *
1275
1283
  * @return {Object} Action object.
1276
1284
  */
1277
1285
  export function exitFormattedText() {
1286
+ deprecated( 'wp.data.dispatch( "core/block-editor" ).exitFormattedText', {
1287
+ since: '6.1',
1288
+ version: '6.3',
1289
+ } );
1278
1290
  return {
1279
- type: 'EXIT_FORMATTED_TEXT',
1291
+ type: 'DO_NOTHING',
1280
1292
  };
1281
1293
  }
1282
1294
 
@@ -160,7 +160,6 @@ export const SETTINGS_DEFAULTS = {
160
160
  __mobileEnablePageTemplates: false,
161
161
  __experimentalBlockPatterns: [],
162
162
  __experimentalBlockPatternCategories: [],
163
- __experimentalSpotlightEntityBlocks: [],
164
163
  __unstableGalleryWithImageBlocks: false,
165
164
 
166
165
  generateAnchors: false,
@@ -1181,26 +1181,6 @@ export function draggedBlocks( state = [], action ) {
1181
1181
  return state;
1182
1182
  }
1183
1183
 
1184
- /**
1185
- * Reducer returning whether the caret is within formatted text.
1186
- *
1187
- * @param {boolean} state Current state.
1188
- * @param {Object} action Dispatched action.
1189
- *
1190
- * @return {boolean} Updated state.
1191
- */
1192
- export function isCaretWithinFormattedText( state = false, action ) {
1193
- switch ( action.type ) {
1194
- case 'ENTER_FORMATTED_TEXT':
1195
- return true;
1196
-
1197
- case 'EXIT_FORMATTED_TEXT':
1198
- return false;
1199
- }
1200
-
1201
- return state;
1202
- }
1203
-
1204
1184
  /**
1205
1185
  * Internal helper reducer for selectionStart and selectionEnd. Can hold a block
1206
1186
  * selection, represented by an object with property clientId.
@@ -1765,7 +1745,6 @@ export default combineReducers( {
1765
1745
  blocks,
1766
1746
  isTyping,
1767
1747
  draggedBlocks,
1768
- isCaretWithinFormattedText,
1769
1748
  selection,
1770
1749
  isMultiSelecting,
1771
1750
  isSelectionEnabled,