Skip to content

Commit

Permalink
Add JS Doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishit30G committed Jan 1, 2025
1 parent a913e5f commit 0a0b3da
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
23 changes: 23 additions & 0 deletions packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,33 @@ Undocumented declaration.

### ObserveTyping

ObserveTyping component sets and removes the `isTyping` flag based on user actions.

_Related_

- <https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/observe-typing/README.md>

_Usage_

```jsx
function Example(){
return (
<ObserveTyping>
<MyInput/>
<ObserveTyping/>
);
}
```

_Parameters_

- _props_ `Object`:
- _props.children_ `JSX.Element`: The children to observe typing on.

_Returns_

- `Element`: The ObserveTyping component.

### PanelColorSettings

Undocumented declaration.
Expand Down
24 changes: 21 additions & 3 deletions packages/block-editor/src/components/observe-typing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,29 @@ export function useTypingObserver() {
return useMergeRefs( [ ref1, ref2 ] );
}

/**
* ObserveTyping component sets and removes the `isTyping` flag based on user actions.
*
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/observe-typing/README.md
*
* @example
* ```jsx
* function Example(){
* return (
* <ObserveTyping>
* <MyInput/>
* <ObserveTyping/>
* );
* }
* ```
*
* @param {Object} props
* @param {JSX.Element} props.children The children to observe typing on.
*
* @return {Element} The ObserveTyping component.
*/
function ObserveTyping( { children } ) {
return <div ref={ useTypingObserver() }>{ children }</div>;
}

/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/observe-typing/README.md
*/
export default ObserveTyping;

0 comments on commit 0a0b3da

Please sign in to comment.