Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use @typedef to document mode param
  • Loading branch information
noisysocks committed May 23, 2023
commit 8162afef4f40d8d9305433f626c34d13f08a6bef
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { store as blockEditorStore } from '../../store';
import { unlock } from '../../lock-unlock';
import { BlockListBlockContext } from '../block-list/block';

/**
* @typedef {'disabled'|'contentOnly'|'default'} BlockEditingMode
*/

/**
* Allows a block to restrict the user interface that is displayed for editing
* that block and its inner blocks.
Expand All @@ -36,11 +40,10 @@ import { BlockListBlockContext } from '../block-list/block';
*
* If called outside of a block context, the mode is applied to all blocks.
*
* @param {?string} mode The editing mode to apply. If undefined, the current
* editing mode is not changed. One of `'disabled'`,
* `'contentOnly'`, or `'default'`.
* @param {?BlockEditingMode} mode The editing mode to apply. If undefined, the
* current editing mode is not changed.
*
* @return {string} The current editing mode.
* @return {BlockEditingMode} The current editing mode.
*/
export function useBlockEditingMode( mode ) {
const { clientId = '' } = useContext( BlockListBlockContext ) ?? {};
Expand Down
10 changes: 7 additions & 3 deletions packages/block-editor/src/store/private-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,18 @@ export function showBlockInterface() {
};
}

/**
* @typedef {import('../components/block-editing-mode').BlockEditingMode} BlockEditingMode
*/

/**
* Sets the block editing mode for a given block.
*
* @see useBlockEditingMode
*
* @param {string} clientId The block client ID, or `''` for the root container.
* @param {string} mode The block editing mode. One of `'disabled'`,
* `'contentOnly'`, or `'default'`.
* @param {string} clientId The block client ID, or `''` for the root container.
* @param {BlockEditingMode} mode The block editing mode. One of `'disabled'`,
* `'contentOnly'`, or `'default'`.
*
* @return {Object} Action object.
*/
Expand Down
8 changes: 6 additions & 2 deletions packages/block-editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export function getLastInsertedBlocksClientIds( state ) {
return state?.lastBlockInserted?.clientIds;
}

/**
* @typedef {import('../components/block-editing-mode').BlockEditingMode} BlockEditingMode
*/

/**
* Returns the block editing mode for a given block.
*
Expand All @@ -64,8 +68,8 @@ export function getLastInsertedBlocksClientIds( state ) {
* @param {Object} state Global application state.
* @param {string} clientId The block client ID, or `''` for the root container.
*
* @return {string} The block editing mode. One of `'disabled'`,
* `'contentOnly'`, or `'default'`.
* @return {BlockEditingMode} The block editing mode. One of `'disabled'`,
* `'contentOnly'`, or `'default'`.
*/
export const getBlockEditingMode = createRegistrySelector(
( select ) =>
Expand Down