@wordpress/block-editor 12.3.5 → 12.3.7
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.
- package/build/components/block-draggable/index.js +6 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/iframe/index.js +21 -46
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build/components/link-control/constants.js +1 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/search-create-button.js +5 -21
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-item.js +13 -30
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/rich-text/content.js +0 -36
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +112 -0
- package/build/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build/components/use-block-display-information/index.js +7 -3
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/private-apis.js +2 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-draggable/index.js +6 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/iframe/index.js +22 -47
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build-module/components/link-control/constants.js +1 -1
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +7 -20
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-item.js +14 -28
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -3
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/rich-text/content.js +1 -36
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +99 -0
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build-module/components/use-block-display-information/index.js +7 -3
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/private-apis.js +1 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +20 -83
- package/build-style/style.css +20 -83
- package/package.json +5 -5
- package/src/components/block-draggable/index.js +13 -4
- package/src/components/iframe/index.js +16 -47
- package/src/components/inserter/reusable-block-rename-hint.js +1 -1
- package/src/components/link-control/constants.js +1 -1
- package/src/components/link-control/search-create-button.js +8 -26
- package/src/components/link-control/search-item.js +21 -43
- package/src/components/link-control/search-results.js +48 -46
- package/src/components/link-control/style.scss +25 -95
- package/src/components/link-control/test/index.js +6 -7
- package/src/components/rich-text/content.js +1 -46
- package/src/components/rich-text/get-rich-text-values.js +95 -0
- package/src/components/use-block-display-information/index.js +12 -5
- package/src/hooks/margin.js +4 -1
- package/src/hooks/padding.js +4 -1
- package/src/private-apis.js +1 -1
- package/src/store/selectors.js +1 -1
- package/src/store/test/selectors.js +1 -1
|
@@ -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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
<
|
|
82
|
-
|
|
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:
|
|
119
|
-
padding: $grid-unit-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
104
|
+
&.components-button.components-menu-item__button {
|
|
105
|
+
height: auto;
|
|
106
|
+
text-align: left;
|
|
107
|
+
}
|
|
145
108
|
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
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:
|
|
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( '
|
|
481
|
+
).not.toHaveTextContent( 'Press ENTER to add this link' );
|
|
482
482
|
}
|
|
483
483
|
);
|
|
484
484
|
|
|
485
485
|
it.each( [
|
|
486
|
-
[ 'https://wordpress.org', '
|
|
487
|
-
[ 'http://wordpress.org', '
|
|
488
|
-
[ 'www.wordpress.org', '
|
|
489
|
-
[ 'wordpress.org', '
|
|
490
|
-
[ 'ftp://wordpress.org', '
|
|
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
|
);
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { RawHTML } from '@wordpress/element';
|
|
5
|
-
import {
|
|
6
|
-
children as childrenSource,
|
|
7
|
-
getSaveElement,
|
|
8
|
-
__unstableGetBlockProps as getBlockProps,
|
|
9
|
-
} from '@wordpress/blocks';
|
|
5
|
+
import { children as childrenSource } from '@wordpress/blocks';
|
|
10
6
|
import deprecated from '@wordpress/deprecated';
|
|
11
7
|
|
|
12
8
|
/**
|
|
@@ -42,44 +38,3 @@ export const Content = ( { value, tagName: Tag, multiline, ...props } ) => {
|
|
|
42
38
|
|
|
43
39
|
return content;
|
|
44
40
|
};
|
|
45
|
-
|
|
46
|
-
Content.__unstableIsRichTextContent = {};
|
|
47
|
-
|
|
48
|
-
function findContent( blocks, richTextValues = [] ) {
|
|
49
|
-
if ( ! Array.isArray( blocks ) ) {
|
|
50
|
-
blocks = [ blocks ];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
for ( const block of blocks ) {
|
|
54
|
-
if (
|
|
55
|
-
block?.type?.__unstableIsRichTextContent ===
|
|
56
|
-
Content.__unstableIsRichTextContent
|
|
57
|
-
) {
|
|
58
|
-
richTextValues.push( block.props.value );
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if ( block?.props?.children ) {
|
|
63
|
-
findContent( block.props.children, richTextValues );
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return richTextValues;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _getSaveElement( { name, attributes, innerBlocks } ) {
|
|
71
|
-
return getSaveElement(
|
|
72
|
-
name,
|
|
73
|
-
attributes,
|
|
74
|
-
innerBlocks.map( _getSaveElement )
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function getRichTextValues( blocks = [] ) {
|
|
79
|
-
getBlockProps.skipFilters = true;
|
|
80
|
-
const values = findContent(
|
|
81
|
-
( Array.isArray( blocks ) ? blocks : [ blocks ] ).map( _getSaveElement )
|
|
82
|
-
);
|
|
83
|
-
getBlockProps.skipFilters = false;
|
|
84
|
-
return values;
|
|
85
|
-
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { RawHTML, StrictMode, Fragment } from '@wordpress/element';
|
|
5
|
+
import {
|
|
6
|
+
getSaveElement,
|
|
7
|
+
__unstableGetBlockProps as getBlockProps,
|
|
8
|
+
} from '@wordpress/blocks';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import InnerBlocks from '../inner-blocks';
|
|
14
|
+
import { Content } from './content';
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* This function is similar to `@wordpress/element`'s `renderToString` function,
|
|
18
|
+
* except that it does not render the elements to a string, but instead collects
|
|
19
|
+
* the values of all rich text `Content` elements.
|
|
20
|
+
*/
|
|
21
|
+
function addValuesForElement( element, ...args ) {
|
|
22
|
+
if ( null === element || undefined === element || false === element ) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if ( Array.isArray( element ) ) {
|
|
27
|
+
return addValuesForElements( element, ...args );
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
switch ( typeof element ) {
|
|
31
|
+
case 'string':
|
|
32
|
+
case 'number':
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const { type, props } = element;
|
|
37
|
+
|
|
38
|
+
switch ( type ) {
|
|
39
|
+
case StrictMode:
|
|
40
|
+
case Fragment:
|
|
41
|
+
return addValuesForElements( props.children, ...args );
|
|
42
|
+
case RawHTML:
|
|
43
|
+
return;
|
|
44
|
+
case InnerBlocks.Content:
|
|
45
|
+
return addValuesForBlocks( ...args );
|
|
46
|
+
case Content:
|
|
47
|
+
const [ values ] = args;
|
|
48
|
+
values.push( props.value );
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
switch ( typeof type ) {
|
|
53
|
+
case 'string':
|
|
54
|
+
if ( typeof props.children !== 'undefined' ) {
|
|
55
|
+
return addValuesForElements( props.children, ...args );
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
case 'function':
|
|
59
|
+
if (
|
|
60
|
+
type.prototype &&
|
|
61
|
+
typeof type.prototype.render === 'function'
|
|
62
|
+
) {
|
|
63
|
+
return addValuesForElement(
|
|
64
|
+
new type( props ).render(),
|
|
65
|
+
...args
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return addValuesForElement( type( props ), ...args );
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function addValuesForElements( children, ...args ) {
|
|
74
|
+
children = Array.isArray( children ) ? children : [ children ];
|
|
75
|
+
|
|
76
|
+
for ( let i = 0; i < children.length; i++ ) {
|
|
77
|
+
addValuesForElement( children[ i ], ...args );
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function addValuesForBlocks( values, blocks ) {
|
|
82
|
+
for ( let i = 0; i < blocks.length; i++ ) {
|
|
83
|
+
const { name, attributes, innerBlocks } = blocks[ i ];
|
|
84
|
+
const saveElement = getSaveElement( name, attributes );
|
|
85
|
+
addValuesForElement( saveElement, values, innerBlocks );
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function getRichTextValues( blocks = [] ) {
|
|
90
|
+
getBlockProps.skipFilters = true;
|
|
91
|
+
const values = [];
|
|
92
|
+
addValuesForBlocks( values, blocks );
|
|
93
|
+
getBlockProps.skipFilters = false;
|
|
94
|
+
return values;
|
|
95
|
+
}
|
|
@@ -67,8 +67,11 @@ export default function useBlockDisplayInformation( clientId ) {
|
|
|
67
67
|
return useSelect(
|
|
68
68
|
( select ) => {
|
|
69
69
|
if ( ! clientId ) return null;
|
|
70
|
-
const {
|
|
71
|
-
|
|
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
|
|
80
|
-
|
|
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
|
|
91
|
+
title,
|
|
85
92
|
icon: blockType.icon,
|
|
86
93
|
description: blockType.description,
|
|
87
94
|
anchor: attributes?.anchor,
|
package/src/hooks/margin.js
CHANGED
|
@@ -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 (
|
|
26
|
+
if (
|
|
27
|
+
! blockElement ||
|
|
28
|
+
null === blockElement.ownerDocument.defaultView
|
|
29
|
+
) {
|
|
27
30
|
return;
|
|
28
31
|
}
|
|
29
32
|
|
package/src/hooks/padding.js
CHANGED
|
@@ -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 (
|
|
26
|
+
if (
|
|
27
|
+
! blockElement ||
|
|
28
|
+
null === blockElement.ownerDocument.defaultView
|
|
29
|
+
) {
|
|
27
30
|
return;
|
|
28
31
|
}
|
|
29
32
|
|
package/src/private-apis.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import * as globalStyles from './components/global-styles';
|
|
5
5
|
import { ExperimentalBlockEditorProvider } from './components/provider';
|
|
6
6
|
import { lock } from './lock-unlock';
|
|
7
|
-
import { getRichTextValues } from './components/rich-text/
|
|
7
|
+
import { getRichTextValues } from './components/rich-text/get-rich-text-values';
|
|
8
8
|
import ResizableBoxPopover from './components/resizable-box-popover';
|
|
9
9
|
import { ComposedPrivateInserter as PrivateInserter } from './components/inserter';
|
|
10
10
|
import { PrivateListView } from './components/list-view';
|
package/src/store/selectors.js
CHANGED
|
@@ -3351,7 +3351,7 @@ describe( 'selectors', () => {
|
|
|
3351
3351
|
id: 'core/block/1',
|
|
3352
3352
|
initialAttributes: { ref: 1 },
|
|
3353
3353
|
isDisabled: false,
|
|
3354
|
-
keywords: [],
|
|
3354
|
+
keywords: [ 'reusable' ],
|
|
3355
3355
|
name: 'core/block',
|
|
3356
3356
|
syncStatus: undefined,
|
|
3357
3357
|
title: 'Reusable Block 1',
|