Skip to content

Commit

Permalink
prep build 10/20
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Oct 20, 2023
2 parents cbbb4f3 + 23c6a71 commit 07a7191
Show file tree
Hide file tree
Showing 60 changed files with 2,804 additions and 342 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ To see a list of all of your available iOS devices, use `xcrun simctl list devic

### Customizing the Demo Editor

By default, the Demo editor renders most of the supported core blocks. This is helpful to showcase the editor's capabilities, but can be distracting when focusing on a specific block or feature. One can customize the editor's intial state by leveraging the `native.block_editor_props` hook in a `packages/react-native-editor/src/setup-local.js` file.
By default, the Demo editor renders most of the supported core blocks. This is helpful to showcase the editor's capabilities, but can be distracting when focusing on a specific block or feature. One can customize the editor's initial state by leveraging the `native.block_editor_props` hook in a `packages/react-native-editor/src/setup-local.js` file.

<details><summary>Example setup-local.js</summary>

Expand Down
2 changes: 1 addition & 1 deletion docs/explanations/architecture/entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ wp.data.dispatch( 'core' ).saveEditedEntityRecord( 'postType', 'post', 1 );

Since the WordPress editors allow multiple entity records to be edited at the same time, the `core-data` package keeps track of all the entity records that have been fetched and edited in a common undo/redo stack. Each step in the undo/redo stack contains a list of "edits" that should be undone or redone at the same time when calling the `undo` or `redo` action.

And to be able to perform both undo and redo operations propertly, each modification in the list of edits contains the following information:
And to be able to perform both undo and redo operations properly, each modification in the list of edits contains the following information:

- Entity kind and name: Each entity in core-data is identified by the pair _(kind, name)_. This corresponds to the identifier of the modified entity.
- Entity Record ID: The ID of the modified record.
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/devenv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Node.js and its accompanying development tools allow you to:
- Lint, format, and test JavaScript code
- Scaffold custom blocks with the `create-block` package

The list goes on. While modern JavaScript development can be challenging, WordPress provides several tools, like [`wp-scripts`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/) and [`create-block`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/), that streamline the process and are made possible by Node.js development tools.
The list goes on. While modern JavaScript development can be challenging, WordPress provides several tools, like [`wp-scripts`](/docs/getting-started/devenv/get-started-with-wp-scripts.md) and [`create-block`](/docs/getting-started/devenv/get-started-with-create-block.md), that streamline the process and are made possible by Node.js development tools.

**The recommended Node.js version for block development is [Active LTS](https://nodejs.dev/en/about/releases/) (Long Term Support)**. However, there are times when you need to to use different versions. A Node.js version manager tool like `nvm` is strongly recommended and allows you to easily change your `node` version when required. You will also need Node Package Manager (`npm`) and the Node Package eXecute (`npx`) to work with some WordPress packages. Both are installed automatically with Node.js.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ import { InspectorControls } from '@wordpress/block-editor';

export const withBookQueryControls = ( BlockEdit ) => ( props ) => {
// We only want to add these controls if it is our variation,
// so here we can implement a custom logic to check for that, similiar
// so here we can implement a custom logic to check for that, similar
// to the `isActive` function described above.
// The following assumes that you wrote a custom `isMyBooksVariation`
// function to handle that.
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to-guides/enqueueing-assets-in-the-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Do you want to add styling or JavaScript to the user-generated content (blocks)

There are different hooks to use depending on the answers to these questions, and if you are building a block or a theme, there are additional approaches to consider. Refer to the designated sections below.

## Scenarios for enqueing assets
## Scenarios for enqueuing assets
### Editor scripts and styles

Whenever you need to enqueue assets for the Editor itself (i.e. not the user-generated content), you should use the [`enqueue_block_editor_assets`](https://developer.wordpress.org/reference/hooks/enqueue_block_editor_assets/) hook coupled with the standard [`wp_enqueue_script`](https://developer.wordpress.org/reference/functions/wp_enqueue_script/) and [`wp_enqueue_style`](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) functions.
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to-guides/platform/custom-block-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Here is a brief summary of what's going on:
- `src/` (directory) - This is where the JavaScript and CSS source files will live. These files are _not_ directly enqueued by the plugin.
- `webpack.config.js` - A custom Webpack config extending the defaults provided by the [`@wordpress/scripts`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/) npm package to allow for custom CSS styles (via Sass).

The only item not shown above is the `build/` directory, which is where the _compiled_ JS and CSS files are outputted by `@wordpress/scripts`. These files are enqueued by the plugin seperately.
The only item not shown above is the `build/` directory, which is where the _compiled_ JS and CSS files are outputted by `@wordpress/scripts`. These files are enqueued by the plugin separately.

<div class="callout callout-info">
Throughout this guide, filename references will be placed in a comment at the top of each code snippet so you can follow along.
Expand Down Expand Up @@ -168,7 +168,7 @@ wp_enqueue_script( $script_handle, $script_url, $script_asset['dependencies'], $

To save time and space, the `$script_` variables assignment has been omitted. You can [review these here](https://github.com/getdave/standalone-block-editor/blob/974a59dcbc539a0595e8fa34670e75ec541853ab/init.php#L19).

Note the third arguement for script dependencies, `$script_asset['dependencies']`. These dependencies are
Note the third argument for script dependencies, `$script_asset['dependencies']`. These dependencies are
dynamically generated using [@wordpress/dependency-extraction-webpack-plugin](https://developer.wordpress.org/block-editor/packages/packages-dependency-extraction-webpack-plugin/) which will
[ensure that](https://developer.wordpress.org/block-editor/packages/packages-scripts/#default-webpack-config) WordPress provided scripts are not included in the built
bundle.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/block-api/block-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ add_action( 'init', 'myplugin_register_template' );

_Options:_

- `contentOnly` — prevents all operations. Additionally, the block types that don't have content are hidden from the list view and can't gain focus within the block list. Unlike the other lock types, this is not overrideable by children.
- `contentOnly` — prevents all operations. Additionally, the block types that don't have content are hidden from the list view and can't gain focus within the block list. Unlike the other lock types, this is not overridable by children.
- `all` — prevents all operations. It is not possible to insert new blocks, move existing blocks, or delete blocks.
- `insert` — prevents inserting or removing blocks, but allows moving existing blocks.

Expand Down
6 changes: 3 additions & 3 deletions docs/reference-guides/block-api/block-transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ A transformation of type `enter` is an object that takes the following parameter

**Example: from --- to Separator block**

To create a separator block when the user types the hypen three times and then hits the ENTER key we can use the following code:
To create a separator block when the user types the hyphen three times and then hits the ENTER key we can use the following code:

```js
transforms = {
Expand Down Expand Up @@ -162,7 +162,7 @@ This type of transformations support the _from_ direction, allowing blocks to be
A transformation of type `prefix` is an object that takes the following parameters:

- **type** _(string)_: the value `prefix`.
- **prefix** _(string)_: the character or sequence of characters that match this transfrom.
- **prefix** _(string)_: the character or sequence of characters that match this transform.
- **transform** _(function)_: a callback that receives the content introduced. It should return a block object or an array of block objects.
- **priority** _(number, optional)_: controls the priority with which a transform is applied, where a lower value will take precedence over higher values. This behaves much like a [WordPress hook](https://codex.wordpress.org/Plugin_API#Hook_to_WordPress). Like hooks, the default priority is `10` when not otherwise set.

Expand Down Expand Up @@ -260,7 +260,7 @@ schema = ({ phrasingContentSchema }) => {

When we successfully match this content every HTML attribute will be stripped away except for `data-post-id` and if we have other arrangements of HTML inside of a given `div` then it won't match our transformer. Likewise we'd fail to match if we found an `<h3>` in there instead of an `<h2>`.

Schemas are most-important when wanting to match HTML snippets containing non-phrasing content, such as `<details>` with a `<summary>`. Without declaring the custom schema the editor will skip over these other contructions before attempting to run them through any block transforms.
Schemas are most-important when wanting to match HTML snippets containing non-phrasing content, such as `<details>` with a `<summary>`. Without declaring the custom schema the editor will skip over these other constructions before attempting to run them through any block transforms.

### Shortcode

Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/filters/editor-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ This is a PHP filter which is applied before sending settings to the WordPress b

You may find details about this filter [on its WordPress Code Reference page](https://developer.wordpress.org/reference/hooks/block_editor_settings_all/).

The filter will send any setting to the initialized Editor, which means any editor setting that is used to configure the editor at initialiation can be filtered by a PHP WordPress plugin before being sent.
The filter will send any setting to the initialized Editor, which means any editor setting that is used to configure the editor at initialization can be filtered by a PHP WordPress plugin before being sent.

_Example:_

Expand Down
31 changes: 30 additions & 1 deletion lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,26 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
return '';
}

/**
* Generates an incremental ID that is independent per each different prefix.
*
* It is similar to `wp_unique_id`, but each prefix has it's own internal ID
* counter to make each prefix independent from each other. The ID starts at 1
* and increments on each call. The returned value is not universally unique,
* but it is unique across the life of the PHP process and it's stable per
* prefix.
*
* @param string $prefix Prefix for the returned ID.
* @return string Incremental ID per prefix.
*/
function gutenberg_incremental_id_per_prefix( $prefix = '' ) {
static $id_counters = array();
if ( ! array_key_exists( $prefix, $id_counters ) ) {
$id_counters[ $prefix ] = 0;
}
return $prefix . (string) ++$id_counters[ $prefix ];
}

/**
* Renders the layout config to the block wrapper.
*
Expand Down Expand Up @@ -608,7 +628,16 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {

$class_names = array();
$layout_definitions = gutenberg_get_layout_definitions();
$container_class = wp_unique_id( 'wp-container-' );

/*
* We use an incremental ID that is independent per prefix to make sure that
* rendering different numbers of blocks doesn't affect the IDs of other
* blocks. We need this to make the CSS class names stable across paginations
* for features like the enhanced pagination of the Query block.
*/
$container_class = gutenberg_incremental_id_per_prefix(
'wp-container-' . sanitize_title( $block['blockName'] ) . '-layout-'
);

// Set the correct layout type for blocks using legacy content width.
if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] || isset( $used_layout['contentSize'] ) && $used_layout['contentSize'] ) {
Expand Down
1 change: 0 additions & 1 deletion lib/class-wp-duotone-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,6 @@ public static function render_duotone_support( $block_content, $block ) {
$has_global_styles_duotone = array_key_exists( $block['blockName'], self::$global_styles_block_names );

if (
empty( $block_content ) ||
! $duotone_selector ||
( ! $has_duotone_attribute && ! $has_global_styles_duotone )
) {
Expand Down
53 changes: 53 additions & 0 deletions lib/experimental/data-views.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Dataviews custom post type and taxonomy.
*
* @package gutenberg
*/

/**
* Registers the `wp_dataviews` post type and the `wp_dataviews_type` taxonomy.
*/
function _gutenberg_register_data_views_post_type() {
register_post_type(
'wp_dataviews',
array(
'label' => _x( 'Dataviews', 'post type general name', 'gutenberg' ),
'description' => __( 'Post which stores the different data views configurations', 'gutenberg' ),
'public' => false,
'show_ui' => false,
'show_in_rest' => true,
'rewrite' => false,
'capabilities' => array(
'read' => 'edit_published_posts',
// 'create_posts' => 'edit_published_posts',
// 'edit_posts' => 'edit_published_posts',
// 'edit_published_posts' => 'edit_published_posts',
// 'delete_published_posts' => 'delete_published_posts',
// 'edit_others_posts' => 'edit_others_posts',
// 'delete_others_posts' => 'edit_theme_options',
),
'map_meta_cap' => true,
'supports' => array( 'title', 'slug', 'editor' ),
)
);

register_taxonomy(
'wp_dataviews_type',
array( 'wp_dataviews' ),
array(
'public' => true,
'hierarchical' => false,
'labels' => array(
'name' => __( 'Dataview types', 'gutenberg' ),
'singular_name' => __( 'Dataview type', 'gutenberg' ),
),
'rewrite' => false,
'show_ui' => false,
'show_in_nav_menus' => false,
'show_in_rest' => true,
)
);
}

add_action( 'init', '_gutenberg_register_data_views_post_type' );
15 changes: 5 additions & 10 deletions lib/experimental/interactivity-api/directives/wp-context.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@ function gutenberg_interactivity_process_wp_context( $tags, $context ) {
}

$value = $tags->get_attribute( 'data-wp-context' );
if ( null === $value ) {
// No data-wp-context directive.
return;
}

$new_context = json_decode( $value, true );
if ( null === $new_context ) {
// If the JSON is not valid, we still add an empty array to the stack.
$new_context = array();
}
$new_context = json_decode(
is_string( $value ) && ! empty( $value ) ? $value : '{}',
true
);

$context->set_context( $new_context );
$context->set_context( $new_context ?? array() );
}
Loading

0 comments on commit 07a7191

Please sign in to comment.