-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editor: Implement meta as custom source (#16402)
* Editor: Implement meta as custom source Co-Authored-By: Riad Benguella <benguella@gmail.com> * Block Editor: Skip outgoing sync next value only if matches by reference * Editor: Implement editor tearDown to un-ready state * Editor: Add subscription action generator for managing sources dependencies * Editor: Track source dependencies by registry * Editor: Prepare initial blocks reset for applied post-sourced values * Editor: Yield editor setup action after state preparation Ensure initial edits set to expected values, since preceding resetPost would unset them otherwise if already assigned * Editor: Update block sources as part of reset step * Editor: Retrieve registry at most once in applying sourced attributes * Editor: Account for source values apply / update in inner blocks * Editor: Update block sources documentation per interface changes * Block Editor: Add lastBlockAttributesChange unit tests * Block Editor: Document, test getLastBlockAttributesChange selector * Editor: Fix block sources getDependencies grammar Co-Authored-By: Enrique Piqueras <epiqueras@users.noreply.github.com> * Editor: Fix block sources meta getDependencies JSDoc typo Co-Authored-By: Enrique Piqueras <epiqueras@users.noreply.github.com> * Editor: Align block sources getDependencies JSDoc tags Co-Authored-By: Enrique Piqueras <epiqueras@users.noreply.github.com> * Editor: Resolve awaitNextStateChange JSDoc typo Co-Authored-By: Enrique Piqueras <epiqueras@users.noreply.github.com> * Editor: Resolve getRegistry JSDoc typo Co-Authored-By: Enrique Piqueras <epiqueras@users.noreply.github.com> * Block Editor: Always unset expected outbound sync value in provider update * Editor: Detect block attributes change as direct result of last action Infer change as non-null state from lastBlockAttributesChange * Documentation: Regenerate editor, block-editor data documentation * Block Editor: Unset outbound sync value in editor provider reset condition * Editor: Update getDependencies JSDoc to separate yield grouping * Editor: Dispatch SETUP_EDITOR prior to blocks reset SETUP_EDITOR is responsible for setting the initial edits, which are expected to be unset by a subsequent block reset * Editor: Update actions tests per reordered SETUP_EDITOR * Block API: Stub default attributes, keywords values for block type registration * Block API: Update documentation per formation of WPBlockTypeIconDescriptor typedef * Editor: Iterate last block changes in updating sources * Editor: Update source even if already updated for block updates A block may have multiple attributes which independently source uniquely from the same source type (e.g. two different meta properties) * Editor: Iterate updated attributes from block reset source update Optimization since the attributes are likely a subset (most likely a single attribute), so we can avoid iterating all attributes defined in a block type. * Editor: Mark custom sources selectors, actions as experimental * Editor: Remove redundant Object#hasOwnProperty in iterating attributes * Block Editor: Rename getLastBlockAttributesChange to getLastBlockAttributeChanges * Editor: Use getRegistry control for next change subscription
- Loading branch information
Showing
22 changed files
with
688 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
BlockEditorProvider | ||
=================== | ||
|
||
BlockEditorProvider is a component which establishes a new block editing context, and serves as the entry point for a new block editor. It is implemented as a [controlled input](https://reactjs.org/docs/forms.html#controlled-components), expected to receive a value of a blocks array, calling `onChange` and/or `onInput` when the user interacts to change blocks in the editor. It is intended to be used as a wrapper component, where its children comprise the user interface through which a user modifies the blocks value, notably via other components made available from this `block-editor` module. | ||
|
||
## Props | ||
|
||
### `value` | ||
|
||
* **Type:** `Array` | ||
* **Required** `no` | ||
|
||
The current array of blocks. | ||
|
||
### `onChange` | ||
|
||
* **Type:** `Function` | ||
* **Required** `no` | ||
|
||
A callback invoked when the blocks have been modified in a persistent manner. Contrasted with `onInput`, a "persistent" change is one which is not an extension of a composed input. Any update to a distinct block or block attribute is treated as persistent. | ||
|
||
The distinction between these two callbacks is akin to the [differences between `input` and `change` events](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event) in the DOM API: | ||
|
||
>The input event is fired every time the value of the element changes. **This is unlike the change event, which only fires when the value is committed**, such as by pressing the enter key, selecting a value from a list of options, and the like. | ||
In the context of an editor, an example usage of this distinction is for managing a history of blocks values (an "Undo"/"Redo" mechanism). While value updates should always be reflected immediately (`onInput`), you may only want history entries to reflect change milestones (`onChange`). | ||
|
||
### `onInput` | ||
|
||
* **Type:** `Function` | ||
* **Required** `no` | ||
|
||
A callback invoked when the blocks have been modified in a non-persistent manner. Contrasted with `onChange`, a "non-persistent" change is one which is part of a composed input. Any sequence of updates to the same block attribute are treated as non-persistent, except for the first. | ||
|
||
### `children` | ||
|
||
* **Type:** `WPElement` | ||
* **Required** `no` | ||
|
||
Children elements for which the BlockEditorProvider context should apply. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.