@automattic/newspack-blocks 1.53.0 → 1.54.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 (97) hide show
  1. package/.cache/babel/1783de595f21d427355e559781275222.json.gz +0 -0
  2. package/.cache/babel/2a75259638488d555bb07fb4f54ddde6.json.gz +0 -0
  3. package/.cache/babel/{64cb5afd808420a679c0d56e7bdb7949.json.gz → 2dfe70bf8fa9218857f45826e2386a32.json.gz} +0 -0
  4. package/.cache/babel/2ef414e63685642b486b71a962a5cc09.json.gz +0 -0
  5. package/.cache/babel/5a94cdb1154d1770a8b0e8cd3145825b.json.gz +0 -0
  6. package/.cache/babel/678cc0f373236434bf692c16d26ba22f.json.gz +0 -0
  7. package/.cache/babel/71371fcf9db60a3a1e024991cb3b4bf3.json.gz +0 -0
  8. package/.cache/babel/725e695c6992a4d01573b83867255ea9.json.gz +0 -0
  9. package/.cache/babel/94ee8f45c55ecf01005a435ab588333b.json.gz +0 -0
  10. package/.cache/babel/a5759fe1915229088160b7f5eb8a2e75.json.gz +0 -0
  11. package/.cache/babel/{bdebf548c146fe858685d50dd0ebd031.json.gz → be383af4530fd3521ee3db177be1bbf4.json.gz} +0 -0
  12. package/.cache/babel/d298f58c94d221b643c4c009ea0d8002.json.gz +0 -0
  13. package/.cache/babel/dc7e2d653dbbdbd1939aa281435afa5d.json.gz +0 -0
  14. package/.cache/babel/f50f27ba4b367318e30e91dbe003e5c8.json.gz +0 -0
  15. package/CHANGELOG.md +35 -0
  16. package/dist/author-profile/view.asset.php +1 -1
  17. package/dist/author-profile/view.css +1 -1
  18. package/dist/author-profile/view.rtl.css +1 -1
  19. package/dist/carousel/view.asset.php +1 -1
  20. package/dist/carousel/view.css +1 -1
  21. package/dist/carousel/view.js +1 -1
  22. package/dist/carousel/view.rtl.css +1 -1
  23. package/dist/donate/view.asset.php +1 -1
  24. package/dist/donate/view.css +1 -1
  25. package/dist/donate/view.rtl.css +1 -1
  26. package/dist/donateStreamlined.asset.php +1 -1
  27. package/dist/donateStreamlined.js +1 -1
  28. package/dist/editor.asset.php +1 -1
  29. package/dist/editor.css +1 -1
  30. package/dist/editor.js +5 -5
  31. package/dist/editor.rtl.css +1 -1
  32. package/dist/homepage-articles/view.asset.php +1 -1
  33. package/dist/homepage-articles/view.css +1 -1
  34. package/dist/homepage-articles/view.rtl.css +1 -1
  35. package/dist/placeholder_blocks.asset.php +1 -0
  36. package/dist/placeholder_blocks.js +1 -0
  37. package/includes/class-newspack-blocks-api.php +14 -12
  38. package/includes/class-newspack-blocks-patterns.php +3 -2
  39. package/includes/class-newspack-blocks.php +64 -1
  40. package/newspack-blocks.php +3 -2
  41. package/package.json +17 -16
  42. package/src/block-patterns/homepage-posts-14.php +1 -1
  43. package/src/block-patterns/homepage-posts-2.php +1 -1
  44. package/src/block-patterns/homepage-posts-26.php +1 -1
  45. package/src/block-patterns/homepage-posts-31.php +13 -0
  46. package/src/block-patterns/homepage-posts-7.php +1 -1
  47. package/src/block-styles/core/columns/editor.scss +10 -10
  48. package/src/block-styles/core/columns/view.scss +8 -8
  49. package/src/block-styles/core/group/editor.scss +3 -3
  50. package/src/block-styles/core/group/view.scss +3 -3
  51. package/src/blocks/author-list/editor.scss +1 -1
  52. package/src/blocks/author-profile/edit.js +29 -6
  53. package/src/blocks/author-profile/editor.scss +4 -3
  54. package/src/blocks/author-profile/view.scss +9 -9
  55. package/src/blocks/carousel/edit.js +31 -15
  56. package/src/blocks/carousel/editor.scss +1 -1
  57. package/src/blocks/carousel/view.php +94 -87
  58. package/src/blocks/carousel/view.scss +52 -13
  59. package/src/blocks/donate/block.json +49 -0
  60. package/src/blocks/donate/edit.tsx +569 -0
  61. package/src/blocks/donate/editor.scss +68 -8
  62. package/src/blocks/donate/index.js +8 -41
  63. package/src/blocks/donate/streamlined/style.scss +17 -17
  64. package/src/blocks/donate/view.php +226 -174
  65. package/src/blocks/donate/view.scss +97 -114
  66. package/src/blocks/homepage-articles/edit.js +28 -22
  67. package/src/blocks/homepage-articles/editor.scss +5 -5
  68. package/src/blocks/homepage-articles/templates/article.php +78 -73
  69. package/src/blocks/homepage-articles/utils.ts +1 -3
  70. package/src/blocks/homepage-articles/view.scss +68 -40
  71. package/src/blocks/iframe/edit.js +18 -14
  72. package/src/blocks/iframe/editor.scss +3 -3
  73. package/src/blocks/video-playlist/editor.scss +2 -2
  74. package/src/setup/editor.scss +46 -4
  75. package/src/setup/placeholder-blocks.js +83 -0
  76. package/src/shared/sass/_mixins.scss +7 -5
  77. package/src/types/@wordpress/block-editor.d.ts +1 -0
  78. package/src/types/@wordpress/components.d.ts +1 -0
  79. package/src/types/{index.ts → index.d.ts} +5 -1
  80. package/src/types/newspack-components.d.ts +7 -0
  81. package/vendor/autoload.php +1 -1
  82. package/vendor/composer/autoload_real.php +4 -4
  83. package/vendor/composer/autoload_static.php +2 -2
  84. package/vendor/composer/installed.php +2 -2
  85. package/webpack.config.js +4 -0
  86. package/.cache/babel/07169c73863508b392f15022920bd0b6.json.gz +0 -0
  87. package/.cache/babel/10faf7c74a89e9aa4d8b9528a654913e.json.gz +0 -0
  88. package/.cache/babel/3fc03f1e35bc1fde55a903cf25d74d3d.json.gz +0 -0
  89. package/.cache/babel/553094e2be86910f765ad110c8da1ba1.json.gz +0 -0
  90. package/.cache/babel/55dd64fbb5126117016b9edff26ca5ee.json.gz +0 -0
  91. package/.cache/babel/7cbfe1b298fdc2a21add34363b2a6046.json.gz +0 -0
  92. package/.cache/babel/95c79f7af2e88cb1c48e88f304b1a1fd.json.gz +0 -0
  93. package/.cache/babel/ac3be6086bb961d3a94ba6ba7728901c.json.gz +0 -0
  94. package/.cache/babel/c9354785521531ea2b4a9a8c2f526abf.json.gz +0 -0
  95. package/.cache/babel/ca34d0586d4fbcd06c357ff72bda9a19.json.gz +0 -0
  96. package/.cache/babel/edb4dcd474dbafd6ea1655b24469e261.json.gz +0 -0
  97. package/src/blocks/donate/edit.js +0 -587
@@ -0,0 +1,83 @@
1
+ /**
2
+ * WordPress dependencies.
3
+ */
4
+ import { __, sprintf } from '@wordpress/i18n';
5
+ import { useBlockProps } from '@wordpress/block-editor';
6
+ import { getBlockType, registerBlockType } from '@wordpress/blocks';
7
+ import { Button } from '@wordpress/components';
8
+ import { withDispatch } from '@wordpress/data';
9
+ import { Icon, pullquote } from '@wordpress/icons';
10
+
11
+ const placeholderBlocks = {
12
+ 'newspack-ads/ad-unit': {
13
+ title: __( 'Ad Unit', 'newspack-blocks' ),
14
+ description: __( 'Render an ad unit from your inventory.', 'newspack-blocks' ),
15
+ icon: pullquote,
16
+ message: __( 'Place ad units inside your page by installing Newspack Ads.', 'newspack-blocks' ),
17
+ url: 'https://newspack.pub/support/advertising/',
18
+ },
19
+ };
20
+
21
+ function registerPlaceholderBlock( blockName, { title, description, icon, message, url } ) {
22
+ if ( getBlockType( blockName ) ) {
23
+ return;
24
+ }
25
+ title = title || blockName.split( '/' ).pop();
26
+ const edit = ( { clientId, removeBlocks } ) => {
27
+ const blockProps = useBlockProps(); // eslint-disable-line
28
+ return (
29
+ <div { ...blockProps }>
30
+ <div className="newspack-blocks-placeholder-block">
31
+ <div className="newspack-blocks-placeholder-block__label">
32
+ { icon && <Icon icon={ icon } /> }
33
+ { title }
34
+ </div>
35
+ <p>
36
+ <strong>
37
+ { sprintf(
38
+ // translators: %s is the block name.
39
+ __( 'The "%s" block is currently not available.', 'newspack-blocks' ),
40
+ title
41
+ ) }
42
+ </strong>
43
+ </p>
44
+ { message && <p>{ message }</p> }
45
+ <div className="newspack-blocks-placeholder-block__buttons">
46
+ { url && (
47
+ <Button variant="primary" target="_blank" rel="external" href={ url }>
48
+ { __( 'Visit Plugin Page', 'newspack-blocks' ) }
49
+ </Button>
50
+ ) }
51
+ <Button variant="secondary" isDestructive onClick={ () => removeBlocks( clientId ) }>
52
+ { __( 'Remove Block', 'newspack-blocks' ) }
53
+ </Button>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ );
58
+ };
59
+ registerBlockType( blockName, {
60
+ title,
61
+ description,
62
+ icon,
63
+ edit: withDispatch( dispatch => ( {
64
+ removeBlocks: dispatch( 'core/block-editor' ).removeBlocks,
65
+ } ) )( edit ),
66
+ supports: {
67
+ html: false,
68
+ lock: false,
69
+ reusable: false,
70
+ inserter: false,
71
+ defaultStylePicker: false,
72
+ customClassName: false,
73
+ className: false,
74
+ alignWide: false,
75
+ align: false,
76
+ anchor: false,
77
+ },
78
+ } );
79
+ }
80
+
81
+ for ( const blockName in placeholderBlocks ) {
82
+ registerPlaceholderBlock( blockName, placeholderBlocks[ blockName ] );
83
+ }
@@ -1,30 +1,32 @@
1
+ @use './variables';
2
+
1
3
  @mixin media( $res ) {
2
4
  @if mobile == $res {
3
- @media only screen and ( min-width: $mobile_width ) {
5
+ @media only screen and ( min-width: variables.$mobile_width ) {
4
6
  @content;
5
7
  }
6
8
  }
7
9
 
8
10
  @if tabletonly == $res {
9
- @media only screen and ( max-width: #{ $tablet_width - 1 } ) {
11
+ @media only screen and ( max-width: #{ variables.$tablet_width - 1 } ) {
10
12
  @content;
11
13
  }
12
14
  }
13
15
 
14
16
  @if tablet == $res {
15
- @media only screen and ( min-width: $tablet_width ) {
17
+ @media only screen and ( min-width: variables.$tablet_width ) {
16
18
  @content;
17
19
  }
18
20
  }
19
21
 
20
22
  @if desktop == $res {
21
- @media only screen and ( min-width: $desktop_width ) {
23
+ @media only screen and ( min-width: variables.$desktop_width ) {
22
24
  @content;
23
25
  }
24
26
  }
25
27
 
26
28
  @if wide == $res {
27
- @media only screen and ( min-width: $wide_width ) {
29
+ @media only screen and ( min-width: variables.$wide_width ) {
28
30
  @content;
29
31
  }
30
32
  }
@@ -0,0 +1 @@
1
+ declare module '@wordpress/block-editor'
@@ -0,0 +1 @@
1
+ declare module '@wordpress/components'
@@ -3,7 +3,11 @@ declare global {
3
3
  wpcomGutenberg: {
4
4
  blogPublic: string;
5
5
  };
6
- newspack_blocks_data: { assets_path: string };
6
+ newspack_blocks_data: {
7
+ assets_path: string;
8
+ is_rendering_streamlined_block?: boolean;
9
+ streamlined_block_stripe_badge?: string;
10
+ };
7
11
  }
8
12
 
9
13
  type PostId = number;
@@ -0,0 +1,7 @@
1
+ declare module 'newspack-components' {
2
+ function useObjectState<StateObject>(
3
+ object: StateObject
4
+ ): [object: StateObject, (object: Partial<StateObject>) => void];
5
+ const hooks = { useObjectState };
6
+ export { hooks };
7
+ }
@@ -4,4 +4,4 @@
4
4
 
5
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
6
 
7
- return ComposerAutoloaderInit23e7353bf7a8e11d2c7c2cc21cce61d6::getLoader();
7
+ return ComposerAutoloaderInit49fbd6ec7deee2cfafc0623f87888fe4::getLoader();
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInit23e7353bf7a8e11d2c7c2cc21cce61d6
5
+ class ComposerAutoloaderInit49fbd6ec7deee2cfafc0623f87888fe4
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -22,15 +22,15 @@ class ComposerAutoloaderInit23e7353bf7a8e11d2c7c2cc21cce61d6
22
22
  return self::$loader;
23
23
  }
24
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInit23e7353bf7a8e11d2c7c2cc21cce61d6', 'loadClassLoader'), true, true);
25
+ spl_autoload_register(array('ComposerAutoloaderInit49fbd6ec7deee2cfafc0623f87888fe4', 'loadClassLoader'), true, true);
26
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
27
- spl_autoload_unregister(array('ComposerAutoloaderInit23e7353bf7a8e11d2c7c2cc21cce61d6', 'loadClassLoader'));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInit49fbd6ec7deee2cfafc0623f87888fe4', 'loadClassLoader'));
28
28
 
29
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
30
  if ($useStaticLoader) {
31
31
  require __DIR__ . '/autoload_static.php';
32
32
 
33
- call_user_func(\Composer\Autoload\ComposerStaticInit23e7353bf7a8e11d2c7c2cc21cce61d6::getInitializer($loader));
33
+ call_user_func(\Composer\Autoload\ComposerStaticInit49fbd6ec7deee2cfafc0623f87888fe4::getInitializer($loader));
34
34
  } else {
35
35
  $map = require __DIR__ . '/autoload_namespaces.php';
36
36
  foreach ($map as $namespace => $path) {
@@ -4,7 +4,7 @@
4
4
 
5
5
  namespace Composer\Autoload;
6
6
 
7
- class ComposerStaticInit23e7353bf7a8e11d2c7c2cc21cce61d6
7
+ class ComposerStaticInit49fbd6ec7deee2cfafc0623f87888fe4
8
8
  {
9
9
  public static $classMap = array (
10
10
  'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -13,7 +13,7 @@ class ComposerStaticInit23e7353bf7a8e11d2c7c2cc21cce61d6
13
13
  public static function getInitializer(ClassLoader $loader)
14
14
  {
15
15
  return \Closure::bind(function () use ($loader) {
16
- $loader->classMap = ComposerStaticInit23e7353bf7a8e11d2c7c2cc21cce61d6::$classMap;
16
+ $loader->classMap = ComposerStaticInit49fbd6ec7deee2cfafc0623f87888fe4::$classMap;
17
17
 
18
18
  }, null, ClassLoader::class);
19
19
  }
@@ -5,7 +5,7 @@
5
5
  'type' => 'wordpress-plugin',
6
6
  'install_path' => __DIR__ . '/../../',
7
7
  'aliases' => array(),
8
- 'reference' => 'f7f4a31da32051a3cdbb44ab64515f863368e08b',
8
+ 'reference' => 'd0c5ef37143589ab35d9926bda95d6de2e196b63',
9
9
  'name' => 'automattic/newspack-blocks',
10
10
  'dev' => false,
11
11
  ),
@@ -16,7 +16,7 @@
16
16
  'type' => 'wordpress-plugin',
17
17
  'install_path' => __DIR__ . '/../../',
18
18
  'aliases' => array(),
19
- 'reference' => 'f7f4a31da32051a3cdbb44ab64515f863368e08b',
19
+ 'reference' => 'd0c5ef37143589ab35d9926bda95d6de2e196b63',
20
20
  'dev_requirement' => false,
21
21
  ),
22
22
  ),
package/webpack.config.js CHANGED
@@ -2,6 +2,7 @@
2
2
  **** WARNING: No ES6 modules here. Not transpiled! ****
3
3
  */
4
4
  /* eslint-disable import/no-nodejs-modules */
5
+ /* eslint-disable @typescript-eslint/no-var-requires */
5
6
 
6
7
  /**
7
8
  * External dependencies
@@ -45,12 +46,15 @@ const editorScript = [
45
46
  ...blockScripts( 'editor', path.join( __dirname, 'src' ), blocks ),
46
47
  ];
47
48
 
49
+ const placeholderBlocksScript = path.join( __dirname, 'src', 'setup', 'placeholder-blocks' );
50
+
48
51
  const blockStylesScript = [ path.join( __dirname, 'src', 'block-styles', 'view' ) ];
49
52
 
50
53
  const webpackConfig = getBaseWebpackConfig(
51
54
  { WP: true },
52
55
  {
53
56
  entry: {
57
+ placeholder_blocks: placeholderBlocksScript,
54
58
  editor: editorScript,
55
59
  block_styles: blockStylesScript,
56
60
  donateStreamlined: path.join( __dirname, 'src/blocks/donate/streamlined' ),