Editor: Update the WordPress packages to the Gutenberg 16.7 RC2 version.

This patch, somewhat small brings a lot to WordPress. 
This includes features like:

 - DataViews.
 - Customization tools like box shadow, background size and repeat.
 - UI improvements in the site editor. 
 - Preferences sharing between the post and site editors.
 - Unified panels and editors between post and site editors.
 - Improved template mode in the post editor.
 - Iterations to multiple interactive blocks.
 - Preparing the blocks and UI for pattern overrides.
 - and a lot more.

Props luisherranz, gziolo, isabel_brison, costdev, jonsurrell, peterwilsoncc, get_dave, antonvlasenko, desrosj.
See #60315.

git-svn-id: https://develop.svn.wordpress.org/trunk@57377 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Riad Benguella 2024-01-29 21:04:18 +00:00
parent 393f67387f
commit cf8b74de16
75 changed files with 4946 additions and 5125 deletions

View File

@ -1566,7 +1566,9 @@ module.exports = function(grunt) {
*/
grunt.registerTask( 'verify:source-maps', function() {
const ignoredFiles = [
'build/wp-includes/js/dist/components.js'
'build/wp-includes/js/dist/components.js',
'build/wp-includes/js/dist/block-editor.js',
'build/wp-includes/js/dist/block-editor.min.js'
];
const files = buildFiles.reduce( ( acc, path ) => {
// Skip excluded paths and any path that isn't a file.

6999
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,12 +27,12 @@
"@lodder/grunt-postcss": "^3.1.1",
"@playwright/test": "1.32.0",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.5",
"@wordpress/babel-preset-default": "7.26.13",
"@wordpress/dependency-extraction-webpack-plugin": "4.25.13",
"@wordpress/e2e-test-utils": "10.13.13",
"@wordpress/e2e-test-utils-playwright": "0.10.13",
"@wordpress/prettier-config": "2.25.13",
"@wordpress/scripts": "26.13.13",
"@wordpress/babel-preset-default": "7.34.0",
"@wordpress/dependency-extraction-webpack-plugin": "5.1.0",
"@wordpress/e2e-test-utils": "10.21.0",
"@wordpress/e2e-test-utils-playwright": "0.18.0",
"@wordpress/prettier-config": "3.7.0",
"@wordpress/scripts": "27.1.0",
"autoprefixer": "10.4.16",
"chalk": "5.3.0",
"check-node-version": "4.2.1",
@ -80,70 +80,72 @@
"dependencies": {
"@emotion/is-prop-valid": "0.8.8",
"@emotion/memoize": "0.7.4",
"@wordpress/a11y": "3.42.13",
"@wordpress/annotations": "2.42.13",
"@wordpress/api-fetch": "6.39.13",
"@wordpress/autop": "3.42.13",
"@wordpress/blob": "3.42.13",
"@wordpress/block-directory": "4.19.16",
"@wordpress/block-editor": "12.10.14",
"@wordpress/block-library": "8.19.16",
"@wordpress/block-serialization-default-parser": "4.42.13",
"@wordpress/blocks": "12.19.13",
"@wordpress/commands": "0.13.14",
"@wordpress/components": "25.8.14",
"@wordpress/compose": "6.19.13",
"@wordpress/core-commands": "0.11.14",
"@wordpress/core-data": "6.19.14",
"@wordpress/customize-widgets": "4.19.16",
"@wordpress/data": "9.12.13",
"@wordpress/data-controls": "3.11.13",
"@wordpress/date": "4.42.13",
"@wordpress/deprecated": "3.42.13",
"@wordpress/dom": "3.42.13",
"@wordpress/dom-ready": "3.42.13",
"@wordpress/edit-post": "7.19.16",
"@wordpress/edit-site": "5.19.16",
"@wordpress/edit-widgets": "5.19.16",
"@wordpress/editor": "13.19.14",
"@wordpress/element": "5.19.13",
"@wordpress/escape-html": "2.42.13",
"@wordpress/format-library": "4.19.14",
"@wordpress/hooks": "3.42.13",
"@wordpress/html-entities": "3.42.13",
"@wordpress/i18n": "4.42.13",
"@wordpress/icons": "9.33.13",
"@wordpress/interactivity": "2.3.13",
"@wordpress/interface": "5.19.14",
"@wordpress/is-shallow-equal": "4.42.13",
"@wordpress/keyboard-shortcuts": "4.19.13",
"@wordpress/keycodes": "3.42.13",
"@wordpress/list-reusable-blocks": "4.19.14",
"@wordpress/media-utils": "4.33.13",
"@wordpress/notices": "4.10.13",
"@wordpress/nux": "8.4.14",
"@wordpress/patterns": "1.3.14",
"@wordpress/plugins": "6.10.14",
"@wordpress/preferences": "3.19.14",
"@wordpress/preferences-persistence": "1.34.13",
"@wordpress/primitives": "3.40.13",
"@wordpress/priority-queue": "2.42.13",
"@wordpress/private-apis": "0.24.13",
"@wordpress/redux-routine": "4.42.13",
"@wordpress/reusable-blocks": "4.19.14",
"@wordpress/rich-text": "6.19.13",
"@wordpress/router": "0.11.13",
"@wordpress/server-side-render": "4.19.14",
"@wordpress/shortcode": "3.42.13",
"@wordpress/style-engine": "1.25.13",
"@wordpress/sync": "0.4.13",
"@wordpress/token-list": "2.42.13",
"@wordpress/undo-manager": "0.2.13",
"@wordpress/url": "3.43.13",
"@wordpress/viewport": "5.19.13",
"@wordpress/warning": "2.42.13",
"@wordpress/widgets": "3.19.14",
"@wordpress/wordcount": "3.42.13",
"@wordpress/a11y": "3.50.0",
"@wordpress/annotations": "2.50.0",
"@wordpress/api-fetch": "6.47.0",
"@wordpress/autop": "3.50.0",
"@wordpress/blob": "3.50.0",
"@wordpress/block-directory": "4.27.1",
"@wordpress/block-editor": "12.18.1",
"@wordpress/block-library": "8.27.1",
"@wordpress/block-serialization-default-parser": "4.50.0",
"@wordpress/blocks": "12.27.1",
"@wordpress/commands": "0.21.0",
"@wordpress/components": "25.16.0",
"@wordpress/compose": "6.27.0",
"@wordpress/core-commands": "0.19.1",
"@wordpress/core-data": "6.27.1",
"@wordpress/customize-widgets": "4.27.1",
"@wordpress/data": "9.20.0",
"@wordpress/data-controls": "3.19.0",
"@wordpress/dataviews": "0.4.0",
"@wordpress/date": "4.50.0",
"@wordpress/deprecated": "3.50.0",
"@wordpress/dom": "3.50.0",
"@wordpress/dom-ready": "3.50.0",
"@wordpress/edit-post": "7.27.1",
"@wordpress/edit-site": "5.27.1",
"@wordpress/edit-widgets": "5.27.1",
"@wordpress/editor": "13.27.1",
"@wordpress/element": "5.27.0",
"@wordpress/escape-html": "2.50.0",
"@wordpress/format-library": "4.27.1",
"@wordpress/hooks": "3.50.0",
"@wordpress/html-entities": "3.50.0",
"@wordpress/i18n": "4.50.0",
"@wordpress/icons": "9.41.0",
"@wordpress/interactivity": "4.0.0",
"@wordpress/interactivity-router": "1.0.0",
"@wordpress/interface": "5.27.0",
"@wordpress/is-shallow-equal": "4.50.0",
"@wordpress/keyboard-shortcuts": "4.27.0",
"@wordpress/keycodes": "3.50.0",
"@wordpress/list-reusable-blocks": "4.27.0",
"@wordpress/media-utils": "4.41.0",
"@wordpress/notices": "4.18.0",
"@wordpress/nux": "8.12.0",
"@wordpress/patterns": "1.11.1",
"@wordpress/plugins": "6.18.0",
"@wordpress/preferences": "3.27.0",
"@wordpress/preferences-persistence": "1.42.0",
"@wordpress/primitives": "3.48.0",
"@wordpress/priority-queue": "2.50.0",
"@wordpress/private-apis": "0.32.0",
"@wordpress/redux-routine": "4.50.0",
"@wordpress/reusable-blocks": "4.27.1",
"@wordpress/rich-text": "6.27.0",
"@wordpress/router": "0.19.0",
"@wordpress/server-side-render": "4.27.1",
"@wordpress/shortcode": "3.50.0",
"@wordpress/style-engine": "1.33.1",
"@wordpress/sync": "0.12.0",
"@wordpress/token-list": "2.50.0",
"@wordpress/undo-manager": "0.10.0",
"@wordpress/url": "3.51.0",
"@wordpress/viewport": "5.27.0",
"@wordpress/warning": "2.50.0",
"@wordpress/widgets": "3.27.1",
"@wordpress/wordcount": "3.50.0",
"backbone": "1.5.0",
"clipboard": "2.0.11",
"core-js-url-browser": "3.6.4",
@ -167,6 +169,7 @@
"polyfill-library": "4.8.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-is": "18.2.0",
"regenerator-runtime": "0.14.0",
"tslib": "2.6.2",
"underscore": "1.13.6",

File diff suppressed because one or more lines are too long

View File

@ -16,8 +16,8 @@
"__experimentalRole": "content"
},
"caption": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "figcaption",
"__experimentalRole": "content"
},

View File

@ -30,7 +30,11 @@
"alignWide": false,
"spacing": {
"margin": true,
"padding": true
"padding": true,
"__experimentalDefaultControls": {
"margin": false,
"padding": false
}
},
"__experimentalBorder": {
"__experimentalSkipSerialization": true,

View File

@ -46,8 +46,28 @@ function render_block_core_block( $attributes ) {
$content = $wp_embed->run_shortcode( $reusable_block->post_content );
$content = $wp_embed->autoembed( $content );
$has_pattern_overrides = isset( $attributes['overrides'] );
/**
* We set the `pattern/overrides` context through the `render_block_context`
* filter so that it is available when a pattern's inner blocks are
* rendering via do_blocks given it only receives the inner content.
*/
if ( $has_pattern_overrides ) {
$filter_block_context = static function ( $context ) use ( $attributes ) {
$context['pattern/overrides'] = $attributes['overrides'];
return $context;
};
add_filter( 'render_block_context', $filter_block_context, 1 );
}
$content = do_blocks( $content );
unset( $seen_refs[ $attributes['ref'] ] );
if ( $has_pattern_overrides ) {
remove_filter( 'render_block_context', $filter_block_context, 1 );
}
return $content;
}

View File

@ -10,11 +10,15 @@
"attributes": {
"ref": {
"type": "number"
},
"overrides": {
"type": "object"
}
},
"supports": {
"customClassName": false,
"html": false,
"inserter": false
"inserter": false,
"renaming": false
}
}

View File

@ -75,8 +75,8 @@
'__experimentalRole' => 'content'
),
'caption' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'figcaption',
'__experimentalRole' => 'content'
),
@ -154,7 +154,11 @@
'alignWide' => false,
'spacing' => array(
'margin' => true,
'padding' => true
'padding' => true,
'__experimentalDefaultControls' => array(
'margin' => false,
'padding' => false
)
),
'__experimentalBorder' => array(
'__experimentalSkipSerialization' => true,
@ -192,12 +196,16 @@
'attributes' => array(
'ref' => array(
'type' => 'number'
),
'overrides' => array(
'type' => 'object'
)
),
'supports' => array(
'customClassName' => false,
'html' => false,
'inserter' => false
'inserter' => false,
'renaming' => false
)
),
'button' => array(
@ -214,6 +222,9 @@
'link'
),
'textdomain' => 'default',
'usesContext' => array(
'pattern/overrides'
),
'attributes' => array(
'tagName' => array(
'type' => 'string',
@ -245,8 +256,8 @@
'__experimentalRole' => 'content'
),
'text' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'a,button',
'__experimentalRole' => 'content'
),
@ -516,8 +527,8 @@
'textdomain' => 'default',
'attributes' => array(
'content' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'code',
'__unstablePreserveWhiteSpace' => true
)
@ -1314,7 +1325,7 @@
'ancestor' => array(
'core/comments'
),
'description' => 'Displays a title with the number of comments',
'description' => 'Displays a title with the number of comments.',
'textdomain' => 'default',
'usesContext' => array(
'postId',
@ -1397,9 +1408,6 @@
),
'alt' => array(
'type' => 'string',
'source' => 'attribute',
'selector' => 'img',
'attribute' => 'alt',
'default' => ''
),
'hasParallax' => array(
@ -1420,6 +1428,9 @@
'customOverlayColor' => array(
'type' => 'string'
),
'isUserOverlayColor' => array(
'type' => 'boolean'
),
'backgroundType' => array(
'type' => 'string',
'default' => 'image'
@ -1508,6 +1519,9 @@
),
'enableContrastChecker' => false
),
'dimensions' => array(
'aspectRatio' => true
),
'typography' => array(
'fontSize' => true,
'lineHeight' => true,
@ -1548,8 +1562,8 @@
'default' => false
),
'summary' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'summary'
)
),
@ -1615,8 +1629,8 @@
'__experimentalRole' => 'content'
),
'caption' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'figcaption',
'__experimentalRole' => 'content'
),
@ -1679,8 +1693,8 @@
'attribute' => 'id'
),
'fileName' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'a:not([download])'
),
'textLinkHref' => array(
@ -1700,8 +1714,8 @@
'default' => true
),
'downloadButtonText' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'a[download]'
),
'displayPreview' => array(
@ -1730,7 +1744,6 @@
),
'interactivity' => true
),
'viewScript' => 'file:./view.min.js',
'editorStyle' => 'wp-block-file-editor',
'style' => 'wp-block-file'
),
@ -1740,7 +1753,7 @@
'name' => 'core/footnotes',
'title' => 'Footnotes',
'category' => 'text',
'description' => '',
'description' => 'Display footnotes added to the page.',
'keywords' => array(
'references'
),
@ -1774,6 +1787,7 @@
'html' => false,
'multiple' => false,
'reusable' => false,
'inserter' => false,
'spacing' => array(
'margin' => true,
'padding' => true,
@ -1873,8 +1887,8 @@
'attribute' => 'data-id'
),
'caption' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => '.blocks-gallery-item__caption'
)
)
@ -1903,14 +1917,18 @@
'maximum' => 8
),
'caption' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => '.blocks-gallery-caption'
),
'imageCrop' => array(
'type' => 'boolean',
'default' => true
),
'randomOrder' => array(
'type' => 'boolean',
'default' => false
),
'fixedHeight' => array(
'type' => 'boolean',
'default' => true
@ -2018,7 +2036,6 @@
'__experimentalOnEnter' => true,
'__experimentalOnMerge' => true,
'__experimentalSettings' => true,
'__experimentalMetadata' => true,
'align' => array(
'wide',
'full'
@ -2027,7 +2044,11 @@
'ariaLabel' => true,
'html' => false,
'background' => array(
'backgroundImage' => true
'backgroundImage' => true,
'backgroundSize' => true,
'__experimentalDefaultControls' => array(
'backgroundImage' => true
)
),
'color' => array(
'gradients' => true,
@ -2052,6 +2073,7 @@
)
),
'dimensions' => array(
'aspectRatio' => true,
'minHeight' => true
),
'__experimentalBorder' => array(
@ -2101,15 +2123,17 @@
'subtitle'
),
'textdomain' => 'default',
'usesContext' => array(
'pattern/overrides'
),
'attributes' => array(
'textAlign' => array(
'type' => 'string'
),
'content' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'h1,h2,h3,h4,h5,h6',
'default' => '',
'__experimentalRole' => 'content'
),
'level' => array(
@ -2154,9 +2178,7 @@
'__experimentalTextDecoration' => true,
'__experimentalWritingMode' => true,
'__experimentalDefaultControls' => array(
'fontSize' => true,
'fontAppearance' => true,
'textTransform' => true
'fontSize' => true
)
),
'__unstablePasteTextInline' => true,
@ -2243,7 +2265,8 @@
'usesContext' => array(
'allowResize',
'imageCrop',
'fixedHeight'
'fixedHeight',
'pattern/overrides'
),
'description' => 'Insert an image to make a visual statement.',
'keywords' => array(
@ -2253,9 +2276,6 @@
),
'textdomain' => 'default',
'attributes' => array(
'align' => array(
'type' => 'string'
),
'url' => array(
'type' => 'string',
'source' => 'attribute',
@ -2272,8 +2292,8 @@
'__experimentalRole' => 'content'
),
'caption' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'figcaption',
'__experimentalRole' => 'content'
),
@ -2339,6 +2359,14 @@
)
),
'supports' => array(
'interactivity' => true,
'align' => array(
'left',
'center',
'right',
'wide',
'full'
),
'anchor' => true,
'color' => array(
'text' => false,
@ -2377,8 +2405,7 @@
)
),
'editorStyle' => 'wp-block-image-editor',
'style' => 'wp-block-image',
'viewScript' => 'file:./view.min.js'
'style' => 'wp-block-image'
),
'latest-comments' => array(
'$schema' => 'https://schemas.wp.org/trunk/block.json',
@ -2559,6 +2586,7 @@
'style' => 'wp-block-latest-posts'
),
'legacy-widget' => array(
'$schema' => 'https://schemas.wp.org/trunk/block.json',
'apiVersion' => 3,
'name' => 'core/legacy-widget',
'title' => 'Legacy Widget',
@ -2686,16 +2714,23 @@
'type' => 'string'
),
'content' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'li',
'default' => '',
'__experimentalRole' => 'content'
)
),
'supports' => array(
'className' => false,
'__experimentalSelector' => 'li',
'spacing' => array(
'margin' => true,
'padding' => true,
'__experimentalDefaultControls' => array(
'margin' => false,
'padding' => false
)
),
'typography' => array(
'fontSize' => true,
'lineHeight' => true,
@ -2736,6 +2771,14 @@
),
'supports' => array(
'className' => true,
'spacing' => array(
'margin' => true,
'padding' => true,
'__experimentalDefaultControls' => array(
'margin' => false,
'padding' => false
)
),
'typography' => array(
'fontSize' => true,
'lineHeight' => true,
@ -2904,7 +2947,7 @@
),
'originalContent' => array(
'type' => 'string',
'source' => 'html'
'source' => 'raw'
)
),
'supports' => array(
@ -3101,9 +3144,9 @@
)
)
),
'interactivity' => true
'interactivity' => true,
'renaming' => false
),
'viewScript' => 'file:./view.min.js',
'editorStyle' => 'wp-block-navigation-editor',
'style' => 'wp-block-navigation'
),
@ -3182,7 +3225,8 @@
'__experimentalDefaultControls' => array(
'fontSize' => true
)
)
),
'renaming' => false
),
'editorStyle' => 'wp-block-navigation-link-editor',
'style' => 'wp-block-navigation-link'
@ -3403,17 +3447,17 @@
),
'textdomain' => 'default',
'usesContext' => array(
'postId'
'postId',
'pattern/overrides'
),
'attributes' => array(
'align' => array(
'type' => 'string'
),
'content' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'p',
'default' => '',
'__experimentalRole' => 'content'
),
'dropCap' => array(
@ -3442,7 +3486,6 @@
'text' => true
)
),
'__experimentalConnections' => true,
'spacing' => array(
'margin' => true,
'padding' => true,
@ -3480,7 +3523,8 @@
'description' => 'Show a block pattern.',
'supports' => array(
'html' => false,
'inserter' => false
'inserter' => false,
'renaming' => false
),
'textdomain' => 'default',
'attributes' => array(
@ -3934,6 +3978,10 @@
),
'customGradient' => array(
'type' => 'string'
),
'useFirstImageFromPost' => array(
'type' => 'boolean',
'default' => false
)
),
'usesContext' => array(
@ -4005,8 +4053,18 @@
'arrow' => array(
'type' => 'string',
'default' => 'none'
),
'inSameTerm' => array(
'type' => 'boolean'
),
'taxonomy' => array(
'type' => 'string',
'default' => ''
)
),
'usesContext' => array(
'postType'
),
'supports' => array(
'reusable' => false,
'html' => false,
@ -4044,7 +4102,6 @@
'usesContext' => array(
'queryId',
'query',
'queryContext',
'displayLayout',
'templateSlug',
'previewPostType',
@ -4218,9 +4275,7 @@
'__experimentalTextDecoration' => true,
'__experimentalLetterSpacing' => true,
'__experimentalDefaultControls' => array(
'fontSize' => true,
'fontAppearance' => true,
'textTransform' => true
'fontSize' => true
)
)
),
@ -4236,10 +4291,9 @@
'textdomain' => 'default',
'attributes' => array(
'content' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'pre',
'default' => '',
'__unstablePreserveWhiteSpace' => true,
'__experimentalRole' => 'content'
)
@ -4283,16 +4337,15 @@
'textdomain' => 'default',
'attributes' => array(
'value' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'p',
'__experimentalRole' => 'content'
),
'citation' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'cite',
'default' => '',
'__experimentalRole' => 'content'
),
'textAlign' => array(
@ -4316,6 +4369,10 @@
'text' => true
)
),
'spacing' => array(
'margin' => true,
'padding' => true
),
'typography' => array(
'fontSize' => true,
'lineHeight' => true,
@ -4326,8 +4383,7 @@
'__experimentalTextDecoration' => true,
'__experimentalLetterSpacing' => true,
'__experimentalDefaultControls' => array(
'fontSize' => true,
'fontAppearance' => true
'fontSize' => true
)
),
'__experimentalBorder' => array(
@ -4413,8 +4469,7 @@
'layout' => true
),
'editorStyle' => 'wp-block-query-editor',
'style' => 'wp-block-query',
'viewScript' => 'file:./view.min.js'
'style' => 'wp-block-query'
),
'query-no-results' => array(
'$schema' => 'https://schemas.wp.org/trunk/block.json',
@ -4577,7 +4632,7 @@
'parent' => array(
'core/query-pagination'
),
'description' => 'Displays a list of page numbers for pagination',
'description' => 'Displays a list of page numbers for pagination.',
'textdomain' => 'default',
'attributes' => array(
'midSize' => array(
@ -4719,9 +4774,7 @@
'__experimentalTextTransform' => true,
'__experimentalTextDecoration' => true,
'__experimentalDefaultControls' => array(
'fontSize' => true,
'fontAppearance' => true,
'textTransform' => true
'fontSize' => true
)
)
),
@ -4749,10 +4802,9 @@
'__experimentalRole' => 'content'
),
'citation' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'cite',
'default' => '',
'__experimentalRole' => 'content'
),
'align' => array(
@ -4774,8 +4826,7 @@
'__experimentalTextDecoration' => true,
'__experimentalLetterSpacing' => true,
'__experimentalDefaultControls' => array(
'fontSize' => true,
'fontAppearance' => true
'fontSize' => true
)
),
'color' => array(
@ -4786,6 +4837,12 @@
'background' => true,
'text' => true
)
),
'layout' => array(
'allowEditing' => false
),
'spacing' => array(
'blockGap' => true
)
),
'styles' => array(
@ -4965,10 +5022,6 @@
)
),
'buttonBehavior' => array(
'type' => 'string',
'default' => 'expand-searchfield'
),
'isSearchFieldHidden' => array(
'type' => 'boolean',
'default' => false
@ -5017,7 +5070,6 @@
),
'html' => false
),
'viewScript' => 'file:./view.min.js',
'editorStyle' => 'wp-block-search-editor',
'style' => 'wp-block-search'
),
@ -5283,11 +5335,7 @@
'__experimentalFontWeight' => true,
'__experimentalLetterSpacing' => true,
'__experimentalDefaultControls' => array(
'fontSize' => true,
'lineHeight' => true,
'fontAppearance' => true,
'letterSpacing' => true,
'textTransform' => true
'fontSize' => true
)
)
),
@ -5496,10 +5544,9 @@
'default' => false
),
'caption' => array(
'type' => 'string',
'source' => 'html',
'selector' => 'figcaption',
'default' => ''
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'figcaption'
),
'head' => array(
'type' => 'array',
@ -5518,8 +5565,8 @@
'selector' => 'td,th',
'query' => array(
'content' => array(
'type' => 'string',
'source' => 'html'
'type' => 'rich-text',
'source' => 'rich-text'
),
'tag' => array(
'type' => 'string',
@ -5567,8 +5614,8 @@
'selector' => 'td,th',
'query' => array(
'content' => array(
'type' => 'string',
'source' => 'html'
'type' => 'rich-text',
'source' => 'rich-text'
),
'tag' => array(
'type' => 'string',
@ -5616,8 +5663,8 @@
'selector' => 'td,th',
'query' => array(
'content' => array(
'type' => 'string',
'source' => 'html'
'type' => 'rich-text',
'source' => 'rich-text'
),
'tag' => array(
'type' => 'string',
@ -5794,7 +5841,8 @@
'supports' => array(
'align' => true,
'html' => false,
'reusable' => false
'reusable' => false,
'renaming' => false
),
'editorStyle' => 'wp-block-template-part-editor'
),
@ -5900,10 +5948,9 @@
'textdomain' => 'default',
'attributes' => array(
'content' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'pre',
'default' => '',
'__unstablePreserveWhiteSpace' => true,
'__experimentalRole' => 'content'
),
@ -5931,8 +5978,7 @@
'__experimentalTextTransform' => true,
'__experimentalTextDecoration' => true,
'__experimentalDefaultControls' => array(
'fontSize' => true,
'fontAppearance' => true
'fontSize' => true
)
),
'spacing' => array(
@ -5972,8 +6018,8 @@
'attribute' => 'autoplay'
),
'caption' => array(
'type' => 'string',
'source' => 'html',
'type' => 'rich-text',
'source' => 'rich-text',
'selector' => 'figcaption',
'__experimentalRole' => 'content'
),
@ -6053,6 +6099,7 @@
'style' => 'wp-block-video'
),
'widget-group' => array(
'$schema' => 'https://schemas.wp.org/trunk/block.json',
'apiVersion' => 3,
'name' => 'core/widget-group',
'category' => 'widgets',

View File

@ -8,6 +8,7 @@
"description": "Prompt visitors to take action with a button-style link.",
"keywords": [ "link" ],
"textdomain": "default",
"usesContext": [ "pattern/overrides" ],
"attributes": {
"tagName": {
"type": "string",
@ -36,8 +37,8 @@
"__experimentalRole": "content"
},
"text": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "a,button",
"__experimentalRole": "content"
},

View File

@ -33,10 +33,8 @@ function render_block_core_calendar( $attributes ) {
str_contains( $permalink_structure, '%monthnum%' ) &&
str_contains( $permalink_structure, '%year%' )
) {
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
$monthnum = $attributes['month'];
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
$year = $attributes['year'];
$year = $attributes['year'];
}
}
@ -70,10 +68,8 @@ function render_block_core_calendar( $attributes ) {
$calendar
);
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
$monthnum = $previous_monthnum;
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
$year = $previous_year;
$year = $previous_year;
return $output;
}

View File

@ -70,8 +70,7 @@ function render_block_core_categories( $attributes ) {
function build_dropdown_script_block_core_categories( $dropdown_id ) {
ob_start();
?>
<script type='text/javascript'>
/* <![CDATA[ */
<script>
( function() {
var dropdown = document.getElementById( '<?php echo esc_js( $dropdown_id ); ?>' );
function onCatChange() {
@ -81,10 +80,9 @@ function build_dropdown_script_block_core_categories( $dropdown_id ) {
}
dropdown.onchange = onCatChange;
})();
/* ]]> */
</script>
<?php
return ob_get_clean();
return wp_get_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
}
/**

View File

@ -8,8 +8,8 @@
"textdomain": "default",
"attributes": {
"content": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "code",
"__unstablePreserveWhiteSpace": true
}

View File

@ -5,7 +5,7 @@
"title": "Comments Title",
"category": "theme",
"ancestor": [ "core/comments" ],
"description": "Displays a title with the number of comments",
"description": "Displays a title with the number of comments.",
"textdomain": "default",
"usesContext": [ "postId", "postType" ],
"attributes": {

View File

@ -19,9 +19,6 @@
},
"alt": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "alt",
"default": ""
},
"hasParallax": {
@ -42,6 +39,9 @@
"customOverlayColor": {
"type": "string"
},
"isUserOverlayColor": {
"type": "boolean"
},
"backgroundType": {
"type": "string",
"default": "image"
@ -114,6 +114,9 @@
"__experimentalSkipSerialization": [ "gradients" ],
"enableContrastChecker": false
},
"dimensions": {
"aspectRatio": true
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -13,8 +13,8 @@
"default": false
},
"summary": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "summary"
}
},

View File

@ -12,8 +12,8 @@
"__experimentalRole": "content"
},
"caption": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "figcaption",
"__experimentalRole": "content"
},

View File

@ -14,25 +14,8 @@
*
* @return string Returns the block content.
*/
function render_block_core_file( $attributes, $content, $block ) {
$should_load_view_script = ! empty( $attributes['displayPreview'] );
$view_js_file = 'wp-block-file-view';
// If the script already exists, there is no point in removing it from viewScript.
if ( ! wp_script_is( $view_js_file ) ) {
$script_handles = $block->block_type->view_script_handles;
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
}
// If the script is needed, but it was previously removed, add it again.
if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
}
}
function render_block_core_file( $attributes, $content ) {
// Update object's aria-label attribute if present in block HTML.
// Match an aria-label attribute from an object tag.
$pattern = '@<object.+(?<attribute>aria-label="(?<filename>[^"]+)?")@i';
$content = preg_replace_callback(
@ -53,13 +36,15 @@ function render_block_core_file( $attributes, $content, $block ) {
$content
);
// If it uses the Interactivity API, add the directives.
if ( $should_load_view_script ) {
// If it's interactive, enqueue the script module and add the directives.
if ( ! empty( $attributes['displayPreview'] ) ) {
wp_enqueue_script_module( '@wordpress/block-library/file' );
$processor = new WP_HTML_Tag_Processor( $content );
$processor->next_tag();
$processor->set_attribute( 'data-wp-interactive', '' );
$processor->set_attribute( 'data-wp-interactive', '{"namespace":"core/file"}' );
$processor->next_tag( 'object' );
$processor->set_attribute( 'data-wp-bind--hidden', '!selectors.core.file.hasPdfPreview' );
$processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
$processor->set_attribute( 'hidden', true );
return $processor->get_updated_html();
}
@ -67,25 +52,6 @@ function render_block_core_file( $attributes, $content, $block ) {
return $content;
}
/**
* Ensure that the view script has the `wp-interactivity` dependency.
*
* @since 6.4.0
*
* @global WP_Scripts $wp_scripts
*/
function block_core_file_ensure_interactivity_dependency() {
global $wp_scripts;
if (
isset( $wp_scripts->registered['wp-block-file-view'] ) &&
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-file-view']->deps, true )
) {
$wp_scripts->registered['wp-block-file-view']->deps[] = 'wp-interactivity';
}
}
add_action( 'wp_print_scripts', 'block_core_file_ensure_interactivity_dependency' );
/**
* Registers the `core/file` block on server.
*/
@ -96,5 +62,12 @@ function register_block_core_file() {
'render_callback' => 'render_block_core_file',
)
);
wp_register_script_module(
'@wordpress/block-library/file',
defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/file.min.js' ) : includes_url( 'blocks/file/view.min.js' ),
array( '@wordpress/interactivity' ),
defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
);
}
add_action( 'init', 'register_block_core_file' );

View File

@ -21,8 +21,8 @@
"attribute": "id"
},
"fileName": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "a:not([download])"
},
"textLinkHref": {
@ -42,8 +42,8 @@
"default": true
},
"downloadButtonText": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "a[download]"
},
"displayPreview": {
@ -72,7 +72,6 @@
},
"interactivity": true
},
"viewScript": "file:./view.min.js",
"editorStyle": "wp-block-file-editor",
"style": "wp-block-file"
}

View File

@ -68,17 +68,26 @@ function render_block_core_footnotes( $attributes, $content, $block ) {
* @since 6.3.0
*/
function register_block_core_footnotes() {
foreach ( array( 'post', 'page' ) as $post_type ) {
register_post_meta(
$post_type,
'footnotes',
array(
'show_in_rest' => true,
'single' => true,
'type' => 'string',
'revisions_enabled' => true,
)
);
$post_types = get_post_types(
array(
'show_in_rest' => true,
'public' => true,
)
);
foreach ( $post_types as $post_type ) {
// Only register the meta field if the post type supports the editor, custom fields, and revisions.
if ( post_type_supports( $post_type, 'editor' ) && post_type_supports( $post_type, 'custom-fields' ) && post_type_supports( $post_type, 'revisions' ) ) {
register_post_meta(
$post_type,
'footnotes',
array(
'show_in_rest' => true,
'single' => true,
'type' => 'string',
'revisions_enabled' => true,
)
);
}
}
register_block_type_from_metadata(
__DIR__ . '/footnotes',

View File

@ -4,7 +4,7 @@
"name": "core/footnotes",
"title": "Footnotes",
"category": "text",
"description": "",
"description": "Display footnotes added to the page.",
"keywords": [ "references" ],
"textdomain": "default",
"usesContext": [ "postId", "postType" ],
@ -33,6 +33,7 @@
"html": false,
"multiple": false,
"reusable": false,
"inserter": false,
"spacing": {
"margin": true,
"padding": true,

View File

@ -32,6 +32,21 @@ function block_core_gallery_data_id_backcompatibility( $parsed_block ) {
add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility' );
/**
* Filter to randomize the order of image blocks.
*
* @param array $parsed_block The block being rendered.
* @return array The block object with randomized order of image blocks.
*/
function block_core_gallery_random_order( $parsed_block ) {
if ( 'core/gallery' === $parsed_block['blockName'] && ! empty( $parsed_block['attrs']['randomOrder'] ) ) {
shuffle( $parsed_block['innerBlocks'] );
}
return $parsed_block;
}
add_filter( 'render_block_data', 'block_core_gallery_random_order' );
/**
* Adds a style tag for the --wp--style--unstable-gallery-gap var.
*

View File

@ -46,8 +46,8 @@
"attribute": "data-id"
},
"caption": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": ".blocks-gallery-item__caption"
}
}
@ -72,14 +72,18 @@
"maximum": 8
},
"caption": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": ".blocks-gallery-caption"
},
"imageCrop": {
"type": "boolean",
"default": true
},
"randomOrder": {
"type": "boolean",
"default": false
},
"fixedHeight": {
"type": "boolean",
"default": true

View File

@ -24,13 +24,16 @@
"__experimentalOnEnter": true,
"__experimentalOnMerge": true,
"__experimentalSettings": true,
"__experimentalMetadata": true,
"align": [ "wide", "full" ],
"anchor": true,
"ariaLabel": true,
"html": false,
"background": {
"backgroundImage": true
"backgroundImage": true,
"backgroundSize": true,
"__experimentalDefaultControls": {
"backgroundImage": true
}
},
"color": {
"gradients": true,
@ -52,6 +55,7 @@
}
},
"dimensions": {
"aspectRatio": true,
"minHeight": true
},
"__experimentalBorder": {

View File

@ -7,15 +7,15 @@
"description": "Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content.",
"keywords": [ "title", "subtitle" ],
"textdomain": "default",
"usesContext": [ "pattern/overrides" ],
"attributes": {
"textAlign": {
"type": "string"
},
"content": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "h1,h2,h3,h4,h5,h6",
"default": "",
"__experimentalRole": "content"
},
"level": {
@ -57,9 +57,7 @@
"__experimentalTextDecoration": true,
"__experimentalWritingMode": true,
"__experimentalDefaultControls": {
"fontSize": true,
"fontAppearance": true,
"textTransform": true
"fontSize": true
}
},
"__unstablePasteTextInline": true,

View File

@ -37,9 +37,6 @@ function render_block_core_image( $attributes, $content, $block ) {
$link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none';
$lightbox_settings = block_core_image_get_lightbox_settings( $block->parsed_block );
$view_js_file_handle = 'wp-block-image-view';
$script_handles = $block->block_type->view_script_handles;
/*
* If the lightbox is enabled and the image is not linked, add the filter
* and the JavaScript view file.
@ -50,31 +47,22 @@ function render_block_core_image( $attributes, $content, $block ) {
isset( $lightbox_settings['enabled'] ) &&
true === $lightbox_settings['enabled']
) {
$block->block_type->supports['interactivity'] = true;
if ( ! in_array( $view_js_file_handle, $script_handles, true ) ) {
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file_handle ) );
}
wp_enqueue_script_module( '@wordpress/block-library/image' );
/*
* This render needs to happen in a filter with priority 15 to ensure
* that it runs after the duotone filter and that duotone styles are
* applied to the image in the lightbox. We also need to ensure that the
* lightbox works with any plugins that might use filters as well. We
* can consider removing this in the future if the way the blocks are
* rendered changes, or if a new kind of filter is introduced.
* This render needs to happen in a filter with priority 15 to ensure that
* it runs after the duotone filter and that duotone styles are applied to
* the image in the lightbox. Lightbox has to work with any plugins that
* might use filters as well. Removing this can be considered in the
* future if the way the blocks are rendered changes, or if a
* new kind of filter is introduced.
*/
add_filter( 'render_block_core/image', 'block_core_image_render_lightbox', 15, 2 );
} else {
/*
* Remove the filter and the JavaScript view file if previously added by
* other Image blocks.
* Remove the filter if previously added by other Image blocks.
*/
remove_filter( 'render_block_core/image', 'block_core_image_render_lightbox', 15 );
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
if ( in_array( $view_js_file_handle, $script_handles, true ) ) {
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file_handle ) );
}
}
return $processor->get_updated_html();
@ -93,12 +81,6 @@ function block_core_image_get_lightbox_settings( $block ) {
// Get the lightbox setting from the block attributes.
if ( isset( $block['attrs']['lightbox'] ) ) {
$lightbox_settings = $block['attrs']['lightbox'];
// If the lightbox setting is not set in the block attributes,
// check the legacy lightbox settings that are set using the
// `gutenberg_should_render_lightbox` filter.
// We can remove this elseif statement when the legacy lightbox settings are removed.
} elseif ( isset( $block['legacyLightboxSettings'] ) ) {
$lightbox_settings = $block['legacyLightboxSettings'];
}
if ( ! isset( $lightbox_settings ) ) {
@ -187,27 +169,23 @@ function block_core_image_render_lightbox( $block_content, $block ) {
$w = new WP_HTML_Tag_Processor( $block_content );
$w->next_tag( 'figure' );
$w->add_class( 'wp-lightbox-container' );
$w->set_attribute( 'data-wp-interactive', true );
$w->set_attribute( 'data-wp-interactive', '{"namespace":"core/image"}' );
$w->set_attribute(
'data-wp-context',
sprintf(
'{ "core":
{ "image":
{ "imageLoaded": false,
"initialized": false,
"lightboxEnabled": false,
"hideAnimationEnabled": false,
"preloadInitialized": false,
"lightboxAnimation": "%s",
"imageUploadedSrc": "%s",
"imageCurrentSrc": "",
"targetWidth": "%s",
"targetHeight": "%s",
"scaleAttr": "%s",
"dialogLabel": "%s"
}
}
'{ "imageLoaded": false,
"initialized": false,
"lightboxEnabled": false,
"hideAnimationEnabled": false,
"preloadInitialized": false,
"lightboxAnimation": "%s",
"imageUploadedSrc": "%s",
"imageCurrentSrc": "",
"targetWidth": "%s",
"targetHeight": "%s",
"scaleAttr": "%s",
"dialogLabel": "%s"
}',
$lightbox_animation,
$img_uploaded_src,
@ -218,14 +196,14 @@ function block_core_image_render_lightbox( $block_content, $block ) {
)
);
$w->next_tag( 'img' );
$w->set_attribute( 'data-wp-init', 'effects.core.image.initOriginImage' );
$w->set_attribute( 'data-wp-on--load', 'actions.core.image.handleLoad' );
$w->set_attribute( 'data-wp-effect', 'effects.core.image.setButtonStyles' );
$w->set_attribute( 'data-wp-init', 'callbacks.initOriginImage' );
$w->set_attribute( 'data-wp-on--load', 'actions.handleLoad' );
$w->set_attribute( 'data-wp-watch', 'callbacks.setButtonStyles' );
// We need to set an event callback on the `img` specifically
// because the `figure` element can also contain a caption, and
// we don't want to trigger the lightbox when the caption is clicked.
$w->set_attribute( 'data-wp-on--click', 'actions.core.image.showLightbox' );
$w->set_attribute( 'data-wp-effect--setStylesOnResize', 'effects.core.image.setStylesOnResize' );
$w->set_attribute( 'data-wp-on--click', 'actions.showLightbox' );
$w->set_attribute( 'data-wp-watch--setStylesOnResize', 'callbacks.setStylesOnResize' );
$body_content = $w->get_updated_html();
// Add a button alongside image in the body content.
@ -239,9 +217,10 @@ function block_core_image_render_lightbox( $block_content, $block ) {
type="button"
aria-haspopup="dialog"
aria-label="' . esc_attr( $aria_label ) . '"
data-wp-on--click="actions.core.image.showLightbox"
data-wp-style--right="context.core.image.imageButtonRight"
data-wp-style--top="context.core.image.imageButtonTop"
data-wp-init="callbacks.initTriggerButton"
data-wp-on--click="actions.showLightbox"
data-wp-style--right="context.imageButtonRight"
data-wp-style--top="context.imageButtonTop"
>
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
@ -267,8 +246,8 @@ function block_core_image_render_lightbox( $block_content, $block ) {
// use the exact same image as in the content when the lightbox is first opened while
// we wait for the larger image to load.
$m->set_attribute( 'src', '' );
$m->set_attribute( 'data-wp-bind--src', 'context.core.image.imageCurrentSrc' );
$m->set_attribute( 'data-wp-style--object-fit', 'selectors.core.image.lightboxObjectFit' );
$m->set_attribute( 'data-wp-bind--src', 'context.imageCurrentSrc' );
$m->set_attribute( 'data-wp-style--object-fit', 'state.lightboxObjectFit' );
$initial_image_content = $m->get_updated_html();
$q = new WP_HTML_Tag_Processor( $block_content );
@ -283,8 +262,8 @@ function block_core_image_render_lightbox( $block_content, $block ) {
// and Chrome (see https://github.com/WordPress/gutenberg/pull/52765#issuecomment-1674008151). Until that
// is resolved, manually setting the 'src' seems to be the best solution to load the large image on demand.
$q->set_attribute( 'src', '' );
$q->set_attribute( 'data-wp-bind--src', 'selectors.core.image.enlargedImgSrc' );
$q->set_attribute( 'data-wp-style--object-fit', 'selectors.core.image.lightboxObjectFit' );
$q->set_attribute( 'data-wp-bind--src', 'state.enlargedImgSrc' );
$q->set_attribute( 'data-wp-style--object-fit', 'state.lightboxObjectFit' );
$enlarged_image_content = $q->get_updated_html();
// If the current theme does NOT have a `theme.json`, or the colors are not defined,
@ -307,21 +286,21 @@ function block_core_image_render_lightbox( $block_content, $block ) {
$lightbox_html = <<<HTML
<div data-wp-body="" class="wp-lightbox-overlay $lightbox_animation"
data-wp-bind--role="selectors.core.image.roleAttribute"
data-wp-bind--aria-label="selectors.core.image.dialogLabel"
data-wp-class--initialized="context.core.image.initialized"
data-wp-class--active="context.core.image.lightboxEnabled"
data-wp-class--hideAnimationEnabled="context.core.image.hideAnimationEnabled"
data-wp-bind--aria-modal="selectors.core.image.ariaModal"
data-wp-effect="effects.core.image.initLightbox"
data-wp-on--keydown="actions.core.image.handleKeydown"
data-wp-on--touchstart="actions.core.image.handleTouchStart"
data-wp-on--touchmove="actions.core.image.handleTouchMove"
data-wp-on--touchend="actions.core.image.handleTouchEnd"
data-wp-on--click="actions.core.image.hideLightbox"
data-wp-bind--role="state.roleAttribute"
data-wp-bind--aria-label="state.dialogLabel"
data-wp-class--initialized="context.initialized"
data-wp-class--active="context.lightboxEnabled"
data-wp-class--hideAnimationEnabled="context.hideAnimationEnabled"
data-wp-bind--aria-modal="state.ariaModal"
data-wp-watch="callbacks.initLightbox"
data-wp-on--keydown="actions.handleKeydown"
data-wp-on--touchstart="actions.handleTouchStart"
data-wp-on--touchmove="actions.handleTouchMove"
data-wp-on--touchend="actions.handleTouchEnd"
data-wp-on--click="actions.hideLightbox"
tabindex="-1"
>
<button type="button" aria-label="$close_button_label" style="fill: $close_button_color" class="close-button" data-wp-on--click="actions.core.image.hideLightbox">
<button type="button" aria-label="$close_button_label" style="fill: $close_button_color" class="close-button" data-wp-on--click="actions.hideLightbox">
$close_button_icon
</button>
<div class="lightbox-image-container">$initial_image_content</div>
@ -333,25 +312,6 @@ HTML;
return str_replace( '</figure>', $lightbox_html . '</figure>', $body_content );
}
/**
* Ensures that the view script has the `wp-interactivity` dependency.
*
* @since 6.4.0
*
* @global WP_Scripts $wp_scripts
*/
function block_core_image_ensure_interactivity_dependency() {
global $wp_scripts;
if (
isset( $wp_scripts->registered['wp-block-image-view'] ) &&
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-image-view']->deps, true )
) {
$wp_scripts->registered['wp-block-image-view']->deps[] = 'wp-interactivity';
}
}
add_action( 'wp_print_scripts', 'block_core_image_ensure_interactivity_dependency' );
/**
* Registers the `core/image` block on server.
*/
@ -362,5 +322,12 @@ function register_block_core_image() {
'render_callback' => 'render_block_core_image',
)
);
wp_register_script_module(
'@wordpress/block-library/image',
defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/image.min.js' ) : includes_url( 'blocks/image/view.min.js' ),
array( '@wordpress/interactivity' ),
defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
);
}
add_action( 'init', 'register_block_core_image' );

View File

@ -4,14 +4,16 @@
"name": "core/image",
"title": "Image",
"category": "media",
"usesContext": [ "allowResize", "imageCrop", "fixedHeight" ],
"usesContext": [
"allowResize",
"imageCrop",
"fixedHeight",
"pattern/overrides"
],
"description": "Insert an image to make a visual statement.",
"keywords": [ "img", "photo", "picture" ],
"textdomain": "default",
"attributes": {
"align": {
"type": "string"
},
"url": {
"type": "string",
"source": "attribute",
@ -28,8 +30,8 @@
"__experimentalRole": "content"
},
"caption": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "figcaption",
"__experimentalRole": "content"
},
@ -95,6 +97,8 @@
}
},
"supports": {
"interactivity": true,
"align": [ "left", "center", "right", "wide", "full" ],
"anchor": true,
"color": {
"text": false,
@ -130,6 +134,5 @@
{ "name": "rounded", "label": "Rounded" }
],
"editorStyle": "wp-block-image-editor",
"style": "wp-block-image",
"viewScript": "file:./view.min.js"
"style": "wp-block-image"
}

View File

@ -1,4 +1,5 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/legacy-widget",
"title": "Legacy Widget",

View File

@ -12,16 +12,23 @@
"type": "string"
},
"content": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "li",
"default": "",
"__experimentalRole": "content"
}
},
"supports": {
"className": false,
"__experimentalSelector": "li",
"spacing": {
"margin": true,
"padding": true,
"__experimentalDefaultControls": {
"margin": false,
"padding": false
}
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -19,6 +19,14 @@
},
"supports": {
"className": true,
"spacing": {
"margin": true,
"padding": true,
"__experimentalDefaultControls": {
"margin": false,
"padding": false
}
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -15,7 +15,7 @@
},
"originalContent": {
"type": "string",
"source": "html"
"source": "raw"
}
},
"supports": {

View File

@ -1,6 +1,6 @@
<?php
/**
* Server-side rendering of the `core/navigation-link` block.
* Server-side registering and rendering of the `core/navigation-link` block.
*
* @package WordPress
*/
@ -323,12 +323,63 @@ function build_variation_for_navigation_link( $entity, $kind ) {
}
/**
* Register the navigation link block.
* Register a variation for a post type / taxonomy for the navigation link block.
*
* @uses render_block_core_navigation()
* @throws WP_Error An WP_Error exception parsing the block definition.
* @param array $variation Variation array from build_variation_for_navigation_link.
* @return void
*/
function register_block_core_navigation_link() {
function block_core_navigation_link_register_variation( $variation ) {
// Directly set the variations on the registered block type
// because there's no server side registration for variations (see #47170).
$navigation_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/navigation-link' );
// If the block is not registered yet, bail early.
// Variation will be registered in register_block_core_navigation_link then.
if ( ! $navigation_block_type ) {
return;
}
$navigation_block_type->variations = array_merge(
$navigation_block_type->variations,
array( $variation )
);
}
/**
* Unregister a variation for a post type / taxonomy for the navigation link block.
*
* @param string $name Name of the post type / taxonomy (which was used as variation name).
* @return void
*/
function block_core_navigation_link_unregister_variation( $name ) {
// Directly get the variations from the registered block type
// because there's no server side (un)registration for variations (see #47170).
$navigation_block_type = WP_Block_Type_Registry::get_instance()->get_registered( 'core/navigation-link' );
// If the block is not registered (yet), there's no need to remove a variation.
if ( ! $navigation_block_type || empty( $navigation_block_type->variations ) ) {
return;
}
$variations = $navigation_block_type->variations;
// Search for the variation and remove it from the array.
foreach ( $variations as $i => $variation ) {
if ( $variation['name'] === $name ) {
unset( $variations[ $i ] );
break;
}
}
// Reindex array after removing one variation.
$navigation_block_type->variations = array_values( $variations );
}
/**
* Register the navigation link block.
* Returns an array of variations for the navigation link block.
*
* @return array
*/
function build_navigation_link_block_variations() {
// This will only handle post types and taxonomies registered until this point (init on priority 9).
// See action hooks below for other post types and taxonomies.
// See https://github.com/WordPress/gutenberg/issues/53826 for details.
$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects' );
@ -360,12 +411,80 @@ function register_block_core_navigation_link() {
}
}
return array_merge( $built_ins, $variations );
}
/**
* Register the navigation link block.
*
* @uses render_block_core_navigation()
* @throws WP_Error An WP_Error exception parsing the block definition.
*/
function register_block_core_navigation_link() {
register_block_type_from_metadata(
__DIR__ . '/navigation-link',
array(
'render_callback' => 'render_block_core_navigation_link',
'variations' => array_merge( $built_ins, $variations ),
'render_callback' => 'render_block_core_navigation_link',
'variation_callback' => 'build_navigation_link_block_variations',
)
);
}
add_action( 'init', 'register_block_core_navigation_link' );
// Register actions for all post types and taxonomies, to add variations when they are registered.
// All post types/taxonomies registered before register_block_core_navigation_link, will be handled by that function.
add_action( 'registered_post_type', 'block_core_navigation_link_register_post_type_variation', 10, 2 );
add_action( 'registered_taxonomy', 'block_core_navigation_link_register_taxonomy_variation', 10, 3 );
// Handle unregistering of post types and taxonomies and remove the variations.
add_action( 'unregistered_post_type', 'block_core_navigation_link_unregister_post_type_variation' );
add_action( 'unregistered_taxonomy', 'block_core_navigation_link_unregister_taxonomy_variation' );
/**
* Register custom post type variations for navigation link on post type registration
* Handles all post types registered after the block is registered in register_navigation_link_post_type_variations
*
* @param string $post_type The post type name passed from registered_post_type action hook.
* @param WP_Post_Type $post_type_object The post type object passed from registered_post_type.
* @return void
*/
function block_core_navigation_link_register_post_type_variation( $post_type, $post_type_object ) {
if ( $post_type_object->show_in_nav_menus ) {
$variation = build_variation_for_navigation_link( $post_type_object, 'post-type' );
block_core_navigation_link_register_variation( $variation );
}
}
/**
* Register a custom taxonomy variation for navigation link on taxonomy registration
* Handles all taxonomies registered after the block is registered in register_navigation_link_post_type_variations
*
* @param string $taxonomy Taxonomy slug.
* @param array|string $object_type Object type or array of object types.
* @param array $args Array of taxonomy registration arguments.
* @return void
*/
function block_core_navigation_link_register_taxonomy_variation( $taxonomy, $object_type, $args ) {
if ( isset( $args['show_in_nav_menus'] ) && $args['show_in_nav_menus'] ) {
$variation = build_variation_for_navigation_link( (object) $args, 'post-type' );
block_core_navigation_link_register_variation( $variation );
}
}
/**
* Unregisters a custom post type variation for navigation link on post type unregistration.
*
* @param string $post_type The post type name passed from unregistered_post_type action hook.
* @return void
*/
function block_core_navigation_link_unregister_post_type_variation( $post_type ) {
block_core_navigation_link_unregister_variation( $post_type );
}
/**
* Unregisters a custom taxonomy variation for navigation link on taxonomy unregistration.
*
* @param string $taxonomy The taxonomy name passed from unregistered_taxonomy action hook.
* @return void
*/
function block_core_navigation_link_unregister_taxonomy_variation( $taxonomy ) {
block_core_navigation_link_unregister_variation( $taxonomy );
}

View File

@ -71,7 +71,8 @@
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"renaming": false
},
"editorStyle": "wp-block-navigation-link-editor",
"style": "wp-block-navigation-link"

File diff suppressed because it is too large Load Diff

View File

@ -133,9 +133,9 @@
}
}
},
"interactivity": true
"interactivity": true,
"renaming": false
},
"viewScript": "file:./view.min.js",
"editorStyle": "wp-block-navigation-editor",
"style": "wp-block-navigation"
}

View File

@ -7,16 +7,15 @@
"description": "Start with the basic building block of all narrative.",
"keywords": [ "text" ],
"textdomain": "default",
"usesContext": [ "postId" ],
"usesContext": [ "postId", "pattern/overrides" ],
"attributes": {
"align": {
"type": "string"
},
"content": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "p",
"default": "",
"__experimentalRole": "content"
},
"dropCap": {
@ -42,7 +41,6 @@
"text": true
}
},
"__experimentalConnections": true,
"spacing": {
"margin": true,
"padding": true,

View File

@ -27,6 +27,8 @@ function register_block_core_pattern() {
* @return string Returns the output of the pattern.
*/
function render_block_core_pattern( $attributes ) {
static $seen_refs = array();
if ( empty( $attributes['slug'] ) ) {
return '';
}
@ -38,6 +40,17 @@ function render_block_core_pattern( $attributes ) {
return '';
}
if ( isset( $seen_refs[ $attributes['slug'] ] ) ) {
// WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent
// is set in `wp_debug_mode()`.
$is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;
return $is_debug ?
// translators: Visible only in the front end, this warning takes the place of a faulty block. %s represents a pattern's slug.
sprintf( __( '[block rendering halted for pattern "%s"]' ), $slug ) :
'';
}
$pattern = $registry->get_registered( $slug );
$content = $pattern['content'];
@ -48,7 +61,15 @@ function render_block_core_pattern( $attributes ) {
$content = gutenberg_serialize_blocks( $blocks );
}
return do_blocks( $content );
$seen_refs[ $attributes['slug'] ] = true;
$content = do_blocks( $content );
global $wp_embed;
$content = $wp_embed->autoembed( $content );
unset( $seen_refs[ $attributes['slug'] ] );
return $content;
}
add_action( 'init', 'register_block_core_pattern' );

View File

@ -7,7 +7,8 @@
"description": "Show a block pattern.",
"supports": {
"html": false,
"inserter": false
"inserter": false,
"renaming": false
},
"textdomain": "default",
"attributes": {

View File

@ -54,9 +54,40 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
}
$featured_image = get_the_post_thumbnail( $post_ID, $size_slug, $attr );
// Get the first image from the post.
if ( $attributes['useFirstImageFromPost'] && ! $featured_image ) {
$content_post = get_post( $post_ID );
$content = $content_post->post_content;
$processor = new WP_HTML_Tag_Processor( $content );
/*
* Transfer the image tag from the post into a new text snippet.
* Because the HTML API doesn't currently expose a way to extract
* HTML substrings this is necessary as a workaround. Of note, this
* is different than directly extracting the IMG tag:
* - If there are duplicate attributes in the source there will only be one in the output.
* - If there are single-quoted or unquoted attributes they will be double-quoted in the output.
* - If there are named character references in the attribute values they may be replaced with their direct code points. E.g. `&hellip;` becomes `…`.
* In the future there will likely be a mechanism to copy snippets of HTML from
* one document into another, via the HTML Processor's `get_outer_html()` or
* equivalent. When that happens it would be appropriate to replace this custom
* code with that canonical code.
*/
if ( $processor->next_tag( 'img' ) ) {
$tag_html = new WP_HTML_Tag_Processor( '<img>' );
$tag_html->next_tag();
foreach ( $processor->get_attribute_names_with_prefix( '' ) as $name ) {
$tag_html->set_attribute( $name, $processor->get_attribute( $name ) );
}
$featured_image = $tag_html->get_updated_html();
}
}
if ( ! $featured_image ) {
return '';
}
if ( $is_link ) {
$link_target = $attributes['linkTarget'];
$rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';

View File

@ -51,6 +51,10 @@
},
"customGradient": {
"type": "string"
},
"useFirstImageFromPost": {
"type": "boolean",
"default": false
}
},
"usesContext": [ "postId", "postType", "queryId" ],

View File

@ -99,10 +99,24 @@ function render_block_core_post_navigation_link( $attributes, $content ) {
}
}
// The dynamic portion of the function name, `$navigation_type`,
// refers to the type of adjacency, 'next' or 'previous'.
$in_same_term = isset( $attributes['inSameTerm'] ) ? $attributes['inSameTerm'] : false;
$taxonomy = isset( $attributes['taxonomy'] ) && $in_same_term ? $attributes['taxonomy'] : '';
/**
* The dynamic portion of the function name, `$navigation_type`,
* Refers to the type of adjacency, 'next' or 'previous'.
*
* @See https://developer.wordpress.org/reference/functions/get_previous_post_link/
* @See https://developer.wordpress.org/reference/functions/get_next_post_link/
*/
$get_link_function = "get_{$navigation_type}_post_link";
$content = $get_link_function( $format, $link );
if ( $in_same_term ) {
$content = $get_link_function( $format, $link, $in_same_term, '', $taxonomy );
} else {
$content = $get_link_function( $format, $link );
}
return sprintf(
'<div %1$s>%2$s</div>',
$wrapper_attributes,

View File

@ -28,8 +28,16 @@
"arrow": {
"type": "string",
"default": "none"
},
"inSameTerm": {
"type": "boolean"
},
"taxonomy": {
"type": "string",
"default": ""
}
},
"usesContext": [ "postType" ],
"supports": {
"reusable": false,
"html": false,

View File

@ -10,7 +10,6 @@
"usesContext": [
"queryId",
"query",
"queryContext",
"displayLayout",
"templateSlug",
"previewPostType",

View File

@ -59,9 +59,11 @@ function render_block_core_post_terms( $attributes, $content, $block ) {
}
/**
* Registers the `core/post-terms` block on the server.
* Returns the available variations for the `core/post-terms` block.
*
* @return array The available variations for the block.
*/
function register_block_core_post_terms() {
function build_post_term_block_variations() {
$taxonomies = get_taxonomies(
array(
'publicly_queryable' => true,
@ -103,11 +105,18 @@ function register_block_core_post_terms() {
}
}
return array_merge( $built_ins, $custom_variations );
}
/**
* Registers the `core/post-terms` block on the server.
*/
function register_block_core_post_terms() {
register_block_type_from_metadata(
__DIR__ . '/post-terms',
array(
'render_callback' => 'render_block_core_post_terms',
'variations' => array_merge( $built_ins, $custom_variations ),
'render_callback' => 'render_block_core_post_terms',
'variation_callback' => 'build_post_term_block_variations',
)
);
}

View File

@ -38,7 +38,7 @@ function render_block_core_post_title( $attributes, $content, $block ) {
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
$title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $block->context['postId'] ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
$title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', esc_url( get_the_permalink( $block->context['postId'] ) ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
}
$classes = array();

View File

@ -55,9 +55,7 @@
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true,
"fontAppearance": true,
"textTransform": true
"fontSize": true
}
}
},

View File

@ -8,10 +8,9 @@
"textdomain": "default",
"attributes": {
"content": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "pre",
"default": "",
"__unstablePreserveWhiteSpace": true,
"__experimentalRole": "content"
}

View File

@ -8,16 +8,15 @@
"textdomain": "default",
"attributes": {
"value": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "p",
"__experimentalRole": "content"
},
"citation": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "cite",
"default": "",
"__experimentalRole": "content"
},
"textAlign": {
@ -36,6 +35,10 @@
"text": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
@ -46,8 +49,7 @@
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true,
"fontAppearance": true
"fontSize": true
}
},
"__experimentalBorder": {

View File

@ -72,9 +72,9 @@ function render_block_core_query_pagination_next( $attributes, $content, $block
)
) ) {
$p->set_attribute( 'data-wp-key', 'query-pagination-next' );
$p->set_attribute( 'data-wp-on--click', 'actions.core.query.navigate' );
$p->set_attribute( 'data-wp-on--mouseenter', 'actions.core.query.prefetch' );
$p->set_attribute( 'data-wp-effect', 'effects.core.query.prefetch' );
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
$p->set_attribute( 'data-wp-on--mouseenter', 'core/query::actions.prefetch' );
$p->set_attribute( 'data-wp-watch', 'core/query::callbacks.prefetch' );
$content = $p->get_updated_html();
}
}

View File

@ -98,7 +98,7 @@ function render_block_core_query_pagination_numbers( $attributes, $content, $blo
'class_name' => 'page-numbers',
)
) ) {
$p->set_attribute( 'data-wp-on--click', 'actions.core.query.navigate' );
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
}
$content = $p->get_updated_html();
}

View File

@ -5,7 +5,7 @@
"title": "Page Numbers",
"category": "theme",
"parent": [ "core/query-pagination" ],
"description": "Displays a list of page numbers for pagination",
"description": "Displays a list of page numbers for pagination.",
"textdomain": "default",
"attributes": {
"midSize": {

View File

@ -60,9 +60,9 @@ function render_block_core_query_pagination_previous( $attributes, $content, $bl
)
) ) {
$p->set_attribute( 'data-wp-key', 'query-pagination-previous' );
$p->set_attribute( 'data-wp-on--click', 'actions.core.query.navigate' );
$p->set_attribute( 'data-wp-on--mouseenter', 'actions.core.query.prefetch' );
$p->set_attribute( 'data-wp-effect', 'effects.core.query.prefetch' );
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
$p->set_attribute( 'data-wp-on--mouseenter', 'core/query::actions.prefetch' );
$p->set_attribute( 'data-wp-watch', 'core/query::callbacks.prefetch' );
$content = $p->get_updated_html();
}
}

View File

@ -50,9 +50,7 @@
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalDefaultControls": {
"fontSize": true,
"fontAppearance": true,
"textTransform": true
"fontSize": true
}
}
},

View File

@ -17,23 +17,26 @@
* @return string Returns the modified output of the query block.
*/
function render_block_core_query( $attributes, $content, $block ) {
if ( $attributes['enhancedPagination'] && isset( $attributes['queryId'] ) ) {
$is_interactive = isset( $attributes['enhancedPagination'] ) && true === $attributes['enhancedPagination'] && isset( $attributes['queryId'] );
// Enqueue the script module and add the necessary directives if the block is
// interactive.
if ( $is_interactive ) {
wp_enqueue_script_module( '@wordpress/block-library/query' );
$p = new WP_HTML_Tag_Processor( $content );
if ( $p->next_tag() ) {
// Add the necessary directives.
$p->set_attribute( 'data-wp-interactive', true );
$p->set_attribute( 'data-wp-navigation-id', 'query-' . $attributes['queryId'] );
$p->set_attribute( 'data-wp-interactive', '{"namespace":"core/query"}' );
$p->set_attribute( 'data-wp-router-region', 'query-' . $attributes['queryId'] );
$p->set_attribute( 'data-wp-init', 'callbacks.setQueryRef' );
// Use context to send translated strings.
$p->set_attribute(
'data-wp-context',
wp_json_encode(
array(
'core' => array(
'query' => array(
'loadingText' => __( 'Loading page, please wait.' ),
'loadedText' => __( 'Page Loaded.' ),
),
),
'loadingText' => __( 'Loading page, please wait.' ),
'loadedText' => __( 'Page Loaded.' ),
),
JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP
)
@ -54,12 +57,12 @@ function render_block_core_query( $attributes, $content, $block ) {
'<div
class="screen-reader-text"
aria-live="polite"
data-wp-text="context.core.query.message"
data-wp-text="context.message"
></div>
<div
class="wp-block-query__enhanced-pagination-animation"
data-wp-class--start-animation="selectors.core.query.startAnimation"
data-wp-class--finish-animation="selectors.core.query.finishAnimation"
data-wp-class--start-animation="state.startAnimation"
data-wp-class--finish-animation="state.finishAnimation"
></div>',
$last_tag_position,
0
@ -67,34 +70,17 @@ function render_block_core_query( $attributes, $content, $block ) {
}
}
$view_asset = 'wp-block-query-view';
if ( ! wp_script_is( $view_asset ) ) {
$script_handles = $block->block_type->view_script_handles;
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
if (
( ! $attributes['enhancedPagination'] || ! isset( $attributes['queryId'] ) )
&& in_array( $view_asset, $script_handles, true )
) {
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_asset ) );
}
// If the script is needed, but it was previously removed, add it again.
if ( $attributes['enhancedPagination'] && isset( $attributes['queryId'] ) && ! in_array( $view_asset, $script_handles, true ) ) {
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_asset ) );
}
}
// Add the styles to the block type if the block is interactive and remove
// them if it's not.
$style_asset = 'wp-block-query';
if ( ! wp_style_is( $style_asset ) ) {
$style_handles = $block->block_type->style_handles;
// If the styles are not needed, and they are still in the `style_handles`, remove them.
if (
( ! $attributes['enhancedPagination'] || ! isset( $attributes['queryId'] ) )
&& in_array( $style_asset, $style_handles, true )
) {
if ( ! $is_interactive && in_array( $style_asset, $style_handles, true ) ) {
$block->block_type->style_handles = array_diff( $style_handles, array( $style_asset ) );
}
// If the styles are needed, but they were previously removed, add them again.
if ( $attributes['enhancedPagination'] && isset( $attributes['queryId'] ) && ! in_array( $style_asset, $style_handles, true ) ) {
if ( $is_interactive && ! in_array( $style_asset, $style_handles, true ) ) {
$block->block_type->style_handles = array_merge( $style_handles, array( $style_asset ) );
}
}
@ -102,25 +88,6 @@ function render_block_core_query( $attributes, $content, $block ) {
return $content;
}
/**
* Ensure that the view script has the `wp-interactivity` dependency.
*
* @since 6.4.0
*
* @global WP_Scripts $wp_scripts
*/
function block_core_query_ensure_interactivity_dependency() {
global $wp_scripts;
if (
isset( $wp_scripts->registered['wp-block-query-view'] ) &&
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-query-view']->deps, true )
) {
$wp_scripts->registered['wp-block-query-view']->deps[] = 'wp-interactivity';
}
}
add_action( 'wp_print_scripts', 'block_core_query_ensure_interactivity_dependency' );
/**
* Registers the `core/query` block on the server.
*/
@ -131,6 +98,22 @@ function register_block_core_query() {
'render_callback' => 'render_block_core_query',
)
);
wp_register_script_module(
'@wordpress/block-library/query',
defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/query.min.js' ) : includes_url( 'blocks/query/view.min.js' ),
array(
array(
'id' => '@wordpress/interactivity',
'import' => 'static',
),
array(
'id' => '@wordpress/interactivity-router',
'import' => 'dynamic',
),
),
defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
);
}
add_action( 'init', 'register_block_core_query' );
@ -150,14 +133,10 @@ function block_core_query_disable_enhanced_pagination( $parsed_block ) {
static $dirty_enhanced_queries = array();
static $render_query_callback = null;
$block_name = $parsed_block['blockName'];
$is_interactive = isset( $parsed_block['attrs']['enhancedPagination'] ) && true === $parsed_block['attrs']['enhancedPagination'] && isset( $parsed_block['attrs']['queryId'] );
$block_name = $parsed_block['blockName'];
if (
'core/query' === $block_name &&
isset( $parsed_block['attrs']['enhancedPagination'] ) &&
true === $parsed_block['attrs']['enhancedPagination'] &&
isset( $parsed_block['attrs']['queryId'] )
) {
if ( 'core/query' === $block_name && $is_interactive ) {
$enhanced_query_stack[] = $parsed_block['attrs']['queryId'];
if ( ! isset( $render_query_callback ) ) {
@ -172,12 +151,9 @@ function block_core_query_disable_enhanced_pagination( $parsed_block ) {
* @return string Returns the modified output of the query block.
*/
$render_query_callback = static function ( $content, $block ) use ( &$enhanced_query_stack, &$dirty_enhanced_queries, &$render_query_callback ) {
$has_enhanced_pagination =
isset( $block['attrs']['enhancedPagination'] ) &&
true === $block['attrs']['enhancedPagination'] &&
isset( $block['attrs']['queryId'] );
$is_interactive = isset( $block['attrs']['enhancedPagination'] ) && true === $block['attrs']['enhancedPagination'] && isset( $block['attrs']['queryId'] );
if ( ! $has_enhanced_pagination ) {
if ( ! $is_interactive ) {
return $content;
}

View File

@ -52,6 +52,5 @@
"layout": true
},
"editorStyle": "wp-block-query-editor",
"style": "wp-block-query",
"viewScript": "file:./view.min.js"
"style": "wp-block-query"
}

View File

@ -17,10 +17,9 @@
"__experimentalRole": "content"
},
"citation": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "cite",
"default": "",
"__experimentalRole": "content"
},
"align": {
@ -42,8 +41,7 @@
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true,
"fontAppearance": true
"fontSize": true
}
},
"color": {
@ -54,6 +52,12 @@
"background": true,
"text": true
}
},
"layout": {
"allowEditing": false
},
"spacing": {
"blockGap": true
}
},
"styles": [

View File

@ -16,7 +16,7 @@
*
* @return string The search block markup.
*/
function render_block_core_search( $attributes, $content, $block ) {
function render_block_core_search( $attributes ) {
// Older versions of the Search block defaulted the label and buttonText
// attributes to `__( 'Search' )` meaning that many posts contain `<!--
// wp:search /-->`. Support these by defaulting an undefined label and
@ -36,7 +36,6 @@ function render_block_core_search( $attributes, $content, $block ) {
$show_button = ( ! empty( $attributes['buttonPosition'] ) && 'no-button' === $attributes['buttonPosition'] ) ? false : true;
$button_position = $show_button ? $attributes['buttonPosition'] : null;
$query_params = ( ! empty( $attributes['query'] ) ) ? $attributes['query'] : array();
$button_behavior = ( ! empty( $attributes['buttonBehavior'] ) ) ? $attributes['buttonBehavior'] : 'default';
$button = '';
$query_params_markup = '';
$inline_styles = styles_for_block_core_search( $attributes );
@ -78,29 +77,19 @@ function render_block_core_search( $attributes, $content, $block ) {
$input->set_attribute( 'value', get_search_query() );
$input->set_attribute( 'placeholder', $attributes['placeholder'] );
$is_expandable_searchfield = 'button-only' === $button_position && 'expand-searchfield' === $button_behavior;
// If it's interactive, enqueue the script module and add the directives.
$is_expandable_searchfield = 'button-only' === $button_position;
if ( $is_expandable_searchfield ) {
$input->set_attribute( 'data-wp-bind--aria-hidden', '!context.core.search.isSearchInputVisible' );
$input->set_attribute( 'data-wp-bind--tabindex', 'selectors.core.search.tabindex' );
// Adding these attributes manually is needed until the Interactivity API SSR logic is added to core.
wp_enqueue_script_module( '@wordpress/block-library/search' );
$input->set_attribute( 'data-wp-bind--aria-hidden', '!context.isSearchInputVisible' );
$input->set_attribute( 'data-wp-bind--tabindex', 'state.tabindex' );
// Adding these attributes manually is needed until the Interactivity API
// SSR logic is added to core.
$input->set_attribute( 'aria-hidden', 'true' );
$input->set_attribute( 'tabindex', '-1' );
}
// If the script already exists, there is no point in removing it from viewScript.
$view_js_file = 'wp-block-search-view';
if ( ! wp_script_is( $view_js_file ) ) {
$script_handles = $block->block_type->view_script_handles;
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
if ( ! $is_expandable_searchfield && in_array( $view_js_file, $script_handles, true ) ) {
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
}
// If the script is needed, but it was previously removed, add it again.
if ( $is_expandable_searchfield && ! in_array( $view_js_file, $script_handles, true ) ) {
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
}
}
}
if ( count( $query_params ) > 0 ) {
@ -144,13 +133,15 @@ function render_block_core_search( $attributes, $content, $block ) {
if ( $button->next_tag() ) {
$button->add_class( implode( ' ', $button_classes ) );
if ( 'expand-searchfield' === $attributes['buttonBehavior'] && 'button-only' === $attributes['buttonPosition'] ) {
$button->set_attribute( 'data-wp-bind--aria-label', 'selectors.core.search.ariaLabel' );
$button->set_attribute( 'data-wp-bind--aria-controls', 'selectors.core.search.ariaControls' );
$button->set_attribute( 'data-wp-bind--aria-expanded', 'context.core.search.isSearchInputVisible' );
$button->set_attribute( 'data-wp-bind--type', 'selectors.core.search.type' );
$button->set_attribute( 'data-wp-on--click', 'actions.core.search.openSearchInput' );
// Adding these attributes manually is needed until the Interactivity API SSR logic is added to core.
if ( 'button-only' === $attributes['buttonPosition'] ) {
$button->set_attribute( 'data-wp-bind--aria-label', 'state.ariaLabel' );
$button->set_attribute( 'data-wp-bind--aria-controls', 'state.ariaControls' );
$button->set_attribute( 'data-wp-bind--aria-expanded', 'context.isSearchInputVisible' );
$button->set_attribute( 'data-wp-bind--type', 'state.type' );
$button->set_attribute( 'data-wp-on--click', 'actions.openSearchInput' );
// Adding these attributes manually is needed until the Interactivity
// API SSR logic is added to core.
$button->set_attribute( 'aria-label', __( 'Expand search field' ) );
$button->set_attribute( 'aria-controls', 'wp-block-search__input-' . $input_id );
$button->set_attribute( 'aria-expanded', 'false' );
@ -172,15 +163,17 @@ function render_block_core_search( $attributes, $content, $block ) {
array( 'class' => $classnames )
);
$form_directives = '';
// If it's interactive, add the directives.
if ( $is_expandable_searchfield ) {
$aria_label_expanded = __( 'Submit Search' );
$aria_label_collapsed = __( 'Expand search field' );
$form_directives = '
data-wp-interactive
data-wp-context=\'{ "core": { "search": { "isSearchInputVisible": ' . $open_by_default . ', "inputId": "' . $input_id . '", "ariaLabelExpanded": "' . $aria_label_expanded . '", "ariaLabelCollapsed": "' . $aria_label_collapsed . '" } } }\'
data-wp-class--wp-block-search__searchfield-hidden="!context.core.search.isSearchInputVisible"
data-wp-on--keydown="actions.core.search.handleSearchKeydown"
data-wp-on--focusout="actions.core.search.handleSearchFocusout"
data-wp-interactive=\'{ "namespace": "core/search" }\'
data-wp-context=\'{ "isSearchInputVisible": ' . $open_by_default . ', "inputId": "' . $input_id . '", "ariaLabelExpanded": "' . $aria_label_expanded . '", "ariaLabelCollapsed": "' . $aria_label_collapsed . '" }\'
data-wp-class--wp-block-search__searchfield-hidden="!context.isSearchInputVisible"
data-wp-on--keydown="actions.handleSearchKeydown"
data-wp-on--focusout="actions.handleSearchFocusout"
';
}
@ -203,28 +196,16 @@ function register_block_core_search() {
'render_callback' => 'render_block_core_search',
)
);
wp_register_script_module(
'@wordpress/block-library/search',
defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/search.min.js' ) : includes_url( 'blocks/search/view.min.js' ),
array( '@wordpress/interactivity' ),
defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
);
}
add_action( 'init', 'register_block_core_search' );
/**
* Ensure that the view script has the `wp-interactivity` dependency.
*
* @since 6.4.0
*
* @global WP_Scripts $wp_scripts
*/
function block_core_search_ensure_interactivity_dependency() {
global $wp_scripts;
if (
isset( $wp_scripts->registered['wp-block-search-view'] ) &&
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-search-view']->deps, true )
) {
$wp_scripts->registered['wp-block-search-view']->deps[] = 'wp-interactivity';
}
}
add_action( 'wp_print_scripts', 'block_core_search_ensure_interactivity_dependency' );
/**
* Builds the correct top level classnames for the 'core/search' block.
*
@ -249,10 +230,7 @@ function classnames_for_block_core_search( $attributes ) {
}
if ( 'button-only' === $attributes['buttonPosition'] ) {
$classnames[] = 'wp-block-search__button-only';
if ( ! empty( $attributes['buttonBehavior'] ) && 'expand-searchfield' === $attributes['buttonBehavior'] ) {
$classnames[] = 'wp-block-search__button-behavior-expand wp-block-search__searchfield-hidden';
}
$classnames[] = 'wp-block-search__button-only wp-block-search__searchfield-hidden';
}
}

View File

@ -43,10 +43,6 @@
"type": "object",
"default": {}
},
"buttonBehavior": {
"type": "string",
"default": "expand-searchfield"
},
"isSearchFieldHidden": {
"type": "boolean",
"default": false
@ -91,7 +87,6 @@
},
"html": false
},
"viewScript": "file:./view.min.js",
"editorStyle": "wp-block-search-editor",
"style": "wp-block-search"
}

View File

@ -56,11 +56,7 @@
"__experimentalFontWeight": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true,
"lineHeight": true,
"fontAppearance": true,
"letterSpacing": true,
"textTransform": true
"fontSize": true
}
}
},

View File

@ -33,7 +33,7 @@ function render_block_core_social_link( $attributes, $content, $block ) {
* The `is_email` returns false for emails with schema.
*/
if ( is_email( $url ) ) {
$url = 'mailto:' . $url;
$url = 'mailto:' . antispambot( $url );
}
/**
@ -62,10 +62,10 @@ function render_block_core_social_link( $attributes, $content, $block ) {
$processor = new WP_HTML_Tag_Processor( $link );
$processor->next_tag( 'a' );
if ( $open_in_new_tab ) {
$processor->set_attribute( 'rel', esc_attr( $rel ) . ' noopener nofollow' );
$processor->set_attribute( 'rel', trim( $rel . ' noopener nofollow' ) );
$processor->set_attribute( 'target', '_blank' );
} elseif ( '' !== $rel ) {
$processor->set_attribute( 'rel', esc_attr( $rel ) );
$processor->set_attribute( 'rel', trim( $rel ) );
}
return $processor->get_updated_html();
}
@ -194,6 +194,10 @@ function block_core_social_link_services( $service = '', $field = '' ) {
'name' => 'GitHub',
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg>',
),
'gravatar' => array(
'name' => 'Gravatar',
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M10.8001 4.69937V10.6494C10.8001 11.1001 10.9791 11.5323 11.2978 11.851C11.6165 12.1697 12.0487 12.3487 12.4994 12.3487C12.9501 12.3487 13.3824 12.1697 13.7011 11.851C14.0198 11.5323 14.1988 11.1001 14.1988 10.6494V6.69089C15.2418 7.05861 16.1371 7.75537 16.7496 8.67617C17.3622 9.59698 17.6589 10.6919 17.595 11.796C17.5311 12.9001 17.1101 13.9535 16.3954 14.7975C15.6807 15.6415 14.711 16.2303 13.6325 16.4753C12.5541 16.7202 11.4252 16.608 10.4161 16.1555C9.40691 15.703 8.57217 14.9348 8.03763 13.9667C7.50308 12.9985 7.29769 11.8828 7.45242 10.7877C7.60714 9.69266 8.11359 8.67755 8.89545 7.89537C9.20904 7.57521 9.38364 7.14426 9.38132 6.69611C9.37899 6.24797 9.19994 5.81884 8.88305 5.50195C8.56616 5.18506 8.13704 5.00601 7.68889 5.00369C7.24075 5.00137 6.80979 5.17597 6.48964 5.48956C5.09907 6.8801 4.23369 8.7098 4.04094 10.6669C3.84819 12.624 4.34 14.5873 5.43257 16.2224C6.52515 17.8575 8.15088 19.0632 10.0328 19.634C11.9146 20.2049 13.9362 20.1055 15.753 19.3529C17.5699 18.6003 19.0695 17.241 19.9965 15.5066C20.9234 13.7722 21.2203 11.7701 20.8366 9.84133C20.4528 7.91259 19.4122 6.17658 17.892 4.92911C16.3717 3.68163 14.466 2.99987 12.4994 3C12.0487 3 11.6165 3.17904 11.2978 3.49773C10.9791 3.81643 10.8001 4.24867 10.8001 4.69937Z" /></svg>',
),
'instagram' => array(
'name' => 'Instagram',
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,4.622c2.403,0,2.688,0.009,3.637,0.052c0.877,0.04,1.354,0.187,1.671,0.31c0.42,0.163,0.72,0.358,1.035,0.673 c0.315,0.315,0.51,0.615,0.673,1.035c0.123,0.317,0.27,0.794,0.31,1.671c0.043,0.949,0.052,1.234,0.052,3.637 s-0.009,2.688-0.052,3.637c-0.04,0.877-0.187,1.354-0.31,1.671c-0.163,0.42-0.358,0.72-0.673,1.035 c-0.315,0.315-0.615,0.51-1.035,0.673c-0.317,0.123-0.794,0.27-1.671,0.31c-0.949,0.043-1.233,0.052-3.637,0.052 s-2.688-0.009-3.637-0.052c-0.877-0.04-1.354-0.187-1.671-0.31c-0.42-0.163-0.72-0.358-1.035-0.673 c-0.315-0.315-0.51-0.615-0.673-1.035c-0.123-0.317-0.27-0.794-0.31-1.671C4.631,14.688,4.622,14.403,4.622,12 s0.009-2.688,0.052-3.637c0.04-0.877,0.187-1.354,0.31-1.671c0.163-0.42,0.358-0.72,0.673-1.035 c0.315-0.315,0.615-0.51,1.035-0.673c0.317-0.123,0.794-0.27,1.671-0.31C9.312,4.631,9.597,4.622,12,4.622 M12,3 C9.556,3,9.249,3.01,8.289,3.054C7.331,3.098,6.677,3.25,6.105,3.472C5.513,3.702,5.011,4.01,4.511,4.511 c-0.5,0.5-0.808,1.002-1.038,1.594C3.25,6.677,3.098,7.331,3.054,8.289C3.01,9.249,3,9.556,3,12c0,2.444,0.01,2.751,0.054,3.711 c0.044,0.958,0.196,1.612,0.418,2.185c0.23,0.592,0.538,1.094,1.038,1.594c0.5,0.5,1.002,0.808,1.594,1.038 c0.572,0.222,1.227,0.375,2.185,0.418C9.249,20.99,9.556,21,12,21s2.751-0.01,3.711-0.054c0.958-0.044,1.612-0.196,2.185-0.418 c0.592-0.23,1.094-0.538,1.594-1.038c0.5-0.5,0.808-1.002,1.038-1.594c0.222-0.572,0.375-1.227,0.418-2.185 C20.99,14.751,21,14.444,21,12s-0.01-2.751-0.054-3.711c-0.044-0.958-0.196-1.612-0.418-2.185c-0.23-0.592-0.538-1.094-1.038-1.594 c-0.5-0.5-1.002-0.808-1.594-1.038c-0.572-0.222-1.227-0.375-2.185-0.418C14.751,3.01,14.444,3,12,3L12,3z M12,7.378 c-2.552,0-4.622,2.069-4.622,4.622S9.448,16.622,12,16.622s4.622-2.069,4.622-4.622S14.552,7.378,12,7.378z M12,15 c-1.657,0-3-1.343-3-3s1.343-3,3-3s3,1.343,3,3S13.657,15,12,15z M16.804,6.116c-0.596,0-1.08,0.484-1.08,1.08 s0.484,1.08,1.08,1.08c0.596,0,1.08-0.484,1.08-1.08S17.401,6.116,16.804,6.116z"></path></svg>',

View File

@ -12,10 +12,9 @@
"default": false
},
"caption": {
"type": "string",
"source": "html",
"selector": "figcaption",
"default": ""
"type": "rich-text",
"source": "rich-text",
"selector": "figcaption"
},
"head": {
"type": "array",
@ -30,8 +29,8 @@
"selector": "td,th",
"query": {
"content": {
"type": "string",
"source": "html"
"type": "rich-text",
"source": "rich-text"
},
"tag": {
"type": "string",
@ -75,8 +74,8 @@
"selector": "td,th",
"query": {
"content": {
"type": "string",
"source": "html"
"type": "rich-text",
"source": "rich-text"
},
"tag": {
"type": "string",
@ -120,8 +119,8 @@
"selector": "td,th",
"query": {
"content": {
"type": "string",
"source": "html"
"type": "rich-text",
"source": "rich-text"
},
"tag": {
"type": "string",

View File

@ -43,10 +43,10 @@ function render_block_core_template_part( $attributes ) {
if ( $template_part_post ) {
// A published post might already exist if this template part was customized elsewhere
// or if it's part of a customized template.
$content = $template_part_post->post_content;
$area_terms = get_the_terms( $template_part_post, 'wp_template_part_area' );
if ( ! is_wp_error( $area_terms ) && false !== $area_terms ) {
$area = $area_terms[0]->name;
$block_template = _build_block_template_result_from_post( $template_part_post );
$content = $block_template->content;
if ( isset( $block_template->area ) ) {
$area = $block_template->area;
}
/**
* Fires when a block template part is loaded from a template post stored in the database.
@ -70,6 +70,12 @@ function render_block_core_template_part( $attributes ) {
if ( isset( $block_template->area ) ) {
$area = $block_template->area;
}
// Needed for the `render_block_core_template_part_file` and `render_block_core_template_part_none` actions below.
$block_template_file = _get_block_template_file( 'wp_template_part', $attributes['slug'] );
if ( $block_template_file ) {
$template_part_file_path = $block_template_file['path'];
}
}
if ( '' !== $content && null !== $content ) {
@ -275,8 +281,8 @@ function register_block_core_template_part() {
register_block_type_from_metadata(
__DIR__ . '/template-part',
array(
'render_callback' => 'render_block_core_template_part',
'variations' => build_template_part_block_variations(),
'render_callback' => 'render_block_core_template_part',
'variation_callback' => 'build_template_part_block_variations',
)
);
}

View File

@ -23,7 +23,8 @@
"supports": {
"align": true,
"html": false,
"reusable": false
"reusable": false,
"renaming": false
},
"editorStyle": "wp-block-template-part-editor"
}

View File

@ -9,10 +9,9 @@
"textdomain": "default",
"attributes": {
"content": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "pre",
"default": "",
"__unstablePreserveWhiteSpace": true,
"__experimentalRole": "content"
},
@ -40,8 +39,7 @@
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalDefaultControls": {
"fontSize": true,
"fontAppearance": true
"fontSize": true
}
},
"spacing": {

View File

@ -15,8 +15,8 @@
"attribute": "autoplay"
},
"caption": {
"type": "string",
"source": "html",
"type": "rich-text",
"source": "rich-text",
"selector": "figcaption",
"__experimentalRole": "content"
},

View File

@ -1,4 +1,5 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/widget-group",
"category": "widgets",

View File

@ -1714,7 +1714,7 @@ function wp_default_styles( $styles ) {
);
$package_styles = array(
'block-editor' => array( 'wp-components' ),
'block-editor' => array( 'wp-components', 'wp-preferences' ),
'block-library' => array(),
'block-directory' => array(),
'components' => array(),
@ -1726,17 +1726,20 @@ function wp_default_styles( $styles ) {
'wp-edit-blocks',
'wp-block-library',
'wp-commands',
'wp-preferences',
),
'editor' => array(
'wp-components',
'wp-block-editor',
'wp-reusable-blocks',
'wp-patterns',
'wp-preferences',
),
'format-library' => array(),
'list-reusable-blocks' => array( 'wp-components' ),
'reusable-blocks' => array( 'wp-components' ),
'patterns' => array( 'wp-components' ),
'preferences' => array( 'wp-components' ),
'nux' => array( 'wp-components' ),
'widgets' => array(
'wp-components',
@ -1748,6 +1751,7 @@ function wp_default_styles( $styles ) {
'wp-block-library',
'wp-reusable-blocks',
'wp-patterns',
'wp-preferences',
),
'customize-widgets' => array(
'wp-widgets',
@ -1756,12 +1760,14 @@ function wp_default_styles( $styles ) {
'wp-block-library',
'wp-reusable-blocks',
'wp-patterns',
'wp-preferences',
),
'edit-site' => array(
'wp-components',
'wp-block-editor',
'wp-edit-blocks',
'wp-commands',
'wp-preferences',
),
);

View File

@ -1,3 +1,3 @@
<blockquote class="wp-block-quote"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><cite>Matt Mullenweg, 2017</cite></blockquote>
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><cite>Matt Mullenweg, 2017</cite></blockquote>

View File

@ -1,3 +1,3 @@
<blockquote class="wp-block-quote is-style-large"><p>There is no greater agony than bearing an untold story inside you.</p><cite>Maya Angelou</cite></blockquote>
<blockquote class="wp-block-quote is-style-large is-layout-flow wp-block-quote-is-layout-flow"><p>There is no greater agony than bearing an untold story inside you.</p><cite>Maya Angelou</cite></blockquote>

View File

@ -64,3 +64,9 @@ remove_action( 'init', 'register_block_core_social_link' );
remove_action( 'init', 'register_block_core_tag_cloud' );
remove_action( 'init', 'register_block_core_template_part' );
remove_action( 'init', 'register_block_core_term_description' );
// Temporary hook removals to prevent impacting the phpunit tests timing.
remove_action( 'registered_post_type', 'block_core_navigation_link_register_post_type_variation' );
remove_action( 'registered_taxonomy', 'block_core_navigation_link_register_taxonomy_variation' );
remove_action( 'unregistered_post_type', 'block_core_navigation_link_unregister_post_type_variation' );
remove_action( 'unregistered_taxonomy', 'block_core_navigation_link_unregister_taxonomy_variation' );

View File

@ -3,60 +3,90 @@
*/
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
/**
* WordPress dependencies
*/
const DependencyExtractionPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
/**
* Internal dependencies
*/
const { baseDir, getBaseConfig, normalizeJoin, stylesTransform } = require( './shared' );
const {
baseDir,
getBaseConfig,
normalizeJoin,
stylesTransform,
} = require( './shared' );
const {
isDynamic,
toDirectoryName,
getStableBlocksMetadata,
} = require( '../release/sync-stable-blocks' );
module.exports = function( env = { environment: 'production', watch: false, buildTarget: false } ) {
module.exports = function (
env = { environment: 'production', watch: false, buildTarget: false }
) {
const mode = env.environment;
const suffix = mode === 'production' ? '.min' : '';
let buildTarget = env.buildTarget ? env.buildTarget : ( mode === 'production' ? 'build' : 'src' );
let buildTarget = env.buildTarget
? env.buildTarget
: mode === 'production'
? 'build'
: 'src';
buildTarget = buildTarget + '/wp-includes';
const blocks = getStableBlocksMetadata();
const dynamicBlockFolders = blocks.filter( isDynamic ).map( toDirectoryName );
const dynamicBlockFolders = blocks
.filter( isDynamic )
.map( toDirectoryName );
const blockFolders = blocks.map( toDirectoryName );
const blockPHPFiles = {
'widgets/src/blocks/legacy-widget/index.php': 'wp-includes/blocks/legacy-widget.php',
'widgets/src/blocks/widget-group/index.php': 'wp-includes/blocks/widget-group.php',
'widgets/src/blocks/legacy-widget/index.php':
'wp-includes/blocks/legacy-widget.php',
'widgets/src/blocks/widget-group/index.php':
'wp-includes/blocks/widget-group.php',
...dynamicBlockFolders.reduce( ( files, blockName ) => {
files[ `block-library/src/${ blockName }/index.php` ] = `wp-includes/blocks/${ blockName }.php`;
files[
`block-library/src/${ blockName }/index.php`
] = `wp-includes/blocks/${ blockName }.php`;
return files;
}, {} ),
};
const blockMetadataFiles = {
'widgets/src/blocks/legacy-widget/block.json': 'wp-includes/blocks/legacy-widget/block.json',
'widgets/src/blocks/widget-group/block.json': 'wp-includes/blocks/widget-group/block.json',
'widgets/src/blocks/legacy-widget/block.json':
'wp-includes/blocks/legacy-widget/block.json',
'widgets/src/blocks/widget-group/block.json':
'wp-includes/blocks/widget-group/block.json',
...blockFolders.reduce( ( files, blockName ) => {
files[ `block-library/src/${ blockName }/block.json` ] = `wp-includes/blocks/${ blockName }/block.json`;
files[
`block-library/src/${ blockName }/block.json`
] = `wp-includes/blocks/${ blockName }/block.json`;
return files;
}, {} ),
};
const blockPHPCopies = Object.keys( blockPHPFiles ).map( ( filename ) => ( {
from: normalizeJoin(baseDir, `node_modules/@wordpress/${ filename }` ),
to: normalizeJoin(baseDir, `src/${ blockPHPFiles[ filename ] }` ),
from: normalizeJoin( baseDir, `node_modules/@wordpress/${ filename }` ),
to: normalizeJoin( baseDir, `src/${ blockPHPFiles[ filename ] }` ),
} ) );
const blockMetadataCopies = Object.keys( blockMetadataFiles ).map( ( filename ) => ( {
from: normalizeJoin(baseDir, `node_modules/@wordpress/${ filename }` ),
to: normalizeJoin(baseDir, `src/${ blockMetadataFiles[ filename ] }` ),
} ) );
const blockMetadataCopies = Object.keys( blockMetadataFiles ).map(
( filename ) => ( {
from: normalizeJoin(
baseDir,
`node_modules/@wordpress/${ filename }`
),
to: normalizeJoin(
baseDir,
`src/${ blockMetadataFiles[ filename ] }`
),
} )
);
const blockStylesheetCopies = blockFolders.map( ( blockName ) => ( {
from: normalizeJoin(baseDir, `node_modules/@wordpress/block-library/build-style/${ blockName }/*.css` ),
to: normalizeJoin(baseDir, `${ buildTarget }/blocks/${ blockName }/[name]${ suffix }.css` ),
from: normalizeJoin(
baseDir,
`node_modules/@wordpress/block-library/build-style/${ blockName }/*.css`
),
to: normalizeJoin(
baseDir,
`${ buildTarget }/blocks/${ blockName }/[name]${ suffix }.css`
),
transform: stylesTransform( mode ),
noErrorOnMissing: true,
} ) );
@ -64,41 +94,45 @@ module.exports = function( env = { environment: 'production', watch: false, buil
const baseConfig = getBaseConfig( env );
const config = {
...baseConfig,
// Todo: This list need of entry points need to be automatically fetched from the package
// We shouldn't have to maintain it manually.
entry: {
'navigation/view': normalizeJoin( baseDir, 'node_modules/@wordpress/block-library/build-module/navigation/view' ),
'image/view': normalizeJoin( baseDir, 'node_modules/@wordpress/block-library/build-module/image/view' ),
'query/view': normalizeJoin( baseDir, 'node_modules/@wordpress/block-library/build-module/query/view' ),
'file/view': normalizeJoin( baseDir, 'node_modules/@wordpress/block-library/build-module/file/view' ),
'search/view': normalizeJoin( baseDir, 'node_modules/@wordpress/block-library/build-module/search/view' ),
navigation: normalizeJoin(
baseDir,
'node_modules/@wordpress/block-library/build-module/navigation/view'
),
image: normalizeJoin(
baseDir,
'node_modules/@wordpress/block-library/build-module/image/view'
),
query: normalizeJoin(
baseDir,
'node_modules/@wordpress/block-library/build-module/query/view'
),
file: normalizeJoin(
baseDir,
'node_modules/@wordpress/block-library/build-module/file/view'
),
search: normalizeJoin(
baseDir,
'node_modules/@wordpress/block-library/build-module/search/view'
),
},
experiments: {
outputModule: true,
},
output: {
devtoolNamespace: 'wp',
filename: `./blocks/[name]${ suffix }.js`,
path: normalizeJoin( baseDir, buildTarget ),
chunkLoadingGlobal: `__WordPressPrivateInteractivityAPI__`,
library: {
type: 'module',
},
environment: { module: true },
},
resolve: {
alias: {
'@wordpress/interactivity': normalizeJoin( baseDir, 'node_modules/@wordpress/interactivity/src/index.js' ),
},
},
optimization: {
...baseConfig.optimization,
runtimeChunk: {
name: 'private-interactivity',
},
splitChunks: {
cacheGroups: {
interactivity: {
name: 'private-interactivity',
test: /^(?!.*[\\/]block-library[\\/]).*$/,
filename: `./js/dist/interactivity${suffix}.js`,
chunks: 'all',
minSize: 0,
priority: -10,
},
},
},
externalsType: 'module',
externals: {
'@wordpress/interactivity': '@wordpress/interactivity',
},
module: {
rules: [
@ -108,7 +142,8 @@ module.exports = function( env = { environment: 'production', watch: false, buil
{
loader: require.resolve( 'babel-loader' ),
options: {
cacheDirectory: process.env.BABEL_CACHE_DIRECTORY || true,
cacheDirectory:
process.env.BABEL_CACHE_DIRECTORY || true,
babelrc: false,
configFile: false,
presets: [
@ -128,10 +163,6 @@ module.exports = function( env = { environment: 'production', watch: false, buil
},
plugins: [
...baseConfig.plugins,
new DependencyExtractionPlugin( {
injectPolyfill: false,
useDefaults: false,
} ),
new CopyWebpackPlugin( {
patterns: [
...blockPHPCopies,

93
tools/webpack/modules.js Normal file
View File

@ -0,0 +1,93 @@
/**
* WordPress dependencies
*/
const DependencyExtractionPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
/**
* Internal dependencies
*/
const {
baseDir,
getBaseConfig,
normalizeJoin,
MODULES,
WORDPRESS_NAMESPACE,
} = require( './shared' );
module.exports = function (
env = { environment: 'production', watch: false, buildTarget: false }
) {
const mode = env.environment;
const suffix = mode === 'production' ? '.min' : '';
let buildTarget = env.buildTarget
? env.buildTarget
: mode === 'production'
? 'build'
: 'src';
buildTarget = buildTarget + '/wp-includes';
const baseConfig = getBaseConfig( env );
const config = {
...baseConfig,
entry: MODULES.map( ( packageName ) =>
packageName.replace( WORDPRESS_NAMESPACE, '' )
).reduce( ( memo, packageName ) => {
memo[ packageName ] = {
import: normalizeJoin(
baseDir,
`node_modules/@wordpress/${ packageName }`
),
};
return memo;
}, {} ),
experiments: {
outputModule: true,
},
output: {
devtoolNamespace: 'wp',
filename: `[name]${ suffix }.js`,
path: normalizeJoin( baseDir, `${ buildTarget }/js/dist` ),
library: {
type: 'module',
},
environment: { module: true },
},
module: {
rules: [
{
test: /\.(j|t)sx?$/,
use: [
{
loader: require.resolve( 'babel-loader' ),
options: {
cacheDirectory:
process.env.BABEL_CACHE_DIRECTORY || true,
babelrc: false,
configFile: false,
presets: [
[
'@babel/preset-react',
{
runtime: 'automatic',
importSource: 'preact',
},
],
],
},
},
],
},
],
},
plugins: [
...baseConfig.plugins,
new DependencyExtractionPlugin( {
injectPolyfill: false,
useDefaults: false,
} ),
],
};
return config;
};

View File

@ -16,7 +16,15 @@ const DependencyExtractionPlugin = require( '@wordpress/dependency-extraction-we
/**
* Internal dependencies
*/
const { baseDir, getBaseConfig, normalizeJoin, stylesTransform } = require( './shared' );
const {
baseDir,
getBaseConfig,
normalizeJoin,
stylesTransform,
BUNDLED_PACKAGES,
MODULES,
WORDPRESS_NAMESPACE,
} = require( './shared' );
const { dependencies } = require( '../../package' );
const exportDefaultPackages = [
@ -40,36 +48,50 @@ const exportDefaultPackages = [
*/
function mapVendorCopies( vendors, buildTarget ) {
return Object.keys( vendors ).map( ( filename ) => ( {
from: normalizeJoin(baseDir, `node_modules/${ vendors[ filename ] }` ),
to: normalizeJoin(baseDir, `${ buildTarget }/js/dist/vendor/${ filename }` ),
from: normalizeJoin( baseDir, `node_modules/${ vendors[ filename ] }` ),
to: normalizeJoin(
baseDir,
`${ buildTarget }/js/dist/vendor/${ filename }`
),
} ) );
}
module.exports = function( env = { environment: 'production', watch: false, buildTarget: false } ) {
module.exports = function (
env = { environment: 'production', watch: false, buildTarget: false }
) {
const mode = env.environment;
const suffix = mode === 'production' ? '.min' : '';
let buildTarget = env.buildTarget ? env.buildTarget : ( mode === 'production' ? 'build' : 'src' );
buildTarget = buildTarget + '/wp-includes';
let buildTarget = env.buildTarget
? env.buildTarget
: mode === 'production'
? 'build'
: 'src';
buildTarget = buildTarget + '/wp-includes';
const WORDPRESS_NAMESPACE = '@wordpress/';
const BUNDLED_PACKAGES = [ '@wordpress/icons', '@wordpress/interface', '@wordpress/interactivity', '@wordpress/sync' ];
const packages = Object.keys( dependencies )
.filter( ( packageName ) =>
! BUNDLED_PACKAGES.includes( packageName ) &&
packageName.startsWith( WORDPRESS_NAMESPACE )
)
.map( ( packageName ) => packageName.replace( WORDPRESS_NAMESPACE, '' ) );
.filter(
( packageName ) =>
! BUNDLED_PACKAGES.includes( packageName ) &&
! MODULES.includes( packageName ) &&
packageName.startsWith( WORDPRESS_NAMESPACE )
)
.map( ( packageName ) =>
packageName.replace( WORDPRESS_NAMESPACE, '' )
);
const vendors = {
'lodash.js': 'lodash/lodash.js',
'wp-polyfill.js': '@wordpress/babel-preset-default/build/polyfill.js',
'wp-polyfill-fetch.js': 'whatwg-fetch/dist/fetch.umd.js',
'wp-polyfill-element-closest.js': 'element-closest/browser.js',
'wp-polyfill-node-contains.js': 'polyfill-library/polyfills/__dist/Node.prototype.contains/raw.js',
'wp-polyfill-node-contains.js':
'polyfill-library/polyfills/__dist/Node.prototype.contains/raw.js',
'wp-polyfill-url.js': 'core-js-url-browser/url.js',
'wp-polyfill-dom-rect.js': 'polyfill-library/polyfills/__dist/DOMRect/raw.js',
'wp-polyfill-dom-rect.js':
'polyfill-library/polyfills/__dist/DOMRect/raw.js',
'wp-polyfill-formdata.js': 'formdata-polyfill/FormData.js',
'wp-polyfill-object-fit.js': 'objectFitPolyfill/src/objectFitPolyfill.js',
'wp-polyfill-object-fit.js':
'objectFitPolyfill/src/objectFitPolyfill.js',
'wp-polyfill-inert.js': 'wicg-inert/dist/inert.js',
'moment.js': 'moment/moment.js',
'react.js': 'react/umd/react.development.js',
@ -79,11 +101,13 @@ module.exports = function( env = { environment: 'production', watch: false, buil
const minifiedVendors = {
'lodash.min.js': 'lodash/lodash.min.js',
'wp-polyfill.min.js': '@wordpress/babel-preset-default/build/polyfill.min.js',
'wp-polyfill.min.js':
'@wordpress/babel-preset-default/build/polyfill.min.js',
'wp-polyfill-element-closest.min.js': 'element-closest/browser.js',
'wp-polyfill-formdata.min.js': 'formdata-polyfill/formdata.min.js',
'wp-polyfill-url.min.js': 'core-js-url-browser/url.min.js',
'wp-polyfill-object-fit.min.js': 'objectFitPolyfill/dist/objectFitPolyfill.min.js',
'wp-polyfill-object-fit.min.js':
'objectFitPolyfill/dist/objectFitPolyfill.min.js',
'wp-polyfill-inert.min.js': 'wicg-inert/dist/inert.min.js',
'moment.min.js': 'moment/min/moment.min.js',
'react.min.js': 'react/umd/react.production.min.js',
@ -93,39 +117,55 @@ module.exports = function( env = { environment: 'production', watch: false, buil
const minifyVendors = {
'regenerator-runtime.min.js': 'regenerator-runtime/runtime.js',
'wp-polyfill-fetch.min.js': 'whatwg-fetch/dist/fetch.umd.js',
'wp-polyfill-node-contains.min.js': 'polyfill-library/polyfills/__dist/Node.prototype.contains/raw.js',
'wp-polyfill-dom-rect.min.js': 'polyfill-library/polyfills/__dist/DOMRect/raw.js',
'wp-polyfill-node-contains.min.js':
'polyfill-library/polyfills/__dist/Node.prototype.contains/raw.js',
'wp-polyfill-dom-rect.min.js':
'polyfill-library/polyfills/__dist/DOMRect/raw.js',
};
const phpFiles = {
'block-serialization-default-parser/class-wp-block-parser.php': 'wp-includes/class-wp-block-parser.php',
'block-serialization-default-parser/class-wp-block-parser-frame.php': 'wp-includes/class-wp-block-parser-frame.php',
'block-serialization-default-parser/class-wp-block-parser-block.php': 'wp-includes/class-wp-block-parser-block.php',
'block-serialization-default-parser/class-wp-block-parser.php':
'wp-includes/class-wp-block-parser.php',
'block-serialization-default-parser/class-wp-block-parser-frame.php':
'wp-includes/class-wp-block-parser-frame.php',
'block-serialization-default-parser/class-wp-block-parser-block.php':
'wp-includes/class-wp-block-parser-block.php',
};
const developmentCopies = mapVendorCopies( vendors, buildTarget );
const minifiedCopies = mapVendorCopies( minifiedVendors, buildTarget );
const minifyCopies = mapVendorCopies( minifyVendors, buildTarget ).map( ( copyCommand ) => {
return {
...copyCommand,
transform: ( content ) => {
return UglifyJS.minify( content.toString() ).code;
},
};
} );
const minifyCopies = mapVendorCopies( minifyVendors, buildTarget ).map(
( copyCommand ) => {
return {
...copyCommand,
transform: ( content ) => {
return UglifyJS.minify( content.toString() ).code;
},
};
}
);
let vendorCopies = mode === "development" ? developmentCopies : [ ...minifiedCopies, ...minifyCopies ];
let vendorCopies =
mode === 'development'
? developmentCopies
: [ ...minifiedCopies, ...minifyCopies ];
let cssCopies = packages.map( ( packageName ) => ( {
from: normalizeJoin(baseDir, `node_modules/@wordpress/${ packageName }/build-style/*.css` ),
to: normalizeJoin(baseDir, `${ buildTarget }/css/dist/${ packageName }/[name]${ suffix }.css` ),
from: normalizeJoin(
baseDir,
`node_modules/@wordpress/${ packageName }/build-style/*.css`
),
to: normalizeJoin(
baseDir,
`${ buildTarget }/css/dist/${ packageName }/[name]${ suffix }.css`
),
transform: stylesTransform( mode ),
noErrorOnMissing: true,
} ) );
const phpCopies = Object.keys( phpFiles ).map( ( filename ) => ( {
from: normalizeJoin(baseDir, `node_modules/@wordpress/${ filename }` ),
to: normalizeJoin(baseDir, `src/${ phpFiles[ filename ] }` ),
from: normalizeJoin( baseDir, `node_modules/@wordpress/${ filename }` ),
to: normalizeJoin( baseDir, `src/${ phpFiles[ filename ] }` ),
} ) );
const baseConfig = getBaseConfig( env );
@ -133,7 +173,10 @@ module.exports = function( env = { environment: 'production', watch: false, buil
...baseConfig,
entry: packages.reduce( ( memo, packageName ) => {
memo[ packageName ] = {
import: normalizeJoin(baseDir, `node_modules/@wordpress/${ packageName }` ),
import: normalizeJoin(
baseDir,
`node_modules/@wordpress/${ packageName }`
),
library: {
name: [ 'wp', camelCaseDash( packageName ) ],
type: 'window',
@ -148,7 +191,7 @@ module.exports = function( env = { environment: 'production', watch: false, buil
output: {
devtoolNamespace: 'wp',
filename: `[name]${ suffix }.js`,
path: normalizeJoin(baseDir, `${ buildTarget }/js/dist` ),
path: normalizeJoin( baseDir, `${ buildTarget }/js/dist` ),
},
plugins: [
...baseConfig.plugins,
@ -158,17 +201,17 @@ module.exports = function( env = { environment: 'production', watch: false, buil
combinedOutputFile: `../../assets/script-loader-packages${ suffix }.php`,
} ),
new CopyWebpackPlugin( {
patterns: [
...vendorCopies,
...cssCopies,
...phpCopies,
],
patterns: [ ...vendorCopies, ...cssCopies, ...phpCopies ],
} ),
],
};
if ( config.mode === 'development' ) {
config.plugins.push( new LiveReloadPlugin( { port: process.env.WORDPRESS_LIVE_RELOAD_PORT || 35729 } ) );
config.plugins.push(
new LiveReloadPlugin( {
port: process.env.WORDPRESS_LIVE_RELOAD_PORT || 35729,
} )
);
}
return config;

View File

@ -20,7 +20,7 @@ const getBaseConfig = ( env ) => {
new TerserPlugin( {
extractComments: false,
} ),
]
],
},
module: {
rules: [
@ -32,10 +32,7 @@ const getBaseConfig = ( env ) => {
],
},
resolve: {
modules: [
baseDir,
'node_modules',
],
modules: [ baseDir, 'node_modules' ],
alias: {
'lodash-es': 'lodash',
},
@ -70,15 +67,20 @@ const getBaseConfig = ( env ) => {
const stylesTransform = ( mode ) => ( content ) => {
return postcss( [
require( 'cssnano' )( {
preset: mode === 'production' ? 'default' : [
'default',
{
discardComments: {
removeAll: ! content.includes( 'Copyright' ) && ! content.includes( 'License' ),
},
normalizeWhitespace: false,
},
],
preset:
mode === 'production'
? 'default'
: [
'default',
{
discardComments: {
removeAll:
! content.includes( 'Copyright' ) &&
! content.includes( 'License' ),
},
normalizeWhitespace: false,
},
],
} ),
] )
.process( content, { from: 'src/app.css', to: 'dest/app.css' } )
@ -87,10 +89,22 @@ const stylesTransform = ( mode ) => ( content ) => {
const normalizeJoin = ( ...paths ) => join( ...paths ).replace( /\\/g, '/' );
const BUNDLED_PACKAGES = [
'@wordpress/dataviews',
'@wordpress/icons',
'@wordpress/interface',
'@wordpress/interactivity',
'@wordpress/sync',
];
const MODULES = [ '@wordpress/interactivity' ];
const WORDPRESS_NAMESPACE = '@wordpress/';
module.exports = {
baseDir,
getBaseConfig,
normalizeJoin,
stylesTransform,
BUNDLED_PACKAGES,
MODULES,
WORDPRESS_NAMESPACE,
};

View File

@ -2,6 +2,7 @@ const blocksConfig = require( './tools/webpack/blocks' );
const developmentConfig = require( './tools/webpack/development' );
const mediaConfig = require( './tools/webpack/media' );
const packagesConfig = require( './tools/webpack/packages' );
const modulesConfig = require( './tools/webpack/modules' );
module.exports = function( env = { environment: "production", watch: false, buildTarget: false } ) {
if ( ! env.watch ) {
@ -17,6 +18,7 @@ module.exports = function( env = { environment: "production", watch: false, buil
...developmentConfig( env ),
mediaConfig( env ),
packagesConfig( env ),
modulesConfig( env ),
];
return config;