Skip to content

Commit

Permalink
Added documentation for PostTrash & PostTrashCheck TimeToRead `…
Browse files Browse the repository at this point in the history
…TextEditorGlobalKeyboardShortcuts` `PostPublishButtonLabel `Component (#62116)

* Added documentation for PostTrash Component

* Added Documentation for PostTrashCheck component

* Added Documentation for PostPublishButtonLabel TimeToRead and TextEditorGlobalKeyboardShortcuts
  • Loading branch information
narenin authored Jun 14, 2024
1 parent fe61e1d commit 79ffe95
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
27 changes: 23 additions & 4 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1399,11 +1399,24 @@ Undocumented declaration.

### PostTrash

Undocumented declaration.
Displays the Post Trash Button and Confirm Dialog in the Editor.

_Returns_

- `JSX.Element|null`: The rendered PostTrash component.

### PostTrashCheck

Undocumented declaration.
Wrapper component that renders its children only if the post can trashed.

_Parameters_

- _props_ `Object`: - The component props.
- _props.children_ `Element`: - The child components to render.

_Returns_

- `Component|null`: The rendered child components or null if the post can not trashed.

### PostTypeSupportCheck

Expand Down Expand Up @@ -1577,7 +1590,9 @@ _Returns_

### TextEditorGlobalKeyboardShortcuts

Undocumented declaration.
Component handles the global keyboard shortcuts for the Text editor.

It provides functionality for various keyboard shortcuts such as toggling editor mode, toggling distraction-free mode, undo/redo.

### ThemeSupportCheck

Expand All @@ -1595,7 +1610,11 @@ _Returns_

### TimeToRead

Undocumented declaration.
Component for showing Time To Read in Content.

_Returns_

- `JSX.Element`: The rendered TimeToRead component.

### transformStyles

Expand Down
7 changes: 7 additions & 0 deletions packages/editor/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,11 @@ export { default as EditorProvider } from './provider';

export * from './deprecated';
export const VisualEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;

/**
* Component handles the global keyboard shortcuts for the Text editor.
*
* It provides functionality for various keyboard shortcuts such as toggling editor mode,
* toggling distraction-free mode, undo/redo.
*/
export const TextEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
8 changes: 8 additions & 0 deletions packages/editor/src/components/post-trash/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import { store as coreStore } from '@wordpress/core-data';
*/
import { store as editorStore } from '../../store';

/**
* Wrapper component that renders its children only if the post can trashed.
*
* @param {Object} props - The component props.
* @param {Element} props.children - The child components to render.
*
* @return {Component|null} The rendered child components or null if the post can not trashed.
*/
export default function PostTrashCheck( { children } ) {
const { canTrashPost } = useSelect( ( select ) => {
const { isEditedPostNew, getCurrentPostId, getCurrentPostType } =
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/post-trash/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import { useState } from '@wordpress/element';
*/
import { store as editorStore } from '../../store';

/**
* Displays the Post Trash Button and Confirm Dialog in the Editor.
*
* @return {JSX.Element|null} The rendered PostTrash component.
*/
export default function PostTrash() {
const { isNew, isDeleting, postId } = useSelect( ( select ) => {
const store = select( editorStore );
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/time-to-read/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import { store as editorStore } from '../../store';
*/
const AVERAGE_READING_RATE = 189;

/**
* Component for showing Time To Read in Content.
*
* @return {JSX.Element} The rendered TimeToRead component.
*/
export default function TimeToRead() {
const content = useSelect(
( select ) => select( editorStore ).getEditedPostAttribute( 'content' ),
Expand Down

0 comments on commit 79ffe95

Please sign in to comment.