Skip to content

Commit 190b44e

Browse files
Merge branch 'WordPress:trunk' into trunk
2 parents e7679f1 + 6eb365e commit 190b44e

File tree

184 files changed

+2679
-1155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+2679
-1155
lines changed

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Gutenberg
22

3-
Copyright 2016-2024 by the contributors
3+
Copyright 2016-2025 by the contributors
44

55
**License for Contributions (on and after April 15, 2021)**
66

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import fs from 'node:fs/promises';
5+
import babel from '@babel/core';
6+
7+
/**
8+
* Returns `meta.tags` from a Storybook file.
9+
*
10+
* @param {string} filePath
11+
* @return {Promise<string[]>} Array of tags.
12+
*/
13+
export async function getTagsFromStorybook( filePath ) {
14+
const fileContent = await fs.readFile( filePath, 'utf8' );
15+
const parsedFile = babel.parse( fileContent, {
16+
filename: filePath,
17+
} );
18+
19+
const meta = parsedFile.program.body.find(
20+
( node ) =>
21+
node.type === 'VariableDeclaration' &&
22+
node.declarations[ 0 ].id.name === 'meta'
23+
);
24+
25+
return (
26+
meta.declarations[ 0 ].init.properties
27+
.find( ( node ) => node.key.name === 'tags' )
28+
?.value.elements.map( ( node ) => node.value ) ?? []
29+
);
30+
}

bin/api-docs/gen-components-docs/index.mjs

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import path from 'path';
1111
*/
1212
import { generateMarkdownDocs } from './markdown/index.mjs';
1313
import { getDescriptionsForSubcomponents } from './get-subcomponent-descriptions.mjs';
14+
import { getTagsFromStorybook } from './get-tags-from-storybook.mjs';
1415

1516
const MANIFEST_GLOB = 'packages/components/src/**/docs-manifest.json';
1617

@@ -113,9 +114,17 @@ await Promise.all(
113114
} ) ?? []
114115
);
115116

117+
const tags = await getTagsFromStorybook(
118+
path.resolve(
119+
path.dirname( manifestPath ),
120+
'stories/index.story.tsx'
121+
)
122+
);
123+
116124
const docs = generateMarkdownDocs( {
117125
typeDocs,
118126
subcomponentTypeDocs,
127+
tags,
119128
} );
120129
const outputFile = path.resolve(
121130
path.dirname( manifestPath ),

bin/api-docs/gen-components-docs/markdown/index.mjs

+19-13
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,32 @@ import json2md from 'json2md';
99
import { generateMarkdownPropsJson } from './props.mjs';
1010

1111
/**
12-
* If the string is contentful, ensure that it ends with a single newline.
13-
* Otherwise normalize to `undefined`.
12+
* Converter for strings that are already formatted as Markdown.
1413
*
15-
* @param {string} [str]
14+
* @param {string} [input]
15+
* @return {string} The trimmed input if it is contentful, otherwise an empty string.
1616
*/
17-
function normalizeTrailingNewline( str ) {
18-
if ( ! str?.trim() ) {
19-
return undefined;
20-
}
21-
return str.replace( /\n*$/, '\n' );
22-
}
17+
json2md.converters.md = ( input ) => {
18+
return input?.trim() || '';
19+
};
2320

24-
export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
21+
export function generateMarkdownDocs( {
22+
typeDocs,
23+
subcomponentTypeDocs,
24+
tags,
25+
} ) {
2526
const mainDocsJson = [
2627
{ h1: typeDocs.displayName },
2728
'<!-- This file is generated automatically and cannot be edited directly. Make edits via TypeScript types and TSDocs. -->',
29+
tags.includes( 'status-private' ) && [
30+
{
31+
p: '🔒 This component is locked as a [private API](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-private-apis/). We do not yet recommend using this outside of the Gutenberg project.',
32+
},
33+
],
2834
{
2935
p: `<p class="callout callout-info">See the <a href="https://wordpress.github.io/gutenberg/?path=/docs/components-${ typeDocs.displayName.toLowerCase() }--docs">WordPress Storybook</a> for more detailed, interactive documentation.</p>`,
3036
},
31-
normalizeTrailingNewline( typeDocs.description ),
37+
{ md: typeDocs.description },
3238
...generateMarkdownPropsJson( typeDocs.props ),
3339
];
3440

@@ -39,7 +45,7 @@ export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
3945
{
4046
h3: subcomponentTypeDoc.displayName,
4147
},
42-
normalizeTrailingNewline( subcomponentTypeDoc.description ),
48+
{ md: subcomponentTypeDoc.description },
4349
...generateMarkdownPropsJson( subcomponentTypeDoc.props, {
4450
headingLevel: 4,
4551
} ),
@@ -49,5 +55,5 @@ export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
4955

5056
return json2md(
5157
[ ...mainDocsJson, ...subcomponentDocsJson ].filter( Boolean )
52-
);
58+
).replace( /\n+$/gm, '\n' ); // clean unnecessary consecutive newlines
5359
}

bin/api-docs/gen-components-docs/markdown/props.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export function generateMarkdownPropsJson( props, { headingLevel = 2 } = {} ) {
3333

3434
return [
3535
{ [ `h${ headingLevel + 1 }` ]: `\`${ key }\`` },
36-
prop.description,
3736
{
3837
ul: [
3938
`Type: \`${ renderPropType( prop.type ) }\``,
@@ -42,6 +41,7 @@ export function generateMarkdownPropsJson( props, { headingLevel = 2 } = {} ) {
4241
`Default: \`${ prop.defaultValue.value }\``,
4342
].filter( Boolean ),
4443
},
44+
{ md: prop.description },
4545
];
4646
} )
4747
.filter( Boolean );

bin/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"noEmit": true,
1717
"outDir": ".cache"
1818
},
19+
"include": [],
1920
"files": [
2021
"./api-docs/update-api-docs.js",
2122
"./plugin/config.js",

bin/validate-tsconfig.mjs

+27-8
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,33 @@ for ( const packageName of packagesWithTypes ) {
2929
hasErrors = true;
3030
}
3131

32-
const packageJson = JSON.parse(
33-
readFileSync( `packages/${ packageName }/package.json`, 'utf8' )
34-
);
35-
const tsconfigJson = JSON.parse(
36-
stripJsonComments(
37-
readFileSync( `packages/${ packageName }/tsconfig.json`, 'utf8' )
38-
)
39-
);
32+
let packageJson;
33+
try {
34+
packageJson = JSON.parse(
35+
readFileSync( `packages/${ packageName }/package.json`, 'utf8' )
36+
);
37+
} catch ( e ) {
38+
console.error(
39+
`Error parsing package.json for package ${ packageName }`
40+
);
41+
throw e;
42+
}
43+
let tsconfigJson;
44+
try {
45+
tsconfigJson = JSON.parse(
46+
stripJsonComments(
47+
readFileSync(
48+
`packages/${ packageName }/tsconfig.json`,
49+
'utf8'
50+
)
51+
)
52+
);
53+
} catch ( e ) {
54+
console.error(
55+
`Error parsing tsconfig.json for package ${ packageName }`
56+
);
57+
throw e;
58+
}
4059
if ( packageJson.dependencies ) {
4160
for ( const dependency of Object.keys( packageJson.dependencies ) ) {
4261
if ( dependency.startsWith( '@wordpress/' ) ) {

docs/getting-started/faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ What follows is a set of questions that have come up from the last few years of
88

99
“Gutenberg” is the name of the project to create a new editor experience for WordPress — contributors have been working on it since January 2017 and it’s one of the most significant changes to WordPress in years. It’s built on the idea of using “blocks” to write and design posts and pages. This will serve as the foundation for future improvements to WordPress, including blocks as a way not just to design posts and pages, but also entire sites. The overall goal is to simplify the first-time user experience of WordPress — for those who are writing, editing, publishing, and designing web pages. The editing experience is intended to give users a better visual representation of what their post or page will look like when they hit publish. Originally, this was the kickoff goal:
1010

11-
> 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.
11+
> The editor will endeavor 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.
1212
1313
Key takeaways include the following points:
1414

docs/reference-guides/core-blocks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ Contains the block elements used to render a post, like the title, date, feature
661661
- **Name:** core/post-template
662662
- **Category:** theme
663663
- **Ancestor:** core/query
664-
- **Supports:** align (full, wide), color (background, gradients, link, text), interactivity (clientNavigation), layout, spacing (blockGap), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~
664+
- **Supports:** align (full, wide), color (background, gradients, link, text), interactivity (clientNavigation), layout, spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~
665665

666666
## Post Terms
667667

jsconfig.json

-15
This file was deleted.

lib/experimental/media/load.php

+2
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ function gutenberg_set_up_cross_origin_isolation() {
247247
* Uses an output buffer to add crossorigin="anonymous" where needed.
248248
*
249249
* @link https://web.dev/coop-coep/
250+
*
251+
* @global bool $is_safari
250252
*/
251253
function gutenberg_start_cross_origin_isolation_output_buffer(): void {
252254
global $is_safari;

0 commit comments

Comments
 (0)