Skip to content

Commit

Permalink
Block Editor: Document block selection state object
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jul 1, 2019
1 parent 81e04f3 commit 0be9fea
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,27 @@ export function isCaretWithinFormattedText( state = false, action ) {
}

const BLOCK_SELECTION_EMPTY_OBJECT = {};

/**
* Initial state object for block selection.
*
* @property {Object} start Block anchor from which the selection
* begins.
* @property {Object} end Block extent to which the selection
* ends.
* @property {boolean} isMultiSelecting Flag representing whether a multi-
* selection interaction is in progress.
* @property {boolean} isEnabled Flag representing whether multi-
* selection is currently allowed.
* @property {number?} initialPosition For a changed selection, the position
* at which the caret should be placed.
* Either null (default position) or -1
* (at the end of the block).
*
* @typedef {WPBlockSelectionState}
*
* @type {Object}
*/
const BLOCK_SELECTION_INITIAL_STATE = {
start: BLOCK_SELECTION_EMPTY_OBJECT,
end: BLOCK_SELECTION_EMPTY_OBJECT,
Expand All @@ -710,10 +731,10 @@ const BLOCK_SELECTION_INITIAL_STATE = {
/**
* Reducer returning the block selection's state.
*
* @param {Object} state Current state.
* @param {WPBlockSelectionState} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
* @return {WPBlockSelectionState} Updated state.
*/
export function blockSelection( state = BLOCK_SELECTION_INITIAL_STATE, action ) {
switch ( action.type ) {
Expand Down

0 comments on commit 0be9fea

Please sign in to comment.