diff --git a/bin/api-docs/update-api-docs.js b/bin/api-docs/update-api-docs.js index ff4b6c21fef371..3fc1e6da297e04 100755 --- a/bin/api-docs/update-api-docs.js +++ b/bin/api-docs/update-api-docs.js @@ -232,6 +232,9 @@ glob.stream( [ { shell: true } ); } + await execa( 'npm', [ 'run', 'format', output ], { + shell: true, + } ); } catch ( error ) { console.error( error ); process.exit( 1 ); diff --git a/docs/reference-guides/data/data-core-annotations.md b/docs/reference-guides/data/data-core-annotations.md index 99c86d36cf7d4d..f1d1d6918e5c5d 100644 --- a/docs/reference-guides/data/data-core-annotations.md +++ b/docs/reference-guides/data/data-core-annotations.md @@ -16,5 +16,4 @@ Nothing to document. Nothing to document. - diff --git a/docs/reference-guides/data/data-core-block-editor.md b/docs/reference-guides/data/data-core-block-editor.md index c7c71e86845ff8..3cc75b50481683 100644 --- a/docs/reference-guides/data/data-core-block-editor.md +++ b/docs/reference-guides/data/data-core-block-editor.md @@ -705,7 +705,7 @@ Returns the defined block template _Parameters_ -- _state_ `boolean`: +- _state_ `boolean`: _Returns_ @@ -1027,7 +1027,7 @@ Returns whether the blocks matches the template or not. _Parameters_ -- _state_ `boolean`: +- _state_ `boolean`: _Returns_ @@ -1067,8 +1067,8 @@ Generator that triggers an action used to duplicate a list of blocks. _Parameters_ -- _clientIds_ `string[]`: -- _updateSelection_ `boolean`: +- _clientIds_ `string[]`: +- _updateSelection_ `boolean`: ### enterFormattedText @@ -1109,7 +1109,7 @@ Generator used to insert an empty block before a given block. _Parameters_ -- _clientId_ `string`: +- _clientId_ `string`: ### insertBeforeBlock @@ -1117,7 +1117,7 @@ Generator used to insert an empty block after a given block. _Parameters_ -- _clientId_ `string`: +- _clientId_ `string`: ### insertBlock @@ -1146,7 +1146,7 @@ _Parameters_ - _blocks_ `Object[]`: Block objects to insert. - _index_ `?number`: Index at which block should be inserted. - _rootClientId_ `?string`: Optional root client ID of block list on which to insert. -- _updateSelection_ `?boolean`: If true block selection will be updated. If false, block selection will not change. Defaults to true. +- _updateSelection_ `?boolean`: If true block selection will be updated. If false, block selection will not change. Defaults to true. - _initialPosition_ `0|-1|null`: Initial focus position. Setting it to null prevent focusing the inserted block. - _meta_ `?Object`: Optional Meta values to be passed to the action object. @@ -1586,5 +1586,4 @@ _Parameters_ - _blocks_ `Array`: Array of blocks. - diff --git a/docs/reference-guides/data/data-core-blocks.md b/docs/reference-guides/data/data-core-blocks.md index 4d78203d384652..4a382444baf789 100644 --- a/docs/reference-guides/data/data-core-blocks.md +++ b/docs/reference-guides/data/data-core-blocks.md @@ -440,5 +440,4 @@ _Returns_ - `Object`: Action object. - diff --git a/docs/reference-guides/data/data-core-edit-post.md b/docs/reference-guides/data/data-core-edit-post.md index 8f150ff19b6684..040bd80cc49d1d 100644 --- a/docs/reference-guides/data/data-core-edit-post.md +++ b/docs/reference-guides/data/data-core-edit-post.md @@ -545,5 +545,4 @@ _Returns_ - `Object`: Action object. - diff --git a/docs/reference-guides/data/data-core-editor.md b/docs/reference-guides/data/data-core-editor.md index 027dcb4441f366..504abe51294cd8 100644 --- a/docs/reference-guides/data/data-core-editor.md +++ b/docs/reference-guides/data/data-core-editor.md @@ -367,7 +367,7 @@ Return the current block list. _Parameters_ -- _state_ `Object`: +- _state_ `Object`: _Returns_ @@ -379,7 +379,7 @@ Returns the current selection. _Parameters_ -- _state_ `Object`: +- _state_ `Object`: _Returns_ @@ -393,7 +393,7 @@ Returns the current selection end. _Parameters_ -- _state_ `Object`: +- _state_ `Object`: _Returns_ @@ -407,7 +407,7 @@ Returns the current selection start. _Parameters_ -- _state_ `Object`: +- _state_ `Object`: _Returns_ @@ -1094,7 +1094,7 @@ _Related_ ### autosave -Action generator used in signalling that the post should autosave. This +Action generator used in signalling that the post should autosave. This includes server-side autosaving (default) and client-side (a.k.a. local) autosaving (e.g. on the Web, the post might be committed to Session Storage). @@ -1364,7 +1364,7 @@ Action generator for saving the current post in the editor. _Parameters_ -- _options_ `Object`: +- _options_ `Object`: ### selectBlock @@ -1537,5 +1537,4 @@ _Returns_ - `Object`: Action object. - diff --git a/docs/reference-guides/data/data-core-keyboard-shortcuts.md b/docs/reference-guides/data/data-core-keyboard-shortcuts.md index fe8a0c9b1e4bba..512668650d04bf 100644 --- a/docs/reference-guides/data/data-core-keyboard-shortcuts.md +++ b/docs/reference-guides/data/data-core-keyboard-shortcuts.md @@ -119,5 +119,4 @@ _Returns_ - `Object`: action. - diff --git a/docs/reference-guides/data/data-core-notices.md b/docs/reference-guides/data/data-core-notices.md index cf24beadd251da..69470c54b7ccd9 100644 --- a/docs/reference-guides/data/data-core-notices.md +++ b/docs/reference-guides/data/data-core-notices.md @@ -134,5 +134,4 @@ _Returns_ - `Object`: Action object. - diff --git a/docs/reference-guides/data/data-core-nux.md b/docs/reference-guides/data/data-core-nux.md index fb92f8840c9593..4d2e8a0d98d546 100644 --- a/docs/reference-guides/data/data-core-nux.md +++ b/docs/reference-guides/data/data-core-nux.md @@ -96,5 +96,4 @@ _Returns_ - `Object`: Action object. - diff --git a/docs/reference-guides/data/data-core-viewport.md b/docs/reference-guides/data/data-core-viewport.md index 045c2f85c9555b..0764429334a08d 100644 --- a/docs/reference-guides/data/data-core-viewport.md +++ b/docs/reference-guides/data/data-core-viewport.md @@ -46,5 +46,4 @@ _Returns_ - `Object`: Action object. - diff --git a/docs/reference-guides/data/data-core.md b/docs/reference-guides/data/data-core.md index 49bc8c8adecf26..bf72387cd62b05 100644 --- a/docs/reference-guides/data/data-core.md +++ b/docs/reference-guides/data/data-core.md @@ -707,5 +707,4 @@ _Parameters_ Action triggered to undo the last edit to an entity record, if any. - diff --git a/packages/a11y/README.md b/packages/a11y/README.md index f233027d56f408..b0a51047c73dc4 100644 --- a/packages/a11y/README.md +++ b/packages/a11y/README.md @@ -42,7 +42,6 @@ _Parameters_ - _message_ `string`: The message to be announced by assistive technologies. - _ariaLive_ `[string]`: The politeness level for aria-live; default: 'polite'. - ### Background diff --git a/packages/autop/README.md b/packages/autop/README.md index 2968ace936b3aa..1bc8b5495db6c1 100644 --- a/packages/autop/README.md +++ b/packages/autop/README.md @@ -62,7 +62,6 @@ _Returns_ - `string`: The content with stripped paragraph tags. -

Code is Poetry.

diff --git a/packages/blob/README.md b/packages/blob/README.md index c8da2a0f36d2aa..2ae25831b3846e 100644 --- a/packages/blob/README.md +++ b/packages/blob/README.md @@ -74,7 +74,6 @@ _Parameters_ - _url_ `string`: The blob URL. -

Code is Poetry.

diff --git a/packages/block-directory/README.md b/packages/block-directory/README.md index 95ed65f00ac181..35d58dd5b5e2a7 100644 --- a/packages/block-directory/README.md +++ b/packages/block-directory/README.md @@ -125,8 +125,8 @@ Returns an action object used to indicate install in progress. _Parameters_ -- _blockId_ `string`: -- _isInstalling_ `boolean`: +- _blockId_ `string`: +- _isInstalling_ `boolean`: _Returns_ @@ -251,7 +251,6 @@ _Returns_ - `boolean`: Whether a request is in progress for the blocks list. -

Code is Poetry.

diff --git a/packages/block-editor/README.md b/packages/block-editor/README.md index 0b5ec868655cfc..4dc58c54807546 100644 --- a/packages/block-editor/README.md +++ b/packages/block-editor/README.md @@ -127,7 +127,7 @@ _Related_ _Parameters_ -- _props_ `BlockContextProviderProps`: +- _props_ `BlockContextProviderProps`: ### BlockControls @@ -222,7 +222,7 @@ _Usage_ _Parameters_ -- _props_ `Object`: +- _props_ `Object`: - _props.clientId_ `string`: Client ID of block. _Returns_ @@ -261,7 +261,7 @@ _Related_ ### ButtonBlockerAppender -> **Deprecated** +> **Deprecated** Use `ButtonBlockAppender` instead. @@ -291,12 +291,15 @@ Use this higher-order component to work with a custom set of colors. _Usage_ ```jsx -const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ]; +const CUSTOM_COLORS = [ + { name: 'Red', slug: 'red', color: '#ff0000' }, + { name: 'Blue', slug: 'blue', color: '#0000ff' }, +]; const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS ); // ... export default compose( - withCustomColors( 'backgroundColor', 'borderColor' ), - MyColorfulComponent, + withCustomColors( 'backgroundColor', 'borderColor' ), + MyColorfulComponent ); ``` @@ -359,8 +362,8 @@ _Returns_ ### getFontSize - Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values. - If namedFontSize is undefined or not found in fontSizes an object with just the size value based on customFontSize is returned. +Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values. +If namedFontSize is undefined or not found in fontSizes an object with just the size value based on customFontSize is returned. _Parameters_ @@ -481,7 +484,7 @@ _Related_ ### MultiSelectScrollIntoView -> **Deprecated** +> **Deprecated** Scrolls the multi block selection end into view if not in view already. This is important to do after selection by keyboard. @@ -659,7 +662,7 @@ _Parameters_ - _props_ `Object`: Optional. Props to pass to the element. Must contain the ref if one is defined. - _options_ `Object`: Options for internal use only. -- _options.\_\_unstableIsHtml_ `boolean`: +- _options.\_\_unstableIsHtml_ `boolean`: _Returns_ @@ -728,8 +731,8 @@ _Usage_ ```jsx export default compose( - withColors( 'backgroundColor', { textColor: 'color' } ), - MyColorfulComponent, + withColors( 'backgroundColor', { textColor: 'color' } ), + MyColorfulComponent ); ``` @@ -764,7 +767,6 @@ _Parameters_ - _props_ `Object`: Component properties. - _props.children_ `WPElement`: Children to be rendered. -

Code is Poetry.

diff --git a/packages/block-library/README.md b/packages/block-library/README.md index 9106f9b60e9c21..c10c1a44b27bbc 100644 --- a/packages/block-library/README.md +++ b/packages/block-library/README.md @@ -88,7 +88,6 @@ _Parameters_ - _blocks_ `Array`: An optional array of the core blocks being registered. -

Code is Poetry.

diff --git a/packages/block-serialization-default-parser/README.md b/packages/block-serialization-default-parser/README.md index 491a4de2b6f304..9627f88faed270 100644 --- a/packages/block-serialization-default-parser/README.md +++ b/packages/block-serialization-default-parser/README.md @@ -26,21 +26,27 @@ Input post: ```html -
-
-

Left

-
- - - -
-

Middle

-
- - - -
-
+
+ +
+ +

Left

+ +
+ + + +
+ +

Middle

+ +
+ + + +
+ +
``` @@ -49,49 +55,51 @@ Parsing code: ```js import { parse } from '@wordpress/block-serialization-default-parser'; -parse( post ) === [ - { - blockName: "core/columns", - attrs: { - columns: 3 - }, - innerBlocks: [ - { - blockName: "core/column", - attrs: null, - innerBlocks: [ - { - blockName: "core/paragraph", - attrs: null, - innerBlocks: [], - innerHTML: "\n

Left

\n" - } - ], - innerHTML: '\n
\n' - }, - { - blockName: "core/column", - attrs: null, - innerBlocks: [ - { - blockName: "core/paragraph", - attrs: null, - innerBlocks: [], - innerHTML: "\n

Middle

\n" - } - ], - innerHTML: '\n
\n' - }, - { - blockName: "core/column", - attrs: null, - innerBlocks: [], - innerHTML: '\n
\n' - } - ], - innerHTML: '\n
\n\n\n\n
\n' - } -]; +parse( post ) === + [ + { + blockName: 'core/columns', + attrs: { + columns: 3, + }, + innerBlocks: [ + { + blockName: 'core/column', + attrs: null, + innerBlocks: [ + { + blockName: 'core/paragraph', + attrs: null, + innerBlocks: [], + innerHTML: '\n

Left

\n', + }, + ], + innerHTML: '\n
\n', + }, + { + blockName: 'core/column', + attrs: null, + innerBlocks: [ + { + blockName: 'core/paragraph', + attrs: null, + innerBlocks: [], + innerHTML: '\n

Middle

\n', + }, + ], + innerHTML: '\n
\n', + }, + { + blockName: 'core/column', + attrs: null, + innerBlocks: [], + innerHTML: '\n
\n', + }, + ], + innerHTML: + '\n
\n\n\n\n
\n', + }, + ]; ``` _Parameters_ @@ -102,7 +110,6 @@ _Returns_ - `Array`: A block-based representation of the input HTML. - ## Theory diff --git a/packages/blocks/README.md b/packages/blocks/README.md index 28f94c1078acac..bf8872d9ce054a 100644 --- a/packages/blocks/README.md +++ b/packages/blocks/README.md @@ -301,8 +301,8 @@ Create a block object from the example API. _Parameters_ -- _name_ `string`: -- _example_ `Object`: +- _name_ `string`: +- _example_ `Object`: _Returns_ @@ -654,7 +654,7 @@ Converts an HTML string to known blocks. Strips everything else. _Parameters_ -- _options_ `Object`: +- _options_ `Object`: - _options.HTML_ `[string]`: The HTML to convert. - _options.plainText_ `[string]`: Plain text version. - _options.mode_ `[string]`: Handle content as blocks or inline content. _ 'AUTO': Decide based on the content passed. _ 'INLINE': Always handle as inline content, and return string. \* 'BLOCKS': Always handle as blocks, and return array of blocks. @@ -671,7 +671,7 @@ Converts an HTML string to known blocks. _Parameters_ -- _$1_ `Object`: +- _$1_ `Object`: - _$1.HTML_ `string`: The HTML to convert. _Returns_ @@ -866,7 +866,6 @@ _Returns_ - `WPComponent`: Enhanced component with injected BlockContent as prop. -

Code is Poetry.

diff --git a/packages/compose/README.md b/packages/compose/README.md index a1cf52195fff49..a14873b331aefb 100644 --- a/packages/compose/README.md +++ b/packages/compose/README.md @@ -96,7 +96,9 @@ _Usage_ ```ts type Props = { foo: string }; const Component = ( props: Props ) =>
{ props.foo }
; -const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component ); +const ConditionalComponent = ifCondition( + ( props: Props ) => props.foo.length !== 0 +)( Component ); ; // => null ; // =>
bar
; ``` @@ -142,14 +144,14 @@ _Usage_ import { useConstrainedTabbing } from '@wordpress/compose'; const ConstrainedTabbingExample = () => { - const constrainedTabbingRef = useConstrainedTabbing() - return ( -
-
- ); -} + const constrainedTabbingRef = useConstrainedTabbing(); + return ( +
+
+ ); +}; ``` _Returns_ @@ -158,7 +160,7 @@ _Returns_ ### useCopyOnClick -> **Deprecated** +> **Deprecated** Copies the text to the clipboard when the element is clicked. @@ -216,14 +218,14 @@ _Usage_ import { useFocusOnMount } from '@wordpress/compose'; const WithFocusOnMount = () => { - const ref = useFocusOnMount() - return ( -
-
- ); -} + const ref = useFocusOnMount(); + return ( +
+
+ ); +}; ``` _Parameters_ @@ -247,14 +249,14 @@ _Usage_ import { useFocusReturn } from '@wordpress/compose'; const WithFocusReturn = () => { - const ref = useFocusReturn() - return ( -
-
- ); -} + const ref = useFocusReturn(); + return ( +
+
+ ); +}; ``` _Parameters_ @@ -480,10 +482,10 @@ this is useful in performance related work, to check why a component re-renders. _Usage_ ```jsx -function MyComponent(props) { - useWarnOnChange(props); +function MyComponent( props ) { + useWarnOnChange( props ); - return "Something"; + return 'Something'; } ``` @@ -494,7 +496,7 @@ _Parameters_ ### withGlobalEvents -> **Deprecated** +> **Deprecated** Higher-order component creator which, given an object of DOM event types and values corresponding to a callback function name on the component, will @@ -544,7 +546,6 @@ _Returns_ - `any`: A higher order component wrapper accepting a component that takes the state props + its own props + `setState` and returning a component that only accepts the own props. -

Code is Poetry.

diff --git a/packages/core-data/README.md b/packages/core-data/README.md index 4e543905c563fd..ac93d0966542a3 100644 --- a/packages/core-data/README.md +++ b/packages/core-data/README.md @@ -745,7 +745,6 @@ _Returns_ - `boolean`: Whether the entity record is saving or not. -

Code is Poetry.

diff --git a/packages/data-controls/README.md b/packages/data-controls/README.md index c5988331f47c2b..3089cf5c2a4c3c 100644 --- a/packages/data-controls/README.md +++ b/packages/data-controls/README.md @@ -64,11 +64,11 @@ import * as actions from './actions'; import * as resolvers from './resolvers'; registerStore( 'my-custom-store', { -reducer, -controls, -actions, -selectors, -resolvers, + reducer, + controls, + actions, + selectors, + resolvers, } ); ``` @@ -103,5 +103,4 @@ _Parameters_ - _args_ `Array`: Arguments passed without change to the `@wordpress/data` control. - diff --git a/packages/data/README.md b/packages/data/README.md index c4f73bee7d8dda..bd6a5ce50cffc3 100644 --- a/packages/data/README.md +++ b/packages/data/README.md @@ -275,19 +275,19 @@ _Usage_ import { useSelect, AsyncModeProvider } from '@wordpress/data'; function BlockCount() { - const count = useSelect( ( select ) => { - return select( 'core/block-editor' ).getBlockCount() - }, [] ); + const count = useSelect( ( select ) => { + return select( 'core/block-editor' ).getBlockCount(); + }, [] ); - return count; + return count; } function App() { - return ( - - - - ); + return ( + + + + ); } ``` @@ -315,18 +315,16 @@ _Usage_ import { combineReducers, createReduxStore, register } from '@wordpress/data'; const prices = ( state = {}, action ) => { - return action.type === 'SET_PRICE' ? - { - ...state, - [ action.item ]: action.price, - } : - state; + return action.type === 'SET_PRICE' + ? { + ...state, + [ action.item ]: action.price, + } + : state; }; const discountPercent = ( state = 0, action ) => { - return action.type === 'START_SALE' ? - action.discountPercent : - state; + return action.type === 'START_SALE' ? action.discountPercent : state; }; const store = createReduxStore( 'my-shop', { @@ -361,10 +359,10 @@ _Usage_ import { createReduxStore } from '@wordpress/data'; const store = createReduxStore( 'demo', { - reducer: ( state = 'OK' ) => state, - selectors: { - getValue: ( state ) => state, - }, + reducer: ( state = 'OK' ) => state, + selectors: { + getValue: ( state ) => state, + }, } ); ``` @@ -397,13 +395,13 @@ Creates a control function that takes additional curried argument with the `regi While a regular control has signature ```js -( action ) => ( iteratorOrPromise ) +( action ) => iteratorOrPromise; ``` where the control works with the `action` that it's bound to, a registry control has signature: ```js -( registry ) => ( action ) => ( iteratorOrPromise ) +( registry ) => ( action ) => iteratorOrPromise; ``` A registry control is typically used to select data or dispatch an action to a registered @@ -426,14 +424,14 @@ Creates a selector function that takes additional curried argument with the registry `select` function. While a regular selector has signature ```js -( state, ...selectorArgs ) => ( result ) +( state, ...selectorArgs ) => result; ``` that allows to select data from the store's `state`, a registry selector has signature: ```js -( select ) => ( state, ...selectorArgs ) => ( result ) +( select ) => ( state, ...selectorArgs ) => result; ``` that supports also selecting from other registered stores. @@ -442,14 +440,18 @@ _Usage_ ```js const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => { - return select( 'core/editor' ).getCurrentPostId(); + return select( 'core/editor' ).getCurrentPostId(); } ); const getPostEdits = createRegistrySelector( ( select ) => ( state ) => { - // calling another registry selector just like any other function - const postType = getCurrentPostType( state ); - const postId = getCurrentPostId( state ); - return select( 'core' ).getEntityRecordEdits( 'postType', postType, postId ); + // calling another registry selector just like any other function + const postType = getCurrentPostType( state ); + const postId = getCurrentPostId( state ); + return select( 'core' ).getEntityRecordEdits( + 'postType', + postType, + postId + ); } ); ``` @@ -512,10 +514,10 @@ _Usage_ import { createReduxStore, register } from '@wordpress/data'; const store = createReduxStore( 'demo', { - reducer: ( state = 'OK' ) => state, - selectors: { - getValue: ( state ) => state, - }, + reducer: ( state = 'OK' ) => state, + selectors: { + getValue: ( state ) => state, + }, } ); register( store ); ``` @@ -603,7 +605,7 @@ _Usage_ ```js import { resolveSelect } from '@wordpress/data'; -resolveSelect( 'my-shop' ).getPrice( 'hammer' ).then(console.log) +resolveSelect( 'my-shop' ).getPrice( 'hammer' ).then( console.log ); ``` _Parameters_ @@ -688,21 +690,25 @@ import { useDispatch, useSelect } from '@wordpress/data'; import { useCallback } from '@wordpress/element'; function Button( { onClick, children } ) { - return + return ( + + ); } const SaleButton = ( { children } ) => { - const { stockNumber } = useSelect( - ( select ) => select( 'my-shop' ).getStockNumber(), - [] - ); - const { startSale } = useDispatch( 'my-shop' ); - const onClick = useCallback( () => { - const discountPercent = stockNumber > 50 ? 10: 20; - startSale( discountPercent ); - }, [ stockNumber ] ); - return -} + const { stockNumber } = useSelect( + ( select ) => select( 'my-shop' ).getStockNumber(), + [] + ); + const { startSale } = useDispatch( 'my-shop' ); + const onClick = useCallback( () => { + const discountPercent = stockNumber > 50 ? 10 : 20; + startSale( discountPercent ); + }, [ stockNumber ] ); + return ; +}; // Rendered somewhere in the application: // @@ -729,30 +735,27 @@ It acts similarly to the `useContext` react hook. Note: Generally speaking, `useRegistry` is a low level hook that in most cases won't be needed for implementation. Most interactions with the `@wordpress/data` -API can be performed via the `useSelect` hook, or the `withSelect` and +API can be performed via the `useSelect` hook, or the `withSelect` and `withDispatch` higher order components. _Usage_ ```js -import { - RegistryProvider, - createRegistry, - useRegistry, -} from '@wordpress/data'; +import { RegistryProvider, createRegistry, useRegistry } from '@wordpress/data'; const registry = createRegistry( {} ); const SomeChildUsingRegistry = ( props ) => { - const registry = useRegistry( registry ); - // ...logic implementing the registry in other react hooks. + const registry = useRegistry( registry ); + // ...logic implementing the registry in other react hooks. }; - const ParentProvidingRegistry = ( props ) => { - return - - + return ( + + + + ); }; ``` @@ -773,13 +776,16 @@ _Usage_ import { useSelect } from '@wordpress/data'; function HammerPriceDisplay( { currency } ) { - const price = useSelect( ( select ) => { - return select( 'my-shop' ).getPrice( 'hammer', currency ) - }, [ currency ] ); - return new Intl.NumberFormat( 'en-US', { - style: 'currency', - currency, - } ).format( price ); + const price = useSelect( + ( select ) => { + return select( 'my-shop' ).getPrice( 'hammer', currency ); + }, + [ currency ] + ); + return new Intl.NumberFormat( 'en-US', { + style: 'currency', + currency, + } ).format( price ); } // Rendered in the application: @@ -803,12 +809,12 @@ function because your component won't re-render on a data change.** import { useSelect } from '@wordpress/data'; function Paste( { children } ) { - const { getSettings } = useSelect( 'my-shop' ); - function onPaste() { - // Do something with the settings. - const settings = getSettings(); - } - return
{ children }
; + const { getSettings } = useSelect( 'my-shop' ); + function onPaste() { + // Do something with the settings. + const settings = getSettings(); + } + return
{ children }
; } ``` @@ -830,20 +836,24 @@ _Usage_ ```jsx function Button( { onClick, children } ) { - return ; + return ( + + ); } import { withDispatch } from '@wordpress/data'; const SaleButton = withDispatch( ( dispatch, ownProps ) => { - const { startSale } = dispatch( 'my-shop' ); - const { discountPercent } = ownProps; - - return { - onClick() { - startSale( discountPercent ); - }, - }; + const { startSale } = dispatch( 'my-shop' ); + const { discountPercent } = ownProps; + + return { + onClick() { + startSale( discountPercent ); + }, + }; } )( Button ); // Rendered in the application: @@ -866,21 +876,25 @@ only. ```jsx function Button( { onClick, children } ) { - return ; + return ( + + ); } import { withDispatch } from '@wordpress/data'; const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => { - // Stock number changes frequently. - const { getStockNumber } = select( 'my-shop' ); - const { startSale } = dispatch( 'my-shop' ); - return { - onClick() { - const discountPercent = getStockNumber() > 50 ? 10 : 20; - startSale( discountPercent ); - }, - }; + // Stock number changes frequently. + const { getStockNumber } = select( 'my-shop' ); + const { startSale } = dispatch( 'my-shop' ); + return { + onClick() { + const discountPercent = getStockNumber() > 50 ? 10 : 20; + startSale( discountPercent ); + }, + }; } )( Button ); // Rendered in the application: @@ -957,7 +971,6 @@ _Returns_ - `WPComponent`: Enhanced component with merged state data props. - ## Going further diff --git a/packages/date/README.md b/packages/date/README.md index aecac2617c7dee..3f6c266aa5b59b 100644 --- a/packages/date/README.md +++ b/packages/date/README.md @@ -129,7 +129,6 @@ _Parameters_ - _dateSettings_ `DateSettings`: Settings, including locale data. -

Code is Poetry.

diff --git a/packages/deprecated/README.md b/packages/deprecated/README.md index 3a2324fd6f1ba8..22fa761c8b942c 100644 --- a/packages/deprecated/README.md +++ b/packages/deprecated/README.md @@ -76,7 +76,6 @@ _Type_ - `Record` -

Code is Poetry.

diff --git a/packages/dom-ready/README.md b/packages/dom-ready/README.md index c0dcecec393335..08ca78f382c756 100644 --- a/packages/dom-ready/README.md +++ b/packages/dom-ready/README.md @@ -25,7 +25,7 @@ _Usage_ ```js import domReady from '@wordpress/dom-ready'; -domReady( function() { +domReady( function () { //do something after DOM loads. } ); ``` @@ -36,8 +36,7 @@ _Parameters_ _Returns_ -- `void`: - +- `void`: diff --git a/packages/dom/README.md b/packages/dom/README.md index fd78e8447b18d4..e6378ae8c98d7c 100644 --- a/packages/dom/README.md +++ b/packages/dom/README.md @@ -156,7 +156,7 @@ _Parameters_ _Returns_ -- `void`: +- `void`: ### isEmpty @@ -242,7 +242,7 @@ _Returns_ _Parameters_ -- _node_ `Node`: +- _node_ `Node`: _Returns_ @@ -306,7 +306,7 @@ _Parameters_ _Returns_ -- `void`: +- `void`: ### removeInvalidHTML @@ -333,7 +333,7 @@ _Parameters_ _Returns_ -- `void`: +- `void`: ### replaceTag @@ -370,7 +370,7 @@ _Parameters_ _Returns_ -- `void`: +- `void`: ### wrap @@ -381,7 +381,6 @@ _Parameters_ - _newNode_ `Element`: The node to insert. - _referenceNode_ `Element`: The node to wrap. -

Code is Poetry.

diff --git a/packages/e2e-test-utils/README.md b/packages/e2e-test-utils/README.md index b307f9fb7ad3ec..7efb106cca124d 100644 --- a/packages/e2e-test-utils/README.md +++ b/packages/e2e-test-utils/README.md @@ -628,14 +628,16 @@ _Usage_ ```js const MOCK_RESPONSES = [ - { - match: isEmbedding( 'https://wordpress.org/gutenberg/handbook/' ), - onRequestMatch: JSONResponse( MOCK_BAD_WORDPRESS_RESPONSE ), - }, - { - match: isEmbedding( 'https://wordpress.org/gutenberg/handbook/block-api/attributes/' ), - onRequestMatch: JSONResponse( MOCK_EMBED_WORDPRESS_SUCCESS_RESPONSE ), - } + { + match: isEmbedding( 'https://wordpress.org/gutenberg/handbook/' ), + onRequestMatch: JSONResponse( MOCK_BAD_WORDPRESS_RESPONSE ), + }, + { + match: isEmbedding( + 'https://wordpress.org/gutenberg/handbook/block-api/attributes/' + ), + onRequestMatch: JSONResponse( MOCK_EMBED_WORDPRESS_SUCCESS_RESPONSE ), + }, ]; setUpResponseMocking( MOCK_RESPONSES ); ``` @@ -768,7 +770,6 @@ _Returns_ - `Promise`: Result of querying. -

Code is Poetry.

diff --git a/packages/edit-post/README.md b/packages/edit-post/README.md index e2c434ab5e279b..9768fe6b6fd211 100644 --- a/packages/edit-post/README.md +++ b/packages/edit-post/README.md @@ -53,20 +53,17 @@ _Usage_ var __ = wp.i18n.__; var PluginBlockSettingsMenuItem = wp.editPost.PluginBlockSettingsMenuItem; -function doOnClick(){ +function doOnClick() { // To be called when the user clicks the menu item. } function MyPluginBlockSettingsMenuItem() { - return wp.element.createElement( - PluginBlockSettingsMenuItem, - { - allowedBlocks: [ 'core/paragraph' ], - icon: 'dashicon-name', - label: __( 'Menu item text' ), - onClick: doOnClick, - } - ); + return wp.element.createElement( PluginBlockSettingsMenuItem, { + allowedBlocks: [ 'core/paragraph' ], + icon: 'dashicon-name', + label: __( 'Menu item text' ), + onClick: doOnClick, + } ); } ``` @@ -75,16 +72,17 @@ function MyPluginBlockSettingsMenuItem() { import { __ } from '@wordpress/i18n'; import { PluginBlockSettingsMenuItem } from '@wordpress/edit-post'; -const doOnClick = ( ) => { - // To be called when the user clicks the menu item. +const doOnClick = () => { + // To be called when the user clicks the menu item. }; const MyPluginBlockSettingsMenuItem = () => ( - + onClick={ doOnClick } + /> ); ``` @@ -127,7 +125,7 @@ function MyDocumentSettingPlugin() { } registerPlugin( 'my-document-setting-plugin', { - render: MyDocumentSettingPlugin + render: MyDocumentSettingPlugin, } ); ``` @@ -137,12 +135,15 @@ import { registerPlugin } from '@wordpress/plugins'; import { PluginDocumentSettingPanel } from '@wordpress/edit-post'; const MyDocumentSettingTest = () => ( - +

My Document Setting Panel

); - registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } ); +registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } ); ``` _Parameters_ @@ -197,10 +198,7 @@ function onButtonClick() { } const MyButtonMoreMenuItem = () => ( - + { __( 'My button title' ) } ); @@ -254,7 +252,7 @@ const MyPluginPostPublishPanel = () => ( title={ __( 'My panel title' ) } initialOpen={ true } > - { __( 'My panel content' ) } + { __( 'My panel content' ) } ); ``` @@ -291,7 +289,7 @@ function MyPluginPostStatusInfo() { className: 'my-plugin-post-status-info', }, __( 'My post status info' ) - ) + ); } ``` @@ -301,9 +299,7 @@ import { __ } from '@wordpress/i18n'; import { PluginPostStatusInfo } from '@wordpress/edit-post'; const MyPluginPostStatusInfo = () => ( - + { __( 'My post status info' ) } ); @@ -355,7 +351,7 @@ const MyPluginPrePublishPanel = () => ( title={ __( 'My panel title' ) } initialOpen={ true } > - { __( 'My panel content' ) } + { __( 'My panel content' ) } ); ``` @@ -379,7 +375,9 @@ It also automatically renders a corresponding `PluginSidebarMenuItem` component If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API: ```js -wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'plugin-name/sidebar-name' ); +wp.data + .dispatch( 'core/edit-post' ) + .openGeneralSidebar( 'plugin-name/sidebar-name' ); ``` _Related_ @@ -398,17 +396,13 @@ var moreIcon = wp.element.createElement( 'svg' ); //... svg element. function MyPluginSidebar() { return el( - PluginSidebar, - { - name: 'my-sidebar', - title: 'My sidebar title', - icon: moreIcon, - }, - el( - PanelBody, - {}, - __( 'My sidebar content' ) - ) + PluginSidebar, + { + name: 'my-sidebar', + title: 'My sidebar title', + icon: moreIcon, + }, + el( PanelBody, {}, __( 'My sidebar content' ) ) ); } ``` @@ -421,14 +415,8 @@ import { PluginSidebar } from '@wordpress/edit-post'; import { more } from '@wordpress/icons'; const MyPluginSidebar = () => ( - - - { __( 'My sidebar content' ) } - + + { __( 'My sidebar content' ) } ); ``` @@ -464,7 +452,7 @@ function MySidebarMoreMenuItem() { icon: moreIcon, }, __( 'My sidebar title' ) - ) + ); } ``` @@ -475,10 +463,7 @@ import { PluginSidebarMoreMenuItem } from '@wordpress/edit-post'; import { more } from '@wordpress/icons'; const MySidebarMoreMenuItem = () => ( - + { __( 'My sidebar title' ) } ); @@ -520,7 +505,6 @@ _Type_ - `Object` -

Code is Poetry.

diff --git a/packages/element/README.md b/packages/element/README.md index 18817a8e49f5de..6dcd2155d44e12 100755 --- a/packages/element/README.md +++ b/packages/element/README.md @@ -278,8 +278,10 @@ _Usage_ import { Platform } from '@wordpress/element'; const placeholderLabel = Platform.select( { - native: __( 'Add media' ), - web: __( 'Drag images, upload new ones or select files from your library.' ), + native: __( 'Add media' ), + web: __( + 'Drag images, upload new ones or select files from your library.' + ), } ); ``` @@ -412,7 +414,6 @@ _Related_ - -

Code is Poetry.

diff --git a/packages/escape-html/README.md b/packages/escape-html/README.md index bc5f76e8c04aca..e1fc36d503fc55 100644 --- a/packages/escape-html/README.md +++ b/packages/escape-html/README.md @@ -129,7 +129,6 @@ _Returns_ - `boolean`: Whether attribute is valid. -

Code is Poetry.

diff --git a/packages/html-entities/README.md b/packages/html-entities/README.md index 189ba24368a134..66d07432f563f2 100644 --- a/packages/html-entities/README.md +++ b/packages/html-entities/README.md @@ -35,7 +35,6 @@ _Returns_ - `string`: The decoded string. -

Code is Poetry.

diff --git a/packages/i18n/README.md b/packages/i18n/README.md index 1f8921c055ab90..548cc5e67d3198 100644 --- a/packages/i18n/README.md +++ b/packages/i18n/README.md @@ -222,7 +222,6 @@ _Returns_ - `string`: Translated text. -

Code is Poetry.

diff --git a/packages/keyboard-shortcuts/README.md b/packages/keyboard-shortcuts/README.md index 5dd1262b1ef6f3..9d62456b0f0627 100644 --- a/packages/keyboard-shortcuts/README.md +++ b/packages/keyboard-shortcuts/README.md @@ -38,7 +38,6 @@ _Parameters_ - _callback_ `Function`: Shortcut callback. - _options_ `Object`: Shortcut options. -

Code is Poetry.

diff --git a/packages/keycodes/README.md b/packages/keycodes/README.md index 27cfd074d14304..defcc8fff3893d 100644 --- a/packages/keycodes/README.md +++ b/packages/keycodes/README.md @@ -146,7 +146,7 @@ _Usage_ ```js // Assuming macOS: -rawShortcut.primary( 'm' ) +rawShortcut.primary( 'm' ); // "meta+m"" ``` @@ -195,7 +195,6 @@ Keycode for UP key. Keycode for ZERO key. -

Code is Poetry.

diff --git a/packages/plugins/README.md b/packages/plugins/README.md index 6dd7a358b5a553..94f0bd2b0071a2 100644 --- a/packages/plugins/README.md +++ b/packages/plugins/README.md @@ -52,12 +52,7 @@ var el = wp.element.createElement; var PluginArea = wp.plugins.PluginArea; function Layout() { - return el( - 'div', - { scope: 'my-page' }, - 'Content of the page', - PluginArea - ); + return el( 'div', { scope: 'my-page' }, 'Content of the page', PluginArea ); } ``` @@ -128,15 +123,10 @@ import { more } from '@wordpress/icons'; const Component = () => ( <> - + My Sidebar - + Content of the sidebar @@ -199,7 +189,6 @@ _Returns_ - `WPComponent`: Enhanced component with injected context as props. -

Code is Poetry.

diff --git a/packages/priority-queue/README.md b/packages/priority-queue/README.md index ae95e7fab18ab7..43f5f725161895 100644 --- a/packages/priority-queue/README.md +++ b/packages/priority-queue/README.md @@ -34,7 +34,7 @@ const ctx2 = {}; // For a given context in the queue, only the last callback is executed. queue.add( ctx1, () => console.log( 'This will be printed first' ) ); -queue.add( ctx2, () => console.log( 'This won\'t be printed' ) ); +queue.add( ctx2, () => console.log( "This won't be printed" ) ); queue.add( ctx2, () => console.log( 'This will be printed second' ) ); ``` @@ -42,7 +42,6 @@ _Returns_ - `WPPriorityQueue`: Queue object with `add`, `flush` and `reset` methods. -

Code is Poetry.

diff --git a/packages/react-i18n/README.md b/packages/react-i18n/README.md index b1656b7cc8aa47..1386b4c045dce9 100644 --- a/packages/react-i18n/README.md +++ b/packages/react-i18n/README.md @@ -88,7 +88,6 @@ _Returns_ - `FunctionComponent< PropsAndI18n< P > >`: The wrapped component -

Code is Poetry.

diff --git a/packages/redux-routine/README.md b/packages/redux-routine/README.md index 8f79c7cabb4745..d13c2beef56932 100644 --- a/packages/redux-routine/README.md +++ b/packages/redux-routine/README.md @@ -76,7 +76,6 @@ _Returns_ - `import('redux').Middleware`: Co-routine runtime - ## Motivation diff --git a/packages/rich-text/README.md b/packages/rich-text/README.md index 0c987517e5e81f..c3bb074551d202 100644 --- a/packages/rich-text/README.md +++ b/packages/rich-text/README.md @@ -85,7 +85,7 @@ _Parameters_ - _$1.multilineTag_ `[string]`: Multiline tag if the structure is multiline. - _$1.multilineWrapperTags_ `[Array]`: Tags where lines can be found if nesting is possible. - _$1.preserveWhiteSpace_ `[boolean]`: Whether or not to collapse white space characters. -- _$1.\_\_unstableIsEditableTree_ `[boolean]`: +- _$1.\_\_unstableIsEditableTree_ `[boolean]`: _Returns_ @@ -295,7 +295,7 @@ Indices are retrieved from the selection if none are provided. _Parameters_ -- _value_ `RichTextValue`: +- _value_ `RichTextValue`: - _string_ `[number|string]`: Start index, or string at which to split. _Returns_ @@ -365,7 +365,7 @@ to the `Popover` component. _Parameters_ - _$1_ `Object`: Named parameters. -- _$1.ref_ `RefObject`: React ref of the element containing the editable content. +- _$1.ref_ `RefObject`: React ref of the element containing the editable content. - _$1.value_ `RichTextValue`: Value to check for selection. - _$1.settings_ `RichTextFormatType`: The format type's settings. @@ -373,7 +373,6 @@ _Returns_ - `Element|Range`: The active element or selection range. -

Code is Poetry.

diff --git a/packages/shortcode/README.md b/packages/shortcode/README.md index 8816d8abd8928b..fda45bc1e0328b 100644 --- a/packages/shortcode/README.md +++ b/packages/shortcode/README.md @@ -136,13 +136,12 @@ format the shortcode using a `single` tag, and a `content` string. _Parameters_ -- _options_ `Object`: +- _options_ `Object`: _Returns_ - `string`: String representation of the shortcode. -

Code is Poetry.

diff --git a/packages/url/README.md b/packages/url/README.md index 56600098af649e..d6b338071b1b96 100644 --- a/packages/url/README.md +++ b/packages/url/README.md @@ -48,13 +48,13 @@ _Usage_ ```js const queryString = buildQueryString( { - simple: 'is ok', - arrays: [ 'are', 'fine', 'too' ], - objects: { - evenNested: { - ok: 'yes', - }, - }, + simple: 'is ok', + arrays: [ 'are', 'fine', 'too' ], + objects: { + evenNested: { + ok: 'yes', + }, + }, } ); // "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes" ``` @@ -95,8 +95,13 @@ Returns a URL for display. _Usage_ ```js -const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg -const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png +const displayUrl = filterURLForDisplay( + 'https://www.wordpress.org/gutenberg/' +); // wordpress.org/gutenberg +const imageUrl = filterURLForDisplay( + 'https://www.wordpress.org/wp-content/uploads/img.png', + 20 +); // …ent/uploads/img.png ``` _Parameters_ @@ -134,8 +139,12 @@ Returns the fragment part of the URL. _Usage_ ```js -const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment' -const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment' +const fragment1 = getFragment( + 'http://localhost:8080/this/is/a/test?query=true#fragment' +); // '#fragment' +const fragment2 = getFragment( + 'https://wordpress.org#another-fragment?query=true' +); // '#another-fragment' ``` _Parameters_ @@ -172,8 +181,12 @@ Returns the path part and query string part of the URL. _Usage_ ```js -const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true' -const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq' +const pathAndQueryString1 = getPathAndQueryString( + 'http://localhost:8080/this/is/a/test?query=true' +); // '/this/is/a/test?query=true' +const pathAndQueryString2 = getPathAndQueryString( + 'https://wordpress.org/help/faq/' +); // '/help/faq' ``` _Parameters_ @@ -249,7 +262,9 @@ Returns the query string part of the URL. _Usage_ ```js -const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true' +const queryString = getQueryString( + 'http://localhost:8080/this/is/a/test?query=true#fragment' +); // 'query=true' ``` _Parameters_ @@ -440,7 +455,11 @@ Removes arguments from the query string of the url _Usage_ ```js -const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar +const newUrl = removeQueryArgs( + 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', + 'foo', + 'bar' +); // https://wordpress.org?baz=foobar ``` _Parameters_ @@ -484,7 +503,6 @@ _Returns_ - `string`: Decoded URI component if possible. -

Code is Poetry.

diff --git a/packages/viewport/README.md b/packages/viewport/README.md index dbb10ee08844ea..d3c185ae94e25a 100644 --- a/packages/viewport/README.md +++ b/packages/viewport/README.md @@ -108,9 +108,7 @@ _Usage_ ```jsx function MyComponent( { isMobile } ) { - return ( -
Currently: { isMobile ? 'Mobile' : 'Not Mobile' }
- ); + return
Currently: { isMobile ? 'Mobile' : 'Not Mobile' }
; } MyComponent = withViewportMatch( { isMobile: '< small' } )( MyComponent ); @@ -124,7 +122,6 @@ _Returns_ - `Function`: Higher-order component. -

Code is Poetry.

diff --git a/packages/warning/README.md b/packages/warning/README.md index 9df545c7a9d7a5..db403d47b28093 100644 --- a/packages/warning/README.md +++ b/packages/warning/README.md @@ -51,7 +51,6 @@ _Parameters_ - _message_ `string`: Message to show in the warning. -

Code is Poetry.

diff --git a/packages/wordcount/README.md b/packages/wordcount/README.md index 4d427f2ed3e42a..7f8ee0b094b792 100644 --- a/packages/wordcount/README.md +++ b/packages/wordcount/README.md @@ -24,7 +24,7 @@ _Usage_ ```js import { count } from '@wordpress/wordcount'; -const numberOfWords = count( 'Words to count', 'words', {} ) +const numberOfWords = count( 'Words to count', 'words', {} ); ``` _Parameters_ @@ -37,7 +37,6 @@ _Returns_ - `number`: The word or character count. -

Code is Poetry.