Skip to content

Commit

Permalink
Post editor: iframe if all blocks are v3
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 25, 2023
1 parent f10f85f commit 4ee7c72
Show file tree
Hide file tree
Showing 224 changed files with 946 additions and 746 deletions.
2 changes: 1 addition & 1 deletion docs/getting-started/create-block/block-anatomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Most of the properties are set in the `src/block.json` file.
```json
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "create-block/gutenpride",
"version": "0.1.0",
"title": "Gutenpride",
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/create-block/wp-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The `register_block_type` function registers the block we are going to create an
```json
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "create-block/gutenpride",
"version": "0.1.0",
"title": "Gutenpride",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ For example:

```json
{
"apiVersion": 2,
"apiVersion": 3,
"name": "gutenberg-examples/example-02-stylesheets",
"title": "Example: Stylesheets",
"icon": "universal-access-alt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
} from '@wordpress/block-editor';

registerBlockType( 'gutenberg-examples/example-04-controls-esnext', {
apiVersion: 2,
apiVersion: 3,
title: 'Example: Controls (esnext)',
icon: 'universal-access-alt',
category: 'design',
Expand Down Expand Up @@ -208,7 +208,7 @@ import {
} from '@wordpress/block-editor';

registerBlockType( 'create-block/gutenpride', {
apiVersion: 2,
apiVersion: 3,
attributes: {
message: {
type: 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '@wordpress/block-editor';

registerBlockType( 'gutenberg-examples/example-dynamic', {
apiVersion: 2,
apiVersion: 3,
title: 'Example: last post title',
icon: 'megaphone',
category: 'widgets',
Expand Down Expand Up @@ -119,7 +119,7 @@ function gutenberg_examples_dynamic() {
register_block_type(
'gutenberg-examples/example-dynamic',
array(
'api_version' => 2,
'api_version' => 3,
'category' => 'widgets',
'attributes' => array(
'bgColor' => array( 'type' => 'string' ),
Expand All @@ -144,7 +144,7 @@ import { useSelect } from '@wordpress/data';
import { useBlockProps } from '@wordpress/block-editor';

registerBlockType( 'gutenberg-examples/example-dynamic-block-supports', {
apiVersion: 2,
apiVersion: 3,
title: 'Example: last post title(block supports)',
icon: 'megaphone',
category: 'widgets',
Expand Down Expand Up @@ -195,7 +195,7 @@ function gutenberg_examples_dynamic_block_supports() {
register_block_type(
'gutenberg-examples/example-dynamic-block-supports',
array(
'api_version' => 2,
'api_version' => 3,
'category' => 'widgets',
'supports' => array( 'color' => true ),
'render_callback' => 'gutenberg_examples_dynamic_block_supports_render_callback',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { registerBlockType } from '@wordpress/blocks';
import { useBlockProps, RichText } from '@wordpress/block-editor';

registerBlockType( 'gutenberg-examples/example-03-editable-esnext', {
apiVersion: 2,
apiVersion: 3,
title: 'Example: Basic with block supports',
icon: 'universal-access-alt',
category: 'design',
Expand Down Expand Up @@ -73,7 +73,7 @@ registerBlockType( 'gutenberg-examples/example-03-editable-esnext', {
var useBlockProps = blockEditor.useBlockProps;

blocks.registerBlockType( 'gutenberg-examples/example-03-editable', {
apiVersion: 2,
apiVersion: 3,
title: 'Example: Basic with block supports',
icon: 'universal-access-alt',
category: 'design',
Expand Down Expand Up @@ -127,7 +127,7 @@ Now, let's alter the block.json file for that block, and add the supports key. (

```json
{
"apiVersion": 2,
"apiVersion": 3,
"name": "gutenberg-examples/example-03-editable-esnext",
"title": "Example: Basic with block supports",
"icon": "universal-access-alt",
Expand Down
10 changes: 5 additions & 5 deletions docs/how-to-guides/block-tutorial/creating-dynamic-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { useSelect } from '@wordpress/data';
import { useBlockProps } from '@wordpress/block-editor';

registerBlockType( 'gutenberg-examples/example-dynamic', {
apiVersion: 2,
apiVersion: 3,
title: 'Example: last post',
icon: 'megaphone',
category: 'widgets',
Expand Down Expand Up @@ -62,7 +62,7 @@ registerBlockType( 'gutenberg-examples/example-dynamic', {
useBlockProps = blockEditor.useBlockProps;

registerBlockType( 'gutenberg-examples/example-dynamic', {
apiVersion: 2,
apiVersion: 3,
title: 'Example: last post',
icon: 'megaphone',
category: 'widgets',
Expand Down Expand Up @@ -132,7 +132,7 @@ function gutenberg_examples_dynamic() {
);

register_block_type( 'gutenberg-examples/example-dynamic', array(
'api_version' => 2,
'api_version' => 3,
'editor_script' => 'gutenberg-examples-dynamic',
'render_callback' => 'gutenberg_examples_dynamic_render_callback'
) );
Expand Down Expand Up @@ -165,7 +165,7 @@ import ServerSideRender from '@wordpress/server-side-render';
import { useBlockProps } from '@wordpress/block-editor';

registerBlockType( 'gutenberg-examples/example-dynamic', {
apiVersion: 2,
apiVersion: 3,
title: 'Example: last post',
icon: 'megaphone',
category: 'widgets',
Expand Down Expand Up @@ -194,7 +194,7 @@ registerBlockType( 'gutenberg-examples/example-dynamic', {
useBlockProps = blockEditor.useBlockProps;

registerBlockType( 'gutenberg-examples/example-dynamic', {
apiVersion: 2,
apiVersion: 3,
title: 'Example: last post',
icon: 'megaphone',
category: 'widgets',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import { registerBlockType } from '@wordpress/blocks';
import { useBlockProps, RichText } from '@wordpress/block-editor';

registerBlockType( 'gutenberg-examples/example-03-editable-esnext', {
apiVersion: 2,
apiVersion: 3,
title: 'Example: Editable (esnext)',
icon: 'universal-access-alt',
category: 'design',
Expand Down Expand Up @@ -117,7 +117,7 @@ registerBlockType( 'gutenberg-examples/example-03-editable-esnext', {
var useBlockProps = blockEditor.useBlockProps;

blocks.registerBlockType( 'gutenberg-examples/example-03-editable', {
apiVersion: 2,
apiVersion: 3,
title: 'Example: Editable',
icon: 'universal-access-alt',
category: 'design',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Create a basic `block.json` file there:

```json
{
"apiVersion": 2,
"apiVersion": 3,
"title": "Example: Basic (ESNext)",
"name": "gutenberg-examples/example-01-basic-esnext",
"category": "layout",
Expand All @@ -56,7 +56,7 @@ Create a basic `block.json` file there:

```json
{
"apiVersion": 2,
"apiVersion": 3,
"title": "Example: Basic",
"name": "gutenberg-examples/example-01-basic",
"category": "layout",
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to-guides/internationalization.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function myguten_block_init() {
);

register_block_type( 'myguten/simple', array(
'api_version' => 2,
'api_version' => 3,
'editor_script' => 'myguten-script',
) );
}
Expand All @@ -46,7 +46,7 @@ import { registerBlockType } from '@wordpress/blocks';
import { useBlockProps } from '@wordpress/block-editor';

registerBlockType( 'myguten/simple', {
apiVersion: 2,
apiVersion: 3,
title: __( 'Simple Block', 'myguten' ),
category: 'widgets',

Expand Down
2 changes: 1 addition & 1 deletion docs/how-to-guides/metabox.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function myguten_render_paragraph( $block_attributes, $content ) {
}

register_block_type( 'core/paragraph', array(
'api_version' => 2,
'api_version' => 3,
'render_callback' => 'myguten_render_paragraph',
) );
```
Expand Down
8 changes: 4 additions & 4 deletions docs/reference-guides/block-api/block-edit-save.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useBlockProps } from '@wordpress/block-editor';

// ...
const blockSettings = {
apiVersion: 2,
apiVersion: 3,

// ...

Expand All @@ -30,7 +30,7 @@ const blockSettings = {

```js
var blockSettings = {
apiVersion: 2,
apiVersion: 3,

// ...

Expand Down Expand Up @@ -58,7 +58,7 @@ import { useBlockProps } from '@wordpress/block-editor';

// ...
const blockSettings = {
apiVersion: 2,
apiVersion: 3,

// ...

Expand All @@ -76,7 +76,7 @@ const blockSettings = {

```js
var blockSettings = {
apiVersion: 2,
apiVersion: 3,

// ...

Expand Down
6 changes: 3 additions & 3 deletions docs/reference-guides/block-api/block-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Starting in WordPress 5.8 release, we recommend using the `block.json` metadata
```json
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "my-plugin/notice",
"title": "Notice",
"category": "text",
Expand Down Expand Up @@ -150,10 +150,10 @@ This section describes all the properties that can be added to the `block.json`
- Default: `1`

```json
{ "apiVersion": 2 }
{ "apiVersion": 3 }
```

The version of the Block API used by the block. The most recent version is `2` and it was introduced in WordPress 5.6.
The version of the Block API used by the block. The most recent version is `3` and it was introduced in WordPress 6.3.

See the [the API versions documentation](/docs/reference-guides/block-api/block-api-versions.md) for more details.

Expand Down
1 change: 1 addition & 0 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function gutenberg_reregister_core_block_types() {
'navigation-link.php' => 'core/navigation-link',
'navigation-submenu.php' => 'core/navigation-submenu',
'page-list.php' => 'core/page-list',
'page-list-item.php' => 'core/page-list-item',
'pattern.php' => 'core/pattern',
'post-author.php' => 'core/post-author',
'post-author-name.php' => 'core/post-author-name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe( 'Edit', () => {
it( 'should assign context', () => {
const edit = ( { context } ) => context.value;
registerBlockType( 'core/test-block', {
apiVersion: 2,
apiVersion: 3,
category: 'text',
title: 'block title',
usesContext: [ 'value' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from '@wordpress/block-editor';

registerBlockType( 'my-plugin/inspector-controls-example', {
apiVersion: 2,
apiVersion: 3,

title: 'Inspector controls example',

Expand Down
17 changes: 14 additions & 3 deletions packages/block-editor/src/components/writing-flow/use-tab-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,24 @@ export default function useTabNav() {
} else {
setNavigationMode( true );

const canvasElement =
container.current.ownerDocument === event.target.ownerDocument
? container.current
: container.current.ownerDocument.defaultView.frameElement;

const isBefore =
// eslint-disable-next-line no-bitwise
event.target.compareDocumentPosition( container.current ) &
event.target.compareDocumentPosition( canvasElement ) &
event.target.DOCUMENT_POSITION_FOLLOWING;
const action = isBefore ? 'findNext' : 'findPrevious';
const tabbables = focus.tabbable.find( container.current );

if ( tabbables.length ) {
const next = isBefore
? tabbables[ 0 ]
: tabbables[ tabbables.length - 1 ];

focus.tabbable[ action ]( event.target ).focus();
next.focus();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/archives/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "core/archives",
"title": "Archives",
"category": "widgets",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/audio/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "core/audio",
"title": "Audio",
"category": "media",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/avatar/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "core/avatar",
"title": "Avatar",
"category": "theme",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/block/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "core/block",
"title": "Reusable block",
"category": "reusable",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/button/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "core/button",
"title": "Button",
"category": "design",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/buttons/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "core/buttons",
"title": "Buttons",
"category": "design",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/calendar/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "core/calendar",
"title": "Calendar",
"category": "widgets",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/categories/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "core/categories",
"title": "Categories List",
"category": "widgets",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/code/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"apiVersion": 3,
"name": "core/code",
"title": "Code",
"category": "text",
Expand Down
Loading

0 comments on commit 4ee7c72

Please sign in to comment.