@wordpress/block-library 8.8.0 → 8.9.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 (185) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/cover/transforms.js +10 -7
  3. package/build/cover/transforms.js.map +1 -1
  4. package/build/group/edit.js +3 -1
  5. package/build/group/edit.js.map +1 -1
  6. package/build/group/index.js +3 -0
  7. package/build/group/index.js.map +1 -1
  8. package/build/image/edit.js +16 -13
  9. package/build/image/edit.js.map +1 -1
  10. package/build/image/index.js +1 -1
  11. package/build/index.native.js +9 -5
  12. package/build/index.native.js.map +1 -1
  13. package/build/media-text/edit.js +4 -2
  14. package/build/media-text/edit.js.map +1 -1
  15. package/build/media-text/index.js +3 -0
  16. package/build/media-text/index.js.map +1 -1
  17. package/build/navigation/edit/index.js +32 -64
  18. package/build/navigation/edit/index.js.map +1 -1
  19. package/build/post-date/edit.js +4 -2
  20. package/build/post-date/edit.js.map +1 -1
  21. package/build/post-excerpt/edit.js +2 -2
  22. package/build/post-excerpt/edit.js.map +1 -1
  23. package/build/post-featured-image/edit.js +8 -5
  24. package/build/post-featured-image/edit.js.map +1 -1
  25. package/build/query/deprecated.js +8 -6
  26. package/build/query/deprecated.js.map +1 -1
  27. package/build/query/edit/inspector-controls/create-new-post-link.js +41 -0
  28. package/build/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
  29. package/build/query/edit/inspector-controls/index.js +14 -6
  30. package/build/query/edit/inspector-controls/index.js.map +1 -1
  31. package/build/query/edit/pattern-selection-modal.js +2 -1
  32. package/build/query/edit/pattern-selection-modal.js.map +1 -1
  33. package/build/query/index.js +5 -12
  34. package/build/query/index.js.map +1 -1
  35. package/build/site-logo/edit.js +114 -16
  36. package/build/site-logo/edit.js.map +1 -1
  37. package/build/site-logo/index.js +1 -1
  38. package/build/social-link/icons/chain.js +1 -1
  39. package/build/social-link/icons/chain.js.map +1 -1
  40. package/build/social-link/icons/mail.js +1 -1
  41. package/build/social-link/icons/mail.js.map +1 -1
  42. package/build/spacer/edit.js +117 -11
  43. package/build/spacer/edit.js.map +1 -1
  44. package/build/template-part/edit/index.js +2 -1
  45. package/build/template-part/edit/index.js.map +1 -1
  46. package/build/template-part/edit/utils/hooks.js +2 -2
  47. package/build/template-part/edit/utils/hooks.js.map +1 -1
  48. package/build/utils/migrate-font-family.js +12 -5
  49. package/build/utils/migrate-font-family.js.map +1 -1
  50. package/build/video/edit.native.js +4 -3
  51. package/build/video/edit.native.js.map +1 -1
  52. package/build-module/cover/transforms.js +5 -1
  53. package/build-module/cover/transforms.js.map +1 -1
  54. package/build-module/group/edit.js +3 -1
  55. package/build-module/group/edit.js.map +1 -1
  56. package/build-module/group/index.js +3 -0
  57. package/build-module/group/index.js.map +1 -1
  58. package/build-module/image/edit.js +16 -13
  59. package/build-module/image/edit.js.map +1 -1
  60. package/build-module/image/index.js +1 -1
  61. package/build-module/index.native.js +9 -5
  62. package/build-module/index.native.js.map +1 -1
  63. package/build-module/media-text/edit.js +4 -2
  64. package/build-module/media-text/edit.js.map +1 -1
  65. package/build-module/media-text/index.js +3 -0
  66. package/build-module/media-text/index.js.map +1 -1
  67. package/build-module/navigation/edit/index.js +31 -63
  68. package/build-module/navigation/edit/index.js.map +1 -1
  69. package/build-module/post-date/edit.js +4 -2
  70. package/build-module/post-date/edit.js.map +1 -1
  71. package/build-module/post-excerpt/edit.js +2 -2
  72. package/build-module/post-excerpt/edit.js.map +1 -1
  73. package/build-module/post-featured-image/edit.js +8 -5
  74. package/build-module/post-featured-image/edit.js.map +1 -1
  75. package/build-module/query/deprecated.js +5 -2
  76. package/build-module/query/deprecated.js.map +1 -1
  77. package/build-module/query/edit/inspector-controls/create-new-post-link.js +33 -0
  78. package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
  79. package/build-module/query/edit/inspector-controls/index.js +12 -7
  80. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  81. package/build-module/query/edit/pattern-selection-modal.js +2 -1
  82. package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
  83. package/build-module/query/index.js +5 -10
  84. package/build-module/query/index.js.map +1 -1
  85. package/build-module/site-logo/edit.js +115 -18
  86. package/build-module/site-logo/edit.js.map +1 -1
  87. package/build-module/site-logo/index.js +1 -1
  88. package/build-module/social-link/icons/chain.js +1 -1
  89. package/build-module/social-link/icons/chain.js.map +1 -1
  90. package/build-module/social-link/icons/mail.js +1 -1
  91. package/build-module/social-link/icons/mail.js.map +1 -1
  92. package/build-module/spacer/edit.js +118 -12
  93. package/build-module/spacer/edit.js.map +1 -1
  94. package/build-module/template-part/edit/index.js +2 -1
  95. package/build-module/template-part/edit/index.js.map +1 -1
  96. package/build-module/template-part/edit/utils/hooks.js +2 -2
  97. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  98. package/build-module/utils/migrate-font-family.js +9 -1
  99. package/build-module/utils/migrate-font-family.js.map +1 -1
  100. package/build-module/video/edit.native.js +4 -3
  101. package/build-module/video/edit.native.js.map +1 -1
  102. package/build-style/cover/editor-rtl.css +3 -3
  103. package/build-style/cover/editor.css +3 -3
  104. package/build-style/cover/style-rtl.css +1 -2
  105. package/build-style/cover/style.css +1 -2
  106. package/build-style/editor-rtl.css +71 -34
  107. package/build-style/editor.css +71 -34
  108. package/build-style/html/editor-rtl.css +2 -2
  109. package/build-style/html/editor.css +2 -2
  110. package/build-style/image/editor-rtl.css +1 -1
  111. package/build-style/image/editor.css +1 -1
  112. package/build-style/query/editor-rtl.css +8 -12
  113. package/build-style/query/editor.css +8 -12
  114. package/build-style/search/style-rtl.css +2 -0
  115. package/build-style/search/style.css +2 -0
  116. package/build-style/shortcode/editor-rtl.css +3 -4
  117. package/build-style/shortcode/editor.css +3 -4
  118. package/build-style/site-logo/editor-rtl.css +46 -0
  119. package/build-style/site-logo/editor.css +46 -0
  120. package/build-style/style-rtl.css +3 -2
  121. package/build-style/style.css +3 -2
  122. package/build-style/template-part/editor-rtl.css +8 -12
  123. package/build-style/template-part/editor.css +8 -12
  124. package/package.json +31 -31
  125. package/src/buttons/test/__snapshots__/edit.native.js.snap +18 -0
  126. package/src/buttons/test/edit.native.js +123 -2
  127. package/src/cover/editor.scss +1 -1
  128. package/src/cover/style.scss +0 -1
  129. package/src/cover/transforms.js +4 -1
  130. package/src/gallery/test/index.native.js +4 -4
  131. package/src/group/block.json +3 -0
  132. package/src/group/edit.js +8 -2
  133. package/src/heading/test/__snapshots__/index.native.js.snap +12 -0
  134. package/src/heading/test/index.native.js +71 -0
  135. package/src/html/editor.scss +2 -21
  136. package/src/image/block.json +1 -1
  137. package/src/image/edit.js +21 -17
  138. package/src/image/editor.scss +1 -1
  139. package/src/index.native.js +9 -5
  140. package/src/list/test/edit.native.js +7 -7
  141. package/src/media-text/block.json +3 -0
  142. package/src/media-text/edit.js +2 -1
  143. package/src/navigation/edit/index.js +32 -106
  144. package/src/navigation/index.php +15 -8
  145. package/src/paragraph/test/edit.native.js +288 -28
  146. package/src/post-date/edit.js +4 -0
  147. package/src/post-date/index.php +17 -8
  148. package/src/post-excerpt/edit.js +1 -1
  149. package/src/post-featured-image/edit.js +6 -5
  150. package/src/post-featured-image/index.php +1 -1
  151. package/src/preformatted/test/edit.native.js +6 -9
  152. package/src/pullquote/test/edit.native.js +7 -12
  153. package/src/query/deprecated.js +4 -1
  154. package/src/query/edit/inspector-controls/create-new-post-link.js +26 -0
  155. package/src/query/edit/inspector-controls/index.js +13 -6
  156. package/src/query/edit/pattern-selection-modal.js +1 -0
  157. package/src/query/editor.scss +8 -11
  158. package/src/query/index.js +1 -7
  159. package/src/quote/test/edit.native.js +6 -10
  160. package/src/search/style.scss +3 -0
  161. package/src/shortcode/editor.scss +1 -21
  162. package/src/site-logo/block.json +1 -1
  163. package/src/site-logo/edit.js +123 -9
  164. package/src/site-logo/editor.scss +57 -0
  165. package/src/social-link/icons/chain.js +1 -1
  166. package/src/social-link/icons/mail.js +1 -1
  167. package/src/social-link/index.php +2 -2
  168. package/src/spacer/edit.js +157 -18
  169. package/src/template-part/edit/index.js +1 -0
  170. package/src/template-part/edit/utils/hooks.js +2 -2
  171. package/src/template-part/editor.scss +9 -11
  172. package/src/utils/migrate-font-family.js +8 -1
  173. package/src/verse/test/edit.native.js +4 -9
  174. package/src/video/edit.native.js +2 -2
  175. package/tsconfig.json +1 -0
  176. package/build/query/hooks.js +0 -72
  177. package/build/query/hooks.js.map +0 -1
  178. package/build/utils/clean-empty-object.js +0 -37
  179. package/build/utils/clean-empty-object.js.map +0 -1
  180. package/build-module/query/hooks.js +0 -59
  181. package/build-module/query/hooks.js.map +0 -1
  182. package/build-module/utils/clean-empty-object.js +0 -28
  183. package/build-module/utils/clean-empty-object.js.map +0 -1
  184. package/src/query/hooks.js +0 -53
  185. package/src/utils/clean-empty-object.js +0 -28
@@ -8,6 +8,8 @@ import classnames from 'classnames';
8
8
  */
9
9
  import {
10
10
  useBlockProps,
11
+ useSetting,
12
+ getCustomValueFromPreset,
11
13
  getSpacingPresetCssVar,
12
14
  store as blockEditorStore,
13
15
  } from '@wordpress/block-editor';
@@ -92,13 +94,20 @@ const SpacerEdit = ( {
92
94
  } );
93
95
  const { orientation } = context;
94
96
  const { orientation: parentOrientation, type } = parentLayout || {};
97
+ // Check if the spacer is inside a flex container.
98
+ const isFlexLayout = type === 'flex';
95
99
  // If the spacer is inside a flex container, it should either inherit the orientation
96
100
  // of the parent or use the flex default orientation.
97
101
  const inheritedOrientation =
98
- ! parentOrientation && type === 'flex'
102
+ ! parentOrientation && isFlexLayout
99
103
  ? 'horizontal'
100
104
  : parentOrientation || orientation;
101
- const { height, width } = attributes;
105
+ const { height, width, style: blockStyle = {} } = attributes;
106
+
107
+ const { layout = {} } = blockStyle;
108
+ const { selfStretch, flexSize } = layout;
109
+
110
+ const spacingSizes = useSetting( 'spacing.spacingSizes' );
102
111
 
103
112
  const [ isResizing, setIsResizing ] = useState( false );
104
113
  const [ temporaryHeight, setTemporaryHeight ] = useState( null );
@@ -110,32 +119,80 @@ const SpacerEdit = ( {
110
119
  const handleOnVerticalResizeStop = ( newHeight ) => {
111
120
  onResizeStop();
112
121
 
122
+ if ( isFlexLayout ) {
123
+ setAttributes( {
124
+ style: {
125
+ ...blockStyle,
126
+ layout: {
127
+ ...layout,
128
+ flexSize: newHeight,
129
+ selfStretch: 'fixed',
130
+ },
131
+ },
132
+ } );
133
+ }
134
+
113
135
  setAttributes( { height: newHeight } );
114
136
  setTemporaryHeight( null );
115
137
  };
116
138
 
117
139
  const handleOnHorizontalResizeStop = ( newWidth ) => {
118
140
  onResizeStop();
141
+
142
+ if ( isFlexLayout ) {
143
+ setAttributes( {
144
+ style: {
145
+ ...blockStyle,
146
+ layout: {
147
+ ...layout,
148
+ flexSize: newWidth,
149
+ selfStretch: 'fixed',
150
+ },
151
+ },
152
+ } );
153
+ }
154
+
119
155
  setAttributes( { width: newWidth } );
120
156
  setTemporaryWidth( null );
121
157
  };
122
158
 
159
+ const getHeightForVerticalBlocks = () => {
160
+ if ( isFlexLayout ) {
161
+ return undefined;
162
+ }
163
+ return temporaryHeight || getSpacingPresetCssVar( height ) || undefined;
164
+ };
165
+
166
+ const getWidthForHorizontalBlocks = () => {
167
+ if ( isFlexLayout ) {
168
+ return undefined;
169
+ }
170
+ return temporaryWidth || getSpacingPresetCssVar( width ) || undefined;
171
+ };
172
+
173
+ const sizeConditionalOnOrientation =
174
+ inheritedOrientation === 'horizontal'
175
+ ? temporaryWidth || flexSize
176
+ : temporaryHeight || flexSize;
177
+
123
178
  const style = {
124
179
  height:
125
180
  inheritedOrientation === 'horizontal'
126
181
  ? 24
127
- : temporaryHeight ||
128
- getSpacingPresetCssVar( height ) ||
129
- undefined,
182
+ : getHeightForVerticalBlocks(),
130
183
  width:
131
184
  inheritedOrientation === 'horizontal'
132
- ? temporaryWidth || getSpacingPresetCssVar( width ) || undefined
185
+ ? getWidthForHorizontalBlocks()
133
186
  : undefined,
134
187
  // In vertical flex containers, the spacer shrinks to nothing without a minimum width.
135
188
  minWidth:
136
- inheritedOrientation === 'vertical' && type === 'flex'
189
+ inheritedOrientation === 'vertical' && isFlexLayout
137
190
  ? 48
138
191
  : undefined,
192
+ // Add flex-basis so temporary sizes are respected.
193
+ flexBasis: isFlexLayout ? sizeConditionalOnOrientation : undefined,
194
+ // Remove flex-grow when resizing.
195
+ flexGrow: isFlexLayout && isResizing ? 0 : undefined,
139
196
  };
140
197
 
141
198
  const resizableBoxWithOrientation = ( blockOrientation ) => {
@@ -191,13 +248,93 @@ const SpacerEdit = ( {
191
248
  };
192
249
 
193
250
  useEffect( () => {
194
- if ( inheritedOrientation === 'horizontal' && ! width ) {
251
+ if (
252
+ isFlexLayout &&
253
+ selfStretch !== 'fill' &&
254
+ selfStretch !== 'fit' &&
255
+ ! flexSize
256
+ ) {
257
+ if ( inheritedOrientation === 'horizontal' ) {
258
+ // If spacer is moving from a vertical container to a horizontal container,
259
+ // it might not have width but have height instead.
260
+ const newSize =
261
+ getCustomValueFromPreset( width, spacingSizes ) ||
262
+ getCustomValueFromPreset( height, spacingSizes ) ||
263
+ '100px';
264
+ setAttributes( {
265
+ width: '0px',
266
+ style: {
267
+ ...blockStyle,
268
+ layout: {
269
+ ...layout,
270
+ flexSize: newSize,
271
+ selfStretch: 'fixed',
272
+ },
273
+ },
274
+ } );
275
+ } else {
276
+ const newSize =
277
+ getCustomValueFromPreset( height, spacingSizes ) ||
278
+ getCustomValueFromPreset( width, spacingSizes ) ||
279
+ '100px';
280
+ setAttributes( {
281
+ height: '0px',
282
+ style: {
283
+ ...blockStyle,
284
+ layout: {
285
+ ...layout,
286
+ flexSize: newSize,
287
+ selfStretch: 'fixed',
288
+ },
289
+ },
290
+ } );
291
+ }
292
+ } else if (
293
+ isFlexLayout &&
294
+ ( selfStretch === 'fill' || selfStretch === 'fit' )
295
+ ) {
296
+ if ( inheritedOrientation === 'horizontal' ) {
297
+ setAttributes( {
298
+ width: undefined,
299
+ } );
300
+ } else {
301
+ setAttributes( {
302
+ height: undefined,
303
+ } );
304
+ }
305
+ } else if ( ! isFlexLayout && ( selfStretch || flexSize ) ) {
306
+ if ( inheritedOrientation === 'horizontal' ) {
307
+ setAttributes( {
308
+ width: flexSize,
309
+ } );
310
+ } else {
311
+ setAttributes( {
312
+ height: flexSize,
313
+ } );
314
+ }
195
315
  setAttributes( {
196
- height: '0px',
197
- width: '72px',
316
+ style: {
317
+ ...blockStyle,
318
+ layout: {
319
+ ...layout,
320
+ flexSize: undefined,
321
+ selfStretch: undefined,
322
+ },
323
+ },
198
324
  } );
199
325
  }
200
- }, [] );
326
+ }, [
327
+ blockStyle,
328
+ flexSize,
329
+ height,
330
+ inheritedOrientation,
331
+ isFlexLayout,
332
+ layout,
333
+ selfStretch,
334
+ setAttributes,
335
+ spacingSizes,
336
+ width,
337
+ ] );
201
338
 
202
339
  return (
203
340
  <>
@@ -211,13 +348,15 @@ const SpacerEdit = ( {
211
348
  >
212
349
  { resizableBoxWithOrientation( inheritedOrientation ) }
213
350
  </View>
214
- <SpacerControls
215
- setAttributes={ setAttributes }
216
- height={ temporaryHeight || height }
217
- width={ temporaryWidth || width }
218
- orientation={ inheritedOrientation }
219
- isResizing={ isResizing }
220
- />
351
+ { ! isFlexLayout && (
352
+ <SpacerControls
353
+ setAttributes={ setAttributes }
354
+ height={ temporaryHeight || height }
355
+ width={ temporaryWidth || width }
356
+ orientation={ inheritedOrientation }
357
+ isResizing={ isResizing }
358
+ />
359
+ ) }
221
360
  </>
222
361
  );
223
362
  };
@@ -205,6 +205,7 @@ export default function TemplatePartEdit( {
205
205
  onRequestClose={ () =>
206
206
  setIsTemplatePartSelectionOpen( false )
207
207
  }
208
+ isFullScreen={ true }
208
209
  >
209
210
  <TemplatePartSelectionModal
210
211
  templatePartId={ templatePartId }
@@ -37,7 +37,7 @@ export function useAlternativeTemplateParts( area, excludedId ) {
37
37
  'wp_template_part',
38
38
  query
39
39
  ),
40
- isLoading: _isResolving( 'getEntityRecords', [
40
+ isResolving: _isResolving( 'getEntityRecords', [
41
41
  'postType',
42
42
  'wp_template_part',
43
43
  query,
@@ -61,7 +61,7 @@ export function useAlternativeTemplateParts( area, excludedId ) {
61
61
  templatePart.area === area )
62
62
  ) || []
63
63
  );
64
- }, [ templateParts, area ] );
64
+ }, [ templateParts, area, excludedId ] );
65
65
 
66
66
  return {
67
67
  templateParts: filteredTemplateParts,
@@ -1,18 +1,16 @@
1
1
  .block-editor-template-part__selection-modal {
2
2
  z-index: z-index(".block-editor-template-part__selection-modal");
3
3
 
4
- // To keep modal dimensions consistent as subsections are navigated, width
5
- // and height are used instead of max-(width/height).
6
- .components-modal__frame {
7
- @include break-small() {
8
- width: calc(100% - #{$grid-unit-20 * 2});
9
- height: calc(100% - #{$header-height * 2});
10
- }
11
- @include break-medium() {
12
- width: $break-medium - $grid-unit-20 * 2;
4
+ .block-editor-block-patterns-list {
5
+ column-count: 2;
6
+ column-gap: $grid-unit-30;
7
+
8
+ @include break-wide() {
9
+ column-count: 3;
13
10
  }
14
- @include break-large() {
15
- height: 70%;
11
+
12
+ .block-editor-block-patterns-list__list-item {
13
+ break-inside: avoid-column;
16
14
  }
17
15
  }
18
16
  }
@@ -1,7 +1,14 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
5
+
1
6
  /**
2
7
  * Internal dependencies
3
8
  */
4
- import cleanEmptyObject from './clean-empty-object';
9
+ import { unlock } from '../private-apis';
10
+
11
+ const { cleanEmptyObject } = unlock( blockEditorPrivateApis );
5
12
 
6
13
  /**
7
14
  * Migrates the current style.typography.fontFamily attribute,
@@ -6,7 +6,7 @@ import {
6
6
  getEditorHtml,
7
7
  initializeEditor,
8
8
  getBlock,
9
- changeAndSelectTextOfRichText,
9
+ typeInRichText,
10
10
  fireEvent,
11
11
  } from 'test/helpers';
12
12
 
@@ -64,23 +64,18 @@ describe( 'Verse block', () => {
64
64
  const verseTextInput = await screen.findByPlaceholderText(
65
65
  'Write verse…'
66
66
  );
67
- const string = 'A great statement.';
68
- changeAndSelectTextOfRichText( verseTextInput, string, {
69
- selectionStart: string.length,
70
- selectionEnd: string.length,
71
- } );
67
+ typeInRichText( verseTextInput, 'A great statement.' );
72
68
  fireEvent( verseTextInput, 'onKeyDown', {
73
69
  nativeEvent: {},
74
70
  preventDefault() {},
75
71
  keyCode: ENTER,
76
72
  } );
77
-
78
- // TODO: Determine a way to type after pressing ENTER within the block.
73
+ typeInRichText( verseTextInput, 'Again' );
79
74
 
80
75
  // Assert
81
76
  expect( getEditorHtml() ).toMatchInlineSnapshot( `
82
77
  "<!-- wp:verse -->
83
- <pre class="wp-block-verse">A great statement.<br></pre>
78
+ <pre class="wp-block-verse">A great statement.<br>Again</pre>
84
79
  <!-- /wp:verse -->"
85
80
  ` );
86
81
  } );
@@ -172,7 +172,7 @@ class VideoEdit extends Component {
172
172
  return;
173
173
  }
174
174
 
175
- setAttributes( { id: url, src: url } );
175
+ setAttributes( { src: url, id: undefined, poster: undefined } );
176
176
  } else {
177
177
  createErrorNotice( __( 'Invalid URL.' ) );
178
178
  }
@@ -235,7 +235,7 @@ class VideoEdit extends Component {
235
235
  ></MediaUpload>
236
236
  );
237
237
 
238
- if ( ! id ) {
238
+ if ( ! src ) {
239
239
  return (
240
240
  <View style={ { flex: 1 } }>
241
241
  <MediaPlaceholder
package/tsconfig.json CHANGED
@@ -26,6 +26,7 @@
26
26
  { "path": "../html-entities" },
27
27
  { "path": "../i18n" },
28
28
  { "path": "../icons" },
29
+ { "path": "../notices" },
29
30
  { "path": "../keycodes" },
30
31
  { "path": "../primitives" },
31
32
  { "path": "../url" },
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
-
14
- var _i18n = require("@wordpress/i18n");
15
-
16
- var _url = require("@wordpress/url");
17
-
18
- var _compose = require("@wordpress/compose");
19
-
20
- var _blockEditor = require("@wordpress/block-editor");
21
-
22
- /**
23
- * WordPress dependencies
24
- */
25
- const CreateNewPostLink = _ref => {
26
- let {
27
- attributes: {
28
- query: {
29
- postType
30
- } = {}
31
- } = {}
32
- } = _ref;
33
- if (!postType) return null;
34
- const newPostUrl = (0, _url.addQueryArgs)('post-new.php', {
35
- post_type: postType
36
- });
37
- return (0, _element.createElement)("div", {
38
- className: "wp-block-query__create-new-link"
39
- }, (0, _element.createInterpolateElement)((0, _i18n.__)('<a>Create a new post</a> for this feed.'), // eslint-disable-next-line jsx-a11y/anchor-has-content
40
- {
41
- a: (0, _element.createElement)("a", {
42
- href: newPostUrl
43
- })
44
- }));
45
- };
46
- /**
47
- * Override the default edit UI to include layout controls
48
- *
49
- * @param {Function} BlockEdit Original component
50
- * @return {Function} Wrapped component
51
- */
52
-
53
-
54
- const queryTopInspectorControls = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
55
- const {
56
- name,
57
- isSelected
58
- } = props;
59
-
60
- if (name !== 'core/query' || !isSelected) {
61
- return (0, _element.createElement)(BlockEdit, (0, _extends2.default)({
62
- key: "edit"
63
- }, props));
64
- }
65
-
66
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(CreateNewPostLink, props)), (0, _element.createElement)(BlockEdit, (0, _extends2.default)({
67
- key: "edit"
68
- }, props)));
69
- }, 'withInspectorControls');
70
- var _default = queryTopInspectorControls;
71
- exports.default = _default;
72
- //# sourceMappingURL=hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/hooks.js"],"names":["CreateNewPostLink","attributes","query","postType","newPostUrl","post_type","a","queryTopInspectorControls","BlockEdit","props","name","isSelected"],"mappings":";;;;;;;;;AAIA;;;;AADA;;AAEA;;AACA;;AACA;;AAPA;AACA;AACA;AAOA,MAAMA,iBAAiB,GAAG,QAEnB;AAAA,MAFqB;AAC3BC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,KAAK,EAAE;AAAEC,QAAAA;AAAF,UAAe;AAAxB,QAA+B;AADhB,GAErB;AACN,MAAK,CAAEA,QAAP,EAAkB,OAAO,IAAP;AAClB,QAAMC,UAAU,GAAG,uBAAc,cAAd,EAA8B;AAChDC,IAAAA,SAAS,EAAEF;AADqC,GAA9B,CAAnB;AAGA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,uCACD,cAAI,yCAAJ,CADC,EAED;AACA;AAAEG,IAAAA,CAAC,EAAE;AAAG,MAAA,IAAI,EAAGF;AAAV;AAAL,GAHC,CADH,CADD;AASA,CAhBD;AAkBA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMG,yBAAyB,GAAG,yCAC/BC,SAAF,IAAmBC,KAAF,IAAa;AAC7B,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAuBF,KAA7B;;AACA,MAAKC,IAAI,KAAK,YAAT,IAAyB,CAAEC,UAAhC,EAA6C;AAC5C,WAAO,4BAAC,SAAD;AAAW,MAAA,GAAG,EAAC;AAAf,OAA2BF,KAA3B,EAAP;AACA;;AAED,SACC,qDACC,4BAAC,8BAAD,QACC,4BAAC,iBAAD,EAAwBA,KAAxB,CADD,CADD,EAIC,4BAAC,SAAD;AAAW,IAAA,GAAG,EAAC;AAAf,KAA2BA,KAA3B,EAJD,CADD;AAQA,CAfgC,EAgBjC,uBAhBiC,CAAlC;eAmBeF,yB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { addQueryArgs } from '@wordpress/url';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { InspectorControls } from '@wordpress/block-editor';\n\nconst CreateNewPostLink = ( {\n\tattributes: { query: { postType } = {} } = {},\n} ) => {\n\tif ( ! postType ) return null;\n\tconst newPostUrl = addQueryArgs( 'post-new.php', {\n\t\tpost_type: postType,\n\t} );\n\treturn (\n\t\t<div className=\"wp-block-query__create-new-link\">\n\t\t\t{ createInterpolateElement(\n\t\t\t\t__( '<a>Create a new post</a> for this feed.' ),\n\t\t\t\t// eslint-disable-next-line jsx-a11y/anchor-has-content\n\t\t\t\t{ a: <a href={ newPostUrl } /> }\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component\n * @return {Function} Wrapped component\n */\nconst queryTopInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name, isSelected } = props;\n\t\tif ( name !== 'core/query' || ! isSelected ) {\n\t\t\treturn <BlockEdit key=\"edit\" { ...props } />;\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<CreateNewPostLink { ...props } />\n\t\t\t\t</InspectorControls>\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withInspectorControls'\n);\n\nexport default queryTopInspectorControls;\n"]}
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _lodash = require("lodash");
9
-
10
- /**
11
- * External dependencies
12
- */
13
-
14
- /**
15
- * Removed empty nodes from nested objects.
16
- *
17
- * @param {Object} object
18
- * @return {Object} Object cleaned from empty nodes.
19
- */
20
- const cleanEmptyObject = object => {
21
- if (object === null || typeof object !== 'object' || Array.isArray(object)) {
22
- return object;
23
- }
24
-
25
- const cleanedNestedObjects = Object.fromEntries(Object.entries(object).map(_ref => {
26
- let [key, value] = _ref;
27
- return [key, cleanEmptyObject(value)];
28
- }).filter(_ref2 => {
29
- let [, value] = _ref2;
30
- return Boolean(value);
31
- }));
32
- return (0, _lodash.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
33
- };
34
-
35
- var _default = cleanEmptyObject;
36
- exports.default = _default;
37
- //# sourceMappingURL=clean-empty-object.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/clean-empty-object.js"],"names":["cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","Object","fromEntries","entries","map","key","value","filter","Boolean","undefined"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,gBAAgB,GAAKC,MAAF,IAAc;AACtC,MACCA,MAAM,KAAK,IAAX,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEAC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAHD,EAIE;AACD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAGC,MAAM,CAACC,WAAP,CAC5BD,MAAM,CAACE,OAAP,CAAgBN,MAAhB,EACEO,GADF,CACO;AAAA,QAAE,CAAEC,GAAF,EAAOC,KAAP,CAAF;AAAA,WAAsB,CAAED,GAAF,EAAOT,gBAAgB,CAAEU,KAAF,CAAvB,CAAtB;AAAA,GADP,EAEEC,MAFF,CAEU;AAAA,QAAE,GAAID,KAAJ,CAAF;AAAA,WAAmBE,OAAO,CAAEF,KAAF,CAA1B;AAAA,GAFV,CAD4B,CAA7B;AAKA,SAAO,qBAASN,oBAAT,IAAkCS,SAAlC,GAA8CT,oBAArD;AACA,CAdD;;eAgBeJ,gB","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * Removed empty nodes from nested objects.\n *\n * @param {Object} object\n * @return {Object} Object cleaned from empty nodes.\n */\nconst cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = Object.fromEntries(\n\t\tObject.entries( object )\n\t\t\t.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )\n\t\t\t.filter( ( [ , value ] ) => Boolean( value ) )\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nexport default cleanEmptyObject;\n"]}
@@ -1,59 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createElement, Fragment } from "@wordpress/element";
3
-
4
- /**
5
- * WordPress dependencies
6
- */
7
- import { __ } from '@wordpress/i18n';
8
- import { createInterpolateElement } from '@wordpress/element';
9
- import { addQueryArgs } from '@wordpress/url';
10
- import { createHigherOrderComponent } from '@wordpress/compose';
11
- import { InspectorControls } from '@wordpress/block-editor';
12
-
13
- const CreateNewPostLink = _ref => {
14
- let {
15
- attributes: {
16
- query: {
17
- postType
18
- } = {}
19
- } = {}
20
- } = _ref;
21
- if (!postType) return null;
22
- const newPostUrl = addQueryArgs('post-new.php', {
23
- post_type: postType
24
- });
25
- return createElement("div", {
26
- className: "wp-block-query__create-new-link"
27
- }, createInterpolateElement(__('<a>Create a new post</a> for this feed.'), // eslint-disable-next-line jsx-a11y/anchor-has-content
28
- {
29
- a: createElement("a", {
30
- href: newPostUrl
31
- })
32
- }));
33
- };
34
- /**
35
- * Override the default edit UI to include layout controls
36
- *
37
- * @param {Function} BlockEdit Original component
38
- * @return {Function} Wrapped component
39
- */
40
-
41
-
42
- const queryTopInspectorControls = createHigherOrderComponent(BlockEdit => props => {
43
- const {
44
- name,
45
- isSelected
46
- } = props;
47
-
48
- if (name !== 'core/query' || !isSelected) {
49
- return createElement(BlockEdit, _extends({
50
- key: "edit"
51
- }, props));
52
- }
53
-
54
- return createElement(Fragment, null, createElement(InspectorControls, null, createElement(CreateNewPostLink, props)), createElement(BlockEdit, _extends({
55
- key: "edit"
56
- }, props)));
57
- }, 'withInspectorControls');
58
- export default queryTopInspectorControls;
59
- //# sourceMappingURL=hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/hooks.js"],"names":["__","createInterpolateElement","addQueryArgs","createHigherOrderComponent","InspectorControls","CreateNewPostLink","attributes","query","postType","newPostUrl","post_type","a","queryTopInspectorControls","BlockEdit","props","name","isSelected"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,wBAAT,QAAyC,oBAAzC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,iBAAT,QAAkC,yBAAlC;;AAEA,MAAMC,iBAAiB,GAAG,QAEnB;AAAA,MAFqB;AAC3BC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,KAAK,EAAE;AAAEC,QAAAA;AAAF,UAAe;AAAxB,QAA+B;AADhB,GAErB;AACN,MAAK,CAAEA,QAAP,EAAkB,OAAO,IAAP;AAClB,QAAMC,UAAU,GAAGP,YAAY,CAAE,cAAF,EAAkB;AAChDQ,IAAAA,SAAS,EAAEF;AADqC,GAAlB,CAA/B;AAGA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGP,wBAAwB,CACzBD,EAAE,CAAE,yCAAF,CADuB,EAEzB;AACA;AAAEW,IAAAA,CAAC,EAAE;AAAG,MAAA,IAAI,EAAGF;AAAV;AAAL,GAHyB,CAD3B,CADD;AASA,CAhBD;AAkBA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMG,yBAAyB,GAAGT,0BAA0B,CACzDU,SAAF,IAAmBC,KAAF,IAAa;AAC7B,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAuBF,KAA7B;;AACA,MAAKC,IAAI,KAAK,YAAT,IAAyB,CAAEC,UAAhC,EAA6C;AAC5C,WAAO,cAAC,SAAD;AAAW,MAAA,GAAG,EAAC;AAAf,OAA2BF,KAA3B,EAAP;AACA;;AAED,SACC,8BACC,cAAC,iBAAD,QACC,cAAC,iBAAD,EAAwBA,KAAxB,CADD,CADD,EAIC,cAAC,SAAD;AAAW,IAAA,GAAG,EAAC;AAAf,KAA2BA,KAA3B,EAJD,CADD;AAQA,CAf0D,EAgB3D,uBAhB2D,CAA5D;AAmBA,eAAeF,yBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { addQueryArgs } from '@wordpress/url';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { InspectorControls } from '@wordpress/block-editor';\n\nconst CreateNewPostLink = ( {\n\tattributes: { query: { postType } = {} } = {},\n} ) => {\n\tif ( ! postType ) return null;\n\tconst newPostUrl = addQueryArgs( 'post-new.php', {\n\t\tpost_type: postType,\n\t} );\n\treturn (\n\t\t<div className=\"wp-block-query__create-new-link\">\n\t\t\t{ createInterpolateElement(\n\t\t\t\t__( '<a>Create a new post</a> for this feed.' ),\n\t\t\t\t// eslint-disable-next-line jsx-a11y/anchor-has-content\n\t\t\t\t{ a: <a href={ newPostUrl } /> }\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component\n * @return {Function} Wrapped component\n */\nconst queryTopInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name, isSelected } = props;\n\t\tif ( name !== 'core/query' || ! isSelected ) {\n\t\t\treturn <BlockEdit key=\"edit\" { ...props } />;\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<CreateNewPostLink { ...props } />\n\t\t\t\t</InspectorControls>\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withInspectorControls'\n);\n\nexport default queryTopInspectorControls;\n"]}
@@ -1,28 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { isEmpty } from 'lodash';
5
- /**
6
- * Removed empty nodes from nested objects.
7
- *
8
- * @param {Object} object
9
- * @return {Object} Object cleaned from empty nodes.
10
- */
11
-
12
- const cleanEmptyObject = object => {
13
- if (object === null || typeof object !== 'object' || Array.isArray(object)) {
14
- return object;
15
- }
16
-
17
- const cleanedNestedObjects = Object.fromEntries(Object.entries(object).map(_ref => {
18
- let [key, value] = _ref;
19
- return [key, cleanEmptyObject(value)];
20
- }).filter(_ref2 => {
21
- let [, value] = _ref2;
22
- return Boolean(value);
23
- }));
24
- return isEmpty(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
25
- };
26
-
27
- export default cleanEmptyObject;
28
- //# sourceMappingURL=clean-empty-object.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/clean-empty-object.js"],"names":["isEmpty","cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","Object","fromEntries","entries","map","key","value","filter","Boolean","undefined"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAKC,MAAF,IAAc;AACtC,MACCA,MAAM,KAAK,IAAX,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEAC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAHD,EAIE;AACD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAGC,MAAM,CAACC,WAAP,CAC5BD,MAAM,CAACE,OAAP,CAAgBN,MAAhB,EACEO,GADF,CACO;AAAA,QAAE,CAAEC,GAAF,EAAOC,KAAP,CAAF;AAAA,WAAsB,CAAED,GAAF,EAAOT,gBAAgB,CAAEU,KAAF,CAAvB,CAAtB;AAAA,GADP,EAEEC,MAFF,CAEU;AAAA,QAAE,GAAID,KAAJ,CAAF;AAAA,WAAmBE,OAAO,CAAEF,KAAF,CAA1B;AAAA,GAFV,CAD4B,CAA7B;AAKA,SAAOX,OAAO,CAAEK,oBAAF,CAAP,GAAkCS,SAAlC,GAA8CT,oBAArD;AACA,CAdD;;AAgBA,eAAeJ,gBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * Removed empty nodes from nested objects.\n *\n * @param {Object} object\n * @return {Object} Object cleaned from empty nodes.\n */\nconst cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = Object.fromEntries(\n\t\tObject.entries( object )\n\t\t\t.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )\n\t\t\t.filter( ( [ , value ] ) => Boolean( value ) )\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nexport default cleanEmptyObject;\n"]}
@@ -1,53 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import { createInterpolateElement } from '@wordpress/element';
6
- import { addQueryArgs } from '@wordpress/url';
7
- import { createHigherOrderComponent } from '@wordpress/compose';
8
- import { InspectorControls } from '@wordpress/block-editor';
9
-
10
- const CreateNewPostLink = ( {
11
- attributes: { query: { postType } = {} } = {},
12
- } ) => {
13
- if ( ! postType ) return null;
14
- const newPostUrl = addQueryArgs( 'post-new.php', {
15
- post_type: postType,
16
- } );
17
- return (
18
- <div className="wp-block-query__create-new-link">
19
- { createInterpolateElement(
20
- __( '<a>Create a new post</a> for this feed.' ),
21
- // eslint-disable-next-line jsx-a11y/anchor-has-content
22
- { a: <a href={ newPostUrl } /> }
23
- ) }
24
- </div>
25
- );
26
- };
27
-
28
- /**
29
- * Override the default edit UI to include layout controls
30
- *
31
- * @param {Function} BlockEdit Original component
32
- * @return {Function} Wrapped component
33
- */
34
- const queryTopInspectorControls = createHigherOrderComponent(
35
- ( BlockEdit ) => ( props ) => {
36
- const { name, isSelected } = props;
37
- if ( name !== 'core/query' || ! isSelected ) {
38
- return <BlockEdit key="edit" { ...props } />;
39
- }
40
-
41
- return (
42
- <>
43
- <InspectorControls>
44
- <CreateNewPostLink { ...props } />
45
- </InspectorControls>
46
- <BlockEdit key="edit" { ...props } />
47
- </>
48
- );
49
- },
50
- 'withInspectorControls'
51
- );
52
-
53
- export default queryTopInspectorControls;