@wordpress/block-library 8.25.1-next.79a6196f.0 → 8.27.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.
- package/CHANGELOG.md +4 -0
- package/build/avatar/edit.js +2 -2
- package/build/avatar/edit.js.map +1 -1
- package/build/block/edit.js +75 -12
- package/build/block/edit.js.map +1 -1
- package/build/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/build/block/edit.native.js.map +1 -0
- package/build/block/index.js +5 -3
- package/build/block/index.js.map +1 -1
- package/build/button/edit.js +24 -6
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +1 -0
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +3 -1
- package/build/button/save.js.map +1 -1
- package/build/embed/edit.js +3 -2
- package/build/embed/edit.js.map +1 -1
- package/build/file/index.js +0 -1
- package/build/file/index.js.map +1 -1
- package/build/footnotes/edit.js +2 -1
- package/build/footnotes/edit.js.map +1 -1
- package/build/footnotes/format.js +17 -19
- package/build/footnotes/format.js.map +1 -1
- package/build/heading/edit.js +2 -1
- package/build/heading/edit.js.map +1 -1
- package/build/heading/edit.native.js +141 -0
- package/build/heading/edit.native.js.map +1 -0
- package/build/heading/index.js +1 -0
- package/build/heading/index.js.map +1 -1
- package/build/image/edit.js +8 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +33 -7
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +6 -3
- package/build/image/index.js.map +1 -1
- package/build/more/index.js +4 -0
- package/build/more/index.js.map +1 -1
- package/build/navigation/edit/index.js +2 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/paragraph/edit.js +2 -1
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/index.js +1 -1
- package/build/paragraph/transforms.js +1 -1
- package/build/post-content/edit.js +2 -2
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +1 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-navigation-link/edit.js +43 -2
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-navigation-link/index.js +8 -0
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/pullquote/index.js +4 -0
- package/build/pullquote/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -3
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +2 -2
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +6 -7
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/index.js +1 -2
- package/build/query/index.js.map +1 -1
- package/build/query/variations.js +8 -1
- package/build/query/variations.js.map +1 -1
- package/build/query/view.js +31 -12
- package/build/query/view.js.map +1 -1
- package/build/search/index.js +0 -1
- package/build/search/index.js.map +1 -1
- package/build/table-of-contents/hooks.js +2 -2
- package/build/table-of-contents/hooks.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +1 -4
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +39 -17
- package/build/template-part/edit/index.js.map +1 -1
- package/build/video/edit.native.js +7 -2
- package/build/video/edit.native.js.map +1 -1
- package/build/video/transforms.js +17 -0
- package/build/video/transforms.js.map +1 -1
- package/build-module/avatar/edit.js +2 -2
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/block/edit.js +74 -11
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/{v1/edit.native.js → edit.native.js} +3 -3
- package/build-module/block/edit.native.js.map +1 -0
- package/build-module/block/index.js +5 -3
- package/build-module/block/index.js.map +1 -1
- package/build-module/button/edit.js +25 -7
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +1 -0
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +4 -2
- package/build-module/button/save.js.map +1 -1
- package/build-module/embed/edit.js +3 -2
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/file/index.js +0 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/footnotes/edit.js +2 -1
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/footnotes/format.js +17 -19
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/heading/edit.js +3 -2
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/edit.native.js +132 -0
- package/build-module/heading/edit.native.js.map +1 -0
- package/build-module/heading/index.js +1 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/edit.js +9 -5
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +33 -7
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +6 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/more/index.js +4 -0
- package/build-module/more/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/paragraph/edit.js +3 -2
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/index.js +1 -1
- package/build-module/paragraph/transforms.js +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +1 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +44 -3
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-navigation-link/index.js +8 -0
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/pullquote/index.js +4 -0
- package/build-module/pullquote/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +4 -4
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +2 -2
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +7 -8
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/index.js +1 -2
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/variations.js +8 -1
- package/build-module/query/variations.js.map +1 -1
- package/build-module/query/view.js +30 -9
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/index.js +0 -1
- package/build-module/search/index.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +2 -2
- package/build-module/table-of-contents/hooks.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +1 -4
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +38 -16
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/video/edit.native.js +7 -2
- package/build-module/video/edit.native.js.map +1 -1
- package/build-module/video/transforms.js +17 -0
- package/build-module/video/transforms.js.map +1 -1
- package/build-style/common-rtl.css +4 -2
- package/build-style/common.css +4 -2
- package/build-style/cover/style-rtl.css +1 -2
- package/build-style/cover/style.css +1 -2
- package/build-style/editor-rtl.css +6 -4
- package/build-style/editor.css +6 -4
- package/build-style/gallery/style-rtl.css +2 -4
- package/build-style/gallery/style.css +2 -4
- package/build-style/image/editor-rtl.css +6 -0
- package/build-style/image/editor.css +6 -0
- package/build-style/page-list/editor-rtl.css +0 -4
- package/build-style/page-list/editor.css +0 -4
- package/build-style/pullquote/style-rtl.css +10 -1
- package/build-style/pullquote/style.css +10 -1
- package/build-style/search/style-rtl.css +2 -1
- package/build-style/search/style.css +2 -1
- package/build-style/style-rtl.css +19 -11
- package/build-style/style.css +19 -11
- package/build-style/video/style-rtl.css +1 -2
- package/build-style/video/style.css +1 -2
- package/package.json +34 -32
- package/src/avatar/edit.js +16 -18
- package/src/block/block.json +3 -0
- package/src/block/edit.js +96 -14
- package/src/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/src/block/index.js +2 -3
- package/src/block/index.php +3 -31
- package/src/button/block.json +1 -0
- package/src/button/edit.js +76 -43
- package/src/button/save.js +3 -0
- package/src/embed/edit.js +3 -2
- package/src/file/block.json +0 -1
- package/src/file/index.php +11 -57
- package/src/footnotes/edit.js +2 -1
- package/src/footnotes/format.js +34 -31
- package/src/footnotes/index.php +20 -11
- package/src/heading/block.json +1 -0
- package/src/heading/edit.js +18 -14
- package/src/heading/edit.native.js +144 -0
- package/src/image/block.json +7 -3
- package/src/image/edit.js +19 -6
- package/src/image/editor.scss +6 -1
- package/src/image/image.js +101 -42
- package/src/image/index.js +6 -0
- package/src/image/index.php +14 -51
- package/src/more/index.js +6 -0
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +2 -2
- package/src/navigation/index.php +777 -28
- package/src/navigation-link/index.php +78 -16
- package/src/page-list/editor.scss +0 -4
- package/src/paragraph/block.json +1 -1
- package/src/paragraph/edit.js +23 -19
- package/src/post-content/edit.js +2 -2
- package/src/post-date/edit.js +38 -33
- package/src/post-navigation-link/block.json +8 -0
- package/src/post-navigation-link/edit.js +63 -1
- package/src/post-navigation-link/index.php +17 -3
- package/src/post-terms/index.php +13 -4
- package/src/pullquote/block.json +4 -0
- package/src/pullquote/style.scss +13 -1
- package/src/query/block.json +1 -2
- package/src/query/edit/inspector-controls/index.js +137 -146
- package/src/query/edit/query-content.js +9 -7
- package/src/query/edit/query-placeholder.js +11 -11
- package/src/query/index.php +33 -71
- package/src/query/variations.js +4 -0
- package/src/query/view.js +24 -19
- package/src/search/block.json +0 -1
- package/src/search/index.php +18 -36
- package/src/table-of-contents/hooks.js +2 -2
- package/src/template-part/edit/advanced-controls.js +2 -3
- package/src/template-part/edit/index.js +77 -50
- package/src/template-part/index.php +2 -2
- package/src/video/edit.native.js +5 -2
- package/src/video/test/edit.native.js +38 -0
- package/src/video/transforms.js +32 -0
- package/tsconfig.json +1 -0
- package/build/block/v1/edit.js +0 -116
- package/build/block/v1/edit.js.map +0 -1
- package/build/block/v1/edit.native.js.map +0 -1
- package/build-module/block/v1/edit.js +0 -108
- package/build-module/block/v1/edit.js.map +0 -1
- package/build-module/block/v1/edit.native.js.map +0 -1
- package/src/block/v1/edit.js +0 -163
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
/**
|
|
3
|
-
* Server-side rendering of the `core/navigation-link` block.
|
|
3
|
+
* Server-side registering and rendering of the `core/navigation-link` block.
|
|
4
4
|
*
|
|
5
5
|
* @package WordPress
|
|
6
6
|
*/
|
|
@@ -323,12 +323,12 @@ function build_variation_for_navigation_link( $entity, $kind ) {
|
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
/**
|
|
326
|
-
* Register a variation for a post type / taxonomy for the navigation link block
|
|
326
|
+
* Register a variation for a post type / taxonomy for the navigation link block.
|
|
327
327
|
*
|
|
328
328
|
* @param array $variation Variation array from build_variation_for_navigation_link.
|
|
329
329
|
* @return void
|
|
330
330
|
*/
|
|
331
|
-
function
|
|
331
|
+
function block_core_navigation_link_register_variation( $variation ) {
|
|
332
332
|
// Directly set the variations on the registered block type
|
|
333
333
|
// because there's no server side registration for variations (see #47170).
|
|
334
334
|
$navigation_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/navigation-link' );
|
|
@@ -338,16 +338,45 @@ function register_block_core_navigation_link_variation( $variation ) {
|
|
|
338
338
|
return;
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
$navigation_block_type->variations
|
|
341
|
+
$navigation_block_type->variations = array_merge(
|
|
342
|
+
$navigation_block_type->variations,
|
|
343
|
+
array( $variation )
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Unregister a variation for a post type / taxonomy for the navigation link block.
|
|
349
|
+
*
|
|
350
|
+
* @param string $name Name of the post type / taxonomy (which was used as variation name).
|
|
351
|
+
* @return void
|
|
352
|
+
*/
|
|
353
|
+
function block_core_navigation_link_unregister_variation( $name ) {
|
|
354
|
+
// Directly get the variations from the registered block type
|
|
355
|
+
// because there's no server side (un)registration for variations (see #47170).
|
|
356
|
+
$navigation_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/navigation-link' );
|
|
357
|
+
// If the block is not registered (yet), there's no need to remove a variation.
|
|
358
|
+
if ( ! $navigation_block_type || empty( $navigation_block_type->variations ) ) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
$variations = $navigation_block_type->variations;
|
|
362
|
+
// Search for the variation and remove it from the array.
|
|
363
|
+
foreach ( $variations as $i => $variation ) {
|
|
364
|
+
if ( $variation['name'] === $name ) {
|
|
365
|
+
unset( $variations[ $i ] );
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
// Reindex array after removing one variation.
|
|
370
|
+
$navigation_block_type->variations = array_values( $variations );
|
|
342
371
|
}
|
|
343
372
|
|
|
344
373
|
/**
|
|
345
374
|
* Register the navigation link block.
|
|
375
|
+
* Returns an array of variations for the navigation link block.
|
|
346
376
|
*
|
|
347
|
-
* @
|
|
348
|
-
* @throws WP_Error An WP_Error exception parsing the block definition.
|
|
377
|
+
* @return array
|
|
349
378
|
*/
|
|
350
|
-
function
|
|
379
|
+
function build_navigation_link_block_variations() {
|
|
351
380
|
// This will only handle post types and taxonomies registered until this point (init on priority 9).
|
|
352
381
|
// See action hooks below for other post types and taxonomies.
|
|
353
382
|
// See https://github.com/WordPress/gutenberg/issues/53826 for details.
|
|
@@ -382,32 +411,45 @@ function register_block_core_navigation_link() {
|
|
|
382
411
|
}
|
|
383
412
|
}
|
|
384
413
|
|
|
414
|
+
return array_merge( $built_ins, $variations );
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Register the navigation link block.
|
|
419
|
+
*
|
|
420
|
+
* @uses render_block_core_navigation()
|
|
421
|
+
* @throws WP_Error An WP_Error exception parsing the block definition.
|
|
422
|
+
*/
|
|
423
|
+
function register_block_core_navigation_link() {
|
|
385
424
|
register_block_type_from_metadata(
|
|
386
425
|
__DIR__ . '/navigation-link',
|
|
387
426
|
array(
|
|
388
|
-
'render_callback'
|
|
389
|
-
'
|
|
427
|
+
'render_callback' => 'render_block_core_navigation_link',
|
|
428
|
+
'variation_callback' => 'build_navigation_link_block_variations',
|
|
390
429
|
)
|
|
391
430
|
);
|
|
392
431
|
}
|
|
393
432
|
add_action( 'init', 'register_block_core_navigation_link' );
|
|
394
433
|
// Register actions for all post types and taxonomies, to add variations when they are registered.
|
|
395
434
|
// All post types/taxonomies registered before register_block_core_navigation_link, will be handled by that function.
|
|
396
|
-
add_action( 'registered_post_type', '
|
|
397
|
-
add_action( 'registered_taxonomy', '
|
|
435
|
+
add_action( 'registered_post_type', 'block_core_navigation_link_register_post_type_variation', 10, 2 );
|
|
436
|
+
add_action( 'registered_taxonomy', 'block_core_navigation_link_register_taxonomy_variation', 10, 3 );
|
|
437
|
+
// Handle unregistering of post types and taxonomies and remove the variations.
|
|
438
|
+
add_action( 'unregistered_post_type', 'block_core_navigation_link_unregister_post_type_variation' );
|
|
439
|
+
add_action( 'unregistered_taxonomy', 'block_core_navigation_link_unregister_taxonomy_variation' );
|
|
398
440
|
|
|
399
441
|
/**
|
|
400
442
|
* Register custom post type variations for navigation link on post type registration
|
|
401
443
|
* Handles all post types registered after the block is registered in register_navigation_link_post_type_variations
|
|
402
444
|
*
|
|
403
|
-
* @param string $post_type The post type name passed from registered_post_type
|
|
445
|
+
* @param string $post_type The post type name passed from registered_post_type action hook.
|
|
404
446
|
* @param WP_Post_Type $post_type_object The post type object passed from registered_post_type.
|
|
405
447
|
* @return void
|
|
406
448
|
*/
|
|
407
|
-
function
|
|
449
|
+
function block_core_navigation_link_register_post_type_variation( $post_type, $post_type_object ) {
|
|
408
450
|
if ( $post_type_object->show_in_nav_menus ) {
|
|
409
451
|
$variation = build_variation_for_navigation_link( $post_type_object, 'post-type' );
|
|
410
|
-
|
|
452
|
+
block_core_navigation_link_register_variation( $variation );
|
|
411
453
|
}
|
|
412
454
|
}
|
|
413
455
|
|
|
@@ -420,9 +462,29 @@ function register_block_core_navigation_link_post_type_variation( $post_type, $p
|
|
|
420
462
|
* @param array $args Array of taxonomy registration arguments.
|
|
421
463
|
* @return void
|
|
422
464
|
*/
|
|
423
|
-
function
|
|
465
|
+
function block_core_navigation_link_register_taxonomy_variation( $taxonomy, $object_type, $args ) {
|
|
424
466
|
if ( isset( $args['show_in_nav_menus'] ) && $args['show_in_nav_menus'] ) {
|
|
425
467
|
$variation = build_variation_for_navigation_link( (object) $args, 'post-type' );
|
|
426
|
-
|
|
468
|
+
block_core_navigation_link_register_variation( $variation );
|
|
427
469
|
}
|
|
428
470
|
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Unregisters a custom post type variation for navigation link on post type unregistration.
|
|
474
|
+
*
|
|
475
|
+
* @param string $post_type The post type name passed from unregistered_post_type action hook.
|
|
476
|
+
* @return void
|
|
477
|
+
*/
|
|
478
|
+
function block_core_navigation_link_unregister_post_type_variation( $post_type ) {
|
|
479
|
+
block_core_navigation_link_unregister_variation( $post_type );
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Unregisters a custom taxonomy variation for navigation link on taxonomy unregistration.
|
|
484
|
+
*
|
|
485
|
+
* @param string $taxonomy The taxonomy name passed from unregistered_taxonomy action hook.
|
|
486
|
+
* @return void
|
|
487
|
+
*/
|
|
488
|
+
function block_core_navigation_link_unregister_taxonomy_variation( $taxonomy ) {
|
|
489
|
+
block_core_navigation_link_unregister_variation( $taxonomy );
|
|
490
|
+
}
|
package/src/paragraph/block.json
CHANGED
package/src/paragraph/edit.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
RichText,
|
|
20
20
|
useBlockProps,
|
|
21
21
|
useSettings,
|
|
22
|
+
useBlockEditingMode,
|
|
22
23
|
} from '@wordpress/block-editor';
|
|
23
24
|
import { createBlock } from '@wordpress/blocks';
|
|
24
25
|
import { formatLtr } from '@wordpress/icons';
|
|
@@ -108,28 +109,31 @@ function ParagraphBlock( {
|
|
|
108
109
|
} ),
|
|
109
110
|
style: { direction },
|
|
110
111
|
} );
|
|
112
|
+
const blockEditingMode = useBlockEditingMode();
|
|
111
113
|
|
|
112
114
|
return (
|
|
113
115
|
<>
|
|
114
|
-
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
116
|
+
{ blockEditingMode === 'default' && (
|
|
117
|
+
<BlockControls group="block">
|
|
118
|
+
<AlignmentControl
|
|
119
|
+
value={ align }
|
|
120
|
+
onChange={ ( newAlign ) =>
|
|
121
|
+
setAttributes( {
|
|
122
|
+
align: newAlign,
|
|
123
|
+
dropCap: hasDropCapDisabled( newAlign )
|
|
124
|
+
? false
|
|
125
|
+
: dropCap,
|
|
126
|
+
} )
|
|
127
|
+
}
|
|
128
|
+
/>
|
|
129
|
+
<ParagraphRTLControl
|
|
130
|
+
direction={ direction }
|
|
131
|
+
setDirection={ ( newDirection ) =>
|
|
132
|
+
setAttributes( { direction: newDirection } )
|
|
133
|
+
}
|
|
134
|
+
/>
|
|
135
|
+
</BlockControls>
|
|
136
|
+
) }
|
|
133
137
|
<InspectorControls group="typography">
|
|
134
138
|
<DropCapControl
|
|
135
139
|
clientId={ clientId }
|
package/src/post-content/edit.js
CHANGED
|
@@ -5,8 +5,8 @@ import { __ } from '@wordpress/i18n';
|
|
|
5
5
|
import {
|
|
6
6
|
useBlockProps,
|
|
7
7
|
useInnerBlocksProps,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
RecursionProvider,
|
|
9
|
+
useHasRecursion,
|
|
10
10
|
Warning,
|
|
11
11
|
} from '@wordpress/block-editor';
|
|
12
12
|
import {
|
package/src/post-date/edit.js
CHANGED
|
@@ -108,40 +108,45 @@ export default function PostDateEdit( {
|
|
|
108
108
|
setAttributes( { textAlign: nextAlign } );
|
|
109
109
|
} }
|
|
110
110
|
/>
|
|
111
|
-
{ date &&
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
renderToggle={ ( { isOpen, onToggle } ) => {
|
|
126
|
-
const openOnArrowDown = ( event ) => {
|
|
127
|
-
if ( ! isOpen && event.keyCode === DOWN ) {
|
|
128
|
-
event.preventDefault();
|
|
129
|
-
onToggle();
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
return (
|
|
133
|
-
<ToolbarButton
|
|
134
|
-
aria-expanded={ isOpen }
|
|
135
|
-
icon={ edit }
|
|
136
|
-
title={ __( 'Change Date' ) }
|
|
137
|
-
onClick={ onToggle }
|
|
138
|
-
onKeyDown={ openOnArrowDown }
|
|
111
|
+
{ date &&
|
|
112
|
+
displayType === 'date' &&
|
|
113
|
+
! isDescendentOfQueryLoop && (
|
|
114
|
+
<ToolbarGroup>
|
|
115
|
+
<Dropdown
|
|
116
|
+
popoverProps={ popoverProps }
|
|
117
|
+
renderContent={ ( { onClose } ) => (
|
|
118
|
+
<PublishDateTimePicker
|
|
119
|
+
currentDate={ date }
|
|
120
|
+
onChange={ setDate }
|
|
121
|
+
is12Hour={ is12HourFormat(
|
|
122
|
+
siteTimeFormat
|
|
123
|
+
) }
|
|
124
|
+
onClose={ onClose }
|
|
139
125
|
/>
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
126
|
+
) }
|
|
127
|
+
renderToggle={ ( { isOpen, onToggle } ) => {
|
|
128
|
+
const openOnArrowDown = ( event ) => {
|
|
129
|
+
if (
|
|
130
|
+
! isOpen &&
|
|
131
|
+
event.keyCode === DOWN
|
|
132
|
+
) {
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
onToggle();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
return (
|
|
138
|
+
<ToolbarButton
|
|
139
|
+
aria-expanded={ isOpen }
|
|
140
|
+
icon={ edit }
|
|
141
|
+
title={ __( 'Change Date' ) }
|
|
142
|
+
onClick={ onToggle }
|
|
143
|
+
onKeyDown={ openOnArrowDown }
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
} }
|
|
147
|
+
/>
|
|
148
|
+
</ToolbarGroup>
|
|
149
|
+
) }
|
|
145
150
|
</BlockControls>
|
|
146
151
|
|
|
147
152
|
<InspectorControls>
|
|
@@ -28,8 +28,16 @@
|
|
|
28
28
|
"arrow": {
|
|
29
29
|
"type": "string",
|
|
30
30
|
"default": "none"
|
|
31
|
+
},
|
|
32
|
+
"inSameTerm": {
|
|
33
|
+
"type": "boolean"
|
|
34
|
+
},
|
|
35
|
+
"taxonomy": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"default": ""
|
|
31
38
|
}
|
|
32
39
|
},
|
|
40
|
+
"usesContext": [ "postType" ],
|
|
33
41
|
"supports": {
|
|
34
42
|
"reusable": false,
|
|
35
43
|
"html": false,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
11
11
|
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
12
12
|
ToggleControl,
|
|
13
|
+
SelectControl,
|
|
13
14
|
PanelBody,
|
|
14
15
|
} from '@wordpress/components';
|
|
15
16
|
import {
|
|
@@ -20,9 +21,20 @@ import {
|
|
|
20
21
|
useBlockProps,
|
|
21
22
|
} from '@wordpress/block-editor';
|
|
22
23
|
import { __, _x } from '@wordpress/i18n';
|
|
24
|
+
import { useSelect } from '@wordpress/data';
|
|
25
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
23
26
|
|
|
24
27
|
export default function PostNavigationLinkEdit( {
|
|
25
|
-
|
|
28
|
+
context: { postType },
|
|
29
|
+
attributes: {
|
|
30
|
+
type,
|
|
31
|
+
label,
|
|
32
|
+
showTitle,
|
|
33
|
+
textAlign,
|
|
34
|
+
linkLabel,
|
|
35
|
+
arrow,
|
|
36
|
+
taxonomy,
|
|
37
|
+
},
|
|
26
38
|
setAttributes,
|
|
27
39
|
} ) {
|
|
28
40
|
const isNext = type === 'next';
|
|
@@ -47,6 +59,40 @@ export default function PostNavigationLinkEdit( {
|
|
|
47
59
|
[ `has-text-align-${ textAlign }` ]: textAlign,
|
|
48
60
|
} ),
|
|
49
61
|
} );
|
|
62
|
+
|
|
63
|
+
const taxonomies = useSelect(
|
|
64
|
+
( select ) => {
|
|
65
|
+
const { getTaxonomies } = select( coreStore );
|
|
66
|
+
const filteredTaxonomies = getTaxonomies( {
|
|
67
|
+
type: postType,
|
|
68
|
+
per_page: -1,
|
|
69
|
+
context: 'view',
|
|
70
|
+
} );
|
|
71
|
+
return filteredTaxonomies;
|
|
72
|
+
},
|
|
73
|
+
[ postType ]
|
|
74
|
+
);
|
|
75
|
+
const getTaxonomyOptions = () => {
|
|
76
|
+
const selectOption = {
|
|
77
|
+
label: __( 'Unfiltered' ),
|
|
78
|
+
value: '',
|
|
79
|
+
};
|
|
80
|
+
const taxonomyOptions = ( taxonomies ?? [] )
|
|
81
|
+
.filter(
|
|
82
|
+
( tax ) =>
|
|
83
|
+
tax.slug !== 'nav_menu' &&
|
|
84
|
+
tax.slug !== 'wp_pattern_category'
|
|
85
|
+
)
|
|
86
|
+
.map( ( item ) => {
|
|
87
|
+
return {
|
|
88
|
+
value: item.slug,
|
|
89
|
+
label: item.name,
|
|
90
|
+
};
|
|
91
|
+
} );
|
|
92
|
+
|
|
93
|
+
return [ selectOption, ...taxonomyOptions ];
|
|
94
|
+
};
|
|
95
|
+
|
|
50
96
|
return (
|
|
51
97
|
<>
|
|
52
98
|
<InspectorControls>
|
|
@@ -114,6 +160,22 @@ export default function PostNavigationLinkEdit( {
|
|
|
114
160
|
</ToggleGroupControl>
|
|
115
161
|
</PanelBody>
|
|
116
162
|
</InspectorControls>
|
|
163
|
+
<InspectorControls group="advanced">
|
|
164
|
+
<SelectControl
|
|
165
|
+
label={ __( 'Filter by taxonomy' ) }
|
|
166
|
+
value={ taxonomy }
|
|
167
|
+
options={ getTaxonomyOptions() }
|
|
168
|
+
onChange={ ( value ) =>
|
|
169
|
+
setAttributes( {
|
|
170
|
+
taxonomy: value,
|
|
171
|
+
inSameTerm: value === '' ? false : true,
|
|
172
|
+
} )
|
|
173
|
+
}
|
|
174
|
+
help={ __(
|
|
175
|
+
'Only link to posts that have the same taxonomy terms as the current post. For example the same tags or categories.'
|
|
176
|
+
) }
|
|
177
|
+
/>
|
|
178
|
+
</InspectorControls>
|
|
117
179
|
<BlockControls>
|
|
118
180
|
<AlignmentToolbar
|
|
119
181
|
value={ textAlign }
|
|
@@ -99,10 +99,24 @@ function render_block_core_post_navigation_link( $attributes, $content ) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
$in_same_term = isset( $attributes['inSameTerm'] ) ? $attributes['inSameTerm'] : false;
|
|
103
|
+
$taxonomy = isset( $attributes['taxonomy'] ) && $in_same_term ? $attributes['taxonomy'] : '';
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The dynamic portion of the function name, `$navigation_type`,
|
|
107
|
+
* Refers to the type of adjacency, 'next' or 'previous'.
|
|
108
|
+
*
|
|
109
|
+
* @See https://developer.wordpress.org/reference/functions/get_previous_post_link/
|
|
110
|
+
* @See https://developer.wordpress.org/reference/functions/get_next_post_link/
|
|
111
|
+
*/
|
|
104
112
|
$get_link_function = "get_{$navigation_type}_post_link";
|
|
105
|
-
|
|
113
|
+
|
|
114
|
+
if ( $in_same_term ) {
|
|
115
|
+
$content = $get_link_function( $format, $link, $in_same_term, '', $taxonomy );
|
|
116
|
+
} else {
|
|
117
|
+
$content = $get_link_function( $format, $link );
|
|
118
|
+
}
|
|
119
|
+
|
|
106
120
|
return sprintf(
|
|
107
121
|
'<div %1$s>%2$s</div>',
|
|
108
122
|
$wrapper_attributes,
|
package/src/post-terms/index.php
CHANGED
|
@@ -59,9 +59,11 @@ function render_block_core_post_terms( $attributes, $content, $block ) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* Returns the available variations for the `core/post-terms` block.
|
|
63
|
+
*
|
|
64
|
+
* @return array The available variations for the block.
|
|
63
65
|
*/
|
|
64
|
-
function
|
|
66
|
+
function build_post_term_block_variations() {
|
|
65
67
|
$taxonomies = get_taxonomies(
|
|
66
68
|
array(
|
|
67
69
|
'publicly_queryable' => true,
|
|
@@ -103,11 +105,18 @@ function register_block_core_post_terms() {
|
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
|
|
108
|
+
return array_merge( $built_ins, $custom_variations );
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Registers the `core/post-terms` block on the server.
|
|
113
|
+
*/
|
|
114
|
+
function register_block_core_post_terms() {
|
|
106
115
|
register_block_type_from_metadata(
|
|
107
116
|
__DIR__ . '/post-terms',
|
|
108
117
|
array(
|
|
109
|
-
'render_callback'
|
|
110
|
-
'
|
|
118
|
+
'render_callback' => 'render_block_core_post_terms',
|
|
119
|
+
'variation_callback' => 'build_post_term_block_variations',
|
|
111
120
|
)
|
|
112
121
|
);
|
|
113
122
|
}
|
package/src/pullquote/block.json
CHANGED
package/src/pullquote/style.scss
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.wp-block-pullquote {
|
|
2
|
-
padding:
|
|
2
|
+
padding: 4em 0;
|
|
3
3
|
text-align: center; // Default text-alignment where the `textAlign` attribute value isn't specified.
|
|
4
4
|
overflow-wrap: break-word; // Break long strings of text without spaces so they don't overflow the block.
|
|
5
5
|
box-sizing: border-box;
|
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
color: inherit;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
blockquote {
|
|
14
|
+
margin: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
p {
|
|
18
|
+
margin-top: 0;
|
|
19
|
+
|
|
20
|
+
&:last-child {
|
|
21
|
+
margin-bottom: 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
13
25
|
&.alignleft,
|
|
14
26
|
&.alignright {
|
|
15
27
|
max-width: $content-width * 0.5;
|