@wordpress/block-editor 12.3.6 → 12.3.8

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 (143) hide show
  1. package/README.md +0 -4
  2. package/build/components/block-draggable/index.js +6 -3
  3. package/build/components/block-draggable/index.js.map +1 -1
  4. package/build/components/block-removal-warning-modal/index.js +15 -25
  5. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  6. package/build/components/colors-gradients/control.js +4 -2
  7. package/build/components/colors-gradients/control.js.map +1 -1
  8. package/build/components/global-styles/dimensions-panel.js +13 -2
  9. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  10. package/build/components/iframe/index.js +16 -3
  11. package/build/components/iframe/index.js.map +1 -1
  12. package/build/components/iframe/use-compatibility-styles.js +5 -0
  13. package/build/components/iframe/use-compatibility-styles.js.map +1 -1
  14. package/build/components/index.js +1 -10
  15. package/build/components/index.js.map +1 -1
  16. package/build/components/inserter/reusable-block-rename-hint.js +23 -3
  17. package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
  18. package/build/components/link-control/constants.js +1 -1
  19. package/build/components/link-control/constants.js.map +1 -1
  20. package/build/components/link-control/search-create-button.js +5 -21
  21. package/build/components/link-control/search-create-button.js.map +1 -1
  22. package/build/components/link-control/search-item.js +13 -30
  23. package/build/components/link-control/search-item.js.map +1 -1
  24. package/build/components/link-control/search-results.js +2 -2
  25. package/build/components/link-control/search-results.js.map +1 -1
  26. package/build/components/rich-text/get-rich-text-values.js +7 -1
  27. package/build/components/rich-text/get-rich-text-values.js.map +1 -1
  28. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  29. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  30. package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
  31. package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
  32. package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
  33. package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
  34. package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
  35. package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
  36. package/build/components/spacing-sizes-control/utils.js +1 -1
  37. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  38. package/build/components/use-block-display-information/index.js +7 -3
  39. package/build/components/use-block-display-information/index.js.map +1 -1
  40. package/build/hooks/margin.js +1 -1
  41. package/build/hooks/margin.js.map +1 -1
  42. package/build/hooks/padding.js +1 -1
  43. package/build/hooks/padding.js.map +1 -1
  44. package/build/private-apis.js +5 -1
  45. package/build/private-apis.js.map +1 -1
  46. package/build/store/index.js +10 -1
  47. package/build/store/index.js.map +1 -1
  48. package/build/store/private-actions.js +36 -36
  49. package/build/store/private-actions.js.map +1 -1
  50. package/build/store/private-selectors.js +3 -3
  51. package/build/store/private-selectors.js.map +1 -1
  52. package/build/store/reducer.js +16 -8
  53. package/build/store/reducer.js.map +1 -1
  54. package/build/store/selectors.js +1 -1
  55. package/build/store/selectors.js.map +1 -1
  56. package/build-module/components/block-draggable/index.js +6 -3
  57. package/build-module/components/block-draggable/index.js.map +1 -1
  58. package/build-module/components/block-removal-warning-modal/index.js +16 -23
  59. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  60. package/build-module/components/colors-gradients/control.js +3 -2
  61. package/build-module/components/colors-gradients/control.js.map +1 -1
  62. package/build-module/components/global-styles/dimensions-panel.js +13 -2
  63. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  64. package/build-module/components/iframe/index.js +16 -3
  65. package/build-module/components/iframe/index.js.map +1 -1
  66. package/build-module/components/iframe/use-compatibility-styles.js +5 -0
  67. package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
  68. package/build-module/components/index.js +0 -5
  69. package/build-module/components/index.js.map +1 -1
  70. package/build-module/components/inserter/reusable-block-rename-hint.js +22 -3
  71. package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
  72. package/build-module/components/link-control/constants.js +1 -1
  73. package/build-module/components/link-control/constants.js.map +1 -1
  74. package/build-module/components/link-control/search-create-button.js +7 -20
  75. package/build-module/components/link-control/search-create-button.js.map +1 -1
  76. package/build-module/components/link-control/search-item.js +14 -28
  77. package/build-module/components/link-control/search-item.js.map +1 -1
  78. package/build-module/components/link-control/search-results.js +3 -3
  79. package/build-module/components/link-control/search-results.js.map +1 -1
  80. package/build-module/components/rich-text/get-rich-text-values.js +7 -1
  81. package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
  82. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  83. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  84. package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
  85. package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
  86. package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
  87. package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
  88. package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
  89. package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
  90. package/build-module/components/spacing-sizes-control/utils.js +1 -1
  91. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  92. package/build-module/components/use-block-display-information/index.js +7 -3
  93. package/build-module/components/use-block-display-information/index.js.map +1 -1
  94. package/build-module/hooks/margin.js +1 -1
  95. package/build-module/hooks/margin.js.map +1 -1
  96. package/build-module/hooks/padding.js +1 -1
  97. package/build-module/hooks/padding.js.map +1 -1
  98. package/build-module/private-apis.js +4 -1
  99. package/build-module/private-apis.js.map +1 -1
  100. package/build-module/store/index.js +10 -1
  101. package/build-module/store/index.js.map +1 -1
  102. package/build-module/store/private-actions.js +35 -32
  103. package/build-module/store/private-actions.js.map +1 -1
  104. package/build-module/store/private-selectors.js +2 -2
  105. package/build-module/store/private-selectors.js.map +1 -1
  106. package/build-module/store/reducer.js +16 -8
  107. package/build-module/store/reducer.js.map +1 -1
  108. package/build-module/store/selectors.js +1 -1
  109. package/build-module/store/selectors.js.map +1 -1
  110. package/build-style/style-rtl.css +20 -83
  111. package/build-style/style.css +20 -83
  112. package/package.json +10 -10
  113. package/src/components/block-draggable/index.js +13 -4
  114. package/src/components/block-removal-warning-modal/index.js +13 -27
  115. package/src/components/colors-gradients/control.js +3 -2
  116. package/src/components/global-styles/dimensions-panel.js +8 -2
  117. package/src/components/iframe/index.js +15 -10
  118. package/src/components/iframe/use-compatibility-styles.js +5 -0
  119. package/src/components/index.js +0 -5
  120. package/src/components/inserter/reusable-block-rename-hint.js +18 -1
  121. package/src/components/link-control/constants.js +1 -1
  122. package/src/components/link-control/search-create-button.js +8 -26
  123. package/src/components/link-control/search-item.js +21 -43
  124. package/src/components/link-control/search-results.js +48 -46
  125. package/src/components/link-control/style.scss +25 -95
  126. package/src/components/link-control/test/index.js +6 -7
  127. package/src/components/rich-text/get-rich-text-values.js +11 -1
  128. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  129. package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
  130. package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
  131. package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
  132. package/src/components/spacing-sizes-control/utils.js +1 -1
  133. package/src/components/use-block-display-information/index.js +12 -5
  134. package/src/hooks/margin.js +4 -1
  135. package/src/hooks/padding.js +4 -1
  136. package/src/private-apis.js +6 -0
  137. package/src/store/index.js +10 -0
  138. package/src/store/private-actions.js +33 -36
  139. package/src/store/private-selectors.js +2 -2
  140. package/src/store/reducer.js +16 -8
  141. package/src/store/selectors.js +1 -1
  142. package/src/store/test/actions.js +3 -0
  143. package/src/store/test/selectors.js +1 -1
@@ -1,21 +1,15 @@
1
- /**
2
- * External dependencies
3
- */
4
- import classnames from 'classnames';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
9
4
  import { __, sprintf } from '@wordpress/i18n';
10
- import { Button } from '@wordpress/components';
5
+ import { MenuItem } from '@wordpress/components';
11
6
  import { createInterpolateElement } from '@wordpress/element';
12
- import { Icon, plus } from '@wordpress/icons';
7
+ import { plus } from '@wordpress/icons';
13
8
 
14
9
  export const LinkControlSearchCreate = ( {
15
10
  searchTerm,
16
11
  onClick,
17
12
  itemProps,
18
- isSelected,
19
13
  buttonText,
20
14
  } ) => {
21
15
  if ( ! searchTerm ) {
@@ -40,27 +34,15 @@ export const LinkControlSearchCreate = ( {
40
34
  }
41
35
 
42
36
  return (
43
- <Button
37
+ <MenuItem
44
38
  { ...itemProps }
45
- className={ classnames(
46
- 'block-editor-link-control__search-create block-editor-link-control__search-item',
47
- {
48
- 'is-selected': isSelected,
49
- }
50
- ) }
39
+ iconPosition="left"
40
+ icon={ plus }
41
+ className="block-editor-link-control__search-item"
51
42
  onClick={ onClick }
52
43
  >
53
- <Icon
54
- className="block-editor-link-control__search-item-icon"
55
- icon={ plus }
56
- />
57
-
58
- <span className="block-editor-link-control__search-item-header">
59
- <span className="block-editor-link-control__search-item-title">
60
- { text }
61
- </span>
62
- </span>
63
- </Button>
44
+ { text }
45
+ </MenuItem>
64
46
  );
65
47
  };
66
48
 
@@ -1,14 +1,8 @@
1
- /**
2
- * External dependencies
3
- */
4
- import classnames from 'classnames';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
9
- import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
10
4
  import { __ } from '@wordpress/i18n';
11
- import { Button, TextHighlight } from '@wordpress/components';
5
+ import { MenuItem, TextHighlight } from '@wordpress/components';
12
6
  import {
13
7
  Icon,
14
8
  globe,
@@ -19,6 +13,7 @@ import {
19
13
  file,
20
14
  } from '@wordpress/icons';
21
15
  import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
16
+ import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
22
17
 
23
18
  const ICONS_MAP = {
24
19
  post: postList,
@@ -52,50 +47,33 @@ function SearchItemIcon( { isURL, suggestion } ) {
52
47
  export const LinkControlSearchItem = ( {
53
48
  itemProps,
54
49
  suggestion,
55
- isSelected = false,
50
+ searchTerm,
56
51
  onClick,
57
52
  isURL = false,
58
- searchTerm = '',
59
53
  shouldShowType = false,
60
54
  } ) => {
55
+ const info = isURL
56
+ ? __( 'Press ENTER to add this link' )
57
+ : filterURLForDisplay( safeDecodeURI( suggestion?.url ) );
58
+
61
59
  return (
62
- <Button
60
+ <MenuItem
63
61
  { ...itemProps }
62
+ info={ info }
63
+ iconPosition="left"
64
+ icon={
65
+ <SearchItemIcon suggestion={ suggestion } isURL={ isURL } />
66
+ }
64
67
  onClick={ onClick }
65
- className={ classnames( 'block-editor-link-control__search-item', {
66
- 'is-selected': isSelected,
67
- 'is-url': isURL,
68
- 'is-entity': ! isURL,
69
- } ) }
68
+ shortcut={ shouldShowType && getVisualTypeName( suggestion ) }
69
+ className="block-editor-link-control__search-item"
70
70
  >
71
- <SearchItemIcon suggestion={ suggestion } isURL={ isURL } />
72
-
73
- <span className="block-editor-link-control__search-item-header">
74
- <span className="block-editor-link-control__search-item-title">
75
- <TextHighlight
76
- // The component expects a plain text string.
77
- text={ stripHTML( suggestion.title ) }
78
- highlight={ searchTerm }
79
- />
80
- </span>
81
- <span
82
- aria-hidden={ ! isURL }
83
- className="block-editor-link-control__search-item-info"
84
- >
85
- { ! isURL &&
86
- ( filterURLForDisplay(
87
- safeDecodeURI( suggestion.url )
88
- ) ||
89
- '' ) }
90
- { isURL && __( 'Press ENTER to add this link' ) }
91
- </span>
92
- </span>
93
- { shouldShowType && suggestion.type && (
94
- <span className="block-editor-link-control__search-item-type">
95
- { getVisualTypeName( suggestion ) }
96
- </span>
97
- ) }
98
- </Button>
71
+ <TextHighlight
72
+ // The component expects a plain text string.
73
+ text={ stripHTML( suggestion.title ) }
74
+ highlight={ searchTerm }
75
+ />
76
+ </MenuItem>
99
77
  );
100
78
  };
101
79
 
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __, sprintf } from '@wordpress/i18n';
5
- import { VisuallyHidden } from '@wordpress/components';
5
+ import { VisuallyHidden, MenuGroup } from '@wordpress/components';
6
6
 
7
7
  /**
8
8
  * External dependencies
@@ -72,59 +72,61 @@ export default function LinkControlSearchResults( {
72
72
  className={ resultsListClasses }
73
73
  aria-labelledby={ searchResultsLabelId }
74
74
  >
75
- { suggestions.map( ( suggestion, index ) => {
76
- if (
77
- shouldShowCreateSuggestion &&
78
- CREATE_TYPE === suggestion.type
79
- ) {
75
+ <MenuGroup>
76
+ { suggestions.map( ( suggestion, index ) => {
77
+ if (
78
+ shouldShowCreateSuggestion &&
79
+ CREATE_TYPE === suggestion.type
80
+ ) {
81
+ return (
82
+ <LinkControlSearchCreate
83
+ searchTerm={ currentInputValue }
84
+ buttonText={ createSuggestionButtonText }
85
+ onClick={ () =>
86
+ handleSuggestionClick( suggestion )
87
+ }
88
+ // Intentionally only using `type` here as
89
+ // the constant is enough to uniquely
90
+ // identify the single "CREATE" suggestion.
91
+ key={ suggestion.type }
92
+ itemProps={ buildSuggestionItemProps(
93
+ suggestion,
94
+ index
95
+ ) }
96
+ isSelected={ index === selectedSuggestion }
97
+ />
98
+ );
99
+ }
100
+
101
+ // If we're not handling "Create" suggestions above then
102
+ // we don't want them in the main results so exit early.
103
+ if ( CREATE_TYPE === suggestion.type ) {
104
+ return null;
105
+ }
106
+
80
107
  return (
81
- <LinkControlSearchCreate
82
- searchTerm={ currentInputValue }
83
- buttonText={ createSuggestionButtonText }
84
- onClick={ () =>
85
- handleSuggestionClick( suggestion )
86
- }
87
- // Intentionally only using `type` here as
88
- // the constant is enough to uniquely
89
- // identify the single "CREATE" suggestion.
90
- key={ suggestion.type }
108
+ <LinkControlSearchItem
109
+ key={ `${ suggestion.id }-${ suggestion.type }` }
91
110
  itemProps={ buildSuggestionItemProps(
92
111
  suggestion,
93
112
  index
94
113
  ) }
114
+ suggestion={ suggestion }
115
+ index={ index }
116
+ onClick={ () => {
117
+ handleSuggestionClick( suggestion );
118
+ } }
95
119
  isSelected={ index === selectedSuggestion }
120
+ isURL={ LINK_ENTRY_TYPES.includes(
121
+ suggestion.type
122
+ ) }
123
+ searchTerm={ currentInputValue }
124
+ shouldShowType={ shouldShowSuggestionsTypes }
125
+ isFrontPage={ suggestion?.isFrontPage }
96
126
  />
97
127
  );
98
- }
99
-
100
- // If we're not handling "Create" suggestions above then
101
- // we don't want them in the main results so exit early.
102
- if ( CREATE_TYPE === suggestion.type ) {
103
- return null;
104
- }
105
-
106
- return (
107
- <LinkControlSearchItem
108
- key={ `${ suggestion.id }-${ suggestion.type }` }
109
- itemProps={ buildSuggestionItemProps(
110
- suggestion,
111
- index
112
- ) }
113
- suggestion={ suggestion }
114
- index={ index }
115
- onClick={ () => {
116
- handleSuggestionClick( suggestion );
117
- } }
118
- isSelected={ index === selectedSuggestion }
119
- isURL={ LINK_ENTRY_TYPES.includes(
120
- suggestion.type
121
- ) }
122
- searchTerm={ currentInputValue }
123
- shouldShowType={ shouldShowSuggestionsTypes }
124
- isFrontPage={ suggestion?.isFrontPage }
125
- />
126
- );
127
- } ) }
128
+ } ) }
129
+ </MenuGroup>
128
130
  </div>
129
131
  </div>
130
132
  );
@@ -41,6 +41,7 @@ $preview-image-height: 140px;
41
41
  // Provides positioning context for reset button. Without this then when an
42
42
  // error notice is displayed the input's reset button is incorrectly positioned.
43
43
  .block-editor-link-control__search-input-wrapper {
44
+ margin-bottom: $grid-unit-10;
44
45
  position: relative;
45
46
  }
46
47
 
@@ -87,36 +88,9 @@ $preview-image-height: 140px;
87
88
  order: 20;
88
89
  }
89
90
 
90
- .block-editor-link-control__search-results-wrapper {
91
- position: relative;
92
-
93
- &::before,
94
- &::after {
95
- content: "";
96
- position: absolute;
97
- left: -1px;
98
- right: $grid-unit-20; // avoid overlaying scrollbars
99
- display: block;
100
- pointer-events: none;
101
- z-index: 100;
102
- }
103
-
104
- &::before {
105
- height: $grid-unit-20 * 0.5;
106
- top: 0;
107
- bottom: auto;
108
- }
109
-
110
- &::after {
111
- height: $grid-unit-20;
112
- bottom: 0;
113
- top: auto;
114
- }
115
- }
116
-
117
91
  .block-editor-link-control__search-results {
118
- margin: 0;
119
- padding: $grid-unit-20 * 0.5 $grid-unit-20 $grid-unit-20 * 0.5;
92
+ margin-top: -$grid-unit-20;
93
+ padding: $grid-unit-10;
120
94
  max-height: 200px;
121
95
  overflow-y: auto; // allow results list to scroll
122
96
 
@@ -126,39 +100,35 @@ $preview-image-height: 140px;
126
100
  }
127
101
 
128
102
  .block-editor-link-control__search-item {
129
- position: relative;
130
- display: flex;
131
- align-items: flex-start; // when link text is very long it is important this indicator remains visible and thus should be aligned top.
132
- font-size: $default-font-size;
133
- cursor: pointer;
134
- background: $white;
135
- width: 100%;
136
- border: none;
137
- text-align: left;
138
- padding: $grid-unit-15 $grid-unit-20;
139
- border-radius: 2px;
140
- height: auto;
141
103
 
142
- &:hover,
143
- &:focus {
144
- background-color: $gray-100;
104
+ &.components-button.components-menu-item__button {
105
+ height: auto;
106
+ text-align: left;
107
+ }
145
108
 
146
- .block-editor-link-control__search-item-type {
147
- background: $white;
109
+ .components-menu-item__item {
110
+ overflow: hidden;
111
+ text-overflow: ellipsis;
112
+ // Inline block required to preserve white space
113
+ // between `<mark>` elements and text nodes.
114
+ display: inline-block;
115
+ width: 100%;
116
+
117
+ mark {
118
+ font-weight: 600;
119
+ color: inherit;
120
+ background-color: transparent;
148
121
  }
149
122
  }
150
123
 
151
- // The added specificity is needed to override.
152
- &:focus:not(:disabled) {
153
- box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color) inset;
124
+ .components-menu-item__shortcut {
125
+ color: $gray-700;
126
+ text-transform: capitalize;
127
+ white-space: nowrap; // tags shouldn't go over two lines.
154
128
  }
155
129
 
156
- &.is-selected {
130
+ &[aria-selected] {
157
131
  background: $gray-100;
158
-
159
- .block-editor-link-control__search-item-type {
160
- background: $white;
161
- }
162
132
  }
163
133
 
164
134
  &.is-current {
@@ -198,7 +168,6 @@ $preview-image-height: 140px;
198
168
 
199
169
  .block-editor-link-control__search-item-icon {
200
170
  position: relative;
201
- top: 0.2em;
202
171
  margin-right: $grid-unit-10;
203
172
  max-height: 24px;
204
173
  flex-shrink: 0;
@@ -217,18 +186,6 @@ $preview-image-height: 140px;
217
186
  max-height: 32px;
218
187
  }
219
188
 
220
- .block-editor-link-control__search-item-info,
221
- .block-editor-link-control__search-item-title {
222
- overflow: hidden;
223
- text-overflow: ellipsis;
224
-
225
- .components-external-link__icon {
226
- position: absolute;
227
- right: 0;
228
- margin-top: 0;
229
- }
230
- }
231
-
232
189
  .block-editor-link-control__search-item-title {
233
190
  display: block;
234
191
  margin-bottom: 0.2em;
@@ -236,7 +193,7 @@ $preview-image-height: 140px;
236
193
  position: relative;
237
194
 
238
195
  mark {
239
- font-weight: 700;
196
+ font-weight: 600;
240
197
  color: inherit;
241
198
  background-color: transparent;
242
199
  }
@@ -250,28 +207,6 @@ $preview-image-height: 140px;
250
207
  }
251
208
  }
252
209
 
253
- .block-editor-link-control__search-item-info {
254
- display: block;
255
- color: $gray-700;
256
- font-size: 0.9em;
257
- line-height: 1.3;
258
- }
259
-
260
- .block-editor-link-control__search-item-error-notice {
261
- font-style: italic;
262
- font-size: 1.1em;
263
- }
264
-
265
- .block-editor-link-control__search-item-type {
266
- display: block;
267
- padding: 3px 6px;
268
- margin-left: auto;
269
- font-size: 0.9em;
270
- background-color: $gray-100;
271
- border-radius: 2px;
272
- white-space: nowrap; // tags shouldn't go over two lines.
273
- }
274
-
275
210
  .block-editor-link-control__search-item-description {
276
211
  padding-top: 12px;
277
212
  margin: 0;
@@ -411,11 +346,6 @@ $preview-image-height: 140px;
411
346
  }
412
347
  }
413
348
 
414
- // Specificity override
415
- .block-editor-link-control__search-results div[role="menu"] > .block-editor-link-control__search-item.block-editor-link-control__search-item {
416
- padding: 10px;
417
- }
418
-
419
349
  .block-editor-link-control__drawer {
420
350
  display: flex; // allow for ordering.
421
351
  order: 30;
@@ -478,16 +478,16 @@ describe( 'Searching for a link', () => {
478
478
  // The fallback URL suggestion should not be shown when input is not URL-like.
479
479
  expect(
480
480
  searchResultElements[ searchResultElements.length - 1 ]
481
- ).not.toHaveTextContent( 'URL' );
481
+ ).not.toHaveTextContent( 'Press ENTER to add this link' );
482
482
  }
483
483
  );
484
484
 
485
485
  it.each( [
486
- [ 'https://wordpress.org', 'URL' ],
487
- [ 'http://wordpress.org', 'URL' ],
488
- [ 'www.wordpress.org', 'URL' ],
489
- [ 'wordpress.org', 'URL' ],
490
- [ 'ftp://wordpress.org', 'URL' ],
486
+ [ 'https://wordpress.org', 'link' ],
487
+ [ 'http://wordpress.org', 'link' ],
488
+ [ 'www.wordpress.org', 'link' ],
489
+ [ 'wordpress.org', 'link' ],
490
+ [ 'ftp://wordpress.org', 'link' ],
491
491
  [ 'mailto:hello@wordpress.org', 'mailto' ],
492
492
  [ 'tel:123456789', 'tel' ],
493
493
  [ '#internal', 'internal' ],
@@ -667,7 +667,6 @@ describe( 'Manual link entry', () => {
667
667
 
668
668
  expect( searchResultElements ).toBeVisible();
669
669
  expect( searchResultElements ).toHaveTextContent( searchTerm );
670
- expect( searchResultElements ).toHaveTextContent( 'URL' );
671
670
  expect( searchResultElements ).toHaveTextContent(
672
671
  'Press ENTER to add this link'
673
672
  );
@@ -78,10 +78,20 @@ function addValuesForElements( children, ...args ) {
78
78
  }
79
79
  }
80
80
 
81
+ function _getSaveElement( name, attributes, innerBlocks ) {
82
+ return getSaveElement(
83
+ name,
84
+ attributes,
85
+ innerBlocks.map( ( block ) =>
86
+ _getSaveElement( block.name, block.attributes, block.innerBlocks )
87
+ )
88
+ );
89
+ }
90
+
81
91
  function addValuesForBlocks( values, blocks ) {
82
92
  for ( let i = 0; i < blocks.length; i++ ) {
83
93
  const { name, attributes, innerBlocks } = blocks[ i ];
84
- const saveElement = getSaveElement( name, attributes );
94
+ const saveElement = _getSaveElement( name, attributes, innerBlocks );
85
95
  addValuesForElement( saveElement, values, innerBlocks );
86
96
  }
87
97
  }
@@ -10,7 +10,7 @@ import useSetting from '../../use-setting';
10
10
 
11
11
  export default function useSpacingSizes() {
12
12
  const spacingSizes = [
13
- { name: 0, slug: '0', side: 0 },
13
+ { name: 0, slug: '0', size: 0 },
14
14
  ...( useSetting( 'spacing.spacingSizes' ) || [] ),
15
15
  ];
16
16
 
@@ -2,7 +2,12 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import SpacingInputControl from './spacing-input-control';
5
- import { LABELS, ICONS, hasAxisSupport } from '../utils';
5
+ import {
6
+ LABELS,
7
+ ICONS,
8
+ getPresetValueFromCustomValue,
9
+ hasAxisSupport,
10
+ } from '../utils';
6
11
 
7
12
  const groupedSides = [ 'vertical', 'horizontal' ];
8
13
 
@@ -20,7 +25,17 @@ export default function AxialInputControls( {
20
25
  if ( ! onChange ) {
21
26
  return;
22
27
  }
23
- const nextValues = { ...values };
28
+
29
+ // Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
30
+ const nextValues = {
31
+ ...Object.keys( values ).reduce( ( acc, key ) => {
32
+ acc[ key ] = getPresetValueFromCustomValue(
33
+ values[ key ],
34
+ spacingSizes
35
+ );
36
+ return acc;
37
+ }, {} ),
38
+ };
24
39
 
25
40
  if ( side === 'vertical' ) {
26
41
  nextValues.top = next;
@@ -2,7 +2,12 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import SpacingInputControl from './spacing-input-control';
5
- import { ALL_SIDES, LABELS, ICONS } from '../utils';
5
+ import {
6
+ ALL_SIDES,
7
+ LABELS,
8
+ ICONS,
9
+ getPresetValueFromCustomValue,
10
+ } from '../utils';
6
11
 
7
12
  export default function SeparatedInputControls( {
8
13
  minimumCustomValue,
@@ -20,7 +25,17 @@ export default function SeparatedInputControls( {
20
25
  : ALL_SIDES;
21
26
 
22
27
  const createHandleOnChange = ( side ) => ( next ) => {
23
- const nextValues = { ...values };
28
+ // Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
29
+ const nextValues = {
30
+ ...Object.keys( values ).reduce( ( acc, key ) => {
31
+ acc[ key ] = getPresetValueFromCustomValue(
32
+ values[ key ],
33
+ spacingSizes
34
+ );
35
+ return acc;
36
+ }, {} ),
37
+ };
38
+
24
39
  nextValues[ side ] = next;
25
40
 
26
41
  onChange( nextValues );
@@ -2,7 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import SpacingInputControl from './spacing-input-control';
5
- import { LABELS } from '../utils';
5
+ import { LABELS, getPresetValueFromCustomValue } from '../utils';
6
6
 
7
7
  export default function SingleInputControl( {
8
8
  minimumCustomValue,
@@ -16,7 +16,17 @@ export default function SingleInputControl( {
16
16
  values,
17
17
  } ) {
18
18
  const createHandleOnChange = ( currentSide ) => ( next ) => {
19
- const nextValues = { ...values };
19
+ // Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
20
+ const nextValues = {
21
+ ...Object.keys( values ).reduce( ( acc, key ) => {
22
+ acc[ key ] = getPresetValueFromCustomValue(
23
+ values[ key ],
24
+ spacingSizes
25
+ );
26
+ return acc;
27
+ }, {} ),
28
+ };
29
+
20
30
  nextValues[ currentSide ] = next;
21
31
 
22
32
  onChange( nextValues );
@@ -102,7 +102,7 @@ export function getCustomValueFromPreset( value, spacingSizes ) {
102
102
  */
103
103
  export function getPresetValueFromCustomValue( value, spacingSizes ) {
104
104
  // Return value as-is if it is already a preset;
105
- if ( isValueSpacingPreset( value ) ) {
105
+ if ( isValueSpacingPreset( value ) || value === '0' ) {
106
106
  return value;
107
107
  }
108
108
 
@@ -67,8 +67,11 @@ export default function useBlockDisplayInformation( clientId ) {
67
67
  return useSelect(
68
68
  ( select ) => {
69
69
  if ( ! clientId ) return null;
70
- const { getBlockName, getBlockAttributes } =
71
- select( blockEditorStore );
70
+ const {
71
+ getBlockName,
72
+ getBlockAttributes,
73
+ __experimentalGetReusableBlockTitle,
74
+ } = select( blockEditorStore );
72
75
  const { getBlockType, getActiveBlockVariation } =
73
76
  select( blocksStore );
74
77
  const blockName = getBlockName( clientId );
@@ -76,12 +79,16 @@ export default function useBlockDisplayInformation( clientId ) {
76
79
  if ( ! blockType ) return null;
77
80
  const attributes = getBlockAttributes( clientId );
78
81
  const match = getActiveBlockVariation( blockName, attributes );
79
- const isSynced =
80
- isReusableBlock( blockType ) || isTemplatePart( blockType );
82
+ const isReusable = isReusableBlock( blockType );
83
+ const resusableTitle = isReusable
84
+ ? __experimentalGetReusableBlockTitle( attributes.ref )
85
+ : undefined;
86
+ const title = resusableTitle || blockType.title;
87
+ const isSynced = isReusable || isTemplatePart( blockType );
81
88
  const positionLabel = getPositionTypeLabel( attributes );
82
89
  const blockTypeInfo = {
83
90
  isSynced,
84
- title: blockType.title,
91
+ title,
85
92
  icon: blockType.icon,
86
93
  description: blockType.description,
87
94
  anchor: attributes?.anchor,
@@ -23,7 +23,10 @@ export function MarginVisualizer( { clientId, attributes, forceShow } ) {
23
23
  const margin = attributes?.style?.spacing?.margin;
24
24
 
25
25
  useEffect( () => {
26
- if ( ! blockElement ) {
26
+ if (
27
+ ! blockElement ||
28
+ null === blockElement.ownerDocument.defaultView
29
+ ) {
27
30
  return;
28
31
  }
29
32
 
@@ -23,7 +23,10 @@ export function PaddingVisualizer( { clientId, attributes, forceShow } ) {
23
23
  const padding = attributes?.style?.spacing?.padding;
24
24
 
25
25
  useEffect( () => {
26
- if ( ! blockElement ) {
26
+ if (
27
+ ! blockElement ||
28
+ null === blockElement.ownerDocument.defaultView
29
+ ) {
27
30
  return;
28
31
  }
29
32