Skip to content

Commit 8332801

Browse files
committed
Real-time collaboration: Remove block client IDs from Awareness, fix "Show Template" view (WordPress#75590)
* Use relative position .parent traversal instead of block client ID when sharing and drawing awareness information * Fix "Show Template" mode by mapping remote positions into absolute block paths * Add tests for block resolution for post-editor-awareness * Remove inner blockPathResolver, use getBlockPathForLocalClientId utility funciton * Make utility function naming a bit easier to follow - change "getAbsolutePositionIndex()" to "convertSelectionStateToAbsolute()", have it return "localClientId" instead of "blockClientId" * Move block lookup functions into block-lookup utils file, improve types * Remove EditorStoreBlock from exported types * Compare relative positions with Yjs built-in function * Replace areSelectionsStatesEqual() relative position comparison with compareRelativePositions() as well * Fix types and tests from crdt-user-selections * Add a guard to avoid getting blocks when path is empty * Rename "useConvertSelectionStateToAbsolute" to "useResolvedSelection" * Add unit tests for getBlockPathInYdoc, resolveBlockClientIdByPath, avoid exporting inner helper functions
2 parents cbb71a7 + 588d4d0 commit 8332801

File tree

80 files changed

+2250
-814
lines changed

Some content is hidden

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

80 files changed

+2250
-814
lines changed

.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,16 @@ module.exports = {
436436
plugins: [ 'ssr-friendly' ],
437437
extends: [ 'plugin:ssr-friendly/recommended' ],
438438
},
439+
{
440+
files: [ 'packages/components/src/**' ],
441+
excludedFiles: [ 'packages/components/src/**/@(test|stories)/**' ],
442+
rules: {
443+
// Disallow usage of Design System token CSS custom properties (`--wpds-*`)
444+
// because the fallback injection in the build process is not compatible with Emotion files.
445+
// Can be removed when there are no more Emotion files in the package.
446+
'@wordpress/no-ds-tokens': 'error',
447+
},
448+
},
439449
{
440450
files: [
441451
'packages/block-editor/src/**',

.github/workflows/end2end-test.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ jobs:
6868
path: artifacts/test-results
6969
if-no-files-found: ignore
7070

71+
- name: Archive blob reports (HTML)
72+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
73+
if: ${{ !cancelled() }}
74+
with:
75+
name: blob-reports--${{ matrix.part }}
76+
path: blob-report
77+
if-no-files-found: ignore
78+
7179
- name: Archive flaky tests report
7280
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
7381
if: ${{ !cancelled() }}
@@ -81,10 +89,19 @@ jobs:
8189
if: ${{ !cancelled() }}
8290
needs: [e2e-playwright]
8391
runs-on: 'ubuntu-24.04'
84-
permissions: {}
92+
permissions:
93+
contents: read
8594
outputs:
8695
has-flaky-test-report: ${{ !!steps.merge-flaky-tests-reports.outputs.artifact-id }}
8796
steps:
97+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
98+
with:
99+
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
100+
persist-credentials: false
101+
102+
- name: Setup Node.js and install dependencies
103+
uses: ./.github/setup-node
104+
88105
- name: Merge failures artifacts
89106
uses: actions/upload-artifact/merge@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
90107
# Don't fail the job if there aren't any artifacts to merge.
@@ -104,6 +121,33 @@ jobs:
104121
pattern: flaky-tests-report*
105122
delete-merged: true
106123

124+
- name: Merge blob reports
125+
uses: actions/upload-artifact/merge@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
126+
continue-on-error: true
127+
with:
128+
name: blob-reports-merged
129+
pattern: blob-reports--*
130+
delete-merged: true
131+
132+
- name: Download merged blob reports
133+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
134+
continue-on-error: true
135+
with:
136+
name: blob-reports-merged
137+
path: all-blob-reports
138+
139+
- name: Merge blob reports into HTML report
140+
run: npx playwright merge-reports --reporter html ./all-blob-reports
141+
continue-on-error: true
142+
143+
- name: Upload merged HTML report
144+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
145+
continue-on-error: true
146+
with:
147+
name: html-report--attempt-${{ github.run_attempt }}
148+
path: playwright-report
149+
if-no-files-found: ignore
150+
107151
report-to-issues:
108152
name: Report to GitHub
109153
needs: [merge-artifacts]

backport-changelog/7.0/11049.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://github.com/WordPress/wordpress-develop/pull/11049
2+
3+
* https://github.com/WordPress/gutenberg/pull/75883

backport-changelog/7.1/11000.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://github.com/WordPress/wordpress-develop/pull/11000
2+
3+
* https://github.com/WordPress/gutenberg/pull/75799

changelog.txt

Lines changed: 88 additions & 148 deletions
Large diffs are not rendered by default.

docs/reference-guides/block-api/block-selectors.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,42 @@ elements to which it should be applied.
7777
}
7878
```
7979

80+
## Custom CSS selector
81+
82+
The `css` selector controls which selector is used when generating a block's
83+
custom CSS rules set via Global Styles. This maps to the
84+
`styles.blocks.<block-type>.css` property in theme.json.
85+
86+
If not set, the block's root selector is used.
87+
88+
### Examples
89+
90+
As a string:
91+
92+
```json
93+
{
94+
...
95+
"selectors": {
96+
"root": ".my-custom-block-selector",
97+
"css": ".my-custom-block-selector > .inner-wrapper"
98+
}
99+
}
100+
```
101+
102+
As an object with a `root` key:
103+
104+
```json
105+
{
106+
...
107+
"selectors": {
108+
"root": ".my-custom-block-selector",
109+
"css": {
110+
"root": ".my-custom-block-selector > .inner-wrapper"
111+
}
112+
}
113+
}
114+
```
115+
80116
## Shorthand
81117

82118
Rather than specify a CSS selector for every subfeature, you can set a single

gutenberg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: Printing since 1440. This is the development plugin for the block editor, site editor, and other future WordPress core functionality.
66
* Requires at least: 6.8
77
* Requires PHP: 7.4
8-
* Version: 22.6.0-rc.3
8+
* Version: 22.6.0
99
* Author: Gutenberg Team
1010
* Text Domain: gutenberg
1111
*

lib/class-wp-theme-json-gutenberg.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,7 +3215,12 @@ static function ( $pseudo_selector ) use ( $selector ) {
32153215

32163216
// 7. Generate and append any custom CSS rules.
32173217
if ( isset( $node['css'] ) && ! $is_root_selector ) {
3218-
$block_rules .= $this->process_blocks_custom_css( $node['css'], $selector );
3218+
$css_feature_selector = $block_metadata['selectors']['css'] ?? null;
3219+
if ( is_array( $css_feature_selector ) ) {
3220+
$css_feature_selector = $css_feature_selector['root'] ?? null;
3221+
}
3222+
$css_selector = is_string( $css_feature_selector ) ? $css_feature_selector : $selector;
3223+
$block_rules .= $this->process_blocks_custom_css( $node['css'], $css_selector );
32193224
}
32203225

32213226
return $block_rules;
@@ -4537,9 +4542,9 @@ protected function get_feature_declarations_for_node( $metadata, &$node ) {
45374542
$settings = $this->theme_json['settings'] ?? null;
45384543

45394544
foreach ( $metadata['selectors'] as $feature => $feature_selectors ) {
4540-
// Skip if this is the block's root selector or the block doesn't
4541-
// have any styles for the feature.
4542-
if ( 'root' === $feature || empty( $node[ $feature ] ) ) {
4545+
// Skip if this is the block's root selector, the custom CSS
4546+
// selector, or the block doesn't have any styles for the feature.
4547+
if ( 'root' === $feature || 'css' === $feature || empty( $node[ $feature ] ) ) {
45434548
continue;
45444549
}
45454550

lib/compat/wordpress-7.0/rest-api.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,18 @@ function gutenberg_modify_wp_template_part_post_type_args_7_0( $args ) {
5555
* @return array Modified array of template part area definitions.
5656
*/
5757
function gutenberg_register_overlay_template_part_area( $areas ) {
58+
foreach ( $areas as $area ) {
59+
if ( isset( $area['area'] ) && 'navigation-overlay' === $area['area'] ) {
60+
return $areas;
61+
}
62+
}
63+
5864
$areas[] = array(
5965
'area' => 'navigation-overlay',
6066
'label' => __( 'Navigation Overlay', 'gutenberg' ),
61-
'description' => __( 'Custom overlay area for navigation overlays.', 'gutenberg' ),
67+
'description' => __(
68+
'The Navigation Overlay template defines an overlay area that typically contains navigation links and can be toggled open and closed.'
69+
),
6270
'icon' => 'navigation-overlay',
6371
'area_tag' => 'div',
6472
);

package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)