Skip to content

Commit

Permalink
Synced with trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
akasunil committed Jul 20, 2024
1 parent 5ea3de1 commit 0c7a78b
Show file tree
Hide file tree
Showing 340 changed files with 16,326 additions and 5,427 deletions.
28 changes: 28 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,34 @@ module.exports = {
],
},
},
{
// Temporary rules until we're ready to officially deprecate the bottom margins.
files: [ 'packages/*/src/**/*.[tj]s?(x)' ],
excludedFiles: [
'packages/components/src/**/@(test|stories)/**',
'**/*.@(native|ios|android).js',
],
rules: {
'no-restricted-syntax': [
'error',
...restrictedSyntax,
...restrictedSyntaxComponents,
...[
'CheckboxControl',
'ComboboxControl',
'FocalPointPicker',
'SearchControl',
'TextareaControl',
'TreeSelect',
].map( ( componentName ) => ( {
selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__nextHasNoMarginBottom"]))`,
message:
componentName +
' should have the `__nextHasNoMarginBottom` prop to opt-in to the new margin-free styles.',
} ) ),
],
},
},
{
files: [
// Components package.
Expand Down
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ changelog.txt linguist-language=Markdown

# Flag docs directory as documentation for GitHub stats.
docs/** linguist-documentation

# TSConfig files use jsonc.
tsconfig*.json linguist-language=jsonc
18 changes: 6 additions & 12 deletions .github/ISSUE_TEMPLATE/Bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,19 @@ body:
validations:
required: false

- type: dropdown
- type: checkboxes
id: existing
attributes:
label: Please confirm that you have searched existing issues in the repo.
description: You can do this by searching https://github.com/WordPress/gutenberg/issues and making sure the bug is not related to another plugin.
multiple: true
options:
- 'Yes'
- 'No'
validations:
required: true
- label: 'Yes'
required: true

- type: dropdown
- type: checkboxes
id: plugins
attributes:
label: Please confirm that you have tested with all plugins deactivated except Gutenberg.
multiple: true
options:
- 'Yes'
- 'No'
validations:
required: true
- label: 'Yes'
required: true
10 changes: 7 additions & 3 deletions .github/workflows/create-block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ concurrency:

jobs:
checks:
name: Checks w/Node.js ${{ matrix.node }} on ${{ matrix.os }}
name: Checks w/Node.js ${{ matrix.node.name }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
node: ['20', '22']
node:
- name: 20
version: 20
- name: 22
version: 22.4
os: ['macos-latest', 'ubuntu-latest', 'windows-latest']

steps:
Expand All @@ -31,7 +35,7 @@ jobs:
- name: Setup Node.js and install dependencies
uses: ./.github/setup-node
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.node.version }}

- name: Create block
shell: bash
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ concurrency:

jobs:
unit-js:
name: JavaScript (Node.js ${{ matrix.node }}) ${{ matrix.shard }}
name: JavaScript (Node.js ${{ matrix.node.name }}) ${{ matrix.shard }}
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
node: ['20', '22']
node:
- name: 20
version: 20
- name: 22
version: 22.4
shard: ['1/4', '2/4', '3/4', '4/4']

steps:
Expand All @@ -39,7 +43,7 @@ jobs:
- name: Setup Node.js and install dependencies
uses: ./.github/setup-node
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.node.version }}

- name: Determine the number of CPU cores
uses: SimenB/github-actions-cpu-cores@97ba232459a8e02ff6121db9362b09661c875ab8 # v2.0.0
Expand All @@ -60,13 +64,17 @@ jobs:
--cacheDirectory="$HOME/.jest-cache"
unit-js-date:
name: JavaScript Date Tests (Node.js ${{ matrix.node }})
name: JavaScript Date Tests (Node.js ${{ matrix.node.name }})
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
node: ['20', '22']
node:
- name: 20
version: 20
- name: 22
version: 22.4

steps:
- name: Checkout repository
Expand All @@ -77,7 +85,7 @@ jobs:
- name: Setup Node.js and install dependencies
uses: ./.github/setup-node
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.node.version }}

- name: Determine the number of CPU cores
uses: SimenB/github-actions-cpu-cores@97ba232459a8e02ff6121db9362b09661c875ab8 # v2.0.0
Expand Down
3 changes: 3 additions & 0 deletions backport-changelog/6.6/7036.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7036

* https://github.com/WordPress/gutenberg/pull/63436
3 changes: 3 additions & 0 deletions backport-changelog/6.6/7061.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7061

* https://github.com/WordPress/gutenberg/pull/63726
3 changes: 3 additions & 0 deletions backport-changelog/6.7/6991.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6991

* https://github.com/WordPress/gutenberg/pull/61382
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
/**
* External dependencies
*/
const path = require( 'path' );
const fs = require( 'fs' );
import path from 'path';
import fs from 'fs';
import url from 'url';
import $RefParser from '@apidevtools/json-schema-ref-parser';

const __dirname = path.dirname( url.fileURLToPath( import.meta.url ) );

/**
* Path to root project directory.
*
Expand Down Expand Up @@ -58,7 +63,7 @@ const END_TOKEN = '<!-- END TOKEN Autogenerated - DO NOT EDIT -->';
*/
const TOKEN_PATTERN = new RegExp( START_TOKEN + '[^]*' + END_TOKEN );

const themejson = require( THEME_JSON_SCHEMA_FILE );
const themejson = await $RefParser.dereference( THEME_JSON_SCHEMA_FILE );

/**
* Convert object keys to an array.
Expand All @@ -74,42 +79,6 @@ const keys = ( maybeObject ) => {
return Object.keys( maybeObject );
};

/**
* Get definition from ref.
*
* @param {string} ref
* @return {Object} definition
* @throws {Error} If the referenced definition is not found in 'themejson.definitions'.
*
* @example
* getDefinition( '#/definitions/typographyProperties/properties/fontFamily' )
* // returns themejson.definitions.typographyProperties.properties.fontFamily
*/
const resolveDefinitionRef = ( ref ) => {
const refParts = ref.split( '/' );
const definition = refParts[ refParts.length - 1 ];
if ( ! themejson.definitions[ definition ] ) {
throw new Error( `Can't resolve '${ ref }'. Definition not found` );
}
return themejson.definitions[ definition ];
};

/**
* Get properties from an array.
*
* @param {Object} items
* @return {Object} properties
*/
const getPropertiesFromArray = ( items ) => {
// if its a $ref resolve it
if ( items.$ref ) {
return resolveDefinitionRef( items.$ref ).properties;
}

// otherwise just return the properties
return items.properties;
};

/**
* Convert settings properties to markup.
*
Expand All @@ -133,9 +102,7 @@ const getSettingsPropertiesMarkup = ( struct ) => {
let type = props[ key ].type || '';
let ps =
props[ key ].type === 'array'
? keys( getPropertiesFromArray( props[ key ].items ) )
.sort()
.join( ', ' )
? keys( props[ key ].items.properties ).sort().join( ', ' )
: '';

/*
Expand All @@ -154,9 +121,7 @@ const getSettingsPropertiesMarkup = ( struct ) => {
.map( ( item ) =>
item?.type === 'object' && item?.properties
? '_{' +
keys( getPropertiesFromArray( item ) )
.sort()
.join( ', ' ) +
keys( item.properties ).sort().join( ', ' ) +
'}_'
: ''
)
Expand Down Expand Up @@ -244,10 +209,6 @@ const formatType = ( prop ) => {
if ( item.type ) {
types.push( item.type );
}
// refComplete is always an object
if ( item.$ref && item.$ref === '#/definitions/refComplete' ) {
types.push( 'object' );
}
} );

type = [ ...new Set( types ) ].join( ', ' );
Expand Down
12 changes: 10 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
== Changelog ==

= 18.8.0-rc.1 =

= 18.8.0 =

## Changelog

Expand Down Expand Up @@ -139,6 +138,7 @@
- Fix Incorrect URL basename logic in EmbedPreview. ([63052](https://github.com/WordPress/gutenberg/pull/63052))
- Fix: Update "Link Text" label to "Text" on Social Icons block #60966. ([61715](https://github.com/WordPress/gutenberg/pull/61715))
- List: Maintain nested list on parent item removal. ([62949](https://github.com/WordPress/gutenberg/pull/62949))
- Navigation: Allow themes to override block library text-decoration rule. ([63406](https://github.com/WordPress/gutenberg/pull/63406))
- Patterns: Check for edited entity content property when exporting. ([63227](https://github.com/WordPress/gutenberg/pull/63227))
- Reduce specificity of social link icon specific colors. ([63049](https://github.com/WordPress/gutenberg/pull/63049))
- Refactor Post Date Relative Time Rendering for Future Dates. ([62979](https://github.com/WordPress/gutenberg/pull/62979))
Expand Down Expand Up @@ -171,11 +171,14 @@
- Only hide drop indicator when grid has `isManualPlacement` set. ([63226](https://github.com/WordPress/gutenberg/pull/63226))
- Remove dotted border from grid dropzone. ([63162](https://github.com/WordPress/gutenberg/pull/63162))
- Resizing in Auto mode shouldn't add `columnStart` and `rowStart` values. ([63160](https://github.com/WordPress/gutenberg/pull/63160))
- Fix invalid css for nested fullwidth layouts with zero padding applied. ([63436](https://github.com/WordPress/gutenberg/pull/63436))

#### Global Styles
- Elements: Avoid specificity bump for top-level element-only selectors. ([63403](https://github.com/WordPress/gutenberg/pull/63403))
- Global styles revisions: Ensure that user-defined variation styles CSS is generated. ([62768](https://github.com/WordPress/gutenberg/pull/62768))
- Root padding styles: Include alignwide in nested has-outer-padding logic. ([63207](https://github.com/WordPress/gutenberg/pull/63207))
- Remove letter-spacing from typography element preview. ([60322](https://github.com/WordPress/gutenberg/pull/60322))
- Only add customizer additional CSS to global styles in block themes. ([63331](https://github.com/WordPress/gutenberg/pull/63331))

#### Site Editor
- Make SiteHub available for Pages, Patterns, and Templates in mobile viewports. ([63118](https://github.com/WordPress/gutenberg/pull/63118))
Expand All @@ -190,6 +193,7 @@
#### Block Editor
- Featured Image Panel: Align text and icons horizontally to avoid clipping. ([62842](https://github.com/WordPress/gutenberg/pull/62842))
- Zoom Out: Move the hook to the inserter component. ([63315](https://github.com/WordPress/gutenberg/pull/63315))
- Fix error when calling the PostActions `view-post` callback. ([63460](https://github.com/WordPress/gutenberg/pull/63460))

#### Block bindings
- Disable post meta editing in blocks inside a Query Loop. ([63237](https://github.com/WordPress/gutenberg/pull/63237))
Expand All @@ -212,6 +216,7 @@

#### Typography
- Use available font weights and styles in FontAppearanceControl. ([61915](https://github.com/WordPress/gutenberg/pull/61915))
- Font Appearance Control: Refactor font appearance fallbacks. ([63215](https://github.com/WordPress/gutenberg/pull/63215))


### Accessibility
Expand Down Expand Up @@ -366,6 +371,7 @@ The following PRs were merged by first-time contributors:
- @iworks: Translation should depend on number of items. ([62857](https://github.com/WordPress/gutenberg/pull/62857))
- @roygbyte: Fix typo to be preposition, not verb, in some package comments and documentations. ([62945](https://github.com/WordPress/gutenberg/pull/62945))
- @shreya0204: Add justification to block toolbar in addition to sidebar. ([62924](https://github.com/WordPress/gutenberg/pull/62924))
- @sejas: Fix: Error when calling the PostActions `view-post` callback. ([63460](https://github.com/WordPress/gutenberg/pull/63460))


## Contributors
Expand All @@ -375,6 +381,8 @@ The following contributors merged PRs in this release:
@aaronrobertshaw @afercia @airman5573 @akasunil @aliaghdam @amitraj2203 @bogiii @carolinan @Chrico @ciampo @costasovo @creativecoder @DaniGuardiola @desrosj @dhananjaykuber @dmsnell @ellatrix @fluiddot @geriux @hbhalodia @iamibrahimriaz @iworks @jameskoster @jasmussen @jeryj @jffng @jorgefilipecosta @jsnajdr @juanmaguitar @kevin940726 @luisherranz @MaggieCabrera @Mamaduka @matiasbenedetto @michalczaplinski @mikachan @mirka @ndiego @ntsekouras @oandregal @ockham @peterwilsoncc @ramonjd @richtabor @roygbyte @SantosGuillamot @scruffian @shail-mehta @shreya0204 @sirreal @stokesman @swissspidy @t-hamano @talldan @tellthemachines @tyxla @vipul0425 @westonruter @youknowriad




= 18.7.1 =


Expand Down
6 changes: 3 additions & 3 deletions docs/contributors/code/coding-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Examples of styles that appear in both the theme and the editor include gallery

## JavaScript

JavaScript in Gutenberg uses modern language features of the [ECMAScript language specification](https://www.ecma-international.org/ecma-262/) as well as the [JSX language syntax extension](https://reactjs.org/docs/introducing-jsx.html). These are enabled through a combination of preset configurations, notably [`@wordpress/babel-preset-default`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/babel-preset-default) which is used as a preset in the project's [Babel](https://babeljs.io/) configuration.
JavaScript in Gutenberg uses modern language features of the [ECMAScript language specification](https://www.ecma-international.org/ecma-262/) as well as the [JSX language syntax extension](https://react.dev/learn/writing-markup-with-jsx). These are enabled through a combination of preset configurations, notably [`@wordpress/babel-preset-default`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/babel-preset-default) which is used as a preset in the project's [Babel](https://babeljs.io/) configuration.

While the [staged process](https://tc39.es/process-document/) for introducing a new JavaScript language feature offers an opportunity to use new features before they are considered complete, **the Gutenberg project and the `@wordpress/babel-preset-default` configuration will only target support for proposals which have reached Stage 4 ("Finished")**.

Expand Down Expand Up @@ -531,7 +531,7 @@ alert( `My name is ${ name }.` );

### React components

It is preferred to implement all components as [function components](https://reactjs.org/docs/components-and-props.html), using [hooks](https://reactjs.org/docs/hooks-reference.html) to manage component state and lifecycle. With the exception of [error boundaries](https://reactjs.org/docs/error-boundaries.html), you should never encounter a situation where you must use a class component. Note that the [WordPress guidance on Code Refactoring](https://make.wordpress.org/core/handbook/contribute/code-refactoring/) applies here: There needn't be a concentrated effort to update class components in bulk. Instead, consider it as a good refactoring opportunity in combination with some other change.
It is preferred to implement all components as [function components](https://react.dev/learn/your-first-component), using [hooks](https://react.dev/reference/react/hooks) to manage component state and lifecycle. With the exception of [error boundaries](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary), you should never encounter a situation where you must use a class component. Note that the [WordPress guidance on Code Refactoring](https://make.wordpress.org/core/handbook/contribute/code-refactoring/) applies here: There needn't be a concentrated effort to update class components in bulk. Instead, consider it as a good refactoring opportunity in combination with some other change.

## JavaScript documentation using JSDoc

Expand Down Expand Up @@ -758,7 +758,7 @@ When documenting an example, use the markdown <code>\`\`\`</code> code block to

### Documenting React components

When possible, all components should be implemented as [function components](https://reactjs.org/docs/components-and-props.html#function-and-class-components), using [hooks](https://react.dev/reference/react/hooks) for managing component lifecycle and state.
When possible, all components should be implemented as [function components](https://react.dev/learn/your-first-component), using [hooks](https://react.dev/reference/react/hooks) for managing component lifecycle and state.

Documenting a function component should be treated the same as any other function. The primary caveat in documenting a component is being aware that the function typically accepts only a single argument (the "props"), which may include many property members. Use the [dot syntax for parameter properties](https://jsdoc.app/tags-param.html#parameters-with-properties) to document individual prop types.

Expand Down
2 changes: 1 addition & 1 deletion docs/contributors/code/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ For features included in the Gutenberg plugin, the deprecation policy is intende

## 3.8.0

- `wp.components.withContext` has been removed. Please use `wp.element.createContext` instead. See: https://reactjs.org/docs/context.html.
- `wp.components.withContext` has been removed. Please use `wp.element.createContext` instead. See: https://react.dev/reference/react/createContext.
- `wp.coreBlocks.registerCoreBlocks` has been removed. Please use `wp.blockLibrary.registerCoreBlocks` instead.
- `wp.editor.DocumentTitle` component has been removed.
- `getDocumentTitle` selector (`core/editor`) has been removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Note that instead of using an `input` tag, we took advantage of the [SearchContr
![](https://raw.githubusercontent.com/WordPress/gutenberg/HEAD/docs/how-to-guides/data-basics/media/list-of-pages/filter-field.jpg)
The field starts empty, and the contents are stored in the `searchTerm` state value. If you aren’t familiar with the [useState](https://reactjs.org/docs/hooks-state.html) hook, you can learn more in [React’s documentation](https://reactjs.org/docs/hooks-state.html).
The field starts empty, and the contents are stored in the `searchTerm` state value. If you aren’t familiar with the [useState](https://react.dev/reference/react/useState) hook, you can learn more in [React’s documentation](https://react.dev/reference/react/useState).
We can now request only the pages matching the `searchTerm`.
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to-guides/platform/custom-block-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function Editor( { settings } ) {
}
```

In this process, the core of the editor's layout is being scaffolded, along with a few specialized [context providers](https://reactjs.org/docs/context.html#contextprovider) that make specific functionality available throughout the component hierarchy.
In this process, the core of the editor's layout is being scaffolded, along with a few specialized [context providers](https://react.dev/reference/react/createContext#provider) that make specific functionality available throughout the component hierarchy.

Let's examine these in more detail:

Expand Down
Loading

0 comments on commit 0c7a78b

Please sign in to comment.