@automattic/newspack-blocks 4.30.4 → 4.31.0-alpha.2
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 +3 -3
- package/dist/block_styles-rtl.css +2 -2
- package/dist/block_styles.asset.php +1 -1
- package/dist/block_styles.css +2 -2
- package/dist/blocks/carousel/block.json +4 -0
- package/dist/carousel/view-rtl.css +1 -1
- package/dist/carousel/view.asset.php +1 -1
- package/dist/carousel/view.css +1 -1
- package/dist/donate/view-rtl.css +1 -1
- package/dist/donate/view.asset.php +1 -1
- package/dist/donate/view.css +1 -1
- package/dist/editor-rtl.css +25 -24
- package/dist/editor.asset.php +1 -1
- package/dist/editor.css +25 -24
- package/dist/editor.js +24 -20
- package/dist/frequencyBased-rtl.css +1 -1
- package/dist/frequencyBased.asset.php +1 -1
- package/dist/frequencyBased.css +1 -1
- package/dist/homepage-articles/view-rtl.css +1 -1
- package/dist/homepage-articles/view.asset.php +1 -1
- package/dist/homepage-articles/view.css +1 -1
- package/dist/modal-rtl.css +1 -1
- package/dist/modal.asset.php +1 -1
- package/dist/modal.css +1 -1
- package/dist/modalCheckout-rtl.css +1 -1
- package/dist/modalCheckout.asset.php +1 -1
- package/dist/modalCheckout.css +1 -1
- package/dist/tiersBased-rtl.css +1 -1
- package/dist/tiersBased.asset.php +1 -1
- package/dist/tiersBased.css +1 -1
- package/includes/class-modal-checkout.php +8 -37
- package/includes/modal-checkout/class-checkout-data.php +39 -6
- package/includes/tracking/class-data-events.php +10 -64
- package/languages/newspack-blocks-de_DE-37552bb09e2a9fceec1970e3c6d46557.json +1 -1
- package/languages/newspack-blocks-de_DE-4fdea541976076f02d56139fb35e5b42.json +1 -1
- package/languages/newspack-blocks-de_DE-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -1
- package/languages/newspack-blocks-de_DE-7c29764d5ef91723f5ce454f66431b9e.json +1 -1
- package/languages/newspack-blocks-de_DE-969286d51bb0afe10983b9aec317b5ee.json +1 -1
- package/languages/newspack-blocks-de_DE-9970d3523fc8f26107b47ceeeb706779.json +1 -0
- package/languages/newspack-blocks-de_DE-eccbc51a43c04f59165364eda71e0be7.json +1 -1
- package/languages/newspack-blocks-de_DE-f8b1589c450689398f90b179f47e74ee.json +1 -1
- package/languages/newspack-blocks-de_DE.po +624 -587
- package/languages/newspack-blocks-es_ES-37552bb09e2a9fceec1970e3c6d46557.json +1 -1
- package/languages/newspack-blocks-es_ES-4fdea541976076f02d56139fb35e5b42.json +1 -1
- package/languages/newspack-blocks-es_ES-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -1
- package/languages/newspack-blocks-es_ES-7c29764d5ef91723f5ce454f66431b9e.json +1 -1
- package/languages/newspack-blocks-es_ES-969286d51bb0afe10983b9aec317b5ee.json +1 -1
- package/languages/newspack-blocks-es_ES-9970d3523fc8f26107b47ceeeb706779.json +1 -0
- package/languages/newspack-blocks-es_ES-eccbc51a43c04f59165364eda71e0be7.json +1 -1
- package/languages/newspack-blocks-es_ES-f8b1589c450689398f90b179f47e74ee.json +1 -1
- package/languages/newspack-blocks-es_ES.po +604 -567
- package/languages/newspack-blocks-fr_BE-37552bb09e2a9fceec1970e3c6d46557.json +1 -1
- package/languages/newspack-blocks-fr_BE-4fdea541976076f02d56139fb35e5b42.json +1 -1
- package/languages/newspack-blocks-fr_BE-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -1
- package/languages/newspack-blocks-fr_BE-7c29764d5ef91723f5ce454f66431b9e.json +1 -1
- package/languages/newspack-blocks-fr_BE-969286d51bb0afe10983b9aec317b5ee.json +1 -1
- package/languages/newspack-blocks-fr_BE-9970d3523fc8f26107b47ceeeb706779.json +1 -0
- package/languages/newspack-blocks-fr_BE-eccbc51a43c04f59165364eda71e0be7.json +1 -1
- package/languages/newspack-blocks-fr_BE-f8b1589c450689398f90b179f47e74ee.json +1 -1
- package/languages/newspack-blocks-fr_BE.po +602 -565
- package/languages/newspack-blocks-nb_NO-37552bb09e2a9fceec1970e3c6d46557.json +1 -1
- package/languages/newspack-blocks-nb_NO-4fdea541976076f02d56139fb35e5b42.json +1 -1
- package/languages/newspack-blocks-nb_NO-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -1
- package/languages/newspack-blocks-nb_NO-7c29764d5ef91723f5ce454f66431b9e.json +1 -1
- package/languages/newspack-blocks-nb_NO-969286d51bb0afe10983b9aec317b5ee.json +1 -1
- package/languages/newspack-blocks-nb_NO-9970d3523fc8f26107b47ceeeb706779.json +1 -0
- package/languages/newspack-blocks-nb_NO-eccbc51a43c04f59165364eda71e0be7.json +1 -1
- package/languages/newspack-blocks-nb_NO-f8b1589c450689398f90b179f47e74ee.json +1 -1
- package/languages/newspack-blocks-nb_NO.po +602 -565
- package/languages/newspack-blocks-pt_PT-37552bb09e2a9fceec1970e3c6d46557.json +1 -1
- package/languages/newspack-blocks-pt_PT-4fdea541976076f02d56139fb35e5b42.json +1 -1
- package/languages/newspack-blocks-pt_PT-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -1
- package/languages/newspack-blocks-pt_PT-7c29764d5ef91723f5ce454f66431b9e.json +1 -1
- package/languages/newspack-blocks-pt_PT-969286d51bb0afe10983b9aec317b5ee.json +1 -1
- package/languages/newspack-blocks-pt_PT-9970d3523fc8f26107b47ceeeb706779.json +1 -0
- package/languages/newspack-blocks-pt_PT-eccbc51a43c04f59165364eda71e0be7.json +1 -1
- package/languages/newspack-blocks-pt_PT-f8b1589c450689398f90b179f47e74ee.json +1 -1
- package/languages/newspack-blocks-pt_PT.po +620 -583
- package/languages/newspack-blocks.pot +806 -760
- package/newspack-blocks.php +2 -2
- package/package.json +6 -5
- package/src/blocks/carousel/block.json +4 -0
- package/src/blocks/carousel/edit.js +22 -0
- package/src/blocks/carousel/view.php +13 -1
- package/src/blocks/checkout-button/view.php +1 -1
- package/src/blocks/donate/edit/index.tsx +23 -11
- package/src/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php +25 -6
- package/src/blocks/homepage-articles/edit.tsx +8 -3
- package/src/blocks/homepage-articles/utils.ts +6 -3
- package/src/types/index.d.ts +2 -0
- package/vendor/composer/installed.php +2 -2
package/newspack-blocks.php
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Author URI: https://newspack.com/
|
|
8
8
|
* Text Domain: newspack-blocks
|
|
9
9
|
* Domain Path: /languages
|
|
10
|
-
* Version: 4.
|
|
10
|
+
* Version: 4.31.0-alpha.2
|
|
11
11
|
*
|
|
12
12
|
* @package Newspack_Blocks
|
|
13
13
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
|
|
16
16
|
define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
|
|
17
17
|
define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
|
|
18
|
-
define( 'NEWSPACK_BLOCKS__VERSION', '4.
|
|
18
|
+
define( 'NEWSPACK_BLOCKS__VERSION', '4.31.0-alpha.2' );
|
|
19
19
|
|
|
20
20
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
|
|
21
21
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/newspack-blocks",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.31.0-alpha.2",
|
|
4
4
|
"author": "Automattic",
|
|
5
5
|
"description": "=== Newspack Blocks === Contributors: (this should be a list of wordpress.org userid's) Donate link: https://example.com/ Tags: comments, spam Requires at least: 4.5 Tested up to: 5.1.1 Stable tag: 0.1.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html",
|
|
6
6
|
"repository": {
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"format:scss": "newspack-scripts wp-scripts lint-style '**/{src,includes}/**/*.scss' --customSyntax postcss-scss --fix",
|
|
34
34
|
"i18n": "NODE_ENV=production npm run build; bash ./bin/update-translations.sh",
|
|
35
35
|
"release": "npm run build && npm run semantic-release",
|
|
36
|
-
"release:archive": "rm -rf release && mkdir -p release && rsync -r . ./release/newspack-blocks --exclude-from='./.distignore' && cd release && zip -r newspack-blocks.zip newspack-blocks"
|
|
36
|
+
"release:archive": "rm -rf release && mkdir -p release && rsync -r . ./release/newspack-blocks --exclude-from='./.distignore' && cd release && zip -r newspack-blocks.zip newspack-blocks",
|
|
37
|
+
"typescript:check": "newspack-scripts typescript-check"
|
|
37
38
|
},
|
|
38
39
|
"lint-staged": {
|
|
39
40
|
"*.{js,jsx,ts,tsx}": "npm run lint:js:staged",
|
|
@@ -46,8 +47,8 @@
|
|
|
46
47
|
"dependencies": {
|
|
47
48
|
"classnames": "^2.5.1",
|
|
48
49
|
"lodash": "^4.17.21",
|
|
49
|
-
"newspack-colors": "1.1.
|
|
50
|
-
"newspack-icons": "1.1.1",
|
|
50
|
+
"newspack-colors": "1.1.4-alpha.1",
|
|
51
|
+
"newspack-icons": "1.1.2-alpha.1",
|
|
51
52
|
"redux": "^5.0.0",
|
|
52
53
|
"redux-saga": "^1.5.0",
|
|
53
54
|
"regenerator-runtime": "^0.14.1",
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@types/lodash": "^4.17.23",
|
|
58
|
-
"newspack-components": "4.
|
|
59
|
+
"newspack-components": "4.7.0-alpha.2",
|
|
59
60
|
"newspack-scripts": "5.11.0"
|
|
60
61
|
},
|
|
61
62
|
"overrides": {
|
|
@@ -148,6 +148,7 @@ class Edit extends Component {
|
|
|
148
148
|
postsToShow,
|
|
149
149
|
postType,
|
|
150
150
|
showCategory,
|
|
151
|
+
showTagLabels,
|
|
151
152
|
showDate,
|
|
152
153
|
showAuthor,
|
|
153
154
|
showAvatar,
|
|
@@ -334,6 +335,11 @@ class Edit extends Component {
|
|
|
334
335
|
checked={ showCategory }
|
|
335
336
|
onChange={ () => setAttributes( { showCategory: ! showCategory } ) }
|
|
336
337
|
/>
|
|
338
|
+
<ToggleControl
|
|
339
|
+
label={ __( 'Show tag labels', 'newspack-blocks' ) }
|
|
340
|
+
checked={ showTagLabels }
|
|
341
|
+
onChange={ () => setAttributes( { showTagLabels: ! showTagLabels } ) }
|
|
342
|
+
/>
|
|
337
343
|
<ToggleControl
|
|
338
344
|
label={ __( 'Show author', 'newspack-blocks' ) }
|
|
339
345
|
checked={ showAuthor }
|
|
@@ -388,6 +394,7 @@ class Edit extends Component {
|
|
|
388
394
|
</figure>
|
|
389
395
|
{ ( post.newspack_post_sponsors ||
|
|
390
396
|
showCategory ||
|
|
397
|
+
( showTagLabels && post.newspack_tag_labels ) ||
|
|
391
398
|
showTitle ||
|
|
392
399
|
showAuthor ||
|
|
393
400
|
showDate ||
|
|
@@ -405,6 +412,21 @@ class Edit extends Component {
|
|
|
405
412
|
) }
|
|
406
413
|
</div>
|
|
407
414
|
) }
|
|
415
|
+
{ showTagLabels && post.newspack_tag_labels && (
|
|
416
|
+
<div className="cat-links tag-labels">
|
|
417
|
+
{ post.newspack_tag_labels.map( ( newspack_tag_label, index ) => {
|
|
418
|
+
return newspack_tag_label.link ? (
|
|
419
|
+
<a key={ index } href="#" className="tag-label flag">
|
|
420
|
+
{ newspack_tag_label.flag }
|
|
421
|
+
</a>
|
|
422
|
+
) : (
|
|
423
|
+
<span key={ index } className="tag-label flag">
|
|
424
|
+
{ newspack_tag_label.flag }
|
|
425
|
+
</span>
|
|
426
|
+
);
|
|
427
|
+
} ) }
|
|
428
|
+
</div>
|
|
429
|
+
) }
|
|
408
430
|
{ showTitle && (
|
|
409
431
|
<h3 className="entry-title">
|
|
410
432
|
<a href="#">{ decodeEntities( post.title.rendered.trim() ) }</a>
|
|
@@ -66,6 +66,10 @@ function newspack_blocks_render_block_carousel( $attributes ) {
|
|
|
66
66
|
// Get sponsors for this post.
|
|
67
67
|
$sponsors = Newspack_Blocks::get_all_sponsors( $post_id );
|
|
68
68
|
|
|
69
|
+
// Get tag labels for this post, but only when the block is set to show them
|
|
70
|
+
// (avoids a per-post taxonomy lookup when tag labels are disabled).
|
|
71
|
+
$tag_labels = ( $attributes['showTagLabels'] ?? true ) ? Newspack_Blocks::get_tag_labels( $post_id ) : null;
|
|
72
|
+
|
|
69
73
|
$counter++;
|
|
70
74
|
$has_featured_image = has_post_thumbnail();
|
|
71
75
|
$post_type = get_post_type();
|
|
@@ -110,7 +114,7 @@ function newspack_blocks_render_block_carousel( $attributes ) {
|
|
|
110
114
|
<?php endif; ?>
|
|
111
115
|
</figure>
|
|
112
116
|
|
|
113
|
-
<?php if ( ! empty( $sponsors ) || $attributes['showCategory'] || $attributes['showTitle'] || $show_author || $show_date || $show_caption || $show_credit ) : ?>
|
|
117
|
+
<?php if ( ! empty( $sponsors ) || $attributes['showCategory'] || ! empty( $tag_labels ) || $attributes['showTitle'] || $show_author || $show_date || $show_caption || $show_credit ) : ?>
|
|
114
118
|
<div class="entry-wrapper">
|
|
115
119
|
<?php if ( ! empty( $sponsors ) || $attributes['showCategory'] ) : ?>
|
|
116
120
|
<div class="cat-links <?php if ( ! empty( $sponsors ) ) : ?>sponsor-label<?php endif; // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?>">
|
|
@@ -129,6 +133,10 @@ function newspack_blocks_render_block_carousel( $attributes ) {
|
|
|
129
133
|
<?php
|
|
130
134
|
endif;
|
|
131
135
|
|
|
136
|
+
if ( ! empty( $tag_labels ) ) {
|
|
137
|
+
Newspack_Blocks::display_tag_labels( $tag_labels );
|
|
138
|
+
}
|
|
139
|
+
|
|
132
140
|
if ( $attributes['showTitle'] ) {
|
|
133
141
|
the_title( '<h3 class="entry-title"><a href="' . esc_url( $post_link ) . '" rel="bookmark">', '</a></h3>' );
|
|
134
142
|
}
|
|
@@ -382,6 +390,10 @@ function newspack_blocks_register_carousel() {
|
|
|
382
390
|
'type' => 'boolean',
|
|
383
391
|
'default' => false,
|
|
384
392
|
),
|
|
393
|
+
'showTagLabels' => array(
|
|
394
|
+
'type' => 'boolean',
|
|
395
|
+
'default' => true,
|
|
396
|
+
),
|
|
385
397
|
'showDate' => array(
|
|
386
398
|
'type' => 'boolean',
|
|
387
399
|
'default' => true,
|
|
@@ -40,18 +40,28 @@ import RedirectAfterSuccess from '../../../components/redirect-after-success';
|
|
|
40
40
|
|
|
41
41
|
const TIER_LABELS = [ __( 'Low-tier', 'newspack-blocks' ), __( 'Mid-tier', 'newspack-blocks' ), __( 'High-tier', 'newspack-blocks' ) ];
|
|
42
42
|
|
|
43
|
+
// Placeholders for the keys the settings fetch fills in. They are a complete
|
|
44
|
+
// EditState so every read is defined even if the fetch fails or returns a
|
|
45
|
+
// partial payload; the loading and error guards below mean they never reach
|
|
46
|
+
// the rendered output.
|
|
47
|
+
const INITIAL_SETTINGS: EditState = {
|
|
48
|
+
amounts: {
|
|
49
|
+
once: [ 0, 0, 0, 0 ],
|
|
50
|
+
month: [ 0, 0, 0, 0 ],
|
|
51
|
+
year: [ 0, 0, 0, 0 ],
|
|
52
|
+
},
|
|
53
|
+
currencySymbol: '$',
|
|
54
|
+
tiered: false,
|
|
55
|
+
disabledFrequencies: { once: false, month: false, year: false },
|
|
56
|
+
minimumDonation: 5,
|
|
57
|
+
platform: '',
|
|
58
|
+
};
|
|
59
|
+
|
|
43
60
|
const Edit = ( { attributes, setAttributes }: EditProps ) => {
|
|
44
61
|
const [ isLoading, setIsLoading ] = useState( true );
|
|
45
62
|
const [ error, setError ] = useState( '' );
|
|
46
63
|
|
|
47
|
-
const [ settings, setSettings ] = hooks.useObjectState< EditState >(
|
|
48
|
-
amounts: {},
|
|
49
|
-
currencySymbol: '$',
|
|
50
|
-
tiered: false,
|
|
51
|
-
disabledFrequencies: {},
|
|
52
|
-
minimumDonation: 5,
|
|
53
|
-
platform: '',
|
|
54
|
-
} );
|
|
64
|
+
const [ settings, setSettings ] = hooks.useObjectState< EditState >( INITIAL_SETTINGS );
|
|
55
65
|
|
|
56
66
|
interface AudienceDonations {
|
|
57
67
|
donation_data: DonationSettings;
|
|
@@ -95,7 +105,9 @@ const Edit = ( { attributes, setAttributes }: EditProps ) => {
|
|
|
95
105
|
setAttributes( { amounts: { ...donationSettings.amounts, ...attributes.amounts } } );
|
|
96
106
|
}
|
|
97
107
|
} )
|
|
98
|
-
|
|
108
|
+
// apiFetch rejects with the REST error object, not a string — take its
|
|
109
|
+
// message so the error Placeholder below actually renders.
|
|
110
|
+
.catch( ( e: { message?: string } ) => setError( e?.message || __( 'Could not fetch the donation settings.', 'newspack-blocks' ) ) )
|
|
99
111
|
.finally( () => setIsLoading( false ) );
|
|
100
112
|
}, [] );
|
|
101
113
|
|
|
@@ -187,7 +199,7 @@ const Edit = ( { attributes, setAttributes }: EditProps ) => {
|
|
|
187
199
|
|
|
188
200
|
const minimumDonation = isManual ? attributes.minimumDonation : settings.minimumDonation;
|
|
189
201
|
const displayedAmounts = { ...amounts };
|
|
190
|
-
Object.keys( amounts ).forEach( frequency => {
|
|
202
|
+
( Object.keys( amounts ) as DonationFrequencySlug[] ).forEach( frequency => {
|
|
191
203
|
const amountsWithMinimum = amounts[ frequency ].map( amount => Math.max( amount, minimumDonation ) ) as DonationAmountsArray;
|
|
192
204
|
displayedAmounts[ frequency ] = amountsWithMinimum;
|
|
193
205
|
} );
|
|
@@ -433,8 +445,8 @@ const Edit = ( { attributes, setAttributes }: EditProps ) => {
|
|
|
433
445
|
<FrequencyBasedLayout
|
|
434
446
|
isTiered={ isTiered }
|
|
435
447
|
canUseNameYourPrice={ canUseNameYourPrice }
|
|
436
|
-
amounts={ displayedAmounts }
|
|
437
448
|
{ ...componentProps }
|
|
449
|
+
amounts={ displayedAmounts }
|
|
438
450
|
/>
|
|
439
451
|
</div>
|
|
440
452
|
) }
|
|
@@ -223,17 +223,36 @@ class WP_REST_Newspack_Articles_Controller extends WP_REST_Controller {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
|
-
* Restrict a list of post types to those
|
|
226
|
+
* Restrict a list of post types to those the public articles endpoint may serve:
|
|
227
|
+
* publicly-viewable types, plus any explicitly allow-listed via the
|
|
228
|
+
* `newspack_blocks_articles_allowed_post_types` filter.
|
|
227
229
|
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* the returned list may be empty when none
|
|
230
|
+
* Keeps the endpoint from exposing post types WordPress would not surface on the
|
|
231
|
+
* front end, while letting a plugin deliberately opt a specific non-viewable CPT
|
|
232
|
+
* in. Disallowed types are dropped; the returned list may be empty when none
|
|
233
|
+
* qualify (the caller then returns no results).
|
|
231
234
|
*
|
|
232
235
|
* @param array|string $post_types Requested post type(s).
|
|
233
|
-
* @return array
|
|
236
|
+
* @return array Allowed post types (may be empty).
|
|
234
237
|
*/
|
|
235
238
|
private static function filter_viewable_post_types( $post_types ) {
|
|
236
|
-
|
|
239
|
+
/**
|
|
240
|
+
* Post types the public articles endpoint may serve in addition to the
|
|
241
|
+
* publicly-viewable ones. Each entry is an explicit, per-CPT decision to
|
|
242
|
+
* expose that type's published posts to unauthenticated callers — do not
|
|
243
|
+
* add types whose published content should stay off the public REST surface.
|
|
244
|
+
*
|
|
245
|
+
* @param string[] $allowed Post type slugs to allow. Default empty.
|
|
246
|
+
*/
|
|
247
|
+
$allowed = (array) apply_filters( 'newspack_blocks_articles_allowed_post_types', [] );
|
|
248
|
+
return array_values(
|
|
249
|
+
array_filter(
|
|
250
|
+
(array) $post_types,
|
|
251
|
+
function ( $type ) use ( $allowed ) {
|
|
252
|
+
return is_post_type_viewable( $type ) || in_array( $type, $allowed, true );
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
);
|
|
237
256
|
}
|
|
238
257
|
|
|
239
258
|
/**
|
|
@@ -747,6 +747,11 @@ const EditWithBlockProps = ( props: any ) => {
|
|
|
747
747
|
return <Edit { ...props } blockProps={ blockProps } />;
|
|
748
748
|
};
|
|
749
749
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
750
|
+
// withSelect/withDispatch type their map functions against the registry's own
|
|
751
|
+
// loose signatures; the casts stay at this call site so the exported selector
|
|
752
|
+
// and dispatcher keep their precise parameter types.
|
|
753
|
+
export default compose( [
|
|
754
|
+
withColors( { textColor: 'color' } ),
|
|
755
|
+
withSelect( postsBlockSelector as any ),
|
|
756
|
+
withDispatch( postsBlockDispatch as any ),
|
|
757
|
+
] as any )( EditWithBlockProps );
|
|
@@ -7,7 +7,6 @@ import { times, isEqual, isNull, isUndefined, pick, pickBy } from 'lodash';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { dispatch as wpDataDispatch } from '@wordpress/data';
|
|
11
10
|
|
|
12
11
|
import { STORE_NAMESPACE } from './store';
|
|
13
12
|
|
|
@@ -244,13 +243,17 @@ export const postsBlockSelector = (
|
|
|
244
243
|
return props;
|
|
245
244
|
};
|
|
246
245
|
|
|
246
|
+
// STORE_NAMESPACE - TODO: move this to src/blocks/homepage-articles/store.js once it's TS.
|
|
247
|
+
type Dispatch = ( namespace: string ) => {
|
|
248
|
+
reflow: () => void;
|
|
249
|
+
};
|
|
250
|
+
|
|
247
251
|
/**
|
|
248
252
|
* wordpress/data dispatch for blocks using this custom store.
|
|
249
253
|
*/
|
|
250
|
-
export const postsBlockDispatch = ( dispatch:
|
|
254
|
+
export const postsBlockDispatch = ( dispatch: Dispatch, { isEditorBlock }: { isEditorBlock: boolean } ) => {
|
|
251
255
|
return {
|
|
252
256
|
// Only editor blocks can trigger reflows.
|
|
253
|
-
// @ts-expect-error It's a string.
|
|
254
257
|
triggerReflow: isEditorBlock ? dispatch( STORE_NAMESPACE ).reflow : () => undefined,
|
|
255
258
|
};
|
|
256
259
|
};
|
package/src/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
'name' => 'automattic/newspack-blocks',
|
|
4
4
|
'pretty_version' => 'dev-main',
|
|
5
5
|
'version' => 'dev-main',
|
|
6
|
-
'reference' => '
|
|
6
|
+
'reference' => 'b5d11514be96c60bb2b4698b38f8f5f35940fb84',
|
|
7
7
|
'type' => 'wordpress-plugin',
|
|
8
8
|
'install_path' => __DIR__ . '/../../',
|
|
9
9
|
'aliases' => array(),
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
'automattic/newspack-blocks' => array(
|
|
14
14
|
'pretty_version' => 'dev-main',
|
|
15
15
|
'version' => 'dev-main',
|
|
16
|
-
'reference' => '
|
|
16
|
+
'reference' => 'b5d11514be96c60bb2b4698b38f8f5f35940fb84',
|
|
17
17
|
'type' => 'wordpress-plugin',
|
|
18
18
|
'install_path' => __DIR__ . '/../../',
|
|
19
19
|
'aliases' => array(),
|